@orpc/contract 0.0.0-next.ef3ba82 → 0.0.0-next.f99e554
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/dist/index.js +72 -89
- package/dist/src/builder.d.ts +7 -5
- package/dist/src/index.d.ts +3 -2
- package/dist/src/procedure-decorated.d.ts +12 -0
- package/dist/src/procedure.d.ts +66 -36
- package/dist/src/router-builder.d.ts +16 -11
- package/dist/src/router.d.ts +8 -11
- package/dist/src/types.d.ts +5 -5
- package/package.json +11 -7
- package/dist/src/constants.d.ts +0 -2
- package/dist/src/utils.d.ts +0 -3
package/dist/index.js
CHANGED
|
@@ -1,93 +1,109 @@
|
|
|
1
1
|
// src/procedure.ts
|
|
2
2
|
var ContractProcedure = class {
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
5
10
|
}
|
|
6
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
|
|
7
20
|
var DecoratedContractProcedure = class _DecoratedContractProcedure extends ContractProcedure {
|
|
8
|
-
static decorate(
|
|
9
|
-
if (
|
|
10
|
-
return
|
|
11
|
-
|
|
21
|
+
static decorate(procedure) {
|
|
22
|
+
if (procedure instanceof _DecoratedContractProcedure) {
|
|
23
|
+
return procedure;
|
|
24
|
+
}
|
|
25
|
+
return new _DecoratedContractProcedure(procedure["~orpc"]);
|
|
12
26
|
}
|
|
13
|
-
route(
|
|
27
|
+
route(route) {
|
|
14
28
|
return new _DecoratedContractProcedure({
|
|
15
|
-
...this
|
|
16
|
-
|
|
17
|
-
method: opts.method,
|
|
18
|
-
path: opts.path
|
|
29
|
+
...this["~orpc"],
|
|
30
|
+
route
|
|
19
31
|
});
|
|
20
32
|
}
|
|
21
33
|
prefix(prefix) {
|
|
22
|
-
if (!this.zz$cp.path)
|
|
23
|
-
return this;
|
|
24
34
|
return new _DecoratedContractProcedure({
|
|
25
|
-
...this
|
|
26
|
-
path
|
|
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
|
|
27
42
|
});
|
|
28
43
|
}
|
|
29
|
-
|
|
30
|
-
if (!tags.length)
|
|
31
|
-
return this;
|
|
44
|
+
unshiftTag(...tags) {
|
|
32
45
|
return new _DecoratedContractProcedure({
|
|
33
|
-
...this
|
|
34
|
-
|
|
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
|
+
}
|
|
35
54
|
});
|
|
36
55
|
}
|
|
37
56
|
input(schema, example) {
|
|
38
57
|
return new _DecoratedContractProcedure({
|
|
39
|
-
...this
|
|
58
|
+
...this["~orpc"],
|
|
40
59
|
InputSchema: schema,
|
|
41
60
|
inputExample: example
|
|
42
61
|
});
|
|
43
62
|
}
|
|
44
63
|
output(schema, example) {
|
|
45
64
|
return new _DecoratedContractProcedure({
|
|
46
|
-
...this
|
|
65
|
+
...this["~orpc"],
|
|
47
66
|
OutputSchema: schema,
|
|
48
67
|
outputExample: example
|
|
49
68
|
});
|
|
50
69
|
}
|
|
51
70
|
};
|
|
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
71
|
|
|
58
72
|
// src/router-builder.ts
|
|
59
73
|
var ContractRouterBuilder = class _ContractRouterBuilder {
|
|
60
|
-
|
|
61
|
-
|
|
74
|
+
"~type" = "ContractProcedure";
|
|
75
|
+
"~orpc";
|
|
76
|
+
constructor(def) {
|
|
77
|
+
this["~orpc"] = def;
|
|
62
78
|
}
|
|
63
79
|
prefix(prefix) {
|
|
64
80
|
return new _ContractRouterBuilder({
|
|
65
|
-
...this
|
|
66
|
-
prefix: `${this.
|
|
81
|
+
...this["~orpc"],
|
|
82
|
+
prefix: `${this["~orpc"].prefix ?? ""}${prefix}`
|
|
67
83
|
});
|
|
68
84
|
}
|
|
69
|
-
|
|
70
|
-
if (!tags.length)
|
|
71
|
-
return this;
|
|
85
|
+
tag(...tags) {
|
|
72
86
|
return new _ContractRouterBuilder({
|
|
73
|
-
...this
|
|
74
|
-
tags: [...this.
|
|
87
|
+
...this["~orpc"],
|
|
88
|
+
tags: [...this["~orpc"].tags ?? [], ...tags]
|
|
75
89
|
});
|
|
76
90
|
}
|
|
77
91
|
router(router) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
);
|
|
85
|
-
handled[key] = this.zz$crb.prefix ? decorated.prefix(this.zz$crb.prefix) : decorated;
|
|
86
|
-
} else {
|
|
87
|
-
handled[key] = this.router(item);
|
|
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);
|
|
88
99
|
}
|
|
100
|
+
return decorated;
|
|
89
101
|
}
|
|
90
|
-
|
|
102
|
+
const adapted = {};
|
|
103
|
+
for (const key in router) {
|
|
104
|
+
adapted[key] = this.router(router[key]);
|
|
105
|
+
}
|
|
106
|
+
return adapted;
|
|
91
107
|
}
|
|
92
108
|
};
|
|
93
109
|
|
|
@@ -98,16 +114,16 @@ var ContractBuilder = class {
|
|
|
98
114
|
prefix
|
|
99
115
|
});
|
|
100
116
|
}
|
|
101
|
-
|
|
117
|
+
tag(...tags) {
|
|
102
118
|
return new ContractRouterBuilder({
|
|
103
119
|
tags
|
|
104
120
|
});
|
|
105
121
|
}
|
|
106
|
-
route(
|
|
122
|
+
route(route) {
|
|
107
123
|
return new DecoratedContractProcedure({
|
|
124
|
+
route,
|
|
108
125
|
InputSchema: void 0,
|
|
109
|
-
OutputSchema: void 0
|
|
110
|
-
...opts
|
|
126
|
+
OutputSchema: void 0
|
|
111
127
|
});
|
|
112
128
|
}
|
|
113
129
|
input(schema, example) {
|
|
@@ -119,9 +135,9 @@ var ContractBuilder = class {
|
|
|
119
135
|
}
|
|
120
136
|
output(schema, example) {
|
|
121
137
|
return new DecoratedContractProcedure({
|
|
122
|
-
InputSchema: void 0,
|
|
123
138
|
OutputSchema: schema,
|
|
124
|
-
outputExample: example
|
|
139
|
+
outputExample: example,
|
|
140
|
+
InputSchema: void 0
|
|
125
141
|
});
|
|
126
142
|
}
|
|
127
143
|
router(router) {
|
|
@@ -129,47 +145,14 @@ var ContractBuilder = class {
|
|
|
129
145
|
}
|
|
130
146
|
};
|
|
131
147
|
|
|
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
148
|
// src/index.ts
|
|
163
149
|
var oc = new ContractBuilder();
|
|
164
150
|
export {
|
|
165
151
|
ContractBuilder,
|
|
166
152
|
ContractProcedure,
|
|
153
|
+
ContractRouterBuilder,
|
|
167
154
|
DecoratedContractProcedure,
|
|
168
|
-
ORPC_HEADER,
|
|
169
|
-
ORPC_HEADER_VALUE,
|
|
170
|
-
eachContractRouterLeaf,
|
|
171
155
|
isContractProcedure,
|
|
172
|
-
oc
|
|
173
|
-
prefixHTTPPath,
|
|
174
|
-
standardizeHTTPPath
|
|
156
|
+
oc
|
|
175
157
|
};
|
|
158
|
+
//# sourceMappingURL=index.js.map
|
package/dist/src/builder.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import type { RouteOptions } from './procedure';
|
|
1
2
|
import type { ContractRouter } from './router';
|
|
2
3
|
import type { HTTPPath, Schema, SchemaInput, SchemaOutput } from './types';
|
|
3
|
-
import { DecoratedContractProcedure
|
|
4
|
+
import { DecoratedContractProcedure } from './procedure-decorated';
|
|
4
5
|
import { ContractRouterBuilder } from './router-builder';
|
|
5
6
|
export declare class ContractBuilder {
|
|
6
7
|
prefix(prefix: HTTPPath): ContractRouterBuilder;
|
|
7
|
-
|
|
8
|
-
route(
|
|
9
|
-
input<
|
|
10
|
-
output<
|
|
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>;
|
|
11
12
|
router<T extends ContractRouter>(router: T): T;
|
|
12
13
|
}
|
|
14
|
+
//# sourceMappingURL=builder.d.ts.map
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/** unnoq */
|
|
2
2
|
import { ContractBuilder } from './builder';
|
|
3
3
|
export * from './builder';
|
|
4
|
-
export * from './constants';
|
|
5
4
|
export * from './procedure';
|
|
5
|
+
export * from './procedure-decorated';
|
|
6
6
|
export * from './router';
|
|
7
|
+
export * from './router-builder';
|
|
7
8
|
export * from './types';
|
|
8
|
-
export * from './utils';
|
|
9
9
|
export declare const oc: ContractBuilder;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
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
CHANGED
|
@@ -1,45 +1,75 @@
|
|
|
1
|
-
import type { HTTPMethod, HTTPPath, Schema,
|
|
1
|
+
import type { HTTPMethod, HTTPPath, Schema, SchemaOutput } from './types';
|
|
2
2
|
export interface RouteOptions {
|
|
3
3
|
method?: HTTPMethod;
|
|
4
4
|
path?: HTTPPath;
|
|
5
5
|
summary?: string;
|
|
6
6
|
description?: string;
|
|
7
7
|
deprecated?: boolean;
|
|
8
|
-
tags?: string[];
|
|
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';
|
|
9
59
|
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
});
|
|
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>;
|
|
35
66
|
}
|
|
36
|
-
export declare class
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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>;
|
|
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>);
|
|
43
71
|
}
|
|
44
|
-
export type
|
|
45
|
-
export
|
|
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,15 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContractProcedure } from './procedure';
|
|
2
|
+
import type { ContractRouter } from './router';
|
|
2
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
|
+
}
|
|
3
12
|
export declare class ContractRouterBuilder {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
constructor(zz$crb: {
|
|
9
|
-
prefix?: HTTPPath;
|
|
10
|
-
tags?: string[];
|
|
11
|
-
});
|
|
13
|
+
'~type': "ContractProcedure";
|
|
14
|
+
'~orpc': ContractRouterBuilderDef;
|
|
15
|
+
constructor(def: ContractRouterBuilderDef);
|
|
12
16
|
prefix(prefix: HTTPPath): ContractRouterBuilder;
|
|
13
|
-
|
|
14
|
-
router<T extends ContractRouter>(router: T):
|
|
17
|
+
tag(...tags: string[]): ContractRouterBuilder;
|
|
18
|
+
router<T extends ContractRouter>(router: T): AdaptedContractRouter<T>;
|
|
15
19
|
}
|
|
20
|
+
//# sourceMappingURL=router-builder.d.ts.map
|
package/dist/src/router.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
+
import type { ANY_CONTRACT_PROCEDURE, ContractProcedure } from './procedure';
|
|
1
2
|
import type { SchemaInput, SchemaOutput } from './types';
|
|
2
|
-
|
|
3
|
-
|
|
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;
|
|
3
|
+
export type ContractRouter = ANY_CONTRACT_PROCEDURE | {
|
|
4
|
+
[k: string]: ContractRouter;
|
|
8
5
|
};
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
[K in keyof T]: T[K] extends ContractProcedure<infer UInputSchema, any> ? SchemaInput<UInputSchema> : T[K] extends ContractRouter ? InferContractRouterInputs<T[K]> : never;
|
|
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;
|
|
12
8
|
};
|
|
13
|
-
export type InferContractRouterOutputs<T extends ContractRouter> = {
|
|
14
|
-
[K in keyof T]: T[K] extends
|
|
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;
|
|
15
11
|
};
|
|
12
|
+
//# sourceMappingURL=router.d.ts.map
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
export type HTTPPath = `/${string}`;
|
|
3
3
|
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
4
|
-
export type
|
|
5
|
-
export type Schema =
|
|
6
|
-
export type
|
|
7
|
-
|
|
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
|
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.f99e554",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -24,17 +24,21 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
|
-
"
|
|
27
|
+
"!**/*.map",
|
|
28
|
+
"!**/*.tsbuildinfo",
|
|
28
29
|
"dist"
|
|
29
30
|
],
|
|
30
|
-
"peerDependencies": {
|
|
31
|
-
"zod": ">=3.23.0"
|
|
32
|
-
},
|
|
33
31
|
"dependencies": {
|
|
34
|
-
"@
|
|
32
|
+
"@standard-schema/spec": "1.0.0-beta.4",
|
|
33
|
+
"@orpc/shared": "0.0.0-next.f99e554"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"arktype": "2.0.0-rc.26",
|
|
37
|
+
"valibot": "1.0.0-beta.9",
|
|
38
|
+
"zod": "3.24.1"
|
|
35
39
|
},
|
|
36
40
|
"scripts": {
|
|
37
|
-
"build": "tsup --clean --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
|
|
41
|
+
"build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
|
|
38
42
|
"build:watch": "pnpm run build --watch",
|
|
39
43
|
"type:check": "tsc -b"
|
|
40
44
|
}
|
package/dist/src/constants.d.ts
DELETED
package/dist/src/utils.d.ts
DELETED