@orpc/openapi 0.0.0-next.9588d75 → 0.0.0-next.9914009
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-EVWWILO6.js +25 -0
- package/dist/chunk-KNYXLM77.js +107 -0
- package/dist/{chunk-UPDKQRQG.js → chunk-X2HG5K4J.js} +178 -192
- package/dist/fetch.js +10 -7
- package/dist/hono.js +34 -0
- package/dist/index.js +445 -4503
- package/dist/next.js +34 -0
- package/dist/node.js +46 -0
- package/dist/src/{fetch → adapters/fetch}/index.d.ts +2 -2
- package/dist/src/adapters/fetch/input-structure-compact.d.ts +6 -0
- package/dist/src/{fetch/input-builder-full.d.ts → adapters/fetch/input-structure-detailed.d.ts} +3 -3
- package/dist/src/adapters/fetch/openapi-handler.d.ts +32 -0
- package/dist/src/{fetch → adapters/fetch}/openapi-payload-codec.d.ts +4 -2
- 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 +5 -0
- package/dist/src/adapters/node/openapi-handler-server.d.ts +7 -0
- package/dist/src/adapters/node/openapi-handler-serverless.d.ts +7 -0
- package/dist/src/adapters/node/openapi-handler.d.ts +11 -0
- package/dist/src/adapters/node/types.d.ts +2 -0
- package/dist/src/index.d.ts +10 -1
- package/dist/src/json-serializer.d.ts +5 -0
- package/dist/src/openapi-content-builder.d.ts +10 -0
- package/dist/src/openapi-error.d.ts +3 -0
- package/dist/src/openapi-generator.d.ts +67 -0
- package/dist/src/openapi-input-structure-parser.d.ts +22 -0
- package/dist/src/openapi-output-structure-parser.d.ts +18 -0
- package/dist/src/openapi-parameters-builder.d.ts +12 -0
- package/dist/src/openapi-path-parser.d.ts +8 -0
- package/dist/src/openapi.d.ts +3 -0
- package/dist/src/schema-converter.d.ts +16 -0
- package/dist/src/schema-utils.d.ts +11 -0
- package/dist/src/schema.d.ts +12 -0
- package/dist/src/utils.d.ts +1 -0
- package/package.json +21 -6
- package/dist/src/fetch/input-builder-simple.d.ts +0 -6
- package/dist/src/fetch/openapi-handler.d.ts +0 -28
- package/dist/src/generator.d.ts +0 -26
- package/dist/src/zod-to-json-schema.d.ts +0 -43
- /package/dist/src/{fetch → adapters/fetch}/bracket-notation.d.ts +0 -0
- /package/dist/src/{fetch → adapters/fetch}/openapi-handler-server.d.ts +0 -0
- /package/dist/src/{fetch → adapters/fetch}/openapi-handler-serverless.d.ts +0 -0
- /package/dist/src/{fetch → adapters/fetch}/openapi-procedure-matcher.d.ts +0 -0
- /package/dist/src/{fetch → adapters/fetch}/schema-coercer.d.ts +0 -0
package/dist/next.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OpenAPIServerHandler,
|
|
3
|
+
OpenAPIServerlessHandler
|
|
4
|
+
} from "./chunk-EVWWILO6.js";
|
|
5
|
+
import {
|
|
6
|
+
CompositeSchemaCoercer,
|
|
7
|
+
InputStructureCompact,
|
|
8
|
+
InputStructureDetailed,
|
|
9
|
+
OpenAPIHandler,
|
|
10
|
+
OpenAPIPayloadCodec,
|
|
11
|
+
OpenAPIProcedureMatcher,
|
|
12
|
+
deserialize,
|
|
13
|
+
escapeSegment,
|
|
14
|
+
parsePath,
|
|
15
|
+
serialize,
|
|
16
|
+
stringifyPath
|
|
17
|
+
} from "./chunk-X2HG5K4J.js";
|
|
18
|
+
import "./chunk-KNYXLM77.js";
|
|
19
|
+
export {
|
|
20
|
+
CompositeSchemaCoercer,
|
|
21
|
+
InputStructureCompact,
|
|
22
|
+
InputStructureDetailed,
|
|
23
|
+
OpenAPIHandler,
|
|
24
|
+
OpenAPIPayloadCodec,
|
|
25
|
+
OpenAPIProcedureMatcher,
|
|
26
|
+
OpenAPIServerHandler,
|
|
27
|
+
OpenAPIServerlessHandler,
|
|
28
|
+
deserialize,
|
|
29
|
+
escapeSegment,
|
|
30
|
+
parsePath,
|
|
31
|
+
serialize,
|
|
32
|
+
stringifyPath
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=next.js.map
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OpenAPIHandler
|
|
3
|
+
} from "./chunk-X2HG5K4J.js";
|
|
4
|
+
import "./chunk-KNYXLM77.js";
|
|
5
|
+
|
|
6
|
+
// src/adapters/node/openapi-handler.ts
|
|
7
|
+
import { createRequest, sendResponse } from "@orpc/server/node";
|
|
8
|
+
var OpenAPIHandler2 = class {
|
|
9
|
+
openapiFetchHandler;
|
|
10
|
+
constructor(hono, router, options) {
|
|
11
|
+
this.openapiFetchHandler = new OpenAPIHandler(hono, router, options);
|
|
12
|
+
}
|
|
13
|
+
async handle(req, res, ...[options]) {
|
|
14
|
+
const request = createRequest(req, res);
|
|
15
|
+
const castedOptions = options ?? {};
|
|
16
|
+
const result = await this.openapiFetchHandler.handle(request, castedOptions);
|
|
17
|
+
if (result.matched === false) {
|
|
18
|
+
return { matched: false };
|
|
19
|
+
}
|
|
20
|
+
await options?.beforeSend?.(result.response, castedOptions.context);
|
|
21
|
+
await sendResponse(res, result.response);
|
|
22
|
+
return { matched: true };
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// src/adapters/node/openapi-handler-server.ts
|
|
27
|
+
import { TrieRouter } from "hono/router/trie-router";
|
|
28
|
+
var OpenAPIServerHandler = class extends OpenAPIHandler2 {
|
|
29
|
+
constructor(router, options) {
|
|
30
|
+
super(new TrieRouter(), router, options);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// src/adapters/node/openapi-handler-serverless.ts
|
|
35
|
+
import { LinearRouter } from "hono/router/linear-router";
|
|
36
|
+
var OpenAPIServerlessHandler = class extends OpenAPIHandler2 {
|
|
37
|
+
constructor(router, options) {
|
|
38
|
+
super(new LinearRouter(), router, options);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
OpenAPIHandler2 as OpenAPIHandler,
|
|
43
|
+
OpenAPIServerHandler,
|
|
44
|
+
OpenAPIServerlessHandler
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './bracket-notation';
|
|
2
|
-
export * from './input-
|
|
3
|
-
export * from './input-
|
|
2
|
+
export * from './input-structure-compact';
|
|
3
|
+
export * from './input-structure-detailed';
|
|
4
4
|
export * from './openapi-handler';
|
|
5
5
|
export * from './openapi-handler-server';
|
|
6
6
|
export * from './openapi-handler-serverless';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Params } from 'hono/router';
|
|
2
|
+
export declare class InputStructureCompact {
|
|
3
|
+
build(params: Params, payload: unknown): unknown;
|
|
4
|
+
}
|
|
5
|
+
export type PublicInputStructureCompact = Pick<InputStructureCompact, keyof InputStructureCompact>;
|
|
6
|
+
//# sourceMappingURL=input-structure-compact.d.ts.map
|
package/dist/src/{fetch/input-builder-full.d.ts → adapters/fetch/input-structure-detailed.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Params } from 'hono/router';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class InputStructureDetailed {
|
|
3
3
|
build(params: Params, query: unknown, headers: unknown, body: unknown): {
|
|
4
4
|
params: Params;
|
|
5
5
|
query: unknown;
|
|
@@ -7,5 +7,5 @@ export declare class InputBuilderFull {
|
|
|
7
7
|
body: unknown;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
export type
|
|
11
|
-
//# sourceMappingURL=input-
|
|
10
|
+
export type PublicInputStructureDetailed = Pick<InputStructureDetailed, keyof InputStructureDetailed>;
|
|
11
|
+
//# sourceMappingURL=input-structure-detailed.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Context, Router, WithSignal } from '@orpc/server';
|
|
2
|
+
import type { FetchHandler, FetchHandleRest, FetchHandleResult } from '@orpc/server/fetch';
|
|
3
|
+
import type { PublicInputStructureCompact } from './input-structure-compact';
|
|
4
|
+
import { type Hooks } from '@orpc/shared';
|
|
5
|
+
import { type PublicJSONSerializer } from '../../json-serializer';
|
|
6
|
+
import { type PublicInputStructureDetailed } from './input-structure-detailed';
|
|
7
|
+
import { type PublicOpenAPIPayloadCodec } from './openapi-payload-codec';
|
|
8
|
+
import { type Hono, type PublicOpenAPIProcedureMatcher } from './openapi-procedure-matcher';
|
|
9
|
+
import { type SchemaCoercer } from './schema-coercer';
|
|
10
|
+
export type OpenAPIHandlerOptions<T extends Context> = Hooks<Request, FetchHandleResult, T, WithSignal> & {
|
|
11
|
+
jsonSerializer?: PublicJSONSerializer;
|
|
12
|
+
procedureMatcher?: PublicOpenAPIProcedureMatcher;
|
|
13
|
+
payloadCodec?: PublicOpenAPIPayloadCodec;
|
|
14
|
+
inputBuilderSimple?: PublicInputStructureCompact;
|
|
15
|
+
inputBuilderFull?: PublicInputStructureDetailed;
|
|
16
|
+
schemaCoercers?: SchemaCoercer[];
|
|
17
|
+
};
|
|
18
|
+
export declare class OpenAPIHandler<T extends Context> implements FetchHandler<T> {
|
|
19
|
+
private readonly options?;
|
|
20
|
+
private readonly procedureMatcher;
|
|
21
|
+
private readonly payloadCodec;
|
|
22
|
+
private readonly inputStructureCompact;
|
|
23
|
+
private readonly inputStructureDetailed;
|
|
24
|
+
private readonly compositeSchemaCoercer;
|
|
25
|
+
constructor(hono: Hono, router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>> | undefined);
|
|
26
|
+
handle(request: Request, ...[options]: FetchHandleRest<T>): Promise<FetchHandleResult>;
|
|
27
|
+
private decodeInput;
|
|
28
|
+
private encodeOutput;
|
|
29
|
+
private assertDetailedOutput;
|
|
30
|
+
private convertToORPCError;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=openapi-handler.d.ts.map
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import type { PublicJSONSerializer } from '../../json-serializer';
|
|
1
2
|
export declare class OpenAPIPayloadCodec {
|
|
2
|
-
|
|
3
|
+
private readonly jsonSerializer;
|
|
4
|
+
constructor(jsonSerializer: PublicJSONSerializer);
|
|
5
|
+
encode(payload: unknown, accept: string | undefined): {
|
|
3
6
|
body: FormData | Blob | string | undefined;
|
|
4
7
|
headers?: Headers;
|
|
5
8
|
};
|
|
6
9
|
private encodeAsJSON;
|
|
7
10
|
private encodeAsFormData;
|
|
8
11
|
private encodeAsURLSearchParams;
|
|
9
|
-
serialize(payload: unknown): unknown;
|
|
10
12
|
decode(re: Request | Response | Headers | URLSearchParams | FormData): Promise<unknown>;
|
|
11
13
|
}
|
|
12
14
|
export type PublicOpenAPIPayloadCodec = Pick<OpenAPIPayloadCodec, keyof OpenAPIPayloadCodec>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Context, Router } from '@orpc/server';
|
|
2
|
+
import type { OpenAPIHandlerOptions } from '../fetch/openapi-handler';
|
|
3
|
+
import { OpenAPIHandler } from './openapi-handler';
|
|
4
|
+
export declare class OpenAPIServerHandler<T extends Context> extends OpenAPIHandler<T> {
|
|
5
|
+
constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=openapi-handler-server.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Context, Router } from '@orpc/server';
|
|
2
|
+
import type { OpenAPIHandlerOptions } from '../fetch/openapi-handler';
|
|
3
|
+
import { OpenAPIHandler } from './openapi-handler';
|
|
4
|
+
export declare class OpenAPIServerlessHandler<T extends Context> extends OpenAPIHandler<T> {
|
|
5
|
+
constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=openapi-handler-serverless.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context, Router } from '@orpc/server';
|
|
2
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
+
import type { OpenAPIHandlerOptions } from '../fetch/openapi-handler';
|
|
4
|
+
import type { Hono } from '../fetch/openapi-procedure-matcher';
|
|
5
|
+
import { type RequestHandler, type RequestHandleRest, type RequestHandleResult } from '@orpc/server/node';
|
|
6
|
+
export declare class OpenAPIHandler<T extends Context> implements RequestHandler<T> {
|
|
7
|
+
private readonly openapiFetchHandler;
|
|
8
|
+
constructor(hono: Hono, router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
9
|
+
handle(req: IncomingMessage, res: ServerResponse, ...[options]: RequestHandleRest<T>): Promise<RequestHandleResult>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=openapi-handler.d.ts.map
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
/** unnoq */
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './json-serializer';
|
|
3
|
+
export * from './openapi';
|
|
4
|
+
export * from './openapi-content-builder';
|
|
5
|
+
export * from './openapi-generator';
|
|
6
|
+
export * from './openapi-parameters-builder';
|
|
7
|
+
export * from './openapi-path-parser';
|
|
8
|
+
export * from './schema';
|
|
9
|
+
export * from './schema-converter';
|
|
10
|
+
export * from './schema-utils';
|
|
11
|
+
export * from './utils';
|
|
3
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OpenAPI } from './openapi';
|
|
2
|
+
import type { JSONSchema } from './schema';
|
|
3
|
+
import type { PublicSchemaUtils } from './schema-utils';
|
|
4
|
+
export declare class OpenAPIContentBuilder {
|
|
5
|
+
private readonly schemaUtils;
|
|
6
|
+
constructor(schemaUtils: PublicSchemaUtils);
|
|
7
|
+
build(jsonSchema: JSONSchema.JSONSchema, options?: Partial<OpenAPI.MediaTypeObject>): OpenAPI.ContentObject;
|
|
8
|
+
}
|
|
9
|
+
export type PublicOpenAPIContentBuilder = Pick<OpenAPIContentBuilder, keyof OpenAPIContentBuilder>;
|
|
10
|
+
//# sourceMappingURL=openapi-content-builder.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ANY_ROUTER } from '@orpc/server';
|
|
2
|
+
import type { PublicOpenAPIInputStructureParser } from './openapi-input-structure-parser';
|
|
3
|
+
import type { PublicOpenAPIOutputStructureParser } from './openapi-output-structure-parser';
|
|
4
|
+
import type { PublicOpenAPIPathParser } from './openapi-path-parser';
|
|
5
|
+
import type { SchemaConverter } from './schema-converter';
|
|
6
|
+
import { type ContractRouter } from '@orpc/contract';
|
|
7
|
+
import { type PublicJSONSerializer } from './json-serializer';
|
|
8
|
+
import { type OpenAPI } from './openapi';
|
|
9
|
+
import { type PublicOpenAPIContentBuilder } from './openapi-content-builder';
|
|
10
|
+
import { type PublicOpenAPIParametersBuilder } from './openapi-parameters-builder';
|
|
11
|
+
import { type PublicSchemaUtils } from './schema-utils';
|
|
12
|
+
type ErrorHandlerStrategy = 'throw' | 'log' | 'ignore';
|
|
13
|
+
export interface OpenAPIGeneratorOptions {
|
|
14
|
+
contentBuilder?: PublicOpenAPIContentBuilder;
|
|
15
|
+
parametersBuilder?: PublicOpenAPIParametersBuilder;
|
|
16
|
+
schemaConverters?: SchemaConverter[];
|
|
17
|
+
schemaUtils?: PublicSchemaUtils;
|
|
18
|
+
jsonSerializer?: PublicJSONSerializer;
|
|
19
|
+
pathParser?: PublicOpenAPIPathParser;
|
|
20
|
+
inputStructureParser?: PublicOpenAPIInputStructureParser;
|
|
21
|
+
outputStructureParser?: PublicOpenAPIOutputStructureParser;
|
|
22
|
+
/**
|
|
23
|
+
* Throw error when you missing define tag definition on OpenAPI root tags
|
|
24
|
+
*
|
|
25
|
+
* Example: if procedure has tags ['foo', 'bar'], and OpenAPI root tags is ['foo'], then error will be thrown
|
|
26
|
+
* Because OpenAPI root tags is missing 'bar' tag
|
|
27
|
+
*
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
considerMissingTagDefinitionAsError?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Weather ignore procedures that has no path defined.
|
|
33
|
+
*
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
ignoreUndefinedPathProcedures?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* What to do when we found an error with our router
|
|
39
|
+
*
|
|
40
|
+
* @default 'throw'
|
|
41
|
+
*/
|
|
42
|
+
errorHandlerStrategy?: ErrorHandlerStrategy;
|
|
43
|
+
/**
|
|
44
|
+
* Strict error response
|
|
45
|
+
*
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
strictErrorResponses?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export declare class OpenAPIGenerator {
|
|
51
|
+
private readonly contentBuilder;
|
|
52
|
+
private readonly parametersBuilder;
|
|
53
|
+
private readonly schemaConverter;
|
|
54
|
+
private readonly schemaUtils;
|
|
55
|
+
private readonly jsonSerializer;
|
|
56
|
+
private readonly pathParser;
|
|
57
|
+
private readonly inputStructureParser;
|
|
58
|
+
private readonly outputStructureParser;
|
|
59
|
+
private readonly errorHandlerStrategy;
|
|
60
|
+
private readonly ignoreUndefinedPathProcedures;
|
|
61
|
+
private readonly considerMissingTagDefinitionAsError;
|
|
62
|
+
private readonly strictErrorResponses;
|
|
63
|
+
constructor(options?: OpenAPIGeneratorOptions);
|
|
64
|
+
generate(router: ContractRouter | ANY_ROUTER, doc: Omit<OpenAPI.OpenAPIObject, 'openapi'>): Promise<OpenAPI.OpenAPIObject>;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=openapi-generator.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PublicOpenAPIPathParser } from './openapi-path-parser';
|
|
2
|
+
import type { JSONSchema, ObjectSchema } from './schema';
|
|
3
|
+
import type { SchemaConverter } from './schema-converter';
|
|
4
|
+
import type { PublicSchemaUtils } from './schema-utils';
|
|
5
|
+
import { type ANY_CONTRACT_PROCEDURE } from '@orpc/contract';
|
|
6
|
+
export interface OpenAPIInputStructureParseResult {
|
|
7
|
+
paramsSchema: ObjectSchema | undefined;
|
|
8
|
+
querySchema: ObjectSchema | undefined;
|
|
9
|
+
headersSchema: ObjectSchema | undefined;
|
|
10
|
+
bodySchema: JSONSchema.JSONSchema | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare class OpenAPIInputStructureParser {
|
|
13
|
+
private readonly schemaConverter;
|
|
14
|
+
private readonly schemaUtils;
|
|
15
|
+
private readonly pathParser;
|
|
16
|
+
constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils, pathParser: PublicOpenAPIPathParser);
|
|
17
|
+
parse(contract: ANY_CONTRACT_PROCEDURE, structure: 'compact' | 'detailed'): OpenAPIInputStructureParseResult;
|
|
18
|
+
private parseDetailedSchema;
|
|
19
|
+
private parseCompactSchema;
|
|
20
|
+
}
|
|
21
|
+
export type PublicOpenAPIInputStructureParser = Pick<OpenAPIInputStructureParser, keyof OpenAPIInputStructureParser>;
|
|
22
|
+
//# sourceMappingURL=openapi-input-structure-parser.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ANY_CONTRACT_PROCEDURE } from '@orpc/contract';
|
|
2
|
+
import type { JSONSchema, ObjectSchema } from './schema';
|
|
3
|
+
import type { SchemaConverter } from './schema-converter';
|
|
4
|
+
import type { PublicSchemaUtils } from './schema-utils';
|
|
5
|
+
export interface OpenAPIOutputStructureParseResult {
|
|
6
|
+
headersSchema: ObjectSchema | undefined;
|
|
7
|
+
bodySchema: JSONSchema.JSONSchema | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare class OpenAPIOutputStructureParser {
|
|
10
|
+
private readonly schemaConverter;
|
|
11
|
+
private readonly schemaUtils;
|
|
12
|
+
constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils);
|
|
13
|
+
parse(contract: ANY_CONTRACT_PROCEDURE, structure: 'compact' | 'detailed'): OpenAPIOutputStructureParseResult;
|
|
14
|
+
private parseDetailedSchema;
|
|
15
|
+
private parseCompactSchema;
|
|
16
|
+
}
|
|
17
|
+
export type PublicOpenAPIOutputStructureParser = Pick<OpenAPIOutputStructureParser, keyof OpenAPIOutputStructureParser>;
|
|
18
|
+
//# sourceMappingURL=openapi-output-structure-parser.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { OpenAPI } from './openapi';
|
|
2
|
+
import type { JSONSchema } from './schema';
|
|
3
|
+
export declare class OpenAPIParametersBuilder {
|
|
4
|
+
build(paramIn: OpenAPI.ParameterObject['in'], jsonSchema: JSONSchema.JSONSchema & {
|
|
5
|
+
type: 'object';
|
|
6
|
+
} & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.ParameterObject[];
|
|
7
|
+
buildHeadersObject(jsonSchema: JSONSchema.JSONSchema & {
|
|
8
|
+
type: 'object';
|
|
9
|
+
} & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.HeadersObject;
|
|
10
|
+
}
|
|
11
|
+
export type PublicOpenAPIParametersBuilder = Pick<OpenAPIParametersBuilder, keyof OpenAPIParametersBuilder>;
|
|
12
|
+
//# sourceMappingURL=openapi-parameters-builder.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Schema } from '@orpc/contract';
|
|
2
|
+
import type { JSONSchema } from './schema';
|
|
3
|
+
export interface SchemaConvertOptions {
|
|
4
|
+
strategy: 'input' | 'output';
|
|
5
|
+
}
|
|
6
|
+
export interface SchemaConverter {
|
|
7
|
+
condition: (schema: Schema, options: SchemaConvertOptions) => boolean;
|
|
8
|
+
convert: (schema: Schema, options: SchemaConvertOptions) => JSONSchema.JSONSchema;
|
|
9
|
+
}
|
|
10
|
+
export declare class CompositeSchemaConverter implements SchemaConverter {
|
|
11
|
+
private readonly converters;
|
|
12
|
+
constructor(converters: SchemaConverter[]);
|
|
13
|
+
condition(): boolean;
|
|
14
|
+
convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=schema-converter.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type FileSchema, type JSONSchema, type ObjectSchema } from './schema';
|
|
2
|
+
export declare class SchemaUtils {
|
|
3
|
+
isFileSchema(schema: JSONSchema.JSONSchema): schema is FileSchema;
|
|
4
|
+
isObjectSchema(schema: JSONSchema.JSONSchema): schema is ObjectSchema;
|
|
5
|
+
isAnySchema(schema: JSONSchema.JSONSchema): boolean;
|
|
6
|
+
isUndefinableSchema(schema: JSONSchema.JSONSchema): boolean;
|
|
7
|
+
separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
|
|
8
|
+
filterSchemaBranches(schema: JSONSchema.JSONSchema, check: (schema: JSONSchema.JSONSchema) => boolean, matches?: JSONSchema.JSONSchema[]): [matches: JSONSchema.JSONSchema[], rest: JSONSchema.JSONSchema | undefined];
|
|
9
|
+
}
|
|
10
|
+
export type PublicSchemaUtils = Pick<SchemaUtils, keyof SchemaUtils>;
|
|
11
|
+
//# sourceMappingURL=schema-utils.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as JSONSchema from 'json-schema-typed/draft-2020-12';
|
|
2
|
+
export { Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
|
|
3
|
+
export { JSONSchema };
|
|
4
|
+
export type ObjectSchema = JSONSchema.JSONSchema & {
|
|
5
|
+
type: 'object';
|
|
6
|
+
} & object;
|
|
7
|
+
export type FileSchema = JSONSchema.JSONSchema & {
|
|
8
|
+
type: 'string';
|
|
9
|
+
contentMediaType: string;
|
|
10
|
+
} & object;
|
|
11
|
+
export declare const NON_LOGIC_KEYWORDS: string[];
|
|
12
|
+
//# sourceMappingURL=schema.d.ts.map
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -13,5 +13,6 @@ export interface EachContractLeafResultItem {
|
|
|
13
13
|
path: string[];
|
|
14
14
|
}
|
|
15
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>;
|
|
16
17
|
export declare function standardizeHTTPPath(path: HTTPPath): HTTPPath;
|
|
17
18
|
//# sourceMappingURL=utils.d.ts.map
|
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.9914009",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -20,10 +20,25 @@
|
|
|
20
20
|
"default": "./dist/index.js"
|
|
21
21
|
},
|
|
22
22
|
"./fetch": {
|
|
23
|
-
"types": "./dist/src/fetch/index.d.ts",
|
|
23
|
+
"types": "./dist/src/adapters/fetch/index.d.ts",
|
|
24
24
|
"import": "./dist/fetch.js",
|
|
25
25
|
"default": "./dist/fetch.js"
|
|
26
26
|
},
|
|
27
|
+
"./hono": {
|
|
28
|
+
"types": "./dist/src/adapters/hono/index.d.ts",
|
|
29
|
+
"import": "./dist/hono.js",
|
|
30
|
+
"default": "./dist/hono.js"
|
|
31
|
+
},
|
|
32
|
+
"./next": {
|
|
33
|
+
"types": "./dist/src/adapters/next/index.d.ts",
|
|
34
|
+
"import": "./dist/next.js",
|
|
35
|
+
"default": "./dist/next.js"
|
|
36
|
+
},
|
|
37
|
+
"./node": {
|
|
38
|
+
"types": "./dist/src/adapters/node/index.d.ts",
|
|
39
|
+
"import": "./dist/node.js",
|
|
40
|
+
"default": "./dist/node.js"
|
|
41
|
+
},
|
|
27
42
|
"./🔒/*": {
|
|
28
43
|
"types": "./dist/src/*.d.ts"
|
|
29
44
|
}
|
|
@@ -43,16 +58,16 @@
|
|
|
43
58
|
"json-schema-typed": "^8.0.1",
|
|
44
59
|
"openapi3-ts": "^4.4.0",
|
|
45
60
|
"wildcard-match": "^5.1.3",
|
|
46
|
-
"@orpc/
|
|
47
|
-
"@orpc/shared": "0.0.0-next.
|
|
48
|
-
"@orpc/
|
|
61
|
+
"@orpc/server": "0.0.0-next.9914009",
|
|
62
|
+
"@orpc/shared": "0.0.0-next.9914009",
|
|
63
|
+
"@orpc/contract": "0.0.0-next.9914009"
|
|
49
64
|
},
|
|
50
65
|
"devDependencies": {
|
|
51
66
|
"@readme/openapi-parser": "^2.6.0",
|
|
52
67
|
"zod": "^3.24.1"
|
|
53
68
|
},
|
|
54
69
|
"scripts": {
|
|
55
|
-
"build": "tsup --
|
|
70
|
+
"build": "tsup --onSuccess='tsc -b --noCheck'",
|
|
56
71
|
"build:watch": "pnpm run build --watch",
|
|
57
72
|
"type:check": "tsc -b"
|
|
58
73
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Params } from 'hono/router';
|
|
2
|
-
export declare class InputBuilderSimple {
|
|
3
|
-
build(params: Params, payload: unknown): unknown;
|
|
4
|
-
}
|
|
5
|
-
export type PublicInputBuilderSimple = Pick<InputBuilderSimple, keyof InputBuilderSimple>;
|
|
6
|
-
//# sourceMappingURL=input-builder-simple.d.ts.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { ConditionalFetchHandler, FetchOptions } from '@orpc/server/fetch';
|
|
2
|
-
import type { PublicInputBuilderSimple } from './input-builder-simple';
|
|
3
|
-
import { type Context, type Router, type WithSignal } from '@orpc/server';
|
|
4
|
-
import { type Hooks } from '@orpc/shared';
|
|
5
|
-
import { type PublicInputBuilderFull } from './input-builder-full';
|
|
6
|
-
import { type PublicOpenAPIPayloadCodec } from './openapi-payload-codec';
|
|
7
|
-
import { type Hono, type PublicOpenAPIProcedureMatcher } from './openapi-procedure-matcher';
|
|
8
|
-
import { type SchemaCoercer } from './schema-coercer';
|
|
9
|
-
export type OpenAPIHandlerOptions<T extends Context> = Hooks<Request, Response, T, WithSignal> & {
|
|
10
|
-
procedureMatcher?: PublicOpenAPIProcedureMatcher;
|
|
11
|
-
payloadCodec?: PublicOpenAPIPayloadCodec;
|
|
12
|
-
inputBuilderSimple?: PublicInputBuilderSimple;
|
|
13
|
-
inputBuilderFull?: PublicInputBuilderFull;
|
|
14
|
-
schemaCoercers?: SchemaCoercer[];
|
|
15
|
-
};
|
|
16
|
-
export declare class OpenAPIHandler<T extends Context> implements ConditionalFetchHandler<T> {
|
|
17
|
-
private readonly options?;
|
|
18
|
-
private readonly procedureMatcher;
|
|
19
|
-
private readonly payloadCodec;
|
|
20
|
-
private readonly inputBuilderSimple;
|
|
21
|
-
private readonly inputBuilderFull;
|
|
22
|
-
private readonly compositeSchemaCoercer;
|
|
23
|
-
constructor(hono: Hono, router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>> | undefined);
|
|
24
|
-
condition(request: Request): boolean;
|
|
25
|
-
fetch(request: Request, ...[options]: [options: FetchOptions<T>] | (undefined extends T ? [] : never)): Promise<Response>;
|
|
26
|
-
private convertToORPCError;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=openapi-handler.d.ts.map
|
package/dist/src/generator.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { PublicOpenAPIPayloadCodec } from './fetch';
|
|
2
|
-
import { type ContractRouter } from '@orpc/contract';
|
|
3
|
-
import { type ANY_ROUTER } from '@orpc/server';
|
|
4
|
-
import { type OpenAPIObject } from 'openapi3-ts/oas31';
|
|
5
|
-
export interface GenerateOpenAPIOptions {
|
|
6
|
-
/**
|
|
7
|
-
* Throw error when you missing define tag definition on OpenAPI root tags
|
|
8
|
-
*
|
|
9
|
-
* Example: if procedure has tags ['foo', 'bar'], and OpenAPI root tags is ['foo'], then error will be thrown
|
|
10
|
-
* Because OpenAPI root tags is missing 'bar' tag
|
|
11
|
-
*
|
|
12
|
-
* @default false
|
|
13
|
-
*/
|
|
14
|
-
throwOnMissingTagDefinition?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Weather ignore procedures that has no path defined.
|
|
17
|
-
*
|
|
18
|
-
* @default false
|
|
19
|
-
*/
|
|
20
|
-
ignoreUndefinedPathProcedures?: boolean;
|
|
21
|
-
payloadCodec?: PublicOpenAPIPayloadCodec;
|
|
22
|
-
}
|
|
23
|
-
export declare function generateOpenAPI(opts: {
|
|
24
|
-
router: ContractRouter | ANY_ROUTER;
|
|
25
|
-
} & Omit<OpenAPIObject, 'openapi'>, options?: GenerateOpenAPIOptions): Promise<OpenAPIObject>;
|
|
26
|
-
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import { type JSONSchema } from 'json-schema-typed/draft-2020-12';
|
|
3
|
-
export declare const NON_LOGIC_KEYWORDS: ("$anchor" | "$comment" | "$defs" | "$dynamicAnchor" | "$dynamicRef" | "$id" | "$schema" | "$vocabulary" | "contentEncoding" | "contentMediaType" | "default" | "definitions" | "deprecated" | "description" | "examples" | "format" | "readOnly" | "title" | "writeOnly")[];
|
|
4
|
-
export declare const UNSUPPORTED_JSON_SCHEMA: {
|
|
5
|
-
not: {};
|
|
6
|
-
};
|
|
7
|
-
export declare const UNDEFINED_JSON_SCHEMA: {
|
|
8
|
-
const: string;
|
|
9
|
-
};
|
|
10
|
-
export interface ZodToJsonSchemaOptions {
|
|
11
|
-
/**
|
|
12
|
-
* Max depth of lazy type, if it exceeds.
|
|
13
|
-
*
|
|
14
|
-
* Used `{}` when reach max depth
|
|
15
|
-
*
|
|
16
|
-
* @default 5
|
|
17
|
-
*/
|
|
18
|
-
maxLazyDepth?: number;
|
|
19
|
-
/**
|
|
20
|
-
* The length used to track the depth of lazy type
|
|
21
|
-
*
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
lazyDepth?: number;
|
|
25
|
-
/**
|
|
26
|
-
* The expected json schema for input or output zod schema
|
|
27
|
-
*
|
|
28
|
-
* @default input
|
|
29
|
-
*/
|
|
30
|
-
mode?: 'input' | 'output';
|
|
31
|
-
/**
|
|
32
|
-
* Track if current level schema is handled custom json schema to prevent recursive
|
|
33
|
-
*
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
36
|
-
isHandledCustomJSONSchema?: boolean;
|
|
37
|
-
}
|
|
38
|
-
export declare function zodToJsonSchema(schema: StandardSchemaV1, options?: ZodToJsonSchemaOptions): Exclude<JSONSchema, boolean>;
|
|
39
|
-
export declare function extractJSONSchema(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): {
|
|
40
|
-
schema: JSONSchema | undefined;
|
|
41
|
-
matches: JSONSchema[];
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL=zod-to-json-schema.d.ts.map
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|