@adminiumjs/manifest 0.3.16 → 0.3.18-rc.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/dist/adjust.d.ts +322 -0
- package/dist/adjust.d.ts.map +1 -0
- package/dist/adjust.js +512 -0
- package/dist/adjust.js.map +1 -0
- package/dist/automations.d.ts +2309 -0
- package/dist/automations.d.ts.map +1 -0
- package/dist/automations.js +384 -0
- package/dist/automations.js.map +1 -0
- package/dist/compose.d.ts.map +1 -1
- package/dist/compose.js +1 -0
- package/dist/compose.js.map +1 -1
- package/dist/documents.d.ts +82 -1
- package/dist/documents.d.ts.map +1 -1
- package/dist/documents.js +36 -6
- package/dist/documents.js.map +1 -1
- package/dist/index.d.ts +15 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/dist/key-bytes.d.ts +27 -0
- package/dist/key-bytes.d.ts.map +1 -0
- package/dist/key-bytes.js +48 -0
- package/dist/key-bytes.js.map +1 -0
- package/dist/ledger-indexes.d.ts +19 -0
- package/dist/ledger-indexes.d.ts.map +1 -0
- package/dist/ledger-indexes.js +74 -0
- package/dist/ledger-indexes.js.map +1 -0
- package/dist/ledgers.d.ts +691 -0
- package/dist/ledgers.d.ts.map +1 -0
- package/dist/ledgers.js +778 -0
- package/dist/ledgers.js.map +1 -0
- package/dist/look-up.d.ts +73 -0
- package/dist/look-up.d.ts.map +1 -0
- package/dist/look-up.js +140 -0
- package/dist/look-up.js.map +1 -0
- package/dist/marketplace-wire.d.ts +2 -2
- package/dist/outbox.d.ts +29 -3
- package/dist/outbox.d.ts.map +1 -1
- package/dist/outbox.js +94 -15
- package/dist/outbox.js.map +1 -1
- package/dist/page-config.d.ts +99 -0
- package/dist/page-config.d.ts.map +1 -0
- package/dist/page-config.js +197 -0
- package/dist/page-config.js.map +1 -0
- package/dist/plan-context.d.ts +8 -18
- package/dist/plan-context.d.ts.map +1 -1
- package/dist/plan-context.js +53 -51
- package/dist/plan-context.js.map +1 -1
- package/dist/plan-model.d.ts +8 -1
- package/dist/plan-model.d.ts.map +1 -1
- package/dist/plan.d.ts +1 -1
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +6 -3
- package/dist/plan.js.map +1 -1
- package/dist/public-access.d.ts +33 -5
- package/dist/public-access.d.ts.map +1 -1
- package/dist/public-access.js +82 -4
- package/dist/public-access.js.map +1 -1
- package/dist/refs.d.ts +2 -0
- package/dist/refs.d.ts.map +1 -1
- package/dist/refs.js +5 -0
- package/dist/refs.js.map +1 -1
- package/dist/roles.d.ts +46 -0
- package/dist/roles.d.ts.map +1 -1
- package/dist/roles.js +50 -0
- package/dist/roles.js.map +1 -1
- package/dist/sample.d.ts +70 -1
- package/dist/sample.d.ts.map +1 -1
- package/dist/sample.js +208 -5
- package/dist/sample.js.map +1 -1
- package/dist/schema.d.ts +9657 -2440
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +751 -52
- package/dist/schema.js.map +1 -1
- package/dist/state-actions.d.ts +185 -0
- package/dist/state-actions.d.ts.map +1 -0
- package/dist/state-actions.js +223 -0
- package/dist/state-actions.js.map +1 -0
- package/dist/states.d.ts +66 -0
- package/dist/states.d.ts.map +1 -1
- package/dist/states.js +31 -0
- package/dist/states.js.map +1 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +22 -6
- package/dist/validate.js.map +1 -1
- package/dist/words.d.ts +33 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +208 -0
- package/dist/words.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* STATE ACTIONS — the buttons of a generated record page.
|
|
3
|
+
*
|
|
4
|
+
* A table with states says which moves exist; its `actions` say which of them
|
|
5
|
+
* (and what else) a person is offered on the row's own page, in the words the
|
|
6
|
+
* app or the add-on chooses: "Send", "Mark received", "Top up". Four forms:
|
|
7
|
+
*
|
|
8
|
+
* - `move` moves the row to a state, optionally asking for a few columns in
|
|
9
|
+
* the confirm and setting others;
|
|
10
|
+
* - `set` writes columns and moves nothing ("Send again");
|
|
11
|
+
* - `link` opens another page for the row;
|
|
12
|
+
* - `child` opens a small form that adds a row of a child table.
|
|
13
|
+
*
|
|
14
|
+
* `set` is always a key of the action itself. On a move or a set action it
|
|
15
|
+
* names columns of the row; on a child action, columns of the new child row.
|
|
16
|
+
*
|
|
17
|
+
* Pure. Nothing imported from the states file, which imports this one.
|
|
18
|
+
*/
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
import { type ReferenceIssue } from './refs.js';
|
|
21
|
+
/** The most actions one table offers. */
|
|
22
|
+
export declare const STATE_ACTIONS_MAX = 12;
|
|
23
|
+
export declare const stateActionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
24
|
+
id: z.ZodString;
|
|
25
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
26
|
+
move: z.ZodObject<{
|
|
27
|
+
to: z.ZodString;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
30
|
+
primary: "primary";
|
|
31
|
+
neutral: "neutral";
|
|
32
|
+
danger: "danger";
|
|
33
|
+
}>>;
|
|
34
|
+
confirm: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
35
|
+
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
|
|
36
|
+
now: z.ZodLiteral<true>;
|
|
37
|
+
}, z.core.$strict>]>>>;
|
|
38
|
+
ask: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
39
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
40
|
+
id: z.ZodString;
|
|
41
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
42
|
+
set: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
|
|
43
|
+
now: z.ZodLiteral<true>;
|
|
44
|
+
}, z.core.$strict>]>>;
|
|
45
|
+
in: z.ZodArray<z.ZodString>;
|
|
46
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
47
|
+
primary: "primary";
|
|
48
|
+
neutral: "neutral";
|
|
49
|
+
danger: "danger";
|
|
50
|
+
}>>;
|
|
51
|
+
confirm: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
52
|
+
ask: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
53
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
54
|
+
id: z.ZodString;
|
|
55
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
56
|
+
link: z.ZodObject<{
|
|
57
|
+
page: z.ZodOptional<z.ZodString>;
|
|
58
|
+
addOnPage: z.ZodOptional<z.ZodString>;
|
|
59
|
+
param: z.ZodString;
|
|
60
|
+
}, z.core.$strict>;
|
|
61
|
+
in: z.ZodArray<z.ZodString>;
|
|
62
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
63
|
+
primary: "primary";
|
|
64
|
+
neutral: "neutral";
|
|
65
|
+
danger: "danger";
|
|
66
|
+
}>>;
|
|
67
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
68
|
+
id: z.ZodString;
|
|
69
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
70
|
+
child: z.ZodObject<{
|
|
71
|
+
table: z.ZodString;
|
|
72
|
+
via: z.ZodString;
|
|
73
|
+
form: z.ZodArray<z.ZodString>;
|
|
74
|
+
}, z.core.$strict>;
|
|
75
|
+
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
76
|
+
in: z.ZodArray<z.ZodString>;
|
|
77
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
78
|
+
primary: "primary";
|
|
79
|
+
neutral: "neutral";
|
|
80
|
+
danger: "danger";
|
|
81
|
+
}>>;
|
|
82
|
+
confirm: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
83
|
+
}, z.core.$strict>]>;
|
|
84
|
+
export type StateAction = z.infer<typeof stateActionSchema>;
|
|
85
|
+
export declare const stateActionsSchema: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
86
|
+
id: z.ZodString;
|
|
87
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
88
|
+
move: z.ZodObject<{
|
|
89
|
+
to: z.ZodString;
|
|
90
|
+
}, z.core.$strict>;
|
|
91
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
92
|
+
primary: "primary";
|
|
93
|
+
neutral: "neutral";
|
|
94
|
+
danger: "danger";
|
|
95
|
+
}>>;
|
|
96
|
+
confirm: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
97
|
+
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
|
|
98
|
+
now: z.ZodLiteral<true>;
|
|
99
|
+
}, z.core.$strict>]>>>;
|
|
100
|
+
ask: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
101
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
102
|
+
id: z.ZodString;
|
|
103
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
104
|
+
set: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
|
|
105
|
+
now: z.ZodLiteral<true>;
|
|
106
|
+
}, z.core.$strict>]>>;
|
|
107
|
+
in: z.ZodArray<z.ZodString>;
|
|
108
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
109
|
+
primary: "primary";
|
|
110
|
+
neutral: "neutral";
|
|
111
|
+
danger: "danger";
|
|
112
|
+
}>>;
|
|
113
|
+
confirm: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
114
|
+
ask: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
115
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
116
|
+
id: z.ZodString;
|
|
117
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
118
|
+
link: z.ZodObject<{
|
|
119
|
+
page: z.ZodOptional<z.ZodString>;
|
|
120
|
+
addOnPage: z.ZodOptional<z.ZodString>;
|
|
121
|
+
param: z.ZodString;
|
|
122
|
+
}, z.core.$strict>;
|
|
123
|
+
in: z.ZodArray<z.ZodString>;
|
|
124
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
125
|
+
primary: "primary";
|
|
126
|
+
neutral: "neutral";
|
|
127
|
+
danger: "danger";
|
|
128
|
+
}>>;
|
|
129
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
130
|
+
id: z.ZodString;
|
|
131
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
132
|
+
child: z.ZodObject<{
|
|
133
|
+
table: z.ZodString;
|
|
134
|
+
via: z.ZodString;
|
|
135
|
+
form: z.ZodArray<z.ZodString>;
|
|
136
|
+
}, z.core.$strict>;
|
|
137
|
+
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
138
|
+
in: z.ZodArray<z.ZodString>;
|
|
139
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
140
|
+
primary: "primary";
|
|
141
|
+
neutral: "neutral";
|
|
142
|
+
danger: "danger";
|
|
143
|
+
}>>;
|
|
144
|
+
confirm: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
145
|
+
}, z.core.$strict>]>>;
|
|
146
|
+
/** Which of the four an action is. */
|
|
147
|
+
export declare function stateActionKind(action: StateAction): 'move' | 'set' | 'link' | 'child';
|
|
148
|
+
interface ActionColumn {
|
|
149
|
+
ref: string;
|
|
150
|
+
type: string;
|
|
151
|
+
enum?: readonly string[] | undefined;
|
|
152
|
+
role?: string | undefined;
|
|
153
|
+
references?: string | undefined;
|
|
154
|
+
rules?: Readonly<Record<string, unknown>> | undefined;
|
|
155
|
+
}
|
|
156
|
+
/** What the checks read of the table the actions are on, and of the manifest around it. */
|
|
157
|
+
export interface StateActionsContext {
|
|
158
|
+
table: string;
|
|
159
|
+
/** The states column, and the moves between its values. A move is a state's name, or an object with `to`. */
|
|
160
|
+
states: {
|
|
161
|
+
column: string;
|
|
162
|
+
moves: Readonly<Record<string, readonly unknown[]>>;
|
|
163
|
+
lock?: {
|
|
164
|
+
when: readonly string[];
|
|
165
|
+
except?: readonly string[] | undefined;
|
|
166
|
+
} | undefined;
|
|
167
|
+
};
|
|
168
|
+
column: (table: string, column: string) => ActionColumn | undefined;
|
|
169
|
+
hasTable: (table: string) => boolean;
|
|
170
|
+
/** Whether another rule already writes a column of the table. */
|
|
171
|
+
decided: (column: string) => boolean;
|
|
172
|
+
/** Why a column of the table is kept from readers, or null. */
|
|
173
|
+
keptFromReaders: (column: string) => string | null;
|
|
174
|
+
/** The manifest's generated page refs, and its code page refs when it is an add-on. */
|
|
175
|
+
pages: ReadonlySet<string>;
|
|
176
|
+
codePages: ReadonlySet<string>;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Everything wrong with a table's state actions: a move nobody may make by
|
|
180
|
+
* hand, a state that is none, a column that is not the row's to set, a child
|
|
181
|
+
* that is no child, a page that is none.
|
|
182
|
+
*/
|
|
183
|
+
export declare function stateActionIssues(actions: readonly StateAction[], ctx: StateActionsContext, at: (...rest: (string | number)[]) => (string | number)[]): ReferenceIssue[];
|
|
184
|
+
export {};
|
|
185
|
+
//# sourceMappingURL=state-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-actions.d.ts","sourceRoot":"","sources":["../src/state-actions.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAmE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AASjH,yCAAyC;AACzC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAoD5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAIoG,CAAC;AAEpI,sCAAsC;AACtC,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAEtF;AAQD,UAAU,YAAY;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,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.0-only
|
|
2
|
+
/**
|
|
3
|
+
* STATE ACTIONS — the buttons of a generated record page.
|
|
4
|
+
*
|
|
5
|
+
* A table with states says which moves exist; its `actions` say which of them
|
|
6
|
+
* (and what else) a person is offered on the row's own page, in the words the
|
|
7
|
+
* app or the add-on chooses: "Send", "Mark received", "Top up". Four forms:
|
|
8
|
+
*
|
|
9
|
+
* - `move` moves the row to a state, optionally asking for a few columns in
|
|
10
|
+
* the confirm and setting others;
|
|
11
|
+
* - `set` writes columns and moves nothing ("Send again");
|
|
12
|
+
* - `link` opens another page for the row;
|
|
13
|
+
* - `child` opens a small form that adds a row of a child table.
|
|
14
|
+
*
|
|
15
|
+
* `set` is always a key of the action itself. On a move or a set action it
|
|
16
|
+
* names columns of the row; on a child action, columns of the new child row.
|
|
17
|
+
*
|
|
18
|
+
* Pure. Nothing imported from the states file, which imports this one.
|
|
19
|
+
*/
|
|
20
|
+
import { z } from 'zod';
|
|
21
|
+
import { refSchema, scalarSchema, textOrLabels, valueFits, wordsOrLabels } from './refs.js';
|
|
22
|
+
const kebab = z.string().regex(/^[a-z][a-z0-9-]{0,39}$/, 'a kebab-case id');
|
|
23
|
+
const stateName = z.string().min(1).max(40);
|
|
24
|
+
const tone = z.enum(['primary', 'neutral', 'danger']);
|
|
25
|
+
const now = z.object({ now: z.literal(true) }).strict();
|
|
26
|
+
const setRow = z.record(refSchema, z.union([scalarSchema, now]));
|
|
27
|
+
const setChild = z.record(refSchema, scalarSchema);
|
|
28
|
+
/** The most actions one table offers. */
|
|
29
|
+
export const STATE_ACTIONS_MAX = 12;
|
|
30
|
+
export const stateActionSchema = z.union([
|
|
31
|
+
z
|
|
32
|
+
.object({
|
|
33
|
+
id: kebab,
|
|
34
|
+
label: textOrLabels,
|
|
35
|
+
move: z.object({ to: stateName }).strict(),
|
|
36
|
+
tone: tone.optional(),
|
|
37
|
+
confirm: wordsOrLabels.optional(),
|
|
38
|
+
set: setRow.optional(),
|
|
39
|
+
/** Columns typed in the confirm, before the move is made. */
|
|
40
|
+
ask: z.array(refSchema).min(1).max(4).optional(),
|
|
41
|
+
})
|
|
42
|
+
.strict(),
|
|
43
|
+
z
|
|
44
|
+
.object({
|
|
45
|
+
id: kebab,
|
|
46
|
+
label: textOrLabels,
|
|
47
|
+
set: setRow,
|
|
48
|
+
in: z.array(stateName).min(1).max(16),
|
|
49
|
+
tone: tone.optional(),
|
|
50
|
+
confirm: wordsOrLabels.optional(),
|
|
51
|
+
ask: z.array(refSchema).min(1).max(4).optional(),
|
|
52
|
+
})
|
|
53
|
+
.strict(),
|
|
54
|
+
z
|
|
55
|
+
.object({
|
|
56
|
+
id: kebab,
|
|
57
|
+
label: textOrLabels,
|
|
58
|
+
/** A generated page of the manifest, or a code page (`<ref>`, or `<add-on key>:<ref>`), opened with the row's key as `param`. */
|
|
59
|
+
link: z
|
|
60
|
+
.object({
|
|
61
|
+
page: z.string().regex(/^[a-z][a-z0-9-]*$/, 'a page ref').optional(),
|
|
62
|
+
addOnPage: z.string().regex(/^([a-z][a-z0-9-]{1,79}:)?[a-z][a-z0-9-]*$/, '<ref>, or <add-on key>:<ref>').optional(),
|
|
63
|
+
param: z.string().regex(/^[a-z][a-z0-9_]{0,23}$/, 'a snake_case parameter name'),
|
|
64
|
+
})
|
|
65
|
+
.strict()
|
|
66
|
+
.refine((link) => (link.page === undefined) !== (link.addOnPage === undefined), { message: 'a link opens one page: "page" or "addOnPage"' }),
|
|
67
|
+
in: z.array(stateName).min(1).max(16),
|
|
68
|
+
tone: tone.optional(),
|
|
69
|
+
})
|
|
70
|
+
.strict(),
|
|
71
|
+
z
|
|
72
|
+
.object({
|
|
73
|
+
id: kebab,
|
|
74
|
+
label: textOrLabels,
|
|
75
|
+
child: z.object({ table: refSchema, via: refSchema, form: z.array(refSchema).max(6) }).strict(),
|
|
76
|
+
set: setChild.optional(),
|
|
77
|
+
in: z.array(stateName).min(1).max(16),
|
|
78
|
+
tone: tone.optional(),
|
|
79
|
+
confirm: wordsOrLabels.optional(),
|
|
80
|
+
})
|
|
81
|
+
.strict(),
|
|
82
|
+
]);
|
|
83
|
+
export const stateActionsSchema = z
|
|
84
|
+
.array(stateActionSchema)
|
|
85
|
+
.min(1)
|
|
86
|
+
.max(STATE_ACTIONS_MAX)
|
|
87
|
+
.refine((actions) => new Set(actions.map((action) => action.id)).size === actions.length, { message: 'two actions share an id' });
|
|
88
|
+
/** Which of the four an action is. */
|
|
89
|
+
export function stateActionKind(action) {
|
|
90
|
+
return 'move' in action ? 'move' : 'link' in action ? 'link' : 'child' in action ? 'child' : 'set';
|
|
91
|
+
}
|
|
92
|
+
/** Whether a fixed value is one the column holds; a date or a time is written as one (`2026-01-31`, never a word such as "@now"). */
|
|
93
|
+
function fits(column, value) {
|
|
94
|
+
if (column.type === 'date' || column.type === 'timestamptz')
|
|
95
|
+
return typeof value === 'string' && /^\d{4}-\d{2}-\d{2}/.test(value) && !Number.isNaN(Date.parse(value));
|
|
96
|
+
return valueFits(column, value);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Everything wrong with a table's state actions: a move nobody may make by
|
|
100
|
+
* hand, a state that is none, a column that is not the row's to set, a child
|
|
101
|
+
* that is no child, a page that is none.
|
|
102
|
+
*/
|
|
103
|
+
export function stateActionIssues(actions, ctx, at) {
|
|
104
|
+
const out = [];
|
|
105
|
+
const { states, table } = ctx;
|
|
106
|
+
const target = (move) => (typeof move === 'string' ? move : String(move.to));
|
|
107
|
+
const planned = (move) => typeof move === 'object' && move !== null && move.planned === true;
|
|
108
|
+
const known = new Set(Object.keys(states.moves));
|
|
109
|
+
for (const moves of Object.values(states.moves))
|
|
110
|
+
for (const move of moves)
|
|
111
|
+
known.add(target(move));
|
|
112
|
+
/** The states a move to `to` may be made from by a person. */
|
|
113
|
+
const sources = (to) => Object.entries(states.moves).flatMap(([from, moves]) => (moves.some((move) => target(move) === to && !planned(move)) ? [from] : []));
|
|
114
|
+
actions.forEach((action, a) => {
|
|
115
|
+
const here = (...rest) => at('actions', a, ...rest);
|
|
116
|
+
const kind = stateActionKind(action);
|
|
117
|
+
// The states the action is offered in: where its move starts, or the ones it lists.
|
|
118
|
+
let offered;
|
|
119
|
+
if ('move' in action) {
|
|
120
|
+
offered = sources(action.move.to);
|
|
121
|
+
if (offered.length === 0) {
|
|
122
|
+
const only = Object.values(states.moves).some((moves) => moves.some((move) => target(move) === action.move.to));
|
|
123
|
+
out.push({
|
|
124
|
+
path: here('move', 'to'),
|
|
125
|
+
message: only
|
|
126
|
+
? `every move to "${action.move.to}" is planned, which only a ledger's own update makes: no button offers it`
|
|
127
|
+
: `no listed move goes to "${action.move.to}": add it to "moves", from each state the button is offered in`,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
offered = action.in;
|
|
133
|
+
action.in.forEach((state, s) => {
|
|
134
|
+
if (!known.has(state))
|
|
135
|
+
out.push({ path: here('in', s), message: `"${state}" is not a state of "${table}" (neither a key nor a target of "moves")` });
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (kind === 'move' || kind === 'set') {
|
|
139
|
+
const set = Object.keys(('set' in action ? action.set : undefined) ?? {});
|
|
140
|
+
const ask = ('ask' in action ? action.ask : undefined) ?? [];
|
|
141
|
+
for (const ref of ask)
|
|
142
|
+
if (set.includes(ref))
|
|
143
|
+
out.push({ path: here('ask'), message: `"${ref}" is set by the action or asked for in its confirm, not both` });
|
|
144
|
+
// Where the table is locked in a state the action is offered in (or moves to), only what the lock leaves open is written.
|
|
145
|
+
const lock = states.lock;
|
|
146
|
+
const reaches = [...offered, ...('move' in action ? [action.move.to] : [])];
|
|
147
|
+
const locked = lock !== undefined && reaches.some((state) => lock.when.includes(state));
|
|
148
|
+
for (const [list, refs] of [['set', set], ['ask', ask]]) {
|
|
149
|
+
refs.forEach((ref) => {
|
|
150
|
+
const path = list === 'set' ? here('set', ref) : here('ask');
|
|
151
|
+
const found = ctx.column(table, ref);
|
|
152
|
+
if (found === undefined) {
|
|
153
|
+
out.push({ path, message: `"${table}" has no column "${ref}"` });
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (ref === states.column)
|
|
157
|
+
out.push({ path, message: `"${ref}" is the state itself: a move sets it, an action's "${list}" never does` });
|
|
158
|
+
else if (found.role === 'pk')
|
|
159
|
+
out.push({ path, message: `"${table}.${ref}" is the row's key` });
|
|
160
|
+
// A stamp the write itself does not trigger is still the row's own column to set.
|
|
161
|
+
else if (ctx.decided(ref) && !(found.rules?.['stamp'] !== undefined && Object.keys(found.rules).length === 1))
|
|
162
|
+
out.push({ path, message: `"${table}.${ref}" is decided by Adminium: an action cannot ${list === 'set' ? 'set' : 'ask for'} it` });
|
|
163
|
+
if (list === 'ask') {
|
|
164
|
+
const kept = ctx.keptFromReaders(ref);
|
|
165
|
+
const hidden = found.rules?.['code']?.hiddenFromStaff === true;
|
|
166
|
+
if (found.rules?.['secret'] === true || hidden || kept === 'a secret')
|
|
167
|
+
out.push({ path, message: `"${table}.${ref}" is kept from staff: no confirm asks for it` });
|
|
168
|
+
}
|
|
169
|
+
if (list === 'set') {
|
|
170
|
+
const value = action.set[ref];
|
|
171
|
+
if (typeof value === 'object' && value !== null) {
|
|
172
|
+
if (found.type !== 'timestamptz')
|
|
173
|
+
out.push({ path, message: `{"now": true} is the moment the action is made: "${table}.${ref}" is ${found.type}, not a timestamptz` });
|
|
174
|
+
}
|
|
175
|
+
else if (!fits(found, value))
|
|
176
|
+
out.push({ path, message: `${JSON.stringify(value)} is not a value "${table}.${ref}" takes` });
|
|
177
|
+
}
|
|
178
|
+
if (locked && !(lock?.except ?? []).includes(ref)) {
|
|
179
|
+
out.push({ path, message: `"${table}" is locked in ${lock.when.filter((state) => reaches.includes(state)).map((state) => `"${state}"`).join(', ')}, where this action is offered: add "${ref}" to lock.except, or the write is refused` });
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if ('child' in action) {
|
|
186
|
+
const child = action.child;
|
|
187
|
+
if (!ctx.hasTable(child.table)) {
|
|
188
|
+
out.push({ path: here('child', 'table'), message: `"${child.table}" is not one of this manifest's tables` });
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const via = ctx.column(child.table, child.via);
|
|
192
|
+
if (via === undefined || via.type !== 'fk' || via.references !== table)
|
|
193
|
+
out.push({ path: here('child', 'via'), message: `"${child.table}.${child.via}" is not a foreign key to "${table}"` });
|
|
194
|
+
const set = Object.keys(action.set ?? {});
|
|
195
|
+
child.form.forEach((ref, f) => {
|
|
196
|
+
if (ref === child.via)
|
|
197
|
+
out.push({ path: here('child', 'form', f), message: `"${ref}" links the new row to this one: the form never asks for it` });
|
|
198
|
+
else if (ctx.column(child.table, ref) === undefined)
|
|
199
|
+
out.push({ path: here('child', 'form', f), message: `"${child.table}" has no column "${ref}"` });
|
|
200
|
+
else if (set.includes(ref))
|
|
201
|
+
out.push({ path: here('child', 'form', f), message: `"${ref}" is set by the action or asked for in its form, not both` });
|
|
202
|
+
});
|
|
203
|
+
for (const ref of set) {
|
|
204
|
+
if (ref === child.via)
|
|
205
|
+
out.push({ path: here('set', ref), message: `"${ref}" links the new row to this one: Adminium fills it` });
|
|
206
|
+
else if (ctx.column(child.table, ref) === undefined)
|
|
207
|
+
out.push({ path: here('set', ref), message: `"${child.table}" has no column "${ref}"` });
|
|
208
|
+
else if (!fits(ctx.column(child.table, ref), action.set?.[ref]))
|
|
209
|
+
out.push({ path: here('set', ref), message: `${JSON.stringify(action.set?.[ref])} is not a value "${child.table}.${ref}" takes` });
|
|
210
|
+
}
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
// A link: a page of this manifest.
|
|
214
|
+
const link = action.link;
|
|
215
|
+
if (link.page !== undefined && !ctx.pages.has(link.page))
|
|
216
|
+
out.push({ path: here('link', 'page'), message: `"${link.page}" is not one of this manifest's pages` });
|
|
217
|
+
if (link.addOnPage !== undefined && !link.addOnPage.includes(':') && !ctx.codePages.has(link.addOnPage)) {
|
|
218
|
+
out.push({ path: here('link', 'addOnPage'), message: `"${link.addOnPage}" is not one of this add-on's own pages (addOn.pages): name another add-on's page as "<add-on key>:<ref>"` });
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
return out;
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=state-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-actions.js","sourceRoot":"","sources":["../src/state-actions.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAuB,MAAM,WAAW,CAAC;AAEjH,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAAC;AAC5E,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAC5C,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AACtD,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AACxD,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AACjE,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAEnD,yCAAyC;AACzC,MAAM,CAAC,MAAM,iB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,CAAC,KAAK,IAAI,GAAG,SAAS,EAAE,CAAC,CAAC;YACvM,CAAC;YACD,OAAO;QACT,CAAC;QAED,mCAAmC;QACnC,MAAM,IAAI,GAAI,MAAkD,CAAC,IAAI,CAAC;QACtE,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,IAAI,CAAC,IAAI,uCAAuC,EAAE,CAAC,CAAC;QAClK,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACxG,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,EAAE,IAAI,IAAI,CAAC,SAAS,2GAA2G,EAAE,CAAC,CAAC;QACxL,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/states.d.ts
CHANGED
|
@@ -150,6 +150,7 @@ export declare const stateMoveSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObj
|
|
|
150
150
|
roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
151
151
|
undo: z.ZodOptional<z.ZodLiteral<true>>;
|
|
152
152
|
clears: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
153
|
+
planned: z.ZodOptional<z.ZodLiteral<true>>;
|
|
153
154
|
}, z.core.$strict>]>;
|
|
154
155
|
export type StateMove = z.infer<typeof stateMoveSchema>;
|
|
155
156
|
export declare const stateChildSchema: z.ZodObject<{
|
|
@@ -351,6 +352,7 @@ export declare const statesSchema: z.ZodObject<{
|
|
|
351
352
|
roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
352
353
|
undo: z.ZodOptional<z.ZodLiteral<true>>;
|
|
353
354
|
clears: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
355
|
+
planned: z.ZodOptional<z.ZodLiteral<true>>;
|
|
354
356
|
}, z.core.$strict>]>>>;
|
|
355
357
|
lock: z.ZodOptional<z.ZodObject<{
|
|
356
358
|
when: z.ZodArray<z.ZodString>;
|
|
@@ -452,6 +454,67 @@ export declare const statesSchema: z.ZodObject<{
|
|
|
452
454
|
}, z.core.$strict>>>;
|
|
453
455
|
}, z.core.$strict>;
|
|
454
456
|
}, z.core.$strict>>;
|
|
457
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
458
|
+
id: z.ZodString;
|
|
459
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
460
|
+
move: z.ZodObject<{
|
|
461
|
+
to: z.ZodString;
|
|
462
|
+
}, z.core.$strict>;
|
|
463
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
464
|
+
primary: "primary";
|
|
465
|
+
neutral: "neutral";
|
|
466
|
+
danger: "danger";
|
|
467
|
+
}>>;
|
|
468
|
+
confirm: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
469
|
+
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
|
|
470
|
+
now: z.ZodLiteral<true>;
|
|
471
|
+
}, z.core.$strict>]>>>;
|
|
472
|
+
ask: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
473
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
474
|
+
id: z.ZodString;
|
|
475
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
476
|
+
set: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
|
|
477
|
+
now: z.ZodLiteral<true>;
|
|
478
|
+
}, z.core.$strict>]>>;
|
|
479
|
+
in: z.ZodArray<z.ZodString>;
|
|
480
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
481
|
+
primary: "primary";
|
|
482
|
+
neutral: "neutral";
|
|
483
|
+
danger: "danger";
|
|
484
|
+
}>>;
|
|
485
|
+
confirm: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
486
|
+
ask: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
487
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
488
|
+
id: z.ZodString;
|
|
489
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
490
|
+
link: z.ZodObject<{
|
|
491
|
+
page: z.ZodOptional<z.ZodString>;
|
|
492
|
+
addOnPage: z.ZodOptional<z.ZodString>;
|
|
493
|
+
param: z.ZodString;
|
|
494
|
+
}, z.core.$strict>;
|
|
495
|
+
in: z.ZodArray<z.ZodString>;
|
|
496
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
497
|
+
primary: "primary";
|
|
498
|
+
neutral: "neutral";
|
|
499
|
+
danger: "danger";
|
|
500
|
+
}>>;
|
|
501
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
502
|
+
id: z.ZodString;
|
|
503
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
504
|
+
child: z.ZodObject<{
|
|
505
|
+
table: z.ZodString;
|
|
506
|
+
via: z.ZodString;
|
|
507
|
+
form: z.ZodArray<z.ZodString>;
|
|
508
|
+
}, z.core.$strict>;
|
|
509
|
+
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
510
|
+
in: z.ZodArray<z.ZodString>;
|
|
511
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
512
|
+
primary: "primary";
|
|
513
|
+
neutral: "neutral";
|
|
514
|
+
danger: "danger";
|
|
515
|
+
}>>;
|
|
516
|
+
confirm: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
517
|
+
}, z.core.$strict>]>>>;
|
|
455
518
|
}, z.core.$strict>;
|
|
456
519
|
export type States = z.infer<typeof statesSchema>;
|
|
457
520
|
/** A move written as a bare state is a move with nothing asked first. */
|
|
@@ -487,6 +550,9 @@ interface StatesContext<C extends ColumnShape> {
|
|
|
487
550
|
lineOf?: ((table: string) => string | undefined) | undefined;
|
|
488
551
|
/** The app's outbox table, whose rows move only by the outbox's own moves. */
|
|
489
552
|
outboxTable?: string | undefined;
|
|
553
|
+
/** The manifest's generated page refs and, for an add-on, its code page refs: what a state action's link may open. */
|
|
554
|
+
pages?: ReadonlySet<string> | undefined;
|
|
555
|
+
codePages?: ReadonlySet<string> | undefined;
|
|
490
556
|
}
|
|
491
557
|
/** A column of the table as the judge of an undo's `clears` needs it. */
|
|
492
558
|
export interface UndoColumn {
|
package/dist/states.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"states.d.ts","sourceRoot":"","sources":["../src/states.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"states.d.ts","sourceRoot":"","sources":["../src/states.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GACxB,cAAc,EAAE,CAalB"}
|
package/dist/states.js
CHANGED
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
* state their rows were in.
|
|
71
71
|
*/
|
|
72
72
|
import { z } from 'zod';
|
|
73
|
+
import { stateActionIssues, stateActionsSchema } from './state-actions.js';
|
|
73
74
|
import { momentIssues, momentOffsetSchema, momentSchema, refSchema, scalarSchema, valueFits, } from './refs.js';
|
|
74
75
|
const stateName = z.string().min(1).max(64);
|
|
75
76
|
const roleKey = z.string().regex(/^[a-z][a-z0-9-]*$/, 'a role key');
|
|
@@ -140,6 +141,12 @@ export const stateMoveSchema = z.union([
|
|
|
140
141
|
* for that move only. Only on a move marked `undo`.
|
|
141
142
|
*/
|
|
142
143
|
clears: z.array(refSchema).min(1).max(8).optional(),
|
|
144
|
+
/**
|
|
145
|
+
* The move is made only by a ledger's own planned update (an order
|
|
146
|
+
* received when its last line is in): no person and no role makes it,
|
|
147
|
+
* no button offers it, and no timed rule reaches it.
|
|
148
|
+
*/
|
|
149
|
+
planned: z.literal(true).optional(),
|
|
143
150
|
})
|
|
144
151
|
.strict(),
|
|
145
152
|
]);
|
|
@@ -334,6 +341,8 @@ export const statesSchema = z
|
|
|
334
341
|
effects: z.array(stateEffectSchema).min(1).max(8).optional(),
|
|
335
342
|
/** What a new row must meet to be created (see {@link createRequiresSchema}). */
|
|
336
343
|
create: createRequiresSchema.optional(),
|
|
344
|
+
/** The buttons a generated record page offers for a row (see `state-actions.ts`). */
|
|
345
|
+
actions: stateActionsSchema.optional(),
|
|
337
346
|
})
|
|
338
347
|
.strict();
|
|
339
348
|
/** A move written as a bare state is a move with nothing asked first. */
|
|
@@ -437,6 +446,13 @@ export function statesIssues(table, states, ctx, at) {
|
|
|
437
446
|
out.push({ path: at('moves', from, m, 'roles'), message: `"${role}" is not one of the app's roles` });
|
|
438
447
|
}
|
|
439
448
|
}
|
|
449
|
+
if (move.planned === true) {
|
|
450
|
+
// Made by a ledger's planned update alone: nothing a person does, so nothing a person's move carries.
|
|
451
|
+
if (move.undo === true)
|
|
452
|
+
out.push({ path: at('moves', from, m, 'planned'), message: 'an undo is made by a person, a planned move by a ledger: a move is one or the other' });
|
|
453
|
+
if (move.roles !== undefined)
|
|
454
|
+
out.push({ path: at('moves', from, m, 'roles'), message: 'a planned move is made by no role: take "roles" out' });
|
|
455
|
+
}
|
|
440
456
|
// An undo takes back a listed move: the one from where it goes to where it starts.
|
|
441
457
|
if (move.undo === true && !(states.moves[to] ?? []).some((back) => moveTarget(back) === from)) {
|
|
442
458
|
out.push({ path: at('moves', from, m, 'undo'), message: `no listed move goes from "${to}" to "${from}", so this move takes nothing back` });
|
|
@@ -565,6 +581,19 @@ export function statesIssues(table, states, ctx, at) {
|
|
|
565
581
|
entry.in.forEach((state, s) => known(state, at('onlyLater', i, 'in', s)));
|
|
566
582
|
});
|
|
567
583
|
out.push(...conditionedMoveIssues(table, states, ctx, at, values));
|
|
584
|
+
// The buttons a record page offers: moves a person may make, columns that are the row's to set, a child that is one.
|
|
585
|
+
if (states.actions !== undefined) {
|
|
586
|
+
out.push(...stateActionIssues(states.actions, {
|
|
587
|
+
table,
|
|
588
|
+
states,
|
|
589
|
+
column: (of, ref) => index.column(of, ref),
|
|
590
|
+
hasTable: (of) => index.table(of) !== undefined,
|
|
591
|
+
decided: (ref) => ctx.decided?.(ref) === true,
|
|
592
|
+
keptFromReaders: (ref) => ctx.keptFromReaders?.(ref) ?? null,
|
|
593
|
+
pages: ctx.pages ?? new Set(),
|
|
594
|
+
codePages: ctx.codePages ?? new Set(),
|
|
595
|
+
}, at));
|
|
596
|
+
}
|
|
568
597
|
return out;
|
|
569
598
|
}
|
|
570
599
|
/**
|
|
@@ -685,6 +714,8 @@ function conditionedMoveIssues(table, states, ctx, at, values) {
|
|
|
685
714
|
out.push({ path: here('to'), message: `no listed move goes from "${timed.from}" to "${timed.to}"` });
|
|
686
715
|
else if (typeof move === 'object' && move.undo === true)
|
|
687
716
|
out.push({ path: here('to'), message: `the move from "${timed.from}" to "${timed.to}" is an undo, which only a person makes` });
|
|
717
|
+
else if (typeof move === 'object' && move.planned === true)
|
|
718
|
+
out.push({ path: here('to'), message: `the move from "${timed.from}" to "${timed.to}" is planned, which only a ledger's own update makes` });
|
|
688
719
|
if ((states.timed ?? []).some((other, j) => j < i && other.from === timed.from)) {
|
|
689
720
|
out.push({ path: here('from'), message: `another timed move already leaves "${timed.from}"` });
|
|
690
721
|
}
|