@orpc/contract 0.0.0-next.b15d206 → 0.0.0-next.b2d00a3

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.
Files changed (45) hide show
  1. package/README.md +114 -0
  2. package/dist/index.d.mts +313 -0
  3. package/dist/index.d.ts +313 -0
  4. package/dist/index.mjs +337 -0
  5. package/dist/plugins/index.d.mts +43 -0
  6. package/dist/plugins/index.d.ts +43 -0
  7. package/dist/plugins/index.mjs +81 -0
  8. package/dist/shared/contract.D_dZrO__.mjs +53 -0
  9. package/dist/shared/contract.TuRtB1Ca.d.mts +254 -0
  10. package/dist/shared/contract.TuRtB1Ca.d.ts +254 -0
  11. package/package.json +21 -20
  12. package/dist/index.js +0 -176
  13. package/dist/index.js.map +0 -1
  14. package/dist/src/builder.d.ts +0 -13
  15. package/dist/src/builder.d.ts.map +0 -1
  16. package/dist/src/constants.d.ts +0 -3
  17. package/dist/src/constants.d.ts.map +0 -1
  18. package/dist/src/index.d.ts +0 -10
  19. package/dist/src/index.d.ts.map +0 -1
  20. package/dist/src/procedure.d.ts +0 -46
  21. package/dist/src/procedure.d.ts.map +0 -1
  22. package/dist/src/router-builder.d.ts +0 -16
  23. package/dist/src/router-builder.d.ts.map +0 -1
  24. package/dist/src/router.d.ts +0 -16
  25. package/dist/src/router.d.ts.map +0 -1
  26. package/dist/src/types.d.ts +0 -8
  27. package/dist/src/types.d.ts.map +0 -1
  28. package/dist/src/utils.d.ts +0 -4
  29. package/dist/src/utils.d.ts.map +0 -1
  30. package/dist/tsconfig.tsbuildinfo +0 -1
  31. package/src/builder.test.ts +0 -179
  32. package/src/builder.ts +0 -52
  33. package/src/constants.ts +0 -2
  34. package/src/index.ts +0 -12
  35. package/src/procedure.test.ts +0 -99
  36. package/src/procedure.ts +0 -125
  37. package/src/router-builder.test.ts +0 -70
  38. package/src/router-builder.ts +0 -46
  39. package/src/router.test-d.ts +0 -63
  40. package/src/router.test.ts +0 -24
  41. package/src/router.ts +0 -55
  42. package/src/types.test-d.ts +0 -16
  43. package/src/types.ts +0 -25
  44. package/src/utils.test.ts +0 -18
  45. package/src/utils.ts +0 -17
@@ -0,0 +1,254 @@
1
+ import { ORPCErrorCode, ORPCError, HTTPMethod, HTTPPath } from '@orpc/client';
2
+ import { Promisable, IsEqual, ThrowableError } from '@orpc/shared';
3
+ import { StandardSchemaV1 } from '@standard-schema/spec';
4
+ import { OpenAPIV3_1 } from 'openapi-types';
5
+
6
+ type Schema<TInput, TOutput> = StandardSchemaV1<TInput, TOutput>;
7
+ type AnySchema = Schema<any, any>;
8
+ type SchemaIssue = StandardSchemaV1.Issue;
9
+ type InferSchemaInput<T extends AnySchema> = T extends StandardSchemaV1<infer UInput, any> ? UInput : never;
10
+ type InferSchemaOutput<T extends AnySchema> = T extends StandardSchemaV1<any, infer UOutput> ? UOutput : never;
11
+ type TypeRest<TInput, TOutput> = [map: (input: TInput) => Promisable<TOutput>] | (IsEqual<TInput, TOutput> extends true ? [] : never);
12
+ /**
13
+ * The schema for things can be trust without validation.
14
+ * If the TInput and TOutput are different, you need pass a map function.
15
+ *
16
+ * @see {@link https://orpc.dev/docs/procedure#type-utility Type Utility Docs}
17
+ */
18
+ declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutput>): Schema<TInput, TOutput>;
19
+
20
+ interface ValidationErrorOptions extends ErrorOptions {
21
+ message: string;
22
+ issues: readonly SchemaIssue[];
23
+ /**
24
+ * @todo require this field in v2
25
+ */
26
+ data?: unknown;
27
+ }
28
+ /**
29
+ * This errors usually used for ORPCError.cause when the error is a validation error.
30
+ *
31
+ * @see {@link https://orpc.dev/docs/advanced/validation-errors Validation Errors Docs}
32
+ */
33
+ declare class ValidationError extends Error {
34
+ readonly issues: readonly SchemaIssue[];
35
+ readonly data: unknown;
36
+ constructor(options: ValidationErrorOptions);
37
+ }
38
+ interface ErrorMapItem<TDataSchema extends AnySchema> {
39
+ status?: number;
40
+ message?: string;
41
+ data?: TDataSchema;
42
+ }
43
+ type ErrorMap = {
44
+ [key in ORPCErrorCode]?: ErrorMapItem<AnySchema>;
45
+ };
46
+ type MergedErrorMap<T1 extends ErrorMap, T2 extends ErrorMap> = Omit<T1, keyof T2> & T2;
47
+ declare function mergeErrorMap<T1 extends ErrorMap, T2 extends ErrorMap>(errorMap1: T1, errorMap2: T2): MergedErrorMap<T1, T2>;
48
+ type ORPCErrorFromErrorMap<TErrorMap extends ErrorMap> = {
49
+ [K in keyof TErrorMap]: K extends string ? TErrorMap[K] extends ErrorMapItem<infer TDataSchema extends Schema<unknown, unknown>> ? ORPCError<K, InferSchemaOutput<TDataSchema>> : never : never;
50
+ }[keyof TErrorMap];
51
+ type ErrorFromErrorMap<TErrorMap extends ErrorMap> = ORPCErrorFromErrorMap<TErrorMap> | ThrowableError;
52
+ declare function validateORPCError(map: ErrorMap, error: ORPCError<any, any>): Promise<ORPCError<string, unknown>>;
53
+
54
+ type Meta = Record<string, any>;
55
+ declare function mergeMeta<T extends Meta>(meta1: T, meta2: T): T;
56
+
57
+ type InputStructure = 'compact' | 'detailed';
58
+ type OutputStructure = 'compact' | 'detailed';
59
+ interface Route {
60
+ /**
61
+ * The HTTP method of the procedure.
62
+ * This option is typically relevant when integrating with OpenAPI.
63
+ *
64
+ * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
65
+ */
66
+ method?: HTTPMethod;
67
+ /**
68
+ * The HTTP path of the procedure.
69
+ * This option is typically relevant when integrating with OpenAPI.
70
+ *
71
+ * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
72
+ */
73
+ path?: HTTPPath;
74
+ /**
75
+ * The operation ID of the endpoint.
76
+ * This option is typically relevant when integrating with OpenAPI.
77
+ *
78
+ * @default Concatenation of router segments
79
+ */
80
+ operationId?: string;
81
+ /**
82
+ * The summary of the procedure.
83
+ * This option is typically relevant when integrating with OpenAPI.
84
+ *
85
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
86
+ */
87
+ summary?: string;
88
+ /**
89
+ * The description of the procedure.
90
+ * This option is typically relevant when integrating with OpenAPI.
91
+ *
92
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
93
+ */
94
+ description?: string;
95
+ /**
96
+ * Marks the procedure as deprecated.
97
+ * This option is typically relevant when integrating with OpenAPI.
98
+ *
99
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
100
+ */
101
+ deprecated?: boolean;
102
+ /**
103
+ * The tags of the procedure.
104
+ * This option is typically relevant when integrating with OpenAPI.
105
+ *
106
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
107
+ */
108
+ tags?: readonly string[];
109
+ /**
110
+ * The status code of the response when the procedure is successful.
111
+ * The status code must be in the 200-399 range.
112
+ * This option is typically relevant when integrating with OpenAPI.
113
+ *
114
+ * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
115
+ * @default 200
116
+ */
117
+ successStatus?: number;
118
+ /**
119
+ * The description of the response when the procedure is successful.
120
+ * This option is typically relevant when integrating with OpenAPI.
121
+ *
122
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
123
+ * @default 'OK'
124
+ */
125
+ successDescription?: string;
126
+ /**
127
+ * Determines how the input should be structured based on `params`, `query`, `headers`, and `body`.
128
+ *
129
+ * @option 'compact'
130
+ * Combines `params` and either `query` or `body` (depending on the HTTP method) into a single object.
131
+ *
132
+ * @option 'detailed'
133
+ * Keeps each part of the request (`params`, `query`, `headers`, and `body`) as separate fields in the input object.
134
+ *
135
+ * Example:
136
+ * ```ts
137
+ * const input = {
138
+ * params: { id: 1 },
139
+ * query: { search: 'hello' },
140
+ * headers: { 'Content-Type': 'application/json' },
141
+ * body: { name: 'John' },
142
+ * }
143
+ * ```
144
+ *
145
+ * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
146
+ * @default 'compact'
147
+ */
148
+ inputStructure?: InputStructure;
149
+ /**
150
+ * Determines how the response should be structured based on the output.
151
+ *
152
+ * @option 'compact'
153
+ * The output data is directly returned as the response body.
154
+ *
155
+ * @option 'detailed'
156
+ * Return an object with optional properties:
157
+ * - `status`: The response status (must be in 200-399 range) if not set fallback to `successStatus`.
158
+ * - `headers`: Custom headers to merge with the response headers (`Record<string, string | string[] | undefined>`)
159
+ * - `body`: The response body.
160
+ *
161
+ * Example:
162
+ * ```ts
163
+ * const output = {
164
+ * status: 201,
165
+ * headers: { 'x-custom-header': 'value' },
166
+ * body: { message: 'Hello, world!' },
167
+ * };
168
+ * ```
169
+ *
170
+ * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
171
+ * @default 'compact'
172
+ */
173
+ outputStructure?: OutputStructure;
174
+ /**
175
+ * Override entire auto-generated OpenAPI Operation Object Specification.
176
+ *
177
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata Operation Metadata Docs}
178
+ */
179
+ spec?: OpenAPIV3_1.OperationObject | ((current: OpenAPIV3_1.OperationObject) => OpenAPIV3_1.OperationObject);
180
+ }
181
+ declare function mergeRoute(a: Route, b: Route): Route;
182
+ declare function prefixRoute(route: Route, prefix: HTTPPath): Route;
183
+ declare function unshiftTagRoute(route: Route, tags: readonly string[]): Route;
184
+ declare function mergePrefix(a: HTTPPath | undefined, b: HTTPPath): HTTPPath;
185
+ declare function mergeTags(a: readonly string[] | undefined, b: readonly string[]): readonly string[];
186
+ interface EnhanceRouteOptions {
187
+ prefix?: HTTPPath;
188
+ tags?: readonly string[];
189
+ }
190
+ declare function enhanceRoute(route: Route, options: EnhanceRouteOptions): Route;
191
+
192
+ interface ContractProcedureDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
193
+ meta: TMeta;
194
+ route: Route;
195
+ inputSchema?: TInputSchema;
196
+ outputSchema?: TOutputSchema;
197
+ errorMap: TErrorMap;
198
+ }
199
+ /**
200
+ * This class represents a contract procedure.
201
+ *
202
+ * @see {@link https://orpc.dev/docs/contract-first/define-contract#procedure-contract Contract Procedure Docs}
203
+ */
204
+ declare class ContractProcedure<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
205
+ /**
206
+ * This property holds the defined options for the contract procedure.
207
+ */
208
+ '~orpc': ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
209
+ constructor(def: ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
210
+ }
211
+ type AnyContractProcedure = ContractProcedure<any, any, any, any>;
212
+ declare function isContractProcedure(item: unknown): item is AnyContractProcedure;
213
+
214
+ /**
215
+ * Represents a contract router, which defines a hierarchical structure of contract procedures.
216
+ *
217
+ * @info A contract procedure is a contract router too.
218
+ * @see {@link https://orpc.dev/docs/contract-first/define-contract#contract-router Contract Router Docs}
219
+ */
220
+ type ContractRouter<TMeta extends Meta> = ContractProcedure<any, any, any, TMeta> | {
221
+ [k: string]: ContractRouter<TMeta>;
222
+ };
223
+ type AnyContractRouter = ContractRouter<any>;
224
+ /**
225
+ * Infer all inputs of the contract router.
226
+ *
227
+ * @info A contract procedure is a contract router too.
228
+ * @see {@link https://orpc.dev/docs/contract-first/define-contract#utilities Contract Utilities Docs}
229
+ */
230
+ type InferContractRouterInputs<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
231
+ [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterInputs<T[K]> : never;
232
+ };
233
+ /**
234
+ * Infer all outputs of the contract router.
235
+ *
236
+ * @info A contract procedure is a contract router too.
237
+ * @see {@link https://orpc.dev/docs/contract-first/define-contract#utilities Contract Utilities Docs}
238
+ */
239
+ type InferContractRouterOutputs<T extends AnyContractRouter> = T extends ContractProcedure<any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
240
+ [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterOutputs<T[K]> : never;
241
+ };
242
+ /**
243
+ * Infer all errors of the contract router.
244
+ *
245
+ * @info A contract procedure is a contract router too.
246
+ * @see {@link https://orpc.dev/docs/contract-first/define-contract#utilities Contract Utilities Docs}
247
+ */
248
+ type InferContractRouterErrorMap<T extends AnyContractRouter> = T extends ContractProcedure<any, any, infer UErrorMap, any> ? UErrorMap : {
249
+ [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterErrorMap<T[K]> : never;
250
+ }[keyof T];
251
+ type InferContractRouterMeta<T extends AnyContractRouter> = T extends ContractRouter<infer UMeta> ? UMeta : never;
252
+
253
+ export { ContractProcedure as C, type as D, ValidationError as j, mergeErrorMap as m, mergeMeta as n, isContractProcedure as p, mergeRoute as q, prefixRoute as r, mergePrefix as s, mergeTags as t, unshiftTagRoute as u, validateORPCError as v, enhanceRoute as w };
254
+ export type { AnyContractRouter as A, InferContractRouterMeta as B, ErrorMap as E, InputStructure as I, MergedErrorMap as M, OutputStructure as O, Route as R, Schema as S, TypeRest as T, ValidationErrorOptions as V, EnhanceRouteOptions as a, AnySchema as b, Meta as c, ContractRouter as d, ContractProcedureDef as e, InferSchemaInput as f, InferSchemaOutput as g, ErrorFromErrorMap as h, SchemaIssue as i, ErrorMapItem as k, ORPCErrorFromErrorMap as l, AnyContractProcedure as o, InferContractRouterInputs as x, InferContractRouterOutputs as y, InferContractRouterErrorMap as z };
package/package.json CHANGED
@@ -1,17 +1,12 @@
1
1
  {
2
2
  "name": "@orpc/contract",
3
3
  "type": "module",
4
- "version": "0.0.0-next.b15d206",
5
- "author": {
6
- "name": "unnoq",
7
- "email": "contact@unnoq.com",
8
- "url": "https://unnoq.com"
9
- },
4
+ "version": "0.0.0-next.b2d00a3",
10
5
  "license": "MIT",
11
- "homepage": "https://github.com/unnoq/orpc",
6
+ "homepage": "https://orpc.dev",
12
7
  "repository": {
13
8
  "type": "git",
14
- "url": "https://github.com/unnoq/orpc.git",
9
+ "url": "git+https://github.com/unnoq/orpc.git",
15
10
  "directory": "packages/contract"
16
11
  },
17
12
  "keywords": [
@@ -20,26 +15,32 @@
20
15
  ],
21
16
  "exports": {
22
17
  ".": {
23
- "types": "./dist/src/index.d.ts",
24
- "import": "./dist/index.js",
25
- "default": "./dist/index.js"
18
+ "types": "./dist/index.d.mts",
19
+ "import": "./dist/index.mjs",
20
+ "default": "./dist/index.mjs"
26
21
  },
27
- "./🔒/*": {
28
- "types": "./dist/src/*.d.ts"
22
+ "./plugins": {
23
+ "types": "./dist/plugins/index.d.mts",
24
+ "import": "./dist/plugins/index.mjs",
25
+ "default": "./dist/plugins/index.mjs"
29
26
  }
30
27
  },
31
28
  "files": [
32
- "dist",
33
- "src"
29
+ "dist"
34
30
  ],
35
- "peerDependencies": {
36
- "zod": ">=3.23.0"
37
- },
38
31
  "dependencies": {
39
- "@orpc/shared": "0.0.0-next.b15d206"
32
+ "@standard-schema/spec": "^1.0.0",
33
+ "openapi-types": "^12.1.3",
34
+ "@orpc/client": "0.0.0-next.b2d00a3",
35
+ "@orpc/shared": "0.0.0-next.b2d00a3"
36
+ },
37
+ "devDependencies": {
38
+ "arktype": "2.1.27",
39
+ "valibot": "^1.2.0",
40
+ "zod": "^4.1.12"
40
41
  },
41
42
  "scripts": {
42
- "build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
43
+ "build": "unbuild",
43
44
  "build:watch": "pnpm run build --watch",
44
45
  "type:check": "tsc -b"
45
46
  }
package/dist/index.js DELETED
@@ -1,176 +0,0 @@
1
- // src/procedure.ts
2
- var ContractProcedure = class {
3
- constructor(zz$cp) {
4
- this.zz$cp = zz$cp;
5
- }
6
- };
7
- var DecoratedContractProcedure = class _DecoratedContractProcedure extends ContractProcedure {
8
- static decorate(cp) {
9
- if (cp instanceof _DecoratedContractProcedure)
10
- return cp;
11
- return new _DecoratedContractProcedure(cp.zz$cp);
12
- }
13
- route(opts) {
14
- return new _DecoratedContractProcedure({
15
- ...this.zz$cp,
16
- ...opts,
17
- method: opts.method,
18
- path: opts.path
19
- });
20
- }
21
- prefix(prefix) {
22
- if (!this.zz$cp.path)
23
- return this;
24
- return new _DecoratedContractProcedure({
25
- ...this.zz$cp,
26
- path: `${prefix}${this.zz$cp.path}`
27
- });
28
- }
29
- addTags(...tags) {
30
- if (!tags.length)
31
- return this;
32
- return new _DecoratedContractProcedure({
33
- ...this.zz$cp,
34
- tags: [...this.zz$cp.tags ?? [], ...tags]
35
- });
36
- }
37
- input(schema, example) {
38
- return new _DecoratedContractProcedure({
39
- ...this.zz$cp,
40
- InputSchema: schema,
41
- inputExample: example
42
- });
43
- }
44
- output(schema, example) {
45
- return new _DecoratedContractProcedure({
46
- ...this.zz$cp,
47
- OutputSchema: schema,
48
- outputExample: example
49
- });
50
- }
51
- };
52
- function isContractProcedure(item) {
53
- if (item instanceof ContractProcedure)
54
- return true;
55
- return (typeof item === "object" || typeof item === "function") && item !== null && "zz$cp" in item && typeof item.zz$cp === "object" && item.zz$cp !== null && "InputSchema" in item.zz$cp && "OutputSchema" in item.zz$cp;
56
- }
57
-
58
- // src/router-builder.ts
59
- var ContractRouterBuilder = class _ContractRouterBuilder {
60
- constructor(zz$crb) {
61
- this.zz$crb = zz$crb;
62
- }
63
- prefix(prefix) {
64
- return new _ContractRouterBuilder({
65
- ...this.zz$crb,
66
- prefix: `${this.zz$crb.prefix ?? ""}${prefix}`
67
- });
68
- }
69
- tags(...tags) {
70
- if (!tags.length)
71
- return this;
72
- return new _ContractRouterBuilder({
73
- ...this.zz$crb,
74
- tags: [...this.zz$crb.tags ?? [], ...tags]
75
- });
76
- }
77
- router(router) {
78
- const handled = {};
79
- for (const key in router) {
80
- const item = router[key];
81
- if (isContractProcedure(item)) {
82
- const decorated = DecoratedContractProcedure.decorate(item).addTags(
83
- ...this.zz$crb.tags ?? []
84
- );
85
- handled[key] = this.zz$crb.prefix ? decorated.prefix(this.zz$crb.prefix) : decorated;
86
- } else {
87
- handled[key] = this.router(item);
88
- }
89
- }
90
- return handled;
91
- }
92
- };
93
-
94
- // src/builder.ts
95
- var ContractBuilder = class {
96
- prefix(prefix) {
97
- return new ContractRouterBuilder({
98
- prefix
99
- });
100
- }
101
- tags(...tags) {
102
- return new ContractRouterBuilder({
103
- tags
104
- });
105
- }
106
- route(opts) {
107
- return new DecoratedContractProcedure({
108
- InputSchema: void 0,
109
- OutputSchema: void 0,
110
- ...opts
111
- });
112
- }
113
- input(schema, example) {
114
- return new DecoratedContractProcedure({
115
- InputSchema: schema,
116
- inputExample: example,
117
- OutputSchema: void 0
118
- });
119
- }
120
- output(schema, example) {
121
- return new DecoratedContractProcedure({
122
- InputSchema: void 0,
123
- OutputSchema: schema,
124
- outputExample: example
125
- });
126
- }
127
- router(router) {
128
- return router;
129
- }
130
- };
131
-
132
- // src/constants.ts
133
- var ORPC_HEADER = "x-orpc-transformer";
134
- var ORPC_HEADER_VALUE = "t";
135
-
136
- // src/router.ts
137
- function eachContractRouterLeaf(router, callback, prefix = []) {
138
- for (const key in router) {
139
- const item = router[key];
140
- if (isContractProcedure(item)) {
141
- callback(item, [...prefix, key]);
142
- } else {
143
- eachContractRouterLeaf(item, callback, [...prefix, key]);
144
- }
145
- }
146
- }
147
-
148
- // src/utils.ts
149
- function standardizeHTTPPath(path) {
150
- return `/${path.replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "")}`;
151
- }
152
- function prefixHTTPPath(prefix, path) {
153
- const prefix_ = standardizeHTTPPath(prefix);
154
- const path_ = standardizeHTTPPath(path);
155
- if (prefix_ === "/")
156
- return path_;
157
- if (path_ === "/")
158
- return prefix_;
159
- return `${prefix_}${path_}`;
160
- }
161
-
162
- // src/index.ts
163
- var oc = new ContractBuilder();
164
- export {
165
- ContractBuilder,
166
- ContractProcedure,
167
- DecoratedContractProcedure,
168
- ORPC_HEADER,
169
- ORPC_HEADER_VALUE,
170
- eachContractRouterLeaf,
171
- isContractProcedure,
172
- oc,
173
- prefixHTTPPath,
174
- standardizeHTTPPath
175
- };
176
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/procedure.ts","../src/router-builder.ts","../src/builder.ts","../src/constants.ts","../src/router.ts","../src/utils.ts","../src/index.ts"],"sourcesContent":["import type {\n HTTPMethod,\n HTTPPath,\n Schema,\n SchemaInput,\n SchemaOutput,\n} from './types'\n\nexport interface RouteOptions {\n method?: HTTPMethod\n path?: HTTPPath\n summary?: string\n description?: string\n deprecated?: boolean\n tags?: string[]\n}\n\nexport class ContractProcedure<\n TInputSchema extends Schema,\n TOutputSchema extends Schema,\n> {\n constructor(\n public zz$cp: {\n path?: HTTPPath\n method?: HTTPMethod\n summary?: string\n description?: string\n deprecated?: boolean\n tags?: string[]\n InputSchema: TInputSchema\n inputExample?: SchemaOutput<TInputSchema>\n OutputSchema: TOutputSchema\n outputExample?: SchemaOutput<TOutputSchema>\n },\n ) {}\n}\n\nexport class DecoratedContractProcedure<\n TInputSchema extends Schema,\n TOutputSchema extends Schema,\n> extends ContractProcedure<TInputSchema, TOutputSchema> {\n static decorate<TInputSchema extends Schema, TOutputSchema extends Schema>(\n cp: ContractProcedure<TInputSchema, TOutputSchema>,\n ): DecoratedContractProcedure<TInputSchema, TOutputSchema> {\n if (cp instanceof DecoratedContractProcedure)\n return cp\n return new DecoratedContractProcedure(cp.zz$cp)\n }\n\n route(\n opts: RouteOptions,\n ): DecoratedContractProcedure<TInputSchema, TOutputSchema> {\n return new DecoratedContractProcedure({\n ...this.zz$cp,\n ...opts,\n method: opts.method,\n path: opts.path,\n })\n }\n\n prefix(\n prefix: HTTPPath,\n ): DecoratedContractProcedure<TInputSchema, TOutputSchema> {\n if (!this.zz$cp.path)\n return this\n\n return new DecoratedContractProcedure({\n ...this.zz$cp,\n path: `${prefix}${this.zz$cp.path}`,\n })\n }\n\n addTags(\n ...tags: string[]\n ): DecoratedContractProcedure<TInputSchema, TOutputSchema> {\n if (!tags.length)\n return this\n\n return new DecoratedContractProcedure({\n ...this.zz$cp,\n tags: [...(this.zz$cp.tags ?? []), ...tags],\n })\n }\n\n input<USchema extends Schema>(\n schema: USchema,\n example?: SchemaInput<USchema>,\n ): DecoratedContractProcedure<USchema, TOutputSchema> {\n return new DecoratedContractProcedure({\n ...this.zz$cp,\n InputSchema: schema,\n inputExample: example,\n })\n }\n\n output<USchema extends Schema>(\n schema: USchema,\n example?: SchemaOutput<USchema>,\n ): DecoratedContractProcedure<TInputSchema, USchema> {\n return new DecoratedContractProcedure({\n ...this.zz$cp,\n OutputSchema: schema,\n outputExample: example,\n })\n }\n}\n\nexport type WELL_DEFINED_CONTRACT_PROCEDURE = ContractProcedure<Schema, Schema>\n\nexport function isContractProcedure(\n item: unknown,\n): item is WELL_DEFINED_CONTRACT_PROCEDURE {\n if (item instanceof ContractProcedure)\n return true\n\n return (\n (typeof item === 'object' || typeof item === 'function')\n && item !== null\n && 'zz$cp' in item\n && typeof item.zz$cp === 'object'\n && item.zz$cp !== null\n && 'InputSchema' in item.zz$cp\n && 'OutputSchema' in item.zz$cp\n )\n}\n","import type { ContractRouter, HandledContractRouter } from './router'\nimport type { HTTPPath } from './types'\nimport { DecoratedContractProcedure, isContractProcedure } from './procedure'\n\nexport class ContractRouterBuilder {\n constructor(public zz$crb: { prefix?: HTTPPath, tags?: string[] }) {}\n\n prefix(prefix: HTTPPath): ContractRouterBuilder {\n return new ContractRouterBuilder({\n ...this.zz$crb,\n prefix: `${this.zz$crb.prefix ?? ''}${prefix}`,\n })\n }\n\n tags(...tags: string[]): ContractRouterBuilder {\n if (!tags.length)\n return this\n\n return new ContractRouterBuilder({\n ...this.zz$crb,\n tags: [...(this.zz$crb.tags ?? []), ...tags],\n })\n }\n\n router<T extends ContractRouter>(router: T): HandledContractRouter<T> {\n const handled: ContractRouter = {}\n\n for (const key in router) {\n const item = router[key]\n if (isContractProcedure(item)) {\n const decorated = DecoratedContractProcedure.decorate(item).addTags(\n ...(this.zz$crb.tags ?? []),\n )\n\n handled[key] = this.zz$crb.prefix\n ? decorated.prefix(this.zz$crb.prefix)\n : decorated\n }\n else {\n handled[key] = this.router(item as ContractRouter)\n }\n }\n\n return handled as HandledContractRouter<T>\n }\n}\n","import type { ContractRouter } from './router'\nimport type { HTTPPath, Schema, SchemaInput, SchemaOutput } from './types'\nimport { DecoratedContractProcedure, type RouteOptions } from './procedure'\nimport { ContractRouterBuilder } from './router-builder'\n\nexport class ContractBuilder {\n prefix(prefix: HTTPPath): ContractRouterBuilder {\n return new ContractRouterBuilder({\n prefix,\n })\n }\n\n tags(...tags: string[]): ContractRouterBuilder {\n return new ContractRouterBuilder({\n tags,\n })\n }\n\n route(opts: RouteOptions): DecoratedContractProcedure<undefined, undefined> {\n return new DecoratedContractProcedure({\n InputSchema: undefined,\n OutputSchema: undefined,\n ...opts,\n })\n }\n\n input<USchema extends Schema>(\n schema: USchema,\n example?: SchemaInput<USchema>,\n ): DecoratedContractProcedure<USchema, undefined> {\n return new DecoratedContractProcedure({\n InputSchema: schema,\n inputExample: example,\n OutputSchema: undefined,\n })\n }\n\n output<USchema extends Schema>(\n schema: USchema,\n example?: SchemaOutput<USchema>,\n ): DecoratedContractProcedure<undefined, USchema> {\n return new DecoratedContractProcedure({\n InputSchema: undefined,\n OutputSchema: schema,\n outputExample: example,\n })\n }\n\n router<T extends ContractRouter>(router: T): T {\n return router\n }\n}\n","export const ORPC_HEADER = 'x-orpc-transformer'\nexport const ORPC_HEADER_VALUE = 't'\n","import type { SchemaInput, SchemaOutput } from './types'\nimport {\n type ContractProcedure,\n type DecoratedContractProcedure,\n isContractProcedure,\n type WELL_DEFINED_CONTRACT_PROCEDURE,\n} from './procedure'\n\nexport interface ContractRouter {\n [k: string]: ContractProcedure<any, any> | ContractRouter\n}\n\nexport type HandledContractRouter<TContract extends ContractRouter> = {\n [K in keyof TContract]: TContract[K] extends ContractProcedure<\n infer UInputSchema,\n infer UOutputSchema\n >\n ? DecoratedContractProcedure<UInputSchema, UOutputSchema>\n : TContract[K] extends ContractRouter\n ? HandledContractRouter<TContract[K]>\n : never\n}\n\nexport function eachContractRouterLeaf(\n router: ContractRouter,\n callback: (item: WELL_DEFINED_CONTRACT_PROCEDURE, path: string[]) => void,\n prefix: string[] = [],\n) {\n for (const key in router) {\n const item = router[key]\n\n if (isContractProcedure(item)) {\n callback(item, [...prefix, key])\n }\n else {\n eachContractRouterLeaf(item as ContractRouter, callback, [...prefix, key])\n }\n }\n}\n\nexport type InferContractRouterInputs<T extends ContractRouter> = {\n [K in keyof T]: T[K] extends ContractProcedure<infer UInputSchema, any>\n ? SchemaInput<UInputSchema>\n : T[K] extends ContractRouter\n ? InferContractRouterInputs<T[K]>\n : never\n}\n\nexport type InferContractRouterOutputs<T extends ContractRouter> = {\n [K in keyof T]: T[K] extends ContractProcedure<any, infer UOutputSchema>\n ? SchemaOutput<UOutputSchema>\n : T[K] extends ContractRouter\n ? InferContractRouterOutputs<T[K]>\n : never\n}\n","import type { HTTPPath } from './types'\n\nexport function standardizeHTTPPath(path: HTTPPath): HTTPPath {\n return `/${path.replace(/\\/{2,}/g, '/').replace(/^\\/|\\/$/g, '')}`\n}\n\nexport function prefixHTTPPath(prefix: HTTPPath, path: HTTPPath): HTTPPath {\n const prefix_ = standardizeHTTPPath(prefix)\n const path_ = standardizeHTTPPath(path)\n\n if (prefix_ === '/')\n return path_\n if (path_ === '/')\n return prefix_\n\n return `${prefix_}${path_}`\n}\n","/** unnoq */\n\nimport { ContractBuilder } from './builder'\n\nexport * from './builder'\nexport * from './constants'\nexport * from './procedure'\nexport * from './router'\nexport * from './types'\nexport * from './utils'\n\nexport const oc = new ContractBuilder()\n"],"mappings":";AAiBO,IAAM,oBAAN,MAGL;AAAA,EACA,YACS,OAYP;AAZO;AAAA,EAYN;AACL;AAEO,IAAM,6BAAN,MAAM,oCAGH,kBAA+C;AAAA,EACv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,2BAA2B;AAAA,MACpC,aAAa;AAAA,MACb,cAAc;AAAA,MACd,cAAc;AAAA,IAChB,CAAC;AAAA,EACH;AAAA,EAEA,OACE,QACA,SACgD;AAChD,WAAO,IAAI,2BAA2B;AAAA,MACpC,aAAa;AAAA,MACb,cAAc;AAAA,MACd,eAAe;AAAA,IACjB,CAAC;AAAA,EACH;AAAA,EAEA,OAAiC,QAAc;AAC7C,WAAO;AAAA,EACT;AACF;;;ACnDO,IAAM,cAAc;AACpB,IAAM,oBAAoB;;;ACsB1B,SAAS,uBACd,QACA,UACA,SAAmB,CAAC,GACpB;AACA,aAAW,OAAO,QAAQ;AACxB,UAAM,OAAO,OAAO,GAAG;AAEvB,QAAI,oBAAoB,IAAI,GAAG;AAC7B,eAAS,MAAM,CAAC,GAAG,QAAQ,GAAG,CAAC;AAAA,IACjC,OACK;AACH,6BAAuB,MAAwB,UAAU,CAAC,GAAG,QAAQ,GAAG,CAAC;AAAA,IAC3E;AAAA,EACF;AACF;;;ACpCO,SAAS,oBAAoB,MAA0B;AAC5D,SAAO,IAAI,KAAK,QAAQ,WAAW,GAAG,EAAE,QAAQ,YAAY,EAAE,CAAC;AACjE;AAEO,SAAS,eAAe,QAAkB,MAA0B;AACzE,QAAM,UAAU,oBAAoB,MAAM;AAC1C,QAAM,QAAQ,oBAAoB,IAAI;AAEtC,MAAI,YAAY;AACd,WAAO;AACT,MAAI,UAAU;AACZ,WAAO;AAET,SAAO,GAAG,OAAO,GAAG,KAAK;AAC3B;;;ACLO,IAAM,KAAK,IAAI,gBAAgB;","names":[]}
@@ -1,13 +0,0 @@
1
- import type { ContractRouter } from './router';
2
- import type { HTTPPath, Schema, SchemaInput, SchemaOutput } from './types';
3
- import { DecoratedContractProcedure, type RouteOptions } from './procedure';
4
- import { ContractRouterBuilder } from './router-builder';
5
- export declare class ContractBuilder {
6
- prefix(prefix: HTTPPath): ContractRouterBuilder;
7
- tags(...tags: string[]): ContractRouterBuilder;
8
- route(opts: RouteOptions): DecoratedContractProcedure<undefined, undefined>;
9
- input<USchema extends Schema>(schema: USchema, example?: SchemaInput<USchema>): DecoratedContractProcedure<USchema, undefined>;
10
- output<USchema extends Schema>(schema: USchema, example?: SchemaOutput<USchema>): DecoratedContractProcedure<undefined, USchema>;
11
- router<T extends ContractRouter>(router: T): T;
12
- }
13
- //# sourceMappingURL=builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC1E,OAAO,EAAE,0BAA0B,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD,qBAAa,eAAe;IAC1B,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,qBAAqB;IAM/C,IAAI,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,qBAAqB;IAM9C,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,0BAA0B,CAAC,SAAS,EAAE,SAAS,CAAC;IAQ3E,KAAK,CAAC,OAAO,SAAS,MAAM,EAC1B,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,GAC7B,0BAA0B,CAAC,OAAO,EAAE,SAAS,CAAC;IAQjD,MAAM,CAAC,OAAO,SAAS,MAAM,EAC3B,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,GAC9B,0BAA0B,CAAC,SAAS,EAAE,OAAO,CAAC;IAQjD,MAAM,CAAC,CAAC,SAAS,cAAc,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC;CAG/C"}
@@ -1,3 +0,0 @@
1
- export declare const ORPC_HEADER = "x-orpc-transformer";
2
- export declare const ORPC_HEADER_VALUE = "t";
3
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,uBAAuB,CAAA;AAC/C,eAAO,MAAM,iBAAiB,MAAM,CAAA"}
@@ -1,10 +0,0 @@
1
- /** unnoq */
2
- import { ContractBuilder } from './builder';
3
- export * from './builder';
4
- export * from './constants';
5
- export * from './procedure';
6
- export * from './router';
7
- export * from './types';
8
- export * from './utils';
9
- export declare const oc: ContractBuilder;
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY;AAEZ,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AAEvB,eAAO,MAAM,EAAE,iBAAwB,CAAA"}
@@ -1,46 +0,0 @@
1
- import type { HTTPMethod, HTTPPath, Schema, SchemaInput, SchemaOutput } from './types';
2
- export interface RouteOptions {
3
- method?: HTTPMethod;
4
- path?: HTTPPath;
5
- summary?: string;
6
- description?: string;
7
- deprecated?: boolean;
8
- tags?: string[];
9
- }
10
- export declare class ContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema> {
11
- zz$cp: {
12
- path?: HTTPPath;
13
- method?: HTTPMethod;
14
- summary?: string;
15
- description?: string;
16
- deprecated?: boolean;
17
- tags?: string[];
18
- InputSchema: TInputSchema;
19
- inputExample?: SchemaOutput<TInputSchema>;
20
- OutputSchema: TOutputSchema;
21
- outputExample?: SchemaOutput<TOutputSchema>;
22
- };
23
- constructor(zz$cp: {
24
- path?: HTTPPath;
25
- method?: HTTPMethod;
26
- summary?: string;
27
- description?: string;
28
- deprecated?: boolean;
29
- tags?: string[];
30
- InputSchema: TInputSchema;
31
- inputExample?: SchemaOutput<TInputSchema>;
32
- OutputSchema: TOutputSchema;
33
- outputExample?: SchemaOutput<TOutputSchema>;
34
- });
35
- }
36
- export declare class DecoratedContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema> extends ContractProcedure<TInputSchema, TOutputSchema> {
37
- static decorate<TInputSchema extends Schema, TOutputSchema extends Schema>(cp: ContractProcedure<TInputSchema, TOutputSchema>): DecoratedContractProcedure<TInputSchema, TOutputSchema>;
38
- route(opts: RouteOptions): DecoratedContractProcedure<TInputSchema, TOutputSchema>;
39
- prefix(prefix: HTTPPath): DecoratedContractProcedure<TInputSchema, TOutputSchema>;
40
- addTags(...tags: string[]): DecoratedContractProcedure<TInputSchema, TOutputSchema>;
41
- input<USchema extends Schema>(schema: USchema, example?: SchemaInput<USchema>): DecoratedContractProcedure<USchema, TOutputSchema>;
42
- output<USchema extends Schema>(schema: USchema, example?: SchemaOutput<USchema>): DecoratedContractProcedure<TInputSchema, USchema>;
43
- }
44
- export type WELL_DEFINED_CONTRACT_PROCEDURE = ContractProcedure<Schema, Schema>;
45
- export declare function isContractProcedure(item: unknown): item is WELL_DEFINED_CONTRACT_PROCEDURE;
46
- //# sourceMappingURL=procedure.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"procedure.d.ts","sourceRoot":"","sources":["../../src/procedure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,MAAM,EACN,WAAW,EACX,YAAY,EACb,MAAM,SAAS,CAAA;AAEhB,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CA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AC,GACjD,0BAA0B,CAAC,YAAY,EAAE,aAAa,CAAC;IAM1D,KAAK,CACH,IAAI,EAAE,YAAY,GACjB,0BAA0B,CAAC,YAAY,EAAE,aAAa,CAAC;IAS1D,MAAM,CACJ,MAAM,EAAE,QAAQ,GACf,0BAA0B,CAAC,YAAY,EAAE,aAAa,CAAC;IAU1D,OAAO,CACL,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB,0BAA0B,CAAC,YAAY,EAAE,aAAa,CAAC;IAU1D,KAAK,CAAC,OAAO,SAAS,MAAM,EAC1B,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,GAC7B,0BAA0B,CAAC,OAAO,EAAE,aAAa,CAAC;IAQrD,MAAM,CAAC,OAAO,SAAS,MAAM,EAC3B,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,GAC9B,0BAA0B,CAAC,YAAY,EAAE,OAAO,CAAC;CAOrD;AAED,MAAM,MAAM,+BAA+B,GAAG,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE/E,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,+BAA+B,CAazC"}
@@ -1,16 +0,0 @@
1
- import type { ContractRouter, HandledContractRouter } from './router';
2
- import type { HTTPPath } from './types';
3
- export declare class ContractRouterBuilder {
4
- zz$crb: {
5
- prefix?: HTTPPath;
6
- tags?: string[];
7
- };
8
- constructor(zz$crb: {
9
- prefix?: HTTPPath;
10
- tags?: string[];
11
- });
12
- prefix(prefix: HTTPPath): ContractRouterBuilder;
13
- tags(...tags: string[]): ContractRouterBuilder;
14
- router<T extends ContractRouter>(router: T): HandledContractRouter<T>;
15
- }
16
- //# sourceMappingURL=router-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"router-builder.d.ts","sourceRoot":"","sources":["../../src/router-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAGvC,qBAAa,qBAAqB;IACb,MAAM,EAAE;QAAE,MAAM,CAAC,EAAE,QAAQ,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE;gBAA9C,MAAM,EAAE;QAAE,MAAM,CAAC,EAAE,QAAQ,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE;IAEjE,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,qBAAqB;IAO/C,IAAI,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,qBAAqB;IAU9C,MAAM,CAAC,CAAC,SAAS,cAAc,EAAE,MAAM,EAAE,CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC;CAqBtE"}
@@ -1,16 +0,0 @@
1
- import type { SchemaInput, SchemaOutput } from './types';
2
- import { type ContractProcedure, type DecoratedContractProcedure, type WELL_DEFINED_CONTRACT_PROCEDURE } from './procedure';
3
- export interface ContractRouter {
4
- [k: string]: ContractProcedure<any, any> | ContractRouter;
5
- }
6
- export type HandledContractRouter<TContract extends ContractRouter> = {
7
- [K in keyof TContract]: TContract[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? DecoratedContractProcedure<UInputSchema, UOutputSchema> : TContract[K] extends ContractRouter ? HandledContractRouter<TContract[K]> : never;
8
- };
9
- export declare function eachContractRouterLeaf(router: ContractRouter, callback: (item: WELL_DEFINED_CONTRACT_PROCEDURE, path: string[]) => void, prefix?: string[]): void;
10
- export type InferContractRouterInputs<T extends ContractRouter> = {
11
- [K in keyof T]: T[K] extends ContractProcedure<infer UInputSchema, any> ? SchemaInput<UInputSchema> : T[K] extends ContractRouter ? InferContractRouterInputs<T[K]> : never;
12
- };
13
- export type InferContractRouterOutputs<T extends ContractRouter> = {
14
- [K in keyof T]: T[K] extends ContractProcedure<any, infer UOutputSchema> ? SchemaOutput<UOutputSchema> : T[K] extends ContractRouter ? InferContractRouterOutputs<T[K]> : never;
15
- };
16
- //# sourceMappingURL=router.d.ts.map