@orpc/openapi 0.14.0 → 0.15.0
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/fetch.js +10 -8
- package/dist/index.js +181 -45
- package/package.json +7 -7
package/dist/fetch.js
CHANGED
|
@@ -45,7 +45,7 @@ function createOpenAPIHandler(createHonoRouter) {
|
|
|
45
45
|
procedure,
|
|
46
46
|
path
|
|
47
47
|
});
|
|
48
|
-
const output = await caller(mergedInput);
|
|
48
|
+
const output = await caller(mergedInput, { signal: options.signal });
|
|
49
49
|
const { body, headers } = serializer.serialize(output);
|
|
50
50
|
return new Response(body, {
|
|
51
51
|
status: 200,
|
|
@@ -58,7 +58,9 @@ function createOpenAPIHandler(createHonoRouter) {
|
|
|
58
58
|
hooks: options,
|
|
59
59
|
execute: handler,
|
|
60
60
|
input: options.request,
|
|
61
|
-
meta:
|
|
61
|
+
meta: {
|
|
62
|
+
signal: options.signal
|
|
63
|
+
}
|
|
62
64
|
});
|
|
63
65
|
} catch (e) {
|
|
64
66
|
const error = toORPCError(e);
|
|
@@ -185,13 +187,13 @@ function openAPIPathToRouterPath(path) {
|
|
|
185
187
|
return standardizeHTTPPath(path).replace(/\{([^}]+)\}/g, ":$1");
|
|
186
188
|
}
|
|
187
189
|
|
|
188
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
190
|
+
// ../../node_modules/.pnpm/hono@4.6.13/node_modules/hono/dist/router.js
|
|
189
191
|
var METHOD_NAME_ALL = "ALL";
|
|
190
192
|
var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
|
|
191
193
|
var UnsupportedPathError = class extends Error {
|
|
192
194
|
};
|
|
193
195
|
|
|
194
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
196
|
+
// ../../node_modules/.pnpm/hono@4.6.13/node_modules/hono/dist/utils/url.js
|
|
195
197
|
var checkOptionalParameter = (path) => {
|
|
196
198
|
if (!path.match(/\:.+\?$/)) {
|
|
197
199
|
return null;
|
|
@@ -220,7 +222,7 @@ var checkOptionalParameter = (path) => {
|
|
|
220
222
|
return results.filter((v, i, a) => a.indexOf(v) === i);
|
|
221
223
|
};
|
|
222
224
|
|
|
223
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
225
|
+
// ../../node_modules/.pnpm/hono@4.6.13/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
224
226
|
var LABEL_REG_EXP_STR = "[^/]+";
|
|
225
227
|
var ONLY_WILDCARD_REG_EXP_STR = ".*";
|
|
226
228
|
var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
|
|
@@ -325,7 +327,7 @@ var Node = class {
|
|
|
325
327
|
}
|
|
326
328
|
};
|
|
327
329
|
|
|
328
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
330
|
+
// ../../node_modules/.pnpm/hono@4.6.13/node_modules/hono/dist/router/reg-exp-router/trie.js
|
|
329
331
|
var Trie = class {
|
|
330
332
|
#context = { varIndex: 0 };
|
|
331
333
|
#root = new Node();
|
|
@@ -381,7 +383,7 @@ var Trie = class {
|
|
|
381
383
|
}
|
|
382
384
|
};
|
|
383
385
|
|
|
384
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
386
|
+
// ../../node_modules/.pnpm/hono@4.6.13/node_modules/hono/dist/router/reg-exp-router/router.js
|
|
385
387
|
var emptyParam = [];
|
|
386
388
|
var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
|
|
387
389
|
var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
@@ -582,7 +584,7 @@ function createOpenAPIServerHandler() {
|
|
|
582
584
|
return createOpenAPIHandler(() => new RegExpRouter());
|
|
583
585
|
}
|
|
584
586
|
|
|
585
|
-
// ../../node_modules/.pnpm/hono@4.6.
|
|
587
|
+
// ../../node_modules/.pnpm/hono@4.6.13/node_modules/hono/dist/router/linear-router/router.js
|
|
586
588
|
var emptyParams = /* @__PURE__ */ Object.create(null);
|
|
587
589
|
var splitPathRe = /\/(:\w+(?:{(?:(?:{[\d,]+})|[^}])+})?)|\/[^\/\?]+|(\?)/g;
|
|
588
590
|
var splitByStarRe = /\*/;
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
Format
|
|
23
23
|
} from "json-schema-typed/draft-2020-12";
|
|
24
24
|
|
|
25
|
-
// ../../node_modules/.pnpm/zod@3.
|
|
25
|
+
// ../../node_modules/.pnpm/zod@3.24.1/node_modules/zod/lib/index.mjs
|
|
26
26
|
var util;
|
|
27
27
|
(function(util2) {
|
|
28
28
|
util2.assertEqual = (val) => val;
|
|
@@ -173,6 +173,9 @@ var ZodIssueCode = util.arrayToEnum([
|
|
|
173
173
|
"not_finite"
|
|
174
174
|
]);
|
|
175
175
|
var ZodError = class _ZodError extends Error {
|
|
176
|
+
get errors() {
|
|
177
|
+
return this.issues;
|
|
178
|
+
}
|
|
176
179
|
constructor(issues) {
|
|
177
180
|
super();
|
|
178
181
|
this.issues = [];
|
|
@@ -191,9 +194,6 @@ var ZodError = class _ZodError extends Error {
|
|
|
191
194
|
this.name = "ZodError";
|
|
192
195
|
this.issues = issues;
|
|
193
196
|
}
|
|
194
|
-
get errors() {
|
|
195
|
-
return this.issues;
|
|
196
|
-
}
|
|
197
197
|
format(_mapper) {
|
|
198
198
|
const mapper = _mapper || function(issue) {
|
|
199
199
|
return issue.message;
|
|
@@ -400,8 +400,11 @@ function addIssueToContext(ctx, issueData) {
|
|
|
400
400
|
path: ctx.path,
|
|
401
401
|
errorMaps: [
|
|
402
402
|
ctx.common.contextualErrorMap,
|
|
403
|
+
// contextual error map is first priority
|
|
403
404
|
ctx.schemaErrorMap,
|
|
405
|
+
// then schema-bound map if available
|
|
404
406
|
overrideMap,
|
|
407
|
+
// then global override map
|
|
405
408
|
overrideMap === errorMap ? void 0 : errorMap
|
|
406
409
|
// then global default map
|
|
407
410
|
].filter((x) => !!x)
|
|
@@ -552,34 +555,6 @@ function processCreateParams(params) {
|
|
|
552
555
|
return { errorMap: customMap, description };
|
|
553
556
|
}
|
|
554
557
|
var ZodType = class {
|
|
555
|
-
constructor(def) {
|
|
556
|
-
this.spa = this.safeParseAsync;
|
|
557
|
-
this._def = def;
|
|
558
|
-
this.parse = this.parse.bind(this);
|
|
559
|
-
this.safeParse = this.safeParse.bind(this);
|
|
560
|
-
this.parseAsync = this.parseAsync.bind(this);
|
|
561
|
-
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
562
|
-
this.spa = this.spa.bind(this);
|
|
563
|
-
this.refine = this.refine.bind(this);
|
|
564
|
-
this.refinement = this.refinement.bind(this);
|
|
565
|
-
this.superRefine = this.superRefine.bind(this);
|
|
566
|
-
this.optional = this.optional.bind(this);
|
|
567
|
-
this.nullable = this.nullable.bind(this);
|
|
568
|
-
this.nullish = this.nullish.bind(this);
|
|
569
|
-
this.array = this.array.bind(this);
|
|
570
|
-
this.promise = this.promise.bind(this);
|
|
571
|
-
this.or = this.or.bind(this);
|
|
572
|
-
this.and = this.and.bind(this);
|
|
573
|
-
this.transform = this.transform.bind(this);
|
|
574
|
-
this.brand = this.brand.bind(this);
|
|
575
|
-
this.default = this.default.bind(this);
|
|
576
|
-
this.catch = this.catch.bind(this);
|
|
577
|
-
this.describe = this.describe.bind(this);
|
|
578
|
-
this.pipe = this.pipe.bind(this);
|
|
579
|
-
this.readonly = this.readonly.bind(this);
|
|
580
|
-
this.isNullable = this.isNullable.bind(this);
|
|
581
|
-
this.isOptional = this.isOptional.bind(this);
|
|
582
|
-
}
|
|
583
558
|
get description() {
|
|
584
559
|
return this._def.description;
|
|
585
560
|
}
|
|
@@ -643,6 +618,43 @@ var ZodType = class {
|
|
|
643
618
|
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
|
644
619
|
return handleResult(ctx, result);
|
|
645
620
|
}
|
|
621
|
+
"~validate"(data) {
|
|
622
|
+
var _a, _b;
|
|
623
|
+
const ctx = {
|
|
624
|
+
common: {
|
|
625
|
+
issues: [],
|
|
626
|
+
async: !!this["~standard"].async
|
|
627
|
+
},
|
|
628
|
+
path: [],
|
|
629
|
+
schemaErrorMap: this._def.errorMap,
|
|
630
|
+
parent: null,
|
|
631
|
+
data,
|
|
632
|
+
parsedType: getParsedType(data)
|
|
633
|
+
};
|
|
634
|
+
if (!this["~standard"].async) {
|
|
635
|
+
try {
|
|
636
|
+
const result = this._parseSync({ data, path: [], parent: ctx });
|
|
637
|
+
return isValid(result) ? {
|
|
638
|
+
value: result.value
|
|
639
|
+
} : {
|
|
640
|
+
issues: ctx.common.issues
|
|
641
|
+
};
|
|
642
|
+
} catch (err) {
|
|
643
|
+
if ((_b = (_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("encountered")) {
|
|
644
|
+
this["~standard"].async = true;
|
|
645
|
+
}
|
|
646
|
+
ctx.common = {
|
|
647
|
+
issues: [],
|
|
648
|
+
async: true
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
|
|
653
|
+
value: result.value
|
|
654
|
+
} : {
|
|
655
|
+
issues: ctx.common.issues
|
|
656
|
+
});
|
|
657
|
+
}
|
|
646
658
|
async parseAsync(data, params) {
|
|
647
659
|
const result = await this.safeParseAsync(data, params);
|
|
648
660
|
if (result.success)
|
|
@@ -720,6 +732,39 @@ var ZodType = class {
|
|
|
720
732
|
superRefine(refinement) {
|
|
721
733
|
return this._refinement(refinement);
|
|
722
734
|
}
|
|
735
|
+
constructor(def) {
|
|
736
|
+
this.spa = this.safeParseAsync;
|
|
737
|
+
this._def = def;
|
|
738
|
+
this.parse = this.parse.bind(this);
|
|
739
|
+
this.safeParse = this.safeParse.bind(this);
|
|
740
|
+
this.parseAsync = this.parseAsync.bind(this);
|
|
741
|
+
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
742
|
+
this.spa = this.spa.bind(this);
|
|
743
|
+
this.refine = this.refine.bind(this);
|
|
744
|
+
this.refinement = this.refinement.bind(this);
|
|
745
|
+
this.superRefine = this.superRefine.bind(this);
|
|
746
|
+
this.optional = this.optional.bind(this);
|
|
747
|
+
this.nullable = this.nullable.bind(this);
|
|
748
|
+
this.nullish = this.nullish.bind(this);
|
|
749
|
+
this.array = this.array.bind(this);
|
|
750
|
+
this.promise = this.promise.bind(this);
|
|
751
|
+
this.or = this.or.bind(this);
|
|
752
|
+
this.and = this.and.bind(this);
|
|
753
|
+
this.transform = this.transform.bind(this);
|
|
754
|
+
this.brand = this.brand.bind(this);
|
|
755
|
+
this.default = this.default.bind(this);
|
|
756
|
+
this.catch = this.catch.bind(this);
|
|
757
|
+
this.describe = this.describe.bind(this);
|
|
758
|
+
this.pipe = this.pipe.bind(this);
|
|
759
|
+
this.readonly = this.readonly.bind(this);
|
|
760
|
+
this.isNullable = this.isNullable.bind(this);
|
|
761
|
+
this.isOptional = this.isOptional.bind(this);
|
|
762
|
+
this["~standard"] = {
|
|
763
|
+
version: 1,
|
|
764
|
+
vendor: "zod",
|
|
765
|
+
validate: (data) => this["~validate"](data)
|
|
766
|
+
};
|
|
767
|
+
}
|
|
723
768
|
optional() {
|
|
724
769
|
return ZodOptional.create(this, this._def);
|
|
725
770
|
}
|
|
@@ -730,7 +775,7 @@ var ZodType = class {
|
|
|
730
775
|
return this.nullable().optional();
|
|
731
776
|
}
|
|
732
777
|
array() {
|
|
733
|
-
return ZodArray.create(this
|
|
778
|
+
return ZodArray.create(this);
|
|
734
779
|
}
|
|
735
780
|
promise() {
|
|
736
781
|
return ZodPromise.create(this, this._def);
|
|
@@ -796,16 +841,20 @@ var ZodType = class {
|
|
|
796
841
|
};
|
|
797
842
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
798
843
|
var cuid2Regex = /^[0-9a-z]+$/;
|
|
799
|
-
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}
|
|
844
|
+
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
|
|
800
845
|
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;
|
|
801
846
|
var nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
847
|
+
var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
|
|
802
848
|
var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
|
803
849
|
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
804
850
|
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
805
851
|
var emojiRegex;
|
|
806
852
|
var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
807
|
-
var
|
|
853
|
+
var ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
|
|
854
|
+
var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
|
|
855
|
+
var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
808
856
|
var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
857
|
+
var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
|
|
809
858
|
var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
|
810
859
|
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
811
860
|
function timeRegexSource(args) {
|
|
@@ -838,6 +887,33 @@ function isValidIP(ip, version) {
|
|
|
838
887
|
}
|
|
839
888
|
return false;
|
|
840
889
|
}
|
|
890
|
+
function isValidJWT(jwt, alg) {
|
|
891
|
+
if (!jwtRegex.test(jwt))
|
|
892
|
+
return false;
|
|
893
|
+
try {
|
|
894
|
+
const [header] = jwt.split(".");
|
|
895
|
+
const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
|
|
896
|
+
const decoded = JSON.parse(atob(base64));
|
|
897
|
+
if (typeof decoded !== "object" || decoded === null)
|
|
898
|
+
return false;
|
|
899
|
+
if (!decoded.typ || !decoded.alg)
|
|
900
|
+
return false;
|
|
901
|
+
if (alg && decoded.alg !== alg)
|
|
902
|
+
return false;
|
|
903
|
+
return true;
|
|
904
|
+
} catch (_a) {
|
|
905
|
+
return false;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
function isValidCidr(ip, version) {
|
|
909
|
+
if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
|
|
910
|
+
return true;
|
|
911
|
+
}
|
|
912
|
+
if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
|
|
913
|
+
return true;
|
|
914
|
+
}
|
|
915
|
+
return false;
|
|
916
|
+
}
|
|
841
917
|
var ZodString = class _ZodString extends ZodType {
|
|
842
918
|
_parse(input) {
|
|
843
919
|
if (this._def.coerce) {
|
|
@@ -1094,6 +1170,26 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1094
1170
|
});
|
|
1095
1171
|
status.dirty();
|
|
1096
1172
|
}
|
|
1173
|
+
} else if (check.kind === "jwt") {
|
|
1174
|
+
if (!isValidJWT(input.data, check.alg)) {
|
|
1175
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1176
|
+
addIssueToContext(ctx, {
|
|
1177
|
+
validation: "jwt",
|
|
1178
|
+
code: ZodIssueCode.invalid_string,
|
|
1179
|
+
message: check.message
|
|
1180
|
+
});
|
|
1181
|
+
status.dirty();
|
|
1182
|
+
}
|
|
1183
|
+
} else if (check.kind === "cidr") {
|
|
1184
|
+
if (!isValidCidr(input.data, check.version)) {
|
|
1185
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1186
|
+
addIssueToContext(ctx, {
|
|
1187
|
+
validation: "cidr",
|
|
1188
|
+
code: ZodIssueCode.invalid_string,
|
|
1189
|
+
message: check.message
|
|
1190
|
+
});
|
|
1191
|
+
status.dirty();
|
|
1192
|
+
}
|
|
1097
1193
|
} else if (check.kind === "base64") {
|
|
1098
1194
|
if (!base64Regex.test(input.data)) {
|
|
1099
1195
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -1104,6 +1200,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1104
1200
|
});
|
|
1105
1201
|
status.dirty();
|
|
1106
1202
|
}
|
|
1203
|
+
} else if (check.kind === "base64url") {
|
|
1204
|
+
if (!base64urlRegex.test(input.data)) {
|
|
1205
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1206
|
+
addIssueToContext(ctx, {
|
|
1207
|
+
validation: "base64url",
|
|
1208
|
+
code: ZodIssueCode.invalid_string,
|
|
1209
|
+
message: check.message
|
|
1210
|
+
});
|
|
1211
|
+
status.dirty();
|
|
1212
|
+
}
|
|
1107
1213
|
} else {
|
|
1108
1214
|
util.assertNever(check);
|
|
1109
1215
|
}
|
|
@@ -1150,9 +1256,21 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1150
1256
|
base64(message) {
|
|
1151
1257
|
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
1152
1258
|
}
|
|
1259
|
+
base64url(message) {
|
|
1260
|
+
return this._addCheck({
|
|
1261
|
+
kind: "base64url",
|
|
1262
|
+
...errorUtil.errToObj(message)
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
jwt(options) {
|
|
1266
|
+
return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
|
|
1267
|
+
}
|
|
1153
1268
|
ip(options) {
|
|
1154
1269
|
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
1155
1270
|
}
|
|
1271
|
+
cidr(options) {
|
|
1272
|
+
return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
|
|
1273
|
+
}
|
|
1156
1274
|
datetime(options) {
|
|
1157
1275
|
var _a, _b;
|
|
1158
1276
|
if (typeof options === "string") {
|
|
@@ -1243,8 +1361,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1243
1361
|
});
|
|
1244
1362
|
}
|
|
1245
1363
|
/**
|
|
1246
|
-
*
|
|
1247
|
-
* @see {@link ZodString.min}
|
|
1364
|
+
* Equivalent to `.min(1)`
|
|
1248
1365
|
*/
|
|
1249
1366
|
nonempty(message) {
|
|
1250
1367
|
return this.min(1, errorUtil.errToObj(message));
|
|
@@ -1306,9 +1423,15 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1306
1423
|
get isIP() {
|
|
1307
1424
|
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
1308
1425
|
}
|
|
1426
|
+
get isCIDR() {
|
|
1427
|
+
return !!this._def.checks.find((ch) => ch.kind === "cidr");
|
|
1428
|
+
}
|
|
1309
1429
|
get isBase64() {
|
|
1310
1430
|
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
1311
1431
|
}
|
|
1432
|
+
get isBase64url() {
|
|
1433
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64url");
|
|
1434
|
+
}
|
|
1312
1435
|
get minLength() {
|
|
1313
1436
|
let min = null;
|
|
1314
1437
|
for (const ch of this._def.checks) {
|
|
@@ -1586,17 +1709,15 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1586
1709
|
}
|
|
1587
1710
|
_parse(input) {
|
|
1588
1711
|
if (this._def.coerce) {
|
|
1589
|
-
|
|
1712
|
+
try {
|
|
1713
|
+
input.data = BigInt(input.data);
|
|
1714
|
+
} catch (_a) {
|
|
1715
|
+
return this._getInvalidInput(input);
|
|
1716
|
+
}
|
|
1590
1717
|
}
|
|
1591
1718
|
const parsedType = this._getType(input);
|
|
1592
1719
|
if (parsedType !== ZodParsedType.bigint) {
|
|
1593
|
-
|
|
1594
|
-
addIssueToContext(ctx2, {
|
|
1595
|
-
code: ZodIssueCode.invalid_type,
|
|
1596
|
-
expected: ZodParsedType.bigint,
|
|
1597
|
-
received: ctx2.parsedType
|
|
1598
|
-
});
|
|
1599
|
-
return INVALID;
|
|
1720
|
+
return this._getInvalidInput(input);
|
|
1600
1721
|
}
|
|
1601
1722
|
let ctx = void 0;
|
|
1602
1723
|
const status = new ParseStatus();
|
|
@@ -1643,6 +1764,15 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1643
1764
|
}
|
|
1644
1765
|
return { status: status.value, value: input.data };
|
|
1645
1766
|
}
|
|
1767
|
+
_getInvalidInput(input) {
|
|
1768
|
+
const ctx = this._getOrReturnCtx(input);
|
|
1769
|
+
addIssueToContext(ctx, {
|
|
1770
|
+
code: ZodIssueCode.invalid_type,
|
|
1771
|
+
expected: ZodParsedType.bigint,
|
|
1772
|
+
received: ctx.parsedType
|
|
1773
|
+
});
|
|
1774
|
+
return INVALID;
|
|
1775
|
+
}
|
|
1646
1776
|
gte(value, message) {
|
|
1647
1777
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
1648
1778
|
}
|
|
@@ -3921,6 +4051,12 @@ function zodToJsonSchema(schema, options) {
|
|
|
3921
4051
|
case "ip":
|
|
3922
4052
|
json.format = Format.IPv4;
|
|
3923
4053
|
break;
|
|
4054
|
+
case "jwt":
|
|
4055
|
+
json.pattern = "^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]*$";
|
|
4056
|
+
break;
|
|
4057
|
+
case "base64url":
|
|
4058
|
+
json.pattern = "^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$";
|
|
4059
|
+
break;
|
|
3924
4060
|
default: {
|
|
3925
4061
|
const _expect = check.kind;
|
|
3926
4062
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/openapi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.15.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
"escape-string-regexp": "^5.0.0",
|
|
38
38
|
"json-schema-typed": "^8.0.1",
|
|
39
39
|
"openapi3-ts": "^4.4.0",
|
|
40
|
-
"@orpc/
|
|
41
|
-
"@orpc/
|
|
42
|
-
"@orpc/shared": "0.
|
|
43
|
-
"@orpc/transformer": "0.
|
|
44
|
-
"@orpc/zod": "0.
|
|
40
|
+
"@orpc/server": "0.15.0",
|
|
41
|
+
"@orpc/contract": "0.15.0",
|
|
42
|
+
"@orpc/shared": "0.15.0",
|
|
43
|
+
"@orpc/transformer": "0.15.0",
|
|
44
|
+
"@orpc/zod": "0.15.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@readme/openapi-parser": "^2.6.0",
|
|
48
48
|
"hono": "^4.6.12",
|
|
49
|
-
"zod": "^3.
|
|
49
|
+
"zod": "^3.24.1"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsup --clean --sourcemap --entry.index=src/index.ts --entry.fetch=src/fetch/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
|