@stonecrop/graphql-middleware 0.8.7 → 0.8.8

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/index.js CHANGED
@@ -1,3198 +1,188 @@
1
- import { isScalarType as nt, isEnumType as rt, isObjectType as Q, isNonNullType as $e, isListType as st, buildSchema as at, buildClientSchema as it } from "graphql";
2
- import { readdirSync as ot, statSync as ct, readFileSync as dt } from "node:fs";
3
- import { join as lt } from "node:path";
4
- import { extendSchema as ut, gql as ft } from "postgraphile/utils";
5
- import { loadOne as fe, object as pe, constant as pt, lambda as ht } from "postgraphile/grafast";
6
- var v;
7
- (function(n) {
8
- n.assertEqual = (s) => {
9
- };
10
- function e(s) {
11
- }
12
- n.assertIs = e;
13
- function t(s) {
14
- throw new Error();
15
- }
16
- n.assertNever = t, n.arrayToEnum = (s) => {
17
- const a = {};
18
- for (const i of s)
19
- a[i] = i;
20
- return a;
21
- }, n.getValidEnumValues = (s) => {
22
- const a = n.objectKeys(s).filter((o) => typeof s[s[o]] != "number"), i = {};
23
- for (const o of a)
24
- i[o] = s[o];
25
- return n.objectValues(i);
26
- }, n.objectValues = (s) => n.objectKeys(s).map(function(a) {
27
- return s[a];
28
- }), n.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
29
- const a = [];
30
- for (const i in s)
31
- Object.prototype.hasOwnProperty.call(s, i) && a.push(i);
32
- return a;
33
- }, n.find = (s, a) => {
34
- for (const i of s)
35
- if (a(i))
36
- return i;
37
- }, n.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && Number.isFinite(s) && Math.floor(s) === s;
38
- function r(s, a = " | ") {
39
- return s.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
40
- }
41
- n.joinValues = r, n.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
42
- })(v || (v = {}));
43
- var Re;
44
- (function(n) {
45
- n.mergeShapes = (e, t) => ({
46
- ...e,
47
- ...t
48
- // second overwrites first
49
- });
50
- })(Re || (Re = {}));
51
- const f = v.arrayToEnum([
52
- "string",
53
- "nan",
54
- "number",
55
- "integer",
56
- "float",
57
- "boolean",
58
- "date",
59
- "bigint",
60
- "symbol",
61
- "function",
62
- "undefined",
63
- "null",
64
- "array",
65
- "object",
66
- "unknown",
67
- "promise",
68
- "void",
69
- "never",
70
- "map",
71
- "set"
72
- ]), j = (n) => {
73
- switch (typeof n) {
74
- case "undefined":
75
- return f.undefined;
76
- case "string":
77
- return f.string;
78
- case "number":
79
- return Number.isNaN(n) ? f.nan : f.number;
80
- case "boolean":
81
- return f.boolean;
82
- case "function":
83
- return f.function;
84
- case "bigint":
85
- return f.bigint;
86
- case "symbol":
87
- return f.symbol;
88
- case "object":
89
- return Array.isArray(n) ? f.array : n === null ? f.null : n.then && typeof n.then == "function" && n.catch && typeof n.catch == "function" ? f.promise : typeof Map < "u" && n instanceof Map ? f.map : typeof Set < "u" && n instanceof Set ? f.set : typeof Date < "u" && n instanceof Date ? f.date : f.object;
90
- default:
91
- return f.unknown;
92
- }
93
- }, d = v.arrayToEnum([
94
- "invalid_type",
95
- "invalid_literal",
96
- "custom",
97
- "invalid_union",
98
- "invalid_union_discriminator",
99
- "invalid_enum_value",
100
- "unrecognized_keys",
101
- "invalid_arguments",
102
- "invalid_return_type",
103
- "invalid_date",
104
- "invalid_string",
105
- "too_small",
106
- "too_big",
107
- "invalid_intersection_types",
108
- "not_multiple_of",
109
- "not_finite"
110
- ]);
111
- class D extends Error {
112
- get errors() {
113
- return this.issues;
114
- }
115
- constructor(e) {
116
- super(), this.issues = [], this.addIssue = (r) => {
117
- this.issues = [...this.issues, r];
118
- }, this.addIssues = (r = []) => {
119
- this.issues = [...this.issues, ...r];
120
- };
121
- const t = new.target.prototype;
122
- Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
123
- }
124
- format(e) {
125
- const t = e || function(a) {
126
- return a.message;
127
- }, r = { _errors: [] }, s = (a) => {
128
- for (const i of a.issues)
129
- if (i.code === "invalid_union")
130
- i.unionErrors.map(s);
131
- else if (i.code === "invalid_return_type")
132
- s(i.returnTypeError);
133
- else if (i.code === "invalid_arguments")
134
- s(i.argumentsError);
135
- else if (i.path.length === 0)
136
- r._errors.push(t(i));
137
- else {
138
- let o = r, c = 0;
139
- for (; c < i.path.length; ) {
140
- const l = i.path[c];
141
- c === i.path.length - 1 ? (o[l] = o[l] || { _errors: [] }, o[l]._errors.push(t(i))) : o[l] = o[l] || { _errors: [] }, o = o[l], c++;
142
- }
143
- }
144
- };
145
- return s(this), r;
146
- }
147
- static assert(e) {
148
- if (!(e instanceof D))
149
- throw new Error(`Not a ZodError: ${e}`);
150
- }
151
- toString() {
152
- return this.message;
153
- }
154
- get message() {
155
- return JSON.stringify(this.issues, v.jsonStringifyReplacer, 2);
156
- }
157
- get isEmpty() {
158
- return this.issues.length === 0;
159
- }
160
- flatten(e = (t) => t.message) {
161
- const t = {}, r = [];
162
- for (const s of this.issues)
163
- if (s.path.length > 0) {
164
- const a = s.path[0];
165
- t[a] = t[a] || [], t[a].push(e(s));
166
- } else
167
- r.push(e(s));
168
- return { formErrors: r, fieldErrors: t };
169
- }
170
- get formErrors() {
171
- return this.flatten();
172
- }
173
- }
174
- D.create = (n) => new D(n);
175
- const me = (n, e) => {
176
- let t;
177
- switch (n.code) {
178
- case d.invalid_type:
179
- n.received === f.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
180
- break;
181
- case d.invalid_literal:
182
- t = `Invalid literal value, expected ${JSON.stringify(n.expected, v.jsonStringifyReplacer)}`;
183
- break;
184
- case d.unrecognized_keys:
185
- t = `Unrecognized key(s) in object: ${v.joinValues(n.keys, ", ")}`;
186
- break;
187
- case d.invalid_union:
188
- t = "Invalid input";
189
- break;
190
- case d.invalid_union_discriminator:
191
- t = `Invalid discriminator value. Expected ${v.joinValues(n.options)}`;
192
- break;
193
- case d.invalid_enum_value:
194
- t = `Invalid enum value. Expected ${v.joinValues(n.options)}, received '${n.received}'`;
195
- break;
196
- case d.invalid_arguments:
197
- t = "Invalid function arguments";
198
- break;
199
- case d.invalid_return_type:
200
- t = "Invalid function return type";
201
- break;
202
- case d.invalid_date:
203
- t = "Invalid date";
204
- break;
205
- case d.invalid_string:
206
- typeof n.validation == "object" ? "includes" in n.validation ? (t = `Invalid input: must include "${n.validation.includes}"`, typeof n.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${n.validation.position}`)) : "startsWith" in n.validation ? t = `Invalid input: must start with "${n.validation.startsWith}"` : "endsWith" in n.validation ? t = `Invalid input: must end with "${n.validation.endsWith}"` : v.assertNever(n.validation) : n.validation !== "regex" ? t = `Invalid ${n.validation}` : t = "Invalid";
207
- break;
208
- case d.too_small:
209
- n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "more than"} ${n.minimum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "over"} ${n.minimum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "bigint" ? t = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(n.minimum))}` : t = "Invalid input";
210
- break;
211
- case d.too_big:
212
- n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "less than"} ${n.maximum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "under"} ${n.maximum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "bigint" ? t = `BigInt must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly" : n.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(n.maximum))}` : t = "Invalid input";
213
- break;
214
- case d.custom:
215
- t = "Invalid input";
216
- break;
217
- case d.invalid_intersection_types:
218
- t = "Intersection results could not be merged";
219
- break;
220
- case d.not_multiple_of:
221
- t = `Number must be a multiple of ${n.multipleOf}`;
222
- break;
223
- case d.not_finite:
224
- t = "Number must be finite";
225
- break;
226
- default:
227
- t = e.defaultError, v.assertNever(n);
228
- }
229
- return { message: t };
230
- };
231
- let mt = me;
232
- function yt() {
233
- return mt;
234
- }
235
- const gt = (n) => {
236
- const { data: e, path: t, errorMaps: r, issueData: s } = n, a = [...t, ...s.path || []], i = {
237
- ...s,
238
- path: a
239
- };
240
- if (s.message !== void 0)
241
- return {
242
- ...s,
243
- path: a,
244
- message: s.message
245
- };
246
- let o = "";
247
- const c = r.filter((l) => !!l).slice().reverse();
248
- for (const l of c)
249
- o = l(i, { data: e, defaultError: o }).message;
250
- return {
251
- ...s,
252
- path: a,
253
- message: o
254
- };
255
- };
256
- function u(n, e) {
257
- const t = yt(), r = gt({
258
- issueData: e,
259
- data: n.data,
260
- path: n.path,
261
- errorMaps: [
262
- n.common.contextualErrorMap,
263
- // contextual error map is first priority
264
- n.schemaErrorMap,
265
- // then schema-bound map if available
266
- t,
267
- // then global override map
268
- t === me ? void 0 : me
269
- // then global default map
270
- ].filter((s) => !!s)
271
- });
272
- n.common.issues.push(r);
273
- }
274
- class S {
275
- constructor() {
276
- this.value = "valid";
277
- }
278
- dirty() {
279
- this.value === "valid" && (this.value = "dirty");
280
- }
281
- abort() {
282
- this.value !== "aborted" && (this.value = "aborted");
283
- }
284
- static mergeArray(e, t) {
285
- const r = [];
286
- for (const s of t) {
287
- if (s.status === "aborted")
288
- return y;
289
- s.status === "dirty" && e.dirty(), r.push(s.value);
290
- }
291
- return { status: e.value, value: r };
292
- }
293
- static async mergeObjectAsync(e, t) {
294
- const r = [];
295
- for (const s of t) {
296
- const a = await s.key, i = await s.value;
297
- r.push({
298
- key: a,
299
- value: i
300
- });
301
- }
302
- return S.mergeObjectSync(e, r);
303
- }
304
- static mergeObjectSync(e, t) {
305
- const r = {};
306
- for (const s of t) {
307
- const { key: a, value: i } = s;
308
- if (a.status === "aborted" || i.status === "aborted")
309
- return y;
310
- a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || s.alwaysSet) && (r[a.value] = i.value);
311
- }
312
- return { status: e.value, value: r };
313
- }
314
- }
315
- const y = Object.freeze({
316
- status: "aborted"
317
- }), J = (n) => ({ status: "dirty", value: n }), T = (n) => ({ status: "valid", value: n }), Ie = (n) => n.status === "aborted", De = (n) => n.status === "dirty", F = (n) => n.status === "valid", ne = (n) => typeof Promise < "u" && n instanceof Promise;
318
- var p;
319
- (function(n) {
320
- n.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, n.toString = (e) => typeof e == "string" ? e : e?.message;
321
- })(p || (p = {}));
322
- class $ {
323
- constructor(e, t, r, s) {
324
- this._cachedPath = [], this.parent = e, this.data = t, this._path = r, this._key = s;
325
- }
326
- get path() {
327
- return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
328
- }
329
- }
330
- const je = (n, e) => {
331
- if (F(e))
332
- return { success: !0, data: e.value };
333
- if (!n.common.issues.length)
334
- throw new Error("Validation failed but no issues detected.");
335
- return {
336
- success: !1,
337
- get error() {
338
- if (this._error)
339
- return this._error;
340
- const t = new D(n.common.issues);
341
- return this._error = t, this._error;
342
- }
343
- };
344
- };
345
- function g(n) {
346
- if (!n)
347
- return {};
348
- const { errorMap: e, invalid_type_error: t, required_error: r, description: s } = n;
349
- if (e && (t || r))
350
- throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
351
- return e ? { errorMap: e, description: s } : { errorMap: (i, o) => {
352
- const { message: c } = n;
353
- return i.code === "invalid_enum_value" ? { message: c ?? o.defaultError } : typeof o.data > "u" ? { message: c ?? r ?? o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: c ?? t ?? o.defaultError };
354
- }, description: s };
355
- }
356
- class _ {
357
- get description() {
358
- return this._def.description;
359
- }
360
- _getType(e) {
361
- return j(e.data);
362
- }
363
- _getOrReturnCtx(e, t) {
364
- return t || {
365
- common: e.parent.common,
366
- data: e.data,
367
- parsedType: j(e.data),
368
- schemaErrorMap: this._def.errorMap,
369
- path: e.path,
370
- parent: e.parent
371
- };
372
- }
373
- _processInputParams(e) {
374
- return {
375
- status: new S(),
376
- ctx: {
377
- common: e.parent.common,
378
- data: e.data,
379
- parsedType: j(e.data),
380
- schemaErrorMap: this._def.errorMap,
381
- path: e.path,
382
- parent: e.parent
383
- }
384
- };
385
- }
386
- _parseSync(e) {
387
- const t = this._parse(e);
388
- if (ne(t))
389
- throw new Error("Synchronous parse encountered promise.");
390
- return t;
391
- }
392
- _parseAsync(e) {
393
- const t = this._parse(e);
394
- return Promise.resolve(t);
395
- }
396
- parse(e, t) {
397
- const r = this.safeParse(e, t);
398
- if (r.success)
399
- return r.data;
400
- throw r.error;
401
- }
402
- safeParse(e, t) {
403
- const r = {
404
- common: {
405
- issues: [],
406
- async: t?.async ?? !1,
407
- contextualErrorMap: t?.errorMap
408
- },
409
- path: t?.path || [],
410
- schemaErrorMap: this._def.errorMap,
411
- parent: null,
412
- data: e,
413
- parsedType: j(e)
414
- }, s = this._parseSync({ data: e, path: r.path, parent: r });
415
- return je(r, s);
416
- }
417
- "~validate"(e) {
418
- const t = {
419
- common: {
420
- issues: [],
421
- async: !!this["~standard"].async
422
- },
423
- path: [],
424
- schemaErrorMap: this._def.errorMap,
425
- parent: null,
426
- data: e,
427
- parsedType: j(e)
428
- };
429
- if (!this["~standard"].async)
430
- try {
431
- const r = this._parseSync({ data: e, path: [], parent: t });
432
- return F(r) ? {
433
- value: r.value
434
- } : {
435
- issues: t.common.issues
436
- };
437
- } catch (r) {
438
- r?.message?.toLowerCase()?.includes("encountered") && (this["~standard"].async = !0), t.common = {
439
- issues: [],
440
- async: !0
441
- };
442
- }
443
- return this._parseAsync({ data: e, path: [], parent: t }).then((r) => F(r) ? {
444
- value: r.value
445
- } : {
446
- issues: t.common.issues
447
- });
448
- }
449
- async parseAsync(e, t) {
450
- const r = await this.safeParseAsync(e, t);
451
- if (r.success)
452
- return r.data;
453
- throw r.error;
454
- }
455
- async safeParseAsync(e, t) {
456
- const r = {
457
- common: {
458
- issues: [],
459
- contextualErrorMap: t?.errorMap,
460
- async: !0
461
- },
462
- path: t?.path || [],
463
- schemaErrorMap: this._def.errorMap,
464
- parent: null,
465
- data: e,
466
- parsedType: j(e)
467
- }, s = this._parse({ data: e, path: r.path, parent: r }), a = await (ne(s) ? s : Promise.resolve(s));
468
- return je(r, a);
469
- }
470
- refine(e, t) {
471
- const r = (s) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(s) : t;
472
- return this._refinement((s, a) => {
473
- const i = e(s), o = () => a.addIssue({
474
- code: d.custom,
475
- ...r(s)
476
- });
477
- return typeof Promise < "u" && i instanceof Promise ? i.then((c) => c ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
478
- });
479
- }
480
- refinement(e, t) {
481
- return this._refinement((r, s) => e(r) ? !0 : (s.addIssue(typeof t == "function" ? t(r, s) : t), !1));
482
- }
483
- _refinement(e) {
484
- return new B({
485
- schema: this,
486
- typeName: m.ZodEffects,
487
- effect: { type: "refinement", refinement: e }
488
- });
489
- }
490
- superRefine(e) {
491
- return this._refinement(e);
492
- }
493
- constructor(e) {
494
- this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
495
- version: 1,
496
- vendor: "zod",
497
- validate: (t) => this["~validate"](t)
498
- };
499
- }
500
- optional() {
501
- return E.create(this, this._def);
502
- }
503
- nullable() {
504
- return z.create(this, this._def);
505
- }
506
- nullish() {
507
- return this.nullable().optional();
508
- }
509
- array() {
510
- return O.create(this);
511
- }
512
- promise() {
513
- return oe.create(this, this._def);
514
- }
515
- or(e) {
516
- return se.create([this, e], this._def);
517
- }
518
- and(e) {
519
- return ae.create(this, e, this._def);
520
- }
521
- transform(e) {
522
- return new B({
523
- ...g(this._def),
524
- schema: this,
525
- typeName: m.ZodEffects,
526
- effect: { type: "transform", transform: e }
527
- });
528
- }
529
- default(e) {
530
- const t = typeof e == "function" ? e : () => e;
531
- return new ve({
532
- ...g(this._def),
533
- innerType: this,
534
- defaultValue: t,
535
- typeName: m.ZodDefault
536
- });
537
- }
538
- brand() {
539
- return new Vt({
540
- typeName: m.ZodBranded,
541
- type: this,
542
- ...g(this._def)
543
- });
544
- }
545
- catch(e) {
546
- const t = typeof e == "function" ? e : () => e;
547
- return new ke({
548
- ...g(this._def),
549
- innerType: this,
550
- catchValue: t,
551
- typeName: m.ZodCatch
552
- });
553
- }
554
- describe(e) {
555
- const t = this.constructor;
556
- return new t({
557
- ...this._def,
558
- description: e
559
- });
560
- }
561
- pipe(e) {
562
- return Se.create(this, e);
563
- }
564
- readonly() {
565
- return xe.create(this);
566
- }
567
- isOptional() {
568
- return this.safeParse(void 0).success;
569
- }
570
- isNullable() {
571
- return this.safeParse(null).success;
572
- }
573
- }
574
- const _t = /^c[^\s-]{8,}$/i, vt = /^[0-9a-z]+$/, kt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, xt = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, bt = /^[a-z0-9_-]{21}$/i, wt = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, St = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, Tt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, At = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
575
- let he;
576
- const Ct = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Nt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, Ot = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, $t = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Rt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, It = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Ue = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", Dt = new RegExp(`^${Ue}$`);
577
- function Je(n) {
578
- let e = "[0-5]\\d";
579
- n.precision ? e = `${e}\\.\\d{${n.precision}}` : n.precision == null && (e = `${e}(\\.\\d+)?`);
580
- const t = n.precision ? "+" : "?";
581
- return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`;
582
- }
583
- function jt(n) {
584
- return new RegExp(`^${Je(n)}$`);
585
- }
586
- function Et(n) {
587
- let e = `${Ue}T${Je(n)}`;
588
- const t = [];
589
- return t.push(n.local ? "Z?" : "Z"), n.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
590
- }
591
- function Zt(n, e) {
592
- return !!((e === "v4" || !e) && Ct.test(n) || (e === "v6" || !e) && Ot.test(n));
593
- }
594
- function Mt(n, e) {
595
- if (!wt.test(n))
596
- return !1;
597
- try {
598
- const [t] = n.split(".");
599
- if (!t)
600
- return !1;
601
- const r = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), s = JSON.parse(atob(r));
602
- return !(typeof s != "object" || s === null || "typ" in s && s?.typ !== "JWT" || !s.alg || e && s.alg !== e);
603
- } catch {
604
- return !1;
605
- }
606
- }
607
- function Lt(n, e) {
608
- return !!((e === "v4" || !e) && Nt.test(n) || (e === "v6" || !e) && $t.test(n));
609
- }
610
- class I extends _ {
611
- _parse(e) {
612
- if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
613
- const a = this._getOrReturnCtx(e);
614
- return u(a, {
615
- code: d.invalid_type,
616
- expected: f.string,
617
- received: a.parsedType
618
- }), y;
619
- }
620
- const r = new S();
621
- let s;
622
- for (const a of this._def.checks)
623
- if (a.kind === "min")
624
- e.data.length < a.value && (s = this._getOrReturnCtx(e, s), u(s, {
625
- code: d.too_small,
626
- minimum: a.value,
627
- type: "string",
628
- inclusive: !0,
629
- exact: !1,
630
- message: a.message
631
- }), r.dirty());
632
- else if (a.kind === "max")
633
- e.data.length > a.value && (s = this._getOrReturnCtx(e, s), u(s, {
634
- code: d.too_big,
635
- maximum: a.value,
636
- type: "string",
637
- inclusive: !0,
638
- exact: !1,
639
- message: a.message
640
- }), r.dirty());
641
- else if (a.kind === "length") {
642
- const i = e.data.length > a.value, o = e.data.length < a.value;
643
- (i || o) && (s = this._getOrReturnCtx(e, s), i ? u(s, {
644
- code: d.too_big,
645
- maximum: a.value,
646
- type: "string",
647
- inclusive: !0,
648
- exact: !0,
649
- message: a.message
650
- }) : o && u(s, {
651
- code: d.too_small,
652
- minimum: a.value,
653
- type: "string",
654
- inclusive: !0,
655
- exact: !0,
656
- message: a.message
657
- }), r.dirty());
658
- } else if (a.kind === "email")
659
- Tt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
660
- validation: "email",
661
- code: d.invalid_string,
662
- message: a.message
663
- }), r.dirty());
664
- else if (a.kind === "emoji")
665
- he || (he = new RegExp(At, "u")), he.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
666
- validation: "emoji",
667
- code: d.invalid_string,
668
- message: a.message
669
- }), r.dirty());
670
- else if (a.kind === "uuid")
671
- xt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
672
- validation: "uuid",
673
- code: d.invalid_string,
674
- message: a.message
675
- }), r.dirty());
676
- else if (a.kind === "nanoid")
677
- bt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
678
- validation: "nanoid",
679
- code: d.invalid_string,
680
- message: a.message
681
- }), r.dirty());
682
- else if (a.kind === "cuid")
683
- _t.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
684
- validation: "cuid",
685
- code: d.invalid_string,
686
- message: a.message
687
- }), r.dirty());
688
- else if (a.kind === "cuid2")
689
- vt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
690
- validation: "cuid2",
691
- code: d.invalid_string,
692
- message: a.message
693
- }), r.dirty());
694
- else if (a.kind === "ulid")
695
- kt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
696
- validation: "ulid",
697
- code: d.invalid_string,
698
- message: a.message
699
- }), r.dirty());
700
- else if (a.kind === "url")
701
- try {
702
- new URL(e.data);
703
- } catch {
704
- s = this._getOrReturnCtx(e, s), u(s, {
705
- validation: "url",
706
- code: d.invalid_string,
707
- message: a.message
708
- }), r.dirty();
709
- }
710
- else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
711
- validation: "regex",
712
- code: d.invalid_string,
713
- message: a.message
714
- }), r.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (s = this._getOrReturnCtx(e, s), u(s, {
715
- code: d.invalid_string,
716
- validation: { includes: a.value, position: a.position },
717
- message: a.message
718
- }), r.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (s = this._getOrReturnCtx(e, s), u(s, {
719
- code: d.invalid_string,
720
- validation: { startsWith: a.value },
721
- message: a.message
722
- }), r.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (s = this._getOrReturnCtx(e, s), u(s, {
723
- code: d.invalid_string,
724
- validation: { endsWith: a.value },
725
- message: a.message
726
- }), r.dirty()) : a.kind === "datetime" ? Et(a).test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
727
- code: d.invalid_string,
728
- validation: "datetime",
729
- message: a.message
730
- }), r.dirty()) : a.kind === "date" ? Dt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
731
- code: d.invalid_string,
732
- validation: "date",
733
- message: a.message
734
- }), r.dirty()) : a.kind === "time" ? jt(a).test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
735
- code: d.invalid_string,
736
- validation: "time",
737
- message: a.message
738
- }), r.dirty()) : a.kind === "duration" ? St.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
739
- validation: "duration",
740
- code: d.invalid_string,
741
- message: a.message
742
- }), r.dirty()) : a.kind === "ip" ? Zt(e.data, a.version) || (s = this._getOrReturnCtx(e, s), u(s, {
743
- validation: "ip",
744
- code: d.invalid_string,
745
- message: a.message
746
- }), r.dirty()) : a.kind === "jwt" ? Mt(e.data, a.alg) || (s = this._getOrReturnCtx(e, s), u(s, {
747
- validation: "jwt",
748
- code: d.invalid_string,
749
- message: a.message
750
- }), r.dirty()) : a.kind === "cidr" ? Lt(e.data, a.version) || (s = this._getOrReturnCtx(e, s), u(s, {
751
- validation: "cidr",
752
- code: d.invalid_string,
753
- message: a.message
754
- }), r.dirty()) : a.kind === "base64" ? Rt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
755
- validation: "base64",
756
- code: d.invalid_string,
757
- message: a.message
758
- }), r.dirty()) : a.kind === "base64url" ? It.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
759
- validation: "base64url",
760
- code: d.invalid_string,
761
- message: a.message
762
- }), r.dirty()) : v.assertNever(a);
763
- return { status: r.value, value: e.data };
764
- }
765
- _regex(e, t, r) {
766
- return this.refinement((s) => e.test(s), {
767
- validation: t,
768
- code: d.invalid_string,
769
- ...p.errToObj(r)
770
- });
771
- }
772
- _addCheck(e) {
773
- return new I({
774
- ...this._def,
775
- checks: [...this._def.checks, e]
776
- });
777
- }
778
- email(e) {
779
- return this._addCheck({ kind: "email", ...p.errToObj(e) });
780
- }
781
- url(e) {
782
- return this._addCheck({ kind: "url", ...p.errToObj(e) });
783
- }
784
- emoji(e) {
785
- return this._addCheck({ kind: "emoji", ...p.errToObj(e) });
786
- }
787
- uuid(e) {
788
- return this._addCheck({ kind: "uuid", ...p.errToObj(e) });
789
- }
790
- nanoid(e) {
791
- return this._addCheck({ kind: "nanoid", ...p.errToObj(e) });
792
- }
793
- cuid(e) {
794
- return this._addCheck({ kind: "cuid", ...p.errToObj(e) });
795
- }
796
- cuid2(e) {
797
- return this._addCheck({ kind: "cuid2", ...p.errToObj(e) });
798
- }
799
- ulid(e) {
800
- return this._addCheck({ kind: "ulid", ...p.errToObj(e) });
801
- }
802
- base64(e) {
803
- return this._addCheck({ kind: "base64", ...p.errToObj(e) });
804
- }
805
- base64url(e) {
806
- return this._addCheck({
807
- kind: "base64url",
808
- ...p.errToObj(e)
809
- });
810
- }
811
- jwt(e) {
812
- return this._addCheck({ kind: "jwt", ...p.errToObj(e) });
813
- }
814
- ip(e) {
815
- return this._addCheck({ kind: "ip", ...p.errToObj(e) });
816
- }
817
- cidr(e) {
818
- return this._addCheck({ kind: "cidr", ...p.errToObj(e) });
819
- }
820
- datetime(e) {
821
- return typeof e == "string" ? this._addCheck({
822
- kind: "datetime",
823
- precision: null,
824
- offset: !1,
825
- local: !1,
826
- message: e
827
- }) : this._addCheck({
828
- kind: "datetime",
829
- precision: typeof e?.precision > "u" ? null : e?.precision,
830
- offset: e?.offset ?? !1,
831
- local: e?.local ?? !1,
832
- ...p.errToObj(e?.message)
833
- });
834
- }
835
- date(e) {
836
- return this._addCheck({ kind: "date", message: e });
837
- }
838
- time(e) {
839
- return typeof e == "string" ? this._addCheck({
840
- kind: "time",
841
- precision: null,
842
- message: e
843
- }) : this._addCheck({
844
- kind: "time",
845
- precision: typeof e?.precision > "u" ? null : e?.precision,
846
- ...p.errToObj(e?.message)
847
- });
848
- }
849
- duration(e) {
850
- return this._addCheck({ kind: "duration", ...p.errToObj(e) });
851
- }
852
- regex(e, t) {
853
- return this._addCheck({
854
- kind: "regex",
855
- regex: e,
856
- ...p.errToObj(t)
857
- });
858
- }
859
- includes(e, t) {
860
- return this._addCheck({
861
- kind: "includes",
862
- value: e,
863
- position: t?.position,
864
- ...p.errToObj(t?.message)
865
- });
866
- }
867
- startsWith(e, t) {
868
- return this._addCheck({
869
- kind: "startsWith",
870
- value: e,
871
- ...p.errToObj(t)
872
- });
873
- }
874
- endsWith(e, t) {
875
- return this._addCheck({
876
- kind: "endsWith",
877
- value: e,
878
- ...p.errToObj(t)
879
- });
880
- }
881
- min(e, t) {
882
- return this._addCheck({
883
- kind: "min",
884
- value: e,
885
- ...p.errToObj(t)
886
- });
887
- }
888
- max(e, t) {
889
- return this._addCheck({
890
- kind: "max",
891
- value: e,
892
- ...p.errToObj(t)
893
- });
894
- }
895
- length(e, t) {
896
- return this._addCheck({
897
- kind: "length",
898
- value: e,
899
- ...p.errToObj(t)
900
- });
901
- }
902
- /**
903
- * Equivalent to `.min(1)`
904
- */
905
- nonempty(e) {
906
- return this.min(1, p.errToObj(e));
907
- }
908
- trim() {
909
- return new I({
910
- ...this._def,
911
- checks: [...this._def.checks, { kind: "trim" }]
912
- });
913
- }
914
- toLowerCase() {
915
- return new I({
916
- ...this._def,
917
- checks: [...this._def.checks, { kind: "toLowerCase" }]
918
- });
919
- }
920
- toUpperCase() {
921
- return new I({
922
- ...this._def,
923
- checks: [...this._def.checks, { kind: "toUpperCase" }]
924
- });
925
- }
926
- get isDatetime() {
927
- return !!this._def.checks.find((e) => e.kind === "datetime");
928
- }
929
- get isDate() {
930
- return !!this._def.checks.find((e) => e.kind === "date");
931
- }
932
- get isTime() {
933
- return !!this._def.checks.find((e) => e.kind === "time");
934
- }
935
- get isDuration() {
936
- return !!this._def.checks.find((e) => e.kind === "duration");
937
- }
938
- get isEmail() {
939
- return !!this._def.checks.find((e) => e.kind === "email");
940
- }
941
- get isURL() {
942
- return !!this._def.checks.find((e) => e.kind === "url");
943
- }
944
- get isEmoji() {
945
- return !!this._def.checks.find((e) => e.kind === "emoji");
946
- }
947
- get isUUID() {
948
- return !!this._def.checks.find((e) => e.kind === "uuid");
949
- }
950
- get isNANOID() {
951
- return !!this._def.checks.find((e) => e.kind === "nanoid");
952
- }
953
- get isCUID() {
954
- return !!this._def.checks.find((e) => e.kind === "cuid");
955
- }
956
- get isCUID2() {
957
- return !!this._def.checks.find((e) => e.kind === "cuid2");
958
- }
959
- get isULID() {
960
- return !!this._def.checks.find((e) => e.kind === "ulid");
961
- }
962
- get isIP() {
963
- return !!this._def.checks.find((e) => e.kind === "ip");
964
- }
965
- get isCIDR() {
966
- return !!this._def.checks.find((e) => e.kind === "cidr");
967
- }
968
- get isBase64() {
969
- return !!this._def.checks.find((e) => e.kind === "base64");
970
- }
971
- get isBase64url() {
972
- return !!this._def.checks.find((e) => e.kind === "base64url");
973
- }
974
- get minLength() {
975
- let e = null;
976
- for (const t of this._def.checks)
977
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
978
- return e;
979
- }
980
- get maxLength() {
981
- let e = null;
982
- for (const t of this._def.checks)
983
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
984
- return e;
985
- }
986
- }
987
- I.create = (n) => new I({
988
- checks: [],
989
- typeName: m.ZodString,
990
- coerce: n?.coerce ?? !1,
991
- ...g(n)
992
- });
993
- function Pt(n, e) {
994
- const t = (n.toString().split(".")[1] || "").length, r = (e.toString().split(".")[1] || "").length, s = t > r ? t : r, a = Number.parseInt(n.toFixed(s).replace(".", "")), i = Number.parseInt(e.toFixed(s).replace(".", ""));
995
- return a % i / 10 ** s;
996
- }
997
- class G extends _ {
998
- constructor() {
999
- super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
1000
- }
1001
- _parse(e) {
1002
- if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== f.number) {
1003
- const a = this._getOrReturnCtx(e);
1004
- return u(a, {
1005
- code: d.invalid_type,
1006
- expected: f.number,
1007
- received: a.parsedType
1008
- }), y;
1009
- }
1010
- let r;
1011
- const s = new S();
1012
- for (const a of this._def.checks)
1013
- a.kind === "int" ? v.isInteger(e.data) || (r = this._getOrReturnCtx(e, r), u(r, {
1014
- code: d.invalid_type,
1015
- expected: "integer",
1016
- received: "float",
1017
- message: a.message
1018
- }), s.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), u(r, {
1019
- code: d.too_small,
1020
- minimum: a.value,
1021
- type: "number",
1022
- inclusive: a.inclusive,
1023
- exact: !1,
1024
- message: a.message
1025
- }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), u(r, {
1026
- code: d.too_big,
1027
- maximum: a.value,
1028
- type: "number",
1029
- inclusive: a.inclusive,
1030
- exact: !1,
1031
- message: a.message
1032
- }), s.dirty()) : a.kind === "multipleOf" ? Pt(e.data, a.value) !== 0 && (r = this._getOrReturnCtx(e, r), u(r, {
1033
- code: d.not_multiple_of,
1034
- multipleOf: a.value,
1035
- message: a.message
1036
- }), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (r = this._getOrReturnCtx(e, r), u(r, {
1037
- code: d.not_finite,
1038
- message: a.message
1039
- }), s.dirty()) : v.assertNever(a);
1040
- return { status: s.value, value: e.data };
1041
- }
1042
- gte(e, t) {
1043
- return this.setLimit("min", e, !0, p.toString(t));
1044
- }
1045
- gt(e, t) {
1046
- return this.setLimit("min", e, !1, p.toString(t));
1047
- }
1048
- lte(e, t) {
1049
- return this.setLimit("max", e, !0, p.toString(t));
1050
- }
1051
- lt(e, t) {
1052
- return this.setLimit("max", e, !1, p.toString(t));
1053
- }
1054
- setLimit(e, t, r, s) {
1055
- return new G({
1056
- ...this._def,
1057
- checks: [
1058
- ...this._def.checks,
1059
- {
1060
- kind: e,
1061
- value: t,
1062
- inclusive: r,
1063
- message: p.toString(s)
1064
- }
1065
- ]
1066
- });
1067
- }
1068
- _addCheck(e) {
1069
- return new G({
1070
- ...this._def,
1071
- checks: [...this._def.checks, e]
1072
- });
1073
- }
1074
- int(e) {
1075
- return this._addCheck({
1076
- kind: "int",
1077
- message: p.toString(e)
1078
- });
1079
- }
1080
- positive(e) {
1081
- return this._addCheck({
1082
- kind: "min",
1083
- value: 0,
1084
- inclusive: !1,
1085
- message: p.toString(e)
1086
- });
1087
- }
1088
- negative(e) {
1089
- return this._addCheck({
1090
- kind: "max",
1091
- value: 0,
1092
- inclusive: !1,
1093
- message: p.toString(e)
1094
- });
1095
- }
1096
- nonpositive(e) {
1097
- return this._addCheck({
1098
- kind: "max",
1099
- value: 0,
1100
- inclusive: !0,
1101
- message: p.toString(e)
1102
- });
1103
- }
1104
- nonnegative(e) {
1105
- return this._addCheck({
1106
- kind: "min",
1107
- value: 0,
1108
- inclusive: !0,
1109
- message: p.toString(e)
1110
- });
1111
- }
1112
- multipleOf(e, t) {
1113
- return this._addCheck({
1114
- kind: "multipleOf",
1115
- value: e,
1116
- message: p.toString(t)
1117
- });
1118
- }
1119
- finite(e) {
1120
- return this._addCheck({
1121
- kind: "finite",
1122
- message: p.toString(e)
1123
- });
1124
- }
1125
- safe(e) {
1126
- return this._addCheck({
1127
- kind: "min",
1128
- inclusive: !0,
1129
- value: Number.MIN_SAFE_INTEGER,
1130
- message: p.toString(e)
1131
- })._addCheck({
1132
- kind: "max",
1133
- inclusive: !0,
1134
- value: Number.MAX_SAFE_INTEGER,
1135
- message: p.toString(e)
1136
- });
1137
- }
1138
- get minValue() {
1139
- let e = null;
1140
- for (const t of this._def.checks)
1141
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1142
- return e;
1143
- }
1144
- get maxValue() {
1145
- let e = null;
1146
- for (const t of this._def.checks)
1147
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1148
- return e;
1149
- }
1150
- get isInt() {
1151
- return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && v.isInteger(e.value));
1152
- }
1153
- get isFinite() {
1154
- let e = null, t = null;
1155
- for (const r of this._def.checks) {
1156
- if (r.kind === "finite" || r.kind === "int" || r.kind === "multipleOf")
1157
- return !0;
1158
- r.kind === "min" ? (t === null || r.value > t) && (t = r.value) : r.kind === "max" && (e === null || r.value < e) && (e = r.value);
1159
- }
1160
- return Number.isFinite(t) && Number.isFinite(e);
1161
- }
1162
- }
1163
- G.create = (n) => new G({
1164
- checks: [],
1165
- typeName: m.ZodNumber,
1166
- coerce: n?.coerce || !1,
1167
- ...g(n)
1168
- });
1169
- class H extends _ {
1170
- constructor() {
1171
- super(...arguments), this.min = this.gte, this.max = this.lte;
1172
- }
1173
- _parse(e) {
1174
- if (this._def.coerce)
1175
- try {
1176
- e.data = BigInt(e.data);
1177
- } catch {
1178
- return this._getInvalidInput(e);
1179
- }
1180
- if (this._getType(e) !== f.bigint)
1181
- return this._getInvalidInput(e);
1182
- let r;
1183
- const s = new S();
1184
- for (const a of this._def.checks)
1185
- a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), u(r, {
1186
- code: d.too_small,
1187
- type: "bigint",
1188
- minimum: a.value,
1189
- inclusive: a.inclusive,
1190
- message: a.message
1191
- }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), u(r, {
1192
- code: d.too_big,
1193
- type: "bigint",
1194
- maximum: a.value,
1195
- inclusive: a.inclusive,
1196
- message: a.message
1197
- }), s.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (r = this._getOrReturnCtx(e, r), u(r, {
1198
- code: d.not_multiple_of,
1199
- multipleOf: a.value,
1200
- message: a.message
1201
- }), s.dirty()) : v.assertNever(a);
1202
- return { status: s.value, value: e.data };
1203
- }
1204
- _getInvalidInput(e) {
1205
- const t = this._getOrReturnCtx(e);
1206
- return u(t, {
1207
- code: d.invalid_type,
1208
- expected: f.bigint,
1209
- received: t.parsedType
1210
- }), y;
1211
- }
1212
- gte(e, t) {
1213
- return this.setLimit("min", e, !0, p.toString(t));
1214
- }
1215
- gt(e, t) {
1216
- return this.setLimit("min", e, !1, p.toString(t));
1217
- }
1218
- lte(e, t) {
1219
- return this.setLimit("max", e, !0, p.toString(t));
1220
- }
1221
- lt(e, t) {
1222
- return this.setLimit("max", e, !1, p.toString(t));
1223
- }
1224
- setLimit(e, t, r, s) {
1225
- return new H({
1226
- ...this._def,
1227
- checks: [
1228
- ...this._def.checks,
1229
- {
1230
- kind: e,
1231
- value: t,
1232
- inclusive: r,
1233
- message: p.toString(s)
1234
- }
1235
- ]
1236
- });
1237
- }
1238
- _addCheck(e) {
1239
- return new H({
1240
- ...this._def,
1241
- checks: [...this._def.checks, e]
1242
- });
1243
- }
1244
- positive(e) {
1245
- return this._addCheck({
1246
- kind: "min",
1247
- value: BigInt(0),
1248
- inclusive: !1,
1249
- message: p.toString(e)
1250
- });
1251
- }
1252
- negative(e) {
1253
- return this._addCheck({
1254
- kind: "max",
1255
- value: BigInt(0),
1256
- inclusive: !1,
1257
- message: p.toString(e)
1258
- });
1259
- }
1260
- nonpositive(e) {
1261
- return this._addCheck({
1262
- kind: "max",
1263
- value: BigInt(0),
1264
- inclusive: !0,
1265
- message: p.toString(e)
1266
- });
1267
- }
1268
- nonnegative(e) {
1269
- return this._addCheck({
1270
- kind: "min",
1271
- value: BigInt(0),
1272
- inclusive: !0,
1273
- message: p.toString(e)
1274
- });
1275
- }
1276
- multipleOf(e, t) {
1277
- return this._addCheck({
1278
- kind: "multipleOf",
1279
- value: e,
1280
- message: p.toString(t)
1281
- });
1282
- }
1283
- get minValue() {
1284
- let e = null;
1285
- for (const t of this._def.checks)
1286
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1287
- return e;
1288
- }
1289
- get maxValue() {
1290
- let e = null;
1291
- for (const t of this._def.checks)
1292
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1293
- return e;
1294
- }
1295
- }
1296
- H.create = (n) => new H({
1297
- checks: [],
1298
- typeName: m.ZodBigInt,
1299
- coerce: n?.coerce ?? !1,
1300
- ...g(n)
1301
- });
1302
- class ye extends _ {
1303
- _parse(e) {
1304
- if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== f.boolean) {
1305
- const r = this._getOrReturnCtx(e);
1306
- return u(r, {
1307
- code: d.invalid_type,
1308
- expected: f.boolean,
1309
- received: r.parsedType
1310
- }), y;
1311
- }
1312
- return T(e.data);
1313
- }
1314
- }
1315
- ye.create = (n) => new ye({
1316
- typeName: m.ZodBoolean,
1317
- coerce: n?.coerce || !1,
1318
- ...g(n)
1319
- });
1320
- class re extends _ {
1321
- _parse(e) {
1322
- if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== f.date) {
1323
- const a = this._getOrReturnCtx(e);
1324
- return u(a, {
1325
- code: d.invalid_type,
1326
- expected: f.date,
1327
- received: a.parsedType
1328
- }), y;
1329
- }
1330
- if (Number.isNaN(e.data.getTime())) {
1331
- const a = this._getOrReturnCtx(e);
1332
- return u(a, {
1333
- code: d.invalid_date
1334
- }), y;
1335
- }
1336
- const r = new S();
1337
- let s;
1338
- for (const a of this._def.checks)
1339
- a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), u(s, {
1340
- code: d.too_small,
1341
- message: a.message,
1342
- inclusive: !0,
1343
- exact: !1,
1344
- minimum: a.value,
1345
- type: "date"
1346
- }), r.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (s = this._getOrReturnCtx(e, s), u(s, {
1347
- code: d.too_big,
1348
- message: a.message,
1349
- inclusive: !0,
1350
- exact: !1,
1351
- maximum: a.value,
1352
- type: "date"
1353
- }), r.dirty()) : v.assertNever(a);
1354
- return {
1355
- status: r.value,
1356
- value: new Date(e.data.getTime())
1357
- };
1358
- }
1359
- _addCheck(e) {
1360
- return new re({
1361
- ...this._def,
1362
- checks: [...this._def.checks, e]
1363
- });
1364
- }
1365
- min(e, t) {
1366
- return this._addCheck({
1367
- kind: "min",
1368
- value: e.getTime(),
1369
- message: p.toString(t)
1370
- });
1371
- }
1372
- max(e, t) {
1373
- return this._addCheck({
1374
- kind: "max",
1375
- value: e.getTime(),
1376
- message: p.toString(t)
1377
- });
1378
- }
1379
- get minDate() {
1380
- let e = null;
1381
- for (const t of this._def.checks)
1382
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1383
- return e != null ? new Date(e) : null;
1384
- }
1385
- get maxDate() {
1386
- let e = null;
1387
- for (const t of this._def.checks)
1388
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1389
- return e != null ? new Date(e) : null;
1390
- }
1391
- }
1392
- re.create = (n) => new re({
1393
- checks: [],
1394
- coerce: n?.coerce || !1,
1395
- typeName: m.ZodDate,
1396
- ...g(n)
1397
- });
1398
- class Ee extends _ {
1399
- _parse(e) {
1400
- if (this._getType(e) !== f.symbol) {
1401
- const r = this._getOrReturnCtx(e);
1402
- return u(r, {
1403
- code: d.invalid_type,
1404
- expected: f.symbol,
1405
- received: r.parsedType
1406
- }), y;
1407
- }
1408
- return T(e.data);
1409
- }
1410
- }
1411
- Ee.create = (n) => new Ee({
1412
- typeName: m.ZodSymbol,
1413
- ...g(n)
1414
- });
1415
- class Ze extends _ {
1416
- _parse(e) {
1417
- if (this._getType(e) !== f.undefined) {
1418
- const r = this._getOrReturnCtx(e);
1419
- return u(r, {
1420
- code: d.invalid_type,
1421
- expected: f.undefined,
1422
- received: r.parsedType
1423
- }), y;
1424
- }
1425
- return T(e.data);
1426
- }
1427
- }
1428
- Ze.create = (n) => new Ze({
1429
- typeName: m.ZodUndefined,
1430
- ...g(n)
1431
- });
1432
- class Me extends _ {
1433
- _parse(e) {
1434
- if (this._getType(e) !== f.null) {
1435
- const r = this._getOrReturnCtx(e);
1436
- return u(r, {
1437
- code: d.invalid_type,
1438
- expected: f.null,
1439
- received: r.parsedType
1440
- }), y;
1441
- }
1442
- return T(e.data);
1443
- }
1444
- }
1445
- Me.create = (n) => new Me({
1446
- typeName: m.ZodNull,
1447
- ...g(n)
1448
- });
1449
- class Le extends _ {
1450
- constructor() {
1451
- super(...arguments), this._any = !0;
1452
- }
1453
- _parse(e) {
1454
- return T(e.data);
1455
- }
1456
- }
1457
- Le.create = (n) => new Le({
1458
- typeName: m.ZodAny,
1459
- ...g(n)
1460
- });
1461
- class ge extends _ {
1462
- constructor() {
1463
- super(...arguments), this._unknown = !0;
1464
- }
1465
- _parse(e) {
1466
- return T(e.data);
1467
- }
1468
- }
1469
- ge.create = (n) => new ge({
1470
- typeName: m.ZodUnknown,
1471
- ...g(n)
1472
- });
1473
- class Z extends _ {
1474
- _parse(e) {
1475
- const t = this._getOrReturnCtx(e);
1476
- return u(t, {
1477
- code: d.invalid_type,
1478
- expected: f.never,
1479
- received: t.parsedType
1480
- }), y;
1481
- }
1482
- }
1483
- Z.create = (n) => new Z({
1484
- typeName: m.ZodNever,
1485
- ...g(n)
1486
- });
1487
- class Pe extends _ {
1488
- _parse(e) {
1489
- if (this._getType(e) !== f.undefined) {
1490
- const r = this._getOrReturnCtx(e);
1491
- return u(r, {
1492
- code: d.invalid_type,
1493
- expected: f.void,
1494
- received: r.parsedType
1495
- }), y;
1496
- }
1497
- return T(e.data);
1498
- }
1499
- }
1500
- Pe.create = (n) => new Pe({
1501
- typeName: m.ZodVoid,
1502
- ...g(n)
1503
- });
1504
- class O extends _ {
1505
- _parse(e) {
1506
- const { ctx: t, status: r } = this._processInputParams(e), s = this._def;
1507
- if (t.parsedType !== f.array)
1508
- return u(t, {
1509
- code: d.invalid_type,
1510
- expected: f.array,
1511
- received: t.parsedType
1512
- }), y;
1513
- if (s.exactLength !== null) {
1514
- const i = t.data.length > s.exactLength.value, o = t.data.length < s.exactLength.value;
1515
- (i || o) && (u(t, {
1516
- code: i ? d.too_big : d.too_small,
1517
- minimum: o ? s.exactLength.value : void 0,
1518
- maximum: i ? s.exactLength.value : void 0,
1519
- type: "array",
1520
- inclusive: !0,
1521
- exact: !0,
1522
- message: s.exactLength.message
1523
- }), r.dirty());
1524
- }
1525
- if (s.minLength !== null && t.data.length < s.minLength.value && (u(t, {
1526
- code: d.too_small,
1527
- minimum: s.minLength.value,
1528
- type: "array",
1529
- inclusive: !0,
1530
- exact: !1,
1531
- message: s.minLength.message
1532
- }), r.dirty()), s.maxLength !== null && t.data.length > s.maxLength.value && (u(t, {
1533
- code: d.too_big,
1534
- maximum: s.maxLength.value,
1535
- type: "array",
1536
- inclusive: !0,
1537
- exact: !1,
1538
- message: s.maxLength.message
1539
- }), r.dirty()), t.common.async)
1540
- return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new $(t, i, t.path, o)))).then((i) => S.mergeArray(r, i));
1541
- const a = [...t.data].map((i, o) => s.type._parseSync(new $(t, i, t.path, o)));
1542
- return S.mergeArray(r, a);
1543
- }
1544
- get element() {
1545
- return this._def.type;
1546
- }
1547
- min(e, t) {
1548
- return new O({
1549
- ...this._def,
1550
- minLength: { value: e, message: p.toString(t) }
1551
- });
1552
- }
1553
- max(e, t) {
1554
- return new O({
1555
- ...this._def,
1556
- maxLength: { value: e, message: p.toString(t) }
1557
- });
1558
- }
1559
- length(e, t) {
1560
- return new O({
1561
- ...this._def,
1562
- exactLength: { value: e, message: p.toString(t) }
1563
- });
1564
- }
1565
- nonempty(e) {
1566
- return this.min(1, e);
1567
- }
1568
- }
1569
- O.create = (n, e) => new O({
1570
- type: n,
1571
- minLength: null,
1572
- maxLength: null,
1573
- exactLength: null,
1574
- typeName: m.ZodArray,
1575
- ...g(e)
1576
- });
1577
- function V(n) {
1578
- if (n instanceof x) {
1579
- const e = {};
1580
- for (const t in n.shape) {
1581
- const r = n.shape[t];
1582
- e[t] = E.create(V(r));
1583
- }
1584
- return new x({
1585
- ...n._def,
1586
- shape: () => e
1587
- });
1588
- } else return n instanceof O ? new O({
1589
- ...n._def,
1590
- type: V(n.element)
1591
- }) : n instanceof E ? E.create(V(n.unwrap())) : n instanceof z ? z.create(V(n.unwrap())) : n instanceof P ? P.create(n.items.map((e) => V(e))) : n;
1592
- }
1593
- class x extends _ {
1594
- constructor() {
1595
- super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
1596
- }
1597
- _getCached() {
1598
- if (this._cached !== null)
1599
- return this._cached;
1600
- const e = this._def.shape(), t = v.objectKeys(e);
1601
- return this._cached = { shape: e, keys: t }, this._cached;
1602
- }
1603
- _parse(e) {
1604
- if (this._getType(e) !== f.object) {
1605
- const l = this._getOrReturnCtx(e);
1606
- return u(l, {
1607
- code: d.invalid_type,
1608
- expected: f.object,
1609
- received: l.parsedType
1610
- }), y;
1611
- }
1612
- const { status: r, ctx: s } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
1613
- if (!(this._def.catchall instanceof Z && this._def.unknownKeys === "strip"))
1614
- for (const l in s.data)
1615
- i.includes(l) || o.push(l);
1616
- const c = [];
1617
- for (const l of i) {
1618
- const h = a[l], w = s.data[l];
1619
- c.push({
1620
- key: { status: "valid", value: l },
1621
- value: h._parse(new $(s, w, s.path, l)),
1622
- alwaysSet: l in s.data
1623
- });
1624
- }
1625
- if (this._def.catchall instanceof Z) {
1626
- const l = this._def.unknownKeys;
1627
- if (l === "passthrough")
1628
- for (const h of o)
1629
- c.push({
1630
- key: { status: "valid", value: h },
1631
- value: { status: "valid", value: s.data[h] }
1632
- });
1633
- else if (l === "strict")
1634
- o.length > 0 && (u(s, {
1635
- code: d.unrecognized_keys,
1636
- keys: o
1637
- }), r.dirty());
1638
- else if (l !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
1639
- } else {
1640
- const l = this._def.catchall;
1641
- for (const h of o) {
1642
- const w = s.data[h];
1643
- c.push({
1644
- key: { status: "valid", value: h },
1645
- value: l._parse(
1646
- new $(s, w, s.path, h)
1647
- //, ctx.child(key), value, getParsedType(value)
1648
- ),
1649
- alwaysSet: h in s.data
1650
- });
1651
- }
1652
- }
1653
- return s.common.async ? Promise.resolve().then(async () => {
1654
- const l = [];
1655
- for (const h of c) {
1656
- const w = await h.key, M = await h.value;
1657
- l.push({
1658
- key: w,
1659
- value: M,
1660
- alwaysSet: h.alwaysSet
1661
- });
1662
- }
1663
- return l;
1664
- }).then((l) => S.mergeObjectSync(r, l)) : S.mergeObjectSync(r, c);
1665
- }
1666
- get shape() {
1667
- return this._def.shape();
1668
- }
1669
- strict(e) {
1670
- return p.errToObj, new x({
1671
- ...this._def,
1672
- unknownKeys: "strict",
1673
- ...e !== void 0 ? {
1674
- errorMap: (t, r) => {
1675
- const s = this._def.errorMap?.(t, r).message ?? r.defaultError;
1676
- return t.code === "unrecognized_keys" ? {
1677
- message: p.errToObj(e).message ?? s
1678
- } : {
1679
- message: s
1680
- };
1681
- }
1682
- } : {}
1683
- });
1684
- }
1685
- strip() {
1686
- return new x({
1687
- ...this._def,
1688
- unknownKeys: "strip"
1689
- });
1690
- }
1691
- passthrough() {
1692
- return new x({
1693
- ...this._def,
1694
- unknownKeys: "passthrough"
1695
- });
1696
- }
1697
- // const AugmentFactory =
1698
- // <Def extends ZodObjectDef>(def: Def) =>
1699
- // <Augmentation extends ZodRawShape>(
1700
- // augmentation: Augmentation
1701
- // ): ZodObject<
1702
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
1703
- // Def["unknownKeys"],
1704
- // Def["catchall"]
1705
- // > => {
1706
- // return new ZodObject({
1707
- // ...def,
1708
- // shape: () => ({
1709
- // ...def.shape(),
1710
- // ...augmentation,
1711
- // }),
1712
- // }) as any;
1713
- // };
1714
- extend(e) {
1715
- return new x({
1716
- ...this._def,
1717
- shape: () => ({
1718
- ...this._def.shape(),
1719
- ...e
1720
- })
1721
- });
1722
- }
1723
- /**
1724
- * Prior to zod@1.0.12 there was a bug in the
1725
- * inferred type of merged objects. Please
1726
- * upgrade if you are experiencing issues.
1727
- */
1728
- merge(e) {
1729
- return new x({
1730
- unknownKeys: e._def.unknownKeys,
1731
- catchall: e._def.catchall,
1732
- shape: () => ({
1733
- ...this._def.shape(),
1734
- ...e._def.shape()
1735
- }),
1736
- typeName: m.ZodObject
1737
- });
1738
- }
1739
- // merge<
1740
- // Incoming extends AnyZodObject,
1741
- // Augmentation extends Incoming["shape"],
1742
- // NewOutput extends {
1743
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1744
- // ? Augmentation[k]["_output"]
1745
- // : k extends keyof Output
1746
- // ? Output[k]
1747
- // : never;
1748
- // },
1749
- // NewInput extends {
1750
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1751
- // ? Augmentation[k]["_input"]
1752
- // : k extends keyof Input
1753
- // ? Input[k]
1754
- // : never;
1755
- // }
1756
- // >(
1757
- // merging: Incoming
1758
- // ): ZodObject<
1759
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1760
- // Incoming["_def"]["unknownKeys"],
1761
- // Incoming["_def"]["catchall"],
1762
- // NewOutput,
1763
- // NewInput
1764
- // > {
1765
- // const merged: any = new ZodObject({
1766
- // unknownKeys: merging._def.unknownKeys,
1767
- // catchall: merging._def.catchall,
1768
- // shape: () =>
1769
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1770
- // typeName: ZodFirstPartyTypeKind.ZodObject,
1771
- // }) as any;
1772
- // return merged;
1773
- // }
1774
- setKey(e, t) {
1775
- return this.augment({ [e]: t });
1776
- }
1777
- // merge<Incoming extends AnyZodObject>(
1778
- // merging: Incoming
1779
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
1780
- // ZodObject<
1781
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1782
- // Incoming["_def"]["unknownKeys"],
1783
- // Incoming["_def"]["catchall"]
1784
- // > {
1785
- // // const mergedShape = objectUtil.mergeShapes(
1786
- // // this._def.shape(),
1787
- // // merging._def.shape()
1788
- // // );
1789
- // const merged: any = new ZodObject({
1790
- // unknownKeys: merging._def.unknownKeys,
1791
- // catchall: merging._def.catchall,
1792
- // shape: () =>
1793
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1794
- // typeName: ZodFirstPartyTypeKind.ZodObject,
1795
- // }) as any;
1796
- // return merged;
1797
- // }
1798
- catchall(e) {
1799
- return new x({
1800
- ...this._def,
1801
- catchall: e
1802
- });
1803
- }
1804
- pick(e) {
1805
- const t = {};
1806
- for (const r of v.objectKeys(e))
1807
- e[r] && this.shape[r] && (t[r] = this.shape[r]);
1808
- return new x({
1809
- ...this._def,
1810
- shape: () => t
1811
- });
1812
- }
1813
- omit(e) {
1814
- const t = {};
1815
- for (const r of v.objectKeys(this.shape))
1816
- e[r] || (t[r] = this.shape[r]);
1817
- return new x({
1818
- ...this._def,
1819
- shape: () => t
1820
- });
1821
- }
1822
- /**
1823
- * @deprecated
1824
- */
1825
- deepPartial() {
1826
- return V(this);
1827
- }
1828
- partial(e) {
1829
- const t = {};
1830
- for (const r of v.objectKeys(this.shape)) {
1831
- const s = this.shape[r];
1832
- e && !e[r] ? t[r] = s : t[r] = s.optional();
1833
- }
1834
- return new x({
1835
- ...this._def,
1836
- shape: () => t
1837
- });
1838
- }
1839
- required(e) {
1840
- const t = {};
1841
- for (const r of v.objectKeys(this.shape))
1842
- if (e && !e[r])
1843
- t[r] = this.shape[r];
1844
- else {
1845
- let a = this.shape[r];
1846
- for (; a instanceof E; )
1847
- a = a._def.innerType;
1848
- t[r] = a;
1849
- }
1850
- return new x({
1851
- ...this._def,
1852
- shape: () => t
1853
- });
1854
- }
1855
- keyof() {
1856
- return We(v.objectKeys(this.shape));
1857
- }
1858
- }
1859
- x.create = (n, e) => new x({
1860
- shape: () => n,
1861
- unknownKeys: "strip",
1862
- catchall: Z.create(),
1863
- typeName: m.ZodObject,
1864
- ...g(e)
1865
- });
1866
- x.strictCreate = (n, e) => new x({
1867
- shape: () => n,
1868
- unknownKeys: "strict",
1869
- catchall: Z.create(),
1870
- typeName: m.ZodObject,
1871
- ...g(e)
1872
- });
1873
- x.lazycreate = (n, e) => new x({
1874
- shape: n,
1875
- unknownKeys: "strip",
1876
- catchall: Z.create(),
1877
- typeName: m.ZodObject,
1878
- ...g(e)
1879
- });
1880
- class se extends _ {
1881
- _parse(e) {
1882
- const { ctx: t } = this._processInputParams(e), r = this._def.options;
1883
- function s(a) {
1884
- for (const o of a)
1885
- if (o.result.status === "valid")
1886
- return o.result;
1887
- for (const o of a)
1888
- if (o.result.status === "dirty")
1889
- return t.common.issues.push(...o.ctx.common.issues), o.result;
1890
- const i = a.map((o) => new D(o.ctx.common.issues));
1891
- return u(t, {
1892
- code: d.invalid_union,
1893
- unionErrors: i
1894
- }), y;
1895
- }
1896
- if (t.common.async)
1897
- return Promise.all(r.map(async (a) => {
1898
- const i = {
1899
- ...t,
1900
- common: {
1901
- ...t.common,
1902
- issues: []
1903
- },
1904
- parent: null
1905
- };
1906
- return {
1907
- result: await a._parseAsync({
1908
- data: t.data,
1909
- path: t.path,
1910
- parent: i
1911
- }),
1912
- ctx: i
1913
- };
1914
- })).then(s);
1915
- {
1916
- let a;
1917
- const i = [];
1918
- for (const c of r) {
1919
- const l = {
1920
- ...t,
1921
- common: {
1922
- ...t.common,
1923
- issues: []
1924
- },
1925
- parent: null
1926
- }, h = c._parseSync({
1927
- data: t.data,
1928
- path: t.path,
1929
- parent: l
1930
- });
1931
- if (h.status === "valid")
1932
- return h;
1933
- h.status === "dirty" && !a && (a = { result: h, ctx: l }), l.common.issues.length && i.push(l.common.issues);
1934
- }
1935
- if (a)
1936
- return t.common.issues.push(...a.ctx.common.issues), a.result;
1937
- const o = i.map((c) => new D(c));
1938
- return u(t, {
1939
- code: d.invalid_union,
1940
- unionErrors: o
1941
- }), y;
1942
- }
1943
- }
1944
- get options() {
1945
- return this._def.options;
1946
- }
1947
- }
1948
- se.create = (n, e) => new se({
1949
- options: n,
1950
- typeName: m.ZodUnion,
1951
- ...g(e)
1952
- });
1953
- function _e(n, e) {
1954
- const t = j(n), r = j(e);
1955
- if (n === e)
1956
- return { valid: !0, data: n };
1957
- if (t === f.object && r === f.object) {
1958
- const s = v.objectKeys(e), a = v.objectKeys(n).filter((o) => s.indexOf(o) !== -1), i = { ...n, ...e };
1959
- for (const o of a) {
1960
- const c = _e(n[o], e[o]);
1961
- if (!c.valid)
1962
- return { valid: !1 };
1963
- i[o] = c.data;
1964
- }
1965
- return { valid: !0, data: i };
1966
- } else if (t === f.array && r === f.array) {
1967
- if (n.length !== e.length)
1968
- return { valid: !1 };
1969
- const s = [];
1970
- for (let a = 0; a < n.length; a++) {
1971
- const i = n[a], o = e[a], c = _e(i, o);
1972
- if (!c.valid)
1973
- return { valid: !1 };
1974
- s.push(c.data);
1975
- }
1976
- return { valid: !0, data: s };
1977
- } else return t === f.date && r === f.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
1978
- }
1979
- class ae extends _ {
1980
- _parse(e) {
1981
- const { status: t, ctx: r } = this._processInputParams(e), s = (a, i) => {
1982
- if (Ie(a) || Ie(i))
1983
- return y;
1984
- const o = _e(a.value, i.value);
1985
- return o.valid ? ((De(a) || De(i)) && t.dirty(), { status: t.value, value: o.data }) : (u(r, {
1986
- code: d.invalid_intersection_types
1987
- }), y);
1988
- };
1989
- return r.common.async ? Promise.all([
1990
- this._def.left._parseAsync({
1991
- data: r.data,
1992
- path: r.path,
1993
- parent: r
1994
- }),
1995
- this._def.right._parseAsync({
1996
- data: r.data,
1997
- path: r.path,
1998
- parent: r
1999
- })
2000
- ]).then(([a, i]) => s(a, i)) : s(this._def.left._parseSync({
2001
- data: r.data,
2002
- path: r.path,
2003
- parent: r
2004
- }), this._def.right._parseSync({
2005
- data: r.data,
2006
- path: r.path,
2007
- parent: r
2008
- }));
2009
- }
2010
- }
2011
- ae.create = (n, e, t) => new ae({
2012
- left: n,
2013
- right: e,
2014
- typeName: m.ZodIntersection,
2015
- ...g(t)
2016
- });
2017
- class P extends _ {
2018
- _parse(e) {
2019
- const { status: t, ctx: r } = this._processInputParams(e);
2020
- if (r.parsedType !== f.array)
2021
- return u(r, {
2022
- code: d.invalid_type,
2023
- expected: f.array,
2024
- received: r.parsedType
2025
- }), y;
2026
- if (r.data.length < this._def.items.length)
2027
- return u(r, {
2028
- code: d.too_small,
2029
- minimum: this._def.items.length,
2030
- inclusive: !0,
2031
- exact: !1,
2032
- type: "array"
2033
- }), y;
2034
- !this._def.rest && r.data.length > this._def.items.length && (u(r, {
2035
- code: d.too_big,
2036
- maximum: this._def.items.length,
2037
- inclusive: !0,
2038
- exact: !1,
2039
- type: "array"
2040
- }), t.dirty());
2041
- const a = [...r.data].map((i, o) => {
2042
- const c = this._def.items[o] || this._def.rest;
2043
- return c ? c._parse(new $(r, i, r.path, o)) : null;
2044
- }).filter((i) => !!i);
2045
- return r.common.async ? Promise.all(a).then((i) => S.mergeArray(t, i)) : S.mergeArray(t, a);
2046
- }
2047
- get items() {
2048
- return this._def.items;
2049
- }
2050
- rest(e) {
2051
- return new P({
2052
- ...this._def,
2053
- rest: e
2054
- });
2055
- }
2056
- }
2057
- P.create = (n, e) => {
2058
- if (!Array.isArray(n))
2059
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2060
- return new P({
2061
- items: n,
2062
- typeName: m.ZodTuple,
2063
- rest: null,
2064
- ...g(e)
2065
- });
2066
- };
2067
- class ie extends _ {
2068
- get keySchema() {
2069
- return this._def.keyType;
2070
- }
2071
- get valueSchema() {
2072
- return this._def.valueType;
2073
- }
2074
- _parse(e) {
2075
- const { status: t, ctx: r } = this._processInputParams(e);
2076
- if (r.parsedType !== f.object)
2077
- return u(r, {
2078
- code: d.invalid_type,
2079
- expected: f.object,
2080
- received: r.parsedType
2081
- }), y;
2082
- const s = [], a = this._def.keyType, i = this._def.valueType;
2083
- for (const o in r.data)
2084
- s.push({
2085
- key: a._parse(new $(r, o, r.path, o)),
2086
- value: i._parse(new $(r, r.data[o], r.path, o)),
2087
- alwaysSet: o in r.data
2088
- });
2089
- return r.common.async ? S.mergeObjectAsync(t, s) : S.mergeObjectSync(t, s);
2090
- }
2091
- get element() {
2092
- return this._def.valueType;
2093
- }
2094
- static create(e, t, r) {
2095
- return t instanceof _ ? new ie({
2096
- keyType: e,
2097
- valueType: t,
2098
- typeName: m.ZodRecord,
2099
- ...g(r)
2100
- }) : new ie({
2101
- keyType: I.create(),
2102
- valueType: e,
2103
- typeName: m.ZodRecord,
2104
- ...g(t)
2105
- });
2106
- }
2107
- }
2108
- class Ve extends _ {
2109
- get keySchema() {
2110
- return this._def.keyType;
2111
- }
2112
- get valueSchema() {
2113
- return this._def.valueType;
2114
- }
2115
- _parse(e) {
2116
- const { status: t, ctx: r } = this._processInputParams(e);
2117
- if (r.parsedType !== f.map)
2118
- return u(r, {
2119
- code: d.invalid_type,
2120
- expected: f.map,
2121
- received: r.parsedType
2122
- }), y;
2123
- const s = this._def.keyType, a = this._def.valueType, i = [...r.data.entries()].map(([o, c], l) => ({
2124
- key: s._parse(new $(r, o, r.path, [l, "key"])),
2125
- value: a._parse(new $(r, c, r.path, [l, "value"]))
2126
- }));
2127
- if (r.common.async) {
2128
- const o = /* @__PURE__ */ new Map();
2129
- return Promise.resolve().then(async () => {
2130
- for (const c of i) {
2131
- const l = await c.key, h = await c.value;
2132
- if (l.status === "aborted" || h.status === "aborted")
2133
- return y;
2134
- (l.status === "dirty" || h.status === "dirty") && t.dirty(), o.set(l.value, h.value);
2135
- }
2136
- return { status: t.value, value: o };
2137
- });
2138
- } else {
2139
- const o = /* @__PURE__ */ new Map();
2140
- for (const c of i) {
2141
- const l = c.key, h = c.value;
2142
- if (l.status === "aborted" || h.status === "aborted")
2143
- return y;
2144
- (l.status === "dirty" || h.status === "dirty") && t.dirty(), o.set(l.value, h.value);
2145
- }
2146
- return { status: t.value, value: o };
2147
- }
2148
- }
2149
- }
2150
- Ve.create = (n, e, t) => new Ve({
2151
- valueType: e,
2152
- keyType: n,
2153
- typeName: m.ZodMap,
2154
- ...g(t)
2155
- });
2156
- class Y extends _ {
2157
- _parse(e) {
2158
- const { status: t, ctx: r } = this._processInputParams(e);
2159
- if (r.parsedType !== f.set)
2160
- return u(r, {
2161
- code: d.invalid_type,
2162
- expected: f.set,
2163
- received: r.parsedType
2164
- }), y;
2165
- const s = this._def;
2166
- s.minSize !== null && r.data.size < s.minSize.value && (u(r, {
2167
- code: d.too_small,
2168
- minimum: s.minSize.value,
2169
- type: "set",
2170
- inclusive: !0,
2171
- exact: !1,
2172
- message: s.minSize.message
2173
- }), t.dirty()), s.maxSize !== null && r.data.size > s.maxSize.value && (u(r, {
2174
- code: d.too_big,
2175
- maximum: s.maxSize.value,
2176
- type: "set",
2177
- inclusive: !0,
2178
- exact: !1,
2179
- message: s.maxSize.message
2180
- }), t.dirty());
2181
- const a = this._def.valueType;
2182
- function i(c) {
2183
- const l = /* @__PURE__ */ new Set();
2184
- for (const h of c) {
2185
- if (h.status === "aborted")
2186
- return y;
2187
- h.status === "dirty" && t.dirty(), l.add(h.value);
2188
- }
2189
- return { status: t.value, value: l };
2190
- }
2191
- const o = [...r.data.values()].map((c, l) => a._parse(new $(r, c, r.path, l)));
2192
- return r.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
2193
- }
2194
- min(e, t) {
2195
- return new Y({
2196
- ...this._def,
2197
- minSize: { value: e, message: p.toString(t) }
2198
- });
2199
- }
2200
- max(e, t) {
2201
- return new Y({
2202
- ...this._def,
2203
- maxSize: { value: e, message: p.toString(t) }
2204
- });
2205
- }
2206
- size(e, t) {
2207
- return this.min(e, t).max(e, t);
2208
- }
2209
- nonempty(e) {
2210
- return this.min(1, e);
2211
- }
2212
- }
2213
- Y.create = (n, e) => new Y({
2214
- valueType: n,
2215
- minSize: null,
2216
- maxSize: null,
2217
- typeName: m.ZodSet,
2218
- ...g(e)
2219
- });
2220
- class Fe extends _ {
2221
- get schema() {
2222
- return this._def.getter();
2223
- }
2224
- _parse(e) {
2225
- const { ctx: t } = this._processInputParams(e);
2226
- return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
2227
- }
2228
- }
2229
- Fe.create = (n, e) => new Fe({
2230
- getter: n,
2231
- typeName: m.ZodLazy,
2232
- ...g(e)
2233
- });
2234
- class qe extends _ {
2235
- _parse(e) {
2236
- if (e.data !== this._def.value) {
2237
- const t = this._getOrReturnCtx(e);
2238
- return u(t, {
2239
- received: t.data,
2240
- code: d.invalid_literal,
2241
- expected: this._def.value
2242
- }), y;
2243
- }
2244
- return { status: "valid", value: e.data };
2245
- }
2246
- get value() {
2247
- return this._def.value;
2248
- }
2249
- }
2250
- qe.create = (n, e) => new qe({
2251
- value: n,
2252
- typeName: m.ZodLiteral,
2253
- ...g(e)
2254
- });
2255
- function We(n, e) {
2256
- return new q({
2257
- values: n,
2258
- typeName: m.ZodEnum,
2259
- ...g(e)
2260
- });
2261
- }
2262
- class q extends _ {
2263
- _parse(e) {
2264
- if (typeof e.data != "string") {
2265
- const t = this._getOrReturnCtx(e), r = this._def.values;
2266
- return u(t, {
2267
- expected: v.joinValues(r),
2268
- received: t.parsedType,
2269
- code: d.invalid_type
2270
- }), y;
2271
- }
2272
- if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
2273
- const t = this._getOrReturnCtx(e), r = this._def.values;
2274
- return u(t, {
2275
- received: t.data,
2276
- code: d.invalid_enum_value,
2277
- options: r
2278
- }), y;
2279
- }
2280
- return T(e.data);
2281
- }
2282
- get options() {
2283
- return this._def.values;
2284
- }
2285
- get enum() {
2286
- const e = {};
2287
- for (const t of this._def.values)
2288
- e[t] = t;
2289
- return e;
2290
- }
2291
- get Values() {
2292
- const e = {};
2293
- for (const t of this._def.values)
2294
- e[t] = t;
2295
- return e;
2296
- }
2297
- get Enum() {
2298
- const e = {};
2299
- for (const t of this._def.values)
2300
- e[t] = t;
2301
- return e;
2302
- }
2303
- extract(e, t = this._def) {
2304
- return q.create(e, {
2305
- ...this._def,
2306
- ...t
2307
- });
2308
- }
2309
- exclude(e, t = this._def) {
2310
- return q.create(this.options.filter((r) => !e.includes(r)), {
2311
- ...this._def,
2312
- ...t
2313
- });
2314
- }
2315
- }
2316
- q.create = We;
2317
- class Be extends _ {
2318
- _parse(e) {
2319
- const t = v.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(e);
2320
- if (r.parsedType !== f.string && r.parsedType !== f.number) {
2321
- const s = v.objectValues(t);
2322
- return u(r, {
2323
- expected: v.joinValues(s),
2324
- received: r.parsedType,
2325
- code: d.invalid_type
2326
- }), y;
2327
- }
2328
- if (this._cache || (this._cache = new Set(v.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
2329
- const s = v.objectValues(t);
2330
- return u(r, {
2331
- received: r.data,
2332
- code: d.invalid_enum_value,
2333
- options: s
2334
- }), y;
2335
- }
2336
- return T(e.data);
2337
- }
2338
- get enum() {
2339
- return this._def.values;
2340
- }
2341
- }
2342
- Be.create = (n, e) => new Be({
2343
- values: n,
2344
- typeName: m.ZodNativeEnum,
2345
- ...g(e)
2346
- });
2347
- class oe extends _ {
2348
- unwrap() {
2349
- return this._def.type;
2350
- }
2351
- _parse(e) {
2352
- const { ctx: t } = this._processInputParams(e);
2353
- if (t.parsedType !== f.promise && t.common.async === !1)
2354
- return u(t, {
2355
- code: d.invalid_type,
2356
- expected: f.promise,
2357
- received: t.parsedType
2358
- }), y;
2359
- const r = t.parsedType === f.promise ? t.data : Promise.resolve(t.data);
2360
- return T(r.then((s) => this._def.type.parseAsync(s, {
2361
- path: t.path,
2362
- errorMap: t.common.contextualErrorMap
2363
- })));
2364
- }
2365
- }
2366
- oe.create = (n, e) => new oe({
2367
- type: n,
2368
- typeName: m.ZodPromise,
2369
- ...g(e)
2370
- });
2371
- class B extends _ {
2372
- innerType() {
2373
- return this._def.schema;
2374
- }
2375
- sourceType() {
2376
- return this._def.schema._def.typeName === m.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2377
- }
2378
- _parse(e) {
2379
- const { status: t, ctx: r } = this._processInputParams(e), s = this._def.effect || null, a = {
2380
- addIssue: (i) => {
2381
- u(r, i), i.fatal ? t.abort() : t.dirty();
2382
- },
2383
- get path() {
2384
- return r.path;
2385
- }
2386
- };
2387
- if (a.addIssue = a.addIssue.bind(a), s.type === "preprocess") {
2388
- const i = s.transform(r.data, a);
2389
- if (r.common.async)
2390
- return Promise.resolve(i).then(async (o) => {
2391
- if (t.value === "aborted")
2392
- return y;
2393
- const c = await this._def.schema._parseAsync({
2394
- data: o,
2395
- path: r.path,
2396
- parent: r
2397
- });
2398
- return c.status === "aborted" ? y : c.status === "dirty" || t.value === "dirty" ? J(c.value) : c;
2399
- });
2400
- {
2401
- if (t.value === "aborted")
2402
- return y;
2403
- const o = this._def.schema._parseSync({
2404
- data: i,
2405
- path: r.path,
2406
- parent: r
2407
- });
2408
- return o.status === "aborted" ? y : o.status === "dirty" || t.value === "dirty" ? J(o.value) : o;
2409
- }
2410
- }
2411
- if (s.type === "refinement") {
2412
- const i = (o) => {
2413
- const c = s.refinement(o, a);
2414
- if (r.common.async)
2415
- return Promise.resolve(c);
2416
- if (c instanceof Promise)
2417
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2418
- return o;
2419
- };
2420
- if (r.common.async === !1) {
2421
- const o = this._def.schema._parseSync({
2422
- data: r.data,
2423
- path: r.path,
2424
- parent: r
2425
- });
2426
- return o.status === "aborted" ? y : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
2427
- } else
2428
- return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((o) => o.status === "aborted" ? y : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
2429
- }
2430
- if (s.type === "transform")
2431
- if (r.common.async === !1) {
2432
- const i = this._def.schema._parseSync({
2433
- data: r.data,
2434
- path: r.path,
2435
- parent: r
2436
- });
2437
- if (!F(i))
2438
- return y;
2439
- const o = s.transform(i.value, a);
2440
- if (o instanceof Promise)
2441
- throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2442
- return { status: t.value, value: o };
2443
- } else
2444
- return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((i) => F(i) ? Promise.resolve(s.transform(i.value, a)).then((o) => ({
2445
- status: t.value,
2446
- value: o
2447
- })) : y);
2448
- v.assertNever(s);
2449
- }
2450
- }
2451
- B.create = (n, e, t) => new B({
2452
- schema: n,
2453
- typeName: m.ZodEffects,
2454
- effect: e,
2455
- ...g(t)
2456
- });
2457
- B.createWithPreprocess = (n, e, t) => new B({
2458
- schema: e,
2459
- effect: { type: "preprocess", transform: n },
2460
- typeName: m.ZodEffects,
2461
- ...g(t)
2462
- });
2463
- class E extends _ {
2464
- _parse(e) {
2465
- return this._getType(e) === f.undefined ? T(void 0) : this._def.innerType._parse(e);
2466
- }
2467
- unwrap() {
2468
- return this._def.innerType;
2469
- }
2470
- }
2471
- E.create = (n, e) => new E({
2472
- innerType: n,
2473
- typeName: m.ZodOptional,
2474
- ...g(e)
2475
- });
2476
- class z extends _ {
2477
- _parse(e) {
2478
- return this._getType(e) === f.null ? T(null) : this._def.innerType._parse(e);
2479
- }
2480
- unwrap() {
2481
- return this._def.innerType;
2482
- }
2483
- }
2484
- z.create = (n, e) => new z({
2485
- innerType: n,
2486
- typeName: m.ZodNullable,
2487
- ...g(e)
2488
- });
2489
- class ve extends _ {
2490
- _parse(e) {
2491
- const { ctx: t } = this._processInputParams(e);
2492
- let r = t.data;
2493
- return t.parsedType === f.undefined && (r = this._def.defaultValue()), this._def.innerType._parse({
2494
- data: r,
2495
- path: t.path,
2496
- parent: t
2497
- });
2498
- }
2499
- removeDefault() {
2500
- return this._def.innerType;
2501
- }
2502
- }
2503
- ve.create = (n, e) => new ve({
2504
- innerType: n,
2505
- typeName: m.ZodDefault,
2506
- defaultValue: typeof e.default == "function" ? e.default : () => e.default,
2507
- ...g(e)
2508
- });
2509
- class ke extends _ {
2510
- _parse(e) {
2511
- const { ctx: t } = this._processInputParams(e), r = {
2512
- ...t,
2513
- common: {
2514
- ...t.common,
2515
- issues: []
2516
- }
2517
- }, s = this._def.innerType._parse({
2518
- data: r.data,
2519
- path: r.path,
2520
- parent: {
2521
- ...r
2522
- }
2523
- });
2524
- return ne(s) ? s.then((a) => ({
2525
- status: "valid",
2526
- value: a.status === "valid" ? a.value : this._def.catchValue({
2527
- get error() {
2528
- return new D(r.common.issues);
2529
- },
2530
- input: r.data
2531
- })
2532
- })) : {
2533
- status: "valid",
2534
- value: s.status === "valid" ? s.value : this._def.catchValue({
2535
- get error() {
2536
- return new D(r.common.issues);
2537
- },
2538
- input: r.data
2539
- })
2540
- };
2541
- }
2542
- removeCatch() {
2543
- return this._def.innerType;
2544
- }
2545
- }
2546
- ke.create = (n, e) => new ke({
2547
- innerType: n,
2548
- typeName: m.ZodCatch,
2549
- catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
2550
- ...g(e)
2551
- });
2552
- class ze extends _ {
2553
- _parse(e) {
2554
- if (this._getType(e) !== f.nan) {
2555
- const r = this._getOrReturnCtx(e);
2556
- return u(r, {
2557
- code: d.invalid_type,
2558
- expected: f.nan,
2559
- received: r.parsedType
2560
- }), y;
2561
- }
2562
- return { status: "valid", value: e.data };
2563
- }
2564
- }
2565
- ze.create = (n) => new ze({
2566
- typeName: m.ZodNaN,
2567
- ...g(n)
2568
- });
2569
- class Vt extends _ {
2570
- _parse(e) {
2571
- const { ctx: t } = this._processInputParams(e), r = t.data;
2572
- return this._def.type._parse({
2573
- data: r,
2574
- path: t.path,
2575
- parent: t
2576
- });
2577
- }
2578
- unwrap() {
2579
- return this._def.type;
2580
- }
2581
- }
2582
- class Se extends _ {
2583
- _parse(e) {
2584
- const { status: t, ctx: r } = this._processInputParams(e);
2585
- if (r.common.async)
2586
- return (async () => {
2587
- const a = await this._def.in._parseAsync({
2588
- data: r.data,
2589
- path: r.path,
2590
- parent: r
2591
- });
2592
- return a.status === "aborted" ? y : a.status === "dirty" ? (t.dirty(), J(a.value)) : this._def.out._parseAsync({
2593
- data: a.value,
2594
- path: r.path,
2595
- parent: r
2596
- });
2597
- })();
2598
- {
2599
- const s = this._def.in._parseSync({
2600
- data: r.data,
2601
- path: r.path,
2602
- parent: r
2603
- });
2604
- return s.status === "aborted" ? y : s.status === "dirty" ? (t.dirty(), {
2605
- status: "dirty",
2606
- value: s.value
2607
- }) : this._def.out._parseSync({
2608
- data: s.value,
2609
- path: r.path,
2610
- parent: r
2611
- });
2612
- }
2613
- }
2614
- static create(e, t) {
2615
- return new Se({
2616
- in: e,
2617
- out: t,
2618
- typeName: m.ZodPipeline
2619
- });
2620
- }
2621
- }
2622
- class xe extends _ {
2623
- _parse(e) {
2624
- const t = this._def.innerType._parse(e), r = (s) => (F(s) && (s.value = Object.freeze(s.value)), s);
2625
- return ne(t) ? t.then((s) => r(s)) : r(t);
2626
- }
2627
- unwrap() {
2628
- return this._def.innerType;
2629
- }
2630
- }
2631
- xe.create = (n, e) => new xe({
2632
- innerType: n,
2633
- typeName: m.ZodReadonly,
2634
- ...g(e)
2635
- });
2636
- var m;
2637
- (function(n) {
2638
- n.ZodString = "ZodString", n.ZodNumber = "ZodNumber", n.ZodNaN = "ZodNaN", n.ZodBigInt = "ZodBigInt", n.ZodBoolean = "ZodBoolean", n.ZodDate = "ZodDate", n.ZodSymbol = "ZodSymbol", n.ZodUndefined = "ZodUndefined", n.ZodNull = "ZodNull", n.ZodAny = "ZodAny", n.ZodUnknown = "ZodUnknown", n.ZodNever = "ZodNever", n.ZodVoid = "ZodVoid", n.ZodArray = "ZodArray", n.ZodObject = "ZodObject", n.ZodUnion = "ZodUnion", n.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", n.ZodIntersection = "ZodIntersection", n.ZodTuple = "ZodTuple", n.ZodRecord = "ZodRecord", n.ZodMap = "ZodMap", n.ZodSet = "ZodSet", n.ZodFunction = "ZodFunction", n.ZodLazy = "ZodLazy", n.ZodLiteral = "ZodLiteral", n.ZodEnum = "ZodEnum", n.ZodEffects = "ZodEffects", n.ZodNativeEnum = "ZodNativeEnum", n.ZodOptional = "ZodOptional", n.ZodNullable = "ZodNullable", n.ZodDefault = "ZodDefault", n.ZodCatch = "ZodCatch", n.ZodPromise = "ZodPromise", n.ZodBranded = "ZodBranded", n.ZodPipeline = "ZodPipeline", n.ZodReadonly = "ZodReadonly";
2639
- })(m || (m = {}));
2640
- const k = I.create, W = ye.create, ce = ge.create;
2641
- Z.create;
2642
- const X = O.create, K = x.create, Ft = se.create;
2643
- ae.create;
2644
- P.create;
2645
- const Te = ie.create, Qe = q.create;
2646
- oe.create;
2647
- E.create;
2648
- z.create;
2649
- const qt = Qe([
2650
- "Data",
2651
- // Short text, varchar
2652
- "Text",
2653
- // Long text
2654
- "Int",
2655
- // Integer
2656
- "Float",
2657
- // Floating point (IEEE 754)
2658
- "Decimal",
2659
- // Arbitrary precision decimal
2660
- "Check",
2661
- // Boolean/checkbox
2662
- "Date",
2663
- // Date only
2664
- "Time",
2665
- // Time only
2666
- "Datetime",
2667
- // Date and time
2668
- "Duration",
2669
- // Time interval
2670
- "DateRange",
2671
- // Date range
2672
- "JSON",
2673
- // JSON data
2674
- "Code",
2675
- // Code/source (with syntax highlighting)
2676
- "Link",
2677
- // Reference to another doctype
2678
- "Doctype",
2679
- // Child doctype (renders as table)
2680
- "Attach",
2681
- // File attachment
2682
- "Currency",
2683
- // Currency value
2684
- "Quantity",
2685
- // Quantity with unit
2686
- "Select"
2687
- // Dropdown selection
2688
- ]), Bt = {
2689
- // Text
2690
- Data: { component: "ATextInput", fieldtype: "Data" },
2691
- Text: { component: "ATextInput", fieldtype: "Text" },
2692
- // Numeric
2693
- Int: { component: "ANumericInput", fieldtype: "Int" },
2694
- Float: { component: "ANumericInput", fieldtype: "Float" },
2695
- Decimal: { component: "ADecimalInput", fieldtype: "Decimal" },
2696
- // Boolean
2697
- Check: { component: "ACheckbox", fieldtype: "Check" },
2698
- // Date/Time
2699
- Date: { component: "ADatePicker", fieldtype: "Date" },
2700
- Time: { component: "ATimeInput", fieldtype: "Time" },
2701
- Datetime: { component: "ADatetimePicker", fieldtype: "Datetime" },
2702
- Duration: { component: "ADurationInput", fieldtype: "Duration" },
2703
- DateRange: { component: "ADateRangePicker", fieldtype: "DateRange" },
2704
- // Structured
2705
- JSON: { component: "ACodeEditor", fieldtype: "JSON" },
2706
- Code: { component: "ACodeEditor", fieldtype: "Code" },
2707
- // Relational
2708
- Link: { component: "ALink", fieldtype: "Link" },
2709
- Doctype: { component: "ATable", fieldtype: "Doctype" },
2710
- // Files
2711
- Attach: { component: "AFileAttach", fieldtype: "Attach" },
2712
- // Specialized
2713
- Currency: { component: "ACurrencyInput", fieldtype: "Currency" },
2714
- Quantity: { component: "AQuantityInput", fieldtype: "Quantity" },
2715
- Select: { component: "ADropdown", fieldtype: "Select" }
2716
- };
2717
- function Nn(n) {
2718
- return Bt[n]?.component ?? "ATextInput";
2719
- }
2720
- const zt = Ft([
2721
- k(),
2722
- // Link/Doctype target: "customer"
2723
- X(k()),
2724
- // Select choices: ["A", "B", "C"]
2725
- Te(k(), ce())
2726
- // Config: \{ precision: 10, scale: 2 \}
2727
- ]), Ut = K({
2728
- /** Error message to display when validation fails */
2729
- errorMessage: k()
2730
- }).passthrough(), Ae = K({
2731
- // === CORE (required) ===
2732
- /** Unique identifier for the field within its doctype */
2733
- fieldname: k().min(1),
2734
- /** Semantic field type - determines behavior and default component */
2735
- fieldtype: qt,
2736
- // === COMPONENT (optional - derived from fieldtype when not specified) ===
2737
- /** Vue component to render this field. If not specified, derived from TYPE_MAP */
2738
- component: k().optional(),
2739
- // === DISPLAY ===
2740
- /** Human-readable label for the field */
2741
- label: k().optional(),
2742
- /** Width of the field (CSS value, e.g., "40ch", "200px") */
2743
- width: k().optional(),
2744
- /** Text alignment within the field */
2745
- align: Qe(["left", "center", "right", "start", "end"]).optional(),
2746
- // === BEHAVIOR ===
2747
- /** Whether the field is required */
2748
- required: W().optional(),
2749
- /** Whether the field is read-only */
2750
- readOnly: W().optional(),
2751
- /** Whether the field is editable (for table cells) */
2752
- edit: W().optional(),
2753
- /** Whether the field is hidden from the UI */
2754
- hidden: W().optional(),
2755
- // === VALUE ===
2756
- /** Current value of the field */
2757
- value: ce().optional(),
2758
- /** Default value for new records */
2759
- default: ce().optional(),
2760
- // === TYPE-SPECIFIC ===
2761
- /**
2762
- * Type-specific options:
2763
- * - Link: target doctype slug ("customer")
2764
- * - Doctype: child doctype slug ("sales-order-item")
2765
- * - Select: choices array (["Draft", "Submitted"])
2766
- * - Decimal: \{ precision, scale \}
2767
- * - Code: \{ language \}
2768
- */
2769
- options: zt.optional(),
2770
- /** Input mask pattern (e.g., "##/##/####" for dates) */
2771
- mask: k().optional(),
2772
- // === VALIDATION ===
2773
- /** Validation configuration */
2774
- validation: Ut.optional()
2775
- }), Jt = K({
2776
- /** Display label for the action */
2777
- label: k().min(1),
2778
- /** Handler function name or path */
2779
- handler: k().min(1),
2780
- /** Fields that must have values before action can execute */
2781
- requiredFields: X(k()).optional(),
2782
- /** Workflow states where this action is available */
2783
- allowedStates: X(k()).optional(),
2784
- /** Whether to show a confirmation dialog */
2785
- confirm: W().optional(),
2786
- /** Additional arguments for the action */
2787
- args: Te(k(), ce()).optional()
2788
- }), Wt = K({
2789
- /** List of workflow states */
2790
- states: X(k()).optional(),
2791
- /** Actions available in this workflow */
2792
- actions: Te(k(), Jt).optional()
2793
- }), Ge = K({
2794
- /** Display name of the doctype */
2795
- name: k().min(1),
2796
- /** URL-friendly slug (kebab-case) */
2797
- slug: k().min(1).optional(),
2798
- /** Database table name */
2799
- tableName: k().optional(),
2800
- /** Field definitions */
2801
- fields: X(Ae),
2802
- /** Workflow configuration */
2803
- workflow: Wt.optional(),
2804
- /** Parent doctype for inheritance */
2805
- inherits: k().optional(),
2806
- /** Doctype to use for list views */
2807
- listDoctype: k().optional(),
2808
- /** Parent doctype for child tables */
2809
- parentDoctype: k().optional()
2810
- });
2811
- function On(n) {
2812
- const e = Ae.safeParse(n);
2813
- return e.success ? { success: !0, errors: [] } : {
2814
- success: !1,
2815
- errors: e.error.issues.map((t) => ({
2816
- path: t.path,
2817
- message: t.message
2818
- }))
2819
- };
2820
- }
2821
- function He(n) {
2822
- const e = Ge.safeParse(n);
2823
- return e.success ? { success: !0, errors: [] } : {
2824
- success: !1,
2825
- errors: e.error.issues.map((t) => ({
2826
- path: t.path,
2827
- message: t.message
2828
- }))
2829
- };
2830
- }
2831
- function $n(n) {
2832
- return Ae.parse(n);
2833
- }
2834
- function Ye(n) {
2835
- return Ge.parse(n);
2836
- }
2837
- function Rn(n) {
2838
- return n.replace(/_([a-z])/g, (e, t) => t.toUpperCase());
2839
- }
2840
- function In(n) {
2841
- return n.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`);
2842
- }
2843
- function Dn(n) {
2844
- return n.split("_").map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ");
2845
- }
2846
- function Qt(n) {
2847
- const e = n.replace(/([A-Z])/g, " $1").trim();
2848
- return e.charAt(0).toUpperCase() + e.slice(1);
2849
- }
2850
- function jn(n) {
2851
- return n.split(/[-_\s]+/).map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join("");
2852
- }
2853
- function te(n) {
2854
- return n.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
2855
- }
2856
- function Gt(n) {
2857
- return n.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
2858
- }
2859
- const Ht = {
2860
- String: { component: "ATextInput", fieldtype: "Data" },
2861
- Int: { component: "ANumericInput", fieldtype: "Int" },
2862
- Float: { component: "ANumericInput", fieldtype: "Float" },
2863
- Boolean: { component: "ACheckbox", fieldtype: "Check" },
2864
- ID: { component: "ATextInput", fieldtype: "Data" }
2865
- }, Yt = {
2866
- // Arbitrary precision / large numbers
2867
- BigFloat: { component: "ADecimalInput", fieldtype: "Decimal" },
2868
- BigDecimal: { component: "ADecimalInput", fieldtype: "Decimal" },
2869
- Decimal: { component: "ADecimalInput", fieldtype: "Decimal" },
2870
- BigInt: { component: "ANumericInput", fieldtype: "Int" },
2871
- Long: { component: "ANumericInput", fieldtype: "Int" },
2872
- // Identifiers
2873
- UUID: { component: "ATextInput", fieldtype: "Data" },
2874
- // Date / Time
2875
- DateTime: { component: "ADatetimePicker", fieldtype: "Datetime" },
2876
- Datetime: { component: "ADatetimePicker", fieldtype: "Datetime" },
2877
- Date: { component: "ADatePicker", fieldtype: "Date" },
2878
- Time: { component: "ATimeInput", fieldtype: "Time" },
2879
- Interval: { component: "ADurationInput", fieldtype: "Duration" },
2880
- Duration: { component: "ADurationInput", fieldtype: "Duration" },
2881
- // Structured data
2882
- JSON: { component: "ACodeEditor", fieldtype: "JSON" },
2883
- JSONObject: { component: "ACodeEditor", fieldtype: "JSON" },
2884
- JsonNode: { component: "ACodeEditor", fieldtype: "JSON" }
2885
- }, Xt = /* @__PURE__ */ new Set(["Cursor"]);
2886
- function Kt(n) {
2887
- const e = { ...Yt };
2888
- for (const [t, r] of Object.entries(Ht))
2889
- e[t] = r;
2890
- if (n)
2891
- for (const [t, r] of Object.entries(n))
2892
- e[t] = {
2893
- component: r.component ?? "ATextInput",
2894
- fieldtype: r.fieldtype ?? "Data"
2895
- };
2896
- return e;
2897
- }
2898
- const en = [
2899
- "Connection",
2900
- "Edge",
2901
- "Input",
2902
- "Patch",
2903
- "Payload",
2904
- "Condition",
2905
- "Filter",
2906
- "OrderBy",
2907
- "Aggregate",
2908
- "AggregateResult",
2909
- "AggregateFilter",
2910
- "DeleteResponse",
2911
- "InsertResponse",
2912
- "UpdateResponse",
2913
- "MutationResponse"
2914
- ], tn = /* @__PURE__ */ new Set(["Query", "Mutation", "Subscription"]);
2915
- function nn(n, e) {
2916
- if (n.startsWith("__") || tn.has(n) || n === "Node")
2917
- return !1;
2918
- for (const r of en)
2919
- if (n.endsWith(r))
2920
- return !1;
2921
- const t = e.getFields();
2922
- return Object.keys(t).length !== 0;
2923
- }
2924
- const rn = /* @__PURE__ */ new Set(["nodeId", "__typename", "clientMutationId"]);
2925
- function sn(n, e, t) {
2926
- return !rn.has(n);
2927
- }
2928
- function be(n) {
2929
- let e = !1, t = !1, r = n;
2930
- return $e(r) && (e = !0, r = r.ofType), st(r) && (t = !0, r = r.ofType, $e(r) && (r = r.ofType)), { namedType: r, required: e, isList: t };
2931
- }
2932
- function an(n) {
2933
- const e = n.getFields().edges;
2934
- if (!e) return;
2935
- const { namedType: t, isList: r } = be(e.type);
2936
- if (!r || !Q(t)) return;
2937
- const s = t.getFields().node;
2938
- if (!s) return;
2939
- const { namedType: a } = be(s.type);
2940
- if (Q(a))
2941
- return a.name;
2942
- }
2943
- function on(n, e, t, r = {}) {
2944
- const { namedType: s, required: a, isList: i } = be(e.type), o = Kt(r.customScalars), c = {
2945
- fieldname: n,
2946
- label: Qt(n),
2947
- component: "ATextInput",
2948
- fieldtype: "Data"
2949
- };
2950
- if (a && (c.required = !0), nt(s)) {
2951
- if (Xt.has(s.name))
2952
- return c._unmapped = !0, r.includeUnmappedMeta && (c._graphqlType = s.name), c;
2953
- const l = o[s.name];
2954
- return l ? (c.component = l.component, c.fieldtype = l.fieldtype) : (c._unmapped = !0, r.includeUnmappedMeta && (c._graphqlType = s.name)), c;
2955
- }
2956
- if (rt(s))
2957
- return c.component = "ADropdown", c.fieldtype = "Select", c.options = s.getValues().map((l) => l.name), c;
2958
- if (Q(s)) {
2959
- if (!i && t.has(s.name))
2960
- return c.component = "ALink", c.fieldtype = "Link", c.options = te(s.name), c;
2961
- const l = an(s);
2962
- return l && t.has(l) ? (c.component = "ATable", c.fieldtype = "Doctype", c.options = te(l), c) : i && t.has(s.name) ? (c.component = "ATable", c.fieldtype = "Doctype", c.options = te(s.name), c) : (c._unmapped = !0, r.includeUnmappedMeta && (c._graphqlType = s.name), c);
2963
- }
2964
- return c._unmapped = !0, r.includeUnmappedMeta && (c._graphqlType = s.name), c;
2965
- }
2966
- function En(n, e = {}) {
2967
- const t = cn(n), r = t.getTypeMap(), s = /* @__PURE__ */ new Set(), a = t.getQueryType(), i = t.getMutationType(), o = t.getSubscriptionType();
2968
- a && s.add(a.name), i && s.add(i.name), o && s.add(o.name);
2969
- const c = e.isEntityType ?? nn, l = /* @__PURE__ */ new Set();
2970
- for (const [b, A] of Object.entries(r))
2971
- Q(A) && (s.has(b) || c(b, A) && l.add(b));
2972
- let h = l;
2973
- if (e.include) {
2974
- const b = new Set(e.include);
2975
- h = new Set([...l].filter((A) => b.has(A)));
2976
- }
2977
- if (e.exclude) {
2978
- const b = new Set(e.exclude);
2979
- h = new Set([...h].filter((A) => !b.has(A)));
2980
- }
2981
- const w = e.isEntityField ?? sn, M = e.deriveTableName ?? ((b) => Gt(b)), R = [];
2982
- for (const b of h) {
2983
- const A = r[b];
2984
- if (!Q(A)) continue;
2985
- const et = A.getFields(), Ne = e.typeOverrides?.[b], tt = Object.entries(et).filter(([C, U]) => w(C, U, A)).map(([C, U]) => {
2986
- if (e.classifyField) {
2987
- const L = e.classifyField(C, U, A);
2988
- if (L != null)
2989
- return {
2990
- fieldname: C,
2991
- label: L.label ?? C,
2992
- component: L.component ?? "ATextInput",
2993
- fieldtype: L.fieldtype ?? "Data",
2994
- ...L
2995
- };
2996
- }
2997
- const ue = on(C, U, l, e);
2998
- return Ne?.[C] ? { ...ue, ...Ne[C] } : ue;
2999
- }).map((C) => {
3000
- if (!e.includeUnmappedMeta) {
3001
- const { _graphqlType: U, _unmapped: ue, ...L } = C;
3002
- return L;
3003
- }
3004
- return C;
3005
- }), le = {
3006
- name: b,
3007
- slug: te(b),
3008
- fields: tt
3009
- }, Oe = M(b);
3010
- Oe && (le.tableName = Oe), e.includeUnmappedMeta && (le._graphqlTypeName = b), R.push(le);
3011
- }
3012
- return R;
3013
- }
3014
- function cn(n) {
3015
- return typeof n == "string" ? at(n) : it(n);
3016
- }
3017
- const N = /* @__PURE__ */ new Map();
3018
- class we extends Error {
3019
- constructor(e, t) {
3020
- const r = t.map((s) => ` ${s.path.join(".")}: ${s.message}`).join(`
1
+ import { validateDoctype as D, parseDoctype as M } from "@stonecrop/schema";
2
+ import { ActionDefinition as me, DoctypeMeta as ge, FieldMeta as he, FieldOptions as $e, FieldValidation as Se, GQL_SCALAR_MAP as we, StonecropFieldType as be, TYPE_MAP as Ne, WELL_KNOWN_SCALARS as Re, WorkflowMeta as De, camelToLabel as Me, camelToSnake as ke, classifyFieldType as Ae, convertGraphQLSchema as qe, defaultIsEntityField as Oe, defaultIsEntityType as Be, getDefaultComponent as Fe, parseDoctype as Ce, parseField as Ee, pascalToSnake as je, snakeToCamel as xe, snakeToLabel as Te, toPascalCase as Ie, toSlug as Je, validateDoctype as Le, validateField as _e } from "@stonecrop/schema";
3
+ import { readdirSync as q, statSync as O, readFileSync as B } from "node:fs";
4
+ import { join as F } from "node:path";
5
+ import { extendSchema as C, gql as E } from "postgraphile/utils";
6
+ import { loadOne as w, object as b, constant as j, lambda as x } from "postgraphile/grafast";
7
+ const l = /* @__PURE__ */ new Map();
8
+ class N extends Error {
9
+ constructor(e, o) {
10
+ const n = o.map((r) => ` ${r.path.join(".")}: ${r.message}`).join(`
3021
11
  `);
3022
12
  super(`Invalid doctype definition in ${e}:
3023
- ${r}`), this.file = e, this.errors = t, this.name = "DoctypeValidationError";
13
+ ${n}`), this.file = e, this.errors = o, this.name = "DoctypeValidationError";
3024
14
  }
3025
15
  }
3026
- function dn(n, e = {}) {
3027
- const t = ot(n);
3028
- for (const r of t) {
3029
- const s = lt(n, r);
3030
- ct(s).isDirectory() ? dn(s, e) : r.endsWith(".json") && ln(s, e);
16
+ function T(t, e = {}) {
17
+ const o = q(t);
18
+ for (const n of o) {
19
+ const r = F(t, n);
20
+ O(r).isDirectory() ? T(r, e) : n.endsWith(".json") && I(r, e);
3031
21
  }
3032
22
  }
3033
- function ln(n, e) {
3034
- const t = dt(n, "utf-8");
3035
- let r;
23
+ function I(t, e) {
24
+ const o = B(t, "utf-8");
25
+ let n;
3036
26
  try {
3037
- r = JSON.parse(t);
3038
- } catch (i) {
3039
- const o = {
27
+ n = JSON.parse(o);
28
+ } catch (c) {
29
+ const s = {
3040
30
  path: [],
3041
- message: `Invalid JSON: ${i instanceof Error ? i.message : String(i)}`
31
+ message: `Invalid JSON: ${c instanceof Error ? c.message : String(c)}`
3042
32
  };
3043
33
  if (e.continueOnError) {
3044
- e.onError?.(n, [o]);
34
+ e.onError?.(t, [s]);
3045
35
  return;
3046
36
  }
3047
- throw new we(n, [o]);
37
+ throw new N(t, [s]);
3048
38
  }
3049
- const s = He(r);
3050
- if (!s.success) {
39
+ const r = D(n);
40
+ if (!r.success) {
3051
41
  if (e.continueOnError) {
3052
- e.onError?.(n, s.errors);
42
+ e.onError?.(t, r.errors);
3053
43
  return;
3054
44
  }
3055
- throw new we(n, s.errors);
45
+ throw new N(t, r.errors);
3056
46
  }
3057
- const a = Ye(r);
3058
- N.set(a.name, a);
47
+ const a = M(n);
48
+ l.set(a.name, a);
3059
49
  }
3060
- function Zn(n, e = {}) {
3061
- for (const [t, r] of Object.entries(n)) {
3062
- const s = { ...r, name: t }, a = He(s);
50
+ function ne(t, e = {}) {
51
+ for (const [o, n] of Object.entries(t)) {
52
+ const r = { ...n, name: o }, a = D(r);
3063
53
  if (!a.success) {
3064
54
  if (e.continueOnError) {
3065
- e.onError?.(t, a.errors);
55
+ e.onError?.(o, a.errors);
3066
56
  continue;
3067
57
  }
3068
- throw new we(t, a.errors);
58
+ throw new N(o, a.errors);
3069
59
  }
3070
- const i = Ye(s);
3071
- N.set(i.name, i);
60
+ const c = M(r);
61
+ l.set(c.name, c);
3072
62
  }
3073
63
  }
3074
- function ee(n) {
3075
- return N.get(n);
64
+ function h(t) {
65
+ return l.get(t);
3076
66
  }
3077
- function un() {
3078
- return Array.from(N.values());
67
+ function J() {
68
+ return Array.from(l.values());
3079
69
  }
3080
- function Mn(n) {
3081
- return N.has(n);
70
+ function ae(t) {
71
+ return l.has(t);
3082
72
  }
3083
- function Ln() {
3084
- N.clear();
73
+ function ce() {
74
+ l.clear();
3085
75
  }
3086
- function Pn() {
3087
- const n = [];
3088
- for (const e of N.values()) {
3089
- e.inherits && !N.has(e.inherits) && n.push({
76
+ function se() {
77
+ const t = [];
78
+ for (const e of l.values()) {
79
+ e.inherits && !l.has(e.inherits) && t.push({
3090
80
  path: [e.name, "inherits"],
3091
81
  message: `References unknown doctype: ${e.inherits}`
3092
- }), e.listDoctype && !N.has(e.listDoctype) && n.push({
82
+ }), e.listDoctype && !l.has(e.listDoctype) && t.push({
3093
83
  path: [e.name, "listDoctype"],
3094
84
  message: `References unknown doctype: ${e.listDoctype}`
3095
- }), e.parentDoctype && !N.has(e.parentDoctype) && n.push({
85
+ }), e.parentDoctype && !l.has(e.parentDoctype) && t.push({
3096
86
  path: [e.name, "parentDoctype"],
3097
87
  message: `References unknown doctype: ${e.parentDoctype}`
3098
88
  });
3099
- for (const t of e.fields)
3100
- t.fieldtype === "Link" && typeof t.options == "string" && (N.has(t.options) || n.push({
3101
- path: [e.name, "fields", t.fieldname, "options"],
3102
- message: `Link references unknown doctype: ${t.options}`
89
+ for (const o of e.fields)
90
+ o.fieldtype === "Link" && typeof o.options == "string" && (l.has(o.options) || t.push({
91
+ path: [e.name, "fields", o.fieldname, "options"],
92
+ message: `Link references unknown doctype: ${o.options}`
3103
93
  }));
3104
94
  }
3105
- return n;
95
+ return t;
3106
96
  }
3107
- const de = /* @__PURE__ */ new Map();
3108
- function fn(n, e) {
3109
- de.set(n, e);
97
+ const $ = /* @__PURE__ */ new Map();
98
+ function L(t, e) {
99
+ $.set(t, e);
3110
100
  }
3111
- function pn(n) {
3112
- return de.get(n);
101
+ function _(t) {
102
+ return $.get(t);
3113
103
  }
3114
- function Vn(n) {
3115
- return de.has(n);
104
+ function ie(t) {
105
+ return $.has(t);
3116
106
  }
3117
- function Fn() {
3118
- de.clear();
107
+ function de() {
108
+ $.clear();
3119
109
  }
3120
- const hn = async (n, e) => {
3121
- const [t] = n, { doctype: r } = e, s = [];
3122
- for (const a of r.fields)
3123
- a.required && (t[a.fieldname] === void 0 || t[a.fieldname] === null) && s.push(a.label ?? a.fieldname);
3124
- if (s.length > 0)
3125
- throw new Error(`Missing required fields: ${s.join(", ")}`);
110
+ const G = async (t, e) => {
111
+ const [o] = t, { doctype: n } = e, r = [];
112
+ for (const a of n.fields)
113
+ a.required && (o[a.fieldname] === void 0 || o[a.fieldname] === null) && r.push(a.label ?? a.fieldname);
114
+ if (r.length > 0)
115
+ throw new Error(`Missing required fields: ${r.join(", ")}`);
3126
116
  return { valid: !0 };
3127
- }, mn = async (n, e) => {
3128
- const [t] = n, { doctype: r } = e, s = [];
3129
- for (const a of r.fields) {
3130
- const i = t[a.fieldname];
3131
- if (i == null) continue;
3132
- const o = yn(a.fieldname, i, a.fieldtype);
3133
- o && s.push(o);
3134
- }
3135
- if (s.length > 0)
117
+ }, U = async (t, e) => {
118
+ const [o] = t, { doctype: n } = e, r = [];
119
+ for (const a of n.fields) {
120
+ const c = o[a.fieldname];
121
+ if (c == null) continue;
122
+ const s = H(a.fieldname, c, a.fieldtype);
123
+ s && r.push(s);
124
+ }
125
+ if (r.length > 0)
3136
126
  throw new Error(`Field type validation failed:
3137
- ${s.join(`
127
+ ${r.join(`
3138
128
  `)}`);
3139
129
  return { valid: !0 };
3140
130
  };
3141
- function yn(n, e, t) {
3142
- switch (t) {
131
+ function H(t, e, o) {
132
+ switch (o) {
3143
133
  case "Int":
3144
134
  if (typeof e != "number" || !Number.isInteger(e))
3145
- return `${n}: expected integer, got ${typeof e}`;
135
+ return `${t}: expected integer, got ${typeof e}`;
3146
136
  break;
3147
137
  case "Float":
3148
138
  case "Decimal":
3149
139
  case "Currency":
3150
140
  case "Quantity":
3151
141
  if (typeof e != "number" && typeof e != "string")
3152
- return `${n}: expected number, got ${typeof e}`;
142
+ return `${t}: expected number, got ${typeof e}`;
3153
143
  break;
3154
144
  case "Check":
3155
145
  if (typeof e != "boolean")
3156
- return `${n}: expected boolean, got ${typeof e}`;
146
+ return `${t}: expected boolean, got ${typeof e}`;
3157
147
  break;
3158
148
  case "Data":
3159
149
  case "Text":
3160
150
  case "Code":
3161
151
  case "Link":
3162
152
  if (typeof e != "string")
3163
- return `${n}: expected string, got ${typeof e}`;
153
+ return `${t}: expected string, got ${typeof e}`;
3164
154
  break;
3165
155
  case "Date":
3166
156
  case "Time":
3167
157
  case "Datetime":
3168
158
  if (typeof e != "string" && !(e instanceof Date))
3169
- return `${n}: expected date string or Date, got ${typeof e}`;
159
+ return `${t}: expected date string or Date, got ${typeof e}`;
3170
160
  break;
3171
161
  case "JSON":
3172
162
  if (typeof e != "object")
3173
- return `${n}: expected object, got ${typeof e}`;
163
+ return `${t}: expected object, got ${typeof e}`;
3174
164
  break;
3175
165
  case "Table":
3176
166
  if (!Array.isArray(e))
3177
- return `${n}: expected array, got ${typeof e}`;
167
+ return `${t}: expected array, got ${typeof e}`;
3178
168
  break;
3179
169
  }
3180
170
  return null;
3181
171
  }
3182
- const gn = async () => ({ ok: !0 }), _n = {
3183
- validateRequiredFields: hn,
3184
- validateFieldTypes: mn,
3185
- noop: gn
172
+ const P = async () => ({ ok: !0 }), Q = {
173
+ validateRequiredFields: G,
174
+ validateFieldTypes: U,
175
+ noop: P
3186
176
  };
3187
- function qn() {
3188
- for (const [n, e] of Object.entries(_n))
3189
- fn(n, e);
3190
- }
3191
- const Bn = (n) => ut(() => ({
3192
- typeDefs: ft`
3193
- scalar JSON
3194
-
3195
- type FieldMeta {
177
+ function le() {
178
+ for (const [t, e] of Object.entries(Q))
179
+ L(t, e);
180
+ }
181
+ const pe = (t) => {
182
+ const e = t.inflection?.recordFieldName ?? W, o = t.inflection?.connectionFieldName ?? V, n = t.inflection?.orderByTypeName ?? v;
183
+ return C(() => ({
184
+ typeDefs: E`
185
+ type StonecropFieldMeta {
3196
186
  fieldname: String!
3197
187
  fieldtype: String!
3198
188
  label: String
@@ -3200,7 +190,7 @@ const Bn = (n) => ut(() => ({
3200
190
  options: JSON
3201
191
  }
3202
192
 
3203
- type ActionDefinition {
193
+ type StonecropActionDefinition {
3204
194
  label: String!
3205
195
  handler: String!
3206
196
  requiredFields: [String!]
@@ -3209,216 +199,234 @@ const Bn = (n) => ut(() => ({
3209
199
  args: JSON
3210
200
  }
3211
201
 
3212
- type WorkflowMeta {
202
+ type StonecropWorkflowMeta {
3213
203
  states: [String!]
3214
204
  actions: JSON
3215
205
  }
3216
206
 
3217
- type DoctypeMeta {
207
+ type StonecropDoctypeMeta {
3218
208
  name: String!
3219
209
  tableName: String
3220
- fields: [FieldMeta!]!
3221
- workflow: WorkflowMeta
210
+ fields: [StonecropFieldMeta!]!
211
+ workflow: StonecropWorkflowMeta
3222
212
  listDoctype: String
3223
213
  parentDoctype: String
3224
214
  }
3225
215
 
3226
- type RecordResult {
216
+ type StonecropRecordResult {
3227
217
  data: JSON
3228
218
  doctype: String!
3229
219
  }
3230
220
 
3231
- type RecordsResult {
221
+ type StonecropRecordsResult {
3232
222
  data: [JSON!]!
3233
223
  doctype: String!
3234
224
  count: Int!
3235
225
  }
3236
226
 
3237
- type ActionResult {
227
+ type StonecropActionResult {
3238
228
  success: Boolean!
3239
229
  data: JSON
3240
230
  error: String
3241
231
  }
3242
232
 
3243
- type Query {
3244
- stonecropMeta(doctype: String!): DoctypeMeta
3245
- stonecropAllMeta: [DoctypeMeta!]!
3246
- stonecropRecord(doctype: String!, id: String!): RecordResult
3247
- stonecropRecords(doctype: String!, filters: JSON, orderBy: String, limit: Int, offset: Int): RecordsResult
233
+ extend type Query {
234
+ stonecropMeta(doctype: String!): StonecropDoctypeMeta
235
+ stonecropAllMeta: [StonecropDoctypeMeta!]!
236
+ stonecropRecord(doctype: String!, id: String!): StonecropRecordResult
237
+ stonecropRecords(
238
+ doctype: String!
239
+ filters: JSON
240
+ orderBy: String
241
+ limit: Int
242
+ offset: Int
243
+ ): StonecropRecordsResult
3248
244
  }
3249
245
 
3250
- type Mutation {
3251
- stonecropAction(doctype: String!, action: String!, args: JSON): ActionResult!
246
+ extend type Mutation {
247
+ stonecropAction(doctype: String!, action: String!, args: JSON): StonecropActionResult!
3252
248
  }
3253
249
  `,
3254
- objects: {
3255
- Query: {
3256
- plans: {
3257
- stonecropMeta(e, t) {
3258
- const r = t.getRaw().doctype;
3259
- return ht(r, (s) => ee(s) ?? null);
3260
- },
3261
- stonecropAllMeta() {
3262
- return pt(un());
3263
- },
3264
- stonecropRecord(e, t) {
3265
- const r = t.getRaw().doctype, s = t.getRaw().id;
3266
- return fe(pe({ doctype: r, id: s }), async (a) => await Promise.all(
3267
- a.map(async (i) => {
3268
- const o = ee(i.doctype);
3269
- if (!o)
3270
- throw new Error(`Unknown doctype: ${i.doctype}`);
3271
- if (!o.tableName)
3272
- throw new Error(`Doctype ${i.doctype} has no table mapping`);
3273
- const c = vn(o), l = await n.executor.query(c, { id: i.id });
3274
- return {
3275
- data: xn(l, o),
3276
- doctype: i.doctype
3277
- };
3278
- })
3279
- ));
3280
- },
3281
- stonecropRecords(e, t) {
3282
- const r = t.getRaw(), s = r.doctype, a = r.filters, i = r.orderBy, o = r.limit, c = r.offset;
3283
- return fe(
3284
- pe({
3285
- doctype: s,
3286
- filters: a,
3287
- orderBy: i,
3288
- limit: o,
3289
- offset: c
3290
- }),
3291
- async (l) => await Promise.all(
3292
- l.map(async (h) => {
3293
- const w = ee(h.doctype);
3294
- if (!w)
3295
- throw new Error(`Unknown doctype: ${h.doctype}`);
3296
- if (!w.tableName)
3297
- throw new Error(`Doctype ${h.doctype} has no table mapping`);
3298
- const M = kn(w, {
3299
- limit: h.limit,
3300
- offset: h.offset,
3301
- orderBy: h.orderBy
3302
- }), R = await n.executor.query(M, {
3303
- limit: h.limit,
3304
- offset: h.offset,
3305
- orderBy: h.orderBy
3306
- }), b = bn(R, w);
250
+ objects: {
251
+ Query: {
252
+ plans: {
253
+ stonecropMeta(r, a) {
254
+ const c = a.getRaw().doctype;
255
+ return x(c, (s) => h(s) ?? null);
256
+ },
257
+ stonecropAllMeta() {
258
+ return j(J());
259
+ },
260
+ stonecropRecord(r, a) {
261
+ const c = a.getRaw().doctype, s = a.getRaw().id;
262
+ return w(b({ doctype: c, id: s }), async (y) => await Promise.all(
263
+ y.map(async (d) => {
264
+ const u = h(d.doctype);
265
+ if (!u)
266
+ throw new Error(`Unknown doctype: ${d.doctype}`);
267
+ if (!u.tableName)
268
+ throw new Error(`Doctype ${d.doctype} has no table mapping`);
269
+ const p = z(u, e), f = await t.executor.query(p, { id: d.id });
3307
270
  return {
3308
- data: b,
3309
- doctype: h.doctype,
3310
- count: b.length
271
+ data: Y(f, u, e),
272
+ doctype: d.doctype
3311
273
  };
3312
274
  })
3313
- )
3314
- );
3315
- }
3316
- }
3317
- },
3318
- Mutation: {
3319
- plans: {
3320
- stonecropAction(e, t) {
3321
- const r = t.getRaw(), s = r.doctype, a = r.action, i = r.args;
3322
- return fe(
3323
- pe({
3324
- doctype: s,
3325
- action: a,
3326
- actionArgs: i
3327
- }),
3328
- async (o) => await Promise.all(
3329
- o.map(async (c) => {
3330
- const l = ee(c.doctype);
3331
- if (!l)
3332
- return {
3333
- success: !1,
3334
- data: null,
3335
- error: `Unknown doctype: ${c.doctype}`
3336
- };
3337
- const h = l.workflow?.actions?.[c.action];
3338
- if (!h)
3339
- return {
3340
- success: !1,
3341
- data: null,
3342
- error: `Unknown action: ${c.action} on ${c.doctype}`
3343
- };
3344
- const w = pn(h.handler);
3345
- if (!w)
3346
- return {
3347
- success: !1,
3348
- data: null,
3349
- error: `Handler not registered: ${h.handler}`
3350
- };
3351
- const M = {
3352
- doctype: l,
3353
- executor: n.executor
3354
- };
3355
- try {
275
+ ));
276
+ },
277
+ stonecropRecords(r, a) {
278
+ const c = a.getRaw(), s = c.doctype, y = c.filters, d = c.orderBy, u = c.limit, p = c.offset;
279
+ return w(
280
+ b({
281
+ doctype: s,
282
+ filters: y,
283
+ orderBy: d,
284
+ limit: u,
285
+ offset: p
286
+ }),
287
+ async (f) => await Promise.all(
288
+ f.map(async (i) => {
289
+ const m = h(i.doctype);
290
+ if (!m)
291
+ throw new Error(`Unknown doctype: ${i.doctype}`);
292
+ if (!m.tableName)
293
+ throw new Error(`Doctype ${i.doctype} has no table mapping`);
294
+ const S = K(
295
+ m,
296
+ {
297
+ limit: i.limit,
298
+ offset: i.offset,
299
+ orderBy: i.orderBy
300
+ },
301
+ o,
302
+ n
303
+ ), g = await t.executor.query(S, {
304
+ limit: i.limit,
305
+ offset: i.offset,
306
+ orderBy: i.orderBy
307
+ }), R = X(g, m, o);
3356
308
  return {
3357
- success: !0,
3358
- data: await w(c.actionArgs ?? [], M),
3359
- error: null
309
+ data: R,
310
+ doctype: i.doctype,
311
+ count: R.length
3360
312
  };
3361
- } catch (R) {
3362
- return {
3363
- success: !1,
3364
- data: null,
3365
- error: R instanceof Error ? R.message : String(R)
313
+ })
314
+ )
315
+ );
316
+ }
317
+ }
318
+ },
319
+ Mutation: {
320
+ plans: {
321
+ stonecropAction(r, a) {
322
+ const c = a.getRaw(), s = c.doctype, y = c.action, d = c.args;
323
+ return w(
324
+ b({
325
+ doctype: s,
326
+ action: y,
327
+ actionArgs: d
328
+ }),
329
+ async (u) => await Promise.all(
330
+ u.map(async (p) => {
331
+ const f = h(p.doctype);
332
+ if (!f)
333
+ return {
334
+ success: !1,
335
+ data: null,
336
+ error: `Unknown doctype: ${p.doctype}`
337
+ };
338
+ const i = f.workflow?.actions?.[p.action];
339
+ if (!i)
340
+ return {
341
+ success: !1,
342
+ data: null,
343
+ error: `Unknown action: ${p.action} on ${p.doctype}`
344
+ };
345
+ const m = _(i.handler);
346
+ if (!m)
347
+ return {
348
+ success: !1,
349
+ data: null,
350
+ error: `Handler not registered: ${i.handler}`
351
+ };
352
+ const S = {
353
+ doctype: f,
354
+ executor: t.executor
3366
355
  };
3367
- }
3368
- })
3369
- )
3370
- );
356
+ try {
357
+ return {
358
+ success: !0,
359
+ data: await m(p.actionArgs ?? [], S),
360
+ error: null
361
+ };
362
+ } catch (g) {
363
+ return {
364
+ success: !1,
365
+ data: null,
366
+ error: g instanceof Error ? g.message : String(g)
367
+ };
368
+ }
369
+ })
370
+ )
371
+ );
372
+ }
3371
373
  }
3372
374
  }
3373
375
  }
3374
- }
3375
- }));
3376
- function Ce(n) {
3377
- return n.replace(/_([a-z])/g, (e, t) => t.toUpperCase());
376
+ }));
377
+ };
378
+ function k(t) {
379
+ return t.replace(/_([a-z])/g, (e, o) => o.toUpperCase());
380
+ }
381
+ function A(t) {
382
+ const e = k(t);
383
+ return e.charAt(0).toUpperCase() + e.slice(1);
384
+ }
385
+ function W(t) {
386
+ const e = t.replace(/s$/, "");
387
+ return `${k(e)}ById`;
3378
388
  }
3379
- function Xe(n) {
3380
- const e = Ce(n);
3381
- return `all${e.charAt(0).toUpperCase()}${e.slice(1)}`;
389
+ function V(t) {
390
+ return `all${A(t)}`;
3382
391
  }
3383
- function Ke(n) {
3384
- const e = n.replace(/s$/, "");
3385
- return Ce(e);
392
+ function v(t) {
393
+ return `${A(t)}OrderBy`;
3386
394
  }
3387
- function vn(n) {
3388
- const e = n.fields.map((r) => r.fieldname).join(`
395
+ function z(t, e) {
396
+ const o = t.fields.map((r) => r.fieldname).join(`
3389
397
  `);
3390
398
  return `
3391
399
  query GetRecord($id: UUID!) {
3392
- ${`${Ke(n.tableName)}ById`}(id: $id) {
3393
- ${e}
400
+ ${e(t.tableName)}(id: $id) {
401
+ ${o}
3394
402
  }
3395
403
  }
3396
404
  `;
3397
405
  }
3398
- function kn(n, e) {
3399
- const t = n.fields.map((i) => i.fieldname).join(`
3400
- `), r = Xe(n.tableName), s = [];
406
+ function K(t, e, o, n) {
407
+ const r = t.fields.map((d) => d.fieldname).join(`
408
+ `), a = o(t.tableName), c = n(t.tableName), s = [];
3401
409
  e.limit && s.push("first: $limit"), e.offset && s.push("offset: $offset"), e.orderBy && s.push("orderBy: $orderBy");
3402
- const a = s.length > 0 ? `(${s.join(", ")})` : "";
410
+ const y = s.length > 0 ? `(${s.join(", ")})` : "";
3403
411
  return `
3404
- query GetRecords($limit: Int, $offset: Int, $orderBy: [${Ce(n.tableName)}OrderBy!]) {
3405
- ${r}${a} {
412
+ query GetRecords($limit: Int, $offset: Int, $orderBy: [${c}!]) {
413
+ ${a}${y} {
3406
414
  nodes {
3407
- ${t}
415
+ ${r}
3408
416
  }
3409
417
  }
3410
418
  }
3411
419
  `;
3412
420
  }
3413
- function xn(n, e) {
3414
- const t = `${Ke(e.tableName)}ById`;
3415
- return n[t];
421
+ function Y(t, e, o) {
422
+ const n = o(e.tableName);
423
+ return t[n];
3416
424
  }
3417
- function bn(n, e) {
3418
- const t = Xe(e.tableName);
3419
- return n[t]?.nodes ?? [];
425
+ function X(t, e, o) {
426
+ const n = o(e.tableName);
427
+ return t[n]?.nodes ?? [];
3420
428
  }
3421
- class zn {
429
+ class ye {
3422
430
  endpoint;
3423
431
  headers;
3424
432
  metaCache = /* @__PURE__ */ new Map();
@@ -3433,32 +441,32 @@ class zn {
3433
441
  * @param query - GraphQL query string
3434
442
  * @param variables - Query variables
3435
443
  */
3436
- async query(e, t) {
3437
- const s = await (await fetch(this.endpoint, {
444
+ async query(e, o) {
445
+ const r = await (await fetch(this.endpoint, {
3438
446
  method: "POST",
3439
447
  headers: this.headers,
3440
- body: JSON.stringify({ query: e, variables: t })
448
+ body: JSON.stringify({ query: e, variables: o })
3441
449
  })).json();
3442
- if (s.errors?.length)
3443
- throw new Error(s.errors[0].message);
3444
- return s.data;
450
+ if (r.errors?.length)
451
+ throw new Error(r.errors[0].message);
452
+ return r.data;
3445
453
  }
3446
454
  /**
3447
455
  * Execute a GraphQL mutation
3448
456
  * @param mutation - GraphQL mutation string
3449
457
  * @param variables - Mutation variables
3450
458
  */
3451
- async mutate(e, t) {
3452
- return this.query(e, t);
459
+ async mutate(e, o) {
460
+ return this.query(e, o);
3453
461
  }
3454
462
  /**
3455
463
  * Get doctype metadata
3456
464
  * @param context - Route context containing doctype name
3457
465
  */
3458
466
  async getMeta(e) {
3459
- const t = this.metaCache.get(e.doctype);
3460
- if (t) return t;
3461
- const r = await this.query(
467
+ const o = this.metaCache.get(e.doctype);
468
+ if (o) return o;
469
+ const n = await this.query(
3462
470
  `
3463
471
  query GetMeta($doctype: String!) {
3464
472
  stonecropMeta(doctype: $doctype) {
@@ -3488,7 +496,7 @@ class zn {
3488
496
  `,
3489
497
  { doctype: e.doctype }
3490
498
  );
3491
- return r.stonecropMeta && this.metaCache.set(e.doctype, r.stonecropMeta), r.stonecropMeta;
499
+ return n.stonecropMeta && this.metaCache.set(e.doctype, n.stonecropMeta), n.stonecropMeta;
3492
500
  }
3493
501
  /**
3494
502
  * Get all doctype metadata
@@ -3523,8 +531,8 @@ class zn {
3523
531
  }
3524
532
  `
3525
533
  );
3526
- for (const t of e.stonecropAllMeta)
3527
- this.metaCache.set(t.name, t);
534
+ for (const o of e.stonecropAllMeta)
535
+ this.metaCache.set(o.name, o);
3528
536
  return e.stonecropAllMeta;
3529
537
  }
3530
538
  /**
@@ -3532,7 +540,7 @@ class zn {
3532
540
  * @param doctype - Doctype metadata
3533
541
  * @param recordId - Record ID to fetch
3534
542
  */
3535
- async getRecord(e, t) {
543
+ async getRecord(e, o) {
3536
544
  return (await this.query(
3537
545
  `
3538
546
  query GetRecord($doctype: String!, $id: String!) {
@@ -3541,7 +549,7 @@ class zn {
3541
549
  }
3542
550
  }
3543
551
  `,
3544
- { doctype: e.name, id: t }
552
+ { doctype: e.name, id: o }
3545
553
  )).stonecropRecord.data;
3546
554
  }
3547
555
  /**
@@ -3549,7 +557,7 @@ class zn {
3549
557
  * @param doctype - Doctype metadata
3550
558
  * @param options - Query options (filters, orderBy, limit, offset)
3551
559
  */
3552
- async getRecords(e, t) {
560
+ async getRecords(e, o) {
3553
561
  return (await this.query(
3554
562
  `
3555
563
  query GetRecords(
@@ -3573,7 +581,7 @@ class zn {
3573
581
  `,
3574
582
  {
3575
583
  doctype: e.name,
3576
- ...t
584
+ ...o
3577
585
  }
3578
586
  )).stonecropRecords.data;
3579
587
  }
@@ -3583,7 +591,7 @@ class zn {
3583
591
  * @param action - Action name to execute
3584
592
  * @param args - Action arguments
3585
593
  */
3586
- async runAction(e, t, r) {
594
+ async runAction(e, o, n) {
3587
595
  return (await this.query(
3588
596
  `
3589
597
  mutation RunAction($doctype: String!, $action: String!, $args: JSON) {
@@ -3596,8 +604,8 @@ class zn {
3596
604
  `,
3597
605
  {
3598
606
  doctype: e.name,
3599
- action: t,
3600
- args: r
607
+ action: o,
608
+ args: n
3601
609
  }
3602
610
  )).stonecropAction;
3603
611
  }
@@ -3609,46 +617,46 @@ class zn {
3609
617
  }
3610
618
  }
3611
619
  export {
3612
- Jt as ActionDefinition,
3613
- Ge as DoctypeMeta,
3614
- we as DoctypeValidationError,
3615
- Ae as FieldMeta,
3616
- zt as FieldOptions,
3617
- Ut as FieldValidation,
3618
- Ht as GQL_SCALAR_MAP,
3619
- zn as StonecropClient,
3620
- qt as StonecropFieldType,
3621
- Bt as TYPE_MAP,
3622
- Yt as WELL_KNOWN_SCALARS,
3623
- Wt as WorkflowMeta,
3624
- _n as builtinHandlers,
3625
- Qt as camelToLabel,
3626
- In as camelToSnake,
3627
- on as classifyFieldType,
3628
- Fn as clearHandlers,
3629
- Ln as clearRegistry,
3630
- En as convertGraphQLSchema,
3631
- Bn as createStonecropPlugin,
3632
- sn as defaultIsEntityField,
3633
- nn as defaultIsEntityType,
3634
- un as getAllMeta,
3635
- Nn as getDefaultComponent,
3636
- pn as getHandler,
3637
- ee as getMeta,
3638
- Vn as hasHandler,
3639
- Mn as hasMeta,
3640
- dn as loadDoctypes,
3641
- Zn as loadDoctypesFromObject,
3642
- Ye as parseDoctype,
3643
- $n as parseField,
3644
- Gt as pascalToSnake,
3645
- qn as registerBuiltinHandlers,
3646
- fn as registerHandler,
3647
- Rn as snakeToCamel,
3648
- Dn as snakeToLabel,
3649
- jn as toPascalCase,
3650
- te as toSlug,
3651
- He as validateDoctype,
3652
- On as validateField,
3653
- Pn as validateReferences
620
+ me as ActionDefinition,
621
+ ge as DoctypeMeta,
622
+ N as DoctypeValidationError,
623
+ he as FieldMeta,
624
+ $e as FieldOptions,
625
+ Se as FieldValidation,
626
+ we as GQL_SCALAR_MAP,
627
+ ye as StonecropClient,
628
+ be as StonecropFieldType,
629
+ Ne as TYPE_MAP,
630
+ Re as WELL_KNOWN_SCALARS,
631
+ De as WorkflowMeta,
632
+ Q as builtinHandlers,
633
+ Me as camelToLabel,
634
+ ke as camelToSnake,
635
+ Ae as classifyFieldType,
636
+ de as clearHandlers,
637
+ ce as clearRegistry,
638
+ qe as convertGraphQLSchema,
639
+ pe as createStonecropPlugin,
640
+ Oe as defaultIsEntityField,
641
+ Be as defaultIsEntityType,
642
+ J as getAllMeta,
643
+ Fe as getDefaultComponent,
644
+ _ as getHandler,
645
+ h as getMeta,
646
+ ie as hasHandler,
647
+ ae as hasMeta,
648
+ T as loadDoctypes,
649
+ ne as loadDoctypesFromObject,
650
+ Ce as parseDoctype,
651
+ Ee as parseField,
652
+ je as pascalToSnake,
653
+ le as registerBuiltinHandlers,
654
+ L as registerHandler,
655
+ xe as snakeToCamel,
656
+ Te as snakeToLabel,
657
+ Ie as toPascalCase,
658
+ Je as toSlug,
659
+ Le as validateDoctype,
660
+ _e as validateField,
661
+ se as validateReferences
3654
662
  };