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

Function decodePrefixPosition

packages/core/src/runtime-boundary.ts:383–400  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

381}
382
383function decodePrefixPosition(value: unknown): RuntimePrefixPositionV1 {
384 if (
385 !isRecord(value) ||
386 !hasExactKeys(value, ['lastEventSeq', 'eventCount', 'lastEventId']) ||
387 !Number.isSafeInteger(value.lastEventSeq) ||
388 (value.lastEventSeq as number) <= 0 ||
389 !Number.isSafeInteger(value.eventCount) ||
390 value.eventCount !== value.lastEventSeq ||
391 !isNonEmptyString(value.lastEventId)
392 ) {
393 throw new Error('Invalid RuntimeEvent prefix position');
394 }
395 return {
396 lastEventSeq: value.lastEventSeq as number,
397 eventCount: value.eventCount as number,
398 lastEventId: value.lastEventId,
399 };
400}
401
402function decodeBoundaryDigest(value: unknown): RuntimeBoundaryDigest {
403 if (typeof value !== 'string' || !/^sha256:[0-9a-f]{64}$/.test(value)) {

Callers 1

Calls 3

isRecordFunction · 0.90
hasExactKeysFunction · 0.70
isNonEmptyStringFunction · 0.70

Tested by

no test coverage detected