@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,161 @@
1
+ import { compileSiteDelivery as e } from "./siteDelivery.js";
2
+ import { readCapturedDocument as t, verifyPublicationState as n } from "./publicationState.js";
3
+ import { copySnapshotResource as r, readVerifiedSnapshotResource as i, verifyBuildSnapshot as a } from "./buildSnapshot.js";
4
+ import { copySnapshotAppCodePin as o, snapshotContentTypeDefinition as s } from "./snapshotDefinitions.js";
5
+ import { copySnapshotConsentPurposes as c } from "./snapshotPresentation.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/snapshotPublicAccess.ts
10
+ var f = class extends l.TaggedError()("SnapshotPublicAccessUnavailable", { reason: l.Literals([
11
+ "definition",
12
+ "binding",
13
+ "scope",
14
+ "publication",
15
+ "bounds"
16
+ ]) }) {}, p = (e) => {
17
+ throw new f({ reason: e });
18
+ }, m = (e) => u("sha256").update(d(e)).digest("hex"), h = (e) => typeof e == "object" && !!e && !Array.isArray(e), g = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && !/[\x00-\x1f\x7f]/.test(e), _ = (e) => h(e) ? e.kind === "public" || e.kind === "deny" ? Object.keys(e).length === 1 ? { kind: e.kind } : p("definition") : e.kind !== "field" || Object.keys(e).length !== 4 || !g(e.field) || !Array.isArray(e.values) || e.values.length === 0 || e.values.length > 64 || !e.values.every(g) || new Set(e.values).size !== e.values.length || e.missing !== "public" && e.missing !== "deny" ? p("definition") : {
19
+ kind: "field",
20
+ field: e.field,
21
+ values: [...e.values].sort(),
22
+ missing: e.missing
23
+ } : p("definition"), v = (e, t) => {
24
+ if (e.kind !== "field") return;
25
+ let n = Object.hasOwn(t, e.field) ? t[e.field] : void 0;
26
+ if (!h(n) || !["string", "literal"].includes(String(n.kind))) return p("definition");
27
+ let r = n.literals;
28
+ if (n.kind === "literal" && (!Array.isArray(r) || e.values.some((e) => !r.includes(e)))) return p("definition");
29
+ }, y = (e, t, n, i = []) => {
30
+ let a = o(t), l = r({
31
+ key: "configuration",
32
+ value: {
33
+ version: 2,
34
+ app: a,
35
+ consentPurposes: c(i)
36
+ }
37
+ }), u = r({
38
+ key: "definitions",
39
+ value: n
40
+ }).value;
41
+ if (e.length === 0 || new Set(e.map((e) => e.name)).size !== e.length || Object.keys(u).length !== e.length || Object.keys(u).some((t) => !e.some((e) => e.name === t))) return p("definition");
42
+ let d = [...e].sort((e, t) => e.name < t.name ? -1 : +(e.name > t.name)).map((e) => {
43
+ let t = _(u[e.name]);
44
+ return v(t, e.fields), r({
45
+ key: `type:${e.name}`,
46
+ value: {
47
+ version: 1,
48
+ app: a,
49
+ contentType: e.name,
50
+ decision: t,
51
+ schemaDigest: m(s(e, a).value)
52
+ }
53
+ });
54
+ }), f = r({
55
+ key: "registry",
56
+ value: {
57
+ version: 2,
58
+ app: a,
59
+ types: d.map((e) => e.value.contentType),
60
+ consentDigest: m(l),
61
+ definitionDigest: m([...d, l])
62
+ }
63
+ });
64
+ return {
65
+ format: "voltro.cms.public-access/v2",
66
+ entries: function* () {
67
+ yield r(f), yield r(l);
68
+ for (let e of d) yield r(e);
69
+ }
70
+ };
71
+ }, b = async (e, t, n, r, i, a, o = Date.now()) => x(e, t, n, r, { profile: i }, a, o), x = async (e, t, r, i, o, s, c) => {
72
+ if (![
73
+ i,
74
+ "profile" in o ? o.profile : o.exact,
75
+ s
76
+ ].every(g)) return p("scope");
77
+ let l = await a(e, t, r, c);
78
+ return w(e, t, l, await n(e, t, l.manifest.publication, c), i, o, s, c);
79
+ }, S = async (e, t, n, r, i, a, o, s) => w(e, t, n, r, i, { profile: a }, o, s), C = async (e, t, n, r, i, a, o, s) => w(e, t, n, r, i, { exact: a }, o, s), w = async (n, r, a, o, s, c, l, u) => {
80
+ if (![
81
+ s,
82
+ "profile" in c ? c.profile : c.exact,
83
+ l
84
+ ].every(g)) return p("scope");
85
+ for (let [e, t] of [
86
+ ["policies", "voltro.cms.public-access/v2"],
87
+ ["schema", "voltro.cms.schema/v1"],
88
+ ["site", "voltro.cms.site/v3"],
89
+ ["locales", "voltro.cms.locales/v1"]
90
+ ]) if (a.manifest.parts.find((t) => t.part === e)?.format !== t) return p("binding");
91
+ if (!o.types.includes(s)) return p("scope");
92
+ let f = (await i(n, r, a, "policies", `type:${s}`)).value, y = (await i(n, r, a, "schema", `type:${s}`)).value, b = (await i(n, r, a, "site", "configuration")).value, x = (await i(n, r, a, "locales", "policy")).value;
93
+ if (f.version !== 1 || y.version !== 1 || b.version !== 3 || x.version !== 1 || f.contentType !== s || f.schemaDigest !== m(y) || [
94
+ f,
95
+ b,
96
+ x
97
+ ].some((e) => d(e.app) !== d(y.app)) || [b, x].some((e) => e.tenantId !== r.tenantId || e.site !== r.site || e.environment !== r.environment) || !h(b.definition) || !h(x.definition) || x.resolution !== "per-node") return p("binding");
98
+ let S = e({
99
+ ...b.definition,
100
+ ...x.definition
101
+ }), C = {
102
+ contentLocales: S.contentLocales,
103
+ defaultLocale: S.defaultLocale,
104
+ sourceLocale: S.sourceLocale,
105
+ fallback: S.fallback,
106
+ prefixes: S.prefixes,
107
+ tags: S.tags,
108
+ directions: S.directions
109
+ };
110
+ if (S.definition.id !== r.site || !S.definition.environments.includes(r.environment) || [b, x].some((e) => e.definitionDigest !== m(S.definition)) || d(x.compiled) !== d(C) || o.locales.length !== S.contentLocales.length || o.locales.some((e) => !S.contentLocales.includes(e))) return p("binding");
111
+ let w = "profile" in c ? S.definition.locales.find((e) => e.id === c.profile && e.enabled)?.contentLocale : S.contentLocales.includes(c.exact) ? c.exact : void 0;
112
+ if (w === void 0) return p("scope");
113
+ let T = y.definition;
114
+ if (!h(T) || T.name !== s || !h(T.fields)) return p("binding");
115
+ let E = _(f.decision);
116
+ if (v(E, T.fields), E.kind === "deny") return null;
117
+ let D = T.tree, O;
118
+ if (D !== void 0) {
119
+ if (!h(D) || !g(D.parent)) return p("binding");
120
+ O = D.parent;
121
+ let e = T.fields[O];
122
+ if (!h(e) || e.kind !== "reference" || e.referenceType !== s) return p("binding");
123
+ }
124
+ let k = [], A = /* @__PURE__ */ new Set(), j = [w, ..."profile" in c ? S.fallback[w] : []], M = l;
125
+ for (;;) {
126
+ if (A.has(M)) return null;
127
+ if (A.size >= 128) return p("bounds");
128
+ A.add(M);
129
+ let e = null;
130
+ for (let i of j) if (e = await t(n, r, a.manifest.publication.id, s, i, M, u), e !== null) break;
131
+ if (e === null) return null;
132
+ if (e.status !== "published" || e.documentId !== M || ![
133
+ e.id,
134
+ e.revisionId,
135
+ e.locale
136
+ ].every(g) || !Number.isSafeInteger(e.revision) || Number(e.revision) < 1) return p("publication");
137
+ if (E.kind === "field") {
138
+ let t = e[E.field];
139
+ if (t == null) {
140
+ if (E.missing !== "public") return null;
141
+ } else if (typeof t != "string" || !E.values.includes(t)) return null;
142
+ }
143
+ k.push({
144
+ documentId: M,
145
+ variantId: String(e.id),
146
+ revisionId: String(e.revisionId),
147
+ revision: Number(e.revision),
148
+ locale: String(e.locale)
149
+ });
150
+ let i = O === void 0 ? void 0 : e[O];
151
+ if (i == null || i === "") return {
152
+ contentType: s,
153
+ requestedLocale: w,
154
+ chain: k
155
+ };
156
+ if (!g(i)) return p("publication");
157
+ M = i;
158
+ }
159
+ };
160
+ //#endregion
161
+ export { f as SnapshotPublicAccessUnavailable, b as admitSnapshotPublicDocument, S as admitVerifiedSnapshotPublicDocument, C as admitVerifiedSnapshotPublicDocumentLocale, y as snapshotPublicAccessSource };
@@ -0,0 +1,40 @@
1
+ import { publicRouteRegistryFail as e } from "./publicRouteRegistry.js";
2
+ import { copySnapshotResource as t } from "./buildSnapshot.js";
3
+ import { compileCmsPublicRouteDeclaration as n } from "./initializePublicRoutes.js";
4
+ import { readPublicRouteHistoryView as r } from "./publicRouteHistoryView.js";
5
+ import { canonicalJson as i } from "@voltro/runtime";
6
+ //#region src/snapshotPublicRouteHistory.ts
7
+ var a = (a, o, s) => {
8
+ let c = n(s);
9
+ return {
10
+ format: "voltro.cms.source-route-history/v1",
11
+ entries: async function* () {
12
+ let n = await r(a, o);
13
+ if (i(n.namespace.binding.definition) !== i(c)) return e("configuration");
14
+ yield t({
15
+ key: "configuration",
16
+ value: {
17
+ version: 1,
18
+ ...n.namespace.scope,
19
+ kind: "source-configuration",
20
+ coverage: "declared-content-source",
21
+ nativeInventory: "not-enumerated",
22
+ binding: n.namespace.binding,
23
+ currentNamespaceDigest: n.namespace.sourceDigest,
24
+ ...n.history
25
+ }
26
+ });
27
+ for await (let e of n.entries()) yield t({
28
+ key: "url:" + e.urlKey,
29
+ value: {
30
+ version: 1,
31
+ ...n.namespace.scope,
32
+ kind: "source-observed",
33
+ ...e
34
+ }
35
+ });
36
+ }
37
+ };
38
+ };
39
+ //#endregion
40
+ export { a as snapshotPublicRouteHistorySource };
@@ -0,0 +1,38 @@
1
+ import { verifyBuildSnapshot as e } from "./buildSnapshot.js";
2
+ import { Schema as t } from "effect";
3
+ //#region src/snapshotReadAdmission.ts
4
+ var n = class extends t.TaggedError()("SnapshotReadAdmissionUnavailable", { reason: t.Literals(["binding"]) }) {}, r = async (t, r, i, a) => {
5
+ let o = await e(t, r, i, a);
6
+ for (let [e, t] of Object.entries({
7
+ policies: "voltro.cms.public-access/v2",
8
+ projection: "voltro.cms.field-projection/v1",
9
+ routes: "voltro.cms.content-routes/v4",
10
+ domains: "voltro.cms.domains/v1",
11
+ schema: "voltro.cms.schema/v1",
12
+ components: "voltro.cms.components/v1",
13
+ assets: "voltro.cms.media-custody/v2",
14
+ site: "voltro.cms.site/v3",
15
+ locales: "voltro.cms.locales/v1",
16
+ seo: "voltro.cms.seo-metadata/v1"
17
+ })) if (o.manifest.parts.find((t) => t.part === e)?.format !== t) throw new n({ reason: "binding" });
18
+ return o;
19
+ }, i = async (e, t, n, i, a) => {
20
+ let o = await r(e, t, n, a);
21
+ return {
22
+ snapshot: o,
23
+ binding: {
24
+ tenantId: t.tenantId,
25
+ site: t.site,
26
+ environment: t.environment,
27
+ consumerId: i.consumerId,
28
+ buildId: i.buildId,
29
+ snapshotId: o.id,
30
+ snapshotDigest: o.digest,
31
+ releaseId: o.manifest.publication.releaseId,
32
+ policyDigest: o.manifest.parts.find((e) => e.part === "policies").digest,
33
+ projectionDigest: o.manifest.parts.find((e) => e.part === "projection").digest
34
+ }
35
+ };
36
+ };
37
+ //#endregion
38
+ export { n as SnapshotReadAdmissionUnavailable, r as readAdmittedBuildSnapshot, i as resolveSnapshotReadBinding };
@@ -0,0 +1,151 @@
1
+ import { lockSiteState as e } from "./siteState.js";
2
+ import { routeDispositionFail as t } from "./routeDispositions.js";
3
+ import { lockOutputRouteHistoryCapture as n } from "./outputActivationStore.js";
4
+ import { copySnapshotSeoDocumentsSelection as r } from "./snapshotSeoPathSets.js";
5
+ import { readSnapshotSeoDocuments as i, snapshotOutputSafetyBinding as a } from "./snapshotSeoDocuments.js";
6
+ import { copyOutputSafetySelection as o, readVerifiedOutputSafetyArtifact as s } from "./outputSafetyArtifact.js";
7
+ import { readSnapshotRouteDispositionPlan as c } from "./snapshotRouteDispositionPlan.js";
8
+ import { copySnapshotRedirectTargets as l } from "./snapshotRedirectTargets.js";
9
+ import { createHash as u } from "node:crypto";
10
+ import { canonicalJson as d } from "@voltro/runtime";
11
+ //#region src/snapshotRedirectOutput.ts
12
+ var f = (u, d, f, p, m) => {
13
+ let h = {
14
+ tenantId: d.tenantId,
15
+ site: d.site,
16
+ environment: d.environment
17
+ }, g = {
18
+ snapshot: {
19
+ id: f.id,
20
+ digest: f.digest
21
+ },
22
+ token: p.token,
23
+ consumerId: p.consumerId,
24
+ buildId: p.buildId,
25
+ host: p.host
26
+ }, _ = r(p.documents), v = o(p.safety), y = l(p.targets, g.host), b = m.keys.map((e) => ({
27
+ id: e.id,
28
+ material: new Uint8Array(e.material)
29
+ })), x = typeof m.declaration == "function" ? m.declaration.bind(m) : m.declaration, S = { ...m.use }, C = m.now ?? Date.now;
30
+ if (!Number.isSafeInteger(m.maxBytes) || m.maxBytes < 1) return t("bounds");
31
+ let w = Math.min(m.maxBytes, 67108864);
32
+ return {
33
+ read: async () => {
34
+ let r, o, l, d = await s(u, h, v.artifactId, {
35
+ provider: m.provider,
36
+ maxBytes: w,
37
+ admit: async (s) => {
38
+ let u = await n(s, h);
39
+ await e(s, h);
40
+ let d = await i(s, h, g, _, {
41
+ provider: m.provider,
42
+ use: S,
43
+ keys: b,
44
+ now: C
45
+ }), f = [d];
46
+ for (let e of y) f.push(await i(s, h, {
47
+ ...g,
48
+ host: e.host
49
+ }, e.documents, {
50
+ provider: m.provider,
51
+ use: S,
52
+ keys: b,
53
+ now: C
54
+ }));
55
+ let p = f.flatMap((e) => e.paths.entries), v = f.flatMap((e) => e.paths.contexts);
56
+ if (o = f.flatMap((e) => e.inventory.records), p.length > 1e5 || o.length > 1e5) return t("bounds");
57
+ l = f.map((e) => ({
58
+ host: e.paths.admission.admission.input.host,
59
+ artifactId: e.paths.selection.artifactId,
60
+ pathSetIds: e.inventory.pathSetIds
61
+ })).sort((e, t) => e.host < t.host ? -1 : +(e.host > t.host));
62
+ let w = d.paths.admission.app, T = typeof x == "function" ? x({
63
+ inputsId: w.inputsId,
64
+ executionId: w.executionId,
65
+ code: { ...w.app },
66
+ routeDiscovery: structuredClone(w.routes.value)
67
+ }) : x;
68
+ return r = await c(s, h, {
69
+ admission: d.paths.admission.admission,
70
+ site: d.paths.admission.site,
71
+ entries: p,
72
+ contexts: v
73
+ }, T, u, C()), a(d);
74
+ }
75
+ });
76
+ if (r === void 0 || o === void 0 || l === void 0) return t("state");
77
+ let f = new Set(d.entries.filter((e) => e.target.kind === "url").map((e) => e.target.kind === "url" ? e.target.url : "")), p = new Set(d.entries.filter((e) => e.target.kind === "asset").map((e) => e.target.kind === "asset" ? e.target.digest : ""));
78
+ for (let e of o) e.media.some((e) => p.has(e.digest)) && f.add(e.url);
79
+ for (let e of r.definitions) if (f.has(e.source.url) || e.action.kind === "redirect" && f.has(e.action.target.url)) return t("graph");
80
+ return {
81
+ ...r,
82
+ binding: d.binding,
83
+ targetDocuments: l,
84
+ safety: {
85
+ artifactId: d.artifactId,
86
+ generation: d.generation,
87
+ safetyDigest: d.safetyDigest
88
+ }
89
+ };
90
+ },
91
+ place: h,
92
+ budget: w
93
+ };
94
+ }, p = (e, t) => ({
95
+ version: 2,
96
+ profile: "voltro.cms.snapshot-redirect-output/v2",
97
+ kind: "redirects",
98
+ ...t,
99
+ ...e.binding,
100
+ targetDocuments: e.targetDocuments,
101
+ safety: e.safety,
102
+ routeState: e.routeState,
103
+ count: e.definitions.length
104
+ }), m = async (...e) => {
105
+ let n = e[4], { read: r, place: i, budget: a } = f(...e), o = await r(), s = Buffer.from(d({
106
+ version: 1,
107
+ definitions: o.definitions
108
+ }) + "\n", "utf8");
109
+ if (s.length > a) return t("bounds");
110
+ let c;
111
+ try {
112
+ if (c = await n.provider.begin(), await c.write({
113
+ path: "redirects.json",
114
+ contentType: "application/json",
115
+ size: s.length,
116
+ digest: u("sha256").update(s).digest("hex")
117
+ }, (async function* () {
118
+ yield s;
119
+ })()), d(await r()) !== d(o)) return t("state");
120
+ let e = await c.seal(p(o, i));
121
+ return /^[a-f0-9]{64}$/.test(e.id) ? {
122
+ artifactId: e.id,
123
+ count: o.definitions.length
124
+ } : t("state");
125
+ } catch (e) {
126
+ throw c !== void 0 && await Promise.allSettled([c.abort()]), e;
127
+ }
128
+ }, h = async (e, n, r, i, a) => {
129
+ let o = i.id, s = f(e, n, r, i, a);
130
+ if (!/^[a-f0-9]{64}$/.test(o) || a.provider.read === void 0) return t("state");
131
+ let c = a.provider.read.bind(a.provider), l = await s.read(), m = Buffer.from(d({
132
+ version: 1,
133
+ definitions: l.definitions
134
+ }) + "\n", "utf8");
135
+ if (m.length > s.budget) return t("bounds");
136
+ let h = {
137
+ version: 1,
138
+ subject: p(l, s.place),
139
+ files: [{
140
+ path: "redirects.json",
141
+ contentType: "application/json",
142
+ size: m.length,
143
+ digest: u("sha256").update(m).digest("hex")
144
+ }]
145
+ };
146
+ if (u("sha256").update(d(h)).digest("hex") !== o) return t("state");
147
+ let g = await c(o);
148
+ return g.id !== o || d(g.manifest) !== d(h) || d(await s.read()) !== d(l) ? t("state") : structuredClone(g);
149
+ };
150
+ //#endregion
151
+ export { h as readSnapshotRedirectOutputArtifact, m as renderSnapshotRouteDispositions };
@@ -0,0 +1,24 @@
1
+ import { normalizeHost as e } from "./domainHost.js";
2
+ import { copySnapshotResource as t } from "./buildSnapshot.js";
3
+ import { routeDispositionFail as n } from "./routeDispositions.js";
4
+ import { copySnapshotSeoDocumentsSelection as r } from "./snapshotSeoPathSets.js";
5
+ //#region src/snapshotRedirectTargets.ts
6
+ var i = (i, a) => {
7
+ if (e(a) !== a) return n("input");
8
+ let o = t({
9
+ key: "redirect-targets",
10
+ value: { targets: i }
11
+ }).value.targets;
12
+ if (!Array.isArray(o) || o.length > 255) return n("bounds");
13
+ let s = "";
14
+ return o.map((t) => {
15
+ if (typeof t != "object" || !t || Array.isArray(t) || Object.keys(t).sort().join(",") !== "documents,host") return n("input");
16
+ let i = t, o = i.host;
17
+ return typeof o != "string" || e(o) !== o || o === a || o <= s ? n("input") : (s = o, {
18
+ host: o,
19
+ documents: r(i.documents)
20
+ });
21
+ });
22
+ };
23
+ //#endregion
24
+ export { i as copySnapshotRedirectTargets };
@@ -0,0 +1,132 @@
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
+ //#region 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
+ //#endregion
132
+ export { h as SnapshotRedirectUnavailable, v as snapshotRedirectSource };
@@ -0,0 +1,8 @@
1
+ //#region 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
+ //#endregion
8
+ export { e as snapshotReference };
@@ -0,0 +1,10 @@
1
+ import { readCapturedPublicAddress as e } from "./snapshotAddressRead.js";
2
+ //#region 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
+ //#endregion
10
+ export { t as readPlannedSnapshotReferenceAddress };
@@ -0,0 +1,79 @@
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
+ //#region 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
+ //#endregion
79
+ export { u as readAdmittedSnapshotReferenceGraph };