@orpc/contract 0.0.0-next.8f622a0 → 0.0.0-next.904b0c2

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
@@ -100,6 +100,14 @@ export const contract = {
100
100
  }
101
101
  ```
102
102
 
103
+ ## Sponsors
104
+
105
+ <p align="center">
106
+ <a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
107
+ <img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
108
+ </a>
109
+ </p>
110
+
103
111
  ## License
104
112
 
105
113
  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,4 +1,4 @@
1
- import { ORPCErrorCode, ORPCError, ClientContext, Client } from '@orpc/client';
1
+ import { ORPCErrorCode, ORPCError, HTTPMethod, HTTPPath, ClientContext, Client } from '@orpc/client';
2
2
  export { ORPCError } from '@orpc/client';
3
3
  import { Promisable, IsEqual } from '@orpc/shared';
4
4
  import { StandardSchemaV1 } from '@standard-schema/spec';
@@ -22,7 +22,6 @@ declare class ValidationError extends Error {
22
22
  interface ErrorMapItem<TDataSchema extends AnySchema> {
23
23
  status?: number;
24
24
  message?: string;
25
- description?: string;
26
25
  data?: TDataSchema;
27
26
  }
28
27
  type ErrorMap = {
@@ -38,8 +37,6 @@ type ErrorFromErrorMap<TErrorMap extends ErrorMap> = Error | ORPCErrorFromErrorM
38
37
  type Meta = Record<string, any>;
39
38
  declare function mergeMeta<T extends Meta>(meta1: T, meta2: T): T;
40
39
 
41
- type HTTPPath = `/${string}`;
42
- type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
43
40
  type InputStructure = 'compact' | 'detailed';
44
41
  type OutputStructure = 'compact' | 'detailed';
45
42
  interface Route {
@@ -233,4 +230,4 @@ type ContractRouterClient<TRouter extends AnyContractRouter, TClientContext exte
233
230
  [K in keyof TRouter]: TRouter[K] extends AnyContractRouter ? ContractRouterClient<TRouter[K], TClientContext> : never;
234
231
  };
235
232
 
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 };
233
+ 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,4 +1,4 @@
1
- import { ORPCErrorCode, ORPCError, ClientContext, Client } from '@orpc/client';
1
+ import { ORPCErrorCode, ORPCError, HTTPMethod, HTTPPath, ClientContext, Client } from '@orpc/client';
2
2
  export { ORPCError } from '@orpc/client';
3
3
  import { Promisable, IsEqual } from '@orpc/shared';
4
4
  import { StandardSchemaV1 } from '@standard-schema/spec';
@@ -22,7 +22,6 @@ declare class ValidationError extends Error {
22
22
  interface ErrorMapItem<TDataSchema extends AnySchema> {
23
23
  status?: number;
24
24
  message?: string;
25
- description?: string;
26
25
  data?: TDataSchema;
27
26
  }
28
27
  type ErrorMap = {
@@ -38,8 +37,6 @@ type ErrorFromErrorMap<TErrorMap extends ErrorMap> = Error | ORPCErrorFromErrorM
38
37
  type Meta = Record<string, any>;
39
38
  declare function mergeMeta<T extends Meta>(meta1: T, meta2: T): T;
40
39
 
41
- type HTTPPath = `/${string}`;
42
- type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
43
40
  type InputStructure = 'compact' | 'detailed';
44
41
  type OutputStructure = 'compact' | 'detailed';
45
42
  interface Route {
@@ -233,4 +230,4 @@ type ContractRouterClient<TRouter extends AnyContractRouter, TClientContext exte
233
230
  [K in keyof TRouter]: TRouter[K] extends AnyContractRouter ? ContractRouterClient<TRouter[K], TClientContext> : never;
234
231
  };
235
232
 
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 };
233
+ 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.8f622a0",
4
+ "version": "0.0.0-next.904b0c2",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -25,9 +25,9 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "@standard-schema/spec": "^1.0.0",
28
- "@orpc/client": "0.0.0-next.8f622a0",
29
- "@orpc/shared": "0.0.0-next.8f622a0",
30
- "@orpc/standard-server": "0.0.0-next.8f622a0"
28
+ "@orpc/client": "0.0.0-next.904b0c2",
29
+ "@orpc/shared": "0.0.0-next.904b0c2",
30
+ "@orpc/standard-server": "0.0.0-next.904b0c2"
31
31
  },
32
32
  "devDependencies": {
33
33
  "arktype": "2.0.0-rc.26",