@scalar/cli 2.10.0 → 2.12.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 +84 -1289
- package/chunks/action-2OPUQFUY.js +164 -0
- package/chunks/{action-4GZI2M5B.js → action-36LZ6XXE.js} +19 -17
- package/chunks/{action-KDUFU7TZ.js → action-3XMTJJRT.js} +19 -16
- package/chunks/{action-R4PGILN4.js → action-6CLEENBI.js} +47 -36
- package/chunks/{action-ZFI77WA5.js → action-7HXYZPOT.js} +10 -10
- package/chunks/{action-X7BA7PQQ.js → action-AC5ENU6Z.js} +20 -18
- package/chunks/{action-PPTFYZWD.js → action-ADGLTNFC.js} +28 -22
- package/chunks/{action-7XOHYWYM.js → action-AOKHLTZ6.js} +25 -21
- package/chunks/{action-XOADBXSX.js → action-AVSJ3AJY.js} +17 -16
- package/chunks/{action-GFLRD7LO.js → action-D3IVCY24.js} +8 -8
- package/chunks/action-EBZJS367.js +130 -0
- package/chunks/{action-ZKA3RR3S.js → action-EZXHSAJ2.js} +18 -17
- package/chunks/{action-5LF4XYHX.js → action-FDTVHVHF.js} +12 -12
- package/chunks/{action-JEYDBB3P.js → action-FUO5F7NV.js} +15 -15
- package/chunks/{action-DKDRAIKV.js → action-HA3CMV3P.js} +13 -15
- package/chunks/{action-YSVTZVKV.js → action-IG3BK2LF.js} +37 -26
- package/chunks/{action-H3RTILLM.js → action-IIQMZVRJ.js} +1 -1
- package/chunks/{action-DTEO4YNX.js → action-JT6C472I.js} +13 -11
- package/chunks/{action-UUL6SWV4.js → action-KDT6H6ML.js} +12 -14
- package/chunks/{action-PAM2EZ22.js → action-KJDIJQ3A.js} +8 -7
- package/chunks/{action-HT42NUUX.js → action-NF5E7JKA.js} +40 -38
- package/chunks/{action-EAUTQ77U.js → action-NIZBME45.js} +26 -24
- package/chunks/{action-CB55NWAU.js → action-O757TFA2.js} +9 -9
- package/chunks/{action-XLE37MZL.js → action-ONR7QSN7.js} +23 -22
- package/chunks/{action-5RL4NWUZ.js → action-QM2BMMHG.js} +33 -30
- package/chunks/{action-GWYYTUTM.js → action-QVTAZCKY.js} +5 -5
- package/chunks/action-SLB52XRG.js +65 -0
- package/chunks/{action-CABLS46Q.js → action-UTFRCKGE.js} +11 -11
- package/chunks/{action-4W5GUGEG.js → action-VESBFIP3.js} +20 -19
- package/chunks/{action-657A4K2D.js → action-VGFAIFYE.js} +26 -23
- package/chunks/action-WCU5O2VT.js +100 -0
- package/chunks/{action-TOBU74JH.js → action-XS5EESHW.js} +51 -27
- package/chunks/action-XVNRZ5VX.js +38 -0
- package/chunks/action-Y7EBKCUU.js +16 -0
- package/chunks/{action-5N3P43MD.js → action-YWQ2OKS3.js} +16 -15
- package/chunks/{actions-3SAMH7A5.js → actions-6QG7LH7P.js} +23 -20
- package/chunks/{agent-2ESZI7NO.js → agent-ONXROEAE.js} +44 -9
- package/chunks/{asyncapi-4HGVM3PR.js → asyncapi-7IFXAIE3.js} +13 -12
- package/chunks/{build.action-VBGFGACM.js → build.action-FI4OWY3T.js} +28 -26
- package/chunks/{chunk-ZGNDXPLU.js → chunk-26VIHQGL.js} +3 -3
- package/chunks/{chunk-JXGF5EHC.js → chunk-3HCEUGOE.js} +42 -13
- package/chunks/{chunk-G4HRW2FZ.js → chunk-5TNKTLQP.js} +370 -254
- package/chunks/{chunk-XAGJJNQW.js → chunk-BB6WWG25.js} +10 -10
- package/chunks/{chunk-K2HIB5BA.js → chunk-BCFUMXMC.js} +3 -3
- package/chunks/{action-F2ZJNURT.js → chunk-EBNFCIKS.js} +7 -10
- package/chunks/{chunk-MC4EMNOR.js → chunk-EJSGWV2K.js} +7 -6
- package/chunks/{chunk-GYRQPDTK.js → chunk-FJCOYEKT.js} +139 -3
- package/chunks/{chunk-ZKJPLWRJ.js → chunk-HU47OMI4.js} +4 -4
- package/chunks/{chunk-VVRUSQCY.js → chunk-I57ID5K7.js} +13 -0
- package/chunks/{chunk-43WALAW3.js → chunk-JLNHOA5Z.js} +64 -115
- package/chunks/{chunk-5SMP756H.js → chunk-LCSU43NJ.js} +2 -2
- package/chunks/{chunk-KHF2QXBG.js → chunk-N645RGAB.js} +1853 -683
- package/chunks/{chunk-3ZJYGGAA.js → chunk-ORCUZITN.js} +1 -1
- package/chunks/{chunk-H467HDVV.js → chunk-PERC34BV.js} +1 -1
- package/chunks/chunk-Q26DFKTY.js +37 -0
- package/chunks/{chunk-MMWSCTDB.js → chunk-QJQTSRU4.js} +19 -19
- package/chunks/{chunk-WDIWLXLV.js → chunk-RLBS4HJT.js} +3 -3
- package/chunks/{chunk-ATNTXKMS.js → chunk-RNZVZMYC.js} +198 -42
- package/chunks/{chunk-IPZP3VRA.js → chunk-RYWXF3LO.js} +12 -21
- package/chunks/{chunk-CWVYOXXM.js → chunk-SNOAL2C5.js} +11 -7
- package/chunks/{chunk-UDBSV3CK.js → chunk-T3R66THO.js} +6085 -4167
- package/chunks/{chunk-VYFGRLVQ.js → chunk-U73OW57G.js} +1 -1
- package/chunks/chunk-U764PQUA.js +1034 -0
- package/chunks/{chunk-KZNRQVMY.js → chunk-UAFCSWQ6.js} +1 -1
- package/chunks/{chunk-WB6PWTMU.js → chunk-UBLFIMUA.js} +1 -1
- package/chunks/{chunk-WIEXQUTD.js → chunk-UODTHS76.js} +1 -1
- package/chunks/chunk-V3MYP5SQ.js +247 -0
- package/chunks/{chunk-36LXIJIZ.js → chunk-V6LUKXBV.js} +1 -16
- package/chunks/{chunk-6M7TL2G2.js → chunk-VRZSDUZK.js} +45 -5
- package/chunks/{chunk-GLWTVLKM.js → chunk-VUNOOPEG.js} +9 -2
- package/chunks/chunk-VUXPDHTQ.js +22 -0
- package/chunks/{chunk-DHZW7Q7U.js → chunk-VVQOFG76.js} +2 -4
- package/chunks/chunk-XP5UM7SF.js +21 -0
- package/chunks/{chunk-ZYBLQ5CT.js → chunk-Y6C3H27E.js} +9 -4
- package/chunks/{chunk-35Z7VTJT.js → chunk-YTFFBGNQ.js} +52 -38
- package/chunks/{chunk-BIMLCGKS.js → chunk-ZNLMQKDU.js} +1 -1
- package/chunks/{create.action-DBNIS665.js → create.action-PPMZEMZL.js} +34 -32
- package/chunks/{delete.action-GBOZC45K.js → delete.action-GDOHATRZ.js} +30 -28
- package/chunks/{delete.action-K7BLK7DK.js → delete.action-VAHKEHEU.js} +29 -27
- package/chunks/{get.action-QHKMYZBK.js → get.action-UXFTGO7W.js} +24 -20
- package/chunks/{get.action-N3JOY3OU.js → get.action-XON3EZDT.js} +16 -15
- package/chunks/{list.action-TJCS6UEY.js → list.action-24F5WDGR.js} +37 -26
- package/chunks/{list.action-6SSO3JVN.js → list.action-OQEAEJ5U.js} +39 -29
- package/chunks/{publish.action-T24VHRMR.js → publish.action-G7FPDRBZ.js} +45 -43
- package/chunks/{scripts-VIBLGKYG.js → scripts-6CI6U32J.js} +1 -1
- package/chunks/{update.action-VOE6PH5F.js → update.action-IFIFXZWA.js} +29 -27
- package/chunks/{update.action-OGYNBXRU.js → update.action-MJDHVVR3.js} +30 -28
- package/index.js +290 -284
- package/package.json +2 -2
- package/skills/scalar-cli/SKILL.md +49 -49
- package/template.md +68 -252
- package/chunks/action-FBRY5JKU.js +0 -37
- package/chunks/action-LYCNT3KA.js +0 -73
- package/chunks/action-OJ2NK25F.js +0 -121
- package/chunks/action-U2L5DCFG.js +0 -91
- package/chunks/chunk-MNNGUUKJ.js +0 -405
- package/chunks/chunk-ZGVZU6L2.js +0 -422
- package/docs.html +0 -6977
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
config
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UBLFIMUA.js";
|
|
5
5
|
import {
|
|
6
6
|
roleSchema
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-FJCOYEKT.js";
|
|
8
8
|
import {
|
|
9
9
|
output
|
|
10
10
|
} from "./chunk-T5HJUAWB.js";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
emailSchema,
|
|
13
13
|
external_exports,
|
|
14
14
|
zod_default
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-I57ID5K7.js";
|
|
16
16
|
|
|
17
17
|
// ../../packages/entities/dist/token/token.js
|
|
18
18
|
var accessTokenPayloadSchema = external_exports.object({
|
|
@@ -44,16 +44,6 @@ var personalTokenPayloadSchema = external_exports.object({
|
|
|
44
44
|
iat: external_exports.number(),
|
|
45
45
|
exp: external_exports.number()
|
|
46
46
|
}).meta({ id: "personal-token-payload" });
|
|
47
|
-
var docsAgentTokenSchema = external_exports.object({
|
|
48
|
-
uid: external_exports.string(),
|
|
49
|
-
publishUid: external_exports.string(),
|
|
50
|
-
projectUid: external_exports.string(),
|
|
51
|
-
teamUid: external_exports.string(),
|
|
52
|
-
mcpServerId: external_exports.string(),
|
|
53
|
-
mcpInstallationId: external_exports.string(),
|
|
54
|
-
iat: external_exports.number(),
|
|
55
|
-
exp: external_exports.number()
|
|
56
|
-
}).meta({ id: "docs-agent-token" });
|
|
57
47
|
|
|
58
48
|
// ../../packages/entities/dist/token/payload.js
|
|
59
49
|
var tokenResponseSchema = external_exports.object({
|
|
@@ -226,7 +216,10 @@ var setMetadata = async (metadata) => {
|
|
|
226
216
|
const currentMetadata = await getMetadata();
|
|
227
217
|
const updatedMetadata = { ...currentMetadata, ...metadata };
|
|
228
218
|
const tmpPath = `${METADATA_FILE_PATH}.${process.pid}.tmp`;
|
|
229
|
-
await fs.writeFile(tmpPath, JSON.stringify(updatedMetadata)
|
|
219
|
+
await fs.writeFile(tmpPath, JSON.stringify(updatedMetadata), {
|
|
220
|
+
mode: 384
|
|
221
|
+
});
|
|
222
|
+
await fs.chmod(tmpPath, 384);
|
|
230
223
|
await fs.rename(tmpPath, METADATA_FILE_PATH);
|
|
231
224
|
metadataCache = {
|
|
232
225
|
mtimeMs: await getMetadataMtimeMs(),
|
|
@@ -301,13 +294,16 @@ var consumerClaimsSchema = external_exports.object({
|
|
|
301
294
|
teamUid: external_exports.string().min(1),
|
|
302
295
|
/**
|
|
303
296
|
* What the reader was admitted to: one docs project, registry record or
|
|
304
|
-
* MCP
|
|
305
|
-
* host and so an audience, and access is granted to each on its
|
|
306
|
-
* resource server checks this against what is being read.
|
|
297
|
+
* MCP server environment, or the namespace's own pages. Several of these
|
|
298
|
+
* share a host and so an audience, and access is granted to each on its
|
|
299
|
+
* own, so a resource server checks this against what is being read.
|
|
307
300
|
*/
|
|
308
301
|
res: external_exports.object({
|
|
309
302
|
kind: external_exports.enum(["project", "registry", "mcp", "namespace"]),
|
|
310
|
-
uid
|
|
303
|
+
/** For `mcp`, the server uid; an installation uuid when `environment` is absent. */
|
|
304
|
+
uid: external_exports.string().min(1).optional(),
|
|
305
|
+
/** For `mcp`, the environment slug of the server named by `uid`. */
|
|
306
|
+
environment: external_exports.string().min(1).optional()
|
|
311
307
|
}),
|
|
312
308
|
/** How the person proved the address */
|
|
313
309
|
via: external_exports.enum(["email", "google", "microsoft", "sso", "scalar"]),
|
|
@@ -342,6 +338,17 @@ function isAccessToken(token) {
|
|
|
342
338
|
}
|
|
343
339
|
|
|
344
340
|
// src/helpers/auth.ts
|
|
341
|
+
var claimsOf = (accessToken) => {
|
|
342
|
+
const { email, role, teamUid } = decode3(accessToken, accessTokenPayloadSchema);
|
|
343
|
+
return { email, role, teamUid };
|
|
344
|
+
};
|
|
345
|
+
var claimsIfReadable = (accessToken) => {
|
|
346
|
+
try {
|
|
347
|
+
return claimsOf(accessToken);
|
|
348
|
+
} catch {
|
|
349
|
+
return {};
|
|
350
|
+
}
|
|
351
|
+
};
|
|
345
352
|
var eventListeners = [];
|
|
346
353
|
var addEventListener = (callback) => {
|
|
347
354
|
eventListeners.push(callback);
|
|
@@ -349,35 +356,37 @@ var addEventListener = (callback) => {
|
|
|
349
356
|
var fireCallbacks = (auth) => eventListeners.forEach((callback) => callback(auth));
|
|
350
357
|
var setAuthData = async (authData) => {
|
|
351
358
|
await setMetadata({ auth: authData });
|
|
352
|
-
fireCallbacks(authData);
|
|
359
|
+
fireCallbacks({ ...authData, ...claimsIfReadable(authData.accessToken) });
|
|
353
360
|
};
|
|
361
|
+
var RENEWAL_MARGIN_MS = 6e4;
|
|
362
|
+
var SESSION_EXPIRED = "Your session has expired. Run `scalar auth login` to log in again.";
|
|
363
|
+
var SESSION_MOVED = "Your session moved to another team while this command ran. Run it again.";
|
|
364
|
+
var needsRenewal = (accessToken, marginMs = 0) => {
|
|
365
|
+
if (!isAccessToken(accessToken)) return true;
|
|
366
|
+
try {
|
|
367
|
+
const { exp } = decode3(accessToken, accessTokenPayloadSchema);
|
|
368
|
+
return exp * 1e3 - marginMs < Date.now();
|
|
369
|
+
} catch {
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
var renewAuth = async (auth) => "refreshToken" in auth ? refreshToken(auth.refreshToken) : generateAccessByPersonalToken({ personalToken: auth.personalToken });
|
|
354
374
|
var getAuthData = async (opts) => {
|
|
355
375
|
const { noExit } = opts ?? {};
|
|
356
376
|
const { auth } = await getMetadata();
|
|
357
377
|
if (!auth) {
|
|
358
|
-
if (noExit) throw new Error("
|
|
359
|
-
return output.error().title("
|
|
378
|
+
if (noExit) throw new Error("Authentication required");
|
|
379
|
+
return output.error().title("Authentication required").message("Run `scalar auth login` before running this command.").exit("error");
|
|
360
380
|
}
|
|
361
|
-
|
|
362
|
-
auth.accessToken,
|
|
363
|
-
accessTokenPayloadSchema
|
|
364
|
-
);
|
|
365
|
-
const isExpired = exp * 1e3 < Date.now() || !isAccessToken(auth.accessToken);
|
|
366
|
-
if (!isExpired) {
|
|
367
|
-
return { ...auth, email, role, teamUid, addEventListener };
|
|
381
|
+
if (!needsRenewal(auth.accessToken)) {
|
|
382
|
+
return { ...auth, ...claimsOf(auth.accessToken), addEventListener };
|
|
368
383
|
}
|
|
369
384
|
try {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
return { ...updatedAuth2, email, role, teamUid, addEventListener };
|
|
373
|
-
}
|
|
374
|
-
const updatedAuth = await generateAccessByPersonalToken({
|
|
375
|
-
personalToken: auth.personalToken
|
|
376
|
-
});
|
|
377
|
-
return { ...updatedAuth, email, role, teamUid, addEventListener };
|
|
385
|
+
const renewed = await renewAuth(auth);
|
|
386
|
+
return { ...renewed, ...claimsOf(renewed.accessToken), addEventListener };
|
|
378
387
|
} catch {
|
|
379
|
-
if (noExit) throw new Error(
|
|
380
|
-
return output.error().title("
|
|
388
|
+
if (noExit) throw new Error(SESSION_EXPIRED);
|
|
389
|
+
return output.error().title("Session expired").message(SESSION_EXPIRED).exit("error");
|
|
381
390
|
}
|
|
382
391
|
};
|
|
383
392
|
var clearAuthData = async () => {
|
|
@@ -444,6 +453,11 @@ export {
|
|
|
444
453
|
setMetadata,
|
|
445
454
|
getMetadata,
|
|
446
455
|
setAuthData,
|
|
456
|
+
RENEWAL_MARGIN_MS,
|
|
457
|
+
SESSION_EXPIRED,
|
|
458
|
+
SESSION_MOVED,
|
|
459
|
+
needsRenewal,
|
|
460
|
+
renewAuth,
|
|
447
461
|
getAuthData,
|
|
448
462
|
CLI_CLIENT_ID,
|
|
449
463
|
requestTokens,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
registryUrl
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LCSU43NJ.js";
|
|
5
5
|
|
|
6
6
|
// src/domains/registry/helpers/fetch.ts
|
|
7
7
|
async function fetchFromRegistry(path, accessToken) {
|
|
@@ -1,48 +1,50 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
BaseCollections
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3HCEUGOE.js";
|
|
5
5
|
import {
|
|
6
6
|
getDatabaseClient
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-RLBS4HJT.js";
|
|
8
8
|
import {
|
|
9
9
|
apiService
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-RNZVZMYC.js";
|
|
11
|
+
import "./chunk-N645RGAB.js";
|
|
12
|
+
import "./chunk-JLNHOA5Z.js";
|
|
13
|
+
import "./chunk-Y6C3H27E.js";
|
|
14
|
+
import "./chunk-5ENKYZA4.js";
|
|
14
15
|
import {
|
|
15
16
|
SdkLanguage
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-RYWXF3LO.js";
|
|
18
|
+
import "./chunk-5TNKTLQP.js";
|
|
19
|
+
import "./chunk-V3MYP5SQ.js";
|
|
20
|
+
import "./chunk-V6LUKXBV.js";
|
|
21
|
+
import "./chunk-VUXPDHTQ.js";
|
|
20
22
|
import {
|
|
21
23
|
getAuthData
|
|
22
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-YTFFBGNQ.js";
|
|
23
25
|
import {
|
|
24
26
|
config
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
+
} from "./chunk-UBLFIMUA.js";
|
|
28
|
+
import "./chunk-VVQOFG76.js";
|
|
27
29
|
import {
|
|
28
30
|
teamSchema
|
|
29
|
-
} from "./chunk-
|
|
30
|
-
import "./chunk-
|
|
31
|
+
} from "./chunk-FJCOYEKT.js";
|
|
32
|
+
import "./chunk-VRZSDUZK.js";
|
|
31
33
|
import {
|
|
32
34
|
requireInteractive
|
|
33
35
|
} from "./chunk-EGOXR5FB.js";
|
|
34
|
-
import "./chunk-GLWTVLKM.js";
|
|
35
36
|
import "./chunk-4ORL4MST.js";
|
|
36
|
-
import "./chunk-
|
|
37
|
+
import "./chunk-VUNOOPEG.js";
|
|
37
38
|
import {
|
|
38
39
|
output
|
|
39
40
|
} from "./chunk-T5HJUAWB.js";
|
|
40
|
-
import "./chunk-
|
|
41
|
+
import "./chunk-U764PQUA.js";
|
|
42
|
+
import "./chunk-Q26DFKTY.js";
|
|
41
43
|
import {
|
|
42
44
|
external_exports,
|
|
43
45
|
namespaceSchema,
|
|
44
46
|
slugSchema
|
|
45
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-I57ID5K7.js";
|
|
46
48
|
import "./chunk-3MZYUBJ6.js";
|
|
47
49
|
|
|
48
50
|
// src/domains/sdk/create.action.ts
|
|
@@ -61,13 +63,13 @@ async function createAction(opts) {
|
|
|
61
63
|
const db = await getDatabaseClient();
|
|
62
64
|
const client = await apiService();
|
|
63
65
|
if (!data.language) {
|
|
64
|
-
requireInteractive("
|
|
66
|
+
requireInteractive("Provide --language.");
|
|
65
67
|
}
|
|
66
68
|
const language = opts.language || await text({
|
|
67
|
-
message: "
|
|
69
|
+
message: "Select the SDK language",
|
|
68
70
|
placeholder: "typescript",
|
|
69
71
|
validate: (v) => {
|
|
70
|
-
return external_exports.enum(SdkLanguage).safeParse(v)?.error ? "
|
|
72
|
+
return external_exports.enum(SdkLanguage).safeParse(v)?.error ? "Select a supported SDK language." : void 0;
|
|
71
73
|
},
|
|
72
74
|
defaultValue: void 0
|
|
73
75
|
});
|
|
@@ -79,43 +81,43 @@ async function createAction(opts) {
|
|
|
79
81
|
schema: teamSchema
|
|
80
82
|
});
|
|
81
83
|
if (team.error)
|
|
82
|
-
return output.error().title("
|
|
84
|
+
return output.error().title("Could not load the current team").message(team.message).exit("error");
|
|
83
85
|
const namespace = data.namespace || team.data.namespaces.at(0);
|
|
84
86
|
if (!namespace) {
|
|
85
87
|
return output.error().title("Missing namespace").message(
|
|
86
|
-
"
|
|
88
|
+
"No team namespace is selected. Pass --namespace <namespace> or run `scalar team get` to see available namespaces."
|
|
87
89
|
).exit("error");
|
|
88
90
|
}
|
|
89
91
|
const namespaceApisRes = await client.managedDocs.getApiDocs(namespace);
|
|
90
92
|
if (namespaceApisRes.error)
|
|
91
93
|
return output.error().title(namespaceApisRes.message).exit("error");
|
|
92
94
|
if (data.api && !namespaceApisRes.data.some((api) => api.slug === data.api)) {
|
|
93
|
-
return output.error().title("
|
|
95
|
+
return output.error().title("API description not found").message("Provide a valid API slug.").exit("error");
|
|
94
96
|
}
|
|
95
97
|
if (!data.api) {
|
|
96
|
-
requireInteractive("
|
|
98
|
+
requireInteractive("Provide --api.");
|
|
97
99
|
}
|
|
98
100
|
const apiUid = namespaceApisRes.data.find((api) => api.slug === data.api)?.uid || await select({
|
|
99
|
-
message: "
|
|
101
|
+
message: "Select an API",
|
|
100
102
|
options: namespaceApisRes.data.map((api) => ({
|
|
101
103
|
value: api.uid,
|
|
102
104
|
label: api.slug
|
|
103
105
|
}))
|
|
104
106
|
});
|
|
105
107
|
if (!apiUid) {
|
|
106
|
-
return output.error().title("
|
|
108
|
+
return output.error().title("API description not found").message("Provide a valid API slug.").exit("error");
|
|
107
109
|
}
|
|
108
|
-
const logger = output.info().loader("Creating
|
|
110
|
+
const logger = output.info().loader("Creating SDK\u2026");
|
|
109
111
|
const response = await client.sdks.create({
|
|
110
112
|
apiUid,
|
|
111
113
|
languages: [language]
|
|
112
114
|
});
|
|
113
115
|
if (response.error) {
|
|
114
|
-
return output.error().title("
|
|
116
|
+
return output.error().title("Could not create the SDK").message(response.message).exit("error");
|
|
115
117
|
}
|
|
116
|
-
logger.update("loader", 0, { content: "SDK created
|
|
118
|
+
logger.update("loader", 0, { content: "SDK created." });
|
|
117
119
|
const dashboardUrl = `${config.projects.dashboard}/sdk/${response.data}`;
|
|
118
|
-
logger.message(`View your SDK in the Scalar
|
|
120
|
+
logger.message(`View your SDK in the Scalar Dashboard: ${as.cyan(dashboardUrl)}`).exit("success");
|
|
119
121
|
}
|
|
120
122
|
export {
|
|
121
123
|
createAction
|
|
@@ -1,46 +1,48 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
BaseCollections
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3HCEUGOE.js";
|
|
5
5
|
import {
|
|
6
6
|
getDatabaseClient
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-RLBS4HJT.js";
|
|
8
8
|
import {
|
|
9
9
|
apiService
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-RNZVZMYC.js";
|
|
11
|
+
import "./chunk-N645RGAB.js";
|
|
12
|
+
import "./chunk-JLNHOA5Z.js";
|
|
13
|
+
import "./chunk-Y6C3H27E.js";
|
|
14
|
+
import "./chunk-5ENKYZA4.js";
|
|
14
15
|
import {
|
|
15
16
|
sdkSchema
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-RYWXF3LO.js";
|
|
18
|
+
import "./chunk-5TNKTLQP.js";
|
|
19
|
+
import "./chunk-V3MYP5SQ.js";
|
|
20
|
+
import "./chunk-V6LUKXBV.js";
|
|
21
|
+
import "./chunk-VUXPDHTQ.js";
|
|
20
22
|
import {
|
|
21
23
|
getAuthData
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-YTFFBGNQ.js";
|
|
25
|
+
import "./chunk-UBLFIMUA.js";
|
|
26
|
+
import "./chunk-VVQOFG76.js";
|
|
25
27
|
import {
|
|
26
28
|
teamSchema
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import "./chunk-
|
|
29
|
+
} from "./chunk-FJCOYEKT.js";
|
|
30
|
+
import "./chunk-VRZSDUZK.js";
|
|
29
31
|
import {
|
|
30
32
|
requireInteractive
|
|
31
33
|
} from "./chunk-EGOXR5FB.js";
|
|
32
|
-
import "./chunk-GLWTVLKM.js";
|
|
33
34
|
import "./chunk-4ORL4MST.js";
|
|
34
|
-
import "./chunk-
|
|
35
|
+
import "./chunk-VUNOOPEG.js";
|
|
35
36
|
import {
|
|
36
37
|
output
|
|
37
38
|
} from "./chunk-T5HJUAWB.js";
|
|
38
|
-
import "./chunk-
|
|
39
|
+
import "./chunk-U764PQUA.js";
|
|
40
|
+
import "./chunk-Q26DFKTY.js";
|
|
39
41
|
import {
|
|
40
42
|
external_exports,
|
|
41
43
|
namespaceSchema,
|
|
42
44
|
slugSchema
|
|
43
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-I57ID5K7.js";
|
|
44
46
|
import "./chunk-3MZYUBJ6.js";
|
|
45
47
|
|
|
46
48
|
// src/domains/sdk/delete.action.ts
|
|
@@ -64,11 +66,11 @@ async function deleteAction(opts) {
|
|
|
64
66
|
schema: teamSchema
|
|
65
67
|
});
|
|
66
68
|
if (team.error)
|
|
67
|
-
return output.error().title("
|
|
69
|
+
return output.error().title("Could not load the current team").message(team.message).exit("error");
|
|
68
70
|
const namespace = data.namespace || team.data.namespaces.at(0);
|
|
69
71
|
if (!namespace) {
|
|
70
72
|
return output.error().title("Missing namespace").message(
|
|
71
|
-
"
|
|
73
|
+
"No team namespace is selected. Pass --namespace <namespace> or run `scalar team get` to see available namespaces."
|
|
72
74
|
).exit("error");
|
|
73
75
|
}
|
|
74
76
|
const sdks = await db.getMany({
|
|
@@ -80,27 +82,27 @@ async function deleteAction(opts) {
|
|
|
80
82
|
});
|
|
81
83
|
if (sdks.error) return output.error().title(sdks.message).exit("error");
|
|
82
84
|
if (data.slug && !sdks.data.some((sdk) => sdk.slug === data.slug)) {
|
|
83
|
-
return output.error().title("
|
|
85
|
+
return output.error().title("SDK not found").message("Provide a valid SDK slug.").exit("error");
|
|
84
86
|
}
|
|
85
87
|
if (!data.slug) {
|
|
86
|
-
requireInteractive("
|
|
88
|
+
requireInteractive("Provide --slug.");
|
|
87
89
|
}
|
|
88
90
|
const sdkUid = sdks.data.find((sdk) => sdk.slug === data.slug)?.uid || await select({
|
|
89
|
-
message: "
|
|
91
|
+
message: "Select an SDK to delete",
|
|
90
92
|
options: sdks.data.map((sdk) => ({
|
|
91
93
|
value: sdk.uid,
|
|
92
94
|
label: sdk.slug
|
|
93
95
|
}))
|
|
94
96
|
});
|
|
95
97
|
if (!sdkUid) {
|
|
96
|
-
return output.error().title("
|
|
98
|
+
return output.error().title("SDK not found").message("Provide a valid SDK slug.").exit("error");
|
|
97
99
|
}
|
|
98
|
-
const logger = output.info().loader("Deleting
|
|
100
|
+
const logger = output.info().loader("Deleting SDK\u2026");
|
|
99
101
|
const response = await client.sdks.delete(sdkUid);
|
|
100
102
|
if (response.error) {
|
|
101
|
-
return output.error().title("
|
|
103
|
+
return output.error().title("Could not delete the SDK").message(response.message).exit("error");
|
|
102
104
|
}
|
|
103
|
-
logger.update("loader", 0, { content: "SDK deleted
|
|
105
|
+
logger.update("loader", 0, { content: "SDK deleted." }).exit("success");
|
|
104
106
|
}
|
|
105
107
|
export {
|
|
106
108
|
deleteAction
|
|
@@ -1,44 +1,46 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
BaseCollections
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3HCEUGOE.js";
|
|
5
5
|
import {
|
|
6
6
|
getDatabaseClient
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-RLBS4HJT.js";
|
|
8
8
|
import {
|
|
9
9
|
apiService
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-IPZP3VRA.js";
|
|
10
|
+
} from "./chunk-RNZVZMYC.js";
|
|
11
|
+
import "./chunk-N645RGAB.js";
|
|
12
|
+
import "./chunk-JLNHOA5Z.js";
|
|
13
|
+
import "./chunk-Y6C3H27E.js";
|
|
15
14
|
import "./chunk-5ENKYZA4.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-RYWXF3LO.js";
|
|
16
|
+
import "./chunk-5TNKTLQP.js";
|
|
17
|
+
import "./chunk-V3MYP5SQ.js";
|
|
18
|
+
import "./chunk-V6LUKXBV.js";
|
|
19
|
+
import "./chunk-VUXPDHTQ.js";
|
|
18
20
|
import {
|
|
19
21
|
getAuthData
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-YTFFBGNQ.js";
|
|
23
|
+
import "./chunk-UBLFIMUA.js";
|
|
24
|
+
import "./chunk-VVQOFG76.js";
|
|
23
25
|
import {
|
|
24
26
|
teamSchema
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
+
} from "./chunk-FJCOYEKT.js";
|
|
28
|
+
import "./chunk-VRZSDUZK.js";
|
|
27
29
|
import {
|
|
28
30
|
requireInteractive
|
|
29
31
|
} from "./chunk-EGOXR5FB.js";
|
|
30
|
-
import "./chunk-GLWTVLKM.js";
|
|
31
32
|
import "./chunk-4ORL4MST.js";
|
|
32
|
-
import "./chunk-
|
|
33
|
+
import "./chunk-VUNOOPEG.js";
|
|
33
34
|
import {
|
|
34
35
|
output
|
|
35
36
|
} from "./chunk-T5HJUAWB.js";
|
|
36
|
-
import "./chunk-
|
|
37
|
+
import "./chunk-U764PQUA.js";
|
|
38
|
+
import "./chunk-Q26DFKTY.js";
|
|
37
39
|
import {
|
|
38
40
|
external_exports,
|
|
39
41
|
namespaceSchema,
|
|
40
42
|
slugSchema
|
|
41
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-I57ID5K7.js";
|
|
42
44
|
import "./chunk-3MZYUBJ6.js";
|
|
43
45
|
|
|
44
46
|
// src/domains/schema/delete.action.ts
|
|
@@ -62,37 +64,37 @@ async function deleteAction(opts) {
|
|
|
62
64
|
schema: teamSchema
|
|
63
65
|
});
|
|
64
66
|
if (team.error)
|
|
65
|
-
return output.error().title("
|
|
67
|
+
return output.error().title("Could not load the current team").message(team.message).exit("error");
|
|
66
68
|
const namespace = data.namespace || team.data.namespaces.at(0);
|
|
67
69
|
if (!namespace) {
|
|
68
70
|
return output.error().title("Missing namespace").message(
|
|
69
|
-
"
|
|
71
|
+
"No team namespace is selected. Pass --namespace <namespace> or run `scalar team get` to see available namespaces."
|
|
70
72
|
).exit("error");
|
|
71
73
|
}
|
|
72
74
|
const schemas = await client.managedSchemas.getSchemas(namespace);
|
|
73
75
|
if (schemas.error) return output.error().title(schemas.message).exit("error");
|
|
74
76
|
if (data.slug && !schemas.data.some((schema) => schema.slug === data.slug)) {
|
|
75
|
-
return output.error().title("
|
|
77
|
+
return output.error().title("Schema not found").message("Provide a valid schema slug.").exit("error");
|
|
76
78
|
}
|
|
77
79
|
if (!data.slug) {
|
|
78
|
-
requireInteractive("
|
|
80
|
+
requireInteractive("Provide --slug.");
|
|
79
81
|
}
|
|
80
82
|
const schemaSlug = schemas.data.find((schema) => schema.slug === data.slug)?.slug || await select({
|
|
81
|
-
message: "
|
|
83
|
+
message: "Select a schema to delete",
|
|
82
84
|
options: schemas.data.map((schema) => ({
|
|
83
85
|
value: schema.slug,
|
|
84
86
|
label: schema.slug
|
|
85
87
|
}))
|
|
86
88
|
});
|
|
87
89
|
if (!schemaSlug) {
|
|
88
|
-
return output.error().title("
|
|
90
|
+
return output.error().title("Schema not found").message("Provide a valid schema slug.").exit("error");
|
|
89
91
|
}
|
|
90
|
-
const logger = output.info().loader("Deleting
|
|
92
|
+
const logger = output.info().loader("Deleting schema\u2026");
|
|
91
93
|
const response = await client.managedSchemas.delete(namespace, schemaSlug);
|
|
92
94
|
if (response.error) {
|
|
93
|
-
return output.error().title("
|
|
95
|
+
return output.error().title("Could not delete the schema").message(response.message).exit("error");
|
|
94
96
|
}
|
|
95
|
-
logger.update("loader", 0, { content: "Schema deleted
|
|
97
|
+
logger.update("loader", 0, { content: "Schema deleted." }).exit("success");
|
|
96
98
|
}
|
|
97
99
|
export {
|
|
98
100
|
deleteAction
|
|
@@ -1,43 +1,45 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
inspectSdk
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BCFUMXMC.js";
|
|
5
5
|
import {
|
|
6
6
|
BaseCollections
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3HCEUGOE.js";
|
|
8
8
|
import {
|
|
9
9
|
getDatabaseClient
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-RLBS4HJT.js";
|
|
11
|
+
import "./chunk-N645RGAB.js";
|
|
12
|
+
import "./chunk-JLNHOA5Z.js";
|
|
13
|
+
import "./chunk-Y6C3H27E.js";
|
|
14
|
+
import "./chunk-5ENKYZA4.js";
|
|
14
15
|
import {
|
|
15
16
|
sdkBuildSchema,
|
|
16
17
|
sdkSchema
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-RYWXF3LO.js";
|
|
19
|
+
import "./chunk-V3MYP5SQ.js";
|
|
20
|
+
import "./chunk-V6LUKXBV.js";
|
|
21
|
+
import "./chunk-VUXPDHTQ.js";
|
|
20
22
|
import {
|
|
21
23
|
getAuthData
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-YTFFBGNQ.js";
|
|
25
|
+
import "./chunk-UBLFIMUA.js";
|
|
26
|
+
import "./chunk-VVQOFG76.js";
|
|
25
27
|
import {
|
|
26
28
|
teamSchema
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-GLWTVLKM.js";
|
|
29
|
+
} from "./chunk-FJCOYEKT.js";
|
|
30
|
+
import "./chunk-VRZSDUZK.js";
|
|
30
31
|
import "./chunk-4ORL4MST.js";
|
|
31
|
-
import "./chunk-
|
|
32
|
+
import "./chunk-VUNOOPEG.js";
|
|
32
33
|
import {
|
|
33
34
|
output
|
|
34
35
|
} from "./chunk-T5HJUAWB.js";
|
|
35
|
-
import "./chunk-
|
|
36
|
+
import "./chunk-U764PQUA.js";
|
|
37
|
+
import "./chunk-Q26DFKTY.js";
|
|
36
38
|
import {
|
|
37
39
|
external_exports,
|
|
38
40
|
namespaceSchema,
|
|
39
41
|
slugSchema
|
|
40
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-I57ID5K7.js";
|
|
41
43
|
import "./chunk-3MZYUBJ6.js";
|
|
42
44
|
|
|
43
45
|
// src/domains/sdk/get.action.ts
|
|
@@ -53,10 +55,12 @@ async function getAction(args) {
|
|
|
53
55
|
schema: teamSchema
|
|
54
56
|
});
|
|
55
57
|
if (team.error)
|
|
56
|
-
return output.error().title("
|
|
58
|
+
return output.error().title("Could not load the current team").message(team.message).exit("error");
|
|
57
59
|
const namespace = result.data.namespace || team.data.namespaces.at(0);
|
|
58
60
|
if (!namespace)
|
|
59
|
-
return output.error().title("Missing namespace").message(
|
|
61
|
+
return output.error().title("Missing namespace").message(
|
|
62
|
+
"Pass --namespace <namespace>. Run `scalar team get` to see available namespaces."
|
|
63
|
+
).exit("error");
|
|
60
64
|
const sdk = await client.getOne({
|
|
61
65
|
collectionPath: BaseCollections.Sdks(team.data.uid),
|
|
62
66
|
query: { namespace, slug: result.data.slug },
|