Skip to content

Commit 8bbb86f

Browse files
committed
refactor(sdk-runner): reuse isSpecVersion for specOverrides key validation
Reuses the canonical spec-version list from #421 instead of keeping a separate copy; SPEC_VERSION_TIMELINE is now exported so the validation message can enumerate the valid keys.
1 parent 19f0d12 commit 8bbb86f

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/sdk-runner/config.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { z } from 'zod';
2-
import { DATED_SPEC_VERSIONS, DRAFT_PROTOCOL_VERSION } from '../types';
2+
import {
3+
DRAFT_PROTOCOL_VERSION,
4+
SPEC_VERSION_TIMELINE,
5+
isSpecVersion
6+
} from '../types';
37

48
// Fields an entry may vary per targeted spec version. Identity fields
59
// (repo / defaultRef / specVersion) can't vary — they pick what to clone,
@@ -24,11 +28,6 @@ const SpecOverrideSchema = z.object({
2428

2529
export type SpecOverride = z.infer<typeof SpecOverrideSchema>;
2630

27-
const VALID_OVERRIDE_KEYS: readonly string[] = [
28-
...DATED_SPEC_VERSIONS,
29-
DRAFT_PROTOCOL_VERSION
30-
];
31-
3231
export const SdkConfigSchema = z.object({
3332
// Clone this repo instead of the KNOWN_SDKS key — lets an alias entry
3433
// (e.g. typescript-sdk-v1) point at the real repo (typescript-sdk).
@@ -67,12 +66,12 @@ export const SdkConfigSchema = z.object({
6766
// date) would silently never match, because the requested version is
6867
// resolved to its dated form before the lookup.
6968
for (const key of Object.keys(overrides)) {
70-
if (!VALID_OVERRIDE_KEYS.includes(key)) {
69+
if (!isSpecVersion(key)) {
7170
ctx.addIssue({
7271
code: z.ZodIssueCode.custom,
7372
message:
7473
`specOverrides key '${key}' is not a spec version. ` +
75-
`Use one of: ${VALID_OVERRIDE_KEYS.join(', ')} ` +
74+
`Use one of: ${SPEC_VERSION_TIMELINE.join(', ')} ` +
7675
`('draft' resolves to ${DRAFT_PROTOCOL_VERSION} before lookup, so key the dated form).`
7776
});
7877
}

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const NEGOTIABLE_PROTOCOL_VERSIONS: readonly string[] = [
6464
export type SpecVersion = DatedSpecVersion | typeof DRAFT_PROTOCOL_VERSION;
6565

6666
/** Spec versions in timeline order, dated revisions followed by the draft. */
67-
const SPEC_VERSION_TIMELINE: readonly SpecVersion[] = [
67+
export const SPEC_VERSION_TIMELINE: readonly SpecVersion[] = [
6868
...DATED_SPEC_VERSIONS,
6969
DRAFT_PROTOCOL_VERSION
7070
];

0 commit comments

Comments
 (0)