@orpc/openapi 2.0.0-beta.47 → 2.0.0-beta.48

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 (88) hide show
  1. package/README.md +2 -3
  2. package/dist/adapters/aws-lambda/index.d.mts +14 -26
  3. package/dist/adapters/aws-lambda/index.mjs +1 -21
  4. package/dist/adapters/aws-lambda/openapi-handler.d.mts +17 -0
  5. package/dist/adapters/aws-lambda/openapi-handler.mjs +11 -0
  6. package/dist/adapters/fastify/index.d.mts +1 -23
  7. package/dist/adapters/fastify/index.mjs +1 -21
  8. package/dist/adapters/fastify/openapi-handler.d.mts +14 -0
  9. package/dist/adapters/fastify/openapi-handler.mjs +11 -0
  10. package/dist/adapters/fetch/index.d.mts +2 -37
  11. package/dist/adapters/fetch/index.mjs +2 -34
  12. package/dist/adapters/fetch/openapi-handler.d.mts +14 -0
  13. package/dist/adapters/fetch/openapi-handler.mjs +11 -0
  14. package/dist/adapters/fetch/openapi-link.d.mts +15 -0
  15. package/dist/adapters/fetch/openapi-link.mjs +11 -0
  16. package/dist/adapters/node/index.d.mts +1 -23
  17. package/dist/adapters/node/index.mjs +1 -21
  18. package/dist/adapters/node/openapi-handler.d.mts +14 -0
  19. package/dist/adapters/node/openapi-handler.mjs +11 -0
  20. package/dist/adapters/standard/index.d.mts +3 -56
  21. package/dist/adapters/standard/index.mjs +3 -12
  22. package/dist/adapters/standard/openapi-handler-codec.d.mts +61 -0
  23. package/dist/adapters/standard/openapi-handler-codec.mjs +203 -0
  24. package/dist/adapters/standard/openapi-link-codec.d.mts +53 -0
  25. package/dist/adapters/standard/openapi-link-codec.mjs +356 -0
  26. package/dist/adapters/standard/openapi-matcher.d.mts +29 -0
  27. package/dist/adapters/standard/openapi-matcher.mjs +105 -0
  28. package/dist/adapters/standard/utils.d.mts +4 -0
  29. package/dist/adapters/standard/utils.mjs +36 -0
  30. package/dist/bracket-notation.d.mts +26 -0
  31. package/dist/bracket-notation.mjs +156 -0
  32. package/dist/client-factory.d.mts +24 -0
  33. package/dist/client-factory.mjs +5 -0
  34. package/dist/constants.d.mts +4 -0
  35. package/dist/constants.mjs +4 -0
  36. package/dist/extensions/route.d.mts +74 -39
  37. package/dist/extensions/route.mjs +8 -10
  38. package/dist/helpers/form-data.d.mts +57 -0
  39. package/dist/helpers/form-data.mjs +36 -0
  40. package/dist/helpers/index.d.mts +1 -59
  41. package/dist/helpers/index.mjs +1 -39
  42. package/dist/index.d.mts +13 -166
  43. package/dist/index.mjs +11 -780
  44. package/dist/meta.d.mts +345 -0
  45. package/dist/meta.mjs +56 -0
  46. package/dist/openapi-generator-components.d.mts +24 -0
  47. package/dist/openapi-generator-components.mjs +227 -0
  48. package/dist/openapi-generator-operation.d.mts +29 -0
  49. package/dist/openapi-generator-operation.mjs +447 -0
  50. package/dist/openapi-generator.d.mts +87 -0
  51. package/dist/openapi-generator.mjs +115 -0
  52. package/dist/openapi-json-serializer.d.mts +86 -0
  53. package/dist/openapi-json-serializer.mjs +229 -0
  54. package/dist/openapi-serializer.d.mts +43 -0
  55. package/dist/openapi-serializer.mjs +87 -0
  56. package/dist/plugins/index.d.mts +1 -121
  57. package/dist/plugins/index.mjs +1 -167
  58. package/dist/plugins/openapi-reference.d.mts +118 -0
  59. package/dist/plugins/openapi-reference.mjs +157 -0
  60. package/dist/router-utils.d.mts +18 -0
  61. package/dist/router-utils.mjs +29 -0
  62. package/dist/types.d.mts +27 -0
  63. package/dist/types.mjs +1 -0
  64. package/dist/utils.d.mts +14 -0
  65. package/dist/utils.mjs +40 -0
  66. package/package.json +15 -15
  67. package/dist/adapters/aws-lambda/index.d.ts +0 -27
  68. package/dist/adapters/fastify/index.d.ts +0 -23
  69. package/dist/adapters/fetch/index.d.ts +0 -37
  70. package/dist/adapters/node/index.d.ts +0 -23
  71. package/dist/adapters/standard/index.d.ts +0 -56
  72. package/dist/extensions/route.d.ts +0 -41
  73. package/dist/helpers/index.d.ts +0 -59
  74. package/dist/index.d.ts +0 -166
  75. package/dist/plugins/index.d.ts +0 -121
  76. package/dist/shared/openapi.B9PQzqBn.mjs +0 -49
  77. package/dist/shared/openapi.CQkXu1nY.mjs +0 -366
  78. package/dist/shared/openapi.Covi8zVE.d.mts +0 -33
  79. package/dist/shared/openapi.Covi8zVE.d.ts +0 -33
  80. package/dist/shared/openapi.DfmCR1pB.d.mts +0 -94
  81. package/dist/shared/openapi.DtEVcxuW.mjs +0 -149
  82. package/dist/shared/openapi.E3ZBiweM.mjs +0 -353
  83. package/dist/shared/openapi.Y4K_-I5W.d.ts +0 -94
  84. package/dist/shared/openapi.YMRD3b4R.d.mts +0 -157
  85. package/dist/shared/openapi.YMRD3b4R.d.ts +0 -157
  86. package/dist/shared/openapi.g7ucL05o.mjs +0 -410
  87. package/dist/shared/openapi.zGZlCOwp.d.mts +0 -329
  88. package/dist/shared/openapi.zGZlCOwp.d.ts +0 -329
@@ -1,39 +1 @@
1
- import { isSchemaIssue } from '@orpc/contract';
2
- import { isTypescriptObject } from '@orpc/shared';
3
- import { B as BracketNotationSerializer } from '../shared/openapi.DtEVcxuW.mjs';
4
-
5
- function parseFormData(form) {
6
- const serializer = new BracketNotationSerializer();
7
- return serializer.deserialize(Array.from(form.entries()));
8
- }
9
- function getIssueMessage(error, path) {
10
- if (!isTypescriptObject(error) || !isTypescriptObject(error.data) || !Array.isArray(error.data.issues)) {
11
- return void 0;
12
- }
13
- const serializer = new BracketNotationSerializer();
14
- for (const issue of error.data.issues) {
15
- if (!isSchemaIssue(issue)) {
16
- continue;
17
- }
18
- if (issue.path === void 0) {
19
- if (path === "") {
20
- return issue.message;
21
- }
22
- continue;
23
- }
24
- const issuePath = serializer.stringifyPath(
25
- issue.path.map((segment) => typeof segment === "object" ? segment.key.toString() : segment.toString())
26
- );
27
- if (issuePath === path) {
28
- return issue.message;
29
- }
30
- if (path.endsWith("[]") && issuePath.replace(/\[(?:0|[1-9]\d*)\]$/, "[]") === path) {
31
- return issue.message;
32
- }
33
- if (path === "" && /^(?:0|[1-9]\d*)$/.test(issuePath)) {
34
- return issue.message;
35
- }
36
- }
37
- }
38
-
39
- export { getIssueMessage, parseFormData };
1
+ export * from "./form-data.mjs";
package/dist/index.d.mts CHANGED
@@ -1,166 +1,13 @@
1
- import { a as OpenAPIJsonSerializer } from './shared/openapi.YMRD3b4R.mjs';
2
- export { B as BracketNotationSerializeResult, b as BracketNotationSerializer, c as BracketNotationSerializerOptions, d as OpenAPIJsonSerialization, e as OpenAPIJsonSerializerHandler, f as OpenAPIJsonSerializerOptions, O as OpenAPISerializer, g as OpenAPISerializerOptions, h as OpenAPISerializerSerializeOptions } from './shared/openapi.YMRD3b4R.mjs';
3
- import { ClientContext, ORPCClientOptions, ClientLink } from '@orpc/client';
4
- export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
5
- import { RouterContract, RouterContractClient, AnyProcedureContract, ProcedureContract } from '@orpc/contract';
6
- import { J as JsonifiedClient, a as OpenAPIVersion, O as OpenAPIDocument } from './shared/openapi.Covi8zVE.mjs';
7
- export { b as JsonifiedArray, c as JsonifiedClientError, d as JsonifiedValue } from './shared/openapi.Covi8zVE.mjs';
8
- export { a as OpenAPIFunction, O as OpenAPIMeta, b as OpenAPIMetaPlugin, c as OpenAPIMethodMetaPlugin, d as OpenAPIPathMetaPlugin, e as OpenAPIPrefixMetaPlugin, f as OpenAPISpecMetaPlugin, g as getOpenAPIMeta, o as openapi } from './shared/openapi.zGZlCOwp.mjs';
9
- import { JsonSchema, JsonSchemaConverter } from '@orpc/json-schema';
10
- export { JsonSchema } from '@orpc/json-schema';
11
- import { AnyRouter, AnyProcedure } from '@orpc/server';
12
- import { Public, Value } from '@orpc/shared';
13
- import * as OpenAPIV3_2 from '@openapi-spec/types/v3.2';
14
- export { OpenAPIV3_2 };
15
- export { StandardBodyHint } from '@standard-server/core';
16
- import * as OpenAPIV3_0 from '@openapi-spec/types/v3.0';
17
- export { OpenAPIV3_0 };
18
- import * as OpenAPIV3_1 from '@openapi-spec/types/v3.1';
19
- export { OpenAPIV3_1 };
20
-
21
- interface ContractJsonifiedClientFactory<TClientContext extends ClientContext> {
22
- <T extends RouterContract>(contract: T): JsonifiedClient<RouterContractClient<T, TClientContext>>;
23
- }
24
- interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientContext> extends Pick<ORPCClientOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>, 'interceptors' | 'scoped'> {
25
- /**
26
- * An optional reference to the root router-contract.
27
- * When provided, the client factory will automatically register the passed contract
28
- * into the router at the path defined by `meta.path`.
29
- */
30
- contractRef?: RouterContract | undefined;
31
- }
32
- /**
33
- * Like `createContractClientFactory`, but the clients it builds are typed as `JsonifiedClient`,
34
- * for links that require it, such as OpenAPI Link.
35
- *
36
- * @remarks
37
- * **Warning**: Every procedure contract passed to the factory must define `meta.path` matching its location in the root contract.
38
- *
39
- * @see {@link https://orpc.dev/docs/contract/client-factory | Contract Client Factory}
40
- */
41
- declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
42
-
43
- declare const DEFAULT_OPENAPI_METHOD = "POST";
44
-
45
- /**
46
- * Dynamic parameters are always returned in path order.
47
- */
48
- declare function getDynamicPathParams(path: `/${string}`): {
49
- segment: string;
50
- startIndex: number;
51
- parameterName: string;
52
- allowsSlash: boolean;
53
- }[] | undefined;
54
-
55
- declare class OpenAPIGeneratorError extends TypeError {
56
- }
57
- interface OpenAPIErrorBodyDefinition {
58
- code: string;
59
- defaultMessage: string | undefined;
60
- dataOptional: boolean;
61
- dataJsonSchema: JsonSchema;
62
- }
63
-
64
- interface OpenAPIGeneratorOptions {
65
- converters?: JsonSchemaConverter[] | undefined;
66
- /**
67
- * The serializer used to serialize the generated OpenAPI documentation
68
- */
69
- serializer?: Public<OpenAPIJsonSerializer> | undefined;
70
- }
71
- interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
72
- /**
73
- * The OpenAPI version of the generated document.
74
- * The document is generated as OpenAPI 3.2 and downgraded when an older version is requested.
75
- * The minor version selects the conversion, the document carries the exact value, such as `3.1.0`.
76
- *
77
- * @default '3.2.0'
78
- */
79
- version?: TVersion | undefined;
80
- /**
81
- * OpenAPI 3.2 document fields to start from, such as `info`, `servers`, or `components`.
82
- * They are downgraded with the rest of the document when an older `version` is requested.
83
- * The `openapi` field is derived from `version`.
84
- */
85
- base?: Partial<Omit<OpenAPIV3_2.OpenAPIObject, 'openapi'>> | undefined;
86
- /**
87
- * Root-level `$defs` are always moved into `components.schemas`.
88
- * Use this to customize the component name of a hoisted def.
89
- *
90
- * @remarks
91
- * - The returned name is a preference, conflicting names are still postfixed (`Planet`, `PlanetInput`, `Planet2`, ...).
92
- * - Return `undefined` to keep the original def name.
93
- *
94
- * @default defName => defName
95
- */
96
- componentName?: ((defName: string, defSchema: JsonSchema) => string | undefined) | undefined;
97
- /**
98
- * Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
99
- *
100
- * @default true
101
- */
102
- filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]> | undefined;
103
- /**
104
- * Define a custom JSON schema for the error response body when using
105
- * type-safe errors. Helps align ORPC error formatting with existing API
106
- * response standards or conventions.
107
- *
108
- * @remarks
109
- * - Return `null | undefined` to use the default error response body shaper.
110
- * - The schema is an OpenAPI 3.2 Schema Object, it is downgraded with the rest of the document when an older `version` is requested.
111
- */
112
- errorResponseBodySchema?: Value<JsonSchema | undefined | null, [
113
- definedErrors: OpenAPIErrorBodyDefinition[],
114
- status: number
115
- ]> | undefined;
116
- /**
117
- * Media type of error responses in the generated document, e.g. `application/problem+json`.
118
- * Should match the handler's `errorResponseContentType`.
119
- *
120
- * @default 'application/json'
121
- */
122
- errorResponseContentType?: string | undefined;
123
- /**
124
- * Mapping ORPCError Code -> HTTP Status Code
125
- * Codes missing from the map fall back to `DEFAULT_ERROR_STATUS` (400).
126
- *
127
- * @default COMMON_ERROR_STATUS_MAP
128
- */
129
- errorStatusMap?: Record<string, number> | undefined;
130
- }
131
- /**
132
- * Generates an OpenAPI document from a contract or router.
133
- * Relies on JSON schema converters to translate input, output, and error schemas into JSON Schemas.
134
- *
135
- * @see {@link https://orpc.dev/docs/openapi/specification#openapi-generator | OpenAPI Specification - OpenAPI Generator}
136
- */
137
- declare class OpenAPIGenerator {
138
- private readonly serializer;
139
- private readonly converter;
140
- constructor(options?: OpenAPIGeneratorOptions);
141
- generate<TVersion extends OpenAPIVersion = '3.2.0'>(router: RouterContract | AnyRouter, options?: OpenAPIGeneratorGenerateOptions<TVersion>): Promise<OpenAPIDocument<TVersion>>;
142
- private convertSchema;
143
- private convertSchemas;
144
- }
145
-
146
- type PopulatedContractRouterOpenAPIPaths<T extends RouterContract> = T extends ProcedureContract<infer UInputSchema, infer UOutputSchema, infer UErrors> ? ProcedureContract<UInputSchema, UOutputSchema, UErrors> : {
147
- [K in keyof T]: T[K] extends RouterContract ? PopulatedContractRouterOpenAPIPaths<T[K]> : never;
148
- };
149
- interface PopulateRouterContractOpenAPIPathsOptions {
150
- /**
151
- * Base path segments.
152
- */
153
- path?: string[] | undefined;
154
- }
155
- /**
156
- * Automatically populates missing openapi.path using router structure.
157
- *
158
- * Builds paths by joining router keys with `/`.
159
- * Useful when you want to ensure all contracts define openapi.path, such as for NestJS integration requirements.
160
- *
161
- * @see {@link https://orpc.dev/docs/integrations/nest | Implement oRPC contract with NestJS}
162
- */
163
- declare function populateRouterContractOpenAPIPaths<T extends RouterContract>(router: T, options?: PopulateRouterContractOpenAPIPathsOptions): PopulatedContractRouterOpenAPIPaths<T>;
164
-
165
- export { DEFAULT_OPENAPI_METHOD, JsonifiedClient, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPIJsonSerializer, OpenAPIVersion, createContractJsonifiedClientFactory, getDynamicPathParams, populateRouterContractOpenAPIPaths };
166
- export type { ContractJsonifiedClientFactory, ContractJsonifiedClientFactoryOptions, OpenAPIErrorBodyDefinition, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, PopulateRouterContractOpenAPIPathsOptions, PopulatedContractRouterOpenAPIPaths };
1
+ export * from "./bracket-notation.mjs";
2
+ export * from "./client-factory.mjs";
3
+ export { DEFAULT_OPENAPI_METHOD } from "./constants.mjs";
4
+ export * from "./meta.mjs";
5
+ export * from "./openapi-generator.mjs";
6
+ export * from "./openapi-json-serializer.mjs";
7
+ export * from "./openapi-serializer.mjs";
8
+ export * from "./router-utils.mjs";
9
+ export * from "./types.mjs";
10
+ export { getDynamicPathParams } from "./utils.mjs";
11
+ export { COMMON_ERROR_STATUS_MAP } from "@orpc/client";
12
+ export type { JsonSchema } from "@orpc/json-schema";
13
+ export type { StandardBodyHint } from "@standard-server/core";