@orpc/openapi 0.0.0-next.af8ac85 → 0.0.0-next.b2e67f7
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/README.md +91 -0
- package/dist/chunk-LTTK3H5J.js +157 -0
- package/dist/chunk-PW7RAFQQ.js +32 -0
- package/dist/chunk-XGHV4TH3.js +13 -0
- package/dist/fetch.js +5 -590
- package/dist/hono.js +9 -0
- package/dist/index.js +460 -121
- package/dist/next.js +9 -0
- package/dist/node.js +30 -0
- package/dist/src/adapters/fetch/index.d.ts +2 -0
- package/dist/src/adapters/fetch/openapi-handler.d.ts +11 -0
- 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 +2 -0
- package/dist/src/adapters/node/openapi-handler.d.ts +11 -0
- package/dist/src/adapters/standard/index.d.ts +4 -0
- package/dist/src/adapters/standard/openapi-codec.d.ts +13 -0
- package/dist/src/adapters/standard/openapi-handler.d.ts +5 -0
- package/dist/src/adapters/standard/openapi-matcher.d.ts +10 -0
- package/dist/src/index.d.ts +5 -1
- package/dist/src/openapi-error.d.ts +3 -0
- package/dist/src/openapi-generator.d.ts +27 -11
- package/dist/src/openapi-input-structure-parser.d.ts +22 -0
- package/dist/src/openapi-operation-extender.d.ts +7 -0
- package/dist/src/openapi-output-structure-parser.d.ts +18 -0
- package/dist/src/openapi-parameters-builder.d.ts +3 -0
- 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 +31 -14
- package/dist/chunk-KNYXLM77.js +0 -107
- package/dist/src/fetch/bracket-notation.d.ts +0 -84
- package/dist/src/fetch/index.d.ts +0 -10
- package/dist/src/fetch/input-builder-full.d.ts +0 -11
- package/dist/src/fetch/input-builder-simple.d.ts +0 -6
- package/dist/src/fetch/openapi-handler-server.d.ts +0 -7
- package/dist/src/fetch/openapi-handler-serverless.d.ts +0 -7
- package/dist/src/fetch/openapi-handler.d.ts +0 -30
- package/dist/src/fetch/openapi-payload-codec.d.ts +0 -15
- package/dist/src/fetch/openapi-procedure-matcher.d.ts +0 -19
- package/dist/src/fetch/schema-coercer.d.ts +0 -10
- package/dist/src/json-serializer.d.ts +0 -5
package/dist/next.js
ADDED
package/dist/node.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OpenAPICodec,
|
|
3
|
+
OpenAPIMatcher
|
|
4
|
+
} from "./chunk-LTTK3H5J.js";
|
|
5
|
+
import "./chunk-XGHV4TH3.js";
|
|
6
|
+
|
|
7
|
+
// src/adapters/node/openapi-handler.ts
|
|
8
|
+
import { StandardHandler } from "@orpc/server/standard";
|
|
9
|
+
import { sendStandardResponse, toStandardRequest } from "@orpc/standard-server-node";
|
|
10
|
+
var OpenAPIHandler = class {
|
|
11
|
+
standardHandler;
|
|
12
|
+
constructor(router, options) {
|
|
13
|
+
const matcher = options?.matcher ?? new OpenAPIMatcher();
|
|
14
|
+
const codec = options?.codec ?? new OpenAPICodec();
|
|
15
|
+
this.standardHandler = new StandardHandler(router, matcher, codec, { ...options });
|
|
16
|
+
}
|
|
17
|
+
async handle(req, res, ...rest) {
|
|
18
|
+
const standardRequest = toStandardRequest(req, res);
|
|
19
|
+
const result = await this.standardHandler.handle(standardRequest, ...rest);
|
|
20
|
+
if (!result.matched) {
|
|
21
|
+
return { matched: false };
|
|
22
|
+
}
|
|
23
|
+
await sendStandardResponse(res, result.response);
|
|
24
|
+
return { matched: true };
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
OpenAPIHandler
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context, Router } from '@orpc/server';
|
|
2
|
+
import type { FetchHandler, FetchHandleResult } from '@orpc/server/fetch';
|
|
3
|
+
import type { StandardHandleOptions } from '@orpc/server/standard';
|
|
4
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
|
5
|
+
import type { OpenAPIHandlerOptions } from '../standard';
|
|
6
|
+
export declare class OpenAPIHandler<T extends Context> implements FetchHandler<T> {
|
|
7
|
+
private readonly standardHandler;
|
|
8
|
+
constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
9
|
+
handle(request: Request, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<FetchHandleResult>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=openapi-handler.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context, Router } from '@orpc/server';
|
|
2
|
+
import type { NodeHttpHandler, NodeHttpHandleResult, NodeHttpRequest, NodeHttpResponse } from '@orpc/server/node';
|
|
3
|
+
import type { StandardHandleOptions } from '@orpc/server/standard';
|
|
4
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
|
5
|
+
import type { OpenAPIHandlerOptions } from '../standard';
|
|
6
|
+
export declare class OpenAPIHandler<T extends Context> implements NodeHttpHandler<T> {
|
|
7
|
+
private readonly standardHandler;
|
|
8
|
+
constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
9
|
+
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=openapi-handler.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ORPCError } from '@orpc/client';
|
|
2
|
+
import type { AnyProcedure } from '@orpc/server';
|
|
3
|
+
import type { StandardCodec, StandardParams } from '@orpc/server/standard';
|
|
4
|
+
import type { StandardRequest, StandardResponse } from '@orpc/standard-server';
|
|
5
|
+
import { OpenAPISerializer } from '@orpc/client/openapi';
|
|
6
|
+
export declare class OpenAPICodec implements StandardCodec {
|
|
7
|
+
private readonly serializer;
|
|
8
|
+
constructor(serializer?: OpenAPISerializer);
|
|
9
|
+
decode(request: StandardRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
|
10
|
+
encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
|
11
|
+
encodeError(error: ORPCError<any, any>): StandardResponse;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=openapi-codec.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AnyRouter } from '@orpc/server';
|
|
2
|
+
import type { StandardMatcher, StandardMatchResult } from '@orpc/server/standard';
|
|
3
|
+
import { type HTTPPath } from '@orpc/contract';
|
|
4
|
+
export declare class OpenAPIMatcher implements StandardMatcher {
|
|
5
|
+
private readonly tree;
|
|
6
|
+
private pendingRouters;
|
|
7
|
+
init(router: AnyRouter, path?: string[]): void;
|
|
8
|
+
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=openapi-matcher.d.ts.map
|
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,19 +1,24 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { PublicOpenAPIInputStructureParser } from './openapi-input-structure-parser';
|
|
2
|
+
import type { PublicOpenAPIOutputStructureParser } from './openapi-output-structure-parser';
|
|
3
3
|
import type { PublicOpenAPIPathParser } from './openapi-path-parser';
|
|
4
4
|
import type { SchemaConverter } from './schema-converter';
|
|
5
|
-
import {
|
|
5
|
+
import { OpenAPIJsonSerializer } from '@orpc/client/openapi';
|
|
6
|
+
import { type ContractRouter } from '@orpc/contract';
|
|
7
|
+
import { type AnyRouter } from '@orpc/server';
|
|
6
8
|
import { type OpenAPI } from './openapi';
|
|
7
9
|
import { type PublicOpenAPIContentBuilder } from './openapi-content-builder';
|
|
8
10
|
import { type PublicOpenAPIParametersBuilder } from './openapi-parameters-builder';
|
|
9
11
|
import { type PublicSchemaUtils } from './schema-utils';
|
|
12
|
+
type ErrorHandlerStrategy = 'throw' | 'log' | 'ignore';
|
|
10
13
|
export interface OpenAPIGeneratorOptions {
|
|
11
14
|
contentBuilder?: PublicOpenAPIContentBuilder;
|
|
12
15
|
parametersBuilder?: PublicOpenAPIParametersBuilder;
|
|
13
16
|
schemaConverters?: SchemaConverter[];
|
|
14
17
|
schemaUtils?: PublicSchemaUtils;
|
|
15
|
-
jsonSerializer?:
|
|
18
|
+
jsonSerializer?: OpenAPIJsonSerializer;
|
|
16
19
|
pathParser?: PublicOpenAPIPathParser;
|
|
20
|
+
inputStructureParser?: PublicOpenAPIInputStructureParser;
|
|
21
|
+
outputStructureParser?: PublicOpenAPIOutputStructureParser;
|
|
17
22
|
/**
|
|
18
23
|
* Throw error when you missing define tag definition on OpenAPI root tags
|
|
19
24
|
*
|
|
@@ -30,22 +35,33 @@ export interface OpenAPIGeneratorOptions {
|
|
|
30
35
|
*/
|
|
31
36
|
ignoreUndefinedPathProcedures?: boolean;
|
|
32
37
|
/**
|
|
33
|
-
*
|
|
38
|
+
* What to do when we found an error with our router
|
|
34
39
|
*
|
|
35
|
-
* @default
|
|
40
|
+
* @default 'throw'
|
|
41
|
+
*/
|
|
42
|
+
errorHandlerStrategy?: ErrorHandlerStrategy;
|
|
43
|
+
/**
|
|
44
|
+
* Strict error response
|
|
45
|
+
*
|
|
46
|
+
* @default true
|
|
36
47
|
*/
|
|
37
|
-
|
|
48
|
+
strictErrorResponses?: boolean;
|
|
38
49
|
}
|
|
39
50
|
export declare class OpenAPIGenerator {
|
|
40
|
-
private readonly options?;
|
|
41
51
|
private readonly contentBuilder;
|
|
42
52
|
private readonly parametersBuilder;
|
|
43
53
|
private readonly schemaConverter;
|
|
44
54
|
private readonly schemaUtils;
|
|
45
55
|
private readonly jsonSerializer;
|
|
46
56
|
private readonly pathParser;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
private
|
|
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> | AnyRouter, doc: Omit<OpenAPI.OpenAPIObject, 'openapi'>): Promise<OpenAPI.OpenAPIObject>;
|
|
50
65
|
}
|
|
66
|
+
export {};
|
|
51
67
|
//# sourceMappingURL=openapi-generator.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AnyContractProcedure } from '@orpc/contract';
|
|
2
|
+
import type { PublicOpenAPIPathParser } from './openapi-path-parser';
|
|
3
|
+
import type { JSONSchema, ObjectSchema } from './schema';
|
|
4
|
+
import type { SchemaConverter } from './schema-converter';
|
|
5
|
+
import type { PublicSchemaUtils } from './schema-utils';
|
|
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: AnyContractProcedure, 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,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
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AnyContractProcedure } 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: AnyContractProcedure, 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
|
|
@@ -4,6 +4,9 @@ export declare class OpenAPIParametersBuilder {
|
|
|
4
4
|
build(paramIn: OpenAPI.ParameterObject['in'], jsonSchema: JSONSchema.JSONSchema & {
|
|
5
5
|
type: 'object';
|
|
6
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;
|
|
7
10
|
}
|
|
8
11
|
export type PublicOpenAPIParametersBuilder = Pick<OpenAPIParametersBuilder, keyof OpenAPIParametersBuilder>;
|
|
9
12
|
//# sourceMappingURL=openapi-parameters-builder.d.ts.map
|
|
@@ -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.b2e67f7",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -19,11 +19,31 @@
|
|
|
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
|
-
"types": "./dist/src/fetch/index.d.ts",
|
|
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
|
+
},
|
|
42
|
+
"./node": {
|
|
43
|
+
"types": "./dist/src/adapters/node/index.d.ts",
|
|
44
|
+
"import": "./dist/node.js",
|
|
45
|
+
"default": "./dist/node.js"
|
|
46
|
+
},
|
|
27
47
|
"./🔒/*": {
|
|
28
48
|
"types": "./dist/src/*.d.ts"
|
|
29
49
|
}
|
|
@@ -34,25 +54,22 @@
|
|
|
34
54
|
"dist"
|
|
35
55
|
],
|
|
36
56
|
"dependencies": {
|
|
37
|
-
"@standard-schema/spec": "1.0.0-beta.4",
|
|
38
|
-
"@types/content-disposition": "^0.5.8",
|
|
39
|
-
"content-disposition": "^0.5.4",
|
|
40
|
-
"escape-string-regexp": "^5.0.0",
|
|
41
|
-
"fast-content-type-parse": "^2.0.0",
|
|
42
|
-
"hono": "^4.6.12",
|
|
43
57
|
"json-schema-typed": "^8.0.1",
|
|
44
58
|
"openapi3-ts": "^4.4.0",
|
|
45
|
-
"
|
|
46
|
-
"@orpc/
|
|
47
|
-
"@orpc/server": "0.0.0-next.
|
|
48
|
-
"@orpc/shared": "0.0.0-next.
|
|
59
|
+
"rou3": "^0.5.1",
|
|
60
|
+
"@orpc/client": "0.0.0-next.b2e67f7",
|
|
61
|
+
"@orpc/server": "0.0.0-next.b2e67f7",
|
|
62
|
+
"@orpc/shared": "0.0.0-next.b2e67f7",
|
|
63
|
+
"@orpc/contract": "0.0.0-next.b2e67f7",
|
|
64
|
+
"@orpc/standard-server": "0.0.0-next.b2e67f7",
|
|
65
|
+
"@orpc/standard-server-fetch": "0.0.0-next.b2e67f7",
|
|
66
|
+
"@orpc/standard-server-node": "0.0.0-next.b2e67f7"
|
|
49
67
|
},
|
|
50
68
|
"devDependencies": {
|
|
51
|
-
"@readme/openapi-parser": "^2.6.0",
|
|
52
69
|
"zod": "^3.24.1"
|
|
53
70
|
},
|
|
54
71
|
"scripts": {
|
|
55
|
-
"build": "tsup --
|
|
72
|
+
"build": "tsup --onSuccess='tsc -b --noCheck'",
|
|
56
73
|
"build:watch": "pnpm run build --watch",
|
|
57
74
|
"type:check": "tsc -b"
|
|
58
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
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Serialize an object or array into a list of [key, value] pairs.
|
|
3
|
-
* The key will express by using bracket-notation.
|
|
4
|
-
*
|
|
5
|
-
* Notice: This way cannot express the empty object or array.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* const payload = {
|
|
10
|
-
* name: 'John Doe',
|
|
11
|
-
* pets: ['dog', 'cat'],
|
|
12
|
-
* }
|
|
13
|
-
*
|
|
14
|
-
* const entities = serialize(payload)
|
|
15
|
-
*
|
|
16
|
-
* expect(entities).toEqual([
|
|
17
|
-
* ['name', 'John Doe'],
|
|
18
|
-
* ['name[pets][0]', 'dog'],
|
|
19
|
-
* ['name[pets][1]', 'cat'],
|
|
20
|
-
* ])
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare function serialize(payload: unknown, parentKey?: string): [string, unknown][];
|
|
24
|
-
/**
|
|
25
|
-
* Deserialize a list of [key, value] pairs into an object or array.
|
|
26
|
-
* The key is expressed by using bracket-notation.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* const entities = [
|
|
31
|
-
* ['name', 'John Doe'],
|
|
32
|
-
* ['name[pets][0]', 'dog'],
|
|
33
|
-
* ['name[pets][1]', 'cat'],
|
|
34
|
-
* ['name[dogs][]', 'hello'],
|
|
35
|
-
* ['name[dogs][]', 'kitty'],
|
|
36
|
-
* ]
|
|
37
|
-
*
|
|
38
|
-
* const payload = deserialize(entities)
|
|
39
|
-
*
|
|
40
|
-
* expect(payload).toEqual({
|
|
41
|
-
* name: 'John Doe',
|
|
42
|
-
* pets: { 0: 'dog', 1: 'cat' },
|
|
43
|
-
* dogs: ['hello', 'kitty'],
|
|
44
|
-
* })
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
export declare function deserialize(entities: readonly (readonly [string, unknown])[]): Record<string, unknown> | unknown[] | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Escape the `[`, `]`, and `\` chars in a path segment.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```ts
|
|
53
|
-
* expect(escapeSegment('name[pets')).toEqual('name\\[pets')
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
export declare function escapeSegment(segment: string): string;
|
|
57
|
-
/**
|
|
58
|
-
* Convert an array of path segments into a path string using bracket-notation.
|
|
59
|
-
*
|
|
60
|
-
* For the special char `[`, `]`, and `\` will be escaped by adding `\` at start.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```ts
|
|
64
|
-
* expect(stringifyPath(['name', 'pets', '0'])).toEqual('name[pets][0]')
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
export declare function stringifyPath(path: readonly [string, ...string[]]): string;
|
|
68
|
-
/**
|
|
69
|
-
* Convert a path string using bracket-notation into an array of path segments.
|
|
70
|
-
*
|
|
71
|
-
* For the special char `[`, `]`, and `\` you should escape by adding `\` at start.
|
|
72
|
-
* It only treats a pair `[${string}]` as a path segment.
|
|
73
|
-
* If missing or escape it will bypass and treat as normal string.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```ts
|
|
77
|
-
* expect(parsePath('name[pets][0]')).toEqual(['name', 'pets', '0'])
|
|
78
|
-
* expect(parsePath('name[pets][0')).toEqual(['name', 'pets', '[0'])
|
|
79
|
-
* expect(parsePath('name[pets[0]')).toEqual(['name', 'pets[0')
|
|
80
|
-
* expect(parsePath('name\\[pets][0]')).toEqual(['name[pets]', '0'])
|
|
81
|
-
* ```
|
|
82
|
-
*/
|
|
83
|
-
export declare function parsePath(path: string): [string, ...string[]];
|
|
84
|
-
//# sourceMappingURL=bracket-notation.d.ts.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './bracket-notation';
|
|
2
|
-
export * from './input-builder-full';
|
|
3
|
-
export * from './input-builder-simple';
|
|
4
|
-
export * from './openapi-handler';
|
|
5
|
-
export * from './openapi-handler-server';
|
|
6
|
-
export * from './openapi-handler-serverless';
|
|
7
|
-
export * from './openapi-payload-codec';
|
|
8
|
-
export * from './openapi-procedure-matcher';
|
|
9
|
-
export * from './schema-coercer';
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Params } from 'hono/router';
|
|
2
|
-
export declare class InputBuilderFull {
|
|
3
|
-
build(params: Params, query: unknown, headers: unknown, body: unknown): {
|
|
4
|
-
params: Params;
|
|
5
|
-
query: unknown;
|
|
6
|
-
headers: unknown;
|
|
7
|
-
body: unknown;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export type PublicInputBuilderFull = Pick<InputBuilderFull, keyof InputBuilderFull>;
|
|
11
|
-
//# sourceMappingURL=input-builder-full.d.ts.map
|
|
@@ -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,7 +0,0 @@
|
|
|
1
|
-
import type { Context, Router } from '@orpc/server';
|
|
2
|
-
import type { OpenAPIHandlerOptions } from './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
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Context, Router } from '@orpc/server';
|
|
2
|
-
import type { OpenAPIHandlerOptions } from './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
|