{"version":3,"file":"pointer.mjs","names":[],"sources":["../../../src/services/registry/pointer.ts"],"sourcesContent":["/**\n * The release-pointer plane's pre-cutover wire (sprint registry-primitive,\n * ticket 05). The key model (keys.ts) speaks the post-cutover wire —\n * `manifest.json`, `versions/<v>.json`, `deploys/<ts>.json` — but the train\n * still writes and the rollback still reads the old keys. Until ticket 10's\n * cutover, THIS file is the only place the old wire keys are derived; every\n * consumer derives them through here so the flip is one file.\n *\n * TODO(cutover): delete the templates below and re-point the helpers onto\n * keyPathOf({ kind: \"manifest\" | \"version\" | \"deployRecord\", ... }).\n */\nimport { fetchRegistryKey } from \"./fastkv\";\n\n/** The pointer key relative to `apps/<account>/<gateway>/` — the form\n * `fetchRegistryKey` takes (it wraps with the runtime prefix) and the form\n * the history endpoint's `keyPath` parameter takes. The full-key helpers\n * below are derived from these — one derivation per wire key, so ticket 10's\n * cutover flips this file and nothing else. */\nexport const PLATFORM_POINTER_REL_KEY = \"platform.json\";\n\nexport function platformVersionSlotRelKeyOf(version: string): string {\n  return `platform-versions/${version}.json`;\n}\n\nexport function platformPointerKeyOf(accountId: string, gatewayId: string): string {\n  return `apps/${accountId}/${gatewayId}/${PLATFORM_POINTER_REL_KEY}`;\n}\n\nexport function platformVersionSlotKeyOf(\n  accountId: string,\n  gatewayId: string,\n  version: string,\n): string {\n  return `apps/${accountId}/${gatewayId}/${platformVersionSlotRelKeyOf(version)}`;\n}\n\n/** The per-deploy audit record's key — the timestamp is munged into a\n * FastKV-safe path form. */\nexport function deployAuditKeyOf(\n  accountId: string,\n  gatewayId: string,\n  publishedAt: string,\n): string {\n  return `apps/${accountId}/${gatewayId}/manifests/${publishedAt.replace(/[:.]/g, \"-\")}.json`;\n}\n\n/** The release classifier's pointer read: absent (null) means no release has\n * published; a read failure throws — an unknown state must never silently\n * classify a release as non-release. The keyPath is RELATIVE —\n * `fetchRegistryKey` wraps it with the runtime prefix (a full key here\n * double-prefixes the wire key and reads a slot that can never exist). */\nexport function readPlatformPointer<T>(\n  accountId: string,\n  gatewayId: string,\n  registry?: string,\n): Promise<T | null> {\n  return fetchRegistryKey<T>(accountId, gatewayId, PLATFORM_POINTER_REL_KEY, registry);\n}\n\n/** The release leg's immutability check: the version slot must either be\n * absent or hold byte-identical content — a divergent republish is a burned\n * version. */\nexport function readPlatformVersionSlot<T>(\n  accountId: string,\n  gatewayId: string,\n  version: string,\n  registry?: string,\n): Promise<T | null> {\n  return fetchRegistryKey<T>(accountId, gatewayId, platformVersionSlotRelKeyOf(version), registry);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,MAAa,2BAA2B;AAExC,SAAgB,4BAA4B,SAAyB;CACnE,OAAO,qBAAqB,QAAQ;AACtC;AAEA,SAAgB,qBAAqB,WAAmB,WAA2B;CACjF,OAAO,QAAQ,UAAU,GAAG,UAAU,GAAG;AAC3C;AAEA,SAAgB,yBACd,WACA,WACA,SACQ;CACR,OAAO,QAAQ,UAAU,GAAG,UAAU,GAAG,4BAA4B,OAAO;AAC9E;;;AAIA,SAAgB,iBACd,WACA,WACA,aACQ;CACR,OAAO,QAAQ,UAAU,GAAG,UAAU,aAAa,YAAY,QAAQ,SAAS,GAAG,EAAE;AACvF;;;;;;AAOA,SAAgB,oBACd,WACA,WACA,UACmB;CACnB,OAAO,iBAAoB,WAAW,WAAW,0BAA0B,QAAQ;AACrF;;;;AAKA,SAAgB,wBACd,WACA,WACA,SACA,UACmB;CACnB,OAAO,iBAAoB,WAAW,WAAW,4BAA4B,OAAO,GAAG,QAAQ;AACjG"}