@orpc/openapi 0.34.0 → 0.35.1
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/chunk-BHJYKXQL.js +52 -0
- package/dist/chunk-HQ34JZI7.js +32 -0
- package/dist/chunk-M5HOHBLW.js +432 -0
- package/dist/fetch.js +5 -30
- package/dist/hono.js +5 -30
- package/dist/index.js +6 -6
- package/dist/next.js +5 -30
- package/dist/node.js +18 -34
- package/dist/src/adapters/fetch/index.d.ts +0 -8
- package/dist/src/adapters/fetch/openapi-handler.d.ts +6 -28
- package/dist/src/adapters/node/index.d.ts +0 -3
- package/dist/src/adapters/node/openapi-handler.d.ts +7 -8
- package/dist/src/adapters/standard/index.d.ts +7 -0
- package/dist/src/adapters/standard/openapi-codec.d.ts +18 -0
- package/dist/src/adapters/standard/openapi-handler.d.ts +7 -0
- package/dist/src/adapters/standard/openapi-matcher.d.ts +20 -0
- package/dist/src/adapters/standard/openapi-serializer.d.ts +11 -0
- package/dist/src/openapi-generator.d.ts +1 -1
- package/dist/src/utils.d.ts +1 -16
- package/dist/standard.js +16 -0
- package/package.json +10 -5
- package/dist/chunk-Q2LSK6YZ.js +0 -102
- package/dist/chunk-SOVQ5ARD.js +0 -650
- package/dist/chunk-VFGNQS5W.js +0 -25
- package/dist/src/adapters/fetch/input-structure-compact.d.ts +0 -6
- package/dist/src/adapters/fetch/input-structure-detailed.d.ts +0 -11
- package/dist/src/adapters/fetch/openapi-handler-server.d.ts +0 -7
- package/dist/src/adapters/fetch/openapi-handler-serverless.d.ts +0 -7
- package/dist/src/adapters/fetch/openapi-payload-codec.d.ts +0 -15
- package/dist/src/adapters/fetch/openapi-procedure-matcher.d.ts +0 -19
- package/dist/src/adapters/node/openapi-handler-server.d.ts +0 -7
- package/dist/src/adapters/node/openapi-handler-serverless.d.ts +0 -7
- package/dist/src/adapters/node/types.d.ts +0 -2
- /package/dist/src/adapters/{fetch → standard}/bracket-notation.d.ts +0 -0
- /package/dist/src/adapters/{fetch → standard}/schema-coercer.d.ts +0 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __export = (target, all) => {
|
3
|
+
for (var name in all)
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
5
|
+
};
|
6
|
+
|
7
|
+
// src/json-serializer.ts
|
8
|
+
import { isPlainObject } from "@orpc/shared";
|
9
|
+
var JSONSerializer = class {
|
10
|
+
serialize(payload) {
|
11
|
+
if (payload instanceof Set)
|
12
|
+
return this.serialize([...payload]);
|
13
|
+
if (payload instanceof Map)
|
14
|
+
return this.serialize([...payload.entries()]);
|
15
|
+
if (Array.isArray(payload)) {
|
16
|
+
return payload.map((v) => v === void 0 ? "undefined" : this.serialize(v));
|
17
|
+
}
|
18
|
+
if (Number.isNaN(payload))
|
19
|
+
return "NaN";
|
20
|
+
if (typeof payload === "bigint")
|
21
|
+
return payload.toString();
|
22
|
+
if (payload instanceof Date && Number.isNaN(payload.getTime())) {
|
23
|
+
return "Invalid Date";
|
24
|
+
}
|
25
|
+
if (payload instanceof RegExp)
|
26
|
+
return payload.toString();
|
27
|
+
if (payload instanceof URL)
|
28
|
+
return payload.toString();
|
29
|
+
if (!isPlainObject(payload))
|
30
|
+
return payload;
|
31
|
+
return Object.keys(payload).reduce(
|
32
|
+
(carry, key) => {
|
33
|
+
const val = payload[key];
|
34
|
+
carry[key] = this.serialize(val);
|
35
|
+
return carry;
|
36
|
+
},
|
37
|
+
{}
|
38
|
+
);
|
39
|
+
}
|
40
|
+
};
|
41
|
+
|
42
|
+
// src/utils.ts
|
43
|
+
function standardizeHTTPPath(path) {
|
44
|
+
return `/${path.replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "")}`;
|
45
|
+
}
|
46
|
+
|
47
|
+
export {
|
48
|
+
__export,
|
49
|
+
JSONSerializer,
|
50
|
+
standardizeHTTPPath
|
51
|
+
};
|
52
|
+
//# sourceMappingURL=chunk-BHJYKXQL.js.map
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import {
|
2
|
+
OpenAPICodec,
|
3
|
+
OpenAPIMatcher
|
4
|
+
} from "./chunk-M5HOHBLW.js";
|
5
|
+
|
6
|
+
// src/adapters/fetch/openapi-handler.ts
|
7
|
+
import { fetchRequestToStandardRequest, standardResponseToFetchResponse } from "@orpc/server/fetch";
|
8
|
+
import { StandardHandler } from "@orpc/server/standard";
|
9
|
+
var OpenAPIHandler = class {
|
10
|
+
standardHandler;
|
11
|
+
constructor(router, options) {
|
12
|
+
const matcher = options?.matcher ?? new OpenAPIMatcher(options);
|
13
|
+
const codec = options?.codec ?? new OpenAPICodec(options);
|
14
|
+
this.standardHandler = new StandardHandler(router, matcher, codec, options);
|
15
|
+
}
|
16
|
+
async handle(request, ...rest) {
|
17
|
+
const standardRequest = fetchRequestToStandardRequest(request);
|
18
|
+
const result = await this.standardHandler.handle(standardRequest, ...rest);
|
19
|
+
if (!result.matched) {
|
20
|
+
return result;
|
21
|
+
}
|
22
|
+
return {
|
23
|
+
matched: true,
|
24
|
+
response: standardResponseToFetchResponse(result.response)
|
25
|
+
};
|
26
|
+
}
|
27
|
+
};
|
28
|
+
|
29
|
+
export {
|
30
|
+
OpenAPIHandler
|
31
|
+
};
|
32
|
+
//# sourceMappingURL=chunk-HQ34JZI7.js.map
|
@@ -0,0 +1,432 @@
|
|
1
|
+
import {
|
2
|
+
JSONSerializer,
|
3
|
+
__export,
|
4
|
+
standardizeHTTPPath
|
5
|
+
} from "./chunk-BHJYKXQL.js";
|
6
|
+
|
7
|
+
// src/adapters/standard/bracket-notation.ts
|
8
|
+
var bracket_notation_exports = {};
|
9
|
+
__export(bracket_notation_exports, {
|
10
|
+
deserialize: () => deserialize,
|
11
|
+
escapeSegment: () => escapeSegment,
|
12
|
+
parsePath: () => parsePath,
|
13
|
+
serialize: () => serialize,
|
14
|
+
stringifyPath: () => stringifyPath
|
15
|
+
});
|
16
|
+
import { isPlainObject } from "@orpc/shared";
|
17
|
+
function serialize(payload, parentKey = "") {
|
18
|
+
if (!Array.isArray(payload) && !isPlainObject(payload))
|
19
|
+
return [["", payload]];
|
20
|
+
const result = [];
|
21
|
+
function helper(value, path) {
|
22
|
+
if (Array.isArray(value)) {
|
23
|
+
value.forEach((item, index) => {
|
24
|
+
helper(item, [...path, String(index)]);
|
25
|
+
});
|
26
|
+
} else if (isPlainObject(value)) {
|
27
|
+
for (const [key, val] of Object.entries(value)) {
|
28
|
+
helper(val, [...path, key]);
|
29
|
+
}
|
30
|
+
} else {
|
31
|
+
result.push([stringifyPath(path), value]);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
helper(payload, parentKey ? [parentKey] : []);
|
35
|
+
return result;
|
36
|
+
}
|
37
|
+
function deserialize(entities) {
|
38
|
+
if (entities.length === 0) {
|
39
|
+
return void 0;
|
40
|
+
}
|
41
|
+
const isRootArray = entities.every(([path]) => path === "");
|
42
|
+
const result = isRootArray ? [] : {};
|
43
|
+
const arrayPushPaths = /* @__PURE__ */ new Set();
|
44
|
+
for (const [path, _] of entities) {
|
45
|
+
const segments = parsePath(path);
|
46
|
+
const base = segments.slice(0, -1).join(".");
|
47
|
+
const last = segments[segments.length - 1];
|
48
|
+
if (last === "") {
|
49
|
+
arrayPushPaths.add(base);
|
50
|
+
} else {
|
51
|
+
arrayPushPaths.delete(base);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
function setValue(obj, segments, value, fullPath) {
|
55
|
+
const [first, ...rest_] = segments;
|
56
|
+
if (Array.isArray(obj) && first === "") {
|
57
|
+
;
|
58
|
+
obj.push(value);
|
59
|
+
return;
|
60
|
+
}
|
61
|
+
const objAsRecord = obj;
|
62
|
+
if (rest_.length === 0) {
|
63
|
+
objAsRecord[first] = value;
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
const rest = rest_;
|
67
|
+
if (rest[0] === "") {
|
68
|
+
const pathToCheck = segments.slice(0, -1).join(".");
|
69
|
+
if (rest.length === 1 && arrayPushPaths.has(pathToCheck)) {
|
70
|
+
if (!(first in objAsRecord)) {
|
71
|
+
objAsRecord[first] = [];
|
72
|
+
}
|
73
|
+
if (Array.isArray(objAsRecord[first])) {
|
74
|
+
;
|
75
|
+
objAsRecord[first].push(value);
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
if (!(first in objAsRecord)) {
|
80
|
+
objAsRecord[first] = {};
|
81
|
+
}
|
82
|
+
const target = objAsRecord[first];
|
83
|
+
target[""] = value;
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
if (!(first in objAsRecord)) {
|
87
|
+
objAsRecord[first] = {};
|
88
|
+
}
|
89
|
+
setValue(
|
90
|
+
objAsRecord[first],
|
91
|
+
rest,
|
92
|
+
value,
|
93
|
+
fullPath
|
94
|
+
);
|
95
|
+
}
|
96
|
+
for (const [path, value] of entities) {
|
97
|
+
const segments = parsePath(path);
|
98
|
+
setValue(result, segments, value, path);
|
99
|
+
}
|
100
|
+
return result;
|
101
|
+
}
|
102
|
+
function escapeSegment(segment) {
|
103
|
+
return segment.replace(/[\\[\]]/g, (match) => {
|
104
|
+
switch (match) {
|
105
|
+
case "\\":
|
106
|
+
return "\\\\";
|
107
|
+
case "[":
|
108
|
+
return "\\[";
|
109
|
+
case "]":
|
110
|
+
return "\\]";
|
111
|
+
default:
|
112
|
+
return match;
|
113
|
+
}
|
114
|
+
});
|
115
|
+
}
|
116
|
+
function stringifyPath(path) {
|
117
|
+
const [first, ...rest] = path;
|
118
|
+
const firstSegment = escapeSegment(first);
|
119
|
+
const base = first === "" ? "" : firstSegment;
|
120
|
+
return rest.reduce(
|
121
|
+
(result, segment) => `${result}[${escapeSegment(segment)}]`,
|
122
|
+
base
|
123
|
+
);
|
124
|
+
}
|
125
|
+
function parsePath(path) {
|
126
|
+
if (path === "")
|
127
|
+
return [""];
|
128
|
+
const result = [];
|
129
|
+
let currentSegment = "";
|
130
|
+
let inBracket = false;
|
131
|
+
let bracketContent = "";
|
132
|
+
let backslashCount = 0;
|
133
|
+
for (let i = 0; i < path.length; i++) {
|
134
|
+
const char = path[i];
|
135
|
+
if (char === "\\") {
|
136
|
+
backslashCount++;
|
137
|
+
continue;
|
138
|
+
}
|
139
|
+
if (backslashCount > 0) {
|
140
|
+
const literalBackslashes = "\\".repeat(Math.floor(backslashCount / 2));
|
141
|
+
if (char === "[" || char === "]") {
|
142
|
+
if (backslashCount % 2 === 1) {
|
143
|
+
if (inBracket) {
|
144
|
+
bracketContent += literalBackslashes + char;
|
145
|
+
} else {
|
146
|
+
currentSegment += literalBackslashes + char;
|
147
|
+
}
|
148
|
+
} else {
|
149
|
+
if (inBracket) {
|
150
|
+
bracketContent += literalBackslashes;
|
151
|
+
} else {
|
152
|
+
currentSegment += literalBackslashes;
|
153
|
+
}
|
154
|
+
if (char === "[" && !inBracket) {
|
155
|
+
if (currentSegment !== "" || result.length === 0) {
|
156
|
+
result.push(currentSegment);
|
157
|
+
}
|
158
|
+
inBracket = true;
|
159
|
+
bracketContent = "";
|
160
|
+
currentSegment = "";
|
161
|
+
} else if (char === "]" && inBracket) {
|
162
|
+
result.push(bracketContent);
|
163
|
+
inBracket = false;
|
164
|
+
bracketContent = "";
|
165
|
+
} else {
|
166
|
+
if (inBracket) {
|
167
|
+
bracketContent += char;
|
168
|
+
} else {
|
169
|
+
currentSegment += char;
|
170
|
+
}
|
171
|
+
}
|
172
|
+
}
|
173
|
+
} else {
|
174
|
+
const allBackslashes = "\\".repeat(backslashCount);
|
175
|
+
if (inBracket) {
|
176
|
+
bracketContent += allBackslashes + char;
|
177
|
+
} else {
|
178
|
+
currentSegment += allBackslashes + char;
|
179
|
+
}
|
180
|
+
}
|
181
|
+
backslashCount = 0;
|
182
|
+
continue;
|
183
|
+
}
|
184
|
+
if (char === "[" && !inBracket) {
|
185
|
+
if (currentSegment !== "" || result.length === 0) {
|
186
|
+
result.push(currentSegment);
|
187
|
+
}
|
188
|
+
inBracket = true;
|
189
|
+
bracketContent = "";
|
190
|
+
currentSegment = "";
|
191
|
+
continue;
|
192
|
+
}
|
193
|
+
if (char === "]" && inBracket) {
|
194
|
+
result.push(bracketContent);
|
195
|
+
inBracket = false;
|
196
|
+
bracketContent = "";
|
197
|
+
continue;
|
198
|
+
}
|
199
|
+
if (inBracket) {
|
200
|
+
bracketContent += char;
|
201
|
+
} else {
|
202
|
+
currentSegment += char;
|
203
|
+
}
|
204
|
+
}
|
205
|
+
if (backslashCount > 0) {
|
206
|
+
const remainingBackslashes = "\\".repeat(backslashCount);
|
207
|
+
if (inBracket) {
|
208
|
+
bracketContent += remainingBackslashes;
|
209
|
+
} else {
|
210
|
+
currentSegment += remainingBackslashes;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
if (inBracket) {
|
214
|
+
if (currentSegment !== "" || result.length === 0) {
|
215
|
+
result.push(currentSegment);
|
216
|
+
}
|
217
|
+
result.push(`[${bracketContent}`);
|
218
|
+
} else if (currentSegment !== "" || result.length === 0) {
|
219
|
+
result.push(currentSegment);
|
220
|
+
}
|
221
|
+
return result;
|
222
|
+
}
|
223
|
+
|
224
|
+
// src/adapters/standard/openapi-codec.ts
|
225
|
+
import { fallbackContractConfig } from "@orpc/contract";
|
226
|
+
import { isPlainObject as isPlainObject2, once } from "@orpc/shared";
|
227
|
+
|
228
|
+
// src/adapters/standard/openapi-serializer.ts
|
229
|
+
import { findDeepMatches } from "@orpc/shared";
|
230
|
+
var OpenAPISerializer = class {
|
231
|
+
jsonSerializer;
|
232
|
+
constructor(options) {
|
233
|
+
this.jsonSerializer = options?.jsonSerializer ?? new JSONSerializer();
|
234
|
+
}
|
235
|
+
serialize(data) {
|
236
|
+
if (data instanceof Blob || data === void 0) {
|
237
|
+
return data;
|
238
|
+
}
|
239
|
+
const serializedJSON = this.jsonSerializer.serialize(data);
|
240
|
+
const { values: blobs } = findDeepMatches((v) => v instanceof Blob, serializedJSON);
|
241
|
+
if (blobs.length === 0) {
|
242
|
+
return serializedJSON;
|
243
|
+
}
|
244
|
+
const form = new FormData();
|
245
|
+
for (const [path, value] of serialize(serializedJSON)) {
|
246
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
247
|
+
form.append(path, value.toString());
|
248
|
+
} else if (value instanceof Date) {
|
249
|
+
form.append(path, value.toISOString());
|
250
|
+
} else if (value instanceof Blob) {
|
251
|
+
form.append(path, value);
|
252
|
+
}
|
253
|
+
}
|
254
|
+
return form;
|
255
|
+
}
|
256
|
+
deserialize(serialized) {
|
257
|
+
if (serialized instanceof URLSearchParams || serialized instanceof FormData) {
|
258
|
+
return deserialize([...serialized.entries()]);
|
259
|
+
}
|
260
|
+
return serialized;
|
261
|
+
}
|
262
|
+
};
|
263
|
+
|
264
|
+
// src/adapters/standard/schema-coercer.ts
|
265
|
+
var CompositeSchemaCoercer = class {
|
266
|
+
constructor(coercers) {
|
267
|
+
this.coercers = coercers;
|
268
|
+
}
|
269
|
+
coerce(schema, value) {
|
270
|
+
let current = value;
|
271
|
+
for (const coercer of this.coercers) {
|
272
|
+
current = coercer.coerce(schema, current);
|
273
|
+
}
|
274
|
+
return current;
|
275
|
+
}
|
276
|
+
};
|
277
|
+
|
278
|
+
// src/adapters/standard/openapi-codec.ts
|
279
|
+
var OpenAPICodec = class {
|
280
|
+
serializer;
|
281
|
+
compositeSchemaCoercer;
|
282
|
+
constructor(options) {
|
283
|
+
this.serializer = options?.serializer ?? new OpenAPISerializer();
|
284
|
+
this.compositeSchemaCoercer = new CompositeSchemaCoercer(options?.schemaCoercers ?? []);
|
285
|
+
}
|
286
|
+
async decode(request, params, procedure) {
|
287
|
+
const inputStructure = fallbackContractConfig("defaultInputStructure", procedure["~orpc"].route.inputStructure);
|
288
|
+
if (inputStructure === "compact") {
|
289
|
+
const data = request.method === "GET" ? this.serializer.deserialize(request.url.searchParams) : this.serializer.deserialize(await request.body());
|
290
|
+
if (data === void 0) {
|
291
|
+
return this.compositeSchemaCoercer.coerce(procedure["~orpc"].inputSchema, params);
|
292
|
+
}
|
293
|
+
if (isPlainObject2(data)) {
|
294
|
+
return this.compositeSchemaCoercer.coerce(procedure["~orpc"].inputSchema, {
|
295
|
+
...params,
|
296
|
+
...data
|
297
|
+
});
|
298
|
+
}
|
299
|
+
return this.compositeSchemaCoercer.coerce(procedure["~orpc"].inputSchema, data);
|
300
|
+
}
|
301
|
+
const query = once(() => {
|
302
|
+
return this.serializer.deserialize(request.url.searchParams);
|
303
|
+
});
|
304
|
+
return this.compositeSchemaCoercer.coerce(procedure["~orpc"].inputSchema, {
|
305
|
+
params,
|
306
|
+
get query() {
|
307
|
+
return query();
|
308
|
+
},
|
309
|
+
headers: request.headers,
|
310
|
+
body: this.serializer.deserialize(await request.body())
|
311
|
+
});
|
312
|
+
}
|
313
|
+
encode(output, procedure) {
|
314
|
+
const successStatus = fallbackContractConfig("defaultSuccessStatus", procedure["~orpc"].route.successStatus);
|
315
|
+
const outputStructure = fallbackContractConfig("defaultOutputStructure", procedure["~orpc"].route.outputStructure);
|
316
|
+
if (outputStructure === "compact") {
|
317
|
+
return {
|
318
|
+
status: successStatus,
|
319
|
+
headers: {},
|
320
|
+
body: this.serializer.serialize(output)
|
321
|
+
};
|
322
|
+
}
|
323
|
+
if (!isPlainObject2(output)) {
|
324
|
+
throw new Error(
|
325
|
+
'Invalid output structure for "detailed" output. Expected format: { body: any, headers?: Record<string, string | string[] | undefined> }'
|
326
|
+
);
|
327
|
+
}
|
328
|
+
return {
|
329
|
+
status: successStatus,
|
330
|
+
headers: output.headers ?? {},
|
331
|
+
body: this.serializer.serialize(output.body)
|
332
|
+
};
|
333
|
+
}
|
334
|
+
encodeError(error) {
|
335
|
+
return {
|
336
|
+
status: error.status,
|
337
|
+
headers: {},
|
338
|
+
body: this.serializer.serialize(error.toJSON())
|
339
|
+
};
|
340
|
+
}
|
341
|
+
};
|
342
|
+
|
343
|
+
// src/adapters/standard/openapi-matcher.ts
|
344
|
+
import { fallbackContractConfig as fallbackContractConfig2 } from "@orpc/contract";
|
345
|
+
import { convertPathToHttpPath, createContractedProcedure, eachContractProcedure, getLazyRouterPrefix, getRouterChild, isProcedure, unlazy } from "@orpc/server";
|
346
|
+
import { addRoute, createRouter, findRoute } from "rou3";
|
347
|
+
var OpenAPIMatcher = class {
|
348
|
+
tree = createRouter();
|
349
|
+
ignoreUndefinedMethod;
|
350
|
+
constructor(options) {
|
351
|
+
this.ignoreUndefinedMethod = options?.ignoreUndefinedMethod ?? false;
|
352
|
+
}
|
353
|
+
pendingRouters = [];
|
354
|
+
init(router, path = []) {
|
355
|
+
const laziedOptions = eachContractProcedure({
|
356
|
+
router,
|
357
|
+
path
|
358
|
+
}, ({ path: path2, contract }) => {
|
359
|
+
if (!contract["~orpc"].route.method && this.ignoreUndefinedMethod) {
|
360
|
+
return;
|
361
|
+
}
|
362
|
+
const method = fallbackContractConfig2("defaultMethod", contract["~orpc"].route.method);
|
363
|
+
const httpPath = contract["~orpc"].route.path ? convertOpenAPIPathToRouterPath(contract["~orpc"].route.path) : convertPathToHttpPath(path2);
|
364
|
+
if (isProcedure(contract)) {
|
365
|
+
addRoute(this.tree, method, httpPath, {
|
366
|
+
path: path2,
|
367
|
+
contract,
|
368
|
+
procedure: contract,
|
369
|
+
// this mean dev not used contract-first so we can used contract as procedure directly
|
370
|
+
router
|
371
|
+
});
|
372
|
+
} else {
|
373
|
+
addRoute(this.tree, method, httpPath, {
|
374
|
+
path: path2,
|
375
|
+
contract,
|
376
|
+
procedure: void 0,
|
377
|
+
router
|
378
|
+
});
|
379
|
+
}
|
380
|
+
});
|
381
|
+
this.pendingRouters.push(...laziedOptions.map((option) => ({
|
382
|
+
...option,
|
383
|
+
httpPathPrefix: convertPathToHttpPath(option.path),
|
384
|
+
laziedPrefix: getLazyRouterPrefix(option.lazied)
|
385
|
+
})));
|
386
|
+
}
|
387
|
+
async match(method, pathname) {
|
388
|
+
if (this.pendingRouters.length) {
|
389
|
+
const newPendingRouters = [];
|
390
|
+
for (const pendingRouter of this.pendingRouters) {
|
391
|
+
if (!pendingRouter.laziedPrefix || pathname.startsWith(pendingRouter.laziedPrefix) || pathname.startsWith(pendingRouter.httpPathPrefix)) {
|
392
|
+
const { default: router } = await unlazy(pendingRouter.lazied);
|
393
|
+
this.init(router, pendingRouter.path);
|
394
|
+
} else {
|
395
|
+
newPendingRouters.push(pendingRouter);
|
396
|
+
}
|
397
|
+
}
|
398
|
+
this.pendingRouters = newPendingRouters;
|
399
|
+
}
|
400
|
+
const match = findRoute(this.tree, method, pathname);
|
401
|
+
if (!match) {
|
402
|
+
return void 0;
|
403
|
+
}
|
404
|
+
if (!match.data.procedure) {
|
405
|
+
const { default: maybeProcedure } = await unlazy(getRouterChild(match.data.router, ...match.data.path));
|
406
|
+
if (!isProcedure(maybeProcedure)) {
|
407
|
+
throw new Error(`
|
408
|
+
[Contract-First] Missing or invalid implementation for procedure at path: ${convertPathToHttpPath(match.data.path)}.
|
409
|
+
Ensure that the procedure is correctly defined and matches the expected contract.
|
410
|
+
`);
|
411
|
+
}
|
412
|
+
match.data.procedure = createContractedProcedure(match.data.contract, maybeProcedure);
|
413
|
+
}
|
414
|
+
return {
|
415
|
+
path: match.data.path,
|
416
|
+
procedure: match.data.procedure,
|
417
|
+
params: match.params
|
418
|
+
};
|
419
|
+
}
|
420
|
+
};
|
421
|
+
function convertOpenAPIPathToRouterPath(path) {
|
422
|
+
return standardizeHTTPPath(path).replace(/\{([^}]+)\}/g, ":$1");
|
423
|
+
}
|
424
|
+
|
425
|
+
export {
|
426
|
+
bracket_notation_exports,
|
427
|
+
OpenAPISerializer,
|
428
|
+
CompositeSchemaCoercer,
|
429
|
+
OpenAPICodec,
|
430
|
+
OpenAPIMatcher
|
431
|
+
};
|
432
|
+
//# sourceMappingURL=chunk-M5HOHBLW.js.map
|
package/dist/fetch.js
CHANGED
@@ -1,34 +1,9 @@
|
|
1
1
|
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
import
|
6
|
-
CompositeSchemaCoercer,
|
7
|
-
InputStructureCompact,
|
8
|
-
InputStructureDetailed,
|
9
|
-
OpenAPIHandler,
|
10
|
-
OpenAPIPayloadCodec,
|
11
|
-
OpenAPIProcedureMatcher,
|
12
|
-
deserialize,
|
13
|
-
escapeSegment,
|
14
|
-
parsePath,
|
15
|
-
serialize,
|
16
|
-
stringifyPath
|
17
|
-
} from "./chunk-SOVQ5ARD.js";
|
18
|
-
import "./chunk-Q2LSK6YZ.js";
|
2
|
+
OpenAPIHandler
|
3
|
+
} from "./chunk-HQ34JZI7.js";
|
4
|
+
import "./chunk-M5HOHBLW.js";
|
5
|
+
import "./chunk-BHJYKXQL.js";
|
19
6
|
export {
|
20
|
-
|
21
|
-
InputStructureCompact,
|
22
|
-
InputStructureDetailed,
|
23
|
-
OpenAPIHandler,
|
24
|
-
OpenAPIPayloadCodec,
|
25
|
-
OpenAPIProcedureMatcher,
|
26
|
-
OpenAPIServerHandler,
|
27
|
-
OpenAPIServerlessHandler,
|
28
|
-
deserialize,
|
29
|
-
escapeSegment,
|
30
|
-
parsePath,
|
31
|
-
serialize,
|
32
|
-
stringifyPath
|
7
|
+
OpenAPIHandler
|
33
8
|
};
|
34
9
|
//# sourceMappingURL=fetch.js.map
|
package/dist/hono.js
CHANGED
@@ -1,34 +1,9 @@
|
|
1
1
|
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
import
|
6
|
-
CompositeSchemaCoercer,
|
7
|
-
InputStructureCompact,
|
8
|
-
InputStructureDetailed,
|
9
|
-
OpenAPIHandler,
|
10
|
-
OpenAPIPayloadCodec,
|
11
|
-
OpenAPIProcedureMatcher,
|
12
|
-
deserialize,
|
13
|
-
escapeSegment,
|
14
|
-
parsePath,
|
15
|
-
serialize,
|
16
|
-
stringifyPath
|
17
|
-
} from "./chunk-SOVQ5ARD.js";
|
18
|
-
import "./chunk-Q2LSK6YZ.js";
|
2
|
+
OpenAPIHandler
|
3
|
+
} from "./chunk-HQ34JZI7.js";
|
4
|
+
import "./chunk-M5HOHBLW.js";
|
5
|
+
import "./chunk-BHJYKXQL.js";
|
19
6
|
export {
|
20
|
-
|
21
|
-
InputStructureCompact,
|
22
|
-
InputStructureDetailed,
|
23
|
-
OpenAPIHandler,
|
24
|
-
OpenAPIPayloadCodec,
|
25
|
-
OpenAPIProcedureMatcher,
|
26
|
-
OpenAPIServerHandler,
|
27
|
-
OpenAPIServerlessHandler,
|
28
|
-
deserialize,
|
29
|
-
escapeSegment,
|
30
|
-
parsePath,
|
31
|
-
serialize,
|
32
|
-
stringifyPath
|
7
|
+
OpenAPIHandler
|
33
8
|
};
|
34
9
|
//# sourceMappingURL=hono.js.map
|
package/dist/index.js
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
import {
|
2
2
|
JSONSerializer,
|
3
|
-
forEachAllContractProcedure,
|
4
|
-
forEachContractProcedure,
|
5
3
|
standardizeHTTPPath
|
6
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-BHJYKXQL.js";
|
7
5
|
|
8
6
|
// src/openapi.ts
|
9
7
|
import { OpenApiBuilder } from "openapi3-ts/oas31";
|
@@ -37,6 +35,7 @@ var OpenAPIContentBuilder = class {
|
|
37
35
|
|
38
36
|
// src/openapi-generator.ts
|
39
37
|
import { fallbackContractConfig as fallbackContractConfig2, fallbackORPCErrorStatus } from "@orpc/contract";
|
38
|
+
import { eachAllContractProcedure } from "@orpc/server";
|
40
39
|
import { group } from "@orpc/shared";
|
41
40
|
|
42
41
|
// src/openapi-error.ts
|
@@ -406,7 +405,10 @@ var OpenAPIGenerator = class {
|
|
406
405
|
openapi: "3.1.1"
|
407
406
|
});
|
408
407
|
const rootTags = doc.tags?.map((tag) => tag.name) ?? [];
|
409
|
-
await
|
408
|
+
await eachAllContractProcedure({
|
409
|
+
path: [],
|
410
|
+
router
|
411
|
+
}, ({ contract, path }) => {
|
410
412
|
try {
|
411
413
|
const def = contract["~orpc"];
|
412
414
|
if (this.ignoreUndefinedPathProcedures && def.route?.path === void 0) {
|
@@ -539,8 +541,6 @@ export {
|
|
539
541
|
OpenAPIPathParser,
|
540
542
|
OpenApiBuilder,
|
541
543
|
SchemaUtils,
|
542
|
-
forEachAllContractProcedure,
|
543
|
-
forEachContractProcedure,
|
544
544
|
standardizeHTTPPath
|
545
545
|
};
|
546
546
|
//# sourceMappingURL=index.js.map
|
package/dist/next.js
CHANGED
@@ -1,34 +1,9 @@
|
|
1
1
|
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
import
|
6
|
-
CompositeSchemaCoercer,
|
7
|
-
InputStructureCompact,
|
8
|
-
InputStructureDetailed,
|
9
|
-
OpenAPIHandler,
|
10
|
-
OpenAPIPayloadCodec,
|
11
|
-
OpenAPIProcedureMatcher,
|
12
|
-
deserialize,
|
13
|
-
escapeSegment,
|
14
|
-
parsePath,
|
15
|
-
serialize,
|
16
|
-
stringifyPath
|
17
|
-
} from "./chunk-SOVQ5ARD.js";
|
18
|
-
import "./chunk-Q2LSK6YZ.js";
|
2
|
+
OpenAPIHandler
|
3
|
+
} from "./chunk-HQ34JZI7.js";
|
4
|
+
import "./chunk-M5HOHBLW.js";
|
5
|
+
import "./chunk-BHJYKXQL.js";
|
19
6
|
export {
|
20
|
-
|
21
|
-
InputStructureCompact,
|
22
|
-
InputStructureDetailed,
|
23
|
-
OpenAPIHandler,
|
24
|
-
OpenAPIPayloadCodec,
|
25
|
-
OpenAPIProcedureMatcher,
|
26
|
-
OpenAPIServerHandler,
|
27
|
-
OpenAPIServerlessHandler,
|
28
|
-
deserialize,
|
29
|
-
escapeSegment,
|
30
|
-
parsePath,
|
31
|
-
serialize,
|
32
|
-
stringifyPath
|
7
|
+
OpenAPIHandler
|
33
8
|
};
|
34
9
|
//# sourceMappingURL=next.js.map
|