@oumla/sdk 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +106 -54
- package/dist/index.mjs +106 -54
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -131,7 +131,7 @@ var Base = class {
|
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
-
// node_modules/.pnpm/zod@3.
|
|
134
|
+
// node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
|
|
135
135
|
var util;
|
|
136
136
|
(function(util2) {
|
|
137
137
|
util2.assertEqual = (val) => val;
|
|
@@ -553,7 +553,7 @@ var ParseStatus = class {
|
|
|
553
553
|
status.dirty();
|
|
554
554
|
if (value.status === "dirty")
|
|
555
555
|
status.dirty();
|
|
556
|
-
if (typeof value.value !== "undefined" || pair.alwaysSet) {
|
|
556
|
+
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
557
557
|
finalObject[key.value] = value.value;
|
|
558
558
|
}
|
|
559
559
|
}
|
|
@@ -656,6 +656,7 @@ var ZodType = class {
|
|
|
656
656
|
this.catch = this.catch.bind(this);
|
|
657
657
|
this.describe = this.describe.bind(this);
|
|
658
658
|
this.pipe = this.pipe.bind(this);
|
|
659
|
+
this.readonly = this.readonly.bind(this);
|
|
659
660
|
this.isNullable = this.isNullable.bind(this);
|
|
660
661
|
this.isOptional = this.isOptional.bind(this);
|
|
661
662
|
}
|
|
@@ -861,6 +862,9 @@ var ZodType = class {
|
|
|
861
862
|
pipe(target) {
|
|
862
863
|
return ZodPipeline.create(this, target);
|
|
863
864
|
}
|
|
865
|
+
readonly() {
|
|
866
|
+
return ZodReadonly.create(this);
|
|
867
|
+
}
|
|
864
868
|
isOptional() {
|
|
865
869
|
return this.safeParse(void 0).success;
|
|
866
870
|
}
|
|
@@ -870,10 +874,11 @@ var ZodType = class {
|
|
|
870
874
|
};
|
|
871
875
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
872
876
|
var cuid2Regex = /^[a-z][a-z0-9]*$/;
|
|
873
|
-
var ulidRegex =
|
|
874
|
-
var uuidRegex = /^
|
|
875
|
-
var emailRegex = /^(
|
|
876
|
-
var
|
|
877
|
+
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
878
|
+
var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
|
|
879
|
+
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
880
|
+
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
881
|
+
var emojiRegex;
|
|
877
882
|
var ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;
|
|
878
883
|
var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
|
|
879
884
|
var datetimeRegex = (args) => {
|
|
@@ -907,23 +912,6 @@ function isValidIP(ip, version) {
|
|
|
907
912
|
return false;
|
|
908
913
|
}
|
|
909
914
|
var ZodString = class extends ZodType {
|
|
910
|
-
constructor() {
|
|
911
|
-
super(...arguments);
|
|
912
|
-
this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), __spreadValues({
|
|
913
|
-
validation,
|
|
914
|
-
code: ZodIssueCode.invalid_string
|
|
915
|
-
}, errorUtil.errToObj(message)));
|
|
916
|
-
this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
|
|
917
|
-
this.trim = () => new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
918
|
-
checks: [...this._def.checks, { kind: "trim" }]
|
|
919
|
-
}));
|
|
920
|
-
this.toLowerCase = () => new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
921
|
-
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
922
|
-
}));
|
|
923
|
-
this.toUpperCase = () => new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
924
|
-
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
925
|
-
}));
|
|
926
|
-
}
|
|
927
915
|
_parse(input) {
|
|
928
916
|
if (this._def.coerce) {
|
|
929
917
|
input.data = String(input.data);
|
|
@@ -1008,6 +996,9 @@ var ZodString = class extends ZodType {
|
|
|
1008
996
|
status.dirty();
|
|
1009
997
|
}
|
|
1010
998
|
} else if (check.kind === "emoji") {
|
|
999
|
+
if (!emojiRegex) {
|
|
1000
|
+
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
1001
|
+
}
|
|
1011
1002
|
if (!emojiRegex.test(input.data)) {
|
|
1012
1003
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
1013
1004
|
addIssueToContext(ctx, {
|
|
@@ -1144,6 +1135,12 @@ var ZodString = class extends ZodType {
|
|
|
1144
1135
|
}
|
|
1145
1136
|
return { status: status.value, value: input.data };
|
|
1146
1137
|
}
|
|
1138
|
+
_regex(regex, validation, message) {
|
|
1139
|
+
return this.refinement((data) => regex.test(data), __spreadValues({
|
|
1140
|
+
validation,
|
|
1141
|
+
code: ZodIssueCode.invalid_string
|
|
1142
|
+
}, errorUtil.errToObj(message)));
|
|
1143
|
+
}
|
|
1147
1144
|
_addCheck(check) {
|
|
1148
1145
|
return new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
1149
1146
|
checks: [...this._def.checks, check]
|
|
@@ -1232,6 +1229,28 @@ var ZodString = class extends ZodType {
|
|
|
1232
1229
|
value: len
|
|
1233
1230
|
}, errorUtil.errToObj(message)));
|
|
1234
1231
|
}
|
|
1232
|
+
/**
|
|
1233
|
+
* @deprecated Use z.string().min(1) instead.
|
|
1234
|
+
* @see {@link ZodString.min}
|
|
1235
|
+
*/
|
|
1236
|
+
nonempty(message) {
|
|
1237
|
+
return this.min(1, errorUtil.errToObj(message));
|
|
1238
|
+
}
|
|
1239
|
+
trim() {
|
|
1240
|
+
return new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
1241
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
1242
|
+
}));
|
|
1243
|
+
}
|
|
1244
|
+
toLowerCase() {
|
|
1245
|
+
return new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
1246
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1247
|
+
}));
|
|
1248
|
+
}
|
|
1249
|
+
toUpperCase() {
|
|
1250
|
+
return new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
1251
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1252
|
+
}));
|
|
1253
|
+
}
|
|
1235
1254
|
get isDatetime() {
|
|
1236
1255
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
1237
1256
|
}
|
|
@@ -2770,6 +2789,12 @@ var ZodRecord = class extends ZodType {
|
|
|
2770
2789
|
}
|
|
2771
2790
|
};
|
|
2772
2791
|
var ZodMap = class extends ZodType {
|
|
2792
|
+
get keySchema() {
|
|
2793
|
+
return this._def.keyType;
|
|
2794
|
+
}
|
|
2795
|
+
get valueSchema() {
|
|
2796
|
+
return this._def.valueType;
|
|
2797
|
+
}
|
|
2773
2798
|
_parse(input) {
|
|
2774
2799
|
const { status, ctx } = this._processInputParams(input);
|
|
2775
2800
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
@@ -2960,27 +2985,31 @@ var ZodFunction = class extends ZodType {
|
|
|
2960
2985
|
const params = { errorMap: ctx.common.contextualErrorMap };
|
|
2961
2986
|
const fn = ctx.data;
|
|
2962
2987
|
if (this._def.returns instanceof ZodPromise) {
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
error
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2988
|
+
const me = this;
|
|
2989
|
+
return OK(function(...args) {
|
|
2990
|
+
return __async(this, null, function* () {
|
|
2991
|
+
const error = new ZodError([]);
|
|
2992
|
+
const parsedArgs = yield me._def.args.parseAsync(args, params).catch((e) => {
|
|
2993
|
+
error.addIssue(makeArgsIssue(args, e));
|
|
2994
|
+
throw error;
|
|
2995
|
+
});
|
|
2996
|
+
const result = yield Reflect.apply(fn, this, parsedArgs);
|
|
2997
|
+
const parsedReturns = yield me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
2998
|
+
error.addIssue(makeReturnsIssue(result, e));
|
|
2999
|
+
throw error;
|
|
3000
|
+
});
|
|
3001
|
+
return parsedReturns;
|
|
2973
3002
|
});
|
|
2974
|
-
|
|
2975
|
-
}));
|
|
3003
|
+
});
|
|
2976
3004
|
} else {
|
|
2977
|
-
|
|
2978
|
-
|
|
3005
|
+
const me = this;
|
|
3006
|
+
return OK(function(...args) {
|
|
3007
|
+
const parsedArgs = me._def.args.safeParse(args, params);
|
|
2979
3008
|
if (!parsedArgs.success) {
|
|
2980
3009
|
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
2981
3010
|
}
|
|
2982
|
-
const result = fn
|
|
2983
|
-
const parsedReturns =
|
|
3011
|
+
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
3012
|
+
const parsedReturns = me._def.returns.safeParse(result, params);
|
|
2984
3013
|
if (!parsedReturns.success) {
|
|
2985
3014
|
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
|
2986
3015
|
}
|
|
@@ -3194,8 +3223,28 @@ var ZodEffects = class extends ZodType {
|
|
|
3194
3223
|
_parse(input) {
|
|
3195
3224
|
const { status, ctx } = this._processInputParams(input);
|
|
3196
3225
|
const effect = this._def.effect || null;
|
|
3226
|
+
const checkCtx = {
|
|
3227
|
+
addIssue: (arg) => {
|
|
3228
|
+
addIssueToContext(ctx, arg);
|
|
3229
|
+
if (arg.fatal) {
|
|
3230
|
+
status.abort();
|
|
3231
|
+
} else {
|
|
3232
|
+
status.dirty();
|
|
3233
|
+
}
|
|
3234
|
+
},
|
|
3235
|
+
get path() {
|
|
3236
|
+
return ctx.path;
|
|
3237
|
+
}
|
|
3238
|
+
};
|
|
3239
|
+
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3197
3240
|
if (effect.type === "preprocess") {
|
|
3198
|
-
const processed = effect.transform(ctx.data);
|
|
3241
|
+
const processed = effect.transform(ctx.data, checkCtx);
|
|
3242
|
+
if (ctx.common.issues.length) {
|
|
3243
|
+
return {
|
|
3244
|
+
status: "dirty",
|
|
3245
|
+
value: ctx.data
|
|
3246
|
+
};
|
|
3247
|
+
}
|
|
3199
3248
|
if (ctx.common.async) {
|
|
3200
3249
|
return Promise.resolve(processed).then((processed2) => {
|
|
3201
3250
|
return this._def.schema._parseAsync({
|
|
@@ -3212,20 +3261,6 @@ var ZodEffects = class extends ZodType {
|
|
|
3212
3261
|
});
|
|
3213
3262
|
}
|
|
3214
3263
|
}
|
|
3215
|
-
const checkCtx = {
|
|
3216
|
-
addIssue: (arg) => {
|
|
3217
|
-
addIssueToContext(ctx, arg);
|
|
3218
|
-
if (arg.fatal) {
|
|
3219
|
-
status.abort();
|
|
3220
|
-
} else {
|
|
3221
|
-
status.dirty();
|
|
3222
|
-
}
|
|
3223
|
-
},
|
|
3224
|
-
get path() {
|
|
3225
|
-
return ctx.path;
|
|
3226
|
-
}
|
|
3227
|
-
};
|
|
3228
|
-
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3229
3264
|
if (effect.type === "refinement") {
|
|
3230
3265
|
const executeRefinement = (acc) => {
|
|
3231
3266
|
const result = effect.refinement(acc, checkCtx);
|
|
@@ -3498,6 +3533,21 @@ var ZodPipeline = class extends ZodType {
|
|
|
3498
3533
|
});
|
|
3499
3534
|
}
|
|
3500
3535
|
};
|
|
3536
|
+
var ZodReadonly = class extends ZodType {
|
|
3537
|
+
_parse(input) {
|
|
3538
|
+
const result = this._def.innerType._parse(input);
|
|
3539
|
+
if (isValid(result)) {
|
|
3540
|
+
result.value = Object.freeze(result.value);
|
|
3541
|
+
}
|
|
3542
|
+
return result;
|
|
3543
|
+
}
|
|
3544
|
+
};
|
|
3545
|
+
ZodReadonly.create = (type, params) => {
|
|
3546
|
+
return new ZodReadonly(__spreadValues({
|
|
3547
|
+
innerType: type,
|
|
3548
|
+
typeName: ZodFirstPartyTypeKind.ZodReadonly
|
|
3549
|
+
}, processCreateParams(params)));
|
|
3550
|
+
};
|
|
3501
3551
|
var custom = (check, params = {}, fatal) => {
|
|
3502
3552
|
if (check)
|
|
3503
3553
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
@@ -3551,6 +3601,7 @@ var ZodFirstPartyTypeKind;
|
|
|
3551
3601
|
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
|
3552
3602
|
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
|
3553
3603
|
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
|
3604
|
+
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
|
3554
3605
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
3555
3606
|
var instanceOfType = (cls, params = {
|
|
3556
3607
|
message: `Input not instance of ${cls.name}`
|
|
@@ -3664,6 +3715,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
3664
3715
|
BRAND,
|
|
3665
3716
|
ZodBranded,
|
|
3666
3717
|
ZodPipeline,
|
|
3718
|
+
ZodReadonly,
|
|
3667
3719
|
custom,
|
|
3668
3720
|
Schema: ZodType,
|
|
3669
3721
|
ZodSchema: ZodType,
|
package/dist/index.mjs
CHANGED
|
@@ -106,7 +106,7 @@ var Base = class {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
// node_modules/.pnpm/zod@3.
|
|
109
|
+
// node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
|
|
110
110
|
var util;
|
|
111
111
|
(function(util2) {
|
|
112
112
|
util2.assertEqual = (val) => val;
|
|
@@ -528,7 +528,7 @@ var ParseStatus = class {
|
|
|
528
528
|
status.dirty();
|
|
529
529
|
if (value.status === "dirty")
|
|
530
530
|
status.dirty();
|
|
531
|
-
if (typeof value.value !== "undefined" || pair.alwaysSet) {
|
|
531
|
+
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
532
532
|
finalObject[key.value] = value.value;
|
|
533
533
|
}
|
|
534
534
|
}
|
|
@@ -631,6 +631,7 @@ var ZodType = class {
|
|
|
631
631
|
this.catch = this.catch.bind(this);
|
|
632
632
|
this.describe = this.describe.bind(this);
|
|
633
633
|
this.pipe = this.pipe.bind(this);
|
|
634
|
+
this.readonly = this.readonly.bind(this);
|
|
634
635
|
this.isNullable = this.isNullable.bind(this);
|
|
635
636
|
this.isOptional = this.isOptional.bind(this);
|
|
636
637
|
}
|
|
@@ -836,6 +837,9 @@ var ZodType = class {
|
|
|
836
837
|
pipe(target) {
|
|
837
838
|
return ZodPipeline.create(this, target);
|
|
838
839
|
}
|
|
840
|
+
readonly() {
|
|
841
|
+
return ZodReadonly.create(this);
|
|
842
|
+
}
|
|
839
843
|
isOptional() {
|
|
840
844
|
return this.safeParse(void 0).success;
|
|
841
845
|
}
|
|
@@ -845,10 +849,11 @@ var ZodType = class {
|
|
|
845
849
|
};
|
|
846
850
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
847
851
|
var cuid2Regex = /^[a-z][a-z0-9]*$/;
|
|
848
|
-
var ulidRegex =
|
|
849
|
-
var uuidRegex = /^
|
|
850
|
-
var emailRegex = /^(
|
|
851
|
-
var
|
|
852
|
+
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
853
|
+
var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
|
|
854
|
+
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
855
|
+
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
856
|
+
var emojiRegex;
|
|
852
857
|
var ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;
|
|
853
858
|
var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
|
|
854
859
|
var datetimeRegex = (args) => {
|
|
@@ -882,23 +887,6 @@ function isValidIP(ip, version) {
|
|
|
882
887
|
return false;
|
|
883
888
|
}
|
|
884
889
|
var ZodString = class extends ZodType {
|
|
885
|
-
constructor() {
|
|
886
|
-
super(...arguments);
|
|
887
|
-
this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), __spreadValues({
|
|
888
|
-
validation,
|
|
889
|
-
code: ZodIssueCode.invalid_string
|
|
890
|
-
}, errorUtil.errToObj(message)));
|
|
891
|
-
this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
|
|
892
|
-
this.trim = () => new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
893
|
-
checks: [...this._def.checks, { kind: "trim" }]
|
|
894
|
-
}));
|
|
895
|
-
this.toLowerCase = () => new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
896
|
-
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
897
|
-
}));
|
|
898
|
-
this.toUpperCase = () => new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
899
|
-
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
900
|
-
}));
|
|
901
|
-
}
|
|
902
890
|
_parse(input) {
|
|
903
891
|
if (this._def.coerce) {
|
|
904
892
|
input.data = String(input.data);
|
|
@@ -983,6 +971,9 @@ var ZodString = class extends ZodType {
|
|
|
983
971
|
status.dirty();
|
|
984
972
|
}
|
|
985
973
|
} else if (check.kind === "emoji") {
|
|
974
|
+
if (!emojiRegex) {
|
|
975
|
+
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
976
|
+
}
|
|
986
977
|
if (!emojiRegex.test(input.data)) {
|
|
987
978
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
988
979
|
addIssueToContext(ctx, {
|
|
@@ -1119,6 +1110,12 @@ var ZodString = class extends ZodType {
|
|
|
1119
1110
|
}
|
|
1120
1111
|
return { status: status.value, value: input.data };
|
|
1121
1112
|
}
|
|
1113
|
+
_regex(regex, validation, message) {
|
|
1114
|
+
return this.refinement((data) => regex.test(data), __spreadValues({
|
|
1115
|
+
validation,
|
|
1116
|
+
code: ZodIssueCode.invalid_string
|
|
1117
|
+
}, errorUtil.errToObj(message)));
|
|
1118
|
+
}
|
|
1122
1119
|
_addCheck(check) {
|
|
1123
1120
|
return new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
1124
1121
|
checks: [...this._def.checks, check]
|
|
@@ -1207,6 +1204,28 @@ var ZodString = class extends ZodType {
|
|
|
1207
1204
|
value: len
|
|
1208
1205
|
}, errorUtil.errToObj(message)));
|
|
1209
1206
|
}
|
|
1207
|
+
/**
|
|
1208
|
+
* @deprecated Use z.string().min(1) instead.
|
|
1209
|
+
* @see {@link ZodString.min}
|
|
1210
|
+
*/
|
|
1211
|
+
nonempty(message) {
|
|
1212
|
+
return this.min(1, errorUtil.errToObj(message));
|
|
1213
|
+
}
|
|
1214
|
+
trim() {
|
|
1215
|
+
return new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
1216
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
1217
|
+
}));
|
|
1218
|
+
}
|
|
1219
|
+
toLowerCase() {
|
|
1220
|
+
return new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
1221
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1222
|
+
}));
|
|
1223
|
+
}
|
|
1224
|
+
toUpperCase() {
|
|
1225
|
+
return new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
1226
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1227
|
+
}));
|
|
1228
|
+
}
|
|
1210
1229
|
get isDatetime() {
|
|
1211
1230
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
1212
1231
|
}
|
|
@@ -2745,6 +2764,12 @@ var ZodRecord = class extends ZodType {
|
|
|
2745
2764
|
}
|
|
2746
2765
|
};
|
|
2747
2766
|
var ZodMap = class extends ZodType {
|
|
2767
|
+
get keySchema() {
|
|
2768
|
+
return this._def.keyType;
|
|
2769
|
+
}
|
|
2770
|
+
get valueSchema() {
|
|
2771
|
+
return this._def.valueType;
|
|
2772
|
+
}
|
|
2748
2773
|
_parse(input) {
|
|
2749
2774
|
const { status, ctx } = this._processInputParams(input);
|
|
2750
2775
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
@@ -2935,27 +2960,31 @@ var ZodFunction = class extends ZodType {
|
|
|
2935
2960
|
const params = { errorMap: ctx.common.contextualErrorMap };
|
|
2936
2961
|
const fn = ctx.data;
|
|
2937
2962
|
if (this._def.returns instanceof ZodPromise) {
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
error
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2963
|
+
const me = this;
|
|
2964
|
+
return OK(function(...args) {
|
|
2965
|
+
return __async(this, null, function* () {
|
|
2966
|
+
const error = new ZodError([]);
|
|
2967
|
+
const parsedArgs = yield me._def.args.parseAsync(args, params).catch((e) => {
|
|
2968
|
+
error.addIssue(makeArgsIssue(args, e));
|
|
2969
|
+
throw error;
|
|
2970
|
+
});
|
|
2971
|
+
const result = yield Reflect.apply(fn, this, parsedArgs);
|
|
2972
|
+
const parsedReturns = yield me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
2973
|
+
error.addIssue(makeReturnsIssue(result, e));
|
|
2974
|
+
throw error;
|
|
2975
|
+
});
|
|
2976
|
+
return parsedReturns;
|
|
2948
2977
|
});
|
|
2949
|
-
|
|
2950
|
-
}));
|
|
2978
|
+
});
|
|
2951
2979
|
} else {
|
|
2952
|
-
|
|
2953
|
-
|
|
2980
|
+
const me = this;
|
|
2981
|
+
return OK(function(...args) {
|
|
2982
|
+
const parsedArgs = me._def.args.safeParse(args, params);
|
|
2954
2983
|
if (!parsedArgs.success) {
|
|
2955
2984
|
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
2956
2985
|
}
|
|
2957
|
-
const result = fn
|
|
2958
|
-
const parsedReturns =
|
|
2986
|
+
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
2987
|
+
const parsedReturns = me._def.returns.safeParse(result, params);
|
|
2959
2988
|
if (!parsedReturns.success) {
|
|
2960
2989
|
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
|
2961
2990
|
}
|
|
@@ -3169,8 +3198,28 @@ var ZodEffects = class extends ZodType {
|
|
|
3169
3198
|
_parse(input) {
|
|
3170
3199
|
const { status, ctx } = this._processInputParams(input);
|
|
3171
3200
|
const effect = this._def.effect || null;
|
|
3201
|
+
const checkCtx = {
|
|
3202
|
+
addIssue: (arg) => {
|
|
3203
|
+
addIssueToContext(ctx, arg);
|
|
3204
|
+
if (arg.fatal) {
|
|
3205
|
+
status.abort();
|
|
3206
|
+
} else {
|
|
3207
|
+
status.dirty();
|
|
3208
|
+
}
|
|
3209
|
+
},
|
|
3210
|
+
get path() {
|
|
3211
|
+
return ctx.path;
|
|
3212
|
+
}
|
|
3213
|
+
};
|
|
3214
|
+
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3172
3215
|
if (effect.type === "preprocess") {
|
|
3173
|
-
const processed = effect.transform(ctx.data);
|
|
3216
|
+
const processed = effect.transform(ctx.data, checkCtx);
|
|
3217
|
+
if (ctx.common.issues.length) {
|
|
3218
|
+
return {
|
|
3219
|
+
status: "dirty",
|
|
3220
|
+
value: ctx.data
|
|
3221
|
+
};
|
|
3222
|
+
}
|
|
3174
3223
|
if (ctx.common.async) {
|
|
3175
3224
|
return Promise.resolve(processed).then((processed2) => {
|
|
3176
3225
|
return this._def.schema._parseAsync({
|
|
@@ -3187,20 +3236,6 @@ var ZodEffects = class extends ZodType {
|
|
|
3187
3236
|
});
|
|
3188
3237
|
}
|
|
3189
3238
|
}
|
|
3190
|
-
const checkCtx = {
|
|
3191
|
-
addIssue: (arg) => {
|
|
3192
|
-
addIssueToContext(ctx, arg);
|
|
3193
|
-
if (arg.fatal) {
|
|
3194
|
-
status.abort();
|
|
3195
|
-
} else {
|
|
3196
|
-
status.dirty();
|
|
3197
|
-
}
|
|
3198
|
-
},
|
|
3199
|
-
get path() {
|
|
3200
|
-
return ctx.path;
|
|
3201
|
-
}
|
|
3202
|
-
};
|
|
3203
|
-
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3204
3239
|
if (effect.type === "refinement") {
|
|
3205
3240
|
const executeRefinement = (acc) => {
|
|
3206
3241
|
const result = effect.refinement(acc, checkCtx);
|
|
@@ -3473,6 +3508,21 @@ var ZodPipeline = class extends ZodType {
|
|
|
3473
3508
|
});
|
|
3474
3509
|
}
|
|
3475
3510
|
};
|
|
3511
|
+
var ZodReadonly = class extends ZodType {
|
|
3512
|
+
_parse(input) {
|
|
3513
|
+
const result = this._def.innerType._parse(input);
|
|
3514
|
+
if (isValid(result)) {
|
|
3515
|
+
result.value = Object.freeze(result.value);
|
|
3516
|
+
}
|
|
3517
|
+
return result;
|
|
3518
|
+
}
|
|
3519
|
+
};
|
|
3520
|
+
ZodReadonly.create = (type, params) => {
|
|
3521
|
+
return new ZodReadonly(__spreadValues({
|
|
3522
|
+
innerType: type,
|
|
3523
|
+
typeName: ZodFirstPartyTypeKind.ZodReadonly
|
|
3524
|
+
}, processCreateParams(params)));
|
|
3525
|
+
};
|
|
3476
3526
|
var custom = (check, params = {}, fatal) => {
|
|
3477
3527
|
if (check)
|
|
3478
3528
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
@@ -3526,6 +3576,7 @@ var ZodFirstPartyTypeKind;
|
|
|
3526
3576
|
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
|
3527
3577
|
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
|
3528
3578
|
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
|
3579
|
+
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
|
3529
3580
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
3530
3581
|
var instanceOfType = (cls, params = {
|
|
3531
3582
|
message: `Input not instance of ${cls.name}`
|
|
@@ -3639,6 +3690,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
3639
3690
|
BRAND,
|
|
3640
3691
|
ZodBranded,
|
|
3641
3692
|
ZodPipeline,
|
|
3693
|
+
ZodReadonly,
|
|
3642
3694
|
custom,
|
|
3643
3695
|
Schema: ZodType,
|
|
3644
3696
|
ZodSchema: ZodType,
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oumla/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Oumla SDK is the fastest way to integrate with blockchain networks",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@changesets/cli": "^2.
|
|
10
|
+
"@changesets/cli": "^2.27.1",
|
|
11
11
|
"@types/node": "^18.14.0",
|
|
12
12
|
"@types/superagent": "^4.1.18",
|
|
13
|
-
"superagent": "^8.
|
|
13
|
+
"superagent": "^8.1.2",
|
|
14
14
|
"tsup": "^6.7.0",
|
|
15
15
|
"typescript": "5.0.4",
|
|
16
|
-
"vitest": "^
|
|
17
|
-
"zod": "^3.
|
|
16
|
+
"vitest": "^1.1.3",
|
|
17
|
+
"zod": "^3.22.4"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [],
|
|
20
20
|
"author": "Mohammed aljasser",
|