@panneau/protocol 5.0.0-alpha.2 → 5.0.0-alpha.20
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/addresses.d.ts +23 -0
- package/dist/addresses.d.ts.map +1 -0
- package/dist/addresses.js +52 -0
- package/dist/addresses.js.map +1 -0
- package/dist/compound.d.ts +20 -0
- package/dist/compound.d.ts.map +1 -0
- package/dist/compound.js +27 -0
- package/dist/compound.js.map +1 -0
- package/dist/conditions.d.ts +1 -1
- package/dist/conformance/index.d.ts +6 -0
- package/dist/conformance/index.d.ts.map +1 -1
- package/dist/conformance/index.js +787 -11
- package/dist/conformance/index.js.map +1 -1
- package/dist/constants.d.ts +101 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +174 -3
- package/dist/constants.js.map +1 -1
- package/dist/context.d.ts +15 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +34 -0
- package/dist/context.js.map +1 -0
- package/dist/currencies.d.ts +22 -0
- package/dist/currencies.d.ts.map +1 -0
- package/dist/currencies.js +231 -0
- package/dist/currencies.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +17 -7
- package/dist/libraries.d.ts +26 -0
- package/dist/libraries.d.ts.map +1 -0
- package/dist/libraries.js +22 -0
- package/dist/libraries.js.map +1 -0
- package/dist/links.d.ts +38 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +65 -0
- package/dist/links.js.map +1 -0
- package/dist/lint.d.ts +4 -3
- package/dist/lint.d.ts.map +1 -1
- package/dist/lint.js +114 -2
- package/dist/lint.js.map +1 -1
- package/dist/mock/auth.d.ts +71 -0
- package/dist/mock/auth.d.ts.map +1 -0
- package/dist/mock/auth.js +346 -0
- package/dist/mock/auth.js.map +1 -0
- package/dist/mock/example.d.ts +3 -2
- package/dist/mock/example.d.ts.map +1 -1
- package/dist/mock/example.js +223 -142
- package/dist/mock/example.js.map +1 -1
- package/dist/mock/index.d.ts +77 -7
- package/dist/mock/index.d.ts.map +1 -1
- package/dist/mock/index.js +577 -34
- package/dist/mock/index.js.map +1 -1
- package/dist/openapi.d.ts.map +1 -1
- package/dist/openapi.js +394 -145
- package/dist/openapi.js.map +1 -1
- package/dist/problem.d.ts +1 -1
- package/dist/query.d.ts +18 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +34 -8
- package/dist/query.js.map +1 -1
- package/dist/rules.d.ts +16 -4
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +230 -13
- package/dist/rules.js.map +1 -1
- package/dist/runtime/index.d.ts +19 -10
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +12 -3
- package/dist/schemas/action.d.ts +117 -10
- package/dist/schemas/action.d.ts.map +1 -1
- package/dist/schemas/action.js +21 -3
- package/dist/schemas/action.js.map +1 -1
- package/dist/schemas/api.d.ts +326 -42
- package/dist/schemas/api.d.ts.map +1 -1
- package/dist/schemas/api.js +192 -34
- package/dist/schemas/api.js.map +1 -1
- package/dist/schemas/boot.d.ts +25 -1
- package/dist/schemas/boot.d.ts.map +1 -1
- package/dist/schemas/boot.js +2 -1
- package/dist/schemas/boot.js.map +1 -1
- package/dist/schemas/common.d.ts +1 -0
- package/dist/schemas/common.d.ts.map +1 -1
- package/dist/schemas/common.js +2 -1
- package/dist/schemas/common.js.map +1 -1
- package/dist/schemas/definition.d.ts +332 -28
- package/dist/schemas/definition.d.ts.map +1 -1
- package/dist/schemas/definition.js +65 -19
- package/dist/schemas/definition.js.map +1 -1
- package/dist/schemas/field.d.ts +356 -2
- package/dist/schemas/field.d.ts.map +1 -1
- package/dist/schemas/field.js +159 -20
- package/dist/schemas/field.js.map +1 -1
- package/dist/schemas/index.d.ts +1384 -72
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +58 -9
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/jsonRules.d.ts +83 -0
- package/dist/schemas/jsonRules.d.ts.map +1 -0
- package/dist/schemas/jsonRules.js +46 -0
- package/dist/schemas/jsonRules.js.map +1 -0
- package/dist/schemas/layout.d.ts +1 -1
- package/dist/schemas/list.d.ts +23 -2
- package/dist/schemas/list.d.ts.map +1 -1
- package/dist/schemas/list.js +14 -5
- package/dist/schemas/list.js.map +1 -1
- package/dist/schemas/resource.d.ts +247 -15
- package/dist/schemas/resource.d.ts.map +1 -1
- package/dist/schemas/resource.js +6 -1
- package/dist/schemas/resource.js.map +1 -1
- package/dist/schemas/widget.d.ts +109 -0
- package/dist/schemas/widget.d.ts.map +1 -0
- package/dist/schemas/widget.js +74 -0
- package/dist/schemas/widget.js.map +1 -0
- package/dist/search.d.ts +51 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +53 -0
- package/dist/search.js.map +1 -0
- package/dist/themes.d.ts +1 -1
- package/dist/transforms.d.ts +17 -0
- package/dist/transforms.d.ts.map +1 -0
- package/dist/transforms.js +34 -0
- package/dist/transforms.js.map +1 -0
- package/dist/validate.d.ts +5 -3
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +36 -2
- package/dist/validate.js.map +1 -1
- package/dist/values.d.ts +5 -1
- package/dist/values.d.ts.map +1 -1
- package/dist/values.js +16 -2
- package/dist/values.js.map +1 -1
- package/dist/widgets.d.ts +42 -0
- package/dist/widgets.d.ts.map +1 -0
- package/dist/widgets.js +130 -0
- package/dist/widgets.js.map +1 -0
- package/package.json +6 -3
- package/schema/boot.schema.json +666 -18
- package/schema/definition.schema.json +663 -18
- package/schema/openapi.json +5694 -2328
package/dist/schemas/action.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { Field } from './field';
|
|
3
|
-
import { LayoutNode } from './layout';
|
|
2
|
+
import { Field } from './field.js';
|
|
3
|
+
import { LayoutNode } from './layout.js';
|
|
4
4
|
export declare const ActionScope: z.ZodEnum<{
|
|
5
5
|
resource: "resource";
|
|
6
6
|
item: "item";
|
|
@@ -20,12 +20,12 @@ export declare const ActionConfirm: z.ZodUnion<readonly [z.ZodBoolean, z.ZodObje
|
|
|
20
20
|
}, z.core.$loose>]>;
|
|
21
21
|
export declare const Action: z.ZodObject<{
|
|
22
22
|
id: z.ZodString;
|
|
23
|
-
label: z.ZodString
|
|
23
|
+
label: z.ZodOptional<z.ZodString>;
|
|
24
24
|
icon: z.ZodOptional<z.ZodString>;
|
|
25
25
|
kind: z.ZodDefault<z.ZodEnum<{
|
|
26
26
|
link: "link";
|
|
27
|
-
server: "server";
|
|
28
27
|
client: "client";
|
|
28
|
+
server: "server";
|
|
29
29
|
}>>;
|
|
30
30
|
scope: z.ZodArray<z.ZodEnum<{
|
|
31
31
|
resource: "resource";
|
|
@@ -54,11 +54,16 @@ export declare const Action: z.ZodObject<{
|
|
|
54
54
|
default: z.ZodOptional<z.ZodUnknown>;
|
|
55
55
|
localized: z.ZodOptional<z.ZodBoolean>;
|
|
56
56
|
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
+
abilities: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
57
58
|
createOnly: z.ZodOptional<z.ZodBoolean>;
|
|
58
59
|
updateOnly: z.ZodOptional<z.ZodBoolean>;
|
|
59
60
|
rules: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
60
61
|
rule: z.ZodLiteral<"required">;
|
|
61
62
|
message: z.ZodOptional<z.ZodString>;
|
|
63
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
64
|
+
update: "update";
|
|
65
|
+
create: "create";
|
|
66
|
+
}>>;
|
|
62
67
|
}, z.core.$loose>, z.ZodObject<{
|
|
63
68
|
rule: z.ZodEnum<{
|
|
64
69
|
min: "min";
|
|
@@ -66,29 +71,82 @@ export declare const Action: z.ZodObject<{
|
|
|
66
71
|
}>;
|
|
67
72
|
value: z.ZodNumber;
|
|
68
73
|
message: z.ZodOptional<z.ZodString>;
|
|
74
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
75
|
+
update: "update";
|
|
76
|
+
create: "create";
|
|
77
|
+
}>>;
|
|
69
78
|
}, z.core.$loose>, z.ZodObject<{
|
|
70
79
|
rule: z.ZodLiteral<"pattern">;
|
|
71
80
|
value: z.ZodString;
|
|
72
81
|
flags: z.ZodOptional<z.ZodString>;
|
|
73
82
|
message: z.ZodOptional<z.ZodString>;
|
|
83
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
84
|
+
update: "update";
|
|
85
|
+
create: "create";
|
|
86
|
+
}>>;
|
|
74
87
|
}, z.core.$loose>, z.ZodObject<{
|
|
75
88
|
rule: z.ZodEnum<{
|
|
76
89
|
email: "email";
|
|
77
90
|
url: "url";
|
|
91
|
+
json: "json";
|
|
78
92
|
}>;
|
|
79
93
|
message: z.ZodOptional<z.ZodString>;
|
|
94
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
95
|
+
update: "update";
|
|
96
|
+
create: "create";
|
|
97
|
+
}>>;
|
|
98
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
99
|
+
rule: z.ZodLiteral<"tel">;
|
|
100
|
+
extension: z.ZodOptional<z.ZodBoolean>;
|
|
101
|
+
message: z.ZodOptional<z.ZodString>;
|
|
102
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
103
|
+
update: "update";
|
|
104
|
+
create: "create";
|
|
105
|
+
}>>;
|
|
106
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
107
|
+
rule: z.ZodLiteral<"daterange">;
|
|
108
|
+
open: z.ZodOptional<z.ZodEnum<{
|
|
109
|
+
start: "start";
|
|
110
|
+
end: "end";
|
|
111
|
+
both: "both";
|
|
112
|
+
}>>;
|
|
113
|
+
message: z.ZodOptional<z.ZodString>;
|
|
114
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
115
|
+
update: "update";
|
|
116
|
+
create: "create";
|
|
117
|
+
}>>;
|
|
118
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
119
|
+
rule: z.ZodLiteral<"money">;
|
|
120
|
+
currencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
121
|
+
message: z.ZodOptional<z.ZodString>;
|
|
122
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
123
|
+
update: "update";
|
|
124
|
+
create: "create";
|
|
125
|
+
}>>;
|
|
80
126
|
}, z.core.$loose>, z.ZodObject<{
|
|
81
127
|
rule: z.ZodLiteral<"in">;
|
|
82
128
|
value: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
83
129
|
message: z.ZodOptional<z.ZodString>;
|
|
130
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
131
|
+
update: "update";
|
|
132
|
+
create: "create";
|
|
133
|
+
}>>;
|
|
84
134
|
}, z.core.$loose>, z.ZodObject<{
|
|
85
135
|
rule: z.ZodLiteral<"accept">;
|
|
86
136
|
value: z.ZodArray<z.ZodString>;
|
|
87
137
|
message: z.ZodOptional<z.ZodString>;
|
|
138
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
139
|
+
update: "update";
|
|
140
|
+
create: "create";
|
|
141
|
+
}>>;
|
|
88
142
|
}, z.core.$loose>, z.ZodObject<{
|
|
89
143
|
rule: z.ZodLiteral<"maxSize">;
|
|
90
144
|
value: z.ZodNumber;
|
|
91
145
|
message: z.ZodOptional<z.ZodString>;
|
|
146
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
147
|
+
update: "update";
|
|
148
|
+
create: "create";
|
|
149
|
+
}>>;
|
|
92
150
|
}, z.core.$loose>, z.ZodObject<{
|
|
93
151
|
rule: z.ZodEnum<{
|
|
94
152
|
before: "before";
|
|
@@ -98,9 +156,46 @@ export declare const Action: z.ZodObject<{
|
|
|
98
156
|
field: z.ZodString;
|
|
99
157
|
}, z.core.$loose>]>;
|
|
100
158
|
message: z.ZodOptional<z.ZodString>;
|
|
159
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
160
|
+
update: "update";
|
|
161
|
+
create: "create";
|
|
162
|
+
}>>;
|
|
163
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
164
|
+
rule: z.ZodLiteral<"postalCode">;
|
|
165
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
166
|
+
field: z.ZodString;
|
|
167
|
+
}, z.core.$loose>]>>;
|
|
168
|
+
message: z.ZodOptional<z.ZodString>;
|
|
169
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
170
|
+
update: "update";
|
|
171
|
+
create: "create";
|
|
172
|
+
}>>;
|
|
173
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
174
|
+
rule: z.ZodLiteral<"crop">;
|
|
175
|
+
value: z.ZodObject<{
|
|
176
|
+
ratios: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
177
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
178
|
+
}, z.core.$loose>;
|
|
179
|
+
message: z.ZodOptional<z.ZodString>;
|
|
180
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
181
|
+
update: "update";
|
|
182
|
+
create: "create";
|
|
183
|
+
}>>;
|
|
184
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
185
|
+
rule: z.ZodLiteral<"providers">;
|
|
186
|
+
value: z.ZodArray<z.ZodString>;
|
|
187
|
+
message: z.ZodOptional<z.ZodString>;
|
|
188
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
189
|
+
update: "update";
|
|
190
|
+
create: "create";
|
|
191
|
+
}>>;
|
|
101
192
|
}, z.core.$loose>, z.ZodObject<{
|
|
102
193
|
rule: z.ZodString;
|
|
103
194
|
message: z.ZodOptional<z.ZodString>;
|
|
195
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
196
|
+
update: "update";
|
|
197
|
+
create: "create";
|
|
198
|
+
}>>;
|
|
104
199
|
}, z.core.$loose>]>>>;
|
|
105
200
|
visibleWhen: z.ZodOptional<z.ZodObject<{
|
|
106
201
|
field: z.ZodOptional<z.ZodString>;
|
|
@@ -108,22 +203,32 @@ export declare const Action: z.ZodObject<{
|
|
|
108
203
|
in: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
109
204
|
notIn: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
110
205
|
filled: z.ZodOptional<z.ZodBoolean>;
|
|
111
|
-
all: z.ZodOptional<z.ZodArray<typeof import("./common").Condition>>;
|
|
112
|
-
any: z.ZodOptional<z.ZodArray<typeof import("./common").Condition>>;
|
|
206
|
+
all: z.ZodOptional<z.ZodArray<typeof import("./common.js").Condition>>;
|
|
207
|
+
any: z.ZodOptional<z.ZodArray<typeof import("./common.js").Condition>>;
|
|
113
208
|
}, z.core.$loose>>;
|
|
114
209
|
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
115
210
|
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
116
211
|
label: z.ZodString;
|
|
117
212
|
description: z.ZodOptional<z.ZodString>;
|
|
118
213
|
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
214
|
+
tone: z.ZodOptional<z.ZodString>;
|
|
119
215
|
}, z.core.$loose>>>;
|
|
120
216
|
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
121
|
-
resource: z.ZodOptional<z.ZodString
|
|
217
|
+
resource: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
122
218
|
accept: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
219
|
+
ratios: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
220
|
+
rotate: z.ZodOptional<z.ZodBoolean>;
|
|
221
|
+
focalPoint: z.ZodOptional<z.ZodBoolean>;
|
|
222
|
+
transformBase: z.ZodOptional<z.ZodEnum<{
|
|
223
|
+
media: "media";
|
|
224
|
+
original: "original";
|
|
225
|
+
choose: "choose";
|
|
226
|
+
}>>;
|
|
123
227
|
from: z.ZodOptional<z.ZodString>;
|
|
228
|
+
check: z.ZodOptional<z.ZodBoolean>;
|
|
124
229
|
display: z.ZodOptional<z.ZodString>;
|
|
125
230
|
fields: z.ZodOptional<z.ZodArray<typeof Field>>;
|
|
126
|
-
types: z.ZodOptional<z.ZodArray<typeof import("./field").BlockType>>;
|
|
231
|
+
types: z.ZodOptional<z.ZodArray<typeof import("./field.js").BlockType>>;
|
|
127
232
|
settings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
128
233
|
}, z.core.$loose>>>;
|
|
129
234
|
layout: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -143,12 +248,14 @@ export declare const Action: z.ZodObject<{
|
|
|
143
248
|
in: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
144
249
|
notIn: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
145
250
|
filled: z.ZodOptional<z.ZodBoolean>;
|
|
146
|
-
all: z.ZodOptional<z.ZodArray<typeof import("./common").Condition>>;
|
|
147
|
-
any: z.ZodOptional<z.ZodArray<typeof import("./common").Condition>>;
|
|
251
|
+
all: z.ZodOptional<z.ZodArray<typeof import("./common.js").Condition>>;
|
|
252
|
+
any: z.ZodOptional<z.ZodArray<typeof import("./common.js").Condition>>;
|
|
148
253
|
}, z.core.$loose>>;
|
|
149
254
|
children: z.ZodOptional<z.ZodArray<typeof LayoutNode>>;
|
|
150
255
|
}, z.core.$loose>>>;
|
|
151
256
|
queued: z.ZodOptional<z.ZodBoolean>;
|
|
257
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
258
|
+
undoable: z.ZodOptional<z.ZodBoolean>;
|
|
152
259
|
url: z.ZodOptional<z.ZodString>;
|
|
153
260
|
route: z.ZodOptional<z.ZodString>;
|
|
154
261
|
component: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/schemas/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/schemas/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,eAAO,MAAM,WAAW;;;;EAA4C,CAAC;AAErE,eAAO,MAAM,eAAe;;;;;EAA6C,CAAC;AAE1E,eAAO,MAAM,aAAa;;;;;mBAWxB,CAAC;AAEH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6Eb,CAAC;AAEP,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AACtD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAC9D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAC1D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAC;AAC5C,qEAAqE;AACrE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAC"}
|
package/dist/schemas/action.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { isBuiltInItemAction, isBuiltInLink } from "../constants.js";
|
|
1
2
|
import { Abilities } from "./common.js";
|
|
2
3
|
import { Field } from "./field.js";
|
|
4
|
+
import { actionJsonRules } from "./jsonRules.js";
|
|
3
5
|
import { LayoutNode } from "./layout.js";
|
|
4
6
|
import { z } from "zod";
|
|
5
7
|
//#region src/schemas/action.ts
|
|
@@ -22,7 +24,7 @@ var ActionConfirm = z.union([z.boolean(), z.looseObject({
|
|
|
22
24
|
})]);
|
|
23
25
|
var Action = z.looseObject({
|
|
24
26
|
id: z.string().min(1),
|
|
25
|
-
label: z.string(),
|
|
27
|
+
label: z.string().optional().meta({ description: "Required, except for the built-in item actions (`show`, `edit`, `duplicate`, `delete`), which the client labels in its locale." }),
|
|
26
28
|
icon: z.string().optional(),
|
|
27
29
|
kind: z.enum([
|
|
28
30
|
"server",
|
|
@@ -36,12 +38,25 @@ var Action = z.looseObject({
|
|
|
36
38
|
fields: z.array(Field).optional().meta({ description: "Parameters, shown in a modal." }),
|
|
37
39
|
layout: z.array(LayoutNode).optional(),
|
|
38
40
|
queued: z.boolean().optional().meta({ description: "The action always answers `202` with a run." }),
|
|
41
|
+
dryRun: z.boolean().optional().meta({ description: "The backend answers dry runs of this action (`dryRun` in the request): lists ask it how many items of a query selection will be skipped. Without it, the UI never sends `dryRun`, since a backend that ignores it would run the action." }),
|
|
42
|
+
undoable: z.boolean().optional().meta({ description: "Its runs can be undone: the client runs it without a confirmation (unless it sets `confirm`), and shows \"Undo\" when its result has an `undo`. Above `UNDO_LIMIT` items (100), and for queued runs, the client confirms it first (decision 0063). The `delete` of a resource with a trash declares it, undone by `restore`." }),
|
|
39
43
|
url: z.string().optional().meta({ description: "`link`: URL template, with `{id}` for the item." }),
|
|
40
44
|
route: z.string().optional().meta({ description: "`link`: name of a route in the definition." }),
|
|
41
45
|
component: z.string().optional().meta({ description: "`client`: the plugin handler." }),
|
|
42
46
|
abilities: Abilities.optional().meta({ description: "`run`: whether the current user can run the action on the resource." })
|
|
43
47
|
}).superRefine((action, context) => {
|
|
44
|
-
|
|
48
|
+
const builtInLink = isBuiltInLink(action.id);
|
|
49
|
+
if (builtInLink && action.kind !== "link") context.addIssue({
|
|
50
|
+
code: "custom",
|
|
51
|
+
path: ["kind"],
|
|
52
|
+
message: `The id \`${action.id}\` is reserved for the built-in link: its \`kind\` must be \`link\`.`
|
|
53
|
+
});
|
|
54
|
+
if (action.label === void 0 && !isBuiltInItemAction(action.id)) context.addIssue({
|
|
55
|
+
code: "custom",
|
|
56
|
+
path: ["label"],
|
|
57
|
+
message: "An action needs a `label`."
|
|
58
|
+
});
|
|
59
|
+
if (action.kind === "link" && action.url === void 0 && action.route === void 0 && !builtInLink) context.addIssue({
|
|
45
60
|
code: "custom",
|
|
46
61
|
message: "A `link` action needs a `url` or a `route`."
|
|
47
62
|
});
|
|
@@ -49,7 +64,10 @@ var Action = z.looseObject({
|
|
|
49
64
|
code: "custom",
|
|
50
65
|
message: "A `client` action needs a `component`."
|
|
51
66
|
});
|
|
52
|
-
}).meta({
|
|
67
|
+
}).meta({
|
|
68
|
+
description: "An operation on one item, a selection, or the whole resource.",
|
|
69
|
+
...actionJsonRules
|
|
70
|
+
});
|
|
53
71
|
//#endregion
|
|
54
72
|
export { Action, ActionConfirm, ActionPlacement, ActionScope };
|
|
55
73
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","names":[],"sources":["../../src/schemas/action.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport { Abilities } from './common';\nimport { Field } from './field';\nimport { LayoutNode } from './layout';\n\nexport const ActionScope = z.enum(['item', 'selection', 'resource']);\n\nexport const ActionPlacement = z.enum(['row', 'toolbar', 'form', 'menu']);\n\nexport const ActionConfirm = z.union([\n z.boolean(),\n z.looseObject({\n title: z.string().optional(),\n message: z\n .string()\n .optional()\n .meta({ description: 'ICU message. `{count}` is the number of items.' }),\n confirmLabel: z.string().optional(),\n cancelLabel: z.string().optional(),\n }),\n]);\n\nexport const Action = z\n .looseObject({\n id: z.string().min(1),\n label: z.string(),\n icon: z.string().optional(),\n kind: z.enum(['server', 'link', 'client']).default('server').meta({\n description:\n '`server` calls the action endpoint; `link` navigates; `client` runs a plugin handler.',\n }),\n scope: z.array(ActionScope).min(1),\n placement: z.array(ActionPlacement).optional(),\n destructive: z.boolean().optional(),\n confirm: ActionConfirm.optional(),\n fields: z.array(Field).optional().meta({ description: 'Parameters, shown in a modal.' }),\n layout: z.array(LayoutNode).optional(),\n queued: z\n .boolean()\n .optional()\n .meta({ description: 'The action always answers `202` with a run.' }),\n url: z\n .string()\n .optional()\n .meta({ description: '`link`: URL template, with `{id}` for the item.' }),\n route: z\n .string()\n .optional()\n .meta({ description: '`link`: name of a route in the definition.' }),\n component: z.string().optional().meta({ description: '`client`: the plugin handler.' }),\n abilities: Abilities.optional().meta({\n description: '`run`: whether the current user can run the action on the resource.',\n }),\n })\n .superRefine((action, context) => {\n if (action.kind
|
|
1
|
+
{"version":3,"file":"action.js","names":[],"sources":["../../src/schemas/action.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport { isBuiltInItemAction, isBuiltInLink } from '../constants';\nimport { Abilities } from './common';\nimport { Field } from './field';\nimport { actionJsonRules } from './jsonRules';\nimport { LayoutNode } from './layout';\n\nexport const ActionScope = z.enum(['item', 'selection', 'resource']);\n\nexport const ActionPlacement = z.enum(['row', 'toolbar', 'form', 'menu']);\n\nexport const ActionConfirm = z.union([\n z.boolean(),\n z.looseObject({\n title: z.string().optional(),\n message: z\n .string()\n .optional()\n .meta({ description: 'ICU message. `{count}` is the number of items.' }),\n confirmLabel: z.string().optional(),\n cancelLabel: z.string().optional(),\n }),\n]);\n\nexport const Action = z\n .looseObject({\n id: z.string().min(1),\n label: z.string().optional().meta({\n description:\n 'Required, except for the built-in item actions (`show`, `edit`, `duplicate`, `delete`), which the client labels in its locale.',\n }),\n icon: z.string().optional(),\n kind: z.enum(['server', 'link', 'client']).default('server').meta({\n description:\n '`server` calls the action endpoint; `link` navigates; `client` runs a plugin handler.',\n }),\n scope: z.array(ActionScope).min(1),\n placement: z.array(ActionPlacement).optional(),\n destructive: z.boolean().optional(),\n confirm: ActionConfirm.optional(),\n fields: z.array(Field).optional().meta({ description: 'Parameters, shown in a modal.' }),\n layout: z.array(LayoutNode).optional(),\n queued: z\n .boolean()\n .optional()\n .meta({ description: 'The action always answers `202` with a run.' }),\n dryRun: z.boolean().optional().meta({\n description:\n 'The backend answers dry runs of this action (`dryRun` in the request): lists ask it how many items of a query selection will be skipped. Without it, the UI never sends `dryRun`, since a backend that ignores it would run the action.',\n }),\n undoable: z.boolean().optional().meta({\n description:\n 'Its runs can be undone: the client runs it without a confirmation (unless it sets `confirm`), and shows \"Undo\" when its result has an `undo`. Above `UNDO_LIMIT` items (100), and for queued runs, the client confirms it first (decision 0063). The `delete` of a resource with a trash declares it, undone by `restore`.',\n }),\n url: z\n .string()\n .optional()\n .meta({ description: '`link`: URL template, with `{id}` for the item.' }),\n route: z\n .string()\n .optional()\n .meta({ description: '`link`: name of a route in the definition.' }),\n component: z.string().optional().meta({ description: '`client`: the plugin handler.' }),\n abilities: Abilities.optional().meta({\n description: '`run`: whether the current user can run the action on the resource.',\n }),\n })\n .superRefine((action, context) => {\n const builtInLink = isBuiltInLink(action.id);\n if (builtInLink && action.kind !== 'link') {\n context.addIssue({\n code: 'custom',\n path: ['kind'],\n message: `The id \\`${action.id}\\` is reserved for the built-in link: its \\`kind\\` must be \\`link\\`.`,\n });\n }\n if (action.label === undefined && !isBuiltInItemAction(action.id)) {\n context.addIssue({\n code: 'custom',\n path: ['label'],\n message: 'An action needs a `label`.',\n });\n }\n if (\n action.kind === 'link' &&\n action.url === undefined &&\n action.route === undefined &&\n !builtInLink\n ) {\n context.addIssue({\n code: 'custom',\n message: 'A `link` action needs a `url` or a `route`.',\n });\n }\n if (action.kind === 'client' && action.component === undefined) {\n context.addIssue({ code: 'custom', message: 'A `client` action needs a `component`.' });\n }\n })\n .meta({\n description: 'An operation on one item, a selection, or the whole resource.',\n ...actionJsonRules,\n });\n\nexport type ActionScope = z.infer<typeof ActionScope>;\nexport type ActionPlacement = z.infer<typeof ActionPlacement>;\nexport type ActionConfirm = z.infer<typeof ActionConfirm>;\nexport type Action = z.infer<typeof Action>;\n/** An action as a backend writes it: `kind` defaults to `server`. */\nexport type ActionInput = z.input<typeof Action>;\n"],"mappings":";;;;;;;AAQA,IAAa,cAAc,EAAE,KAAK;CAAC;CAAQ;CAAa;AAAU,CAAC;AAEnE,IAAa,kBAAkB,EAAE,KAAK;CAAC;CAAO;CAAW;CAAQ;AAAM,CAAC;AAExE,IAAa,gBAAgB,EAAE,MAAM,CACjC,EAAE,QAAQ,GACV,EAAE,YAAY;CACV,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;CAC3B,SAAS,EACJ,OAAO,CAAC,CACR,SAAS,CAAC,CACV,KAAK,EAAE,aAAa,iDAAiD,CAAC;CAC3E,cAAc,EAAE,OAAO,CAAC,CAAC,SAAS;CAClC,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;AACrC,CAAC,CACL,CAAC;AAED,IAAa,SAAS,EACjB,YAAY;CACT,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACpB,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAC9B,aACI,iIACR,CAAC;CACD,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,MAAM,EAAE,KAAK;EAAC;EAAU;EAAQ;CAAQ,CAAC,CAAC,CAAC,QAAQ,QAAQ,CAAC,CAAC,KAAK,EAC9D,aACI,wFACR,CAAC;CACD,OAAO,EAAE,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC;CACjC,WAAW,EAAE,MAAM,eAAe,CAAC,CAAC,SAAS;CAC7C,aAAa,EAAE,QAAQ,CAAC,CAAC,SAAS;CAClC,SAAS,cAAc,SAAS;CAChC,QAAQ,EAAE,MAAM,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,aAAa,gCAAgC,CAAC;CACvF,QAAQ,EAAE,MAAM,UAAU,CAAC,CAAC,SAAS;CACrC,QAAQ,EACH,QAAQ,CAAC,CACT,SAAS,CAAC,CACV,KAAK,EAAE,aAAa,8CAA8C,CAAC;CACxE,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAChC,aACI,0OACR,CAAC;CACD,UAAU,EAAE,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAClC,aACI,+TACR,CAAC;CACD,KAAK,EACA,OAAO,CAAC,CACR,SAAS,CAAC,CACV,KAAK,EAAE,aAAa,kDAAkD,CAAC;CAC5E,OAAO,EACF,OAAO,CAAC,CACR,SAAS,CAAC,CACV,KAAK,EAAE,aAAa,6CAA6C,CAAC;CACvE,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,aAAa,gCAAgC,CAAC;CACtF,WAAW,UAAU,SAAS,CAAC,CAAC,KAAK,EACjC,aAAa,sEACjB,CAAC;AACL,CAAC,CAAC,CACD,aAAa,QAAQ,YAAY;CAC9B,MAAM,cAAc,cAAc,OAAO,EAAE;CAC3C,IAAI,eAAe,OAAO,SAAS,QAC/B,QAAQ,SAAS;EACb,MAAM;EACN,MAAM,CAAC,MAAM;EACb,SAAS,YAAY,OAAO,GAAG;CACnC,CAAC;CAEL,IAAI,OAAO,UAAU,KAAA,KAAa,CAAC,oBAAoB,OAAO,EAAE,GAC5D,QAAQ,SAAS;EACb,MAAM;EACN,MAAM,CAAC,OAAO;EACd,SAAS;CACb,CAAC;CAEL,IACI,OAAO,SAAS,UAChB,OAAO,QAAQ,KAAA,KACf,OAAO,UAAU,KAAA,KACjB,CAAC,aAED,QAAQ,SAAS;EACb,MAAM;EACN,SAAS;CACb,CAAC;CAEL,IAAI,OAAO,SAAS,YAAY,OAAO,cAAc,KAAA,GACjD,QAAQ,SAAS;EAAE,MAAM;EAAU,SAAS;CAAyC,CAAC;AAE9F,CAAC,CAAC,CACD,KAAK;CACF,aAAa;CACb,GAAG;AACP,CAAC"}
|