@voltro/cms 0.85.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 +666 -0
- package/THIRD-PARTY-NOTICES.md +5 -33
- 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 +11 -7
- package/dist/index.js +73 -6082
- 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.js +33 -2
- package/dist/workflow.js +322 -0
- package/dist/write.js +394 -0
- package/dist/xliff.js +325 -0
- package/package.json +5 -5
- package/dist/presenceAnchors-4iHAVQB3.js +0 -4367
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import "./richDocument.js";
|
|
2
|
+
//#region src/contentfulImport.ts
|
|
3
|
+
var e = {
|
|
4
|
+
bold: "bold",
|
|
5
|
+
italic: "italic",
|
|
6
|
+
underline: "underline"
|
|
7
|
+
}, t = (t, n = {}) => {
|
|
8
|
+
let r = 0, i = n.newId ?? (() => `rb_import_${++r}`), a = [], o = (e, t) => {
|
|
9
|
+
a.some((n) => n.kind === e && n.detail === t) || a.push({
|
|
10
|
+
kind: e,
|
|
11
|
+
detail: t
|
|
12
|
+
});
|
|
13
|
+
}, s = (t) => {
|
|
14
|
+
let r = [], i = (e) => {
|
|
15
|
+
let t = r[r.length - 1];
|
|
16
|
+
e.type === "text" && t?.type === "text" && (t.marks ?? []).join() === (e.marks ?? []).join() ? r[r.length - 1] = {
|
|
17
|
+
...t,
|
|
18
|
+
text: t.text + e.text
|
|
19
|
+
} : e.text !== "" && r.push(e);
|
|
20
|
+
};
|
|
21
|
+
for (let r of t ?? []) switch (r.nodeType) {
|
|
22
|
+
case "text": {
|
|
23
|
+
let t = (r.marks ?? []).map((t) => e[t.type]).filter((e) => e !== void 0);
|
|
24
|
+
i({
|
|
25
|
+
type: "text",
|
|
26
|
+
text: r.value ?? "",
|
|
27
|
+
...t.length > 0 ? { marks: t } : {}
|
|
28
|
+
});
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
case "entry-hyperlink": {
|
|
32
|
+
let e = r.data?.target?.sys?.id ?? "", t = n.resolveEntry?.(e) ?? null, a = s(r.content).map((e) => e.text).join("");
|
|
33
|
+
t === null ? (o("externalLink", `entry:${e}`), i({
|
|
34
|
+
type: "text",
|
|
35
|
+
text: a
|
|
36
|
+
})) : i({
|
|
37
|
+
type: "link",
|
|
38
|
+
target: t,
|
|
39
|
+
text: a
|
|
40
|
+
});
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case "hyperlink":
|
|
44
|
+
o("externalLink", r.data?.uri ?? "");
|
|
45
|
+
for (let e of s(r.content)) i(e);
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
o("unsupportedTag", r.nodeType);
|
|
49
|
+
for (let e of s(r.content)) i(e);
|
|
50
|
+
}
|
|
51
|
+
let a = r[0];
|
|
52
|
+
a !== void 0 && (r[0] = {
|
|
53
|
+
...a,
|
|
54
|
+
text: a.text.replace(/^[ \t\r\n\f]+/, "")
|
|
55
|
+
});
|
|
56
|
+
let c = r[r.length - 1];
|
|
57
|
+
return c !== void 0 && (r[r.length - 1] = {
|
|
58
|
+
...c,
|
|
59
|
+
text: c.text.replace(/[ \t\r\n\f]+$/, "")
|
|
60
|
+
}), r.filter((e) => e.text !== "");
|
|
61
|
+
}, c = (e) => (e.content ?? []).flatMap((e, t) => {
|
|
62
|
+
let n = e.nodeType === "paragraph" ? s(e.content) : s([e]);
|
|
63
|
+
return t > 0 && n.length > 0 ? [{
|
|
64
|
+
type: "text",
|
|
65
|
+
text: " "
|
|
66
|
+
}, ...n] : n;
|
|
67
|
+
}), l = [];
|
|
68
|
+
for (let e of t?.content ?? []) switch (e.nodeType) {
|
|
69
|
+
case "paragraph": {
|
|
70
|
+
let t = s(e.content);
|
|
71
|
+
t.length > 0 && l.push({
|
|
72
|
+
id: i(),
|
|
73
|
+
type: "paragraph",
|
|
74
|
+
content: t
|
|
75
|
+
});
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
case "heading-1":
|
|
79
|
+
case "heading-2":
|
|
80
|
+
case "heading-3":
|
|
81
|
+
case "heading-4":
|
|
82
|
+
case "heading-5":
|
|
83
|
+
case "heading-6": {
|
|
84
|
+
let t = s(e.content);
|
|
85
|
+
t.length > 0 && l.push({
|
|
86
|
+
id: i(),
|
|
87
|
+
type: "heading",
|
|
88
|
+
level: e.nodeType === "heading-1" || e.nodeType === "heading-2" ? 2 : 3,
|
|
89
|
+
content: t
|
|
90
|
+
});
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case "unordered-list":
|
|
94
|
+
case "ordered-list": {
|
|
95
|
+
let t = [], n = [], r = [], a = (e) => e.nodeType === "ordered-list" ? "ordered" : "unordered", o = (i, s) => {
|
|
96
|
+
for (let l of i.content ?? []) {
|
|
97
|
+
let i = (l.content ?? []).filter((e) => e.nodeType === "unordered-list" || e.nodeType === "ordered-list"), u = c({
|
|
98
|
+
...l,
|
|
99
|
+
content: (l.content ?? []).filter((e) => !i.includes(e))
|
|
100
|
+
});
|
|
101
|
+
u.length > 0 && (t.push(u), n.push(Math.min(s, 3, n.length === 0 ? 0 : n[n.length - 1] + 1)));
|
|
102
|
+
for (let t of i) {
|
|
103
|
+
let n = Math.min(s + 1, 3) - 1;
|
|
104
|
+
for (; r.length < n;) r.push(r[r.length - 1] ?? a(e));
|
|
105
|
+
r.length === n && r.push(a(t)), o(t, s + 1);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
o(e, 0);
|
|
110
|
+
let s = a(e);
|
|
111
|
+
t.length > 0 && l.push({
|
|
112
|
+
id: i(),
|
|
113
|
+
type: "list",
|
|
114
|
+
ordered: s === "ordered",
|
|
115
|
+
items: t,
|
|
116
|
+
...n.some((e) => e > 0) ? {
|
|
117
|
+
levels: n,
|
|
118
|
+
...r.some((e) => e !== s) ? { sublists: r } : {}
|
|
119
|
+
} : {}
|
|
120
|
+
});
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
case "table": {
|
|
124
|
+
let t = (e.content ?? []).map((e) => (e.content ?? []).map(c)), n = (e.content?.[0]?.content ?? []).some((e) => e.nodeType === "table-header-cell");
|
|
125
|
+
t.length > 0 && l.push({
|
|
126
|
+
id: i(),
|
|
127
|
+
type: "table",
|
|
128
|
+
header: n,
|
|
129
|
+
rows: t
|
|
130
|
+
});
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
case "embedded-asset-block": {
|
|
134
|
+
let t = e.data?.target?.sys?.id ?? "", r = n.resolveAsset?.(t) ?? null;
|
|
135
|
+
r === null ? o("image", `asset:${t}`) : l.push({
|
|
136
|
+
id: i(),
|
|
137
|
+
type: "image",
|
|
138
|
+
asset: r
|
|
139
|
+
});
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
case "hr": break;
|
|
143
|
+
default: {
|
|
144
|
+
o("unsupportedTag", e.nodeType);
|
|
145
|
+
let t = s((e.content ?? []).flatMap((e) => e.nodeType === "paragraph" ? e.content ?? [] : [e]));
|
|
146
|
+
t.length > 0 && l.push({
|
|
147
|
+
id: i(),
|
|
148
|
+
type: "paragraph",
|
|
149
|
+
content: t
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
document: {
|
|
155
|
+
type: "doc",
|
|
156
|
+
blocks: l
|
|
157
|
+
},
|
|
158
|
+
findings: a
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
//#endregion
|
|
162
|
+
export { t as richDocumentFromContentful };
|
package/dist/copies.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { asTyped as e } from "./effectForm.js";
|
|
2
|
+
import { ContentIdConflict as t, ContentNotFound as n, ContentValidationFailed as r, RevisionMismatch as i } from "./errors.js";
|
|
3
|
+
import { saveDraft as a } from "./write.js";
|
|
4
|
+
import { and as o, eq as s, id as c, table as l, text as u, timestamp as d } from "@voltro/database";
|
|
5
|
+
import { tenant as f } from "@voltro/plugin-multitenancy/mixin";
|
|
6
|
+
//#region src/copies.ts
|
|
7
|
+
var p = "cms_copies", m = l(p, {
|
|
8
|
+
id: c({ prefix: "ccpy" }),
|
|
9
|
+
contentType: u().maxLength(64),
|
|
10
|
+
documentId: u().maxLength(64),
|
|
11
|
+
sourceDocumentId: u().maxLength(64),
|
|
12
|
+
sourceRevisionId: u().maxLength(64).nullable(),
|
|
13
|
+
copiedBy: u().maxLength(64).nullable(),
|
|
14
|
+
copiedAt: d()
|
|
15
|
+
}).with(f()).index("cms_copies_by_document", ["documentId"]).index("cms_copies_by_source", ["sourceDocumentId"]), h = [
|
|
16
|
+
"id",
|
|
17
|
+
"documentId",
|
|
18
|
+
"revisionId",
|
|
19
|
+
"status",
|
|
20
|
+
"tenantId",
|
|
21
|
+
"publishAt",
|
|
22
|
+
"createdAt",
|
|
23
|
+
"updatedAt",
|
|
24
|
+
"createdBy",
|
|
25
|
+
"updatedBy"
|
|
26
|
+
], g = (e) => e instanceof Date ? e : new Date(String(e)), _ = (e) => typeof e == "string" && e !== "" ? e : null, v = async (e, t, n, r, i = {}, c = /* @__PURE__ */ new Date()) => {
|
|
27
|
+
let [l] = await e.query({
|
|
28
|
+
table: `${t.name}_drafts`,
|
|
29
|
+
predicate: o(s("documentId", n), s("site", r.site), s("environment", r.environment), s("locale", r.locale)),
|
|
30
|
+
order: [],
|
|
31
|
+
take: 1,
|
|
32
|
+
skip: void 0,
|
|
33
|
+
projection: void 0
|
|
34
|
+
});
|
|
35
|
+
if (l === void 0) return {
|
|
36
|
+
ok: !1,
|
|
37
|
+
reason: "notFound"
|
|
38
|
+
};
|
|
39
|
+
let u = Object.fromEntries(Object.entries(l).filter(([e]) => !h.includes(e)));
|
|
40
|
+
if ("title" in t.fields) {
|
|
41
|
+
let t = (await x(e, n)).length, r = String(l.title ?? "");
|
|
42
|
+
u.title = (i.title?.trim() || `${r} (copy${t > 0 ? ` ${t + 1}` : ""})`).slice(0, 200);
|
|
43
|
+
}
|
|
44
|
+
let d = await a(e, t, u, r), f = String(d.documentId);
|
|
45
|
+
return await e.insert(p, {
|
|
46
|
+
contentType: t.name,
|
|
47
|
+
documentId: f,
|
|
48
|
+
sourceDocumentId: n,
|
|
49
|
+
sourceRevisionId: _(l.revisionId),
|
|
50
|
+
copiedBy: i.actorId ?? null,
|
|
51
|
+
copiedAt: c,
|
|
52
|
+
...d.tenantId !== void 0 && d.tenantId !== null ? { tenantId: d.tenantId } : {}
|
|
53
|
+
}), {
|
|
54
|
+
ok: !0,
|
|
55
|
+
id: String(d.id),
|
|
56
|
+
documentId: f,
|
|
57
|
+
revisionId: String(d.revisionId)
|
|
58
|
+
};
|
|
59
|
+
}, y = async (e, t) => {
|
|
60
|
+
let [n] = await e.query({
|
|
61
|
+
table: p,
|
|
62
|
+
predicate: s("documentId", t),
|
|
63
|
+
order: [],
|
|
64
|
+
take: 1,
|
|
65
|
+
skip: void 0,
|
|
66
|
+
projection: void 0
|
|
67
|
+
});
|
|
68
|
+
return n === void 0 ? null : b(n);
|
|
69
|
+
}, b = (e) => ({
|
|
70
|
+
sourceDocumentId: String(e.sourceDocumentId),
|
|
71
|
+
sourceRevisionId: _(e.sourceRevisionId),
|
|
72
|
+
copiedBy: _(e.copiedBy),
|
|
73
|
+
copiedAt: g(e.copiedAt)
|
|
74
|
+
}), x = async (e, t) => (await e.query({
|
|
75
|
+
table: p,
|
|
76
|
+
predicate: s("sourceDocumentId", t),
|
|
77
|
+
order: [{
|
|
78
|
+
column: "copiedAt",
|
|
79
|
+
direction: "asc"
|
|
80
|
+
}],
|
|
81
|
+
take: void 0,
|
|
82
|
+
skip: void 0,
|
|
83
|
+
projection: void 0
|
|
84
|
+
})).map((e) => ({
|
|
85
|
+
...b(e),
|
|
86
|
+
documentId: String(e.documentId)
|
|
87
|
+
})), S = (...a) => e(() => v(...a), r, n, t, i), C = (...t) => e(() => y(...t)), w = (...t) => e(() => x(...t));
|
|
88
|
+
//#endregion
|
|
89
|
+
export { p as CMS_COPIES_TABLE, m as cmsCopiesTable, x as copiesOf, w as copiesOfEffect, v as copyDocument, S as copyDocumentEffect, y as copyOrigin, C as copyOriginEffect };
|
package/dist/cutover.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { asTyped as e } from "./effectForm.js";
|
|
2
|
+
import { CMS_REVISIONS_TABLE as t } from "./contentType.js";
|
|
3
|
+
import { and as n, eq as r, gt as i, id as a, inSet as o, json as s, table as c, text as l, timestamp as u } from "@voltro/database";
|
|
4
|
+
import { tenant as d } from "@voltro/plugin-multitenancy/mixin";
|
|
5
|
+
//#region src/cutover.ts
|
|
6
|
+
var f = "cms_cutover_issues", p = "cms_cutover_decisions", m = c(f, {
|
|
7
|
+
id: a({ prefix: "ccis" }),
|
|
8
|
+
source: l().maxLength(200),
|
|
9
|
+
key: l().maxLength(200),
|
|
10
|
+
kind: l().maxLength(64),
|
|
11
|
+
detail: l(),
|
|
12
|
+
resolution: l().nullable(),
|
|
13
|
+
resolvedBy: l().nullable(),
|
|
14
|
+
resolvedAt: u().nullable()
|
|
15
|
+
}).with(d()).unique("cms_cutover_issues_once", [
|
|
16
|
+
"tenantId",
|
|
17
|
+
"source",
|
|
18
|
+
"key"
|
|
19
|
+
]), h = c(p, {
|
|
20
|
+
id: a({ prefix: "ccdc" }),
|
|
21
|
+
source: l().maxLength(200),
|
|
22
|
+
decision: l().oneOf(["go", "fallback"]),
|
|
23
|
+
criteria: s(),
|
|
24
|
+
note: l(),
|
|
25
|
+
plan: s().nullable(),
|
|
26
|
+
decidedBy: l(),
|
|
27
|
+
decidedAt: u()
|
|
28
|
+
}).with(d()).index("cms_cutover_decisions_by_source", ["source"]), g = 30, _ = (e, t) => e.routing.trim() === "" ? "routing" : !Number.isInteger(e.redirects) || e.redirects < 0 ? "redirects" : e.rollbackUntil.getTime() <= e.freezeAt.getTime() ? "rollbackBeforeFreeze" : e.rollbackUntil.getTime() - t.getTime() > 2592e6 ? "rollbackTooLong" : null, v = (e, t) => {
|
|
29
|
+
let n = e.map((e) => {
|
|
30
|
+
let n = t[e.measure] ?? null, r = n !== null && (e.op === "atMost" ? n <= e.value : n >= e.value);
|
|
31
|
+
return {
|
|
32
|
+
...e,
|
|
33
|
+
measured: n,
|
|
34
|
+
pass: r
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
results: n,
|
|
39
|
+
ready: n.length > 0 && n.every((e) => e.pass)
|
|
40
|
+
};
|
|
41
|
+
}, y = (e) => ({
|
|
42
|
+
id: String(e.id),
|
|
43
|
+
key: String(e.key),
|
|
44
|
+
kind: String(e.kind),
|
|
45
|
+
detail: String(e.detail),
|
|
46
|
+
resolution: typeof e.resolution == "string" ? e.resolution : null,
|
|
47
|
+
resolvedBy: typeof e.resolvedBy == "string" ? e.resolvedBy : null
|
|
48
|
+
}), b = async (e, t, n, r) => {
|
|
49
|
+
let i = 0;
|
|
50
|
+
for (let a of n) (await e.insertIgnoreWithOutcome("cms_cutover_issues", {
|
|
51
|
+
source: t,
|
|
52
|
+
key: a.key,
|
|
53
|
+
kind: a.kind,
|
|
54
|
+
detail: a.detail,
|
|
55
|
+
resolution: null,
|
|
56
|
+
resolvedBy: null,
|
|
57
|
+
resolvedAt: null,
|
|
58
|
+
...r === null ? {} : { tenantId: r }
|
|
59
|
+
}, { conflictColumns: [
|
|
60
|
+
"tenantId",
|
|
61
|
+
"source",
|
|
62
|
+
"key"
|
|
63
|
+
] })).outcome === "inserted" && i++;
|
|
64
|
+
return i;
|
|
65
|
+
}, x = async (e, t) => (await e.query({
|
|
66
|
+
table: f,
|
|
67
|
+
predicate: r("source", t),
|
|
68
|
+
order: [{
|
|
69
|
+
column: "createdAt",
|
|
70
|
+
direction: "asc"
|
|
71
|
+
}],
|
|
72
|
+
take: void 0,
|
|
73
|
+
skip: void 0,
|
|
74
|
+
projection: void 0
|
|
75
|
+
})).map(y).sort((e, t) => Number(e.resolution !== null) - Number(t.resolution !== null)), S = async (e, t, n, i = /* @__PURE__ */ new Date()) => {
|
|
76
|
+
let a = n.resolution.trim();
|
|
77
|
+
if (a === "" || a.length > 500) return {
|
|
78
|
+
ok: !1,
|
|
79
|
+
reason: "noReason"
|
|
80
|
+
};
|
|
81
|
+
let [o] = await e.query({
|
|
82
|
+
table: f,
|
|
83
|
+
predicate: r("id", t),
|
|
84
|
+
order: [],
|
|
85
|
+
take: 1,
|
|
86
|
+
skip: void 0,
|
|
87
|
+
projection: void 0
|
|
88
|
+
});
|
|
89
|
+
return o === void 0 ? {
|
|
90
|
+
ok: !1,
|
|
91
|
+
reason: "notFound"
|
|
92
|
+
} : typeof o.resolution == "string" ? {
|
|
93
|
+
ok: !1,
|
|
94
|
+
reason: "alreadyResolved"
|
|
95
|
+
} : (await e.update(f, t, {
|
|
96
|
+
resolution: a,
|
|
97
|
+
resolvedBy: n.actorId,
|
|
98
|
+
resolvedAt: i
|
|
99
|
+
}), { ok: !0 });
|
|
100
|
+
}, C = async (e, r, a) => {
|
|
101
|
+
if (r.length === 0) return [];
|
|
102
|
+
let s = await e.query({
|
|
103
|
+
table: t,
|
|
104
|
+
predicate: n(o("documentId", [...r]), a === void 0 ? i("number", 1) : i("createdAt", a)),
|
|
105
|
+
order: [],
|
|
106
|
+
take: void 0,
|
|
107
|
+
skip: void 0,
|
|
108
|
+
projection: [
|
|
109
|
+
"documentId",
|
|
110
|
+
"createdBy",
|
|
111
|
+
"createdAt"
|
|
112
|
+
]
|
|
113
|
+
}), c = /* @__PURE__ */ new Map();
|
|
114
|
+
for (let e of s) {
|
|
115
|
+
let t = typeof e.createdBy == "string" ? e.createdBy : null;
|
|
116
|
+
if (t === null) continue;
|
|
117
|
+
let n = c.get(t) ?? {
|
|
118
|
+
revisions: 0,
|
|
119
|
+
documents: /* @__PURE__ */ new Set(),
|
|
120
|
+
lastAt: null
|
|
121
|
+
};
|
|
122
|
+
n.revisions++, n.documents.add(String(e.documentId));
|
|
123
|
+
let r = e.createdAt instanceof Date ? e.createdAt : new Date(String(e.createdAt));
|
|
124
|
+
(n.lastAt === null || r > n.lastAt) && (n.lastAt = r), c.set(t, n);
|
|
125
|
+
}
|
|
126
|
+
return [...c].map(([e, t]) => ({
|
|
127
|
+
actorId: e,
|
|
128
|
+
revisions: t.revisions,
|
|
129
|
+
documents: t.documents.size,
|
|
130
|
+
lastAt: t.lastAt
|
|
131
|
+
})).sort((e, t) => t.revisions - e.revisions);
|
|
132
|
+
}, w = async (e, t, n = /* @__PURE__ */ new Date()) => {
|
|
133
|
+
let r = t.note.trim();
|
|
134
|
+
if (r === "" || r.length > 1e3) return {
|
|
135
|
+
ok: !1,
|
|
136
|
+
reason: "noNote"
|
|
137
|
+
};
|
|
138
|
+
let i = t.results.filter((e) => !e.pass).map((e) => e.id);
|
|
139
|
+
if (t.decision === "go" && (t.results.length === 0 || i.length > 0)) return {
|
|
140
|
+
ok: !1,
|
|
141
|
+
reason: "notReady",
|
|
142
|
+
failing: i
|
|
143
|
+
};
|
|
144
|
+
let a = t.decision === "go" ? t.plan : void 0;
|
|
145
|
+
if (t.decision === "go") {
|
|
146
|
+
if (a === void 0) return {
|
|
147
|
+
ok: !1,
|
|
148
|
+
reason: "noPlan"
|
|
149
|
+
};
|
|
150
|
+
let e = _(a, n);
|
|
151
|
+
if (e !== null) return {
|
|
152
|
+
ok: !1,
|
|
153
|
+
reason: "noPlan",
|
|
154
|
+
problem: e
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
let o = await e.insert(p, {
|
|
158
|
+
source: t.source,
|
|
159
|
+
decision: t.decision,
|
|
160
|
+
criteria: [...t.results],
|
|
161
|
+
note: r,
|
|
162
|
+
plan: a === void 0 ? null : {
|
|
163
|
+
...a,
|
|
164
|
+
freezeAt: a.freezeAt.toISOString(),
|
|
165
|
+
rollbackUntil: a.rollbackUntil.toISOString()
|
|
166
|
+
},
|
|
167
|
+
decidedBy: t.actorId,
|
|
168
|
+
decidedAt: n,
|
|
169
|
+
...t.tenantId === null ? {} : { tenantId: t.tenantId }
|
|
170
|
+
});
|
|
171
|
+
return {
|
|
172
|
+
ok: !0,
|
|
173
|
+
id: String(o.id)
|
|
174
|
+
};
|
|
175
|
+
}, T = async (e, t) => (await e.query({
|
|
176
|
+
table: p,
|
|
177
|
+
predicate: r("source", t),
|
|
178
|
+
order: [{
|
|
179
|
+
column: "decidedAt",
|
|
180
|
+
direction: "desc"
|
|
181
|
+
}],
|
|
182
|
+
take: 50,
|
|
183
|
+
skip: void 0,
|
|
184
|
+
projection: void 0
|
|
185
|
+
})).map((e) => ({
|
|
186
|
+
id: String(e.id),
|
|
187
|
+
decision: e.decision === "go" ? "go" : "fallback",
|
|
188
|
+
criteria: e.criteria ?? [],
|
|
189
|
+
note: String(e.note),
|
|
190
|
+
plan: e.plan === null || e.plan === void 0 ? null : (() => {
|
|
191
|
+
let t = e.plan;
|
|
192
|
+
return {
|
|
193
|
+
...t,
|
|
194
|
+
freezeAt: new Date(t.freezeAt),
|
|
195
|
+
rollbackUntil: new Date(t.rollbackUntil)
|
|
196
|
+
};
|
|
197
|
+
})(),
|
|
198
|
+
decidedBy: String(e.decidedBy),
|
|
199
|
+
decidedAt: e.decidedAt instanceof Date ? e.decidedAt : new Date(String(e.decidedAt))
|
|
200
|
+
})), E = (...t) => e(() => b(...t)), D = (...t) => e(() => x(...t)), O = (...t) => e(() => S(...t)), k = (...t) => e(() => C(...t)), A = (...t) => e(() => w(...t)), j = (...t) => e(() => T(...t));
|
|
201
|
+
//#endregion
|
|
202
|
+
export { p as CMS_CUTOVER_DECISIONS_TABLE, f as CMS_CUTOVER_ISSUES_TABLE, g as MAX_ROLLBACK_DAYS, h as cmsCutoverDecisionsTable, m as cmsCutoverIssuesTable, C as cutoverAdoption, k as cutoverAdoptionEffect, T as cutoverDecisions, j as cutoverDecisionsEffect, x as cutoverIssues, D as cutoverIssuesEffect, _ as cutoverPlanProblem, w as decideCutover, A as decideCutoverEffect, v as evaluateCutover, b as recordCutoverIssues, E as recordCutoverIssuesEffect, S as resolveCutoverIssue, O as resolveCutoverIssueEffect };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { asTyped as e } from "./effectForm.js";
|
|
2
|
+
import { CMS_RELEASES_TABLE as t, CMS_RELEASE_ITEMS_TABLE as n } from "./release.js";
|
|
3
|
+
import { and as r, eq as i, id as a, integer as o, table as s, text as c, timestamp as l } from "@voltro/database";
|
|
4
|
+
import { tenant as u } from "@voltro/plugin-multitenancy/mixin";
|
|
5
|
+
//#region src/deliveryChecks.ts
|
|
6
|
+
var d = "cms_delivery_checks", f = s(d, {
|
|
7
|
+
id: a({ prefix: "cdlv" }),
|
|
8
|
+
contentType: c().maxLength(64),
|
|
9
|
+
documentId: c().maxLength(64),
|
|
10
|
+
locale: c().maxLength(64),
|
|
11
|
+
kind: c().oneOf(["publish", "unpublish"]),
|
|
12
|
+
revisionId: c().maxLength(64).nullable(),
|
|
13
|
+
url: c().maxLength(1e3),
|
|
14
|
+
status: c().oneOf([
|
|
15
|
+
"pending",
|
|
16
|
+
"observed",
|
|
17
|
+
"stale"
|
|
18
|
+
]),
|
|
19
|
+
requestedAt: l(),
|
|
20
|
+
observedAt: l().nullable(),
|
|
21
|
+
lastSeen: c().maxLength(200).nullable(),
|
|
22
|
+
attempts: o().default(0)
|
|
23
|
+
}).with(u()).index("cms_delivery_checks_by_status", ["status"]), p = (e) => e instanceof Date ? e : new Date(String(e)), m = (e) => ({
|
|
24
|
+
id: String(e.id),
|
|
25
|
+
contentType: String(e.contentType),
|
|
26
|
+
documentId: String(e.documentId),
|
|
27
|
+
locale: String(e.locale),
|
|
28
|
+
kind: e.kind === "unpublish" ? "unpublish" : "publish",
|
|
29
|
+
revisionId: typeof e.revisionId == "string" ? e.revisionId : null,
|
|
30
|
+
url: String(e.url),
|
|
31
|
+
status: e.status === "observed" || e.status === "stale" ? e.status : "pending",
|
|
32
|
+
requestedAt: p(e.requestedAt),
|
|
33
|
+
observedAt: e.observedAt === null || e.observedAt === void 0 ? null : p(e.observedAt),
|
|
34
|
+
lastSeen: typeof e.lastSeen == "string" ? e.lastSeen : null,
|
|
35
|
+
attempts: Number(e.attempts ?? 0)
|
|
36
|
+
}), h = async (e, t, n = /* @__PURE__ */ new Date()) => {
|
|
37
|
+
await e.updateMany(d, {
|
|
38
|
+
status: "stale",
|
|
39
|
+
lastSeen: "superseded"
|
|
40
|
+
}, { where: r(i("documentId", t.documentId), i("locale", t.locale), i("url", t.url), i("status", "pending")) });
|
|
41
|
+
let a = await e.insert(d, {
|
|
42
|
+
contentType: t.contentType,
|
|
43
|
+
documentId: t.documentId,
|
|
44
|
+
locale: t.locale,
|
|
45
|
+
kind: t.kind,
|
|
46
|
+
revisionId: t.revisionId ?? null,
|
|
47
|
+
url: t.url,
|
|
48
|
+
status: "pending",
|
|
49
|
+
requestedAt: n,
|
|
50
|
+
observedAt: null,
|
|
51
|
+
lastSeen: null,
|
|
52
|
+
attempts: 0,
|
|
53
|
+
...t.tenantId !== void 0 && t.tenantId !== null ? { tenantId: t.tenantId } : {}
|
|
54
|
+
});
|
|
55
|
+
return String(a.id);
|
|
56
|
+
}, g = async (e, t, n = /* @__PURE__ */ new Date(), r = {}) => {
|
|
57
|
+
let a = r.staleAfterMs ?? 9e5, o = await e.query({
|
|
58
|
+
table: d,
|
|
59
|
+
predicate: i("status", "pending"),
|
|
60
|
+
order: [{
|
|
61
|
+
column: "requestedAt",
|
|
62
|
+
direction: "asc"
|
|
63
|
+
}],
|
|
64
|
+
take: r.limit ?? 50,
|
|
65
|
+
skip: void 0,
|
|
66
|
+
projection: void 0
|
|
67
|
+
}), s = [];
|
|
68
|
+
for (let r of o) {
|
|
69
|
+
let i = m(r), o = await t(i.url).catch((e) => `error: ${String(e).slice(0, 150)}`), c = typeof o == "string" ? [o] : o, l = i.kind === "publish" ? i.revisionId !== null && c.includes(i.revisionId) : c.length === 1 && c[0] === "gone", u = l && i.revisionId !== null ? i.revisionId : c.join(" "), f = n.getTime() - i.requestedAt.getTime() > a, p = l ? "observed" : f ? "stale" : "pending", h = await e.update(d, i.id, {
|
|
70
|
+
status: p,
|
|
71
|
+
lastSeen: u.slice(0, 200),
|
|
72
|
+
attempts: i.attempts + 1,
|
|
73
|
+
...l ? { observedAt: n } : {}
|
|
74
|
+
});
|
|
75
|
+
p !== "pending" && h !== null && s.push(m(h));
|
|
76
|
+
}
|
|
77
|
+
return s;
|
|
78
|
+
}, _ = async (e, t = {}) => (await e.query({
|
|
79
|
+
table: d,
|
|
80
|
+
predicate: t.documentId === void 0 ? void 0 : i("documentId", t.documentId),
|
|
81
|
+
order: [{
|
|
82
|
+
column: "requestedAt",
|
|
83
|
+
direction: "desc"
|
|
84
|
+
}],
|
|
85
|
+
take: t.limit ?? 50,
|
|
86
|
+
skip: void 0,
|
|
87
|
+
projection: void 0
|
|
88
|
+
})).map(m), v = (e, t, n) => e.query({
|
|
89
|
+
table: t,
|
|
90
|
+
predicate: n,
|
|
91
|
+
order: [],
|
|
92
|
+
take: void 0,
|
|
93
|
+
skip: void 0,
|
|
94
|
+
projection: void 0
|
|
95
|
+
}), y = async (e, a) => {
|
|
96
|
+
let [o] = await v(e, t, i("id", a));
|
|
97
|
+
if (o === void 0) return null;
|
|
98
|
+
let s = o.publishedAt === null || o.publishedAt === void 0 ? null : p(o.publishedAt), c = await v(e, n, i("releaseId", a)), l = [];
|
|
99
|
+
for (let t of [...c].sort((e, t) => Number(e.position) - Number(t.position))) {
|
|
100
|
+
let n = String(t.contentType), [a] = await v(e, `${n}_drafts`, i("id", String(t.variantId))), o = String(a === void 0 ? t.variantId : a.documentId), c = t.action === "unpublish" ? "unpublish" : "publish", u = s === null ? [] : (await v(e, d, r(i("documentId", o), i("locale", String(t.locale))))).filter((e) => e.contentType === n && e.kind === c && p(e.requestedAt).getTime() >= s.getTime() - 1e3 && (c === "unpublish" || e.revisionId === t.revisionId)).sort((e, t) => p(t.requestedAt).getTime() - p(e.requestedAt).getTime()), f = /* @__PURE__ */ new Map();
|
|
101
|
+
for (let e of u) {
|
|
102
|
+
let t = m(e);
|
|
103
|
+
f.has(t.url) || f.set(t.url, t);
|
|
104
|
+
}
|
|
105
|
+
let h = {
|
|
106
|
+
contentType: n,
|
|
107
|
+
documentId: o,
|
|
108
|
+
locale: String(t.locale),
|
|
109
|
+
action: c
|
|
110
|
+
};
|
|
111
|
+
f.size === 0 && l.push({
|
|
112
|
+
...h,
|
|
113
|
+
status: "unchecked",
|
|
114
|
+
url: null,
|
|
115
|
+
tookSeconds: null,
|
|
116
|
+
lastSeen: null
|
|
117
|
+
});
|
|
118
|
+
for (let e of [...f.values()].sort((e, t) => e.requestedAt.getTime() - t.requestedAt.getTime() || e.url.localeCompare(t.url))) l.push({
|
|
119
|
+
...h,
|
|
120
|
+
status: e.status,
|
|
121
|
+
url: e.url,
|
|
122
|
+
tookSeconds: e.observedAt === null ? null : Math.round((e.observedAt.getTime() - e.requestedAt.getTime()) / 1e3),
|
|
123
|
+
lastSeen: e.lastSeen
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
let u = l.filter((e) => e.status !== "unchecked"), f = u.filter((e) => e.status === "observed").length;
|
|
127
|
+
return {
|
|
128
|
+
releaseId: a,
|
|
129
|
+
status: String(o.status),
|
|
130
|
+
publishedAt: s,
|
|
131
|
+
addresses: l,
|
|
132
|
+
reached: f,
|
|
133
|
+
checked: u.length,
|
|
134
|
+
complete: u.length > 0 && f === u.length
|
|
135
|
+
};
|
|
136
|
+
}, b = (...t) => e(() => h(...t)), x = (...t) => e(() => g(...t)), S = (...t) => e(() => _(...t)), C = (...t) => e(() => y(...t));
|
|
137
|
+
//#endregion
|
|
138
|
+
export { d as CMS_DELIVERY_CHECKS_TABLE, f as cmsDeliveryChecksTable, _ as deliveryChecks, S as deliveryChecksEffect, y as releaseCheckpoint, C as releaseCheckpointEffect, h as requestDeliveryCheck, b as requestDeliveryCheckEffect, g as runDeliveryChecks, x as runDeliveryChecksEffect };
|