@orpc/openapi 2.0.0-beta.49 → 2.0.0-beta.50
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/adapters/aws-lambda/index.d.ts +3 -15
- package/dist/adapters/aws-lambda/index.js +1 -1
- package/dist/adapters/aws-lambda/openapi-handler.d.ts +8 -9
- package/dist/adapters/aws-lambda/openapi-handler.js +19 -17
- package/dist/adapters/fastify/index.d.ts +2 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/fastify/openapi-handler.d.ts +8 -9
- package/dist/adapters/fastify/openapi-handler.js +16 -14
- package/dist/adapters/fetch/index.d.ts +3 -2
- package/dist/adapters/fetch/index.js +2 -2
- package/dist/adapters/fetch/openapi-handler.d.ts +8 -9
- package/dist/adapters/fetch/openapi-handler.js +16 -14
- package/dist/adapters/fetch/openapi-link.d.ts +9 -10
- package/dist/adapters/fetch/openapi-link.js +21 -19
- package/dist/adapters/node/index.d.ts +2 -1
- package/dist/adapters/node/index.js +1 -1
- package/dist/adapters/node/openapi-handler.d.ts +8 -9
- package/dist/adapters/node/openapi-handler.js +16 -14
- package/dist/adapters/standard/index.d.ts +4 -3
- package/dist/adapters/standard/index.js +3 -3
- package/dist/adapters/standard/openapi-handler-codec.d.ts +56 -57
- package/dist/adapters/standard/openapi-handler-codec.js +143 -205
- package/dist/adapters/standard/openapi-link-codec.d.ts +55 -59
- package/dist/adapters/standard/openapi-link-codec.js +262 -377
- package/dist/adapters/standard/openapi-matcher.d.ts +26 -26
- package/dist/adapters/standard/openapi-matcher.js +78 -108
- package/dist/adapters/standard/utils.js +28 -44
- package/dist/bracket-notation.d.ts +22 -22
- package/dist/bracket-notation.js +123 -173
- package/dist/client-factory.d.ts +12 -12
- package/dist/client-factory.js +13 -11
- package/dist/constants.d.ts +1 -4
- package/dist/constants.js +5 -4
- package/dist/extensions/route.d.ts +36 -36
- package/dist/extensions/route.js +7 -6
- package/dist/helpers/form-data.d.ts +1 -1
- package/dist/helpers/form-data.js +74 -86
- package/dist/helpers/index.d.ts +2 -1
- package/dist/helpers/index.js +1 -1
- package/dist/index.d.ts +15 -13
- package/dist/index.js +11 -11
- package/dist/meta.d.ts +298 -298
- package/dist/meta.js +54 -72
- package/dist/openapi-generator-components.d.ts +2 -31
- package/dist/openapi-generator-components.js +200 -248
- package/dist/openapi-generator-operation.d.ts +12 -33
- package/dist/openapi-generator-operation.js +369 -437
- package/dist/openapi-generator.d.ts +75 -80
- package/dist/openapi-generator.js +114 -142
- package/dist/openapi-json-serializer.d.ts +65 -65
- package/dist/openapi-json-serializer.js +218 -257
- package/dist/openapi-serializer.d.ts +31 -32
- package/dist/openapi-serializer.js +68 -92
- package/dist/plugins/index.d.ts +2 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/openapi-reference.d.ts +99 -102
- package/dist/plugins/openapi-reference.js +109 -132
- package/dist/router-utils.d.ts +7 -10
- package/dist/router-utils.js +30 -34
- package/dist/types.d.ts +8 -12
- package/dist/utils.d.ts +5 -10
- package/dist/utils.js +39 -42
- package/package.json +12 -12
- package/dist/adapters/standard/utils.d.ts +0 -4
- package/dist/types.js +0 -1
package/dist/bracket-notation.js
CHANGED
|
@@ -1,185 +1,135 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
current.push(value);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
internalSetOwn(currentRef, nextSegment, [current, value]);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
internalSetOwn(currentRef, nextSegment, value);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return root;
|
|
99
|
-
}
|
|
100
|
-
stringifyPath(segments) {
|
|
101
|
-
if (segments.length === 0) {
|
|
102
|
-
return '';
|
|
103
|
-
}
|
|
104
|
-
let result = segments[0].toString();
|
|
105
|
-
for (let i = 1; i < segments.length; i++) {
|
|
106
|
-
result += `[${segments[i]}]`;
|
|
107
|
-
}
|
|
108
|
-
return result;
|
|
109
|
-
}
|
|
110
|
-
parsePath(path) {
|
|
111
|
-
const start = path.indexOf('[');
|
|
112
|
-
// Brackets must open after the first segment and close at the very end, e.g. `a[b][c]`
|
|
113
|
-
if (start === -1 || path[path.length - 1] !== ']') {
|
|
114
|
-
return [path];
|
|
115
|
-
}
|
|
116
|
-
const segments = [path.slice(0, start)];
|
|
117
|
-
let from = start + 1;
|
|
118
|
-
let to = path.indexOf('][', from);
|
|
119
|
-
while (to !== -1) {
|
|
120
|
-
segments.push(path.slice(from, to));
|
|
121
|
-
from = to + 2;
|
|
122
|
-
to = path.indexOf('][', from);
|
|
123
|
-
}
|
|
124
|
-
segments.push(path.slice(from, -1));
|
|
125
|
-
return segments;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
1
|
+
import { NullProtoObj, isPlainObject, setOwn } from "@orpc/shared";
|
|
2
|
+
// src/bracket-notation.ts
|
|
3
|
+
var BracketNotationSerializer = class {
|
|
4
|
+
maxDeserializingEmptySlots;
|
|
5
|
+
constructor(options = {}) {
|
|
6
|
+
this.maxDeserializingEmptySlots = options.maxDeserializingEmptySlots ?? 1e3;
|
|
7
|
+
}
|
|
8
|
+
serialize(data) {
|
|
9
|
+
const result = [];
|
|
10
|
+
this.internalSerialize(data, "", true, result);
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
internalSerialize(data, path, isRoot, result) {
|
|
14
|
+
if (Array.isArray(data)) data.forEach((item, i) => {
|
|
15
|
+
this.internalSerialize(item, isRoot ? i.toString() : `${path}[${i}]`, false, result);
|
|
16
|
+
});
|
|
17
|
+
else if (isPlainObject(data)) for (const key of Object.keys(data)) this.internalSerialize(data[key], isRoot ? key : `${path}[${key}]`, false, result);
|
|
18
|
+
else result.push([path, data]);
|
|
19
|
+
}
|
|
20
|
+
deserialize(serialized) {
|
|
21
|
+
let arrayPushStyles;
|
|
22
|
+
const root = new NullProtoObj();
|
|
23
|
+
let emptySlotsLeft = this.maxDeserializingEmptySlots;
|
|
24
|
+
for (const [path, value] of serialized) {
|
|
25
|
+
const segments = this.parsePath(path);
|
|
26
|
+
let currentRef = root;
|
|
27
|
+
let nextSegment = segments[0];
|
|
28
|
+
for (let i = 1; i < segments.length; i++) {
|
|
29
|
+
const segment = segments[i];
|
|
30
|
+
const isLast = i === segments.length - 1;
|
|
31
|
+
const hasExisting = Object.hasOwn(currentRef, nextSegment);
|
|
32
|
+
const existing = hasExisting ? currentRef[nextSegment] : void 0;
|
|
33
|
+
let child = existing;
|
|
34
|
+
let key = segment;
|
|
35
|
+
if (Array.isArray(child) || !isPlainObject(child)) {
|
|
36
|
+
if (hasExisting && !Array.isArray(child)) child = [child];
|
|
37
|
+
const isArray = Array.isArray(child);
|
|
38
|
+
const isPushStyle = isArray && !!arrayPushStyles?.has(child);
|
|
39
|
+
const length = isArray ? child.length : 0;
|
|
40
|
+
const index = internalToArrayIndex(segment);
|
|
41
|
+
const emptySlots = index === void 0 ? 0 : Math.max(0, index - length);
|
|
42
|
+
if (segment === "" ? isLast && (isPushStyle || length === 0) : index !== void 0 && !(isLast && isPushStyle) && emptySlots <= emptySlotsLeft) {
|
|
43
|
+
emptySlotsLeft -= emptySlots;
|
|
44
|
+
child = isArray ? child : [];
|
|
45
|
+
key = index ?? segment;
|
|
46
|
+
} else if (isArray) {
|
|
47
|
+
arrayPushStyles?.delete(child);
|
|
48
|
+
child = isPushStyle ? internalPushStyleArrayToObject(child) : internalArrayToObject(child);
|
|
49
|
+
} else child = new NullProtoObj();
|
|
50
|
+
}
|
|
51
|
+
if (child !== existing) internalSetOwn(currentRef, nextSegment, child);
|
|
52
|
+
currentRef = child;
|
|
53
|
+
nextSegment = key;
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(currentRef) && nextSegment === "") {
|
|
56
|
+
arrayPushStyles ??= /* @__PURE__ */ new WeakSet();
|
|
57
|
+
arrayPushStyles.add(currentRef);
|
|
58
|
+
currentRef.push(value);
|
|
59
|
+
} else if (Object.hasOwn(currentRef, nextSegment)) {
|
|
60
|
+
const current = currentRef[nextSegment];
|
|
61
|
+
if (Array.isArray(current)) current.push(value);
|
|
62
|
+
else internalSetOwn(currentRef, nextSegment, [current, value]);
|
|
63
|
+
} else internalSetOwn(currentRef, nextSegment, value);
|
|
64
|
+
}
|
|
65
|
+
return root;
|
|
66
|
+
}
|
|
67
|
+
stringifyPath(segments) {
|
|
68
|
+
if (segments.length === 0) return "";
|
|
69
|
+
let result = segments[0].toString();
|
|
70
|
+
for (let i = 1; i < segments.length; i++) result += `[${segments[i]}]`;
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
parsePath(path) {
|
|
74
|
+
const start = path.indexOf("[");
|
|
75
|
+
if (start === -1 || path[path.length - 1] !== "]") return [path];
|
|
76
|
+
const segments = [path.slice(0, start)];
|
|
77
|
+
let from = start + 1;
|
|
78
|
+
let to = path.indexOf("][", from);
|
|
79
|
+
while (to !== -1) {
|
|
80
|
+
segments.push(path.slice(from, to));
|
|
81
|
+
from = to + 2;
|
|
82
|
+
to = path.indexOf("][", from);
|
|
83
|
+
}
|
|
84
|
+
segments.push(path.slice(from, -1));
|
|
85
|
+
return segments;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
128
88
|
/**
|
|
129
|
-
|
|
130
|
-
|
|
89
|
+
* The largest array index. Larger integer keys are ordinary properties.
|
|
90
|
+
*/
|
|
131
91
|
const MAX_ARRAY_INDEX = 2 ** 32 - 2;
|
|
132
92
|
/**
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
93
|
+
* Returns `key` as an array index (no sign, no leading zeros), which is also how engines store the
|
|
94
|
+
* integer keys of objects, or `undefined` if it is not one.
|
|
95
|
+
*/
|
|
136
96
|
function internalToArrayIndex(key) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const digit = key.charCodeAt(i) - 48;
|
|
147
|
-
if (digit < 0 || digit > 9) {
|
|
148
|
-
return undefined;
|
|
149
|
-
}
|
|
150
|
-
index = index * 10 + digit;
|
|
151
|
-
}
|
|
152
|
-
return index <= MAX_ARRAY_INDEX ? index : undefined;
|
|
97
|
+
if (key.length === 0 || key.length > 10) return;
|
|
98
|
+
let index = key.charCodeAt(0) - 48;
|
|
99
|
+
if (index < 0 || index > 9 || index === 0 && key.length > 1) return;
|
|
100
|
+
for (let i = 1; i < key.length; i++) {
|
|
101
|
+
const digit = key.charCodeAt(i) - 48;
|
|
102
|
+
if (digit < 0 || digit > 9) return;
|
|
103
|
+
index = index * 10 + digit;
|
|
104
|
+
}
|
|
105
|
+
return index <= MAX_ARRAY_INDEX ? index : void 0;
|
|
153
106
|
}
|
|
154
107
|
function internalArrayToObject(array) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
108
|
+
const obj = new NullProtoObj();
|
|
109
|
+
array.forEach((item, i) => {
|
|
110
|
+
obj[i] = item;
|
|
111
|
+
});
|
|
112
|
+
return obj;
|
|
160
113
|
}
|
|
161
114
|
function internalPushStyleArrayToObject(array) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
115
|
+
const obj = new NullProtoObj();
|
|
116
|
+
obj[""] = array.length === 1 ? array[0] : array;
|
|
117
|
+
return obj;
|
|
165
118
|
}
|
|
166
119
|
/**
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
120
|
+
* Like `setOwn`, but first switches an object created during deserialization to sparse storage when an
|
|
121
|
+
* integer key would leave a gap. Engines keep integer keys in a flat backing store sized by the largest one,
|
|
122
|
+
* so a lone `{ 999: x }` takes ~12KB in V8. Holding `MAX_ARRAY_INDEX` switches an object to sparse storage
|
|
123
|
+
* for good (V8 and JSC), so writing and deleting it keeps the object's integer keys cheap without a trace.
|
|
124
|
+
*/
|
|
172
125
|
function internalSetOwn(container, key, value) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
delete container[MAX_ARRAY_INDEX];
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
setOwn(container, key, value);
|
|
126
|
+
if (typeof key === "string" && container instanceof NullProtoObj) {
|
|
127
|
+
const index = internalToArrayIndex(key);
|
|
128
|
+
if (index !== void 0 && index !== 0 && !Object.hasOwn(container, index - 1) && !Object.hasOwn(container, MAX_ARRAY_INDEX)) {
|
|
129
|
+
container[MAX_ARRAY_INDEX] = void 0;
|
|
130
|
+
delete container[MAX_ARRAY_INDEX];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
setOwn(container, key, value);
|
|
185
134
|
}
|
|
135
|
+
export { BracketNotationSerializer };
|
package/dist/client-factory.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { JsonifiedClient } from "./types.js";
|
|
2
|
+
import { RouterContract, RouterContractClient } from "@orpc/contract";
|
|
3
|
+
import { ClientContext, ClientLink, ORPCClientOptions } from "@orpc/client";
|
|
4
4
|
export interface ContractJsonifiedClientFactory<TClientContext extends ClientContext> {
|
|
5
|
-
|
|
5
|
+
<T extends RouterContract>(contract: T): JsonifiedClient<RouterContractClient<T, TClientContext>>;
|
|
6
6
|
}
|
|
7
|
-
export interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientContext> extends Pick<ORPCClientOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
export interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientContext> extends Pick<ORPCClientOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>, "interceptors" | "scoped"> {
|
|
8
|
+
/**
|
|
9
|
+
* An optional reference to the root router-contract.
|
|
10
|
+
* When provided, the client factory will automatically register the passed contract
|
|
11
|
+
* into the router at the path defined by `meta.path`.
|
|
12
|
+
*/
|
|
13
|
+
contractRef?: RouterContract | undefined;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Like `createContractClientFactory`, but the clients it builds are typed as `JsonifiedClient`,
|
|
@@ -21,4 +21,4 @@ export interface ContractJsonifiedClientFactoryOptions<TClientContext extends Cl
|
|
|
21
21
|
*
|
|
22
22
|
* @see {@link https://orpc.dev/docs/contract/client-factory | Contract Client Factory}
|
|
23
23
|
*/
|
|
24
|
-
export declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
|
|
24
|
+
export declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
|
package/dist/client-factory.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { createContractClientFactory } from
|
|
1
|
+
import { createContractClientFactory } from "@orpc/contract";
|
|
2
|
+
// src/client-factory.ts
|
|
2
3
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
* Like `createContractClientFactory`, but the clients it builds are typed as `JsonifiedClient`,
|
|
5
|
+
* for links that require it, such as OpenAPI Link.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* **Warning**: Every procedure contract passed to the factory must define `meta.path` matching its location in the root contract.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://orpc.dev/docs/contract/client-factory | Contract Client Factory}
|
|
11
|
+
*/
|
|
12
|
+
function createContractJsonifiedClientFactory(link, options = {}) {
|
|
13
|
+
return createContractClientFactory(link, options);
|
|
13
14
|
}
|
|
15
|
+
export { createContractJsonifiedClientFactory };
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export declare const DEFAULT_OPENAPI_METHOD = "POST";
|
|
2
|
-
export declare const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = "OK";
|
|
3
|
-
export declare const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
|
|
4
|
-
export declare const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
|
|
1
|
+
export declare const DEFAULT_OPENAPI_METHOD = "POST";
|
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// src/constants.ts
|
|
2
|
+
const DEFAULT_OPENAPI_METHOD = "POST";
|
|
3
|
+
const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
|
|
4
|
+
const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
|
|
5
|
+
export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE };
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
declare module
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
declare module '@orpc/server' {
|
|
19
|
-
interface Builder<TInitialContext extends Context, TErrorMap extends ErrorMap> {
|
|
20
|
-
route(meta: OpenAPIMeta): Builder<TInitialContext, TErrorMap>;
|
|
21
|
-
}
|
|
22
|
-
interface BuilderWithMiddlewares<TInitialContext extends Context, TInjectedContext extends Context, TErrorMap extends ErrorMap> {
|
|
23
|
-
route(meta: OpenAPIMeta): BuilderWithMiddlewares<TInitialContext, TInjectedContext, TErrorMap>;
|
|
24
|
-
}
|
|
25
|
-
interface BuilderWithInput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
26
|
-
route(meta: OpenAPIMeta): BuilderWithInput<TInitialContext, TInjectedContext, TInputSchema, TErrorMap>;
|
|
27
|
-
}
|
|
28
|
-
interface BuilderWithOutput<TInitialContext extends Context, TInjectedContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
29
|
-
route(meta: OpenAPIMeta): BuilderWithOutput<TInitialContext, TInjectedContext, TOutputSchema, TErrorMap>;
|
|
30
|
-
}
|
|
31
|
-
interface BuilderWithInputOutput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
32
|
-
route(meta: OpenAPIMeta): BuilderWithInputOutput<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
33
|
-
}
|
|
34
|
-
interface DecoratedProcedure<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
35
|
-
route(meta: OpenAPIMeta): DecoratedProcedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
36
|
-
}
|
|
1
|
+
import { OpenAPIMeta } from "../meta.js";
|
|
2
|
+
import { AnySchema, ErrorMap } from "@orpc/contract";
|
|
3
|
+
import { Context } from "@orpc/server";
|
|
4
|
+
declare module "@orpc/contract" {
|
|
5
|
+
interface ContractBuilder<TErrorMap extends ErrorMap> {
|
|
6
|
+
route(meta: OpenAPIMeta): ContractBuilder<TErrorMap>;
|
|
7
|
+
}
|
|
8
|
+
interface ProcedureContractBuilderWithInput<TInputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
9
|
+
route(meta: OpenAPIMeta): ProcedureContractBuilderWithInput<TInputSchema, TErrorMap>;
|
|
10
|
+
}
|
|
11
|
+
interface ProcedureContractBuilderWithOutput<TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
12
|
+
route(meta: OpenAPIMeta): ProcedureContractBuilderWithOutput<TOutputSchema, TErrorMap>;
|
|
13
|
+
}
|
|
14
|
+
interface ProcedureContractBuilderWithInputOutput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
15
|
+
route(meta: OpenAPIMeta): ProcedureContractBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap>;
|
|
16
|
+
}
|
|
37
17
|
}
|
|
18
|
+
declare module "@orpc/server" {
|
|
19
|
+
interface Builder<TInitialContext extends Context, TErrorMap extends ErrorMap> {
|
|
20
|
+
route(meta: OpenAPIMeta): Builder<TInitialContext, TErrorMap>;
|
|
21
|
+
}
|
|
22
|
+
interface BuilderWithMiddlewares<TInitialContext extends Context, TInjectedContext extends Context, TErrorMap extends ErrorMap> {
|
|
23
|
+
route(meta: OpenAPIMeta): BuilderWithMiddlewares<TInitialContext, TInjectedContext, TErrorMap>;
|
|
24
|
+
}
|
|
25
|
+
interface BuilderWithInput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
26
|
+
route(meta: OpenAPIMeta): BuilderWithInput<TInitialContext, TInjectedContext, TInputSchema, TErrorMap>;
|
|
27
|
+
}
|
|
28
|
+
interface BuilderWithOutput<TInitialContext extends Context, TInjectedContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
29
|
+
route(meta: OpenAPIMeta): BuilderWithOutput<TInitialContext, TInjectedContext, TOutputSchema, TErrorMap>;
|
|
30
|
+
}
|
|
31
|
+
interface BuilderWithInputOutput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
32
|
+
route(meta: OpenAPIMeta): BuilderWithInputOutput<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
33
|
+
}
|
|
34
|
+
interface DecoratedProcedure<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
35
|
+
route(meta: OpenAPIMeta): DecoratedProcedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
36
|
+
}
|
|
37
|
+
}
|
package/dist/extensions/route.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { openapi } from "../meta.js";
|
|
2
|
+
import { ContractBuilder } from "@orpc/contract";
|
|
3
|
+
import { Builder, DecoratedProcedure } from "@orpc/server";
|
|
4
|
+
// src/extensions/route.ts
|
|
4
5
|
ContractBuilder.prototype.route = function route(meta) {
|
|
5
|
-
|
|
6
|
+
return this.meta(openapi(meta));
|
|
6
7
|
};
|
|
7
8
|
Builder.prototype.route = function route(meta) {
|
|
8
|
-
|
|
9
|
+
return this.meta(openapi(meta));
|
|
9
10
|
};
|
|
10
11
|
DecoratedProcedure.prototype.route = function route(meta) {
|
|
11
|
-
|
|
12
|
+
return this.meta(openapi(meta));
|
|
12
13
|
};
|
|
@@ -54,4 +54,4 @@ export declare function parseFormData(form: FormData): any;
|
|
|
54
54
|
*
|
|
55
55
|
* @see {@link https://orpc.dev/docs/helpers/form-data#getissuemessage | Form Data Helpers - getIssueMessage}
|
|
56
56
|
*/
|
|
57
|
-
export declare function getIssueMessage(error: unknown, path: string): string | undefined;
|
|
57
|
+
export declare function getIssueMessage(error: unknown, path: string): string | undefined;
|