Skip to content

Commit 40f4e39

Browse files
committed
fix(build): align protocol registry with main
1 parent bec309f commit 40f4e39

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎packages/gateway-protocol/src/schema/protocol-schemas.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { SessionLifecycleProtocolSchemas } from "./protocol-schema-fragment-sess
1717
import { TransportProtocolSchemas } from "./protocol-schema-fragment-transport.js";
1818

1919
/** Public schema registry keyed by stable protocol schema name. */
20-
// Named fragment types keep declaration emit below the compiler's serialization limit.
20+
// Named fragment types avoid expanding every schema during declaration emission.
2121
export const ProtocolSchemas: typeof BoardProtocolSchemas &
2222
typeof ProgressCardProtocolSchemas &
2323
typeof TransportProtocolSchemas &

‎scripts/check-protocol-registry.mts‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,24 @@ check(
3939
);
4040

4141
const composition = registrySource.match(
42-
/export const ProtocolSchemas: ([\s\S]*?) = composeProtocolSchemaFragments\(\[([\s\S]*?)\]\s+as const\);/u,
42+
/export const ProtocolSchemas:\s*([\s\S]*?)\s*= composeProtocolSchemaFragments\(\[([\s\S]*?)\]\s+as const\);/u,
4343
);
44-
const declaredBindings = (composition?.[1] ?? "")
45-
.split("&")
46-
.map((type) => type.trim().replace(/^typeof\s+/u, ""));
4744
const composedBindings = (composition?.[2] ?? "")
4845
.split("\n")
4946
.map((line) => line.trim().replace(/,$/u, ""))
5047
.filter(Boolean);
48+
const annotatedBindings = (composition?.[1] ?? "")
49+
.split("&")
50+
.map((type) => /^typeof ([A-Za-z0-9_]+)$/u.exec(type.trim())?.[1]);
5151
const importedBindings = fragmentImports.map(({ binding }) => binding);
52-
check(Boolean(composition), `${registryPath} must explicitly compose an ordered fragment array`);
5352
check(
54-
JSON.stringify(declaredBindings) === JSON.stringify(composedBindings),
55-
`${registryPath} must declare the same named fragment types as its composition`,
53+
Boolean(composition),
54+
`${registryPath} must explicitly type and compose an ordered fragment array`,
55+
);
56+
check(
57+
annotatedBindings.length === composedBindings.length &&
58+
annotatedBindings.every((binding, index) => binding === composedBindings[index]),
59+
`${registryPath} must annotate the composed fragments with their exact ordered typeof intersection`,
5660
);
5761
check(
5862
composedBindings.length === importedBindings.length &&

0 commit comments

Comments
 (0)