@orpc/openapi 2.0.0-beta.5 → 2.0.0-beta.51

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 (90) hide show
  1. package/README.md +139 -102
  2. package/dist/adapters/aws-lambda/index.d.ts +3 -0
  3. package/dist/adapters/aws-lambda/index.js +1 -0
  4. package/dist/adapters/aws-lambda/openapi-handler.d.ts +17 -0
  5. package/dist/adapters/aws-lambda/openapi-handler.js +20 -0
  6. package/dist/adapters/fastify/index.d.ts +2 -0
  7. package/dist/adapters/fastify/index.js +1 -0
  8. package/dist/adapters/fastify/openapi-handler.d.ts +14 -0
  9. package/dist/adapters/fastify/openapi-handler.js +17 -0
  10. package/dist/adapters/fetch/index.d.ts +3 -27
  11. package/dist/adapters/fetch/index.js +2 -0
  12. package/dist/adapters/fetch/openapi-handler.d.ts +14 -0
  13. package/dist/adapters/fetch/openapi-handler.js +17 -0
  14. package/dist/adapters/fetch/openapi-link.d.ts +20 -0
  15. package/dist/adapters/fetch/openapi-link.js +22 -0
  16. package/dist/adapters/node/index.d.ts +2 -18
  17. package/dist/adapters/node/index.js +1 -0
  18. package/dist/adapters/node/openapi-handler.d.ts +14 -0
  19. package/dist/adapters/node/openapi-handler.js +17 -0
  20. package/dist/adapters/standard/index.d.ts +4 -50
  21. package/dist/adapters/standard/index.js +3 -0
  22. package/dist/adapters/standard/openapi-handler-codec.d.ts +61 -0
  23. package/dist/adapters/standard/openapi-handler-codec.js +158 -0
  24. package/dist/adapters/standard/openapi-link-codec.d.ts +58 -0
  25. package/dist/adapters/standard/openapi-link-codec.js +290 -0
  26. package/dist/adapters/standard/openapi-matcher.d.ts +29 -0
  27. package/dist/adapters/standard/openapi-matcher.js +78 -0
  28. package/dist/adapters/standard/utils.js +31 -0
  29. package/dist/bracket-notation.d.ts +26 -0
  30. package/dist/bracket-notation.js +135 -0
  31. package/dist/client-factory.d.ts +24 -0
  32. package/dist/client-factory.js +15 -0
  33. package/dist/constants.d.ts +1 -0
  34. package/dist/constants.js +5 -0
  35. package/dist/extensions/route.d.ts +36 -42
  36. package/dist/extensions/route.js +13 -0
  37. package/dist/helpers/{index.d.mts → form-data.d.ts} +11 -5
  38. package/dist/helpers/form-data.js +78 -0
  39. package/dist/helpers/index.d.ts +2 -51
  40. package/dist/helpers/index.js +1 -0
  41. package/dist/index.d.ts +15 -120
  42. package/dist/index.js +11 -0
  43. package/dist/meta.d.ts +327 -0
  44. package/dist/meta.js +66 -0
  45. package/dist/openapi-generator-components.d.ts +2 -0
  46. package/dist/openapi-generator-components.js +318 -0
  47. package/dist/openapi-generator-operation.d.ts +13 -0
  48. package/dist/openapi-generator-operation.js +459 -0
  49. package/dist/openapi-generator.d.ts +87 -0
  50. package/dist/openapi-generator.js +119 -0
  51. package/dist/openapi-json-serializer.d.ts +79 -0
  52. package/dist/openapi-json-serializer.js +221 -0
  53. package/dist/openapi-serializer.d.ts +42 -0
  54. package/dist/openapi-serializer.js +69 -0
  55. package/dist/plugins/index.d.ts +2 -90
  56. package/dist/plugins/index.js +1 -0
  57. package/dist/plugins/openapi-reference.d.ts +112 -0
  58. package/dist/plugins/openapi-reference.js +164 -0
  59. package/dist/router-utils.d.ts +18 -0
  60. package/dist/router-utils.js +32 -0
  61. package/dist/types.d.ts +28 -0
  62. package/dist/utils.d.ts +9 -0
  63. package/dist/utils.js +44 -0
  64. package/package.json +87 -49
  65. package/dist/adapters/fetch/index.d.mts +0 -27
  66. package/dist/adapters/fetch/index.mjs +0 -34
  67. package/dist/adapters/node/index.d.mts +0 -18
  68. package/dist/adapters/node/index.mjs +0 -21
  69. package/dist/adapters/standard/index.d.mts +0 -50
  70. package/dist/adapters/standard/index.mjs +0 -12
  71. package/dist/extensions/route.d.mts +0 -43
  72. package/dist/extensions/route.mjs +0 -14
  73. package/dist/helpers/index.mjs +0 -39
  74. package/dist/index.d.mts +0 -120
  75. package/dist/index.mjs +0 -930
  76. package/dist/plugins/index.d.mts +0 -90
  77. package/dist/plugins/index.mjs +0 -162
  78. package/dist/shared/openapi.7vgmPxca.d.ts +0 -82
  79. package/dist/shared/openapi.B2SK0ZAr.mjs +0 -359
  80. package/dist/shared/openapi.B9PQzqBn.mjs +0 -49
  81. package/dist/shared/openapi.BQzzr4-4.d.ts +0 -299
  82. package/dist/shared/openapi.BcEtAxQj.d.mts +0 -299
  83. package/dist/shared/openapi.Bt87OzTt.mjs +0 -131
  84. package/dist/shared/openapi.C7m7NAmH.d.mts +0 -142
  85. package/dist/shared/openapi.C7m7NAmH.d.ts +0 -142
  86. package/dist/shared/openapi.CTlpLuKN.mjs +0 -318
  87. package/dist/shared/openapi.CX6Ri5dP.d.mts +0 -82
  88. package/dist/shared/openapi.CYgMBSUF.d.mts +0 -18
  89. package/dist/shared/openapi.CYgMBSUF.d.ts +0 -18
  90. package/dist/shared/openapi.DmAa7YPO.mjs +0 -275
@@ -0,0 +1,164 @@
1
+ import { getTracer, matchesHttpPath, mergeHttpPath, stringifyJSON, toArray, value } from "@orpc/shared";
2
+ // src/plugins/openapi-reference.ts
3
+ /**
4
+ * Serves API reference documentation powered by Scalar or Swagger UI,
5
+ * and exposes the OpenAPI specification as JSON.
6
+ *
7
+ * @remarks
8
+ * **Note**: By default, the API reference UI is served from `/` and the OpenAPI specification from `/spec.json`.
9
+ *
10
+ * @see {@link https://orpc.dev/docs/plugins/openapi-reference | OpenAPI Reference Plugin (Swagger/Scalar)}
11
+ */
12
+ var OpenAPIReferenceHandlerPlugin = class {
13
+ name = "~openapi-reference";
14
+ spec;
15
+ allow;
16
+ specPath;
17
+ provider;
18
+ providerConfig;
19
+ providerScriptUrl;
20
+ providerCssUrl;
21
+ docsPath;
22
+ docsTitle;
23
+ docsHead;
24
+ constructor(options) {
25
+ this.spec = options.spec;
26
+ this.allow = options.allow;
27
+ this.specPath = options.specPath ?? "/spec.json";
28
+ this.provider = options.provider ?? "scalar";
29
+ this.providerConfig = options.providerConfig;
30
+ this.providerScriptUrl = options.providerScriptUrl;
31
+ this.providerCssUrl = options.providerCssUrl;
32
+ this.docsTitle = options.docsTitle;
33
+ this.docsPath = options.docsPath ?? "/";
34
+ this.docsHead = options.docsHead ?? "";
35
+ }
36
+ init(options) {
37
+ return {
38
+ ...options,
39
+ routingInterceptors: [...toArray(options.routingInterceptors), async ({ next, ...routingInterceptorOptions }) => {
40
+ const result = await next();
41
+ if (result.matched || routingInterceptorOptions.request.method !== "GET") return result;
42
+ const isSpecPath = matchesHttpPath(routingInterceptorOptions.request.url, routingInterceptorOptions.prefix ? mergeHttpPath(routingInterceptorOptions.prefix, this.specPath) : this.specPath);
43
+ const isDocsPath = matchesHttpPath(routingInterceptorOptions.request.url, routingInterceptorOptions.prefix ? mergeHttpPath(routingInterceptorOptions.prefix, this.docsPath) : this.docsPath);
44
+ if (!isSpecPath && !isDocsPath) return result;
45
+ if (await value(this.allow, routingInterceptorOptions) === false) return result;
46
+ const span = getTracer()?.getActiveSpan();
47
+ const spec = await value(this.spec, routingInterceptorOptions);
48
+ if (isSpecPath) {
49
+ span?.updateName(`${routingInterceptorOptions.request.method} ${routingInterceptorOptions.request.url} (openapi spec)`);
50
+ return {
51
+ matched: true,
52
+ response: {
53
+ status: 200,
54
+ headers: {},
55
+ body: new File([stringifyJSON(spec)], `${spec.info.title}.json`, { type: "application/json" })
56
+ }
57
+ };
58
+ }
59
+ span?.updateName(`${routingInterceptorOptions.request.method} ${routingInterceptorOptions.request.url} (${this.provider} ui)`);
60
+ const docsTitle = await value(this.docsTitle, routingInterceptorOptions) ?? spec.info.title;
61
+ const docsHead = await value(this.docsHead, routingInterceptorOptions);
62
+ let html;
63
+ if (this.provider === "swagger") {
64
+ const scriptUrl = this.providerScriptUrl ?? "https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js";
65
+ const cssUrl = this.providerCssUrl ?? "https://unpkg.com/swagger-ui-dist/swagger-ui.css";
66
+ const config = {
67
+ dom_id: "#app",
68
+ spec,
69
+ deepLinking: true,
70
+ presets: ["SwaggerUIBundle.presets.apis"],
71
+ plugins: ["SwaggerUIBundle.plugins.DownloadUrl"],
72
+ ...this.providerConfig
73
+ };
74
+ html = `
75
+ <!doctype html>
76
+ <html>
77
+ <head>
78
+ <meta charset="utf-8" />
79
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
80
+ <title>${escapeHtmlEntities(docsTitle)}</title>
81
+ <link rel="stylesheet" type="text/css" href="${escapeHtmlEntities(cssUrl)}" />
82
+ ${docsHead}
83
+ </head>
84
+ <body>
85
+ <div id="app"></div>
86
+
87
+ <script src="${escapeHtmlEntities(scriptUrl)}"><\/script>
88
+
89
+ <!-- IMPORTANT: assign to a variable first to prevent ), ( in values breaking the call expression. -->
90
+ <!-- IMPORTANT: escapeJsonForHtml ensures <, > cannot terminate the <\/script> tag prematurely. -->
91
+ <!-- IMPORTANT: resolve presets/plugins global paths at runtime, never unquote them in the JSON, which also holds the spec. -->
92
+ <script>
93
+ const swaggerConfig = ${escapeJsonForHtml(config)}
94
+
95
+ window.onload = () => {
96
+ for (const key of ['presets', 'plugins']) {
97
+ swaggerConfig[key] &&= swaggerConfig[key].map(path => path.split('.').reduce((value, name) => value?.[name], window))
98
+ }
99
+
100
+ window.ui = SwaggerUIBundle(swaggerConfig)
101
+ }
102
+ <\/script>
103
+ </body>
104
+ </html>
105
+ `;
106
+ } else {
107
+ const scriptUrl = this.providerScriptUrl ?? "https://cdn.jsdelivr.net/npm/@scalar/api-reference";
108
+ const cssUrl = this.providerCssUrl;
109
+ const config = {
110
+ content: stringifyJSON(spec),
111
+ ...this.providerConfig
112
+ };
113
+ html = `
114
+ <!doctype html>
115
+ <html>
116
+ <head>
117
+ <meta charset="utf-8" />
118
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
119
+ <title>${escapeHtmlEntities(docsTitle)}</title>
120
+ ${cssUrl ? `<link rel="stylesheet" type="text/css" href="${escapeHtmlEntities(cssUrl)}" />` : ""}
121
+ ${docsHead}
122
+ </head>
123
+ <body>
124
+ <div id="app"></div>
125
+
126
+ <script src="${escapeHtmlEntities(scriptUrl)}"><\/script>
127
+
128
+ <!-- IMPORTANT: assign to a variable first to prevent ), ( in values breaking the call expression. -->
129
+ <!-- IMPORTANT: escapeJsonForHtml ensures <, > cannot terminate the <\/script> tag prematurely. -->
130
+ <script>
131
+ const scalarConfig = ${escapeJsonForHtml(config)}
132
+
133
+ Scalar.createApiReference('#app', scalarConfig)
134
+ <\/script>
135
+ </body>
136
+ </html>
137
+ `;
138
+ }
139
+ return {
140
+ matched: true,
141
+ response: {
142
+ status: 200,
143
+ headers: { "content-disposition": [] },
144
+ body: new Blob([html], { type: "text/html" })
145
+ }
146
+ };
147
+ }]
148
+ };
149
+ }
150
+ };
151
+ /** Escapes a string for safe embedding in an HTML attribute value. */
152
+ function escapeHtmlEntities(s) {
153
+ return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
154
+ }
155
+ /**
156
+ * Serialises a value to JSON safe for HTML embedding (attribute or <script>).
157
+ * Uses Unicode escapes instead of HTML entities so JSON.parse reconstructs
158
+ * the original values without corruption. Cannot be merged with `esc` —
159
+ * HTML entities inside <script> are not decoded by the JS engine.
160
+ */
161
+ function escapeJsonForHtml(obj) {
162
+ return stringifyJSON(obj).replace(/&/g, "\\u0026").replace(/'/g, "\\u0027").replace(/</g, "\\u003C").replace(/>/g, "\\u003E").replace(/\//g, "\\u002F");
163
+ }
164
+ export { OpenAPIReferenceHandlerPlugin };
@@ -0,0 +1,18 @@
1
+ import { ProcedureContract, RouterContract } from "@orpc/contract";
2
+ export type PopulatedContractRouterOpenAPIPaths<T extends RouterContract> = PopulatedContractRouterOpenAPIPathsInternal<T>;
3
+ export type PopulatedContractRouterOpenAPIPathsInternal<T> = T extends ProcedureContract<infer UInputSchema, infer UOutputSchema, infer UErrors> ? ProcedureContract<UInputSchema, UOutputSchema, UErrors> : { [K in keyof T]: PopulatedContractRouterOpenAPIPathsInternal<T[K] & {}>; };
4
+ export interface PopulateRouterContractOpenAPIPathsOptions {
5
+ /**
6
+ * Base path segments.
7
+ */
8
+ path?: string[] | undefined;
9
+ }
10
+ /**
11
+ * Automatically populates missing openapi.path using router structure.
12
+ *
13
+ * Builds paths by joining router keys with `/`.
14
+ * Useful when you want to ensure all contracts define openapi.path, such as for NestJS integration requirements.
15
+ *
16
+ * @see {@link https://orpc.dev/docs/integrations/nest | Implement oRPC contract with NestJS}
17
+ */
18
+ export declare function populateRouterContractOpenAPIPaths<T extends RouterContract>(router: T, options?: PopulateRouterContractOpenAPIPathsOptions): PopulatedContractRouterOpenAPIPaths<T>;
@@ -0,0 +1,32 @@
1
+ import { getOpenAPIMeta, openapi } from "./meta.js";
2
+ import { isNonPrimitive, pathToHttpPath, toArray } from "@orpc/shared";
3
+ import { ProcedureContract, resolveMetaPlugins } from "@orpc/contract";
4
+ // src/router-utils.ts
5
+ /**
6
+ * Automatically populates missing openapi.path using router structure.
7
+ *
8
+ * Builds paths by joining router keys with `/`.
9
+ * Useful when you want to ensure all contracts define openapi.path, such as for NestJS integration requirements.
10
+ *
11
+ * @see {@link https://orpc.dev/docs/integrations/nest | Implement oRPC contract with NestJS}
12
+ */
13
+ function populateRouterContractOpenAPIPaths(router, options = {}) {
14
+ const path = toArray(options.path);
15
+ if (router instanceof ProcedureContract) {
16
+ if (getOpenAPIMeta(router)?.path !== void 0) return router;
17
+ const [meta, metaPlugins] = resolveMetaPlugins(router["~orpc"].meta, router["~orpc"].metaPlugins, [openapi({ path: pathToHttpPath(path) })]);
18
+ return new ProcedureContract({
19
+ ...router["~orpc"],
20
+ meta,
21
+ metaPlugins
22
+ });
23
+ }
24
+ if (!isNonPrimitive(router)) return router;
25
+ const populated = {};
26
+ for (const key of Object.keys(router)) populated[key] = populateRouterContractOpenAPIPaths(router[key], {
27
+ ...options,
28
+ path: [...path, key]
29
+ });
30
+ return populated;
31
+ }
32
+ export { populateRouterContractOpenAPIPaths };
@@ -0,0 +1,28 @@
1
+ import { AsyncIteratorClass } from "@orpc/shared";
2
+ import { AnyNestedClient, Client, ORPCError } from "@orpc/client";
3
+ import * as OpenAPIV3_0 from "@openapi-spec/types/v3.0";
4
+ import * as OpenAPIV3_1 from "@openapi-spec/types/v3.1";
5
+ import * as OpenAPIV3_2 from "@openapi-spec/types/v3.2";
6
+ /**
7
+ * An OpenAPI version `OpenAPIGenerator` can target: any `3.0.x`, `3.1.x`, or `3.2.x` value.
8
+ *
9
+ * @see {@link https://orpc.dev/docs/openapi/specification#openapi-version | OpenAPI Specification - OpenAPI Version}
10
+ */
11
+ export type OpenAPIVersion = `3.0.${number}` | `3.1.${number}` | `3.2.${number}`;
12
+ /**
13
+ * The OpenAPI document of the given version.
14
+ *
15
+ * @see {@link https://orpc.dev/docs/openapi/specification#openapi-version | OpenAPI Specification - OpenAPI Version}
16
+ */
17
+ export type OpenAPIDocument<TVersion extends OpenAPIVersion> = TVersion extends `3.0.${string}` ? OpenAPIV3_0.OpenAPIObject : TVersion extends `3.1.${string}` ? OpenAPIV3_1.OpenAPIObject : OpenAPIV3_2.OpenAPIObject;
18
+ export type JsonifiedValue<T> = T extends string | number | boolean | null | undefined ? T : T extends Date | bigint | URL ? string : T extends ReadonlyArray<unknown> ? JsonifiedArray<T> : T extends Blob | ReadonlyMap<any, any> | ReadonlySet<any> | AsyncIteratorObject<any, any, any> | Function ? T extends File ? File : T extends Blob ? Blob : T extends ReadonlyMap<infer K, infer V> ? JsonifiedArray<[K, V][]> : T extends ReadonlySet<infer U> ? JsonifiedArray<U[]> : T extends AsyncIteratorClass<infer U, infer V> ? AsyncIteratorClass<JsonifiedValue<U>, JsonifiedValue<V>> : T extends AsyncGenerator<infer U, infer V> ? AsyncGenerator<JsonifiedValue<U>, JsonifiedValue<V>> : T extends AsyncIteratorObject<infer U, infer V> ? AsyncIteratorObject<JsonifiedValue<U>, JsonifiedValue<V>> : unknown : T extends object ? { [K in keyof T]: JsonifiedValue<T[K]>; } : unknown;
19
+ export type JsonifiedArray<T extends ReadonlyArray<unknown>> = T extends readonly [] ? [] : T extends readonly [infer U, ...infer V] ? [U extends undefined ? null : JsonifiedValue<U>, ...JsonifiedArray<V>] : T extends ReadonlyArray<infer U> ? Array<JsonifiedValue<U>> : unknown;
20
+ export type JsonifiedClientError<T> = T extends ORPCError<infer UCode, infer UData> ? ORPCError<UCode, JsonifiedValue<UData>> : T;
21
+ /**
22
+ * Client type whose outputs and error data replace types JSON cannot represent with their JSON equivalents.
23
+ *
24
+ * @see {@link https://orpc.dev/docs/openapi/link | OpenAPI Link}
25
+ */
26
+ export type JsonifiedClient<T extends AnyNestedClient> = JsonifiedClientInternal<T>;
27
+ export type JsonifiedClientInternal<T> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Client<UClientContext, UInput, JsonifiedValue<UOutput>, JsonifiedClientError<UError>> : { [K in keyof T]: JsonifiedClientInternal<T[K] & {}>; };
28
+ export type { OpenAPIV3_0, OpenAPIV3_1, OpenAPIV3_2 };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Dynamic parameters are always returned in path order.
3
+ */
4
+ export declare function getDynamicPathParams(path: `/${string}`): {
5
+ segment: string;
6
+ startIndex: number;
7
+ parameterName: string;
8
+ allowsSlash: boolean;
9
+ }[] | undefined;
package/dist/utils.js ADDED
@@ -0,0 +1,44 @@
1
+ // src/utils.ts
2
+ /**
3
+ * GET and HEAD requests cannot carry a request body,
4
+ * so their compact input maps to query parameters instead.
5
+ */
6
+ function isBodylessMethod(method) {
7
+ return method === "GET" || method === "HEAD";
8
+ }
9
+ const PARAMETER_NAME_REGEX = /^[\w-]+$/;
10
+ /**
11
+ * Dynamic parameters are always returned in path order.
12
+ */
13
+ function getDynamicPathParams(path) {
14
+ if (!path.includes("{")) return;
15
+ const len = path.length;
16
+ let params;
17
+ let index = 1;
18
+ while (index < len) {
19
+ const segmentStart = index;
20
+ const slashPos = path.indexOf("/", index);
21
+ const segmentEnd = slashPos === -1 ? len : slashPos;
22
+ if (segmentEnd > segmentStart && path.charCodeAt(segmentStart) === 123 && path.charCodeAt(segmentEnd - 1) === 125) {
23
+ let parameterStart = segmentStart + 1;
24
+ let allowsSlash = false;
25
+ if (path.charCodeAt(parameterStart) === 43) {
26
+ allowsSlash = true;
27
+ parameterStart++;
28
+ }
29
+ const parameterName = path.slice(parameterStart, segmentEnd - 1);
30
+ if (PARAMETER_NAME_REGEX.test(parameterName)) {
31
+ params ??= [];
32
+ params.push({
33
+ segment: path.slice(segmentStart, segmentEnd),
34
+ startIndex: segmentStart,
35
+ parameterName,
36
+ allowsSlash
37
+ });
38
+ }
39
+ }
40
+ index = segmentEnd + 1;
41
+ }
42
+ return params;
43
+ }
44
+ export { getDynamicPathParams, isBodylessMethod };
package/package.json CHANGED
@@ -1,82 +1,120 @@
1
1
  {
2
2
  "name": "@orpc/openapi",
3
- "type": "module",
4
- "version": "2.0.0-beta.5",
5
- "license": "MIT",
3
+ "version": "2.0.0-beta.51",
4
+ "description": "Generate OpenAPI specs from oRPC routers and serve OpenAPI-compliant APIs with end-to-end type safety",
5
+ "keywords": [
6
+ "api",
7
+ "json-schema",
8
+ "openapi",
9
+ "orpc",
10
+ "rest",
11
+ "rpc",
12
+ "scalar",
13
+ "swagger",
14
+ "typesafe",
15
+ "typescript"
16
+ ],
6
17
  "homepage": "https://orpc.dev",
18
+ "license": "MIT",
7
19
  "repository": {
8
20
  "type": "git",
9
21
  "url": "git+https://github.com/middleapi/orpc.git",
10
22
  "directory": "packages/openapi"
11
23
  },
12
- "keywords": [
13
- "orpc",
14
- "openapi"
24
+ "funding": [
25
+ "https://github.com/sponsors/dinwwwh",
26
+ "https://opencollective.com/middleapi"
27
+ ],
28
+ "files": [
29
+ "dist"
15
30
  ],
31
+ "type": "module",
16
32
  "sideEffects": [
17
- "./dist/extensions/route.mjs"
33
+ "./dist/extensions/route.js"
18
34
  ],
19
35
  "exports": {
20
36
  "./package.json": "./package.json",
21
37
  ".": {
22
- "types": "./dist/index.d.mts",
23
- "import": "./dist/index.mjs",
24
- "default": "./dist/index.mjs"
38
+ "types": "./dist/index.d.ts",
39
+ "import": "./dist/index.js",
40
+ "default": "./dist/index.js"
25
41
  },
26
42
  "./helpers": {
27
- "types": "./dist/helpers/index.d.mts",
28
- "import": "./dist/helpers/index.mjs",
29
- "default": "./dist/helpers/index.mjs"
43
+ "types": "./dist/helpers/index.d.ts",
44
+ "import": "./dist/helpers/index.js",
45
+ "default": "./dist/helpers/index.js"
30
46
  },
31
47
  "./plugins": {
32
- "types": "./dist/plugins/index.d.mts",
33
- "import": "./dist/plugins/index.mjs",
34
- "default": "./dist/plugins/index.mjs"
48
+ "types": "./dist/plugins/index.d.ts",
49
+ "import": "./dist/plugins/index.js",
50
+ "default": "./dist/plugins/index.js"
35
51
  },
36
52
  "./standard": {
37
- "types": "./dist/adapters/standard/index.d.mts",
38
- "import": "./dist/adapters/standard/index.mjs",
39
- "default": "./dist/adapters/standard/index.mjs"
53
+ "types": "./dist/adapters/standard/index.d.ts",
54
+ "import": "./dist/adapters/standard/index.js",
55
+ "default": "./dist/adapters/standard/index.js"
40
56
  },
41
57
  "./fetch": {
42
- "types": "./dist/adapters/fetch/index.d.mts",
43
- "import": "./dist/adapters/fetch/index.mjs",
44
- "default": "./dist/adapters/fetch/index.mjs"
58
+ "types": "./dist/adapters/fetch/index.d.ts",
59
+ "import": "./dist/adapters/fetch/index.js",
60
+ "default": "./dist/adapters/fetch/index.js"
45
61
  },
46
62
  "./node": {
47
- "types": "./dist/adapters/node/index.d.mts",
48
- "import": "./dist/adapters/node/index.mjs",
49
- "default": "./dist/adapters/node/index.mjs"
63
+ "types": "./dist/adapters/node/index.d.ts",
64
+ "import": "./dist/adapters/node/index.js",
65
+ "default": "./dist/adapters/node/index.js"
66
+ },
67
+ "./aws-lambda": {
68
+ "types": "./dist/adapters/aws-lambda/index.d.ts",
69
+ "import": "./dist/adapters/aws-lambda/index.js",
70
+ "default": "./dist/adapters/aws-lambda/index.js"
71
+ },
72
+ "./fastify": {
73
+ "types": "./dist/adapters/fastify/index.d.ts",
74
+ "import": "./dist/adapters/fastify/index.js",
75
+ "default": "./dist/adapters/fastify/index.js"
50
76
  },
51
77
  "./extensions/route": {
52
- "types": "./dist/extensions/route.d.mts",
53
- "import": "./dist/extensions/route.mjs",
54
- "default": "./dist/extensions/route.mjs"
78
+ "types": "./dist/extensions/route.d.ts",
79
+ "import": "./dist/extensions/route.js",
80
+ "default": "./dist/extensions/route.js"
55
81
  }
56
82
  },
57
- "files": [
58
- "dist"
59
- ],
60
83
  "dependencies": {
61
- "@hey-api/spec-types": "0.0.0-next-20260408030107",
62
- "@scalar/api-reference": "^1.57.2",
63
- "@standardserver/core": "^0.0.25",
64
- "@standardserver/fetch": "^0.0.25",
65
- "@types/swagger-ui": "^5.32.0",
66
- "rou3": "^0.8.1",
67
- "swagger-ui": "^5.32.6",
68
- "@orpc/json-schema": "2.0.0-beta.5",
69
- "@orpc/contract": "2.0.0-beta.5",
70
- "@orpc/server": "2.0.0-beta.5",
71
- "@orpc/shared": "2.0.0-beta.5",
72
- "@orpc/client": "2.0.0-beta.5"
84
+ "@openapi-spec/downgrader": "~0.8.0",
85
+ "@openapi-spec/router": "~0.8.0",
86
+ "@openapi-spec/types": "~0.8.0",
87
+ "@orpc/client": "2.0.0-beta.51",
88
+ "@orpc/contract": "2.0.0-beta.51",
89
+ "@orpc/json-schema": "2.0.0-beta.51",
90
+ "@orpc/server": "2.0.0-beta.51",
91
+ "@orpc/shared": "2.0.0-beta.51",
92
+ "@standard-server/core": "~0.16.0",
93
+ "@standard-server/fetch": "~0.16.0"
73
94
  },
74
95
  "devDependencies": {
75
- "fastify": "^5.6.2",
76
- "zod": "^4.4.3"
96
+ "@scalar/api-reference": "^1.76.4",
97
+ "@standard-server/aws-lambda": "~0.16.0",
98
+ "@types/swagger-ui": "^5.32.1",
99
+ "fastify": "^5.12.8",
100
+ "swagger-ui": "^5.34.1",
101
+ "zod": "^4.6.7"
102
+ },
103
+ "peerDependencies": {
104
+ "@scalar/api-reference": ">=1.57.2",
105
+ "@types/swagger-ui": ">=5.32.0",
106
+ "swagger-ui": ">=5.32.6"
107
+ },
108
+ "peerDependenciesMeta": {
109
+ "@scalar/api-reference": {
110
+ "optional": true
111
+ },
112
+ "@types/swagger-ui": {
113
+ "optional": true
114
+ },
115
+ "swagger-ui": {
116
+ "optional": true
117
+ }
77
118
  },
78
- "scripts": {
79
- "build": "unbuild",
80
- "type:check": "tsc -b"
81
- }
119
+ "scripts": {}
82
120
  }
@@ -1,27 +0,0 @@
1
- import { Context, Router } from '@orpc/server';
2
- import { FetchHandler, FetchHandlerOptions } from '@orpc/server/fetch';
3
- import { StandardHandlerOptions } from '@orpc/server/standard';
4
- import { O as OpenAPIHandlerCodecOptions } from '../../shared/openapi.CX6Ri5dP.mjs';
5
- import { ClientContext } from '@orpc/client';
6
- import { FetchLinkTransportOptions } from '@orpc/client/fetch';
7
- import { StandardLink, StandardLinkOptions } from '@orpc/client/standard';
8
- import { RouterContract } from '@orpc/contract';
9
- import { OpenAPILinkCodecOptions } from '../standard/index.mjs';
10
- import '@orpc/shared';
11
- import '@standardserver/core';
12
- import '../../shared/openapi.C7m7NAmH.mjs';
13
-
14
- interface OpenAPIHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, Omit<StandardHandlerOptions<T>, 'plugins'>, OpenAPIHandlerCodecOptions<T> {
15
- }
16
- declare class OpenAPIHandler<T extends Context> extends FetchHandler<T> {
17
- constructor(router: Router<T>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
18
- }
19
-
20
- interface OpenAPILinkOptions<T extends ClientContext> extends Omit<StandardLinkOptions<T>, 'plugins'>, FetchLinkTransportOptions<T>, OpenAPILinkCodecOptions<T> {
21
- }
22
- declare class OpenAPILink<T extends ClientContext> extends StandardLink<T> {
23
- constructor(router: RouterContract, options?: OpenAPILinkOptions<T>);
24
- }
25
-
26
- export { OpenAPIHandler, OpenAPILink };
27
- export type { OpenAPIHandlerOptions, OpenAPILinkOptions };
@@ -1,34 +0,0 @@
1
- import { FetchHandler } from '@orpc/server/fetch';
2
- import { StandardHandler } from '@orpc/server/standard';
3
- import { O as OpenAPIHandlerCodec } from '../../shared/openapi.CTlpLuKN.mjs';
4
- import { FetchLinkTransport } from '@orpc/client/fetch';
5
- import { StandardLink } from '@orpc/client/standard';
6
- import { O as OpenAPILinkCodec } from '../../shared/openapi.B2SK0ZAr.mjs';
7
- import '@orpc/client';
8
- import '@orpc/server';
9
- import '@orpc/shared';
10
- import '@standardserver/core';
11
- import '../../shared/openapi.DmAa7YPO.mjs';
12
- import '../../shared/openapi.Bt87OzTt.mjs';
13
- import '../../shared/openapi.B9PQzqBn.mjs';
14
- import 'rou3';
15
- import '@orpc/contract';
16
- import '@standardserver/fetch';
17
-
18
- class OpenAPIHandler extends FetchHandler {
19
- constructor(router, options = {}) {
20
- const codec = new OpenAPIHandlerCodec(router, options);
21
- const handler = new StandardHandler(codec, options);
22
- super(handler, options);
23
- }
24
- }
25
-
26
- class OpenAPILink extends StandardLink {
27
- constructor(router, options = {}) {
28
- const codec = new OpenAPILinkCodec(router, options);
29
- const transport = new FetchLinkTransport(options);
30
- super(codec, transport, options);
31
- }
32
- }
33
-
34
- export { OpenAPIHandler, OpenAPILink };
@@ -1,18 +0,0 @@
1
- import { Context, Router } from '@orpc/server';
2
- import { NodeHttpHandler, NodeHttpHandlerOptions } from '@orpc/server/node';
3
- import { StandardHandlerOptions } from '@orpc/server/standard';
4
- import { O as OpenAPIHandlerCodecOptions } from '../../shared/openapi.CX6Ri5dP.mjs';
5
- import '@orpc/client';
6
- import '@orpc/shared';
7
- import '@standardserver/core';
8
- import '@orpc/contract';
9
- import '../../shared/openapi.C7m7NAmH.mjs';
10
-
11
- interface OpenAPIHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>, Omit<StandardHandlerOptions<T>, 'plugins'>, OpenAPIHandlerCodecOptions<T> {
12
- }
13
- declare class OpenAPIHandler<T extends Context> extends NodeHttpHandler<T> {
14
- constructor(router: Router<T>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
15
- }
16
-
17
- export { OpenAPIHandler };
18
- export type { OpenAPIHandlerOptions };
@@ -1,21 +0,0 @@
1
- import { NodeHttpHandler } from '@orpc/server/node';
2
- import { StandardHandler } from '@orpc/server/standard';
3
- import { O as OpenAPIHandlerCodec } from '../../shared/openapi.CTlpLuKN.mjs';
4
- import '@orpc/client';
5
- import '@orpc/server';
6
- import '@orpc/shared';
7
- import '@standardserver/core';
8
- import '../../shared/openapi.DmAa7YPO.mjs';
9
- import '../../shared/openapi.Bt87OzTt.mjs';
10
- import '../../shared/openapi.B9PQzqBn.mjs';
11
- import 'rou3';
12
-
13
- class OpenAPIHandler extends NodeHttpHandler {
14
- constructor(router, options = {}) {
15
- const codec = new OpenAPIHandlerCodec(router, options);
16
- const handler = new StandardHandler(codec, options);
17
- super(handler, options);
18
- }
19
- }
20
-
21
- export { OpenAPIHandler };
@@ -1,50 +0,0 @@
1
- export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.CX6Ri5dP.mjs';
2
- import { ClientContext, ClientOptions, AnyORPCError } from '@orpc/client';
3
- import { StandardLinkCodec, StandardLinkCodecDecodedResponse } from '@orpc/client/standard';
4
- import { RouterContract } from '@orpc/contract';
5
- import { Value, Promisable } from '@orpc/shared';
6
- import { StandardUrl, StandardHeaders, StandardLazyResponse, StandardRequest } from '@standardserver/core';
7
- import { O as OpenAPISerializer } from '../../shared/openapi.C7m7NAmH.mjs';
8
- import '@orpc/server';
9
- import '@orpc/server/standard';
10
-
11
- declare class OpenAPILinkCodecError extends TypeError {
12
- }
13
- interface OpenAPILinkCodecOptions<T extends ClientContext> {
14
- /**
15
- * Base URL for all requests, without origin. Should match the OpenAPI handler mount path.
16
- *
17
- * @example '/api'
18
- * @default '/'
19
- */
20
- url?: Value<Promisable<StandardUrl>, [options: ClientOptions<T>, path: string[], input: unknown]>;
21
- /**
22
- * Inject headers into the request.
23
- */
24
- headers?: Value<Promisable<StandardHeaders | Headers>, [options: ClientOptions<T>, path: string[], input: unknown]>;
25
- /**
26
- * Override the default OpenAPI serializer.
27
- */
28
- serializer?: Pick<OpenAPISerializer, keyof OpenAPISerializer>;
29
- /**
30
- * Customize how an error response body is converted into an ORPC error.
31
- * Return `null` or `undefined` to fall back to the default decoding behavior.
32
- */
33
- customErrorResponseBodyDecoder?: (deserializedBody: unknown, response: StandardLazyResponse) => AnyORPCError | null | undefined;
34
- }
35
- declare class OpenAPILinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
36
- private readonly router;
37
- private readonly baseUrl;
38
- private readonly headers;
39
- private readonly serializer;
40
- private readonly customErrorResponseBodyDecoder;
41
- constructor(router: RouterContract, options?: OpenAPILinkCodecOptions<T>);
42
- encodeInput(input: unknown, path: string[], options: ClientOptions<T>): Promise<StandardRequest>;
43
- private encodePathParam;
44
- private serializeQueryString;
45
- decodeResponse(response: StandardLazyResponse, path: string[], _options: ClientOptions<T>): Promise<StandardLinkCodecDecodedResponse>;
46
- private resolveProcedure;
47
- }
48
-
49
- export { OpenAPILinkCodec, OpenAPILinkCodecError };
50
- export type { OpenAPILinkCodecOptions };
@@ -1,12 +0,0 @@
1
- export { O as OpenAPIHandlerCodec, a as OpenAPIHandlerCodecCore, b as OpenAPIMatcher } from '../../shared/openapi.CTlpLuKN.mjs';
2
- export { O as OpenAPILinkCodec, a as OpenAPILinkCodecError } from '../../shared/openapi.B2SK0ZAr.mjs';
3
- import '@orpc/client';
4
- import '@orpc/server';
5
- import '@orpc/shared';
6
- import '@standardserver/core';
7
- import '../../shared/openapi.DmAa7YPO.mjs';
8
- import '../../shared/openapi.Bt87OzTt.mjs';
9
- import '../../shared/openapi.B9PQzqBn.mjs';
10
- import 'rou3';
11
- import '@orpc/contract';
12
- import '@standardserver/fetch';