@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,338 @@
1
+ import { StaticPathSetConflict as e, StaticPathSetUnavailable as t, copyStaticPathContext as n, copyStaticPathEntry as r, signStaticPathSet as i, staticPathHash as a, staticPathUrl as o, verifyStaticPathPage as s, verifyStaticPathSet as c } from "./staticPathSet.js";
2
+ import { and as l, eq as u, generateId as d, id as f, integer as p, json as m, table as h, text as g } from "@voltro/database";
3
+ import { tenant as _ } from "@voltro/plugin-multitenancy/mixin";
4
+ import { createHash as v, createHmac as y, timingSafeEqual as b } from "node:crypto";
5
+ import { canonicalJson as x } from "@voltro/runtime";
6
+ //#region src/staticPathSetStore.ts
7
+ var S = "_voltro_cms_static_path_sets", C = "_voltro_cms_static_path_pages", w = h(S, {
8
+ id: f({ prefix: "cpaths" }),
9
+ site: g().maxLength(64),
10
+ environment: g().maxLength(64),
11
+ contextDigest: g().maxLength(64),
12
+ context: m(),
13
+ progress: m(),
14
+ sealed: m().nullable()
15
+ }).with(_()).unique("cms_static_path_set_context", [
16
+ "tenantId",
17
+ "site",
18
+ "environment",
19
+ "contextDigest"
20
+ ]), T = h(C, {
21
+ id: f({ prefix: "cpathpg" }),
22
+ site: g().maxLength(64),
23
+ environment: g().maxLength(64),
24
+ setId: g().maxLength(64),
25
+ kind: g().oneOf([
26
+ "input",
27
+ "stage",
28
+ "output"
29
+ ]),
30
+ ordinal: p(),
31
+ value: m(),
32
+ digest: g().maxLength(64)
33
+ }).with(_()).unique("cms_static_path_page", [
34
+ "tenantId",
35
+ "setId",
36
+ "kind",
37
+ "ordinal"
38
+ ]), E = Object.freeze([w, T]), D = (e) => {
39
+ throw new t({ reason: e });
40
+ }, O = (e) => typeof e == "string" && /^[A-Za-z0-9_-]{1,64}$/.test(e), k = (e) => typeof e == "string" && /^[a-f0-9]{64}$/.test(e), A = (e) => typeof e != "object" || !e || Array.isArray(e) ? D("state") : e, j = (e) => l(u("tenantId", e.tenantId), u("site", e.site), u("environment", e.environment)), M = (e) => {
41
+ let t = A(e);
42
+ return Object.keys(t).sort().join(",") !== "after,chain,codeIndex,inputBytes,inputCount,inputPages,phase,revision,version" || t.version !== 1 || ![
43
+ "cms",
44
+ "code",
45
+ "seal",
46
+ "ready"
47
+ ].includes(String(t.phase)) || !(t.after === null || O(t.after)) || !k(t.chain) || ![
48
+ "codeIndex",
49
+ "inputBytes",
50
+ "inputCount",
51
+ "inputPages",
52
+ "revision"
53
+ ].every((e) => Number.isSafeInteger(t[e]) && Number(t[e]) >= 0) || Number(t.codeIndex) > 4096 || Number(t.inputCount) > 1e5 || Number(t.inputPages) > 1e5 || Number(t.inputBytes) > 67108864 || Number(t.revision) > 1e5 ? D("state") : { ...t };
54
+ }, N = (e, t, n) => {
55
+ if (!O(e.id) || e.contextDigest !== a(t) || x(e.context) !== x(t)) return D("changed");
56
+ let r = M(e.progress), i = e.sealed === null ? null : c(e.sealed, n);
57
+ return i !== null != (r.phase === "ready") || i !== null && x(i.manifest.context) !== x(t) ? D("state") : {
58
+ id: e.id,
59
+ context: t,
60
+ progress: r,
61
+ sealed: i
62
+ };
63
+ }, P = async (e, t, r, i, a = !1) => {
64
+ let o = n(t);
65
+ if (!O(r)) return D("input");
66
+ let [s] = await e.query({
67
+ table: S,
68
+ predicate: l(j(o), u("id", r)),
69
+ ...a ? { lock: "update" } : {},
70
+ order: [],
71
+ take: 1,
72
+ skip: void 0,
73
+ projection: void 0
74
+ });
75
+ if (s === void 0) return D("state");
76
+ let c = N(s, o, i);
77
+ return await L(e, c, i), c;
78
+ }, F = async (e, t, r) => {
79
+ let i = n(t), o = a(i), s = d({
80
+ kind: "typeid",
81
+ prefix: "cpaths"
82
+ }, S);
83
+ if (s === null) return D("state");
84
+ let c = {
85
+ version: 1,
86
+ phase: "cms",
87
+ after: null,
88
+ codeIndex: 0,
89
+ revision: 0,
90
+ inputPages: 0,
91
+ inputCount: 0,
92
+ inputBytes: 0,
93
+ chain: a({ context: i })
94
+ };
95
+ await e.insertIgnore(S, {
96
+ id: s,
97
+ tenantId: i.tenantId,
98
+ site: i.site,
99
+ environment: i.environment,
100
+ contextDigest: o,
101
+ context: i,
102
+ progress: c,
103
+ sealed: null
104
+ }, { conflictColumns: [
105
+ "tenantId",
106
+ "site",
107
+ "environment",
108
+ "contextDigest"
109
+ ] });
110
+ let [f] = await e.query({
111
+ table: S,
112
+ predicate: l(j(i), u("contextDigest", o)),
113
+ lock: "update",
114
+ order: [],
115
+ take: 1,
116
+ skip: void 0,
117
+ projection: void 0
118
+ });
119
+ if (f === void 0) return D("state");
120
+ let p = N(f, i, r);
121
+ return await L(e, p, r), p;
122
+ }, I = (e, t) => !O(t.id) || !(t.material instanceof Uint8Array) || t.material.byteLength < 32 ? D("key") : y("sha256", t.material).update(x({
123
+ purpose: "voltro.cms.static-path-stage/v1",
124
+ value: e,
125
+ keyId: t.id
126
+ })).digest("hex"), L = async (e, t, n) => {
127
+ if (t.progress.revision === 0) {
128
+ let e = {
129
+ version: 1,
130
+ phase: "cms",
131
+ after: null,
132
+ codeIndex: 0,
133
+ revision: 0,
134
+ inputPages: 0,
135
+ inputCount: 0,
136
+ inputBytes: 0,
137
+ chain: a({ context: t.context })
138
+ };
139
+ return x(t.progress) !== x(e) || t.sealed !== null ? D("integrity") : void 0;
140
+ }
141
+ let r = A(await R(e, t, "stage", t.progress.revision)), i = A(r.body), o = n.find((e) => e.id === r.keyId), s = {
142
+ ...t.progress,
143
+ chain: "",
144
+ ...t.sealed === null ? {} : { phase: "seal" }
145
+ };
146
+ if (o === void 0 || !k(r.signature) || i.setId !== t.id || i.contextDigest !== a(t.context) || a(i) !== t.progress.chain || x(i.next) !== x(s) || !b(Buffer.from(I(i, o), "hex"), Buffer.from(r.signature, "hex"))) return D("integrity");
147
+ }, R = async (e, t, n, r) => {
148
+ let [i] = await e.query({
149
+ table: C,
150
+ predicate: l(j(t.context), u("setId", t.id), u("kind", n), u("ordinal", r)),
151
+ order: [],
152
+ take: 1,
153
+ skip: void 0,
154
+ projection: void 0
155
+ });
156
+ return i === void 0 || i.digest !== a(i.value) ? D("integrity") : i.value;
157
+ }, z = (e, t, n, r, i) => e.insert(C, {
158
+ tenantId: t.context.tenantId,
159
+ site: t.context.site,
160
+ environment: t.context.environment,
161
+ setId: t.id,
162
+ kind: n,
163
+ ordinal: r,
164
+ value: i,
165
+ digest: a(i)
166
+ }), B = async (e, t, n, i, o) => {
167
+ if (t.sealed !== null || !k(n.receiptDigest) || n.source.length === 0 || n.source.length > 2048 || n.entries.length > 1e4) return D("input");
168
+ if (t.progress.phase === "seal" || t.progress.phase === "ready" || n.next.phase === "ready" || t.progress.phase === "cms" && (n.next.codeIndex !== 0 || n.next.phase === "cms" && (n.next.after === null || n.next.after === t.progress.after) || n.next.phase !== "cms" && n.next.after !== null) || t.progress.phase === "code" && (n.next.phase === "cms" || n.next.after !== null || n.next.codeIndex !== t.progress.codeIndex + 1)) return D("state");
169
+ let s = n.entries.map(r), c = t.progress.revision + 1;
170
+ if (s.some((e) => e.host !== t.context.host || !t.context.localeIds.includes(e.localeId) || !t.context.owners.includes(e.owner))) return D("input");
171
+ let l = Buffer.byteLength(x(s)), u = M({
172
+ ...t.progress,
173
+ ...n.next,
174
+ revision: c,
175
+ inputPages: t.progress.inputPages + Math.ceil(s.length / 200),
176
+ inputCount: t.progress.inputCount + s.length,
177
+ inputBytes: t.progress.inputBytes + l
178
+ }), d = {
179
+ contextDigest: a(t.context),
180
+ setId: t.id,
181
+ revision: c,
182
+ source: n.source,
183
+ receiptDigest: n.receiptDigest,
184
+ previous: t.progress.chain,
185
+ pages: Array.from({ length: Math.ceil(s.length / 200) }, (e, t) => a(s.slice(t * 200, (t + 1) * 200))),
186
+ next: {
187
+ ...u,
188
+ chain: ""
189
+ }
190
+ }, f = a(d), p = {
191
+ ...u,
192
+ chain: f
193
+ }, m = await P(e, t.context, t.id, o, !0);
194
+ if (m.progress.revision >= c) {
195
+ let t = A(await R(e, m, "stage", c));
196
+ return a(t.body) === f ? m : D("changed");
197
+ }
198
+ if (x(m.progress) !== x(t.progress)) return D("changed");
199
+ for (let n = 0; n < d.pages.length; n++) await z(e, m, "input", t.progress.inputPages + n + 1, s.slice(n * 200, (n + 1) * 200));
200
+ return await z(e, m, "stage", c, {
201
+ body: d,
202
+ keyId: i.id,
203
+ signature: I(d, i)
204
+ }), await e.update(S, t.id, { progress: p }), {
205
+ ...m,
206
+ progress: p
207
+ };
208
+ }, V = async (t, n, s, c) => {
209
+ let l = await P(t, n.context, n.id, c, !0);
210
+ if (l.sealed !== null) return l;
211
+ if (l.progress.phase !== "seal" || x(l.progress) !== x(n.progress)) return D("changed");
212
+ let u = [], d = v("sha256"), f = a({ context: l.context }), p = 0, m = 0;
213
+ for (let e = 1; e <= l.progress.revision; e++) {
214
+ let n = A(await R(t, l, "stage", e)), i = A(n.body), o = c.find((e) => e.id === n.keyId);
215
+ if (o === void 0 || !k(n.signature) || !b(Buffer.from(I(i, o), "hex"), Buffer.from(n.signature, "hex")) || i.contextDigest !== a(l.context) || i.setId !== l.id || i.revision !== e || i.previous !== f || !Array.isArray(i.pages) || i.pages.length > 50 || i.pages.some((e) => !k(e))) return D("integrity");
216
+ f = a(i), d.update(x({
217
+ source: i.source,
218
+ receiptDigest: i.receiptDigest,
219
+ pages: i.pages
220
+ }) + "\n");
221
+ let s = [];
222
+ for (let e of i.pages) {
223
+ let n = await R(t, l, "input", ++p);
224
+ if (!Array.isArray(n) || n.length < 1 || n.length > 200 || a(n) !== e) return D("integrity");
225
+ s.push(...n.map(r));
226
+ }
227
+ if (m += Buffer.byteLength(x(s)), u.length + s.length > 1e5 || m > 67108864) return D("bounds");
228
+ u.push(...s);
229
+ }
230
+ if (f !== l.progress.chain || p !== l.progress.inputPages || u.length !== l.progress.inputCount || m !== l.progress.inputBytes) return D("integrity");
231
+ let h = u.map((e) => ({
232
+ entry: e,
233
+ url: o(e.host, e.path)
234
+ })).sort((e, t) => e.url < t.url ? -1 : +(e.url > t.url));
235
+ for (let t = 0; t < h.length; t++) {
236
+ let n = h[t];
237
+ if (n.entry.host !== l.context.host || !l.context.localeIds.includes(n.entry.localeId) || !l.context.owners.includes(n.entry.owner)) return D("integrity");
238
+ if (t > 0 && h[t - 1].url === n.url) throw new e({
239
+ url: n.url,
240
+ owners: [h[t - 1].entry, n.entry].map((e) => `${e.owner}:${e.file ?? e.routeId}`),
241
+ repair: "Change the captured location or native path enumeration and capture a new build snapshot."
242
+ });
243
+ }
244
+ let g = [];
245
+ for (let e = 0; e < h.length; e += 200) {
246
+ let n = h.slice(e, e + 200), r = n.map((e) => e.entry);
247
+ g.push({
248
+ count: r.length,
249
+ digest: a(r),
250
+ first: n[0].url,
251
+ last: n[n.length - 1].url
252
+ }), await z(t, l, "output", g.length, r);
253
+ }
254
+ let _ = i({
255
+ version: 1,
256
+ context: l.context,
257
+ sort: "host-nfc-path/v1",
258
+ pageSize: 200,
259
+ count: h.length,
260
+ sources: {
261
+ count: l.progress.revision,
262
+ digest: d.digest("hex")
263
+ },
264
+ pages: g
265
+ }, s), y = {
266
+ ...l.progress,
267
+ phase: "ready"
268
+ };
269
+ return await t.update(S, l.id, {
270
+ progress: y,
271
+ sealed: _
272
+ }), {
273
+ ...l,
274
+ progress: y,
275
+ sealed: _
276
+ };
277
+ }, H = async (e, t, n, r, i) => {
278
+ let a = await P(e, t, n, i);
279
+ if (a.sealed === null || !Number.isSafeInteger(r) || r < 0 || r > a.sealed.manifest.pages.length) return D("state");
280
+ if (a.sealed.manifest.count > 0 && r >= a.sealed.manifest.pages.length) return D("bounds");
281
+ if (a.sealed.manifest.count === 0 && r === 0) return {
282
+ set: a.sealed,
283
+ index: r,
284
+ entries: [],
285
+ next: null
286
+ };
287
+ let o = s(a.sealed, r, await R(e, a, "output", r + 1));
288
+ return {
289
+ set: a.sealed,
290
+ index: r,
291
+ entries: o,
292
+ next: r + 1 < a.sealed.manifest.pages.length ? r + 1 : null
293
+ };
294
+ }, U = async (e, t, r, i) => {
295
+ if (typeof t != "object" || !t || Array.isArray(t) || !O(t.tenantId) || !O(t.site) || !O(t.environment) || !O(r?.id) || !k(r?.digest)) return D("input");
296
+ let a = {
297
+ tenantId: t.tenantId,
298
+ site: t.site,
299
+ environment: t.environment
300
+ }, [o] = await e.query({
301
+ table: S,
302
+ predicate: l(j(a), u("id", r.id)),
303
+ order: [],
304
+ take: 1,
305
+ skip: void 0,
306
+ projection: void 0
307
+ });
308
+ if (o === void 0) return D("state");
309
+ let c = n(o.context);
310
+ if (c.tenantId !== a.tenantId || c.site !== a.site || c.environment !== a.environment) return D("changed");
311
+ let d = await P(e, c, r.id, i), f = d.sealed;
312
+ if (f === null) return D("state");
313
+ if (f.id !== r.digest) return D("changed");
314
+ let p = await e.query({
315
+ table: C,
316
+ predicate: l(j(a), u("setId", r.id), u("kind", "output")),
317
+ order: [{
318
+ column: "ordinal",
319
+ direction: "asc"
320
+ }],
321
+ take: f.manifest.pages.length + 1,
322
+ skip: void 0,
323
+ projection: ["ordinal"]
324
+ });
325
+ if (p.length !== f.manifest.pages.length || p.some((e, t) => e.ordinal !== t + 1)) return D("integrity");
326
+ let m = [], h = 0, g = Buffer.byteLength(x(f));
327
+ for (let t = 0; t < f.manifest.pages.length; t++) {
328
+ let n = s(f, t, await R(e, d, "output", t + 1));
329
+ if (g += Buffer.byteLength(x(n)), h += n.length, g > 67108864 || h > 1e5) return D("bounds");
330
+ m.push([...n]);
331
+ }
332
+ return h === f.manifest.count ? {
333
+ set: f,
334
+ pages: m
335
+ } : D("integrity");
336
+ };
337
+ //#endregion
338
+ export { C as STATIC_PATH_PAGES_TABLE, S as STATIC_PATH_SETS_TABLE, B as appendStaticPathStage, F as beginStaticPathSet, H as pageStaticPathSet, P as readStaticPathSet, U as readStaticPathSetEvidence, V as sealStaticPathSet, T as staticPathPagesTable, E as staticPathSetTables, w as staticPathSetsTable };
@@ -0,0 +1,146 @@
1
+ import { asTyped as e } from "./effectForm.js";
2
+ import { CMS_REFERENCES_TABLE as t } from "./references.js";
3
+ import { translationStatuses as n } from "./translation.js";
4
+ import { and as r, eq as i, id as a, neq as o, table as s, text as c, timestamp as l } from "@voltro/database";
5
+ import { tenant as u } from "@voltro/plugin-multitenancy/mixin";
6
+ //#region src/stewardship.ts
7
+ var d = "cms_stewardship", f = s(d, {
8
+ id: a({ prefix: "cstw" }),
9
+ contentType: c().maxLength(64),
10
+ documentId: c().maxLength(64),
11
+ site: c().maxLength(64),
12
+ environment: c().maxLength(64),
13
+ owner: c().nullable(),
14
+ reviewDue: l().nullable(),
15
+ reviewedAt: l().nullable(),
16
+ reviewedBy: c().nullable(),
17
+ reviewedRevision: c().nullable()
18
+ }).with(u()).index("cms_stewardship_by_document", [
19
+ "contentType",
20
+ "documentId",
21
+ "site",
22
+ "environment"
23
+ ]), p = 864e5, m = (e, t, n, r) => e.query({
24
+ table: t,
25
+ predicate: n,
26
+ order: [],
27
+ take: r,
28
+ skip: void 0,
29
+ projection: void 0
30
+ }), h = (e) => {
31
+ if (e instanceof Date) return e;
32
+ if (typeof e == "string" || typeof e == "number") {
33
+ let t = new Date(e);
34
+ return Number.isNaN(t.getTime()) ? null : t;
35
+ }
36
+ return null;
37
+ }, g = (e) => typeof e == "string" && e !== "" ? e : null, _ = async (e, t, n, a) => (await m(e, d, r(i("contentType", t), i("documentId", n), i("site", a.site), i("environment", a.environment)), 1))[0], v = (e, t) => e === null ? "notRequired" : e.getTime() <= t.getTime() ? "due" : "scheduled", y = (e, t) => {
38
+ let n = h(e?.reviewDue);
39
+ return {
40
+ owner: g(e?.owner),
41
+ reviewDue: n,
42
+ reviewedAt: h(e?.reviewedAt),
43
+ reviewedBy: g(e?.reviewedBy),
44
+ reviewedRevision: g(e?.reviewedRevision),
45
+ review: v(n, t)
46
+ };
47
+ }, b = async (e, t, n, r, i, a) => {
48
+ let o = await _(e, t.name, n, r);
49
+ if (o !== void 0) return await e.update("cms_stewardship", String(o.id), i) ?? o;
50
+ let s = a == null ? {} : { tenantId: a };
51
+ return e.insert(d, {
52
+ contentType: t.name,
53
+ documentId: n,
54
+ site: r.site,
55
+ environment: r.environment,
56
+ owner: null,
57
+ reviewDue: null,
58
+ reviewedAt: null,
59
+ reviewedBy: null,
60
+ reviewedRevision: null,
61
+ ...i,
62
+ ...s
63
+ });
64
+ }, x = async (e, t, n, r, i, a = /* @__PURE__ */ new Date()) => {
65
+ let o = t.lifecycle;
66
+ if (o === void 0) return;
67
+ let s = await _(e, t.name, n, r);
68
+ (s === void 0 || s.reviewDue == null) && await b(e, t, n, r, { reviewDue: new Date(a.getTime() + o.reviewEveryDays * p) }, i);
69
+ }, S = async (e, t, n, r, i = /* @__PURE__ */ new Date()) => y(await _(e, t.name, n, r), i), C = async (e, t, n, r, i) => y(await b(e, t, n, r, { owner: i }), /* @__PURE__ */ new Date()), w = async (e, t, n, r, i) => {
70
+ let a = i.now ?? /* @__PURE__ */ new Date();
71
+ return y(await b(e, t, n, r, {
72
+ reviewDue: t.lifecycle === void 0 ? null : new Date(a.getTime() + t.lifecycle.reviewEveryDays * p),
73
+ reviewedAt: a,
74
+ reviewedBy: i.by,
75
+ reviewedRevision: i.revisionId
76
+ }), a);
77
+ }, T = async (e, a, s, c) => {
78
+ let l = c.now ?? /* @__PURE__ */ new Date(), u = [i("site", s.site), i("environment", s.environment)], f = [], p = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
79
+ for (let t of a) {
80
+ let n = /* @__PURE__ */ new Map();
81
+ for (let i of await m(e, `${t.name}_published`, r(...u, o("status", "archived")))) {
82
+ let e = String(i.documentId), r = String(i.locale);
83
+ n.set(e, (n.get(e) ?? /* @__PURE__ */ new Set()).add(r));
84
+ let a = g(i.title) ?? g(i.name) ?? g(i.slug) ?? e;
85
+ (r === c.sourceLocale || !h.has(`${t.name}:${e}`)) && h.set(`${t.name}:${e}`, a);
86
+ }
87
+ p.set(t.name, n);
88
+ }
89
+ let _ = (e, t) => h.get(`${e}:${t}`) ?? t, v = new Map((await m(e, d, r(...u))).map((e) => [`${String(e.contentType)}:${String(e.documentId)}`, e]));
90
+ for (let t of a) {
91
+ let r = p.get(t.name) ?? /* @__PURE__ */ new Map(), i = await n(e, t, [...r].filter(([, e]) => e.has(c.sourceLocale)).map(([e]) => e), s, c.sourceLocale, c.locales);
92
+ for (let [e, n] of r) {
93
+ let r = y(v.get(`${t.name}:${e}`), l), a = {
94
+ contentType: t.name,
95
+ documentId: e,
96
+ title: _(t.name, e)
97
+ };
98
+ if (r.owner === null && f.push({
99
+ ...a,
100
+ kind: "noOwner",
101
+ locale: null,
102
+ detail: []
103
+ }), r.review === "due" && f.push({
104
+ ...a,
105
+ kind: "reviewDue",
106
+ locale: null,
107
+ detail: []
108
+ }), n.has(c.sourceLocale)) for (let t of i.get(e)?.targets ?? []) t.state === "missing" && f.push({
109
+ ...a,
110
+ kind: "translationMissing",
111
+ locale: t.locale,
112
+ detail: []
113
+ }), t.state === "outdated" && f.push({
114
+ ...a,
115
+ kind: "translationOutdated",
116
+ locale: t.locale,
117
+ detail: [...t.changed]
118
+ });
119
+ }
120
+ }
121
+ let b = /* @__PURE__ */ new Map();
122
+ for (let n of await m(e, t, r(...u, i("stage", "published")))) {
123
+ let e = p.get(String(n.targetType)), t = String(n.sourceType);
124
+ if (e === void 0 || !p.has(t)) continue;
125
+ let r = String(n.locale);
126
+ if (e.get(String(n.targetDocumentId))?.has(r) === !0) continue;
127
+ let i = String(n.sourceDocumentId), a = `${t}:${i}:${r}`, o = b.get(a) ?? {
128
+ type: t,
129
+ doc: i,
130
+ locale: r,
131
+ paths: []
132
+ };
133
+ o.paths.push(String(n.path)), b.set(a, o);
134
+ }
135
+ for (let e of b.values()) f.push({
136
+ kind: "linksToUnpublished",
137
+ contentType: e.type,
138
+ documentId: e.doc,
139
+ locale: e.locale,
140
+ title: _(e.type, e.doc),
141
+ detail: e.paths
142
+ });
143
+ return f;
144
+ }, E = (...t) => e(() => T(...t)), D = (...t) => e(() => w(...t)), O = (...t) => e(() => C(...t)), k = (...t) => e(() => x(...t)), A = (...t) => e(() => S(...t));
145
+ //#endregion
146
+ export { d as CMS_STEWARDSHIP_TABLE, f as cmsStewardshipTable, T as contentHealth, E as contentHealthEffect, w as recertify, D as recertifyEffect, C as setOwner, O as setOwnerEffect, x as startStewardship, k as startStewardshipEffect, S as stewardshipOf, A as stewardshipOfEffect };
@@ -0,0 +1,36 @@
1
+ //#region src/taxonomy.ts
2
+ var e = (e) => e.normalize("NFKC").trim().replace(/\s+/g, " ").toLowerCase(), t = (t, n) => {
3
+ let r = /* @__PURE__ */ new Map();
4
+ for (let n of t.terms) {
5
+ r.set(e(n.term), n.term);
6
+ for (let t of n.synonyms ?? []) r.set(e(t), n.term);
7
+ }
8
+ let i = [], a = [];
9
+ for (let t of n) {
10
+ if (typeof t != "string" || t.trim() === "") continue;
11
+ let n = r.get(e(t));
12
+ if (n !== void 0) i.includes(n) || i.push(n);
13
+ else {
14
+ let n = t.normalize("NFKC").trim().replace(/\s+/g, " ");
15
+ a.some((t) => e(t) === e(n)) || a.push(n);
16
+ }
17
+ }
18
+ return {
19
+ terms: i,
20
+ unknown: a
21
+ };
22
+ }, n = (e, n) => {
23
+ let { terms: r, unknown: i } = t(e, n);
24
+ return [...r, ...i];
25
+ }, r = (t) => {
26
+ if (t.terms.length === 0) return "names no terms";
27
+ let n = /* @__PURE__ */ new Map();
28
+ for (let r of t.terms) for (let t of [r.term, ...r.synonyms ?? []]) {
29
+ let i = e(t), a = n.get(i);
30
+ if (a !== void 0 && a !== r.term) return `'${t}' means both '${a}' and '${r.term}'`;
31
+ n.set(i, r.term);
32
+ }
33
+ return null;
34
+ };
35
+ //#endregion
36
+ export { t as normalizeTerms, r as taxonomyProblem, n as taxonomyValue };
package/dist/team.js ADDED
@@ -0,0 +1,103 @@
1
+ import { asTyped as e } from "./effectForm.js";
2
+ import { and as t, eq as n, id as r, json as i, table as a, text as o } from "@voltro/database";
3
+ import { tenant as s } from "@voltro/plugin-multitenancy/mixin";
4
+ //#region src/team.ts
5
+ var c = "cms_team", l = "cms_team_invitations", u = a(c, {
6
+ id: r({ prefix: "ctm" }),
7
+ defaultRole: o().nullable(),
8
+ reviewRequired: i().nullable()
9
+ }).with(s()).unique("cms_team_uq_tenant", ["tenantId"]), d = a(l, {
10
+ id: r({ prefix: "cinv" }),
11
+ email: o().sensitive("pii"),
12
+ role: o()
13
+ }).with(s()).unique("cms_team_invitations_uq_email", ["tenantId", "email"]), f = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, p = /^[a-z][a-zA-Z0-9-]{0,39}$/, m = (e) => {
14
+ let t = [];
15
+ e.defaultRole !== void 0 && !p.test(e.defaultRole) && t.push(`default role "${e.defaultRole}" is not a role name`);
16
+ let n = /* @__PURE__ */ new Set();
17
+ for (let r of e.members ?? []) {
18
+ let e = r.email.trim().toLowerCase();
19
+ f.test(e) || t.push(`"${r.email}" is not an e-mail address`), n.has(e) && t.push(`"${r.email}" is invited twice`), n.add(e), p.test(r.role) || t.push(`role "${r.role}" of ${r.email} is not a role name`);
20
+ }
21
+ return new Set(e.reviewRequired ?? []).size !== (e.reviewRequired ?? []).length && t.push("a type is listed twice for review"), t;
22
+ }, h = (e, t, n) => e.query({
23
+ table: t,
24
+ predicate: n,
25
+ order: [{
26
+ column: "id",
27
+ direction: "asc"
28
+ }],
29
+ take: void 0,
30
+ skip: void 0,
31
+ projection: void 0
32
+ }), g = async (e, t) => (await h(e, c, n("tenantId", t)))[0], _ = async (e, r, i, a) => {
33
+ let o = null;
34
+ if (i.defaultRole !== void 0) {
35
+ let t = await g(e, r), n = typeof t?.defaultRole == "string";
36
+ o = {
37
+ role: n ? String(t.defaultRole) : i.defaultRole,
38
+ action: n ? "kept" : "set"
39
+ }, a && !n && (t === void 0 ? await e.insert(c, {
40
+ defaultRole: i.defaultRole,
41
+ tenantId: r
42
+ }) : await e.update(c, String(t.id), { defaultRole: i.defaultRole }));
43
+ }
44
+ let s = [];
45
+ for (let o of i.members ?? []) {
46
+ let i = o.email.trim().toLowerCase(), [c] = await h(e, l, t(n("tenantId", r), n("email", i)));
47
+ s.push({
48
+ email: i,
49
+ role: c === void 0 ? o.role : String(c.role),
50
+ action: c === void 0 ? "invite" : "present"
51
+ }), a && c === void 0 && await e.insert(l, {
52
+ email: i,
53
+ role: o.role,
54
+ tenantId: r
55
+ });
56
+ }
57
+ let u = [];
58
+ if ((i.reviewRequired ?? []).length > 0) {
59
+ let t = v(await g(e, r));
60
+ for (let e of i.reviewRequired ?? []) u.push({
61
+ type: e,
62
+ action: t.includes(e) ? "present" : "require"
63
+ });
64
+ let n = u.filter((e) => e.action === "require").map((e) => e.type);
65
+ a && n.length > 0 && await y(e, r, [...t, ...n]);
66
+ }
67
+ return {
68
+ defaultRole: o,
69
+ members: s,
70
+ reviewRequired: u
71
+ };
72
+ }, v = (e) => Array.isArray(e?.reviewRequired) ? e.reviewRequired.filter((e) => typeof e == "string") : [], y = async (e, t, n) => {
73
+ let r = await g(e, t), i = [...new Set(n)].sort();
74
+ r === void 0 ? await e.insert(c, {
75
+ defaultRole: null,
76
+ reviewRequired: i,
77
+ tenantId: t
78
+ }) : await e.update(c, String(r.id), { reviewRequired: i });
79
+ }, b = async (e, t) => v(await g(e, t)), x = async (e, t, n, r) => {
80
+ let i = v(await g(e, t)), a = r ? [...i, n] : i.filter((e) => e !== n);
81
+ return await y(e, t, a), [...new Set(a)].sort();
82
+ }, S = (e, t, n) => _(e, t, n, !1), C = (e, t, n) => _(e, t, n, !0), w = async (e, t) => {
83
+ let n = (await g(e, t))?.defaultRole;
84
+ return typeof n == "string" ? n : null;
85
+ }, T = async (e, r, i) => {
86
+ let [a] = await h(e, l, t(n("tenantId", r), n("email", i.trim().toLowerCase())));
87
+ return a === void 0 ? null : String(a.role);
88
+ }, E = async (e, t) => (await h(e, l, n("tenantId", t))).map((e) => ({
89
+ email: String(e.email),
90
+ role: String(e.role)
91
+ })).sort((e, t) => e.email < t.email ? -1 : 1), D = async (e, r, i, a) => {
92
+ let o = i.trim().toLowerCase(), [s] = await h(e, l, t(n("tenantId", r), n("email", o)));
93
+ return s === void 0 ? (await e.insert(l, {
94
+ email: o,
95
+ role: a,
96
+ tenantId: r
97
+ }), "invited") : s.role === a ? "present" : (await e.update(l, String(s.id), { role: a }), "changed");
98
+ }, O = async (e, r, i) => {
99
+ let [a] = await h(e, l, t(n("tenantId", r), n("email", i.trim().toLowerCase())));
100
+ return a !== void 0 && (await e.delete(l, String(a.id)), !0);
101
+ }, k = (...t) => e(() => C(...t)), A = (...t) => e(() => T(...t)), j = (...t) => e(() => D(...t)), M = (...t) => e(() => S(...t)), N = (...t) => e(() => w(...t)), P = (...t) => e(() => E(...t)), F = (...t) => e(() => x(...t)), I = (...t) => e(() => O(...t)), L = (...t) => e(() => b(...t));
102
+ //#endregion
103
+ export { l as CMS_TEAM_INVITATIONS_TABLE, c as CMS_TEAM_TABLE, C as applyBlueprintTeam, k as applyBlueprintTeamEffect, d as cmsTeamInvitationsTable, u as cmsTeamTable, D as inviteToTeam, j as inviteToTeamEffect, T as invitedRole, A as invitedRoleEffect, S as planBlueprintTeam, M as planBlueprintTeamEffect, x as setReviewRequired, F as setReviewRequiredEffect, w as teamDefaultRole, N as teamDefaultRoleEffect, E as teamInvitations, P as teamInvitationsEffect, m as teamProblems, O as withdrawInvitation, I as withdrawInvitationEffect, b as workspaceReviewTypes, L as workspaceReviewTypesEffect };