@orpc/openapi 0.0.0-next.e9dc36e → 0.0.0-next.ee0aeaf
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-7HD5IZWG.js +53 -0
- package/dist/fetch.js +707 -0
- package/dist/index.js +403 -240
- package/dist/src/fetch/base-handler.d.ts +13 -0
- package/dist/src/fetch/index.d.ts +4 -0
- package/dist/src/fetch/server-handler.d.ts +3 -0
- package/dist/src/fetch/serverless-handler.d.ts +3 -0
- package/dist/src/generator.d.ts +1 -1
- package/dist/src/utils.d.ts +17 -0
- package/dist/src/zod-to-json-schema.d.ts +2 -2
- package/package.json +22 -18
- package/dist/index.js.map +0 -1
- package/dist/src/generator.d.ts.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/zod-to-json-schema.d.ts.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/generator.test.ts +0 -643
- package/src/generator.ts +0 -338
- package/src/index.ts +0 -3
- package/src/zod-to-json-schema.test.ts +0 -391
- package/src/zod-to-json-schema.ts +0 -655
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// src/utils.ts
|
|
2
|
+
import { isContractProcedure } from "@orpc/contract";
|
|
3
|
+
import { isLazy, isProcedure, ROUTER_CONTRACT_SYMBOL } from "@orpc/server";
|
|
4
|
+
function eachContractProcedureLeaf(options, callback, result = [], isCurrentRouterContract = false) {
|
|
5
|
+
if (!isCurrentRouterContract && ROUTER_CONTRACT_SYMBOL in options.router && options.router[ROUTER_CONTRACT_SYMBOL]) {
|
|
6
|
+
return eachContractProcedureLeaf(
|
|
7
|
+
{
|
|
8
|
+
path: options.path,
|
|
9
|
+
router: options.router[ROUTER_CONTRACT_SYMBOL]
|
|
10
|
+
},
|
|
11
|
+
callback,
|
|
12
|
+
result,
|
|
13
|
+
true
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
if (isLazy(options.router)) {
|
|
17
|
+
result.push({
|
|
18
|
+
lazy: options.router,
|
|
19
|
+
path: options.path
|
|
20
|
+
});
|
|
21
|
+
} else if (isProcedure(options.router)) {
|
|
22
|
+
callback({
|
|
23
|
+
contract: options.router.zz$p.contract,
|
|
24
|
+
path: options.path
|
|
25
|
+
});
|
|
26
|
+
} else if (isContractProcedure(options.router)) {
|
|
27
|
+
callback({
|
|
28
|
+
contract: options.router,
|
|
29
|
+
path: options.path
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
for (const key in options.router) {
|
|
33
|
+
eachContractProcedureLeaf(
|
|
34
|
+
{
|
|
35
|
+
router: options.router[key],
|
|
36
|
+
path: [...options.path, key]
|
|
37
|
+
},
|
|
38
|
+
callback,
|
|
39
|
+
result
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
function standardizeHTTPPath(path) {
|
|
46
|
+
return `/${path.replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "")}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
eachContractProcedureLeaf,
|
|
51
|
+
standardizeHTTPPath
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=chunk-7HD5IZWG.js.map
|