@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,166 @@
|
|
|
1
|
+
import { templateValues as e } from "./templates.js";
|
|
2
|
+
import { asTyped as t } from "./effectForm.js";
|
|
3
|
+
import { ContentIdConflict as n, ContentNotFound as r, ContentValidationFailed as i, ReferenceUnavailable as a, ReviewRequired as o, RevisionMismatch as s } from "./errors.js";
|
|
4
|
+
import { applyDerivations as c } from "./validation.js";
|
|
5
|
+
import { teamProblems as l } from "./team.js";
|
|
6
|
+
import { reviewRequiredFor as u } from "./review.js";
|
|
7
|
+
import { publish as d, saveDraft as f } from "./write.js";
|
|
8
|
+
import { and as p, eq as m } from "@voltro/database";
|
|
9
|
+
//#region src/blueprint.ts
|
|
10
|
+
var h = class extends Error {
|
|
11
|
+
reason;
|
|
12
|
+
_tag = "BlueprintInvalid";
|
|
13
|
+
constructor(e) {
|
|
14
|
+
super(`blueprint not usable: ${e}`), this.reason = e;
|
|
15
|
+
}
|
|
16
|
+
}, g = "$entry", _ = (e) => ({ [g]: e }), v = (e) => {
|
|
17
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return;
|
|
18
|
+
let t = Object.keys(e), n = e[g];
|
|
19
|
+
return t.length === 1 && typeof n == "string" ? n : void 0;
|
|
20
|
+
}, y = (e, t) => {
|
|
21
|
+
let n = v(e);
|
|
22
|
+
if (n !== void 0) t.add(n);
|
|
23
|
+
else if (Array.isArray(e)) for (let n of e) y(n, t);
|
|
24
|
+
else if (typeof e == "object" && e) for (let n of Object.values(e)) y(n, t);
|
|
25
|
+
return t;
|
|
26
|
+
}, b = (e, t) => {
|
|
27
|
+
let n = v(e);
|
|
28
|
+
return n === void 0 ? Array.isArray(e) ? e.map((e) => b(e, t)) : typeof e == "object" && e ? Object.fromEntries(Object.entries(e).map(([e, n]) => [e, b(n, t)])) : e : t.get(n);
|
|
29
|
+
}, x = (e) => {
|
|
30
|
+
let t = e.team === void 0 ? [] : l(e.team);
|
|
31
|
+
if (t.length > 0) throw new h(t.join("; "));
|
|
32
|
+
let n = /* @__PURE__ */ new Map();
|
|
33
|
+
for (let t of e.entries) {
|
|
34
|
+
if (n.has(t.key)) throw new h(`the key '${t.key}' is used twice`);
|
|
35
|
+
n.set(t.key, t);
|
|
36
|
+
}
|
|
37
|
+
let r = new Map(e.entries.map((e) => [e.key, y([e.values, e.translations ?? {}], /* @__PURE__ */ new Set())]));
|
|
38
|
+
for (let [e, t] of r) for (let r of t) if (!n.has(r)) throw new h(`'${e}' references '${r}', which is no entry`);
|
|
39
|
+
let i = [], a = /* @__PURE__ */ new Map(), o = (e, t) => {
|
|
40
|
+
if (a.get(e) !== "done") {
|
|
41
|
+
if (a.get(e) === "visiting") throw new h(`the entries reference each other in a circle: ${[...t, e].join(" → ")}`);
|
|
42
|
+
a.set(e, "visiting");
|
|
43
|
+
for (let n of r.get(e) ?? []) o(n, [...t, e]);
|
|
44
|
+
a.set(e, "done"), i.push(n.get(e));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
for (let t of e.entries) o(t.key, []);
|
|
48
|
+
return {
|
|
49
|
+
...e,
|
|
50
|
+
entries: i
|
|
51
|
+
};
|
|
52
|
+
}, S = (e, t) => {
|
|
53
|
+
let n = e.find((e) => e.name === t.type);
|
|
54
|
+
if (n === void 0) throw new h(`'${t.key}' is of type '${t.type}', which this app does not have`);
|
|
55
|
+
if (t.match !== void 0 && n.fields[t.match] === void 0) throw new h(`'${t.key}' matches on '${t.match}', which ${n.name} does not have`);
|
|
56
|
+
return n;
|
|
57
|
+
}, C = (t, n, r, i) => {
|
|
58
|
+
let a = {};
|
|
59
|
+
if (n.template !== void 0) {
|
|
60
|
+
let r = e(t, n.template);
|
|
61
|
+
if (r === null) throw new h(`'${n.key}' is built from the template '${n.template}', which ${t.name} does not have`);
|
|
62
|
+
a = r;
|
|
63
|
+
}
|
|
64
|
+
let o = r === i ? {} : n.translations?.[r] ?? {};
|
|
65
|
+
return {
|
|
66
|
+
...a,
|
|
67
|
+
...n.values,
|
|
68
|
+
...o
|
|
69
|
+
};
|
|
70
|
+
}, w = (e, t) => {
|
|
71
|
+
if (typeof t.title == "string" && t.title !== "") return t.title;
|
|
72
|
+
let n = e.match === void 0 ? void 0 : t[e.match];
|
|
73
|
+
return typeof n == "string" && n !== "" ? n : e.key;
|
|
74
|
+
}, T = (e, t, n, r) => e.query({
|
|
75
|
+
table: `${t.name}_drafts`,
|
|
76
|
+
predicate: p(m("site", n.site), m("environment", n.environment), m("locale", n.locale), ...r === null ? [] : [r]),
|
|
77
|
+
order: [{
|
|
78
|
+
column: "id",
|
|
79
|
+
direction: "asc"
|
|
80
|
+
}],
|
|
81
|
+
take: 1,
|
|
82
|
+
skip: void 0,
|
|
83
|
+
projection: void 0
|
|
84
|
+
}), E = async (e, t, n, r, i, a) => {
|
|
85
|
+
if (a !== null) {
|
|
86
|
+
let [n] = await T(e, t, r, m("documentId", a));
|
|
87
|
+
if (n !== void 0) return n;
|
|
88
|
+
}
|
|
89
|
+
let o = n.match === void 0 ? void 0 : i[n.match];
|
|
90
|
+
if (n.match !== void 0 && (o == null || o === "")) return null;
|
|
91
|
+
let [s] = await T(e, t, r, n.match === void 0 ? null : m(n.match, o));
|
|
92
|
+
return s ?? null;
|
|
93
|
+
}, D = (e, t) => [e.locale, ...Object.keys(t.translations ?? {}).filter((t) => t !== e.locale)], O = async (e, t, n, r, i) => {
|
|
94
|
+
let a = /* @__PURE__ */ new Map(), o = [], s = 0;
|
|
95
|
+
for (let l of n.entries) {
|
|
96
|
+
let p = S(t, l), m = null, h = !1, g = !1;
|
|
97
|
+
for (let t of D(n, l)) {
|
|
98
|
+
if (g) break;
|
|
99
|
+
let _ = {
|
|
100
|
+
site: r.site,
|
|
101
|
+
environment: r.environment,
|
|
102
|
+
locale: t
|
|
103
|
+
}, v = C(p, l, t, n.locale), y = c(p, b(v, a)), x = await E(e, p, l, _, y, m);
|
|
104
|
+
if (x !== null) {
|
|
105
|
+
g = t === n.locale, m ??= String(x.documentId), o.push({
|
|
106
|
+
key: l.key,
|
|
107
|
+
type: p.name,
|
|
108
|
+
locale: t,
|
|
109
|
+
label: w(l, x),
|
|
110
|
+
action: "present",
|
|
111
|
+
documentId: String(x.documentId),
|
|
112
|
+
variantId: String(x.id),
|
|
113
|
+
outcome: null
|
|
114
|
+
});
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
let S = w(l, y);
|
|
118
|
+
m === null && !h && s++, h = !0;
|
|
119
|
+
let T = l.publish === !1 ? "draft" : p.review?.required === !0 || p.review?.required === "workspace" && (n.team?.reviewRequired ?? []).includes(p.name) ? "review" : "live";
|
|
120
|
+
if (!i) {
|
|
121
|
+
let e = T;
|
|
122
|
+
o.push({
|
|
123
|
+
key: l.key,
|
|
124
|
+
type: p.name,
|
|
125
|
+
locale: t,
|
|
126
|
+
label: S,
|
|
127
|
+
action: "create",
|
|
128
|
+
documentId: m,
|
|
129
|
+
variantId: null,
|
|
130
|
+
outcome: e
|
|
131
|
+
});
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
let D = await f(e, p, {
|
|
135
|
+
...y,
|
|
136
|
+
...m === null ? {} : { documentId: m }
|
|
137
|
+
}, _), O = T === "live" && await u(e, p, String(D.id)) ? "review" : T;
|
|
138
|
+
O === "live" && await d(e, p, String(D.id), _), m ??= String(D.documentId), o.push({
|
|
139
|
+
key: l.key,
|
|
140
|
+
type: p.name,
|
|
141
|
+
locale: t,
|
|
142
|
+
label: S,
|
|
143
|
+
action: "create",
|
|
144
|
+
documentId: String(D.documentId),
|
|
145
|
+
variantId: String(D.id),
|
|
146
|
+
outcome: O
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
m !== null && a.set(l.key, m);
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
blueprint: n.id,
|
|
153
|
+
steps: o,
|
|
154
|
+
documents: s
|
|
155
|
+
};
|
|
156
|
+
}, k = (e, t, n, r) => O(e, t, n, r, !1), A = (e, t, n, r) => O(e, t, n, r, !0), j = [
|
|
157
|
+
h,
|
|
158
|
+
n,
|
|
159
|
+
r,
|
|
160
|
+
i,
|
|
161
|
+
a,
|
|
162
|
+
o,
|
|
163
|
+
s
|
|
164
|
+
], M = (...e) => t(() => A(...e), ...j), N = (...e) => t(() => k(...e), ...j);
|
|
165
|
+
//#endregion
|
|
166
|
+
export { h as BlueprintInvalid, A as applyBlueprint, M as applyBlueprintEffect, _ as blueprintRef, x as defineBlueprint, k as planBlueprint, N as planBlueprintEffect };
|
package/dist/bulk.js
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { asTyped as e } from "./effectForm.js";
|
|
2
|
+
import { ContentIdConflict as t, ContentNotFound as n, ContentValidationFailed as r, ReferenceUnavailable as i, ReviewRequired as a, RevisionMismatch as o } from "./errors.js";
|
|
3
|
+
import { applyDerivations as s, publishViolations as c, validateContent as l } from "./validation.js";
|
|
4
|
+
import { CMS_REVISIONS_TABLE as u } from "./contentType.js";
|
|
5
|
+
import { assertApproved as d } from "./review.js";
|
|
6
|
+
import { assertReferencesAvailable as f } from "./availability.js";
|
|
7
|
+
import { setOwner as p, stewardshipOf as m } from "./stewardship.js";
|
|
8
|
+
import { pickDeclared as h, publishRevision as g, revalidateContent as _, saveDraft as v, unpublish as y } from "./write.js";
|
|
9
|
+
import { addToRelease as b, releaseStatusOf as x } from "./release.js";
|
|
10
|
+
import { and as S, eq as C, id as w, json as T, table as E, text as D, timestamp as O } from "@voltro/database";
|
|
11
|
+
import { tenant as k } from "@voltro/plugin-multitenancy/mixin";
|
|
12
|
+
//#region src/bulk.ts
|
|
13
|
+
var A = async (e, t, n, r) => (await e.query({
|
|
14
|
+
table: t,
|
|
15
|
+
predicate: S(C("id", n), C("site", r.site), C("environment", r.environment), C("locale", r.locale)),
|
|
16
|
+
order: [],
|
|
17
|
+
take: 1,
|
|
18
|
+
skip: void 0,
|
|
19
|
+
projection: void 0
|
|
20
|
+
}))[0], j = (e, t) => {
|
|
21
|
+
for (let t of [
|
|
22
|
+
"title",
|
|
23
|
+
"name",
|
|
24
|
+
"slug"
|
|
25
|
+
]) {
|
|
26
|
+
let n = e?.[t];
|
|
27
|
+
if (typeof n == "string" && n !== "") return n;
|
|
28
|
+
}
|
|
29
|
+
return t;
|
|
30
|
+
}, M = (e) => e.targets.map((e) => `${e.path}: ${e.reason}`), N = async (e, t, n, o, p) => {
|
|
31
|
+
let g = (e, t = {}) => ({
|
|
32
|
+
...p,
|
|
33
|
+
documentId: null,
|
|
34
|
+
title: p.id,
|
|
35
|
+
revisionId: null,
|
|
36
|
+
disposition: "blocked",
|
|
37
|
+
reason: e,
|
|
38
|
+
detail: [],
|
|
39
|
+
...t
|
|
40
|
+
});
|
|
41
|
+
if (t === void 0) return g("unknownType");
|
|
42
|
+
let _ = {
|
|
43
|
+
...n,
|
|
44
|
+
locale: p.locale
|
|
45
|
+
}, v = await A(e, `${t.name}_drafts`, p.id, _);
|
|
46
|
+
if (v === void 0) return g("notFound");
|
|
47
|
+
let y = {
|
|
48
|
+
documentId: String(v.documentId),
|
|
49
|
+
title: j(v, p.id)
|
|
50
|
+
}, b = (e, t = null) => ({
|
|
51
|
+
...p,
|
|
52
|
+
...y,
|
|
53
|
+
revisionId: t,
|
|
54
|
+
disposition: e,
|
|
55
|
+
reason: null,
|
|
56
|
+
detail: []
|
|
57
|
+
});
|
|
58
|
+
if (o.kind === "unpublish") return await A(e, `${t.name}_published`, p.id, _) === void 0 ? g("notPublished", y) : b("ready");
|
|
59
|
+
if (o.kind === "setOwner") return b((await m(e, t, y.documentId, n)).owner === o.owner ? "unchanged" : "ready");
|
|
60
|
+
if (o.kind === "setField") {
|
|
61
|
+
let e = t.fields[o.field];
|
|
62
|
+
if (e === void 0 || e.derived !== void 0 || e.kind === "richText" || e.kind === "components") return g("invalid", {
|
|
63
|
+
...y,
|
|
64
|
+
detail: [`${o.field}: not a field this can set`]
|
|
65
|
+
});
|
|
66
|
+
let n = String(v.revisionId);
|
|
67
|
+
if (JSON.stringify(v[o.field] ?? null) === JSON.stringify(o.value ?? null)) return b("unchanged", n);
|
|
68
|
+
try {
|
|
69
|
+
l(t, s(t, h(t, {
|
|
70
|
+
...v,
|
|
71
|
+
[o.field]: o.value
|
|
72
|
+
})));
|
|
73
|
+
} catch (e) {
|
|
74
|
+
if (e instanceof r) return g("invalid", {
|
|
75
|
+
...y,
|
|
76
|
+
revisionId: n,
|
|
77
|
+
detail: e.violations.map((e) => `${e.field}: ${e.message}`)
|
|
78
|
+
});
|
|
79
|
+
throw e;
|
|
80
|
+
}
|
|
81
|
+
return b("ready", n);
|
|
82
|
+
}
|
|
83
|
+
let S = String(v.revisionId);
|
|
84
|
+
if (o.kind === "addToRelease" && await x(e, o.releaseId) !== "draft") return g("releaseClosed", {
|
|
85
|
+
...y,
|
|
86
|
+
revisionId: S
|
|
87
|
+
});
|
|
88
|
+
if ((await A(e, `${t.name}_published`, p.id, _))?.revisionId === S) return b("unchanged", S);
|
|
89
|
+
try {
|
|
90
|
+
let [n] = await e.query({
|
|
91
|
+
table: u,
|
|
92
|
+
predicate: C("id", S),
|
|
93
|
+
order: [],
|
|
94
|
+
take: 1,
|
|
95
|
+
skip: void 0,
|
|
96
|
+
projection: void 0
|
|
97
|
+
}), r = n?.values ?? {}, i = c(t, r);
|
|
98
|
+
if (i.length > 0) return g("incomplete", {
|
|
99
|
+
...y,
|
|
100
|
+
revisionId: S,
|
|
101
|
+
detail: i.map((e) => e.field)
|
|
102
|
+
});
|
|
103
|
+
await d(e, t, p.id, _, S), await f(e, t, p.id, r, _);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
if (e instanceof a) return g("reviewRequired", {
|
|
106
|
+
...y,
|
|
107
|
+
revisionId: S
|
|
108
|
+
});
|
|
109
|
+
if (e instanceof i) return g("referenceUnavailable", {
|
|
110
|
+
...y,
|
|
111
|
+
revisionId: S,
|
|
112
|
+
detail: M(e)
|
|
113
|
+
});
|
|
114
|
+
throw e;
|
|
115
|
+
}
|
|
116
|
+
return b("ready", S);
|
|
117
|
+
}, P = async (e, t, n, r, i) => {
|
|
118
|
+
let a = new Map(t.map((e) => [e.name, e])), o = [];
|
|
119
|
+
for (let t of i) o.push(await N(e, a.get(t.type), n, r, t));
|
|
120
|
+
return o;
|
|
121
|
+
}, F = async (e, t, s, c, l) => {
|
|
122
|
+
let u = new Map(t.map((e) => [e.name, e])), d = [], f = /* @__PURE__ */ new Set();
|
|
123
|
+
for (let t of l) {
|
|
124
|
+
let l = {
|
|
125
|
+
type: t.type,
|
|
126
|
+
id: t.id,
|
|
127
|
+
locale: t.locale,
|
|
128
|
+
title: t.title
|
|
129
|
+
};
|
|
130
|
+
if (t.disposition !== "ready") {
|
|
131
|
+
d.push({
|
|
132
|
+
...l,
|
|
133
|
+
outcome: t.disposition === "unchanged" ? "unchanged" : "failed",
|
|
134
|
+
reason: t.reason,
|
|
135
|
+
detail: t.detail
|
|
136
|
+
});
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
let m = u.get(t.type), _ = {
|
|
140
|
+
...s,
|
|
141
|
+
locale: t.locale
|
|
142
|
+
};
|
|
143
|
+
try {
|
|
144
|
+
if (m === void 0) throw new n({
|
|
145
|
+
contentType: t.type,
|
|
146
|
+
id: t.id,
|
|
147
|
+
stage: "draft"
|
|
148
|
+
});
|
|
149
|
+
if (c.kind === "publish") await e.transactional((e) => g(e, m, t.id, _, t.revisionId ?? "")), f.add(m);
|
|
150
|
+
else if (c.kind === "addToRelease") await e.transactional((e) => b(e, c.releaseId, {
|
|
151
|
+
type: m,
|
|
152
|
+
id: t.id,
|
|
153
|
+
locale: t.locale,
|
|
154
|
+
action: "publish",
|
|
155
|
+
revisionId: t.revisionId ?? ""
|
|
156
|
+
}));
|
|
157
|
+
else if (c.kind === "unpublish") await e.transactional((e) => y(e, m, t.id, _)), f.add(m);
|
|
158
|
+
else if (c.kind === "setField") await e.transactional(async (e) => {
|
|
159
|
+
let r = await A(e, `${m.name}_drafts`, t.id, _);
|
|
160
|
+
if (r === void 0) throw new n({
|
|
161
|
+
contentType: t.type,
|
|
162
|
+
id: t.id,
|
|
163
|
+
stage: "draft"
|
|
164
|
+
});
|
|
165
|
+
await v(e, m, {
|
|
166
|
+
...h(m, r),
|
|
167
|
+
id: t.id,
|
|
168
|
+
[c.field]: c.value
|
|
169
|
+
}, _, t.revisionId === null ? {} : { expectedRevision: t.revisionId });
|
|
170
|
+
});
|
|
171
|
+
else {
|
|
172
|
+
if (t.documentId === null) throw new n({
|
|
173
|
+
contentType: t.type,
|
|
174
|
+
id: t.id,
|
|
175
|
+
stage: "draft"
|
|
176
|
+
});
|
|
177
|
+
await p(e, m, t.documentId, s, c.owner);
|
|
178
|
+
}
|
|
179
|
+
d.push({
|
|
180
|
+
...l,
|
|
181
|
+
outcome: "done",
|
|
182
|
+
reason: null,
|
|
183
|
+
detail: []
|
|
184
|
+
});
|
|
185
|
+
} catch (e) {
|
|
186
|
+
let t = e instanceof a ? "reviewRequired" : e instanceof o ? "revisionMoved" : e instanceof r ? "incomplete" : e instanceof i ? "referenceUnavailable" : e instanceof n ? e.stage === "published" ? "notPublished" : "notFound" : "failed", s = e instanceof i ? M(e) : e instanceof r ? e.violations.map((e) => e.field) : t === "failed" ? [e instanceof Error ? e.message : String(e)] : [];
|
|
187
|
+
d.push({
|
|
188
|
+
...l,
|
|
189
|
+
outcome: "failed",
|
|
190
|
+
reason: t,
|
|
191
|
+
detail: s
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
for (let e of f) _(e);
|
|
196
|
+
return d;
|
|
197
|
+
}, I = "cms_bulk_runs", L = E(I, {
|
|
198
|
+
id: w({ prefix: "cbrn" }),
|
|
199
|
+
site: D().maxLength(64),
|
|
200
|
+
environment: D().maxLength(64),
|
|
201
|
+
action: T(),
|
|
202
|
+
plan: T(),
|
|
203
|
+
results: T(),
|
|
204
|
+
status: D().oneOf(["running", "done"]),
|
|
205
|
+
startedBy: D().maxLength(64).nullable(),
|
|
206
|
+
finishedAt: O().nullable()
|
|
207
|
+
}).with(k()), R = (e) => ({
|
|
208
|
+
id: String(e.id),
|
|
209
|
+
action: e.action,
|
|
210
|
+
status: e.status === "done" ? "done" : "running",
|
|
211
|
+
total: (e.plan ?? []).length,
|
|
212
|
+
results: e.results ?? []
|
|
213
|
+
}), z = async (e, t, n, r, i) => {
|
|
214
|
+
let a = await e.insert(I, {
|
|
215
|
+
site: t.site,
|
|
216
|
+
environment: t.environment,
|
|
217
|
+
action: n,
|
|
218
|
+
plan: [...r],
|
|
219
|
+
results: [],
|
|
220
|
+
status: r.length === 0 ? "done" : "running",
|
|
221
|
+
startedBy: i,
|
|
222
|
+
finishedAt: r.length === 0 ? /* @__PURE__ */ new Date() : null
|
|
223
|
+
});
|
|
224
|
+
return String(a.id);
|
|
225
|
+
}, B = async (e, t, n, r = 25, i = /* @__PURE__ */ new Date()) => {
|
|
226
|
+
let [a] = await e.query({
|
|
227
|
+
table: I,
|
|
228
|
+
predicate: C("id", n),
|
|
229
|
+
order: [],
|
|
230
|
+
take: 1,
|
|
231
|
+
skip: void 0,
|
|
232
|
+
projection: void 0
|
|
233
|
+
});
|
|
234
|
+
if (a === void 0) return null;
|
|
235
|
+
let o = a.plan ?? [], s = a.action, c = {
|
|
236
|
+
site: String(a.site),
|
|
237
|
+
environment: String(a.environment)
|
|
238
|
+
}, l = [...a.results ?? []], u = a;
|
|
239
|
+
for (let a of o.slice(l.length, l.length + Math.max(1, r))) {
|
|
240
|
+
let [r] = await F(e, t, c, s, [a]);
|
|
241
|
+
l = [...l, r];
|
|
242
|
+
let d = l.length >= o.length;
|
|
243
|
+
u = await e.update("cms_bulk_runs", n, {
|
|
244
|
+
results: l,
|
|
245
|
+
...d ? {
|
|
246
|
+
status: "done",
|
|
247
|
+
finishedAt: i
|
|
248
|
+
} : {}
|
|
249
|
+
}) ?? u;
|
|
250
|
+
}
|
|
251
|
+
return R(u);
|
|
252
|
+
}, V = async (e, t) => {
|
|
253
|
+
let [n] = await e.query({
|
|
254
|
+
table: I,
|
|
255
|
+
predicate: C("id", t),
|
|
256
|
+
order: [],
|
|
257
|
+
take: 1,
|
|
258
|
+
skip: void 0,
|
|
259
|
+
projection: void 0
|
|
260
|
+
});
|
|
261
|
+
return n === void 0 ? null : R(n);
|
|
262
|
+
}, H = async (e) => (await e.query({
|
|
263
|
+
table: I,
|
|
264
|
+
predicate: C("status", "running"),
|
|
265
|
+
order: [{
|
|
266
|
+
column: "createdAt",
|
|
267
|
+
direction: "asc"
|
|
268
|
+
}],
|
|
269
|
+
take: 20,
|
|
270
|
+
skip: void 0,
|
|
271
|
+
projection: ["id"]
|
|
272
|
+
})).map((e) => String(e.id)), U = [
|
|
273
|
+
t,
|
|
274
|
+
n,
|
|
275
|
+
r,
|
|
276
|
+
i,
|
|
277
|
+
a,
|
|
278
|
+
o
|
|
279
|
+
], W = (...t) => e(() => P(...t), ...U), G = (...t) => e(() => F(...t), ...U), K = (...t) => e(() => z(...t)), q = (...t) => e(() => B(...t)), J = (...t) => e(() => V(...t)), Y = (...t) => e(() => H(...t));
|
|
280
|
+
//#endregion
|
|
281
|
+
export { I as CMS_BULK_RUNS_TABLE, V as bulkRunState, J as bulkRunStateEffect, L as cmsBulkRunsTable, B as continueBulkRun, q as continueBulkRunEffect, P as planBulk, W as planBulkEffect, F as runBulk, G as runBulkEffect, z as startBulkRun, K as startBulkRunEffect, H as unfinishedBulkRuns, Y as unfinishedBulkRunsEffect };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
//#region src/cacheIdentity.ts
|
|
2
|
+
var e = /^(utm_[a-z]+|fbclid|gclid|dclid|msclkid|mc_[a-z]+|_ga|_gl|ref)$/i, t = (e) => {
|
|
3
|
+
let t = 2166136261;
|
|
4
|
+
for (let n of e) t ^= n.codePointAt(0) ?? 0, t = Math.imul(t, 16777619) >>> 0;
|
|
5
|
+
return t.toString(36);
|
|
6
|
+
}, n = (e) => new Map((e ?? "").split(";").map((e) => e.trim()).filter((e) => e.includes("=")).map((e) => [e.slice(0, e.indexOf("=")).trim(), e.slice(e.indexOf("=") + 1).trim()])), r = (e, t) => t.startsWith("cookie:") ? n(e.headers.cookie).get(t.slice(7)) : e.headers[t.toLowerCase()], i = (e) => {
|
|
7
|
+
if (!e.startsWith("/") || /%2f|%5c|%25|%00/i.test(e) || e.includes("\\")) return null;
|
|
8
|
+
let t;
|
|
9
|
+
try {
|
|
10
|
+
t = decodeURIComponent(e);
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
let n = t.split("/").slice(1);
|
|
15
|
+
return n.some((e, t) => e === "." || e === ".." || e === "" && t < n.length - 1) ? null : `/${n.map((e) => encodeURIComponent(e)).join("/")}`;
|
|
16
|
+
}, a = (e, t) => {
|
|
17
|
+
if (t === void 0 || t === "") return e.fallback;
|
|
18
|
+
if (e.values.includes(t)) return t;
|
|
19
|
+
let n = t.split(",").map((e) => e.split(";")[0].trim()).filter((e) => e !== "");
|
|
20
|
+
for (let t of n) {
|
|
21
|
+
let n = e.values.find((e) => e.toLowerCase() === t.toLowerCase());
|
|
22
|
+
if (n !== void 0) return n;
|
|
23
|
+
let r = e.values.find((e) => e.toLowerCase().split("-")[0] === t.toLowerCase().split("-")[0]);
|
|
24
|
+
if (r !== void 0) return r;
|
|
25
|
+
}
|
|
26
|
+
return e.fallback;
|
|
27
|
+
}, o = (e, t) => {
|
|
28
|
+
switch (e.type) {
|
|
29
|
+
case "string": return t.length <= (e.maxLength ?? 200) ? t : null;
|
|
30
|
+
case "int": {
|
|
31
|
+
if (!/^-?\d{1,9}$/.test(t)) return null;
|
|
32
|
+
let n = Number(t);
|
|
33
|
+
return e.min !== void 0 && n < e.min || e.max !== void 0 && n > e.max ? null : String(n);
|
|
34
|
+
}
|
|
35
|
+
case "enum": return e.values.includes(t) ? t : null;
|
|
36
|
+
}
|
|
37
|
+
}, s = (e) => [
|
|
38
|
+
e.locale,
|
|
39
|
+
e.audience,
|
|
40
|
+
e.consent
|
|
41
|
+
].reduce((e, t) => e * (t?.values.length ?? 1), 1) * (e.query ?? []).reduce((e, t) => e * (t.type === "enum" ? t.values.length + 1 : t.type === "int" && t.min !== void 0 && t.max !== void 0 ? t.max - t.min + 2 : 1), 1), c = (n, c, l) => {
|
|
42
|
+
let u = [], d = (e, t) => ({
|
|
43
|
+
cacheable: !1,
|
|
44
|
+
reason: e,
|
|
45
|
+
detail: t,
|
|
46
|
+
cacheControl: "private, no-store",
|
|
47
|
+
explain: u
|
|
48
|
+
}), f = c.method.toUpperCase();
|
|
49
|
+
if (f !== "GET" && f !== "HEAD") return d("method", `${f} is never shared-cached`);
|
|
50
|
+
if (c.headers.authorization !== void 0) return d("credential", "the request carries authorization");
|
|
51
|
+
for (let e of n.credentials ?? []) if (r(c, e) !== void 0) return d("credential", `the request carries ${e}`);
|
|
52
|
+
let p = i(c.path);
|
|
53
|
+
if (p === null) return d("path", `the path ${c.path.slice(0, 120)} has no single canonical form`);
|
|
54
|
+
let m = s(n), h = n.cardinalityBudget ?? 64;
|
|
55
|
+
if (m > h) return d("budget", `${m} variants exceed the budget of ${h}`);
|
|
56
|
+
let g = c.host.toLowerCase().replace(/:(80|443)$/, "");
|
|
57
|
+
u.push({
|
|
58
|
+
dimension: "host",
|
|
59
|
+
included: !0,
|
|
60
|
+
value: g,
|
|
61
|
+
why: "the site and domain binding"
|
|
62
|
+
}), u.push({
|
|
63
|
+
dimension: "path",
|
|
64
|
+
included: !0,
|
|
65
|
+
value: p,
|
|
66
|
+
why: "canonical encoding"
|
|
67
|
+
});
|
|
68
|
+
let _ = new Map((n.query ?? []).map((e) => [e.name, e])), v = [];
|
|
69
|
+
for (let [t, n] of new URLSearchParams(c.query)) {
|
|
70
|
+
let r = _.get(t);
|
|
71
|
+
if (r === void 0) {
|
|
72
|
+
u.push({
|
|
73
|
+
dimension: `query:${t}`,
|
|
74
|
+
included: !1,
|
|
75
|
+
value: n,
|
|
76
|
+
why: e.test(t) ? "tracking parameter" : "not declared by the route"
|
|
77
|
+
});
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
let i = o(r, n);
|
|
81
|
+
i === null || i === "" || i === String(r.default ?? "") ? u.push({
|
|
82
|
+
dimension: `query:${t}`,
|
|
83
|
+
included: !1,
|
|
84
|
+
value: n,
|
|
85
|
+
why: i === null ? "not a valid value" : "empty or the default"
|
|
86
|
+
}) : v.some(([e]) => e === t) || (v.push([t, i]), u.push({
|
|
87
|
+
dimension: `query:${t}`,
|
|
88
|
+
included: !0,
|
|
89
|
+
value: i,
|
|
90
|
+
why: `declared ${r.type}`
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
v.sort(([e], [t]) => e.localeCompare(t));
|
|
94
|
+
let y = [], b = (e, t) => {
|
|
95
|
+
if (t === void 0) return null;
|
|
96
|
+
let n = r(c, t.from), i = a(t, n);
|
|
97
|
+
return u.push({
|
|
98
|
+
dimension: e,
|
|
99
|
+
included: !0,
|
|
100
|
+
value: i,
|
|
101
|
+
why: n === void 0 ? `not given: ${t.fallback}` : `from ${t.from}, one of ${t.values.length}`
|
|
102
|
+
}), t.from.startsWith("cookie:") ? y.includes("cookie") || y.push("cookie") : y.push(t.from), i;
|
|
103
|
+
}, x = b("locale", n.locale), S = b("audience", n.audience), C = b("consent", n.consent);
|
|
104
|
+
u.push({
|
|
105
|
+
dimension: "checkpoint",
|
|
106
|
+
included: !0,
|
|
107
|
+
value: l.checkpoint,
|
|
108
|
+
why: "the publication this answer belongs to"
|
|
109
|
+
});
|
|
110
|
+
let w = [
|
|
111
|
+
"v1",
|
|
112
|
+
g,
|
|
113
|
+
p,
|
|
114
|
+
v.map(([e, t]) => `${e}=${t}`).join("&"),
|
|
115
|
+
`locale=${x ?? ""}`,
|
|
116
|
+
`audience=${S ?? ""}`,
|
|
117
|
+
`consent=${C ?? ""}`,
|
|
118
|
+
`checkpoint=${l.checkpoint}`
|
|
119
|
+
].join("|");
|
|
120
|
+
return {
|
|
121
|
+
cacheable: !0,
|
|
122
|
+
key: w,
|
|
123
|
+
fingerprint: t(w),
|
|
124
|
+
vary: y,
|
|
125
|
+
purge: {
|
|
126
|
+
route: n.route,
|
|
127
|
+
tags: [...new Set(l.tags ?? [])].sort()
|
|
128
|
+
},
|
|
129
|
+
variants: m,
|
|
130
|
+
explain: u
|
|
131
|
+
};
|
|
132
|
+
}, l = (e) => {
|
|
133
|
+
let t = (e["cache-control"] ?? "").toLowerCase();
|
|
134
|
+
return e["set-cookie"] === void 0 && !/\b(private|no-store)\b/.test(t);
|
|
135
|
+
}, u = (e, t, n) => {
|
|
136
|
+
if (!t.cacheable) return { "cache-control": t.cacheControl };
|
|
137
|
+
let r = n.staleWhileRevalidate === void 0 ? "" : `, stale-while-revalidate=${n.staleWhileRevalidate}`, i = `public, max-age=0, s-maxage=${n.maxAge}${r}`, a = t.vary.length === 0 ? {} : { vary: t.vary.join(", ") }, o = { "x-cache-identity": t.fingerprint };
|
|
138
|
+
return e === "fastly" ? {
|
|
139
|
+
"cache-control": "public, max-age=0",
|
|
140
|
+
"surrogate-control": `max-age=${n.maxAge}${r}`,
|
|
141
|
+
"surrogate-key": t.purge.tags.join(" "),
|
|
142
|
+
...a,
|
|
143
|
+
...o
|
|
144
|
+
} : {
|
|
145
|
+
"cache-control": i,
|
|
146
|
+
"cache-tag": t.purge.tags.join(","),
|
|
147
|
+
...a,
|
|
148
|
+
...o
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
//#endregion
|
|
152
|
+
export { c as compileCacheIdentity, s as contractVariants, u as edgeHeaders, l as sharedCacheable };
|
package/dist/changes.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { asTyped as e } from "./effectForm.js";
|
|
2
|
+
import { and as t, eq as n, gt as r, id as i, integer as a, lt as o, table as s, text as c, timestamp as l } from "@voltro/database";
|
|
3
|
+
import { tenant as u } from "@voltro/plugin-multitenancy/mixin";
|
|
4
|
+
//#region src/changes.ts
|
|
5
|
+
var d = "cms_changes", f = s(d, {
|
|
6
|
+
id: i({ prefix: "cchg" }),
|
|
7
|
+
site: c().maxLength(64),
|
|
8
|
+
environment: c().maxLength(64),
|
|
9
|
+
locale: c().maxLength(64),
|
|
10
|
+
contentType: c().maxLength(64),
|
|
11
|
+
documentId: c().maxLength(64),
|
|
12
|
+
variantId: c().maxLength(64),
|
|
13
|
+
action: c().oneOf(["published", "unpublished"]),
|
|
14
|
+
revision: a().nullable(),
|
|
15
|
+
releaseId: c().nullable(),
|
|
16
|
+
at: l()
|
|
17
|
+
}).with(u()).index("cms_changes_by_place", [
|
|
18
|
+
"site",
|
|
19
|
+
"environment",
|
|
20
|
+
"id"
|
|
21
|
+
]), p = async (e, t, n, r, i, a = {}) => {
|
|
22
|
+
if (t.changeFeed !== !0) return;
|
|
23
|
+
let o = n.tenantId;
|
|
24
|
+
await e.insert(d, {
|
|
25
|
+
site: r.site,
|
|
26
|
+
environment: r.environment,
|
|
27
|
+
locale: r.locale,
|
|
28
|
+
contentType: t.name,
|
|
29
|
+
documentId: String(n.documentId),
|
|
30
|
+
variantId: String(n.id),
|
|
31
|
+
action: i,
|
|
32
|
+
revision: i === "published" && typeof n.revision == "number" ? n.revision : null,
|
|
33
|
+
releaseId: a.releaseId ?? null,
|
|
34
|
+
at: /* @__PURE__ */ new Date(),
|
|
35
|
+
...o == null ? {} : { tenantId: o }
|
|
36
|
+
});
|
|
37
|
+
}, m = (e) => e instanceof Date ? e.getTime() : typeof e == "string" ? Date.parse(e) : Number(e), h = async (e, i, a = {}) => {
|
|
38
|
+
let s = Math.max(1, Math.min(1e3, Math.floor(a.limit ?? 100))), c = new Date((a.now ?? Date.now()) - (a.settleMs ?? 2e3)), l = (await e.query({
|
|
39
|
+
table: d,
|
|
40
|
+
predicate: t(n("site", i.site), n("environment", i.environment), o("at", c), ...a.after === void 0 ? [] : [r("id", a.after)], ...Object.entries(a.filter ?? {}).map(([e, t]) => n(e, t))),
|
|
41
|
+
order: [{
|
|
42
|
+
column: "id",
|
|
43
|
+
direction: "asc"
|
|
44
|
+
}],
|
|
45
|
+
take: s,
|
|
46
|
+
skip: void 0,
|
|
47
|
+
projection: void 0
|
|
48
|
+
})).map((e) => ({
|
|
49
|
+
id: String(e.id),
|
|
50
|
+
at: m(e.at),
|
|
51
|
+
locale: String(e.locale),
|
|
52
|
+
contentType: String(e.contentType),
|
|
53
|
+
documentId: String(e.documentId),
|
|
54
|
+
variantId: String(e.variantId),
|
|
55
|
+
action: e.action === "unpublished" ? "unpublished" : "published",
|
|
56
|
+
revision: typeof e.revision == "number" ? e.revision : null,
|
|
57
|
+
releaseId: typeof e.releaseId == "string" ? e.releaseId : null
|
|
58
|
+
}));
|
|
59
|
+
return {
|
|
60
|
+
items: l,
|
|
61
|
+
next: l.length > 0 ? l[l.length - 1].id : a.after ?? null
|
|
62
|
+
};
|
|
63
|
+
}, g = async (e, r, i) => {
|
|
64
|
+
let a = await e.query({
|
|
65
|
+
table: d,
|
|
66
|
+
predicate: t(n("site", i.site), n("environment", i.environment), n("locale", i.locale), n("contentType", r.contentType), n("documentId", r.documentId)),
|
|
67
|
+
order: [{
|
|
68
|
+
column: "at",
|
|
69
|
+
direction: "asc"
|
|
70
|
+
}, {
|
|
71
|
+
column: "id",
|
|
72
|
+
direction: "asc"
|
|
73
|
+
}],
|
|
74
|
+
take: void 0,
|
|
75
|
+
skip: void 0,
|
|
76
|
+
projection: void 0
|
|
77
|
+
}), o = [];
|
|
78
|
+
for (let e of a) {
|
|
79
|
+
let t = new Date(m(e.at)).toISOString(), n = o[o.length - 1];
|
|
80
|
+
n !== void 0 && n.to === null && (n.to = t), e.action === "published" && typeof e.revision == "number" && o.push({
|
|
81
|
+
revision: e.revision,
|
|
82
|
+
releaseId: typeof e.releaseId == "string" ? e.releaseId : null,
|
|
83
|
+
from: t,
|
|
84
|
+
to: null
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return o;
|
|
88
|
+
}, _ = (...t) => e(() => h(...t)), v = (...t) => e(() => g(...t)), y = (...t) => e(() => p(...t));
|
|
89
|
+
//#endregion
|
|
90
|
+
export { d as CMS_CHANGES_TABLE, f as cmsChangesTable, h as readChanges, _ as readChangesEffect, p as recordChange, y as recordChangeEffect, g as revisionTimeline, v as revisionTimelineEffect };
|