@orpc/contract 0.0.0-next.f99e554 → 0.0.0-next.f9e5dec
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 +307 -0
- package/dist/index.d.ts +307 -0
- package/dist/index.mjs +326 -0
- package/dist/plugins/index.d.mts +43 -0
- package/dist/plugins/index.d.ts +43 -0
- package/dist/plugins/index.mjs +81 -0
- package/dist/shared/contract.CvRxURhn.d.mts +254 -0
- package/dist/shared/contract.CvRxURhn.d.ts +254 -0
- package/dist/shared/contract.D_dZrO__.mjs +53 -0
- package/package.json +16 -14
- package/dist/index.js +0 -158
- package/dist/src/builder.d.ts +0 -14
- package/dist/src/index.d.ts +0 -10
- package/dist/src/procedure-decorated.d.ts +0 -12
- package/dist/src/procedure.d.ts +0 -75
- package/dist/src/router-builder.d.ts +0 -20
- package/dist/src/router.d.ts +0 -12
- package/dist/src/types.d.ts +0 -7
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { fallbackORPCErrorStatus, ORPCError, isORPCErrorStatus } from '@orpc/client';
|
|
2
|
+
|
|
3
|
+
class ValidationError extends Error {
|
|
4
|
+
issues;
|
|
5
|
+
data;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super(options.message, options);
|
|
8
|
+
this.issues = options.issues;
|
|
9
|
+
this.data = options.data;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function mergeErrorMap(errorMap1, errorMap2) {
|
|
13
|
+
return { ...errorMap1, ...errorMap2 };
|
|
14
|
+
}
|
|
15
|
+
async function validateORPCError(map, error) {
|
|
16
|
+
const { code, status, message, data, cause, defined } = error;
|
|
17
|
+
const config = map?.[error.code];
|
|
18
|
+
if (!config || fallbackORPCErrorStatus(error.code, config.status) !== error.status) {
|
|
19
|
+
return defined ? new ORPCError(code, { defined: false, status, message, data, cause }) : error;
|
|
20
|
+
}
|
|
21
|
+
if (!config.data) {
|
|
22
|
+
return defined ? error : new ORPCError(code, { defined: true, status, message, data, cause });
|
|
23
|
+
}
|
|
24
|
+
const validated = await config.data["~standard"].validate(error.data);
|
|
25
|
+
if (validated.issues) {
|
|
26
|
+
return defined ? new ORPCError(code, { defined: false, status, message, data, cause }) : error;
|
|
27
|
+
}
|
|
28
|
+
return new ORPCError(code, { defined: true, status, message, data: validated.value, cause });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class ContractProcedure {
|
|
32
|
+
/**
|
|
33
|
+
* This property holds the defined options for the contract procedure.
|
|
34
|
+
*/
|
|
35
|
+
"~orpc";
|
|
36
|
+
constructor(def) {
|
|
37
|
+
if (def.route?.successStatus && isORPCErrorStatus(def.route.successStatus)) {
|
|
38
|
+
throw new Error("[ContractProcedure] Invalid successStatus.");
|
|
39
|
+
}
|
|
40
|
+
if (Object.values(def.errorMap).some((val) => val && val.status && !isORPCErrorStatus(val.status))) {
|
|
41
|
+
throw new Error("[ContractProcedure] Invalid error status code.");
|
|
42
|
+
}
|
|
43
|
+
this["~orpc"] = def;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function isContractProcedure(item) {
|
|
47
|
+
if (item instanceof ContractProcedure) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return (typeof item === "object" || typeof item === "function") && item !== null && "~orpc" in item && typeof item["~orpc"] === "object" && item["~orpc"] !== null && "errorMap" in item["~orpc"] && "route" in item["~orpc"] && "meta" in item["~orpc"];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { ContractProcedure as C, ValidationError as V, isContractProcedure as i, mergeErrorMap as m, validateORPCError as v };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/contract",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.f9e5dec",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -15,30 +15,32 @@
|
|
|
15
15
|
],
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
|
-
"types": "./dist/
|
|
19
|
-
"import": "./dist/index.
|
|
20
|
-
"default": "./dist/index.
|
|
18
|
+
"types": "./dist/index.d.mts",
|
|
19
|
+
"import": "./dist/index.mjs",
|
|
20
|
+
"default": "./dist/index.mjs"
|
|
21
21
|
},
|
|
22
|
-
"
|
|
23
|
-
"types": "./dist/
|
|
22
|
+
"./plugins": {
|
|
23
|
+
"types": "./dist/plugins/index.d.mts",
|
|
24
|
+
"import": "./dist/plugins/index.mjs",
|
|
25
|
+
"default": "./dist/plugins/index.mjs"
|
|
24
26
|
}
|
|
25
27
|
},
|
|
26
28
|
"files": [
|
|
27
|
-
"!**/*.map",
|
|
28
|
-
"!**/*.tsbuildinfo",
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@standard-schema/spec": "1.0.0
|
|
33
|
-
"
|
|
32
|
+
"@standard-schema/spec": "^1.0.0",
|
|
33
|
+
"openapi-types": "^12.1.3",
|
|
34
|
+
"@orpc/client": "0.0.0-next.f9e5dec",
|
|
35
|
+
"@orpc/shared": "0.0.0-next.f9e5dec"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
36
|
-
"arktype": "2.
|
|
37
|
-
"valibot": "1.
|
|
38
|
-
"zod": "
|
|
38
|
+
"arktype": "2.1.27",
|
|
39
|
+
"valibot": "^1.1.0",
|
|
40
|
+
"zod": "^4.1.12"
|
|
39
41
|
},
|
|
40
42
|
"scripts": {
|
|
41
|
-
"build": "
|
|
43
|
+
"build": "unbuild",
|
|
42
44
|
"build:watch": "pnpm run build --watch",
|
|
43
45
|
"type:check": "tsc -b"
|
|
44
46
|
}
|
package/dist/index.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
// src/procedure.ts
|
|
2
|
-
var ContractProcedure = class {
|
|
3
|
-
"~type" = "ContractProcedure";
|
|
4
|
-
"~orpc";
|
|
5
|
-
constructor(def) {
|
|
6
|
-
if (def.route?.successStatus && (def.route.successStatus < 200 || def.route?.successStatus > 299)) {
|
|
7
|
-
throw new Error("[ContractProcedure] The successStatus must be between 200 and 299");
|
|
8
|
-
}
|
|
9
|
-
this["~orpc"] = def;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
function isContractProcedure(item) {
|
|
13
|
-
if (item instanceof ContractProcedure) {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
return (typeof item === "object" || typeof item === "function") && item !== null && "~type" in item && item["~type"] === "ContractProcedure" && "~orpc" in item && typeof item["~orpc"] === "object" && item["~orpc"] !== null && "InputSchema" in item["~orpc"] && "OutputSchema" in item["~orpc"];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// src/procedure-decorated.ts
|
|
20
|
-
var DecoratedContractProcedure = class _DecoratedContractProcedure extends ContractProcedure {
|
|
21
|
-
static decorate(procedure) {
|
|
22
|
-
if (procedure instanceof _DecoratedContractProcedure) {
|
|
23
|
-
return procedure;
|
|
24
|
-
}
|
|
25
|
-
return new _DecoratedContractProcedure(procedure["~orpc"]);
|
|
26
|
-
}
|
|
27
|
-
route(route) {
|
|
28
|
-
return new _DecoratedContractProcedure({
|
|
29
|
-
...this["~orpc"],
|
|
30
|
-
route
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
prefix(prefix) {
|
|
34
|
-
return new _DecoratedContractProcedure({
|
|
35
|
-
...this["~orpc"],
|
|
36
|
-
...this["~orpc"].route?.path ? {
|
|
37
|
-
route: {
|
|
38
|
-
...this["~orpc"].route,
|
|
39
|
-
path: `${prefix}${this["~orpc"].route.path}`
|
|
40
|
-
}
|
|
41
|
-
} : void 0
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
unshiftTag(...tags) {
|
|
45
|
-
return new _DecoratedContractProcedure({
|
|
46
|
-
...this["~orpc"],
|
|
47
|
-
route: {
|
|
48
|
-
...this["~orpc"].route,
|
|
49
|
-
tags: [
|
|
50
|
-
...tags,
|
|
51
|
-
...this["~orpc"].route?.tags?.filter((tag) => !tags.includes(tag)) ?? []
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
input(schema, example) {
|
|
57
|
-
return new _DecoratedContractProcedure({
|
|
58
|
-
...this["~orpc"],
|
|
59
|
-
InputSchema: schema,
|
|
60
|
-
inputExample: example
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
output(schema, example) {
|
|
64
|
-
return new _DecoratedContractProcedure({
|
|
65
|
-
...this["~orpc"],
|
|
66
|
-
OutputSchema: schema,
|
|
67
|
-
outputExample: example
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// src/router-builder.ts
|
|
73
|
-
var ContractRouterBuilder = class _ContractRouterBuilder {
|
|
74
|
-
"~type" = "ContractProcedure";
|
|
75
|
-
"~orpc";
|
|
76
|
-
constructor(def) {
|
|
77
|
-
this["~orpc"] = def;
|
|
78
|
-
}
|
|
79
|
-
prefix(prefix) {
|
|
80
|
-
return new _ContractRouterBuilder({
|
|
81
|
-
...this["~orpc"],
|
|
82
|
-
prefix: `${this["~orpc"].prefix ?? ""}${prefix}`
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
tag(...tags) {
|
|
86
|
-
return new _ContractRouterBuilder({
|
|
87
|
-
...this["~orpc"],
|
|
88
|
-
tags: [...this["~orpc"].tags ?? [], ...tags]
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
router(router) {
|
|
92
|
-
if (isContractProcedure(router)) {
|
|
93
|
-
let decorated = DecoratedContractProcedure.decorate(router);
|
|
94
|
-
if (this["~orpc"].tags) {
|
|
95
|
-
decorated = decorated.unshiftTag(...this["~orpc"].tags);
|
|
96
|
-
}
|
|
97
|
-
if (this["~orpc"].prefix) {
|
|
98
|
-
decorated = decorated.prefix(this["~orpc"].prefix);
|
|
99
|
-
}
|
|
100
|
-
return decorated;
|
|
101
|
-
}
|
|
102
|
-
const adapted = {};
|
|
103
|
-
for (const key in router) {
|
|
104
|
-
adapted[key] = this.router(router[key]);
|
|
105
|
-
}
|
|
106
|
-
return adapted;
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// src/builder.ts
|
|
111
|
-
var ContractBuilder = class {
|
|
112
|
-
prefix(prefix) {
|
|
113
|
-
return new ContractRouterBuilder({
|
|
114
|
-
prefix
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
tag(...tags) {
|
|
118
|
-
return new ContractRouterBuilder({
|
|
119
|
-
tags
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
route(route) {
|
|
123
|
-
return new DecoratedContractProcedure({
|
|
124
|
-
route,
|
|
125
|
-
InputSchema: void 0,
|
|
126
|
-
OutputSchema: void 0
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
input(schema, example) {
|
|
130
|
-
return new DecoratedContractProcedure({
|
|
131
|
-
InputSchema: schema,
|
|
132
|
-
inputExample: example,
|
|
133
|
-
OutputSchema: void 0
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
output(schema, example) {
|
|
137
|
-
return new DecoratedContractProcedure({
|
|
138
|
-
OutputSchema: schema,
|
|
139
|
-
outputExample: example,
|
|
140
|
-
InputSchema: void 0
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
router(router) {
|
|
144
|
-
return router;
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
// src/index.ts
|
|
149
|
-
var oc = new ContractBuilder();
|
|
150
|
-
export {
|
|
151
|
-
ContractBuilder,
|
|
152
|
-
ContractProcedure,
|
|
153
|
-
ContractRouterBuilder,
|
|
154
|
-
DecoratedContractProcedure,
|
|
155
|
-
isContractProcedure,
|
|
156
|
-
oc
|
|
157
|
-
};
|
|
158
|
-
//# sourceMappingURL=index.js.map
|
package/dist/src/builder.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { RouteOptions } from './procedure';
|
|
2
|
-
import type { ContractRouter } from './router';
|
|
3
|
-
import type { HTTPPath, Schema, SchemaInput, SchemaOutput } from './types';
|
|
4
|
-
import { DecoratedContractProcedure } from './procedure-decorated';
|
|
5
|
-
import { ContractRouterBuilder } from './router-builder';
|
|
6
|
-
export declare class ContractBuilder {
|
|
7
|
-
prefix(prefix: HTTPPath): ContractRouterBuilder;
|
|
8
|
-
tag(...tags: string[]): ContractRouterBuilder;
|
|
9
|
-
route(route: RouteOptions): DecoratedContractProcedure<undefined, undefined>;
|
|
10
|
-
input<U extends Schema = undefined>(schema: U, example?: SchemaInput<U>): DecoratedContractProcedure<U, undefined>;
|
|
11
|
-
output<U extends Schema = undefined>(schema: U, example?: SchemaOutput<U>): DecoratedContractProcedure<undefined, U>;
|
|
12
|
-
router<T extends ContractRouter>(router: T): T;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=builder.d.ts.map
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/** unnoq */
|
|
2
|
-
import { ContractBuilder } from './builder';
|
|
3
|
-
export * from './builder';
|
|
4
|
-
export * from './procedure';
|
|
5
|
-
export * from './procedure-decorated';
|
|
6
|
-
export * from './router';
|
|
7
|
-
export * from './router-builder';
|
|
8
|
-
export * from './types';
|
|
9
|
-
export declare const oc: ContractBuilder;
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { RouteOptions } from './procedure';
|
|
2
|
-
import type { HTTPPath, Schema, SchemaInput, SchemaOutput } from './types';
|
|
3
|
-
import { ContractProcedure } from './procedure';
|
|
4
|
-
export declare class DecoratedContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema> extends ContractProcedure<TInputSchema, TOutputSchema> {
|
|
5
|
-
static decorate<UInputSchema extends Schema = undefined, UOutputSchema extends Schema = undefined>(procedure: ContractProcedure<UInputSchema, UOutputSchema>): DecoratedContractProcedure<UInputSchema, UOutputSchema>;
|
|
6
|
-
route(route: RouteOptions): DecoratedContractProcedure<TInputSchema, TOutputSchema>;
|
|
7
|
-
prefix(prefix: HTTPPath): DecoratedContractProcedure<TInputSchema, TOutputSchema>;
|
|
8
|
-
unshiftTag(...tags: string[]): DecoratedContractProcedure<TInputSchema, TOutputSchema>;
|
|
9
|
-
input<U extends Schema = undefined>(schema: U, example?: SchemaInput<U>): DecoratedContractProcedure<U, TOutputSchema>;
|
|
10
|
-
output<U extends Schema = undefined>(schema: U, example?: SchemaOutput<U>): DecoratedContractProcedure<TInputSchema, U>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=procedure-decorated.d.ts.map
|
package/dist/src/procedure.d.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { HTTPMethod, HTTPPath, Schema, SchemaOutput } from './types';
|
|
2
|
-
export interface RouteOptions {
|
|
3
|
-
method?: HTTPMethod;
|
|
4
|
-
path?: HTTPPath;
|
|
5
|
-
summary?: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
deprecated?: boolean;
|
|
8
|
-
tags?: readonly string[];
|
|
9
|
-
/**
|
|
10
|
-
* The status code of the response when the procedure is successful.
|
|
11
|
-
*
|
|
12
|
-
* @default 200
|
|
13
|
-
*/
|
|
14
|
-
successStatus?: number;
|
|
15
|
-
/**
|
|
16
|
-
* Determines how the input should be structured based on `params`, `query`, `headers`, and `body`.
|
|
17
|
-
*
|
|
18
|
-
* @option 'compact'
|
|
19
|
-
* Combines `params` and either `query` or `body` (depending on the HTTP method) into a single object.
|
|
20
|
-
*
|
|
21
|
-
* @option 'detailed'
|
|
22
|
-
* Keeps each part of the request (`params`, `query`, `headers`, and `body`) as separate fields in the input object.
|
|
23
|
-
*
|
|
24
|
-
* Example:
|
|
25
|
-
* ```ts
|
|
26
|
-
* const input = {
|
|
27
|
-
* params: { id: 1 },
|
|
28
|
-
* query: { search: 'hello' },
|
|
29
|
-
* headers: { 'Content-Type': 'application/json' },
|
|
30
|
-
* body: { name: 'John' },
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* @default 'compact'
|
|
35
|
-
*/
|
|
36
|
-
inputStructure?: 'compact' | 'detailed';
|
|
37
|
-
/**
|
|
38
|
-
* Determines how the response should be structured based on the output.
|
|
39
|
-
*
|
|
40
|
-
* @option 'compact'
|
|
41
|
-
* Includes only the body data, encoded directly in the response.
|
|
42
|
-
*
|
|
43
|
-
* @option 'detailed'
|
|
44
|
-
* Separates the output into `headers` and `body` fields.
|
|
45
|
-
* - `headers`: Custom headers to merge with the response headers.
|
|
46
|
-
* - `body`: The response data.
|
|
47
|
-
*
|
|
48
|
-
* Example:
|
|
49
|
-
* ```ts
|
|
50
|
-
* const output = {
|
|
51
|
-
* headers: { 'x-custom-header': 'value' },
|
|
52
|
-
* body: { message: 'Hello, world!' },
|
|
53
|
-
* };
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
* @default 'compact'
|
|
57
|
-
*/
|
|
58
|
-
outputStructure?: 'compact' | 'detailed';
|
|
59
|
-
}
|
|
60
|
-
export interface ContractProcedureDef<TInputSchema extends Schema, TOutputSchema extends Schema> {
|
|
61
|
-
route?: RouteOptions;
|
|
62
|
-
InputSchema: TInputSchema;
|
|
63
|
-
inputExample?: SchemaOutput<TInputSchema>;
|
|
64
|
-
OutputSchema: TOutputSchema;
|
|
65
|
-
outputExample?: SchemaOutput<TOutputSchema>;
|
|
66
|
-
}
|
|
67
|
-
export declare class ContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema> {
|
|
68
|
-
'~type': "ContractProcedure";
|
|
69
|
-
'~orpc': ContractProcedureDef<TInputSchema, TOutputSchema>;
|
|
70
|
-
constructor(def: ContractProcedureDef<TInputSchema, TOutputSchema>);
|
|
71
|
-
}
|
|
72
|
-
export type ANY_CONTRACT_PROCEDURE = ContractProcedure<any, any>;
|
|
73
|
-
export type WELL_CONTRACT_PROCEDURE = ContractProcedure<Schema, Schema>;
|
|
74
|
-
export declare function isContractProcedure(item: unknown): item is ANY_CONTRACT_PROCEDURE;
|
|
75
|
-
//# sourceMappingURL=procedure.d.ts.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ContractProcedure } from './procedure';
|
|
2
|
-
import type { ContractRouter } from './router';
|
|
3
|
-
import type { HTTPPath } from './types';
|
|
4
|
-
import { DecoratedContractProcedure } from './procedure-decorated';
|
|
5
|
-
export type AdaptedContractRouter<TContract extends ContractRouter> = {
|
|
6
|
-
[K in keyof TContract]: TContract[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? DecoratedContractProcedure<UInputSchema, UOutputSchema> : TContract[K] extends ContractRouter ? AdaptedContractRouter<TContract[K]> : never;
|
|
7
|
-
};
|
|
8
|
-
export interface ContractRouterBuilderDef {
|
|
9
|
-
prefix?: HTTPPath;
|
|
10
|
-
tags?: string[];
|
|
11
|
-
}
|
|
12
|
-
export declare class ContractRouterBuilder {
|
|
13
|
-
'~type': "ContractProcedure";
|
|
14
|
-
'~orpc': ContractRouterBuilderDef;
|
|
15
|
-
constructor(def: ContractRouterBuilderDef);
|
|
16
|
-
prefix(prefix: HTTPPath): ContractRouterBuilder;
|
|
17
|
-
tag(...tags: string[]): ContractRouterBuilder;
|
|
18
|
-
router<T extends ContractRouter>(router: T): AdaptedContractRouter<T>;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=router-builder.d.ts.map
|
package/dist/src/router.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ANY_CONTRACT_PROCEDURE, ContractProcedure } from './procedure';
|
|
2
|
-
import type { SchemaInput, SchemaOutput } from './types';
|
|
3
|
-
export type ContractRouter = ANY_CONTRACT_PROCEDURE | {
|
|
4
|
-
[k: string]: ContractRouter;
|
|
5
|
-
};
|
|
6
|
-
export type InferContractRouterInputs<T extends ContractRouter> = T extends ContractProcedure<infer UInputSchema, any> ? SchemaInput<UInputSchema> : {
|
|
7
|
-
[K in keyof T]: T[K] extends ContractRouter ? InferContractRouterInputs<T[K]> : never;
|
|
8
|
-
};
|
|
9
|
-
export type InferContractRouterOutputs<T extends ContractRouter> = T extends ContractProcedure<any, infer UOutputSchema> ? SchemaOutput<UOutputSchema> : {
|
|
10
|
-
[K in keyof T]: T[K] extends ContractRouter ? InferContractRouterOutputs<T[K]> : never;
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=router.d.ts.map
|
package/dist/src/types.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
export type HTTPPath = `/${string}`;
|
|
3
|
-
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
4
|
-
export type Schema = StandardSchemaV1 | undefined;
|
|
5
|
-
export type SchemaInput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<TSchema> : TFallback;
|
|
6
|
-
export type SchemaOutput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : TFallback;
|
|
7
|
-
//# sourceMappingURL=types.d.ts.map
|