@orpc/contract 1.2.0 → 1.3.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/README.md CHANGED
@@ -49,6 +49,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
49
49
  - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
50
50
  - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
51
51
  - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
52
+ - [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with NestJS.
52
53
  - [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
53
54
  - [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
54
55
  - [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
package/dist/index.d.mts CHANGED
@@ -96,6 +96,7 @@ interface Route {
96
96
  tags?: readonly string[];
97
97
  /**
98
98
  * The status code of the response when the procedure is successful.
99
+ * The status code must be in the 200-399 range.
99
100
  * This option is typically relevant when integrating with OpenAPI.
100
101
  *
101
102
  * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
@@ -137,16 +138,18 @@ interface Route {
137
138
  * Determines how the response should be structured based on the output.
138
139
  *
139
140
  * @option 'compact'
140
- * Includes only the body data, encoded directly in the response.
141
+ * The output data is directly returned as the response body.
141
142
  *
142
143
  * @option 'detailed'
143
- * Separates the output into `headers` and `body` fields.
144
- * - `headers`: Custom headers to merge with the response headers.
145
- * - `body`: The response data.
144
+ * Return an object with optional properties:
145
+ * - `status`: The response status (must be in 200-399 range) if not set fallback to `successStatus`.
146
+ * - `headers`: Custom headers to merge with the response headers (`Record<string, string | string[] | undefined>`)
147
+ * - `body`: The response body.
146
148
  *
147
149
  * Example:
148
150
  * ```ts
149
151
  * const output = {
152
+ * status: 201,
150
153
  * headers: { 'x-custom-header': 'value' },
151
154
  * body: { message: 'Hello, world!' },
152
155
  * };
@@ -507,5 +510,7 @@ type ContractRouterClient<TRouter extends AnyContractRouter, TClientContext exte
507
510
  [K in keyof TRouter]: TRouter[K] extends AnyContractRouter ? ContractRouterClient<TRouter[K], TClientContext> : never;
508
511
  };
509
512
 
510
- export { ContractBuilder, ContractProcedure, ValidationError, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, isContractProcedure, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, oc, prefixRoute, type, unshiftTagRoute };
513
+ declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
514
+
515
+ export { ContractBuilder, ContractProcedure, ValidationError, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, isContractProcedure, isSchemaIssue, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, oc, prefixRoute, type, unshiftTagRoute };
511
516
  export type { AnyContractProcedure, AnyContractRouter, AnySchema, ContractBuilderDef, ContractConfig, ContractProcedureBuilder, ContractProcedureBuilderWithInput, ContractProcedureBuilderWithInputOutput, ContractProcedureBuilderWithOutput, ContractProcedureClient, ContractProcedureDef, ContractRouter, ContractRouterBuilder, ContractRouterClient, EnhanceContractRouterOptions, EnhanceRouteOptions, EnhancedContractRouter, ErrorFromErrorMap, ErrorMap, ErrorMapItem, EventIteratorSchemaDetails, InferContractRouterErrorMap, InferContractRouterInputs, InferContractRouterMeta, InferContractRouterOutputs, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, ORPCErrorFromErrorMap, OutputStructure, Route, Schema, SchemaIssue, TypeRest, ValidationErrorOptions };
package/dist/index.d.ts CHANGED
@@ -96,6 +96,7 @@ interface Route {
96
96
  tags?: readonly string[];
97
97
  /**
98
98
  * The status code of the response when the procedure is successful.
99
+ * The status code must be in the 200-399 range.
99
100
  * This option is typically relevant when integrating with OpenAPI.
100
101
  *
101
102
  * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
@@ -137,16 +138,18 @@ interface Route {
137
138
  * Determines how the response should be structured based on the output.
138
139
  *
139
140
  * @option 'compact'
140
- * Includes only the body data, encoded directly in the response.
141
+ * The output data is directly returned as the response body.
141
142
  *
142
143
  * @option 'detailed'
143
- * Separates the output into `headers` and `body` fields.
144
- * - `headers`: Custom headers to merge with the response headers.
145
- * - `body`: The response data.
144
+ * Return an object with optional properties:
145
+ * - `status`: The response status (must be in 200-399 range) if not set fallback to `successStatus`.
146
+ * - `headers`: Custom headers to merge with the response headers (`Record<string, string | string[] | undefined>`)
147
+ * - `body`: The response body.
146
148
  *
147
149
  * Example:
148
150
  * ```ts
149
151
  * const output = {
152
+ * status: 201,
150
153
  * headers: { 'x-custom-header': 'value' },
151
154
  * body: { message: 'Hello, world!' },
152
155
  * };
@@ -507,5 +510,7 @@ type ContractRouterClient<TRouter extends AnyContractRouter, TClientContext exte
507
510
  [K in keyof TRouter]: TRouter[K] extends AnyContractRouter ? ContractRouterClient<TRouter[K], TClientContext> : never;
508
511
  };
509
512
 
510
- export { ContractBuilder, ContractProcedure, ValidationError, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, isContractProcedure, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, oc, prefixRoute, type, unshiftTagRoute };
513
+ declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
514
+
515
+ export { ContractBuilder, ContractProcedure, ValidationError, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, isContractProcedure, isSchemaIssue, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, oc, prefixRoute, type, unshiftTagRoute };
511
516
  export type { AnyContractProcedure, AnyContractRouter, AnySchema, ContractBuilderDef, ContractConfig, ContractProcedureBuilder, ContractProcedureBuilderWithInput, ContractProcedureBuilderWithInputOutput, ContractProcedureBuilderWithOutput, ContractProcedureClient, ContractProcedureDef, ContractRouter, ContractRouterBuilder, ContractRouterClient, EnhanceContractRouterOptions, EnhanceRouteOptions, EnhancedContractRouter, ErrorFromErrorMap, ErrorMap, ErrorMapItem, EventIteratorSchemaDetails, InferContractRouterErrorMap, InferContractRouterInputs, InferContractRouterMeta, InferContractRouterOutputs, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, ORPCErrorFromErrorMap, OutputStructure, Route, Schema, SchemaIssue, TypeRest, ValidationErrorOptions };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { isORPCErrorStatus, mapEventIterator, ORPCError } from '@orpc/client';
2
2
  export { ORPCError } from '@orpc/client';
3
- import { isAsyncIteratorObject } from '@orpc/shared';
3
+ import { isAsyncIteratorObject, isTypescriptObject, isPropertyKey } from '@orpc/shared';
4
4
 
5
5
  class ValidationError extends Error {
6
6
  issues;
@@ -307,4 +307,19 @@ function type(...[map]) {
307
307
  };
308
308
  }
309
309
 
310
- export { ContractBuilder, ContractProcedure, ValidationError, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, isContractProcedure, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, oc, prefixRoute, type, unshiftTagRoute };
310
+ function isSchemaIssue(issue) {
311
+ if (!isTypescriptObject(issue) || typeof issue.message !== "string") {
312
+ return false;
313
+ }
314
+ if (issue.path !== void 0) {
315
+ if (!Array.isArray(issue.path)) {
316
+ return false;
317
+ }
318
+ if (!issue.path.every((segment) => isPropertyKey(segment) || isTypescriptObject(segment) && isPropertyKey(segment.key))) {
319
+ return false;
320
+ }
321
+ }
322
+ return true;
323
+ }
324
+
325
+ export { ContractBuilder, ContractProcedure, ValidationError, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, isContractProcedure, isSchemaIssue, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, oc, prefixRoute, type, unshiftTagRoute };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/contract",
3
3
  "type": "module",
4
- "version": "1.2.0",
4
+ "version": "1.3.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -25,13 +25,13 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "@standard-schema/spec": "^1.0.0",
28
- "@orpc/shared": "1.2.0",
29
- "@orpc/client": "1.2.0"
28
+ "@orpc/client": "1.3.0",
29
+ "@orpc/shared": "1.3.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "arktype": "2.1.20",
33
- "valibot": "1.0.0",
34
- "zod": "^3.24.2"
33
+ "valibot": "^1.1.0",
34
+ "zod": "^3.25.11"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "unbuild",