@voltro/cms 0.86.0 → 0.88.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 (243) hide show
  1. package/CHANGELOG.md +5484 -0
  2. package/README.md +138 -0
  3. package/THIRD-PARTY-NOTICES.md +1511 -276
  4. package/dist/ContentForm.js +1 -2
  5. package/dist/RichDocumentEditor.js +1 -2
  6. package/dist/RichDocumentView.js +82 -38
  7. package/dist/RichTextSurface.js +1 -2
  8. package/dist/aiCandidates.js +4 -5
  9. package/dist/aiOperations.js +1 -2
  10. package/dist/applicationBuildSnapshotService.js +100 -0
  11. package/dist/assetRenditions.js +101 -0
  12. package/dist/assetRevision.js +45 -0
  13. package/dist/assetUseRights.js +71 -0
  14. package/dist/audiences.js +1 -2
  15. package/dist/availability.js +20 -18
  16. package/dist/blueprint.js +76 -77
  17. package/dist/build.d.ts +3063 -0
  18. package/dist/build.js +37 -0
  19. package/dist/buildApplicationAdmission.js +15 -0
  20. package/dist/buildApplicationCatalog.js +135 -0
  21. package/dist/buildApplicationCatalogTable.js +23 -0
  22. package/dist/buildApplicationRest.js +98 -0
  23. package/dist/buildApplicationUpload.js +110 -0
  24. package/dist/buildSnapshot.js +400 -0
  25. package/dist/buildSnapshotApplicationPin.js +31 -0
  26. package/dist/buildSnapshotRest.js +209 -0
  27. package/dist/buildSnapshotService.js +264 -0
  28. package/dist/buildSnapshotTables.js +24 -0
  29. package/dist/bulk.js +72 -72
  30. package/dist/cacheIdentity.js +1 -2
  31. package/dist/changes.js +280 -64
  32. package/dist/cmsContext.js +1 -2
  33. package/dist/collections.js +1 -2
  34. package/dist/consent.js +6 -7
  35. package/dist/contentLocations.js +52 -0
  36. package/dist/contentProjection.js +82 -0
  37. package/dist/contentRouteIdentity.js +12 -0
  38. package/dist/contentRouteMaterializer.js +96 -0
  39. package/dist/contentRouteTypes.js +38 -0
  40. package/dist/contentSeo.js +188 -0
  41. package/dist/contentTreePath.js +59 -0
  42. package/dist/contentType.js +121 -105
  43. package/dist/contentValues.js +17 -0
  44. package/dist/contentfulImport.js +1 -2
  45. package/dist/copies.js +4 -5
  46. package/dist/cutover.js +1 -2
  47. package/dist/deliveryChecks.js +1 -2
  48. package/dist/domainHost.js +6 -0
  49. package/dist/domains.js +82 -89
  50. package/dist/draftTexts.js +38 -39
  51. package/dist/duplicates.js +24 -25
  52. package/dist/edgePurge.js +1 -2
  53. package/dist/editHistory.js +1 -2
  54. package/dist/effectForm.js +1 -2
  55. package/dist/environmentAliases.js +137 -0
  56. package/dist/environments.js +108 -71
  57. package/dist/errors.js +55 -16
  58. package/dist/experiments.js +8 -9
  59. package/dist/exposure.js +1 -2
  60. package/dist/extensionManifest.js +2 -3
  61. package/dist/extensions.js +1 -2
  62. package/dist/fieldSchema.js +1 -2
  63. package/dist/formStrings.js +1 -2
  64. package/dist/frontendBindings.js +98 -0
  65. package/dist/frontendMedia.js +17 -0
  66. package/dist/glossary.js +1 -2
  67. package/dist/history.js +1 -2
  68. package/dist/htmlImport.js +1 -2
  69. package/dist/index.d.ts +760 -47
  70. package/dist/index.js +89 -73
  71. package/dist/initializePublicRoutes.js +27 -0
  72. package/dist/liveContentRouteView.js +75 -0
  73. package/dist/media.js +1 -2
  74. package/dist/metrics.js +1 -2
  75. package/dist/migration.js +1 -2
  76. package/dist/migrationStages.js +1 -2
  77. package/dist/nativeOutputDeploymentService.js +204 -0
  78. package/dist/outputActivation.js +233 -0
  79. package/dist/outputActivationOrigin.js +50 -0
  80. package/dist/outputActivationStore.js +410 -0
  81. package/dist/outputActivationTables.js +10 -0
  82. package/dist/outputActivationTarget.js +80 -0
  83. package/dist/outputActivationTargetTable.js +24 -0
  84. package/dist/outputDeployment.js +173 -0
  85. package/dist/outputDeploymentRest.js +167 -0
  86. package/dist/outputDeploymentService.js +240 -0
  87. package/dist/outputRouteGraph.js +176 -0
  88. package/dist/outputSafetyArtifact.js +146 -0
  89. package/dist/outputTargetRest.js +61 -0
  90. package/dist/pathSegmentEncoding.js +3 -0
  91. package/dist/presenceAnchors.js +1 -2
  92. package/dist/preview.js +1 -2
  93. package/dist/privateCmsTransport.js +75 -0
  94. package/dist/privateNativeRouteReservation.js +9 -0
  95. package/dist/promotion.js +69 -61
  96. package/dist/publicBuild.js +89 -0
  97. package/dist/publicBuildRest.js +97 -0
  98. package/dist/publicBuildService.js +62 -0
  99. package/dist/publicOutputHttp.js +128 -0
  100. package/dist/publicOutputService.js +286 -0
  101. package/dist/publicPresentation.js +16 -0
  102. package/dist/publicRouteDispositionAdmission.js +37 -0
  103. package/dist/publicRouteHistoryStore.js +11 -0
  104. package/dist/publicRouteHistoryView.js +33 -0
  105. package/dist/publicRouteIntegrity.js +4 -0
  106. package/dist/publicRouteMutation.js +5 -0
  107. package/dist/publicRouteNamespace.js +133 -0
  108. package/dist/publicRoutePublication.js +35 -0
  109. package/dist/publicRouteRegistry.js +16 -0
  110. package/dist/publicRouteRegistryBinding.js +193 -0
  111. package/dist/publicRouteRegistryDefinition.js +75 -0
  112. package/dist/publicRouteSitePublication.js +39 -0
  113. package/dist/publicRouteTables.js +12 -0
  114. package/dist/publicRouteUrl.js +17 -0
  115. package/dist/publicationSeo.js +51 -0
  116. package/dist/publicationState.js +295 -0
  117. package/dist/quality.js +9 -10
  118. package/dist/reconfigurePublicRoutes.js +40 -0
  119. package/dist/recurrence.js +1 -2
  120. package/dist/redirects.js +105 -75
  121. package/dist/referenceGraph.js +16 -16
  122. package/dist/references.js +3 -4
  123. package/dist/release.js +178 -143
  124. package/dist/renderReadAuthority.js +42 -0
  125. package/dist/renderReadGrant.js +136 -0
  126. package/dist/rest.js +1 -2
  127. package/dist/review.js +29 -30
  128. package/dist/richDocument.js +56 -27
  129. package/dist/richInline.js +1 -2
  130. package/dist/routeDispositionGraph.js +43 -0
  131. package/dist/routeDispositionRest.js +50 -0
  132. package/dist/routeDispositionService.js +72 -0
  133. package/dist/routeDispositionStore.js +288 -0
  134. package/dist/routeDispositionTables.js +4 -0
  135. package/dist/routeDispositions.js +90 -0
  136. package/dist/routeHistoryStorage.js +319 -0
  137. package/dist/routeHistoryStore.js +11 -0
  138. package/dist/schedule.js +37 -38
  139. package/dist/search.js +1 -2
  140. package/dist/selectionIntent.js +1 -2
  141. package/dist/seo.js +2 -3
  142. package/dist/series.js +12 -13
  143. package/dist/share.js +14 -15
  144. package/dist/siteBindings.js +158 -0
  145. package/dist/siteBuildCandidate.js +103 -0
  146. package/dist/siteDelivery.js +114 -0
  147. package/dist/siteState.js +46 -0
  148. package/dist/snapshotAddressGraph.js +54 -0
  149. package/dist/snapshotAddressRead.js +72 -0
  150. package/dist/snapshotAppConsumer.js +70 -0
  151. package/dist/snapshotAppExecution.js +101 -0
  152. package/dist/snapshotApplication.js +74 -0
  153. package/dist/snapshotApprovedRouteDispositions.js +43 -0
  154. package/dist/snapshotAssetAssembly.js +69 -0
  155. package/dist/snapshotAssetAssemblyRest.js +49 -0
  156. package/dist/snapshotBindingRead.js +60 -0
  157. package/dist/snapshotCodeSeo.js +28 -0
  158. package/dist/snapshotComponent.js +33 -0
  159. package/dist/snapshotComponentSource.js +23 -0
  160. package/dist/snapshotConsumer.js +86 -0
  161. package/dist/snapshotContentIdentity.js +9 -0
  162. package/dist/snapshotDefinitions.js +263 -0
  163. package/dist/snapshotDocumentAssembly.js +192 -0
  164. package/dist/snapshotDocumentAssemblyRest.js +83 -0
  165. package/dist/snapshotDocumentProjection.js +201 -0
  166. package/dist/snapshotDocumentTransfer.js +34 -0
  167. package/dist/snapshotDocumentTransferRest.js +79 -0
  168. package/dist/snapshotDomains.js +55 -0
  169. package/dist/snapshotEnvironment.js +30 -0
  170. package/dist/snapshotFieldPlan.js +84 -0
  171. package/dist/snapshotFrontend.js +102 -0
  172. package/dist/snapshotLink.js +7 -0
  173. package/dist/snapshotMedia.js +110 -0
  174. package/dist/snapshotMediaCapture.js +245 -0
  175. package/dist/snapshotMediaFields.js +224 -0
  176. package/dist/snapshotMediaRead.js +184 -0
  177. package/dist/snapshotMediaReader.js +12 -0
  178. package/dist/snapshotObservation.js +15 -0
  179. package/dist/snapshotObservedRouteHistory.js +33 -0
  180. package/dist/snapshotOutputTransfer.js +77 -0
  181. package/dist/snapshotPageLoader.js +6 -0
  182. package/dist/snapshotPageSeo.js +58 -0
  183. package/dist/snapshotPathLocale.js +14 -0
  184. package/dist/snapshotPresentation.js +85 -0
  185. package/dist/snapshotPresentationPolicy.js +11 -0
  186. package/dist/snapshotProjection.js +118 -0
  187. package/dist/snapshotPublicAccess.js +160 -0
  188. package/dist/snapshotPublicRouteHistory.js +39 -0
  189. package/dist/snapshotReadAdmission.js +37 -0
  190. package/dist/snapshotRedirectOutput.js +150 -0
  191. package/dist/snapshotRedirectTargets.js +23 -0
  192. package/dist/snapshotRedirects.js +131 -0
  193. package/dist/snapshotReference.js +7 -0
  194. package/dist/snapshotReferenceAddress.js +9 -0
  195. package/dist/snapshotReferenceGraph.js +78 -0
  196. package/dist/snapshotReferenceRead.js +64 -0
  197. package/dist/snapshotRelease.js +98 -0
  198. package/dist/snapshotRender.js +360 -0
  199. package/dist/snapshotRenderDependencies.js +177 -0
  200. package/dist/snapshotRenditions.js +87 -0
  201. package/dist/snapshotRichDocument.js +61 -0
  202. package/dist/snapshotRoleTransfer.js +105 -0
  203. package/dist/snapshotRoleTransferRest.js +98 -0
  204. package/dist/snapshotRouteAdmission.js +70 -0
  205. package/dist/snapshotRouteDispatch.js +110 -0
  206. package/dist/snapshotRouteDispositionPlan.js +72 -0
  207. package/dist/snapshotRouteRead.js +42 -0
  208. package/dist/snapshotRoutes.js +78 -0
  209. package/dist/snapshotRouting.js +112 -0
  210. package/dist/snapshotSeo.js +178 -0
  211. package/dist/snapshotSeoControls.js +100 -0
  212. package/dist/snapshotSeoDocumentInventory.js +114 -0
  213. package/dist/snapshotSeoDocuments.js +128 -0
  214. package/dist/snapshotSeoMerge.js +84 -0
  215. package/dist/snapshotSeoMetadata.js +136 -0
  216. package/dist/snapshotSeoOutput.js +172 -0
  217. package/dist/snapshotSeoPathSets.js +104 -0
  218. package/dist/snapshotSeoRead.js +87 -0
  219. package/dist/snapshotSite.js +127 -0
  220. package/dist/snapshotSitemapFiles.js +35 -0
  221. package/dist/snapshotTreeDependencies.js +57 -0
  222. package/dist/snapshotTreeLoader.js +9 -0
  223. package/dist/snapshotTreeRead.js +157 -0
  224. package/dist/staticPathSet.js +176 -0
  225. package/dist/staticPathSetRest.js +128 -0
  226. package/dist/staticPathSetService.js +248 -0
  227. package/dist/staticPathSetStore.js +337 -0
  228. package/dist/stewardship.js +2 -3
  229. package/dist/taxonomy.js +1 -2
  230. package/dist/team.js +1 -2
  231. package/dist/templates.js +2 -3
  232. package/dist/trackChanges.js +1 -2
  233. package/dist/translation.js +1 -2
  234. package/dist/tree.js +10 -11
  235. package/dist/usage.js +1 -2
  236. package/dist/validation.js +54 -55
  237. package/dist/visualEditing.js +1 -2
  238. package/dist/web.d.ts +709 -7
  239. package/dist/web.js +50 -33
  240. package/dist/workflow.js +9 -10
  241. package/dist/write.js +251 -227
  242. package/dist/xliff.js +1 -2
  243. package/package.json +21 -7
@@ -0,0 +1,131 @@
1
+ import { readPublicationBoundary as e } from "./changes.js";
2
+ import { CMS_PATHS_TABLE as t, CMS_REDIRECTS_TABLE as n } from "./redirects.js";
3
+ import { verifyPublicationState as r } from "./publicationState.js";
4
+ import { copySnapshotResource as i } from "./buildSnapshot.js";
5
+ import { snapshotObservedRouteHistorySource as a } from "./snapshotObservedRouteHistory.js";
6
+ import { snapshotPublicRouteHistorySource as o } from "./snapshotPublicRouteHistory.js";
7
+ import { snapshotApprovedRouteDispositionsSource as s } from "./snapshotApprovedRouteDispositions.js";
8
+ import { Schema as c } from "effect";
9
+ import { and as l, eq as u, gt as d, inSet as f } from "@voltro/database";
10
+ import { createHash as p } from "node:crypto";
11
+ import { canonicalJson as m } from "@voltro/runtime";
12
+ // src/snapshotRedirects.ts
13
+ var h = class extends c.TaggedError()("SnapshotRedirectUnavailable", { reason: c.Literals([
14
+ "scope",
15
+ "checkpoint",
16
+ "row",
17
+ "history"
18
+ ]) }) {}, g = (e) => {
19
+ throw new h({ reason: e });
20
+ }, _ = (e) => typeof e == "string" && e.length > 0, v = (c, h, v, y, b = Date.now()) => {
21
+ let x = {
22
+ tenantId: h.tenantId,
23
+ site: h.site,
24
+ environment: h.environment
25
+ };
26
+ if (!Object.values(x).every(_)) return g("scope");
27
+ let S = o(c, x, y);
28
+ return {
29
+ format: "voltro.cms.redirect-history/v4",
30
+ entries: async function* (o) {
31
+ let h = await e(c, x);
32
+ if (h.generation !== o.generation || h.releaseId !== o.releaseId || h.checkpoint !== o.checkpoint) return g("checkpoint");
33
+ let y = await r(c, x, o, b), C = !1;
34
+ for await (let e of a(c, x, b).entries(o)) if (e.key === "configuration") {
35
+ if (C || e.value.revision !== v.generation || e.value.sourceDigest !== v.sourceDigest || v.generation === 0 != (v.activationId === null)) return g("history");
36
+ C = !0, yield i({
37
+ key: "configuration",
38
+ value: {
39
+ ...e.value,
40
+ version: 4,
41
+ coverage: "source-and-activated-output",
42
+ activationId: v.activationId,
43
+ status: v.generation === 0 ? "before-first-activation" : "observed"
44
+ }
45
+ });
46
+ } else {
47
+ if (!C) return g("history");
48
+ yield i({
49
+ key: "observed:" + e.key,
50
+ value: {
51
+ ...e.value,
52
+ version: 2,
53
+ kind: "observed"
54
+ }
55
+ });
56
+ }
57
+ if (!C) return g("history");
58
+ for await (let e of S.entries(o)) yield i({
59
+ key: "source:" + e.key,
60
+ value: e.value
61
+ });
62
+ for await (let e of s(c, x, b).entries(o)) yield i({
63
+ key: "disposition:" + e.key,
64
+ value: {
65
+ ...e.value,
66
+ kind: e.key === "configuration" ? "disposition-configuration" : "disposition"
67
+ }
68
+ });
69
+ for (let [e, r, a] of [[
70
+ "path",
71
+ t,
72
+ "path"
73
+ ], [
74
+ "redirect",
75
+ n,
76
+ "fromPath"
77
+ ]]) {
78
+ let t;
79
+ for (;;) {
80
+ let n = await c.query({
81
+ table: r,
82
+ predicate: l(u("tenantId", x.tenantId), u("site", x.site), u("environment", x.environment), f("contentType", y.types), f("locale", y.locales), ...t === void 0 ? [] : [d("id", t)]),
83
+ lock: "update",
84
+ order: [{
85
+ column: "id",
86
+ direction: "asc"
87
+ }],
88
+ take: 500,
89
+ skip: void 0,
90
+ projection: [
91
+ "id",
92
+ "contentType",
93
+ "locale",
94
+ "documentId",
95
+ a
96
+ ]
97
+ });
98
+ if (n.length === 0) break;
99
+ for (let t of n) {
100
+ if (![
101
+ t.id,
102
+ t.contentType,
103
+ t.locale,
104
+ t.documentId
105
+ ].every(_) || typeof t[a] != "string") return g("row");
106
+ let n = [
107
+ t.contentType,
108
+ t.locale,
109
+ e === "path" ? t.documentId : t[a]
110
+ ], r = `${e}:${p("sha256").update(m(n)).digest("hex")}`;
111
+ yield i({
112
+ key: r,
113
+ value: {
114
+ version: 1,
115
+ kind: e,
116
+ ...x,
117
+ id: t.id,
118
+ contentType: t.contentType,
119
+ locale: t.locale,
120
+ documentId: t.documentId,
121
+ path: t[a]
122
+ }
123
+ });
124
+ }
125
+ t = String(n[n.length - 1].id);
126
+ }
127
+ }
128
+ }
129
+ };
130
+ };
131
+ export { h as SnapshotRedirectUnavailable, v as snapshotRedirectSource };
@@ -0,0 +1,7 @@
1
+ // src/snapshotReference.ts
2
+ var e = (e, t) => {
3
+ let n = Object.getOwnPropertyDescriptor(e, Symbol.for("voltro.cms.snapshot.reference/v1"));
4
+ if (n === void 0 || n.enumerable || n.writable || typeof n.value != "function") throw Error("Snapshot reference unavailable");
5
+ return n.value(t);
6
+ };
7
+ export { e as snapshotReference };
@@ -0,0 +1,9 @@
1
+ import { readCapturedPublicAddress as e } from "./snapshotAddressRead.js";
2
+ // src/snapshotReferenceAddress.ts
3
+ var t = (t, n, r, i, a, o) => e(t, n, r.snapshot, {
4
+ contentType: i.targetType,
5
+ documentId: i.targetDocumentId,
6
+ localeId: r.output.localeId,
7
+ mappingId: a
8
+ }, o);
9
+ export { t as readPlannedSnapshotReferenceAddress };
@@ -0,0 +1,78 @@
1
+ import { readVerifiedSnapshotResource as e } from "./buildSnapshot.js";
2
+ import { copySnapshotReferenceTypes as t } from "./snapshotProjection.js";
3
+ import { coversSnapshotComponents as n } from "./snapshotFrontend.js";
4
+ import { SnapshotRouteReadUnavailable as r } from "./snapshotRouteAdmission.js";
5
+ import { readAdmittedSnapshotFieldPlan as i } from "./snapshotFieldPlan.js";
6
+ import { readPlannedSnapshotReferenceContext as a } from "./snapshotReferenceRead.js";
7
+ import { createHash as o } from "node:crypto";
8
+ import { canonicalJson as s } from "@voltro/runtime";
9
+ // src/snapshotReferenceGraph.ts
10
+ var c = (e) => {
11
+ throw new r({ reason: e });
12
+ }, l = (e) => o("sha256").update(s(e)).digest("hex"), u = async (r, o, u, d, f, p) => {
13
+ if (u.length === 0 || u.length > 65 || u[0]?.source !== null || new Set(u.map((e) => e.source)).size !== u.length) return c("bounds");
14
+ let m = u[0].context.snapshot;
15
+ if (u.some((e) => e.context.snapshot.id !== m.id || e.context.snapshot.digest !== m.digest || e.context.output.localeId !== f.localeId || e.source?.startsWith("@ref:"))) return c("binding");
16
+ let h = (await e(r, o, m, "projection", "registry")).value;
17
+ if (!Array.isArray(h.types) || !h.types.every((e) => typeof e == "string")) return c("binding");
18
+ let g = new Set(t(h.referenceTypes, h.types)), _ = Object.create(null), v = [], y = /* @__PURE__ */ new Map(), b = u.map((e) => ({
19
+ ...e,
20
+ selection: {
21
+ ...e.source === null ? {} : { binding: e.source },
22
+ references: []
23
+ }
24
+ })), x = u.reduce((e, t) => e + t.fields.media.length, 0);
25
+ if (x > 1024) return c("bounds");
26
+ if (g.size === 0) return {
27
+ nodes: _,
28
+ edges: v
29
+ };
30
+ for (let e = 0; e < b.length; e++) {
31
+ let t = b[e];
32
+ for (let e of t.fields.references) {
33
+ if (!g.has(e.targetType)) continue;
34
+ if (v.length >= 8192) return c("bounds");
35
+ let s = l([
36
+ e.targetType,
37
+ e.targetDocumentId,
38
+ t.context.output.localeId
39
+ ]), u = y.get(s);
40
+ if (!y.has(s)) {
41
+ if (y.size >= 256 || t.selection.references.length >= 16) return c("bounds");
42
+ let l = await a(r, o, t.context, e, p);
43
+ if (l === null) u = null;
44
+ else {
45
+ if (!n(d, l.components, f)) return c("binding");
46
+ let a = await i(r, o, l, p);
47
+ if (x += a.media.length, x > 1024) return c("bounds");
48
+ u = "@ref:" + s;
49
+ let m = {
50
+ ...t.selection,
51
+ references: [...t.selection.references, [...e.path]]
52
+ };
53
+ _[u] = {
54
+ selection: m,
55
+ output: l.output,
56
+ fields: a
57
+ }, b.push({
58
+ source: u,
59
+ context: l,
60
+ fields: a,
61
+ selection: m
62
+ });
63
+ }
64
+ y.set(s, u);
65
+ }
66
+ v.push({
67
+ source: t.source,
68
+ fieldPath: [...e.path],
69
+ target: u ?? null
70
+ });
71
+ }
72
+ }
73
+ return v.sort((e, t) => s(e) < s(t) ? -1 : +(s(e) > s(t))), {
74
+ nodes: _,
75
+ edges: v
76
+ };
77
+ };
78
+ export { u as readAdmittedSnapshotReferenceGraph };
@@ -0,0 +1,64 @@
1
+ import { readVerifiedSnapshotResource as e } from "./buildSnapshot.js";
2
+ import { copySnapshotPresentationValue as t } from "./snapshotPresentation.js";
3
+ import { admitSnapshotPublicDocument as n } from "./snapshotPublicAccess.js";
4
+ import { SnapshotRouteReadUnavailable as r } from "./snapshotRouteAdmission.js";
5
+ import { projectSnapshotDocument as i } from "./snapshotDocumentProjection.js";
6
+ import { readSnapshotRouteContext as a } from "./snapshotRouteRead.js";
7
+ import { readAdmittedSnapshotBindingContext as o } from "./snapshotBindingRead.js";
8
+ import { readAdmittedSnapshotFieldPlan as s } from "./snapshotFieldPlan.js";
9
+ import { canonicalJson as c } from "@voltro/runtime";
10
+ // src/snapshotReferenceRead.ts
11
+ var l = () => {
12
+ throw new r({ reason: "binding" });
13
+ }, u = (e) => !Array.isArray(e) || e.length === 0 || e.length > 128 || e.some((e) => typeof e == "number" ? !Number.isSafeInteger(e) || e < 0 : typeof e != "string" || e.length === 0 || e.length > 256) ? l() : [...e], d = async (e, t, n, r, i) => {
14
+ let a = await f(e, t, n, r, i);
15
+ return a === null ? null : p(e, t, n, a, i);
16
+ }, f = async (e, t, n, r, i) => {
17
+ let a = u(r);
18
+ return (await s(e, t, n, i)).references.find((e) => c(e.path) === c(a)) ?? null;
19
+ }, p = async (t, r, a, o, s) => {
20
+ let c = await n(t, r, a.snapshot, o.targetType, a.output.localeId, o.targetDocumentId, s);
21
+ if (c === null) return null;
22
+ let l = c.chain[0], u = (await e(t, r, a.snapshot, "schema", `type:${o.targetType}`)).value, d = await i(t, r, a.snapshot, o.targetType, l, u, s, a.output.presentation);
23
+ return {
24
+ snapshot: a.snapshot,
25
+ document: l,
26
+ binding: a.binding,
27
+ routeId: a.routeId,
28
+ components: d.components,
29
+ output: {
30
+ contentType: o.targetType,
31
+ localeId: a.output.localeId,
32
+ requestedLocale: c.requestedLocale,
33
+ sourceLocale: l.locale,
34
+ fallback: l.locale !== c.requestedLocale,
35
+ values: d.values,
36
+ presentation: d.presentation
37
+ }
38
+ };
39
+ }, m = async (e, n, r, i, s) => {
40
+ let c = {
41
+ ...i,
42
+ presentation: t(i.presentation)
43
+ }, f = s.now ?? Date.now();
44
+ if (!Array.isArray(c.references) || c.references.length > 16) return l();
45
+ let p = c.references.map(u), m = {
46
+ tenantId: n.tenantId,
47
+ site: n.site,
48
+ environment: n.environment
49
+ }, h = await a(e, m, r, c, {
50
+ ...s,
51
+ now: f
52
+ });
53
+ if (h === null) return null;
54
+ let g = c.binding === void 0 ? {
55
+ ...h,
56
+ routeId: h.output.routeId
57
+ } : await o(e, m, h, c.binding, f);
58
+ for (let t of p) {
59
+ if (g === null) return null;
60
+ g = await d(e, m, g, t, f);
61
+ }
62
+ return g;
63
+ }, h = async (...e) => !Array.isArray(e[3].references) || e[3].references.length === 0 ? l() : m(...e);
64
+ export { d as readAdmittedSnapshotReferenceContext, f as readAdmittedSnapshotReferenceUse, p as readPlannedSnapshotReferenceContext, h as readSnapshotReferenceContext, m as readSnapshotReferenceSourceContext };
@@ -0,0 +1,98 @@
1
+ import { readPublicationBoundary as e } from "./changes.js";
2
+ import { readCapturedPublication as t } from "./publicationState.js";
3
+ import { copySnapshotResource as n } from "./buildSnapshot.js";
4
+ import { CMS_RELEASES_TABLE as r, CMS_RELEASE_ITEMS_TABLE as i } from "./release.js";
5
+ import { Schema as a } from "effect";
6
+ import { and as o, eq as s, gt as c } from "@voltro/database";
7
+ // src/snapshotRelease.ts
8
+ var l = class extends a.TaggedError()("SnapshotReleaseUnavailable", { reason: a.Literals([
9
+ "scope",
10
+ "release",
11
+ "checkpoint",
12
+ "item"
13
+ ]) }) {}, u = (e) => {
14
+ throw new l({ reason: e });
15
+ }, d = (e) => typeof e == "string" && e.trim().length > 0, f = (e) => e === null || d(e), p = (a, l, p, m = Date.now()) => {
16
+ let h = {
17
+ tenantId: l.tenantId,
18
+ site: l.site,
19
+ environment: l.environment
20
+ };
21
+ return ![
22
+ h.tenantId,
23
+ h.site,
24
+ h.environment,
25
+ p
26
+ ].every(d) || !Number.isSafeInteger(m) ? u("scope") : {
27
+ format: "voltro.cms.release/v1",
28
+ entries: async function* (l) {
29
+ let g = await e(a, h);
30
+ if (g.generation !== l.generation || g.releaseId !== p || l.releaseId !== p || g.checkpoint !== l.checkpoint) return u("checkpoint");
31
+ let [_] = await a.query({
32
+ table: r,
33
+ predicate: o(s("tenantId", h.tenantId), s("site", h.site), s("environment", h.environment), s("id", p)),
34
+ lock: "update",
35
+ order: [],
36
+ take: 1,
37
+ skip: void 0,
38
+ projection: void 0
39
+ });
40
+ if (_ === void 0 || _.publicationGeneration !== l.generation || _.publicationCheckpoint !== l.checkpoint || _.status !== "published" || !d(_.name) || !f(_.rollbackOf)) return u("release");
41
+ let v = _.publishedAt instanceof Date ? _.publishedAt.getTime() : typeof _.publishedAt == "string" ? Date.parse(_.publishedAt) : NaN;
42
+ if (!Number.isSafeInteger(v) || v > m) return u("release");
43
+ yield n({
44
+ key: "release",
45
+ value: {
46
+ id: p,
47
+ name: _.name,
48
+ ...h,
49
+ publishedAt: v,
50
+ rollbackOf: _.rollbackOf,
51
+ publication: { ...l }
52
+ }
53
+ });
54
+ let y;
55
+ for (;;) {
56
+ let e = await a.query({
57
+ table: i,
58
+ predicate: o(s("tenantId", h.tenantId), s("releaseId", p), ...y === void 0 ? [] : [c("id", y)]),
59
+ lock: "update",
60
+ order: [{
61
+ column: "id",
62
+ direction: "asc"
63
+ }],
64
+ take: 128,
65
+ skip: void 0,
66
+ projection: void 0
67
+ });
68
+ if (e.length === 0) break;
69
+ for (let r of e) {
70
+ if (![
71
+ r.id,
72
+ r.contentType,
73
+ r.variantId,
74
+ r.locale
75
+ ].every(d) || !Number.isSafeInteger(r.position) || Number(r.position) < 0 || !f(r.previousRevisionId) || !(r.action === "publish" ? d(r.revisionId) : r.action === "unpublish" && r.revisionId === null)) return u("item");
76
+ let e = await t(a, h, l.id, String(r.contentType), String(r.locale), String(r.variantId), m);
77
+ if (r.action === "publish" ? e?.revisionId !== r.revisionId : e !== null) return u("item");
78
+ yield n({
79
+ key: `item:${String(r.id)}`,
80
+ value: {
81
+ id: r.id,
82
+ contentType: r.contentType,
83
+ variantId: r.variantId,
84
+ locale: r.locale,
85
+ action: r.action,
86
+ revisionId: r.revisionId,
87
+ previousRevisionId: r.previousRevisionId,
88
+ position: r.position,
89
+ inherited: r.inherited ?? null
90
+ }
91
+ });
92
+ }
93
+ y = String(e[e.length - 1].id);
94
+ }
95
+ }
96
+ };
97
+ };
98
+ export { l as SnapshotReleaseUnavailable, p as snapshotReleaseSource };