@adminiumjs/manifest 0.3.17 → 0.3.18

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.
Files changed (90) hide show
  1. package/dist/adjust.d.ts +322 -0
  2. package/dist/adjust.d.ts.map +1 -0
  3. package/dist/adjust.js +512 -0
  4. package/dist/adjust.js.map +1 -0
  5. package/dist/automations.d.ts +2309 -0
  6. package/dist/automations.d.ts.map +1 -0
  7. package/dist/automations.js +384 -0
  8. package/dist/automations.js.map +1 -0
  9. package/dist/compose.d.ts.map +1 -1
  10. package/dist/compose.js +1 -0
  11. package/dist/compose.js.map +1 -1
  12. package/dist/documents.d.ts +82 -1
  13. package/dist/documents.d.ts.map +1 -1
  14. package/dist/documents.js +36 -6
  15. package/dist/documents.js.map +1 -1
  16. package/dist/index.d.ts +15 -6
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +15 -6
  19. package/dist/index.js.map +1 -1
  20. package/dist/key-bytes.d.ts +27 -0
  21. package/dist/key-bytes.d.ts.map +1 -0
  22. package/dist/key-bytes.js +48 -0
  23. package/dist/key-bytes.js.map +1 -0
  24. package/dist/ledger-indexes.d.ts +19 -0
  25. package/dist/ledger-indexes.d.ts.map +1 -0
  26. package/dist/ledger-indexes.js +74 -0
  27. package/dist/ledger-indexes.js.map +1 -0
  28. package/dist/ledgers.d.ts +691 -0
  29. package/dist/ledgers.d.ts.map +1 -0
  30. package/dist/ledgers.js +778 -0
  31. package/dist/ledgers.js.map +1 -0
  32. package/dist/look-up.d.ts +73 -0
  33. package/dist/look-up.d.ts.map +1 -0
  34. package/dist/look-up.js +140 -0
  35. package/dist/look-up.js.map +1 -0
  36. package/dist/marketplace-wire.d.ts +2 -2
  37. package/dist/outbox.d.ts +29 -3
  38. package/dist/outbox.d.ts.map +1 -1
  39. package/dist/outbox.js +94 -15
  40. package/dist/outbox.js.map +1 -1
  41. package/dist/page-config.d.ts +99 -0
  42. package/dist/page-config.d.ts.map +1 -0
  43. package/dist/page-config.js +197 -0
  44. package/dist/page-config.js.map +1 -0
  45. package/dist/plan-context.d.ts +8 -18
  46. package/dist/plan-context.d.ts.map +1 -1
  47. package/dist/plan-context.js +53 -51
  48. package/dist/plan-context.js.map +1 -1
  49. package/dist/plan-model.d.ts +8 -1
  50. package/dist/plan-model.d.ts.map +1 -1
  51. package/dist/plan.d.ts +1 -1
  52. package/dist/plan.d.ts.map +1 -1
  53. package/dist/plan.js +6 -3
  54. package/dist/plan.js.map +1 -1
  55. package/dist/public-access.d.ts +33 -5
  56. package/dist/public-access.d.ts.map +1 -1
  57. package/dist/public-access.js +82 -4
  58. package/dist/public-access.js.map +1 -1
  59. package/dist/refs.d.ts +2 -0
  60. package/dist/refs.d.ts.map +1 -1
  61. package/dist/refs.js +5 -0
  62. package/dist/refs.js.map +1 -1
  63. package/dist/roles.d.ts +46 -0
  64. package/dist/roles.d.ts.map +1 -1
  65. package/dist/roles.js +50 -0
  66. package/dist/roles.js.map +1 -1
  67. package/dist/sample.d.ts +70 -1
  68. package/dist/sample.d.ts.map +1 -1
  69. package/dist/sample.js +208 -5
  70. package/dist/sample.js.map +1 -1
  71. package/dist/schema.d.ts +9657 -2440
  72. package/dist/schema.d.ts.map +1 -1
  73. package/dist/schema.js +751 -52
  74. package/dist/schema.js.map +1 -1
  75. package/dist/state-actions.d.ts +185 -0
  76. package/dist/state-actions.d.ts.map +1 -0
  77. package/dist/state-actions.js +223 -0
  78. package/dist/state-actions.js.map +1 -0
  79. package/dist/states.d.ts +66 -0
  80. package/dist/states.d.ts.map +1 -1
  81. package/dist/states.js +31 -0
  82. package/dist/states.js.map +1 -1
  83. package/dist/validate.d.ts.map +1 -1
  84. package/dist/validate.js +22 -6
  85. package/dist/validate.js.map +1 -1
  86. package/dist/words.d.ts +33 -0
  87. package/dist/words.d.ts.map +1 -0
  88. package/dist/words.js +208 -0
  89. package/dist/words.js.map +1 -0
  90. package/package.json +2 -2
@@ -0,0 +1,691 @@
1
+ /**
2
+ * LEDGERS AND POSTINGS.
3
+ *
4
+ * A ledger is an add-on's own set of tables that only Adminium writes, from
5
+ * rows the add-on's code works out (stock movements, a gift card's spends).
6
+ * The add-on declares it under `addOn.ledgers`: its receipt table, the tables
7
+ * and columns that may be written, and its ACTIONS (use, receive, spend …) —
8
+ * each with the inputs it takes, the rows it reads first and the rows a lock
9
+ * is named by.
10
+ *
11
+ * A posting is the other half, declared on any table of any manifest
12
+ * (`postings`): "when a row of this table reaches this point, hand these
13
+ * columns to that action". An order line reserving stock at checkout and
14
+ * taking it when the order is picked up is one posting with two points.
15
+ *
16
+ * This file holds the words and what one manifest can check of them by
17
+ * itself. Whether a host's posting fits the ledger it names is checked with
18
+ * both manifests at hand (`postingFitIssues`), at install and when an owner
19
+ * stores a rule.
20
+ *
21
+ * Pure: no I/O, and nothing imported from the manifest's own schema file, so
22
+ * that file may import this one.
23
+ */
24
+ import { z } from 'zod';
25
+ import { type ReferenceIssue } from './refs.js';
26
+ /** The most ledgers one add-on declares. */
27
+ export declare const LEDGERS_MAX = 4;
28
+ /** The most actions one ledger declares. */
29
+ export declare const LEDGER_ACTIONS_MAX = 16;
30
+ /** The most tables one ledger may write. */
31
+ export declare const LEDGER_WRITES_MAX = 12;
32
+ /** The most reads one action declares. */
33
+ export declare const LEDGER_READS_MAX = 6;
34
+ /** The most rows one read returns. */
35
+ export declare const LEDGER_READ_ROWS = 1000;
36
+ /** The most postings one table carries. */
37
+ export declare const POSTINGS_PER_TABLE = 6;
38
+ /** What an action's input is: a link, a number, text, a date, a yes/no, a table's stored name, or a row of any table. */
39
+ export declare const LEDGER_INPUT_TYPES: readonly ["link", "link?", "number", "number?", "decimal", "decimal?", "text", "text?", "date?", "bool?", "tableRef", "rowRef"];
40
+ export type LedgerInputType = (typeof LEDGER_INPUT_TYPES)[number];
41
+ /** Whether a posting may leave the input unmapped. */
42
+ export declare const optionalInput: (type: LedgerInputType) => boolean;
43
+ /** The phases of a posting round: held, taken, given back. */
44
+ export declare const POSTING_PHASES: readonly ["reserve", "post", "reverse"];
45
+ export type PostingPhase = (typeof POSTING_PHASES)[number];
46
+ /**
47
+ * Where a read's key comes from: an input of the action (`input.item`; a
48
+ * `rowRef` input as `input.what.table` / `input.what.row`), a column of an
49
+ * earlier read (`items.unit_id`), the source row (`source.table`,
50
+ * `source.row`, `source.line`), the round's receipt (`receipt.id`), a column
51
+ * of the add-on's settings row (`setting.low_below`), or what a price
52
+ * question recorded (`uses.offer`, `uses.code`, `uses.voucher`).
53
+ */
54
+ export declare const readFromSchema: z.ZodString;
55
+ /** One read an action makes before its code runs: rows of an own table, by up to three keys. */
56
+ export declare const ledgerReadSchema: z.ZodObject<{
57
+ as: z.ZodString;
58
+ table: z.ZodString;
59
+ by: z.ZodArray<z.ZodObject<{
60
+ column: z.ZodString;
61
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
62
+ }, z.core.$strict>>;
63
+ where: z.ZodOptional<z.ZodArray<z.ZodObject<{
64
+ column: z.ZodString;
65
+ eq: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
66
+ in: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
67
+ }, z.core.$strict>>>;
68
+ limit: z.ZodOptional<z.ZodNumber>;
69
+ }, z.core.$strict>;
70
+ export type LedgerRead = z.infer<typeof ledgerReadSchema>;
71
+ export declare const ledgerActionSchema: z.ZodObject<{
72
+ inputs: z.ZodRecord<z.ZodString, z.ZodEnum<{
73
+ number: "number";
74
+ decimal: "decimal";
75
+ link: "link";
76
+ text: "text";
77
+ "link?": "link?";
78
+ "number?": "number?";
79
+ "decimal?": "decimal?";
80
+ "text?": "text?";
81
+ "date?": "date?";
82
+ "bool?": "bool?";
83
+ tableRef: "tableRef";
84
+ rowRef: "rowRef";
85
+ }>>;
86
+ phases: z.ZodArray<z.ZodEnum<{
87
+ reverse: "reverse";
88
+ reserve: "reserve";
89
+ post: "post";
90
+ }>>;
91
+ reads: z.ZodArray<z.ZodObject<{
92
+ as: z.ZodString;
93
+ table: z.ZodString;
94
+ by: z.ZodArray<z.ZodObject<{
95
+ column: z.ZodString;
96
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
97
+ }, z.core.$strict>>;
98
+ where: z.ZodOptional<z.ZodArray<z.ZodObject<{
99
+ column: z.ZodString;
100
+ eq: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
101
+ in: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
102
+ }, z.core.$strict>>>;
103
+ limit: z.ZodOptional<z.ZodNumber>;
104
+ }, z.core.$strict>>;
105
+ locks: z.ZodArray<z.ZodObject<{
106
+ read: z.ZodString;
107
+ column: z.ZodString;
108
+ table: z.ZodString;
109
+ }, z.core.$strict>>;
110
+ decides: z.ZodOptional<z.ZodArray<z.ZodObject<{
111
+ input: z.ZodString;
112
+ min: z.ZodLiteral<"0">;
113
+ max: z.ZodUnion<readonly [z.ZodObject<{
114
+ input: z.ZodString;
115
+ }, z.core.$strict>, z.ZodObject<{
116
+ read: z.ZodString;
117
+ column: z.ZodString;
118
+ }, z.core.$strict>]>;
119
+ }, z.core.$strict>>>;
120
+ holds: z.ZodOptional<z.ZodLiteral<true>>;
121
+ unavailable: z.ZodOptional<z.ZodObject<{
122
+ allow: z.ZodObject<{
123
+ read: z.ZodString;
124
+ column: z.ZodString;
125
+ }, z.core.$strict>;
126
+ }, z.core.$strict>>;
127
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
128
+ }, z.core.$strict>;
129
+ export type LedgerAction = z.infer<typeof ledgerActionSchema>;
130
+ /**
131
+ * The table a `link` input names a row of: the table of the action's read
132
+ * that is keyed by its own primary key and fed by that input. Null when no
133
+ * read says so (an input the add-on's code looks up by another column).
134
+ * `keyOf` answers a table's primary-key column.
135
+ */
136
+ export declare function linkInputTable(action: Pick<LedgerAction, 'inputs' | 'reads'>, input: string, keyOf: (table: string) => string | undefined): string | null;
137
+ export declare const ledgerSchema: z.ZodObject<{
138
+ id: z.ZodString;
139
+ receipts: z.ZodString;
140
+ refusal: z.ZodEnum<{
141
+ value: "value";
142
+ stock: "stock";
143
+ }>;
144
+ writes: z.ZodRecord<z.ZodString, z.ZodObject<{
145
+ insert: z.ZodOptional<z.ZodArray<z.ZodString>>;
146
+ update: z.ZodOptional<z.ZodObject<{
147
+ by: z.ZodArray<z.ZodString>;
148
+ set: z.ZodArray<z.ZodString>;
149
+ }, z.core.$strict>>;
150
+ }, z.core.$strict>>;
151
+ actions: z.ZodRecord<z.ZodString, z.ZodObject<{
152
+ inputs: z.ZodRecord<z.ZodString, z.ZodEnum<{
153
+ number: "number";
154
+ decimal: "decimal";
155
+ link: "link";
156
+ text: "text";
157
+ "link?": "link?";
158
+ "number?": "number?";
159
+ "decimal?": "decimal?";
160
+ "text?": "text?";
161
+ "date?": "date?";
162
+ "bool?": "bool?";
163
+ tableRef: "tableRef";
164
+ rowRef: "rowRef";
165
+ }>>;
166
+ phases: z.ZodArray<z.ZodEnum<{
167
+ reverse: "reverse";
168
+ reserve: "reserve";
169
+ post: "post";
170
+ }>>;
171
+ reads: z.ZodArray<z.ZodObject<{
172
+ as: z.ZodString;
173
+ table: z.ZodString;
174
+ by: z.ZodArray<z.ZodObject<{
175
+ column: z.ZodString;
176
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
177
+ }, z.core.$strict>>;
178
+ where: z.ZodOptional<z.ZodArray<z.ZodObject<{
179
+ column: z.ZodString;
180
+ eq: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
181
+ in: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
182
+ }, z.core.$strict>>>;
183
+ limit: z.ZodOptional<z.ZodNumber>;
184
+ }, z.core.$strict>>;
185
+ locks: z.ZodArray<z.ZodObject<{
186
+ read: z.ZodString;
187
+ column: z.ZodString;
188
+ table: z.ZodString;
189
+ }, z.core.$strict>>;
190
+ decides: z.ZodOptional<z.ZodArray<z.ZodObject<{
191
+ input: z.ZodString;
192
+ min: z.ZodLiteral<"0">;
193
+ max: z.ZodUnion<readonly [z.ZodObject<{
194
+ input: z.ZodString;
195
+ }, z.core.$strict>, z.ZodObject<{
196
+ read: z.ZodString;
197
+ column: z.ZodString;
198
+ }, z.core.$strict>]>;
199
+ }, z.core.$strict>>>;
200
+ holds: z.ZodOptional<z.ZodLiteral<true>>;
201
+ unavailable: z.ZodOptional<z.ZodObject<{
202
+ allow: z.ZodObject<{
203
+ read: z.ZodString;
204
+ column: z.ZodString;
205
+ }, z.core.$strict>;
206
+ }, z.core.$strict>>;
207
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
208
+ }, z.core.$strict>>;
209
+ }, z.core.$strict>;
210
+ export type Ledger = z.infer<typeof ledgerSchema>;
211
+ export declare const ledgersSchema: z.ZodArray<z.ZodObject<{
212
+ id: z.ZodString;
213
+ receipts: z.ZodString;
214
+ refusal: z.ZodEnum<{
215
+ value: "value";
216
+ stock: "stock";
217
+ }>;
218
+ writes: z.ZodRecord<z.ZodString, z.ZodObject<{
219
+ insert: z.ZodOptional<z.ZodArray<z.ZodString>>;
220
+ update: z.ZodOptional<z.ZodObject<{
221
+ by: z.ZodArray<z.ZodString>;
222
+ set: z.ZodArray<z.ZodString>;
223
+ }, z.core.$strict>>;
224
+ }, z.core.$strict>>;
225
+ actions: z.ZodRecord<z.ZodString, z.ZodObject<{
226
+ inputs: z.ZodRecord<z.ZodString, z.ZodEnum<{
227
+ number: "number";
228
+ decimal: "decimal";
229
+ link: "link";
230
+ text: "text";
231
+ "link?": "link?";
232
+ "number?": "number?";
233
+ "decimal?": "decimal?";
234
+ "text?": "text?";
235
+ "date?": "date?";
236
+ "bool?": "bool?";
237
+ tableRef: "tableRef";
238
+ rowRef: "rowRef";
239
+ }>>;
240
+ phases: z.ZodArray<z.ZodEnum<{
241
+ reverse: "reverse";
242
+ reserve: "reserve";
243
+ post: "post";
244
+ }>>;
245
+ reads: z.ZodArray<z.ZodObject<{
246
+ as: z.ZodString;
247
+ table: z.ZodString;
248
+ by: z.ZodArray<z.ZodObject<{
249
+ column: z.ZodString;
250
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
251
+ }, z.core.$strict>>;
252
+ where: z.ZodOptional<z.ZodArray<z.ZodObject<{
253
+ column: z.ZodString;
254
+ eq: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
255
+ in: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
256
+ }, z.core.$strict>>>;
257
+ limit: z.ZodOptional<z.ZodNumber>;
258
+ }, z.core.$strict>>;
259
+ locks: z.ZodArray<z.ZodObject<{
260
+ read: z.ZodString;
261
+ column: z.ZodString;
262
+ table: z.ZodString;
263
+ }, z.core.$strict>>;
264
+ decides: z.ZodOptional<z.ZodArray<z.ZodObject<{
265
+ input: z.ZodString;
266
+ min: z.ZodLiteral<"0">;
267
+ max: z.ZodUnion<readonly [z.ZodObject<{
268
+ input: z.ZodString;
269
+ }, z.core.$strict>, z.ZodObject<{
270
+ read: z.ZodString;
271
+ column: z.ZodString;
272
+ }, z.core.$strict>]>;
273
+ }, z.core.$strict>>>;
274
+ holds: z.ZodOptional<z.ZodLiteral<true>>;
275
+ unavailable: z.ZodOptional<z.ZodObject<{
276
+ allow: z.ZodObject<{
277
+ read: z.ZodString;
278
+ column: z.ZodString;
279
+ }, z.core.$strict>;
280
+ }, z.core.$strict>>;
281
+ writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
282
+ }, z.core.$strict>>;
283
+ }, z.core.$strict>>;
284
+ /**
285
+ * The moment a posting's phase fires: the row's own create; a move of its
286
+ * state; a column reaching a value; a column being filled. Under `via` every
287
+ * point but a create is judged on the parent row, unless it says `own`.
288
+ */
289
+ export declare const postingPointSchema: z.ZodUnion<readonly [z.ZodObject<{
290
+ create: z.ZodLiteral<true>;
291
+ }, z.core.$strict>, z.ZodObject<{
292
+ to: z.ZodArray<z.ZodString>;
293
+ from: z.ZodOptional<z.ZodArray<z.ZodString>>;
294
+ }, z.core.$strict>, z.ZodObject<{
295
+ column: z.ZodString;
296
+ in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
297
+ from: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
298
+ own: z.ZodOptional<z.ZodLiteral<true>>;
299
+ }, z.core.$strict>, z.ZodObject<{
300
+ column: z.ZodString;
301
+ set: z.ZodLiteral<true>;
302
+ own: z.ZodOptional<z.ZodLiteral<true>>;
303
+ }, z.core.$strict>]>;
304
+ export type PostingPoint = z.infer<typeof postingPointSchema>;
305
+ /** What an input is filled from: a column of the row, the row itself, a column of the `via` parent, a setting of the add-on, or a fixed value. */
306
+ export declare const postingMappingSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
307
+ row: z.ZodLiteral<true>;
308
+ }, z.core.$strict>, z.ZodObject<{
309
+ parent: z.ZodString;
310
+ }, z.core.$strict>, z.ZodObject<{
311
+ setting: z.ZodString;
312
+ }, z.core.$strict>, z.ZodObject<{
313
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
314
+ }, z.core.$strict>]>;
315
+ export type PostingMapping = z.infer<typeof postingMappingSchema>;
316
+ export declare const postingSchema: z.ZodObject<{
317
+ id: z.ZodString;
318
+ into: z.ZodObject<{
319
+ addOn: z.ZodString;
320
+ ledger: z.ZodString;
321
+ action: z.ZodString;
322
+ }, z.core.$strict>;
323
+ needs: z.ZodOptional<z.ZodString>;
324
+ via: z.ZodOptional<z.ZodString>;
325
+ reserve: z.ZodOptional<z.ZodObject<{
326
+ on: z.ZodUnion<readonly [z.ZodObject<{
327
+ create: z.ZodLiteral<true>;
328
+ }, z.core.$strict>, z.ZodObject<{
329
+ to: z.ZodArray<z.ZodString>;
330
+ from: z.ZodOptional<z.ZodArray<z.ZodString>>;
331
+ }, z.core.$strict>, z.ZodObject<{
332
+ column: z.ZodString;
333
+ in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
334
+ from: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
335
+ own: z.ZodOptional<z.ZodLiteral<true>>;
336
+ }, z.core.$strict>, z.ZodObject<{
337
+ column: z.ZodString;
338
+ set: z.ZodLiteral<true>;
339
+ own: z.ZodOptional<z.ZodLiteral<true>>;
340
+ }, z.core.$strict>]>;
341
+ }, z.core.$strict>>;
342
+ post: z.ZodOptional<z.ZodObject<{
343
+ on: z.ZodUnion<readonly [z.ZodObject<{
344
+ create: z.ZodLiteral<true>;
345
+ }, z.core.$strict>, z.ZodObject<{
346
+ to: z.ZodArray<z.ZodString>;
347
+ from: z.ZodOptional<z.ZodArray<z.ZodString>>;
348
+ }, z.core.$strict>, z.ZodObject<{
349
+ column: z.ZodString;
350
+ in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
351
+ from: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
352
+ own: z.ZodOptional<z.ZodLiteral<true>>;
353
+ }, z.core.$strict>, z.ZodObject<{
354
+ column: z.ZodString;
355
+ set: z.ZodLiteral<true>;
356
+ own: z.ZodOptional<z.ZodLiteral<true>>;
357
+ }, z.core.$strict>]>;
358
+ }, z.core.$strict>>;
359
+ reverse: z.ZodOptional<z.ZodObject<{
360
+ on: z.ZodUnion<readonly [z.ZodObject<{
361
+ create: z.ZodLiteral<true>;
362
+ }, z.core.$strict>, z.ZodObject<{
363
+ to: z.ZodArray<z.ZodString>;
364
+ from: z.ZodOptional<z.ZodArray<z.ZodString>>;
365
+ }, z.core.$strict>, z.ZodObject<{
366
+ column: z.ZodString;
367
+ in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
368
+ from: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
369
+ own: z.ZodOptional<z.ZodLiteral<true>>;
370
+ }, z.core.$strict>, z.ZodObject<{
371
+ column: z.ZodString;
372
+ set: z.ZodLiteral<true>;
373
+ own: z.ZodOptional<z.ZodLiteral<true>>;
374
+ }, z.core.$strict>]>;
375
+ }, z.core.$strict>>;
376
+ map: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
377
+ row: z.ZodLiteral<true>;
378
+ }, z.core.$strict>, z.ZodObject<{
379
+ parent: z.ZodString;
380
+ }, z.core.$strict>, z.ZodObject<{
381
+ setting: z.ZodString;
382
+ }, z.core.$strict>, z.ZodObject<{
383
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
384
+ }, z.core.$strict>]>>;
385
+ multipliers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
386
+ row: z.ZodLiteral<true>;
387
+ }, z.core.$strict>, z.ZodObject<{
388
+ parent: z.ZodString;
389
+ }, z.core.$strict>, z.ZodObject<{
390
+ setting: z.ZodString;
391
+ }, z.core.$strict>, z.ZodObject<{
392
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
393
+ }, z.core.$strict>]>>>;
394
+ heldUntil: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
395
+ row: z.ZodLiteral<true>;
396
+ }, z.core.$strict>, z.ZodObject<{
397
+ parent: z.ZodString;
398
+ }, z.core.$strict>, z.ZodObject<{
399
+ setting: z.ZodString;
400
+ }, z.core.$strict>, z.ZodObject<{
401
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
402
+ }, z.core.$strict>]>>;
403
+ refuses: z.ZodOptional<z.ZodArray<z.ZodObject<{
404
+ table: z.ZodOptional<z.ZodString>;
405
+ via: z.ZodOptional<z.ZodString>;
406
+ column: z.ZodString;
407
+ set: z.ZodLiteral<true>;
408
+ }, z.core.$strict>>>;
409
+ unlessSet: z.ZodOptional<z.ZodString>;
410
+ only: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
411
+ column: z.ZodString;
412
+ eq: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
413
+ }, z.core.$strict>, z.ZodObject<{
414
+ column: z.ZodString;
415
+ in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
416
+ }, z.core.$strict>, z.ZodObject<{
417
+ column: z.ZodString;
418
+ set: z.ZodLiteral<true>;
419
+ }, z.core.$strict>]>>;
420
+ }, z.core.$strict>;
421
+ export type Posting = z.infer<typeof postingSchema>;
422
+ export declare const postingsSchema: z.ZodArray<z.ZodObject<{
423
+ id: z.ZodString;
424
+ into: z.ZodObject<{
425
+ addOn: z.ZodString;
426
+ ledger: z.ZodString;
427
+ action: z.ZodString;
428
+ }, z.core.$strict>;
429
+ needs: z.ZodOptional<z.ZodString>;
430
+ via: z.ZodOptional<z.ZodString>;
431
+ reserve: z.ZodOptional<z.ZodObject<{
432
+ on: z.ZodUnion<readonly [z.ZodObject<{
433
+ create: z.ZodLiteral<true>;
434
+ }, z.core.$strict>, z.ZodObject<{
435
+ to: z.ZodArray<z.ZodString>;
436
+ from: z.ZodOptional<z.ZodArray<z.ZodString>>;
437
+ }, z.core.$strict>, z.ZodObject<{
438
+ column: z.ZodString;
439
+ in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
440
+ from: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
441
+ own: z.ZodOptional<z.ZodLiteral<true>>;
442
+ }, z.core.$strict>, z.ZodObject<{
443
+ column: z.ZodString;
444
+ set: z.ZodLiteral<true>;
445
+ own: z.ZodOptional<z.ZodLiteral<true>>;
446
+ }, z.core.$strict>]>;
447
+ }, z.core.$strict>>;
448
+ post: z.ZodOptional<z.ZodObject<{
449
+ on: z.ZodUnion<readonly [z.ZodObject<{
450
+ create: z.ZodLiteral<true>;
451
+ }, z.core.$strict>, z.ZodObject<{
452
+ to: z.ZodArray<z.ZodString>;
453
+ from: z.ZodOptional<z.ZodArray<z.ZodString>>;
454
+ }, z.core.$strict>, z.ZodObject<{
455
+ column: z.ZodString;
456
+ in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
457
+ from: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
458
+ own: z.ZodOptional<z.ZodLiteral<true>>;
459
+ }, z.core.$strict>, z.ZodObject<{
460
+ column: z.ZodString;
461
+ set: z.ZodLiteral<true>;
462
+ own: z.ZodOptional<z.ZodLiteral<true>>;
463
+ }, z.core.$strict>]>;
464
+ }, z.core.$strict>>;
465
+ reverse: z.ZodOptional<z.ZodObject<{
466
+ on: z.ZodUnion<readonly [z.ZodObject<{
467
+ create: z.ZodLiteral<true>;
468
+ }, z.core.$strict>, z.ZodObject<{
469
+ to: z.ZodArray<z.ZodString>;
470
+ from: z.ZodOptional<z.ZodArray<z.ZodString>>;
471
+ }, z.core.$strict>, z.ZodObject<{
472
+ column: z.ZodString;
473
+ in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
474
+ from: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
475
+ own: z.ZodOptional<z.ZodLiteral<true>>;
476
+ }, z.core.$strict>, z.ZodObject<{
477
+ column: z.ZodString;
478
+ set: z.ZodLiteral<true>;
479
+ own: z.ZodOptional<z.ZodLiteral<true>>;
480
+ }, z.core.$strict>]>;
481
+ }, z.core.$strict>>;
482
+ map: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
483
+ row: z.ZodLiteral<true>;
484
+ }, z.core.$strict>, z.ZodObject<{
485
+ parent: z.ZodString;
486
+ }, z.core.$strict>, z.ZodObject<{
487
+ setting: z.ZodString;
488
+ }, z.core.$strict>, z.ZodObject<{
489
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
490
+ }, z.core.$strict>]>>;
491
+ multipliers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
492
+ row: z.ZodLiteral<true>;
493
+ }, z.core.$strict>, z.ZodObject<{
494
+ parent: z.ZodString;
495
+ }, z.core.$strict>, z.ZodObject<{
496
+ setting: z.ZodString;
497
+ }, z.core.$strict>, z.ZodObject<{
498
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
499
+ }, z.core.$strict>]>>>;
500
+ heldUntil: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
501
+ row: z.ZodLiteral<true>;
502
+ }, z.core.$strict>, z.ZodObject<{
503
+ parent: z.ZodString;
504
+ }, z.core.$strict>, z.ZodObject<{
505
+ setting: z.ZodString;
506
+ }, z.core.$strict>, z.ZodObject<{
507
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
508
+ }, z.core.$strict>]>>;
509
+ refuses: z.ZodOptional<z.ZodArray<z.ZodObject<{
510
+ table: z.ZodOptional<z.ZodString>;
511
+ via: z.ZodOptional<z.ZodString>;
512
+ column: z.ZodString;
513
+ set: z.ZodLiteral<true>;
514
+ }, z.core.$strict>>>;
515
+ unlessSet: z.ZodOptional<z.ZodString>;
516
+ only: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
517
+ column: z.ZodString;
518
+ eq: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
519
+ }, z.core.$strict>, z.ZodObject<{
520
+ column: z.ZodString;
521
+ in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
522
+ }, z.core.$strict>, z.ZodObject<{
523
+ column: z.ZodString;
524
+ set: z.ZodLiteral<true>;
525
+ }, z.core.$strict>]>>;
526
+ }, z.core.$strict>>;
527
+ /** The owner's switch, stored apart from the rule so an app update never switches it back on. */
528
+ export declare const switchedOffSchema: z.ZodObject<{
529
+ postings: z.ZodArray<z.ZodString>;
530
+ adjust: z.ZodOptional<z.ZodLiteral<true>>;
531
+ }, z.core.$strict>;
532
+ export type SwitchedOff = z.infer<typeof switchedOffSchema>;
533
+ /** What the checks read of a table. */
534
+ export interface LedgerTableShape {
535
+ ref: string;
536
+ columns: readonly {
537
+ ref: string;
538
+ type: string;
539
+ role?: string | undefined;
540
+ nullable?: boolean | undefined;
541
+ enum?: readonly string[] | undefined;
542
+ references?: string | undefined;
543
+ maxLength?: number | undefined;
544
+ rules?: {
545
+ rollup?: {
546
+ balance?: {
547
+ column: string;
548
+ } | undefined;
549
+ } | undefined;
550
+ copy?: {
551
+ follow?: unknown;
552
+ } | undefined;
553
+ tableRef?: true | undefined;
554
+ } | undefined;
555
+ }[];
556
+ states?: {
557
+ column: string;
558
+ initial: string;
559
+ moves: Readonly<Record<string, readonly unknown[]>>;
560
+ timed?: unknown;
561
+ } | undefined;
562
+ postings?: readonly Posting[] | undefined;
563
+ }
564
+ /**
565
+ * Everything wrong with a table's postings that this manifest can see: its
566
+ * points, its `via`, the columns it maps, and — for an add-on posting into
567
+ * its own ledger — the fit with the action it names.
568
+ */
569
+ export declare function postingIssues(table: LedgerTableShape, ctx: {
570
+ /** This manifest's key and kind. */
571
+ key: string;
572
+ kind: 'app' | 'add-on';
573
+ tables: ReadonlyMap<string, LedgerTableShape>;
574
+ /** The add-ons the manifest names (`requires` and `suggests`). */
575
+ named: ReadonlySet<string>;
576
+ /** An app's `addOns.features`, by id, with the add-ons each needs. */
577
+ features: ReadonlyMap<string, readonly string[]>;
578
+ /** The manifest's own ledgers, when it is an add-on. */
579
+ ledgers: readonly Ledger[];
580
+ }, at: (...rest: (string | number)[]) => (string | number)[]): ReferenceIssue[];
581
+ /**
582
+ * Whether a posting fits the ledger action it names: the action exists, every
583
+ * input it needs is mapped and nothing else is, its phases are ones the
584
+ * action has, and a hold has an end.
585
+ *
586
+ * `timed`: whether the judged row's table moves by itself in time — a round
587
+ * that Adminium decides at the create must be given back by something.
588
+ */
589
+ export declare function postingFitIssues(posting: Posting, ledger: Ledger, facts: {
590
+ timed: boolean;
591
+ }): ReferenceIssue[];
592
+ /** The columns of a receipt table Adminium keys by, in key order. */
593
+ export declare const RECEIPT_KEY: readonly ["source_table", "source_row", "source_line", "posting", "phase", "round"];
594
+ /** Every column of a receipt table, with the type it must have. `held_until` is the one that may be empty. */
595
+ export declare const RECEIPT_COLUMNS: Readonly<Record<string, {
596
+ type: readonly string[];
597
+ nullable?: true;
598
+ enum?: readonly string[];
599
+ tableRef?: true;
600
+ }>>;
601
+ /**
602
+ * Whether a table is a receipt table as Adminium writes one: exactly the
603
+ * columns of `RECEIPT_COLUMNS` beside its key, each of its type, none but
604
+ * `held_until` nullable, and a bounded width on every text column of the key.
605
+ */
606
+ export declare function receiptTableIssues(table: LedgerTableShape, at: (...rest: (string | number)[]) => (string | number)[]): ReferenceIssue[];
607
+ /** What the scope checks read of a table, beyond {@link LedgerTableShape}. */
608
+ export interface LedgerScopeTable extends LedgerTableShape {
609
+ columns: readonly (LedgerTableShape['columns'][number] & {
610
+ unique?: true | undefined;
611
+ rules?: (NonNullable<LedgerTableShape['columns'][number]['rules']> & {
612
+ rollup?: {
613
+ from?: string;
614
+ cap?: true | undefined;
615
+ balance?: {
616
+ column: string;
617
+ minus?: readonly string[] | undefined;
618
+ } | undefined;
619
+ } | undefined;
620
+ formula?: unknown;
621
+ stamp?: unknown;
622
+ sequence?: {
623
+ gapless?: true | undefined;
624
+ } | undefined;
625
+ code?: unknown;
626
+ copy?: {
627
+ follow?: unknown;
628
+ } | undefined;
629
+ }) | undefined;
630
+ })[];
631
+ unique?: readonly (readonly string[])[] | undefined;
632
+ booking?: unknown;
633
+ capacity?: unknown;
634
+ }
635
+ export declare const LEDGER_ISSUE_CODES: readonly ["LEDGER_OUT_OF_SCOPE", "LEDGER_WRITES_DECIDED", "LEDGER_UPDATE_KEY", "LEDGER_READ_CHAIN", "LEDGER_LOCK", "LEDGER_TABLE_GUARDED", "LEDGER_DECIDES_TYPE"];
636
+ export type LedgerIssueCode = (typeof LEDGER_ISSUE_CODES)[number];
637
+ export interface LedgerIssue {
638
+ code: LedgerIssueCode;
639
+ path: (string | number)[];
640
+ message: string;
641
+ }
642
+ /**
643
+ * Everything that would let a ledger reach outside what it declares: a table
644
+ * that is not the add-on's own, a written column Adminium decides, an update
645
+ * that could name more than one row, a read whose key comes from nowhere, a
646
+ * capped total nobody locks, a table another guard already rules, an amount
647
+ * decided that is no number.
648
+ *
649
+ * `addOn.scopes` grants nothing and refuses nothing at run time; a ledger is
650
+ * bounded by these checks and by the same ones made again on every answer.
651
+ */
652
+ export declare function ledgerIssues(m: {
653
+ tables: readonly LedgerScopeTable[];
654
+ ledgers: readonly Ledger[];
655
+ settingsTable?: string | undefined;
656
+ }): LedgerIssue[];
657
+ /**
658
+ * A question asked of a ledger's action with nothing written: one line per
659
+ * row asked about, a quantity of one, answered `in`, `low` or `out`. `input`
660
+ * is the action's input that takes the row asked about; `showLeftBelow` names
661
+ * the settings column holding the owner's "show how many are left below".
662
+ */
663
+ export declare const wordsSchema: z.ZodObject<{
664
+ id: z.ZodString;
665
+ ledger: z.ZodString;
666
+ action: z.ZodString;
667
+ input: z.ZodString;
668
+ showLeftBelow: z.ZodOptional<z.ZodObject<{
669
+ setting: z.ZodString;
670
+ }, z.core.$strict>>;
671
+ }, z.core.$strict>;
672
+ export type StockWords = z.infer<typeof wordsSchema>;
673
+ export declare const wordsListSchema: z.ZodArray<z.ZodObject<{
674
+ id: z.ZodString;
675
+ ledger: z.ZodString;
676
+ action: z.ZodString;
677
+ input: z.ZodString;
678
+ showLeftBelow: z.ZodOptional<z.ZodObject<{
679
+ setting: z.ZodString;
680
+ }, z.core.$strict>>;
681
+ }, z.core.$strict>>;
682
+ /** The most rows one words question asks about. */
683
+ export declare const WORDS_IDS_MAX = 60;
684
+ /** Everything wrong with an add-on's stock words that its own manifest can see. */
685
+ export declare function wordsIssues(m: {
686
+ words: readonly StockWords[];
687
+ ledgers: readonly Ledger[];
688
+ tables: readonly LedgerTableShape[];
689
+ settingsTable?: string | undefined;
690
+ }): ReferenceIssue[];
691
+ //# sourceMappingURL=ledgers.d.ts.map