@orpc/contract 0.0.0-next.f81b4a2 → 0.0.0-next.fa75202
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 +14 -17
- package/dist/index.d.mts +10 -5
- package/dist/index.d.ts +10 -5
- package/dist/index.mjs +17 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -21,28 +21,24 @@
|
|
|
21
21
|
|
|
22
22
|
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
|
23
23
|
|
|
24
|
-
**oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards
|
|
24
|
+
**oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
28
28
|
## Highlights
|
|
29
29
|
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
- **Reusability 🔄**: Write once and reuse your code across multiple purposes effortlessly.
|
|
43
|
-
- **Extendability 🔌**: Easily enhance oRPC with plugins, middleware, and interceptors.
|
|
44
|
-
- **Reliability 🛡️**: Well-tested, fully TypeScript, production-ready, and MIT licensed for peace of mind.
|
|
45
|
-
- **Simplicity 💡**: Enjoy straightforward, clean code with no hidden magic.
|
|
30
|
+
- **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
|
|
31
|
+
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
|
32
|
+
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
|
33
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
|
|
34
|
+
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
|
35
|
+
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
|
36
|
+
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
|
37
|
+
- **⏱️ Lazy Router**: Enhance cold start times with our lazy routing feature.
|
|
38
|
+
- **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
|
|
39
|
+
- **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
|
|
40
|
+
- **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
|
|
41
|
+
- **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed.
|
|
46
42
|
|
|
47
43
|
## Documentation
|
|
48
44
|
|
|
@@ -53,6 +49,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
53
49
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
|
54
50
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
55
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.
|
|
56
53
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
57
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).
|
|
58
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
|
-
*
|
|
141
|
+
* The output data is directly returned as the response body.
|
|
141
142
|
*
|
|
142
143
|
* @option 'detailed'
|
|
143
|
-
*
|
|
144
|
-
* - `
|
|
145
|
-
* - `
|
|
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
|
-
|
|
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
|
-
*
|
|
141
|
+
* The output data is directly returned as the response body.
|
|
141
142
|
*
|
|
142
143
|
* @option 'detailed'
|
|
143
|
-
*
|
|
144
|
-
* - `
|
|
145
|
-
* - `
|
|
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
|
-
|
|
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
|
-
|
|
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": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.fa75202",
|
|
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/
|
|
29
|
-
"@orpc/
|
|
28
|
+
"@orpc/shared": "0.0.0-next.fa75202",
|
|
29
|
+
"@orpc/client": "0.0.0-next.fa75202"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"arktype": "2.1.
|
|
33
|
-
"valibot": "1.
|
|
34
|
-
"zod": "^3.
|
|
32
|
+
"arktype": "2.1.20",
|
|
33
|
+
"valibot": "^1.1.0",
|
|
34
|
+
"zod": "^3.25.11"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "unbuild",
|