@budibase/backend-core 3.2.43 → 3.2.44

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/plugins.js CHANGED
@@ -1,4364 +1,2 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/plugin/index.ts
31
- var plugin_exports = {};
32
- __export(plugin_exports, {
33
- validate: () => validate
34
- });
35
- module.exports = __toCommonJS(plugin_exports);
36
-
37
- // ../types/src/sdk/events/event.ts
38
- var UserGroupSyncEvents = [
39
- "user:created" /* USER_CREATED */,
40
- "user:updated" /* USER_UPDATED */,
41
- "user:deleted" /* USER_DELETED */,
42
- "user:admin:assigned" /* USER_PERMISSION_ADMIN_ASSIGNED */,
43
- "user:admin:removed" /* USER_PERMISSION_ADMIN_REMOVED */,
44
- "user:builder:assigned" /* USER_PERMISSION_BUILDER_ASSIGNED */,
45
- "user:builder:removed" /* USER_PERMISSION_BUILDER_REMOVED */,
46
- "user_group:created" /* USER_GROUP_CREATED */,
47
- "user_group:updated" /* USER_GROUP_UPDATED */,
48
- "user_group:deleted" /* USER_GROUP_DELETED */,
49
- "user_group:user_added" /* USER_GROUP_USERS_ADDED */,
50
- "user_group:users_deleted" /* USER_GROUP_USERS_REMOVED */,
51
- "user_group:permissions_edited" /* USER_GROUP_PERMISSIONS_EDITED */
52
- ];
53
- var AsyncEvents = [...UserGroupSyncEvents];
54
-
55
- // ../types/src/sdk/datasources.ts
56
- var QueryType = /* @__PURE__ */ ((QueryType2) => {
57
- QueryType2["SQL"] = "sql";
58
- QueryType2["JSON"] = "json";
59
- QueryType2["FIELDS"] = "fields";
60
- return QueryType2;
61
- })(QueryType || {});
62
- var DatasourceFieldType = /* @__PURE__ */ ((DatasourceFieldType2) => {
63
- DatasourceFieldType2["STRING"] = "string";
64
- DatasourceFieldType2["CODE"] = "code";
65
- DatasourceFieldType2["LONGFORM"] = "longForm";
66
- DatasourceFieldType2["BOOLEAN"] = "boolean";
67
- DatasourceFieldType2["NUMBER"] = "number";
68
- DatasourceFieldType2["PASSWORD"] = "password";
69
- DatasourceFieldType2["LIST"] = "list";
70
- DatasourceFieldType2["OBJECT"] = "object";
71
- DatasourceFieldType2["JSON"] = "json";
72
- DatasourceFieldType2["FILE"] = "file";
73
- DatasourceFieldType2["FIELD_GROUP"] = "fieldGroup";
74
- DatasourceFieldType2["SELECT"] = "select";
75
- return DatasourceFieldType2;
76
- })(DatasourceFieldType || {});
77
- var DatasourceFeature = /* @__PURE__ */ ((DatasourceFeature2) => {
78
- DatasourceFeature2["CONNECTION_CHECKING"] = "connection";
79
- DatasourceFeature2["FETCH_TABLE_NAMES"] = "fetch_table_names";
80
- DatasourceFeature2["EXPORT_SCHEMA"] = "export_schema";
81
- return DatasourceFeature2;
82
- })(DatasourceFeature || {});
83
-
84
- // ../types/src/sdk/search.ts
85
- var EmptyFilterOption = /* @__PURE__ */ ((EmptyFilterOption2) => {
86
- EmptyFilterOption2["RETURN_ALL"] = "all";
87
- EmptyFilterOption2["RETURN_NONE"] = "none";
88
- return EmptyFilterOption2;
89
- })(EmptyFilterOption || {});
90
-
91
- // ../types/src/sdk/cli/constants.ts
92
- var AnalyticsEvent = {
93
- OptOut: "analytics:opt:out",
94
- OptIn: "analytics:opt:in",
95
- SelfHostInit: "hosting:init",
96
- PluginInit: "plugin:init" /* PLUGIN_INIT */
97
- };
98
-
99
- // ../types/src/documents/app/automation/automation.ts
100
- var AutomationIOType = /* @__PURE__ */ ((AutomationIOType2) => {
101
- AutomationIOType2["OBJECT"] = "object";
102
- AutomationIOType2["STRING"] = "string";
103
- AutomationIOType2["BOOLEAN"] = "boolean";
104
- AutomationIOType2["NUMBER"] = "number";
105
- AutomationIOType2["ARRAY"] = "array";
106
- AutomationIOType2["JSON"] = "json";
107
- AutomationIOType2["DATE"] = "date";
108
- AutomationIOType2["ATTACHMENT"] = "attachment";
109
- return AutomationIOType2;
110
- })(AutomationIOType || {});
111
- var AutomationCustomIOType = /* @__PURE__ */ ((AutomationCustomIOType2) => {
112
- AutomationCustomIOType2["TABLE"] = "table";
113
- AutomationCustomIOType2["ROW"] = "row";
114
- AutomationCustomIOType2["ROWS"] = "rows";
115
- AutomationCustomIOType2["WIDE"] = "wide";
116
- AutomationCustomIOType2["QUERY"] = "query";
117
- AutomationCustomIOType2["QUERY_PARAMS"] = "queryParams";
118
- AutomationCustomIOType2["QUERY_LIMIT"] = "queryLimit";
119
- AutomationCustomIOType2["LOOP_OPTION"] = "loopOption";
120
- AutomationCustomIOType2["ITEM"] = "item";
121
- AutomationCustomIOType2["CODE"] = "code";
122
- AutomationCustomIOType2["FILTERS"] = "filters";
123
- AutomationCustomIOType2["COLUMN"] = "column";
124
- AutomationCustomIOType2["TRIGGER_SCHEMA"] = "triggerSchema";
125
- AutomationCustomIOType2["CRON"] = "cron";
126
- AutomationCustomIOType2["WEBHOOK_URL"] = "webhookUrl";
127
- AutomationCustomIOType2["AUTOMATION"] = "automation";
128
- AutomationCustomIOType2["AUTOMATION_FIELDS"] = "automationFields";
129
- AutomationCustomIOType2["MULTI_ATTACHMENTS"] = "multi_attachments";
130
- AutomationCustomIOType2["TRIGGER_FILTER"] = "trigger_filter";
131
- return AutomationCustomIOType2;
132
- })(AutomationCustomIOType || {});
133
- var AutomationTriggerStepId = /* @__PURE__ */ ((AutomationTriggerStepId2) => {
134
- AutomationTriggerStepId2["ROW_SAVED"] = "ROW_SAVED";
135
- AutomationTriggerStepId2["ROW_UPDATED"] = "ROW_UPDATED";
136
- AutomationTriggerStepId2["ROW_DELETED"] = "ROW_DELETED";
137
- AutomationTriggerStepId2["WEBHOOK"] = "WEBHOOK";
138
- AutomationTriggerStepId2["APP"] = "APP";
139
- AutomationTriggerStepId2["CRON"] = "CRON";
140
- AutomationTriggerStepId2["ROW_ACTION"] = "ROW_ACTION";
141
- return AutomationTriggerStepId2;
142
- })(AutomationTriggerStepId || {});
143
- var AutomationActionStepId = /* @__PURE__ */ ((AutomationActionStepId2) => {
144
- AutomationActionStepId2["SEND_EMAIL_SMTP"] = "SEND_EMAIL_SMTP";
145
- AutomationActionStepId2["CREATE_ROW"] = "CREATE_ROW";
146
- AutomationActionStepId2["UPDATE_ROW"] = "UPDATE_ROW";
147
- AutomationActionStepId2["DELETE_ROW"] = "DELETE_ROW";
148
- AutomationActionStepId2["EXECUTE_BASH"] = "EXECUTE_BASH";
149
- AutomationActionStepId2["OUTGOING_WEBHOOK"] = "OUTGOING_WEBHOOK";
150
- AutomationActionStepId2["EXECUTE_SCRIPT"] = "EXECUTE_SCRIPT";
151
- AutomationActionStepId2["EXECUTE_QUERY"] = "EXECUTE_QUERY";
152
- AutomationActionStepId2["SERVER_LOG"] = "SERVER_LOG";
153
- AutomationActionStepId2["DELAY"] = "DELAY";
154
- AutomationActionStepId2["FILTER"] = "FILTER";
155
- AutomationActionStepId2["QUERY_ROWS"] = "QUERY_ROWS";
156
- AutomationActionStepId2["LOOP"] = "LOOP";
157
- AutomationActionStepId2["COLLECT"] = "COLLECT";
158
- AutomationActionStepId2["OPENAI"] = "OPENAI";
159
- AutomationActionStepId2["TRIGGER_AUTOMATION_RUN"] = "TRIGGER_AUTOMATION_RUN";
160
- AutomationActionStepId2["BRANCH"] = "BRANCH";
161
- AutomationActionStepId2["discord"] = "discord";
162
- AutomationActionStepId2["slack"] = "slack";
163
- AutomationActionStepId2["zapier"] = "zapier";
164
- AutomationActionStepId2["integromat"] = "integromat";
165
- AutomationActionStepId2["n8n"] = "n8n";
166
- return AutomationActionStepId2;
167
- })(AutomationActionStepId || {});
168
- var AutomationStepIdArray = [
169
- ...Object.values(AutomationActionStepId),
170
- ...Object.values(AutomationTriggerStepId)
171
- ];
172
-
173
- // ../types/src/documents/document.ts
174
- var DocumentType = /* @__PURE__ */ ((DocumentType2) => {
175
- DocumentType2["USER"] = "us";
176
- DocumentType2["GROUP"] = "gr";
177
- DocumentType2["WORKSPACE"] = "workspace";
178
- DocumentType2["CONFIG"] = "config";
179
- DocumentType2["TEMPLATE"] = "template";
180
- DocumentType2["APP"] = "app";
181
- DocumentType2["DEV"] = "dev";
182
- DocumentType2["APP_DEV"] = "app_dev";
183
- DocumentType2["APP_METADATA"] = "app_metadata";
184
- DocumentType2["ROLE"] = "role";
185
- DocumentType2["MIGRATIONS"] = "migrations";
186
- DocumentType2["DEV_INFO"] = "devinfo";
187
- DocumentType2["AUTOMATION_LOG"] = "log_au";
188
- DocumentType2["ACCOUNT_METADATA"] = "acc_metadata";
189
- DocumentType2["PLUGIN"] = "plg";
190
- DocumentType2["DATASOURCE"] = "datasource";
191
- DocumentType2["DATASOURCE_PLUS"] = "datasource_plus";
192
- DocumentType2["APP_BACKUP"] = "backup";
193
- DocumentType2["TABLE"] = "ta";
194
- DocumentType2["ROW"] = "ro";
195
- DocumentType2["AUTOMATION"] = "au";
196
- DocumentType2["LINK"] = "li";
197
- DocumentType2["WEBHOOK"] = "wh";
198
- DocumentType2["INSTANCE"] = "inst";
199
- DocumentType2["LAYOUT"] = "layout";
200
- DocumentType2["SCREEN"] = "screen";
201
- DocumentType2["QUERY"] = "query";
202
- DocumentType2["DEPLOYMENTS"] = "deployments";
203
- DocumentType2["METADATA"] = "metadata";
204
- DocumentType2["MEM_VIEW"] = "view";
205
- DocumentType2["USER_FLAG"] = "flag";
206
- DocumentType2["AUTOMATION_METADATA"] = "meta_au";
207
- DocumentType2["AUDIT_LOG"] = "al";
208
- DocumentType2["APP_MIGRATION_METADATA"] = "_design/migrations";
209
- DocumentType2["SCIM_LOG"] = "scimlog";
210
- DocumentType2["ROW_ACTIONS"] = "ra";
211
- return DocumentType2;
212
- })(DocumentType || {});
213
- var sortedDocumentTypes = Object.values(DocumentType).sort(
214
- (a, b) => b.length - a.length
215
- // descending
216
- );
217
- var VirtualDocumentType = /* @__PURE__ */ ((VirtualDocumentType2) => {
218
- VirtualDocumentType2["VIEW"] = "view";
219
- VirtualDocumentType2["ROW_ACTION"] = "row_action";
220
- return VirtualDocumentType2;
221
- })(VirtualDocumentType || {});
222
- var sortedVirtualDocumentTypes = Object.values(VirtualDocumentType).sort(
223
- (a, b) => b.length - a.length
224
- // descending
225
- );
226
-
227
- // ../types/src/documents/global/plugin.ts
228
- var PluginType = /* @__PURE__ */ ((PluginType2) => {
229
- PluginType2["DATASOURCE"] = "datasource";
230
- PluginType2["COMPONENT"] = "component";
231
- PluginType2["AUTOMATION"] = "automation";
232
- return PluginType2;
233
- })(PluginType || {});
234
- var PLUGIN_TYPE_ARR = Object.values(PluginType);
235
-
236
- // ../types/src/documents/global/quotas.ts
237
- var APP_QUOTA_NAMES = [
238
- "rows" /* ROWS */,
239
- "queries" /* QUERIES */,
240
- "automations" /* AUTOMATIONS */
241
- ];
242
- var BREAKDOWN_QUOTA_NAMES = [
243
- "queries" /* QUERIES */,
244
- "automations" /* AUTOMATIONS */
245
- ];
246
-
247
- // ../types/src/api/web/pagination.ts
248
- var SortOrder = /* @__PURE__ */ ((SortOrder2) => {
249
- SortOrder2["ASCENDING"] = "ascending";
250
- SortOrder2["DESCENDING"] = "descending";
251
- return SortOrder2;
252
- })(SortOrder || {});
253
- var SortType = /* @__PURE__ */ ((SortType2) => {
254
- SortType2["STRING"] = "string";
255
- SortType2["NUMBER"] = "number";
256
- return SortType2;
257
- })(SortType || {});
258
-
259
- // ../../node_modules/zod/lib/index.mjs
260
- var util;
261
- (function(util2) {
262
- util2.assertEqual = (val) => val;
263
- function assertIs(_arg) {
264
- }
265
- util2.assertIs = assertIs;
266
- function assertNever(_x) {
267
- throw new Error();
268
- }
269
- util2.assertNever = assertNever;
270
- util2.arrayToEnum = (items) => {
271
- const obj = {};
272
- for (const item of items) {
273
- obj[item] = item;
274
- }
275
- return obj;
276
- };
277
- util2.getValidEnumValues = (obj) => {
278
- const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
279
- const filtered = {};
280
- for (const k of validKeys) {
281
- filtered[k] = obj[k];
282
- }
283
- return util2.objectValues(filtered);
284
- };
285
- util2.objectValues = (obj) => {
286
- return util2.objectKeys(obj).map(function(e) {
287
- return obj[e];
288
- });
289
- };
290
- util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
291
- const keys = [];
292
- for (const key in object) {
293
- if (Object.prototype.hasOwnProperty.call(object, key)) {
294
- keys.push(key);
295
- }
296
- }
297
- return keys;
298
- };
299
- util2.find = (arr, checker) => {
300
- for (const item of arr) {
301
- if (checker(item))
302
- return item;
303
- }
304
- return void 0;
305
- };
306
- util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
307
- function joinValues(array, separator = " | ") {
308
- return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
309
- }
310
- util2.joinValues = joinValues;
311
- util2.jsonStringifyReplacer = (_, value) => {
312
- if (typeof value === "bigint") {
313
- return value.toString();
314
- }
315
- return value;
316
- };
317
- })(util || (util = {}));
318
- var objectUtil;
319
- (function(objectUtil2) {
320
- objectUtil2.mergeShapes = (first, second) => {
321
- return {
322
- ...first,
323
- ...second
324
- // second overwrites first
325
- };
326
- };
327
- })(objectUtil || (objectUtil = {}));
328
- var ZodParsedType = util.arrayToEnum([
329
- "string",
330
- "nan",
331
- "number",
332
- "integer",
333
- "float",
334
- "boolean",
335
- "date",
336
- "bigint",
337
- "symbol",
338
- "function",
339
- "undefined",
340
- "null",
341
- "array",
342
- "object",
343
- "unknown",
344
- "promise",
345
- "void",
346
- "never",
347
- "map",
348
- "set"
349
- ]);
350
- var getParsedType = (data) => {
351
- const t = typeof data;
352
- switch (t) {
353
- case "undefined":
354
- return ZodParsedType.undefined;
355
- case "string":
356
- return ZodParsedType.string;
357
- case "number":
358
- return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
359
- case "boolean":
360
- return ZodParsedType.boolean;
361
- case "function":
362
- return ZodParsedType.function;
363
- case "bigint":
364
- return ZodParsedType.bigint;
365
- case "symbol":
366
- return ZodParsedType.symbol;
367
- case "object":
368
- if (Array.isArray(data)) {
369
- return ZodParsedType.array;
370
- }
371
- if (data === null) {
372
- return ZodParsedType.null;
373
- }
374
- if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
375
- return ZodParsedType.promise;
376
- }
377
- if (typeof Map !== "undefined" && data instanceof Map) {
378
- return ZodParsedType.map;
379
- }
380
- if (typeof Set !== "undefined" && data instanceof Set) {
381
- return ZodParsedType.set;
382
- }
383
- if (typeof Date !== "undefined" && data instanceof Date) {
384
- return ZodParsedType.date;
385
- }
386
- return ZodParsedType.object;
387
- default:
388
- return ZodParsedType.unknown;
389
- }
390
- };
391
- var ZodIssueCode = util.arrayToEnum([
392
- "invalid_type",
393
- "invalid_literal",
394
- "custom",
395
- "invalid_union",
396
- "invalid_union_discriminator",
397
- "invalid_enum_value",
398
- "unrecognized_keys",
399
- "invalid_arguments",
400
- "invalid_return_type",
401
- "invalid_date",
402
- "invalid_string",
403
- "too_small",
404
- "too_big",
405
- "invalid_intersection_types",
406
- "not_multiple_of",
407
- "not_finite"
408
- ]);
409
- var quotelessJson = (obj) => {
410
- const json = JSON.stringify(obj, null, 2);
411
- return json.replace(/"([^"]+)":/g, "$1:");
412
- };
413
- var ZodError = class _ZodError extends Error {
414
- constructor(issues) {
415
- super();
416
- this.issues = [];
417
- this.addIssue = (sub) => {
418
- this.issues = [...this.issues, sub];
419
- };
420
- this.addIssues = (subs = []) => {
421
- this.issues = [...this.issues, ...subs];
422
- };
423
- const actualProto = new.target.prototype;
424
- if (Object.setPrototypeOf) {
425
- Object.setPrototypeOf(this, actualProto);
426
- } else {
427
- this.__proto__ = actualProto;
428
- }
429
- this.name = "ZodError";
430
- this.issues = issues;
431
- }
432
- get errors() {
433
- return this.issues;
434
- }
435
- format(_mapper) {
436
- const mapper = _mapper || function(issue) {
437
- return issue.message;
438
- };
439
- const fieldErrors = { _errors: [] };
440
- const processError = (error) => {
441
- for (const issue of error.issues) {
442
- if (issue.code === "invalid_union") {
443
- issue.unionErrors.map(processError);
444
- } else if (issue.code === "invalid_return_type") {
445
- processError(issue.returnTypeError);
446
- } else if (issue.code === "invalid_arguments") {
447
- processError(issue.argumentsError);
448
- } else if (issue.path.length === 0) {
449
- fieldErrors._errors.push(mapper(issue));
450
- } else {
451
- let curr = fieldErrors;
452
- let i = 0;
453
- while (i < issue.path.length) {
454
- const el = issue.path[i];
455
- const terminal = i === issue.path.length - 1;
456
- if (!terminal) {
457
- curr[el] = curr[el] || { _errors: [] };
458
- } else {
459
- curr[el] = curr[el] || { _errors: [] };
460
- curr[el]._errors.push(mapper(issue));
461
- }
462
- curr = curr[el];
463
- i++;
464
- }
465
- }
466
- }
467
- };
468
- processError(this);
469
- return fieldErrors;
470
- }
471
- static assert(value) {
472
- if (!(value instanceof _ZodError)) {
473
- throw new Error(`Not a ZodError: ${value}`);
474
- }
475
- }
476
- toString() {
477
- return this.message;
478
- }
479
- get message() {
480
- return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
481
- }
482
- get isEmpty() {
483
- return this.issues.length === 0;
484
- }
485
- flatten(mapper = (issue) => issue.message) {
486
- const fieldErrors = {};
487
- const formErrors = [];
488
- for (const sub of this.issues) {
489
- if (sub.path.length > 0) {
490
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
491
- fieldErrors[sub.path[0]].push(mapper(sub));
492
- } else {
493
- formErrors.push(mapper(sub));
494
- }
495
- }
496
- return { formErrors, fieldErrors };
497
- }
498
- get formErrors() {
499
- return this.flatten();
500
- }
501
- };
502
- ZodError.create = (issues) => {
503
- const error = new ZodError(issues);
504
- return error;
505
- };
506
- var errorMap = (issue, _ctx) => {
507
- let message;
508
- switch (issue.code) {
509
- case ZodIssueCode.invalid_type:
510
- if (issue.received === ZodParsedType.undefined) {
511
- message = "Required";
512
- } else {
513
- message = `Expected ${issue.expected}, received ${issue.received}`;
514
- }
515
- break;
516
- case ZodIssueCode.invalid_literal:
517
- message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
518
- break;
519
- case ZodIssueCode.unrecognized_keys:
520
- message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
521
- break;
522
- case ZodIssueCode.invalid_union:
523
- message = `Invalid input`;
524
- break;
525
- case ZodIssueCode.invalid_union_discriminator:
526
- message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
527
- break;
528
- case ZodIssueCode.invalid_enum_value:
529
- message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
530
- break;
531
- case ZodIssueCode.invalid_arguments:
532
- message = `Invalid function arguments`;
533
- break;
534
- case ZodIssueCode.invalid_return_type:
535
- message = `Invalid function return type`;
536
- break;
537
- case ZodIssueCode.invalid_date:
538
- message = `Invalid date`;
539
- break;
540
- case ZodIssueCode.invalid_string:
541
- if (typeof issue.validation === "object") {
542
- if ("includes" in issue.validation) {
543
- message = `Invalid input: must include "${issue.validation.includes}"`;
544
- if (typeof issue.validation.position === "number") {
545
- message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
546
- }
547
- } else if ("startsWith" in issue.validation) {
548
- message = `Invalid input: must start with "${issue.validation.startsWith}"`;
549
- } else if ("endsWith" in issue.validation) {
550
- message = `Invalid input: must end with "${issue.validation.endsWith}"`;
551
- } else {
552
- util.assertNever(issue.validation);
553
- }
554
- } else if (issue.validation !== "regex") {
555
- message = `Invalid ${issue.validation}`;
556
- } else {
557
- message = "Invalid";
558
- }
559
- break;
560
- case ZodIssueCode.too_small:
561
- if (issue.type === "array")
562
- message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
563
- else if (issue.type === "string")
564
- message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
565
- else if (issue.type === "number")
566
- message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
567
- else if (issue.type === "date")
568
- message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
569
- else
570
- message = "Invalid input";
571
- break;
572
- case ZodIssueCode.too_big:
573
- if (issue.type === "array")
574
- message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
575
- else if (issue.type === "string")
576
- message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
577
- else if (issue.type === "number")
578
- message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
579
- else if (issue.type === "bigint")
580
- message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
581
- else if (issue.type === "date")
582
- message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
583
- else
584
- message = "Invalid input";
585
- break;
586
- case ZodIssueCode.custom:
587
- message = `Invalid input`;
588
- break;
589
- case ZodIssueCode.invalid_intersection_types:
590
- message = `Intersection results could not be merged`;
591
- break;
592
- case ZodIssueCode.not_multiple_of:
593
- message = `Number must be a multiple of ${issue.multipleOf}`;
594
- break;
595
- case ZodIssueCode.not_finite:
596
- message = "Number must be finite";
597
- break;
598
- default:
599
- message = _ctx.defaultError;
600
- util.assertNever(issue);
601
- }
602
- return { message };
603
- };
604
- var overrideErrorMap = errorMap;
605
- function setErrorMap(map) {
606
- overrideErrorMap = map;
607
- }
608
- function getErrorMap() {
609
- return overrideErrorMap;
610
- }
611
- var makeIssue = (params) => {
612
- const { data, path, errorMaps, issueData } = params;
613
- const fullPath = [...path, ...issueData.path || []];
614
- const fullIssue = {
615
- ...issueData,
616
- path: fullPath
617
- };
618
- if (issueData.message !== void 0) {
619
- return {
620
- ...issueData,
621
- path: fullPath,
622
- message: issueData.message
623
- };
624
- }
625
- let errorMessage = "";
626
- const maps = errorMaps.filter((m) => !!m).slice().reverse();
627
- for (const map of maps) {
628
- errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
629
- }
630
- return {
631
- ...issueData,
632
- path: fullPath,
633
- message: errorMessage
634
- };
635
- };
636
- var EMPTY_PATH = [];
637
- function addIssueToContext(ctx, issueData) {
638
- const overrideMap = getErrorMap();
639
- const issue = makeIssue({
640
- issueData,
641
- data: ctx.data,
642
- path: ctx.path,
643
- errorMaps: [
644
- ctx.common.contextualErrorMap,
645
- ctx.schemaErrorMap,
646
- overrideMap,
647
- overrideMap === errorMap ? void 0 : errorMap
648
- // then global default map
649
- ].filter((x) => !!x)
650
- });
651
- ctx.common.issues.push(issue);
652
- }
653
- var ParseStatus = class _ParseStatus {
654
- constructor() {
655
- this.value = "valid";
656
- }
657
- dirty() {
658
- if (this.value === "valid")
659
- this.value = "dirty";
660
- }
661
- abort() {
662
- if (this.value !== "aborted")
663
- this.value = "aborted";
664
- }
665
- static mergeArray(status, results) {
666
- const arrayValue = [];
667
- for (const s of results) {
668
- if (s.status === "aborted")
669
- return INVALID;
670
- if (s.status === "dirty")
671
- status.dirty();
672
- arrayValue.push(s.value);
673
- }
674
- return { status: status.value, value: arrayValue };
675
- }
676
- static async mergeObjectAsync(status, pairs) {
677
- const syncPairs = [];
678
- for (const pair of pairs) {
679
- const key = await pair.key;
680
- const value = await pair.value;
681
- syncPairs.push({
682
- key,
683
- value
684
- });
685
- }
686
- return _ParseStatus.mergeObjectSync(status, syncPairs);
687
- }
688
- static mergeObjectSync(status, pairs) {
689
- const finalObject = {};
690
- for (const pair of pairs) {
691
- const { key, value } = pair;
692
- if (key.status === "aborted")
693
- return INVALID;
694
- if (value.status === "aborted")
695
- return INVALID;
696
- if (key.status === "dirty")
697
- status.dirty();
698
- if (value.status === "dirty")
699
- status.dirty();
700
- if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
701
- finalObject[key.value] = value.value;
702
- }
703
- }
704
- return { status: status.value, value: finalObject };
705
- }
706
- };
707
- var INVALID = Object.freeze({
708
- status: "aborted"
709
- });
710
- var DIRTY = (value) => ({ status: "dirty", value });
711
- var OK = (value) => ({ status: "valid", value });
712
- var isAborted = (x) => x.status === "aborted";
713
- var isDirty = (x) => x.status === "dirty";
714
- var isValid = (x) => x.status === "valid";
715
- var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
716
- function __classPrivateFieldGet(receiver, state, kind, f) {
717
- if (kind === "a" && !f)
718
- throw new TypeError("Private accessor was defined without a getter");
719
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
720
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
721
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
722
- }
723
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
724
- if (kind === "m")
725
- throw new TypeError("Private method is not writable");
726
- if (kind === "a" && !f)
727
- throw new TypeError("Private accessor was defined without a setter");
728
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
729
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
730
- return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
731
- }
732
- var errorUtil;
733
- (function(errorUtil2) {
734
- errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
735
- errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
736
- })(errorUtil || (errorUtil = {}));
737
- var _ZodEnum_cache;
738
- var _ZodNativeEnum_cache;
739
- var ParseInputLazyPath = class {
740
- constructor(parent, value, path, key) {
741
- this._cachedPath = [];
742
- this.parent = parent;
743
- this.data = value;
744
- this._path = path;
745
- this._key = key;
746
- }
747
- get path() {
748
- if (!this._cachedPath.length) {
749
- if (this._key instanceof Array) {
750
- this._cachedPath.push(...this._path, ...this._key);
751
- } else {
752
- this._cachedPath.push(...this._path, this._key);
753
- }
754
- }
755
- return this._cachedPath;
756
- }
757
- };
758
- var handleResult = (ctx, result) => {
759
- if (isValid(result)) {
760
- return { success: true, data: result.value };
761
- } else {
762
- if (!ctx.common.issues.length) {
763
- throw new Error("Validation failed but no issues detected.");
764
- }
765
- return {
766
- success: false,
767
- get error() {
768
- if (this._error)
769
- return this._error;
770
- const error = new ZodError(ctx.common.issues);
771
- this._error = error;
772
- return this._error;
773
- }
774
- };
775
- }
776
- };
777
- function processCreateParams(params) {
778
- if (!params)
779
- return {};
780
- const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
781
- if (errorMap2 && (invalid_type_error || required_error)) {
782
- throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
783
- }
784
- if (errorMap2)
785
- return { errorMap: errorMap2, description };
786
- const customMap = (iss, ctx) => {
787
- var _a, _b;
788
- const { message } = params;
789
- if (iss.code === "invalid_enum_value") {
790
- return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
791
- }
792
- if (typeof ctx.data === "undefined") {
793
- return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
794
- }
795
- if (iss.code !== "invalid_type")
796
- return { message: ctx.defaultError };
797
- return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
798
- };
799
- return { errorMap: customMap, description };
800
- }
801
- var ZodType = class {
802
- constructor(def) {
803
- this.spa = this.safeParseAsync;
804
- this._def = def;
805
- this.parse = this.parse.bind(this);
806
- this.safeParse = this.safeParse.bind(this);
807
- this.parseAsync = this.parseAsync.bind(this);
808
- this.safeParseAsync = this.safeParseAsync.bind(this);
809
- this.spa = this.spa.bind(this);
810
- this.refine = this.refine.bind(this);
811
- this.refinement = this.refinement.bind(this);
812
- this.superRefine = this.superRefine.bind(this);
813
- this.optional = this.optional.bind(this);
814
- this.nullable = this.nullable.bind(this);
815
- this.nullish = this.nullish.bind(this);
816
- this.array = this.array.bind(this);
817
- this.promise = this.promise.bind(this);
818
- this.or = this.or.bind(this);
819
- this.and = this.and.bind(this);
820
- this.transform = this.transform.bind(this);
821
- this.brand = this.brand.bind(this);
822
- this.default = this.default.bind(this);
823
- this.catch = this.catch.bind(this);
824
- this.describe = this.describe.bind(this);
825
- this.pipe = this.pipe.bind(this);
826
- this.readonly = this.readonly.bind(this);
827
- this.isNullable = this.isNullable.bind(this);
828
- this.isOptional = this.isOptional.bind(this);
829
- }
830
- get description() {
831
- return this._def.description;
832
- }
833
- _getType(input) {
834
- return getParsedType(input.data);
835
- }
836
- _getOrReturnCtx(input, ctx) {
837
- return ctx || {
838
- common: input.parent.common,
839
- data: input.data,
840
- parsedType: getParsedType(input.data),
841
- schemaErrorMap: this._def.errorMap,
842
- path: input.path,
843
- parent: input.parent
844
- };
845
- }
846
- _processInputParams(input) {
847
- return {
848
- status: new ParseStatus(),
849
- ctx: {
850
- common: input.parent.common,
851
- data: input.data,
852
- parsedType: getParsedType(input.data),
853
- schemaErrorMap: this._def.errorMap,
854
- path: input.path,
855
- parent: input.parent
856
- }
857
- };
858
- }
859
- _parseSync(input) {
860
- const result = this._parse(input);
861
- if (isAsync(result)) {
862
- throw new Error("Synchronous parse encountered promise.");
863
- }
864
- return result;
865
- }
866
- _parseAsync(input) {
867
- const result = this._parse(input);
868
- return Promise.resolve(result);
869
- }
870
- parse(data, params) {
871
- const result = this.safeParse(data, params);
872
- if (result.success)
873
- return result.data;
874
- throw result.error;
875
- }
876
- safeParse(data, params) {
877
- var _a;
878
- const ctx = {
879
- common: {
880
- issues: [],
881
- async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
882
- contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
883
- },
884
- path: (params === null || params === void 0 ? void 0 : params.path) || [],
885
- schemaErrorMap: this._def.errorMap,
886
- parent: null,
887
- data,
888
- parsedType: getParsedType(data)
889
- };
890
- const result = this._parseSync({ data, path: ctx.path, parent: ctx });
891
- return handleResult(ctx, result);
892
- }
893
- async parseAsync(data, params) {
894
- const result = await this.safeParseAsync(data, params);
895
- if (result.success)
896
- return result.data;
897
- throw result.error;
898
- }
899
- async safeParseAsync(data, params) {
900
- const ctx = {
901
- common: {
902
- issues: [],
903
- contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
904
- async: true
905
- },
906
- path: (params === null || params === void 0 ? void 0 : params.path) || [],
907
- schemaErrorMap: this._def.errorMap,
908
- parent: null,
909
- data,
910
- parsedType: getParsedType(data)
911
- };
912
- const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
913
- const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
914
- return handleResult(ctx, result);
915
- }
916
- refine(check, message) {
917
- const getIssueProperties = (val) => {
918
- if (typeof message === "string" || typeof message === "undefined") {
919
- return { message };
920
- } else if (typeof message === "function") {
921
- return message(val);
922
- } else {
923
- return message;
924
- }
925
- };
926
- return this._refinement((val, ctx) => {
927
- const result = check(val);
928
- const setError = () => ctx.addIssue({
929
- code: ZodIssueCode.custom,
930
- ...getIssueProperties(val)
931
- });
932
- if (typeof Promise !== "undefined" && result instanceof Promise) {
933
- return result.then((data) => {
934
- if (!data) {
935
- setError();
936
- return false;
937
- } else {
938
- return true;
939
- }
940
- });
941
- }
942
- if (!result) {
943
- setError();
944
- return false;
945
- } else {
946
- return true;
947
- }
948
- });
949
- }
950
- refinement(check, refinementData) {
951
- return this._refinement((val, ctx) => {
952
- if (!check(val)) {
953
- ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
954
- return false;
955
- } else {
956
- return true;
957
- }
958
- });
959
- }
960
- _refinement(refinement) {
961
- return new ZodEffects({
962
- schema: this,
963
- typeName: ZodFirstPartyTypeKind.ZodEffects,
964
- effect: { type: "refinement", refinement }
965
- });
966
- }
967
- superRefine(refinement) {
968
- return this._refinement(refinement);
969
- }
970
- optional() {
971
- return ZodOptional.create(this, this._def);
972
- }
973
- nullable() {
974
- return ZodNullable.create(this, this._def);
975
- }
976
- nullish() {
977
- return this.nullable().optional();
978
- }
979
- array() {
980
- return ZodArray.create(this, this._def);
981
- }
982
- promise() {
983
- return ZodPromise.create(this, this._def);
984
- }
985
- or(option) {
986
- return ZodUnion.create([this, option], this._def);
987
- }
988
- and(incoming) {
989
- return ZodIntersection.create(this, incoming, this._def);
990
- }
991
- transform(transform) {
992
- return new ZodEffects({
993
- ...processCreateParams(this._def),
994
- schema: this,
995
- typeName: ZodFirstPartyTypeKind.ZodEffects,
996
- effect: { type: "transform", transform }
997
- });
998
- }
999
- default(def) {
1000
- const defaultValueFunc = typeof def === "function" ? def : () => def;
1001
- return new ZodDefault({
1002
- ...processCreateParams(this._def),
1003
- innerType: this,
1004
- defaultValue: defaultValueFunc,
1005
- typeName: ZodFirstPartyTypeKind.ZodDefault
1006
- });
1007
- }
1008
- brand() {
1009
- return new ZodBranded({
1010
- typeName: ZodFirstPartyTypeKind.ZodBranded,
1011
- type: this,
1012
- ...processCreateParams(this._def)
1013
- });
1014
- }
1015
- catch(def) {
1016
- const catchValueFunc = typeof def === "function" ? def : () => def;
1017
- return new ZodCatch({
1018
- ...processCreateParams(this._def),
1019
- innerType: this,
1020
- catchValue: catchValueFunc,
1021
- typeName: ZodFirstPartyTypeKind.ZodCatch
1022
- });
1023
- }
1024
- describe(description) {
1025
- const This = this.constructor;
1026
- return new This({
1027
- ...this._def,
1028
- description
1029
- });
1030
- }
1031
- pipe(target) {
1032
- return ZodPipeline.create(this, target);
1033
- }
1034
- readonly() {
1035
- return ZodReadonly.create(this);
1036
- }
1037
- isOptional() {
1038
- return this.safeParse(void 0).success;
1039
- }
1040
- isNullable() {
1041
- return this.safeParse(null).success;
1042
- }
1043
- };
1044
- var cuidRegex = /^c[^\s-]{8,}$/i;
1045
- var cuid2Regex = /^[0-9a-z]+$/;
1046
- var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
1047
- var uuidRegex = /^[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;
1048
- var nanoidRegex = /^[a-z0-9_-]{21}$/i;
1049
- var durationRegex = /^[-+]?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)?)??$/;
1050
- var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
1051
- var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1052
- var emojiRegex;
1053
- var ipv4Regex = /^(?:(?: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])$/;
1054
- var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
1055
- var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
1056
- var dateRegexSource = `((\\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])))`;
1057
- var dateRegex = new RegExp(`^${dateRegexSource}$`);
1058
- function timeRegexSource(args) {
1059
- let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
1060
- if (args.precision) {
1061
- regex = `${regex}\\.\\d{${args.precision}}`;
1062
- } else if (args.precision == null) {
1063
- regex = `${regex}(\\.\\d+)?`;
1064
- }
1065
- return regex;
1066
- }
1067
- function timeRegex(args) {
1068
- return new RegExp(`^${timeRegexSource(args)}$`);
1069
- }
1070
- function datetimeRegex(args) {
1071
- let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
1072
- const opts = [];
1073
- opts.push(args.local ? `Z?` : `Z`);
1074
- if (args.offset)
1075
- opts.push(`([+-]\\d{2}:?\\d{2})`);
1076
- regex = `${regex}(${opts.join("|")})`;
1077
- return new RegExp(`^${regex}$`);
1078
- }
1079
- function isValidIP(ip, version) {
1080
- if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
1081
- return true;
1082
- }
1083
- if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
1084
- return true;
1085
- }
1086
- return false;
1087
- }
1088
- var ZodString = class _ZodString extends ZodType {
1089
- _parse(input) {
1090
- if (this._def.coerce) {
1091
- input.data = String(input.data);
1092
- }
1093
- const parsedType = this._getType(input);
1094
- if (parsedType !== ZodParsedType.string) {
1095
- const ctx2 = this._getOrReturnCtx(input);
1096
- addIssueToContext(ctx2, {
1097
- code: ZodIssueCode.invalid_type,
1098
- expected: ZodParsedType.string,
1099
- received: ctx2.parsedType
1100
- });
1101
- return INVALID;
1102
- }
1103
- const status = new ParseStatus();
1104
- let ctx = void 0;
1105
- for (const check of this._def.checks) {
1106
- if (check.kind === "min") {
1107
- if (input.data.length < check.value) {
1108
- ctx = this._getOrReturnCtx(input, ctx);
1109
- addIssueToContext(ctx, {
1110
- code: ZodIssueCode.too_small,
1111
- minimum: check.value,
1112
- type: "string",
1113
- inclusive: true,
1114
- exact: false,
1115
- message: check.message
1116
- });
1117
- status.dirty();
1118
- }
1119
- } else if (check.kind === "max") {
1120
- if (input.data.length > check.value) {
1121
- ctx = this._getOrReturnCtx(input, ctx);
1122
- addIssueToContext(ctx, {
1123
- code: ZodIssueCode.too_big,
1124
- maximum: check.value,
1125
- type: "string",
1126
- inclusive: true,
1127
- exact: false,
1128
- message: check.message
1129
- });
1130
- status.dirty();
1131
- }
1132
- } else if (check.kind === "length") {
1133
- const tooBig = input.data.length > check.value;
1134
- const tooSmall = input.data.length < check.value;
1135
- if (tooBig || tooSmall) {
1136
- ctx = this._getOrReturnCtx(input, ctx);
1137
- if (tooBig) {
1138
- addIssueToContext(ctx, {
1139
- code: ZodIssueCode.too_big,
1140
- maximum: check.value,
1141
- type: "string",
1142
- inclusive: true,
1143
- exact: true,
1144
- message: check.message
1145
- });
1146
- } else if (tooSmall) {
1147
- addIssueToContext(ctx, {
1148
- code: ZodIssueCode.too_small,
1149
- minimum: check.value,
1150
- type: "string",
1151
- inclusive: true,
1152
- exact: true,
1153
- message: check.message
1154
- });
1155
- }
1156
- status.dirty();
1157
- }
1158
- } else if (check.kind === "email") {
1159
- if (!emailRegex.test(input.data)) {
1160
- ctx = this._getOrReturnCtx(input, ctx);
1161
- addIssueToContext(ctx, {
1162
- validation: "email",
1163
- code: ZodIssueCode.invalid_string,
1164
- message: check.message
1165
- });
1166
- status.dirty();
1167
- }
1168
- } else if (check.kind === "emoji") {
1169
- if (!emojiRegex) {
1170
- emojiRegex = new RegExp(_emojiRegex, "u");
1171
- }
1172
- if (!emojiRegex.test(input.data)) {
1173
- ctx = this._getOrReturnCtx(input, ctx);
1174
- addIssueToContext(ctx, {
1175
- validation: "emoji",
1176
- code: ZodIssueCode.invalid_string,
1177
- message: check.message
1178
- });
1179
- status.dirty();
1180
- }
1181
- } else if (check.kind === "uuid") {
1182
- if (!uuidRegex.test(input.data)) {
1183
- ctx = this._getOrReturnCtx(input, ctx);
1184
- addIssueToContext(ctx, {
1185
- validation: "uuid",
1186
- code: ZodIssueCode.invalid_string,
1187
- message: check.message
1188
- });
1189
- status.dirty();
1190
- }
1191
- } else if (check.kind === "nanoid") {
1192
- if (!nanoidRegex.test(input.data)) {
1193
- ctx = this._getOrReturnCtx(input, ctx);
1194
- addIssueToContext(ctx, {
1195
- validation: "nanoid",
1196
- code: ZodIssueCode.invalid_string,
1197
- message: check.message
1198
- });
1199
- status.dirty();
1200
- }
1201
- } else if (check.kind === "cuid") {
1202
- if (!cuidRegex.test(input.data)) {
1203
- ctx = this._getOrReturnCtx(input, ctx);
1204
- addIssueToContext(ctx, {
1205
- validation: "cuid",
1206
- code: ZodIssueCode.invalid_string,
1207
- message: check.message
1208
- });
1209
- status.dirty();
1210
- }
1211
- } else if (check.kind === "cuid2") {
1212
- if (!cuid2Regex.test(input.data)) {
1213
- ctx = this._getOrReturnCtx(input, ctx);
1214
- addIssueToContext(ctx, {
1215
- validation: "cuid2",
1216
- code: ZodIssueCode.invalid_string,
1217
- message: check.message
1218
- });
1219
- status.dirty();
1220
- }
1221
- } else if (check.kind === "ulid") {
1222
- if (!ulidRegex.test(input.data)) {
1223
- ctx = this._getOrReturnCtx(input, ctx);
1224
- addIssueToContext(ctx, {
1225
- validation: "ulid",
1226
- code: ZodIssueCode.invalid_string,
1227
- message: check.message
1228
- });
1229
- status.dirty();
1230
- }
1231
- } else if (check.kind === "url") {
1232
- try {
1233
- new URL(input.data);
1234
- } catch (_a) {
1235
- ctx = this._getOrReturnCtx(input, ctx);
1236
- addIssueToContext(ctx, {
1237
- validation: "url",
1238
- code: ZodIssueCode.invalid_string,
1239
- message: check.message
1240
- });
1241
- status.dirty();
1242
- }
1243
- } else if (check.kind === "regex") {
1244
- check.regex.lastIndex = 0;
1245
- const testResult = check.regex.test(input.data);
1246
- if (!testResult) {
1247
- ctx = this._getOrReturnCtx(input, ctx);
1248
- addIssueToContext(ctx, {
1249
- validation: "regex",
1250
- code: ZodIssueCode.invalid_string,
1251
- message: check.message
1252
- });
1253
- status.dirty();
1254
- }
1255
- } else if (check.kind === "trim") {
1256
- input.data = input.data.trim();
1257
- } else if (check.kind === "includes") {
1258
- if (!input.data.includes(check.value, check.position)) {
1259
- ctx = this._getOrReturnCtx(input, ctx);
1260
- addIssueToContext(ctx, {
1261
- code: ZodIssueCode.invalid_string,
1262
- validation: { includes: check.value, position: check.position },
1263
- message: check.message
1264
- });
1265
- status.dirty();
1266
- }
1267
- } else if (check.kind === "toLowerCase") {
1268
- input.data = input.data.toLowerCase();
1269
- } else if (check.kind === "toUpperCase") {
1270
- input.data = input.data.toUpperCase();
1271
- } else if (check.kind === "startsWith") {
1272
- if (!input.data.startsWith(check.value)) {
1273
- ctx = this._getOrReturnCtx(input, ctx);
1274
- addIssueToContext(ctx, {
1275
- code: ZodIssueCode.invalid_string,
1276
- validation: { startsWith: check.value },
1277
- message: check.message
1278
- });
1279
- status.dirty();
1280
- }
1281
- } else if (check.kind === "endsWith") {
1282
- if (!input.data.endsWith(check.value)) {
1283
- ctx = this._getOrReturnCtx(input, ctx);
1284
- addIssueToContext(ctx, {
1285
- code: ZodIssueCode.invalid_string,
1286
- validation: { endsWith: check.value },
1287
- message: check.message
1288
- });
1289
- status.dirty();
1290
- }
1291
- } else if (check.kind === "datetime") {
1292
- const regex = datetimeRegex(check);
1293
- if (!regex.test(input.data)) {
1294
- ctx = this._getOrReturnCtx(input, ctx);
1295
- addIssueToContext(ctx, {
1296
- code: ZodIssueCode.invalid_string,
1297
- validation: "datetime",
1298
- message: check.message
1299
- });
1300
- status.dirty();
1301
- }
1302
- } else if (check.kind === "date") {
1303
- const regex = dateRegex;
1304
- if (!regex.test(input.data)) {
1305
- ctx = this._getOrReturnCtx(input, ctx);
1306
- addIssueToContext(ctx, {
1307
- code: ZodIssueCode.invalid_string,
1308
- validation: "date",
1309
- message: check.message
1310
- });
1311
- status.dirty();
1312
- }
1313
- } else if (check.kind === "time") {
1314
- const regex = timeRegex(check);
1315
- if (!regex.test(input.data)) {
1316
- ctx = this._getOrReturnCtx(input, ctx);
1317
- addIssueToContext(ctx, {
1318
- code: ZodIssueCode.invalid_string,
1319
- validation: "time",
1320
- message: check.message
1321
- });
1322
- status.dirty();
1323
- }
1324
- } else if (check.kind === "duration") {
1325
- if (!durationRegex.test(input.data)) {
1326
- ctx = this._getOrReturnCtx(input, ctx);
1327
- addIssueToContext(ctx, {
1328
- validation: "duration",
1329
- code: ZodIssueCode.invalid_string,
1330
- message: check.message
1331
- });
1332
- status.dirty();
1333
- }
1334
- } else if (check.kind === "ip") {
1335
- if (!isValidIP(input.data, check.version)) {
1336
- ctx = this._getOrReturnCtx(input, ctx);
1337
- addIssueToContext(ctx, {
1338
- validation: "ip",
1339
- code: ZodIssueCode.invalid_string,
1340
- message: check.message
1341
- });
1342
- status.dirty();
1343
- }
1344
- } else if (check.kind === "base64") {
1345
- if (!base64Regex.test(input.data)) {
1346
- ctx = this._getOrReturnCtx(input, ctx);
1347
- addIssueToContext(ctx, {
1348
- validation: "base64",
1349
- code: ZodIssueCode.invalid_string,
1350
- message: check.message
1351
- });
1352
- status.dirty();
1353
- }
1354
- } else {
1355
- util.assertNever(check);
1356
- }
1357
- }
1358
- return { status: status.value, value: input.data };
1359
- }
1360
- _regex(regex, validation, message) {
1361
- return this.refinement((data) => regex.test(data), {
1362
- validation,
1363
- code: ZodIssueCode.invalid_string,
1364
- ...errorUtil.errToObj(message)
1365
- });
1366
- }
1367
- _addCheck(check) {
1368
- return new _ZodString({
1369
- ...this._def,
1370
- checks: [...this._def.checks, check]
1371
- });
1372
- }
1373
- email(message) {
1374
- return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
1375
- }
1376
- url(message) {
1377
- return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
1378
- }
1379
- emoji(message) {
1380
- return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
1381
- }
1382
- uuid(message) {
1383
- return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1384
- }
1385
- nanoid(message) {
1386
- return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
1387
- }
1388
- cuid(message) {
1389
- return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1390
- }
1391
- cuid2(message) {
1392
- return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
1393
- }
1394
- ulid(message) {
1395
- return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1396
- }
1397
- base64(message) {
1398
- return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
1399
- }
1400
- ip(options) {
1401
- return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1402
- }
1403
- datetime(options) {
1404
- var _a, _b;
1405
- if (typeof options === "string") {
1406
- return this._addCheck({
1407
- kind: "datetime",
1408
- precision: null,
1409
- offset: false,
1410
- local: false,
1411
- message: options
1412
- });
1413
- }
1414
- return this._addCheck({
1415
- kind: "datetime",
1416
- precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1417
- offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1418
- local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
1419
- ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1420
- });
1421
- }
1422
- date(message) {
1423
- return this._addCheck({ kind: "date", message });
1424
- }
1425
- time(options) {
1426
- if (typeof options === "string") {
1427
- return this._addCheck({
1428
- kind: "time",
1429
- precision: null,
1430
- message: options
1431
- });
1432
- }
1433
- return this._addCheck({
1434
- kind: "time",
1435
- precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1436
- ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1437
- });
1438
- }
1439
- duration(message) {
1440
- return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
1441
- }
1442
- regex(regex, message) {
1443
- return this._addCheck({
1444
- kind: "regex",
1445
- regex,
1446
- ...errorUtil.errToObj(message)
1447
- });
1448
- }
1449
- includes(value, options) {
1450
- return this._addCheck({
1451
- kind: "includes",
1452
- value,
1453
- position: options === null || options === void 0 ? void 0 : options.position,
1454
- ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1455
- });
1456
- }
1457
- startsWith(value, message) {
1458
- return this._addCheck({
1459
- kind: "startsWith",
1460
- value,
1461
- ...errorUtil.errToObj(message)
1462
- });
1463
- }
1464
- endsWith(value, message) {
1465
- return this._addCheck({
1466
- kind: "endsWith",
1467
- value,
1468
- ...errorUtil.errToObj(message)
1469
- });
1470
- }
1471
- min(minLength, message) {
1472
- return this._addCheck({
1473
- kind: "min",
1474
- value: minLength,
1475
- ...errorUtil.errToObj(message)
1476
- });
1477
- }
1478
- max(maxLength, message) {
1479
- return this._addCheck({
1480
- kind: "max",
1481
- value: maxLength,
1482
- ...errorUtil.errToObj(message)
1483
- });
1484
- }
1485
- length(len, message) {
1486
- return this._addCheck({
1487
- kind: "length",
1488
- value: len,
1489
- ...errorUtil.errToObj(message)
1490
- });
1491
- }
1492
- /**
1493
- * @deprecated Use z.string().min(1) instead.
1494
- * @see {@link ZodString.min}
1495
- */
1496
- nonempty(message) {
1497
- return this.min(1, errorUtil.errToObj(message));
1498
- }
1499
- trim() {
1500
- return new _ZodString({
1501
- ...this._def,
1502
- checks: [...this._def.checks, { kind: "trim" }]
1503
- });
1504
- }
1505
- toLowerCase() {
1506
- return new _ZodString({
1507
- ...this._def,
1508
- checks: [...this._def.checks, { kind: "toLowerCase" }]
1509
- });
1510
- }
1511
- toUpperCase() {
1512
- return new _ZodString({
1513
- ...this._def,
1514
- checks: [...this._def.checks, { kind: "toUpperCase" }]
1515
- });
1516
- }
1517
- get isDatetime() {
1518
- return !!this._def.checks.find((ch) => ch.kind === "datetime");
1519
- }
1520
- get isDate() {
1521
- return !!this._def.checks.find((ch) => ch.kind === "date");
1522
- }
1523
- get isTime() {
1524
- return !!this._def.checks.find((ch) => ch.kind === "time");
1525
- }
1526
- get isDuration() {
1527
- return !!this._def.checks.find((ch) => ch.kind === "duration");
1528
- }
1529
- get isEmail() {
1530
- return !!this._def.checks.find((ch) => ch.kind === "email");
1531
- }
1532
- get isURL() {
1533
- return !!this._def.checks.find((ch) => ch.kind === "url");
1534
- }
1535
- get isEmoji() {
1536
- return !!this._def.checks.find((ch) => ch.kind === "emoji");
1537
- }
1538
- get isUUID() {
1539
- return !!this._def.checks.find((ch) => ch.kind === "uuid");
1540
- }
1541
- get isNANOID() {
1542
- return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1543
- }
1544
- get isCUID() {
1545
- return !!this._def.checks.find((ch) => ch.kind === "cuid");
1546
- }
1547
- get isCUID2() {
1548
- return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1549
- }
1550
- get isULID() {
1551
- return !!this._def.checks.find((ch) => ch.kind === "ulid");
1552
- }
1553
- get isIP() {
1554
- return !!this._def.checks.find((ch) => ch.kind === "ip");
1555
- }
1556
- get isBase64() {
1557
- return !!this._def.checks.find((ch) => ch.kind === "base64");
1558
- }
1559
- get minLength() {
1560
- let min = null;
1561
- for (const ch of this._def.checks) {
1562
- if (ch.kind === "min") {
1563
- if (min === null || ch.value > min)
1564
- min = ch.value;
1565
- }
1566
- }
1567
- return min;
1568
- }
1569
- get maxLength() {
1570
- let max = null;
1571
- for (const ch of this._def.checks) {
1572
- if (ch.kind === "max") {
1573
- if (max === null || ch.value < max)
1574
- max = ch.value;
1575
- }
1576
- }
1577
- return max;
1578
- }
1579
- };
1580
- ZodString.create = (params) => {
1581
- var _a;
1582
- return new ZodString({
1583
- checks: [],
1584
- typeName: ZodFirstPartyTypeKind.ZodString,
1585
- coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1586
- ...processCreateParams(params)
1587
- });
1588
- };
1589
- function floatSafeRemainder(val, step) {
1590
- const valDecCount = (val.toString().split(".")[1] || "").length;
1591
- const stepDecCount = (step.toString().split(".")[1] || "").length;
1592
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1593
- const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
1594
- const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
1595
- return valInt % stepInt / Math.pow(10, decCount);
1596
- }
1597
- var ZodNumber = class _ZodNumber extends ZodType {
1598
- constructor() {
1599
- super(...arguments);
1600
- this.min = this.gte;
1601
- this.max = this.lte;
1602
- this.step = this.multipleOf;
1603
- }
1604
- _parse(input) {
1605
- if (this._def.coerce) {
1606
- input.data = Number(input.data);
1607
- }
1608
- const parsedType = this._getType(input);
1609
- if (parsedType !== ZodParsedType.number) {
1610
- const ctx2 = this._getOrReturnCtx(input);
1611
- addIssueToContext(ctx2, {
1612
- code: ZodIssueCode.invalid_type,
1613
- expected: ZodParsedType.number,
1614
- received: ctx2.parsedType
1615
- });
1616
- return INVALID;
1617
- }
1618
- let ctx = void 0;
1619
- const status = new ParseStatus();
1620
- for (const check of this._def.checks) {
1621
- if (check.kind === "int") {
1622
- if (!util.isInteger(input.data)) {
1623
- ctx = this._getOrReturnCtx(input, ctx);
1624
- addIssueToContext(ctx, {
1625
- code: ZodIssueCode.invalid_type,
1626
- expected: "integer",
1627
- received: "float",
1628
- message: check.message
1629
- });
1630
- status.dirty();
1631
- }
1632
- } else if (check.kind === "min") {
1633
- const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1634
- if (tooSmall) {
1635
- ctx = this._getOrReturnCtx(input, ctx);
1636
- addIssueToContext(ctx, {
1637
- code: ZodIssueCode.too_small,
1638
- minimum: check.value,
1639
- type: "number",
1640
- inclusive: check.inclusive,
1641
- exact: false,
1642
- message: check.message
1643
- });
1644
- status.dirty();
1645
- }
1646
- } else if (check.kind === "max") {
1647
- const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1648
- if (tooBig) {
1649
- ctx = this._getOrReturnCtx(input, ctx);
1650
- addIssueToContext(ctx, {
1651
- code: ZodIssueCode.too_big,
1652
- maximum: check.value,
1653
- type: "number",
1654
- inclusive: check.inclusive,
1655
- exact: false,
1656
- message: check.message
1657
- });
1658
- status.dirty();
1659
- }
1660
- } else if (check.kind === "multipleOf") {
1661
- if (floatSafeRemainder(input.data, check.value) !== 0) {
1662
- ctx = this._getOrReturnCtx(input, ctx);
1663
- addIssueToContext(ctx, {
1664
- code: ZodIssueCode.not_multiple_of,
1665
- multipleOf: check.value,
1666
- message: check.message
1667
- });
1668
- status.dirty();
1669
- }
1670
- } else if (check.kind === "finite") {
1671
- if (!Number.isFinite(input.data)) {
1672
- ctx = this._getOrReturnCtx(input, ctx);
1673
- addIssueToContext(ctx, {
1674
- code: ZodIssueCode.not_finite,
1675
- message: check.message
1676
- });
1677
- status.dirty();
1678
- }
1679
- } else {
1680
- util.assertNever(check);
1681
- }
1682
- }
1683
- return { status: status.value, value: input.data };
1684
- }
1685
- gte(value, message) {
1686
- return this.setLimit("min", value, true, errorUtil.toString(message));
1687
- }
1688
- gt(value, message) {
1689
- return this.setLimit("min", value, false, errorUtil.toString(message));
1690
- }
1691
- lte(value, message) {
1692
- return this.setLimit("max", value, true, errorUtil.toString(message));
1693
- }
1694
- lt(value, message) {
1695
- return this.setLimit("max", value, false, errorUtil.toString(message));
1696
- }
1697
- setLimit(kind, value, inclusive, message) {
1698
- return new _ZodNumber({
1699
- ...this._def,
1700
- checks: [
1701
- ...this._def.checks,
1702
- {
1703
- kind,
1704
- value,
1705
- inclusive,
1706
- message: errorUtil.toString(message)
1707
- }
1708
- ]
1709
- });
1710
- }
1711
- _addCheck(check) {
1712
- return new _ZodNumber({
1713
- ...this._def,
1714
- checks: [...this._def.checks, check]
1715
- });
1716
- }
1717
- int(message) {
1718
- return this._addCheck({
1719
- kind: "int",
1720
- message: errorUtil.toString(message)
1721
- });
1722
- }
1723
- positive(message) {
1724
- return this._addCheck({
1725
- kind: "min",
1726
- value: 0,
1727
- inclusive: false,
1728
- message: errorUtil.toString(message)
1729
- });
1730
- }
1731
- negative(message) {
1732
- return this._addCheck({
1733
- kind: "max",
1734
- value: 0,
1735
- inclusive: false,
1736
- message: errorUtil.toString(message)
1737
- });
1738
- }
1739
- nonpositive(message) {
1740
- return this._addCheck({
1741
- kind: "max",
1742
- value: 0,
1743
- inclusive: true,
1744
- message: errorUtil.toString(message)
1745
- });
1746
- }
1747
- nonnegative(message) {
1748
- return this._addCheck({
1749
- kind: "min",
1750
- value: 0,
1751
- inclusive: true,
1752
- message: errorUtil.toString(message)
1753
- });
1754
- }
1755
- multipleOf(value, message) {
1756
- return this._addCheck({
1757
- kind: "multipleOf",
1758
- value,
1759
- message: errorUtil.toString(message)
1760
- });
1761
- }
1762
- finite(message) {
1763
- return this._addCheck({
1764
- kind: "finite",
1765
- message: errorUtil.toString(message)
1766
- });
1767
- }
1768
- safe(message) {
1769
- return this._addCheck({
1770
- kind: "min",
1771
- inclusive: true,
1772
- value: Number.MIN_SAFE_INTEGER,
1773
- message: errorUtil.toString(message)
1774
- })._addCheck({
1775
- kind: "max",
1776
- inclusive: true,
1777
- value: Number.MAX_SAFE_INTEGER,
1778
- message: errorUtil.toString(message)
1779
- });
1780
- }
1781
- get minValue() {
1782
- let min = null;
1783
- for (const ch of this._def.checks) {
1784
- if (ch.kind === "min") {
1785
- if (min === null || ch.value > min)
1786
- min = ch.value;
1787
- }
1788
- }
1789
- return min;
1790
- }
1791
- get maxValue() {
1792
- let max = null;
1793
- for (const ch of this._def.checks) {
1794
- if (ch.kind === "max") {
1795
- if (max === null || ch.value < max)
1796
- max = ch.value;
1797
- }
1798
- }
1799
- return max;
1800
- }
1801
- get isInt() {
1802
- return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
1803
- }
1804
- get isFinite() {
1805
- let max = null, min = null;
1806
- for (const ch of this._def.checks) {
1807
- if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
1808
- return true;
1809
- } else if (ch.kind === "min") {
1810
- if (min === null || ch.value > min)
1811
- min = ch.value;
1812
- } else if (ch.kind === "max") {
1813
- if (max === null || ch.value < max)
1814
- max = ch.value;
1815
- }
1816
- }
1817
- return Number.isFinite(min) && Number.isFinite(max);
1818
- }
1819
- };
1820
- ZodNumber.create = (params) => {
1821
- return new ZodNumber({
1822
- checks: [],
1823
- typeName: ZodFirstPartyTypeKind.ZodNumber,
1824
- coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1825
- ...processCreateParams(params)
1826
- });
1827
- };
1828
- var ZodBigInt = class _ZodBigInt extends ZodType {
1829
- constructor() {
1830
- super(...arguments);
1831
- this.min = this.gte;
1832
- this.max = this.lte;
1833
- }
1834
- _parse(input) {
1835
- if (this._def.coerce) {
1836
- input.data = BigInt(input.data);
1837
- }
1838
- const parsedType = this._getType(input);
1839
- if (parsedType !== ZodParsedType.bigint) {
1840
- const ctx2 = this._getOrReturnCtx(input);
1841
- addIssueToContext(ctx2, {
1842
- code: ZodIssueCode.invalid_type,
1843
- expected: ZodParsedType.bigint,
1844
- received: ctx2.parsedType
1845
- });
1846
- return INVALID;
1847
- }
1848
- let ctx = void 0;
1849
- const status = new ParseStatus();
1850
- for (const check of this._def.checks) {
1851
- if (check.kind === "min") {
1852
- const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1853
- if (tooSmall) {
1854
- ctx = this._getOrReturnCtx(input, ctx);
1855
- addIssueToContext(ctx, {
1856
- code: ZodIssueCode.too_small,
1857
- type: "bigint",
1858
- minimum: check.value,
1859
- inclusive: check.inclusive,
1860
- message: check.message
1861
- });
1862
- status.dirty();
1863
- }
1864
- } else if (check.kind === "max") {
1865
- const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1866
- if (tooBig) {
1867
- ctx = this._getOrReturnCtx(input, ctx);
1868
- addIssueToContext(ctx, {
1869
- code: ZodIssueCode.too_big,
1870
- type: "bigint",
1871
- maximum: check.value,
1872
- inclusive: check.inclusive,
1873
- message: check.message
1874
- });
1875
- status.dirty();
1876
- }
1877
- } else if (check.kind === "multipleOf") {
1878
- if (input.data % check.value !== BigInt(0)) {
1879
- ctx = this._getOrReturnCtx(input, ctx);
1880
- addIssueToContext(ctx, {
1881
- code: ZodIssueCode.not_multiple_of,
1882
- multipleOf: check.value,
1883
- message: check.message
1884
- });
1885
- status.dirty();
1886
- }
1887
- } else {
1888
- util.assertNever(check);
1889
- }
1890
- }
1891
- return { status: status.value, value: input.data };
1892
- }
1893
- gte(value, message) {
1894
- return this.setLimit("min", value, true, errorUtil.toString(message));
1895
- }
1896
- gt(value, message) {
1897
- return this.setLimit("min", value, false, errorUtil.toString(message));
1898
- }
1899
- lte(value, message) {
1900
- return this.setLimit("max", value, true, errorUtil.toString(message));
1901
- }
1902
- lt(value, message) {
1903
- return this.setLimit("max", value, false, errorUtil.toString(message));
1904
- }
1905
- setLimit(kind, value, inclusive, message) {
1906
- return new _ZodBigInt({
1907
- ...this._def,
1908
- checks: [
1909
- ...this._def.checks,
1910
- {
1911
- kind,
1912
- value,
1913
- inclusive,
1914
- message: errorUtil.toString(message)
1915
- }
1916
- ]
1917
- });
1918
- }
1919
- _addCheck(check) {
1920
- return new _ZodBigInt({
1921
- ...this._def,
1922
- checks: [...this._def.checks, check]
1923
- });
1924
- }
1925
- positive(message) {
1926
- return this._addCheck({
1927
- kind: "min",
1928
- value: BigInt(0),
1929
- inclusive: false,
1930
- message: errorUtil.toString(message)
1931
- });
1932
- }
1933
- negative(message) {
1934
- return this._addCheck({
1935
- kind: "max",
1936
- value: BigInt(0),
1937
- inclusive: false,
1938
- message: errorUtil.toString(message)
1939
- });
1940
- }
1941
- nonpositive(message) {
1942
- return this._addCheck({
1943
- kind: "max",
1944
- value: BigInt(0),
1945
- inclusive: true,
1946
- message: errorUtil.toString(message)
1947
- });
1948
- }
1949
- nonnegative(message) {
1950
- return this._addCheck({
1951
- kind: "min",
1952
- value: BigInt(0),
1953
- inclusive: true,
1954
- message: errorUtil.toString(message)
1955
- });
1956
- }
1957
- multipleOf(value, message) {
1958
- return this._addCheck({
1959
- kind: "multipleOf",
1960
- value,
1961
- message: errorUtil.toString(message)
1962
- });
1963
- }
1964
- get minValue() {
1965
- let min = null;
1966
- for (const ch of this._def.checks) {
1967
- if (ch.kind === "min") {
1968
- if (min === null || ch.value > min)
1969
- min = ch.value;
1970
- }
1971
- }
1972
- return min;
1973
- }
1974
- get maxValue() {
1975
- let max = null;
1976
- for (const ch of this._def.checks) {
1977
- if (ch.kind === "max") {
1978
- if (max === null || ch.value < max)
1979
- max = ch.value;
1980
- }
1981
- }
1982
- return max;
1983
- }
1984
- };
1985
- ZodBigInt.create = (params) => {
1986
- var _a;
1987
- return new ZodBigInt({
1988
- checks: [],
1989
- typeName: ZodFirstPartyTypeKind.ZodBigInt,
1990
- coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1991
- ...processCreateParams(params)
1992
- });
1993
- };
1994
- var ZodBoolean = class extends ZodType {
1995
- _parse(input) {
1996
- if (this._def.coerce) {
1997
- input.data = Boolean(input.data);
1998
- }
1999
- const parsedType = this._getType(input);
2000
- if (parsedType !== ZodParsedType.boolean) {
2001
- const ctx = this._getOrReturnCtx(input);
2002
- addIssueToContext(ctx, {
2003
- code: ZodIssueCode.invalid_type,
2004
- expected: ZodParsedType.boolean,
2005
- received: ctx.parsedType
2006
- });
2007
- return INVALID;
2008
- }
2009
- return OK(input.data);
2010
- }
2011
- };
2012
- ZodBoolean.create = (params) => {
2013
- return new ZodBoolean({
2014
- typeName: ZodFirstPartyTypeKind.ZodBoolean,
2015
- coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2016
- ...processCreateParams(params)
2017
- });
2018
- };
2019
- var ZodDate = class _ZodDate extends ZodType {
2020
- _parse(input) {
2021
- if (this._def.coerce) {
2022
- input.data = new Date(input.data);
2023
- }
2024
- const parsedType = this._getType(input);
2025
- if (parsedType !== ZodParsedType.date) {
2026
- const ctx2 = this._getOrReturnCtx(input);
2027
- addIssueToContext(ctx2, {
2028
- code: ZodIssueCode.invalid_type,
2029
- expected: ZodParsedType.date,
2030
- received: ctx2.parsedType
2031
- });
2032
- return INVALID;
2033
- }
2034
- if (isNaN(input.data.getTime())) {
2035
- const ctx2 = this._getOrReturnCtx(input);
2036
- addIssueToContext(ctx2, {
2037
- code: ZodIssueCode.invalid_date
2038
- });
2039
- return INVALID;
2040
- }
2041
- const status = new ParseStatus();
2042
- let ctx = void 0;
2043
- for (const check of this._def.checks) {
2044
- if (check.kind === "min") {
2045
- if (input.data.getTime() < check.value) {
2046
- ctx = this._getOrReturnCtx(input, ctx);
2047
- addIssueToContext(ctx, {
2048
- code: ZodIssueCode.too_small,
2049
- message: check.message,
2050
- inclusive: true,
2051
- exact: false,
2052
- minimum: check.value,
2053
- type: "date"
2054
- });
2055
- status.dirty();
2056
- }
2057
- } else if (check.kind === "max") {
2058
- if (input.data.getTime() > check.value) {
2059
- ctx = this._getOrReturnCtx(input, ctx);
2060
- addIssueToContext(ctx, {
2061
- code: ZodIssueCode.too_big,
2062
- message: check.message,
2063
- inclusive: true,
2064
- exact: false,
2065
- maximum: check.value,
2066
- type: "date"
2067
- });
2068
- status.dirty();
2069
- }
2070
- } else {
2071
- util.assertNever(check);
2072
- }
2073
- }
2074
- return {
2075
- status: status.value,
2076
- value: new Date(input.data.getTime())
2077
- };
2078
- }
2079
- _addCheck(check) {
2080
- return new _ZodDate({
2081
- ...this._def,
2082
- checks: [...this._def.checks, check]
2083
- });
2084
- }
2085
- min(minDate, message) {
2086
- return this._addCheck({
2087
- kind: "min",
2088
- value: minDate.getTime(),
2089
- message: errorUtil.toString(message)
2090
- });
2091
- }
2092
- max(maxDate, message) {
2093
- return this._addCheck({
2094
- kind: "max",
2095
- value: maxDate.getTime(),
2096
- message: errorUtil.toString(message)
2097
- });
2098
- }
2099
- get minDate() {
2100
- let min = null;
2101
- for (const ch of this._def.checks) {
2102
- if (ch.kind === "min") {
2103
- if (min === null || ch.value > min)
2104
- min = ch.value;
2105
- }
2106
- }
2107
- return min != null ? new Date(min) : null;
2108
- }
2109
- get maxDate() {
2110
- let max = null;
2111
- for (const ch of this._def.checks) {
2112
- if (ch.kind === "max") {
2113
- if (max === null || ch.value < max)
2114
- max = ch.value;
2115
- }
2116
- }
2117
- return max != null ? new Date(max) : null;
2118
- }
2119
- };
2120
- ZodDate.create = (params) => {
2121
- return new ZodDate({
2122
- checks: [],
2123
- coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2124
- typeName: ZodFirstPartyTypeKind.ZodDate,
2125
- ...processCreateParams(params)
2126
- });
2127
- };
2128
- var ZodSymbol = class extends ZodType {
2129
- _parse(input) {
2130
- const parsedType = this._getType(input);
2131
- if (parsedType !== ZodParsedType.symbol) {
2132
- const ctx = this._getOrReturnCtx(input);
2133
- addIssueToContext(ctx, {
2134
- code: ZodIssueCode.invalid_type,
2135
- expected: ZodParsedType.symbol,
2136
- received: ctx.parsedType
2137
- });
2138
- return INVALID;
2139
- }
2140
- return OK(input.data);
2141
- }
2142
- };
2143
- ZodSymbol.create = (params) => {
2144
- return new ZodSymbol({
2145
- typeName: ZodFirstPartyTypeKind.ZodSymbol,
2146
- ...processCreateParams(params)
2147
- });
2148
- };
2149
- var ZodUndefined = class extends ZodType {
2150
- _parse(input) {
2151
- const parsedType = this._getType(input);
2152
- if (parsedType !== ZodParsedType.undefined) {
2153
- const ctx = this._getOrReturnCtx(input);
2154
- addIssueToContext(ctx, {
2155
- code: ZodIssueCode.invalid_type,
2156
- expected: ZodParsedType.undefined,
2157
- received: ctx.parsedType
2158
- });
2159
- return INVALID;
2160
- }
2161
- return OK(input.data);
2162
- }
2163
- };
2164
- ZodUndefined.create = (params) => {
2165
- return new ZodUndefined({
2166
- typeName: ZodFirstPartyTypeKind.ZodUndefined,
2167
- ...processCreateParams(params)
2168
- });
2169
- };
2170
- var ZodNull = class extends ZodType {
2171
- _parse(input) {
2172
- const parsedType = this._getType(input);
2173
- if (parsedType !== ZodParsedType.null) {
2174
- const ctx = this._getOrReturnCtx(input);
2175
- addIssueToContext(ctx, {
2176
- code: ZodIssueCode.invalid_type,
2177
- expected: ZodParsedType.null,
2178
- received: ctx.parsedType
2179
- });
2180
- return INVALID;
2181
- }
2182
- return OK(input.data);
2183
- }
2184
- };
2185
- ZodNull.create = (params) => {
2186
- return new ZodNull({
2187
- typeName: ZodFirstPartyTypeKind.ZodNull,
2188
- ...processCreateParams(params)
2189
- });
2190
- };
2191
- var ZodAny = class extends ZodType {
2192
- constructor() {
2193
- super(...arguments);
2194
- this._any = true;
2195
- }
2196
- _parse(input) {
2197
- return OK(input.data);
2198
- }
2199
- };
2200
- ZodAny.create = (params) => {
2201
- return new ZodAny({
2202
- typeName: ZodFirstPartyTypeKind.ZodAny,
2203
- ...processCreateParams(params)
2204
- });
2205
- };
2206
- var ZodUnknown = class extends ZodType {
2207
- constructor() {
2208
- super(...arguments);
2209
- this._unknown = true;
2210
- }
2211
- _parse(input) {
2212
- return OK(input.data);
2213
- }
2214
- };
2215
- ZodUnknown.create = (params) => {
2216
- return new ZodUnknown({
2217
- typeName: ZodFirstPartyTypeKind.ZodUnknown,
2218
- ...processCreateParams(params)
2219
- });
2220
- };
2221
- var ZodNever = class extends ZodType {
2222
- _parse(input) {
2223
- const ctx = this._getOrReturnCtx(input);
2224
- addIssueToContext(ctx, {
2225
- code: ZodIssueCode.invalid_type,
2226
- expected: ZodParsedType.never,
2227
- received: ctx.parsedType
2228
- });
2229
- return INVALID;
2230
- }
2231
- };
2232
- ZodNever.create = (params) => {
2233
- return new ZodNever({
2234
- typeName: ZodFirstPartyTypeKind.ZodNever,
2235
- ...processCreateParams(params)
2236
- });
2237
- };
2238
- var ZodVoid = class extends ZodType {
2239
- _parse(input) {
2240
- const parsedType = this._getType(input);
2241
- if (parsedType !== ZodParsedType.undefined) {
2242
- const ctx = this._getOrReturnCtx(input);
2243
- addIssueToContext(ctx, {
2244
- code: ZodIssueCode.invalid_type,
2245
- expected: ZodParsedType.void,
2246
- received: ctx.parsedType
2247
- });
2248
- return INVALID;
2249
- }
2250
- return OK(input.data);
2251
- }
2252
- };
2253
- ZodVoid.create = (params) => {
2254
- return new ZodVoid({
2255
- typeName: ZodFirstPartyTypeKind.ZodVoid,
2256
- ...processCreateParams(params)
2257
- });
2258
- };
2259
- var ZodArray = class _ZodArray extends ZodType {
2260
- _parse(input) {
2261
- const { ctx, status } = this._processInputParams(input);
2262
- const def = this._def;
2263
- if (ctx.parsedType !== ZodParsedType.array) {
2264
- addIssueToContext(ctx, {
2265
- code: ZodIssueCode.invalid_type,
2266
- expected: ZodParsedType.array,
2267
- received: ctx.parsedType
2268
- });
2269
- return INVALID;
2270
- }
2271
- if (def.exactLength !== null) {
2272
- const tooBig = ctx.data.length > def.exactLength.value;
2273
- const tooSmall = ctx.data.length < def.exactLength.value;
2274
- if (tooBig || tooSmall) {
2275
- addIssueToContext(ctx, {
2276
- code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
2277
- minimum: tooSmall ? def.exactLength.value : void 0,
2278
- maximum: tooBig ? def.exactLength.value : void 0,
2279
- type: "array",
2280
- inclusive: true,
2281
- exact: true,
2282
- message: def.exactLength.message
2283
- });
2284
- status.dirty();
2285
- }
2286
- }
2287
- if (def.minLength !== null) {
2288
- if (ctx.data.length < def.minLength.value) {
2289
- addIssueToContext(ctx, {
2290
- code: ZodIssueCode.too_small,
2291
- minimum: def.minLength.value,
2292
- type: "array",
2293
- inclusive: true,
2294
- exact: false,
2295
- message: def.minLength.message
2296
- });
2297
- status.dirty();
2298
- }
2299
- }
2300
- if (def.maxLength !== null) {
2301
- if (ctx.data.length > def.maxLength.value) {
2302
- addIssueToContext(ctx, {
2303
- code: ZodIssueCode.too_big,
2304
- maximum: def.maxLength.value,
2305
- type: "array",
2306
- inclusive: true,
2307
- exact: false,
2308
- message: def.maxLength.message
2309
- });
2310
- status.dirty();
2311
- }
2312
- }
2313
- if (ctx.common.async) {
2314
- return Promise.all([...ctx.data].map((item, i) => {
2315
- return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2316
- })).then((result2) => {
2317
- return ParseStatus.mergeArray(status, result2);
2318
- });
2319
- }
2320
- const result = [...ctx.data].map((item, i) => {
2321
- return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2322
- });
2323
- return ParseStatus.mergeArray(status, result);
2324
- }
2325
- get element() {
2326
- return this._def.type;
2327
- }
2328
- min(minLength, message) {
2329
- return new _ZodArray({
2330
- ...this._def,
2331
- minLength: { value: minLength, message: errorUtil.toString(message) }
2332
- });
2333
- }
2334
- max(maxLength, message) {
2335
- return new _ZodArray({
2336
- ...this._def,
2337
- maxLength: { value: maxLength, message: errorUtil.toString(message) }
2338
- });
2339
- }
2340
- length(len, message) {
2341
- return new _ZodArray({
2342
- ...this._def,
2343
- exactLength: { value: len, message: errorUtil.toString(message) }
2344
- });
2345
- }
2346
- nonempty(message) {
2347
- return this.min(1, message);
2348
- }
2349
- };
2350
- ZodArray.create = (schema, params) => {
2351
- return new ZodArray({
2352
- type: schema,
2353
- minLength: null,
2354
- maxLength: null,
2355
- exactLength: null,
2356
- typeName: ZodFirstPartyTypeKind.ZodArray,
2357
- ...processCreateParams(params)
2358
- });
2359
- };
2360
- function deepPartialify(schema) {
2361
- if (schema instanceof ZodObject) {
2362
- const newShape = {};
2363
- for (const key in schema.shape) {
2364
- const fieldSchema = schema.shape[key];
2365
- newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
2366
- }
2367
- return new ZodObject({
2368
- ...schema._def,
2369
- shape: () => newShape
2370
- });
2371
- } else if (schema instanceof ZodArray) {
2372
- return new ZodArray({
2373
- ...schema._def,
2374
- type: deepPartialify(schema.element)
2375
- });
2376
- } else if (schema instanceof ZodOptional) {
2377
- return ZodOptional.create(deepPartialify(schema.unwrap()));
2378
- } else if (schema instanceof ZodNullable) {
2379
- return ZodNullable.create(deepPartialify(schema.unwrap()));
2380
- } else if (schema instanceof ZodTuple) {
2381
- return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
2382
- } else {
2383
- return schema;
2384
- }
2385
- }
2386
- var ZodObject = class _ZodObject extends ZodType {
2387
- constructor() {
2388
- super(...arguments);
2389
- this._cached = null;
2390
- this.nonstrict = this.passthrough;
2391
- this.augment = this.extend;
2392
- }
2393
- _getCached() {
2394
- if (this._cached !== null)
2395
- return this._cached;
2396
- const shape = this._def.shape();
2397
- const keys = util.objectKeys(shape);
2398
- return this._cached = { shape, keys };
2399
- }
2400
- _parse(input) {
2401
- const parsedType = this._getType(input);
2402
- if (parsedType !== ZodParsedType.object) {
2403
- const ctx2 = this._getOrReturnCtx(input);
2404
- addIssueToContext(ctx2, {
2405
- code: ZodIssueCode.invalid_type,
2406
- expected: ZodParsedType.object,
2407
- received: ctx2.parsedType
2408
- });
2409
- return INVALID;
2410
- }
2411
- const { status, ctx } = this._processInputParams(input);
2412
- const { shape, keys: shapeKeys } = this._getCached();
2413
- const extraKeys = [];
2414
- if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
2415
- for (const key in ctx.data) {
2416
- if (!shapeKeys.includes(key)) {
2417
- extraKeys.push(key);
2418
- }
2419
- }
2420
- }
2421
- const pairs = [];
2422
- for (const key of shapeKeys) {
2423
- const keyValidator = shape[key];
2424
- const value = ctx.data[key];
2425
- pairs.push({
2426
- key: { status: "valid", value: key },
2427
- value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2428
- alwaysSet: key in ctx.data
2429
- });
2430
- }
2431
- if (this._def.catchall instanceof ZodNever) {
2432
- const unknownKeys = this._def.unknownKeys;
2433
- if (unknownKeys === "passthrough") {
2434
- for (const key of extraKeys) {
2435
- pairs.push({
2436
- key: { status: "valid", value: key },
2437
- value: { status: "valid", value: ctx.data[key] }
2438
- });
2439
- }
2440
- } else if (unknownKeys === "strict") {
2441
- if (extraKeys.length > 0) {
2442
- addIssueToContext(ctx, {
2443
- code: ZodIssueCode.unrecognized_keys,
2444
- keys: extraKeys
2445
- });
2446
- status.dirty();
2447
- }
2448
- } else if (unknownKeys === "strip")
2449
- ;
2450
- else {
2451
- throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
2452
- }
2453
- } else {
2454
- const catchall = this._def.catchall;
2455
- for (const key of extraKeys) {
2456
- const value = ctx.data[key];
2457
- pairs.push({
2458
- key: { status: "valid", value: key },
2459
- value: catchall._parse(
2460
- new ParseInputLazyPath(ctx, value, ctx.path, key)
2461
- //, ctx.child(key), value, getParsedType(value)
2462
- ),
2463
- alwaysSet: key in ctx.data
2464
- });
2465
- }
2466
- }
2467
- if (ctx.common.async) {
2468
- return Promise.resolve().then(async () => {
2469
- const syncPairs = [];
2470
- for (const pair of pairs) {
2471
- const key = await pair.key;
2472
- const value = await pair.value;
2473
- syncPairs.push({
2474
- key,
2475
- value,
2476
- alwaysSet: pair.alwaysSet
2477
- });
2478
- }
2479
- return syncPairs;
2480
- }).then((syncPairs) => {
2481
- return ParseStatus.mergeObjectSync(status, syncPairs);
2482
- });
2483
- } else {
2484
- return ParseStatus.mergeObjectSync(status, pairs);
2485
- }
2486
- }
2487
- get shape() {
2488
- return this._def.shape();
2489
- }
2490
- strict(message) {
2491
- errorUtil.errToObj;
2492
- return new _ZodObject({
2493
- ...this._def,
2494
- unknownKeys: "strict",
2495
- ...message !== void 0 ? {
2496
- errorMap: (issue, ctx) => {
2497
- var _a, _b, _c, _d;
2498
- const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
2499
- if (issue.code === "unrecognized_keys")
2500
- return {
2501
- message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
2502
- };
2503
- return {
2504
- message: defaultError
2505
- };
2506
- }
2507
- } : {}
2508
- });
2509
- }
2510
- strip() {
2511
- return new _ZodObject({
2512
- ...this._def,
2513
- unknownKeys: "strip"
2514
- });
2515
- }
2516
- passthrough() {
2517
- return new _ZodObject({
2518
- ...this._def,
2519
- unknownKeys: "passthrough"
2520
- });
2521
- }
2522
- // const AugmentFactory =
2523
- // <Def extends ZodObjectDef>(def: Def) =>
2524
- // <Augmentation extends ZodRawShape>(
2525
- // augmentation: Augmentation
2526
- // ): ZodObject<
2527
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2528
- // Def["unknownKeys"],
2529
- // Def["catchall"]
2530
- // > => {
2531
- // return new ZodObject({
2532
- // ...def,
2533
- // shape: () => ({
2534
- // ...def.shape(),
2535
- // ...augmentation,
2536
- // }),
2537
- // }) as any;
2538
- // };
2539
- extend(augmentation) {
2540
- return new _ZodObject({
2541
- ...this._def,
2542
- shape: () => ({
2543
- ...this._def.shape(),
2544
- ...augmentation
2545
- })
2546
- });
2547
- }
2548
- /**
2549
- * Prior to zod@1.0.12 there was a bug in the
2550
- * inferred type of merged objects. Please
2551
- * upgrade if you are experiencing issues.
2552
- */
2553
- merge(merging) {
2554
- const merged = new _ZodObject({
2555
- unknownKeys: merging._def.unknownKeys,
2556
- catchall: merging._def.catchall,
2557
- shape: () => ({
2558
- ...this._def.shape(),
2559
- ...merging._def.shape()
2560
- }),
2561
- typeName: ZodFirstPartyTypeKind.ZodObject
2562
- });
2563
- return merged;
2564
- }
2565
- // merge<
2566
- // Incoming extends AnyZodObject,
2567
- // Augmentation extends Incoming["shape"],
2568
- // NewOutput extends {
2569
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2570
- // ? Augmentation[k]["_output"]
2571
- // : k extends keyof Output
2572
- // ? Output[k]
2573
- // : never;
2574
- // },
2575
- // NewInput extends {
2576
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2577
- // ? Augmentation[k]["_input"]
2578
- // : k extends keyof Input
2579
- // ? Input[k]
2580
- // : never;
2581
- // }
2582
- // >(
2583
- // merging: Incoming
2584
- // ): ZodObject<
2585
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2586
- // Incoming["_def"]["unknownKeys"],
2587
- // Incoming["_def"]["catchall"],
2588
- // NewOutput,
2589
- // NewInput
2590
- // > {
2591
- // const merged: any = new ZodObject({
2592
- // unknownKeys: merging._def.unknownKeys,
2593
- // catchall: merging._def.catchall,
2594
- // shape: () =>
2595
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2596
- // typeName: ZodFirstPartyTypeKind.ZodObject,
2597
- // }) as any;
2598
- // return merged;
2599
- // }
2600
- setKey(key, schema) {
2601
- return this.augment({ [key]: schema });
2602
- }
2603
- // merge<Incoming extends AnyZodObject>(
2604
- // merging: Incoming
2605
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2606
- // ZodObject<
2607
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2608
- // Incoming["_def"]["unknownKeys"],
2609
- // Incoming["_def"]["catchall"]
2610
- // > {
2611
- // // const mergedShape = objectUtil.mergeShapes(
2612
- // // this._def.shape(),
2613
- // // merging._def.shape()
2614
- // // );
2615
- // const merged: any = new ZodObject({
2616
- // unknownKeys: merging._def.unknownKeys,
2617
- // catchall: merging._def.catchall,
2618
- // shape: () =>
2619
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2620
- // typeName: ZodFirstPartyTypeKind.ZodObject,
2621
- // }) as any;
2622
- // return merged;
2623
- // }
2624
- catchall(index) {
2625
- return new _ZodObject({
2626
- ...this._def,
2627
- catchall: index
2628
- });
2629
- }
2630
- pick(mask) {
2631
- const shape = {};
2632
- util.objectKeys(mask).forEach((key) => {
2633
- if (mask[key] && this.shape[key]) {
2634
- shape[key] = this.shape[key];
2635
- }
2636
- });
2637
- return new _ZodObject({
2638
- ...this._def,
2639
- shape: () => shape
2640
- });
2641
- }
2642
- omit(mask) {
2643
- const shape = {};
2644
- util.objectKeys(this.shape).forEach((key) => {
2645
- if (!mask[key]) {
2646
- shape[key] = this.shape[key];
2647
- }
2648
- });
2649
- return new _ZodObject({
2650
- ...this._def,
2651
- shape: () => shape
2652
- });
2653
- }
2654
- /**
2655
- * @deprecated
2656
- */
2657
- deepPartial() {
2658
- return deepPartialify(this);
2659
- }
2660
- partial(mask) {
2661
- const newShape = {};
2662
- util.objectKeys(this.shape).forEach((key) => {
2663
- const fieldSchema = this.shape[key];
2664
- if (mask && !mask[key]) {
2665
- newShape[key] = fieldSchema;
2666
- } else {
2667
- newShape[key] = fieldSchema.optional();
2668
- }
2669
- });
2670
- return new _ZodObject({
2671
- ...this._def,
2672
- shape: () => newShape
2673
- });
2674
- }
2675
- required(mask) {
2676
- const newShape = {};
2677
- util.objectKeys(this.shape).forEach((key) => {
2678
- if (mask && !mask[key]) {
2679
- newShape[key] = this.shape[key];
2680
- } else {
2681
- const fieldSchema = this.shape[key];
2682
- let newField = fieldSchema;
2683
- while (newField instanceof ZodOptional) {
2684
- newField = newField._def.innerType;
2685
- }
2686
- newShape[key] = newField;
2687
- }
2688
- });
2689
- return new _ZodObject({
2690
- ...this._def,
2691
- shape: () => newShape
2692
- });
2693
- }
2694
- keyof() {
2695
- return createZodEnum(util.objectKeys(this.shape));
2696
- }
2697
- };
2698
- ZodObject.create = (shape, params) => {
2699
- return new ZodObject({
2700
- shape: () => shape,
2701
- unknownKeys: "strip",
2702
- catchall: ZodNever.create(),
2703
- typeName: ZodFirstPartyTypeKind.ZodObject,
2704
- ...processCreateParams(params)
2705
- });
2706
- };
2707
- ZodObject.strictCreate = (shape, params) => {
2708
- return new ZodObject({
2709
- shape: () => shape,
2710
- unknownKeys: "strict",
2711
- catchall: ZodNever.create(),
2712
- typeName: ZodFirstPartyTypeKind.ZodObject,
2713
- ...processCreateParams(params)
2714
- });
2715
- };
2716
- ZodObject.lazycreate = (shape, params) => {
2717
- return new ZodObject({
2718
- shape,
2719
- unknownKeys: "strip",
2720
- catchall: ZodNever.create(),
2721
- typeName: ZodFirstPartyTypeKind.ZodObject,
2722
- ...processCreateParams(params)
2723
- });
2724
- };
2725
- var ZodUnion = class extends ZodType {
2726
- _parse(input) {
2727
- const { ctx } = this._processInputParams(input);
2728
- const options = this._def.options;
2729
- function handleResults(results) {
2730
- for (const result of results) {
2731
- if (result.result.status === "valid") {
2732
- return result.result;
2733
- }
2734
- }
2735
- for (const result of results) {
2736
- if (result.result.status === "dirty") {
2737
- ctx.common.issues.push(...result.ctx.common.issues);
2738
- return result.result;
2739
- }
2740
- }
2741
- const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
2742
- addIssueToContext(ctx, {
2743
- code: ZodIssueCode.invalid_union,
2744
- unionErrors
2745
- });
2746
- return INVALID;
2747
- }
2748
- if (ctx.common.async) {
2749
- return Promise.all(options.map(async (option) => {
2750
- const childCtx = {
2751
- ...ctx,
2752
- common: {
2753
- ...ctx.common,
2754
- issues: []
2755
- },
2756
- parent: null
2757
- };
2758
- return {
2759
- result: await option._parseAsync({
2760
- data: ctx.data,
2761
- path: ctx.path,
2762
- parent: childCtx
2763
- }),
2764
- ctx: childCtx
2765
- };
2766
- })).then(handleResults);
2767
- } else {
2768
- let dirty = void 0;
2769
- const issues = [];
2770
- for (const option of options) {
2771
- const childCtx = {
2772
- ...ctx,
2773
- common: {
2774
- ...ctx.common,
2775
- issues: []
2776
- },
2777
- parent: null
2778
- };
2779
- const result = option._parseSync({
2780
- data: ctx.data,
2781
- path: ctx.path,
2782
- parent: childCtx
2783
- });
2784
- if (result.status === "valid") {
2785
- return result;
2786
- } else if (result.status === "dirty" && !dirty) {
2787
- dirty = { result, ctx: childCtx };
2788
- }
2789
- if (childCtx.common.issues.length) {
2790
- issues.push(childCtx.common.issues);
2791
- }
2792
- }
2793
- if (dirty) {
2794
- ctx.common.issues.push(...dirty.ctx.common.issues);
2795
- return dirty.result;
2796
- }
2797
- const unionErrors = issues.map((issues2) => new ZodError(issues2));
2798
- addIssueToContext(ctx, {
2799
- code: ZodIssueCode.invalid_union,
2800
- unionErrors
2801
- });
2802
- return INVALID;
2803
- }
2804
- }
2805
- get options() {
2806
- return this._def.options;
2807
- }
2808
- };
2809
- ZodUnion.create = (types, params) => {
2810
- return new ZodUnion({
2811
- options: types,
2812
- typeName: ZodFirstPartyTypeKind.ZodUnion,
2813
- ...processCreateParams(params)
2814
- });
2815
- };
2816
- var getDiscriminator = (type) => {
2817
- if (type instanceof ZodLazy) {
2818
- return getDiscriminator(type.schema);
2819
- } else if (type instanceof ZodEffects) {
2820
- return getDiscriminator(type.innerType());
2821
- } else if (type instanceof ZodLiteral) {
2822
- return [type.value];
2823
- } else if (type instanceof ZodEnum) {
2824
- return type.options;
2825
- } else if (type instanceof ZodNativeEnum) {
2826
- return util.objectValues(type.enum);
2827
- } else if (type instanceof ZodDefault) {
2828
- return getDiscriminator(type._def.innerType);
2829
- } else if (type instanceof ZodUndefined) {
2830
- return [void 0];
2831
- } else if (type instanceof ZodNull) {
2832
- return [null];
2833
- } else if (type instanceof ZodOptional) {
2834
- return [void 0, ...getDiscriminator(type.unwrap())];
2835
- } else if (type instanceof ZodNullable) {
2836
- return [null, ...getDiscriminator(type.unwrap())];
2837
- } else if (type instanceof ZodBranded) {
2838
- return getDiscriminator(type.unwrap());
2839
- } else if (type instanceof ZodReadonly) {
2840
- return getDiscriminator(type.unwrap());
2841
- } else if (type instanceof ZodCatch) {
2842
- return getDiscriminator(type._def.innerType);
2843
- } else {
2844
- return [];
2845
- }
2846
- };
2847
- var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2848
- _parse(input) {
2849
- const { ctx } = this._processInputParams(input);
2850
- if (ctx.parsedType !== ZodParsedType.object) {
2851
- addIssueToContext(ctx, {
2852
- code: ZodIssueCode.invalid_type,
2853
- expected: ZodParsedType.object,
2854
- received: ctx.parsedType
2855
- });
2856
- return INVALID;
2857
- }
2858
- const discriminator = this.discriminator;
2859
- const discriminatorValue = ctx.data[discriminator];
2860
- const option = this.optionsMap.get(discriminatorValue);
2861
- if (!option) {
2862
- addIssueToContext(ctx, {
2863
- code: ZodIssueCode.invalid_union_discriminator,
2864
- options: Array.from(this.optionsMap.keys()),
2865
- path: [discriminator]
2866
- });
2867
- return INVALID;
2868
- }
2869
- if (ctx.common.async) {
2870
- return option._parseAsync({
2871
- data: ctx.data,
2872
- path: ctx.path,
2873
- parent: ctx
2874
- });
2875
- } else {
2876
- return option._parseSync({
2877
- data: ctx.data,
2878
- path: ctx.path,
2879
- parent: ctx
2880
- });
2881
- }
2882
- }
2883
- get discriminator() {
2884
- return this._def.discriminator;
2885
- }
2886
- get options() {
2887
- return this._def.options;
2888
- }
2889
- get optionsMap() {
2890
- return this._def.optionsMap;
2891
- }
2892
- /**
2893
- * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2894
- * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2895
- * have a different value for each object in the union.
2896
- * @param discriminator the name of the discriminator property
2897
- * @param types an array of object schemas
2898
- * @param params
2899
- */
2900
- static create(discriminator, options, params) {
2901
- const optionsMap = /* @__PURE__ */ new Map();
2902
- for (const type of options) {
2903
- const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2904
- if (!discriminatorValues.length) {
2905
- throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2906
- }
2907
- for (const value of discriminatorValues) {
2908
- if (optionsMap.has(value)) {
2909
- throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
2910
- }
2911
- optionsMap.set(value, type);
2912
- }
2913
- }
2914
- return new _ZodDiscriminatedUnion({
2915
- typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2916
- discriminator,
2917
- options,
2918
- optionsMap,
2919
- ...processCreateParams(params)
2920
- });
2921
- }
2922
- };
2923
- function mergeValues(a, b) {
2924
- const aType = getParsedType(a);
2925
- const bType = getParsedType(b);
2926
- if (a === b) {
2927
- return { valid: true, data: a };
2928
- } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
2929
- const bKeys = util.objectKeys(b);
2930
- const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
2931
- const newObj = { ...a, ...b };
2932
- for (const key of sharedKeys) {
2933
- const sharedValue = mergeValues(a[key], b[key]);
2934
- if (!sharedValue.valid) {
2935
- return { valid: false };
2936
- }
2937
- newObj[key] = sharedValue.data;
2938
- }
2939
- return { valid: true, data: newObj };
2940
- } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
2941
- if (a.length !== b.length) {
2942
- return { valid: false };
2943
- }
2944
- const newArray = [];
2945
- for (let index = 0; index < a.length; index++) {
2946
- const itemA = a[index];
2947
- const itemB = b[index];
2948
- const sharedValue = mergeValues(itemA, itemB);
2949
- if (!sharedValue.valid) {
2950
- return { valid: false };
2951
- }
2952
- newArray.push(sharedValue.data);
2953
- }
2954
- return { valid: true, data: newArray };
2955
- } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
2956
- return { valid: true, data: a };
2957
- } else {
2958
- return { valid: false };
2959
- }
2960
- }
2961
- var ZodIntersection = class extends ZodType {
2962
- _parse(input) {
2963
- const { status, ctx } = this._processInputParams(input);
2964
- const handleParsed = (parsedLeft, parsedRight) => {
2965
- if (isAborted(parsedLeft) || isAborted(parsedRight)) {
2966
- return INVALID;
2967
- }
2968
- const merged = mergeValues(parsedLeft.value, parsedRight.value);
2969
- if (!merged.valid) {
2970
- addIssueToContext(ctx, {
2971
- code: ZodIssueCode.invalid_intersection_types
2972
- });
2973
- return INVALID;
2974
- }
2975
- if (isDirty(parsedLeft) || isDirty(parsedRight)) {
2976
- status.dirty();
2977
- }
2978
- return { status: status.value, value: merged.data };
2979
- };
2980
- if (ctx.common.async) {
2981
- return Promise.all([
2982
- this._def.left._parseAsync({
2983
- data: ctx.data,
2984
- path: ctx.path,
2985
- parent: ctx
2986
- }),
2987
- this._def.right._parseAsync({
2988
- data: ctx.data,
2989
- path: ctx.path,
2990
- parent: ctx
2991
- })
2992
- ]).then(([left, right]) => handleParsed(left, right));
2993
- } else {
2994
- return handleParsed(this._def.left._parseSync({
2995
- data: ctx.data,
2996
- path: ctx.path,
2997
- parent: ctx
2998
- }), this._def.right._parseSync({
2999
- data: ctx.data,
3000
- path: ctx.path,
3001
- parent: ctx
3002
- }));
3003
- }
3004
- }
3005
- };
3006
- ZodIntersection.create = (left, right, params) => {
3007
- return new ZodIntersection({
3008
- left,
3009
- right,
3010
- typeName: ZodFirstPartyTypeKind.ZodIntersection,
3011
- ...processCreateParams(params)
3012
- });
3013
- };
3014
- var ZodTuple = class _ZodTuple extends ZodType {
3015
- _parse(input) {
3016
- const { status, ctx } = this._processInputParams(input);
3017
- if (ctx.parsedType !== ZodParsedType.array) {
3018
- addIssueToContext(ctx, {
3019
- code: ZodIssueCode.invalid_type,
3020
- expected: ZodParsedType.array,
3021
- received: ctx.parsedType
3022
- });
3023
- return INVALID;
3024
- }
3025
- if (ctx.data.length < this._def.items.length) {
3026
- addIssueToContext(ctx, {
3027
- code: ZodIssueCode.too_small,
3028
- minimum: this._def.items.length,
3029
- inclusive: true,
3030
- exact: false,
3031
- type: "array"
3032
- });
3033
- return INVALID;
3034
- }
3035
- const rest = this._def.rest;
3036
- if (!rest && ctx.data.length > this._def.items.length) {
3037
- addIssueToContext(ctx, {
3038
- code: ZodIssueCode.too_big,
3039
- maximum: this._def.items.length,
3040
- inclusive: true,
3041
- exact: false,
3042
- type: "array"
3043
- });
3044
- status.dirty();
3045
- }
3046
- const items = [...ctx.data].map((item, itemIndex) => {
3047
- const schema = this._def.items[itemIndex] || this._def.rest;
3048
- if (!schema)
3049
- return null;
3050
- return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3051
- }).filter((x) => !!x);
3052
- if (ctx.common.async) {
3053
- return Promise.all(items).then((results) => {
3054
- return ParseStatus.mergeArray(status, results);
3055
- });
3056
- } else {
3057
- return ParseStatus.mergeArray(status, items);
3058
- }
3059
- }
3060
- get items() {
3061
- return this._def.items;
3062
- }
3063
- rest(rest) {
3064
- return new _ZodTuple({
3065
- ...this._def,
3066
- rest
3067
- });
3068
- }
3069
- };
3070
- ZodTuple.create = (schemas, params) => {
3071
- if (!Array.isArray(schemas)) {
3072
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3073
- }
3074
- return new ZodTuple({
3075
- items: schemas,
3076
- typeName: ZodFirstPartyTypeKind.ZodTuple,
3077
- rest: null,
3078
- ...processCreateParams(params)
3079
- });
3080
- };
3081
- var ZodRecord = class _ZodRecord extends ZodType {
3082
- get keySchema() {
3083
- return this._def.keyType;
3084
- }
3085
- get valueSchema() {
3086
- return this._def.valueType;
3087
- }
3088
- _parse(input) {
3089
- const { status, ctx } = this._processInputParams(input);
3090
- if (ctx.parsedType !== ZodParsedType.object) {
3091
- addIssueToContext(ctx, {
3092
- code: ZodIssueCode.invalid_type,
3093
- expected: ZodParsedType.object,
3094
- received: ctx.parsedType
3095
- });
3096
- return INVALID;
3097
- }
3098
- const pairs = [];
3099
- const keyType = this._def.keyType;
3100
- const valueType = this._def.valueType;
3101
- for (const key in ctx.data) {
3102
- pairs.push({
3103
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3104
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3105
- alwaysSet: key in ctx.data
3106
- });
3107
- }
3108
- if (ctx.common.async) {
3109
- return ParseStatus.mergeObjectAsync(status, pairs);
3110
- } else {
3111
- return ParseStatus.mergeObjectSync(status, pairs);
3112
- }
3113
- }
3114
- get element() {
3115
- return this._def.valueType;
3116
- }
3117
- static create(first, second, third) {
3118
- if (second instanceof ZodType) {
3119
- return new _ZodRecord({
3120
- keyType: first,
3121
- valueType: second,
3122
- typeName: ZodFirstPartyTypeKind.ZodRecord,
3123
- ...processCreateParams(third)
3124
- });
3125
- }
3126
- return new _ZodRecord({
3127
- keyType: ZodString.create(),
3128
- valueType: first,
3129
- typeName: ZodFirstPartyTypeKind.ZodRecord,
3130
- ...processCreateParams(second)
3131
- });
3132
- }
3133
- };
3134
- var ZodMap = class extends ZodType {
3135
- get keySchema() {
3136
- return this._def.keyType;
3137
- }
3138
- get valueSchema() {
3139
- return this._def.valueType;
3140
- }
3141
- _parse(input) {
3142
- const { status, ctx } = this._processInputParams(input);
3143
- if (ctx.parsedType !== ZodParsedType.map) {
3144
- addIssueToContext(ctx, {
3145
- code: ZodIssueCode.invalid_type,
3146
- expected: ZodParsedType.map,
3147
- received: ctx.parsedType
3148
- });
3149
- return INVALID;
3150
- }
3151
- const keyType = this._def.keyType;
3152
- const valueType = this._def.valueType;
3153
- const pairs = [...ctx.data.entries()].map(([key, value], index) => {
3154
- return {
3155
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
3156
- value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
3157
- };
3158
- });
3159
- if (ctx.common.async) {
3160
- const finalMap = /* @__PURE__ */ new Map();
3161
- return Promise.resolve().then(async () => {
3162
- for (const pair of pairs) {
3163
- const key = await pair.key;
3164
- const value = await pair.value;
3165
- if (key.status === "aborted" || value.status === "aborted") {
3166
- return INVALID;
3167
- }
3168
- if (key.status === "dirty" || value.status === "dirty") {
3169
- status.dirty();
3170
- }
3171
- finalMap.set(key.value, value.value);
3172
- }
3173
- return { status: status.value, value: finalMap };
3174
- });
3175
- } else {
3176
- const finalMap = /* @__PURE__ */ new Map();
3177
- for (const pair of pairs) {
3178
- const key = pair.key;
3179
- const value = pair.value;
3180
- if (key.status === "aborted" || value.status === "aborted") {
3181
- return INVALID;
3182
- }
3183
- if (key.status === "dirty" || value.status === "dirty") {
3184
- status.dirty();
3185
- }
3186
- finalMap.set(key.value, value.value);
3187
- }
3188
- return { status: status.value, value: finalMap };
3189
- }
3190
- }
3191
- };
3192
- ZodMap.create = (keyType, valueType, params) => {
3193
- return new ZodMap({
3194
- valueType,
3195
- keyType,
3196
- typeName: ZodFirstPartyTypeKind.ZodMap,
3197
- ...processCreateParams(params)
3198
- });
3199
- };
3200
- var ZodSet = class _ZodSet extends ZodType {
3201
- _parse(input) {
3202
- const { status, ctx } = this._processInputParams(input);
3203
- if (ctx.parsedType !== ZodParsedType.set) {
3204
- addIssueToContext(ctx, {
3205
- code: ZodIssueCode.invalid_type,
3206
- expected: ZodParsedType.set,
3207
- received: ctx.parsedType
3208
- });
3209
- return INVALID;
3210
- }
3211
- const def = this._def;
3212
- if (def.minSize !== null) {
3213
- if (ctx.data.size < def.minSize.value) {
3214
- addIssueToContext(ctx, {
3215
- code: ZodIssueCode.too_small,
3216
- minimum: def.minSize.value,
3217
- type: "set",
3218
- inclusive: true,
3219
- exact: false,
3220
- message: def.minSize.message
3221
- });
3222
- status.dirty();
3223
- }
3224
- }
3225
- if (def.maxSize !== null) {
3226
- if (ctx.data.size > def.maxSize.value) {
3227
- addIssueToContext(ctx, {
3228
- code: ZodIssueCode.too_big,
3229
- maximum: def.maxSize.value,
3230
- type: "set",
3231
- inclusive: true,
3232
- exact: false,
3233
- message: def.maxSize.message
3234
- });
3235
- status.dirty();
3236
- }
3237
- }
3238
- const valueType = this._def.valueType;
3239
- function finalizeSet(elements2) {
3240
- const parsedSet = /* @__PURE__ */ new Set();
3241
- for (const element of elements2) {
3242
- if (element.status === "aborted")
3243
- return INVALID;
3244
- if (element.status === "dirty")
3245
- status.dirty();
3246
- parsedSet.add(element.value);
3247
- }
3248
- return { status: status.value, value: parsedSet };
3249
- }
3250
- const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
3251
- if (ctx.common.async) {
3252
- return Promise.all(elements).then((elements2) => finalizeSet(elements2));
3253
- } else {
3254
- return finalizeSet(elements);
3255
- }
3256
- }
3257
- min(minSize, message) {
3258
- return new _ZodSet({
3259
- ...this._def,
3260
- minSize: { value: minSize, message: errorUtil.toString(message) }
3261
- });
3262
- }
3263
- max(maxSize, message) {
3264
- return new _ZodSet({
3265
- ...this._def,
3266
- maxSize: { value: maxSize, message: errorUtil.toString(message) }
3267
- });
3268
- }
3269
- size(size, message) {
3270
- return this.min(size, message).max(size, message);
3271
- }
3272
- nonempty(message) {
3273
- return this.min(1, message);
3274
- }
3275
- };
3276
- ZodSet.create = (valueType, params) => {
3277
- return new ZodSet({
3278
- valueType,
3279
- minSize: null,
3280
- maxSize: null,
3281
- typeName: ZodFirstPartyTypeKind.ZodSet,
3282
- ...processCreateParams(params)
3283
- });
3284
- };
3285
- var ZodFunction = class _ZodFunction extends ZodType {
3286
- constructor() {
3287
- super(...arguments);
3288
- this.validate = this.implement;
3289
- }
3290
- _parse(input) {
3291
- const { ctx } = this._processInputParams(input);
3292
- if (ctx.parsedType !== ZodParsedType.function) {
3293
- addIssueToContext(ctx, {
3294
- code: ZodIssueCode.invalid_type,
3295
- expected: ZodParsedType.function,
3296
- received: ctx.parsedType
3297
- });
3298
- return INVALID;
3299
- }
3300
- function makeArgsIssue(args, error) {
3301
- return makeIssue({
3302
- data: args,
3303
- path: ctx.path,
3304
- errorMaps: [
3305
- ctx.common.contextualErrorMap,
3306
- ctx.schemaErrorMap,
3307
- getErrorMap(),
3308
- errorMap
3309
- ].filter((x) => !!x),
3310
- issueData: {
3311
- code: ZodIssueCode.invalid_arguments,
3312
- argumentsError: error
3313
- }
3314
- });
3315
- }
3316
- function makeReturnsIssue(returns, error) {
3317
- return makeIssue({
3318
- data: returns,
3319
- path: ctx.path,
3320
- errorMaps: [
3321
- ctx.common.contextualErrorMap,
3322
- ctx.schemaErrorMap,
3323
- getErrorMap(),
3324
- errorMap
3325
- ].filter((x) => !!x),
3326
- issueData: {
3327
- code: ZodIssueCode.invalid_return_type,
3328
- returnTypeError: error
3329
- }
3330
- });
3331
- }
3332
- const params = { errorMap: ctx.common.contextualErrorMap };
3333
- const fn = ctx.data;
3334
- if (this._def.returns instanceof ZodPromise) {
3335
- const me = this;
3336
- return OK(async function(...args) {
3337
- const error = new ZodError([]);
3338
- const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3339
- error.addIssue(makeArgsIssue(args, e));
3340
- throw error;
3341
- });
3342
- const result = await Reflect.apply(fn, this, parsedArgs);
3343
- const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3344
- error.addIssue(makeReturnsIssue(result, e));
3345
- throw error;
3346
- });
3347
- return parsedReturns;
3348
- });
3349
- } else {
3350
- const me = this;
3351
- return OK(function(...args) {
3352
- const parsedArgs = me._def.args.safeParse(args, params);
3353
- if (!parsedArgs.success) {
3354
- throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3355
- }
3356
- const result = Reflect.apply(fn, this, parsedArgs.data);
3357
- const parsedReturns = me._def.returns.safeParse(result, params);
3358
- if (!parsedReturns.success) {
3359
- throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3360
- }
3361
- return parsedReturns.data;
3362
- });
3363
- }
3364
- }
3365
- parameters() {
3366
- return this._def.args;
3367
- }
3368
- returnType() {
3369
- return this._def.returns;
3370
- }
3371
- args(...items) {
3372
- return new _ZodFunction({
3373
- ...this._def,
3374
- args: ZodTuple.create(items).rest(ZodUnknown.create())
3375
- });
3376
- }
3377
- returns(returnType) {
3378
- return new _ZodFunction({
3379
- ...this._def,
3380
- returns: returnType
3381
- });
3382
- }
3383
- implement(func) {
3384
- const validatedFunc = this.parse(func);
3385
- return validatedFunc;
3386
- }
3387
- strictImplement(func) {
3388
- const validatedFunc = this.parse(func);
3389
- return validatedFunc;
3390
- }
3391
- static create(args, returns, params) {
3392
- return new _ZodFunction({
3393
- args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
3394
- returns: returns || ZodUnknown.create(),
3395
- typeName: ZodFirstPartyTypeKind.ZodFunction,
3396
- ...processCreateParams(params)
3397
- });
3398
- }
3399
- };
3400
- var ZodLazy = class extends ZodType {
3401
- get schema() {
3402
- return this._def.getter();
3403
- }
3404
- _parse(input) {
3405
- const { ctx } = this._processInputParams(input);
3406
- const lazySchema = this._def.getter();
3407
- return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3408
- }
3409
- };
3410
- ZodLazy.create = (getter, params) => {
3411
- return new ZodLazy({
3412
- getter,
3413
- typeName: ZodFirstPartyTypeKind.ZodLazy,
3414
- ...processCreateParams(params)
3415
- });
3416
- };
3417
- var ZodLiteral = class extends ZodType {
3418
- _parse(input) {
3419
- if (input.data !== this._def.value) {
3420
- const ctx = this._getOrReturnCtx(input);
3421
- addIssueToContext(ctx, {
3422
- received: ctx.data,
3423
- code: ZodIssueCode.invalid_literal,
3424
- expected: this._def.value
3425
- });
3426
- return INVALID;
3427
- }
3428
- return { status: "valid", value: input.data };
3429
- }
3430
- get value() {
3431
- return this._def.value;
3432
- }
3433
- };
3434
- ZodLiteral.create = (value, params) => {
3435
- return new ZodLiteral({
3436
- value,
3437
- typeName: ZodFirstPartyTypeKind.ZodLiteral,
3438
- ...processCreateParams(params)
3439
- });
3440
- };
3441
- function createZodEnum(values, params) {
3442
- return new ZodEnum({
3443
- values,
3444
- typeName: ZodFirstPartyTypeKind.ZodEnum,
3445
- ...processCreateParams(params)
3446
- });
3447
- }
3448
- var ZodEnum = class _ZodEnum extends ZodType {
3449
- constructor() {
3450
- super(...arguments);
3451
- _ZodEnum_cache.set(this, void 0);
3452
- }
3453
- _parse(input) {
3454
- if (typeof input.data !== "string") {
3455
- const ctx = this._getOrReturnCtx(input);
3456
- const expectedValues = this._def.values;
3457
- addIssueToContext(ctx, {
3458
- expected: util.joinValues(expectedValues),
3459
- received: ctx.parsedType,
3460
- code: ZodIssueCode.invalid_type
3461
- });
3462
- return INVALID;
3463
- }
3464
- if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
3465
- __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
3466
- }
3467
- if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
3468
- const ctx = this._getOrReturnCtx(input);
3469
- const expectedValues = this._def.values;
3470
- addIssueToContext(ctx, {
3471
- received: ctx.data,
3472
- code: ZodIssueCode.invalid_enum_value,
3473
- options: expectedValues
3474
- });
3475
- return INVALID;
3476
- }
3477
- return OK(input.data);
3478
- }
3479
- get options() {
3480
- return this._def.values;
3481
- }
3482
- get enum() {
3483
- const enumValues = {};
3484
- for (const val of this._def.values) {
3485
- enumValues[val] = val;
3486
- }
3487
- return enumValues;
3488
- }
3489
- get Values() {
3490
- const enumValues = {};
3491
- for (const val of this._def.values) {
3492
- enumValues[val] = val;
3493
- }
3494
- return enumValues;
3495
- }
3496
- get Enum() {
3497
- const enumValues = {};
3498
- for (const val of this._def.values) {
3499
- enumValues[val] = val;
3500
- }
3501
- return enumValues;
3502
- }
3503
- extract(values, newDef = this._def) {
3504
- return _ZodEnum.create(values, {
3505
- ...this._def,
3506
- ...newDef
3507
- });
3508
- }
3509
- exclude(values, newDef = this._def) {
3510
- return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3511
- ...this._def,
3512
- ...newDef
3513
- });
3514
- }
3515
- };
3516
- _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
3517
- ZodEnum.create = createZodEnum;
3518
- var ZodNativeEnum = class extends ZodType {
3519
- constructor() {
3520
- super(...arguments);
3521
- _ZodNativeEnum_cache.set(this, void 0);
3522
- }
3523
- _parse(input) {
3524
- const nativeEnumValues = util.getValidEnumValues(this._def.values);
3525
- const ctx = this._getOrReturnCtx(input);
3526
- if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
3527
- const expectedValues = util.objectValues(nativeEnumValues);
3528
- addIssueToContext(ctx, {
3529
- expected: util.joinValues(expectedValues),
3530
- received: ctx.parsedType,
3531
- code: ZodIssueCode.invalid_type
3532
- });
3533
- return INVALID;
3534
- }
3535
- if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
3536
- __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
3537
- }
3538
- if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
3539
- const expectedValues = util.objectValues(nativeEnumValues);
3540
- addIssueToContext(ctx, {
3541
- received: ctx.data,
3542
- code: ZodIssueCode.invalid_enum_value,
3543
- options: expectedValues
3544
- });
3545
- return INVALID;
3546
- }
3547
- return OK(input.data);
3548
- }
3549
- get enum() {
3550
- return this._def.values;
3551
- }
3552
- };
3553
- _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
3554
- ZodNativeEnum.create = (values, params) => {
3555
- return new ZodNativeEnum({
3556
- values,
3557
- typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3558
- ...processCreateParams(params)
3559
- });
3560
- };
3561
- var ZodPromise = class extends ZodType {
3562
- unwrap() {
3563
- return this._def.type;
3564
- }
3565
- _parse(input) {
3566
- const { ctx } = this._processInputParams(input);
3567
- if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
3568
- addIssueToContext(ctx, {
3569
- code: ZodIssueCode.invalid_type,
3570
- expected: ZodParsedType.promise,
3571
- received: ctx.parsedType
3572
- });
3573
- return INVALID;
3574
- }
3575
- const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
3576
- return OK(promisified.then((data) => {
3577
- return this._def.type.parseAsync(data, {
3578
- path: ctx.path,
3579
- errorMap: ctx.common.contextualErrorMap
3580
- });
3581
- }));
3582
- }
3583
- };
3584
- ZodPromise.create = (schema, params) => {
3585
- return new ZodPromise({
3586
- type: schema,
3587
- typeName: ZodFirstPartyTypeKind.ZodPromise,
3588
- ...processCreateParams(params)
3589
- });
3590
- };
3591
- var ZodEffects = class extends ZodType {
3592
- innerType() {
3593
- return this._def.schema;
3594
- }
3595
- sourceType() {
3596
- return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3597
- }
3598
- _parse(input) {
3599
- const { status, ctx } = this._processInputParams(input);
3600
- const effect = this._def.effect || null;
3601
- const checkCtx = {
3602
- addIssue: (arg) => {
3603
- addIssueToContext(ctx, arg);
3604
- if (arg.fatal) {
3605
- status.abort();
3606
- } else {
3607
- status.dirty();
3608
- }
3609
- },
3610
- get path() {
3611
- return ctx.path;
3612
- }
3613
- };
3614
- checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3615
- if (effect.type === "preprocess") {
3616
- const processed = effect.transform(ctx.data, checkCtx);
3617
- if (ctx.common.async) {
3618
- return Promise.resolve(processed).then(async (processed2) => {
3619
- if (status.value === "aborted")
3620
- return INVALID;
3621
- const result = await this._def.schema._parseAsync({
3622
- data: processed2,
3623
- path: ctx.path,
3624
- parent: ctx
3625
- });
3626
- if (result.status === "aborted")
3627
- return INVALID;
3628
- if (result.status === "dirty")
3629
- return DIRTY(result.value);
3630
- if (status.value === "dirty")
3631
- return DIRTY(result.value);
3632
- return result;
3633
- });
3634
- } else {
3635
- if (status.value === "aborted")
3636
- return INVALID;
3637
- const result = this._def.schema._parseSync({
3638
- data: processed,
3639
- path: ctx.path,
3640
- parent: ctx
3641
- });
3642
- if (result.status === "aborted")
3643
- return INVALID;
3644
- if (result.status === "dirty")
3645
- return DIRTY(result.value);
3646
- if (status.value === "dirty")
3647
- return DIRTY(result.value);
3648
- return result;
3649
- }
3650
- }
3651
- if (effect.type === "refinement") {
3652
- const executeRefinement = (acc) => {
3653
- const result = effect.refinement(acc, checkCtx);
3654
- if (ctx.common.async) {
3655
- return Promise.resolve(result);
3656
- }
3657
- if (result instanceof Promise) {
3658
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3659
- }
3660
- return acc;
3661
- };
3662
- if (ctx.common.async === false) {
3663
- const inner = this._def.schema._parseSync({
3664
- data: ctx.data,
3665
- path: ctx.path,
3666
- parent: ctx
3667
- });
3668
- if (inner.status === "aborted")
3669
- return INVALID;
3670
- if (inner.status === "dirty")
3671
- status.dirty();
3672
- executeRefinement(inner.value);
3673
- return { status: status.value, value: inner.value };
3674
- } else {
3675
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
3676
- if (inner.status === "aborted")
3677
- return INVALID;
3678
- if (inner.status === "dirty")
3679
- status.dirty();
3680
- return executeRefinement(inner.value).then(() => {
3681
- return { status: status.value, value: inner.value };
3682
- });
3683
- });
3684
- }
3685
- }
3686
- if (effect.type === "transform") {
3687
- if (ctx.common.async === false) {
3688
- const base = this._def.schema._parseSync({
3689
- data: ctx.data,
3690
- path: ctx.path,
3691
- parent: ctx
3692
- });
3693
- if (!isValid(base))
3694
- return base;
3695
- const result = effect.transform(base.value, checkCtx);
3696
- if (result instanceof Promise) {
3697
- throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
3698
- }
3699
- return { status: status.value, value: result };
3700
- } else {
3701
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
3702
- if (!isValid(base))
3703
- return base;
3704
- return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
3705
- });
3706
- }
3707
- }
3708
- util.assertNever(effect);
3709
- }
3710
- };
3711
- ZodEffects.create = (schema, effect, params) => {
3712
- return new ZodEffects({
3713
- schema,
3714
- typeName: ZodFirstPartyTypeKind.ZodEffects,
3715
- effect,
3716
- ...processCreateParams(params)
3717
- });
3718
- };
3719
- ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3720
- return new ZodEffects({
3721
- schema,
3722
- effect: { type: "preprocess", transform: preprocess },
3723
- typeName: ZodFirstPartyTypeKind.ZodEffects,
3724
- ...processCreateParams(params)
3725
- });
3726
- };
3727
- var ZodOptional = class extends ZodType {
3728
- _parse(input) {
3729
- const parsedType = this._getType(input);
3730
- if (parsedType === ZodParsedType.undefined) {
3731
- return OK(void 0);
3732
- }
3733
- return this._def.innerType._parse(input);
3734
- }
3735
- unwrap() {
3736
- return this._def.innerType;
3737
- }
3738
- };
3739
- ZodOptional.create = (type, params) => {
3740
- return new ZodOptional({
3741
- innerType: type,
3742
- typeName: ZodFirstPartyTypeKind.ZodOptional,
3743
- ...processCreateParams(params)
3744
- });
3745
- };
3746
- var ZodNullable = class extends ZodType {
3747
- _parse(input) {
3748
- const parsedType = this._getType(input);
3749
- if (parsedType === ZodParsedType.null) {
3750
- return OK(null);
3751
- }
3752
- return this._def.innerType._parse(input);
3753
- }
3754
- unwrap() {
3755
- return this._def.innerType;
3756
- }
3757
- };
3758
- ZodNullable.create = (type, params) => {
3759
- return new ZodNullable({
3760
- innerType: type,
3761
- typeName: ZodFirstPartyTypeKind.ZodNullable,
3762
- ...processCreateParams(params)
3763
- });
3764
- };
3765
- var ZodDefault = class extends ZodType {
3766
- _parse(input) {
3767
- const { ctx } = this._processInputParams(input);
3768
- let data = ctx.data;
3769
- if (ctx.parsedType === ZodParsedType.undefined) {
3770
- data = this._def.defaultValue();
3771
- }
3772
- return this._def.innerType._parse({
3773
- data,
3774
- path: ctx.path,
3775
- parent: ctx
3776
- });
3777
- }
3778
- removeDefault() {
3779
- return this._def.innerType;
3780
- }
3781
- };
3782
- ZodDefault.create = (type, params) => {
3783
- return new ZodDefault({
3784
- innerType: type,
3785
- typeName: ZodFirstPartyTypeKind.ZodDefault,
3786
- defaultValue: typeof params.default === "function" ? params.default : () => params.default,
3787
- ...processCreateParams(params)
3788
- });
3789
- };
3790
- var ZodCatch = class extends ZodType {
3791
- _parse(input) {
3792
- const { ctx } = this._processInputParams(input);
3793
- const newCtx = {
3794
- ...ctx,
3795
- common: {
3796
- ...ctx.common,
3797
- issues: []
3798
- }
3799
- };
3800
- const result = this._def.innerType._parse({
3801
- data: newCtx.data,
3802
- path: newCtx.path,
3803
- parent: {
3804
- ...newCtx
3805
- }
3806
- });
3807
- if (isAsync(result)) {
3808
- return result.then((result2) => {
3809
- return {
3810
- status: "valid",
3811
- value: result2.status === "valid" ? result2.value : this._def.catchValue({
3812
- get error() {
3813
- return new ZodError(newCtx.common.issues);
3814
- },
3815
- input: newCtx.data
3816
- })
3817
- };
3818
- });
3819
- } else {
3820
- return {
3821
- status: "valid",
3822
- value: result.status === "valid" ? result.value : this._def.catchValue({
3823
- get error() {
3824
- return new ZodError(newCtx.common.issues);
3825
- },
3826
- input: newCtx.data
3827
- })
3828
- };
3829
- }
3830
- }
3831
- removeCatch() {
3832
- return this._def.innerType;
3833
- }
3834
- };
3835
- ZodCatch.create = (type, params) => {
3836
- return new ZodCatch({
3837
- innerType: type,
3838
- typeName: ZodFirstPartyTypeKind.ZodCatch,
3839
- catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
3840
- ...processCreateParams(params)
3841
- });
3842
- };
3843
- var ZodNaN = class extends ZodType {
3844
- _parse(input) {
3845
- const parsedType = this._getType(input);
3846
- if (parsedType !== ZodParsedType.nan) {
3847
- const ctx = this._getOrReturnCtx(input);
3848
- addIssueToContext(ctx, {
3849
- code: ZodIssueCode.invalid_type,
3850
- expected: ZodParsedType.nan,
3851
- received: ctx.parsedType
3852
- });
3853
- return INVALID;
3854
- }
3855
- return { status: "valid", value: input.data };
3856
- }
3857
- };
3858
- ZodNaN.create = (params) => {
3859
- return new ZodNaN({
3860
- typeName: ZodFirstPartyTypeKind.ZodNaN,
3861
- ...processCreateParams(params)
3862
- });
3863
- };
3864
- var BRAND = Symbol("zod_brand");
3865
- var ZodBranded = class extends ZodType {
3866
- _parse(input) {
3867
- const { ctx } = this._processInputParams(input);
3868
- const data = ctx.data;
3869
- return this._def.type._parse({
3870
- data,
3871
- path: ctx.path,
3872
- parent: ctx
3873
- });
3874
- }
3875
- unwrap() {
3876
- return this._def.type;
3877
- }
3878
- };
3879
- var ZodPipeline = class _ZodPipeline extends ZodType {
3880
- _parse(input) {
3881
- const { status, ctx } = this._processInputParams(input);
3882
- if (ctx.common.async) {
3883
- const handleAsync = async () => {
3884
- const inResult = await this._def.in._parseAsync({
3885
- data: ctx.data,
3886
- path: ctx.path,
3887
- parent: ctx
3888
- });
3889
- if (inResult.status === "aborted")
3890
- return INVALID;
3891
- if (inResult.status === "dirty") {
3892
- status.dirty();
3893
- return DIRTY(inResult.value);
3894
- } else {
3895
- return this._def.out._parseAsync({
3896
- data: inResult.value,
3897
- path: ctx.path,
3898
- parent: ctx
3899
- });
3900
- }
3901
- };
3902
- return handleAsync();
3903
- } else {
3904
- const inResult = this._def.in._parseSync({
3905
- data: ctx.data,
3906
- path: ctx.path,
3907
- parent: ctx
3908
- });
3909
- if (inResult.status === "aborted")
3910
- return INVALID;
3911
- if (inResult.status === "dirty") {
3912
- status.dirty();
3913
- return {
3914
- status: "dirty",
3915
- value: inResult.value
3916
- };
3917
- } else {
3918
- return this._def.out._parseSync({
3919
- data: inResult.value,
3920
- path: ctx.path,
3921
- parent: ctx
3922
- });
3923
- }
3924
- }
3925
- }
3926
- static create(a, b) {
3927
- return new _ZodPipeline({
3928
- in: a,
3929
- out: b,
3930
- typeName: ZodFirstPartyTypeKind.ZodPipeline
3931
- });
3932
- }
3933
- };
3934
- var ZodReadonly = class extends ZodType {
3935
- _parse(input) {
3936
- const result = this._def.innerType._parse(input);
3937
- const freeze = (data) => {
3938
- if (isValid(data)) {
3939
- data.value = Object.freeze(data.value);
3940
- }
3941
- return data;
3942
- };
3943
- return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
3944
- }
3945
- unwrap() {
3946
- return this._def.innerType;
3947
- }
3948
- };
3949
- ZodReadonly.create = (type, params) => {
3950
- return new ZodReadonly({
3951
- innerType: type,
3952
- typeName: ZodFirstPartyTypeKind.ZodReadonly,
3953
- ...processCreateParams(params)
3954
- });
3955
- };
3956
- function custom(check, params = {}, fatal) {
3957
- if (check)
3958
- return ZodAny.create().superRefine((data, ctx) => {
3959
- var _a, _b;
3960
- if (!check(data)) {
3961
- const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
3962
- const _fatal = (_b = (_a = p.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
3963
- const p2 = typeof p === "string" ? { message: p } : p;
3964
- ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
3965
- }
3966
- });
3967
- return ZodAny.create();
3968
- }
3969
- var late = {
3970
- object: ZodObject.lazycreate
3971
- };
3972
- var ZodFirstPartyTypeKind;
3973
- (function(ZodFirstPartyTypeKind2) {
3974
- ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
3975
- ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
3976
- ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
3977
- ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
3978
- ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
3979
- ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
3980
- ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
3981
- ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
3982
- ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
3983
- ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
3984
- ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
3985
- ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
3986
- ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
3987
- ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
3988
- ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
3989
- ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
3990
- ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
3991
- ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
3992
- ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
3993
- ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
3994
- ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
3995
- ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
3996
- ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
3997
- ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
3998
- ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
3999
- ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
4000
- ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
4001
- ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
4002
- ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
4003
- ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
4004
- ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
4005
- ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
4006
- ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
4007
- ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
4008
- ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
4009
- ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
4010
- })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
4011
- var instanceOfType = (cls, params = {
4012
- message: `Input not instance of ${cls.name}`
4013
- }) => custom((data) => data instanceof cls, params);
4014
- var stringType = ZodString.create;
4015
- var numberType = ZodNumber.create;
4016
- var nanType = ZodNaN.create;
4017
- var bigIntType = ZodBigInt.create;
4018
- var booleanType = ZodBoolean.create;
4019
- var dateType = ZodDate.create;
4020
- var symbolType = ZodSymbol.create;
4021
- var undefinedType = ZodUndefined.create;
4022
- var nullType = ZodNull.create;
4023
- var anyType = ZodAny.create;
4024
- var unknownType = ZodUnknown.create;
4025
- var neverType = ZodNever.create;
4026
- var voidType = ZodVoid.create;
4027
- var arrayType = ZodArray.create;
4028
- var objectType = ZodObject.create;
4029
- var strictObjectType = ZodObject.strictCreate;
4030
- var unionType = ZodUnion.create;
4031
- var discriminatedUnionType = ZodDiscriminatedUnion.create;
4032
- var intersectionType = ZodIntersection.create;
4033
- var tupleType = ZodTuple.create;
4034
- var recordType = ZodRecord.create;
4035
- var mapType = ZodMap.create;
4036
- var setType = ZodSet.create;
4037
- var functionType = ZodFunction.create;
4038
- var lazyType = ZodLazy.create;
4039
- var literalType = ZodLiteral.create;
4040
- var enumType = ZodEnum.create;
4041
- var nativeEnumType = ZodNativeEnum.create;
4042
- var promiseType = ZodPromise.create;
4043
- var effectsType = ZodEffects.create;
4044
- var optionalType = ZodOptional.create;
4045
- var nullableType = ZodNullable.create;
4046
- var preprocessType = ZodEffects.createWithPreprocess;
4047
- var pipelineType = ZodPipeline.create;
4048
- var ostring = () => stringType().optional();
4049
- var onumber = () => numberType().optional();
4050
- var oboolean = () => booleanType().optional();
4051
- var coerce = {
4052
- string: (arg) => ZodString.create({ ...arg, coerce: true }),
4053
- number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
4054
- boolean: (arg) => ZodBoolean.create({
4055
- ...arg,
4056
- coerce: true
4057
- }),
4058
- bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
4059
- date: (arg) => ZodDate.create({ ...arg, coerce: true })
4060
- };
4061
- var NEVER = INVALID;
4062
- var z = /* @__PURE__ */ Object.freeze({
4063
- __proto__: null,
4064
- defaultErrorMap: errorMap,
4065
- setErrorMap,
4066
- getErrorMap,
4067
- makeIssue,
4068
- EMPTY_PATH,
4069
- addIssueToContext,
4070
- ParseStatus,
4071
- INVALID,
4072
- DIRTY,
4073
- OK,
4074
- isAborted,
4075
- isDirty,
4076
- isValid,
4077
- isAsync,
4078
- get util() {
4079
- return util;
4080
- },
4081
- get objectUtil() {
4082
- return objectUtil;
4083
- },
4084
- ZodParsedType,
4085
- getParsedType,
4086
- ZodType,
4087
- datetimeRegex,
4088
- ZodString,
4089
- ZodNumber,
4090
- ZodBigInt,
4091
- ZodBoolean,
4092
- ZodDate,
4093
- ZodSymbol,
4094
- ZodUndefined,
4095
- ZodNull,
4096
- ZodAny,
4097
- ZodUnknown,
4098
- ZodNever,
4099
- ZodVoid,
4100
- ZodArray,
4101
- ZodObject,
4102
- ZodUnion,
4103
- ZodDiscriminatedUnion,
4104
- ZodIntersection,
4105
- ZodTuple,
4106
- ZodRecord,
4107
- ZodMap,
4108
- ZodSet,
4109
- ZodFunction,
4110
- ZodLazy,
4111
- ZodLiteral,
4112
- ZodEnum,
4113
- ZodNativeEnum,
4114
- ZodPromise,
4115
- ZodEffects,
4116
- ZodTransformer: ZodEffects,
4117
- ZodOptional,
4118
- ZodNullable,
4119
- ZodDefault,
4120
- ZodCatch,
4121
- ZodNaN,
4122
- BRAND,
4123
- ZodBranded,
4124
- ZodPipeline,
4125
- ZodReadonly,
4126
- custom,
4127
- Schema: ZodType,
4128
- ZodSchema: ZodType,
4129
- late,
4130
- get ZodFirstPartyTypeKind() {
4131
- return ZodFirstPartyTypeKind;
4132
- },
4133
- coerce,
4134
- any: anyType,
4135
- array: arrayType,
4136
- bigint: bigIntType,
4137
- boolean: booleanType,
4138
- date: dateType,
4139
- discriminatedUnion: discriminatedUnionType,
4140
- effect: effectsType,
4141
- "enum": enumType,
4142
- "function": functionType,
4143
- "instanceof": instanceOfType,
4144
- intersection: intersectionType,
4145
- lazy: lazyType,
4146
- literal: literalType,
4147
- map: mapType,
4148
- nan: nanType,
4149
- nativeEnum: nativeEnumType,
4150
- never: neverType,
4151
- "null": nullType,
4152
- nullable: nullableType,
4153
- number: numberType,
4154
- object: objectType,
4155
- oboolean,
4156
- onumber,
4157
- optional: optionalType,
4158
- ostring,
4159
- pipeline: pipelineType,
4160
- preprocess: preprocessType,
4161
- promise: promiseType,
4162
- record: recordType,
4163
- set: setType,
4164
- strictObject: strictObjectType,
4165
- string: stringType,
4166
- symbol: symbolType,
4167
- transformer: effectsType,
4168
- tuple: tupleType,
4169
- "undefined": undefinedType,
4170
- union: unionType,
4171
- unknown: unknownType,
4172
- "void": voidType,
4173
- NEVER,
4174
- ZodIssueCode,
4175
- quotelessJson,
4176
- ZodError
4177
- });
4178
-
4179
- // ../types/src/api/web/app/rows/search.ts
4180
- var fieldKey = z.string().refine((s) => s !== "_complexIdOperator" /* COMPLEX_ID_OPERATOR */, {
4181
- message: `Key '${"_complexIdOperator" /* COMPLEX_ID_OPERATOR */}' is not allowed`
4182
- });
4183
- var stringBasicFilter = z.record(fieldKey, z.string());
4184
- var basicFilter = z.record(fieldKey, z.any());
4185
- var arrayFilter = z.record(fieldKey, z.union([z.any().array(), z.string()]));
4186
- var logicFilter = z.lazy(
4187
- () => z.object({
4188
- conditions: z.array(z.object(queryFilterValidation))
4189
- })
4190
- );
4191
- var stringOrNumber = z.union([z.string(), z.number()]);
4192
- var queryFilterValidation = {
4193
- ["string" /* STRING */]: stringBasicFilter.optional(),
4194
- ["fuzzy" /* FUZZY */]: stringBasicFilter.optional(),
4195
- ["range" /* RANGE */]: z.record(
4196
- fieldKey,
4197
- z.union([
4198
- z.object({ high: stringOrNumber, low: stringOrNumber }),
4199
- z.object({ high: stringOrNumber }),
4200
- z.object({ low: stringOrNumber })
4201
- ])
4202
- ).optional(),
4203
- ["equal" /* EQUAL */]: basicFilter.optional(),
4204
- ["notEqual" /* NOT_EQUAL */]: basicFilter.optional(),
4205
- ["empty" /* EMPTY */]: basicFilter.optional(),
4206
- ["notEmpty" /* NOT_EMPTY */]: basicFilter.optional(),
4207
- ["oneOf" /* ONE_OF */]: arrayFilter.optional(),
4208
- ["contains" /* CONTAINS */]: arrayFilter.optional(),
4209
- ["notContains" /* NOT_CONTAINS */]: arrayFilter.optional(),
4210
- ["containsAny" /* CONTAINS_ANY */]: arrayFilter.optional(),
4211
- ["$and" /* AND */]: logicFilter.optional(),
4212
- ["$or" /* OR */]: logicFilter.optional()
4213
- };
4214
- var searchRowRequest = z.object({
4215
- query: z.object({
4216
- allOr: z.boolean().optional(),
4217
- onEmptyFilter: z.nativeEnum(EmptyFilterOption).optional(),
4218
- ...queryFilterValidation
4219
- }).optional(),
4220
- paginate: z.boolean().optional(),
4221
- bookmark: z.union([z.string(), z.number()]).nullish(),
4222
- limit: z.number().optional(),
4223
- sort: z.string().nullish(),
4224
- sortOrder: z.nativeEnum(SortOrder).optional(),
4225
- sortType: z.nativeEnum(SortType).nullish(),
4226
- version: z.string().optional(),
4227
- disableEscaping: z.boolean().optional(),
4228
- countRows: z.boolean().optional()
4229
- });
4230
-
4231
- // src/plugin/utils.ts
4232
- var import_joi = __toESM(require("joi"));
4233
- var DATASOURCE_TYPES = [
4234
- "Relational",
4235
- "Non-relational",
4236
- "Spreadsheet",
4237
- "Object store",
4238
- "Graph",
4239
- "API"
4240
- ];
4241
- function runJoi(validator, schema) {
4242
- const { error } = validator.validate(schema);
4243
- if (error) {
4244
- throw error;
4245
- }
4246
- }
4247
- function validateComponent(schema) {
4248
- const validator = import_joi.default.object({
4249
- type: import_joi.default.string().allow("component" /* COMPONENT */).required(),
4250
- metadata: import_joi.default.object().unknown(true).required(),
4251
- hash: import_joi.default.string().optional(),
4252
- version: import_joi.default.string().optional(),
4253
- schema: import_joi.default.object({
4254
- name: import_joi.default.string().required(),
4255
- settings: import_joi.default.array().items(import_joi.default.object().unknown(true)).required()
4256
- }).unknown(true)
4257
- });
4258
- runJoi(validator, schema);
4259
- }
4260
- function validateDatasource(schema) {
4261
- const fieldValidator = import_joi.default.object({
4262
- type: import_joi.default.string().allow(...Object.values(DatasourceFieldType)).required(),
4263
- required: import_joi.default.boolean().required(),
4264
- default: import_joi.default.any(),
4265
- display: import_joi.default.string()
4266
- });
4267
- const queryValidator = import_joi.default.object({
4268
- type: import_joi.default.string().allow(...Object.values(QueryType)),
4269
- readable: import_joi.default.boolean(),
4270
- fields: import_joi.default.object().pattern(import_joi.default.string(), fieldValidator)
4271
- }).required();
4272
- const validator = import_joi.default.object({
4273
- type: import_joi.default.string().allow("datasource" /* DATASOURCE */).required(),
4274
- metadata: import_joi.default.object().unknown(true).required(),
4275
- hash: import_joi.default.string().optional(),
4276
- version: import_joi.default.string().optional(),
4277
- schema: import_joi.default.object({
4278
- docs: import_joi.default.string(),
4279
- plus: import_joi.default.boolean().optional(),
4280
- isSQL: import_joi.default.boolean().optional(),
4281
- auth: import_joi.default.object({
4282
- type: import_joi.default.string().required()
4283
- }).optional(),
4284
- features: import_joi.default.object(
4285
- Object.fromEntries(
4286
- Object.values(DatasourceFeature).map((key) => [
4287
- key,
4288
- import_joi.default.boolean().optional()
4289
- ])
4290
- )
4291
- ).optional(),
4292
- relationships: import_joi.default.boolean().optional(),
4293
- description: import_joi.default.string().required(),
4294
- friendlyName: import_joi.default.string().required(),
4295
- type: import_joi.default.string().allow(...DATASOURCE_TYPES),
4296
- datasource: import_joi.default.object().pattern(import_joi.default.string(), fieldValidator).required(),
4297
- query: import_joi.default.object().pattern(import_joi.default.string(), queryValidator).unknown(true).required(),
4298
- extra: import_joi.default.object().pattern(
4299
- import_joi.default.string(),
4300
- import_joi.default.object({
4301
- type: import_joi.default.string().required(),
4302
- displayName: import_joi.default.string().required(),
4303
- required: import_joi.default.boolean(),
4304
- data: import_joi.default.object()
4305
- })
4306
- )
4307
- })
4308
- });
4309
- runJoi(validator, schema);
4310
- }
4311
- function validateAutomation(schema) {
4312
- const basePropsValidator = import_joi.default.object().pattern(import_joi.default.string(), {
4313
- type: import_joi.default.string().allow(...Object.values(AutomationIOType)).required(),
4314
- customType: import_joi.default.string().allow(...Object.values(AutomationCustomIOType)),
4315
- title: import_joi.default.string(),
4316
- description: import_joi.default.string(),
4317
- enum: import_joi.default.array().items(import_joi.default.string()),
4318
- pretty: import_joi.default.array().items(import_joi.default.string())
4319
- });
4320
- const stepSchemaValidator = import_joi.default.object({
4321
- properties: basePropsValidator,
4322
- required: import_joi.default.array().items(import_joi.default.string())
4323
- }).concat(basePropsValidator).required();
4324
- const validator = import_joi.default.object({
4325
- type: import_joi.default.string().allow("automation" /* AUTOMATION */).required(),
4326
- metadata: import_joi.default.object().unknown(true).required(),
4327
- hash: import_joi.default.string().optional(),
4328
- version: import_joi.default.string().optional(),
4329
- schema: import_joi.default.object({
4330
- name: import_joi.default.string().required(),
4331
- tagline: import_joi.default.string().required(),
4332
- icon: import_joi.default.string().required(),
4333
- description: import_joi.default.string().required(),
4334
- type: import_joi.default.string().allow("ACTION" /* ACTION */, "LOGIC" /* LOGIC */).required(),
4335
- stepId: import_joi.default.string().disallow(...AutomationStepIdArray).required(),
4336
- inputs: import_joi.default.object().optional(),
4337
- schema: import_joi.default.object({
4338
- inputs: stepSchemaValidator,
4339
- outputs: stepSchemaValidator
4340
- }).required()
4341
- })
4342
- });
4343
- runJoi(validator, schema);
4344
- }
4345
- function validate(schema) {
4346
- switch (schema?.type) {
4347
- case "component" /* COMPONENT */:
4348
- validateComponent(schema);
4349
- break;
4350
- case "datasource" /* DATASOURCE */:
4351
- validateDatasource(schema);
4352
- break;
4353
- case "automation" /* AUTOMATION */:
4354
- validateAutomation(schema);
4355
- break;
4356
- default:
4357
- throw new Error(`Unknown plugin type - check schema.json: ${schema.type}`);
4358
- }
4359
- }
4360
- // Annotate the CommonJS export names for ESM import in node:
4361
- 0 && (module.exports = {
4362
- validate
4363
- });
1
+ "use strict";var mt=Object.create;var ye=Object.defineProperty;var ft=Object.getOwnPropertyDescriptor;var gt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,_t=Object.prototype.hasOwnProperty;var ht=(r,e)=>{for(var t in e)ye(r,t,{get:e[t],enumerable:!0})},Ye=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of gt(e))!_t.call(r,a)&&a!==t&&ye(r,a,{get:()=>e[a],enumerable:!(n=ft(e,a))||n.enumerable});return r};var yt=(r,e,t)=>(t=r!=null?mt(Et(r)):{},Ye(e||!r||!r.__esModule?ye(t,"default",{value:r,enumerable:!0}):t,r)),Tt=r=>Ye(ye({},"__esModule",{value:!0}),r);var Dr={};ht(Dr,{validate:()=>br});module.exports=Tt(Dr);var At=["user:created","user:updated","user:deleted","user:admin:assigned","user:admin:removed","user:builder:assigned","user:builder:removed","user_group:created","user_group:updated","user_group:deleted","user_group:user_added","user_group:users_deleted","user_group:permissions_edited"],Pr=[...At];var Ce=(n=>(n.SQL="sql",n.JSON="json",n.FIELDS="fields",n))(Ce||{}),Ue=(I=>(I.STRING="string",I.CODE="code",I.LONGFORM="longForm",I.BOOLEAN="boolean",I.NUMBER="number",I.PASSWORD="password",I.LIST="list",I.OBJECT="object",I.JSON="json",I.FILE="file",I.FIELD_GROUP="fieldGroup",I.SELECT="select",I))(Ue||{});var Pe=(n=>(n.CONNECTION_CHECKING="connection",n.FETCH_TABLE_NAMES="fetch_table_names",n.EXPORT_SCHEMA="export_schema",n))(Pe||{});var Le=(t=>(t.RETURN_ALL="all",t.RETURN_NONE="none",t))(Le||{});var Ln={OptOut:"analytics:opt:out",OptIn:"analytics:opt:in",SelfHostInit:"hosting:init",PluginInit:"plugin:init"};var we=(u=>(u.OBJECT="object",u.STRING="string",u.BOOLEAN="boolean",u.NUMBER="number",u.ARRAY="array",u.JSON="json",u.DATE="date",u.ATTACHMENT="attachment",u))(we||{}),Me=(O=>(O.TABLE="table",O.ROW="row",O.ROWS="rows",O.WIDE="wide",O.QUERY="query",O.QUERY_PARAMS="queryParams",O.QUERY_LIMIT="queryLimit",O.LOOP_OPTION="loopOption",O.ITEM="item",O.CODE="code",O.FILTERS="filters",O.COLUMN="column",O.TRIGGER_SCHEMA="triggerSchema",O.CRON="cron",O.WEBHOOK_URL="webhookUrl",O.AUTOMATION="automation",O.AUTOMATION_FIELDS="automationFields",O.MULTI_ATTACHMENTS="multi_attachments",O.TRIGGER_FILTER="trigger_filter",O))(Me||{}),Ze=(s=>(s.ROW_SAVED="ROW_SAVED",s.ROW_UPDATED="ROW_UPDATED",s.ROW_DELETED="ROW_DELETED",s.WEBHOOK="WEBHOOK",s.APP="APP",s.CRON="CRON",s.ROW_ACTION="ROW_ACTION",s))(Ze||{});var He=(R=>(R.SEND_EMAIL_SMTP="SEND_EMAIL_SMTP",R.CREATE_ROW="CREATE_ROW",R.UPDATE_ROW="UPDATE_ROW",R.DELETE_ROW="DELETE_ROW",R.EXECUTE_BASH="EXECUTE_BASH",R.OUTGOING_WEBHOOK="OUTGOING_WEBHOOK",R.EXECUTE_SCRIPT="EXECUTE_SCRIPT",R.EXECUTE_QUERY="EXECUTE_QUERY",R.SERVER_LOG="SERVER_LOG",R.DELAY="DELAY",R.FILTER="FILTER",R.QUERY_ROWS="QUERY_ROWS",R.LOOP="LOOP",R.COLLECT="COLLECT",R.OPENAI="OPENAI",R.TRIGGER_AUTOMATION_RUN="TRIGGER_AUTOMATION_RUN",R.BRANCH="BRANCH",R.discord="discord",R.slack="slack",R.zapier="zapier",R.integromat="integromat",R.n8n="n8n",R))(He||{}),Ke=[...Object.values(He),...Object.values(Ze)];var $e=(A=>(A.USER="us",A.GROUP="gr",A.WORKSPACE="workspace",A.CONFIG="config",A.TEMPLATE="template",A.APP="app",A.DEV="dev",A.APP_DEV="app_dev",A.APP_METADATA="app_metadata",A.ROLE="role",A.MIGRATIONS="migrations",A.DEV_INFO="devinfo",A.AUTOMATION_LOG="log_au",A.ACCOUNT_METADATA="acc_metadata",A.PLUGIN="plg",A.DATASOURCE="datasource",A.DATASOURCE_PLUS="datasource_plus",A.APP_BACKUP="backup",A.TABLE="ta",A.ROW="ro",A.AUTOMATION="au",A.LINK="li",A.WEBHOOK="wh",A.INSTANCE="inst",A.LAYOUT="layout",A.SCREEN="screen",A.QUERY="query",A.DEPLOYMENTS="deployments",A.METADATA="metadata",A.MEM_VIEW="view",A.USER_FLAG="flag",A.AUTOMATION_METADATA="meta_au",A.AUDIT_LOG="al",A.APP_MIGRATION_METADATA="_design/migrations",A.SCIM_LOG="scimlog",A.ROW_ACTIONS="ra",A))($e||{}),$a=Object.values($e).sort((r,e)=>e.length-r.length);var ze=(t=>(t.VIEW="view",t.ROW_ACTION="row_action",t))(ze||{}),za=Object.values(ze).sort((r,e)=>e.length-r.length);var ke=(n=>(n.DATASOURCE="datasource",n.COMPONENT="component",n.AUTOMATION="automation",n))(ke||{});var Ni=Object.values(ke);var wi=["rows","queries","automations"],Mi=["queries","automations"];var Be=(t=>(t.ASCENDING="ascending",t.DESCENDING="descending",t))(Be||{}),Fe=(t=>(t.STRING="string",t.NUMBER="number",t))(Fe||{});var x;(function(r){r.assertEqual=a=>a;function e(a){}r.assertIs=e;function t(a){throw new Error}r.assertNever=t,r.arrayToEnum=a=>{let i={};for(let o of a)i[o]=o;return i},r.getValidEnumValues=a=>{let i=r.objectKeys(a).filter(s=>typeof a[a[s]]!="number"),o={};for(let s of i)o[s]=a[s];return r.objectValues(o)},r.objectValues=a=>r.objectKeys(a).map(function(i){return a[i]}),r.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let i=[];for(let o in a)Object.prototype.hasOwnProperty.call(a,o)&&i.push(o);return i},r.find=(a,i)=>{for(let o of a)if(i(o))return o},r.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&isFinite(a)&&Math.floor(a)===a;function n(a,i=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(x||(x={}));var Ve;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ve||(Ve={}));var m=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),G=r=>{switch(typeof r){case"undefined":return m.undefined;case"string":return m.string;case"number":return isNaN(r)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(r)?m.array:r===null?m.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?m.promise:typeof Map<"u"&&r instanceof Map?m.map:typeof Set<"u"&&r instanceof Set?m.set:typeof Date<"u"&&r instanceof Date?m.date:m.object;default:return m.unknown}},d=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),xt=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),D=class r extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let t=e||function(i){return i.message},n={_errors:[]},a=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(a);else if(o.code==="invalid_return_type")a(o.returnTypeError);else if(o.code==="invalid_arguments")a(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let s=n,u=0;for(;u<o.path.length;){let l=o.path[u];u===o.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(t(o))):s[l]=s[l]||{_errors:[]},s=s[l],u++}}};return a(this),n}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):n.push(e(a));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};D.create=r=>new D(r);var oe=(r,e)=>{let t;switch(r.code){case d.invalid_type:r.received===m.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,x.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(r.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(r.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:x.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case d.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case d.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(r)}return{message:t}},et=oe;function Rt(r){et=r}function Te(){return et}var Ae=r=>{let{data:e,path:t,errorMaps:n,issueData:a}=r,i=[...t,...a.path||[]],o={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let s="",u=n.filter(l=>!!l).slice().reverse();for(let l of u)s=l(o,{data:e,defaultError:s}).message;return{...a,path:i,message:s}},Ot=[];function p(r,e){let t=Te(),n=Ae({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===oe?void 0:oe].filter(a=>!!a)});r.common.issues.push(n)}var S=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let a of t){if(a.status==="aborted")return E;a.status==="dirty"&&e.dirty(),n.push(a.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let a of t){let i=await a.key,o=await a.value;n.push({key:i,value:o})}return r.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let a of t){let{key:i,value:o}=a;if(i.status==="aborted"||o.status==="aborted")return E;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}},E=Object.freeze({status:"aborted"}),se=r=>({status:"dirty",value:r}),v=r=>({status:"valid",value:r}),je=r=>r.status==="aborted",Qe=r=>r.status==="dirty",ge=r=>r.status==="valid",Ee=r=>typeof Promise<"u"&&r instanceof Promise;function xe(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function tt(r,e,t,n,a){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!a:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?a.call(r,t):a?a.value=t:e.set(r,t),t}var f;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(f||(f={}));var me,fe,P=class{constructor(e,t,n,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=a}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Xe=(r,e)=>{if(ge(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new D(r.common.issues);return this._error=t,this._error}}};function h(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:a}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(o,s)=>{var u,l;let{message:_}=r;return o.code==="invalid_enum_value"?{message:_??s.defaultError}:typeof s.data>"u"?{message:(u=_??n)!==null&&u!==void 0?u:s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:(l=_??t)!==null&&l!==void 0?l:s.defaultError}},description:a}}var y=class{constructor(e){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)}get description(){return this._def.description}_getType(e){return G(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:G(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new S,ctx:{common:e.parent.common,data:e.data,parsedType:G(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Ee(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;let a={common:{issues:[],async:(n=t?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:G(e)},i=this._parseSync({data:e,path:a.path,parent:a});return Xe(a,i)}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:G(e)},a=this._parse({data:e,path:n.path,parent:n}),i=await(Ee(a)?a:Promise.resolve(a));return Xe(n,i)}refine(e,t){let n=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,i)=>{let o=e(a),s=()=>i.addIssue({code:d.custom,...n(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(e,t){return this._refinement((n,a)=>e(n)?!0:(a.addIssue(typeof t=="function"?t(n,a):t),!1))}_refinement(e){return new N({schema:this,typeName:g.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return U.create(this,this._def)}nullable(){return M.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return F.create(this,this._def)}promise(){return Q.create(this,this._def)}or(e){return $.create([this,e],this._def)}and(e){return z.create(this,e,this._def)}transform(e){return new N({...h(this._def),schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new re({...h(this._def),innerType:this,defaultValue:t,typeName:g.ZodDefault})}brand(){return new _e({typeName:g.ZodBranded,type:this,...h(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new ne({...h(this._def),innerType:this,catchValue:t,typeName:g.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return he.create(this,e)}readonly(){return ae.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},St=/^c[^\s-]{8,}$/i,It=/^[0-9a-z]+$/,vt=/^[0-9A-HJKMNP-TV-Z]{26}$/,bt=/^[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,Dt=/^[a-z0-9_-]{21}$/i,Nt=/^[-+]?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)?)??$/,Ct=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ut="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ge,Pt=/^(?:(?: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])$/,Lt=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,wt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,rt="((\\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])))",Mt=new RegExp(`^${rt}$`);function nt(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function kt(r){return new RegExp(`^${nt(r)}$`)}function at(r){let e=`${rt}T${nt(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Bt(r,e){return!!((e==="v4"||!e)&&Pt.test(r)||(e==="v6"||!e)&&Lt.test(r))}var V=class r extends y{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){let i=this._getOrReturnCtx(e);return p(i,{code:d.invalid_type,expected:m.string,received:i.parsedType}),E}let n=new S,a;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(a=this._getOrReturnCtx(e,a),p(a,{code:d.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(a=this._getOrReturnCtx(e,a),p(a,{code:d.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,s=e.data.length<i.value;(o||s)&&(a=this._getOrReturnCtx(e,a),o?p(a,{code:d.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&p(a,{code:d.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Ct.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"email",code:d.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Ge||(Ge=new RegExp(Ut,"u")),Ge.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"emoji",code:d.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")bt.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"uuid",code:d.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Dt.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"nanoid",code:d.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")St.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"cuid",code:d.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")It.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"cuid2",code:d.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")vt.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"ulid",code:d.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),p(a,{validation:"url",code:d.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"regex",code:d.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(e,a),p(a,{code:d.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(a=this._getOrReturnCtx(e,a),p(a,{code:d.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(a=this._getOrReturnCtx(e,a),p(a,{code:d.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?at(i).test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{code:d.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?Mt.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{code:d.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?kt(i).test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{code:d.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Nt.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"duration",code:d.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?Bt(e.data,i.version)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"ip",code:d.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?wt.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"base64",code:d.invalid_string,message:i.message}),n.dirty()):x.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(a=>e.test(a),{validation:t,code:d.invalid_string,...f.errToObj(n)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...f.errToObj(e)})}url(e){return this._addCheck({kind:"url",...f.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...f.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...f.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...f.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...f.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...f.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...f.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...f.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...f.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,local:(n=e?.local)!==null&&n!==void 0?n:!1,...f.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...f.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...f.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...f.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...f.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...f.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...f.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...f.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...f.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...f.errToObj(t)})}nonempty(e){return this.min(1,f.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};V.create=r=>{var e;return new V({checks:[],typeName:g.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...h(r)})};function Ft(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,a=t>n?t:n,i=parseInt(r.toFixed(a).replace(".","")),o=parseInt(e.toFixed(a).replace(".",""));return i%o/Math.pow(10,a)}var q=class r extends y{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==m.number){let i=this._getOrReturnCtx(e);return p(i,{code:d.invalid_type,expected:m.number,received:i.parsedType}),E}let n,a=new S;for(let i of this._def.checks)i.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:d.invalid_type,expected:"integer",received:"float",message:i.message}),a.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?Ft(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:d.not_finite,message:i.message}),a.dirty()):x.assertNever(i);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,f.toString(t))}gt(e,t){return this.setLimit("min",e,!1,f.toString(t))}lte(e,t){return this.setLimit("max",e,!0,f.toString(t))}lt(e,t){return this.setLimit("max",e,!1,f.toString(t))}setLimit(e,t,n,a){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:f.toString(a)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:f.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:f.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:f.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:f.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:f.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:f.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:f.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:f.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:f.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};q.create=r=>new q({checks:[],typeName:g.ZodNumber,coerce:r?.coerce||!1,...h(r)});var W=class r extends y{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==m.bigint){let i=this._getOrReturnCtx(e);return p(i,{code:d.invalid_type,expected:m.bigint,received:i.parsedType}),E}let n,a=new S;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):x.assertNever(i);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,f.toString(t))}gt(e,t){return this.setLimit("min",e,!1,f.toString(t))}lte(e,t){return this.setLimit("max",e,!0,f.toString(t))}lt(e,t){return this.setLimit("max",e,!1,f.toString(t))}setLimit(e,t,n,a){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:f.toString(a)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:f.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:f.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:f.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:f.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:f.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};W.create=r=>{var e;return new W({checks:[],typeName:g.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...h(r)})};var Y=class extends y{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==m.boolean){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:m.boolean,received:n.parsedType}),E}return v(e.data)}};Y.create=r=>new Y({typeName:g.ZodBoolean,coerce:r?.coerce||!1,...h(r)});var Z=class r extends y{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==m.date){let i=this._getOrReturnCtx(e);return p(i,{code:d.invalid_type,expected:m.date,received:i.parsedType}),E}if(isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return p(i,{code:d.invalid_date}),E}let n=new S,a;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(a=this._getOrReturnCtx(e,a),p(a,{code:d.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(a=this._getOrReturnCtx(e,a),p(a,{code:d.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):x.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:f.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:f.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};Z.create=r=>new Z({checks:[],coerce:r?.coerce||!1,typeName:g.ZodDate,...h(r)});var de=class extends y{_parse(e){if(this._getType(e)!==m.symbol){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:m.symbol,received:n.parsedType}),E}return v(e.data)}};de.create=r=>new de({typeName:g.ZodSymbol,...h(r)});var H=class extends y{_parse(e){if(this._getType(e)!==m.undefined){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:m.undefined,received:n.parsedType}),E}return v(e.data)}};H.create=r=>new H({typeName:g.ZodUndefined,...h(r)});var K=class extends y{_parse(e){if(this._getType(e)!==m.null){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:m.null,received:n.parsedType}),E}return v(e.data)}};K.create=r=>new K({typeName:g.ZodNull,...h(r)});var j=class extends y{constructor(){super(...arguments),this._any=!0}_parse(e){return v(e.data)}};j.create=r=>new j({typeName:g.ZodAny,...h(r)});var B=class extends y{constructor(){super(...arguments),this._unknown=!0}_parse(e){return v(e.data)}};B.create=r=>new B({typeName:g.ZodUnknown,...h(r)});var L=class extends y{_parse(e){let t=this._getOrReturnCtx(e);return p(t,{code:d.invalid_type,expected:m.never,received:t.parsedType}),E}};L.create=r=>new L({typeName:g.ZodNever,...h(r)});var ue=class extends y{_parse(e){if(this._getType(e)!==m.undefined){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:m.void,received:n.parsedType}),E}return v(e.data)}};ue.create=r=>new ue({typeName:g.ZodVoid,...h(r)});var F=class r extends y{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),a=this._def;if(t.parsedType!==m.array)return p(t,{code:d.invalid_type,expected:m.array,received:t.parsedType}),E;if(a.exactLength!==null){let o=t.data.length>a.exactLength.value,s=t.data.length<a.exactLength.value;(o||s)&&(p(t,{code:o?d.too_big:d.too_small,minimum:s?a.exactLength.value:void 0,maximum:o?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(p(t,{code:d.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(p(t,{code:d.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,s)=>a.type._parseAsync(new P(t,o,t.path,s)))).then(o=>S.mergeArray(n,o));let i=[...t.data].map((o,s)=>a.type._parseSync(new P(t,o,t.path,s)));return S.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:f.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:f.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:f.toString(t)}})}nonempty(e){return this.min(1,e)}};F.create=(r,e)=>new F({type:r,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray,...h(e)});function ie(r){if(r instanceof b){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=U.create(ie(n))}return new b({...r._def,shape:()=>e})}else return r instanceof F?new F({...r._def,type:ie(r.element)}):r instanceof U?U.create(ie(r.unwrap())):r instanceof M?M.create(ie(r.unwrap())):r instanceof w?w.create(r.items.map(e=>ie(e))):r}var b=class r extends y{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==m.object){let l=this._getOrReturnCtx(e);return p(l,{code:d.invalid_type,expected:m.object,received:l.parsedType}),E}let{status:n,ctx:a}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof L&&this._def.unknownKeys==="strip"))for(let l in a.data)o.includes(l)||s.push(l);let u=[];for(let l of o){let _=i[l],C=a.data[l];u.push({key:{status:"valid",value:l},value:_._parse(new P(a,C,a.path,l)),alwaysSet:l in a.data})}if(this._def.catchall instanceof L){let l=this._def.unknownKeys;if(l==="passthrough")for(let _ of s)u.push({key:{status:"valid",value:_},value:{status:"valid",value:a.data[_]}});else if(l==="strict")s.length>0&&(p(a,{code:d.unrecognized_keys,keys:s}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let _ of s){let C=a.data[_];u.push({key:{status:"valid",value:_},value:l._parse(new P(a,C,a.path,_)),alwaysSet:_ in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let l=[];for(let _ of u){let C=await _.key,I=await _.value;l.push({key:C,value:I,alwaysSet:_.alwaysSet})}return l}).then(l=>S.mergeObjectSync(n,l)):S.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return f.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var a,i,o,s;let u=(o=(i=(a=this._def).errorMap)===null||i===void 0?void 0:i.call(a,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(s=f.errToObj(e).message)!==null&&s!==void 0?s:u}:{message:u}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:g.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};return x.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}omit(e){let t={};return x.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}deepPartial(){return ie(this)}partial(e){let t={};return x.objectKeys(this.shape).forEach(n=>{let a=this.shape[n];e&&!e[n]?t[n]=a:t[n]=a.optional()}),new r({...this._def,shape:()=>t})}required(e){let t={};return x.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof U;)i=i._def.innerType;t[n]=i}}),new r({...this._def,shape:()=>t})}keyof(){return it(x.objectKeys(this.shape))}};b.create=(r,e)=>new b({shape:()=>r,unknownKeys:"strip",catchall:L.create(),typeName:g.ZodObject,...h(e)});b.strictCreate=(r,e)=>new b({shape:()=>r,unknownKeys:"strict",catchall:L.create(),typeName:g.ZodObject,...h(e)});b.lazycreate=(r,e)=>new b({shape:r,unknownKeys:"strip",catchall:L.create(),typeName:g.ZodObject,...h(e)});var $=class extends y{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function a(i){for(let s of i)if(s.result.status==="valid")return s.result;for(let s of i)if(s.result.status==="dirty")return t.common.issues.push(...s.ctx.common.issues),s.result;let o=i.map(s=>new D(s.ctx.common.issues));return p(t,{code:d.invalid_union,unionErrors:o}),E}if(t.common.async)return Promise.all(n.map(async i=>{let o={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(a);{let i,o=[];for(let u of n){let l={...t,common:{...t.common,issues:[]},parent:null},_=u._parseSync({data:t.data,path:t.path,parent:l});if(_.status==="valid")return _;_.status==="dirty"&&!i&&(i={result:_,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;let s=o.map(u=>new D(u));return p(t,{code:d.invalid_union,unionErrors:s}),E}}get options(){return this._def.options}};$.create=(r,e)=>new $({options:r,typeName:g.ZodUnion,...h(e)});var k=r=>r instanceof X?k(r.schema):r instanceof N?k(r.innerType()):r instanceof J?[r.value]:r instanceof ee?r.options:r instanceof te?x.objectValues(r.enum):r instanceof re?k(r._def.innerType):r instanceof H?[void 0]:r instanceof K?[null]:r instanceof U?[void 0,...k(r.unwrap())]:r instanceof M?[null,...k(r.unwrap())]:r instanceof _e||r instanceof ae?k(r.unwrap()):r instanceof ne?k(r._def.innerType):[],Re=class r extends y{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.object)return p(t,{code:d.invalid_type,expected:m.object,received:t.parsedType}),E;let n=this.discriminator,a=t.data[n],i=this.optionsMap.get(a);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(p(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),E)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let a=new Map;for(let i of t){let o=k(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of o){if(a.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);a.set(s,i)}}return new r({typeName:g.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...h(n)})}};function qe(r,e){let t=G(r),n=G(e);if(r===e)return{valid:!0,data:r};if(t===m.object&&n===m.object){let a=x.objectKeys(e),i=x.objectKeys(r).filter(s=>a.indexOf(s)!==-1),o={...r,...e};for(let s of i){let u=qe(r[s],e[s]);if(!u.valid)return{valid:!1};o[s]=u.data}return{valid:!0,data:o}}else if(t===m.array&&n===m.array){if(r.length!==e.length)return{valid:!1};let a=[];for(let i=0;i<r.length;i++){let o=r[i],s=e[i],u=qe(o,s);if(!u.valid)return{valid:!1};a.push(u.data)}return{valid:!0,data:a}}else return t===m.date&&n===m.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var z=class extends y{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),a=(i,o)=>{if(je(i)||je(o))return E;let s=qe(i.value,o.value);return s.valid?((Qe(i)||Qe(o))&&t.dirty(),{status:t.value,value:s.data}):(p(n,{code:d.invalid_intersection_types}),E)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>a(i,o)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};z.create=(r,e,t)=>new z({left:r,right:e,typeName:g.ZodIntersection,...h(t)});var w=class r extends y{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.array)return p(n,{code:d.invalid_type,expected:m.array,received:n.parsedType}),E;if(n.data.length<this._def.items.length)return p(n,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),E;!this._def.rest&&n.data.length>this._def.items.length&&(p(n,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let i=[...n.data].map((o,s)=>{let u=this._def.items[s]||this._def.rest;return u?u._parse(new P(n,o,n.path,s)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>S.mergeArray(t,o)):S.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};w.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new w({items:r,typeName:g.ZodTuple,rest:null,...h(e)})};var Oe=class r extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.object)return p(n,{code:d.invalid_type,expected:m.object,received:n.parsedType}),E;let a=[],i=this._def.keyType,o=this._def.valueType;for(let s in n.data)a.push({key:i._parse(new P(n,s,n.path,s)),value:o._parse(new P(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?S.mergeObjectAsync(t,a):S.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof y?new r({keyType:e,valueType:t,typeName:g.ZodRecord,...h(n)}):new r({keyType:V.create(),valueType:e,typeName:g.ZodRecord,...h(t)})}},ce=class extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.map)return p(n,{code:d.invalid_type,expected:m.map,received:n.parsedType}),E;let a=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([s,u],l)=>({key:a._parse(new P(n,s,n.path,[l,"key"])),value:i._parse(new P(n,u,n.path,[l,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let u of o){let l=await u.key,_=await u.value;if(l.status==="aborted"||_.status==="aborted")return E;(l.status==="dirty"||_.status==="dirty")&&t.dirty(),s.set(l.value,_.value)}return{status:t.value,value:s}})}else{let s=new Map;for(let u of o){let l=u.key,_=u.value;if(l.status==="aborted"||_.status==="aborted")return E;(l.status==="dirty"||_.status==="dirty")&&t.dirty(),s.set(l.value,_.value)}return{status:t.value,value:s}}}};ce.create=(r,e,t)=>new ce({valueType:e,keyType:r,typeName:g.ZodMap,...h(t)});var le=class r extends y{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.set)return p(n,{code:d.invalid_type,expected:m.set,received:n.parsedType}),E;let a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(p(n,{code:d.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(p(n,{code:d.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());let i=this._def.valueType;function o(u){let l=new Set;for(let _ of u){if(_.status==="aborted")return E;_.status==="dirty"&&t.dirty(),l.add(_.value)}return{status:t.value,value:l}}let s=[...n.data.values()].map((u,l)=>i._parse(new P(n,u,n.path,l)));return n.common.async?Promise.all(s).then(u=>o(u)):o(s)}min(e,t){return new r({...this._def,minSize:{value:e,message:f.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:f.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};le.create=(r,e)=>new le({valueType:r,minSize:null,maxSize:null,typeName:g.ZodSet,...h(e)});var Se=class r extends y{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.function)return p(t,{code:d.invalid_type,expected:m.function,received:t.parsedType}),E;function n(s,u){return Ae({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Te(),oe].filter(l=>!!l),issueData:{code:d.invalid_arguments,argumentsError:u}})}function a(s,u){return Ae({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Te(),oe].filter(l=>!!l),issueData:{code:d.invalid_return_type,returnTypeError:u}})}let i={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Q){let s=this;return v(async function(...u){let l=new D([]),_=await s._def.args.parseAsync(u,i).catch(Ne=>{throw l.addIssue(n(u,Ne)),l}),C=await Reflect.apply(o,this,_);return await s._def.returns._def.type.parseAsync(C,i).catch(Ne=>{throw l.addIssue(a(C,Ne)),l})})}else{let s=this;return v(function(...u){let l=s._def.args.safeParse(u,i);if(!l.success)throw new D([n(u,l.error)]);let _=Reflect.apply(o,this,l.data),C=s._def.returns.safeParse(_,i);if(!C.success)throw new D([a(_,C.error)]);return C.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:w.create(e).rest(B.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new r({args:e||w.create([]).rest(B.create()),returns:t||B.create(),typeName:g.ZodFunction,...h(n)})}},X=class extends y{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};X.create=(r,e)=>new X({getter:r,typeName:g.ZodLazy,...h(e)});var J=class extends y{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),E}return{status:"valid",value:e.data}}get value(){return this._def.value}};J.create=(r,e)=>new J({value:r,typeName:g.ZodLiteral,...h(e)});function it(r,e){return new ee({values:r,typeName:g.ZodEnum,...h(e)})}var ee=class r extends y{constructor(){super(...arguments),me.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{expected:x.joinValues(n),received:t.parsedType,code:d.invalid_type}),E}if(xe(this,me,"f")||tt(this,me,new Set(this._def.values),"f"),!xe(this,me,"f").has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{received:t.data,code:d.invalid_enum_value,options:n}),E}return v(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};me=new WeakMap;ee.create=it;var te=class extends y{constructor(){super(...arguments),fe.set(this,void 0)}_parse(e){let t=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==m.string&&n.parsedType!==m.number){let a=x.objectValues(t);return p(n,{expected:x.joinValues(a),received:n.parsedType,code:d.invalid_type}),E}if(xe(this,fe,"f")||tt(this,fe,new Set(x.getValidEnumValues(this._def.values)),"f"),!xe(this,fe,"f").has(e.data)){let a=x.objectValues(t);return p(n,{received:n.data,code:d.invalid_enum_value,options:a}),E}return v(e.data)}get enum(){return this._def.values}};fe=new WeakMap;te.create=(r,e)=>new te({values:r,typeName:g.ZodNativeEnum,...h(e)});var Q=class extends y{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.promise&&t.common.async===!1)return p(t,{code:d.invalid_type,expected:m.promise,received:t.parsedType}),E;let n=t.parsedType===m.promise?t.data:Promise.resolve(t.data);return v(n.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Q.create=(r,e)=>new Q({type:r,typeName:g.ZodPromise,...h(e)});var N=class extends y{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),a=this._def.effect||null,i={addIssue:o=>{p(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){let o=a.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async s=>{if(t.value==="aborted")return E;let u=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return u.status==="aborted"?E:u.status==="dirty"||t.value==="dirty"?se(u.value):u});{if(t.value==="aborted")return E;let s=this._def.schema._parseSync({data:o,path:n.path,parent:n});return s.status==="aborted"?E:s.status==="dirty"||t.value==="dirty"?se(s.value):s}}if(a.type==="refinement"){let o=s=>{let u=a.refinement(s,i);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?E:(s.status==="dirty"&&t.dirty(),o(s.value),{status:t.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?E:(s.status==="dirty"&&t.dirty(),o(s.value).then(()=>({status:t.value,value:s.value}))))}if(a.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ge(o))return o;let s=a.transform(o.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>ge(o)?Promise.resolve(a.transform(o.value,i)).then(s=>({status:t.value,value:s})):o);x.assertNever(a)}};N.create=(r,e,t)=>new N({schema:r,typeName:g.ZodEffects,effect:e,...h(t)});N.createWithPreprocess=(r,e,t)=>new N({schema:e,effect:{type:"preprocess",transform:r},typeName:g.ZodEffects,...h(t)});var U=class extends y{_parse(e){return this._getType(e)===m.undefined?v(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};U.create=(r,e)=>new U({innerType:r,typeName:g.ZodOptional,...h(e)});var M=class extends y{_parse(e){return this._getType(e)===m.null?v(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};M.create=(r,e)=>new M({innerType:r,typeName:g.ZodNullable,...h(e)});var re=class extends y{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===m.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};re.create=(r,e)=>new re({innerType:r,typeName:g.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...h(e)});var ne=class extends y{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ee(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new D(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new D(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ne.create=(r,e)=>new ne({innerType:r,typeName:g.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...h(e)});var pe=class extends y{_parse(e){if(this._getType(e)!==m.nan){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:m.nan,received:n.parsedType}),E}return{status:"valid",value:e.data}}};pe.create=r=>new pe({typeName:g.ZodNaN,...h(r)});var Gt=Symbol("zod_brand"),_e=class extends y{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},he=class r extends y{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?E:i.status==="dirty"?(t.dirty(),se(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?E:a.status==="dirty"?(t.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(e,t){return new r({in:e,out:t,typeName:g.ZodPipeline})}},ae=class extends y{_parse(e){let t=this._def.innerType._parse(e),n=a=>(ge(a)&&(a.value=Object.freeze(a.value)),a);return Ee(t)?t.then(a=>n(a)):n(t)}unwrap(){return this._def.innerType}};ae.create=(r,e)=>new ae({innerType:r,typeName:g.ZodReadonly,...h(e)});function st(r,e={},t){return r?j.create().superRefine((n,a)=>{var i,o;if(!r(n)){let s=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(i=s.fatal)!==null&&i!==void 0?i:t)!==null&&o!==void 0?o:!0,l=typeof s=="string"?{message:s}:s;a.addIssue({code:"custom",...l,fatal:u})}}):j.create()}var Vt={object:b.lazycreate},g;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(g||(g={}));var jt=(r,e={message:`Input not instance of ${r.name}`})=>st(t=>t instanceof r,e),ot=V.create,dt=q.create,Qt=pe.create,qt=W.create,ut=Y.create,Wt=Z.create,Yt=de.create,Zt=H.create,Ht=K.create,Kt=j.create,$t=B.create,zt=L.create,Xt=ue.create,Jt=F.create,er=b.create,tr=b.strictCreate,rr=$.create,nr=Re.create,ar=z.create,ir=w.create,sr=Oe.create,or=ce.create,dr=le.create,ur=Se.create,cr=X.create,lr=J.create,pr=ee.create,mr=te.create,fr=Q.create,Je=N.create,gr=U.create,Er=M.create,_r=N.createWithPreprocess,hr=he.create,yr=()=>ot().optional(),Tr=()=>dt().optional(),Ar=()=>ut().optional(),xr={string:r=>V.create({...r,coerce:!0}),number:r=>q.create({...r,coerce:!0}),boolean:r=>Y.create({...r,coerce:!0}),bigint:r=>W.create({...r,coerce:!0}),date:r=>Z.create({...r,coerce:!0})},Rr=E,T=Object.freeze({__proto__:null,defaultErrorMap:oe,setErrorMap:Rt,getErrorMap:Te,makeIssue:Ae,EMPTY_PATH:Ot,addIssueToContext:p,ParseStatus:S,INVALID:E,DIRTY:se,OK:v,isAborted:je,isDirty:Qe,isValid:ge,isAsync:Ee,get util(){return x},get objectUtil(){return Ve},ZodParsedType:m,getParsedType:G,ZodType:y,datetimeRegex:at,ZodString:V,ZodNumber:q,ZodBigInt:W,ZodBoolean:Y,ZodDate:Z,ZodSymbol:de,ZodUndefined:H,ZodNull:K,ZodAny:j,ZodUnknown:B,ZodNever:L,ZodVoid:ue,ZodArray:F,ZodObject:b,ZodUnion:$,ZodDiscriminatedUnion:Re,ZodIntersection:z,ZodTuple:w,ZodRecord:Oe,ZodMap:ce,ZodSet:le,ZodFunction:Se,ZodLazy:X,ZodLiteral:J,ZodEnum:ee,ZodNativeEnum:te,ZodPromise:Q,ZodEffects:N,ZodTransformer:N,ZodOptional:U,ZodNullable:M,ZodDefault:re,ZodCatch:ne,ZodNaN:pe,BRAND:Gt,ZodBranded:_e,ZodPipeline:he,ZodReadonly:ae,custom:st,Schema:y,ZodSchema:y,late:Vt,get ZodFirstPartyTypeKind(){return g},coerce:xr,any:Kt,array:Jt,bigint:qt,boolean:ut,date:Wt,discriminatedUnion:nr,effect:Je,enum:pr,function:ur,instanceof:jt,intersection:ar,lazy:cr,literal:lr,map:or,nan:Qt,nativeEnum:mr,never:zt,null:Ht,nullable:Er,number:dt,object:er,oboolean:Ar,onumber:Tr,optional:gr,ostring:yr,pipeline:hr,preprocess:_r,promise:fr,record:sr,set:dr,strictObject:tr,string:ot,symbol:Yt,transformer:Je,tuple:ir,undefined:Zt,union:rr,unknown:$t,void:Xt,NEVER:Rr,ZodIssueCode:d,quotelessJson:xt,ZodError:D});var De=T.string().refine(r=>r!=="_complexIdOperator",{message:"Key '_complexIdOperator' is not allowed"}),ct=T.record(De,T.string()),Ie=T.record(De,T.any()),ve=T.record(De,T.union([T.any().array(),T.string()])),lt=T.lazy(()=>T.object({conditions:T.array(T.object(pt))})),be=T.union([T.string(),T.number()]),pt={string:ct.optional(),fuzzy:ct.optional(),range:T.record(De,T.union([T.object({high:be,low:be}),T.object({high:be}),T.object({low:be})])).optional(),equal:Ie.optional(),notEqual:Ie.optional(),empty:Ie.optional(),notEmpty:Ie.optional(),oneOf:ve.optional(),contains:ve.optional(),notContains:ve.optional(),containsAny:ve.optional(),$and:lt.optional(),$or:lt.optional()},Ps=T.object({query:T.object({allOr:T.boolean().optional(),onEmptyFilter:T.nativeEnum(Le).optional(),...pt}).optional(),paginate:T.boolean().optional(),bookmark:T.union([T.string(),T.number()]).nullish(),limit:T.number().optional(),sort:T.string().nullish(),sortOrder:T.nativeEnum(Be).optional(),sortType:T.nativeEnum(Fe).nullish(),version:T.string().optional(),disableEscaping:T.boolean().optional(),countRows:T.boolean().optional()});var c=yt(require("joi")),Or=["Relational","Non-relational","Spreadsheet","Object store","Graph","API"];function We(r,e){let{error:t}=r.validate(e);if(t)throw t}function Sr(r){let e=c.default.object({type:c.default.string().allow("component").required(),metadata:c.default.object().unknown(!0).required(),hash:c.default.string().optional(),version:c.default.string().optional(),schema:c.default.object({name:c.default.string().required(),settings:c.default.array().items(c.default.object().unknown(!0)).required()}).unknown(!0)});We(e,r)}function Ir(r){let e=c.default.object({type:c.default.string().allow(...Object.values(Ue)).required(),required:c.default.boolean().required(),default:c.default.any(),display:c.default.string()}),t=c.default.object({type:c.default.string().allow(...Object.values(Ce)),readable:c.default.boolean(),fields:c.default.object().pattern(c.default.string(),e)}).required(),n=c.default.object({type:c.default.string().allow("datasource").required(),metadata:c.default.object().unknown(!0).required(),hash:c.default.string().optional(),version:c.default.string().optional(),schema:c.default.object({docs:c.default.string(),plus:c.default.boolean().optional(),isSQL:c.default.boolean().optional(),auth:c.default.object({type:c.default.string().required()}).optional(),features:c.default.object(Object.fromEntries(Object.values(Pe).map(a=>[a,c.default.boolean().optional()]))).optional(),relationships:c.default.boolean().optional(),description:c.default.string().required(),friendlyName:c.default.string().required(),type:c.default.string().allow(...Or),datasource:c.default.object().pattern(c.default.string(),e).required(),query:c.default.object().pattern(c.default.string(),t).unknown(!0).required(),extra:c.default.object().pattern(c.default.string(),c.default.object({type:c.default.string().required(),displayName:c.default.string().required(),required:c.default.boolean(),data:c.default.object()}))})});We(n,r)}function vr(r){let e=c.default.object().pattern(c.default.string(),{type:c.default.string().allow(...Object.values(we)).required(),customType:c.default.string().allow(...Object.values(Me)),title:c.default.string(),description:c.default.string(),enum:c.default.array().items(c.default.string()),pretty:c.default.array().items(c.default.string())}),t=c.default.object({properties:e,required:c.default.array().items(c.default.string())}).concat(e).required(),n=c.default.object({type:c.default.string().allow("automation").required(),metadata:c.default.object().unknown(!0).required(),hash:c.default.string().optional(),version:c.default.string().optional(),schema:c.default.object({name:c.default.string().required(),tagline:c.default.string().required(),icon:c.default.string().required(),description:c.default.string().required(),type:c.default.string().allow("ACTION","LOGIC").required(),stepId:c.default.string().disallow(...Ke).required(),inputs:c.default.object().optional(),schema:c.default.object({inputs:t,outputs:t}).required()})});We(n,r)}function br(r){switch(r?.type){case"component":Sr(r);break;case"datasource":Ir(r);break;case"automation":vr(r);break;default:throw new Error(`Unknown plugin type - check schema.json: ${r.type}`)}}0&&(module.exports={validate});
4364
2
  //# sourceMappingURL=plugins.js.map