@_linked/translation 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +15 -16
  2. package/lib/esm/archive.d.ts +2 -2
  3. package/lib/esm/archive.js +2 -2
  4. package/lib/esm/archive.js.map +1 -1
  5. package/lib/esm/authorization.d.ts +1 -1
  6. package/lib/esm/authorization.js +1 -1
  7. package/lib/esm/authorization.js.map +1 -1
  8. package/lib/esm/cdn-loader.d.ts +1 -1
  9. package/lib/esm/cdn-loader.js.map +1 -1
  10. package/lib/esm/core/messages.d.ts +14 -1
  11. package/lib/esm/core/messages.js +33 -2
  12. package/lib/esm/core/messages.js.map +1 -1
  13. package/lib/esm/exchange.d.ts +1 -1
  14. package/lib/esm/exchange.js +1 -1
  15. package/lib/esm/exchange.js.map +1 -1
  16. package/lib/esm/export.js +4 -1
  17. package/lib/esm/export.js.map +1 -1
  18. package/lib/esm/formats/xliff.js +1 -1
  19. package/lib/esm/formats/xliff.js.map +1 -1
  20. package/lib/esm/key-sync.d.ts +12 -0
  21. package/lib/esm/key-sync.js +32 -7
  22. package/lib/esm/key-sync.js.map +1 -1
  23. package/lib/esm/mt.js +1 -1
  24. package/lib/esm/mt.js.map +1 -1
  25. package/lib/esm/ontologies/translation.d.ts +3 -1
  26. package/lib/esm/ontologies/translation.js +4 -2
  27. package/lib/esm/ontologies/translation.js.map +1 -1
  28. package/lib/esm/react.d.ts +38 -2
  29. package/lib/esm/react.js +98 -15
  30. package/lib/esm/react.js.map +1 -1
  31. package/lib/esm/records.d.ts +2 -1
  32. package/lib/esm/records.js.map +1 -1
  33. package/lib/esm/release.d.ts +3 -1
  34. package/lib/esm/release.js +21 -4
  35. package/lib/esm/release.js.map +1 -1
  36. package/lib/esm/shape-catalog.d.ts +1 -1
  37. package/lib/esm/shape-catalog.js.map +1 -1
  38. package/lib/esm/shapes/TranslationKey.d.ts +10 -5
  39. package/lib/esm/shapes/TranslationKey.js +16 -5
  40. package/lib/esm/shapes/TranslationKey.js.map +1 -1
  41. package/lib/esm/shapes/TranslationProvider.d.ts +25 -8
  42. package/lib/esm/shapes/TranslationProvider.js +50 -19
  43. package/lib/esm/shapes/TranslationProvider.js.map +1 -1
  44. package/package.json +3 -3
  45. package/src/archive.ts +2 -2
  46. package/src/authorization.ts +1 -1
  47. package/src/cdn-loader.ts +1 -1
  48. package/src/core/messages.ts +35 -2
  49. package/src/exchange.ts +1 -1
  50. package/src/export.ts +4 -1
  51. package/src/formats/xliff.ts +1 -1
  52. package/src/key-sync.ts +46 -6
  53. package/src/mt.ts +1 -1
  54. package/src/ontologies/translation.ts +4 -2
  55. package/src/react.tsx +158 -35
  56. package/src/records.ts +2 -1
  57. package/src/release.ts +31 -3
  58. package/src/shape-catalog.ts +1 -1
  59. package/src/shapes/TranslationKey.ts +14 -5
  60. package/src/shapes/TranslationProvider.ts +73 -13
@@ -1,6 +1,6 @@
1
1
  import { runChecks } from './checks.js';
2
2
  import { compileLanguage } from './compile.js';
3
- import { classifyKeyVersion, sha256Hex } from './key-version.js';
3
+ import { classifyKeyVersion, createArgumentSignature, sha256Hex, } from './key-version.js';
4
4
  import { isConfirmedBuildDeclaration, } from './exchange.js';
5
5
  export const DEFAULT_TRANSLATION_MAX_PATCHES = 8;
6
6
  export const DEFAULT_TRANSLATION_PATCH_TO_BASE_RATIO = 0.25;
@@ -37,10 +37,12 @@ export async function translationContractSetHash(entries) {
37
37
  }
38
38
  /**
39
39
  * Resolve keys extracted from one immutable build workspace to graph versions.
40
- * Any missing/orphaned/conflicting/default-drifted key fails before publication.
40
+ * Missing/orphaned/conflicting/default-drifted keys fail before publication.
41
+ * Explicit app-owned declaration overrides may change wording, never the
42
+ * exact workspace's declared format or runtime-argument contract.
41
43
  */
42
44
  export async function buildSnapshotContractSetHash(entries, extracted) {
43
- var _a, _b;
45
+ var _a, _b, _c;
44
46
  const declarations = extracted.filter(isConfirmedBuildDeclaration);
45
47
  const declarationsByKey = new Map();
46
48
  for (const item of declarations) {
@@ -85,7 +87,22 @@ export async function buildSnapshotContractSetHash(entries, extracted) {
85
87
  }
86
88
  const extractedContract = [...distinct.values()][0];
87
89
  const decision = classifyKeyVersion(current, extractedContract);
88
- if (decision.action !== 'unchanged') {
90
+ const explicitDeclarationOverride = entry.overridden === true &&
91
+ !!(entry.ofShape ||
92
+ entry.ofProperty ||
93
+ entry.ofResource ||
94
+ entry.fromPackage);
95
+ // source-changed is reached only AFTER the existing classifier has checked
96
+ // identical format and argument signature. Do not infer the missing format
97
+ // of a legacy extraction from the very app override being verified.
98
+ const compatibleAppWording = explicitDeclarationOverride &&
99
+ decision.reason === 'source-changed' &&
100
+ ((_c = declarationsByKey.get(entry.key)) !== null && _c !== void 0 ? _c : []).every((item) => item.format !== undefined && item.namespace === entry.namespace) &&
101
+ entry.sourceText === current.sourceText &&
102
+ entry.format === current.format &&
103
+ createArgumentSignature(current.sourceText, current.format) ===
104
+ current.argumentSignature;
105
+ if (decision.action !== 'unchanged' && !compatibleAppWording) {
89
106
  throw new Error(`Build translation source for "${entry.key}" does not match its current key version (${decision.reason}).`);
90
107
  }
91
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"release.js","sourceRoot":"","sources":["../../src/release.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAqB,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EACL,2BAA2B,GAE5B,MAAM,eAAe,CAAC;AA4IvB,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,uCAAuC,GAAG,IAAI,CAAC;AAE5D,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAClC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,gFAAgF;A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CAAC,EAAE,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAAE;YAChD,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;IACF,MAAM,YAAY,GAAG,MAAM,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9D,OAAO;QACL,UAAU,EAAE;YACV,aAAa,EAAE,CAAC;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS;YACT,eAAe;YACf,WAAW,EAAE,SAAS,CACpB,KAAK,CAAC,UAAU,EAChB,YAAY,SAAS,gBAAgB,CACtC;SACF;QACD,QAAQ;QACR,YAAY;QACZ,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAAiC,EACjC,KAAyD,EACzD,UAA8C;IAE9C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE;YAC7C,GAAG,KAAK;YACR,SAAS,EAAE,SAAS,CAAC,SAAS;SAC/B,CAAC,CAAC;QACH,IAAI,QAAQ,CAAC,YAAY,KAAK,SAAS,CAAC,YAAY;YAAE,OAAO,QAAQ,CAAC;IACxE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { TranslationLanguageDefinition } from './languages.js';\nimport { runChecks, type CheckFinding } from './checks.js';\nimport { compileLanguage } from './compile.js';\nimport type { TranslationMessages } from './core/messages.js';\nimport { classifyKeyVersion, sha256Hex } from './key-version.js';\nimport {\n isConfirmedBuildDeclaration,\n type TranslationBuildDeclaration,\n} from './exchange.js';\nimport type { GlossaryTermRecord, TranslationEntryRecord } from './records.js';\nimport type { ExtractedTranslationKey } from './key-sync.js';\n\nexport interface TranslationBuildDescriptor {\n schemaVersion: 2;\n appId: string;\n releaseId: string;\n contractSetHash: string;\n manifestUrl: string;\n}\n\n/** Serializable handoff from translation publication to an exact app build. */\nexport interface TranslationBuildPin {\n schemaVersion: 1;\n appId: string;\n branchId: string;\n buildId: string;\n channel: 'preview' | 'production';\n releaseId: string;\n contractSetHash: string;\n manifestHash: string;\n manifestUrl: string;\n /** Sequence baked into the fallback catalogs at build time. */\n hotfixSequence: number;\n catalogs: Record<string, TranslationCatalogObject>;\n pinnedAt: string;\n /** Which declaration source supplied the contract verifier for this build. */\n inventorySource?: 'confirmed-inventory' | 'static-fallback';\n}\n\nexport interface TranslationCatalogObject {\n hash: string;\n url: string;\n bytes: number;\n encoding?: 'gzip';\n}\n\nexport interface TranslationCatalogPatchObject\n extends TranslationCatalogObject {\n sequence: number;\n}\n\nexport interface TranslationQualitySummary {\n errors: number;\n warnings: number;\n rules: Record<string, number>;\n}\n\nexport interface TranslationReleaseManifest {\n languageResources?: TranslationLanguageDefinition[];\n schemaVersion: 2;\n releaseId: string;\n contractSetHash: string;\n hotfixSequence: number;\n revisionWatermark?: string;\n /** Compact release selection index: logical key → exact key-version IRI. */\n keyVersions: Record<string, string>;\n quality: Record<string, TranslationQualitySummary>;\n languages: Record<\n string,\n {\n base: TranslationCatalogObject;\n patches: TranslationCatalogPatchObject[];\n }\n >;\n}\n\nexport interface TranslationCatalogPatch {\n set: TranslationMessages;\n remove?: string[];\n}\n\nexport interface CompileReleaseInput {\n languageResources?: TranslationLanguageDefinition[];\n appId: string;\n branchId: string;\n buildId?: string;\n releaseId?: string;\n publicBase?: string;\n channel?: 'preview' | 'production';\n languages: string[];\n defaultLanguage: string;\n reviewedOnlyLanguages?: Iterable<string>;\n previousRelease?: TranslationReleaseManifest;\n revisionWatermark?: string;\n glossary?: GlossaryTermRecord[];\n allowQualityErrors?: boolean;\n}\n\nexport interface CompiledTranslationRelease {\n descriptor: TranslationBuildDescriptor;\n manifest: TranslationReleaseManifest;\n manifestHash: string;\n immutableObjects: Array<{\n kind: 'base' | 'patch';\n hash: string;\n body: Uint8Array;\n }>;\n}\n\nexport interface TranslationReleaseReuseCandidate {\n releaseId: string;\n manifestHash: string;\n}\n\nexport interface CompiledTranslationHotfix {\n key: string;\n language: string;\n sequence: number;\n patch: TranslationCatalogPatch;\n immutableObject: {\n kind: 'patch';\n hash: string;\n body: Uint8Array;\n };\n manifest: TranslationReleaseManifest;\n}\n\nexport interface CompiledTranslationCompaction {\n language: string;\n immutableObject: {\n kind: 'base';\n hash: string;\n body: Uint8Array;\n };\n manifest: TranslationReleaseManifest;\n}\n\nexport interface TranslationObjectInventoryEntry {\n /** App-relative object name, for example `objects/catalog/<hash>.json`. */\n name: string;\n lastModified?: Date | string;\n}\n\nexport interface TranslationCompactionThresholds {\n maxPatches?: number;\n maxPatchToBaseRatio?: number;\n}\n\nexport const DEFAULT_TRANSLATION_MAX_PATCHES = 8;\nexport const DEFAULT_TRANSLATION_PATCH_TO_BASE_RATIO = 0.25;\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\n/** Recursive canonical JSON used for every content-addressed release object. */\nexport function canonicalJson(value: unknown): string {\n if (value === null || typeof value !== 'object') return JSON.stringify(value);\n if (Array.isArray(value)) return `[${value.map(canonicalJson).join(',')}]`;\n const record = value as Record<string, unknown>;\n return `{${Object.keys(record)\n .sort()\n .map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`)\n .join(',')}}`;\n}\n\nfunction translationContracts(entries: TranslationEntryRecord[]) {\n return entries\n .filter((entry) => entry.kind === 'ui')\n .sort((left, right) => left.key.localeCompare(right.key))\n .map((entry) => ({\n key: entry.key,\n versionId: entry.currentVersion?.id ?? null,\n contractHash: entry.currentVersion?.contractHash ?? null,\n }));\n}\n\n/** The one canonical contract-set hash used by release compile and build pinning. */\nexport async function translationContractSetHash(\n entries: TranslationEntryRecord[]\n): Promise<string> {\n return sha256Hex(canonicalJson(translationContracts(entries)));\n}\n\n/**\n * Resolve keys extracted from one immutable build workspace to graph versions.\n * Any missing/orphaned/conflicting/default-drifted key fails before publication.\n */\nexport async function buildSnapshotContractSetHash(\n entries: TranslationEntryRecord[],\n extracted: Array<ExtractedTranslationKey | TranslationBuildDeclaration>\n): Promise<string> {\n const declarations = extracted.filter(isConfirmedBuildDeclaration);\n const declarationsByKey = new Map<string, TranslationBuildDeclaration[]>();\n for (const item of declarations) {\n const values = declarationsByKey.get(item.key) ?? [];\n values.push(item);\n declarationsByKey.set(item.key, values);\n }\n const selected = entries\n .filter((entry) => entry.kind === 'ui')\n .sort((left, right) => left.key.localeCompare(right.key));\n const graphKeys = new Set(selected.map(({ key }) => key));\n const missing = [...declarationsByKey.keys()]\n .filter((key) => !graphKeys.has(key))\n .sort();\n const orphaned = selected\n .map(({ key }) => key)\n .filter((key) => !declarationsByKey.has(key))\n .sort();\n if (missing.length || orphaned.length) {\n throw new Error(\n `Build translation contract differs from the release: ${\n missing.length ? `missing in graph [${missing.join(', ')}]` : ''\n }${missing.length && orphaned.length ? '; ' : ''}${\n orphaned.length ? `missing in build [${orphaned.join(', ')}]` : ''\n }.`\n );\n }\n\n for (const entry of selected) {\n const current = entry.currentVersion;\n if (!current?.id) {\n throw new Error(\n `Translation key \"${entry.key}\" has no current contract version.`\n );\n }\n const contracts = (declarationsByKey.get(entry.key) ?? []).map(\n (declaration) => ({\n sourceText: declaration.sourceText,\n // Legacy static extraction has no format. Preserve its shipped behavior\n // by resolving against the current graph contract.\n format: declaration.format ?? current.format ?? entry.format,\n })\n );\n const distinct = new Map(\n contracts.map((contract) => [\n canonicalJson([contract.sourceText, contract.format]),\n contract,\n ])\n );\n if (distinct.size > 1) {\n throw new Error(\n `Build translation key \"${entry.key}\" has conflicting source defaults or formats.`\n );\n }\n const extractedContract = [...distinct.values()][0];\n const decision = classifyKeyVersion(current, extractedContract);\n if (decision.action !== 'unchanged') {\n throw new Error(\n `Build translation source for \"${entry.key}\" does not match its current key version (${decision.reason}).`\n );\n }\n }\n return translationContractSetHash(selected);\n}\n\nexport function assertTranslationContractSet(\n buildContractSetHash: string,\n releaseContractSetHash: string\n): void {\n if (buildContractSetHash !== releaseContractSetHash) {\n throw new Error(\n `Build translation contract ${buildContractSetHash} does not match release contract ${releaseContractSetHash}.`\n );\n }\n}\n\n/** Verify immutable catalog bytes before a build adapter writes them. */\nexport async function assertTranslationObjectHash(\n value: string | Uint8Array,\n expectedHash: string\n): Promise<void> {\n const text = typeof value === 'string' ? value : decoder.decode(value);\n const actual = await sha256Hex(text);\n if (actual !== expectedHash) {\n throw new Error(\n `Translation object hash mismatch: expected ${expectedHash}, received ${actual}.`\n );\n }\n}\n\nexport function createTranslationBuildPin(input: {\n descriptor: TranslationBuildDescriptor;\n manifest: TranslationReleaseManifest;\n manifestHash: string;\n branchId: string;\n buildId: string;\n channel: 'preview' | 'production';\n pinnedAt?: string;\n inventorySource?: 'confirmed-inventory' | 'static-fallback';\n}): TranslationBuildPin {\n if (\n input.manifest.releaseId !== input.descriptor.releaseId ||\n input.manifest.contractSetHash !== input.descriptor.contractSetHash\n ) {\n throw new Error(\n 'Translation release descriptor and manifest are incompatible.'\n );\n }\n return {\n schemaVersion: 1,\n appId: input.descriptor.appId,\n branchId: input.branchId,\n buildId: input.buildId,\n channel: input.channel,\n releaseId: input.descriptor.releaseId,\n contractSetHash: input.descriptor.contractSetHash,\n manifestHash: input.manifestHash,\n manifestUrl: input.descriptor.manifestUrl,\n hotfixSequence: input.manifest.hotfixSequence,\n catalogs: Object.fromEntries(\n Object.entries(input.manifest.languages).map(([language, lane]) => [\n language,\n lane.base,\n ])\n ),\n pinnedAt: input.pinnedAt ?? new Date().toISOString(),\n ...(input.inventorySource\n ? { inventorySource: input.inventorySource }\n : {}),\n };\n}\n\nexport function decodeReleaseObject(body: Uint8Array): unknown {\n return JSON.parse(decoder.decode(body));\n}\n\nexport function applyCatalogPatches(\n base: TranslationMessages,\n patches: TranslationCatalogPatch[]\n): TranslationMessages {\n const result: TranslationMessages = { ...base };\n for (const patch of patches) {\n for (const key of patch.remove ?? []) delete result[key];\n Object.assign(result, patch.set);\n }\n return result;\n}\n\nexport function releaseReferencesKeyVersion(\n manifest: TranslationReleaseManifest,\n keyVersionId: string\n): boolean {\n return Object.values(manifest.keyVersions).includes(keyVersionId);\n}\n\nexport function keyForVersion(\n manifest: TranslationReleaseManifest,\n keyVersionId: string\n): string | undefined {\n return Object.entries(manifest.keyVersions).find(\n ([, version]) => version === keyVersionId\n )?.[0];\n}\n\nexport function shouldCompactTranslationLanguage(\n lane: TranslationReleaseManifest['languages'][string],\n thresholds: TranslationCompactionThresholds = {}\n): boolean {\n const maxPatches = thresholds.maxPatches ?? DEFAULT_TRANSLATION_MAX_PATCHES;\n const maxPatchToBaseRatio =\n thresholds.maxPatchToBaseRatio ?? DEFAULT_TRANSLATION_PATCH_TO_BASE_RATIO;\n if (lane.patches.length > maxPatches) return true;\n if (lane.base.bytes <= 0) return lane.patches.length > 0;\n const patchBytes = lane.patches.reduce(\n (total, patch) => total + patch.bytes,\n 0\n );\n return patchBytes > lane.base.bytes * maxPatchToBaseRatio;\n}\n\nfunction publicBaseFromObjectUrl(url: string): string | undefined {\n const marker = '/objects/';\n const index = url.indexOf(marker);\n return index < 0 ? undefined : url.slice(0, index);\n}\n\n/**\n * Replace one eligible patch chain with an equivalent immutable base. The\n * release identity, contract set, and hotfix sequence deliberately do not\n * change because compaction changes representation, not translation content.\n */\nexport async function compileTranslationCompaction(input: {\n manifest: TranslationReleaseManifest;\n language: string;\n currentMessages: TranslationMessages;\n force?: boolean;\n thresholds?: TranslationCompactionThresholds;\n}): Promise<CompiledTranslationCompaction | null> {\n const lane = input.manifest.languages[input.language];\n if (!lane) {\n throw new Error(\n `Release ${input.manifest.releaseId} does not publish ${input.language}.`\n );\n }\n if (\n !input.force &&\n !shouldCompactTranslationLanguage(lane, input.thresholds)\n ) {\n return null;\n }\n if (lane.patches.length === 0) return null;\n\n const body = encoder.encode(canonicalJson(input.currentMessages));\n const hash = await sha256Hex(decoder.decode(body));\n const base: TranslationCatalogObject = {\n hash,\n url: objectUrl(\n publicBaseFromObjectUrl(lane.base.url),\n `objects/catalog/${hash}.json`\n ),\n bytes: body.byteLength,\n };\n return {\n language: input.language,\n immutableObject: { kind: 'base', hash, body },\n manifest: {\n ...input.manifest,\n languages: {\n ...input.manifest.languages,\n [input.language]: {\n base,\n patches: [],\n },\n },\n },\n };\n}\n\nfunction objectNameFromUrl(url: string, fallback: string): string {\n const clean = url.split(/[?#]/, 1)[0].replace(/^\\/+/, '');\n const marker = 'objects/';\n const index = clean.indexOf(marker);\n return index >= 0 ? clean.slice(index) : fallback;\n}\n\n/** Every immutable object directly reachable from the supplied manifests. */\nexport function collectReferencedTranslationObjects(\n manifests: Iterable<TranslationReleaseManifest>\n): Set<string> {\n const referenced = new Set<string>();\n for (const manifest of manifests) {\n for (const lane of Object.values(manifest.languages)) {\n referenced.add(\n objectNameFromUrl(\n lane.base.url,\n `objects/catalog/${lane.base.hash}.json${\n lane.base.encoding === 'gzip' ? '.gz' : ''\n }`\n )\n );\n for (const patch of lane.patches) {\n referenced.add(\n objectNameFromUrl(\n patch.url,\n `objects/patch/${patch.hash}.json${\n patch.encoding === 'gzip' ? '.gz' : ''\n }`\n )\n );\n }\n }\n }\n return referenced;\n}\n\n/**\n * Mark only old, content-addressed objects that are absent from every retained\n * manifest. Unknown timestamps fail closed and remain retained.\n */\nexport function selectPrunableTranslationObjects(input: {\n objects: Iterable<TranslationObjectInventoryEntry>;\n manifests: Iterable<TranslationReleaseManifest>;\n now?: Date | number;\n gracePeriodMs: number;\n}): string[] {\n if (!Number.isFinite(input.gracePeriodMs) || input.gracePeriodMs < 0) {\n throw new Error('gracePeriodMs must be a non-negative finite number.');\n }\n const now =\n input.now instanceof Date ? input.now.getTime() : input.now ?? Date.now();\n const referenced = collectReferencedTranslationObjects(input.manifests);\n const candidates = new Set<string>();\n for (const object of input.objects) {\n const name = object.name.replace(/^\\/+/, '');\n if (\n !/^objects\\/(?:catalog|patch)\\/[^/]+\\.json(?:\\.gz)?$/.test(name) ||\n referenced.has(name) ||\n !object.lastModified\n ) {\n continue;\n }\n const modifiedAt =\n object.lastModified instanceof Date\n ? object.lastModified.getTime()\n : new Date(object.lastModified).getTime();\n if (\n Number.isFinite(modifiedAt) &&\n now - modifiedAt >= input.gracePeriodMs\n ) {\n candidates.add(name);\n }\n }\n return [...candidates].sort();\n}\n\n/**\n * Create one content-addressed language patch and advance a compatible\n * manifest. Returns null for an idempotent re-approval of the current value.\n */\nexport async function compileTranslationHotfix(input: {\n manifest: TranslationReleaseManifest;\n keyVersionId: string;\n language: string;\n text: string;\n currentMessages: TranslationMessages;\n}): Promise<CompiledTranslationHotfix | null> {\n const key = keyForVersion(input.manifest, input.keyVersionId);\n if (!key) {\n throw new Error(\n `Release ${input.manifest.releaseId} does not reference key version ${input.keyVersionId}.`\n );\n }\n const lane = input.manifest.languages[input.language];\n if (!lane) {\n throw new Error(\n `Release ${input.manifest.releaseId} does not publish ${input.language}.`\n );\n }\n const current = input.currentMessages[key];\n const next =\n typeof current === 'object' && current?.format === 'icu'\n ? { message: input.text, format: 'icu' as const }\n : input.text;\n if (canonicalJson(current) === canonicalJson(next)) return null;\n\n const patch: TranslationCatalogPatch = { set: { [key]: next } };\n const body = encoder.encode(canonicalJson(patch));\n const hash = await sha256Hex(decoder.decode(body));\n const sequence = input.manifest.hotfixSequence + 1;\n const publicBase = publicBaseFromObjectUrl(lane.base.url);\n const patchObject: TranslationCatalogPatchObject = {\n hash,\n url: objectUrl(publicBase, `objects/patch/${hash}.json`),\n bytes: body.byteLength,\n sequence,\n };\n return {\n key,\n language: input.language,\n sequence,\n patch,\n immutableObject: { kind: 'patch', hash, body },\n manifest: {\n ...input.manifest,\n hotfixSequence: sequence,\n languages: {\n ...input.manifest.languages,\n [input.language]: {\n ...lane,\n patches: [...lane.patches, patchObject],\n },\n },\n },\n };\n}\n\nfunction qualitySummary(findings: CheckFinding[]): TranslationQualitySummary {\n const rules: Record<string, number> = {};\n let errors = 0;\n let warnings = 0;\n for (const finding of findings) {\n finding.severity === 'error' ? errors++ : warnings++;\n rules[finding.rule] = (rules[finding.rule] ?? 0) + 1;\n }\n return { errors, warnings, rules };\n}\n\nfunction objectUrl(publicBase: string | undefined, path: string): string {\n const base = publicBase?.replace(/\\/+$/, '');\n return base ? `${base}/${path}` : path;\n}\n\n/**\n * Compile one immutable schema-v2 release. The input entries are the captured\n * graph snapshot; callers are responsible for supplying its revision watermark.\n */\nexport async function compileRelease(\n entries: TranslationEntryRecord[],\n input: CompileReleaseInput\n): Promise<CompiledTranslationRelease> {\n const reviewedOnly = new Set(input.reviewedOnlyLanguages ?? []);\n const selected = entries\n .filter((entry) => entry.kind === 'ui')\n .sort((left, right) => left.key.localeCompare(right.key));\n const missingVersion = selected.find((entry) => !entry.currentVersion?.id);\n if (missingVersion) {\n throw new Error(\n `Translation key \"${missingVersion.key}\" has no current contract version.`\n );\n }\n const keyVersions = Object.fromEntries(\n selected.map((entry) => [entry.key, entry.currentVersion!.id])\n );\n const contractSetHash = await translationContractSetHash(selected);\n const releaseSeed = canonicalJson([\n input.appId,\n input.branchId,\n input.buildId ?? '',\n contractSetHash,\n ]);\n const releaseId =\n input.releaseId?.trim() ||\n `release-${(await sha256Hex(releaseSeed)).slice(0, 24)}`;\n const immutableObjects: CompiledTranslationRelease['immutableObjects'] = [];\n const languages: TranslationReleaseManifest['languages'] = {};\n const quality: TranslationReleaseManifest['quality'] = {};\n\n for (const language of [...new Set(input.languages)].sort()) {\n const payload = compileLanguage(selected, language, {\n defaultLanguage: input.defaultLanguage,\n reviewedOnly: reviewedOnly.has(language),\n languageResources: input.languageResources,\n });\n const body = encoder.encode(canonicalJson(payload));\n const hash = await sha256Hex(decoder.decode(body));\n immutableObjects.push({ kind: 'base', hash, body });\n languages[language] = {\n base: {\n hash,\n url: objectUrl(input.publicBase, `objects/catalog/${hash}.json`),\n bytes: body.byteLength,\n },\n patches: [],\n };\n const checkedEntries = selected.map((entry) => {\n const message = payload[entry.key];\n const text =\n typeof message === 'string' ? message : message?.message ?? '';\n return {\n ...entry,\n units: {\n ...entry.units,\n [language]: {\n language,\n text,\n state: entry.units[language]?.state ?? 'untranslated',\n },\n },\n };\n });\n quality[language] = qualitySummary(\n language === input.defaultLanguage\n ? []\n : runChecks(checkedEntries, language, input.glossary ?? [])\n );\n }\n\n const errorCount = Object.values(quality).reduce(\n (total, summary) => total + summary.errors,\n 0\n );\n if (\n input.channel === 'production' &&\n errorCount > 0 &&\n !input.allowQualityErrors\n ) {\n throw new Error(\n `Production translation release blocked by ${errorCount} quality error${\n errorCount === 1 ? '' : 's'\n }.`\n );\n }\n\n const manifest: TranslationReleaseManifest = {\n schemaVersion: 2,\n releaseId,\n contractSetHash,\n hotfixSequence: 0,\n ...(input.revisionWatermark\n ? { revisionWatermark: input.revisionWatermark }\n : {}),\n keyVersions,\n quality,\n languages,\n ...(input.languageResources\n ? { languageResources: input.languageResources }\n : {}),\n };\n const manifestHash = await sha256Hex(canonicalJson(manifest));\n return {\n descriptor: {\n schemaVersion: 2,\n appId: input.appId,\n releaseId,\n contractSetHash,\n manifestUrl: objectUrl(\n input.publicBase,\n `releases/${releaseId}/manifest.json`\n ),\n },\n manifest,\n manifestHash,\n immutableObjects,\n };\n}\n\n/**\n * Recompile content beneath existing release identities and reuse only an\n * exact manifest match. Contract equality alone is insufficient because\n * selected translations, language policy, quality, or delivery URLs may differ.\n */\nexport async function findReusableCompiledRelease(\n entries: TranslationEntryRecord[],\n input: Omit<CompileReleaseInput, 'releaseId' | 'buildId'>,\n candidates: TranslationReleaseReuseCandidate[]\n): Promise<CompiledTranslationRelease | null> {\n for (const candidate of candidates) {\n const compiled = await compileRelease(entries, {\n ...input,\n releaseId: candidate.releaseId,\n });\n if (compiled.manifestHash === candidate.manifestHash) return compiled;\n }\n return null;\n}\n"]}
1
+ {"version":3,"file":"release.js","sourceRoot":"","sources":["../../src/release.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAqB,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EACL,kBAAkB,EAClB,uBAA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IAC9D,OAAO;QACL,UAAU,EAAE;YACV,aAAa,EAAE,CAAC;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS;YACT,eAAe;YACf,WAAW,EAAE,SAAS,CACpB,KAAK,CAAC,UAAU,EAChB,YAAY,SAAS,gBAAgB,CACtC;SACF;QACD,QAAQ;QACR,YAAY;QACZ,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAAiC,EACjC,KAAyD,EACzD,UAA8C;IAE9C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE;YAC7C,GAAG,KAAK;YACR,SAAS,EAAE,SAAS,CAAC,SAAS;SAC/B,CAAC,CAAC;QACH,IAAI,QAAQ,CAAC,YAAY,KAAK,SAAS,CAAC,YAAY;YAAE,OAAO,QAAQ,CAAC;IACxE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { TranslationLanguageDefinition } from './languages.js';\nimport { runChecks, type CheckFinding } from './checks.js';\nimport { compileLanguage } from './compile.js';\nimport type { TranslationMessages } from './core/messages.js';\nimport {\n classifyKeyVersion,\n createArgumentSignature,\n sha256Hex,\n} from './key-version.js';\nimport {\n isConfirmedBuildDeclaration,\n type TranslationBuildDeclaration,\n} from './exchange.js';\nimport type { GlossaryTermRecord, TranslationEntryRecord } from './records.js';\nimport type { ExtractedTranslationKey } from './key-sync.js';\n\nexport interface TranslationBuildDescriptor {\n schemaVersion: 2;\n appId: string;\n releaseId: string;\n contractSetHash: string;\n manifestUrl: string;\n}\n\n/** Serializable handoff from translation publication to an exact app build. */\nexport interface TranslationBuildPin {\n schemaVersion: 1;\n appId: string;\n branchId: string;\n buildId: string;\n channel: 'preview' | 'production';\n releaseId: string;\n contractSetHash: string;\n manifestHash: string;\n manifestUrl: string;\n /** Sequence baked into the fallback catalogs at build time. */\n hotfixSequence: number;\n catalogs: Record<string, TranslationCatalogObject>;\n pinnedAt: string;\n /** Which declaration source supplied the contract verifier for this build. */\n inventorySource?: 'confirmed-inventory' | 'static-fallback';\n}\n\nexport interface TranslationCatalogObject {\n hash: string;\n url: string;\n bytes: number;\n encoding?: 'gzip';\n}\n\nexport interface TranslationCatalogPatchObject\n extends TranslationCatalogObject {\n sequence: number;\n}\n\nexport interface TranslationQualitySummary {\n errors: number;\n warnings: number;\n rules: Record<string, number>;\n}\n\nexport interface TranslationReleaseManifest {\n languageResources?: TranslationLanguageDefinition[];\n schemaVersion: 2;\n releaseId: string;\n contractSetHash: string;\n hotfixSequence: number;\n revisionWatermark?: string;\n /** Compact release selection index: logical key → exact key-version IRI. */\n keyVersions: Record<string, string>;\n quality: Record<string, TranslationQualitySummary>;\n languages: Record<\n string,\n {\n base: TranslationCatalogObject;\n patches: TranslationCatalogPatchObject[];\n }\n >;\n}\n\nexport interface TranslationCatalogPatch {\n set: TranslationMessages;\n remove?: string[];\n}\n\nexport interface CompileReleaseInput {\n languageResources?: TranslationLanguageDefinition[];\n appId: string;\n branchId: string;\n buildId?: string;\n releaseId?: string;\n publicBase?: string;\n channel?: 'preview' | 'production';\n languages: string[];\n defaultLanguage: string;\n reviewedOnlyLanguages?: Iterable<string>;\n previousRelease?: TranslationReleaseManifest;\n revisionWatermark?: string;\n glossary?: GlossaryTermRecord[];\n allowQualityErrors?: boolean;\n}\n\nexport interface CompiledTranslationRelease {\n descriptor: TranslationBuildDescriptor;\n manifest: TranslationReleaseManifest;\n manifestHash: string;\n immutableObjects: Array<{\n kind: 'base' | 'patch';\n hash: string;\n body: Uint8Array;\n }>;\n}\n\nexport interface TranslationReleaseReuseCandidate {\n releaseId: string;\n manifestHash: string;\n}\n\nexport interface CompiledTranslationHotfix {\n key: string;\n language: string;\n sequence: number;\n patch: TranslationCatalogPatch;\n immutableObject: {\n kind: 'patch';\n hash: string;\n body: Uint8Array;\n };\n manifest: TranslationReleaseManifest;\n}\n\nexport interface CompiledTranslationCompaction {\n language: string;\n immutableObject: {\n kind: 'base';\n hash: string;\n body: Uint8Array;\n };\n manifest: TranslationReleaseManifest;\n}\n\nexport interface TranslationObjectInventoryEntry {\n /** App-relative object name, for example `objects/catalog/<hash>.json`. */\n name: string;\n lastModified?: Date | string;\n}\n\nexport interface TranslationCompactionThresholds {\n maxPatches?: number;\n maxPatchToBaseRatio?: number;\n}\n\nexport const DEFAULT_TRANSLATION_MAX_PATCHES = 8;\nexport const DEFAULT_TRANSLATION_PATCH_TO_BASE_RATIO = 0.25;\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\n/** Recursive canonical JSON used for every content-addressed release object. */\nexport function canonicalJson(value: unknown): string {\n if (value === null || typeof value !== 'object') return JSON.stringify(value);\n if (Array.isArray(value)) return `[${value.map(canonicalJson).join(',')}]`;\n const record = value as Record<string, unknown>;\n return `{${Object.keys(record)\n .sort()\n .map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`)\n .join(',')}}`;\n}\n\nfunction translationContracts(entries: TranslationEntryRecord[]) {\n return entries\n .filter((entry) => entry.kind === 'ui')\n .sort((left, right) => left.key.localeCompare(right.key))\n .map((entry) => ({\n key: entry.key,\n versionId: entry.currentVersion?.id ?? null,\n contractHash: entry.currentVersion?.contractHash ?? null,\n }));\n}\n\n/** The one canonical contract-set hash used by release compile and build pinning. */\nexport async function translationContractSetHash(\n entries: TranslationEntryRecord[]\n): Promise<string> {\n return sha256Hex(canonicalJson(translationContracts(entries)));\n}\n\n/**\n * Resolve keys extracted from one immutable build workspace to graph versions.\n * Missing/orphaned/conflicting/default-drifted keys fail before publication.\n * Explicit app-owned declaration overrides may change wording, never the\n * exact workspace's declared format or runtime-argument contract.\n */\nexport async function buildSnapshotContractSetHash(\n entries: TranslationEntryRecord[],\n extracted: Array<ExtractedTranslationKey | TranslationBuildDeclaration>\n): Promise<string> {\n const declarations = extracted.filter(isConfirmedBuildDeclaration);\n const declarationsByKey = new Map<string, TranslationBuildDeclaration[]>();\n for (const item of declarations) {\n const values = declarationsByKey.get(item.key) ?? [];\n values.push(item);\n declarationsByKey.set(item.key, values);\n }\n const selected = entries\n .filter((entry) => entry.kind === 'ui')\n .sort((left, right) => left.key.localeCompare(right.key));\n const graphKeys = new Set(selected.map(({ key }) => key));\n const missing = [...declarationsByKey.keys()]\n .filter((key) => !graphKeys.has(key))\n .sort();\n const orphaned = selected\n .map(({ key }) => key)\n .filter((key) => !declarationsByKey.has(key))\n .sort();\n if (missing.length || orphaned.length) {\n throw new Error(\n `Build translation contract differs from the release: ${\n missing.length ? `missing in graph [${missing.join(', ')}]` : ''\n }${missing.length && orphaned.length ? '; ' : ''}${\n orphaned.length ? `missing in build [${orphaned.join(', ')}]` : ''\n }.`\n );\n }\n\n for (const entry of selected) {\n const current = entry.currentVersion;\n if (!current?.id) {\n throw new Error(\n `Translation key \"${entry.key}\" has no current contract version.`\n );\n }\n const contracts = (declarationsByKey.get(entry.key) ?? []).map(\n (declaration) => ({\n sourceText: declaration.sourceText,\n // Legacy static extraction has no format. Preserve its shipped behavior\n // by resolving against the current graph contract.\n format: declaration.format ?? current.format ?? entry.format,\n })\n );\n const distinct = new Map(\n contracts.map((contract) => [\n canonicalJson([contract.sourceText, contract.format]),\n contract,\n ])\n );\n if (distinct.size > 1) {\n throw new Error(\n `Build translation key \"${entry.key}\" has conflicting source defaults or formats.`\n );\n }\n const extractedContract = [...distinct.values()][0];\n const decision = classifyKeyVersion(current, extractedContract);\n const explicitDeclarationOverride =\n entry.overridden === true &&\n !!(\n entry.ofShape ||\n entry.ofProperty ||\n entry.ofResource ||\n entry.fromPackage\n );\n // source-changed is reached only AFTER the existing classifier has checked\n // identical format and argument signature. Do not infer the missing format\n // of a legacy extraction from the very app override being verified.\n const compatibleAppWording =\n explicitDeclarationOverride &&\n decision.reason === 'source-changed' &&\n (declarationsByKey.get(entry.key) ?? []).every(\n (item) =>\n item.format !== undefined && item.namespace === entry.namespace\n ) &&\n entry.sourceText === current.sourceText &&\n entry.format === current.format &&\n createArgumentSignature(current.sourceText, current.format) ===\n current.argumentSignature;\n if (decision.action !== 'unchanged' && !compatibleAppWording) {\n throw new Error(\n `Build translation source for \"${entry.key}\" does not match its current key version (${decision.reason}).`\n );\n }\n }\n return translationContractSetHash(selected);\n}\n\nexport function assertTranslationContractSet(\n buildContractSetHash: string,\n releaseContractSetHash: string\n): void {\n if (buildContractSetHash !== releaseContractSetHash) {\n throw new Error(\n `Build translation contract ${buildContractSetHash} does not match release contract ${releaseContractSetHash}.`\n );\n }\n}\n\n/** Verify immutable catalog bytes before a build adapter writes them. */\nexport async function assertTranslationObjectHash(\n value: string | Uint8Array,\n expectedHash: string\n): Promise<void> {\n const text = typeof value === 'string' ? value : decoder.decode(value);\n const actual = await sha256Hex(text);\n if (actual !== expectedHash) {\n throw new Error(\n `Translation object hash mismatch: expected ${expectedHash}, received ${actual}.`\n );\n }\n}\n\nexport function createTranslationBuildPin(input: {\n descriptor: TranslationBuildDescriptor;\n manifest: TranslationReleaseManifest;\n manifestHash: string;\n branchId: string;\n buildId: string;\n channel: 'preview' | 'production';\n pinnedAt?: string;\n inventorySource?: 'confirmed-inventory' | 'static-fallback';\n}): TranslationBuildPin {\n if (\n input.manifest.releaseId !== input.descriptor.releaseId ||\n input.manifest.contractSetHash !== input.descriptor.contractSetHash\n ) {\n throw new Error(\n 'Translation release descriptor and manifest are incompatible.'\n );\n }\n return {\n schemaVersion: 1,\n appId: input.descriptor.appId,\n branchId: input.branchId,\n buildId: input.buildId,\n channel: input.channel,\n releaseId: input.descriptor.releaseId,\n contractSetHash: input.descriptor.contractSetHash,\n manifestHash: input.manifestHash,\n manifestUrl: input.descriptor.manifestUrl,\n hotfixSequence: input.manifest.hotfixSequence,\n catalogs: Object.fromEntries(\n Object.entries(input.manifest.languages).map(([language, lane]) => [\n language,\n lane.base,\n ])\n ),\n pinnedAt: input.pinnedAt ?? new Date().toISOString(),\n ...(input.inventorySource\n ? { inventorySource: input.inventorySource }\n : {}),\n };\n}\n\nexport function decodeReleaseObject(body: Uint8Array): unknown {\n return JSON.parse(decoder.decode(body));\n}\n\nexport function applyCatalogPatches(\n base: TranslationMessages,\n patches: TranslationCatalogPatch[]\n): TranslationMessages {\n const result: TranslationMessages = { ...base };\n for (const patch of patches) {\n for (const key of patch.remove ?? []) delete result[key];\n Object.assign(result, patch.set);\n }\n return result;\n}\n\nexport function releaseReferencesKeyVersion(\n manifest: TranslationReleaseManifest,\n keyVersionId: string\n): boolean {\n return Object.values(manifest.keyVersions).includes(keyVersionId);\n}\n\nexport function keyForVersion(\n manifest: TranslationReleaseManifest,\n keyVersionId: string\n): string | undefined {\n return Object.entries(manifest.keyVersions).find(\n ([, version]) => version === keyVersionId\n )?.[0];\n}\n\nexport function shouldCompactTranslationLanguage(\n lane: TranslationReleaseManifest['languages'][string],\n thresholds: TranslationCompactionThresholds = {}\n): boolean {\n const maxPatches = thresholds.maxPatches ?? DEFAULT_TRANSLATION_MAX_PATCHES;\n const maxPatchToBaseRatio =\n thresholds.maxPatchToBaseRatio ?? DEFAULT_TRANSLATION_PATCH_TO_BASE_RATIO;\n if (lane.patches.length > maxPatches) return true;\n if (lane.base.bytes <= 0) return lane.patches.length > 0;\n const patchBytes = lane.patches.reduce(\n (total, patch) => total + patch.bytes,\n 0\n );\n return patchBytes > lane.base.bytes * maxPatchToBaseRatio;\n}\n\nfunction publicBaseFromObjectUrl(url: string): string | undefined {\n const marker = '/objects/';\n const index = url.indexOf(marker);\n return index < 0 ? undefined : url.slice(0, index);\n}\n\n/**\n * Replace one eligible patch chain with an equivalent immutable base. The\n * release identity, contract set, and hotfix sequence deliberately do not\n * change because compaction changes representation, not translation content.\n */\nexport async function compileTranslationCompaction(input: {\n manifest: TranslationReleaseManifest;\n language: string;\n currentMessages: TranslationMessages;\n force?: boolean;\n thresholds?: TranslationCompactionThresholds;\n}): Promise<CompiledTranslationCompaction | null> {\n const lane = input.manifest.languages[input.language];\n if (!lane) {\n throw new Error(\n `Release ${input.manifest.releaseId} does not publish ${input.language}.`\n );\n }\n if (\n !input.force &&\n !shouldCompactTranslationLanguage(lane, input.thresholds)\n ) {\n return null;\n }\n if (lane.patches.length === 0) return null;\n\n const body = encoder.encode(canonicalJson(input.currentMessages));\n const hash = await sha256Hex(decoder.decode(body));\n const base: TranslationCatalogObject = {\n hash,\n url: objectUrl(\n publicBaseFromObjectUrl(lane.base.url),\n `objects/catalog/${hash}.json`\n ),\n bytes: body.byteLength,\n };\n return {\n language: input.language,\n immutableObject: { kind: 'base', hash, body },\n manifest: {\n ...input.manifest,\n languages: {\n ...input.manifest.languages,\n [input.language]: {\n base,\n patches: [],\n },\n },\n },\n };\n}\n\nfunction objectNameFromUrl(url: string, fallback: string): string {\n const clean = url.split(/[?#]/, 1)[0].replace(/^\\/+/, '');\n const marker = 'objects/';\n const index = clean.indexOf(marker);\n return index >= 0 ? clean.slice(index) : fallback;\n}\n\n/** Every immutable object directly reachable from the supplied manifests. */\nexport function collectReferencedTranslationObjects(\n manifests: Iterable<TranslationReleaseManifest>\n): Set<string> {\n const referenced = new Set<string>();\n for (const manifest of manifests) {\n for (const lane of Object.values(manifest.languages)) {\n referenced.add(\n objectNameFromUrl(\n lane.base.url,\n `objects/catalog/${lane.base.hash}.json${\n lane.base.encoding === 'gzip' ? '.gz' : ''\n }`\n )\n );\n for (const patch of lane.patches) {\n referenced.add(\n objectNameFromUrl(\n patch.url,\n `objects/patch/${patch.hash}.json${\n patch.encoding === 'gzip' ? '.gz' : ''\n }`\n )\n );\n }\n }\n }\n return referenced;\n}\n\n/**\n * Mark only old, content-addressed objects that are absent from every retained\n * manifest. Unknown timestamps fail closed and remain retained.\n */\nexport function selectPrunableTranslationObjects(input: {\n objects: Iterable<TranslationObjectInventoryEntry>;\n manifests: Iterable<TranslationReleaseManifest>;\n now?: Date | number;\n gracePeriodMs: number;\n}): string[] {\n if (!Number.isFinite(input.gracePeriodMs) || input.gracePeriodMs < 0) {\n throw new Error('gracePeriodMs must be a non-negative finite number.');\n }\n const now =\n input.now instanceof Date ? input.now.getTime() : input.now ?? Date.now();\n const referenced = collectReferencedTranslationObjects(input.manifests);\n const candidates = new Set<string>();\n for (const object of input.objects) {\n const name = object.name.replace(/^\\/+/, '');\n if (\n !/^objects\\/(?:catalog|patch)\\/[^/]+\\.json(?:\\.gz)?$/.test(name) ||\n referenced.has(name) ||\n !object.lastModified\n ) {\n continue;\n }\n const modifiedAt =\n object.lastModified instanceof Date\n ? object.lastModified.getTime()\n : new Date(object.lastModified).getTime();\n if (\n Number.isFinite(modifiedAt) &&\n now - modifiedAt >= input.gracePeriodMs\n ) {\n candidates.add(name);\n }\n }\n return [...candidates].sort();\n}\n\n/**\n * Create one content-addressed language patch and advance a compatible\n * manifest. Returns null for an idempotent re-approval of the current value.\n */\nexport async function compileTranslationHotfix(input: {\n manifest: TranslationReleaseManifest;\n keyVersionId: string;\n language: string;\n text: string;\n currentMessages: TranslationMessages;\n}): Promise<CompiledTranslationHotfix | null> {\n const key = keyForVersion(input.manifest, input.keyVersionId);\n if (!key) {\n throw new Error(\n `Release ${input.manifest.releaseId} does not reference key version ${input.keyVersionId}.`\n );\n }\n const lane = input.manifest.languages[input.language];\n if (!lane) {\n throw new Error(\n `Release ${input.manifest.releaseId} does not publish ${input.language}.`\n );\n }\n const current = input.currentMessages[key];\n const next =\n typeof current === 'object' && current?.format === 'icu'\n ? { message: input.text, format: 'icu' as const }\n : input.text;\n if (canonicalJson(current) === canonicalJson(next)) return null;\n\n const patch: TranslationCatalogPatch = { set: { [key]: next } };\n const body = encoder.encode(canonicalJson(patch));\n const hash = await sha256Hex(decoder.decode(body));\n const sequence = input.manifest.hotfixSequence + 1;\n const publicBase = publicBaseFromObjectUrl(lane.base.url);\n const patchObject: TranslationCatalogPatchObject = {\n hash,\n url: objectUrl(publicBase, `objects/patch/${hash}.json`),\n bytes: body.byteLength,\n sequence,\n };\n return {\n key,\n language: input.language,\n sequence,\n patch,\n immutableObject: { kind: 'patch', hash, body },\n manifest: {\n ...input.manifest,\n hotfixSequence: sequence,\n languages: {\n ...input.manifest.languages,\n [input.language]: {\n ...lane,\n patches: [...lane.patches, patchObject],\n },\n },\n },\n };\n}\n\nfunction qualitySummary(findings: CheckFinding[]): TranslationQualitySummary {\n const rules: Record<string, number> = {};\n let errors = 0;\n let warnings = 0;\n for (const finding of findings) {\n finding.severity === 'error' ? errors++ : warnings++;\n rules[finding.rule] = (rules[finding.rule] ?? 0) + 1;\n }\n return { errors, warnings, rules };\n}\n\nfunction objectUrl(publicBase: string | undefined, path: string): string {\n const base = publicBase?.replace(/\\/+$/, '');\n return base ? `${base}/${path}` : path;\n}\n\n/**\n * Compile one immutable schema-v2 release. The input entries are the captured\n * graph snapshot; callers are responsible for supplying its revision watermark.\n */\nexport async function compileRelease(\n entries: TranslationEntryRecord[],\n input: CompileReleaseInput\n): Promise<CompiledTranslationRelease> {\n const reviewedOnly = new Set(input.reviewedOnlyLanguages ?? []);\n const selected = entries\n .filter((entry) => entry.kind === 'ui')\n .sort((left, right) => left.key.localeCompare(right.key));\n const missingVersion = selected.find((entry) => !entry.currentVersion?.id);\n if (missingVersion) {\n throw new Error(\n `Translation key \"${missingVersion.key}\" has no current contract version.`\n );\n }\n const keyVersions = Object.fromEntries(\n selected.map((entry) => [entry.key, entry.currentVersion!.id])\n );\n const contractSetHash = await translationContractSetHash(selected);\n const releaseSeed = canonicalJson([\n input.appId,\n input.branchId,\n input.buildId ?? '',\n contractSetHash,\n ]);\n const releaseId =\n input.releaseId?.trim() ||\n `release-${(await sha256Hex(releaseSeed)).slice(0, 24)}`;\n const immutableObjects: CompiledTranslationRelease['immutableObjects'] = [];\n const languages: TranslationReleaseManifest['languages'] = {};\n const quality: TranslationReleaseManifest['quality'] = {};\n\n for (const language of [...new Set(input.languages)].sort()) {\n const payload = compileLanguage(selected, language, {\n defaultLanguage: input.defaultLanguage,\n reviewedOnly: reviewedOnly.has(language),\n languageResources: input.languageResources,\n });\n const body = encoder.encode(canonicalJson(payload));\n const hash = await sha256Hex(decoder.decode(body));\n immutableObjects.push({ kind: 'base', hash, body });\n languages[language] = {\n base: {\n hash,\n url: objectUrl(input.publicBase, `objects/catalog/${hash}.json`),\n bytes: body.byteLength,\n },\n patches: [],\n };\n const checkedEntries = selected.map((entry) => {\n const message = payload[entry.key];\n const text =\n typeof message === 'string' ? message : message?.message ?? '';\n return {\n ...entry,\n units: {\n ...entry.units,\n [language]: {\n language,\n text,\n state: entry.units[language]?.state ?? 'untranslated',\n },\n },\n };\n });\n quality[language] = qualitySummary(\n language === input.defaultLanguage\n ? []\n : runChecks(checkedEntries, language, input.glossary ?? [])\n );\n }\n\n const errorCount = Object.values(quality).reduce(\n (total, summary) => total + summary.errors,\n 0\n );\n if (\n input.channel === 'production' &&\n errorCount > 0 &&\n !input.allowQualityErrors\n ) {\n throw new Error(\n `Production translation release blocked by ${errorCount} quality error${\n errorCount === 1 ? '' : 's'\n }.`\n );\n }\n\n const manifest: TranslationReleaseManifest = {\n schemaVersion: 2,\n releaseId,\n contractSetHash,\n hotfixSequence: 0,\n ...(input.revisionWatermark\n ? { revisionWatermark: input.revisionWatermark }\n : {}),\n keyVersions,\n quality,\n languages,\n ...(input.languageResources\n ? { languageResources: input.languageResources }\n : {}),\n };\n const manifestHash = await sha256Hex(canonicalJson(manifest));\n return {\n descriptor: {\n schemaVersion: 2,\n appId: input.appId,\n releaseId,\n contractSetHash,\n manifestUrl: objectUrl(\n input.publicBase,\n `releases/${releaseId}/manifest.json`\n ),\n },\n manifest,\n manifestHash,\n immutableObjects,\n };\n}\n\n/**\n * Recompile content beneath existing release identities and reuse only an\n * exact manifest match. Contract equality alone is insufficient because\n * selected translations, language policy, quality, or delivery URLs may differ.\n */\nexport async function findReusableCompiledRelease(\n entries: TranslationEntryRecord[],\n input: Omit<CompileReleaseInput, 'releaseId' | 'buildId'>,\n candidates: TranslationReleaseReuseCandidate[]\n): Promise<CompiledTranslationRelease | null> {\n for (const candidate of candidates) {\n const compiled = await compileRelease(entries, {\n ...input,\n releaseId: candidate.releaseId,\n });\n if (compiled.manifestHash === candidate.manifestHash) return compiled;\n }\n return null;\n}\n"]}
@@ -3,7 +3,7 @@ import type { TranslationDiscoverySource } from './discovery.js';
3
3
  /**
4
4
  * Code-canonical translations shipped beside one reusable LINKED shape.
5
5
  * Packages may expose this object from code or serialize the same contract as
6
- * JSON for Host Agent discovery without executing package code.
6
+ * JSON for a host's discovery tooling without executing package code.
7
7
  */
8
8
  export interface ShapeTranslationCatalog {
9
9
  schemaVersion: 1;
@@ -1 +1 @@
1
- {"version":3,"file":"shape-catalog.js","sourceRoot":"","sources":["../../src/shape-catalog.ts"],"names":[],"mappings":"AAkEA,SAAS,aAAa,CAAC,KAAc,EAAE,KAAa;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,eAAe,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,6BAA6B,CAC3C,OAAgC;IAEhC,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,MAAK,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IACD,aAAa,CAAC,OAAO,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAClD,aAAa,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC5C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,KAAK,IAAI,OAAO,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gBAC/D,SAAS;YACX,CAAC;YACD,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;YACjE,MAAM,MAAM,CAAC,UAAU,CAAC;gBACtB,KAAK;gBACL,GAAG,EAAE,KAAK,CAAC,GAAG;gBACd,QAAQ;gBACR,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,KAAK,EAAE,MAAA,IAAI,CAAC,KAAK,mCAAI,UAAU;aAChC,CAAC,CAAC;YACH,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type {\n TranslationEntryRecord,\n TranslationState,\n} from './records.js';\nimport type { TranslationDiscoverySource } from './discovery.js';\n\n/**\n * Code-canonical translations shipped beside one reusable LINKED shape.\n * Packages may expose this object from code or serialize the same contract as\n * JSON for Host Agent discovery without executing package code.\n */\nexport interface ShapeTranslationCatalog {\n schemaVersion: 1;\n packageName: string;\n /** Canonical SHACL node-shape IRI, not a display label or filesystem path. */\n shapeIri: string;\n /** Optional stable domain-class IRI used for semantic browsing. */\n targetClass?: string;\n entries: ShapeTranslationCatalogEntry[];\n}\n\nexport interface ShapeTranslationCatalogEntry {\n key: string;\n sourceText: string;\n description?: string;\n namespace?: string;\n /** Stable predicate IRI when this message describes a shape property. */\n propertyIri?: string;\n format?: 'simple' | 'icu';\n /** Curated BCP-47 language values supplied by the package. */\n translations?: Record<\n string,\n string | { text: string; state?: TranslationState }\n >;\n}\n\nexport interface ShapeTranslationCatalogTarget {\n listEntries(data: { appId: string }): Promise<TranslationEntryRecord[]>;\n upsertKey(data: {\n appId: string;\n key: string;\n sourceText: string;\n namespace?: string;\n description?: string;\n kind: 'ui';\n format?: 'simple' | 'icu';\n ofShape: string;\n ofProperty?: string;\n fromPackage: string;\n }): Promise<unknown>;\n upsertUnit(data: {\n appId: string;\n key: string;\n language: string;\n text: string;\n state: TranslationState;\n }): Promise<unknown>;\n}\n\nexport interface ShapeTranslationInstallReport {\n createdKeys: string[];\n createdUnits: Array<{ key: string; language: string }>;\n skippedExistingKeys: string[];\n skippedExistingUnits: Array<{ key: string; language: string }>;\n}\n\nfunction requireString(value: unknown, label: string): string {\n if (typeof value !== 'string' || !value.trim()) {\n throw new Error(`${label} is required.`);\n }\n return value.trim();\n}\n\n/** Validate and freeze the package-owned declaration at module load time. */\nexport function defineShapeTranslationCatalog(\n catalog: ShapeTranslationCatalog,\n): Readonly<ShapeTranslationCatalog> {\n if (catalog?.schemaVersion !== 1) {\n throw new Error('Shape translation catalog schemaVersion must be 1.');\n }\n requireString(catalog.packageName, 'packageName');\n requireString(catalog.shapeIri, 'shapeIri');\n if (!Array.isArray(catalog.entries)) {\n throw new Error('Shape translation catalog entries must be an array.');\n }\n const keys = new Set<string>();\n for (const entry of catalog.entries) {\n const key = requireString(entry?.key, 'entry.key');\n requireString(entry?.sourceText, `sourceText for ${key}`);\n if (keys.has(key)) throw new Error(`Duplicate shape translation key \"${key}\".`);\n keys.add(key);\n }\n return Object.freeze(catalog);\n}\n\n/** Adapt the existing schema-v1 catalog without changing its install contract. */\nexport function shapeCatalogTranslationDiscoverySource(\n input: ShapeTranslationCatalog,\n): TranslationDiscoverySource {\n const catalog = defineShapeTranslationCatalog(input);\n return {\n name: `shape-catalog:${catalog.packageName}:${catalog.shapeIri}`,\n async *discover() {\n for (const entry of catalog.entries) {\n yield {\n schemaVersion: 1,\n key: entry.key,\n sourceText: entry.sourceText,\n kind: 'ui',\n format: entry.format ?? 'simple',\n ...(entry.namespace ? { namespace: entry.namespace } : {}),\n ...(entry.description ? { description: entry.description } : {}),\n provenance: {\n source: 'package',\n sourceId: `${catalog.packageName}:${catalog.shapeIri}`,\n authoritative: true,\n ownerIri: catalog.shapeIri,\n shapeIri: catalog.shapeIri,\n fromPackage: catalog.packageName,\n ...(catalog.targetClass\n ? { targetClass: catalog.targetClass }\n : {}),\n ...(entry.propertyIri\n ? { propertyIri: entry.propertyIri }\n : {}),\n },\n };\n }\n },\n };\n}\n\n/**\n * Seed only missing app values for the currently activated languages.\n * Existing project-authored keys and units always win over package defaults.\n */\nexport async function installShapeTranslationCatalog(\n target: ShapeTranslationCatalogTarget,\n input: {\n appId: string;\n catalog: ShapeTranslationCatalog;\n activeLanguages: Iterable<string>;\n },\n): Promise<ShapeTranslationInstallReport> {\n const appId = requireString(input.appId, 'appId');\n const catalog = defineShapeTranslationCatalog(input.catalog);\n const activeLanguages = new Set(\n [...input.activeLanguages].map((language) => language.trim()).filter(Boolean),\n );\n const existing = new Map(\n (await target.listEntries({ appId })).map((entry) => [entry.key, entry]),\n );\n const report: ShapeTranslationInstallReport = {\n createdKeys: [],\n createdUnits: [],\n skippedExistingKeys: [],\n skippedExistingUnits: [],\n };\n\n for (const entry of catalog.entries) {\n const current = existing.get(entry.key);\n if (current) report.skippedExistingKeys.push(entry.key);\n else {\n await target.upsertKey({\n appId,\n key: entry.key,\n sourceText: entry.sourceText,\n namespace: entry.namespace,\n description: entry.description,\n kind: 'ui',\n format: entry.format,\n ofShape: catalog.shapeIri,\n ofProperty: entry.propertyIri,\n fromPackage: catalog.packageName,\n });\n report.createdKeys.push(entry.key);\n }\n\n for (const language of [...activeLanguages].sort()) {\n const value = entry.translations?.[language];\n if (value === undefined) continue;\n if (current?.units[language]) {\n report.skippedExistingUnits.push({ key: entry.key, language });\n continue;\n }\n const unit = typeof value === 'string' ? { text: value } : value;\n await target.upsertUnit({\n appId,\n key: entry.key,\n language,\n text: unit.text,\n state: unit.state ?? 'reviewed',\n });\n report.createdUnits.push({ key: entry.key, language });\n }\n }\n return report;\n}\n"]}
1
+ {"version":3,"file":"shape-catalog.js","sourceRoot":"","sources":["../../src/shape-catalog.ts"],"names":[],"mappings":"AAkEA,SAAS,aAAa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QAAQ,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type {\n TranslationEntryRecord,\n TranslationState,\n} from './records.js';\nimport type { TranslationDiscoverySource } from './discovery.js';\n\n/**\n * Code-canonical translations shipped beside one reusable LINKED shape.\n * Packages may expose this object from code or serialize the same contract as\n * JSON for a host's discovery tooling without executing package code.\n */\nexport interface ShapeTranslationCatalog {\n schemaVersion: 1;\n packageName: string;\n /** Canonical SHACL node-shape IRI, not a display label or filesystem path. */\n shapeIri: string;\n /** Optional stable domain-class IRI used for semantic browsing. */\n targetClass?: string;\n entries: ShapeTranslationCatalogEntry[];\n}\n\nexport interface ShapeTranslationCatalogEntry {\n key: string;\n sourceText: string;\n description?: string;\n namespace?: string;\n /** Stable predicate IRI when this message describes a shape property. */\n propertyIri?: string;\n format?: 'simple' | 'icu';\n /** Curated BCP-47 language values supplied by the package. */\n translations?: Record<\n string,\n string | { text: string; state?: TranslationState }\n >;\n}\n\nexport interface ShapeTranslationCatalogTarget {\n listEntries(data: { appId: string }): Promise<TranslationEntryRecord[]>;\n upsertKey(data: {\n appId: string;\n key: string;\n sourceText: string;\n namespace?: string;\n description?: string;\n kind: 'ui';\n format?: 'simple' | 'icu';\n ofShape: string;\n ofProperty?: string;\n fromPackage: string;\n }): Promise<unknown>;\n upsertUnit(data: {\n appId: string;\n key: string;\n language: string;\n text: string;\n state: TranslationState;\n }): Promise<unknown>;\n}\n\nexport interface ShapeTranslationInstallReport {\n createdKeys: string[];\n createdUnits: Array<{ key: string; language: string }>;\n skippedExistingKeys: string[];\n skippedExistingUnits: Array<{ key: string; language: string }>;\n}\n\nfunction requireString(value: unknown, label: string): string {\n if (typeof value !== 'string' || !value.trim()) {\n throw new Error(`${label} is required.`);\n }\n return value.trim();\n}\n\n/** Validate and freeze the package-owned declaration at module load time. */\nexport function defineShapeTranslationCatalog(\n catalog: ShapeTranslationCatalog,\n): Readonly<ShapeTranslationCatalog> {\n if (catalog?.schemaVersion !== 1) {\n throw new Error('Shape translation catalog schemaVersion must be 1.');\n }\n requireString(catalog.packageName, 'packageName');\n requireString(catalog.shapeIri, 'shapeIri');\n if (!Array.isArray(catalog.entries)) {\n throw new Error('Shape translation catalog entries must be an array.');\n }\n const keys = new Set<string>();\n for (const entry of catalog.entries) {\n const key = requireString(entry?.key, 'entry.key');\n requireString(entry?.sourceText, `sourceText for ${key}`);\n if (keys.has(key)) throw new Error(`Duplicate shape translation key \"${key}\".`);\n keys.add(key);\n }\n return Object.freeze(catalog);\n}\n\n/** Adapt the existing schema-v1 catalog without changing its install contract. */\nexport function shapeCatalogTranslationDiscoverySource(\n input: ShapeTranslationCatalog,\n): TranslationDiscoverySource {\n const catalog = defineShapeTranslationCatalog(input);\n return {\n name: `shape-catalog:${catalog.packageName}:${catalog.shapeIri}`,\n async *discover() {\n for (const entry of catalog.entries) {\n yield {\n schemaVersion: 1,\n key: entry.key,\n sourceText: entry.sourceText,\n kind: 'ui',\n format: entry.format ?? 'simple',\n ...(entry.namespace ? { namespace: entry.namespace } : {}),\n ...(entry.description ? { description: entry.description } : {}),\n provenance: {\n source: 'package',\n sourceId: `${catalog.packageName}:${catalog.shapeIri}`,\n authoritative: true,\n ownerIri: catalog.shapeIri,\n shapeIri: catalog.shapeIri,\n fromPackage: catalog.packageName,\n ...(catalog.targetClass\n ? { targetClass: catalog.targetClass }\n : {}),\n ...(entry.propertyIri\n ? { propertyIri: entry.propertyIri }\n : {}),\n },\n };\n }\n },\n };\n}\n\n/**\n * Seed only missing app values for the currently activated languages.\n * Existing project-authored keys and units always win over package defaults.\n */\nexport async function installShapeTranslationCatalog(\n target: ShapeTranslationCatalogTarget,\n input: {\n appId: string;\n catalog: ShapeTranslationCatalog;\n activeLanguages: Iterable<string>;\n },\n): Promise<ShapeTranslationInstallReport> {\n const appId = requireString(input.appId, 'appId');\n const catalog = defineShapeTranslationCatalog(input.catalog);\n const activeLanguages = new Set(\n [...input.activeLanguages].map((language) => language.trim()).filter(Boolean),\n );\n const existing = new Map(\n (await target.listEntries({ appId })).map((entry) => [entry.key, entry]),\n );\n const report: ShapeTranslationInstallReport = {\n createdKeys: [],\n createdUnits: [],\n skippedExistingKeys: [],\n skippedExistingUnits: [],\n };\n\n for (const entry of catalog.entries) {\n const current = existing.get(entry.key);\n if (current) report.skippedExistingKeys.push(entry.key);\n else {\n await target.upsertKey({\n appId,\n key: entry.key,\n sourceText: entry.sourceText,\n namespace: entry.namespace,\n description: entry.description,\n kind: 'ui',\n format: entry.format,\n ofShape: catalog.shapeIri,\n ofProperty: entry.propertyIri,\n fromPackage: catalog.packageName,\n });\n report.createdKeys.push(entry.key);\n }\n\n for (const language of [...activeLanguages].sort()) {\n const value = entry.translations?.[language];\n if (value === undefined) continue;\n if (current?.units[language]) {\n report.skippedExistingUnits.push({ key: entry.key, language });\n continue;\n }\n const unit = typeof value === 'string' ? { text: value } : value;\n await target.upsertUnit({\n appId,\n key: entry.key,\n language,\n text: unit.text,\n state: unit.state ?? 'reviewed',\n });\n report.createdUnits.push({ key: entry.key, language });\n }\n }\n return report;\n}\n"]}
@@ -31,19 +31,23 @@ export declare class TranslationKey extends Shape {
31
31
  get ofShape(): string;
32
32
  /** Stable predicate IRI when this key describes one shape property. */
33
33
  get ofProperty(): string;
34
+ /** Arbitrary declared semantic resource, such as an action or condition. */
35
+ get ofResource(): string;
34
36
  /** Reusable package that supplied the seed value. */
35
37
  get fromPackage(): string;
36
38
  /**
37
- * True when this app copy of a shape-owned key has been edited locally and
38
- * should NOT be overwritten by shape-route propagation (AD-N: "never
39
+ * True when this app copy of a declaration-owned key has been edited locally
40
+ * (shape, property or named package resource, including help) and should NOT
41
+ * be overwritten by declaration refresh or shape-route propagation (AD-N: "never
39
42
  * overwrites an app's own override"). Set when the per-app editor changes the
40
- * source of a key that carries `ofShape`.
43
+ * source of a key with declared ownership.
41
44
  */
42
45
  get overridden(): boolean;
43
46
  /**
44
- * The shape's canonical source captured the moment this app first overrode the
47
+ * The declaration's canonical source captured when this app first overrode the
45
48
  * key — what "clear override" reverts to when no non-overridden sibling copy is
46
- * available to read the current canonical from (AD-N).
49
+ * available to read the current canonical from (AD-N). The historic predicate
50
+ * name stays compatible; resource-owned help does not invent a second carrier.
47
51
  */
48
52
  get shapeSource(): string;
49
53
  /** Message syntax: 'simple' (FormatSimple) | 'icu'. */
@@ -72,6 +76,7 @@ export declare class TranslationKey extends Shape {
72
76
  ofField?: string;
73
77
  ofShape?: string;
74
78
  ofProperty?: string;
79
+ ofResource?: string;
75
80
  fromPackage?: string;
76
81
  format?: 'simple' | 'icu';
77
82
  }): Promise<{
@@ -60,23 +60,29 @@ let TranslationKey = class TranslationKey extends Shape {
60
60
  get ofProperty() {
61
61
  return '';
62
62
  }
63
+ /** Arbitrary declared semantic resource, such as an action or condition. */
64
+ get ofResource() {
65
+ return '';
66
+ }
63
67
  /** Reusable package that supplied the seed value. */
64
68
  get fromPackage() {
65
69
  return '';
66
70
  }
67
71
  /**
68
- * True when this app copy of a shape-owned key has been edited locally and
69
- * should NOT be overwritten by shape-route propagation (AD-N: "never
72
+ * True when this app copy of a declaration-owned key has been edited locally
73
+ * (shape, property or named package resource, including help) and should NOT
74
+ * be overwritten by declaration refresh or shape-route propagation (AD-N: "never
70
75
  * overwrites an app's own override"). Set when the per-app editor changes the
71
- * source of a key that carries `ofShape`.
76
+ * source of a key with declared ownership.
72
77
  */
73
78
  get overridden() {
74
79
  return false;
75
80
  }
76
81
  /**
77
- * The shape's canonical source captured the moment this app first overrode the
82
+ * The declaration's canonical source captured when this app first overrode the
78
83
  * key — what "clear override" reverts to when no non-overridden sibling copy is
79
- * available to read the current canonical from (AD-N).
84
+ * available to read the current canonical from (AD-N). The historic predicate
85
+ * name stays compatible; resource-owned help does not invent a second carrier.
80
86
  */
81
87
  get shapeSource() {
82
88
  return '';
@@ -162,6 +168,11 @@ __decorate([
162
168
  __metadata("design:type", String),
163
169
  __metadata("design:paramtypes", [])
164
170
  ], TranslationKey.prototype, "ofProperty", null);
171
+ __decorate([
172
+ objectProperty({ path: tr.ofResource, maxCount: 1 }),
173
+ __metadata("design:type", String),
174
+ __metadata("design:paramtypes", [])
175
+ ], TranslationKey.prototype, "ofResource", null);
165
176
  __decorate([
166
177
  literalProperty({ path: tr.fromPackage, maxCount: 1 }),
167
178
  __metadata("design:type", String),
@@ -1 +1 @@
1
- {"version":3,"file":"TranslationKey.js","sourceRoot":"","sources":["../../../src/shapes/TranslationKey.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,8BAA8B,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAS5C;;;;;;;GAOG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,KAAK;IAGvC,iDAAiD;IACjD,IACI,SAAS;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,0CAA0C;IAC1C,IACI,GAAG;QACL,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,uCAAuC;IACvC,IACI,UAAU;QACZ,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IACI,WAAW;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,sDAAsD;IACtD,IACI,IAAI;QACN,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+EAA+E;IAC/E,IACI,aAAa;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,mEAAmE;IACnE,IACI,MAAM;QACR,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,iEAAiE;IACjE,IACI,OAAO;QACT,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,0DAA0D;IAC1D,IACI,OAAO;QACT,OAAO,EAAE,CAAC;IACZ,CA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C,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;;;gDAGrD;AAOD;IAAC,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;;;iDAGtD;AAGD;IAAC,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;;;4CAGjD;AAGD;IAAC,cAAc,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,cAAc,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;;;oDAGxD;AAnGU,cAAc;IAD1B,WAAW;GACC,cAAc,CAuJ1B","sourcesContent":["import { Shape } from '@_linked/core/shapes/Shape';\nimport { literalProperty, objectProperty } from '@_linked/core/shapes/SHACL';\nimport { Server } from '@_linked/server-utils/utils/Server';\nimport { tr } from '../ontologies/translation.js';\nimport { linkedShape } from '../package.js';\nimport type {\n TranslationEntryRecord,\n TranslationKeyVersionRecord,\n TranslationState,\n} from '../records.js';\nimport type { TranslationMessages } from '../core/messages.js';\nimport type { TranslationKeyVersion } from './TranslationKeyVersion.js';\n\n/**\n * A translatable key (Plan 014 AD-H). Covers both UI-string keys (`kind:'ui'`)\n * and graph-content translations (`kind:'content'` + `ofNode`/`ofField`), unified\n * in one scheme. `sourceText` is the canonical English (R7); `format` pins the\n * message syntax so imported FormatSimple strings aren't reinterpreted as ICU\n * (R8). Named `TranslationKey` (its per-language values are {@link TranslationUnit}s,\n * not `Translation` — avoids collision with serve's legacy shape, R13).\n */\n@linkedShape\nexport class TranslationKey extends Shape {\n static targetClass = tr.TranslationKey;\n\n /** Dotted namespace grouping, e.g. \"account\". */\n @literalProperty({ path: tr.namespace, maxCount: 1 })\n get namespace(): string {\n return '';\n }\n\n /** The key path, e.g. \"account.title\". */\n @literalProperty({ path: tr.key, maxCount: 1 })\n get key(): string {\n return '';\n }\n\n /** Canonical English source string. */\n @literalProperty({ path: tr.sourceText, maxCount: 1 })\n get sourceText(): string {\n return '';\n }\n\n @literalProperty({ path: tr.description, maxCount: 1 })\n get description(): string {\n return '';\n }\n\n /** 'ui' (chrome string) | 'content' (graph field). */\n @literalProperty({ path: tr.kind, maxCount: 1 })\n get kind(): string {\n return 'ui';\n }\n\n /** IRI of the owning Application (translation content is app-scoped, AD-I). */\n @objectProperty({ path: tr.ofApplication, maxCount: 1 })\n get ofApplication(): string {\n return '';\n }\n\n /** For kind:'content' — the IRI of the translated subject node. */\n @objectProperty({ path: tr.ofNode, maxCount: 1 })\n get ofNode(): string {\n return '';\n }\n\n /** For kind:'content' — the field/predicate being translated. */\n @literalProperty({ path: tr.ofField, maxCount: 1 })\n get ofField(): string {\n return '';\n }\n\n /** SHACL node-shape IRI this packaged key accompanies. */\n @objectProperty({ path: tr.ofShape, maxCount: 1 })\n get ofShape(): string {\n return '';\n }\n\n /** Stable predicate IRI when this key describes one shape property. */\n @objectProperty({ path: tr.ofProperty, maxCount: 1 })\n get ofProperty(): string {\n return '';\n }\n\n /** Reusable package that supplied the seed value. */\n @literalProperty({ path: tr.fromPackage, maxCount: 1 })\n get fromPackage(): string {\n return '';\n }\n\n /**\n * True when this app copy of a shape-owned key has been edited locally and\n * should NOT be overwritten by shape-route propagation (AD-N: \"never\n * overwrites an app's own override\"). Set when the per-app editor changes the\n * source of a key that carries `ofShape`.\n */\n @literalProperty({ path: tr.overridden, maxCount: 1 })\n get overridden(): boolean {\n return false;\n }\n\n /**\n * The shape's canonical source captured the moment this app first overrode the\n * key — what \"clear override\" reverts to when no non-overridden sibling copy is\n * available to read the current canonical from (AD-N).\n */\n @literalProperty({ path: tr.shapeSource, maxCount: 1 })\n get shapeSource(): string {\n return '';\n }\n\n /** Message syntax: 'simple' (FormatSimple) | 'icu'. */\n @literalProperty({ path: tr.format, maxCount: 1 })\n get format(): string {\n return 'simple';\n }\n\n /** Current immutable source/argument contract. Populated by Plan 018 migration. */\n @objectProperty({ path: tr.currentVersion, maxCount: 1 })\n get currentVersion(): TranslationKeyVersion {\n return undefined as any;\n }\n\n static list(data: { appId: string }) {\n return Server.call(this, 'listKeys', data);\n }\n\n /** Plain app-scoped records for authoring UIs; no live Shape crosses RPC. */\n static listEntries(data: { appId: string }) {\n return Server.call(this, 'listEntries', data) as Promise<\n TranslationEntryRecord[]\n >;\n }\n\n static listVersions(data: { appId: string; key?: string }) {\n return Server.call(this, 'listKeyVersions', data) as Promise<\n TranslationKeyVersionRecord[]\n >;\n }\n\n // Shape.upsert is the framework's typed graph-update builder. Keep the\n // app-scoped translation RPC separate from that inherited API.\n static upsertKey(data: {\n appId: string;\n key: string;\n sourceText: string;\n namespace?: string;\n description?: string;\n kind?: 'ui' | 'content';\n ofNode?: string;\n ofField?: string;\n ofShape?: string;\n ofProperty?: string;\n fromPackage?: string;\n format?: 'simple' | 'icu';\n }): Promise<{ id: string }> {\n return Server.call(this, 'upsertKey', data);\n }\n\n static upsertUnit(data: {\n appId: string;\n key: string;\n language: string;\n text: string;\n state?: TranslationState;\n updatedBy?: string;\n }) {\n return Server.call(this, 'upsertUnit', data);\n }\n\n static getMessages(data: { appId: string; language: string }) {\n return Server.call(this, 'getMessages', data) as Promise<TranslationMessages>;\n }\n}\n"]}
1
+ {"version":3,"file":"TranslationKey.js","sourceRoot":"","sources":["../../../src/shapes/TranslationKey.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,8BAA8B,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAS5C;;;;;;;GAOG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,KAAK;IAGvC,iD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linked/core/shapes/Shape';\nimport { literalProperty, objectProperty } from '@_linked/core/shapes/SHACL';\nimport { Server } from '@_linked/server-utils/utils/Server';\nimport { tr } from '../ontologies/translation.js';\nimport { linkedShape } from '../package.js';\nimport type {\n TranslationEntryRecord,\n TranslationKeyVersionRecord,\n TranslationState,\n} from '../records.js';\nimport type { TranslationMessages } from '../core/messages.js';\nimport type { TranslationKeyVersion } from './TranslationKeyVersion.js';\n\n/**\n * A translatable key (Plan 014 AD-H). Covers both UI-string keys (`kind:'ui'`)\n * and graph-content translations (`kind:'content'` + `ofNode`/`ofField`), unified\n * in one scheme. `sourceText` is the canonical English (R7); `format` pins the\n * message syntax so imported FormatSimple strings aren't reinterpreted as ICU\n * (R8). Named `TranslationKey` (its per-language values are {@link TranslationUnit}s,\n * not `Translation` — avoids collision with serve's legacy shape, R13).\n */\n@linkedShape\nexport class TranslationKey extends Shape {\n static targetClass = tr.TranslationKey;\n\n /** Dotted namespace grouping, e.g. \"account\". */\n @literalProperty({ path: tr.namespace, maxCount: 1 })\n get namespace(): string {\n return '';\n }\n\n /** The key path, e.g. \"account.title\". */\n @literalProperty({ path: tr.key, maxCount: 1 })\n get key(): string {\n return '';\n }\n\n /** Canonical English source string. */\n @literalProperty({ path: tr.sourceText, maxCount: 1 })\n get sourceText(): string {\n return '';\n }\n\n @literalProperty({ path: tr.description, maxCount: 1 })\n get description(): string {\n return '';\n }\n\n /** 'ui' (chrome string) | 'content' (graph field). */\n @literalProperty({ path: tr.kind, maxCount: 1 })\n get kind(): string {\n return 'ui';\n }\n\n /** IRI of the owning Application (translation content is app-scoped, AD-I). */\n @objectProperty({ path: tr.ofApplication, maxCount: 1 })\n get ofApplication(): string {\n return '';\n }\n\n /** For kind:'content' — the IRI of the translated subject node. */\n @objectProperty({ path: tr.ofNode, maxCount: 1 })\n get ofNode(): string {\n return '';\n }\n\n /** For kind:'content' — the field/predicate being translated. */\n @literalProperty({ path: tr.ofField, maxCount: 1 })\n get ofField(): string {\n return '';\n }\n\n /** SHACL node-shape IRI this packaged key accompanies. */\n @objectProperty({ path: tr.ofShape, maxCount: 1 })\n get ofShape(): string {\n return '';\n }\n\n /** Stable predicate IRI when this key describes one shape property. */\n @objectProperty({ path: tr.ofProperty, maxCount: 1 })\n get ofProperty(): string {\n return '';\n }\n\n /** Arbitrary declared semantic resource, such as an action or condition. */\n @objectProperty({ path: tr.ofResource, maxCount: 1 })\n get ofResource(): string {\n return '';\n }\n\n /** Reusable package that supplied the seed value. */\n @literalProperty({ path: tr.fromPackage, maxCount: 1 })\n get fromPackage(): string {\n return '';\n }\n\n /**\n * True when this app copy of a declaration-owned key has been edited locally\n * (shape, property or named package resource, including help) and should NOT\n * be overwritten by declaration refresh or shape-route propagation (AD-N: \"never\n * overwrites an app's own override\"). Set when the per-app editor changes the\n * source of a key with declared ownership.\n */\n @literalProperty({ path: tr.overridden, maxCount: 1 })\n get overridden(): boolean {\n return false;\n }\n\n /**\n * The declaration's canonical source captured when this app first overrode the\n * key — what \"clear override\" reverts to when no non-overridden sibling copy is\n * available to read the current canonical from (AD-N). The historic predicate\n * name stays compatible; resource-owned help does not invent a second carrier.\n */\n @literalProperty({ path: tr.shapeSource, maxCount: 1 })\n get shapeSource(): string {\n return '';\n }\n\n /** Message syntax: 'simple' (FormatSimple) | 'icu'. */\n @literalProperty({ path: tr.format, maxCount: 1 })\n get format(): string {\n return 'simple';\n }\n\n /** Current immutable source/argument contract. Populated by Plan 018 migration. */\n @objectProperty({ path: tr.currentVersion, maxCount: 1 })\n get currentVersion(): TranslationKeyVersion {\n return undefined as any;\n }\n\n static list(data: { appId: string }) {\n return Server.call(this, 'listKeys', data);\n }\n\n /** Plain app-scoped records for authoring UIs; no live Shape crosses RPC. */\n static listEntries(data: { appId: string }) {\n return Server.call(this, 'listEntries', data) as Promise<\n TranslationEntryRecord[]\n >;\n }\n\n static listVersions(data: { appId: string; key?: string }) {\n return Server.call(this, 'listKeyVersions', data) as Promise<\n TranslationKeyVersionRecord[]\n >;\n }\n\n // Shape.upsert is the framework's typed graph-update builder. Keep the\n // app-scoped translation RPC separate from that inherited API.\n static upsertKey(data: {\n appId: string;\n key: string;\n sourceText: string;\n namespace?: string;\n description?: string;\n kind?: 'ui' | 'content';\n ofNode?: string;\n ofField?: string;\n ofShape?: string;\n ofProperty?: string;\n ofResource?: string;\n fromPackage?: string;\n format?: 'simple' | 'icu';\n }): Promise<{ id: string }> {\n return Server.call(this, 'upsertKey', data);\n }\n\n static upsertUnit(data: {\n appId: string;\n key: string;\n language: string;\n text: string;\n state?: TranslationState;\n updatedBy?: string;\n }) {\n return Server.call(this, 'upsertUnit', data);\n }\n\n static getMessages(data: { appId: string; language: string }) {\n return Server.call(this, 'getMessages', data) as Promise<TranslationMessages>;\n }\n}\n"]}
@@ -13,12 +13,31 @@ export interface TranslationKeyInput {
13
13
  ofField?: string;
14
14
  ofShape?: string;
15
15
  ofProperty?: string;
16
+ ofResource?: string;
16
17
  fromPackage?: string;
17
18
  /** Force the override flag; when omitted it is derived (see upsertTranslationKey). */
18
19
  overridden?: boolean;
19
20
  format?: 'simple' | 'icu';
20
21
  sourceLanguage?: string;
21
22
  }
23
+ /** Trusted caller context, not a client payload flag. Package discovery and
24
+ * explicit app authoring have different ownership semantics. */
25
+ export interface TranslationKeyWriteContext {
26
+ createdBy?: string;
27
+ /**
28
+ * `'declaration-sync'` is a refresh from code/package declarations: it never
29
+ * marks a key overridden, and it leaves an existing app override untouched
30
+ * (answering `preservedOverride: true`). Anything else is an app edit.
31
+ */
32
+ source?: 'app-edit' | 'declaration-sync';
33
+ }
34
+ export interface TranslationKeyWriteResult {
35
+ id: string;
36
+ versionId: string;
37
+ versionCreated: boolean;
38
+ /** Present when a declaration refresh kept the app's override and wrote nothing. */
39
+ preservedOverride?: true;
40
+ }
22
41
  export interface TranslationUnitInput {
23
42
  appId: string;
24
43
  key: string;
@@ -118,6 +137,8 @@ export declare function listTranslationKeys(data: {
118
137
  ofShape: string;
119
138
  } & {
120
139
  ofProperty: string;
140
+ } & {
141
+ ofResource: string;
121
142
  } & {
122
143
  fromPackage: string;
123
144
  } & {
@@ -181,13 +202,7 @@ export declare function decideTranslationProposal(data: {
181
202
  * Idempotent key write shared by the RPC provider and managed key-sync flows.
182
203
  * Source drift marks every existing language unit stale before returning.
183
204
  */
184
- export declare function upsertTranslationKey(data: TranslationKeyInput, authorship?: {
185
- createdBy?: string;
186
- }): Promise<{
187
- id: string;
188
- versionId: string;
189
- versionCreated: boolean;
190
- }>;
205
+ export declare function upsertTranslationKey(data: TranslationKeyInput, authorship?: TranslationKeyWriteContext): Promise<TranslationKeyWriteResult>;
191
206
  /**
192
207
  * Append one revision WITHOUT touching the unit (Plan 017 AD-P) — the write
193
208
  * path for MT SUGGESTIONS (Slice B) and translator PROPOSALS (Slice C): a
@@ -259,7 +274,7 @@ export declare class TranslationProvider extends ShapeProvider {
259
274
  shape: typeof TranslationKey;
260
275
  /**
261
276
  * Authoring gate. Reads `linkedAuth` off the request the LINKED server already
262
- * populates, so this stays portable (no Create Now import, AD-G).
277
+ * populates, so this stays portable (no host-application import, AD-G).
263
278
  *
264
279
  * Every method except `getMessages` resolves the caller once, synchronously,
265
280
  * before its first `await`, and uses that value for both the permission check
@@ -298,6 +313,8 @@ export declare class TranslationProvider extends ShapeProvider {
298
313
  ofShape: string;
299
314
  } & {
300
315
  ofProperty: string;
316
+ } & {
317
+ ofResource: string;
301
318
  } & {
302
319
  fromPackage: string;
303
320
  } & {