@voltro/cms 0.86.0 → 0.87.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 (201) hide show
  1. package/CHANGELOG.md +5321 -0
  2. package/README.md +138 -0
  3. package/THIRD-PARTY-NOTICES.md +860 -221
  4. package/dist/RichDocumentView.js +81 -36
  5. package/dist/aiCandidates.js +3 -3
  6. package/dist/applicationBuildSnapshotService.js +101 -0
  7. package/dist/assetRenditions.js +102 -0
  8. package/dist/assetRevision.js +46 -0
  9. package/dist/assetUseRights.js +72 -0
  10. package/dist/availability.js +19 -16
  11. package/dist/blueprint.js +75 -75
  12. package/dist/build.d.ts +3063 -0
  13. package/dist/build.js +37 -0
  14. package/dist/buildApplicationAdmission.js +16 -0
  15. package/dist/buildApplicationCatalog.js +136 -0
  16. package/dist/buildApplicationCatalogTable.js +24 -0
  17. package/dist/buildApplicationRest.js +99 -0
  18. package/dist/buildApplicationUpload.js +111 -0
  19. package/dist/buildSnapshot.js +401 -0
  20. package/dist/buildSnapshotApplicationPin.js +32 -0
  21. package/dist/buildSnapshotRest.js +210 -0
  22. package/dist/buildSnapshotService.js +265 -0
  23. package/dist/buildSnapshotTables.js +25 -0
  24. package/dist/bulk.js +71 -70
  25. package/dist/changes.js +279 -62
  26. package/dist/consent.js +5 -5
  27. package/dist/contentLocations.js +53 -0
  28. package/dist/contentProjection.js +83 -0
  29. package/dist/contentRouteIdentity.js +13 -0
  30. package/dist/contentRouteMaterializer.js +97 -0
  31. package/dist/contentRouteTypes.js +39 -0
  32. package/dist/contentSeo.js +189 -0
  33. package/dist/contentTreePath.js +60 -0
  34. package/dist/contentType.js +117 -100
  35. package/dist/contentValues.js +18 -0
  36. package/dist/copies.js +3 -3
  37. package/dist/domainHost.js +7 -0
  38. package/dist/domains.js +81 -87
  39. package/dist/draftTexts.js +37 -37
  40. package/dist/duplicates.js +23 -23
  41. package/dist/environmentAliases.js +138 -0
  42. package/dist/environments.js +107 -69
  43. package/dist/errors.js +54 -14
  44. package/dist/experiments.js +7 -7
  45. package/dist/frontendBindings.js +99 -0
  46. package/dist/frontendMedia.js +18 -0
  47. package/dist/index.d.ts +760 -47
  48. package/dist/index.js +89 -73
  49. package/dist/initializePublicRoutes.js +28 -0
  50. package/dist/liveContentRouteView.js +76 -0
  51. package/dist/nativeOutputDeploymentService.js +205 -0
  52. package/dist/outputActivation.js +234 -0
  53. package/dist/outputActivationOrigin.js +51 -0
  54. package/dist/outputActivationStore.js +411 -0
  55. package/dist/outputActivationTables.js +11 -0
  56. package/dist/outputActivationTarget.js +81 -0
  57. package/dist/outputActivationTargetTable.js +25 -0
  58. package/dist/outputDeployment.js +174 -0
  59. package/dist/outputDeploymentRest.js +168 -0
  60. package/dist/outputDeploymentService.js +241 -0
  61. package/dist/outputRouteGraph.js +177 -0
  62. package/dist/outputSafetyArtifact.js +147 -0
  63. package/dist/outputTargetRest.js +62 -0
  64. package/dist/pathSegmentEncoding.js +4 -0
  65. package/dist/privateCmsTransport.js +76 -0
  66. package/dist/privateNativeRouteReservation.js +10 -0
  67. package/dist/promotion.js +68 -59
  68. package/dist/publicBuild.js +90 -0
  69. package/dist/publicBuildRest.js +98 -0
  70. package/dist/publicBuildService.js +63 -0
  71. package/dist/publicOutputHttp.js +129 -0
  72. package/dist/publicOutputService.js +287 -0
  73. package/dist/publicPresentation.js +17 -0
  74. package/dist/publicRouteDispositionAdmission.js +38 -0
  75. package/dist/publicRouteHistoryStore.js +12 -0
  76. package/dist/publicRouteHistoryView.js +34 -0
  77. package/dist/publicRouteIntegrity.js +5 -0
  78. package/dist/publicRouteMutation.js +6 -0
  79. package/dist/publicRouteNamespace.js +134 -0
  80. package/dist/publicRoutePublication.js +36 -0
  81. package/dist/publicRouteRegistry.js +17 -0
  82. package/dist/publicRouteRegistryBinding.js +194 -0
  83. package/dist/publicRouteRegistryDefinition.js +76 -0
  84. package/dist/publicRouteSitePublication.js +40 -0
  85. package/dist/publicRouteTables.js +13 -0
  86. package/dist/publicRouteUrl.js +18 -0
  87. package/dist/publicationSeo.js +52 -0
  88. package/dist/publicationState.js +296 -0
  89. package/dist/quality.js +8 -8
  90. package/dist/reconfigurePublicRoutes.js +41 -0
  91. package/dist/redirects.js +104 -73
  92. package/dist/referenceGraph.js +15 -14
  93. package/dist/references.js +2 -2
  94. package/dist/release.js +177 -141
  95. package/dist/renderReadAuthority.js +43 -0
  96. package/dist/renderReadGrant.js +137 -0
  97. package/dist/review.js +28 -28
  98. package/dist/richDocument.js +54 -24
  99. package/dist/routeDispositionGraph.js +44 -0
  100. package/dist/routeDispositionRest.js +51 -0
  101. package/dist/routeDispositionService.js +73 -0
  102. package/dist/routeDispositionStore.js +289 -0
  103. package/dist/routeDispositionTables.js +5 -0
  104. package/dist/routeDispositions.js +91 -0
  105. package/dist/routeHistoryStorage.js +320 -0
  106. package/dist/routeHistoryStore.js +12 -0
  107. package/dist/schedule.js +36 -36
  108. package/dist/seo.js +1 -1
  109. package/dist/series.js +11 -11
  110. package/dist/share.js +13 -13
  111. package/dist/siteBindings.js +159 -0
  112. package/dist/siteBuildCandidate.js +104 -0
  113. package/dist/siteDelivery.js +115 -0
  114. package/dist/siteState.js +47 -0
  115. package/dist/snapshotAddressGraph.js +55 -0
  116. package/dist/snapshotAddressRead.js +73 -0
  117. package/dist/snapshotAppConsumer.js +71 -0
  118. package/dist/snapshotAppExecution.js +102 -0
  119. package/dist/snapshotApplication.js +75 -0
  120. package/dist/snapshotApprovedRouteDispositions.js +44 -0
  121. package/dist/snapshotAssetAssembly.js +70 -0
  122. package/dist/snapshotAssetAssemblyRest.js +50 -0
  123. package/dist/snapshotBindingRead.js +61 -0
  124. package/dist/snapshotCodeSeo.js +29 -0
  125. package/dist/snapshotComponent.js +34 -0
  126. package/dist/snapshotComponentSource.js +24 -0
  127. package/dist/snapshotConsumer.js +87 -0
  128. package/dist/snapshotContentIdentity.js +10 -0
  129. package/dist/snapshotDefinitions.js +264 -0
  130. package/dist/snapshotDocumentAssembly.js +193 -0
  131. package/dist/snapshotDocumentAssemblyRest.js +84 -0
  132. package/dist/snapshotDocumentProjection.js +202 -0
  133. package/dist/snapshotDocumentTransfer.js +35 -0
  134. package/dist/snapshotDocumentTransferRest.js +80 -0
  135. package/dist/snapshotDomains.js +56 -0
  136. package/dist/snapshotEnvironment.js +31 -0
  137. package/dist/snapshotFieldPlan.js +85 -0
  138. package/dist/snapshotFrontend.js +103 -0
  139. package/dist/snapshotLink.js +8 -0
  140. package/dist/snapshotMedia.js +111 -0
  141. package/dist/snapshotMediaCapture.js +246 -0
  142. package/dist/snapshotMediaFields.js +225 -0
  143. package/dist/snapshotMediaRead.js +185 -0
  144. package/dist/snapshotMediaReader.js +13 -0
  145. package/dist/snapshotObservation.js +16 -0
  146. package/dist/snapshotObservedRouteHistory.js +34 -0
  147. package/dist/snapshotOutputTransfer.js +78 -0
  148. package/dist/snapshotPageLoader.js +7 -0
  149. package/dist/snapshotPageSeo.js +59 -0
  150. package/dist/snapshotPathLocale.js +15 -0
  151. package/dist/snapshotPresentation.js +86 -0
  152. package/dist/snapshotPresentationPolicy.js +12 -0
  153. package/dist/snapshotProjection.js +119 -0
  154. package/dist/snapshotPublicAccess.js +161 -0
  155. package/dist/snapshotPublicRouteHistory.js +40 -0
  156. package/dist/snapshotReadAdmission.js +38 -0
  157. package/dist/snapshotRedirectOutput.js +151 -0
  158. package/dist/snapshotRedirectTargets.js +24 -0
  159. package/dist/snapshotRedirects.js +132 -0
  160. package/dist/snapshotReference.js +8 -0
  161. package/dist/snapshotReferenceAddress.js +10 -0
  162. package/dist/snapshotReferenceGraph.js +79 -0
  163. package/dist/snapshotReferenceRead.js +65 -0
  164. package/dist/snapshotRelease.js +99 -0
  165. package/dist/snapshotRender.js +361 -0
  166. package/dist/snapshotRenderDependencies.js +178 -0
  167. package/dist/snapshotRenditions.js +88 -0
  168. package/dist/snapshotRichDocument.js +62 -0
  169. package/dist/snapshotRoleTransfer.js +106 -0
  170. package/dist/snapshotRoleTransferRest.js +99 -0
  171. package/dist/snapshotRouteAdmission.js +71 -0
  172. package/dist/snapshotRouteDispatch.js +111 -0
  173. package/dist/snapshotRouteDispositionPlan.js +73 -0
  174. package/dist/snapshotRouteRead.js +43 -0
  175. package/dist/snapshotRoutes.js +79 -0
  176. package/dist/snapshotRouting.js +113 -0
  177. package/dist/snapshotSeo.js +179 -0
  178. package/dist/snapshotSeoControls.js +101 -0
  179. package/dist/snapshotSeoDocumentInventory.js +115 -0
  180. package/dist/snapshotSeoDocuments.js +129 -0
  181. package/dist/snapshotSeoMerge.js +85 -0
  182. package/dist/snapshotSeoMetadata.js +137 -0
  183. package/dist/snapshotSeoOutput.js +173 -0
  184. package/dist/snapshotSeoPathSets.js +105 -0
  185. package/dist/snapshotSeoRead.js +88 -0
  186. package/dist/snapshotSite.js +128 -0
  187. package/dist/snapshotSitemapFiles.js +36 -0
  188. package/dist/snapshotTreeDependencies.js +58 -0
  189. package/dist/snapshotTreeLoader.js +10 -0
  190. package/dist/snapshotTreeRead.js +158 -0
  191. package/dist/staticPathSet.js +177 -0
  192. package/dist/staticPathSetRest.js +129 -0
  193. package/dist/staticPathSetService.js +249 -0
  194. package/dist/staticPathSetStore.js +338 -0
  195. package/dist/tree.js +9 -9
  196. package/dist/validation.js +53 -53
  197. package/dist/web.d.ts +709 -7
  198. package/dist/web.js +50 -33
  199. package/dist/workflow.js +8 -8
  200. package/dist/write.js +250 -225
  201. package/package.json +20 -6
@@ -0,0 +1,111 @@
1
+ import { defineSiteDelivery as e } from "./siteDelivery.js";
2
+ import { nativeSnapshotRouteId as t, readSnapshotRouting as n, snapshotCmsPage as r, snapshotRouteDispatch as i, verifySnapshotRouteOwnership as a } from "./snapshotRouting.js";
3
+ import { coversSnapshotComponents as o } from "./snapshotFrontend.js";
4
+ import { readSnapshotAppExecution as s } from "./snapshotAppExecution.js";
5
+ import { SnapshotRouteReadUnavailable as c, readSnapshotRouteAdmission as l } from "./snapshotRouteAdmission.js";
6
+ import { readAdmittedSnapshotContentRoute as u } from "./snapshotRouteRead.js";
7
+ import { readAdmittedSnapshotBindingContext as d } from "./snapshotBindingRead.js";
8
+ import { snapshotPathLocale as f } from "./snapshotPathLocale.js";
9
+ import { readAdmittedSnapshotTrees as p } from "./snapshotTreeRead.js";
10
+ import { readAdmittedSnapshotFieldPlan as m } from "./snapshotFieldPlan.js";
11
+ import { readAdmittedSnapshotSeo as h } from "./snapshotSeoRead.js";
12
+ import { readAdmittedSnapshotAddressGraph as g } from "./snapshotAddressGraph.js";
13
+ import { readAdmittedSnapshotReferenceGraph as _ } from "./snapshotReferenceGraph.js";
14
+ //#region src/snapshotRouteDispatch.ts
15
+ var v = async (...v) => {
16
+ let [y] = v, b = await l(...v), { snapshot: x, place: S, input: C, route: w, configuration: T } = b, E = n(T);
17
+ if (w !== void 0 && T.definitionDigest !== w.definitionDigest) throw new c({ reason: "binding" });
18
+ let D = w === void 0 ? i(E, C.path, !1) : a(T, w);
19
+ if (D === null) return null;
20
+ if (D.owner === "cms") {
21
+ let e = await u(y, b);
22
+ if (e === null) return null;
23
+ let t = await s(y, S, x, e.output.contentType, e.components, {
24
+ id: e.output.localeId,
25
+ contentLocale: e.output.requestedLocale
26
+ }), n = t.nativePages ? r(E, C.path) : null, i = n === null ? null : await h(y, S, e, b.now), a = n === null ? null : await m(y, S, e, b.now), l = a ?? {
27
+ references: [],
28
+ media: [],
29
+ dependencies: [],
30
+ content: null
31
+ }, f = a === null ? [] : [{
32
+ source: null,
33
+ context: {
34
+ ...e,
35
+ routeId: e.output.routeId
36
+ },
37
+ fields: a
38
+ }], v = t.definitions.value, w = n === null ? [] : Object.keys(v.site.bindings).sort();
39
+ if (w.length > 64) throw new c({ reason: "binding" });
40
+ let T = Object.create(null);
41
+ for (let n of w) {
42
+ let r = await d(y, S, e, n, b.now);
43
+ if (r === null) {
44
+ T[n] = null;
45
+ continue;
46
+ }
47
+ if (!o(v.frontend, r.components, t.context)) throw new c({ reason: "binding" });
48
+ let i = await m(y, S, r, b.now);
49
+ T[n] = {
50
+ output: r.output,
51
+ ...i
52
+ }, f.push({
53
+ source: n,
54
+ context: r,
55
+ fields: i
56
+ });
57
+ }
58
+ if (l.media.length + Object.values(T).reduce((e, t) => e + (t?.media.length ?? 0), 0) > 1024) throw new c({ reason: "binding" });
59
+ let D = {
60
+ nodes: {},
61
+ edges: []
62
+ };
63
+ if (a !== null) {
64
+ if (t.context === void 0) throw new c({ reason: "binding" });
65
+ D = await _(y, S, f, v.frontend, t.context, b.now);
66
+ }
67
+ let O = n === null ? {} : await p(y, S, x, e.output.localeId, {
68
+ contentType: e.output.contentType,
69
+ documentId: e.document.documentId
70
+ }, b.now);
71
+ return {
72
+ owner: "cms",
73
+ presentation: b.presentation,
74
+ capturedAt: x.manifest.capturedAt,
75
+ route: e.output,
76
+ page: n,
77
+ ...l,
78
+ trees: O,
79
+ bindings: T,
80
+ referenceGraph: D,
81
+ addressGraph: a === null ? [] : await g(y, S, f, D, b.now),
82
+ seo: i?.seo ?? null,
83
+ image: i?.image ?? null,
84
+ ...t
85
+ };
86
+ }
87
+ if (D.code === null) throw new c({ reason: "owner" });
88
+ let O = e(T.site), k = f(O, C.path), A = await s(y, S, x, void 0, [], {
89
+ id: k.id,
90
+ contentLocale: k.contentLocale
91
+ });
92
+ if (!A.nativePages) throw new c({ reason: "owner" });
93
+ let j = E.definition?.claims[D.code.file];
94
+ return {
95
+ owner: "code",
96
+ publicCode: j?.kind === "code" && j.public === !0,
97
+ presentation: b.presentation,
98
+ capturedAt: x.manifest.capturedAt,
99
+ route: {
100
+ routeId: t(S, k.id, D.code.file, C.path),
101
+ path: C.path,
102
+ code: D.code,
103
+ localeId: k.id,
104
+ languageTag: k.tag
105
+ },
106
+ trees: await p(y, S, x, k.id, null, b.now),
107
+ ...A
108
+ };
109
+ };
110
+ //#endregion
111
+ export { v as readSnapshotRenderRoute };
@@ -0,0 +1,73 @@
1
+ import { copyObservedRoutes as e } from "./routeHistoryStorage.js";
2
+ import { findVerifiedSnapshotResources as t } from "./buildSnapshot.js";
3
+ import { copyRouteDispositionDefinition as n, routeDispositionFail as r } from "./routeDispositions.js";
4
+ import { compileCmsPublicRouteDeclaration as i } from "./initializePublicRoutes.js";
5
+ import { snapshotRedirectSource as a } from "./snapshotRedirects.js";
6
+ import { isPrivateNativeRouteReservation as o } from "./privateNativeRouteReservation.js";
7
+ import { planExactRouteDispositions as s } from "./routeDispositionGraph.js";
8
+ import { canonicalJson as c } from "@voltro/runtime";
9
+ //#region src/snapshotRouteDispositionPlan.ts
10
+ var l = async (l, u, d, f, p, m) => {
11
+ let h = i(f).routing, { snapshot: g, input: _ } = d.admission, v = g.manifest.parts.find((e) => e.part === "redirects");
12
+ if (v?.format !== "voltro.cms.redirect-history/v4") return r("state");
13
+ let y = new Set(d.contexts.map((e) => e.host));
14
+ if (!y.has(_.host) || y.size > 256 || d.entries.length > 1e5 || d.entries.some((e) => !y.has(e.host))) return r("graph");
15
+ for (let e of y) for (let t of d.site.locales.filter((e) => e.enabled)) for (let n of ["cms", "code"]) if (!d.contexts.some((r) => r.host === e && r.localeIds.includes(t.id) && r.owners.includes(n))) return r("graph");
16
+ let b = [], x = [], S = [], C = [], w = 0, T = /* @__PURE__ */ new Map(), E = (t) => {
17
+ let i = t.value;
18
+ if ([
19
+ "configuration",
20
+ "source:configuration",
21
+ "disposition:configuration"
22
+ ].includes(t.key) && T.set(t.key, i), t.key.startsWith("source:url:") || t.key.startsWith("observed:url:")) {
23
+ let [n] = e([{
24
+ url: i.url,
25
+ routeId: i.routeId
26
+ }]);
27
+ if (n === void 0) return r("state");
28
+ if (new URL(n.url).hostname !== _.host) return;
29
+ let a = t.key.startsWith("source:") ? b : x;
30
+ if (a.length >= 1e5) return r("bounds");
31
+ a.push(n), t.key.startsWith("source:") && i.active === !0 && S.push(n);
32
+ } else if (t.key.startsWith("disposition:url:")) {
33
+ let e = n(i.definition);
34
+ if (new URL(e.source.url).hostname !== _.host) return;
35
+ if (C.length >= 1e5) return r("bounds");
36
+ C.push(e);
37
+ }
38
+ }, D = async (e) => {
39
+ let n = await t(l, u, g, "redirects", e.map((e) => e.key));
40
+ for (let t of e) {
41
+ if (++w > v.entries || c(n.get(t.key)) !== c(t)) return r("state");
42
+ E(t);
43
+ }
44
+ }, O = [], k = a(l, u, p, f, m);
45
+ for await (let e of k.entries(g.manifest.publication)) O.push(e), O.length === 200 && (await D(O), O = []);
46
+ if (O.length > 0 && await D(O), w !== v.entries) return r("state");
47
+ let A = T.get("source:configuration"), j = T.get("configuration"), M = T.get("disposition:configuration");
48
+ if (A === void 0 || j === void 0 || M === void 0 || typeof A.revision != "number" || typeof A.sourceDigest != "string" || typeof j.revision != "number" || j.sourceDigest !== null && typeof j.sourceDigest != "string" || typeof M.revision != "number") return r("state");
49
+ let N = new Map([...x, ...b].map((e) => [e.url, e])), P = new Set(S.map((e) => e.url)), F = [...N.values()].filter((e) => o(h, new URL(e.url).pathname, P.has(e.url)));
50
+ return {
51
+ definitions: s({
52
+ observed: x,
53
+ sourceObserved: b,
54
+ currentOwned: S,
55
+ reserved: F,
56
+ current: d.entries.map((e) => ({
57
+ url: "https://" + e.host + e.path,
58
+ routeId: e.routeId
59
+ })),
60
+ decisions: C,
61
+ now: m
62
+ }),
63
+ routeState: {
64
+ sourceRevision: A.revision,
65
+ sourceDigest: A.sourceDigest,
66
+ outputRevision: j.revision,
67
+ outputSourceDigest: j.sourceDigest,
68
+ approvalRevision: M.revision
69
+ }
70
+ };
71
+ };
72
+ //#endregion
73
+ export { l as readSnapshotRouteDispositionPlan };
@@ -0,0 +1,43 @@
1
+ import { readVerifiedSnapshotResource as e } from "./buildSnapshot.js";
2
+ import { verifySnapshotRouteOwnership as t } from "./snapshotRouting.js";
3
+ import { admitSnapshotPublicDocument as n, admitVerifiedSnapshotPublicDocument as r } from "./snapshotPublicAccess.js";
4
+ import { SnapshotRouteReadUnavailable as i, readSnapshotRouteAdmission as a } from "./snapshotRouteAdmission.js";
5
+ import { projectSnapshotDocument as o } from "./snapshotDocumentProjection.js";
6
+ import { canonicalJson as s } from "@voltro/runtime";
7
+ //#region src/snapshotRouteRead.ts
8
+ var c = (e) => {
9
+ throw new i({ reason: e });
10
+ }, l = async (e, t, n, r, i) => u(e, await a(e, t, n, r, i)), u = async (i, a, l) => {
11
+ let { snapshot: u, binding: d, place: f, input: p, route: m, configuration: h, presentation: g, now: _ } = a;
12
+ if (m === void 0) return null;
13
+ let { contentType: v, documentId: y, localeId: b } = m, x = l === void 0 ? await n(i, f, u, String(v), String(b), String(y), _) : await r(i, f, u, l, String(v), String(b), String(y), _);
14
+ if (x === null) return null;
15
+ let S = x.chain[0];
16
+ if (S.variantId !== m.variantId || S.revisionId !== m.revisionId || S.revision !== m.revision || S.locale !== m.sourceLocale || x.requestedLocale !== m.requestedLocale || m.fallback !== (S.locale !== x.requestedLocale)) return c("route");
17
+ let C = (await e(i, f, u, "schema", `type:${String(v)}`)).value;
18
+ if (h.definitionDigest !== m.definitionDigest || s(h.app) !== s(C.app)) return c("binding");
19
+ if (t(h, m).owner !== "cms") return c("owner");
20
+ let { values: w, components: T } = await o(i, f, u, String(v), S, C, _, g);
21
+ return {
22
+ snapshot: u,
23
+ binding: d,
24
+ route: m,
25
+ document: S,
26
+ components: T,
27
+ output: {
28
+ snapshotId: u.id,
29
+ snapshotDigest: u.digest,
30
+ routeId: String(m.routeId),
31
+ path: p.path,
32
+ contentType: String(v),
33
+ localeId: String(b),
34
+ requestedLocale: x.requestedLocale,
35
+ sourceLocale: S.locale,
36
+ fallback: S.locale !== x.requestedLocale,
37
+ values: w,
38
+ presentation: g
39
+ }
40
+ };
41
+ }, d = async (...e) => (await l(...e))?.output ?? null;
42
+ //#endregion
43
+ export { i as SnapshotRouteReadUnavailable, u as readAdmittedSnapshotContentRoute, d as readSnapshotRoute, l as readSnapshotRouteContext };
@@ -0,0 +1,79 @@
1
+ import { compileSiteDelivery as e } from "./siteDelivery.js";
2
+ import { compileContentRouteTypes as t } from "./contentRouteTypes.js";
3
+ import { pageCapturedPublications as n, readCapturedDocumentEntry as r, verifyPublicationState as i } from "./publicationState.js";
4
+ import { copySnapshotResource as a } from "./buildSnapshot.js";
5
+ import { compileSnapshotRouting as o } from "./snapshotRouting.js";
6
+ import { copySnapshotAppCodePin as s } from "./snapshotDefinitions.js";
7
+ import { ContentRouteMaterializationUnavailable as c, materializeContentRoutes as l } from "./contentRouteMaterializer.js";
8
+ import { Schema as u } from "effect";
9
+ import { createHash as d } from "node:crypto";
10
+ import { canonicalJson as f } from "@voltro/runtime";
11
+ //#region src/snapshotRoutes.ts
12
+ var p = class extends u.TaggedError()("SnapshotRouteUnavailable", { reason: u.Literals([
13
+ "scope",
14
+ "types",
15
+ "mapping",
16
+ "publication",
17
+ "bounds"
18
+ ]) }) {}, m = (e) => {
19
+ throw new p({ reason: e });
20
+ }, h = (e) => d("sha256").update(f(e)).digest("hex"), g = (e) => typeof e == "string" && e.length > 0, _ = (u, d, f, p, _, v = Date.now(), y = {
21
+ definition: null,
22
+ discovery: null
23
+ }) => {
24
+ let b = {
25
+ tenantId: d.tenantId,
26
+ site: d.site,
27
+ environment: d.environment
28
+ }, x = e(p), S = s(_), C = o(y.definition, y.discovery, S);
29
+ if (!Object.values(b).every(g) || x.definition.id !== b.site || !x.definition.environments.includes(b.environment)) return m("scope");
30
+ let w = t(f);
31
+ if (!w.ok) return m(w.reason);
32
+ let T = w.types, E = h({
33
+ site: x.definition,
34
+ types: T,
35
+ routing: C
36
+ }), D = a({
37
+ key: "configuration",
38
+ value: {
39
+ version: 1,
40
+ ...b,
41
+ app: S,
42
+ definitionDigest: E,
43
+ types: T,
44
+ site: x.definition,
45
+ routing: C,
46
+ resolution: "per-node",
47
+ addressScope: "site"
48
+ }
49
+ });
50
+ return {
51
+ format: "voltro.cms.content-routes/v4",
52
+ entries: async function* (e) {
53
+ let t = await i(u, b, e, v);
54
+ if (t.types.length !== T.length || t.types.some((e) => !T.some((t) => t.name === e)) || t.locales.length !== x.contentLocales.length || t.locales.some((e) => !x.contentLocales.includes(e))) return m("scope");
55
+ yield a(D);
56
+ try {
57
+ yield* l({
58
+ scope: b,
59
+ site: x,
60
+ types: T,
61
+ routing: C,
62
+ definitionDigest: E
63
+ }, {
64
+ read: (t, n, i) => r(u, b, e.id, t, n, i, v),
65
+ page: (t, r, i) => n(u, b, e.id, t, r, {
66
+ limit: 200,
67
+ now: v,
68
+ ...i === void 0 ? {} : { after: i }
69
+ })
70
+ });
71
+ } catch (e) {
72
+ if (e instanceof c) return m(e.reason);
73
+ throw e;
74
+ }
75
+ }
76
+ };
77
+ };
78
+ //#endregion
79
+ export { p as SnapshotRouteUnavailable, _ as snapshotContentRoutesSource };
@@ -0,0 +1,113 @@
1
+ import { copySnapshotResource as e } from "./buildSnapshot.js";
2
+ import { Schema as t } from "effect";
3
+ import { createHash as n } from "node:crypto";
4
+ import { canonicalJson as r } from "@voltro/runtime";
5
+ //#region src/snapshotRouting.ts
6
+ var i = class extends t.TaggedError()("SnapshotRoutingUnavailable", { reason: t.Literals([
7
+ "definition",
8
+ "discovery",
9
+ "claim",
10
+ "missing",
11
+ "collision",
12
+ "ownership"
13
+ ]) }) {}, a = (e) => {
14
+ throw new i({ reason: e });
15
+ }, o = (e) => n("sha256").update(r(e)).digest("hex"), s = (e) => typeof e != "object" || !e || Array.isArray(e) ? a("definition") : e, c = (e) => typeof e == "string" && e.length > 0 && e.length <= 1024 && !/[\\\x00-\x1f\x7f:]/.test(e) && e.split("/").every((e) => e !== "" && e !== "." && e !== ".." && e.toLowerCase() !== ".git"), l = (e) => typeof e == "string" && /^[a-f0-9]{64}$/.test(e), u = (t) => e({
16
+ key: "routing",
17
+ value: { data: t }
18
+ }).value.data, d = (e) => {
19
+ if (e === null) return null;
20
+ let t = s(u(e)), n = s(t.claims);
21
+ if (Object.keys(t).length !== 2 || !c(t.pagesDirectory) || Object.keys(n).length > 4096) return a("definition");
22
+ let r = Object.fromEntries(Object.keys(n).sort().map((e) => {
23
+ if (!c(e)) return a("definition");
24
+ let t = s(n[e]);
25
+ return t.kind === "cms" && Object.keys(t).length === 1 ? [e, { kind: "cms" }] : t.kind === "code" && ["collision,kind", "collision,kind,public"].includes(Object.keys(t).sort().join(",")) && [
26
+ "reject",
27
+ "cms",
28
+ "code"
29
+ ].includes(String(t.collision)) && (t.public === void 0 || typeof t.public == "boolean") ? [e, {
30
+ kind: "code",
31
+ collision: t.collision,
32
+ ...t.public === void 0 ? {} : { public: t.public }
33
+ }] : a("definition");
34
+ }));
35
+ return {
36
+ pagesDirectory: t.pagesDirectory,
37
+ claims: r
38
+ };
39
+ }, f = (e, t, n) => {
40
+ let i = d(e);
41
+ if (i === null) return t === null ? {
42
+ definition: null,
43
+ discovery: null
44
+ } : a("discovery");
45
+ let f = s(u(t)), { digest: p, ...m } = f, h = s(f.inputs);
46
+ if (f.version !== 2 || !l(p) || o(m) !== p || f.pagesDirectory !== i.pagesDirectory || !l(h.id) || r(h) !== r({
47
+ id: h.id,
48
+ ...n
49
+ }) || !Array.isArray(f.pages) || f.pages.length === 0 || f.pages.length > 4096) return a("discovery");
50
+ let g = /* @__PURE__ */ new Set();
51
+ for (let e of f.pages) {
52
+ let t = s(e), n = s(t.source), r = s(t.matcher);
53
+ if (!c(t.file) || g.has(t.file) || n.path !== `${i.pagesDirectory}/${t.file}` || !l(n.digest) || typeof t.pattern != "string" || !t.pattern.startsWith("/") || t.pattern.length > 4096 || typeof r.source != "string" || r.source.length > 8192 || r.flags !== "" || !Number.isSafeInteger(r.priority) || Number(r.priority) < 0) return a("discovery");
54
+ try {
55
+ new RegExp(r.source);
56
+ } catch {
57
+ return a("discovery");
58
+ }
59
+ g.add(t.file);
60
+ }
61
+ return Object.keys(i.claims).some((e) => !g.has(e)) ? a("claim") : {
62
+ definition: i,
63
+ discovery: f
64
+ };
65
+ }, p = (e, t, n) => {
66
+ if (e.definition === null || e.discovery === null) return n ? {
67
+ owner: "cms",
68
+ code: null
69
+ } : null;
70
+ let r = e.discovery.pages.filter((e) => new RegExp(e.matcher.source, e.matcher.flags).test(t)).sort((e, t) => e.matcher.priority - t.matcher.priority), i = r[0];
71
+ if (i === void 0) return n ? a("missing") : null;
72
+ if (r[1]?.matcher.priority === i.matcher.priority) return a("collision");
73
+ let o = e.definition.claims[i.file] ?? {
74
+ kind: "code",
75
+ collision: "reject"
76
+ }, s = {
77
+ file: i.file,
78
+ pattern: i.pattern,
79
+ sourceDigest: i.source.digest
80
+ };
81
+ return n ? o.kind === "code" && o.collision === "reject" ? a("collision") : {
82
+ owner: o.kind === "cms" ? "cms" : o.collision,
83
+ code: s
84
+ } : o.kind === "cms" ? null : {
85
+ owner: "code",
86
+ code: s
87
+ };
88
+ }, m = (e, t) => p(e, t, !0), h = (e, t) => {
89
+ if (e.definition === null || e.discovery === null) return a("missing");
90
+ let n = e.discovery.pages.filter((n) => e.definition.claims[n.file]?.kind === "cms" && new RegExp(n.matcher.source, n.matcher.flags).test(t)).sort((e, t) => e.matcher.priority - t.matcher.priority), r = n[0];
91
+ return r === void 0 ? a("missing") : n[1]?.matcher.priority === r.matcher.priority ? a("collision") : {
92
+ file: r.file,
93
+ pattern: r.pattern,
94
+ sourceDigest: r.source.digest
95
+ };
96
+ }, g = (e) => {
97
+ let t = s(e.routing), n = f(t.definition, t.discovery, e.app);
98
+ return r(t) === r(n) ? n : a("discovery");
99
+ }, _ = (e, t) => {
100
+ let n = m(g(e), String(t.path));
101
+ return r(t.ownership) === r(n) ? n : a("ownership");
102
+ }, v = (e, t, n, r) => `native_${o([
103
+ {
104
+ tenantId: e.tenantId,
105
+ site: e.site,
106
+ environment: e.environment
107
+ },
108
+ t,
109
+ n,
110
+ r
111
+ ])}`;
112
+ //#endregion
113
+ export { i as SnapshotRoutingUnavailable, f as compileSnapshotRouting, d as copySnapshotRoutingDefinition, v as nativeSnapshotRouteId, g as readSnapshotRouting, h as snapshotCmsPage, p as snapshotRouteDispatch, m as snapshotRouteOwnership, c as snapshotRoutingPath, _ as verifySnapshotRouteOwnership };
@@ -0,0 +1,179 @@
1
+ import { compileSiteDelivery as e } from "./siteDelivery.js";
2
+ import { normalizeHost as t } from "./domainHost.js";
3
+ import { copySnapshotResource as n, findVerifiedSnapshotResource as r, pinnedSnapshotPartSource as i, readVerifiedSnapshotResource as a, verifyBuildSnapshot as o } from "./buildSnapshot.js";
4
+ import { verifySnapshotRouteOwnership as s } from "./snapshotRouting.js";
5
+ import { contentRouteId as c } from "./contentRouteIdentity.js";
6
+ import { Schema as l } from "effect";
7
+ import { createHash as u } from "node:crypto";
8
+ import { canonicalJson as d } from "@voltro/runtime";
9
+ //#region src/snapshotSeo.ts
10
+ var f = class extends l.TaggedError()("SnapshotSeoUnavailable", { reason: l.Literals([
11
+ "scope",
12
+ "format",
13
+ "configuration",
14
+ "domain",
15
+ "route",
16
+ "publication"
17
+ ]) }) {}, p = (e) => {
18
+ throw new f({ reason: e });
19
+ }, m = (e) => u("sha256").update(d(e)).digest("hex"), h = (e) => typeof e == "string" && e.length > 0, g = async (l, u, f, g) => {
20
+ let _ = {
21
+ tenantId: u.tenantId,
22
+ site: u.site,
23
+ environment: u.environment
24
+ }, v = {
25
+ id: f.id,
26
+ digest: f.digest
27
+ }, y = g.now ?? Date.now(), b = g.xDefault, x = g.routeKey;
28
+ if (x !== void 0 && !/^path:[a-f0-9]{64}$/.test(x)) return p("route");
29
+ if (!Object.values(_).every(h) || typeof b != "boolean") return p("scope");
30
+ let S = await o(l, _, v, y), C = (e, t) => {
31
+ let n = i(l, _, S, e, y);
32
+ return n.format === t ? n : p("format");
33
+ }, w = C("routes", "voltro.cms.content-routes/v4"), T = C("domains", "voltro.cms.domains/v1");
34
+ C("locales", "voltro.cms.locales/v1");
35
+ let E = (await a(l, _, S, "routes", "configuration")).value, D = (await a(l, _, S, "locales", "policy")).value, O = e(E.site);
36
+ if (O.definition.id !== _.site || !O.definition.environments.includes(_.environment) || [E, D].some((e) => e.tenantId !== _.tenantId || e.environment !== _.environment) || D.site !== _.site || d(E.app) !== d(D.app) || E.resolution !== "per-node" || D.resolution !== "per-node" || !Array.isArray(E.types) || E.types.some((e) => typeof e != "object" || !e || !Array.isArray(e.locations))) return p("configuration");
37
+ let k = {
38
+ version: O.definition.version,
39
+ defaultLocale: O.definition.defaultLocale,
40
+ sourceLocale: O.definition.sourceLocale,
41
+ locales: O.definition.locales
42
+ }, A = {
43
+ contentLocales: O.contentLocales,
44
+ defaultLocale: O.defaultLocale,
45
+ sourceLocale: O.sourceLocale,
46
+ fallback: O.fallback,
47
+ prefixes: O.prefixes,
48
+ tags: O.tags,
49
+ directions: O.directions
50
+ };
51
+ if (d(D.definition) !== d(k) || d(D.compiled) !== d(A)) return p("configuration");
52
+ let j;
53
+ for await (let e of T.entries(S.manifest.publication)) {
54
+ let n = e.value;
55
+ if (n.version !== 1 || n.tenantId !== _.tenantId || n.site !== _.site || typeof n.host != "string" || t(n.host) !== n.host || e.key !== n.host || typeof n.primary != "boolean") return p("domain");
56
+ if (n.primary) {
57
+ if (j !== void 0) return p("domain");
58
+ j = n.host;
59
+ }
60
+ }
61
+ if (j === void 0) return p("domain");
62
+ let M = `https://${j}`, N = O.definition.locales.filter((e) => e.enabled), P = (e) => {
63
+ let t = e.value;
64
+ if (t.version !== 1 || t.tenantId !== _.tenantId || t.site !== _.site || t.environment !== _.environment || ![
65
+ t.contentType,
66
+ t.documentId,
67
+ t.mappingId,
68
+ t.localeId,
69
+ t.requestedLocale,
70
+ t.sourceLocale,
71
+ t.variantId,
72
+ t.revisionId
73
+ ].every(h) || !Number.isSafeInteger(t.revision) || Number(t.revision) < 1 || typeof t.fallback != "boolean" || t.definitionDigest !== E.definitionDigest) return p("route");
74
+ let n = t.lastModified;
75
+ if (n !== null && (typeof n != "string" || !Number.isFinite(Date.parse(n)) || new Date(n).toISOString() !== n)) return p("route");
76
+ let r = N.find((e) => e.id === t.localeId), i = E.types.find((e) => e.name === t.contentType);
77
+ if (r === void 0 || r.contentLocale !== t.requestedLocale || i === void 0 || !i.locations.some((e) => e.id === t.mappingId) || ![r.contentLocale, ...O.fallback[r.contentLocale]].includes(String(t.sourceLocale)) || t.fallback !== (t.sourceLocale !== t.requestedLocale) || t.routeId !== c(_, r.id, String(t.contentType), String(t.documentId), String(t.mappingId))) return p("route");
78
+ if (t.state === "unroutable") {
79
+ if (e.key !== `unroutable:${t.routeId}` || t.reason !== "orphan") return p("route");
80
+ } else if (t.state !== "resolved" || typeof t.path != "string" || !t.path.startsWith("/") || t.path.startsWith("//") || /[?#\\]/.test(t.path) || e.key !== `path:${m(t.path)}`) return p("route");
81
+ return t.state === "resolved" && s(E, t), t;
82
+ }, F = async (e, t) => {
83
+ let n = c(_, t, String(e.contentType), String(e.documentId), String(e.mappingId)), i = await r(l, _, S, "routes", `identity:${n}`);
84
+ if (i === null) return null;
85
+ if (i.value.version !== 1 || i.value.kind !== "route-index" || !h(i.value.target)) return p("route");
86
+ let o = await a(l, _, S, "routes", i.value.target), s = P(o);
87
+ return s.routeId === n ? s : p("route");
88
+ }, I = n({
89
+ key: "configuration",
90
+ value: {
91
+ version: 1,
92
+ ..._,
93
+ origin: M,
94
+ xDefault: b,
95
+ sourceSnapshot: {
96
+ id: S.id,
97
+ digest: S.digest
98
+ },
99
+ inputs: S.manifest.parts.filter((e) => [
100
+ "routes",
101
+ "domains",
102
+ "locales"
103
+ ].includes(e.part)),
104
+ addressPolicy: "published-own-variants/v1",
105
+ publicAdmission: "required"
106
+ }
107
+ });
108
+ return {
109
+ format: "voltro.cms.seo-addresses/v2",
110
+ entries: async function* (e) {
111
+ if (d(e) !== d(S.manifest.publication)) return p("publication");
112
+ yield n(I);
113
+ let t = x === void 0 ? w.entries(e) : (async function* () {
114
+ yield await a(l, _, S, "routes", x);
115
+ })();
116
+ for await (let e of t) {
117
+ if (e.key === "configuration" || e.key.startsWith("identity:")) continue;
118
+ let t = P(e), r = await F(t, String(t.localeId));
119
+ if (r === null || d(r) !== d(t)) return p("route");
120
+ if (t.state === "unroutable") {
121
+ yield {
122
+ key: String(t.routeId),
123
+ value: {
124
+ version: 1,
125
+ routeKey: e.key,
126
+ state: "excluded",
127
+ reason: "unroutable"
128
+ }
129
+ };
130
+ continue;
131
+ }
132
+ if (s(E, t).owner === "code") {
133
+ yield {
134
+ key: String(t.routeId),
135
+ value: {
136
+ version: 1,
137
+ routeKey: e.key,
138
+ state: "excluded",
139
+ reason: "code-owned"
140
+ }
141
+ };
142
+ continue;
143
+ }
144
+ let i = [];
145
+ for (let e of N) {
146
+ let n = await F(t, e.id);
147
+ n !== null && n.state === "resolved" && n.fallback === !1 && s(E, n).owner === "cms" && i.push({
148
+ localeId: e.id,
149
+ locale: e.tag,
150
+ routeId: String(n.routeId),
151
+ href: M + String(n.path)
152
+ });
153
+ }
154
+ let a = N.find((e) => e.contentLocale === t.sourceLocale), o = a === void 0 ? void 0 : i.find((e) => e.localeId === a.id);
155
+ if (o === void 0) return p("route");
156
+ yield n({
157
+ key: String(t.routeId),
158
+ value: {
159
+ version: 1,
160
+ state: "resolved",
161
+ routeKey: e.key,
162
+ routeId: t.routeId,
163
+ revisionId: t.revisionId,
164
+ lastModified: t.lastModified,
165
+ requestedLocale: t.requestedLocale,
166
+ sourceLocale: t.sourceLocale,
167
+ fallback: t.fallback,
168
+ canonical: o.href,
169
+ canonicalRouteId: o.routeId,
170
+ alternates: i,
171
+ xDefault: b ? i.find((e) => e.localeId === O.definition.defaultLocale)?.href ?? null : null
172
+ }
173
+ });
174
+ }
175
+ }
176
+ };
177
+ };
178
+ //#endregion
179
+ export { f as SnapshotSeoUnavailable, g as snapshotSeoAddressSource };