@corelayer-ai/cli 0.4.2 → 0.4.4
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/dist/commands/api-keys.js +6 -8
- package/dist/lib/api-client.js +22 -2
- package/package.json +1 -1
|
@@ -11,21 +11,24 @@ function printHelp() {
|
|
|
11
11
|
process.stdout.write(`corelayer api-keys - Manage Corelayer API keys
|
|
12
12
|
|
|
13
13
|
USAGE:
|
|
14
|
-
corelayer api-keys create --name <name> [--
|
|
14
|
+
corelayer api-keys create --name <name> [--expires-at <iso8601>]
|
|
15
15
|
|
|
16
16
|
SUBCOMMANDS:
|
|
17
17
|
create Create a new API key and print the raw key once
|
|
18
18
|
|
|
19
19
|
OPTIONS:
|
|
20
20
|
--name <name> Display name for the API key
|
|
21
|
-
--role <role> member or admin (default: member)
|
|
22
21
|
--expires-at <value> Optional ISO timestamp for key expiry
|
|
23
22
|
--json Output as JSON
|
|
24
23
|
-h, --help Print help
|
|
25
24
|
|
|
25
|
+
NOTES:
|
|
26
|
+
The new key inherits your organization role. Admins get admin keys;
|
|
27
|
+
everyone else gets member keys. The role is not configurable.
|
|
28
|
+
|
|
26
29
|
EXAMPLES:
|
|
27
30
|
corelayer api-keys create --name "Claude Desktop MCP"
|
|
28
|
-
corelayer api-keys create --name "Codex MCP" --
|
|
31
|
+
corelayer api-keys create --name "Codex MCP" --json
|
|
29
32
|
`);
|
|
30
33
|
}
|
|
31
34
|
export async function runApiKeys(args, ctx) {
|
|
@@ -45,16 +48,11 @@ export async function runApiKeys(args, ctx) {
|
|
|
45
48
|
if (!name) {
|
|
46
49
|
fail("Usage: corelayer api-keys create --name <name> [options]");
|
|
47
50
|
}
|
|
48
|
-
const role = readFlag(args, "--role") || "member";
|
|
49
|
-
if (role !== "member" && role !== "admin") {
|
|
50
|
-
fail("role must be member or admin");
|
|
51
|
-
}
|
|
52
51
|
const expiresAt = readFlag(args, "--expires-at");
|
|
53
52
|
const apiUrl = resolveApiUrl(ctx.apiUrlOverride);
|
|
54
53
|
const client = new CorelayerClient(apiUrl, token);
|
|
55
54
|
const created = await client.createApiKey({
|
|
56
55
|
name: name,
|
|
57
|
-
role: role,
|
|
58
56
|
expiresAt,
|
|
59
57
|
});
|
|
60
58
|
if (ctx.json) {
|
package/dist/lib/api-client.js
CHANGED
|
@@ -104,7 +104,6 @@ export class CorelayerClient {
|
|
|
104
104
|
async createApiKey(params) {
|
|
105
105
|
const data = await this.request("POST", "/api/v1/api-keys", {
|
|
106
106
|
name: params.name,
|
|
107
|
-
role: params.role || "member",
|
|
108
107
|
expires_at: params.expiresAt ?? null,
|
|
109
108
|
});
|
|
110
109
|
return {
|
|
@@ -129,7 +128,28 @@ export class CorelayerClient {
|
|
|
129
128
|
params.set("groupId", groupId);
|
|
130
129
|
}
|
|
131
130
|
const suffix = params.toString() ? `?${params.toString()}` : "";
|
|
132
|
-
|
|
131
|
+
const raw = await this.request("GET", `/api/v1/integrations/accounts${suffix}`);
|
|
132
|
+
return {
|
|
133
|
+
accounts: (raw.accounts ?? []).map(account => ({
|
|
134
|
+
id: account.id,
|
|
135
|
+
group_id: account.group_id,
|
|
136
|
+
provider_code: account.provider_code,
|
|
137
|
+
is_active: account.is_active,
|
|
138
|
+
created_at: account.created_at,
|
|
139
|
+
resources: (account.resources ?? []).map(resource => ({
|
|
140
|
+
id: resource.id,
|
|
141
|
+
resource_type: resource.resource_type,
|
|
142
|
+
external_id: resource.external_id,
|
|
143
|
+
name: resource.name,
|
|
144
|
+
is_active: resource.is_active,
|
|
145
|
+
})),
|
|
146
|
+
})),
|
|
147
|
+
providers: (raw.providers ?? []).map(provider => ({
|
|
148
|
+
provider_code: provider.provider_code,
|
|
149
|
+
display_name: provider.display_name,
|
|
150
|
+
})),
|
|
151
|
+
total: raw.total ?? 0,
|
|
152
|
+
};
|
|
133
153
|
}
|
|
134
154
|
}
|
|
135
155
|
export async function exchangeCliCode(baseUrl, code) {
|