@voltro/cms 0.86.0 → 0.87.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/CHANGELOG.md +5321 -0
  2. package/README.md +138 -0
  3. package/THIRD-PARTY-NOTICES.md +860 -221
  4. package/dist/RichDocumentView.js +81 -36
  5. package/dist/aiCandidates.js +3 -3
  6. package/dist/applicationBuildSnapshotService.js +101 -0
  7. package/dist/assetRenditions.js +102 -0
  8. package/dist/assetRevision.js +46 -0
  9. package/dist/assetUseRights.js +72 -0
  10. package/dist/availability.js +19 -16
  11. package/dist/blueprint.js +75 -75
  12. package/dist/build.d.ts +3063 -0
  13. package/dist/build.js +37 -0
  14. package/dist/buildApplicationAdmission.js +16 -0
  15. package/dist/buildApplicationCatalog.js +136 -0
  16. package/dist/buildApplicationCatalogTable.js +24 -0
  17. package/dist/buildApplicationRest.js +99 -0
  18. package/dist/buildApplicationUpload.js +111 -0
  19. package/dist/buildSnapshot.js +401 -0
  20. package/dist/buildSnapshotApplicationPin.js +32 -0
  21. package/dist/buildSnapshotRest.js +210 -0
  22. package/dist/buildSnapshotService.js +265 -0
  23. package/dist/buildSnapshotTables.js +25 -0
  24. package/dist/bulk.js +71 -70
  25. package/dist/changes.js +279 -62
  26. package/dist/consent.js +5 -5
  27. package/dist/contentLocations.js +53 -0
  28. package/dist/contentProjection.js +83 -0
  29. package/dist/contentRouteIdentity.js +13 -0
  30. package/dist/contentRouteMaterializer.js +97 -0
  31. package/dist/contentRouteTypes.js +39 -0
  32. package/dist/contentSeo.js +189 -0
  33. package/dist/contentTreePath.js +60 -0
  34. package/dist/contentType.js +117 -100
  35. package/dist/contentValues.js +18 -0
  36. package/dist/copies.js +3 -3
  37. package/dist/domainHost.js +7 -0
  38. package/dist/domains.js +81 -87
  39. package/dist/draftTexts.js +37 -37
  40. package/dist/duplicates.js +23 -23
  41. package/dist/environmentAliases.js +138 -0
  42. package/dist/environments.js +107 -69
  43. package/dist/errors.js +54 -14
  44. package/dist/experiments.js +7 -7
  45. package/dist/frontendBindings.js +99 -0
  46. package/dist/frontendMedia.js +18 -0
  47. package/dist/index.d.ts +760 -47
  48. package/dist/index.js +89 -73
  49. package/dist/initializePublicRoutes.js +28 -0
  50. package/dist/liveContentRouteView.js +76 -0
  51. package/dist/nativeOutputDeploymentService.js +205 -0
  52. package/dist/outputActivation.js +234 -0
  53. package/dist/outputActivationOrigin.js +51 -0
  54. package/dist/outputActivationStore.js +411 -0
  55. package/dist/outputActivationTables.js +11 -0
  56. package/dist/outputActivationTarget.js +81 -0
  57. package/dist/outputActivationTargetTable.js +25 -0
  58. package/dist/outputDeployment.js +174 -0
  59. package/dist/outputDeploymentRest.js +168 -0
  60. package/dist/outputDeploymentService.js +241 -0
  61. package/dist/outputRouteGraph.js +177 -0
  62. package/dist/outputSafetyArtifact.js +147 -0
  63. package/dist/outputTargetRest.js +62 -0
  64. package/dist/pathSegmentEncoding.js +4 -0
  65. package/dist/privateCmsTransport.js +76 -0
  66. package/dist/privateNativeRouteReservation.js +10 -0
  67. package/dist/promotion.js +68 -59
  68. package/dist/publicBuild.js +90 -0
  69. package/dist/publicBuildRest.js +98 -0
  70. package/dist/publicBuildService.js +63 -0
  71. package/dist/publicOutputHttp.js +129 -0
  72. package/dist/publicOutputService.js +287 -0
  73. package/dist/publicPresentation.js +17 -0
  74. package/dist/publicRouteDispositionAdmission.js +38 -0
  75. package/dist/publicRouteHistoryStore.js +12 -0
  76. package/dist/publicRouteHistoryView.js +34 -0
  77. package/dist/publicRouteIntegrity.js +5 -0
  78. package/dist/publicRouteMutation.js +6 -0
  79. package/dist/publicRouteNamespace.js +134 -0
  80. package/dist/publicRoutePublication.js +36 -0
  81. package/dist/publicRouteRegistry.js +17 -0
  82. package/dist/publicRouteRegistryBinding.js +194 -0
  83. package/dist/publicRouteRegistryDefinition.js +76 -0
  84. package/dist/publicRouteSitePublication.js +40 -0
  85. package/dist/publicRouteTables.js +13 -0
  86. package/dist/publicRouteUrl.js +18 -0
  87. package/dist/publicationSeo.js +52 -0
  88. package/dist/publicationState.js +296 -0
  89. package/dist/quality.js +8 -8
  90. package/dist/reconfigurePublicRoutes.js +41 -0
  91. package/dist/redirects.js +104 -73
  92. package/dist/referenceGraph.js +15 -14
  93. package/dist/references.js +2 -2
  94. package/dist/release.js +177 -141
  95. package/dist/renderReadAuthority.js +43 -0
  96. package/dist/renderReadGrant.js +137 -0
  97. package/dist/review.js +28 -28
  98. package/dist/richDocument.js +54 -24
  99. package/dist/routeDispositionGraph.js +44 -0
  100. package/dist/routeDispositionRest.js +51 -0
  101. package/dist/routeDispositionService.js +73 -0
  102. package/dist/routeDispositionStore.js +289 -0
  103. package/dist/routeDispositionTables.js +5 -0
  104. package/dist/routeDispositions.js +91 -0
  105. package/dist/routeHistoryStorage.js +320 -0
  106. package/dist/routeHistoryStore.js +12 -0
  107. package/dist/schedule.js +36 -36
  108. package/dist/seo.js +1 -1
  109. package/dist/series.js +11 -11
  110. package/dist/share.js +13 -13
  111. package/dist/siteBindings.js +159 -0
  112. package/dist/siteBuildCandidate.js +104 -0
  113. package/dist/siteDelivery.js +115 -0
  114. package/dist/siteState.js +47 -0
  115. package/dist/snapshotAddressGraph.js +55 -0
  116. package/dist/snapshotAddressRead.js +73 -0
  117. package/dist/snapshotAppConsumer.js +71 -0
  118. package/dist/snapshotAppExecution.js +102 -0
  119. package/dist/snapshotApplication.js +75 -0
  120. package/dist/snapshotApprovedRouteDispositions.js +44 -0
  121. package/dist/snapshotAssetAssembly.js +70 -0
  122. package/dist/snapshotAssetAssemblyRest.js +50 -0
  123. package/dist/snapshotBindingRead.js +61 -0
  124. package/dist/snapshotCodeSeo.js +29 -0
  125. package/dist/snapshotComponent.js +34 -0
  126. package/dist/snapshotComponentSource.js +24 -0
  127. package/dist/snapshotConsumer.js +87 -0
  128. package/dist/snapshotContentIdentity.js +10 -0
  129. package/dist/snapshotDefinitions.js +264 -0
  130. package/dist/snapshotDocumentAssembly.js +193 -0
  131. package/dist/snapshotDocumentAssemblyRest.js +84 -0
  132. package/dist/snapshotDocumentProjection.js +202 -0
  133. package/dist/snapshotDocumentTransfer.js +35 -0
  134. package/dist/snapshotDocumentTransferRest.js +80 -0
  135. package/dist/snapshotDomains.js +56 -0
  136. package/dist/snapshotEnvironment.js +31 -0
  137. package/dist/snapshotFieldPlan.js +85 -0
  138. package/dist/snapshotFrontend.js +103 -0
  139. package/dist/snapshotLink.js +8 -0
  140. package/dist/snapshotMedia.js +111 -0
  141. package/dist/snapshotMediaCapture.js +246 -0
  142. package/dist/snapshotMediaFields.js +225 -0
  143. package/dist/snapshotMediaRead.js +185 -0
  144. package/dist/snapshotMediaReader.js +13 -0
  145. package/dist/snapshotObservation.js +16 -0
  146. package/dist/snapshotObservedRouteHistory.js +34 -0
  147. package/dist/snapshotOutputTransfer.js +78 -0
  148. package/dist/snapshotPageLoader.js +7 -0
  149. package/dist/snapshotPageSeo.js +59 -0
  150. package/dist/snapshotPathLocale.js +15 -0
  151. package/dist/snapshotPresentation.js +86 -0
  152. package/dist/snapshotPresentationPolicy.js +12 -0
  153. package/dist/snapshotProjection.js +119 -0
  154. package/dist/snapshotPublicAccess.js +161 -0
  155. package/dist/snapshotPublicRouteHistory.js +40 -0
  156. package/dist/snapshotReadAdmission.js +38 -0
  157. package/dist/snapshotRedirectOutput.js +151 -0
  158. package/dist/snapshotRedirectTargets.js +24 -0
  159. package/dist/snapshotRedirects.js +132 -0
  160. package/dist/snapshotReference.js +8 -0
  161. package/dist/snapshotReferenceAddress.js +10 -0
  162. package/dist/snapshotReferenceGraph.js +79 -0
  163. package/dist/snapshotReferenceRead.js +65 -0
  164. package/dist/snapshotRelease.js +99 -0
  165. package/dist/snapshotRender.js +361 -0
  166. package/dist/snapshotRenderDependencies.js +178 -0
  167. package/dist/snapshotRenditions.js +88 -0
  168. package/dist/snapshotRichDocument.js +62 -0
  169. package/dist/snapshotRoleTransfer.js +106 -0
  170. package/dist/snapshotRoleTransferRest.js +99 -0
  171. package/dist/snapshotRouteAdmission.js +71 -0
  172. package/dist/snapshotRouteDispatch.js +111 -0
  173. package/dist/snapshotRouteDispositionPlan.js +73 -0
  174. package/dist/snapshotRouteRead.js +43 -0
  175. package/dist/snapshotRoutes.js +79 -0
  176. package/dist/snapshotRouting.js +113 -0
  177. package/dist/snapshotSeo.js +179 -0
  178. package/dist/snapshotSeoControls.js +101 -0
  179. package/dist/snapshotSeoDocumentInventory.js +115 -0
  180. package/dist/snapshotSeoDocuments.js +129 -0
  181. package/dist/snapshotSeoMerge.js +85 -0
  182. package/dist/snapshotSeoMetadata.js +137 -0
  183. package/dist/snapshotSeoOutput.js +173 -0
  184. package/dist/snapshotSeoPathSets.js +105 -0
  185. package/dist/snapshotSeoRead.js +88 -0
  186. package/dist/snapshotSite.js +128 -0
  187. package/dist/snapshotSitemapFiles.js +36 -0
  188. package/dist/snapshotTreeDependencies.js +58 -0
  189. package/dist/snapshotTreeLoader.js +10 -0
  190. package/dist/snapshotTreeRead.js +158 -0
  191. package/dist/staticPathSet.js +177 -0
  192. package/dist/staticPathSetRest.js +129 -0
  193. package/dist/staticPathSetService.js +249 -0
  194. package/dist/staticPathSetStore.js +338 -0
  195. package/dist/tree.js +9 -9
  196. package/dist/validation.js +53 -53
  197. package/dist/web.d.ts +709 -7
  198. package/dist/web.js +50 -33
  199. package/dist/workflow.js +8 -8
  200. package/dist/write.js +250 -225
  201. package/package.json +20 -6
@@ -0,0 +1,111 @@
1
+ import { 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 };
@@ -0,0 +1,225 @@
1
+ import { richDocumentProblems as e, richDocumentReferencePaths as t } from "./richDocument.js";
2
+ import { Schema as n } from "effect";
3
+ import { createHash as r } from "node:crypto";
4
+ import { canonicalJson as i } from "@voltro/runtime";
5
+ //#region src/snapshotMediaFields.ts
6
+ var a = class extends n.TaggedError()("SnapshotMediaUnavailable", { reason: n.Literals([
7
+ "scope",
8
+ "definition",
9
+ "publication",
10
+ "bounds",
11
+ "asset"
12
+ ]) }) {}, o = (e) => {
13
+ throw new a({ reason: e });
14
+ }, s = (e) => r("sha256").update(i(e)).digest("hex"), c = (e) => typeof e == "string" && e.length > 0, l = (e) => typeof e != "object" || !e || Array.isArray(e) ? o("definition") : e, u = (n, r) => {
15
+ let i = new Map(r.filter((e) => e.key !== "registry").map((e) => [l(e.value.definition).id, e])), a = (e, t) => Object.entries(l(e)).map(([e, n]) => [e, u(n, t)]), u = (e, t) => {
16
+ if (t > 64) return o("bounds");
17
+ let n = l(e), r = (e) => e === void 0 ? /* @__PURE__ */ new Map() : Array.isArray(e) ? new Map(e.map((e) => {
18
+ let n = l(e), r = i.get(n.id);
19
+ if (!c(n.id) || r === void 0 || s(r.value) !== n.digest) return o("definition");
20
+ let u = l(r.value.definition);
21
+ return !c(u.fingerprint) || u.consent !== void 0 && !c(u.consent) ? o("definition") : [n.id, {
22
+ fingerprint: u.fingerprint,
23
+ digest: s(r.value),
24
+ consent: typeof u.consent == "string" ? u.consent : null,
25
+ fields: a(u.props, t + 1)
26
+ }];
27
+ })) : o("definition");
28
+ switch (n.kind) {
29
+ case "media": return { kind: "media" };
30
+ case "reference": return c(n.referenceType) ? {
31
+ kind: "reference",
32
+ targetType: n.referenceType
33
+ } : o("definition");
34
+ case "array": return {
35
+ kind: "array",
36
+ element: u(n.element, t + 1)
37
+ };
38
+ case "struct": return {
39
+ kind: "struct",
40
+ fields: a(n.struct, t + 1)
41
+ };
42
+ case "components": return {
43
+ kind: "components",
44
+ components: r(n.components)
45
+ };
46
+ case "richText": {
47
+ let e = n.richText === void 0 ? {} : l(n.richText);
48
+ return {
49
+ kind: "richText",
50
+ components: r((e.profile === void 0 ? {} : l(e.profile)).components),
51
+ options: e
52
+ };
53
+ }
54
+ case "string":
55
+ case "number":
56
+ case "boolean":
57
+ case "date":
58
+ case "datetime":
59
+ case "literal": return n.token === void 0 ? { kind: "leaf" } : n.kind !== "literal" || !c(n.token) || !Array.isArray(n.literals) || !n.literals.every(c) ? o("definition") : {
60
+ kind: "leaf",
61
+ token: {
62
+ group: n.token,
63
+ names: n.literals,
64
+ digest: s(n)
65
+ }
66
+ };
67
+ default: return o("definition");
68
+ }
69
+ }, p = n.filter((e) => e.key !== "registry").map((e) => {
70
+ let t = l(e.value.definition);
71
+ return c(t.name) ? {
72
+ name: t.name,
73
+ fields: a(t.fields, 0),
74
+ definition: t,
75
+ digest: s(e.value)
76
+ } : o("definition");
77
+ }), m = function* (n, r, i) {
78
+ if (i.length > 128) return o("bounds");
79
+ if (r == null) return;
80
+ if (n.kind === "leaf") {
81
+ if (n.token !== void 0) {
82
+ if (typeof r != "string" || !n.token.names.includes(r)) return o("publication");
83
+ yield {
84
+ kind: "token",
85
+ path: i,
86
+ group: n.token.group,
87
+ name: r,
88
+ digest: n.token.digest
89
+ };
90
+ }
91
+ return;
92
+ }
93
+ if (n.kind === "reference") {
94
+ if (typeof r != "string") return o("publication");
95
+ r !== "" && (yield {
96
+ path: i,
97
+ targetType: n.targetType,
98
+ targetDocumentId: r
99
+ });
100
+ return;
101
+ }
102
+ if (n.kind === "media") {
103
+ if (typeof r != "string") return o("publication");
104
+ r !== "" && (yield {
105
+ path: i,
106
+ mediaKey: r
107
+ });
108
+ return;
109
+ }
110
+ if (n.kind === "array") {
111
+ if (!Array.isArray(r)) return o("publication");
112
+ for (let e = 0; e < r.length; e++) yield* m(n.element, r[e], [...i, e]);
113
+ return;
114
+ }
115
+ if (n.kind === "struct") {
116
+ if (typeof r != "object" || Array.isArray(r)) return o("publication");
117
+ for (let [e, t] of n.fields) yield* m(t, r[e], [...i, e]);
118
+ return;
119
+ }
120
+ if (n.kind === "richText") {
121
+ if (e("", r, n.options).length > 0 || n.options.profile !== void 0 && r.profile !== n.options.profile.id) return o("publication");
122
+ yield {
123
+ kind: "rich-document",
124
+ path: i,
125
+ digest: s(n.options)
126
+ }, yield* f(r, i, n.options);
127
+ for (let e of t(i, r, n.options)) {
128
+ let t = r;
129
+ for (let n of e.path.slice(i.length)) t = d(t, n);
130
+ let n = l(t), a = n.type === "image" || n.type === "file" ? ["asset"] : n.type === "contact" ? ["contact", "target"] : ["target"];
131
+ yield {
132
+ ...e,
133
+ path: [...e.path, ...a]
134
+ };
135
+ }
136
+ }
137
+ let a = n.kind === "richText" ? typeof r == "object" && !Array.isArray(r) ? r.blocks : void 0 : r;
138
+ if (!Array.isArray(a)) return o("publication");
139
+ for (let e = 0; e < a.length; e++) {
140
+ let t = a[e];
141
+ if (typeof t != "object" || !t || Array.isArray(t)) return o("publication");
142
+ let r = t;
143
+ if (n.kind === "richText" && r.type !== "component") {
144
+ if (![
145
+ "paragraph",
146
+ "heading",
147
+ "list",
148
+ "table",
149
+ "image",
150
+ "file"
151
+ ].includes(String(r.type))) return o("publication");
152
+ continue;
153
+ }
154
+ let s = r.props, c = typeof r.componentId == "string" ? n.components.get(r.componentId) : void 0;
155
+ if (c === void 0 || r.fingerprint !== c.fingerprint || typeof s != "object" || !s || Array.isArray(s)) return o("publication");
156
+ let l = n.kind === "richText" ? [
157
+ ...i,
158
+ "blocks",
159
+ e,
160
+ "props"
161
+ ] : [
162
+ ...i,
163
+ e,
164
+ "props"
165
+ ];
166
+ yield {
167
+ kind: "component",
168
+ path: l.slice(0, -1),
169
+ componentId: String(r.componentId),
170
+ digest: c.digest,
171
+ fingerprint: c.fingerprint,
172
+ consent: c.consent
173
+ };
174
+ for (let [e, t] of c.fields) yield* m(t, s[e], [...l, e]);
175
+ }
176
+ };
177
+ return p.map((e) => ({
178
+ name: e.name,
179
+ definition: e.definition,
180
+ digest: e.digest,
181
+ uses: function* (t) {
182
+ for (let [n, r] of e.fields) for (let e of m(r, t[n], [n])) "kind" in e || (yield e);
183
+ },
184
+ dependencies: function* (t) {
185
+ for (let [n, r] of e.fields) for (let e of m(r, t[n], [n])) "kind" in e && (yield e);
186
+ }
187
+ }));
188
+ }, d = (e, t) => typeof e != "object" || !e || !Object.hasOwn(e, t) ? o("publication") : e[t], f = function* (e, t, n) {
189
+ let r = n.profile?.styles;
190
+ if (r === void 0) return;
191
+ let i = function* (e, t) {
192
+ e !== void 0 && (yield {
193
+ kind: "token",
194
+ path: [...t, "style"],
195
+ group: r.group,
196
+ name: e,
197
+ digest: s(r)
198
+ });
199
+ }, a = function* (e, t) {
200
+ for (let n = 0; n < e.length; n++) {
201
+ let r = e[n];
202
+ r.type === "text" && (yield* i(r.style, [...t, n]));
203
+ }
204
+ };
205
+ for (let n = 0; n < e.blocks.length; n++) {
206
+ let r = e.blocks[n], o = [
207
+ ...t,
208
+ "blocks",
209
+ n
210
+ ];
211
+ if ((r.type === "paragraph" || r.type === "heading" || r.type === "list") && (yield* i(r.style, o)), (r.type === "paragraph" || r.type === "heading") && (yield* a(r.content, [...o, "content"])), r.type === "list") for (let e = 0; e < r.items.length; e++) yield* a(r.items[e], [
212
+ ...o,
213
+ "items",
214
+ e
215
+ ]);
216
+ if (r.type === "table") for (let e = 0; e < r.rows.length; e++) for (let t = 0; t < r.rows[e].length; t++) yield* a(r.rows[e][t], [
217
+ ...o,
218
+ "rows",
219
+ e,
220
+ t
221
+ ]);
222
+ }
223
+ };
224
+ //#endregion
225
+ export { a as SnapshotMediaUnavailable, u as compileSnapshotMediaFields };