@voltro/cms 0.84.0 → 0.86.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 (81) hide show
  1. package/CHANGELOG.md +1215 -0
  2. package/THIRD-PARTY-NOTICES.md +118 -600
  3. package/dist/ContentForm.js +282 -0
  4. package/dist/RichDocumentEditor.js +550 -0
  5. package/dist/RichDocumentView.js +132 -0
  6. package/dist/RichTextSurface.js +135 -0
  7. package/dist/aiCandidates.js +199 -0
  8. package/dist/aiOperations.js +152 -0
  9. package/dist/audiences.js +31 -0
  10. package/dist/availability.js +121 -0
  11. package/dist/blueprint.js +166 -0
  12. package/dist/bulk.js +281 -0
  13. package/dist/cacheIdentity.js +152 -0
  14. package/dist/changes.js +90 -0
  15. package/dist/cmsContext.js +229 -0
  16. package/dist/collections.js +224 -0
  17. package/dist/consent.js +29 -0
  18. package/dist/contentType.js +191 -0
  19. package/dist/contentfulImport.js +162 -0
  20. package/dist/copies.js +89 -0
  21. package/dist/cutover.js +202 -0
  22. package/dist/deliveryChecks.js +138 -0
  23. package/dist/domains.js +145 -0
  24. package/dist/draftTexts.js +164 -0
  25. package/dist/duplicates.js +78 -0
  26. package/dist/edgePurge.js +69 -0
  27. package/dist/editHistory.js +113 -0
  28. package/dist/effectForm.js +11 -0
  29. package/dist/environments.js +109 -0
  30. package/dist/errors.js +67 -0
  31. package/dist/experiments.js +528 -0
  32. package/dist/exposure.js +28 -0
  33. package/dist/extensionManifest.js +81 -0
  34. package/dist/extensions.js +314 -0
  35. package/dist/fieldSchema.js +199 -0
  36. package/dist/formStrings.js +74 -0
  37. package/dist/glossary.js +73 -0
  38. package/dist/history.js +54 -0
  39. package/dist/htmlImport.js +297 -0
  40. package/dist/index.d.ts +2266 -170
  41. package/dist/index.js +73 -3947
  42. package/dist/media.js +29 -0
  43. package/dist/metrics.js +46 -0
  44. package/dist/migration.js +193 -0
  45. package/dist/migrationStages.js +13 -0
  46. package/dist/presenceAnchors.js +68 -0
  47. package/dist/preview.js +31 -0
  48. package/dist/promotion.js +107 -0
  49. package/dist/quality.js +188 -0
  50. package/dist/recurrence.js +78 -0
  51. package/dist/redirects.js +99 -0
  52. package/dist/referenceGraph.js +223 -0
  53. package/dist/references.js +173 -0
  54. package/dist/release.js +205 -0
  55. package/dist/rest.js +52 -0
  56. package/dist/review.js +160 -0
  57. package/dist/richDocument.js +491 -0
  58. package/dist/richInline.js +100 -0
  59. package/dist/schedule.js +80 -0
  60. package/dist/search.js +148 -0
  61. package/dist/selectionIntent.js +164 -0
  62. package/dist/seo.js +31 -0
  63. package/dist/series.js +105 -0
  64. package/dist/share.js +112 -0
  65. package/dist/stewardship.js +146 -0
  66. package/dist/taxonomy.js +36 -0
  67. package/dist/team.js +103 -0
  68. package/dist/templates.js +106 -0
  69. package/dist/trackChanges.js +197 -0
  70. package/dist/translation.js +64 -0
  71. package/dist/tree.js +87 -0
  72. package/dist/usage.js +50 -0
  73. package/dist/validation.js +192 -0
  74. package/dist/visualEditing.js +60 -0
  75. package/dist/web.d.ts +927 -131
  76. package/dist/web.js +33 -2
  77. package/dist/workflow.js +322 -0
  78. package/dist/write.js +394 -0
  79. package/dist/xliff.js +325 -0
  80. package/package.json +6 -6
  81. package/dist/extensionManifest-BK3ZcL2P.js +0 -2782
package/dist/tree.js ADDED
@@ -0,0 +1,87 @@
1
+ //#region src/tree.ts
2
+ var e = (e, t) => {
3
+ let n = e[t.parent];
4
+ return typeof n == "string" && n !== "" ? n : null;
5
+ }, t = (e, t) => {
6
+ let n = t.order === void 0 ? void 0 : e[t.order];
7
+ return typeof n == "number" && Number.isFinite(n) ? n : Infinity;
8
+ }, n = (e, t) => {
9
+ let n = e[t.segment];
10
+ return typeof n == "string" ? n : "";
11
+ }, r = (r, i) => {
12
+ let a = /* @__PURE__ */ new Map();
13
+ for (let e of r) {
14
+ let t = e.row.documentId;
15
+ typeof t == "string" && !a.has(t) && a.set(t, e);
16
+ }
17
+ let o = /* @__PURE__ */ new Map();
18
+ for (let t of a.values()) {
19
+ let n = e(t.row, i), r = o.get(n) ?? [];
20
+ r.push(t), o.set(n, r);
21
+ }
22
+ let s = (e, r) => t(e.row, i) - t(r.row, i) || n(e.row, i).localeCompare(n(r.row, i)) || String(e.row.documentId).localeCompare(String(r.row.documentId)), c = [], l = /* @__PURE__ */ new Set(), u = (e, t) => {
23
+ for (let r of [...o.get(e) ?? []].sort(s)) {
24
+ let a = r.row.documentId, o = n(r.row, i);
25
+ if (o === "" || l.has(a)) continue;
26
+ l.add(a);
27
+ let s = [...t, o];
28
+ c.push({
29
+ documentId: a,
30
+ parent: e,
31
+ depth: t.length,
32
+ segments: s,
33
+ path: s.join("/"),
34
+ row: r.row,
35
+ locale: r.locale,
36
+ fallback: r.fallback
37
+ }), u(a, s);
38
+ }
39
+ };
40
+ return u(null, []), {
41
+ nodes: c,
42
+ orphans: [...a.keys()].filter((e) => !l.has(e)).sort()
43
+ };
44
+ }, i = (e) => e != null && e !== "", a = (e, t, n, r = {}) => {
45
+ let a = new Map(e.nodes.map((e) => [e.documentId, e])), o = r.ancestorsOnly === !0 ? t.parent === null ? void 0 : a.get(t.parent) : t, s = /* @__PURE__ */ new Set();
46
+ for (; o !== void 0 && !s.has(o.documentId);) {
47
+ if (s.add(o.documentId), i(o.row[n])) return {
48
+ value: o.row[n],
49
+ from: o.documentId,
50
+ how: o.documentId === t.documentId ? "own" : "ancestor"
51
+ };
52
+ if (r.mask !== void 0 && o.row[r.mask] === !0) return {
53
+ value: void 0,
54
+ from: o.documentId,
55
+ how: "masked"
56
+ };
57
+ o = o.parent === null ? void 0 : a.get(o.parent);
58
+ }
59
+ return {
60
+ value: void 0,
61
+ from: null,
62
+ how: "none"
63
+ };
64
+ }, o = (e, t, n) => {
65
+ let r = t.nodes.some((e) => e.documentId === n.documentId) ? {
66
+ ...t,
67
+ nodes: t.nodes.map((e) => e.documentId === n.documentId ? n : e)
68
+ } : {
69
+ ...t,
70
+ nodes: [...t.nodes, n]
71
+ };
72
+ return Object.entries(e).map(([e, t]) => {
73
+ let i = t.mask === void 0 ? {} : { mask: t.mask };
74
+ return {
75
+ field: e,
76
+ locked: t.locked === !0,
77
+ mask: t.mask ?? null,
78
+ ...a(r, n, e, i),
79
+ inherited: a(r, n, e, {
80
+ ...i,
81
+ ancestorsOnly: !0
82
+ })
83
+ };
84
+ });
85
+ };
86
+ //#endregion
87
+ export { r as buildTree, o as effectiveInheritance, a as inheritedValue };
package/dist/usage.js ADDED
@@ -0,0 +1,50 @@
1
+ import { asTyped as e } from "./effectForm.js";
2
+ import { and as t, eq as n, neq as r } from "@voltro/database";
3
+ //#region src/usage.ts
4
+ var i = async (e, i, a) => {
5
+ let o = {}, s = /* @__PURE__ */ new Set();
6
+ for (let c of i) {
7
+ let i = await e.query({
8
+ table: `${c.name}_drafts`,
9
+ predicate: t(n("site", a), r("status", "archived")),
10
+ order: [],
11
+ take: void 0,
12
+ skip: void 0,
13
+ projection: void 0,
14
+ groupBy: ["environment"],
15
+ aggregations: [{
16
+ op: "column",
17
+ column: "environment",
18
+ alias: "environment"
19
+ }, {
20
+ op: "count-distinct",
21
+ column: "documentId",
22
+ alias: "documents"
23
+ }]
24
+ });
25
+ if (i.length > 1) {
26
+ let [i] = await e.query({
27
+ table: `${c.name}_drafts`,
28
+ predicate: t(n("site", a), r("status", "archived")),
29
+ order: [],
30
+ take: void 0,
31
+ skip: void 0,
32
+ projection: void 0,
33
+ aggregations: [{
34
+ op: "count-distinct",
35
+ column: "documentId",
36
+ alias: "documents"
37
+ }]
38
+ });
39
+ o[c.name] = Number(i?.documents ?? 0);
40
+ } else o[c.name] = Number(i[0]?.documents ?? 0);
41
+ for (let e of i) s.add(String(e.environment));
42
+ }
43
+ return {
44
+ documents: Object.values(o).reduce((e, t) => e + t, 0),
45
+ documentsByType: o,
46
+ environments: [...s].sort()
47
+ };
48
+ }, a = (...t) => e(() => i(...t));
49
+ //#endregion
50
+ export { i as contentUsage, a as contentUsageEffect };
@@ -0,0 +1,192 @@
1
+ import { normalizeRichDocument as e, richDocumentProblems as t } from "./richDocument.js";
2
+ import { normalizeTerms as n, taxonomyValue as r } from "./taxonomy.js";
3
+ import { ContentValidationFailed as i } from "./errors.js";
4
+ import { documentHasChanges as a } from "./trackChanges.js";
5
+ //#region src/validation.ts
6
+ var o = /* @__PURE__ */ new Set([
7
+ "status",
8
+ "publishAt",
9
+ "unpublishAt",
10
+ "revisionId",
11
+ "revision",
12
+ "documentId",
13
+ "site",
14
+ "environment",
15
+ "locale",
16
+ "tenantId",
17
+ "createdAt",
18
+ "updatedAt",
19
+ "createdBy",
20
+ "updatedBy"
21
+ ]), s = (e, t, n) => ({
22
+ field: e,
23
+ rule: t,
24
+ message: n
25
+ }), c = (e) => typeof e == "object" && !!e && !Array.isArray(e), l = (e) => e instanceof Date ? !Number.isNaN(e.getTime()) : typeof e == "string" && !Number.isNaN(new Date(e).getTime()), u = (e, t, n) => {
26
+ let r = [];
27
+ return t.maxLength !== void 0 && n.length > t.maxLength && r.push(s(e, "maxLength", `exceeds maxLength(${t.maxLength}) — got ${n.length} characters`)), t.pattern !== void 0 && !new RegExp(t.pattern).test(n) && r.push(s(e, "pattern", `does not match pattern /${t.pattern}/`)), r;
28
+ }, d = (n, r, i) => {
29
+ switch (r.kind) {
30
+ case "string":
31
+ case "media":
32
+ case "reference": return typeof i == "string" ? u(n, r, i) : [s(n, "type", `expected a string, got ${typeof i}`)];
33
+ case "number": return typeof i != "number" || !Number.isFinite(i) ? [s(n, "type", "expected a finite number")] : r.fraction !== !0 && !Number.isInteger(i) ? [s(n, "integer", "expected a whole number (declare Schema.Fraction for fractions)")] : [];
34
+ case "boolean": return typeof i == "boolean" ? [] : [s(n, "type", `expected a boolean, got ${typeof i}`)];
35
+ case "date":
36
+ case "datetime": return l(i) ? [] : [s(n, "type", "expected a Date or a parseable date string")];
37
+ case "literal": {
38
+ let e = r.literals ?? [];
39
+ return typeof i != "string" || !e.includes(i) ? [s(n, "literal", `expected one of: ${e.join(", ")}`)] : [];
40
+ }
41
+ case "richText": {
42
+ let a = r.richText ?? {}, o = e(i), l = t(n, o, a).map((e) => s(e.path, e.rule, e.message)), u = new Map((a.profile?.components ?? []).map((e) => [e.id, e]));
43
+ return (c(o) && Array.isArray(o.blocks) ? o.blocks : []).forEach((e, t) => {
44
+ if (!c(e) || e.type !== "component" || !c(e.props)) return;
45
+ let r = u.get(String(e.componentId));
46
+ r !== void 0 && l.push(...f(`${n}.blocks[${t}].props`, r.props, e.props, `component '${r.id}'`, !0));
47
+ }), l;
48
+ }
49
+ case "array": {
50
+ if (!Array.isArray(i)) return [s(n, "type", "expected an array")];
51
+ let e = r.element;
52
+ if (e === void 0) return [];
53
+ let t = [];
54
+ return i.forEach((r, i) => t.push(...d(`${n}[${i}]`, e, r))), t;
55
+ }
56
+ case "struct": return c(i) ? f(n, r.struct ?? {}, i, "struct", !1) : [s(n, "type", "expected an object")];
57
+ case "components": {
58
+ if (!Array.isArray(i)) return [s(n, "type", "expected a list of components")];
59
+ let e = new Map((r.components ?? []).map((e) => [e.id, e])), t = [], a = /* @__PURE__ */ new Set();
60
+ return i.forEach((r, i) => {
61
+ let o = `${n}[${i}]`;
62
+ if (!c(r)) {
63
+ t.push(s(o, "type", "expected a component instance"));
64
+ return;
65
+ }
66
+ let l = r.instanceId;
67
+ typeof l != "string" || l === "" ? t.push(s(`${o}.instanceId`, "required", "missing instance id")) : a.has(l) ? t.push(s(`${o}.instanceId`, "unique", `instance '${l}' appears twice`)) : a.add(l);
68
+ let u = e.get(String(r.componentId));
69
+ if (u === void 0) {
70
+ t.push(s(`${o}.componentId`, "unknown", `'${String(r.componentId)}' is not a component this field allows`));
71
+ return;
72
+ }
73
+ let d = r.props;
74
+ c(d) ? t.push(...f(`${o}.props`, u.props, d, `component '${u.id}'`, !0)) : t.push(s(`${o}.props`, "type", "expected an object"));
75
+ }), t;
76
+ }
77
+ }
78
+ }, f = (e, t, n, r, i) => {
79
+ let a = [];
80
+ for (let [r, o] of Object.entries(t)) {
81
+ let t = n[r];
82
+ t == null || i && t === "" ? o.isOptional || a.push(s(`${e}.${r}`, "required", "missing required field")) : a.push(...d(`${e}.${r}`, o, t));
83
+ }
84
+ for (let i of Object.keys(n)) i in t || a.push(s(`${e}.${i}`, "unknown", `not a declared field of this ${r}`));
85
+ return a;
86
+ }, p = (e, t) => {
87
+ let r = [];
88
+ for (let [n, i] of Object.entries(e.fields)) {
89
+ let e = t[n];
90
+ e == null ? i.isOptional || r.push(s(n, "required", "missing required field")) : r.push(...d(n, i, e));
91
+ }
92
+ let i = t.id;
93
+ i !== void 0 && typeof i != "string" && r.push(s("id", "type", "expected a string id"));
94
+ for (let n of Object.keys(t)) n === "id" || n in e.fields || o.has(n) || r.push(s(n, "unknown", `'${n}' is not a declared field of '${e.name}'`));
95
+ let a = e.taxonomy;
96
+ if (a !== void 0 && (a.unknown ?? "refuse") === "refuse" && Array.isArray(t[a.field])) {
97
+ let { unknown: e } = n(a, t[a.field]);
98
+ e.length > 0 && r.push(s(a.field, "taxonomy", `not in the vocabulary: ${e.join(", ")}`));
99
+ }
100
+ return r;
101
+ }, m = (e, t) => [...Object.entries(e.fields).filter(([e, n]) => {
102
+ let r = t[e];
103
+ return n.publishRequired === !0 && (r == null || typeof r == "string" && r.trim() === "");
104
+ }).map(([e]) => s(e, "requiredToPublish", "needed before publishing")), ...Object.entries(e.fields).filter(([e, n]) => {
105
+ let r = t[e];
106
+ return n.kind === "richText" && c(r) && Array.isArray(r.blocks) && a(r);
107
+ }).map(([e]) => s(e, "pendingChanges", "accept or reject the suggested changes first"))], h = (e, t) => {
108
+ let n = p(e, t);
109
+ if (n.length > 0) throw new i({
110
+ contentType: e.name,
111
+ violations: n
112
+ });
113
+ }, g = (t, n) => {
114
+ let i = { ...n }, a = t.taxonomy;
115
+ a !== void 0 && Array.isArray(i[a.field]) && (i[a.field] = r(a, i[a.field]));
116
+ for (let e of t.derivedFields) {
117
+ let n = t.fields[e]?.derived;
118
+ n !== void 0 && (i[e] = n.transform(i[n.source], i));
119
+ }
120
+ for (let [n, r] of Object.entries(t.fields)) r.kind === "richText" && i[n] !== void 0 && i[n] !== null && (i[n] = _(r, e(i[n], r.richText?.profile)));
121
+ for (let [e, n] of Object.entries(t.fields)) n.kind === "components" && Array.isArray(i[e]) && (i[e] = v(n.components ?? [], i[e]));
122
+ return i;
123
+ }, _ = (e, t) => {
124
+ let n = e.richText?.profile?.components ?? [];
125
+ return n.length === 0 || !c(t) || !Array.isArray(t.blocks) ? t : {
126
+ ...t,
127
+ blocks: t.blocks.map((e) => {
128
+ if (!c(e) || e.type !== "component") return e;
129
+ let [t] = v(n, [{
130
+ ...e,
131
+ instanceId: e.id
132
+ }]);
133
+ return t === void 0 || t.fingerprint === void 0 ? e : {
134
+ ...e,
135
+ props: t.props,
136
+ fingerprint: t.fingerprint
137
+ };
138
+ })
139
+ };
140
+ }, v = (e, t) => {
141
+ let n = new Map(e.map((e) => [e.id, e]));
142
+ return t.map((e) => {
143
+ if (!c(e)) return e;
144
+ let t = n.get(String(e.componentId)), r = typeof e.instanceId == "string" && e.instanceId !== "" ? e.instanceId : x();
145
+ if (t === void 0) return {
146
+ ...e,
147
+ instanceId: r
148
+ };
149
+ let i = c(e.props) ? e.props : {}, a = typeof e.fingerprint == "string" ? e.fingerprint : null, o = a !== null && a !== t.fingerprint ? t.migrations?.[a] : void 0;
150
+ o !== void 0 && (i = o(i));
151
+ let s = Object.fromEntries(Object.entries(i).map(([e, n]) => {
152
+ let r = t.props[e];
153
+ return [e, r?.kind === "components" && Array.isArray(n) ? v(r.components ?? [], n) : n];
154
+ }));
155
+ return {
156
+ ...e,
157
+ instanceId: r,
158
+ props: s,
159
+ fingerprint: t.fingerprint
160
+ };
161
+ });
162
+ }, y = (e, t) => {
163
+ let n = [], r = (e, t, i) => {
164
+ if (e.kind !== "components" || !Array.isArray(t)) return;
165
+ let a = new Map((e.components ?? []).map((e) => [e.id, e]));
166
+ t.forEach((e, t) => {
167
+ if (!c(e)) return;
168
+ let o = a.get(String(e.componentId));
169
+ if (o === void 0) return;
170
+ let s = typeof e.fingerprint == "string" ? e.fingerprint : null;
171
+ s !== o.fingerprint && (s === null || o.migrations?.[s] === void 0) && n.push({
172
+ path: `${i}[${t}]`,
173
+ componentId: o.id,
174
+ fingerprint: s
175
+ });
176
+ let l = c(e.props) ? e.props : {};
177
+ for (let [e, n] of Object.entries(o.props)) r(n, l[e], `${i}[${t}].props.${e}`);
178
+ });
179
+ };
180
+ for (let [n, i] of Object.entries(e.fields)) r(i, t[n], n);
181
+ return n;
182
+ }, b = (e) => {
183
+ let t = [];
184
+ for (let [n, r] of Object.entries(e.fixtures ?? {})) t.push(...f(`fixtures.${n}`, e.props, r, `component '${e.id}'`, !0));
185
+ for (let [n, r] of Object.entries(e.variants ?? {})) {
186
+ let i = Object.fromEntries(Object.entries(e.props).filter(([e]) => e in r));
187
+ t.push(...f(`variants.${n}`, i, r, `component '${e.id}'`, !0));
188
+ }
189
+ return t;
190
+ }, x = () => `cins_${globalThis.crypto.randomUUID().replaceAll("-", "")}`;
191
+ //#endregion
192
+ export { g as applyDerivations, b as componentExampleViolations, p as contentViolations, x as newInstanceId, m as publishViolations, y as staleComponents, h as validateContent };
@@ -0,0 +1,60 @@
1
+ //#region src/visualEditing.ts
2
+ var e = "voltro.cms.visual/1", t = () => Array.from(globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16)), (e) => e.toString(16).padStart(2, "0")).join(""), n = /^[A-Za-z_][A-Za-z0-9_]*(\.\d+)?$/, r = (e, t) => {
3
+ if (e.origin !== t.origin) return null;
4
+ let n = e.data;
5
+ if (typeof n != "object" || !n) return null;
6
+ let r = n;
7
+ return r.protocol === "voltro.cms.visual/1" && typeof r.nonce == "string" && r.nonce === t.nonce ? r : null;
8
+ }, i = (t, i) => {
9
+ let a = r(t, i);
10
+ if (a === null) return null;
11
+ let o = {
12
+ protocol: e,
13
+ nonce: i.nonce
14
+ };
15
+ return a.kind === "ready" ? {
16
+ ...o,
17
+ kind: "ready"
18
+ } : typeof a.path != "string" || !n.test(a.path) ? null : a.kind === "select" ? {
19
+ ...o,
20
+ kind: "select",
21
+ path: a.path
22
+ } : a.kind === "move" && Number.isInteger(a.to) && a.to >= 0 ? {
23
+ ...o,
24
+ kind: "move",
25
+ path: a.path,
26
+ to: a.to
27
+ } : null;
28
+ }, a = (t, n) => {
29
+ let i = r(t, n);
30
+ return i === null || i.kind !== "values" || typeof i.values != "object" || i.values === null || Array.isArray(i.values) ? null : {
31
+ protocol: e,
32
+ nonce: n.nonce,
33
+ kind: "values",
34
+ values: i.values
35
+ };
36
+ }, o = (t, n) => ({
37
+ protocol: e,
38
+ nonce: t.nonce,
39
+ ...n
40
+ }), s = (e) => ({ "data-cms-source": e }), c = (e) => {
41
+ let t = e;
42
+ return (typeof t?.closest == "function" ? t.closest("[data-cms-source]") : null)?.getAttribute("data-cms-source") ?? null;
43
+ }, l = (e) => {
44
+ let [t = "", n] = e.split(".");
45
+ return n === void 0 ? { field: t } : {
46
+ field: t,
47
+ index: Number(n)
48
+ };
49
+ }, u = (e, t, n) => {
50
+ let r = Math.max(0, Math.min(e.length - 1, n));
51
+ if (t < 0 || t >= e.length || t === r) return e;
52
+ let i = [...e], [a] = i.splice(t, 1);
53
+ return i.splice(r, 0, a), i;
54
+ }, d = (e, t) => {
55
+ if (!n.test(t)) return null;
56
+ let { field: r, index: i } = l(t), a = e.querySelector(`[data-cms-field="${r}"]`);
57
+ return a === null || i === void 0 ? a : a.querySelectorAll("[data-cms-components] > [data-cms-component]")[i] ?? null;
58
+ };
59
+ //#endregion
60
+ export { e as VISUAL_EDITING_PROTOCOL, d as formPartOf, u as moveEntry, t as newVisualNonce, l as parseSourcePath, a as readEditorMessage, i as readPreviewMessage, s as sourceAttributes, c as sourcePathOf, o as visualMessage };