@adminiumjs/manifest 0.3.64 → 0.3.65

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.
@@ -0,0 +1,144 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ /**
3
+ * LANDING: THE ADD-ON BLOCK'S `landing` WORD.
4
+ *
5
+ * A landing pages add-on names which of its own tables hold its pages and its
6
+ * funnels:
7
+ *
8
+ * ```json
9
+ * "addOn": { "landing": { "pages": "pages", "funnels": "funnels" } }
10
+ * ```
11
+ *
12
+ * (`addOn.pages` is another word: the add-on's own staff screens.)
13
+ *
14
+ * The engine draws every live page for a stranger (no add-on code runs for
15
+ * one) and reads the funnels' steps, so each table must have the columns the
16
+ * engine reads, by these names and of these kinds ({@link LANDING_COLUMNS}),
17
+ * and a numbered key (a funnel's step and a page's link name a page by it).
18
+ * Staff write both tables through the add-on's screens, so roles and grants
19
+ * may write them; the engine seals the columns that publish a page (its
20
+ * state, its published copy and when it was published) in its own write
21
+ * service. No public entry of the add-on opens either table: strangers are
22
+ * served by the engine alone.
23
+ *
24
+ * A package declares one stranger's door: `landing` beside `forms` or `chat`
25
+ * is refused, since each door is vouched for, and its rows kept, per package.
26
+ *
27
+ * Pure: no I/O, and nothing imported from the manifest's own schema file, so
28
+ * that file may import this one.
29
+ */
30
+ import { z } from 'zod';
31
+ import { contractColumnIssues, contractColumns } from './forms.js';
32
+ import { refSchema } from './refs.js';
33
+ /** The block: the add-on's own tables, by ref. Both are required. */
34
+ export const addOnLandingSchema = z
35
+ .object({
36
+ pages: refSchema,
37
+ funnels: refSchema,
38
+ })
39
+ .strict();
40
+ export const LANDING_PARTS = ['pages', 'funnels'];
41
+ /** The category a package that declares landing pages is filed under. */
42
+ export const LANDING_CATEGORY = 'marketing';
43
+ /** Where a page stands: being written, served to strangers, or switched off. */
44
+ export const LANDING_STATES = ['draft', 'live', 'off'];
45
+ /** The longest a page's slug is (the landing slug rule in `@adminium/add-on-contracts/landing`). */
46
+ export const LANDING_SLUG_MAX = 80;
47
+ /** The most steps one funnel has. */
48
+ export const LANDING_FUNNEL_STEPS_MAX = 8;
49
+ const { text, moment, json, choice } = contractColumns;
50
+ /**
51
+ * The columns each part has, which the engine reads (and, for a page's
52
+ * publish columns, seals) by these names. A table may have more of its own,
53
+ * each nullable, with a default, decided by a rule, or a moment its role
54
+ * stamps (`created_at`, `updated_at`): nothing else the engine writes fills it.
55
+ */
56
+ export const LANDING_COLUMNS = {
57
+ pages: {
58
+ /** Staff's own name for the page, never shown to a stranger. */
59
+ name: text(200),
60
+ /** The last part of its address (`/x/pages/<slug>`). */
61
+ slug: text(LANDING_SLUG_MAX),
62
+ state: choice(LANDING_STATES),
63
+ /** The one language the page is written in. */
64
+ language: text(10),
65
+ /** The page document staff are working on; it may carry the assistant's marks. */
66
+ draft: json(),
67
+ /** The page document frozen at publish: strangers are served only this, and it never carries a mark. */
68
+ published: json(true),
69
+ /** When the published copy was written, set by the engine. */
70
+ published_at: moment(true),
71
+ updated_at: moment(),
72
+ },
73
+ funnels: {
74
+ name: text(200),
75
+ /** `[{ "kind": "page" | "form", "key": "…" }]`, at most eight, each naming a row by its key. */
76
+ steps: json(),
77
+ /** The rule picked by hand as what happens after the funnel. */
78
+ rule_id: text(64, true),
79
+ },
80
+ };
81
+ /**
82
+ * Whether Adminium writes a column on every create by its role: a moment
83
+ * (a time or a date) whose role is `created_at` or `updated_at` is stamped
84
+ * with the moment its row is made, and an `updated_at` again at each change,
85
+ * through every door (the kit's writes included). A role on any other type
86
+ * stamps nothing.
87
+ */
88
+ function stampedByRole(column) {
89
+ return (column.role === 'created_at' || column.role === 'updated_at') && (column.type === 'timestamptz' || column.type === 'date');
90
+ }
91
+ /** Everything wrong with an add-on's landing block, against its own tables and entries. */
92
+ export function landingBlockIssues(block, m) {
93
+ const out = [];
94
+ const tables = new Map(m.tables.map((table, t) => [table.ref, { table, t }]));
95
+ const at = (...rest) => ['addOn', 'landing', ...rest];
96
+ if (!m.categories.includes(LANDING_CATEGORY))
97
+ out.push({ path: ['categories'], message: `an add-on that declares landing pages is filed under the "${LANDING_CATEGORY}" category` });
98
+ // Each door is vouched for, and its rows kept, per package: one package with two would mix them.
99
+ if (m.forms === true)
100
+ out.push({ path: at(), message: 'an add-on declares landing pages or forms, not both: each is a package of its own' });
101
+ if (m.chat === true)
102
+ out.push({ path: at(), message: 'an add-on declares landing pages or chat, not both: each is a package of its own' });
103
+ const seen = new Map();
104
+ for (const part of LANDING_PARTS) {
105
+ const ref = block[part];
106
+ const other = seen.get(ref);
107
+ if (other !== undefined)
108
+ out.push({ path: at(part), message: `"${ref}" holds the ${other} already: each part of landing is a table of its own` });
109
+ seen.set(ref, part);
110
+ }
111
+ for (const part of LANDING_PARTS) {
112
+ const ref = block[part];
113
+ const found = tables.get(ref);
114
+ if (found === undefined) {
115
+ out.push({ path: at(part), message: `"${ref}" is not one of this add-on's tables` });
116
+ continue;
117
+ }
118
+ const { table, t } = found;
119
+ const contract = LANDING_COLUMNS[part];
120
+ out.push(...contractColumnIssues(table, t, `the ${part}`, contract, (to) => block[to]));
121
+ // A numbered key: a funnel's step and a page's link name a row by it.
122
+ const k = table.columns.findIndex((column) => column.role === 'pk');
123
+ const key = table.columns[k];
124
+ if (key === undefined)
125
+ out.push({ path: at(part), message: `"${ref}" holds the ${part}, so its rows are numbered: give it an int key (role "pk")` });
126
+ else if (key.type !== 'int' && key.type !== 'bigint')
127
+ out.push({ path: ['requiredSchema', 'tables', t, 'columns', k, 'type'], message: `"${ref}" holds the ${part}, so its rows are numbered: its key "${key.ref}" is an int or a bigint, not ${key.type}` });
128
+ // Every other column is one a write may leave out: nothing the engine writes fills it, but for a moment it stamps.
129
+ table.columns.forEach((column, c) => {
130
+ if (contract[column.ref] !== undefined || column.role === 'pk' || column.nullable === true || column.default !== undefined || m.decided?.(ref, column.ref) === true)
131
+ return;
132
+ if (stampedByRole(column))
133
+ return;
134
+ out.push({ path: ['requiredSchema', 'tables', t, 'columns', c], message: `"${ref}" holds the ${part}, and Adminium never fills "${column.ref}": make it nullable or give it a default` });
135
+ });
136
+ // The engine serves a stranger a live page and nothing else: no public entry of the add-on opens a landing table.
137
+ (m.publicAccess ?? []).forEach((entry, e) => {
138
+ if (entry.table === ref)
139
+ out.push({ path: ['publicAccess', e, 'table'], message: `"${ref}" holds the ${part}, which Adminium alone serves to strangers: no public entry opens it` });
140
+ });
141
+ }
142
+ return out;
143
+ }
144
+ //# sourceMappingURL=landing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"landing.js","sourceRoot":"","sources":["../src/landing.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAA6C,MAAM,YAAY,CAAC;AAC9G,OAAO,EAAE,SAAS,EAAuB,MAAM,WAAW,CAAC;AAE3D,qEAAqE;AACrE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC;KAChC,MAAM,CAAC;IACN,KAAK,EAAE,SAAS;IAChB,OAAO,EAAE,SAAS;CACnB,CAAC;KACD,MAAM,EAAE,CAAC;AAKZ,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,SAAS,CAA2C,CAAC;AAE5F,yEAAyE;AACzE,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAK5C,gFAAgF;AAChF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAU,CAAC;AAChE,oGAAoG;AACpG,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,qCAAqC;AACrC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAE1C,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC;AAEvD;;;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KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAClC,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI;gBAAE,OAAO;YAC5K,IAAI,aAAa,CAAC,MAAM,CAAC;gBAAE,OAAO;YAClC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,gBAAgB,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,GAAG,eAAe,IAAI,+BAA+B,MAAM,CAAC,GAAG,0CAA0C,EAAE,CAAC,CAAC;QAC5L,CAAC,CAAC,CAAC;QAEH,kHAAkH;QAClH,CAAC,CAAC,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YAC1C,IAAI,KAAK,CAAC,KAAK,KAAK,GAAG;gBAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,cAAc,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,GAAG,eAAe,IAAI,sEAAsE,EAAE,CAAC,CAAC;QACvL,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/sample.d.ts CHANGED
@@ -7,7 +7,10 @@
7
7
  *
8
8
  * `{"@ref": "<label>"}` the key of an earlier row with that `@label`
9
9
  * (or of a labelled starting row of the manifest's
10
- * own `seeds`: see `seedLabelsOf`)
10
+ * own `seeds`: see `seedLabelsOf`). In a column,
11
+ * and anywhere inside a json value (a funnel's
12
+ * step, a page's link), where it is the key as
13
+ * text: a json document names a row by a text key
11
14
  * `{"@ago": "PT19M"}` an ISO-8601 duration before now
12
15
  * `{"@in": "PT20M", "@grid": 15}` an ISO-8601 duration after now; with
13
16
  * `@grid`, rounded up to the next time on that
@@ -16,7 +19,8 @@
16
19
  * `{"@day": -1, "@time": "09:30"}` a wall time in the venue's own zone,
17
20
  * days from today
18
21
  * `{"@day": 3}` a date in the venue's own zone
19
- * `{"@t": {"en-US": "…"}}` the adding person's language
22
+ * `{"@t": {"en-US": "…"}}` the adding person's language; in a column, and
23
+ * anywhere inside a json value (a page's words)
20
24
  * `{"@asset": "<label>"}` a file from `assets`, added to the Files library:
21
25
  * a picture (in a picture column) or a product
22
26
  * asset — an SVG or a model (.glb, .stl, .3mf) —
@@ -30,6 +34,14 @@
30
34
  * or another text column that holds a staff id,
31
35
  * and anywhere inside a json value (a saved
32
36
  * filter that names a rep)
37
+ * `{"@rule": "<rule key>"}` the id of the rule the file's own app (or
38
+ * add-on) ships under that key (`automations`),
39
+ * as this install holds it: in a column (a
40
+ * funnel's `rule_id`) and anywhere inside a json
41
+ * value. A key with no such rule here (never
42
+ * shipped, or taken away) is written as null, and
43
+ * the server says so in its log: the rest of the
44
+ * sample goes in all the same
33
45
  *
34
46
  * A `@day` may add `"@workdays": true`: its days count Monday to Friday, and
35
47
  * day 0 on a weekend is the Monday after — so "today's" busy day is never a
@@ -118,6 +130,8 @@ export declare const sampleValueSchema: z.ZodUnion<readonly [z.ZodUnion<readonly
118
130
  '@table': z.ZodString;
119
131
  }, z.core.$strict>, z.ZodObject<{
120
132
  '@person': z.ZodString;
133
+ }, z.core.$strict>, z.ZodObject<{
134
+ '@rule': z.ZodString;
121
135
  }, z.core.$strict>]>, z.ZodArray<z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
122
136
  export declare const sampleRowSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodUnion<readonly [z.ZodObject<{
123
137
  '@ref': z.ZodString;
@@ -148,6 +162,8 @@ export declare const sampleRowSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readon
148
162
  '@table': z.ZodString;
149
163
  }, z.core.$strict>, z.ZodObject<{
150
164
  '@person': z.ZodString;
165
+ }, z.core.$strict>, z.ZodObject<{
166
+ '@rule': z.ZodString;
151
167
  }, z.core.$strict>]>, z.ZodArray<z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
152
168
  /** `@byClock`: a row's columns by where its time falls against the adding moment. */
153
169
  export declare const byClockSchema: z.ZodObject<{
@@ -180,6 +196,8 @@ export declare const byClockSchema: z.ZodObject<{
180
196
  '@table': z.ZodString;
181
197
  }, z.core.$strict>, z.ZodObject<{
182
198
  '@person': z.ZodString;
199
+ }, z.core.$strict>, z.ZodObject<{
200
+ '@rule': z.ZodString;
183
201
  }, z.core.$strict>]>]>;
184
202
  before: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodUnion<readonly [z.ZodObject<{
185
203
  '@ref': z.ZodString;
@@ -210,6 +228,8 @@ export declare const byClockSchema: z.ZodObject<{
210
228
  '@table': z.ZodString;
211
229
  }, z.core.$strict>, z.ZodObject<{
212
230
  '@person': z.ZodString;
231
+ }, z.core.$strict>, z.ZodObject<{
232
+ '@rule': z.ZodString;
213
233
  }, z.core.$strict>]>, z.ZodArray<z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>;
214
234
  around: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodUnion<readonly [z.ZodObject<{
215
235
  '@ref': z.ZodString;
@@ -240,6 +260,8 @@ export declare const byClockSchema: z.ZodObject<{
240
260
  '@table': z.ZodString;
241
261
  }, z.core.$strict>, z.ZodObject<{
242
262
  '@person': z.ZodString;
263
+ }, z.core.$strict>, z.ZodObject<{
264
+ '@rule': z.ZodString;
243
265
  }, z.core.$strict>]>, z.ZodArray<z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>;
244
266
  after: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodUnion<readonly [z.ZodObject<{
245
267
  '@ref': z.ZodString;
@@ -270,6 +292,8 @@ export declare const byClockSchema: z.ZodObject<{
270
292
  '@table': z.ZodString;
271
293
  }, z.core.$strict>, z.ZodObject<{
272
294
  '@person': z.ZodString;
295
+ }, z.core.$strict>, z.ZodObject<{
296
+ '@rule': z.ZodString;
273
297
  }, z.core.$strict>]>, z.ZodArray<z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>;
274
298
  }, z.core.$strict>;
275
299
  export type ByClock = z.infer<typeof byClockSchema>;
@@ -304,6 +328,8 @@ export declare const byStaySchema: z.ZodObject<{
304
328
  '@table': z.ZodString;
305
329
  }, z.core.$strict>, z.ZodObject<{
306
330
  '@person': z.ZodString;
331
+ }, z.core.$strict>, z.ZodObject<{
332
+ '@rule': z.ZodString;
307
333
  }, z.core.$strict>]>]>;
308
334
  to: z.ZodUnion<readonly [z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
309
335
  '@ref': z.ZodString;
@@ -334,6 +360,8 @@ export declare const byStaySchema: z.ZodObject<{
334
360
  '@table': z.ZodString;
335
361
  }, z.core.$strict>, z.ZodObject<{
336
362
  '@person': z.ZodString;
363
+ }, z.core.$strict>, z.ZodObject<{
364
+ '@rule': z.ZodString;
337
365
  }, z.core.$strict>]>]>;
338
366
  times: z.ZodOptional<z.ZodObject<{
339
367
  from: z.ZodOptional<z.ZodString>;
@@ -368,6 +396,8 @@ export declare const byStaySchema: z.ZodObject<{
368
396
  '@table': z.ZodString;
369
397
  }, z.core.$strict>, z.ZodObject<{
370
398
  '@person': z.ZodString;
399
+ }, z.core.$strict>, z.ZodObject<{
400
+ '@rule': z.ZodString;
371
401
  }, z.core.$strict>]>, z.ZodArray<z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>;
372
402
  during: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodUnion<readonly [z.ZodObject<{
373
403
  '@ref': z.ZodString;
@@ -398,6 +428,8 @@ export declare const byStaySchema: z.ZodObject<{
398
428
  '@table': z.ZodString;
399
429
  }, z.core.$strict>, z.ZodObject<{
400
430
  '@person': z.ZodString;
431
+ }, z.core.$strict>, z.ZodObject<{
432
+ '@rule': z.ZodString;
401
433
  }, z.core.$strict>]>, z.ZodArray<z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>;
402
434
  after: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodUnion<readonly [z.ZodObject<{
403
435
  '@ref': z.ZodString;
@@ -428,6 +460,8 @@ export declare const byStaySchema: z.ZodObject<{
428
460
  '@table': z.ZodString;
429
461
  }, z.core.$strict>, z.ZodObject<{
430
462
  '@person': z.ZodString;
463
+ }, z.core.$strict>, z.ZodObject<{
464
+ '@rule': z.ZodString;
431
465
  }, z.core.$strict>]>, z.ZodArray<z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>;
432
466
  }, z.core.$strict>;
433
467
  export type ByStay = z.infer<typeof byStaySchema>;
@@ -506,6 +540,8 @@ export declare const sampleBundleSchema: z.ZodObject<{
506
540
  '@table': z.ZodString;
507
541
  }, z.core.$strict>, z.ZodObject<{
508
542
  '@person': z.ZodString;
543
+ }, z.core.$strict>, z.ZodObject<{
544
+ '@rule': z.ZodString;
509
545
  }, z.core.$strict>]>, z.ZodArray<z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>;
510
546
  }, z.core.$strict>>;
511
547
  moves: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -556,12 +592,33 @@ export declare function sampleDirective(value: unknown): {
556
592
  } | {
557
593
  kind: 'person';
558
594
  key: string;
595
+ } | {
596
+ kind: 'rule';
597
+ key: string;
559
598
  } | null;
560
599
  /**
561
600
  * Every sample person a value names: itself, or anywhere inside it when it
562
601
  * is a json value (an object or a list that is no directive of its own).
563
602
  */
564
603
  export declare function samplePeopleIn(value: unknown): string[];
604
+ /**
605
+ * How deep inside a json value a directive is resolved (`@ref`, `@person`,
606
+ * `@t`, `@rule`; any other one there is written as it stands): a page
607
+ * document names another page five levels down (its blocks, a block, its
608
+ * button, the link, the key), so sixteen is room to spare, and the loader
609
+ * never walks a value nested without end. One deeper is refused by the check.
610
+ */
611
+ export declare const SAMPLE_JSON_DEPTH = 16;
612
+ /**
613
+ * Every row a json value names inside it (`{"@ref": label}` in an object or a
614
+ * list that is no directive of its own), within {@link SAMPLE_JSON_DEPTH}
615
+ * levels; `deeper` when a directive the loader resolves inside json sits
616
+ * past them, where it would be left as written.
617
+ */
618
+ export declare function sampleJsonRefs(value: unknown): {
619
+ labels: string[];
620
+ deeper: boolean;
621
+ };
565
622
  /** An ISO-8601 duration in milliseconds. */
566
623
  export declare function isoDurationMs(duration: string): number;
567
624
  export interface SampleIssue {
@@ -1 +1 @@
1
- {"version":3,"file":"sample.d.ts","sourceRoot":"","sources":["../src/sample.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsFG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAiD,KAAK,aAAa,EAAE,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,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAUtD;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AA2BD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,GAAG,WAAW,EAAE,CAiB1F;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,CAM5D;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAA;CAAE,EAAE,CAgB5J;AAwDD;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,CA8B/E;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,CAY/E;AAED,0HAA0H;AAC1H,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAIxF;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,aAAa,GAAG,WAAW,EAAE,CAkEhH"}
package/dist/sample.js CHANGED
@@ -8,7 +8,10 @@
8
8
  *
9
9
  * `{"@ref": "<label>"}` the key of an earlier row with that `@label`
10
10
  * (or of a labelled starting row of the manifest's
11
- * own `seeds`: see `seedLabelsOf`)
11
+ * own `seeds`: see `seedLabelsOf`). In a column,
12
+ * and anywhere inside a json value (a funnel's
13
+ * step, a page's link), where it is the key as
14
+ * text: a json document names a row by a text key
12
15
  * `{"@ago": "PT19M"}` an ISO-8601 duration before now
13
16
  * `{"@in": "PT20M", "@grid": 15}` an ISO-8601 duration after now; with
14
17
  * `@grid`, rounded up to the next time on that
@@ -17,7 +20,8 @@
17
20
  * `{"@day": -1, "@time": "09:30"}` a wall time in the venue's own zone,
18
21
  * days from today
19
22
  * `{"@day": 3}` a date in the venue's own zone
20
- * `{"@t": {"en-US": "…"}}` the adding person's language
23
+ * `{"@t": {"en-US": "…"}}` the adding person's language; in a column, and
24
+ * anywhere inside a json value (a page's words)
21
25
  * `{"@asset": "<label>"}` a file from `assets`, added to the Files library:
22
26
  * a picture (in a picture column) or a product
23
27
  * asset — an SVG or a model (.glb, .stl, .3mf) —
@@ -31,6 +35,14 @@
31
35
  * or another text column that holds a staff id,
32
36
  * and anywhere inside a json value (a saved
33
37
  * filter that names a rep)
38
+ * `{"@rule": "<rule key>"}` the id of the rule the file's own app (or
39
+ * add-on) ships under that key (`automations`),
40
+ * as this install holds it: in a column (a
41
+ * funnel's `rule_id`) and anywhere inside a json
42
+ * value. A key with no such rule here (never
43
+ * shipped, or taken away) is written as null, and
44
+ * the server says so in its log: the rest of the
45
+ * sample goes in all the same
34
46
  *
35
47
  * A `@day` may add `"@workdays": true`: its days count Monday to Friday, and
36
48
  * day 0 on a weekend is the Monday after — so "today's" busy day is never a
@@ -127,6 +139,7 @@ const directive = z.union([
127
139
  z.object({ '@asset': label }).strict(),
128
140
  z.object({ '@table': z.string().regex(/^[a-z][a-z0-9_]*$/, 'a table') }).strict(),
129
141
  z.object({ '@person': z.string().regex(/^[a-z][a-z0-9_-]{0,39}$/, 'a sample person\'s key') }).strict(),
142
+ z.object({ '@rule': z.string().regex(/^[a-z][a-z0-9-]{0,79}$/, 'a rule\'s key') }).strict(),
130
143
  ]);
131
144
  const plain = z.union([z.string(), z.number(), z.boolean(), z.null()]);
132
145
  /** A column's value: a plain value, a directive, or (for a json column) any object or array. */
@@ -257,6 +270,8 @@ export function sampleDirective(value) {
257
270
  return { kind: 'table', ref: record['@table'] };
258
271
  if (typeof record['@person'] === 'string')
259
272
  return { kind: 'person', key: record['@person'] };
273
+ if (typeof record['@rule'] === 'string')
274
+ return { kind: 'rule', key: record['@rule'] };
260
275
  return null;
261
276
  }
262
277
  /**
@@ -273,6 +288,48 @@ export function samplePeopleIn(value) {
273
288
  return Object.values(value).flatMap(samplePeopleIn);
274
289
  return [];
275
290
  }
291
+ /**
292
+ * How deep inside a json value a directive is resolved (`@ref`, `@person`,
293
+ * `@t`, `@rule`; any other one there is written as it stands): a page
294
+ * document names another page five levels down (its blocks, a block, its
295
+ * button, the link, the key), so sixteen is room to spare, and the loader
296
+ * never walks a value nested without end. One deeper is refused by the check.
297
+ */
298
+ export const SAMPLE_JSON_DEPTH = 16;
299
+ /**
300
+ * Every row a json value names inside it (`{"@ref": label}` in an object or a
301
+ * list that is no directive of its own), within {@link SAMPLE_JSON_DEPTH}
302
+ * levels; `deeper` when a directive the loader resolves inside json sits
303
+ * past them, where it would be left as written.
304
+ */
305
+ export function sampleJsonRefs(value) {
306
+ const labels = [];
307
+ let deeper = false;
308
+ const walk = (inner, depth) => {
309
+ if (typeof inner !== 'object' || inner === null)
310
+ return;
311
+ if (depth > SAMPLE_JSON_DEPTH) {
312
+ // Past the depth the loader reads: what is there stays as written.
313
+ if (/"@(ref|person|t|rule)"/.test(JSON.stringify(inner)))
314
+ deeper = true;
315
+ return;
316
+ }
317
+ const found = sampleDirective(inner);
318
+ if (found?.kind === 'ref')
319
+ labels.push(found.label);
320
+ if (found !== null)
321
+ return;
322
+ for (const item of Array.isArray(inner) ? inner : Object.values(inner))
323
+ walk(item, depth + 1);
324
+ };
325
+ // The value itself is a column's value, read from its items on: a directive there is the column's own (its
326
+ // fields are plain text), not one inside json.
327
+ if (typeof value === 'object' && value !== null) {
328
+ for (const item of Array.isArray(value) ? value : Object.values(value))
329
+ walk(item, 1);
330
+ }
331
+ return { labels, deeper };
332
+ }
276
333
  /** An ISO-8601 duration in milliseconds. */
277
334
  export function isoDurationMs(duration) {
278
335
  const match = ISO_DURATION.exec(duration);
@@ -869,6 +926,10 @@ function rowIssues(bundle, declared, opts) {
869
926
  if (holds?.type !== 'text')
870
927
  issues.push({ path: `${at}.${column}`, message: `"${table.ref}.${column}" is not a text column, so it cannot hold a staff member.` });
871
928
  }
929
+ // A rule's id is text: a funnel's `rule_id`. Which rules there are is the install's to say, never a reason to refuse.
930
+ if (found?.kind === 'rule' && shape.columns.find((c) => c.ref === column)?.type !== 'text') {
931
+ issues.push({ path: `${at}.${column}`, message: `"${table.ref}.${column}" is not a text column, so it cannot hold a rule.` });
932
+ }
872
933
  if (found?.kind === 'table') {
873
934
  const holds = shape.columns.find((c) => c.ref === column);
874
935
  if (!opts.names.has(found.ref))
@@ -885,6 +946,17 @@ function rowIssues(bundle, declared, opts) {
885
946
  else if (found?.kind === 'ref' && mayBeLeftOut.has(found.label)) {
886
947
  issues.push({ path: `${at}.${column}`, message: `"${found.label}" is in a table only for an empty table, so it may not be written: nothing points at it.` });
887
948
  }
949
+ // A row named inside a json value (a funnel's steps): the same rules as a column's `@ref`.
950
+ const inside = sampleJsonRefs(value);
951
+ for (const named of inside.labels) {
952
+ if (!seen.has(named) && !opts.otherLabels)
953
+ issues.push({ path: `${at}.${column}`, message: `"${named}" is not an earlier row: a referenced row must come first.` });
954
+ else if (mayBeLeftOut.has(named))
955
+ issues.push({ path: `${at}.${column}`, message: `"${named}" is in a table only for an empty table, so it may not be written: nothing points at it.` });
956
+ }
957
+ if (inside.deeper) {
958
+ issues.push({ path: `${at}.${column}`, message: `A "@ref", "@person", "@t" or "@rule" inside "${column}" is more than ${String(SAMPLE_JSON_DEPTH)} levels down, where it is not read: move it up.` });
959
+ }
888
960
  if (found?.kind === 'asset' && bundle.assets[found.label] === undefined) {
889
961
  issues.push({ path: `${at}.${column}`, message: `"${found.label}" is not one of the bundle’s assets.` });
890
962
  }