@scalar/cli 2.7.1 → 2.10.0
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 +475 -80
- package/chunks/action-4GZI2M5B.js +62 -0
- package/chunks/action-4W5GUGEG.js +63 -0
- package/chunks/{action-HJYZCPUN.js → action-5LF4XYHX.js} +10 -7
- package/chunks/{action-SRBN7N3R.js → action-5N3P43MD.js} +17 -12
- package/chunks/{action-RBOLLIGX.js → action-5RL4NWUZ.js} +17 -17
- package/chunks/{action-SNPOOW6S.js → action-657A4K2D.js} +16 -16
- package/chunks/{action-EOAVVL52.js → action-7XOHYWYM.js} +11 -14
- package/chunks/{action-AQRPFQKI.js → action-CABLS46Q.js} +9 -7
- package/chunks/{action-F7A2K74G.js → action-CB55NWAU.js} +9 -13
- package/chunks/{action-5SK5NE7E.js → action-DKDRAIKV.js} +11 -14
- package/chunks/{action-7PEQXDWT.js → action-DTEO4YNX.js} +127 -20
- package/chunks/{action-BAQYJ6UE.js → action-EAUTQ77U.js} +27 -23
- package/chunks/{action-QYGOPSTY.js → action-FBRY5JKU.js} +16 -16
- package/chunks/{action-VOFDW3U2.js → action-GFLRD7LO.js} +6 -5
- package/chunks/{action-LPVITMWA.js → action-GWYYTUTM.js} +4 -3
- package/chunks/{action-4NGK5XMD.js → action-HT42NUUX.js} +29 -24
- package/chunks/action-JEYDBB3P.js +147 -0
- package/chunks/{action-E4YSRFGT.js → action-KDUFU7TZ.js} +11 -13
- package/chunks/{action-BRSSC2SR.js → action-LYCNT3KA.js} +29 -10
- package/chunks/{action-CA4QYPI6.js → action-OJ2NK25F.js} +4 -8
- package/chunks/{action-NVI5DWFP.js → action-PAM2EZ22.js} +4 -8
- package/chunks/action-PPTFYZWD.js +1552 -0
- package/chunks/{action-OX2566BE.js → action-R4PGILN4.js} +30 -26
- package/chunks/{action-CPLH2CQ5.js → action-TOBU74JH.js} +23 -19
- package/chunks/action-U2L5DCFG.js +91 -0
- package/chunks/{action-H6OUJWWM.js → action-UUL6SWV4.js} +11 -14
- package/chunks/{action-T5XMJXPO.js → action-X7BA7PQQ.js} +10 -8
- package/chunks/{action-LVDU6YOI.js → action-XLE37MZL.js} +16 -16
- package/chunks/{action-BOZNBCNZ.js → action-XOADBXSX.js} +16 -12
- package/chunks/{action-SCOXTCPR.js → action-YSVTZVKV.js} +38 -19
- package/chunks/{action-YRX6SN5F.js → action-ZFI77WA5.js} +8 -6
- package/chunks/{action-ATGZOWSH.js → action-ZKA3RR3S.js} +15 -11
- package/chunks/actions-3SAMH7A5.js +182 -0
- package/chunks/{agent-ASPV3R5U.js → agent-2ESZI7NO.js} +7 -5
- package/chunks/{asyncapi-H4FU6GPC.js → asyncapi-4HGVM3PR.js} +14 -10
- package/chunks/{build.action-6V6GXI3X.js → build.action-VBGFGACM.js} +21 -19
- package/chunks/chunk-35Z7VTJT.js +453 -0
- package/chunks/chunk-36LXIJIZ.js +52 -0
- package/chunks/{chunk-BIKOD3SG.js → chunk-43WALAW3.js} +251 -103
- package/chunks/{chunk-C2KAWRIX.js → chunk-5ENKYZA4.js} +1 -1
- package/chunks/{chunk-ZJVYOZFB.js → chunk-5SMP756H.js} +2 -2
- package/chunks/{chunk-5JLVQVKO.js → chunk-6M7TL2G2.js} +146 -148
- package/chunks/chunk-6PSYZO3U.js +24 -0
- package/chunks/{chunk-ISXH6Q7I.js → chunk-ATNTXKMS.js} +45 -274
- package/chunks/{chunk-BDEPNGTO.js → chunk-BIMLCGKS.js} +1 -1
- package/chunks/{chunk-HGOD6THU.js → chunk-CWVYOXXM.js} +2 -19
- package/chunks/chunk-DFOZG7ZV.js +15 -0
- package/chunks/chunk-DHZW7Q7U.js +133 -0
- package/chunks/{chunk-R5LK6VPY.js → chunk-G4HRW2FZ.js} +13 -20
- package/chunks/{chunk-KCCFN4F7.js → chunk-GLWTVLKM.js} +29 -29
- package/chunks/{chunk-5UHLAJQD.js → chunk-GYRQPDTK.js} +24 -10
- package/chunks/chunk-H467HDVV.js +24 -0
- package/chunks/chunk-IPZP3VRA.js +327 -0
- package/chunks/{chunk-LG7IFACX.js → chunk-JXGF5EHC.js} +152 -18
- package/chunks/chunk-K2HIB5BA.js +92 -0
- package/chunks/{chunk-FDC2IESH.js → chunk-KHF2QXBG.js} +1352 -8327
- package/chunks/{chunk-IMG35UXX.js → chunk-KZNRQVMY.js} +1 -1
- package/chunks/{chunk-OJ2EWIJH.js → chunk-MC4EMNOR.js} +5 -1
- package/chunks/{chunk-YILQODZF.js → chunk-MMWSCTDB.js} +7 -4
- package/chunks/{chunk-6XWCMJDB.js → chunk-MNNGUUKJ.js} +12 -11
- package/chunks/chunk-NAC63XJF.js +10 -0
- package/chunks/{chunk-XXSQUBXS.js → chunk-UDBSV3CK.js} +107 -453
- package/chunks/{chunk-IKT5F47M.js → chunk-VVRUSQCY.js} +11 -11
- package/chunks/{chunk-2PPRO2QB.js → chunk-VYFGRLVQ.js} +1 -1
- package/chunks/{chunk-GPNB7ISG.js → chunk-WB6PWTMU.js} +5 -13
- package/chunks/{chunk-4X47MN6Q.js → chunk-WDIWLXLV.js} +3 -15
- package/chunks/{chunk-6YPQGVF4.js → chunk-WIEXQUTD.js} +1 -1
- package/chunks/{chunk-W24BETFG.js → chunk-XAGJJNQW.js} +3 -3
- package/chunks/{chunk-2DSVF5AD.js → chunk-ZGNDXPLU.js} +3 -3
- package/chunks/{chunk-XEDGMZJD.js → chunk-ZGVZU6L2.js} +81 -25
- package/chunks/{chunk-QXQZVEDC.js → chunk-ZKJPLWRJ.js} +2 -2
- package/chunks/{chunk-MLSZVVTT.js → chunk-ZYBLQ5CT.js} +13 -7
- package/chunks/{create.action-P6DLCK4W.js → create.action-DBNIS665.js} +21 -19
- package/chunks/{delete.action-HJKRRHE2.js → delete.action-GBOZC45K.js} +21 -19
- package/chunks/{delete.action-Z3GAA4ZN.js → delete.action-K7BLK7DK.js} +21 -19
- package/chunks/{get.action-IT4EHAV4.js → get.action-N3JOY3OU.js} +17 -12
- package/chunks/get.action-QHKMYZBK.js +91 -0
- package/chunks/{list.action-WLIAO5UW.js → list.action-6SSO3JVN.js} +45 -15
- package/chunks/{list.action-2FU5UZNH.js → list.action-TJCS6UEY.js} +41 -21
- package/chunks/{publish.action-T4J4DRXR.js → publish.action-T24VHRMR.js} +29 -24
- package/chunks/query-WKATAJJ6.js +129 -0
- package/chunks/scripts-VIBLGKYG.js +102 -0
- package/chunks/{update.action-3OVS3HWC.js → update.action-OGYNBXRU.js} +24 -19
- package/chunks/{update.action-MY7QPSSU.js → update.action-VOE6PH5F.js} +24 -19
- package/docs.html +1363 -320
- package/index.js +417 -174
- package/package.json +14 -13
- package/skills/scalar-cli/SKILL.md +13 -1
- package/template.md +157 -15
- package/chunks/action-JAHFRYWZ.js +0 -423
- package/chunks/action-N7BA5I3E.js +0 -229
- package/chunks/chunk-CWCETP6H.js +0 -610
- package/chunks/chunk-K74E42RV.js +0 -7311
|
@@ -2,38 +2,38 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
|
|
|
2
2
|
import {
|
|
3
3
|
measureTime
|
|
4
4
|
} from "./chunk-KHDYYVYF.js";
|
|
5
|
+
import {
|
|
6
|
+
isDocument
|
|
7
|
+
} from "./chunk-CWVYOXXM.js";
|
|
5
8
|
import {
|
|
6
9
|
isAsyncApiDocument,
|
|
7
|
-
isDocument,
|
|
8
10
|
safeNormalize
|
|
9
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-H467HDVV.js";
|
|
10
12
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
err,
|
|
14
|
+
ok
|
|
15
|
+
} from "./chunk-5ENKYZA4.js";
|
|
16
|
+
import "./chunk-GLWTVLKM.js";
|
|
15
17
|
import {
|
|
16
18
|
isYamlFileName
|
|
17
19
|
} from "./chunk-4ORL4MST.js";
|
|
20
|
+
import "./chunk-MNNGUUKJ.js";
|
|
18
21
|
import {
|
|
19
22
|
output
|
|
20
23
|
} from "./chunk-T5HJUAWB.js";
|
|
21
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-ZGVZU6L2.js";
|
|
22
25
|
import {
|
|
23
26
|
external_exports
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import
|
|
26
|
-
__toESM
|
|
27
|
-
} from "./chunk-3MZYUBJ6.js";
|
|
27
|
+
} from "./chunk-VVRUSQCY.js";
|
|
28
|
+
import "./chunk-3MZYUBJ6.js";
|
|
28
29
|
|
|
29
30
|
// src/domains/document/join/action.ts
|
|
30
|
-
var import_yaml = __toESM(require_dist(), 1);
|
|
31
31
|
import fs from "node:fs/promises";
|
|
32
32
|
import path from "node:path";
|
|
33
33
|
import as from "ansis";
|
|
34
|
-
import
|
|
34
|
+
import YAML from "yaml";
|
|
35
|
+
import { bundle as bundle2 } from "@scalar/json-magic/bundle";
|
|
35
36
|
import { fetchUrls, readFiles } from "@scalar/json-magic/bundle/plugins/node";
|
|
36
|
-
import { join } from "@scalar/openapi-parser";
|
|
37
37
|
|
|
38
38
|
// src/domains/document/join/helpers.ts
|
|
39
39
|
import { getValueByPath as getValueByPathWithContext } from "@scalar/json-magic/helpers/get-value-by-path";
|
|
@@ -171,6 +171,111 @@ var joinAsyncApi = (inputs, prefixes) => {
|
|
|
171
171
|
return conflicts.length ? { ok: false, conflicts } : { ok: true, document: result };
|
|
172
172
|
};
|
|
173
173
|
|
|
174
|
+
// ../../node_modules/.pnpm/@scalar+helpers@0.16.1/node_modules/@scalar/helpers/dist/object/prevent-pollution.js
|
|
175
|
+
var PROTOTYPE_POLLUTION_KEYS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
176
|
+
var isPollutionKey = (key) => PROTOTYPE_POLLUTION_KEYS.has(key);
|
|
177
|
+
|
|
178
|
+
// src/domains/document/join/openapi.ts
|
|
179
|
+
import { bundle } from "@scalar/json-magic/bundle";
|
|
180
|
+
import { join } from "@scalar/json-magic/join";
|
|
181
|
+
import { upgrade as upgrade2 } from "@scalar/openapi-upgrader";
|
|
182
|
+
var omitEmptySection = (value) => {
|
|
183
|
+
if (Array.isArray(value)) return value.length ? value : void 0;
|
|
184
|
+
if (isDocument(value)) return Object.keys(value).length ? value : void 0;
|
|
185
|
+
return value ?? void 0;
|
|
186
|
+
};
|
|
187
|
+
var prefixComponents = async (document, prefix) => {
|
|
188
|
+
await bundle(document, {
|
|
189
|
+
treeShake: false,
|
|
190
|
+
urlMap: false,
|
|
191
|
+
plugins: [
|
|
192
|
+
{
|
|
193
|
+
type: "lifecycle",
|
|
194
|
+
onBeforeNodeProcess: (node) => {
|
|
195
|
+
const ref = node.$ref;
|
|
196
|
+
if (typeof ref !== "string" || !ref.startsWith("#/components/"))
|
|
197
|
+
return;
|
|
198
|
+
const parts = ref.split("/");
|
|
199
|
+
if (parts.length < 4) return;
|
|
200
|
+
parts[3] = `${prefix}${parts[3]}`;
|
|
201
|
+
node.$ref = parts.join("/");
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
type: "lifecycle",
|
|
206
|
+
onBeforeNodeProcess: (node, context) => {
|
|
207
|
+
if (context.path.length !== 2 || context.path[0] !== "components")
|
|
208
|
+
return;
|
|
209
|
+
for (const key of Object.keys(node)) {
|
|
210
|
+
const value = node[key];
|
|
211
|
+
delete node[key];
|
|
212
|
+
const name = `${prefix}${key}`;
|
|
213
|
+
if (!isPollutionKey(key) && !isPollutionKey(name))
|
|
214
|
+
node[name] = value;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
var joinOpenApi = async (inputs, prefixes) => {
|
|
222
|
+
const documents = await Promise.all(
|
|
223
|
+
inputs.map(async (input, index) => {
|
|
224
|
+
const document = upgrade2(structuredClone(input), "3.1");
|
|
225
|
+
await prefixComponents(document, prefixes[index] ?? "");
|
|
226
|
+
return {
|
|
227
|
+
...document,
|
|
228
|
+
info: isDocument(document.info) ? document.info : {},
|
|
229
|
+
paths: document.paths ?? {},
|
|
230
|
+
webhooks: document.webhooks ?? {},
|
|
231
|
+
components: document.components ?? {},
|
|
232
|
+
tags: document.tags ?? [],
|
|
233
|
+
servers: document.servers ?? []
|
|
234
|
+
};
|
|
235
|
+
})
|
|
236
|
+
);
|
|
237
|
+
const result = join(documents.reverse(), {
|
|
238
|
+
strategy: ({ path: path2, current }) => {
|
|
239
|
+
const [field] = path2;
|
|
240
|
+
if (isPollutionKey(path2.at(-1) ?? "") && (field === "info" || field === "components" || path2.length === 2))
|
|
241
|
+
return "skip";
|
|
242
|
+
if (field === "info") return "merge-by-index";
|
|
243
|
+
if (field === "tags") return { uniqueBy: "name" };
|
|
244
|
+
if (field === "servers") return { uniqueBy: "url" };
|
|
245
|
+
if (field === "paths" || field === "webhooks" || field === "components") {
|
|
246
|
+
if (path2.length < 3) return "merge";
|
|
247
|
+
return field === "components" && !current ? "replace" : "conflict";
|
|
248
|
+
}
|
|
249
|
+
return "replace";
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
if (!result.ok) {
|
|
253
|
+
const conflicts = [];
|
|
254
|
+
for (const field of ["paths", "webhooks", "components"]) {
|
|
255
|
+
for (const { path: path2 } of result.conflicts) {
|
|
256
|
+
if (path2[0] !== field) continue;
|
|
257
|
+
conflicts.push(
|
|
258
|
+
field === "components" ? { type: "component", componentType: path2[1], name: path2[2] } : {
|
|
259
|
+
type: field === "paths" ? "path" : "webhook",
|
|
260
|
+
path: path2[1],
|
|
261
|
+
method: path2[2]
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return err(conflicts);
|
|
267
|
+
}
|
|
268
|
+
return ok({
|
|
269
|
+
...result.document,
|
|
270
|
+
info: result.document.info ?? {},
|
|
271
|
+
paths: result.document.paths ?? {},
|
|
272
|
+
webhooks: omitEmptySection(result.document.webhooks),
|
|
273
|
+
tags: omitEmptySection(result.document.tags),
|
|
274
|
+
servers: omitEmptySection(result.document.servers),
|
|
275
|
+
components: omitEmptySection(result.document.components)
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
|
|
174
279
|
// src/domains/document/join/action.ts
|
|
175
280
|
var formatErrorMessage = (conflicts) => {
|
|
176
281
|
return conflicts.map((conflict) => {
|
|
@@ -215,7 +320,7 @@ async function joinAction(rawInput, rawOpt) {
|
|
|
215
320
|
const specification = asyncApiCount ? "AsyncAPI" : "OpenAPI";
|
|
216
321
|
const documents = asyncApiCount ? await Promise.all(
|
|
217
322
|
input.map(async (file) => {
|
|
218
|
-
const document = await
|
|
323
|
+
const document = await bundle2(path.resolve(file), {
|
|
219
324
|
plugins: [readFiles(), fetchUrls()],
|
|
220
325
|
treeShake: false
|
|
221
326
|
});
|
|
@@ -228,17 +333,19 @@ async function joinAction(rawInput, rawOpt) {
|
|
|
228
333
|
})
|
|
229
334
|
) : files;
|
|
230
335
|
const prefixes = opts.prefixComponentsWithPathValue ? getPrefixes(files, opts.prefixComponentsWithPathValue) : [];
|
|
231
|
-
const { executionTimeMs, result } = await measureTime(
|
|
232
|
-
|
|
233
|
-
|
|
336
|
+
const { executionTimeMs, result } = await measureTime(async () => {
|
|
337
|
+
if (!asyncApiCount) return joinOpenApi(files, prefixes);
|
|
338
|
+
const joined = joinAsyncApi(documents, prefixes);
|
|
339
|
+
return joined.ok ? ok(joined.document) : err(joined.conflicts);
|
|
340
|
+
});
|
|
234
341
|
if (!result.ok) {
|
|
235
342
|
return output.error().title(`Failed to join ${specification} documents`).line().line(`Conflicts:
|
|
236
|
-
${formatErrorMessage(result.
|
|
343
|
+
${formatErrorMessage(result.error).join("\n")}`).line().exit("error");
|
|
237
344
|
}
|
|
238
345
|
const isYaml = isYamlFileName(opts.output);
|
|
239
346
|
await fs.writeFile(
|
|
240
347
|
opts.output,
|
|
241
|
-
isYaml ?
|
|
348
|
+
isYaml ? YAML.stringify(result.data) : JSON.stringify(result.data, null, 2),
|
|
242
349
|
"utf8"
|
|
243
350
|
);
|
|
244
351
|
output.info().message(
|
|
@@ -1,48 +1,50 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
getProjectDeployments
|
|
4
|
-
} from "./chunk-2DSVF5AD.js";
|
|
5
2
|
import {
|
|
6
3
|
getPublishDeploymentUrl
|
|
7
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KZNRQVMY.js";
|
|
5
|
+
import {
|
|
6
|
+
getProjectDeployments
|
|
7
|
+
} from "./chunk-ZGNDXPLU.js";
|
|
8
8
|
import {
|
|
9
9
|
resolveProject
|
|
10
10
|
} from "./chunk-TSURUX4A.js";
|
|
11
11
|
import {
|
|
12
12
|
formatAbsoluteTime
|
|
13
13
|
} from "./chunk-AEFPCC4U.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-MMWSCTDB.js";
|
|
15
|
+
import "./chunk-JXGF5EHC.js";
|
|
16
|
+
import "./chunk-WDIWLXLV.js";
|
|
15
17
|
import {
|
|
16
18
|
apiService
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
19
|
+
} from "./chunk-ATNTXKMS.js";
|
|
20
|
+
import "./chunk-43WALAW3.js";
|
|
21
|
+
import "./chunk-ZYBLQ5CT.js";
|
|
22
|
+
import "./chunk-KHF2QXBG.js";
|
|
23
|
+
import "./chunk-IPZP3VRA.js";
|
|
24
|
+
import "./chunk-5ENKYZA4.js";
|
|
25
|
+
import "./chunk-G4HRW2FZ.js";
|
|
26
|
+
import "./chunk-36LXIJIZ.js";
|
|
25
27
|
import {
|
|
26
28
|
getAuthData
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
30
|
-
import "./chunk-
|
|
29
|
+
} from "./chunk-35Z7VTJT.js";
|
|
30
|
+
import "./chunk-WB6PWTMU.js";
|
|
31
|
+
import "./chunk-DHZW7Q7U.js";
|
|
32
|
+
import "./chunk-GYRQPDTK.js";
|
|
33
|
+
import "./chunk-6M7TL2G2.js";
|
|
31
34
|
import {
|
|
32
35
|
requireInteractive
|
|
33
36
|
} from "./chunk-EGOXR5FB.js";
|
|
34
|
-
import "./chunk-
|
|
35
|
-
import "./chunk-KCCFN4F7.js";
|
|
36
|
-
import "./chunk-6XWCMJDB.js";
|
|
37
|
+
import "./chunk-GLWTVLKM.js";
|
|
37
38
|
import "./chunk-4ORL4MST.js";
|
|
39
|
+
import "./chunk-MNNGUUKJ.js";
|
|
38
40
|
import {
|
|
39
41
|
output
|
|
40
42
|
} from "./chunk-T5HJUAWB.js";
|
|
41
|
-
import "./chunk-
|
|
43
|
+
import "./chunk-ZGVZU6L2.js";
|
|
42
44
|
import {
|
|
43
45
|
external_exports,
|
|
44
46
|
slugSchema
|
|
45
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-VVRUSQCY.js";
|
|
46
48
|
import "./chunk-3MZYUBJ6.js";
|
|
47
49
|
|
|
48
50
|
// src/domains/project/rollback/action.ts
|
|
@@ -106,7 +108,9 @@ async function rollbackAction(args) {
|
|
|
106
108
|
}
|
|
107
109
|
const { slug, to, yes } = argsParseResult.data;
|
|
108
110
|
if (!slug) {
|
|
109
|
-
return output.error().title("Invalid argument").message(
|
|
111
|
+
return output.error().title("Invalid argument").message(
|
|
112
|
+
"Slug is required. Run scalar project list to find your project slug, then pass --slug <slug>."
|
|
113
|
+
).exit("error");
|
|
110
114
|
}
|
|
111
115
|
const apiClient = await apiService();
|
|
112
116
|
const auth = await getAuthData();
|
|
@@ -1,25 +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-
|
|
17
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-ATNTXKMS.js";
|
|
5
|
+
import "./chunk-43WALAW3.js";
|
|
6
|
+
import "./chunk-ZYBLQ5CT.js";
|
|
7
|
+
import "./chunk-KHF2QXBG.js";
|
|
8
|
+
import "./chunk-IPZP3VRA.js";
|
|
9
|
+
import "./chunk-5ENKYZA4.js";
|
|
10
|
+
import "./chunk-G4HRW2FZ.js";
|
|
11
|
+
import "./chunk-35Z7VTJT.js";
|
|
12
|
+
import "./chunk-WB6PWTMU.js";
|
|
13
|
+
import "./chunk-DHZW7Q7U.js";
|
|
14
|
+
import "./chunk-GYRQPDTK.js";
|
|
15
|
+
import "./chunk-6M7TL2G2.js";
|
|
16
|
+
import "./chunk-GLWTVLKM.js";
|
|
17
|
+
import "./chunk-MNNGUUKJ.js";
|
|
18
18
|
import {
|
|
19
19
|
output
|
|
20
20
|
} from "./chunk-T5HJUAWB.js";
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-ZGVZU6L2.js";
|
|
22
|
+
import "./chunk-VVRUSQCY.js";
|
|
23
23
|
import "./chunk-3MZYUBJ6.js";
|
|
24
24
|
|
|
25
25
|
// src/domains/registry/delete/action.ts
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
getFileOrUrl
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-CWVYOXXM.js";
|
|
5
|
+
import "./chunk-H467HDVV.js";
|
|
6
|
+
import "./chunk-GLWTVLKM.js";
|
|
7
7
|
import "./chunk-4ORL4MST.js";
|
|
8
|
+
import "./chunk-MNNGUUKJ.js";
|
|
8
9
|
import {
|
|
9
10
|
output
|
|
10
11
|
} from "./chunk-T5HJUAWB.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-ZGVZU6L2.js";
|
|
13
|
+
import "./chunk-VVRUSQCY.js";
|
|
13
14
|
import "./chunk-3MZYUBJ6.js";
|
|
14
15
|
|
|
15
16
|
// src/domains/document/markdown/action.ts
|
|
@@ -4,10 +4,11 @@ import {
|
|
|
4
4
|
downloadIsolate,
|
|
5
5
|
isDiskWriteError,
|
|
6
6
|
updateIsolate
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZKJPLWRJ.js";
|
|
8
8
|
import "./chunk-3ZJYGGAA.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-VYFGRLVQ.js";
|
|
10
|
+
import "./chunk-WB6PWTMU.js";
|
|
11
|
+
import "./chunk-DHZW7Q7U.js";
|
|
11
12
|
import "./chunk-T5HJUAWB.js";
|
|
12
13
|
import "./chunk-3MZYUBJ6.js";
|
|
13
14
|
export {
|
|
@@ -2,62 +2,67 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
|
|
|
2
2
|
import {
|
|
3
3
|
dashboardUrl,
|
|
4
4
|
registryUrl
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-5SMP756H.js";
|
|
6
6
|
import {
|
|
7
7
|
registry
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-MMWSCTDB.js";
|
|
9
9
|
import {
|
|
10
10
|
getFileOrUrl,
|
|
11
|
-
isDocument
|
|
11
|
+
isDocument
|
|
12
|
+
} from "./chunk-CWVYOXXM.js";
|
|
13
|
+
import {
|
|
12
14
|
safeNormalize
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-H467HDVV.js";
|
|
14
16
|
import {
|
|
15
17
|
DEFAULT_FETCH_CONCURRENCY
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import
|
|
18
|
-
apiService
|
|
19
|
-
} from "./chunk-ISXH6Q7I.js";
|
|
18
|
+
} from "./chunk-MC4EMNOR.js";
|
|
19
|
+
import "./chunk-DFOZG7ZV.js";
|
|
20
20
|
import {
|
|
21
21
|
BaseCollections
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-JXGF5EHC.js";
|
|
23
23
|
import {
|
|
24
24
|
getDatabaseClient
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
import "./chunk-
|
|
30
|
-
import "./chunk-
|
|
25
|
+
} from "./chunk-WDIWLXLV.js";
|
|
26
|
+
import {
|
|
27
|
+
apiService
|
|
28
|
+
} from "./chunk-ATNTXKMS.js";
|
|
29
|
+
import "./chunk-43WALAW3.js";
|
|
30
|
+
import "./chunk-ZYBLQ5CT.js";
|
|
31
|
+
import "./chunk-KHF2QXBG.js";
|
|
32
|
+
import "./chunk-IPZP3VRA.js";
|
|
33
|
+
import "./chunk-5ENKYZA4.js";
|
|
34
|
+
import "./chunk-G4HRW2FZ.js";
|
|
35
|
+
import "./chunk-36LXIJIZ.js";
|
|
31
36
|
import {
|
|
32
37
|
getAuthData
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import "./chunk-
|
|
38
|
+
} from "./chunk-35Z7VTJT.js";
|
|
39
|
+
import "./chunk-WB6PWTMU.js";
|
|
40
|
+
import "./chunk-DHZW7Q7U.js";
|
|
35
41
|
import {
|
|
36
42
|
teamSchema
|
|
37
|
-
} from "./chunk-
|
|
38
|
-
import "./chunk-
|
|
43
|
+
} from "./chunk-GYRQPDTK.js";
|
|
44
|
+
import "./chunk-6M7TL2G2.js";
|
|
39
45
|
import {
|
|
40
46
|
requireInteractive
|
|
41
47
|
} from "./chunk-EGOXR5FB.js";
|
|
42
|
-
import "./chunk-K74E42RV.js";
|
|
43
48
|
import {
|
|
44
49
|
RegistryAsset
|
|
45
|
-
} from "./chunk-
|
|
46
|
-
import "./chunk-6XWCMJDB.js";
|
|
50
|
+
} from "./chunk-GLWTVLKM.js";
|
|
47
51
|
import {
|
|
48
52
|
isUrl
|
|
49
53
|
} from "./chunk-4ORL4MST.js";
|
|
54
|
+
import "./chunk-MNNGUUKJ.js";
|
|
50
55
|
import {
|
|
51
56
|
output
|
|
52
57
|
} from "./chunk-T5HJUAWB.js";
|
|
53
|
-
import "./chunk-
|
|
58
|
+
import "./chunk-ZGVZU6L2.js";
|
|
54
59
|
import {
|
|
55
60
|
docVersionSchema,
|
|
56
61
|
external_exports,
|
|
57
62
|
namespaceSchema,
|
|
58
63
|
slugSchema,
|
|
59
64
|
toAsciiSlug
|
|
60
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-VVRUSQCY.js";
|
|
61
66
|
import "./chunk-3MZYUBJ6.js";
|
|
62
67
|
|
|
63
68
|
// src/domains/registry/publish/action.ts
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
openBrowser
|
|
4
|
+
} from "./chunk-JFIXNSPP.js";
|
|
5
|
+
import {
|
|
6
|
+
CLI_CLIENT_ID,
|
|
7
|
+
accessTokenPayloadSchema,
|
|
8
|
+
decode,
|
|
9
|
+
generateAccessByPersonalToken,
|
|
10
|
+
requestTokens,
|
|
11
|
+
setAuthData
|
|
12
|
+
} from "./chunk-35Z7VTJT.js";
|
|
13
|
+
import {
|
|
14
|
+
config
|
|
15
|
+
} from "./chunk-WB6PWTMU.js";
|
|
16
|
+
import "./chunk-DHZW7Q7U.js";
|
|
17
|
+
import "./chunk-GYRQPDTK.js";
|
|
18
|
+
import "./chunk-6M7TL2G2.js";
|
|
19
|
+
import {
|
|
20
|
+
output
|
|
21
|
+
} from "./chunk-T5HJUAWB.js";
|
|
22
|
+
import "./chunk-VVRUSQCY.js";
|
|
23
|
+
import "./chunk-3MZYUBJ6.js";
|
|
24
|
+
|
|
25
|
+
// src/domains/auth/login/action.ts
|
|
26
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
27
|
+
import { createServer } from "node:http";
|
|
28
|
+
import as2 from "ansis";
|
|
29
|
+
import getPort from "get-port";
|
|
30
|
+
|
|
31
|
+
// src/domains/auth/login/helpers/messages.ts
|
|
32
|
+
import as from "ansis";
|
|
33
|
+
function loggedInMessage(userIdentifier) {
|
|
34
|
+
if (process.env.CI || !userIdentifier)
|
|
35
|
+
return "Successfully authenticated to Scalar CLI";
|
|
36
|
+
return `Successfully authenticated to Scalar CLI as ${as.cyan(userIdentifier)}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/domains/auth/login/action.ts
|
|
40
|
+
var CALLBACK_TIMEOUT_MS = 3 * 60 * 1e3;
|
|
41
|
+
async function listenForCode(state) {
|
|
42
|
+
const preferred = await getPort({
|
|
43
|
+
port: config.auth.callback.preferredPortRange
|
|
44
|
+
});
|
|
45
|
+
const server = createServer();
|
|
46
|
+
await new Promise((resolve, reject) => {
|
|
47
|
+
server.once("error", reject);
|
|
48
|
+
server.listen({ port: preferred, host: "127.0.0.1" }, resolve);
|
|
49
|
+
});
|
|
50
|
+
const { port } = server.address();
|
|
51
|
+
const answer = new Promise((resolve, reject) => {
|
|
52
|
+
const timeout = setTimeout(() => {
|
|
53
|
+
server.close();
|
|
54
|
+
reject(new Error("Timed out waiting for the browser"));
|
|
55
|
+
}, CALLBACK_TIMEOUT_MS);
|
|
56
|
+
server.on("request", (req, res) => {
|
|
57
|
+
const url = new URL(req.url ?? "/", `http://127.0.0.1:${port}`);
|
|
58
|
+
if (url.pathname !== "/callback" || url.searchParams.get("state") !== state) {
|
|
59
|
+
res.writeHead(400).end();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
clearTimeout(timeout);
|
|
63
|
+
resolve({
|
|
64
|
+
code: url.searchParams.get("code"),
|
|
65
|
+
finish: (ok) => {
|
|
66
|
+
const page = ok ? "success" : "failure";
|
|
67
|
+
res.writeHead(302, {
|
|
68
|
+
location: `${config.projects.dashboard}/login/exchange/${page}`
|
|
69
|
+
});
|
|
70
|
+
res.end(() => server.close());
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
return { redirectUri: `http://127.0.0.1:${port}/callback`, answer };
|
|
76
|
+
}
|
|
77
|
+
async function loginAction({
|
|
78
|
+
email,
|
|
79
|
+
password,
|
|
80
|
+
token: _token
|
|
81
|
+
}) {
|
|
82
|
+
if (email || password) {
|
|
83
|
+
return output.error().title(
|
|
84
|
+
"Email and password login is no longer supported: use --token with a personal token, or `scalar auth login` without options."
|
|
85
|
+
).exit("error");
|
|
86
|
+
}
|
|
87
|
+
const token = process.env.SCALAR_API_KEY || _token;
|
|
88
|
+
if (token) {
|
|
89
|
+
try {
|
|
90
|
+
const { accessToken } = await generateAccessByPersonalToken({
|
|
91
|
+
personalToken: token
|
|
92
|
+
});
|
|
93
|
+
const { email: userEmail } = decode(accessToken, accessTokenPayloadSchema);
|
|
94
|
+
output.info().message(loggedInMessage(userEmail)).print();
|
|
95
|
+
} catch (err) {
|
|
96
|
+
return output.error().title("Invalid token").message(err.message ?? "Please provide a valid personal token").exit("error");
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const state = randomBytes(16).toString("base64url");
|
|
101
|
+
const verifier = randomBytes(32).toString("base64url");
|
|
102
|
+
let callback;
|
|
103
|
+
try {
|
|
104
|
+
callback = await listenForCode(state);
|
|
105
|
+
} catch (err) {
|
|
106
|
+
return output.error().title("Unable to start the login callback server").message(err.message).exit("error");
|
|
107
|
+
}
|
|
108
|
+
const loginUrl = new URL("/_scalar/oauth/authorize", config.auth.origin);
|
|
109
|
+
loginUrl.search = new URLSearchParams({
|
|
110
|
+
response_type: "code",
|
|
111
|
+
client_id: CLI_CLIENT_ID,
|
|
112
|
+
redirect_uri: callback.redirectUri,
|
|
113
|
+
code_challenge: createHash("sha256").update(verifier).digest("base64url"),
|
|
114
|
+
code_challenge_method: "S256",
|
|
115
|
+
state
|
|
116
|
+
}).toString();
|
|
117
|
+
output.info().message("Please follow the link to login:").print();
|
|
118
|
+
process.stdout.write(`${as2.cyan(loginUrl.href)}
|
|
119
|
+
`);
|
|
120
|
+
openBrowser(loginUrl.href);
|
|
121
|
+
try {
|
|
122
|
+
const { code, finish } = await callback.answer;
|
|
123
|
+
const tokens = code ? await requestTokens({
|
|
124
|
+
grant_type: "authorization_code",
|
|
125
|
+
code,
|
|
126
|
+
code_verifier: verifier,
|
|
127
|
+
client_id: CLI_CLIENT_ID,
|
|
128
|
+
redirect_uri: callback.redirectUri
|
|
129
|
+
}).catch(() => void 0) : void 0;
|
|
130
|
+
finish(Boolean(tokens?.refresh_token));
|
|
131
|
+
if (!tokens?.refresh_token) throw new Error("Unable to sign in");
|
|
132
|
+
await setAuthData({
|
|
133
|
+
accessToken: tokens.access_token,
|
|
134
|
+
refreshToken: tokens.refresh_token
|
|
135
|
+
});
|
|
136
|
+
const { email: userEmail } = decode(
|
|
137
|
+
tokens.access_token,
|
|
138
|
+
accessTokenPayloadSchema
|
|
139
|
+
);
|
|
140
|
+
return output.info().message(loggedInMessage(userEmail)).exit("success");
|
|
141
|
+
} catch {
|
|
142
|
+
return output.error().title("Something went wrong. Please try again.").exit("error");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
export {
|
|
146
|
+
loginAction
|
|
147
|
+
};
|
|
@@ -1,41 +1,39 @@
|
|
|
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-ZKJPLWRJ.js";
|
|
5
5
|
import "./chunk-3ZJYGGAA.js";
|
|
6
6
|
import {
|
|
7
7
|
readAndParseConfig,
|
|
8
8
|
renderConfigError
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XAGJJNQW.js";
|
|
10
10
|
import {
|
|
11
11
|
CONFIG_FILE_DEFAULT,
|
|
12
12
|
findConfig
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-UDBSV3CK.js";
|
|
14
14
|
import {
|
|
15
15
|
ISOLATE_DIR
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-VYFGRLVQ.js";
|
|
17
|
+
import "./chunk-36LXIJIZ.js";
|
|
17
18
|
import {
|
|
18
19
|
getAuthData
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-35Z7VTJT.js";
|
|
20
21
|
import {
|
|
21
22
|
config
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
23
|
+
} from "./chunk-WB6PWTMU.js";
|
|
24
|
+
import "./chunk-DHZW7Q7U.js";
|
|
25
|
+
import "./chunk-GYRQPDTK.js";
|
|
24
26
|
import {
|
|
25
27
|
ConfigVersion
|
|
26
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-6M7TL2G2.js";
|
|
27
29
|
import {
|
|
28
30
|
requireInteractive
|
|
29
31
|
} from "./chunk-EGOXR5FB.js";
|
|
30
|
-
import "./chunk-K74E42RV.js";
|
|
31
|
-
import "./chunk-KCCFN4F7.js";
|
|
32
|
-
import "./chunk-6XWCMJDB.js";
|
|
33
32
|
import "./chunk-4ORL4MST.js";
|
|
34
33
|
import {
|
|
35
34
|
output
|
|
36
35
|
} from "./chunk-T5HJUAWB.js";
|
|
37
|
-
import "./chunk-
|
|
38
|
-
import "./chunk-IKT5F47M.js";
|
|
36
|
+
import "./chunk-VVRUSQCY.js";
|
|
39
37
|
import "./chunk-3MZYUBJ6.js";
|
|
40
38
|
|
|
41
39
|
// src/domains/project/preview/action.ts
|