commet 2.1.0 → 2.2.1
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/index.js +2649 -216
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -24,13 +24,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
));
|
|
25
25
|
|
|
26
26
|
// src/index.ts
|
|
27
|
-
var
|
|
28
|
-
var
|
|
27
|
+
var import_chalk16 = __toESM(require("chalk"));
|
|
28
|
+
var import_commander11 = require("commander");
|
|
29
29
|
|
|
30
30
|
// package.json
|
|
31
31
|
var package_default = {
|
|
32
32
|
name: "commet",
|
|
33
|
-
version: "2.1
|
|
33
|
+
version: "2.2.1",
|
|
34
34
|
description: "Commet CLI - Manage your billing platform from the command line",
|
|
35
35
|
bin: {
|
|
36
36
|
commet: "./bin/commet"
|
|
@@ -65,7 +65,8 @@ var package_default = {
|
|
|
65
65
|
"jsonc-parser": "3.3.1",
|
|
66
66
|
open: "11.0.0",
|
|
67
67
|
ora: "9.4.0",
|
|
68
|
-
tar: "^7.5.13"
|
|
68
|
+
tar: "^7.5.13",
|
|
69
|
+
"@commet/node": "workspace:*"
|
|
69
70
|
},
|
|
70
71
|
devDependencies: {
|
|
71
72
|
"@types/node": "24.12.4",
|
|
@@ -90,7 +91,9 @@ var package_default = {
|
|
|
90
91
|
// src/commands/api-key.ts
|
|
91
92
|
var import_chalk2 = __toESM(require("chalk"));
|
|
92
93
|
var import_commander = require("commander");
|
|
93
|
-
|
|
94
|
+
|
|
95
|
+
// src/utils/output.ts
|
|
96
|
+
var import_chalk = __toESM(require("chalk"));
|
|
94
97
|
|
|
95
98
|
// src/utils/config.ts
|
|
96
99
|
var fs = __toESM(require("fs"));
|
|
@@ -160,7 +163,7 @@ function clearProjectConfig() {
|
|
|
160
163
|
}
|
|
161
164
|
|
|
162
165
|
// src/utils/telemetry.ts
|
|
163
|
-
var CLI_VERSION = true ? "2.1
|
|
166
|
+
var CLI_VERSION = true ? "2.2.1" : "0.0.0";
|
|
164
167
|
var TELEMETRY_URL = "https://commet.co/api/cli/telemetry";
|
|
165
168
|
function detectRuntime() {
|
|
166
169
|
if ("Bun" in globalThis) {
|
|
@@ -297,54 +300,7 @@ function installCrashHandler() {
|
|
|
297
300
|
});
|
|
298
301
|
}
|
|
299
302
|
|
|
300
|
-
// src/utils/api.ts
|
|
301
|
-
var BASE_URL = "https://commet.co";
|
|
302
|
-
async function apiRequest(endpoint, options = {}) {
|
|
303
|
-
const apiKey = process.env.COMMET_API_KEY;
|
|
304
|
-
const auth = apiKey ? null : loadAuth();
|
|
305
|
-
if (!apiKey && !auth) {
|
|
306
|
-
return {
|
|
307
|
-
error: {
|
|
308
|
-
code: "auth_required",
|
|
309
|
-
message: "Not authenticated. Run `commet login` first."
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
try {
|
|
314
|
-
markApiRequest();
|
|
315
|
-
const response = await fetch(endpoint, {
|
|
316
|
-
...options,
|
|
317
|
-
headers: {
|
|
318
|
-
...options.headers,
|
|
319
|
-
"Content-Type": "application/json",
|
|
320
|
-
"User-Agent": getUserAgent(),
|
|
321
|
-
"commet-client-info": getClientInfoHeader(),
|
|
322
|
-
...apiKey ? { "x-api-key": apiKey } : { Authorization: `Bearer ${auth.token}` }
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
if (!response.ok) {
|
|
326
|
-
const errorData = await response.json().catch(() => ({}));
|
|
327
|
-
return {
|
|
328
|
-
error: {
|
|
329
|
-
code: errorData.code ?? `http_${response.status}`,
|
|
330
|
-
message: errorData.message ?? errorData.error ?? `Request failed with status ${response.status}`
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
const data = await response.json();
|
|
335
|
-
return { data };
|
|
336
|
-
} catch (error) {
|
|
337
|
-
return {
|
|
338
|
-
error: {
|
|
339
|
-
code: "network_error",
|
|
340
|
-
message: error instanceof Error ? error.message : "Unknown error occurred"
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
303
|
// src/utils/output.ts
|
|
347
|
-
var import_chalk = __toESM(require("chalk"));
|
|
348
304
|
function isAgentMode(options) {
|
|
349
305
|
if (options?.output === "agent") return true;
|
|
350
306
|
const idx = process.argv.indexOf("--output");
|
|
@@ -390,91 +346,27 @@ function requireOrgContext() {
|
|
|
390
346
|
}
|
|
391
347
|
|
|
392
348
|
// src/commands/api-key.ts
|
|
393
|
-
var apiKeyCommand = new import_commander.Command("api-key").description(
|
|
394
|
-
|
|
395
|
-
).option("--name <name>", "Name for the API key", "CLI").option(
|
|
396
|
-
"--output <format>",
|
|
397
|
-
"Output format: human (default) or agent",
|
|
398
|
-
"human"
|
|
399
|
-
).addHelpText(
|
|
400
|
-
"after",
|
|
401
|
-
`
|
|
402
|
-
Examples:
|
|
403
|
-
$ commet api-key Generate a key for the linked org
|
|
404
|
-
$ commet api-key --name "GitHub CI" Name it for easy identification
|
|
405
|
-
$ commet api-key --output agent JSON output with the key
|
|
406
|
-
|
|
407
|
-
Then use it in CI:
|
|
408
|
-
$ COMMET_API_KEY=sk_... commet push --yes
|
|
409
|
-
`
|
|
410
|
-
).action(async (options) => {
|
|
411
|
-
const agentMode = isAgentMode(options);
|
|
412
|
-
if (process.env.COMMET_API_KEY) {
|
|
413
|
-
exitWithError({
|
|
414
|
-
code: "invalid_context",
|
|
415
|
-
message: "Cannot create API keys while using COMMET_API_KEY",
|
|
416
|
-
action: "commet login"
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
requireAuth();
|
|
420
|
-
const projectConfig = loadProjectConfig();
|
|
421
|
-
if (!projectConfig) {
|
|
422
|
-
exitWithError({
|
|
423
|
-
code: "project_not_linked",
|
|
424
|
-
message: "No organization linked",
|
|
425
|
-
action: "commet link"
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
const spinner = agentMode ? null : (0, import_ora.default)("Generating API key...").start();
|
|
429
|
-
const result = await apiRequest(
|
|
430
|
-
`${BASE_URL}/api/cli/api-keys`,
|
|
431
|
-
{
|
|
432
|
-
method: "POST",
|
|
433
|
-
body: JSON.stringify({
|
|
434
|
-
organizationId: projectConfig.orgId,
|
|
435
|
-
name: options.name
|
|
436
|
-
})
|
|
437
|
-
}
|
|
438
|
-
);
|
|
439
|
-
if (result.error || !result.data) {
|
|
440
|
-
if (agentMode) {
|
|
441
|
-
console.log(JSON.stringify({ error: result.error }));
|
|
442
|
-
} else {
|
|
443
|
-
spinner?.fail("Failed to create API key");
|
|
444
|
-
console.error(import_chalk2.default.red("Error:"), result.error?.message);
|
|
445
|
-
}
|
|
446
|
-
process.exit(1);
|
|
447
|
-
}
|
|
448
|
-
const { apiKey } = result.data;
|
|
449
|
-
const isLive = projectConfig.mode === "live";
|
|
450
|
-
if (agentMode) {
|
|
349
|
+
var apiKeyCommand = new import_commander.Command("api-key").description("Deprecated \u2014 use 'commet api-keys create' instead").allowUnknownOption().allowExcessArguments().helpOption(false).action((options) => {
|
|
350
|
+
if (isAgentMode(options)) {
|
|
451
351
|
console.log(
|
|
452
352
|
JSON.stringify({
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
...isLive ? {
|
|
457
|
-
warning: "This is a live API key. Rotate it before using in production if generated by an agent."
|
|
458
|
-
} : {}
|
|
353
|
+
deprecated: true,
|
|
354
|
+
replacement: "commet api-keys create",
|
|
355
|
+
message: "This command has been removed. Use 'commet api-keys create' instead."
|
|
459
356
|
})
|
|
460
357
|
);
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
spinner?.succeed("API key created");
|
|
464
|
-
console.log("");
|
|
465
|
-
console.log(` ${import_chalk2.default.bold(apiKey)}`);
|
|
466
|
-
console.log("");
|
|
467
|
-
console.log(import_chalk2.default.yellow(" \u26A0 This key is shown only once \u2014 copy it now."));
|
|
468
|
-
if (isLive) {
|
|
358
|
+
} else {
|
|
359
|
+
console.log(import_chalk2.default.yellow("\n \u26A0 'commet api-key' has been removed.\n"));
|
|
469
360
|
console.log(
|
|
470
|
-
import_chalk2.default.
|
|
471
|
-
|
|
472
|
-
|
|
361
|
+
` Use ${import_chalk2.default.bold("commet api-keys create --name <name>")} instead.
|
|
362
|
+
`
|
|
363
|
+
);
|
|
364
|
+
console.log(
|
|
365
|
+
` Run ${import_chalk2.default.dim("commet api-keys --help")} for all options.
|
|
366
|
+
`
|
|
473
367
|
);
|
|
474
368
|
}
|
|
475
|
-
|
|
476
|
-
import_chalk2.default.dim("\n Use in CI: COMMET_API_KEY=<key> commet push --yes")
|
|
477
|
-
);
|
|
369
|
+
process.exit(0);
|
|
478
370
|
});
|
|
479
371
|
|
|
480
372
|
// src/commands/create.ts
|
|
@@ -485,13 +377,59 @@ var path2 = __toESM(require("path"));
|
|
|
485
377
|
var import_prompts = require("@inquirer/prompts");
|
|
486
378
|
var import_chalk5 = __toESM(require("chalk"));
|
|
487
379
|
var import_commander2 = require("commander");
|
|
488
|
-
var
|
|
380
|
+
var import_ora2 = __toESM(require("ora"));
|
|
489
381
|
var import_tar = require("tar");
|
|
490
382
|
|
|
383
|
+
// src/utils/api.ts
|
|
384
|
+
var BASE_URL = "https://commet.co";
|
|
385
|
+
async function apiRequest(endpoint, options = {}) {
|
|
386
|
+
const apiKey = process.env.COMMET_API_KEY;
|
|
387
|
+
const auth = apiKey ? null : loadAuth();
|
|
388
|
+
if (!apiKey && !auth) {
|
|
389
|
+
return {
|
|
390
|
+
error: {
|
|
391
|
+
code: "auth_required",
|
|
392
|
+
message: "Not authenticated. Run `commet login` first."
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
try {
|
|
397
|
+
markApiRequest();
|
|
398
|
+
const response = await fetch(endpoint, {
|
|
399
|
+
...options,
|
|
400
|
+
headers: {
|
|
401
|
+
...options.headers,
|
|
402
|
+
"Content-Type": "application/json",
|
|
403
|
+
"User-Agent": getUserAgent(),
|
|
404
|
+
"commet-client-info": getClientInfoHeader(),
|
|
405
|
+
...apiKey ? { "x-api-key": apiKey } : { Authorization: `Bearer ${auth.token}` }
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
if (!response.ok) {
|
|
409
|
+
const errorData = await response.json().catch(() => ({}));
|
|
410
|
+
return {
|
|
411
|
+
error: {
|
|
412
|
+
code: errorData.code ?? `http_${response.status}`,
|
|
413
|
+
message: errorData.message ?? errorData.error ?? `Request failed with status ${response.status}`
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
const data = await response.json();
|
|
418
|
+
return { data };
|
|
419
|
+
} catch (error) {
|
|
420
|
+
return {
|
|
421
|
+
error: {
|
|
422
|
+
code: "network_error",
|
|
423
|
+
message: error instanceof Error ? error.message : "Unknown error occurred"
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
491
429
|
// src/utils/login-flow.ts
|
|
492
430
|
var import_chalk4 = __toESM(require("chalk"));
|
|
493
431
|
var import_open = __toESM(require("open"));
|
|
494
|
-
var
|
|
432
|
+
var import_ora = __toESM(require("ora"));
|
|
495
433
|
|
|
496
434
|
// src/utils/prompt-theme.ts
|
|
497
435
|
var import_chalk3 = __toESM(require("chalk"));
|
|
@@ -514,7 +452,7 @@ function sleep(ms) {
|
|
|
514
452
|
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
515
453
|
}
|
|
516
454
|
async function performLogin() {
|
|
517
|
-
const spinner = (0,
|
|
455
|
+
const spinner = (0, import_ora.default)("Initiating login flow...").start();
|
|
518
456
|
try {
|
|
519
457
|
const deviceResponse = await fetch(`${BASE_URL}/api/auth/device/code`, {
|
|
520
458
|
method: "POST",
|
|
@@ -547,7 +485,7 @@ async function performLogin() {
|
|
|
547
485
|
} catch {
|
|
548
486
|
console.log(import_chalk4.default.yellow("\u26A0 Could not open browser automatically."));
|
|
549
487
|
}
|
|
550
|
-
const pollSpinner = (0,
|
|
488
|
+
const pollSpinner = (0, import_ora.default)("Waiting for authorization...").start();
|
|
551
489
|
let pollingInterval = interval;
|
|
552
490
|
let attempts = 0;
|
|
553
491
|
const maxAttempts = Math.floor(180 / pollingInterval);
|
|
@@ -851,7 +789,7 @@ var createCommand = new import_commander2.Command("create").description("Create
|
|
|
851
789
|
return;
|
|
852
790
|
}
|
|
853
791
|
}
|
|
854
|
-
const orgsSpinner = (0,
|
|
792
|
+
const orgsSpinner = (0, import_ora2.default)("Fetching sandbox organizations...").start();
|
|
855
793
|
const orgsResult = await apiRequest(`${BASE_URL}/api/cli/organizations`);
|
|
856
794
|
if (orgsResult.error || !orgsResult.data) {
|
|
857
795
|
orgsSpinner.fail("Failed to fetch organizations");
|
|
@@ -945,7 +883,7 @@ var createCommand = new import_commander2.Command("create").description("Create
|
|
|
945
883
|
}
|
|
946
884
|
}
|
|
947
885
|
const shouldInstallSkills = await resolveSkills(opts);
|
|
948
|
-
const downloadSpinner = (0,
|
|
886
|
+
const downloadSpinner = (0, import_ora2.default)("Downloading template...").start();
|
|
949
887
|
try {
|
|
950
888
|
await downloadTemplate(template.dir, dest, opts.ref);
|
|
951
889
|
downloadSpinner.succeed("Template downloaded");
|
|
@@ -961,7 +899,7 @@ var createCommand = new import_commander2.Command("create").description("Create
|
|
|
961
899
|
}
|
|
962
900
|
updatePackageJson(dest, projectName);
|
|
963
901
|
copyEnvExample(dest);
|
|
964
|
-
const resolveSpinner = (0,
|
|
902
|
+
const resolveSpinner = (0, import_ora2.default)("Resolving package versions...").start();
|
|
965
903
|
try {
|
|
966
904
|
const count = await resolveWorkspaceDeps(dest);
|
|
967
905
|
if (count > 0) {
|
|
@@ -979,7 +917,7 @@ var createCommand = new import_commander2.Command("create").description("Create
|
|
|
979
917
|
}
|
|
980
918
|
return;
|
|
981
919
|
}
|
|
982
|
-
const planSpinner = (0,
|
|
920
|
+
const planSpinner = (0, import_ora2.default)("Creating plans...").start();
|
|
983
921
|
const templateResult = await apiRequest(`${BASE_URL}/api/cli/templates`, {
|
|
984
922
|
method: "POST",
|
|
985
923
|
body: JSON.stringify({
|
|
@@ -995,7 +933,7 @@ var createCommand = new import_commander2.Command("create").description("Create
|
|
|
995
933
|
`Created ${templateResult.data.plansCreated} plans and ${templateResult.data.featuresCreated} features`
|
|
996
934
|
);
|
|
997
935
|
}
|
|
998
|
-
const keySpinner = (0,
|
|
936
|
+
const keySpinner = (0, import_ora2.default)("Creating API key...").start();
|
|
999
937
|
const keyResult = await apiRequest(`${BASE_URL}/api/cli/api-keys`, {
|
|
1000
938
|
method: "POST",
|
|
1001
939
|
body: JSON.stringify({
|
|
@@ -1030,7 +968,7 @@ var createCommand = new import_commander2.Command("create").description("Create
|
|
|
1030
968
|
var import_prompts2 = require("@inquirer/prompts");
|
|
1031
969
|
var import_chalk6 = __toESM(require("chalk"));
|
|
1032
970
|
var import_commander3 = require("commander");
|
|
1033
|
-
var
|
|
971
|
+
var import_ora3 = __toESM(require("ora"));
|
|
1034
972
|
|
|
1035
973
|
// src/utils/gitignore-updater.ts
|
|
1036
974
|
var fs3 = __toESM(require("fs"));
|
|
@@ -1113,7 +1051,7 @@ Examples:
|
|
|
1113
1051
|
});
|
|
1114
1052
|
}
|
|
1115
1053
|
const currentConfig = projectConfigExists() ? loadProjectConfig() : null;
|
|
1116
|
-
const spinner = agentMode ? null : (0,
|
|
1054
|
+
const spinner = agentMode ? null : (0, import_ora3.default)("Fetching organizations...").start();
|
|
1117
1055
|
const result = await apiRequest(
|
|
1118
1056
|
`${BASE_URL}/api/cli/organizations`
|
|
1119
1057
|
);
|
|
@@ -1229,6 +1167,26 @@ Examples:
|
|
|
1229
1167
|
mode: selectedOrg.mode
|
|
1230
1168
|
});
|
|
1231
1169
|
const gitignoreResult = updateGitignore(".commet/");
|
|
1170
|
+
let autoApiKey = null;
|
|
1171
|
+
const keyResult = await apiRequest(
|
|
1172
|
+
`${BASE_URL}/api/cli/api-keys`,
|
|
1173
|
+
{
|
|
1174
|
+
method: "POST",
|
|
1175
|
+
body: JSON.stringify({
|
|
1176
|
+
organizationId: selectedOrg.id,
|
|
1177
|
+
name: "CLI (auto)"
|
|
1178
|
+
})
|
|
1179
|
+
}
|
|
1180
|
+
).catch(() => null);
|
|
1181
|
+
if (keyResult?.data?.apiKey) {
|
|
1182
|
+
autoApiKey = keyResult.data.apiKey;
|
|
1183
|
+
saveProjectConfig({
|
|
1184
|
+
orgId: selectedOrg.id,
|
|
1185
|
+
orgName: selectedOrg.name,
|
|
1186
|
+
mode: selectedOrg.mode,
|
|
1187
|
+
apiKey: autoApiKey
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1232
1190
|
if (agentMode) {
|
|
1233
1191
|
console.log(
|
|
1234
1192
|
JSON.stringify({
|
|
@@ -1239,7 +1197,8 @@ Examples:
|
|
|
1239
1197
|
name: selectedOrg.name,
|
|
1240
1198
|
slug: selectedOrg.slug,
|
|
1241
1199
|
mode: selectedOrg.mode
|
|
1242
|
-
}
|
|
1200
|
+
},
|
|
1201
|
+
...autoApiKey ? { apiKey: autoApiKey, apiKeyAutoGenerated: true } : {}
|
|
1243
1202
|
})
|
|
1244
1203
|
);
|
|
1245
1204
|
} else {
|
|
@@ -1251,6 +1210,17 @@ Examples:
|
|
|
1251
1210
|
if (gitignoreResult.success && action === "linked") {
|
|
1252
1211
|
console.log(import_chalk6.default.green("\u2713 Updated .gitignore"));
|
|
1253
1212
|
}
|
|
1213
|
+
if (autoApiKey) {
|
|
1214
|
+
console.log(
|
|
1215
|
+
import_chalk6.default.green("\u2713 API key auto-generated for resource commands")
|
|
1216
|
+
);
|
|
1217
|
+
} else {
|
|
1218
|
+
console.log(
|
|
1219
|
+
import_chalk6.default.dim(
|
|
1220
|
+
" API key auto-generation failed. Run `commet api-keys create` to create one manually."
|
|
1221
|
+
)
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
1254
1224
|
console.log(import_chalk6.default.dim("\nRun `commet pull` to sync your config"));
|
|
1255
1225
|
}
|
|
1256
1226
|
});
|
|
@@ -1511,7 +1481,7 @@ var logoutCommand = new import_commander6.Command("logout").description(
|
|
|
1511
1481
|
// src/commands/orgs.ts
|
|
1512
1482
|
var import_chalk10 = __toESM(require("chalk"));
|
|
1513
1483
|
var import_commander7 = require("commander");
|
|
1514
|
-
var
|
|
1484
|
+
var import_ora4 = __toESM(require("ora"));
|
|
1515
1485
|
var orgsCommand = new import_commander7.Command("orgs").description(
|
|
1516
1486
|
"List all organizations you have access to. Shows name, slug, mode (live/sandbox), and which one is currently linked."
|
|
1517
1487
|
).option(
|
|
@@ -1530,7 +1500,7 @@ The slug shown here is what you pass to 'commet link --org <slug>'.
|
|
|
1530
1500
|
).action(async (options) => {
|
|
1531
1501
|
const agentMode = isAgentMode(options);
|
|
1532
1502
|
requireAuth();
|
|
1533
|
-
const spinner = agentMode ? null : (0,
|
|
1503
|
+
const spinner = agentMode ? null : (0, import_ora4.default)("Fetching organizations...").start();
|
|
1534
1504
|
const result = await apiRequest(
|
|
1535
1505
|
`${BASE_URL}/api/cli/organizations`
|
|
1536
1506
|
);
|
|
@@ -1577,7 +1547,7 @@ var path5 = __toESM(require("path"));
|
|
|
1577
1547
|
var import_prompts3 = require("@inquirer/prompts");
|
|
1578
1548
|
var import_chalk12 = __toESM(require("chalk"));
|
|
1579
1549
|
var import_commander8 = require("commander");
|
|
1580
|
-
var
|
|
1550
|
+
var import_ora5 = __toESM(require("ora"));
|
|
1581
1551
|
|
|
1582
1552
|
// src/utils/config-loader.ts
|
|
1583
1553
|
var fs4 = __toESM(require("fs"));
|
|
@@ -1910,12 +1880,12 @@ Examples:
|
|
|
1910
1880
|
$ commet pull --dry-run Preview changes without applying
|
|
1911
1881
|
$ commet pull --yes Apply without confirmation
|
|
1912
1882
|
$ commet pull --output agent --yes Agent/CI \u2014 structured JSON, no prompts
|
|
1913
|
-
$ COMMET_API_KEY=
|
|
1883
|
+
$ COMMET_API_KEY=ck_... commet pull --yes CI pipeline
|
|
1914
1884
|
`
|
|
1915
1885
|
).action(async (options) => {
|
|
1916
1886
|
const agentMode = isAgentMode(options);
|
|
1917
1887
|
const { orgId } = requireOrgContext();
|
|
1918
|
-
const spinner = agentMode ? null : (0,
|
|
1888
|
+
const spinner = agentMode ? null : (0, import_ora5.default)("Fetching config from remote...").start();
|
|
1919
1889
|
const orgQuery = orgId === "__from_api_key__" ? "" : `?orgId=${orgId}`;
|
|
1920
1890
|
const result = await apiRequest(
|
|
1921
1891
|
`${BASE_URL}/api/cli/pull${orgQuery}`
|
|
@@ -2129,7 +2099,7 @@ Would create commet.config.ts (${features.length} features, ${plans.length} plan
|
|
|
2129
2099
|
var import_prompts4 = require("@inquirer/prompts");
|
|
2130
2100
|
var import_chalk13 = __toESM(require("chalk"));
|
|
2131
2101
|
var import_commander9 = require("commander");
|
|
2132
|
-
var
|
|
2102
|
+
var import_ora6 = __toESM(require("ora"));
|
|
2133
2103
|
var pushCommand = new import_commander9.Command("push").description(
|
|
2134
2104
|
"Push your local commet.config.ts to Commet. Creates or updates features and plans to match your config file."
|
|
2135
2105
|
).option("-y, --yes", "Skip confirmation prompt").option("--dry-run", "Show what would change without pushing").option(
|
|
@@ -2144,12 +2114,12 @@ Examples:
|
|
|
2144
2114
|
$ commet push --dry-run Preview what would change on remote
|
|
2145
2115
|
$ commet push --yes Push without confirmation
|
|
2146
2116
|
$ commet push --output agent --yes Agent/CI \u2014 structured JSON, no prompts
|
|
2147
|
-
$ COMMET_API_KEY=
|
|
2117
|
+
$ COMMET_API_KEY=ck_... commet push --yes CI pipeline
|
|
2148
2118
|
`
|
|
2149
2119
|
).action(async (options) => {
|
|
2150
2120
|
const agentMode = isAgentMode(options);
|
|
2151
2121
|
const { orgId } = requireOrgContext();
|
|
2152
|
-
const loadSpinner = agentMode ? null : (0,
|
|
2122
|
+
const loadSpinner = agentMode ? null : (0, import_ora6.default)("Loading commet.config.ts...").start();
|
|
2153
2123
|
const loaded = await loadBillingConfig(process.cwd()).catch(
|
|
2154
2124
|
(error) => {
|
|
2155
2125
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -2169,7 +2139,7 @@ Examples:
|
|
|
2169
2139
|
if (!loaded) process.exit(1);
|
|
2170
2140
|
const { config, configPath } = loaded;
|
|
2171
2141
|
loadSpinner?.succeed(`Loaded ${configPath}`);
|
|
2172
|
-
const fetchSpinner = agentMode ? null : (0,
|
|
2142
|
+
const fetchSpinner = agentMode ? null : (0, import_ora6.default)("Fetching remote state...").start();
|
|
2173
2143
|
const orgQuery = orgId === "__from_api_key__" ? "" : `?orgId=${orgId}`;
|
|
2174
2144
|
const remoteResult = await apiRequest(
|
|
2175
2145
|
`${BASE_URL}/api/cli/pull${orgQuery}`
|
|
@@ -2249,7 +2219,7 @@ Examples:
|
|
|
2249
2219
|
return;
|
|
2250
2220
|
}
|
|
2251
2221
|
}
|
|
2252
|
-
const pushSpinner = agentMode ? null : (0,
|
|
2222
|
+
const pushSpinner = agentMode ? null : (0, import_ora6.default)("Pushing config...").start();
|
|
2253
2223
|
const pushBody = {
|
|
2254
2224
|
config: { features: config.features, plans: config.plans }
|
|
2255
2225
|
};
|
|
@@ -2314,55 +2284,2515 @@ Examples:
|
|
|
2314
2284
|
}
|
|
2315
2285
|
});
|
|
2316
2286
|
|
|
2317
|
-
// src/
|
|
2318
|
-
var
|
|
2319
|
-
var os3 = __toESM(require("os"));
|
|
2320
|
-
var path6 = __toESM(require("path"));
|
|
2287
|
+
// src/commands/resources/factory.ts
|
|
2288
|
+
var import_node2 = require("@commet/node");
|
|
2321
2289
|
var import_chalk14 = __toESM(require("chalk"));
|
|
2322
|
-
var
|
|
2323
|
-
var
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2290
|
+
var import_commander10 = require("commander");
|
|
2291
|
+
var import_ora7 = __toESM(require("ora"));
|
|
2292
|
+
|
|
2293
|
+
// src/utils/sdk.ts
|
|
2294
|
+
var import_node = require("@commet/node");
|
|
2295
|
+
function createSdkClient() {
|
|
2296
|
+
const envKey = process.env.COMMET_API_KEY;
|
|
2297
|
+
if (envKey) {
|
|
2298
|
+
return new import_node.Commet({ apiKey: envKey });
|
|
2331
2299
|
}
|
|
2332
|
-
|
|
2300
|
+
const config = loadProjectConfig();
|
|
2301
|
+
if (config?.apiKey) {
|
|
2302
|
+
return new import_node.Commet({ apiKey: config.apiKey });
|
|
2303
|
+
}
|
|
2304
|
+
exitWithError({
|
|
2305
|
+
code: "api_key_required",
|
|
2306
|
+
message: "No API key found. Set COMMET_API_KEY env var, or run `commet link` to auto-generate one.",
|
|
2307
|
+
action: "commet link"
|
|
2308
|
+
});
|
|
2333
2309
|
}
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2310
|
+
|
|
2311
|
+
// src/commands/resources/factory.ts
|
|
2312
|
+
function createResourceCommand(def) {
|
|
2313
|
+
const command = new import_commander10.Command(def.name).description(def.description);
|
|
2314
|
+
for (const [actionName, actionDef] of Object.entries(def.actions)) {
|
|
2315
|
+
const subcommand = new import_commander10.Command(actionName).description(actionDef.description).option(
|
|
2316
|
+
"--output <format>",
|
|
2317
|
+
"Output format: human (default) or agent",
|
|
2318
|
+
"human"
|
|
2319
|
+
);
|
|
2320
|
+
for (const param of actionDef.params) {
|
|
2321
|
+
if (param.required) {
|
|
2322
|
+
subcommand.requiredOption(param.flag, param.description);
|
|
2323
|
+
} else {
|
|
2324
|
+
subcommand.option(param.flag, param.description);
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
subcommand.action(async (options) => {
|
|
2328
|
+
const agentMode = isAgentMode(options);
|
|
2329
|
+
const spinner = agentMode ? null : (0, import_ora7.default)(`Running ${def.name} ${actionName}...`).start();
|
|
2330
|
+
try {
|
|
2331
|
+
const client = createSdkClient();
|
|
2332
|
+
const resource = client[def.sdkProperty];
|
|
2333
|
+
const method = resource[actionDef.method];
|
|
2334
|
+
let params;
|
|
2335
|
+
if (actionDef.buildParams) {
|
|
2336
|
+
params = actionDef.buildParams(options);
|
|
2337
|
+
} else {
|
|
2338
|
+
const built = {};
|
|
2339
|
+
for (const paramDef of actionDef.params) {
|
|
2340
|
+
const rawValue = options[paramDef.sdkKey];
|
|
2341
|
+
if (rawValue === void 0) {
|
|
2342
|
+
continue;
|
|
2343
|
+
}
|
|
2344
|
+
built[paramDef.sdkKey] = paramDef.parse ? paramDef.parse(rawValue) : rawValue;
|
|
2345
|
+
}
|
|
2346
|
+
params = built;
|
|
2347
|
+
}
|
|
2348
|
+
const result = await method.call(resource, params);
|
|
2349
|
+
spinner?.succeed(`${def.name} ${actionName}`);
|
|
2350
|
+
if (agentMode) {
|
|
2351
|
+
console.log(JSON.stringify(result));
|
|
2352
|
+
} else {
|
|
2353
|
+
console.log(JSON.stringify(result, null, 2));
|
|
2354
|
+
}
|
|
2355
|
+
} catch (error) {
|
|
2356
|
+
if (error instanceof import_node2.CommetValidationError) {
|
|
2357
|
+
spinner?.fail(`Validation error`);
|
|
2358
|
+
if (agentMode) {
|
|
2359
|
+
console.log(
|
|
2360
|
+
JSON.stringify({
|
|
2361
|
+
error: {
|
|
2362
|
+
code: "validation_error",
|
|
2363
|
+
message: error.message,
|
|
2364
|
+
validationErrors: error.validationErrors
|
|
2365
|
+
}
|
|
2366
|
+
})
|
|
2367
|
+
);
|
|
2368
|
+
} else {
|
|
2369
|
+
console.error(import_chalk14.default.red(`\u2717 ${error.message}`));
|
|
2370
|
+
for (const [field, messages] of Object.entries(
|
|
2371
|
+
error.validationErrors
|
|
2372
|
+
)) {
|
|
2373
|
+
for (const msg of messages) {
|
|
2374
|
+
console.error(import_chalk14.default.red(` ${field}: ${msg}`));
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
process.exit(1);
|
|
2379
|
+
}
|
|
2380
|
+
if (error instanceof import_node2.CommetAPIError) {
|
|
2381
|
+
spinner?.fail(`API error`);
|
|
2382
|
+
if (agentMode) {
|
|
2383
|
+
console.log(
|
|
2384
|
+
JSON.stringify({
|
|
2385
|
+
error: {
|
|
2386
|
+
code: error.code ?? `http_${error.statusCode}`,
|
|
2387
|
+
message: error.message,
|
|
2388
|
+
statusCode: error.statusCode
|
|
2389
|
+
}
|
|
2390
|
+
})
|
|
2391
|
+
);
|
|
2392
|
+
} else {
|
|
2393
|
+
console.error(
|
|
2394
|
+
import_chalk14.default.red(`\u2717 ${error.message} (${error.statusCode})`)
|
|
2395
|
+
);
|
|
2396
|
+
}
|
|
2397
|
+
process.exit(1);
|
|
2398
|
+
}
|
|
2399
|
+
spinner?.fail(`Unexpected error`);
|
|
2400
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2401
|
+
if (agentMode) {
|
|
2402
|
+
console.log(JSON.stringify({ error: { code: "unknown", message } }));
|
|
2403
|
+
} else {
|
|
2404
|
+
console.error(import_chalk14.default.red(`\u2717 ${message}`));
|
|
2405
|
+
}
|
|
2406
|
+
process.exit(1);
|
|
2407
|
+
}
|
|
2408
|
+
});
|
|
2409
|
+
command.addCommand(subcommand);
|
|
2339
2410
|
}
|
|
2411
|
+
return command;
|
|
2340
2412
|
}
|
|
2341
|
-
function
|
|
2413
|
+
function generateResourceSchema(defs) {
|
|
2414
|
+
const resources = {};
|
|
2415
|
+
for (const def of defs) {
|
|
2416
|
+
const actions = {};
|
|
2417
|
+
for (const [actionName, actionDef] of Object.entries(def.actions)) {
|
|
2418
|
+
const params = {};
|
|
2419
|
+
for (const param of actionDef.params) {
|
|
2420
|
+
params[param.sdkKey] = {
|
|
2421
|
+
flag: param.flag,
|
|
2422
|
+
description: param.description,
|
|
2423
|
+
required: param.required ?? false
|
|
2424
|
+
};
|
|
2425
|
+
}
|
|
2426
|
+
actions[actionName] = {
|
|
2427
|
+
usage: `commet ${def.name} ${actionName}`,
|
|
2428
|
+
description: actionDef.description,
|
|
2429
|
+
params
|
|
2430
|
+
};
|
|
2431
|
+
}
|
|
2432
|
+
resources[def.name] = {
|
|
2433
|
+
description: def.description,
|
|
2434
|
+
actions
|
|
2435
|
+
};
|
|
2436
|
+
}
|
|
2437
|
+
return resources;
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
// src/commands/resources/param-types.ts
|
|
2441
|
+
function parseJson(value) {
|
|
2342
2442
|
try {
|
|
2343
|
-
|
|
2443
|
+
return JSON.parse(value);
|
|
2344
2444
|
} catch {
|
|
2445
|
+
throw new Error(`Invalid JSON: ${value}`);
|
|
2345
2446
|
}
|
|
2346
2447
|
}
|
|
2347
|
-
function
|
|
2348
|
-
|
|
2349
|
-
if (
|
|
2350
|
-
|
|
2351
|
-
if (idx !== -1 && process.argv[idx + 1] === "agent") return true;
|
|
2352
|
-
return false;
|
|
2353
|
-
}
|
|
2354
|
-
var updateAvailable = null;
|
|
2355
|
-
function scheduleUpdateCheck(currentVersion) {
|
|
2356
|
-
if (shouldSkip()) return;
|
|
2357
|
-
const cache = readCache();
|
|
2358
|
-
if (cache && isNewerVersion(cache.latestVersion, currentVersion)) {
|
|
2359
|
-
updateAvailable = cache.latestVersion;
|
|
2448
|
+
function parseNumber(value) {
|
|
2449
|
+
const num = Number(value);
|
|
2450
|
+
if (Number.isNaN(num)) {
|
|
2451
|
+
throw new Error(`Invalid number: ${value}`);
|
|
2360
2452
|
}
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2453
|
+
return num;
|
|
2454
|
+
}
|
|
2455
|
+
function parseBool(value) {
|
|
2456
|
+
if (value === "true") return true;
|
|
2457
|
+
if (value === "false") return false;
|
|
2458
|
+
throw new Error(`Invalid boolean: ${value}. Expected "true" or "false".`);
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
// src/commands/resources/registry.ts
|
|
2462
|
+
var customersResource = {
|
|
2463
|
+
name: "customers",
|
|
2464
|
+
description: "Manage customers",
|
|
2465
|
+
sdkProperty: "customers",
|
|
2466
|
+
actions: {
|
|
2467
|
+
create: {
|
|
2468
|
+
method: "create",
|
|
2469
|
+
description: "Create a customer",
|
|
2470
|
+
params: [
|
|
2471
|
+
{
|
|
2472
|
+
flag: "--email <email>",
|
|
2473
|
+
description: "Billing email (required)",
|
|
2474
|
+
required: true,
|
|
2475
|
+
sdkKey: "email"
|
|
2476
|
+
},
|
|
2477
|
+
{ flag: "--id <id>", description: "Custom customer ID", sdkKey: "id" },
|
|
2478
|
+
{
|
|
2479
|
+
flag: "--full-name <name>",
|
|
2480
|
+
description: "Full name",
|
|
2481
|
+
sdkKey: "fullName"
|
|
2482
|
+
},
|
|
2483
|
+
{ flag: "--domain <domain>", description: "Domain", sdkKey: "domain" },
|
|
2484
|
+
{
|
|
2485
|
+
flag: "--website <url>",
|
|
2486
|
+
description: "Website URL",
|
|
2487
|
+
sdkKey: "website"
|
|
2488
|
+
},
|
|
2489
|
+
{
|
|
2490
|
+
flag: "--timezone <tz>",
|
|
2491
|
+
description: "Timezone",
|
|
2492
|
+
sdkKey: "timezone"
|
|
2493
|
+
},
|
|
2494
|
+
{
|
|
2495
|
+
flag: "--language <lang>",
|
|
2496
|
+
description: "Language code",
|
|
2497
|
+
sdkKey: "language"
|
|
2498
|
+
},
|
|
2499
|
+
{
|
|
2500
|
+
flag: "--industry <industry>",
|
|
2501
|
+
description: "Industry",
|
|
2502
|
+
sdkKey: "industry"
|
|
2503
|
+
},
|
|
2504
|
+
{
|
|
2505
|
+
flag: "--metadata <json>",
|
|
2506
|
+
description: "Metadata (JSON)",
|
|
2507
|
+
parse: parseJson,
|
|
2508
|
+
sdkKey: "metadata"
|
|
2509
|
+
},
|
|
2510
|
+
{
|
|
2511
|
+
flag: "--address <json>",
|
|
2512
|
+
description: "Address (JSON: {line1, city, postalCode, country, ...})",
|
|
2513
|
+
parse: parseJson,
|
|
2514
|
+
sdkKey: "address"
|
|
2515
|
+
}
|
|
2516
|
+
]
|
|
2517
|
+
},
|
|
2518
|
+
"create-batch": {
|
|
2519
|
+
method: "createBatch",
|
|
2520
|
+
description: "Create multiple customers in a batch",
|
|
2521
|
+
params: [
|
|
2522
|
+
{
|
|
2523
|
+
flag: "--customers <json>",
|
|
2524
|
+
description: "Array of customer objects (JSON)",
|
|
2525
|
+
required: true,
|
|
2526
|
+
parse: parseJson,
|
|
2527
|
+
sdkKey: "customers"
|
|
2528
|
+
}
|
|
2529
|
+
]
|
|
2530
|
+
},
|
|
2531
|
+
get: {
|
|
2532
|
+
method: "get",
|
|
2533
|
+
description: "Get a customer by ID",
|
|
2534
|
+
params: [
|
|
2535
|
+
{
|
|
2536
|
+
flag: "--id <id>",
|
|
2537
|
+
description: "Customer ID",
|
|
2538
|
+
required: true,
|
|
2539
|
+
sdkKey: "id"
|
|
2540
|
+
}
|
|
2541
|
+
]
|
|
2542
|
+
},
|
|
2543
|
+
update: {
|
|
2544
|
+
method: "update",
|
|
2545
|
+
description: "Update a customer",
|
|
2546
|
+
params: [
|
|
2547
|
+
{
|
|
2548
|
+
flag: "--id <id>",
|
|
2549
|
+
description: "Customer ID",
|
|
2550
|
+
required: true,
|
|
2551
|
+
sdkKey: "id"
|
|
2552
|
+
},
|
|
2553
|
+
{
|
|
2554
|
+
flag: "--email <email>",
|
|
2555
|
+
description: "Billing email",
|
|
2556
|
+
sdkKey: "email"
|
|
2557
|
+
},
|
|
2558
|
+
{
|
|
2559
|
+
flag: "--full-name <name>",
|
|
2560
|
+
description: "Full name",
|
|
2561
|
+
sdkKey: "fullName"
|
|
2562
|
+
},
|
|
2563
|
+
{ flag: "--domain <domain>", description: "Domain", sdkKey: "domain" },
|
|
2564
|
+
{
|
|
2565
|
+
flag: "--website <url>",
|
|
2566
|
+
description: "Website URL",
|
|
2567
|
+
sdkKey: "website"
|
|
2568
|
+
},
|
|
2569
|
+
{
|
|
2570
|
+
flag: "--timezone <tz>",
|
|
2571
|
+
description: "Timezone",
|
|
2572
|
+
sdkKey: "timezone"
|
|
2573
|
+
},
|
|
2574
|
+
{
|
|
2575
|
+
flag: "--language <lang>",
|
|
2576
|
+
description: "Language code",
|
|
2577
|
+
sdkKey: "language"
|
|
2578
|
+
},
|
|
2579
|
+
{
|
|
2580
|
+
flag: "--industry <industry>",
|
|
2581
|
+
description: "Industry",
|
|
2582
|
+
sdkKey: "industry"
|
|
2583
|
+
},
|
|
2584
|
+
{
|
|
2585
|
+
flag: "--metadata <json>",
|
|
2586
|
+
description: "Metadata (JSON)",
|
|
2587
|
+
parse: parseJson,
|
|
2588
|
+
sdkKey: "metadata"
|
|
2589
|
+
},
|
|
2590
|
+
{
|
|
2591
|
+
flag: "--address <json>",
|
|
2592
|
+
description: "Address (JSON)",
|
|
2593
|
+
parse: parseJson,
|
|
2594
|
+
sdkKey: "address"
|
|
2595
|
+
}
|
|
2596
|
+
]
|
|
2597
|
+
},
|
|
2598
|
+
list: {
|
|
2599
|
+
method: "list",
|
|
2600
|
+
description: "List customers",
|
|
2601
|
+
params: [
|
|
2602
|
+
{
|
|
2603
|
+
flag: "--search <query>",
|
|
2604
|
+
description: "Search query",
|
|
2605
|
+
sdkKey: "search"
|
|
2606
|
+
},
|
|
2607
|
+
{
|
|
2608
|
+
flag: "--limit <n>",
|
|
2609
|
+
description: "Max results",
|
|
2610
|
+
parse: parseNumber,
|
|
2611
|
+
sdkKey: "limit"
|
|
2612
|
+
},
|
|
2613
|
+
{
|
|
2614
|
+
flag: "--cursor <cursor>",
|
|
2615
|
+
description: "Pagination cursor",
|
|
2616
|
+
sdkKey: "cursor"
|
|
2617
|
+
},
|
|
2618
|
+
{
|
|
2619
|
+
flag: "--start-date <date>",
|
|
2620
|
+
description: "Start date filter",
|
|
2621
|
+
sdkKey: "startDate"
|
|
2622
|
+
},
|
|
2623
|
+
{
|
|
2624
|
+
flag: "--end-date <date>",
|
|
2625
|
+
description: "End date filter",
|
|
2626
|
+
sdkKey: "endDate"
|
|
2627
|
+
}
|
|
2628
|
+
]
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
};
|
|
2632
|
+
var subscriptionsResource = {
|
|
2633
|
+
name: "subscriptions",
|
|
2634
|
+
description: "Manage subscriptions",
|
|
2635
|
+
sdkProperty: "subscriptions",
|
|
2636
|
+
actions: {
|
|
2637
|
+
create: {
|
|
2638
|
+
method: "create",
|
|
2639
|
+
description: "Create a subscription",
|
|
2640
|
+
params: [
|
|
2641
|
+
{
|
|
2642
|
+
flag: "--customer-id <id>",
|
|
2643
|
+
description: "Customer ID (required)",
|
|
2644
|
+
required: true,
|
|
2645
|
+
sdkKey: "customerId"
|
|
2646
|
+
},
|
|
2647
|
+
{
|
|
2648
|
+
flag: "--plan-code <code>",
|
|
2649
|
+
description: "Plan code (provide this or --plan-id)",
|
|
2650
|
+
sdkKey: "planCode"
|
|
2651
|
+
},
|
|
2652
|
+
{
|
|
2653
|
+
flag: "--plan-id <id>",
|
|
2654
|
+
description: "Plan ID (provide this or --plan-code)",
|
|
2655
|
+
sdkKey: "planId"
|
|
2656
|
+
},
|
|
2657
|
+
{
|
|
2658
|
+
flag: "--billing-interval <interval>",
|
|
2659
|
+
description: "Billing interval: weekly, monthly, quarterly, yearly, one_time",
|
|
2660
|
+
sdkKey: "billingInterval"
|
|
2661
|
+
},
|
|
2662
|
+
{
|
|
2663
|
+
flag: "--initial-seats <json>",
|
|
2664
|
+
description: "Initial seats map (JSON: {featureCode: count})",
|
|
2665
|
+
parse: parseJson,
|
|
2666
|
+
sdkKey: "initialSeats"
|
|
2667
|
+
},
|
|
2668
|
+
{
|
|
2669
|
+
flag: "--skip-trial <bool>",
|
|
2670
|
+
description: "Skip trial period",
|
|
2671
|
+
parse: parseBool,
|
|
2672
|
+
sdkKey: "skipTrial"
|
|
2673
|
+
},
|
|
2674
|
+
{
|
|
2675
|
+
flag: "--name <name>",
|
|
2676
|
+
description: "Subscription name",
|
|
2677
|
+
sdkKey: "name"
|
|
2678
|
+
},
|
|
2679
|
+
{
|
|
2680
|
+
flag: "--start-date <date>",
|
|
2681
|
+
description: "Start date (ISO 8601)",
|
|
2682
|
+
sdkKey: "startDate"
|
|
2683
|
+
},
|
|
2684
|
+
{
|
|
2685
|
+
flag: "--success-url <url>",
|
|
2686
|
+
description: "Redirect URL after successful checkout",
|
|
2687
|
+
sdkKey: "successUrl"
|
|
2688
|
+
}
|
|
2689
|
+
],
|
|
2690
|
+
buildParams: (options) => {
|
|
2691
|
+
const params = {
|
|
2692
|
+
customerId: options.customerId
|
|
2693
|
+
};
|
|
2694
|
+
if (options.planCode) params.planCode = options.planCode;
|
|
2695
|
+
if (options.planId) params.planId = options.planId;
|
|
2696
|
+
if (options.billingInterval)
|
|
2697
|
+
params.billingInterval = options.billingInterval;
|
|
2698
|
+
if (options.initialSeats)
|
|
2699
|
+
params.initialSeats = parseJson(options.initialSeats);
|
|
2700
|
+
if (options.skipTrial) params.skipTrial = parseBool(options.skipTrial);
|
|
2701
|
+
if (options.name) params.name = options.name;
|
|
2702
|
+
if (options.startDate) params.startDate = options.startDate;
|
|
2703
|
+
if (options.successUrl) params.successUrl = options.successUrl;
|
|
2704
|
+
return params;
|
|
2705
|
+
}
|
|
2706
|
+
},
|
|
2707
|
+
"get-active": {
|
|
2708
|
+
method: "getActive",
|
|
2709
|
+
description: "Get the active subscription for a customer",
|
|
2710
|
+
params: [
|
|
2711
|
+
{
|
|
2712
|
+
flag: "--customer-id <id>",
|
|
2713
|
+
description: "Customer ID",
|
|
2714
|
+
required: true,
|
|
2715
|
+
sdkKey: "customerId"
|
|
2716
|
+
}
|
|
2717
|
+
]
|
|
2718
|
+
},
|
|
2719
|
+
cancel: {
|
|
2720
|
+
method: "cancel",
|
|
2721
|
+
description: "Cancel a subscription",
|
|
2722
|
+
params: [
|
|
2723
|
+
{
|
|
2724
|
+
flag: "--id <id>",
|
|
2725
|
+
description: "Subscription ID",
|
|
2726
|
+
required: true,
|
|
2727
|
+
sdkKey: "id"
|
|
2728
|
+
},
|
|
2729
|
+
{
|
|
2730
|
+
flag: "--reason <reason>",
|
|
2731
|
+
description: "Cancellation reason",
|
|
2732
|
+
sdkKey: "reason"
|
|
2733
|
+
},
|
|
2734
|
+
{
|
|
2735
|
+
flag: "--immediate <bool>",
|
|
2736
|
+
description: "Cancel immediately instead of at period end",
|
|
2737
|
+
parse: parseBool,
|
|
2738
|
+
sdkKey: "immediate"
|
|
2739
|
+
}
|
|
2740
|
+
]
|
|
2741
|
+
},
|
|
2742
|
+
uncancel: {
|
|
2743
|
+
method: "uncancel",
|
|
2744
|
+
description: "Revert a pending cancellation",
|
|
2745
|
+
params: [
|
|
2746
|
+
{
|
|
2747
|
+
flag: "--id <id>",
|
|
2748
|
+
description: "Subscription ID",
|
|
2749
|
+
required: true,
|
|
2750
|
+
sdkKey: "id"
|
|
2751
|
+
}
|
|
2752
|
+
]
|
|
2753
|
+
},
|
|
2754
|
+
"change-plan": {
|
|
2755
|
+
method: "changePlan",
|
|
2756
|
+
description: "Change subscription plan",
|
|
2757
|
+
params: [
|
|
2758
|
+
{
|
|
2759
|
+
flag: "--id <id>",
|
|
2760
|
+
description: "Subscription ID",
|
|
2761
|
+
required: true,
|
|
2762
|
+
sdkKey: "id"
|
|
2763
|
+
},
|
|
2764
|
+
{
|
|
2765
|
+
flag: "--new-plan-id <id>",
|
|
2766
|
+
description: "New plan ID",
|
|
2767
|
+
sdkKey: "newPlanId"
|
|
2768
|
+
},
|
|
2769
|
+
{
|
|
2770
|
+
flag: "--new-billing-interval <interval>",
|
|
2771
|
+
description: "New billing interval",
|
|
2772
|
+
sdkKey: "newBillingInterval"
|
|
2773
|
+
}
|
|
2774
|
+
]
|
|
2775
|
+
},
|
|
2776
|
+
list: {
|
|
2777
|
+
method: "list",
|
|
2778
|
+
description: "List subscriptions",
|
|
2779
|
+
params: [
|
|
2780
|
+
{
|
|
2781
|
+
flag: "--customer-id <id>",
|
|
2782
|
+
description: "Filter by customer ID",
|
|
2783
|
+
sdkKey: "customerId"
|
|
2784
|
+
},
|
|
2785
|
+
{
|
|
2786
|
+
flag: "--status <status>",
|
|
2787
|
+
description: "Filter by status",
|
|
2788
|
+
sdkKey: "status"
|
|
2789
|
+
},
|
|
2790
|
+
{
|
|
2791
|
+
flag: "--limit <n>",
|
|
2792
|
+
description: "Max results",
|
|
2793
|
+
parse: parseNumber,
|
|
2794
|
+
sdkKey: "limit"
|
|
2795
|
+
},
|
|
2796
|
+
{
|
|
2797
|
+
flag: "--cursor <cursor>",
|
|
2798
|
+
description: "Pagination cursor",
|
|
2799
|
+
sdkKey: "cursor"
|
|
2800
|
+
}
|
|
2801
|
+
]
|
|
2802
|
+
},
|
|
2803
|
+
"preview-change": {
|
|
2804
|
+
method: "previewChange",
|
|
2805
|
+
description: "Preview plan change proration without applying",
|
|
2806
|
+
params: [
|
|
2807
|
+
{
|
|
2808
|
+
flag: "--id <id>",
|
|
2809
|
+
description: "Subscription ID",
|
|
2810
|
+
required: true,
|
|
2811
|
+
sdkKey: "id"
|
|
2812
|
+
},
|
|
2813
|
+
{
|
|
2814
|
+
flag: "--plan-id <planId>",
|
|
2815
|
+
description: "New plan ID",
|
|
2816
|
+
sdkKey: "planId"
|
|
2817
|
+
},
|
|
2818
|
+
{
|
|
2819
|
+
flag: "--billing-interval <interval>",
|
|
2820
|
+
description: "New billing interval",
|
|
2821
|
+
sdkKey: "billingInterval"
|
|
2822
|
+
}
|
|
2823
|
+
]
|
|
2824
|
+
},
|
|
2825
|
+
"activate-addon": {
|
|
2826
|
+
method: "activateAddon",
|
|
2827
|
+
description: "Activate an addon on a subscription",
|
|
2828
|
+
params: [
|
|
2829
|
+
{
|
|
2830
|
+
flag: "--id <id>",
|
|
2831
|
+
description: "Subscription ID",
|
|
2832
|
+
required: true,
|
|
2833
|
+
sdkKey: "id"
|
|
2834
|
+
},
|
|
2835
|
+
{
|
|
2836
|
+
flag: "--addon-id <addonId>",
|
|
2837
|
+
description: "Addon ID",
|
|
2838
|
+
required: true,
|
|
2839
|
+
sdkKey: "addonId"
|
|
2840
|
+
}
|
|
2841
|
+
]
|
|
2842
|
+
},
|
|
2843
|
+
"deactivate-addon": {
|
|
2844
|
+
method: "deactivateAddon",
|
|
2845
|
+
description: "Deactivate an addon from a subscription",
|
|
2846
|
+
params: [
|
|
2847
|
+
{
|
|
2848
|
+
flag: "--id <id>",
|
|
2849
|
+
description: "Subscription ID",
|
|
2850
|
+
required: true,
|
|
2851
|
+
sdkKey: "id"
|
|
2852
|
+
},
|
|
2853
|
+
{
|
|
2854
|
+
flag: "--addon-id <addonId>",
|
|
2855
|
+
description: "Addon ID",
|
|
2856
|
+
required: true,
|
|
2857
|
+
sdkKey: "addonId"
|
|
2858
|
+
}
|
|
2859
|
+
]
|
|
2860
|
+
},
|
|
2861
|
+
"adjust-balance": {
|
|
2862
|
+
method: "adjustBalance",
|
|
2863
|
+
description: "Adjust subscription balance or credits",
|
|
2864
|
+
params: [
|
|
2865
|
+
{
|
|
2866
|
+
flag: "--id <id>",
|
|
2867
|
+
description: "Subscription ID",
|
|
2868
|
+
required: true,
|
|
2869
|
+
sdkKey: "id"
|
|
2870
|
+
},
|
|
2871
|
+
{
|
|
2872
|
+
flag: "--amount <amount>",
|
|
2873
|
+
description: "Amount (positive adds, negative subtracts)",
|
|
2874
|
+
required: true,
|
|
2875
|
+
parse: parseNumber,
|
|
2876
|
+
sdkKey: "amount"
|
|
2877
|
+
},
|
|
2878
|
+
{
|
|
2879
|
+
flag: "--reason <reason>",
|
|
2880
|
+
description: "Reason for adjustment",
|
|
2881
|
+
sdkKey: "reason"
|
|
2882
|
+
},
|
|
2883
|
+
{
|
|
2884
|
+
flag: "--type <type>",
|
|
2885
|
+
description: "Adjustment type: balance or credits",
|
|
2886
|
+
sdkKey: "type"
|
|
2887
|
+
}
|
|
2888
|
+
]
|
|
2889
|
+
},
|
|
2890
|
+
"topup-balance": {
|
|
2891
|
+
method: "topupBalance",
|
|
2892
|
+
description: "Top up subscription balance (charges payment method)",
|
|
2893
|
+
params: [
|
|
2894
|
+
{
|
|
2895
|
+
flag: "--id <id>",
|
|
2896
|
+
description: "Subscription ID",
|
|
2897
|
+
required: true,
|
|
2898
|
+
sdkKey: "id"
|
|
2899
|
+
},
|
|
2900
|
+
{
|
|
2901
|
+
flag: "--amount <amount>",
|
|
2902
|
+
description: "Amount to top up",
|
|
2903
|
+
required: true,
|
|
2904
|
+
parse: parseNumber,
|
|
2905
|
+
sdkKey: "amount"
|
|
2906
|
+
}
|
|
2907
|
+
]
|
|
2908
|
+
},
|
|
2909
|
+
"purchase-credits": {
|
|
2910
|
+
method: "purchaseCredits",
|
|
2911
|
+
description: "Purchase a credit pack for a subscription",
|
|
2912
|
+
params: [
|
|
2913
|
+
{
|
|
2914
|
+
flag: "--id <id>",
|
|
2915
|
+
description: "Subscription ID",
|
|
2916
|
+
required: true,
|
|
2917
|
+
sdkKey: "id"
|
|
2918
|
+
},
|
|
2919
|
+
{
|
|
2920
|
+
flag: "--credit-pack-id <creditPackId>",
|
|
2921
|
+
description: "Credit pack ID",
|
|
2922
|
+
required: true,
|
|
2923
|
+
sdkKey: "creditPackId"
|
|
2924
|
+
}
|
|
2925
|
+
]
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
};
|
|
2929
|
+
var plansResource = {
|
|
2930
|
+
name: "plans",
|
|
2931
|
+
description: "Manage plans",
|
|
2932
|
+
sdkProperty: "plans",
|
|
2933
|
+
actions: {
|
|
2934
|
+
list: {
|
|
2935
|
+
method: "list",
|
|
2936
|
+
description: "List plans",
|
|
2937
|
+
params: [
|
|
2938
|
+
{
|
|
2939
|
+
flag: "--include-private <bool>",
|
|
2940
|
+
description: "Include private plans",
|
|
2941
|
+
parse: parseBool,
|
|
2942
|
+
sdkKey: "includePrivate"
|
|
2943
|
+
},
|
|
2944
|
+
{
|
|
2945
|
+
flag: "--limit <n>",
|
|
2946
|
+
description: "Max results",
|
|
2947
|
+
parse: parseNumber,
|
|
2948
|
+
sdkKey: "limit"
|
|
2949
|
+
},
|
|
2950
|
+
{
|
|
2951
|
+
flag: "--cursor <cursor>",
|
|
2952
|
+
description: "Pagination cursor",
|
|
2953
|
+
sdkKey: "cursor"
|
|
2954
|
+
}
|
|
2955
|
+
]
|
|
2956
|
+
},
|
|
2957
|
+
get: {
|
|
2958
|
+
method: "get",
|
|
2959
|
+
description: "Get plan details",
|
|
2960
|
+
params: [
|
|
2961
|
+
{
|
|
2962
|
+
flag: "--id <id>",
|
|
2963
|
+
description: "Plan ID",
|
|
2964
|
+
required: true,
|
|
2965
|
+
sdkKey: "id"
|
|
2966
|
+
}
|
|
2967
|
+
]
|
|
2968
|
+
},
|
|
2969
|
+
create: {
|
|
2970
|
+
method: "create",
|
|
2971
|
+
description: "Create a plan",
|
|
2972
|
+
params: [
|
|
2973
|
+
{
|
|
2974
|
+
flag: "--name <name>",
|
|
2975
|
+
description: "Plan name",
|
|
2976
|
+
required: true,
|
|
2977
|
+
sdkKey: "name"
|
|
2978
|
+
},
|
|
2979
|
+
{
|
|
2980
|
+
flag: "--code <code>",
|
|
2981
|
+
description: "Plan code",
|
|
2982
|
+
required: true,
|
|
2983
|
+
sdkKey: "code"
|
|
2984
|
+
},
|
|
2985
|
+
{
|
|
2986
|
+
flag: "--description <desc>",
|
|
2987
|
+
description: "Plan description",
|
|
2988
|
+
sdkKey: "description"
|
|
2989
|
+
},
|
|
2990
|
+
{
|
|
2991
|
+
flag: "--consumption-model <model>",
|
|
2992
|
+
description: "Consumption model: metered, credits, or balance",
|
|
2993
|
+
sdkKey: "consumptionModel"
|
|
2994
|
+
},
|
|
2995
|
+
{
|
|
2996
|
+
flag: "--is-public <bool>",
|
|
2997
|
+
description: "Whether plan is publicly visible",
|
|
2998
|
+
parse: parseBool,
|
|
2999
|
+
sdkKey: "isPublic"
|
|
3000
|
+
},
|
|
3001
|
+
{
|
|
3002
|
+
flag: "--is-free <bool>",
|
|
3003
|
+
description: "Whether plan is free",
|
|
3004
|
+
parse: parseBool,
|
|
3005
|
+
sdkKey: "isFree"
|
|
3006
|
+
},
|
|
3007
|
+
{
|
|
3008
|
+
flag: "--block-on-exhaustion <bool>",
|
|
3009
|
+
description: "Block usage when balance/credits exhausted",
|
|
3010
|
+
parse: parseBool,
|
|
3011
|
+
sdkKey: "blockOnExhaustion"
|
|
3012
|
+
},
|
|
3013
|
+
{
|
|
3014
|
+
flag: "--plan-group-id <id>",
|
|
3015
|
+
description: "Plan group ID",
|
|
3016
|
+
sdkKey: "planGroupId"
|
|
3017
|
+
},
|
|
3018
|
+
{
|
|
3019
|
+
flag: "--metadata <json>",
|
|
3020
|
+
description: "Metadata (JSON)",
|
|
3021
|
+
parse: parseJson,
|
|
3022
|
+
sdkKey: "metadata"
|
|
3023
|
+
}
|
|
3024
|
+
]
|
|
3025
|
+
},
|
|
3026
|
+
update: {
|
|
3027
|
+
method: "update",
|
|
3028
|
+
description: "Update a plan",
|
|
3029
|
+
params: [
|
|
3030
|
+
{
|
|
3031
|
+
flag: "--id <id>",
|
|
3032
|
+
description: "Plan ID",
|
|
3033
|
+
required: true,
|
|
3034
|
+
sdkKey: "id"
|
|
3035
|
+
},
|
|
3036
|
+
{
|
|
3037
|
+
flag: "--name <name>",
|
|
3038
|
+
description: "Plan name",
|
|
3039
|
+
sdkKey: "name"
|
|
3040
|
+
},
|
|
3041
|
+
{
|
|
3042
|
+
flag: "--description <desc>",
|
|
3043
|
+
description: "Plan description",
|
|
3044
|
+
sdkKey: "description"
|
|
3045
|
+
},
|
|
3046
|
+
{
|
|
3047
|
+
flag: "--metadata <json>",
|
|
3048
|
+
description: "Metadata (JSON)",
|
|
3049
|
+
parse: parseJson,
|
|
3050
|
+
sdkKey: "metadata"
|
|
3051
|
+
},
|
|
3052
|
+
{
|
|
3053
|
+
flag: "--is-public <bool>",
|
|
3054
|
+
description: "Whether plan is publicly visible",
|
|
3055
|
+
parse: parseBool,
|
|
3056
|
+
sdkKey: "isPublic"
|
|
3057
|
+
}
|
|
3058
|
+
]
|
|
3059
|
+
},
|
|
3060
|
+
delete: {
|
|
3061
|
+
method: "delete",
|
|
3062
|
+
description: "Delete a plan",
|
|
3063
|
+
params: [
|
|
3064
|
+
{
|
|
3065
|
+
flag: "--id <id>",
|
|
3066
|
+
description: "Plan ID",
|
|
3067
|
+
required: true,
|
|
3068
|
+
sdkKey: "id"
|
|
3069
|
+
}
|
|
3070
|
+
]
|
|
3071
|
+
},
|
|
3072
|
+
"set-visibility": {
|
|
3073
|
+
method: "setVisibility",
|
|
3074
|
+
description: "Set plan visibility",
|
|
3075
|
+
params: [
|
|
3076
|
+
{
|
|
3077
|
+
flag: "--id <id>",
|
|
3078
|
+
description: "Plan ID",
|
|
3079
|
+
required: true,
|
|
3080
|
+
sdkKey: "id"
|
|
3081
|
+
},
|
|
3082
|
+
{
|
|
3083
|
+
flag: "--is-public <bool>",
|
|
3084
|
+
description: "Public visibility",
|
|
3085
|
+
required: true,
|
|
3086
|
+
parse: parseBool,
|
|
3087
|
+
sdkKey: "isPublic"
|
|
3088
|
+
}
|
|
3089
|
+
]
|
|
3090
|
+
},
|
|
3091
|
+
"add-feature": {
|
|
3092
|
+
method: "addFeature",
|
|
3093
|
+
description: "Add a feature to a plan",
|
|
3094
|
+
params: [
|
|
3095
|
+
{
|
|
3096
|
+
flag: "--plan-id <id>",
|
|
3097
|
+
description: "Plan ID",
|
|
3098
|
+
required: true,
|
|
3099
|
+
sdkKey: "planId"
|
|
3100
|
+
},
|
|
3101
|
+
{
|
|
3102
|
+
flag: "--feature-id <id>",
|
|
3103
|
+
description: "Feature ID",
|
|
3104
|
+
required: true,
|
|
3105
|
+
sdkKey: "featureId"
|
|
3106
|
+
},
|
|
3107
|
+
{
|
|
3108
|
+
flag: "--enabled <bool>",
|
|
3109
|
+
description: "Whether feature is enabled",
|
|
3110
|
+
parse: parseBool,
|
|
3111
|
+
sdkKey: "enabled"
|
|
3112
|
+
},
|
|
3113
|
+
{
|
|
3114
|
+
flag: "--included-amount <n>",
|
|
3115
|
+
description: "Included amount",
|
|
3116
|
+
parse: parseNumber,
|
|
3117
|
+
sdkKey: "includedAmount"
|
|
3118
|
+
},
|
|
3119
|
+
{
|
|
3120
|
+
flag: "--unlimited <bool>",
|
|
3121
|
+
description: "Whether usage is unlimited",
|
|
3122
|
+
parse: parseBool,
|
|
3123
|
+
sdkKey: "unlimited"
|
|
3124
|
+
},
|
|
3125
|
+
{
|
|
3126
|
+
flag: "--overage-enabled <bool>",
|
|
3127
|
+
description: "Whether overage is enabled",
|
|
3128
|
+
parse: parseBool,
|
|
3129
|
+
sdkKey: "overageEnabled"
|
|
3130
|
+
},
|
|
3131
|
+
{
|
|
3132
|
+
flag: "--overage-unit-price <n>",
|
|
3133
|
+
description: "Overage unit price (fixed pricing)",
|
|
3134
|
+
parse: parseNumber,
|
|
3135
|
+
sdkKey: "overageUnitPrice"
|
|
3136
|
+
},
|
|
3137
|
+
{
|
|
3138
|
+
flag: "--pricing-mode <mode>",
|
|
3139
|
+
description: "Pricing mode: fixed or ai_model",
|
|
3140
|
+
sdkKey: "pricingMode"
|
|
3141
|
+
},
|
|
3142
|
+
{
|
|
3143
|
+
flag: "--margin <n>",
|
|
3144
|
+
description: "Margin percentage (ai_model pricing)",
|
|
3145
|
+
parse: parseNumber,
|
|
3146
|
+
sdkKey: "margin"
|
|
3147
|
+
},
|
|
3148
|
+
{
|
|
3149
|
+
flag: "--credits-per-unit <n>",
|
|
3150
|
+
description: "Credits per unit",
|
|
3151
|
+
parse: parseNumber,
|
|
3152
|
+
sdkKey: "creditsPerUnit"
|
|
3153
|
+
}
|
|
3154
|
+
]
|
|
3155
|
+
},
|
|
3156
|
+
"update-feature": {
|
|
3157
|
+
method: "updateFeature",
|
|
3158
|
+
description: "Update a feature on a plan",
|
|
3159
|
+
params: [
|
|
3160
|
+
{
|
|
3161
|
+
flag: "--plan-id <id>",
|
|
3162
|
+
description: "Plan ID",
|
|
3163
|
+
required: true,
|
|
3164
|
+
sdkKey: "planId"
|
|
3165
|
+
},
|
|
3166
|
+
{
|
|
3167
|
+
flag: "--feature-id <id>",
|
|
3168
|
+
description: "Feature ID",
|
|
3169
|
+
required: true,
|
|
3170
|
+
sdkKey: "featureId"
|
|
3171
|
+
},
|
|
3172
|
+
{
|
|
3173
|
+
flag: "--enabled <bool>",
|
|
3174
|
+
description: "Whether feature is enabled",
|
|
3175
|
+
parse: parseBool,
|
|
3176
|
+
sdkKey: "enabled"
|
|
3177
|
+
},
|
|
3178
|
+
{
|
|
3179
|
+
flag: "--included-amount <n>",
|
|
3180
|
+
description: "Included amount",
|
|
3181
|
+
parse: parseNumber,
|
|
3182
|
+
sdkKey: "includedAmount"
|
|
3183
|
+
},
|
|
3184
|
+
{
|
|
3185
|
+
flag: "--unlimited <bool>",
|
|
3186
|
+
description: "Whether usage is unlimited",
|
|
3187
|
+
parse: parseBool,
|
|
3188
|
+
sdkKey: "unlimited"
|
|
3189
|
+
},
|
|
3190
|
+
{
|
|
3191
|
+
flag: "--overage-enabled <bool>",
|
|
3192
|
+
description: "Whether overage is enabled",
|
|
3193
|
+
parse: parseBool,
|
|
3194
|
+
sdkKey: "overageEnabled"
|
|
3195
|
+
},
|
|
3196
|
+
{
|
|
3197
|
+
flag: "--overage-unit-price <n>",
|
|
3198
|
+
description: "Overage unit price (fixed pricing)",
|
|
3199
|
+
parse: parseNumber,
|
|
3200
|
+
sdkKey: "overageUnitPrice"
|
|
3201
|
+
},
|
|
3202
|
+
{
|
|
3203
|
+
flag: "--pricing-mode <mode>",
|
|
3204
|
+
description: "Pricing mode: fixed or ai_model",
|
|
3205
|
+
sdkKey: "pricingMode"
|
|
3206
|
+
},
|
|
3207
|
+
{
|
|
3208
|
+
flag: "--margin <n>",
|
|
3209
|
+
description: "Margin percentage (ai_model pricing)",
|
|
3210
|
+
parse: parseNumber,
|
|
3211
|
+
sdkKey: "margin"
|
|
3212
|
+
},
|
|
3213
|
+
{
|
|
3214
|
+
flag: "--credits-per-unit <n>",
|
|
3215
|
+
description: "Credits per unit",
|
|
3216
|
+
parse: parseNumber,
|
|
3217
|
+
sdkKey: "creditsPerUnit"
|
|
3218
|
+
}
|
|
3219
|
+
]
|
|
3220
|
+
},
|
|
3221
|
+
"remove-feature": {
|
|
3222
|
+
method: "removeFeature",
|
|
3223
|
+
description: "Remove a feature from a plan",
|
|
3224
|
+
params: [
|
|
3225
|
+
{
|
|
3226
|
+
flag: "--plan-id <id>",
|
|
3227
|
+
description: "Plan ID",
|
|
3228
|
+
required: true,
|
|
3229
|
+
sdkKey: "planId"
|
|
3230
|
+
},
|
|
3231
|
+
{
|
|
3232
|
+
flag: "--feature-id <id>",
|
|
3233
|
+
description: "Feature ID",
|
|
3234
|
+
required: true,
|
|
3235
|
+
sdkKey: "featureId"
|
|
3236
|
+
}
|
|
3237
|
+
]
|
|
3238
|
+
},
|
|
3239
|
+
"add-price": {
|
|
3240
|
+
method: "addPrice",
|
|
3241
|
+
description: "Add a price to a plan",
|
|
3242
|
+
params: [
|
|
3243
|
+
{
|
|
3244
|
+
flag: "--plan-id <id>",
|
|
3245
|
+
description: "Plan ID",
|
|
3246
|
+
required: true,
|
|
3247
|
+
sdkKey: "planId"
|
|
3248
|
+
},
|
|
3249
|
+
{
|
|
3250
|
+
flag: "--billing-interval <interval>",
|
|
3251
|
+
description: "Billing interval: weekly, monthly, quarterly, yearly, one_time",
|
|
3252
|
+
required: true,
|
|
3253
|
+
sdkKey: "billingInterval"
|
|
3254
|
+
},
|
|
3255
|
+
{
|
|
3256
|
+
flag: "--price <n>",
|
|
3257
|
+
description: "Price in cents",
|
|
3258
|
+
required: true,
|
|
3259
|
+
parse: parseNumber,
|
|
3260
|
+
sdkKey: "price"
|
|
3261
|
+
},
|
|
3262
|
+
{
|
|
3263
|
+
flag: "--trial-days <n>",
|
|
3264
|
+
description: "Trial days",
|
|
3265
|
+
parse: parseNumber,
|
|
3266
|
+
sdkKey: "trialDays"
|
|
3267
|
+
},
|
|
3268
|
+
{
|
|
3269
|
+
flag: "--is-default <bool>",
|
|
3270
|
+
description: "Set as default price",
|
|
3271
|
+
parse: parseBool,
|
|
3272
|
+
sdkKey: "isDefault"
|
|
3273
|
+
},
|
|
3274
|
+
{
|
|
3275
|
+
flag: "--included-balance <n>",
|
|
3276
|
+
description: "Included balance",
|
|
3277
|
+
parse: parseNumber,
|
|
3278
|
+
sdkKey: "includedBalance"
|
|
3279
|
+
},
|
|
3280
|
+
{
|
|
3281
|
+
flag: "--included-credits <n>",
|
|
3282
|
+
description: "Included credits",
|
|
3283
|
+
parse: parseNumber,
|
|
3284
|
+
sdkKey: "includedCredits"
|
|
3285
|
+
},
|
|
3286
|
+
{
|
|
3287
|
+
flag: "--intro-offer-enabled <bool>",
|
|
3288
|
+
description: "Enable intro offer",
|
|
3289
|
+
parse: parseBool,
|
|
3290
|
+
sdkKey: "introOfferEnabled"
|
|
3291
|
+
},
|
|
3292
|
+
{
|
|
3293
|
+
flag: "--intro-offer-discount-type <type>",
|
|
3294
|
+
description: "Intro offer discount type: percentage or amount",
|
|
3295
|
+
sdkKey: "introOfferDiscountType"
|
|
3296
|
+
},
|
|
3297
|
+
{
|
|
3298
|
+
flag: "--intro-offer-discount-value <n>",
|
|
3299
|
+
description: "Intro offer discount value",
|
|
3300
|
+
parse: parseNumber,
|
|
3301
|
+
sdkKey: "introOfferDiscountValue"
|
|
3302
|
+
},
|
|
3303
|
+
{
|
|
3304
|
+
flag: "--intro-offer-duration-cycles <n>",
|
|
3305
|
+
description: "Intro offer duration in cycles",
|
|
3306
|
+
parse: parseNumber,
|
|
3307
|
+
sdkKey: "introOfferDurationCycles"
|
|
3308
|
+
}
|
|
3309
|
+
]
|
|
3310
|
+
},
|
|
3311
|
+
"update-price": {
|
|
3312
|
+
method: "updatePrice",
|
|
3313
|
+
description: "Update a plan price",
|
|
3314
|
+
params: [
|
|
3315
|
+
{
|
|
3316
|
+
flag: "--plan-id <id>",
|
|
3317
|
+
description: "Plan ID",
|
|
3318
|
+
required: true,
|
|
3319
|
+
sdkKey: "planId"
|
|
3320
|
+
},
|
|
3321
|
+
{
|
|
3322
|
+
flag: "--price-id <id>",
|
|
3323
|
+
description: "Price ID",
|
|
3324
|
+
required: true,
|
|
3325
|
+
sdkKey: "priceId"
|
|
3326
|
+
},
|
|
3327
|
+
{
|
|
3328
|
+
flag: "--price <n>",
|
|
3329
|
+
description: "Price in cents",
|
|
3330
|
+
parse: parseNumber,
|
|
3331
|
+
sdkKey: "price"
|
|
3332
|
+
},
|
|
3333
|
+
{
|
|
3334
|
+
flag: "--is-default <bool>",
|
|
3335
|
+
description: "Set as default price",
|
|
3336
|
+
parse: parseBool,
|
|
3337
|
+
sdkKey: "isDefault"
|
|
3338
|
+
},
|
|
3339
|
+
{
|
|
3340
|
+
flag: "--trial-days <n>",
|
|
3341
|
+
description: "Trial days",
|
|
3342
|
+
parse: parseNumber,
|
|
3343
|
+
sdkKey: "trialDays"
|
|
3344
|
+
},
|
|
3345
|
+
{
|
|
3346
|
+
flag: "--included-balance <n>",
|
|
3347
|
+
description: "Included balance",
|
|
3348
|
+
parse: parseNumber,
|
|
3349
|
+
sdkKey: "includedBalance"
|
|
3350
|
+
},
|
|
3351
|
+
{
|
|
3352
|
+
flag: "--included-credits <n>",
|
|
3353
|
+
description: "Included credits",
|
|
3354
|
+
parse: parseNumber,
|
|
3355
|
+
sdkKey: "includedCredits"
|
|
3356
|
+
},
|
|
3357
|
+
{
|
|
3358
|
+
flag: "--intro-offer-enabled <bool>",
|
|
3359
|
+
description: "Enable intro offer",
|
|
3360
|
+
parse: parseBool,
|
|
3361
|
+
sdkKey: "introOfferEnabled"
|
|
3362
|
+
},
|
|
3363
|
+
{
|
|
3364
|
+
flag: "--intro-offer-discount-type <type>",
|
|
3365
|
+
description: "Intro offer discount type: percentage or amount",
|
|
3366
|
+
sdkKey: "introOfferDiscountType"
|
|
3367
|
+
},
|
|
3368
|
+
{
|
|
3369
|
+
flag: "--intro-offer-discount-value <n>",
|
|
3370
|
+
description: "Intro offer discount value",
|
|
3371
|
+
parse: parseNumber,
|
|
3372
|
+
sdkKey: "introOfferDiscountValue"
|
|
3373
|
+
},
|
|
3374
|
+
{
|
|
3375
|
+
flag: "--intro-offer-duration-cycles <n>",
|
|
3376
|
+
description: "Intro offer duration in cycles",
|
|
3377
|
+
parse: parseNumber,
|
|
3378
|
+
sdkKey: "introOfferDurationCycles"
|
|
3379
|
+
}
|
|
3380
|
+
]
|
|
3381
|
+
},
|
|
3382
|
+
"delete-price": {
|
|
3383
|
+
method: "deletePrice",
|
|
3384
|
+
description: "Delete a plan price",
|
|
3385
|
+
params: [
|
|
3386
|
+
{
|
|
3387
|
+
flag: "--plan-id <id>",
|
|
3388
|
+
description: "Plan ID",
|
|
3389
|
+
required: true,
|
|
3390
|
+
sdkKey: "planId"
|
|
3391
|
+
},
|
|
3392
|
+
{
|
|
3393
|
+
flag: "--price-id <id>",
|
|
3394
|
+
description: "Price ID",
|
|
3395
|
+
required: true,
|
|
3396
|
+
sdkKey: "priceId"
|
|
3397
|
+
}
|
|
3398
|
+
]
|
|
3399
|
+
},
|
|
3400
|
+
"set-default-price": {
|
|
3401
|
+
method: "setDefaultPrice",
|
|
3402
|
+
description: "Set a price as the default for a plan",
|
|
3403
|
+
params: [
|
|
3404
|
+
{
|
|
3405
|
+
flag: "--plan-id <id>",
|
|
3406
|
+
description: "Plan ID",
|
|
3407
|
+
required: true,
|
|
3408
|
+
sdkKey: "planId"
|
|
3409
|
+
},
|
|
3410
|
+
{
|
|
3411
|
+
flag: "--price-id <id>",
|
|
3412
|
+
description: "Price ID",
|
|
3413
|
+
required: true,
|
|
3414
|
+
sdkKey: "priceId"
|
|
3415
|
+
}
|
|
3416
|
+
]
|
|
3417
|
+
},
|
|
3418
|
+
"set-regional-prices": {
|
|
3419
|
+
method: "setRegionalPrices",
|
|
3420
|
+
description: "Set regional price overrides",
|
|
3421
|
+
params: [
|
|
3422
|
+
{
|
|
3423
|
+
flag: "--plan-id <id>",
|
|
3424
|
+
description: "Plan ID",
|
|
3425
|
+
required: true,
|
|
3426
|
+
sdkKey: "planId"
|
|
3427
|
+
},
|
|
3428
|
+
{
|
|
3429
|
+
flag: "--price-id <id>",
|
|
3430
|
+
description: "Price ID",
|
|
3431
|
+
required: true,
|
|
3432
|
+
sdkKey: "priceId"
|
|
3433
|
+
},
|
|
3434
|
+
{
|
|
3435
|
+
flag: "--overrides <json>",
|
|
3436
|
+
description: 'Regional overrides (JSON: [{currency: "EUR", price: 900}])',
|
|
3437
|
+
required: true,
|
|
3438
|
+
parse: parseJson,
|
|
3439
|
+
sdkKey: "overrides"
|
|
3440
|
+
}
|
|
3441
|
+
]
|
|
3442
|
+
},
|
|
3443
|
+
"delete-regional-prices": {
|
|
3444
|
+
method: "deleteRegionalPrices",
|
|
3445
|
+
description: "Delete regional price overrides",
|
|
3446
|
+
params: [
|
|
3447
|
+
{
|
|
3448
|
+
flag: "--plan-id <id>",
|
|
3449
|
+
description: "Plan ID",
|
|
3450
|
+
required: true,
|
|
3451
|
+
sdkKey: "planId"
|
|
3452
|
+
},
|
|
3453
|
+
{
|
|
3454
|
+
flag: "--price-id <id>",
|
|
3455
|
+
description: "Price ID",
|
|
3456
|
+
required: true,
|
|
3457
|
+
sdkKey: "priceId"
|
|
3458
|
+
}
|
|
3459
|
+
]
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
};
|
|
3463
|
+
var featuresResource = {
|
|
3464
|
+
name: "features",
|
|
3465
|
+
description: "Manage features and check feature access",
|
|
3466
|
+
sdkProperty: "features",
|
|
3467
|
+
actions: {
|
|
3468
|
+
get: {
|
|
3469
|
+
method: "get",
|
|
3470
|
+
description: "Get feature access for a customer",
|
|
3471
|
+
params: [
|
|
3472
|
+
{
|
|
3473
|
+
flag: "--customer-id <id>",
|
|
3474
|
+
description: "Customer ID",
|
|
3475
|
+
required: true,
|
|
3476
|
+
sdkKey: "customerId"
|
|
3477
|
+
},
|
|
3478
|
+
{
|
|
3479
|
+
flag: "--code <code>",
|
|
3480
|
+
description: "Feature code",
|
|
3481
|
+
required: true,
|
|
3482
|
+
sdkKey: "code"
|
|
3483
|
+
}
|
|
3484
|
+
]
|
|
3485
|
+
},
|
|
3486
|
+
"can-use": {
|
|
3487
|
+
method: "canUse",
|
|
3488
|
+
description: "Check if a customer can use a feature",
|
|
3489
|
+
params: [
|
|
3490
|
+
{
|
|
3491
|
+
flag: "--customer-id <id>",
|
|
3492
|
+
description: "Customer ID",
|
|
3493
|
+
required: true,
|
|
3494
|
+
sdkKey: "customerId"
|
|
3495
|
+
},
|
|
3496
|
+
{
|
|
3497
|
+
flag: "--code <code>",
|
|
3498
|
+
description: "Feature code",
|
|
3499
|
+
required: true,
|
|
3500
|
+
sdkKey: "code"
|
|
3501
|
+
}
|
|
3502
|
+
]
|
|
3503
|
+
},
|
|
3504
|
+
list: {
|
|
3505
|
+
method: "list",
|
|
3506
|
+
description: "List features for a customer",
|
|
3507
|
+
params: [
|
|
3508
|
+
{
|
|
3509
|
+
flag: "--customer-id <id>",
|
|
3510
|
+
description: "Customer ID",
|
|
3511
|
+
required: true,
|
|
3512
|
+
sdkKey: "customerId"
|
|
3513
|
+
}
|
|
3514
|
+
]
|
|
3515
|
+
},
|
|
3516
|
+
create: {
|
|
3517
|
+
method: "create",
|
|
3518
|
+
description: "Create a feature",
|
|
3519
|
+
params: [
|
|
3520
|
+
{
|
|
3521
|
+
flag: "--code <code>",
|
|
3522
|
+
description: "Feature code",
|
|
3523
|
+
required: true,
|
|
3524
|
+
sdkKey: "code"
|
|
3525
|
+
},
|
|
3526
|
+
{
|
|
3527
|
+
flag: "--name <name>",
|
|
3528
|
+
description: "Feature name",
|
|
3529
|
+
required: true,
|
|
3530
|
+
sdkKey: "name"
|
|
3531
|
+
},
|
|
3532
|
+
{
|
|
3533
|
+
flag: "--type <type>",
|
|
3534
|
+
description: "Feature type: boolean, usage, or seats",
|
|
3535
|
+
required: true,
|
|
3536
|
+
sdkKey: "type"
|
|
3537
|
+
},
|
|
3538
|
+
{
|
|
3539
|
+
flag: "--description <desc>",
|
|
3540
|
+
description: "Feature description",
|
|
3541
|
+
sdkKey: "description"
|
|
3542
|
+
},
|
|
3543
|
+
{
|
|
3544
|
+
flag: "--unit-name <name>",
|
|
3545
|
+
description: "Unit name for metered features",
|
|
3546
|
+
sdkKey: "unitName"
|
|
3547
|
+
}
|
|
3548
|
+
]
|
|
3549
|
+
},
|
|
3550
|
+
update: {
|
|
3551
|
+
method: "update",
|
|
3552
|
+
description: "Update a feature",
|
|
3553
|
+
params: [
|
|
3554
|
+
{
|
|
3555
|
+
flag: "--code <code>",
|
|
3556
|
+
description: "Feature code",
|
|
3557
|
+
required: true,
|
|
3558
|
+
sdkKey: "code"
|
|
3559
|
+
},
|
|
3560
|
+
{
|
|
3561
|
+
flag: "--name <name>",
|
|
3562
|
+
description: "Feature name",
|
|
3563
|
+
sdkKey: "name"
|
|
3564
|
+
},
|
|
3565
|
+
{
|
|
3566
|
+
flag: "--description <desc>",
|
|
3567
|
+
description: "Feature description",
|
|
3568
|
+
sdkKey: "description"
|
|
3569
|
+
},
|
|
3570
|
+
{
|
|
3571
|
+
flag: "--unit-name <name>",
|
|
3572
|
+
description: "Unit name",
|
|
3573
|
+
sdkKey: "unitName"
|
|
3574
|
+
}
|
|
3575
|
+
]
|
|
3576
|
+
},
|
|
3577
|
+
delete: {
|
|
3578
|
+
method: "delete",
|
|
3579
|
+
description: "Delete a feature",
|
|
3580
|
+
params: [
|
|
3581
|
+
{
|
|
3582
|
+
flag: "--code <code>",
|
|
3583
|
+
description: "Feature code",
|
|
3584
|
+
required: true,
|
|
3585
|
+
sdkKey: "code"
|
|
3586
|
+
}
|
|
3587
|
+
]
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
};
|
|
3591
|
+
var seatsResource = {
|
|
3592
|
+
name: "seats",
|
|
3593
|
+
description: "Manage seat allocations",
|
|
3594
|
+
sdkProperty: "seats",
|
|
3595
|
+
actions: {
|
|
3596
|
+
add: {
|
|
3597
|
+
method: "add",
|
|
3598
|
+
description: "Add seats for a customer",
|
|
3599
|
+
params: [
|
|
3600
|
+
{
|
|
3601
|
+
flag: "--customer-id <id>",
|
|
3602
|
+
description: "Customer ID",
|
|
3603
|
+
required: true,
|
|
3604
|
+
sdkKey: "customerId"
|
|
3605
|
+
},
|
|
3606
|
+
{
|
|
3607
|
+
flag: "--feature-code <code>",
|
|
3608
|
+
description: "Feature code",
|
|
3609
|
+
required: true,
|
|
3610
|
+
sdkKey: "featureCode"
|
|
3611
|
+
},
|
|
3612
|
+
{
|
|
3613
|
+
flag: "--count <n>",
|
|
3614
|
+
description: "Number of seats to add (defaults to 1)",
|
|
3615
|
+
parse: parseNumber,
|
|
3616
|
+
sdkKey: "count"
|
|
3617
|
+
}
|
|
3618
|
+
]
|
|
3619
|
+
},
|
|
3620
|
+
remove: {
|
|
3621
|
+
method: "remove",
|
|
3622
|
+
description: "Remove seats for a customer",
|
|
3623
|
+
params: [
|
|
3624
|
+
{
|
|
3625
|
+
flag: "--customer-id <id>",
|
|
3626
|
+
description: "Customer ID",
|
|
3627
|
+
required: true,
|
|
3628
|
+
sdkKey: "customerId"
|
|
3629
|
+
},
|
|
3630
|
+
{
|
|
3631
|
+
flag: "--feature-code <code>",
|
|
3632
|
+
description: "Feature code",
|
|
3633
|
+
required: true,
|
|
3634
|
+
sdkKey: "featureCode"
|
|
3635
|
+
},
|
|
3636
|
+
{
|
|
3637
|
+
flag: "--count <n>",
|
|
3638
|
+
description: "Number of seats to remove (defaults to 1)",
|
|
3639
|
+
parse: parseNumber,
|
|
3640
|
+
sdkKey: "count"
|
|
3641
|
+
}
|
|
3642
|
+
]
|
|
3643
|
+
},
|
|
3644
|
+
set: {
|
|
3645
|
+
method: "set",
|
|
3646
|
+
description: "Set exact seat count for a customer",
|
|
3647
|
+
params: [
|
|
3648
|
+
{
|
|
3649
|
+
flag: "--customer-id <id>",
|
|
3650
|
+
description: "Customer ID",
|
|
3651
|
+
required: true,
|
|
3652
|
+
sdkKey: "customerId"
|
|
3653
|
+
},
|
|
3654
|
+
{
|
|
3655
|
+
flag: "--feature-code <code>",
|
|
3656
|
+
description: "Feature code",
|
|
3657
|
+
required: true,
|
|
3658
|
+
sdkKey: "featureCode"
|
|
3659
|
+
},
|
|
3660
|
+
{
|
|
3661
|
+
flag: "--count <n>",
|
|
3662
|
+
description: "Exact seat count",
|
|
3663
|
+
required: true,
|
|
3664
|
+
parse: parseNumber,
|
|
3665
|
+
sdkKey: "count"
|
|
3666
|
+
}
|
|
3667
|
+
]
|
|
3668
|
+
},
|
|
3669
|
+
"set-all": {
|
|
3670
|
+
method: "setAll",
|
|
3671
|
+
description: "Set all seat counts for a customer at once",
|
|
3672
|
+
params: [
|
|
3673
|
+
{
|
|
3674
|
+
flag: "--customer-id <id>",
|
|
3675
|
+
description: "Customer ID",
|
|
3676
|
+
required: true,
|
|
3677
|
+
sdkKey: "customerId"
|
|
3678
|
+
},
|
|
3679
|
+
{
|
|
3680
|
+
flag: "--seats <json>",
|
|
3681
|
+
description: "Seats map (JSON: {featureCode: count})",
|
|
3682
|
+
required: true,
|
|
3683
|
+
parse: parseJson,
|
|
3684
|
+
sdkKey: "seats"
|
|
3685
|
+
}
|
|
3686
|
+
]
|
|
3687
|
+
},
|
|
3688
|
+
"get-balance": {
|
|
3689
|
+
method: "getBalance",
|
|
3690
|
+
description: "Get seat balance for a specific feature",
|
|
3691
|
+
params: [
|
|
3692
|
+
{
|
|
3693
|
+
flag: "--customer-id <id>",
|
|
3694
|
+
description: "Customer ID",
|
|
3695
|
+
required: true,
|
|
3696
|
+
sdkKey: "customerId"
|
|
3697
|
+
},
|
|
3698
|
+
{
|
|
3699
|
+
flag: "--feature-code <code>",
|
|
3700
|
+
description: "Feature code",
|
|
3701
|
+
required: true,
|
|
3702
|
+
sdkKey: "featureCode"
|
|
3703
|
+
}
|
|
3704
|
+
]
|
|
3705
|
+
},
|
|
3706
|
+
"get-all-balances": {
|
|
3707
|
+
method: "getAllBalances",
|
|
3708
|
+
description: "Get all seat balances for a customer",
|
|
3709
|
+
params: [
|
|
3710
|
+
{
|
|
3711
|
+
flag: "--customer-id <id>",
|
|
3712
|
+
description: "Customer ID",
|
|
3713
|
+
required: true,
|
|
3714
|
+
sdkKey: "customerId"
|
|
3715
|
+
}
|
|
3716
|
+
]
|
|
3717
|
+
}
|
|
3718
|
+
}
|
|
3719
|
+
};
|
|
3720
|
+
var usageResource = {
|
|
3721
|
+
name: "usage",
|
|
3722
|
+
description: "Track usage events",
|
|
3723
|
+
sdkProperty: "usage",
|
|
3724
|
+
actions: {
|
|
3725
|
+
track: {
|
|
3726
|
+
method: "track",
|
|
3727
|
+
description: "Track a usage event",
|
|
3728
|
+
params: [
|
|
3729
|
+
{
|
|
3730
|
+
flag: "--feature <code>",
|
|
3731
|
+
description: "Feature code",
|
|
3732
|
+
required: true,
|
|
3733
|
+
sdkKey: "feature"
|
|
3734
|
+
},
|
|
3735
|
+
{
|
|
3736
|
+
flag: "--customer-id <id>",
|
|
3737
|
+
description: "Customer ID",
|
|
3738
|
+
required: true,
|
|
3739
|
+
sdkKey: "customerId"
|
|
3740
|
+
},
|
|
3741
|
+
{
|
|
3742
|
+
flag: "--value <n>",
|
|
3743
|
+
description: "Usage value (standard tracking)",
|
|
3744
|
+
parse: parseNumber,
|
|
3745
|
+
sdkKey: "value"
|
|
3746
|
+
},
|
|
3747
|
+
{
|
|
3748
|
+
flag: "--model <model>",
|
|
3749
|
+
description: "AI model name (model token tracking)",
|
|
3750
|
+
sdkKey: "model"
|
|
3751
|
+
},
|
|
3752
|
+
{
|
|
3753
|
+
flag: "--input-tokens <n>",
|
|
3754
|
+
description: "Input tokens (model tracking)",
|
|
3755
|
+
parse: parseNumber,
|
|
3756
|
+
sdkKey: "inputTokens"
|
|
3757
|
+
},
|
|
3758
|
+
{
|
|
3759
|
+
flag: "--output-tokens <n>",
|
|
3760
|
+
description: "Output tokens (model tracking)",
|
|
3761
|
+
parse: parseNumber,
|
|
3762
|
+
sdkKey: "outputTokens"
|
|
3763
|
+
},
|
|
3764
|
+
{
|
|
3765
|
+
flag: "--cache-read-tokens <n>",
|
|
3766
|
+
description: "Cache read tokens (model tracking)",
|
|
3767
|
+
parse: parseNumber,
|
|
3768
|
+
sdkKey: "cacheReadTokens"
|
|
3769
|
+
},
|
|
3770
|
+
{
|
|
3771
|
+
flag: "--cache-write-tokens <n>",
|
|
3772
|
+
description: "Cache write tokens (model tracking)",
|
|
3773
|
+
parse: parseNumber,
|
|
3774
|
+
sdkKey: "cacheWriteTokens"
|
|
3775
|
+
},
|
|
3776
|
+
{
|
|
3777
|
+
flag: "--idempotency-key <key>",
|
|
3778
|
+
description: "Idempotency key for deduplication",
|
|
3779
|
+
sdkKey: "idempotencyKey"
|
|
3780
|
+
},
|
|
3781
|
+
{
|
|
3782
|
+
flag: "--timestamp <ts>",
|
|
3783
|
+
description: "Event timestamp (ISO 8601)",
|
|
3784
|
+
sdkKey: "timestamp"
|
|
3785
|
+
},
|
|
3786
|
+
{
|
|
3787
|
+
flag: "--properties <json>",
|
|
3788
|
+
description: "Event properties (JSON: {key: value})",
|
|
3789
|
+
parse: parseJson,
|
|
3790
|
+
sdkKey: "properties"
|
|
3791
|
+
}
|
|
3792
|
+
],
|
|
3793
|
+
buildParams: (options) => {
|
|
3794
|
+
const params = {
|
|
3795
|
+
feature: options.feature,
|
|
3796
|
+
customerId: options.customerId
|
|
3797
|
+
};
|
|
3798
|
+
if (options.idempotencyKey)
|
|
3799
|
+
params.idempotencyKey = options.idempotencyKey;
|
|
3800
|
+
if (options.timestamp) params.timestamp = options.timestamp;
|
|
3801
|
+
if (options.properties)
|
|
3802
|
+
params.properties = parseJson(options.properties);
|
|
3803
|
+
if (options.model) {
|
|
3804
|
+
params.model = options.model;
|
|
3805
|
+
params.inputTokens = parseNumber(options.inputTokens);
|
|
3806
|
+
params.outputTokens = parseNumber(options.outputTokens);
|
|
3807
|
+
if (options.cacheReadTokens)
|
|
3808
|
+
params.cacheReadTokens = parseNumber(options.cacheReadTokens);
|
|
3809
|
+
if (options.cacheWriteTokens)
|
|
3810
|
+
params.cacheWriteTokens = parseNumber(options.cacheWriteTokens);
|
|
3811
|
+
} else {
|
|
3812
|
+
if (options.value) params.value = parseNumber(options.value);
|
|
3813
|
+
}
|
|
3814
|
+
return params;
|
|
3815
|
+
}
|
|
3816
|
+
},
|
|
3817
|
+
check: {
|
|
3818
|
+
method: "check",
|
|
3819
|
+
description: "Check if a usage event would be allowed",
|
|
3820
|
+
params: [
|
|
3821
|
+
{
|
|
3822
|
+
flag: "--customer-id <id>",
|
|
3823
|
+
description: "Customer ID",
|
|
3824
|
+
required: true,
|
|
3825
|
+
sdkKey: "customerId"
|
|
3826
|
+
},
|
|
3827
|
+
{
|
|
3828
|
+
flag: "--feature-code <code>",
|
|
3829
|
+
description: "Feature code",
|
|
3830
|
+
required: true,
|
|
3831
|
+
sdkKey: "featureCode"
|
|
3832
|
+
},
|
|
3833
|
+
{
|
|
3834
|
+
flag: "--quantity <n>",
|
|
3835
|
+
description: "Quantity to check",
|
|
3836
|
+
required: true,
|
|
3837
|
+
parse: parseNumber,
|
|
3838
|
+
sdkKey: "quantity"
|
|
3839
|
+
}
|
|
3840
|
+
]
|
|
3841
|
+
}
|
|
3842
|
+
}
|
|
3843
|
+
};
|
|
3844
|
+
var portalResource = {
|
|
3845
|
+
name: "portal",
|
|
3846
|
+
description: "Customer portal access",
|
|
3847
|
+
sdkProperty: "portal",
|
|
3848
|
+
actions: {
|
|
3849
|
+
"get-url": {
|
|
3850
|
+
method: "getUrl",
|
|
3851
|
+
description: "Get a portal URL for a customer",
|
|
3852
|
+
params: [
|
|
3853
|
+
{
|
|
3854
|
+
flag: "--customer-id <id>",
|
|
3855
|
+
description: "Customer ID (provide this or --email)",
|
|
3856
|
+
sdkKey: "customerId"
|
|
3857
|
+
},
|
|
3858
|
+
{
|
|
3859
|
+
flag: "--email <email>",
|
|
3860
|
+
description: "Customer email (provide this or --customer-id)",
|
|
3861
|
+
sdkKey: "email"
|
|
3862
|
+
}
|
|
3863
|
+
],
|
|
3864
|
+
buildParams: (options) => {
|
|
3865
|
+
if (options.customerId) {
|
|
3866
|
+
return { customerId: options.customerId };
|
|
3867
|
+
}
|
|
3868
|
+
if (options.email) {
|
|
3869
|
+
return { email: options.email };
|
|
3870
|
+
}
|
|
3871
|
+
throw new Error("Either --customer-id or --email is required");
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
};
|
|
3876
|
+
var addonsResource = {
|
|
3877
|
+
name: "addons",
|
|
3878
|
+
description: "Manage addons",
|
|
3879
|
+
sdkProperty: "addons",
|
|
3880
|
+
actions: {
|
|
3881
|
+
"list-active": {
|
|
3882
|
+
method: "listActive",
|
|
3883
|
+
description: "List active addons for a customer",
|
|
3884
|
+
params: [
|
|
3885
|
+
{
|
|
3886
|
+
flag: "--customer-id <id>",
|
|
3887
|
+
description: "Customer ID",
|
|
3888
|
+
required: true,
|
|
3889
|
+
sdkKey: "customerId"
|
|
3890
|
+
}
|
|
3891
|
+
]
|
|
3892
|
+
},
|
|
3893
|
+
list: {
|
|
3894
|
+
method: "list",
|
|
3895
|
+
description: "List all addons",
|
|
3896
|
+
params: [
|
|
3897
|
+
{
|
|
3898
|
+
flag: "--limit <n>",
|
|
3899
|
+
description: "Max results",
|
|
3900
|
+
parse: parseNumber,
|
|
3901
|
+
sdkKey: "limit"
|
|
3902
|
+
},
|
|
3903
|
+
{
|
|
3904
|
+
flag: "--cursor <cursor>",
|
|
3905
|
+
description: "Pagination cursor",
|
|
3906
|
+
sdkKey: "cursor"
|
|
3907
|
+
}
|
|
3908
|
+
]
|
|
3909
|
+
},
|
|
3910
|
+
get: {
|
|
3911
|
+
method: "get",
|
|
3912
|
+
description: "Get addon details",
|
|
3913
|
+
params: [
|
|
3914
|
+
{
|
|
3915
|
+
flag: "--id <id>",
|
|
3916
|
+
description: "Addon ID",
|
|
3917
|
+
required: true,
|
|
3918
|
+
sdkKey: "id"
|
|
3919
|
+
}
|
|
3920
|
+
]
|
|
3921
|
+
},
|
|
3922
|
+
create: {
|
|
3923
|
+
method: "create",
|
|
3924
|
+
description: "Create an addon",
|
|
3925
|
+
params: [
|
|
3926
|
+
{
|
|
3927
|
+
flag: "--name <name>",
|
|
3928
|
+
description: "Addon name",
|
|
3929
|
+
required: true,
|
|
3930
|
+
sdkKey: "name"
|
|
3931
|
+
},
|
|
3932
|
+
{
|
|
3933
|
+
flag: "--base-price <n>",
|
|
3934
|
+
description: "Base price in cents",
|
|
3935
|
+
required: true,
|
|
3936
|
+
parse: parseNumber,
|
|
3937
|
+
sdkKey: "basePrice"
|
|
3938
|
+
},
|
|
3939
|
+
{
|
|
3940
|
+
flag: "--feature-id <id>",
|
|
3941
|
+
description: "Feature ID",
|
|
3942
|
+
required: true,
|
|
3943
|
+
sdkKey: "featureId"
|
|
3944
|
+
},
|
|
3945
|
+
{
|
|
3946
|
+
flag: "--consumption-model <model>",
|
|
3947
|
+
description: "Consumption model: boolean, metered, credits, or balance",
|
|
3948
|
+
required: true,
|
|
3949
|
+
sdkKey: "consumptionModel"
|
|
3950
|
+
},
|
|
3951
|
+
{
|
|
3952
|
+
flag: "--description <desc>",
|
|
3953
|
+
description: "Addon description",
|
|
3954
|
+
sdkKey: "description"
|
|
3955
|
+
},
|
|
3956
|
+
{
|
|
3957
|
+
flag: "--included-units <n>",
|
|
3958
|
+
description: "Included units (metered)",
|
|
3959
|
+
parse: parseNumber,
|
|
3960
|
+
sdkKey: "includedUnits"
|
|
3961
|
+
},
|
|
3962
|
+
{
|
|
3963
|
+
flag: "--overage-rate <n>",
|
|
3964
|
+
description: "Overage rate (metered/balance)",
|
|
3965
|
+
parse: parseNumber,
|
|
3966
|
+
sdkKey: "overageRate"
|
|
3967
|
+
},
|
|
3968
|
+
{
|
|
3969
|
+
flag: "--credit-cost <n>",
|
|
3970
|
+
description: "Credit cost (credits)",
|
|
3971
|
+
parse: parseNumber,
|
|
3972
|
+
sdkKey: "creditCost"
|
|
3973
|
+
}
|
|
3974
|
+
]
|
|
3975
|
+
},
|
|
3976
|
+
update: {
|
|
3977
|
+
method: "update",
|
|
3978
|
+
description: "Update an addon",
|
|
3979
|
+
params: [
|
|
3980
|
+
{
|
|
3981
|
+
flag: "--id <id>",
|
|
3982
|
+
description: "Addon ID",
|
|
3983
|
+
required: true,
|
|
3984
|
+
sdkKey: "id"
|
|
3985
|
+
},
|
|
3986
|
+
{
|
|
3987
|
+
flag: "--name <name>",
|
|
3988
|
+
description: "Addon name",
|
|
3989
|
+
sdkKey: "name"
|
|
3990
|
+
},
|
|
3991
|
+
{
|
|
3992
|
+
flag: "--description <desc>",
|
|
3993
|
+
description: "Addon description",
|
|
3994
|
+
sdkKey: "description"
|
|
3995
|
+
},
|
|
3996
|
+
{
|
|
3997
|
+
flag: "--base-price <n>",
|
|
3998
|
+
description: "Base price in cents",
|
|
3999
|
+
parse: parseNumber,
|
|
4000
|
+
sdkKey: "basePrice"
|
|
4001
|
+
},
|
|
4002
|
+
{
|
|
4003
|
+
flag: "--included-units <n>",
|
|
4004
|
+
description: "Included units",
|
|
4005
|
+
parse: parseNumber,
|
|
4006
|
+
sdkKey: "includedUnits"
|
|
4007
|
+
},
|
|
4008
|
+
{
|
|
4009
|
+
flag: "--overage-rate <n>",
|
|
4010
|
+
description: "Overage rate",
|
|
4011
|
+
parse: parseNumber,
|
|
4012
|
+
sdkKey: "overageRate"
|
|
4013
|
+
}
|
|
4014
|
+
]
|
|
4015
|
+
},
|
|
4016
|
+
delete: {
|
|
4017
|
+
method: "delete",
|
|
4018
|
+
description: "Delete an addon",
|
|
4019
|
+
params: [
|
|
4020
|
+
{
|
|
4021
|
+
flag: "--id <id>",
|
|
4022
|
+
description: "Addon ID",
|
|
4023
|
+
required: true,
|
|
4024
|
+
sdkKey: "id"
|
|
4025
|
+
}
|
|
4026
|
+
]
|
|
4027
|
+
}
|
|
4028
|
+
}
|
|
4029
|
+
};
|
|
4030
|
+
var creditPacksResource = {
|
|
4031
|
+
name: "credit-packs",
|
|
4032
|
+
description: "Manage credit packs",
|
|
4033
|
+
sdkProperty: "creditPacks",
|
|
4034
|
+
actions: {
|
|
4035
|
+
list: {
|
|
4036
|
+
method: "list",
|
|
4037
|
+
description: "List credit packs",
|
|
4038
|
+
params: []
|
|
4039
|
+
},
|
|
4040
|
+
create: {
|
|
4041
|
+
method: "create",
|
|
4042
|
+
description: "Create a credit pack",
|
|
4043
|
+
params: [
|
|
4044
|
+
{
|
|
4045
|
+
flag: "--name <name>",
|
|
4046
|
+
description: "Credit pack name",
|
|
4047
|
+
required: true,
|
|
4048
|
+
sdkKey: "name"
|
|
4049
|
+
},
|
|
4050
|
+
{
|
|
4051
|
+
flag: "--credits <n>",
|
|
4052
|
+
description: "Number of credits",
|
|
4053
|
+
required: true,
|
|
4054
|
+
parse: parseNumber,
|
|
4055
|
+
sdkKey: "credits"
|
|
4056
|
+
},
|
|
4057
|
+
{
|
|
4058
|
+
flag: "--price <n>",
|
|
4059
|
+
description: "Price in cents",
|
|
4060
|
+
required: true,
|
|
4061
|
+
parse: parseNumber,
|
|
4062
|
+
sdkKey: "price"
|
|
4063
|
+
},
|
|
4064
|
+
{
|
|
4065
|
+
flag: "--description <desc>",
|
|
4066
|
+
description: "Credit pack description",
|
|
4067
|
+
sdkKey: "description"
|
|
4068
|
+
},
|
|
4069
|
+
{
|
|
4070
|
+
flag: "--is-active <bool>",
|
|
4071
|
+
description: "Whether credit pack is active",
|
|
4072
|
+
parse: parseBool,
|
|
4073
|
+
sdkKey: "isActive"
|
|
4074
|
+
}
|
|
4075
|
+
]
|
|
4076
|
+
},
|
|
4077
|
+
update: {
|
|
4078
|
+
method: "update",
|
|
4079
|
+
description: "Update a credit pack",
|
|
4080
|
+
params: [
|
|
4081
|
+
{
|
|
4082
|
+
flag: "--id <id>",
|
|
4083
|
+
description: "Credit pack ID",
|
|
4084
|
+
required: true,
|
|
4085
|
+
sdkKey: "id"
|
|
4086
|
+
},
|
|
4087
|
+
{
|
|
4088
|
+
flag: "--name <name>",
|
|
4089
|
+
description: "Credit pack name",
|
|
4090
|
+
sdkKey: "name"
|
|
4091
|
+
},
|
|
4092
|
+
{
|
|
4093
|
+
flag: "--description <desc>",
|
|
4094
|
+
description: "Credit pack description",
|
|
4095
|
+
sdkKey: "description"
|
|
4096
|
+
},
|
|
4097
|
+
{
|
|
4098
|
+
flag: "--credits <n>",
|
|
4099
|
+
description: "Number of credits",
|
|
4100
|
+
parse: parseNumber,
|
|
4101
|
+
sdkKey: "credits"
|
|
4102
|
+
},
|
|
4103
|
+
{
|
|
4104
|
+
flag: "--price <n>",
|
|
4105
|
+
description: "Price in cents",
|
|
4106
|
+
parse: parseNumber,
|
|
4107
|
+
sdkKey: "price"
|
|
4108
|
+
},
|
|
4109
|
+
{
|
|
4110
|
+
flag: "--is-active <bool>",
|
|
4111
|
+
description: "Whether credit pack is active",
|
|
4112
|
+
parse: parseBool,
|
|
4113
|
+
sdkKey: "isActive"
|
|
4114
|
+
}
|
|
4115
|
+
]
|
|
4116
|
+
},
|
|
4117
|
+
delete: {
|
|
4118
|
+
method: "delete",
|
|
4119
|
+
description: "Delete a credit pack",
|
|
4120
|
+
params: [
|
|
4121
|
+
{
|
|
4122
|
+
flag: "--id <id>",
|
|
4123
|
+
description: "Credit pack ID",
|
|
4124
|
+
required: true,
|
|
4125
|
+
sdkKey: "id"
|
|
4126
|
+
}
|
|
4127
|
+
]
|
|
4128
|
+
}
|
|
4129
|
+
}
|
|
4130
|
+
};
|
|
4131
|
+
var webhooksResource = {
|
|
4132
|
+
name: "webhooks",
|
|
4133
|
+
description: "Manage webhook endpoints",
|
|
4134
|
+
sdkProperty: "webhooks",
|
|
4135
|
+
actions: {
|
|
4136
|
+
list: {
|
|
4137
|
+
method: "list",
|
|
4138
|
+
description: "List webhook endpoints",
|
|
4139
|
+
params: [
|
|
4140
|
+
{
|
|
4141
|
+
flag: "--limit <n>",
|
|
4142
|
+
description: "Max results",
|
|
4143
|
+
parse: parseNumber,
|
|
4144
|
+
sdkKey: "limit"
|
|
4145
|
+
},
|
|
4146
|
+
{
|
|
4147
|
+
flag: "--cursor <cursor>",
|
|
4148
|
+
description: "Pagination cursor",
|
|
4149
|
+
sdkKey: "cursor"
|
|
4150
|
+
}
|
|
4151
|
+
]
|
|
4152
|
+
},
|
|
4153
|
+
create: {
|
|
4154
|
+
method: "create",
|
|
4155
|
+
description: "Create a webhook endpoint",
|
|
4156
|
+
params: [
|
|
4157
|
+
{
|
|
4158
|
+
flag: "--url <url>",
|
|
4159
|
+
description: "Webhook URL",
|
|
4160
|
+
required: true,
|
|
4161
|
+
sdkKey: "url"
|
|
4162
|
+
},
|
|
4163
|
+
{
|
|
4164
|
+
flag: "--events <json>",
|
|
4165
|
+
description: 'Events to subscribe to (JSON array: ["subscription.created"])',
|
|
4166
|
+
required: true,
|
|
4167
|
+
parse: parseJson,
|
|
4168
|
+
sdkKey: "events"
|
|
4169
|
+
},
|
|
4170
|
+
{
|
|
4171
|
+
flag: "--description <desc>",
|
|
4172
|
+
description: "Webhook description",
|
|
4173
|
+
sdkKey: "description"
|
|
4174
|
+
}
|
|
4175
|
+
]
|
|
4176
|
+
},
|
|
4177
|
+
delete: {
|
|
4178
|
+
method: "delete",
|
|
4179
|
+
description: "Delete a webhook endpoint",
|
|
4180
|
+
params: [
|
|
4181
|
+
{
|
|
4182
|
+
flag: "--id <id>",
|
|
4183
|
+
description: "Webhook endpoint ID",
|
|
4184
|
+
required: true,
|
|
4185
|
+
sdkKey: "id"
|
|
4186
|
+
}
|
|
4187
|
+
]
|
|
4188
|
+
},
|
|
4189
|
+
test: {
|
|
4190
|
+
method: "test",
|
|
4191
|
+
description: "Send a test event to a webhook endpoint",
|
|
4192
|
+
params: [
|
|
4193
|
+
{
|
|
4194
|
+
flag: "--id <id>",
|
|
4195
|
+
description: "Webhook endpoint ID",
|
|
4196
|
+
required: true,
|
|
4197
|
+
sdkKey: "id"
|
|
4198
|
+
}
|
|
4199
|
+
]
|
|
4200
|
+
}
|
|
4201
|
+
}
|
|
4202
|
+
};
|
|
4203
|
+
var apiKeysResource = {
|
|
4204
|
+
name: "api-keys",
|
|
4205
|
+
description: "Manage API keys",
|
|
4206
|
+
sdkProperty: "apiKeys",
|
|
4207
|
+
actions: {
|
|
4208
|
+
list: {
|
|
4209
|
+
method: "list",
|
|
4210
|
+
description: "List API keys",
|
|
4211
|
+
params: [
|
|
4212
|
+
{
|
|
4213
|
+
flag: "--limit <n>",
|
|
4214
|
+
description: "Max results",
|
|
4215
|
+
parse: parseNumber,
|
|
4216
|
+
sdkKey: "limit"
|
|
4217
|
+
},
|
|
4218
|
+
{
|
|
4219
|
+
flag: "--cursor <cursor>",
|
|
4220
|
+
description: "Pagination cursor",
|
|
4221
|
+
sdkKey: "cursor"
|
|
4222
|
+
}
|
|
4223
|
+
]
|
|
4224
|
+
},
|
|
4225
|
+
create: {
|
|
4226
|
+
method: "create",
|
|
4227
|
+
description: "Create an API key",
|
|
4228
|
+
params: [
|
|
4229
|
+
{
|
|
4230
|
+
flag: "--name <name>",
|
|
4231
|
+
description: "API key name",
|
|
4232
|
+
required: true,
|
|
4233
|
+
sdkKey: "name"
|
|
4234
|
+
},
|
|
4235
|
+
{
|
|
4236
|
+
flag: "--expires-in-days <n>",
|
|
4237
|
+
description: "Expiration in days",
|
|
4238
|
+
parse: parseNumber,
|
|
4239
|
+
sdkKey: "expiresInDays"
|
|
4240
|
+
}
|
|
4241
|
+
]
|
|
4242
|
+
},
|
|
4243
|
+
delete: {
|
|
4244
|
+
method: "delete",
|
|
4245
|
+
description: "Delete an API key",
|
|
4246
|
+
params: [
|
|
4247
|
+
{
|
|
4248
|
+
flag: "--id <id>",
|
|
4249
|
+
description: "API key ID",
|
|
4250
|
+
required: true,
|
|
4251
|
+
sdkKey: "id"
|
|
4252
|
+
}
|
|
4253
|
+
]
|
|
4254
|
+
}
|
|
4255
|
+
}
|
|
4256
|
+
};
|
|
4257
|
+
var invoicesResource = {
|
|
4258
|
+
name: "invoices",
|
|
4259
|
+
description: "Manage invoices",
|
|
4260
|
+
sdkProperty: "invoices",
|
|
4261
|
+
actions: {
|
|
4262
|
+
list: {
|
|
4263
|
+
method: "list",
|
|
4264
|
+
description: "List invoices",
|
|
4265
|
+
params: [
|
|
4266
|
+
{
|
|
4267
|
+
flag: "--customer-id <id>",
|
|
4268
|
+
description: "Filter by customer ID",
|
|
4269
|
+
sdkKey: "customerId"
|
|
4270
|
+
},
|
|
4271
|
+
{
|
|
4272
|
+
flag: "--status <status>",
|
|
4273
|
+
description: "Filter by status",
|
|
4274
|
+
sdkKey: "status"
|
|
4275
|
+
},
|
|
4276
|
+
{
|
|
4277
|
+
flag: "--subscription-id <id>",
|
|
4278
|
+
description: "Filter by subscription ID",
|
|
4279
|
+
sdkKey: "subscriptionId"
|
|
4280
|
+
},
|
|
4281
|
+
{
|
|
4282
|
+
flag: "--limit <n>",
|
|
4283
|
+
description: "Max results",
|
|
4284
|
+
parse: parseNumber,
|
|
4285
|
+
sdkKey: "limit"
|
|
4286
|
+
},
|
|
4287
|
+
{
|
|
4288
|
+
flag: "--cursor <cursor>",
|
|
4289
|
+
description: "Pagination cursor",
|
|
4290
|
+
sdkKey: "cursor"
|
|
4291
|
+
}
|
|
4292
|
+
]
|
|
4293
|
+
},
|
|
4294
|
+
get: {
|
|
4295
|
+
method: "get",
|
|
4296
|
+
description: "Get invoice details",
|
|
4297
|
+
params: [
|
|
4298
|
+
{
|
|
4299
|
+
flag: "--id <id>",
|
|
4300
|
+
description: "Invoice ID",
|
|
4301
|
+
required: true,
|
|
4302
|
+
sdkKey: "id"
|
|
4303
|
+
}
|
|
4304
|
+
]
|
|
4305
|
+
},
|
|
4306
|
+
"create-adjustment": {
|
|
4307
|
+
method: "createAdjustment",
|
|
4308
|
+
description: "Create an adjustment invoice (negative amount = credit)",
|
|
4309
|
+
params: [
|
|
4310
|
+
{
|
|
4311
|
+
flag: "--customer-id <id>",
|
|
4312
|
+
description: "Customer ID",
|
|
4313
|
+
required: true,
|
|
4314
|
+
sdkKey: "customerId"
|
|
4315
|
+
},
|
|
4316
|
+
{
|
|
4317
|
+
flag: "--amount <n>",
|
|
4318
|
+
description: "Amount in cents (negative for credit)",
|
|
4319
|
+
required: true,
|
|
4320
|
+
parse: parseNumber,
|
|
4321
|
+
sdkKey: "amount"
|
|
4322
|
+
},
|
|
4323
|
+
{
|
|
4324
|
+
flag: "--description <desc>",
|
|
4325
|
+
description: "Adjustment description",
|
|
4326
|
+
sdkKey: "description"
|
|
4327
|
+
},
|
|
4328
|
+
{
|
|
4329
|
+
flag: "--metadata <json>",
|
|
4330
|
+
description: "Metadata (JSON)",
|
|
4331
|
+
parse: parseJson,
|
|
4332
|
+
sdkKey: "metadata"
|
|
4333
|
+
}
|
|
4334
|
+
]
|
|
4335
|
+
},
|
|
4336
|
+
"get-download-url": {
|
|
4337
|
+
method: "getDownloadUrl",
|
|
4338
|
+
description: "Get a signed download URL for an invoice PDF",
|
|
4339
|
+
params: [
|
|
4340
|
+
{
|
|
4341
|
+
flag: "--id <id>",
|
|
4342
|
+
description: "Invoice ID",
|
|
4343
|
+
required: true,
|
|
4344
|
+
sdkKey: "id"
|
|
4345
|
+
}
|
|
4346
|
+
]
|
|
4347
|
+
},
|
|
4348
|
+
send: {
|
|
4349
|
+
method: "send",
|
|
4350
|
+
description: "Send an invoice by email",
|
|
4351
|
+
params: [
|
|
4352
|
+
{
|
|
4353
|
+
flag: "--id <id>",
|
|
4354
|
+
description: "Invoice ID",
|
|
4355
|
+
required: true,
|
|
4356
|
+
sdkKey: "id"
|
|
4357
|
+
}
|
|
4358
|
+
]
|
|
4359
|
+
},
|
|
4360
|
+
"update-status": {
|
|
4361
|
+
method: "updateStatus",
|
|
4362
|
+
description: "Update invoice status (outstanding invoices only)",
|
|
4363
|
+
params: [
|
|
4364
|
+
{
|
|
4365
|
+
flag: "--id <id>",
|
|
4366
|
+
description: "Invoice ID",
|
|
4367
|
+
required: true,
|
|
4368
|
+
sdkKey: "id"
|
|
4369
|
+
},
|
|
4370
|
+
{
|
|
4371
|
+
flag: "--status <status>",
|
|
4372
|
+
description: "New status (paid or void)",
|
|
4373
|
+
required: true,
|
|
4374
|
+
sdkKey: "status"
|
|
4375
|
+
}
|
|
4376
|
+
]
|
|
4377
|
+
}
|
|
4378
|
+
}
|
|
4379
|
+
};
|
|
4380
|
+
var transactionsResource = {
|
|
4381
|
+
name: "transactions",
|
|
4382
|
+
description: "Manage transactions",
|
|
4383
|
+
sdkProperty: "transactions",
|
|
4384
|
+
actions: {
|
|
4385
|
+
list: {
|
|
4386
|
+
method: "list",
|
|
4387
|
+
description: "List transactions",
|
|
4388
|
+
params: [
|
|
4389
|
+
{
|
|
4390
|
+
flag: "--status <status>",
|
|
4391
|
+
description: "Filter by status",
|
|
4392
|
+
sdkKey: "status"
|
|
4393
|
+
},
|
|
4394
|
+
{
|
|
4395
|
+
flag: "--customer-email <email>",
|
|
4396
|
+
description: "Filter by customer email",
|
|
4397
|
+
sdkKey: "customerEmail"
|
|
4398
|
+
},
|
|
4399
|
+
{
|
|
4400
|
+
flag: "--limit <n>",
|
|
4401
|
+
description: "Max results",
|
|
4402
|
+
parse: parseNumber,
|
|
4403
|
+
sdkKey: "limit"
|
|
4404
|
+
},
|
|
4405
|
+
{
|
|
4406
|
+
flag: "--cursor <cursor>",
|
|
4407
|
+
description: "Pagination cursor",
|
|
4408
|
+
sdkKey: "cursor"
|
|
4409
|
+
}
|
|
4410
|
+
]
|
|
4411
|
+
},
|
|
4412
|
+
get: {
|
|
4413
|
+
method: "get",
|
|
4414
|
+
description: "Get transaction details",
|
|
4415
|
+
params: [
|
|
4416
|
+
{
|
|
4417
|
+
flag: "--id <id>",
|
|
4418
|
+
description: "Transaction ID",
|
|
4419
|
+
required: true,
|
|
4420
|
+
sdkKey: "id"
|
|
4421
|
+
}
|
|
4422
|
+
]
|
|
4423
|
+
},
|
|
4424
|
+
refund: {
|
|
4425
|
+
method: "refund",
|
|
4426
|
+
description: "Refund a transaction (full refund)",
|
|
4427
|
+
params: [
|
|
4428
|
+
{
|
|
4429
|
+
flag: "--id <id>",
|
|
4430
|
+
description: "Transaction ID",
|
|
4431
|
+
required: true,
|
|
4432
|
+
sdkKey: "id"
|
|
4433
|
+
}
|
|
4434
|
+
]
|
|
4435
|
+
},
|
|
4436
|
+
retry: {
|
|
4437
|
+
method: "retry",
|
|
4438
|
+
description: "Retry a failed transaction",
|
|
4439
|
+
params: [
|
|
4440
|
+
{
|
|
4441
|
+
flag: "--id <id>",
|
|
4442
|
+
description: "Transaction ID",
|
|
4443
|
+
required: true,
|
|
4444
|
+
sdkKey: "id"
|
|
4445
|
+
}
|
|
4446
|
+
]
|
|
4447
|
+
}
|
|
4448
|
+
}
|
|
4449
|
+
};
|
|
4450
|
+
var promoCodesResource = {
|
|
4451
|
+
name: "promo-codes",
|
|
4452
|
+
description: "Manage promo codes",
|
|
4453
|
+
sdkProperty: "promoCodes",
|
|
4454
|
+
actions: {
|
|
4455
|
+
list: {
|
|
4456
|
+
method: "list",
|
|
4457
|
+
description: "List promo codes",
|
|
4458
|
+
params: [
|
|
4459
|
+
{
|
|
4460
|
+
flag: "--limit <n>",
|
|
4461
|
+
description: "Max results",
|
|
4462
|
+
parse: parseNumber,
|
|
4463
|
+
sdkKey: "limit"
|
|
4464
|
+
},
|
|
4465
|
+
{
|
|
4466
|
+
flag: "--cursor <cursor>",
|
|
4467
|
+
description: "Pagination cursor",
|
|
4468
|
+
sdkKey: "cursor"
|
|
4469
|
+
}
|
|
4470
|
+
]
|
|
4471
|
+
},
|
|
4472
|
+
get: {
|
|
4473
|
+
method: "get",
|
|
4474
|
+
description: "Get promo code details",
|
|
4475
|
+
params: [
|
|
4476
|
+
{
|
|
4477
|
+
flag: "--id <id>",
|
|
4478
|
+
description: "Promo code ID",
|
|
4479
|
+
required: true,
|
|
4480
|
+
sdkKey: "id"
|
|
4481
|
+
}
|
|
4482
|
+
]
|
|
4483
|
+
},
|
|
4484
|
+
create: {
|
|
4485
|
+
method: "create",
|
|
4486
|
+
description: "Create a promo code",
|
|
4487
|
+
params: [
|
|
4488
|
+
{
|
|
4489
|
+
flag: "--code <code>",
|
|
4490
|
+
description: "Promo code string",
|
|
4491
|
+
required: true,
|
|
4492
|
+
sdkKey: "code"
|
|
4493
|
+
},
|
|
4494
|
+
{
|
|
4495
|
+
flag: "--discount-type <type>",
|
|
4496
|
+
description: "Discount type: percentage or amount",
|
|
4497
|
+
required: true,
|
|
4498
|
+
sdkKey: "discountType"
|
|
4499
|
+
},
|
|
4500
|
+
{
|
|
4501
|
+
flag: "--discount-value <n>",
|
|
4502
|
+
description: "Discount value",
|
|
4503
|
+
required: true,
|
|
4504
|
+
parse: parseNumber,
|
|
4505
|
+
sdkKey: "discountValue"
|
|
4506
|
+
},
|
|
4507
|
+
{
|
|
4508
|
+
flag: "--duration-cycles <n>",
|
|
4509
|
+
description: "Duration in billing cycles",
|
|
4510
|
+
parse: parseNumber,
|
|
4511
|
+
sdkKey: "durationCycles"
|
|
4512
|
+
},
|
|
4513
|
+
{
|
|
4514
|
+
flag: "--max-redemptions <n>",
|
|
4515
|
+
description: "Maximum number of redemptions",
|
|
4516
|
+
parse: parseNumber,
|
|
4517
|
+
sdkKey: "maxRedemptions"
|
|
4518
|
+
},
|
|
4519
|
+
{
|
|
4520
|
+
flag: "--expires-at <date>",
|
|
4521
|
+
description: "Expiration date (ISO 8601)",
|
|
4522
|
+
sdkKey: "expiresAt"
|
|
4523
|
+
},
|
|
4524
|
+
{
|
|
4525
|
+
flag: "--plan-ids <json>",
|
|
4526
|
+
description: "Restrict to plan IDs (JSON array)",
|
|
4527
|
+
parse: parseJson,
|
|
4528
|
+
sdkKey: "planIds"
|
|
4529
|
+
}
|
|
4530
|
+
]
|
|
4531
|
+
},
|
|
4532
|
+
update: {
|
|
4533
|
+
method: "update",
|
|
4534
|
+
description: "Update a promo code",
|
|
4535
|
+
params: [
|
|
4536
|
+
{
|
|
4537
|
+
flag: "--id <id>",
|
|
4538
|
+
description: "Promo code ID",
|
|
4539
|
+
required: true,
|
|
4540
|
+
sdkKey: "id"
|
|
4541
|
+
},
|
|
4542
|
+
{
|
|
4543
|
+
flag: "--max-redemptions <n>",
|
|
4544
|
+
description: "Maximum number of redemptions",
|
|
4545
|
+
parse: parseNumber,
|
|
4546
|
+
sdkKey: "maxRedemptions"
|
|
4547
|
+
},
|
|
4548
|
+
{
|
|
4549
|
+
flag: "--expires-at <date>",
|
|
4550
|
+
description: "Expiration date (ISO 8601)",
|
|
4551
|
+
sdkKey: "expiresAt"
|
|
4552
|
+
},
|
|
4553
|
+
{
|
|
4554
|
+
flag: "--active <bool>",
|
|
4555
|
+
description: "Whether promo code is active",
|
|
4556
|
+
parse: parseBool,
|
|
4557
|
+
sdkKey: "active"
|
|
4558
|
+
},
|
|
4559
|
+
{
|
|
4560
|
+
flag: "--plan-ids <json>",
|
|
4561
|
+
description: "Restrict to plan IDs (JSON array)",
|
|
4562
|
+
parse: parseJson,
|
|
4563
|
+
sdkKey: "planIds"
|
|
4564
|
+
}
|
|
4565
|
+
]
|
|
4566
|
+
}
|
|
4567
|
+
}
|
|
4568
|
+
};
|
|
4569
|
+
var planGroupsResource = {
|
|
4570
|
+
name: "plan-groups",
|
|
4571
|
+
description: "Manage plan groups",
|
|
4572
|
+
sdkProperty: "planGroups",
|
|
4573
|
+
actions: {
|
|
4574
|
+
list: {
|
|
4575
|
+
method: "list",
|
|
4576
|
+
description: "List plan groups",
|
|
4577
|
+
params: [
|
|
4578
|
+
{
|
|
4579
|
+
flag: "--limit <n>",
|
|
4580
|
+
description: "Max results",
|
|
4581
|
+
parse: parseNumber,
|
|
4582
|
+
sdkKey: "limit"
|
|
4583
|
+
},
|
|
4584
|
+
{
|
|
4585
|
+
flag: "--cursor <cursor>",
|
|
4586
|
+
description: "Pagination cursor",
|
|
4587
|
+
sdkKey: "cursor"
|
|
4588
|
+
}
|
|
4589
|
+
]
|
|
4590
|
+
},
|
|
4591
|
+
get: {
|
|
4592
|
+
method: "get",
|
|
4593
|
+
description: "Get plan group details",
|
|
4594
|
+
params: [
|
|
4595
|
+
{
|
|
4596
|
+
flag: "--id <id>",
|
|
4597
|
+
description: "Plan group ID",
|
|
4598
|
+
required: true,
|
|
4599
|
+
sdkKey: "id"
|
|
4600
|
+
}
|
|
4601
|
+
]
|
|
4602
|
+
},
|
|
4603
|
+
create: {
|
|
4604
|
+
method: "create",
|
|
4605
|
+
description: "Create a plan group",
|
|
4606
|
+
params: [
|
|
4607
|
+
{
|
|
4608
|
+
flag: "--name <name>",
|
|
4609
|
+
description: "Plan group name",
|
|
4610
|
+
required: true,
|
|
4611
|
+
sdkKey: "name"
|
|
4612
|
+
},
|
|
4613
|
+
{
|
|
4614
|
+
flag: "--description <desc>",
|
|
4615
|
+
description: "Plan group description",
|
|
4616
|
+
sdkKey: "description"
|
|
4617
|
+
},
|
|
4618
|
+
{
|
|
4619
|
+
flag: "--is-public <bool>",
|
|
4620
|
+
description: "Whether plan group is publicly visible",
|
|
4621
|
+
parse: parseBool,
|
|
4622
|
+
sdkKey: "isPublic"
|
|
4623
|
+
}
|
|
4624
|
+
]
|
|
4625
|
+
},
|
|
4626
|
+
update: {
|
|
4627
|
+
method: "update",
|
|
4628
|
+
description: "Update a plan group",
|
|
4629
|
+
params: [
|
|
4630
|
+
{
|
|
4631
|
+
flag: "--id <id>",
|
|
4632
|
+
description: "Plan group ID",
|
|
4633
|
+
required: true,
|
|
4634
|
+
sdkKey: "id"
|
|
4635
|
+
},
|
|
4636
|
+
{
|
|
4637
|
+
flag: "--name <name>",
|
|
4638
|
+
description: "Plan group name",
|
|
4639
|
+
sdkKey: "name"
|
|
4640
|
+
},
|
|
4641
|
+
{
|
|
4642
|
+
flag: "--description <desc>",
|
|
4643
|
+
description: "Plan group description",
|
|
4644
|
+
sdkKey: "description"
|
|
4645
|
+
},
|
|
4646
|
+
{
|
|
4647
|
+
flag: "--is-public <bool>",
|
|
4648
|
+
description: "Whether plan group is publicly visible",
|
|
4649
|
+
parse: parseBool,
|
|
4650
|
+
sdkKey: "isPublic"
|
|
4651
|
+
}
|
|
4652
|
+
]
|
|
4653
|
+
},
|
|
4654
|
+
delete: {
|
|
4655
|
+
method: "delete",
|
|
4656
|
+
description: "Delete a plan group",
|
|
4657
|
+
params: [
|
|
4658
|
+
{
|
|
4659
|
+
flag: "--id <id>",
|
|
4660
|
+
description: "Plan group ID",
|
|
4661
|
+
required: true,
|
|
4662
|
+
sdkKey: "id"
|
|
4663
|
+
}
|
|
4664
|
+
]
|
|
4665
|
+
},
|
|
4666
|
+
"add-plan": {
|
|
4667
|
+
method: "addPlan",
|
|
4668
|
+
description: "Add a plan to a group",
|
|
4669
|
+
params: [
|
|
4670
|
+
{
|
|
4671
|
+
flag: "--id <id>",
|
|
4672
|
+
description: "Plan group ID",
|
|
4673
|
+
required: true,
|
|
4674
|
+
sdkKey: "id"
|
|
4675
|
+
},
|
|
4676
|
+
{
|
|
4677
|
+
flag: "--plan-id <planId>",
|
|
4678
|
+
description: "Plan ID to add",
|
|
4679
|
+
required: true,
|
|
4680
|
+
sdkKey: "planId"
|
|
4681
|
+
},
|
|
4682
|
+
{
|
|
4683
|
+
flag: "--sort-order <n>",
|
|
4684
|
+
description: "Sort order",
|
|
4685
|
+
parse: parseNumber,
|
|
4686
|
+
sdkKey: "sortOrder"
|
|
4687
|
+
}
|
|
4688
|
+
]
|
|
4689
|
+
},
|
|
4690
|
+
"remove-plan": {
|
|
4691
|
+
method: "removePlan",
|
|
4692
|
+
description: "Remove a plan from a group",
|
|
4693
|
+
params: [
|
|
4694
|
+
{
|
|
4695
|
+
flag: "--id <id>",
|
|
4696
|
+
description: "Plan group ID",
|
|
4697
|
+
required: true,
|
|
4698
|
+
sdkKey: "id"
|
|
4699
|
+
},
|
|
4700
|
+
{
|
|
4701
|
+
flag: "--plan-id <planId>",
|
|
4702
|
+
description: "Plan ID to remove",
|
|
4703
|
+
required: true,
|
|
4704
|
+
sdkKey: "planId"
|
|
4705
|
+
}
|
|
4706
|
+
]
|
|
4707
|
+
},
|
|
4708
|
+
"reorder-plans": {
|
|
4709
|
+
method: "reorderPlans",
|
|
4710
|
+
description: "Reorder plans within a group",
|
|
4711
|
+
params: [
|
|
4712
|
+
{
|
|
4713
|
+
flag: "--id <id>",
|
|
4714
|
+
description: "Plan group ID",
|
|
4715
|
+
required: true,
|
|
4716
|
+
sdkKey: "id"
|
|
4717
|
+
},
|
|
4718
|
+
{
|
|
4719
|
+
flag: "--plan-ids <json>",
|
|
4720
|
+
description: "Ordered plan IDs (JSON array)",
|
|
4721
|
+
required: true,
|
|
4722
|
+
parse: parseJson,
|
|
4723
|
+
sdkKey: "planIds"
|
|
4724
|
+
}
|
|
4725
|
+
]
|
|
4726
|
+
}
|
|
4727
|
+
}
|
|
4728
|
+
};
|
|
4729
|
+
var resourceDefinitions = [
|
|
4730
|
+
customersResource,
|
|
4731
|
+
subscriptionsResource,
|
|
4732
|
+
plansResource,
|
|
4733
|
+
featuresResource,
|
|
4734
|
+
seatsResource,
|
|
4735
|
+
usageResource,
|
|
4736
|
+
portalResource,
|
|
4737
|
+
addonsResource,
|
|
4738
|
+
creditPacksResource,
|
|
4739
|
+
webhooksResource,
|
|
4740
|
+
apiKeysResource,
|
|
4741
|
+
invoicesResource,
|
|
4742
|
+
transactionsResource,
|
|
4743
|
+
promoCodesResource,
|
|
4744
|
+
planGroupsResource
|
|
4745
|
+
];
|
|
4746
|
+
|
|
4747
|
+
// src/utils/update-check.ts
|
|
4748
|
+
var fs6 = __toESM(require("fs"));
|
|
4749
|
+
var os3 = __toESM(require("os"));
|
|
4750
|
+
var path6 = __toESM(require("path"));
|
|
4751
|
+
var import_chalk15 = __toESM(require("chalk"));
|
|
4752
|
+
var CACHE_FILE = path6.join(os3.homedir(), ".commet", ".update-check");
|
|
4753
|
+
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
4754
|
+
var REGISTRY_URL = "https://registry.npmjs.org/commet/latest";
|
|
4755
|
+
function isNewerVersion(latest, current) {
|
|
4756
|
+
const l = latest.split(".").map(Number);
|
|
4757
|
+
const c = current.split(".").map(Number);
|
|
4758
|
+
for (let i = 0; i < 3; i++) {
|
|
4759
|
+
if ((l[i] ?? 0) > (c[i] ?? 0)) return true;
|
|
4760
|
+
if ((l[i] ?? 0) < (c[i] ?? 0)) return false;
|
|
4761
|
+
}
|
|
4762
|
+
return false;
|
|
4763
|
+
}
|
|
4764
|
+
function readCache() {
|
|
4765
|
+
try {
|
|
4766
|
+
return JSON.parse(fs6.readFileSync(CACHE_FILE, "utf8"));
|
|
4767
|
+
} catch {
|
|
4768
|
+
return null;
|
|
4769
|
+
}
|
|
4770
|
+
}
|
|
4771
|
+
function writeCache(cache) {
|
|
4772
|
+
try {
|
|
4773
|
+
fs6.writeFileSync(CACHE_FILE, JSON.stringify(cache), "utf8");
|
|
4774
|
+
} catch {
|
|
4775
|
+
}
|
|
4776
|
+
}
|
|
4777
|
+
function shouldSkip() {
|
|
4778
|
+
if (process.env.COMMET_NO_UPDATE_CHECK === "1") return true;
|
|
4779
|
+
if (process.env.CI) return true;
|
|
4780
|
+
const idx = process.argv.indexOf("--output");
|
|
4781
|
+
if (idx !== -1 && process.argv[idx + 1] === "agent") return true;
|
|
4782
|
+
return false;
|
|
4783
|
+
}
|
|
4784
|
+
var updateAvailable = null;
|
|
4785
|
+
function scheduleUpdateCheck(currentVersion) {
|
|
4786
|
+
if (shouldSkip()) return;
|
|
4787
|
+
const cache = readCache();
|
|
4788
|
+
if (cache && isNewerVersion(cache.latestVersion, currentVersion)) {
|
|
4789
|
+
updateAvailable = cache.latestVersion;
|
|
4790
|
+
}
|
|
4791
|
+
const needsFetch = !cache || Date.now() - cache.checkedAt > CHECK_INTERVAL_MS;
|
|
4792
|
+
if (!needsFetch) return;
|
|
4793
|
+
const controller = new AbortController();
|
|
4794
|
+
const timeout = setTimeout(() => controller.abort(), 3e3);
|
|
4795
|
+
fetch(REGISTRY_URL, { signal: controller.signal }).then((r) => r.json()).then((data) => {
|
|
2366
4796
|
writeCache({ latestVersion: data.version, checkedAt: Date.now() });
|
|
2367
4797
|
if (!updateAvailable && isNewerVersion(data.version, currentVersion)) {
|
|
2368
4798
|
updateAvailable = data.version;
|
|
@@ -2374,13 +4804,13 @@ function printUpdateNotification(currentVersion) {
|
|
|
2374
4804
|
if (!updateAvailable) return;
|
|
2375
4805
|
console.log("");
|
|
2376
4806
|
console.log(
|
|
2377
|
-
` Update available: ${
|
|
4807
|
+
` Update available: ${import_chalk15.default.dim(currentVersion)} \u2192 ${import_chalk15.default.green(updateAvailable)}`
|
|
2378
4808
|
);
|
|
2379
|
-
console.log(
|
|
4809
|
+
console.log(import_chalk15.default.dim(` Run: npm i -g commet@latest`));
|
|
2380
4810
|
}
|
|
2381
4811
|
|
|
2382
4812
|
// src/index.ts
|
|
2383
|
-
var program = new
|
|
4813
|
+
var program = new import_commander11.Command();
|
|
2384
4814
|
program.name("commet").description(
|
|
2385
4815
|
"Commet CLI \u2014 billing infrastructure as code.\nManage features, plans, and billing config from the command line."
|
|
2386
4816
|
).version(package_default.version).addHelpText(
|
|
@@ -2394,7 +4824,7 @@ Workflow:
|
|
|
2394
4824
|
For agents and CI:
|
|
2395
4825
|
$ commet JSON capabilities when piped (no args)
|
|
2396
4826
|
$ commet pull --output agent --yes Structured output, no prompts
|
|
2397
|
-
$ COMMET_API_KEY=
|
|
4827
|
+
$ COMMET_API_KEY=ck_... commet push --yes CI pipeline
|
|
2398
4828
|
|
|
2399
4829
|
Run commet <command> --help for detailed usage and examples.
|
|
2400
4830
|
`
|
|
@@ -2407,7 +4837,10 @@ program.addCommand(orgsCommand);
|
|
|
2407
4837
|
program.addCommand(pushCommand);
|
|
2408
4838
|
program.addCommand(pullCommand);
|
|
2409
4839
|
program.addCommand(listenCommand);
|
|
2410
|
-
program.addCommand(apiKeyCommand);
|
|
4840
|
+
program.addCommand(apiKeyCommand, { hidden: true });
|
|
4841
|
+
for (const def of resourceDefinitions) {
|
|
4842
|
+
program.addCommand(createResourceCommand(def));
|
|
4843
|
+
}
|
|
2411
4844
|
program.enablePositionalOptions().passThroughOptions().option(
|
|
2412
4845
|
"--output <format>",
|
|
2413
4846
|
"Output format: human (default) or agent",
|
|
@@ -2439,7 +4872,7 @@ try {
|
|
|
2439
4872
|
process.exit(0);
|
|
2440
4873
|
}
|
|
2441
4874
|
reportCommand(commandName, "error", code);
|
|
2442
|
-
console.error(
|
|
4875
|
+
console.error(import_chalk16.default.red("Error:"), error.message);
|
|
2443
4876
|
}
|
|
2444
4877
|
process.exit(1);
|
|
2445
4878
|
}
|
|
@@ -2491,7 +4924,7 @@ function printAgentInfo() {
|
|
|
2491
4924
|
description: "Push commet.config.ts to remote",
|
|
2492
4925
|
usage: "commet push --output agent --yes",
|
|
2493
4926
|
preview: "commet push --output agent --dry-run",
|
|
2494
|
-
ci: "COMMET_API_KEY=
|
|
4927
|
+
ci: "COMMET_API_KEY=ck_... commet push --yes"
|
|
2495
4928
|
},
|
|
2496
4929
|
orgs: {
|
|
2497
4930
|
description: "List available organizations",
|
|
@@ -2510,10 +4943,6 @@ function printAgentInfo() {
|
|
|
2510
4943
|
description: "Scaffold a new Commet app from template",
|
|
2511
4944
|
usage: "commet create [name] -t <template> --org <slug> -y"
|
|
2512
4945
|
},
|
|
2513
|
-
"api-key": {
|
|
2514
|
-
description: "Generate API key for CI",
|
|
2515
|
-
usage: "commet api-key --output agent"
|
|
2516
|
-
},
|
|
2517
4946
|
login: {
|
|
2518
4947
|
description: "Authenticate via browser. Requires a human \u2014 opens a device-code flow.",
|
|
2519
4948
|
usage: "commet login"
|
|
@@ -2522,47 +4951,48 @@ function printAgentInfo() {
|
|
|
2522
4951
|
description: "Log out of Commet",
|
|
2523
4952
|
usage: "commet logout"
|
|
2524
4953
|
}
|
|
2525
|
-
}
|
|
4954
|
+
},
|
|
4955
|
+
resources: generateResourceSchema(resourceDefinitions)
|
|
2526
4956
|
};
|
|
2527
4957
|
console.log(JSON.stringify(output, null, 2));
|
|
2528
4958
|
}
|
|
2529
4959
|
function printDefaultScreen() {
|
|
2530
|
-
const version =
|
|
4960
|
+
const version = import_chalk16.default.dim(`v${package_default.version}`);
|
|
2531
4961
|
console.log(`
|
|
2532
4962
|
${commetColor.bold("Commet")} ${version}`);
|
|
2533
|
-
console.log(
|
|
4963
|
+
console.log(import_chalk16.default.dim(" Billing infrastructure as code\n"));
|
|
2534
4964
|
const authenticated = authExists();
|
|
2535
4965
|
const projectConfig = projectConfigExists() ? loadProjectConfig() : null;
|
|
2536
4966
|
const configFile = findConfigFile(process.cwd());
|
|
2537
4967
|
if (authenticated) {
|
|
2538
|
-
console.log(
|
|
4968
|
+
console.log(import_chalk16.default.green(" \u2713 Authenticated"));
|
|
2539
4969
|
} else {
|
|
2540
4970
|
console.log(
|
|
2541
|
-
` ${
|
|
4971
|
+
` ${import_chalk16.default.yellow("\u26A0")} Not logged in ${import_chalk16.default.dim("\u2192 commet login")}`
|
|
2542
4972
|
);
|
|
2543
4973
|
}
|
|
2544
4974
|
if (projectConfig) {
|
|
2545
4975
|
console.log(
|
|
2546
|
-
|
|
2547
|
-
` \u2713 ${projectConfig.orgName} ${
|
|
4976
|
+
import_chalk16.default.green(
|
|
4977
|
+
` \u2713 ${projectConfig.orgName} ${import_chalk16.default.dim(`(${projectConfig.mode})`)}`
|
|
2548
4978
|
)
|
|
2549
4979
|
);
|
|
2550
|
-
console.log(
|
|
4980
|
+
console.log(import_chalk16.default.dim(` ${projectConfig.orgId}`));
|
|
2551
4981
|
} else if (authenticated) {
|
|
2552
4982
|
console.log(
|
|
2553
|
-
` ${
|
|
4983
|
+
` ${import_chalk16.default.yellow("\u26A0")} No project linked ${import_chalk16.default.dim("\u2192 commet link")}`
|
|
2554
4984
|
);
|
|
2555
4985
|
}
|
|
2556
4986
|
if (configFile) {
|
|
2557
4987
|
const fileName = configFile.split("/").pop();
|
|
2558
|
-
console.log(
|
|
4988
|
+
console.log(import_chalk16.default.green(` \u2713 ${fileName}`));
|
|
2559
4989
|
} else if (projectConfig) {
|
|
2560
4990
|
console.log(
|
|
2561
|
-
` ${
|
|
4991
|
+
` ${import_chalk16.default.yellow("\u26A0")} No config file ${import_chalk16.default.dim("\u2192 commet pull")}`
|
|
2562
4992
|
);
|
|
2563
4993
|
}
|
|
2564
4994
|
const cmd = (name) => commetColor(name.padEnd(22));
|
|
2565
|
-
const dim =
|
|
4995
|
+
const dim = import_chalk16.default.dim;
|
|
2566
4996
|
console.log(dim("\n Config"));
|
|
2567
4997
|
console.log(` ${cmd("pull")}${dim("Sync remote \u2192 commet.config.ts")}`);
|
|
2568
4998
|
console.log(` ${cmd("push")}${dim("Sync commet.config.ts \u2192 remote")}`);
|
|
@@ -2571,9 +5001,12 @@ function printDefaultScreen() {
|
|
|
2571
5001
|
console.log(dim("\n Project"));
|
|
2572
5002
|
console.log(` ${cmd("link")}${dim("Link / switch organization")}`);
|
|
2573
5003
|
console.log(` ${cmd("orgs")}${dim("List organizations")}`);
|
|
5004
|
+
console.log(dim("\n Resources (SDK)"));
|
|
5005
|
+
for (const def of resourceDefinitions) {
|
|
5006
|
+
console.log(` ${cmd(def.name)}${dim(def.description)}`);
|
|
5007
|
+
}
|
|
2574
5008
|
console.log(dim("\n Setup"));
|
|
2575
5009
|
console.log(` ${cmd("create")}${dim("Scaffold a new Commet app")}`);
|
|
2576
|
-
console.log(` ${cmd("api-key")}${dim("Generate API key for CI")}`);
|
|
2577
5010
|
console.log(` ${cmd("login")}${dim("Authenticate")}`);
|
|
2578
5011
|
console.log(` ${cmd("logout")}${dim("Log out")}`);
|
|
2579
5012
|
console.log(
|