@questwork/p-templates-model 0.1.2 → 0.1.3
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/README.md +2 -0
- package/dist/p-templates-model.cjs +11 -11
- package/dist/p-templates-model.cjs.map +1 -1
- package/dist/p-templates-model.esm.js +660 -642
- package/dist/p-templates-model.esm.js.map +1 -1
- package/dist/p-templates-model.umd.js +11 -11
- package/dist/p-templates-model.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { TenantAwareEntity as
|
|
2
|
-
import { Liquid as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
1
|
+
import { TenantAwareEntity as Ot, copySerializableProperties as L, copySerializableKeyValueObjects as qe, Lifecycle as Ct, TrackedEntity as tt, EntityAction as nt, copySerializableValue as Ge } from "@questwork/q-utilities";
|
|
2
|
+
import { Liquid as At, TypeGuards as A, Tokenizer as Rt } from "liquidjs";
|
|
3
|
+
import Nt from "juice/client";
|
|
4
|
+
const Ie = 2, rt = Object.freeze([2]), y = Object.freeze({
|
|
5
5
|
BLOCK_CONTEXT_MISMATCH: "BLOCK_CONTEXT_MISMATCH",
|
|
6
6
|
BLOCK_DEPRECATED: "BLOCK_DEPRECATED",
|
|
7
7
|
BLOCK_ELEMENT_INVALID: "BLOCK_ELEMENT_INVALID",
|
|
@@ -30,121 +30,132 @@ const we = 2, Ze = Object.freeze([2]), y = Object.freeze({
|
|
|
30
30
|
}), X = Object.freeze({
|
|
31
31
|
ERROR: "ERROR",
|
|
32
32
|
WARNING: "WARNING"
|
|
33
|
-
}),
|
|
33
|
+
}), De = Object.freeze(["blank", "empty", "false", "forloop", "nil", "null", "params", "true"]), F = "params", Q = /^[A-Z_]\w*$/i, P = Object.freeze({
|
|
34
34
|
BOOLEAN: "boolean",
|
|
35
35
|
DATE: "date",
|
|
36
36
|
LIST: "list",
|
|
37
37
|
NUMBER: "number",
|
|
38
38
|
OBJECT: "object",
|
|
39
39
|
STRING: "string"
|
|
40
|
-
}),
|
|
41
|
-
class
|
|
40
|
+
}), St = /* @__PURE__ */ new Set([P.BOOLEAN, P.DATE, P.NUMBER, P.STRING]), se = Symbol("templateProjectionNode"), Lt = 10;
|
|
41
|
+
class it {
|
|
42
42
|
constructor({ projectionCode: e, label: n, description: r, fields: i } = {}) {
|
|
43
43
|
if (!e || typeof e != "string")
|
|
44
44
|
throw new TypeError("TemplateProjection requires a projectionCode.");
|
|
45
|
-
Object.defineProperty(this,
|
|
45
|
+
Object.defineProperty(this, se, {
|
|
46
46
|
enumerable: !1,
|
|
47
|
-
value:
|
|
47
|
+
value: oe({ description: r, fields: i, label: n, type: P.OBJECT }, e)
|
|
48
48
|
}), this.projectionCode = e, Object.freeze(this);
|
|
49
49
|
}
|
|
50
50
|
/** Serializable schema for editors and checks (no functions). */
|
|
51
51
|
describe() {
|
|
52
|
-
return
|
|
52
|
+
return ae(this[se]);
|
|
53
53
|
}
|
|
54
54
|
/** Project a model (or plain object) onto plain data: declared fields plus the other values. */
|
|
55
55
|
project(e) {
|
|
56
|
-
return
|
|
56
|
+
return ce(this[se], e);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
function B(t) {
|
|
60
|
-
return new
|
|
60
|
+
return new it(t);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
return { description: n, item: t, label: e, type:
|
|
62
|
+
function ve(t, { label: e, description: n, value: r } = {}) {
|
|
63
|
+
return { description: n, item: t, label: e, type: P.LIST, value: r };
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
return
|
|
65
|
+
function We(t, e = "root") {
|
|
66
|
+
return oe(t, e);
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
return
|
|
68
|
+
function wt(t) {
|
|
69
|
+
return ae(t);
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
return
|
|
71
|
+
function Pt(t, e) {
|
|
72
|
+
return ce(t, e);
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
if (t instanceof
|
|
76
|
-
return t[
|
|
74
|
+
function oe(t, e) {
|
|
75
|
+
if (t instanceof it)
|
|
76
|
+
return t[se];
|
|
77
77
|
if (!t || typeof t != "object")
|
|
78
78
|
throw new TypeError(`Template field "${e}" must be an object definition.`);
|
|
79
79
|
const { description: n, label: r, type: i, value: s } = t;
|
|
80
80
|
if (s !== void 0 && typeof s != "function")
|
|
81
81
|
throw new TypeError(`Template field "${e}" value must be a function.`);
|
|
82
82
|
const o = { description: n, label: r, type: i, value: s };
|
|
83
|
-
if (i ===
|
|
84
|
-
o.fields = Object.entries(t.fields || {}).reduce((a, [
|
|
85
|
-
else if (i ===
|
|
86
|
-
o.item =
|
|
87
|
-
else if (!
|
|
83
|
+
if (i === P.OBJECT)
|
|
84
|
+
o.fields = Object.entries(t.fields || {}).reduce((a, [c, l]) => (It(c, e), a[c] = oe(l, `${e}.${c}`), a), {});
|
|
85
|
+
else if (i === P.LIST)
|
|
86
|
+
o.item = oe(t.item, `${e}[]`);
|
|
87
|
+
else if (!St.has(i))
|
|
88
88
|
throw new TypeError(`Template field "${e}" has unsupported type "${i}".`);
|
|
89
89
|
return Object.freeze(o);
|
|
90
90
|
}
|
|
91
|
-
function
|
|
92
|
-
if (!Q.test(t) || t.startsWith("__") ||
|
|
91
|
+
function It(t, e) {
|
|
92
|
+
if (!Q.test(t) || t.startsWith("__") || De.includes(t))
|
|
93
93
|
throw new TypeError(`Template field name "${e}.${t}" is not allowed.`);
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function ae(t) {
|
|
96
96
|
const e = { type: t.type };
|
|
97
|
-
return t.label && (e.label = t.label), t.description && (e.description = t.description), t.fields && (e.fields = Object.entries(t.fields).reduce((n, [r, i]) => (n[r] =
|
|
97
|
+
return t.label && (e.label = t.label), t.description && (e.description = t.description), t.fields && (e.fields = Object.entries(t.fields).reduce((n, [r, i]) => (n[r] = ae(i), n), {})), t.item && (e.item = ae(t.item)), e;
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
if (t.type ===
|
|
99
|
+
function ce(t, e) {
|
|
100
|
+
if (t.type === P.OBJECT) {
|
|
101
101
|
if (e === null || typeof e != "object")
|
|
102
102
|
return null;
|
|
103
|
-
const n =
|
|
104
|
-
return Object.entries(t.fields).reduce((r, [i, s]) => (r[i] =
|
|
103
|
+
const n = Ae(e, 0, /* @__PURE__ */ new WeakSet()) || {};
|
|
104
|
+
return Object.entries(t.fields).reduce((r, [i, s]) => (r[i] = ce(s, s.value ? s.value(e) : e[i]), r), n);
|
|
105
105
|
}
|
|
106
|
-
return t.type ===
|
|
106
|
+
return t.type === P.LIST ? Array.isArray(e) ? e.map((n) => ce(t.item, n)) : [] : e instanceof Date ? Number.isNaN(e.getTime()) ? null : e.getTime() : ["string", "number", "boolean"].includes(typeof e) ? typeof e == "number" && !Number.isFinite(e) ? null : e : null;
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function Ae(t, e, n) {
|
|
109
109
|
if (t instanceof Date)
|
|
110
110
|
return Number.isNaN(t.getTime()) ? null : t.getTime();
|
|
111
111
|
if (typeof t == "number")
|
|
112
112
|
return Number.isFinite(t) ? t : null;
|
|
113
113
|
if (typeof t == "string" || typeof t == "boolean" || t === null)
|
|
114
114
|
return t;
|
|
115
|
-
if (typeof t != "object" || e >=
|
|
115
|
+
if (typeof t != "object" || e >= Lt || n.has(t))
|
|
116
116
|
return null;
|
|
117
117
|
n.add(t);
|
|
118
118
|
try {
|
|
119
119
|
if (Array.isArray(t))
|
|
120
|
-
return t.map((i) => i === void 0 || typeof i == "function" || typeof i == "symbol" ? null :
|
|
120
|
+
return t.map((i) => i === void 0 || typeof i == "function" || typeof i == "symbol" ? null : Ae(i, e + 1, n));
|
|
121
121
|
const r = typeof t.toObject == "function" ? t.toObject() : t;
|
|
122
|
-
return Object.entries(r).reduce((i, [s, o]) => (o !== void 0 && typeof o != "function" && typeof o != "symbol" && typeof o != "bigint" && (i[s] =
|
|
122
|
+
return Object.entries(r).reduce((i, [s, o]) => (o !== void 0 && typeof o != "function" && typeof o != "symbol" && typeof o != "bigint" && (i[s] = Ae(o, e + 1, n)), i), {});
|
|
123
123
|
} finally {
|
|
124
124
|
n.delete(t);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
class
|
|
128
|
-
constructor({ contextCode: e, name: n, subjectType: r, roots: i, recipientRules: s = [], functionNames: o = [],
|
|
127
|
+
class Dt {
|
|
128
|
+
constructor({ contextCode: e, name: n, subjectType: r, roots: i, recipientRules: s = [], functionNames: o = [], includeTemplateDocumentReference: a = !1, loadData: c, sampleData: l } = {}) {
|
|
129
129
|
if (!e || typeof e != "string")
|
|
130
130
|
throw new TypeError("DataContext requires a contextCode.");
|
|
131
|
-
if (
|
|
131
|
+
if (c !== void 0 && typeof c != "function")
|
|
132
132
|
throw new TypeError(`DataContext ${e} loadData must be a function.`);
|
|
133
|
-
const
|
|
134
|
-
if (!Q.test(
|
|
135
|
-
throw new TypeError(`DataContext ${e} root name "${
|
|
136
|
-
return
|
|
133
|
+
const m = Object.entries(i || {}).reduce((u, [d, f]) => {
|
|
134
|
+
if (!Q.test(d) || d.startsWith("__") || De.includes(d))
|
|
135
|
+
throw new TypeError(`DataContext ${e} root name "${d}" is not allowed.`);
|
|
136
|
+
return u[d] = We(f, d), u;
|
|
137
137
|
}, {});
|
|
138
|
-
if (
|
|
138
|
+
if (a) {
|
|
139
|
+
if (Object.hasOwn(m, "template"))
|
|
140
|
+
throw new TypeError(`DataContext ${e} already declares a template root.`);
|
|
141
|
+
m.template = We({
|
|
142
|
+
fields: {
|
|
143
|
+
documentReference: { label: "Document reference", type: "string" }
|
|
144
|
+
},
|
|
145
|
+
label: "Template",
|
|
146
|
+
type: "object"
|
|
147
|
+
}, "template");
|
|
148
|
+
}
|
|
149
|
+
if (!Object.keys(m).length)
|
|
139
150
|
throw new TypeError(`DataContext ${e} requires at least one data root.`);
|
|
140
151
|
Object.defineProperties(this, {
|
|
141
|
-
_loadData: { enumerable: !1, value:
|
|
142
|
-
_rootNodes: { enumerable: !1, value: Object.freeze(
|
|
152
|
+
_loadData: { enumerable: !1, value: c },
|
|
153
|
+
_rootNodes: { enumerable: !1, value: Object.freeze(m) },
|
|
143
154
|
_sampleData: { enumerable: !1, value: l }
|
|
144
|
-
}), this.contextCode = e, this.functionNames = Object.freeze([...new Set(o)]), this.name = n || e, this.recipientRules = Object.freeze(s.map(({ recipientType:
|
|
145
|
-
if (!
|
|
155
|
+
}), this.contextCode = e, this.functionNames = Object.freeze([...new Set(o)]), this.includeTemplateDocumentReference = !!a, this.name = n || e, this.recipientRules = Object.freeze(s.map(({ recipientType: u, name: d, description: f }) => {
|
|
156
|
+
if (!u)
|
|
146
157
|
throw new TypeError(`DataContext ${e} recipient rules require recipientType.`);
|
|
147
|
-
return Object.freeze({ description:
|
|
158
|
+
return Object.freeze({ description: f, name: d || u, recipientType: u });
|
|
148
159
|
})), this.subjectType = r, Object.freeze(this);
|
|
149
160
|
}
|
|
150
161
|
get rootNames() {
|
|
@@ -155,15 +166,16 @@ class Pt {
|
|
|
155
166
|
return {
|
|
156
167
|
contextCode: this.contextCode,
|
|
157
168
|
functionNames: [...this.functionNames],
|
|
169
|
+
...this.includeTemplateDocumentReference ? { includeTemplateDocumentReference: !0 } : {},
|
|
158
170
|
name: this.name,
|
|
159
171
|
recipientRules: this.recipientRules.map((e) => ({ ...e })),
|
|
160
|
-
roots: Object.entries(this._rootNodes).reduce((e, [n, r]) => (e[n] =
|
|
172
|
+
roots: Object.entries(this._rootNodes).reduce((e, [n, r]) => (e[n] = wt(r), e), {}),
|
|
161
173
|
subjectType: this.subjectType
|
|
162
174
|
};
|
|
163
175
|
}
|
|
164
176
|
/** Project raw root models into the plain data a template renders with. */
|
|
165
177
|
project(e = {}) {
|
|
166
|
-
return Object.entries(this._rootNodes).reduce((n, [r, i]) => (n[r] =
|
|
178
|
+
return Object.entries(this._rootNodes).reduce((n, [r, i]) => (this.includeTemplateDocumentReference && r === "template" || (n[r] = Pt(i, e[r])), n), {});
|
|
167
179
|
}
|
|
168
180
|
/**
|
|
169
181
|
* Build template data for every recipient of a subject.
|
|
@@ -187,10 +199,10 @@ class Pt {
|
|
|
187
199
|
return this._sampleData ? structuredClone(this._sampleData) : null;
|
|
188
200
|
}
|
|
189
201
|
}
|
|
190
|
-
function
|
|
191
|
-
return new
|
|
202
|
+
function pe(t) {
|
|
203
|
+
return new Dt(t);
|
|
192
204
|
}
|
|
193
|
-
function
|
|
205
|
+
function J(t) {
|
|
194
206
|
return t ? typeof t.describe == "function" ? t.describe() : t : null;
|
|
195
207
|
}
|
|
196
208
|
const U = Object.freeze({
|
|
@@ -200,10 +212,10 @@ const U = Object.freeze({
|
|
|
200
212
|
NUMBER: "number",
|
|
201
213
|
OBJECT: "object",
|
|
202
214
|
STRING: "string"
|
|
203
|
-
}),
|
|
204
|
-
let
|
|
205
|
-
function
|
|
206
|
-
if (!
|
|
215
|
+
}), vt = new Set(Object.values(U)), jt = /^__[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/, V = /* @__PURE__ */ new Map();
|
|
216
|
+
let je = 0;
|
|
217
|
+
function Bt({ name: t, fn: e, signature: n = [], trustedHtml: r = !1, label: i, description: s } = {}) {
|
|
218
|
+
if (!jt.test(t || ""))
|
|
207
219
|
throw new TypeError(`Template function name "${t}" must be "__" followed by snake_case letters and digits.`);
|
|
208
220
|
if (typeof e != "function")
|
|
209
221
|
throw new TypeError(`Template function ${t} requires fn.`);
|
|
@@ -211,13 +223,13 @@ function Dt({ name: t, fn: e, signature: n = [], trustedHtml: r = !1, label: i,
|
|
|
211
223
|
throw new Error(`Template function ${t} is already registered.`);
|
|
212
224
|
if (!n.length)
|
|
213
225
|
throw new TypeError(`Template function ${t} requires a signature with at least the piped value.`);
|
|
214
|
-
const o = n.map((a,
|
|
215
|
-
const
|
|
216
|
-
if (!
|
|
217
|
-
throw new TypeError(`Template function ${t} argument #${
|
|
226
|
+
const o = n.map((a, c) => {
|
|
227
|
+
const l = (a == null ? void 0 : a.types) || [];
|
|
228
|
+
if (!l.length || l.some((m) => !vt.has(m)))
|
|
229
|
+
throw new TypeError(`Template function ${t} argument #${c + 1} has invalid types.`);
|
|
218
230
|
return Object.freeze({
|
|
219
231
|
...a.optional ? { optional: !0 } : {},
|
|
220
|
-
types: Object.freeze([...
|
|
232
|
+
types: Object.freeze([...l]),
|
|
221
233
|
...a.variadic ? { variadic: !0 } : {}
|
|
222
234
|
});
|
|
223
235
|
});
|
|
@@ -229,41 +241,41 @@ function Dt({ name: t, fn: e, signature: n = [], trustedHtml: r = !1, label: i,
|
|
|
229
241
|
signature: Object.freeze(o),
|
|
230
242
|
trustedHtml: !!r
|
|
231
243
|
}),
|
|
232
|
-
filter:
|
|
233
|
-
})),
|
|
244
|
+
filter: $t(t, e, o)
|
|
245
|
+
})), je += 1;
|
|
234
246
|
}
|
|
235
|
-
function
|
|
247
|
+
function me() {
|
|
236
248
|
return [...V.values()].map(({ descriptor: t }) => ({
|
|
237
249
|
...t,
|
|
238
250
|
signature: t.signature.map((e) => ({ ...e, types: [...e.types] }))
|
|
239
251
|
}));
|
|
240
252
|
}
|
|
241
|
-
function
|
|
253
|
+
function Or(t) {
|
|
242
254
|
var e;
|
|
243
255
|
return ((e = V.get(t)) == null ? void 0 : e.descriptor) || null;
|
|
244
256
|
}
|
|
245
|
-
function
|
|
257
|
+
function xt() {
|
|
246
258
|
return {
|
|
247
259
|
filters: [...V.values()].map(({ descriptor: t, filter: e }) => ({ handler: e, name: t.name, raw: t.trustedHtml })),
|
|
248
|
-
version:
|
|
260
|
+
version: je
|
|
249
261
|
};
|
|
250
262
|
}
|
|
251
|
-
function
|
|
252
|
-
V.clear(),
|
|
263
|
+
function Cr() {
|
|
264
|
+
V.clear(), je += 1;
|
|
253
265
|
}
|
|
254
|
-
function
|
|
266
|
+
function $t(t, e, n) {
|
|
255
267
|
return (...r) => {
|
|
256
268
|
const i = r.map((o) => o === void 0 ? null : o);
|
|
257
269
|
i.forEach((o, a) => {
|
|
258
|
-
const
|
|
259
|
-
if (o !== null &&
|
|
260
|
-
throw new TypeError(`${t} argument #${a + 1} must be ${
|
|
270
|
+
const c = n[Math.min(a, n.length - 1)];
|
|
271
|
+
if (o !== null && c && !c.types.some((l) => Mt(o, l)))
|
|
272
|
+
throw new TypeError(`${t} argument #${a + 1} must be ${c.types.join(" or ")}.`);
|
|
261
273
|
});
|
|
262
274
|
const s = e(...i);
|
|
263
275
|
return s === void 0 ? null : s;
|
|
264
276
|
};
|
|
265
277
|
}
|
|
266
|
-
function
|
|
278
|
+
function Mt(t, e) {
|
|
267
279
|
switch (e) {
|
|
268
280
|
case U.ANY:
|
|
269
281
|
return !0;
|
|
@@ -288,10 +300,10 @@ function O({ code: t, message: e, severity: n = X.ERROR, ...r } = {}) {
|
|
|
288
300
|
function K(t = []) {
|
|
289
301
|
return t.some((e) => e.severity === X.ERROR);
|
|
290
302
|
}
|
|
291
|
-
class
|
|
303
|
+
class ee extends Error {
|
|
292
304
|
constructor(e = [], n) {
|
|
293
305
|
const r = e.filter((i) => i.severity === X.ERROR);
|
|
294
|
-
super(n ||
|
|
306
|
+
super(n || Ut(r)), this.name = "TemplateSyntaxError", this.code = "TEMPLATE_SYNTAX_INVALID", this.issues = e;
|
|
295
307
|
}
|
|
296
308
|
}
|
|
297
309
|
class j extends Error {
|
|
@@ -299,38 +311,38 @@ class j extends Error {
|
|
|
299
311
|
super(e || "Template rendering failed.", i ? { cause: i } : void 0), this.name = "TemplateRenderError", this.code = "TEMPLATE_RENDER_FAILED", this.partCode = n, this.source = r;
|
|
300
312
|
}
|
|
301
313
|
}
|
|
302
|
-
function
|
|
314
|
+
function Ut(t) {
|
|
303
315
|
if (!t.length)
|
|
304
316
|
return "Template is invalid.";
|
|
305
317
|
const [e] = t, n = e.partCode ? ` (${e.partCode}${e.line ? `:${e.line}:${e.column}` : ""})` : "", r = t.length > 1 ? ` and ${t.length - 1} more issue(s)` : "";
|
|
306
318
|
return `${e.code}: ${e.message}${n}${r}`;
|
|
307
319
|
}
|
|
308
|
-
const
|
|
309
|
-
function
|
|
310
|
-
return `<div ${
|
|
320
|
+
const st = "data-qw-layout", kt = `<([a-z][a-z0-9-]*)\\b[^>]*\\s${st}\\s*=\\s*"([^"]*)"[^>]*>\\s*</\\1\\s*>`, zt = "PUBLISHED", ot = () => new RegExp(kt, "gi"), Vt = (t) => typeof (t == null ? void 0 : t.describe) == "function" ? t.describe() : t;
|
|
321
|
+
function Ar(t) {
|
|
322
|
+
return `<div ${st}="${t}"></div>`;
|
|
311
323
|
}
|
|
312
|
-
function
|
|
313
|
-
return [...new Set([...String(t || "").matchAll(
|
|
324
|
+
function Be(t) {
|
|
325
|
+
return [...new Set([...String(t || "").matchAll(ot())].map(([, , e]) => e))];
|
|
314
326
|
}
|
|
315
|
-
function
|
|
316
|
-
return e && t.map(
|
|
327
|
+
function at({ layouts: t = [], layoutCode: e } = {}) {
|
|
328
|
+
return e && t.map(Vt).filter((n) => (n == null ? void 0 : n.layoutCode) === e && n.stateCode === zt).sort((n, r) => r.version - n.version)[0] || null;
|
|
317
329
|
}
|
|
318
|
-
function
|
|
330
|
+
function Ft({ html: t, layouts: e = [] } = {}) {
|
|
319
331
|
const n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
320
|
-
return { html: String(t || "").replace(
|
|
321
|
-
const
|
|
322
|
-
return
|
|
332
|
+
return { html: String(t || "").replace(ot(), (s, o, a) => {
|
|
333
|
+
const c = at({ layoutCode: a, layouts: e });
|
|
334
|
+
return c ? (n.add(`${c.layoutCode}@${c.version}`), c.html || "") : (r.add(a), s);
|
|
323
335
|
}), layoutRefs: [...n], missingLayoutCodes: [...r] };
|
|
324
336
|
}
|
|
325
|
-
function
|
|
326
|
-
return String(t || "").trim() ?
|
|
337
|
+
function ct(t) {
|
|
338
|
+
return String(t || "").trim() ? Be(t).map((e) => O({ code: y.LAYOUT_NOT_ALLOWED, layoutCode: e, message: `Layout ${e} cannot be placed inside another layout.`, partCode: "layout" })) : [O({ code: y.LAYOUT_EMPTY, message: "The layout is empty.", partCode: "layout" })];
|
|
327
339
|
}
|
|
328
|
-
const
|
|
340
|
+
const lt = Object.freeze(["#", "case", "comment", "for", "if", "unless"]), Re = Object.freeze(["assign", "capture"]), ye = (t = !1) => ({ ...t ? { optional: t } : {}, types: ["any"] }), g = (t, e = !1) => ({ ...e ? { optional: e } : {}, types: t }), ut = Object.freeze([
|
|
329
341
|
{ description: 'Format a timestamp (milliseconds) or date text, e.g. date: "%Y-%m-%d". Dates are UTC unless a time zone is given.', label: "date", name: "date", signature: [g(["number", "string"]), g(["string"], !0), g(["number", "string"], !0)] },
|
|
330
|
-
{ description: "The argument when the value is nil, false or empty.", name: "default", signature: [
|
|
342
|
+
{ description: "The argument when the value is nil, false or empty.", name: "default", signature: [ye(), ye()] },
|
|
331
343
|
{ description: "Join list items with a separator.", label: "joined", name: "join", signature: [g(["array"]), g(["string"], !0)] },
|
|
332
344
|
{ description: "The given field of every list item.", name: "map", signature: [g(["array"]), g(["string"])] },
|
|
333
|
-
{ description: "List items whose field is truthy or equals a value.", name: "where", signature: [g(["array"]), g(["string"]),
|
|
345
|
+
{ description: "List items whose field is truthy or equals a value.", name: "where", signature: [g(["array"]), g(["string"]), ye(!0)] },
|
|
334
346
|
{ description: 'List items for which an expression is true, e.g. where_exp: "line", "line.qty > 0".', name: "where_exp", signature: [g(["array"]), g(["string"]), g(["string"])] },
|
|
335
347
|
{ description: "The first list item.", label: "first", name: "first", signature: [g(["array"])] },
|
|
336
348
|
{ description: "Number of list items or characters.", label: "count", name: "size", signature: [g(["array", "string"])] },
|
|
@@ -343,7 +355,7 @@ const st = Object.freeze(["#", "case", "comment", "for", "if", "unless"]), Ae =
|
|
|
343
355
|
{ description: "Multiply by a number.", name: "times", signature: [g(["number"]), g(["number"])] },
|
|
344
356
|
{ description: "Divide by a number.", name: "divided_by", signature: [g(["number"]), g(["number"])] },
|
|
345
357
|
{ description: "Round to a number of decimals.", label: "rounded", name: "round", signature: [g(["number"]), g(["number"], !0)] }
|
|
346
|
-
].map((t) => Object.freeze({ ...t, builtin: !0, signature: Object.freeze(t.signature.map(Object.freeze)) }))),
|
|
358
|
+
].map((t) => Object.freeze({ ...t, builtin: !0, signature: Object.freeze(t.signature.map(Object.freeze)) }))), Kt = new Set(ut.map(({ name: t }) => t)), dt = Object.freeze({
|
|
347
359
|
""": '"',
|
|
348
360
|
"'": "'",
|
|
349
361
|
"<": "<",
|
|
@@ -355,15 +367,15 @@ const st = Object.freeze(["#", "case", "comment", "for", "if", "unless"]), Ae =
|
|
|
355
367
|
"<": "<",
|
|
356
368
|
" ": " ",
|
|
357
369
|
""": '"'
|
|
358
|
-
}),
|
|
359
|
-
function
|
|
360
|
-
return String(t ?? "").replace(
|
|
370
|
+
}), qt = /\{\{[\s\S]*?\}\}|\{%[\s\S]*?%\}/g;
|
|
371
|
+
function Gt(t) {
|
|
372
|
+
return String(t ?? "").replace(qt, (e) => e.replace(/&(?:#34|#39|#60|#62|#x27|amp|apos|gt|lt|nbsp|quot);/g, (n) => dt[n]).replace(/[\u2018\u2019]/g, "'").replace(/[\u201C\u201D]/g, '"').replace(/\xA0/g, " ").replace(/[\u200B-\u200D\uFEFF]/g, ""));
|
|
361
373
|
}
|
|
362
|
-
function
|
|
363
|
-
return String(t ?? "").replace(/&(?:#34|#39|#60|#62|#x27|amp|apos|gt|lt|nbsp|quot);/g, (e) =>
|
|
374
|
+
function He(t) {
|
|
375
|
+
return String(t ?? "").replace(/&(?:#34|#39|#60|#62|#x27|amp|apos|gt|lt|nbsp|quot);/g, (e) => dt[e]);
|
|
364
376
|
}
|
|
365
|
-
function
|
|
366
|
-
const r = new
|
|
377
|
+
function pt({ escape: t = !1, limits: e = {}, tags: n } = {}) {
|
|
378
|
+
const r = new At({
|
|
367
379
|
cache: !1,
|
|
368
380
|
dynamicPartials: !1,
|
|
369
381
|
jsTruthy: !1,
|
|
@@ -375,7 +387,7 @@ function ct({ escape: t = !1, limits: e = {}, tags: n } = {}) {
|
|
|
375
387
|
...e
|
|
376
388
|
});
|
|
377
389
|
Object.keys(r.filters).forEach((s) => {
|
|
378
|
-
|
|
390
|
+
Kt.has(s) || r.unregisterFilter(s);
|
|
379
391
|
});
|
|
380
392
|
const i = r.filters.date;
|
|
381
393
|
if (r.registerFilter("date", function(s, ...o) {
|
|
@@ -388,28 +400,28 @@ function ct({ escape: t = !1, limits: e = {}, tags: n } = {}) {
|
|
|
388
400
|
}
|
|
389
401
|
return r;
|
|
390
402
|
}
|
|
391
|
-
const k = "data-qw-block",
|
|
392
|
-
function
|
|
393
|
-
const r =
|
|
394
|
-
let
|
|
395
|
-
for (;
|
|
396
|
-
a.push(
|
|
397
|
-
let
|
|
403
|
+
const k = "data-qw-block", Ne = "data-qw-params", Wt = /^([A-Z][A-Z0-9_]*)@([1-9]\d*)$/, Ht = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "source", "track", "wbr"]), Yt = pt();
|
|
404
|
+
function te(t, { partCode: e, allowBlocks: n = !0 } = {}) {
|
|
405
|
+
const r = Gt(typeof t == "string" ? t : ""), i = nn(r, e), s = [], o = [], a = [];
|
|
406
|
+
let c = 0, l = le(r, c);
|
|
407
|
+
for (; l; )
|
|
408
|
+
a.push(l), c = l.end, l.issue ? s.push(O({ ...l.issue, ...i(l.start) })) : n ? o.push({ ...l.node, end: l.end, location: i(l.start), start: l.start }) : s.push(O({ blockRef: l.node.blockRef, code: y.BLOCK_NOT_ALLOWED, message: "Block instances are not allowed here.", ...i(l.start) })), l = le(r, c);
|
|
409
|
+
let m = [];
|
|
398
410
|
try {
|
|
399
|
-
|
|
411
|
+
m = Yt.parse(Zt(r, a));
|
|
400
412
|
} catch (u) {
|
|
401
|
-
s.push(
|
|
413
|
+
s.push(Qt(u, i));
|
|
402
414
|
}
|
|
403
|
-
return { blockRefs: [...new Set(o.map(({ blockRef: u }) => u))], blocks: o, issues: s, locate: i, templates:
|
|
415
|
+
return { blockRefs: [...new Set(o.map(({ blockRef: u }) => u))], blocks: o, issues: s, locate: i, templates: m, text: r };
|
|
404
416
|
}
|
|
405
|
-
function
|
|
417
|
+
function Xt(t) {
|
|
406
418
|
const e = typeof t == "string" ? t : "", n = /* @__PURE__ */ new Set();
|
|
407
|
-
let r =
|
|
419
|
+
let r = le(e, 0);
|
|
408
420
|
for (; r; )
|
|
409
|
-
r.node && n.add(r.node.blockRef), r =
|
|
421
|
+
r.node && n.add(r.node.blockRef), r = le(e, r.end);
|
|
410
422
|
return [...n];
|
|
411
423
|
}
|
|
412
|
-
function
|
|
424
|
+
function Qt(t, e, n = 0) {
|
|
413
425
|
var i;
|
|
414
426
|
if (!(t != null && t.token) && !/^(?:Parse|Tokenization|Liquid)Error$/.test((t == null ? void 0 : t.name) || ""))
|
|
415
427
|
throw t;
|
|
@@ -420,18 +432,18 @@ function Ht(t, e, n = 0) {
|
|
|
420
432
|
...e ? e(n + (((i = t.token) == null ? void 0 : i.begin) ?? 0)) : {}
|
|
421
433
|
});
|
|
422
434
|
}
|
|
423
|
-
function
|
|
424
|
-
const e =
|
|
435
|
+
function Jt(t) {
|
|
436
|
+
const e = Wt.exec(typeof t == "string" ? t.trim() : "");
|
|
425
437
|
return e ? { blockCode: e[1], version: Number(e[2]) } : null;
|
|
426
438
|
}
|
|
427
|
-
function
|
|
439
|
+
function Se({ blockCode: t, version: e } = {}) {
|
|
428
440
|
return `${t}@${e}`;
|
|
429
441
|
}
|
|
430
|
-
function
|
|
442
|
+
function Rr({ blockCode: t, version: e, params: n = {}, tagName: r = "div" } = {}) {
|
|
431
443
|
const i = JSON.stringify(n || {}).replace(/&/g, "&").replace(/'/g, "'");
|
|
432
|
-
return `<${r} ${k}="${
|
|
444
|
+
return `<${r} ${k}="${Se({ blockCode: t, version: e })}" ${Ne}='${i}'></${r}>`;
|
|
433
445
|
}
|
|
434
|
-
function
|
|
446
|
+
function Zt(t, e) {
|
|
435
447
|
if (!e.length)
|
|
436
448
|
return t;
|
|
437
449
|
let n = "", r = 0;
|
|
@@ -439,55 +451,55 @@ function Xt(t, e) {
|
|
|
439
451
|
n += t.slice(r, i) + t.slice(i, s).replace(/[^\n]/g, " "), r = s;
|
|
440
452
|
}), n + t.slice(r);
|
|
441
453
|
}
|
|
442
|
-
function
|
|
454
|
+
function le(t, e) {
|
|
443
455
|
let n = e;
|
|
444
456
|
for (; n < t.length; ) {
|
|
445
457
|
const r = t.indexOf(k, n);
|
|
446
458
|
if (r === -1)
|
|
447
459
|
return null;
|
|
448
|
-
const i = t.lastIndexOf("<", r), s = i >= e ?
|
|
460
|
+
const i = t.lastIndexOf("<", r), s = i >= e ? en(t, i) : null;
|
|
449
461
|
if (!s || s.end <= r || !Object.hasOwn(s.attributes, k)) {
|
|
450
462
|
n = r + k.length;
|
|
451
463
|
continue;
|
|
452
464
|
}
|
|
453
|
-
const o = s.selfClosing ||
|
|
465
|
+
const o = s.selfClosing || Ht.has(s.name) ? s.end : tn(t, s.name, s.end);
|
|
454
466
|
if (o === -1)
|
|
455
467
|
return {
|
|
456
468
|
end: t.length,
|
|
457
469
|
issue: { code: y.BLOCK_ELEMENT_INVALID, message: `Block element <${s.name}> is not closed.` },
|
|
458
470
|
start: i
|
|
459
471
|
};
|
|
460
|
-
const a =
|
|
472
|
+
const a = Jt(He(s.attributes[k]));
|
|
461
473
|
if (!a)
|
|
462
474
|
return {
|
|
463
475
|
end: o,
|
|
464
476
|
issue: { code: y.BLOCK_ELEMENT_INVALID, message: `Block reference "${s.attributes[k]}" must look like BLOCK_CODE@1.` },
|
|
465
477
|
start: i
|
|
466
478
|
};
|
|
467
|
-
let
|
|
468
|
-
const
|
|
469
|
-
if (
|
|
479
|
+
let c = {};
|
|
480
|
+
const l = s.attributes[Ne];
|
|
481
|
+
if (l) {
|
|
470
482
|
try {
|
|
471
|
-
|
|
483
|
+
c = JSON.parse(He(l));
|
|
472
484
|
} catch {
|
|
473
|
-
|
|
485
|
+
c = null;
|
|
474
486
|
}
|
|
475
|
-
if (!
|
|
487
|
+
if (!c || typeof c != "object" || Array.isArray(c))
|
|
476
488
|
return {
|
|
477
489
|
end: o,
|
|
478
|
-
issue: { blockRef:
|
|
490
|
+
issue: { blockRef: Se(a), code: y.BLOCK_PARAMS_INVALID, message: `${Ne} must be a JSON object.` },
|
|
479
491
|
start: i
|
|
480
492
|
};
|
|
481
493
|
}
|
|
482
494
|
return {
|
|
483
495
|
end: o,
|
|
484
|
-
node: { blockCode: a.blockCode, blockRef:
|
|
496
|
+
node: { blockCode: a.blockCode, blockRef: Se(a), params: c, type: "Block", version: a.version },
|
|
485
497
|
start: i
|
|
486
498
|
};
|
|
487
499
|
}
|
|
488
500
|
return null;
|
|
489
501
|
}
|
|
490
|
-
function
|
|
502
|
+
function en(t, e) {
|
|
491
503
|
const n = /^<([A-Z][\w-]*)/i.exec(t.slice(e));
|
|
492
504
|
if (!n)
|
|
493
505
|
return null;
|
|
@@ -504,7 +516,7 @@ function Qt(t, e) {
|
|
|
504
516
|
}
|
|
505
517
|
return null;
|
|
506
518
|
}
|
|
507
|
-
function
|
|
519
|
+
function tn(t, e, n) {
|
|
508
520
|
const r = new RegExp(`<(/?)${e}(?=[\\s/>])[^>]*>`, "gi");
|
|
509
521
|
r.lastIndex = n;
|
|
510
522
|
let i = 1, s = r.exec(t);
|
|
@@ -517,7 +529,7 @@ function Jt(t, e, n) {
|
|
|
517
529
|
}
|
|
518
530
|
return -1;
|
|
519
531
|
}
|
|
520
|
-
function
|
|
532
|
+
function nn(t, e) {
|
|
521
533
|
const n = [0];
|
|
522
534
|
for (let r = 0; r < t.length; r += 1)
|
|
523
535
|
t[r] === `
|
|
@@ -534,11 +546,11 @@ function Zt(t, e) {
|
|
|
534
546
|
};
|
|
535
547
|
};
|
|
536
548
|
}
|
|
537
|
-
const
|
|
538
|
-
class
|
|
549
|
+
const rn = ["active", "created", "creator", "deleted", "modified", "owner", "revision"], sn = ["contextCode", "documentReference", "name", "templateCode", "templateRevision", "templateSyntaxVersion"], on = ["contextCode", "name", "templateSyntaxVersion"];
|
|
550
|
+
class an extends Ot {
|
|
539
551
|
constructor(e = {}) {
|
|
540
552
|
var n;
|
|
541
|
-
e = e || {}, super(e), this._type = e._type || "Template", this.contextCode = e.contextCode, this.name = e.name, this.partContent =
|
|
553
|
+
e = e || {}, super(e), this._type = e._type || "Template", this.contextCode = e.contextCode, this.documentReference = Ye(e.documentReference), this.name = e.name, this.partContent = Xe(e.partContent), this.templateCode = e.templateCode, this.templateRevision = Number(e.templateRevision || ((n = e.meta) == null ? void 0 : n.revision) || 1), this.templateSyntaxVersion = Number(e.templateSyntaxVersion || Ie);
|
|
542
554
|
}
|
|
543
555
|
static get _classname() {
|
|
544
556
|
return "Template";
|
|
@@ -555,7 +567,7 @@ class rn extends Et {
|
|
|
555
567
|
return ((e = this.kind) == null ? void 0 : e.partDefinitions) || [];
|
|
556
568
|
}
|
|
557
569
|
get isValid() {
|
|
558
|
-
return super.isValid && !!this.templateCode && !!this.contextCode && Number.isInteger(this.templateRevision) && this.templateRevision > 0;
|
|
570
|
+
return super.isValid && !!this.templateCode && !!this.contextCode && Number.isInteger(this.templateRevision) && this.templateRevision > 0 && (this.documentReference == null || typeof this.documentReference == "string" && this.documentReference.length <= 120 && !/[\r\n]/.test(this.documentReference));
|
|
559
571
|
}
|
|
560
572
|
getCode() {
|
|
561
573
|
return this.templateCode;
|
|
@@ -577,12 +589,12 @@ class rn extends Et {
|
|
|
577
589
|
getBlockRefs() {
|
|
578
590
|
const e = /* @__PURE__ */ new Set();
|
|
579
591
|
return this.getContentParts().forEach(({ content: n }) => {
|
|
580
|
-
|
|
592
|
+
Xt(n).forEach((r) => e.add(r));
|
|
581
593
|
}), [...e];
|
|
582
594
|
}
|
|
583
595
|
/** Codes of the email layouts placed in the parts. */
|
|
584
596
|
getLayoutCodes() {
|
|
585
|
-
return [...new Set(this.getContentParts().flatMap(({ content: e }) =>
|
|
597
|
+
return [...new Set(this.getContentParts().flatMap(({ content: e }) => Be(e)))];
|
|
586
598
|
}
|
|
587
599
|
setPartContent(e, n) {
|
|
588
600
|
if (!this.constructor.partDefinitions.some((r) => r.partCode === e))
|
|
@@ -594,7 +606,7 @@ class rn extends Et {
|
|
|
594
606
|
* part is unchanged and an explicit null clears it.
|
|
595
607
|
*/
|
|
596
608
|
update(e = {}) {
|
|
597
|
-
return
|
|
609
|
+
return Object.hasOwn(e, "documentReference") && (this.documentReference = Ye(e.documentReference)), on.forEach((n) => {
|
|
598
610
|
Object.hasOwn(e, n) && (this[n] = n === "templateSyntaxVersion" ? Number(e[n]) : e[n]);
|
|
599
611
|
}), e.partContent && typeof e.partContent == "object" && Object.entries(e.partContent).forEach(([n, r]) => {
|
|
600
612
|
this.setPartContent(n, r);
|
|
@@ -606,29 +618,32 @@ class rn extends Et {
|
|
|
606
618
|
toObject() {
|
|
607
619
|
const e = {
|
|
608
620
|
_type: this._type,
|
|
609
|
-
meta:
|
|
610
|
-
metadata:
|
|
611
|
-
partContent:
|
|
612
|
-
remarks:
|
|
621
|
+
meta: L(this.meta, rn),
|
|
622
|
+
metadata: qe(this.metadata),
|
|
623
|
+
partContent: Xe(this.partContent),
|
|
624
|
+
remarks: qe(this.remarks),
|
|
613
625
|
tenantCode: this.tenantCode,
|
|
614
|
-
...
|
|
626
|
+
...L(this, sn)
|
|
615
627
|
};
|
|
616
628
|
return typeof this.id < "u" && (e.id = this.id), e;
|
|
617
629
|
}
|
|
618
630
|
}
|
|
619
|
-
function
|
|
631
|
+
function Ye(t) {
|
|
632
|
+
return typeof t == "string" ? t.trim() || null : t;
|
|
633
|
+
}
|
|
634
|
+
function Xe(t) {
|
|
620
635
|
return !t || typeof t != "object" ? {} : Object.entries(t).reduce((e, [n, r]) => (typeof r == "string" && (e[n] = r), e), {});
|
|
621
636
|
}
|
|
622
637
|
const z = Object.freeze({
|
|
623
638
|
DEPRECATED: "DEPRECATED",
|
|
624
639
|
DRAFT: "DRAFT",
|
|
625
640
|
PUBLISHED: "PUBLISHED"
|
|
626
|
-
}),
|
|
641
|
+
}), cn = new Set(Object.values(z)), ln = Object.freeze({
|
|
627
642
|
DEPRECATED: /* @__PURE__ */ new Set(),
|
|
628
643
|
DRAFT: /* @__PURE__ */ new Set(["PUBLISHED"]),
|
|
629
644
|
PUBLISHED: /* @__PURE__ */ new Set(["DEPRECATED"])
|
|
630
645
|
});
|
|
631
|
-
class
|
|
646
|
+
class Le extends Ct {
|
|
632
647
|
constructor(e = {}) {
|
|
633
648
|
super(e), this._setPublicationState(e.publication);
|
|
634
649
|
}
|
|
@@ -647,7 +662,7 @@ class Se extends yt {
|
|
|
647
662
|
canTransition(e, n) {
|
|
648
663
|
var i, s;
|
|
649
664
|
const r = (i = this.getState(e)) == null ? void 0 : i.stateCode;
|
|
650
|
-
return e === "publication" && !!((s =
|
|
665
|
+
return e === "publication" && !!((s = ln[r]) != null && s.has(n));
|
|
651
666
|
}
|
|
652
667
|
transition(e, { actionRevision: n, modified: r = Date.now(), stateCode: i } = {}) {
|
|
653
668
|
var s;
|
|
@@ -656,7 +671,7 @@ class Se extends yt {
|
|
|
656
671
|
return this._setPublicationState({ actionRevision: n, modified: r, stateCode: i });
|
|
657
672
|
}
|
|
658
673
|
_setPublicationState(e) {
|
|
659
|
-
if (!
|
|
674
|
+
if (!cn.has(e == null ? void 0 : e.stateCode))
|
|
660
675
|
throw new TypeError(`Invalid ${this.constructor.entityType} lifecycle state for publication.`);
|
|
661
676
|
return this._setState("publication", e);
|
|
662
677
|
}
|
|
@@ -666,40 +681,40 @@ const R = Object.freeze({
|
|
|
666
681
|
MULTI_SELECT: "multiSelect",
|
|
667
682
|
SELECT: "select",
|
|
668
683
|
TEXT: "text"
|
|
669
|
-
}),
|
|
670
|
-
function
|
|
684
|
+
}), un = new Set(Object.values(R)), Qe = /* @__PURE__ */ new Set([R.MULTI_SELECT, R.SELECT]);
|
|
685
|
+
function Z(t = []) {
|
|
671
686
|
const e = [], n = /* @__PURE__ */ new Set();
|
|
672
687
|
return { definitions: (Array.isArray(t) ? t : []).map((i, s) => {
|
|
673
|
-
const { paramCode: o, type: a, label:
|
|
674
|
-
return !Q.test(o || "") || o.startsWith("__") ? e.push(`Param #${s + 1} has an invalid paramCode "${o}".`) : n.has(o) && e.push(`Param "${o}" is declared twice.`), n.add(o),
|
|
675
|
-
...
|
|
688
|
+
const { paramCode: o, type: a, label: c, description: l, required: m = !1, options: u = [] } = i || {};
|
|
689
|
+
return !Q.test(o || "") || o.startsWith("__") ? e.push(`Param #${s + 1} has an invalid paramCode "${o}".`) : n.has(o) && e.push(`Param "${o}" is declared twice.`), n.add(o), un.has(a) || e.push(`Param "${o}" has unsupported type "${a}".`), Qe.has(a) && (!Array.isArray(u) || !u.length ? e.push(`Param "${o}" requires options.`) : u.some((d) => !Q.test(String((d == null ? void 0 : d.value) ?? ""))) && e.push(`Param "${o}" option values must match [A-Za-z_]\\w*.`)), {
|
|
690
|
+
...l ? { description: l } : {},
|
|
676
691
|
..."default" in (i || {}) ? { default: i.default } : {},
|
|
677
|
-
label:
|
|
678
|
-
...
|
|
692
|
+
label: c || o,
|
|
693
|
+
...Qe.has(a) ? { options: u.map(({ value: d, label: f }) => ({ label: f || d, value: d })) } : {},
|
|
679
694
|
paramCode: o,
|
|
680
|
-
required: !!
|
|
695
|
+
required: !!m,
|
|
681
696
|
type: a
|
|
682
697
|
};
|
|
683
698
|
}), errors: e };
|
|
684
699
|
}
|
|
685
|
-
function
|
|
700
|
+
function mt(t = [], e = {}) {
|
|
686
701
|
const n = [], r = e && typeof e == "object" ? e : {}, i = new Set(t.map(({ paramCode: o }) => o));
|
|
687
702
|
Object.keys(r).forEach((o) => {
|
|
688
703
|
i.has(o) || n.push(`Unknown param "${o}".`);
|
|
689
704
|
});
|
|
690
705
|
const s = t.reduce((o, a) => {
|
|
691
|
-
const { paramCode:
|
|
706
|
+
const { paramCode: c, type: l, required: m } = a, u = Object.hasOwn(r, c) ? r[c] : a.default;
|
|
692
707
|
if (u == null || u === "")
|
|
693
|
-
return
|
|
694
|
-
const
|
|
695
|
-
return
|
|
708
|
+
return m && n.push(`Param "${c}" is required.`), o[c] = l === R.MULTI_SELECT ? [] : l === R.BOOLEAN ? !1 : null, o;
|
|
709
|
+
const d = pn(a, u);
|
|
710
|
+
return d && n.push(d), o[c] = u, o;
|
|
696
711
|
}, {});
|
|
697
712
|
return { errors: n, values: s };
|
|
698
713
|
}
|
|
699
|
-
function
|
|
714
|
+
function dn(t = [], e = {}) {
|
|
700
715
|
return t.reduce((n, { paramCode: r, type: i }) => (i === R.MULTI_SELECT ? n[r] = (Array.isArray(e[r]) ? e[r] : []).reduce((s, o) => (s[o] = !0, s), {}) : n[r] = e[r] ?? null, n), {});
|
|
701
716
|
}
|
|
702
|
-
function
|
|
717
|
+
function xe(t = []) {
|
|
703
718
|
return {
|
|
704
719
|
fields: t.reduce((e, { paramCode: n, type: r, label: i, options: s }) => (r === R.MULTI_SELECT ? e[n] = {
|
|
705
720
|
fields: s.reduce((o, a) => (o[a.value] = { label: a.label, type: "boolean" }, o), {}),
|
|
@@ -709,7 +724,7 @@ function Be(t = []) {
|
|
|
709
724
|
type: "object"
|
|
710
725
|
};
|
|
711
726
|
}
|
|
712
|
-
function
|
|
727
|
+
function pn({ paramCode: t, type: e, options: n = [] }, r) {
|
|
713
728
|
const i = new Set(n.map((s) => s.value));
|
|
714
729
|
switch (e) {
|
|
715
730
|
case R.BOOLEAN:
|
|
@@ -724,22 +739,23 @@ function ln({ paramCode: t, type: e, options: n = [] }, r) {
|
|
|
724
739
|
return null;
|
|
725
740
|
}
|
|
726
741
|
}
|
|
727
|
-
const
|
|
742
|
+
const $e = Object.freeze({
|
|
728
743
|
EMAIL: "EMAIL"
|
|
729
744
|
}), x = Object.freeze({
|
|
730
745
|
TEXT_HTML: "text/html",
|
|
731
746
|
TEXT_PLAIN: "text/plain"
|
|
732
|
-
}),
|
|
747
|
+
}), I = Object.freeze({
|
|
733
748
|
MAILBOX: "mailbox",
|
|
734
749
|
MAILBOX_LIST: "mailboxList",
|
|
735
750
|
TEXT: "text"
|
|
736
|
-
}),
|
|
751
|
+
}), Me = Object.freeze({
|
|
737
752
|
fieldDefinitions: Object.freeze([
|
|
738
|
-
Object.freeze({
|
|
739
|
-
Object.freeze({ emailExpression: !1, fieldCode: "
|
|
740
|
-
Object.freeze({ emailExpression: !
|
|
741
|
-
Object.freeze({ emailExpression: !0, fieldCode: "
|
|
742
|
-
Object.freeze({ emailExpression: !0, fieldCode: "
|
|
753
|
+
Object.freeze({ fieldCode: "documentReference", label: "Document reference", literal: !0, type: I.TEXT }),
|
|
754
|
+
Object.freeze({ emailExpression: !1, fieldCode: "to", label: "To", nameExpression: !0, type: I.MAILBOX }),
|
|
755
|
+
Object.freeze({ emailExpression: !1, fieldCode: "from", label: "From", nameExpression: !0, type: I.MAILBOX }),
|
|
756
|
+
Object.freeze({ emailExpression: !0, fieldCode: "replyTo", label: "Reply to", nameExpression: !0, type: I.MAILBOX }),
|
|
757
|
+
Object.freeze({ emailExpression: !0, fieldCode: "cc", label: "CC", nameExpression: !0, type: I.MAILBOX_LIST }),
|
|
758
|
+
Object.freeze({ emailExpression: !0, fieldCode: "bcc", label: "BCC", nameExpression: !0, type: I.MAILBOX_LIST })
|
|
743
759
|
]),
|
|
744
760
|
label: "Email",
|
|
745
761
|
partDefinitions: Object.freeze([
|
|
@@ -757,14 +773,14 @@ const xe = Object.freeze({
|
|
|
757
773
|
Object.freeze({ label: "HTML", previewViewCode: "HTML" }),
|
|
758
774
|
Object.freeze({ label: "Plain text", previewViewCode: "TEXT" })
|
|
759
775
|
]),
|
|
760
|
-
templateKindCode:
|
|
761
|
-
}),
|
|
762
|
-
[
|
|
776
|
+
templateKindCode: $e.EMAIL
|
|
777
|
+
}), mn = Object.freeze({
|
|
778
|
+
[$e.EMAIL]: Me
|
|
763
779
|
});
|
|
764
|
-
function
|
|
765
|
-
return
|
|
780
|
+
function ft(t) {
|
|
781
|
+
return mn[t] || null;
|
|
766
782
|
}
|
|
767
|
-
function
|
|
783
|
+
function Nr(t) {
|
|
768
784
|
return structuredClone({
|
|
769
785
|
fieldDefinitions: t.fieldDefinitions || [],
|
|
770
786
|
label: t.label,
|
|
@@ -774,25 +790,27 @@ function Cr(t) {
|
|
|
774
790
|
templateKindCode: t.templateKindCode
|
|
775
791
|
});
|
|
776
792
|
}
|
|
777
|
-
function
|
|
778
|
-
return (t.fieldDefinitions || []).flatMap(({ fieldCode: n, type: r, emailExpression: i, nameExpression: s,
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
793
|
+
function fn(t, e = {}) {
|
|
794
|
+
return (t.fieldDefinitions || []).flatMap(({ fieldCode: n, type: r, emailExpression: i, nameExpression: s, literal: o, expressionAllowed: a = !1 }) => {
|
|
795
|
+
if (o)
|
|
796
|
+
return [];
|
|
797
|
+
const c = e[n];
|
|
798
|
+
return r === I.TEXT ? typeof c == "string" && c ? [{ content: c, expressionAllowed: !!a, fieldPath: n }] : [] : (r === I.MAILBOX_LIST ? Array.isArray(c) ? c : [] : c ? [c] : []).flatMap((m, u) => {
|
|
799
|
+
const d = r === I.MAILBOX_LIST ? `${n}[${u}]` : n;
|
|
782
800
|
return [
|
|
783
|
-
{ content: (
|
|
784
|
-
{ content: (
|
|
785
|
-
].filter(({ content:
|
|
801
|
+
{ content: (m == null ? void 0 : m.email) || "", expressionAllowed: i, fieldPath: `${d}.email` },
|
|
802
|
+
{ content: (m == null ? void 0 : m.name) || "", expressionAllowed: s, fieldPath: `${d}.name` }
|
|
803
|
+
].filter(({ content: f }) => f);
|
|
786
804
|
});
|
|
787
805
|
});
|
|
788
806
|
}
|
|
789
|
-
const
|
|
790
|
-
fields: Object.freeze({ first:
|
|
807
|
+
const ht = new Map(ut.map((t) => [t.name, t])), w = Object.freeze({ type: "number" }), Ue = Object.freeze({ type: "string" }), we = Object.freeze({ type: "boolean" }), hn = Object.freeze({
|
|
808
|
+
fields: Object.freeze({ first: we, index: w, index0: w, last: we, length: w, rindex: w, rindex0: w }),
|
|
791
809
|
label: "Loop",
|
|
792
810
|
type: "object"
|
|
793
|
-
}),
|
|
794
|
-
function
|
|
795
|
-
const
|
|
811
|
+
}), Tn = /* @__PURE__ */ new Set([F, "forloop"]), bn = /* @__PURE__ */ new Set(["where", "where_exp"]), En = /* @__PURE__ */ new Set(["date", "downcase", "join", "strip_html", "truncate", "upcase"]), yn = /* @__PURE__ */ new Set(["divided_by", "minus", "plus", "round", "size", "times"]);
|
|
812
|
+
function fe(t, { locate: e, text: n, roots: r = null, variables: i = /* @__PURE__ */ new Map(), functionsByName: s = null, allowedFunctionNames: o = null, allowAssign: a = !1 } = {}) {
|
|
813
|
+
const c = {
|
|
796
814
|
allowAssign: a,
|
|
797
815
|
allowedFunctionNames: o,
|
|
798
816
|
assigned: /* @__PURE__ */ new Map(),
|
|
@@ -803,27 +821,27 @@ function me(t, { locate: e, text: n, roots: r = null, variables: i = /* @__PURE_
|
|
|
803
821
|
roots: r,
|
|
804
822
|
text: n
|
|
805
823
|
};
|
|
806
|
-
return
|
|
824
|
+
return v(t, i, c), { issues: c.issues, requiredRoots: [...c.requiredRoots].sort() };
|
|
807
825
|
}
|
|
808
|
-
function
|
|
809
|
-
return
|
|
826
|
+
function Sr(t, e) {
|
|
827
|
+
return ht.get(t) || (e == null ? void 0 : e.get(t)) || null;
|
|
810
828
|
}
|
|
811
|
-
function
|
|
829
|
+
function v(t, e, n) {
|
|
812
830
|
(t || []).forEach((r) => {
|
|
813
831
|
const { token: i } = r;
|
|
814
832
|
if (A.isOutputToken(i)) {
|
|
815
|
-
const s =
|
|
833
|
+
const s = ue(n, i), o = H(r.value, e, n, s);
|
|
816
834
|
o && (o.type === "list" || o.type === "object") && N(n, y.OUTPUT_NOT_SCALAR, `"${s}" outputs a ${o.type}; output a field of it or use a filter such as join or size.`, i, s);
|
|
817
835
|
return;
|
|
818
836
|
}
|
|
819
|
-
A.isTagToken(i) &&
|
|
837
|
+
A.isTagToken(i) && gn(r, e, n);
|
|
820
838
|
});
|
|
821
839
|
}
|
|
822
|
-
function
|
|
840
|
+
function gn(t, e, n) {
|
|
823
841
|
var o;
|
|
824
|
-
const { name: r, token: i } = t, s =
|
|
825
|
-
if (!
|
|
826
|
-
const a =
|
|
842
|
+
const { name: r, token: i } = t, s = ue(n, i);
|
|
843
|
+
if (!lt.includes(r) && !(n.allowAssign && Re.includes(r))) {
|
|
844
|
+
const a = Re.includes(r) ? " outside block fragments" : "";
|
|
827
845
|
N(n, y.TAG_NOT_ALLOWED, `Tag "${r}" is not allowed${a}.`, i, s);
|
|
828
846
|
return;
|
|
829
847
|
}
|
|
@@ -831,52 +849,52 @@ function bn(t, e, n) {
|
|
|
831
849
|
case "if":
|
|
832
850
|
case "unless":
|
|
833
851
|
t.branches.forEach((a) => {
|
|
834
|
-
H(a.value, e, n, s),
|
|
835
|
-
}),
|
|
852
|
+
H(a.value, e, n, s), v(a.templates, e, n);
|
|
853
|
+
}), v(t.elseTemplates, e, n);
|
|
836
854
|
break;
|
|
837
855
|
case "case":
|
|
838
856
|
H(t.value, e, n, s), t.branches.forEach((a) => {
|
|
839
|
-
a.values.forEach((
|
|
840
|
-
}),
|
|
857
|
+
a.values.forEach((c) => D(c, e, n, s)), v(a.templates, e, n);
|
|
858
|
+
}), v(t.elseTemplates, e, n);
|
|
841
859
|
break;
|
|
842
860
|
case "for": {
|
|
843
861
|
const { variable: a } = t;
|
|
844
|
-
|
|
845
|
-
const
|
|
846
|
-
let
|
|
847
|
-
A.isRangeToken(t.collection) ?
|
|
848
|
-
|
|
849
|
-
}),
|
|
862
|
+
ge(a, e, n, i, s);
|
|
863
|
+
const c = D(t.collection, e, n, s);
|
|
864
|
+
let l = null;
|
|
865
|
+
A.isRangeToken(t.collection) ? l = w : c && c.type !== "list" ? N(n, y.LOOP_SOURCE_NOT_LIST, `"${ue(n, t.collection)}" is not a list.`, t.collection, s) : c && (l = c.item || null), Object.values(((o = t.hash) == null ? void 0 : o.hash) || {}).forEach((m) => {
|
|
866
|
+
m && D(m, e, n, s);
|
|
867
|
+
}), v(t.templates, new Map([...e, [a, l], ["forloop", hn]]), n), v(t.elseTemplates, e, n);
|
|
850
868
|
break;
|
|
851
869
|
}
|
|
852
870
|
case "assign": {
|
|
853
|
-
|
|
871
|
+
ge(t.key, e, n, i, s), n.assigned.set(t.key, H(t.value, e, n, s));
|
|
854
872
|
break;
|
|
855
873
|
}
|
|
856
874
|
case "capture":
|
|
857
|
-
|
|
875
|
+
ge(t.variable, e, n, i, s), v(t.templates, e, n), n.assigned.set(t.variable, Ue);
|
|
858
876
|
break;
|
|
859
877
|
}
|
|
860
878
|
}
|
|
861
|
-
function
|
|
862
|
-
!Q.test(t || "") || t.startsWith("__") ? N(n, y.VARIABLE_INVALID, `Variable "${t}" must match [A-Za-z_]\\w* and must not start with "__".`, r, i) : (
|
|
879
|
+
function ge(t, e, n, r, i) {
|
|
880
|
+
!Q.test(t || "") || t.startsWith("__") ? N(n, y.VARIABLE_INVALID, `Variable "${t}" must match [A-Za-z_]\\w* and must not start with "__".`, r, i) : (De.includes(t) || e.has(t) || n.roots && Object.hasOwn(n.roots, t)) && N(n, y.VARIABLE_INVALID, `Variable "${t}" conflicts with a data root, a loop variable or a reserved name.`, r, i);
|
|
863
881
|
}
|
|
864
882
|
function H(t, e, n, r) {
|
|
865
883
|
if (!t)
|
|
866
884
|
return null;
|
|
867
|
-
let i =
|
|
885
|
+
let i = Tt(t.initial, e, n, r);
|
|
868
886
|
return (t.filters || []).forEach((s) => {
|
|
869
|
-
i =
|
|
887
|
+
i = On(s, i, e, n, r);
|
|
870
888
|
}), i;
|
|
871
889
|
}
|
|
872
|
-
function
|
|
873
|
-
const i = [...(t == null ? void 0 : t.postfix) || []], s = i.map((o) =>
|
|
874
|
-
return i.length === 1 ? s[0] : i.some((o) => A.isOperatorToken(o)) ?
|
|
890
|
+
function Tt(t, e, n, r) {
|
|
891
|
+
const i = [...(t == null ? void 0 : t.postfix) || []], s = i.map((o) => D(o, e, n, r));
|
|
892
|
+
return i.length === 1 ? s[0] : i.some((o) => A.isOperatorToken(o)) ? we : null;
|
|
875
893
|
}
|
|
876
|
-
function
|
|
877
|
-
return t ? A.isPropertyAccessToken(t) ?
|
|
894
|
+
function D(t, e, n, r) {
|
|
895
|
+
return t ? A.isPropertyAccessToken(t) ? _n(t, e, n, r) : A.isRangeToken(t) ? (D(t.lhs, e, n, r), D(t.rhs, e, n, r), { item: w, type: "list" }) : A.isNumberToken(t) ? w : A.isQuotedToken(t) ? Ue : t.initial ? H(t, e, n, r) : null : null;
|
|
878
896
|
}
|
|
879
|
-
function
|
|
897
|
+
function _n(t, e, n, r) {
|
|
880
898
|
const [i, ...s] = t.props || [], o = i == null ? void 0 : i.content;
|
|
881
899
|
if (typeof o != "string" || !A.isWordToken(i))
|
|
882
900
|
return null;
|
|
@@ -891,162 +909,162 @@ function En(t, e, n, r) {
|
|
|
891
909
|
else
|
|
892
910
|
return N(n, y.ROOT_UNKNOWN, `"${o}" is not a data root of this context (${Object.keys(n.roots).join(", ")}) or a template variable.`, t, r), null;
|
|
893
911
|
else return o !== F && n.requiredRoots.add(o), null;
|
|
894
|
-
for (const
|
|
912
|
+
for (const c of s) {
|
|
895
913
|
if (!a)
|
|
896
914
|
return null;
|
|
897
|
-
if (A.isPropertyAccessToken(
|
|
898
|
-
if (
|
|
915
|
+
if (A.isPropertyAccessToken(c) || c.initial) {
|
|
916
|
+
if (D(c, e, n, r), a.type === "list") {
|
|
899
917
|
a = a.item || null;
|
|
900
918
|
continue;
|
|
901
919
|
}
|
|
902
|
-
return a.type === "object" ? null :
|
|
920
|
+
return a.type === "object" ? null : ie(n, t, r, "only a list or an object can be indexed.");
|
|
903
921
|
}
|
|
904
|
-
if (A.isNumberToken(
|
|
922
|
+
if (A.isNumberToken(c)) {
|
|
905
923
|
if (a.type !== "list")
|
|
906
|
-
return
|
|
924
|
+
return ie(n, t, r, "only a list can be indexed.");
|
|
907
925
|
a = a.item || null;
|
|
908
926
|
continue;
|
|
909
927
|
}
|
|
910
|
-
const
|
|
928
|
+
const l = c.content;
|
|
911
929
|
if (a.type === "list")
|
|
912
|
-
if (
|
|
913
|
-
a =
|
|
914
|
-
else if (
|
|
930
|
+
if (l === "size")
|
|
931
|
+
a = w;
|
|
932
|
+
else if (l === "first" || l === "last")
|
|
915
933
|
a = a.item || null;
|
|
916
934
|
else
|
|
917
|
-
return
|
|
918
|
-
else if (a.type === "string" &&
|
|
919
|
-
a =
|
|
920
|
-
else if (a.type === "object" && a.fields && Object.hasOwn(a.fields,
|
|
921
|
-
a = a.fields[
|
|
922
|
-
else return a.type === "object" && !
|
|
935
|
+
return ie(n, t, r, `a list has no field "${l}" (use size, first, last or a loop).`);
|
|
936
|
+
else if (a.type === "string" && l === "size")
|
|
937
|
+
a = w;
|
|
938
|
+
else if (a.type === "object" && a.fields && Object.hasOwn(a.fields, l))
|
|
939
|
+
a = a.fields[l];
|
|
940
|
+
else return a.type === "object" && !Tn.has(o) ? null : ie(n, t, r, `field "${l}" does not exist.`);
|
|
923
941
|
}
|
|
924
942
|
return a;
|
|
925
943
|
}
|
|
926
|
-
function
|
|
927
|
-
return N(t, y.PATH_UNKNOWN, `"${
|
|
944
|
+
function ie(t, e, n, r) {
|
|
945
|
+
return N(t, y.PATH_UNKNOWN, `"${ue(t, e)}": ${r}`, e, n), null;
|
|
928
946
|
}
|
|
929
|
-
function
|
|
947
|
+
function On(t, e, n, r, i) {
|
|
930
948
|
var _;
|
|
931
949
|
const { name: s, args: o = [] } = t;
|
|
932
950
|
if (!s)
|
|
933
951
|
return N(r, y.SYNTAX_ERROR, 'A filter name is missing after "|".', t.token, i), null;
|
|
934
|
-
const a = o.filter((
|
|
935
|
-
a.forEach((
|
|
936
|
-
const
|
|
937
|
-
if (!
|
|
952
|
+
const a = o.filter((h) => !Array.isArray(h)), c = o.filter((h) => Array.isArray(h));
|
|
953
|
+
a.forEach((h) => D(h, n, r, i)), c.forEach(([, h]) => D(h, n, r, i));
|
|
954
|
+
const l = ht.get(s), m = l || ((_ = r.functionsByName) == null ? void 0 : _.get(s));
|
|
955
|
+
if (!m)
|
|
938
956
|
return (r.functionsByName || !s.startsWith("__")) && N(r, y.UNKNOWN_FUNCTION, `Filter "${s}" is not available.`, t.token, i), null;
|
|
939
|
-
if (!
|
|
957
|
+
if (!l && r.allowedFunctionNames && !r.allowedFunctionNames.has(s))
|
|
940
958
|
return N(r, y.FUNCTION_NOT_ALLOWED, `Filter "${s}" is not allowed in this data context.`, t.token, i), null;
|
|
941
|
-
const u = (
|
|
942
|
-
if (
|
|
943
|
-
const
|
|
944
|
-
return N(r, y.FUNCTION_ARGUMENTS_INVALID, `Filter "${s}" expects ${
|
|
959
|
+
const u = (m.signature || []).slice(1), d = u.filter((h) => !h.optional && !h.variadic).length, f = u.some((h) => h.variadic);
|
|
960
|
+
if (c.length || a.length < d || !f && a.length > u.length) {
|
|
961
|
+
const h = f ? `at least ${d}` : d === u.length ? d : `${d}-${u.length}`;
|
|
962
|
+
return N(r, y.FUNCTION_ARGUMENTS_INVALID, `Filter "${s}" expects ${h} argument(s)${c.length ? " and no named arguments" : ""}, got ${a.length}.`, t.token, i), null;
|
|
945
963
|
}
|
|
946
|
-
return
|
|
964
|
+
return l ? Cn(s, e, a, n, r, i) : null;
|
|
947
965
|
}
|
|
948
|
-
function
|
|
949
|
-
const o = (e == null ? void 0 : e.type) === "list" ? e.item : null, a = (
|
|
966
|
+
function Cn(t, e, n, r, i, s) {
|
|
967
|
+
const o = (e == null ? void 0 : e.type) === "list" ? e.item : null, a = (l) => !o || o.type !== "object" || typeof l != "string" ? null : o.fields && Object.hasOwn(o.fields, l) ? o.fields[l] : null, c = (l) => l && A.isQuotedToken(l) ? l.content : null;
|
|
950
968
|
if (t === "where")
|
|
951
|
-
return a(
|
|
969
|
+
return a(c(n[0])), e;
|
|
952
970
|
if (t === "where_exp")
|
|
953
|
-
return
|
|
954
|
-
if (
|
|
971
|
+
return An(c(n[0]), n[1], o, r, i, s), e;
|
|
972
|
+
if (bn.has(t))
|
|
955
973
|
return e;
|
|
956
974
|
if (t === "map") {
|
|
957
|
-
const
|
|
958
|
-
return (e == null ? void 0 : e.type) === "list" ? { item:
|
|
975
|
+
const l = a(c(n[0]));
|
|
976
|
+
return (e == null ? void 0 : e.type) === "list" ? { item: l, type: "list" } : null;
|
|
959
977
|
}
|
|
960
|
-
return t === "first" ? o : t === "default" ? e :
|
|
978
|
+
return t === "first" ? o : t === "default" ? e : yn.has(t) ? w : En.has(t) ? Ue : null;
|
|
961
979
|
}
|
|
962
|
-
function
|
|
980
|
+
function An(t, e, n, r, i, s) {
|
|
963
981
|
if (!t || !e || !A.isQuotedToken(e))
|
|
964
982
|
return;
|
|
965
983
|
let o;
|
|
966
984
|
try {
|
|
967
|
-
o = new
|
|
968
|
-
} catch (
|
|
969
|
-
N(i, y.SYNTAX_ERROR, `where_exp expression: ${
|
|
985
|
+
o = new Rt(e.content).readExpression();
|
|
986
|
+
} catch (c) {
|
|
987
|
+
N(i, y.SYNTAX_ERROR, `where_exp expression: ${c.message}`, e, s);
|
|
970
988
|
return;
|
|
971
989
|
}
|
|
972
990
|
const a = { ...i, text: e.content };
|
|
973
|
-
a.issues = [],
|
|
991
|
+
a.issues = [], Tt(o, new Map([...r, [t, n]]), a, s), a.issues.forEach((c) => i.issues.push({ ...c, ...i.locate(e.begin) }));
|
|
974
992
|
}
|
|
975
|
-
function
|
|
993
|
+
function ue(t, e) {
|
|
976
994
|
return t.text && e ? t.text.slice(e.begin, e.end) : "";
|
|
977
995
|
}
|
|
978
996
|
function N(t, e, n, r, i) {
|
|
979
997
|
t.issues.push(O({ code: e, message: n, ...t.locate((r == null ? void 0 : r.begin) ?? 0), ...i ? { source: i } : {} }));
|
|
980
998
|
}
|
|
981
|
-
const
|
|
982
|
-
function
|
|
983
|
-
var
|
|
984
|
-
const a = typeof (t == null ? void 0 : t.toObject) == "function" ? t.toObject() : t || {},
|
|
985
|
-
if (!
|
|
999
|
+
const Rn = /\{\{|\{%/, _e = Object.freeze({ DEPRECATED: "DEPRECATED", DRAFT: "DRAFT", PUBLISHED: "PUBLISHED" });
|
|
1000
|
+
function Lr({ template: t, kind: e, context: n, functions: r, blocks: i, allowedDeprecatedBlockRefs: s, layouts: o = [] } = {}) {
|
|
1001
|
+
var b;
|
|
1002
|
+
const a = typeof (t == null ? void 0 : t.toObject) == "function" ? t.toObject() : t || {}, c = e || ((b = t == null ? void 0 : t.constructor) == null ? void 0 : b.kind) || ft(a.templateKindCode), l = [], m = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
|
|
1003
|
+
if (!c)
|
|
986
1004
|
throw new TypeError("checkTemplate requires a template kind.");
|
|
987
|
-
const
|
|
988
|
-
if (!
|
|
989
|
-
return
|
|
990
|
-
const
|
|
991
|
-
return
|
|
992
|
-
const E = _[
|
|
1005
|
+
const d = a.templateSyntaxVersion ?? Ie;
|
|
1006
|
+
if (!rt.includes(d))
|
|
1007
|
+
return l.push(O({ code: y.SYNTAX_VERSION_UNSUPPORTED, message: `Template syntax version ${d} is not supported.` })), { blockRefs: [], issues: l, layoutCodes: [], valid: !1 };
|
|
1008
|
+
const f = Et({ allowedDeprecatedBlockRefs: s, blocks: i, context: n, functions: r }), _ = a.partContent || {}, h = new Set(c.partDefinitions.map(({ partCode: p }) => p));
|
|
1009
|
+
return c.partDefinitions.forEach(({ partCode: p, required: T }) => {
|
|
1010
|
+
const E = _[p];
|
|
993
1011
|
if (typeof E != "string" || !E.trim()) {
|
|
994
|
-
|
|
1012
|
+
T && l.push(O({ code: y.PART_REQUIRED, message: `Part "${p}" is required.`, partCode: p }));
|
|
995
1013
|
return;
|
|
996
1014
|
}
|
|
997
|
-
const C =
|
|
998
|
-
|
|
999
|
-
u.has(
|
|
1015
|
+
const C = de(E, { allowBlocks: !0, env: f, partCode: p });
|
|
1016
|
+
l.push(...C.issues), C.blockRefs.forEach((S) => m.add(S)), Be(E).forEach((S) => {
|
|
1017
|
+
u.has(S) || l.push(...Nn(S, { env: f, layouts: o, partCode: p })), u.add(S);
|
|
1000
1018
|
});
|
|
1001
|
-
}), Object.keys(_).forEach((
|
|
1002
|
-
|
|
1003
|
-
}),
|
|
1019
|
+
}), Object.keys(_).forEach((p) => {
|
|
1020
|
+
h.has(p) || l.push(O({ code: y.PART_UNKNOWN, message: `Part "${p}" is not declared by template kind ${c.templateKindCode}.`, partCode: p }));
|
|
1021
|
+
}), fn(c, a).forEach(({ fieldPath: p, content: T, expressionAllowed: E }) => {
|
|
1004
1022
|
if (!E) {
|
|
1005
|
-
|
|
1023
|
+
Rn.test(T) && l.push(O({ code: y.FIELD_EXPRESSION_NOT_ALLOWED, message: `Field "${p}" must be a fixed value.`, partCode: p }));
|
|
1006
1024
|
return;
|
|
1007
1025
|
}
|
|
1008
|
-
|
|
1009
|
-
}), { blockRefs: [...
|
|
1026
|
+
l.push(...de(T, { allowBlocks: !1, env: f, partCode: p }).issues);
|
|
1027
|
+
}), { blockRefs: [...m], issues: l, layoutCodes: [...u], valid: !K(l) };
|
|
1010
1028
|
}
|
|
1011
|
-
function
|
|
1012
|
-
const i =
|
|
1029
|
+
function Nn(t, { env: e, layouts: n, partCode: r }) {
|
|
1030
|
+
const i = at({ layoutCode: t, layouts: n });
|
|
1013
1031
|
if (!i)
|
|
1014
1032
|
return [O({ code: y.LAYOUT_NOT_FOUND, layoutCode: t, message: `Layout ${t} has no published version.`, partCode: r })];
|
|
1015
1033
|
const s = `${i.layoutCode}@${i.version}`;
|
|
1016
1034
|
return [
|
|
1017
|
-
...
|
|
1018
|
-
...
|
|
1035
|
+
...de(i.html || "", { allowBlocks: !1, env: e, partCode: r }).issues,
|
|
1036
|
+
...ct(i.html)
|
|
1019
1037
|
].map((o) => ({ ...o, layoutRef: s, message: `${s}: ${o.message}`, partCode: r }));
|
|
1020
1038
|
}
|
|
1021
|
-
function
|
|
1022
|
-
const a =
|
|
1023
|
-
return { ...
|
|
1039
|
+
function wr({ content: t, partCode: e, allowBlocks: n = !0, context: r, functions: i, blocks: s, allowedDeprecatedBlockRefs: o } = {}) {
|
|
1040
|
+
const a = Et({ allowedDeprecatedBlockRefs: o, blocks: s, context: r, functions: i }), c = de(t, { allowBlocks: n, env: a, partCode: e });
|
|
1041
|
+
return { ...c, valid: !K(c.issues) };
|
|
1024
1042
|
}
|
|
1025
|
-
function
|
|
1026
|
-
const { definitions: i, errors: s } =
|
|
1043
|
+
function Sn({ fragment: t, params: e, functions: n, context: r } = {}) {
|
|
1044
|
+
const { definitions: i, errors: s } = Z(e), o = s.map((c) => O({ code: y.BLOCK_PARAMS_INVALID, message: c })), a = bt(t, { allowAssign: !0, context: r, functions: n, paramsRoot: xe(i) });
|
|
1027
1045
|
return o.push(...a.issues), { issues: o, requiredRoots: a.requiredRoots, valid: !K(o) };
|
|
1028
1046
|
}
|
|
1029
|
-
function
|
|
1030
|
-
const n =
|
|
1047
|
+
function Ln({ html: t, functions: e } = {}) {
|
|
1048
|
+
const n = bt(t || "", { allowAssign: !1, functions: e, paramsRoot: xe([]) }), r = [...n.issues.map((i) => ({ ...i, partCode: "layout" })), ...ct(t)];
|
|
1031
1049
|
return { issues: r, requiredRoots: n.requiredRoots, valid: !K(r) };
|
|
1032
1050
|
}
|
|
1033
|
-
function
|
|
1034
|
-
const s =
|
|
1051
|
+
function bt(t, { allowAssign: e, context: n, functions: r, paramsRoot: i }) {
|
|
1052
|
+
const s = J(n), o = te(t, { allowBlocks: !1 }), a = r || (s ? me() : null), c = fe(o.templates, {
|
|
1035
1053
|
allowAssign: e,
|
|
1036
1054
|
allowedFunctionNames: s ? new Set(s.functionNames || []) : null,
|
|
1037
|
-
functionsByName: a ? new Map(a.map((
|
|
1055
|
+
functionsByName: a ? new Map(a.map((l) => [l.name, l])) : null,
|
|
1038
1056
|
locate: o.locate,
|
|
1039
1057
|
roots: (s == null ? void 0 : s.roots) || null,
|
|
1040
1058
|
text: o.text,
|
|
1041
1059
|
variables: /* @__PURE__ */ new Map([[F, i]])
|
|
1042
1060
|
});
|
|
1043
|
-
return { issues: [...o.issues, ...
|
|
1061
|
+
return { issues: [...o.issues, ...c.issues], requiredRoots: c.requiredRoots };
|
|
1044
1062
|
}
|
|
1045
|
-
function
|
|
1046
|
-
const i =
|
|
1063
|
+
function Et({ allowedDeprecatedBlockRefs: t = [], blocks: e = [], context: n, functions: r }) {
|
|
1064
|
+
const i = J(n);
|
|
1047
1065
|
if (!i || !i.roots)
|
|
1048
1066
|
throw new TypeError("Template checks require a data context.");
|
|
1049
|
-
const s = r ||
|
|
1067
|
+
const s = r || me();
|
|
1050
1068
|
return {
|
|
1051
1069
|
allowedDeprecatedBlockRefs: new Set(t),
|
|
1052
1070
|
allowedFunctionNames: new Set(i.functionNames || []),
|
|
@@ -1059,28 +1077,28 @@ function ft({ allowedDeprecatedBlockRefs: t = [], blocks: e = [], context: n, fu
|
|
|
1059
1077
|
roots: i.roots
|
|
1060
1078
|
};
|
|
1061
1079
|
}
|
|
1062
|
-
function
|
|
1063
|
-
const i =
|
|
1064
|
-
return s.push(...
|
|
1080
|
+
function de(t, { allowBlocks: e, env: n, partCode: r }) {
|
|
1081
|
+
const i = te(t, { allowBlocks: e, partCode: r }), s = [...i.issues];
|
|
1082
|
+
return s.push(...fe(i.templates, {
|
|
1065
1083
|
allowedFunctionNames: n.allowedFunctionNames,
|
|
1066
1084
|
functionsByName: n.functionsByName,
|
|
1067
1085
|
locate: i.locate,
|
|
1068
1086
|
roots: n.roots,
|
|
1069
1087
|
text: i.text
|
|
1070
|
-
}).issues), i.blocks.forEach((o) =>
|
|
1088
|
+
}).issues), i.blocks.forEach((o) => wn(o, n, s)), { blockRefs: i.blockRefs, issues: s };
|
|
1071
1089
|
}
|
|
1072
|
-
function
|
|
1073
|
-
const { blockRef: r, location: i } = t, s = (u,
|
|
1090
|
+
function wn(t, e, n) {
|
|
1091
|
+
const { blockRef: r, location: i } = t, s = (u, d, f) => n.push(O({ blockRef: r, code: u, message: d, severity: f, ...i })), o = e.blocksByRef.get(r);
|
|
1074
1092
|
if (!o) {
|
|
1075
1093
|
s(y.UNKNOWN_BLOCK, `Block ${r} does not exist.`);
|
|
1076
1094
|
return;
|
|
1077
1095
|
}
|
|
1078
|
-
const a = o.stateCode ||
|
|
1079
|
-
if (a ===
|
|
1096
|
+
const a = o.stateCode || _e.PUBLISHED;
|
|
1097
|
+
if (a === _e.DRAFT) {
|
|
1080
1098
|
s(y.BLOCK_NOT_PUBLISHED, `Block ${r} is not published.`);
|
|
1081
1099
|
return;
|
|
1082
1100
|
}
|
|
1083
|
-
if (a ===
|
|
1101
|
+
if (a === _e.DEPRECATED) {
|
|
1084
1102
|
const u = e.allowedDeprecatedBlockRefs.has(r);
|
|
1085
1103
|
s(
|
|
1086
1104
|
y.BLOCK_DEPRECATED,
|
|
@@ -1092,35 +1110,35 @@ function Nn(t, e, n) {
|
|
|
1092
1110
|
s(y.BLOCK_CONTEXT_MISMATCH, `Block ${r} is for data context ${o.contextCode || "(none)"}, not ${e.contextCode}.`);
|
|
1093
1111
|
return;
|
|
1094
1112
|
}
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1097
|
-
const { definitions:
|
|
1098
|
-
if (
|
|
1099
|
-
const u =
|
|
1113
|
+
const c = (o.requiredRoots || []).filter((u) => !Object.hasOwn(e.roots, u));
|
|
1114
|
+
c.length && s(y.BLOCK_ROOT_NOT_IN_CONTEXT, `Block ${r} requires data roots not in this context: ${c.join(", ")}.`);
|
|
1115
|
+
const { definitions: l } = Z(o.params), { errors: m } = mt(l, t.params);
|
|
1116
|
+
if (m.forEach((u) => s(y.BLOCK_PARAMS_INVALID, `${r}: ${u}`)), typeof o.fragment == "string" && !c.length) {
|
|
1117
|
+
const u = te(o.fragment, { allowBlocks: !1 }), d = fe(u.templates, {
|
|
1100
1118
|
allowAssign: !0,
|
|
1101
1119
|
allowedFunctionNames: e.allowedFunctionNames,
|
|
1102
1120
|
functionsByName: e.functionsByName,
|
|
1103
1121
|
locate: u.locate,
|
|
1104
1122
|
roots: e.roots,
|
|
1105
1123
|
text: u.text,
|
|
1106
|
-
variables: /* @__PURE__ */ new Map([[F,
|
|
1124
|
+
variables: /* @__PURE__ */ new Map([[F, xe(l)]])
|
|
1107
1125
|
});
|
|
1108
|
-
[...u.issues, ...
|
|
1126
|
+
[...u.issues, ...d.issues].forEach((f) => n.push(O({
|
|
1109
1127
|
...i,
|
|
1110
1128
|
blockRef: r,
|
|
1111
|
-
code:
|
|
1112
|
-
message: `${r}: ${
|
|
1113
|
-
severity:
|
|
1129
|
+
code: f.code,
|
|
1130
|
+
message: `${r}: ${f.message}`,
|
|
1131
|
+
severity: f.severity
|
|
1114
1132
|
})));
|
|
1115
1133
|
}
|
|
1116
1134
|
}
|
|
1117
|
-
const
|
|
1135
|
+
const Pn = ["active", "created", "creator", "deleted", "modified", "owner", "revision"], In = ["blockCode", "category", "contextCode", "description", "fragment", "name", "tenantCode", "version"], Je = ["category", "contextCode", "description", "fragment", "name", "params"], Dn = /^[A-Z][A-Z0-9_]*$/, Pr = Object.freeze({
|
|
1118
1136
|
DEPRECATED: "TEMPLATE_BLOCK_DEPRECATED",
|
|
1119
1137
|
PUBLISHED: "TEMPLATE_BLOCK_PUBLISHED"
|
|
1120
1138
|
});
|
|
1121
|
-
class
|
|
1139
|
+
class vn extends tt {
|
|
1122
1140
|
constructor(e = {}) {
|
|
1123
|
-
e = e || {}, super(e), this._type = e._type || "TemplateBlock", this.blockCode = e.blockCode, this.category = e.category || "", this.contextCode = e.contextCode || "", this.description = e.description || "", this.fragment = typeof e.fragment == "string" ? e.fragment : "", this.lifecycle = e.lifecycle ?
|
|
1141
|
+
e = e || {}, super(e), this._type = e._type || "TemplateBlock", this.blockCode = e.blockCode, this.category = e.category || "", this.contextCode = e.contextCode || "", this.description = e.description || "", this.fragment = typeof e.fragment == "string" ? e.fragment : "", this.lifecycle = e.lifecycle ? Le.init(e.lifecycle) : null, this.name = e.name || "", this.params = Z(e.params).definitions, this.requiredRoots = Array.isArray(e.requiredRoots) ? [...e.requiredRoots] : [], this.tenantCode = e.tenantCode || void 0, this.version = Number(e.version);
|
|
1124
1142
|
}
|
|
1125
1143
|
static get _classname() {
|
|
1126
1144
|
return "TemplateBlock";
|
|
@@ -1132,13 +1150,13 @@ class wn extends Qe {
|
|
|
1132
1150
|
static create({ actionRevision: e = 1, modified: n = Date.now(), ...r } = {}) {
|
|
1133
1151
|
return this.init({
|
|
1134
1152
|
...r,
|
|
1135
|
-
lifecycle:
|
|
1153
|
+
lifecycle: Le.create({ actionRevision: e, modified: n }).toObject(),
|
|
1136
1154
|
meta: { ...r.meta, revision: e }
|
|
1137
1155
|
});
|
|
1138
1156
|
}
|
|
1139
1157
|
get isValid() {
|
|
1140
1158
|
var e;
|
|
1141
|
-
return super.isValid &&
|
|
1159
|
+
return super.isValid && Dn.test(this.blockCode || "") && !!this.contextCode && Number.isInteger(this.version) && this.version >= 1 && !!((e = this.lifecycle) != null && e.isValid);
|
|
1142
1160
|
}
|
|
1143
1161
|
get blockRef() {
|
|
1144
1162
|
return `${this.blockCode}@${this.version}`;
|
|
@@ -1162,15 +1180,15 @@ class wn extends Qe {
|
|
|
1162
1180
|
*/
|
|
1163
1181
|
check({ context: e, functions: n } = {}) {
|
|
1164
1182
|
var r;
|
|
1165
|
-
if (e && ((r =
|
|
1183
|
+
if (e && ((r = J(e)) == null ? void 0 : r.contextCode) !== this.contextCode)
|
|
1166
1184
|
throw new TypeError(`TemplateBlock ${this.blockRef} belongs to data context ${this.contextCode}.`);
|
|
1167
|
-
return
|
|
1185
|
+
return Sn({ context: e, fragment: this.fragment, functions: n, params: this.params });
|
|
1168
1186
|
}
|
|
1169
1187
|
update(e = {}) {
|
|
1170
|
-
if (
|
|
1188
|
+
if (Je.some((r) => Object.hasOwn(e, r)) && !this.isDraft)
|
|
1171
1189
|
throw new Error(`TemplateBlock ${this.blockRef} is ${this.stateCode}; publish changes as a new version.`);
|
|
1172
|
-
return
|
|
1173
|
-
Object.hasOwn(e, r) && (this[r] = r === "params" ?
|
|
1190
|
+
return Je.forEach((r) => {
|
|
1191
|
+
Object.hasOwn(e, r) && (this[r] = r === "params" ? Z(e.params).definitions : e[r] ?? "");
|
|
1174
1192
|
}), super.update(e);
|
|
1175
1193
|
}
|
|
1176
1194
|
/**
|
|
@@ -1180,7 +1198,7 @@ class wn extends Qe {
|
|
|
1180
1198
|
publish({ actionRevision: e = this.revision + 1, context: n, modified: r = Date.now(), functions: i } = {}) {
|
|
1181
1199
|
const s = this.check({ context: n, functions: i });
|
|
1182
1200
|
if (!s.valid)
|
|
1183
|
-
throw new
|
|
1201
|
+
throw new ee(s.issues.map((o) => ({ ...o, blockRef: this.blockRef })));
|
|
1184
1202
|
return this.lifecycle.transition("publication", { actionRevision: e, modified: r, stateCode: z.PUBLISHED }), this.requiredRoots = s.requiredRoots, this.meta.revision = e, this.setModified();
|
|
1185
1203
|
}
|
|
1186
1204
|
/** Hide this version from editors; templates that use it still render. */
|
|
@@ -1189,7 +1207,7 @@ class wn extends Qe {
|
|
|
1189
1207
|
}
|
|
1190
1208
|
/** EntityAction for the latest publication transition. */
|
|
1191
1209
|
createEntityAction({ actionCode: e, actor: n, previousStateCode: r, timestamp: i = Date.now(), ...s } = {}) {
|
|
1192
|
-
return
|
|
1210
|
+
return nt.init({
|
|
1193
1211
|
...s,
|
|
1194
1212
|
actionCode: e,
|
|
1195
1213
|
actor: n,
|
|
@@ -1212,7 +1230,7 @@ class wn extends Qe {
|
|
|
1212
1230
|
description: this.description,
|
|
1213
1231
|
fragment: this.fragment,
|
|
1214
1232
|
name: this.name,
|
|
1215
|
-
params:
|
|
1233
|
+
params: Ge(this.params),
|
|
1216
1234
|
requiredRoots: [...this.requiredRoots],
|
|
1217
1235
|
stateCode: this.stateCode,
|
|
1218
1236
|
...this.tenantCode ? { tenantCode: this.tenantCode } : {},
|
|
@@ -1226,38 +1244,38 @@ class wn extends Qe {
|
|
|
1226
1244
|
const e = {
|
|
1227
1245
|
_type: this._type,
|
|
1228
1246
|
...this.lifecycle ? { lifecycle: this.lifecycle.toObject() } : {},
|
|
1229
|
-
meta:
|
|
1230
|
-
params:
|
|
1247
|
+
meta: L(this.meta, Pn),
|
|
1248
|
+
params: Ge(this.params),
|
|
1231
1249
|
requiredRoots: [...this.requiredRoots],
|
|
1232
|
-
...
|
|
1250
|
+
...L(this, In)
|
|
1233
1251
|
};
|
|
1234
1252
|
return typeof this.id < "u" && (e.id = this.id), e;
|
|
1235
1253
|
}
|
|
1236
1254
|
}
|
|
1237
|
-
const G = ["email", "name"],
|
|
1238
|
-
class
|
|
1255
|
+
const G = ["email", "name"], jn = ["bcc", "cc", "from", "replyTo", "to"];
|
|
1256
|
+
class Bn extends an {
|
|
1239
1257
|
constructor(e = {}) {
|
|
1240
|
-
e = e || {}, super(e), this._type = e._type || "TemplateEmail", this.bcc =
|
|
1258
|
+
e = e || {}, super(e), this._type = e._type || "TemplateEmail", this.bcc = Oe(e.bcc), this.cc = Oe(e.cc), this.from = W(e.from), this.replyTo = W(e.replyTo), this.to = W(e.to);
|
|
1241
1259
|
}
|
|
1242
1260
|
static get _classname() {
|
|
1243
1261
|
return "TemplateEmail";
|
|
1244
1262
|
}
|
|
1245
1263
|
static get kind() {
|
|
1246
|
-
return
|
|
1264
|
+
return Me;
|
|
1247
1265
|
}
|
|
1248
1266
|
update(e = {}) {
|
|
1249
|
-
return
|
|
1250
|
-
Object.hasOwn(e, n) && (this[n] = n === "cc" || n === "bcc" ?
|
|
1267
|
+
return jn.forEach((n) => {
|
|
1268
|
+
Object.hasOwn(e, n) && (this[n] = n === "cc" || n === "bcc" ? Oe(e[n]) : W(e[n]));
|
|
1251
1269
|
}), super.update(e);
|
|
1252
1270
|
}
|
|
1253
1271
|
toObject() {
|
|
1254
1272
|
return {
|
|
1255
1273
|
...super.toObject(),
|
|
1256
|
-
bcc: this.bcc.map((e) =>
|
|
1257
|
-
cc: this.cc.map((e) =>
|
|
1258
|
-
from: this.from ?
|
|
1259
|
-
replyTo: this.replyTo ?
|
|
1260
|
-
to: this.to ?
|
|
1274
|
+
bcc: this.bcc.map((e) => L(e, G)),
|
|
1275
|
+
cc: this.cc.map((e) => L(e, G)),
|
|
1276
|
+
from: this.from ? L(this.from, G) : null,
|
|
1277
|
+
replyTo: this.replyTo ? L(this.replyTo, G) : null,
|
|
1278
|
+
to: this.to ? L(this.to, G) : null
|
|
1261
1279
|
};
|
|
1262
1280
|
}
|
|
1263
1281
|
}
|
|
@@ -1267,11 +1285,11 @@ function W(t) {
|
|
|
1267
1285
|
...t.name ? { name: String(t.name) } : {}
|
|
1268
1286
|
} : null;
|
|
1269
1287
|
}
|
|
1270
|
-
function
|
|
1288
|
+
function Oe(t) {
|
|
1271
1289
|
return (Array.isArray(t) ? t : []).map(W).filter(Boolean);
|
|
1272
1290
|
}
|
|
1273
|
-
const
|
|
1274
|
-
class
|
|
1291
|
+
const Ce = z;
|
|
1292
|
+
class Ze extends Le {
|
|
1275
1293
|
static get _classname() {
|
|
1276
1294
|
return "LifecycleTemplateLayout";
|
|
1277
1295
|
}
|
|
@@ -1279,13 +1297,13 @@ class Ye extends Se {
|
|
|
1279
1297
|
return "TemplateLayout";
|
|
1280
1298
|
}
|
|
1281
1299
|
}
|
|
1282
|
-
const
|
|
1300
|
+
const xn = ["active", "created", "creator", "deleted", "modified", "owner", "revision"], $n = ["description", "eventShortCode", "html", "layoutCode", "name", "templateKindCode", "tenantCode", "version"], et = ["description", "html", "name"], Mn = /^[A-Z][A-Z0-9_]*$/, Ir = Object.freeze({
|
|
1283
1301
|
DEPRECATED: "TEMPLATE_LAYOUT_DEPRECATED",
|
|
1284
1302
|
PUBLISHED: "TEMPLATE_LAYOUT_PUBLISHED"
|
|
1285
1303
|
});
|
|
1286
|
-
class
|
|
1304
|
+
class Dr extends tt {
|
|
1287
1305
|
constructor(e = {}) {
|
|
1288
|
-
e = e || {}, super(e), this._type = e._type || "TemplateLayout", this.description = e.description || "", this.eventShortCode = e.eventShortCode || void 0, this.html = typeof e.html == "string" ? e.html : "", this.layoutCode = e.layoutCode, this.lifecycle = e.lifecycle ?
|
|
1306
|
+
e = e || {}, super(e), this._type = e._type || "TemplateLayout", this.description = e.description || "", this.eventShortCode = e.eventShortCode || void 0, this.html = typeof e.html == "string" ? e.html : "", this.layoutCode = e.layoutCode, this.lifecycle = e.lifecycle ? Ze.init(e.lifecycle) : null, this.name = e.name || "", this.requiredRoots = Array.isArray(e.requiredRoots) ? [...e.requiredRoots] : [], this.templateKindCode = e.templateKindCode || $e.EMAIL, this.tenantCode = e.tenantCode || void 0, this.version = Number(e.version);
|
|
1289
1307
|
}
|
|
1290
1308
|
static get _classname() {
|
|
1291
1309
|
return "TemplateLayout";
|
|
@@ -1297,13 +1315,13 @@ class Pr extends Qe {
|
|
|
1297
1315
|
static create({ actionRevision: e = 1, modified: n = Date.now(), ...r } = {}) {
|
|
1298
1316
|
return this.init({
|
|
1299
1317
|
...r,
|
|
1300
|
-
lifecycle:
|
|
1318
|
+
lifecycle: Ze.create({ actionRevision: e, modified: n }).toObject(),
|
|
1301
1319
|
meta: { ...r.meta, revision: e }
|
|
1302
1320
|
});
|
|
1303
1321
|
}
|
|
1304
1322
|
get isValid() {
|
|
1305
1323
|
var e;
|
|
1306
|
-
return super.isValid &&
|
|
1324
|
+
return super.isValid && Mn.test(this.layoutCode || "") && Number.isInteger(this.version) && this.version >= 1 && !!((e = this.lifecycle) != null && e.isValid);
|
|
1307
1325
|
}
|
|
1308
1326
|
get layoutRef() {
|
|
1309
1327
|
return `${this.layoutCode}@${this.version}`;
|
|
@@ -1313,7 +1331,7 @@ class Pr extends Qe {
|
|
|
1313
1331
|
return ((n = (e = this.lifecycle) == null ? void 0 : e.getState("publication")) == null ? void 0 : n.stateCode) || null;
|
|
1314
1332
|
}
|
|
1315
1333
|
get isDraft() {
|
|
1316
|
-
return this.stateCode ===
|
|
1334
|
+
return this.stateCode === Ce.DRAFT;
|
|
1317
1335
|
}
|
|
1318
1336
|
getCode() {
|
|
1319
1337
|
return this.layoutRef;
|
|
@@ -1323,12 +1341,12 @@ class Pr extends Qe {
|
|
|
1323
1341
|
}
|
|
1324
1342
|
/** Check the HTML without changing the layout. */
|
|
1325
1343
|
check({ functions: e } = {}) {
|
|
1326
|
-
return
|
|
1344
|
+
return Ln({ functions: e, html: this.html });
|
|
1327
1345
|
}
|
|
1328
1346
|
update(e = {}) {
|
|
1329
|
-
if (
|
|
1347
|
+
if (et.some((r) => Object.hasOwn(e, r)) && !this.isDraft)
|
|
1330
1348
|
throw new Error(`TemplateLayout ${this.layoutRef} is ${this.stateCode}; publish changes as a new version.`);
|
|
1331
|
-
return
|
|
1349
|
+
return et.forEach((r) => {
|
|
1332
1350
|
Object.hasOwn(e, r) && (this[r] = e[r] ?? "");
|
|
1333
1351
|
}), super.update(e);
|
|
1334
1352
|
}
|
|
@@ -1339,16 +1357,16 @@ class Pr extends Qe {
|
|
|
1339
1357
|
publish({ actionRevision: e = this.revision + 1, modified: n = Date.now(), functions: r } = {}) {
|
|
1340
1358
|
const i = this.check({ functions: r });
|
|
1341
1359
|
if (!i.valid)
|
|
1342
|
-
throw new
|
|
1343
|
-
return this.lifecycle.transition("publication", { actionRevision: e, modified: n, stateCode:
|
|
1360
|
+
throw new ee(i.issues.map((s) => ({ ...s, layoutRef: this.layoutRef })));
|
|
1361
|
+
return this.lifecycle.transition("publication", { actionRevision: e, modified: n, stateCode: Ce.PUBLISHED }), this.requiredRoots = i.requiredRoots, this.meta.revision = e, this.setModified();
|
|
1344
1362
|
}
|
|
1345
1363
|
/** Retire this version; templates fall back to an older published version, if any. */
|
|
1346
1364
|
deprecate({ actionRevision: e = this.revision + 1, modified: n = Date.now() } = {}) {
|
|
1347
|
-
return this.lifecycle.transition("publication", { actionRevision: e, modified: n, stateCode:
|
|
1365
|
+
return this.lifecycle.transition("publication", { actionRevision: e, modified: n, stateCode: Ce.DEPRECATED }), this.meta.revision = e, this.setModified();
|
|
1348
1366
|
}
|
|
1349
1367
|
/** EntityAction for the latest publication transition. */
|
|
1350
1368
|
createEntityAction({ actionCode: e, actor: n, previousStateCode: r, timestamp: i = Date.now(), ...s } = {}) {
|
|
1351
|
-
return
|
|
1369
|
+
return nt.init({
|
|
1352
1370
|
...s,
|
|
1353
1371
|
actionCode: e,
|
|
1354
1372
|
actor: n,
|
|
@@ -1384,20 +1402,20 @@ class Pr extends Qe {
|
|
|
1384
1402
|
const e = {
|
|
1385
1403
|
_type: this._type,
|
|
1386
1404
|
...this.lifecycle ? { lifecycle: this.lifecycle.toObject() } : {},
|
|
1387
|
-
meta:
|
|
1405
|
+
meta: L(this.meta, xn),
|
|
1388
1406
|
requiredRoots: [...this.requiredRoots],
|
|
1389
|
-
...
|
|
1407
|
+
...L(this, $n)
|
|
1390
1408
|
};
|
|
1391
1409
|
return typeof this.id < "u" && (e.id = this.id), e;
|
|
1392
1410
|
}
|
|
1393
1411
|
}
|
|
1394
|
-
const
|
|
1412
|
+
const Un = Object.freeze({
|
|
1395
1413
|
memoryLimit: 1e7,
|
|
1396
1414
|
parseLimit: 1024 * 1024,
|
|
1397
1415
|
renderLimit: 1e3
|
|
1398
|
-
}),
|
|
1416
|
+
}), yt = "qw_block";
|
|
1399
1417
|
let Y = null;
|
|
1400
|
-
const
|
|
1418
|
+
const kn = {
|
|
1401
1419
|
parse(t) {
|
|
1402
1420
|
if (this.block = Y == null ? void 0 : Y[Number(t.args)], !this.block)
|
|
1403
1421
|
throw new Error(`Unknown block instance ${t.args}.`);
|
|
@@ -1407,134 +1425,134 @@ const $n = {
|
|
|
1407
1425
|
yield this.liquid.renderer.renderTemplates(this.block.templates, n, e);
|
|
1408
1426
|
}
|
|
1409
1427
|
};
|
|
1410
|
-
function
|
|
1411
|
-
const n = /* @__PURE__ */ new Map(), r = Object.freeze({ ...
|
|
1428
|
+
function zn({ maxCacheEntries: t = 500, limits: e = {} } = {}) {
|
|
1429
|
+
const n = /* @__PURE__ */ new Map(), r = Object.freeze({ ...Un, ...e });
|
|
1412
1430
|
let i = null;
|
|
1413
1431
|
const s = () => {
|
|
1414
|
-
const { filters: u, version:
|
|
1415
|
-
if ((i == null ? void 0 : i.version) ===
|
|
1432
|
+
const { filters: u, version: d } = xt();
|
|
1433
|
+
if ((i == null ? void 0 : i.version) === d)
|
|
1416
1434
|
return i;
|
|
1417
1435
|
n.clear();
|
|
1418
|
-
const
|
|
1419
|
-
const
|
|
1420
|
-
return u.forEach(({ name:
|
|
1436
|
+
const f = (_) => {
|
|
1437
|
+
const h = pt({ escape: _, limits: r, tags: [...lt, ...Re] });
|
|
1438
|
+
return u.forEach(({ name: b, handler: p, raw: T }) => h.registerFilter(b, { handler: p, raw: _ && T })), h.registerTag(yt, kn), h;
|
|
1421
1439
|
};
|
|
1422
|
-
return i = { html:
|
|
1423
|
-
}, o = ({ content: u, contentType:
|
|
1440
|
+
return i = { html: f(!0), text: f(!1), version: d }, i;
|
|
1441
|
+
}, o = ({ content: u, contentType: d, partCode: f, allowedFunctions: _, blocks: h, allowBlocks: b, cacheKey: p }) => {
|
|
1424
1442
|
s();
|
|
1425
|
-
const
|
|
1426
|
-
if (
|
|
1427
|
-
const C = n.get(
|
|
1428
|
-
return n.delete(
|
|
1443
|
+
const T = p ? `${p}\0${f}\0${d}\0${_.join(",")}` : null;
|
|
1444
|
+
if (T && n.has(T)) {
|
|
1445
|
+
const C = n.get(T);
|
|
1446
|
+
return n.delete(T), n.set(T, C), C;
|
|
1429
1447
|
}
|
|
1430
|
-
const E =
|
|
1431
|
-
return
|
|
1432
|
-
}, a = ({ content: u, contentType:
|
|
1433
|
-
const E =
|
|
1448
|
+
const E = qn({ allowBlocks: b, allowedFunctions: _, blocks: h, content: u, contentType: d, engines: s(), partCode: f });
|
|
1449
|
+
return T && (n.set(T, E), n.size > t && n.delete(n.keys().next().value)), E;
|
|
1450
|
+
}, a = ({ content: u, contentType: d = x.TEXT_HTML, partCode: f, data: _, context: h, blocks: b, cacheKey: p, allowBlocks: T = !0 } = {}) => {
|
|
1451
|
+
const E = J(h);
|
|
1434
1452
|
if (!E)
|
|
1435
1453
|
throw new TypeError("Template rendering requires a data context.");
|
|
1436
1454
|
return o({
|
|
1437
|
-
allowBlocks:
|
|
1455
|
+
allowBlocks: T,
|
|
1438
1456
|
allowedFunctions: [...E.functionNames || []].sort(),
|
|
1439
|
-
blocks:
|
|
1440
|
-
cacheKey:
|
|
1457
|
+
blocks: Kn(b),
|
|
1458
|
+
cacheKey: p,
|
|
1441
1459
|
content: u ?? "",
|
|
1442
|
-
contentType:
|
|
1443
|
-
partCode:
|
|
1460
|
+
contentType: d,
|
|
1461
|
+
partCode: f
|
|
1444
1462
|
}).render(_ || {});
|
|
1445
1463
|
};
|
|
1446
|
-
return Object.freeze({ clearCache: () => n.clear(), renderBlock: ({ block: u, params:
|
|
1447
|
-
const
|
|
1464
|
+
return Object.freeze({ clearCache: () => n.clear(), renderBlock: ({ block: u, params: d = {}, data: f, context: _ } = {}) => {
|
|
1465
|
+
const h = typeof (u == null ? void 0 : u.describe) == "function" ? u.describe() : u, b = `${h.blockCode}@${h.version}`, p = JSON.stringify(d).replace(/&/g, "&").replace(/'/g, "'");
|
|
1448
1466
|
return a({
|
|
1449
|
-
blocks: [{ ...
|
|
1450
|
-
content: `<div data-qw-block="${
|
|
1467
|
+
blocks: [{ ...h, stateCode: "PUBLISHED" }],
|
|
1468
|
+
content: `<div data-qw-block="${b}" data-qw-params='${p}'></div>`,
|
|
1451
1469
|
context: _,
|
|
1452
|
-
data:
|
|
1470
|
+
data: f,
|
|
1453
1471
|
partCode: "block"
|
|
1454
1472
|
});
|
|
1455
|
-
}, renderContent: a, renderTemplate: ({ template: u, kind:
|
|
1456
|
-
var
|
|
1457
|
-
const E = typeof (u == null ? void 0 : u.toObject) == "function" ? u.toObject() : u || {}, C =
|
|
1473
|
+
}, renderContent: a, renderTemplate: ({ template: u, kind: d, data: f, context: _, blocks: h, cacheKey: b, draft: p = !1, layouts: T = [] } = {}) => {
|
|
1474
|
+
var Fe;
|
|
1475
|
+
const E = typeof (u == null ? void 0 : u.toObject) == "function" ? u.toObject() : u || {}, C = d || ((Fe = u == null ? void 0 : u.constructor) == null ? void 0 : Fe.kind) || ft(E.templateKindCode);
|
|
1458
1476
|
if (!C)
|
|
1459
1477
|
throw new TypeError("renderTemplate requires a template kind.");
|
|
1460
|
-
|
|
1461
|
-
const
|
|
1462
|
-
return C.partDefinitions.forEach(({ partCode: $, contentType:
|
|
1463
|
-
var
|
|
1464
|
-
const
|
|
1465
|
-
if (typeof
|
|
1478
|
+
Vn(E.templateSyntaxVersion);
|
|
1479
|
+
const S = J(_), Ve = S != null && S.includeTemplateDocumentReference ? { ...f, template: { documentReference: E.documentReference ?? "" } } : f, ne = p ? null : b ?? Fn(E), be = {};
|
|
1480
|
+
return C.partDefinitions.forEach(({ partCode: $, contentType: Ee }) => {
|
|
1481
|
+
var Ke;
|
|
1482
|
+
const re = (Ke = E.partContent) == null ? void 0 : Ke[$];
|
|
1483
|
+
if (typeof re != "string" || !re)
|
|
1466
1484
|
return;
|
|
1467
|
-
if (
|
|
1468
|
-
|
|
1485
|
+
if (Ee !== x.TEXT_HTML) {
|
|
1486
|
+
be[$] = a({ blocks: h, cacheKey: ne, content: re, context: S, contentType: Ee, data: Ve, partCode: $ });
|
|
1469
1487
|
return;
|
|
1470
1488
|
}
|
|
1471
|
-
const q =
|
|
1489
|
+
const q = Ft({ html: re, layouts: T });
|
|
1472
1490
|
if (q.missingLayoutCodes.length)
|
|
1473
1491
|
throw new j({ message: `Layout ${q.missingLayoutCodes.join(", ")} has no published version.`, partCode: $ });
|
|
1474
|
-
const
|
|
1475
|
-
|
|
1476
|
-
}), { partContent:
|
|
1492
|
+
const _t = ne && q.layoutRefs.length ? `${ne}\0${q.layoutRefs.join(",")}` : ne;
|
|
1493
|
+
be[$] = a({ blocks: h, cacheKey: _t, content: q.html, context: S, contentType: Ee, data: Ve, partCode: $ });
|
|
1494
|
+
}), { partContent: be };
|
|
1477
1495
|
} });
|
|
1478
1496
|
}
|
|
1479
|
-
function
|
|
1480
|
-
if (!
|
|
1481
|
-
throw new
|
|
1497
|
+
function Vn(t = Ie) {
|
|
1498
|
+
if (!rt.includes(t))
|
|
1499
|
+
throw new ee([O({
|
|
1482
1500
|
code: y.SYNTAX_VERSION_UNSUPPORTED,
|
|
1483
1501
|
message: `Template syntax version ${t} is not supported.`
|
|
1484
1502
|
})]);
|
|
1485
1503
|
}
|
|
1486
|
-
function
|
|
1504
|
+
function Fn(t) {
|
|
1487
1505
|
const { templateCode: e, tenantCode: n, meta: r } = t;
|
|
1488
1506
|
return !e || !(r != null && r.revision) ? null : `${n || ""}\0${e}\0${r.revision}`;
|
|
1489
1507
|
}
|
|
1490
|
-
function
|
|
1508
|
+
function Kn(t = []) {
|
|
1491
1509
|
return new Map((t || []).map((e) => {
|
|
1492
1510
|
const n = typeof e.describe == "function" ? e.describe() : e;
|
|
1493
1511
|
return [`${n.blockCode}@${n.version}`, n];
|
|
1494
1512
|
}));
|
|
1495
1513
|
}
|
|
1496
|
-
function
|
|
1497
|
-
const a = new Map(
|
|
1514
|
+
function qn({ content: t, contentType: e, partCode: n, allowedFunctions: r, blocks: i, allowBlocks: s, engines: o }) {
|
|
1515
|
+
const a = new Map(me().map((p) => [p.name, p])), c = new Set(r), l = te(t, { allowBlocks: s, partCode: n }), m = (p, T) => fe(p.templates, { allowedFunctionNames: c, functionsByName: a, locate: p.locate, text: p.text, ...T }).issues, u = [...l.issues, ...m(l, {})];
|
|
1498
1516
|
if (K(u))
|
|
1499
|
-
throw new
|
|
1500
|
-
const
|
|
1501
|
-
let _ = "",
|
|
1502
|
-
|
|
1503
|
-
_ += `${
|
|
1504
|
-
}), _ +=
|
|
1505
|
-
const
|
|
1517
|
+
throw new ee(u);
|
|
1518
|
+
const d = e === x.TEXT_PLAIN ? o.text : o.html, f = l.blocks.map((p) => Gn(p, { blocks: i, engine: d, partCode: n, policy: m }));
|
|
1519
|
+
let _ = "", h = 0;
|
|
1520
|
+
l.blocks.forEach(({ start: p, end: T }, E) => {
|
|
1521
|
+
_ += `${l.text.slice(h, p)}{% ${yt} ${E} %}`, h = T;
|
|
1522
|
+
}), _ += l.text.slice(h);
|
|
1523
|
+
const b = gt(d, _, f);
|
|
1506
1524
|
return Object.freeze({
|
|
1507
|
-
render(
|
|
1525
|
+
render(p) {
|
|
1508
1526
|
try {
|
|
1509
|
-
return
|
|
1510
|
-
} catch (
|
|
1511
|
-
const E = (
|
|
1527
|
+
return d.renderSync(b, { ...p });
|
|
1528
|
+
} catch (T) {
|
|
1529
|
+
const E = (T == null ? void 0 : T.originalError) || T;
|
|
1512
1530
|
if (E instanceof j)
|
|
1513
1531
|
throw E;
|
|
1514
|
-
const C = String((E == null ? void 0 : E.message) ||
|
|
1515
|
-
throw new j({ cause:
|
|
1532
|
+
const C = String((E == null ? void 0 : E.message) || T.message).replace(/, line:\d+, col:\d+$/, "");
|
|
1533
|
+
throw new j({ cause: T, message: `Failed to render ${n || "content"}: ${C}`, partCode: n });
|
|
1516
1534
|
}
|
|
1517
1535
|
}
|
|
1518
1536
|
});
|
|
1519
1537
|
}
|
|
1520
|
-
function
|
|
1538
|
+
function Gn(t, { blocks: e, engine: n, partCode: r, policy: i }) {
|
|
1521
1539
|
const { blockRef: s } = t, o = e.get(s);
|
|
1522
1540
|
if (!o || typeof o.fragment != "string")
|
|
1523
1541
|
throw new j({ message: `Block ${s} is not available for rendering.`, partCode: r, source: s });
|
|
1524
1542
|
if (o.stateCode === "DRAFT")
|
|
1525
1543
|
throw new j({ message: `Block ${s} is not published.`, partCode: r, source: s });
|
|
1526
|
-
const { definitions: a, errors:
|
|
1527
|
-
if (
|
|
1528
|
-
throw new j({ message: `Block ${s} params are invalid: ${[...
|
|
1529
|
-
const u =
|
|
1530
|
-
if (K(
|
|
1531
|
-
throw new
|
|
1544
|
+
const { definitions: a, errors: c } = Z(o.params), { errors: l, values: m } = mt(a, t.params);
|
|
1545
|
+
if (c.length || l.length)
|
|
1546
|
+
throw new j({ message: `Block ${s} params are invalid: ${[...c, ...l].join(" ")}`, partCode: r, source: s });
|
|
1547
|
+
const u = te(o.fragment, { allowBlocks: !1 }), d = [...u.issues, ...i(u, { allowAssign: !0, variables: /* @__PURE__ */ new Map([[F, null]]) })];
|
|
1548
|
+
if (K(d))
|
|
1549
|
+
throw new ee(d.map((f) => ({ ...f, blockRef: s })));
|
|
1532
1550
|
return {
|
|
1533
|
-
params: Object.freeze(
|
|
1534
|
-
templates:
|
|
1551
|
+
params: Object.freeze(dn(a, m)),
|
|
1552
|
+
templates: gt(n, u.text, [])
|
|
1535
1553
|
};
|
|
1536
1554
|
}
|
|
1537
|
-
function
|
|
1555
|
+
function gt(t, e, n) {
|
|
1538
1556
|
Y = n;
|
|
1539
1557
|
try {
|
|
1540
1558
|
return t.parse(e);
|
|
@@ -1542,49 +1560,49 @@ function Tt(t, e, n) {
|
|
|
1542
1560
|
Y = null;
|
|
1543
1561
|
}
|
|
1544
1562
|
}
|
|
1545
|
-
const
|
|
1546
|
-
async function
|
|
1547
|
-
const
|
|
1563
|
+
const Wn = /^[^\s@<>()[\]\\,;:"]+@[^\s"(),:;<>@[\\\]][^\s"(),.:;<>@[\\\]]*\.[^\s"(),:;<>@[\\\]]+$/, Hn = /cid:([^\s"'<>)]+)/g, Yn = zn();
|
|
1564
|
+
async function vr({ template: t, data: e, context: n, blocks: r, layouts: i, renderer: s = Yn, resolveInlineImage: o, juiceOptions: a, draft: c = !1 } = {}) {
|
|
1565
|
+
const l = typeof (t == null ? void 0 : t.toObject) == "function" ? t.toObject() : t || {}, { partContent: m } = s.renderTemplate({ blocks: r, context: n, data: e, draft: c, kind: Me, layouts: i, template: l }), u = (b, p) => s.renderContent({
|
|
1548
1566
|
allowBlocks: !1,
|
|
1549
|
-
content:
|
|
1567
|
+
content: b,
|
|
1550
1568
|
context: n,
|
|
1551
1569
|
contentType: x.TEXT_PLAIN,
|
|
1552
1570
|
data: e,
|
|
1553
|
-
partCode:
|
|
1554
|
-
}).trim(),
|
|
1555
|
-
if (!(
|
|
1571
|
+
partCode: p
|
|
1572
|
+
}).trim(), d = (b, p, { fixedEmail: T = !1 } = {}) => {
|
|
1573
|
+
if (!(b != null && b.email))
|
|
1556
1574
|
return null;
|
|
1557
|
-
if (
|
|
1558
|
-
throw new j({ message: `${
|
|
1559
|
-
const E =
|
|
1575
|
+
if (T && /\{\{|\{%/.test(b.email))
|
|
1576
|
+
throw new j({ message: `${p}.email must be a fixed address.`, partCode: `${p}.email` });
|
|
1577
|
+
const E = T ? b.email.trim() : u(b.email, `${p}.email`);
|
|
1560
1578
|
if (!E)
|
|
1561
1579
|
return null;
|
|
1562
|
-
if (!
|
|
1563
|
-
throw new j({ message: `${
|
|
1564
|
-
const C =
|
|
1580
|
+
if (!Wn.test(E))
|
|
1581
|
+
throw new j({ message: `${p}.email "${E}" is not a valid email address.`, partCode: `${p}.email` });
|
|
1582
|
+
const C = b.name ? u(b.name, `${p}.name`) : "";
|
|
1565
1583
|
return { email: E, ...C ? { name: C } : {} };
|
|
1566
|
-
},
|
|
1567
|
-
let _ =
|
|
1568
|
-
const
|
|
1569
|
-
if (o &&
|
|
1570
|
-
const
|
|
1571
|
-
|
|
1572
|
-
T
|
|
1584
|
+
}, f = (b, p) => (Array.isArray(b) ? b : []).map((T, E) => d(typeof T == "string" ? { email: T } : T, `${p}[${E}]`)).filter(Boolean);
|
|
1585
|
+
let _ = m.html ? Nt(m.html, { preserveImportant: !0, preserveMediaQueries: !0, ...a }) : "";
|
|
1586
|
+
const h = [...new Set([..._.matchAll(Hn)].map((b) => b[1]))];
|
|
1587
|
+
if (o && h.length) {
|
|
1588
|
+
const b = await Promise.all(h.map((p) => o({ contentId: p })));
|
|
1589
|
+
h.forEach((p, T) => {
|
|
1590
|
+
b[T] && (_ = _.split(`cid:${p}`).join(b[T]));
|
|
1573
1591
|
});
|
|
1574
1592
|
}
|
|
1575
1593
|
return {
|
|
1576
|
-
bcc:
|
|
1577
|
-
cc:
|
|
1578
|
-
from:
|
|
1594
|
+
bcc: f(l.bcc, "bcc"),
|
|
1595
|
+
cc: f(l.cc, "cc"),
|
|
1596
|
+
from: d(l.from, "from", { fixedEmail: !0 }),
|
|
1579
1597
|
html: _,
|
|
1580
|
-
inlineAttachments:
|
|
1581
|
-
replyTo:
|
|
1582
|
-
subject: (
|
|
1583
|
-
text:
|
|
1584
|
-
to:
|
|
1598
|
+
inlineAttachments: h.map((b) => ({ contentId: b })),
|
|
1599
|
+
replyTo: d(l.replyTo, "replyTo"),
|
|
1600
|
+
subject: (m.subject || "").replace(/\s+/g, " ").trim(),
|
|
1601
|
+
text: m.text ?? null,
|
|
1602
|
+
to: d(l.to, "to", { fixedEmail: !0 })
|
|
1585
1603
|
};
|
|
1586
1604
|
}
|
|
1587
|
-
const
|
|
1605
|
+
const Xn = Object.freeze({
|
|
1588
1606
|
blockCode: "INVOICE_LINES_TABLE",
|
|
1589
1607
|
category: "Invoice",
|
|
1590
1608
|
contextCode: "RECEIPT",
|
|
@@ -1600,7 +1618,7 @@ const Wn = Object.freeze({
|
|
|
1600
1618
|
name: "Invoice lines (fixed)",
|
|
1601
1619
|
params: [],
|
|
1602
1620
|
version: 1
|
|
1603
|
-
}),
|
|
1621
|
+
}), Qn = Object.freeze({
|
|
1604
1622
|
blockCode: "INVOICE_LINES_TABLE",
|
|
1605
1623
|
category: "Invoice",
|
|
1606
1624
|
contextCode: "RECEIPT",
|
|
@@ -1652,7 +1670,7 @@ const Wn = Object.freeze({
|
|
|
1652
1670
|
{ default: !0, label: "Show total", paramCode: "showTotal", type: "boolean" }
|
|
1653
1671
|
],
|
|
1654
1672
|
version: 2
|
|
1655
|
-
}),
|
|
1673
|
+
}), Jn = Object.freeze({
|
|
1656
1674
|
blockCode: "AUTHOR_LIST",
|
|
1657
1675
|
category: "Abstract",
|
|
1658
1676
|
contextCode: "ABSTRACT",
|
|
@@ -1670,7 +1688,7 @@ const Wn = Object.freeze({
|
|
|
1670
1688
|
{ default: !0, label: "Show affiliation", paramCode: "showAffiliation", type: "boolean" }
|
|
1671
1689
|
],
|
|
1672
1690
|
version: 1
|
|
1673
|
-
}),
|
|
1691
|
+
}), Zn = Object.freeze({
|
|
1674
1692
|
blockCode: "AUTHOR_LIST",
|
|
1675
1693
|
category: "Abstract",
|
|
1676
1694
|
contextCode: "ABSTRACT",
|
|
@@ -1708,16 +1726,16 @@ const Wn = Object.freeze({
|
|
|
1708
1726
|
],
|
|
1709
1727
|
version: 2
|
|
1710
1728
|
});
|
|
1711
|
-
function
|
|
1712
|
-
const e = (n) =>
|
|
1729
|
+
function jr({ modified: t = Date.UTC(2027, 0, 1) } = {}) {
|
|
1730
|
+
const e = (n) => vn.create({ ...n, modified: t }).publish({ modified: t });
|
|
1713
1731
|
return [
|
|
1714
|
-
e(
|
|
1715
|
-
e(
|
|
1716
|
-
e(
|
|
1717
|
-
e(
|
|
1732
|
+
e(Xn).deprecate({ modified: t }),
|
|
1733
|
+
e(Qn),
|
|
1734
|
+
e(Jn),
|
|
1735
|
+
e(Zn)
|
|
1718
1736
|
];
|
|
1719
1737
|
}
|
|
1720
|
-
const
|
|
1738
|
+
const he = B({
|
|
1721
1739
|
fields: {
|
|
1722
1740
|
code: { description: "The recipient's event registration code.", label: "Registration code", type: "string" },
|
|
1723
1741
|
displayName: { description: "Prefix, first name and last name, for greetings.", label: "Display name", type: "string", value: (t) => [t.prefix, t.firstName, t.lastName].filter(Boolean).join(" ") },
|
|
@@ -1729,7 +1747,7 @@ const fe = B({
|
|
|
1729
1747
|
description: "Current email recipient values.",
|
|
1730
1748
|
label: "Recipient",
|
|
1731
1749
|
projectionCode: "PERSON"
|
|
1732
|
-
}),
|
|
1750
|
+
}), Te = B({
|
|
1733
1751
|
fields: {
|
|
1734
1752
|
badge: {
|
|
1735
1753
|
fields: {
|
|
@@ -1748,7 +1766,7 @@ const fe = B({
|
|
|
1748
1766
|
description: "Current congress or event display information.",
|
|
1749
1767
|
label: "Event",
|
|
1750
1768
|
projectionCode: "EVENT"
|
|
1751
|
-
}),
|
|
1769
|
+
}), er = B({
|
|
1752
1770
|
fields: {
|
|
1753
1771
|
amount: { description: "Amount of the line: quantity times unit price.", label: "Amount", type: "number" },
|
|
1754
1772
|
name: { description: "Name of the item bought.", label: "Item", type: "string", value: (t) => {
|
|
@@ -1761,19 +1779,19 @@ const fe = B({
|
|
|
1761
1779
|
description: "One line of an invoice.",
|
|
1762
1780
|
label: "Invoice line",
|
|
1763
1781
|
projectionCode: "INVOICE_LINE"
|
|
1764
|
-
}),
|
|
1782
|
+
}), tr = B({
|
|
1765
1783
|
fields: {
|
|
1766
1784
|
created: { description: "Date the invoice was issued.", label: "Invoice date", type: "date" },
|
|
1767
1785
|
currencyCode: { description: "Currency code of the invoice, such as AUD.", label: "Currency", type: "string" },
|
|
1768
1786
|
invoiceNumber: { description: "Number printed on the invoice.", label: "Invoice number", type: "string" },
|
|
1769
|
-
lines:
|
|
1787
|
+
lines: ve(er, { description: "Items bought on the invoice.", label: "Lines" }),
|
|
1770
1788
|
revisionNumber: { description: "Revision of the invoice; 0 for the first issue.", label: "Revision", type: "number" },
|
|
1771
1789
|
total: { description: "Sum of all invoice lines.", label: "Total", type: "number", value: (t) => (t.lines || []).reduce((e, n) => e + (n.amount || 0), 0) }
|
|
1772
1790
|
},
|
|
1773
1791
|
description: "Invoice header and number values.",
|
|
1774
1792
|
label: "Invoice",
|
|
1775
1793
|
projectionCode: "INVOICE"
|
|
1776
|
-
}),
|
|
1794
|
+
}), nr = B({
|
|
1777
1795
|
fields: {
|
|
1778
1796
|
paidAmount: { description: "Amount paid in this payment.", label: "Paid amount", type: "number" },
|
|
1779
1797
|
paymentDate: { description: "Date the payment was made.", label: "Payment date", type: "date" },
|
|
@@ -1784,7 +1802,7 @@ const fe = B({
|
|
|
1784
1802
|
description: "Payment result, paid amount and payment details.",
|
|
1785
1803
|
label: "Payment result",
|
|
1786
1804
|
projectionCode: "PAYMENT_RESULT"
|
|
1787
|
-
}),
|
|
1805
|
+
}), rr = B({
|
|
1788
1806
|
fields: {
|
|
1789
1807
|
affiliation: { description: "The author's institution.", label: "Affiliation", type: "string" },
|
|
1790
1808
|
capacity: { description: "The author's role on the abstract, such as co-author.", label: "Capacity", type: "string" },
|
|
@@ -1795,10 +1813,10 @@ const fe = B({
|
|
|
1795
1813
|
description: "One author of an abstract.",
|
|
1796
1814
|
label: "Author",
|
|
1797
1815
|
projectionCode: "AUTHOR"
|
|
1798
|
-
}),
|
|
1816
|
+
}), ir = B({
|
|
1799
1817
|
fields: {
|
|
1800
1818
|
abstractCode: { description: "Reference ID of the submitted abstract.", label: "Abstract code", type: "string" },
|
|
1801
|
-
authors:
|
|
1819
|
+
authors: ve(rr, { description: "Authors attached to the abstract.", label: "Authors" }),
|
|
1802
1820
|
conclusions: { description: "Conclusions section of the abstract.", label: "Conclusions", type: "string" },
|
|
1803
1821
|
keywords: { description: "Keywords given by the submitter.", label: "Keywords", type: "string" },
|
|
1804
1822
|
methods: { description: "Methods section of the abstract.", label: "Methods", type: "string" },
|
|
@@ -1812,27 +1830,27 @@ const fe = B({
|
|
|
1812
1830
|
description: "Abstract submission values.",
|
|
1813
1831
|
label: "Abstract",
|
|
1814
1832
|
projectionCode: "ABSTRACT"
|
|
1815
|
-
}),
|
|
1833
|
+
}), sr = B({
|
|
1816
1834
|
fields: {
|
|
1817
1835
|
eventRegistrationCode: { description: "Code of the event registration.", label: "Registration code", type: "string" },
|
|
1818
1836
|
hasBadge: { description: "Whether the registration includes a badge.", label: "Has badge", type: "boolean" },
|
|
1819
|
-
roleCodes:
|
|
1837
|
+
roleCodes: ve({ label: "Role", type: "string" }, { description: "Role codes of the registration.", label: "Roles" })
|
|
1820
1838
|
},
|
|
1821
1839
|
description: "Event registration profile values.",
|
|
1822
1840
|
label: "Event registration",
|
|
1823
1841
|
projectionCode: "EVENT_REGISTRATION"
|
|
1824
|
-
}),
|
|
1842
|
+
}), ke = Object.freeze({
|
|
1825
1843
|
badge: { barcodeFormat: "QR_CODE" },
|
|
1826
1844
|
displayDate: "27-30 August 2027",
|
|
1827
1845
|
isOnline: !1,
|
|
1828
1846
|
location: "Example Convention Centre",
|
|
1829
1847
|
name: "Example Congress 2027",
|
|
1830
1848
|
websiteUrl: "https://congress.example.org"
|
|
1831
|
-
}),
|
|
1849
|
+
}), ze = Object.freeze({
|
|
1832
1850
|
"ER-1001": { code: "ER-1001", email: "alex.chan@example.org", firstName: "Alex", lastName: "Chan", prefix: "Dr" },
|
|
1833
1851
|
"ER-1002": { code: "ER-1002", email: "sam.wong@example.org", firstName: "Sam", lastName: "Wong", prefix: "Prof" },
|
|
1834
1852
|
"ER-1003": { code: "ER-1003", email: "kim.lee@example.org", firstName: "Kim", lastName: "Lee", prefix: "" }
|
|
1835
|
-
}),
|
|
1853
|
+
}), or = Object.freeze({
|
|
1836
1854
|
"INV-2027-0001": {
|
|
1837
1855
|
created: Date.UTC(2027, 2, 14),
|
|
1838
1856
|
currencyCode: "HKD",
|
|
@@ -1846,7 +1864,7 @@ const fe = B({
|
|
|
1846
1864
|
paymentResult: { paidAmount: 3200, paymentDate: Date.UTC(2027, 2, 15), paymentMethod: "Credit card", paymentRemark: "Paid online", receivedAmount: 3200 },
|
|
1847
1865
|
revisionNumber: 1
|
|
1848
1866
|
}
|
|
1849
|
-
}),
|
|
1867
|
+
}), ar = Object.freeze({
|
|
1850
1868
|
"ABS-0042": {
|
|
1851
1869
|
abstractCode: "ABS-0042",
|
|
1852
1870
|
authors: [
|
|
@@ -1866,24 +1884,24 @@ Methods
|
|
|
1866
1884
|
Results`,
|
|
1867
1885
|
title: "Outcomes of an example study"
|
|
1868
1886
|
}
|
|
1869
|
-
}),
|
|
1887
|
+
}), cr = Object.freeze({
|
|
1870
1888
|
"ER-1001": { eventRegistrationCode: "ER-1001", hasBadge: !0, roleCodes: ["REGISTRANT", "DELEGATE"] }
|
|
1871
1889
|
}), M = Object.freeze({
|
|
1872
1890
|
ALL_AUTHORS: "ALL_AUTHORS",
|
|
1873
1891
|
PRESENTER: "PRESENTER",
|
|
1874
1892
|
SUBMITTER: "SUBMITTER"
|
|
1875
|
-
}),
|
|
1893
|
+
}), lr = pe({
|
|
1876
1894
|
contextCode: "ABSTRACT",
|
|
1877
1895
|
functionNames: ["__format_date", "__multiline"],
|
|
1878
1896
|
loadData: async ({ subjectRef: t, recipientType: e }) => {
|
|
1879
|
-
const n =
|
|
1897
|
+
const n = ar[t];
|
|
1880
1898
|
return n ? {
|
|
1881
1899
|
[M.ALL_AUTHORS]: n.authors.map((i) => i.registrationCode),
|
|
1882
1900
|
[M.PRESENTER]: n.authors.filter((i) => i.isPresenter).map((i) => i.registrationCode),
|
|
1883
1901
|
[M.SUBMITTER]: [n.submitterCode]
|
|
1884
1902
|
}[e].map((i) => ({
|
|
1885
1903
|
recipientRef: i,
|
|
1886
|
-
roots: { abstract: n, event:
|
|
1904
|
+
roots: { abstract: n, event: ke, recipient: ze[i] }
|
|
1887
1905
|
})) : [];
|
|
1888
1906
|
},
|
|
1889
1907
|
name: "Abstract",
|
|
@@ -1893,9 +1911,9 @@ Results`,
|
|
|
1893
1911
|
{ name: "All authors", recipientType: M.ALL_AUTHORS }
|
|
1894
1912
|
],
|
|
1895
1913
|
roots: {
|
|
1896
|
-
abstract:
|
|
1897
|
-
event:
|
|
1898
|
-
recipient:
|
|
1914
|
+
abstract: ir,
|
|
1915
|
+
event: Te,
|
|
1916
|
+
recipient: he
|
|
1899
1917
|
},
|
|
1900
1918
|
sampleData: {
|
|
1901
1919
|
abstract: {
|
|
@@ -1919,19 +1937,19 @@ Line two`,
|
|
|
1919
1937
|
recipient: { code: "ER-0001", displayName: "Dr Alex Chan", email: "alex.chan@example.org", firstName: "Alex", lastName: "Chan", prefix: "Dr" }
|
|
1920
1938
|
},
|
|
1921
1939
|
subjectType: "Abstract"
|
|
1922
|
-
}),
|
|
1940
|
+
}), ur = pe({
|
|
1923
1941
|
contextCode: "EVENT_REGISTRATION",
|
|
1924
1942
|
functionNames: ["__barcode", "__format_date"],
|
|
1925
1943
|
loadData: async ({ subjectRef: t }) => {
|
|
1926
|
-
const e =
|
|
1927
|
-
return e ? [{ recipientRef: t, roots: { event:
|
|
1944
|
+
const e = cr[t];
|
|
1945
|
+
return e ? [{ recipientRef: t, roots: { event: ke, eventRegistration: e, recipient: ze[t] } }] : [];
|
|
1928
1946
|
},
|
|
1929
1947
|
name: "Event registration",
|
|
1930
1948
|
recipientRules: [{ name: "Registrant", recipientType: "REGISTRANT" }],
|
|
1931
1949
|
roots: {
|
|
1932
|
-
event:
|
|
1933
|
-
eventRegistration:
|
|
1934
|
-
recipient:
|
|
1950
|
+
event: Te,
|
|
1951
|
+
eventRegistration: sr,
|
|
1952
|
+
recipient: he
|
|
1935
1953
|
},
|
|
1936
1954
|
sampleData: {
|
|
1937
1955
|
event: { badge: { barcodeFormat: "QR_CODE" }, displayDate: "27-30 August 2027", isOnline: !1, location: "Sample Venue", name: "Sample Congress", websiteUrl: "https://congress.example.org" },
|
|
@@ -1939,20 +1957,20 @@ Line two`,
|
|
|
1939
1957
|
recipient: { code: "ER-0001", displayName: "Dr Alex Chan", email: "alex.chan@example.org", firstName: "Alex", lastName: "Chan", prefix: "Dr" }
|
|
1940
1958
|
},
|
|
1941
1959
|
subjectType: "EventRegistration"
|
|
1942
|
-
}),
|
|
1960
|
+
}), dr = pe({
|
|
1943
1961
|
contextCode: "RECEIPT",
|
|
1944
1962
|
functionNames: ["__format_date", "__format_money"],
|
|
1945
1963
|
loadData: async ({ subjectRef: t }) => {
|
|
1946
|
-
const e =
|
|
1947
|
-
return e ? [{ recipientRef: e.payerCode, roots: { event:
|
|
1964
|
+
const e = or[t];
|
|
1965
|
+
return e ? [{ recipientRef: e.payerCode, roots: { event: ke, invoice: e, paymentResult: e.paymentResult, recipient: ze[e.payerCode] } }] : [];
|
|
1948
1966
|
},
|
|
1949
1967
|
name: "Receipt",
|
|
1950
1968
|
recipientRules: [{ name: "Payer", recipientType: "PAYER" }],
|
|
1951
1969
|
roots: {
|
|
1952
|
-
event:
|
|
1953
|
-
invoice:
|
|
1954
|
-
paymentResult:
|
|
1955
|
-
recipient:
|
|
1970
|
+
event: Te,
|
|
1971
|
+
invoice: tr,
|
|
1972
|
+
paymentResult: nr,
|
|
1973
|
+
recipient: he
|
|
1956
1974
|
},
|
|
1957
1975
|
sampleData: {
|
|
1958
1976
|
event: { badge: { barcodeFormat: "QR_CODE" }, displayDate: "27-30 August 2027", isOnline: !1, location: "Sample Venue", name: "Sample Congress", websiteUrl: "https://congress.example.org" },
|
|
@@ -1971,35 +1989,35 @@ Line two`,
|
|
|
1971
1989
|
recipient: { code: "ER-0001", displayName: "Dr Alex Chan", email: "alex.chan@example.org", firstName: "Alex", lastName: "Chan", prefix: "Dr" }
|
|
1972
1990
|
},
|
|
1973
1991
|
subjectType: "Invoice"
|
|
1974
|
-
}),
|
|
1992
|
+
}), Br = pe({
|
|
1975
1993
|
contextCode: "LAYOUT",
|
|
1976
1994
|
functionNames: ["__format_date"],
|
|
1977
1995
|
name: "Layout (every email)",
|
|
1978
1996
|
roots: {
|
|
1979
|
-
event:
|
|
1980
|
-
recipient:
|
|
1997
|
+
event: Te,
|
|
1998
|
+
recipient: he
|
|
1981
1999
|
},
|
|
1982
2000
|
sampleData: {
|
|
1983
2001
|
event: { badge: { barcodeFormat: "QR_CODE" }, displayDate: "27-30 August 2027", isOnline: !1, location: "Sample Venue", name: "Sample Congress", websiteUrl: "https://congress.example.org" },
|
|
1984
2002
|
recipient: { code: "ER-0001", displayName: "Dr Alex Chan", email: "alex.chan@example.org", firstName: "Alex", lastName: "Chan", prefix: "Dr" }
|
|
1985
2003
|
}
|
|
1986
|
-
}),
|
|
1987
|
-
ABSTRACT:
|
|
1988
|
-
EVENT_REGISTRATION:
|
|
1989
|
-
RECEIPT:
|
|
1990
|
-
}),
|
|
2004
|
+
}), pr = Object.freeze({
|
|
2005
|
+
ABSTRACT: lr,
|
|
2006
|
+
EVENT_REGISTRATION: ur,
|
|
2007
|
+
RECEIPT: dr
|
|
2008
|
+
}), mr = Object.freeze({
|
|
1991
2009
|
ABSTRACT: "ABSTRACT",
|
|
1992
2010
|
EVENT_REGISTRATION: "EVENT_REGISTRATION",
|
|
1993
2011
|
RECEIPT: "RECEIPT",
|
|
1994
2012
|
STORE: "RECEIPT"
|
|
1995
2013
|
});
|
|
1996
2014
|
function Pe(t) {
|
|
1997
|
-
return
|
|
2015
|
+
return mr[t] || null;
|
|
1998
2016
|
}
|
|
1999
|
-
function
|
|
2000
|
-
return
|
|
2017
|
+
function xr(t) {
|
|
2018
|
+
return pr[Pe(t)] || null;
|
|
2001
2019
|
}
|
|
2002
|
-
const
|
|
2020
|
+
const fr = Object.freeze([
|
|
2003
2021
|
{
|
|
2004
2022
|
description: "Format an amount with a currency code, e.g. HKD 1,200.00.",
|
|
2005
2023
|
fn: (t, e) => {
|
|
@@ -2035,13 +2053,13 @@ const dr = Object.freeze([
|
|
|
2035
2053
|
trustedHtml: !0
|
|
2036
2054
|
}
|
|
2037
2055
|
]);
|
|
2038
|
-
function
|
|
2039
|
-
const t = new Set(
|
|
2040
|
-
|
|
2041
|
-
t.has(e.name) ||
|
|
2056
|
+
function $r() {
|
|
2057
|
+
const t = new Set(me().map(({ name: e }) => e));
|
|
2058
|
+
fr.forEach((e) => {
|
|
2059
|
+
t.has(e.name) || Bt(e);
|
|
2042
2060
|
});
|
|
2043
2061
|
}
|
|
2044
|
-
const
|
|
2062
|
+
const hr = Object.freeze({
|
|
2045
2063
|
description: "Event banner across the top of the email.",
|
|
2046
2064
|
eventShortCode: "EXAMPLE2027",
|
|
2047
2065
|
html: '<img src="https://congress.2026.apvrs.org/userfile/apvrs/img/apvrs2026/banner.png" alt="{{ event.name }}" width="600" style="display: block; width: 100%; height: auto; border: 0;">',
|
|
@@ -2049,7 +2067,7 @@ const pr = Object.freeze({
|
|
|
2049
2067
|
name: "APVRS header",
|
|
2050
2068
|
tenantCode: "example",
|
|
2051
2069
|
version: 1
|
|
2052
|
-
}),
|
|
2070
|
+
}), Tr = Object.freeze({
|
|
2053
2071
|
description: "Event name, dates and website below the content.",
|
|
2054
2072
|
eventShortCode: "EXAMPLE2027",
|
|
2055
2073
|
html: '<p style="margin: 24px 0 0; padding-top: 12px; border-top: 1px solid #dddddd; font-size: 16px; color: #666666;">{{ event.name }} · {{ event.displayDate }} · <a href="{{ event.websiteUrl }}">{{ event.websiteUrl }}</a></p>',
|
|
@@ -2057,7 +2075,7 @@ const pr = Object.freeze({
|
|
|
2057
2075
|
name: "Congress footer",
|
|
2058
2076
|
tenantCode: "example",
|
|
2059
2077
|
version: 1
|
|
2060
|
-
}),
|
|
2078
|
+
}), br = Object.freeze({
|
|
2061
2079
|
description: "APVRS 2026 venue and copyright lines for the footer row of the email frame.",
|
|
2062
2080
|
eventShortCode: "EXAMPLE2027",
|
|
2063
2081
|
html: '<p style="margin: 0; font-size: 12px; line-height: 1.5; color: #888888;">APVRS 2026 Gold Coast · Gold Coast Convention & Exhibition Centre, Queensland, Australia<br>© 2026 Asia-Pacific Vitreo-Retina Society. All rights reserved.</p>',
|
|
@@ -2065,8 +2083,8 @@ const pr = Object.freeze({
|
|
|
2065
2083
|
name: "APVRS footer",
|
|
2066
2084
|
tenantCode: "example",
|
|
2067
2085
|
version: 1
|
|
2068
|
-
}),
|
|
2069
|
-
class
|
|
2086
|
+
}), Mr = Object.freeze([hr, Tr, br]), Er = ["mobileWalletBadgePass", "subTemplateGroupName", "templateGroupName"];
|
|
2087
|
+
class Ur extends Bn {
|
|
2070
2088
|
constructor(e = {}) {
|
|
2071
2089
|
e = e || {}, super({ ...e, contextCode: Pe(e.templateGroupName) || e.contextCode }), this._type = e._type || "TemplateEmailCongress", this.eventShortCode = e.eventShortCode, this.mobileWalletBadgePass = !!e.mobileWalletBadgePass, this.subTemplateGroupName = e.subTemplateGroupName || null, this.templateGroupName = e.templateGroupName;
|
|
2072
2090
|
}
|
|
@@ -2077,7 +2095,7 @@ class xr extends Dn {
|
|
|
2077
2095
|
return super.isValid && !!this.eventShortCode && !!this.templateGroupName;
|
|
2078
2096
|
}
|
|
2079
2097
|
update(e = {}) {
|
|
2080
|
-
return
|
|
2098
|
+
return Er.forEach((n) => {
|
|
2081
2099
|
Object.hasOwn(e, n) && (this[n] = n === "mobileWalletBadgePass" ? !!e[n] : e[n]);
|
|
2082
2100
|
}), Object.hasOwn(e, "templateGroupName") && (this.contextCode = Pe(e.templateGroupName)), super.update(e);
|
|
2083
2101
|
}
|
|
@@ -2091,7 +2109,7 @@ class xr extends Dn {
|
|
|
2091
2109
|
};
|
|
2092
2110
|
}
|
|
2093
2111
|
}
|
|
2094
|
-
const
|
|
2112
|
+
const kr = Object.freeze({
|
|
2095
2113
|
bcc: [{ email: "finance@congress.example.org" }],
|
|
2096
2114
|
eventShortCode: "EXAMPLE2027",
|
|
2097
2115
|
from: { email: "secretariat@congress.example.org", name: "{{ event.name }} Secretariat" },
|
|
@@ -2118,7 +2136,7 @@ const $r = Object.freeze({
|
|
|
2118
2136
|
templateCode: "RECEIPT.EVENT.paymentCompleted",
|
|
2119
2137
|
templateGroupName: "RECEIPT",
|
|
2120
2138
|
tenantCode: "example"
|
|
2121
|
-
}),
|
|
2139
|
+
}), zr = Object.freeze({
|
|
2122
2140
|
eventShortCode: "EXAMPLE2027",
|
|
2123
2141
|
meta: { revision: 1 },
|
|
2124
2142
|
name: "Submission acknowledgement",
|
|
@@ -2137,7 +2155,7 @@ const $r = Object.freeze({
|
|
|
2137
2155
|
templateCode: "ABSTRACT.submissionAcknowledgement",
|
|
2138
2156
|
templateGroupName: "ABSTRACT",
|
|
2139
2157
|
tenantCode: "example"
|
|
2140
|
-
}),
|
|
2158
|
+
}), Vr = Object.freeze({
|
|
2141
2159
|
eventShortCode: "EXAMPLE2027",
|
|
2142
2160
|
meta: { revision: 1 },
|
|
2143
2161
|
mobileWalletBadgePass: !0,
|
|
@@ -2161,105 +2179,105 @@ const $r = Object.freeze({
|
|
|
2161
2179
|
tenantCode: "example"
|
|
2162
2180
|
});
|
|
2163
2181
|
export {
|
|
2164
|
-
|
|
2182
|
+
zr as ABSTRACT_ACKNOWLEDGEMENT_TEMPLATE,
|
|
2165
2183
|
M as ABSTRACT_RECIPIENT_TYPE,
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2184
|
+
br as APVRS_FOOTER_V1,
|
|
2185
|
+
hr as APVRS_HEADER_V1,
|
|
2186
|
+
Jn as AUTHOR_LIST_V1,
|
|
2187
|
+
Zn as AUTHOR_LIST_V2,
|
|
2170
2188
|
k as BLOCK_ATTRIBUTE,
|
|
2171
|
-
|
|
2189
|
+
Ne as BLOCK_PARAMS_ATTRIBUTE,
|
|
2172
2190
|
F as BLOCK_PARAMS_ROOT,
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2191
|
+
pr as CONGRESS_CONTEXTS,
|
|
2192
|
+
Tr as CONGRESS_FOOTER_V1,
|
|
2193
|
+
Mr as CONGRESS_LAYOUTS,
|
|
2194
|
+
fr as CONGRESS_TEMPLATE_FUNCTIONS,
|
|
2195
|
+
Dt as DataContext,
|
|
2196
|
+
Xn as INVOICE_LINES_TABLE_V1,
|
|
2197
|
+
Qn as INVOICE_LINES_TABLE_V2,
|
|
2198
|
+
st as LAYOUT_ATTRIBUTE,
|
|
2199
|
+
Le as LifecycleTemplateBlock,
|
|
2200
|
+
Ze as LifecycleTemplateLayout,
|
|
2201
|
+
kr as RECEIPT_TEMPLATE,
|
|
2202
|
+
Vr as REGISTRATION_CONFIRMATION_TEMPLATE,
|
|
2203
|
+
ar as SAMPLE_ABSTRACTS,
|
|
2204
|
+
ke as SAMPLE_EVENT,
|
|
2205
|
+
or as SAMPLE_INVOICES,
|
|
2206
|
+
ze as SAMPLE_PEOPLE,
|
|
2207
|
+
cr as SAMPLE_REGISTRATIONS,
|
|
2208
|
+
rt as SUPPORTED_TEMPLATE_SYNTAX_VERSIONS,
|
|
2209
|
+
Pr as TEMPLATE_BLOCK_ACTION_CODE,
|
|
2192
2210
|
R as TEMPLATE_BLOCK_PARAM_TYPE,
|
|
2193
2211
|
z as TEMPLATE_BLOCK_STATE_CODE,
|
|
2194
|
-
|
|
2212
|
+
ut as TEMPLATE_BUILTIN_FILTERS,
|
|
2195
2213
|
x as TEMPLATE_CONTENT_TYPE,
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2214
|
+
Me as TEMPLATE_EMAIL_KIND,
|
|
2215
|
+
Un as TEMPLATE_EVALUATION_LIMITS,
|
|
2216
|
+
I as TEMPLATE_FIELD_KIND,
|
|
2217
|
+
P as TEMPLATE_FIELD_TYPE,
|
|
2218
|
+
Re as TEMPLATE_FRAGMENT_TAGS,
|
|
2201
2219
|
U as TEMPLATE_FUNCTION_ARG_TYPE,
|
|
2202
2220
|
y as TEMPLATE_ISSUE_CODE,
|
|
2203
2221
|
X as TEMPLATE_ISSUE_SEVERITY,
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2222
|
+
$e as TEMPLATE_KIND_CODE,
|
|
2223
|
+
Ir as TEMPLATE_LAYOUT_ACTION_CODE,
|
|
2224
|
+
Ce as TEMPLATE_LAYOUT_STATE_CODE,
|
|
2225
|
+
Ie as TEMPLATE_SYNTAX_VERSION,
|
|
2226
|
+
lt as TEMPLATE_TAGS,
|
|
2227
|
+
an as Template,
|
|
2228
|
+
vn as TemplateBlock,
|
|
2229
|
+
Bn as TemplateEmail,
|
|
2230
|
+
Ur as TemplateEmailCongress,
|
|
2231
|
+
Dr as TemplateLayout,
|
|
2232
|
+
it as TemplateProjection,
|
|
2215
2233
|
j as TemplateRenderError,
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2234
|
+
ee as TemplateSyntaxError,
|
|
2235
|
+
lr as abstractContext,
|
|
2236
|
+
ir as abstractProjection,
|
|
2237
|
+
rr as authorProjection,
|
|
2238
|
+
Sn as checkBlockFragment,
|
|
2239
|
+
Lr as checkTemplate,
|
|
2240
|
+
wr as checkTemplateContent,
|
|
2241
|
+
Ln as checkTemplateLayoutContent,
|
|
2242
|
+
Cr as clearCustomFunctions,
|
|
2225
2243
|
Pe as contextCodeForTemplateGroup,
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2244
|
+
xr as contextForTemplateGroup,
|
|
2245
|
+
Rr as createBlockElement,
|
|
2246
|
+
jr as createCongressBlocks,
|
|
2247
|
+
zn as createTemplateRenderer,
|
|
2248
|
+
pe as defineDataContext,
|
|
2231
2249
|
B as defineTemplateProjection,
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2250
|
+
Sr as describeTemplateFilter,
|
|
2251
|
+
me as describeTemplateFunctions,
|
|
2252
|
+
Nr as describeTemplateKind,
|
|
2253
|
+
Te as eventProjection,
|
|
2254
|
+
ur as eventRegistrationContext,
|
|
2255
|
+
sr as eventRegistrationProjection,
|
|
2256
|
+
Ft as expandTemplateLayouts,
|
|
2257
|
+
Xt as findBlockRefs,
|
|
2258
|
+
Be as findLayoutCodes,
|
|
2259
|
+
Se as formatBlockRef,
|
|
2260
|
+
Or as getTemplateFunctionDescriptor,
|
|
2261
|
+
ft as getTemplateKind,
|
|
2244
2262
|
K as hasTemplateErrors,
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2263
|
+
er as invoiceLineProjection,
|
|
2264
|
+
tr as invoiceProjection,
|
|
2265
|
+
Br as layoutContext,
|
|
2266
|
+
Ar as layoutElementHtml,
|
|
2267
|
+
ct as layoutHtmlIssues,
|
|
2268
|
+
ve as listOf,
|
|
2269
|
+
Z as normalizeBlockParamDefinitions,
|
|
2270
|
+
Gt as normalizeTemplateMarkup,
|
|
2271
|
+
Jt as parseBlockRef,
|
|
2272
|
+
te as parseTemplateContent,
|
|
2273
|
+
nr as paymentResultProjection,
|
|
2274
|
+
he as personProjection,
|
|
2275
|
+
dr as receiptContext,
|
|
2276
|
+
$r as registerCongressTemplateFunctions,
|
|
2277
|
+
Bt as registerTemplateFunction,
|
|
2278
|
+
vr as renderTemplateEmail,
|
|
2279
|
+
mt as resolveBlockParams,
|
|
2280
|
+
at as resolveTemplateLayout,
|
|
2281
|
+
J as toDataContextDescriptor
|
|
2264
2282
|
};
|
|
2265
2283
|
//# sourceMappingURL=p-templates-model.esm.js.map
|