agent-relay 6.0.2 → 6.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/dist/index.cjs +2024 -962
- package/dist/src/cli/commands/cloud.d.ts.map +1 -1
- package/dist/src/cli/commands/cloud.js +17 -144
- package/dist/src/cli/commands/cloud.js.map +1 -1
- package/dist/src/cli/commands/setup.d.ts +2 -39
- package/dist/src/cli/commands/setup.d.ts.map +1 -1
- package/dist/src/cli/commands/setup.js +4 -333
- package/dist/src/cli/commands/setup.js.map +1 -1
- package/dist/src/cli/lib/auth-ssh.d.ts +2 -33
- package/dist/src/cli/lib/auth-ssh.d.ts.map +1 -1
- package/dist/src/cli/lib/auth-ssh.js +3 -39
- package/dist/src/cli/lib/auth-ssh.js.map +1 -1
- package/dist/src/cli/lib/ssh-interactive.d.ts +4 -66
- package/dist/src/cli/lib/ssh-interactive.d.ts.map +1 -1
- package/dist/src/cli/lib/ssh-interactive.js +4 -436
- package/dist/src/cli/lib/ssh-interactive.js.map +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/README.md +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/locales/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/mini/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/package.json +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v3/tests/all-errors.test.ts +3 -3
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v3/tests/object.test.ts +5 -5
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v3/tests/partials.test.ts +3 -3
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/errors.ts +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/external.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/from-json-schema.ts +39 -23
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/parse.ts +6 -6
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/schemas.ts +389 -148
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/catch.test.ts +4 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/codec.test.ts +142 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/continuability.test.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/datetime.test.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/default.test.ts +44 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +197 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +31 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +214 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +161 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/function.test.ts +6 -6
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/global-config.test.ts +39 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/index.test.ts +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +46 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/number.test.ts +55 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/object.test.ts +83 -6
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/optional.test.ts +114 -4
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/partial.test.ts +28 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/prefault.test.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/record.test.ts +85 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +49 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/refine.test.ts +63 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/string.test.ts +50 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +4 -4
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +128 -14
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/transform.test.ts +17 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/tuple.test.ts +315 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/union.test.ts +54 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/api.ts +25 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/checks.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/core.ts +17 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/errors.ts +31 -24
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/json-schema-processors.ts +15 -17
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/parse.ts +7 -7
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/regexes.ts +8 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/schemas.ts +218 -66
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/el.test.ts +215 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +22 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +58 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/to-json-schema.ts +9 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/util.ts +52 -35
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/versions.ts +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/el.ts +121 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/en.ts +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/fr.ts +24 -8
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/hr.ts +131 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/index.ts +3 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/it.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/ka.ts +8 -8
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/ro.ts +129 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/uz.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/external.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/schemas.ts +55 -24
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/codec.test.ts +19 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/index.test.ts +27 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/object.test.ts +9 -9
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +51 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/string.test.ts +5 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v3/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/errors.js +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/external.d.cts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/external.d.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/from-json-schema.cjs +31 -16
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/from-json-schema.js +31 -16
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.cjs +346 -117
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.d.cts +34 -12
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.d.ts +34 -12
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.js +345 -117
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.cjs +7 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.d.cts +20 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.d.ts +20 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.js +7 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/checks.d.cts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/checks.d.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/core.cjs +3 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/core.js +4 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.cjs +26 -23
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.d.cts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.d.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.js +26 -23
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/json-schema-processors.cjs +14 -19
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/json-schema-processors.js +14 -19
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/parse.cjs +7 -7
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/parse.js +7 -7
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.cjs +9 -3
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.d.cts +6 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.d.ts +6 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.js +7 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.cjs +196 -59
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.d.cts +21 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.d.ts +21 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.js +196 -59
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/to-json-schema.cjs +10 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/to-json-schema.js +10 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.cjs +54 -30
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.d.cts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.d.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.js +55 -32
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.cjs +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.d.cts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.d.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.js +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.cjs +136 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.d.cts +5 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.d.ts +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.js +109 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/en.cjs +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/en.js +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/fr.cjs +24 -7
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/fr.js +24 -7
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.cjs +149 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.d.cts +5 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.d.ts +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.js +122 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.cjs +8 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.d.cts +3 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.d.ts +3 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.js +3 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/it.cjs +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/it.js +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ka.cjs +8 -8
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ka.js +8 -8
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.cjs +146 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.d.cts +5 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.d.ts +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.js +119 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/uz.cjs +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/uz.js +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/external.d.cts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/external.d.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.cjs +41 -4
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.d.cts +27 -9
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.d.ts +27 -9
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.js +40 -4
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4-mini/package.json +2 -1
- package/package.json +10 -10
|
@@ -110,6 +110,11 @@ export function _nanoid(Class, params) {
|
|
|
110
110
|
...util.normalizeParams(params),
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
115
|
+
* (timestamps embedded in the id). Use {@link _cuid2} instead.
|
|
116
|
+
* See https://github.com/paralleldrive/cuid.
|
|
117
|
+
*/
|
|
113
118
|
// @__NO_SIDE_EFFECTS__
|
|
114
119
|
export function _cuid(Class, params) {
|
|
115
120
|
return new Class({
|
|
@@ -954,7 +959,7 @@ export function _refine(Class, fn, _params) {
|
|
|
954
959
|
return schema;
|
|
955
960
|
}
|
|
956
961
|
// @__NO_SIDE_EFFECTS__
|
|
957
|
-
export function _superRefine(fn) {
|
|
962
|
+
export function _superRefine(fn, params) {
|
|
958
963
|
const ch = _check((payload) => {
|
|
959
964
|
payload.addIssue = (issue) => {
|
|
960
965
|
if (typeof issue === "string") {
|
|
@@ -973,7 +978,7 @@ export function _superRefine(fn) {
|
|
|
973
978
|
}
|
|
974
979
|
};
|
|
975
980
|
return fn(payload.value, payload);
|
|
976
|
-
});
|
|
981
|
+
}, params);
|
|
977
982
|
return ch;
|
|
978
983
|
}
|
|
979
984
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -7,7 +7,7 @@ export interface $ZodCheckDef {
|
|
|
7
7
|
error?: errors.$ZodErrorMap<never> | undefined;
|
|
8
8
|
/** If true, no later checks will be executed if this check fails. Default `false`. */
|
|
9
9
|
abort?: boolean | undefined;
|
|
10
|
-
/** If provided,
|
|
10
|
+
/** If provided, the check runs only when this returns `true`. By default, it is skipped if prior parsing produced aborting issues. */
|
|
11
11
|
when?: ((payload: schemas.ParsePayload) => boolean) | undefined;
|
|
12
12
|
}
|
|
13
13
|
export interface $ZodCheckInternals<T> {
|
|
@@ -7,7 +7,7 @@ export interface $ZodCheckDef {
|
|
|
7
7
|
error?: errors.$ZodErrorMap<never> | undefined;
|
|
8
8
|
/** If true, no later checks will be executed if this check fails. Default `false`. */
|
|
9
9
|
abort?: boolean | undefined;
|
|
10
|
-
/** If provided,
|
|
10
|
+
/** If provided, the check runs only when this returns `true`. By default, it is skipped if prior parsing produced aborting issues. */
|
|
11
11
|
when?: ((payload: schemas.ParsePayload) => boolean) | undefined;
|
|
12
12
|
}
|
|
13
13
|
export interface $ZodCheckInternals<T> {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.globalConfig = exports.$ZodEncodeError = exports.$ZodAsyncError = exports.$brand = exports.NEVER = void 0;
|
|
4
5
|
exports.$constructor = $constructor;
|
|
@@ -75,7 +76,8 @@ class $ZodEncodeError extends Error {
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
exports.$ZodEncodeError = $ZodEncodeError;
|
|
78
|
-
|
|
79
|
+
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
|
|
80
|
+
exports.globalConfig = globalThis.__zod_globalConfig;
|
|
79
81
|
function config(newConfig) {
|
|
80
82
|
if (newConfig)
|
|
81
83
|
Object.assign(exports.globalConfig, newConfig);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
var _a;
|
|
1
2
|
/** A special constant with type `never` */
|
|
2
|
-
export const NEVER = Object.freeze({
|
|
3
|
+
export const NEVER = /*@__PURE__*/ Object.freeze({
|
|
3
4
|
status: "aborted",
|
|
4
5
|
});
|
|
5
6
|
export /*@__NO_SIDE_EFFECTS__*/ function $constructor(name, initializer, params) {
|
|
@@ -68,7 +69,8 @@ export class $ZodEncodeError extends Error {
|
|
|
68
69
|
this.name = "ZodEncodeError";
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
|
-
|
|
72
|
+
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
|
|
73
|
+
export const globalConfig = globalThis.__zod_globalConfig;
|
|
72
74
|
export function config(newConfig) {
|
|
73
75
|
if (newConfig)
|
|
74
76
|
Object.assign(globalConfig, newConfig);
|
|
@@ -65,35 +65,38 @@ function flattenError(error, mapper = (issue) => issue.message) {
|
|
|
65
65
|
}
|
|
66
66
|
function formatError(error, mapper = (issue) => issue.message) {
|
|
67
67
|
const fieldErrors = { _errors: [] };
|
|
68
|
-
const processError = (error) => {
|
|
68
|
+
const processError = (error, path = []) => {
|
|
69
69
|
for (const issue of error.issues) {
|
|
70
70
|
if (issue.code === "invalid_union" && issue.errors.length) {
|
|
71
|
-
issue.errors.map((issues) => processError({ issues }));
|
|
71
|
+
issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
72
72
|
}
|
|
73
73
|
else if (issue.code === "invalid_key") {
|
|
74
|
-
processError({ issues: issue.issues });
|
|
74
|
+
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
75
75
|
}
|
|
76
76
|
else if (issue.code === "invalid_element") {
|
|
77
|
-
processError({ issues: issue.issues });
|
|
78
|
-
}
|
|
79
|
-
else if (issue.path.length === 0) {
|
|
80
|
-
fieldErrors._errors.push(mapper(issue));
|
|
77
|
+
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
81
78
|
}
|
|
82
79
|
else {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
80
|
+
const fullpath = [...path, ...issue.path];
|
|
81
|
+
if (fullpath.length === 0) {
|
|
82
|
+
fieldErrors._errors.push(mapper(issue));
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
let curr = fieldErrors;
|
|
86
|
+
let i = 0;
|
|
87
|
+
while (i < fullpath.length) {
|
|
88
|
+
const el = fullpath[i];
|
|
89
|
+
const terminal = i === fullpath.length - 1;
|
|
90
|
+
if (!terminal) {
|
|
91
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
95
|
+
curr[el]._errors.push(mapper(issue));
|
|
96
|
+
}
|
|
97
|
+
curr = curr[el];
|
|
98
|
+
i++;
|
|
94
99
|
}
|
|
95
|
-
curr = curr[el];
|
|
96
|
-
i++;
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
102
|
}
|
|
@@ -108,13 +111,13 @@ function treeifyError(error, mapper = (issue) => issue.message) {
|
|
|
108
111
|
for (const issue of error.issues) {
|
|
109
112
|
if (issue.code === "invalid_union" && issue.errors.length) {
|
|
110
113
|
// regular union error
|
|
111
|
-
issue.errors.map((issues) => processError({ issues }, issue.path));
|
|
114
|
+
issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
112
115
|
}
|
|
113
116
|
else if (issue.code === "invalid_key") {
|
|
114
|
-
processError({ issues: issue.issues }, issue.path);
|
|
117
|
+
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
115
118
|
}
|
|
116
119
|
else if (issue.code === "invalid_element") {
|
|
117
|
-
processError({ issues: issue.issues }, issue.path);
|
|
120
|
+
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
118
121
|
}
|
|
119
122
|
else {
|
|
120
123
|
const fullpath = [...path, ...issue.path];
|
|
@@ -54,6 +54,7 @@ interface $ZodIssueInvalidUnionNoMatch extends $ZodIssueBase {
|
|
|
54
54
|
readonly errors: $ZodIssue[][];
|
|
55
55
|
readonly input?: unknown;
|
|
56
56
|
readonly discriminator?: string | undefined;
|
|
57
|
+
readonly options?: util.Primitive[];
|
|
57
58
|
readonly inclusive?: true;
|
|
58
59
|
}
|
|
59
60
|
interface $ZodIssueInvalidUnionMultipleMatch extends $ZodIssueBase {
|
|
@@ -54,6 +54,7 @@ interface $ZodIssueInvalidUnionNoMatch extends $ZodIssueBase {
|
|
|
54
54
|
readonly errors: $ZodIssue[][];
|
|
55
55
|
readonly input?: unknown;
|
|
56
56
|
readonly discriminator?: string | undefined;
|
|
57
|
+
readonly options?: util.Primitive[];
|
|
57
58
|
readonly inclusive?: true;
|
|
58
59
|
}
|
|
59
60
|
interface $ZodIssueInvalidUnionMultipleMatch extends $ZodIssueBase {
|
|
@@ -34,35 +34,38 @@ export function flattenError(error, mapper = (issue) => issue.message) {
|
|
|
34
34
|
}
|
|
35
35
|
export function formatError(error, mapper = (issue) => issue.message) {
|
|
36
36
|
const fieldErrors = { _errors: [] };
|
|
37
|
-
const processError = (error) => {
|
|
37
|
+
const processError = (error, path = []) => {
|
|
38
38
|
for (const issue of error.issues) {
|
|
39
39
|
if (issue.code === "invalid_union" && issue.errors.length) {
|
|
40
|
-
issue.errors.map((issues) => processError({ issues }));
|
|
40
|
+
issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
41
41
|
}
|
|
42
42
|
else if (issue.code === "invalid_key") {
|
|
43
|
-
processError({ issues: issue.issues });
|
|
43
|
+
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
44
44
|
}
|
|
45
45
|
else if (issue.code === "invalid_element") {
|
|
46
|
-
processError({ issues: issue.issues });
|
|
47
|
-
}
|
|
48
|
-
else if (issue.path.length === 0) {
|
|
49
|
-
fieldErrors._errors.push(mapper(issue));
|
|
46
|
+
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
50
47
|
}
|
|
51
48
|
else {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
49
|
+
const fullpath = [...path, ...issue.path];
|
|
50
|
+
if (fullpath.length === 0) {
|
|
51
|
+
fieldErrors._errors.push(mapper(issue));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
let curr = fieldErrors;
|
|
55
|
+
let i = 0;
|
|
56
|
+
while (i < fullpath.length) {
|
|
57
|
+
const el = fullpath[i];
|
|
58
|
+
const terminal = i === fullpath.length - 1;
|
|
59
|
+
if (!terminal) {
|
|
60
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
64
|
+
curr[el]._errors.push(mapper(issue));
|
|
65
|
+
}
|
|
66
|
+
curr = curr[el];
|
|
67
|
+
i++;
|
|
63
68
|
}
|
|
64
|
-
curr = curr[el];
|
|
65
|
-
i++;
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
}
|
|
@@ -77,13 +80,13 @@ export function treeifyError(error, mapper = (issue) => issue.message) {
|
|
|
77
80
|
for (const issue of error.issues) {
|
|
78
81
|
if (issue.code === "invalid_union" && issue.errors.length) {
|
|
79
82
|
// regular union error
|
|
80
|
-
issue.errors.map((issues) => processError({ issues }, issue.path));
|
|
83
|
+
issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
81
84
|
}
|
|
82
85
|
else if (issue.code === "invalid_key") {
|
|
83
|
-
processError({ issues: issue.issues }, issue.path);
|
|
86
|
+
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
84
87
|
}
|
|
85
88
|
else if (issue.code === "invalid_element") {
|
|
86
|
-
processError({ issues: issue.issues }, issue.path);
|
|
89
|
+
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
87
90
|
}
|
|
88
91
|
else {
|
|
89
92
|
const fullpath = [...path, ...issue.path];
|
|
@@ -58,8 +58,12 @@ const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
58
58
|
json.type = "integer";
|
|
59
59
|
else
|
|
60
60
|
json.type = "number";
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
// when both minimum and exclusiveMinimum exist, pick the more restrictive one
|
|
62
|
+
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
63
|
+
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
64
|
+
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
65
|
+
if (exMin) {
|
|
66
|
+
if (legacy) {
|
|
63
67
|
json.minimum = exclusiveMinimum;
|
|
64
68
|
json.exclusiveMinimum = true;
|
|
65
69
|
}
|
|
@@ -67,17 +71,11 @@ const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
67
71
|
json.exclusiveMinimum = exclusiveMinimum;
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
|
-
if (typeof minimum === "number") {
|
|
74
|
+
else if (typeof minimum === "number") {
|
|
71
75
|
json.minimum = minimum;
|
|
72
|
-
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
|
|
73
|
-
if (exclusiveMinimum >= minimum)
|
|
74
|
-
delete json.minimum;
|
|
75
|
-
else
|
|
76
|
-
delete json.exclusiveMinimum;
|
|
77
|
-
}
|
|
78
76
|
}
|
|
79
|
-
if (
|
|
80
|
-
if (
|
|
77
|
+
if (exMax) {
|
|
78
|
+
if (legacy) {
|
|
81
79
|
json.maximum = exclusiveMaximum;
|
|
82
80
|
json.exclusiveMaximum = true;
|
|
83
81
|
}
|
|
@@ -85,14 +83,8 @@ const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
85
83
|
json.exclusiveMaximum = exclusiveMaximum;
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
|
-
if (typeof maximum === "number") {
|
|
86
|
+
else if (typeof maximum === "number") {
|
|
89
87
|
json.maximum = maximum;
|
|
90
|
-
if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
|
|
91
|
-
if (exclusiveMaximum <= maximum)
|
|
92
|
-
delete json.maximum;
|
|
93
|
-
else
|
|
94
|
-
delete json.exclusiveMaximum;
|
|
95
|
-
}
|
|
96
88
|
}
|
|
97
89
|
if (typeof multipleOf === "number")
|
|
98
90
|
json.multipleOf = multipleOf;
|
|
@@ -302,7 +294,10 @@ const arrayProcessor = (schema, ctx, _json, params) => {
|
|
|
302
294
|
if (typeof maximum === "number")
|
|
303
295
|
json.maxItems = maximum;
|
|
304
296
|
json.type = "array";
|
|
305
|
-
json.items = (0, to_json_schema_js_1.process)(def.element, ctx, {
|
|
297
|
+
json.items = (0, to_json_schema_js_1.process)(def.element, ctx, {
|
|
298
|
+
...params,
|
|
299
|
+
path: [...params.path, "items"],
|
|
300
|
+
});
|
|
306
301
|
};
|
|
307
302
|
exports.arrayProcessor = arrayProcessor;
|
|
308
303
|
const objectProcessor = (schema, ctx, _json, params) => {
|
|
@@ -53,8 +53,12 @@ export const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
53
53
|
json.type = "integer";
|
|
54
54
|
else
|
|
55
55
|
json.type = "number";
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
// when both minimum and exclusiveMinimum exist, pick the more restrictive one
|
|
57
|
+
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
58
|
+
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
59
|
+
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
60
|
+
if (exMin) {
|
|
61
|
+
if (legacy) {
|
|
58
62
|
json.minimum = exclusiveMinimum;
|
|
59
63
|
json.exclusiveMinimum = true;
|
|
60
64
|
}
|
|
@@ -62,17 +66,11 @@ export const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
62
66
|
json.exclusiveMinimum = exclusiveMinimum;
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
|
-
if (typeof minimum === "number") {
|
|
69
|
+
else if (typeof minimum === "number") {
|
|
66
70
|
json.minimum = minimum;
|
|
67
|
-
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
|
|
68
|
-
if (exclusiveMinimum >= minimum)
|
|
69
|
-
delete json.minimum;
|
|
70
|
-
else
|
|
71
|
-
delete json.exclusiveMinimum;
|
|
72
|
-
}
|
|
73
71
|
}
|
|
74
|
-
if (
|
|
75
|
-
if (
|
|
72
|
+
if (exMax) {
|
|
73
|
+
if (legacy) {
|
|
76
74
|
json.maximum = exclusiveMaximum;
|
|
77
75
|
json.exclusiveMaximum = true;
|
|
78
76
|
}
|
|
@@ -80,14 +78,8 @@ export const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
80
78
|
json.exclusiveMaximum = exclusiveMaximum;
|
|
81
79
|
}
|
|
82
80
|
}
|
|
83
|
-
if (typeof maximum === "number") {
|
|
81
|
+
else if (typeof maximum === "number") {
|
|
84
82
|
json.maximum = maximum;
|
|
85
|
-
if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
|
|
86
|
-
if (exclusiveMaximum <= maximum)
|
|
87
|
-
delete json.maximum;
|
|
88
|
-
else
|
|
89
|
-
delete json.exclusiveMaximum;
|
|
90
|
-
}
|
|
91
83
|
}
|
|
92
84
|
if (typeof multipleOf === "number")
|
|
93
85
|
json.multipleOf = multipleOf;
|
|
@@ -275,7 +267,10 @@ export const arrayProcessor = (schema, ctx, _json, params) => {
|
|
|
275
267
|
if (typeof maximum === "number")
|
|
276
268
|
json.maxItems = maximum;
|
|
277
269
|
json.type = "array";
|
|
278
|
-
json.items = process(def.element, ctx, {
|
|
270
|
+
json.items = process(def.element, ctx, {
|
|
271
|
+
...params,
|
|
272
|
+
path: [...params.path, "items"],
|
|
273
|
+
});
|
|
279
274
|
};
|
|
280
275
|
export const objectProcessor = (schema, ctx, _json, params) => {
|
|
281
276
|
const json = _json;
|
|
@@ -28,7 +28,7 @@ const core = __importStar(require("./core.cjs"));
|
|
|
28
28
|
const errors = __importStar(require("./errors.cjs"));
|
|
29
29
|
const util = __importStar(require("./util.cjs"));
|
|
30
30
|
const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
31
|
-
const ctx = _ctx ?
|
|
31
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
32
32
|
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
33
33
|
if (result instanceof Promise) {
|
|
34
34
|
throw new core.$ZodAsyncError();
|
|
@@ -43,7 +43,7 @@ const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
43
43
|
exports._parse = _parse;
|
|
44
44
|
exports.parse = (0, exports._parse)(errors.$ZodRealError);
|
|
45
45
|
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
46
|
-
const ctx = _ctx ?
|
|
46
|
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
47
47
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
48
48
|
if (result instanceof Promise)
|
|
49
49
|
result = await result;
|
|
@@ -72,7 +72,7 @@ const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
|
72
72
|
exports._safeParse = _safeParse;
|
|
73
73
|
exports.safeParse = (0, exports._safeParse)(errors.$ZodRealError);
|
|
74
74
|
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
75
|
-
const ctx = _ctx ?
|
|
75
|
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
76
76
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
77
77
|
if (result instanceof Promise)
|
|
78
78
|
result = await result;
|
|
@@ -86,7 +86,7 @@ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
86
86
|
exports._safeParseAsync = _safeParseAsync;
|
|
87
87
|
exports.safeParseAsync = (0, exports._safeParseAsync)(errors.$ZodRealError);
|
|
88
88
|
const _encode = (_Err) => (schema, value, _ctx) => {
|
|
89
|
-
const ctx = _ctx ?
|
|
89
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
90
90
|
return (0, exports._parse)(_Err)(schema, value, ctx);
|
|
91
91
|
};
|
|
92
92
|
exports._encode = _encode;
|
|
@@ -97,7 +97,7 @@ const _decode = (_Err) => (schema, value, _ctx) => {
|
|
|
97
97
|
exports._decode = _decode;
|
|
98
98
|
exports.decode = (0, exports._decode)(errors.$ZodRealError);
|
|
99
99
|
const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
100
|
-
const ctx = _ctx ?
|
|
100
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
101
101
|
return (0, exports._parseAsync)(_Err)(schema, value, ctx);
|
|
102
102
|
};
|
|
103
103
|
exports._encodeAsync = _encodeAsync;
|
|
@@ -108,7 +108,7 @@ const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
108
108
|
exports._decodeAsync = _decodeAsync;
|
|
109
109
|
exports.decodeAsync = (0, exports._decodeAsync)(errors.$ZodRealError);
|
|
110
110
|
const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
111
|
-
const ctx = _ctx ?
|
|
111
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
112
112
|
return (0, exports._safeParse)(_Err)(schema, value, ctx);
|
|
113
113
|
};
|
|
114
114
|
exports._safeEncode = _safeEncode;
|
|
@@ -119,7 +119,7 @@ const _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
|
119
119
|
exports._safeDecode = _safeDecode;
|
|
120
120
|
exports.safeDecode = (0, exports._safeDecode)(errors.$ZodRealError);
|
|
121
121
|
const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
122
|
-
const ctx = _ctx ?
|
|
122
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
123
123
|
return (0, exports._safeParseAsync)(_Err)(schema, value, ctx);
|
|
124
124
|
};
|
|
125
125
|
exports._safeEncodeAsync = _safeEncodeAsync;
|
|
@@ -2,7 +2,7 @@ import * as core from "./core.js";
|
|
|
2
2
|
import * as errors from "./errors.js";
|
|
3
3
|
import * as util from "./util.js";
|
|
4
4
|
export const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
5
|
-
const ctx = _ctx ?
|
|
5
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
6
6
|
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
7
7
|
if (result instanceof Promise) {
|
|
8
8
|
throw new core.$ZodAsyncError();
|
|
@@ -16,7 +16,7 @@ export const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
16
16
|
};
|
|
17
17
|
export const parse = /* @__PURE__*/ _parse(errors.$ZodRealError);
|
|
18
18
|
export const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
19
|
-
const ctx = _ctx ?
|
|
19
|
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
20
20
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
21
21
|
if (result instanceof Promise)
|
|
22
22
|
result = await result;
|
|
@@ -43,7 +43,7 @@ export const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
|
43
43
|
};
|
|
44
44
|
export const safeParse = /* @__PURE__*/ _safeParse(errors.$ZodRealError);
|
|
45
45
|
export const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
46
|
-
const ctx = _ctx ?
|
|
46
|
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
47
47
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
48
48
|
if (result instanceof Promise)
|
|
49
49
|
result = await result;
|
|
@@ -56,7 +56,7 @@ export const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
56
56
|
};
|
|
57
57
|
export const safeParseAsync = /* @__PURE__*/ _safeParseAsync(errors.$ZodRealError);
|
|
58
58
|
export const _encode = (_Err) => (schema, value, _ctx) => {
|
|
59
|
-
const ctx = _ctx ?
|
|
59
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
60
60
|
return _parse(_Err)(schema, value, ctx);
|
|
61
61
|
};
|
|
62
62
|
export const encode = /* @__PURE__*/ _encode(errors.$ZodRealError);
|
|
@@ -65,7 +65,7 @@ export const _decode = (_Err) => (schema, value, _ctx) => {
|
|
|
65
65
|
};
|
|
66
66
|
export const decode = /* @__PURE__*/ _decode(errors.$ZodRealError);
|
|
67
67
|
export const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
68
|
-
const ctx = _ctx ?
|
|
68
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
69
69
|
return _parseAsync(_Err)(schema, value, ctx);
|
|
70
70
|
};
|
|
71
71
|
export const encodeAsync = /* @__PURE__*/ _encodeAsync(errors.$ZodRealError);
|
|
@@ -74,7 +74,7 @@ export const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
74
74
|
};
|
|
75
75
|
export const decodeAsync = /* @__PURE__*/ _decodeAsync(errors.$ZodRealError);
|
|
76
76
|
export const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
77
|
-
const ctx = _ctx ?
|
|
77
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
78
78
|
return _safeParse(_Err)(schema, value, ctx);
|
|
79
79
|
};
|
|
80
80
|
export const safeEncode = /* @__PURE__*/ _safeEncode(errors.$ZodRealError);
|
|
@@ -83,7 +83,7 @@ export const _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
|
83
83
|
};
|
|
84
84
|
export const safeDecode = /* @__PURE__*/ _safeDecode(errors.$ZodRealError);
|
|
85
85
|
export const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
86
|
-
const ctx = _ctx ?
|
|
86
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
87
87
|
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
88
88
|
};
|
|
89
89
|
export const safeEncodeAsync = /* @__PURE__*/ _safeEncodeAsync(errors.$ZodRealError);
|
|
@@ -23,13 +23,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
exports.sha512_base64url = exports.sha512_base64 = exports.sha512_hex = exports.sha384_base64url = exports.sha384_base64 = void 0;
|
|
26
|
+
exports.sha256_base64url = exports.sha256_base64 = exports.sha256_hex = exports.sha1_base64url = exports.sha1_base64 = exports.sha1_hex = exports.md5_base64url = exports.md5_base64 = exports.md5_hex = exports.hex = exports.uppercase = exports.lowercase = exports.undefined = exports.null = exports.boolean = exports.number = exports.integer = exports.bigint = exports.string = exports.date = exports.e164 = exports.httpProtocol = exports.domain = exports.hostname = exports.base64url = exports.base64 = exports.cidrv6 = exports.cidrv4 = exports.mac = exports.ipv6 = exports.ipv4 = exports.browserEmail = exports.idnEmail = exports.unicodeEmail = exports.rfc5322Email = exports.html5Email = exports.email = exports.uuid7 = exports.uuid6 = exports.uuid4 = exports.uuid = exports.guid = exports.extendedDuration = exports.duration = exports.nanoid = exports.ksuid = exports.xid = exports.ulid = exports.cuid2 = exports.cuid = void 0;
|
|
27
|
+
exports.sha512_base64url = exports.sha512_base64 = exports.sha512_hex = exports.sha384_base64url = exports.sha384_base64 = exports.sha384_hex = void 0;
|
|
28
28
|
exports.emoji = emoji;
|
|
29
29
|
exports.time = time;
|
|
30
30
|
exports.datetime = datetime;
|
|
31
31
|
const util = __importStar(require("./util.cjs"));
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
34
|
+
* (timestamps embedded in the id). Use {@link cuid2} instead.
|
|
35
|
+
* See https://github.com/paralleldrive/cuid.
|
|
36
|
+
*/
|
|
37
|
+
exports.cuid = /^[cC][0-9a-z]{6,}$/;
|
|
33
38
|
exports.cuid2 = /^[0-9a-z]+$/;
|
|
34
39
|
exports.ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
35
40
|
exports.xid = /^[0-9a-vA-V]{20}$/;
|
|
@@ -84,6 +89,7 @@ exports.base64url = /^[A-Za-z0-9_-]*$/;
|
|
|
84
89
|
// export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
|
85
90
|
exports.hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
86
91
|
exports.domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
92
|
+
exports.httpProtocol = /^https?$/;
|
|
87
93
|
// https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
|
|
88
94
|
// E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15
|
|
89
95
|
exports.e164 = /^\+[1-9]\d{6,14}$/;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
3
|
+
* (timestamps embedded in the id). Use {@link cuid2} instead.
|
|
4
|
+
* See https://github.com/paralleldrive/cuid.
|
|
5
|
+
*/
|
|
1
6
|
export declare const cuid: RegExp;
|
|
2
7
|
export declare const cuid2: RegExp;
|
|
3
8
|
export declare const ulid: RegExp;
|
|
@@ -37,6 +42,7 @@ export declare const base64: RegExp;
|
|
|
37
42
|
export declare const base64url: RegExp;
|
|
38
43
|
export declare const hostname: RegExp;
|
|
39
44
|
export declare const domain: RegExp;
|
|
45
|
+
export declare const httpProtocol: RegExp;
|
|
40
46
|
export declare const e164: RegExp;
|
|
41
47
|
export declare const date: RegExp;
|
|
42
48
|
export declare function time(args: {
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
3
|
+
* (timestamps embedded in the id). Use {@link cuid2} instead.
|
|
4
|
+
* See https://github.com/paralleldrive/cuid.
|
|
5
|
+
*/
|
|
1
6
|
export declare const cuid: RegExp;
|
|
2
7
|
export declare const cuid2: RegExp;
|
|
3
8
|
export declare const ulid: RegExp;
|
|
@@ -37,6 +42,7 @@ export declare const base64: RegExp;
|
|
|
37
42
|
export declare const base64url: RegExp;
|
|
38
43
|
export declare const hostname: RegExp;
|
|
39
44
|
export declare const domain: RegExp;
|
|
45
|
+
export declare const httpProtocol: RegExp;
|
|
40
46
|
export declare const e164: RegExp;
|
|
41
47
|
export declare const date: RegExp;
|
|
42
48
|
export declare function time(args: {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import * as util from "./util.js";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
4
|
+
* (timestamps embedded in the id). Use {@link cuid2} instead.
|
|
5
|
+
* See https://github.com/paralleldrive/cuid.
|
|
6
|
+
*/
|
|
7
|
+
export const cuid = /^[cC][0-9a-z]{6,}$/;
|
|
3
8
|
export const cuid2 = /^[0-9a-z]+$/;
|
|
4
9
|
export const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
5
10
|
export const xid = /^[0-9a-vA-V]{20}$/;
|
|
@@ -52,6 +57,7 @@ export const base64url = /^[A-Za-z0-9_-]*$/;
|
|
|
52
57
|
// export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
|
53
58
|
export const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
54
59
|
export const domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
60
|
+
export const httpProtocol = /^https?$/;
|
|
55
61
|
// https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
|
|
56
62
|
// E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15
|
|
57
63
|
export const e164 = /^\+[1-9]\d{6,14}$/;
|