@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,85 @@
1
+ import { readCapturedPublication as e } from "./publicationState.js";
2
+ import { pageSnapshotResources as t, readVerifiedSnapshotResource as n } from "./buildSnapshot.js";
3
+ import { copySnapshotRenditionRequirements as r } from "./snapshotRenditions.js";
4
+ import { SnapshotMediaUnavailable as i, compileSnapshotMediaFields as a } from "./snapshotMediaFields.js";
5
+ import { canonicalJson as o } from "@voltro/runtime";
6
+ //#region src/snapshotFieldPlan.ts
7
+ var s = (e) => {
8
+ throw new i({ reason: e });
9
+ }, c = async (i, c, l, u) => {
10
+ let { snapshot: d, document: f, output: p } = l, m = async (e) => {
11
+ let n = [], r;
12
+ for (;;) {
13
+ let a = await t(i, c, d.id, e, {
14
+ now: u,
15
+ limit: 200,
16
+ ...r === void 0 ? {} : { after: r }
17
+ });
18
+ if (n.push(...a.items), n.length > 8192) return s("bounds");
19
+ if (a.next === null) return n;
20
+ r = a.next;
21
+ }
22
+ }, h = a(await m("schema"), await m("components")), g = h.find((e) => e.name === p.contentType), _ = await e(i, c, d.manifest.publication.id, p.contentType, p.sourceLocale, String(f.variantId), u);
23
+ if (g === void 0 || _ === null || _.documentId !== f.documentId || _.revisionId !== f.revisionId || _.revision !== f.revision) return s("publication");
24
+ let v = (await n(i, c, d, "assets", "configuration")).value, y = r(v.renditionRequirements), b = [], x = [], S = (e) => {
25
+ let t = p.values;
26
+ for (let n of e) {
27
+ if (typeof t != "object" || !t || !Object.hasOwn(t, n) || (Array.isArray(t) ? typeof n != "number" : typeof n != "string")) {
28
+ t = void 0;
29
+ break;
30
+ }
31
+ t = t[n];
32
+ }
33
+ return t;
34
+ }, C = [];
35
+ for (let e of g.dependencies(_)) {
36
+ let t = S(e.path);
37
+ if (t !== void 0) {
38
+ if (e.kind === "component") {
39
+ if (typeof t != "object" || !t || Array.isArray(t)) return s("publication");
40
+ if (t.componentId !== e.componentId) continue;
41
+ } else if (e.kind === "token" && t !== e.name) return s("publication");
42
+ if (C.push(e), C.length > 8192) return s("bounds");
43
+ }
44
+ }
45
+ for (let e of g.uses(_)) {
46
+ let t = S(e.path);
47
+ if (t === void 0) continue;
48
+ if (t !== ("mediaKey" in e ? e.mediaKey : e.targetDocumentId)) return s("publication");
49
+ if ("targetType" in e && (x.push(e), x.length > 8192)) return s("bounds");
50
+ let n = "targetType" in e ? h.find((t) => t.name === e.targetType) : e.path.length === 1 && g.definition.asset?.file === e.path[0] ? g : void 0;
51
+ if (!("targetType" in e && n?.definition.asset === void 0)) {
52
+ if (b.push({
53
+ fieldPath: [...e.path],
54
+ output: { kind: "original" }
55
+ }), n !== void 0) for (let t of y.filter((e) => e.contentType === n.name)) b.push({
56
+ fieldPath: [...e.path],
57
+ output: {
58
+ kind: "rendition",
59
+ slot: t.slot
60
+ }
61
+ });
62
+ if (b.length > 1024) return s("bounds");
63
+ }
64
+ }
65
+ let w = (e) => e.map((e) => ({
66
+ value: e,
67
+ key: o(e)
68
+ })).sort((e, t) => e.key < t.key ? -1 : +(e.key > t.key)).map((e) => e.value);
69
+ return {
70
+ references: w(x),
71
+ media: w(b),
72
+ dependencies: w(C),
73
+ content: {
74
+ contentType: p.contentType,
75
+ documentId: String(f.documentId),
76
+ variantId: String(f.variantId),
77
+ revisionId: String(f.revisionId),
78
+ revision: Number(f.revision),
79
+ sourceLocale: p.sourceLocale,
80
+ definitionDigest: g.digest
81
+ }
82
+ };
83
+ };
84
+ //#endregion
85
+ export { c as readAdmittedSnapshotFieldPlan };
@@ -0,0 +1,103 @@
1
+ import { copySnapshotResource as e, readVerifiedSnapshotResource as t } from "./buildSnapshot.js";
2
+ import { snapshotComponentDefinition as n, snapshotDefinitionSources as r } from "./snapshotDefinitions.js";
3
+ import { FrontendBindingUnavailable as i, copyFrontendContexts as a, copyFrontendOutputSelection as o, defineFrontendBindings as s, frontendRendererId as c, supportsFrontendContext as l } from "./frontendBindings.js";
4
+ import { createHash as u } from "node:crypto";
5
+ import { canonicalJson as d } from "@voltro/runtime";
6
+ //#region src/snapshotFrontend.ts
7
+ var f = (e) => u("sha256").update(d(e)).digest("hex"), p = (e, t, n) => ({
8
+ kind: "app-implementation",
9
+ app: e,
10
+ path: [
11
+ "frontend",
12
+ t,
13
+ n
14
+ ]
15
+ }), m = (e, t) => ({
16
+ empty: p(e, t, "empty"),
17
+ loading: p(e, t, "loading"),
18
+ error: p(e, t, "error")
19
+ }), h = (e, t, a, c) => {
20
+ let l = s(t), u = new Map([...r(e, a).components.entries()].map((e) => [e.key, e.value]));
21
+ return {
22
+ version: 2,
23
+ output: o(c),
24
+ components: Object.entries(l).map(([e, t]) => {
25
+ let r = u.get(`component:${e}`);
26
+ if (r === void 0 || d(n(t.schema, a).value) !== d(r)) throw new i({ reason: "schema" });
27
+ return {
28
+ id: e,
29
+ digest: f(r),
30
+ renderer: t.renderer,
31
+ contexts: t.contexts,
32
+ ...m(a, e),
33
+ render: p(a, e, "render"),
34
+ restricted: t.restricted === void 0 ? null : p(a, e, "restricted")
35
+ };
36
+ })
37
+ };
38
+ }, g = () => {
39
+ throw new i({ reason: "definition" });
40
+ }, _ = (t) => {
41
+ if (typeof t != "object" || !t || Array.isArray(t)) return g();
42
+ let n = e({
43
+ key: "frontend",
44
+ value: t
45
+ }).value;
46
+ return n.version !== 2 || !Array.isArray(n.components) || n.components.length > 4096 ? g() : n;
47
+ }, v = (e, t, n) => {
48
+ let r = o(e.output), i = [], s = /* @__PURE__ */ new Set();
49
+ for (let r of e.components) {
50
+ if (typeof r != "object" || !r || Array.isArray(r)) return g();
51
+ let e = r;
52
+ if (typeof e.id != "string" || !/^[a-z][a-zA-Z0-9]*$/.test(e.id) || s.has(e.id) || !c(e.renderer)) return g();
53
+ s.add(e.id);
54
+ let o = n.get(e.id);
55
+ if (o === void 0) return g();
56
+ let l = o.definition;
57
+ if (l.id !== e.id || d(o.app) !== d(t) || l.consent !== void 0 && e.restricted === null) return g();
58
+ let u = a(e.contexts);
59
+ i.push({
60
+ id: e.id,
61
+ digest: f(o),
62
+ renderer: e.renderer,
63
+ contexts: u,
64
+ ...m(t, e.id),
65
+ render: p(t, e.id, "render"),
66
+ restricted: e.restricted === null ? null : p(t, e.id, "restricted")
67
+ });
68
+ }
69
+ i.sort((e, t) => e.id < t.id ? -1 : +(e.id > t.id));
70
+ let l = {
71
+ version: 2,
72
+ output: r,
73
+ components: i
74
+ };
75
+ return d(e) === d(l) ? l : g();
76
+ }, y = (e, t, n, i) => {
77
+ let a = new Map([...r(e, n).components.entries()].filter((e) => e.key.startsWith("component:")).map((e) => [e.key.slice(10), e.value])), s = v(_(t), n, a);
78
+ return d(s.output) === d(o(i)) ? s : g();
79
+ }, b = async (e, n, r, i, a) => {
80
+ let o;
81
+ try {
82
+ o = _(i);
83
+ } catch {
84
+ return !1;
85
+ }
86
+ let s = /* @__PURE__ */ new Map();
87
+ for (let i of o.components) {
88
+ if (typeof i != "object" || !i || Array.isArray(i)) return !1;
89
+ let a = i.id;
90
+ if (typeof a != "string" || !/^[a-z][a-zA-Z0-9]*$/.test(a) || s.has(a)) return !1;
91
+ s.set(a, (await t(e, n, r, "components", `component:${a}`)).value);
92
+ }
93
+ try {
94
+ return v(o, a, s), !0;
95
+ } catch {
96
+ return !1;
97
+ }
98
+ }, x = (e, t, n) => {
99
+ let r = e;
100
+ return t.every((e) => r.components.some((t) => t.id === e.id && t.digest === e.digest && (n === void 0 || l(t.contexts, n))));
101
+ };
102
+ //#endregion
103
+ export { x as coversSnapshotComponents, b as matchesSnapshotFrontend, y as snapshotFrontendFromManifest, h as snapshotFrontendManifest };
@@ -0,0 +1,8 @@
1
+ //#region src/snapshotLink.ts
2
+ var e = (e, t) => {
3
+ let n = Object.getOwnPropertyDescriptor(e, Symbol.for("voltro.cms.snapshot.link/v1"));
4
+ if (n === void 0 || n.enumerable || n.writable || typeof n.value != "function") throw Error("Snapshot link unavailable");
5
+ return n.value(t);
6
+ };
7
+ //#endregion
8
+ export { e as snapshotLink };
@@ -0,0 +1,111 @@
1
+ import { pageCapturedPublications as e, readCapturedDocument as t, verifyPublicationState as n } from "./publicationState.js";
2
+ import { copySnapshotResource as r } from "./buildSnapshot.js";
3
+ import { snapshotDefinitionSources as i } from "./snapshotDefinitions.js";
4
+ import { pinAssetRevision as a } from "./assetRevision.js";
5
+ import { SnapshotMediaUnavailable as o, compileSnapshotMediaFields as s } from "./snapshotMediaFields.js";
6
+ import { createHash as c } from "node:crypto";
7
+ import { canonicalJson as l } from "@voltro/runtime";
8
+ //#region src/snapshotMedia.ts
9
+ var u = (e) => {
10
+ throw new o({ reason: e });
11
+ }, d = (e) => c("sha256").update(l(e)).digest("hex"), f = (e) => typeof e == "string" && e.length > 0, p = (o, c, l, p, m = Date.now()) => {
12
+ let h = {
13
+ tenantId: c.tenantId,
14
+ site: c.site,
15
+ environment: c.environment
16
+ };
17
+ if (!Object.values(h).every(f)) return u("scope");
18
+ let g = i(l, p);
19
+ return {
20
+ format: "voltro.cms.media-uses/v1",
21
+ entries: async function* (i) {
22
+ let c = await n(o, h, i, m), l = [], p = [];
23
+ for await (let e of g.schema.entries()) l.push(e);
24
+ for await (let e of g.components.entries()) p.push(e);
25
+ let _ = s(l, p);
26
+ if (c.types.length !== _.length || c.types.some((e) => !_.some((t) => t.name === e))) return u("scope");
27
+ let v = d({
28
+ schemas: l,
29
+ components: p
30
+ });
31
+ yield r({
32
+ key: "configuration",
33
+ value: {
34
+ version: 1,
35
+ ...h,
36
+ definitionDigest: v,
37
+ assetResolution: "exact-locale/v1",
38
+ app: l[0].value.app,
39
+ types: _.map((e) => e.name),
40
+ locales: c.locales
41
+ }
42
+ });
43
+ for (let n of _) for (let s of c.locales) {
44
+ let c;
45
+ for (;;) {
46
+ let l = await e(o, h, i.id, n.name, s, {
47
+ limit: 200,
48
+ now: m,
49
+ ...c === void 0 ? {} : { after: c }
50
+ });
51
+ for (let e of l.items) {
52
+ if (![
53
+ e.id,
54
+ e.documentId,
55
+ e.revisionId
56
+ ].every(f) || !Number.isSafeInteger(e.revision) || Number(e.revision) < 1) return u("publication");
57
+ let c = n.definition.asset === void 0 ? void 0 : a(h, n.definition, n.digest, e);
58
+ for (let l of n.uses(e)) {
59
+ let f = c !== void 0 && l.path.length === 1 && l.path[0] === c.fileField ? c : void 0, p, g;
60
+ if ("mediaKey" in l) p = l.mediaKey;
61
+ else {
62
+ let r = _.find((e) => e.name === l.targetType);
63
+ if (r === void 0 || r.definition.asset === void 0) continue;
64
+ let c = await t(o, h, i.id, r.name, s, l.targetDocumentId, m);
65
+ if (c === null) return u("asset");
66
+ f = a(h, r.definition, r.digest, c), p = f.fileRefId, g = {
67
+ id: d([
68
+ "cms-asset-placement/v1",
69
+ h.tenantId,
70
+ h.site,
71
+ n.name,
72
+ e.id,
73
+ l.path
74
+ ]),
75
+ resolution: "exact-locale/v1"
76
+ };
77
+ }
78
+ yield r({
79
+ key: `media-use:${d([
80
+ n.name,
81
+ e.id,
82
+ l.path
83
+ ])}`,
84
+ value: {
85
+ version: 1,
86
+ ...h,
87
+ publicationId: i.id,
88
+ definitionDigest: v,
89
+ contentType: n.name,
90
+ documentId: e.documentId,
91
+ variantId: e.id,
92
+ revisionId: e.revisionId,
93
+ revision: e.revision,
94
+ locale: s,
95
+ path: l.path,
96
+ mediaKey: p,
97
+ ...f === void 0 ? {} : { assetRevision: f },
98
+ ...g === void 0 ? {} : { placement: g }
99
+ }
100
+ });
101
+ }
102
+ }
103
+ if (l.next === null) break;
104
+ c = l.next;
105
+ }
106
+ }
107
+ }
108
+ };
109
+ };
110
+ //#endregion
111
+ export { p as snapshotMediaUsesSource };
@@ -0,0 +1,246 @@
1
+ import { deriveBuildSnapshot as e, pinnedSnapshotPartSource as t, readVerifiedSnapshotResource as n, verifyBuildSnapshot as r } from "./buildSnapshot.js";
2
+ import { Effect as i, Schema as a, Stream as o } from "effect";
3
+ import { and as s, eq as c, json as l, table as u, text as d, timestamp as f } from "@voltro/database";
4
+ import { createHash as p, randomUUID as m } from "node:crypto";
5
+ import { canonicalJson as h } from "@voltro/runtime";
6
+ //#region src/snapshotMediaCapture.ts
7
+ var g = "_voltro_cms_snapshot_media_captures", _ = u(g, {
8
+ id: d().maxLength(64),
9
+ captureId: d().maxLength(64),
10
+ tenantId: d().maxLength(64),
11
+ site: d().maxLength(64),
12
+ environment: d().maxLength(64),
13
+ contextDigest: d().maxLength(64),
14
+ config: l(),
15
+ state: d().oneOf([
16
+ "registering",
17
+ "registered",
18
+ "complete",
19
+ "abandoned"
20
+ ]),
21
+ nonce: d().maxLength(64),
22
+ candidate: l().nullable(),
23
+ custody: l().nullable(),
24
+ result: l().nullable(),
25
+ expiresAt: f().nullable(),
26
+ cleanupCheckedAt: f()
27
+ }).primaryKey(["id"]).index("cms_media_cleanup_order", ["cleanupCheckedAt", "id"]).nonReactive(), v = class extends a.TaggedError()("SnapshotMediaCaptureUnavailable", { reason: a.Literals([
28
+ "scope",
29
+ "identity",
30
+ "state",
31
+ "media",
32
+ "integrity"
33
+ ]) }) {}, y = (e) => {
34
+ throw new v({ reason: e });
35
+ }, b = (e) => p("sha256").update(h(e)).digest("hex"), x = (e) => i.tryPromise({
36
+ try: e,
37
+ catch: (e) => e
38
+ }), S = (e) => typeof e == "string" && /^[a-f0-9]{64}$/.test(e), C = (e) => typeof e == "string" && e.length > 0 && e.length <= 64, w = (e) => ({
39
+ tenantId: e.tenantId,
40
+ site: e.site,
41
+ environment: e.environment
42
+ }), T = (e) => ({
43
+ id: e.id,
44
+ contextDigest: e.contextDigest
45
+ }), E = (e, t) => !Object.values(w(e)).every(C) || !C(t.id) || !S(t.contextDigest) ? y("scope") : b([
46
+ e.tenantId,
47
+ e.site,
48
+ e.environment,
49
+ t.id
50
+ ]), D = (e, t) => s(c("id", E(e, t)), c("tenantId", e.tenantId), c("site", e.site), c("environment", e.environment)), O = (e) => {
51
+ let t = e;
52
+ return typeof t != "object" || !t || !C(t.id) || !S(t.digest) ? y("integrity") : {
53
+ id: t.id,
54
+ digest: t.digest
55
+ };
56
+ }, k = (e, t, n) => b({
57
+ version: 1,
58
+ scope: e,
59
+ key: t,
60
+ candidate: n
61
+ }), A = async (e, t, n, r = !1) => {
62
+ let [i] = await e.query({
63
+ table: g,
64
+ predicate: D(t, n),
65
+ order: [],
66
+ take: 1,
67
+ skip: void 0,
68
+ projection: void 0,
69
+ ...r ? { lock: "update" } : {}
70
+ });
71
+ return i === void 0 || i.captureId !== n.id || i.contextDigest !== n.contextDigest ? y("identity") : [
72
+ "registering",
73
+ "registered",
74
+ "complete",
75
+ "abandoned"
76
+ ].includes(String(i.state)) ? r && await e.update("_voltro_cms_snapshot_media_captures", E(t, n), { nonce: m() }) === null ? y("identity") : i : y("integrity");
77
+ }, j = (e, t, n) => {
78
+ let r = O(e.candidate), i = e.custody;
79
+ return typeof i != "object" || !i || i.id !== E(t, n) || i.tenantId !== t.tenantId || i.contextDigest !== k(t, n, r) || typeof i.instance != "string" || typeof i.bucket != "string" ? y("integrity") : {
80
+ candidate: r,
81
+ custody: { ...i }
82
+ };
83
+ }, M = (e, t, n, r) => {
84
+ let a = w(n);
85
+ return !Object.values(a).every(C) || !["voltro.cms.media-uses/v1", "voltro.cms.media-renditions/v1"].includes(r.format) ? y("media") : {
86
+ format: "voltro.cms.media-selection/v1",
87
+ entries: async function* (n) {
88
+ for await (let o of r.entries(n)) {
89
+ if (o.key === "configuration") {
90
+ yield o;
91
+ continue;
92
+ }
93
+ let n = o.value.mediaKey;
94
+ if (!C(n)) return y("media");
95
+ let r = await i.runPromise(t.inspect(e, {
96
+ id: n,
97
+ tenantId: a.tenantId
98
+ }));
99
+ for (let { rendition: e } of N(o.value)) if (h(e.source) !== h(r)) return y("media");
100
+ yield {
101
+ ...o,
102
+ value: {
103
+ ...o.value,
104
+ selectedSource: r
105
+ }
106
+ };
107
+ }
108
+ }
109
+ };
110
+ }, N = (e) => {
111
+ if (e.renditions === void 0) return [];
112
+ let t = e.renditions;
113
+ return !Array.isArray(t) || t.length > 64 || t.some((t) => !t || !t.selection || !t.rendition || t.selection.renditionId !== t.rendition.id || !S(t.selection.revisionId) || t.rendition.source?.id !== e.mediaKey || !t.rendition.output?.renditionProof) ? y("media") : t;
114
+ }, P = (e, n, r, i) => {
115
+ let a = t(e, n, r, "assets", i);
116
+ return a.format === "voltro.cms.media-selection/v1" ? {
117
+ format: a.format,
118
+ entries: async function* (e) {
119
+ let t;
120
+ for await (let r of a.entries(e)) {
121
+ let i = r.value;
122
+ if (i.version !== 1 || i.tenantId !== n.tenantId || i.site !== n.site || i.environment !== n.environment || !S(i.definitionDigest)) return y("media");
123
+ if (r.key === "configuration") {
124
+ if (t !== void 0) return y("media");
125
+ t = i.definitionDigest;
126
+ } else {
127
+ let a = i.path, o = i.selectedSource;
128
+ if (o == null || o.version !== 1 || o.id !== i.mediaKey || o.tenantId !== n.tenantId || !S(o.digest) || !S(o.sourceDigest) || t === void 0 || i.definitionDigest !== t || i.publicationId !== e.id || ![
129
+ i.mediaKey,
130
+ i.contentType,
131
+ i.documentId,
132
+ i.variantId,
133
+ i.revisionId,
134
+ i.locale
135
+ ].every(C) || !Array.isArray(a) || a.length === 0 || a.length > 128 || !a.every((e) => typeof e == "string" || Number.isSafeInteger(e) && Number(e) >= 0) || !Number.isSafeInteger(i.revision) || Number(i.revision) < 1 || r.key !== `media-use:${b([
136
+ i.contentType,
137
+ i.variantId,
138
+ a
139
+ ])}`) return y("media");
140
+ }
141
+ r.key !== "configuration" && N(i), yield r;
142
+ }
143
+ if (t === void 0) return y("media");
144
+ }
145
+ } : y("media");
146
+ }, F = async (e, t, n, a, o) => {
147
+ let s = w(n), c = T(a), l = E(s, c), u = o.maxBytes, d = o.capture;
148
+ if (!Number.isSafeInteger(u) || u < 0) return y("scope");
149
+ await e.insertIgnore(g, {
150
+ id: l,
151
+ captureId: c.id,
152
+ ...s,
153
+ contextDigest: c.contextDigest,
154
+ config: { maxBytes: u },
155
+ state: "registering",
156
+ nonce: m(),
157
+ candidate: null,
158
+ custody: null,
159
+ result: null,
160
+ expiresAt: null,
161
+ cleanupCheckedAt: /* @__PURE__ */ new Date(0)
162
+ }, { conflictColumns: ["id"] });
163
+ let f = await A(e, s, c, !0);
164
+ if (h(f.config) !== h({ maxBytes: u })) return y("identity");
165
+ if (f.state === "abandoned") return y("state");
166
+ if (f.state !== "registering") return j(f, s, c), c;
167
+ let p = await d(e), _ = o.now ?? Date.now(), v = await r(e, s, O(p), _), b = O(v), x = P(e, s, v, _), S = await i.runPromise(t.register(e, {
168
+ id: l,
169
+ tenantId: s.tenantId,
170
+ contextDigest: k(s, c, b),
171
+ maxBytes: u,
172
+ sources: async function* () {
173
+ for await (let e of x.entries(v.manifest.publication)) if (e.key !== "configuration") {
174
+ yield e.value.selectedSource;
175
+ for (let { rendition: t } of N(e.value)) yield t.output;
176
+ }
177
+ }
178
+ }));
179
+ return await e.update(g, l, {
180
+ state: "registered",
181
+ candidate: b,
182
+ custody: S.key,
183
+ expiresAt: new Date(v.expiresAt)
184
+ }), c;
185
+ }, I = (t, a, s, c, l = Date.now) => i.gen(function* () {
186
+ let u = w(s), d = T(c), f = yield* x(() => A(t, u, d));
187
+ if (f.state !== "registered" && f.state !== "complete") return yield* i.fail(new v({ reason: "state" }));
188
+ let p = j(f, u, d);
189
+ return yield* x(() => r(t, u, f.state === "complete" ? O(f.result) : p.candidate, l())), yield* a.run(p.custody), yield* x(() => t.transactional(async (t) => {
190
+ let s = await A(t, u, d, !0), c = l();
191
+ if (s.state === "complete") return r(t, u, O(s.result), c);
192
+ if (s.state !== "registered") return y("state");
193
+ let f = j(s, u, d), p = await r(t, u, f.candidate, c), m = await i.runPromise(a.seal(t, f.custody)), h = P(t, u, p, c), _ = (e) => `binary:${b([m.source?.instance ?? m.instance, e])}`, v = await e(t, u, f.candidate, { assets: {
194
+ format: "voltro.cms.media-custody/v2",
195
+ entries: async function* (e) {
196
+ yield {
197
+ key: "custody",
198
+ value: {
199
+ version: 1,
200
+ capture: m
201
+ }
202
+ };
203
+ for await (let e of o.toAsyncIterable(a.items(m, t))) yield {
204
+ key: _(e.sourceId),
205
+ value: {
206
+ version: 1,
207
+ binaryId: b([
208
+ "cms-binary/v1",
209
+ u.tenantId,
210
+ e.checksum,
211
+ e.size,
212
+ e.contentType
213
+ ]),
214
+ object: e
215
+ }
216
+ };
217
+ for await (let t of h.entries(e)) yield t.key === "configuration" ? t : {
218
+ ...t,
219
+ value: {
220
+ ...t.value,
221
+ binaryKey: _(String(t.value.mediaKey)),
222
+ ...t.value.renditions === void 0 ? {} : { renditions: N(t.value).map((e) => ({
223
+ ...e,
224
+ binaryKey: _(e.rendition.output.id)
225
+ })) }
226
+ }
227
+ };
228
+ }
229
+ } }, c);
230
+ for await (let e of h.entries(p.manifest.publication)) {
231
+ let r = N(e.value);
232
+ if (r.length === 0) continue;
233
+ let i = (await n(t, u, v, "assets", _(String(e.value.mediaKey)))).value.object;
234
+ for (let { rendition: e } of r) {
235
+ let r = (await n(t, u, v, "assets", _(e.output.id))).value.object, a = e.output.renditionProof;
236
+ for (let [e, t] of [[i, a.source], [r, a.output]]) if (!e || e.checksum !== t.checksum || e.size !== t.size || e.contentType !== t.contentType) return y("media");
237
+ }
238
+ }
239
+ return await t.update(g, E(u, d), {
240
+ state: "complete",
241
+ result: O(v)
242
+ }), v;
243
+ }));
244
+ });
245
+ //#endregion
246
+ export { g as SNAPSHOT_MEDIA_CAPTURES, v as SnapshotMediaCaptureUnavailable, F as beginSnapshotMediaCapture, I as resumeSnapshotMediaCapture, _ as snapshotMediaCapturesTable, M as snapshotMediaSelectionSource };