@azx-pbc/axiom-builder 0.0.0-stage → 0.0.6

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 (231) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +648 -2
  3. package/dist/cards/selectors.d.ts +70 -0
  4. package/dist/cards/selectors.d.ts.map +1 -0
  5. package/dist/cards/selectors.js +194 -0
  6. package/dist/cards/selectors.js.map +1 -0
  7. package/dist/definition.d.ts +36 -0
  8. package/dist/definition.d.ts.map +1 -0
  9. package/dist/definition.js +48 -0
  10. package/dist/definition.js.map +1 -0
  11. package/dist/evidence/cases.d.ts +44 -0
  12. package/dist/evidence/cases.d.ts.map +1 -0
  13. package/dist/evidence/cases.js +578 -0
  14. package/dist/evidence/cases.js.map +1 -0
  15. package/dist/evidence/repairs.d.ts +99 -0
  16. package/dist/evidence/repairs.d.ts.map +1 -0
  17. package/dist/evidence/repairs.js +181 -0
  18. package/dist/evidence/repairs.js.map +1 -0
  19. package/dist/evidence/summary.d.ts +35 -0
  20. package/dist/evidence/summary.d.ts.map +1 -0
  21. package/dist/evidence/summary.js +38 -0
  22. package/dist/evidence/summary.js.map +1 -0
  23. package/dist/i18n/gaps.d.ts +3 -0
  24. package/dist/i18n/gaps.d.ts.map +1 -0
  25. package/dist/i18n/gaps.js +2 -0
  26. package/dist/i18n/gaps.js.map +1 -0
  27. package/dist/i18n/message-slots.d.ts +19 -0
  28. package/dist/i18n/message-slots.d.ts.map +1 -0
  29. package/dist/i18n/message-slots.js +101 -0
  30. package/dist/i18n/message-slots.js.map +1 -0
  31. package/dist/i18n/text-locale.d.ts +13 -0
  32. package/dist/i18n/text-locale.d.ts.map +1 -0
  33. package/dist/i18n/text-locale.js +14 -0
  34. package/dist/i18n/text-locale.js.map +1 -0
  35. package/dist/i18n/translations.d.ts +56 -0
  36. package/dist/i18n/translations.d.ts.map +1 -0
  37. package/dist/i18n/translations.js +103 -0
  38. package/dist/i18n/translations.js.map +1 -0
  39. package/dist/impact/references.d.ts +143 -0
  40. package/dist/impact/references.d.ts.map +1 -0
  41. package/dist/impact/references.js +429 -0
  42. package/dist/impact/references.js.map +1 -0
  43. package/dist/index.d.ts +86 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +58 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/preview/compile-preview.d.ts +67 -0
  48. package/dist/preview/compile-preview.d.ts.map +1 -0
  49. package/dist/preview/compile-preview.js +286 -0
  50. package/dist/preview/compile-preview.js.map +1 -0
  51. package/dist/preview/handle.d.ts +119 -0
  52. package/dist/preview/handle.d.ts.map +1 -0
  53. package/dist/preview/handle.js +2 -0
  54. package/dist/preview/handle.js.map +1 -0
  55. package/dist/preview/held.d.ts +39 -0
  56. package/dist/preview/held.d.ts.map +1 -0
  57. package/dist/preview/held.js +15 -0
  58. package/dist/preview/held.js.map +1 -0
  59. package/dist/preview/measurement.d.ts +5 -0
  60. package/dist/preview/measurement.d.ts.map +1 -0
  61. package/dist/preview/measurement.js +18 -0
  62. package/dist/preview/measurement.js.map +1 -0
  63. package/dist/publish/build.d.ts +33 -0
  64. package/dist/publish/build.d.ts.map +1 -0
  65. package/dist/publish/build.js +15 -0
  66. package/dist/publish/build.js.map +1 -0
  67. package/dist/publish/diff.d.ts +208 -0
  68. package/dist/publish/diff.d.ts.map +1 -0
  69. package/dist/publish/diff.js +227 -0
  70. package/dist/publish/diff.js.map +1 -0
  71. package/dist/publish/review.d.ts +41 -0
  72. package/dist/publish/review.d.ts.map +1 -0
  73. package/dist/publish/review.js +22 -0
  74. package/dist/publish/review.js.map +1 -0
  75. package/dist/schema/dataset-input.d.ts +30 -0
  76. package/dist/schema/dataset-input.d.ts.map +1 -0
  77. package/dist/schema/dataset-input.js +58 -0
  78. package/dist/schema/dataset-input.js.map +1 -0
  79. package/dist/schema/dataset.d.ts +166 -0
  80. package/dist/schema/dataset.d.ts.map +1 -0
  81. package/dist/schema/dataset.js +281 -0
  82. package/dist/schema/dataset.js.map +1 -0
  83. package/dist/schema/declarations.d.ts +15 -0
  84. package/dist/schema/declarations.d.ts.map +1 -0
  85. package/dist/schema/declarations.js +47 -0
  86. package/dist/schema/declarations.js.map +1 -0
  87. package/dist/schema/document.d.ts +504 -0
  88. package/dist/schema/document.d.ts.map +1 -0
  89. package/dist/schema/document.js +337 -0
  90. package/dist/schema/document.js.map +1 -0
  91. package/dist/schema/error.d.ts +15 -0
  92. package/dist/schema/error.d.ts.map +1 -0
  93. package/dist/schema/error.js +18 -0
  94. package/dist/schema/error.js.map +1 -0
  95. package/dist/schema/field-id.d.ts +8 -0
  96. package/dist/schema/field-id.d.ts.map +1 -0
  97. package/dist/schema/field-id.js +47 -0
  98. package/dist/schema/field-id.js.map +1 -0
  99. package/dist/schema/layout.d.ts +118 -0
  100. package/dist/schema/layout.d.ts.map +1 -0
  101. package/dist/schema/layout.js +101 -0
  102. package/dist/schema/layout.js.map +1 -0
  103. package/dist/schema/palette.d.ts +103 -0
  104. package/dist/schema/palette.d.ts.map +1 -0
  105. package/dist/schema/palette.js +140 -0
  106. package/dist/schema/palette.js.map +1 -0
  107. package/dist/schema/read.d.ts +49 -0
  108. package/dist/schema/read.d.ts.map +1 -0
  109. package/dist/schema/read.js +942 -0
  110. package/dist/schema/read.js.map +1 -0
  111. package/dist/store/apply-dataset.d.ts +14 -0
  112. package/dist/store/apply-dataset.d.ts.map +1 -0
  113. package/dist/store/apply-dataset.js +513 -0
  114. package/dist/store/apply-dataset.js.map +1 -0
  115. package/dist/store/apply.d.ts +37 -0
  116. package/dist/store/apply.d.ts.map +1 -0
  117. package/dist/store/apply.js +2269 -0
  118. package/dist/store/apply.js.map +1 -0
  119. package/dist/store/candidate.d.ts +37 -0
  120. package/dist/store/candidate.d.ts.map +1 -0
  121. package/dist/store/candidate.js +178 -0
  122. package/dist/store/candidate.js.map +1 -0
  123. package/dist/store/commands/coverage.d.ts +58 -0
  124. package/dist/store/commands/coverage.d.ts.map +1 -0
  125. package/dist/store/commands/coverage.js +354 -0
  126. package/dist/store/commands/coverage.js.map +1 -0
  127. package/dist/store/commands/dataset.d.ts +26 -0
  128. package/dist/store/commands/dataset.d.ts.map +1 -0
  129. package/dist/store/commands/dataset.js +368 -0
  130. package/dist/store/commands/dataset.js.map +1 -0
  131. package/dist/store/commands/document.d.ts +21 -0
  132. package/dist/store/commands/document.d.ts.map +1 -0
  133. package/dist/store/commands/document.js +160 -0
  134. package/dist/store/commands/document.js.map +1 -0
  135. package/dist/store/commands/field.d.ts +32 -0
  136. package/dist/store/commands/field.d.ts.map +1 -0
  137. package/dist/store/commands/field.js +572 -0
  138. package/dist/store/commands/field.js.map +1 -0
  139. package/dist/store/commands/layout.d.ts +16 -0
  140. package/dist/store/commands/layout.d.ts.map +1 -0
  141. package/dist/store/commands/layout.js +70 -0
  142. package/dist/store/commands/layout.js.map +1 -0
  143. package/dist/store/commands/parse.d.ts +19 -0
  144. package/dist/store/commands/parse.d.ts.map +1 -0
  145. package/dist/store/commands/parse.js +328 -0
  146. package/dist/store/commands/parse.js.map +1 -0
  147. package/dist/store/commands/readers.d.ts +198 -0
  148. package/dist/store/commands/readers.d.ts.map +1 -0
  149. package/dist/store/commands/readers.js +711 -0
  150. package/dist/store/commands/readers.js.map +1 -0
  151. package/dist/store/commands/rule.d.ts +24 -0
  152. package/dist/store/commands/rule.d.ts.map +1 -0
  153. package/dist/store/commands/rule.js +379 -0
  154. package/dist/store/commands/rule.js.map +1 -0
  155. package/dist/store/commands/shapes.d.ts +900 -0
  156. package/dist/store/commands/shapes.d.ts.map +1 -0
  157. package/dist/store/commands/shapes.js +166 -0
  158. package/dist/store/commands/shapes.js.map +1 -0
  159. package/dist/store/commands/suggestions.d.ts +37 -0
  160. package/dist/store/commands/suggestions.d.ts.map +1 -0
  161. package/dist/store/commands/suggestions.js +177 -0
  162. package/dist/store/commands/suggestions.js.map +1 -0
  163. package/dist/store/commands.d.ts +16 -0
  164. package/dist/store/commands.d.ts.map +1 -0
  165. package/dist/store/commands.js +13 -0
  166. package/dist/store/commands.js.map +1 -0
  167. package/dist/store/dataset-candidate.d.ts +33 -0
  168. package/dist/store/dataset-candidate.d.ts.map +1 -0
  169. package/dist/store/dataset-candidate.js +31 -0
  170. package/dist/store/dataset-candidate.js.map +1 -0
  171. package/dist/store/dataset-pin.d.ts +93 -0
  172. package/dist/store/dataset-pin.d.ts.map +1 -0
  173. package/dist/store/dataset-pin.js +86 -0
  174. package/dist/store/dataset-pin.js.map +1 -0
  175. package/dist/store/dataset-store.d.ts +96 -0
  176. package/dist/store/dataset-store.d.ts.map +1 -0
  177. package/dist/store/dataset-store.js +112 -0
  178. package/dist/store/dataset-store.js.map +1 -0
  179. package/dist/store/history.d.ts +149 -0
  180. package/dist/store/history.d.ts.map +1 -0
  181. package/dist/store/history.js +173 -0
  182. package/dist/store/history.js.map +1 -0
  183. package/dist/store/measurement.d.ts +5 -0
  184. package/dist/store/measurement.d.ts.map +1 -0
  185. package/dist/store/measurement.js +20 -0
  186. package/dist/store/measurement.js.map +1 -0
  187. package/dist/store/notify.d.ts +11 -0
  188. package/dist/store/notify.d.ts.map +1 -0
  189. package/dist/store/notify.js +26 -0
  190. package/dist/store/notify.js.map +1 -0
  191. package/dist/store/published.d.ts +50 -0
  192. package/dist/store/published.d.ts.map +1 -0
  193. package/dist/store/published.js +27 -0
  194. package/dist/store/published.js.map +1 -0
  195. package/dist/store/refusals.d.ts +175 -0
  196. package/dist/store/refusals.d.ts.map +1 -0
  197. package/dist/store/refusals.js +160 -0
  198. package/dist/store/refusals.js.map +1 -0
  199. package/dist/store/steps.d.ts +14 -0
  200. package/dist/store/steps.d.ts.map +1 -0
  201. package/dist/store/steps.js +124 -0
  202. package/dist/store/steps.js.map +1 -0
  203. package/dist/store/store.d.ts +142 -0
  204. package/dist/store/store.d.ts.map +1 -0
  205. package/dist/store/store.js +136 -0
  206. package/dist/store/store.js.map +1 -0
  207. package/dist/store/unchanged.d.ts +12 -0
  208. package/dist/store/unchanged.d.ts.map +1 -0
  209. package/dist/store/unchanged.js +35 -0
  210. package/dist/store/unchanged.js.map +1 -0
  211. package/dist/visual/emit.d.ts +21 -0
  212. package/dist/visual/emit.d.ts.map +1 -0
  213. package/dist/visual/emit.js +133 -0
  214. package/dist/visual/emit.js.map +1 -0
  215. package/dist/visual/parse.d.ts +32 -0
  216. package/dist/visual/parse.d.ts.map +1 -0
  217. package/dist/visual/parse.js +330 -0
  218. package/dist/visual/parse.js.map +1 -0
  219. package/dist/visual/project.d.ts +40 -0
  220. package/dist/visual/project.d.ts.map +1 -0
  221. package/dist/visual/project.js +349 -0
  222. package/dist/visual/project.js.map +1 -0
  223. package/dist/visual/represent.d.ts +50 -0
  224. package/dist/visual/represent.d.ts.map +1 -0
  225. package/dist/visual/represent.js +66 -0
  226. package/dist/visual/represent.js.map +1 -0
  227. package/dist/visual/vocabulary.d.ts +121 -0
  228. package/dist/visual/vocabulary.d.ts.map +1 -0
  229. package/dist/visual/vocabulary.js +32 -0
  230. package/dist/visual/vocabulary.js.map +1 -0
  231. package/package.json +52 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/publish/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,OAAO,EACP,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAUhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AA+KrE,2FAA2F;AAC3F,SAAS,kBAAkB,CAAC,MAAgC;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,MAAM,KAAK,GAAG,CAAC,OAAiC,EAAQ,EAAE;QACxD,KAAK,MAAM,MAAM,IAAI,OAA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Diff,\n compile,\n mergeRevisionMigrations,\n revisionRequirements,\n} from '@azx-pbc/axiom-compiler';\nimport type { RevisionMigration, SchemaDiagnostic } from '@azx-pbc/axiom-compiler';\nimport {\n AxiomError,\n artifactBehaviour,\n compareCodePoints,\n ruleTargets,\n unresolvedUpcasters,\n} from '@azx-pbc/axiom-runtime';\nimport type { ArtifactDiff, CompiledDatasetDeclaration } from '@azx-pbc/axiom-compiler';\nimport type {\n ArtifactBehaviour,\n CompiledField,\n CompiledRule,\n CompiledSchema,\n SchemaCatalogue,\n Upcasters,\n} from '@azx-pbc/axiom-runtime';\nimport { serializeDocument } from '../schema/document.js';\nimport type { AuthoringDocument } from '../schema/document.js';\nimport type { DatasetInput } from '../schema/dataset-input.js';\nimport { withDatasetDeclarations } from '../schema/dataset-input.js';\n\n/**\n * What publishing a draft would mean against the revision a host already published.\n *\n * The authoring store can say what a document declares; only a diff against the published\n * revision can say whether publishing it is a presentation-only edit, a behaviour change a version\n * bump carries, or a revision that recorded values cannot move to without something the revision\n * does not itself contain (`spec/semantics/evolution-v1.md` `EVOL-1.1.1`–`EVOL-3.1.3`).\n *\n * The classification is not a second opinion about behaviour. A compiled draft and the published\n * artifact are compared by `classifyArtifactDiff`, and the hashes the answer rests on are\n * `artifactBehaviour`'s — the identity an evaluation report pins and the publish gate binds its\n * evidence to — so this answer and `verifyPublishReadiness()` cannot disagree about whether a\n * revision moved.\n */\n\n/**\n * What a revision requires before it may publish.\n *\n * - `none`: the behaviour identity is unchanged, so layout and copy alone moved\n * (`EVOL-1.1.1` permits publishing those without a version bump).\n * - `additive`: behaviour moved, the edition advanced, every published declaration is kept, and\n * the revision asks nothing of the values recorded under the published one, so a new edition is\n * all it is.\n * - `requires-migration`: the revision is lawful but not yet migratable — `migrations` names what\n * recorded values need before it publishes.\n *\n * A revision that drops a published declaration, or gives a deprecated one a new rule, is refused\n * instead: neither is something a migration can repair.\n */\nexport type RevisionVerdict = 'none' | 'additive' | 'requires-migration';\n\n/** The revision difference a host reads before it publishes a draft. */\nexport interface PublishedDiff extends ArtifactDiff {\n /** What the revision requires. A host publishes on `none` and `additive` only. */\n readonly verdict: RevisionVerdict;\n /**\n * What the revision asks of the values recorded under the published one, one entry per kind,\n * unioned over every edition the transition passes through. Empty unless `verdict` is\n * `requires-migration`.\n */\n readonly migrations: readonly RevisionMigration[];\n readonly publishedVersion: number;\n readonly draftVersion: number;\n /** The published artifact's behaviour identity, `artifactBehaviour()`. */\n readonly publishedBehaviorHash: string;\n /** The identity the draft would publish with. */\n readonly draftBehaviorHash: string;\n}\n\n/** Why a draft is not a revision the host may publish. */\nexport type RevisionRefusal =\n /** The draft does not compile, so it has no behaviour identity to compare. */\n | { readonly kind: 'draft_not_compiling'; readonly diagnostics: readonly SchemaDiagnostic[] }\n /** The two artifacts are revisions of different documents. */\n | {\n readonly kind: 'different_schema';\n readonly publishedSchemaId: string;\n readonly draftSchemaId: string;\n }\n /**\n * The draft drops a declaration the published revision states. `EVOL-3.1.2` forbids deleting a\n * `fieldId`: a retired field is marked `deprecated` and kept, because signatures, digests and\n * historical reports bind to the identifier. No catalogue entry makes the removal lawful — the\n * upcast refuses the recorded value of a declaration one of the two versions does not name\n * (`EVOL-2.1.7`) — so this is not a migration the host can supply.\n */\n | {\n readonly kind: 'removal_forbidden';\n /** Every published declaration the draft no longer states, in code-point order. */\n readonly removedFields: readonly string[];\n }\n /** A rule a deprecated field newly acquires, forbidden by `EVOL-3.1.3`. */\n | {\n readonly kind: 'deprecated_field_rule';\n /** Every newly acquired rule/deprecated target pair, in rule then field code-point order. */\n readonly violations: readonly { readonly ruleId: string; readonly fieldId: string }[];\n }\n /**\n * A declaration the draft keeps changes which array scope holds its value — out of an array into\n * the record root, or between arrays. `EVOL-2.1.6` carries a value row for row and a row is never\n * an upcaster key, so the recorded values have no pairing and no transform repairs the structure:\n * the host re-establishes where the value belongs, or retires the declaration by deprecating it\n * and adding one that fits.\n */\n | {\n readonly kind: 'row_scope_unpairable';\n /** Every declaration whose row scope the draft changes, in code-point order. */\n readonly fieldIds: readonly string[];\n }\n /** A transform names no value-bearing declaration on both sides of its hop (`EVOL-2.1.7`). */\n | {\n readonly kind: 'upcaster_unresolved';\n /** Every unresolved transform id, in code-point order. */\n readonly fieldIds: readonly string[];\n }\n /**\n * Behaviour moved without the edition advancing — it stayed at the published version or went\n * backwards — which `EVOL-1.1.1` forbids: a device that resolves the published version would\n * evaluate a different form under the same pin, and no retained version resolves backwards.\n */\n | {\n readonly kind: 'version_not_advanced';\n readonly publishedVersion: number;\n readonly draftVersion: number;\n }\n /**\n * The draft skips an edition whose artifact the caller did not supply, so no hop between the two\n * can be read. `EVOL-2.1.2` transforms one edition at a time and `EVOL-2.1.7` refuses a version\n * the catalogue does not hold, so a transition through an unretained edition is one recorded\n * values have no path across.\n */\n | {\n readonly kind: 'version_not_retained';\n readonly from: number;\n readonly to: number;\n /** The first edition the walk needed and the caller did not supply. */\n readonly missingVersion: number;\n };\n\n/** A revision diff, or the reason the draft cannot publish against the published revision. */\nexport type PublishedDiffResult =\n | { readonly kind: 'diff'; readonly diff: PublishedDiff }\n | { readonly kind: 'refused'; readonly refusal: RevisionRefusal };\n\n/** What the caller supplies that is not in the draft. */\nexport interface DiffAgainstPublishedOptions {\n /**\n * The compiled declarations of tables the draft's expressions read. A `datasetRef` pins a\n * table's id and version but does not carry its columns or kind, so strict compilation needs\n * the same declarations the host supplied when it compiled the published artifact.\n */\n readonly datasets?: readonly CompiledDatasetDeclaration[];\n /**\n * The authored tables the host holds, or the dataset stores editing them. The job the `datasets`\n * option does for a caller that already compiled its tables; only the draft's pinned tables are\n * compiled. Either way an expression that reads an undeclared table is the compiler's refusal,\n * naming it.\n */\n readonly tables?: readonly DatasetInput[];\n /**\n * The artifacts the host retains for the editions the draft skips.\n *\n * A consecutive edition needs none: the two artifacts the call already holds are its one hop. A\n * draft that skips editions is judged hop by hop, because each hop states its own requirements\n * and `EVOL-2.1.7` refuses a transition through a version nobody retains — which is why a\n * skipped edition the catalogue does not hold is refused rather than assumed to be an identity.\n */\n readonly catalogue?: SchemaCatalogue;\n /**\n * The transforms the host publishes, keyed by the version each hop starts at and then by\n * `fieldId` (`EVOL-2.1.5`).\n *\n * A transform states what a recorded value becomes, so the hop it belongs to stops requiring an\n * upcaster or a code mapping for that field and the revision can publish. Omitting the map states\n * that the host has written no transform, which is why every requirement the declarations state\n * is then outstanding. It discharges nothing else: row identity, archived context and the\n * measurement basis are not values an upcast sees.\n */\n readonly upcasters?: Upcasters;\n /**\n * The artifact classifier, so a caller that already knows what moved can supply it and a test\n * can prove the invariant below. Defaults to `classifyArtifactDiff`. A supplied classifier is\n * trusted for the declaration sets it reports; the behaviour answer it states is checked\n * against `artifactBehaviour`, because that is the one fact with a second derivation. The\n * identities this call derived are handed to the classifier rather than derived again.\n */\n readonly classify?: (\n published: CompiledSchema,\n draft: CompiledSchema,\n behaviours: { readonly published: ArtifactBehaviour; readonly draft: ArtifactBehaviour },\n ) => ArtifactDiff;\n}\n\n/** Every declaration marked deprecated, including members nested in records and arrays. */\nfunction deprecatedFieldIds(fields: readonly CompiledField[]): ReadonlySet<string> {\n const ids = new Set<string>();\n const visit = (members: readonly CompiledField[]): void => {\n for (const member of members) {\n if (member.annotations?.['deprecated'] === true) ids.add(member.fieldId);\n visit(member.fields ?? []);\n }\n };\n visit(fields);\n return ids;\n}\n\n/** Every declaration a rule decides, including the member an item rule addresses. */\nfunction ruledFieldIds(rule: CompiledRule): ReadonlySet<string> {\n // An item rule's `fieldId` is its array; `targetFieldId` is the member it constrains or writes.\n const targets = new Set(ruleTargets(rule));\n if (rule.targetFieldId !== undefined) targets.add(rule.targetFieldId);\n return targets;\n}\n\n/** Every rule/target pair that gives a deprecated declaration a rule it did not previously have. */\nfunction newRulesOnDeprecatedFields(\n published: CompiledSchema,\n draft: CompiledSchema,\n): readonly { readonly ruleId: string; readonly fieldId: string }[] {\n const publishedRules = new Map((published.rules ?? []).map((rule) => [rule.ruleId, rule]));\n const deprecated = deprecatedFieldIds(draft.fields);\n const violations: { readonly ruleId: string; readonly fieldId: string }[] = [];\n for (const rule of draft.rules ?? []) {\n const prior = publishedRules.get(rule.ruleId);\n const priorTargets = prior === undefined ? undefined : ruledFieldIds(prior);\n for (const fieldId of ruledFieldIds(rule)) {\n if (deprecated.has(fieldId) && priorTargets?.has(fieldId) !== true) {\n violations.push({ ruleId: rule.ruleId, fieldId });\n }\n }\n }\n return violations.sort(\n (left, right) =>\n compareCodePoints(left.ruleId, right.ruleId) ||\n compareCodePoints(left.fieldId, right.fieldId),\n );\n}\n\n/** One edition's move: the declarations values are read under, and the ones they are carried to. */\ninterface EditionHop {\n readonly from: CompiledSchema;\n readonly to: CompiledSchema;\n}\n\n/** The editions a transition passes through, or the first one the caller did not supply. */\ntype EditionWalk =\n | { readonly kind: 'walked'; readonly hops: readonly EditionHop[] }\n | { readonly kind: 'missing'; readonly missingVersion: number };\n\n/**\n * Every hop from the published edition to the draft's, one edition at a time.\n *\n * The endpoints are the artifacts the call holds; a skipped edition's artifact is the host's, so\n * the catalogue supplies it. A hop the walk cannot read is reported rather than skipped: treating\n * an unretained edition as an identity would answer for a path the upcast refuses to take.\n */\nfunction editionHops(\n published: CompiledSchema,\n draft: CompiledSchema,\n catalogue: SchemaCatalogue | undefined,\n): EditionWalk {\n const first = published.schemaVersion;\n const last = draft.schemaVersion;\n const hops: EditionHop[] = [];\n for (let version = first; version < last; version += 1) {\n const from = version === first ? published : catalogue?.get(version);\n const to = version + 1 === last ? draft : catalogue?.get(version + 1);\n if (from === undefined) return { kind: 'missing', missingVersion: version };\n if (to === undefined) return { kind: 'missing', missingVersion: version + 1 };\n hops.push({ from, to });\n }\n return { kind: 'walked', hops };\n}\n\n/**\n * Diff a draft against the revision a host published.\n *\n * The draft is compiled strictly, because the publication it is compared against carries no\n * diagnostics and a draft that does not compile has no behaviour to compare. The comparison then\n * applies the revision contract: presentation-only edits need nothing, a behaviour change needs\n * the edition to advance, and the transition is read one edition at a time so a skipped edition's\n * own requirements and refusals are not lost. A declaration the draft drops, and a rule newly\n * acquired by a deprecated declaration, are refused because no migration repairs either.\n *\n * A classifier that calls a revision presentation-only while `artifactBehaviour` moved — or\n * reports a move the hashes do not show — is a violated invariant, not a diff, so it throws\n * rather than returning a flag a caller could choose to print.\n */\nexport function diffAgainstPublished(\n published: CompiledSchema,\n draft: AuthoringDocument,\n options: DiffAgainstPublishedOptions = {},\n): PublishedDiffResult {\n const resolved = withDatasetDeclarations(draft, options.datasets, options.tables);\n if (!resolved.ok) {\n return {\n kind: 'refused',\n refusal: { kind: 'draft_not_compiling', diagnostics: [resolved.diagnostic] },\n };\n }\n const compiled = compile(\n serializeDocument(draft),\n resolved.declarations.length === 0 ? {} : { datasets: resolved.declarations },\n );\n if (!compiled.ok) {\n return {\n kind: 'refused',\n refusal: { kind: 'draft_not_compiling', diagnostics: compiled.diagnostics },\n };\n }\n return diffAgainstCompiled(published, compiled.schema, options);\n}\n\n/** The options a diff of an already-compiled draft reads; the dataset inputs have done their work. */\nexport type DiffAgainstCompiledOptions = Omit<DiffAgainstPublishedOptions, 'datasets' | 'tables'>;\n\n/**\n * Diff an already-compiled draft against the published revision.\n *\n * The compile is the expensive half and the caller often already holds its artifact — a build, a\n * publish panel, a review — so this is the entry that lets one compile serve the build and the\n * diff. `draft` must be the artifact compiled from the document being compared; the diff reads\n * only the artifact and the published revision, so it cannot detect a mismatch.\n */\nexport function diffAgainstCompiled(\n published: CompiledSchema,\n draft: CompiledSchema,\n options: DiffAgainstCompiledOptions = {},\n): PublishedDiffResult {\n const next = draft;\n if (next.schemaId !== published.schemaId) {\n return {\n kind: 'refused',\n refusal: {\n kind: 'different_schema',\n publishedSchemaId: published.schemaId,\n draftSchemaId: next.schemaId,\n },\n };\n }\n const classify = options.classify ?? classifyArtifactDiff;\n // One derivation per side: the classifier's answer and the hashes this result states are the\n // same two identities, so neither side is hashed a second time.\n const publishedBehaviour = artifactBehaviour(published);\n const draftBehaviour = artifactBehaviour(next);\n const change = classify(published, next, {\n published: publishedBehaviour,\n draft: draftBehaviour,\n });\n const publishedBehaviorHash = publishedBehaviour.behaviorHash;\n const draftBehaviorHash = draftBehaviour.behaviorHash;\n const behaviorChanged = publishedBehaviorHash !== draftBehaviorHash;\n if (change.behaviorChanged !== behaviorChanged) {\n throw new AxiomError(\n 'ENGINE_ERROR',\n `\\`${published.schemaId}\\` behaviour ${behaviorChanged ? 'moved' : 'did not move'} from ${publishedBehaviorHash} to ${draftBehaviorHash}, but the classifier reported behaviorChanged: ${String(change.behaviorChanged)}`,\n );\n }\n const publishedVersion = published.schemaVersion;\n const draftVersion = next.schemaVersion;\n if (!behaviorChanged) {\n return {\n kind: 'diff',\n diff: {\n ...change,\n verdict: 'none',\n // Empty by construction, not by omission: every member a requirement or a refusal is read\n // from — a value domain, an option domain, a `rowKey`, the array containers that locate a\n // value, a context root, a dataset pin — is part of the behaviour identity, so an unchanged\n // identity cannot hide one.\n migrations: [],\n publishedVersion,\n draftVersion,\n publishedBehaviorHash,\n draftBehaviorHash,\n },\n };\n }\n if (draftVersion <= publishedVersion) {\n return {\n kind: 'refused',\n refusal: { kind: 'version_not_advanced', publishedVersion, draftVersion },\n };\n }\n const walk = editionHops(published, next, options.catalogue);\n if (walk.kind === 'missing') {\n return {\n kind: 'refused',\n refusal: {\n kind: 'version_not_retained',\n from: publishedVersion,\n to: draftVersion,\n missingVersion: walk.missingVersion,\n },\n };\n }\n const requirements = walk.hops.map((hop) =>\n revisionRequirements(hop.from, hop.to, options.upcasters?.get(hop.from.schemaVersion)),\n );\n // The refusal covers every hop, so a declaration dropped at an edition the draft passes through\n // is refused even when the endpoints both declare it; for a consecutive edition this is the\n // same set the classifier reports as `removedFields`.\n const removedFields = [\n ...new Set(requirements.flatMap((requirement) => requirement.removedFields)),\n ].sort(compareCodePoints);\n // `EVOL-3.1.2`: a published declaration may be deprecated, never deleted. The target refuses the\n // recorded value of a declaration it does not name (`relocateRecord` → `field_unresolved`), so\n // no catalogue entry can carry a value across a removal. Refusing here keeps this answer and the\n // runtime from disagreeing about whether the transition is survivable.\n if (removedFields.length > 0) {\n return { kind: 'refused', refusal: { kind: 'removal_forbidden', removedFields } };\n }\n const rowsUnpaired = [\n ...new Set(requirements.flatMap((requirement) => requirement.rowsUnpaired)),\n ].sort(compareCodePoints);\n if (rowsUnpaired.length > 0) {\n return { kind: 'refused', refusal: { kind: 'row_scope_unpairable', fieldIds: rowsUnpaired } };\n }\n const unresolved = [\n ...new Set(\n walk.hops.flatMap((hop) =>\n unresolvedUpcasters(hop.from, hop.to, options.upcasters?.get(hop.from.schemaVersion)),\n ),\n ),\n ].sort(compareCodePoints);\n if (unresolved.length > 0) {\n return { kind: 'refused', refusal: { kind: 'upcaster_unresolved', fieldIds: unresolved } };\n }\n // Acquisition belongs to a hop, not just the endpoints: a deprecated field that loses a rule in\n // a retained edition cannot re-acquire it in a later one merely because the endpoints match.\n const deprecatedViolations = walk.hops\n .flatMap((hop) => newRulesOnDeprecatedFields(hop.from, hop.to))\n .sort(\n (left, right) =>\n compareCodePoints(left.ruleId, right.ruleId) ||\n compareCodePoints(left.fieldId, right.fieldId),\n )\n .filter((violation, index, all) => {\n const previous = all[index - 1];\n return (\n previous === undefined ||\n previous.ruleId !== violation.ruleId ||\n previous.fieldId !== violation.fieldId\n );\n });\n if (deprecatedViolations.length > 0) {\n return {\n kind: 'refused',\n refusal: { kind: 'deprecated_field_rule', violations: deprecatedViolations },\n };\n }\n const migrations = mergeRevisionMigrations(\n requirements.flatMap((requirement) => requirement.migrations),\n );\n return {\n kind: 'diff',\n diff: {\n ...change,\n verdict: migrations.length === 0 ? 'additive' : 'requires-migration',\n migrations,\n publishedVersion,\n draftVersion,\n publishedBehaviorHash,\n draftBehaviorHash,\n },\n };\n}\n"]}
@@ -0,0 +1,41 @@
1
+ import type { CompileResult, PublishVerification, ScenarioSuiteDocument } from '@azx-pbc/axiom-compiler';
2
+ import type { CompiledSchema } from '@azx-pbc/axiom-runtime';
3
+ import type { AuthoringDocument } from '../schema/document.js';
4
+ import type { BuildDocumentOptions } from './build.js';
5
+ import type { DiffAgainstCompiledOptions, PublishedDiffResult } from './diff.js';
6
+ /**
7
+ * One compile, every verdict a publish panel asks for.
8
+ *
9
+ * The panel needs three answers about one draft: does it build, what would publishing it change,
10
+ * and does its evidence support publishing. Each of the builder's older entries compiled the
11
+ * draft for its own answer, so a Studio paid three compiles per edit. This entry compiles once —
12
+ * through `buildDocument`, with the draft's own pinned tables — and derives the diff from that
13
+ * artifact. `compilePreview` remains a compile of its own, because it compiles a single-locale
14
+ * fallback the strict build cannot use; a host that shows a preview and a review therefore pays
15
+ * two compiles, not three.
16
+ */
17
+ export interface ReviewDocumentOptions extends BuildDocumentOptions {
18
+ /** The artifact the host serves, so the review can say what publishing the draft would change. */
19
+ readonly published?: CompiledSchema;
20
+ /** The classifier, catalogue and upcasters `diffAgainstPublished` reads. */
21
+ readonly diff?: DiffAgainstCompiledOptions;
22
+ /**
23
+ * The scenario suites the publish verdict executes. Stating a list asks for a verdict even when
24
+ * it is empty; omitting both this and `verify` skips the evidence walk.
25
+ */
26
+ readonly suites?: readonly ScenarioSuiteDocument[];
27
+ /** Ask for the publish verdict over the artifact's own vectors when no suites are supplied. */
28
+ readonly verify?: boolean;
29
+ }
30
+ /** What one compile says about a draft. */
31
+ export interface DocumentReview {
32
+ /** The strict build; its diagnostics are the reason there is no diff or verdict. */
33
+ readonly build: CompileResult;
34
+ /** The revision diff, when the caller supplied a published artifact and the build succeeded. */
35
+ readonly diff?: PublishedDiffResult;
36
+ /** The publish verdict, when the caller asked for one and the build succeeded. */
37
+ readonly readiness?: PublishVerification;
38
+ }
39
+ /** Compiles a draft once and reads its publish diff and evidence verdict off that artifact. */
40
+ export declare function reviewDocument(document: AuthoringDocument, options?: ReviewDocumentOptions): DocumentReview;
41
+ //# sourceMappingURL=review.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../../src/publish/review.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,KAAK,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGjF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE,kGAAkG;IAClG,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC;IACpC,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,CAAC,EAAE,0BAA0B,CAAC;IAC3C;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACnD,+FAA+F;IAC/F,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,2CAA2C;AAC3C,MAAM,WAAW,cAAc;IAC7B,oFAAoF;IACpF,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,gGAAgG;IAChG,QAAQ,CAAC,IAAI,CAAC,EAAE,mBAAmB,CAAC;IACpC,kFAAkF;IAClF,QAAQ,CAAC,SAAS,CAAC,EAAE,mBAAmB,CAAC;CAC1C;AAED,+FAA+F;AAC/F,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,GAAE,qBAA0B,GAClC,cAAc,CAkBhB"}
@@ -0,0 +1,22 @@
1
+ import { verifyPublishReadiness } from '@azx-pbc/axiom-compiler';
2
+ import { buildDocument } from './build.js';
3
+ import { diffAgainstCompiled } from './diff.js';
4
+ /** Compiles a draft once and reads its publish diff and evidence verdict off that artifact. */
5
+ export function reviewDocument(document, options = {}) {
6
+ const build = buildDocument(document, options);
7
+ if (!build.ok)
8
+ return { build };
9
+ const schema = build.schema;
10
+ return {
11
+ build,
12
+ ...(options.published === undefined
13
+ ? {}
14
+ : { diff: diffAgainstCompiled(options.published, schema, options.diff ?? {}) }),
15
+ ...(options.verify === true || options.suites !== undefined
16
+ ? {
17
+ readiness: verifyPublishReadiness(schema, options.suites === undefined ? {} : { suites: options.suites }),
18
+ }
19
+ : {}),
20
+ };
21
+ }
22
+ //# sourceMappingURL=review.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review.js","sourceRoot":"","sources":["../../src/publish/review.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AASjE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAqChD,+FAA+F;AAC/F,MAAM,UAAU,cAAc,CAC5B,QAA2B,EAC3B,OAAO,GAA0B,EAAE;IAEnC,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK,CAAC,EAAE;QAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,OAAO;QACL,KAAK;QACL,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS;YACjC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC;QACjF,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;YACzD,CAAC,CAAC;gBACE,SAAS,EAAE,sBAAsB,CAC/B,MAAM,EACN,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAC/D;aACF;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC","sourcesContent":["import { verifyPublishReadiness } from '@azx-pbc/axiom-compiler';\nimport type {\n CompileResult,\n PublishVerification,\n ScenarioSuiteDocument,\n} from '@azx-pbc/axiom-compiler';\nimport type { CompiledSchema } from '@azx-pbc/axiom-runtime';\nimport type { AuthoringDocument } from '../schema/document.js';\nimport type { BuildDocumentOptions } from './build.js';\nimport { buildDocument } from './build.js';\nimport type { DiffAgainstCompiledOptions, PublishedDiffResult } from './diff.js';\nimport { diffAgainstCompiled } from './diff.js';\n\n/**\n * One compile, every verdict a publish panel asks for.\n *\n * The panel needs three answers about one draft: does it build, what would publishing it change,\n * and does its evidence support publishing. Each of the builder's older entries compiled the\n * draft for its own answer, so a Studio paid three compiles per edit. This entry compiles once —\n * through `buildDocument`, with the draft's own pinned tables — and derives the diff from that\n * artifact. `compilePreview` remains a compile of its own, because it compiles a single-locale\n * fallback the strict build cannot use; a host that shows a preview and a review therefore pays\n * two compiles, not three.\n */\nexport interface ReviewDocumentOptions extends BuildDocumentOptions {\n /** The artifact the host serves, so the review can say what publishing the draft would change. */\n readonly published?: CompiledSchema;\n /** The classifier, catalogue and upcasters `diffAgainstPublished` reads. */\n readonly diff?: DiffAgainstCompiledOptions;\n /**\n * The scenario suites the publish verdict executes. Stating a list asks for a verdict even when\n * it is empty; omitting both this and `verify` skips the evidence walk.\n */\n readonly suites?: readonly ScenarioSuiteDocument[];\n /** Ask for the publish verdict over the artifact's own vectors when no suites are supplied. */\n readonly verify?: boolean;\n}\n\n/** What one compile says about a draft. */\nexport interface DocumentReview {\n /** The strict build; its diagnostics are the reason there is no diff or verdict. */\n readonly build: CompileResult;\n /** The revision diff, when the caller supplied a published artifact and the build succeeded. */\n readonly diff?: PublishedDiffResult;\n /** The publish verdict, when the caller asked for one and the build succeeded. */\n readonly readiness?: PublishVerification;\n}\n\n/** Compiles a draft once and reads its publish diff and evidence verdict off that artifact. */\nexport function reviewDocument(\n document: AuthoringDocument,\n options: ReviewDocumentOptions = {},\n): DocumentReview {\n const build = buildDocument(document, options);\n if (!build.ok) return { build };\n const schema = build.schema;\n return {\n build,\n ...(options.published === undefined\n ? {}\n : { diff: diffAgainstCompiled(options.published, schema, options.diff ?? {}) }),\n ...(options.verify === true || options.suites !== undefined\n ? {\n readiness: verifyPublishReadiness(\n schema,\n options.suites === undefined ? {} : { suites: options.suites },\n ),\n }\n : {}),\n };\n}\n"]}
@@ -0,0 +1,30 @@
1
+ import type { CompiledDatasetDeclaration, SchemaDiagnostic } from '@azx-pbc/axiom-compiler';
2
+ import type { AuthoringDocument } from './document.js';
3
+ import type { AuthoredDatasetDocument } from './dataset.js';
4
+ /**
5
+ * The tables a host holds, as a build, a preview or a diff reads them.
6
+ *
7
+ * A document's `datasetRef` states only a table id and the version it pins: the columns, kind and
8
+ * clock binding a rule is checked against live in the table's own document. A host therefore has
9
+ * to hand those documents to every entry that compiles the schema, and the authoring API takes
10
+ * them in the shape the host already has — the authored document, or the store editing it — and
11
+ * compiles them here, once, rather than asking the host to re-implement the pin walk.
12
+ */
13
+ export type DatasetInput = AuthoredDatasetDocument | DatasetSource;
14
+ /** The only member this module reads from a dataset store, so the store is an input without a cycle. */
15
+ export interface DatasetSource {
16
+ getState(): {
17
+ readonly document: AuthoredDatasetDocument;
18
+ };
19
+ }
20
+ /** The compiled declarations a build may pass to the compiler, or the reason one is not readable. */
21
+ export type DatasetDeclarations = {
22
+ readonly ok: true;
23
+ readonly declarations: readonly CompiledDatasetDeclaration[];
24
+ } | {
25
+ readonly ok: false;
26
+ readonly diagnostic: SchemaDiagnostic;
27
+ };
28
+ /** The declarations a caller supplied directly, plus those resolved from its tables. */
29
+ export declare function withDatasetDeclarations(document: AuthoringDocument, supplied: readonly CompiledDatasetDeclaration[] | undefined, inputs: readonly DatasetInput[] | undefined): DatasetDeclarations;
30
+ //# sourceMappingURL=dataset-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataset-input.d.ts","sourceRoot":"","sources":["../../src/schema/dataset-input.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC5F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE5D;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,uBAAuB,GAAG,aAAa,CAAC;AAEnE,wGAAwG;AACxG,MAAM,WAAW,aAAa;IAC5B,QAAQ,IAAI;QAAE,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,CAAA;KAAE,CAAC;CAC5D;AAYD,qGAAqG;AACrG,MAAM,MAAM,mBAAmB,GAC3B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,SAAS,0BAA0B,EAAE,CAAA;CAAE,GACnF;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAgDlE,wFAAwF;AACxF,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,SAAS,0BAA0B,EAAE,GAAG,SAAS,EAC3D,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,GAC1C,mBAAmB,CAIrB"}
@@ -0,0 +1,58 @@
1
+ import { compileDataset } from '@azx-pbc/axiom-compiler';
2
+ import { serializeDocument } from './document.js';
3
+ /** Whether an input is the store editing a table rather than the table document itself. */
4
+ function isDatasetSource(input) {
5
+ return 'getState' in input && typeof input.getState === 'function';
6
+ }
7
+ /** The authored document behind one input. */
8
+ function documentOf(input) {
9
+ return isDatasetSource(input) ? input.getState().document : input;
10
+ }
11
+ /**
12
+ * The compiled declarations of the tables this document pins.
13
+ *
14
+ * Selection is the document's own pin list, not the host's whole catalogue: a build compiles the
15
+ * tables the artifact will promise, and a table the document does not pin cannot reach it. An
16
+ * input for another table is ignored rather than refused — a host holds a library, not a defect —
17
+ * while a pinned table the inputs do not carry is left for the compiler, whose
18
+ * `DATASET_DECLARATION_MISSING` names the table and version and is the same refusal a `compile()`
19
+ * caller already reads.
20
+ *
21
+ * An input that is not a table the dataset compiler admits is the one case answered here: its
22
+ * diagnostic would otherwise be lost (the schema compiler trusts declarations), so it is restated
23
+ * as a build diagnostic naming the table and the dataset compiler's own cause.
24
+ */
25
+ function datasetDeclarationsFor(document, inputs) {
26
+ if (inputs === undefined || inputs.length === 0)
27
+ return { ok: true, declarations: [] };
28
+ const pins = new Map((document.datasets ?? []).map((pin, index) => [pin.tableId, { ...pin, index }]));
29
+ const declarations = [];
30
+ for (const input of inputs) {
31
+ const table = documentOf(input);
32
+ const pin = pins.get(table.tableId);
33
+ if (pin === undefined)
34
+ continue;
35
+ const compiled = compileDataset({ format: 'json', text: serializeDocument(table) });
36
+ if (!compiled.ok) {
37
+ const first = compiled.diagnostics[0];
38
+ return {
39
+ ok: false,
40
+ diagnostic: {
41
+ code: 'DATASET_DECLARATION_MISSING',
42
+ path: `$.datasets[${String(pin.index)}]`,
43
+ detail: `table \`${table.tableId}\` version ${String(table.tableVersion)} is not a table the dataset compiler admits${first === undefined ? '' : `: ${first.code} at ${first.path} — ${first.detail}`}; repair the table before building a schema that pins it`,
44
+ },
45
+ };
46
+ }
47
+ declarations.push(compiled.dataset.declaration);
48
+ }
49
+ return { ok: true, declarations };
50
+ }
51
+ /** The declarations a caller supplied directly, plus those resolved from its tables. */
52
+ export function withDatasetDeclarations(document, supplied, inputs) {
53
+ const resolved = datasetDeclarationsFor(document, inputs);
54
+ if (!resolved.ok)
55
+ return resolved;
56
+ return { ok: true, declarations: [...(supplied ?? []), ...resolved.declarations] };
57
+ }
58
+ //# sourceMappingURL=dataset-input.js.map
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import type { CompiledDatasetDeclaration, SchemaDiagnostic } from '@azx-pbc/axiom-compiler';\nimport type { AuthoringDocument } from './document.js';\nimport { serializeDocument } from './document.js';\nimport type { AuthoredDatasetDocument } from './dataset.js';\n\n/**\n * The tables a host holds, as a build, a preview or a diff reads them.\n *\n * A document's `datasetRef` states only a table id and the version it pins: the columns, kind and\n * clock binding a rule is checked against live in the table's own document. A host therefore has\n * to hand those documents to every entry that compiles the schema, and the authoring API takes\n * them in the shape the host already has — the authored document, or the store editing it — and\n * compiles them here, once, rather than asking the host to re-implement the pin walk.\n */\nexport type DatasetInput = AuthoredDatasetDocument | DatasetSource;\n\n/** The only member this module reads from a dataset store, so the store is an input without a cycle. */\nexport interface DatasetSource {\n getState(): { readonly document: AuthoredDatasetDocument };\n}\n\n/** Whether an input is the store editing a table rather than the table document itself. */\nfunction isDatasetSource(input: DatasetInput): input is DatasetSource {\n return 'getState' in input && typeof input.getState === 'function';\n}\n\n/** The authored document behind one input. */\nfunction documentOf(input: DatasetInput): AuthoredDatasetDocument {\n return isDatasetSource(input) ? input.getState().document : input;\n}\n\n/** The compiled declarations a build may pass to the compiler, or the reason one is not readable. */\nexport type DatasetDeclarations =\n | { readonly ok: true; readonly declarations: readonly CompiledDatasetDeclaration[] }\n | { readonly ok: false; readonly diagnostic: SchemaDiagnostic };\n\n/**\n * The compiled declarations of the tables this document pins.\n *\n * Selection is the document's own pin list, not the host's whole catalogue: a build compiles the\n * tables the artifact will promise, and a table the document does not pin cannot reach it. An\n * input for another table is ignored rather than refused — a host holds a library, not a defect —\n * while a pinned table the inputs do not carry is left for the compiler, whose\n * `DATASET_DECLARATION_MISSING` names the table and version and is the same refusal a `compile()`\n * caller already reads.\n *\n * An input that is not a table the dataset compiler admits is the one case answered here: its\n * diagnostic would otherwise be lost (the schema compiler trusts declarations), so it is restated\n * as a build diagnostic naming the table and the dataset compiler's own cause.\n */\nfunction datasetDeclarationsFor(\n document: AuthoringDocument,\n inputs: readonly DatasetInput[] | undefined,\n): DatasetDeclarations {\n if (inputs === undefined || inputs.length === 0) return { ok: true, declarations: [] };\n const pins = new Map(\n (document.datasets ?? []).map((pin, index) => [pin.tableId, { ...pin, index }]),\n );\n const declarations: CompiledDatasetDeclaration[] = [];\n for (const input of inputs) {\n const table = documentOf(input);\n const pin = pins.get(table.tableId);\n if (pin === undefined) continue;\n const compiled = compileDataset({ format: 'json', text: serializeDocument(table) });\n if (!compiled.ok) {\n const first = compiled.diagnostics[0];\n return {\n ok: false,\n diagnostic: {\n code: 'DATASET_DECLARATION_MISSING',\n path: `$.datasets[${String(pin.index)}]`,\n detail: `table \\`${table.tableId}\\` version ${String(table.tableVersion)} is not a table the dataset compiler admits${\n first === undefined ? '' : `: ${first.code} at ${first.path} — ${first.detail}`\n }; repair the table before building a schema that pins it`,\n },\n };\n }\n declarations.push(compiled.dataset.declaration);\n }\n return { ok: true, declarations };\n}\n\n/** The declarations a caller supplied directly, plus those resolved from its tables. */\nexport function withDatasetDeclarations(\n document: AuthoringDocument,\n supplied: readonly CompiledDatasetDeclaration[] | undefined,\n inputs: readonly DatasetInput[] | undefined,\n): DatasetDeclarations {\n const resolved = datasetDeclarationsFor(document, inputs);\n if (!resolved.ok) return resolved;\n return { ok: true, declarations: [...(supplied ?? []), ...resolved.declarations] };\n}\n"]}
@@ -0,0 +1,166 @@
1
+ import type { DatasetColumn, HitPolicy, Outcome, QuantityValue, ScalarWireValue } from '@azx-pbc/axiom-runtime';
2
+ import type { AuthoringRefusal } from '../store/refusals.js';
3
+ /**
4
+ * The authored dataset document, as an authoring store holds it.
5
+ *
6
+ * It is `spec/metaschema/dataset.v1.json` in the author's own state: the table's identity, its
7
+ * clock binding, its kind and — for a keyed table — the declared columns, the rows and the hit
8
+ * policy. The shape is the closed contract rather than a second one, and the two facts the
9
+ * metaschema states conditionally are stated by the type instead of left to a runtime check:
10
+ *
11
+ * - a `data` table carries `[effectiveFrom, effectiveTo)` and a `behavior` table carries no range
12
+ * at all (`DATA-2.1.2`, `DATA-2.1.3`), so the binding is a discriminated union;
13
+ * - `COLLECT` carries its `collectLimit` and the other policies carry none (`DATA-3.1.5`);
14
+ * - a `PASS` decision row carries its `output` and a lookup row carries no `outcome`
15
+ * (`DATA-1.2.4`).
16
+ *
17
+ * A value no state of the contract admits is therefore unrepresentable here, and the compiler's
18
+ * own dataset stage is the candidate gate the store holds every rewrite to.
19
+ */
20
+ /** The identity every table states, `DATA-1.1.1`. */
21
+ export interface AuthoredDatasetIdentity {
22
+ readonly tableId: string;
23
+ readonly tableVersion: number;
24
+ }
25
+ /** Which clock a table binds to, and the half-open window a `data` table must declare. */
26
+ export type AuthoredDatasetBinding = {
27
+ readonly binding: 'behavior';
28
+ } | {
29
+ readonly binding: 'data';
30
+ /** The first civil date the table answers for, inclusive. */
31
+ readonly effectiveFrom: string;
32
+ /** The first civil date it no longer answers for, exclusive. */
33
+ readonly effectiveTo: string;
34
+ };
35
+ /** The hit policy a keyed table resolves with, and the cap `COLLECT` must state. */
36
+ export type AuthoredHitPolicy = {
37
+ readonly hitPolicy: 'UNIQUE';
38
+ } | {
39
+ readonly hitPolicy: 'FIRST';
40
+ } | {
41
+ readonly hitPolicy: 'COLLECT';
42
+ readonly collectLimit: number;
43
+ };
44
+ /** One lookup row: a composite key and the output every hit returns. */
45
+ export interface AuthoredLookupRow {
46
+ readonly rowId: string;
47
+ /** One scalar per key column, in declaration order. */
48
+ readonly key: readonly ScalarWireValue[];
49
+ readonly output: Readonly<Record<string, ScalarWireValue>>;
50
+ }
51
+ /**
52
+ * One decision-table row.
53
+ *
54
+ * A `PASS` row states an output because it is the row that decides a result; another verdict may
55
+ * carry one, because the metaschema admits it, but need not.
56
+ */
57
+ export type AuthoredDecisionRow = {
58
+ readonly rowId: string;
59
+ readonly key: readonly ScalarWireValue[];
60
+ readonly outcome: 'PASS';
61
+ readonly output: Readonly<Record<string, ScalarWireValue>>;
62
+ } | {
63
+ readonly rowId: string;
64
+ readonly key: readonly ScalarWireValue[];
65
+ readonly outcome: Exclude<Outcome, 'PASS'>;
66
+ readonly output?: Readonly<Record<string, ScalarWireValue>>;
67
+ };
68
+ /** A `set` table: its closed membership domain and nothing else (`DATA-1.2.1`). */
69
+ export type AuthoredSetTable = AuthoredDatasetIdentity & AuthoredDatasetBinding & {
70
+ readonly kind: 'set';
71
+ readonly values: readonly ScalarWireValue[];
72
+ };
73
+ /** A keyed table that resolves without a verdict: every row carries an output. */
74
+ export type AuthoredLookupTable = AuthoredDatasetIdentity & AuthoredDatasetBinding & AuthoredHitPolicy & {
75
+ readonly kind: 'lookup';
76
+ readonly columns: readonly DatasetColumn[];
77
+ readonly rows: readonly AuthoredLookupRow[];
78
+ };
79
+ /** A keyed table whose rows state a verdict. */
80
+ export type AuthoredDecisionTable = AuthoredDatasetIdentity & AuthoredDatasetBinding & AuthoredHitPolicy & {
81
+ readonly kind: 'decision_table';
82
+ readonly columns: readonly DatasetColumn[];
83
+ readonly rows: readonly AuthoredDecisionRow[];
84
+ };
85
+ /** Every dataset document the authoring store holds. */
86
+ export type AuthoredDatasetDocument = AuthoredSetTable | AuthoredLookupTable | AuthoredDecisionTable;
87
+ /**
88
+ * What a caller states to start a table.
89
+ *
90
+ * The kind, the clock binding and the hit policy are design decisions, so they are constructor
91
+ * arguments rather than edits: a published table's policy is part of what its rows mean, and
92
+ * `binding` decides whether a range exists at all. The `set` arm states no policy because a set has
93
+ * no rows to resolve; the keyed arm must state one.
94
+ */
95
+ export type CreateDatasetOptions = AuthoredDatasetIdentity & (({
96
+ readonly kind: 'set';
97
+ } & AuthoredDatasetBinding) | ({
98
+ readonly kind: 'lookup' | 'decision_table';
99
+ } & AuthoredDatasetBinding & AuthoredHitPolicy));
100
+ /**
101
+ * Starts a table in an explicit identity, binding and policy.
102
+ *
103
+ * The document it returns is a draft, not a table a compiler admits: a `set` has no `values` yet
104
+ * and a keyed table declares no `columns`, so the first `setDatasetValues` or `setDatasetColumns`
105
+ * is the dispatch that completes it. That is the same starting state `createEmptySchema` states,
106
+ * and the store reports what the compiler says about it rather than inventing a default domain.
107
+ */
108
+ export declare function createDatasetTable(options: CreateDatasetOptions): AuthoredDatasetDocument;
109
+ /**
110
+ * The restricted-JCS SHA-256 of the document, `DATA-4.1.2`.
111
+ *
112
+ * This is the digest an artifact pins and a resolution records. The authored document states the
113
+ * metaschema's own members, so the hash is computed over the document itself by the one canonical
114
+ * authority in the repository rather than a second serializer.
115
+ */
116
+ export declare function datasetDigest(document: AuthoredDatasetDocument): string;
117
+ /** One loaded dataset document, or the reason the text is not one. */
118
+ export type DatasetDocumentRead = {
119
+ readonly ok: true;
120
+ readonly document: AuthoredDatasetDocument;
121
+ } | {
122
+ readonly ok: false;
123
+ readonly refusal: AuthoringRefusal;
124
+ };
125
+ /**
126
+ * A measured quantity as a dataset scalar states it, `MODEL-2.1.21`.
127
+ *
128
+ * The dataset declares no unit domain on a column, so the value carries its own unit and the
129
+ * metaschema checks the pair's spelling only: canonical decimal text and a lower-case unit code.
130
+ * The member set is closed, because `unevaluatedProperties: false` is the contract's.
131
+ */
132
+ export declare function isQuantityValue(value: unknown): value is QuantityValue;
133
+ /**
134
+ * Whether a value is a dataset scalar, `spec/metaschema/dataset.v1.json` `$defs/scalar`.
135
+ *
136
+ * The runtime decides this for its own store, but the predicate is not on its public entry; the
137
+ * decision is restated here through the runtime's own money reader, so a value the wire boundary
138
+ * refuses as money is refused here too. Anything that is not an `AxiomError` is a programmer error
139
+ * in the reader and is rethrown rather than reported as "not a scalar".
140
+ */
141
+ export declare function isDatasetScalar(value: unknown): value is ScalarWireValue;
142
+ /**
143
+ * The authored document a `dataset.v1.json` states, or the reason the compiler refuses it.
144
+ *
145
+ * The compiler is the door: its restricted-JSON ingestion, closed metaschema and semantic checks
146
+ * run before this walk, so an accepted document is one an editable store can hold. The walk then
147
+ * states the closed shape as the authored union — the two conditional facts the metaschema cannot
148
+ * express as a type are checked here, and a disagreement is a refusal rather than a cast.
149
+ */
150
+ export declare function readDatasetDocument(source: string): DatasetDocumentRead;
151
+ /**
152
+ * The primitives a dataset column may declare, from the runtime's one registry.
153
+ *
154
+ * A dataset scalar is the runtime's vocabulary (`DATASET_SCALAR_PRIMITIVES`, derived from the
155
+ * metaschema enum), not a list this package maintains: a record or an array is never a column,
156
+ * and `quantity` is a scalar a column may declare. The store's cell kinds read the same registry,
157
+ * so a host can write every column the compiler admits.
158
+ */
159
+ export declare const DATASET_PRIMITIVES: readonly DatasetColumn['primitive'][];
160
+ /** The roles a column states, `DATA-1.2.2`. */
161
+ export declare const DATASET_COLUMN_ROLES: readonly DatasetColumn['role'][];
162
+ /** The hit policies the closed contract enumerates. */
163
+ export declare const DATASET_HIT_POLICIES: readonly HitPolicy[];
164
+ /** The outcomes a decision row states. */
165
+ export declare const DATASET_OUTCOMES: readonly Outcome[];
166
+ //# sourceMappingURL=dataset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataset.d.ts","sourceRoot":"","sources":["../../src/schema/dataset.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EAET,OAAO,EACP,aAAa,EACb,eAAe,EAEhB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D;;;;;;;;;;;;;;;;GAgBG;AAEH,qDAAqD;AACrD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,0FAA0F;AAC1F,MAAM,MAAM,sBAAsB,GAC9B;IAAE,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;CAAE,GAChC;IACE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,gEAAgE;IAChE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEN,oFAAoF;AACpF,MA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