@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/write.js ADDED
@@ -0,0 +1,419 @@
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, ReviewRequired as o, RevisionMismatch as s } from "./errors.js";
3
+ import { seoPublishViolations as c } from "./publicationSeo.js";
4
+ import { templateViolations as l } from "./templates.js";
5
+ import { asTyped as u } from "./effectForm.js";
6
+ import { dropFromSearch as d, indexForSearch as f } from "./search.js";
7
+ import { applyDerivations as p, publishViolations as m, validateContent as h } from "./validation.js";
8
+ import { CMS_REVISIONS_TABLE as g, contentTypeToEntities as _ } from "./contentType.js";
9
+ import { lockPublicationStream as v, recordChange as y } from "./changes.js";
10
+ import { recordPublicationPaths as b } from "./redirects.js";
11
+ import { clearReferences as x, hasReferenceFields as S, writeReferences as C, writeRevisionReferences as w } from "./references.js";
12
+ import { pickDeclared as ee } from "./contentValues.js";
13
+ import { withPublicRouteMutation as T } from "./publicRouteMutation.js";
14
+ import { publicationRouteScope as E, reconcilePublishedContentRoutes as D } from "./publicRoutePublication.js";
15
+ import { assertApproved as O } from "./review.js";
16
+ import { qualityViolations as k } from "./quality.js";
17
+ import { assertReferencesAvailable as A, writeAvailability as te } from "./availability.js";
18
+ import { changedFields as ne } from "./history.js";
19
+ import { changedApartFromShared as re, liveDraftTexts as ie, openNewBlockTexts as ae, readDraftTexts as oe, rebaseDraftTexts as se, richBlockOfKey as j, setDraftText as M, typeDraftText as ce, withSharedBlocks as le } from "./draftTexts.js";
20
+ import { startStewardship as ue } from "./stewardship.js";
21
+ import { and as N, eq as P, generateId as F, neq as de } from "@voltro/database";
22
+ import { revalidatePath as fe, revalidateTag as pe } from "@voltro/runtime";
23
+ //#region src/write.ts
24
+ var I = (e) => `${e.name}_drafts`, L = (e) => `${e.name}_published`, R = (e) => ({
25
+ site: e.site,
26
+ environment: e.environment,
27
+ locale: e.locale
28
+ }), z = (e) => [
29
+ P("site", e.site),
30
+ P("environment", e.environment),
31
+ P("locale", e.locale)
32
+ ], B = (e, t, n, r) => ({
33
+ table: e,
34
+ predicate: r === void 0 ? P("id", t) : N(P("id", t), ...z(r)),
35
+ order: [],
36
+ take: 1,
37
+ skip: void 0,
38
+ projection: void 0,
39
+ ...n === !0 ? { crossTenant: !0 } : {}
40
+ }), V = async (e, t, n, r, i) => (await e.query({
41
+ ...B(t, n, !1, r),
42
+ ...i === void 0 ? {} : { lock: i }
43
+ }))[0], H = async (e, n, r) => {
44
+ let i = n.tenantId;
45
+ if (typeof i != "string" || i === "") throw new t({ reason: "scope" });
46
+ await v(e, {
47
+ tenantId: i,
48
+ site: r.site,
49
+ environment: r.environment
50
+ });
51
+ }, U = async (e, t, n, r, a) => {
52
+ let o = t.tree;
53
+ if (o === void 0) return;
54
+ let s = Object.entries(o.inherit ?? {}).filter(([e, t]) => t.locked === !0 && n[e] !== void 0 && n[e] !== null && n[e] !== "");
55
+ if (s.length > 0) throw new i({
56
+ contentType: t.name,
57
+ violations: s.map(([e]) => ({
58
+ field: e,
59
+ rule: "locked",
60
+ message: `${e} is set for the whole site and cannot be changed on a page`
61
+ }))
62
+ });
63
+ let c = Object.entries(o.inherit ?? {}).filter(([e, t]) => t.mask !== void 0 && n[t.mask] === !0 && n[e] !== void 0 && n[e] !== null && n[e] !== "");
64
+ if (c.length > 0) throw new i({
65
+ contentType: t.name,
66
+ violations: c.map(([e, t]) => ({
67
+ field: e,
68
+ rule: "maskedAndSet",
69
+ message: `${e} is masked (${t.mask}) — clear the mask or the value`
70
+ }))
71
+ });
72
+ let l = n[o.parent];
73
+ if (typeof l != "string" || l === "") return;
74
+ let u = (e, n) => {
75
+ throw new i({
76
+ contentType: t.name,
77
+ violations: [{
78
+ field: o.parent,
79
+ rule: e,
80
+ message: n
81
+ }]
82
+ });
83
+ }, d = async (n) => {
84
+ let r = await e.query({
85
+ table: I(t),
86
+ predicate: N(P("documentId", n), P("site", a.site), P("environment", a.environment)),
87
+ order: [],
88
+ take: void 0,
89
+ skip: void 0,
90
+ projection: void 0
91
+ });
92
+ return r.find((e) => e.locale === a.locale) ?? r[0];
93
+ }, f = /* @__PURE__ */ new Set(), p = l;
94
+ for (; p !== null && !f.has(p);) {
95
+ p === r && u("cycle", "the parent is this page or one of its descendants"), f.add(p);
96
+ let e = await d(p);
97
+ if (e === void 0) {
98
+ p === l && u("unknown", `no ${t.name} document '${l}'`);
99
+ return;
100
+ }
101
+ let n = e[o.parent];
102
+ p = typeof n == "string" && n !== "" ? n : null;
103
+ }
104
+ }, W = () => {
105
+ let e = F({
106
+ kind: "typeid",
107
+ prefix: "cdoc"
108
+ }, g);
109
+ if (e === null) throw Error("[voltro cms] the document id scheme did not mint an id.");
110
+ return e;
111
+ }, G = /* @__PURE__ */ new WeakMap(), K = (e) => {
112
+ let t = G.get(e);
113
+ t === void 0 && (t = _(e).draft.fields.id.idScheme, G.set(e, t));
114
+ let n = t === void 0 ? null : F(t, I(e));
115
+ if (n === null) throw Error(`[voltro cms] '${e.name}': the drafts table's id scheme does not mint ids up front.`);
116
+ return n;
117
+ }, q = async (e, t, n, r, i, a, o, s = null) => {
118
+ let c = await e.insert(g, {
119
+ contentType: t.name,
120
+ documentId: n,
121
+ number: r,
122
+ ...R(a),
123
+ values: i,
124
+ basedOn: s,
125
+ ...o == null ? {} : { tenantId: o }
126
+ });
127
+ return await w(e, t, c, a), c;
128
+ }, J = (e, t, n, r) => e.query({
129
+ table: g,
130
+ predicate: N(P("contentType", t.name), P("documentId", n), ...z(r)),
131
+ order: [{
132
+ column: "number",
133
+ direction: "desc"
134
+ }],
135
+ take: void 0,
136
+ skip: void 0,
137
+ projection: void 0
138
+ }), me = async (e, t) => {
139
+ if (typeof t != "string" || t === "") return null;
140
+ let [n] = await e.query({
141
+ table: g,
142
+ predicate: P("id", t),
143
+ order: [],
144
+ take: 1,
145
+ skip: void 0,
146
+ projection: void 0
147
+ });
148
+ return typeof n?.basedOn == "string" ? n.basedOn : null;
149
+ }, Y = async (e, t, n, r, a, o, s) => {
150
+ let c = [];
151
+ for (let [i, l] of Object.entries(t.fields)) {
152
+ let t = r[i];
153
+ l.unique === !0 && typeof t == "string" && t !== "" && (await e.query({
154
+ table: n,
155
+ predicate: N(P(i, t), de("id", a), P("site", s.site), P("environment", s.environment), P("locale", s.locale), ...typeof o == "string" ? [P("tenantId", o)] : []),
156
+ order: [],
157
+ take: 1,
158
+ skip: void 0,
159
+ projection: ["id"]
160
+ })).length > 0 && c.push({
161
+ field: i,
162
+ rule: "unique",
163
+ message: `${i} '${t}' is already used by another entry`
164
+ });
165
+ }
166
+ if (c.length > 0) throw new i({
167
+ contentType: t.name,
168
+ violations: c
169
+ });
170
+ }, he = async (e, t, n, r, i) => {
171
+ if (i === void 0 || i.values.size === 0) return !1;
172
+ let [a] = await e.query({
173
+ table: g,
174
+ predicate: P("id", n),
175
+ order: [],
176
+ take: 1,
177
+ skip: void 0,
178
+ projection: void 0
179
+ });
180
+ return a !== void 0 && re(t, a.values ?? {}, r, i.values.keys()).length === 0;
181
+ }, X = async (e, t, a, o, c = {}) => {
182
+ let u = c.collaborative === !0 && typeof a.id == "string" ? await V(e, I(t), a.id, o) : void 0;
183
+ if (u !== void 0) {
184
+ let t = new Set((await oe(e, String(u.id))).map((e) => String(e.id)));
185
+ for (let n of c.texts ?? []) t.has(n.id) && await ce(e, n.id, n.update);
186
+ }
187
+ let d = u === void 0 ? void 0 : await ie(e, u), m = u === void 0 ? void 0 : c.expectedRevision === void 0 || c.expectedRevision === u.revisionId ? u : (await e.query({
188
+ table: g,
189
+ predicate: P("id", c.expectedRevision),
190
+ order: [],
191
+ take: 1,
192
+ skip: void 0,
193
+ projection: void 0
194
+ }))[0]?.values, _ = (e) => typeof e == "string" ? e : "", v = (e, t) => typeof a[e] == "string" && m !== void 0 && a[e] !== _(m[e]) && t === _(u?.[e]) && _(u?.[e]) === _(m[e]), y = d === void 0 ? [] : [...d.values].filter(([e, t]) => j(e) === null && (t !== "" || typeof u?.[e] == "string") && !v(e, t)), b = d === void 0 ? {
195
+ values: {},
196
+ typedBefore: []
197
+ } : le(t, a, d.values, {
198
+ current: u,
199
+ seen: m
200
+ }), x = p(t, {
201
+ ...a,
202
+ ...Object.fromEntries(y),
203
+ ...b.values
204
+ });
205
+ h(t, x);
206
+ let w = l(t, x);
207
+ if (w.length > 0) throw new i({
208
+ contentType: t.name,
209
+ violations: [...w]
210
+ });
211
+ let T = I(t), E = ee(t, x), D = async (n, r) => {
212
+ await U(e, t, E, r, o), await Y(e, t, T, E, n, void 0, o);
213
+ let i = await q(e, t, r, 1, E, o, void 0, c.basedOn ?? null), a = await e.insert(T, {
214
+ ...E,
215
+ id: n,
216
+ documentId: r,
217
+ ...R(o),
218
+ status: "draft",
219
+ revisionId: i.id,
220
+ revision: 1
221
+ });
222
+ return await f(e, t, a, o, "draft"), S(t) && await C(e, t, a, o, "draft"), a;
223
+ }, O = x.id, k = x.documentId;
224
+ if (O === void 0) {
225
+ if (k === void 0) return D(K(t), W());
226
+ let i = await e.query({
227
+ table: T,
228
+ predicate: P("documentId", k),
229
+ order: [],
230
+ take: void 0,
231
+ skip: void 0,
232
+ projection: void 0
233
+ });
234
+ if (i.length === 0) throw new r({
235
+ contentType: t.name,
236
+ id: k,
237
+ stage: "draft"
238
+ });
239
+ let a = i.find((e) => e.site === o.site && e.environment === o.environment && e.locale === o.locale);
240
+ if (a !== void 0) throw new n({
241
+ contentType: t.name,
242
+ id: a.id
243
+ });
244
+ return D(K(t), k);
245
+ }
246
+ let A = await V(e, T, O, o);
247
+ if (A !== void 0) {
248
+ if (c.expectedRevision !== void 0 && A.revisionId !== c.expectedRevision && !await he(e, t, c.expectedRevision, A, d)) throw new s({
249
+ contentType: t.name,
250
+ id: O,
251
+ expected: c.expectedRevision,
252
+ actual: String(A.revisionId)
253
+ });
254
+ if (c.basedOn === void 0 && A.status !== "archived" && ne(t.fields, A, E).length === 0) return A;
255
+ let n = Number(A.revision) + 1, r = A.documentId;
256
+ await U(e, t, E, r, o), await Y(e, t, T, E, O, A.tenantId, o);
257
+ let i = c.basedOn ?? await me(e, A.revisionId), l = await q(e, t, r, n, E, o, A.tenantId, i), u = await e.update(T, O, {
258
+ ...E,
259
+ status: "draft",
260
+ revisionId: l.id,
261
+ revision: n
262
+ });
263
+ if (d !== void 0) {
264
+ let n = new Map(b.typedBefore.map((e) => [e.key, e.markup]));
265
+ for (let t of d.rows) {
266
+ let r = String(t.field), i = n.get(r);
267
+ i === void 0 ? j(r) === null && v(r, d.values.get(r) ?? "") && await M(e, String(t.id), String(a[r])) : await M(e, String(t.id), i);
268
+ }
269
+ await se(e, d.rows, String(l.id)), await ae(e, t, String(A.id));
270
+ }
271
+ return await f(e, t, u ?? A, o, "draft"), S(t) && await C(e, t, u ?? A, o, "draft"), u ?? A;
272
+ }
273
+ if ((await e.query(B(T, O, !0))).length > 0) throw new n({
274
+ contentType: t.name,
275
+ id: O
276
+ });
277
+ return D(O, k ?? W());
278
+ }, Z = async (e, t, n, i, a) => {
279
+ let o = await V(e, I(t), n, i);
280
+ if (o === void 0) throw new r({
281
+ contentType: t.name,
282
+ id: n,
283
+ stage: "draft"
284
+ });
285
+ let [s] = await e.query({
286
+ table: g,
287
+ predicate: N(P("id", a), P("contentType", t.name), P("documentId", o.documentId), ...z(i)),
288
+ order: [],
289
+ take: 1,
290
+ skip: void 0,
291
+ projection: void 0
292
+ });
293
+ if (s === void 0) throw new r({
294
+ contentType: t.name,
295
+ id: a,
296
+ stage: "revision"
297
+ });
298
+ let c = s.values ?? {}, l = { id: n };
299
+ for (let e of Object.keys(t.fields)) l[e] = e in c ? c[e] : null;
300
+ return X(e, t, l, i);
301
+ }, ge = (e) => {
302
+ let t = e.revalidate;
303
+ if (t !== void 0) {
304
+ for (let n of t.paths ?? []) fe(n).catch((t) => {
305
+ console.warn(`[voltro cms] revalidatePath('${n}') for '${e.name}' failed:`, t);
306
+ });
307
+ for (let n of t.tags ?? []) pe(n).catch((t) => {
308
+ console.warn(`[voltro cms] revalidateTag('${n}') for '${e.name}' failed:`, t);
309
+ });
310
+ }
311
+ }, _e = async (e, t, n, i, a = {}) => {
312
+ let o = await V(e, I(t), n, i);
313
+ if (o === void 0 || (await H(e, o, i), o = await V(e, I(t), n, i, "update"), o === void 0)) throw new r({
314
+ contentType: t.name,
315
+ id: n,
316
+ stage: "draft"
317
+ });
318
+ let c = o.revisionId;
319
+ if (a.revisionId !== void 0 && a.revisionId !== c) throw new s({
320
+ contentType: t.name,
321
+ id: n,
322
+ expected: a.revisionId,
323
+ actual: c
324
+ });
325
+ return Q(e, t, n, i, c);
326
+ }, Q = async (e, t, n, a, o, s = {}) => {
327
+ let l = await V(e, I(t), n, a);
328
+ if (l === void 0 || (await H(e, l, a), l = await V(e, I(t), n, a, "update"), l === void 0)) throw new r({
329
+ contentType: t.name,
330
+ id: n,
331
+ stage: "draft"
332
+ });
333
+ return T(e, E(l, a), (t.locations?.length ?? 0) > 0, async () => {
334
+ let [u] = await e.query({
335
+ table: g,
336
+ lock: "update",
337
+ predicate: N(P("id", o), P("contentType", t.name), P("documentId", l.documentId), ...z(a)),
338
+ order: [],
339
+ take: 1,
340
+ skip: void 0,
341
+ projection: void 0
342
+ });
343
+ if (u === void 0) throw new r({
344
+ contentType: t.name,
345
+ id: o,
346
+ stage: "revision"
347
+ });
348
+ let d = m(t, u.values ?? {}), p = await k(e, t, n, a, u.values ?? {}), h = c(t, u.values ?? {}, a);
349
+ if (d.length + p.length + h.length > 0) throw new i({
350
+ contentType: t.name,
351
+ violations: [
352
+ ...d,
353
+ ...p,
354
+ ...h
355
+ ]
356
+ });
357
+ await O(e, t, n, a, o), await A(e, t, n, u.values ?? {}, a);
358
+ let _ = L(t), v = {
359
+ ...ee(t, u.values ?? {}),
360
+ documentId: l.documentId,
361
+ revisionId: o,
362
+ revision: u.number
363
+ };
364
+ await Y(e, t, _, v, n, l.tenantId, a);
365
+ let x = await V(e, _, n, a, "update"), w;
366
+ if (x !== void 0) w = await e.update(_, n, {
367
+ ...v,
368
+ status: "published"
369
+ }) ?? x;
370
+ else {
371
+ let t = l.tenantId;
372
+ w = await e.insert(_, {
373
+ ...v,
374
+ id: n,
375
+ ...R(a),
376
+ status: "published",
377
+ ...t == null ? {} : { tenantId: t }
378
+ });
379
+ }
380
+ return l.revisionId === o && (await e.update(I(t), n, { status: "published" }), l.status === "archived" && S(t) && await C(e, t, l, a, "draft")), await C(e, t, w, a), await te(e, t, w, a), await b(e, t, a, w.tenantId), await ue(e, t, String(l.documentId), a, w.tenantId), await y(e, t, w, a, "published", s), await f(e, t, w, a, "published"), await D(e, t, w, a), w;
381
+ });
382
+ }, ve = async (e, t, n, i, a = {}) => {
383
+ let o = await V(e, L(t), n, i);
384
+ if (o === void 0 || (await H(e, o, i), o = await V(e, L(t), n, i, "update"), o === void 0)) throw new r({
385
+ contentType: t.name,
386
+ id: n,
387
+ stage: "published"
388
+ });
389
+ return T(e, E(o, i), (t.locations?.length ?? 0) > 0, async () => {
390
+ await y(e, t, o, i, "unpublished", a), await e.delete(L(t), n), await x(e, t, n, i), await d(e, t, n, ["published"]);
391
+ let r = await V(e, I(t), n, i);
392
+ r !== void 0 && (await e.update(I(t), n, { status: "draft" }), r.status === "archived" && S(t) && await C(e, t, r, i, "draft")), await D(e, t, o, i);
393
+ });
394
+ }, ye = async (e, t, n, i) => {
395
+ let a = await V(e, I(t), n, i), o = await V(e, L(t), n, i);
396
+ if (a === void 0 && o === void 0 || (await H(e, o ?? a, i), a = await V(e, I(t), n, i, "update"), o = await V(e, L(t), n, i, "update"), a === void 0 && o === void 0)) throw new r({
397
+ contentType: t.name,
398
+ id: n,
399
+ stage: "draft"
400
+ });
401
+ return T(e, E(o ?? a, i), (t.locations?.length ?? 0) > 0, async () => {
402
+ o !== void 0 && o.status !== "archived" && await y(e, t, o, i, "unpublished"), a !== void 0 && await e.update(I(t), n, { status: "archived" }), a !== void 0 && S(t) && await x(e, t, n, i, "draft"), o !== void 0 && (await e.update(L(t), n, { status: "archived" }), await x(e, t, n, i)), await d(e, t, n, ["draft", "published"]), o !== void 0 && await D(e, t, o, i);
403
+ });
404
+ }, be = [
405
+ i,
406
+ n,
407
+ r,
408
+ s
409
+ ], $ = [
410
+ r,
411
+ s,
412
+ o,
413
+ a,
414
+ i,
415
+ t,
416
+ e
417
+ ], xe = (e, t, n, r, i = {}) => u(() => X(e, t, n, r, i), ...be), Se = (e, t, n, a, o) => u(() => Z(e, t, n, a, o), i, r), Ce = (e, t, n, r, i = {}) => u(() => _e(e, t, n, r, i), ...$), we = (e, t, n, r, i, a = {}) => u(() => Q(e, t, n, r, i, a), ...$), Te = (n, i, a, o) => u(() => ve(n, i, a, o), r, t, e), Ee = (n, i, a, o) => u(() => ye(n, i, a, o), r, t, e), De = (...e) => u(() => J(...e));
418
+ //#endregion
419
+ export { ye as archive, Ee as archiveEffect, J as listRevisions, De as listRevisionsEffect, K as newVariantId, _e as publish, Ce as publishEffect, Q as publishRevision, we as publishRevisionEffect, Z as restoreRevision, Se as restoreRevisionEffect, ge as revalidateContent, X as saveDraft, xe as saveDraftEffect, R as scopeColumns, ve as unpublish, Te as unpublishEffect, q as writeRevision };