@orpc/server 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -114,20 +114,20 @@ function createProcedureCaller(options) {
114
114
  const procedure = await loadProcedure(options.procedure);
115
115
  const context = await value(options.context);
116
116
  const execute = async () => {
117
- const validInput = (() => {
117
+ const validInput = await (async () => {
118
118
  const schema = procedure.zz$p.contract.zz$cp.InputSchema;
119
119
  if (!schema) {
120
120
  return input;
121
121
  }
122
- try {
123
- return schema.parse(input);
124
- } catch (e) {
122
+ const result = await schema["~standard"].validate(input);
123
+ if (result.issues) {
125
124
  throw new ORPCError({
126
125
  message: "Validation input failed",
127
126
  code: "BAD_REQUEST",
128
- cause: e
127
+ issues: result.issues
129
128
  });
130
129
  }
130
+ return result.value;
131
131
  })();
132
132
  const meta = {
133
133
  path,
@@ -160,15 +160,14 @@ function createProcedureCaller(options) {
160
160
  if (!schema) {
161
161
  return output2;
162
162
  }
163
- const result = await schema.safeParseAsync(output2);
164
- if (result.error) {
163
+ const result = await schema["~standard"].validate(output2);
164
+ if (result.issues) {
165
165
  throw new ORPCError({
166
166
  message: "Validation output failed",
167
- code: "INTERNAL_SERVER_ERROR",
168
- cause: result.error
167
+ code: "INTERNAL_SERVER_ERROR"
169
168
  });
170
169
  }
171
- return result.data;
170
+ return result.value;
172
171
  })();
173
172
  return validOutput;
174
173
  };
@@ -271,4 +270,4 @@ export {
271
270
  decorateProcedure,
272
271
  isProcedure
273
272
  };
274
- //# sourceMappingURL=chunk-3JMSDC5L.js.map
273
+ //# sourceMappingURL=chunk-Z2PQ6UAM.js.map
package/dist/fetch.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  createProcedureCaller,
3
3
  isLazy,
4
4
  isProcedure
5
- } from "./chunk-3JMSDC5L.js";
5
+ } from "./chunk-Z2PQ6UAM.js";
6
6
 
7
7
  // src/fetch/handle.ts
8
8
  import { ORPCError } from "@orpc/shared/error";
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  loadLazy,
13
13
  loadProcedure,
14
14
  mergeContext
15
- } from "./chunk-3JMSDC5L.js";
15
+ } from "./chunk-Z2PQ6UAM.js";
16
16
 
17
17
  // src/builder.ts
18
18
  import {
@@ -12,10 +12,10 @@ export declare class RouterImplementer<TContext extends Context, TContract exten
12
12
  constructor(zz$ri: {
13
13
  contract: TContract;
14
14
  });
15
- router(router: RouterWithContract<TContext, TContract>): HandledRouter<RouterWithContract<TContext, TContract>>;
16
- lazy(loader: () => Promise<{
17
- default: RouterWithContract<TContext, TContract>;
18
- }>): DecoratedLazy<RouterWithContract<TContext, TContract>>;
15
+ router<U extends RouterWithContract<TContext, TContract>>(router: U): HandledRouter<U>;
16
+ lazy<U extends RouterWithContract<TContext, TContract>>(loader: () => Promise<{
17
+ default: U;
18
+ }>): DecoratedLazy<U>;
19
19
  }
20
20
  export type ChainedRouterImplementer<TContext extends Context, TContract extends ContractRouter, TExtraContext extends Context> = {
21
21
  [K in keyof TContract]: TContract[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? ProcedureImplementer<TContext, TExtraContext, UInputSchema, UOutputSchema> : TContract[K] extends ContractRouter ? ChainedRouterImplementer<TContext, TContract[K], TExtraContext> : never;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/server",
3
3
  "type": "module",
4
- "version": "0.15.0",
4
+ "version": "0.16.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -34,16 +34,15 @@
34
34
  "dist"
35
35
  ],
36
36
  "peerDependencies": {
37
- "zod": ">=3.23.0",
38
- "@orpc/zod": "0.15.0"
37
+ "@orpc/zod": "0.16.0"
39
38
  },
40
39
  "dependencies": {
41
- "@orpc/contract": "0.15.0",
42
- "@orpc/shared": "0.15.0",
43
- "@orpc/transformer": "0.15.0"
40
+ "@orpc/contract": "0.16.0",
41
+ "@orpc/shared": "0.16.0",
42
+ "@orpc/transformer": "0.16.0"
44
43
  },
45
44
  "devDependencies": {
46
- "@orpc/openapi": "0.15.0"
45
+ "@orpc/openapi": "0.16.0"
47
46
  },
48
47
  "scripts": {
49
48
  "build": "tsup --clean --sourcemap --entry.index=src/index.ts --entry.fetch=src/fetch/index.ts --format=esm --onSuccess='tsc -b --noCheck'",