@orpc/contract 0.0.0-next.9adcd05 → 0.0.0-next.9b13466

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
@@ -32,7 +32,7 @@
32
32
  - **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
33
33
  - **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
34
34
  - **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
35
- - **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue), Pinia Colada, and more.
35
+ - **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
36
36
  - **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
37
37
  - **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
38
38
  - **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
@@ -53,11 +53,16 @@ You can find the full documentation [here](https://orpc.unnoq.com).
53
53
  - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
54
54
  - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
55
55
  - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
56
+ - [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
56
57
  - [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
57
58
  - [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
59
+ - [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
60
+ - [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
58
61
  - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
59
62
  - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
60
63
  - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
64
+ - [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
65
+ - [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
61
66
 
62
67
  ## `@orpc/contract`
63
68
 
@@ -96,6 +101,14 @@ export const contract = {
96
101
  }
97
102
  ```
98
103
 
104
+ ## Sponsors
105
+
106
+ <p align="center">
107
+ <a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
108
+ <img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
109
+ </a>
110
+ </p>
111
+
99
112
  ## License
100
113
 
101
114
  Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
- import { ORPCErrorCode, ORPCError, ClientContext, Client } from '@orpc/client';
2
- export { ORPCError } from '@orpc/client';
3
- import { Promisable, IsEqual } from '@orpc/shared';
1
+ import { ORPCErrorCode, ORPCError, HTTPMethod, HTTPPath, ClientContext, Client } from '@orpc/client';
2
+ export { HTTPMethod, HTTPPath, ORPCError } from '@orpc/client';
3
+ import { Promisable, IsEqual, ThrowableError } from '@orpc/shared';
4
+ export { Registry, ThrowableError } from '@orpc/shared';
4
5
  import { StandardSchemaV1 } from '@standard-schema/spec';
5
6
 
6
7
  type Schema<TInput, TOutput> = StandardSchemaV1<TInput, TOutput>;
@@ -22,7 +23,6 @@ declare class ValidationError extends Error {
22
23
  interface ErrorMapItem<TDataSchema extends AnySchema> {
23
24
  status?: number;
24
25
  message?: string;
25
- description?: string;
26
26
  data?: TDataSchema;
27
27
  }
28
28
  type ErrorMap = {
@@ -33,13 +33,11 @@ declare function mergeErrorMap<T1 extends ErrorMap, T2 extends ErrorMap>(errorMa
33
33
  type ORPCErrorFromErrorMap<TErrorMap extends ErrorMap> = {
34
34
  [K in keyof TErrorMap]: K extends string ? TErrorMap[K] extends ErrorMapItem<infer TDataSchema extends Schema<unknown, unknown>> ? ORPCError<K, InferSchemaOutput<TDataSchema>> : never : never;
35
35
  }[keyof TErrorMap];
36
- type ErrorFromErrorMap<TErrorMap extends ErrorMap> = Error | ORPCErrorFromErrorMap<TErrorMap>;
36
+ type ErrorFromErrorMap<TErrorMap extends ErrorMap> = ORPCErrorFromErrorMap<TErrorMap> | ThrowableError;
37
37
 
38
38
  type Meta = Record<string, any>;
39
39
  declare function mergeMeta<T extends Meta>(meta1: T, meta2: T): T;
40
40
 
41
- type HTTPPath = `/${string}`;
42
- type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
43
41
  type InputStructure = 'compact' | 'detailed';
44
42
  type OutputStructure = 'compact' | 'detailed';
45
43
  interface Route {
@@ -195,7 +193,7 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
195
193
  /**
196
194
  * Reset initial meta
197
195
  */
198
- $meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U>;
196
+ $meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
199
197
  /**
200
198
  * Reset initial route
201
199
  */
@@ -233,4 +231,4 @@ type ContractRouterClient<TRouter extends AnyContractRouter, TClientContext exte
233
231
  [K in keyof TRouter]: TRouter[K] extends AnyContractRouter ? ContractRouterClient<TRouter[K], TClientContext> : never;
234
232
  };
235
233
 
236
- export { type AnyContractProcedure, type AnyContractRouter, type AnySchema, ContractBuilder, type ContractBuilderDef, type ContractConfig, ContractProcedure, type ContractProcedureBuilder, type ContractProcedureBuilderWithInput, type ContractProcedureBuilderWithInputOutput, type ContractProcedureBuilderWithOutput, type ContractProcedureClient, type ContractProcedureDef, type ContractRouter, type ContractRouterBuilder, type ContractRouterClient, type EnhanceContractRouterOptions, type EnhanceRouteOptions, type EnhancedContractRouter, type ErrorFromErrorMap, type ErrorMap, type ErrorMapItem, type EventIteratorSchemaDetails, type HTTPMethod, type HTTPPath, type InferContractRouterErrorMap, type InferContractRouterInputs, type InferContractRouterMeta, type InferContractRouterOutputs, type InferSchemaInput, type InferSchemaOutput, type InputStructure, type MergedErrorMap, type Meta, type ORPCErrorFromErrorMap, type OutputStructure, type Route, type Schema, type SchemaIssue, type TypeRest, ValidationError, type ValidationErrorOptions, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, isContractProcedure, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, oc, prefixRoute, type, unshiftTagRoute };
234
+ export { type AnyContractProcedure, type AnyContractRouter, type AnySchema, ContractBuilder, type ContractBuilderDef, type ContractConfig, ContractProcedure, type ContractProcedureBuilder, type ContractProcedureBuilderWithInput, type ContractProcedureBuilderWithInputOutput, type ContractProcedureBuilderWithOutput, type ContractProcedureClient, type ContractProcedureDef, type ContractRouter, type ContractRouterBuilder, type ContractRouterClient, type EnhanceContractRouterOptions, type EnhanceRouteOptions, type EnhancedContractRouter, type ErrorFromErrorMap, type ErrorMap, type ErrorMapItem, type EventIteratorSchemaDetails, type InferContractRouterErrorMap, type InferContractRouterInputs, type InferContractRouterMeta, type InferContractRouterOutputs, type InferSchemaInput, type InferSchemaOutput, type InputStructure, type MergedErrorMap, type Meta, type ORPCErrorFromErrorMap, type OutputStructure, type Route, type Schema, type SchemaIssue, type TypeRest, ValidationError, type ValidationErrorOptions, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, isContractProcedure, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, oc, prefixRoute, type, unshiftTagRoute };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { ORPCErrorCode, ORPCError, ClientContext, Client } from '@orpc/client';
2
- export { ORPCError } from '@orpc/client';
3
- import { Promisable, IsEqual } from '@orpc/shared';
1
+ import { ORPCErrorCode, ORPCError, HTTPMethod, HTTPPath, ClientContext, Client } from '@orpc/client';
2
+ export { HTTPMethod, HTTPPath, ORPCError } from '@orpc/client';
3
+ import { Promisable, IsEqual, ThrowableError } from '@orpc/shared';
4
+ export { Registry, ThrowableError } from '@orpc/shared';
4
5
  import { StandardSchemaV1 } from '@standard-schema/spec';
5
6
 
6
7
  type Schema<TInput, TOutput> = StandardSchemaV1<TInput, TOutput>;
@@ -22,7 +23,6 @@ declare class ValidationError extends Error {
22
23
  interface ErrorMapItem<TDataSchema extends AnySchema> {
23
24
  status?: number;
24
25
  message?: string;
25
- description?: string;
26
26
  data?: TDataSchema;
27
27
  }
28
28
  type ErrorMap = {
@@ -33,13 +33,11 @@ declare function mergeErrorMap<T1 extends ErrorMap, T2 extends ErrorMap>(errorMa
33
33
  type ORPCErrorFromErrorMap<TErrorMap extends ErrorMap> = {
34
34
  [K in keyof TErrorMap]: K extends string ? TErrorMap[K] extends ErrorMapItem<infer TDataSchema extends Schema<unknown, unknown>> ? ORPCError<K, InferSchemaOutput<TDataSchema>> : never : never;
35
35
  }[keyof TErrorMap];
36
- type ErrorFromErrorMap<TErrorMap extends ErrorMap> = Error | ORPCErrorFromErrorMap<TErrorMap>;
36
+ type ErrorFromErrorMap<TErrorMap extends ErrorMap> = ORPCErrorFromErrorMap<TErrorMap> | ThrowableError;
37
37
 
38
38
  type Meta = Record<string, any>;
39
39
  declare function mergeMeta<T extends Meta>(meta1: T, meta2: T): T;
40
40
 
41
- type HTTPPath = `/${string}`;
42
- type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
43
41
  type InputStructure = 'compact' | 'detailed';
44
42
  type OutputStructure = 'compact' | 'detailed';
45
43
  interface Route {
@@ -195,7 +193,7 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
195
193
  /**
196
194
  * Reset initial meta
197
195
  */
198
- $meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U>;
196
+ $meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
199
197
  /**
200
198
  * Reset initial route
201
199
  */
@@ -233,4 +231,4 @@ type ContractRouterClient<TRouter extends AnyContractRouter, TClientContext exte
233
231
  [K in keyof TRouter]: TRouter[K] extends AnyContractRouter ? ContractRouterClient<TRouter[K], TClientContext> : never;
234
232
  };
235
233
 
236
- export { type AnyContractProcedure, type AnyContractRouter, type AnySchema, ContractBuilder, type ContractBuilderDef, type ContractConfig, ContractProcedure, type ContractProcedureBuilder, type ContractProcedureBuilderWithInput, type ContractProcedureBuilderWithInputOutput, type ContractProcedureBuilderWithOutput, type ContractProcedureClient, type ContractProcedureDef, type ContractRouter, type ContractRouterBuilder, type ContractRouterClient, type EnhanceContractRouterOptions, type EnhanceRouteOptions, type EnhancedContractRouter, type ErrorFromErrorMap, type ErrorMap, type ErrorMapItem, type EventIteratorSchemaDetails, type HTTPMethod, type HTTPPath, type InferContractRouterErrorMap, type InferContractRouterInputs, type InferContractRouterMeta, type InferContractRouterOutputs, type InferSchemaInput, type InferSchemaOutput, type InputStructure, type MergedErrorMap, type Meta, type ORPCErrorFromErrorMap, type OutputStructure, type Route, type Schema, type SchemaIssue, type TypeRest, ValidationError, type ValidationErrorOptions, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, isContractProcedure, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, oc, prefixRoute, type, unshiftTagRoute };
234
+ export { type AnyContractProcedure, type AnyContractRouter, type AnySchema, ContractBuilder, type ContractBuilderDef, type ContractConfig, ContractProcedure, type ContractProcedureBuilder, type ContractProcedureBuilderWithInput, type ContractProcedureBuilderWithInputOutput, type ContractProcedureBuilderWithOutput, type ContractProcedureClient, type ContractProcedureDef, type ContractRouter, type ContractRouterBuilder, type ContractRouterClient, type EnhanceContractRouterOptions, type EnhanceRouteOptions, type EnhancedContractRouter, type ErrorFromErrorMap, type ErrorMap, type ErrorMapItem, type EventIteratorSchemaDetails, type InferContractRouterErrorMap, type InferContractRouterInputs, type InferContractRouterMeta, type InferContractRouterOutputs, type InferSchemaInput, type InferSchemaOutput, type InputStructure, type MergedErrorMap, type Meta, type ORPCErrorFromErrorMap, type OutputStructure, type Route, type Schema, type SchemaIssue, type TypeRest, ValidationError, type ValidationErrorOptions, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, isContractProcedure, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, oc, prefixRoute, type, unshiftTagRoute };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { mapEventIterator, ORPCError } from '@orpc/client';
1
+ import { isORPCErrorStatus, mapEventIterator, ORPCError } from '@orpc/client';
2
2
  export { ORPCError } from '@orpc/client';
3
3
  import { isAsyncIteratorObject } from '@orpc/shared';
4
4
 
@@ -20,11 +20,11 @@ function mergeMeta(meta1, meta2) {
20
20
  class ContractProcedure {
21
21
  "~orpc";
22
22
  constructor(def) {
23
- if (def.route?.successStatus && (def.route.successStatus < 200 || def.route?.successStatus > 299)) {
24
- throw new Error("[ContractProcedure] The successStatus must be between 200 and 299");
23
+ if (def.route?.successStatus && isORPCErrorStatus(def.route.successStatus)) {
24
+ throw new Error("[ContractProcedure] Invalid successStatus.");
25
25
  }
26
- if (Object.values(def.errorMap).some((val) => val && val.status && (val.status < 400 || val.status > 599))) {
27
- throw new Error("[ContractProcedure] The error status code must be in the 400-599 range.");
26
+ if (Object.values(def.errorMap).some((val) => val && val.status && !isORPCErrorStatus(val.status))) {
27
+ throw new Error("[ContractProcedure] Invalid error status code.");
28
28
  }
29
29
  this["~orpc"] = def;
30
30
  }
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.9adcd05",
4
+ "version": "0.0.0-next.9b13466",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -25,13 +25,12 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "@standard-schema/spec": "^1.0.0",
28
- "@orpc/shared": "0.0.0-next.9adcd05",
29
- "@orpc/standard-server": "0.0.0-next.9adcd05",
30
- "@orpc/client": "0.0.0-next.9adcd05"
28
+ "@orpc/client": "0.0.0-next.9b13466",
29
+ "@orpc/shared": "0.0.0-next.9b13466"
31
30
  },
32
31
  "devDependencies": {
33
32
  "arktype": "2.0.0-rc.26",
34
- "valibot": "1.0.0-beta.9",
33
+ "valibot": "1.0.0",
35
34
  "zod": "^3.24.2"
36
35
  },
37
36
  "scripts": {