@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,29 @@
1
+ import { copySnapshotResource as e } from "./buildSnapshot.js";
2
+ //#region src/snapshotCodeSeo.ts
3
+ var t = () => {
4
+ throw Error("Invalid retained code SEO");
5
+ }, n = (e, t) => typeof e == "string" && e.length > 0 && e.length <= t && !/[\x00-\x1f\x7f]/.test(e), r = (r) => {
6
+ let i = e({
7
+ key: "native-seo",
8
+ value: { metadata: r }
9
+ }).value.metadata;
10
+ if (typeof i != "object" || !i || Array.isArray(i)) return t();
11
+ let a = i;
12
+ if (Object.keys(a).sort().join(",") !== "alternates,canonical,noIndex,version" || a.version !== 1 || a.canonical !== null && !n(a.canonical, 8192) || typeof a.noIndex != "boolean" || !Array.isArray(a.alternates) || a.alternates.length > 1024) return t();
13
+ let o = a.alternates.map((e) => {
14
+ if (typeof e != "object" || !e || Array.isArray(e)) return t();
15
+ let r = e;
16
+ return Object.keys(r).sort().join(",") !== "href,locale" || !n(r.href, 8192) || !n(r.locale, 128) ? t() : {
17
+ href: r.href,
18
+ locale: r.locale
19
+ };
20
+ });
21
+ return new Set(o.map((e) => e.locale)).size === o.length ? {
22
+ version: 1,
23
+ canonical: a.canonical,
24
+ noIndex: a.noIndex,
25
+ alternates: o
26
+ } : t();
27
+ };
28
+ //#endregion
29
+ export { r as copySnapshotCodeSeo };
@@ -0,0 +1,34 @@
1
+ import { renderCapturedFrontendComponent as e } from "./frontendBindings.js";
2
+ import { snapshotComponentSource as t } from "./snapshotComponentSource.js";
3
+ import { snapshotObserver as n, snapshotProjectedValue as r } from "./snapshotObservation.js";
4
+ //#region src/snapshotComponent.ts
5
+ var i = (i, a, o, s = "content") => {
6
+ let c = r(i, o), l = n(i), u = [...o];
7
+ if (typeof c != "object" || !c || Array.isArray(c)) throw Error("Snapshot component unavailable");
8
+ let d = c;
9
+ if (typeof d.componentId != "string" || d.props === null || typeof d.props != "object" || Array.isArray(d.props)) throw Error("Snapshot component unavailable");
10
+ return e(a, {
11
+ componentId: d.componentId,
12
+ props: d.props,
13
+ context: i.context,
14
+ state: s,
15
+ presentation: i.presentation,
16
+ consentPurposes: i.consentPurposes,
17
+ source: t(i, u, d),
18
+ observe: (e) => l({
19
+ kind: "component",
20
+ fieldPath: u,
21
+ ...e
22
+ }),
23
+ media: {
24
+ entries: i.media,
25
+ fieldPath: [...u, "props"],
26
+ observe: (e) => l({
27
+ kind: "media",
28
+ ...e
29
+ })
30
+ }
31
+ });
32
+ };
33
+ //#endregion
34
+ export { i as renderSnapshotComponent };
@@ -0,0 +1,24 @@
1
+ import { snapshotReference as e } from "./snapshotReference.js";
2
+ import { snapshotLink as t } from "./snapshotLink.js";
3
+ import { copySnapshotContentIdentity as n } from "./snapshotContentIdentity.js";
4
+ //#region src/snapshotComponentSource.ts
5
+ var r = (r, i, a) => {
6
+ let o = Object.freeze([...i]), s = a.type === "component" ? a.id : a.instanceId;
7
+ return Object.freeze({
8
+ content: Object.freeze(n(r.content)),
9
+ fieldPath: o,
10
+ instanceId: typeof s == "string" && s.length > 0 ? s : null,
11
+ link: (e) => t(r, [
12
+ ...o,
13
+ "props",
14
+ ...e
15
+ ]),
16
+ reference: (t) => e(r, [
17
+ ...o,
18
+ "props",
19
+ ...t
20
+ ])
21
+ });
22
+ };
23
+ //#endregion
24
+ export { r as snapshotComponentSource };
@@ -0,0 +1,87 @@
1
+ import { readVerifiedSnapshotResource as e } from "./buildSnapshot.js";
2
+ import { copyRenderReadAuthority as t, readRenderReadAuthority as n } from "./renderReadAuthority.js";
3
+ import { resolveSnapshotReadBinding as r } from "./snapshotReadAdmission.js";
4
+ import { issueRenderReadGrant as i, verifyRenderReadRenewal as a } from "./renderReadGrant.js";
5
+ import { Schema as o } from "effect";
6
+ import { generateId as s } from "@voltro/database";
7
+ import { dataStoreApiKeyStore as c, makeApiKeyService as l } from "@voltro/runtime";
8
+ //#region src/snapshotConsumer.ts
9
+ var u = class extends o.TaggedError()("SnapshotConsumerUnavailable", { reason: o.Literals([
10
+ "configuration",
11
+ "credential",
12
+ "projection",
13
+ "expiry"
14
+ ]) }) {}, d = (e) => {
15
+ throw new u({ reason: e });
16
+ }, f = (e) => Number.isSafeInteger(e) && Number.isFinite(new Date(e).getTime()), p = (e, t) => {
17
+ if (typeof e != "object" || !e || Array.isArray(e)) return d("configuration");
18
+ let n = e;
19
+ if (Object.keys(n).length !== 3 || Object.keys(n).some((e) => ![
20
+ "id",
21
+ "requiredScope",
22
+ "maxGrantMs"
23
+ ].includes(e))) return d("configuration");
24
+ let { id: r, requiredScope: i, maxGrantMs: a } = n;
25
+ return !f(t) || typeof r != "string" || !/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(r) || typeof i != "string" || !/^[A-Za-z][A-Za-z0-9:_.-]{0,127}$/.test(i) || typeof a != "number" || !Number.isSafeInteger(a) || a <= 0 || !f(t + a) ? d("configuration") : {
26
+ id: r,
27
+ requiredScope: i,
28
+ maxGrantMs: a
29
+ };
30
+ }, m = async (o, u, m, h) => {
31
+ let g = {
32
+ tenantId: u.tenantId,
33
+ site: u.site,
34
+ environment: u.environment
35
+ }, _ = {
36
+ id: m.snapshot.id,
37
+ digest: m.snapshot.digest
38
+ }, v = m.apiKey, y = m.resume === void 0 ? void 0 : {
39
+ token: m.resume.token,
40
+ buildId: m.resume.buildId
41
+ }, b = h.now ?? Date.now(), x = p(h.consumer, b), S = {
42
+ id: h.key.id,
43
+ material: new Uint8Array(h.key.material)
44
+ }, C = (h.verificationKeys ?? []).map((e) => ({
45
+ id: e.id,
46
+ material: new Uint8Array(e.material)
47
+ }));
48
+ if (typeof v != "string" || v.length === 0 || v.length > 512) return d("credential");
49
+ let w = await l(c(o)).verify(v, b);
50
+ if (w === null) return d("credential");
51
+ let T = t({
52
+ kind: "apiKey",
53
+ id: w.id,
54
+ scope: x.requiredScope
55
+ });
56
+ if (T === null) return d("credential");
57
+ let E = await n(o, g, T, b);
58
+ if (E === null) return d("credential");
59
+ let D = y?.buildId ?? s({
60
+ kind: "typeid",
61
+ prefix: "cmsbuild"
62
+ }, "_voltro_cms_render_read_grants"), { snapshot: O, binding: k } = await r(o, g, _, {
63
+ consumerId: x.id,
64
+ buildId: D
65
+ }, b), A = (await e(o, g, O, "projection", "registry")).value;
66
+ if (A.version !== 1 || A.id !== x.id) return d("projection");
67
+ y !== void 0 && await a(o, y.token, k, T, {
68
+ keys: [S, ...C],
69
+ now: b
70
+ });
71
+ let j = Math.min(b + x.maxGrantMs, O.expiresAt, E.expiresAt ?? 2 ** 53 - 1);
72
+ return !f(j) || j <= b ? d("expiry") : {
73
+ ...await i(o, k, {
74
+ key: S,
75
+ now: b,
76
+ expiresAt: j,
77
+ maxExpiresAt: j,
78
+ authority: T
79
+ }),
80
+ consumerId: x.id,
81
+ buildId: D,
82
+ snapshotId: O.id,
83
+ snapshotDigest: O.digest
84
+ };
85
+ };
86
+ //#endregion
87
+ export { u as SnapshotConsumerUnavailable, p as copySnapshotConsumer, m as issueSnapshotReadGrant };
@@ -0,0 +1,10 @@
1
+ //#region src/snapshotContentIdentity.ts
2
+ var e = ({ contentType: e, documentId: t, variantId: n, revisionId: r, revision: i }) => ({
3
+ contentType: e,
4
+ documentId: t,
5
+ variantId: n,
6
+ revisionId: r,
7
+ revision: i
8
+ });
9
+ //#endregion
10
+ export { e as copySnapshotContentIdentity };
@@ -0,0 +1,264 @@
1
+ import { copySnapshotResource as e } from "./buildSnapshot.js";
2
+ import { Schema as t } from "effect";
3
+ import { createHash as n } from "node:crypto";
4
+ import { canonicalJson as r } from "@voltro/runtime";
5
+ //#region src/snapshotDefinitions.ts
6
+ var i = class extends t.TaggedError()("SnapshotDefinitionUnavailable", { reason: t.Literals([
7
+ "app",
8
+ "definition",
9
+ "duplicate",
10
+ "component-conflict",
11
+ "cycle",
12
+ "bounds"
13
+ ]) }) {}, a = (e) => {
14
+ throw new i({ reason: e });
15
+ }, o = (e) => n("sha256").update(r(e)).digest("hex"), s = (e) => typeof e == "string" && e.trim().length > 0, c = (e) => !/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(e.commit) || ![e.artifactDigest, e.configDigest].every((e) => /^[0-9a-f]{64}$/.test(e)) ? a("app") : {
16
+ commit: e.commit,
17
+ artifactDigest: e.artifactDigest,
18
+ configDigest: e.configDigest
19
+ }, l = {
20
+ kind: "data",
21
+ editorHint: "data",
22
+ isOptional: "data",
23
+ publishRequired: "data",
24
+ maxLength: "data",
25
+ pattern: "data",
26
+ literals: "data",
27
+ literalLabels: "data",
28
+ token: "data",
29
+ action: "data",
30
+ fraction: "data",
31
+ unique: "data",
32
+ richText: "richText",
33
+ referenceType: "data",
34
+ element: "field",
35
+ struct: "fields",
36
+ components: "components",
37
+ derived: "derived"
38
+ }, u = {
39
+ id: "data",
40
+ displayName: "data",
41
+ props: "fields",
42
+ fingerprint: "data",
43
+ description: "data",
44
+ jobs: "data",
45
+ variants: "data",
46
+ fixtures: "data",
47
+ migrations: "migrations",
48
+ consent: "data"
49
+ }, d = {
50
+ name: "data",
51
+ displayName: "data",
52
+ pluralName: "data",
53
+ fields: "fields",
54
+ asset: "data",
55
+ list: "data",
56
+ idPrefix: "data",
57
+ revalidate: "data",
58
+ tree: "data",
59
+ address: "data",
60
+ locations: "data",
61
+ seo: "data",
62
+ seoSites: "data",
63
+ review: "review",
64
+ availability: "data",
65
+ lifecycle: "data",
66
+ templates: "templates",
67
+ changeFeed: "data",
68
+ search: "data",
69
+ quality: "quality",
70
+ taxonomy: "data",
71
+ derivedFields: "data",
72
+ uniqueFields: "data"
73
+ }, f = {
74
+ name: "data",
75
+ version: "data",
76
+ id: "data",
77
+ blocks: "data",
78
+ headings: "data",
79
+ marks: "data",
80
+ styles: "data",
81
+ components: "components",
82
+ contactPoints: "data",
83
+ contactLiterals: "data"
84
+ }, p = {
85
+ id: "data",
86
+ displayName: "data",
87
+ values: "data",
88
+ sections: "sections",
89
+ required: "components",
90
+ first: "component",
91
+ max: "limits",
92
+ regions: "regions",
93
+ widths: "widths",
94
+ maxDepth: "data"
95
+ }, m = {
96
+ id: "data",
97
+ label: "data",
98
+ approverScope: "data",
99
+ after: "data",
100
+ when: "implementation",
101
+ slaHours: "data",
102
+ evidence: "data"
103
+ }, h = {
104
+ id: "data",
105
+ field: "data",
106
+ message: "data",
107
+ blocking: "data",
108
+ pack: "data",
109
+ sites: "data",
110
+ locales: "data",
111
+ check: "implementation"
112
+ }, g = {
113
+ source: "data",
114
+ transform: "implementation"
115
+ }, _ = {
116
+ images: "data",
117
+ files: "data",
118
+ links: "data",
119
+ profile: "profile"
120
+ }, v = {
121
+ field: "data",
122
+ components: "data",
123
+ width: "data",
124
+ list: "templateList"
125
+ }, y = {
126
+ allowed: "components",
127
+ required: "components",
128
+ maxItems: "data"
129
+ }, b = {
130
+ id: "data",
131
+ version: "data",
132
+ steps: "steps"
133
+ }, x = (t, n, i = []) => {
134
+ let x = c(n);
135
+ if (t.length === 0 && i.length === 0 || t.some((e) => !s(e.name))) return a("definition");
136
+ if (new Set(t.map((e) => e.name)).size !== t.length) return a("duplicate");
137
+ let S = /* @__PURE__ */ new Set(), C = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Map(), T = (e, t) => {
138
+ if (typeof e != "object" || !e || Array.isArray(e) || ![Object.prototype, null].includes(Object.getPrototypeOf(e))) return a("definition");
139
+ if (S.has(e)) return a("cycle");
140
+ if (S.size >= 64) return a("bounds");
141
+ if (Object.getOwnPropertySymbols(e).length > 0) return a("definition");
142
+ let n = Object.getOwnPropertyDescriptors(e);
143
+ if (Object.values(n).some((e) => !e.enumerable || !("value" in e))) return a("definition");
144
+ S.add(e);
145
+ try {
146
+ return t(Object.fromEntries(Object.entries(n).map(([e, t]) => [e, t.value])));
147
+ } finally {
148
+ S.delete(e);
149
+ }
150
+ }, E = (t) => e({
151
+ key: "metadata",
152
+ value: { data: t }
153
+ }).value.data, D = (e, t) => {
154
+ if (typeof e != "function") return a("definition");
155
+ let n = r(t), i = w.get(n);
156
+ return i !== void 0 && i !== e ? a("component-conflict") : (w.set(n, e), {
157
+ kind: "app-implementation",
158
+ app: x,
159
+ path: [...t]
160
+ });
161
+ }, O = (e, t, n) => {
162
+ if (!Array.isArray(e) || Object.getOwnPropertySymbols(e).length > 0 || Object.keys(e).length !== e.length || Object.keys(e).some((e, t) => e !== String(t))) return a("definition");
163
+ let r = Object.getOwnPropertyDescriptors(e);
164
+ return Object.entries(r).some(([e, t]) => e !== "length" && (!t.enumerable || !("value" in t))) ? a("definition") : Array.from({ length: e.length }, (e, i) => n(r[String(i)].value, [...t, String(i)]));
165
+ }, k = (e, t, n) => T(e, (e) => Object.fromEntries(Object.keys(e).sort().map((r) => [r, n(e[r], [...t, r])]))), A = (e, t, n, r = !1) => T(e, (e) => Object.fromEntries(Object.keys(e).sort().flatMap((i) => r && [
166
+ "pipe",
167
+ "optional",
168
+ "requiredToPublish"
169
+ ].includes(i) ? typeof e[i] == "function" ? [] : a("definition") : Object.hasOwn(t, i) ? e[i] === void 0 ? [] : [[i, M(t[i], e[i], [...n, i])]] : a("definition")))), j = (t) => {
170
+ let n = typeof t == "object" && t ? Object.getOwnPropertyDescriptor(t, "id")?.value : void 0;
171
+ if (!s(n)) return a("definition");
172
+ let r = {
173
+ version: 1,
174
+ app: x,
175
+ definition: A(t, u, ["components", n])
176
+ }, i = e({
177
+ key: `component:${n}`,
178
+ value: r
179
+ }), c = o(i.value), l = C.get(n);
180
+ return l !== void 0 && l.digest !== c ? a("component-conflict") : (C.set(n, {
181
+ resource: i,
182
+ digest: c
183
+ }), {
184
+ id: n,
185
+ digest: c
186
+ });
187
+ }, M = (e, t, n) => {
188
+ switch (e) {
189
+ case "data": return E(t);
190
+ case "implementation": return D(t, n);
191
+ case "migrations": return k(t, n, D);
192
+ case "fields": return k(t, n, (e, t) => A(e, l, t, !0));
193
+ case "field": return A(t, l, n, !0);
194
+ case "component": return j(t);
195
+ case "components": return O(t, n, j);
196
+ case "richText": return A(t, _, n);
197
+ case "profile": return A(t, f, n);
198
+ case "derived": return A(t, g, n);
199
+ case "review": return A(t, {
200
+ required: "data",
201
+ workflow: "workflow"
202
+ }, n);
203
+ case "workflow": return A(t, b, n);
204
+ case "steps": return O(t, n, (e, t) => A(e, m, t));
205
+ case "quality": return O(t, n, (e, t) => A(e, h, t));
206
+ case "templates": return A(t, v, n);
207
+ case "templateList": return O(t, n, (e, t) => A(e, p, t));
208
+ case "sections": return O(t, n, (e, t) => A(e, {
209
+ component: "component",
210
+ props: "data"
211
+ }, t));
212
+ case "limits": return O(t, n, (e, t) => A(e, {
213
+ component: "component",
214
+ count: "data"
215
+ }, t));
216
+ case "widths": return O(t, n, (e, t) => A(e, {
217
+ component: "component",
218
+ allowed: "data"
219
+ }, t));
220
+ case "regions": return k(t, n, (e, t) => A(e, y, t));
221
+ }
222
+ }, N = [...t].sort((e, t) => e.name < t.name ? -1 : +(e.name > t.name)).map((t) => e({
223
+ key: `type:${t.name}`,
224
+ value: {
225
+ version: 1,
226
+ app: x,
227
+ definition: A(t, d, ["types", t.name])
228
+ }
229
+ }));
230
+ for (let e of i) j(e);
231
+ let P = (t, n) => {
232
+ let r = [e({
233
+ key: "registry",
234
+ value: {
235
+ version: 1,
236
+ app: x,
237
+ count: n.length
238
+ }
239
+ }), ...n];
240
+ return {
241
+ format: `voltro.cms.${t}/v1`,
242
+ entries: () => structuredClone(r)
243
+ };
244
+ };
245
+ return {
246
+ schema: P("schema", N),
247
+ components: P("components", [...C.keys()].sort().map((e) => C.get(e).resource)),
248
+ definition: (t) => {
249
+ let n = N.find((e) => e.key === `type:${t}`);
250
+ return n === void 0 ? a("definition") : e(n);
251
+ }
252
+ };
253
+ }, S = (e, t) => {
254
+ let { schema: n, components: r } = x(e, t);
255
+ return {
256
+ schema: n,
257
+ components: r
258
+ };
259
+ }, C = (e, t) => x([e], t).definition(e.name), w = (e, t) => {
260
+ for (let n of x([], t, [e]).components.entries()) if (n.key === `component:${e.id}`) return n;
261
+ return a("definition");
262
+ };
263
+ //#endregion
264
+ export { i as SnapshotDefinitionUnavailable, c as copySnapshotAppCodePin, w as snapshotComponentDefinition, C as snapshotContentTypeDefinition, S as snapshotDefinitionSources };
@@ -0,0 +1,193 @@
1
+ import { copySnapshotResource as e } from "./buildSnapshot.js";
2
+ import { admitSnapshotPresentation as t, snapshotPresentations as n } from "./snapshotPresentation.js";
3
+ import { readCapturedSnapshotConsentPurposes as r } from "./snapshotPresentationPolicy.js";
4
+ import { SnapshotSeoReadUnavailable as i } from "./snapshotSeoRead.js";
5
+ import { copySnapshotPathSetSelection as a, readSnapshotPathSets as o } from "./snapshotSeoPathSets.js";
6
+ import { readSnapshotSeoDocuments as s } from "./snapshotSeoDocuments.js";
7
+ import { createHash as c } from "node:crypto";
8
+ import { canonicalJson as l } from "@voltro/runtime";
9
+ //#region src/snapshotDocumentAssembly.ts
10
+ var u = () => {
11
+ throw new i({ reason: "binding" });
12
+ }, d = (e) => c("sha256").update(l(e)).digest("hex"), f = (e) => typeof e == "string" && /^[a-f0-9]{64}$/.test(e), p = (e, t) => typeof e != "object" || !e || Array.isArray(e) || Object.keys(e).sort().join(",") !== t ? u() : e, m = (e, t) => Number.isSafeInteger(e) && Number(e) >= 0 && Number(e) <= t, h = 1e5, g = 67108864, _ = 8192, v = "voltro.cms-document-assembly/v1", y = (i) => {
13
+ let { store: c, provider: y } = i, b = {
14
+ tenantId: i.scope.tenantId,
15
+ site: i.scope.site,
16
+ environment: i.scope.environment
17
+ }, x = { ...i.use }, S = i.keys.map((e) => ({
18
+ id: e.id,
19
+ material: new Uint8Array(e.material)
20
+ })), C = i.now ?? Date.now, w = (e) => ({
21
+ snapshot: {
22
+ id: e.snapshot.id,
23
+ digest: e.snapshot.digest
24
+ },
25
+ token: e.token,
26
+ consumerId: e.consumerId,
27
+ buildId: e.buildId,
28
+ host: e.host,
29
+ ...a({ pathSets: e.pathSets })
30
+ }), T = async (e) => c.transactional(async (t) => {
31
+ let i = await o(t, b, e, { pathSets: e.pathSets }, {
32
+ keys: S,
33
+ now: C
34
+ }), a = i.admission;
35
+ if (a.app.web === void 0) return u();
36
+ let s = await r(t, b, a.admission.snapshot, a.admission.configuration.app), c = [...n(s, 257)].sort((e, t) => d(e) < d(t) ? -1 : +(d(e) > d(t)));
37
+ return {
38
+ paths: i,
39
+ consentPurposes: s,
40
+ presentations: c,
41
+ binding: {
42
+ scope: b,
43
+ snapshot: e.snapshot,
44
+ consumerId: e.consumerId,
45
+ buildId: e.buildId,
46
+ host: e.host,
47
+ inputsId: a.app.inputsId,
48
+ executionId: a.app.executionId,
49
+ pathSets: [...i.selection.pathSets].sort((e, t) => e.id < t.id ? -1 : +(e.id > t.id)),
50
+ consentPurposes: s,
51
+ presentations: c
52
+ }
53
+ };
54
+ }), E = (e, t) => {
55
+ if (l(e.binding) !== l(t.binding) || l(e.paths.entries) !== l(t.paths.entries) || l(e.paths.contexts) !== l(t.paths.contexts)) return u();
56
+ }, D = async (e) => {
57
+ if (!f(e) || y.read === void 0) return u();
58
+ let t = await y.read(e);
59
+ return t.id !== e || d(t.manifest) !== e || t.manifest.version !== 1 || t.manifest.files.length !== 0 ? u() : t.manifest.subject;
60
+ }, O = async (e) => {
61
+ let t = await y.begin();
62
+ try {
63
+ let n = await t.seal(e);
64
+ return !f(n.id) || n.id !== d({
65
+ version: 1,
66
+ subject: e,
67
+ files: []
68
+ }) ? u() : n.id;
69
+ } catch (e) {
70
+ throw await t.abort(), e;
71
+ }
72
+ }, k = (e) => !f(e.headerId) || !f(e.tipId) ? u() : {
73
+ headerId: e.headerId,
74
+ tipId: e.tipId
75
+ }, A = async (e, t) => {
76
+ let n = p(await D(e.headerId), "binding,profile,version");
77
+ if (n.version !== 1 || n.profile !== v || l(n.binding) !== l(t.binding)) return u();
78
+ }, j = (n, r) => {
79
+ let i = e({
80
+ key: "document-assembly",
81
+ value: { documents: n }
82
+ }).value.documents;
83
+ if (!Array.isArray(i) || i.length === 0 || i.length > h || Buffer.byteLength(l(i)) > _) return u();
84
+ let a = new Map(r.paths.entries.map((e) => [e.path, e]));
85
+ return i.map((e) => {
86
+ let n = p(e, "artifactId,path,presentation,routeId,url"), i = a.get(String(n.path));
87
+ return !f(n.artifactId) || i === void 0 || n.routeId !== i.routeId || n.url !== "https://" + i.host + i.path ? u() : {
88
+ url: String(n.url),
89
+ path: i.path,
90
+ routeId: i.routeId,
91
+ artifactId: n.artifactId,
92
+ presentation: t(r.consentPurposes, n.presentation)
93
+ };
94
+ });
95
+ }, M = async (e, t, n) => {
96
+ if (e === t.headerId) return {
97
+ previousId: null,
98
+ count: 0,
99
+ bytes: 0,
100
+ documents: []
101
+ };
102
+ let r = p(await D(e), "bytes,count,documents,headerId,previousId,profile,version");
103
+ return r.version !== 1 || r.profile !== v || r.headerId !== t.headerId || !f(r.previousId) || !m(r.count, h) || !m(r.bytes, g) ? u() : {
104
+ previousId: r.previousId,
105
+ count: r.count,
106
+ bytes: r.bytes,
107
+ documents: j(r.documents, n)
108
+ };
109
+ };
110
+ return {
111
+ begin: async (e) => {
112
+ let t = w(e), n = await T(t), r = await O({
113
+ version: 1,
114
+ profile: v,
115
+ binding: n.binding
116
+ });
117
+ return E(n, await T(t)), {
118
+ headerId: r,
119
+ tipId: r,
120
+ count: 0,
121
+ bytes: 0
122
+ };
123
+ },
124
+ append: async (t) => {
125
+ let n = w(t), r = k(t), i = e({
126
+ key: "document-assembly",
127
+ value: { documents: t.documents }
128
+ }).value.documents, a = await T(n), o = j(i, a);
129
+ await A(r, a);
130
+ let s = await M(r.tipId, r, a), c = s.count + o.length, d = s.bytes + Buffer.byteLength(l(o));
131
+ if (c > h || d > g) return u();
132
+ let f = await O({
133
+ version: 1,
134
+ profile: v,
135
+ headerId: r.headerId,
136
+ previousId: r.tipId,
137
+ count: c,
138
+ bytes: d,
139
+ documents: o
140
+ });
141
+ return E(a, await T(n)), {
142
+ headerId: r.headerId,
143
+ tipId: f,
144
+ count: c,
145
+ bytes: d
146
+ };
147
+ },
148
+ seal: async (e) => {
149
+ let t = w(e), n = k(e), r = await T(t);
150
+ if (y.composeDocuments === void 0) return u();
151
+ await A(n, r);
152
+ let i = [], a = /* @__PURE__ */ new Set(), o = n.tipId, d, p = 0, _ = 0;
153
+ for (;;) {
154
+ if (a.has(o) || a.size > h) return u();
155
+ a.add(o);
156
+ let e = await M(o, n, r);
157
+ if (d !== void 0 && (e.count + d.documents.length !== d.count || e.bytes + Buffer.byteLength(l(d.documents)) !== d.bytes) || (p += e.documents.length, _ += e.documents.length === 0 ? 0 : Buffer.byteLength(l(e.documents)), p > h || _ > g)) return u();
158
+ if (e.previousId === null) break;
159
+ i.push(e.documents), d = e, o = e.previousId;
160
+ }
161
+ let v = i.reverse().flat(), D = r.paths.admission.app, O = await y.composeDocuments({
162
+ snapshotDigest: t.snapshot.digest,
163
+ inputsId: D.inputsId,
164
+ executionId: D.executionId,
165
+ selector: [
166
+ "1",
167
+ t.snapshot.digest,
168
+ D.inputsId,
169
+ D.executionId
170
+ ].join("."),
171
+ pathSetIds: r.paths.selection.pathSets.map((e) => e.digest).sort(),
172
+ consentPurposes: r.consentPurposes,
173
+ presentations: r.presentations,
174
+ documents: v
175
+ });
176
+ return !f(O.id) || O.documents !== p || !m(O.bytes, 1073741824) ? u() : (E(r, await T(t)), await c.transactional((e) => s(e, b, t, {
177
+ artifactId: O.id,
178
+ pathSets: t.pathSets
179
+ }, {
180
+ provider: y,
181
+ use: x,
182
+ keys: S,
183
+ now: C
184
+ })), E(r, await T(t)), {
185
+ artifactId: O.id,
186
+ documents: O.documents,
187
+ bytes: O.bytes
188
+ });
189
+ }
190
+ };
191
+ };
192
+ //#endregion
193
+ export { y as createSnapshotDocumentAssembly };