@questwork/p-templates-model 0.1.1 → 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 +4 -1
- package/dist/p-templates-model.cjs +11 -11
- package/dist/p-templates-model.cjs.map +1 -1
- package/dist/p-templates-model.esm.js +682 -664
- 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 +2 -2
|
@@ -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",
|
|
@@ -27,53 +27,53 @@ const Pe = 2, Ze = Object.freeze([2]), y = Object.freeze({
|
|
|
27
27
|
UNKNOWN_BLOCK: "UNKNOWN_BLOCK",
|
|
28
28
|
UNKNOWN_FUNCTION: "UNKNOWN_FUNCTION",
|
|
29
29
|
VARIABLE_INVALID: "VARIABLE_INVALID"
|
|
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
|
-
function
|
|
60
|
-
return new
|
|
59
|
+
function B(t) {
|
|
60
|
+
return new it(t);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function ve(t, { label: e, description: n, value: r } = {}) {
|
|
63
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;
|
|
@@ -81,70 +81,81 @@ function ie(t, e) {
|
|
|
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
83
|
if (i === P.OBJECT)
|
|
84
|
-
o.fields = Object.entries(t.fields || {}).reduce((a, [
|
|
84
|
+
o.fields = Object.entries(t.fields || {}).reduce((a, [c, l]) => (It(c, e), a[c] = oe(l, `${e}.${c}`), a), {});
|
|
85
85
|
else if (i === P.LIST)
|
|
86
|
-
o.item =
|
|
87
|
-
else if (!
|
|
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 (!
|
|
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
|
|
99
|
+
function ce(t, e) {
|
|
100
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 === P.LIST ? Array.isArray(e) ? e.map((n) =>
|
|
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 (!
|
|
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 wt {
|
|
|
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 wt {
|
|
|
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;
|
|
@@ -279,58 +291,58 @@ function Bt(t, e) {
|
|
|
279
291
|
return typeof t == "string";
|
|
280
292
|
}
|
|
281
293
|
}
|
|
282
|
-
function O({ code: t, message: e, severity: n =
|
|
294
|
+
function O({ code: t, message: e, severity: n = X.ERROR, ...r } = {}) {
|
|
283
295
|
const i = { code: t, message: e, severity: n };
|
|
284
296
|
return ["partCode", "offset", "line", "column", "source", "blockRef", "detail"].forEach((s) => {
|
|
285
297
|
typeof r[s] < "u" && (i[s] = r[s]);
|
|
286
298
|
}), i;
|
|
287
299
|
}
|
|
288
300
|
function K(t = []) {
|
|
289
|
-
return t.some((e) => e.severity ===
|
|
301
|
+
return t.some((e) => e.severity === X.ERROR);
|
|
290
302
|
}
|
|
291
|
-
class
|
|
303
|
+
class ee extends Error {
|
|
292
304
|
constructor(e = [], n) {
|
|
293
|
-
const r = e.filter((i) => i.severity ===
|
|
294
|
-
super(n ||
|
|
305
|
+
const r = e.filter((i) => i.severity === X.ERROR);
|
|
306
|
+
super(n || Ut(r)), this.name = "TemplateSyntaxError", this.code = "TEMPLATE_SYNTAX_INVALID", this.issues = e;
|
|
295
307
|
}
|
|
296
308
|
}
|
|
297
|
-
class
|
|
309
|
+
class j extends Error {
|
|
298
310
|
constructor({ message: e, partCode: n, source: r, cause: i } = {}) {
|
|
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,10 +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;
|
|
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);
|
|
541
554
|
}
|
|
542
555
|
static get _classname() {
|
|
543
556
|
return "Template";
|
|
@@ -554,7 +567,7 @@ class rn extends Et {
|
|
|
554
567
|
return ((e = this.kind) == null ? void 0 : e.partDefinitions) || [];
|
|
555
568
|
}
|
|
556
569
|
get isValid() {
|
|
557
|
-
return super.isValid && !!this.templateCode && !!this.contextCode;
|
|
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));
|
|
558
571
|
}
|
|
559
572
|
getCode() {
|
|
560
573
|
return this.templateCode;
|
|
@@ -576,12 +589,12 @@ class rn extends Et {
|
|
|
576
589
|
getBlockRefs() {
|
|
577
590
|
const e = /* @__PURE__ */ new Set();
|
|
578
591
|
return this.getContentParts().forEach(({ content: n }) => {
|
|
579
|
-
|
|
592
|
+
Xt(n).forEach((r) => e.add(r));
|
|
580
593
|
}), [...e];
|
|
581
594
|
}
|
|
582
595
|
/** Codes of the email layouts placed in the parts. */
|
|
583
596
|
getLayoutCodes() {
|
|
584
|
-
return [...new Set(this.getContentParts().flatMap(({ content: e }) =>
|
|
597
|
+
return [...new Set(this.getContentParts().flatMap(({ content: e }) => Be(e)))];
|
|
585
598
|
}
|
|
586
599
|
setPartContent(e, n) {
|
|
587
600
|
if (!this.constructor.partDefinitions.some((r) => r.partCode === e))
|
|
@@ -593,7 +606,7 @@ class rn extends Et {
|
|
|
593
606
|
* part is unchanged and an explicit null clears it.
|
|
594
607
|
*/
|
|
595
608
|
update(e = {}) {
|
|
596
|
-
return
|
|
609
|
+
return Object.hasOwn(e, "documentReference") && (this.documentReference = Ye(e.documentReference)), on.forEach((n) => {
|
|
597
610
|
Object.hasOwn(e, n) && (this[n] = n === "templateSyntaxVersion" ? Number(e[n]) : e[n]);
|
|
598
611
|
}), e.partContent && typeof e.partContent == "object" && Object.entries(e.partContent).forEach(([n, r]) => {
|
|
599
612
|
this.setPartContent(n, r);
|
|
@@ -605,29 +618,32 @@ class rn extends Et {
|
|
|
605
618
|
toObject() {
|
|
606
619
|
const e = {
|
|
607
620
|
_type: this._type,
|
|
608
|
-
meta:
|
|
609
|
-
metadata:
|
|
610
|
-
partContent:
|
|
611
|
-
remarks:
|
|
621
|
+
meta: L(this.meta, rn),
|
|
622
|
+
metadata: qe(this.metadata),
|
|
623
|
+
partContent: Xe(this.partContent),
|
|
624
|
+
remarks: qe(this.remarks),
|
|
612
625
|
tenantCode: this.tenantCode,
|
|
613
|
-
...
|
|
626
|
+
...L(this, sn)
|
|
614
627
|
};
|
|
615
628
|
return typeof this.id < "u" && (e.id = this.id), e;
|
|
616
629
|
}
|
|
617
630
|
}
|
|
618
|
-
function
|
|
631
|
+
function Ye(t) {
|
|
632
|
+
return typeof t == "string" ? t.trim() || null : t;
|
|
633
|
+
}
|
|
634
|
+
function Xe(t) {
|
|
619
635
|
return !t || typeof t != "object" ? {} : Object.entries(t).reduce((e, [n, r]) => (typeof r == "string" && (e[n] = r), e), {});
|
|
620
636
|
}
|
|
621
637
|
const z = Object.freeze({
|
|
622
638
|
DEPRECATED: "DEPRECATED",
|
|
623
639
|
DRAFT: "DRAFT",
|
|
624
640
|
PUBLISHED: "PUBLISHED"
|
|
625
|
-
}),
|
|
641
|
+
}), cn = new Set(Object.values(z)), ln = Object.freeze({
|
|
626
642
|
DEPRECATED: /* @__PURE__ */ new Set(),
|
|
627
643
|
DRAFT: /* @__PURE__ */ new Set(["PUBLISHED"]),
|
|
628
644
|
PUBLISHED: /* @__PURE__ */ new Set(["DEPRECATED"])
|
|
629
645
|
});
|
|
630
|
-
class
|
|
646
|
+
class Le extends Ct {
|
|
631
647
|
constructor(e = {}) {
|
|
632
648
|
super(e), this._setPublicationState(e.publication);
|
|
633
649
|
}
|
|
@@ -646,7 +662,7 @@ class Se extends yt {
|
|
|
646
662
|
canTransition(e, n) {
|
|
647
663
|
var i, s;
|
|
648
664
|
const r = (i = this.getState(e)) == null ? void 0 : i.stateCode;
|
|
649
|
-
return e === "publication" && !!((s =
|
|
665
|
+
return e === "publication" && !!((s = ln[r]) != null && s.has(n));
|
|
650
666
|
}
|
|
651
667
|
transition(e, { actionRevision: n, modified: r = Date.now(), stateCode: i } = {}) {
|
|
652
668
|
var s;
|
|
@@ -655,7 +671,7 @@ class Se extends yt {
|
|
|
655
671
|
return this._setPublicationState({ actionRevision: n, modified: r, stateCode: i });
|
|
656
672
|
}
|
|
657
673
|
_setPublicationState(e) {
|
|
658
|
-
if (!
|
|
674
|
+
if (!cn.has(e == null ? void 0 : e.stateCode))
|
|
659
675
|
throw new TypeError(`Invalid ${this.constructor.entityType} lifecycle state for publication.`);
|
|
660
676
|
return this._setState("publication", e);
|
|
661
677
|
}
|
|
@@ -665,40 +681,40 @@ const R = Object.freeze({
|
|
|
665
681
|
MULTI_SELECT: "multiSelect",
|
|
666
682
|
SELECT: "select",
|
|
667
683
|
TEXT: "text"
|
|
668
|
-
}),
|
|
669
|
-
function
|
|
684
|
+
}), un = new Set(Object.values(R)), Qe = /* @__PURE__ */ new Set([R.MULTI_SELECT, R.SELECT]);
|
|
685
|
+
function Z(t = []) {
|
|
670
686
|
const e = [], n = /* @__PURE__ */ new Set();
|
|
671
687
|
return { definitions: (Array.isArray(t) ? t : []).map((i, s) => {
|
|
672
|
-
const { paramCode: o, type: a, label:
|
|
673
|
-
return !
|
|
674
|
-
...
|
|
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 } : {},
|
|
675
691
|
..."default" in (i || {}) ? { default: i.default } : {},
|
|
676
|
-
label:
|
|
677
|
-
...
|
|
692
|
+
label: c || o,
|
|
693
|
+
...Qe.has(a) ? { options: u.map(({ value: d, label: f }) => ({ label: f || d, value: d })) } : {},
|
|
678
694
|
paramCode: o,
|
|
679
|
-
required: !!
|
|
695
|
+
required: !!m,
|
|
680
696
|
type: a
|
|
681
697
|
};
|
|
682
698
|
}), errors: e };
|
|
683
699
|
}
|
|
684
|
-
function
|
|
700
|
+
function mt(t = [], e = {}) {
|
|
685
701
|
const n = [], r = e && typeof e == "object" ? e : {}, i = new Set(t.map(({ paramCode: o }) => o));
|
|
686
702
|
Object.keys(r).forEach((o) => {
|
|
687
703
|
i.has(o) || n.push(`Unknown param "${o}".`);
|
|
688
704
|
});
|
|
689
705
|
const s = t.reduce((o, a) => {
|
|
690
|
-
const { paramCode:
|
|
706
|
+
const { paramCode: c, type: l, required: m } = a, u = Object.hasOwn(r, c) ? r[c] : a.default;
|
|
691
707
|
if (u == null || u === "")
|
|
692
|
-
return
|
|
693
|
-
const
|
|
694
|
-
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;
|
|
695
711
|
}, {});
|
|
696
712
|
return { errors: n, values: s };
|
|
697
713
|
}
|
|
698
|
-
function
|
|
714
|
+
function dn(t = [], e = {}) {
|
|
699
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), {});
|
|
700
716
|
}
|
|
701
|
-
function
|
|
717
|
+
function xe(t = []) {
|
|
702
718
|
return {
|
|
703
719
|
fields: t.reduce((e, { paramCode: n, type: r, label: i, options: s }) => (r === R.MULTI_SELECT ? e[n] = {
|
|
704
720
|
fields: s.reduce((o, a) => (o[a.value] = { label: a.label, type: "boolean" }, o), {}),
|
|
@@ -708,7 +724,7 @@ function Be(t = []) {
|
|
|
708
724
|
type: "object"
|
|
709
725
|
};
|
|
710
726
|
}
|
|
711
|
-
function
|
|
727
|
+
function pn({ paramCode: t, type: e, options: n = [] }, r) {
|
|
712
728
|
const i = new Set(n.map((s) => s.value));
|
|
713
729
|
switch (e) {
|
|
714
730
|
case R.BOOLEAN:
|
|
@@ -723,21 +739,23 @@ function ln({ paramCode: t, type: e, options: n = [] }, r) {
|
|
|
723
739
|
return null;
|
|
724
740
|
}
|
|
725
741
|
}
|
|
726
|
-
const
|
|
742
|
+
const $e = Object.freeze({
|
|
727
743
|
EMAIL: "EMAIL"
|
|
728
744
|
}), x = Object.freeze({
|
|
729
745
|
TEXT_HTML: "text/html",
|
|
730
746
|
TEXT_PLAIN: "text/plain"
|
|
731
|
-
}),
|
|
747
|
+
}), I = Object.freeze({
|
|
732
748
|
MAILBOX: "mailbox",
|
|
733
749
|
MAILBOX_LIST: "mailboxList",
|
|
734
750
|
TEXT: "text"
|
|
735
|
-
}),
|
|
751
|
+
}), Me = Object.freeze({
|
|
736
752
|
fieldDefinitions: Object.freeze([
|
|
737
|
-
Object.freeze({
|
|
738
|
-
Object.freeze({ emailExpression: !
|
|
739
|
-
Object.freeze({ emailExpression: !
|
|
740
|
-
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 })
|
|
741
759
|
]),
|
|
742
760
|
label: "Email",
|
|
743
761
|
partDefinitions: Object.freeze([
|
|
@@ -755,14 +773,14 @@ const xe = Object.freeze({
|
|
|
755
773
|
Object.freeze({ label: "HTML", previewViewCode: "HTML" }),
|
|
756
774
|
Object.freeze({ label: "Plain text", previewViewCode: "TEXT" })
|
|
757
775
|
]),
|
|
758
|
-
templateKindCode:
|
|
759
|
-
}),
|
|
760
|
-
[
|
|
776
|
+
templateKindCode: $e.EMAIL
|
|
777
|
+
}), mn = Object.freeze({
|
|
778
|
+
[$e.EMAIL]: Me
|
|
761
779
|
});
|
|
762
|
-
function
|
|
763
|
-
return
|
|
780
|
+
function ft(t) {
|
|
781
|
+
return mn[t] || null;
|
|
764
782
|
}
|
|
765
|
-
function
|
|
783
|
+
function Nr(t) {
|
|
766
784
|
return structuredClone({
|
|
767
785
|
fieldDefinitions: t.fieldDefinitions || [],
|
|
768
786
|
label: t.label,
|
|
@@ -772,25 +790,27 @@ function Cr(t) {
|
|
|
772
790
|
templateKindCode: t.templateKindCode
|
|
773
791
|
});
|
|
774
792
|
}
|
|
775
|
-
function
|
|
776
|
-
return (t.fieldDefinitions || []).flatMap(({ fieldCode: n, type: r, emailExpression: i, nameExpression: s,
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
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;
|
|
780
800
|
return [
|
|
781
|
-
{ content: (
|
|
782
|
-
{ content: (
|
|
783
|
-
].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);
|
|
784
804
|
});
|
|
785
805
|
});
|
|
786
806
|
}
|
|
787
|
-
const
|
|
788
|
-
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 }),
|
|
789
809
|
label: "Loop",
|
|
790
810
|
type: "object"
|
|
791
|
-
}),
|
|
792
|
-
function
|
|
793
|
-
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 = {
|
|
794
814
|
allowAssign: a,
|
|
795
815
|
allowedFunctionNames: o,
|
|
796
816
|
assigned: /* @__PURE__ */ new Map(),
|
|
@@ -801,27 +821,27 @@ function me(t, { locate: e, text: n, roots: r = null, variables: i = /* @__PURE_
|
|
|
801
821
|
roots: r,
|
|
802
822
|
text: n
|
|
803
823
|
};
|
|
804
|
-
return
|
|
824
|
+
return v(t, i, c), { issues: c.issues, requiredRoots: [...c.requiredRoots].sort() };
|
|
805
825
|
}
|
|
806
|
-
function
|
|
807
|
-
return
|
|
826
|
+
function Sr(t, e) {
|
|
827
|
+
return ht.get(t) || (e == null ? void 0 : e.get(t)) || null;
|
|
808
828
|
}
|
|
809
|
-
function
|
|
829
|
+
function v(t, e, n) {
|
|
810
830
|
(t || []).forEach((r) => {
|
|
811
831
|
const { token: i } = r;
|
|
812
832
|
if (A.isOutputToken(i)) {
|
|
813
|
-
const s =
|
|
833
|
+
const s = ue(n, i), o = H(r.value, e, n, s);
|
|
814
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);
|
|
815
835
|
return;
|
|
816
836
|
}
|
|
817
|
-
A.isTagToken(i) &&
|
|
837
|
+
A.isTagToken(i) && gn(r, e, n);
|
|
818
838
|
});
|
|
819
839
|
}
|
|
820
|
-
function
|
|
840
|
+
function gn(t, e, n) {
|
|
821
841
|
var o;
|
|
822
|
-
const { name: r, token: i } = t, s =
|
|
823
|
-
if (!
|
|
824
|
-
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" : "";
|
|
825
845
|
N(n, y.TAG_NOT_ALLOWED, `Tag "${r}" is not allowed${a}.`, i, s);
|
|
826
846
|
return;
|
|
827
847
|
}
|
|
@@ -829,52 +849,52 @@ function bn(t, e, n) {
|
|
|
829
849
|
case "if":
|
|
830
850
|
case "unless":
|
|
831
851
|
t.branches.forEach((a) => {
|
|
832
|
-
|
|
833
|
-
}),
|
|
852
|
+
H(a.value, e, n, s), v(a.templates, e, n);
|
|
853
|
+
}), v(t.elseTemplates, e, n);
|
|
834
854
|
break;
|
|
835
855
|
case "case":
|
|
836
|
-
|
|
837
|
-
a.values.forEach((
|
|
838
|
-
}),
|
|
856
|
+
H(t.value, e, n, s), t.branches.forEach((a) => {
|
|
857
|
+
a.values.forEach((c) => D(c, e, n, s)), v(a.templates, e, n);
|
|
858
|
+
}), v(t.elseTemplates, e, n);
|
|
839
859
|
break;
|
|
840
860
|
case "for": {
|
|
841
861
|
const { variable: a } = t;
|
|
842
|
-
|
|
843
|
-
const
|
|
844
|
-
let
|
|
845
|
-
A.isRangeToken(t.collection) ?
|
|
846
|
-
|
|
847
|
-
}),
|
|
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);
|
|
848
868
|
break;
|
|
849
869
|
}
|
|
850
870
|
case "assign": {
|
|
851
|
-
|
|
871
|
+
ge(t.key, e, n, i, s), n.assigned.set(t.key, H(t.value, e, n, s));
|
|
852
872
|
break;
|
|
853
873
|
}
|
|
854
874
|
case "capture":
|
|
855
|
-
|
|
875
|
+
ge(t.variable, e, n, i, s), v(t.templates, e, n), n.assigned.set(t.variable, Ue);
|
|
856
876
|
break;
|
|
857
877
|
}
|
|
858
878
|
}
|
|
859
|
-
function
|
|
860
|
-
!
|
|
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);
|
|
861
881
|
}
|
|
862
|
-
function
|
|
882
|
+
function H(t, e, n, r) {
|
|
863
883
|
if (!t)
|
|
864
884
|
return null;
|
|
865
|
-
let i =
|
|
885
|
+
let i = Tt(t.initial, e, n, r);
|
|
866
886
|
return (t.filters || []).forEach((s) => {
|
|
867
|
-
i =
|
|
887
|
+
i = On(s, i, e, n, r);
|
|
868
888
|
}), i;
|
|
869
889
|
}
|
|
870
|
-
function
|
|
871
|
-
const i = [...(t == null ? void 0 : t.postfix) || []], s = i.map((o) =>
|
|
872
|
-
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;
|
|
873
893
|
}
|
|
874
|
-
function
|
|
875
|
-
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;
|
|
876
896
|
}
|
|
877
|
-
function
|
|
897
|
+
function _n(t, e, n, r) {
|
|
878
898
|
const [i, ...s] = t.props || [], o = i == null ? void 0 : i.content;
|
|
879
899
|
if (typeof o != "string" || !A.isWordToken(i))
|
|
880
900
|
return null;
|
|
@@ -889,162 +909,162 @@ function En(t, e, n, r) {
|
|
|
889
909
|
else
|
|
890
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;
|
|
891
911
|
else return o !== F && n.requiredRoots.add(o), null;
|
|
892
|
-
for (const
|
|
912
|
+
for (const c of s) {
|
|
893
913
|
if (!a)
|
|
894
914
|
return null;
|
|
895
|
-
if (A.isPropertyAccessToken(
|
|
896
|
-
if (
|
|
915
|
+
if (A.isPropertyAccessToken(c) || c.initial) {
|
|
916
|
+
if (D(c, e, n, r), a.type === "list") {
|
|
897
917
|
a = a.item || null;
|
|
898
918
|
continue;
|
|
899
919
|
}
|
|
900
|
-
return a.type === "object" ? null :
|
|
920
|
+
return a.type === "object" ? null : ie(n, t, r, "only a list or an object can be indexed.");
|
|
901
921
|
}
|
|
902
|
-
if (A.isNumberToken(
|
|
922
|
+
if (A.isNumberToken(c)) {
|
|
903
923
|
if (a.type !== "list")
|
|
904
|
-
return
|
|
924
|
+
return ie(n, t, r, "only a list can be indexed.");
|
|
905
925
|
a = a.item || null;
|
|
906
926
|
continue;
|
|
907
927
|
}
|
|
908
|
-
const
|
|
928
|
+
const l = c.content;
|
|
909
929
|
if (a.type === "list")
|
|
910
|
-
if (
|
|
911
|
-
a =
|
|
912
|
-
else if (
|
|
930
|
+
if (l === "size")
|
|
931
|
+
a = w;
|
|
932
|
+
else if (l === "first" || l === "last")
|
|
913
933
|
a = a.item || null;
|
|
914
934
|
else
|
|
915
|
-
return
|
|
916
|
-
else if (a.type === "string" &&
|
|
917
|
-
a =
|
|
918
|
-
else if (a.type === "object" && a.fields && Object.hasOwn(a.fields,
|
|
919
|
-
a = a.fields[
|
|
920
|
-
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.`);
|
|
921
941
|
}
|
|
922
942
|
return a;
|
|
923
943
|
}
|
|
924
|
-
function
|
|
925
|
-
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;
|
|
926
946
|
}
|
|
927
|
-
function
|
|
947
|
+
function On(t, e, n, r, i) {
|
|
928
948
|
var _;
|
|
929
949
|
const { name: s, args: o = [] } = t;
|
|
930
950
|
if (!s)
|
|
931
951
|
return N(r, y.SYNTAX_ERROR, 'A filter name is missing after "|".', t.token, i), null;
|
|
932
|
-
const a = o.filter((
|
|
933
|
-
a.forEach((
|
|
934
|
-
const
|
|
935
|
-
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)
|
|
936
956
|
return (r.functionsByName || !s.startsWith("__")) && N(r, y.UNKNOWN_FUNCTION, `Filter "${s}" is not available.`, t.token, i), null;
|
|
937
|
-
if (!
|
|
957
|
+
if (!l && r.allowedFunctionNames && !r.allowedFunctionNames.has(s))
|
|
938
958
|
return N(r, y.FUNCTION_NOT_ALLOWED, `Filter "${s}" is not allowed in this data context.`, t.token, i), null;
|
|
939
|
-
const u = (
|
|
940
|
-
if (
|
|
941
|
-
const
|
|
942
|
-
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;
|
|
943
963
|
}
|
|
944
|
-
return
|
|
964
|
+
return l ? Cn(s, e, a, n, r, i) : null;
|
|
945
965
|
}
|
|
946
|
-
function
|
|
947
|
-
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;
|
|
948
968
|
if (t === "where")
|
|
949
|
-
return a(
|
|
969
|
+
return a(c(n[0])), e;
|
|
950
970
|
if (t === "where_exp")
|
|
951
|
-
return
|
|
952
|
-
if (
|
|
971
|
+
return An(c(n[0]), n[1], o, r, i, s), e;
|
|
972
|
+
if (bn.has(t))
|
|
953
973
|
return e;
|
|
954
974
|
if (t === "map") {
|
|
955
|
-
const
|
|
956
|
-
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;
|
|
957
977
|
}
|
|
958
|
-
return t === "first" ? o : t === "default" ? e :
|
|
978
|
+
return t === "first" ? o : t === "default" ? e : yn.has(t) ? w : En.has(t) ? Ue : null;
|
|
959
979
|
}
|
|
960
|
-
function
|
|
980
|
+
function An(t, e, n, r, i, s) {
|
|
961
981
|
if (!t || !e || !A.isQuotedToken(e))
|
|
962
982
|
return;
|
|
963
983
|
let o;
|
|
964
984
|
try {
|
|
965
|
-
o = new
|
|
966
|
-
} catch (
|
|
967
|
-
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);
|
|
968
988
|
return;
|
|
969
989
|
}
|
|
970
990
|
const a = { ...i, text: e.content };
|
|
971
|
-
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) }));
|
|
972
992
|
}
|
|
973
|
-
function
|
|
993
|
+
function ue(t, e) {
|
|
974
994
|
return t.text && e ? t.text.slice(e.begin, e.end) : "";
|
|
975
995
|
}
|
|
976
996
|
function N(t, e, n, r, i) {
|
|
977
997
|
t.issues.push(O({ code: e, message: n, ...t.locate((r == null ? void 0 : r.begin) ?? 0), ...i ? { source: i } : {} }));
|
|
978
998
|
}
|
|
979
|
-
const
|
|
980
|
-
function
|
|
981
|
-
var
|
|
982
|
-
const a = typeof (t == null ? void 0 : t.toObject) == "function" ? t.toObject() : t || {},
|
|
983
|
-
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)
|
|
984
1004
|
throw new TypeError("checkTemplate requires a template kind.");
|
|
985
|
-
const
|
|
986
|
-
if (!
|
|
987
|
-
return
|
|
988
|
-
const
|
|
989
|
-
return
|
|
990
|
-
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];
|
|
991
1011
|
if (typeof E != "string" || !E.trim()) {
|
|
992
|
-
|
|
1012
|
+
T && l.push(O({ code: y.PART_REQUIRED, message: `Part "${p}" is required.`, partCode: p }));
|
|
993
1013
|
return;
|
|
994
1014
|
}
|
|
995
|
-
const C =
|
|
996
|
-
|
|
997
|
-
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);
|
|
998
1018
|
});
|
|
999
|
-
}), Object.keys(_).forEach((
|
|
1000
|
-
|
|
1001
|
-
}),
|
|
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 }) => {
|
|
1002
1022
|
if (!E) {
|
|
1003
|
-
|
|
1023
|
+
Rn.test(T) && l.push(O({ code: y.FIELD_EXPRESSION_NOT_ALLOWED, message: `Field "${p}" must be a fixed value.`, partCode: p }));
|
|
1004
1024
|
return;
|
|
1005
1025
|
}
|
|
1006
|
-
|
|
1007
|
-
}), { blockRefs: [...
|
|
1026
|
+
l.push(...de(T, { allowBlocks: !1, env: f, partCode: p }).issues);
|
|
1027
|
+
}), { blockRefs: [...m], issues: l, layoutCodes: [...u], valid: !K(l) };
|
|
1008
1028
|
}
|
|
1009
|
-
function
|
|
1010
|
-
const i =
|
|
1029
|
+
function Nn(t, { env: e, layouts: n, partCode: r }) {
|
|
1030
|
+
const i = at({ layoutCode: t, layouts: n });
|
|
1011
1031
|
if (!i)
|
|
1012
1032
|
return [O({ code: y.LAYOUT_NOT_FOUND, layoutCode: t, message: `Layout ${t} has no published version.`, partCode: r })];
|
|
1013
1033
|
const s = `${i.layoutCode}@${i.version}`;
|
|
1014
1034
|
return [
|
|
1015
|
-
...
|
|
1016
|
-
...
|
|
1035
|
+
...de(i.html || "", { allowBlocks: !1, env: e, partCode: r }).issues,
|
|
1036
|
+
...ct(i.html)
|
|
1017
1037
|
].map((o) => ({ ...o, layoutRef: s, message: `${s}: ${o.message}`, partCode: r }));
|
|
1018
1038
|
}
|
|
1019
|
-
function
|
|
1020
|
-
const a =
|
|
1021
|
-
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) };
|
|
1022
1042
|
}
|
|
1023
|
-
function
|
|
1024
|
-
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) });
|
|
1025
1045
|
return o.push(...a.issues), { issues: o, requiredRoots: a.requiredRoots, valid: !K(o) };
|
|
1026
1046
|
}
|
|
1027
|
-
function
|
|
1028
|
-
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)];
|
|
1029
1049
|
return { issues: r, requiredRoots: n.requiredRoots, valid: !K(r) };
|
|
1030
1050
|
}
|
|
1031
|
-
function
|
|
1032
|
-
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, {
|
|
1033
1053
|
allowAssign: e,
|
|
1034
1054
|
allowedFunctionNames: s ? new Set(s.functionNames || []) : null,
|
|
1035
|
-
functionsByName: a ? new Map(a.map((
|
|
1055
|
+
functionsByName: a ? new Map(a.map((l) => [l.name, l])) : null,
|
|
1036
1056
|
locate: o.locate,
|
|
1037
1057
|
roots: (s == null ? void 0 : s.roots) || null,
|
|
1038
1058
|
text: o.text,
|
|
1039
1059
|
variables: /* @__PURE__ */ new Map([[F, i]])
|
|
1040
1060
|
});
|
|
1041
|
-
return { issues: [...o.issues, ...
|
|
1061
|
+
return { issues: [...o.issues, ...c.issues], requiredRoots: c.requiredRoots };
|
|
1042
1062
|
}
|
|
1043
|
-
function
|
|
1044
|
-
const i =
|
|
1063
|
+
function Et({ allowedDeprecatedBlockRefs: t = [], blocks: e = [], context: n, functions: r }) {
|
|
1064
|
+
const i = J(n);
|
|
1045
1065
|
if (!i || !i.roots)
|
|
1046
1066
|
throw new TypeError("Template checks require a data context.");
|
|
1047
|
-
const s = r ||
|
|
1067
|
+
const s = r || me();
|
|
1048
1068
|
return {
|
|
1049
1069
|
allowedDeprecatedBlockRefs: new Set(t),
|
|
1050
1070
|
allowedFunctionNames: new Set(i.functionNames || []),
|
|
@@ -1057,68 +1077,68 @@ function ft({ allowedDeprecatedBlockRefs: t = [], blocks: e = [], context: n, fu
|
|
|
1057
1077
|
roots: i.roots
|
|
1058
1078
|
};
|
|
1059
1079
|
}
|
|
1060
|
-
function
|
|
1061
|
-
const i =
|
|
1062
|
-
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, {
|
|
1063
1083
|
allowedFunctionNames: n.allowedFunctionNames,
|
|
1064
1084
|
functionsByName: n.functionsByName,
|
|
1065
1085
|
locate: i.locate,
|
|
1066
1086
|
roots: n.roots,
|
|
1067
1087
|
text: i.text
|
|
1068
|
-
}).issues), i.blocks.forEach((o) =>
|
|
1088
|
+
}).issues), i.blocks.forEach((o) => wn(o, n, s)), { blockRefs: i.blockRefs, issues: s };
|
|
1069
1089
|
}
|
|
1070
|
-
function
|
|
1071
|
-
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);
|
|
1072
1092
|
if (!o) {
|
|
1073
1093
|
s(y.UNKNOWN_BLOCK, `Block ${r} does not exist.`);
|
|
1074
1094
|
return;
|
|
1075
1095
|
}
|
|
1076
|
-
const a = o.stateCode ||
|
|
1077
|
-
if (a ===
|
|
1096
|
+
const a = o.stateCode || _e.PUBLISHED;
|
|
1097
|
+
if (a === _e.DRAFT) {
|
|
1078
1098
|
s(y.BLOCK_NOT_PUBLISHED, `Block ${r} is not published.`);
|
|
1079
1099
|
return;
|
|
1080
1100
|
}
|
|
1081
|
-
if (a ===
|
|
1101
|
+
if (a === _e.DEPRECATED) {
|
|
1082
1102
|
const u = e.allowedDeprecatedBlockRefs.has(r);
|
|
1083
1103
|
s(
|
|
1084
1104
|
y.BLOCK_DEPRECATED,
|
|
1085
1105
|
u ? `Block ${r} is deprecated; consider a newer version.` : `Block ${r} is deprecated and cannot be added.`,
|
|
1086
|
-
u ?
|
|
1106
|
+
u ? X.WARNING : X.ERROR
|
|
1087
1107
|
);
|
|
1088
1108
|
}
|
|
1089
1109
|
if (o.contextCode !== e.contextCode) {
|
|
1090
1110
|
s(y.BLOCK_CONTEXT_MISMATCH, `Block ${r} is for data context ${o.contextCode || "(none)"}, not ${e.contextCode}.`);
|
|
1091
1111
|
return;
|
|
1092
1112
|
}
|
|
1093
|
-
const
|
|
1094
|
-
|
|
1095
|
-
const { definitions:
|
|
1096
|
-
if (
|
|
1097
|
-
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, {
|
|
1098
1118
|
allowAssign: !0,
|
|
1099
1119
|
allowedFunctionNames: e.allowedFunctionNames,
|
|
1100
1120
|
functionsByName: e.functionsByName,
|
|
1101
1121
|
locate: u.locate,
|
|
1102
1122
|
roots: e.roots,
|
|
1103
1123
|
text: u.text,
|
|
1104
|
-
variables: /* @__PURE__ */ new Map([[F,
|
|
1124
|
+
variables: /* @__PURE__ */ new Map([[F, xe(l)]])
|
|
1105
1125
|
});
|
|
1106
|
-
[...u.issues, ...
|
|
1126
|
+
[...u.issues, ...d.issues].forEach((f) => n.push(O({
|
|
1107
1127
|
...i,
|
|
1108
1128
|
blockRef: r,
|
|
1109
|
-
code:
|
|
1110
|
-
message: `${r}: ${
|
|
1111
|
-
severity:
|
|
1129
|
+
code: f.code,
|
|
1130
|
+
message: `${r}: ${f.message}`,
|
|
1131
|
+
severity: f.severity
|
|
1112
1132
|
})));
|
|
1113
1133
|
}
|
|
1114
1134
|
}
|
|
1115
|
-
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({
|
|
1116
1136
|
DEPRECATED: "TEMPLATE_BLOCK_DEPRECATED",
|
|
1117
1137
|
PUBLISHED: "TEMPLATE_BLOCK_PUBLISHED"
|
|
1118
1138
|
});
|
|
1119
|
-
class
|
|
1139
|
+
class vn extends tt {
|
|
1120
1140
|
constructor(e = {}) {
|
|
1121
|
-
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);
|
|
1122
1142
|
}
|
|
1123
1143
|
static get _classname() {
|
|
1124
1144
|
return "TemplateBlock";
|
|
@@ -1130,13 +1150,13 @@ class Pn extends Qe {
|
|
|
1130
1150
|
static create({ actionRevision: e = 1, modified: n = Date.now(), ...r } = {}) {
|
|
1131
1151
|
return this.init({
|
|
1132
1152
|
...r,
|
|
1133
|
-
lifecycle:
|
|
1153
|
+
lifecycle: Le.create({ actionRevision: e, modified: n }).toObject(),
|
|
1134
1154
|
meta: { ...r.meta, revision: e }
|
|
1135
1155
|
});
|
|
1136
1156
|
}
|
|
1137
1157
|
get isValid() {
|
|
1138
1158
|
var e;
|
|
1139
|
-
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);
|
|
1140
1160
|
}
|
|
1141
1161
|
get blockRef() {
|
|
1142
1162
|
return `${this.blockCode}@${this.version}`;
|
|
@@ -1160,15 +1180,15 @@ class Pn extends Qe {
|
|
|
1160
1180
|
*/
|
|
1161
1181
|
check({ context: e, functions: n } = {}) {
|
|
1162
1182
|
var r;
|
|
1163
|
-
if (e && ((r =
|
|
1183
|
+
if (e && ((r = J(e)) == null ? void 0 : r.contextCode) !== this.contextCode)
|
|
1164
1184
|
throw new TypeError(`TemplateBlock ${this.blockRef} belongs to data context ${this.contextCode}.`);
|
|
1165
|
-
return
|
|
1185
|
+
return Sn({ context: e, fragment: this.fragment, functions: n, params: this.params });
|
|
1166
1186
|
}
|
|
1167
1187
|
update(e = {}) {
|
|
1168
|
-
if (
|
|
1188
|
+
if (Je.some((r) => Object.hasOwn(e, r)) && !this.isDraft)
|
|
1169
1189
|
throw new Error(`TemplateBlock ${this.blockRef} is ${this.stateCode}; publish changes as a new version.`);
|
|
1170
|
-
return
|
|
1171
|
-
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] ?? "");
|
|
1172
1192
|
}), super.update(e);
|
|
1173
1193
|
}
|
|
1174
1194
|
/**
|
|
@@ -1178,7 +1198,7 @@ class Pn extends Qe {
|
|
|
1178
1198
|
publish({ actionRevision: e = this.revision + 1, context: n, modified: r = Date.now(), functions: i } = {}) {
|
|
1179
1199
|
const s = this.check({ context: n, functions: i });
|
|
1180
1200
|
if (!s.valid)
|
|
1181
|
-
throw new
|
|
1201
|
+
throw new ee(s.issues.map((o) => ({ ...o, blockRef: this.blockRef })));
|
|
1182
1202
|
return this.lifecycle.transition("publication", { actionRevision: e, modified: r, stateCode: z.PUBLISHED }), this.requiredRoots = s.requiredRoots, this.meta.revision = e, this.setModified();
|
|
1183
1203
|
}
|
|
1184
1204
|
/** Hide this version from editors; templates that use it still render. */
|
|
@@ -1187,7 +1207,7 @@ class Pn extends Qe {
|
|
|
1187
1207
|
}
|
|
1188
1208
|
/** EntityAction for the latest publication transition. */
|
|
1189
1209
|
createEntityAction({ actionCode: e, actor: n, previousStateCode: r, timestamp: i = Date.now(), ...s } = {}) {
|
|
1190
|
-
return
|
|
1210
|
+
return nt.init({
|
|
1191
1211
|
...s,
|
|
1192
1212
|
actionCode: e,
|
|
1193
1213
|
actor: n,
|
|
@@ -1210,7 +1230,7 @@ class Pn extends Qe {
|
|
|
1210
1230
|
description: this.description,
|
|
1211
1231
|
fragment: this.fragment,
|
|
1212
1232
|
name: this.name,
|
|
1213
|
-
params:
|
|
1233
|
+
params: Ge(this.params),
|
|
1214
1234
|
requiredRoots: [...this.requiredRoots],
|
|
1215
1235
|
stateCode: this.stateCode,
|
|
1216
1236
|
...this.tenantCode ? { tenantCode: this.tenantCode } : {},
|
|
@@ -1224,55 +1244,52 @@ class Pn extends Qe {
|
|
|
1224
1244
|
const e = {
|
|
1225
1245
|
_type: this._type,
|
|
1226
1246
|
...this.lifecycle ? { lifecycle: this.lifecycle.toObject() } : {},
|
|
1227
|
-
meta:
|
|
1228
|
-
params:
|
|
1247
|
+
meta: L(this.meta, Pn),
|
|
1248
|
+
params: Ge(this.params),
|
|
1229
1249
|
requiredRoots: [...this.requiredRoots],
|
|
1230
|
-
...
|
|
1250
|
+
...L(this, In)
|
|
1231
1251
|
};
|
|
1232
1252
|
return typeof this.id < "u" && (e.id = this.id), e;
|
|
1233
1253
|
}
|
|
1234
1254
|
}
|
|
1235
|
-
const
|
|
1236
|
-
class
|
|
1255
|
+
const G = ["email", "name"], jn = ["bcc", "cc", "from", "replyTo", "to"];
|
|
1256
|
+
class Bn extends an {
|
|
1237
1257
|
constructor(e = {}) {
|
|
1238
|
-
|
|
1239
|
-
throw new TypeError('TemplateEmail does not accept "to"; recipients come from the sending job.');
|
|
1240
|
-
super(e), this._type = e._type || "TemplateEmail", this.bcc = _e(e.bcc), this.cc = _e(e.cc), this.from = re(e.from), this.replyTo = re(e.replyTo);
|
|
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
|
-
|
|
1250
|
-
|
|
1251
|
-
return In.forEach((n) => {
|
|
1252
|
-
Object.hasOwn(e, n) && (this[n] = n === "cc" || n === "bcc" ? _e(e[n]) : re(e[n]));
|
|
1267
|
+
return jn.forEach((n) => {
|
|
1268
|
+
Object.hasOwn(e, n) && (this[n] = n === "cc" || n === "bcc" ? Oe(e[n]) : W(e[n]));
|
|
1253
1269
|
}), super.update(e);
|
|
1254
1270
|
}
|
|
1255
1271
|
toObject() {
|
|
1256
1272
|
return {
|
|
1257
1273
|
...super.toObject(),
|
|
1258
|
-
bcc: this.bcc.map((e) =>
|
|
1259
|
-
cc: this.cc.map((e) =>
|
|
1260
|
-
from: this.from ?
|
|
1261
|
-
replyTo: this.replyTo ?
|
|
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
|
|
1262
1279
|
};
|
|
1263
1280
|
}
|
|
1264
1281
|
}
|
|
1265
|
-
function
|
|
1282
|
+
function W(t) {
|
|
1266
1283
|
return t ? typeof t == "string" ? t.trim() ? { email: t.trim() } : null : typeof t != "object" || !t.email ? null : {
|
|
1267
1284
|
email: String(t.email).trim(),
|
|
1268
1285
|
...t.name ? { name: String(t.name) } : {}
|
|
1269
1286
|
} : null;
|
|
1270
1287
|
}
|
|
1271
|
-
function
|
|
1272
|
-
return (Array.isArray(t) ? t : []).map(
|
|
1288
|
+
function Oe(t) {
|
|
1289
|
+
return (Array.isArray(t) ? t : []).map(W).filter(Boolean);
|
|
1273
1290
|
}
|
|
1274
|
-
const
|
|
1275
|
-
class
|
|
1291
|
+
const Ce = z;
|
|
1292
|
+
class Ze extends Le {
|
|
1276
1293
|
static get _classname() {
|
|
1277
1294
|
return "LifecycleTemplateLayout";
|
|
1278
1295
|
}
|
|
@@ -1280,13 +1297,13 @@ class Ye extends Se {
|
|
|
1280
1297
|
return "TemplateLayout";
|
|
1281
1298
|
}
|
|
1282
1299
|
}
|
|
1283
|
-
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({
|
|
1284
1301
|
DEPRECATED: "TEMPLATE_LAYOUT_DEPRECATED",
|
|
1285
1302
|
PUBLISHED: "TEMPLATE_LAYOUT_PUBLISHED"
|
|
1286
1303
|
});
|
|
1287
|
-
class
|
|
1304
|
+
class Dr extends tt {
|
|
1288
1305
|
constructor(e = {}) {
|
|
1289
|
-
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);
|
|
1290
1307
|
}
|
|
1291
1308
|
static get _classname() {
|
|
1292
1309
|
return "TemplateLayout";
|
|
@@ -1298,13 +1315,13 @@ class wr extends Qe {
|
|
|
1298
1315
|
static create({ actionRevision: e = 1, modified: n = Date.now(), ...r } = {}) {
|
|
1299
1316
|
return this.init({
|
|
1300
1317
|
...r,
|
|
1301
|
-
lifecycle:
|
|
1318
|
+
lifecycle: Ze.create({ actionRevision: e, modified: n }).toObject(),
|
|
1302
1319
|
meta: { ...r.meta, revision: e }
|
|
1303
1320
|
});
|
|
1304
1321
|
}
|
|
1305
1322
|
get isValid() {
|
|
1306
1323
|
var e;
|
|
1307
|
-
return super.isValid &&
|
|
1324
|
+
return super.isValid && Mn.test(this.layoutCode || "") && Number.isInteger(this.version) && this.version >= 1 && !!((e = this.lifecycle) != null && e.isValid);
|
|
1308
1325
|
}
|
|
1309
1326
|
get layoutRef() {
|
|
1310
1327
|
return `${this.layoutCode}@${this.version}`;
|
|
@@ -1314,7 +1331,7 @@ class wr extends Qe {
|
|
|
1314
1331
|
return ((n = (e = this.lifecycle) == null ? void 0 : e.getState("publication")) == null ? void 0 : n.stateCode) || null;
|
|
1315
1332
|
}
|
|
1316
1333
|
get isDraft() {
|
|
1317
|
-
return this.stateCode ===
|
|
1334
|
+
return this.stateCode === Ce.DRAFT;
|
|
1318
1335
|
}
|
|
1319
1336
|
getCode() {
|
|
1320
1337
|
return this.layoutRef;
|
|
@@ -1324,12 +1341,12 @@ class wr extends Qe {
|
|
|
1324
1341
|
}
|
|
1325
1342
|
/** Check the HTML without changing the layout. */
|
|
1326
1343
|
check({ functions: e } = {}) {
|
|
1327
|
-
return
|
|
1344
|
+
return Ln({ functions: e, html: this.html });
|
|
1328
1345
|
}
|
|
1329
1346
|
update(e = {}) {
|
|
1330
|
-
if (
|
|
1347
|
+
if (et.some((r) => Object.hasOwn(e, r)) && !this.isDraft)
|
|
1331
1348
|
throw new Error(`TemplateLayout ${this.layoutRef} is ${this.stateCode}; publish changes as a new version.`);
|
|
1332
|
-
return
|
|
1349
|
+
return et.forEach((r) => {
|
|
1333
1350
|
Object.hasOwn(e, r) && (this[r] = e[r] ?? "");
|
|
1334
1351
|
}), super.update(e);
|
|
1335
1352
|
}
|
|
@@ -1340,16 +1357,16 @@ class wr extends Qe {
|
|
|
1340
1357
|
publish({ actionRevision: e = this.revision + 1, modified: n = Date.now(), functions: r } = {}) {
|
|
1341
1358
|
const i = this.check({ functions: r });
|
|
1342
1359
|
if (!i.valid)
|
|
1343
|
-
throw new
|
|
1344
|
-
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();
|
|
1345
1362
|
}
|
|
1346
1363
|
/** Retire this version; templates fall back to an older published version, if any. */
|
|
1347
1364
|
deprecate({ actionRevision: e = this.revision + 1, modified: n = Date.now() } = {}) {
|
|
1348
|
-
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();
|
|
1349
1366
|
}
|
|
1350
1367
|
/** EntityAction for the latest publication transition. */
|
|
1351
1368
|
createEntityAction({ actionCode: e, actor: n, previousStateCode: r, timestamp: i = Date.now(), ...s } = {}) {
|
|
1352
|
-
return
|
|
1369
|
+
return nt.init({
|
|
1353
1370
|
...s,
|
|
1354
1371
|
actionCode: e,
|
|
1355
1372
|
actor: n,
|
|
@@ -1385,22 +1402,22 @@ class wr extends Qe {
|
|
|
1385
1402
|
const e = {
|
|
1386
1403
|
_type: this._type,
|
|
1387
1404
|
...this.lifecycle ? { lifecycle: this.lifecycle.toObject() } : {},
|
|
1388
|
-
meta:
|
|
1405
|
+
meta: L(this.meta, xn),
|
|
1389
1406
|
requiredRoots: [...this.requiredRoots],
|
|
1390
|
-
...
|
|
1407
|
+
...L(this, $n)
|
|
1391
1408
|
};
|
|
1392
1409
|
return typeof this.id < "u" && (e.id = this.id), e;
|
|
1393
1410
|
}
|
|
1394
1411
|
}
|
|
1395
|
-
const
|
|
1412
|
+
const Un = Object.freeze({
|
|
1396
1413
|
memoryLimit: 1e7,
|
|
1397
1414
|
parseLimit: 1024 * 1024,
|
|
1398
1415
|
renderLimit: 1e3
|
|
1399
|
-
}),
|
|
1400
|
-
let
|
|
1401
|
-
const
|
|
1416
|
+
}), yt = "qw_block";
|
|
1417
|
+
let Y = null;
|
|
1418
|
+
const kn = {
|
|
1402
1419
|
parse(t) {
|
|
1403
|
-
if (this.block =
|
|
1420
|
+
if (this.block = Y == null ? void 0 : Y[Number(t.args)], !this.block)
|
|
1404
1421
|
throw new Error(`Unknown block instance ${t.args}.`);
|
|
1405
1422
|
},
|
|
1406
1423
|
*render(t, e) {
|
|
@@ -1408,183 +1425,184 @@ const $n = {
|
|
|
1408
1425
|
yield this.liquid.renderer.renderTemplates(this.block.templates, n, e);
|
|
1409
1426
|
}
|
|
1410
1427
|
};
|
|
1411
|
-
function
|
|
1412
|
-
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 });
|
|
1413
1430
|
let i = null;
|
|
1414
1431
|
const s = () => {
|
|
1415
|
-
const { filters: u, version:
|
|
1416
|
-
if ((i == null ? void 0 : i.version) ===
|
|
1432
|
+
const { filters: u, version: d } = xt();
|
|
1433
|
+
if ((i == null ? void 0 : i.version) === d)
|
|
1417
1434
|
return i;
|
|
1418
1435
|
n.clear();
|
|
1419
|
-
const
|
|
1420
|
-
const
|
|
1421
|
-
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;
|
|
1422
1439
|
};
|
|
1423
|
-
return i = { html:
|
|
1424
|
-
}, 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 }) => {
|
|
1425
1442
|
s();
|
|
1426
|
-
const
|
|
1427
|
-
if (
|
|
1428
|
-
const C = n.get(
|
|
1429
|
-
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;
|
|
1430
1447
|
}
|
|
1431
|
-
const E =
|
|
1432
|
-
return
|
|
1433
|
-
}, a = ({ content: u, contentType:
|
|
1434
|
-
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);
|
|
1435
1452
|
if (!E)
|
|
1436
1453
|
throw new TypeError("Template rendering requires a data context.");
|
|
1437
1454
|
return o({
|
|
1438
|
-
allowBlocks:
|
|
1455
|
+
allowBlocks: T,
|
|
1439
1456
|
allowedFunctions: [...E.functionNames || []].sort(),
|
|
1440
|
-
blocks:
|
|
1441
|
-
cacheKey:
|
|
1457
|
+
blocks: Kn(b),
|
|
1458
|
+
cacheKey: p,
|
|
1442
1459
|
content: u ?? "",
|
|
1443
|
-
contentType:
|
|
1444
|
-
partCode:
|
|
1460
|
+
contentType: d,
|
|
1461
|
+
partCode: f
|
|
1445
1462
|
}).render(_ || {});
|
|
1446
1463
|
};
|
|
1447
|
-
return Object.freeze({ clearCache: () => n.clear(), renderBlock: ({ block: u, params:
|
|
1448
|
-
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, "'");
|
|
1449
1466
|
return a({
|
|
1450
|
-
blocks: [{ ...
|
|
1451
|
-
content: `<div data-qw-block="${
|
|
1467
|
+
blocks: [{ ...h, stateCode: "PUBLISHED" }],
|
|
1468
|
+
content: `<div data-qw-block="${b}" data-qw-params='${p}'></div>`,
|
|
1452
1469
|
context: _,
|
|
1453
|
-
data:
|
|
1470
|
+
data: f,
|
|
1454
1471
|
partCode: "block"
|
|
1455
1472
|
});
|
|
1456
|
-
}, renderContent: a, renderTemplate: ({ template: u, kind:
|
|
1457
|
-
var
|
|
1458
|
-
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);
|
|
1459
1476
|
if (!C)
|
|
1460
1477
|
throw new TypeError("renderTemplate requires a template kind.");
|
|
1461
|
-
|
|
1462
|
-
const
|
|
1463
|
-
return C.partDefinitions.forEach(({ partCode: $, contentType:
|
|
1464
|
-
var
|
|
1465
|
-
const
|
|
1466
|
-
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)
|
|
1467
1484
|
return;
|
|
1468
|
-
if (
|
|
1469
|
-
|
|
1485
|
+
if (Ee !== x.TEXT_HTML) {
|
|
1486
|
+
be[$] = a({ blocks: h, cacheKey: ne, content: re, context: S, contentType: Ee, data: Ve, partCode: $ });
|
|
1470
1487
|
return;
|
|
1471
1488
|
}
|
|
1472
|
-
const q =
|
|
1489
|
+
const q = Ft({ html: re, layouts: T });
|
|
1473
1490
|
if (q.missingLayoutCodes.length)
|
|
1474
|
-
throw new
|
|
1475
|
-
const
|
|
1476
|
-
|
|
1477
|
-
}), { partContent:
|
|
1491
|
+
throw new j({ message: `Layout ${q.missingLayoutCodes.join(", ")} has no published version.`, partCode: $ });
|
|
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 };
|
|
1478
1495
|
} });
|
|
1479
1496
|
}
|
|
1480
|
-
function
|
|
1481
|
-
if (!
|
|
1482
|
-
throw new
|
|
1497
|
+
function Vn(t = Ie) {
|
|
1498
|
+
if (!rt.includes(t))
|
|
1499
|
+
throw new ee([O({
|
|
1483
1500
|
code: y.SYNTAX_VERSION_UNSUPPORTED,
|
|
1484
1501
|
message: `Template syntax version ${t} is not supported.`
|
|
1485
1502
|
})]);
|
|
1486
1503
|
}
|
|
1487
|
-
function
|
|
1504
|
+
function Fn(t) {
|
|
1488
1505
|
const { templateCode: e, tenantCode: n, meta: r } = t;
|
|
1489
1506
|
return !e || !(r != null && r.revision) ? null : `${n || ""}\0${e}\0${r.revision}`;
|
|
1490
1507
|
}
|
|
1491
|
-
function
|
|
1508
|
+
function Kn(t = []) {
|
|
1492
1509
|
return new Map((t || []).map((e) => {
|
|
1493
1510
|
const n = typeof e.describe == "function" ? e.describe() : e;
|
|
1494
1511
|
return [`${n.blockCode}@${n.version}`, n];
|
|
1495
1512
|
}));
|
|
1496
1513
|
}
|
|
1497
|
-
function
|
|
1498
|
-
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, {})];
|
|
1499
1516
|
if (K(u))
|
|
1500
|
-
throw new
|
|
1501
|
-
const
|
|
1502
|
-
let _ = "",
|
|
1503
|
-
|
|
1504
|
-
_ += `${
|
|
1505
|
-
}), _ +=
|
|
1506
|
-
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);
|
|
1507
1524
|
return Object.freeze({
|
|
1508
|
-
render(
|
|
1525
|
+
render(p) {
|
|
1509
1526
|
try {
|
|
1510
|
-
return
|
|
1511
|
-
} catch (
|
|
1512
|
-
const E = (
|
|
1513
|
-
if (E instanceof
|
|
1527
|
+
return d.renderSync(b, { ...p });
|
|
1528
|
+
} catch (T) {
|
|
1529
|
+
const E = (T == null ? void 0 : T.originalError) || T;
|
|
1530
|
+
if (E instanceof j)
|
|
1514
1531
|
throw E;
|
|
1515
|
-
const C = String((E == null ? void 0 : E.message) ||
|
|
1516
|
-
throw new
|
|
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 });
|
|
1517
1534
|
}
|
|
1518
1535
|
}
|
|
1519
1536
|
});
|
|
1520
1537
|
}
|
|
1521
|
-
function
|
|
1538
|
+
function Gn(t, { blocks: e, engine: n, partCode: r, policy: i }) {
|
|
1522
1539
|
const { blockRef: s } = t, o = e.get(s);
|
|
1523
1540
|
if (!o || typeof o.fragment != "string")
|
|
1524
|
-
throw new
|
|
1541
|
+
throw new j({ message: `Block ${s} is not available for rendering.`, partCode: r, source: s });
|
|
1525
1542
|
if (o.stateCode === "DRAFT")
|
|
1526
|
-
throw new
|
|
1527
|
-
const { definitions: a, errors:
|
|
1528
|
-
if (
|
|
1529
|
-
throw new
|
|
1530
|
-
const u =
|
|
1531
|
-
if (K(
|
|
1532
|
-
throw new
|
|
1543
|
+
throw new j({ message: `Block ${s} is not published.`, partCode: r, source: s });
|
|
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 })));
|
|
1533
1550
|
return {
|
|
1534
|
-
params: Object.freeze(
|
|
1535
|
-
templates:
|
|
1551
|
+
params: Object.freeze(dn(a, m)),
|
|
1552
|
+
templates: gt(n, u.text, [])
|
|
1536
1553
|
};
|
|
1537
1554
|
}
|
|
1538
|
-
function
|
|
1539
|
-
|
|
1555
|
+
function gt(t, e, n) {
|
|
1556
|
+
Y = n;
|
|
1540
1557
|
try {
|
|
1541
1558
|
return t.parse(e);
|
|
1542
1559
|
} finally {
|
|
1543
|
-
|
|
1560
|
+
Y = null;
|
|
1544
1561
|
}
|
|
1545
1562
|
}
|
|
1546
|
-
const
|
|
1547
|
-
async function
|
|
1548
|
-
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({
|
|
1549
1566
|
allowBlocks: !1,
|
|
1550
|
-
content:
|
|
1567
|
+
content: b,
|
|
1551
1568
|
context: n,
|
|
1552
1569
|
contentType: x.TEXT_PLAIN,
|
|
1553
1570
|
data: e,
|
|
1554
|
-
partCode:
|
|
1555
|
-
}).trim(),
|
|
1556
|
-
if (!(
|
|
1571
|
+
partCode: p
|
|
1572
|
+
}).trim(), d = (b, p, { fixedEmail: T = !1 } = {}) => {
|
|
1573
|
+
if (!(b != null && b.email))
|
|
1557
1574
|
return null;
|
|
1558
|
-
if (
|
|
1559
|
-
throw new
|
|
1560
|
-
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`);
|
|
1561
1578
|
if (!E)
|
|
1562
1579
|
return null;
|
|
1563
|
-
if (!
|
|
1564
|
-
throw new
|
|
1565
|
-
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`) : "";
|
|
1566
1583
|
return { email: E, ...C ? { name: C } : {} };
|
|
1567
|
-
},
|
|
1568
|
-
let _ =
|
|
1569
|
-
const
|
|
1570
|
-
if (o &&
|
|
1571
|
-
const
|
|
1572
|
-
|
|
1573
|
-
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]));
|
|
1574
1591
|
});
|
|
1575
1592
|
}
|
|
1576
1593
|
return {
|
|
1577
|
-
bcc:
|
|
1578
|
-
cc:
|
|
1579
|
-
from:
|
|
1594
|
+
bcc: f(l.bcc, "bcc"),
|
|
1595
|
+
cc: f(l.cc, "cc"),
|
|
1596
|
+
from: d(l.from, "from", { fixedEmail: !0 }),
|
|
1580
1597
|
html: _,
|
|
1581
|
-
inlineAttachments:
|
|
1582
|
-
replyTo:
|
|
1583
|
-
subject: (
|
|
1584
|
-
text:
|
|
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 = j({
|
|
|
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 = j({
|
|
|
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 = j({
|
|
|
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 = j({
|
|
|
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 = j({
|
|
|
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 = j({
|
|
|
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 = j({
|
|
|
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
|
-
function
|
|
1997
|
-
return
|
|
2014
|
+
function Pe(t) {
|
|
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,10 +2083,10 @@ 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
|
-
e = e || {}, super({ ...e, contextCode:
|
|
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
|
}
|
|
2073
2091
|
static get _classname() {
|
|
2074
2092
|
return "TemplateEmailCongress";
|
|
@@ -2077,9 +2095,9 @@ 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
|
-
}), Object.hasOwn(e, "templateGroupName") && (this.contextCode =
|
|
2100
|
+
}), Object.hasOwn(e, "templateGroupName") && (this.contextCode = Pe(e.templateGroupName)), super.update(e);
|
|
2083
2101
|
}
|
|
2084
2102
|
toObject() {
|
|
2085
2103
|
return {
|
|
@@ -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
|
-
|
|
2214
|
+
Me as TEMPLATE_EMAIL_KIND,
|
|
2215
|
+
Un as TEMPLATE_EVALUATION_LIMITS,
|
|
2216
|
+
I as TEMPLATE_FIELD_KIND,
|
|
2199
2217
|
P as TEMPLATE_FIELD_TYPE,
|
|
2200
|
-
|
|
2218
|
+
Re as TEMPLATE_FRAGMENT_TAGS,
|
|
2201
2219
|
U as TEMPLATE_FUNCTION_ARG_TYPE,
|
|
2202
2220
|
y as TEMPLATE_ISSUE_CODE,
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2221
|
+
X as TEMPLATE_ISSUE_SEVERITY,
|
|
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,
|
|
2233
|
+
j as TemplateRenderError,
|
|
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,
|
|
2243
|
+
Pe as contextCodeForTemplateGroup,
|
|
2244
|
+
xr as contextForTemplateGroup,
|
|
2245
|
+
Rr as createBlockElement,
|
|
2246
|
+
jr as createCongressBlocks,
|
|
2247
|
+
zn as createTemplateRenderer,
|
|
2248
|
+
pe as defineDataContext,
|
|
2249
|
+
B as defineTemplateProjection,
|
|
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
|