@scalar/cli 2.0.1 → 2.1.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 +40 -0
- package/chunks/action-45OGQB2M.js +138 -0
- package/chunks/action-5R5FDF6S.js +2097 -0
- package/chunks/action-ANU5HGC4.js +34 -0
- package/chunks/action-BMFXENMX.js +176 -0
- package/chunks/action-BNEGJBUH.js +38 -0
- package/chunks/action-BYZUBXVB.js +82 -0
- package/chunks/action-C5VB4ITT.js +132 -0
- package/chunks/action-CCW66QJN.js +72 -0
- package/chunks/action-CLSD7O2R.js +60 -0
- package/chunks/action-CQ56FVES.js +65 -0
- package/chunks/action-CYP4VDK3.js +148 -0
- package/chunks/action-DFKHSDFV.js +36 -0
- package/chunks/action-F4Y6Q2VB.js +92 -0
- package/chunks/action-GB6DM53B.js +70 -0
- package/chunks/action-GEBRPNRT.js +87 -0
- package/chunks/action-H5OHT2GV.js +56 -0
- package/chunks/action-HD2T6BFJ.js +54 -0
- package/chunks/action-HNKM3Q65.js +65 -0
- package/chunks/action-JOSVV6YA.js +71 -0
- package/chunks/action-MENXFJH3.js +204 -0
- package/chunks/action-P7LN6FGY.js +13 -0
- package/chunks/action-PVDDRIM6.js +130 -0
- package/chunks/action-Q5UJ32D6.js +46 -0
- package/chunks/action-R6ZZO26F.js +299 -0
- package/chunks/action-STIEAXOE.js +53 -0
- package/chunks/action-TPBKPHNS.js +110 -0
- package/chunks/action-TWFJNQ2R.js +95 -0
- package/chunks/action-TZ5KGAQT.js +64 -0
- package/chunks/action-UDZUUJSI.js +49 -0
- package/chunks/action-W5BATF4Q.js +197 -0
- package/chunks/agent-XGLOHXNA.js +112 -0
- package/chunks/build.action-LKOILPA6.js +108 -0
- package/chunks/chunk-23I5PKZZ.js +78 -0
- package/chunks/chunk-2BSG2QHO.js +455 -0
- package/chunks/chunk-3MZYUBJ6.js +49 -0
- package/chunks/chunk-47Y4L5IT.js +63361 -0
- package/chunks/chunk-4DGQIAJX.js +359 -0
- package/chunks/chunk-4QS7SJTG.js +138 -0
- package/chunks/chunk-5BISXQX4.js +447 -0
- package/chunks/chunk-5BPPGTUU.js +463 -0
- package/chunks/chunk-AEFPCC4U.js +16 -0
- package/chunks/chunk-AHWWJ3MD.js +32 -0
- package/chunks/chunk-ASMHW5AY.js +19 -0
- package/chunks/chunk-B6QZJWCQ.js +92 -0
- package/chunks/chunk-DOVIWNKQ.js +108 -0
- package/chunks/chunk-H2WRMLYY.js +13780 -0
- package/chunks/chunk-HQKBZOYU.js +34 -0
- package/chunks/chunk-ISGLWBXZ.js +4265 -0
- package/chunks/chunk-IX7LJ3AD.js +17 -0
- package/chunks/chunk-JFIXNSPP.js +26 -0
- package/chunks/chunk-K74E42RV.js +7311 -0
- package/chunks/chunk-KHDYYVYF.js +16 -0
- package/chunks/chunk-KWOL7A6J.js +23 -0
- package/chunks/chunk-NUXPNUSS.js +38 -0
- package/chunks/chunk-OAXFCOJV.js +25 -0
- package/chunks/chunk-P2VH7DOC.js +107 -0
- package/chunks/chunk-P646T2WH.js +1608 -0
- package/chunks/chunk-SHSHFGA7.js +297 -0
- package/chunks/chunk-SXYALPYK.js +2709 -0
- package/chunks/chunk-T7B6WNZC.js +18 -0
- package/chunks/chunk-T7MDADON.js +17 -0
- package/chunks/chunk-TLFMATXR.js +344 -0
- package/chunks/chunk-TQ5XC2E3.js +284 -0
- package/chunks/chunk-UPUTMFD4.js +465 -0
- package/chunks/chunk-VTYTPSXO.js +161 -0
- package/chunks/chunk-X4QLDBB5.js +221 -0
- package/chunks/chunk-ZTVWAKNJ.js +21 -0
- package/chunks/create.action-FFQLBSJH.js +108 -0
- package/chunks/delete.action-QNN3LC2F.js +96 -0
- package/chunks/delete.action-STHQHP4F.js +88 -0
- package/chunks/get.action-OTKYOP3Z.js +87 -0
- package/chunks/list.action-6I5EZAVB.js +95 -0
- package/chunks/list.action-KDM5RHEH.js +116 -0
- package/chunks/publish.action-PODTVRXS.js +182 -0
- package/chunks/update.action-4F6STTEQ.js +101 -0
- package/chunks/update.action-KMD4ZM75.js +95 -0
- package/docs.html +310 -209
- package/index.js +645 -99061
- package/package.json +13 -11
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
apiService
|
|
4
|
+
} from "./chunk-SXYALPYK.js";
|
|
5
|
+
import {
|
|
6
|
+
BaseCollections
|
|
7
|
+
} from "./chunk-2BSG2QHO.js";
|
|
8
|
+
import {
|
|
9
|
+
getDatabaseClient
|
|
10
|
+
} from "./chunk-SHSHFGA7.js";
|
|
11
|
+
import "./chunk-UPUTMFD4.js";
|
|
12
|
+
import "./chunk-B6QZJWCQ.js";
|
|
13
|
+
import "./chunk-5BPPGTUU.js";
|
|
14
|
+
import "./chunk-P646T2WH.js";
|
|
15
|
+
import "./chunk-4QS7SJTG.js";
|
|
16
|
+
import "./chunk-VTYTPSXO.js";
|
|
17
|
+
import {
|
|
18
|
+
getAuthData
|
|
19
|
+
} from "./chunk-5BISXQX4.js";
|
|
20
|
+
import "./chunk-OAXFCOJV.js";
|
|
21
|
+
import "./chunk-TLFMATXR.js";
|
|
22
|
+
import {
|
|
23
|
+
teamSchema
|
|
24
|
+
} from "./chunk-4DGQIAJX.js";
|
|
25
|
+
import {
|
|
26
|
+
compareVersionsDesc,
|
|
27
|
+
namespaceSchema
|
|
28
|
+
} from "./chunk-ISGLWBXZ.js";
|
|
29
|
+
import {
|
|
30
|
+
external_exports
|
|
31
|
+
} from "./chunk-H2WRMLYY.js";
|
|
32
|
+
import "./chunk-K74E42RV.js";
|
|
33
|
+
import "./chunk-IX7LJ3AD.js";
|
|
34
|
+
import {
|
|
35
|
+
output,
|
|
36
|
+
printTable
|
|
37
|
+
} from "./chunk-X4QLDBB5.js";
|
|
38
|
+
import "./chunk-3MZYUBJ6.js";
|
|
39
|
+
|
|
40
|
+
// src/domains/schema/list.action.ts
|
|
41
|
+
import as from "ansis";
|
|
42
|
+
async function listAction(args) {
|
|
43
|
+
const { error, data } = external_exports.object({
|
|
44
|
+
namespace: namespaceSchema.optional()
|
|
45
|
+
}).safeParse({
|
|
46
|
+
namespace: args.namespace
|
|
47
|
+
});
|
|
48
|
+
if (error)
|
|
49
|
+
return output.error().title("Invalid input").message(error.issues[0].message).exit("error");
|
|
50
|
+
const auth = await getAuthData();
|
|
51
|
+
auth.addEventListener((state) => Object.assign(auth, state));
|
|
52
|
+
const client = await getDatabaseClient();
|
|
53
|
+
const team = await client.getOne({
|
|
54
|
+
collectionPath: BaseCollections.Teams,
|
|
55
|
+
query: {
|
|
56
|
+
uid: auth.teamUid
|
|
57
|
+
},
|
|
58
|
+
schema: teamSchema
|
|
59
|
+
});
|
|
60
|
+
if (team.error)
|
|
61
|
+
return output.error().title("An error occurred when fetching your team.").message(team.message).exit("error");
|
|
62
|
+
const namespace = data.namespace || team.data.namespaces.at(0);
|
|
63
|
+
if (!namespace) {
|
|
64
|
+
return output.error().title("Missing namespace").message(
|
|
65
|
+
"Could not find a valid namespace for your API. Please specify a namespace or contact support."
|
|
66
|
+
).exit("error");
|
|
67
|
+
}
|
|
68
|
+
const apiClient = await apiService();
|
|
69
|
+
const schemas = await apiClient.managedSchemas.getSchemas(namespace);
|
|
70
|
+
if (schemas.error) return output.error().title(schemas.message).exit("error");
|
|
71
|
+
if (schemas.data.length === 0) {
|
|
72
|
+
output.info().title(`No schemas found for namespace "${namespace}".`).print();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
printTable(
|
|
76
|
+
[
|
|
77
|
+
{ name: "title", title: "Title", alignment: "left", maxLen: 40 },
|
|
78
|
+
{ name: "name", title: "Name", alignment: "left", color: "blue" },
|
|
79
|
+
{ name: "version", title: "Version", alignment: "left" },
|
|
80
|
+
{ name: "access", title: "Access", alignment: "left" }
|
|
81
|
+
],
|
|
82
|
+
schemas.data.map((schema) => {
|
|
83
|
+
const latestVersion = [...schema.versions].sort((a, b) => compareVersionsDesc(a.version, b.version)).at(0);
|
|
84
|
+
return {
|
|
85
|
+
title: schema.title || as.dim("\u2014"),
|
|
86
|
+
name: `@${schema.namespace}/${schema.slug}`,
|
|
87
|
+
version: latestVersion?.version ?? as.dim("\u2014"),
|
|
88
|
+
access: schema.isPrivate ? as.green("Private") : as.yellow("Public")
|
|
89
|
+
};
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
listAction
|
|
95
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
formatAbsoluteTime
|
|
4
|
+
} from "./chunk-AEFPCC4U.js";
|
|
5
|
+
import {
|
|
6
|
+
BaseCollections
|
|
7
|
+
} from "./chunk-2BSG2QHO.js";
|
|
8
|
+
import {
|
|
9
|
+
getDatabaseClient
|
|
10
|
+
} from "./chunk-SHSHFGA7.js";
|
|
11
|
+
import "./chunk-UPUTMFD4.js";
|
|
12
|
+
import "./chunk-B6QZJWCQ.js";
|
|
13
|
+
import {
|
|
14
|
+
sdkBuildSchema,
|
|
15
|
+
sdkSchema
|
|
16
|
+
} from "./chunk-5BPPGTUU.js";
|
|
17
|
+
import "./chunk-4QS7SJTG.js";
|
|
18
|
+
import "./chunk-VTYTPSXO.js";
|
|
19
|
+
import {
|
|
20
|
+
getAuthData
|
|
21
|
+
} from "./chunk-5BISXQX4.js";
|
|
22
|
+
import "./chunk-OAXFCOJV.js";
|
|
23
|
+
import "./chunk-TLFMATXR.js";
|
|
24
|
+
import {
|
|
25
|
+
teamSchema
|
|
26
|
+
} from "./chunk-4DGQIAJX.js";
|
|
27
|
+
import {
|
|
28
|
+
namespaceSchema
|
|
29
|
+
} from "./chunk-ISGLWBXZ.js";
|
|
30
|
+
import {
|
|
31
|
+
external_exports
|
|
32
|
+
} from "./chunk-H2WRMLYY.js";
|
|
33
|
+
import "./chunk-K74E42RV.js";
|
|
34
|
+
import "./chunk-IX7LJ3AD.js";
|
|
35
|
+
import {
|
|
36
|
+
output,
|
|
37
|
+
printTable
|
|
38
|
+
} from "./chunk-X4QLDBB5.js";
|
|
39
|
+
import "./chunk-3MZYUBJ6.js";
|
|
40
|
+
|
|
41
|
+
// src/domains/sdk/list.action.ts
|
|
42
|
+
import as from "ansis";
|
|
43
|
+
async function listAction(args) {
|
|
44
|
+
const { error, data } = external_exports.object({
|
|
45
|
+
namespace: namespaceSchema.optional()
|
|
46
|
+
}).safeParse({
|
|
47
|
+
namespace: args.namespace
|
|
48
|
+
});
|
|
49
|
+
if (error)
|
|
50
|
+
return output.error().title("Invalid input").message(error.issues[0].message).exit("error");
|
|
51
|
+
const auth = await getAuthData();
|
|
52
|
+
auth.addEventListener((state) => Object.assign(auth, state));
|
|
53
|
+
const client = await getDatabaseClient();
|
|
54
|
+
const team = await client.getOne({
|
|
55
|
+
collectionPath: BaseCollections.Teams,
|
|
56
|
+
query: {
|
|
57
|
+
uid: auth.teamUid
|
|
58
|
+
},
|
|
59
|
+
schema: teamSchema
|
|
60
|
+
});
|
|
61
|
+
if (team.error)
|
|
62
|
+
return output.error().title("An error occurred when fetching your team.").message(team.message).exit("error");
|
|
63
|
+
const namespace = data.namespace || team.data.namespaces.at(0);
|
|
64
|
+
if (!namespace) {
|
|
65
|
+
return output.error().title("Missing namespace").message(
|
|
66
|
+
"Could not find a valid namespace for your API. Please specify a namespace or contact support."
|
|
67
|
+
).exit("error");
|
|
68
|
+
}
|
|
69
|
+
const sdks = await client.getMany({
|
|
70
|
+
collectionPath: BaseCollections.Sdks(team.data.uid),
|
|
71
|
+
query: {
|
|
72
|
+
namespace
|
|
73
|
+
},
|
|
74
|
+
schema: sdkSchema.array()
|
|
75
|
+
});
|
|
76
|
+
if (sdks.error) return output.error().title(sdks.message).exit("error");
|
|
77
|
+
if (sdks.data.length === 0) {
|
|
78
|
+
output.info().title(`No SDKs found for namespace "${namespace}".`).print();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const builds = await client.getMany({
|
|
82
|
+
collectionPath: BaseCollections.SdkBuilds(team.data.uid),
|
|
83
|
+
query: {},
|
|
84
|
+
schema: sdkBuildSchema.array()
|
|
85
|
+
});
|
|
86
|
+
const lastBuiltAt = /* @__PURE__ */ new Map();
|
|
87
|
+
if (!builds.error) {
|
|
88
|
+
for (const build of builds.data) {
|
|
89
|
+
if (build.createdAt > (lastBuiltAt.get(build.sdk.uid) ?? 0)) {
|
|
90
|
+
lastBuiltAt.set(build.sdk.uid, build.createdAt);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
printTable(
|
|
95
|
+
[
|
|
96
|
+
{ name: "title", title: "Title", alignment: "left", maxLen: 40 },
|
|
97
|
+
{ name: "name", title: "Name", alignment: "left", color: "blue" },
|
|
98
|
+
{ name: "version", title: "Version", alignment: "left" },
|
|
99
|
+
{ name: "access", title: "Access", alignment: "left" },
|
|
100
|
+
{ name: "lastBuild", title: "Last Build", alignment: "left" }
|
|
101
|
+
],
|
|
102
|
+
sdks.data.map((sdk) => {
|
|
103
|
+
const builtAt = lastBuiltAt.get(sdk.uid);
|
|
104
|
+
return {
|
|
105
|
+
title: sdk.title || as.dim("\u2014"),
|
|
106
|
+
name: `@${sdk.namespace}/${sdk.slug}`,
|
|
107
|
+
version: sdk.currentVersion,
|
|
108
|
+
access: sdk.isPrivate ? as.green("Private") : as.yellow("Public"),
|
|
109
|
+
lastBuild: builtAt ? as.dim(formatAbsoluteTime(builtAt * 1e3)) : as.dim("Never")
|
|
110
|
+
};
|
|
111
|
+
})
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
export {
|
|
115
|
+
listAction
|
|
116
|
+
};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
dashboardUrl,
|
|
4
|
+
registryUrl
|
|
5
|
+
} from "./chunk-T7MDADON.js";
|
|
6
|
+
import {
|
|
7
|
+
registry
|
|
8
|
+
} from "./chunk-DOVIWNKQ.js";
|
|
9
|
+
import {
|
|
10
|
+
getFileOrUrl
|
|
11
|
+
} from "./chunk-23I5PKZZ.js";
|
|
12
|
+
import {
|
|
13
|
+
DEFAULT_FETCH_CONCURRENCY
|
|
14
|
+
} from "./chunk-AHWWJ3MD.js";
|
|
15
|
+
import {
|
|
16
|
+
apiService
|
|
17
|
+
} from "./chunk-SXYALPYK.js";
|
|
18
|
+
import {
|
|
19
|
+
BaseCollections
|
|
20
|
+
} from "./chunk-2BSG2QHO.js";
|
|
21
|
+
import {
|
|
22
|
+
getDatabaseClient
|
|
23
|
+
} from "./chunk-SHSHFGA7.js";
|
|
24
|
+
import "./chunk-UPUTMFD4.js";
|
|
25
|
+
import "./chunk-B6QZJWCQ.js";
|
|
26
|
+
import "./chunk-5BPPGTUU.js";
|
|
27
|
+
import "./chunk-P646T2WH.js";
|
|
28
|
+
import {
|
|
29
|
+
RegistryAsset
|
|
30
|
+
} from "./chunk-4QS7SJTG.js";
|
|
31
|
+
import "./chunk-VTYTPSXO.js";
|
|
32
|
+
import {
|
|
33
|
+
getAuthData
|
|
34
|
+
} from "./chunk-5BISXQX4.js";
|
|
35
|
+
import "./chunk-OAXFCOJV.js";
|
|
36
|
+
import "./chunk-TLFMATXR.js";
|
|
37
|
+
import {
|
|
38
|
+
teamSchema
|
|
39
|
+
} from "./chunk-4DGQIAJX.js";
|
|
40
|
+
import {
|
|
41
|
+
docVersionSchema,
|
|
42
|
+
namespaceSchema,
|
|
43
|
+
slugSchema
|
|
44
|
+
} from "./chunk-ISGLWBXZ.js";
|
|
45
|
+
import {
|
|
46
|
+
external_exports
|
|
47
|
+
} from "./chunk-H2WRMLYY.js";
|
|
48
|
+
import "./chunk-K74E42RV.js";
|
|
49
|
+
import "./chunk-IX7LJ3AD.js";
|
|
50
|
+
import {
|
|
51
|
+
output
|
|
52
|
+
} from "./chunk-X4QLDBB5.js";
|
|
53
|
+
import "./chunk-3MZYUBJ6.js";
|
|
54
|
+
|
|
55
|
+
// src/domains/schema/publish.action.ts
|
|
56
|
+
import { text } from "@clack/prompts";
|
|
57
|
+
import as from "ansis";
|
|
58
|
+
import { bundle } from "@scalar/json-magic/bundle";
|
|
59
|
+
import { fetchUrls, readFiles } from "@scalar/json-magic/bundle/plugins/node";
|
|
60
|
+
import { parseJsonOrYaml } from "@scalar/oas-utils/helpers";
|
|
61
|
+
async function publishAction(file, args) {
|
|
62
|
+
const { error, data } = external_exports.object({
|
|
63
|
+
slug: slugSchema.optional(),
|
|
64
|
+
file: external_exports.string().min(1, "Please provide a valid file path or URL for your document.").optional(),
|
|
65
|
+
title: external_exports.string().max(50).optional(),
|
|
66
|
+
namespace: namespaceSchema.optional(),
|
|
67
|
+
private: external_exports.boolean().optional(),
|
|
68
|
+
version: docVersionSchema.optional(),
|
|
69
|
+
bundle: external_exports.coerce.boolean().optional(),
|
|
70
|
+
fetchLimit: external_exports.coerce.number().optional(),
|
|
71
|
+
urlMap: external_exports.coerce.boolean().default(false),
|
|
72
|
+
treeShake: external_exports.coerce.boolean().default(false)
|
|
73
|
+
}).safeParse({
|
|
74
|
+
file,
|
|
75
|
+
title: args.title,
|
|
76
|
+
slug: args.slug,
|
|
77
|
+
namespace: args.namespace,
|
|
78
|
+
private: args.private,
|
|
79
|
+
version: args.version
|
|
80
|
+
});
|
|
81
|
+
if (error)
|
|
82
|
+
return output.error().title("Invalid input").message(error.issues[0].message).exit("error");
|
|
83
|
+
const auth = await getAuthData();
|
|
84
|
+
auth.addEventListener((state) => Object.assign(auth, state));
|
|
85
|
+
const db = await getDatabaseClient();
|
|
86
|
+
const team = await db.getOne({
|
|
87
|
+
collectionPath: BaseCollections.Teams,
|
|
88
|
+
query: {
|
|
89
|
+
uid: auth.teamUid
|
|
90
|
+
},
|
|
91
|
+
schema: teamSchema
|
|
92
|
+
});
|
|
93
|
+
if (team.error)
|
|
94
|
+
return output.error().title("An error occurred when fetching your team.").message(team.message).exit("error");
|
|
95
|
+
const namespace = data.namespace || team.data.namespaces.at(0);
|
|
96
|
+
if (!namespace) {
|
|
97
|
+
return output.error().title("Missing namespace").message(
|
|
98
|
+
"Could not find a valid namespace for your API. Please specify a namespace or contact support."
|
|
99
|
+
).exit("error");
|
|
100
|
+
}
|
|
101
|
+
const client = await apiService();
|
|
102
|
+
const namespaceSchemaRes = await client.managedSchemas.getSchemas(namespace);
|
|
103
|
+
if (namespaceSchemaRes.error)
|
|
104
|
+
return output.error().title(namespaceSchemaRes.message).exit("error");
|
|
105
|
+
const apiFile = data.file || (await text({
|
|
106
|
+
message: "Please enter a file path or URL for your document",
|
|
107
|
+
placeholder: "./api.yaml",
|
|
108
|
+
validate(value) {
|
|
109
|
+
if (value.length === 0) return "File path or URL is required!";
|
|
110
|
+
}
|
|
111
|
+
})).toString();
|
|
112
|
+
const rawDocument = await getFileOrUrl(apiFile);
|
|
113
|
+
const result = parseJsonOrYaml(rawDocument);
|
|
114
|
+
if (!rawDocument) {
|
|
115
|
+
return output.error().title("Invalid file").message("Please provide a valid file path for your document.").exit("error");
|
|
116
|
+
}
|
|
117
|
+
const slug = data.slug || (await text({
|
|
118
|
+
message: "Please provide a slug identifier for your schema",
|
|
119
|
+
validate(value) {
|
|
120
|
+
if (value.length === 0) return "Slug is required.";
|
|
121
|
+
if (slugSchema.safeParse(value)?.error)
|
|
122
|
+
return "Please enter a valid slug (e.g. my-schema)";
|
|
123
|
+
}
|
|
124
|
+
})).toString();
|
|
125
|
+
const matchingSchema = namespaceSchemaRes.data.find(
|
|
126
|
+
(schema2) => schema2.slug === slug
|
|
127
|
+
);
|
|
128
|
+
const documentTitle = result?.info?.title;
|
|
129
|
+
const providedTitle = data.title ?? documentTitle;
|
|
130
|
+
const title = matchingSchema || providedTitle ? providedTitle : (await text({
|
|
131
|
+
message: "Please provide a title for your schema",
|
|
132
|
+
validate(value) {
|
|
133
|
+
if (value.length === 0) return "Title is required.";
|
|
134
|
+
}
|
|
135
|
+
})).toString();
|
|
136
|
+
const version = data.version || (await text({
|
|
137
|
+
message: "What is the version of your document (e.g. 0.1.0)?",
|
|
138
|
+
validate(value) {
|
|
139
|
+
if (value.length === 0) return "Version is required.";
|
|
140
|
+
if (docVersionSchema.safeParse(value)?.error)
|
|
141
|
+
return "Version must be a non-empty string";
|
|
142
|
+
}
|
|
143
|
+
})).toString();
|
|
144
|
+
const logger = output.info().line().loader(`Publishing ${slug} to Scalar registry...`);
|
|
145
|
+
const bundlingPlugins = [readFiles()];
|
|
146
|
+
if (data.bundle) {
|
|
147
|
+
bundlingPlugins.push(
|
|
148
|
+
fetchUrls({
|
|
149
|
+
limit: data.fetchLimit ?? DEFAULT_FETCH_CONCURRENCY
|
|
150
|
+
})
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
const bundledDocument = await bundle(result, {
|
|
154
|
+
plugins: bundlingPlugins,
|
|
155
|
+
treeShake: data.treeShake,
|
|
156
|
+
urlMap: data.urlMap
|
|
157
|
+
});
|
|
158
|
+
const document = JSON.stringify(bundledDocument);
|
|
159
|
+
const publishRes = matchingSchema ? await client.managedSchemas.createVersion(namespace, slug, {
|
|
160
|
+
document,
|
|
161
|
+
version
|
|
162
|
+
}) : await client.managedSchemas.create(namespace, {
|
|
163
|
+
title: title || "Untitled",
|
|
164
|
+
version,
|
|
165
|
+
slug,
|
|
166
|
+
isPrivate: data.private,
|
|
167
|
+
document
|
|
168
|
+
});
|
|
169
|
+
if (publishRes.error)
|
|
170
|
+
return output.error().title(publishRes.message).exit("error");
|
|
171
|
+
const schema = registry(namespace).schemas(slug);
|
|
172
|
+
const schemaUrl = dashboardUrl(
|
|
173
|
+
RegistryAsset.Schemas,
|
|
174
|
+
matchingSchema?.uid ?? publishRes.data.uid
|
|
175
|
+
);
|
|
176
|
+
logger.update("loader", 0, {
|
|
177
|
+
content: `Successfully published v${version} for ${slug}.`
|
|
178
|
+
}).line().line(`${as.green("\u279C")} ${as.white.bold("View in dashboard:")}`).line(as.cyan(schemaUrl)).line().line(`${as.green("\u279C")} ${as.white.bold("Registry Preview:")}`).line(as.cyan(registryUrl(schema.url({ version })))).line().line(`${as.green("\u279C")} ${as.white.bold("Registry YAML:")}`).line(as.cyan(registryUrl(schema.url({ version, format: "yaml" })))).line().line(`${as.green("\u279C")} ${as.white.bold("Registry JSON:")}`).line(as.cyan(registryUrl(schema.url({ version, format: "json" })))).print();
|
|
179
|
+
}
|
|
180
|
+
export {
|
|
181
|
+
publishAction
|
|
182
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
apiService
|
|
4
|
+
} from "./chunk-SXYALPYK.js";
|
|
5
|
+
import {
|
|
6
|
+
BaseCollections
|
|
7
|
+
} from "./chunk-2BSG2QHO.js";
|
|
8
|
+
import {
|
|
9
|
+
getDatabaseClient
|
|
10
|
+
} from "./chunk-SHSHFGA7.js";
|
|
11
|
+
import "./chunk-UPUTMFD4.js";
|
|
12
|
+
import "./chunk-B6QZJWCQ.js";
|
|
13
|
+
import {
|
|
14
|
+
sdkSchema
|
|
15
|
+
} from "./chunk-5BPPGTUU.js";
|
|
16
|
+
import "./chunk-P646T2WH.js";
|
|
17
|
+
import "./chunk-4QS7SJTG.js";
|
|
18
|
+
import "./chunk-VTYTPSXO.js";
|
|
19
|
+
import {
|
|
20
|
+
getAuthData
|
|
21
|
+
} from "./chunk-5BISXQX4.js";
|
|
22
|
+
import "./chunk-OAXFCOJV.js";
|
|
23
|
+
import "./chunk-TLFMATXR.js";
|
|
24
|
+
import {
|
|
25
|
+
teamSchema
|
|
26
|
+
} from "./chunk-4DGQIAJX.js";
|
|
27
|
+
import {
|
|
28
|
+
namespaceSchema,
|
|
29
|
+
slugSchema
|
|
30
|
+
} from "./chunk-ISGLWBXZ.js";
|
|
31
|
+
import {
|
|
32
|
+
external_exports
|
|
33
|
+
} from "./chunk-H2WRMLYY.js";
|
|
34
|
+
import "./chunk-K74E42RV.js";
|
|
35
|
+
import "./chunk-IX7LJ3AD.js";
|
|
36
|
+
import {
|
|
37
|
+
output
|
|
38
|
+
} from "./chunk-X4QLDBB5.js";
|
|
39
|
+
import "./chunk-3MZYUBJ6.js";
|
|
40
|
+
|
|
41
|
+
// src/domains/sdk/update.action.ts
|
|
42
|
+
import { select } from "@clack/prompts";
|
|
43
|
+
async function updateAction(opts) {
|
|
44
|
+
const { error, data } = external_exports.object({
|
|
45
|
+
slug: slugSchema.optional(),
|
|
46
|
+
namespace: namespaceSchema.optional(),
|
|
47
|
+
title: external_exports.string().max(50).optional(),
|
|
48
|
+
isPrivate: external_exports.boolean().optional()
|
|
49
|
+
}).safeParse(opts);
|
|
50
|
+
if (error)
|
|
51
|
+
return output.error().title("Invalid input").message(error.issues[0].message).exit("error");
|
|
52
|
+
const auth = await getAuthData();
|
|
53
|
+
auth.addEventListener((state) => Object.assign(auth, state));
|
|
54
|
+
const db = await getDatabaseClient();
|
|
55
|
+
const client = await apiService();
|
|
56
|
+
const team = await db.getOne({
|
|
57
|
+
collectionPath: BaseCollections.Teams,
|
|
58
|
+
query: {
|
|
59
|
+
uid: auth.teamUid
|
|
60
|
+
},
|
|
61
|
+
schema: teamSchema
|
|
62
|
+
});
|
|
63
|
+
if (team.error)
|
|
64
|
+
return output.error().title("An error occurred when fetching your team.").message(team.message).exit("error");
|
|
65
|
+
const namespace = data.namespace || team.data.namespaces.at(0);
|
|
66
|
+
if (!namespace) {
|
|
67
|
+
return output.error().title("Missing namespace").message(
|
|
68
|
+
"Could not find a valid namespace for your SDK. Please specify a namespace or contact support."
|
|
69
|
+
).exit("error");
|
|
70
|
+
}
|
|
71
|
+
const sdks = await db.getMany({
|
|
72
|
+
collectionPath: BaseCollections.Sdks(team.data.uid),
|
|
73
|
+
query: {
|
|
74
|
+
namespace
|
|
75
|
+
},
|
|
76
|
+
schema: sdkSchema.array()
|
|
77
|
+
});
|
|
78
|
+
if (sdks.error) return output.error().title(sdks.message).exit("error");
|
|
79
|
+
const sdkUid = sdks.data.find((sdk) => sdk.slug === data.slug)?.uid || await select({
|
|
80
|
+
message: "Please select an SDK to update",
|
|
81
|
+
options: sdks.data.map((sdk) => ({
|
|
82
|
+
value: sdk.uid,
|
|
83
|
+
label: sdk.slug
|
|
84
|
+
}))
|
|
85
|
+
});
|
|
86
|
+
if (!sdkUid) {
|
|
87
|
+
return output.error().title("No SDK found").message("Please provide a valid SDK slug").exit("error");
|
|
88
|
+
}
|
|
89
|
+
const logger = output.info().loader("Updating the SDK");
|
|
90
|
+
const response = await client.sdks.update(sdkUid, {
|
|
91
|
+
title: data.title,
|
|
92
|
+
isPrivate: data.isPrivate
|
|
93
|
+
});
|
|
94
|
+
if (response.error) {
|
|
95
|
+
return output.error().title("Something went wrong").message(response.message).exit("error");
|
|
96
|
+
}
|
|
97
|
+
logger.update("loader", 0, { content: "SDK updated successfully!" }).exit("success");
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
updateAction
|
|
101
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
apiService
|
|
4
|
+
} from "./chunk-SXYALPYK.js";
|
|
5
|
+
import {
|
|
6
|
+
BaseCollections
|
|
7
|
+
} from "./chunk-2BSG2QHO.js";
|
|
8
|
+
import {
|
|
9
|
+
getDatabaseClient
|
|
10
|
+
} from "./chunk-SHSHFGA7.js";
|
|
11
|
+
import "./chunk-UPUTMFD4.js";
|
|
12
|
+
import "./chunk-B6QZJWCQ.js";
|
|
13
|
+
import "./chunk-5BPPGTUU.js";
|
|
14
|
+
import "./chunk-P646T2WH.js";
|
|
15
|
+
import "./chunk-4QS7SJTG.js";
|
|
16
|
+
import "./chunk-VTYTPSXO.js";
|
|
17
|
+
import {
|
|
18
|
+
getAuthData
|
|
19
|
+
} from "./chunk-5BISXQX4.js";
|
|
20
|
+
import "./chunk-OAXFCOJV.js";
|
|
21
|
+
import "./chunk-TLFMATXR.js";
|
|
22
|
+
import {
|
|
23
|
+
teamSchema
|
|
24
|
+
} from "./chunk-4DGQIAJX.js";
|
|
25
|
+
import {
|
|
26
|
+
namespaceSchema,
|
|
27
|
+
slugSchema
|
|
28
|
+
} from "./chunk-ISGLWBXZ.js";
|
|
29
|
+
import {
|
|
30
|
+
external_exports
|
|
31
|
+
} from "./chunk-H2WRMLYY.js";
|
|
32
|
+
import "./chunk-K74E42RV.js";
|
|
33
|
+
import "./chunk-IX7LJ3AD.js";
|
|
34
|
+
import {
|
|
35
|
+
output
|
|
36
|
+
} from "./chunk-X4QLDBB5.js";
|
|
37
|
+
import "./chunk-3MZYUBJ6.js";
|
|
38
|
+
|
|
39
|
+
// src/domains/schema/update.action.ts
|
|
40
|
+
import { select } from "@clack/prompts";
|
|
41
|
+
async function updateAction(opts) {
|
|
42
|
+
const { error, data } = external_exports.object({
|
|
43
|
+
slug: slugSchema.optional(),
|
|
44
|
+
namespace: namespaceSchema.optional(),
|
|
45
|
+
title: external_exports.string().max(50).optional(),
|
|
46
|
+
description: external_exports.string().optional(),
|
|
47
|
+
isPrivate: external_exports.boolean().optional()
|
|
48
|
+
}).safeParse(opts);
|
|
49
|
+
if (error)
|
|
50
|
+
return output.error().title("Invalid input").message(error.issues[0].message).exit("error");
|
|
51
|
+
const auth = await getAuthData();
|
|
52
|
+
auth.addEventListener((state) => Object.assign(auth, state));
|
|
53
|
+
const db = await getDatabaseClient();
|
|
54
|
+
const client = await apiService();
|
|
55
|
+
const team = await db.getOne({
|
|
56
|
+
collectionPath: BaseCollections.Teams,
|
|
57
|
+
query: {
|
|
58
|
+
uid: auth.teamUid
|
|
59
|
+
},
|
|
60
|
+
schema: teamSchema
|
|
61
|
+
});
|
|
62
|
+
if (team.error)
|
|
63
|
+
return output.error().title("An error occurred when fetching your team.").message(team.message).exit("error");
|
|
64
|
+
const namespace = data.namespace || team.data.namespaces.at(0);
|
|
65
|
+
if (!namespace) {
|
|
66
|
+
return output.error().title("Missing namespace").message(
|
|
67
|
+
"Could not find a valid namespace for your schema. Please specify a namespace or contact support."
|
|
68
|
+
).exit("error");
|
|
69
|
+
}
|
|
70
|
+
const schemas = await client.managedSchemas.getSchemas(namespace);
|
|
71
|
+
if (schemas.error) return output.error().title(schemas.message).exit("error");
|
|
72
|
+
const schemaSlug = schemas.data.find((schema) => schema.slug === data.slug)?.slug || await select({
|
|
73
|
+
message: "Please select a schema to update",
|
|
74
|
+
options: schemas.data.map((schema) => ({
|
|
75
|
+
value: schema.slug,
|
|
76
|
+
label: schema.slug
|
|
77
|
+
}))
|
|
78
|
+
});
|
|
79
|
+
if (!schemaSlug) {
|
|
80
|
+
return output.error().title("No schema found").message("Please provide a valid schema slug").exit("error");
|
|
81
|
+
}
|
|
82
|
+
const logger = output.info().loader("Updating the schema");
|
|
83
|
+
const response = await client.managedSchemas.update(namespace, schemaSlug, {
|
|
84
|
+
title: data.title,
|
|
85
|
+
description: data.description,
|
|
86
|
+
isPrivate: data.isPrivate
|
|
87
|
+
});
|
|
88
|
+
if (response.error) {
|
|
89
|
+
return output.error().title("Something went wrong").message(response.message).exit("error");
|
|
90
|
+
}
|
|
91
|
+
logger.update("loader", 0, { content: "Schema updated successfully!" }).exit("success");
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
updateAction
|
|
95
|
+
};
|