@logto/connector-github 1.0.0-beta.8 → 1.0.0-beta.9
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/LICENSE +21 -373
- package/lib/index.js +1056 -546
- package/package.json +6 -6
package/lib/index.js
CHANGED
|
@@ -1,6 +1,109 @@
|
|
|
1
1
|
/******/ (() => { // webpackBootstrap
|
|
2
2
|
/******/ var __webpack_modules__ = ({
|
|
3
3
|
|
|
4
|
+
/***/ 8697:
|
|
5
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
24
|
+
exports.parseJson = exports.validateConfig = void 0;
|
|
25
|
+
const types_1 = __nccwpck_require__(444);
|
|
26
|
+
__exportStar(__nccwpck_require__(444), exports);
|
|
27
|
+
function validateConfig(config, guard) {
|
|
28
|
+
const result = guard.safeParse(config);
|
|
29
|
+
if (!result.success) {
|
|
30
|
+
throw new types_1.ConnectorError(types_1.ConnectorErrorCodes.InvalidConfig, result.error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.validateConfig = validateConfig;
|
|
34
|
+
const parseJson = (jsonString, errorCode = types_1.ConnectorErrorCodes.InvalidResponse, errorPayload) => {
|
|
35
|
+
try {
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
37
|
+
return JSON.parse(jsonString);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
throw new types_1.ConnectorError(errorCode, errorPayload ?? jsonString);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.parseJson = parseJson;
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/***/ }),
|
|
47
|
+
|
|
48
|
+
/***/ 444:
|
|
49
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
50
|
+
|
|
51
|
+
"use strict";
|
|
52
|
+
|
|
53
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
54
|
+
exports.messageTypesGuard = exports.MessageTypes = exports.ConnectorError = exports.ConnectorErrorCodes = exports.ConnectorPlatform = exports.ConnectorType = void 0;
|
|
55
|
+
const zod_1 = __nccwpck_require__(8062);
|
|
56
|
+
// MARK: Foundation
|
|
57
|
+
var ConnectorType;
|
|
58
|
+
(function (ConnectorType) {
|
|
59
|
+
ConnectorType["Email"] = "Email";
|
|
60
|
+
ConnectorType["Sms"] = "Sms";
|
|
61
|
+
ConnectorType["Social"] = "Social";
|
|
62
|
+
})(ConnectorType = exports.ConnectorType || (exports.ConnectorType = {}));
|
|
63
|
+
var ConnectorPlatform;
|
|
64
|
+
(function (ConnectorPlatform) {
|
|
65
|
+
ConnectorPlatform["Native"] = "Native";
|
|
66
|
+
ConnectorPlatform["Universal"] = "Universal";
|
|
67
|
+
ConnectorPlatform["Web"] = "Web";
|
|
68
|
+
})(ConnectorPlatform = exports.ConnectorPlatform || (exports.ConnectorPlatform = {}));
|
|
69
|
+
var ConnectorErrorCodes;
|
|
70
|
+
(function (ConnectorErrorCodes) {
|
|
71
|
+
ConnectorErrorCodes["General"] = "general";
|
|
72
|
+
ConnectorErrorCodes["InvalidMetadata"] = "invalid_metadata";
|
|
73
|
+
ConnectorErrorCodes["UnexpectedType"] = "unexpected_type";
|
|
74
|
+
ConnectorErrorCodes["InvalidConfigGuard"] = "invalid_config_guard";
|
|
75
|
+
ConnectorErrorCodes["InvalidRequestParameters"] = "invalid_request_parameters";
|
|
76
|
+
ConnectorErrorCodes["InsufficientRequestParameters"] = "insufficient_request_parameters";
|
|
77
|
+
ConnectorErrorCodes["InvalidConfig"] = "invalid_config";
|
|
78
|
+
ConnectorErrorCodes["InvalidResponse"] = "invalid_response";
|
|
79
|
+
ConnectorErrorCodes["TemplateNotFound"] = "template_not_found";
|
|
80
|
+
ConnectorErrorCodes["NotImplemented"] = "not_implemented";
|
|
81
|
+
ConnectorErrorCodes["SocialAuthCodeInvalid"] = "social_auth_code_invalid";
|
|
82
|
+
ConnectorErrorCodes["SocialAccessTokenInvalid"] = "social_invalid_access_token";
|
|
83
|
+
ConnectorErrorCodes["SocialIdTokenInvalid"] = "social_invalid_id_token";
|
|
84
|
+
ConnectorErrorCodes["AuthorizationFailed"] = "authorization_failed";
|
|
85
|
+
})(ConnectorErrorCodes = exports.ConnectorErrorCodes || (exports.ConnectorErrorCodes = {}));
|
|
86
|
+
class ConnectorError extends Error {
|
|
87
|
+
constructor(code, data) {
|
|
88
|
+
const message = typeof data === 'string' ? data : 'Connector error occurred.';
|
|
89
|
+
super(message);
|
|
90
|
+
this.code = code;
|
|
91
|
+
this.data = typeof data === 'string' ? { message: data } : data;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.ConnectorError = ConnectorError;
|
|
95
|
+
var MessageTypes;
|
|
96
|
+
(function (MessageTypes) {
|
|
97
|
+
MessageTypes["SignIn"] = "SignIn";
|
|
98
|
+
MessageTypes["Register"] = "Register";
|
|
99
|
+
MessageTypes["ForgotPassword"] = "ForgotPassword";
|
|
100
|
+
MessageTypes["Test"] = "Test";
|
|
101
|
+
})(MessageTypes = exports.MessageTypes || (exports.MessageTypes = {}));
|
|
102
|
+
exports.messageTypesGuard = zod_1.z.nativeEnum(MessageTypes);
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
/***/ }),
|
|
106
|
+
|
|
4
107
|
/***/ 8138:
|
|
5
108
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
6
109
|
|
|
@@ -283,7 +386,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
283
386
|
|
|
284
387
|
/***/ }),
|
|
285
388
|
|
|
286
|
-
/***/
|
|
389
|
+
/***/ 5173:
|
|
287
390
|
/***/ ((module, exports) => {
|
|
288
391
|
|
|
289
392
|
"use strict";
|
|
@@ -318,6 +421,7 @@ const objectTypeNames = [
|
|
|
318
421
|
'Observable',
|
|
319
422
|
'Array',
|
|
320
423
|
'Buffer',
|
|
424
|
+
'Blob',
|
|
321
425
|
'Object',
|
|
322
426
|
'RegExp',
|
|
323
427
|
'Date',
|
|
@@ -428,11 +532,12 @@ is.array = (value, assertion) => {
|
|
|
428
532
|
return value.every(assertion);
|
|
429
533
|
};
|
|
430
534
|
is.buffer = (value) => { var _a, _b, _c, _d; return (_d = (_c = (_b = (_a = value) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.isBuffer) === null || _c === void 0 ? void 0 : _c.call(_b, value)) !== null && _d !== void 0 ? _d : false; };
|
|
535
|
+
is.blob = (value) => isObjectOfType('Blob')(value);
|
|
431
536
|
is.nullOrUndefined = (value) => is.null_(value) || is.undefined(value);
|
|
432
537
|
is.object = (value) => !is.null_(value) && (typeof value === 'object' || is.function_(value));
|
|
433
538
|
is.iterable = (value) => { var _a; return is.function_((_a = value) === null || _a === void 0 ? void 0 : _a[Symbol.iterator]); };
|
|
434
539
|
is.asyncIterable = (value) => { var _a; return is.function_((_a = value) === null || _a === void 0 ? void 0 : _a[Symbol.asyncIterator]); };
|
|
435
|
-
is.generator = (value) => is.iterable(value) && is.function_(value.next) && is.function_(value.throw);
|
|
540
|
+
is.generator = (value) => { var _a, _b; return is.iterable(value) && is.function_((_a = value) === null || _a === void 0 ? void 0 : _a.next) && is.function_((_b = value) === null || _b === void 0 ? void 0 : _b.throw); };
|
|
436
541
|
is.asyncGenerator = (value) => is.asyncIterable(value) && is.function_(value.next) && is.function_(value.throw);
|
|
437
542
|
is.nativePromise = (value) => isObjectOfType('Promise')(value);
|
|
438
543
|
const hasPromiseAPI = (value) => {
|
|
@@ -467,6 +572,7 @@ is.bigUint64Array = isObjectOfType('BigUint64Array');
|
|
|
467
572
|
is.arrayBuffer = isObjectOfType('ArrayBuffer');
|
|
468
573
|
is.sharedArrayBuffer = isObjectOfType('SharedArrayBuffer');
|
|
469
574
|
is.dataView = isObjectOfType('DataView');
|
|
575
|
+
is.enumCase = (value, targetEnum) => Object.values(targetEnum).includes(value);
|
|
470
576
|
is.directInstanceOf = (instance, class_) => Object.getPrototypeOf(instance) === class_.prototype;
|
|
471
577
|
is.urlInstance = (value) => isObjectOfType('URL')(value);
|
|
472
578
|
is.urlString = (value) => {
|
|
@@ -481,7 +587,6 @@ is.urlString = (value) => {
|
|
|
481
587
|
return false;
|
|
482
588
|
}
|
|
483
589
|
};
|
|
484
|
-
// TODO: Use the `not` operator with a type guard here when it's available.
|
|
485
590
|
// Example: `is.truthy = (value: unknown): value is (not false | not 0 | not '' | not undefined | not null) => Boolean(value);`
|
|
486
591
|
is.truthy = (value) => Boolean(value);
|
|
487
592
|
// Example: `is.falsy = (value: unknown): value is (not true | 0 | '' | undefined | null) => Boolean(value);`
|
|
@@ -547,10 +652,12 @@ is.oddInteger = isAbsoluteMod2(1);
|
|
|
547
652
|
is.emptyArray = (value) => is.array(value) && value.length === 0;
|
|
548
653
|
is.nonEmptyArray = (value) => is.array(value) && value.length > 0;
|
|
549
654
|
is.emptyString = (value) => is.string(value) && value.length === 0;
|
|
550
|
-
// TODO: Use `not ''` when the `not` operator is available.
|
|
551
|
-
is.nonEmptyString = (value) => is.string(value) && value.length > 0;
|
|
552
655
|
const isWhiteSpaceString = (value) => is.string(value) && !/\S/.test(value);
|
|
553
656
|
is.emptyStringOrWhitespace = (value) => is.emptyString(value) || isWhiteSpaceString(value);
|
|
657
|
+
// TODO: Use `not ''` when the `not` operator is available.
|
|
658
|
+
is.nonEmptyString = (value) => is.string(value) && value.length > 0;
|
|
659
|
+
// TODO: Use `not ''` when the `not` operator is available.
|
|
660
|
+
is.nonEmptyStringAndNotWhitespace = (value) => is.string(value) && !is.emptyStringOrWhitespace(value);
|
|
554
661
|
is.emptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length === 0;
|
|
555
662
|
// TODO: Use `not` operator here to remove `Map` and `Set` from type guard:
|
|
556
663
|
// - https://github.com/Microsoft/TypeScript/pull/29317
|
|
@@ -609,6 +716,7 @@ exports.assert = {
|
|
|
609
716
|
}
|
|
610
717
|
},
|
|
611
718
|
buffer: (value) => assertType(is.buffer(value), 'Buffer', value),
|
|
719
|
+
blob: (value) => assertType(is.blob(value), 'Blob', value),
|
|
612
720
|
nullOrUndefined: (value) => assertType(is.nullOrUndefined(value), "null or undefined" /* nullOrUndefined */, value),
|
|
613
721
|
object: (value) => assertType(is.object(value), 'Object', value),
|
|
614
722
|
iterable: (value) => assertType(is.iterable(value), "Iterable" /* iterable */, value),
|
|
@@ -644,6 +752,7 @@ exports.assert = {
|
|
|
644
752
|
arrayBuffer: (value) => assertType(is.arrayBuffer(value), 'ArrayBuffer', value),
|
|
645
753
|
sharedArrayBuffer: (value) => assertType(is.sharedArrayBuffer(value), 'SharedArrayBuffer', value),
|
|
646
754
|
dataView: (value) => assertType(is.dataView(value), 'DataView', value),
|
|
755
|
+
enumCase: (value, targetEnum) => assertType(is.enumCase(value, targetEnum), 'EnumCase', value),
|
|
647
756
|
urlInstance: (value) => assertType(is.urlInstance(value), 'URL', value),
|
|
648
757
|
urlString: (value) => assertType(is.urlString(value), "string with a URL" /* urlString */, value),
|
|
649
758
|
truthy: (value) => assertType(is.truthy(value), "truthy" /* truthy */, value),
|
|
@@ -662,8 +771,9 @@ exports.assert = {
|
|
|
662
771
|
emptyArray: (value) => assertType(is.emptyArray(value), "empty array" /* emptyArray */, value),
|
|
663
772
|
nonEmptyArray: (value) => assertType(is.nonEmptyArray(value), "non-empty array" /* nonEmptyArray */, value),
|
|
664
773
|
emptyString: (value) => assertType(is.emptyString(value), "empty string" /* emptyString */, value),
|
|
665
|
-
nonEmptyString: (value) => assertType(is.nonEmptyString(value), "non-empty string" /* nonEmptyString */, value),
|
|
666
774
|
emptyStringOrWhitespace: (value) => assertType(is.emptyStringOrWhitespace(value), "empty string or whitespace" /* emptyStringOrWhitespace */, value),
|
|
775
|
+
nonEmptyString: (value) => assertType(is.nonEmptyString(value), "non-empty string" /* nonEmptyString */, value),
|
|
776
|
+
nonEmptyStringAndNotWhitespace: (value) => assertType(is.nonEmptyStringAndNotWhitespace(value), "non-empty string and not whitespace" /* nonEmptyStringAndNotWhitespace */, value),
|
|
667
777
|
emptyObject: (value) => assertType(is.emptyObject(value), "empty object" /* emptyObject */, value),
|
|
668
778
|
nonEmptyObject: (value) => assertType(is.nonEmptyObject(value), "non-empty object" /* nonEmptyObject */, value),
|
|
669
779
|
emptySet: (value) => assertType(is.emptySet(value), "empty set" /* emptySet */, value),
|
|
@@ -1307,10 +1417,10 @@ const urlLib = __nccwpck_require__(7310);
|
|
|
1307
1417
|
const normalizeUrl = __nccwpck_require__(5299);
|
|
1308
1418
|
const getStream = __nccwpck_require__(5288);
|
|
1309
1419
|
const CachePolicy = __nccwpck_require__(1454);
|
|
1310
|
-
const Response = __nccwpck_require__(
|
|
1420
|
+
const Response = __nccwpck_require__(1534);
|
|
1311
1421
|
const lowercaseKeys = __nccwpck_require__(4162);
|
|
1312
|
-
const cloneResponse = __nccwpck_require__(
|
|
1313
|
-
const Keyv = __nccwpck_require__(
|
|
1422
|
+
const cloneResponse = __nccwpck_require__(895);
|
|
1423
|
+
const Keyv = __nccwpck_require__(787);
|
|
1314
1424
|
|
|
1315
1425
|
class CacheableRequest {
|
|
1316
1426
|
constructor(request, cacheAdapter) {
|
|
@@ -1555,7 +1665,7 @@ module.exports = CacheableRequest;
|
|
|
1555
1665
|
|
|
1556
1666
|
/***/ }),
|
|
1557
1667
|
|
|
1558
|
-
/***/
|
|
1668
|
+
/***/ 895:
|
|
1559
1669
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
1560
1670
|
|
|
1561
1671
|
"use strict";
|
|
@@ -1578,6 +1688,85 @@ const cloneResponse = response => {
|
|
|
1578
1688
|
module.exports = cloneResponse;
|
|
1579
1689
|
|
|
1580
1690
|
|
|
1691
|
+
/***/ }),
|
|
1692
|
+
|
|
1693
|
+
/***/ 2809:
|
|
1694
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
1695
|
+
|
|
1696
|
+
"use strict";
|
|
1697
|
+
|
|
1698
|
+
|
|
1699
|
+
const { promisify } = __nccwpck_require__(3837)
|
|
1700
|
+
const JSONB = __nccwpck_require__(9604)
|
|
1701
|
+
const zlib = __nccwpck_require__(9796)
|
|
1702
|
+
|
|
1703
|
+
const mergeOptions = __nccwpck_require__(113)
|
|
1704
|
+
|
|
1705
|
+
const compress = promisify(zlib.brotliCompress)
|
|
1706
|
+
|
|
1707
|
+
const decompress = promisify(zlib.brotliDecompress)
|
|
1708
|
+
|
|
1709
|
+
const identity = val => val
|
|
1710
|
+
|
|
1711
|
+
const createCompress = ({
|
|
1712
|
+
enable = true,
|
|
1713
|
+
serialize = JSONB.stringify,
|
|
1714
|
+
deserialize = JSONB.parse,
|
|
1715
|
+
compressOptions,
|
|
1716
|
+
decompressOptions
|
|
1717
|
+
} = {}) => {
|
|
1718
|
+
if (!enable) {
|
|
1719
|
+
return { serialize, deserialize, decompress: identity, compress: identity }
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
return {
|
|
1723
|
+
serialize,
|
|
1724
|
+
deserialize,
|
|
1725
|
+
compress: async (data, options = {}) => {
|
|
1726
|
+
if (data === undefined) return data
|
|
1727
|
+
const serializedData = serialize(data)
|
|
1728
|
+
return compress(serializedData, mergeOptions(compressOptions, options))
|
|
1729
|
+
},
|
|
1730
|
+
decompress: async (data, options = {}) => {
|
|
1731
|
+
if (data === undefined) return data
|
|
1732
|
+
return deserialize(
|
|
1733
|
+
await decompress(data, mergeOptions(decompressOptions, options))
|
|
1734
|
+
)
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
module.exports = createCompress
|
|
1740
|
+
module.exports.stringify = JSONB.stringify
|
|
1741
|
+
module.exports.parse = JSONB.parse
|
|
1742
|
+
|
|
1743
|
+
|
|
1744
|
+
/***/ }),
|
|
1745
|
+
|
|
1746
|
+
/***/ 113:
|
|
1747
|
+
/***/ ((module) => {
|
|
1748
|
+
|
|
1749
|
+
"use strict";
|
|
1750
|
+
|
|
1751
|
+
|
|
1752
|
+
module.exports = (defaultOptions = {}, options = {}) => {
|
|
1753
|
+
const params = {
|
|
1754
|
+
...(defaultOptions.params || {}),
|
|
1755
|
+
...(options.params || {})
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
return {
|
|
1759
|
+
...defaultOptions,
|
|
1760
|
+
...options,
|
|
1761
|
+
...(Object.keys(params).length
|
|
1762
|
+
? {
|
|
1763
|
+
params
|
|
1764
|
+
}
|
|
1765
|
+
: {})
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
|
|
1581
1770
|
/***/ }),
|
|
1582
1771
|
|
|
1583
1772
|
/***/ 3014:
|
|
@@ -2057,13 +2246,13 @@ module.exports.MaxBufferError = MaxBufferError;
|
|
|
2057
2246
|
|
|
2058
2247
|
/***/ }),
|
|
2059
2248
|
|
|
2060
|
-
/***/
|
|
2249
|
+
/***/ 1729:
|
|
2061
2250
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
2062
2251
|
|
|
2063
2252
|
"use strict";
|
|
2064
2253
|
|
|
2065
2254
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2066
|
-
const types_1 = __nccwpck_require__(
|
|
2255
|
+
const types_1 = __nccwpck_require__(2580);
|
|
2067
2256
|
function createRejection(error, ...beforeErrorGroups) {
|
|
2068
2257
|
const promise = (async () => {
|
|
2069
2258
|
if (error instanceof types_1.RequestError) {
|
|
@@ -2095,7 +2284,7 @@ exports["default"] = createRejection;
|
|
|
2095
2284
|
|
|
2096
2285
|
/***/ }),
|
|
2097
2286
|
|
|
2098
|
-
/***/
|
|
2287
|
+
/***/ 2234:
|
|
2099
2288
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
2100
2289
|
|
|
2101
2290
|
"use strict";
|
|
@@ -2112,14 +2301,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
2112
2301
|
};
|
|
2113
2302
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2114
2303
|
const events_1 = __nccwpck_require__(2361);
|
|
2115
|
-
const is_1 = __nccwpck_require__(
|
|
2304
|
+
const is_1 = __nccwpck_require__(5173);
|
|
2116
2305
|
const PCancelable = __nccwpck_require__(6419);
|
|
2117
|
-
const types_1 = __nccwpck_require__(
|
|
2118
|
-
const parse_body_1 = __nccwpck_require__(
|
|
2119
|
-
const core_1 = __nccwpck_require__(
|
|
2120
|
-
const proxy_events_1 = __nccwpck_require__(
|
|
2121
|
-
const get_buffer_1 = __nccwpck_require__(
|
|
2122
|
-
const is_response_ok_1 = __nccwpck_require__(
|
|
2306
|
+
const types_1 = __nccwpck_require__(2580);
|
|
2307
|
+
const parse_body_1 = __nccwpck_require__(416);
|
|
2308
|
+
const core_1 = __nccwpck_require__(1032);
|
|
2309
|
+
const proxy_events_1 = __nccwpck_require__(5262);
|
|
2310
|
+
const get_buffer_1 = __nccwpck_require__(7342);
|
|
2311
|
+
const is_response_ok_1 = __nccwpck_require__(6948);
|
|
2123
2312
|
const proxiedRequestEvents = [
|
|
2124
2313
|
'request',
|
|
2125
2314
|
'response',
|
|
@@ -2214,11 +2403,11 @@ function asPromise(normalizedOptions) {
|
|
|
2214
2403
|
request._beforeError(new types_1.RequestError(error.message, error, request));
|
|
2215
2404
|
return;
|
|
2216
2405
|
}
|
|
2406
|
+
globalResponse = response;
|
|
2217
2407
|
if (!is_response_ok_1.isResponseOk(response)) {
|
|
2218
2408
|
request._beforeError(new types_1.HTTPError(response));
|
|
2219
2409
|
return;
|
|
2220
2410
|
}
|
|
2221
|
-
globalResponse = response;
|
|
2222
2411
|
resolve(request.options.resolveBodyOnly ? response.body : response);
|
|
2223
2412
|
});
|
|
2224
2413
|
const onError = (error) => {
|
|
@@ -2273,18 +2462,18 @@ function asPromise(normalizedOptions) {
|
|
|
2273
2462
|
return promise;
|
|
2274
2463
|
}
|
|
2275
2464
|
exports["default"] = asPromise;
|
|
2276
|
-
__exportStar(__nccwpck_require__(
|
|
2465
|
+
__exportStar(__nccwpck_require__(2580), exports);
|
|
2277
2466
|
|
|
2278
2467
|
|
|
2279
2468
|
/***/ }),
|
|
2280
2469
|
|
|
2281
|
-
/***/
|
|
2470
|
+
/***/ 530:
|
|
2282
2471
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
2283
2472
|
|
|
2284
2473
|
"use strict";
|
|
2285
2474
|
|
|
2286
2475
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2287
|
-
const is_1 = __nccwpck_require__(
|
|
2476
|
+
const is_1 = __nccwpck_require__(5173);
|
|
2288
2477
|
const normalizeArguments = (options, defaults) => {
|
|
2289
2478
|
if (is_1.default.null_(options.encoding)) {
|
|
2290
2479
|
throw new TypeError('To get a Buffer, set `options.responseType` to `buffer` instead');
|
|
@@ -2364,13 +2553,13 @@ exports["default"] = normalizeArguments;
|
|
|
2364
2553
|
|
|
2365
2554
|
/***/ }),
|
|
2366
2555
|
|
|
2367
|
-
/***/
|
|
2556
|
+
/***/ 416:
|
|
2368
2557
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
2369
2558
|
|
|
2370
2559
|
"use strict";
|
|
2371
2560
|
|
|
2372
2561
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2373
|
-
const types_1 = __nccwpck_require__(
|
|
2562
|
+
const types_1 = __nccwpck_require__(2580);
|
|
2374
2563
|
const parseBody = (response, responseType, parseJson, encoding) => {
|
|
2375
2564
|
const { rawBody } = response;
|
|
2376
2565
|
try {
|
|
@@ -2397,7 +2586,7 @@ exports["default"] = parseBody;
|
|
|
2397
2586
|
|
|
2398
2587
|
/***/ }),
|
|
2399
2588
|
|
|
2400
|
-
/***/
|
|
2589
|
+
/***/ 2580:
|
|
2401
2590
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
2402
2591
|
|
|
2403
2592
|
"use strict";
|
|
@@ -2414,7 +2603,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
2414
2603
|
};
|
|
2415
2604
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2416
2605
|
exports.CancelError = exports.ParseError = void 0;
|
|
2417
|
-
const core_1 = __nccwpck_require__(
|
|
2606
|
+
const core_1 = __nccwpck_require__(1032);
|
|
2418
2607
|
/**
|
|
2419
2608
|
An error to be thrown when server response code is 2xx, and parsing body fails.
|
|
2420
2609
|
Includes a `response` property.
|
|
@@ -2442,12 +2631,12 @@ class CancelError extends core_1.RequestError {
|
|
|
2442
2631
|
}
|
|
2443
2632
|
}
|
|
2444
2633
|
exports.CancelError = CancelError;
|
|
2445
|
-
__exportStar(__nccwpck_require__(
|
|
2634
|
+
__exportStar(__nccwpck_require__(1032), exports);
|
|
2446
2635
|
|
|
2447
2636
|
|
|
2448
2637
|
/***/ }),
|
|
2449
2638
|
|
|
2450
|
-
/***/
|
|
2639
|
+
/***/ 1879:
|
|
2451
2640
|
/***/ ((__unused_webpack_module, exports) => {
|
|
2452
2641
|
|
|
2453
2642
|
"use strict";
|
|
@@ -2484,7 +2673,7 @@ exports["default"] = calculateRetryDelay;
|
|
|
2484
2673
|
|
|
2485
2674
|
/***/ }),
|
|
2486
2675
|
|
|
2487
|
-
/***/
|
|
2676
|
+
/***/ 1032:
|
|
2488
2677
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
2489
2678
|
|
|
2490
2679
|
"use strict";
|
|
@@ -2505,20 +2694,20 @@ const decompressResponse = __nccwpck_require__(2269);
|
|
|
2505
2694
|
// @ts-expect-error Missing types
|
|
2506
2695
|
const http2wrapper = __nccwpck_require__(7952);
|
|
2507
2696
|
const lowercaseKeys = __nccwpck_require__(4162);
|
|
2508
|
-
const is_1 = __nccwpck_require__(
|
|
2509
|
-
const get_body_size_1 = __nccwpck_require__(
|
|
2510
|
-
const is_form_data_1 = __nccwpck_require__(
|
|
2511
|
-
const proxy_events_1 = __nccwpck_require__(
|
|
2512
|
-
const timed_out_1 = __nccwpck_require__(
|
|
2513
|
-
const url_to_options_1 = __nccwpck_require__(
|
|
2514
|
-
const options_to_url_1 = __nccwpck_require__(
|
|
2515
|
-
const weakable_map_1 = __nccwpck_require__(
|
|
2516
|
-
const get_buffer_1 = __nccwpck_require__(
|
|
2517
|
-
const dns_ip_version_1 = __nccwpck_require__(
|
|
2518
|
-
const is_response_ok_1 = __nccwpck_require__(
|
|
2519
|
-
const deprecation_warning_1 = __nccwpck_require__(
|
|
2520
|
-
const normalize_arguments_1 = __nccwpck_require__(
|
|
2521
|
-
const calculate_retry_delay_1 = __nccwpck_require__(
|
|
2697
|
+
const is_1 = __nccwpck_require__(5173);
|
|
2698
|
+
const get_body_size_1 = __nccwpck_require__(4543);
|
|
2699
|
+
const is_form_data_1 = __nccwpck_require__(8652);
|
|
2700
|
+
const proxy_events_1 = __nccwpck_require__(5262);
|
|
2701
|
+
const timed_out_1 = __nccwpck_require__(7738);
|
|
2702
|
+
const url_to_options_1 = __nccwpck_require__(4892);
|
|
2703
|
+
const options_to_url_1 = __nccwpck_require__(1186);
|
|
2704
|
+
const weakable_map_1 = __nccwpck_require__(2009);
|
|
2705
|
+
const get_buffer_1 = __nccwpck_require__(7342);
|
|
2706
|
+
const dns_ip_version_1 = __nccwpck_require__(3371);
|
|
2707
|
+
const is_response_ok_1 = __nccwpck_require__(6948);
|
|
2708
|
+
const deprecation_warning_1 = __nccwpck_require__(3351);
|
|
2709
|
+
const normalize_arguments_1 = __nccwpck_require__(530);
|
|
2710
|
+
const calculate_retry_delay_1 = __nccwpck_require__(1879);
|
|
2522
2711
|
let globalDnsCache;
|
|
2523
2712
|
const kRequest = Symbol('request');
|
|
2524
2713
|
const kResponse = Symbol('response');
|
|
@@ -3356,6 +3545,14 @@ class Request extends stream_1.Duplex {
|
|
|
3356
3545
|
const redirectUrl = new url_1.URL(redirectBuffer, url);
|
|
3357
3546
|
const redirectString = redirectUrl.toString();
|
|
3358
3547
|
decodeURI(redirectString);
|
|
3548
|
+
// eslint-disable-next-line no-inner-declarations
|
|
3549
|
+
function isUnixSocketURL(url) {
|
|
3550
|
+
return url.protocol === 'unix:' || url.hostname === 'unix';
|
|
3551
|
+
}
|
|
3552
|
+
if (!isUnixSocketURL(url) && isUnixSocketURL(redirectUrl)) {
|
|
3553
|
+
this._beforeError(new RequestError('Cannot redirect to UNIX socket', {}, this));
|
|
3554
|
+
return;
|
|
3555
|
+
}
|
|
3359
3556
|
// Redirecting to a different site, clear sensitive data.
|
|
3360
3557
|
if (redirectUrl.hostname !== url.hostname || redirectUrl.port !== url.port) {
|
|
3361
3558
|
if ('host' in options.headers) {
|
|
@@ -3989,7 +4186,7 @@ exports["default"] = Request;
|
|
|
3989
4186
|
|
|
3990
4187
|
/***/ }),
|
|
3991
4188
|
|
|
3992
|
-
/***/
|
|
4189
|
+
/***/ 3371:
|
|
3993
4190
|
/***/ ((__unused_webpack_module, exports) => {
|
|
3994
4191
|
|
|
3995
4192
|
"use strict";
|
|
@@ -4014,7 +4211,7 @@ exports.dnsLookupIpVersionToFamily = (dnsLookupIpVersion) => {
|
|
|
4014
4211
|
|
|
4015
4212
|
/***/ }),
|
|
4016
4213
|
|
|
4017
|
-
/***/
|
|
4214
|
+
/***/ 4543:
|
|
4018
4215
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
4019
4216
|
|
|
4020
4217
|
"use strict";
|
|
@@ -4022,8 +4219,8 @@ exports.dnsLookupIpVersionToFamily = (dnsLookupIpVersion) => {
|
|
|
4022
4219
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4023
4220
|
const fs_1 = __nccwpck_require__(7147);
|
|
4024
4221
|
const util_1 = __nccwpck_require__(3837);
|
|
4025
|
-
const is_1 = __nccwpck_require__(
|
|
4026
|
-
const is_form_data_1 = __nccwpck_require__(
|
|
4222
|
+
const is_1 = __nccwpck_require__(5173);
|
|
4223
|
+
const is_form_data_1 = __nccwpck_require__(8652);
|
|
4027
4224
|
const statAsync = util_1.promisify(fs_1.stat);
|
|
4028
4225
|
exports["default"] = async (body, headers) => {
|
|
4029
4226
|
if (headers && 'content-length' in headers) {
|
|
@@ -4054,7 +4251,7 @@ exports["default"] = async (body, headers) => {
|
|
|
4054
4251
|
|
|
4055
4252
|
/***/ }),
|
|
4056
4253
|
|
|
4057
|
-
/***/
|
|
4254
|
+
/***/ 7342:
|
|
4058
4255
|
/***/ ((__unused_webpack_module, exports) => {
|
|
4059
4256
|
|
|
4060
4257
|
"use strict";
|
|
@@ -4078,19 +4275,19 @@ exports["default"] = getBuffer;
|
|
|
4078
4275
|
|
|
4079
4276
|
/***/ }),
|
|
4080
4277
|
|
|
4081
|
-
/***/
|
|
4278
|
+
/***/ 8652:
|
|
4082
4279
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
4083
4280
|
|
|
4084
4281
|
"use strict";
|
|
4085
4282
|
|
|
4086
4283
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4087
|
-
const is_1 = __nccwpck_require__(
|
|
4284
|
+
const is_1 = __nccwpck_require__(5173);
|
|
4088
4285
|
exports["default"] = (body) => is_1.default.nodeStream(body) && is_1.default.function_(body.getBoundary);
|
|
4089
4286
|
|
|
4090
4287
|
|
|
4091
4288
|
/***/ }),
|
|
4092
4289
|
|
|
4093
|
-
/***/
|
|
4290
|
+
/***/ 6948:
|
|
4094
4291
|
/***/ ((__unused_webpack_module, exports) => {
|
|
4095
4292
|
|
|
4096
4293
|
"use strict";
|
|
@@ -4106,7 +4303,7 @@ exports.isResponseOk = (response) => {
|
|
|
4106
4303
|
|
|
4107
4304
|
/***/ }),
|
|
4108
4305
|
|
|
4109
|
-
/***/
|
|
4306
|
+
/***/ 1186:
|
|
4110
4307
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
4111
4308
|
|
|
4112
4309
|
"use strict";
|
|
@@ -4167,7 +4364,7 @@ exports["default"] = (origin, options) => {
|
|
|
4167
4364
|
|
|
4168
4365
|
/***/ }),
|
|
4169
4366
|
|
|
4170
|
-
/***/
|
|
4367
|
+
/***/ 5262:
|
|
4171
4368
|
/***/ ((__unused_webpack_module, exports) => {
|
|
4172
4369
|
|
|
4173
4370
|
"use strict";
|
|
@@ -4192,7 +4389,7 @@ exports["default"] = default_1;
|
|
|
4192
4389
|
|
|
4193
4390
|
/***/ }),
|
|
4194
4391
|
|
|
4195
|
-
/***/
|
|
4392
|
+
/***/ 7738:
|
|
4196
4393
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
4197
4394
|
|
|
4198
4395
|
"use strict";
|
|
@@ -4200,7 +4397,7 @@ exports["default"] = default_1;
|
|
|
4200
4397
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4201
4398
|
exports.TimeoutError = void 0;
|
|
4202
4399
|
const net = __nccwpck_require__(1808);
|
|
4203
|
-
const unhandle_1 = __nccwpck_require__(
|
|
4400
|
+
const unhandle_1 = __nccwpck_require__(3762);
|
|
4204
4401
|
const reentry = Symbol('reentry');
|
|
4205
4402
|
const noop = () => { };
|
|
4206
4403
|
class TimeoutError extends Error {
|
|
@@ -4321,7 +4518,7 @@ exports["default"] = (request, delays, options) => {
|
|
|
4321
4518
|
|
|
4322
4519
|
/***/ }),
|
|
4323
4520
|
|
|
4324
|
-
/***/
|
|
4521
|
+
/***/ 3762:
|
|
4325
4522
|
/***/ ((__unused_webpack_module, exports) => {
|
|
4326
4523
|
|
|
4327
4524
|
"use strict";
|
|
@@ -4351,13 +4548,13 @@ exports["default"] = () => {
|
|
|
4351
4548
|
|
|
4352
4549
|
/***/ }),
|
|
4353
4550
|
|
|
4354
|
-
/***/
|
|
4551
|
+
/***/ 4892:
|
|
4355
4552
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
4356
4553
|
|
|
4357
4554
|
"use strict";
|
|
4358
4555
|
|
|
4359
4556
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4360
|
-
const is_1 = __nccwpck_require__(
|
|
4557
|
+
const is_1 = __nccwpck_require__(5173);
|
|
4361
4558
|
exports["default"] = (url) => {
|
|
4362
4559
|
// Cast to URL
|
|
4363
4560
|
url = url;
|
|
@@ -4383,7 +4580,7 @@ exports["default"] = (url) => {
|
|
|
4383
4580
|
|
|
4384
4581
|
/***/ }),
|
|
4385
4582
|
|
|
4386
|
-
/***/
|
|
4583
|
+
/***/ 2009:
|
|
4387
4584
|
/***/ ((__unused_webpack_module, exports) => {
|
|
4388
4585
|
|
|
4389
4586
|
"use strict";
|
|
@@ -4420,7 +4617,7 @@ exports["default"] = WeakableMap;
|
|
|
4420
4617
|
|
|
4421
4618
|
/***/ }),
|
|
4422
4619
|
|
|
4423
|
-
/***/
|
|
4620
|
+
/***/ 5133:
|
|
4424
4621
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
4425
4622
|
|
|
4426
4623
|
"use strict";
|
|
@@ -4437,11 +4634,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
4437
4634
|
};
|
|
4438
4635
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4439
4636
|
exports.defaultHandler = void 0;
|
|
4440
|
-
const is_1 = __nccwpck_require__(
|
|
4441
|
-
const as_promise_1 = __nccwpck_require__(
|
|
4442
|
-
const create_rejection_1 = __nccwpck_require__(
|
|
4443
|
-
const core_1 = __nccwpck_require__(
|
|
4444
|
-
const deep_freeze_1 = __nccwpck_require__(
|
|
4637
|
+
const is_1 = __nccwpck_require__(5173);
|
|
4638
|
+
const as_promise_1 = __nccwpck_require__(2234);
|
|
4639
|
+
const create_rejection_1 = __nccwpck_require__(1729);
|
|
4640
|
+
const core_1 = __nccwpck_require__(1032);
|
|
4641
|
+
const deep_freeze_1 = __nccwpck_require__(8295);
|
|
4445
4642
|
const errors = {
|
|
4446
4643
|
RequestError: as_promise_1.RequestError,
|
|
4447
4644
|
CacheError: as_promise_1.CacheError,
|
|
@@ -4663,12 +4860,12 @@ const create = (defaults) => {
|
|
|
4663
4860
|
return got;
|
|
4664
4861
|
};
|
|
4665
4862
|
exports["default"] = create;
|
|
4666
|
-
__exportStar(__nccwpck_require__(
|
|
4863
|
+
__exportStar(__nccwpck_require__(5499), exports);
|
|
4667
4864
|
|
|
4668
4865
|
|
|
4669
4866
|
/***/ }),
|
|
4670
4867
|
|
|
4671
|
-
/***/
|
|
4868
|
+
/***/ 5569:
|
|
4672
4869
|
/***/ (function(module, exports, __nccwpck_require__) {
|
|
4673
4870
|
|
|
4674
4871
|
"use strict";
|
|
@@ -4685,7 +4882,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
4685
4882
|
};
|
|
4686
4883
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4687
4884
|
const url_1 = __nccwpck_require__(7310);
|
|
4688
|
-
const create_1 = __nccwpck_require__(
|
|
4885
|
+
const create_1 = __nccwpck_require__(5133);
|
|
4689
4886
|
const defaults = {
|
|
4690
4887
|
options: {
|
|
4691
4888
|
method: 'GET',
|
|
@@ -4802,13 +4999,13 @@ exports["default"] = got;
|
|
|
4802
4999
|
module.exports = got;
|
|
4803
5000
|
module.exports["default"] = got;
|
|
4804
5001
|
module.exports.__esModule = true; // Workaround for TS issue: https://github.com/sindresorhus/got/pull/1267
|
|
4805
|
-
__exportStar(__nccwpck_require__(
|
|
4806
|
-
__exportStar(__nccwpck_require__(
|
|
5002
|
+
__exportStar(__nccwpck_require__(5133), exports);
|
|
5003
|
+
__exportStar(__nccwpck_require__(2234), exports);
|
|
4807
5004
|
|
|
4808
5005
|
|
|
4809
5006
|
/***/ }),
|
|
4810
5007
|
|
|
4811
|
-
/***/
|
|
5008
|
+
/***/ 5499:
|
|
4812
5009
|
/***/ ((__unused_webpack_module, exports) => {
|
|
4813
5010
|
|
|
4814
5011
|
"use strict";
|
|
@@ -4818,13 +5015,13 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
4818
5015
|
|
|
4819
5016
|
/***/ }),
|
|
4820
5017
|
|
|
4821
|
-
/***/
|
|
5018
|
+
/***/ 8295:
|
|
4822
5019
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
4823
5020
|
|
|
4824
5021
|
"use strict";
|
|
4825
5022
|
|
|
4826
5023
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4827
|
-
const is_1 = __nccwpck_require__(
|
|
5024
|
+
const is_1 = __nccwpck_require__(5173);
|
|
4828
5025
|
function deepFreeze(object) {
|
|
4829
5026
|
for (const value of Object.values(object)) {
|
|
4830
5027
|
if (is_1.default.plainObject(value) || is_1.default.array(value)) {
|
|
@@ -4838,7 +5035,7 @@ exports["default"] = deepFreeze;
|
|
|
4838
5035
|
|
|
4839
5036
|
/***/ }),
|
|
4840
5037
|
|
|
4841
|
-
/***/
|
|
5038
|
+
/***/ 3351:
|
|
4842
5039
|
/***/ ((__unused_webpack_module, exports) => {
|
|
4843
5040
|
|
|
4844
5041
|
"use strict";
|
|
@@ -7152,7 +7349,7 @@ exports.parse = function (s) {
|
|
|
7152
7349
|
|
|
7153
7350
|
/***/ }),
|
|
7154
7351
|
|
|
7155
|
-
/***/
|
|
7352
|
+
/***/ 787:
|
|
7156
7353
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
7157
7354
|
|
|
7158
7355
|
"use strict";
|
|
@@ -7160,68 +7357,186 @@ exports.parse = function (s) {
|
|
|
7160
7357
|
|
|
7161
7358
|
const EventEmitter = __nccwpck_require__(2361);
|
|
7162
7359
|
const JSONB = __nccwpck_require__(9604);
|
|
7360
|
+
const compressBrotli = __nccwpck_require__(2809);
|
|
7163
7361
|
|
|
7164
7362
|
const loadStore = options => {
|
|
7165
7363
|
const adapters = {
|
|
7166
7364
|
redis: '@keyv/redis',
|
|
7365
|
+
rediss: '@keyv/redis',
|
|
7167
7366
|
mongodb: '@keyv/mongo',
|
|
7168
7367
|
mongo: '@keyv/mongo',
|
|
7169
7368
|
sqlite: '@keyv/sqlite',
|
|
7170
7369
|
postgresql: '@keyv/postgres',
|
|
7171
7370
|
postgres: '@keyv/postgres',
|
|
7172
7371
|
mysql: '@keyv/mysql',
|
|
7372
|
+
etcd: '@keyv/etcd',
|
|
7373
|
+
offline: '@keyv/offline',
|
|
7374
|
+
tiered: '@keyv/tiered',
|
|
7173
7375
|
};
|
|
7174
7376
|
if (options.adapter || options.uri) {
|
|
7175
|
-
const adapter = options.adapter || /^[
|
|
7377
|
+
const adapter = options.adapter || /^[^:+]*/.exec(options.uri)[0];
|
|
7176
7378
|
return new (require(adapters[adapter]))(options);
|
|
7177
7379
|
}
|
|
7178
7380
|
|
|
7179
7381
|
return new Map();
|
|
7180
7382
|
};
|
|
7181
7383
|
|
|
7384
|
+
const iterableAdapters = [
|
|
7385
|
+
'sqlite',
|
|
7386
|
+
'postgres',
|
|
7387
|
+
'mysql',
|
|
7388
|
+
'mongo',
|
|
7389
|
+
'redis',
|
|
7390
|
+
'tiered',
|
|
7391
|
+
];
|
|
7392
|
+
|
|
7182
7393
|
class Keyv extends EventEmitter {
|
|
7183
|
-
constructor(uri, options) {
|
|
7394
|
+
constructor(uri, {emitErrors = true, ...options} = {}) {
|
|
7184
7395
|
super();
|
|
7185
|
-
this.opts =
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
options,
|
|
7193
|
-
);
|
|
7396
|
+
this.opts = {
|
|
7397
|
+
namespace: 'keyv',
|
|
7398
|
+
serialize: JSONB.stringify,
|
|
7399
|
+
deserialize: JSONB.parse,
|
|
7400
|
+
...((typeof uri === 'string') ? {uri} : uri),
|
|
7401
|
+
...options,
|
|
7402
|
+
};
|
|
7194
7403
|
|
|
7195
7404
|
if (!this.opts.store) {
|
|
7196
|
-
const adapterOptions =
|
|
7405
|
+
const adapterOptions = {...this.opts};
|
|
7197
7406
|
this.opts.store = loadStore(adapterOptions);
|
|
7198
7407
|
}
|
|
7199
7408
|
|
|
7200
|
-
if (
|
|
7409
|
+
if (this.opts.compress) {
|
|
7410
|
+
const brotli = compressBrotli(this.opts.compress.opts);
|
|
7411
|
+
this.opts.serialize = async ({value, expires}) => brotli.serialize({value: await brotli.compress(value), expires});
|
|
7412
|
+
this.opts.deserialize = async data => {
|
|
7413
|
+
const {value, expires} = brotli.deserialize(data);
|
|
7414
|
+
return {value: await brotli.decompress(value), expires};
|
|
7415
|
+
};
|
|
7416
|
+
}
|
|
7417
|
+
|
|
7418
|
+
if (typeof this.opts.store.on === 'function' && emitErrors) {
|
|
7201
7419
|
this.opts.store.on('error', error => this.emit('error', error));
|
|
7202
7420
|
}
|
|
7203
7421
|
|
|
7204
7422
|
this.opts.store.namespace = this.opts.namespace;
|
|
7423
|
+
|
|
7424
|
+
const generateIterator = iterator => async function * () {
|
|
7425
|
+
for await (const [key, raw] of typeof iterator === 'function'
|
|
7426
|
+
? iterator(this.opts.store.namespace)
|
|
7427
|
+
: iterator) {
|
|
7428
|
+
const data = this.opts.deserialize(raw);
|
|
7429
|
+
if (this.opts.store.namespace && !key.includes(this.opts.store.namespace)) {
|
|
7430
|
+
continue;
|
|
7431
|
+
}
|
|
7432
|
+
|
|
7433
|
+
if (typeof data.expires === 'number' && Date.now() > data.expires) {
|
|
7434
|
+
this.delete(key);
|
|
7435
|
+
continue;
|
|
7436
|
+
}
|
|
7437
|
+
|
|
7438
|
+
yield [this._getKeyUnprefix(key), data.value];
|
|
7439
|
+
}
|
|
7440
|
+
};
|
|
7441
|
+
|
|
7442
|
+
// Attach iterators
|
|
7443
|
+
if (typeof this.opts.store[Symbol.iterator] === 'function' && this.opts.store instanceof Map) {
|
|
7444
|
+
this.iterator = generateIterator(this.opts.store);
|
|
7445
|
+
} else if (typeof this.opts.store.iterator === 'function' && this.opts.store.opts
|
|
7446
|
+
&& this._checkIterableAdaptar()) {
|
|
7447
|
+
this.iterator = generateIterator(this.opts.store.iterator.bind(this.opts.store));
|
|
7448
|
+
}
|
|
7449
|
+
}
|
|
7450
|
+
|
|
7451
|
+
_checkIterableAdaptar() {
|
|
7452
|
+
return iterableAdapters.includes(this.opts.store.opts.dialect)
|
|
7453
|
+
|| iterableAdapters.findIndex(element => this.opts.store.opts.url.includes(element)) >= 0;
|
|
7205
7454
|
}
|
|
7206
7455
|
|
|
7207
7456
|
_getKeyPrefix(key) {
|
|
7208
7457
|
return `${this.opts.namespace}:${key}`;
|
|
7209
7458
|
}
|
|
7210
7459
|
|
|
7460
|
+
_getKeyPrefixArray(keys) {
|
|
7461
|
+
return keys.map(key => `${this.opts.namespace}:${key}`);
|
|
7462
|
+
}
|
|
7463
|
+
|
|
7464
|
+
_getKeyUnprefix(key) {
|
|
7465
|
+
return key
|
|
7466
|
+
.split(':')
|
|
7467
|
+
.splice(1)
|
|
7468
|
+
.join(':');
|
|
7469
|
+
}
|
|
7470
|
+
|
|
7211
7471
|
get(key, options) {
|
|
7212
|
-
const
|
|
7213
|
-
const
|
|
7472
|
+
const {store} = this.opts;
|
|
7473
|
+
const isArray = Array.isArray(key);
|
|
7474
|
+
const keyPrefixed = isArray ? this._getKeyPrefixArray(key) : this._getKeyPrefix(key);
|
|
7475
|
+
if (isArray && store.getMany === undefined) {
|
|
7476
|
+
const promises = [];
|
|
7477
|
+
for (const key of keyPrefixed) {
|
|
7478
|
+
promises.push(Promise.resolve()
|
|
7479
|
+
.then(() => store.get(key))
|
|
7480
|
+
.then(data => (typeof data === 'string') ? this.opts.deserialize(data) : data)
|
|
7481
|
+
.then(data => {
|
|
7482
|
+
if (data === undefined || data === null) {
|
|
7483
|
+
return undefined;
|
|
7484
|
+
}
|
|
7485
|
+
|
|
7486
|
+
if (typeof data.expires === 'number' && Date.now() > data.expires) {
|
|
7487
|
+
return this.delete(key).then(() => undefined);
|
|
7488
|
+
}
|
|
7489
|
+
|
|
7490
|
+
return (options && options.raw) ? data : data.value;
|
|
7491
|
+
}),
|
|
7492
|
+
);
|
|
7493
|
+
}
|
|
7494
|
+
|
|
7495
|
+
return Promise.allSettled(promises)
|
|
7496
|
+
.then(values => {
|
|
7497
|
+
const data = [];
|
|
7498
|
+
for (const value of values) {
|
|
7499
|
+
data.push(value.value);
|
|
7500
|
+
}
|
|
7501
|
+
|
|
7502
|
+
return data;
|
|
7503
|
+
});
|
|
7504
|
+
}
|
|
7505
|
+
|
|
7214
7506
|
return Promise.resolve()
|
|
7215
|
-
.then(() => store.get(keyPrefixed))
|
|
7507
|
+
.then(() => isArray ? store.getMany(keyPrefixed) : store.get(keyPrefixed))
|
|
7216
7508
|
.then(data => (typeof data === 'string') ? this.opts.deserialize(data) : data)
|
|
7217
7509
|
.then(data => {
|
|
7218
|
-
if (data === undefined) {
|
|
7510
|
+
if (data === undefined || data === null) {
|
|
7219
7511
|
return undefined;
|
|
7220
7512
|
}
|
|
7221
7513
|
|
|
7514
|
+
if (isArray) {
|
|
7515
|
+
const result = [];
|
|
7516
|
+
|
|
7517
|
+
for (let row of data) {
|
|
7518
|
+
if ((typeof row === 'string')) {
|
|
7519
|
+
row = this.opts.deserialize(row);
|
|
7520
|
+
}
|
|
7521
|
+
|
|
7522
|
+
if (row === undefined || row === null) {
|
|
7523
|
+
result.push(undefined);
|
|
7524
|
+
continue;
|
|
7525
|
+
}
|
|
7526
|
+
|
|
7527
|
+
if (typeof row.expires === 'number' && Date.now() > row.expires) {
|
|
7528
|
+
this.delete(key).then(() => undefined);
|
|
7529
|
+
result.push(undefined);
|
|
7530
|
+
} else {
|
|
7531
|
+
result.push((options && options.raw) ? row : row.value);
|
|
7532
|
+
}
|
|
7533
|
+
}
|
|
7534
|
+
|
|
7535
|
+
return result;
|
|
7536
|
+
}
|
|
7537
|
+
|
|
7222
7538
|
if (typeof data.expires === 'number' && Date.now() > data.expires) {
|
|
7223
|
-
this.delete(key);
|
|
7224
|
-
return undefined;
|
|
7539
|
+
return this.delete(key).then(() => undefined);
|
|
7225
7540
|
}
|
|
7226
7541
|
|
|
7227
7542
|
return (options && options.raw) ? data : data.value;
|
|
@@ -7238,12 +7553,16 @@ class Keyv extends EventEmitter {
|
|
|
7238
7553
|
ttl = undefined;
|
|
7239
7554
|
}
|
|
7240
7555
|
|
|
7241
|
-
const {
|
|
7556
|
+
const {store} = this.opts;
|
|
7242
7557
|
|
|
7243
7558
|
return Promise.resolve()
|
|
7244
7559
|
.then(() => {
|
|
7245
7560
|
const expires = (typeof ttl === 'number') ? (Date.now() + ttl) : null;
|
|
7246
|
-
|
|
7561
|
+
if (typeof value === 'symbol') {
|
|
7562
|
+
this.emit('error', 'symbol cannot be serialized');
|
|
7563
|
+
}
|
|
7564
|
+
|
|
7565
|
+
value = {value, expires};
|
|
7247
7566
|
return this.opts.serialize(value);
|
|
7248
7567
|
})
|
|
7249
7568
|
.then(value => store.set(keyPrefixed, value, ttl))
|
|
@@ -7251,17 +7570,54 @@ class Keyv extends EventEmitter {
|
|
|
7251
7570
|
}
|
|
7252
7571
|
|
|
7253
7572
|
delete(key) {
|
|
7573
|
+
const {store} = this.opts;
|
|
7574
|
+
if (Array.isArray(key)) {
|
|
7575
|
+
const keyPrefixed = this._getKeyPrefixArray(key);
|
|
7576
|
+
if (store.deleteMany === undefined) {
|
|
7577
|
+
const promises = [];
|
|
7578
|
+
for (const key of keyPrefixed) {
|
|
7579
|
+
promises.push(store.delete(key));
|
|
7580
|
+
}
|
|
7581
|
+
|
|
7582
|
+
return Promise.allSettled(promises)
|
|
7583
|
+
.then(values => values.every(x => x.value === true));
|
|
7584
|
+
}
|
|
7585
|
+
|
|
7586
|
+
return Promise.resolve()
|
|
7587
|
+
.then(() => store.deleteMany(keyPrefixed));
|
|
7588
|
+
}
|
|
7589
|
+
|
|
7254
7590
|
const keyPrefixed = this._getKeyPrefix(key);
|
|
7255
|
-
const { store } = this.opts;
|
|
7256
7591
|
return Promise.resolve()
|
|
7257
7592
|
.then(() => store.delete(keyPrefixed));
|
|
7258
7593
|
}
|
|
7259
7594
|
|
|
7260
7595
|
clear() {
|
|
7261
|
-
const {
|
|
7596
|
+
const {store} = this.opts;
|
|
7262
7597
|
return Promise.resolve()
|
|
7263
7598
|
.then(() => store.clear());
|
|
7264
7599
|
}
|
|
7600
|
+
|
|
7601
|
+
has(key) {
|
|
7602
|
+
const keyPrefixed = this._getKeyPrefix(key);
|
|
7603
|
+
const {store} = this.opts;
|
|
7604
|
+
return Promise.resolve()
|
|
7605
|
+
.then(async () => {
|
|
7606
|
+
if (typeof store.has === 'function') {
|
|
7607
|
+
return store.has(keyPrefixed);
|
|
7608
|
+
}
|
|
7609
|
+
|
|
7610
|
+
const value = await store.get(keyPrefixed);
|
|
7611
|
+
return value !== undefined;
|
|
7612
|
+
});
|
|
7613
|
+
}
|
|
7614
|
+
|
|
7615
|
+
disconnect() {
|
|
7616
|
+
const {store} = this.opts;
|
|
7617
|
+
if (typeof store.disconnect === 'function') {
|
|
7618
|
+
return store.disconnect();
|
|
7619
|
+
}
|
|
7620
|
+
}
|
|
7265
7621
|
}
|
|
7266
7622
|
|
|
7267
7623
|
module.exports = Keyv;
|
|
@@ -10897,7 +11253,7 @@ module.exports = pump
|
|
|
10897
11253
|
|
|
10898
11254
|
/***/ }),
|
|
10899
11255
|
|
|
10900
|
-
/***/
|
|
11256
|
+
/***/ 7348:
|
|
10901
11257
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
10902
11258
|
|
|
10903
11259
|
"use strict";
|
|
@@ -10952,6 +11308,23 @@ function encoderForArrayFormat(options) {
|
|
|
10952
11308
|
return [...result, [encode(key, options), '[]=', encode(value, options)].join('')];
|
|
10953
11309
|
};
|
|
10954
11310
|
|
|
11311
|
+
case 'colon-list-separator':
|
|
11312
|
+
return key => (result, value) => {
|
|
11313
|
+
if (
|
|
11314
|
+
value === undefined ||
|
|
11315
|
+
(options.skipNull && value === null) ||
|
|
11316
|
+
(options.skipEmptyString && value === '')
|
|
11317
|
+
) {
|
|
11318
|
+
return result;
|
|
11319
|
+
}
|
|
11320
|
+
|
|
11321
|
+
if (value === null) {
|
|
11322
|
+
return [...result, [encode(key, options), ':list='].join('')];
|
|
11323
|
+
}
|
|
11324
|
+
|
|
11325
|
+
return [...result, [encode(key, options), ':list=', encode(value, options)].join('')];
|
|
11326
|
+
};
|
|
11327
|
+
|
|
10955
11328
|
case 'comma':
|
|
10956
11329
|
case 'separator':
|
|
10957
11330
|
case 'bracket-separator': {
|
|
@@ -11038,6 +11411,24 @@ function parserForArrayFormat(options) {
|
|
|
11038
11411
|
accumulator[key] = [].concat(accumulator[key], value);
|
|
11039
11412
|
};
|
|
11040
11413
|
|
|
11414
|
+
case 'colon-list-separator':
|
|
11415
|
+
return (key, value, accumulator) => {
|
|
11416
|
+
result = /(:list)$/.exec(key);
|
|
11417
|
+
key = key.replace(/:list$/, '');
|
|
11418
|
+
|
|
11419
|
+
if (!result) {
|
|
11420
|
+
accumulator[key] = value;
|
|
11421
|
+
return;
|
|
11422
|
+
}
|
|
11423
|
+
|
|
11424
|
+
if (accumulator[key] === undefined) {
|
|
11425
|
+
accumulator[key] = [value];
|
|
11426
|
+
return;
|
|
11427
|
+
}
|
|
11428
|
+
|
|
11429
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
11430
|
+
};
|
|
11431
|
+
|
|
11041
11432
|
case 'comma':
|
|
11042
11433
|
case 'separator':
|
|
11043
11434
|
return (key, value, accumulator) => {
|
|
@@ -11534,7 +11925,7 @@ module.exports = (options = {}, connect = tls.connect) => new Promise((resolve,
|
|
|
11534
11925
|
|
|
11535
11926
|
/***/ }),
|
|
11536
11927
|
|
|
11537
|
-
/***/
|
|
11928
|
+
/***/ 1534:
|
|
11538
11929
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
11539
11930
|
|
|
11540
11931
|
"use strict";
|
|
@@ -11656,16 +12047,18 @@ function wrappy (fn, cb) {
|
|
|
11656
12047
|
|
|
11657
12048
|
/***/ }),
|
|
11658
12049
|
|
|
11659
|
-
/***/
|
|
12050
|
+
/***/ 6597:
|
|
11660
12051
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
11661
12052
|
|
|
11662
12053
|
"use strict";
|
|
11663
12054
|
|
|
11664
12055
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11665
|
-
exports.
|
|
11666
|
-
const
|
|
12056
|
+
exports.getErrorMap = exports.setErrorMap = exports.defaultErrorMap = exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0;
|
|
12057
|
+
const parseUtil_1 = __nccwpck_require__(7822);
|
|
12058
|
+
const util_1 = __nccwpck_require__(809);
|
|
11667
12059
|
exports.ZodIssueCode = util_1.util.arrayToEnum([
|
|
11668
12060
|
"invalid_type",
|
|
12061
|
+
"invalid_literal",
|
|
11669
12062
|
"custom",
|
|
11670
12063
|
"invalid_union",
|
|
11671
12064
|
"invalid_union_discriminator",
|
|
@@ -11689,51 +12082,6 @@ class ZodError extends Error {
|
|
|
11689
12082
|
constructor(issues) {
|
|
11690
12083
|
super();
|
|
11691
12084
|
this.issues = [];
|
|
11692
|
-
this.format = () => {
|
|
11693
|
-
const fieldErrors = { _errors: [] };
|
|
11694
|
-
const processError = (error) => {
|
|
11695
|
-
for (const issue of error.issues) {
|
|
11696
|
-
if (issue.code === "invalid_union") {
|
|
11697
|
-
issue.unionErrors.map(processError);
|
|
11698
|
-
}
|
|
11699
|
-
else if (issue.code === "invalid_return_type") {
|
|
11700
|
-
processError(issue.returnTypeError);
|
|
11701
|
-
}
|
|
11702
|
-
else if (issue.code === "invalid_arguments") {
|
|
11703
|
-
processError(issue.argumentsError);
|
|
11704
|
-
}
|
|
11705
|
-
else if (issue.path.length === 0) {
|
|
11706
|
-
fieldErrors._errors.push(issue.message);
|
|
11707
|
-
}
|
|
11708
|
-
else {
|
|
11709
|
-
let curr = fieldErrors;
|
|
11710
|
-
let i = 0;
|
|
11711
|
-
while (i < issue.path.length) {
|
|
11712
|
-
const el = issue.path[i];
|
|
11713
|
-
const terminal = i === issue.path.length - 1;
|
|
11714
|
-
if (!terminal) {
|
|
11715
|
-
if (typeof el === "string") {
|
|
11716
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
11717
|
-
}
|
|
11718
|
-
else if (typeof el === "number") {
|
|
11719
|
-
const errorArray = [];
|
|
11720
|
-
errorArray._errors = [];
|
|
11721
|
-
curr[el] = curr[el] || errorArray;
|
|
11722
|
-
}
|
|
11723
|
-
}
|
|
11724
|
-
else {
|
|
11725
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
11726
|
-
curr[el]._errors.push(issue.message);
|
|
11727
|
-
}
|
|
11728
|
-
curr = curr[el];
|
|
11729
|
-
i++;
|
|
11730
|
-
}
|
|
11731
|
-
}
|
|
11732
|
-
}
|
|
11733
|
-
};
|
|
11734
|
-
processError(this);
|
|
11735
|
-
return fieldErrors;
|
|
11736
|
-
};
|
|
11737
12085
|
this.addIssue = (sub) => {
|
|
11738
12086
|
this.issues = [...this.issues, sub];
|
|
11739
12087
|
};
|
|
@@ -11754,12 +12102,61 @@ class ZodError extends Error {
|
|
|
11754
12102
|
get errors() {
|
|
11755
12103
|
return this.issues;
|
|
11756
12104
|
}
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
12105
|
+
format(_mapper) {
|
|
12106
|
+
const mapper = _mapper ||
|
|
12107
|
+
function (issue) {
|
|
12108
|
+
return issue.message;
|
|
12109
|
+
};
|
|
12110
|
+
const fieldErrors = { _errors: [] };
|
|
12111
|
+
const processError = (error) => {
|
|
12112
|
+
for (const issue of error.issues) {
|
|
12113
|
+
if (issue.code === "invalid_union") {
|
|
12114
|
+
issue.unionErrors.map(processError);
|
|
12115
|
+
}
|
|
12116
|
+
else if (issue.code === "invalid_return_type") {
|
|
12117
|
+
processError(issue.returnTypeError);
|
|
12118
|
+
}
|
|
12119
|
+
else if (issue.code === "invalid_arguments") {
|
|
12120
|
+
processError(issue.argumentsError);
|
|
12121
|
+
}
|
|
12122
|
+
else if (issue.path.length === 0) {
|
|
12123
|
+
fieldErrors._errors.push(mapper(issue));
|
|
12124
|
+
}
|
|
12125
|
+
else {
|
|
12126
|
+
let curr = fieldErrors;
|
|
12127
|
+
let i = 0;
|
|
12128
|
+
while (i < issue.path.length) {
|
|
12129
|
+
const el = issue.path[i];
|
|
12130
|
+
const terminal = i === issue.path.length - 1;
|
|
12131
|
+
if (!terminal) {
|
|
12132
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
12133
|
+
// if (typeof el === "string") {
|
|
12134
|
+
// curr[el] = curr[el] || { _errors: [] };
|
|
12135
|
+
// } else if (typeof el === "number") {
|
|
12136
|
+
// const errorArray: any = [];
|
|
12137
|
+
// errorArray._errors = [];
|
|
12138
|
+
// curr[el] = curr[el] || errorArray;
|
|
12139
|
+
// }
|
|
12140
|
+
}
|
|
12141
|
+
else {
|
|
12142
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
12143
|
+
curr[el]._errors.push(mapper(issue));
|
|
12144
|
+
}
|
|
12145
|
+
curr = curr[el];
|
|
12146
|
+
i++;
|
|
12147
|
+
}
|
|
12148
|
+
}
|
|
12149
|
+
}
|
|
12150
|
+
};
|
|
12151
|
+
processError(this);
|
|
12152
|
+
return fieldErrors;
|
|
12153
|
+
}
|
|
12154
|
+
toString() {
|
|
12155
|
+
return this.message;
|
|
12156
|
+
}
|
|
12157
|
+
get message() {
|
|
12158
|
+
return JSON.stringify(this.issues, parseUtil_1.jsonStringifyReplacer, 2);
|
|
12159
|
+
}
|
|
11763
12160
|
get isEmpty() {
|
|
11764
12161
|
return this.issues.length === 0;
|
|
11765
12162
|
}
|
|
@@ -11790,30 +12187,27 @@ const defaultErrorMap = (issue, _ctx) => {
|
|
|
11790
12187
|
let message;
|
|
11791
12188
|
switch (issue.code) {
|
|
11792
12189
|
case exports.ZodIssueCode.invalid_type:
|
|
11793
|
-
if (issue.received ===
|
|
12190
|
+
if (issue.received === util_1.ZodParsedType.undefined) {
|
|
11794
12191
|
message = "Required";
|
|
11795
12192
|
}
|
|
11796
12193
|
else {
|
|
11797
12194
|
message = `Expected ${issue.expected}, received ${issue.received}`;
|
|
11798
12195
|
}
|
|
11799
12196
|
break;
|
|
12197
|
+
case exports.ZodIssueCode.invalid_literal:
|
|
12198
|
+
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, parseUtil_1.jsonStringifyReplacer)}`;
|
|
12199
|
+
break;
|
|
11800
12200
|
case exports.ZodIssueCode.unrecognized_keys:
|
|
11801
|
-
message = `Unrecognized key(s) in object: ${issue.keys
|
|
11802
|
-
.map((k) => `'${k}'`)
|
|
11803
|
-
.join(", ")}`;
|
|
12201
|
+
message = `Unrecognized key(s) in object: ${util_1.util.joinValues(issue.keys, ", ")}`;
|
|
11804
12202
|
break;
|
|
11805
12203
|
case exports.ZodIssueCode.invalid_union:
|
|
11806
12204
|
message = `Invalid input`;
|
|
11807
12205
|
break;
|
|
11808
12206
|
case exports.ZodIssueCode.invalid_union_discriminator:
|
|
11809
|
-
message = `Invalid discriminator value. Expected ${issue.options
|
|
11810
|
-
.map((val) => (typeof val === "string" ? `'${val}'` : val))
|
|
11811
|
-
.join(" | ")}`;
|
|
12207
|
+
message = `Invalid discriminator value. Expected ${util_1.util.joinValues(issue.options)}`;
|
|
11812
12208
|
break;
|
|
11813
12209
|
case exports.ZodIssueCode.invalid_enum_value:
|
|
11814
|
-
message = `Invalid enum value. Expected ${issue.options
|
|
11815
|
-
.map((val) => (typeof val === "string" ? `'${val}'` : val))
|
|
11816
|
-
.join(" | ")}`;
|
|
12210
|
+
message = `Invalid enum value. Expected ${util_1.util.joinValues(issue.options)}, received '${issue.received}'`;
|
|
11817
12211
|
break;
|
|
11818
12212
|
case exports.ZodIssueCode.invalid_arguments:
|
|
11819
12213
|
message = `Invalid function arguments`;
|
|
@@ -11825,10 +12219,23 @@ const defaultErrorMap = (issue, _ctx) => {
|
|
|
11825
12219
|
message = `Invalid date`;
|
|
11826
12220
|
break;
|
|
11827
12221
|
case exports.ZodIssueCode.invalid_string:
|
|
11828
|
-
if (issue.validation
|
|
12222
|
+
if (typeof issue.validation === "object") {
|
|
12223
|
+
if ("startsWith" in issue.validation) {
|
|
12224
|
+
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
12225
|
+
}
|
|
12226
|
+
else if ("endsWith" in issue.validation) {
|
|
12227
|
+
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
|
12228
|
+
}
|
|
12229
|
+
else {
|
|
12230
|
+
util_1.util.assertNever(issue.validation);
|
|
12231
|
+
}
|
|
12232
|
+
}
|
|
12233
|
+
else if (issue.validation !== "regex") {
|
|
11829
12234
|
message = `Invalid ${issue.validation}`;
|
|
11830
|
-
|
|
12235
|
+
}
|
|
12236
|
+
else {
|
|
11831
12237
|
message = "Invalid";
|
|
12238
|
+
}
|
|
11832
12239
|
break;
|
|
11833
12240
|
case exports.ZodIssueCode.too_small:
|
|
11834
12241
|
if (issue.type === "array")
|
|
@@ -11837,6 +12244,8 @@ const defaultErrorMap = (issue, _ctx) => {
|
|
|
11837
12244
|
message = `String must contain ${issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
11838
12245
|
else if (issue.type === "number")
|
|
11839
12246
|
message = `Number must be greater than ${issue.inclusive ? `or equal to ` : ``}${issue.minimum}`;
|
|
12247
|
+
else if (issue.type === "date")
|
|
12248
|
+
message = `Date must be greater than ${issue.inclusive ? `or equal to ` : ``}${new Date(issue.minimum)}`;
|
|
11840
12249
|
else
|
|
11841
12250
|
message = "Invalid input";
|
|
11842
12251
|
break;
|
|
@@ -11847,6 +12256,8 @@ const defaultErrorMap = (issue, _ctx) => {
|
|
|
11847
12256
|
message = `String must contain ${issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
11848
12257
|
else if (issue.type === "number")
|
|
11849
12258
|
message = `Number must be less than ${issue.inclusive ? `or equal to ` : ``}${issue.maximum}`;
|
|
12259
|
+
else if (issue.type === "date")
|
|
12260
|
+
message = `Date must be smaller than ${issue.inclusive ? `or equal to ` : ``}${new Date(issue.maximum)}`;
|
|
11850
12261
|
else
|
|
11851
12262
|
message = "Invalid input";
|
|
11852
12263
|
break;
|
|
@@ -11866,27 +12277,27 @@ const defaultErrorMap = (issue, _ctx) => {
|
|
|
11866
12277
|
return { message };
|
|
11867
12278
|
};
|
|
11868
12279
|
exports.defaultErrorMap = defaultErrorMap;
|
|
11869
|
-
|
|
11870
|
-
|
|
11871
|
-
|
|
11872
|
-
}
|
|
12280
|
+
let overrideErrorMap = exports.defaultErrorMap;
|
|
12281
|
+
function setErrorMap(map) {
|
|
12282
|
+
overrideErrorMap = map;
|
|
12283
|
+
}
|
|
11873
12284
|
exports.setErrorMap = setErrorMap;
|
|
12285
|
+
function getErrorMap() {
|
|
12286
|
+
return overrideErrorMap;
|
|
12287
|
+
}
|
|
12288
|
+
exports.getErrorMap = getErrorMap;
|
|
11874
12289
|
|
|
11875
12290
|
|
|
11876
12291
|
/***/ }),
|
|
11877
12292
|
|
|
11878
|
-
/***/
|
|
12293
|
+
/***/ 8857:
|
|
11879
12294
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
11880
12295
|
|
|
11881
12296
|
"use strict";
|
|
11882
12297
|
|
|
11883
12298
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11884
12299
|
if (k2 === undefined) k2 = k;
|
|
11885
|
-
|
|
11886
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11887
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11888
|
-
}
|
|
11889
|
-
Object.defineProperty(o, k2, desc);
|
|
12300
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
11890
12301
|
}) : (function(o, m, k, k2) {
|
|
11891
12302
|
if (k2 === undefined) k2 = k;
|
|
11892
12303
|
o[k2] = m[k];
|
|
@@ -11895,15 +12306,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11895
12306
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11896
12307
|
};
|
|
11897
12308
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11898
|
-
|
|
11899
|
-
__exportStar(__nccwpck_require__(
|
|
11900
|
-
__exportStar(__nccwpck_require__(
|
|
11901
|
-
|
|
12309
|
+
exports.ZodParsedType = exports.getParsedType = void 0;
|
|
12310
|
+
__exportStar(__nccwpck_require__(7822), exports);
|
|
12311
|
+
__exportStar(__nccwpck_require__(6836), exports);
|
|
12312
|
+
var util_1 = __nccwpck_require__(809);
|
|
12313
|
+
Object.defineProperty(exports, "getParsedType", ({ enumerable: true, get: function () { return util_1.getParsedType; } }));
|
|
12314
|
+
Object.defineProperty(exports, "ZodParsedType", ({ enumerable: true, get: function () { return util_1.ZodParsedType; } }));
|
|
12315
|
+
__exportStar(__nccwpck_require__(54), exports);
|
|
12316
|
+
__exportStar(__nccwpck_require__(6597), exports);
|
|
11902
12317
|
|
|
11903
12318
|
|
|
11904
12319
|
/***/ }),
|
|
11905
12320
|
|
|
11906
|
-
/***/
|
|
12321
|
+
/***/ 3797:
|
|
11907
12322
|
/***/ ((__unused_webpack_module, exports) => {
|
|
11908
12323
|
|
|
11909
12324
|
"use strict";
|
|
@@ -11919,80 +12334,14 @@ var errorUtil;
|
|
|
11919
12334
|
|
|
11920
12335
|
/***/ }),
|
|
11921
12336
|
|
|
11922
|
-
/***/
|
|
12337
|
+
/***/ 7822:
|
|
11923
12338
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
11924
12339
|
|
|
11925
12340
|
"use strict";
|
|
11926
12341
|
|
|
11927
12342
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11928
|
-
exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue =
|
|
11929
|
-
const ZodError_1 = __nccwpck_require__(
|
|
11930
|
-
const util_1 = __nccwpck_require__(977);
|
|
11931
|
-
exports.ZodParsedType = util_1.util.arrayToEnum([
|
|
11932
|
-
"string",
|
|
11933
|
-
"nan",
|
|
11934
|
-
"number",
|
|
11935
|
-
"integer",
|
|
11936
|
-
"float",
|
|
11937
|
-
"boolean",
|
|
11938
|
-
"date",
|
|
11939
|
-
"bigint",
|
|
11940
|
-
"symbol",
|
|
11941
|
-
"function",
|
|
11942
|
-
"undefined",
|
|
11943
|
-
"null",
|
|
11944
|
-
"array",
|
|
11945
|
-
"object",
|
|
11946
|
-
"unknown",
|
|
11947
|
-
"promise",
|
|
11948
|
-
"void",
|
|
11949
|
-
"never",
|
|
11950
|
-
"map",
|
|
11951
|
-
"set",
|
|
11952
|
-
]);
|
|
11953
|
-
const getParsedType = (data) => {
|
|
11954
|
-
const t = typeof data;
|
|
11955
|
-
switch (t) {
|
|
11956
|
-
case "undefined":
|
|
11957
|
-
return exports.ZodParsedType.undefined;
|
|
11958
|
-
case "string":
|
|
11959
|
-
return exports.ZodParsedType.string;
|
|
11960
|
-
case "number":
|
|
11961
|
-
return isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number;
|
|
11962
|
-
case "boolean":
|
|
11963
|
-
return exports.ZodParsedType.boolean;
|
|
11964
|
-
case "function":
|
|
11965
|
-
return exports.ZodParsedType.function;
|
|
11966
|
-
case "bigint":
|
|
11967
|
-
return exports.ZodParsedType.bigint;
|
|
11968
|
-
case "object":
|
|
11969
|
-
if (Array.isArray(data)) {
|
|
11970
|
-
return exports.ZodParsedType.array;
|
|
11971
|
-
}
|
|
11972
|
-
if (data === null) {
|
|
11973
|
-
return exports.ZodParsedType.null;
|
|
11974
|
-
}
|
|
11975
|
-
if (data.then &&
|
|
11976
|
-
typeof data.then === "function" &&
|
|
11977
|
-
data.catch &&
|
|
11978
|
-
typeof data.catch === "function") {
|
|
11979
|
-
return exports.ZodParsedType.promise;
|
|
11980
|
-
}
|
|
11981
|
-
if (typeof Map !== "undefined" && data instanceof Map) {
|
|
11982
|
-
return exports.ZodParsedType.map;
|
|
11983
|
-
}
|
|
11984
|
-
if (typeof Set !== "undefined" && data instanceof Set) {
|
|
11985
|
-
return exports.ZodParsedType.set;
|
|
11986
|
-
}
|
|
11987
|
-
if (typeof Date !== "undefined" && data instanceof Date) {
|
|
11988
|
-
return exports.ZodParsedType.date;
|
|
11989
|
-
}
|
|
11990
|
-
return exports.ZodParsedType.object;
|
|
11991
|
-
default:
|
|
11992
|
-
return exports.ZodParsedType.unknown;
|
|
11993
|
-
}
|
|
11994
|
-
};
|
|
11995
|
-
exports.getParsedType = getParsedType;
|
|
12343
|
+
exports.jsonStringifyReplacer = exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = void 0;
|
|
12344
|
+
const ZodError_1 = __nccwpck_require__(6597);
|
|
11996
12345
|
const makeIssue = (params) => {
|
|
11997
12346
|
const { data, path, errorMaps, issueData } = params;
|
|
11998
12347
|
const fullPath = [...path, ...(issueData.path || [])];
|
|
@@ -12017,15 +12366,15 @@ const makeIssue = (params) => {
|
|
|
12017
12366
|
exports.makeIssue = makeIssue;
|
|
12018
12367
|
exports.EMPTY_PATH = [];
|
|
12019
12368
|
function addIssueToContext(ctx, issueData) {
|
|
12020
|
-
const issue =
|
|
12369
|
+
const issue = exports.makeIssue({
|
|
12021
12370
|
issueData: issueData,
|
|
12022
12371
|
data: ctx.data,
|
|
12023
12372
|
path: ctx.path,
|
|
12024
12373
|
errorMaps: [
|
|
12025
12374
|
ctx.common.contextualErrorMap,
|
|
12026
12375
|
ctx.schemaErrorMap,
|
|
12027
|
-
ZodError_1.
|
|
12028
|
-
ZodError_1.defaultErrorMap,
|
|
12376
|
+
ZodError_1.getErrorMap(),
|
|
12377
|
+
ZodError_1.defaultErrorMap,
|
|
12029
12378
|
].filter((x) => !!x),
|
|
12030
12379
|
});
|
|
12031
12380
|
ctx.common.issues.push(issue);
|
|
@@ -12099,11 +12448,18 @@ const isValid = (x) => x.status === "valid";
|
|
|
12099
12448
|
exports.isValid = isValid;
|
|
12100
12449
|
const isAsync = (x) => typeof Promise !== undefined && x instanceof Promise;
|
|
12101
12450
|
exports.isAsync = isAsync;
|
|
12451
|
+
const jsonStringifyReplacer = (_, value) => {
|
|
12452
|
+
if (typeof value === "bigint") {
|
|
12453
|
+
return value.toString();
|
|
12454
|
+
}
|
|
12455
|
+
return value;
|
|
12456
|
+
};
|
|
12457
|
+
exports.jsonStringifyReplacer = jsonStringifyReplacer;
|
|
12102
12458
|
|
|
12103
12459
|
|
|
12104
12460
|
/***/ }),
|
|
12105
12461
|
|
|
12106
|
-
/***/
|
|
12462
|
+
/***/ 6836:
|
|
12107
12463
|
/***/ ((__unused_webpack_module, exports) => {
|
|
12108
12464
|
|
|
12109
12465
|
"use strict";
|
|
@@ -12113,15 +12469,18 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
12113
12469
|
|
|
12114
12470
|
/***/ }),
|
|
12115
12471
|
|
|
12116
|
-
/***/
|
|
12472
|
+
/***/ 809:
|
|
12117
12473
|
/***/ ((__unused_webpack_module, exports) => {
|
|
12118
12474
|
|
|
12119
12475
|
"use strict";
|
|
12120
12476
|
|
|
12121
12477
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
12122
|
-
exports.util = void 0;
|
|
12478
|
+
exports.getParsedType = exports.ZodParsedType = exports.util = void 0;
|
|
12123
12479
|
var util;
|
|
12124
12480
|
(function (util) {
|
|
12481
|
+
util.assertEqual = (val) => val;
|
|
12482
|
+
function assertIs(_arg) { }
|
|
12483
|
+
util.assertIs = assertIs;
|
|
12125
12484
|
function assertNever(_x) {
|
|
12126
12485
|
throw new Error();
|
|
12127
12486
|
}
|
|
@@ -12167,23 +12526,90 @@ var util;
|
|
|
12167
12526
|
util.isInteger = typeof Number.isInteger === "function"
|
|
12168
12527
|
? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
|
|
12169
12528
|
: (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
|
|
12529
|
+
function joinValues(array, separator = " | ") {
|
|
12530
|
+
return array
|
|
12531
|
+
.map((val) => (typeof val === "string" ? `'${val}'` : val))
|
|
12532
|
+
.join(separator);
|
|
12533
|
+
}
|
|
12534
|
+
util.joinValues = joinValues;
|
|
12170
12535
|
})(util = exports.util || (exports.util = {}));
|
|
12536
|
+
exports.ZodParsedType = util.arrayToEnum([
|
|
12537
|
+
"string",
|
|
12538
|
+
"nan",
|
|
12539
|
+
"number",
|
|
12540
|
+
"integer",
|
|
12541
|
+
"float",
|
|
12542
|
+
"boolean",
|
|
12543
|
+
"date",
|
|
12544
|
+
"bigint",
|
|
12545
|
+
"symbol",
|
|
12546
|
+
"function",
|
|
12547
|
+
"undefined",
|
|
12548
|
+
"null",
|
|
12549
|
+
"array",
|
|
12550
|
+
"object",
|
|
12551
|
+
"unknown",
|
|
12552
|
+
"promise",
|
|
12553
|
+
"void",
|
|
12554
|
+
"never",
|
|
12555
|
+
"map",
|
|
12556
|
+
"set",
|
|
12557
|
+
]);
|
|
12558
|
+
const getParsedType = (data) => {
|
|
12559
|
+
const t = typeof data;
|
|
12560
|
+
switch (t) {
|
|
12561
|
+
case "undefined":
|
|
12562
|
+
return exports.ZodParsedType.undefined;
|
|
12563
|
+
case "string":
|
|
12564
|
+
return exports.ZodParsedType.string;
|
|
12565
|
+
case "number":
|
|
12566
|
+
return isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number;
|
|
12567
|
+
case "boolean":
|
|
12568
|
+
return exports.ZodParsedType.boolean;
|
|
12569
|
+
case "function":
|
|
12570
|
+
return exports.ZodParsedType.function;
|
|
12571
|
+
case "bigint":
|
|
12572
|
+
return exports.ZodParsedType.bigint;
|
|
12573
|
+
case "object":
|
|
12574
|
+
if (Array.isArray(data)) {
|
|
12575
|
+
return exports.ZodParsedType.array;
|
|
12576
|
+
}
|
|
12577
|
+
if (data === null) {
|
|
12578
|
+
return exports.ZodParsedType.null;
|
|
12579
|
+
}
|
|
12580
|
+
if (data.then &&
|
|
12581
|
+
typeof data.then === "function" &&
|
|
12582
|
+
data.catch &&
|
|
12583
|
+
typeof data.catch === "function") {
|
|
12584
|
+
return exports.ZodParsedType.promise;
|
|
12585
|
+
}
|
|
12586
|
+
if (typeof Map !== "undefined" && data instanceof Map) {
|
|
12587
|
+
return exports.ZodParsedType.map;
|
|
12588
|
+
}
|
|
12589
|
+
if (typeof Set !== "undefined" && data instanceof Set) {
|
|
12590
|
+
return exports.ZodParsedType.set;
|
|
12591
|
+
}
|
|
12592
|
+
if (typeof Date !== "undefined" && data instanceof Date) {
|
|
12593
|
+
return exports.ZodParsedType.date;
|
|
12594
|
+
}
|
|
12595
|
+
return exports.ZodParsedType.object;
|
|
12596
|
+
default:
|
|
12597
|
+
return exports.ZodParsedType.unknown;
|
|
12598
|
+
}
|
|
12599
|
+
};
|
|
12600
|
+
exports.getParsedType = getParsedType;
|
|
12171
12601
|
|
|
12172
12602
|
|
|
12173
12603
|
/***/ }),
|
|
12174
12604
|
|
|
12175
|
-
/***/
|
|
12605
|
+
/***/ 8062:
|
|
12176
12606
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
12177
12607
|
|
|
12178
12608
|
"use strict";
|
|
12179
12609
|
|
|
12180
12610
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12181
12611
|
if (k2 === undefined) k2 = k;
|
|
12182
|
-
|
|
12183
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12184
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12185
|
-
}
|
|
12186
|
-
Object.defineProperty(o, k2, desc);
|
|
12612
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12187
12613
|
}) : (function(o, m, k, k2) {
|
|
12188
12614
|
if (k2 === undefined) k2 = k;
|
|
12189
12615
|
o[k2] = m[k];
|
|
@@ -12205,26 +12631,26 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12205
12631
|
};
|
|
12206
12632
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
12207
12633
|
exports.z = void 0;
|
|
12208
|
-
const mod = __importStar(__nccwpck_require__(
|
|
12634
|
+
const mod = __importStar(__nccwpck_require__(8857));
|
|
12209
12635
|
exports.z = mod;
|
|
12210
|
-
__exportStar(__nccwpck_require__(
|
|
12636
|
+
__exportStar(__nccwpck_require__(8857), exports);
|
|
12211
12637
|
exports["default"] = mod;
|
|
12212
12638
|
|
|
12213
12639
|
|
|
12214
12640
|
/***/ }),
|
|
12215
12641
|
|
|
12216
|
-
/***/
|
|
12642
|
+
/***/ 54:
|
|
12217
12643
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
12218
12644
|
|
|
12219
12645
|
"use strict";
|
|
12220
12646
|
|
|
12221
12647
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
12222
|
-
exports
|
|
12223
|
-
exports["void"] = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports["null"] = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = void 0;
|
|
12224
|
-
const errorUtil_1 = __nccwpck_require__(
|
|
12225
|
-
const parseUtil_1 = __nccwpck_require__(
|
|
12226
|
-
const util_1 = __nccwpck_require__(
|
|
12227
|
-
const ZodError_1 = __nccwpck_require__(
|
|
12648
|
+
exports["function"] = exports["enum"] = exports.effect = exports.discriminatedUnion = exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.objectUtil = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0;
|
|
12649
|
+
exports["void"] = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports["null"] = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports["instanceof"] = void 0;
|
|
12650
|
+
const errorUtil_1 = __nccwpck_require__(3797);
|
|
12651
|
+
const parseUtil_1 = __nccwpck_require__(7822);
|
|
12652
|
+
const util_1 = __nccwpck_require__(809);
|
|
12653
|
+
const ZodError_1 = __nccwpck_require__(6597);
|
|
12228
12654
|
class ParseInputLazyPath {
|
|
12229
12655
|
constructor(parent, value, path, key) {
|
|
12230
12656
|
this.parent = parent;
|
|
@@ -12237,7 +12663,7 @@ class ParseInputLazyPath {
|
|
|
12237
12663
|
}
|
|
12238
12664
|
}
|
|
12239
12665
|
const handleResult = (ctx, result) => {
|
|
12240
|
-
if (
|
|
12666
|
+
if (parseUtil_1.isValid(result)) {
|
|
12241
12667
|
return { success: true, data: result.value };
|
|
12242
12668
|
}
|
|
12243
12669
|
else {
|
|
@@ -12260,11 +12686,10 @@ function processCreateParams(params) {
|
|
|
12260
12686
|
const customMap = (iss, ctx) => {
|
|
12261
12687
|
if (iss.code !== "invalid_type")
|
|
12262
12688
|
return { message: ctx.defaultError };
|
|
12263
|
-
if (typeof ctx.data === "undefined"
|
|
12264
|
-
return { message: required_error };
|
|
12265
|
-
|
|
12266
|
-
|
|
12267
|
-
return { message: ctx.defaultError };
|
|
12689
|
+
if (typeof ctx.data === "undefined") {
|
|
12690
|
+
return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
|
|
12691
|
+
}
|
|
12692
|
+
return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
|
|
12268
12693
|
};
|
|
12269
12694
|
return { errorMap: customMap, description };
|
|
12270
12695
|
}
|
|
@@ -12299,13 +12724,13 @@ class ZodType {
|
|
|
12299
12724
|
return this._def.description;
|
|
12300
12725
|
}
|
|
12301
12726
|
_getType(input) {
|
|
12302
|
-
return
|
|
12727
|
+
return util_1.getParsedType(input.data);
|
|
12303
12728
|
}
|
|
12304
12729
|
_getOrReturnCtx(input, ctx) {
|
|
12305
12730
|
return (ctx || {
|
|
12306
12731
|
common: input.parent.common,
|
|
12307
12732
|
data: input.data,
|
|
12308
|
-
parsedType:
|
|
12733
|
+
parsedType: util_1.getParsedType(input.data),
|
|
12309
12734
|
schemaErrorMap: this._def.errorMap,
|
|
12310
12735
|
path: input.path,
|
|
12311
12736
|
parent: input.parent,
|
|
@@ -12317,7 +12742,7 @@ class ZodType {
|
|
|
12317
12742
|
ctx: {
|
|
12318
12743
|
common: input.parent.common,
|
|
12319
12744
|
data: input.data,
|
|
12320
|
-
parsedType:
|
|
12745
|
+
parsedType: util_1.getParsedType(input.data),
|
|
12321
12746
|
schemaErrorMap: this._def.errorMap,
|
|
12322
12747
|
path: input.path,
|
|
12323
12748
|
parent: input.parent,
|
|
@@ -12326,7 +12751,7 @@ class ZodType {
|
|
|
12326
12751
|
}
|
|
12327
12752
|
_parseSync(input) {
|
|
12328
12753
|
const result = this._parse(input);
|
|
12329
|
-
if (
|
|
12754
|
+
if (parseUtil_1.isAsync(result)) {
|
|
12330
12755
|
throw new Error("Synchronous parse encountered promise.");
|
|
12331
12756
|
}
|
|
12332
12757
|
return result;
|
|
@@ -12347,14 +12772,13 @@ class ZodType {
|
|
|
12347
12772
|
common: {
|
|
12348
12773
|
issues: [],
|
|
12349
12774
|
async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
|
|
12350
|
-
typeCache: typeof Map !== "undefined" ? new Map() : undefined,
|
|
12351
12775
|
contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
|
|
12352
12776
|
},
|
|
12353
12777
|
path: (params === null || params === void 0 ? void 0 : params.path) || [],
|
|
12354
12778
|
schemaErrorMap: this._def.errorMap,
|
|
12355
12779
|
parent: null,
|
|
12356
12780
|
data,
|
|
12357
|
-
parsedType:
|
|
12781
|
+
parsedType: util_1.getParsedType(data),
|
|
12358
12782
|
};
|
|
12359
12783
|
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
|
12360
12784
|
return handleResult(ctx, result);
|
|
@@ -12371,16 +12795,15 @@ class ZodType {
|
|
|
12371
12795
|
issues: [],
|
|
12372
12796
|
contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
|
|
12373
12797
|
async: true,
|
|
12374
|
-
typeCache: typeof Map !== "undefined" ? new Map() : undefined,
|
|
12375
12798
|
},
|
|
12376
12799
|
path: (params === null || params === void 0 ? void 0 : params.path) || [],
|
|
12377
12800
|
schemaErrorMap: this._def.errorMap,
|
|
12378
12801
|
parent: null,
|
|
12379
12802
|
data,
|
|
12380
|
-
parsedType:
|
|
12803
|
+
parsedType: util_1.getParsedType(data),
|
|
12381
12804
|
};
|
|
12382
12805
|
const maybeAsyncResult = this._parse({ data, path: [], parent: ctx });
|
|
12383
|
-
const result = await (
|
|
12806
|
+
const result = await (parseUtil_1.isAsync(maybeAsyncResult)
|
|
12384
12807
|
? maybeAsyncResult
|
|
12385
12808
|
: Promise.resolve(maybeAsyncResult));
|
|
12386
12809
|
return handleResult(ctx, result);
|
|
@@ -12444,8 +12867,6 @@ class ZodType {
|
|
|
12444
12867
|
});
|
|
12445
12868
|
}
|
|
12446
12869
|
optional() {
|
|
12447
|
-
("");
|
|
12448
|
-
("asdf");
|
|
12449
12870
|
return ZodOptional.create(this);
|
|
12450
12871
|
}
|
|
12451
12872
|
nullable() {
|
|
@@ -12481,6 +12902,13 @@ class ZodType {
|
|
|
12481
12902
|
typeName: ZodFirstPartyTypeKind.ZodDefault,
|
|
12482
12903
|
});
|
|
12483
12904
|
}
|
|
12905
|
+
brand() {
|
|
12906
|
+
return new ZodBranded({
|
|
12907
|
+
typeName: ZodFirstPartyTypeKind.ZodBranded,
|
|
12908
|
+
type: this,
|
|
12909
|
+
...processCreateParams(undefined),
|
|
12910
|
+
});
|
|
12911
|
+
}
|
|
12484
12912
|
describe(description) {
|
|
12485
12913
|
const This = this.constructor;
|
|
12486
12914
|
return new This({
|
|
@@ -12514,18 +12942,22 @@ class ZodString extends ZodType {
|
|
|
12514
12942
|
...errorUtil_1.errorUtil.errToObj(message),
|
|
12515
12943
|
});
|
|
12516
12944
|
/**
|
|
12517
|
-
*
|
|
12518
|
-
*
|
|
12945
|
+
* @deprecated Use z.string().min(1) instead.
|
|
12946
|
+
* @see {@link ZodString.min}
|
|
12519
12947
|
*/
|
|
12520
12948
|
this.nonempty = (message) => this.min(1, errorUtil_1.errorUtil.errToObj(message));
|
|
12949
|
+
this.trim = () => new ZodString({
|
|
12950
|
+
...this._def,
|
|
12951
|
+
checks: [...this._def.checks, { kind: "trim" }],
|
|
12952
|
+
});
|
|
12521
12953
|
}
|
|
12522
12954
|
_parse(input) {
|
|
12523
12955
|
const parsedType = this._getType(input);
|
|
12524
|
-
if (parsedType !==
|
|
12956
|
+
if (parsedType !== util_1.ZodParsedType.string) {
|
|
12525
12957
|
const ctx = this._getOrReturnCtx(input);
|
|
12526
|
-
|
|
12958
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12527
12959
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
12528
|
-
expected:
|
|
12960
|
+
expected: util_1.ZodParsedType.string,
|
|
12529
12961
|
received: ctx.parsedType,
|
|
12530
12962
|
}
|
|
12531
12963
|
//
|
|
@@ -12538,7 +12970,7 @@ class ZodString extends ZodType {
|
|
|
12538
12970
|
if (check.kind === "min") {
|
|
12539
12971
|
if (input.data.length < check.value) {
|
|
12540
12972
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
12541
|
-
|
|
12973
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12542
12974
|
code: ZodError_1.ZodIssueCode.too_small,
|
|
12543
12975
|
minimum: check.value,
|
|
12544
12976
|
type: "string",
|
|
@@ -12551,7 +12983,7 @@ class ZodString extends ZodType {
|
|
|
12551
12983
|
else if (check.kind === "max") {
|
|
12552
12984
|
if (input.data.length > check.value) {
|
|
12553
12985
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
12554
|
-
|
|
12986
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12555
12987
|
code: ZodError_1.ZodIssueCode.too_big,
|
|
12556
12988
|
maximum: check.value,
|
|
12557
12989
|
type: "string",
|
|
@@ -12564,7 +12996,7 @@ class ZodString extends ZodType {
|
|
|
12564
12996
|
else if (check.kind === "email") {
|
|
12565
12997
|
if (!emailRegex.test(input.data)) {
|
|
12566
12998
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
12567
|
-
|
|
12999
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12568
13000
|
validation: "email",
|
|
12569
13001
|
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
12570
13002
|
message: check.message,
|
|
@@ -12575,7 +13007,7 @@ class ZodString extends ZodType {
|
|
|
12575
13007
|
else if (check.kind === "uuid") {
|
|
12576
13008
|
if (!uuidRegex.test(input.data)) {
|
|
12577
13009
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
12578
|
-
|
|
13010
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12579
13011
|
validation: "uuid",
|
|
12580
13012
|
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
12581
13013
|
message: check.message,
|
|
@@ -12586,7 +13018,7 @@ class ZodString extends ZodType {
|
|
|
12586
13018
|
else if (check.kind === "cuid") {
|
|
12587
13019
|
if (!cuidRegex.test(input.data)) {
|
|
12588
13020
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
12589
|
-
|
|
13021
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12590
13022
|
validation: "cuid",
|
|
12591
13023
|
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
12592
13024
|
message: check.message,
|
|
@@ -12600,7 +13032,7 @@ class ZodString extends ZodType {
|
|
|
12600
13032
|
}
|
|
12601
13033
|
catch (_a) {
|
|
12602
13034
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
12603
|
-
|
|
13035
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12604
13036
|
validation: "url",
|
|
12605
13037
|
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
12606
13038
|
message: check.message,
|
|
@@ -12613,7 +13045,7 @@ class ZodString extends ZodType {
|
|
|
12613
13045
|
const testResult = check.regex.test(input.data);
|
|
12614
13046
|
if (!testResult) {
|
|
12615
13047
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
12616
|
-
|
|
13048
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12617
13049
|
validation: "regex",
|
|
12618
13050
|
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
12619
13051
|
message: check.message,
|
|
@@ -12621,6 +13053,34 @@ class ZodString extends ZodType {
|
|
|
12621
13053
|
status.dirty();
|
|
12622
13054
|
}
|
|
12623
13055
|
}
|
|
13056
|
+
else if (check.kind === "trim") {
|
|
13057
|
+
input.data = input.data.trim();
|
|
13058
|
+
}
|
|
13059
|
+
else if (check.kind === "startsWith") {
|
|
13060
|
+
if (!input.data.startsWith(check.value)) {
|
|
13061
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
13062
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13063
|
+
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
13064
|
+
validation: { startsWith: check.value },
|
|
13065
|
+
message: check.message,
|
|
13066
|
+
});
|
|
13067
|
+
status.dirty();
|
|
13068
|
+
}
|
|
13069
|
+
}
|
|
13070
|
+
else if (check.kind === "endsWith") {
|
|
13071
|
+
if (!input.data.endsWith(check.value)) {
|
|
13072
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
13073
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13074
|
+
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
13075
|
+
validation: { endsWith: check.value },
|
|
13076
|
+
message: check.message,
|
|
13077
|
+
});
|
|
13078
|
+
status.dirty();
|
|
13079
|
+
}
|
|
13080
|
+
}
|
|
13081
|
+
else {
|
|
13082
|
+
util_1.util.assertNever(check);
|
|
13083
|
+
}
|
|
12624
13084
|
}
|
|
12625
13085
|
return { status: status.value, value: input.data };
|
|
12626
13086
|
}
|
|
@@ -12649,6 +13109,20 @@ class ZodString extends ZodType {
|
|
|
12649
13109
|
...errorUtil_1.errorUtil.errToObj(message),
|
|
12650
13110
|
});
|
|
12651
13111
|
}
|
|
13112
|
+
startsWith(value, message) {
|
|
13113
|
+
return this._addCheck({
|
|
13114
|
+
kind: "startsWith",
|
|
13115
|
+
value: value,
|
|
13116
|
+
...errorUtil_1.errorUtil.errToObj(message),
|
|
13117
|
+
});
|
|
13118
|
+
}
|
|
13119
|
+
endsWith(value, message) {
|
|
13120
|
+
return this._addCheck({
|
|
13121
|
+
kind: "endsWith",
|
|
13122
|
+
value: value,
|
|
13123
|
+
...errorUtil_1.errorUtil.errToObj(message),
|
|
13124
|
+
});
|
|
13125
|
+
}
|
|
12652
13126
|
min(minLength, message) {
|
|
12653
13127
|
return this._addCheck({
|
|
12654
13128
|
kind: "min",
|
|
@@ -12679,25 +13153,23 @@ class ZodString extends ZodType {
|
|
|
12679
13153
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
12680
13154
|
}
|
|
12681
13155
|
get minLength() {
|
|
12682
|
-
let min =
|
|
12683
|
-
this._def.checks
|
|
13156
|
+
let min = null;
|
|
13157
|
+
for (const ch of this._def.checks) {
|
|
12684
13158
|
if (ch.kind === "min") {
|
|
12685
|
-
if (min === null || ch.value > min)
|
|
13159
|
+
if (min === null || ch.value > min)
|
|
12686
13160
|
min = ch.value;
|
|
12687
|
-
}
|
|
12688
13161
|
}
|
|
12689
|
-
}
|
|
13162
|
+
}
|
|
12690
13163
|
return min;
|
|
12691
13164
|
}
|
|
12692
13165
|
get maxLength() {
|
|
12693
13166
|
let max = null;
|
|
12694
|
-
this._def.checks
|
|
13167
|
+
for (const ch of this._def.checks) {
|
|
12695
13168
|
if (ch.kind === "max") {
|
|
12696
|
-
if (max === null || ch.value < max)
|
|
13169
|
+
if (max === null || ch.value < max)
|
|
12697
13170
|
max = ch.value;
|
|
12698
|
-
}
|
|
12699
13171
|
}
|
|
12700
|
-
}
|
|
13172
|
+
}
|
|
12701
13173
|
return max;
|
|
12702
13174
|
}
|
|
12703
13175
|
}
|
|
@@ -12727,11 +13199,11 @@ class ZodNumber extends ZodType {
|
|
|
12727
13199
|
}
|
|
12728
13200
|
_parse(input) {
|
|
12729
13201
|
const parsedType = this._getType(input);
|
|
12730
|
-
if (parsedType !==
|
|
13202
|
+
if (parsedType !== util_1.ZodParsedType.number) {
|
|
12731
13203
|
const ctx = this._getOrReturnCtx(input);
|
|
12732
|
-
|
|
13204
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12733
13205
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
12734
|
-
expected:
|
|
13206
|
+
expected: util_1.ZodParsedType.number,
|
|
12735
13207
|
received: ctx.parsedType,
|
|
12736
13208
|
});
|
|
12737
13209
|
return parseUtil_1.INVALID;
|
|
@@ -12742,7 +13214,7 @@ class ZodNumber extends ZodType {
|
|
|
12742
13214
|
if (check.kind === "int") {
|
|
12743
13215
|
if (!util_1.util.isInteger(input.data)) {
|
|
12744
13216
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
12745
|
-
|
|
13217
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12746
13218
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
12747
13219
|
expected: "integer",
|
|
12748
13220
|
received: "float",
|
|
@@ -12757,7 +13229,7 @@ class ZodNumber extends ZodType {
|
|
|
12757
13229
|
: input.data <= check.value;
|
|
12758
13230
|
if (tooSmall) {
|
|
12759
13231
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
12760
|
-
|
|
13232
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12761
13233
|
code: ZodError_1.ZodIssueCode.too_small,
|
|
12762
13234
|
minimum: check.value,
|
|
12763
13235
|
type: "number",
|
|
@@ -12773,7 +13245,7 @@ class ZodNumber extends ZodType {
|
|
|
12773
13245
|
: input.data >= check.value;
|
|
12774
13246
|
if (tooBig) {
|
|
12775
13247
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
12776
|
-
|
|
13248
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12777
13249
|
code: ZodError_1.ZodIssueCode.too_big,
|
|
12778
13250
|
maximum: check.value,
|
|
12779
13251
|
type: "number",
|
|
@@ -12786,7 +13258,7 @@ class ZodNumber extends ZodType {
|
|
|
12786
13258
|
else if (check.kind === "multipleOf") {
|
|
12787
13259
|
if (floatSafeRemainder(input.data, check.value) !== 0) {
|
|
12788
13260
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
12789
|
-
|
|
13261
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12790
13262
|
code: ZodError_1.ZodIssueCode.not_multiple_of,
|
|
12791
13263
|
multipleOf: check.value,
|
|
12792
13264
|
message: check.message,
|
|
@@ -12912,16 +13384,16 @@ ZodNumber.create = (params) => {
|
|
|
12912
13384
|
class ZodBigInt extends ZodType {
|
|
12913
13385
|
_parse(input) {
|
|
12914
13386
|
const parsedType = this._getType(input);
|
|
12915
|
-
if (parsedType !==
|
|
13387
|
+
if (parsedType !== util_1.ZodParsedType.bigint) {
|
|
12916
13388
|
const ctx = this._getOrReturnCtx(input);
|
|
12917
|
-
|
|
13389
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12918
13390
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
12919
|
-
expected:
|
|
13391
|
+
expected: util_1.ZodParsedType.bigint,
|
|
12920
13392
|
received: ctx.parsedType,
|
|
12921
13393
|
});
|
|
12922
13394
|
return parseUtil_1.INVALID;
|
|
12923
13395
|
}
|
|
12924
|
-
return
|
|
13396
|
+
return parseUtil_1.OK(input.data);
|
|
12925
13397
|
}
|
|
12926
13398
|
}
|
|
12927
13399
|
exports.ZodBigInt = ZodBigInt;
|
|
@@ -12934,16 +13406,16 @@ ZodBigInt.create = (params) => {
|
|
|
12934
13406
|
class ZodBoolean extends ZodType {
|
|
12935
13407
|
_parse(input) {
|
|
12936
13408
|
const parsedType = this._getType(input);
|
|
12937
|
-
if (parsedType !==
|
|
13409
|
+
if (parsedType !== util_1.ZodParsedType.boolean) {
|
|
12938
13410
|
const ctx = this._getOrReturnCtx(input);
|
|
12939
|
-
|
|
13411
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12940
13412
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
12941
|
-
expected:
|
|
13413
|
+
expected: util_1.ZodParsedType.boolean,
|
|
12942
13414
|
received: ctx.parsedType,
|
|
12943
13415
|
});
|
|
12944
13416
|
return parseUtil_1.INVALID;
|
|
12945
13417
|
}
|
|
12946
|
-
return
|
|
13418
|
+
return parseUtil_1.OK(input.data);
|
|
12947
13419
|
}
|
|
12948
13420
|
}
|
|
12949
13421
|
exports.ZodBoolean = ZodBoolean;
|
|
@@ -12956,31 +13428,105 @@ ZodBoolean.create = (params) => {
|
|
|
12956
13428
|
class ZodDate extends ZodType {
|
|
12957
13429
|
_parse(input) {
|
|
12958
13430
|
const parsedType = this._getType(input);
|
|
12959
|
-
if (parsedType !==
|
|
13431
|
+
if (parsedType !== util_1.ZodParsedType.date) {
|
|
12960
13432
|
const ctx = this._getOrReturnCtx(input);
|
|
12961
|
-
|
|
13433
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12962
13434
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
12963
|
-
expected:
|
|
13435
|
+
expected: util_1.ZodParsedType.date,
|
|
12964
13436
|
received: ctx.parsedType,
|
|
12965
13437
|
});
|
|
12966
13438
|
return parseUtil_1.INVALID;
|
|
12967
13439
|
}
|
|
12968
13440
|
if (isNaN(input.data.getTime())) {
|
|
12969
13441
|
const ctx = this._getOrReturnCtx(input);
|
|
12970
|
-
|
|
13442
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12971
13443
|
code: ZodError_1.ZodIssueCode.invalid_date,
|
|
12972
13444
|
});
|
|
12973
13445
|
return parseUtil_1.INVALID;
|
|
12974
13446
|
}
|
|
13447
|
+
const status = new parseUtil_1.ParseStatus();
|
|
13448
|
+
let ctx = undefined;
|
|
13449
|
+
for (const check of this._def.checks) {
|
|
13450
|
+
if (check.kind === "min") {
|
|
13451
|
+
if (input.data.getTime() < check.value) {
|
|
13452
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
13453
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13454
|
+
code: ZodError_1.ZodIssueCode.too_small,
|
|
13455
|
+
message: check.message,
|
|
13456
|
+
inclusive: true,
|
|
13457
|
+
minimum: check.value,
|
|
13458
|
+
type: "date",
|
|
13459
|
+
});
|
|
13460
|
+
status.dirty();
|
|
13461
|
+
}
|
|
13462
|
+
}
|
|
13463
|
+
else if (check.kind === "max") {
|
|
13464
|
+
if (input.data.getTime() > check.value) {
|
|
13465
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
13466
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13467
|
+
code: ZodError_1.ZodIssueCode.too_big,
|
|
13468
|
+
message: check.message,
|
|
13469
|
+
inclusive: true,
|
|
13470
|
+
maximum: check.value,
|
|
13471
|
+
type: "date",
|
|
13472
|
+
});
|
|
13473
|
+
status.dirty();
|
|
13474
|
+
}
|
|
13475
|
+
}
|
|
13476
|
+
else {
|
|
13477
|
+
util_1.util.assertNever(check);
|
|
13478
|
+
}
|
|
13479
|
+
}
|
|
12975
13480
|
return {
|
|
12976
|
-
status:
|
|
13481
|
+
status: status.value,
|
|
12977
13482
|
value: new Date(input.data.getTime()),
|
|
12978
13483
|
};
|
|
12979
13484
|
}
|
|
13485
|
+
_addCheck(check) {
|
|
13486
|
+
return new ZodDate({
|
|
13487
|
+
...this._def,
|
|
13488
|
+
checks: [...this._def.checks, check],
|
|
13489
|
+
});
|
|
13490
|
+
}
|
|
13491
|
+
min(minDate, message) {
|
|
13492
|
+
return this._addCheck({
|
|
13493
|
+
kind: "min",
|
|
13494
|
+
value: minDate.getTime(),
|
|
13495
|
+
message: errorUtil_1.errorUtil.toString(message),
|
|
13496
|
+
});
|
|
13497
|
+
}
|
|
13498
|
+
max(maxDate, message) {
|
|
13499
|
+
return this._addCheck({
|
|
13500
|
+
kind: "max",
|
|
13501
|
+
value: maxDate.getTime(),
|
|
13502
|
+
message: errorUtil_1.errorUtil.toString(message),
|
|
13503
|
+
});
|
|
13504
|
+
}
|
|
13505
|
+
get minDate() {
|
|
13506
|
+
let min = null;
|
|
13507
|
+
for (const ch of this._def.checks) {
|
|
13508
|
+
if (ch.kind === "min") {
|
|
13509
|
+
if (min === null || ch.value > min)
|
|
13510
|
+
min = ch.value;
|
|
13511
|
+
}
|
|
13512
|
+
}
|
|
13513
|
+
return min != null ? new Date(min) : null;
|
|
13514
|
+
}
|
|
13515
|
+
get maxDate() {
|
|
13516
|
+
let max = null;
|
|
13517
|
+
for (const ch of this._def.checks) {
|
|
13518
|
+
if (ch.kind === "max") {
|
|
13519
|
+
if (max === null || ch.value < max)
|
|
13520
|
+
max = ch.value;
|
|
13521
|
+
}
|
|
13522
|
+
}
|
|
13523
|
+
return max != null ? new Date(max) : null;
|
|
13524
|
+
}
|
|
12980
13525
|
}
|
|
12981
13526
|
exports.ZodDate = ZodDate;
|
|
12982
13527
|
ZodDate.create = (params) => {
|
|
12983
13528
|
return new ZodDate({
|
|
13529
|
+
checks: [],
|
|
12984
13530
|
typeName: ZodFirstPartyTypeKind.ZodDate,
|
|
12985
13531
|
...processCreateParams(params),
|
|
12986
13532
|
});
|
|
@@ -12988,16 +13534,16 @@ ZodDate.create = (params) => {
|
|
|
12988
13534
|
class ZodUndefined extends ZodType {
|
|
12989
13535
|
_parse(input) {
|
|
12990
13536
|
const parsedType = this._getType(input);
|
|
12991
|
-
if (parsedType !==
|
|
13537
|
+
if (parsedType !== util_1.ZodParsedType.undefined) {
|
|
12992
13538
|
const ctx = this._getOrReturnCtx(input);
|
|
12993
|
-
|
|
13539
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
12994
13540
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
12995
|
-
expected:
|
|
13541
|
+
expected: util_1.ZodParsedType.undefined,
|
|
12996
13542
|
received: ctx.parsedType,
|
|
12997
13543
|
});
|
|
12998
13544
|
return parseUtil_1.INVALID;
|
|
12999
13545
|
}
|
|
13000
|
-
return
|
|
13546
|
+
return parseUtil_1.OK(input.data);
|
|
13001
13547
|
}
|
|
13002
13548
|
}
|
|
13003
13549
|
exports.ZodUndefined = ZodUndefined;
|
|
@@ -13010,16 +13556,16 @@ ZodUndefined.create = (params) => {
|
|
|
13010
13556
|
class ZodNull extends ZodType {
|
|
13011
13557
|
_parse(input) {
|
|
13012
13558
|
const parsedType = this._getType(input);
|
|
13013
|
-
if (parsedType !==
|
|
13559
|
+
if (parsedType !== util_1.ZodParsedType.null) {
|
|
13014
13560
|
const ctx = this._getOrReturnCtx(input);
|
|
13015
|
-
|
|
13561
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13016
13562
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
13017
|
-
expected:
|
|
13563
|
+
expected: util_1.ZodParsedType.null,
|
|
13018
13564
|
received: ctx.parsedType,
|
|
13019
13565
|
});
|
|
13020
13566
|
return parseUtil_1.INVALID;
|
|
13021
13567
|
}
|
|
13022
|
-
return
|
|
13568
|
+
return parseUtil_1.OK(input.data);
|
|
13023
13569
|
}
|
|
13024
13570
|
}
|
|
13025
13571
|
exports.ZodNull = ZodNull;
|
|
@@ -13036,7 +13582,7 @@ class ZodAny extends ZodType {
|
|
|
13036
13582
|
this._any = true;
|
|
13037
13583
|
}
|
|
13038
13584
|
_parse(input) {
|
|
13039
|
-
return
|
|
13585
|
+
return parseUtil_1.OK(input.data);
|
|
13040
13586
|
}
|
|
13041
13587
|
}
|
|
13042
13588
|
exports.ZodAny = ZodAny;
|
|
@@ -13053,7 +13599,7 @@ class ZodUnknown extends ZodType {
|
|
|
13053
13599
|
this._unknown = true;
|
|
13054
13600
|
}
|
|
13055
13601
|
_parse(input) {
|
|
13056
|
-
return
|
|
13602
|
+
return parseUtil_1.OK(input.data);
|
|
13057
13603
|
}
|
|
13058
13604
|
}
|
|
13059
13605
|
exports.ZodUnknown = ZodUnknown;
|
|
@@ -13066,9 +13612,9 @@ ZodUnknown.create = (params) => {
|
|
|
13066
13612
|
class ZodNever extends ZodType {
|
|
13067
13613
|
_parse(input) {
|
|
13068
13614
|
const ctx = this._getOrReturnCtx(input);
|
|
13069
|
-
|
|
13615
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13070
13616
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
13071
|
-
expected:
|
|
13617
|
+
expected: util_1.ZodParsedType.never,
|
|
13072
13618
|
received: ctx.parsedType,
|
|
13073
13619
|
});
|
|
13074
13620
|
return parseUtil_1.INVALID;
|
|
@@ -13084,16 +13630,16 @@ ZodNever.create = (params) => {
|
|
|
13084
13630
|
class ZodVoid extends ZodType {
|
|
13085
13631
|
_parse(input) {
|
|
13086
13632
|
const parsedType = this._getType(input);
|
|
13087
|
-
if (parsedType !==
|
|
13633
|
+
if (parsedType !== util_1.ZodParsedType.undefined) {
|
|
13088
13634
|
const ctx = this._getOrReturnCtx(input);
|
|
13089
|
-
|
|
13635
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13090
13636
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
13091
|
-
expected:
|
|
13637
|
+
expected: util_1.ZodParsedType.void,
|
|
13092
13638
|
received: ctx.parsedType,
|
|
13093
13639
|
});
|
|
13094
13640
|
return parseUtil_1.INVALID;
|
|
13095
13641
|
}
|
|
13096
|
-
return
|
|
13642
|
+
return parseUtil_1.OK(input.data);
|
|
13097
13643
|
}
|
|
13098
13644
|
}
|
|
13099
13645
|
exports.ZodVoid = ZodVoid;
|
|
@@ -13107,17 +13653,17 @@ class ZodArray extends ZodType {
|
|
|
13107
13653
|
_parse(input) {
|
|
13108
13654
|
const { ctx, status } = this._processInputParams(input);
|
|
13109
13655
|
const def = this._def;
|
|
13110
|
-
if (ctx.parsedType !==
|
|
13111
|
-
|
|
13656
|
+
if (ctx.parsedType !== util_1.ZodParsedType.array) {
|
|
13657
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13112
13658
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
13113
|
-
expected:
|
|
13659
|
+
expected: util_1.ZodParsedType.array,
|
|
13114
13660
|
received: ctx.parsedType,
|
|
13115
13661
|
});
|
|
13116
13662
|
return parseUtil_1.INVALID;
|
|
13117
13663
|
}
|
|
13118
13664
|
if (def.minLength !== null) {
|
|
13119
13665
|
if (ctx.data.length < def.minLength.value) {
|
|
13120
|
-
|
|
13666
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13121
13667
|
code: ZodError_1.ZodIssueCode.too_small,
|
|
13122
13668
|
minimum: def.minLength.value,
|
|
13123
13669
|
type: "array",
|
|
@@ -13129,7 +13675,7 @@ class ZodArray extends ZodType {
|
|
|
13129
13675
|
}
|
|
13130
13676
|
if (def.maxLength !== null) {
|
|
13131
13677
|
if (ctx.data.length > def.maxLength.value) {
|
|
13132
|
-
|
|
13678
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13133
13679
|
code: ZodError_1.ZodIssueCode.too_big,
|
|
13134
13680
|
maximum: def.maxLength.value,
|
|
13135
13681
|
type: "array",
|
|
@@ -13195,7 +13741,7 @@ var objectUtil;
|
|
|
13195
13741
|
objectUtil.mergeShapes = (first, second) => {
|
|
13196
13742
|
return {
|
|
13197
13743
|
...first,
|
|
13198
|
-
...second,
|
|
13744
|
+
...second,
|
|
13199
13745
|
};
|
|
13200
13746
|
};
|
|
13201
13747
|
})(objectUtil = exports.objectUtil || (exports.objectUtil = {}));
|
|
@@ -13257,19 +13803,23 @@ class ZodObject extends ZodType {
|
|
|
13257
13803
|
}
|
|
13258
13804
|
_parse(input) {
|
|
13259
13805
|
const parsedType = this._getType(input);
|
|
13260
|
-
if (parsedType !==
|
|
13806
|
+
if (parsedType !== util_1.ZodParsedType.object) {
|
|
13261
13807
|
const ctx = this._getOrReturnCtx(input);
|
|
13262
|
-
|
|
13808
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13263
13809
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
13264
|
-
expected:
|
|
13810
|
+
expected: util_1.ZodParsedType.object,
|
|
13265
13811
|
received: ctx.parsedType,
|
|
13266
13812
|
});
|
|
13267
13813
|
return parseUtil_1.INVALID;
|
|
13268
13814
|
}
|
|
13269
13815
|
const { status, ctx } = this._processInputParams(input);
|
|
13270
13816
|
const { shape, keys: shapeKeys } = this._getCached();
|
|
13271
|
-
const
|
|
13272
|
-
const
|
|
13817
|
+
const extraKeys = [];
|
|
13818
|
+
for (const key in ctx.data) {
|
|
13819
|
+
if (!shapeKeys.includes(key)) {
|
|
13820
|
+
extraKeys.push(key);
|
|
13821
|
+
}
|
|
13822
|
+
}
|
|
13273
13823
|
const pairs = [];
|
|
13274
13824
|
for (const key of shapeKeys) {
|
|
13275
13825
|
const keyValidator = shape[key];
|
|
@@ -13292,7 +13842,7 @@ class ZodObject extends ZodType {
|
|
|
13292
13842
|
}
|
|
13293
13843
|
else if (unknownKeys === "strict") {
|
|
13294
13844
|
if (extraKeys.length > 0) {
|
|
13295
|
-
|
|
13845
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13296
13846
|
code: ZodError_1.ZodIssueCode.unrecognized_keys,
|
|
13297
13847
|
keys: extraKeys,
|
|
13298
13848
|
});
|
|
@@ -13407,7 +13957,9 @@ class ZodObject extends ZodType {
|
|
|
13407
13957
|
pick(mask) {
|
|
13408
13958
|
const shape = {};
|
|
13409
13959
|
util_1.util.objectKeys(mask).map((key) => {
|
|
13410
|
-
shape
|
|
13960
|
+
// only add to shape if key corresponds to an element of the current shape
|
|
13961
|
+
if (this.shape[key])
|
|
13962
|
+
shape[key] = this.shape[key];
|
|
13411
13963
|
});
|
|
13412
13964
|
return new ZodObject({
|
|
13413
13965
|
...this._def,
|
|
@@ -13471,6 +14023,9 @@ class ZodObject extends ZodType {
|
|
|
13471
14023
|
shape: () => newShape,
|
|
13472
14024
|
});
|
|
13473
14025
|
}
|
|
14026
|
+
keyof() {
|
|
14027
|
+
return createZodEnum(util_1.util.objectKeys(this.shape));
|
|
14028
|
+
}
|
|
13474
14029
|
}
|
|
13475
14030
|
exports.ZodObject = ZodObject;
|
|
13476
14031
|
ZodObject.create = (shape, params) => {
|
|
@@ -13520,7 +14075,7 @@ class ZodUnion extends ZodType {
|
|
|
13520
14075
|
}
|
|
13521
14076
|
// return invalid
|
|
13522
14077
|
const unionErrors = results.map((result) => new ZodError_1.ZodError(result.ctx.common.issues));
|
|
13523
|
-
|
|
14078
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13524
14079
|
code: ZodError_1.ZodIssueCode.invalid_union,
|
|
13525
14080
|
unionErrors,
|
|
13526
14081
|
});
|
|
@@ -13578,7 +14133,7 @@ class ZodUnion extends ZodType {
|
|
|
13578
14133
|
return dirty.result;
|
|
13579
14134
|
}
|
|
13580
14135
|
const unionErrors = issues.map((issues) => new ZodError_1.ZodError(issues));
|
|
13581
|
-
|
|
14136
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13582
14137
|
code: ZodError_1.ZodIssueCode.invalid_union,
|
|
13583
14138
|
unionErrors,
|
|
13584
14139
|
});
|
|
@@ -13600,10 +14155,10 @@ ZodUnion.create = (types, params) => {
|
|
|
13600
14155
|
class ZodDiscriminatedUnion extends ZodType {
|
|
13601
14156
|
_parse(input) {
|
|
13602
14157
|
const { ctx } = this._processInputParams(input);
|
|
13603
|
-
if (ctx.parsedType !==
|
|
13604
|
-
|
|
14158
|
+
if (ctx.parsedType !== util_1.ZodParsedType.object) {
|
|
14159
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13605
14160
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
13606
|
-
expected:
|
|
14161
|
+
expected: util_1.ZodParsedType.object,
|
|
13607
14162
|
received: ctx.parsedType,
|
|
13608
14163
|
});
|
|
13609
14164
|
return parseUtil_1.INVALID;
|
|
@@ -13612,7 +14167,7 @@ class ZodDiscriminatedUnion extends ZodType {
|
|
|
13612
14167
|
const discriminatorValue = ctx.data[discriminator];
|
|
13613
14168
|
const option = this.options.get(discriminatorValue);
|
|
13614
14169
|
if (!option) {
|
|
13615
|
-
|
|
14170
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13616
14171
|
code: ZodError_1.ZodIssueCode.invalid_union_discriminator,
|
|
13617
14172
|
options: this.validDiscriminatorValues,
|
|
13618
14173
|
path: [discriminator],
|
|
@@ -13677,12 +14232,12 @@ class ZodDiscriminatedUnion extends ZodType {
|
|
|
13677
14232
|
}
|
|
13678
14233
|
exports.ZodDiscriminatedUnion = ZodDiscriminatedUnion;
|
|
13679
14234
|
function mergeValues(a, b) {
|
|
13680
|
-
const aType =
|
|
13681
|
-
const bType =
|
|
14235
|
+
const aType = util_1.getParsedType(a);
|
|
14236
|
+
const bType = util_1.getParsedType(b);
|
|
13682
14237
|
if (a === b) {
|
|
13683
14238
|
return { valid: true, data: a };
|
|
13684
14239
|
}
|
|
13685
|
-
else if (aType ===
|
|
14240
|
+
else if (aType === util_1.ZodParsedType.object && bType === util_1.ZodParsedType.object) {
|
|
13686
14241
|
const bKeys = util_1.util.objectKeys(b);
|
|
13687
14242
|
const sharedKeys = util_1.util
|
|
13688
14243
|
.objectKeys(a)
|
|
@@ -13697,7 +14252,7 @@ function mergeValues(a, b) {
|
|
|
13697
14252
|
}
|
|
13698
14253
|
return { valid: true, data: newObj };
|
|
13699
14254
|
}
|
|
13700
|
-
else if (aType ===
|
|
14255
|
+
else if (aType === util_1.ZodParsedType.array && bType === util_1.ZodParsedType.array) {
|
|
13701
14256
|
if (a.length !== b.length) {
|
|
13702
14257
|
return { valid: false };
|
|
13703
14258
|
}
|
|
@@ -13713,8 +14268,8 @@ function mergeValues(a, b) {
|
|
|
13713
14268
|
}
|
|
13714
14269
|
return { valid: true, data: newArray };
|
|
13715
14270
|
}
|
|
13716
|
-
else if (aType ===
|
|
13717
|
-
bType ===
|
|
14271
|
+
else if (aType === util_1.ZodParsedType.date &&
|
|
14272
|
+
bType === util_1.ZodParsedType.date &&
|
|
13718
14273
|
+a === +b) {
|
|
13719
14274
|
return { valid: true, data: a };
|
|
13720
14275
|
}
|
|
@@ -13726,17 +14281,17 @@ class ZodIntersection extends ZodType {
|
|
|
13726
14281
|
_parse(input) {
|
|
13727
14282
|
const { status, ctx } = this._processInputParams(input);
|
|
13728
14283
|
const handleParsed = (parsedLeft, parsedRight) => {
|
|
13729
|
-
if (
|
|
14284
|
+
if (parseUtil_1.isAborted(parsedLeft) || parseUtil_1.isAborted(parsedRight)) {
|
|
13730
14285
|
return parseUtil_1.INVALID;
|
|
13731
14286
|
}
|
|
13732
14287
|
const merged = mergeValues(parsedLeft.value, parsedRight.value);
|
|
13733
14288
|
if (!merged.valid) {
|
|
13734
|
-
|
|
14289
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13735
14290
|
code: ZodError_1.ZodIssueCode.invalid_intersection_types,
|
|
13736
14291
|
});
|
|
13737
14292
|
return parseUtil_1.INVALID;
|
|
13738
14293
|
}
|
|
13739
|
-
if (
|
|
14294
|
+
if (parseUtil_1.isDirty(parsedLeft) || parseUtil_1.isDirty(parsedRight)) {
|
|
13740
14295
|
status.dirty();
|
|
13741
14296
|
}
|
|
13742
14297
|
return { status: status.value, value: merged.data };
|
|
@@ -13780,16 +14335,16 @@ ZodIntersection.create = (left, right, params) => {
|
|
|
13780
14335
|
class ZodTuple extends ZodType {
|
|
13781
14336
|
_parse(input) {
|
|
13782
14337
|
const { status, ctx } = this._processInputParams(input);
|
|
13783
|
-
if (ctx.parsedType !==
|
|
13784
|
-
|
|
14338
|
+
if (ctx.parsedType !== util_1.ZodParsedType.array) {
|
|
14339
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13785
14340
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
13786
|
-
expected:
|
|
14341
|
+
expected: util_1.ZodParsedType.array,
|
|
13787
14342
|
received: ctx.parsedType,
|
|
13788
14343
|
});
|
|
13789
14344
|
return parseUtil_1.INVALID;
|
|
13790
14345
|
}
|
|
13791
14346
|
if (ctx.data.length < this._def.items.length) {
|
|
13792
|
-
|
|
14347
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13793
14348
|
code: ZodError_1.ZodIssueCode.too_small,
|
|
13794
14349
|
minimum: this._def.items.length,
|
|
13795
14350
|
inclusive: true,
|
|
@@ -13799,7 +14354,7 @@ class ZodTuple extends ZodType {
|
|
|
13799
14354
|
}
|
|
13800
14355
|
const rest = this._def.rest;
|
|
13801
14356
|
if (!rest && ctx.data.length > this._def.items.length) {
|
|
13802
|
-
|
|
14357
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13803
14358
|
code: ZodError_1.ZodIssueCode.too_big,
|
|
13804
14359
|
maximum: this._def.items.length,
|
|
13805
14360
|
inclusive: true,
|
|
@@ -13852,10 +14407,10 @@ class ZodRecord extends ZodType {
|
|
|
13852
14407
|
}
|
|
13853
14408
|
_parse(input) {
|
|
13854
14409
|
const { status, ctx } = this._processInputParams(input);
|
|
13855
|
-
if (ctx.parsedType !==
|
|
13856
|
-
|
|
14410
|
+
if (ctx.parsedType !== util_1.ZodParsedType.object) {
|
|
14411
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13857
14412
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
13858
|
-
expected:
|
|
14413
|
+
expected: util_1.ZodParsedType.object,
|
|
13859
14414
|
received: ctx.parsedType,
|
|
13860
14415
|
});
|
|
13861
14416
|
return parseUtil_1.INVALID;
|
|
@@ -13900,10 +14455,10 @@ exports.ZodRecord = ZodRecord;
|
|
|
13900
14455
|
class ZodMap extends ZodType {
|
|
13901
14456
|
_parse(input) {
|
|
13902
14457
|
const { status, ctx } = this._processInputParams(input);
|
|
13903
|
-
if (ctx.parsedType !==
|
|
13904
|
-
|
|
14458
|
+
if (ctx.parsedType !== util_1.ZodParsedType.map) {
|
|
14459
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13905
14460
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
13906
|
-
expected:
|
|
14461
|
+
expected: util_1.ZodParsedType.map,
|
|
13907
14462
|
received: ctx.parsedType,
|
|
13908
14463
|
});
|
|
13909
14464
|
return parseUtil_1.INVALID;
|
|
@@ -13962,10 +14517,10 @@ ZodMap.create = (keyType, valueType, params) => {
|
|
|
13962
14517
|
class ZodSet extends ZodType {
|
|
13963
14518
|
_parse(input) {
|
|
13964
14519
|
const { status, ctx } = this._processInputParams(input);
|
|
13965
|
-
if (ctx.parsedType !==
|
|
13966
|
-
|
|
14520
|
+
if (ctx.parsedType !== util_1.ZodParsedType.set) {
|
|
14521
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13967
14522
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
13968
|
-
expected:
|
|
14523
|
+
expected: util_1.ZodParsedType.set,
|
|
13969
14524
|
received: ctx.parsedType,
|
|
13970
14525
|
});
|
|
13971
14526
|
return parseUtil_1.INVALID;
|
|
@@ -13973,7 +14528,7 @@ class ZodSet extends ZodType {
|
|
|
13973
14528
|
const def = this._def;
|
|
13974
14529
|
if (def.minSize !== null) {
|
|
13975
14530
|
if (ctx.data.size < def.minSize.value) {
|
|
13976
|
-
|
|
14531
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13977
14532
|
code: ZodError_1.ZodIssueCode.too_small,
|
|
13978
14533
|
minimum: def.minSize.value,
|
|
13979
14534
|
type: "set",
|
|
@@ -13985,7 +14540,7 @@ class ZodSet extends ZodType {
|
|
|
13985
14540
|
}
|
|
13986
14541
|
if (def.maxSize !== null) {
|
|
13987
14542
|
if (ctx.data.size > def.maxSize.value) {
|
|
13988
|
-
|
|
14543
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
13989
14544
|
code: ZodError_1.ZodIssueCode.too_big,
|
|
13990
14545
|
maximum: def.maxSize.value,
|
|
13991
14546
|
type: "set",
|
|
@@ -14051,22 +14606,22 @@ class ZodFunction extends ZodType {
|
|
|
14051
14606
|
}
|
|
14052
14607
|
_parse(input) {
|
|
14053
14608
|
const { ctx } = this._processInputParams(input);
|
|
14054
|
-
if (ctx.parsedType !==
|
|
14055
|
-
|
|
14609
|
+
if (ctx.parsedType !== util_1.ZodParsedType.function) {
|
|
14610
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
14056
14611
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
14057
|
-
expected:
|
|
14612
|
+
expected: util_1.ZodParsedType.function,
|
|
14058
14613
|
received: ctx.parsedType,
|
|
14059
14614
|
});
|
|
14060
14615
|
return parseUtil_1.INVALID;
|
|
14061
14616
|
}
|
|
14062
14617
|
function makeArgsIssue(args, error) {
|
|
14063
|
-
return
|
|
14618
|
+
return parseUtil_1.makeIssue({
|
|
14064
14619
|
data: args,
|
|
14065
14620
|
path: ctx.path,
|
|
14066
14621
|
errorMaps: [
|
|
14067
14622
|
ctx.common.contextualErrorMap,
|
|
14068
14623
|
ctx.schemaErrorMap,
|
|
14069
|
-
ZodError_1.
|
|
14624
|
+
ZodError_1.getErrorMap(),
|
|
14070
14625
|
ZodError_1.defaultErrorMap,
|
|
14071
14626
|
].filter((x) => !!x),
|
|
14072
14627
|
issueData: {
|
|
@@ -14076,13 +14631,13 @@ class ZodFunction extends ZodType {
|
|
|
14076
14631
|
});
|
|
14077
14632
|
}
|
|
14078
14633
|
function makeReturnsIssue(returns, error) {
|
|
14079
|
-
return
|
|
14634
|
+
return parseUtil_1.makeIssue({
|
|
14080
14635
|
data: returns,
|
|
14081
14636
|
path: ctx.path,
|
|
14082
14637
|
errorMaps: [
|
|
14083
14638
|
ctx.common.contextualErrorMap,
|
|
14084
14639
|
ctx.schemaErrorMap,
|
|
14085
|
-
ZodError_1.
|
|
14640
|
+
ZodError_1.getErrorMap(),
|
|
14086
14641
|
ZodError_1.defaultErrorMap,
|
|
14087
14642
|
].filter((x) => !!x),
|
|
14088
14643
|
issueData: {
|
|
@@ -14094,7 +14649,7 @@ class ZodFunction extends ZodType {
|
|
|
14094
14649
|
const params = { errorMap: ctx.common.contextualErrorMap };
|
|
14095
14650
|
const fn = ctx.data;
|
|
14096
14651
|
if (this._def.returns instanceof ZodPromise) {
|
|
14097
|
-
return
|
|
14652
|
+
return parseUtil_1.OK(async (...args) => {
|
|
14098
14653
|
const error = new ZodError_1.ZodError([]);
|
|
14099
14654
|
const parsedArgs = await this._def.args
|
|
14100
14655
|
.parseAsync(args, params)
|
|
@@ -14113,7 +14668,7 @@ class ZodFunction extends ZodType {
|
|
|
14113
14668
|
});
|
|
14114
14669
|
}
|
|
14115
14670
|
else {
|
|
14116
|
-
return
|
|
14671
|
+
return parseUtil_1.OK((...args) => {
|
|
14117
14672
|
const parsedArgs = this._def.args.safeParse(args, params);
|
|
14118
14673
|
if (!parsedArgs.success) {
|
|
14119
14674
|
throw new ZodError_1.ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
@@ -14187,10 +14742,9 @@ class ZodLiteral extends ZodType {
|
|
|
14187
14742
|
_parse(input) {
|
|
14188
14743
|
if (input.data !== this._def.value) {
|
|
14189
14744
|
const ctx = this._getOrReturnCtx(input);
|
|
14190
|
-
|
|
14191
|
-
code: ZodError_1.ZodIssueCode.
|
|
14192
|
-
expected:
|
|
14193
|
-
received: ctx.parsedType,
|
|
14745
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
14746
|
+
code: ZodError_1.ZodIssueCode.invalid_literal,
|
|
14747
|
+
expected: this._def.value,
|
|
14194
14748
|
});
|
|
14195
14749
|
return parseUtil_1.INVALID;
|
|
14196
14750
|
}
|
|
@@ -14208,23 +14762,36 @@ ZodLiteral.create = (value, params) => {
|
|
|
14208
14762
|
...processCreateParams(params),
|
|
14209
14763
|
});
|
|
14210
14764
|
};
|
|
14211
|
-
function createZodEnum(values) {
|
|
14765
|
+
function createZodEnum(values, params) {
|
|
14212
14766
|
return new ZodEnum({
|
|
14213
14767
|
values: values,
|
|
14214
14768
|
typeName: ZodFirstPartyTypeKind.ZodEnum,
|
|
14769
|
+
...processCreateParams(params),
|
|
14215
14770
|
});
|
|
14216
14771
|
}
|
|
14217
14772
|
class ZodEnum extends ZodType {
|
|
14218
14773
|
_parse(input) {
|
|
14774
|
+
if (typeof input.data !== "string") {
|
|
14775
|
+
const ctx = this._getOrReturnCtx(input);
|
|
14776
|
+
const expectedValues = this._def.values;
|
|
14777
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
14778
|
+
expected: util_1.util.joinValues(expectedValues),
|
|
14779
|
+
received: ctx.parsedType,
|
|
14780
|
+
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
14781
|
+
});
|
|
14782
|
+
return parseUtil_1.INVALID;
|
|
14783
|
+
}
|
|
14219
14784
|
if (this._def.values.indexOf(input.data) === -1) {
|
|
14220
14785
|
const ctx = this._getOrReturnCtx(input);
|
|
14221
|
-
|
|
14786
|
+
const expectedValues = this._def.values;
|
|
14787
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
14788
|
+
received: ctx.data,
|
|
14222
14789
|
code: ZodError_1.ZodIssueCode.invalid_enum_value,
|
|
14223
|
-
options:
|
|
14790
|
+
options: expectedValues,
|
|
14224
14791
|
});
|
|
14225
14792
|
return parseUtil_1.INVALID;
|
|
14226
14793
|
}
|
|
14227
|
-
return
|
|
14794
|
+
return parseUtil_1.OK(input.data);
|
|
14228
14795
|
}
|
|
14229
14796
|
get options() {
|
|
14230
14797
|
return this._def.values;
|
|
@@ -14256,15 +14823,27 @@ ZodEnum.create = createZodEnum;
|
|
|
14256
14823
|
class ZodNativeEnum extends ZodType {
|
|
14257
14824
|
_parse(input) {
|
|
14258
14825
|
const nativeEnumValues = util_1.util.getValidEnumValues(this._def.values);
|
|
14826
|
+
const ctx = this._getOrReturnCtx(input);
|
|
14827
|
+
if (ctx.parsedType !== util_1.ZodParsedType.string &&
|
|
14828
|
+
ctx.parsedType !== util_1.ZodParsedType.number) {
|
|
14829
|
+
const expectedValues = util_1.util.objectValues(nativeEnumValues);
|
|
14830
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
14831
|
+
expected: util_1.util.joinValues(expectedValues),
|
|
14832
|
+
received: ctx.parsedType,
|
|
14833
|
+
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
14834
|
+
});
|
|
14835
|
+
return parseUtil_1.INVALID;
|
|
14836
|
+
}
|
|
14259
14837
|
if (nativeEnumValues.indexOf(input.data) === -1) {
|
|
14260
|
-
const
|
|
14261
|
-
|
|
14838
|
+
const expectedValues = util_1.util.objectValues(nativeEnumValues);
|
|
14839
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
14840
|
+
received: ctx.data,
|
|
14262
14841
|
code: ZodError_1.ZodIssueCode.invalid_enum_value,
|
|
14263
|
-
options:
|
|
14842
|
+
options: expectedValues,
|
|
14264
14843
|
});
|
|
14265
14844
|
return parseUtil_1.INVALID;
|
|
14266
14845
|
}
|
|
14267
|
-
return
|
|
14846
|
+
return parseUtil_1.OK(input.data);
|
|
14268
14847
|
}
|
|
14269
14848
|
get enum() {
|
|
14270
14849
|
return this._def.values;
|
|
@@ -14281,19 +14860,19 @@ ZodNativeEnum.create = (values, params) => {
|
|
|
14281
14860
|
class ZodPromise extends ZodType {
|
|
14282
14861
|
_parse(input) {
|
|
14283
14862
|
const { ctx } = this._processInputParams(input);
|
|
14284
|
-
if (ctx.parsedType !==
|
|
14863
|
+
if (ctx.parsedType !== util_1.ZodParsedType.promise &&
|
|
14285
14864
|
ctx.common.async === false) {
|
|
14286
|
-
|
|
14865
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
14287
14866
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
14288
|
-
expected:
|
|
14867
|
+
expected: util_1.ZodParsedType.promise,
|
|
14289
14868
|
received: ctx.parsedType,
|
|
14290
14869
|
});
|
|
14291
14870
|
return parseUtil_1.INVALID;
|
|
14292
14871
|
}
|
|
14293
|
-
const promisified = ctx.parsedType ===
|
|
14872
|
+
const promisified = ctx.parsedType === util_1.ZodParsedType.promise
|
|
14294
14873
|
? ctx.data
|
|
14295
14874
|
: Promise.resolve(ctx.data);
|
|
14296
|
-
return
|
|
14875
|
+
return parseUtil_1.OK(promisified.then((data) => {
|
|
14297
14876
|
return this._def.type.parseAsync(data, {
|
|
14298
14877
|
path: ctx.path,
|
|
14299
14878
|
errorMap: ctx.common.contextualErrorMap,
|
|
@@ -14335,22 +14914,22 @@ class ZodEffects extends ZodType {
|
|
|
14335
14914
|
});
|
|
14336
14915
|
}
|
|
14337
14916
|
}
|
|
14917
|
+
const checkCtx = {
|
|
14918
|
+
addIssue: (arg) => {
|
|
14919
|
+
parseUtil_1.addIssueToContext(ctx, arg);
|
|
14920
|
+
if (arg.fatal) {
|
|
14921
|
+
status.abort();
|
|
14922
|
+
}
|
|
14923
|
+
else {
|
|
14924
|
+
status.dirty();
|
|
14925
|
+
}
|
|
14926
|
+
},
|
|
14927
|
+
get path() {
|
|
14928
|
+
return ctx.path;
|
|
14929
|
+
},
|
|
14930
|
+
};
|
|
14931
|
+
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
14338
14932
|
if (effect.type === "refinement") {
|
|
14339
|
-
const checkCtx = {
|
|
14340
|
-
addIssue: (arg) => {
|
|
14341
|
-
(0, parseUtil_1.addIssueToContext)(ctx, arg);
|
|
14342
|
-
if (arg.fatal) {
|
|
14343
|
-
status.abort();
|
|
14344
|
-
}
|
|
14345
|
-
else {
|
|
14346
|
-
status.dirty();
|
|
14347
|
-
}
|
|
14348
|
-
},
|
|
14349
|
-
get path() {
|
|
14350
|
-
return ctx.path;
|
|
14351
|
-
},
|
|
14352
|
-
};
|
|
14353
|
-
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
14354
14933
|
const executeRefinement = (acc
|
|
14355
14934
|
// effect: RefinementEffect<any>
|
|
14356
14935
|
) => {
|
|
@@ -14402,25 +14981,25 @@ class ZodEffects extends ZodType {
|
|
|
14402
14981
|
// if (base.status === "dirty") {
|
|
14403
14982
|
// return { status: "dirty", value: base.value };
|
|
14404
14983
|
// }
|
|
14405
|
-
if (!
|
|
14984
|
+
if (!parseUtil_1.isValid(base))
|
|
14406
14985
|
return base;
|
|
14407
|
-
const result = effect.transform(base.value);
|
|
14986
|
+
const result = effect.transform(base.value, checkCtx);
|
|
14408
14987
|
if (result instanceof Promise) {
|
|
14409
14988
|
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
14410
14989
|
}
|
|
14411
|
-
return
|
|
14990
|
+
return { status: status.value, value: result };
|
|
14412
14991
|
}
|
|
14413
14992
|
else {
|
|
14414
14993
|
return this._def.schema
|
|
14415
14994
|
._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx })
|
|
14416
14995
|
.then((base) => {
|
|
14417
|
-
if (!
|
|
14996
|
+
if (!parseUtil_1.isValid(base))
|
|
14418
14997
|
return base;
|
|
14419
14998
|
// if (base.status === "aborted") return INVALID;
|
|
14420
14999
|
// if (base.status === "dirty") {
|
|
14421
15000
|
// return { status: "dirty", value: base.value };
|
|
14422
15001
|
// }
|
|
14423
|
-
return Promise.resolve(effect.transform(base.value)).then(
|
|
15002
|
+
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
|
|
14424
15003
|
});
|
|
14425
15004
|
}
|
|
14426
15005
|
}
|
|
@@ -14448,8 +15027,8 @@ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
|
|
|
14448
15027
|
class ZodOptional extends ZodType {
|
|
14449
15028
|
_parse(input) {
|
|
14450
15029
|
const parsedType = this._getType(input);
|
|
14451
|
-
if (parsedType ===
|
|
14452
|
-
return
|
|
15030
|
+
if (parsedType === util_1.ZodParsedType.undefined) {
|
|
15031
|
+
return parseUtil_1.OK(undefined);
|
|
14453
15032
|
}
|
|
14454
15033
|
return this._def.innerType._parse(input);
|
|
14455
15034
|
}
|
|
@@ -14468,8 +15047,8 @@ ZodOptional.create = (type, params) => {
|
|
|
14468
15047
|
class ZodNullable extends ZodType {
|
|
14469
15048
|
_parse(input) {
|
|
14470
15049
|
const parsedType = this._getType(input);
|
|
14471
|
-
if (parsedType ===
|
|
14472
|
-
return
|
|
15050
|
+
if (parsedType === util_1.ZodParsedType.null) {
|
|
15051
|
+
return parseUtil_1.OK(null);
|
|
14473
15052
|
}
|
|
14474
15053
|
return this._def.innerType._parse(input);
|
|
14475
15054
|
}
|
|
@@ -14489,7 +15068,7 @@ class ZodDefault extends ZodType {
|
|
|
14489
15068
|
_parse(input) {
|
|
14490
15069
|
const { ctx } = this._processInputParams(input);
|
|
14491
15070
|
let data = ctx.data;
|
|
14492
|
-
if (ctx.parsedType ===
|
|
15071
|
+
if (ctx.parsedType === util_1.ZodParsedType.undefined) {
|
|
14493
15072
|
data = this._def.defaultValue();
|
|
14494
15073
|
}
|
|
14495
15074
|
return this._def.innerType._parse({
|
|
@@ -14513,11 +15092,11 @@ ZodDefault.create = (type, params) => {
|
|
|
14513
15092
|
class ZodNaN extends ZodType {
|
|
14514
15093
|
_parse(input) {
|
|
14515
15094
|
const parsedType = this._getType(input);
|
|
14516
|
-
if (parsedType !==
|
|
15095
|
+
if (parsedType !== util_1.ZodParsedType.nan) {
|
|
14517
15096
|
const ctx = this._getOrReturnCtx(input);
|
|
14518
|
-
|
|
15097
|
+
parseUtil_1.addIssueToContext(ctx, {
|
|
14519
15098
|
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
14520
|
-
expected:
|
|
15099
|
+
expected: util_1.ZodParsedType.nan,
|
|
14521
15100
|
received: ctx.parsedType,
|
|
14522
15101
|
});
|
|
14523
15102
|
return parseUtil_1.INVALID;
|
|
@@ -14532,9 +15111,31 @@ ZodNaN.create = (params) => {
|
|
|
14532
15111
|
...processCreateParams(params),
|
|
14533
15112
|
});
|
|
14534
15113
|
};
|
|
14535
|
-
|
|
15114
|
+
exports.BRAND = Symbol("zod_brand");
|
|
15115
|
+
class ZodBranded extends ZodType {
|
|
15116
|
+
_parse(input) {
|
|
15117
|
+
const { ctx } = this._processInputParams(input);
|
|
15118
|
+
const data = ctx.data;
|
|
15119
|
+
return this._def.type._parse({
|
|
15120
|
+
data,
|
|
15121
|
+
path: ctx.path,
|
|
15122
|
+
parent: ctx,
|
|
15123
|
+
});
|
|
15124
|
+
}
|
|
15125
|
+
unwrap() {
|
|
15126
|
+
return this._def.type;
|
|
15127
|
+
}
|
|
15128
|
+
}
|
|
15129
|
+
exports.ZodBranded = ZodBranded;
|
|
15130
|
+
const custom = (check, params = {}, fatal) => {
|
|
14536
15131
|
if (check)
|
|
14537
|
-
return ZodAny.create().
|
|
15132
|
+
return ZodAny.create().superRefine((data, ctx) => {
|
|
15133
|
+
if (!check(data)) {
|
|
15134
|
+
const p = typeof params === "function" ? params(data) : params;
|
|
15135
|
+
const p2 = typeof p === "string" ? { message: p } : p;
|
|
15136
|
+
ctx.addIssue({ code: "custom", ...p2, fatal });
|
|
15137
|
+
}
|
|
15138
|
+
});
|
|
14538
15139
|
return ZodAny.create();
|
|
14539
15140
|
};
|
|
14540
15141
|
exports.custom = custom;
|
|
@@ -14574,10 +15175,11 @@ var ZodFirstPartyTypeKind;
|
|
|
14574
15175
|
ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
|
|
14575
15176
|
ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
|
|
14576
15177
|
ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
|
|
15178
|
+
ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
|
|
14577
15179
|
})(ZodFirstPartyTypeKind = exports.ZodFirstPartyTypeKind || (exports.ZodFirstPartyTypeKind = {}));
|
|
14578
15180
|
const instanceOfType = (cls, params = {
|
|
14579
15181
|
message: `Input not instance of ${cls.name}`,
|
|
14580
|
-
}) =>
|
|
15182
|
+
}) => exports.custom((data) => data instanceof cls, params, true);
|
|
14581
15183
|
exports["instanceof"] = instanceOfType;
|
|
14582
15184
|
const stringType = ZodString.create;
|
|
14583
15185
|
exports.string = stringType;
|
|
@@ -14652,98 +15254,6 @@ const oboolean = () => booleanType().optional();
|
|
|
14652
15254
|
exports.oboolean = oboolean;
|
|
14653
15255
|
|
|
14654
15256
|
|
|
14655
|
-
/***/ }),
|
|
14656
|
-
|
|
14657
|
-
/***/ 7271:
|
|
14658
|
-
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
14659
|
-
|
|
14660
|
-
"use strict";
|
|
14661
|
-
|
|
14662
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14663
|
-
if (k2 === undefined) k2 = k;
|
|
14664
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14665
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14666
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14667
|
-
}
|
|
14668
|
-
Object.defineProperty(o, k2, desc);
|
|
14669
|
-
}) : (function(o, m, k, k2) {
|
|
14670
|
-
if (k2 === undefined) k2 = k;
|
|
14671
|
-
o[k2] = m[k];
|
|
14672
|
-
}));
|
|
14673
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14674
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14675
|
-
};
|
|
14676
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
14677
|
-
exports.validateConfig = void 0;
|
|
14678
|
-
const types_1 = __nccwpck_require__(1523);
|
|
14679
|
-
__exportStar(__nccwpck_require__(1523), exports);
|
|
14680
|
-
function validateConfig(config, guard) {
|
|
14681
|
-
const result = guard.safeParse(config);
|
|
14682
|
-
if (!result.success) {
|
|
14683
|
-
throw new types_1.ConnectorError(types_1.ConnectorErrorCodes.InvalidConfig, result.error);
|
|
14684
|
-
}
|
|
14685
|
-
}
|
|
14686
|
-
exports.validateConfig = validateConfig;
|
|
14687
|
-
|
|
14688
|
-
|
|
14689
|
-
/***/ }),
|
|
14690
|
-
|
|
14691
|
-
/***/ 1523:
|
|
14692
|
-
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
14693
|
-
|
|
14694
|
-
"use strict";
|
|
14695
|
-
|
|
14696
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
14697
|
-
exports.messageTypesGuard = exports.MessageTypes = exports.ConnectorError = exports.ConnectorErrorCodes = exports.ConnectorPlatform = exports.ConnectorType = void 0;
|
|
14698
|
-
const zod_1 = __nccwpck_require__(4786);
|
|
14699
|
-
// MARK: Foundation
|
|
14700
|
-
var ConnectorType;
|
|
14701
|
-
(function (ConnectorType) {
|
|
14702
|
-
ConnectorType["Email"] = "Email";
|
|
14703
|
-
ConnectorType["Sms"] = "Sms";
|
|
14704
|
-
ConnectorType["Social"] = "Social";
|
|
14705
|
-
})(ConnectorType = exports.ConnectorType || (exports.ConnectorType = {}));
|
|
14706
|
-
var ConnectorPlatform;
|
|
14707
|
-
(function (ConnectorPlatform) {
|
|
14708
|
-
ConnectorPlatform["Native"] = "Native";
|
|
14709
|
-
ConnectorPlatform["Universal"] = "Universal";
|
|
14710
|
-
ConnectorPlatform["Web"] = "Web";
|
|
14711
|
-
})(ConnectorPlatform = exports.ConnectorPlatform || (exports.ConnectorPlatform = {}));
|
|
14712
|
-
var ConnectorErrorCodes;
|
|
14713
|
-
(function (ConnectorErrorCodes) {
|
|
14714
|
-
ConnectorErrorCodes["General"] = "general";
|
|
14715
|
-
ConnectorErrorCodes["InvalidMetadata"] = "invalid_metadata";
|
|
14716
|
-
ConnectorErrorCodes["UnexpectedType"] = "unexpected_type";
|
|
14717
|
-
ConnectorErrorCodes["InvalidConfigGuard"] = "invalid_config_guard";
|
|
14718
|
-
ConnectorErrorCodes["InsufficientRequestParameters"] = "insufficient_request_parameters";
|
|
14719
|
-
ConnectorErrorCodes["InvalidConfig"] = "invalid_config";
|
|
14720
|
-
ConnectorErrorCodes["InvalidResponse"] = "invalid_response";
|
|
14721
|
-
ConnectorErrorCodes["TemplateNotFound"] = "template_not_found";
|
|
14722
|
-
ConnectorErrorCodes["NotImplemented"] = "not_implemented";
|
|
14723
|
-
ConnectorErrorCodes["SocialAuthCodeInvalid"] = "social_auth_code_invalid";
|
|
14724
|
-
ConnectorErrorCodes["SocialAccessTokenInvalid"] = "social_invalid_access_token";
|
|
14725
|
-
ConnectorErrorCodes["SocialIdTokenInvalid"] = "social_invalid_id_token";
|
|
14726
|
-
ConnectorErrorCodes["AuthorizationFailed"] = "authorization_failed";
|
|
14727
|
-
})(ConnectorErrorCodes = exports.ConnectorErrorCodes || (exports.ConnectorErrorCodes = {}));
|
|
14728
|
-
class ConnectorError extends Error {
|
|
14729
|
-
constructor(code, data) {
|
|
14730
|
-
const message = typeof data === 'string' ? data : 'Connector error occurred.';
|
|
14731
|
-
super(message);
|
|
14732
|
-
this.code = code;
|
|
14733
|
-
this.data = typeof data === 'string' ? { message: data } : data;
|
|
14734
|
-
}
|
|
14735
|
-
}
|
|
14736
|
-
exports.ConnectorError = ConnectorError;
|
|
14737
|
-
var MessageTypes;
|
|
14738
|
-
(function (MessageTypes) {
|
|
14739
|
-
MessageTypes["SignIn"] = "SignIn";
|
|
14740
|
-
MessageTypes["Register"] = "Register";
|
|
14741
|
-
MessageTypes["ForgotPassword"] = "ForgotPassword";
|
|
14742
|
-
MessageTypes["Test"] = "Test";
|
|
14743
|
-
})(MessageTypes = exports.MessageTypes || (exports.MessageTypes = {}));
|
|
14744
|
-
exports.messageTypesGuard = zod_1.z.nativeEnum(MessageTypes);
|
|
14745
|
-
|
|
14746
|
-
|
|
14747
15257
|
/***/ }),
|
|
14748
15258
|
|
|
14749
15259
|
/***/ 87:
|
|
@@ -14753,7 +15263,7 @@ exports.messageTypesGuard = zod_1.z.nativeEnum(MessageTypes);
|
|
|
14753
15263
|
|
|
14754
15264
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
14755
15265
|
exports.defaultTimeout = exports.defaultMetadata = exports.userInfoEndpoint = exports.accessTokenEndpoint = exports.scope = exports.authorizationEndpoint = void 0;
|
|
14756
|
-
const connector_core_1 = __nccwpck_require__(
|
|
15266
|
+
const connector_core_1 = __nccwpck_require__(8697);
|
|
14757
15267
|
exports.authorizationEndpoint = 'https://github.com/login/oauth/authorize';
|
|
14758
15268
|
exports.scope = 'read:user';
|
|
14759
15269
|
exports.accessTokenEndpoint = 'https://github.com/login/oauth/access_token';
|
|
@@ -14772,7 +15282,7 @@ exports.defaultMetadata = {
|
|
|
14772
15282
|
logoDark: './logo-dark.svg',
|
|
14773
15283
|
description: {
|
|
14774
15284
|
en: 'GitHub is an online community for software development and version control.',
|
|
14775
|
-
'zh-CN': 'GitHub
|
|
15285
|
+
'zh-CN': 'GitHub 是极受欢迎的代码托管仓库。',
|
|
14776
15286
|
'tr-TR': 'GitHub, yazılım geliştirme ve sürüm kontrolü için çevrimiçi bir topluluktur.',
|
|
14777
15287
|
'ko-KR': 'GitHub는 소프트웨어 개발과 버전 관리를 위한 온라인 커뮤니티입니다.',
|
|
14778
15288
|
},
|
|
@@ -14814,10 +15324,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
14814
15324
|
};
|
|
14815
15325
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
14816
15326
|
exports.getAccessToken = void 0;
|
|
14817
|
-
const connector_core_1 = __nccwpck_require__(
|
|
15327
|
+
const connector_core_1 = __nccwpck_require__(8697);
|
|
14818
15328
|
const essentials_1 = __nccwpck_require__(8138);
|
|
14819
|
-
const got_1 = __importStar(__nccwpck_require__(
|
|
14820
|
-
const qs = __importStar(__nccwpck_require__(
|
|
15329
|
+
const got_1 = __importStar(__nccwpck_require__(5569));
|
|
15330
|
+
const qs = __importStar(__nccwpck_require__(7348));
|
|
14821
15331
|
const constant_1 = __nccwpck_require__(87);
|
|
14822
15332
|
const types_1 = __nccwpck_require__(7760);
|
|
14823
15333
|
const getAuthorizationUri = (getConfig) => async ({ state, redirectUri }) => {
|
|
@@ -14927,7 +15437,7 @@ exports["default"] = createGithubConnector;
|
|
|
14927
15437
|
|
|
14928
15438
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
14929
15439
|
exports.authResponseGuard = exports.authorizationCallbackErrorGuard = exports.userInfoResponseGuard = exports.accessTokenResponseGuard = exports.githubConfigGuard = void 0;
|
|
14930
|
-
const zod_1 = __nccwpck_require__(
|
|
15440
|
+
const zod_1 = __nccwpck_require__(8062);
|
|
14931
15441
|
exports.githubConfigGuard = zod_1.z.object({
|
|
14932
15442
|
clientId: zod_1.z.string(),
|
|
14933
15443
|
clientSecret: zod_1.z.string(),
|