@atxp/base 0.8.3 → 0.9.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.
- package/dist/baseAccount.d.ts +20 -0
- package/dist/baseAccount.d.ts.map +1 -0
- package/dist/baseAccount.js +46 -0
- package/dist/baseAccount.js.map +1 -0
- package/dist/baseAppAccount.js +1 -1
- package/dist/baseAppPaymentMaker.js +1 -1
- package/dist/baseConstants.d.ts +10 -0
- package/dist/baseConstants.d.ts.map +1 -0
- package/dist/baseConstants.js +21 -0
- package/dist/baseConstants.js.map +1 -0
- package/dist/basePaymentMaker.d.ts +23 -0
- package/dist/basePaymentMaker.d.ts.map +1 -0
- package/dist/basePaymentMaker.js +196 -0
- package/dist/basePaymentMaker.js.map +1 -0
- package/dist/index.cjs +5258 -209
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +49 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5254 -210
- package/dist/index.js.map +1 -1
- package/dist/mainWalletPaymentMaker.d.ts.map +1 -1
- package/dist/mainWalletPaymentMaker.js +1 -1
- package/dist/mainWalletPaymentMaker.js.map +1 -1
- package/dist/node_modules/@aa-sdk/core/dist/esm/client/schema.js +69 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/client/schema.js.map +1 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/errors/base.js +43 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/errors/base.js.map +1 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/errors/client.js +22 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/errors/client.js.map +1 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/transport/split.js +57 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/transport/split.js.map +1 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/utils/schema.js +33 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/utils/schema.js.map +1 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/utils/traceHeader.js +22 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/utils/traceHeader.js.map +1 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/version.js +6 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/version.js.map +1 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/alchemyTrackerHeaders.js +36 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/alchemyTrackerHeaders.js.map +1 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/alchemyTransport.js +190 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/alchemyTransport.js.map +1 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/schema.js +10 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/schema.js.map +1 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/version.js +6 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/version.js.map +1 -0
- package/dist/node_modules/zod/index.js +6 -0
- package/dist/node_modules/zod/index.js.map +1 -0
- package/dist/node_modules/zod/v3/ZodError.js +137 -0
- package/dist/node_modules/zod/v3/ZodError.js.map +1 -0
- package/dist/node_modules/zod/v3/errors.js +12 -0
- package/dist/node_modules/zod/v3/errors.js.map +1 -0
- package/dist/node_modules/zod/v3/external.js +7 -0
- package/dist/node_modules/zod/v3/external.js.map +1 -0
- package/dist/node_modules/zod/v3/helpers/errorUtil.js +9 -0
- package/dist/node_modules/zod/v3/helpers/errorUtil.js.map +1 -0
- package/dist/node_modules/zod/v3/helpers/parseUtil.js +113 -0
- package/dist/node_modules/zod/v3/helpers/parseUtil.js.map +1 -0
- package/dist/node_modules/zod/v3/helpers/util.js +136 -0
- package/dist/node_modules/zod/v3/helpers/util.js.map +1 -0
- package/dist/node_modules/zod/v3/locales/en.js +112 -0
- package/dist/node_modules/zod/v3/locales/en.js.map +1 -0
- package/dist/node_modules/zod/v3/types.js +3690 -0
- package/dist/node_modules/zod/v3/types.js.map +1 -0
- package/dist/smartWalletHelpers.d.ts +5 -1
- package/dist/smartWalletHelpers.d.ts.map +1 -1
- package/dist/smartWalletHelpers.js +67 -3
- package/dist/smartWalletHelpers.js.map +1 -1
- package/package.json +5 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alchemyTransport.js","sources":["../../../../../../../../node_modules/@account-kit/infra/dist/esm/alchemyTransport.js"],"sourcesContent":["import { ChainNotFoundError, ConnectionConfigSchema, split, } from \"@aa-sdk/core\";\nimport { createTransport, http, } from \"viem\";\nimport { mutateRemoveTrackingHeaders } from \"./alchemyTrackerHeaders.js\";\nimport { AlchemyChainSchema } from \"./schema.js\";\nimport { VERSION } from \"./version.js\";\nconst alchemyMethods = [\n \"eth_sendUserOperation\",\n \"eth_estimateUserOperationGas\",\n \"eth_getUserOperationReceipt\",\n \"eth_getUserOperationByHash\",\n \"eth_supportedEntryPoints\",\n \"rundler_maxPriorityFeePerGas\",\n \"pm_getPaymasterData\",\n \"pm_getPaymasterStubData\",\n \"alchemy_requestGasAndPaymasterAndData\",\n];\nconst chainAgnosticMethods = [\n \"wallet_prepareCalls\",\n \"wallet_sendPreparedCalls\",\n \"wallet_requestAccount\",\n \"wallet_createAccount\",\n \"wallet_listAccounts\",\n \"wallet_createSession\",\n \"wallet_getCallsStatus\",\n \"wallet_requestQuote_v0\",\n];\n/**\n * A type guard for the transport to determine if it is an Alchemy transport.\n * Used in cases where we would like to do switching depending on the transport, where there used\n * to be two clients for an alchemy and a non-alchemy, and with this switch we don't need the two seperate clients. *\n *\n * @param {Transport} transport The transport to check\n * @param {Chain} chain Chain for the transport to run its function to return the transport config\n * @returns {boolean} `true` if the transport is an Alchemy transport, otherwise `false`\n */\nexport function isAlchemyTransport(transport, chain) {\n return transport({ chain }).config.type === \"alchemy\";\n}\n/**\n * Creates an Alchemy transport with the specified configuration options.\n * When sending all traffic to Alchemy, you must pass in one of rpcUrl, apiKey, or jwt.\n * If you want to send Bundler and Paymaster traffic to Alchemy and Node traffic to a different RPC, you must pass in alchemyConnection and nodeRpcUrl.\n *\n * @example\n * ### Basic Example\n * If the chain you're using is supported for both Bundler and Node RPCs, then you can do the following:\n * ```ts\n * import { alchemy } from \"@account-kit/infra\";\n *\n * const transport = alchemy({\n * // NOTE: you can also pass in an rpcUrl or jwt here or rpcUrl and jwt\n * apiKey: \"your-api-key\",\n * });\n * ```\n *\n * ### AA Only Chains\n * For AA-only chains, you need to specify the alchemyConnection and nodeRpcUrl since Alchemy only\n * handles the Bundler and Paymaster RPCs for these chains.\n * ```ts\n * import { alchemy } from \"@account-kit/infra\";\n *\n * const transport = alchemy({\n * alchemyConnection: {\n * apiKey: \"your-api-key\",\n * },\n * nodeRpcUrl: \"https://zora.rpc.url\",\n * });\n * ```\n *\n * @param {AlchemyTransportConfig} config The configuration object for the Alchemy transport.\n * @param {number} config.retryDelay Optional The delay between retries, in milliseconds.\n * @param {number} config.retryCount Optional The number of retry attempts.\n * @param {string} [config.alchemyConnection] Optional Alchemy connection configuration (if this is passed in, nodeRpcUrl is required).\n * @param {string} [config.fetchOptions] Optional fetch options for HTTP requests.\n * @param {string} [config.nodeRpcUrl] Optional RPC URL for node (if this is passed in, alchemyConnection is required).\n * @param {string} [config.rpcUrl] Optional RPC URL.\n * @param {string} [config.apiKey] Optional API key for Alchemy.\n * @param {string} [config.jwt] Optional JSON Web Token for authorization.\n * @returns {AlchemyTransport} The configured Alchemy transport object.\n */\nexport function alchemy(config) {\n const { retryDelay, retryCount = 0 } = config;\n // we create a copy here in case we create a split transport down below\n // we don't want to add alchemy headers to 3rd party nodes\n const fetchOptions = { ...config.fetchOptions };\n const connectionConfig = ConnectionConfigSchema.parse(config.alchemyConnection ?? config);\n const headersAsObject = convertHeadersToObject(fetchOptions.headers);\n // TODO: we probably should just log these headers during telemetry logging instead of doing this mutable header stuff\n fetchOptions.headers = {\n ...headersAsObject,\n \"Alchemy-AA-Sdk-Version\": VERSION,\n };\n if (connectionConfig.jwt != null || connectionConfig.apiKey != null) {\n fetchOptions.headers = {\n ...fetchOptions.headers,\n Authorization: `Bearer ${connectionConfig.jwt ?? connectionConfig.apiKey}`,\n };\n }\n const transport = (opts) => {\n const { chain: chain_ } = opts;\n if (!chain_) {\n throw new ChainNotFoundError();\n }\n const chain = AlchemyChainSchema.parse(chain_);\n const rpcUrl = connectionConfig.rpcUrl == null\n ? chain.rpcUrls.alchemy.http[0]\n : connectionConfig.rpcUrl;\n const chainAgnosticRpcUrl = connectionConfig.rpcUrl == null\n ? \"https://api.g.alchemy.com/v2\"\n : (connectionConfig.chainAgnosticUrl ?? connectionConfig.rpcUrl);\n const innerTransport = (() => {\n mutateRemoveTrackingHeaders(config?.fetchOptions?.headers);\n if (config.alchemyConnection && config.nodeRpcUrl) {\n return split({\n overrides: [\n {\n methods: alchemyMethods,\n transport: http(rpcUrl, { fetchOptions, retryCount }),\n },\n {\n methods: chainAgnosticMethods,\n transport: http(chainAgnosticRpcUrl, {\n fetchOptions,\n retryCount,\n retryDelay,\n }),\n },\n ],\n fallback: http(config.nodeRpcUrl, {\n fetchOptions: config.fetchOptions,\n retryCount,\n retryDelay,\n }),\n });\n }\n return split({\n overrides: [\n {\n methods: chainAgnosticMethods,\n transport: http(chainAgnosticRpcUrl, {\n fetchOptions,\n retryCount,\n retryDelay,\n }),\n },\n ],\n fallback: http(rpcUrl, { fetchOptions, retryCount, retryDelay }),\n });\n })();\n return createTransport({\n key: \"alchemy\",\n name: \"Alchemy Transport\",\n request: innerTransport({\n ...opts,\n // Retries are already handled above within the split transport,\n // so `retryCount` must be 0 here for the expected behavior.\n retryCount: 0,\n }).request,\n // Retries are already handled above within the split transport,\n // so `retryCount` must be 0 here too for the expected behavior.\n retryCount: 0,\n retryDelay,\n type: \"alchemy\",\n }, { alchemyRpcUrl: rpcUrl, fetchOptions });\n };\n return Object.assign(transport, {\n dynamicFetchOptions: fetchOptions,\n updateHeaders(newHeaders_) {\n const newHeaders = convertHeadersToObject(newHeaders_);\n fetchOptions.headers = {\n ...fetchOptions.headers,\n ...newHeaders,\n };\n },\n config,\n });\n}\nexport const convertHeadersToObject = (headers) => {\n if (!headers) {\n return {};\n }\n if (headers instanceof Headers) {\n const headersObject = {};\n headers.forEach((value, key) => {\n headersObject[key] = value;\n });\n return headersObject;\n }\n if (Array.isArray(headers)) {\n return headers.reduce((acc, header) => {\n acc[header[0]] = header[1];\n return acc;\n }, {});\n }\n return headers;\n};\n//# sourceMappingURL=alchemyTransport.js.map"],"names":[],"mappings":";;;;;;;;AAKA,MAAM,cAAc,GAAG;AACvB,IAAI,uBAAuB;AAC3B,IAAI,8BAA8B;AAClC,IAAI,6BAA6B;AACjC,IAAI,4BAA4B;AAChC,IAAI,0BAA0B;AAC9B,IAAI,8BAA8B;AAClC,IAAI,qBAAqB;AACzB,IAAI,yBAAyB;AAC7B,IAAI,uCAAuC;AAC3C,CAAC;AACD,MAAM,oBAAoB,GAAG;AAC7B,IAAI,qBAAqB;AACzB,IAAI,0BAA0B;AAC9B,IAAI,uBAAuB;AAC3B,IAAI,sBAAsB;AAC1B,IAAI,qBAAqB;AACzB,IAAI,sBAAsB;AAC1B,IAAI,uBAAuB;AAC3B,IAAI,wBAAwB;AAC5B,CAAC;AAaD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,OAAO,CAAC,MAAM,EAAE;AAChC,IAAI,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,CAAC,EAAE,GAAG,MAAM;AACjD;AACA;AACA,IAAI,MAAM,YAAY,GAAG,EAAE,GAAG,MAAM,CAAC,YAAY,EAAE;AACnD,IAAI,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,KAAK,CAAC,MAAM,CAAC,iBAAiB,IAAI,MAAM,CAAC;AAC7F,IAAI,MAAM,eAAe,GAAG,sBAAsB,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]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as external from '../../../../zod/v3/external.js';
|
|
2
|
+
import { ChainSchema } from '../../../../@aa-sdk/core/dist/esm/utils/schema.js';
|
|
3
|
+
|
|
4
|
+
const AlchemyChainSchema = external.custom((chain) => {
|
|
5
|
+
const chain_ = ChainSchema.parse(chain);
|
|
6
|
+
return chain_.rpcUrls.alchemy != null;
|
|
7
|
+
}, "chain must include an alchemy rpc url. See `defineAlchemyChain` or import a chain from `@account-kit/infra`.");
|
|
8
|
+
|
|
9
|
+
export { AlchemyChainSchema };
|
|
10
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sources":["../../../../../../../../node_modules/@account-kit/infra/dist/esm/schema.js"],"sourcesContent":["import { ChainSchema } from \"@aa-sdk/core\";\nimport z from \"zod\";\nexport const AlchemyChainSchema = z.custom((chain) => {\n const chain_ = ChainSchema.parse(chain);\n return chain_.rpcUrls.alchemy != null;\n}, \"chain must include an alchemy rpc url. See `defineAlchemyChain` or import a chain from `@account-kit/infra`.\");\n//# sourceMappingURL=schema.js.map"],"names":["z"],"mappings":";;;AAEY,MAAC,kBAAkB,GAAGA,QAAC,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK;AACtD,IAAI,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC;AAC3C,IAAI,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,IAAI;AACzC,CAAC,EAAE,8GAA8G;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../../../../../../../../node_modules/@account-kit/infra/dist/esm/version.js"],"sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.81.3\";\n//# sourceMappingURL=version.js.map"],"names":[],"mappings":"AAAA;AACA;AACY,MAAC,OAAO,GAAG;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { util } from './helpers/util.js';
|
|
2
|
+
|
|
3
|
+
const ZodIssueCode = util.arrayToEnum([
|
|
4
|
+
"invalid_type",
|
|
5
|
+
"invalid_literal",
|
|
6
|
+
"custom",
|
|
7
|
+
"invalid_union",
|
|
8
|
+
"invalid_union_discriminator",
|
|
9
|
+
"invalid_enum_value",
|
|
10
|
+
"unrecognized_keys",
|
|
11
|
+
"invalid_arguments",
|
|
12
|
+
"invalid_return_type",
|
|
13
|
+
"invalid_date",
|
|
14
|
+
"invalid_string",
|
|
15
|
+
"too_small",
|
|
16
|
+
"too_big",
|
|
17
|
+
"invalid_intersection_types",
|
|
18
|
+
"not_multiple_of",
|
|
19
|
+
"not_finite",
|
|
20
|
+
]);
|
|
21
|
+
const quotelessJson = (obj) => {
|
|
22
|
+
const json = JSON.stringify(obj, null, 2);
|
|
23
|
+
return json.replace(/"([^"]+)":/g, "$1:");
|
|
24
|
+
};
|
|
25
|
+
class ZodError extends Error {
|
|
26
|
+
get errors() {
|
|
27
|
+
return this.issues;
|
|
28
|
+
}
|
|
29
|
+
constructor(issues) {
|
|
30
|
+
super();
|
|
31
|
+
this.issues = [];
|
|
32
|
+
this.addIssue = (sub) => {
|
|
33
|
+
this.issues = [...this.issues, sub];
|
|
34
|
+
};
|
|
35
|
+
this.addIssues = (subs = []) => {
|
|
36
|
+
this.issues = [...this.issues, ...subs];
|
|
37
|
+
};
|
|
38
|
+
const actualProto = new.target.prototype;
|
|
39
|
+
if (Object.setPrototypeOf) {
|
|
40
|
+
// eslint-disable-next-line ban/ban
|
|
41
|
+
Object.setPrototypeOf(this, actualProto);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.__proto__ = actualProto;
|
|
45
|
+
}
|
|
46
|
+
this.name = "ZodError";
|
|
47
|
+
this.issues = issues;
|
|
48
|
+
}
|
|
49
|
+
format(_mapper) {
|
|
50
|
+
const mapper = _mapper ||
|
|
51
|
+
function (issue) {
|
|
52
|
+
return issue.message;
|
|
53
|
+
};
|
|
54
|
+
const fieldErrors = { _errors: [] };
|
|
55
|
+
const processError = (error) => {
|
|
56
|
+
for (const issue of error.issues) {
|
|
57
|
+
if (issue.code === "invalid_union") {
|
|
58
|
+
issue.unionErrors.map(processError);
|
|
59
|
+
}
|
|
60
|
+
else if (issue.code === "invalid_return_type") {
|
|
61
|
+
processError(issue.returnTypeError);
|
|
62
|
+
}
|
|
63
|
+
else if (issue.code === "invalid_arguments") {
|
|
64
|
+
processError(issue.argumentsError);
|
|
65
|
+
}
|
|
66
|
+
else if (issue.path.length === 0) {
|
|
67
|
+
fieldErrors._errors.push(mapper(issue));
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
let curr = fieldErrors;
|
|
71
|
+
let i = 0;
|
|
72
|
+
while (i < issue.path.length) {
|
|
73
|
+
const el = issue.path[i];
|
|
74
|
+
const terminal = i === issue.path.length - 1;
|
|
75
|
+
if (!terminal) {
|
|
76
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
77
|
+
// if (typeof el === "string") {
|
|
78
|
+
// curr[el] = curr[el] || { _errors: [] };
|
|
79
|
+
// } else if (typeof el === "number") {
|
|
80
|
+
// const errorArray: any = [];
|
|
81
|
+
// errorArray._errors = [];
|
|
82
|
+
// curr[el] = curr[el] || errorArray;
|
|
83
|
+
// }
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
87
|
+
curr[el]._errors.push(mapper(issue));
|
|
88
|
+
}
|
|
89
|
+
curr = curr[el];
|
|
90
|
+
i++;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
processError(this);
|
|
96
|
+
return fieldErrors;
|
|
97
|
+
}
|
|
98
|
+
static assert(value) {
|
|
99
|
+
if (!(value instanceof ZodError)) {
|
|
100
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
toString() {
|
|
104
|
+
return this.message;
|
|
105
|
+
}
|
|
106
|
+
get message() {
|
|
107
|
+
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
|
|
108
|
+
}
|
|
109
|
+
get isEmpty() {
|
|
110
|
+
return this.issues.length === 0;
|
|
111
|
+
}
|
|
112
|
+
flatten(mapper = (issue) => issue.message) {
|
|
113
|
+
const fieldErrors = {};
|
|
114
|
+
const formErrors = [];
|
|
115
|
+
for (const sub of this.issues) {
|
|
116
|
+
if (sub.path.length > 0) {
|
|
117
|
+
const firstEl = sub.path[0];
|
|
118
|
+
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
119
|
+
fieldErrors[firstEl].push(mapper(sub));
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
formErrors.push(mapper(sub));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return { formErrors, fieldErrors };
|
|
126
|
+
}
|
|
127
|
+
get formErrors() {
|
|
128
|
+
return this.flatten();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
ZodError.create = (issues) => {
|
|
132
|
+
const error = new ZodError(issues);
|
|
133
|
+
return error;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export { ZodError, ZodIssueCode, quotelessJson };
|
|
137
|
+
//# sourceMappingURL=ZodError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZodError.js","sources":["../../../../../../node_modules/zod/v3/ZodError.js"],"sourcesContent":["import { util } from \"./helpers/util.js\";\nexport const ZodIssueCode = util.arrayToEnum([\n \"invalid_type\",\n \"invalid_literal\",\n \"custom\",\n \"invalid_union\",\n \"invalid_union_discriminator\",\n \"invalid_enum_value\",\n \"unrecognized_keys\",\n \"invalid_arguments\",\n \"invalid_return_type\",\n \"invalid_date\",\n \"invalid_string\",\n \"too_small\",\n \"too_big\",\n \"invalid_intersection_types\",\n \"not_multiple_of\",\n \"not_finite\",\n]);\nexport const quotelessJson = (obj) => {\n const json = JSON.stringify(obj, null, 2);\n return json.replace(/\"([^\"]+)\":/g, \"$1:\");\n};\nexport class ZodError extends Error {\n get errors() {\n return this.issues;\n }\n constructor(issues) {\n super();\n this.issues = [];\n this.addIssue = (sub) => {\n this.issues = [...this.issues, sub];\n };\n this.addIssues = (subs = []) => {\n this.issues = [...this.issues, ...subs];\n };\n const actualProto = new.target.prototype;\n if (Object.setPrototypeOf) {\n // eslint-disable-next-line ban/ban\n Object.setPrototypeOf(this, actualProto);\n }\n else {\n this.__proto__ = actualProto;\n }\n this.name = \"ZodError\";\n this.issues = issues;\n }\n format(_mapper) {\n const mapper = _mapper ||\n function (issue) {\n return issue.message;\n };\n const fieldErrors = { _errors: [] };\n const processError = (error) => {\n for (const issue of error.issues) {\n if (issue.code === \"invalid_union\") {\n issue.unionErrors.map(processError);\n }\n else if (issue.code === \"invalid_return_type\") {\n processError(issue.returnTypeError);\n }\n else if (issue.code === \"invalid_arguments\") {\n processError(issue.argumentsError);\n }\n else if (issue.path.length === 0) {\n fieldErrors._errors.push(mapper(issue));\n }\n else {\n let curr = fieldErrors;\n let i = 0;\n while (i < issue.path.length) {\n const el = issue.path[i];\n const terminal = i === issue.path.length - 1;\n if (!terminal) {\n curr[el] = curr[el] || { _errors: [] };\n // if (typeof el === \"string\") {\n // curr[el] = curr[el] || { _errors: [] };\n // } else if (typeof el === \"number\") {\n // const errorArray: any = [];\n // errorArray._errors = [];\n // curr[el] = curr[el] || errorArray;\n // }\n }\n else {\n curr[el] = curr[el] || { _errors: [] };\n curr[el]._errors.push(mapper(issue));\n }\n curr = curr[el];\n i++;\n }\n }\n }\n };\n processError(this);\n return fieldErrors;\n }\n static assert(value) {\n if (!(value instanceof ZodError)) {\n throw new Error(`Not a ZodError: ${value}`);\n }\n }\n toString() {\n return this.message;\n }\n get message() {\n return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);\n }\n get isEmpty() {\n return this.issues.length === 0;\n }\n flatten(mapper = (issue) => issue.message) {\n const fieldErrors = {};\n const formErrors = [];\n for (const sub of this.issues) {\n if (sub.path.length > 0) {\n const firstEl = sub.path[0];\n fieldErrors[firstEl] = fieldErrors[firstEl] || [];\n fieldErrors[firstEl].push(mapper(sub));\n }\n else {\n formErrors.push(mapper(sub));\n }\n }\n return { formErrors, fieldErrors };\n }\n get formErrors() {\n return this.flatten();\n }\n}\nZodError.create = (issues) => {\n const error = new ZodError(issues);\n return error;\n};\n"],"names":[],"mappings":";;AACY,MAAC,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC;AAC7C,IAAI,cAAc;AAClB,IAAI,iBAAiB;AACrB,IAAI,QAAQ;AACZ,IAAI,eAAe;AACnB,IAAI,6BAA6B;AACjC,IAAI,oBAAoB;AACxB,IAAI,mBAAmB;AACvB,IAAI,mBAAmB;AACvB,IAAI,qBAAqB;AACzB,IAAI,cAAc;AAClB,IAAI,gBAAgB;AACpB,IAAI,WAAW;AACf,IAAI,SAAS;AACb,IAAI,4BAA4B;AAChC,IAAI,iBAAiB;AACrB,IAAI,YAAY;AAChB,CAAC;AACW,MAAC,aAAa,GAAG,CAAC,GAAG,KAAK;AACtC,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7C,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC;AAC7C;AACO,MAAM,QAAQ,SAAS,KAAK,CAAC;AACpC,IAAI,IAAI,MAAM,GAAG;AACjB,QAAQ,OAAO,IAAI,CAAC,MAAM;AAC1B,IAAI;AACJ,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,QAAQ,KAAK,EAAE;AACf,QAAQ,IAAI,CAAC,MAAM,GAAG,EAAE;AACxB,QAAQ,IAAI,CAAC,QAA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AU,EAAE,WAAW,EAAE;AAC1C,IAAI;AACJ,IAAI,IAAI,UAAU,GAAG;AACrB,QAAQ,OAAO,IAAI,CAAC,OAAO,EAAE;AAC7B,IAAI;AACJ;AACA,QAAQ,CAAC,MAAM,GAAG,CAAC,MAAM,KAAK;AAC9B,IAAI,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC;AACtC,IAAI,OAAO,KAAK;AAChB,CAAC;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import errorMap from './locales/en.js';
|
|
2
|
+
|
|
3
|
+
let overrideErrorMap = errorMap;
|
|
4
|
+
function setErrorMap(map) {
|
|
5
|
+
overrideErrorMap = map;
|
|
6
|
+
}
|
|
7
|
+
function getErrorMap() {
|
|
8
|
+
return overrideErrorMap;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { errorMap as defaultErrorMap, getErrorMap, setErrorMap };
|
|
12
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sources":["../../../../../../node_modules/zod/v3/errors.js"],"sourcesContent":["import defaultErrorMap from \"./locales/en.js\";\nlet overrideErrorMap = defaultErrorMap;\nexport { defaultErrorMap };\nexport function setErrorMap(map) {\n overrideErrorMap = map;\n}\nexport function getErrorMap() {\n return overrideErrorMap;\n}\n"],"names":["defaultErrorMap"],"mappings":";;AACA,IAAI,gBAAgB,GAAGA,QAAe;AAE/B,SAAS,WAAW,CAAC,GAAG,EAAE;AACjC,IAAI,gBAAgB,GAAG,GAAG;AAC1B;AACO,SAAS,WAAW,GAAG;AAC9B,IAAI,OAAO,gBAAgB;AAC3B;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { getErrorMap, setErrorMap } from './errors.js';
|
|
2
|
+
export { DIRTY, EMPTY_PATH, INVALID, OK, ParseStatus, addIssueToContext, isAborted, isAsync, isDirty, isValid, makeIssue } from './helpers/parseUtil.js';
|
|
3
|
+
export { ZodParsedType, getParsedType, objectUtil, util } from './helpers/util.js';
|
|
4
|
+
export { BRAND, NEVER, ZodType as Schema, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEnum, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodPipeline, ZodPromise, ZodReadonly, ZodRecord, ZodType as ZodSchema, ZodSet, ZodString, ZodSymbol, ZodEffects as ZodTransformer, ZodTuple, ZodType, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, any, array, bigint, boolean, coerce, custom, date, datetimeRegex, discriminatedUnion, effect, enum, function, instanceof, intersection, late, lazy, literal, map, nan, nativeEnum, never, null, nullable, number, object, oboolean, onumber, optional, ostring, pipeline, preprocess, promise, record, set, strictObject, string, symbol, effect as transformer, tuple, undefined, union, unknown, void } from './types.js';
|
|
5
|
+
export { ZodError, ZodIssueCode, quotelessJson } from './ZodError.js';
|
|
6
|
+
export { default as defaultErrorMap } from './locales/en.js';
|
|
7
|
+
//# sourceMappingURL=external.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var errorUtil;
|
|
2
|
+
(function (errorUtil) {
|
|
3
|
+
errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
4
|
+
// biome-ignore lint:
|
|
5
|
+
errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
6
|
+
})(errorUtil || (errorUtil = {}));
|
|
7
|
+
|
|
8
|
+
export { errorUtil };
|
|
9
|
+
//# sourceMappingURL=errorUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorUtil.js","sources":["../../../../../../../node_modules/zod/v3/helpers/errorUtil.js"],"sourcesContent":["export var errorUtil;\n(function (errorUtil) {\n errorUtil.errToObj = (message) => typeof message === \"string\" ? { message } : message || {};\n // biome-ignore lint:\n errorUtil.toString = (message) => typeof message === \"string\" ? message : message?.message;\n})(errorUtil || (errorUtil = {}));\n"],"names":[],"mappings":"AAAU,IAAC;AACX,CAAC,UAAU,SAAS,EAAE;AACtB,IAAI,SAAS,CAAC,QAAQ,GAAG,CAAC,OAAO,KAAK,OAAO,OAAO,KAAK,QAAQ,GAAG,EAAE,OAAO,EAAE,GAAG,OAAO,IAAI,EAAE;AAC/F;AACA,IAAI,SAAS,CAAC,QAAQ,GAAG,CAAC,OAAO,KAAK,OAAO,OAAO,KAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,EAAE,OAAO;AAC9F,CAAC,EAAE,SAAS,KAAK,SAAS,GAAG,EAAE,CAAC,CAAC;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { getErrorMap } from '../errors.js';
|
|
2
|
+
import errorMap from '../locales/en.js';
|
|
3
|
+
|
|
4
|
+
const makeIssue = (params) => {
|
|
5
|
+
const { data, path, errorMaps, issueData } = params;
|
|
6
|
+
const fullPath = [...path, ...(issueData.path || [])];
|
|
7
|
+
const fullIssue = {
|
|
8
|
+
...issueData,
|
|
9
|
+
path: fullPath,
|
|
10
|
+
};
|
|
11
|
+
if (issueData.message !== undefined) {
|
|
12
|
+
return {
|
|
13
|
+
...issueData,
|
|
14
|
+
path: fullPath,
|
|
15
|
+
message: issueData.message,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
let errorMessage = "";
|
|
19
|
+
const maps = errorMaps
|
|
20
|
+
.filter((m) => !!m)
|
|
21
|
+
.slice()
|
|
22
|
+
.reverse();
|
|
23
|
+
for (const map of maps) {
|
|
24
|
+
errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
...issueData,
|
|
28
|
+
path: fullPath,
|
|
29
|
+
message: errorMessage,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const EMPTY_PATH = [];
|
|
33
|
+
function addIssueToContext(ctx, issueData) {
|
|
34
|
+
const overrideMap = getErrorMap();
|
|
35
|
+
const issue = makeIssue({
|
|
36
|
+
issueData: issueData,
|
|
37
|
+
data: ctx.data,
|
|
38
|
+
path: ctx.path,
|
|
39
|
+
errorMaps: [
|
|
40
|
+
ctx.common.contextualErrorMap, // contextual error map is first priority
|
|
41
|
+
ctx.schemaErrorMap, // then schema-bound map if available
|
|
42
|
+
overrideMap, // then global override map
|
|
43
|
+
overrideMap === errorMap ? undefined : errorMap, // then global default map
|
|
44
|
+
].filter((x) => !!x),
|
|
45
|
+
});
|
|
46
|
+
ctx.common.issues.push(issue);
|
|
47
|
+
}
|
|
48
|
+
class ParseStatus {
|
|
49
|
+
constructor() {
|
|
50
|
+
this.value = "valid";
|
|
51
|
+
}
|
|
52
|
+
dirty() {
|
|
53
|
+
if (this.value === "valid")
|
|
54
|
+
this.value = "dirty";
|
|
55
|
+
}
|
|
56
|
+
abort() {
|
|
57
|
+
if (this.value !== "aborted")
|
|
58
|
+
this.value = "aborted";
|
|
59
|
+
}
|
|
60
|
+
static mergeArray(status, results) {
|
|
61
|
+
const arrayValue = [];
|
|
62
|
+
for (const s of results) {
|
|
63
|
+
if (s.status === "aborted")
|
|
64
|
+
return INVALID;
|
|
65
|
+
if (s.status === "dirty")
|
|
66
|
+
status.dirty();
|
|
67
|
+
arrayValue.push(s.value);
|
|
68
|
+
}
|
|
69
|
+
return { status: status.value, value: arrayValue };
|
|
70
|
+
}
|
|
71
|
+
static async mergeObjectAsync(status, pairs) {
|
|
72
|
+
const syncPairs = [];
|
|
73
|
+
for (const pair of pairs) {
|
|
74
|
+
const key = await pair.key;
|
|
75
|
+
const value = await pair.value;
|
|
76
|
+
syncPairs.push({
|
|
77
|
+
key,
|
|
78
|
+
value,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return ParseStatus.mergeObjectSync(status, syncPairs);
|
|
82
|
+
}
|
|
83
|
+
static mergeObjectSync(status, pairs) {
|
|
84
|
+
const finalObject = {};
|
|
85
|
+
for (const pair of pairs) {
|
|
86
|
+
const { key, value } = pair;
|
|
87
|
+
if (key.status === "aborted")
|
|
88
|
+
return INVALID;
|
|
89
|
+
if (value.status === "aborted")
|
|
90
|
+
return INVALID;
|
|
91
|
+
if (key.status === "dirty")
|
|
92
|
+
status.dirty();
|
|
93
|
+
if (value.status === "dirty")
|
|
94
|
+
status.dirty();
|
|
95
|
+
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
96
|
+
finalObject[key.value] = value.value;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return { status: status.value, value: finalObject };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const INVALID = Object.freeze({
|
|
103
|
+
status: "aborted",
|
|
104
|
+
});
|
|
105
|
+
const DIRTY = (value) => ({ status: "dirty", value });
|
|
106
|
+
const OK = (value) => ({ status: "valid", value });
|
|
107
|
+
const isAborted = (x) => x.status === "aborted";
|
|
108
|
+
const isDirty = (x) => x.status === "dirty";
|
|
109
|
+
const isValid = (x) => x.status === "valid";
|
|
110
|
+
const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
111
|
+
|
|
112
|
+
export { DIRTY, EMPTY_PATH, INVALID, OK, ParseStatus, addIssueToContext, isAborted, isAsync, isDirty, isValid, makeIssue };
|
|
113
|
+
//# sourceMappingURL=parseUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseUtil.js","sources":["../../../../../../../node_modules/zod/v3/helpers/parseUtil.js"],"sourcesContent":["import { getErrorMap } from \"../errors.js\";\nimport defaultErrorMap from \"../locales/en.js\";\nexport const makeIssue = (params) => {\n const { data, path, errorMaps, issueData } = params;\n const fullPath = [...path, ...(issueData.path || [])];\n const fullIssue = {\n ...issueData,\n path: fullPath,\n };\n if (issueData.message !== undefined) {\n return {\n ...issueData,\n path: fullPath,\n message: issueData.message,\n };\n }\n let errorMessage = \"\";\n const maps = errorMaps\n .filter((m) => !!m)\n .slice()\n .reverse();\n for (const map of maps) {\n errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;\n }\n return {\n ...issueData,\n path: fullPath,\n message: errorMessage,\n };\n};\nexport const EMPTY_PATH = [];\nexport function addIssueToContext(ctx, issueData) {\n const overrideMap = getErrorMap();\n const issue = makeIssue({\n issueData: issueData,\n data: ctx.data,\n path: ctx.path,\n errorMaps: [\n ctx.common.contextualErrorMap, // contextual error map is first priority\n ctx.schemaErrorMap, // then schema-bound map if available\n overrideMap, // then global override map\n overrideMap === defaultErrorMap ? undefined : defaultErrorMap, // then global default map\n ].filter((x) => !!x),\n });\n ctx.common.issues.push(issue);\n}\nexport class ParseStatus {\n constructor() {\n this.value = \"valid\";\n }\n dirty() {\n if (this.value === \"valid\")\n this.value = \"dirty\";\n }\n abort() {\n if (this.value !== \"aborted\")\n this.value = \"aborted\";\n }\n static mergeArray(status, results) {\n const arrayValue = [];\n for (const s of results) {\n if (s.status === \"aborted\")\n return INVALID;\n if (s.status === \"dirty\")\n status.dirty();\n arrayValue.push(s.value);\n }\n return { status: status.value, value: arrayValue };\n }\n static async mergeObjectAsync(status, pairs) {\n const syncPairs = [];\n for (const pair of pairs) {\n const key = await pair.key;\n const value = await pair.value;\n syncPairs.push({\n key,\n value,\n });\n }\n return ParseStatus.mergeObjectSync(status, syncPairs);\n }\n static mergeObjectSync(status, pairs) {\n const finalObject = {};\n for (const pair of pairs) {\n const { key, value } = pair;\n if (key.status === \"aborted\")\n return INVALID;\n if (value.status === \"aborted\")\n return INVALID;\n if (key.status === \"dirty\")\n status.dirty();\n if (value.status === \"dirty\")\n status.dirty();\n if (key.value !== \"__proto__\" && (typeof value.value !== \"undefined\" || pair.alwaysSet)) {\n finalObject[key.value] = value.value;\n }\n }\n return { status: status.value, value: finalObject };\n }\n}\nexport const INVALID = Object.freeze({\n status: \"aborted\",\n});\nexport const DIRTY = (value) => ({ status: \"dirty\", value });\nexport const OK = (value) => ({ status: \"valid\", value });\nexport const isAborted = (x) => x.status === \"aborted\";\nexport const isDirty = (x) => x.status === \"dirty\";\nexport const isValid = (x) => x.status === \"valid\";\nexport const isAsync = (x) => typeof Promise !== \"undefined\" && x instanceof Promise;\n"],"names":["defaultErrorMap"],"mappings":";;;AAEY,MAAC,SAAS,GAAG,CAAC,MAAM,KAAK;AACrC,IAAI,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,MAAM;AACvD,IAAI,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,EAAE,IAAI,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;AACzD,IAAI,MAAM,SAAS,GAAG;AACtB,QAAQ,GAAG,SAAS;AACpB,QAAQ,IAAI,EAAE,QAAQ;AACtB,KAAK;AACL,IAAI,IAAI,SAAS,CAAC,OAAO,KAAK,SAAS,EAAE;AACzC,QAAQ,OAAO;AACf,YAAY,GAAG,SAAS;AACxB,YAAY,IAAI,EAAE,QAAQ;AAC1B,YAAY,OAAO,EAAE,SAAS,CAAC,OAAO;AACtC,SAAS;AACT,IAAI;AACJ,IAAI,IAAI,YAAY,GAAG,EAAE;AACzB,IAAI,MAAM,IAAI,GAAG;AACjB,SAAS,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1B,SAAS,KAAK;AACd,SAAS,OAAO,EAAE;AAClB,IAAI,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;AAC5B,QAAQ,YAAY,GAAG,GAAG,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,CAAC,OAAO;AACnF,IAAI;AACJ,IAAI,OAAO;AACX,Q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K,CAAC,MAAM,KAAK,OAAO;AACxC,gBAAgB,MAAM,CAAC,KAAK,EAAE;AAC9B,YAAY,IAAI,GAAG,CAAC,KAAK,KAAK,WAAW,KAAK,OAAO,KAAK,CAAC,KAAK,KAAK,WAAW,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE;AACrG,gBAAgB,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK;AACpD,YAAY;AACZ,QAAQ;AACR,QAAQ,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE;AAC3D,IAAI;AACJ;AACY,MAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;AACrC,IAAI,MAAM,EAAE,SAAS;AACrB,CAAC;AACW,MAAC,KAAK,GAAG,CAAC,KAAK,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE;AAC/C,MAAC,EAAE,GAAG,CAAC,KAAK,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE;AAC5C,MAAC,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK;AACjC,MAAC,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK;AAC/B,MAAC,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK;AAC/B,MAAC,OAAO,GAAG,CAAC,CAAC,KAAK,OAAO,OAAO,KAAK,WAAW,IAAI,CAAC,YAAY;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
var util;
|
|
2
|
+
(function (util) {
|
|
3
|
+
util.assertEqual = (_) => { };
|
|
4
|
+
function assertIs(_arg) { }
|
|
5
|
+
util.assertIs = assertIs;
|
|
6
|
+
function assertNever(_x) {
|
|
7
|
+
throw new Error();
|
|
8
|
+
}
|
|
9
|
+
util.assertNever = assertNever;
|
|
10
|
+
util.arrayToEnum = (items) => {
|
|
11
|
+
const obj = {};
|
|
12
|
+
for (const item of items) {
|
|
13
|
+
obj[item] = item;
|
|
14
|
+
}
|
|
15
|
+
return obj;
|
|
16
|
+
};
|
|
17
|
+
util.getValidEnumValues = (obj) => {
|
|
18
|
+
const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
19
|
+
const filtered = {};
|
|
20
|
+
for (const k of validKeys) {
|
|
21
|
+
filtered[k] = obj[k];
|
|
22
|
+
}
|
|
23
|
+
return util.objectValues(filtered);
|
|
24
|
+
};
|
|
25
|
+
util.objectValues = (obj) => {
|
|
26
|
+
return util.objectKeys(obj).map(function (e) {
|
|
27
|
+
return obj[e];
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
|
|
31
|
+
? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
|
|
32
|
+
: (object) => {
|
|
33
|
+
const keys = [];
|
|
34
|
+
for (const key in object) {
|
|
35
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
36
|
+
keys.push(key);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return keys;
|
|
40
|
+
};
|
|
41
|
+
util.find = (arr, checker) => {
|
|
42
|
+
for (const item of arr) {
|
|
43
|
+
if (checker(item))
|
|
44
|
+
return item;
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
};
|
|
48
|
+
util.isInteger = typeof Number.isInteger === "function"
|
|
49
|
+
? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
|
|
50
|
+
: (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
51
|
+
function joinValues(array, separator = " | ") {
|
|
52
|
+
return array.map((val) => (typeof val === "string" ? `'${val}'` : val)).join(separator);
|
|
53
|
+
}
|
|
54
|
+
util.joinValues = joinValues;
|
|
55
|
+
util.jsonStringifyReplacer = (_, value) => {
|
|
56
|
+
if (typeof value === "bigint") {
|
|
57
|
+
return value.toString();
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
};
|
|
61
|
+
})(util || (util = {}));
|
|
62
|
+
var objectUtil;
|
|
63
|
+
(function (objectUtil) {
|
|
64
|
+
objectUtil.mergeShapes = (first, second) => {
|
|
65
|
+
return {
|
|
66
|
+
...first,
|
|
67
|
+
...second, // second overwrites first
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
})(objectUtil || (objectUtil = {}));
|
|
71
|
+
const ZodParsedType = util.arrayToEnum([
|
|
72
|
+
"string",
|
|
73
|
+
"nan",
|
|
74
|
+
"number",
|
|
75
|
+
"integer",
|
|
76
|
+
"float",
|
|
77
|
+
"boolean",
|
|
78
|
+
"date",
|
|
79
|
+
"bigint",
|
|
80
|
+
"symbol",
|
|
81
|
+
"function",
|
|
82
|
+
"undefined",
|
|
83
|
+
"null",
|
|
84
|
+
"array",
|
|
85
|
+
"object",
|
|
86
|
+
"unknown",
|
|
87
|
+
"promise",
|
|
88
|
+
"void",
|
|
89
|
+
"never",
|
|
90
|
+
"map",
|
|
91
|
+
"set",
|
|
92
|
+
]);
|
|
93
|
+
const getParsedType = (data) => {
|
|
94
|
+
const t = typeof data;
|
|
95
|
+
switch (t) {
|
|
96
|
+
case "undefined":
|
|
97
|
+
return ZodParsedType.undefined;
|
|
98
|
+
case "string":
|
|
99
|
+
return ZodParsedType.string;
|
|
100
|
+
case "number":
|
|
101
|
+
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
102
|
+
case "boolean":
|
|
103
|
+
return ZodParsedType.boolean;
|
|
104
|
+
case "function":
|
|
105
|
+
return ZodParsedType.function;
|
|
106
|
+
case "bigint":
|
|
107
|
+
return ZodParsedType.bigint;
|
|
108
|
+
case "symbol":
|
|
109
|
+
return ZodParsedType.symbol;
|
|
110
|
+
case "object":
|
|
111
|
+
if (Array.isArray(data)) {
|
|
112
|
+
return ZodParsedType.array;
|
|
113
|
+
}
|
|
114
|
+
if (data === null) {
|
|
115
|
+
return ZodParsedType.null;
|
|
116
|
+
}
|
|
117
|
+
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
|
118
|
+
return ZodParsedType.promise;
|
|
119
|
+
}
|
|
120
|
+
if (typeof Map !== "undefined" && data instanceof Map) {
|
|
121
|
+
return ZodParsedType.map;
|
|
122
|
+
}
|
|
123
|
+
if (typeof Set !== "undefined" && data instanceof Set) {
|
|
124
|
+
return ZodParsedType.set;
|
|
125
|
+
}
|
|
126
|
+
if (typeof Date !== "undefined" && data instanceof Date) {
|
|
127
|
+
return ZodParsedType.date;
|
|
128
|
+
}
|
|
129
|
+
return ZodParsedType.object;
|
|
130
|
+
default:
|
|
131
|
+
return ZodParsedType.unknown;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export { ZodParsedType, getParsedType, objectUtil, util };
|
|
136
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sources":["../../../../../../../node_modules/zod/v3/helpers/util.js"],"sourcesContent":["export var util;\n(function (util) {\n util.assertEqual = (_) => { };\n function assertIs(_arg) { }\n util.assertIs = assertIs;\n function assertNever(_x) {\n throw new Error();\n }\n util.assertNever = assertNever;\n util.arrayToEnum = (items) => {\n const obj = {};\n for (const item of items) {\n obj[item] = item;\n }\n return obj;\n };\n util.getValidEnumValues = (obj) => {\n const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== \"number\");\n const filtered = {};\n for (const k of validKeys) {\n filtered[k] = obj[k];\n }\n return util.objectValues(filtered);\n };\n util.objectValues = (obj) => {\n return util.objectKeys(obj).map(function (e) {\n return obj[e];\n });\n };\n util.objectKeys = typeof Object.keys === \"function\" // eslint-disable-line ban/ban\n ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban\n : (object) => {\n const keys = [];\n for (const key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n keys.push(key);\n }\n }\n return keys;\n };\n util.find = (arr, checker) => {\n for (const item of arr) {\n if (checker(item))\n return item;\n }\n return undefined;\n };\n util.isInteger = typeof Number.isInteger === \"function\"\n ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban\n : (val) => typeof val === \"number\" && Number.isFinite(val) && Math.floor(val) === val;\n function joinValues(array, separator = \" | \") {\n return array.map((val) => (typeof val === \"string\" ? `'${val}'` : val)).join(separator);\n }\n util.joinValues = joinValues;\n util.jsonStringifyReplacer = (_, value) => {\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n return value;\n };\n})(util || (util = {}));\nexport var objectUtil;\n(function (objectUtil) {\n objectUtil.mergeShapes = (first, second) => {\n return {\n ...first,\n ...second, // second overwrites first\n };\n };\n})(objectUtil || (objectUtil = {}));\nexport const ZodParsedType = util.arrayToEnum([\n \"string\",\n \"nan\",\n \"number\",\n \"integer\",\n \"float\",\n \"boolean\",\n \"date\",\n \"bigint\",\n \"symbol\",\n \"function\",\n \"undefined\",\n \"null\",\n \"array\",\n \"object\",\n \"unknown\",\n \"promise\",\n \"void\",\n \"never\",\n \"map\",\n \"set\",\n]);\nexport const getParsedType = (data) => {\n const t = typeof data;\n switch (t) {\n case \"undefined\":\n return ZodParsedType.undefined;\n case \"string\":\n return ZodParsedType.string;\n case \"number\":\n return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;\n case \"boolean\":\n return ZodParsedType.boolean;\n case \"function\":\n return ZodParsedType.function;\n case \"bigint\":\n return ZodParsedType.bigint;\n case \"symbol\":\n return ZodParsedType.symbol;\n case \"object\":\n if (Array.isArray(data)) {\n return ZodParsedType.array;\n }\n if (data === null) {\n return ZodParsedType.null;\n }\n if (data.then && typeof data.then === \"function\" && data.catch && typeof data.catch === \"function\") {\n return ZodParsedType.promise;\n }\n if (typeof Map !== \"undefined\" && data instanceof Map) {\n return ZodParsedType.map;\n }\n if (typeof Set !== \"undefined\" && data instanceof Set) {\n return ZodParsedType.set;\n }\n if (typeof Date !== \"undefined\" &&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