@orpc/openapi 2.0.0-beta.1 → 2.0.0-beta.2
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 +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.mjs +3 -3
- package/dist/shared/{openapi.C9Olbxd5.d.ts → openapi.BYcWgK1j.d.ts} +4 -0
- package/dist/shared/{openapi.CcyUEuTs.mjs → openapi.DR-y5p-D.mjs} +31 -29
- package/dist/shared/{openapi.Drd1OtzG.d.mts → openapi.XeW6_5tm.d.mts} +4 -0
- 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.XeW6_5tm.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.BYcWgK1j.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.DR-y5p-D.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.XeW6_5tm.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.BYcWgK1j.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.DR-y5p-D.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 OpenAPIHandlerCodecError, O as OpenAPIHandlerCodecOptions, c as OpenAPIMatcher, d as OpenAPIMatcherOptions } from '../../shared/openapi.
|
|
1
|
+
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecError, O as OpenAPIHandlerCodecOptions, c as OpenAPIMatcher, d as OpenAPIMatcherOptions } from '../../shared/openapi.XeW6_5tm.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 OpenAPIHandlerCodecError, O as OpenAPIHandlerCodecOptions, c as OpenAPIMatcher, d as OpenAPIMatcherOptions } from '../../shared/openapi.
|
|
1
|
+
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecError, O as OpenAPIHandlerCodecOptions, c as OpenAPIMatcher, d as OpenAPIMatcherOptions } from '../../shared/openapi.BYcWgK1j.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 OpenAPIHandlerCodecError, b as OpenAPIMatcher } from '../../shared/openapi.
|
|
1
|
+
export { O as OpenAPIHandlerCodec, a as OpenAPIHandlerCodecError, b as OpenAPIMatcher } from '../../shared/openapi.DR-y5p-D.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
|
@@ -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
|
@@ -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,5 +1,7 @@
|
|
|
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';
|
|
@@ -7,8 +9,6 @@ export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
|
|
|
7
9
|
import { DelegatingJsonSchemaConverter, StandardJsonSchemaConverter, combineJsonSchemasWithComposition, isUnconstrainedSchema, extractJsonObjectSchemaEntries, combineJsonObjectSchemaEntries, isJsonPrimitiveSchema, matchArrayableJsonSchema, flattenJsonUnionSchema, 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 = {}) {
|
|
@@ -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 };
|
|
@@ -61,6 +61,10 @@ declare class OpenAPIHandlerCodec<T extends Context> implements StandardHandlerC
|
|
|
61
61
|
private readonly errorStatusMap;
|
|
62
62
|
private readonly customErrorResponseBodySerializer;
|
|
63
63
|
constructor(router: AnyRouter, options?: OpenAPIHandlerCodecOptions<T>);
|
|
64
|
+
decodeInput(matched: {
|
|
65
|
+
procedure: AnyProcedure;
|
|
66
|
+
params?: undefined | Record<string, string>;
|
|
67
|
+
}, request: StandardLazyRequest): Promise<unknown>;
|
|
64
68
|
resolveProcedure(request: StandardLazyRequest, options: StandardHandlerHandleOptions<T>): Promise<StandardHandlerCodecResolvedProcedure | undefined>;
|
|
65
69
|
/**
|
|
66
70
|
* @throws {Error} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
|
|
@@ -137,8 +137,37 @@ class OpenAPIHandlerCodec {
|
|
|
137
137
|
this.errorStatusMap = options.errorStatusMap ?? COMMON_ERROR_STATUS_MAP;
|
|
138
138
|
this.customErrorResponseBodySerializer = options.customErrorResponseBodyEncoder;
|
|
139
139
|
}
|
|
140
|
+
async decodeInput(matched, request) {
|
|
141
|
+
const [_, search] = parseStandardUrl(request.url);
|
|
142
|
+
const meta = getOpenAPIMeta(matched.procedure);
|
|
143
|
+
const inputStructure = meta?.inputStructure ?? DEFAULT_OPENAPI_INPUT_STRUCTURE;
|
|
144
|
+
const params = this.deserializeParams(matched.params, meta?.paramsStyles);
|
|
145
|
+
const query = this.deserializeQuery(search, meta?.queryStyles);
|
|
146
|
+
if (inputStructure === "compact") {
|
|
147
|
+
const data = request.method === "GET" ? query : this.serializer.deserialize(await request.resolveBody(meta?.requestBodyHint));
|
|
148
|
+
if (data === void 0) {
|
|
149
|
+
return params;
|
|
150
|
+
}
|
|
151
|
+
if (!params || Object.keys(params).length < 1) {
|
|
152
|
+
return data;
|
|
153
|
+
}
|
|
154
|
+
if (isPlainObject(data)) {
|
|
155
|
+
return {
|
|
156
|
+
...params,
|
|
157
|
+
...data
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
return data;
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
params,
|
|
164
|
+
query,
|
|
165
|
+
headers: request.headers,
|
|
166
|
+
body: this.serializer.deserialize(await request.resolveBody(meta?.requestBodyHint))
|
|
167
|
+
};
|
|
168
|
+
}
|
|
140
169
|
async resolveProcedure(request, options) {
|
|
141
|
-
const [pathname
|
|
170
|
+
const [pathname] = parseStandardUrl(request.url);
|
|
142
171
|
const matched = await this.matcher.match(request.method, pathname, options.prefix);
|
|
143
172
|
if (!matched) {
|
|
144
173
|
return void 0;
|
|
@@ -146,34 +175,7 @@ class OpenAPIHandlerCodec {
|
|
|
146
175
|
return {
|
|
147
176
|
procedure: matched.procedure,
|
|
148
177
|
path: matched.path,
|
|
149
|
-
decodeInput:
|
|
150
|
-
const meta = getOpenAPIMeta(matched.procedure);
|
|
151
|
-
const inputStructure = meta?.inputStructure ?? DEFAULT_OPENAPI_INPUT_STRUCTURE;
|
|
152
|
-
const params = this.deserializeParams(matched.params, meta?.paramsStyles);
|
|
153
|
-
const query = this.deserializeQuery(search, meta?.queryStyles);
|
|
154
|
-
if (inputStructure === "compact") {
|
|
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
|
-
}
|
|
170
|
-
return {
|
|
171
|
-
params,
|
|
172
|
-
query,
|
|
173
|
-
headers: request.headers,
|
|
174
|
-
body: this.serializer.deserialize(await request.resolveBody(meta?.requestBodyHint))
|
|
175
|
-
};
|
|
176
|
-
}
|
|
178
|
+
decodeInput: () => this.decodeInput(matched, request)
|
|
177
179
|
};
|
|
178
180
|
}
|
|
179
181
|
/**
|
|
@@ -61,6 +61,10 @@ declare class OpenAPIHandlerCodec<T extends Context> implements StandardHandlerC
|
|
|
61
61
|
private readonly errorStatusMap;
|
|
62
62
|
private readonly customErrorResponseBodySerializer;
|
|
63
63
|
constructor(router: AnyRouter, options?: OpenAPIHandlerCodecOptions<T>);
|
|
64
|
+
decodeInput(matched: {
|
|
65
|
+
procedure: AnyProcedure;
|
|
66
|
+
params?: undefined | Record<string, string>;
|
|
67
|
+
}, request: StandardLazyRequest): Promise<unknown>;
|
|
64
68
|
resolveProcedure(request: StandardLazyRequest, options: StandardHandlerHandleOptions<T>): Promise<StandardHandlerCodecResolvedProcedure | undefined>;
|
|
65
69
|
/**
|
|
66
70
|
* @throws {Error} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
|
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.2",
|
|
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/client": "2.0.0-beta.
|
|
69
|
-
"@orpc/
|
|
70
|
-
"@orpc/
|
|
71
|
-
"@orpc/
|
|
72
|
-
"@orpc/
|
|
68
|
+
"@orpc/client": "2.0.0-beta.2",
|
|
69
|
+
"@orpc/json-schema": "2.0.0-beta.2",
|
|
70
|
+
"@orpc/server": "2.0.0-beta.2",
|
|
71
|
+
"@orpc/shared": "2.0.0-beta.2",
|
|
72
|
+
"@orpc/contract": "2.0.0-beta.2"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"fastify": "^5.6.2",
|