@tahanabavi/typefetch 1.2.2 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +214 -134
- package/dist/index.d.mts +270 -90
- package/dist/index.d.ts +270 -90
- package/dist/index.js +710 -665
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +709 -666
- package/dist/index.mjs.map +1 -1
- package/package.json +24 -4
package/dist/index.js
CHANGED
|
@@ -1,25 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __pow = Math.pow;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
5
|
var __export = (target, all) => {
|
|
24
6
|
for (var name in all)
|
|
25
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -33,26 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
33
15
|
return to;
|
|
34
16
|
};
|
|
35
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
-
var __async = (__this, __arguments, generator) => {
|
|
37
|
-
return new Promise((resolve, reject) => {
|
|
38
|
-
var fulfilled = (value) => {
|
|
39
|
-
try {
|
|
40
|
-
step(generator.next(value));
|
|
41
|
-
} catch (e) {
|
|
42
|
-
reject(e);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
var rejected = (value) => {
|
|
46
|
-
try {
|
|
47
|
-
step(generator.throw(value));
|
|
48
|
-
} catch (e) {
|
|
49
|
-
reject(e);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
53
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
18
|
|
|
57
19
|
// src/index.ts
|
|
58
20
|
var index_exports = {};
|
|
@@ -62,6 +24,7 @@ __export(index_exports, {
|
|
|
62
24
|
authMiddleware: () => authMiddleware,
|
|
63
25
|
cacheMiddleware: () => cacheMiddleware,
|
|
64
26
|
loggingMiddleware: () => loggingMiddleware,
|
|
27
|
+
makeRequestSchema: () => makeRequestSchema,
|
|
65
28
|
retryMiddleware: () => retryMiddleware
|
|
66
29
|
});
|
|
67
30
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -241,7 +204,11 @@ var util;
|
|
|
241
204
|
var objectUtil;
|
|
242
205
|
(function(objectUtil2) {
|
|
243
206
|
objectUtil2.mergeShapes = (first, second) => {
|
|
244
|
-
return
|
|
207
|
+
return {
|
|
208
|
+
...first,
|
|
209
|
+
...second
|
|
210
|
+
// second overwrites first
|
|
211
|
+
};
|
|
245
212
|
};
|
|
246
213
|
})(objectUtil || (objectUtil = {}));
|
|
247
214
|
var ZodParsedType = util.arrayToEnum([
|
|
@@ -542,24 +509,27 @@ function getErrorMap() {
|
|
|
542
509
|
var makeIssue = (params) => {
|
|
543
510
|
const { data, path, errorMaps, issueData } = params;
|
|
544
511
|
const fullPath = [...path, ...issueData.path || []];
|
|
545
|
-
const fullIssue =
|
|
512
|
+
const fullIssue = {
|
|
513
|
+
...issueData,
|
|
546
514
|
path: fullPath
|
|
547
|
-
}
|
|
515
|
+
};
|
|
548
516
|
if (issueData.message !== void 0) {
|
|
549
|
-
return
|
|
517
|
+
return {
|
|
518
|
+
...issueData,
|
|
550
519
|
path: fullPath,
|
|
551
520
|
message: issueData.message
|
|
552
|
-
}
|
|
521
|
+
};
|
|
553
522
|
}
|
|
554
523
|
let errorMessage = "";
|
|
555
524
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
556
525
|
for (const map of maps) {
|
|
557
526
|
errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
|
|
558
527
|
}
|
|
559
|
-
return
|
|
528
|
+
return {
|
|
529
|
+
...issueData,
|
|
560
530
|
path: fullPath,
|
|
561
531
|
message: errorMessage
|
|
562
|
-
}
|
|
532
|
+
};
|
|
563
533
|
};
|
|
564
534
|
var EMPTY_PATH = [];
|
|
565
535
|
function addIssueToContext(ctx, issueData) {
|
|
@@ -604,19 +574,17 @@ var ParseStatus = class _ParseStatus {
|
|
|
604
574
|
}
|
|
605
575
|
return { status: status.value, value: arrayValue };
|
|
606
576
|
}
|
|
607
|
-
static mergeObjectAsync(status, pairs) {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
|
619
|
-
});
|
|
577
|
+
static async mergeObjectAsync(status, pairs) {
|
|
578
|
+
const syncPairs = [];
|
|
579
|
+
for (const pair of pairs) {
|
|
580
|
+
const key = await pair.key;
|
|
581
|
+
const value = await pair.value;
|
|
582
|
+
syncPairs.push({
|
|
583
|
+
key,
|
|
584
|
+
value
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
|
620
588
|
}
|
|
621
589
|
static mergeObjectSync(status, pairs) {
|
|
622
590
|
const finalObject = {};
|
|
@@ -651,7 +619,7 @@ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
|
651
619
|
var errorUtil;
|
|
652
620
|
(function(errorUtil2) {
|
|
653
621
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
654
|
-
errorUtil2.toString = (message) => typeof message === "string" ? message : message
|
|
622
|
+
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
655
623
|
})(errorUtil || (errorUtil = {}));
|
|
656
624
|
|
|
657
625
|
// node_modules/zod/v3/types.js
|
|
@@ -703,17 +671,16 @@ function processCreateParams(params) {
|
|
|
703
671
|
if (errorMap2)
|
|
704
672
|
return { errorMap: errorMap2, description };
|
|
705
673
|
const customMap = (iss, ctx) => {
|
|
706
|
-
var _a, _b;
|
|
707
674
|
const { message } = params;
|
|
708
675
|
if (iss.code === "invalid_enum_value") {
|
|
709
|
-
return { message: message
|
|
676
|
+
return { message: message ?? ctx.defaultError };
|
|
710
677
|
}
|
|
711
678
|
if (typeof ctx.data === "undefined") {
|
|
712
|
-
return { message:
|
|
679
|
+
return { message: message ?? required_error ?? ctx.defaultError };
|
|
713
680
|
}
|
|
714
681
|
if (iss.code !== "invalid_type")
|
|
715
682
|
return { message: ctx.defaultError };
|
|
716
|
-
return { message:
|
|
683
|
+
return { message: message ?? invalid_type_error ?? ctx.defaultError };
|
|
717
684
|
};
|
|
718
685
|
return { errorMap: customMap, description };
|
|
719
686
|
}
|
|
@@ -765,14 +732,13 @@ var ZodType = class {
|
|
|
765
732
|
throw result.error;
|
|
766
733
|
}
|
|
767
734
|
safeParse(data, params) {
|
|
768
|
-
var _a;
|
|
769
735
|
const ctx = {
|
|
770
736
|
common: {
|
|
771
737
|
issues: [],
|
|
772
|
-
async:
|
|
773
|
-
contextualErrorMap: params
|
|
738
|
+
async: params?.async ?? false,
|
|
739
|
+
contextualErrorMap: params?.errorMap
|
|
774
740
|
},
|
|
775
|
-
path:
|
|
741
|
+
path: params?.path || [],
|
|
776
742
|
schemaErrorMap: this._def.errorMap,
|
|
777
743
|
parent: null,
|
|
778
744
|
data,
|
|
@@ -782,7 +748,6 @@ var ZodType = class {
|
|
|
782
748
|
return handleResult(ctx, result);
|
|
783
749
|
}
|
|
784
750
|
"~validate"(data) {
|
|
785
|
-
var _a, _b;
|
|
786
751
|
const ctx = {
|
|
787
752
|
common: {
|
|
788
753
|
issues: [],
|
|
@@ -803,7 +768,7 @@ var ZodType = class {
|
|
|
803
768
|
issues: ctx.common.issues
|
|
804
769
|
};
|
|
805
770
|
} catch (err) {
|
|
806
|
-
if (
|
|
771
|
+
if (err?.message?.toLowerCase()?.includes("encountered")) {
|
|
807
772
|
this["~standard"].async = true;
|
|
808
773
|
}
|
|
809
774
|
ctx.common = {
|
|
@@ -818,32 +783,28 @@ var ZodType = class {
|
|
|
818
783
|
issues: ctx.common.issues
|
|
819
784
|
});
|
|
820
785
|
}
|
|
821
|
-
parseAsync(data, params) {
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
throw result.error;
|
|
827
|
-
});
|
|
786
|
+
async parseAsync(data, params) {
|
|
787
|
+
const result = await this.safeParseAsync(data, params);
|
|
788
|
+
if (result.success)
|
|
789
|
+
return result.data;
|
|
790
|
+
throw result.error;
|
|
828
791
|
}
|
|
829
|
-
safeParseAsync(data, params) {
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
return handleResult(ctx, result);
|
|
846
|
-
});
|
|
792
|
+
async safeParseAsync(data, params) {
|
|
793
|
+
const ctx = {
|
|
794
|
+
common: {
|
|
795
|
+
issues: [],
|
|
796
|
+
contextualErrorMap: params?.errorMap,
|
|
797
|
+
async: true
|
|
798
|
+
},
|
|
799
|
+
path: params?.path || [],
|
|
800
|
+
schemaErrorMap: this._def.errorMap,
|
|
801
|
+
parent: null,
|
|
802
|
+
data,
|
|
803
|
+
parsedType: getParsedType(data)
|
|
804
|
+
};
|
|
805
|
+
const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
|
|
806
|
+
const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
|
|
807
|
+
return handleResult(ctx, result);
|
|
847
808
|
}
|
|
848
809
|
refine(check, message) {
|
|
849
810
|
const getIssueProperties = (val) => {
|
|
@@ -857,9 +818,10 @@ var ZodType = class {
|
|
|
857
818
|
};
|
|
858
819
|
return this._refinement((val, ctx) => {
|
|
859
820
|
const result = check(val);
|
|
860
|
-
const setError = () => ctx.addIssue(
|
|
861
|
-
code: ZodIssueCode.custom
|
|
862
|
-
|
|
821
|
+
const setError = () => ctx.addIssue({
|
|
822
|
+
code: ZodIssueCode.custom,
|
|
823
|
+
...getIssueProperties(val)
|
|
824
|
+
});
|
|
863
825
|
if (typeof Promise !== "undefined" && result instanceof Promise) {
|
|
864
826
|
return result.then((data) => {
|
|
865
827
|
if (!data) {
|
|
@@ -953,39 +915,44 @@ var ZodType = class {
|
|
|
953
915
|
return ZodIntersection.create(this, incoming, this._def);
|
|
954
916
|
}
|
|
955
917
|
transform(transform) {
|
|
956
|
-
return new ZodEffects(
|
|
918
|
+
return new ZodEffects({
|
|
919
|
+
...processCreateParams(this._def),
|
|
957
920
|
schema: this,
|
|
958
921
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
959
922
|
effect: { type: "transform", transform }
|
|
960
|
-
})
|
|
923
|
+
});
|
|
961
924
|
}
|
|
962
925
|
default(def) {
|
|
963
926
|
const defaultValueFunc = typeof def === "function" ? def : () => def;
|
|
964
|
-
return new ZodDefault(
|
|
927
|
+
return new ZodDefault({
|
|
928
|
+
...processCreateParams(this._def),
|
|
965
929
|
innerType: this,
|
|
966
930
|
defaultValue: defaultValueFunc,
|
|
967
931
|
typeName: ZodFirstPartyTypeKind.ZodDefault
|
|
968
|
-
})
|
|
932
|
+
});
|
|
969
933
|
}
|
|
970
934
|
brand() {
|
|
971
|
-
return new ZodBranded(
|
|
935
|
+
return new ZodBranded({
|
|
972
936
|
typeName: ZodFirstPartyTypeKind.ZodBranded,
|
|
973
|
-
type: this
|
|
974
|
-
|
|
937
|
+
type: this,
|
|
938
|
+
...processCreateParams(this._def)
|
|
939
|
+
});
|
|
975
940
|
}
|
|
976
941
|
catch(def) {
|
|
977
942
|
const catchValueFunc = typeof def === "function" ? def : () => def;
|
|
978
|
-
return new ZodCatch(
|
|
943
|
+
return new ZodCatch({
|
|
944
|
+
...processCreateParams(this._def),
|
|
979
945
|
innerType: this,
|
|
980
946
|
catchValue: catchValueFunc,
|
|
981
947
|
typeName: ZodFirstPartyTypeKind.ZodCatch
|
|
982
|
-
})
|
|
948
|
+
});
|
|
983
949
|
}
|
|
984
950
|
describe(description) {
|
|
985
951
|
const This = this.constructor;
|
|
986
|
-
return new This(
|
|
952
|
+
return new This({
|
|
953
|
+
...this._def,
|
|
987
954
|
description
|
|
988
|
-
})
|
|
955
|
+
});
|
|
989
956
|
}
|
|
990
957
|
pipe(target) {
|
|
991
958
|
return ZodPipeline.create(this, target);
|
|
@@ -1060,14 +1027,14 @@ function isValidJWT(jwt, alg) {
|
|
|
1060
1027
|
const decoded = JSON.parse(atob(base64));
|
|
1061
1028
|
if (typeof decoded !== "object" || decoded === null)
|
|
1062
1029
|
return false;
|
|
1063
|
-
if ("typ" in decoded &&
|
|
1030
|
+
if ("typ" in decoded && decoded?.typ !== "JWT")
|
|
1064
1031
|
return false;
|
|
1065
1032
|
if (!decoded.alg)
|
|
1066
1033
|
return false;
|
|
1067
1034
|
if (alg && decoded.alg !== alg)
|
|
1068
1035
|
return false;
|
|
1069
1036
|
return true;
|
|
1070
|
-
} catch
|
|
1037
|
+
} catch {
|
|
1071
1038
|
return false;
|
|
1072
1039
|
}
|
|
1073
1040
|
}
|
|
@@ -1226,7 +1193,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1226
1193
|
} else if (check.kind === "url") {
|
|
1227
1194
|
try {
|
|
1228
1195
|
new URL(input.data);
|
|
1229
|
-
} catch
|
|
1196
|
+
} catch {
|
|
1230
1197
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
1231
1198
|
addIssueToContext(ctx, {
|
|
1232
1199
|
validation: "url",
|
|
@@ -1383,59 +1350,61 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1383
1350
|
return { status: status.value, value: input.data };
|
|
1384
1351
|
}
|
|
1385
1352
|
_regex(regex, validation, message) {
|
|
1386
|
-
return this.refinement((data) => regex.test(data),
|
|
1353
|
+
return this.refinement((data) => regex.test(data), {
|
|
1387
1354
|
validation,
|
|
1388
|
-
code: ZodIssueCode.invalid_string
|
|
1389
|
-
|
|
1355
|
+
code: ZodIssueCode.invalid_string,
|
|
1356
|
+
...errorUtil.errToObj(message)
|
|
1357
|
+
});
|
|
1390
1358
|
}
|
|
1391
1359
|
_addCheck(check) {
|
|
1392
|
-
return new _ZodString(
|
|
1360
|
+
return new _ZodString({
|
|
1361
|
+
...this._def,
|
|
1393
1362
|
checks: [...this._def.checks, check]
|
|
1394
|
-
})
|
|
1363
|
+
});
|
|
1395
1364
|
}
|
|
1396
1365
|
email(message) {
|
|
1397
|
-
return this._addCheck(
|
|
1366
|
+
return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
|
|
1398
1367
|
}
|
|
1399
1368
|
url(message) {
|
|
1400
|
-
return this._addCheck(
|
|
1369
|
+
return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
|
|
1401
1370
|
}
|
|
1402
1371
|
emoji(message) {
|
|
1403
|
-
return this._addCheck(
|
|
1372
|
+
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
|
|
1404
1373
|
}
|
|
1405
1374
|
uuid(message) {
|
|
1406
|
-
return this._addCheck(
|
|
1375
|
+
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
1407
1376
|
}
|
|
1408
1377
|
nanoid(message) {
|
|
1409
|
-
return this._addCheck(
|
|
1378
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
|
1410
1379
|
}
|
|
1411
1380
|
cuid(message) {
|
|
1412
|
-
return this._addCheck(
|
|
1381
|
+
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
1413
1382
|
}
|
|
1414
1383
|
cuid2(message) {
|
|
1415
|
-
return this._addCheck(
|
|
1384
|
+
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
|
|
1416
1385
|
}
|
|
1417
1386
|
ulid(message) {
|
|
1418
|
-
return this._addCheck(
|
|
1387
|
+
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
1419
1388
|
}
|
|
1420
1389
|
base64(message) {
|
|
1421
|
-
return this._addCheck(
|
|
1390
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
1422
1391
|
}
|
|
1423
1392
|
base64url(message) {
|
|
1424
|
-
return this._addCheck(
|
|
1425
|
-
kind: "base64url"
|
|
1426
|
-
|
|
1393
|
+
return this._addCheck({
|
|
1394
|
+
kind: "base64url",
|
|
1395
|
+
...errorUtil.errToObj(message)
|
|
1396
|
+
});
|
|
1427
1397
|
}
|
|
1428
1398
|
jwt(options) {
|
|
1429
|
-
return this._addCheck(
|
|
1399
|
+
return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
|
|
1430
1400
|
}
|
|
1431
1401
|
ip(options) {
|
|
1432
|
-
return this._addCheck(
|
|
1402
|
+
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
1433
1403
|
}
|
|
1434
1404
|
cidr(options) {
|
|
1435
|
-
return this._addCheck(
|
|
1405
|
+
return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
|
|
1436
1406
|
}
|
|
1437
1407
|
datetime(options) {
|
|
1438
|
-
var _a, _b;
|
|
1439
1408
|
if (typeof options === "string") {
|
|
1440
1409
|
return this._addCheck({
|
|
1441
1410
|
kind: "datetime",
|
|
@@ -1445,12 +1414,13 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1445
1414
|
message: options
|
|
1446
1415
|
});
|
|
1447
1416
|
}
|
|
1448
|
-
return this._addCheck(
|
|
1417
|
+
return this._addCheck({
|
|
1449
1418
|
kind: "datetime",
|
|
1450
|
-
precision: typeof
|
|
1451
|
-
offset:
|
|
1452
|
-
local:
|
|
1453
|
-
|
|
1419
|
+
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
1420
|
+
offset: options?.offset ?? false,
|
|
1421
|
+
local: options?.local ?? false,
|
|
1422
|
+
...errorUtil.errToObj(options?.message)
|
|
1423
|
+
});
|
|
1454
1424
|
}
|
|
1455
1425
|
date(message) {
|
|
1456
1426
|
return this._addCheck({ kind: "date", message });
|
|
@@ -1463,56 +1433,64 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1463
1433
|
message: options
|
|
1464
1434
|
});
|
|
1465
1435
|
}
|
|
1466
|
-
return this._addCheck(
|
|
1436
|
+
return this._addCheck({
|
|
1467
1437
|
kind: "time",
|
|
1468
|
-
precision: typeof
|
|
1469
|
-
|
|
1438
|
+
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
1439
|
+
...errorUtil.errToObj(options?.message)
|
|
1440
|
+
});
|
|
1470
1441
|
}
|
|
1471
1442
|
duration(message) {
|
|
1472
|
-
return this._addCheck(
|
|
1443
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
|
1473
1444
|
}
|
|
1474
1445
|
regex(regex, message) {
|
|
1475
|
-
return this._addCheck(
|
|
1446
|
+
return this._addCheck({
|
|
1476
1447
|
kind: "regex",
|
|
1477
|
-
regex
|
|
1478
|
-
|
|
1448
|
+
regex,
|
|
1449
|
+
...errorUtil.errToObj(message)
|
|
1450
|
+
});
|
|
1479
1451
|
}
|
|
1480
1452
|
includes(value, options) {
|
|
1481
|
-
return this._addCheck(
|
|
1453
|
+
return this._addCheck({
|
|
1482
1454
|
kind: "includes",
|
|
1483
1455
|
value,
|
|
1484
|
-
position: options
|
|
1485
|
-
|
|
1456
|
+
position: options?.position,
|
|
1457
|
+
...errorUtil.errToObj(options?.message)
|
|
1458
|
+
});
|
|
1486
1459
|
}
|
|
1487
1460
|
startsWith(value, message) {
|
|
1488
|
-
return this._addCheck(
|
|
1461
|
+
return this._addCheck({
|
|
1489
1462
|
kind: "startsWith",
|
|
1490
|
-
value
|
|
1491
|
-
|
|
1463
|
+
value,
|
|
1464
|
+
...errorUtil.errToObj(message)
|
|
1465
|
+
});
|
|
1492
1466
|
}
|
|
1493
1467
|
endsWith(value, message) {
|
|
1494
|
-
return this._addCheck(
|
|
1468
|
+
return this._addCheck({
|
|
1495
1469
|
kind: "endsWith",
|
|
1496
|
-
value
|
|
1497
|
-
|
|
1470
|
+
value,
|
|
1471
|
+
...errorUtil.errToObj(message)
|
|
1472
|
+
});
|
|
1498
1473
|
}
|
|
1499
1474
|
min(minLength, message) {
|
|
1500
|
-
return this._addCheck(
|
|
1475
|
+
return this._addCheck({
|
|
1501
1476
|
kind: "min",
|
|
1502
|
-
value: minLength
|
|
1503
|
-
|
|
1477
|
+
value: minLength,
|
|
1478
|
+
...errorUtil.errToObj(message)
|
|
1479
|
+
});
|
|
1504
1480
|
}
|
|
1505
1481
|
max(maxLength, message) {
|
|
1506
|
-
return this._addCheck(
|
|
1482
|
+
return this._addCheck({
|
|
1507
1483
|
kind: "max",
|
|
1508
|
-
value: maxLength
|
|
1509
|
-
|
|
1484
|
+
value: maxLength,
|
|
1485
|
+
...errorUtil.errToObj(message)
|
|
1486
|
+
});
|
|
1510
1487
|
}
|
|
1511
1488
|
length(len, message) {
|
|
1512
|
-
return this._addCheck(
|
|
1489
|
+
return this._addCheck({
|
|
1513
1490
|
kind: "length",
|
|
1514
|
-
value: len
|
|
1515
|
-
|
|
1491
|
+
value: len,
|
|
1492
|
+
...errorUtil.errToObj(message)
|
|
1493
|
+
});
|
|
1516
1494
|
}
|
|
1517
1495
|
/**
|
|
1518
1496
|
* Equivalent to `.min(1)`
|
|
@@ -1521,19 +1499,22 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1521
1499
|
return this.min(1, errorUtil.errToObj(message));
|
|
1522
1500
|
}
|
|
1523
1501
|
trim() {
|
|
1524
|
-
return new _ZodString(
|
|
1502
|
+
return new _ZodString({
|
|
1503
|
+
...this._def,
|
|
1525
1504
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
1526
|
-
})
|
|
1505
|
+
});
|
|
1527
1506
|
}
|
|
1528
1507
|
toLowerCase() {
|
|
1529
|
-
return new _ZodString(
|
|
1508
|
+
return new _ZodString({
|
|
1509
|
+
...this._def,
|
|
1530
1510
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1531
|
-
})
|
|
1511
|
+
});
|
|
1532
1512
|
}
|
|
1533
1513
|
toUpperCase() {
|
|
1534
|
-
return new _ZodString(
|
|
1514
|
+
return new _ZodString({
|
|
1515
|
+
...this._def,
|
|
1535
1516
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1536
|
-
})
|
|
1517
|
+
});
|
|
1537
1518
|
}
|
|
1538
1519
|
get isDatetime() {
|
|
1539
1520
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
@@ -1605,12 +1586,12 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1605
1586
|
}
|
|
1606
1587
|
};
|
|
1607
1588
|
ZodString.create = (params) => {
|
|
1608
|
-
|
|
1609
|
-
return new ZodString(__spreadValues({
|
|
1589
|
+
return new ZodString({
|
|
1610
1590
|
checks: [],
|
|
1611
1591
|
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
1612
|
-
coerce:
|
|
1613
|
-
|
|
1592
|
+
coerce: params?.coerce ?? false,
|
|
1593
|
+
...processCreateParams(params)
|
|
1594
|
+
});
|
|
1614
1595
|
};
|
|
1615
1596
|
function floatSafeRemainder(val, step) {
|
|
1616
1597
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
@@ -1618,7 +1599,7 @@ function floatSafeRemainder(val, step) {
|
|
|
1618
1599
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
1619
1600
|
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
1620
1601
|
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
1621
|
-
return valInt % stepInt /
|
|
1602
|
+
return valInt % stepInt / 10 ** decCount;
|
|
1622
1603
|
}
|
|
1623
1604
|
var ZodNumber = class _ZodNumber extends ZodType {
|
|
1624
1605
|
constructor() {
|
|
@@ -1721,7 +1702,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1721
1702
|
return this.setLimit("max", value, false, errorUtil.toString(message));
|
|
1722
1703
|
}
|
|
1723
1704
|
setLimit(kind, value, inclusive, message) {
|
|
1724
|
-
return new _ZodNumber(
|
|
1705
|
+
return new _ZodNumber({
|
|
1706
|
+
...this._def,
|
|
1725
1707
|
checks: [
|
|
1726
1708
|
...this._def.checks,
|
|
1727
1709
|
{
|
|
@@ -1731,12 +1713,13 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1731
1713
|
message: errorUtil.toString(message)
|
|
1732
1714
|
}
|
|
1733
1715
|
]
|
|
1734
|
-
})
|
|
1716
|
+
});
|
|
1735
1717
|
}
|
|
1736
1718
|
_addCheck(check) {
|
|
1737
|
-
return new _ZodNumber(
|
|
1719
|
+
return new _ZodNumber({
|
|
1720
|
+
...this._def,
|
|
1738
1721
|
checks: [...this._def.checks, check]
|
|
1739
|
-
})
|
|
1722
|
+
});
|
|
1740
1723
|
}
|
|
1741
1724
|
int(message) {
|
|
1742
1725
|
return this._addCheck({
|
|
@@ -1843,11 +1826,12 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1843
1826
|
}
|
|
1844
1827
|
};
|
|
1845
1828
|
ZodNumber.create = (params) => {
|
|
1846
|
-
return new ZodNumber(
|
|
1829
|
+
return new ZodNumber({
|
|
1847
1830
|
checks: [],
|
|
1848
1831
|
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
|
1849
|
-
coerce:
|
|
1850
|
-
|
|
1832
|
+
coerce: params?.coerce || false,
|
|
1833
|
+
...processCreateParams(params)
|
|
1834
|
+
});
|
|
1851
1835
|
};
|
|
1852
1836
|
var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
1853
1837
|
constructor() {
|
|
@@ -1859,7 +1843,7 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1859
1843
|
if (this._def.coerce) {
|
|
1860
1844
|
try {
|
|
1861
1845
|
input.data = BigInt(input.data);
|
|
1862
|
-
} catch
|
|
1846
|
+
} catch {
|
|
1863
1847
|
return this._getInvalidInput(input);
|
|
1864
1848
|
}
|
|
1865
1849
|
}
|
|
@@ -1934,7 +1918,8 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1934
1918
|
return this.setLimit("max", value, false, errorUtil.toString(message));
|
|
1935
1919
|
}
|
|
1936
1920
|
setLimit(kind, value, inclusive, message) {
|
|
1937
|
-
return new _ZodBigInt(
|
|
1921
|
+
return new _ZodBigInt({
|
|
1922
|
+
...this._def,
|
|
1938
1923
|
checks: [
|
|
1939
1924
|
...this._def.checks,
|
|
1940
1925
|
{
|
|
@@ -1944,12 +1929,13 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1944
1929
|
message: errorUtil.toString(message)
|
|
1945
1930
|
}
|
|
1946
1931
|
]
|
|
1947
|
-
})
|
|
1932
|
+
});
|
|
1948
1933
|
}
|
|
1949
1934
|
_addCheck(check) {
|
|
1950
|
-
return new _ZodBigInt(
|
|
1935
|
+
return new _ZodBigInt({
|
|
1936
|
+
...this._def,
|
|
1951
1937
|
checks: [...this._def.checks, check]
|
|
1952
|
-
})
|
|
1938
|
+
});
|
|
1953
1939
|
}
|
|
1954
1940
|
positive(message) {
|
|
1955
1941
|
return this._addCheck({
|
|
@@ -2012,12 +1998,12 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
2012
1998
|
}
|
|
2013
1999
|
};
|
|
2014
2000
|
ZodBigInt.create = (params) => {
|
|
2015
|
-
|
|
2016
|
-
return new ZodBigInt(__spreadValues({
|
|
2001
|
+
return new ZodBigInt({
|
|
2017
2002
|
checks: [],
|
|
2018
2003
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
2019
|
-
coerce:
|
|
2020
|
-
|
|
2004
|
+
coerce: params?.coerce ?? false,
|
|
2005
|
+
...processCreateParams(params)
|
|
2006
|
+
});
|
|
2021
2007
|
};
|
|
2022
2008
|
var ZodBoolean = class extends ZodType {
|
|
2023
2009
|
_parse(input) {
|
|
@@ -2038,10 +2024,11 @@ var ZodBoolean = class extends ZodType {
|
|
|
2038
2024
|
}
|
|
2039
2025
|
};
|
|
2040
2026
|
ZodBoolean.create = (params) => {
|
|
2041
|
-
return new ZodBoolean(
|
|
2027
|
+
return new ZodBoolean({
|
|
2042
2028
|
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
|
2043
|
-
coerce:
|
|
2044
|
-
|
|
2029
|
+
coerce: params?.coerce || false,
|
|
2030
|
+
...processCreateParams(params)
|
|
2031
|
+
});
|
|
2045
2032
|
};
|
|
2046
2033
|
var ZodDate = class _ZodDate extends ZodType {
|
|
2047
2034
|
_parse(input) {
|
|
@@ -2104,9 +2091,10 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2104
2091
|
};
|
|
2105
2092
|
}
|
|
2106
2093
|
_addCheck(check) {
|
|
2107
|
-
return new _ZodDate(
|
|
2094
|
+
return new _ZodDate({
|
|
2095
|
+
...this._def,
|
|
2108
2096
|
checks: [...this._def.checks, check]
|
|
2109
|
-
})
|
|
2097
|
+
});
|
|
2110
2098
|
}
|
|
2111
2099
|
min(minDate, message) {
|
|
2112
2100
|
return this._addCheck({
|
|
@@ -2144,11 +2132,12 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2144
2132
|
}
|
|
2145
2133
|
};
|
|
2146
2134
|
ZodDate.create = (params) => {
|
|
2147
|
-
return new ZodDate(
|
|
2135
|
+
return new ZodDate({
|
|
2148
2136
|
checks: [],
|
|
2149
|
-
coerce:
|
|
2150
|
-
typeName: ZodFirstPartyTypeKind.ZodDate
|
|
2151
|
-
|
|
2137
|
+
coerce: params?.coerce || false,
|
|
2138
|
+
typeName: ZodFirstPartyTypeKind.ZodDate,
|
|
2139
|
+
...processCreateParams(params)
|
|
2140
|
+
});
|
|
2152
2141
|
};
|
|
2153
2142
|
var ZodSymbol = class extends ZodType {
|
|
2154
2143
|
_parse(input) {
|
|
@@ -2166,9 +2155,10 @@ var ZodSymbol = class extends ZodType {
|
|
|
2166
2155
|
}
|
|
2167
2156
|
};
|
|
2168
2157
|
ZodSymbol.create = (params) => {
|
|
2169
|
-
return new ZodSymbol(
|
|
2170
|
-
typeName: ZodFirstPartyTypeKind.ZodSymbol
|
|
2171
|
-
|
|
2158
|
+
return new ZodSymbol({
|
|
2159
|
+
typeName: ZodFirstPartyTypeKind.ZodSymbol,
|
|
2160
|
+
...processCreateParams(params)
|
|
2161
|
+
});
|
|
2172
2162
|
};
|
|
2173
2163
|
var ZodUndefined = class extends ZodType {
|
|
2174
2164
|
_parse(input) {
|
|
@@ -2186,9 +2176,10 @@ var ZodUndefined = class extends ZodType {
|
|
|
2186
2176
|
}
|
|
2187
2177
|
};
|
|
2188
2178
|
ZodUndefined.create = (params) => {
|
|
2189
|
-
return new ZodUndefined(
|
|
2190
|
-
typeName: ZodFirstPartyTypeKind.ZodUndefined
|
|
2191
|
-
|
|
2179
|
+
return new ZodUndefined({
|
|
2180
|
+
typeName: ZodFirstPartyTypeKind.ZodUndefined,
|
|
2181
|
+
...processCreateParams(params)
|
|
2182
|
+
});
|
|
2192
2183
|
};
|
|
2193
2184
|
var ZodNull = class extends ZodType {
|
|
2194
2185
|
_parse(input) {
|
|
@@ -2206,9 +2197,10 @@ var ZodNull = class extends ZodType {
|
|
|
2206
2197
|
}
|
|
2207
2198
|
};
|
|
2208
2199
|
ZodNull.create = (params) => {
|
|
2209
|
-
return new ZodNull(
|
|
2210
|
-
typeName: ZodFirstPartyTypeKind.ZodNull
|
|
2211
|
-
|
|
2200
|
+
return new ZodNull({
|
|
2201
|
+
typeName: ZodFirstPartyTypeKind.ZodNull,
|
|
2202
|
+
...processCreateParams(params)
|
|
2203
|
+
});
|
|
2212
2204
|
};
|
|
2213
2205
|
var ZodAny = class extends ZodType {
|
|
2214
2206
|
constructor() {
|
|
@@ -2220,9 +2212,10 @@ var ZodAny = class extends ZodType {
|
|
|
2220
2212
|
}
|
|
2221
2213
|
};
|
|
2222
2214
|
ZodAny.create = (params) => {
|
|
2223
|
-
return new ZodAny(
|
|
2224
|
-
typeName: ZodFirstPartyTypeKind.ZodAny
|
|
2225
|
-
|
|
2215
|
+
return new ZodAny({
|
|
2216
|
+
typeName: ZodFirstPartyTypeKind.ZodAny,
|
|
2217
|
+
...processCreateParams(params)
|
|
2218
|
+
});
|
|
2226
2219
|
};
|
|
2227
2220
|
var ZodUnknown = class extends ZodType {
|
|
2228
2221
|
constructor() {
|
|
@@ -2234,9 +2227,10 @@ var ZodUnknown = class extends ZodType {
|
|
|
2234
2227
|
}
|
|
2235
2228
|
};
|
|
2236
2229
|
ZodUnknown.create = (params) => {
|
|
2237
|
-
return new ZodUnknown(
|
|
2238
|
-
typeName: ZodFirstPartyTypeKind.ZodUnknown
|
|
2239
|
-
|
|
2230
|
+
return new ZodUnknown({
|
|
2231
|
+
typeName: ZodFirstPartyTypeKind.ZodUnknown,
|
|
2232
|
+
...processCreateParams(params)
|
|
2233
|
+
});
|
|
2240
2234
|
};
|
|
2241
2235
|
var ZodNever = class extends ZodType {
|
|
2242
2236
|
_parse(input) {
|
|
@@ -2250,9 +2244,10 @@ var ZodNever = class extends ZodType {
|
|
|
2250
2244
|
}
|
|
2251
2245
|
};
|
|
2252
2246
|
ZodNever.create = (params) => {
|
|
2253
|
-
return new ZodNever(
|
|
2254
|
-
typeName: ZodFirstPartyTypeKind.ZodNever
|
|
2255
|
-
|
|
2247
|
+
return new ZodNever({
|
|
2248
|
+
typeName: ZodFirstPartyTypeKind.ZodNever,
|
|
2249
|
+
...processCreateParams(params)
|
|
2250
|
+
});
|
|
2256
2251
|
};
|
|
2257
2252
|
var ZodVoid = class extends ZodType {
|
|
2258
2253
|
_parse(input) {
|
|
@@ -2270,9 +2265,10 @@ var ZodVoid = class extends ZodType {
|
|
|
2270
2265
|
}
|
|
2271
2266
|
};
|
|
2272
2267
|
ZodVoid.create = (params) => {
|
|
2273
|
-
return new ZodVoid(
|
|
2274
|
-
typeName: ZodFirstPartyTypeKind.ZodVoid
|
|
2275
|
-
|
|
2268
|
+
return new ZodVoid({
|
|
2269
|
+
typeName: ZodFirstPartyTypeKind.ZodVoid,
|
|
2270
|
+
...processCreateParams(params)
|
|
2271
|
+
});
|
|
2276
2272
|
};
|
|
2277
2273
|
var ZodArray = class _ZodArray extends ZodType {
|
|
2278
2274
|
_parse(input) {
|
|
@@ -2344,32 +2340,36 @@ var ZodArray = class _ZodArray extends ZodType {
|
|
|
2344
2340
|
return this._def.type;
|
|
2345
2341
|
}
|
|
2346
2342
|
min(minLength, message) {
|
|
2347
|
-
return new _ZodArray(
|
|
2343
|
+
return new _ZodArray({
|
|
2344
|
+
...this._def,
|
|
2348
2345
|
minLength: { value: minLength, message: errorUtil.toString(message) }
|
|
2349
|
-
})
|
|
2346
|
+
});
|
|
2350
2347
|
}
|
|
2351
2348
|
max(maxLength, message) {
|
|
2352
|
-
return new _ZodArray(
|
|
2349
|
+
return new _ZodArray({
|
|
2350
|
+
...this._def,
|
|
2353
2351
|
maxLength: { value: maxLength, message: errorUtil.toString(message) }
|
|
2354
|
-
})
|
|
2352
|
+
});
|
|
2355
2353
|
}
|
|
2356
2354
|
length(len, message) {
|
|
2357
|
-
return new _ZodArray(
|
|
2355
|
+
return new _ZodArray({
|
|
2356
|
+
...this._def,
|
|
2358
2357
|
exactLength: { value: len, message: errorUtil.toString(message) }
|
|
2359
|
-
})
|
|
2358
|
+
});
|
|
2360
2359
|
}
|
|
2361
2360
|
nonempty(message) {
|
|
2362
2361
|
return this.min(1, message);
|
|
2363
2362
|
}
|
|
2364
2363
|
};
|
|
2365
2364
|
ZodArray.create = (schema, params) => {
|
|
2366
|
-
return new ZodArray(
|
|
2365
|
+
return new ZodArray({
|
|
2367
2366
|
type: schema,
|
|
2368
2367
|
minLength: null,
|
|
2369
2368
|
maxLength: null,
|
|
2370
2369
|
exactLength: null,
|
|
2371
|
-
typeName: ZodFirstPartyTypeKind.ZodArray
|
|
2372
|
-
|
|
2370
|
+
typeName: ZodFirstPartyTypeKind.ZodArray,
|
|
2371
|
+
...processCreateParams(params)
|
|
2372
|
+
});
|
|
2373
2373
|
};
|
|
2374
2374
|
function deepPartialify(schema) {
|
|
2375
2375
|
if (schema instanceof ZodObject) {
|
|
@@ -2378,13 +2378,15 @@ function deepPartialify(schema) {
|
|
|
2378
2378
|
const fieldSchema = schema.shape[key];
|
|
2379
2379
|
newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
|
|
2380
2380
|
}
|
|
2381
|
-
return new ZodObject(
|
|
2381
|
+
return new ZodObject({
|
|
2382
|
+
...schema._def,
|
|
2382
2383
|
shape: () => newShape
|
|
2383
|
-
})
|
|
2384
|
+
});
|
|
2384
2385
|
} else if (schema instanceof ZodArray) {
|
|
2385
|
-
return new ZodArray(
|
|
2386
|
+
return new ZodArray({
|
|
2387
|
+
...schema._def,
|
|
2386
2388
|
type: deepPartialify(schema.element)
|
|
2387
|
-
})
|
|
2389
|
+
});
|
|
2388
2390
|
} else if (schema instanceof ZodOptional) {
|
|
2389
2391
|
return ZodOptional.create(deepPartialify(schema.unwrap()));
|
|
2390
2392
|
} else if (schema instanceof ZodNullable) {
|
|
@@ -2477,11 +2479,11 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2477
2479
|
}
|
|
2478
2480
|
}
|
|
2479
2481
|
if (ctx.common.async) {
|
|
2480
|
-
return Promise.resolve().then(() =>
|
|
2482
|
+
return Promise.resolve().then(async () => {
|
|
2481
2483
|
const syncPairs = [];
|
|
2482
2484
|
for (const pair of pairs) {
|
|
2483
|
-
const key =
|
|
2484
|
-
const value =
|
|
2485
|
+
const key = await pair.key;
|
|
2486
|
+
const value = await pair.value;
|
|
2485
2487
|
syncPairs.push({
|
|
2486
2488
|
key,
|
|
2487
2489
|
value,
|
|
@@ -2489,7 +2491,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2489
2491
|
});
|
|
2490
2492
|
}
|
|
2491
2493
|
return syncPairs;
|
|
2492
|
-
})
|
|
2494
|
+
}).then((syncPairs) => {
|
|
2493
2495
|
return ParseStatus.mergeObjectSync(status, syncPairs);
|
|
2494
2496
|
});
|
|
2495
2497
|
} else {
|
|
@@ -2501,31 +2503,34 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2501
2503
|
}
|
|
2502
2504
|
strict(message) {
|
|
2503
2505
|
errorUtil.errToObj;
|
|
2504
|
-
return new _ZodObject(
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2506
|
+
return new _ZodObject({
|
|
2507
|
+
...this._def,
|
|
2508
|
+
unknownKeys: "strict",
|
|
2509
|
+
...message !== void 0 ? {
|
|
2510
|
+
errorMap: (issue, ctx) => {
|
|
2511
|
+
const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
|
|
2512
|
+
if (issue.code === "unrecognized_keys")
|
|
2513
|
+
return {
|
|
2514
|
+
message: errorUtil.errToObj(message).message ?? defaultError
|
|
2515
|
+
};
|
|
2511
2516
|
return {
|
|
2512
|
-
message:
|
|
2517
|
+
message: defaultError
|
|
2513
2518
|
};
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
}
|
|
2518
|
-
} : {}));
|
|
2519
|
+
}
|
|
2520
|
+
} : {}
|
|
2521
|
+
});
|
|
2519
2522
|
}
|
|
2520
2523
|
strip() {
|
|
2521
|
-
return new _ZodObject(
|
|
2524
|
+
return new _ZodObject({
|
|
2525
|
+
...this._def,
|
|
2522
2526
|
unknownKeys: "strip"
|
|
2523
|
-
})
|
|
2527
|
+
});
|
|
2524
2528
|
}
|
|
2525
2529
|
passthrough() {
|
|
2526
|
-
return new _ZodObject(
|
|
2530
|
+
return new _ZodObject({
|
|
2531
|
+
...this._def,
|
|
2527
2532
|
unknownKeys: "passthrough"
|
|
2528
|
-
})
|
|
2533
|
+
});
|
|
2529
2534
|
}
|
|
2530
2535
|
// const AugmentFactory =
|
|
2531
2536
|
// <Def extends ZodObjectDef>(def: Def) =>
|
|
@@ -2545,9 +2550,13 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2545
2550
|
// }) as any;
|
|
2546
2551
|
// };
|
|
2547
2552
|
extend(augmentation) {
|
|
2548
|
-
return new _ZodObject(
|
|
2549
|
-
|
|
2550
|
-
|
|
2553
|
+
return new _ZodObject({
|
|
2554
|
+
...this._def,
|
|
2555
|
+
shape: () => ({
|
|
2556
|
+
...this._def.shape(),
|
|
2557
|
+
...augmentation
|
|
2558
|
+
})
|
|
2559
|
+
});
|
|
2551
2560
|
}
|
|
2552
2561
|
/**
|
|
2553
2562
|
* Prior to zod@1.0.12 there was a bug in the
|
|
@@ -2558,7 +2567,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2558
2567
|
const merged = new _ZodObject({
|
|
2559
2568
|
unknownKeys: merging._def.unknownKeys,
|
|
2560
2569
|
catchall: merging._def.catchall,
|
|
2561
|
-
shape: () =>
|
|
2570
|
+
shape: () => ({
|
|
2571
|
+
...this._def.shape(),
|
|
2572
|
+
...merging._def.shape()
|
|
2573
|
+
}),
|
|
2562
2574
|
typeName: ZodFirstPartyTypeKind.ZodObject
|
|
2563
2575
|
});
|
|
2564
2576
|
return merged;
|
|
@@ -2623,9 +2635,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2623
2635
|
// return merged;
|
|
2624
2636
|
// }
|
|
2625
2637
|
catchall(index) {
|
|
2626
|
-
return new _ZodObject(
|
|
2638
|
+
return new _ZodObject({
|
|
2639
|
+
...this._def,
|
|
2627
2640
|
catchall: index
|
|
2628
|
-
})
|
|
2641
|
+
});
|
|
2629
2642
|
}
|
|
2630
2643
|
pick(mask) {
|
|
2631
2644
|
const shape = {};
|
|
@@ -2634,9 +2647,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2634
2647
|
shape[key] = this.shape[key];
|
|
2635
2648
|
}
|
|
2636
2649
|
}
|
|
2637
|
-
return new _ZodObject(
|
|
2650
|
+
return new _ZodObject({
|
|
2651
|
+
...this._def,
|
|
2638
2652
|
shape: () => shape
|
|
2639
|
-
})
|
|
2653
|
+
});
|
|
2640
2654
|
}
|
|
2641
2655
|
omit(mask) {
|
|
2642
2656
|
const shape = {};
|
|
@@ -2645,9 +2659,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2645
2659
|
shape[key] = this.shape[key];
|
|
2646
2660
|
}
|
|
2647
2661
|
}
|
|
2648
|
-
return new _ZodObject(
|
|
2662
|
+
return new _ZodObject({
|
|
2663
|
+
...this._def,
|
|
2649
2664
|
shape: () => shape
|
|
2650
|
-
})
|
|
2665
|
+
});
|
|
2651
2666
|
}
|
|
2652
2667
|
/**
|
|
2653
2668
|
* @deprecated
|
|
@@ -2665,9 +2680,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2665
2680
|
newShape[key] = fieldSchema.optional();
|
|
2666
2681
|
}
|
|
2667
2682
|
}
|
|
2668
|
-
return new _ZodObject(
|
|
2683
|
+
return new _ZodObject({
|
|
2684
|
+
...this._def,
|
|
2669
2685
|
shape: () => newShape
|
|
2670
|
-
})
|
|
2686
|
+
});
|
|
2671
2687
|
}
|
|
2672
2688
|
required(mask) {
|
|
2673
2689
|
const newShape = {};
|
|
@@ -2683,37 +2699,41 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2683
2699
|
newShape[key] = newField;
|
|
2684
2700
|
}
|
|
2685
2701
|
}
|
|
2686
|
-
return new _ZodObject(
|
|
2702
|
+
return new _ZodObject({
|
|
2703
|
+
...this._def,
|
|
2687
2704
|
shape: () => newShape
|
|
2688
|
-
})
|
|
2705
|
+
});
|
|
2689
2706
|
}
|
|
2690
2707
|
keyof() {
|
|
2691
2708
|
return createZodEnum(util.objectKeys(this.shape));
|
|
2692
2709
|
}
|
|
2693
2710
|
};
|
|
2694
2711
|
ZodObject.create = (shape, params) => {
|
|
2695
|
-
return new ZodObject(
|
|
2712
|
+
return new ZodObject({
|
|
2696
2713
|
shape: () => shape,
|
|
2697
2714
|
unknownKeys: "strip",
|
|
2698
2715
|
catchall: ZodNever.create(),
|
|
2699
|
-
typeName: ZodFirstPartyTypeKind.ZodObject
|
|
2700
|
-
|
|
2716
|
+
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
2717
|
+
...processCreateParams(params)
|
|
2718
|
+
});
|
|
2701
2719
|
};
|
|
2702
2720
|
ZodObject.strictCreate = (shape, params) => {
|
|
2703
|
-
return new ZodObject(
|
|
2721
|
+
return new ZodObject({
|
|
2704
2722
|
shape: () => shape,
|
|
2705
2723
|
unknownKeys: "strict",
|
|
2706
2724
|
catchall: ZodNever.create(),
|
|
2707
|
-
typeName: ZodFirstPartyTypeKind.ZodObject
|
|
2708
|
-
|
|
2725
|
+
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
2726
|
+
...processCreateParams(params)
|
|
2727
|
+
});
|
|
2709
2728
|
};
|
|
2710
2729
|
ZodObject.lazycreate = (shape, params) => {
|
|
2711
|
-
return new ZodObject(
|
|
2730
|
+
return new ZodObject({
|
|
2712
2731
|
shape,
|
|
2713
2732
|
unknownKeys: "strip",
|
|
2714
2733
|
catchall: ZodNever.create(),
|
|
2715
|
-
typeName: ZodFirstPartyTypeKind.ZodObject
|
|
2716
|
-
|
|
2734
|
+
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
2735
|
+
...processCreateParams(params)
|
|
2736
|
+
});
|
|
2717
2737
|
};
|
|
2718
2738
|
var ZodUnion = class extends ZodType {
|
|
2719
2739
|
_parse(input) {
|
|
@@ -2739,32 +2759,36 @@ var ZodUnion = class extends ZodType {
|
|
|
2739
2759
|
return INVALID;
|
|
2740
2760
|
}
|
|
2741
2761
|
if (ctx.common.async) {
|
|
2742
|
-
return Promise.all(options.map((option) =>
|
|
2743
|
-
const childCtx =
|
|
2744
|
-
|
|
2762
|
+
return Promise.all(options.map(async (option) => {
|
|
2763
|
+
const childCtx = {
|
|
2764
|
+
...ctx,
|
|
2765
|
+
common: {
|
|
2766
|
+
...ctx.common,
|
|
2745
2767
|
issues: []
|
|
2746
|
-
}
|
|
2768
|
+
},
|
|
2747
2769
|
parent: null
|
|
2748
|
-
}
|
|
2770
|
+
};
|
|
2749
2771
|
return {
|
|
2750
|
-
result:
|
|
2772
|
+
result: await option._parseAsync({
|
|
2751
2773
|
data: ctx.data,
|
|
2752
2774
|
path: ctx.path,
|
|
2753
2775
|
parent: childCtx
|
|
2754
2776
|
}),
|
|
2755
2777
|
ctx: childCtx
|
|
2756
2778
|
};
|
|
2757
|
-
}))
|
|
2779
|
+
})).then(handleResults);
|
|
2758
2780
|
} else {
|
|
2759
2781
|
let dirty = void 0;
|
|
2760
2782
|
const issues = [];
|
|
2761
2783
|
for (const option of options) {
|
|
2762
|
-
const childCtx =
|
|
2763
|
-
|
|
2784
|
+
const childCtx = {
|
|
2785
|
+
...ctx,
|
|
2786
|
+
common: {
|
|
2787
|
+
...ctx.common,
|
|
2764
2788
|
issues: []
|
|
2765
|
-
}
|
|
2789
|
+
},
|
|
2766
2790
|
parent: null
|
|
2767
|
-
}
|
|
2791
|
+
};
|
|
2768
2792
|
const result = option._parseSync({
|
|
2769
2793
|
data: ctx.data,
|
|
2770
2794
|
path: ctx.path,
|
|
@@ -2796,10 +2820,11 @@ var ZodUnion = class extends ZodType {
|
|
|
2796
2820
|
}
|
|
2797
2821
|
};
|
|
2798
2822
|
ZodUnion.create = (types, params) => {
|
|
2799
|
-
return new ZodUnion(
|
|
2823
|
+
return new ZodUnion({
|
|
2800
2824
|
options: types,
|
|
2801
|
-
typeName: ZodFirstPartyTypeKind.ZodUnion
|
|
2802
|
-
|
|
2825
|
+
typeName: ZodFirstPartyTypeKind.ZodUnion,
|
|
2826
|
+
...processCreateParams(params)
|
|
2827
|
+
});
|
|
2803
2828
|
};
|
|
2804
2829
|
var getDiscriminator = (type) => {
|
|
2805
2830
|
if (type instanceof ZodLazy) {
|
|
@@ -2899,12 +2924,13 @@ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
|
2899
2924
|
optionsMap.set(value, type);
|
|
2900
2925
|
}
|
|
2901
2926
|
}
|
|
2902
|
-
return new _ZodDiscriminatedUnion(
|
|
2927
|
+
return new _ZodDiscriminatedUnion({
|
|
2903
2928
|
typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
|
|
2904
2929
|
discriminator,
|
|
2905
2930
|
options,
|
|
2906
|
-
optionsMap
|
|
2907
|
-
|
|
2931
|
+
optionsMap,
|
|
2932
|
+
...processCreateParams(params)
|
|
2933
|
+
});
|
|
2908
2934
|
}
|
|
2909
2935
|
};
|
|
2910
2936
|
function mergeValues(a, b) {
|
|
@@ -2915,7 +2941,7 @@ function mergeValues(a, b) {
|
|
|
2915
2941
|
} else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
|
|
2916
2942
|
const bKeys = util.objectKeys(b);
|
|
2917
2943
|
const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
2918
|
-
const newObj =
|
|
2944
|
+
const newObj = { ...a, ...b };
|
|
2919
2945
|
for (const key of sharedKeys) {
|
|
2920
2946
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
2921
2947
|
if (!sharedValue.valid) {
|
|
@@ -2991,11 +3017,12 @@ var ZodIntersection = class extends ZodType {
|
|
|
2991
3017
|
}
|
|
2992
3018
|
};
|
|
2993
3019
|
ZodIntersection.create = (left, right, params) => {
|
|
2994
|
-
return new ZodIntersection(
|
|
3020
|
+
return new ZodIntersection({
|
|
2995
3021
|
left,
|
|
2996
3022
|
right,
|
|
2997
|
-
typeName: ZodFirstPartyTypeKind.ZodIntersection
|
|
2998
|
-
|
|
3023
|
+
typeName: ZodFirstPartyTypeKind.ZodIntersection,
|
|
3024
|
+
...processCreateParams(params)
|
|
3025
|
+
});
|
|
2999
3026
|
};
|
|
3000
3027
|
var ZodTuple = class _ZodTuple extends ZodType {
|
|
3001
3028
|
_parse(input) {
|
|
@@ -3047,20 +3074,22 @@ var ZodTuple = class _ZodTuple extends ZodType {
|
|
|
3047
3074
|
return this._def.items;
|
|
3048
3075
|
}
|
|
3049
3076
|
rest(rest) {
|
|
3050
|
-
return new _ZodTuple(
|
|
3077
|
+
return new _ZodTuple({
|
|
3078
|
+
...this._def,
|
|
3051
3079
|
rest
|
|
3052
|
-
})
|
|
3080
|
+
});
|
|
3053
3081
|
}
|
|
3054
3082
|
};
|
|
3055
3083
|
ZodTuple.create = (schemas, params) => {
|
|
3056
3084
|
if (!Array.isArray(schemas)) {
|
|
3057
3085
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
3058
3086
|
}
|
|
3059
|
-
return new ZodTuple(
|
|
3087
|
+
return new ZodTuple({
|
|
3060
3088
|
items: schemas,
|
|
3061
3089
|
typeName: ZodFirstPartyTypeKind.ZodTuple,
|
|
3062
|
-
rest: null
|
|
3063
|
-
|
|
3090
|
+
rest: null,
|
|
3091
|
+
...processCreateParams(params)
|
|
3092
|
+
});
|
|
3064
3093
|
};
|
|
3065
3094
|
var ZodRecord = class _ZodRecord extends ZodType {
|
|
3066
3095
|
get keySchema() {
|
|
@@ -3100,17 +3129,19 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
3100
3129
|
}
|
|
3101
3130
|
static create(first, second, third) {
|
|
3102
3131
|
if (second instanceof ZodType) {
|
|
3103
|
-
return new _ZodRecord(
|
|
3132
|
+
return new _ZodRecord({
|
|
3104
3133
|
keyType: first,
|
|
3105
3134
|
valueType: second,
|
|
3106
|
-
typeName: ZodFirstPartyTypeKind.ZodRecord
|
|
3107
|
-
|
|
3135
|
+
typeName: ZodFirstPartyTypeKind.ZodRecord,
|
|
3136
|
+
...processCreateParams(third)
|
|
3137
|
+
});
|
|
3108
3138
|
}
|
|
3109
|
-
return new _ZodRecord(
|
|
3139
|
+
return new _ZodRecord({
|
|
3110
3140
|
keyType: ZodString.create(),
|
|
3111
3141
|
valueType: first,
|
|
3112
|
-
typeName: ZodFirstPartyTypeKind.ZodRecord
|
|
3113
|
-
|
|
3142
|
+
typeName: ZodFirstPartyTypeKind.ZodRecord,
|
|
3143
|
+
...processCreateParams(second)
|
|
3144
|
+
});
|
|
3114
3145
|
}
|
|
3115
3146
|
};
|
|
3116
3147
|
var ZodMap = class extends ZodType {
|
|
@@ -3140,10 +3171,10 @@ var ZodMap = class extends ZodType {
|
|
|
3140
3171
|
});
|
|
3141
3172
|
if (ctx.common.async) {
|
|
3142
3173
|
const finalMap = /* @__PURE__ */ new Map();
|
|
3143
|
-
return Promise.resolve().then(() =>
|
|
3174
|
+
return Promise.resolve().then(async () => {
|
|
3144
3175
|
for (const pair of pairs) {
|
|
3145
|
-
const key =
|
|
3146
|
-
const value =
|
|
3176
|
+
const key = await pair.key;
|
|
3177
|
+
const value = await pair.value;
|
|
3147
3178
|
if (key.status === "aborted" || value.status === "aborted") {
|
|
3148
3179
|
return INVALID;
|
|
3149
3180
|
}
|
|
@@ -3153,7 +3184,7 @@ var ZodMap = class extends ZodType {
|
|
|
3153
3184
|
finalMap.set(key.value, value.value);
|
|
3154
3185
|
}
|
|
3155
3186
|
return { status: status.value, value: finalMap };
|
|
3156
|
-
})
|
|
3187
|
+
});
|
|
3157
3188
|
} else {
|
|
3158
3189
|
const finalMap = /* @__PURE__ */ new Map();
|
|
3159
3190
|
for (const pair of pairs) {
|
|
@@ -3172,11 +3203,12 @@ var ZodMap = class extends ZodType {
|
|
|
3172
3203
|
}
|
|
3173
3204
|
};
|
|
3174
3205
|
ZodMap.create = (keyType, valueType, params) => {
|
|
3175
|
-
return new ZodMap(
|
|
3206
|
+
return new ZodMap({
|
|
3176
3207
|
valueType,
|
|
3177
3208
|
keyType,
|
|
3178
|
-
typeName: ZodFirstPartyTypeKind.ZodMap
|
|
3179
|
-
|
|
3209
|
+
typeName: ZodFirstPartyTypeKind.ZodMap,
|
|
3210
|
+
...processCreateParams(params)
|
|
3211
|
+
});
|
|
3180
3212
|
};
|
|
3181
3213
|
var ZodSet = class _ZodSet extends ZodType {
|
|
3182
3214
|
_parse(input) {
|
|
@@ -3236,14 +3268,16 @@ var ZodSet = class _ZodSet extends ZodType {
|
|
|
3236
3268
|
}
|
|
3237
3269
|
}
|
|
3238
3270
|
min(minSize, message) {
|
|
3239
|
-
return new _ZodSet(
|
|
3271
|
+
return new _ZodSet({
|
|
3272
|
+
...this._def,
|
|
3240
3273
|
minSize: { value: minSize, message: errorUtil.toString(message) }
|
|
3241
|
-
})
|
|
3274
|
+
});
|
|
3242
3275
|
}
|
|
3243
3276
|
max(maxSize, message) {
|
|
3244
|
-
return new _ZodSet(
|
|
3277
|
+
return new _ZodSet({
|
|
3278
|
+
...this._def,
|
|
3245
3279
|
maxSize: { value: maxSize, message: errorUtil.toString(message) }
|
|
3246
|
-
})
|
|
3280
|
+
});
|
|
3247
3281
|
}
|
|
3248
3282
|
size(size, message) {
|
|
3249
3283
|
return this.min(size, message).max(size, message);
|
|
@@ -3253,12 +3287,13 @@ var ZodSet = class _ZodSet extends ZodType {
|
|
|
3253
3287
|
}
|
|
3254
3288
|
};
|
|
3255
3289
|
ZodSet.create = (valueType, params) => {
|
|
3256
|
-
return new ZodSet(
|
|
3290
|
+
return new ZodSet({
|
|
3257
3291
|
valueType,
|
|
3258
3292
|
minSize: null,
|
|
3259
3293
|
maxSize: null,
|
|
3260
|
-
typeName: ZodFirstPartyTypeKind.ZodSet
|
|
3261
|
-
|
|
3294
|
+
typeName: ZodFirstPartyTypeKind.ZodSet,
|
|
3295
|
+
...processCreateParams(params)
|
|
3296
|
+
});
|
|
3262
3297
|
};
|
|
3263
3298
|
var ZodFunction = class _ZodFunction extends ZodType {
|
|
3264
3299
|
constructor() {
|
|
@@ -3301,20 +3336,18 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
3301
3336
|
const fn = ctx.data;
|
|
3302
3337
|
if (this._def.returns instanceof ZodPromise) {
|
|
3303
3338
|
const me = this;
|
|
3304
|
-
return OK(function(...args) {
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
throw error;
|
|
3315
|
-
});
|
|
3316
|
-
return parsedReturns;
|
|
3339
|
+
return OK(async function(...args) {
|
|
3340
|
+
const error = new ZodError([]);
|
|
3341
|
+
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
3342
|
+
error.addIssue(makeArgsIssue(args, e));
|
|
3343
|
+
throw error;
|
|
3344
|
+
});
|
|
3345
|
+
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
3346
|
+
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
3347
|
+
error.addIssue(makeReturnsIssue(result, e));
|
|
3348
|
+
throw error;
|
|
3317
3349
|
});
|
|
3350
|
+
return parsedReturns;
|
|
3318
3351
|
});
|
|
3319
3352
|
} else {
|
|
3320
3353
|
const me = this;
|
|
@@ -3339,14 +3372,16 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
3339
3372
|
return this._def.returns;
|
|
3340
3373
|
}
|
|
3341
3374
|
args(...items) {
|
|
3342
|
-
return new _ZodFunction(
|
|
3375
|
+
return new _ZodFunction({
|
|
3376
|
+
...this._def,
|
|
3343
3377
|
args: ZodTuple.create(items).rest(ZodUnknown.create())
|
|
3344
|
-
})
|
|
3378
|
+
});
|
|
3345
3379
|
}
|
|
3346
3380
|
returns(returnType) {
|
|
3347
|
-
return new _ZodFunction(
|
|
3381
|
+
return new _ZodFunction({
|
|
3382
|
+
...this._def,
|
|
3348
3383
|
returns: returnType
|
|
3349
|
-
})
|
|
3384
|
+
});
|
|
3350
3385
|
}
|
|
3351
3386
|
implement(func) {
|
|
3352
3387
|
const validatedFunc = this.parse(func);
|
|
@@ -3357,11 +3392,12 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
3357
3392
|
return validatedFunc;
|
|
3358
3393
|
}
|
|
3359
3394
|
static create(args, returns, params) {
|
|
3360
|
-
return new _ZodFunction(
|
|
3395
|
+
return new _ZodFunction({
|
|
3361
3396
|
args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
|
|
3362
3397
|
returns: returns || ZodUnknown.create(),
|
|
3363
|
-
typeName: ZodFirstPartyTypeKind.ZodFunction
|
|
3364
|
-
|
|
3398
|
+
typeName: ZodFirstPartyTypeKind.ZodFunction,
|
|
3399
|
+
...processCreateParams(params)
|
|
3400
|
+
});
|
|
3365
3401
|
}
|
|
3366
3402
|
};
|
|
3367
3403
|
var ZodLazy = class extends ZodType {
|
|
@@ -3375,10 +3411,11 @@ var ZodLazy = class extends ZodType {
|
|
|
3375
3411
|
}
|
|
3376
3412
|
};
|
|
3377
3413
|
ZodLazy.create = (getter, params) => {
|
|
3378
|
-
return new ZodLazy(
|
|
3414
|
+
return new ZodLazy({
|
|
3379
3415
|
getter,
|
|
3380
|
-
typeName: ZodFirstPartyTypeKind.ZodLazy
|
|
3381
|
-
|
|
3416
|
+
typeName: ZodFirstPartyTypeKind.ZodLazy,
|
|
3417
|
+
...processCreateParams(params)
|
|
3418
|
+
});
|
|
3382
3419
|
};
|
|
3383
3420
|
var ZodLiteral = class extends ZodType {
|
|
3384
3421
|
_parse(input) {
|
|
@@ -3398,16 +3435,18 @@ var ZodLiteral = class extends ZodType {
|
|
|
3398
3435
|
}
|
|
3399
3436
|
};
|
|
3400
3437
|
ZodLiteral.create = (value, params) => {
|
|
3401
|
-
return new ZodLiteral(
|
|
3438
|
+
return new ZodLiteral({
|
|
3402
3439
|
value,
|
|
3403
|
-
typeName: ZodFirstPartyTypeKind.ZodLiteral
|
|
3404
|
-
|
|
3440
|
+
typeName: ZodFirstPartyTypeKind.ZodLiteral,
|
|
3441
|
+
...processCreateParams(params)
|
|
3442
|
+
});
|
|
3405
3443
|
};
|
|
3406
3444
|
function createZodEnum(values, params) {
|
|
3407
|
-
return new ZodEnum(
|
|
3445
|
+
return new ZodEnum({
|
|
3408
3446
|
values,
|
|
3409
|
-
typeName: ZodFirstPartyTypeKind.ZodEnum
|
|
3410
|
-
|
|
3447
|
+
typeName: ZodFirstPartyTypeKind.ZodEnum,
|
|
3448
|
+
...processCreateParams(params)
|
|
3449
|
+
});
|
|
3411
3450
|
}
|
|
3412
3451
|
var ZodEnum = class _ZodEnum extends ZodType {
|
|
3413
3452
|
_parse(input) {
|
|
@@ -3461,10 +3500,16 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3461
3500
|
return enumValues;
|
|
3462
3501
|
}
|
|
3463
3502
|
extract(values, newDef = this._def) {
|
|
3464
|
-
return _ZodEnum.create(values,
|
|
3503
|
+
return _ZodEnum.create(values, {
|
|
3504
|
+
...this._def,
|
|
3505
|
+
...newDef
|
|
3506
|
+
});
|
|
3465
3507
|
}
|
|
3466
3508
|
exclude(values, newDef = this._def) {
|
|
3467
|
-
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)),
|
|
3509
|
+
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
|
3510
|
+
...this._def,
|
|
3511
|
+
...newDef
|
|
3512
|
+
});
|
|
3468
3513
|
}
|
|
3469
3514
|
};
|
|
3470
3515
|
ZodEnum.create = createZodEnum;
|
|
@@ -3500,10 +3545,11 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3500
3545
|
}
|
|
3501
3546
|
};
|
|
3502
3547
|
ZodNativeEnum.create = (values, params) => {
|
|
3503
|
-
return new ZodNativeEnum(
|
|
3548
|
+
return new ZodNativeEnum({
|
|
3504
3549
|
values,
|
|
3505
|
-
typeName: ZodFirstPartyTypeKind.ZodNativeEnum
|
|
3506
|
-
|
|
3550
|
+
typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
|
|
3551
|
+
...processCreateParams(params)
|
|
3552
|
+
});
|
|
3507
3553
|
};
|
|
3508
3554
|
var ZodPromise = class extends ZodType {
|
|
3509
3555
|
unwrap() {
|
|
@@ -3529,10 +3575,11 @@ var ZodPromise = class extends ZodType {
|
|
|
3529
3575
|
}
|
|
3530
3576
|
};
|
|
3531
3577
|
ZodPromise.create = (schema, params) => {
|
|
3532
|
-
return new ZodPromise(
|
|
3578
|
+
return new ZodPromise({
|
|
3533
3579
|
type: schema,
|
|
3534
|
-
typeName: ZodFirstPartyTypeKind.ZodPromise
|
|
3535
|
-
|
|
3580
|
+
typeName: ZodFirstPartyTypeKind.ZodPromise,
|
|
3581
|
+
...processCreateParams(params)
|
|
3582
|
+
});
|
|
3536
3583
|
};
|
|
3537
3584
|
var ZodEffects = class extends ZodType {
|
|
3538
3585
|
innerType() {
|
|
@@ -3561,10 +3608,10 @@ var ZodEffects = class extends ZodType {
|
|
|
3561
3608
|
if (effect.type === "preprocess") {
|
|
3562
3609
|
const processed = effect.transform(ctx.data, checkCtx);
|
|
3563
3610
|
if (ctx.common.async) {
|
|
3564
|
-
return Promise.resolve(processed).then((processed2) =>
|
|
3611
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
|
3565
3612
|
if (status.value === "aborted")
|
|
3566
3613
|
return INVALID;
|
|
3567
|
-
const result =
|
|
3614
|
+
const result = await this._def.schema._parseAsync({
|
|
3568
3615
|
data: processed2,
|
|
3569
3616
|
path: ctx.path,
|
|
3570
3617
|
parent: ctx
|
|
@@ -3576,7 +3623,7 @@ var ZodEffects = class extends ZodType {
|
|
|
3576
3623
|
if (status.value === "dirty")
|
|
3577
3624
|
return DIRTY(result.value);
|
|
3578
3625
|
return result;
|
|
3579
|
-
})
|
|
3626
|
+
});
|
|
3580
3627
|
} else {
|
|
3581
3628
|
if (status.value === "aborted")
|
|
3582
3629
|
return INVALID;
|
|
@@ -3658,18 +3705,20 @@ var ZodEffects = class extends ZodType {
|
|
|
3658
3705
|
}
|
|
3659
3706
|
};
|
|
3660
3707
|
ZodEffects.create = (schema, effect, params) => {
|
|
3661
|
-
return new ZodEffects(
|
|
3708
|
+
return new ZodEffects({
|
|
3662
3709
|
schema,
|
|
3663
3710
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
3664
|
-
effect
|
|
3665
|
-
|
|
3711
|
+
effect,
|
|
3712
|
+
...processCreateParams(params)
|
|
3713
|
+
});
|
|
3666
3714
|
};
|
|
3667
3715
|
ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
|
|
3668
|
-
return new ZodEffects(
|
|
3716
|
+
return new ZodEffects({
|
|
3669
3717
|
schema,
|
|
3670
3718
|
effect: { type: "preprocess", transform: preprocess },
|
|
3671
|
-
typeName: ZodFirstPartyTypeKind.ZodEffects
|
|
3672
|
-
|
|
3719
|
+
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
3720
|
+
...processCreateParams(params)
|
|
3721
|
+
});
|
|
3673
3722
|
};
|
|
3674
3723
|
var ZodOptional = class extends ZodType {
|
|
3675
3724
|
_parse(input) {
|
|
@@ -3684,10 +3733,11 @@ var ZodOptional = class extends ZodType {
|
|
|
3684
3733
|
}
|
|
3685
3734
|
};
|
|
3686
3735
|
ZodOptional.create = (type, params) => {
|
|
3687
|
-
return new ZodOptional(
|
|
3736
|
+
return new ZodOptional({
|
|
3688
3737
|
innerType: type,
|
|
3689
|
-
typeName: ZodFirstPartyTypeKind.ZodOptional
|
|
3690
|
-
|
|
3738
|
+
typeName: ZodFirstPartyTypeKind.ZodOptional,
|
|
3739
|
+
...processCreateParams(params)
|
|
3740
|
+
});
|
|
3691
3741
|
};
|
|
3692
3742
|
var ZodNullable = class extends ZodType {
|
|
3693
3743
|
_parse(input) {
|
|
@@ -3702,10 +3752,11 @@ var ZodNullable = class extends ZodType {
|
|
|
3702
3752
|
}
|
|
3703
3753
|
};
|
|
3704
3754
|
ZodNullable.create = (type, params) => {
|
|
3705
|
-
return new ZodNullable(
|
|
3755
|
+
return new ZodNullable({
|
|
3706
3756
|
innerType: type,
|
|
3707
|
-
typeName: ZodFirstPartyTypeKind.ZodNullable
|
|
3708
|
-
|
|
3757
|
+
typeName: ZodFirstPartyTypeKind.ZodNullable,
|
|
3758
|
+
...processCreateParams(params)
|
|
3759
|
+
});
|
|
3709
3760
|
};
|
|
3710
3761
|
var ZodDefault = class extends ZodType {
|
|
3711
3762
|
_parse(input) {
|
|
@@ -3725,24 +3776,29 @@ var ZodDefault = class extends ZodType {
|
|
|
3725
3776
|
}
|
|
3726
3777
|
};
|
|
3727
3778
|
ZodDefault.create = (type, params) => {
|
|
3728
|
-
return new ZodDefault(
|
|
3779
|
+
return new ZodDefault({
|
|
3729
3780
|
innerType: type,
|
|
3730
3781
|
typeName: ZodFirstPartyTypeKind.ZodDefault,
|
|
3731
|
-
defaultValue: typeof params.default === "function" ? params.default : () => params.default
|
|
3732
|
-
|
|
3782
|
+
defaultValue: typeof params.default === "function" ? params.default : () => params.default,
|
|
3783
|
+
...processCreateParams(params)
|
|
3784
|
+
});
|
|
3733
3785
|
};
|
|
3734
3786
|
var ZodCatch = class extends ZodType {
|
|
3735
3787
|
_parse(input) {
|
|
3736
3788
|
const { ctx } = this._processInputParams(input);
|
|
3737
|
-
const newCtx =
|
|
3738
|
-
|
|
3789
|
+
const newCtx = {
|
|
3790
|
+
...ctx,
|
|
3791
|
+
common: {
|
|
3792
|
+
...ctx.common,
|
|
3739
3793
|
issues: []
|
|
3740
|
-
}
|
|
3741
|
-
}
|
|
3794
|
+
}
|
|
3795
|
+
};
|
|
3742
3796
|
const result = this._def.innerType._parse({
|
|
3743
3797
|
data: newCtx.data,
|
|
3744
3798
|
path: newCtx.path,
|
|
3745
|
-
parent:
|
|
3799
|
+
parent: {
|
|
3800
|
+
...newCtx
|
|
3801
|
+
}
|
|
3746
3802
|
});
|
|
3747
3803
|
if (isAsync(result)) {
|
|
3748
3804
|
return result.then((result2) => {
|
|
@@ -3773,11 +3829,12 @@ var ZodCatch = class extends ZodType {
|
|
|
3773
3829
|
}
|
|
3774
3830
|
};
|
|
3775
3831
|
ZodCatch.create = (type, params) => {
|
|
3776
|
-
return new ZodCatch(
|
|
3832
|
+
return new ZodCatch({
|
|
3777
3833
|
innerType: type,
|
|
3778
3834
|
typeName: ZodFirstPartyTypeKind.ZodCatch,
|
|
3779
|
-
catchValue: typeof params.catch === "function" ? params.catch : () => params.catch
|
|
3780
|
-
|
|
3835
|
+
catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
|
|
3836
|
+
...processCreateParams(params)
|
|
3837
|
+
});
|
|
3781
3838
|
};
|
|
3782
3839
|
var ZodNaN = class extends ZodType {
|
|
3783
3840
|
_parse(input) {
|
|
@@ -3795,9 +3852,10 @@ var ZodNaN = class extends ZodType {
|
|
|
3795
3852
|
}
|
|
3796
3853
|
};
|
|
3797
3854
|
ZodNaN.create = (params) => {
|
|
3798
|
-
return new ZodNaN(
|
|
3799
|
-
typeName: ZodFirstPartyTypeKind.ZodNaN
|
|
3800
|
-
|
|
3855
|
+
return new ZodNaN({
|
|
3856
|
+
typeName: ZodFirstPartyTypeKind.ZodNaN,
|
|
3857
|
+
...processCreateParams(params)
|
|
3858
|
+
});
|
|
3801
3859
|
};
|
|
3802
3860
|
var BRAND = Symbol("zod_brand");
|
|
3803
3861
|
var ZodBranded = class extends ZodType {
|
|
@@ -3818,8 +3876,8 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
3818
3876
|
_parse(input) {
|
|
3819
3877
|
const { status, ctx } = this._processInputParams(input);
|
|
3820
3878
|
if (ctx.common.async) {
|
|
3821
|
-
const handleAsync = () =>
|
|
3822
|
-
const inResult =
|
|
3879
|
+
const handleAsync = async () => {
|
|
3880
|
+
const inResult = await this._def.in._parseAsync({
|
|
3823
3881
|
data: ctx.data,
|
|
3824
3882
|
path: ctx.path,
|
|
3825
3883
|
parent: ctx
|
|
@@ -3836,7 +3894,7 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
3836
3894
|
parent: ctx
|
|
3837
3895
|
});
|
|
3838
3896
|
}
|
|
3839
|
-
}
|
|
3897
|
+
};
|
|
3840
3898
|
return handleAsync();
|
|
3841
3899
|
} else {
|
|
3842
3900
|
const inResult = this._def.in._parseSync({
|
|
@@ -3885,10 +3943,11 @@ var ZodReadonly = class extends ZodType {
|
|
|
3885
3943
|
}
|
|
3886
3944
|
};
|
|
3887
3945
|
ZodReadonly.create = (type, params) => {
|
|
3888
|
-
return new ZodReadonly(
|
|
3946
|
+
return new ZodReadonly({
|
|
3889
3947
|
innerType: type,
|
|
3890
|
-
typeName: ZodFirstPartyTypeKind.ZodReadonly
|
|
3891
|
-
|
|
3948
|
+
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
|
3949
|
+
...processCreateParams(params)
|
|
3950
|
+
});
|
|
3892
3951
|
};
|
|
3893
3952
|
function cleanParams(params, data) {
|
|
3894
3953
|
const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
|
|
@@ -3898,22 +3957,20 @@ function cleanParams(params, data) {
|
|
|
3898
3957
|
function custom(check, _params = {}, fatal) {
|
|
3899
3958
|
if (check)
|
|
3900
3959
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
3901
|
-
var _a, _b;
|
|
3902
3960
|
const r = check(data);
|
|
3903
3961
|
if (r instanceof Promise) {
|
|
3904
3962
|
return r.then((r2) => {
|
|
3905
|
-
var _a2, _b2;
|
|
3906
3963
|
if (!r2) {
|
|
3907
3964
|
const params = cleanParams(_params, data);
|
|
3908
|
-
const _fatal =
|
|
3909
|
-
ctx.addIssue(
|
|
3965
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
3966
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
3910
3967
|
}
|
|
3911
3968
|
});
|
|
3912
3969
|
}
|
|
3913
3970
|
if (!r) {
|
|
3914
3971
|
const params = cleanParams(_params, data);
|
|
3915
|
-
const _fatal =
|
|
3916
|
-
ctx.addIssue(
|
|
3972
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
3973
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
3917
3974
|
}
|
|
3918
3975
|
return;
|
|
3919
3976
|
});
|
|
@@ -4002,18 +4059,29 @@ var ostring = () => stringType().optional();
|
|
|
4002
4059
|
var onumber = () => numberType().optional();
|
|
4003
4060
|
var oboolean = () => booleanType().optional();
|
|
4004
4061
|
var coerce = {
|
|
4005
|
-
string: ((arg) => ZodString.create(
|
|
4006
|
-
number: ((arg) => ZodNumber.create(
|
|
4007
|
-
boolean: ((arg) => ZodBoolean.create(
|
|
4062
|
+
string: ((arg) => ZodString.create({ ...arg, coerce: true })),
|
|
4063
|
+
number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
|
|
4064
|
+
boolean: ((arg) => ZodBoolean.create({
|
|
4065
|
+
...arg,
|
|
4008
4066
|
coerce: true
|
|
4009
|
-
}))
|
|
4010
|
-
bigint: ((arg) => ZodBigInt.create(
|
|
4011
|
-
date: ((arg) => ZodDate.create(
|
|
4067
|
+
})),
|
|
4068
|
+
bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
|
|
4069
|
+
date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
|
|
4012
4070
|
};
|
|
4013
4071
|
var NEVER = INVALID;
|
|
4014
4072
|
|
|
4015
4073
|
// src/client.ts
|
|
4016
4074
|
var RichError = class extends Error {
|
|
4075
|
+
status;
|
|
4076
|
+
// HTTP status code (e.g. 404, 500)
|
|
4077
|
+
code;
|
|
4078
|
+
// Application-level error code (e.g. "USER_NOT_FOUND")
|
|
4079
|
+
title;
|
|
4080
|
+
// Optional title or short summary
|
|
4081
|
+
detail;
|
|
4082
|
+
// Additional human-readable explanation
|
|
4083
|
+
errors;
|
|
4084
|
+
// Field-specific validation errors
|
|
4017
4085
|
constructor(error) {
|
|
4018
4086
|
super(error.message);
|
|
4019
4087
|
Object.assign(this, error);
|
|
@@ -4023,17 +4091,31 @@ var ApiClient = class {
|
|
|
4023
4091
|
constructor(config, contracts) {
|
|
4024
4092
|
this.config = config;
|
|
4025
4093
|
this.contracts = contracts;
|
|
4026
|
-
this.middlewares = [];
|
|
4027
|
-
this.responseTransform = (d) => d;
|
|
4028
|
-
this.useMockData = false;
|
|
4029
|
-
this.mockDelay = { min: 100, max: 1e3 };
|
|
4030
4094
|
this.useMockData = config.useMockData || false;
|
|
4031
4095
|
this.mockDelay = config.mockDelay || { min: 100, max: 1e3 };
|
|
4032
4096
|
this.tokenProvider = config.tokenProvider;
|
|
4033
4097
|
}
|
|
4098
|
+
middlewares = [];
|
|
4099
|
+
// Registered middlewares
|
|
4100
|
+
errorHandler;
|
|
4101
|
+
// Global error handler
|
|
4102
|
+
responseTransform = (d) => d;
|
|
4103
|
+
// Post-parse data transformer
|
|
4104
|
+
useMockData = false;
|
|
4105
|
+
// Whether mock responses are enabled
|
|
4106
|
+
mockDelay = { min: 100, max: 1e3 };
|
|
4107
|
+
// Mock latency range (ms)
|
|
4108
|
+
responseWrapper;
|
|
4109
|
+
// Wrapper for APIs with envelope structures
|
|
4110
|
+
tokenProvider;
|
|
4111
|
+
// Optional async token supplier
|
|
4112
|
+
// Configuration for retry behavior
|
|
4113
|
+
retryConfig;
|
|
4114
|
+
// Holds generated API endpoint methods
|
|
4115
|
+
_modules;
|
|
4034
4116
|
/**
|
|
4035
|
-
* Builds
|
|
4036
|
-
*
|
|
4117
|
+
* Builds all API methods (`modules`) dynamically from the Zod contract definition.
|
|
4118
|
+
* After `init()` is called, each endpoint can be invoked through `client.modules.moduleName.endpointName()`.
|
|
4037
4119
|
*/
|
|
4038
4120
|
init() {
|
|
4039
4121
|
const modules = {};
|
|
@@ -4042,285 +4124,215 @@ var ApiClient = class {
|
|
|
4042
4124
|
modules[moduleName] = {};
|
|
4043
4125
|
for (const endpointName in module2) {
|
|
4044
4126
|
const endpoint = module2[endpointName];
|
|
4045
|
-
modules[moduleName][endpointName] = (input) => this.request(endpoint, input);
|
|
4127
|
+
modules[moduleName][endpointName] = (input, options) => this.request(endpoint, input, options);
|
|
4046
4128
|
}
|
|
4047
4129
|
}
|
|
4048
4130
|
this._modules = modules;
|
|
4049
4131
|
}
|
|
4050
|
-
/**
|
|
4051
|
-
* Type-safe entrypoint for calling API endpoints.
|
|
4052
|
-
* Populated by `init()` based on the `contracts` passed to the constructor.
|
|
4053
|
-
*/
|
|
4132
|
+
/** Provides access to initialized modules after calling `init()`. */
|
|
4054
4133
|
get modules() {
|
|
4055
4134
|
return this._modules;
|
|
4056
4135
|
}
|
|
4057
|
-
/**
|
|
4058
|
-
* Registers a middleware in the pipeline.
|
|
4059
|
-
* Middlewares are executed in reverse order of registration.
|
|
4060
|
-
*/
|
|
4136
|
+
/** Registers a new middleware in the client’s pipeline. */
|
|
4061
4137
|
use(middleware, options) {
|
|
4062
4138
|
this.middlewares.push({ fn: middleware, options });
|
|
4063
4139
|
}
|
|
4064
|
-
/**
|
|
4065
|
-
* Registers a global error handler.
|
|
4066
|
-
* The handler is invoked for normalized errors before they are re-thrown.
|
|
4067
|
-
*/
|
|
4140
|
+
/** Sets a global error handler function to unify error behavior. */
|
|
4068
4141
|
onError(handler) {
|
|
4069
4142
|
this.errorHandler = handler;
|
|
4070
4143
|
}
|
|
4071
|
-
/**
|
|
4072
|
-
* Registers a transformation function applied to all successful responses
|
|
4073
|
-
* after Zod parsing.
|
|
4074
|
-
*/
|
|
4144
|
+
/** Defines a global transform function applied to all validated responses. */
|
|
4075
4145
|
useResponseTransform(fn) {
|
|
4076
4146
|
this.responseTransform = fn;
|
|
4077
4147
|
}
|
|
4078
|
-
/**
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4148
|
+
/** Configures the retry logic (max attempts, backoff mode, etc.). */
|
|
4149
|
+
setRetryConfig(config) {
|
|
4150
|
+
this.retryConfig = config;
|
|
4151
|
+
}
|
|
4152
|
+
/** Provides a custom token provider that returns tokens dynamically. */
|
|
4153
|
+
setTokenProvider(provider) {
|
|
4154
|
+
this.tokenProvider = provider;
|
|
4155
|
+
}
|
|
4156
|
+
/** Enables mock responses instead of network requests. */
|
|
4082
4157
|
setMockMode(enabled, delay) {
|
|
4083
4158
|
this.useMockData = enabled;
|
|
4084
|
-
if (delay)
|
|
4085
|
-
this.mockDelay = delay;
|
|
4086
|
-
}
|
|
4159
|
+
if (delay) this.mockDelay = delay;
|
|
4087
4160
|
}
|
|
4088
|
-
/**
|
|
4089
|
-
* Registers a schema wrapper for APIs that wrap data in an envelope.
|
|
4090
|
-
* Example: { success, data, message, code, ... }.
|
|
4091
|
-
*/
|
|
4161
|
+
/** Registers a wrapper schema for APIs that nest response data (e.g. `{ data, success, message }`). */
|
|
4092
4162
|
setResponseWrapper(wrapper) {
|
|
4093
4163
|
this.responseWrapper = wrapper;
|
|
4094
4164
|
}
|
|
4095
|
-
/**
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
setTokenProvider(provider) {
|
|
4100
|
-
this.tokenProvider = provider;
|
|
4165
|
+
/** Retrieves the current auth token, using a provider if available. */
|
|
4166
|
+
async getCurrentToken() {
|
|
4167
|
+
if (this.tokenProvider) return await this.tokenProvider();
|
|
4168
|
+
return this.config.token;
|
|
4101
4169
|
}
|
|
4102
4170
|
/**
|
|
4103
|
-
*
|
|
4104
|
-
*
|
|
4171
|
+
* Core request entry point used by auto-generated endpoint methods.
|
|
4172
|
+
* Handles caching, deduplication, and mock mode routing.
|
|
4105
4173
|
*/
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
});
|
|
4174
|
+
async request(endpoint, input, options) {
|
|
4175
|
+
const parsedInput = endpoint.request.parse(input);
|
|
4176
|
+
if (this.useMockData && endpoint.mockData) {
|
|
4177
|
+
return this.handleMockRequest(endpoint);
|
|
4178
|
+
}
|
|
4179
|
+
const { url, body } = this.buildUrlAndBody(endpoint, parsedInput);
|
|
4180
|
+
const requestKey = JSON.stringify({ method: endpoint.method, url, body });
|
|
4181
|
+
const promise = this.performRequestLogic(
|
|
4182
|
+
endpoint,
|
|
4183
|
+
parsedInput,
|
|
4184
|
+
url,
|
|
4185
|
+
body,
|
|
4186
|
+
requestKey,
|
|
4187
|
+
options
|
|
4188
|
+
);
|
|
4189
|
+
return promise;
|
|
4113
4190
|
}
|
|
4114
4191
|
/**
|
|
4115
|
-
*
|
|
4116
|
-
*
|
|
4117
|
-
*
|
|
4118
|
-
*
|
|
4119
|
-
*
|
|
4120
|
-
*
|
|
4121
|
-
*
|
|
4122
|
-
* })
|
|
4123
|
-
*
|
|
4124
|
-
* If the parsed request does not contain `path`, `query` or `body`,
|
|
4125
|
-
* the entire input is treated as the legacy flat request body.
|
|
4192
|
+
* Full HTTP request workflow:
|
|
4193
|
+
* - Token injection
|
|
4194
|
+
* - Timeout support
|
|
4195
|
+
* - Middleware pipeline
|
|
4196
|
+
* - Fetch + response handling
|
|
4197
|
+
* - Zod parsing + transformation
|
|
4198
|
+
* - Caching
|
|
4126
4199
|
*/
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4200
|
+
async performRequestLogic(endpoint, parsedInput, url, body, key, options) {
|
|
4201
|
+
const headers = {};
|
|
4202
|
+
const token = await this.getCurrentToken();
|
|
4203
|
+
if (endpoint.auth && !token) {
|
|
4204
|
+
const error = this.createError({
|
|
4205
|
+
message: `Missing token for ${endpoint.path}`,
|
|
4206
|
+
status: 401,
|
|
4207
|
+
code: "NO_TOKEN"
|
|
4208
|
+
});
|
|
4209
|
+
this.errorHandler?.(error);
|
|
4210
|
+
throw error;
|
|
4211
|
+
}
|
|
4212
|
+
if (endpoint.auth && token) headers["Authorization"] = `Bearer ${token}`;
|
|
4213
|
+
if (endpoint.bodyType !== "form-data")
|
|
4214
|
+
headers["Content-Type"] = "application/json";
|
|
4215
|
+
const ctx = {
|
|
4216
|
+
url,
|
|
4217
|
+
init: { method: endpoint.method, headers, body }
|
|
4218
|
+
};
|
|
4219
|
+
let controller;
|
|
4220
|
+
let timeoutId;
|
|
4221
|
+
if (options?.timeout) {
|
|
4222
|
+
controller = new AbortController();
|
|
4223
|
+
timeoutId = setTimeout(() => controller.abort(), options.timeout);
|
|
4224
|
+
}
|
|
4225
|
+
if (options?.signal || controller)
|
|
4226
|
+
ctx.init.signal = options?.signal || controller?.signal;
|
|
4227
|
+
const runner = this.middlewares.reduceRight(
|
|
4228
|
+
(next, mw) => () => mw.fn(ctx, next, mw.options),
|
|
4229
|
+
() => fetch(ctx.url, ctx.init)
|
|
4230
|
+
);
|
|
4231
|
+
const execute = async () => {
|
|
4232
|
+
const res = await runner();
|
|
4233
|
+
const json = await res.json();
|
|
4234
|
+
let responseData = json;
|
|
4235
|
+
if (this.responseWrapper) {
|
|
4236
|
+
const wrappedSchema = this.responseWrapper(endpoint.response);
|
|
4237
|
+
const parsedWrapped = wrappedSchema.parse(json);
|
|
4238
|
+
if (parsedWrapped.success === false) {
|
|
4239
|
+
const error = this.createError({
|
|
4240
|
+
message: parsedWrapped.message || "Request failed",
|
|
4241
|
+
status: parsedWrapped.code || res.status,
|
|
4242
|
+
code: `API_ERROR_${parsedWrapped.code}`
|
|
4243
|
+
});
|
|
4244
|
+
this.errorHandler?.(error);
|
|
4245
|
+
throw error;
|
|
4246
|
+
}
|
|
4247
|
+
responseData = parsedWrapped.data;
|
|
4137
4248
|
}
|
|
4138
|
-
if (
|
|
4249
|
+
if (!res.ok) {
|
|
4139
4250
|
const error = this.createError({
|
|
4140
|
-
message:
|
|
4141
|
-
status:
|
|
4142
|
-
code:
|
|
4251
|
+
message: json.message || res.statusText,
|
|
4252
|
+
status: res.status,
|
|
4253
|
+
code: json.code,
|
|
4254
|
+
title: json.title,
|
|
4255
|
+
detail: json.detail,
|
|
4256
|
+
errors: json.errors
|
|
4143
4257
|
});
|
|
4144
|
-
|
|
4258
|
+
this.errorHandler?.(error);
|
|
4145
4259
|
throw error;
|
|
4146
4260
|
}
|
|
4147
|
-
const
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
const
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4261
|
+
const parsed = endpoint.response.parse(responseData);
|
|
4262
|
+
const result = this.responseTransform(parsed);
|
|
4263
|
+
return result;
|
|
4264
|
+
};
|
|
4265
|
+
try {
|
|
4266
|
+
const result = await this.executeWithRetry(execute);
|
|
4267
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
4268
|
+
return result;
|
|
4269
|
+
} catch (err) {
|
|
4270
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
4271
|
+
const error = this.normalizeError(err);
|
|
4272
|
+
this.errorHandler?.(error);
|
|
4273
|
+
throw error;
|
|
4274
|
+
}
|
|
4275
|
+
}
|
|
4276
|
+
// =========================================================
|
|
4277
|
+
// 🔁 RETRY ENGINE
|
|
4278
|
+
// =========================================================
|
|
4279
|
+
/** Executes a function with retry logic and configurable backoff strategy. */
|
|
4280
|
+
async executeWithRetry(fn) {
|
|
4281
|
+
if (!this.retryConfig) return fn();
|
|
4282
|
+
const { maxRetries, backoff, retryCondition } = this.retryConfig;
|
|
4283
|
+
let attempt = 0;
|
|
4284
|
+
while (true) {
|
|
4164
4285
|
try {
|
|
4165
|
-
|
|
4166
|
-
const json = yield res.json();
|
|
4167
|
-
let responseData = json;
|
|
4168
|
-
if (this.responseWrapper) {
|
|
4169
|
-
const wrappedSchema = this.responseWrapper(endpoint.response);
|
|
4170
|
-
const parsedResponse = wrappedSchema.parse(json);
|
|
4171
|
-
if (parsedResponse.success === false) {
|
|
4172
|
-
const error = this.createError({
|
|
4173
|
-
message: parsedResponse.message || "Request failed",
|
|
4174
|
-
status: parsedResponse.code || res.status,
|
|
4175
|
-
code: `API_ERROR_${parsedResponse.code}`
|
|
4176
|
-
});
|
|
4177
|
-
(_b = this.errorHandler) == null ? void 0 : _b.call(this, error);
|
|
4178
|
-
throw error;
|
|
4179
|
-
}
|
|
4180
|
-
responseData = parsedResponse.data;
|
|
4181
|
-
}
|
|
4182
|
-
if (!res.ok) {
|
|
4183
|
-
const error = this.createError({
|
|
4184
|
-
message: json.message || res.statusText,
|
|
4185
|
-
status: res.status,
|
|
4186
|
-
code: json.code,
|
|
4187
|
-
title: json.title,
|
|
4188
|
-
detail: json.detail,
|
|
4189
|
-
errors: json.errors
|
|
4190
|
-
});
|
|
4191
|
-
(_c = this.errorHandler) == null ? void 0 : _c.call(this, error);
|
|
4192
|
-
throw error;
|
|
4193
|
-
}
|
|
4194
|
-
return this.responseTransform(endpoint.response.parse(responseData));
|
|
4286
|
+
return await fn();
|
|
4195
4287
|
} catch (err) {
|
|
4288
|
+
attempt++;
|
|
4196
4289
|
const error = this.normalizeError(err);
|
|
4197
|
-
|
|
4198
|
-
throw error;
|
|
4290
|
+
const shouldRetry = attempt <= maxRetries && (retryCondition?.(error, attempt) ?? (error.status !== void 0 && error.status >= 500));
|
|
4291
|
+
if (!shouldRetry) throw error;
|
|
4292
|
+
const delay = this.getBackoffDelay(backoff, attempt);
|
|
4293
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
4199
4294
|
}
|
|
4200
|
-
}
|
|
4295
|
+
}
|
|
4201
4296
|
}
|
|
4202
|
-
/**
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
const isObject = typeof parsedInput === "object" && parsedInput !== null;
|
|
4213
|
-
const hasNewShape = isObject && ("path" in parsedInput || "query" in parsedInput || "body" in parsedInput);
|
|
4214
|
-
if (!hasNewShape) {
|
|
4215
|
-
const url2 = this.config.baseUrl + endpoint.path;
|
|
4216
|
-
let requestBody2 = void 0;
|
|
4217
|
-
if (endpoint.method !== "GET") {
|
|
4218
|
-
requestBody2 = JSON.stringify(parsedInput);
|
|
4219
|
-
}
|
|
4220
|
-
return { url: url2, body: requestBody2 };
|
|
4297
|
+
/** Calculates retry delay intervals for various backoff strategies. */
|
|
4298
|
+
getBackoffDelay(type, attempt) {
|
|
4299
|
+
const base = 300;
|
|
4300
|
+
switch (type) {
|
|
4301
|
+
case "fixed":
|
|
4302
|
+
return base;
|
|
4303
|
+
case "linear":
|
|
4304
|
+
return base * attempt;
|
|
4305
|
+
case "exponential":
|
|
4306
|
+
return base * Math.pow(2, attempt - 1);
|
|
4221
4307
|
}
|
|
4222
|
-
|
|
4308
|
+
}
|
|
4309
|
+
// =========================================================
|
|
4310
|
+
// 🔧 UTILITIES
|
|
4311
|
+
// =========================================================
|
|
4312
|
+
/** Builds the final URL and request body from the endpoint definition and input payload. */
|
|
4313
|
+
buildUrlAndBody(endpoint, input) {
|
|
4223
4314
|
let url = this.config.baseUrl + endpoint.path;
|
|
4224
|
-
|
|
4225
|
-
for (const [key, value] of Object.entries(path)) {
|
|
4226
|
-
if (value === void 0 || value === null) continue;
|
|
4227
|
-
const token = `:${key}`;
|
|
4228
|
-
if (!url.includes(token)) {
|
|
4229
|
-
continue;
|
|
4230
|
-
}
|
|
4231
|
-
url = url.replace(token, encodeURIComponent(String(value)));
|
|
4232
|
-
}
|
|
4233
|
-
}
|
|
4234
|
-
const templatePlaceholders = Array.from(
|
|
4235
|
-
endpoint.path.matchAll(/:([A-Za-z0-9_]+)/g)
|
|
4236
|
-
).map((m) => m[1]);
|
|
4237
|
-
const missingTokens = templatePlaceholders.filter((name) => {
|
|
4238
|
-
const v = path ? path[name] : void 0;
|
|
4239
|
-
return v === void 0 || v === null;
|
|
4240
|
-
});
|
|
4241
|
-
if (missingTokens.length > 0) {
|
|
4242
|
-
throw this.createError({
|
|
4243
|
-
message: `Missing path params for placeholders: ${missingTokens.join(
|
|
4244
|
-
", "
|
|
4245
|
-
)} in "${endpoint.path}"`,
|
|
4246
|
-
code: "MISSING_PATH_PARAMS"
|
|
4247
|
-
});
|
|
4248
|
-
}
|
|
4249
|
-
if (query) {
|
|
4250
|
-
const searchParams = new URLSearchParams();
|
|
4251
|
-
for (const [key, value] of Object.entries(query)) {
|
|
4252
|
-
if (value === void 0 || value === null) continue;
|
|
4253
|
-
if (Array.isArray(value)) {
|
|
4254
|
-
for (const v of value) {
|
|
4255
|
-
if (v === void 0 || v === null) continue;
|
|
4256
|
-
searchParams.append(key, String(v));
|
|
4257
|
-
}
|
|
4258
|
-
} else if (typeof value === "object") {
|
|
4259
|
-
searchParams.append(key, JSON.stringify(value));
|
|
4260
|
-
} else {
|
|
4261
|
-
searchParams.append(key, String(value));
|
|
4262
|
-
}
|
|
4263
|
-
}
|
|
4264
|
-
const qs = searchParams.toString();
|
|
4265
|
-
if (qs) {
|
|
4266
|
-
url += (url.includes("?") ? "&" : "?") + qs;
|
|
4267
|
-
}
|
|
4268
|
-
}
|
|
4269
|
-
let requestBody = void 0;
|
|
4315
|
+
let body;
|
|
4270
4316
|
if (endpoint.method !== "GET") {
|
|
4271
|
-
if (
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
/**
|
|
4278
|
-
* Returns a mocked response based on `endpoint.mockData`,
|
|
4279
|
-
* respecting the configured mock delay and response wrapper.
|
|
4280
|
-
*/
|
|
4281
|
-
handleMockRequest(endpoint) {
|
|
4282
|
-
return __async(this, null, function* () {
|
|
4283
|
-
const delay = this.getRandomDelay();
|
|
4284
|
-
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
4285
|
-
let mockData;
|
|
4286
|
-
if (typeof endpoint.mockData === "function") {
|
|
4287
|
-
mockData = endpoint.mockData();
|
|
4317
|
+
if (endpoint.bodyType === "form-data") {
|
|
4318
|
+
const form = new FormData();
|
|
4319
|
+
for (const [k, v] of Object.entries(input.body || {})) {
|
|
4320
|
+
if (v != null) form.append(k, v);
|
|
4321
|
+
}
|
|
4322
|
+
body = form;
|
|
4288
4323
|
} else {
|
|
4289
|
-
|
|
4324
|
+
body = JSON.stringify(input.body ?? input);
|
|
4290
4325
|
}
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
const mockWrappedResponse = {
|
|
4294
|
-
success: true,
|
|
4295
|
-
data: mockData,
|
|
4296
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4297
|
-
requestId: `mock-${Math.random().toString(36).substr(2, 9)}`
|
|
4298
|
-
};
|
|
4299
|
-
const parsedWrappedResponse = wrappedSchema.parse(mockWrappedResponse);
|
|
4300
|
-
return this.responseTransform(
|
|
4301
|
-
endpoint.response.parse(parsedWrappedResponse.data)
|
|
4302
|
-
);
|
|
4303
|
-
}
|
|
4304
|
-
return this.responseTransform(endpoint.response.parse(mockData));
|
|
4305
|
-
});
|
|
4306
|
-
}
|
|
4307
|
-
/**
|
|
4308
|
-
* Returns a random delay in milliseconds within the current mock delay range.
|
|
4309
|
-
*/
|
|
4310
|
-
getRandomDelay() {
|
|
4311
|
-
return Math.floor(
|
|
4312
|
-
Math.random() * (this.mockDelay.max - this.mockDelay.min + 1)
|
|
4313
|
-
) + this.mockDelay.min;
|
|
4326
|
+
}
|
|
4327
|
+
return { url, body };
|
|
4314
4328
|
}
|
|
4315
|
-
/**
|
|
4316
|
-
* Creates a RichError instance from a partial error description.
|
|
4317
|
-
*/
|
|
4329
|
+
/** Creates and returns a RichError from details. */
|
|
4318
4330
|
createError(error) {
|
|
4319
4331
|
return new RichError(error);
|
|
4320
4332
|
}
|
|
4321
4333
|
/**
|
|
4322
|
-
*
|
|
4323
|
-
* Zod validation errors
|
|
4334
|
+
* Converts any thrown error to a standardized RichError instance.
|
|
4335
|
+
* Also flattens Zod validation errors into readable messages.
|
|
4324
4336
|
*/
|
|
4325
4337
|
normalizeError(err) {
|
|
4326
4338
|
if (err instanceof RichError) return err;
|
|
@@ -4332,67 +4344,99 @@ var ApiClient = class {
|
|
|
4332
4344
|
}
|
|
4333
4345
|
return this.createError({ message: err.message || "Unknown error" });
|
|
4334
4346
|
}
|
|
4347
|
+
/**
|
|
4348
|
+
* Handles mock-mode requests by simulating a delayed network call
|
|
4349
|
+
* and returning validated mock data.
|
|
4350
|
+
*/
|
|
4351
|
+
async handleMockRequest(endpoint) {
|
|
4352
|
+
const delay = Math.floor(
|
|
4353
|
+
Math.random() * (this.mockDelay.max - this.mockDelay.min + 1)
|
|
4354
|
+
) + this.mockDelay.min;
|
|
4355
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
4356
|
+
const data = typeof endpoint.mockData === "function" ? endpoint.mockData() : endpoint.mockData;
|
|
4357
|
+
return this.responseTransform(endpoint.response.parse(data));
|
|
4358
|
+
}
|
|
4335
4359
|
};
|
|
4336
4360
|
|
|
4337
4361
|
// src/middlewares/logging.ts
|
|
4338
|
-
var loggingMiddleware = (ctx, next, options) =>
|
|
4362
|
+
var loggingMiddleware = async (ctx, next, options) => {
|
|
4339
4363
|
const { logRequest = true, logResponse = true, debug = true } = options || {};
|
|
4340
4364
|
if (debug && logRequest) console.log("\u27A1\uFE0F Request:", ctx.url, ctx.init);
|
|
4341
|
-
const res =
|
|
4365
|
+
const res = await next();
|
|
4342
4366
|
if (debug && logResponse) console.log("\u2B05\uFE0F Response:", res.status);
|
|
4343
4367
|
return res;
|
|
4344
|
-
}
|
|
4368
|
+
};
|
|
4345
4369
|
|
|
4346
4370
|
// src/middlewares/retry.ts
|
|
4347
4371
|
var retryMiddleware = (options) => {
|
|
4348
4372
|
const { maxRetries = 3, delay = 500 } = options || {};
|
|
4349
|
-
const middleware = (ctx, next) =>
|
|
4373
|
+
const middleware = async (ctx, next) => {
|
|
4350
4374
|
let attempt = 0;
|
|
4351
4375
|
while (true) {
|
|
4352
4376
|
try {
|
|
4353
|
-
return
|
|
4377
|
+
return await next();
|
|
4354
4378
|
} catch (err) {
|
|
4355
4379
|
if (attempt >= maxRetries) throw err;
|
|
4356
4380
|
attempt++;
|
|
4357
|
-
|
|
4381
|
+
await new Promise((r) => setTimeout(r, delay * 2 ** attempt));
|
|
4358
4382
|
}
|
|
4359
4383
|
}
|
|
4360
|
-
}
|
|
4384
|
+
};
|
|
4361
4385
|
return middleware;
|
|
4362
4386
|
};
|
|
4363
4387
|
|
|
4364
4388
|
// src/middlewares/auth.ts
|
|
4365
|
-
var authMiddleware = (ctx, next, options) =>
|
|
4366
|
-
if (options
|
|
4389
|
+
var authMiddleware = async (ctx, next, options) => {
|
|
4390
|
+
if (options?.refreshToken) {
|
|
4367
4391
|
try {
|
|
4368
|
-
const newToken =
|
|
4369
|
-
ctx.init.headers =
|
|
4392
|
+
const newToken = await options.refreshToken();
|
|
4393
|
+
ctx.init.headers = {
|
|
4394
|
+
...ctx.init.headers,
|
|
4395
|
+
// Preserve any headers set by prior middleware
|
|
4370
4396
|
Authorization: `Bearer ${newToken}`
|
|
4371
|
-
}
|
|
4372
|
-
} catch (
|
|
4397
|
+
};
|
|
4398
|
+
} catch (error) {
|
|
4399
|
+
console.warn(
|
|
4400
|
+
"Authentication token refresh failed, proceeding without authorization header.",
|
|
4401
|
+
error
|
|
4402
|
+
);
|
|
4373
4403
|
}
|
|
4374
4404
|
}
|
|
4375
4405
|
return next();
|
|
4376
|
-
}
|
|
4406
|
+
};
|
|
4377
4407
|
|
|
4378
4408
|
// src/middlewares/cache.ts
|
|
4379
4409
|
var cacheMiddleware = (options = {}) => {
|
|
4380
4410
|
const { ttl = 6e4 } = options;
|
|
4381
4411
|
const cache = /* @__PURE__ */ new Map();
|
|
4382
|
-
return (ctx, next) =>
|
|
4412
|
+
return async (ctx, next) => {
|
|
4383
4413
|
if (ctx.init.method === "GET") {
|
|
4384
|
-
const
|
|
4414
|
+
const key = `${ctx.init.method}:${ctx.url}`;
|
|
4415
|
+
const cached = cache.get(key);
|
|
4385
4416
|
const now = Date.now();
|
|
4386
|
-
if (cached && cached.expires > now)
|
|
4387
|
-
return new Response(JSON.stringify(cached.data)
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4417
|
+
if (cached && cached.expires > now) {
|
|
4418
|
+
return new Response(JSON.stringify(cached.data), {
|
|
4419
|
+
headers: { "Content-Type": "application/json" }
|
|
4420
|
+
});
|
|
4421
|
+
}
|
|
4422
|
+
const res = await next();
|
|
4423
|
+
const data = await res.clone().json().catch(() => null);
|
|
4424
|
+
if (data) {
|
|
4425
|
+
cache.set(key, { data, expires: now + ttl });
|
|
4426
|
+
}
|
|
4391
4427
|
return res;
|
|
4392
4428
|
}
|
|
4393
4429
|
return next();
|
|
4394
|
-
}
|
|
4430
|
+
};
|
|
4395
4431
|
};
|
|
4432
|
+
|
|
4433
|
+
// src/utils/make-request-schema.ts
|
|
4434
|
+
var makeRequestSchema = () => (defs) => external_exports.object({
|
|
4435
|
+
path: (defs.path ?? external_exports.object({}))?.optional(),
|
|
4436
|
+
query: (defs.query ?? external_exports.object({}))?.optional(),
|
|
4437
|
+
body: defs.body ?? external_exports.undefined(),
|
|
4438
|
+
headers: defs.headers ?? external_exports.record(external_exports.string()).optional()
|
|
4439
|
+
});
|
|
4396
4440
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4397
4441
|
0 && (module.exports = {
|
|
4398
4442
|
ApiClient,
|
|
@@ -4400,6 +4444,7 @@ var cacheMiddleware = (options = {}) => {
|
|
|
4400
4444
|
authMiddleware,
|
|
4401
4445
|
cacheMiddleware,
|
|
4402
4446
|
loggingMiddleware,
|
|
4447
|
+
makeRequestSchema,
|
|
4403
4448
|
retryMiddleware
|
|
4404
4449
|
});
|
|
4405
4450
|
//# sourceMappingURL=index.js.map
|