@panneau/protocol 5.0.0-alpha.15 → 5.0.0-alpha.16
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/conformance/index.d.ts.map +1 -1
- package/dist/conformance/index.js +109 -0
- package/dist/conformance/index.js.map +1 -1
- package/dist/constants.d.ts +23 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +51 -3
- package/dist/constants.js.map +1 -1
- 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.js +7 -4
- 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.js +6 -2
- package/dist/lint.js.map +1 -1
- package/dist/mock/index.d.ts.map +1 -1
- package/dist/mock/index.js +11 -2
- package/dist/mock/index.js.map +1 -1
- package/dist/query.d.ts +4 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +23 -7
- package/dist/query.js.map +1 -1
- package/dist/rules.d.ts +4 -1
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +165 -7
- package/dist/rules.js.map +1 -1
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +5 -2
- package/dist/schemas/action.d.ts +46 -1
- package/dist/schemas/action.d.ts.map +1 -1
- package/dist/schemas/api.d.ts +43 -3
- package/dist/schemas/api.d.ts.map +1 -1
- package/dist/schemas/api.js +35 -1
- package/dist/schemas/api.js.map +1 -1
- package/dist/schemas/definition.d.ts +93 -3
- package/dist/schemas/definition.d.ts.map +1 -1
- package/dist/schemas/field.d.ts +193 -2
- package/dist/schemas/field.d.ts.map +1 -1
- package/dist/schemas/field.js +91 -7
- package/dist/schemas/field.js.map +1 -1
- package/dist/schemas/index.d.ts +445 -14
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +14 -4
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/list.d.ts +2 -2
- package/dist/schemas/resource.d.ts +93 -3
- package/dist/schemas/resource.d.ts.map +1 -1
- package/dist/validate.d.ts +2 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +18 -4
- package/dist/validate.js.map +1 -1
- package/package.json +1 -1
- package/schema/boot.schema.json +164 -2
- package/schema/definition.schema.json +164 -2
- package/schema/openapi.json +611 -5
package/dist/schemas/field.d.ts
CHANGED
|
@@ -31,7 +31,6 @@ export declare const Rule: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
31
31
|
rule: z.ZodEnum<{
|
|
32
32
|
email: "email";
|
|
33
33
|
url: "url";
|
|
34
|
-
tel: "tel";
|
|
35
34
|
json: "json";
|
|
36
35
|
}>;
|
|
37
36
|
message: z.ZodOptional<z.ZodString>;
|
|
@@ -39,6 +38,34 @@ export declare const Rule: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
39
38
|
update: "update";
|
|
40
39
|
create: "create";
|
|
41
40
|
}>>;
|
|
41
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
42
|
+
rule: z.ZodLiteral<"tel">;
|
|
43
|
+
extension: z.ZodOptional<z.ZodBoolean>;
|
|
44
|
+
message: z.ZodOptional<z.ZodString>;
|
|
45
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
46
|
+
update: "update";
|
|
47
|
+
create: "create";
|
|
48
|
+
}>>;
|
|
49
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
50
|
+
rule: z.ZodLiteral<"daterange">;
|
|
51
|
+
open: z.ZodOptional<z.ZodEnum<{
|
|
52
|
+
start: "start";
|
|
53
|
+
end: "end";
|
|
54
|
+
both: "both";
|
|
55
|
+
}>>;
|
|
56
|
+
message: z.ZodOptional<z.ZodString>;
|
|
57
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
58
|
+
update: "update";
|
|
59
|
+
create: "create";
|
|
60
|
+
}>>;
|
|
61
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
62
|
+
rule: z.ZodLiteral<"money">;
|
|
63
|
+
currencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
|
+
message: z.ZodOptional<z.ZodString>;
|
|
65
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
66
|
+
update: "update";
|
|
67
|
+
create: "create";
|
|
68
|
+
}>>;
|
|
42
69
|
}, z.core.$loose>, z.ZodObject<{
|
|
43
70
|
rule: z.ZodLiteral<"in">;
|
|
44
71
|
value: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
@@ -76,6 +103,16 @@ export declare const Rule: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
76
103
|
update: "update";
|
|
77
104
|
create: "create";
|
|
78
105
|
}>>;
|
|
106
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
107
|
+
rule: z.ZodLiteral<"postalCode">;
|
|
108
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
109
|
+
field: z.ZodString;
|
|
110
|
+
}, z.core.$loose>]>>;
|
|
111
|
+
message: z.ZodOptional<z.ZodString>;
|
|
112
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
113
|
+
update: "update";
|
|
114
|
+
create: "create";
|
|
115
|
+
}>>;
|
|
79
116
|
}, z.core.$loose>, z.ZodObject<{
|
|
80
117
|
rule: z.ZodLiteral<"crop">;
|
|
81
118
|
value: z.ZodObject<{
|
|
@@ -87,6 +124,14 @@ export declare const Rule: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
87
124
|
update: "update";
|
|
88
125
|
create: "create";
|
|
89
126
|
}>>;
|
|
127
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
128
|
+
rule: z.ZodLiteral<"providers">;
|
|
129
|
+
value: z.ZodArray<z.ZodString>;
|
|
130
|
+
message: z.ZodOptional<z.ZodString>;
|
|
131
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
132
|
+
update: "update";
|
|
133
|
+
create: "create";
|
|
134
|
+
}>>;
|
|
90
135
|
}, z.core.$loose>, z.ZodObject<{
|
|
91
136
|
rule: z.ZodString;
|
|
92
137
|
message: z.ZodOptional<z.ZodString>;
|
|
@@ -144,7 +189,6 @@ export declare const Field: z.ZodObject<{
|
|
|
144
189
|
rule: z.ZodEnum<{
|
|
145
190
|
email: "email";
|
|
146
191
|
url: "url";
|
|
147
|
-
tel: "tel";
|
|
148
192
|
json: "json";
|
|
149
193
|
}>;
|
|
150
194
|
message: z.ZodOptional<z.ZodString>;
|
|
@@ -152,6 +196,34 @@ export declare const Field: z.ZodObject<{
|
|
|
152
196
|
update: "update";
|
|
153
197
|
create: "create";
|
|
154
198
|
}>>;
|
|
199
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
200
|
+
rule: z.ZodLiteral<"tel">;
|
|
201
|
+
extension: z.ZodOptional<z.ZodBoolean>;
|
|
202
|
+
message: z.ZodOptional<z.ZodString>;
|
|
203
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
204
|
+
update: "update";
|
|
205
|
+
create: "create";
|
|
206
|
+
}>>;
|
|
207
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
208
|
+
rule: z.ZodLiteral<"daterange">;
|
|
209
|
+
open: z.ZodOptional<z.ZodEnum<{
|
|
210
|
+
start: "start";
|
|
211
|
+
end: "end";
|
|
212
|
+
both: "both";
|
|
213
|
+
}>>;
|
|
214
|
+
message: z.ZodOptional<z.ZodString>;
|
|
215
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
216
|
+
update: "update";
|
|
217
|
+
create: "create";
|
|
218
|
+
}>>;
|
|
219
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
220
|
+
rule: z.ZodLiteral<"money">;
|
|
221
|
+
currencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
222
|
+
message: z.ZodOptional<z.ZodString>;
|
|
223
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
224
|
+
update: "update";
|
|
225
|
+
create: "create";
|
|
226
|
+
}>>;
|
|
155
227
|
}, z.core.$loose>, z.ZodObject<{
|
|
156
228
|
rule: z.ZodLiteral<"in">;
|
|
157
229
|
value: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
@@ -189,6 +261,16 @@ export declare const Field: z.ZodObject<{
|
|
|
189
261
|
update: "update";
|
|
190
262
|
create: "create";
|
|
191
263
|
}>>;
|
|
264
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
265
|
+
rule: z.ZodLiteral<"postalCode">;
|
|
266
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
267
|
+
field: z.ZodString;
|
|
268
|
+
}, z.core.$loose>]>>;
|
|
269
|
+
message: z.ZodOptional<z.ZodString>;
|
|
270
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
271
|
+
update: "update";
|
|
272
|
+
create: "create";
|
|
273
|
+
}>>;
|
|
192
274
|
}, z.core.$loose>, z.ZodObject<{
|
|
193
275
|
rule: z.ZodLiteral<"crop">;
|
|
194
276
|
value: z.ZodObject<{
|
|
@@ -200,6 +282,14 @@ export declare const Field: z.ZodObject<{
|
|
|
200
282
|
update: "update";
|
|
201
283
|
create: "create";
|
|
202
284
|
}>>;
|
|
285
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
286
|
+
rule: z.ZodLiteral<"providers">;
|
|
287
|
+
value: z.ZodArray<z.ZodString>;
|
|
288
|
+
message: z.ZodOptional<z.ZodString>;
|
|
289
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
290
|
+
update: "update";
|
|
291
|
+
create: "create";
|
|
292
|
+
}>>;
|
|
203
293
|
}, z.core.$loose>, z.ZodObject<{
|
|
204
294
|
rule: z.ZodString;
|
|
205
295
|
message: z.ZodOptional<z.ZodString>;
|
|
@@ -292,6 +382,95 @@ export declare const RichTextSettings: z.ZodObject<{
|
|
|
292
382
|
}>>;
|
|
293
383
|
}, z.core.$loose>>;
|
|
294
384
|
}, z.core.$loose>;
|
|
385
|
+
/**
|
|
386
|
+
* The `settings` of a `duration` field: the unit of its value, and the parts its input shows.
|
|
387
|
+
* `validateDefinition()` checks them.
|
|
388
|
+
*/
|
|
389
|
+
export declare const DurationSettings: z.ZodObject<{
|
|
390
|
+
unit: z.ZodOptional<z.ZodEnum<{
|
|
391
|
+
seconds: "seconds";
|
|
392
|
+
minutes: "minutes";
|
|
393
|
+
hours: "hours";
|
|
394
|
+
days: "days";
|
|
395
|
+
}>>;
|
|
396
|
+
precision: z.ZodOptional<z.ZodEnum<{
|
|
397
|
+
seconds: "seconds";
|
|
398
|
+
minutes: "minutes";
|
|
399
|
+
hours: "hours";
|
|
400
|
+
days: "days";
|
|
401
|
+
}>>;
|
|
402
|
+
largestUnit: z.ZodOptional<z.ZodEnum<{
|
|
403
|
+
seconds: "seconds";
|
|
404
|
+
minutes: "minutes";
|
|
405
|
+
hours: "hours";
|
|
406
|
+
days: "days";
|
|
407
|
+
}>>;
|
|
408
|
+
}, z.core.$loose>;
|
|
409
|
+
/** A type of link that a site adds to a `link` field, in its `settings.types`. */
|
|
410
|
+
export declare const LinkTypeSetting: z.ZodObject<{
|
|
411
|
+
id: z.ZodString;
|
|
412
|
+
label: z.ZodString;
|
|
413
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
414
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
415
|
+
}, z.core.$loose>;
|
|
416
|
+
/** The `settings` of a `link` field (decision 0055). `validateDefinition()` checks them. */
|
|
417
|
+
export declare const LinkSettings: z.ZodObject<{
|
|
418
|
+
types: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
|
|
419
|
+
email: "email";
|
|
420
|
+
url: "url";
|
|
421
|
+
tel: "tel";
|
|
422
|
+
page: "page";
|
|
423
|
+
file: "file";
|
|
424
|
+
}>, z.ZodObject<{
|
|
425
|
+
id: z.ZodString;
|
|
426
|
+
label: z.ZodString;
|
|
427
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
428
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
429
|
+
}, z.core.$loose>]>>>;
|
|
430
|
+
newTab: z.ZodOptional<z.ZodEnum<{
|
|
431
|
+
never: "never";
|
|
432
|
+
choose: "choose";
|
|
433
|
+
external: "external";
|
|
434
|
+
}>>;
|
|
435
|
+
label: z.ZodOptional<z.ZodEnum<{
|
|
436
|
+
required: "required";
|
|
437
|
+
optional: "optional";
|
|
438
|
+
none: "none";
|
|
439
|
+
}>>;
|
|
440
|
+
libraries: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
441
|
+
}, z.core.$loose>;
|
|
442
|
+
/** The `settings` of an `address` field (decision 0054). `validateDefinition()` checks them. */
|
|
443
|
+
export declare const AddressSettings: z.ZodObject<{
|
|
444
|
+
country: z.ZodOptional<z.ZodString>;
|
|
445
|
+
countries: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
446
|
+
preferred: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
447
|
+
required: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
448
|
+
country: "country";
|
|
449
|
+
region: "region";
|
|
450
|
+
postalCode: "postalCode";
|
|
451
|
+
street: "street";
|
|
452
|
+
unit: "unit";
|
|
453
|
+
city: "city";
|
|
454
|
+
}>>>;
|
|
455
|
+
point: z.ZodOptional<z.ZodBoolean>;
|
|
456
|
+
}, z.core.$loose>;
|
|
457
|
+
/** The `settings` of a `daterange` field (decision 0053). `validateDefinition()` checks them. */
|
|
458
|
+
export declare const DateRangeSettings: z.ZodObject<{
|
|
459
|
+
time: z.ZodOptional<z.ZodBoolean>;
|
|
460
|
+
allDay: z.ZodOptional<z.ZodBoolean>;
|
|
461
|
+
open: z.ZodOptional<z.ZodEnum<{
|
|
462
|
+
start: "start";
|
|
463
|
+
end: "end";
|
|
464
|
+
both: "both";
|
|
465
|
+
}>>;
|
|
466
|
+
timeZone: z.ZodOptional<z.ZodString>;
|
|
467
|
+
chooseTimeZone: z.ZodOptional<z.ZodBoolean>;
|
|
468
|
+
}, z.core.$loose>;
|
|
469
|
+
/** The `settings` of a `money` field (decision 0053). `validateDefinition()` checks them. */
|
|
470
|
+
export declare const MoneySettings: z.ZodObject<{
|
|
471
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
472
|
+
currencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
473
|
+
}, z.core.$loose>;
|
|
295
474
|
export type Rule = z.infer<typeof Rule>;
|
|
296
475
|
export type BlockType = z.infer<typeof BlockType>;
|
|
297
476
|
export type Field = z.infer<typeof Field>;
|
|
@@ -299,4 +478,16 @@ export type Field = z.infer<typeof Field>;
|
|
|
299
478
|
export type RichTextStyle = z.infer<typeof RichTextStyle>;
|
|
300
479
|
/** The `settings` of a `richtext` field. */
|
|
301
480
|
export type RichTextSettings = z.infer<typeof RichTextSettings>;
|
|
481
|
+
/** A type of link that a site adds to a `link` field. */
|
|
482
|
+
export type LinkTypeSetting = z.infer<typeof LinkTypeSetting>;
|
|
483
|
+
/** The `settings` of a `link` field. */
|
|
484
|
+
export type LinkSettings = z.infer<typeof LinkSettings>;
|
|
485
|
+
/** The `settings` of an `address` field. */
|
|
486
|
+
export type AddressSettings = z.infer<typeof AddressSettings>;
|
|
487
|
+
/** The `settings` of a `daterange` field. */
|
|
488
|
+
export type DateRangeSettings = z.infer<typeof DateRangeSettings>;
|
|
489
|
+
/** The `settings` of a `money` field. */
|
|
490
|
+
export type MoneySettings = z.infer<typeof MoneySettings>;
|
|
491
|
+
/** The `settings` of a `duration` field. */
|
|
492
|
+
export type DurationSettings = z.infer<typeof DurationSettings>;
|
|
302
493
|
//# sourceMappingURL=field.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/schemas/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/schemas/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,OAAO,EAAa,SAAS,EAAU,MAAM,UAAU,CAAC;AAmCxD,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAiHX,CAAC;AAEP,eAAO,MAAM,SAAS;;;;YAKJ,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC;iBAGxC,CAAC;AAEH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAoEI,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC,CAAC;WAMxC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,SAAS,CAAC,CAAC;;iBAQhB,CAAC;AAEjD,4FAA4F;AAC5F,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;iBAepB,CAAC;AAEP;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsBvB,CAAC;AAEP;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;iBAkBvB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AAC,CAAC;AAC1D,4CAA4C;AAC5C,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
package/dist/schemas/field.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { PORTABLE_RULES, RICH_TEXT_STYLE_ELEMENTS } from "../constants.js";
|
|
1
|
+
import { ADDRESS_PARTS, BUILT_IN_LINK_TYPES, DATE_RANGE_OPEN_BOUNDS, DURATION_UNITS, PORTABLE_RULES, RICH_TEXT_STYLE_ELEMENTS } from "../constants.js";
|
|
2
2
|
import { Abilities, Condition, Option } from "./common.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/schemas/field.ts
|
|
5
5
|
var message = z.string().optional().meta({ description: "Message shown when the rule fails, instead of the default one." });
|
|
6
6
|
var mode = z.enum(["create", "update"]).optional().meta({ description: "The rule only applies when the item is created (`create`) or updated (`update`): a password required to create a user, optional to edit one. Without it, the rule applies in both modes." });
|
|
7
7
|
var Ratio = z.string().regex(/^[1-9][0-9]*:[1-9][0-9]*$/).meta({ description: "An aspect ratio, as `width:height`: `16:9`." });
|
|
8
|
+
var CountryCode = z.string().regex(/^[A-Z]{2}$/).meta({ description: "An ISO 3166-1 alpha-2 code, in capitals: `CA`." });
|
|
9
|
+
var CurrencyCode = z.string().regex(/^[A-Z]{3}$/).meta({ description: "An ISO 4217 currency code, in capitals: `CAD`." });
|
|
10
|
+
var DateRangeOpen = z.enum(DATE_RANGE_OPEN_BOUNDS).meta({ description: "Which bounds of the range can be `null`: `start`, `end` or `both`." });
|
|
8
11
|
var DateBound = z.union([z.string().meta({ description: "An ISO 8601 date or date-time." }), z.looseObject({ field: z.string().min(1) }).meta({ description: "Another field of the form." })]);
|
|
9
12
|
var Rule = z.union([
|
|
10
13
|
z.looseObject({
|
|
@@ -29,12 +32,29 @@ var Rule = z.union([
|
|
|
29
32
|
rule: z.enum([
|
|
30
33
|
"email",
|
|
31
34
|
"url",
|
|
32
|
-
"json"
|
|
33
|
-
"tel"
|
|
35
|
+
"json"
|
|
34
36
|
]),
|
|
35
37
|
message,
|
|
36
38
|
mode
|
|
37
39
|
}),
|
|
40
|
+
z.looseObject({
|
|
41
|
+
rule: z.literal("tel"),
|
|
42
|
+
extension: z.boolean().optional().meta({ description: "The number can have an extension, after `;ext=` as in a `tel:` URI (RFC 3966): `+15145550199;ext=123`, 1 to 10 digits. Without it, a value with an extension fails." }),
|
|
43
|
+
message,
|
|
44
|
+
mode
|
|
45
|
+
}),
|
|
46
|
+
z.looseObject({
|
|
47
|
+
rule: z.literal("daterange"),
|
|
48
|
+
open: DateRangeOpen.optional(),
|
|
49
|
+
message,
|
|
50
|
+
mode
|
|
51
|
+
}),
|
|
52
|
+
z.looseObject({
|
|
53
|
+
rule: z.literal("money"),
|
|
54
|
+
currencies: z.array(CurrencyCode).optional().meta({ description: "The currencies allowed. Without them, any ISO 4217 currency." }),
|
|
55
|
+
message,
|
|
56
|
+
mode
|
|
57
|
+
}),
|
|
38
58
|
z.looseObject({
|
|
39
59
|
rule: z.literal("in"),
|
|
40
60
|
value: z.array(z.union([
|
|
@@ -63,6 +83,12 @@ var Rule = z.union([
|
|
|
63
83
|
message,
|
|
64
84
|
mode
|
|
65
85
|
}),
|
|
86
|
+
z.looseObject({
|
|
87
|
+
rule: z.literal("postalCode"),
|
|
88
|
+
value: z.union([CountryCode, z.looseObject({ field: z.string().min(1) }).meta({ description: "Another field of the form, which holds the country." })]).optional().meta({ description: "The country of the postal code. Without it, or without a country, any postal code passes. An `address` value has its own country." }),
|
|
89
|
+
message,
|
|
90
|
+
mode
|
|
91
|
+
}),
|
|
66
92
|
z.looseObject({
|
|
67
93
|
rule: z.literal("crop"),
|
|
68
94
|
value: z.looseObject({
|
|
@@ -72,12 +98,18 @@ var Rule = z.union([
|
|
|
72
98
|
message,
|
|
73
99
|
mode
|
|
74
100
|
}),
|
|
101
|
+
z.looseObject({
|
|
102
|
+
rule: z.literal("providers"),
|
|
103
|
+
value: z.array(z.string().min(1)).min(1),
|
|
104
|
+
message,
|
|
105
|
+
mode
|
|
106
|
+
}).meta({ description: "The providers an `embed` value may come from: the `provider_name` of their oEmbed (`YouTube`), compared without case (decision 0058)." }),
|
|
75
107
|
z.looseObject({
|
|
76
108
|
rule: z.string().refine((rule) => !PORTABLE_RULES.includes(rule)),
|
|
77
109
|
message,
|
|
78
110
|
mode
|
|
79
111
|
}).meta({ description: "A rule added in a later version of the protocol. Clients that don't know it ignore it; the server still enforces it." })
|
|
80
|
-
]).meta({ description: "A portable validation rule. `min` and `max` apply to numbers, and to the length of text and arrays. `accept` lists MIME types (`image/*`). `maxSize` is in bytes. `crop` checks the transform of each image of an `image` or `media` value (decision 0031)." });
|
|
112
|
+
]).meta({ description: "A portable validation rule. `min` and `max` apply to numbers, to the amount of `money` values (in minor units), and to the length of text and arrays. `daterange` and `money` are implied by their types, with the `open` bounds and the `currencies` of the field (decision 0053). `accept` lists MIME types (`image/*`). `maxSize` is in bytes. `tel` checks an E.164 number, with an extension when `extension` is `true`. `crop` checks the transform of each image of an `image` or `media` value (decision 0031). `postalCode` checks a postal code against the format of its country, for the countries whose format Panneau knows: Canada and the United States (decision 0054). `providers` lists the providers of an `embed` value (decision 0058)." });
|
|
81
113
|
var BlockType = z.looseObject({
|
|
82
114
|
id: z.string().min(1),
|
|
83
115
|
label: z.string(),
|
|
@@ -101,8 +133,8 @@ var Field = z.looseObject({
|
|
|
101
133
|
rules: z.array(Rule).optional(),
|
|
102
134
|
visibleWhen: Condition.optional(),
|
|
103
135
|
options: z.array(Option).optional().meta({ description: "`select`: the choices." }),
|
|
104
|
-
multiple: z.boolean().optional().meta({ description: "`select`, `relation`, `media`, `image`, `file`: the value is an array." }),
|
|
105
|
-
resource: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]).optional().meta({ description: "`relation`: id of the related resource. `media`, `image`: id of a resource of kind `media`, or a list of them; without it, every library of the definition (decision 0027)." }),
|
|
136
|
+
multiple: z.boolean().optional().meta({ description: "`select`, `relation`, `media`, `image`, `file`, `country`: the value is an array." }),
|
|
137
|
+
resource: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]).optional().meta({ description: "`relation`: id of the related resource. `media`, `image`: id of a resource of kind `media`, or a list of them; without it, every library of the definition (decision 0027). `link`: the resources of its `page` links (decision 0055)." }),
|
|
106
138
|
accept: z.array(z.string()).optional().meta({ description: "`media`, `image`, `file`: accepted MIME types. `image` defaults to `image/*`." }),
|
|
107
139
|
ratios: z.array(Ratio).optional().meta({ description: "`image`: ratios the editor suggests. The `crop` rule enforces ratios (decision 0031)." }),
|
|
108
140
|
rotate: z.boolean().optional().meta({ description: "`image`: whether the editor offers rotation and flips. Defaults to true." }),
|
|
@@ -143,7 +175,59 @@ var RichTextSettings = z.looseObject({
|
|
|
143
175
|
"never"
|
|
144
176
|
]).optional().meta({ description: "Which links open in a new tab (`target=\"_blank\" rel=\"noopener noreferrer\"`): as the user chooses (the default), every link to another site, or none." }) }).optional()
|
|
145
177
|
}).meta({ description: "The `settings` of a `richtext` field. Its value is HTML. The toolbar only limits what users add: content that the field stores keeps its elements and attributes." });
|
|
178
|
+
/**
|
|
179
|
+
* The `settings` of a `duration` field: the unit of its value, and the parts its input shows.
|
|
180
|
+
* `validateDefinition()` checks them.
|
|
181
|
+
*/
|
|
182
|
+
var DurationSettings = z.looseObject({
|
|
183
|
+
unit: z.enum(DURATION_UNITS).optional().meta({ description: "The unit of the value, a whole number: `seconds` (the default), `minutes`, `hours` or `days`. The `min` and `max` rules are in it too." }),
|
|
184
|
+
precision: z.enum(DURATION_UNITS).optional().meta({ description: "The smallest part the input shows. Defaults to `unit`; a precision finer than `unit` is raised to it." }),
|
|
185
|
+
largestUnit: z.enum(DURATION_UNITS).optional().meta({ description: "The largest part the input shows, which has no upper bound: `days` shows days, and hours from 0 to 23. Defaults to the larger of `hours` and `precision`; a largest unit smaller than `precision` is raised to it." })
|
|
186
|
+
}).meta({ description: "The `settings` of a `duration` field. Its value is a whole number of `unit`, zero or more. A day is 24 hours." });
|
|
187
|
+
/** A type of link that a site adds to a `link` field, in its `settings.types`. */
|
|
188
|
+
var LinkTypeSetting = z.looseObject({
|
|
189
|
+
id: z.string().min(1).refine((id) => !BUILT_IN_LINK_TYPES.includes(id), { message: "A type of a site can't have the id of a built-in type." }).meta({ description: "The id of the type, in the `type` of values: `anchor`." }),
|
|
190
|
+
label: z.string().meta({ description: "The name of the type, in the field." }),
|
|
191
|
+
pattern: z.string().optional().meta({ description: "The pattern that the `url` of its links matches: `^#[\\w-]+$`." }),
|
|
192
|
+
placeholder: z.string().optional()
|
|
193
|
+
}).meta({ description: "A type of link that a site adds: its `url` is the text typed, checked against its `pattern`." });
|
|
194
|
+
/** The `settings` of a `link` field (decision 0055). `validateDefinition()` checks them. */
|
|
195
|
+
var LinkSettings = z.looseObject({
|
|
196
|
+
types: z.array(z.union([z.enum(BUILT_IN_LINK_TYPES), LinkTypeSetting])).min(1).optional().meta({ description: "The types the field offers, in order: `url`, `page`, `email`, `tel`, `file`, and the types of the site. Defaults to `url`, `email` and `tel`, after `page` when the field has a `resource`." }),
|
|
197
|
+
newTab: z.enum([
|
|
198
|
+
"choose",
|
|
199
|
+
"external",
|
|
200
|
+
"never"
|
|
201
|
+
]).optional().meta({ description: "Which links open in a new tab: as the user chooses (the default), by their type (`url` and `file` links), or none." }),
|
|
202
|
+
label: z.enum([
|
|
203
|
+
"optional",
|
|
204
|
+
"required",
|
|
205
|
+
"none"
|
|
206
|
+
]).optional().meta({ description: "Whether links have a label: optional (the default), required, or none." }),
|
|
207
|
+
libraries: z.array(z.string().min(1)).optional().meta({ description: "The media libraries of `file` links. Defaults to every library of the definition." })
|
|
208
|
+
}).meta({ description: "The `settings` of a `link` field. Its value is `{ \"type\", \"url\", \"page\", \"file\", \"label\", \"newTab\" }` (`LinkValue`)." });
|
|
209
|
+
/** The `settings` of an `address` field (decision 0054). `validateDefinition()` checks them. */
|
|
210
|
+
var AddressSettings = z.looseObject({
|
|
211
|
+
country: CountryCode.optional().meta({ description: "The country of a new address. The field sets it once a part is typed." }),
|
|
212
|
+
countries: z.array(CountryCode).optional().meta({ description: "The countries the field allows. With one, the field doesn't show the country, and sets it." }),
|
|
213
|
+
preferred: z.array(CountryCode).optional().meta({ description: "The countries shown first." }),
|
|
214
|
+
required: z.array(z.enum(ADDRESS_PARTS)).optional().meta({ description: "The parts a filled address must have. Defaults to `street`, `city` and `country`." }),
|
|
215
|
+
point: z.boolean().optional().meta({ description: "Adds a map, and the point of the address to the value." })
|
|
216
|
+
}).meta({ description: "The `settings` of an `address` field. Its value is `{ \"street\", \"unit\", \"city\", \"region\", \"postalCode\", \"country\", \"point\" }` (`AddressValue`)." });
|
|
217
|
+
/** The `settings` of a `daterange` field (decision 0053). `validateDefinition()` checks them. */
|
|
218
|
+
var DateRangeSettings = z.looseObject({
|
|
219
|
+
time: z.boolean().optional().meta({ description: "The bounds are date-times, with an offset (`2026-11-04T23:30:00Z`). Without it, they are days (`2026-11-04`), both inclusive." }),
|
|
220
|
+
allDay: z.boolean().optional().meta({ description: "With `time`: an \"All day\" switch. An all-day value has days as bounds, and `\"allDay\": true`." }),
|
|
221
|
+
open: DateRangeOpen.optional(),
|
|
222
|
+
timeZone: z.string().min(1).optional().meta({ description: "The IANA time zone the date-times are shown and typed in (`America/Toronto`), when the value has none. Without it, the browser's." }),
|
|
223
|
+
chooseTimeZone: z.boolean().optional().meta({ description: "With `time`: the field has a menu of time zones, and keeps the choice in the value (`timeZone`)." })
|
|
224
|
+
}).meta({ description: "The `settings` of a `daterange` field: days or date-times, an \"All day\" switch, open bounds and the time zone of its date-times." });
|
|
225
|
+
/** The `settings` of a `money` field (decision 0053). `validateDefinition()` checks them. */
|
|
226
|
+
var MoneySettings = z.looseObject({
|
|
227
|
+
currency: CurrencyCode.optional().meta({ description: "The currency of every amount: the field shows it and cannot change it." }),
|
|
228
|
+
currencies: z.array(CurrencyCode).min(1).optional().meta({ description: "The currencies the user picks from, the first one for a new amount. Without `currency` or `currencies`, every currency." })
|
|
229
|
+
}).meta({ description: "The `settings` of a `money` field: its currency, or the currencies to pick from. `min` and `max` rules apply to the amount, in minor units." });
|
|
146
230
|
//#endregion
|
|
147
|
-
export { BlockType, Field, RichTextSettings, RichTextStyle, Rule };
|
|
231
|
+
export { AddressSettings, BlockType, DateRangeSettings, DurationSettings, Field, LinkSettings, LinkTypeSetting, MoneySettings, RichTextSettings, RichTextStyle, Rule };
|
|
148
232
|
|
|
149
233
|
//# sourceMappingURL=field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.js","names":[],"sources":["../../src/schemas/field.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport { PORTABLE_RULES, RICH_TEXT_STYLE_ELEMENTS } from '../constants';\nimport { Abilities, Condition, Option } from './common';\n\nconst message = z\n .string()\n .optional()\n .meta({ description: 'Message shown when the rule fails, instead of the default one.' });\n\nconst mode = z.enum(['create', 'update']).optional().meta({\n description:\n 'The rule only applies when the item is created (`create`) or updated (`update`): a password required to create a user, optional to edit one. Without it, the rule applies in both modes.',\n});\n\nconst Ratio = z\n .string()\n .regex(/^[1-9][0-9]*:[1-9][0-9]*$/)\n .meta({ description: 'An aspect ratio, as `width:height`: `16:9`.' });\n\nconst DateBound = z.union([\n z.string().meta({ description: 'An ISO 8601 date or date-time.' }),\n z.looseObject({ field: z.string().min(1) }).meta({ description: 'Another field of the form.' }),\n]);\n\nexport const Rule = z\n .union([\n z.looseObject({ rule: z.literal('required'), message, mode }),\n z.looseObject({ rule: z.enum(['min', 'max']), value: z.number(), message, mode }),\n z.looseObject({\n rule: z.literal('pattern'),\n value: z.string(),\n flags: z.string().optional(),\n message,\n mode,\n }),\n z.looseObject({ rule: z.enum(['email', 'url', 'json', 'tel']), message, mode }),\n z.looseObject({\n rule: z.literal('in'),\n value: z.array(z.union([z.string(), z.number(), z.boolean()])),\n message,\n mode,\n }),\n z.looseObject({\n rule: z.literal('accept'),\n value: z.array(z.string().min(1)),\n message,\n mode,\n }),\n z.looseObject({\n rule: z.literal('maxSize'),\n value: z.number().int().positive(),\n message,\n mode,\n }),\n z.looseObject({ rule: z.enum(['before', 'after']), value: DateBound, message, mode }),\n z.looseObject({\n rule: z.literal('crop'),\n value: z.looseObject({\n ratios: z.array(Ratio).optional().meta({\n description:\n 'A crop must have one of them: its height is within one pixel of its width divided by the ratio, after its rotation.',\n }),\n required: z\n .boolean()\n .optional()\n .meta({ description: 'Each image needs a crop for this use.' }),\n }),\n message,\n mode,\n }),\n z\n .looseObject({\n rule: z\n .string()\n .refine((rule) => !(PORTABLE_RULES as readonly string[]).includes(rule)),\n message,\n mode,\n })\n .meta({\n description:\n \"A rule added in a later version of the protocol. Clients that don't know it ignore it; the server still enforces it.\",\n }),\n ])\n .meta({\n description:\n 'A portable validation rule. `min` and `max` apply to numbers, and to the length of text and arrays. `accept` lists MIME types (`image/*`). `maxSize` is in bytes. `crop` checks the transform of each image of an `image` or `media` value (decision 0031).',\n });\n\nexport const BlockType = z.looseObject({\n id: z.string().min(1),\n label: z.string(),\n icon: z.string().optional(),\n // Return types are written out so that declaration files keep the recursion.\n get fields(): z.ZodArray<typeof Field> {\n return z.array(Field);\n },\n});\n\nexport const Field = z\n .looseObject({\n name: z.string().min(1),\n type: z\n .string()\n .min(1)\n .meta({ description: 'A built-in field type, or a type provided by a plugin.' }),\n label: z.string().optional(),\n help: z.string().optional(),\n placeholder: z.string().optional(),\n default: z.unknown().optional(),\n localized: z\n .boolean()\n .optional()\n .meta({ description: 'The value is an object keyed by locale.' }),\n readOnly: z.boolean().optional().meta({\n description:\n \"Nobody edits the field (a computed value). For a field the current user can't edit, use `abilities.update: false`.\",\n }),\n abilities: Abilities.optional().meta({\n description:\n \"What the current user can do with the field (decision 0046). Only `false` restricts: `view: false` leaves the field out of forms, details and lists, and items don't carry its value; `update: false` makes it read-only, and the backend ignores its value. For the fields at the top of a resource and of its types.\",\n }),\n createOnly: z.boolean().optional(),\n updateOnly: z.boolean().optional(),\n rules: z.array(Rule).optional(),\n visibleWhen: Condition.optional(),\n options: z.array(Option).optional().meta({ description: '`select`: the choices.' }),\n multiple: z.boolean().optional().meta({\n description: '`select`, `relation`, `media`, `image`, `file`: the value is an array.',\n }),\n resource: z\n .union([z.string().min(1), z.array(z.string().min(1)).min(1)])\n .optional()\n .meta({\n description:\n '`relation`: id of the related resource. `media`, `image`: id of a resource of kind `media`, or a list of them; without it, every library of the definition (decision 0027).',\n }),\n accept: z.array(z.string()).optional().meta({\n description:\n '`media`, `image`, `file`: accepted MIME types. `image` defaults to `image/*`.',\n }),\n ratios: z.array(Ratio).optional().meta({\n description:\n '`image`: ratios the editor suggests. The `crop` rule enforces ratios (decision 0031).',\n }),\n rotate: z.boolean().optional().meta({\n description: '`image`: whether the editor offers rotation and flips. Defaults to true.',\n }),\n focalPoint: z.boolean().optional().meta({\n description: '`image`: whether the editor offers the focal point. Defaults to true.',\n }),\n transformBase: z.enum(['media', 'original', 'choose']).optional().meta({\n description:\n \"`image`: what a transform for one use starts from: the media's own transform (`media`, the default), the original file, or the user's choice in the editor (decision 0031).\",\n }),\n from: z.string().optional().meta({\n description:\n '`slug`: the field the slug is generated from. `region`: the field of the same object that holds its country.',\n }),\n check: z.boolean().optional().meta({\n description:\n 'The client checks the value with the backend as it is typed, with `POST /resources/{resource}/fields/{field}/check`: whether a `slug` is available, and its URL. A field at the top of the resource only.',\n }),\n display: z.string().optional().meta({\n description: 'Display used in lists, when it differs from the default one of the type.',\n }),\n get fields(): z.ZodOptional<z.ZodArray<typeof Field>> {\n return z\n .array(Field)\n .optional()\n .meta({ description: '`group` and `repeater`: the nested fields.' });\n },\n get types(): z.ZodOptional<z.ZodArray<typeof BlockType>> {\n return z\n .array(BlockType)\n .optional()\n .meta({ description: '`repeater`: typed blocks, each with its own fields.' });\n },\n settings: z.record(z.string(), z.unknown()).optional(),\n })\n .meta({ description: 'A field of a form.' });\n\n/** A block style of a `richtext` field: a named class on an element (`<p class=\"big\">`). */\nexport const RichTextStyle = z\n .looseObject({\n label: z.string().meta({ description: 'The name of the style in the toolbar.' }),\n class: z.string().min(1).meta({\n description:\n 'The class the style puts on the element: `big`. Several classes are separated by spaces.',\n }),\n element: z.enum(RICH_TEXT_STYLE_ELEMENTS).optional().meta({\n description:\n 'The element the style applies to: `p` (the default), `h1` to `h6`, `blockquote`, `ul`, `ol` or `li`.',\n }),\n })\n .meta({\n description:\n 'A block style of a `richtext` field: a named class on a paragraph, a heading, a quote or a list (`<p class=\"big\">`).',\n });\n\n/**\n * The `settings` of a `richtext` field: its toolbar, heading levels, block styles and which links\n * open in a new tab. `validateDefinition()` checks them.\n */\nexport const RichTextSettings = z\n .looseObject({\n toolbar: z.array(z.string().min(1)).optional().meta({\n description:\n \"The toolbar, in order: `heading`, `style`, `bold`, `italic`, `underline`, `strike`, `superscript`, `subscript`, `code`, `link`, `bulletList`, `orderedList`, `blockquote`, `horizontalRule`, `clear`, `undo`, `redo`, `|` between groups, and the buttons of plugins. Clients skip the names they don't know.\",\n }),\n headings: z.array(z.number().int().min(1).max(6)).optional().meta({\n description: 'The heading levels the toolbar offers. Defaults to 2, 3 and 4.',\n }),\n styles: z.array(RichTextStyle).optional().meta({ description: 'The block styles.' }),\n links: z\n .looseObject({\n newTab: z.enum(['choose', 'external', 'never']).optional().meta({\n description:\n 'Which links open in a new tab (`target=\"_blank\" rel=\"noopener noreferrer\"`): as the user chooses (the default), every link to another site, or none.',\n }),\n })\n .optional(),\n })\n .meta({\n description:\n 'The `settings` of a `richtext` field. Its value is HTML. The toolbar only limits what users add: content that the field stores keeps its elements and attributes.',\n });\n\nexport type Rule = z.infer<typeof Rule>;\nexport type BlockType = z.infer<typeof BlockType>;\nexport type Field = z.infer<typeof Field>;\n/** A block style of a `richtext` field. */\nexport type RichTextStyle = z.infer<typeof RichTextStyle>;\n/** The `settings` of a `richtext` field. */\nexport type RichTextSettings = z.infer<typeof RichTextSettings>;\n"],"mappings":";;;;AAKA,IAAM,UAAU,EACX,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UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAC9D,aAAa,iEACjB,CAAC;CACD,QAAQ,EAAE,MAAM,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,aAAa,oBAAoB,CAAC;CACnF,OAAO,EACF,YAAY,EACT,QAAQ,EAAE,KAAK;EAAC;EAAU;EAAY;CAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAC5D,aACI,2JACR,CAAC,EACL,CAAC,CAAC,CACD,SAAS;AAClB,CAAC,CAAC,CACD,KAAK,EACF,aACI,oKACR,CAAC"}
|
|
1
|
+
{"version":3,"file":"field.js","names":[],"sources":["../../src/schemas/field.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport {\n ADDRESS_PARTS,\n BUILT_IN_LINK_TYPES,\n DATE_RANGE_OPEN_BOUNDS,\n DURATION_UNITS,\n PORTABLE_RULES,\n RICH_TEXT_STYLE_ELEMENTS,\n} from '../constants';\nimport { Abilities, Condition, Option } from './common';\n\nconst message = z\n .string()\n .optional()\n .meta({ description: 'Message shown when the rule fails, instead of the default one.' });\n\nconst mode = z.enum(['create', 'update']).optional().meta({\n description:\n 'The rule only applies when the item is created (`create`) or updated (`update`): a password required to create a user, optional to edit one. Without it, the rule applies in both modes.',\n});\n\nconst Ratio = z\n .string()\n .regex(/^[1-9][0-9]*:[1-9][0-9]*$/)\n .meta({ description: 'An aspect ratio, as `width:height`: `16:9`.' });\n\nconst CountryCode = z\n .string()\n .regex(/^[A-Z]{2}$/)\n .meta({ description: 'An ISO 3166-1 alpha-2 code, in capitals: `CA`.' });\nconst CurrencyCode = z\n .string()\n .regex(/^[A-Z]{3}$/)\n .meta({ description: 'An ISO 4217 currency code, in capitals: `CAD`.' });\n\nconst DateRangeOpen = z.enum(DATE_RANGE_OPEN_BOUNDS).meta({\n description: 'Which bounds of the range can be `null`: `start`, `end` or `both`.',\n});\n\nconst DateBound = z.union([\n z.string().meta({ description: 'An ISO 8601 date or date-time.' }),\n z.looseObject({ field: z.string().min(1) }).meta({ description: 'Another field of the form.' }),\n]);\n\nexport const Rule = z\n .union([\n z.looseObject({ rule: z.literal('required'), message, mode }),\n z.looseObject({ rule: z.enum(['min', 'max']), value: z.number(), message, mode }),\n z.looseObject({\n rule: z.literal('pattern'),\n value: z.string(),\n flags: z.string().optional(),\n message,\n mode,\n }),\n z.looseObject({ rule: z.enum(['email', 'url', 'json']), message, mode }),\n z.looseObject({\n rule: z.literal('tel'),\n extension: z.boolean().optional().meta({\n description:\n 'The number can have an extension, after `;ext=` as in a `tel:` URI (RFC 3966): `+15145550199;ext=123`, 1 to 10 digits. Without it, a value with an extension fails.',\n }),\n message,\n mode,\n }),\n z.looseObject({\n rule: z.literal('daterange'),\n open: DateRangeOpen.optional(),\n message,\n mode,\n }),\n z.looseObject({\n rule: z.literal('money'),\n currencies: z.array(CurrencyCode).optional().meta({\n description: 'The currencies allowed. Without them, any ISO 4217 currency.',\n }),\n message,\n mode,\n }),\n z.looseObject({\n rule: z.literal('in'),\n value: z.array(z.union([z.string(), z.number(), z.boolean()])),\n message,\n mode,\n }),\n z.looseObject({\n rule: z.literal('accept'),\n value: z.array(z.string().min(1)),\n message,\n mode,\n }),\n z.looseObject({\n rule: z.literal('maxSize'),\n value: z.number().int().positive(),\n message,\n mode,\n }),\n z.looseObject({ rule: z.enum(['before', 'after']), value: DateBound, message, mode }),\n z.looseObject({\n rule: z.literal('postalCode'),\n value: z\n .union([\n CountryCode,\n z.looseObject({ field: z.string().min(1) }).meta({\n description: 'Another field of the form, which holds the country.',\n }),\n ])\n .optional()\n .meta({\n description:\n 'The country of the postal code. Without it, or without a country, any postal code passes. An `address` value has its own country.',\n }),\n message,\n mode,\n }),\n z.looseObject({\n rule: z.literal('crop'),\n value: z.looseObject({\n ratios: z.array(Ratio).optional().meta({\n description:\n 'A crop must have one of them: its height is within one pixel of its width divided by the ratio, after its rotation.',\n }),\n required: z\n .boolean()\n .optional()\n .meta({ description: 'Each image needs a crop for this use.' }),\n }),\n message,\n mode,\n }),\n z\n .looseObject({\n rule: z.literal('providers'),\n value: z.array(z.string().min(1)).min(1),\n message,\n mode,\n })\n .meta({\n description:\n 'The providers an `embed` value may come from: the `provider_name` of their oEmbed (`YouTube`), compared without case (decision 0058).',\n }),\n z\n .looseObject({\n rule: z\n .string()\n .refine((rule) => !(PORTABLE_RULES as readonly string[]).includes(rule)),\n message,\n mode,\n })\n .meta({\n description:\n \"A rule added in a later version of the protocol. Clients that don't know it ignore it; the server still enforces it.\",\n }),\n ])\n .meta({\n description:\n 'A portable validation rule. `min` and `max` apply to numbers, to the amount of `money` values (in minor units), and to the length of text and arrays. `daterange` and `money` are implied by their types, with the `open` bounds and the `currencies` of the field (decision 0053). `accept` lists MIME types (`image/*`). `maxSize` is in bytes. `tel` checks an E.164 number, with an extension when `extension` is `true`. `crop` checks the transform of each image of an `image` or `media` value (decision 0031). `postalCode` checks a postal code against the format of its country, for the countries whose format Panneau knows: Canada and the United States (decision 0054). `providers` lists the providers of an `embed` value (decision 0058).',\n });\n\nexport const BlockType = z.looseObject({\n id: z.string().min(1),\n label: z.string(),\n icon: z.string().optional(),\n // Return types are written out so that declaration files keep the recursion.\n get fields(): z.ZodArray<typeof Field> {\n return z.array(Field);\n },\n});\n\nexport const Field = z\n .looseObject({\n name: z.string().min(1),\n type: z\n .string()\n .min(1)\n .meta({ description: 'A built-in field type, or a type provided by a plugin.' }),\n label: z.string().optional(),\n help: z.string().optional(),\n placeholder: z.string().optional(),\n default: z.unknown().optional(),\n localized: z\n .boolean()\n .optional()\n .meta({ description: 'The value is an object keyed by locale.' }),\n readOnly: z.boolean().optional().meta({\n description:\n \"Nobody edits the field (a computed value). For a field the current user can't edit, use `abilities.update: false`.\",\n }),\n abilities: Abilities.optional().meta({\n description:\n \"What the current user can do with the field (decision 0046). Only `false` restricts: `view: false` leaves the field out of forms, details and lists, and items don't carry its value; `update: false` makes it read-only, and the backend ignores its value. For the fields at the top of a resource and of its types.\",\n }),\n createOnly: z.boolean().optional(),\n updateOnly: z.boolean().optional(),\n rules: z.array(Rule).optional(),\n visibleWhen: Condition.optional(),\n options: z.array(Option).optional().meta({ description: '`select`: the choices.' }),\n multiple: z.boolean().optional().meta({\n description:\n '`select`, `relation`, `media`, `image`, `file`, `country`: the value is an array.',\n }),\n resource: z\n .union([z.string().min(1), z.array(z.string().min(1)).min(1)])\n .optional()\n .meta({\n description:\n '`relation`: id of the related resource. `media`, `image`: id of a resource of kind `media`, or a list of them; without it, every library of the definition (decision 0027). `link`: the resources of its `page` links (decision 0055).',\n }),\n accept: z.array(z.string()).optional().meta({\n description:\n '`media`, `image`, `file`: accepted MIME types. `image` defaults to `image/*`.',\n }),\n ratios: z.array(Ratio).optional().meta({\n description:\n '`image`: ratios the editor suggests. The `crop` rule enforces ratios (decision 0031).',\n }),\n rotate: z.boolean().optional().meta({\n description: '`image`: whether the editor offers rotation and flips. Defaults to true.',\n }),\n focalPoint: z.boolean().optional().meta({\n description: '`image`: whether the editor offers the focal point. Defaults to true.',\n }),\n transformBase: z.enum(['media', 'original', 'choose']).optional().meta({\n description:\n \"`image`: what a transform for one use starts from: the media's own transform (`media`, the default), the original file, or the user's choice in the editor (decision 0031).\",\n }),\n from: z.string().optional().meta({\n description:\n '`slug`: the field the slug is generated from. `region`: the field of the same object that holds its country.',\n }),\n check: z.boolean().optional().meta({\n description:\n 'The client checks the value with the backend as it is typed, with `POST /resources/{resource}/fields/{field}/check`: whether a `slug` is available, and its URL. A field at the top of the resource only.',\n }),\n display: z.string().optional().meta({\n description: 'Display used in lists, when it differs from the default one of the type.',\n }),\n get fields(): z.ZodOptional<z.ZodArray<typeof Field>> {\n return z\n .array(Field)\n .optional()\n .meta({ description: '`group` and `repeater`: the nested fields.' });\n },\n get types(): z.ZodOptional<z.ZodArray<typeof BlockType>> {\n return z\n .array(BlockType)\n .optional()\n .meta({ description: '`repeater`: typed blocks, each with its own fields.' });\n },\n settings: z.record(z.string(), z.unknown()).optional(),\n })\n .meta({ description: 'A field of a form.' });\n\n/** A block style of a `richtext` field: a named class on an element (`<p class=\"big\">`). */\nexport const RichTextStyle = z\n .looseObject({\n label: z.string().meta({ description: 'The name of the style in the toolbar.' }),\n class: z.string().min(1).meta({\n description:\n 'The class the style puts on the element: `big`. Several classes are separated by spaces.',\n }),\n element: z.enum(RICH_TEXT_STYLE_ELEMENTS).optional().meta({\n description:\n 'The element the style applies to: `p` (the default), `h1` to `h6`, `blockquote`, `ul`, `ol` or `li`.',\n }),\n })\n .meta({\n description:\n 'A block style of a `richtext` field: a named class on a paragraph, a heading, a quote or a list (`<p class=\"big\">`).',\n });\n\n/**\n * The `settings` of a `richtext` field: its toolbar, heading levels, block styles and which links\n * open in a new tab. `validateDefinition()` checks them.\n */\nexport const RichTextSettings = z\n .looseObject({\n toolbar: z.array(z.string().min(1)).optional().meta({\n description:\n \"The toolbar, in order: `heading`, `style`, `bold`, `italic`, `underline`, `strike`, `superscript`, `subscript`, `code`, `link`, `bulletList`, `orderedList`, `blockquote`, `horizontalRule`, `clear`, `undo`, `redo`, `|` between groups, and the buttons of plugins. Clients skip the names they don't know.\",\n }),\n headings: z.array(z.number().int().min(1).max(6)).optional().meta({\n description: 'The heading levels the toolbar offers. Defaults to 2, 3 and 4.',\n }),\n styles: z.array(RichTextStyle).optional().meta({ description: 'The block styles.' }),\n links: z\n .looseObject({\n newTab: z.enum(['choose', 'external', 'never']).optional().meta({\n description:\n 'Which links open in a new tab (`target=\"_blank\" rel=\"noopener noreferrer\"`): as the user chooses (the default), every link to another site, or none.',\n }),\n })\n .optional(),\n })\n .meta({\n description:\n 'The `settings` of a `richtext` field. Its value is HTML. The toolbar only limits what users add: content that the field stores keeps its elements and attributes.',\n });\n\n/**\n * The `settings` of a `duration` field: the unit of its value, and the parts its input shows.\n * `validateDefinition()` checks them.\n */\nexport const DurationSettings = z\n .looseObject({\n unit: z.enum(DURATION_UNITS).optional().meta({\n description:\n 'The unit of the value, a whole number: `seconds` (the default), `minutes`, `hours` or `days`. The `min` and `max` rules are in it too.',\n }),\n precision: z.enum(DURATION_UNITS).optional().meta({\n description:\n 'The smallest part the input shows. Defaults to `unit`; a precision finer than `unit` is raised to it.',\n }),\n largestUnit: z.enum(DURATION_UNITS).optional().meta({\n description:\n 'The largest part the input shows, which has no upper bound: `days` shows days, and hours from 0 to 23. Defaults to the larger of `hours` and `precision`; a largest unit smaller than `precision` is raised to it.',\n }),\n })\n .meta({\n description:\n 'The `settings` of a `duration` field. Its value is a whole number of `unit`, zero or more. A day is 24 hours.',\n });\n\n/** A type of link that a site adds to a `link` field, in its `settings.types`. */\nexport const LinkTypeSetting = z\n .looseObject({\n id: z\n .string()\n .min(1)\n .refine((id) => !(BUILT_IN_LINK_TYPES as readonly string[]).includes(id), {\n message: \"A type of a site can't have the id of a built-in type.\",\n })\n .meta({ description: 'The id of the type, in the `type` of values: `anchor`.' }),\n label: z.string().meta({ description: 'The name of the type, in the field.' }),\n pattern: z.string().optional().meta({\n description: 'The pattern that the `url` of its links matches: `^#[\\\\w-]+$`.',\n }),\n placeholder: z.string().optional(),\n })\n .meta({\n description:\n 'A type of link that a site adds: its `url` is the text typed, checked against its `pattern`.',\n });\n\n/** The `settings` of a `link` field (decision 0055). `validateDefinition()` checks them. */\nexport const LinkSettings = z\n .looseObject({\n types: z\n .array(z.union([z.enum(BUILT_IN_LINK_TYPES), LinkTypeSetting]))\n .min(1)\n .optional()\n .meta({\n description:\n 'The types the field offers, in order: `url`, `page`, `email`, `tel`, `file`, and the types of the site. Defaults to `url`, `email` and `tel`, after `page` when the field has a `resource`.',\n }),\n newTab: z.enum(['choose', 'external', 'never']).optional().meta({\n description:\n 'Which links open in a new tab: as the user chooses (the default), by their type (`url` and `file` links), or none.',\n }),\n label: z.enum(['optional', 'required', 'none']).optional().meta({\n description: 'Whether links have a label: optional (the default), required, or none.',\n }),\n libraries: z.array(z.string().min(1)).optional().meta({\n description:\n 'The media libraries of `file` links. Defaults to every library of the definition.',\n }),\n })\n .meta({\n description:\n 'The `settings` of a `link` field. Its value is `{ \"type\", \"url\", \"page\", \"file\", \"label\", \"newTab\" }` (`LinkValue`).',\n });\n\n/** The `settings` of an `address` field (decision 0054). `validateDefinition()` checks them. */\nexport const AddressSettings = z\n .looseObject({\n country: CountryCode.optional().meta({\n description: 'The country of a new address. The field sets it once a part is typed.',\n }),\n countries: z.array(CountryCode).optional().meta({\n description:\n \"The countries the field allows. With one, the field doesn't show the country, and sets it.\",\n }),\n preferred: z\n .array(CountryCode)\n .optional()\n .meta({ description: 'The countries shown first.' }),\n required: z.array(z.enum(ADDRESS_PARTS)).optional().meta({\n description:\n 'The parts a filled address must have. Defaults to `street`, `city` and `country`.',\n }),\n point: z.boolean().optional().meta({\n description: 'Adds a map, and the point of the address to the value.',\n }),\n })\n .meta({\n description:\n 'The `settings` of an `address` field. Its value is `{ \"street\", \"unit\", \"city\", \"region\", \"postalCode\", \"country\", \"point\" }` (`AddressValue`).',\n });\n\n/** The `settings` of a `daterange` field (decision 0053). `validateDefinition()` checks them. */\nexport const DateRangeSettings = z\n .looseObject({\n time: z.boolean().optional().meta({\n description:\n 'The bounds are date-times, with an offset (`2026-11-04T23:30:00Z`). Without it, they are days (`2026-11-04`), both inclusive.',\n }),\n allDay: z.boolean().optional().meta({\n description:\n 'With `time`: an \"All day\" switch. An all-day value has days as bounds, and `\"allDay\": true`.',\n }),\n open: DateRangeOpen.optional(),\n timeZone: z.string().min(1).optional().meta({\n description:\n \"The IANA time zone the date-times are shown and typed in (`America/Toronto`), when the value has none. Without it, the browser's.\",\n }),\n chooseTimeZone: z.boolean().optional().meta({\n description:\n 'With `time`: the field has a menu of time zones, and keeps the choice in the value (`timeZone`).',\n }),\n })\n .meta({\n description:\n 'The `settings` of a `daterange` field: days or date-times, an \"All day\" switch, open bounds and the time zone of its date-times.',\n });\n\n/** The `settings` of a `money` field (decision 0053). `validateDefinition()` checks them. */\nexport const MoneySettings = z\n .looseObject({\n currency: CurrencyCode.optional().meta({\n description: 'The currency of every amount: the field shows it and cannot change it.',\n }),\n currencies: z.array(CurrencyCode).min(1).optional().meta({\n description:\n 'The currencies the user picks from, the first one for a new amount. Without `currency` or `currencies`, every currency.',\n }),\n })\n .meta({\n description:\n 'The `settings` of a `money` field: its currency, or the currencies to pick from. `min` and `max` rules apply to the amount, in minor units.',\n });\n\nexport type Rule = z.infer<typeof Rule>;\nexport type BlockType = z.infer<typeof BlockType>;\nexport type Field = z.infer<typeof Field>;\n/** A block style of a `richtext` field. */\nexport type RichTextStyle = z.infer<typeof RichTextStyle>;\n/** The `settings` of a `richtext` field. */\nexport type RichTextSettings = z.infer<typeof RichTextSettings>;\n/** A type of link that a site adds to a `link` field. */\nexport type LinkTypeSetting = z.infer<typeof LinkTypeSetting>;\n/** The `settings` of a `link` field. */\nexport type LinkSettings = z.infer<typeof LinkSettings>;\n/** The `settings` of an `address` field. */\nexport type AddressSettings = z.infer<typeof AddressSettings>;\n/** The `settings` of a `daterange` field. */\nexport type DateRangeSettings = z.infer<typeof DateRangeSettings>;\n/** The `settings` of a `money` field. */\nexport type MoneySettings = z.infer<typeof MoneySettings>;\n/** The `settings` of a `duration` field. */\nexport type DurationSettings = z.infer<typeof DurationSettings>;\n"],"mappings":";;;;AAYA,IAAM,UAAU,EACX,OAAO,CAAC,CACR,SAAS,CAAC,CACV,KAAK,EAAE,aAAa,iEAAiE,CAAC;AAE3F,IAAM,OAAO,EAAE,KAAK,CAAC,UAAU,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EACtD,aACI,2LACR,CAAC;AAED,IAAM,QAAQ,EACT,OAAO,CAAC,CACR,MAAM,2BAA2B,CAAC,CAClC,KAAK,EAAE,aAAa,8CAA8C,CAAC;AAExE,IAAM,cAAc,EACf,OAAO,CAAC,CACR,MAAM,YAAY,CAAC,CACnB,KAAK,EAAE,aA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