UNPKG

everything-dev

Version:

A consolidated product package for building Module Federation apps with oRPC APIs.

58 lines (56 loc) • 2.93 kB
const require_services_registry_fastkv = require("./fastkv.cjs"); //#region src/services/registry/pointer.ts /** * The release-pointer plane's pre-cutover wire (sprint registry-primitive, * ticket 05). The key model (keys.ts) speaks the post-cutover wire — * `manifest.json`, `versions/<v>.json`, `deploys/<ts>.json` — but the train * still writes and the rollback still reads the old keys. Until ticket 10's * cutover, THIS file is the only place the old wire keys are derived; every * consumer derives them through here so the flip is one file. * * TODO(cutover): delete the templates below and re-point the helpers onto * keyPathOf({ kind: "manifest" | "version" | "deployRecord", ... }). */ /** The pointer key relative to `apps/<account>/<gateway>/` — the form * `fetchRegistryKey` takes (it wraps with the runtime prefix) and the form * the history endpoint's `keyPath` parameter takes. The full-key helpers * below are derived from these — one derivation per wire key, so ticket 10's * cutover flips this file and nothing else. */ const MANIFEST_TAG_REL_KEY = "manifest.json"; function getVersionRelKey(version) { return `versions/${version}.json`; } function getManifestKey(accountId, gatewayId) { return `apps/${accountId}/${gatewayId}/${MANIFEST_TAG_REL_KEY}`; } function getVersionKey(accountId, gatewayId, version) { return `apps/${accountId}/${gatewayId}/${getVersionRelKey(version)}`; } /** The per-deploy audit record's key — the timestamp is munged into a * FastKV-safe path form. */ function deployAuditKeyOf(accountId, gatewayId, publishedAt) { return `apps/${accountId}/${gatewayId}/deploys/${publishedAt.replace(/[:.]/g, "-")}.json`; } /** The release classifier's pointer read: absent (null) means no release has * published; a read failure throws — an unknown state must never silently * classify a release as non-release. The keyPath is RELATIVE — * `fetchRegistryKey` wraps it with the runtime prefix (a full key here * double-prefixes the wire key and reads a key that can never exist). */ function readManifestTag(accountId, gatewayId, registry) { return require_services_registry_fastkv.fetchRegistryKey(accountId, gatewayId, MANIFEST_TAG_REL_KEY, registry); } /** The release leg's immutability check: the version record must either be * absent or hold byte-identical content — a divergent republish is a burned * version. */ function readVersionRecord(accountId, gatewayId, version, registry) { return require_services_registry_fastkv.fetchRegistryKey(accountId, gatewayId, getVersionRelKey(version), registry); } //#endregion exports.MANIFEST_TAG_REL_KEY = MANIFEST_TAG_REL_KEY; exports.deployAuditKeyOf = deployAuditKeyOf; exports.getManifestKey = getManifestKey; exports.getVersionKey = getVersionKey; exports.getVersionRelKey = getVersionRelKey; exports.readManifestTag = readManifestTag; exports.readVersionRecord = readVersionRecord; //# sourceMappingURL=pointer.cjs.map