@orpc/zod 0.0.0-next.837ee14 → 0.0.0-next.854b646
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 +13 -9
- package/dist/src/coercer.d.ts +5 -4
- package/dist/src/schemas.d.ts +1 -1
- package/package.json +4 -2
package/dist/index.js
CHANGED
@@ -31,14 +31,17 @@ var guard = (func, shouldGuard) => {
|
|
31
31
|
import {
|
32
32
|
ZodFirstPartyTypeKind
|
33
33
|
} from "zod";
|
34
|
-
var
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
34
|
+
var ZodAutoCoercePlugin = class {
|
35
|
+
beforeCreateProcedureClient(clientOptions) {
|
36
|
+
clientOptions.interceptors ??= [];
|
37
|
+
clientOptions.interceptors.unshift((options) => {
|
38
|
+
const inputSchema = options.procedure["~orpc"].inputSchema;
|
39
|
+
if (!inputSchema || inputSchema["~standard"].vendor !== "zod") {
|
40
|
+
return options.next();
|
41
|
+
}
|
42
|
+
const coercedInput = zodCoerceInternal(inputSchema, options.input, { bracketNotation: true });
|
43
|
+
return options.next({ ...options, input: coercedInput });
|
44
|
+
});
|
42
45
|
}
|
43
46
|
};
|
44
47
|
function zodCoerceInternal(schema, value, options) {
|
@@ -724,6 +727,7 @@ function zodToJsonSchema(schema, options) {
|
|
724
727
|
const schema_ = schema__;
|
725
728
|
const def = schema_._def;
|
726
729
|
const json = { type: "array" };
|
730
|
+
json.items = zodToJsonSchema(def.type, childOptions);
|
727
731
|
if (def.exactLength) {
|
728
732
|
json.maxItems = def.exactLength.value;
|
729
733
|
json.minItems = def.exactLength.value;
|
@@ -956,7 +960,7 @@ export {
|
|
956
960
|
NON_LOGIC_KEYWORDS,
|
957
961
|
UNDEFINED_JSON_SCHEMA,
|
958
962
|
UNSUPPORTED_JSON_SCHEMA,
|
959
|
-
|
963
|
+
ZodAutoCoercePlugin,
|
960
964
|
ZodToJsonSchemaConverter,
|
961
965
|
blob,
|
962
966
|
file,
|
package/dist/src/coercer.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
3
|
-
|
4
|
-
|
1
|
+
import type { Context } from '@orpc/server';
|
2
|
+
import type { Plugin } from '@orpc/server/plugins';
|
3
|
+
import type { WellCreateProcedureClientOptions } from '@orpc/server/standard';
|
4
|
+
export declare class ZodAutoCoercePlugin<TContext extends Context> implements Plugin<TContext> {
|
5
|
+
beforeCreateProcedureClient(clientOptions: WellCreateProcedureClientOptions<TContext>): void;
|
5
6
|
}
|
6
7
|
//# sourceMappingURL=coercer.d.ts.map
|
package/dist/src/schemas.d.ts
CHANGED
@@ -10,7 +10,7 @@ export declare function getCustomJSONSchema(def: ZodTypeDef, options?: {
|
|
10
10
|
mode?: 'input' | 'output';
|
11
11
|
}): Exclude<JSONSchema, boolean> | undefined;
|
12
12
|
export declare function file(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<InstanceType<typeof File>, ZodTypeDef, InstanceType<typeof File>> & {
|
13
|
-
type
|
13
|
+
type(mimeType: string, params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodEffects<ZodType<InstanceType<typeof File>, ZodTypeDef, InstanceType<typeof File>>, InstanceType<typeof File>, InstanceType<typeof File>>;
|
14
14
|
};
|
15
15
|
export declare function blob(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<InstanceType<typeof Blob>, ZodTypeDef, InstanceType<typeof Blob>>;
|
16
16
|
export declare function invalidDate(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<Date, ZodTypeDef, Date>;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/zod",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next.
|
4
|
+
"version": "0.0.0-next.854b646",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -29,9 +29,11 @@
|
|
29
29
|
"dist"
|
30
30
|
],
|
31
31
|
"peerDependencies": {
|
32
|
-
"@orpc/openapi": "0.0.0-next.
|
32
|
+
"@orpc/openapi": "0.0.0-next.854b646",
|
33
|
+
"@orpc/server": "0.0.0-next.854b646"
|
33
34
|
},
|
34
35
|
"dependencies": {
|
36
|
+
"@standard-schema/spec": "^1.0.0",
|
35
37
|
"json-schema-typed": "^8.0.1",
|
36
38
|
"wildcard-match": "^5.1.3",
|
37
39
|
"zod": "^3.24.1"
|