@orpc/contract 0.0.0-next.f356b86 → 0.0.0-next.f437dcb
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 +4 -2
- package/dist/index.d.mts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.mjs +4 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
- **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
|
|
31
31
|
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
|
32
32
|
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
|
33
|
-
-
|
|
33
|
+
- **🔍 First-Class OpenTelemetry**: Seamlessly integrate with OpenTelemetry for observability.
|
|
34
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more.
|
|
34
35
|
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
|
35
36
|
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
|
36
37
|
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
|
@@ -38,7 +39,6 @@
|
|
|
38
39
|
- **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
|
|
39
40
|
- **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
|
|
40
41
|
- **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
|
|
41
|
-
- **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed.
|
|
42
42
|
|
|
43
43
|
## Documentation
|
|
44
44
|
|
|
@@ -50,9 +50,11 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
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
52
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
53
|
+
- [@orpc/otel](https://www.npmjs.com/package/@orpc/otel): [OpenTelemetry](https://opentelemetry.io/) integration for observability.
|
|
53
54
|
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
|
54
55
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
55
56
|
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
|
|
57
|
+
- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration.
|
|
56
58
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
57
59
|
- [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
|
|
58
60
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
package/dist/index.d.mts
CHANGED
|
@@ -23,6 +23,10 @@ declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutp
|
|
|
23
23
|
interface ValidationErrorOptions extends ErrorOptions {
|
|
24
24
|
message: string;
|
|
25
25
|
issues: readonly SchemaIssue[];
|
|
26
|
+
/**
|
|
27
|
+
* @todo require this field in v2
|
|
28
|
+
*/
|
|
29
|
+
data?: unknown;
|
|
26
30
|
}
|
|
27
31
|
/**
|
|
28
32
|
* This errors usually used for ORPCError.cause when the error is a validation error.
|
|
@@ -31,6 +35,7 @@ interface ValidationErrorOptions extends ErrorOptions {
|
|
|
31
35
|
*/
|
|
32
36
|
declare class ValidationError extends Error {
|
|
33
37
|
readonly issues: readonly SchemaIssue[];
|
|
38
|
+
readonly data: unknown;
|
|
34
39
|
constructor(options: ValidationErrorOptions);
|
|
35
40
|
}
|
|
36
41
|
interface ErrorMapItem<TDataSchema extends AnySchema> {
|
|
@@ -68,6 +73,13 @@ interface Route {
|
|
|
68
73
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
69
74
|
*/
|
|
70
75
|
path?: HTTPPath;
|
|
76
|
+
/**
|
|
77
|
+
* The operation ID of the endpoint.
|
|
78
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
79
|
+
*
|
|
80
|
+
* @default Concatenation of router segments
|
|
81
|
+
*/
|
|
82
|
+
operationId?: string;
|
|
71
83
|
/**
|
|
72
84
|
* The summary of the procedure.
|
|
73
85
|
* This option is typically relevant when integrating with OpenAPI.
|
|
@@ -166,7 +178,7 @@ interface Route {
|
|
|
166
178
|
*
|
|
167
179
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata Operation Metadata Docs}
|
|
168
180
|
*/
|
|
169
|
-
spec?: OpenAPIV3_1.OperationObject;
|
|
181
|
+
spec?: OpenAPIV3_1.OperationObject | ((current: OpenAPIV3_1.OperationObject) => OpenAPIV3_1.OperationObject);
|
|
170
182
|
}
|
|
171
183
|
declare function mergeRoute(a: Route, b: Route): Route;
|
|
172
184
|
declare function prefixRoute(route: Route, prefix: HTTPPath): Route;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutp
|
|
|
23
23
|
interface ValidationErrorOptions extends ErrorOptions {
|
|
24
24
|
message: string;
|
|
25
25
|
issues: readonly SchemaIssue[];
|
|
26
|
+
/**
|
|
27
|
+
* @todo require this field in v2
|
|
28
|
+
*/
|
|
29
|
+
data?: unknown;
|
|
26
30
|
}
|
|
27
31
|
/**
|
|
28
32
|
* This errors usually used for ORPCError.cause when the error is a validation error.
|
|
@@ -31,6 +35,7 @@ interface ValidationErrorOptions extends ErrorOptions {
|
|
|
31
35
|
*/
|
|
32
36
|
declare class ValidationError extends Error {
|
|
33
37
|
readonly issues: readonly SchemaIssue[];
|
|
38
|
+
readonly data: unknown;
|
|
34
39
|
constructor(options: ValidationErrorOptions);
|
|
35
40
|
}
|
|
36
41
|
interface ErrorMapItem<TDataSchema extends AnySchema> {
|
|
@@ -68,6 +73,13 @@ interface Route {
|
|
|
68
73
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
69
74
|
*/
|
|
70
75
|
path?: HTTPPath;
|
|
76
|
+
/**
|
|
77
|
+
* The operation ID of the endpoint.
|
|
78
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
79
|
+
*
|
|
80
|
+
* @default Concatenation of router segments
|
|
81
|
+
*/
|
|
82
|
+
operationId?: string;
|
|
71
83
|
/**
|
|
72
84
|
* The summary of the procedure.
|
|
73
85
|
* This option is typically relevant when integrating with OpenAPI.
|
|
@@ -166,7 +178,7 @@ interface Route {
|
|
|
166
178
|
*
|
|
167
179
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata Operation Metadata Docs}
|
|
168
180
|
*/
|
|
169
|
-
spec?: OpenAPIV3_1.OperationObject;
|
|
181
|
+
spec?: OpenAPIV3_1.OperationObject | ((current: OpenAPIV3_1.OperationObject) => OpenAPIV3_1.OperationObject);
|
|
170
182
|
}
|
|
171
183
|
declare function mergeRoute(a: Route, b: Route): Route;
|
|
172
184
|
declare function prefixRoute(route: Route, prefix: HTTPPath): Route;
|
package/dist/index.mjs
CHANGED
|
@@ -4,9 +4,11 @@ import { isAsyncIteratorObject, get, isTypescriptObject, isPropertyKey } from '@
|
|
|
4
4
|
|
|
5
5
|
class ValidationError extends Error {
|
|
6
6
|
issues;
|
|
7
|
+
data;
|
|
7
8
|
constructor(options) {
|
|
8
9
|
super(options.message, options);
|
|
9
10
|
this.issues = options.issues;
|
|
11
|
+
this.data = options.data;
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
function mergeErrorMap(errorMap1, errorMap2) {
|
|
@@ -289,7 +291,8 @@ function eventIterator(yields, returns) {
|
|
|
289
291
|
message: "Event iterator validation failed",
|
|
290
292
|
cause: new ValidationError({
|
|
291
293
|
issues: result.issues,
|
|
292
|
-
message: "Event iterator validation failed"
|
|
294
|
+
message: "Event iterator validation failed",
|
|
295
|
+
data: value
|
|
293
296
|
})
|
|
294
297
|
});
|
|
295
298
|
}
|
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.f437dcb",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@standard-schema/spec": "^1.0.0",
|
|
28
28
|
"openapi-types": "^12.1.3",
|
|
29
|
-
"@orpc/client": "0.0.0-next.
|
|
30
|
-
"@orpc/shared": "0.0.0-next.
|
|
29
|
+
"@orpc/client": "0.0.0-next.f437dcb",
|
|
30
|
+
"@orpc/shared": "0.0.0-next.f437dcb"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"arktype": "2.1.20",
|
|
34
34
|
"valibot": "^1.1.0",
|
|
35
|
-
"zod": "^
|
|
35
|
+
"zod": "^4.1.3"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "unbuild",
|