@adminiumjs/manifest 0.3.85 → 0.3.86

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/dist/legal.js ADDED
@@ -0,0 +1,286 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ /**
3
+ * `legal` — THE LEGAL TEXTS AN APP SHOWS ITS CUSTOMERS, KEPT BY ADMINIUM.
4
+ *
5
+ * ```json
6
+ * "legal": {
7
+ * "kinds": ["legal_notice", "privacy", "terms", "withdrawal_info"],
8
+ * "whenEu": ["withdrawal_info"],
9
+ * "eu": { "table": "settings", "column": "eu_on" },
10
+ * "identity": { "table": "settings", "name": "shop_name", "address": ["street", "city"], "email": "shop_email" }
11
+ * }
12
+ * ```
13
+ *
14
+ * The owner writes the texts in Studio, per install of the app, and publishes
15
+ * them as numbered versions; the app reads the newest from Adminium's public
16
+ * legal read, which is open on every customer surface (a closed one, one for
17
+ * signed-in customers only, one switched off) because the app says it has
18
+ * legal pages by carrying this block.
19
+ *
20
+ * - `kinds`: the texts the app shows. Each is needed: while one is empty the
21
+ * owner is told so (never anything paused).
22
+ * - `whenEu` (of `kinds`): needed only while the app sells to consumers in
23
+ * the EU, which `eu` names: a yes/no (or 0/1) column of the app's one-row
24
+ * settings table. Without `eu`, or when it cannot be read, they are needed.
25
+ * - `identity`: where the app's own settings keep the business's name,
26
+ * address and e-mail. Read live, and only while the owner has not written
27
+ * the business in Studio; never another install's.
28
+ * - `import`: where an earlier version of the app kept its texts, copied once
29
+ * per install into Adminium by the install or update that brings it
30
+ * (settings columns become version 1; a table of numbered versions keeps
31
+ * its numbers, dates and publisher). With `identity`, the business named
32
+ * by columns the earlier version kept is copied too, while Studio has none.
33
+ *
34
+ * An order's column takes the version its customer was shown with
35
+ * `rules: { legalVersion: { acceptedAt: "terms_accepted_at" } }` (see
36
+ * `legalVersionRuleSchema`).
37
+ *
38
+ * Pure.
39
+ */
40
+ import { z } from 'zod';
41
+ import { refSchema } from './refs.js';
42
+ /** The kinds of legal text Adminium keeps, a closed list. */
43
+ export const LEGAL_TEXT_KINDS = ['legal_notice', 'privacy', 'terms', 'withdrawal_info'];
44
+ /** The first Adminium that keeps an app's legal texts. If the release number moves, this line moves. */
45
+ export const LEGAL_FLOOR = '0.3.86';
46
+ /** The grant an app's role carries to write and publish its own install's legal texts and business. */
47
+ export const LEGAL_EDIT_GRANT = 'legal:@:edit';
48
+ const kindSchema = z.enum(LEGAL_TEXT_KINDS);
49
+ const kindsSchema = z.array(kindSchema).min(1).max(LEGAL_TEXT_KINDS.length);
50
+ /** Columns of one table, by the kind of text each holds. */
51
+ const columnsByKind = z
52
+ .object({ legal_notice: refSchema.optional(), privacy: refSchema.optional(), terms: refSchema.optional(), withdrawal_info: refSchema.optional() })
53
+ .strict()
54
+ .refine((columns) => Object.keys(columns).length > 0, 'name at least one kind');
55
+ /**
56
+ * Where an earlier version kept its texts: columns of its one-row settings
57
+ * table, or a table of numbered versions whose numbers, dates and publisher
58
+ * are copied as they are.
59
+ */
60
+ export const legalIdentitySourceSchema = z
61
+ .object({
62
+ /** The app's one-row settings table. */
63
+ table: refSchema,
64
+ name: refSchema,
65
+ /** The address, as the columns that hold its lines, in order. */
66
+ address: z.array(refSchema).min(1).max(6).optional(),
67
+ email: refSchema.optional(),
68
+ phone: refSchema.optional(),
69
+ })
70
+ .strict();
71
+ /** Where an earlier version's business identity was kept: copied once, while Studio has none. */
72
+ const importIdentitySchema = legalIdentitySourceSchema;
73
+ export const legalImportSchema = z.union([
74
+ z.object({ settings: z.object({ table: refSchema, columns: columnsByKind }).strict(), identity: importIdentitySchema.optional() }).strict(),
75
+ z
76
+ .object({
77
+ versions: z
78
+ .object({
79
+ table: refSchema,
80
+ number: refSchema,
81
+ publishedAt: refSchema,
82
+ publishedBy: refSchema.optional(),
83
+ columns: columnsByKind,
84
+ })
85
+ .strict(),
86
+ identity: importIdentitySchema.optional(),
87
+ })
88
+ .strict(),
89
+ ]);
90
+ /**
91
+ * `rules.legalVersion` — THE LEGAL TEXTS AN ORDER WAS PLACED UNDER.
92
+ *
93
+ * On a nullable text column of a table customers create rows of (an order, a
94
+ * booking, a proposal's acceptance). The browser writes the version number
95
+ * of the texts it showed (`version` of the public legal read); Adminium
96
+ * keeps the version's own id in its place, and only:
97
+ *
98
+ * - the install's newest version, or the one it replaced while that was
99
+ * published less than two hours ago (a tab left open through a publish);
100
+ * anything else is refused (409 `LEGAL_VERSION_MOVED`), and the page reads
101
+ * the texts again;
102
+ * - on a create: the column is never changed afterwards, by anyone;
103
+ * - a public create that sends none takes the newest version, marked as
104
+ * assumed in `assumed` (an old tab or an old customer build);
105
+ * - a create by staff, a rule or an import of new rows takes the newest
106
+ * version when it names none, and is never stamped as accepted.
107
+ *
108
+ * `acceptedAt` (a nullable timestamptz of the same table) takes the moment a
109
+ * customer's write gave the version; `assumed` (a nullable bool) is set when
110
+ * the version was not sent. Both are Adminium's: nobody else writes them.
111
+ * Rows brought in as history (sample data, an undo) keep what they carry.
112
+ */
113
+ export const legalVersionRuleSchema = z.union([
114
+ z.literal(true),
115
+ z.object({ acceptedAt: refSchema.optional(), assumed: refSchema.optional() }).strict(),
116
+ ]);
117
+ /** How many characters a version's id takes (`lgv_` and 26 more). */
118
+ export const LEGAL_VERSION_ID_LENGTH = 30;
119
+ /** The rule's two columns, spelled out. */
120
+ export function legalVersionColumns(rule) {
121
+ if (rule === undefined)
122
+ return null;
123
+ return rule === true ? {} : { acceptedAt: rule.acceptedAt, assumed: rule.assumed };
124
+ }
125
+ export const legalSchema = z
126
+ .object({
127
+ kinds: kindsSchema,
128
+ whenEu: kindsSchema.optional(),
129
+ eu: z.object({ table: refSchema, column: refSchema }).strict().optional(),
130
+ identity: legalIdentitySourceSchema.optional(),
131
+ import: legalImportSchema.optional(),
132
+ })
133
+ .strict();
134
+ /** The source of an import, whichever kind it is. */
135
+ export function legalImportSource(legalImport) {
136
+ return 'settings' in legalImport
137
+ ? { kind: 'settings', table: legalImport.settings.table, columns: legalImport.settings.columns }
138
+ : { kind: 'versions', table: legalImport.versions.table, columns: legalImport.versions.columns };
139
+ }
140
+ /** What may hold a line of text: words, or a fixed list. */
141
+ const TEXT_TYPES = ['text', 'enum'];
142
+ /** What may hold a long text. */
143
+ const LONG_TYPES = ['text'];
144
+ /** What may say yes or no. */
145
+ const SWITCH_TYPES = ['bool', 'int'];
146
+ /** The kinds an install needs, given whether it sells to consumers in the EU (null: not known, so needed). */
147
+ export function neededLegalKinds(legal, eu) {
148
+ const onlyEu = new Set(legal.whenEu ?? []);
149
+ return legal.kinds.filter((kind) => eu !== false || !onlyEu.has(kind));
150
+ }
151
+ /** Everything wrong with an app's `legal`, checked against its own tables and columns. */
152
+ export function legalIssues(m, index) {
153
+ const legal = m.legal;
154
+ if (legal === undefined)
155
+ return [];
156
+ const out = [];
157
+ const at = (...rest) => ['legal', ...rest];
158
+ legal.kinds.forEach((kind, k) => {
159
+ if (legal.kinds.indexOf(kind) !== k)
160
+ out.push({ path: at('kinds', k), message: `"${kind}" is named twice` });
161
+ });
162
+ (legal.whenEu ?? []).forEach((kind, k) => {
163
+ if (!legal.kinds.includes(kind))
164
+ out.push({ path: at('whenEu', k), message: `"${kind}" is not one of the kinds the app shows` });
165
+ if ((legal.whenEu ?? []).indexOf(kind) !== k)
166
+ out.push({ path: at('whenEu', k), message: `"${kind}" is named twice` });
167
+ });
168
+ if (legal.whenEu !== undefined && legal.eu === undefined)
169
+ out.push({ path: at('eu'), message: 'name the setting that says the app sells to consumers in the EU' });
170
+ const column = (table, ref, types, path) => {
171
+ if (index.table(table) === undefined) {
172
+ out.push({ path, message: `"${table}" is not a table of this app` });
173
+ return;
174
+ }
175
+ const found = index.column(table, ref);
176
+ if (found === undefined)
177
+ out.push({ path, message: `"${table}" has no column "${ref}"` });
178
+ else if (!types.includes(found.type))
179
+ out.push({ path, message: `"${table}.${ref}" is a ${found.type} column, which cannot hold this` });
180
+ };
181
+ if (legal.eu !== undefined)
182
+ column(legal.eu.table, legal.eu.column, SWITCH_TYPES, at('eu', 'column'));
183
+ const identityIssues = (source, base) => {
184
+ const { table, name, address, email, phone } = source;
185
+ if (index.table(table) === undefined)
186
+ out.push({ path: [...base, 'table'], message: `"${table}" is not a table of this app` });
187
+ else {
188
+ column(table, name, TEXT_TYPES, [...base, 'name']);
189
+ (address ?? []).forEach((ref, a) => {
190
+ column(table, ref, TEXT_TYPES, [...base, 'address', a]);
191
+ if ((address ?? []).indexOf(ref) !== a)
192
+ out.push({ path: [...base, 'address', a], message: `"${ref}" is named twice` });
193
+ });
194
+ if (email !== undefined)
195
+ column(table, email, TEXT_TYPES, [...base, 'email']);
196
+ if (phone !== undefined)
197
+ column(table, phone, TEXT_TYPES, [...base, 'phone']);
198
+ }
199
+ };
200
+ if (legal.identity !== undefined)
201
+ identityIssues(legal.identity, at('identity'));
202
+ if (legal.import?.identity !== undefined)
203
+ identityIssues(legal.import.identity, at('import', 'identity'));
204
+ if (legal.import !== undefined) {
205
+ const source = 'settings' in legal.import ? legal.import.settings : legal.import.versions;
206
+ const base = 'settings' in legal.import ? at('import', 'settings') : at('import', 'versions');
207
+ if (index.table(source.table) === undefined)
208
+ out.push({ path: [...base, 'table'], message: `"${source.table}" is not a table of this app` });
209
+ else {
210
+ for (const [kind, ref] of Object.entries(source.columns)) {
211
+ if (ref === undefined)
212
+ continue;
213
+ if (!legal.kinds.includes(kind))
214
+ out.push({ path: [...base, 'columns', kind], message: `"${kind}" is not one of the kinds the app shows` });
215
+ column(source.table, ref, LONG_TYPES, [...base, 'columns', kind]);
216
+ }
217
+ if ('versions' in legal.import) {
218
+ const { number, publishedAt, publishedBy } = legal.import.versions;
219
+ column(source.table, number, ['int', 'bigint'], [...base, 'number']);
220
+ column(source.table, publishedAt, ['timestamptz', 'date'], [...base, 'publishedAt']);
221
+ if (publishedBy !== undefined)
222
+ column(source.table, publishedBy, TEXT_TYPES, [...base, 'publishedBy']);
223
+ }
224
+ }
225
+ }
226
+ return out;
227
+ }
228
+ /**
229
+ * Why a table with an order-version column is never written inside another
230
+ * row's save: the version is judged by a before hook as each of its rows is
231
+ * written, and a save of a row with the rows below it, or a ledger's posting,
232
+ * runs no before hook for the rows it writes (it refuses them when it comes).
233
+ */
234
+ export const LEGAL_VERSION_WRITTEN_ALONE = 'keeps the legal texts an order was placed under, judged as each of its rows is written alone';
235
+ /**
236
+ * Everything wrong with the app's order-version columns as its public
237
+ * entries meet them: an entry that adds rows of such a table names the
238
+ * column among what it writes (else the version shown could never arrive),
239
+ * and never the moment or the mark Adminium writes beside it; and no entry
240
+ * adds its rows below another row's create (`children`), which a save of a
241
+ * row with its children refuses.
242
+ */
243
+ export function legalVersionEntryIssues(m) {
244
+ const out = [];
245
+ const byTable = new Map();
246
+ for (const table of m.requiredSchema.tables) {
247
+ for (const column of table.columns) {
248
+ const rule = legalVersionColumns(column.rules?.legalVersion);
249
+ if (rule !== null && !byTable.has(table.ref))
250
+ byTable.set(table.ref, { column: column.ref, ...rule });
251
+ }
252
+ }
253
+ if (byTable.size === 0)
254
+ return out;
255
+ (m.publicAccess ?? []).forEach((entry, e) => {
256
+ const walk = (children, base) => {
257
+ for (const [name, child] of Object.entries(children ?? {})) {
258
+ if (byTable.has(name))
259
+ out.push({ path: [...base, name], message: `"${name}" ${LEGAL_VERSION_WRITTEN_ALONE}: its rows cannot come below another row's create` });
260
+ walk(child.children, [...base, name, 'children']);
261
+ }
262
+ };
263
+ walk(entry.children, ['publicAccess', e, 'children']);
264
+ const found = byTable.get(entry.table);
265
+ if (found === undefined)
266
+ return;
267
+ // The moment and the mark are Adminium's: no entry that writes rows names them, whatever it does to them.
268
+ if (entry.methods.some((method) => method === 'POST' || method === 'PATCH' || method === 'PUT' || method === 'BATCH')) {
269
+ for (const [side, ref] of [['moment the customer accepted the texts', found.acceptedAt], ['mark that the version was taken for the customer', found.assumed]]) {
270
+ if (ref !== undefined && (entry.writable ?? []).includes(ref)) {
271
+ out.push({ path: ['publicAccess', e, 'writable'], message: `"${ref}" is the ${side}, which Adminium writes beside "${found.column}": an entry never writes it` });
272
+ }
273
+ }
274
+ }
275
+ if (!entry.methods.some((method) => method === 'POST' || method === 'PUT' || method === 'BATCH'))
276
+ return;
277
+ if (entry.writable === undefined) {
278
+ out.push({ path: ['publicAccess', e, 'writable'], message: `"${entry.table}" keeps the legal texts an order was placed under: name what the entry writes, "${found.column}" among it` });
279
+ return;
280
+ }
281
+ if (!entry.writable.includes(found.column))
282
+ out.push({ path: ['publicAccess', e, 'writable'], message: `an entry that adds "${entry.table}" rows writes "${found.column}", the legal texts its customer was shown` });
283
+ });
284
+ return out;
285
+ }
286
+ //# sourceMappingURL=legal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legal.js","sourceRoot":"","sources":["../src/legal.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAA0D,MAAM,WAAW,CAAC;AAE9F,6DAA6D;AAC7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB,CAAU,CAAC;AAGjG,wGAAwG;AACxG,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC;AAEpC,uGAAuG;AACvG,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAE/C,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAC5C,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAE5E,4DAA4D;AAC5D,MAAM,aAAa,GAAG,CAAC;KACpB,MAAM,CAAC,EAAE,YAAY,EAAE,SAAS,CAAC,QAAQ,EAAE,EAAE,OAAO,E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AC,EAAE,IAAI,EAAE,CAAC,cAAc,EAAE,CAAC,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,GAAG,YAAY,IAAI,mCAAmC,KAAK,CAAC,MAAM,6BAA6B,EAAE,CAAC,CAAC;gBACpK,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,OAAO,CAAC;YAAE,OAAO;QACzG,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,cAAc,EAAE,CAAC,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,KAAK,CAAC,KAAK,mFAAmF,KAAK,CAAC,MAAM,YAAY,EAAE,CAAC,CAAC;YACzL,OAAO;QACT,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,cAAc,EAAE,CAAC,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,uBAAuB,KAAK,CAAC,KAAK,kBAAkB,KAAK,CAAC,MAAM,2CAA2C,EAAE,CAAC,CAAC;IACxN,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/outbox.d.ts CHANGED
@@ -73,6 +73,7 @@ export declare const outboxProducerSchema: z.ZodUnion<readonly [z.ZodObject<{
73
73
  module: z.ZodOptional<z.ZodString>;
74
74
  optIn: z.ZodOptional<z.ZodLiteral<true>>;
75
75
  hold: z.ZodOptional<z.ZodLiteral<true>>;
76
+ dailyCap: z.ZodOptional<z.ZodNumber>;
76
77
  due: z.ZodOptional<z.ZodObject<{
77
78
  date: z.ZodString;
78
79
  days: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
@@ -178,6 +179,7 @@ export declare const outboxProducerSchema: z.ZodUnion<readonly [z.ZodObject<{
178
179
  module: z.ZodOptional<z.ZodString>;
179
180
  optIn: z.ZodOptional<z.ZodLiteral<true>>;
180
181
  hold: z.ZodOptional<z.ZodLiteral<true>>;
182
+ dailyCap: z.ZodOptional<z.ZodNumber>;
181
183
  due: z.ZodOptional<z.ZodObject<{
182
184
  date: z.ZodString;
183
185
  days: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
@@ -269,6 +271,7 @@ export declare const outboxProducerSchema: z.ZodUnion<readonly [z.ZodObject<{
269
271
  module: z.ZodOptional<z.ZodString>;
270
272
  optIn: z.ZodOptional<z.ZodLiteral<true>>;
271
273
  hold: z.ZodOptional<z.ZodLiteral<true>>;
274
+ dailyCap: z.ZodOptional<z.ZodNumber>;
272
275
  due: z.ZodOptional<z.ZodObject<{
273
276
  date: z.ZodString;
274
277
  days: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
@@ -372,6 +375,7 @@ export declare const outboxProducerSchema: z.ZodUnion<readonly [z.ZodObject<{
372
375
  module: z.ZodOptional<z.ZodString>;
373
376
  optIn: z.ZodOptional<z.ZodLiteral<true>>;
374
377
  hold: z.ZodOptional<z.ZodLiteral<true>>;
378
+ dailyCap: z.ZodOptional<z.ZodNumber>;
375
379
  due: z.ZodOptional<z.ZodObject<{
376
380
  date: z.ZodString;
377
381
  days: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
@@ -543,6 +547,7 @@ export declare const outboxSchema: z.ZodObject<{
543
547
  module: z.ZodOptional<z.ZodString>;
544
548
  optIn: z.ZodOptional<z.ZodLiteral<true>>;
545
549
  hold: z.ZodOptional<z.ZodLiteral<true>>;
550
+ dailyCap: z.ZodOptional<z.ZodNumber>;
546
551
  due: z.ZodOptional<z.ZodObject<{
547
552
  date: z.ZodString;
548
553
  days: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
@@ -648,6 +653,7 @@ export declare const outboxSchema: z.ZodObject<{
648
653
  module: z.ZodOptional<z.ZodString>;
649
654
  optIn: z.ZodOptional<z.ZodLiteral<true>>;
650
655
  hold: z.ZodOptional<z.ZodLiteral<true>>;
656
+ dailyCap: z.ZodOptional<z.ZodNumber>;
651
657
  due: z.ZodOptional<z.ZodObject<{
652
658
  date: z.ZodString;
653
659
  days: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
@@ -739,6 +745,7 @@ export declare const outboxSchema: z.ZodObject<{
739
745
  module: z.ZodOptional<z.ZodString>;
740
746
  optIn: z.ZodOptional<z.ZodLiteral<true>>;
741
747
  hold: z.ZodOptional<z.ZodLiteral<true>>;
748
+ dailyCap: z.ZodOptional<z.ZodNumber>;
742
749
  due: z.ZodOptional<z.ZodObject<{
743
750
  date: z.ZodString;
744
751
  days: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
@@ -842,6 +849,7 @@ export declare const outboxSchema: z.ZodObject<{
842
849
  module: z.ZodOptional<z.ZodString>;
843
850
  optIn: z.ZodOptional<z.ZodLiteral<true>>;
844
851
  hold: z.ZodOptional<z.ZodLiteral<true>>;
852
+ dailyCap: z.ZodOptional<z.ZodNumber>;
845
853
  due: z.ZodOptional<z.ZodObject<{
846
854
  date: z.ZodString;
847
855
  days: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
@@ -994,6 +1002,7 @@ export declare const emailTemplateSchema: z.ZodObject<{
994
1002
  file: z.ZodString;
995
1003
  }, z.core.$strict>>>;
996
1004
  vars: z.ZodOptional<z.ZodArray<z.ZodString>>;
1005
+ mustCarry: z.ZodOptional<z.ZodArray<z.ZodString>>;
997
1006
  locales: z.ZodRecord<z.ZodString, z.ZodObject<{
998
1007
  subject: z.ZodString;
999
1008
  preheader: z.ZodOptional<z.ZodString>;
@@ -1011,6 +1020,8 @@ export declare const emailTemplateSchema: z.ZodObject<{
1011
1020
  }, z.core.$strict>>;
1012
1021
  }, z.core.$strict>;
1013
1022
  export type EmailTemplate = z.infer<typeof emailTemplateSchema>;
1023
+ /** Everything wrong with a template's `mustCarry`: each id names a block of every language, once. */
1024
+ export declare function mustCarryIssues(template: Pick<EmailTemplate, 'mustCarry' | 'locales'>, path: (string | number)[]): ReferenceIssue[];
1014
1025
  /**
1015
1026
  * What a producer of a removal (`onDelete`) does not take: each reads the row
1016
1027
  * again after the message is written (to date it, drop it, overtake it, hold
@@ -1 +1 @@
1
- {"version":3,"file":"outbox.d.ts","sourceRoot":"","sources":["../src/outbox.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C,OAAO,EAAkB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpE,OAAO,EAQL,KAAK,cAAc,EAEnB,KAAK,UAAU,EAChB,MAAM,WAAW,CAAC;AAEnB,mFAAmF;AACnF,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,yEAAyE;AACzE,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,+DAA+D;AAC/D,eAAO,MAAM,eAAe,kDAAmD,CAAC;AAEhF,qHAAqH;AACrH,eAAO,MAAM,eAAe,2BAA4B,CAAC;AAEzD,mEAAmE;AACnE,eAAO,MAAM,WAAW,SAAS,CAAC;AAElC,kGAAkG;AAClG,eAAO,MAAM,mBAAmB,uEAAwE,CAAC;AAqKzG,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE;YAAE,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;SAAE,GAAG,SAAS,CAAA;KAAE,GAAG,SAAS,CAAA;CAAE,GAAG,OAAO,CAIlL;AAED,oFAAoF;AACpF,eAAO,MAAM,YAAY,YAAY,CAAC;AAEtC;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,SAAK,GAAG,MAAM,CAO/D;AAED,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAAA;CAAE,GAAG,OAAO,CAEtG;AAED,gIAAgI;AAChI,eAAO,MAAM,eAAe,SAAS,CAAC;AAEtC,0KAA0K;AAC1K,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,MAAM,EAAE,CAKrJ;AAED,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,eAAe,CAAC;AAEjD,uHAAuH;AACvH,eAAO,MAAM,kBAAkB,aAAa,CAAC"}
package/dist/outbox.js CHANGED
@@ -123,6 +123,15 @@ const producerBase = {
123
123
  optIn: z.literal(true).optional(),
124
124
  /** Written `held`: sent only once someone approves it. */
125
125
  hold: z.literal(true).optional(),
126
+ /**
127
+ * The most messages of this kind one install sends in a day, on the
128
+ * venue's clock (a receipt anyone may ask for by typing an address). Past
129
+ * it the message is still written, `held` with the sentence "Not sent: the
130
+ * daily limit is reached", and goes only once someone releases it (held →
131
+ * queued). What the visitor is answered does not change. The outbox's
132
+ * status column offers `held`. From Adminium 0.3.86.
133
+ */
134
+ dailyCap: z.number().int().min(1).max(10_000).optional(),
126
135
  /** When it comes due: days after a date of the source row, at a time of day on the venue's clock (09:00 by default). */
127
136
  due: z
128
137
  .object({
@@ -464,7 +473,7 @@ export const outboxSchema = z
464
473
  .object({
465
474
  kinds: z.array(z.string().min(1).max(40)).min(1).max(8),
466
475
  link: z.string().min(1).max(40),
467
- page: z.string().max(200).regex(/^\/(?:[A-Za-z0-9._~-]+\/?)*$/, 'a path on the app\'s customer side, such as "/review": no query, no fragment'),
476
+ page: z.string().max(200).regex(/^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]*$/, 'a path on the app\'s customer side, such as "/review": no query, no fragment'),
468
477
  })
469
478
  .strict()
470
479
  .optional(),
@@ -585,12 +594,33 @@ export const emailTemplateSchema = z
585
594
  attachments: z.array(emailTemplateAttachmentSchema).min(1).max(EMAIL_ATTACHMENTS_MAX).optional(),
586
595
  /** The variables it reads, for the editor's list. */
587
596
  vars: z.array(templateVariableSchema).max(60).optional(),
597
+ /**
598
+ * Blocks (by `id`) every copy of the mail carries, whoever edited it: the
599
+ * legal lines a confirmation owes its customer. A copy an operator edited
600
+ * that leaves one out, or changes what it reads, is sent with the app's
601
+ * own block added at the end, in the copy's language. Each id names a
602
+ * block of every language. From Adminium 0.3.86.
603
+ */
604
+ mustCarry: z.array(z.string().min(1).max(60)).min(1).max(20).optional(),
588
605
  /** The template in each language it ships, US English always among them. */
589
606
  locales: z
590
607
  .record(bcp47TagSchema, emailContentSchema)
591
608
  .refine((locales) => locales['en-US'] !== undefined, { message: 'a template includes en-US' }),
592
609
  })
593
610
  .strict();
611
+ /** Everything wrong with a template's `mustCarry`: each id names a block of every language, once. */
612
+ export function mustCarryIssues(template, path) {
613
+ const out = [];
614
+ (template.mustCarry ?? []).forEach((id, i) => {
615
+ if ((template.mustCarry ?? []).indexOf(id) !== i)
616
+ out.push({ path: [...path, 'mustCarry', i], message: `"${id}" is named twice` });
617
+ for (const [locale, content] of Object.entries(template.locales)) {
618
+ if (!content.blocks.some((block) => block.id === id))
619
+ out.push({ path: [...path, 'mustCarry', i], message: `the ${locale} mail has no block "${id}"` });
620
+ }
621
+ });
622
+ return out;
623
+ }
594
624
  /** The column rules that decide a value on the server (see `columnRulesSchema`). */
595
625
  const DECIDING_RULES = ['copy', 'default', 'sequence', 'format', 'code', 'rollup', 'formula', 'stamp', 'perNight'];
596
626
  /** The column rules that refuse a value: Adminium's own writes to the column would be refused by them. */
@@ -883,6 +913,10 @@ export function outboxIssues(m, index) {
883
913
  if (holds && status !== undefined && !(status.enum ?? []).includes(OUTBOX_HELD)) {
884
914
  out.push({ path: at('columns', 'status'), message: `a producer holds its messages, so "${box.table}.${status.ref}" offers "${OUTBOX_HELD}"` });
885
915
  }
916
+ const capped = (box.producers ?? []).some((producer) => producer.dailyCap !== undefined);
917
+ if (capped && status !== undefined && !(status.enum ?? []).includes(OUTBOX_HELD)) {
918
+ out.push({ path: at('columns', 'status'), message: `a producer's messages past its daily cap wait to be released, so "${box.table}.${status.ref}" offers "${OUTBOX_HELD}"` });
919
+ }
886
920
  if (holds && box.columns.due === undefined) {
887
921
  out.push({ path: at('columns'), message: 'a held message waits for its due moment: name the outbox\'s due column' });
888
922
  }