@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,164 @@
1
+ import { ContentNotFound as e } from "./errors.js";
2
+ import { blockMarkup as t, normalizeRichDocument as n, withBlockMarkup as r } from "./richDocument.js";
3
+ import { asTyped as i } from "./effectForm.js";
4
+ import { blockHasChanges as a } from "./trackChanges.js";
5
+ import { changedFields as o } from "./history.js";
6
+ import { crdtText as s, eq as c, id as l, table as u, text as d } from "@voltro/database";
7
+ import { tenant as f } from "@voltro/plugin-multitenancy/mixin";
8
+ import { crdtText as p, crdtTextEdit as m, decodeCrdtText as h, mergeCrdtStates as g } from "@voltro/local-first";
9
+ //#region src/draftTexts.ts
10
+ var _ = "cms_draft_texts", v = u(_, {
11
+ id: l({ prefix: "cdtx" }),
12
+ contentType: d().maxLength(64),
13
+ draftId: d(),
14
+ field: d(),
15
+ baseRevision: d(),
16
+ state: s()
17
+ }).with(f()).unique("cms_draft_texts_uq_field", [
18
+ "tenantId",
19
+ "draftId",
20
+ "field"
21
+ ]), y = (e) => Object.entries(e.fields).filter(([t, n]) => t !== e.templates?.field && n.kind === "string" && (n.editorHint === "text" || n.editorHint === "textarea") && n.derived === void 0 && n.literals === void 0 && n.unique !== !0).map(([e]) => e), b = (e, t) => /* @__PURE__ */ new Set([...t, ...Object.entries(e.fields).filter(([, e]) => e.derived !== void 0 && t.has(e.derived.source)).map(([e]) => e)]), x = (e, t) => `${e}#${t}`, S = (e) => {
22
+ let t = e.indexOf("#");
23
+ return t <= 0 ? null : {
24
+ field: e.slice(0, t),
25
+ blockId: e.slice(t + 1)
26
+ };
27
+ }, C = /* @__PURE__ */ new Set([
28
+ "paragraph",
29
+ "heading",
30
+ "list",
31
+ "table"
32
+ ]), w = (e) => {
33
+ let t = n(e ?? "");
34
+ return typeof t == "object" && t && Array.isArray(t.blocks) ? t : null;
35
+ }, T = (e, n) => Object.entries(e.fields).filter(([, e]) => e.kind === "richText").flatMap(([e]) => (w(n[e])?.blocks ?? []).filter((e) => C.has(e.type) && !a(e)).map((n) => ({
36
+ key: x(e, n.id),
37
+ field: e,
38
+ block: n,
39
+ markup: t(n)
40
+ }))), E = (e, n, i, o = {}) => {
41
+ let s = {}, c = [], l = (e, n) => {
42
+ let r = w(e)?.blocks.find((e) => e.id === n);
43
+ return r === void 0 ? void 0 : t(r);
44
+ };
45
+ for (let [u, d] of Object.entries(e.fields)) {
46
+ if (d.kind !== "richText" || n[u] === void 0 || n[u] === null) continue;
47
+ let e = w(n[u]);
48
+ if (e === null) continue;
49
+ let f = Object.keys(d.richText?.profile?.styles?.tokens ?? {}), p = !1, m = e.blocks.map((e) => {
50
+ let n = x(u, e.id), s = i.get(n);
51
+ if (s === void 0 || !C.has(e.type) || a(e)) return e;
52
+ let d = t(e), m = l(o.current?.[u], e.id), h = l(o.seen?.[u], e.id);
53
+ return o.seen !== void 0 && d !== h && s === m && m === h ? (c.push({
54
+ key: n,
55
+ markup: d
56
+ }), e) : s === d ? e : (p = !0, r(e, s, f));
57
+ });
58
+ p && (s[u] = {
59
+ ...e,
60
+ blocks: m
61
+ });
62
+ }
63
+ return {
64
+ values: s,
65
+ typedBefore: c
66
+ };
67
+ }, D = (e, t, n) => {
68
+ let r = (e) => {
69
+ let t = w(e);
70
+ return t === null ? e : t.blocks.map((e) => n.has(e.id) ? {
71
+ id: e.id,
72
+ type: e.type
73
+ } : e);
74
+ };
75
+ return JSON.stringify(r(e)) === JSON.stringify(r(t));
76
+ }, O = (e, t, n, r) => {
77
+ let i = [...r], a = b(e, new Set(i.filter((e) => S(e) === null))), s = /* @__PURE__ */ new Map();
78
+ for (let e of i) {
79
+ let t = S(e);
80
+ t !== null && s.set(t.field, /* @__PURE__ */ new Set([...s.get(t.field) ?? [], t.blockId]));
81
+ }
82
+ return o(e.fields, t, n).filter((e) => !a.has(e) && !(s.has(e) && D(t[e], n[e], s.get(e))));
83
+ }, k = (e, t, n) => e.query({
84
+ table: t,
85
+ predicate: n,
86
+ order: [],
87
+ take: void 0,
88
+ skip: void 0,
89
+ projection: void 0
90
+ }), A = async (t, n, r) => {
91
+ let [i] = await k(t, `${n.name}_drafts`, c("id", r));
92
+ if (i === void 0) throw new e({
93
+ contentType: n.name,
94
+ id: r,
95
+ stage: "draft"
96
+ });
97
+ return i;
98
+ }, j = (e, t) => k(e, _, c("draftId", t)), M = async (e, t, n) => {
99
+ let r = await A(e, t, n), i = String(r.revisionId), a = new Map((await j(e, n)).map((e) => [String(e.field), e])), o = r.tenantId !== void 0 && r.tenantId !== null ? { tenantId: r.tenantId } : {}, s = [...y(t).map((e) => ({
100
+ key: e,
101
+ value: typeof r[e] == "string" ? r[e] : ""
102
+ })), ...T(t, r).map((e) => ({
103
+ key: e.key,
104
+ value: e.markup
105
+ }))];
106
+ for (let { key: r, value: c } of s) {
107
+ let s = a.get(r);
108
+ s?.baseRevision !== i && (s !== void 0 && await e.delete(_, String(s.id)), await e.insertIgnore(_, {
109
+ contentType: t.name,
110
+ draftId: n,
111
+ field: r,
112
+ baseRevision: i,
113
+ state: p(c).encode(),
114
+ ...o
115
+ }, { conflictColumns: [
116
+ "tenantId",
117
+ "draftId",
118
+ "field"
119
+ ] }));
120
+ }
121
+ return j(e, n);
122
+ }, N = async (e, t, n) => {
123
+ let r = await j(e, n);
124
+ if (r.length === 0) return;
125
+ let i = new Set(r.map((e) => String(e.field))), a = await A(e, t, n), o = a.tenantId !== void 0 && a.tenantId !== null ? { tenantId: a.tenantId } : {};
126
+ for (let r of T(t, a)) i.has(r.key) || await e.insertIgnore(_, {
127
+ contentType: t.name,
128
+ draftId: n,
129
+ field: r.key,
130
+ baseRevision: String(a.revisionId),
131
+ state: p(r.markup).encode(),
132
+ ...o
133
+ }, { conflictColumns: [
134
+ "tenantId",
135
+ "draftId",
136
+ "field"
137
+ ] });
138
+ }, P = async (t, n, r) => {
139
+ let [i] = await k(t, _, c("id", n));
140
+ if (i === void 0) throw new e({
141
+ contentType: _,
142
+ id: n,
143
+ stage: "draft"
144
+ });
145
+ let a = i.state instanceof Uint8Array ? i.state : /* @__PURE__ */ new Uint8Array();
146
+ return await t.update("cms_draft_texts", n, { state: a.length === 0 ? r : g(a, r) }) ?? i;
147
+ }, F = async (e, t, n) => {
148
+ let [r] = await k(e, _, c("id", t));
149
+ if (r === void 0) return;
150
+ let i = p();
151
+ r.state instanceof Uint8Array && r.state.length > 0 && i.merge(r.state);
152
+ let a = m(i.toString(), n);
153
+ a !== null && (a.deleteLength > 0 && i.delete(a.index, a.deleteLength), a.insert !== "" && i.insert(a.index, a.insert), await P(e, t, i.encode()));
154
+ }, I = async (e, t) => {
155
+ let n = (await j(e, String(t.id))).filter((e) => e.baseRevision === t.revisionId);
156
+ return {
157
+ values: new Map(n.map((e) => [String(e.field), e.state instanceof Uint8Array && e.state.length > 0 ? h(e.state) : ""])),
158
+ rows: n
159
+ };
160
+ }, L = async (e, t, n) => {
161
+ for (let r of t) await e.update(_, String(r.id), { baseRevision: n });
162
+ }, R = [e], z = (...e) => i(() => I(...e), ...R), B = (...e) => i(() => M(...e), ...R), V = (...e) => i(() => j(...e), ...R), H = (...e) => i(() => L(...e), ...R), U = (...e) => i(() => P(...e), ...R);
163
+ //#endregion
164
+ export { _ as CMS_DRAFT_TEXTS_TABLE, O as changedApartFromShared, v as cmsDraftTextsTable, y as collaborativeFields, I as liveDraftTexts, z as liveDraftTextsEffect, b as movedTogether, M as openDraftTexts, B as openDraftTextsEffect, N as openNewBlockTexts, j as readDraftTexts, V as readDraftTextsEffect, L as rebaseDraftTexts, H as rebaseDraftTextsEffect, S as richBlockOfKey, x as richBlockTextKey, F as setDraftText, T as sharedRichBlocks, P as typeDraftText, U as typeDraftTextEffect, E as withSharedBlocks };
@@ -0,0 +1,78 @@
1
+ import { ChangeFeedUnavailable as e, ContentNotFound as t } from "./errors.js";
2
+ import { asTyped as n } from "./effectForm.js";
3
+ import { usedBy as r } from "./references.js";
4
+ import { archive as i } from "./write.js";
5
+ import { and as a, eq as o, neq as s } from "@voltro/database";
6
+ //#region src/duplicates.ts
7
+ var c = async (e, t, n, r) => {
8
+ let i = await e.query({
9
+ table: `${t.name}_drafts`,
10
+ predicate: a(o("site", n.site), o("environment", n.environment), o("locale", n.locale), s("status", "archived")),
11
+ order: [{
12
+ column: "createdAt",
13
+ direction: "asc"
14
+ }],
15
+ take: void 0,
16
+ skip: void 0,
17
+ projection: void 0
18
+ }), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
19
+ for (let e of i) {
20
+ let t = e[r.field];
21
+ if (typeof t != "string" || t === "") continue;
22
+ c.has(t) || c.set(t, r.fingerprint(t).catch(() => null));
23
+ let n = await c.get(t);
24
+ if (n === null) continue;
25
+ let i = l.get(n) ?? [];
26
+ i.push({
27
+ id: String(e.id),
28
+ documentId: String(e.documentId),
29
+ title: String(e[r.titleField ?? "title"] ?? ""),
30
+ status: String(e.status)
31
+ }), l.set(n, i);
32
+ }
33
+ return [...l].filter(([, e]) => e.length > 1).map(([e, t]) => ({
34
+ fingerprint: e,
35
+ documents: t
36
+ }));
37
+ }, l = async (e, n, s, c) => {
38
+ if (c.copyId === c.keepId) return {
39
+ ok: !1,
40
+ reason: "notDuplicate"
41
+ };
42
+ let l = async (r) => {
43
+ let [i] = await e.query({
44
+ table: `${n.name}_drafts`,
45
+ predicate: a(o("id", r), o("site", s.site), o("environment", s.environment), o("locale", s.locale)),
46
+ order: [],
47
+ take: 1,
48
+ skip: void 0,
49
+ projection: void 0
50
+ });
51
+ if (i === void 0) throw new t({
52
+ contentType: n.name,
53
+ id: r,
54
+ stage: "draft"
55
+ });
56
+ return i;
57
+ }, [u, d] = [await l(c.copyId), await l(c.keepId)], [f, p] = [u[c.field], d[c.field]];
58
+ if (typeof f != "string" || typeof p != "string") return {
59
+ ok: !1,
60
+ reason: "notDuplicate"
61
+ };
62
+ let [m, h] = [await c.fingerprint(f), await c.fingerprint(p)];
63
+ if (m === null || m !== h) return {
64
+ ok: !1,
65
+ reason: "notDuplicate"
66
+ };
67
+ let g = await r(e, {
68
+ type: n.name,
69
+ documentId: String(u.documentId)
70
+ }, s);
71
+ return g.length > 0 ? {
72
+ ok: !1,
73
+ reason: "inUse",
74
+ usedBy: g
75
+ } : (await i(e, n, c.copyId, s), { ok: !0 });
76
+ }, u = (...e) => n(() => c(...e)), d = (...r) => n(() => l(...r), t, e);
77
+ //#endregion
78
+ export { c as duplicateGroups, u as duplicateGroupsEffect, l as retireDuplicate, d as retireDuplicateEffect };
@@ -0,0 +1,69 @@
1
+ //#region src/edgePurge.ts
2
+ var e = /^[\w:.\-/@]{1,256}$/, t = (e) => {
3
+ if (e.length > 2048 || /[\s]/.test(e)) return null;
4
+ try {
5
+ let t = new URL(e);
6
+ return t.protocol === "https:" || t.protocol === "http:" ? t.toString() : null;
7
+ } catch {
8
+ return null;
9
+ }
10
+ }, n = (n, i, a, o = []) => {
11
+ let s = [...new Set(a.filter((t) => e.test(t)))], c = [...new Set(o.map(t).filter((e) => e !== null))];
12
+ if (i.target === "") return [];
13
+ let l = i.token === null || i.token === "" ? {} : { authorization: `Bearer ${i.token}` };
14
+ switch (n) {
15
+ case "cloudflare": {
16
+ let e = `https://api.cloudflare.com/client/v4/zones/${encodeURIComponent(i.target)}/purge_cache`, t = (t) => ({
17
+ url: e,
18
+ method: "POST",
19
+ headers: {
20
+ "content-type": "application/json",
21
+ ...l
22
+ },
23
+ body: JSON.stringify(t)
24
+ });
25
+ return [...r(s).map((e) => t({ tags: e })), ...r(c).map((e) => t({ files: e }))];
26
+ }
27
+ case "fastly": {
28
+ let e = i.token === null || i.token === "" ? {} : { "fastly-key": i.token };
29
+ return [...s.length === 0 ? [] : [{
30
+ url: `https://api.fastly.com/service/${encodeURIComponent(i.target)}/purge`,
31
+ method: "POST",
32
+ headers: {
33
+ "surrogate-key": s.join(" "),
34
+ ...e
35
+ }
36
+ }], ...c.map((t) => ({
37
+ url: `https://api.fastly.com/purge/${t.replace(/^https?:\/\//, "")}`,
38
+ method: "POST",
39
+ headers: { ...e }
40
+ }))];
41
+ }
42
+ case "webhook": {
43
+ let e;
44
+ try {
45
+ e = new URL(i.target);
46
+ } catch {
47
+ return [];
48
+ }
49
+ return e.protocol !== "https:" && e.hostname !== "localhost" && e.hostname !== "127.0.0.1" || s.length === 0 && c.length === 0 ? [] : [{
50
+ url: e.toString(),
51
+ method: "POST",
52
+ headers: {
53
+ "content-type": "application/json",
54
+ ...l
55
+ },
56
+ body: JSON.stringify(c.length === 0 ? { tags: s } : {
57
+ tags: s,
58
+ urls: c
59
+ })
60
+ }];
61
+ }
62
+ }
63
+ }, r = (e) => {
64
+ let t = [];
65
+ for (let n = 0; n < e.length; n += 30) t.push(e.slice(n, n + 30));
66
+ return t;
67
+ };
68
+ //#endregion
69
+ export { n as edgePurgeRequests };
@@ -0,0 +1,113 @@
1
+ import { changedFields as e } from "./history.js";
2
+ //#region src/editHistory.ts
3
+ var t = (e, t, n) => (Array.isArray(e) ? e : []).flatMap((e) => {
4
+ let r = e;
5
+ return typeof r == "object" && r && typeof r[t] == "string" ? [{
6
+ id: r[t],
7
+ name: String(r[n] ?? ""),
8
+ raw: JSON.stringify(r)
9
+ }] : [];
10
+ }), n = (e, t, n, r, i) => {
11
+ let a = new Map(e.map((e, t) => [e.id, t])), o = new Map(t.map((e, t) => [e.id, t])), s = t.find((e) => !a.has(e.id));
12
+ if (s !== void 0) return {
13
+ label: i.add(r(s)),
14
+ key: `add:${n}:${s.id}`
15
+ };
16
+ let c = e.find((e) => !o.has(e.id));
17
+ if (c !== void 0) return {
18
+ label: i.remove(r(c)),
19
+ key: `remove:${n}:${c.id}`
20
+ };
21
+ let l = t.flatMap((t, n) => e[n]?.id === t.id ? [] : [n]);
22
+ if (l.length === 2 && l[1] === l[0] + 1 && t[l[0]]?.id === e[l[1]]?.id) {
23
+ let [t, a] = [e[l[0]], e[l[1]]];
24
+ return {
25
+ label: i.swap(r(t), r(a)),
26
+ key: `move:${n}:${t.id}:${a.id}:${l[0]}`
27
+ };
28
+ }
29
+ let u = t.find((e, t) => (a.get(e.id) ?? t) > t);
30
+ if (u !== void 0) return {
31
+ label: i.moveUp(r(u)),
32
+ key: `move:${n}:${u.id}:${o.get(u.id)}`
33
+ };
34
+ let d = t.find((e, t) => (a.get(e.id) ?? t) < t);
35
+ if (d !== void 0) return {
36
+ label: i.moveDown(r(d)),
37
+ key: `move:${n}:${d.id}:${o.get(d.id)}`
38
+ };
39
+ let f = t.find((t) => t.raw !== e[a.get(t.id) ?? -1]?.raw);
40
+ return {
41
+ label: i.edit(f === void 0 ? i.fieldLabel(n) : r(f)),
42
+ key: `edit:${n}${f === void 0 ? "" : `:${f.id}`}`
43
+ };
44
+ }, r = (r, i, a, o) => {
45
+ let s = e(r, i, a);
46
+ if (s.length === 0) return null;
47
+ if (s.length > 1) return {
48
+ label: o.edit(s.map(o.fieldLabel).join(", ")),
49
+ key: `edit:${s.join(",")}`
50
+ };
51
+ let c = s[0], l = r[c];
52
+ if (l?.editorHint === "components") return n(t(i[c], "instanceId", "componentId"), t(a[c], "instanceId", "componentId"), c, (e) => o.componentLabel(e.name), o);
53
+ if (l?.editorHint === "richText") {
54
+ let e = (e) => t(e?.blocks, "id", "type"), r = n(e(i[c]), e(a[c]), c, (e) => o.blockLabel(e.name), o);
55
+ return r.key.startsWith("edit:") ? {
56
+ label: r.label,
57
+ key: `edit:${c}`
58
+ } : r;
59
+ }
60
+ return {
61
+ label: o.edit(o.fieldLabel(c)),
62
+ key: `edit:${c}`
63
+ };
64
+ }, i = {
65
+ past: [],
66
+ future: []
67
+ }, a = (e, t, n, r, i = {}) => {
68
+ let a = e.past[e.past.length - 1];
69
+ return a !== void 0 && a.key === n.key && r - a.at <= (i.mergeMs ?? 1500) ? {
70
+ past: [...e.past.slice(0, -1), {
71
+ ...a,
72
+ label: n.label,
73
+ at: r
74
+ }],
75
+ future: []
76
+ } : {
77
+ past: [...e.past, {
78
+ values: t,
79
+ label: n.label,
80
+ key: n.key,
81
+ at: r
82
+ }].slice(-(i.limit ?? 100)),
83
+ future: []
84
+ };
85
+ }, o = (e, t) => {
86
+ let n = e.past[e.past.length - 1];
87
+ return n === void 0 ? null : {
88
+ values: n.values,
89
+ label: n.label,
90
+ history: {
91
+ past: e.past.slice(0, -1),
92
+ future: [{
93
+ ...n,
94
+ values: t
95
+ }, ...e.future]
96
+ }
97
+ };
98
+ }, s = (e, t) => {
99
+ let n = e.future[0];
100
+ return n === void 0 ? null : {
101
+ values: n.values,
102
+ label: n.label,
103
+ history: {
104
+ past: [...e.past, {
105
+ ...n,
106
+ values: t
107
+ }],
108
+ future: e.future.slice(1)
109
+ }
110
+ };
111
+ };
112
+ //#endregion
113
+ export { i as EMPTY_EDIT_HISTORY, r as describeEdit, a as recordEdit, s as redoEdit, o as undoEdit };
@@ -0,0 +1,11 @@
1
+ import { Effect as e } from "effect";
2
+ //#region src/effectForm.ts
3
+ var t = (t, ...n) => {
4
+ let r = (e) => n.some((t) => e instanceof t);
5
+ return e.tryPromise({
6
+ try: t,
7
+ catch: (e) => e
8
+ }).pipe(e.catch((t) => r(t) ? e.fail(t) : e.die(t)));
9
+ };
10
+ //#endregion
11
+ export { t as asTyped };
@@ -0,0 +1,138 @@
1
+ import { EnvironmentAliasUnavailable as e } from "./errors.js";
2
+ import { asTyped as t } from "./effectForm.js";
3
+ import { and as n, eq as r, generateId as i, id as a, table as o, text as s } from "@voltro/database";
4
+ import { tenant as c } from "@voltro/plugin-multitenancy/mixin";
5
+ //#region src/environmentAliases.ts
6
+ var l = "cms_environment_aliases", u = "cms_environment_alias_revisions", d = o(l, {
7
+ id: a({ prefix: "ceal" }),
8
+ site: s().maxLength(64),
9
+ name: s().maxLength(64),
10
+ environment: s().maxLength(64),
11
+ revisionId: s().maxLength(64)
12
+ }).with(c()).unique("cms_environment_alias_scope", [
13
+ "tenantId",
14
+ "site",
15
+ "name"
16
+ ]), f = o(u, {
17
+ id: a({ prefix: "cear" }),
18
+ site: s().maxLength(64),
19
+ aliasId: s().maxLength(64),
20
+ environment: s().maxLength(64),
21
+ previousRevisionId: s().maxLength(64).nullable(),
22
+ action: s().oneOf([
23
+ "created",
24
+ "swapped",
25
+ "rolledBack"
26
+ ]),
27
+ sourceRevisionId: s().maxLength(64).nullable()
28
+ }).with(c()), p = (t) => {
29
+ throw new e({ reason: t });
30
+ }, m = (e) => typeof e == "string" && e.length > 0 && e.length <= 64 && e.trim() === e, h = (e) => typeof e == "string" && /^[a-z][a-z0-9_-]{0,63}$/.test(e), g = (e) => e === null || m(e), _ = (e) => !m(e.tenantId) || !m(e.site) ? p("scope") : n(r("tenantId", e.tenantId), r("site", e.site)), v = (e, t) => {
31
+ if (e.length === 0 || !e.every(h) || new Set(e).size !== e.length || !h(t) || !e.includes(t)) return p("target");
32
+ }, y = (e, t) => !m(e.id) || !h(e.name) || !m(e.revisionId) ? p("state") : (v(t, e.environment), {
33
+ id: e.id,
34
+ name: e.name,
35
+ environment: String(e.environment),
36
+ revisionId: e.revisionId
37
+ }), b = (e, t) => {
38
+ let n = i({
39
+ kind: "typeid",
40
+ prefix: e
41
+ }, t);
42
+ return n === null ? p("state") : String(n);
43
+ }, x = async (e, t, i, a) => {
44
+ let o = _(t);
45
+ if (!h(i)) return p("name");
46
+ let [s] = await e.query({
47
+ table: l,
48
+ predicate: n(o, r("name", i)),
49
+ ...a === void 0 ? {} : { lock: a },
50
+ order: [],
51
+ take: 1,
52
+ skip: void 0,
53
+ projection: void 0
54
+ });
55
+ return s === void 0 ? p("missing") : s;
56
+ }, S = async (e, t, n, r) => y(await x(e, t, r, "update"), n), C = async (e, t, n, r) => y(await x(e, t, r), n), w = async (e, t, n, r) => {
57
+ if (_(t), !h(r.name)) return p("name");
58
+ v(n, r.environment);
59
+ let i = b("ceal", l), a = b("cear", u);
60
+ await e.insertIgnore(l, {
61
+ id: i,
62
+ tenantId: t.tenantId,
63
+ site: t.site,
64
+ name: r.name,
65
+ environment: r.environment,
66
+ revisionId: a
67
+ }, { conflictColumns: [
68
+ "tenantId",
69
+ "site",
70
+ "name"
71
+ ] });
72
+ let o = await x(e, t, r.name, "update");
73
+ return o.id === i ? (await e.insert(u, {
74
+ id: a,
75
+ tenantId: t.tenantId,
76
+ site: t.site,
77
+ aliasId: i,
78
+ environment: r.environment,
79
+ previousRevisionId: null,
80
+ action: "created",
81
+ sourceRevisionId: null
82
+ }), y(o, n)) : p("conflict");
83
+ }, T = async (e, t, i, a) => {
84
+ if (!m(a)) return p("revision");
85
+ let o = await x(e, t, i), [s] = await e.query({
86
+ table: u,
87
+ predicate: n(_(t), r("aliasId", String(o.id)), r("id", a)),
88
+ order: [],
89
+ take: 1,
90
+ skip: void 0,
91
+ projection: void 0,
92
+ lock: "update"
93
+ });
94
+ return s === void 0 ? p("revision") : !m(s.id) || !m(s.aliasId) || !h(s.environment) || !g(s.previousRevisionId) || !g(s.sourceRevisionId) || ![
95
+ "created",
96
+ "swapped",
97
+ "rolledBack"
98
+ ].includes(String(s.action)) ? p("state") : {
99
+ id: s.id,
100
+ aliasId: s.aliasId,
101
+ environment: s.environment,
102
+ previousRevisionId: s.previousRevisionId,
103
+ action: s.action,
104
+ sourceRevisionId: s.sourceRevisionId
105
+ };
106
+ }, E = (e, t) => {
107
+ if (!m(t) || e.revisionId !== t) return p("conflict");
108
+ }, D = async (e, t, n, r, i, a) => {
109
+ let o = b("cear", u);
110
+ return await e.insert(u, {
111
+ id: o,
112
+ tenantId: t.tenantId,
113
+ site: t.site,
114
+ aliasId: n.id,
115
+ environment: r,
116
+ previousRevisionId: n.revisionId,
117
+ action: i,
118
+ sourceRevisionId: a
119
+ }), await e.update(l, n.id, {
120
+ environment: r,
121
+ revisionId: o
122
+ }), {
123
+ ...n,
124
+ environment: r,
125
+ revisionId: o
126
+ };
127
+ }, O = async (e, t, n, r, i) => {
128
+ v(n, i.environment);
129
+ let a = await S(e, t, n, r);
130
+ return E(a, i.expectedRevisionId), a.environment === i.environment ? a : D(e, t, a, i.environment, "swapped", null);
131
+ }, k = async (e, t, n, r, i) => {
132
+ let a = await S(e, t, n, r);
133
+ E(a, i.expectedRevisionId);
134
+ let o = await T(e, t, r, i.revisionId);
135
+ return v(n, o.environment), D(e, t, a, o.environment, "rolledBack", o.id);
136
+ }, A = (...n) => t(() => w(...n), e), j = (...n) => t(() => C(...n), e), M = (...n) => t(() => T(...n), e), N = (...n) => t(() => O(...n), e), P = (...n) => t(() => k(...n), e);
137
+ //#endregion
138
+ export { l as CMS_ENVIRONMENT_ALIASES_TABLE, u as CMS_ENVIRONMENT_ALIAS_REVISIONS_TABLE, f as cmsEnvironmentAliasRevisionsTable, d as cmsEnvironmentAliasesTable, w as createEnvironmentAlias, A as createEnvironmentAliasEffect, T as environmentAliasRevision, M as environmentAliasRevisionEffect, S as lockEnvironmentAlias, C as resolveEnvironmentAlias, j as resolveEnvironmentAliasEffect, k as rollbackEnvironmentAlias, P as rollbackEnvironmentAliasEffect, O as swapEnvironmentAlias, N as swapEnvironmentAliasEffect };