@orpc/openapi 0.0.0-next.f99e554 → 0.0.0-next.fe39bf3
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-LPBZEW4B.js +165 -0
- package/dist/chunk-UU2TTVB2.js +32 -0
- package/dist/chunk-XGHV4TH3.js +13 -0
- package/dist/fetch.js +5 -42
- package/dist/hono.js +9 -0
- package/dist/index.js +259 -48
- package/dist/next.js +9 -0
- package/dist/node.js +20 -36
- package/dist/src/adapters/fetch/index.d.ts +0 -8
- package/dist/src/adapters/fetch/openapi-handler.d.ts +9 -31
- package/dist/src/adapters/hono/index.d.ts +2 -0
- package/dist/src/adapters/next/index.d.ts +2 -0
- package/dist/src/adapters/node/index.d.ts +0 -3
- package/dist/src/adapters/node/openapi-handler.d.ts +8 -9
- package/dist/src/adapters/standard/index.d.ts +4 -0
- package/dist/src/adapters/standard/openapi-codec.d.ts +16 -0
- package/dist/src/adapters/standard/openapi-handler.d.ts +7 -0
- package/dist/src/adapters/standard/openapi-matcher.d.ts +20 -0
- package/dist/src/index.d.ts +5 -1
- package/dist/src/openapi-generator.d.ts +12 -5
- package/dist/src/openapi-input-structure-parser.d.ts +2 -2
- package/dist/src/openapi-operation-extender.d.ts +7 -0
- package/dist/src/openapi-output-structure-parser.d.ts +2 -2
- package/dist/src/schema-converter.d.ts +2 -2
- package/dist/src/schema.d.ts +1 -1
- package/dist/src/utils.d.ts +2 -16
- package/dist/standard.js +10 -0
- package/package.json +25 -14
- package/dist/chunk-KNYXLM77.js +0 -107
- package/dist/chunk-YXHH6XHB.js +0 -642
- package/dist/src/adapters/fetch/bracket-notation.d.ts +0 -84
- package/dist/src/adapters/fetch/input-structure-compact.d.ts +0 -6
- package/dist/src/adapters/fetch/input-structure-detailed.d.ts +0 -11
- package/dist/src/adapters/fetch/openapi-handler-server.d.ts +0 -7
- package/dist/src/adapters/fetch/openapi-handler-serverless.d.ts +0 -7
- package/dist/src/adapters/fetch/openapi-payload-codec.d.ts +0 -15
- package/dist/src/adapters/fetch/openapi-procedure-matcher.d.ts +0 -19
- package/dist/src/adapters/fetch/schema-coercer.d.ts +0 -10
- package/dist/src/adapters/node/openapi-handler-server.d.ts +0 -7
- package/dist/src/adapters/node/openapi-handler-serverless.d.ts +0 -7
- package/dist/src/adapters/node/types.d.ts +0 -2
- package/dist/src/json-serializer.d.ts +0 -5
package/dist/src/index.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
/** unnoq */
|
|
2
|
-
|
|
2
|
+
import { setOperationExtender } from './openapi-operation-extender';
|
|
3
3
|
export * from './openapi';
|
|
4
4
|
export * from './openapi-content-builder';
|
|
5
5
|
export * from './openapi-generator';
|
|
6
|
+
export * from './openapi-operation-extender';
|
|
6
7
|
export * from './openapi-parameters-builder';
|
|
7
8
|
export * from './openapi-path-parser';
|
|
8
9
|
export * from './schema';
|
|
9
10
|
export * from './schema-converter';
|
|
10
11
|
export * from './schema-utils';
|
|
11
12
|
export * from './utils';
|
|
13
|
+
export declare const oo: {
|
|
14
|
+
spec: typeof setOperationExtender;
|
|
15
|
+
};
|
|
12
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ContractRouter } from '@orpc/contract';
|
|
2
|
-
import type { ANY_ROUTER } from '@orpc/server';
|
|
3
1
|
import type { PublicOpenAPIInputStructureParser } from './openapi-input-structure-parser';
|
|
4
2
|
import type { PublicOpenAPIOutputStructureParser } from './openapi-output-structure-parser';
|
|
5
3
|
import type { PublicOpenAPIPathParser } from './openapi-path-parser';
|
|
6
4
|
import type { SchemaConverter } from './schema-converter';
|
|
7
|
-
import { type
|
|
5
|
+
import { type PublicOpenAPIJsonSerializer } from '@orpc/client/openapi';
|
|
6
|
+
import { type ContractRouter } from '@orpc/contract';
|
|
7
|
+
import { type AnyRouter } from '@orpc/server';
|
|
8
8
|
import { type OpenAPI } from './openapi';
|
|
9
9
|
import { type PublicOpenAPIContentBuilder } from './openapi-content-builder';
|
|
10
10
|
import { type PublicOpenAPIParametersBuilder } from './openapi-parameters-builder';
|
|
@@ -15,7 +15,7 @@ export interface OpenAPIGeneratorOptions {
|
|
|
15
15
|
parametersBuilder?: PublicOpenAPIParametersBuilder;
|
|
16
16
|
schemaConverters?: SchemaConverter[];
|
|
17
17
|
schemaUtils?: PublicSchemaUtils;
|
|
18
|
-
jsonSerializer?:
|
|
18
|
+
jsonSerializer?: PublicOpenAPIJsonSerializer;
|
|
19
19
|
pathParser?: PublicOpenAPIPathParser;
|
|
20
20
|
inputStructureParser?: PublicOpenAPIInputStructureParser;
|
|
21
21
|
outputStructureParser?: PublicOpenAPIOutputStructureParser;
|
|
@@ -40,6 +40,12 @@ export interface OpenAPIGeneratorOptions {
|
|
|
40
40
|
* @default 'throw'
|
|
41
41
|
*/
|
|
42
42
|
errorHandlerStrategy?: ErrorHandlerStrategy;
|
|
43
|
+
/**
|
|
44
|
+
* Strict error response
|
|
45
|
+
*
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
strictErrorResponses?: boolean;
|
|
43
49
|
}
|
|
44
50
|
export declare class OpenAPIGenerator {
|
|
45
51
|
private readonly contentBuilder;
|
|
@@ -53,8 +59,9 @@ export declare class OpenAPIGenerator {
|
|
|
53
59
|
private readonly errorHandlerStrategy;
|
|
54
60
|
private readonly ignoreUndefinedPathProcedures;
|
|
55
61
|
private readonly considerMissingTagDefinitionAsError;
|
|
62
|
+
private readonly strictErrorResponses;
|
|
56
63
|
constructor(options?: OpenAPIGeneratorOptions);
|
|
57
|
-
generate(router: ContractRouter |
|
|
64
|
+
generate(router: ContractRouter<any> | AnyRouter, doc: Omit<OpenAPI.OpenAPIObject, 'openapi'>): Promise<OpenAPI.OpenAPIObject>;
|
|
58
65
|
}
|
|
59
66
|
export {};
|
|
60
67
|
//# sourceMappingURL=openapi-generator.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnyContractProcedure } from '@orpc/contract';
|
|
2
2
|
import type { PublicOpenAPIPathParser } from './openapi-path-parser';
|
|
3
3
|
import type { JSONSchema, ObjectSchema } from './schema';
|
|
4
4
|
import type { SchemaConverter } from './schema-converter';
|
|
@@ -14,7 +14,7 @@ export declare class OpenAPIInputStructureParser {
|
|
|
14
14
|
private readonly schemaUtils;
|
|
15
15
|
private readonly pathParser;
|
|
16
16
|
constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils, pathParser: PublicOpenAPIPathParser);
|
|
17
|
-
parse(contract:
|
|
17
|
+
parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIInputStructureParseResult;
|
|
18
18
|
private parseDetailedSchema;
|
|
19
19
|
private parseCompactSchema;
|
|
20
20
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AnyContractProcedure } from '@orpc/contract';
|
|
2
|
+
import type { OpenAPI } from './openapi';
|
|
3
|
+
export type OverrideOperationValue = OpenAPI.OperationObject | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
|
|
4
|
+
export declare function setOperationExtender<T extends object>(o: T, extend: OverrideOperationValue): T;
|
|
5
|
+
export declare function getOperationExtender(o: object): OverrideOperationValue | undefined;
|
|
6
|
+
export declare function extendOperation(operation: OpenAPI.OperationObject, procedure: AnyContractProcedure): OpenAPI.OperationObject;
|
|
7
|
+
//# sourceMappingURL=openapi-operation-extender.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnyContractProcedure } from '@orpc/contract';
|
|
2
2
|
import type { JSONSchema, ObjectSchema } from './schema';
|
|
3
3
|
import type { SchemaConverter } from './schema-converter';
|
|
4
4
|
import type { PublicSchemaUtils } from './schema-utils';
|
|
@@ -10,7 +10,7 @@ export declare class OpenAPIOutputStructureParser {
|
|
|
10
10
|
private readonly schemaConverter;
|
|
11
11
|
private readonly schemaUtils;
|
|
12
12
|
constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils);
|
|
13
|
-
parse(contract:
|
|
13
|
+
parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIOutputStructureParseResult;
|
|
14
14
|
private parseDetailedSchema;
|
|
15
15
|
private parseCompactSchema;
|
|
16
16
|
}
|
|
@@ -4,8 +4,8 @@ export interface SchemaConvertOptions {
|
|
|
4
4
|
strategy: 'input' | 'output';
|
|
5
5
|
}
|
|
6
6
|
export interface SchemaConverter {
|
|
7
|
-
condition
|
|
8
|
-
convert
|
|
7
|
+
condition(schema: Schema, options: SchemaConvertOptions): boolean;
|
|
8
|
+
convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema;
|
|
9
9
|
}
|
|
10
10
|
export declare class CompositeSchemaConverter implements SchemaConverter {
|
|
11
11
|
private readonly converters;
|
package/dist/src/schema.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ export type FileSchema = JSONSchema.JSONSchema & {
|
|
|
8
8
|
type: 'string';
|
|
9
9
|
contentMediaType: string;
|
|
10
10
|
} & object;
|
|
11
|
-
export declare const NON_LOGIC_KEYWORDS:
|
|
11
|
+
export declare const NON_LOGIC_KEYWORDS: string[];
|
|
12
12
|
//# sourceMappingURL=schema.d.ts.map
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ANY_PROCEDURE, ANY_ROUTER, Lazy } from '@orpc/server';
|
|
3
|
-
export interface EachLeafOptions {
|
|
4
|
-
router: ContractRouter | ANY_ROUTER;
|
|
5
|
-
path: string[];
|
|
6
|
-
}
|
|
7
|
-
export interface EachLeafCallbackOptions {
|
|
8
|
-
contract: WELL_CONTRACT_PROCEDURE;
|
|
9
|
-
path: string[];
|
|
10
|
-
}
|
|
11
|
-
export interface EachContractLeafResultItem {
|
|
12
|
-
router: Lazy<ANY_PROCEDURE> | Lazy<Record<string, ANY_ROUTER> | ANY_PROCEDURE>;
|
|
13
|
-
path: string[];
|
|
14
|
-
}
|
|
15
|
-
export declare function forEachContractProcedure(options: EachLeafOptions, callback: (options: EachLeafCallbackOptions) => void, result?: EachContractLeafResultItem[], isCurrentRouterContract?: boolean): EachContractLeafResultItem[];
|
|
16
|
-
export declare function forEachAllContractProcedure(router: ContractRouter | ANY_ROUTER, callback: (options: EachLeafCallbackOptions) => void): Promise<void>;
|
|
1
|
+
import type { HTTPPath } from '@orpc/contract';
|
|
17
2
|
export declare function standardizeHTTPPath(path: HTTPPath): HTTPPath;
|
|
3
|
+
export declare function toOpenAPI31RoutePattern(path: HTTPPath): string;
|
|
18
4
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/standard.js
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/openapi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.fe39bf3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -19,11 +19,26 @@
|
|
|
19
19
|
"import": "./dist/index.js",
|
|
20
20
|
"default": "./dist/index.js"
|
|
21
21
|
},
|
|
22
|
+
"./standard": {
|
|
23
|
+
"types": "./dist/src/adapters/standard/index.d.ts",
|
|
24
|
+
"import": "./dist/standard.js",
|
|
25
|
+
"default": "./dist/standard.js"
|
|
26
|
+
},
|
|
22
27
|
"./fetch": {
|
|
23
28
|
"types": "./dist/src/adapters/fetch/index.d.ts",
|
|
24
29
|
"import": "./dist/fetch.js",
|
|
25
30
|
"default": "./dist/fetch.js"
|
|
26
31
|
},
|
|
32
|
+
"./hono": {
|
|
33
|
+
"types": "./dist/src/adapters/hono/index.d.ts",
|
|
34
|
+
"import": "./dist/hono.js",
|
|
35
|
+
"default": "./dist/hono.js"
|
|
36
|
+
},
|
|
37
|
+
"./next": {
|
|
38
|
+
"types": "./dist/src/adapters/next/index.d.ts",
|
|
39
|
+
"import": "./dist/next.js",
|
|
40
|
+
"default": "./dist/next.js"
|
|
41
|
+
},
|
|
27
42
|
"./node": {
|
|
28
43
|
"types": "./dist/src/adapters/node/index.d.ts",
|
|
29
44
|
"import": "./dist/node.js",
|
|
@@ -39,26 +54,22 @@
|
|
|
39
54
|
"dist"
|
|
40
55
|
],
|
|
41
56
|
"dependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@standard-
|
|
44
|
-
"@
|
|
45
|
-
"content-disposition": "^0.5.4",
|
|
46
|
-
"escape-string-regexp": "^5.0.0",
|
|
47
|
-
"fast-content-type-parse": "^2.0.0",
|
|
48
|
-
"hono": "^4.6.12",
|
|
57
|
+
"@orpc/server-standard": "^0.4.0",
|
|
58
|
+
"@orpc/server-standard-fetch": "^0.4.0",
|
|
59
|
+
"@orpc/server-standard-node": "^0.4.0",
|
|
49
60
|
"json-schema-typed": "^8.0.1",
|
|
50
61
|
"openapi3-ts": "^4.4.0",
|
|
51
|
-
"
|
|
52
|
-
"@orpc/
|
|
53
|
-
"@orpc/
|
|
54
|
-
"@orpc/
|
|
62
|
+
"rou3": "^0.5.1",
|
|
63
|
+
"@orpc/client": "0.0.0-next.fe39bf3",
|
|
64
|
+
"@orpc/contract": "0.0.0-next.fe39bf3",
|
|
65
|
+
"@orpc/shared": "0.0.0-next.fe39bf3",
|
|
66
|
+
"@orpc/server": "0.0.0-next.fe39bf3"
|
|
55
67
|
},
|
|
56
68
|
"devDependencies": {
|
|
57
|
-
"@readme/openapi-parser": "^2.6.0",
|
|
58
69
|
"zod": "^3.24.1"
|
|
59
70
|
},
|
|
60
71
|
"scripts": {
|
|
61
|
-
"build": "tsup --
|
|
72
|
+
"build": "tsup --onSuccess='tsc -b --noCheck'",
|
|
62
73
|
"build:watch": "pnpm run build --watch",
|
|
63
74
|
"type:check": "tsc -b"
|
|
64
75
|
}
|
package/dist/chunk-KNYXLM77.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
// src/json-serializer.ts
|
|
2
|
-
import { isPlainObject } from "@orpc/shared";
|
|
3
|
-
var JSONSerializer = class {
|
|
4
|
-
serialize(payload) {
|
|
5
|
-
if (payload instanceof Set)
|
|
6
|
-
return this.serialize([...payload]);
|
|
7
|
-
if (payload instanceof Map)
|
|
8
|
-
return this.serialize([...payload.entries()]);
|
|
9
|
-
if (Array.isArray(payload)) {
|
|
10
|
-
return payload.map((v) => v === void 0 ? "undefined" : this.serialize(v));
|
|
11
|
-
}
|
|
12
|
-
if (Number.isNaN(payload))
|
|
13
|
-
return "NaN";
|
|
14
|
-
if (typeof payload === "bigint")
|
|
15
|
-
return payload.toString();
|
|
16
|
-
if (payload instanceof Date && Number.isNaN(payload.getTime())) {
|
|
17
|
-
return "Invalid Date";
|
|
18
|
-
}
|
|
19
|
-
if (payload instanceof RegExp)
|
|
20
|
-
return payload.toString();
|
|
21
|
-
if (payload instanceof URL)
|
|
22
|
-
return payload.toString();
|
|
23
|
-
if (!isPlainObject(payload))
|
|
24
|
-
return payload;
|
|
25
|
-
return Object.keys(payload).reduce(
|
|
26
|
-
(carry, key) => {
|
|
27
|
-
const val = payload[key];
|
|
28
|
-
carry[key] = this.serialize(val);
|
|
29
|
-
return carry;
|
|
30
|
-
},
|
|
31
|
-
{}
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// src/utils.ts
|
|
37
|
-
import { isContractProcedure } from "@orpc/contract";
|
|
38
|
-
import { getRouterContract, isLazy, isProcedure, unlazy } from "@orpc/server";
|
|
39
|
-
function forEachContractProcedure(options, callback, result = [], isCurrentRouterContract = false) {
|
|
40
|
-
const hiddenContract = getRouterContract(options.router);
|
|
41
|
-
if (!isCurrentRouterContract && hiddenContract) {
|
|
42
|
-
return forEachContractProcedure(
|
|
43
|
-
{
|
|
44
|
-
path: options.path,
|
|
45
|
-
router: hiddenContract
|
|
46
|
-
},
|
|
47
|
-
callback,
|
|
48
|
-
result,
|
|
49
|
-
true
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
if (isLazy(options.router)) {
|
|
53
|
-
result.push({
|
|
54
|
-
router: options.router,
|
|
55
|
-
path: options.path
|
|
56
|
-
});
|
|
57
|
-
} else if (isProcedure(options.router)) {
|
|
58
|
-
callback({
|
|
59
|
-
contract: options.router["~orpc"].contract,
|
|
60
|
-
path: options.path
|
|
61
|
-
});
|
|
62
|
-
} else if (isContractProcedure(options.router)) {
|
|
63
|
-
callback({
|
|
64
|
-
contract: options.router,
|
|
65
|
-
path: options.path
|
|
66
|
-
});
|
|
67
|
-
} else {
|
|
68
|
-
for (const key in options.router) {
|
|
69
|
-
forEachContractProcedure(
|
|
70
|
-
{
|
|
71
|
-
router: options.router[key],
|
|
72
|
-
path: [...options.path, key]
|
|
73
|
-
},
|
|
74
|
-
callback,
|
|
75
|
-
result
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return result;
|
|
80
|
-
}
|
|
81
|
-
async function forEachAllContractProcedure(router, callback) {
|
|
82
|
-
const pending = [{
|
|
83
|
-
path: [],
|
|
84
|
-
router
|
|
85
|
-
}];
|
|
86
|
-
for (const item of pending) {
|
|
87
|
-
const lazies = forEachContractProcedure(item, callback);
|
|
88
|
-
for (const lazy of lazies) {
|
|
89
|
-
const { default: router2 } = await unlazy(lazy.router);
|
|
90
|
-
pending.push({
|
|
91
|
-
path: lazy.path,
|
|
92
|
-
router: router2
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function standardizeHTTPPath(path) {
|
|
98
|
-
return `/${path.replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "")}`;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export {
|
|
102
|
-
JSONSerializer,
|
|
103
|
-
forEachContractProcedure,
|
|
104
|
-
forEachAllContractProcedure,
|
|
105
|
-
standardizeHTTPPath
|
|
106
|
-
};
|
|
107
|
-
//# sourceMappingURL=chunk-KNYXLM77.js.map
|