@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.
@@ -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