@schemavaults/app-definitions 0.6.1

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