@orpc/openapi 0.0.0-next.f56d2b3 → 0.0.0-next.fd0ca3d
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 -30
- package/dist/hono.js +5 -30
- package/dist/index.js +196 -41
- package/dist/next.js +5 -30
- package/dist/node.js +18 -34
- package/dist/src/adapters/fetch/index.d.ts +0 -8
- package/dist/src/adapters/fetch/openapi-handler.d.ts +7 -28
- package/dist/src/adapters/node/index.d.ts +0 -3
- package/dist/src/adapters/node/openapi-handler.d.ts +8 -8
- 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 +3 -3
- package/dist/src/openapi-operation-extender.d.ts +7 -0
- package/dist/src/utils.d.ts +2 -16
- package/dist/standard.js +10 -0
- package/package.json +14 -12
- package/dist/chunk-Q2LSK6YZ.js +0 -102
- package/dist/chunk-SOVQ5ARD.js +0 -650
- package/dist/chunk-VFGNQS5W.js +0 -25
- 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/node.js
CHANGED
|
@@ -1,46 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
OpenAPICodec,
|
|
3
|
+
OpenAPIMatcher
|
|
4
|
+
} from "./chunk-LPBZEW4B.js";
|
|
5
|
+
import "./chunk-XGHV4TH3.js";
|
|
5
6
|
|
|
6
7
|
// src/adapters/node/openapi-handler.ts
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import { sendStandardResponse, toStandardRequest } from "@orpc/server-standard-node";
|
|
9
|
+
import { StandardHandler } from "@orpc/server/standard";
|
|
10
|
+
var OpenAPIHandler = class {
|
|
11
|
+
standardHandler;
|
|
12
|
+
constructor(router, options) {
|
|
13
|
+
const matcher = options?.matcher ?? new OpenAPIMatcher(options);
|
|
14
|
+
const codec = options?.codec ?? new OpenAPICodec(options);
|
|
15
|
+
this.standardHandler = new StandardHandler(router, matcher, codec, { ...options });
|
|
12
16
|
}
|
|
13
|
-
async handle(req, res, ...
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
if (result.matched === false) {
|
|
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) {
|
|
18
21
|
return { matched: false };
|
|
19
22
|
}
|
|
20
|
-
await
|
|
21
|
-
await sendResponse(res, result.response);
|
|
23
|
+
await sendStandardResponse(res, result.response);
|
|
22
24
|
return { matched: true };
|
|
23
25
|
}
|
|
24
26
|
};
|
|
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
27
|
export {
|
|
42
|
-
|
|
43
|
-
OpenAPIServerHandler,
|
|
44
|
-
OpenAPIServerlessHandler
|
|
28
|
+
OpenAPIHandler
|
|
45
29
|
};
|
|
46
30
|
//# sourceMappingURL=node.js.map
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
export * from './bracket-notation';
|
|
2
|
-
export * from './input-structure-compact';
|
|
3
|
-
export * from './input-structure-detailed';
|
|
4
1
|
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
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,32 +1,11 @@
|
|
|
1
1
|
import type { Context, Router } from '@orpc/server';
|
|
2
|
-
import type { FetchHandler,
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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, any> & {
|
|
11
|
-
jsonSerializer?: PublicJSONSerializer;
|
|
12
|
-
procedureMatcher?: PublicOpenAPIProcedureMatcher;
|
|
13
|
-
payloadCodec?: PublicOpenAPIPayloadCodec;
|
|
14
|
-
inputBuilderSimple?: PublicInputStructureCompact;
|
|
15
|
-
inputBuilderFull?: PublicInputStructureDetailed;
|
|
16
|
-
schemaCoercers?: SchemaCoercer[];
|
|
17
|
-
};
|
|
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';
|
|
18
6
|
export declare class OpenAPIHandler<T extends Context> implements FetchHandler<T> {
|
|
19
|
-
private readonly
|
|
20
|
-
|
|
21
|
-
|
|
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;
|
|
7
|
+
private readonly standardHandler;
|
|
8
|
+
constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
9
|
+
handle(request: Request, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<FetchHandleResult>;
|
|
31
10
|
}
|
|
32
11
|
//# sourceMappingURL=openapi-handler.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Context, Router } from '@orpc/server';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import
|
|
6
|
-
export declare class OpenAPIHandler<T extends Context> implements
|
|
7
|
-
private readonly
|
|
8
|
-
constructor(
|
|
9
|
-
handle(req:
|
|
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
10
|
}
|
|
11
11
|
//# sourceMappingURL=openapi-handler.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ORPCError } from '@orpc/client';
|
|
2
|
+
import type { AnyProcedure } from '@orpc/server';
|
|
3
|
+
import type { StandardRequest, StandardResponse } from '@orpc/server-standard';
|
|
4
|
+
import type { StandardCodec, StandardParams } from '@orpc/server/standard';
|
|
5
|
+
import { OpenAPISerializer } from '@orpc/client/openapi';
|
|
6
|
+
export interface OpenAPICodecOptions {
|
|
7
|
+
serializer?: OpenAPISerializer;
|
|
8
|
+
}
|
|
9
|
+
export declare class OpenAPICodec implements StandardCodec {
|
|
10
|
+
private readonly serializer;
|
|
11
|
+
constructor(options?: OpenAPICodecOptions);
|
|
12
|
+
decode(request: StandardRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
|
13
|
+
encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
|
14
|
+
encodeError(error: ORPCError<any, any>): StandardResponse;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=openapi-codec.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Context } from '@orpc/server';
|
|
2
|
+
import type { RPCHandlerOptions } from '@orpc/server/standard';
|
|
3
|
+
import type { OpenAPICodecOptions } from './openapi-codec';
|
|
4
|
+
import type { OpenAPIMatcherOptions } from './openapi-matcher';
|
|
5
|
+
export interface OpenAPIHandlerOptions<T extends Context> extends RPCHandlerOptions<T>, OpenAPIMatcherOptions, OpenAPICodecOptions {
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=openapi-handler.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
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 interface OpenAPIMatcherOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Ignore procedure that does not have a method defined in the contract.
|
|
7
|
+
*
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
ignoreUndefinedMethod?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class OpenAPIMatcher implements StandardMatcher {
|
|
13
|
+
private readonly tree;
|
|
14
|
+
private readonly ignoreUndefinedMethod;
|
|
15
|
+
constructor(options?: OpenAPIMatcherOptions);
|
|
16
|
+
private pendingRouters;
|
|
17
|
+
init(router: AnyRouter, path?: string[]): void;
|
|
18
|
+
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
|
19
|
+
}
|
|
20
|
+
//# 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,10 +1,10 @@
|
|
|
1
|
-
import type { AnyRouter } from '@orpc/server';
|
|
2
1
|
import type { PublicOpenAPIInputStructureParser } from './openapi-input-structure-parser';
|
|
3
2
|
import type { PublicOpenAPIOutputStructureParser } from './openapi-output-structure-parser';
|
|
4
3
|
import type { PublicOpenAPIPathParser } from './openapi-path-parser';
|
|
5
4
|
import type { SchemaConverter } from './schema-converter';
|
|
5
|
+
import { type PublicOpenAPIJsonSerializer } from '@orpc/client/openapi';
|
|
6
6
|
import { type ContractRouter } from '@orpc/contract';
|
|
7
|
-
import { type
|
|
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;
|
|
@@ -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
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AnyProcedure, AnyRouter, Lazy } from '@orpc/server';
|
|
3
|
-
export interface EachLeafOptions {
|
|
4
|
-
router: AnyContractRouter | AnyRouter;
|
|
5
|
-
path: string[];
|
|
6
|
-
}
|
|
7
|
-
export interface EachLeafCallbackOptions {
|
|
8
|
-
contract: AnyContractProcedure;
|
|
9
|
-
path: string[];
|
|
10
|
-
}
|
|
11
|
-
export interface EachContractLeafResultItem {
|
|
12
|
-
router: Lazy<AnyProcedure> | Lazy<Record<string, AnyRouter> | AnyProcedure>;
|
|
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: AnyContractRouter | AnyRouter, 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.fd0ca3d",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -19,6 +19,11 @@
|
|
|
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",
|
|
@@ -49,21 +54,18 @@
|
|
|
49
54
|
"dist"
|
|
50
55
|
],
|
|
51
56
|
"dependencies": {
|
|
52
|
-
"@standard
|
|
53
|
-
"@
|
|
54
|
-
"
|
|
55
|
-
"escape-string-regexp": "^5.0.0",
|
|
56
|
-
"fast-content-type-parse": "^2.0.0",
|
|
57
|
-
"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",
|
|
58
60
|
"json-schema-typed": "^8.0.1",
|
|
59
61
|
"openapi3-ts": "^4.4.0",
|
|
60
|
-
"
|
|
61
|
-
"@orpc/
|
|
62
|
-
"@orpc/contract": "0.0.0-next.
|
|
63
|
-
"@orpc/
|
|
62
|
+
"rou3": "^0.5.1",
|
|
63
|
+
"@orpc/client": "0.0.0-next.fd0ca3d",
|
|
64
|
+
"@orpc/contract": "0.0.0-next.fd0ca3d",
|
|
65
|
+
"@orpc/server": "0.0.0-next.fd0ca3d",
|
|
66
|
+
"@orpc/shared": "0.0.0-next.fd0ca3d"
|
|
64
67
|
},
|
|
65
68
|
"devDependencies": {
|
|
66
|
-
"@readme/openapi-parser": "^2.6.0",
|
|
67
69
|
"zod": "^3.24.1"
|
|
68
70
|
},
|
|
69
71
|
"scripts": {
|
package/dist/chunk-Q2LSK6YZ.js
DELETED
|
@@ -1,102 +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, 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 (isContractProcedure(options.router)) {
|
|
58
|
-
callback({
|
|
59
|
-
contract: options.router,
|
|
60
|
-
path: options.path
|
|
61
|
-
});
|
|
62
|
-
} else {
|
|
63
|
-
for (const key in options.router) {
|
|
64
|
-
forEachContractProcedure(
|
|
65
|
-
{
|
|
66
|
-
router: options.router[key],
|
|
67
|
-
path: [...options.path, key]
|
|
68
|
-
},
|
|
69
|
-
callback,
|
|
70
|
-
result
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
async function forEachAllContractProcedure(router, callback) {
|
|
77
|
-
const pending = [{
|
|
78
|
-
path: [],
|
|
79
|
-
router
|
|
80
|
-
}];
|
|
81
|
-
for (const item of pending) {
|
|
82
|
-
const lazies = forEachContractProcedure(item, callback);
|
|
83
|
-
for (const lazy of lazies) {
|
|
84
|
-
const { default: router2 } = await unlazy(lazy.router);
|
|
85
|
-
pending.push({
|
|
86
|
-
path: lazy.path,
|
|
87
|
-
router: router2
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function standardizeHTTPPath(path) {
|
|
93
|
-
return `/${path.replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "")}`;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export {
|
|
97
|
-
JSONSerializer,
|
|
98
|
-
forEachContractProcedure,
|
|
99
|
-
forEachAllContractProcedure,
|
|
100
|
-
standardizeHTTPPath
|
|
101
|
-
};
|
|
102
|
-
//# sourceMappingURL=chunk-Q2LSK6YZ.js.map
|