@orpc/openapi 0.0.0-next.22ccd98 → 0.0.0-next.23aa4be
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-EVWWILO6.js +25 -0
- package/dist/{chunk-WNX6GP4X.js → chunk-X2HG5K4J.js} +14 -15
- package/dist/fetch.js +5 -17
- package/dist/hono.js +34 -0
- package/dist/index.js +61 -7
- package/dist/next.js +34 -0
- package/dist/node.js +10 -10
- package/dist/src/adapters/fetch/openapi-handler.d.ts +4 -5
- package/dist/src/adapters/hono/index.d.ts +2 -0
- package/dist/src/adapters/next/index.d.ts +2 -0
- package/dist/src/adapters/node/openapi-handler.d.ts +3 -4
- package/dist/src/openapi-generator.d.ts +7 -0
- package/dist/src/schema.d.ts +1 -1
- package/package.json +15 -6
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OpenAPIHandler
|
|
3
|
+
} from "./chunk-X2HG5K4J.js";
|
|
4
|
+
|
|
5
|
+
// src/adapters/fetch/openapi-handler-server.ts
|
|
6
|
+
import { TrieRouter } from "hono/router/trie-router";
|
|
7
|
+
var OpenAPIServerHandler = class extends OpenAPIHandler {
|
|
8
|
+
constructor(router, options) {
|
|
9
|
+
super(new TrieRouter(), router, options);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// src/adapters/fetch/openapi-handler-serverless.ts
|
|
14
|
+
import { LinearRouter } from "hono/router/linear-router";
|
|
15
|
+
var OpenAPIServerlessHandler = class extends OpenAPIHandler {
|
|
16
|
+
constructor(router, options) {
|
|
17
|
+
super(new LinearRouter(), router, options);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
OpenAPIServerHandler,
|
|
23
|
+
OpenAPIServerlessHandler
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-EVWWILO6.js.map
|
|
@@ -486,7 +486,7 @@ var CompositeSchemaCoercer = class {
|
|
|
486
486
|
|
|
487
487
|
// src/adapters/fetch/openapi-handler.ts
|
|
488
488
|
import { createProcedureClient, fallbackToGlobalConfig as fallbackToGlobalConfig2, ORPCError as ORPCError2 } from "@orpc/server";
|
|
489
|
-
import { executeWithHooks, isPlainObject as isPlainObject3,
|
|
489
|
+
import { executeWithHooks, isPlainObject as isPlainObject3, trim } from "@orpc/shared";
|
|
490
490
|
var OpenAPIHandler = class {
|
|
491
491
|
constructor(hono, router, options) {
|
|
492
492
|
this.options = options;
|
|
@@ -502,13 +502,10 @@ var OpenAPIHandler = class {
|
|
|
502
502
|
inputStructureCompact;
|
|
503
503
|
inputStructureDetailed;
|
|
504
504
|
compositeSchemaCoercer;
|
|
505
|
-
|
|
506
|
-
return request.headers.get(ORPC_HANDLER_HEADER) === null;
|
|
507
|
-
}
|
|
508
|
-
async fetch(request, ...[options]) {
|
|
505
|
+
async handle(request, ...[options]) {
|
|
509
506
|
const context = options?.context;
|
|
510
507
|
const headers = request.headers;
|
|
511
|
-
const accept = headers.get("
|
|
508
|
+
const accept = headers.get("accept") || void 0;
|
|
512
509
|
const execute = async () => {
|
|
513
510
|
const url = new URL(request.url);
|
|
514
511
|
const pathname = `/${trim(url.pathname.replace(options?.prefix ?? "", ""), "/")}`;
|
|
@@ -517,22 +514,22 @@ var OpenAPIHandler = class {
|
|
|
517
514
|
const matchedMethod = customMethod || request.method;
|
|
518
515
|
const matched = await this.procedureMatcher.match(matchedMethod, pathname);
|
|
519
516
|
if (!matched) {
|
|
520
|
-
|
|
517
|
+
return { matched: false, response: void 0 };
|
|
521
518
|
}
|
|
522
519
|
const contractDef = matched.procedure["~orpc"].contract["~orpc"];
|
|
523
520
|
const input = await this.decodeInput(matched.procedure, matched.params, request);
|
|
524
521
|
const coercedInput = this.compositeSchemaCoercer.coerce(contractDef.InputSchema, input);
|
|
525
|
-
const client = createProcedureClient({
|
|
522
|
+
const client = createProcedureClient(matched.procedure, {
|
|
526
523
|
context,
|
|
527
|
-
procedure: matched.procedure,
|
|
528
524
|
path: matched.path
|
|
529
525
|
});
|
|
530
|
-
const output = await client(coercedInput, { signal:
|
|
526
|
+
const output = await client(coercedInput, { signal: request.signal });
|
|
531
527
|
const { body, headers: resHeaders } = this.encodeOutput(matched.procedure, output, accept);
|
|
532
|
-
|
|
528
|
+
const response = new Response(body, {
|
|
533
529
|
headers: resHeaders,
|
|
534
530
|
status: fallbackToGlobalConfig2("defaultSuccessStatus", contractDef.route?.successStatus)
|
|
535
531
|
});
|
|
532
|
+
return { matched: true, response };
|
|
536
533
|
};
|
|
537
534
|
try {
|
|
538
535
|
return await executeWithHooks({
|
|
@@ -541,24 +538,26 @@ var OpenAPIHandler = class {
|
|
|
541
538
|
input: request,
|
|
542
539
|
hooks: this.options,
|
|
543
540
|
meta: {
|
|
544
|
-
signal:
|
|
541
|
+
signal: request.signal
|
|
545
542
|
}
|
|
546
543
|
});
|
|
547
544
|
} catch (e) {
|
|
548
545
|
const error = this.convertToORPCError(e);
|
|
549
546
|
try {
|
|
550
547
|
const { body, headers: headers2 } = this.payloadCodec.encode(error.toJSON(), accept);
|
|
551
|
-
|
|
548
|
+
const response = new Response(body, {
|
|
552
549
|
status: error.status,
|
|
553
550
|
headers: headers2
|
|
554
551
|
});
|
|
552
|
+
return { matched: true, response };
|
|
555
553
|
} catch (e2) {
|
|
556
554
|
const error2 = this.convertToORPCError(e2);
|
|
557
555
|
const { body, headers: headers2 } = this.payloadCodec.encode(error2.toJSON(), void 0);
|
|
558
|
-
|
|
556
|
+
const response = new Response(body, {
|
|
559
557
|
status: error2.status,
|
|
560
558
|
headers: headers2
|
|
561
559
|
});
|
|
560
|
+
return { matched: true, response };
|
|
562
561
|
}
|
|
563
562
|
}
|
|
564
563
|
}
|
|
@@ -649,4 +648,4 @@ export {
|
|
|
649
648
|
CompositeSchemaCoercer,
|
|
650
649
|
OpenAPIHandler
|
|
651
650
|
};
|
|
652
|
-
//# sourceMappingURL=chunk-
|
|
651
|
+
//# sourceMappingURL=chunk-X2HG5K4J.js.map
|
package/dist/fetch.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OpenAPIServerHandler,
|
|
3
|
+
OpenAPIServerlessHandler
|
|
4
|
+
} from "./chunk-EVWWILO6.js";
|
|
1
5
|
import {
|
|
2
6
|
CompositeSchemaCoercer,
|
|
3
7
|
InputStructureCompact,
|
|
@@ -10,24 +14,8 @@ import {
|
|
|
10
14
|
parsePath,
|
|
11
15
|
serialize,
|
|
12
16
|
stringifyPath
|
|
13
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-X2HG5K4J.js";
|
|
14
18
|
import "./chunk-KNYXLM77.js";
|
|
15
|
-
|
|
16
|
-
// src/adapters/fetch/openapi-handler-server.ts
|
|
17
|
-
import { TrieRouter } from "hono/router/trie-router";
|
|
18
|
-
var OpenAPIServerHandler = class extends OpenAPIHandler {
|
|
19
|
-
constructor(router, options) {
|
|
20
|
-
super(new TrieRouter(), router, options);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// src/adapters/fetch/openapi-handler-serverless.ts
|
|
25
|
-
import { LinearRouter } from "hono/router/linear-router";
|
|
26
|
-
var OpenAPIServerlessHandler = class extends OpenAPIHandler {
|
|
27
|
-
constructor(router, options) {
|
|
28
|
-
super(new LinearRouter(), router, options);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
19
|
export {
|
|
32
20
|
CompositeSchemaCoercer,
|
|
33
21
|
InputStructureCompact,
|
package/dist/hono.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OpenAPIServerHandler,
|
|
3
|
+
OpenAPIServerlessHandler
|
|
4
|
+
} from "./chunk-EVWWILO6.js";
|
|
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-X2HG5K4J.js";
|
|
18
|
+
import "./chunk-KNYXLM77.js";
|
|
19
|
+
export {
|
|
20
|
+
CompositeSchemaCoercer,
|
|
21
|
+
InputStructureCompact,
|
|
22
|
+
InputStructureDetailed,
|
|
23
|
+
OpenAPIHandler,
|
|
24
|
+
OpenAPIPayloadCodec,
|
|
25
|
+
OpenAPIProcedureMatcher,
|
|
26
|
+
OpenAPIServerHandler,
|
|
27
|
+
OpenAPIServerlessHandler,
|
|
28
|
+
deserialize,
|
|
29
|
+
escapeSegment,
|
|
30
|
+
parsePath,
|
|
31
|
+
serialize,
|
|
32
|
+
stringifyPath
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=hono.js.map
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,8 @@ var OpenAPIContentBuilder = class {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
// src/openapi-generator.ts
|
|
39
|
-
import { fallbackToGlobalConfig as fallbackToGlobalConfig2 } from "@orpc/contract";
|
|
39
|
+
import { fallbackORPCErrorStatus, fallbackToGlobalConfig as fallbackToGlobalConfig2 } from "@orpc/contract";
|
|
40
|
+
import { group } from "@orpc/shared";
|
|
40
41
|
|
|
41
42
|
// src/openapi-error.ts
|
|
42
43
|
var OpenAPIError = class extends Error {
|
|
@@ -293,14 +294,14 @@ var SchemaUtils = class {
|
|
|
293
294
|
return typeof schema === "object" && schema.type === "object";
|
|
294
295
|
}
|
|
295
296
|
isAnySchema(schema) {
|
|
296
|
-
return schema === true || Object.keys(schema).length === 0;
|
|
297
|
+
return schema === true || Object.keys(schema).filter((key) => !NON_LOGIC_KEYWORDS.includes(key)).length === 0;
|
|
297
298
|
}
|
|
298
299
|
isUndefinableSchema(schema) {
|
|
299
300
|
const [matches] = this.filterSchemaBranches(schema, (schema2) => {
|
|
300
301
|
if (typeof schema2 === "boolean") {
|
|
301
302
|
return schema2;
|
|
302
303
|
}
|
|
303
|
-
return Object.keys(schema2).length === 0;
|
|
304
|
+
return Object.keys(schema2).filter((key) => !NON_LOGIC_KEYWORDS.includes(key)).length === 0;
|
|
304
305
|
});
|
|
305
306
|
return matches.length > 0;
|
|
306
307
|
}
|
|
@@ -384,6 +385,7 @@ var OpenAPIGenerator = class {
|
|
|
384
385
|
errorHandlerStrategy;
|
|
385
386
|
ignoreUndefinedPathProcedures;
|
|
386
387
|
considerMissingTagDefinitionAsError;
|
|
388
|
+
strictErrorResponses;
|
|
387
389
|
constructor(options) {
|
|
388
390
|
this.parametersBuilder = options?.parametersBuilder ?? new OpenAPIParametersBuilder();
|
|
389
391
|
this.schemaConverter = new CompositeSchemaConverter(options?.schemaConverters ?? []);
|
|
@@ -396,6 +398,7 @@ var OpenAPIGenerator = class {
|
|
|
396
398
|
this.errorHandlerStrategy = options?.errorHandlerStrategy ?? "throw";
|
|
397
399
|
this.ignoreUndefinedPathProcedures = options?.ignoreUndefinedPathProcedures ?? false;
|
|
398
400
|
this.considerMissingTagDefinitionAsError = options?.considerMissingTagDefinitionAsError ?? false;
|
|
401
|
+
this.strictErrorResponses = options?.strictErrorResponses ?? true;
|
|
399
402
|
}
|
|
400
403
|
async generate(router, doc) {
|
|
401
404
|
const builder = new OpenApiBuilder({
|
|
@@ -425,7 +428,8 @@ var OpenAPIGenerator = class {
|
|
|
425
428
|
required: this.schemaUtils.isUndefinableSchema(bodySchema),
|
|
426
429
|
content: this.contentBuilder.build(bodySchema)
|
|
427
430
|
} : void 0;
|
|
428
|
-
const
|
|
431
|
+
const responses = {};
|
|
432
|
+
responses[fallbackToGlobalConfig2("defaultSuccessStatus", def.route?.successStatus)] = {
|
|
429
433
|
description: fallbackToGlobalConfig2("defaultSuccessDescription", def.route?.successDescription),
|
|
430
434
|
content: resBodySchema !== void 0 ? this.contentBuilder.build(resBodySchema, {
|
|
431
435
|
example: def.outputExample
|
|
@@ -434,6 +438,58 @@ var OpenAPIGenerator = class {
|
|
|
434
438
|
example: def.outputExample
|
|
435
439
|
}) : void 0
|
|
436
440
|
};
|
|
441
|
+
const errors = group(Object.entries(def.errorMap ?? {}).filter(([_, config]) => config).map(([code, config]) => ({
|
|
442
|
+
...config,
|
|
443
|
+
code,
|
|
444
|
+
status: fallbackORPCErrorStatus(code, config?.status)
|
|
445
|
+
})), (error) => error.status);
|
|
446
|
+
for (const status in errors) {
|
|
447
|
+
const configs = errors[status];
|
|
448
|
+
if (!configs || configs.length === 0) {
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
const schemas = configs.map(({ data, code, message }) => {
|
|
452
|
+
const json = {
|
|
453
|
+
type: "object",
|
|
454
|
+
properties: {
|
|
455
|
+
defined: { const: true },
|
|
456
|
+
code: { const: code },
|
|
457
|
+
status: { const: Number(status) },
|
|
458
|
+
message: { type: "string", default: message },
|
|
459
|
+
data: {}
|
|
460
|
+
},
|
|
461
|
+
required: ["defined", "code", "status", "message"]
|
|
462
|
+
};
|
|
463
|
+
if (data) {
|
|
464
|
+
const dataJson = this.schemaConverter.convert(data, { strategy: "output" });
|
|
465
|
+
json.properties.data = dataJson;
|
|
466
|
+
if (!this.schemaUtils.isUndefinableSchema(dataJson)) {
|
|
467
|
+
json.required.push("data");
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return json;
|
|
471
|
+
});
|
|
472
|
+
if (this.strictErrorResponses) {
|
|
473
|
+
schemas.push({
|
|
474
|
+
type: "object",
|
|
475
|
+
properties: {
|
|
476
|
+
defined: { const: false },
|
|
477
|
+
code: { type: "string" },
|
|
478
|
+
status: { type: "number" },
|
|
479
|
+
message: { type: "string" },
|
|
480
|
+
data: {}
|
|
481
|
+
},
|
|
482
|
+
required: ["defined", "code", "status", "message"]
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
const contentSchema = schemas.length === 1 ? schemas[0] : {
|
|
486
|
+
oneOf: schemas
|
|
487
|
+
};
|
|
488
|
+
responses[status] = {
|
|
489
|
+
description: status,
|
|
490
|
+
content: this.contentBuilder.build(contentSchema)
|
|
491
|
+
};
|
|
492
|
+
}
|
|
437
493
|
if (this.considerMissingTagDefinitionAsError && def.route?.tags) {
|
|
438
494
|
const missingTag = def.route?.tags.find((tag) => !rootTags.includes(tag));
|
|
439
495
|
if (missingTag !== void 0) {
|
|
@@ -450,9 +506,7 @@ var OpenAPIGenerator = class {
|
|
|
450
506
|
operationId: path.join("."),
|
|
451
507
|
parameters: parameters.length ? parameters : void 0,
|
|
452
508
|
requestBody,
|
|
453
|
-
responses
|
|
454
|
-
[fallbackToGlobalConfig2("defaultSuccessStatus", def.route?.successStatus)]: successResponse
|
|
455
|
-
}
|
|
509
|
+
responses
|
|
456
510
|
};
|
|
457
511
|
builder.addPath(httpPath, {
|
|
458
512
|
[method.toLocaleLowerCase()]: operation
|
package/dist/next.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OpenAPIServerHandler,
|
|
3
|
+
OpenAPIServerlessHandler
|
|
4
|
+
} from "./chunk-EVWWILO6.js";
|
|
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-X2HG5K4J.js";
|
|
18
|
+
import "./chunk-KNYXLM77.js";
|
|
19
|
+
export {
|
|
20
|
+
CompositeSchemaCoercer,
|
|
21
|
+
InputStructureCompact,
|
|
22
|
+
InputStructureDetailed,
|
|
23
|
+
OpenAPIHandler,
|
|
24
|
+
OpenAPIPayloadCodec,
|
|
25
|
+
OpenAPIProcedureMatcher,
|
|
26
|
+
OpenAPIServerHandler,
|
|
27
|
+
OpenAPIServerlessHandler,
|
|
28
|
+
deserialize,
|
|
29
|
+
escapeSegment,
|
|
30
|
+
parsePath,
|
|
31
|
+
serialize,
|
|
32
|
+
stringifyPath
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=next.js.map
|
package/dist/node.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OpenAPIHandler
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-X2HG5K4J.js";
|
|
4
4
|
import "./chunk-KNYXLM77.js";
|
|
5
5
|
|
|
6
6
|
// src/adapters/node/openapi-handler.ts
|
|
7
|
-
import { createRequest, sendResponse } from "@
|
|
8
|
-
import { ORPC_HANDLER_HEADER } from "@orpc/shared";
|
|
7
|
+
import { createRequest, sendResponse } from "@orpc/server/node";
|
|
9
8
|
var OpenAPIHandler2 = class {
|
|
10
9
|
openapiFetchHandler;
|
|
11
10
|
constructor(hono, router, options) {
|
|
12
11
|
this.openapiFetchHandler = new OpenAPIHandler(hono, router, options);
|
|
13
12
|
}
|
|
14
|
-
condition(request) {
|
|
15
|
-
return request.headers[ORPC_HANDLER_HEADER] === void 0;
|
|
16
|
-
}
|
|
17
13
|
async handle(req, res, ...[options]) {
|
|
18
|
-
const request = createRequest(req, res
|
|
14
|
+
const request = createRequest(req, res);
|
|
19
15
|
const castedOptions = options ?? {};
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
const result = await this.openapiFetchHandler.handle(request, castedOptions);
|
|
17
|
+
if (result.matched === false) {
|
|
18
|
+
return { matched: false };
|
|
19
|
+
}
|
|
20
|
+
await options?.beforeSend?.(result.response, castedOptions.context);
|
|
21
|
+
await sendResponse(res, result.response);
|
|
22
|
+
return { matched: true };
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context, Router, WithSignal } from '@orpc/server';
|
|
2
|
-
import type {
|
|
2
|
+
import type { FetchHandler, FetchHandleRest, FetchHandleResult } from '@orpc/server/fetch';
|
|
3
3
|
import type { PublicInputStructureCompact } from './input-structure-compact';
|
|
4
4
|
import { type Hooks } from '@orpc/shared';
|
|
5
5
|
import { type PublicJSONSerializer } from '../../json-serializer';
|
|
@@ -7,7 +7,7 @@ import { type PublicInputStructureDetailed } from './input-structure-detailed';
|
|
|
7
7
|
import { type PublicOpenAPIPayloadCodec } from './openapi-payload-codec';
|
|
8
8
|
import { type Hono, type PublicOpenAPIProcedureMatcher } from './openapi-procedure-matcher';
|
|
9
9
|
import { type SchemaCoercer } from './schema-coercer';
|
|
10
|
-
export type OpenAPIHandlerOptions<T extends Context> = Hooks<Request,
|
|
10
|
+
export type OpenAPIHandlerOptions<T extends Context> = Hooks<Request, FetchHandleResult, T, WithSignal> & {
|
|
11
11
|
jsonSerializer?: PublicJSONSerializer;
|
|
12
12
|
procedureMatcher?: PublicOpenAPIProcedureMatcher;
|
|
13
13
|
payloadCodec?: PublicOpenAPIPayloadCodec;
|
|
@@ -15,7 +15,7 @@ export type OpenAPIHandlerOptions<T extends Context> = Hooks<Request, Response,
|
|
|
15
15
|
inputBuilderFull?: PublicInputStructureDetailed;
|
|
16
16
|
schemaCoercers?: SchemaCoercer[];
|
|
17
17
|
};
|
|
18
|
-
export declare class OpenAPIHandler<T extends Context> implements
|
|
18
|
+
export declare class OpenAPIHandler<T extends Context> implements FetchHandler<T> {
|
|
19
19
|
private readonly options?;
|
|
20
20
|
private readonly procedureMatcher;
|
|
21
21
|
private readonly payloadCodec;
|
|
@@ -23,8 +23,7 @@ export declare class OpenAPIHandler<T extends Context> implements ConditionalFet
|
|
|
23
23
|
private readonly inputStructureDetailed;
|
|
24
24
|
private readonly compositeSchemaCoercer;
|
|
25
25
|
constructor(hono: Hono, router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>> | undefined);
|
|
26
|
-
|
|
27
|
-
fetch(request: Request, ...[options]: [options: FetchOptions<T>] | (undefined extends T ? [] : never)): Promise<Response>;
|
|
26
|
+
handle(request: Request, ...[options]: FetchHandleRest<T>): Promise<FetchHandleResult>;
|
|
28
27
|
private decodeInput;
|
|
29
28
|
private encodeOutput;
|
|
30
29
|
private assertDetailedOutput;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { Context, Router } from '@orpc/server';
|
|
2
|
-
import type { ConditionalRequestHandler, RequestOptions } from '@orpc/server/node';
|
|
3
2
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
4
3
|
import type { OpenAPIHandlerOptions } from '../fetch/openapi-handler';
|
|
5
4
|
import type { Hono } from '../fetch/openapi-procedure-matcher';
|
|
6
|
-
|
|
5
|
+
import { type RequestHandler, type RequestHandleRest, type RequestHandleResult } from '@orpc/server/node';
|
|
6
|
+
export declare class OpenAPIHandler<T extends Context> implements RequestHandler<T> {
|
|
7
7
|
private readonly openapiFetchHandler;
|
|
8
8
|
constructor(hono: Hono, router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
9
|
-
|
|
10
|
-
handle(req: IncomingMessage, res: ServerResponse, ...[options]: [options: RequestOptions<T>] | (undefined extends T ? [] : never)): Promise<void>;
|
|
9
|
+
handle(req: IncomingMessage, res: ServerResponse, ...[options]: RequestHandleRest<T>): Promise<RequestHandleResult>;
|
|
11
10
|
}
|
|
12
11
|
//# sourceMappingURL=openapi-handler.d.ts.map
|
|
@@ -40,6 +40,12 @@ export interface OpenAPIGeneratorOptions {
|
|
|
40
40
|
* @default 'throw'
|
|
41
41
|
*/
|
|
42
42
|
errorHandlerStrategy?: ErrorHandlerStrategy;
|
|
43
|
+
/**
|
|
44
|
+
* Strict error response
|
|
45
|
+
*
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
strictErrorResponses?: boolean;
|
|
43
49
|
}
|
|
44
50
|
export declare class OpenAPIGenerator {
|
|
45
51
|
private readonly contentBuilder;
|
|
@@ -53,6 +59,7 @@ export declare class OpenAPIGenerator {
|
|
|
53
59
|
private readonly errorHandlerStrategy;
|
|
54
60
|
private readonly ignoreUndefinedPathProcedures;
|
|
55
61
|
private readonly considerMissingTagDefinitionAsError;
|
|
62
|
+
private readonly strictErrorResponses;
|
|
56
63
|
constructor(options?: OpenAPIGeneratorOptions);
|
|
57
64
|
generate(router: ContractRouter | ANY_ROUTER, doc: Omit<OpenAPI.OpenAPIObject, 'openapi'>): Promise<OpenAPI.OpenAPIObject>;
|
|
58
65
|
}
|
package/dist/src/schema.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ export type FileSchema = JSONSchema.JSONSchema & {
|
|
|
8
8
|
type: 'string';
|
|
9
9
|
contentMediaType: string;
|
|
10
10
|
} & object;
|
|
11
|
-
export declare const NON_LOGIC_KEYWORDS:
|
|
11
|
+
export declare const NON_LOGIC_KEYWORDS: string[];
|
|
12
12
|
//# sourceMappingURL=schema.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/openapi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.23aa4be",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -24,6 +24,16 @@
|
|
|
24
24
|
"import": "./dist/fetch.js",
|
|
25
25
|
"default": "./dist/fetch.js"
|
|
26
26
|
},
|
|
27
|
+
"./hono": {
|
|
28
|
+
"types": "./dist/src/adapters/hono/index.d.ts",
|
|
29
|
+
"import": "./dist/hono.js",
|
|
30
|
+
"default": "./dist/hono.js"
|
|
31
|
+
},
|
|
32
|
+
"./next": {
|
|
33
|
+
"types": "./dist/src/adapters/next/index.d.ts",
|
|
34
|
+
"import": "./dist/next.js",
|
|
35
|
+
"default": "./dist/next.js"
|
|
36
|
+
},
|
|
27
37
|
"./node": {
|
|
28
38
|
"types": "./dist/src/adapters/node/index.d.ts",
|
|
29
39
|
"import": "./dist/node.js",
|
|
@@ -39,7 +49,6 @@
|
|
|
39
49
|
"dist"
|
|
40
50
|
],
|
|
41
51
|
"dependencies": {
|
|
42
|
-
"@mjackson/node-fetch-server": "^0.5.0",
|
|
43
52
|
"@standard-schema/spec": "1.0.0-beta.4",
|
|
44
53
|
"@types/content-disposition": "^0.5.8",
|
|
45
54
|
"content-disposition": "^0.5.4",
|
|
@@ -49,16 +58,16 @@
|
|
|
49
58
|
"json-schema-typed": "^8.0.1",
|
|
50
59
|
"openapi3-ts": "^4.4.0",
|
|
51
60
|
"wildcard-match": "^5.1.3",
|
|
52
|
-
"@orpc/contract": "0.0.0-next.
|
|
53
|
-
"@orpc/
|
|
54
|
-
"@orpc/
|
|
61
|
+
"@orpc/contract": "0.0.0-next.23aa4be",
|
|
62
|
+
"@orpc/server": "0.0.0-next.23aa4be",
|
|
63
|
+
"@orpc/shared": "0.0.0-next.23aa4be"
|
|
55
64
|
},
|
|
56
65
|
"devDependencies": {
|
|
57
66
|
"@readme/openapi-parser": "^2.6.0",
|
|
58
67
|
"zod": "^3.24.1"
|
|
59
68
|
},
|
|
60
69
|
"scripts": {
|
|
61
|
-
"build": "tsup --
|
|
70
|
+
"build": "tsup --onSuccess='tsc -b --noCheck'",
|
|
62
71
|
"build:watch": "pnpm run build --watch",
|
|
63
72
|
"type:check": "tsc -b"
|
|
64
73
|
}
|