@orpc/contract 0.0.0-next.ed15210 → 0.0.0-next.ee46dab
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 +114 -0
- package/dist/index.d.mts +234 -0
- package/dist/index.d.ts +234 -0
- package/dist/index.mjs +252 -0
- package/package.json +10 -13
- package/dist/index.js +0 -527
- package/dist/src/builder.d.ts +0 -32
- package/dist/src/client-utils.d.ts +0 -5
- package/dist/src/client.d.ts +0 -19
- package/dist/src/config.d.ts +0 -11
- package/dist/src/error-map.d.ts +0 -58
- package/dist/src/error-orpc.d.ts +0 -109
- package/dist/src/error.d.ts +0 -13
- package/dist/src/index.d.ts +0 -23
- package/dist/src/procedure-builder-with-input.d.ts +0 -19
- package/dist/src/procedure-builder-with-output.d.ts +0 -19
- package/dist/src/procedure-builder.d.ts +0 -15
- package/dist/src/procedure-client.d.ts +0 -6
- package/dist/src/procedure-decorated.d.ts +0 -12
- package/dist/src/procedure.d.ts +0 -20
- package/dist/src/route.d.ts +0 -88
- package/dist/src/router-builder.d.ts +0 -24
- package/dist/src/router-client.d.ts +0 -7
- package/dist/src/router.d.ts +0 -13
- package/dist/src/schema-utils.d.ts +0 -5
- package/dist/src/types.d.ts +0 -7
package/dist/src/error-orpc.d.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import type { ErrorMap, ErrorMapItem } from './error-map';
|
|
2
|
-
import type { SchemaOutput } from './types';
|
|
3
|
-
export type ORPCErrorFromErrorMap<TErrorMap extends ErrorMap> = {
|
|
4
|
-
[K in keyof TErrorMap]: K extends string ? TErrorMap[K] extends ErrorMapItem<infer TDataSchema> ? ORPCError<K, SchemaOutput<TDataSchema>> : never : never;
|
|
5
|
-
}[keyof TErrorMap];
|
|
6
|
-
export declare const COMMON_ORPC_ERROR_DEFS: {
|
|
7
|
-
readonly BAD_REQUEST: {
|
|
8
|
-
readonly status: 400;
|
|
9
|
-
readonly message: "Bad Request";
|
|
10
|
-
};
|
|
11
|
-
readonly UNAUTHORIZED: {
|
|
12
|
-
readonly status: 401;
|
|
13
|
-
readonly message: "Unauthorized";
|
|
14
|
-
};
|
|
15
|
-
readonly FORBIDDEN: {
|
|
16
|
-
readonly status: 403;
|
|
17
|
-
readonly message: "Forbidden";
|
|
18
|
-
};
|
|
19
|
-
readonly NOT_FOUND: {
|
|
20
|
-
readonly status: 404;
|
|
21
|
-
readonly message: "Not Found";
|
|
22
|
-
};
|
|
23
|
-
readonly METHOD_NOT_SUPPORTED: {
|
|
24
|
-
readonly status: 405;
|
|
25
|
-
readonly message: "Method Not Supported";
|
|
26
|
-
};
|
|
27
|
-
readonly NOT_ACCEPTABLE: {
|
|
28
|
-
readonly status: 406;
|
|
29
|
-
readonly message: "Not Acceptable";
|
|
30
|
-
};
|
|
31
|
-
readonly TIMEOUT: {
|
|
32
|
-
readonly status: 408;
|
|
33
|
-
readonly message: "Request Timeout";
|
|
34
|
-
};
|
|
35
|
-
readonly CONFLICT: {
|
|
36
|
-
readonly status: 409;
|
|
37
|
-
readonly message: "Conflict";
|
|
38
|
-
};
|
|
39
|
-
readonly PRECONDITION_FAILED: {
|
|
40
|
-
readonly status: 412;
|
|
41
|
-
readonly message: "Precondition Failed";
|
|
42
|
-
};
|
|
43
|
-
readonly PAYLOAD_TOO_LARGE: {
|
|
44
|
-
readonly status: 413;
|
|
45
|
-
readonly message: "Payload Too Large";
|
|
46
|
-
};
|
|
47
|
-
readonly UNSUPPORTED_MEDIA_TYPE: {
|
|
48
|
-
readonly status: 415;
|
|
49
|
-
readonly message: "Unsupported Media Type";
|
|
50
|
-
};
|
|
51
|
-
readonly UNPROCESSABLE_CONTENT: {
|
|
52
|
-
readonly status: 422;
|
|
53
|
-
readonly message: "Unprocessable Content";
|
|
54
|
-
};
|
|
55
|
-
readonly TOO_MANY_REQUESTS: {
|
|
56
|
-
readonly status: 429;
|
|
57
|
-
readonly message: "Too Many Requests";
|
|
58
|
-
};
|
|
59
|
-
readonly CLIENT_CLOSED_REQUEST: {
|
|
60
|
-
readonly status: 499;
|
|
61
|
-
readonly message: "Client Closed Request";
|
|
62
|
-
};
|
|
63
|
-
readonly INTERNAL_SERVER_ERROR: {
|
|
64
|
-
readonly status: 500;
|
|
65
|
-
readonly message: "Internal Server Error";
|
|
66
|
-
};
|
|
67
|
-
readonly NOT_IMPLEMENTED: {
|
|
68
|
-
readonly status: 501;
|
|
69
|
-
readonly message: "Not Implemented";
|
|
70
|
-
};
|
|
71
|
-
readonly BAD_GATEWAY: {
|
|
72
|
-
readonly status: 502;
|
|
73
|
-
readonly message: "Bad Gateway";
|
|
74
|
-
};
|
|
75
|
-
readonly SERVICE_UNAVAILABLE: {
|
|
76
|
-
readonly status: 503;
|
|
77
|
-
readonly message: "Service Unavailable";
|
|
78
|
-
};
|
|
79
|
-
readonly GATEWAY_TIMEOUT: {
|
|
80
|
-
readonly status: 504;
|
|
81
|
-
readonly message: "Gateway Timeout";
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
export type CommonORPCErrorCode = keyof typeof COMMON_ORPC_ERROR_DEFS;
|
|
85
|
-
export type ORPCErrorOptions<TCode extends string, TData> = ErrorOptions & {
|
|
86
|
-
defined?: boolean;
|
|
87
|
-
code: TCode;
|
|
88
|
-
status?: number;
|
|
89
|
-
message?: string;
|
|
90
|
-
} & (undefined extends TData ? {
|
|
91
|
-
data?: TData;
|
|
92
|
-
} : {
|
|
93
|
-
data: TData;
|
|
94
|
-
});
|
|
95
|
-
export declare function fallbackORPCErrorStatus(code: CommonORPCErrorCode | (string & {}), status: number | undefined): number;
|
|
96
|
-
export declare function fallbackORPCErrorMessage(code: CommonORPCErrorCode | (string & {}), message: string | undefined): string;
|
|
97
|
-
export declare class ORPCError<TCode extends CommonORPCErrorCode | (string & {}), TData> extends Error {
|
|
98
|
-
readonly defined: boolean;
|
|
99
|
-
readonly code: TCode;
|
|
100
|
-
readonly status: number;
|
|
101
|
-
readonly data: TData;
|
|
102
|
-
constructor(options: ORPCErrorOptions<TCode, TData>);
|
|
103
|
-
toJSON(): ORPCErrorJSON<TCode, TData>;
|
|
104
|
-
static isValidJSON(json: unknown): json is ORPCErrorJSON<string, unknown>;
|
|
105
|
-
}
|
|
106
|
-
export type ORPCErrorJSON<TCode extends string, TData> = Pick<ORPCError<TCode, TData>, 'defined' | 'code' | 'status' | 'message' | 'data'>;
|
|
107
|
-
export declare function isDefinedError<T>(error: T): error is Extract<T, ORPCError<any, any>>;
|
|
108
|
-
export declare function validateORPCError(map: ErrorMap, error: ORPCError<any, any>): Promise<ORPCError<string, unknown>>;
|
|
109
|
-
//# sourceMappingURL=error-orpc.d.ts.map
|
package/dist/src/error.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import type { ErrorMap } from './error-map';
|
|
3
|
-
import type { ORPCErrorFromErrorMap } from './error-orpc';
|
|
4
|
-
export type ErrorFromErrorMap<TErrorMap extends ErrorMap> = Error | ORPCErrorFromErrorMap<TErrorMap>;
|
|
5
|
-
export interface ValidationErrorOptions extends ErrorOptions {
|
|
6
|
-
message: string;
|
|
7
|
-
issues: readonly StandardSchemaV1.Issue[];
|
|
8
|
-
}
|
|
9
|
-
export declare class ValidationError extends Error {
|
|
10
|
-
readonly issues: readonly StandardSchemaV1.Issue[];
|
|
11
|
-
constructor(options: ValidationErrorOptions);
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=error.d.ts.map
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/** unnoq */
|
|
2
|
-
import { ContractBuilder } from './builder';
|
|
3
|
-
export * from './builder';
|
|
4
|
-
export * from './client';
|
|
5
|
-
export * from './client-utils';
|
|
6
|
-
export * from './config';
|
|
7
|
-
export * from './error';
|
|
8
|
-
export * from './error-map';
|
|
9
|
-
export * from './error-orpc';
|
|
10
|
-
export * from './procedure';
|
|
11
|
-
export * from './procedure-builder';
|
|
12
|
-
export * from './procedure-builder-with-input';
|
|
13
|
-
export * from './procedure-builder-with-output';
|
|
14
|
-
export * from './procedure-client';
|
|
15
|
-
export * from './procedure-decorated';
|
|
16
|
-
export * from './route';
|
|
17
|
-
export * from './router';
|
|
18
|
-
export * from './router-builder';
|
|
19
|
-
export * from './router-client';
|
|
20
|
-
export * from './schema-utils';
|
|
21
|
-
export * from './types';
|
|
22
|
-
export declare const oc: ContractBuilder<{}, {}>;
|
|
23
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ErrorMap, ErrorMapGuard, ErrorMapSuggestions, StrictErrorMap } from './error-map';
|
|
2
|
-
import type { HTTPPath, MergeRoute, PrefixRoute, Route, UnshiftTagRoute } from './route';
|
|
3
|
-
import type { Schema, SchemaOutput } from './types';
|
|
4
|
-
import { ContractProcedure } from './procedure';
|
|
5
|
-
import { DecoratedContractProcedure } from './procedure-decorated';
|
|
6
|
-
/**
|
|
7
|
-
* `ContractProcedureBuilderWithInput` is a branch of `ContractProcedureBuilder` which it has input schema.
|
|
8
|
-
*
|
|
9
|
-
* Why?
|
|
10
|
-
* - prevents override input schema after .input
|
|
11
|
-
*/
|
|
12
|
-
export declare class ContractProcedureBuilderWithInput<TInputSchema extends Schema, TErrorMap extends ErrorMap, TRoute extends Route> extends ContractProcedure<TInputSchema, undefined, TErrorMap, TRoute> {
|
|
13
|
-
errors<const U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, StrictErrorMap<U> & TErrorMap, TRoute>;
|
|
14
|
-
route<const U extends Route>(route: U): ContractProcedureBuilderWithInput<TInputSchema, TErrorMap, MergeRoute<TRoute, U>>;
|
|
15
|
-
prefix<U extends HTTPPath>(prefix: U): ContractProcedureBuilderWithInput<TInputSchema, TErrorMap, PrefixRoute<TRoute, U>>;
|
|
16
|
-
unshiftTag<U extends string[]>(...tags: U): ContractProcedureBuilderWithInput<TInputSchema, TErrorMap, UnshiftTagRoute<TRoute, U>>;
|
|
17
|
-
output<U extends Schema>(schema: U, example?: SchemaOutput<U>): DecoratedContractProcedure<TInputSchema, U, TErrorMap, TRoute>;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=procedure-builder-with-input.d.ts.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ErrorMap, ErrorMapGuard, ErrorMapSuggestions, StrictErrorMap } from './error-map';
|
|
2
|
-
import type { HTTPPath, MergeRoute, PrefixRoute, Route, UnshiftTagRoute } from './route';
|
|
3
|
-
import type { Schema, SchemaInput } from './types';
|
|
4
|
-
import { ContractProcedure } from './procedure';
|
|
5
|
-
import { DecoratedContractProcedure } from './procedure-decorated';
|
|
6
|
-
/**
|
|
7
|
-
* `ContractProcedureBuilderWithOutput` is a branch of `ContractProcedureBuilder` which it has output schema.
|
|
8
|
-
*
|
|
9
|
-
* Why?
|
|
10
|
-
* - prevents override output schema after .output
|
|
11
|
-
*/
|
|
12
|
-
export declare class ContractProcedureBuilderWithOutput<TOutputSchema extends Schema, TErrorMap extends ErrorMap, TRoute extends Route> extends ContractProcedure<undefined, TOutputSchema, TErrorMap, TRoute> {
|
|
13
|
-
errors<const U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): ContractProcedureBuilderWithOutput<TOutputSchema, StrictErrorMap<U> & TErrorMap, TRoute>;
|
|
14
|
-
route<const U extends Route>(route: U): ContractProcedureBuilderWithOutput<TOutputSchema, TErrorMap, MergeRoute<TRoute, U>>;
|
|
15
|
-
prefix<U extends HTTPPath>(prefix: U): ContractProcedureBuilderWithOutput<TOutputSchema, TErrorMap, PrefixRoute<TRoute, U>>;
|
|
16
|
-
unshiftTag<U extends string[]>(...tags: U): ContractProcedureBuilderWithOutput<TOutputSchema, TErrorMap, UnshiftTagRoute<TRoute, U>>;
|
|
17
|
-
input<U extends Schema>(schema: U, example?: SchemaInput<U>): DecoratedContractProcedure<U, TOutputSchema, TErrorMap, TRoute>;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=procedure-builder-with-output.d.ts.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ErrorMap, ErrorMapGuard, ErrorMapSuggestions, StrictErrorMap } from './error-map';
|
|
2
|
-
import type { HTTPPath, MergeRoute, PrefixRoute, Route, UnshiftTagRoute } from './route';
|
|
3
|
-
import type { Schema, SchemaInput, SchemaOutput } from './types';
|
|
4
|
-
import { ContractProcedure } from './procedure';
|
|
5
|
-
import { ContractProcedureBuilderWithInput } from './procedure-builder-with-input';
|
|
6
|
-
import { ContractProcedureBuilderWithOutput } from './procedure-builder-with-output';
|
|
7
|
-
export declare class ContractProcedureBuilder<TErrorMap extends ErrorMap, TRoute extends Route> extends ContractProcedure<undefined, undefined, TErrorMap, TRoute> {
|
|
8
|
-
errors<const U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): ContractProcedureBuilder<StrictErrorMap<U> & TErrorMap, TRoute>;
|
|
9
|
-
route<const U extends Route>(route: U): ContractProcedureBuilder<TErrorMap, MergeRoute<TRoute, U>>;
|
|
10
|
-
prefix<U extends HTTPPath>(prefix: U): ContractProcedureBuilder<TErrorMap, PrefixRoute<TRoute, U>>;
|
|
11
|
-
unshiftTag<U extends string[]>(...tags: U): ContractProcedureBuilder<TErrorMap, UnshiftTagRoute<TRoute, U>>;
|
|
12
|
-
input<U extends Schema>(schema: U, example?: SchemaInput<U>): ContractProcedureBuilderWithInput<U, TErrorMap, TRoute>;
|
|
13
|
-
output<U extends Schema>(schema: U, example?: SchemaOutput<U>): ContractProcedureBuilderWithOutput<U, TErrorMap, TRoute>;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=procedure-builder.d.ts.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Client } from './client';
|
|
2
|
-
import type { ErrorFromErrorMap } from './error';
|
|
3
|
-
import type { ErrorMap } from './error-map';
|
|
4
|
-
import type { Schema, SchemaInput, SchemaOutput } from './types';
|
|
5
|
-
export type ContractProcedureClient<TClientContext, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap> = Client<TClientContext, SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
|
6
|
-
//# sourceMappingURL=procedure-client.d.ts.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ErrorMap, ErrorMapGuard, ErrorMapSuggestions, StrictErrorMap } from './error-map';
|
|
2
|
-
import type { Schema } from './types';
|
|
3
|
-
import { ContractProcedure } from './procedure';
|
|
4
|
-
import { type HTTPPath, type MergeRoute, type PrefixRoute, type Route, type UnshiftTagRoute } from './route';
|
|
5
|
-
export declare class DecoratedContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TRoute extends Route> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TRoute> {
|
|
6
|
-
static decorate<UInputSchema extends Schema, UOutputSchema extends Schema, UErrorMap extends ErrorMap, URoute extends Route>(procedure: ContractProcedure<UInputSchema, UOutputSchema, UErrorMap, URoute>): DecoratedContractProcedure<UInputSchema, UOutputSchema, UErrorMap, URoute>;
|
|
7
|
-
errors<const U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): DecoratedContractProcedure<TInputSchema, TOutputSchema, StrictErrorMap<U> & TErrorMap, TRoute>;
|
|
8
|
-
route<const U extends Route>(route: U): DecoratedContractProcedure<TInputSchema, TOutputSchema, TErrorMap, MergeRoute<TRoute, U>>;
|
|
9
|
-
prefix<U extends HTTPPath>(prefix: U): DecoratedContractProcedure<TInputSchema, TOutputSchema, TErrorMap, PrefixRoute<TRoute, U>>;
|
|
10
|
-
unshiftTag<U extends string[]>(...tags: U): DecoratedContractProcedure<TInputSchema, TOutputSchema, TErrorMap, UnshiftTagRoute<TRoute, U>>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=procedure-decorated.d.ts.map
|
package/dist/src/procedure.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ErrorMap } from './error-map';
|
|
2
|
-
import type { Route } from './route';
|
|
3
|
-
import type { Schema, SchemaOutput } from './types';
|
|
4
|
-
export interface ContractProcedureDef<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TRoute extends Route> {
|
|
5
|
-
route: TRoute;
|
|
6
|
-
InputSchema: TInputSchema;
|
|
7
|
-
inputExample?: SchemaOutput<TInputSchema>;
|
|
8
|
-
OutputSchema: TOutputSchema;
|
|
9
|
-
outputExample?: SchemaOutput<TOutputSchema>;
|
|
10
|
-
errorMap: TErrorMap;
|
|
11
|
-
}
|
|
12
|
-
export declare class ContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TRoute extends Route> {
|
|
13
|
-
'~type': "ContractProcedure";
|
|
14
|
-
'~orpc': ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TRoute>;
|
|
15
|
-
constructor(def: ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TRoute>);
|
|
16
|
-
}
|
|
17
|
-
export type ANY_CONTRACT_PROCEDURE = ContractProcedure<any, any, any, any>;
|
|
18
|
-
export type WELL_CONTRACT_PROCEDURE = ContractProcedure<Schema, Schema, ErrorMap, Route>;
|
|
19
|
-
export declare function isContractProcedure(item: unknown): item is ANY_CONTRACT_PROCEDURE;
|
|
20
|
-
//# sourceMappingURL=procedure.d.ts.map
|
package/dist/src/route.d.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
export type HTTPPath = `/${string}`;
|
|
2
|
-
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
3
|
-
export type InputStructure = 'compact' | 'detailed';
|
|
4
|
-
export type OutputStructure = 'compact' | 'detailed';
|
|
5
|
-
export interface Route {
|
|
6
|
-
method?: HTTPMethod;
|
|
7
|
-
path?: HTTPPath;
|
|
8
|
-
summary?: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
deprecated?: boolean;
|
|
11
|
-
tags?: readonly string[];
|
|
12
|
-
/**
|
|
13
|
-
* The status code of the response when the procedure is successful.
|
|
14
|
-
*
|
|
15
|
-
* @default 200
|
|
16
|
-
*/
|
|
17
|
-
successStatus?: number;
|
|
18
|
-
/**
|
|
19
|
-
* The description of the response when the procedure is successful.
|
|
20
|
-
*
|
|
21
|
-
* @default 'OK'
|
|
22
|
-
*/
|
|
23
|
-
successDescription?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Determines how the input should be structured based on `params`, `query`, `headers`, and `body`.
|
|
26
|
-
*
|
|
27
|
-
* @option 'compact'
|
|
28
|
-
* Combines `params` and either `query` or `body` (depending on the HTTP method) into a single object.
|
|
29
|
-
*
|
|
30
|
-
* @option 'detailed'
|
|
31
|
-
* Keeps each part of the request (`params`, `query`, `headers`, and `body`) as separate fields in the input object.
|
|
32
|
-
*
|
|
33
|
-
* Example:
|
|
34
|
-
* ```ts
|
|
35
|
-
* const input = {
|
|
36
|
-
* params: { id: 1 },
|
|
37
|
-
* query: { search: 'hello' },
|
|
38
|
-
* headers: { 'Content-Type': 'application/json' },
|
|
39
|
-
* body: { name: 'John' },
|
|
40
|
-
* }
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* @default 'compact'
|
|
44
|
-
*/
|
|
45
|
-
inputStructure?: InputStructure;
|
|
46
|
-
/**
|
|
47
|
-
* Determines how the response should be structured based on the output.
|
|
48
|
-
*
|
|
49
|
-
* @option 'compact'
|
|
50
|
-
* Includes only the body data, encoded directly in the response.
|
|
51
|
-
*
|
|
52
|
-
* @option 'detailed'
|
|
53
|
-
* Separates the output into `headers` and `body` fields.
|
|
54
|
-
* - `headers`: Custom headers to merge with the response headers.
|
|
55
|
-
* - `body`: The response data.
|
|
56
|
-
*
|
|
57
|
-
* Example:
|
|
58
|
-
* ```ts
|
|
59
|
-
* const output = {
|
|
60
|
-
* headers: { 'x-custom-header': 'value' },
|
|
61
|
-
* body: { message: 'Hello, world!' },
|
|
62
|
-
* };
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* @default 'compact'
|
|
66
|
-
*/
|
|
67
|
-
outputStructure?: OutputStructure;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Since `undefined` has a specific meaning (it use default value),
|
|
71
|
-
* we ensure all additional properties in each item of the ErrorMap are explicitly set to `undefined`.
|
|
72
|
-
*/
|
|
73
|
-
export type StrictRoute<T extends Route> = T & Partial<Record<Exclude<keyof Route, keyof T>, undefined>>;
|
|
74
|
-
export type MergeRoute<A extends Route, B extends Route> = Omit<A, keyof B> & B;
|
|
75
|
-
export declare function mergeRoute<A extends Route, B extends Route>(a: A, b: B): MergeRoute<A, B>;
|
|
76
|
-
export type PrefixRoute<TRoute extends Route, TPrefix extends HTTPPath> = TRoute['path'] extends HTTPPath ? Omit<TRoute, 'path'> & {
|
|
77
|
-
path: TPrefix extends HTTPPath ? `${TPrefix}${TRoute['path']}` : TRoute['path'];
|
|
78
|
-
} : TRoute;
|
|
79
|
-
export declare function prefixRoute<TRoute extends Route, TPrefix extends HTTPPath>(route: TRoute, prefix: TPrefix): PrefixRoute<TRoute, TPrefix>;
|
|
80
|
-
export type UnshiftTagRoute<TRoute extends Route, TTags extends readonly string[]> = Omit<TRoute, 'tags'> & {
|
|
81
|
-
tags: TRoute['tags'] extends string[] ? [...TTags, ...TRoute['tags']] : TTags;
|
|
82
|
-
};
|
|
83
|
-
export declare function unshiftTagRoute<TRoute extends Route, TTags extends readonly string[]>(route: TRoute, tags: TTags): UnshiftTagRoute<TRoute, TTags>;
|
|
84
|
-
export type MergePrefix<A extends HTTPPath | undefined, B extends HTTPPath> = A extends HTTPPath ? `${A}${B}` : B;
|
|
85
|
-
export declare function mergePrefix<A extends HTTPPath | undefined, B extends HTTPPath>(a: A, b: B): MergePrefix<A, B>;
|
|
86
|
-
export type MergeTags<A extends readonly string[] | undefined, B extends readonly string[]> = A extends readonly string[] ? [...A, ...B] : B;
|
|
87
|
-
export declare function mergeTags<A extends readonly string[] | undefined, B extends readonly string[]>(a: A, b: B): MergeTags<A, B>;
|
|
88
|
-
//# sourceMappingURL=route.d.ts.map
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { ErrorMap, ErrorMapGuard, ErrorMapSuggestions, StrictErrorMap } from './error-map';
|
|
2
|
-
import type { ContractProcedure } from './procedure';
|
|
3
|
-
import type { ContractRouter } from './router';
|
|
4
|
-
import { DecoratedContractProcedure } from './procedure-decorated';
|
|
5
|
-
import { type HTTPPath, type MergePrefix, type MergeTags, type PrefixRoute, type Route, type UnshiftTagRoute } from './route';
|
|
6
|
-
export type AdaptRoute<TRoute extends Route, TPrefix extends HTTPPath | undefined, TTags extends readonly string[] | undefined> = TPrefix extends HTTPPath ? PrefixRoute<TTags extends readonly string[] ? UnshiftTagRoute<TRoute, TTags> : TRoute, TPrefix> : TTags extends readonly string[] ? UnshiftTagRoute<TRoute, TTags> : TRoute;
|
|
7
|
-
export type AdaptedContractRouter<TContract extends ContractRouter<any>, TErrorMapExtra extends ErrorMap, TPrefix extends HTTPPath | undefined, TTags extends readonly string[] | undefined> = {
|
|
8
|
-
[K in keyof TContract]: TContract[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrors, infer URoute> ? DecoratedContractProcedure<UInputSchema, UOutputSchema, UErrors & TErrorMapExtra, AdaptRoute<URoute, TPrefix, TTags>> : TContract[K] extends ContractRouter<any> ? AdaptedContractRouter<TContract[K], TErrorMapExtra, TPrefix, TTags> : never;
|
|
9
|
-
};
|
|
10
|
-
export interface ContractRouterBuilderDef<TErrorMap extends ErrorMap, TPrefix extends HTTPPath | undefined, TTags extends readonly string[] | undefined> {
|
|
11
|
-
errorMap: TErrorMap;
|
|
12
|
-
prefix: TPrefix;
|
|
13
|
-
tags: TTags;
|
|
14
|
-
}
|
|
15
|
-
export declare class ContractRouterBuilder<TErrorMap extends ErrorMap, TPrefix extends HTTPPath | undefined, TTags extends readonly string[] | undefined> {
|
|
16
|
-
'~type': "ContractProcedure";
|
|
17
|
-
'~orpc': ContractRouterBuilderDef<TErrorMap, TPrefix, TTags>;
|
|
18
|
-
constructor(def: ContractRouterBuilderDef<TErrorMap, TPrefix, TTags>);
|
|
19
|
-
prefix<U extends HTTPPath>(prefix: U): ContractRouterBuilder<TErrorMap, MergePrefix<TPrefix, U>, TTags>;
|
|
20
|
-
tag<U extends string[]>(...tags: U): ContractRouterBuilder<TErrorMap, TPrefix, MergeTags<TTags, U>>;
|
|
21
|
-
errors<const U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): ContractRouterBuilder<StrictErrorMap<U> & TErrorMap, TPrefix, TTags>;
|
|
22
|
-
router<T extends ContractRouter<ErrorMap & Partial<TErrorMap>>>(router: T): AdaptedContractRouter<T, TErrorMap, TPrefix, TTags>;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=router-builder.d.ts.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ContractProcedure } from './procedure';
|
|
2
|
-
import type { ContractProcedureClient } from './procedure-client';
|
|
3
|
-
import type { ContractRouter } from './router';
|
|
4
|
-
export type ContractRouterClient<TRouter extends ContractRouter<any>, TClientContext> = TRouter extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ContractProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
|
|
5
|
-
[K in keyof TRouter]: TRouter[K] extends ContractRouter<any> ? ContractRouterClient<TRouter[K], TClientContext> : never;
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=router-client.d.ts.map
|
package/dist/src/router.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ErrorMap } from './error-map';
|
|
2
|
-
import type { ContractProcedure } from './procedure';
|
|
3
|
-
import type { SchemaInput, SchemaOutput } from './types';
|
|
4
|
-
export type ContractRouter<T extends ErrorMap> = ContractProcedure<any, any, T, any> | {
|
|
5
|
-
[k: string]: ContractRouter<T>;
|
|
6
|
-
};
|
|
7
|
-
export type InferContractRouterInputs<T extends ContractRouter<any>> = T extends ContractProcedure<infer UInputSchema, any, any, any> ? SchemaInput<UInputSchema> : {
|
|
8
|
-
[K in keyof T]: T[K] extends ContractRouter<any> ? InferContractRouterInputs<T[K]> : never;
|
|
9
|
-
};
|
|
10
|
-
export type InferContractRouterOutputs<T extends ContractRouter<any>> = T extends ContractProcedure<any, infer UOutputSchema, any, any> ? SchemaOutput<UOutputSchema> : {
|
|
11
|
-
[K in keyof T]: T[K] extends ContractRouter<any> ? InferContractRouterOutputs<T[K]> : never;
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=router.d.ts.map
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { IsEqual, Promisable } from '@orpc/shared';
|
|
2
|
-
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
-
export type TypeRest<TInput, TOutput> = [map: (input: TInput) => Promisable<TOutput>] | (IsEqual<TInput, TOutput> extends true ? [] : never);
|
|
4
|
-
export declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutput>): StandardSchemaV1<TInput, TOutput>;
|
|
5
|
-
//# sourceMappingURL=schema-utils.d.ts.map
|
package/dist/src/types.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { FindGlobalInstanceType } from '@orpc/shared';
|
|
2
|
-
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
-
export type Schema = StandardSchemaV1 | undefined;
|
|
4
|
-
export type SchemaInput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<TSchema> : TFallback;
|
|
5
|
-
export type SchemaOutput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : TFallback;
|
|
6
|
-
export type AbortSignal = FindGlobalInstanceType<'AbortSignal'>;
|
|
7
|
-
//# sourceMappingURL=types.d.ts.map
|