@voltro/cms 0.85.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 (244) hide show
  1. package/CHANGELOG.md +5987 -0
  2. package/README.md +138 -0
  3. package/THIRD-PARTY-NOTICES.md +864 -253
  4. package/dist/ContentForm.js +282 -0
  5. package/dist/RichDocumentEditor.js +550 -0
  6. package/dist/RichDocumentView.js +177 -0
  7. package/dist/RichTextSurface.js +135 -0
  8. package/dist/aiCandidates.js +199 -0
  9. package/dist/aiOperations.js +152 -0
  10. package/dist/applicationBuildSnapshotService.js +101 -0
  11. package/dist/assetRenditions.js +102 -0
  12. package/dist/assetRevision.js +46 -0
  13. package/dist/assetUseRights.js +72 -0
  14. package/dist/audiences.js +31 -0
  15. package/dist/availability.js +124 -0
  16. package/dist/blueprint.js +166 -0
  17. package/dist/build.d.ts +3063 -0
  18. package/dist/build.js +37 -0
  19. package/dist/buildApplicationAdmission.js +16 -0
  20. package/dist/buildApplicationCatalog.js +136 -0
  21. package/dist/buildApplicationCatalogTable.js +24 -0
  22. package/dist/buildApplicationRest.js +99 -0
  23. package/dist/buildApplicationUpload.js +111 -0
  24. package/dist/buildSnapshot.js +401 -0
  25. package/dist/buildSnapshotApplicationPin.js +32 -0
  26. package/dist/buildSnapshotRest.js +210 -0
  27. package/dist/buildSnapshotService.js +265 -0
  28. package/dist/buildSnapshotTables.js +25 -0
  29. package/dist/bulk.js +282 -0
  30. package/dist/cacheIdentity.js +152 -0
  31. package/dist/changes.js +307 -0
  32. package/dist/cmsContext.js +229 -0
  33. package/dist/collections.js +224 -0
  34. package/dist/consent.js +29 -0
  35. package/dist/contentLocations.js +53 -0
  36. package/dist/contentProjection.js +83 -0
  37. package/dist/contentRouteIdentity.js +13 -0
  38. package/dist/contentRouteMaterializer.js +97 -0
  39. package/dist/contentRouteTypes.js +39 -0
  40. package/dist/contentSeo.js +189 -0
  41. package/dist/contentTreePath.js +60 -0
  42. package/dist/contentType.js +208 -0
  43. package/dist/contentValues.js +18 -0
  44. package/dist/contentfulImport.js +162 -0
  45. package/dist/copies.js +89 -0
  46. package/dist/cutover.js +202 -0
  47. package/dist/deliveryChecks.js +138 -0
  48. package/dist/domainHost.js +7 -0
  49. package/dist/domains.js +139 -0
  50. package/dist/draftTexts.js +164 -0
  51. package/dist/duplicates.js +78 -0
  52. package/dist/edgePurge.js +69 -0
  53. package/dist/editHistory.js +113 -0
  54. package/dist/effectForm.js +11 -0
  55. package/dist/environmentAliases.js +138 -0
  56. package/dist/environments.js +147 -0
  57. package/dist/errors.js +107 -0
  58. package/dist/experiments.js +528 -0
  59. package/dist/exposure.js +28 -0
  60. package/dist/extensionManifest.js +81 -0
  61. package/dist/extensions.js +314 -0
  62. package/dist/fieldSchema.js +199 -0
  63. package/dist/formStrings.js +74 -0
  64. package/dist/frontendBindings.js +99 -0
  65. package/dist/frontendMedia.js +18 -0
  66. package/dist/glossary.js +73 -0
  67. package/dist/history.js +54 -0
  68. package/dist/htmlImport.js +297 -0
  69. package/dist/index.d.ts +771 -54
  70. package/dist/index.js +89 -6082
  71. package/dist/initializePublicRoutes.js +28 -0
  72. package/dist/liveContentRouteView.js +76 -0
  73. package/dist/media.js +29 -0
  74. package/dist/metrics.js +46 -0
  75. package/dist/migration.js +193 -0
  76. package/dist/migrationStages.js +13 -0
  77. package/dist/nativeOutputDeploymentService.js +205 -0
  78. package/dist/outputActivation.js +234 -0
  79. package/dist/outputActivationOrigin.js +51 -0
  80. package/dist/outputActivationStore.js +411 -0
  81. package/dist/outputActivationTables.js +11 -0
  82. package/dist/outputActivationTarget.js +81 -0
  83. package/dist/outputActivationTargetTable.js +25 -0
  84. package/dist/outputDeployment.js +174 -0
  85. package/dist/outputDeploymentRest.js +168 -0
  86. package/dist/outputDeploymentService.js +241 -0
  87. package/dist/outputRouteGraph.js +177 -0
  88. package/dist/outputSafetyArtifact.js +147 -0
  89. package/dist/outputTargetRest.js +62 -0
  90. package/dist/pathSegmentEncoding.js +4 -0
  91. package/dist/presenceAnchors.js +68 -0
  92. package/dist/preview.js +31 -0
  93. package/dist/privateCmsTransport.js +76 -0
  94. package/dist/privateNativeRouteReservation.js +10 -0
  95. package/dist/promotion.js +116 -0
  96. package/dist/publicBuild.js +90 -0
  97. package/dist/publicBuildRest.js +98 -0
  98. package/dist/publicBuildService.js +63 -0
  99. package/dist/publicOutputHttp.js +129 -0
  100. package/dist/publicOutputService.js +287 -0
  101. package/dist/publicPresentation.js +17 -0
  102. package/dist/publicRouteDispositionAdmission.js +38 -0
  103. package/dist/publicRouteHistoryStore.js +12 -0
  104. package/dist/publicRouteHistoryView.js +34 -0
  105. package/dist/publicRouteIntegrity.js +5 -0
  106. package/dist/publicRouteMutation.js +6 -0
  107. package/dist/publicRouteNamespace.js +134 -0
  108. package/dist/publicRoutePublication.js +36 -0
  109. package/dist/publicRouteRegistry.js +17 -0
  110. package/dist/publicRouteRegistryBinding.js +194 -0
  111. package/dist/publicRouteRegistryDefinition.js +76 -0
  112. package/dist/publicRouteSitePublication.js +40 -0
  113. package/dist/publicRouteTables.js +13 -0
  114. package/dist/publicRouteUrl.js +18 -0
  115. package/dist/publicationSeo.js +52 -0
  116. package/dist/publicationState.js +296 -0
  117. package/dist/quality.js +188 -0
  118. package/dist/reconfigurePublicRoutes.js +41 -0
  119. package/dist/recurrence.js +78 -0
  120. package/dist/redirects.js +130 -0
  121. package/dist/referenceGraph.js +224 -0
  122. package/dist/references.js +173 -0
  123. package/dist/release.js +241 -0
  124. package/dist/renderReadAuthority.js +43 -0
  125. package/dist/renderReadGrant.js +137 -0
  126. package/dist/rest.js +52 -0
  127. package/dist/review.js +160 -0
  128. package/dist/richDocument.js +521 -0
  129. package/dist/richInline.js +100 -0
  130. package/dist/routeDispositionGraph.js +44 -0
  131. package/dist/routeDispositionRest.js +51 -0
  132. package/dist/routeDispositionService.js +73 -0
  133. package/dist/routeDispositionStore.js +289 -0
  134. package/dist/routeDispositionTables.js +5 -0
  135. package/dist/routeDispositions.js +91 -0
  136. package/dist/routeHistoryStorage.js +320 -0
  137. package/dist/routeHistoryStore.js +12 -0
  138. package/dist/schedule.js +80 -0
  139. package/dist/search.js +148 -0
  140. package/dist/selectionIntent.js +164 -0
  141. package/dist/seo.js +31 -0
  142. package/dist/series.js +105 -0
  143. package/dist/share.js +112 -0
  144. package/dist/siteBindings.js +159 -0
  145. package/dist/siteBuildCandidate.js +104 -0
  146. package/dist/siteDelivery.js +115 -0
  147. package/dist/siteState.js +47 -0
  148. package/dist/snapshotAddressGraph.js +55 -0
  149. package/dist/snapshotAddressRead.js +73 -0
  150. package/dist/snapshotAppConsumer.js +71 -0
  151. package/dist/snapshotAppExecution.js +102 -0
  152. package/dist/snapshotApplication.js +75 -0
  153. package/dist/snapshotApprovedRouteDispositions.js +44 -0
  154. package/dist/snapshotAssetAssembly.js +70 -0
  155. package/dist/snapshotAssetAssemblyRest.js +50 -0
  156. package/dist/snapshotBindingRead.js +61 -0
  157. package/dist/snapshotCodeSeo.js +29 -0
  158. package/dist/snapshotComponent.js +34 -0
  159. package/dist/snapshotComponentSource.js +24 -0
  160. package/dist/snapshotConsumer.js +87 -0
  161. package/dist/snapshotContentIdentity.js +10 -0
  162. package/dist/snapshotDefinitions.js +264 -0
  163. package/dist/snapshotDocumentAssembly.js +193 -0
  164. package/dist/snapshotDocumentAssemblyRest.js +84 -0
  165. package/dist/snapshotDocumentProjection.js +202 -0
  166. package/dist/snapshotDocumentTransfer.js +35 -0
  167. package/dist/snapshotDocumentTransferRest.js +80 -0
  168. package/dist/snapshotDomains.js +56 -0
  169. package/dist/snapshotEnvironment.js +31 -0
  170. package/dist/snapshotFieldPlan.js +85 -0
  171. package/dist/snapshotFrontend.js +103 -0
  172. package/dist/snapshotLink.js +8 -0
  173. package/dist/snapshotMedia.js +111 -0
  174. package/dist/snapshotMediaCapture.js +246 -0
  175. package/dist/snapshotMediaFields.js +225 -0
  176. package/dist/snapshotMediaRead.js +185 -0
  177. package/dist/snapshotMediaReader.js +13 -0
  178. package/dist/snapshotObservation.js +16 -0
  179. package/dist/snapshotObservedRouteHistory.js +34 -0
  180. package/dist/snapshotOutputTransfer.js +78 -0
  181. package/dist/snapshotPageLoader.js +7 -0
  182. package/dist/snapshotPageSeo.js +59 -0
  183. package/dist/snapshotPathLocale.js +15 -0
  184. package/dist/snapshotPresentation.js +86 -0
  185. package/dist/snapshotPresentationPolicy.js +12 -0
  186. package/dist/snapshotProjection.js +119 -0
  187. package/dist/snapshotPublicAccess.js +161 -0
  188. package/dist/snapshotPublicRouteHistory.js +40 -0
  189. package/dist/snapshotReadAdmission.js +38 -0
  190. package/dist/snapshotRedirectOutput.js +151 -0
  191. package/dist/snapshotRedirectTargets.js +24 -0
  192. package/dist/snapshotRedirects.js +132 -0
  193. package/dist/snapshotReference.js +8 -0
  194. package/dist/snapshotReferenceAddress.js +10 -0
  195. package/dist/snapshotReferenceGraph.js +79 -0
  196. package/dist/snapshotReferenceRead.js +65 -0
  197. package/dist/snapshotRelease.js +99 -0
  198. package/dist/snapshotRender.js +361 -0
  199. package/dist/snapshotRenderDependencies.js +178 -0
  200. package/dist/snapshotRenditions.js +88 -0
  201. package/dist/snapshotRichDocument.js +62 -0
  202. package/dist/snapshotRoleTransfer.js +106 -0
  203. package/dist/snapshotRoleTransferRest.js +99 -0
  204. package/dist/snapshotRouteAdmission.js +71 -0
  205. package/dist/snapshotRouteDispatch.js +111 -0
  206. package/dist/snapshotRouteDispositionPlan.js +73 -0
  207. package/dist/snapshotRouteRead.js +43 -0
  208. package/dist/snapshotRoutes.js +79 -0
  209. package/dist/snapshotRouting.js +113 -0
  210. package/dist/snapshotSeo.js +179 -0
  211. package/dist/snapshotSeoControls.js +101 -0
  212. package/dist/snapshotSeoDocumentInventory.js +115 -0
  213. package/dist/snapshotSeoDocuments.js +129 -0
  214. package/dist/snapshotSeoMerge.js +85 -0
  215. package/dist/snapshotSeoMetadata.js +137 -0
  216. package/dist/snapshotSeoOutput.js +173 -0
  217. package/dist/snapshotSeoPathSets.js +105 -0
  218. package/dist/snapshotSeoRead.js +88 -0
  219. package/dist/snapshotSite.js +128 -0
  220. package/dist/snapshotSitemapFiles.js +36 -0
  221. package/dist/snapshotTreeDependencies.js +58 -0
  222. package/dist/snapshotTreeLoader.js +10 -0
  223. package/dist/snapshotTreeRead.js +158 -0
  224. package/dist/staticPathSet.js +177 -0
  225. package/dist/staticPathSetRest.js +129 -0
  226. package/dist/staticPathSetService.js +249 -0
  227. package/dist/staticPathSetStore.js +338 -0
  228. package/dist/stewardship.js +146 -0
  229. package/dist/taxonomy.js +36 -0
  230. package/dist/team.js +103 -0
  231. package/dist/templates.js +106 -0
  232. package/dist/trackChanges.js +197 -0
  233. package/dist/translation.js +64 -0
  234. package/dist/tree.js +87 -0
  235. package/dist/usage.js +50 -0
  236. package/dist/validation.js +192 -0
  237. package/dist/visualEditing.js +60 -0
  238. package/dist/web.d.ts +709 -7
  239. package/dist/web.js +50 -2
  240. package/dist/workflow.js +322 -0
  241. package/dist/write.js +419 -0
  242. package/dist/xliff.js +325 -0
  243. package/package.json +20 -6
  244. package/dist/presenceAnchors-4iHAVQB3.js +0 -4367
@@ -0,0 +1,401 @@
1
+ import { capturePublicationState as e, verifyPublicationState as t } from "./publicationState.js";
2
+ import { Schema as n } from "effect";
3
+ import { and as r, eq as i, gt as a, id as o, inSet as s, integer as c, json as l, or as u, table as d, text as f, timestamp as p } from "@voltro/database";
4
+ import { tenant as m } from "@voltro/plugin-multitenancy/mixin";
5
+ import { createHash as h } from "node:crypto";
6
+ import { canonicalJson as g } from "@voltro/runtime";
7
+ //#region src/buildSnapshot.ts
8
+ var _ = [
9
+ "release",
10
+ "environment",
11
+ "site",
12
+ "domains",
13
+ "locales",
14
+ "routes",
15
+ "schema",
16
+ "components",
17
+ "assets",
18
+ "redirects",
19
+ "seo",
20
+ "policies",
21
+ "projection",
22
+ "app"
23
+ ], v = /* @__PURE__ */ new Set([
24
+ "release",
25
+ "environment",
26
+ "site",
27
+ "locales",
28
+ "schema",
29
+ "components",
30
+ "seo",
31
+ "policies",
32
+ "projection",
33
+ "app"
34
+ ]), y = class extends n.TaggedError()("BuildSnapshotUnavailable", { reason: n.Literals([
35
+ "scope",
36
+ "parts",
37
+ "resource",
38
+ "duplicate",
39
+ "bounds",
40
+ "snapshot",
41
+ "expired",
42
+ "cursor"
43
+ ]) }) {}, b = "_voltro_cms_build_snapshots", x = "_voltro_cms_snapshot_resources", S = d(b, {
44
+ id: o({ prefix: "bsnap" }),
45
+ site: f().maxLength(64),
46
+ environment: f().maxLength(64),
47
+ state: f().oneOf(["capturing", "sealed"]),
48
+ publicationStateId: f().maxLength(64),
49
+ manifest: l().nullable(),
50
+ digest: f().maxLength(64).nullable(),
51
+ capturedAt: p(),
52
+ expiresAt: p()
53
+ }).with(m()), C = d(x, {
54
+ id: o({ prefix: "bsres" }),
55
+ snapshotId: f().maxLength(64),
56
+ site: f().maxLength(64),
57
+ environment: f().maxLength(64),
58
+ part: f().maxLength(32),
59
+ ordinal: c(),
60
+ key: f().maxLength(256),
61
+ keyDigest: f().maxLength(64),
62
+ value: l(),
63
+ digest: f().maxLength(64)
64
+ }).with(m()).index("cms_snapshot_resources_page", [
65
+ "tenantId",
66
+ "snapshotId",
67
+ "part",
68
+ "ordinal"
69
+ ]).unique("cms_snapshot_resources_key", [
70
+ "tenantId",
71
+ "snapshotId",
72
+ "part",
73
+ "keyDigest"
74
+ ]), w = (e) => {
75
+ throw new y({ reason: e });
76
+ }, T = (e) => typeof e == "string" && e.trim().length > 0, E = (e) => h("sha256").update(g(e)).digest("hex"), D = (e, t, n) => E({
77
+ part: e,
78
+ ordinal: t,
79
+ ...n
80
+ }), O = (e, t) => {
81
+ let n = h("sha256"), r = 0;
82
+ for (let i of t.entries()) n.update(D(e, ++r, M(i)) + "\n");
83
+ return {
84
+ part: e,
85
+ format: t.format,
86
+ entries: r,
87
+ digest: n.digest("hex")
88
+ };
89
+ }, k = (e) => typeof e == "string" && /^[0-9a-f]{64}$/.test(e), A = (e) => [
90
+ e.tenantId,
91
+ e.site,
92
+ e.environment
93
+ ].every(T) ? r(i("tenantId", e.tenantId), i("site", e.site), i("environment", e.environment)) : w("scope"), j = (e) => e instanceof Date ? e.getTime() : typeof e == "string" ? Date.parse(e) : NaN, M = (e) => {
94
+ if (!T(e.key) || e.key.length > 256 || e.value === null || typeof e.value != "object" || Array.isArray(e.value)) return w("resource");
95
+ let t = /* @__PURE__ */ new Set(), n = (e, r) => {
96
+ if (r > 64) return w("bounds");
97
+ if (e !== null && typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e))) {
98
+ if (typeof e != "object" || t.has(e) || Object.getOwnPropertySymbols(e).length > 0 || !Array.isArray(e) && Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null || Array.isArray(e) && (Object.keys(e).length !== e.length || Object.keys(e).some((e, t) => e !== String(t)))) return w("resource");
99
+ t.add(e);
100
+ for (let [t, i] of Object.entries(Object.getOwnPropertyDescriptors(e))) if (!(Array.isArray(e) && t === "length")) {
101
+ if (!i.enumerable || !("value" in i)) return w("resource");
102
+ n(i.value, r + 1);
103
+ }
104
+ t.delete(e);
105
+ }
106
+ };
107
+ n(e.value, 0);
108
+ let r = JSON.stringify(e.value);
109
+ return Buffer.byteLength(r, "utf8") > 524288 ? w("bounds") : {
110
+ key: e.key,
111
+ value: JSON.parse(r)
112
+ };
113
+ }, N = async (t, n, r, i) => {
114
+ if (A(r), Object.keys(i.sources).length !== _.length || _.some((e) => {
115
+ let t = i.sources[e];
116
+ return t === void 0 || !T(t.format) || t.format.length > 128 || typeof t.entries != "function";
117
+ })) return w("parts");
118
+ let a = {
119
+ tenantId: r.tenantId,
120
+ site: r.site,
121
+ environment: r.environment
122
+ }, o = Object.fromEntries(_.map((e) => [e, {
123
+ format: i.sources[e].format,
124
+ entries: i.sources[e].entries
125
+ }])), s = i.now ?? Date.now();
126
+ return P(t, a, await e(t, n, a, {
127
+ locales: i.locales,
128
+ expiresAt: i.expiresAt,
129
+ now: s
130
+ }), {
131
+ sources: o,
132
+ now: s,
133
+ expiresAt: i.expiresAt
134
+ });
135
+ }, P = async (e, t, n, a) => {
136
+ let { now: o, sources: c } = a, l = await e.insert(b, {
137
+ tenantId: t.tenantId,
138
+ site: t.site,
139
+ environment: t.environment,
140
+ state: "capturing",
141
+ publicationStateId: n.id,
142
+ manifest: null,
143
+ digest: null,
144
+ capturedAt: new Date(o),
145
+ expiresAt: new Date(a.expiresAt)
146
+ }), u = String(l.id), d = [];
147
+ for (let a of _) {
148
+ let o = c[a], l = h("sha256"), f = 0, p = [], m = 0, g = async () => {
149
+ if (p.length === 0) return;
150
+ let n = p.map((e) => String(e.keyDigest));
151
+ if (new Set(n).size !== n.length || (await e.query({
152
+ table: "_voltro_cms_snapshot_resources",
153
+ predicate: r(A(t), i("snapshotId", u), i("part", a), s("keyDigest", n)),
154
+ order: [],
155
+ take: 1,
156
+ skip: void 0,
157
+ projection: ["id"]
158
+ })).length > 0) return w("duplicate");
159
+ await e.insertMany(x, p, { returning: "none" }), p = [], m = 0;
160
+ };
161
+ for await (let e of o.entries(structuredClone(n))) {
162
+ let n = M(e), r = Buffer.byteLength(JSON.stringify(n.value), "utf8");
163
+ if ((p.length >= 64 || m + r > 2097152) && await g(), f === 2147483647) return w("bounds");
164
+ let i = ++f, o = D(a, i, n);
165
+ l.update(o + "\n"), p.push({
166
+ tenantId: t.tenantId,
167
+ site: t.site,
168
+ environment: t.environment,
169
+ snapshotId: u,
170
+ part: a,
171
+ ordinal: i,
172
+ key: n.key,
173
+ keyDigest: E(n.key),
174
+ value: n.value,
175
+ digest: o
176
+ }), m += r;
177
+ }
178
+ if (await g(), f === 0 && v.has(a)) return w("parts");
179
+ d.push({
180
+ part: a,
181
+ format: o.format,
182
+ entries: f,
183
+ digest: l.digest("hex")
184
+ });
185
+ }
186
+ let f = {
187
+ version: 1,
188
+ capturedAt: o,
189
+ expiresAt: a.expiresAt,
190
+ scope: {
191
+ tenantId: t.tenantId,
192
+ site: t.site,
193
+ environment: t.environment
194
+ },
195
+ publication: n,
196
+ parts: d
197
+ }, p = E(f);
198
+ return await e.update(b, u, {
199
+ state: "sealed",
200
+ manifest: f,
201
+ digest: p
202
+ }), {
203
+ id: u,
204
+ digest: p,
205
+ expiresAt: a.expiresAt,
206
+ manifest: structuredClone(f)
207
+ };
208
+ }, F = async (e, t, n, a = Date.now()) => {
209
+ let [o] = await e.query({
210
+ table: b,
211
+ predicate: r(A(t), i("id", n)),
212
+ order: [],
213
+ take: 1,
214
+ skip: void 0,
215
+ projection: void 0
216
+ });
217
+ if (o === void 0 || o.state !== "sealed" || !k(o.digest) || o.manifest === null || typeof o.manifest != "object") return w("snapshot");
218
+ let s = o.manifest;
219
+ if (s.version !== 1 || !Array.isArray(s.parts) || s.parts.length !== _.length || g(s.scope) !== g({
220
+ tenantId: t.tenantId,
221
+ site: t.site,
222
+ environment: t.environment
223
+ }) || s.publication?.id !== o.publicationStateId || !k(s.publication?.digest) || s.parts.some((e, t) => typeof e != "object" || !e || e.part !== _[t] || !T(e.format) || !Number.isSafeInteger(e.entries) || e.entries < 0 || !k(e.digest)) || E(s) !== o.digest) return w("snapshot");
224
+ let c = j(o.expiresAt);
225
+ return !Number.isSafeInteger(a) || !Number.isFinite(c) || !Number.isSafeInteger(s.capturedAt) || !Number.isSafeInteger(s.expiresAt) || s.expiresAt <= s.capturedAt || j(o.capturedAt) !== s.capturedAt || c !== s.expiresAt || a < s.capturedAt ? w("snapshot") : c <= a ? w("expired") : {
226
+ id: n,
227
+ digest: o.digest,
228
+ expiresAt: c,
229
+ manifest: structuredClone(s)
230
+ };
231
+ }, I = async (e, t, n, o, s = {}) => {
232
+ let c = (await F(e, t, n, s.now)).manifest.parts.find((e) => e.part === o), l = 0, u = s.limit ?? 64;
233
+ if (c === void 0) return w("parts");
234
+ if (s.after !== void 0) {
235
+ if (!T(s.after) || s.after.length > 64) return w("cursor");
236
+ let [a] = await e.query({
237
+ table: x,
238
+ predicate: r(A(t), i("snapshotId", n), i("part", o), i("id", s.after)),
239
+ order: [],
240
+ take: 1,
241
+ skip: void 0,
242
+ projection: void 0
243
+ });
244
+ if (a === void 0 || typeof a.ordinal != "number" || !Number.isSafeInteger(a.ordinal) || a.ordinal < 1 || a.ordinal > c.entries || a.keyDigest !== E(a.key) || a.digest !== E({
245
+ part: o,
246
+ ordinal: a.ordinal,
247
+ key: a.key,
248
+ value: a.value
249
+ })) return w("cursor");
250
+ l = a.ordinal;
251
+ }
252
+ if (!Number.isSafeInteger(u) || u < 1 || u > 200) return w("bounds");
253
+ let d = await e.query({
254
+ table: x,
255
+ predicate: r(A(t), i("snapshotId", n), i("part", o), a("ordinal", l)),
256
+ order: [{
257
+ column: "ordinal",
258
+ direction: "asc"
259
+ }],
260
+ take: Math.min(u, c.entries - l) + 1,
261
+ skip: void 0,
262
+ projection: void 0
263
+ }), f = Math.min(u + 1, c.entries - l);
264
+ return d.length === f ? {
265
+ items: d.map((e, t) => {
266
+ let n = l + t + 1;
267
+ return e.ordinal !== n || e.keyDigest !== E(e.key) || e.digest !== E({
268
+ part: o,
269
+ ordinal: n,
270
+ key: e.key,
271
+ value: e.value
272
+ }) ? w("resource") : M({
273
+ key: String(e.key),
274
+ value: e.value
275
+ });
276
+ }).slice(0, u),
277
+ next: l + u < c.entries ? String(d[u - 1].id) : null
278
+ } : w("resource");
279
+ }, L = async (e, t, n, r, i) => (await R(e, t, n, r, [i])).get(i) ?? null, R = async (e, t, n, a, o) => {
280
+ let c = n.manifest.parts.find((e) => e.part === a);
281
+ if (c === void 0 || o.some((e) => !T(e) || e.length > 256) || g(n.manifest.scope) !== g({
282
+ tenantId: t.tenantId,
283
+ site: t.site,
284
+ environment: t.environment
285
+ })) return w("scope");
286
+ if (o.length > 200) return w("bounds");
287
+ let l = new Set(o), u = /* @__PURE__ */ new Map();
288
+ if (l.size === 0) return u;
289
+ let d = await e.query({
290
+ table: x,
291
+ predicate: r(A(t), i("snapshotId", n.id), i("part", a), s("keyDigest", [...l].map(E))),
292
+ lock: "update",
293
+ order: [],
294
+ take: l.size,
295
+ skip: void 0,
296
+ projection: void 0
297
+ });
298
+ for (let e of d) {
299
+ let t = e.key;
300
+ if (typeof t != "string" || !l.has(t) || u.has(t) || e.keyDigest !== E(t) || !Number.isSafeInteger(e.ordinal) || Number(e.ordinal) < 1 || Number(e.ordinal) > c.entries || e.digest !== E({
301
+ part: a,
302
+ ordinal: e.ordinal,
303
+ key: t,
304
+ value: e.value
305
+ })) return w("resource");
306
+ u.set(t, M({
307
+ key: t,
308
+ value: e.value
309
+ }));
310
+ }
311
+ return u;
312
+ }, z = async (e, t, n, r, i) => await L(e, t, n, r, i) ?? w("resource"), B = async (e, n, o, s = Date.now()) => {
313
+ let c = await F(e, n, o.id, s);
314
+ if (c.digest !== o.digest) return w("snapshot");
315
+ await t(e, c.manifest.scope, c.manifest.publication, s);
316
+ let l = new Map(c.manifest.parts.map((e) => [e.part, {
317
+ pin: e,
318
+ count: 0,
319
+ digest: h("sha256")
320
+ }])), d;
321
+ for (;;) {
322
+ let t = await e.query({
323
+ table: x,
324
+ predicate: r(A(n), i("snapshotId", c.id), ...d === void 0 ? [] : [u(a("part", d.part), r(i("part", d.part), a("ordinal", d.ordinal)))]),
325
+ order: [{
326
+ column: "part",
327
+ direction: "asc"
328
+ }, {
329
+ column: "ordinal",
330
+ direction: "asc"
331
+ }],
332
+ take: 64,
333
+ skip: void 0,
334
+ projection: void 0
335
+ });
336
+ for (let e of t) {
337
+ let t = l.get(e.part);
338
+ if (t === void 0 || e.ordinal !== ++t.count || t.count > t.pin.entries || e.keyDigest !== E(e.key) || e.digest !== E({
339
+ part: t.pin.part,
340
+ ordinal: t.count,
341
+ key: e.key,
342
+ value: e.value
343
+ })) return w("resource");
344
+ let n = M({
345
+ key: String(e.key),
346
+ value: e.value
347
+ });
348
+ t.digest.update(D(t.pin.part, t.count, n) + "\n"), d = {
349
+ part: t.pin.part,
350
+ ordinal: t.count
351
+ };
352
+ }
353
+ if (t.length < 64) break;
354
+ }
355
+ for (let { pin: e, count: t, digest: n } of l.values()) if (t !== e.entries || n.digest("hex") !== e.digest) return w("resource");
356
+ return c;
357
+ }, V = (e, t, n, r, i = Date.now()) => {
358
+ let a = structuredClone(n), o = {
359
+ tenantId: t.tenantId,
360
+ site: t.site,
361
+ environment: t.environment
362
+ }, s = a.manifest.parts.find((e) => e.part === r);
363
+ return s === void 0 ? w("parts") : {
364
+ format: s.format,
365
+ entries: async function* (t) {
366
+ if (g(t) !== g(a.manifest.publication)) return w("snapshot");
367
+ let n = h("sha256"), c, l = 0;
368
+ do {
369
+ let t = await I(e, o, a.id, r, {
370
+ now: i,
371
+ limit: 100,
372
+ ...c === void 0 ? {} : { after: c }
373
+ });
374
+ for (let e of t.items) n.update(D(r, ++l, e) + "\n"), yield e;
375
+ c = t.next ?? void 0;
376
+ } while (c !== void 0);
377
+ if (l !== s.entries || n.digest("hex") !== s.digest) return w("resource");
378
+ }
379
+ };
380
+ }, H = async (e, t, n, r, i = Date.now()) => {
381
+ let a = {
382
+ tenantId: t.tenantId,
383
+ site: t.site,
384
+ environment: t.environment
385
+ }, o = {
386
+ id: n.id,
387
+ digest: n.digest
388
+ }, s = Object.entries(r);
389
+ if (s.some(([e, t]) => !_.includes(e) || t === void 0 || !T(t.format) || t.format.length > 128 || typeof t.entries != "function")) return w("parts");
390
+ let c = new Map(s.map(([e, t]) => [e, {
391
+ format: t.format,
392
+ entries: t.entries
393
+ }])), l = await B(e, a, o, i), u = Object.fromEntries(l.manifest.parts.map((t) => [t.part, c.get(t.part) ?? V(e, a, l, t.part, i)])), d = await P(e, a, l.manifest.publication, {
394
+ sources: u,
395
+ now: l.manifest.capturedAt,
396
+ expiresAt: l.expiresAt
397
+ });
398
+ return d.manifest.parts.some((e, t) => !c.has(e.part) && g(e) !== g(l.manifest.parts[t])) ? w("resource") : d;
399
+ };
400
+ //#endregion
401
+ export { b as BUILD_SNAPSHOTS_TABLE, y as BuildSnapshotUnavailable, _ as SNAPSHOT_PARTS, x as SNAPSHOT_RESOURCES_TABLE, S as buildSnapshotsTable, N as captureBuildSnapshot, M as copySnapshotResource, H as deriveBuildSnapshot, L as findVerifiedSnapshotResource, R as findVerifiedSnapshotResources, I as pageSnapshotResources, V as pinnedSnapshotPartSource, F as readBuildSnapshot, z as readVerifiedSnapshotResource, D as snapshotResourceDigest, C as snapshotResourcesTable, O as snapshotStaticPartPin, B as verifyBuildSnapshot };
@@ -0,0 +1,32 @@
1
+ import { copySnapshotAppCodePin as e } from "./snapshotDefinitions.js";
2
+ //#region src/buildSnapshotApplicationPin.ts
3
+ var t = (e) => {
4
+ let t = () => {
5
+ throw TypeError("Invalid retained application identity");
6
+ };
7
+ if (typeof e != "object" || !e || Array.isArray(e) || Object.keys(e).sort().join(",") !== "executionId,inputsId") return t();
8
+ let { inputsId: n, executionId: r } = e;
9
+ return typeof n != "string" || !/^[a-f0-9]{64}$/.test(n) || typeof r != "string" || !/^[a-f0-9]{64}$/.test(r) ? t() : {
10
+ inputsId: n,
11
+ executionId: r
12
+ };
13
+ }, n = (t) => {
14
+ let n = () => {
15
+ throw TypeError("Invalid retained application pin");
16
+ };
17
+ if (typeof t != "object" || !t || Array.isArray(t) || Object.keys(t).sort().join(",") !== "code,executionId,inputsId") return n();
18
+ let { code: r, inputsId: i, executionId: a } = t;
19
+ if (typeof i != "string" || !/^[a-f0-9]{64}$/.test(i) || typeof a != "string" || !/^[a-f0-9]{64}$/.test(a) || typeof r != "object" || !r || Array.isArray(r) || Object.keys(r).sort().join(",") !== "artifactDigest,commit,configDigest") return n();
20
+ let o = r;
21
+ return typeof o.commit != "string" || typeof o.artifactDigest != "string" || typeof o.configDigest != "string" ? n() : {
22
+ inputsId: i,
23
+ executionId: a,
24
+ code: e({
25
+ commit: o.commit,
26
+ artifactDigest: o.artifactDigest,
27
+ configDigest: o.configDigest
28
+ })
29
+ };
30
+ };
31
+ //#endregion
32
+ export { t as copyBuildSnapshotApplicationIdentity, n as copyBuildSnapshotApplicationPin };
@@ -0,0 +1,210 @@
1
+ import { cmsCredential as e, privateCmsHttpRoutes as t, privateCmsOperation as n } from "./privateCmsTransport.js";
2
+ import { CmsBuildSnapshotUnavailable as r } from "./buildSnapshotService.js";
3
+ import { Schema as i } from "effect";
4
+ //#region src/buildSnapshotRest.ts
5
+ var a = (t) => e(t, "CmsBuildSnapshotUnavailable"), o = i.Struct({
6
+ id: i.String,
7
+ digest: i.String
8
+ }), s = i.Struct({
9
+ artifactId: i.String,
10
+ pathSets: i.Array(i.Struct({
11
+ id: i.String,
12
+ digest: i.String
13
+ }))
14
+ }), c = i.Struct({
15
+ version: i.Literal(1),
16
+ decided: i.Boolean,
17
+ granted: i.Array(i.Struct({
18
+ id: i.String,
19
+ version: i.Number
20
+ }))
21
+ }), l = i.Struct({
22
+ snapshot: o,
23
+ consumerId: i.String,
24
+ buildId: i.String,
25
+ host: i.String,
26
+ path: i.String,
27
+ presentation: i.optional(c)
28
+ }), u = (e, t) => ({
29
+ snapshot: e.snapshot,
30
+ consumerId: e.consumerId,
31
+ buildId: e.buildId,
32
+ host: e.host,
33
+ path: e.path,
34
+ token: a(t),
35
+ ...e.presentation === void 0 ? {} : { presentation: e.presentation }
36
+ }), d = i.Struct({
37
+ snapshotId: i.String,
38
+ snapshotDigest: i.String,
39
+ routeId: i.String,
40
+ path: i.String,
41
+ contentType: i.String,
42
+ localeId: i.String,
43
+ requestedLocale: i.String,
44
+ sourceLocale: i.String,
45
+ fallback: i.Boolean,
46
+ values: i.Record(i.String, i.Unknown),
47
+ presentation: c
48
+ }), f = i.Struct({
49
+ documentId: i.String,
50
+ parent: i.NullOr(i.String),
51
+ depth: i.Number,
52
+ path: i.String,
53
+ sourceLocale: i.String,
54
+ fallback: i.Boolean,
55
+ values: i.Record(i.String, i.Unknown)
56
+ }), p = (e, t, i, a, o, s) => n({
57
+ namespace: "cms.buildSnapshot",
58
+ path: "/v1/cms/build-snapshots",
59
+ operationPrefix: "cmsBuildSnapshot",
60
+ tags: ["CMS build snapshots"],
61
+ credentialError: "CmsBuildSnapshotUnavailable",
62
+ error: r,
63
+ errorStatus: { CmsBuildSnapshotUnavailable: 409 }
64
+ }, e, t, i, a, o, s), m = (e) => {
65
+ let n = [
66
+ p("capture", "Capture or resume one immutable build snapshot", "Organization API-key bearer. Scope, app inputs, expiry and storage are selected by the server. Optional expectedApplication compares the retained source, inputs and execution before any capture attempt; it selects no provider or path. Reuse attemptId only with the same authority, release and configuration.", i.Struct({
67
+ attemptId: i.String,
68
+ releaseId: i.String,
69
+ expectedApplication: i.optional(i.Struct({
70
+ inputsId: i.String,
71
+ executionId: i.String,
72
+ code: i.Struct({
73
+ commit: i.String,
74
+ artifactDigest: i.String,
75
+ configDigest: i.String
76
+ })
77
+ }))
78
+ }), i.Struct({
79
+ id: i.String,
80
+ digest: i.String,
81
+ expiresAt: i.Number
82
+ }), (t, n) => e.capture({
83
+ attemptId: t.attemptId,
84
+ releaseId: t.releaseId,
85
+ apiKey: a(n),
86
+ ...t.expectedApplication === void 0 ? {} : { expectedApplication: t.expectedApplication }
87
+ })),
88
+ p("open", "Issue a short-lived read grant for the retained application", "Organization API-key bearer. Optional resume requires the original grant token and buildId plus the same parent credential, even after read expiry; revoked proof refuses. consentPurposes is the bounded catalog from this same independently verified retained application, not personal consent or additional rights. Coordinators can derive finite public presentation classes without executing application code. The response token is private and must never be persisted in a public artifact or a generic HTTP idempotency cache.", i.Struct({
89
+ snapshot: o,
90
+ resume: i.optional(i.Struct({
91
+ token: i.String,
92
+ buildId: i.String
93
+ }))
94
+ }), i.Struct({
95
+ id: i.String,
96
+ token: i.String,
97
+ expiresAt: i.Number,
98
+ consumerId: i.String,
99
+ buildId: i.String,
100
+ snapshotId: i.String,
101
+ snapshotDigest: i.String,
102
+ consentPurposes: i.Array(i.Struct({
103
+ id: i.String,
104
+ version: i.Int
105
+ })).check(i.isMaxLength(32))
106
+ }), (t, n) => e.open({
107
+ snapshot: t.snapshot,
108
+ apiKey: a(n),
109
+ ...t.resume === void 0 ? {} : { resume: t.resume }
110
+ })),
111
+ p("read", "Read anonymous projected content at one snapshot route", "Render-read token bearer from open. All reads carry the same snapshot pin. Unknown routes return null only after fresh grant, host and snapshot admission; there is no live fallback.", l, i.NullOr(d), (t, n) => e.read(u(t, n))),
112
+ p("readBinding", "Read a captured site binding at an admitted CMS page", "Render-read token bearer. The server resolves only named site bindings captured in the same snapshot, using its locale fallback, anonymous access, consent and field projection. Nested references grant no media or document access.", i.Struct({
113
+ ...l.fields,
114
+ binding: i.String
115
+ }), i.NullOr(i.Struct({
116
+ snapshotId: i.String,
117
+ snapshotDigest: i.String,
118
+ binding: i.String,
119
+ contentType: i.String,
120
+ localeId: i.String,
121
+ requestedLocale: i.String,
122
+ sourceLocale: i.String,
123
+ fallback: i.Boolean,
124
+ values: i.Record(i.String, i.Unknown),
125
+ presentation: c
126
+ })), (t, n) => e.readBinding({
127
+ ...u(t, n),
128
+ binding: t.binding
129
+ })),
130
+ p("readTree", "Read a named public tree from the captured publication", "Render-read token bearer. Named scalar projections, tree ordering, ancestor policy and mapped addresses come from this snapshot. Breadcrumbs are independent of navigation inclusion. No live fallback or personal authority; unknown names fail after credential admission.", i.Struct({
131
+ ...l.fields,
132
+ name: i.String
133
+ }), i.Struct({
134
+ version: i.Literals([1]),
135
+ contentType: i.String,
136
+ localeId: i.String,
137
+ requestedLocale: i.String,
138
+ currentDocumentId: i.NullOr(i.String),
139
+ nodes: i.Array(f),
140
+ ancestors: i.Array(f)
141
+ }), (t, n) => e.readTree({
142
+ ...u(t, n),
143
+ name: t.name
144
+ })),
145
+ p("render", "Render a private candidate using the retained application", "Render-read token bearer from open. This does not activate output or grant permission to serve it. Media requires the server-configured custody/output provider.", l, i.NullOr(i.Struct({
146
+ html: i.String,
147
+ head: i.String,
148
+ document: i.NullOr(i.String),
149
+ artifactId: i.NullOr(i.String)
150
+ })), (t, n) => e.render(u(t, n))),
151
+ p("renderSafety", "Stage one complete current safety generation for captured output", "Render-read token bearer. Requires actual complete documents and stored signed path sets from the same snapshot, application and build. The server stages every current scoped URL/hash denial; a changed generation or withdrawn admission refuses before sealing. Returned private artifact IDs grant no activation or serving authority.", i.Struct({
152
+ snapshot: o,
153
+ consumerId: i.String,
154
+ buildId: i.String,
155
+ host: i.String,
156
+ documents: s
157
+ }), i.Struct({
158
+ artifactId: i.String,
159
+ generation: i.Int,
160
+ entryCount: i.Int
161
+ }), (t, n) => e.renderSafety({
162
+ ...t,
163
+ token: a(n)
164
+ })),
165
+ p("renderRedirects", "Stage explicitly approved retired routes from captured source and output history", "Render-read token bearer. Requires actual document custody, complete signed path sets for every enabled locale and both owners on this host, current renderSafety output, and the captured server-admitted route declaration. The required sorted targets array supplies {host, documents} for every other selected host; use an empty array for one host. Each target inventory undergoes the same fresh grant, document, rights and complete signed EOF admission. Every retired observed URL needs explicit current intent; conflicting historical owners hold. Current owners suppress old rules, but only admitted public documents may be redirect targets. Intrinsic CMS redirects do not authorize output. Exact 301/302 method permission, 307/308 preservation, 404/410 and active intervals remain distinct. Rechecks authority and current metadata around writes. Returned private artifacts confer no activation or public serving authority.", i.Struct({
166
+ snapshot: o,
167
+ consumerId: i.String,
168
+ buildId: i.String,
169
+ host: i.String,
170
+ documents: s,
171
+ targets: i.Array(i.Struct({
172
+ host: i.String,
173
+ documents: s
174
+ })),
175
+ safety: i.Struct({ artifactId: i.String })
176
+ }), i.Struct({
177
+ artifactId: i.String,
178
+ count: i.Int
179
+ }), (t, n) => e.renderRedirects({
180
+ ...t,
181
+ token: a(n)
182
+ })),
183
+ p("renderSeo", "Stage private sitemap and robots artifacts from captured public SEO", "Render-read token bearer. Anonymous own variants, editorial opt-out/index policy, canonical domain and alternates come from this snapshot. Production web controls require the actual document artifact, stored signed path-set IDs and digests, and the current renderSafety artifact; native metadata comes from matched render receipts. Withdrawn URLs and documents using denied media are excluded, including their alternates. Current safety and document admission are checked around output writes. Large sitemaps split by protocol limits. Returned private artifact IDs confer no activation or serving authority; an output provider is required.", i.Struct({
184
+ snapshot: o,
185
+ consumerId: i.String,
186
+ buildId: i.String,
187
+ host: i.String,
188
+ documents: i.optional(s),
189
+ safety: i.optional(i.Struct({ artifactId: i.String }))
190
+ }), i.Struct({
191
+ sitemapArtifactId: i.String,
192
+ robotsArtifactId: i.String,
193
+ urlCount: i.Number
194
+ }), (t, n) => e.renderSeo({
195
+ snapshot: t.snapshot,
196
+ consumerId: t.consumerId,
197
+ buildId: t.buildId,
198
+ host: t.host,
199
+ token: a(n),
200
+ ...t.documents === void 0 ? {} : { documents: t.documents },
201
+ ...t.safety === void 0 ? {} : { safety: t.safety }
202
+ }))
203
+ ];
204
+ return {
205
+ routes: n,
206
+ httpRoutes: t(n)
207
+ };
208
+ };
209
+ //#endregion
210
+ export { m as cmsBuildSnapshotRest };