@orpc/openapi 0.35.1 → 0.36.1
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/{chunk-M5HOHBLW.js → chunk-44Q55FOB.js} +18 -29
- package/dist/{chunk-HQ34JZI7.js → chunk-WBGO55OM.js} +2 -2
- package/dist/fetch.js +2 -2
- package/dist/hono.js +2 -2
- package/dist/next.js +2 -2
- package/dist/node.js +1 -1
- package/dist/src/adapters/standard/index.d.ts +0 -1
- package/dist/src/adapters/standard/openapi-codec.d.ts +0 -3
- package/dist/standard.js +1 -3
- package/package.json +4 -7
- package/dist/src/adapters/standard/schema-coercer.d.ts +0 -10
@@ -223,7 +223,7 @@ function parsePath(path) {
|
|
223
223
|
|
224
224
|
// src/adapters/standard/openapi-codec.ts
|
225
225
|
import { fallbackContractConfig } from "@orpc/contract";
|
226
|
-
import { isPlainObject as isPlainObject2
|
226
|
+
import { isPlainObject as isPlainObject2 } from "@orpc/shared";
|
227
227
|
|
228
228
|
// src/adapters/standard/openapi-serializer.ts
|
229
229
|
import { findDeepMatches } from "@orpc/shared";
|
@@ -261,54 +261,43 @@ var OpenAPISerializer = class {
|
|
261
261
|
}
|
262
262
|
};
|
263
263
|
|
264
|
-
// src/adapters/standard/schema-coercer.ts
|
265
|
-
var CompositeSchemaCoercer = class {
|
266
|
-
constructor(coercers) {
|
267
|
-
this.coercers = coercers;
|
268
|
-
}
|
269
|
-
coerce(schema, value) {
|
270
|
-
let current = value;
|
271
|
-
for (const coercer of this.coercers) {
|
272
|
-
current = coercer.coerce(schema, current);
|
273
|
-
}
|
274
|
-
return current;
|
275
|
-
}
|
276
|
-
};
|
277
|
-
|
278
264
|
// src/adapters/standard/openapi-codec.ts
|
279
265
|
var OpenAPICodec = class {
|
280
266
|
serializer;
|
281
|
-
compositeSchemaCoercer;
|
282
267
|
constructor(options) {
|
283
268
|
this.serializer = options?.serializer ?? new OpenAPISerializer();
|
284
|
-
this.compositeSchemaCoercer = new CompositeSchemaCoercer(options?.schemaCoercers ?? []);
|
285
269
|
}
|
286
270
|
async decode(request, params, procedure) {
|
287
271
|
const inputStructure = fallbackContractConfig("defaultInputStructure", procedure["~orpc"].route.inputStructure);
|
288
272
|
if (inputStructure === "compact") {
|
289
273
|
const data = request.method === "GET" ? this.serializer.deserialize(request.url.searchParams) : this.serializer.deserialize(await request.body());
|
290
274
|
if (data === void 0) {
|
291
|
-
return
|
275
|
+
return params;
|
292
276
|
}
|
293
277
|
if (isPlainObject2(data)) {
|
294
|
-
return
|
278
|
+
return {
|
295
279
|
...params,
|
296
280
|
...data
|
297
|
-
}
|
281
|
+
};
|
298
282
|
}
|
299
|
-
return
|
283
|
+
return data;
|
300
284
|
}
|
301
|
-
const
|
285
|
+
const deserializeSearchParams = () => {
|
302
286
|
return this.serializer.deserialize(request.url.searchParams);
|
303
|
-
}
|
304
|
-
return
|
287
|
+
};
|
288
|
+
return {
|
305
289
|
params,
|
306
290
|
get query() {
|
307
|
-
|
291
|
+
const value = deserializeSearchParams();
|
292
|
+
Object.defineProperty(this, "query", { value, writable: true });
|
293
|
+
return value;
|
294
|
+
},
|
295
|
+
set query(value) {
|
296
|
+
Object.defineProperty(this, "query", { value, writable: true });
|
308
297
|
},
|
309
298
|
headers: request.headers,
|
310
299
|
body: this.serializer.deserialize(await request.body())
|
311
|
-
}
|
300
|
+
};
|
312
301
|
}
|
313
302
|
encode(output, procedure) {
|
314
303
|
const successStatus = fallbackContractConfig("defaultSuccessStatus", procedure["~orpc"].route.successStatus);
|
@@ -414,7 +403,8 @@ var OpenAPIMatcher = class {
|
|
414
403
|
return {
|
415
404
|
path: match.data.path,
|
416
405
|
procedure: match.data.procedure,
|
417
|
-
params: match.params
|
406
|
+
params: match.params ? { ...match.params } : void 0
|
407
|
+
// normalize params to be a plain object
|
418
408
|
};
|
419
409
|
}
|
420
410
|
};
|
@@ -425,8 +415,7 @@ function convertOpenAPIPathToRouterPath(path) {
|
|
425
415
|
export {
|
426
416
|
bracket_notation_exports,
|
427
417
|
OpenAPISerializer,
|
428
|
-
CompositeSchemaCoercer,
|
429
418
|
OpenAPICodec,
|
430
419
|
OpenAPIMatcher
|
431
420
|
};
|
432
|
-
//# sourceMappingURL=chunk-
|
421
|
+
//# sourceMappingURL=chunk-44Q55FOB.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import {
|
2
2
|
OpenAPICodec,
|
3
3
|
OpenAPIMatcher
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-44Q55FOB.js";
|
5
5
|
|
6
6
|
// src/adapters/fetch/openapi-handler.ts
|
7
7
|
import { fetchRequestToStandardRequest, standardResponseToFetchResponse } from "@orpc/server/fetch";
|
@@ -29,4 +29,4 @@ var OpenAPIHandler = class {
|
|
29
29
|
export {
|
30
30
|
OpenAPIHandler
|
31
31
|
};
|
32
|
-
//# sourceMappingURL=chunk-
|
32
|
+
//# sourceMappingURL=chunk-WBGO55OM.js.map
|
package/dist/fetch.js
CHANGED
package/dist/hono.js
CHANGED
package/dist/next.js
CHANGED
package/dist/node.js
CHANGED
@@ -2,14 +2,11 @@ import type { AnyProcedure } from '@orpc/server';
|
|
2
2
|
import type { StandardCodec, StandardParams, StandardRequest, StandardResponse } from '@orpc/server/standard';
|
3
3
|
import { type ORPCError } from '@orpc/contract';
|
4
4
|
import { OpenAPISerializer } from './openapi-serializer';
|
5
|
-
import { type SchemaCoercer } from './schema-coercer';
|
6
5
|
export interface OpenAPICodecOptions {
|
7
6
|
serializer?: OpenAPISerializer;
|
8
|
-
schemaCoercers?: SchemaCoercer[];
|
9
7
|
}
|
10
8
|
export declare class OpenAPICodec implements StandardCodec {
|
11
9
|
private readonly serializer;
|
12
|
-
private readonly compositeSchemaCoercer;
|
13
10
|
constructor(options?: OpenAPICodecOptions);
|
14
11
|
decode(request: StandardRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
15
12
|
encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
package/dist/standard.js
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
import {
|
2
|
-
CompositeSchemaCoercer,
|
3
2
|
OpenAPICodec,
|
4
3
|
OpenAPIMatcher,
|
5
4
|
OpenAPISerializer,
|
6
5
|
bracket_notation_exports
|
7
|
-
} from "./chunk-
|
6
|
+
} from "./chunk-44Q55FOB.js";
|
8
7
|
import "./chunk-BHJYKXQL.js";
|
9
8
|
export {
|
10
9
|
bracket_notation_exports as BracketNotation,
|
11
|
-
CompositeSchemaCoercer,
|
12
10
|
OpenAPICodec,
|
13
11
|
OpenAPIMatcher,
|
14
12
|
OpenAPISerializer
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/openapi",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.36.1",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -54,18 +54,15 @@
|
|
54
54
|
"dist"
|
55
55
|
],
|
56
56
|
"dependencies": {
|
57
|
-
"@standard-schema/spec": "1.0.0-beta.4",
|
58
|
-
"@types/content-disposition": "^0.5.8",
|
59
|
-
"content-disposition": "^0.5.4",
|
60
57
|
"escape-string-regexp": "^5.0.0",
|
61
58
|
"fast-content-type-parse": "^2.0.0",
|
62
59
|
"json-schema-typed": "^8.0.1",
|
63
60
|
"openapi3-ts": "^4.4.0",
|
64
61
|
"rou3": "^0.5.1",
|
65
62
|
"wildcard-match": "^5.1.3",
|
66
|
-
"@orpc/contract": "0.
|
67
|
-
"@orpc/
|
68
|
-
"@orpc/
|
63
|
+
"@orpc/contract": "0.36.1",
|
64
|
+
"@orpc/shared": "0.36.1",
|
65
|
+
"@orpc/server": "0.36.1"
|
69
66
|
},
|
70
67
|
"devDependencies": {
|
71
68
|
"@readme/openapi-parser": "^2.6.0",
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { Schema } from '@orpc/contract';
|
2
|
-
export interface SchemaCoercer {
|
3
|
-
coerce(schema: Schema, value: unknown): unknown;
|
4
|
-
}
|
5
|
-
export declare class CompositeSchemaCoercer implements SchemaCoercer {
|
6
|
-
private readonly coercers;
|
7
|
-
constructor(coercers: SchemaCoercer[]);
|
8
|
-
coerce(schema: Schema, value: unknown): unknown;
|
9
|
-
}
|
10
|
-
//# sourceMappingURL=schema-coercer.d.ts.map
|