@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,68 @@
1
+ //#region src/presenceAnchors.ts
2
+ var e = /^[A-Za-z0-9_.:/-]{1,120}$/, t = (t) => typeof t == "string" && e.test(t), n = (e) => Number.isInteger(e) && e >= 0 && e <= 1e6, r = (e) => typeof e == "number" && Number.isFinite(e) && e >= 0 && e <= 1, i = (e) => {
3
+ if (typeof e != "object" || !e) return null;
4
+ let i = e;
5
+ switch (i.kind) {
6
+ case "view": return t(i.view) ? {
7
+ kind: "view",
8
+ view: i.view
9
+ } : null;
10
+ case "field": return t(i.field) ? {
11
+ kind: "field",
12
+ field: i.field
13
+ } : null;
14
+ case "component": return t(i.field) && t(i.instanceId) && t(i.componentId) ? {
15
+ kind: "component",
16
+ field: i.field,
17
+ instanceId: i.instanceId,
18
+ componentId: i.componentId
19
+ } : null;
20
+ case "slot": return t(i.field) && t(i.instanceId) && t(i.componentId) && t(i.prop) ? {
21
+ kind: "slot",
22
+ field: i.field,
23
+ instanceId: i.instanceId,
24
+ componentId: i.componentId,
25
+ prop: i.prop
26
+ } : null;
27
+ case "selection": return t(i.field) && n(i.start) && n(i.end) && i.end >= i.start ? {
28
+ kind: "selection",
29
+ field: i.field,
30
+ start: i.start,
31
+ end: i.end
32
+ } : null;
33
+ case "assetRegion": return r(i.x) && r(i.y) && r(i.width) && r(i.height) && i.x + i.width <= 1 && i.y + i.height <= 1 ? {
34
+ kind: "assetRegion",
35
+ x: i.x,
36
+ y: i.y,
37
+ width: i.width,
38
+ height: i.height
39
+ } : null;
40
+ default: return null;
41
+ }
42
+ }, a = (e) => {
43
+ let t = e;
44
+ if (typeof t != "object" || !t || typeof t.closest != "function") return null;
45
+ let n = t.closest("[data-cms-field]"), r = t.closest("[data-cms-instance]");
46
+ if (r != null) {
47
+ let e = r.parentElement?.closest?.("[data-cms-field]") ?? null, t = e?.getAttribute("data-cms-field") ?? null, a = r.getAttribute("data-cms-instance"), o = r.getAttribute("data-cms-component"), s = n != null && n !== e ? n.getAttribute("data-cms-field") : null;
48
+ if (t !== null && a !== null && o !== null) return i(s === null ? {
49
+ kind: "component",
50
+ field: t,
51
+ instanceId: a,
52
+ componentId: o
53
+ } : {
54
+ kind: "slot",
55
+ field: t,
56
+ instanceId: a,
57
+ componentId: o,
58
+ prop: s
59
+ });
60
+ }
61
+ let a = n?.getAttribute("data-cms-field") ?? null;
62
+ return a === null ? null : i({
63
+ kind: "field",
64
+ field: a
65
+ });
66
+ };
67
+ //#endregion
68
+ export { i as parsePresenceAnchor, a as presenceAnchorOf };
@@ -0,0 +1,31 @@
1
+ import { createHmac as e, timingSafeEqual as t } from "node:crypto";
2
+ //#region src/preview.ts
3
+ var n = 3600, r = (e) => (Buffer.isBuffer(e) ? e : Buffer.from(e, "utf8")).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""), i = (e) => Buffer.from(e.replace(/-/g, "+").replace(/_/g, "/"), "base64"), a = (e) => e ?? process.env.VOLTRO_SESSION_SECRET ?? null, o = (t, i, o = {}) => {
4
+ let s = a(o.secret);
5
+ if (s === null) throw Error("cms previewToken requires a signing secret — set VOLTRO_SESSION_SECRET or pass { secret }. Refusing to sign with a hardcoded default (it would ship in the bundle and be forgeable).");
6
+ let c = {
7
+ t,
8
+ i,
9
+ exp: Math.floor(Date.now() / 1e3) + (o.ttlSeconds ?? n)
10
+ }, l = r(JSON.stringify(c));
11
+ return `${l}.${r(e("sha256", s).update(l).digest())}`;
12
+ }, s = (n, r = {}) => {
13
+ if (!n) return null;
14
+ let o = a(r.secret);
15
+ if (o === null) return null;
16
+ let s = n.indexOf(".");
17
+ if (s <= 0 || s === n.length - 1) return null;
18
+ let c = n.slice(0, s), l = n.slice(s + 1), u = e("sha256", o).update(c).digest(), d = i(l);
19
+ if (d.length !== u.length || !t(d, u)) return null;
20
+ try {
21
+ let e = JSON.parse(i(c).toString("utf8"));
22
+ return typeof e.t != "string" || typeof e.i != "string" || typeof e.exp != "number" || e.exp < Math.floor(Date.now() / 1e3) ? null : {
23
+ type: e.t,
24
+ id: e.i
25
+ };
26
+ } catch {
27
+ return null;
28
+ }
29
+ };
30
+ //#endregion
31
+ export { o as previewToken, s as verifyPreviewToken };
@@ -0,0 +1,76 @@
1
+ import { Effect as e } from "effect";
2
+ import { defineAction as t } from "@voltro/protocol";
3
+ import { RestRouteError as n, projectedFailure as r, publicApiRoute as i, restError as a, restRoutesToHttpRoutes as o } from "@voltro/protocol/rest";
4
+ //#region src/privateCmsTransport.ts
5
+ var s = {
6
+ "cache-control": "private, no-store",
7
+ pragma: "no-cache",
8
+ vary: "Authorization"
9
+ }, c = (e) => {
10
+ let t = e.headers.authorization;
11
+ return typeof t != "string" || t.length > 520 ? null : /^Bearer ([^\s]+)$/i.exec(t)?.[1] ?? null;
12
+ }, l = (e, t) => c(e) ?? (() => {
13
+ throw a(401, {
14
+ error: t,
15
+ _tag: t,
16
+ reason: "credential"
17
+ }, {
18
+ ...s,
19
+ "www-authenticate": "Bearer"
20
+ });
21
+ })(), u = (e) => c(e) === null ? {
22
+ status: 401,
23
+ message: "CMS credential required"
24
+ } : void 0, d = async (t, i, o) => {
25
+ let c = await e.runPromise(e.result(t));
26
+ if (c._tag === "Success") return c.success;
27
+ let l = c.failure;
28
+ if (typeof l == "object" && l && "_tag" in l && l._tag === i && "reason" in l && l.reason === "credential") {
29
+ let e = r(l, o, { errorStatus: { [i]: 401 } });
30
+ throw e instanceof n ? a(e.status, e.body, {
31
+ ...s,
32
+ "www-authenticate": "Bearer"
33
+ }) : e;
34
+ }
35
+ throw l;
36
+ }, f = (e, n, r, a, o, s, c) => {
37
+ let l = `${e.namespace}.${n}`, f = t({
38
+ name: l,
39
+ input: o,
40
+ output: s,
41
+ error: e.error,
42
+ openAccess: "Dedicated credential exchange: the header guard and server-bound CMS service verify authority; no ambient Subject grants access.",
43
+ publicApi: {
44
+ method: "POST",
45
+ path: `${e.path}/${n}`,
46
+ security: "required",
47
+ idempotent: !1,
48
+ operationId: `${e.operationPrefix}${n[0].toUpperCase()}${n.slice(1)}`,
49
+ tags: [...e.tags],
50
+ errorStatus: e.errorStatus,
51
+ ...Object.hasOwn(e.errorStatus, e.credentialError) ? { additionalErrorStatuses: { [e.credentialError]: [401] } } : {},
52
+ summary: r,
53
+ description: a
54
+ }
55
+ }), p = i(f, (t, n) => d(c(t, n), e.credentialError, f));
56
+ return {
57
+ ...p,
58
+ guards: [...p.guards ?? [], u],
59
+ maxBodyBytes: 16384
60
+ };
61
+ }, p = (e) => o(e).map((e) => ({
62
+ ...e,
63
+ handle: async (...t) => {
64
+ let n = await e.handle(...t);
65
+ return {
66
+ ...n,
67
+ headers: {
68
+ ...n.headers,
69
+ ...s,
70
+ ...n.status === 401 ? { "www-authenticate": "Bearer" } : {}
71
+ }
72
+ };
73
+ }
74
+ }));
75
+ //#endregion
76
+ export { l as cmsCredential, s as privateCmsHeaders, p as privateCmsHttpRoutes, f as privateCmsOperation };
@@ -0,0 +1,10 @@
1
+ import { snapshotRouteDispatch as e } from "./snapshotRouting.js";
2
+ //#region src/privateNativeRouteReservation.ts
3
+ var t = (t, n, r) => {
4
+ let i = e(t, n, r);
5
+ if (i?.owner !== "code") return !1;
6
+ let a = t.definition?.claims[i.code.file];
7
+ return a?.kind !== "code" || a.public !== !0;
8
+ };
9
+ //#endregion
10
+ export { t as isPrivateNativeRouteReservation };
@@ -0,0 +1,116 @@
1
+ import { PublicRouteRegistryUnavailable as e } from "./publicRouteRegistry.js";
2
+ import { ChangeFeedUnavailable as t, ContentIdConflict as n, ContentNotFound as r, ContentValidationFailed as i, ReferenceUnavailable as a, ReleaseNotEditable as o, ReviewRequired as s, RevisionMismatch as c } from "./errors.js";
3
+ import { asTyped as l } from "./effectForm.js";
4
+ import { pickDeclared as u } from "./contentValues.js";
5
+ import { withPublicRouteStateMutation as d } from "./publicRouteMutation.js";
6
+ import { saveDraft as f } from "./write.js";
7
+ import { addToRelease as p, createRelease as m, publishRelease as h } from "./release.js";
8
+ import { lockEnvironmentPairForPublication as g } from "./environments.js";
9
+ import { and as _, eq as v, neq as y } from "@voltro/database";
10
+ //#region src/promotion.ts
11
+ var b = (e, t, n, r, i = []) => e.query({
12
+ table: t,
13
+ predicate: _(v("site", n), v("environment", r), y("status", "archived"), ...i),
14
+ order: [{
15
+ column: "id",
16
+ direction: "asc"
17
+ }],
18
+ take: void 0,
19
+ skip: void 0,
20
+ projection: void 0
21
+ }), x = (e) => JSON.stringify(e, (e, t) => typeof t == "object" && t && !Array.isArray(t) && !(t instanceof Date) ? Object.fromEntries(Object.entries(t).sort(([e], [t]) => e < t ? -1 : 1)) : t), S = (e) => {
22
+ for (let t of [
23
+ "title",
24
+ "name",
25
+ "slug"
26
+ ]) if (typeof e[t] == "string" && e[t] !== "") return e[t];
27
+ return String(e.documentId);
28
+ }, C = (e) => `${String(e.documentId)}\u0000${String(e.locale)}`, w = async (e, t, n) => {
29
+ let r = [];
30
+ for (let i of t) {
31
+ let t = await b(e, `${i.name}_published`, n.site, n.from);
32
+ if (t.length === 0) continue;
33
+ let a = new Map((await b(e, `${i.name}_published`, n.site, n.to)).map((e) => [C(e), e])), o = new Map((await b(e, `${i.name}_drafts`, n.site, n.to)).map((e) => [C(e), e]));
34
+ for (let e of t) {
35
+ let t = a.get(C(e)), n = o.get(C(e)), s = {
36
+ contentType: i.name,
37
+ documentId: String(e.documentId),
38
+ locale: String(e.locale),
39
+ title: S(e)
40
+ };
41
+ n !== void 0 && n.status === "draft" ? r.push({
42
+ ...s,
43
+ change: "blocked"
44
+ }) : t === void 0 ? r.push({
45
+ ...s,
46
+ change: "new"
47
+ }) : x(u(i, e)) !== x(u(i, t)) && r.push({
48
+ ...s,
49
+ change: "changed"
50
+ });
51
+ }
52
+ }
53
+ return r;
54
+ }, T = async (e, n, r, i, a) => {
55
+ if (i.length === 0) return {
56
+ ok: !1,
57
+ reason: "nothingSelected",
58
+ items: []
59
+ };
60
+ let o = await g(e, n, r), s = await w(e, n, r), c = new Map(s.map((e) => [`${e.contentType}\u0000${e.documentId}\u0000${e.locale}`, e])), l = i.filter((e) => !c.has(`${e.contentType}\u0000${e.documentId}\u0000${e.locale}`));
61
+ if (l.length > 0) return {
62
+ ok: !1,
63
+ reason: "notInPlan",
64
+ items: l
65
+ };
66
+ let _ = i.filter((e) => c.get(`${e.contentType}\u0000${e.documentId}\u0000${e.locale}`).change === "blocked");
67
+ if (_.length > 0) return {
68
+ ok: !1,
69
+ reason: "blocked",
70
+ items: _
71
+ };
72
+ let y = new Map(n.map((e) => [e.name, e]));
73
+ return d(e, async () => {
74
+ let s = await m(e, {
75
+ name: a.name,
76
+ site: r.site,
77
+ environment: r.to
78
+ }), c = String(s.id);
79
+ for (let n of i) {
80
+ let i = y.get(n.contentType), [a] = await b(e, `${i.name}_published`, r.site, r.from, [v("documentId", n.documentId), v("locale", n.locale)]), s = {
81
+ site: r.site,
82
+ environment: r.to,
83
+ locale: n.locale
84
+ }, [l] = await b(e, `${i.name}_drafts`, r.site, r.to, [v("documentId", n.documentId), v("locale", n.locale)]);
85
+ if (o === null || a === void 0 || a.tenantId !== o.tenantId) throw new t({ reason: "scope" });
86
+ let d = u(i, a), m = await f(e, i, l === void 0 ? {
87
+ ...d,
88
+ documentId: n.documentId
89
+ } : {
90
+ ...d,
91
+ id: l.id
92
+ }, s);
93
+ await p(e, c, {
94
+ type: i,
95
+ id: String(m.id),
96
+ locale: n.locale,
97
+ revisionId: String(m.revisionId)
98
+ });
99
+ }
100
+ return await h(e, n, c), {
101
+ ok: !0,
102
+ releaseId: c,
103
+ promoted: i.length
104
+ };
105
+ });
106
+ }, E = [
107
+ i,
108
+ n,
109
+ r,
110
+ c,
111
+ o,
112
+ s,
113
+ a
114
+ ], D = (...e) => l(() => w(...e), ...E), O = (...n) => l(() => T(...n), ...E, t, e);
115
+ //#endregion
116
+ export { w as planPromotion, D as planPromotionEffect, T as promote, O as promoteEffect };
@@ -0,0 +1,90 @@
1
+ import { encodeCanonicalPathSegment as e } from "./pathSegmentEncoding.js";
2
+ //#region src/publicBuild.ts
3
+ var t = class extends Error {
4
+ reason;
5
+ _tag = "CmsPublicBuildUnavailable";
6
+ constructor(e) {
7
+ super("Public build unavailable: " + e), this.reason = e;
8
+ }
9
+ }, n = (e) => {
10
+ throw new t(e);
11
+ }, r = (e) => typeof e == "string" && /^[a-f0-9]{64}$/.test(e), i = (e) => {
12
+ if (typeof e != "object" || !e || Array.isArray(e)) return n("identity");
13
+ let t = e;
14
+ return Object.keys(t).sort().join(",") !== "executionId,inputsId,snapshotDigest,version" || t.version !== 1 || !r(t.snapshotDigest) || !r(t.inputsId) || !r(t.executionId) ? n("identity") : {
15
+ version: 1,
16
+ snapshotDigest: t.snapshotDigest,
17
+ inputsId: t.inputsId,
18
+ executionId: t.executionId
19
+ };
20
+ }, a = (e) => {
21
+ let t = i(e);
22
+ return [
23
+ "1",
24
+ t.snapshotDigest,
25
+ t.inputsId,
26
+ t.executionId
27
+ ].join(".");
28
+ }, o = (e) => {
29
+ if (typeof e != "string" || !/^1\.[a-f0-9]{64}\.[a-f0-9]{64}\.[a-f0-9]{64}$/.test(e)) return n("identity");
30
+ let [, t, r, a] = e.split(".");
31
+ return i({
32
+ version: 1,
33
+ snapshotDigest: t,
34
+ inputsId: r,
35
+ executionId: a
36
+ });
37
+ }, s = (e = globalThis.document) => {
38
+ if (e === void 0) return null;
39
+ let t = e.querySelectorAll("meta[name=\"voltro:cms-build\"]");
40
+ return t.length === 0 ? null : t.length === 1 ? o(t[0].getAttribute("content") ?? "") : n("identity");
41
+ }, c = (e) => `<meta name="voltro:cms-build" content="${a(e)}" />`, l = (t) => {
42
+ if (typeof t != "string" || t.length > 4096 || !t.startsWith("/") || t.startsWith("//") || /[\\?#\x00-\x20\x7f]/.test(t) || t.slice(1).includes("//")) return n("request");
43
+ try {
44
+ if (new URL(t, "https://captured.invalid").pathname !== t) return n("request");
45
+ let r = t.split("/").map((t) => {
46
+ let r = decodeURIComponent(t).normalize("NFC");
47
+ return /[\\/\x00-\x1f\x7f]/.test(r) || r === "." || r === ".." ? n("request") : e(r);
48
+ }).join("/").replace(/\/$/, "") || "/";
49
+ return r.length > 4096 ? n("request") : r;
50
+ } catch {
51
+ return n("request");
52
+ }
53
+ }, u = async (e, t, r = {}) => {
54
+ let o = i(e), s = l(t), c = new URLSearchParams({
55
+ build: a(o),
56
+ path: s
57
+ }), u;
58
+ try {
59
+ u = await (r.fetch ?? globalThis.fetch)("/v1/cms/public-build/page?" + c, {
60
+ method: "GET",
61
+ credentials: "same-origin",
62
+ cache: "no-store",
63
+ redirect: "error",
64
+ ...r.signal === void 0 ? {} : { signal: r.signal }
65
+ });
66
+ } catch (e) {
67
+ if (r.signal?.aborted) throw e;
68
+ return n("transport");
69
+ }
70
+ if (u.status === 409) return n("changed");
71
+ if (u.status === 404) return n("not-found");
72
+ if (u.status === 403 || u.status === 410) return n("denied");
73
+ if (!u.ok || u.headers.get("content-type")?.split(";", 1)[0] !== "application/json") return n("transport");
74
+ let d;
75
+ try {
76
+ d = await u.json();
77
+ } catch {
78
+ return n("transport");
79
+ }
80
+ if (typeof d != "object" || !d || Array.isArray(d)) return n("request");
81
+ let f = d;
82
+ return Object.keys(f).sort().join(",") !== "build,page,path,version" || f.version !== 1 || f.path !== s || a(i(f.build)) !== a(o) ? n("changed") : {
83
+ version: 1,
84
+ build: o,
85
+ path: s,
86
+ page: f.page
87
+ };
88
+ };
89
+ //#endregion
90
+ export { t as CmsPublicBuildUnavailable, l as canonicalCmsPublicPath, c as cmsPublicBuildMeta, i as copyCmsPublicBuildIdentity, o as decodeCmsPublicBuildIdentity, a as encodeCmsPublicBuildIdentity, u as loadCmsPublicBuildPage, s as readCmsPublicBuildIdentity };
@@ -0,0 +1,98 @@
1
+ import { CmsPublicBuildUnavailable as e, decodeCmsPublicBuildIdentity as t } from "./publicBuild.js";
2
+ import { Effect as n, Schema as r } from "effect";
3
+ import { defineQuery as i } from "@voltro/protocol";
4
+ import { RestRouteError as a, projectedFailure as o, publicApiRoute as s, restError as c, restRoutesToHttpRoutes as l } from "@voltro/protocol/rest";
5
+ //#region src/publicBuildRest.ts
6
+ var u = {
7
+ "cache-control": "private, no-store",
8
+ pragma: "no-cache",
9
+ vary: "Cookie"
10
+ }, d = r.Struct({
11
+ version: r.Literal(1),
12
+ snapshotDigest: r.String,
13
+ inputsId: r.String,
14
+ executionId: r.String
15
+ }), f = r.Struct({
16
+ build: r.String,
17
+ path: r.String
18
+ }), p = {
19
+ identity: 400,
20
+ request: 400,
21
+ changed: 409,
22
+ "not-found": 404,
23
+ denied: 410,
24
+ transport: 503
25
+ }, m = i({
26
+ name: "cms.publicBuildPage",
27
+ input: f,
28
+ output: r.Struct({
29
+ version: r.Literal(1),
30
+ build: d,
31
+ path: r.String,
32
+ page: r.Unknown
33
+ }),
34
+ error: r.Struct({
35
+ _tag: r.Literal("CmsPublicBuildUnavailable"),
36
+ reason: r.Literals([
37
+ "identity",
38
+ "request",
39
+ "changed",
40
+ "not-found",
41
+ "denied",
42
+ "transport"
43
+ ])
44
+ }),
45
+ openAccess: "Anonymous presentation from the current independently admitted public output marker. Private read credentials never grant this endpoint.",
46
+ publicApi: {
47
+ method: "GET",
48
+ path: "/v1/cms/public-build/page",
49
+ security: !1,
50
+ idempotent: !1,
51
+ operationId: "cmsPublicBuildPage",
52
+ tags: ["CMS public builds"],
53
+ errorStatus: { CmsPublicBuildUnavailable: 409 },
54
+ additionalErrorStatuses: { CmsPublicBuildUnavailable: [...new Set(Object.values(p))].filter((e) => e !== 409) },
55
+ summary: "Read a current captured public page presentation",
56
+ description: "Exact public build selector, admitted request host and canonical path. Active generation, region, output membership, current rights and monotone denies are checked. No live fallback; private no-store including errors."
57
+ }
58
+ }), h = (t) => {
59
+ let n = o(new e(t), m, { errorStatus: { CmsPublicBuildUnavailable: p[t] } });
60
+ throw n instanceof a ? c(n.status, n.body, u) : n;
61
+ }, g = (e, r) => {
62
+ let i = [s(m, async (i, a) => {
63
+ let o = i;
64
+ [...new URLSearchParams(a.query).keys()].sort().join(",") !== "build,path" && h("request");
65
+ let s = (() => {
66
+ try {
67
+ return t(o.build);
68
+ } catch {
69
+ return h("identity");
70
+ }
71
+ })(), c = r.choices?.(a.headers), l = await n.runPromise(n.result(e.page({
72
+ build: s,
73
+ path: o.path,
74
+ host: r.host(a.headers),
75
+ ...c === void 0 ? {} : { choices: c }
76
+ })));
77
+ if (l._tag === "Success") return l.success;
78
+ h(l.failure.reason);
79
+ })];
80
+ return {
81
+ routes: i,
82
+ httpRoutes: l(i).map((e) => ({
83
+ ...e,
84
+ handle: async (...t) => {
85
+ let n = await e.handle(...t);
86
+ return {
87
+ ...n,
88
+ headers: {
89
+ ...n.headers,
90
+ ...u
91
+ }
92
+ };
93
+ }
94
+ }))
95
+ };
96
+ };
97
+ //#endregion
98
+ export { g as cmsPublicBuildRest };
@@ -0,0 +1,63 @@
1
+ import { normalizeHost as e } from "./domainHost.js";
2
+ import { OutputActivationUnavailable as t } from "./outputActivation.js";
3
+ import { CmsPublicBuildUnavailable as n, canonicalCmsPublicPath as r, copyCmsPublicBuildIdentity as i, encodeCmsPublicBuildIdentity as a } from "./publicBuild.js";
4
+ import { readActiveOutput as o } from "./outputActivationStore.js";
5
+ import { copyPublicConsentChoices as s, selectPublicPresentation as c } from "./publicPresentation.js";
6
+ import { Effect as l } from "effect";
7
+ //#region src/publicBuildService.ts
8
+ var u = (u) => {
9
+ let d = { ...u.scope }, f = u.keys.map((e) => ({
10
+ id: e.id,
11
+ material: new Uint8Array(e.material)
12
+ })), p = Object.fromEntries(Object.entries(u.regionKeys).map(([e, t]) => [e, t.map((e) => ({
13
+ id: e.id,
14
+ material: new Uint8Array(e.material)
15
+ }))])), m = u.region, h = u.admit, g = u.readPage, _ = u.store;
16
+ return { page: (v) => l.tryPromise({
17
+ try: async () => {
18
+ let t = i(v.build), l = e(v.host), y = r(v.path), b = s(v.choices);
19
+ if (l !== v.host) throw new n("request");
20
+ return _.transactional(async (e) => {
21
+ let r;
22
+ if (await o(e, d, {
23
+ kind: "url",
24
+ url: "https://" + l + y
25
+ }, {
26
+ keys: f,
27
+ regionKeys: p,
28
+ region: m,
29
+ lock: "share",
30
+ admit: async (e, i, o, s) => {
31
+ let d = {
32
+ version: 1,
33
+ snapshotDigest: i.manifest.snapshot.digest,
34
+ inputsId: i.manifest.app.inputsId,
35
+ executionId: i.manifest.app.executionId
36
+ };
37
+ if (a(d) !== a(t)) throw new n("changed");
38
+ if (!i.manifest.paths.some((e) => e.host === l)) throw new n("not-found");
39
+ await h(e, i, o, s);
40
+ let f = c(await u.readPresentations(e, i, s), b), p = await g(e, i, s, {
41
+ host: l,
42
+ path: y,
43
+ presentation: f
44
+ });
45
+ if (!p.found) throw new n("not-found");
46
+ let m = JSON.stringify(p.page);
47
+ if (m === void 0 || Buffer.byteLength(m) > 4194304) throw new n("transport");
48
+ await h(e, i, o, s), r = {
49
+ version: 1,
50
+ build: t,
51
+ path: y,
52
+ page: JSON.parse(m)
53
+ };
54
+ }
55
+ }) === null || r === void 0) throw new n("not-found");
56
+ return r;
57
+ });
58
+ },
59
+ catch: (e) => e instanceof n ? e : e instanceof t ? new n(e.reason === "denied" ? "denied" : "changed") : new n("transport")
60
+ }) };
61
+ };
62
+ //#endregion
63
+ export { u as createCmsPublicBuilds };
@@ -0,0 +1,129 @@
1
+ import { canonicalCmsPublicPath as e } from "./publicBuild.js";
2
+ import { Effect as t } from "effect";
3
+ import { storageByteSecurityHeaders as n } from "@voltro/plugin-storage/byte-security";
4
+ //#region src/publicOutputHttp.ts
5
+ var r = (r, i) => {
6
+ if (i.redirects && r.redirect === void 0) throw Error("Missing public redirect service");
7
+ let a = [
8
+ ...i.documents.map((e) => ({
9
+ ...e,
10
+ kind: "document"
11
+ })),
12
+ {
13
+ path: "/__voltro/media",
14
+ match: "prefix",
15
+ kind: "asset"
16
+ },
17
+ {
18
+ path: "/__voltro/web",
19
+ match: "prefix",
20
+ kind: "asset"
21
+ },
22
+ ...i.controls ? [
23
+ {
24
+ path: "/sitemap.xml",
25
+ match: "exact",
26
+ kind: "control"
27
+ },
28
+ {
29
+ path: "/robots.txt",
30
+ match: "exact",
31
+ kind: "control"
32
+ },
33
+ {
34
+ path: "/sitemaps",
35
+ match: "prefix",
36
+ kind: "control"
37
+ }
38
+ ] : []
39
+ ];
40
+ if (a.some((t) => e(t.path) !== t.path) || new Set(a.map((e) => e.path)).size !== a.length) throw Error("Invalid public output mounts");
41
+ return a.map((e) => ({
42
+ path: e.path,
43
+ match: e.match,
44
+ method: "GET",
45
+ answersOtherMethods: !0,
46
+ handle: async (a) => {
47
+ let o = {
48
+ "cache-control": "private, no-store",
49
+ pragma: "no-cache",
50
+ ...e.kind === "control" ? {} : { vary: "Cookie" },
51
+ "x-content-type-options": "nosniff"
52
+ };
53
+ if (a.method !== "GET" && a.method !== "HEAD" && !(i.redirects && e.kind === "document")) return {
54
+ status: 405,
55
+ headers: {
56
+ ...o,
57
+ allow: "GET, HEAD"
58
+ }
59
+ };
60
+ let s, c;
61
+ try {
62
+ s = i.host(a.headers), c = e.kind === "control" ? void 0 : i.choices?.(a.headers);
63
+ } catch {
64
+ return {
65
+ status: 400,
66
+ headers: o
67
+ };
68
+ }
69
+ if (i.redirects && e.kind === "document" && r.redirect !== void 0) {
70
+ let e = await t.runPromise(t.result(r.redirect({
71
+ host: s,
72
+ path: a.path,
73
+ ...c === void 0 ? {} : { choices: c }
74
+ })));
75
+ if (e._tag === "Success") {
76
+ let t = e.success;
77
+ return {
78
+ status: t.status,
79
+ headers: {
80
+ ...o,
81
+ ...t.location === null ? {} : { location: t.location },
82
+ "content-length": "0"
83
+ }
84
+ };
85
+ }
86
+ let n = e.failure.reason;
87
+ if (n !== "not-found") return {
88
+ status: n === "request" || n === "identity" ? 400 : n === "denied" ? 410 : n === "changed" ? 409 : 503,
89
+ headers: o
90
+ };
91
+ }
92
+ if (a.method !== "GET" && a.method !== "HEAD") return {
93
+ status: 405,
94
+ headers: {
95
+ ...o,
96
+ allow: "GET, HEAD"
97
+ }
98
+ };
99
+ let l = e.kind === "control" ? r.control({
100
+ host: s,
101
+ path: a.path
102
+ }) : r[e.kind]({
103
+ host: s,
104
+ path: a.path,
105
+ ...c === void 0 ? {} : { choices: c }
106
+ }), u = await t.runPromise(t.result(l));
107
+ if (u._tag === "Failure") {
108
+ let e = u.failure.reason;
109
+ return {
110
+ status: e === "request" || e === "identity" ? 400 : e === "not-found" ? 404 : e === "denied" ? 410 : e === "changed" ? 409 : 503,
111
+ headers: o
112
+ };
113
+ }
114
+ let d = u.success;
115
+ return {
116
+ status: 200,
117
+ headers: {
118
+ ...o,
119
+ ...e.path === "/__voltro/media" ? n(d.contentType) : {},
120
+ "content-length": String(d.bytes.byteLength)
121
+ },
122
+ contentType: d.contentType,
123
+ ...a.method === "HEAD" ? {} : { body: d.bytes }
124
+ };
125
+ }
126
+ }));
127
+ };
128
+ //#endregion
129
+ export { r as cmsPublicOutputHttp };