@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,177 @@
1
+ import { contactLiteralHref as e, listNumberedAt as t, normalizeRichDocument as n, richDocumentProblems as r } from "./richDocument.js";
2
+ import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
3
+ //#region src/RichDocumentView.tsx
4
+ var s = ({ content: t, resolve: n, fieldPath: r }) => t.map((t, i) => {
5
+ if (t.type === "link" || t.type === "contact") {
6
+ let o = t.type === "link" ? n.hrefOf(t.target, { fieldPath: [
7
+ ...r,
8
+ i,
9
+ "target"
10
+ ] }) : "target" in t.contact ? n.contactHrefOf(t.contact.target, { fieldPath: [
11
+ ...r,
12
+ i,
13
+ "contact",
14
+ "target"
15
+ ] }) : e(t.contact.channel, t.contact.value);
16
+ return o === void 0 ? /* @__PURE__ */ a("span", { children: t.text }, i) : /* @__PURE__ */ a("a", {
17
+ href: o,
18
+ children: t.text
19
+ }, i);
20
+ }
21
+ let o = t.marks ?? [], s = t.text;
22
+ return o.includes("underline") && (s = /* @__PURE__ */ a("u", { children: s })), o.includes("italic") && (s = /* @__PURE__ */ a("em", { children: s })), o.includes("bold") && (s = /* @__PURE__ */ a("strong", { children: s })), /* @__PURE__ */ a("span", {
23
+ ...t.style === void 0 ? {} : { "data-style": t.style },
24
+ children: s
25
+ }, i);
26
+ }).map((e, n) => {
27
+ let r = t[n]?.change;
28
+ if (r === void 0) return e;
29
+ let i = r.kind === "insert" ? "ins" : "del";
30
+ return /* @__PURE__ */ a(i, {
31
+ "data-change-id": r.id,
32
+ title: r.by,
33
+ children: e
34
+ }, n);
35
+ }), c = (e) => "style" in e && e.style !== void 0 ? { "data-style": e.style } : {}, l = ({ block: e, index: n, resolve: r, renderImage: i, renderComponent: l, fileHrefOf: u }) => {
36
+ switch (e.type) {
37
+ case "paragraph": return /* @__PURE__ */ a("p", {
38
+ "data-block-id": e.id,
39
+ ...c(e),
40
+ children: /* @__PURE__ */ a(s, {
41
+ content: e.content,
42
+ resolve: r,
43
+ fieldPath: [
44
+ "blocks",
45
+ n,
46
+ "content"
47
+ ]
48
+ })
49
+ });
50
+ case "heading": return e.level === 2 ? /* @__PURE__ */ a("h2", {
51
+ "data-block-id": e.id,
52
+ ...c(e),
53
+ children: /* @__PURE__ */ a(s, {
54
+ content: e.content,
55
+ resolve: r,
56
+ fieldPath: [
57
+ "blocks",
58
+ n,
59
+ "content"
60
+ ]
61
+ })
62
+ }) : /* @__PURE__ */ a("h3", {
63
+ "data-block-id": e.id,
64
+ ...c(e),
65
+ children: /* @__PURE__ */ a(s, {
66
+ content: e.content,
67
+ resolve: r,
68
+ fieldPath: [
69
+ "blocks",
70
+ n,
71
+ "content"
72
+ ]
73
+ })
74
+ });
75
+ case "list": {
76
+ let i = e.levels ?? e.items.map(() => 0), l = (n) => t(e, n) ? "ol" : "ul", u = (t, c) => {
77
+ let d = [], f = t;
78
+ for (; f < e.items.length && i[f] >= c;) {
79
+ let t = f, [i, p] = u(f + 1, c + 1), m = l(c + 1);
80
+ d.push(/* @__PURE__ */ o("li", { children: [/* @__PURE__ */ a(s, {
81
+ content: e.items[t],
82
+ resolve: r,
83
+ fieldPath: [
84
+ "blocks",
85
+ n,
86
+ "items",
87
+ t
88
+ ]
89
+ }), i.length > 0 ? /* @__PURE__ */ a(m, { children: i }) : null] }, t)), f = p;
90
+ }
91
+ return [d, f];
92
+ }, d = l(0);
93
+ return /* @__PURE__ */ a(d, {
94
+ "data-block-id": e.id,
95
+ ...c(e),
96
+ children: u(0, 0)[0]
97
+ });
98
+ }
99
+ case "table": {
100
+ let [t, ...i] = e.header ? e.rows : [void 0, ...e.rows];
101
+ return /* @__PURE__ */ o("table", {
102
+ "data-block-id": e.id,
103
+ children: [t === void 0 ? null : /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: t.map((e, t) => /* @__PURE__ */ a("th", {
104
+ scope: "col",
105
+ children: /* @__PURE__ */ a(s, {
106
+ content: e,
107
+ resolve: r,
108
+ fieldPath: [
109
+ "blocks",
110
+ n,
111
+ "rows",
112
+ 0,
113
+ t
114
+ ]
115
+ })
116
+ }, t)) }) }), /* @__PURE__ */ a("tbody", { children: i.map((t, i) => /* @__PURE__ */ a("tr", { children: (t ?? []).map((t, o) => /* @__PURE__ */ a("td", { children: /* @__PURE__ */ a(s, {
117
+ content: t,
118
+ resolve: r,
119
+ fieldPath: [
120
+ "blocks",
121
+ n,
122
+ "rows",
123
+ i + +!!e.header,
124
+ o
125
+ ]
126
+ }) }, o)) }, i)) })]
127
+ });
128
+ }
129
+ case "image": return i === void 0 ? null : /* @__PURE__ */ a("div", {
130
+ "data-block-id": e.id,
131
+ children: i(e, { index: n })
132
+ });
133
+ case "file": {
134
+ let t = u(e.asset, { index: n });
135
+ return t === void 0 ? null : /* @__PURE__ */ a("p", {
136
+ "data-block-id": e.id,
137
+ "data-file": !0,
138
+ children: /* @__PURE__ */ a("a", {
139
+ href: t,
140
+ download: !0,
141
+ children: e.label
142
+ })
143
+ });
144
+ }
145
+ case "component": return l === void 0 ? null : /* @__PURE__ */ a("div", {
146
+ "data-block-id": e.id,
147
+ "data-component": e.componentId,
148
+ children: l(e, { index: n })
149
+ });
150
+ }
151
+ }, u = ({ block: e, children: t }) => e.change === void 0 || t === null ? t : /* @__PURE__ */ a("div", {
152
+ "data-change": e.change.kind,
153
+ "data-change-id": e.change.id,
154
+ title: e.change.by,
155
+ children: t
156
+ }), d = ({ document: e, hrefOf: t = () => void 0, renderImage: o, contactHrefOf: s = () => void 0, renderComponent: c, fileHrefOf: d = () => void 0 }) => {
157
+ let f = {
158
+ hrefOf: t,
159
+ contactHrefOf: s
160
+ }, p = n(e);
161
+ return r("", p, {
162
+ images: "*",
163
+ links: "*"
164
+ }).some((e) => e.rule === "type" || e.rule === "unknown") ? null : /* @__PURE__ */ a(i, { children: p.blocks.map((e, t) => /* @__PURE__ */ a(u, {
165
+ block: e,
166
+ children: /* @__PURE__ */ a(l, {
167
+ block: e,
168
+ index: t,
169
+ resolve: f,
170
+ renderImage: o,
171
+ renderComponent: c,
172
+ fileHrefOf: d
173
+ })
174
+ }, e.id)) });
175
+ };
176
+ //#endregion
177
+ export { d as RichDocumentView };
@@ -0,0 +1,135 @@
1
+ import { hasMark as e, inlineFromDom as t, inlineHtml as n, replaceText as r, toggleMark as i } from "./richInline.js";
2
+ import { createElement as a, useEffect as o, useRef as s } from "react";
3
+ //#region src/RichTextSurface.tsx
4
+ var c = (e, t, n) => {
5
+ let r = 0, i = null, a = (e) => {
6
+ if (i === null) {
7
+ if (e === t && e.nodeType !== 3) {
8
+ for (let t = 0; t < n && t < e.childNodes.length; t++) r += l(e.childNodes[t]);
9
+ i = r;
10
+ } else if (e.nodeType === 3) {
11
+ if (e === t) {
12
+ i = r + n;
13
+ return;
14
+ }
15
+ r += (e.textContent ?? "").length;
16
+ } else if (e.nodeName === "BR") r += 1;
17
+ else for (let t of Array.from(e.childNodes)) a(t);
18
+ }
19
+ };
20
+ return a(e), i ?? r;
21
+ }, l = (e) => e.nodeType === 3 ? (e.textContent ?? "").length : e.nodeName === "BR" ? 1 : Array.from(e.childNodes).reduce((e, t) => e + l(t), 0), u = (e, t) => {
22
+ let n = 0, r = null, i = (e) => {
23
+ if (r === null) {
24
+ if (e.nodeType === 3) {
25
+ let i = (e.textContent ?? "").length;
26
+ if (t <= n + i) {
27
+ r = [e, t - n];
28
+ return;
29
+ }
30
+ n += i;
31
+ } else if (e.nodeName === "BR") {
32
+ if (t <= n) {
33
+ r = [e.parentNode, Array.from(e.parentNode.childNodes).indexOf(e)];
34
+ return;
35
+ }
36
+ n += 1;
37
+ } else for (let t of Array.from(e.childNodes)) i(t);
38
+ }
39
+ };
40
+ return i(e), r ?? [e, e.childNodes.length];
41
+ }, d = (e) => {
42
+ let t = e.ownerDocument.getSelection();
43
+ if (t === null || t.rangeCount === 0) return null;
44
+ let n = t.getRangeAt(0);
45
+ return !e.contains(n.startContainer) || !e.contains(n.endContainer) ? null : [c(e, n.startContainer, n.startOffset), c(e, n.endContainer, n.endOffset)];
46
+ }, f = (e, t, n) => {
47
+ let r = e.ownerDocument.getSelection();
48
+ if (r === null) return;
49
+ let i = e.ownerDocument.createRange(), [a, o] = u(e, t), [s, c] = u(e, n);
50
+ i.setStart(a, o), i.setEnd(s, c), r.removeAllRanges(), r.addRange(i);
51
+ }, p = (c) => {
52
+ let { id: l, labelledBy: u, content: p, onChange: m, words: h } = c, g = s(null), _ = s("");
53
+ o(() => {
54
+ let e = g.current;
55
+ if (e === null) return;
56
+ let t = JSON.stringify(p);
57
+ if (t === _.current) return;
58
+ _.current = t;
59
+ let r = e.ownerDocument.activeElement === e ? d(e) : null, i = e.textContent ?? "";
60
+ if (e.innerHTML = n(p), r === null) return;
61
+ let a = e.textContent ?? "", o = 0;
62
+ for (; o < i.length && o < a.length && i[o] === a[o];) o += 1;
63
+ let s = (e) => Math.min(a.length, e <= o ? e : e + a.length - i.length);
64
+ f(e, s(r[0]), s(r[1]));
65
+ }, [p]);
66
+ let v = (e, t) => {
67
+ let r = g.current;
68
+ r !== null && (_.current = JSON.stringify(e), r.innerHTML = n(e), t !== void 0 && f(r, t[0], t[1]), m(e));
69
+ }, y = () => {
70
+ let e = g.current;
71
+ if (e === null) return;
72
+ let n = t(e);
73
+ _.current = JSON.stringify(n), m(n);
74
+ }, b = (e) => {
75
+ let n = g.current, r = n === null ? null : d(n);
76
+ r !== null && r[0] !== r[1] && v(i(t(n), r[0], r[1], e), r);
77
+ }, x = (e) => {
78
+ let n = {
79
+ b: "bold",
80
+ i: "italic",
81
+ u: "underline"
82
+ }[e.key.toLowerCase()];
83
+ if ((e.ctrlKey || e.metaKey) && n !== void 0) e.preventDefault(), b(n);
84
+ else if (e.key === "Enter") {
85
+ if (e.preventDefault(), !e.shiftKey || g.current === null) return;
86
+ let n = d(g.current);
87
+ n !== null && v(r(t(g.current), n[0], n[1], "\n"), [n[0] + 1, n[0] + 1]);
88
+ }
89
+ }, S = (e) => {
90
+ e.preventDefault();
91
+ let n = g.current, i = e.clipboardData?.getData("text/plain") ?? "", a = n === null ? null : d(n);
92
+ a !== null && i !== "" && v(r(t(n), a[0], a[1], i), [a[0] + i.length, a[0] + i.length]);
93
+ }, C = (t) => {
94
+ let n = g.current, r = n === null ? null : d(n);
95
+ return r !== null && e(p, r[0], r[1], t);
96
+ }, w = (e) => e.preventDefault();
97
+ return a("div", { "data-cms-rich-surface": !0 }, a("div", {
98
+ role: "toolbar",
99
+ "aria-controls": l,
100
+ "data-cms-rich-marks": !0
101
+ }, a("button", {
102
+ type: "button",
103
+ onMouseDown: w,
104
+ onClick: () => b("bold"),
105
+ "aria-pressed": C("bold"),
106
+ "aria-label": h.bold
107
+ }, a("strong", null, "B")), a("button", {
108
+ type: "button",
109
+ onMouseDown: w,
110
+ onClick: () => b("italic"),
111
+ "aria-pressed": C("italic"),
112
+ "aria-label": h.italic
113
+ }, a("em", null, "I")), a("button", {
114
+ type: "button",
115
+ onMouseDown: w,
116
+ onClick: () => b("underline"),
117
+ "aria-pressed": C("underline"),
118
+ "aria-label": h.underline
119
+ }, a("u", null, "U"))), a("div", {
120
+ id: l,
121
+ ref: g,
122
+ role: "textbox",
123
+ "aria-multiline": !0,
124
+ "aria-labelledby": u,
125
+ contentEditable: !0,
126
+ suppressContentEditableWarning: !0,
127
+ tabIndex: 0,
128
+ onInput: y,
129
+ onKeyDown: x,
130
+ onPaste: S,
131
+ "data-cms-rich-text": !0
132
+ }));
133
+ };
134
+ //#endregion
135
+ export { p as RichTextSurface, d as selectionIn };
@@ -0,0 +1,199 @@
1
+ import { ContentIdConflict as e, ContentNotFound as t, ContentValidationFailed as n, RevisionMismatch as r } from "./errors.js";
2
+ import { asTyped as i } from "./effectForm.js";
3
+ import { saveDraft as a } from "./write.js";
4
+ import { settleAiOperation as o } from "./aiOperations.js";
5
+ import { and as s, eq as c, id as l, json as u, table as d, text as f, timestamp as p } from "@voltro/database";
6
+ import { tenant as m } from "@voltro/plugin-multitenancy/mixin";
7
+ //#region src/aiCandidates.ts
8
+ var h = "cms_ai_candidates", g = d(h, {
9
+ id: l({ prefix: "caic" }),
10
+ contentType: f().maxLength(64),
11
+ variantId: f().maxLength(64),
12
+ baseRevisionId: f().maxLength(64).nullable(),
13
+ operationId: f().maxLength(64).nullable(),
14
+ suggestedBy: f().maxLength(64).nullable(),
15
+ values: u(),
16
+ status: f().oneOf([
17
+ "open",
18
+ "adopted",
19
+ "partial",
20
+ "discarded"
21
+ ]),
22
+ adoptedUnits: u().nullable(),
23
+ adoptedRevisionId: f().maxLength(64).nullable(),
24
+ decidedBy: f().maxLength(64).nullable(),
25
+ decidedAt: p().nullable()
26
+ }).with(m()).index("cms_ai_candidates_by_variant", ["contentType", "variantId"]), _ = (e, t) => JSON.stringify(e ?? null) === JSON.stringify(t ?? null), v = (e, t, n) => {
27
+ let r = [];
28
+ for (let [i, a] of Object.entries(e.fields)) {
29
+ if (!(i in n)) continue;
30
+ if (a.kind !== "components") {
31
+ _(t[i], n[i]) || r.push({
32
+ key: i,
33
+ kind: "field",
34
+ field: i,
35
+ before: t[i] ?? null,
36
+ after: n[i]
37
+ });
38
+ continue;
39
+ }
40
+ let e = Array.isArray(t[i]) ? t[i] : [], o = Array.isArray(n[i]) ? n[i] : [], s = 0;
41
+ for (let t of o) {
42
+ let n = typeof t.instanceId == "string" ? e.find((e) => e.instanceId === t.instanceId) : void 0;
43
+ n === void 0 ? r.push({
44
+ key: `${i}+${s++}`,
45
+ kind: "addedSection",
46
+ field: i,
47
+ before: null,
48
+ after: t
49
+ }) : _(n.props, t.props) || r.push({
50
+ key: `${i}[${String(t.instanceId)}]`,
51
+ kind: "section",
52
+ field: i,
53
+ before: n,
54
+ after: t
55
+ });
56
+ }
57
+ }
58
+ return r;
59
+ }, y = (e) => e instanceof Date ? e : new Date(String(e)), b = (e) => typeof e == "string" && e !== "" ? e : null, x = (e) => ({
60
+ id: String(e.id),
61
+ contentType: String(e.contentType),
62
+ variantId: String(e.variantId),
63
+ baseRevisionId: b(e.baseRevisionId),
64
+ operationId: b(e.operationId),
65
+ suggestedBy: b(e.suggestedBy),
66
+ values: e.values ?? {},
67
+ status: [
68
+ "open",
69
+ "adopted",
70
+ "partial",
71
+ "discarded"
72
+ ].find((t) => t === e.status) ?? "open",
73
+ adoptedUnits: e.adoptedUnits ?? [],
74
+ adoptedRevisionId: b(e.adoptedRevisionId),
75
+ decidedBy: b(e.decidedBy),
76
+ createdAt: y(e.createdAt ?? 0)
77
+ }), S = async (e, t, n, r) => (await e.query({
78
+ table: `${t.name}_drafts`,
79
+ predicate: s(c("id", n), c("site", r.site), c("environment", r.environment), c("locale", r.locale)),
80
+ order: [],
81
+ take: 1,
82
+ skip: void 0,
83
+ projection: void 0
84
+ }))[0], C = async (e, t, n, r, i) => {
85
+ let a = await S(e, t, n, r);
86
+ if (a === void 0) return {
87
+ ok: !1,
88
+ reason: "notFound"
89
+ };
90
+ let o = Object.fromEntries(Object.entries(i.values).filter(([e]) => e in t.fields && !t.derivedFields.includes(e)));
91
+ if (v(t, a, o).length === 0) return {
92
+ ok: !1,
93
+ reason: "empty"
94
+ };
95
+ let s = await e.insert(h, {
96
+ contentType: t.name,
97
+ variantId: n,
98
+ baseRevisionId: b(a.revisionId),
99
+ operationId: i.operationId ?? null,
100
+ suggestedBy: i.suggestedBy ?? null,
101
+ values: o,
102
+ status: "open",
103
+ adoptedUnits: null,
104
+ adoptedRevisionId: null,
105
+ decidedBy: null,
106
+ decidedAt: null,
107
+ ...a.tenantId !== void 0 && a.tenantId !== null ? { tenantId: a.tenantId } : {}
108
+ });
109
+ return {
110
+ ok: !0,
111
+ id: String(s.id)
112
+ };
113
+ }, w = async (e, t, n, r, i, s = /* @__PURE__ */ new Date()) => {
114
+ let [l] = await e.query({
115
+ table: h,
116
+ predicate: c("id", n),
117
+ order: [],
118
+ take: 1,
119
+ skip: void 0,
120
+ projection: void 0
121
+ });
122
+ if (l === void 0 || l.contentType !== t.name) return {
123
+ ok: !1,
124
+ reason: "notFound"
125
+ };
126
+ let u = x(l);
127
+ if (u.status !== "open") return {
128
+ ok: !1,
129
+ reason: "closed"
130
+ };
131
+ if (i.units.length === 0) return {
132
+ ok: !1,
133
+ reason: "noUnits"
134
+ };
135
+ let d = await S(e, t, u.variantId, r);
136
+ if (d === void 0) return {
137
+ ok: !1,
138
+ reason: "notFound"
139
+ };
140
+ let f = v(t, d, u.values), p = i.units.filter((e) => !f.some((t) => t.key === e));
141
+ if (p.length > 0) return {
142
+ ok: !1,
143
+ reason: "unknownUnit",
144
+ units: p
145
+ };
146
+ let m = { ...d };
147
+ for (let e of f.filter((e) => i.units.includes(e.key))) {
148
+ if (e.kind === "field") {
149
+ m[e.field] = e.after;
150
+ continue;
151
+ }
152
+ let t = [...Array.isArray(m[e.field]) ? m[e.field] : []], n = e.after;
153
+ m[e.field] = e.kind === "addedSection" ? [...t, {
154
+ componentId: n.componentId,
155
+ props: n.props
156
+ }] : t.map((e) => e.instanceId === n.instanceId ? {
157
+ ...e,
158
+ props: n.props
159
+ } : e);
160
+ }
161
+ let g = await a(e, t, m, r, { expectedRevision: String(d.revisionId) }), _ = i.units.length === f.length ? "adopted" : "partial";
162
+ return await e.update(h, n, {
163
+ status: _,
164
+ adoptedUnits: [...i.units],
165
+ adoptedRevisionId: String(g.revisionId),
166
+ decidedBy: i.actorId,
167
+ decidedAt: s
168
+ }), u.operationId !== null && await o(e, u.operationId, "applied"), {
169
+ ok: !0,
170
+ revisionId: String(g.revisionId),
171
+ status: _
172
+ };
173
+ }, T = async (e, t, n, r = /* @__PURE__ */ new Date()) => {
174
+ let [i] = await e.query({
175
+ table: h,
176
+ predicate: c("id", t),
177
+ order: [],
178
+ take: 1,
179
+ skip: void 0,
180
+ projection: void 0
181
+ });
182
+ return i === void 0 || i.status !== "open" ? !1 : (await e.update(h, t, {
183
+ status: "discarded",
184
+ decidedBy: n,
185
+ decidedAt: r
186
+ }), typeof i.operationId == "string" && await o(e, i.operationId, "discarded"), !0);
187
+ }, E = async (e, t, n) => (await e.query({
188
+ table: h,
189
+ predicate: s(c("contentType", t.name), c("variantId", n)),
190
+ order: [{
191
+ column: "createdAt",
192
+ direction: "desc"
193
+ }],
194
+ take: 20,
195
+ skip: void 0,
196
+ projection: void 0
197
+ })).map(x), D = (...e) => i(() => C(...e)), O = (...a) => i(() => w(...a), n, t, e, r), k = (...e) => i(() => T(...e)), A = (...e) => i(() => E(...e));
198
+ //#endregion
199
+ export { h as CMS_AI_CANDIDATES_TABLE, w as adoptCandidate, O as adoptCandidateEffect, v as candidateUnits, E as candidatesFor, A as candidatesForEffect, g as cmsAiCandidatesTable, T as discardCandidate, k as discardCandidateEffect, C as proposeCandidate, D as proposeCandidateEffect };
@@ -0,0 +1,152 @@
1
+ import { asTyped as e } from "./effectForm.js";
2
+ import { and as t, eq as n, gte as r, id as i, integer as a, table as o, text as s } from "@voltro/database";
3
+ import { tenant as c } from "@voltro/plugin-multitenancy/mixin";
4
+ import { createHash as l } from "node:crypto";
5
+ //#region src/aiOperations.ts
6
+ var u = "cms_ai_operations", d = "cms_ai_settings", f = [
7
+ "suggested",
8
+ "failed",
9
+ "applied",
10
+ "discarded"
11
+ ], p = o(u, {
12
+ id: i({ prefix: "caio" }),
13
+ operation: s(),
14
+ version: s(),
15
+ provider: s(),
16
+ model: s(),
17
+ contentType: s().maxLength(64),
18
+ variantId: s().maxLength(64),
19
+ revisionId: s().nullable(),
20
+ field: s().nullable(),
21
+ promptHash: s(),
22
+ inputTokens: a().nullable(),
23
+ outputTokens: a().nullable(),
24
+ outcome: s().oneOf([...f]),
25
+ error: s().nullable(),
26
+ actor: s().nullable()
27
+ }).with(c()), m = o(d, {
28
+ id: i({ prefix: "cais" }),
29
+ provider: s(),
30
+ model: s(),
31
+ apiKey: s().encrypted().serverOnly().nullable(),
32
+ monthlyTokens: a().nullable()
33
+ }).with(c()).unique("cms_ai_settings_uq_tenant", ["tenantId"]), h = (e) => l("sha256").update(e).digest("hex"), g = async (e, t) => {
34
+ let n = await e.insert(u, {
35
+ operation: t.operation,
36
+ version: t.version,
37
+ provider: t.provider,
38
+ model: t.model,
39
+ contentType: t.contentType,
40
+ variantId: t.variantId,
41
+ revisionId: t.revisionId ?? null,
42
+ field: t.field ?? null,
43
+ promptHash: h(t.prompt),
44
+ inputTokens: t.usage?.inputTokens ?? null,
45
+ outputTokens: t.usage?.outputTokens ?? null,
46
+ outcome: t.outcome,
47
+ error: t.error ?? null,
48
+ actor: t.actor ?? null
49
+ });
50
+ return String(n.id);
51
+ }, _ = async (e, t, r) => {
52
+ let [i] = await e.query({
53
+ table: u,
54
+ predicate: n("id", t),
55
+ order: [],
56
+ take: 1,
57
+ skip: void 0,
58
+ projection: void 0
59
+ });
60
+ return i === void 0 || i.outcome !== "suggested" ? !1 : (await e.update(u, t, { outcome: r }), !0);
61
+ }, v = (e) => ({
62
+ id: String(e.id),
63
+ operation: String(e.operation),
64
+ version: String(e.version),
65
+ provider: String(e.provider),
66
+ model: String(e.model),
67
+ field: typeof e.field == "string" ? e.field : null,
68
+ revisionId: typeof e.revisionId == "string" ? e.revisionId : null,
69
+ outcome: e.outcome,
70
+ inputTokens: typeof e.inputTokens == "number" ? e.inputTokens : null,
71
+ outputTokens: typeof e.outputTokens == "number" ? e.outputTokens : null,
72
+ at: e.createdAt instanceof Date ? e.createdAt.getTime() : new Date(String(e.createdAt ?? 0)).getTime()
73
+ }), y = async (e, r, i) => (await e.query({
74
+ table: u,
75
+ predicate: t(n("contentType", r), n("variantId", i)),
76
+ order: [{
77
+ column: "createdAt",
78
+ direction: "desc"
79
+ }, {
80
+ column: "id",
81
+ direction: "desc"
82
+ }],
83
+ take: 200,
84
+ skip: void 0,
85
+ projection: void 0
86
+ })).map(v), b = async (e, t) => {
87
+ let [r] = await e.query({
88
+ table: d,
89
+ predicate: n("tenantId", t),
90
+ order: [],
91
+ take: 1,
92
+ skip: void 0,
93
+ projection: void 0
94
+ });
95
+ return r === void 0 ? null : {
96
+ provider: typeof r.provider == "string" && r.provider !== "" ? r.provider : null,
97
+ model: typeof r.model == "string" && r.model !== "" ? r.model : null,
98
+ apiKey: typeof r.apiKey == "string" && r.apiKey !== "" ? r.apiKey : null,
99
+ monthlyTokens: typeof r.monthlyTokens == "number" ? r.monthlyTokens : null
100
+ };
101
+ }, x = (e = /* @__PURE__ */ new Date()) => new Date(Date.UTC(e.getUTCFullYear(), e.getUTCMonth(), 1)), S = async (e, i, a = x()) => (await e.query({
102
+ table: u,
103
+ predicate: t(n("tenantId", i), r("createdAt", a)),
104
+ order: [],
105
+ take: void 0,
106
+ skip: void 0,
107
+ projection: ["inputTokens", "outputTokens"]
108
+ })).reduce((e, t) => e + (Number(t.inputTokens) || 0) + (Number(t.outputTokens) || 0), 0), C = async (e, t, n = /* @__PURE__ */ new Date()) => {
109
+ let r = (await b(e, t))?.monthlyTokens ?? null;
110
+ return r === null ? null : Math.max(0, r - await S(e, t, x(n)));
111
+ }, w = async (e, t, r) => {
112
+ let [i] = await e.query({
113
+ table: d,
114
+ predicate: n("tenantId", t),
115
+ order: [],
116
+ take: 1,
117
+ skip: void 0,
118
+ projection: void 0
119
+ }), a = r === null ? {
120
+ provider: "",
121
+ model: "",
122
+ apiKey: null
123
+ } : {
124
+ provider: r.provider,
125
+ model: r.model,
126
+ ...r.apiKey === void 0 ? {} : { apiKey: r.apiKey }
127
+ };
128
+ i === void 0 ? r !== null && await e.insert(d, {
129
+ apiKey: null,
130
+ monthlyTokens: null,
131
+ ...a,
132
+ tenantId: t
133
+ }) : r === null && typeof i.monthlyTokens != "number" ? await e.delete(d, String(i.id)) : await e.update(d, String(i.id), a);
134
+ }, T = async (e, t, r) => {
135
+ let [i] = await e.query({
136
+ table: d,
137
+ predicate: n("tenantId", t),
138
+ order: [],
139
+ take: 1,
140
+ skip: void 0,
141
+ projection: void 0
142
+ });
143
+ i === void 0 ? r !== null && await e.insert(d, {
144
+ provider: "",
145
+ model: "",
146
+ apiKey: null,
147
+ monthlyTokens: r,
148
+ tenantId: t
149
+ }) : r === null && i.provider === "" ? await e.delete(d, String(i.id)) : await e.update(d, String(i.id), { monthlyTokens: r });
150
+ }, E = (...t) => e(() => C(...t)), D = (...t) => e(() => y(...t)), O = (...t) => e(() => b(...t)), k = (...t) => e(() => S(...t)), A = (...t) => e(() => T(...t)), j = (...t) => e(() => g(...t)), M = (...t) => e(() => w(...t)), N = (...t) => e(() => _(...t));
151
+ //#endregion
152
+ export { f as AI_OUTCOMES, u as CMS_AI_OPERATIONS_TABLE, d as CMS_AI_SETTINGS_TABLE, C as aiBudgetLeft, E as aiBudgetLeftEffect, y as aiOperationsFor, D as aiOperationsForEffect, b as aiSettings, O as aiSettingsEffect, S as aiTokensUsed, k as aiTokensUsedEffect, p as cmsAiOperationsTable, m as cmsAiSettingsTable, x as monthStart, h as promptHash, g as recordAiOperation, j as recordAiOperationEffect, T as setAiBudget, A as setAiBudgetEffect, w as setAiSettings, M as setAiSettingsEffect, _ as settleAiOperation, N as settleAiOperationEffect };