@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.
- package/CHANGELOG.md +1215 -0
- package/THIRD-PARTY-NOTICES.md +118 -600
- package/dist/ContentForm.js +282 -0
- package/dist/RichDocumentEditor.js +550 -0
- package/dist/RichDocumentView.js +132 -0
- package/dist/RichTextSurface.js +135 -0
- package/dist/aiCandidates.js +199 -0
- package/dist/aiOperations.js +152 -0
- package/dist/audiences.js +31 -0
- package/dist/availability.js +121 -0
- package/dist/blueprint.js +166 -0
- package/dist/bulk.js +281 -0
- package/dist/cacheIdentity.js +152 -0
- package/dist/changes.js +90 -0
- package/dist/cmsContext.js +229 -0
- package/dist/collections.js +224 -0
- package/dist/consent.js +29 -0
- package/dist/contentType.js +191 -0
- package/dist/contentfulImport.js +162 -0
- package/dist/copies.js +89 -0
- package/dist/cutover.js +202 -0
- package/dist/deliveryChecks.js +138 -0
- package/dist/domains.js +145 -0
- package/dist/draftTexts.js +164 -0
- package/dist/duplicates.js +78 -0
- package/dist/edgePurge.js +69 -0
- package/dist/editHistory.js +113 -0
- package/dist/effectForm.js +11 -0
- package/dist/environments.js +109 -0
- package/dist/errors.js +67 -0
- package/dist/experiments.js +528 -0
- package/dist/exposure.js +28 -0
- package/dist/extensionManifest.js +81 -0
- package/dist/extensions.js +314 -0
- package/dist/fieldSchema.js +199 -0
- package/dist/formStrings.js +74 -0
- package/dist/glossary.js +73 -0
- package/dist/history.js +54 -0
- package/dist/htmlImport.js +297 -0
- package/dist/index.d.ts +2266 -170
- package/dist/index.js +73 -3947
- package/dist/media.js +29 -0
- package/dist/metrics.js +46 -0
- package/dist/migration.js +193 -0
- package/dist/migrationStages.js +13 -0
- package/dist/presenceAnchors.js +68 -0
- package/dist/preview.js +31 -0
- package/dist/promotion.js +107 -0
- package/dist/quality.js +188 -0
- package/dist/recurrence.js +78 -0
- package/dist/redirects.js +99 -0
- package/dist/referenceGraph.js +223 -0
- package/dist/references.js +173 -0
- package/dist/release.js +205 -0
- package/dist/rest.js +52 -0
- package/dist/review.js +160 -0
- package/dist/richDocument.js +491 -0
- package/dist/richInline.js +100 -0
- package/dist/schedule.js +80 -0
- package/dist/search.js +148 -0
- package/dist/selectionIntent.js +164 -0
- package/dist/seo.js +31 -0
- package/dist/series.js +105 -0
- package/dist/share.js +112 -0
- package/dist/stewardship.js +146 -0
- package/dist/taxonomy.js +36 -0
- package/dist/team.js +103 -0
- package/dist/templates.js +106 -0
- package/dist/trackChanges.js +197 -0
- package/dist/translation.js +64 -0
- package/dist/tree.js +87 -0
- package/dist/usage.js +50 -0
- package/dist/validation.js +192 -0
- package/dist/visualEditing.js +60 -0
- package/dist/web.d.ts +927 -131
- package/dist/web.js +33 -2
- package/dist/workflow.js +322 -0
- package/dist/write.js +394 -0
- package/dist/xliff.js +325 -0
- package/package.json +6 -6
- package/dist/extensionManifest-BK3ZcL2P.js +0 -2782
|
@@ -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 };
|
package/dist/taxonomy.js
ADDED
|
@@ -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 };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
//#region src/templates.ts
|
|
2
|
+
var e = (e) => Array.isArray(e) ? e.map((e) => typeof e == "object" && e ? String(e.componentId ?? "") : "") : [], t = (e, t) => {
|
|
3
|
+
let n = e.templates, r = n === void 0 ? void 0 : t[n.field];
|
|
4
|
+
if (n !== void 0 && typeof r == "string" && r !== "") return n.list.find((e) => e.id === r) ?? null;
|
|
5
|
+
}, n = (n, i) => {
|
|
6
|
+
let a = n.templates, o = t(n, i);
|
|
7
|
+
if (a === void 0 || o === void 0) return [];
|
|
8
|
+
if (o === null) return [{
|
|
9
|
+
field: a.field,
|
|
10
|
+
rule: "unknown",
|
|
11
|
+
message: `no template '${String(i[a.field])}' for ${n.name}`
|
|
12
|
+
}];
|
|
13
|
+
let s = e(i[a.components]), c = [];
|
|
14
|
+
for (let e of o.required ?? []) s.includes(e.id) || c.push({
|
|
15
|
+
field: a.components,
|
|
16
|
+
rule: "required",
|
|
17
|
+
message: `the ${o.displayName} template needs a ${e.displayName}`
|
|
18
|
+
});
|
|
19
|
+
o.first !== void 0 && s.length > 0 && s[0] !== o.first.id && c.push({
|
|
20
|
+
field: a.components,
|
|
21
|
+
rule: "position",
|
|
22
|
+
message: `the ${o.displayName} template starts with a ${o.first.displayName}`
|
|
23
|
+
});
|
|
24
|
+
for (let e of o.max ?? []) s.filter((t) => t === e.component.id).length > e.count && c.push({
|
|
25
|
+
field: a.components,
|
|
26
|
+
rule: "max",
|
|
27
|
+
message: `the ${o.displayName} template allows at most ${e.count} ${e.component.displayName}`
|
|
28
|
+
});
|
|
29
|
+
for (let [t, r] of Object.entries(o.regions ?? {})) {
|
|
30
|
+
let a = e(i[t]), s = r.allowed === void 0 ? void 0 : new Set(r.allowed.map((e) => e.id)), l = new Map((n.fields[t]?.components ?? []).map((e) => [e.id, e.displayName]));
|
|
31
|
+
for (let e of new Set(a)) s !== void 0 && !s.has(e) && c.push({
|
|
32
|
+
field: t,
|
|
33
|
+
rule: "region",
|
|
34
|
+
message: `the ${o.displayName} template does not allow a ${l.get(e) ?? e} in ${t}`
|
|
35
|
+
});
|
|
36
|
+
for (let e of r.required ?? []) a.includes(e.id) || c.push({
|
|
37
|
+
field: t,
|
|
38
|
+
rule: "required",
|
|
39
|
+
message: `the ${o.displayName} template needs a ${e.displayName} in ${t}`
|
|
40
|
+
});
|
|
41
|
+
r.maxItems !== void 0 && a.length > r.maxItems && c.push({
|
|
42
|
+
field: t,
|
|
43
|
+
rule: "max",
|
|
44
|
+
message: `the ${o.displayName} template allows at most ${r.maxItems} in ${t}`
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
let l = a.width ?? "width", u = [a.components, ...Object.keys(o.regions ?? {})].flatMap((e) => (Array.isArray(i[e]) ? i[e] : []).map((t, n) => ({
|
|
48
|
+
field: e,
|
|
49
|
+
index: n,
|
|
50
|
+
item: t
|
|
51
|
+
})));
|
|
52
|
+
for (let e of o.widths ?? []) for (let { field: t, index: n, item: r } of u) {
|
|
53
|
+
let i = r?.props?.[l];
|
|
54
|
+
r?.componentId === e.component.id && typeof i == "string" && !e.allowed.includes(i) && c.push({
|
|
55
|
+
field: `${t}[${n}].props.${l}`,
|
|
56
|
+
rule: "width",
|
|
57
|
+
message: `in the ${o.displayName} template a ${e.component.displayName} is ${e.allowed.join(" or ")}, not ${i}`
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (o.maxDepth !== void 0) for (let { field: e, index: t, item: n } of u) r(n) > o.maxDepth && c.push({
|
|
61
|
+
field: `${e}[${t}]`,
|
|
62
|
+
rule: "depth",
|
|
63
|
+
message: `the ${o.displayName} template nests components at most ${o.maxDepth} deep`
|
|
64
|
+
});
|
|
65
|
+
return c;
|
|
66
|
+
}, r = (e) => {
|
|
67
|
+
let t = Object.values(e?.props ?? {}).filter((e) => Array.isArray(e) && e.some((e) => typeof e == "object" && !!e && typeof e.componentId == "string"));
|
|
68
|
+
return 1 + Math.max(0, ...t.flatMap((e) => e.map(r)));
|
|
69
|
+
}, i = (e, t) => {
|
|
70
|
+
let n = e.templates, r = n?.list.find((e) => e.id === t);
|
|
71
|
+
return n === void 0 || r === void 0 ? null : {
|
|
72
|
+
...r.values,
|
|
73
|
+
[n.field]: r.id,
|
|
74
|
+
[n.components]: (r.sections ?? []).map((e) => ({
|
|
75
|
+
componentId: e.component.id,
|
|
76
|
+
props: { ...e.props }
|
|
77
|
+
}))
|
|
78
|
+
};
|
|
79
|
+
}, a = (e, t, n) => {
|
|
80
|
+
let r = (t) => {
|
|
81
|
+
throw Error(`defineContentType('${e}'): templates ${t}`);
|
|
82
|
+
}, i = t[n.field];
|
|
83
|
+
(i === void 0 || i.kind !== "string" || !i.isOptional) && r(`field '${n.field}' must be a declared optional string field.`);
|
|
84
|
+
let a = t[n.components];
|
|
85
|
+
(a === void 0 || a.kind !== "components") && r(`components '${n.components}' must be a declared Schema.Components field.`);
|
|
86
|
+
let o = new Set((a?.components ?? []).map((e) => e.id)), s = /* @__PURE__ */ new Set();
|
|
87
|
+
for (let e of n.list) {
|
|
88
|
+
s.has(e.id) && r(`id '${e.id}' is declared twice.`), s.add(e.id);
|
|
89
|
+
let i = [
|
|
90
|
+
...(e.sections ?? []).map((e) => e.component),
|
|
91
|
+
...e.required ?? [],
|
|
92
|
+
...e.first ? [e.first] : [],
|
|
93
|
+
...(e.max ?? []).map((e) => e.component)
|
|
94
|
+
];
|
|
95
|
+
for (let t of i) o.has(t.id) || r(`'${e.id}' uses '${t.id}', which '${n.components}' does not allow.`);
|
|
96
|
+
for (let [i, a] of Object.entries(e.regions ?? {})) {
|
|
97
|
+
let o = t[i];
|
|
98
|
+
(o === void 0 || o.kind !== "components" || i === n.components) && r(`'${e.id}' region '${i}' must be another declared Schema.Components field.`);
|
|
99
|
+
let s = new Set((o?.components ?? []).map((e) => e.id));
|
|
100
|
+
for (let t of [...a.allowed ?? [], ...a.required ?? []]) s.has(t.id) || r(`'${e.id}' region '${i}' uses '${t.id}', which '${i}' does not allow.`);
|
|
101
|
+
}
|
|
102
|
+
e.maxDepth !== void 0 && (!Number.isInteger(e.maxDepth) || e.maxDepth < 1) && r(`'${e.id}' maxDepth must be a whole number from 1.`);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
//#endregion
|
|
106
|
+
export { a as checkTemplates, t as templateOf, i as templateValues, n as templateViolations };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { newBlockId as e } from "./richDocument.js";
|
|
2
|
+
import { inlineText as t, mergeInline as n, sliceInline as r } from "./richInline.js";
|
|
3
|
+
//#region src/trackChanges.ts
|
|
4
|
+
var i = (e, t) => e.map((e) => ({
|
|
5
|
+
...e,
|
|
6
|
+
change: t
|
|
7
|
+
})), a = (e) => {
|
|
8
|
+
switch (e.type) {
|
|
9
|
+
case "paragraph":
|
|
10
|
+
case "heading": return [e.content];
|
|
11
|
+
case "list": return e.items;
|
|
12
|
+
case "table": return e.rows.flat();
|
|
13
|
+
case "image":
|
|
14
|
+
case "file":
|
|
15
|
+
case "component": return [];
|
|
16
|
+
}
|
|
17
|
+
}, o = (e) => e.change !== void 0 || a(e).some((e) => e.some((e) => e.change !== void 0)), s = (e) => e.blocks.some(o), c = /[\p{L}\p{N}_]/u, l = (e, a, o) => {
|
|
18
|
+
let s = t(e), l = t(a);
|
|
19
|
+
if (s === l) return a;
|
|
20
|
+
let u = 0;
|
|
21
|
+
for (; u < s.length && u < l.length && s[u] === l[u];) u += 1;
|
|
22
|
+
let d = 0;
|
|
23
|
+
for (; d < s.length - u && d < l.length - u && s[s.length - 1 - d] === l[l.length - 1 - d];) d += 1;
|
|
24
|
+
for (; u > 0 && c.test(s[u - 1]);) --u;
|
|
25
|
+
for (; d > 0 && c.test(s[s.length - d]);) --d;
|
|
26
|
+
return n([
|
|
27
|
+
...r(a, 0, u),
|
|
28
|
+
...i(r(e, u, s.length - d), {
|
|
29
|
+
...o,
|
|
30
|
+
kind: "delete"
|
|
31
|
+
}),
|
|
32
|
+
...i(r(a, u, l.length - d), {
|
|
33
|
+
...o,
|
|
34
|
+
kind: "insert"
|
|
35
|
+
}),
|
|
36
|
+
...r(a, l.length - d, l.length)
|
|
37
|
+
]);
|
|
38
|
+
}, u = (e, t, n) => Array.from({ length: Math.max(e.length, t.length) }, (r, a) => {
|
|
39
|
+
let o = e[a], s = t[a];
|
|
40
|
+
return o === void 0 ? i(s ?? [], {
|
|
41
|
+
...n,
|
|
42
|
+
kind: "insert"
|
|
43
|
+
}) : s === void 0 ? i(o, {
|
|
44
|
+
...n,
|
|
45
|
+
kind: "delete"
|
|
46
|
+
}) : l(o, s, n);
|
|
47
|
+
}), d = (e, t) => JSON.stringify(e) === JSON.stringify(t), f = (e, t, n) => {
|
|
48
|
+
if ((e.type === "paragraph" || e.type === "heading") && t.type === e.type) return {
|
|
49
|
+
...t,
|
|
50
|
+
content: l(e.content, t.content, n)
|
|
51
|
+
};
|
|
52
|
+
if (e.type === "list" && t.type === "list") {
|
|
53
|
+
let r = u(e.items, t.items, n), i = r.map((n, r) => t.levels?.[r] ?? e.levels?.[r] ?? 0);
|
|
54
|
+
return {
|
|
55
|
+
...t,
|
|
56
|
+
items: r,
|
|
57
|
+
...i.some((e) => e > 0) ? { levels: i } : {}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (e.type === "table" && t.type === "table") {
|
|
61
|
+
let r = Array.from({ length: Math.max(e.rows.length, t.rows.length) }, (r, i) => u(e.rows[i] ?? [], t.rows[i] ?? [], n));
|
|
62
|
+
return {
|
|
63
|
+
...t,
|
|
64
|
+
rows: r
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}, p = (t, n, r) => {
|
|
69
|
+
let i = new Map(t.blocks.map((e) => [e.id, e])), a = new Set(n.blocks.map((e) => e.id)), s = [], c = [];
|
|
70
|
+
for (let t of n.blocks) {
|
|
71
|
+
let n = i.get(t.id);
|
|
72
|
+
if (n === void 0) {
|
|
73
|
+
c.push({
|
|
74
|
+
...t,
|
|
75
|
+
change: {
|
|
76
|
+
...r,
|
|
77
|
+
kind: "insert"
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (d(n, t)) {
|
|
83
|
+
c.push(n);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (o(n)) {
|
|
87
|
+
s.push(t.id), c.push(n);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
let a = f(n, t, r);
|
|
91
|
+
a === null ? c.push({
|
|
92
|
+
...n,
|
|
93
|
+
change: {
|
|
94
|
+
...r,
|
|
95
|
+
kind: "delete"
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
...t,
|
|
99
|
+
id: e(),
|
|
100
|
+
change: {
|
|
101
|
+
...r,
|
|
102
|
+
kind: "insert"
|
|
103
|
+
}
|
|
104
|
+
}) : c.push(a);
|
|
105
|
+
}
|
|
106
|
+
return t.blocks.forEach((e, n) => {
|
|
107
|
+
if (a.has(e.id)) return;
|
|
108
|
+
let i = o(e) ? e : {
|
|
109
|
+
...e,
|
|
110
|
+
change: {
|
|
111
|
+
...r,
|
|
112
|
+
kind: "delete"
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
o(e) && s.push(e.id);
|
|
116
|
+
let l = t.blocks.slice(0, n).reverse().find((e) => c.some((t) => t.id === e.id)), u = l === void 0 ? 0 : c.findIndex((e) => e.id === l.id) + 1;
|
|
117
|
+
for (; u < c.length && c[u].change?.kind === "delete" && !a.has(c[u].id);) u += 1;
|
|
118
|
+
c.splice(u, 0, i);
|
|
119
|
+
}), {
|
|
120
|
+
document: {
|
|
121
|
+
...t,
|
|
122
|
+
blocks: c
|
|
123
|
+
},
|
|
124
|
+
conflicts: s
|
|
125
|
+
};
|
|
126
|
+
}, m = (e, t) => {
|
|
127
|
+
if (e === void 0) return "keep";
|
|
128
|
+
let n = t(e);
|
|
129
|
+
return n === "keep" ? "keep" : n === "accept" == (e.kind === "insert") ? "unmark" : "drop";
|
|
130
|
+
}, h = (e) => {
|
|
131
|
+
let { change: t, ...n } = e;
|
|
132
|
+
return n;
|
|
133
|
+
}, g = (e, t) => n(e.flatMap((e) => {
|
|
134
|
+
let n = m(e.change, t);
|
|
135
|
+
return n === "drop" ? [] : [n === "unmark" ? h(e) : e];
|
|
136
|
+
})), _ = (e, t) => t.length === 0 && e.length > 0 && e.every((e) => e.change !== void 0), v = (e, t) => ({
|
|
137
|
+
...e,
|
|
138
|
+
blocks: e.blocks.flatMap((e) => {
|
|
139
|
+
let n = m(e.change, t);
|
|
140
|
+
if (n === "drop") return [];
|
|
141
|
+
let r = n === "unmark" ? h(e) : e;
|
|
142
|
+
switch (r.type) {
|
|
143
|
+
case "paragraph":
|
|
144
|
+
case "heading": return [{
|
|
145
|
+
...r,
|
|
146
|
+
content: g(r.content, t)
|
|
147
|
+
}];
|
|
148
|
+
case "list": {
|
|
149
|
+
let e = r.items.map((e) => g(e, t)), n = e.map((e, t) => !_(r.items[t], e)), i = r.levels?.filter((e, t) => n[t]);
|
|
150
|
+
return [{
|
|
151
|
+
...r,
|
|
152
|
+
items: e.filter((e, t) => n[t]),
|
|
153
|
+
...i === void 0 ? {} : { levels: i }
|
|
154
|
+
}];
|
|
155
|
+
}
|
|
156
|
+
case "table": {
|
|
157
|
+
let e = r.rows.map((e) => e.map((e) => g(e, t)));
|
|
158
|
+
return [{
|
|
159
|
+
...r,
|
|
160
|
+
rows: e.filter((e, t) => !e.every((e, n) => _(r.rows[t][n], e)))
|
|
161
|
+
}];
|
|
162
|
+
}
|
|
163
|
+
case "image":
|
|
164
|
+
case "file":
|
|
165
|
+
case "component": return [r];
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
}), y = (e) => {
|
|
169
|
+
let n = /* @__PURE__ */ new Map(), r = (e, t) => {
|
|
170
|
+
let r = n.get(e.id) ?? {
|
|
171
|
+
id: e.id,
|
|
172
|
+
by: e.by,
|
|
173
|
+
at: e.at,
|
|
174
|
+
blockIds: [],
|
|
175
|
+
inserted: "",
|
|
176
|
+
deleted: "",
|
|
177
|
+
blocks: 0
|
|
178
|
+
};
|
|
179
|
+
return r.blockIds.includes(t) || r.blockIds.push(t), n.set(e.id, r), r;
|
|
180
|
+
};
|
|
181
|
+
for (let n of e.blocks) {
|
|
182
|
+
if (n.change !== void 0) {
|
|
183
|
+
let e = r(n.change, n.id);
|
|
184
|
+
e.blocks += 1;
|
|
185
|
+
let i = a(n).map(t).join(" ");
|
|
186
|
+
n.change.kind === "insert" ? e.inserted += i : e.deleted += i;
|
|
187
|
+
}
|
|
188
|
+
for (let e of a(n)) for (let t of e) {
|
|
189
|
+
if (t.change === void 0) continue;
|
|
190
|
+
let e = r(t.change, n.id);
|
|
191
|
+
t.change.kind === "insert" ? e.inserted += t.text : e.deleted += t.text;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return [...n.values()];
|
|
195
|
+
};
|
|
196
|
+
//#endregion
|
|
197
|
+
export { o as blockHasChanges, s as documentHasChanges, y as pendingChanges, v as resolveChanges, p as trackChanges, l as trackInline };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { asTyped as e } from "./effectForm.js";
|
|
2
|
+
import { CMS_REVISIONS_TABLE as t } from "./contentType.js";
|
|
3
|
+
import { changedFields as n } from "./history.js";
|
|
4
|
+
import { and as r, eq as i, inSet as a } from "@voltro/database";
|
|
5
|
+
//#region src/translation.ts
|
|
6
|
+
var o = (e, t, n) => e.query({
|
|
7
|
+
table: t,
|
|
8
|
+
predicate: n,
|
|
9
|
+
order: [],
|
|
10
|
+
take: void 0,
|
|
11
|
+
skip: void 0,
|
|
12
|
+
projection: void 0
|
|
13
|
+
}), s = 500, c = async (e, t, n, i, ...c) => {
|
|
14
|
+
let l = [];
|
|
15
|
+
for (let u = 0; u < i.length; u += s) l.push(...await o(e, t, r(a(n, i.slice(u, u + s)), ...c)));
|
|
16
|
+
return l;
|
|
17
|
+
}, l = async (e, t, n, r, i, a) => (await u(e, t, [n], r, i, a)).get(n), u = async (e, r, a, o, s, l) => {
|
|
18
|
+
let u = [...new Set(a)], d = await c(e, `${r.name}_drafts`, "documentId", u, i("site", o.site), i("environment", o.environment)), f = /* @__PURE__ */ new Map();
|
|
19
|
+
for (let e of d) {
|
|
20
|
+
let t = String(e.documentId);
|
|
21
|
+
f.set(t, (f.get(t) ?? /* @__PURE__ */ new Map()).set(String(e.locale), e));
|
|
22
|
+
}
|
|
23
|
+
let p = await c(e, t, "id", [...new Set(d.map((e) => String(e.revisionId)))]), m = new Map(p.map((e) => [String(e.id), e])), h = [...new Set(p.map((e) => e.basedOn).filter((e) => typeof e == "string"))], g = new Map((await c(e, t, "id", h)).map((e) => [String(e.id), e])), _ = (e) => {
|
|
24
|
+
let t = e.get(s), i = t === void 0 ? void 0 : m.get(String(t.revisionId)), a = l.filter((e) => e !== s).map((a) => {
|
|
25
|
+
let o = e.get(a);
|
|
26
|
+
if (o === void 0) return {
|
|
27
|
+
locale: a,
|
|
28
|
+
state: "missing",
|
|
29
|
+
variantId: null,
|
|
30
|
+
changed: []
|
|
31
|
+
};
|
|
32
|
+
let s = String(o.id), c = m.get(String(o.revisionId))?.basedOn;
|
|
33
|
+
if (typeof c != "string" || t === void 0) return {
|
|
34
|
+
locale: a,
|
|
35
|
+
state: "unknown",
|
|
36
|
+
variantId: s,
|
|
37
|
+
changed: []
|
|
38
|
+
};
|
|
39
|
+
if (c === t.revisionId) return {
|
|
40
|
+
locale: a,
|
|
41
|
+
state: "upToDate",
|
|
42
|
+
variantId: s,
|
|
43
|
+
changed: []
|
|
44
|
+
};
|
|
45
|
+
let l = g.get(c);
|
|
46
|
+
return {
|
|
47
|
+
locale: a,
|
|
48
|
+
state: "outdated",
|
|
49
|
+
variantId: s,
|
|
50
|
+
changed: l === void 0 || i === void 0 ? [] : n(r.fields, l.values ?? {}, i.values ?? {})
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
source: t === void 0 ? null : {
|
|
55
|
+
variantId: String(t.id),
|
|
56
|
+
revisionId: String(t.revisionId)
|
|
57
|
+
},
|
|
58
|
+
targets: a
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
return new Map(u.map((e) => [e, _(f.get(e) ?? /* @__PURE__ */ new Map())]));
|
|
62
|
+
}, d = (...t) => e(() => l(...t)), f = (...t) => e(() => u(...t));
|
|
63
|
+
//#endregion
|
|
64
|
+
export { l as translationStatus, d as translationStatusEffect, u as translationStatuses, f as translationStatusesEffect };
|