@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
package/dist/copies.js ADDED
@@ -0,0 +1,89 @@
1
+ import { ContentIdConflict as e, ContentNotFound as t, ContentValidationFailed as n, RevisionMismatch as r } from "./errors.js";
2
+ import { asTyped as i } from "./effectForm.js";
3
+ import { saveDraft as a } from "./write.js";
4
+ import { and as o, eq as s, id as c, table as l, text as u, timestamp as d } from "@voltro/database";
5
+ import { tenant as f } from "@voltro/plugin-multitenancy/mixin";
6
+ //#region src/copies.ts
7
+ var p = "cms_copies", m = l(p, {
8
+ id: c({ prefix: "ccpy" }),
9
+ contentType: u().maxLength(64),
10
+ documentId: u().maxLength(64),
11
+ sourceDocumentId: u().maxLength(64),
12
+ sourceRevisionId: u().maxLength(64).nullable(),
13
+ copiedBy: u().maxLength(64).nullable(),
14
+ copiedAt: d()
15
+ }).with(f()).index("cms_copies_by_document", ["documentId"]).index("cms_copies_by_source", ["sourceDocumentId"]), h = [
16
+ "id",
17
+ "documentId",
18
+ "revisionId",
19
+ "status",
20
+ "tenantId",
21
+ "publishAt",
22
+ "createdAt",
23
+ "updatedAt",
24
+ "createdBy",
25
+ "updatedBy"
26
+ ], g = (e) => e instanceof Date ? e : new Date(String(e)), _ = (e) => typeof e == "string" && e !== "" ? e : null, v = async (e, t, n, r, i = {}, c = /* @__PURE__ */ new Date()) => {
27
+ let [l] = await e.query({
28
+ table: `${t.name}_drafts`,
29
+ predicate: o(s("documentId", n), s("site", r.site), s("environment", r.environment), s("locale", r.locale)),
30
+ order: [],
31
+ take: 1,
32
+ skip: void 0,
33
+ projection: void 0
34
+ });
35
+ if (l === void 0) return {
36
+ ok: !1,
37
+ reason: "notFound"
38
+ };
39
+ let u = Object.fromEntries(Object.entries(l).filter(([e]) => !h.includes(e)));
40
+ if ("title" in t.fields) {
41
+ let t = (await x(e, n)).length, r = String(l.title ?? "");
42
+ u.title = (i.title?.trim() || `${r} (copy${t > 0 ? ` ${t + 1}` : ""})`).slice(0, 200);
43
+ }
44
+ let d = await a(e, t, u, r), f = String(d.documentId);
45
+ return await e.insert(p, {
46
+ contentType: t.name,
47
+ documentId: f,
48
+ sourceDocumentId: n,
49
+ sourceRevisionId: _(l.revisionId),
50
+ copiedBy: i.actorId ?? null,
51
+ copiedAt: c,
52
+ ...d.tenantId !== void 0 && d.tenantId !== null ? { tenantId: d.tenantId } : {}
53
+ }), {
54
+ ok: !0,
55
+ id: String(d.id),
56
+ documentId: f,
57
+ revisionId: String(d.revisionId)
58
+ };
59
+ }, y = async (e, t) => {
60
+ let [n] = await e.query({
61
+ table: p,
62
+ predicate: s("documentId", t),
63
+ order: [],
64
+ take: 1,
65
+ skip: void 0,
66
+ projection: void 0
67
+ });
68
+ return n === void 0 ? null : b(n);
69
+ }, b = (e) => ({
70
+ sourceDocumentId: String(e.sourceDocumentId),
71
+ sourceRevisionId: _(e.sourceRevisionId),
72
+ copiedBy: _(e.copiedBy),
73
+ copiedAt: g(e.copiedAt)
74
+ }), x = async (e, t) => (await e.query({
75
+ table: p,
76
+ predicate: s("sourceDocumentId", t),
77
+ order: [{
78
+ column: "copiedAt",
79
+ direction: "asc"
80
+ }],
81
+ take: void 0,
82
+ skip: void 0,
83
+ projection: void 0
84
+ })).map((e) => ({
85
+ ...b(e),
86
+ documentId: String(e.documentId)
87
+ })), S = (...a) => i(() => v(...a), n, t, e, r), C = (...e) => i(() => y(...e)), w = (...e) => i(() => x(...e));
88
+ //#endregion
89
+ export { p as CMS_COPIES_TABLE, m as cmsCopiesTable, x as copiesOf, w as copiesOfEffect, v as copyDocument, S as copyDocumentEffect, y as copyOrigin, C as copyOriginEffect };
@@ -0,0 +1,202 @@
1
+ import { asTyped as e } from "./effectForm.js";
2
+ import { CMS_REVISIONS_TABLE as t } from "./contentType.js";
3
+ import { and as n, eq as r, gt as i, id as a, inSet as o, json as s, table as c, text as l, timestamp as u } from "@voltro/database";
4
+ import { tenant as d } from "@voltro/plugin-multitenancy/mixin";
5
+ //#region src/cutover.ts
6
+ var f = "cms_cutover_issues", p = "cms_cutover_decisions", m = c(f, {
7
+ id: a({ prefix: "ccis" }),
8
+ source: l().maxLength(200),
9
+ key: l().maxLength(200),
10
+ kind: l().maxLength(64),
11
+ detail: l(),
12
+ resolution: l().nullable(),
13
+ resolvedBy: l().nullable(),
14
+ resolvedAt: u().nullable()
15
+ }).with(d()).unique("cms_cutover_issues_once", [
16
+ "tenantId",
17
+ "source",
18
+ "key"
19
+ ]), h = c(p, {
20
+ id: a({ prefix: "ccdc" }),
21
+ source: l().maxLength(200),
22
+ decision: l().oneOf(["go", "fallback"]),
23
+ criteria: s(),
24
+ note: l(),
25
+ plan: s().nullable(),
26
+ decidedBy: l(),
27
+ decidedAt: u()
28
+ }).with(d()).index("cms_cutover_decisions_by_source", ["source"]), g = 30, _ = (e, t) => e.routing.trim() === "" ? "routing" : !Number.isInteger(e.redirects) || e.redirects < 0 ? "redirects" : e.rollbackUntil.getTime() <= e.freezeAt.getTime() ? "rollbackBeforeFreeze" : e.rollbackUntil.getTime() - t.getTime() > 2592e6 ? "rollbackTooLong" : null, v = (e, t) => {
29
+ let n = e.map((e) => {
30
+ let n = t[e.measure] ?? null, r = n !== null && (e.op === "atMost" ? n <= e.value : n >= e.value);
31
+ return {
32
+ ...e,
33
+ measured: n,
34
+ pass: r
35
+ };
36
+ });
37
+ return {
38
+ results: n,
39
+ ready: n.length > 0 && n.every((e) => e.pass)
40
+ };
41
+ }, y = (e) => ({
42
+ id: String(e.id),
43
+ key: String(e.key),
44
+ kind: String(e.kind),
45
+ detail: String(e.detail),
46
+ resolution: typeof e.resolution == "string" ? e.resolution : null,
47
+ resolvedBy: typeof e.resolvedBy == "string" ? e.resolvedBy : null
48
+ }), b = async (e, t, n, r) => {
49
+ let i = 0;
50
+ for (let a of n) (await e.insertIgnoreWithOutcome("cms_cutover_issues", {
51
+ source: t,
52
+ key: a.key,
53
+ kind: a.kind,
54
+ detail: a.detail,
55
+ resolution: null,
56
+ resolvedBy: null,
57
+ resolvedAt: null,
58
+ ...r === null ? {} : { tenantId: r }
59
+ }, { conflictColumns: [
60
+ "tenantId",
61
+ "source",
62
+ "key"
63
+ ] })).outcome === "inserted" && i++;
64
+ return i;
65
+ }, x = async (e, t) => (await e.query({
66
+ table: f,
67
+ predicate: r("source", t),
68
+ order: [{
69
+ column: "createdAt",
70
+ direction: "asc"
71
+ }],
72
+ take: void 0,
73
+ skip: void 0,
74
+ projection: void 0
75
+ })).map(y).sort((e, t) => Number(e.resolution !== null) - Number(t.resolution !== null)), S = async (e, t, n, i = /* @__PURE__ */ new Date()) => {
76
+ let a = n.resolution.trim();
77
+ if (a === "" || a.length > 500) return {
78
+ ok: !1,
79
+ reason: "noReason"
80
+ };
81
+ let [o] = await e.query({
82
+ table: f,
83
+ predicate: r("id", t),
84
+ order: [],
85
+ take: 1,
86
+ skip: void 0,
87
+ projection: void 0
88
+ });
89
+ return o === void 0 ? {
90
+ ok: !1,
91
+ reason: "notFound"
92
+ } : typeof o.resolution == "string" ? {
93
+ ok: !1,
94
+ reason: "alreadyResolved"
95
+ } : (await e.update(f, t, {
96
+ resolution: a,
97
+ resolvedBy: n.actorId,
98
+ resolvedAt: i
99
+ }), { ok: !0 });
100
+ }, C = async (e, r, a) => {
101
+ if (r.length === 0) return [];
102
+ let s = await e.query({
103
+ table: t,
104
+ predicate: n(o("documentId", [...r]), a === void 0 ? i("number", 1) : i("createdAt", a)),
105
+ order: [],
106
+ take: void 0,
107
+ skip: void 0,
108
+ projection: [
109
+ "documentId",
110
+ "createdBy",
111
+ "createdAt"
112
+ ]
113
+ }), c = /* @__PURE__ */ new Map();
114
+ for (let e of s) {
115
+ let t = typeof e.createdBy == "string" ? e.createdBy : null;
116
+ if (t === null) continue;
117
+ let n = c.get(t) ?? {
118
+ revisions: 0,
119
+ documents: /* @__PURE__ */ new Set(),
120
+ lastAt: null
121
+ };
122
+ n.revisions++, n.documents.add(String(e.documentId));
123
+ let r = e.createdAt instanceof Date ? e.createdAt : new Date(String(e.createdAt));
124
+ (n.lastAt === null || r > n.lastAt) && (n.lastAt = r), c.set(t, n);
125
+ }
126
+ return [...c].map(([e, t]) => ({
127
+ actorId: e,
128
+ revisions: t.revisions,
129
+ documents: t.documents.size,
130
+ lastAt: t.lastAt
131
+ })).sort((e, t) => t.revisions - e.revisions);
132
+ }, w = async (e, t, n = /* @__PURE__ */ new Date()) => {
133
+ let r = t.note.trim();
134
+ if (r === "" || r.length > 1e3) return {
135
+ ok: !1,
136
+ reason: "noNote"
137
+ };
138
+ let i = t.results.filter((e) => !e.pass).map((e) => e.id);
139
+ if (t.decision === "go" && (t.results.length === 0 || i.length > 0)) return {
140
+ ok: !1,
141
+ reason: "notReady",
142
+ failing: i
143
+ };
144
+ let a = t.decision === "go" ? t.plan : void 0;
145
+ if (t.decision === "go") {
146
+ if (a === void 0) return {
147
+ ok: !1,
148
+ reason: "noPlan"
149
+ };
150
+ let e = _(a, n);
151
+ if (e !== null) return {
152
+ ok: !1,
153
+ reason: "noPlan",
154
+ problem: e
155
+ };
156
+ }
157
+ let o = await e.insert(p, {
158
+ source: t.source,
159
+ decision: t.decision,
160
+ criteria: [...t.results],
161
+ note: r,
162
+ plan: a === void 0 ? null : {
163
+ ...a,
164
+ freezeAt: a.freezeAt.toISOString(),
165
+ rollbackUntil: a.rollbackUntil.toISOString()
166
+ },
167
+ decidedBy: t.actorId,
168
+ decidedAt: n,
169
+ ...t.tenantId === null ? {} : { tenantId: t.tenantId }
170
+ });
171
+ return {
172
+ ok: !0,
173
+ id: String(o.id)
174
+ };
175
+ }, T = async (e, t) => (await e.query({
176
+ table: p,
177
+ predicate: r("source", t),
178
+ order: [{
179
+ column: "decidedAt",
180
+ direction: "desc"
181
+ }],
182
+ take: 50,
183
+ skip: void 0,
184
+ projection: void 0
185
+ })).map((e) => ({
186
+ id: String(e.id),
187
+ decision: e.decision === "go" ? "go" : "fallback",
188
+ criteria: e.criteria ?? [],
189
+ note: String(e.note),
190
+ plan: e.plan === null || e.plan === void 0 ? null : (() => {
191
+ let t = e.plan;
192
+ return {
193
+ ...t,
194
+ freezeAt: new Date(t.freezeAt),
195
+ rollbackUntil: new Date(t.rollbackUntil)
196
+ };
197
+ })(),
198
+ decidedBy: String(e.decidedBy),
199
+ decidedAt: e.decidedAt instanceof Date ? e.decidedAt : new Date(String(e.decidedAt))
200
+ })), E = (...t) => e(() => b(...t)), D = (...t) => e(() => x(...t)), O = (...t) => e(() => S(...t)), k = (...t) => e(() => C(...t)), A = (...t) => e(() => w(...t)), j = (...t) => e(() => T(...t));
201
+ //#endregion
202
+ export { p as CMS_CUTOVER_DECISIONS_TABLE, f as CMS_CUTOVER_ISSUES_TABLE, g as MAX_ROLLBACK_DAYS, h as cmsCutoverDecisionsTable, m as cmsCutoverIssuesTable, C as cutoverAdoption, k as cutoverAdoptionEffect, T as cutoverDecisions, j as cutoverDecisionsEffect, x as cutoverIssues, D as cutoverIssuesEffect, _ as cutoverPlanProblem, w as decideCutover, A as decideCutoverEffect, v as evaluateCutover, b as recordCutoverIssues, E as recordCutoverIssuesEffect, S as resolveCutoverIssue, O as resolveCutoverIssueEffect };
@@ -0,0 +1,138 @@
1
+ import { asTyped as e } from "./effectForm.js";
2
+ import { CMS_RELEASES_TABLE as t, CMS_RELEASE_ITEMS_TABLE as n } from "./release.js";
3
+ import { and as r, eq as i, id as a, integer as o, table as s, text as c, timestamp as l } from "@voltro/database";
4
+ import { tenant as u } from "@voltro/plugin-multitenancy/mixin";
5
+ //#region src/deliveryChecks.ts
6
+ var d = "cms_delivery_checks", f = s(d, {
7
+ id: a({ prefix: "cdlv" }),
8
+ contentType: c().maxLength(64),
9
+ documentId: c().maxLength(64),
10
+ locale: c().maxLength(64),
11
+ kind: c().oneOf(["publish", "unpublish"]),
12
+ revisionId: c().maxLength(64).nullable(),
13
+ url: c().maxLength(1e3),
14
+ status: c().oneOf([
15
+ "pending",
16
+ "observed",
17
+ "stale"
18
+ ]),
19
+ requestedAt: l(),
20
+ observedAt: l().nullable(),
21
+ lastSeen: c().maxLength(200).nullable(),
22
+ attempts: o().default(0)
23
+ }).with(u()).index("cms_delivery_checks_by_status", ["status"]), p = (e) => e instanceof Date ? e : new Date(String(e)), m = (e) => ({
24
+ id: String(e.id),
25
+ contentType: String(e.contentType),
26
+ documentId: String(e.documentId),
27
+ locale: String(e.locale),
28
+ kind: e.kind === "unpublish" ? "unpublish" : "publish",
29
+ revisionId: typeof e.revisionId == "string" ? e.revisionId : null,
30
+ url: String(e.url),
31
+ status: e.status === "observed" || e.status === "stale" ? e.status : "pending",
32
+ requestedAt: p(e.requestedAt),
33
+ observedAt: e.observedAt === null || e.observedAt === void 0 ? null : p(e.observedAt),
34
+ lastSeen: typeof e.lastSeen == "string" ? e.lastSeen : null,
35
+ attempts: Number(e.attempts ?? 0)
36
+ }), h = async (e, t, n = /* @__PURE__ */ new Date()) => {
37
+ await e.updateMany(d, {
38
+ status: "stale",
39
+ lastSeen: "superseded"
40
+ }, { where: r(i("documentId", t.documentId), i("locale", t.locale), i("url", t.url), i("status", "pending")) });
41
+ let a = await e.insert(d, {
42
+ contentType: t.contentType,
43
+ documentId: t.documentId,
44
+ locale: t.locale,
45
+ kind: t.kind,
46
+ revisionId: t.revisionId ?? null,
47
+ url: t.url,
48
+ status: "pending",
49
+ requestedAt: n,
50
+ observedAt: null,
51
+ lastSeen: null,
52
+ attempts: 0,
53
+ ...t.tenantId !== void 0 && t.tenantId !== null ? { tenantId: t.tenantId } : {}
54
+ });
55
+ return String(a.id);
56
+ }, g = async (e, t, n = /* @__PURE__ */ new Date(), r = {}) => {
57
+ let a = r.staleAfterMs ?? 9e5, o = await e.query({
58
+ table: d,
59
+ predicate: i("status", "pending"),
60
+ order: [{
61
+ column: "requestedAt",
62
+ direction: "asc"
63
+ }],
64
+ take: r.limit ?? 50,
65
+ skip: void 0,
66
+ projection: void 0
67
+ }), s = [];
68
+ for (let r of o) {
69
+ let i = m(r), o = await t(i.url).catch((e) => `error: ${String(e).slice(0, 150)}`), c = typeof o == "string" ? [o] : o, l = i.kind === "publish" ? i.revisionId !== null && c.includes(i.revisionId) : c.length === 1 && c[0] === "gone", u = l && i.revisionId !== null ? i.revisionId : c.join(" "), f = n.getTime() - i.requestedAt.getTime() > a, p = l ? "observed" : f ? "stale" : "pending", h = await e.update(d, i.id, {
70
+ status: p,
71
+ lastSeen: u.slice(0, 200),
72
+ attempts: i.attempts + 1,
73
+ ...l ? { observedAt: n } : {}
74
+ });
75
+ p !== "pending" && h !== null && s.push(m(h));
76
+ }
77
+ return s;
78
+ }, _ = async (e, t = {}) => (await e.query({
79
+ table: d,
80
+ predicate: t.documentId === void 0 ? void 0 : i("documentId", t.documentId),
81
+ order: [{
82
+ column: "requestedAt",
83
+ direction: "desc"
84
+ }],
85
+ take: t.limit ?? 50,
86
+ skip: void 0,
87
+ projection: void 0
88
+ })).map(m), v = (e, t, n) => e.query({
89
+ table: t,
90
+ predicate: n,
91
+ order: [],
92
+ take: void 0,
93
+ skip: void 0,
94
+ projection: void 0
95
+ }), y = async (e, a) => {
96
+ let [o] = await v(e, t, i("id", a));
97
+ if (o === void 0) return null;
98
+ let s = o.publishedAt === null || o.publishedAt === void 0 ? null : p(o.publishedAt), c = await v(e, n, i("releaseId", a)), l = [];
99
+ for (let t of [...c].sort((e, t) => Number(e.position) - Number(t.position))) {
100
+ let n = String(t.contentType), [a] = await v(e, `${n}_drafts`, i("id", String(t.variantId))), o = String(a === void 0 ? t.variantId : a.documentId), c = t.action === "unpublish" ? "unpublish" : "publish", u = s === null ? [] : (await v(e, d, r(i("documentId", o), i("locale", String(t.locale))))).filter((e) => e.contentType === n && e.kind === c && p(e.requestedAt).getTime() >= s.getTime() - 1e3 && (c === "unpublish" || e.revisionId === t.revisionId)).sort((e, t) => p(t.requestedAt).getTime() - p(e.requestedAt).getTime()), f = /* @__PURE__ */ new Map();
101
+ for (let e of u) {
102
+ let t = m(e);
103
+ f.has(t.url) || f.set(t.url, t);
104
+ }
105
+ let h = {
106
+ contentType: n,
107
+ documentId: o,
108
+ locale: String(t.locale),
109
+ action: c
110
+ };
111
+ f.size === 0 && l.push({
112
+ ...h,
113
+ status: "unchecked",
114
+ url: null,
115
+ tookSeconds: null,
116
+ lastSeen: null
117
+ });
118
+ for (let e of [...f.values()].sort((e, t) => e.requestedAt.getTime() - t.requestedAt.getTime() || e.url.localeCompare(t.url))) l.push({
119
+ ...h,
120
+ status: e.status,
121
+ url: e.url,
122
+ tookSeconds: e.observedAt === null ? null : Math.round((e.observedAt.getTime() - e.requestedAt.getTime()) / 1e3),
123
+ lastSeen: e.lastSeen
124
+ });
125
+ }
126
+ let u = l.filter((e) => e.status !== "unchecked"), f = u.filter((e) => e.status === "observed").length;
127
+ return {
128
+ releaseId: a,
129
+ status: String(o.status),
130
+ publishedAt: s,
131
+ addresses: l,
132
+ reached: f,
133
+ checked: u.length,
134
+ complete: u.length > 0 && f === u.length
135
+ };
136
+ }, b = (...t) => e(() => h(...t)), x = (...t) => e(() => g(...t)), S = (...t) => e(() => _(...t)), C = (...t) => e(() => y(...t));
137
+ //#endregion
138
+ export { d as CMS_DELIVERY_CHECKS_TABLE, f as cmsDeliveryChecksTable, _ as deliveryChecks, S as deliveryChecksEffect, y as releaseCheckpoint, C as releaseCheckpointEffect, h as requestDeliveryCheck, b as requestDeliveryCheckEffect, g as runDeliveryChecks, x as runDeliveryChecksEffect };
@@ -0,0 +1,7 @@
1
+ //#region src/domainHost.ts
2
+ var e = /^(?=.{1,253}$)(?!-)[a-z0-9-]{1,63}(?<!-)(\.(?!-)[a-z0-9-]{1,63}(?<!-))+$/, t = (t) => {
3
+ let n = t.trim().toLowerCase().replace(/\.$/, "");
4
+ return e.test(n) && !/^\d+(\.\d+){3}$/.test(n) ? n : null;
5
+ };
6
+ //#endregion
7
+ export { t as normalizeHost };
@@ -0,0 +1,139 @@
1
+ import { PublicRouteRegistryUnavailable as e } from "./publicRouteRegistry.js";
2
+ import { ChangeFeedUnavailable as t, SiteStateUnavailable as n } from "./errors.js";
3
+ import { asTyped as r } from "./effectForm.js";
4
+ import { copySiteScope as i, lockSiteState as a, siteStatePredicate as o } from "./siteState.js";
5
+ import { normalizeHost as s } from "./domainHost.js";
6
+ import { withPublicRouteStateMutation as c } from "./publicRouteMutation.js";
7
+ import { reconcileDomainPublication as l } from "./publicRouteSitePublication.js";
8
+ import { and as u, boolean as d, eq as f, id as p, table as m, text as h, timestamp as g } from "@voltro/database";
9
+ import { tenant as _ } from "@voltro/plugin-multitenancy/mixin";
10
+ import { randomBytes as v } from "node:crypto";
11
+ //#region src/domains.ts
12
+ var y = "cms_site_domains", b = m(y, {
13
+ id: p({ prefix: "cdom" }),
14
+ site: h().maxLength(64),
15
+ host: h().maxLength(253),
16
+ token: h().maxLength(64),
17
+ status: h().oneOf(["pending", "verified"]),
18
+ verifiedAt: g().nullable(),
19
+ isPrimary: d().default(!1)
20
+ }).with(_()).unique("cms_site_domains_host", ["host"]), x = (e) => ({
21
+ id: String(e.id),
22
+ site: String(e.site),
23
+ host: String(e.host),
24
+ status: e.status === "verified" ? "verified" : "pending",
25
+ primary: e.isPrimary === !0,
26
+ verifiedAt: e.verifiedAt instanceof Date ? e.verifiedAt : e.verifiedAt ? new Date(String(e.verifiedAt)) : null,
27
+ record: {
28
+ name: `_voltro-verify.${String(e.host)}`,
29
+ value: `voltro-verify=${String(e.token)}`
30
+ }
31
+ }), S = async (e, t) => (await e.query({
32
+ table: y,
33
+ predicate: o(i(t)),
34
+ order: [{
35
+ column: "host",
36
+ direction: "asc"
37
+ }],
38
+ take: 100,
39
+ skip: void 0,
40
+ projection: void 0
41
+ })).map(x).sort((e, t) => Number(t.primary) - Number(e.primary)), C = async (e, t, n) => {
42
+ let r = i(t), o = s(n);
43
+ if (o === null) return {
44
+ ok: !1,
45
+ reason: "notAHost"
46
+ };
47
+ await a(e, r);
48
+ let c = await e.insertIgnoreWithOutcome(y, {
49
+ ...r,
50
+ host: o,
51
+ token: v(16).toString("hex"),
52
+ status: "pending",
53
+ verifiedAt: null,
54
+ isPrimary: !1
55
+ }, { conflictColumns: ["host"] });
56
+ return c.outcome === "ignored" ? {
57
+ ok: !1,
58
+ reason: "taken"
59
+ } : {
60
+ ok: !0,
61
+ domain: x(c.row)
62
+ };
63
+ }, w = async (e, t, n) => {
64
+ let r = i(t);
65
+ await a(e, r);
66
+ let [s] = await e.query({
67
+ table: y,
68
+ predicate: u(o(r), f("id", n)),
69
+ lock: "update",
70
+ order: [],
71
+ take: 1,
72
+ skip: void 0,
73
+ projection: void 0
74
+ });
75
+ return s;
76
+ }, T = async (e, t, n, r, i = /* @__PURE__ */ new Date()) => {
77
+ let a = await w(e, t, n);
78
+ if (a === void 0) return {
79
+ ok: !1,
80
+ reason: "notFound"
81
+ };
82
+ let o = x(a);
83
+ if (o.status === "verified") return {
84
+ ok: !0,
85
+ domain: o
86
+ };
87
+ let s = await r(o.record.name).catch(() => []);
88
+ return s.some((e) => e.trim() === o.record.value) ? c(e, async () => {
89
+ let r = await e.update(y, n, {
90
+ status: "verified",
91
+ verifiedAt: i
92
+ });
93
+ return await l(e, t), {
94
+ ok: !0,
95
+ domain: x(r ?? {
96
+ ...a,
97
+ status: "verified",
98
+ verifiedAt: i
99
+ })
100
+ };
101
+ }) : {
102
+ ok: !1,
103
+ reason: "recordMissing",
104
+ found: s
105
+ };
106
+ }, E = async (e, t, n) => {
107
+ let r = await w(e, t, n);
108
+ return r === void 0 ? {
109
+ ok: !1,
110
+ reason: "notFound"
111
+ } : r.status === "verified" ? c(e, async () => (await e.updateMany(y, { isPrimary: !1 }, { where: u(o({
112
+ tenantId: String(r.tenantId),
113
+ site: String(r.site)
114
+ }), f("isPrimary", !0)) }), await e.update(y, n, { isPrimary: !0 }), await l(e, t), { ok: !0 })) : {
115
+ ok: !1,
116
+ reason: "notVerified"
117
+ };
118
+ }, D = async (e, t, n) => {
119
+ let r = await w(e, t, n);
120
+ return r === void 0 ? {
121
+ ok: !1,
122
+ reason: "notFound"
123
+ } : r.isPrimary === !0 ? {
124
+ ok: !1,
125
+ reason: "primary"
126
+ } : c(e, async () => (await e.delete(y, n), r.status === "verified" && await l(e, t), { ok: !0 }));
127
+ }, O = async (e, t) => {
128
+ let [n] = await e.query({
129
+ table: y,
130
+ predicate: u(o(i(t)), f("status", "verified"), f("isPrimary", !0)),
131
+ order: [],
132
+ take: 1,
133
+ skip: void 0,
134
+ projection: void 0
135
+ });
136
+ return n === void 0 ? null : String(n.host);
137
+ }, k = (...e) => r(() => S(...e), n), A = (...e) => r(() => C(...e), n), j = (...i) => r(() => T(...i), n, t, e), M = (...i) => r(() => E(...i), n, t, e), N = (...i) => r(() => D(...i), n, t, e), P = (...e) => r(() => O(...e), n);
138
+ //#endregion
139
+ export { y as CMS_SITE_DOMAINS_TABLE, C as addDomain, A as addDomainEffect, b as cmsSiteDomainsTable, s as normalizeHost, O as primaryDomain, P as primaryDomainEffect, D as removeDomain, N as removeDomainEffect, E as setPrimaryDomain, M as setPrimaryDomainEffect, S as siteDomains, k as siteDomainsEffect, T as verifyDomain, j as verifyDomainEffect };