@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,101 @@
1
+ import { copySiteScope as e } from "./siteState.js";
2
+ import { readRenderReadCredential as t } from "./renderReadAuthority.js";
3
+ import { readAdmittedBuildSnapshot as n, resolveSnapshotReadBinding as r } from "./snapshotReadAdmission.js";
4
+ import { readSnapshotAppExecution as i } from "./snapshotAppExecution.js";
5
+ import { verifyRenderReadGrant as a } from "./renderReadGrant.js";
6
+ import { copySnapshotConsumer as o } from "./snapshotConsumer.js";
7
+ import { CmsBuildSnapshotUnavailable as s, createCmsBuildSnapshots as c } from "./buildSnapshotService.js";
8
+ import { copyBuildSnapshotApplicationPin as l } from "./buildSnapshotApplicationPin.js";
9
+ import { Effect as u } from "effect";
10
+ import { canonicalJson as d } from "@voltro/protocol";
11
+ //#region src/applicationBuildSnapshotService.ts
12
+ var f = (e) => {
13
+ throw new s({ reason: e });
14
+ }, p = (e, t) => d(e) === d(t), m = (d) => {
15
+ let m = d.store, h = {
16
+ ...e(d.scope),
17
+ environment: d.scope.environment
18
+ }, g = d.now ?? Date.now, _ = d.resolveApplication.bind(d), v = [d.key, ...d.verificationKeys ?? []].map((e) => ({
19
+ id: e.id,
20
+ material: new Uint8Array(e.material)
21
+ })), y = d.requiredScope, b = (e) => m.transactional(async (n) => {
22
+ let r = await t(n, h, e.apiKey, g());
23
+ return r === null || !r.scopes.includes(y) ? f("credential") : e.expectedApplication === void 0 ? f("configuration") : {
24
+ application: l(e.expectedApplication),
25
+ authority: r.id
26
+ };
27
+ }), x = (e) => m.transactional(async (r) => {
28
+ let a = g(), s = await t(r, h, e.apiKey, a);
29
+ if (s === null) return f("credential");
30
+ let c = await n(r, h, e.snapshot, a), u = await i(r, h, c), d = o(u.declaration.value, a);
31
+ return s.scopes.includes(d.requiredScope) ? {
32
+ application: l({
33
+ inputsId: u.inputsId,
34
+ executionId: u.executionId,
35
+ code: u.app
36
+ }),
37
+ authority: s.id
38
+ } : f("credential");
39
+ }), S = (e) => m.transactional(async (t) => {
40
+ let n = g(), { snapshot: o, binding: s } = await r(t, h, e.snapshot, e, n);
41
+ await a(t, e.token, s, {
42
+ keys: v,
43
+ now: n
44
+ });
45
+ let c = await i(t, h, o);
46
+ return {
47
+ application: l({
48
+ inputsId: c.inputsId,
49
+ executionId: c.executionId,
50
+ code: c.app
51
+ }),
52
+ authority: s.buildId
53
+ };
54
+ }), C = (e, t) => u.tryPromise({
55
+ try: async () => {
56
+ let n = structuredClone(e), r = await t(n), i = await _(l(r.application)), a = l({
57
+ inputsId: i.inputsId,
58
+ executionId: i.executionId,
59
+ code: i.code
60
+ });
61
+ if (!p(a, r.application)) return f("configuration");
62
+ let o = {
63
+ ...i,
64
+ code: a.code,
65
+ app: {
66
+ format: i.app.format,
67
+ entries: i.app.entries.bind(i.app)
68
+ },
69
+ execution: { run: i.execution.run.bind(i.execution) },
70
+ routeDiscovery: structuredClone(i.routeDiscovery)
71
+ };
72
+ return p(r, await t(n)) ? {
73
+ input: n,
74
+ service: c({
75
+ ...d,
76
+ scope: h,
77
+ ...o,
78
+ key: v[0],
79
+ verificationKeys: v.slice(1)
80
+ })
81
+ } : f("credential");
82
+ },
83
+ catch: (e) => e instanceof s ? e : new s({ reason: "configuration" })
84
+ }), w = (e) => C(e, (e) => S({
85
+ ...e,
86
+ path: "path" in e ? String(e.path) : "/"
87
+ }));
88
+ return {
89
+ capture: (e) => C(e, b).pipe(u.flatMap(({ input: e, service: t }) => t.capture(e))),
90
+ open: (e) => C(e, x).pipe(u.flatMap(({ input: e, service: t }) => t.open(e))),
91
+ read: (e) => w(e).pipe(u.flatMap(({ input: e, service: t }) => t.read(e))),
92
+ readBinding: (e) => w(e).pipe(u.flatMap(({ input: e, service: t }) => t.readBinding(e))),
93
+ readTree: (e) => w(e).pipe(u.flatMap(({ input: e, service: t }) => t.readTree(e))),
94
+ render: (e) => w(e).pipe(u.flatMap(({ input: e, service: t }) => t.render(e))),
95
+ renderSafety: (e) => w(e).pipe(u.flatMap(({ input: e, service: t }) => t.renderSafety(e))),
96
+ renderRedirects: (e) => w(e).pipe(u.flatMap(({ input: e, service: t }) => t.renderRedirects(e))),
97
+ renderSeo: (e) => w(e).pipe(u.flatMap(({ input: e, service: t }) => t.renderSeo(e)))
98
+ };
99
+ };
100
+ //#endregion
101
+ export { m as createCmsApplicationBuildSnapshots };
@@ -0,0 +1,102 @@
1
+ import { Schema as e } from "effect";
2
+ import { and as t, eq as n, json as r, table as i, text as a } from "@voltro/database";
3
+ import { createHash as o } from "node:crypto";
4
+ import { canonicalJson as s } from "@voltro/runtime";
5
+ //#region src/assetRenditions.ts
6
+ var c = "_voltro_cms_asset_renditions", l = "_voltro_cms_asset_rendition_selections", u = "_voltro_cms_asset_rendition_history";
7
+ i(c, {
8
+ id: a().maxLength(64),
9
+ tenantId: a().maxLength(64),
10
+ site: a().maxLength(64),
11
+ environment: a().maxLength(64),
12
+ versionId: a().maxLength(64),
13
+ requestDigest: a().maxLength(64),
14
+ digest: a().maxLength(64),
15
+ payload: r()
16
+ }).primaryKey(["id"]).index("cms_renditions_by_version", [
17
+ "tenantId",
18
+ "site",
19
+ "environment",
20
+ "versionId"
21
+ ]).nonReactive(), i(l, {
22
+ id: a().maxLength(64),
23
+ tenantId: a().maxLength(64),
24
+ site: a().maxLength(64),
25
+ environment: a().maxLength(64),
26
+ versionId: a().maxLength(64),
27
+ slot: a().maxLength(64),
28
+ revisionId: a().maxLength(64).nullable(),
29
+ renditionId: a().maxLength(64).nullable()
30
+ }).primaryKey(["id"]).nonReactive(), i(u, {
31
+ id: a().maxLength(64),
32
+ tenantId: a().maxLength(64),
33
+ site: a().maxLength(64),
34
+ environment: a().maxLength(64),
35
+ selectionId: a().maxLength(64),
36
+ requestDigest: a().maxLength(64),
37
+ previousRevisionId: a().maxLength(64).nullable(),
38
+ versionId: a().maxLength(64),
39
+ slot: a().maxLength(64),
40
+ renditionId: a().maxLength(64).nullable()
41
+ }).primaryKey(["id"]).index("cms_rendition_history_by_selection", ["selectionId", "id"]).nonReactive();
42
+ var d = class extends e.TaggedError()("AssetRenditionUnavailable", { reason: e.Literals([
43
+ "scope",
44
+ "identity",
45
+ "publication",
46
+ "source",
47
+ "proof",
48
+ "missing",
49
+ "conflict",
50
+ "integrity"
51
+ ]) }) {}, f = (e) => {
52
+ throw new d({ reason: e });
53
+ }, p = (e) => o("sha256").update(s(e)).digest("hex"), m = (e) => typeof e == "string" && e.length > 0 && e.length <= 64 && e.trim() === e, h = (e) => typeof e == "string" && /^[a-f0-9]{64}$/.test(e), g = (e) => {
54
+ let t = {
55
+ tenantId: e.tenantId,
56
+ site: e.site,
57
+ environment: e.environment
58
+ };
59
+ return Object.values(t).every(m) ? t : f("scope");
60
+ }, _ = (e) => t(n("tenantId", e.tenantId), n("site", e.site), n("environment", e.environment)), v = async (e, r, i, a) => (await e.query({
61
+ table: r,
62
+ predicate: t(_(i), n("id", a)),
63
+ lock: "update",
64
+ order: [],
65
+ take: 1,
66
+ skip: void 0,
67
+ projection: void 0
68
+ }))[0], y = (e) => JSON.parse(s(e)), b = (e, t) => {
69
+ let n = e.payload;
70
+ return typeof n != "object" || !n || n.version !== 1 || n.id !== e.id || !h(e.id) || !h(e.requestDigest) || !h(e.digest) || e.digest !== p(n) || n.tenantId !== t.tenantId || n.site !== t.site || n.environment !== t.environment || !n.asset || n.asset.versionId !== e.versionId || !h(n.asset.versionId) || !n.source || !n.output || n.source.id !== n.asset.fileRefId ? f("integrity") : (x(n.source, n.output), y({
71
+ ...n,
72
+ digest: String(e.digest)
73
+ }));
74
+ }, x = (e, t) => {
75
+ let n = t.renditionProof;
76
+ if (e.version !== 1 || t.version !== 1 || e.tenantId !== t.tenantId || e.instance !== t.instance || e.bucket !== t.bucket || e.id === t.id || t.derivedFrom !== e.id || n == null || n.version !== 1 || !n.source || !n.output || n.source.id !== e.id || n.source.metadataDigest !== e.sourceDigest || n.source.size !== e.size || n.source.contentType !== e.contentType || n.output.checksum !== t.checksum || n.output.size !== t.size || n.output.contentType !== t.contentType || h(e.checksum) && e.checksum !== n.source.checksum) return f("proof");
77
+ }, S = async (e, t, n) => {
78
+ let r = g(t);
79
+ if (!h(n)) return f("identity");
80
+ let i = await v(e, c, r, n);
81
+ return i === void 0 ? f("missing") : b(i, r);
82
+ }, C = (e, t, n) => p([
83
+ "cms-asset-rendition-selection/v1",
84
+ e,
85
+ t,
86
+ n
87
+ ]), w = (e, t) => !h(e.versionId) || !m(e.slot) || !h(e.revisionId) || e.id !== C(t, e.versionId, e.slot) || e.renditionId !== null && !h(e.renditionId) ? f("integrity") : {
88
+ id: String(e.id),
89
+ versionId: e.versionId,
90
+ slot: e.slot,
91
+ revisionId: e.revisionId,
92
+ renditionId: e.renditionId
93
+ }, T = async (e, t, n, r) => {
94
+ let i = g(t);
95
+ if (!h(n) || !m(r)) return f("identity");
96
+ let a = await v(e, l, i, C(i, n, r));
97
+ if (a === void 0) return null;
98
+ let o = w(a, i), s = await v(e, u, i, o.revisionId);
99
+ return s === void 0 || s.selectionId !== o.id || s.versionId !== o.versionId || s.slot !== o.slot || s.renditionId !== o.renditionId ? f("integrity") : o;
100
+ };
101
+ //#endregion
102
+ export { c as ASSET_RENDITIONS, u as ASSET_RENDITION_HISTORY, l as ASSET_RENDITION_SELECTIONS, d as AssetRenditionUnavailable, S as readAssetRendition, T as readAssetRenditionSelection };
@@ -0,0 +1,46 @@
1
+ import { Schema as e } from "effect";
2
+ import { createHash as t } from "node:crypto";
3
+ import { canonicalJson as n } from "@voltro/runtime";
4
+ //#region src/assetRevision.ts
5
+ var r = class extends e.TaggedError()("AssetRevisionUnavailable", { reason: e.Literals(["definition", "publication"]) }) {}, i = (e) => {
6
+ throw new r({ reason: e });
7
+ }, a = (e) => t("sha256").update(n(e)).digest("hex"), o = (e) => typeof e == "string" && e.length > 0 && e.length <= 64, s = (e) => typeof e == "string" && /^[a-f0-9]{64}$/.test(e), c = (e) => typeof e != "object" || !e || Array.isArray(e) ? i("definition") : e, l = (e, t, n, r) => {
8
+ let l = t.name, u = c(t.asset), d = c(t.fields), f = u.file;
9
+ if (!o(l) || !o(f) || Object.keys(u).some((e) => e !== "file") || !Object.hasOwn(d, f) || c(d[f]).kind !== "media" || c(d[f]).isOptional === !0 || !s(n)) return i("definition");
10
+ if (!Object.values(e).every(o) || r.tenantId !== e.tenantId || r.site !== e.site || r.environment !== e.environment || r.status !== "published" || ![
11
+ r.id,
12
+ r.documentId,
13
+ r.revisionId,
14
+ r.locale,
15
+ r[f]
16
+ ].every(o) || !Number.isSafeInteger(r.revision) || Number(r.revision) < 1) return i("publication");
17
+ let p = String(r.documentId), m = String(r.locale), h = String(r.revisionId), g = a([
18
+ "cms-asset/v1",
19
+ e.tenantId,
20
+ e.site,
21
+ l,
22
+ p
23
+ ]), _ = Object.fromEntries(Object.keys(d).filter((e) => Object.hasOwn(r, e)).map((e) => [e, r[e]]));
24
+ return {
25
+ version: 1,
26
+ assetId: g,
27
+ versionId: a([
28
+ "cms-asset-version/v1",
29
+ g,
30
+ m,
31
+ h
32
+ ]),
33
+ contentType: l,
34
+ documentId: p,
35
+ variantId: String(r.id),
36
+ revisionId: h,
37
+ revision: Number(r.revision),
38
+ locale: m,
39
+ fileField: f,
40
+ fileRefId: String(r[f]),
41
+ definitionDigest: n,
42
+ metadataDigest: a(_)
43
+ };
44
+ };
45
+ //#endregion
46
+ export { r as AssetRevisionUnavailable, l as pinAssetRevision };
@@ -0,0 +1,72 @@
1
+ import { CMS_AVAILABILITY_TABLE as e, availabilityReason as t } from "./availability.js";
2
+ import { Schema as n } from "effect";
3
+ import { and as r, eq as i } from "@voltro/database";
4
+ //#region src/assetUseRights.ts
5
+ var a = class extends n.TaggedError()("AssetUseRightsUnavailable", { reason: n.Literals(["input", "rights"]) }) {}, o = (e) => {
6
+ throw new a({ reason: e });
7
+ }, s = {
8
+ from: "availableFrom",
9
+ until: "availableUntil",
10
+ blocked: "blocked",
11
+ territories: "territories",
12
+ channels: "channels",
13
+ purposes: "purposes"
14
+ }, c = (e, n, r) => {
15
+ if (!Number.isSafeInteger(r) || !Number.isFinite(new Date(r).getTime())) return o("input");
16
+ if (e.blocked !== void 0 && e.blocked !== null && typeof e.blocked != "boolean") return o("rights");
17
+ for (let t of ["availableFrom", "availableUntil"]) {
18
+ let n = e[t];
19
+ if (n != null && (!(n instanceof Date) && typeof n != "string" || !Number.isFinite(n instanceof Date ? n.getTime() : Date.parse(String(n))))) return o("rights");
20
+ }
21
+ for (let [t, r] of [
22
+ ["territories", n.territory],
23
+ ["channels", n.channel],
24
+ ["purposes", n.purpose]
25
+ ]) {
26
+ let n = e[t];
27
+ if (n != null && (!Array.isArray(n) || !n.every((e) => typeof e == "string") || n.some((e) => e.trim() !== "") && r === null)) return o("rights");
28
+ }
29
+ if (t(e, new Date(r), n) !== null) return o("rights");
30
+ }, l = async (t, n, a, l, u, d, f) => {
31
+ l = structuredClone(l), d = { ...d }, c(l, d, f);
32
+ let p = await t.query({
33
+ table: e,
34
+ lock: "share",
35
+ predicate: r(i("tenantId", n.tenantId), i("site", n.site), i("environment", n.environment), i("contentType", a.contentType), i("documentId", a.documentId)),
36
+ order: [],
37
+ take: 2,
38
+ skip: void 0,
39
+ projection: void 0
40
+ });
41
+ if (p.length > 1 || u && p.length !== 1) return o("rights");
42
+ let m = p[0];
43
+ if (m !== void 0) {
44
+ if (m.tenantId !== n.tenantId || m.site !== n.site || m.environment !== n.environment || m.contentType !== a.contentType || m.documentId !== a.documentId || typeof m.blocked != "boolean" || Object.values(s).some((e) => !Object.hasOwn(m, e))) return o("rights");
45
+ c(m, d, f);
46
+ }
47
+ let h = m === void 0 ? void 0 : Object.fromEntries(Object.values(s).map((e) => [e, structuredClone(m[e])]));
48
+ return (e) => {
49
+ c(l, d, e), h !== void 0 && c(h, d, e);
50
+ };
51
+ }, u = async (e, t, n, r, i, a, o) => {
52
+ await l(e, t, n, r, i, a, o);
53
+ }, d = (e) => typeof e != "object" || !e || Array.isArray(e) ? o("rights") : e, f = (e, t) => Object.keys(e).sort().join(",") === t, p = (e) => typeof e == "string" && e.length > 0 && e.length <= 128 && !/[\x00-\x1f\x7f]/.test(e), m = async (e, t, n, r, i) => {
54
+ let a = d(n), u = d(a.use), m = d(a.captured);
55
+ if (!f(a, "asset,captured,requireRecord,use,version") || a.version !== 1 || typeof a.requireRecord != "boolean" || !f(u, "channel,purpose,territory") || !Object.values(u).every((e) => e === null || p(e) && e.trim() === e) || u.territory !== null && !/^[A-Za-z]{2}$/.test(String(u.territory)) || Object.keys(m).some((e) => !Object.values(s).includes(e))) return o("rights");
56
+ let h = {
57
+ territory: u.territory,
58
+ channel: u.channel,
59
+ purpose: u.purpose
60
+ };
61
+ if (i.territory !== h.territory || i.channel !== h.channel || i.purpose !== h.purpose) return o("rights");
62
+ if (c(m, h, r), a.asset === null) return a.requireRecord || Object.keys(m).length > 0 ? o("rights") : (e) => c({}, h, e);
63
+ let g = d(a.asset);
64
+ return !f(g, "contentType,documentId,versionId") || !p(g.contentType) || !p(g.documentId) || !p(g.versionId) ? o("rights") : l(e, t, {
65
+ contentType: g.contentType,
66
+ documentId: g.documentId
67
+ }, m, a.requireRecord, h, r);
68
+ }, h = async (e, t, n, r, i) => {
69
+ await m(e, t, n, r, i);
70
+ };
71
+ //#endregion
72
+ export { a as AssetUseRightsUnavailable, h as admitCapturedAssetUseRights, u as assertCurrentAssetUseRights, s as assetRightsFields, m as retainCapturedAssetUseRights };
@@ -0,0 +1,31 @@
1
+ //#region src/audiences.ts
2
+ var e = (e) => {
3
+ let { languages: t, countries: n, returning: r } = e.rule;
4
+ if ((t?.length ?? 0) === 0 && (n?.length ?? 0) === 0 && r === void 0) throw Error(`defineAudience('${e.id}'): the rule has no condition, so it would match every reader.`);
5
+ return e;
6
+ }, t = (e, t) => {
7
+ if (e.languages !== void 0 && e.languages.length > 0) {
8
+ let n = (t.languages ?? [])[0]?.toLowerCase();
9
+ if (n === void 0 || !e.languages.some((e) => n === e.toLowerCase() || n.startsWith(`${e.toLowerCase()}-`))) return !1;
10
+ }
11
+ if (e.countries !== void 0 && e.countries.length > 0) {
12
+ let n = t.country?.toUpperCase();
13
+ if (n === void 0 || !e.countries.some((e) => e.toUpperCase() === n)) return !1;
14
+ }
15
+ return e.returning === void 0 || (t.returning ?? !1) === e.returning;
16
+ }, n = (e, n, r) => {
17
+ let i = new Map(n.map((e) => [e.id, e]));
18
+ return e.find((e) => {
19
+ let n = i.get(e.audience);
20
+ return n !== void 0 && t(n.rule, r);
21
+ }) ?? null;
22
+ }, r = (e) => (e ?? "").split(",").map((e, t) => {
23
+ let [n, ...r] = e.trim().split(";"), i = Number(r.find((e) => e.trim().startsWith("q="))?.trim().slice(2) ?? "1");
24
+ return {
25
+ tag: (n ?? "").trim(),
26
+ q: Number.isFinite(i) ? i : 0,
27
+ i: t
28
+ };
29
+ }).filter((e) => e.tag !== "" && e.tag !== "*" && e.q > 0).sort((e, t) => t.q - e.q || e.i - t.i).map((e) => e.tag);
30
+ //#endregion
31
+ export { e as defineAudience, r as languagesOf, t as matchesAudience, n as pickVariant };
@@ -0,0 +1,124 @@
1
+ import { ReferenceUnavailable as e } from "./errors.js";
2
+ import { asTyped as t } from "./effectForm.js";
3
+ import { referencesOf as n } from "./references.js";
4
+ import { and as r, boolean as i, eq as a, gt as o, id as s, inSet as c, json as l, lte as u, table as d, text as f, timestamp as p } from "@voltro/database";
5
+ import { tenant as m } from "@voltro/plugin-multitenancy/mixin";
6
+ //#region src/availability.ts
7
+ var h = "cms_availability", g = d(h, {
8
+ id: s({ prefix: "cavl" }),
9
+ contentType: f().maxLength(64),
10
+ documentId: f().maxLength(64),
11
+ site: f().maxLength(64),
12
+ environment: f().maxLength(64),
13
+ availableUntil: p().nullable(),
14
+ blocked: i().default(!1),
15
+ availableFrom: p().nullable(),
16
+ territories: l().nullable(),
17
+ channels: l().nullable(),
18
+ purposes: l().nullable()
19
+ }).with(m()).index("cms_availability_by_document", [
20
+ "documentId",
21
+ "site",
22
+ "environment"
23
+ ]), _ = (e) => {
24
+ if (!Array.isArray(e)) return null;
25
+ let t = e.filter((e) => typeof e == "string" && e.trim() !== "").map((e) => e.trim());
26
+ return t.length === 0 ? null : t;
27
+ }, v = (e) => {
28
+ if (e instanceof Date) return e;
29
+ if (typeof e == "string" && e !== "") {
30
+ let t = new Date(e);
31
+ return Number.isNaN(t.getTime()) ? null : t;
32
+ }
33
+ return null;
34
+ }, y = (e, t, n = {}) => {
35
+ let r = (e, t, n = !1) => {
36
+ let r = _(e);
37
+ return r === null || t == null || t === "" ? !1 : !r.includes(n ? t.toUpperCase() : t);
38
+ }, i = v(e.availableUntil), a = v(e.availableFrom);
39
+ return e.blocked === !0 ? "blocked" : i !== null && i.getTime() <= t.getTime() ? "expired" : a !== null && a.getTime() > t.getTime() ? "notYet" : r(e.territories, n.territory, !0) ? "territory" : r(e.channels, n.channel) ? "channel" : r(e.purposes, n.purpose) ? "purpose" : null;
40
+ }, b = async (e, t, n, i) => {
41
+ let o = t.availability;
42
+ if (o === void 0) return;
43
+ let s = {
44
+ availableUntil: o.until === void 0 ? null : v(n[o.until]),
45
+ blocked: o.blocked !== void 0 && n[o.blocked] === !0,
46
+ availableFrom: o.from === void 0 ? null : v(n[o.from]),
47
+ territories: o.territories === void 0 ? null : _(n[o.territories])?.map((e) => e.toUpperCase()) ?? null,
48
+ channels: o.channels === void 0 ? null : _(n[o.channels]),
49
+ purposes: o.purposes === void 0 ? null : _(n[o.purposes])
50
+ }, [c] = await e.query({
51
+ table: h,
52
+ predicate: r(a("contentType", t.name), a("documentId", n.documentId), a("site", i.site), a("environment", i.environment)),
53
+ order: [],
54
+ take: 1,
55
+ skip: void 0,
56
+ projection: void 0
57
+ });
58
+ if (c !== void 0) {
59
+ await e.update(h, c.id, s);
60
+ return;
61
+ }
62
+ let l = n.tenantId;
63
+ await e.insert(h, {
64
+ contentType: t.name,
65
+ documentId: n.documentId,
66
+ site: i.site,
67
+ environment: i.environment,
68
+ ...s,
69
+ ...l == null ? {} : { tenantId: l }
70
+ });
71
+ }, x = async (e, t, n, i = /* @__PURE__ */ new Date(), o = {}) => {
72
+ let s = /* @__PURE__ */ new Map(), l = [...new Set(t)];
73
+ if (l.length === 0) return s;
74
+ let u = await e.query({
75
+ table: h,
76
+ predicate: r(c("documentId", l), a("site", n.site), a("environment", n.environment)),
77
+ order: [],
78
+ take: void 0,
79
+ skip: void 0,
80
+ projection: void 0
81
+ });
82
+ for (let e of u) {
83
+ let t = e.documentId, n = y(e, i, o);
84
+ n !== null && s.set(t, n);
85
+ }
86
+ return s;
87
+ }, S = async (e, t, n, i = /* @__PURE__ */ new Date()) => {
88
+ let s = new Date(i.getTime() + n * 864e5);
89
+ return (await e.query({
90
+ table: h,
91
+ predicate: r(a("site", t.site), a("environment", t.environment), a("blocked", !1), o("availableUntil", i), u("availableUntil", s)),
92
+ order: [{
93
+ column: "availableUntil",
94
+ direction: "asc"
95
+ }],
96
+ take: 500,
97
+ skip: void 0,
98
+ projection: void 0
99
+ })).flatMap((e) => {
100
+ let t = v(e.availableUntil);
101
+ return t === null ? [] : [{
102
+ contentType: String(e.contentType),
103
+ documentId: String(e.documentId),
104
+ until: t,
105
+ days: Math.ceil((t.getTime() - i.getTime()) / 864e5)
106
+ }];
107
+ });
108
+ }, C = async (t, r, i, a, o, s = /* @__PURE__ */ new Date()) => {
109
+ let c = n(r, a);
110
+ if (c.length === 0) return;
111
+ let l = await x(t, c.map((e) => e.targetDocumentId), o, s);
112
+ if (l.size !== 0) throw new e({
113
+ contentType: r.name,
114
+ id: i,
115
+ targets: c.filter((e) => l.has(e.targetDocumentId)).map((e) => ({
116
+ path: e.path,
117
+ contentType: e.targetType,
118
+ documentId: e.targetDocumentId,
119
+ reason: l.get(e.targetDocumentId)
120
+ }))
121
+ });
122
+ }, w = [e], T = (...e) => t(() => S(...e)), E = (...e) => t(() => C(...e), ...w), D = (...e) => t(() => x(...e), ...w), O = (...e) => t(() => b(...e), ...w);
123
+ //#endregion
124
+ export { h as CMS_AVAILABILITY_TABLE, C as assertReferencesAvailable, E as assertReferencesAvailableEffect, y as availabilityReason, g as cmsAvailabilityTable, S as expiringAmong, T as expiringAmongEffect, x as unavailableAmong, D as unavailableAmongEffect, b as writeAvailability, O as writeAvailabilityEffect };
@@ -0,0 +1,166 @@
1
+ import { ChangeFeedUnavailable as e, ContentIdConflict as t, ContentNotFound as n, ContentValidationFailed as r, ReferenceUnavailable as i, ReviewRequired as a, RevisionMismatch as o } from "./errors.js";
2
+ import { templateValues as s } from "./templates.js";
3
+ import { asTyped as c } from "./effectForm.js";
4
+ import { applyDerivations as l } from "./validation.js";
5
+ import { teamProblems as u } from "./team.js";
6
+ import { reviewRequiredFor as d } from "./review.js";
7
+ import { publish as f, saveDraft as p } from "./write.js";
8
+ import { and as m, eq as h } from "@voltro/database";
9
+ //#region src/blueprint.ts
10
+ var g = class extends Error {
11
+ reason;
12
+ _tag = "BlueprintInvalid";
13
+ constructor(e) {
14
+ super(`blueprint not usable: ${e}`), this.reason = e;
15
+ }
16
+ }, _ = "$entry", v = (e) => ({ [_]: e }), y = (e) => {
17
+ if (typeof e != "object" || !e || Array.isArray(e)) return;
18
+ let t = Object.keys(e), n = e[_];
19
+ return t.length === 1 && typeof n == "string" ? n : void 0;
20
+ }, b = (e, t) => {
21
+ let n = y(e);
22
+ if (n !== void 0) t.add(n);
23
+ else if (Array.isArray(e)) for (let n of e) b(n, t);
24
+ else if (typeof e == "object" && e) for (let n of Object.values(e)) b(n, t);
25
+ return t;
26
+ }, x = (e, t) => {
27
+ let n = y(e);
28
+ return n === void 0 ? Array.isArray(e) ? e.map((e) => x(e, t)) : typeof e == "object" && e ? Object.fromEntries(Object.entries(e).map(([e, n]) => [e, x(n, t)])) : e : t.get(n);
29
+ }, S = (e) => {
30
+ let t = e.team === void 0 ? [] : u(e.team);
31
+ if (t.length > 0) throw new g(t.join("; "));
32
+ let n = /* @__PURE__ */ new Map();
33
+ for (let t of e.entries) {
34
+ if (n.has(t.key)) throw new g(`the key '${t.key}' is used twice`);
35
+ n.set(t.key, t);
36
+ }
37
+ let r = new Map(e.entries.map((e) => [e.key, b([e.values, e.translations ?? {}], /* @__PURE__ */ new Set())]));
38
+ for (let [e, t] of r) for (let r of t) if (!n.has(r)) throw new g(`'${e}' references '${r}', which is no entry`);
39
+ let i = [], a = /* @__PURE__ */ new Map(), o = (e, t) => {
40
+ if (a.get(e) !== "done") {
41
+ if (a.get(e) === "visiting") throw new g(`the entries reference each other in a circle: ${[...t, e].join(" → ")}`);
42
+ a.set(e, "visiting");
43
+ for (let n of r.get(e) ?? []) o(n, [...t, e]);
44
+ a.set(e, "done"), i.push(n.get(e));
45
+ }
46
+ };
47
+ for (let t of e.entries) o(t.key, []);
48
+ return {
49
+ ...e,
50
+ entries: i
51
+ };
52
+ }, C = (e, t) => {
53
+ let n = e.find((e) => e.name === t.type);
54
+ if (n === void 0) throw new g(`'${t.key}' is of type '${t.type}', which this app does not have`);
55
+ if (t.match !== void 0 && n.fields[t.match] === void 0) throw new g(`'${t.key}' matches on '${t.match}', which ${n.name} does not have`);
56
+ return n;
57
+ }, w = (e, t, n, r) => {
58
+ let i = {};
59
+ if (t.template !== void 0) {
60
+ let n = s(e, t.template);
61
+ if (n === null) throw new g(`'${t.key}' is built from the template '${t.template}', which ${e.name} does not have`);
62
+ i = n;
63
+ }
64
+ let a = n === r ? {} : t.translations?.[n] ?? {};
65
+ return {
66
+ ...i,
67
+ ...t.values,
68
+ ...a
69
+ };
70
+ }, T = (e, t) => {
71
+ if (typeof t.title == "string" && t.title !== "") return t.title;
72
+ let n = e.match === void 0 ? void 0 : t[e.match];
73
+ return typeof n == "string" && n !== "" ? n : e.key;
74
+ }, E = (e, t, n, r) => e.query({
75
+ table: `${t.name}_drafts`,
76
+ predicate: m(h("site", n.site), h("environment", n.environment), h("locale", n.locale), ...r === null ? [] : [r]),
77
+ order: [{
78
+ column: "id",
79
+ direction: "asc"
80
+ }],
81
+ take: 1,
82
+ skip: void 0,
83
+ projection: void 0
84
+ }), D = async (e, t, n, r, i, a) => {
85
+ if (a !== null) {
86
+ let [n] = await E(e, t, r, h("documentId", a));
87
+ if (n !== void 0) return n;
88
+ }
89
+ let o = n.match === void 0 ? void 0 : i[n.match];
90
+ if (n.match !== void 0 && (o == null || o === "")) return null;
91
+ let [s] = await E(e, t, r, n.match === void 0 ? null : h(n.match, o));
92
+ return s ?? null;
93
+ }, O = (e, t) => [e.locale, ...Object.keys(t.translations ?? {}).filter((t) => t !== e.locale)], k = async (e, t, n, r, i) => {
94
+ let a = /* @__PURE__ */ new Map(), o = [], s = 0;
95
+ for (let c of n.entries) {
96
+ let u = C(t, c), m = null, h = !1, g = !1;
97
+ for (let t of O(n, c)) {
98
+ if (g) break;
99
+ let _ = {
100
+ site: r.site,
101
+ environment: r.environment,
102
+ locale: t
103
+ }, v = w(u, c, t, n.locale), y = l(u, x(v, a)), b = await D(e, u, c, _, y, m);
104
+ if (b !== null) {
105
+ g = t === n.locale, m ??= String(b.documentId), o.push({
106
+ key: c.key,
107
+ type: u.name,
108
+ locale: t,
109
+ label: T(c, b),
110
+ action: "present",
111
+ documentId: String(b.documentId),
112
+ variantId: String(b.id),
113
+ outcome: null
114
+ });
115
+ continue;
116
+ }
117
+ let S = T(c, y);
118
+ m === null && !h && s++, h = !0;
119
+ let C = c.publish === !1 ? "draft" : u.review?.required === !0 || u.review?.required === "workspace" && (n.team?.reviewRequired ?? []).includes(u.name) ? "review" : "live";
120
+ if (!i) {
121
+ let e = C;
122
+ o.push({
123
+ key: c.key,
124
+ type: u.name,
125
+ locale: t,
126
+ label: S,
127
+ action: "create",
128
+ documentId: m,
129
+ variantId: null,
130
+ outcome: e
131
+ });
132
+ continue;
133
+ }
134
+ let E = await p(e, u, {
135
+ ...y,
136
+ ...m === null ? {} : { documentId: m }
137
+ }, _), O = C === "live" && await d(e, u, String(E.id)) ? "review" : C;
138
+ O === "live" && await f(e, u, String(E.id), _), m ??= String(E.documentId), o.push({
139
+ key: c.key,
140
+ type: u.name,
141
+ locale: t,
142
+ label: S,
143
+ action: "create",
144
+ documentId: String(E.documentId),
145
+ variantId: String(E.id),
146
+ outcome: O
147
+ });
148
+ }
149
+ m !== null && a.set(c.key, m);
150
+ }
151
+ return {
152
+ blueprint: n.id,
153
+ steps: o,
154
+ documents: s
155
+ };
156
+ }, A = (e, t, n, r) => k(e, t, n, r, !1), j = (e, t, n, r) => k(e, t, n, r, !0), M = [
157
+ g,
158
+ t,
159
+ n,
160
+ r,
161
+ i,
162
+ a,
163
+ o
164
+ ], N = (...t) => c(() => j(...t), ...M, e), P = (...e) => c(() => A(...e), ...M);
165
+ //#endregion
166
+ export { g as BlueprintInvalid, j as applyBlueprint, N as applyBlueprintEffect, v as blueprintRef, S as defineBlueprint, A as planBlueprint, P as planBlueprintEffect };