@orpc/openapi 0.0.0-next.aa72097 → 0.0.0-next.ad0709a

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.
Files changed (40) hide show
  1. package/dist/chunk-BHJYKXQL.js +52 -0
  2. package/dist/chunk-HQ34JZI7.js +32 -0
  3. package/dist/chunk-M5HOHBLW.js +432 -0
  4. package/dist/fetch.js +5 -30
  5. package/dist/hono.js +5 -30
  6. package/dist/index.js +77 -27
  7. package/dist/next.js +9 -0
  8. package/dist/node.js +18 -34
  9. package/dist/src/adapters/fetch/index.d.ts +0 -8
  10. package/dist/src/adapters/fetch/openapi-handler.d.ts +7 -29
  11. package/dist/src/adapters/next/index.d.ts +2 -0
  12. package/dist/src/adapters/node/index.d.ts +0 -3
  13. package/dist/src/adapters/node/openapi-handler.d.ts +7 -8
  14. package/dist/src/adapters/standard/index.d.ts +7 -0
  15. package/dist/src/adapters/standard/openapi-codec.d.ts +18 -0
  16. package/dist/src/adapters/standard/openapi-handler.d.ts +7 -0
  17. package/dist/src/adapters/standard/openapi-matcher.d.ts +20 -0
  18. package/dist/src/adapters/standard/openapi-serializer.d.ts +11 -0
  19. package/dist/src/adapters/{fetch → standard}/schema-coercer.d.ts +1 -1
  20. package/dist/src/openapi-generator.d.ts +9 -2
  21. package/dist/src/openapi-input-structure-parser.d.ts +2 -2
  22. package/dist/src/openapi-output-structure-parser.d.ts +2 -2
  23. package/dist/src/schema-converter.d.ts +2 -2
  24. package/dist/src/schema.d.ts +1 -1
  25. package/dist/src/utils.d.ts +1 -16
  26. package/dist/standard.js +16 -0
  27. package/package.json +15 -5
  28. package/dist/chunk-KNYXLM77.js +0 -107
  29. package/dist/chunk-XYIZDXKB.js +0 -652
  30. package/dist/chunk-YOKECDND.js +0 -25
  31. package/dist/src/adapters/fetch/input-structure-compact.d.ts +0 -6
  32. package/dist/src/adapters/fetch/input-structure-detailed.d.ts +0 -11
  33. package/dist/src/adapters/fetch/openapi-handler-server.d.ts +0 -7
  34. package/dist/src/adapters/fetch/openapi-handler-serverless.d.ts +0 -7
  35. package/dist/src/adapters/fetch/openapi-payload-codec.d.ts +0 -15
  36. package/dist/src/adapters/fetch/openapi-procedure-matcher.d.ts +0 -19
  37. package/dist/src/adapters/node/openapi-handler-server.d.ts +0 -7
  38. package/dist/src/adapters/node/openapi-handler-serverless.d.ts +0 -7
  39. package/dist/src/adapters/node/types.d.ts +0 -2
  40. /package/dist/src/adapters/{fetch → standard}/bracket-notation.d.ts +0 -0
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-KNYXLM77.js";
4
+ } from "./chunk-BHJYKXQL.js";
7
5
 
8
6
  // src/openapi.ts
9
7
  import { OpenApiBuilder } from "openapi3-ts/oas31";
@@ -36,14 +34,16 @@ var OpenAPIContentBuilder = class {
36
34
  };
37
35
 
38
36
  // src/openapi-generator.ts
39
- import { fallbackToGlobalConfig as fallbackToGlobalConfig2 } from "@orpc/contract";
37
+ import { fallbackContractConfig as fallbackContractConfig2, fallbackORPCErrorStatus } from "@orpc/contract";
38
+ import { eachAllContractProcedure } from "@orpc/server";
39
+ import { group } from "@orpc/shared";
40
40
 
41
41
  // src/openapi-error.ts
42
42
  var OpenAPIError = class extends Error {
43
43
  };
44
44
 
45
45
  // src/openapi-input-structure-parser.ts
46
- import { fallbackToGlobalConfig } from "@orpc/contract";
46
+ import { fallbackContractConfig } from "@orpc/contract";
47
47
  var OpenAPIInputStructureParser = class {
48
48
  constructor(schemaConverter, schemaUtils, pathParser) {
49
49
  this.schemaConverter = schemaConverter;
@@ -51,8 +51,8 @@ var OpenAPIInputStructureParser = class {
51
51
  this.pathParser = pathParser;
52
52
  }
53
53
  parse(contract, structure) {
54
- const inputSchema = this.schemaConverter.convert(contract["~orpc"].InputSchema, { strategy: "input" });
55
- const method = fallbackToGlobalConfig("defaultMethod", contract["~orpc"].route?.method);
54
+ const inputSchema = this.schemaConverter.convert(contract["~orpc"].inputSchema, { strategy: "input" });
55
+ const method = fallbackContractConfig("defaultMethod", contract["~orpc"].route?.method);
56
56
  const httpPath = contract["~orpc"].route?.path;
57
57
  if (this.schemaUtils.isAnySchema(inputSchema)) {
58
58
  return {
@@ -144,7 +144,7 @@ var OpenAPIOutputStructureParser = class {
144
144
  this.schemaUtils = schemaUtils;
145
145
  }
146
146
  parse(contract, structure) {
147
- const outputSchema = this.schemaConverter.convert(contract["~orpc"].OutputSchema, { strategy: "output" });
147
+ const outputSchema = this.schemaConverter.convert(contract["~orpc"].outputSchema, { strategy: "output" });
148
148
  if (this.schemaUtils.isAnySchema(outputSchema)) {
149
149
  return {
150
150
  headersSchema: void 0,
@@ -293,14 +293,14 @@ var SchemaUtils = class {
293
293
  return typeof schema === "object" && schema.type === "object";
294
294
  }
295
295
  isAnySchema(schema) {
296
- return schema === true || Object.keys(schema).length === 0;
296
+ return schema === true || Object.keys(schema).filter((key) => !NON_LOGIC_KEYWORDS.includes(key)).length === 0;
297
297
  }
298
298
  isUndefinableSchema(schema) {
299
299
  const [matches] = this.filterSchemaBranches(schema, (schema2) => {
300
300
  if (typeof schema2 === "boolean") {
301
301
  return schema2;
302
302
  }
303
- return Object.keys(schema2).length === 0;
303
+ return Object.keys(schema2).filter((key) => !NON_LOGIC_KEYWORDS.includes(key)).length === 0;
304
304
  });
305
305
  return matches.length > 0;
306
306
  }
@@ -384,6 +384,7 @@ var OpenAPIGenerator = class {
384
384
  errorHandlerStrategy;
385
385
  ignoreUndefinedPathProcedures;
386
386
  considerMissingTagDefinitionAsError;
387
+ strictErrorResponses;
387
388
  constructor(options) {
388
389
  this.parametersBuilder = options?.parametersBuilder ?? new OpenAPIParametersBuilder();
389
390
  this.schemaConverter = new CompositeSchemaConverter(options?.schemaConverters ?? []);
@@ -396,6 +397,7 @@ var OpenAPIGenerator = class {
396
397
  this.errorHandlerStrategy = options?.errorHandlerStrategy ?? "throw";
397
398
  this.ignoreUndefinedPathProcedures = options?.ignoreUndefinedPathProcedures ?? false;
398
399
  this.considerMissingTagDefinitionAsError = options?.considerMissingTagDefinitionAsError ?? false;
400
+ this.strictErrorResponses = options?.strictErrorResponses ?? true;
399
401
  }
400
402
  async generate(router, doc) {
401
403
  const builder = new OpenApiBuilder({
@@ -403,16 +405,19 @@ var OpenAPIGenerator = class {
403
405
  openapi: "3.1.1"
404
406
  });
405
407
  const rootTags = doc.tags?.map((tag) => tag.name) ?? [];
406
- await forEachAllContractProcedure(router, ({ contract, path }) => {
408
+ await eachAllContractProcedure({
409
+ path: [],
410
+ router
411
+ }, ({ contract, path }) => {
407
412
  try {
408
413
  const def = contract["~orpc"];
409
414
  if (this.ignoreUndefinedPathProcedures && def.route?.path === void 0) {
410
415
  return;
411
416
  }
412
- const method = fallbackToGlobalConfig2("defaultMethod", def.route?.method);
417
+ const method = fallbackContractConfig2("defaultMethod", def.route?.method);
413
418
  const httpPath = def.route?.path ? standardizeHTTPPath(def.route?.path) : `/${path.map(encodeURIComponent).join("/")}`;
414
- const inputStructure = fallbackToGlobalConfig2("defaultInputStructure", def.route?.inputStructure);
415
- const outputStructure = fallbackToGlobalConfig2("defaultOutputStructure", def.route?.outputStructure);
419
+ const inputStructure = fallbackContractConfig2("defaultInputStructure", def.route?.inputStructure);
420
+ const outputStructure = fallbackContractConfig2("defaultOutputStructure", def.route?.outputStructure);
416
421
  const { paramsSchema, querySchema, headersSchema, bodySchema } = this.inputStructureParser.parse(contract, inputStructure);
417
422
  const { headersSchema: resHeadersSchema, bodySchema: resBodySchema } = this.outputStructureParser.parse(contract, outputStructure);
418
423
  const params = paramsSchema ? this.parametersBuilder.build("path", paramsSchema, {
@@ -425,15 +430,64 @@ var OpenAPIGenerator = class {
425
430
  required: this.schemaUtils.isUndefinableSchema(bodySchema),
426
431
  content: this.contentBuilder.build(bodySchema)
427
432
  } : void 0;
428
- const successResponse = {
429
- description: fallbackToGlobalConfig2("defaultSuccessDescription", def.route?.successDescription),
430
- content: resBodySchema !== void 0 ? this.contentBuilder.build(resBodySchema, {
431
- example: def.outputExample
432
- }) : void 0,
433
- headers: resHeadersSchema !== void 0 ? this.parametersBuilder.buildHeadersObject(resHeadersSchema, {
434
- example: def.outputExample
435
- }) : void 0
433
+ const responses = {};
434
+ responses[fallbackContractConfig2("defaultSuccessStatus", def.route?.successStatus)] = {
435
+ description: fallbackContractConfig2("defaultSuccessDescription", def.route?.successDescription),
436
+ content: resBodySchema !== void 0 ? this.contentBuilder.build(resBodySchema) : void 0,
437
+ headers: resHeadersSchema !== void 0 ? this.parametersBuilder.buildHeadersObject(resHeadersSchema) : void 0
436
438
  };
439
+ const errors = group(Object.entries(def.errorMap ?? {}).filter(([_, config]) => config).map(([code, config]) => ({
440
+ ...config,
441
+ code,
442
+ status: fallbackORPCErrorStatus(code, config?.status)
443
+ })), (error) => error.status);
444
+ for (const status in errors) {
445
+ const configs = errors[status];
446
+ if (!configs || configs.length === 0) {
447
+ continue;
448
+ }
449
+ const schemas = configs.map(({ data, code, message }) => {
450
+ const json = {
451
+ type: "object",
452
+ properties: {
453
+ defined: { const: true },
454
+ code: { const: code },
455
+ status: { const: Number(status) },
456
+ message: { type: "string", default: message },
457
+ data: {}
458
+ },
459
+ required: ["defined", "code", "status", "message"]
460
+ };
461
+ if (data) {
462
+ const dataJson = this.schemaConverter.convert(data, { strategy: "output" });
463
+ json.properties.data = dataJson;
464
+ if (!this.schemaUtils.isUndefinableSchema(dataJson)) {
465
+ json.required.push("data");
466
+ }
467
+ }
468
+ return json;
469
+ });
470
+ if (this.strictErrorResponses) {
471
+ schemas.push({
472
+ type: "object",
473
+ properties: {
474
+ defined: { const: false },
475
+ code: { type: "string" },
476
+ status: { type: "number" },
477
+ message: { type: "string" },
478
+ data: {}
479
+ },
480
+ required: ["defined", "code", "status", "message"]
481
+ });
482
+ }
483
+ const contentSchema = schemas.length === 1 ? schemas[0] : {
484
+ oneOf: schemas
485
+ };
486
+ responses[status] = {
487
+ description: status,
488
+ content: this.contentBuilder.build(contentSchema)
489
+ };
490
+ }
437
491
  if (this.considerMissingTagDefinitionAsError && def.route?.tags) {
438
492
  const missingTag = def.route?.tags.find((tag) => !rootTags.includes(tag));
439
493
  if (missingTag !== void 0) {
@@ -450,9 +504,7 @@ var OpenAPIGenerator = class {
450
504
  operationId: path.join("."),
451
505
  parameters: parameters.length ? parameters : void 0,
452
506
  requestBody,
453
- responses: {
454
- [fallbackToGlobalConfig2("defaultSuccessStatus", def.route?.successStatus)]: successResponse
455
- }
507
+ responses
456
508
  };
457
509
  builder.addPath(httpPath, {
458
510
  [method.toLocaleLowerCase()]: operation
@@ -489,8 +541,6 @@ export {
489
541
  OpenAPIPathParser,
490
542
  OpenApiBuilder,
491
543
  SchemaUtils,
492
- forEachAllContractProcedure,
493
- forEachContractProcedure,
494
544
  standardizeHTTPPath
495
545
  };
496
546
  //# sourceMappingURL=index.js.map
package/dist/next.js ADDED
@@ -0,0 +1,9 @@
1
+ import {
2
+ OpenAPIHandler
3
+ } from "./chunk-HQ34JZI7.js";
4
+ import "./chunk-M5HOHBLW.js";
5
+ import "./chunk-BHJYKXQL.js";
6
+ export {
7
+ OpenAPIHandler
8
+ };
9
+ //# sourceMappingURL=next.js.map
package/dist/node.js CHANGED
@@ -1,46 +1,30 @@
1
1
  import {
2
- OpenAPIHandler
3
- } from "./chunk-XYIZDXKB.js";
4
- import "./chunk-KNYXLM77.js";
2
+ OpenAPICodec,
3
+ OpenAPIMatcher
4
+ } from "./chunk-M5HOHBLW.js";
5
+ import "./chunk-BHJYKXQL.js";
5
6
 
6
7
  // src/adapters/node/openapi-handler.ts
7
- import { createRequest, sendResponse } from "@orpc/server/node";
8
- var OpenAPIHandler2 = class {
9
- openapiFetchHandler;
10
- constructor(hono, router, options) {
11
- this.openapiFetchHandler = new OpenAPIHandler(hono, router, options);
8
+ import { nodeHttpResponseSendStandardResponse, nodeHttpToStandardRequest } from "@orpc/server/node";
9
+ import { StandardHandler } from "@orpc/server/standard";
10
+ var OpenAPIHandler = class {
11
+ standardHandler;
12
+ constructor(router, options) {
13
+ const matcher = options?.matcher ?? new OpenAPIMatcher(options);
14
+ const codec = options?.codec ?? new OpenAPICodec(options);
15
+ this.standardHandler = new StandardHandler(router, matcher, codec, { ...options });
12
16
  }
13
- async handle(req, res, ...[options]) {
14
- const request = createRequest(req, res);
15
- const castedOptions = options ?? {};
16
- const result = await this.openapiFetchHandler.handle(request, castedOptions);
17
- if (result.matched === false) {
17
+ async handle(req, res, ...rest) {
18
+ const standardRequest = nodeHttpToStandardRequest(req, res);
19
+ const result = await this.standardHandler.handle(standardRequest, ...rest);
20
+ if (!result.matched) {
18
21
  return { matched: false };
19
22
  }
20
- await options?.beforeSend?.(result.response, castedOptions.context);
21
- await sendResponse(res, result.response);
23
+ await nodeHttpResponseSendStandardResponse(res, result.response);
22
24
  return { matched: true };
23
25
  }
24
26
  };
25
-
26
- // src/adapters/node/openapi-handler-server.ts
27
- import { TrieRouter } from "hono/router/trie-router";
28
- var OpenAPIServerHandler = class extends OpenAPIHandler2 {
29
- constructor(router, options) {
30
- super(new TrieRouter(), router, options);
31
- }
32
- };
33
-
34
- // src/adapters/node/openapi-handler-serverless.ts
35
- import { LinearRouter } from "hono/router/linear-router";
36
- var OpenAPIServerlessHandler = class extends OpenAPIHandler2 {
37
- constructor(router, options) {
38
- super(new LinearRouter(), router, options);
39
- }
40
- };
41
27
  export {
42
- OpenAPIHandler2 as OpenAPIHandler,
43
- OpenAPIServerHandler,
44
- OpenAPIServerlessHandler
28
+ OpenAPIHandler
45
29
  };
46
30
  //# sourceMappingURL=node.js.map
@@ -1,10 +1,2 @@
1
- export * from './bracket-notation';
2
- export * from './input-structure-compact';
3
- export * from './input-structure-detailed';
4
1
  export * from './openapi-handler';
5
- export * from './openapi-handler-server';
6
- export * from './openapi-handler-serverless';
7
- export * from './openapi-payload-codec';
8
- export * from './openapi-procedure-matcher';
9
- export * from './schema-coercer';
10
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,32 +1,10 @@
1
- import type { Context, Router, WithSignal } from '@orpc/server';
2
- import type { FetchHandler, FetchHandleRest, FetchHandleResult } from '@orpc/server/fetch';
3
- import type { PublicInputStructureCompact } from './input-structure-compact';
4
- import { type Hooks } from '@orpc/shared';
5
- import { type PublicJSONSerializer } from '../../json-serializer';
6
- import { type PublicInputStructureDetailed } from './input-structure-detailed';
7
- import { type PublicOpenAPIPayloadCodec } from './openapi-payload-codec';
8
- import { type Hono, type PublicOpenAPIProcedureMatcher } from './openapi-procedure-matcher';
9
- import { type SchemaCoercer } from './schema-coercer';
10
- export type OpenAPIHandlerOptions<T extends Context> = Hooks<Request, FetchHandleResult, T, WithSignal> & {
11
- jsonSerializer?: PublicJSONSerializer;
12
- procedureMatcher?: PublicOpenAPIProcedureMatcher;
13
- payloadCodec?: PublicOpenAPIPayloadCodec;
14
- inputBuilderSimple?: PublicInputStructureCompact;
15
- inputBuilderFull?: PublicInputStructureDetailed;
16
- schemaCoercers?: SchemaCoercer[];
17
- };
1
+ import type { Context, Router } from '@orpc/server';
2
+ import type { FetchHandler, FetchHandleResult } from '@orpc/server/fetch';
3
+ import type { StandardHandleRest } from '@orpc/server/standard';
4
+ import type { OpenAPIHandlerOptions } from '../standard';
18
5
  export declare class OpenAPIHandler<T extends Context> implements FetchHandler<T> {
19
- private readonly options?;
20
- private readonly procedureMatcher;
21
- private readonly payloadCodec;
22
- private readonly inputStructureCompact;
23
- private readonly inputStructureDetailed;
24
- private readonly compositeSchemaCoercer;
25
- constructor(hono: Hono, router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>> | undefined);
26
- handle(request: Request, ...[options]: FetchHandleRest<T>): Promise<FetchHandleResult>;
27
- private decodeInput;
28
- private encodeOutput;
29
- private assertDetailedOutput;
30
- private convertToORPCError;
6
+ private readonly standardHandler;
7
+ constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
8
+ handle(request: Request, ...rest: StandardHandleRest<T>): Promise<FetchHandleResult>;
31
9
  }
32
10
  //# sourceMappingURL=openapi-handler.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from '../fetch';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,2 @@
1
1
  export * from './openapi-handler';
2
- export * from './openapi-handler-server';
3
- export * from './openapi-handler-serverless';
4
- export * from './types';
5
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,11 +1,10 @@
1
1
  import type { Context, Router } from '@orpc/server';
2
- import type { IncomingMessage, ServerResponse } from 'node:http';
3
- import type { OpenAPIHandlerOptions } from '../fetch/openapi-handler';
4
- import type { Hono } from '../fetch/openapi-procedure-matcher';
5
- import { type RequestHandler, type RequestHandleRest, type RequestHandleResult } from '@orpc/server/node';
6
- export declare class OpenAPIHandler<T extends Context> implements RequestHandler<T> {
7
- private readonly openapiFetchHandler;
8
- constructor(hono: Hono, router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
9
- handle(req: IncomingMessage, res: ServerResponse, ...[options]: RequestHandleRest<T>): Promise<RequestHandleResult>;
2
+ import type { NodeHttpHandler, NodeHttpHandleResult, NodeHttpRequest, NodeHttpResponse } from '@orpc/server/node';
3
+ import type { StandardHandleRest } from '@orpc/server/standard';
4
+ import type { OpenAPIHandlerOptions } from '../standard';
5
+ export declare class OpenAPIHandler<T extends Context> implements NodeHttpHandler<T> {
6
+ private readonly standardHandler;
7
+ constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
8
+ handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: StandardHandleRest<T>): Promise<NodeHttpHandleResult>;
10
9
  }
11
10
  //# sourceMappingURL=openapi-handler.d.ts.map
@@ -0,0 +1,7 @@
1
+ export * as BracketNotation from './bracket-notation';
2
+ export * from './openapi-codec';
3
+ export * from './openapi-handler';
4
+ export * from './openapi-matcher';
5
+ export * from './openapi-serializer';
6
+ export * from './schema-coercer';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,18 @@
1
+ import type { AnyProcedure } from '@orpc/server';
2
+ import type { StandardCodec, StandardParams, StandardRequest, StandardResponse } from '@orpc/server/standard';
3
+ import { type ORPCError } from '@orpc/contract';
4
+ import { OpenAPISerializer } from './openapi-serializer';
5
+ import { type SchemaCoercer } from './schema-coercer';
6
+ export interface OpenAPICodecOptions {
7
+ serializer?: OpenAPISerializer;
8
+ schemaCoercers?: SchemaCoercer[];
9
+ }
10
+ export declare class OpenAPICodec implements StandardCodec {
11
+ private readonly serializer;
12
+ private readonly compositeSchemaCoercer;
13
+ constructor(options?: OpenAPICodecOptions);
14
+ decode(request: StandardRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
15
+ encode(output: unknown, procedure: AnyProcedure): StandardResponse;
16
+ encodeError(error: ORPCError<any, any>): StandardResponse;
17
+ }
18
+ //# sourceMappingURL=openapi-codec.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { Context } from '@orpc/server';
2
+ import type { RPCHandlerOptions } from '@orpc/server/standard';
3
+ import type { OpenAPICodecOptions } from './openapi-codec';
4
+ import type { OpenAPIMatcherOptions } from './openapi-matcher';
5
+ export interface OpenAPIHandlerOptions<T extends Context> extends RPCHandlerOptions<T>, OpenAPIMatcherOptions, OpenAPICodecOptions {
6
+ }
7
+ //# sourceMappingURL=openapi-handler.d.ts.map
@@ -0,0 +1,20 @@
1
+ import type { AnyRouter } from '@orpc/server';
2
+ import type { StandardMatcher, StandardMatchResult } from '@orpc/server/standard';
3
+ import { type HTTPPath } from '@orpc/contract';
4
+ export interface OpenAPIMatcherOptions {
5
+ /**
6
+ * Ignore procedure that does not have a method defined in the contract.
7
+ *
8
+ * @default false
9
+ */
10
+ ignoreUndefinedMethod?: boolean;
11
+ }
12
+ export declare class OpenAPIMatcher implements StandardMatcher {
13
+ private readonly tree;
14
+ private readonly ignoreUndefinedMethod;
15
+ constructor(options?: OpenAPIMatcherOptions);
16
+ private pendingRouters;
17
+ init(router: AnyRouter, path?: string[]): void;
18
+ match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
19
+ }
20
+ //# sourceMappingURL=openapi-matcher.d.ts.map
@@ -0,0 +1,11 @@
1
+ import type { PublicJSONSerializer } from '../../json-serializer';
2
+ export interface OpenAPISerializerOptions {
3
+ jsonSerializer?: PublicJSONSerializer;
4
+ }
5
+ export declare class OpenAPISerializer {
6
+ private readonly jsonSerializer;
7
+ constructor(options?: OpenAPISerializerOptions);
8
+ serialize(data: unknown): unknown;
9
+ deserialize(serialized: unknown): unknown;
10
+ }
11
+ //# sourceMappingURL=openapi-serializer.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import type { Schema } from '@orpc/contract';
2
2
  export interface SchemaCoercer {
3
- coerce: (schema: Schema, value: unknown) => unknown;
3
+ coerce(schema: Schema, value: unknown): unknown;
4
4
  }
5
5
  export declare class CompositeSchemaCoercer implements SchemaCoercer {
6
6
  private readonly coercers;
@@ -1,9 +1,9 @@
1
- import type { ANY_ROUTER } from '@orpc/server';
2
1
  import type { PublicOpenAPIInputStructureParser } from './openapi-input-structure-parser';
3
2
  import type { PublicOpenAPIOutputStructureParser } from './openapi-output-structure-parser';
4
3
  import type { PublicOpenAPIPathParser } from './openapi-path-parser';
5
4
  import type { SchemaConverter } from './schema-converter';
6
5
  import { type ContractRouter } from '@orpc/contract';
6
+ import { type AnyRouter } from '@orpc/server';
7
7
  import { type PublicJSONSerializer } from './json-serializer';
8
8
  import { type OpenAPI } from './openapi';
9
9
  import { type PublicOpenAPIContentBuilder } from './openapi-content-builder';
@@ -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,8 +59,9 @@ 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
- generate(router: ContractRouter | ANY_ROUTER, doc: Omit<OpenAPI.OpenAPIObject, 'openapi'>): Promise<OpenAPI.OpenAPIObject>;
64
+ generate(router: ContractRouter<any> | AnyRouter, doc: Omit<OpenAPI.OpenAPIObject, 'openapi'>): Promise<OpenAPI.OpenAPIObject>;
58
65
  }
59
66
  export {};
60
67
  //# sourceMappingURL=openapi-generator.d.ts.map
@@ -1,8 +1,8 @@
1
+ import type { AnyContractProcedure } from '@orpc/contract';
1
2
  import type { PublicOpenAPIPathParser } from './openapi-path-parser';
2
3
  import type { JSONSchema, ObjectSchema } from './schema';
3
4
  import type { SchemaConverter } from './schema-converter';
4
5
  import type { PublicSchemaUtils } from './schema-utils';
5
- import { type ANY_CONTRACT_PROCEDURE } from '@orpc/contract';
6
6
  export interface OpenAPIInputStructureParseResult {
7
7
  paramsSchema: ObjectSchema | undefined;
8
8
  querySchema: ObjectSchema | undefined;
@@ -14,7 +14,7 @@ export declare class OpenAPIInputStructureParser {
14
14
  private readonly schemaUtils;
15
15
  private readonly pathParser;
16
16
  constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils, pathParser: PublicOpenAPIPathParser);
17
- parse(contract: ANY_CONTRACT_PROCEDURE, structure: 'compact' | 'detailed'): OpenAPIInputStructureParseResult;
17
+ parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIInputStructureParseResult;
18
18
  private parseDetailedSchema;
19
19
  private parseCompactSchema;
20
20
  }
@@ -1,4 +1,4 @@
1
- import type { ANY_CONTRACT_PROCEDURE } from '@orpc/contract';
1
+ import type { AnyContractProcedure } from '@orpc/contract';
2
2
  import type { JSONSchema, ObjectSchema } from './schema';
3
3
  import type { SchemaConverter } from './schema-converter';
4
4
  import type { PublicSchemaUtils } from './schema-utils';
@@ -10,7 +10,7 @@ export declare class OpenAPIOutputStructureParser {
10
10
  private readonly schemaConverter;
11
11
  private readonly schemaUtils;
12
12
  constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils);
13
- parse(contract: ANY_CONTRACT_PROCEDURE, structure: 'compact' | 'detailed'): OpenAPIOutputStructureParseResult;
13
+ parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIOutputStructureParseResult;
14
14
  private parseDetailedSchema;
15
15
  private parseCompactSchema;
16
16
  }
@@ -4,8 +4,8 @@ export interface SchemaConvertOptions {
4
4
  strategy: 'input' | 'output';
5
5
  }
6
6
  export interface SchemaConverter {
7
- condition: (schema: Schema, options: SchemaConvertOptions) => boolean;
8
- convert: (schema: Schema, options: SchemaConvertOptions) => JSONSchema.JSONSchema;
7
+ condition(schema: Schema, options: SchemaConvertOptions): boolean;
8
+ convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema;
9
9
  }
10
10
  export declare class CompositeSchemaConverter implements SchemaConverter {
11
11
  private readonly converters;
@@ -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: ("$anchor" | "$comment" | "$defs" | "$dynamicAnchor" | "$dynamicRef" | "$id" | "$schema" | "$vocabulary" | "contentEncoding" | "contentMediaType" | "default" | "definitions" | "deprecated" | "description" | "examples" | "format" | "readOnly" | "title" | "writeOnly")[];
11
+ export declare const NON_LOGIC_KEYWORDS: string[];
12
12
  //# sourceMappingURL=schema.d.ts.map
@@ -1,18 +1,3 @@
1
- import type { ContractRouter, HTTPPath, WELL_CONTRACT_PROCEDURE } from '@orpc/contract';
2
- import type { ANY_PROCEDURE, ANY_ROUTER, Lazy } from '@orpc/server';
3
- export interface EachLeafOptions {
4
- router: ContractRouter | ANY_ROUTER;
5
- path: string[];
6
- }
7
- export interface EachLeafCallbackOptions {
8
- contract: WELL_CONTRACT_PROCEDURE;
9
- path: string[];
10
- }
11
- export interface EachContractLeafResultItem {
12
- router: Lazy<ANY_PROCEDURE> | Lazy<Record<string, ANY_ROUTER> | ANY_PROCEDURE>;
13
- path: string[];
14
- }
15
- export declare function forEachContractProcedure(options: EachLeafOptions, callback: (options: EachLeafCallbackOptions) => void, result?: EachContractLeafResultItem[], isCurrentRouterContract?: boolean): EachContractLeafResultItem[];
16
- export declare function forEachAllContractProcedure(router: ContractRouter | ANY_ROUTER, callback: (options: EachLeafCallbackOptions) => void): Promise<void>;
1
+ import type { HTTPPath } from '@orpc/contract';
17
2
  export declare function standardizeHTTPPath(path: HTTPPath): HTTPPath;
18
3
  //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,16 @@
1
+ import {
2
+ CompositeSchemaCoercer,
3
+ OpenAPICodec,
4
+ OpenAPIMatcher,
5
+ OpenAPISerializer,
6
+ bracket_notation_exports
7
+ } from "./chunk-M5HOHBLW.js";
8
+ import "./chunk-BHJYKXQL.js";
9
+ export {
10
+ bracket_notation_exports as BracketNotation,
11
+ CompositeSchemaCoercer,
12
+ OpenAPICodec,
13
+ OpenAPIMatcher,
14
+ OpenAPISerializer
15
+ };
16
+ //# sourceMappingURL=standard.js.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.aa72097",
4
+ "version": "0.0.0-next.ad0709a",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -19,6 +19,11 @@
19
19
  "import": "./dist/index.js",
20
20
  "default": "./dist/index.js"
21
21
  },
22
+ "./standard": {
23
+ "types": "./dist/src/adapters/standard/index.d.ts",
24
+ "import": "./dist/standard.js",
25
+ "default": "./dist/standard.js"
26
+ },
22
27
  "./fetch": {
23
28
  "types": "./dist/src/adapters/fetch/index.d.ts",
24
29
  "import": "./dist/fetch.js",
@@ -29,6 +34,11 @@
29
34
  "import": "./dist/hono.js",
30
35
  "default": "./dist/hono.js"
31
36
  },
37
+ "./next": {
38
+ "types": "./dist/src/adapters/next/index.d.ts",
39
+ "import": "./dist/next.js",
40
+ "default": "./dist/next.js"
41
+ },
32
42
  "./node": {
33
43
  "types": "./dist/src/adapters/node/index.d.ts",
34
44
  "import": "./dist/node.js",
@@ -49,13 +59,13 @@
49
59
  "content-disposition": "^0.5.4",
50
60
  "escape-string-regexp": "^5.0.0",
51
61
  "fast-content-type-parse": "^2.0.0",
52
- "hono": "^4.6.12",
53
62
  "json-schema-typed": "^8.0.1",
54
63
  "openapi3-ts": "^4.4.0",
64
+ "rou3": "^0.5.1",
55
65
  "wildcard-match": "^5.1.3",
56
- "@orpc/contract": "0.0.0-next.aa72097",
57
- "@orpc/shared": "0.0.0-next.aa72097",
58
- "@orpc/server": "0.0.0-next.aa72097"
66
+ "@orpc/shared": "0.0.0-next.ad0709a",
67
+ "@orpc/server": "0.0.0-next.ad0709a",
68
+ "@orpc/contract": "0.0.0-next.ad0709a"
59
69
  },
60
70
  "devDependencies": {
61
71
  "@readme/openapi-parser": "^2.6.0",