@orpc/openapi 2.0.0-beta.1 → 2.0.0-beta.3
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/adapters/fetch/index.d.mts +1 -1
- package/dist/adapters/fetch/index.d.ts +1 -1
- package/dist/adapters/fetch/index.mjs +1 -1
- package/dist/adapters/node/index.d.mts +1 -1
- package/dist/adapters/node/index.d.ts +1 -1
- package/dist/adapters/node/index.mjs +1 -1
- package/dist/adapters/standard/index.d.mts +1 -1
- package/dist/adapters/standard/index.d.ts +1 -1
- package/dist/adapters/standard/index.mjs +1 -1
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.mjs +6 -6
- package/dist/shared/{openapi.CcyUEuTs.mjs → openapi.B3H7yHQa.mjs} +48 -43
- package/dist/shared/{openapi.C9Olbxd5.d.ts → openapi.DBYxUpK8.d.ts} +18 -11
- package/dist/shared/{openapi.Drd1OtzG.d.mts → openapi.DuDd2iQz.d.mts} +18 -11
- package/package.json +9 -9
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
|
2
2
|
import { FetchHandler, FetchHandlerOptions } from '@orpc/server/fetch';
|
|
3
3
|
import { StandardHandlerOptions } from '@orpc/server/standard';
|
|
4
|
-
import { O as OpenAPIHandlerCodecOptions } from '../../shared/openapi.
|
|
4
|
+
import { O as OpenAPIHandlerCodecOptions } from '../../shared/openapi.DuDd2iQz.mjs';
|
|
5
5
|
import { ClientContext } from '@orpc/client';
|
|
6
6
|
import { FetchLinkTransportOptions } from '@orpc/client/fetch';
|
|
7
7
|
import { StandardLink, StandardLinkOptions } from '@orpc/client/standard';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
|
2
2
|
import { FetchHandler, FetchHandlerOptions } from '@orpc/server/fetch';
|
|
3
3
|
import { StandardHandlerOptions } from '@orpc/server/standard';
|
|
4
|
-
import { O as OpenAPIHandlerCodecOptions } from '../../shared/openapi.
|
|
4
|
+
import { O as OpenAPIHandlerCodecOptions } from '../../shared/openapi.DBYxUpK8.js';
|
|
5
5
|
import { ClientContext } from '@orpc/client';
|
|
6
6
|
import { FetchLinkTransportOptions } from '@orpc/client/fetch';
|
|
7
7
|
import { StandardLink, StandardLinkOptions } from '@orpc/client/standard';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FetchHandler } from '@orpc/server/fetch';
|
|
2
2
|
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
-
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.
|
|
3
|
+
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.B3H7yHQa.mjs';
|
|
4
4
|
import { FetchLinkTransport } from '@orpc/client/fetch';
|
|
5
5
|
import { StandardLink } from '@orpc/client/standard';
|
|
6
6
|
import { O as OpenAPILinkCodec } from '../../shared/openapi.B2SK0ZAr.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
|
2
2
|
import { NodeHttpHandler, NodeHttpHandlerOptions } from '@orpc/server/node';
|
|
3
3
|
import { StandardHandlerOptions } from '@orpc/server/standard';
|
|
4
|
-
import { O as OpenAPIHandlerCodecOptions } from '../../shared/openapi.
|
|
4
|
+
import { O as OpenAPIHandlerCodecOptions } from '../../shared/openapi.DuDd2iQz.mjs';
|
|
5
5
|
import '@orpc/client';
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@standardserver/core';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
|
2
2
|
import { NodeHttpHandler, NodeHttpHandlerOptions } from '@orpc/server/node';
|
|
3
3
|
import { StandardHandlerOptions } from '@orpc/server/standard';
|
|
4
|
-
import { O as OpenAPIHandlerCodecOptions } from '../../shared/openapi.
|
|
4
|
+
import { O as OpenAPIHandlerCodecOptions } from '../../shared/openapi.DBYxUpK8.js';
|
|
5
5
|
import '@orpc/client';
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@standardserver/core';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeHttpHandler } from '@orpc/server/node';
|
|
2
2
|
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
-
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.
|
|
3
|
+
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.B3H7yHQa.mjs';
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/server';
|
|
6
6
|
import '@orpc/shared';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as OpenAPIHandlerCodec, b as
|
|
1
|
+
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.DuDd2iQz.mjs';
|
|
2
2
|
import { ClientContext, ClientOptions, AnyORPCError } from '@orpc/client';
|
|
3
3
|
import { StandardLinkCodec, StandardLinkCodecDecodedResponse } from '@orpc/client/standard';
|
|
4
4
|
import { RouterContract } from '@orpc/contract';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as OpenAPIHandlerCodec, b as
|
|
1
|
+
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.DBYxUpK8.js';
|
|
2
2
|
import { ClientContext, ClientOptions, AnyORPCError } from '@orpc/client';
|
|
3
3
|
import { StandardLinkCodec, StandardLinkCodecDecodedResponse } from '@orpc/client/standard';
|
|
4
4
|
import { RouterContract } from '@orpc/contract';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { O as OpenAPIHandlerCodec, a as
|
|
1
|
+
export { O as OpenAPIHandlerCodec, a as OpenAPIHandlerCodecCore, b as OpenAPIMatcher } from '../../shared/openapi.B3H7yHQa.mjs';
|
|
2
2
|
export { O as OpenAPILinkCodec, a as OpenAPILinkCodecError } from '../../shared/openapi.B2SK0ZAr.mjs';
|
|
3
3
|
import '@orpc/client';
|
|
4
4
|
import '@orpc/server';
|
package/dist/index.d.mts
CHANGED
|
@@ -9,7 +9,7 @@ export { d as JsonifiedArray, O as OpenAPIOperationObject } from './shared/opena
|
|
|
9
9
|
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.BcEtAxQj.mjs';
|
|
10
10
|
import { JsonSchemaConverter, JsonSchema } from '@orpc/json-schema';
|
|
11
11
|
import { AnyRouter, AnyProcedure } from '@orpc/server';
|
|
12
|
-
|
|
12
|
+
export { StandardBodyHint } from '@standardserver/core';
|
|
13
13
|
import '@hey-api/spec-types';
|
|
14
14
|
|
|
15
15
|
interface ContractJsonifiedCaller<TClientContext extends ClientContext> {
|
|
@@ -25,6 +25,11 @@ interface ContractJsonifiedCallerOptions<TClientContext extends ClientContext> e
|
|
|
25
25
|
}
|
|
26
26
|
declare function createContractJsonifiedCaller<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedCallerOptions<TClientContext>): ContractJsonifiedCaller<TClientContext>;
|
|
27
27
|
|
|
28
|
+
declare const DEFAULT_OPENAPI_METHOD = "POST";
|
|
29
|
+
declare const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = "OK";
|
|
30
|
+
declare const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
|
|
31
|
+
declare const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
|
|
32
|
+
|
|
28
33
|
declare class OpenAPIGeneratorError extends TypeError {
|
|
29
34
|
}
|
|
30
35
|
interface OpenAPIGeneratorOptions {
|
|
@@ -94,5 +99,5 @@ declare function getDynamicPathParams(path: `/${string}`): {
|
|
|
94
99
|
allowsSlash: boolean;
|
|
95
100
|
}[] | undefined;
|
|
96
101
|
|
|
97
|
-
export { JsonifiedClient, JsonifiedClientError, JsonifiedValue, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPISerializer, createContractJsonifiedCaller, getDynamicPathParams };
|
|
102
|
+
export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, JsonifiedClient, JsonifiedClientError, JsonifiedValue, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPISerializer, createContractJsonifiedCaller, getDynamicPathParams };
|
|
98
103
|
export type { ContractJsonifiedCaller, ContractJsonifiedCallerOptions, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { d as JsonifiedArray, O as OpenAPIOperationObject } from './shared/opena
|
|
|
9
9
|
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.BQzzr4-4.js';
|
|
10
10
|
import { JsonSchemaConverter, JsonSchema } from '@orpc/json-schema';
|
|
11
11
|
import { AnyRouter, AnyProcedure } from '@orpc/server';
|
|
12
|
-
|
|
12
|
+
export { StandardBodyHint } from '@standardserver/core';
|
|
13
13
|
import '@hey-api/spec-types';
|
|
14
14
|
|
|
15
15
|
interface ContractJsonifiedCaller<TClientContext extends ClientContext> {
|
|
@@ -25,6 +25,11 @@ interface ContractJsonifiedCallerOptions<TClientContext extends ClientContext> e
|
|
|
25
25
|
}
|
|
26
26
|
declare function createContractJsonifiedCaller<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedCallerOptions<TClientContext>): ContractJsonifiedCaller<TClientContext>;
|
|
27
27
|
|
|
28
|
+
declare const DEFAULT_OPENAPI_METHOD = "POST";
|
|
29
|
+
declare const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = "OK";
|
|
30
|
+
declare const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
|
|
31
|
+
declare const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
|
|
32
|
+
|
|
28
33
|
declare class OpenAPIGeneratorError extends TypeError {
|
|
29
34
|
}
|
|
30
35
|
interface OpenAPIGeneratorOptions {
|
|
@@ -94,5 +99,5 @@ declare function getDynamicPathParams(path: `/${string}`): {
|
|
|
94
99
|
allowsSlash: boolean;
|
|
95
100
|
}[] | undefined;
|
|
96
101
|
|
|
97
|
-
export { JsonifiedClient, JsonifiedClientError, JsonifiedValue, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPISerializer, createContractJsonifiedCaller, getDynamicPathParams };
|
|
102
|
+
export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, JsonifiedClient, JsonifiedClientError, JsonifiedValue, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPISerializer, createContractJsonifiedCaller, getDynamicPathParams };
|
|
98
103
|
export type { ContractJsonifiedCaller, ContractJsonifiedCallerOptions, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export { B as BracketNotationSerializer } from './shared/openapi.Bt87OzTt.mjs';
|
|
2
2
|
import { createContractCaller, getEventIteratorSchemaDetails } from '@orpc/contract';
|
|
3
|
+
import { O as OpenAPISerializer, D as DEFAULT_OPENAPI_METHOD, g as getDynamicPathParams, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, c as DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE } from './shared/openapi.DmAa7YPO.mjs';
|
|
4
|
+
export { d as OpenAPIJsonSerializer } from './shared/openapi.DmAa7YPO.mjs';
|
|
3
5
|
import { g as getOpenAPIMeta } from './shared/openapi.B9PQzqBn.mjs';
|
|
4
6
|
export { o as openapi } from './shared/openapi.B9PQzqBn.mjs';
|
|
5
7
|
import { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
|
|
6
8
|
export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
|
|
7
|
-
import { DelegatingJsonSchemaConverter, StandardJsonSchemaConverter, combineJsonSchemasWithComposition, isUnconstrainedSchema, extractJsonObjectSchemaEntries, combineJsonObjectSchemaEntries, isJsonPrimitiveSchema, matchArrayableJsonSchema,
|
|
9
|
+
import { DelegatingJsonSchemaConverter, StandardJsonSchemaConverter, combineJsonSchemasWithComposition, isUnconstrainedSchema, extractJsonObjectSchemaEntries, combineJsonObjectSchemaEntries, flattenJsonUnionSchema, isJsonPrimitiveSchema, matchArrayableJsonSchema, ensureJsonSchemaObject, isJsonFileSchema, mapJsonSchemaRefs, encodeJsonPointerSegment, decodeJsonPointerSegment } from '@orpc/json-schema';
|
|
8
10
|
import { walkProcedureContractsAsync, DEFAULT_SUCCESS_STATUS, DEFAULT_ERROR_STATUS } from '@orpc/server';
|
|
9
11
|
import { toArray, clone, value, pathToHttpPath, mergeHttpPath, stringifyJSON, findDeepMatches, isPlainObject, isDeepEqual } from '@orpc/shared';
|
|
10
|
-
import { O as OpenAPISerializer, D as DEFAULT_OPENAPI_METHOD, g as getDynamicPathParams, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, c as DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE } from './shared/openapi.DmAa7YPO.mjs';
|
|
11
|
-
export { d as OpenAPIJsonSerializer } from './shared/openapi.DmAa7YPO.mjs';
|
|
12
12
|
import '@standardserver/core';
|
|
13
13
|
|
|
14
14
|
function createContractJsonifiedCaller(link, options = {}) {
|
|
@@ -202,9 +202,9 @@ ${errors.join("\n\n")}`
|
|
|
202
202
|
};
|
|
203
203
|
delete parameter.schema;
|
|
204
204
|
} else if (style === void 0) {
|
|
205
|
-
if (!isJsonPrimitiveSchema(
|
|
205
|
+
if (flattenJsonUnionSchema(schema2).some((s) => !isJsonPrimitiveSchema(s))) {
|
|
206
206
|
const arrayable = matchArrayableJsonSchema(schema2);
|
|
207
|
-
if (!arrayable ||
|
|
207
|
+
if (!arrayable || flattenJsonUnionSchema(arrayable[0]).some((s) => !isJsonPrimitiveSchema(s))) {
|
|
208
208
|
parameter.style = "deepObject";
|
|
209
209
|
parameter.explode = true;
|
|
210
210
|
}
|
|
@@ -898,4 +898,4 @@ function rewriteComponentSchemaRefs(schema, renameMap) {
|
|
|
898
898
|
});
|
|
899
899
|
}
|
|
900
900
|
|
|
901
|
-
export { OpenAPIGenerator, OpenAPIGeneratorError, OpenAPISerializer, createContractJsonifiedCaller, getDynamicPathParams, getOpenAPIMeta };
|
|
901
|
+
export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPISerializer, createContractJsonifiedCaller, getDynamicPathParams, getOpenAPIMeta };
|
|
@@ -124,60 +124,46 @@ function decodeParams(params) {
|
|
|
124
124
|
return Object.fromEntries(Object.entries(params).map(([key, val]) => [key, tryDecodeURIComponent(val)]));
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
class
|
|
128
|
-
}
|
|
129
|
-
class OpenAPIHandlerCodec {
|
|
130
|
-
matcher;
|
|
127
|
+
class OpenAPIHandlerCodecCore {
|
|
131
128
|
serializer;
|
|
132
129
|
errorStatusMap;
|
|
133
130
|
customErrorResponseBodySerializer;
|
|
134
|
-
constructor(
|
|
135
|
-
this.matcher = new OpenAPIMatcher(router, options);
|
|
131
|
+
constructor(options = {}) {
|
|
136
132
|
this.serializer = options.serializer ?? new OpenAPISerializer();
|
|
137
133
|
this.errorStatusMap = options.errorStatusMap ?? COMMON_ERROR_STATUS_MAP;
|
|
138
134
|
this.customErrorResponseBodySerializer = options.customErrorResponseBodyEncoder;
|
|
139
135
|
}
|
|
140
|
-
async
|
|
141
|
-
const [
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const data = request.method === "GET" ? query : this.serializer.deserialize(await request.resolveBody(meta?.requestBodyHint));
|
|
156
|
-
if (data === void 0) {
|
|
157
|
-
return params;
|
|
158
|
-
}
|
|
159
|
-
if (!params || Object.keys(params).length < 1) {
|
|
160
|
-
return data;
|
|
161
|
-
}
|
|
162
|
-
if (isPlainObject(data)) {
|
|
163
|
-
return {
|
|
164
|
-
...params,
|
|
165
|
-
...data
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
return data;
|
|
169
|
-
}
|
|
136
|
+
async decodeInput(matched, request) {
|
|
137
|
+
const [_, search] = parseStandardUrl(request.url);
|
|
138
|
+
const meta = getOpenAPIMeta(matched.procedure);
|
|
139
|
+
const inputStructure = meta?.inputStructure ?? DEFAULT_OPENAPI_INPUT_STRUCTURE;
|
|
140
|
+
const params = this.deserializeParams(matched.params, meta?.paramsStyles);
|
|
141
|
+
const query = this.deserializeQuery(search, meta?.queryStyles);
|
|
142
|
+
if (inputStructure === "compact") {
|
|
143
|
+
const data = request.method === "GET" ? query : this.serializer.deserialize(await request.resolveBody(meta?.requestBodyHint));
|
|
144
|
+
if (data === void 0) {
|
|
145
|
+
return params;
|
|
146
|
+
}
|
|
147
|
+
if (!params || Object.keys(params).length < 1) {
|
|
148
|
+
return data;
|
|
149
|
+
}
|
|
150
|
+
if (isPlainObject(data)) {
|
|
170
151
|
return {
|
|
171
|
-
params,
|
|
172
|
-
|
|
173
|
-
headers: request.headers,
|
|
174
|
-
body: this.serializer.deserialize(await request.resolveBody(meta?.requestBodyHint))
|
|
152
|
+
...params,
|
|
153
|
+
...data
|
|
175
154
|
};
|
|
176
155
|
}
|
|
156
|
+
return data;
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
params,
|
|
160
|
+
query,
|
|
161
|
+
headers: request.headers,
|
|
162
|
+
body: this.serializer.deserialize(await request.resolveBody(meta?.requestBodyHint))
|
|
177
163
|
};
|
|
178
164
|
}
|
|
179
165
|
/**
|
|
180
|
-
* @throws {
|
|
166
|
+
* @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
|
|
181
167
|
*/
|
|
182
168
|
encodeOutput(output, procedure, path, _options) {
|
|
183
169
|
const meta = getOpenAPIMeta(procedure);
|
|
@@ -191,7 +177,7 @@ class OpenAPIHandlerCodec {
|
|
|
191
177
|
};
|
|
192
178
|
}
|
|
193
179
|
if (!isValidDetailedOutput(output)) {
|
|
194
|
-
throw new
|
|
180
|
+
throw new TypeError(`
|
|
195
181
|
Invalid "detailed" output structure returned by procedure (${path.join(".")}):
|
|
196
182
|
\u2022 Expected an object with optional properties:
|
|
197
183
|
- status (number 200-399)
|
|
@@ -276,6 +262,25 @@ class OpenAPIHandlerCodec {
|
|
|
276
262
|
return parsed;
|
|
277
263
|
}
|
|
278
264
|
}
|
|
265
|
+
class OpenAPIHandlerCodec extends OpenAPIHandlerCodecCore {
|
|
266
|
+
matcher;
|
|
267
|
+
constructor(router, options = {}) {
|
|
268
|
+
super(options);
|
|
269
|
+
this.matcher = new OpenAPIMatcher(router, options);
|
|
270
|
+
}
|
|
271
|
+
async resolveProcedure(request, options) {
|
|
272
|
+
const [pathname] = parseStandardUrl(request.url);
|
|
273
|
+
const matched = await this.matcher.match(request.method, pathname, options.prefix);
|
|
274
|
+
if (!matched) {
|
|
275
|
+
return void 0;
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
procedure: matched.procedure,
|
|
279
|
+
path: matched.path,
|
|
280
|
+
decodeInput: () => this.decodeInput(matched, request)
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
}
|
|
279
284
|
function isValidDetailedOutput(output) {
|
|
280
285
|
if (!isTypescriptObject(output)) {
|
|
281
286
|
return false;
|
|
@@ -310,4 +315,4 @@ function decodeDelimitedObject(value, delimiter) {
|
|
|
310
315
|
return obj;
|
|
311
316
|
}
|
|
312
317
|
|
|
313
|
-
export { OpenAPIHandlerCodec as O,
|
|
318
|
+
export { OpenAPIHandlerCodec as O, OpenAPIHandlerCodecCore as a, OpenAPIMatcher as b };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyORPCError } from '@orpc/client';
|
|
2
2
|
import { AnyProcedure, AnyRouter, Context } from '@orpc/server';
|
|
3
|
-
import {
|
|
3
|
+
import { StandardHandlerHandleOptions, StandardHandlerCodec, StandardHandlerCodecResolvedProcedure } from '@orpc/server/standard';
|
|
4
4
|
import { Value, Promisable } from '@orpc/shared';
|
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@standardserver/core';
|
|
6
6
|
import { AnyProcedureContract } from '@orpc/contract';
|
|
@@ -31,9 +31,7 @@ declare class OpenAPIMatcher {
|
|
|
31
31
|
private resolveProcedure;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
interface OpenAPIHandlerCodecOptions<_T extends Context> extends OpenAPIMatcherOptions {
|
|
34
|
+
interface OpenAPIHandlerCodecCoreOptions<_T extends Context> {
|
|
37
35
|
/**
|
|
38
36
|
* Override the default OpenAPI serializer.
|
|
39
37
|
*/
|
|
@@ -55,21 +53,30 @@ interface OpenAPIHandlerCodecOptions<_T extends Context> extends OpenAPIMatcherO
|
|
|
55
53
|
*/
|
|
56
54
|
customErrorResponseBodyEncoder?: (error: AnyORPCError) => unknown;
|
|
57
55
|
}
|
|
58
|
-
declare class
|
|
59
|
-
private readonly matcher;
|
|
56
|
+
declare class OpenAPIHandlerCodecCore<T extends Context> {
|
|
60
57
|
private readonly serializer;
|
|
61
58
|
private readonly errorStatusMap;
|
|
62
59
|
private readonly customErrorResponseBodySerializer;
|
|
63
|
-
constructor(
|
|
64
|
-
|
|
60
|
+
constructor(options?: OpenAPIHandlerCodecCoreOptions<T>);
|
|
61
|
+
decodeInput(matched: {
|
|
62
|
+
procedure: AnyProcedure;
|
|
63
|
+
params?: undefined | Record<string, string>;
|
|
64
|
+
}, request: StandardLazyRequest): Promise<unknown>;
|
|
65
65
|
/**
|
|
66
|
-
* @throws {
|
|
66
|
+
* @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
|
|
67
67
|
*/
|
|
68
68
|
encodeOutput(output: unknown, procedure: AnyProcedure, path: string[], _options: StandardHandlerHandleOptions<T>): Promisable<StandardResponse>;
|
|
69
69
|
encodeError(error: AnyORPCError, _procedure: AnyProcedure, _path: string[], _options: StandardHandlerHandleOptions<T>): Promisable<StandardResponse>;
|
|
70
70
|
private deserializeQuery;
|
|
71
71
|
private deserializeParams;
|
|
72
72
|
}
|
|
73
|
+
interface OpenAPIHandlerCodecOptions<T extends Context> extends OpenAPIHandlerCodecCoreOptions<T>, OpenAPIMatcherOptions {
|
|
74
|
+
}
|
|
75
|
+
declare class OpenAPIHandlerCodec<T extends Context> extends OpenAPIHandlerCodecCore<T> implements StandardHandlerCodec<T> {
|
|
76
|
+
private readonly matcher;
|
|
77
|
+
constructor(router: AnyRouter, options?: OpenAPIHandlerCodecOptions<T>);
|
|
78
|
+
resolveProcedure(request: StandardLazyRequest, options: StandardHandlerHandleOptions<T>): Promise<StandardHandlerCodecResolvedProcedure | undefined>;
|
|
79
|
+
}
|
|
73
80
|
|
|
74
|
-
export { OpenAPIHandlerCodec as a,
|
|
75
|
-
export type { OpenAPIHandlerCodecOptions as O, OpenAPIMatcherOptions as
|
|
81
|
+
export { OpenAPIHandlerCodec as a, OpenAPIHandlerCodecCore as b, OpenAPIMatcher as d };
|
|
82
|
+
export type { OpenAPIHandlerCodecOptions as O, OpenAPIHandlerCodecCoreOptions as c, OpenAPIMatcherOptions as e };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyORPCError } from '@orpc/client';
|
|
2
2
|
import { AnyProcedure, AnyRouter, Context } from '@orpc/server';
|
|
3
|
-
import {
|
|
3
|
+
import { StandardHandlerHandleOptions, StandardHandlerCodec, StandardHandlerCodecResolvedProcedure } from '@orpc/server/standard';
|
|
4
4
|
import { Value, Promisable } from '@orpc/shared';
|
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@standardserver/core';
|
|
6
6
|
import { AnyProcedureContract } from '@orpc/contract';
|
|
@@ -31,9 +31,7 @@ declare class OpenAPIMatcher {
|
|
|
31
31
|
private resolveProcedure;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
interface OpenAPIHandlerCodecOptions<_T extends Context> extends OpenAPIMatcherOptions {
|
|
34
|
+
interface OpenAPIHandlerCodecCoreOptions<_T extends Context> {
|
|
37
35
|
/**
|
|
38
36
|
* Override the default OpenAPI serializer.
|
|
39
37
|
*/
|
|
@@ -55,21 +53,30 @@ interface OpenAPIHandlerCodecOptions<_T extends Context> extends OpenAPIMatcherO
|
|
|
55
53
|
*/
|
|
56
54
|
customErrorResponseBodyEncoder?: (error: AnyORPCError) => unknown;
|
|
57
55
|
}
|
|
58
|
-
declare class
|
|
59
|
-
private readonly matcher;
|
|
56
|
+
declare class OpenAPIHandlerCodecCore<T extends Context> {
|
|
60
57
|
private readonly serializer;
|
|
61
58
|
private readonly errorStatusMap;
|
|
62
59
|
private readonly customErrorResponseBodySerializer;
|
|
63
|
-
constructor(
|
|
64
|
-
|
|
60
|
+
constructor(options?: OpenAPIHandlerCodecCoreOptions<T>);
|
|
61
|
+
decodeInput(matched: {
|
|
62
|
+
procedure: AnyProcedure;
|
|
63
|
+
params?: undefined | Record<string, string>;
|
|
64
|
+
}, request: StandardLazyRequest): Promise<unknown>;
|
|
65
65
|
/**
|
|
66
|
-
* @throws {
|
|
66
|
+
* @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
|
|
67
67
|
*/
|
|
68
68
|
encodeOutput(output: unknown, procedure: AnyProcedure, path: string[], _options: StandardHandlerHandleOptions<T>): Promisable<StandardResponse>;
|
|
69
69
|
encodeError(error: AnyORPCError, _procedure: AnyProcedure, _path: string[], _options: StandardHandlerHandleOptions<T>): Promisable<StandardResponse>;
|
|
70
70
|
private deserializeQuery;
|
|
71
71
|
private deserializeParams;
|
|
72
72
|
}
|
|
73
|
+
interface OpenAPIHandlerCodecOptions<T extends Context> extends OpenAPIHandlerCodecCoreOptions<T>, OpenAPIMatcherOptions {
|
|
74
|
+
}
|
|
75
|
+
declare class OpenAPIHandlerCodec<T extends Context> extends OpenAPIHandlerCodecCore<T> implements StandardHandlerCodec<T> {
|
|
76
|
+
private readonly matcher;
|
|
77
|
+
constructor(router: AnyRouter, options?: OpenAPIHandlerCodecOptions<T>);
|
|
78
|
+
resolveProcedure(request: StandardLazyRequest, options: StandardHandlerHandleOptions<T>): Promise<StandardHandlerCodecResolvedProcedure | undefined>;
|
|
79
|
+
}
|
|
73
80
|
|
|
74
|
-
export { OpenAPIHandlerCodec as a,
|
|
75
|
-
export type { OpenAPIHandlerCodecOptions as O, OpenAPIMatcherOptions as
|
|
81
|
+
export { OpenAPIHandlerCodec as a, OpenAPIHandlerCodecCore as b, OpenAPIMatcher as d };
|
|
82
|
+
export type { OpenAPIHandlerCodecOptions as O, OpenAPIHandlerCodecCoreOptions as c, OpenAPIMatcherOptions as e };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/openapi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
@@ -60,16 +60,16 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@hey-api/spec-types": "0.0.0-next-20260408030107",
|
|
62
62
|
"@scalar/api-reference": "^1.57.2",
|
|
63
|
-
"@standardserver/core": "^0.0.
|
|
64
|
-
"@standardserver/fetch": "^0.0.
|
|
63
|
+
"@standardserver/core": "^0.0.25",
|
|
64
|
+
"@standardserver/fetch": "^0.0.25",
|
|
65
65
|
"@types/swagger-ui": "^5.32.0",
|
|
66
|
-
"rou3": "^0.
|
|
66
|
+
"rou3": "^0.8.1",
|
|
67
67
|
"swagger-ui": "^5.32.6",
|
|
68
|
-
"@orpc/
|
|
69
|
-
"@orpc/
|
|
70
|
-
"@orpc/
|
|
71
|
-
"@orpc/
|
|
72
|
-
"@orpc/
|
|
68
|
+
"@orpc/json-schema": "2.0.0-beta.3",
|
|
69
|
+
"@orpc/client": "2.0.0-beta.3",
|
|
70
|
+
"@orpc/contract": "2.0.0-beta.3",
|
|
71
|
+
"@orpc/shared": "2.0.0-beta.3",
|
|
72
|
+
"@orpc/server": "2.0.0-beta.3"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"fastify": "^5.6.2",
|