@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,491 @@
|
|
|
1
|
+
//#region src/richDocument.ts
|
|
2
|
+
var e = 3, t = (e, t) => t === 0 ? e.ordered : (e.sublists?.[t - 1] ?? (e.ordered ? "ordered" : "unordered")) === "ordered", n = /* @__PURE__ */ new Set([
|
|
3
|
+
"bold",
|
|
4
|
+
"italic",
|
|
5
|
+
"underline"
|
|
6
|
+
]), r = /* @__PURE__ */ new Set([
|
|
7
|
+
"paragraph",
|
|
8
|
+
"heading",
|
|
9
|
+
"list",
|
|
10
|
+
"table",
|
|
11
|
+
"image",
|
|
12
|
+
"file",
|
|
13
|
+
"component"
|
|
14
|
+
]), i = (e) => typeof e == "object" && !!e && !Array.isArray(e), a = () => `rb_${crypto.randomUUID().replace(/-/g, "")}`, o = () => ({
|
|
15
|
+
type: "doc",
|
|
16
|
+
blocks: []
|
|
17
|
+
}), s = (e, t) => {
|
|
18
|
+
let n = t === void 0 ? {} : { profile: t.id };
|
|
19
|
+
return typeof e == "string" ? {
|
|
20
|
+
type: "doc",
|
|
21
|
+
blocks: e.split(/\n{2,}/).map((e) => e.trim()).filter((e) => e !== "").map((e) => ({
|
|
22
|
+
id: a(),
|
|
23
|
+
type: "paragraph",
|
|
24
|
+
content: [{
|
|
25
|
+
type: "text",
|
|
26
|
+
text: e
|
|
27
|
+
}]
|
|
28
|
+
})),
|
|
29
|
+
...n
|
|
30
|
+
} : !i(e) || e.type !== "doc" || !Array.isArray(e.blocks) ? e : {
|
|
31
|
+
...e,
|
|
32
|
+
blocks: e.blocks.map((e) => i(e) && (typeof e.id != "string" || e.id === "") ? {
|
|
33
|
+
...e,
|
|
34
|
+
id: a()
|
|
35
|
+
} : e),
|
|
36
|
+
...n
|
|
37
|
+
};
|
|
38
|
+
}, c = /^[^\s@<>()[\],;:"]+@[^\s@<>()[\],;:"]+\.[^\s@<>()[\],;:"]{2,}$/, l = /^\+?[0-9][0-9 ()/.-]*[0-9]$/, u = (e, t) => {
|
|
39
|
+
if (e === "email") return t.length <= 254 && c.test(t) ? null : "not an e-mail address";
|
|
40
|
+
let n = t.replace(/[^0-9]/g, "").length;
|
|
41
|
+
return l.test(t) && n >= 5 && n <= 15 ? null : "not a phone number (5 to 15 digits, an optional leading +)";
|
|
42
|
+
}, d = (e, t) => e === "email" ? `mailto:${t}` : `tel:${t.replace(/[^0-9+]/g, "")}`, f = (e, t, n) => {
|
|
43
|
+
t !== void 0 && (!i(t) || t.kind !== "insert" && t.kind !== "delete" || typeof t.id != "string" || t.id === "" || typeof t.by != "string" || t.by === "" || typeof t.at != "string" || Number.isNaN(Date.parse(t.at))) && n.push({
|
|
44
|
+
path: `${e}.change`,
|
|
45
|
+
rule: "type",
|
|
46
|
+
message: "a suggested change has an id, a kind (insert or delete), who made it and when"
|
|
47
|
+
});
|
|
48
|
+
}, p = (e, t, n, r) => {
|
|
49
|
+
if (t === void 0) return;
|
|
50
|
+
let i = n.profile?.styles;
|
|
51
|
+
if (i === void 0) return void r.push({
|
|
52
|
+
path: `${e}.style`,
|
|
53
|
+
rule: "profile",
|
|
54
|
+
message: "this field has no styles"
|
|
55
|
+
});
|
|
56
|
+
(typeof t != "string" || !(t in i.tokens)) && r.push({
|
|
57
|
+
path: `${e}.style`,
|
|
58
|
+
rule: "profile",
|
|
59
|
+
message: `a style is one of: ${Object.keys(i.tokens).join(", ")}`
|
|
60
|
+
});
|
|
61
|
+
}, m = (e, t, r, a) => {
|
|
62
|
+
if (!Array.isArray(t)) {
|
|
63
|
+
a.push({
|
|
64
|
+
path: e,
|
|
65
|
+
rule: "type",
|
|
66
|
+
message: "expected a list of inline nodes"
|
|
67
|
+
});
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
let o = r.profile;
|
|
71
|
+
t.forEach((t, s) => {
|
|
72
|
+
let c = `${e}[${s}]`;
|
|
73
|
+
if (!i(t)) return void a.push({
|
|
74
|
+
path: c,
|
|
75
|
+
rule: "type",
|
|
76
|
+
message: "expected an inline node"
|
|
77
|
+
});
|
|
78
|
+
if (f(c, t.change, a), t.type === "text") {
|
|
79
|
+
typeof t.text != "string" && a.push({
|
|
80
|
+
path: c,
|
|
81
|
+
rule: "type",
|
|
82
|
+
message: "text must be a string"
|
|
83
|
+
});
|
|
84
|
+
let e = t.marks;
|
|
85
|
+
return e !== void 0 && (!Array.isArray(e) || e.some((e) => !n.has(String(e)))) ? a.push({
|
|
86
|
+
path: c,
|
|
87
|
+
rule: "unknown",
|
|
88
|
+
message: `marks must be ${[...n].join(" / ")}`
|
|
89
|
+
}) : o !== void 0 && Array.isArray(e) && e.some((e) => !o.marks.includes(e)) && a.push({
|
|
90
|
+
path: `${c}.marks`,
|
|
91
|
+
rule: "profile",
|
|
92
|
+
message: `this field allows the marks: ${o.marks.join(", ") || "none"}`
|
|
93
|
+
}), p(c, t.style, r, a);
|
|
94
|
+
}
|
|
95
|
+
if (t.type === "link") {
|
|
96
|
+
if (r.links === void 0) return void a.push({
|
|
97
|
+
path: c,
|
|
98
|
+
rule: "richText",
|
|
99
|
+
message: "links are not allowed in this field"
|
|
100
|
+
});
|
|
101
|
+
(typeof t.target != "string" || t.target === "") && a.push({
|
|
102
|
+
path: c,
|
|
103
|
+
rule: "required",
|
|
104
|
+
message: "a link needs a target document"
|
|
105
|
+
}), (typeof t.text != "string" || t.text === "") && a.push({
|
|
106
|
+
path: c,
|
|
107
|
+
rule: "required",
|
|
108
|
+
message: "a link needs text"
|
|
109
|
+
});
|
|
110
|
+
} else if (t.type === "contact") {
|
|
111
|
+
(typeof t.text != "string" || t.text === "") && a.push({
|
|
112
|
+
path: c,
|
|
113
|
+
rule: "required",
|
|
114
|
+
message: "a contact needs text"
|
|
115
|
+
});
|
|
116
|
+
let e = t.contact;
|
|
117
|
+
if (!i(e)) return void a.push({
|
|
118
|
+
path: `${c}.contact`,
|
|
119
|
+
rule: "type",
|
|
120
|
+
message: "expected a contact point or an address"
|
|
121
|
+
});
|
|
122
|
+
if ("target" in e) {
|
|
123
|
+
if (o?.contactPoints === void 0) return void a.push({
|
|
124
|
+
path: c,
|
|
125
|
+
rule: "profile",
|
|
126
|
+
message: "this field names no contact points"
|
|
127
|
+
});
|
|
128
|
+
(typeof e.target != "string" || e.target === "") && a.push({
|
|
129
|
+
path: `${c}.contact.target`,
|
|
130
|
+
rule: "required",
|
|
131
|
+
message: "a contact needs its contact point"
|
|
132
|
+
});
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (o?.contactLiterals !== !0) return void a.push({
|
|
136
|
+
path: c,
|
|
137
|
+
rule: "profile",
|
|
138
|
+
message: "this field takes no one-off addresses or numbers"
|
|
139
|
+
});
|
|
140
|
+
let n = e.channel;
|
|
141
|
+
if (n !== "email" && n !== "phone") return void a.push({
|
|
142
|
+
path: `${c}.contact.channel`,
|
|
143
|
+
rule: "literal",
|
|
144
|
+
message: "a contact is an email or a phone"
|
|
145
|
+
});
|
|
146
|
+
let r = typeof e.value == "string" ? u(n, e.value) : "missing";
|
|
147
|
+
r !== null && a.push({
|
|
148
|
+
path: `${c}.contact.value`,
|
|
149
|
+
rule: "contact",
|
|
150
|
+
message: r
|
|
151
|
+
});
|
|
152
|
+
} else a.push({
|
|
153
|
+
path: c,
|
|
154
|
+
rule: "unknown",
|
|
155
|
+
message: `unknown inline node '${String(t.type)}'`
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}, h = (e, t, n) => {
|
|
159
|
+
let a = [];
|
|
160
|
+
if (!i(t) || t.type !== "doc" || !Array.isArray(t.blocks)) return [{
|
|
161
|
+
path: e,
|
|
162
|
+
rule: "type",
|
|
163
|
+
message: "expected a rich document ({ type: 'doc', blocks })"
|
|
164
|
+
}];
|
|
165
|
+
let o = n.profile, s = /* @__PURE__ */ new Set();
|
|
166
|
+
return t.blocks.forEach((t, c) => {
|
|
167
|
+
let l = `${e}.blocks[${c}]`;
|
|
168
|
+
if (!i(t)) return void a.push({
|
|
169
|
+
path: l,
|
|
170
|
+
rule: "type",
|
|
171
|
+
message: "expected a block"
|
|
172
|
+
});
|
|
173
|
+
let u = t.id;
|
|
174
|
+
typeof u != "string" || u === "" ? a.push({
|
|
175
|
+
path: `${l}.id`,
|
|
176
|
+
rule: "required",
|
|
177
|
+
message: "every block needs an id"
|
|
178
|
+
}) : s.has(u) ? a.push({
|
|
179
|
+
path: `${l}.id`,
|
|
180
|
+
rule: "unique",
|
|
181
|
+
message: `block id '${u}' is used twice`
|
|
182
|
+
}) : s.add(u), f(l, t.change, a);
|
|
183
|
+
let d = t.type;
|
|
184
|
+
if (o !== void 0 && r.has(String(d)) && !o.blocks.includes(d)) a.push({
|
|
185
|
+
path: l,
|
|
186
|
+
rule: "profile",
|
|
187
|
+
message: `this field allows the blocks: ${o.blocks.join(", ")}`
|
|
188
|
+
});
|
|
189
|
+
else switch ((d === "paragraph" || d === "heading" || d === "list") && p(l, t.style, n, a), d) {
|
|
190
|
+
case "paragraph": return m(`${l}.content`, t.content, n, a);
|
|
191
|
+
case "heading": return t.level !== 2 && t.level !== 3 ? a.push({
|
|
192
|
+
path: `${l}.level`,
|
|
193
|
+
rule: "literal",
|
|
194
|
+
message: "a heading is level 2 or 3"
|
|
195
|
+
}) : o !== void 0 && !o.headings.includes(t.level) && a.push({
|
|
196
|
+
path: `${l}.level`,
|
|
197
|
+
rule: "profile",
|
|
198
|
+
message: `this field allows heading levels: ${o.headings.join(", ")}`
|
|
199
|
+
}), m(`${l}.content`, t.content, n, a);
|
|
200
|
+
case "list": {
|
|
201
|
+
let e = t.items;
|
|
202
|
+
if (typeof t.ordered != "boolean" && a.push({
|
|
203
|
+
path: `${l}.ordered`,
|
|
204
|
+
rule: "type",
|
|
205
|
+
message: "ordered must be true or false"
|
|
206
|
+
}), !Array.isArray(e)) return void a.push({
|
|
207
|
+
path: `${l}.items`,
|
|
208
|
+
rule: "type",
|
|
209
|
+
message: "expected list items"
|
|
210
|
+
});
|
|
211
|
+
let r = t.levels;
|
|
212
|
+
r !== void 0 && (!Array.isArray(r) || r.length !== e.length ? a.push({
|
|
213
|
+
path: `${l}.levels`,
|
|
214
|
+
rule: "type",
|
|
215
|
+
message: "one level per item"
|
|
216
|
+
}) : r.forEach((e, t) => {
|
|
217
|
+
let n = t === 0 ? -1 : Number(r[t - 1]);
|
|
218
|
+
(!Number.isInteger(e) || e < 0 || e > 3 || e > n + 1) && a.push({
|
|
219
|
+
path: `${l}.levels[${t}]`,
|
|
220
|
+
rule: "level",
|
|
221
|
+
message: "an item sits at most 3 deep, and at most one deeper than the item before it"
|
|
222
|
+
});
|
|
223
|
+
}));
|
|
224
|
+
let i = t.sublists;
|
|
225
|
+
return i !== void 0 && (!Array.isArray(i) || i.length > 3 || i.some((e) => e !== "ordered" && e !== "unordered")) && a.push({
|
|
226
|
+
path: `${l}.sublists`,
|
|
227
|
+
rule: "type",
|
|
228
|
+
message: "at most 3 kinds of nested lists, each ordered or unordered"
|
|
229
|
+
}), e.forEach((e, t) => m(`${l}.items[${t}]`, e, n, a));
|
|
230
|
+
}
|
|
231
|
+
case "table": {
|
|
232
|
+
let e = t.rows;
|
|
233
|
+
return typeof t.header != "boolean" && a.push({
|
|
234
|
+
path: `${l}.header`,
|
|
235
|
+
rule: "type",
|
|
236
|
+
message: "header must be true or false"
|
|
237
|
+
}), Array.isArray(e) ? e.forEach((e, t) => {
|
|
238
|
+
if (!Array.isArray(e)) return void a.push({
|
|
239
|
+
path: `${l}.rows[${t}]`,
|
|
240
|
+
rule: "type",
|
|
241
|
+
message: "expected a row of cells"
|
|
242
|
+
});
|
|
243
|
+
e.forEach((e, r) => m(`${l}.rows[${t}][${r}]`, e, n, a));
|
|
244
|
+
}) : void a.push({
|
|
245
|
+
path: `${l}.rows`,
|
|
246
|
+
rule: "type",
|
|
247
|
+
message: "expected table rows"
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
case "image":
|
|
251
|
+
if (n.images === void 0) return void a.push({
|
|
252
|
+
path: l,
|
|
253
|
+
rule: "richText",
|
|
254
|
+
message: "images are not allowed in this field"
|
|
255
|
+
});
|
|
256
|
+
(typeof t.asset != "string" || t.asset === "") && a.push({
|
|
257
|
+
path: `${l}.asset`,
|
|
258
|
+
rule: "required",
|
|
259
|
+
message: "an image needs an asset"
|
|
260
|
+
}), t.caption !== void 0 && typeof t.caption != "string" && a.push({
|
|
261
|
+
path: `${l}.caption`,
|
|
262
|
+
rule: "type",
|
|
263
|
+
message: "a caption is text"
|
|
264
|
+
});
|
|
265
|
+
return;
|
|
266
|
+
case "file":
|
|
267
|
+
if (n.files === void 0) return void a.push({
|
|
268
|
+
path: l,
|
|
269
|
+
rule: "richText",
|
|
270
|
+
message: "downloads are not allowed in this field"
|
|
271
|
+
});
|
|
272
|
+
(typeof t.asset != "string" || t.asset === "") && a.push({
|
|
273
|
+
path: `${l}.asset`,
|
|
274
|
+
rule: "required",
|
|
275
|
+
message: "a download needs a file"
|
|
276
|
+
}), (typeof t.label != "string" || t.label.trim() === "") && a.push({
|
|
277
|
+
path: `${l}.label`,
|
|
278
|
+
rule: "required",
|
|
279
|
+
message: "a download needs the text its link shows"
|
|
280
|
+
});
|
|
281
|
+
return;
|
|
282
|
+
case "component":
|
|
283
|
+
if (o === void 0 || o.components.length === 0) return void a.push({
|
|
284
|
+
path: l,
|
|
285
|
+
rule: "profile",
|
|
286
|
+
message: "components are not allowed in this field"
|
|
287
|
+
});
|
|
288
|
+
if (!o.components.some((e) => e.id === t.componentId)) {
|
|
289
|
+
a.push({
|
|
290
|
+
path: `${l}.componentId`,
|
|
291
|
+
rule: "unknown",
|
|
292
|
+
message: `'${String(t.componentId)}' is not a component this field allows`
|
|
293
|
+
});
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
i(t.props) || a.push({
|
|
297
|
+
path: `${l}.props`,
|
|
298
|
+
rule: "type",
|
|
299
|
+
message: "expected an object"
|
|
300
|
+
});
|
|
301
|
+
return;
|
|
302
|
+
default: a.push({
|
|
303
|
+
path: l,
|
|
304
|
+
rule: "unknown",
|
|
305
|
+
message: `unknown block '${String(t.type)}'`
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}), a;
|
|
309
|
+
}, g = (e, t, n) => {
|
|
310
|
+
let r = [], i = n.profile?.contactPoints, a = (e, t) => {
|
|
311
|
+
t.forEach((t, a) => {
|
|
312
|
+
t.type === "link" && n.links !== void 0 && t.target !== "" && r.push({
|
|
313
|
+
path: `${e}[${a}]`,
|
|
314
|
+
targetType: n.links,
|
|
315
|
+
targetDocumentId: t.target
|
|
316
|
+
}), t.type === "contact" && i !== void 0 && "target" in t.contact && t.contact.target !== "" && r.push({
|
|
317
|
+
path: `${e}[${a}]`,
|
|
318
|
+
targetType: i,
|
|
319
|
+
targetDocumentId: t.contact.target
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
};
|
|
323
|
+
return t.blocks.forEach((t, i) => {
|
|
324
|
+
let o = `${e}.blocks[${i}]`;
|
|
325
|
+
switch (t.type) {
|
|
326
|
+
case "paragraph":
|
|
327
|
+
case "heading": return a(`${o}.content`, t.content);
|
|
328
|
+
case "list": return t.items.forEach((e, t) => a(`${o}.items[${t}]`, e));
|
|
329
|
+
case "table": return t.rows.forEach((e, t) => e.forEach((e, n) => a(`${o}.rows[${t}][${n}]`, e)));
|
|
330
|
+
case "image":
|
|
331
|
+
n.images !== void 0 && t.asset !== "" && r.push({
|
|
332
|
+
path: o,
|
|
333
|
+
targetType: n.images,
|
|
334
|
+
targetDocumentId: t.asset
|
|
335
|
+
});
|
|
336
|
+
return;
|
|
337
|
+
case "file":
|
|
338
|
+
n.files !== void 0 && t.asset !== "" && r.push({
|
|
339
|
+
path: o,
|
|
340
|
+
targetType: n.files,
|
|
341
|
+
targetDocumentId: t.asset
|
|
342
|
+
});
|
|
343
|
+
return;
|
|
344
|
+
case "component": return;
|
|
345
|
+
}
|
|
346
|
+
}), r;
|
|
347
|
+
}, _ = /[*_+[\]()\\{}|]/, v = (e, t = []) => {
|
|
348
|
+
let n = [], r = "", i = [], a, o = () => {
|
|
349
|
+
if (r === "") return;
|
|
350
|
+
let e = n[n.length - 1];
|
|
351
|
+
e?.type === "text" && (e.marks ?? []).join() === i.join() && e.style === a && e.type === "text" ? n[n.length - 1] = {
|
|
352
|
+
...e,
|
|
353
|
+
text: e.text + r
|
|
354
|
+
} : n.push({
|
|
355
|
+
type: "text",
|
|
356
|
+
text: r,
|
|
357
|
+
...i.length > 0 ? { marks: [...i] } : {},
|
|
358
|
+
...a === void 0 ? {} : { style: a }
|
|
359
|
+
}), r = "";
|
|
360
|
+
}, s = (e, t) => {
|
|
361
|
+
o(), i = t ? i.filter((t) => t !== e) : [...i, e];
|
|
362
|
+
}, c = 0;
|
|
363
|
+
for (; c < e.length;) {
|
|
364
|
+
let l = e[c];
|
|
365
|
+
if (l === "\\" && c + 1 < e.length && _.test(e[c + 1])) r += e[c + 1], c += 2;
|
|
366
|
+
else {
|
|
367
|
+
if (e.startsWith("**", c)) {
|
|
368
|
+
let t = i.includes("bold");
|
|
369
|
+
if (t || e.indexOf("**", c + 2) !== -1) {
|
|
370
|
+
s("bold", t), c += 2;
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
if (e.startsWith("++", c)) {
|
|
375
|
+
let t = i.includes("underline");
|
|
376
|
+
if (t || e.indexOf("++", c + 2) !== -1) {
|
|
377
|
+
s("underline", t), c += 2;
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (l === "_") {
|
|
382
|
+
let t = i.includes("italic");
|
|
383
|
+
if (t || e.indexOf("_", c + 1) !== -1) {
|
|
384
|
+
s("italic", t), c += 1;
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (l === "[") {
|
|
389
|
+
let t = /^\[([^\]]+)\]\((doc|contact|mailto|tel):([^)\s]+)\)/.exec(e.slice(c));
|
|
390
|
+
if (t !== null) {
|
|
391
|
+
o();
|
|
392
|
+
let [, e = "", r, i = ""] = t;
|
|
393
|
+
n.push(r === "doc" ? {
|
|
394
|
+
type: "link",
|
|
395
|
+
text: e,
|
|
396
|
+
target: i
|
|
397
|
+
} : r === "contact" ? {
|
|
398
|
+
type: "contact",
|
|
399
|
+
text: e,
|
|
400
|
+
contact: { target: i }
|
|
401
|
+
} : {
|
|
402
|
+
type: "contact",
|
|
403
|
+
text: e,
|
|
404
|
+
contact: {
|
|
405
|
+
channel: r === "mailto" ? "email" : "phone",
|
|
406
|
+
value: i
|
|
407
|
+
}
|
|
408
|
+
}), c += t[0].length;
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (l === "{" && a === void 0) {
|
|
413
|
+
let n = /^\{([a-z][a-zA-Z0-9]*)\|/.exec(e.slice(c));
|
|
414
|
+
if (n !== null && t.includes(n[1]) && e.indexOf("}", c) !== -1) {
|
|
415
|
+
o(), a = n[1], c += n[0].length;
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
l === "}" && a !== void 0 ? (o(), a = void 0, c += 1) : (r += l, c += 1);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return o(), n;
|
|
423
|
+
}, y = (e) => e.replace(/[*_+[\]()\\{}|]/g, (e) => `\\${e}`), b = (e) => e.map((e) => {
|
|
424
|
+
if (e.type === "link") return `[${y(e.text)}](doc:${e.target})`;
|
|
425
|
+
if (e.type === "contact") {
|
|
426
|
+
let t = "target" in e.contact ? `contact:${e.contact.target}` : `${e.contact.channel === "email" ? "mailto" : "tel"}:${e.contact.value}`;
|
|
427
|
+
return `[${y(e.text)}](${t})`;
|
|
428
|
+
}
|
|
429
|
+
let t = e.marks ?? [], n = t.includes("bold") ? "**" : "", r = t.includes("italic") ? "_" : "", i = t.includes("underline") ? "++" : "", a = `${n}${r}${i}${y(e.text)}${i}${r}${n}`;
|
|
430
|
+
return e.style === void 0 ? a : `{${e.style}|${a}}`;
|
|
431
|
+
}).join(""), x = (e) => {
|
|
432
|
+
switch (e.type) {
|
|
433
|
+
case "paragraph":
|
|
434
|
+
case "heading": return b(e.content);
|
|
435
|
+
case "list": return e.items.map((t, n) => `${" ".repeat(e.levels?.[n] ?? 0)}${b(t)}`).join("\n");
|
|
436
|
+
case "table": return e.rows.map((e) => e.map(b).join(" | ")).join("\n");
|
|
437
|
+
case "image":
|
|
438
|
+
case "file":
|
|
439
|
+
case "component": return "";
|
|
440
|
+
}
|
|
441
|
+
}, S = (e, t) => {
|
|
442
|
+
let n = [], r = [];
|
|
443
|
+
for (let i of e.split("\n")) {
|
|
444
|
+
if (i.trim() === "") continue;
|
|
445
|
+
let e = /^[ \t]*/.exec(i)[0].replace(/\t/g, " ").length, a = Math.floor(e / 2), o = Math.min(a, 3, r.length === 0 ? 0 : r[r.length - 1] + 1);
|
|
446
|
+
n.push(v(i.trim(), t)), r.push(o);
|
|
447
|
+
}
|
|
448
|
+
return r.some((e) => e > 0) ? {
|
|
449
|
+
items: n,
|
|
450
|
+
levels: r
|
|
451
|
+
} : { items: n };
|
|
452
|
+
}, C = (e) => e.split("\n").map((e) => e.trim()).filter((e) => e !== ""), w = (e, t, n = []) => {
|
|
453
|
+
switch (e.type) {
|
|
454
|
+
case "paragraph":
|
|
455
|
+
case "heading": return {
|
|
456
|
+
...e,
|
|
457
|
+
content: v(t, n)
|
|
458
|
+
};
|
|
459
|
+
case "list": return {
|
|
460
|
+
id: e.id,
|
|
461
|
+
type: "list",
|
|
462
|
+
ordered: e.ordered,
|
|
463
|
+
...S(t, n),
|
|
464
|
+
...e.change === void 0 ? {} : { change: e.change },
|
|
465
|
+
...e.sublists === void 0 ? {} : { sublists: e.sublists },
|
|
466
|
+
...e.style === void 0 ? {} : { style: e.style }
|
|
467
|
+
};
|
|
468
|
+
case "table": return {
|
|
469
|
+
...e,
|
|
470
|
+
rows: C(t).map((e) => e.split("|").map((e) => v(e.trim())))
|
|
471
|
+
};
|
|
472
|
+
case "image":
|
|
473
|
+
case "file":
|
|
474
|
+
case "component": return e;
|
|
475
|
+
}
|
|
476
|
+
}, T = (e) => {
|
|
477
|
+
let t = (e) => e.map((e) => e.text).join("");
|
|
478
|
+
return e.blocks.map((e) => {
|
|
479
|
+
switch (e.type) {
|
|
480
|
+
case "paragraph":
|
|
481
|
+
case "heading": return t(e.content);
|
|
482
|
+
case "list": return e.items.map(t).join("\n");
|
|
483
|
+
case "table": return e.rows.map((e) => e.map(t).join(" ")).join("\n");
|
|
484
|
+
case "image": return e.caption ?? "";
|
|
485
|
+
case "file": return e.label;
|
|
486
|
+
case "component": return "";
|
|
487
|
+
}
|
|
488
|
+
}).filter((e) => e !== "").join("\n");
|
|
489
|
+
};
|
|
490
|
+
//#endregion
|
|
491
|
+
export { e as MAX_LIST_LEVEL, x as blockMarkup, d as contactLiteralHref, u as contactLiteralProblem, o as emptyRichDocument, b as inlineMarkupOf, t as listNumberedAt, a as newBlockId, s as normalizeRichDocument, v as parseInlineMarkup, T as plainTextOf, h as richDocumentProblems, g as richDocumentReferences, w as withBlockMarkup };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
//#region src/richInline.ts
|
|
2
|
+
var e = (e) => e.type === "text" ? e.marks ?? [] : [], t = (e) => e.type === "text" ? e.style : void 0, n = (e, t) => e.length === t.length && e.every((e) => t.includes(e)), r = (e, t, n, r) => ({
|
|
3
|
+
type: "text",
|
|
4
|
+
text: e,
|
|
5
|
+
...t.length > 0 ? { marks: [...t].sort() } : {},
|
|
6
|
+
...n === void 0 ? {} : { style: n },
|
|
7
|
+
...r === void 0 ? {} : { change: r }
|
|
8
|
+
}), i = (n, i) => i === void 0 ? r(n, []) : r(n, e(i), t(i), i.change), a = (e, t) => e.change?.id === t.change?.id && e.change?.kind === t.change?.kind, o = (r) => {
|
|
9
|
+
let o = [];
|
|
10
|
+
for (let s of r) {
|
|
11
|
+
if (s.text === "") continue;
|
|
12
|
+
let r = o[o.length - 1];
|
|
13
|
+
s.type === "text" && r?.type === "text" && n(e(r), e(s)) && t(r) === t(s) && a(r, s) ? o[o.length - 1] = i(r.text + s.text, s) : o.push(s.type === "text" ? i(s.text, s) : s);
|
|
14
|
+
}
|
|
15
|
+
return o;
|
|
16
|
+
}, s = (e) => e.map((e) => e.text).join(""), c = (t, n, r, i) => {
|
|
17
|
+
if (r <= n) return !1;
|
|
18
|
+
let a = 0;
|
|
19
|
+
for (let o of t) {
|
|
20
|
+
let t = a;
|
|
21
|
+
if (a += o.text.length, !(a <= n || t >= r) && (o.type !== "text" || !e(o).includes(i))) return !1;
|
|
22
|
+
}
|
|
23
|
+
return !0;
|
|
24
|
+
}, l = (n, i, a, s) => {
|
|
25
|
+
if (a <= i) return n;
|
|
26
|
+
let l = c(n, i, a, s), u = [], d = 0;
|
|
27
|
+
for (let o of n) {
|
|
28
|
+
let n = d;
|
|
29
|
+
if (d += o.text.length, o.type !== "text" || d <= i || n >= a) {
|
|
30
|
+
u.push(o);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
let c = Math.max(i, n) - n, f = Math.min(a, d) - n, p = e(o), m = t(o), h = l ? p.filter((e) => e !== s) : p.includes(s) ? p : [...p, s];
|
|
34
|
+
u.push(r(o.text.slice(0, c), p, m, o.change), r(o.text.slice(c, f), h, m, o.change), r(o.text.slice(f), p, m, o.change));
|
|
35
|
+
}
|
|
36
|
+
return o(u);
|
|
37
|
+
}, u = (e, t, n) => {
|
|
38
|
+
let a = [], o = 0;
|
|
39
|
+
for (let s of e) {
|
|
40
|
+
let e = o;
|
|
41
|
+
o += s.text.length;
|
|
42
|
+
let c = Math.max(t, e) - e, l = Math.min(n, o) - e;
|
|
43
|
+
l <= c || (s.type === "text" ? a.push(i(s.text.slice(c, l), s)) : a.push(c === 0 && l === s.text.length ? s : r(s.text.slice(c, l), [], void 0, s.change)));
|
|
44
|
+
}
|
|
45
|
+
return a;
|
|
46
|
+
}, d = (e, t, n, r) => {
|
|
47
|
+
let a = u(e, 0, t), [s] = n > t ? u(e, t, t + 1) : [], c = s ?? a[a.length - 1];
|
|
48
|
+
return o([
|
|
49
|
+
...a,
|
|
50
|
+
i(r, c),
|
|
51
|
+
...u(e, n, 2 ** 53 - 1)
|
|
52
|
+
]);
|
|
53
|
+
}, f = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), p = (t) => t.map((t) => {
|
|
54
|
+
if (t.type === "link") return `<a data-target="${f(t.target)}">${f(t.text)}</a>`;
|
|
55
|
+
if (t.type === "contact") return `<a data-contact="${f("target" in t.contact ? `contact:${t.contact.target}` : `${t.contact.channel}:${t.contact.value}`)}">${f(t.text)}</a>`;
|
|
56
|
+
let n = f(t.text);
|
|
57
|
+
return e(t).includes("underline") && (n = `<u>${n}</u>`), e(t).includes("italic") && (n = `<em>${n}</em>`), e(t).includes("bold") && (n = `<strong>${n}</strong>`), t.style === void 0 ? n : `<span data-style="${f(t.style)}">${n}</span>`;
|
|
58
|
+
}).join(""), m = (e) => {
|
|
59
|
+
let t = e.indexOf(":"), n = e.slice(0, t), r = e.slice(t + 1);
|
|
60
|
+
return t <= 0 || r === "" ? null : n === "contact" ? { target: r } : n === "email" || n === "phone" ? {
|
|
61
|
+
channel: n,
|
|
62
|
+
value: r
|
|
63
|
+
} : null;
|
|
64
|
+
}, h = (e) => {
|
|
65
|
+
let t = [], n = (e, i, a) => {
|
|
66
|
+
if (e.nodeType === 3) {
|
|
67
|
+
t.push(r(e.textContent ?? "", i, a));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (e.nodeType !== 1) return;
|
|
71
|
+
let o = e.nodeName.toLowerCase();
|
|
72
|
+
if (o === "br") {
|
|
73
|
+
t.push(r("\n", i, a));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (o === "a" && e.getAttribute?.("data-target")) {
|
|
77
|
+
t.push({
|
|
78
|
+
type: "link",
|
|
79
|
+
target: e.getAttribute("data-target"),
|
|
80
|
+
text: e.textContent ?? ""
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
let s = o === "a" ? m(e.getAttribute?.("data-contact") ?? "") : null;
|
|
85
|
+
if (s !== null) {
|
|
86
|
+
t.push({
|
|
87
|
+
type: "contact",
|
|
88
|
+
text: e.textContent ?? "",
|
|
89
|
+
contact: s
|
|
90
|
+
});
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
let c = o === "strong" || o === "b" ? [.../* @__PURE__ */ new Set([...i, "bold"])] : o === "em" || o === "i" ? [.../* @__PURE__ */ new Set([...i, "italic"])] : o === "u" ? [.../* @__PURE__ */ new Set([...i, "underline"])] : i, l = o === "span" ? e.getAttribute?.("data-style") : null;
|
|
94
|
+
for (let t of Array.from(e.childNodes)) n(t, c, l != null && l !== "" ? l : a);
|
|
95
|
+
};
|
|
96
|
+
for (let t of Array.from(e.childNodes)) n(t, [], void 0);
|
|
97
|
+
return o(t);
|
|
98
|
+
};
|
|
99
|
+
//#endregion
|
|
100
|
+
export { c as hasMark, h as inlineFromDom, p as inlineHtml, s as inlineText, o as mergeInline, d as replaceText, u as sliceInline, l as toggleMark };
|
package/dist/schedule.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { asTyped as e } from "./effectForm.js";
|
|
2
|
+
import { ContentNotFound as t, ReferenceUnavailable as n, ReviewRequired as r } from "./errors.js";
|
|
3
|
+
import { publish as i, revalidateContent as a, scopeColumns as o, unpublish as s } from "./write.js";
|
|
4
|
+
import { and as c, eq as l, lte as u } from "@voltro/database";
|
|
5
|
+
//#region src/schedule.ts
|
|
6
|
+
var d = (e) => `${e.name}_drafts`, f = async (e, t, n, r, i) => m(e, t, n, { publishAt: r }, i), p = async (e, t, n, r, i) => m(e, t, n, { unpublishAt: r }, i), m = async (e, n, r, i, a) => {
|
|
7
|
+
let s = d(n), u = await e.query({
|
|
8
|
+
table: s,
|
|
9
|
+
predicate: c(l("id", r), ...Object.entries(o(a)).map(([e, t]) => l(e, t))),
|
|
10
|
+
order: [],
|
|
11
|
+
take: 1,
|
|
12
|
+
skip: void 0,
|
|
13
|
+
projection: void 0
|
|
14
|
+
});
|
|
15
|
+
if (u[0] === void 0) throw new t({
|
|
16
|
+
contentType: n.name,
|
|
17
|
+
id: r,
|
|
18
|
+
stage: "draft"
|
|
19
|
+
});
|
|
20
|
+
return await e.update(s, r, i) ?? u[0];
|
|
21
|
+
}, h = (e, t) => ({
|
|
22
|
+
table: d(e),
|
|
23
|
+
predicate: c(u("publishAt", t), l("status", "draft")),
|
|
24
|
+
order: [],
|
|
25
|
+
take: void 0,
|
|
26
|
+
skip: void 0,
|
|
27
|
+
projection: void 0
|
|
28
|
+
}), g = async (e, t, o = /* @__PURE__ */ new Date()) => {
|
|
29
|
+
let s = await e.query(h(t, o)), c = [];
|
|
30
|
+
for (let a of s) {
|
|
31
|
+
let o = a.id;
|
|
32
|
+
if (typeof o != "string") continue;
|
|
33
|
+
let s = {
|
|
34
|
+
site: String(a.site),
|
|
35
|
+
environment: String(a.environment),
|
|
36
|
+
locale: String(a.locale)
|
|
37
|
+
};
|
|
38
|
+
try {
|
|
39
|
+
await e.transactional(async (e) => {
|
|
40
|
+
await i(e, t, o, s), await e.update(d(t), o, { publishAt: null });
|
|
41
|
+
});
|
|
42
|
+
} catch (e) {
|
|
43
|
+
if (e instanceof r || e instanceof n) continue;
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
c.push(o);
|
|
47
|
+
}
|
|
48
|
+
return c.length > 0 && a(t), c;
|
|
49
|
+
}, _ = async (e, n, r = /* @__PURE__ */ new Date()) => {
|
|
50
|
+
let i = await e.query({
|
|
51
|
+
table: d(n),
|
|
52
|
+
predicate: u("unpublishAt", r),
|
|
53
|
+
order: [],
|
|
54
|
+
take: void 0,
|
|
55
|
+
skip: void 0,
|
|
56
|
+
projection: void 0
|
|
57
|
+
}), o = [];
|
|
58
|
+
for (let r of i) {
|
|
59
|
+
let i = r.id;
|
|
60
|
+
if (typeof i != "string") continue;
|
|
61
|
+
let a = {
|
|
62
|
+
site: String(r.site),
|
|
63
|
+
environment: String(r.environment),
|
|
64
|
+
locale: String(r.locale)
|
|
65
|
+
};
|
|
66
|
+
await e.transactional(async (e) => {
|
|
67
|
+
let r = !0;
|
|
68
|
+
try {
|
|
69
|
+
await s(e, n, i, a);
|
|
70
|
+
} catch (e) {
|
|
71
|
+
if (!(e instanceof t)) throw e;
|
|
72
|
+
r = !1;
|
|
73
|
+
}
|
|
74
|
+
return await e.update(d(n), i, { unpublishAt: null }), r;
|
|
75
|
+
}) && o.push(i);
|
|
76
|
+
}
|
|
77
|
+
return o.length > 0 && a(n), o;
|
|
78
|
+
}, v = (...n) => e(() => f(...n), t), y = (...n) => e(() => p(...n), t), b = (...t) => e(() => g(...t)), x = (...t) => e(() => _(...t));
|
|
79
|
+
//#endregion
|
|
80
|
+
export { g as publishDue, b as publishDueEffect, f as schedulePublish, v as schedulePublishEffect, p as scheduleUnpublish, y as scheduleUnpublishEffect, _ as unpublishDue, x as unpublishDueEffect };
|