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