@scalar/cli 2.1.0 → 2.5.2
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 +28 -24
- package/chunks/action-42D2C47G.js +18 -0
- package/chunks/{action-DFKHSDFV.js → action-6FAJNP6C.js} +7 -3
- package/chunks/{action-5R5FDF6S.js → action-6MZZHPVQ.js} +120 -22
- package/chunks/{action-BYZUBXVB.js → action-7H3XARJP.js} +8 -4
- package/chunks/{action-H5OHT2GV.js → action-AMNYOA4B.js} +7 -3
- package/chunks/{action-ANU5HGC4.js → action-DCINFQ57.js} +17 -14
- package/chunks/{action-GB6DM53B.js → action-DGD6Q6Y5.js} +21 -10
- package/chunks/{action-TPBKPHNS.js → action-EPNE5XCM.js} +22 -22
- package/chunks/{action-C5VB4ITT.js → action-FF2OMGAS.js} +36 -18
- package/chunks/{action-Q5UJ32D6.js → action-H3RTILLM.js} +1 -1
- package/chunks/action-HIL5ZFNB.js +84 -0
- package/chunks/{action-MENXFJH3.js → action-HXHBU7XC.js} +9 -9
- package/chunks/{action-F4Y6Q2VB.js → action-LFL3ZZKN.js} +21 -21
- package/chunks/action-LUVBQEIQ.js +250 -0
- package/chunks/{action-TZ5KGAQT.js → action-OILGZAMK.js} +17 -14
- package/chunks/{action-HD2T6BFJ.js → action-OK55BFGM.js} +10 -10
- package/chunks/{action-HNKM3Q65.js → action-P7RFXIC7.js} +17 -14
- package/chunks/action-PAA4NWUJ.js +374 -0
- package/chunks/action-PHLOE27S.js +522 -0
- package/chunks/{action-CYP4VDK3.js → action-RBVPKCRI.js} +12 -35
- package/chunks/action-SJYAMXYI.js +244 -0
- package/chunks/{action-45OGQB2M.js → action-TWHLZW4V.js} +17 -8
- package/chunks/{action-GEBRPNRT.js → action-V5KYG7XD.js} +15 -16
- package/chunks/{action-BNEGJBUH.js → action-W62AIEBN.js} +8 -9
- package/chunks/{action-PVDDRIM6.js → action-X7TZA3RE.js} +65 -26
- package/chunks/{action-CLSD7O2R.js → action-XUQ7TKKJ.js} +10 -10
- package/chunks/{action-BMFXENMX.js → action-Y6CEKYEK.js} +39 -34
- package/chunks/{action-STIEAXOE.js → action-YRWHX2AE.js} +16 -5
- package/chunks/{action-W5BATF4Q.js → action-ZLTUMRO2.js} +24 -24
- package/chunks/{action-UDZUUJSI.js → action-ZWQLQENM.js} +18 -7
- package/chunks/{agent-XGLOHXNA.js → agent-JAXLLDPE.js} +25 -5
- package/chunks/asyncapi-P6Y3L7RG.js +105 -0
- package/chunks/{build.action-LKOILPA6.js → build.action-AZ5ECU4B.js} +22 -22
- package/chunks/chunk-3BWGTPPT.js +27022 -0
- package/chunks/{chunk-ZTVWAKNJ.js → chunk-3DJ2GKEG.js} +1 -1
- package/chunks/chunk-3ZJYGGAA.js +30 -0
- package/chunks/{chunk-IX7LJ3AD.js → chunk-4ORL4MST.js} +2 -3
- package/chunks/{chunk-ASMHW5AY.js → chunk-6ZMT63IV.js} +1 -1
- package/chunks/{chunk-B6QZJWCQ.js → chunk-B2MHTD3R.js} +4 -6
- package/chunks/{chunk-P646T2WH.js → chunk-CIFOFSZ3.js} +131 -13
- package/chunks/chunk-CX7ZRMTC.js +404 -0
- package/chunks/{chunk-HQKBZOYU.js → chunk-FOKFF4EP.js} +3 -3
- package/chunks/{chunk-UPUTMFD4.js → chunk-FQVVKQPU.js} +185 -13
- package/chunks/{chunk-P2VH7DOC.js → chunk-HUCR333E.js} +6 -6
- package/chunks/{chunk-KWOL7A6J.js → chunk-HXIDUCSZ.js} +2 -2
- package/chunks/{chunk-H2WRMLYY.js → chunk-IKT5F47M.js} +3571 -7
- package/chunks/{chunk-OAXFCOJV.js → chunk-JV7TUEXQ.js} +2 -1
- package/chunks/{chunk-2BSG2QHO.js → chunk-KEOCJ3NJ.js} +133 -20
- package/chunks/{chunk-AHWWJ3MD.js → chunk-LCPFHE4Z.js} +1 -1
- package/chunks/{chunk-TLFMATXR.js → chunk-LQN4S62O.js} +33 -25
- package/chunks/chunk-M622VXRQ.js +14 -0
- package/chunks/chunk-M6Q3ARBV.js +210 -0
- package/chunks/{chunk-4QS7SJTG.js → chunk-MNLXYOVF.js} +51 -36
- package/chunks/{chunk-5BISXQX4.js → chunk-NIXG4KDE.js} +11 -13
- package/chunks/{chunk-47Y4L5IT.js → chunk-NNMSZVAB.js} +1031 -481
- package/chunks/chunk-OQKDBLOZ.js +741 -0
- package/chunks/{chunk-NUXPNUSS.js → chunk-RAO7VUGM.js} +1 -1
- package/chunks/{chunk-SHSHFGA7.js → chunk-RPVHJMQT.js} +4 -6
- package/chunks/{chunk-23I5PKZZ.js → chunk-SWWWYWHC.js} +32 -5
- package/chunks/{chunk-X4QLDBB5.js → chunk-T5HJUAWB.js} +24 -3
- package/chunks/chunk-TYLWJ2UL.js +25 -0
- package/chunks/{chunk-SXYALPYK.js → chunk-UB3XGOUW.js} +498 -60
- package/chunks/{chunk-TQ5XC2E3.js → chunk-UMPODUJO.js} +77 -11
- package/chunks/{chunk-4DGQIAJX.js → chunk-VNYE4R7N.js} +154 -14
- package/chunks/{create.action-FFQLBSJH.js → create.action-34OTO2SB.js} +22 -22
- package/chunks/{delete.action-QNN3LC2F.js → delete.action-6LRT4M3S.js} +22 -22
- package/chunks/{delete.action-STHQHP4F.js → delete.action-ZYXFMIOW.js} +22 -22
- package/chunks/{get.action-OTKYOP3Z.js → get.action-XP36SA2J.js} +15 -16
- package/chunks/{list.action-KDM5RHEH.js → list.action-6LF6KSD5.js} +19 -19
- package/chunks/{list.action-6I5EZAVB.js → list.action-WVRVLX5E.js} +22 -22
- package/chunks/{publish.action-PODTVRXS.js → publish.action-AHFUBT5C.js} +44 -36
- package/chunks/{update.action-KMD4ZM75.js → update.action-YQTVUDYE.js} +22 -22
- package/chunks/{update.action-4F6STTEQ.js → update.action-ZREAFJVG.js} +22 -22
- package/docs.html +107 -104
- package/index.js +84 -68
- package/package.json +19 -15
- package/chunks/action-CCW66QJN.js +0 -72
- package/chunks/action-CQ56FVES.js +0 -65
- package/chunks/action-JOSVV6YA.js +0 -71
- package/chunks/action-P7LN6FGY.js +0 -13
- package/chunks/action-R6ZZO26F.js +0 -299
- package/chunks/action-TWFJNQ2R.js +0 -95
- package/chunks/chunk-5BPPGTUU.js +0 -463
- package/chunks/chunk-DOVIWNKQ.js +0 -108
- package/chunks/chunk-ISGLWBXZ.js +0 -4265
- package/chunks/chunk-T7MDADON.js +0 -17
- package/chunks/chunk-VTYTPSXO.js +0 -161
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
downloadIsolate
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UMPODUJO.js";
|
|
5
|
+
import "./chunk-3ZJYGGAA.js";
|
|
5
6
|
import {
|
|
6
7
|
readAndParseConfig,
|
|
7
8
|
renderConfigError
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HUCR333E.js";
|
|
9
10
|
import {
|
|
10
11
|
CONFIG_FILE_DEFAULT,
|
|
11
12
|
findConfig
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-NNMSZVAB.js";
|
|
13
14
|
import {
|
|
14
15
|
ISOLATE_DIR
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-5BPPGTUU.js";
|
|
17
|
-
import "./chunk-4QS7SJTG.js";
|
|
18
|
-
import "./chunk-VTYTPSXO.js";
|
|
16
|
+
} from "./chunk-HXIDUCSZ.js";
|
|
19
17
|
import {
|
|
20
18
|
getAuthData
|
|
21
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-NIXG4KDE.js";
|
|
22
20
|
import {
|
|
23
21
|
config
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-4DGQIAJX.js";
|
|
22
|
+
} from "./chunk-JV7TUEXQ.js";
|
|
23
|
+
import "./chunk-VNYE4R7N.js";
|
|
27
24
|
import {
|
|
28
25
|
ConfigVersion
|
|
29
|
-
} from "./chunk-
|
|
30
|
-
import "./chunk-H2WRMLYY.js";
|
|
26
|
+
} from "./chunk-OQKDBLOZ.js";
|
|
31
27
|
import "./chunk-K74E42RV.js";
|
|
32
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-MNLXYOVF.js";
|
|
29
|
+
import "./chunk-CX7ZRMTC.js";
|
|
30
|
+
import "./chunk-4ORL4MST.js";
|
|
33
31
|
import {
|
|
34
32
|
output
|
|
35
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-T5HJUAWB.js";
|
|
34
|
+
import "./chunk-LQN4S62O.js";
|
|
35
|
+
import "./chunk-IKT5F47M.js";
|
|
36
36
|
import "./chunk-3MZYUBJ6.js";
|
|
37
37
|
|
|
38
38
|
// src/domains/project/preview/action.ts
|
|
@@ -43,13 +43,31 @@ import as from "ansis";
|
|
|
43
43
|
import { spawn } from "node:child_process";
|
|
44
44
|
import path from "node:path";
|
|
45
45
|
async function runIsolate(isolateOptions) {
|
|
46
|
-
const
|
|
46
|
+
const executable = process.env.SCALAR_CLI_DISTRIBUTION === "portable" ? path.join(
|
|
47
|
+
path.dirname(process.execPath),
|
|
48
|
+
"runtime",
|
|
49
|
+
process.platform === "win32" ? "node.exe" : "node"
|
|
50
|
+
) : process.execPath;
|
|
51
|
+
const child = spawn(executable, ["dist/isolate-entry.js"], {
|
|
52
|
+
cwd: ISOLATE_DIR,
|
|
53
|
+
env: {
|
|
54
|
+
...process.env,
|
|
55
|
+
PATH: `${path.dirname(executable)}${path.delimiter}${process.env.PATH ?? ""}`
|
|
56
|
+
}
|
|
57
|
+
});
|
|
47
58
|
child.stdin.write(JSON.stringify(isolateOptions));
|
|
48
59
|
child.stdin.end();
|
|
49
60
|
child.stdout.pipe(process.stdout);
|
|
50
61
|
child.stderr.pipe(process.stderr);
|
|
51
|
-
child.on("
|
|
52
|
-
console.
|
|
62
|
+
child.on("error", (error) => {
|
|
63
|
+
console.error(`Could not start docs preview: ${error.message}`);
|
|
64
|
+
process.exitCode = 1;
|
|
65
|
+
});
|
|
66
|
+
child.on("close", (code, signal) => {
|
|
67
|
+
console.log(
|
|
68
|
+
`Process exited with code ${code}${signal ? ` (signal ${signal})` : ""}.`
|
|
69
|
+
);
|
|
70
|
+
process.exitCode = code ?? 1;
|
|
53
71
|
});
|
|
54
72
|
}
|
|
55
73
|
async function getAccessToken() {
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
getFileOrUrl,
|
|
4
|
+
isAsyncApiContent
|
|
5
|
+
} from "./chunk-SWWWYWHC.js";
|
|
6
|
+
import {
|
|
7
|
+
config
|
|
8
|
+
} from "./chunk-JV7TUEXQ.js";
|
|
9
|
+
import "./chunk-MNLXYOVF.js";
|
|
10
|
+
import "./chunk-CX7ZRMTC.js";
|
|
11
|
+
import "./chunk-4ORL4MST.js";
|
|
12
|
+
import {
|
|
13
|
+
output
|
|
14
|
+
} from "./chunk-T5HJUAWB.js";
|
|
15
|
+
import "./chunk-LQN4S62O.js";
|
|
16
|
+
import "./chunk-IKT5F47M.js";
|
|
17
|
+
import "./chunk-3MZYUBJ6.js";
|
|
18
|
+
|
|
19
|
+
// src/domains/document/share/action.ts
|
|
20
|
+
import as from "ansis";
|
|
21
|
+
async function shareAction(fileArgument, { token }) {
|
|
22
|
+
if (!fileArgument) {
|
|
23
|
+
return output.error().title("Invalid argument").message("Please provide a file path").exit("error");
|
|
24
|
+
}
|
|
25
|
+
const content = await getFileOrUrl(fileArgument);
|
|
26
|
+
const specification = isAsyncApiContent(content) ? "AsyncAPI" : "OpenAPI";
|
|
27
|
+
const sandboxUrl = new URL(config.projects.sandbox);
|
|
28
|
+
const url = new URL("/api/share", sandboxUrl);
|
|
29
|
+
url.pathname = "/api/share";
|
|
30
|
+
if (token) {
|
|
31
|
+
url.searchParams.append("token", token);
|
|
32
|
+
}
|
|
33
|
+
return fetch(url.toString(), {
|
|
34
|
+
method: "POST",
|
|
35
|
+
headers: {
|
|
36
|
+
"Content-Type": "application/json"
|
|
37
|
+
},
|
|
38
|
+
body: JSON.stringify({
|
|
39
|
+
content
|
|
40
|
+
})
|
|
41
|
+
}).then(async (response) => {
|
|
42
|
+
if (!response.ok)
|
|
43
|
+
throw new Error(`Sandbox returned HTTP ${response.status}`);
|
|
44
|
+
return response.json();
|
|
45
|
+
}).then((data) => {
|
|
46
|
+
if (data === null || typeof data !== "object" || Array.isArray(data)) {
|
|
47
|
+
throw new Error("Invalid sandbox response");
|
|
48
|
+
}
|
|
49
|
+
if (data.error || typeof data.id !== "string" || typeof data.token !== "string") {
|
|
50
|
+
throw new Error(data.message || "Invalid sandbox response");
|
|
51
|
+
}
|
|
52
|
+
const { id, token: newToken } = data;
|
|
53
|
+
const link = (pathname) => new URL(pathname, sandboxUrl).toString();
|
|
54
|
+
output.info().line(as.green.bold(`Your ${specification} file is public.`)).line().table(
|
|
55
|
+
[
|
|
56
|
+
[
|
|
57
|
+
`${as.green("\u279C")} ${as.white.bold("API Reference:")}`,
|
|
58
|
+
as.cyan(link(`/p/${id}`))
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
`${as.grey("\u279C")} ${as.grey.bold("Editor:")}`,
|
|
62
|
+
as.cyan(link(`/e/${id}`))
|
|
63
|
+
],
|
|
64
|
+
[],
|
|
65
|
+
[
|
|
66
|
+
`${as.grey("\u279C")} ${as.grey.bold(`${specification} JSON:`)}`,
|
|
67
|
+
as.cyan(link(`/files/${id}/openapi.json`))
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
`${as.grey("\u279C")} ${as.grey.bold(`${specification} YAML:`)}`,
|
|
71
|
+
as.cyan(link(`/files/${id}/openapi.yaml`))
|
|
72
|
+
]
|
|
73
|
+
],
|
|
74
|
+
{ padding: 1 }
|
|
75
|
+
).line().line("Use the token to update the existing sandbox:").line().line(
|
|
76
|
+
`${as.grey("$")} ${as.white.bold("scalar document share --token=")}${as.cyan.bold(`${newToken}`)} `
|
|
77
|
+
).line().print();
|
|
78
|
+
}).catch((error) => {
|
|
79
|
+
output.error().title("Failed to share the file.").message(`Details: ${error}`).exit("error");
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
shareAction
|
|
84
|
+
};
|
|
@@ -8,19 +8,19 @@ import {
|
|
|
8
8
|
generateAccessByPersonalToken,
|
|
9
9
|
setAuthData,
|
|
10
10
|
tokenResponseSchema
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-NIXG4KDE.js";
|
|
12
12
|
import {
|
|
13
13
|
config
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import
|
|
18
|
-
external_exports
|
|
19
|
-
} from "./chunk-H2WRMLYY.js";
|
|
20
|
-
import "./chunk-IX7LJ3AD.js";
|
|
14
|
+
} from "./chunk-JV7TUEXQ.js";
|
|
15
|
+
import "./chunk-VNYE4R7N.js";
|
|
16
|
+
import "./chunk-OQKDBLOZ.js";
|
|
17
|
+
import "./chunk-4ORL4MST.js";
|
|
21
18
|
import {
|
|
22
19
|
output
|
|
23
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-T5HJUAWB.js";
|
|
21
|
+
import {
|
|
22
|
+
external_exports
|
|
23
|
+
} from "./chunk-IKT5F47M.js";
|
|
24
24
|
import "./chunk-3MZYUBJ6.js";
|
|
25
25
|
|
|
26
26
|
// src/domains/auth/login/action.ts
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
apiService
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UB3XGOUW.js";
|
|
5
5
|
import {
|
|
6
6
|
BaseCollections
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-KEOCJ3NJ.js";
|
|
8
8
|
import {
|
|
9
9
|
getDatabaseClient
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-VTYTPSXO.js";
|
|
10
|
+
} from "./chunk-RPVHJMQT.js";
|
|
11
|
+
import "./chunk-FQVVKQPU.js";
|
|
12
|
+
import "./chunk-B2MHTD3R.js";
|
|
13
|
+
import "./chunk-3BWGTPPT.js";
|
|
14
|
+
import "./chunk-M622VXRQ.js";
|
|
15
|
+
import "./chunk-CIFOFSZ3.js";
|
|
17
16
|
import {
|
|
18
17
|
getAuthData
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-TLFMATXR.js";
|
|
18
|
+
} from "./chunk-NIXG4KDE.js";
|
|
19
|
+
import "./chunk-JV7TUEXQ.js";
|
|
22
20
|
import {
|
|
23
21
|
teamSchema
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import
|
|
26
|
-
namespaceSchema
|
|
27
|
-
} from "./chunk-ISGLWBXZ.js";
|
|
28
|
-
import {
|
|
29
|
-
external_exports
|
|
30
|
-
} from "./chunk-H2WRMLYY.js";
|
|
22
|
+
} from "./chunk-VNYE4R7N.js";
|
|
23
|
+
import "./chunk-OQKDBLOZ.js";
|
|
31
24
|
import "./chunk-K74E42RV.js";
|
|
32
|
-
import "./chunk-
|
|
25
|
+
import "./chunk-MNLXYOVF.js";
|
|
26
|
+
import "./chunk-CX7ZRMTC.js";
|
|
27
|
+
import "./chunk-4ORL4MST.js";
|
|
33
28
|
import {
|
|
34
29
|
output,
|
|
35
30
|
printTable
|
|
36
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-T5HJUAWB.js";
|
|
32
|
+
import "./chunk-LQN4S62O.js";
|
|
33
|
+
import {
|
|
34
|
+
external_exports,
|
|
35
|
+
namespaceSchema
|
|
36
|
+
} from "./chunk-IKT5F47M.js";
|
|
37
37
|
import "./chunk-3MZYUBJ6.js";
|
|
38
38
|
|
|
39
39
|
// src/domains/registry/list/action.ts
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
measureTime
|
|
4
|
+
} from "./chunk-KHDYYVYF.js";
|
|
5
|
+
import {
|
|
6
|
+
isAsyncApiDocument,
|
|
7
|
+
isDocument,
|
|
8
|
+
safeNormalize
|
|
9
|
+
} from "./chunk-SWWWYWHC.js";
|
|
10
|
+
import {
|
|
11
|
+
require_dist
|
|
12
|
+
} from "./chunk-K74E42RV.js";
|
|
13
|
+
import "./chunk-MNLXYOVF.js";
|
|
14
|
+
import "./chunk-CX7ZRMTC.js";
|
|
15
|
+
import {
|
|
16
|
+
isYamlFileName
|
|
17
|
+
} from "./chunk-4ORL4MST.js";
|
|
18
|
+
import {
|
|
19
|
+
output
|
|
20
|
+
} from "./chunk-T5HJUAWB.js";
|
|
21
|
+
import "./chunk-LQN4S62O.js";
|
|
22
|
+
import {
|
|
23
|
+
external_exports
|
|
24
|
+
} from "./chunk-IKT5F47M.js";
|
|
25
|
+
import {
|
|
26
|
+
__toESM
|
|
27
|
+
} from "./chunk-3MZYUBJ6.js";
|
|
28
|
+
|
|
29
|
+
// src/domains/document/join/action.ts
|
|
30
|
+
var import_yaml = __toESM(require_dist(), 1);
|
|
31
|
+
import fs from "node:fs/promises";
|
|
32
|
+
import path from "node:path";
|
|
33
|
+
import as from "ansis";
|
|
34
|
+
import { bundle } from "@scalar/json-magic/bundle";
|
|
35
|
+
import { fetchUrls, readFiles } from "@scalar/json-magic/bundle/plugins/node";
|
|
36
|
+
import { join } from "@scalar/openapi-parser";
|
|
37
|
+
|
|
38
|
+
// src/domains/document/join/helpers.ts
|
|
39
|
+
import { getValueByPath as getValueByPathWithContext } from "@scalar/json-magic/helpers/get-value-by-path";
|
|
40
|
+
var getValueByPath = (input, path2) => {
|
|
41
|
+
return getValueByPathWithContext(input, path2).value;
|
|
42
|
+
};
|
|
43
|
+
var getPrefixes = (documents, path2) => {
|
|
44
|
+
const segments = path2.split(".");
|
|
45
|
+
return documents.map((doc) => {
|
|
46
|
+
const value = getValueByPath(doc, segments);
|
|
47
|
+
if (value === void 0) {
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
50
|
+
return String(value);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/domains/document/join/asyncapi.ts
|
|
55
|
+
import { isDeepStrictEqual } from "node:util";
|
|
56
|
+
import { upgrade } from "@scalar/asyncapi-upgrader";
|
|
57
|
+
import { validate } from "@scalar/asyncapi-validator";
|
|
58
|
+
var escapePointer = (value) => value.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
59
|
+
var unescapePointer = (value) => value.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
60
|
+
var prefixReferences = (value, prefix, section = "components") => {
|
|
61
|
+
if (Array.isArray(value))
|
|
62
|
+
return value.map((item) => prefixReferences(item, prefix, section));
|
|
63
|
+
if (!isDocument(value)) return value;
|
|
64
|
+
return Object.fromEntries(
|
|
65
|
+
Object.entries(value).map(([key, child]) => {
|
|
66
|
+
if (key === "$ref" && typeof child === "string" && child.startsWith(`#/${section}/`)) {
|
|
67
|
+
const segments = child.split("/");
|
|
68
|
+
const offset = section === "components" ? 3 : 2;
|
|
69
|
+
if (segments[offset])
|
|
70
|
+
segments[offset] = escapePointer(
|
|
71
|
+
prefix + unescapePointer(segments[offset])
|
|
72
|
+
);
|
|
73
|
+
return [key, segments.join("/")];
|
|
74
|
+
}
|
|
75
|
+
return [key, prefixReferences(child, prefix, section)];
|
|
76
|
+
})
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
var joinAsyncApi = (inputs, prefixes) => {
|
|
80
|
+
const conflicts = [];
|
|
81
|
+
const documents = inputs.map((input, index) => {
|
|
82
|
+
if (!validate(input).valid)
|
|
83
|
+
conflicts.push({
|
|
84
|
+
type: "asyncapi",
|
|
85
|
+
path: `input ${index + 1} is invalid`
|
|
86
|
+
});
|
|
87
|
+
const externalPrefix = `document${index}-`;
|
|
88
|
+
const document = prefixReferences(
|
|
89
|
+
upgrade(structuredClone(input)),
|
|
90
|
+
externalPrefix,
|
|
91
|
+
"x-ext"
|
|
92
|
+
);
|
|
93
|
+
if (isDocument(document["x-ext"])) {
|
|
94
|
+
document["x-ext"] = Object.fromEntries(
|
|
95
|
+
Object.entries(document["x-ext"]).map(([key, value]) => [
|
|
96
|
+
externalPrefix + key,
|
|
97
|
+
value
|
|
98
|
+
])
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
const prefix = prefixes[index] ?? "";
|
|
102
|
+
if (!prefix) return document;
|
|
103
|
+
const renamed = prefixReferences(document, prefix);
|
|
104
|
+
if (isDocument(renamed.components)) {
|
|
105
|
+
renamed.components = Object.fromEntries(
|
|
106
|
+
Object.entries(renamed.components).map(([kind, entries]) => [
|
|
107
|
+
kind,
|
|
108
|
+
isDocument(entries) ? Object.fromEntries(
|
|
109
|
+
Object.entries(entries).map(([name, value]) => [
|
|
110
|
+
prefix + name,
|
|
111
|
+
value
|
|
112
|
+
])
|
|
113
|
+
) : entries
|
|
114
|
+
])
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
return renamed;
|
|
118
|
+
});
|
|
119
|
+
const mergeNamed = (values, pointer) => {
|
|
120
|
+
const merged = /* @__PURE__ */ new Map();
|
|
121
|
+
for (const value of values) {
|
|
122
|
+
if (!isDocument(value)) continue;
|
|
123
|
+
for (const [name, entry] of Object.entries(value)) {
|
|
124
|
+
if (merged.has(name) && !isDeepStrictEqual(merged.get(name), entry)) {
|
|
125
|
+
conflicts.push({
|
|
126
|
+
type: "asyncapi",
|
|
127
|
+
path: `${pointer}/${escapePointer(name)}`
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
merged.set(name, entry);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return Object.fromEntries(merged);
|
|
134
|
+
};
|
|
135
|
+
const namedSections = ["channels", "operations", "servers", "x-ext"];
|
|
136
|
+
const separatelyMerged = /* @__PURE__ */ new Set(["info", "components", ...namedSections]);
|
|
137
|
+
const result = mergeNamed(
|
|
138
|
+
documents.map(
|
|
139
|
+
(document) => Object.fromEntries(
|
|
140
|
+
Object.entries(document).filter(([key]) => !separatelyMerged.has(key))
|
|
141
|
+
)
|
|
142
|
+
),
|
|
143
|
+
"#"
|
|
144
|
+
);
|
|
145
|
+
result.info = Object.assign(
|
|
146
|
+
{},
|
|
147
|
+
...[...documents].reverse().map((document) => document.info)
|
|
148
|
+
);
|
|
149
|
+
for (const section of namedSections) {
|
|
150
|
+
result[section] = mergeNamed(
|
|
151
|
+
documents.map((document) => document[section]),
|
|
152
|
+
`#/${section}`
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
const componentKinds = new Set(
|
|
156
|
+
documents.flatMap(
|
|
157
|
+
(document) => isDocument(document.components) ? Object.keys(document.components) : []
|
|
158
|
+
)
|
|
159
|
+
);
|
|
160
|
+
result.components = Object.fromEntries(
|
|
161
|
+
[...componentKinds].map((kind) => [
|
|
162
|
+
kind,
|
|
163
|
+
mergeNamed(
|
|
164
|
+
documents.map(
|
|
165
|
+
(document) => isDocument(document.components) ? document.components[kind] : void 0
|
|
166
|
+
),
|
|
167
|
+
`#/components/${escapePointer(kind)}`
|
|
168
|
+
)
|
|
169
|
+
])
|
|
170
|
+
);
|
|
171
|
+
return conflicts.length ? { ok: false, conflicts } : { ok: true, document: result };
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// src/domains/document/join/action.ts
|
|
175
|
+
var formatErrorMessage = (conflicts) => {
|
|
176
|
+
return conflicts.map((conflict) => {
|
|
177
|
+
if (conflict.type === "asyncapi")
|
|
178
|
+
return `AsyncAPI conflict at ${conflict.path}`;
|
|
179
|
+
if (conflict.type === "component") {
|
|
180
|
+
return `Component '/${conflict.componentType}/${conflict.name}' has conflicts`;
|
|
181
|
+
}
|
|
182
|
+
if (conflict.type === "path") {
|
|
183
|
+
return `Path '${conflict.path} ${conflict.method}' has conflicts`;
|
|
184
|
+
}
|
|
185
|
+
return `Webhook '${conflict.path} ${conflict.method}' has conflicts`;
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
async function joinAction(rawInput, rawOpt) {
|
|
189
|
+
const { error, data: input } = external_exports.array(external_exports.string()).safeParse(rawInput);
|
|
190
|
+
if (error) {
|
|
191
|
+
return output.error().title("Invalid input").message(error.issues[0].message).exit("error");
|
|
192
|
+
}
|
|
193
|
+
const { error: optsError, data: opts } = external_exports.object({
|
|
194
|
+
output: external_exports.string(),
|
|
195
|
+
prefixComponentsWithPathValue: external_exports.string().optional()
|
|
196
|
+
}).safeParse(rawOpt);
|
|
197
|
+
if (optsError) {
|
|
198
|
+
return output.error().title("Invalid options").line("").line(
|
|
199
|
+
optsError.issues.map((e) => `${e.message} property: '${e.path}'`).join("\n")
|
|
200
|
+
).line("").exit("error");
|
|
201
|
+
}
|
|
202
|
+
const files = (await Promise.all(input.map((file) => fs.readFile(file, "utf-8")))).map((it) => {
|
|
203
|
+
const document = safeNormalize(it);
|
|
204
|
+
if (!isDocument(document)) {
|
|
205
|
+
return output.error().title("Invalid input").message(
|
|
206
|
+
"Could not read an API document from one of the input files. Please provide valid JSON or YAML files."
|
|
207
|
+
).exit("error");
|
|
208
|
+
}
|
|
209
|
+
return document;
|
|
210
|
+
});
|
|
211
|
+
const asyncApiCount = files.filter(isAsyncApiDocument).length;
|
|
212
|
+
if (asyncApiCount > 0 && asyncApiCount !== files.length) {
|
|
213
|
+
return output.error().title("Cannot join OpenAPI and AsyncAPI documents together").exit("error");
|
|
214
|
+
}
|
|
215
|
+
const specification = asyncApiCount ? "AsyncAPI" : "OpenAPI";
|
|
216
|
+
const documents = asyncApiCount ? await Promise.all(
|
|
217
|
+
input.map(async (file) => {
|
|
218
|
+
const document = await bundle(path.resolve(file), {
|
|
219
|
+
plugins: [readFiles(), fetchUrls()],
|
|
220
|
+
treeShake: false
|
|
221
|
+
});
|
|
222
|
+
if (!isDocument(document)) {
|
|
223
|
+
return output.error().title("Invalid input").message(
|
|
224
|
+
"Could not read an API document from one of the input files. Please provide valid JSON or YAML files."
|
|
225
|
+
).exit("error");
|
|
226
|
+
}
|
|
227
|
+
return document;
|
|
228
|
+
})
|
|
229
|
+
) : files;
|
|
230
|
+
const prefixes = opts.prefixComponentsWithPathValue ? getPrefixes(files, opts.prefixComponentsWithPathValue) : [];
|
|
231
|
+
const { executionTimeMs, result } = await measureTime(
|
|
232
|
+
async () => asyncApiCount ? joinAsyncApi(documents, prefixes) : await join(files, { prefixComponents: prefixes })
|
|
233
|
+
);
|
|
234
|
+
if (!result.ok) {
|
|
235
|
+
return output.error().title(`Failed to join ${specification} documents`).line().line(`Conflicts:
|
|
236
|
+
${formatErrorMessage(result.conflicts).join("\n")}`).line().exit("error");
|
|
237
|
+
}
|
|
238
|
+
const isYaml = isYamlFileName(opts.output);
|
|
239
|
+
await fs.writeFile(
|
|
240
|
+
opts.output,
|
|
241
|
+
isYaml ? import_yaml.default.stringify(result.document) : JSON.stringify(result.document, null, 2),
|
|
242
|
+
"utf8"
|
|
243
|
+
);
|
|
244
|
+
output.info().message(
|
|
245
|
+
`${as.green(`\u{1F91D} ${specification} Documents joined`)} in ${as.white(`${as.bold(`${Math.round(executionTimeMs)}`)} ms`)}`
|
|
246
|
+
).print();
|
|
247
|
+
}
|
|
248
|
+
export {
|
|
249
|
+
joinAction
|
|
250
|
+
};
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
apiService
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-UB3XGOUW.js";
|
|
5
|
+
import "./chunk-FQVVKQPU.js";
|
|
6
|
+
import "./chunk-B2MHTD3R.js";
|
|
7
|
+
import "./chunk-3BWGTPPT.js";
|
|
8
|
+
import "./chunk-M622VXRQ.js";
|
|
9
|
+
import "./chunk-CIFOFSZ3.js";
|
|
10
|
+
import "./chunk-NIXG4KDE.js";
|
|
11
|
+
import "./chunk-JV7TUEXQ.js";
|
|
12
|
+
import "./chunk-VNYE4R7N.js";
|
|
13
|
+
import "./chunk-OQKDBLOZ.js";
|
|
14
|
+
import "./chunk-K74E42RV.js";
|
|
15
|
+
import "./chunk-MNLXYOVF.js";
|
|
16
|
+
import "./chunk-CX7ZRMTC.js";
|
|
17
|
+
import "./chunk-4ORL4MST.js";
|
|
17
18
|
import {
|
|
18
19
|
output
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-T5HJUAWB.js";
|
|
21
|
+
import "./chunk-LQN4S62O.js";
|
|
22
|
+
import "./chunk-IKT5F47M.js";
|
|
20
23
|
import "./chunk-3MZYUBJ6.js";
|
|
21
24
|
|
|
22
25
|
// src/domains/registry/update/action.ts
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
getUserTeams
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6ZMT63IV.js";
|
|
5
5
|
import {
|
|
6
6
|
getDatabaseClient
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-RPVHJMQT.js";
|
|
8
|
+
import "./chunk-B2MHTD3R.js";
|
|
9
9
|
import {
|
|
10
10
|
getAuthData
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-IX7LJ3AD.js";
|
|
11
|
+
} from "./chunk-NIXG4KDE.js";
|
|
12
|
+
import "./chunk-JV7TUEXQ.js";
|
|
13
|
+
import "./chunk-VNYE4R7N.js";
|
|
14
|
+
import "./chunk-OQKDBLOZ.js";
|
|
15
|
+
import "./chunk-4ORL4MST.js";
|
|
17
16
|
import {
|
|
18
17
|
output,
|
|
19
18
|
printTable
|
|
20
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-T5HJUAWB.js";
|
|
20
|
+
import "./chunk-IKT5F47M.js";
|
|
21
21
|
import "./chunk-3MZYUBJ6.js";
|
|
22
22
|
|
|
23
23
|
// src/domains/team/list/action.ts
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
apiService
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-UB3XGOUW.js";
|
|
5
|
+
import "./chunk-FQVVKQPU.js";
|
|
6
|
+
import "./chunk-B2MHTD3R.js";
|
|
7
|
+
import "./chunk-3BWGTPPT.js";
|
|
8
|
+
import "./chunk-M622VXRQ.js";
|
|
9
|
+
import "./chunk-CIFOFSZ3.js";
|
|
10
|
+
import "./chunk-NIXG4KDE.js";
|
|
11
|
+
import "./chunk-JV7TUEXQ.js";
|
|
12
|
+
import "./chunk-VNYE4R7N.js";
|
|
13
|
+
import "./chunk-OQKDBLOZ.js";
|
|
14
|
+
import "./chunk-K74E42RV.js";
|
|
15
|
+
import "./chunk-MNLXYOVF.js";
|
|
16
|
+
import "./chunk-CX7ZRMTC.js";
|
|
17
|
+
import "./chunk-4ORL4MST.js";
|
|
17
18
|
import {
|
|
18
19
|
output
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-T5HJUAWB.js";
|
|
21
|
+
import "./chunk-LQN4S62O.js";
|
|
22
|
+
import "./chunk-IKT5F47M.js";
|
|
20
23
|
import "./chunk-3MZYUBJ6.js";
|
|
21
24
|
|
|
22
25
|
// src/domains/project/create/action.ts
|