MCPcopy Create free account
hub / github.com/apache/maka / assertExactKeys

Function assertExactKeys

packages/runtime-host/src/protocol/codec.ts:34–49  ·  view source on GitHub ↗
(
  record: Record<string, unknown>,
  label: string,
  keys: readonly string[],
)

Source from the content-addressed store, hash-verified

32}
33
34export function assertExactKeys(
35 record: Record<string, unknown>,
36 label: string,
37 keys: readonly string[],
38): void {
39 const allowed = new Set(keys);
40 if (Object.keys(record).some((key) => !allowed.has(key))) {
41 throw invalidProtocolFrame(`Unknown ${label} field`);
42 }
43 if (
44 Object.keys(record).length !== keys.length ||
45 keys.some((key) => !Object.hasOwn(record, key))
46 ) {
47 throw invalidProtocolFrame(`Invalid ${label} fields`);
48 }
49}
50
51export function requireString(value: unknown, label: string, maxLength: number): string {
52 if (typeof value !== 'string' || value.length === 0 || value.length > maxLength) {

Callers 15

requireExactRecordFunction · 0.85
decodeTurnResumePlanFunction · 0.85
decodeTurnStartResultFunction · 0.85
decodeTurnSnapshotFunction · 0.85
decodeTurnProviderRetryFunction · 0.85
decodeSubscriptionFrameFunction · 0.85
decodeSessionToolEventFunction · 0.85
decodeContentBlockFunction · 0.85

Calls 3

invalidProtocolFrameFunction · 0.85
keysMethod · 0.80
hasMethod · 0.65

Tested by

no test coverage detected