commet 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2766 -186
- 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.
|
|
33
|
+
version: "2.2.0",
|
|
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",
|
|
@@ -160,7 +161,7 @@ function clearProjectConfig() {
|
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
// src/utils/telemetry.ts
|
|
163
|
-
var CLI_VERSION = true ? "2.
|
|
164
|
+
var CLI_VERSION = true ? "2.2.0" : "0.0.0";
|
|
164
165
|
var TELEMETRY_URL = "https://commet.co/api/cli/telemetry";
|
|
165
166
|
function detectRuntime() {
|
|
166
167
|
if ("Bun" in globalThis) {
|
|
@@ -405,10 +406,22 @@ Examples:
|
|
|
405
406
|
$ commet api-key --output agent JSON output with the key
|
|
406
407
|
|
|
407
408
|
Then use it in CI:
|
|
408
|
-
$ COMMET_API_KEY=
|
|
409
|
+
$ COMMET_API_KEY=ck_... commet push --yes
|
|
409
410
|
`
|
|
410
411
|
).action(async (options) => {
|
|
411
412
|
const agentMode = isAgentMode(options);
|
|
413
|
+
if (agentMode) {
|
|
414
|
+
console.log(
|
|
415
|
+
JSON.stringify({
|
|
416
|
+
deprecated: true,
|
|
417
|
+
replacement: "commet api-keys create"
|
|
418
|
+
})
|
|
419
|
+
);
|
|
420
|
+
} else {
|
|
421
|
+
console.log(
|
|
422
|
+
import_chalk2.default.yellow("\u26A0 Deprecated: use 'commet api-keys create' instead")
|
|
423
|
+
);
|
|
424
|
+
}
|
|
412
425
|
if (process.env.COMMET_API_KEY) {
|
|
413
426
|
exitWithError({
|
|
414
427
|
code: "invalid_context",
|
|
@@ -1229,6 +1242,26 @@ Examples:
|
|
|
1229
1242
|
mode: selectedOrg.mode
|
|
1230
1243
|
});
|
|
1231
1244
|
const gitignoreResult = updateGitignore(".commet/");
|
|
1245
|
+
let autoApiKey = null;
|
|
1246
|
+
const keyResult = await apiRequest(
|
|
1247
|
+
`${BASE_URL}/api/cli/api-keys`,
|
|
1248
|
+
{
|
|
1249
|
+
method: "POST",
|
|
1250
|
+
body: JSON.stringify({
|
|
1251
|
+
organizationId: selectedOrg.id,
|
|
1252
|
+
name: "CLI (auto)"
|
|
1253
|
+
})
|
|
1254
|
+
}
|
|
1255
|
+
).catch(() => null);
|
|
1256
|
+
if (keyResult?.data?.apiKey) {
|
|
1257
|
+
autoApiKey = keyResult.data.apiKey;
|
|
1258
|
+
saveProjectConfig({
|
|
1259
|
+
orgId: selectedOrg.id,
|
|
1260
|
+
orgName: selectedOrg.name,
|
|
1261
|
+
mode: selectedOrg.mode,
|
|
1262
|
+
apiKey: autoApiKey
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1232
1265
|
if (agentMode) {
|
|
1233
1266
|
console.log(
|
|
1234
1267
|
JSON.stringify({
|
|
@@ -1239,7 +1272,8 @@ Examples:
|
|
|
1239
1272
|
name: selectedOrg.name,
|
|
1240
1273
|
slug: selectedOrg.slug,
|
|
1241
1274
|
mode: selectedOrg.mode
|
|
1242
|
-
}
|
|
1275
|
+
},
|
|
1276
|
+
...autoApiKey ? { apiKey: autoApiKey, apiKeyAutoGenerated: true } : {}
|
|
1243
1277
|
})
|
|
1244
1278
|
);
|
|
1245
1279
|
} else {
|
|
@@ -1251,6 +1285,17 @@ Examples:
|
|
|
1251
1285
|
if (gitignoreResult.success && action === "linked") {
|
|
1252
1286
|
console.log(import_chalk6.default.green("\u2713 Updated .gitignore"));
|
|
1253
1287
|
}
|
|
1288
|
+
if (autoApiKey) {
|
|
1289
|
+
console.log(
|
|
1290
|
+
import_chalk6.default.green("\u2713 API key auto-generated for resource commands")
|
|
1291
|
+
);
|
|
1292
|
+
} else {
|
|
1293
|
+
console.log(
|
|
1294
|
+
import_chalk6.default.dim(
|
|
1295
|
+
" API key auto-generation failed. Run `commet api-keys create` to create one manually."
|
|
1296
|
+
)
|
|
1297
|
+
);
|
|
1298
|
+
}
|
|
1254
1299
|
console.log(import_chalk6.default.dim("\nRun `commet pull` to sync your config"));
|
|
1255
1300
|
}
|
|
1256
1301
|
});
|
|
@@ -1523,7 +1568,7 @@ var orgsCommand = new import_commander7.Command("orgs").description(
|
|
|
1523
1568
|
`
|
|
1524
1569
|
Examples:
|
|
1525
1570
|
$ commet orgs Show orgs with current selection marked
|
|
1526
|
-
$ commet orgs --
|
|
1571
|
+
$ commet orgs --output agent JSON array for agent/CI use
|
|
1527
1572
|
|
|
1528
1573
|
The slug shown here is what you pass to 'commet link --org <slug>'.
|
|
1529
1574
|
`
|
|
@@ -1910,7 +1955,7 @@ Examples:
|
|
|
1910
1955
|
$ commet pull --dry-run Preview changes without applying
|
|
1911
1956
|
$ commet pull --yes Apply without confirmation
|
|
1912
1957
|
$ commet pull --output agent --yes Agent/CI \u2014 structured JSON, no prompts
|
|
1913
|
-
$ COMMET_API_KEY=
|
|
1958
|
+
$ COMMET_API_KEY=ck_... commet pull --yes CI pipeline
|
|
1914
1959
|
`
|
|
1915
1960
|
).action(async (options) => {
|
|
1916
1961
|
const agentMode = isAgentMode(options);
|
|
@@ -2144,7 +2189,7 @@ Examples:
|
|
|
2144
2189
|
$ commet push --dry-run Preview what would change on remote
|
|
2145
2190
|
$ commet push --yes Push without confirmation
|
|
2146
2191
|
$ commet push --output agent --yes Agent/CI \u2014 structured JSON, no prompts
|
|
2147
|
-
$ COMMET_API_KEY=
|
|
2192
|
+
$ COMMET_API_KEY=ck_... commet push --yes CI pipeline
|
|
2148
2193
|
`
|
|
2149
2194
|
).action(async (options) => {
|
|
2150
2195
|
const agentMode = isAgentMode(options);
|
|
@@ -2314,196 +2359,2731 @@ Examples:
|
|
|
2314
2359
|
}
|
|
2315
2360
|
});
|
|
2316
2361
|
|
|
2317
|
-
// src/
|
|
2318
|
-
var
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
"after",
|
|
2323
|
-
`
|
|
2324
|
-
Workflow:
|
|
2325
|
-
$ commet pull Sync remote \u2192 commet.config.ts
|
|
2326
|
-
$ commet push Push local changes \u2192 remote
|
|
2327
|
-
$ commet pull --dry-run See what's configured
|
|
2362
|
+
// src/commands/resources/factory.ts
|
|
2363
|
+
var import_node2 = require("@commet/node");
|
|
2364
|
+
var import_chalk14 = __toESM(require("chalk"));
|
|
2365
|
+
var import_commander10 = require("commander");
|
|
2366
|
+
var import_ora8 = __toESM(require("ora"));
|
|
2328
2367
|
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2368
|
+
// src/utils/sdk.ts
|
|
2369
|
+
var import_node = require("@commet/node");
|
|
2370
|
+
function createSdkClient() {
|
|
2371
|
+
const envKey = process.env.COMMET_API_KEY;
|
|
2372
|
+
if (envKey) {
|
|
2373
|
+
return new import_node.Commet({ apiKey: envKey });
|
|
2374
|
+
}
|
|
2375
|
+
const config = loadProjectConfig();
|
|
2376
|
+
if (config?.apiKey) {
|
|
2377
|
+
return new import_node.Commet({ apiKey: config.apiKey });
|
|
2378
|
+
}
|
|
2379
|
+
exitWithError({
|
|
2380
|
+
code: "api_key_required",
|
|
2381
|
+
message: "No API key found. Set COMMET_API_KEY env var, or run `commet link` to auto-generate one.",
|
|
2382
|
+
action: "commet link"
|
|
2383
|
+
});
|
|
2384
|
+
}
|
|
2333
2385
|
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
);
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
)
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2386
|
+
// src/commands/resources/factory.ts
|
|
2387
|
+
function createResourceCommand(def) {
|
|
2388
|
+
const command = new import_commander10.Command(def.name).description(def.description);
|
|
2389
|
+
for (const [actionName, actionDef] of Object.entries(def.actions)) {
|
|
2390
|
+
const subcommand = new import_commander10.Command(actionName).description(actionDef.description).option(
|
|
2391
|
+
"--output <format>",
|
|
2392
|
+
"Output format: human (default) or agent",
|
|
2393
|
+
"human"
|
|
2394
|
+
);
|
|
2395
|
+
for (const param of actionDef.params) {
|
|
2396
|
+
if (param.required) {
|
|
2397
|
+
subcommand.requiredOption(param.flag, param.description);
|
|
2398
|
+
} else {
|
|
2399
|
+
subcommand.option(param.flag, param.description);
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
subcommand.action(async (options) => {
|
|
2403
|
+
const agentMode = isAgentMode(options);
|
|
2404
|
+
const spinner = agentMode ? null : (0, import_ora8.default)(`Running ${def.name} ${actionName}...`).start();
|
|
2405
|
+
try {
|
|
2406
|
+
const client = createSdkClient();
|
|
2407
|
+
const resource = client[def.sdkProperty];
|
|
2408
|
+
const method = resource[actionDef.method];
|
|
2409
|
+
let params;
|
|
2410
|
+
if (actionDef.buildParams) {
|
|
2411
|
+
params = actionDef.buildParams(options);
|
|
2412
|
+
} else {
|
|
2413
|
+
const built = {};
|
|
2414
|
+
for (const paramDef of actionDef.params) {
|
|
2415
|
+
const rawValue = options[paramDef.sdkKey];
|
|
2416
|
+
if (rawValue === void 0) {
|
|
2417
|
+
continue;
|
|
2418
|
+
}
|
|
2419
|
+
built[paramDef.sdkKey] = paramDef.parse ? paramDef.parse(rawValue) : rawValue;
|
|
2420
|
+
}
|
|
2421
|
+
params = built;
|
|
2422
|
+
}
|
|
2423
|
+
const result = await method.call(resource, params);
|
|
2424
|
+
spinner?.succeed(`${def.name} ${actionName}`);
|
|
2425
|
+
if (agentMode) {
|
|
2426
|
+
console.log(JSON.stringify(result));
|
|
2427
|
+
} else {
|
|
2428
|
+
console.log(JSON.stringify(result, null, 2));
|
|
2429
|
+
}
|
|
2430
|
+
} catch (error) {
|
|
2431
|
+
if (error instanceof import_node2.CommetValidationError) {
|
|
2432
|
+
spinner?.fail(`Validation error`);
|
|
2433
|
+
if (agentMode) {
|
|
2434
|
+
console.log(
|
|
2435
|
+
JSON.stringify({
|
|
2436
|
+
error: {
|
|
2437
|
+
code: "validation_error",
|
|
2438
|
+
message: error.message,
|
|
2439
|
+
validationErrors: error.validationErrors
|
|
2440
|
+
}
|
|
2441
|
+
})
|
|
2442
|
+
);
|
|
2443
|
+
} else {
|
|
2444
|
+
console.error(import_chalk14.default.red(`\u2717 ${error.message}`));
|
|
2445
|
+
for (const [field, messages] of Object.entries(
|
|
2446
|
+
error.validationErrors
|
|
2447
|
+
)) {
|
|
2448
|
+
for (const msg of messages) {
|
|
2449
|
+
console.error(import_chalk14.default.red(` ${field}: ${msg}`));
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
process.exit(1);
|
|
2454
|
+
}
|
|
2455
|
+
if (error instanceof import_node2.CommetAPIError) {
|
|
2456
|
+
spinner?.fail(`API error`);
|
|
2457
|
+
if (agentMode) {
|
|
2458
|
+
console.log(
|
|
2459
|
+
JSON.stringify({
|
|
2460
|
+
error: {
|
|
2461
|
+
code: error.code ?? `http_${error.statusCode}`,
|
|
2462
|
+
message: error.message,
|
|
2463
|
+
statusCode: error.statusCode
|
|
2464
|
+
}
|
|
2465
|
+
})
|
|
2466
|
+
);
|
|
2467
|
+
} else {
|
|
2468
|
+
console.error(
|
|
2469
|
+
import_chalk14.default.red(`\u2717 ${error.message} (${error.statusCode})`)
|
|
2470
|
+
);
|
|
2471
|
+
}
|
|
2472
|
+
process.exit(1);
|
|
2473
|
+
}
|
|
2474
|
+
spinner?.fail(`Unexpected error`);
|
|
2475
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2476
|
+
if (agentMode) {
|
|
2477
|
+
console.log(JSON.stringify({ error: { code: "unknown", message } }));
|
|
2478
|
+
} else {
|
|
2479
|
+
console.error(import_chalk14.default.red(`\u2717 ${message}`));
|
|
2480
|
+
}
|
|
2481
|
+
process.exit(1);
|
|
2482
|
+
}
|
|
2483
|
+
});
|
|
2484
|
+
command.addCommand(subcommand);
|
|
2356
2485
|
}
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2486
|
+
return command;
|
|
2487
|
+
}
|
|
2488
|
+
function generateResourceSchema(defs) {
|
|
2489
|
+
const resources = {};
|
|
2490
|
+
for (const def of defs) {
|
|
2491
|
+
const actions = {};
|
|
2492
|
+
for (const [actionName, actionDef] of Object.entries(def.actions)) {
|
|
2493
|
+
const params = {};
|
|
2494
|
+
for (const param of actionDef.params) {
|
|
2495
|
+
params[param.sdkKey] = {
|
|
2496
|
+
flag: param.flag,
|
|
2497
|
+
description: param.description,
|
|
2498
|
+
required: param.required ?? false
|
|
2499
|
+
};
|
|
2500
|
+
}
|
|
2501
|
+
actions[actionName] = {
|
|
2502
|
+
usage: `commet ${def.name} ${actionName}`,
|
|
2503
|
+
description: actionDef.description,
|
|
2504
|
+
params
|
|
2505
|
+
};
|
|
2373
2506
|
}
|
|
2374
|
-
|
|
2375
|
-
|
|
2507
|
+
resources[def.name] = {
|
|
2508
|
+
description: def.description,
|
|
2509
|
+
actions
|
|
2510
|
+
};
|
|
2376
2511
|
}
|
|
2377
|
-
|
|
2512
|
+
return resources;
|
|
2378
2513
|
}
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
"Not authenticated. Run 'commet login' (interactive) or set COMMET_API_KEY env var."
|
|
2387
|
-
);
|
|
2514
|
+
|
|
2515
|
+
// src/commands/resources/param-types.ts
|
|
2516
|
+
function parseJson(value) {
|
|
2517
|
+
try {
|
|
2518
|
+
return JSON.parse(value);
|
|
2519
|
+
} catch {
|
|
2520
|
+
throw new Error(`Invalid JSON: ${value}`);
|
|
2388
2521
|
}
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2522
|
+
}
|
|
2523
|
+
function parseNumber(value) {
|
|
2524
|
+
const num = Number(value);
|
|
2525
|
+
if (Number.isNaN(num)) {
|
|
2526
|
+
throw new Error(`Invalid number: ${value}`);
|
|
2393
2527
|
}
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2528
|
+
return num;
|
|
2529
|
+
}
|
|
2530
|
+
function parseBool(value) {
|
|
2531
|
+
if (value === "true") return true;
|
|
2532
|
+
if (value === "false") return false;
|
|
2533
|
+
throw new Error(`Invalid boolean: ${value}. Expected "true" or "false".`);
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2536
|
+
// src/commands/resources/registry.ts
|
|
2537
|
+
var customersResource = {
|
|
2538
|
+
name: "customers",
|
|
2539
|
+
description: "Manage customers",
|
|
2540
|
+
sdkProperty: "customers",
|
|
2541
|
+
actions: {
|
|
2542
|
+
create: {
|
|
2543
|
+
method: "create",
|
|
2544
|
+
description: "Create a customer",
|
|
2545
|
+
params: [
|
|
2546
|
+
{
|
|
2547
|
+
flag: "--email <email>",
|
|
2548
|
+
description: "Billing email (required)",
|
|
2549
|
+
required: true,
|
|
2550
|
+
sdkKey: "email"
|
|
2551
|
+
},
|
|
2552
|
+
{ flag: "--id <id>", description: "Custom customer ID", sdkKey: "id" },
|
|
2553
|
+
{
|
|
2554
|
+
flag: "--full-name <name>",
|
|
2555
|
+
description: "Full name",
|
|
2556
|
+
sdkKey: "fullName"
|
|
2557
|
+
},
|
|
2558
|
+
{ flag: "--domain <domain>", description: "Domain", sdkKey: "domain" },
|
|
2559
|
+
{
|
|
2560
|
+
flag: "--website <url>",
|
|
2561
|
+
description: "Website URL",
|
|
2562
|
+
sdkKey: "website"
|
|
2563
|
+
},
|
|
2564
|
+
{
|
|
2565
|
+
flag: "--timezone <tz>",
|
|
2566
|
+
description: "Timezone",
|
|
2567
|
+
sdkKey: "timezone"
|
|
2568
|
+
},
|
|
2569
|
+
{
|
|
2570
|
+
flag: "--language <lang>",
|
|
2571
|
+
description: "Language code",
|
|
2572
|
+
sdkKey: "language"
|
|
2573
|
+
},
|
|
2574
|
+
{
|
|
2575
|
+
flag: "--industry <industry>",
|
|
2576
|
+
description: "Industry",
|
|
2577
|
+
sdkKey: "industry"
|
|
2578
|
+
},
|
|
2579
|
+
{
|
|
2580
|
+
flag: "--metadata <json>",
|
|
2581
|
+
description: "Metadata (JSON)",
|
|
2582
|
+
parse: parseJson,
|
|
2583
|
+
sdkKey: "metadata"
|
|
2584
|
+
},
|
|
2585
|
+
{
|
|
2586
|
+
flag: "--address <json>",
|
|
2587
|
+
description: "Address (JSON: {line1, city, postalCode, country, ...})",
|
|
2588
|
+
parse: parseJson,
|
|
2589
|
+
sdkKey: "address"
|
|
2590
|
+
}
|
|
2591
|
+
]
|
|
2407
2592
|
},
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2593
|
+
"create-batch": {
|
|
2594
|
+
method: "createBatch",
|
|
2595
|
+
description: "Create multiple customers in a batch",
|
|
2596
|
+
params: [
|
|
2597
|
+
{
|
|
2598
|
+
flag: "--customers <json>",
|
|
2599
|
+
description: "Array of customer objects (JSON)",
|
|
2600
|
+
required: true,
|
|
2601
|
+
parse: parseJson,
|
|
2602
|
+
sdkKey: "customers"
|
|
2603
|
+
}
|
|
2604
|
+
]
|
|
2412
2605
|
},
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2606
|
+
get: {
|
|
2607
|
+
method: "get",
|
|
2608
|
+
description: "Get a customer by ID",
|
|
2609
|
+
params: [
|
|
2610
|
+
{
|
|
2611
|
+
flag: "--id <id>",
|
|
2612
|
+
description: "Customer ID",
|
|
2613
|
+
required: true,
|
|
2614
|
+
sdkKey: "id"
|
|
2615
|
+
}
|
|
2616
|
+
]
|
|
2416
2617
|
},
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2618
|
+
update: {
|
|
2619
|
+
method: "update",
|
|
2620
|
+
description: "Update a customer",
|
|
2621
|
+
params: [
|
|
2622
|
+
{
|
|
2623
|
+
flag: "--id <id>",
|
|
2624
|
+
description: "Customer ID",
|
|
2625
|
+
required: true,
|
|
2626
|
+
sdkKey: "id"
|
|
2627
|
+
},
|
|
2628
|
+
{
|
|
2629
|
+
flag: "--email <email>",
|
|
2630
|
+
description: "Billing email",
|
|
2631
|
+
sdkKey: "email"
|
|
2632
|
+
},
|
|
2633
|
+
{
|
|
2634
|
+
flag: "--full-name <name>",
|
|
2635
|
+
description: "Full name",
|
|
2636
|
+
sdkKey: "fullName"
|
|
2637
|
+
},
|
|
2638
|
+
{ flag: "--domain <domain>", description: "Domain", sdkKey: "domain" },
|
|
2639
|
+
{
|
|
2640
|
+
flag: "--website <url>",
|
|
2641
|
+
description: "Website URL",
|
|
2642
|
+
sdkKey: "website"
|
|
2643
|
+
},
|
|
2644
|
+
{
|
|
2645
|
+
flag: "--timezone <tz>",
|
|
2646
|
+
description: "Timezone",
|
|
2647
|
+
sdkKey: "timezone"
|
|
2648
|
+
},
|
|
2649
|
+
{
|
|
2650
|
+
flag: "--language <lang>",
|
|
2651
|
+
description: "Language code",
|
|
2652
|
+
sdkKey: "language"
|
|
2653
|
+
},
|
|
2654
|
+
{
|
|
2655
|
+
flag: "--industry <industry>",
|
|
2656
|
+
description: "Industry",
|
|
2657
|
+
sdkKey: "industry"
|
|
2658
|
+
},
|
|
2659
|
+
{
|
|
2660
|
+
flag: "--metadata <json>",
|
|
2661
|
+
description: "Metadata (JSON)",
|
|
2662
|
+
parse: parseJson,
|
|
2663
|
+
sdkKey: "metadata"
|
|
2664
|
+
},
|
|
2665
|
+
{
|
|
2666
|
+
flag: "--address <json>",
|
|
2667
|
+
description: "Address (JSON)",
|
|
2668
|
+
parse: parseJson,
|
|
2669
|
+
sdkKey: "address"
|
|
2670
|
+
}
|
|
2671
|
+
]
|
|
2672
|
+
},
|
|
2673
|
+
list: {
|
|
2674
|
+
method: "list",
|
|
2675
|
+
description: "List customers",
|
|
2676
|
+
params: [
|
|
2677
|
+
{
|
|
2678
|
+
flag: "--search <query>",
|
|
2679
|
+
description: "Search query",
|
|
2680
|
+
sdkKey: "search"
|
|
2681
|
+
},
|
|
2682
|
+
{
|
|
2683
|
+
flag: "--limit <n>",
|
|
2684
|
+
description: "Max results",
|
|
2685
|
+
parse: parseNumber,
|
|
2686
|
+
sdkKey: "limit"
|
|
2687
|
+
},
|
|
2688
|
+
{
|
|
2689
|
+
flag: "--cursor <cursor>",
|
|
2690
|
+
description: "Pagination cursor",
|
|
2691
|
+
sdkKey: "cursor"
|
|
2692
|
+
},
|
|
2693
|
+
{
|
|
2694
|
+
flag: "--start-date <date>",
|
|
2695
|
+
description: "Start date filter",
|
|
2696
|
+
sdkKey: "startDate"
|
|
2697
|
+
},
|
|
2698
|
+
{
|
|
2699
|
+
flag: "--end-date <date>",
|
|
2700
|
+
description: "End date filter",
|
|
2701
|
+
sdkKey: "endDate"
|
|
2702
|
+
}
|
|
2703
|
+
]
|
|
2458
2704
|
}
|
|
2459
|
-
};
|
|
2460
|
-
console.log(JSON.stringify(output, null, 2));
|
|
2461
|
-
}
|
|
2462
|
-
function printDefaultScreen() {
|
|
2463
|
-
const version = import_chalk14.default.dim(`v${package_default.version}`);
|
|
2464
|
-
console.log(`
|
|
2465
|
-
${commetColor.bold("Commet")} ${version}`);
|
|
2466
|
-
console.log(import_chalk14.default.dim(" Billing infrastructure as code\n"));
|
|
2467
|
-
const authenticated = authExists();
|
|
2468
|
-
const projectConfig = projectConfigExists() ? loadProjectConfig() : null;
|
|
2469
|
-
const configFile = findConfigFile(process.cwd());
|
|
2470
|
-
if (authenticated) {
|
|
2471
|
-
console.log(import_chalk14.default.green(" \u2713 Authenticated"));
|
|
2472
|
-
} else {
|
|
2473
|
-
console.log(
|
|
2474
|
-
` ${import_chalk14.default.yellow("\u26A0")} Not logged in ${import_chalk14.default.dim("\u2192 commet login")}`
|
|
2475
|
-
);
|
|
2476
|
-
}
|
|
2477
|
-
if (projectConfig) {
|
|
2478
|
-
console.log(
|
|
2479
|
-
import_chalk14.default.green(
|
|
2480
|
-
` \u2713 ${projectConfig.orgName} ${import_chalk14.default.dim(`(${projectConfig.mode})`)}`
|
|
2481
|
-
)
|
|
2482
|
-
);
|
|
2483
|
-
console.log(import_chalk14.default.dim(` ${projectConfig.orgId}`));
|
|
2484
|
-
} else if (authenticated) {
|
|
2485
|
-
console.log(
|
|
2486
|
-
` ${import_chalk14.default.yellow("\u26A0")} No project linked ${import_chalk14.default.dim("\u2192 commet link")}`
|
|
2487
|
-
);
|
|
2488
|
-
}
|
|
2489
|
-
if (configFile) {
|
|
2490
|
-
const fileName = configFile.split("/").pop();
|
|
2491
|
-
console.log(import_chalk14.default.green(` \u2713 ${fileName}`));
|
|
2492
|
-
} else if (projectConfig) {
|
|
2493
|
-
console.log(
|
|
2494
|
-
` ${import_chalk14.default.yellow("\u26A0")} No config file ${import_chalk14.default.dim("\u2192 commet pull")}`
|
|
2495
|
-
);
|
|
2496
2705
|
}
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2706
|
+
};
|
|
2707
|
+
var subscriptionsResource = {
|
|
2708
|
+
name: "subscriptions",
|
|
2709
|
+
description: "Manage subscriptions",
|
|
2710
|
+
sdkProperty: "subscriptions",
|
|
2711
|
+
actions: {
|
|
2712
|
+
create: {
|
|
2713
|
+
method: "create",
|
|
2714
|
+
description: "Create a subscription",
|
|
2715
|
+
params: [
|
|
2716
|
+
{
|
|
2717
|
+
flag: "--customer-id <id>",
|
|
2718
|
+
description: "Customer ID (required)",
|
|
2719
|
+
required: true,
|
|
2720
|
+
sdkKey: "customerId"
|
|
2721
|
+
},
|
|
2722
|
+
{
|
|
2723
|
+
flag: "--plan-code <code>",
|
|
2724
|
+
description: "Plan code (provide this or --plan-id)",
|
|
2725
|
+
sdkKey: "planCode"
|
|
2726
|
+
},
|
|
2727
|
+
{
|
|
2728
|
+
flag: "--plan-id <id>",
|
|
2729
|
+
description: "Plan ID (provide this or --plan-code)",
|
|
2730
|
+
sdkKey: "planId"
|
|
2731
|
+
},
|
|
2732
|
+
{
|
|
2733
|
+
flag: "--billing-interval <interval>",
|
|
2734
|
+
description: "Billing interval: weekly, monthly, quarterly, yearly, one_time",
|
|
2735
|
+
sdkKey: "billingInterval"
|
|
2736
|
+
},
|
|
2737
|
+
{
|
|
2738
|
+
flag: "--initial-seats <json>",
|
|
2739
|
+
description: "Initial seats map (JSON: {featureCode: count})",
|
|
2740
|
+
parse: parseJson,
|
|
2741
|
+
sdkKey: "initialSeats"
|
|
2742
|
+
},
|
|
2743
|
+
{
|
|
2744
|
+
flag: "--skip-trial <bool>",
|
|
2745
|
+
description: "Skip trial period",
|
|
2746
|
+
parse: parseBool,
|
|
2747
|
+
sdkKey: "skipTrial"
|
|
2748
|
+
},
|
|
2749
|
+
{
|
|
2750
|
+
flag: "--name <name>",
|
|
2751
|
+
description: "Subscription name",
|
|
2752
|
+
sdkKey: "name"
|
|
2753
|
+
},
|
|
2754
|
+
{
|
|
2755
|
+
flag: "--start-date <date>",
|
|
2756
|
+
description: "Start date (ISO 8601)",
|
|
2757
|
+
sdkKey: "startDate"
|
|
2758
|
+
},
|
|
2759
|
+
{
|
|
2760
|
+
flag: "--success-url <url>",
|
|
2761
|
+
description: "Redirect URL after successful checkout",
|
|
2762
|
+
sdkKey: "successUrl"
|
|
2763
|
+
}
|
|
2764
|
+
],
|
|
2765
|
+
buildParams: (options) => {
|
|
2766
|
+
const params = {
|
|
2767
|
+
customerId: options.customerId
|
|
2768
|
+
};
|
|
2769
|
+
if (options.planCode) params.planCode = options.planCode;
|
|
2770
|
+
if (options.planId) params.planId = options.planId;
|
|
2771
|
+
if (options.billingInterval)
|
|
2772
|
+
params.billingInterval = options.billingInterval;
|
|
2773
|
+
if (options.initialSeats)
|
|
2774
|
+
params.initialSeats = parseJson(options.initialSeats);
|
|
2775
|
+
if (options.skipTrial) params.skipTrial = parseBool(options.skipTrial);
|
|
2776
|
+
if (options.name) params.name = options.name;
|
|
2777
|
+
if (options.startDate) params.startDate = options.startDate;
|
|
2778
|
+
if (options.successUrl) params.successUrl = options.successUrl;
|
|
2779
|
+
return params;
|
|
2780
|
+
}
|
|
2781
|
+
},
|
|
2782
|
+
"get-active": {
|
|
2783
|
+
method: "getActive",
|
|
2784
|
+
description: "Get the active subscription for a customer",
|
|
2785
|
+
params: [
|
|
2786
|
+
{
|
|
2787
|
+
flag: "--customer-id <id>",
|
|
2788
|
+
description: "Customer ID",
|
|
2789
|
+
required: true,
|
|
2790
|
+
sdkKey: "customerId"
|
|
2791
|
+
}
|
|
2792
|
+
]
|
|
2793
|
+
},
|
|
2794
|
+
cancel: {
|
|
2795
|
+
method: "cancel",
|
|
2796
|
+
description: "Cancel a subscription",
|
|
2797
|
+
params: [
|
|
2798
|
+
{
|
|
2799
|
+
flag: "--id <id>",
|
|
2800
|
+
description: "Subscription ID",
|
|
2801
|
+
required: true,
|
|
2802
|
+
sdkKey: "id"
|
|
2803
|
+
},
|
|
2804
|
+
{
|
|
2805
|
+
flag: "--reason <reason>",
|
|
2806
|
+
description: "Cancellation reason",
|
|
2807
|
+
sdkKey: "reason"
|
|
2808
|
+
},
|
|
2809
|
+
{
|
|
2810
|
+
flag: "--immediate <bool>",
|
|
2811
|
+
description: "Cancel immediately instead of at period end",
|
|
2812
|
+
parse: parseBool,
|
|
2813
|
+
sdkKey: "immediate"
|
|
2814
|
+
}
|
|
2815
|
+
]
|
|
2816
|
+
},
|
|
2817
|
+
uncancel: {
|
|
2818
|
+
method: "uncancel",
|
|
2819
|
+
description: "Revert a pending cancellation",
|
|
2820
|
+
params: [
|
|
2821
|
+
{
|
|
2822
|
+
flag: "--id <id>",
|
|
2823
|
+
description: "Subscription ID",
|
|
2824
|
+
required: true,
|
|
2825
|
+
sdkKey: "id"
|
|
2826
|
+
}
|
|
2827
|
+
]
|
|
2828
|
+
},
|
|
2829
|
+
"change-plan": {
|
|
2830
|
+
method: "changePlan",
|
|
2831
|
+
description: "Change subscription plan",
|
|
2832
|
+
params: [
|
|
2833
|
+
{
|
|
2834
|
+
flag: "--id <id>",
|
|
2835
|
+
description: "Subscription ID",
|
|
2836
|
+
required: true,
|
|
2837
|
+
sdkKey: "id"
|
|
2838
|
+
},
|
|
2839
|
+
{
|
|
2840
|
+
flag: "--new-plan-id <id>",
|
|
2841
|
+
description: "New plan ID",
|
|
2842
|
+
sdkKey: "newPlanId"
|
|
2843
|
+
},
|
|
2844
|
+
{
|
|
2845
|
+
flag: "--new-billing-interval <interval>",
|
|
2846
|
+
description: "New billing interval",
|
|
2847
|
+
sdkKey: "newBillingInterval"
|
|
2848
|
+
}
|
|
2849
|
+
]
|
|
2850
|
+
},
|
|
2851
|
+
list: {
|
|
2852
|
+
method: "list",
|
|
2853
|
+
description: "List subscriptions",
|
|
2854
|
+
params: [
|
|
2855
|
+
{
|
|
2856
|
+
flag: "--customer-id <id>",
|
|
2857
|
+
description: "Filter by customer ID",
|
|
2858
|
+
sdkKey: "customerId"
|
|
2859
|
+
},
|
|
2860
|
+
{
|
|
2861
|
+
flag: "--status <status>",
|
|
2862
|
+
description: "Filter by status",
|
|
2863
|
+
sdkKey: "status"
|
|
2864
|
+
},
|
|
2865
|
+
{
|
|
2866
|
+
flag: "--limit <n>",
|
|
2867
|
+
description: "Max results",
|
|
2868
|
+
parse: parseNumber,
|
|
2869
|
+
sdkKey: "limit"
|
|
2870
|
+
},
|
|
2871
|
+
{
|
|
2872
|
+
flag: "--cursor <cursor>",
|
|
2873
|
+
description: "Pagination cursor",
|
|
2874
|
+
sdkKey: "cursor"
|
|
2875
|
+
}
|
|
2876
|
+
]
|
|
2877
|
+
},
|
|
2878
|
+
"preview-change": {
|
|
2879
|
+
method: "previewChange",
|
|
2880
|
+
description: "Preview plan change proration without applying",
|
|
2881
|
+
params: [
|
|
2882
|
+
{
|
|
2883
|
+
flag: "--id <id>",
|
|
2884
|
+
description: "Subscription ID",
|
|
2885
|
+
required: true,
|
|
2886
|
+
sdkKey: "id"
|
|
2887
|
+
},
|
|
2888
|
+
{
|
|
2889
|
+
flag: "--plan-id <planId>",
|
|
2890
|
+
description: "New plan ID",
|
|
2891
|
+
sdkKey: "planId"
|
|
2892
|
+
},
|
|
2893
|
+
{
|
|
2894
|
+
flag: "--billing-interval <interval>",
|
|
2895
|
+
description: "New billing interval",
|
|
2896
|
+
sdkKey: "billingInterval"
|
|
2897
|
+
}
|
|
2898
|
+
]
|
|
2899
|
+
},
|
|
2900
|
+
"activate-addon": {
|
|
2901
|
+
method: "activateAddon",
|
|
2902
|
+
description: "Activate an addon on a subscription",
|
|
2903
|
+
params: [
|
|
2904
|
+
{
|
|
2905
|
+
flag: "--id <id>",
|
|
2906
|
+
description: "Subscription ID",
|
|
2907
|
+
required: true,
|
|
2908
|
+
sdkKey: "id"
|
|
2909
|
+
},
|
|
2910
|
+
{
|
|
2911
|
+
flag: "--addon-id <addonId>",
|
|
2912
|
+
description: "Addon ID",
|
|
2913
|
+
required: true,
|
|
2914
|
+
sdkKey: "addonId"
|
|
2915
|
+
}
|
|
2916
|
+
]
|
|
2917
|
+
},
|
|
2918
|
+
"deactivate-addon": {
|
|
2919
|
+
method: "deactivateAddon",
|
|
2920
|
+
description: "Deactivate an addon from a subscription",
|
|
2921
|
+
params: [
|
|
2922
|
+
{
|
|
2923
|
+
flag: "--id <id>",
|
|
2924
|
+
description: "Subscription ID",
|
|
2925
|
+
required: true,
|
|
2926
|
+
sdkKey: "id"
|
|
2927
|
+
},
|
|
2928
|
+
{
|
|
2929
|
+
flag: "--addon-id <addonId>",
|
|
2930
|
+
description: "Addon ID",
|
|
2931
|
+
required: true,
|
|
2932
|
+
sdkKey: "addonId"
|
|
2933
|
+
}
|
|
2934
|
+
]
|
|
2935
|
+
},
|
|
2936
|
+
"adjust-balance": {
|
|
2937
|
+
method: "adjustBalance",
|
|
2938
|
+
description: "Adjust subscription balance or credits",
|
|
2939
|
+
params: [
|
|
2940
|
+
{
|
|
2941
|
+
flag: "--id <id>",
|
|
2942
|
+
description: "Subscription ID",
|
|
2943
|
+
required: true,
|
|
2944
|
+
sdkKey: "id"
|
|
2945
|
+
},
|
|
2946
|
+
{
|
|
2947
|
+
flag: "--amount <amount>",
|
|
2948
|
+
description: "Amount (positive adds, negative subtracts)",
|
|
2949
|
+
required: true,
|
|
2950
|
+
parse: parseNumber,
|
|
2951
|
+
sdkKey: "amount"
|
|
2952
|
+
},
|
|
2953
|
+
{
|
|
2954
|
+
flag: "--reason <reason>",
|
|
2955
|
+
description: "Reason for adjustment",
|
|
2956
|
+
sdkKey: "reason"
|
|
2957
|
+
},
|
|
2958
|
+
{
|
|
2959
|
+
flag: "--type <type>",
|
|
2960
|
+
description: "Adjustment type: balance or credits",
|
|
2961
|
+
sdkKey: "type"
|
|
2962
|
+
}
|
|
2963
|
+
]
|
|
2964
|
+
},
|
|
2965
|
+
"topup-balance": {
|
|
2966
|
+
method: "topupBalance",
|
|
2967
|
+
description: "Top up subscription balance (charges payment method)",
|
|
2968
|
+
params: [
|
|
2969
|
+
{
|
|
2970
|
+
flag: "--id <id>",
|
|
2971
|
+
description: "Subscription ID",
|
|
2972
|
+
required: true,
|
|
2973
|
+
sdkKey: "id"
|
|
2974
|
+
},
|
|
2975
|
+
{
|
|
2976
|
+
flag: "--amount <amount>",
|
|
2977
|
+
description: "Amount to top up",
|
|
2978
|
+
required: true,
|
|
2979
|
+
parse: parseNumber,
|
|
2980
|
+
sdkKey: "amount"
|
|
2981
|
+
}
|
|
2982
|
+
]
|
|
2983
|
+
},
|
|
2984
|
+
"purchase-credits": {
|
|
2985
|
+
method: "purchaseCredits",
|
|
2986
|
+
description: "Purchase a credit pack for a subscription",
|
|
2987
|
+
params: [
|
|
2988
|
+
{
|
|
2989
|
+
flag: "--id <id>",
|
|
2990
|
+
description: "Subscription ID",
|
|
2991
|
+
required: true,
|
|
2992
|
+
sdkKey: "id"
|
|
2993
|
+
},
|
|
2994
|
+
{
|
|
2995
|
+
flag: "--credit-pack-id <creditPackId>",
|
|
2996
|
+
description: "Credit pack ID",
|
|
2997
|
+
required: true,
|
|
2998
|
+
sdkKey: "creditPackId"
|
|
2999
|
+
}
|
|
3000
|
+
]
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
};
|
|
3004
|
+
var plansResource = {
|
|
3005
|
+
name: "plans",
|
|
3006
|
+
description: "Manage plans",
|
|
3007
|
+
sdkProperty: "plans",
|
|
3008
|
+
actions: {
|
|
3009
|
+
list: {
|
|
3010
|
+
method: "list",
|
|
3011
|
+
description: "List plans",
|
|
3012
|
+
params: [
|
|
3013
|
+
{
|
|
3014
|
+
flag: "--include-private <bool>",
|
|
3015
|
+
description: "Include private plans",
|
|
3016
|
+
parse: parseBool,
|
|
3017
|
+
sdkKey: "includePrivate"
|
|
3018
|
+
},
|
|
3019
|
+
{
|
|
3020
|
+
flag: "--limit <n>",
|
|
3021
|
+
description: "Max results",
|
|
3022
|
+
parse: parseNumber,
|
|
3023
|
+
sdkKey: "limit"
|
|
3024
|
+
},
|
|
3025
|
+
{
|
|
3026
|
+
flag: "--cursor <cursor>",
|
|
3027
|
+
description: "Pagination cursor",
|
|
3028
|
+
sdkKey: "cursor"
|
|
3029
|
+
}
|
|
3030
|
+
]
|
|
3031
|
+
},
|
|
3032
|
+
get: {
|
|
3033
|
+
method: "get",
|
|
3034
|
+
description: "Get plan details",
|
|
3035
|
+
params: [
|
|
3036
|
+
{
|
|
3037
|
+
flag: "--id <id>",
|
|
3038
|
+
description: "Plan ID",
|
|
3039
|
+
required: true,
|
|
3040
|
+
sdkKey: "id"
|
|
3041
|
+
}
|
|
3042
|
+
]
|
|
3043
|
+
},
|
|
3044
|
+
create: {
|
|
3045
|
+
method: "create",
|
|
3046
|
+
description: "Create a plan",
|
|
3047
|
+
params: [
|
|
3048
|
+
{
|
|
3049
|
+
flag: "--name <name>",
|
|
3050
|
+
description: "Plan name",
|
|
3051
|
+
required: true,
|
|
3052
|
+
sdkKey: "name"
|
|
3053
|
+
},
|
|
3054
|
+
{
|
|
3055
|
+
flag: "--code <code>",
|
|
3056
|
+
description: "Plan code",
|
|
3057
|
+
required: true,
|
|
3058
|
+
sdkKey: "code"
|
|
3059
|
+
},
|
|
3060
|
+
{
|
|
3061
|
+
flag: "--description <desc>",
|
|
3062
|
+
description: "Plan description",
|
|
3063
|
+
sdkKey: "description"
|
|
3064
|
+
},
|
|
3065
|
+
{
|
|
3066
|
+
flag: "--consumption-model <model>",
|
|
3067
|
+
description: "Consumption model: metered, credits, or balance",
|
|
3068
|
+
sdkKey: "consumptionModel"
|
|
3069
|
+
},
|
|
3070
|
+
{
|
|
3071
|
+
flag: "--is-public <bool>",
|
|
3072
|
+
description: "Whether plan is publicly visible",
|
|
3073
|
+
parse: parseBool,
|
|
3074
|
+
sdkKey: "isPublic"
|
|
3075
|
+
},
|
|
3076
|
+
{
|
|
3077
|
+
flag: "--is-free <bool>",
|
|
3078
|
+
description: "Whether plan is free",
|
|
3079
|
+
parse: parseBool,
|
|
3080
|
+
sdkKey: "isFree"
|
|
3081
|
+
},
|
|
3082
|
+
{
|
|
3083
|
+
flag: "--block-on-exhaustion <bool>",
|
|
3084
|
+
description: "Block usage when balance/credits exhausted",
|
|
3085
|
+
parse: parseBool,
|
|
3086
|
+
sdkKey: "blockOnExhaustion"
|
|
3087
|
+
},
|
|
3088
|
+
{
|
|
3089
|
+
flag: "--plan-group-id <id>",
|
|
3090
|
+
description: "Plan group ID",
|
|
3091
|
+
sdkKey: "planGroupId"
|
|
3092
|
+
},
|
|
3093
|
+
{
|
|
3094
|
+
flag: "--metadata <json>",
|
|
3095
|
+
description: "Metadata (JSON)",
|
|
3096
|
+
parse: parseJson,
|
|
3097
|
+
sdkKey: "metadata"
|
|
3098
|
+
}
|
|
3099
|
+
]
|
|
3100
|
+
},
|
|
3101
|
+
update: {
|
|
3102
|
+
method: "update",
|
|
3103
|
+
description: "Update a plan",
|
|
3104
|
+
params: [
|
|
3105
|
+
{
|
|
3106
|
+
flag: "--id <id>",
|
|
3107
|
+
description: "Plan ID",
|
|
3108
|
+
required: true,
|
|
3109
|
+
sdkKey: "id"
|
|
3110
|
+
},
|
|
3111
|
+
{
|
|
3112
|
+
flag: "--name <name>",
|
|
3113
|
+
description: "Plan name",
|
|
3114
|
+
sdkKey: "name"
|
|
3115
|
+
},
|
|
3116
|
+
{
|
|
3117
|
+
flag: "--description <desc>",
|
|
3118
|
+
description: "Plan description",
|
|
3119
|
+
sdkKey: "description"
|
|
3120
|
+
},
|
|
3121
|
+
{
|
|
3122
|
+
flag: "--metadata <json>",
|
|
3123
|
+
description: "Metadata (JSON)",
|
|
3124
|
+
parse: parseJson,
|
|
3125
|
+
sdkKey: "metadata"
|
|
3126
|
+
},
|
|
3127
|
+
{
|
|
3128
|
+
flag: "--is-public <bool>",
|
|
3129
|
+
description: "Whether plan is publicly visible",
|
|
3130
|
+
parse: parseBool,
|
|
3131
|
+
sdkKey: "isPublic"
|
|
3132
|
+
}
|
|
3133
|
+
]
|
|
3134
|
+
},
|
|
3135
|
+
delete: {
|
|
3136
|
+
method: "delete",
|
|
3137
|
+
description: "Delete a plan",
|
|
3138
|
+
params: [
|
|
3139
|
+
{
|
|
3140
|
+
flag: "--id <id>",
|
|
3141
|
+
description: "Plan ID",
|
|
3142
|
+
required: true,
|
|
3143
|
+
sdkKey: "id"
|
|
3144
|
+
}
|
|
3145
|
+
]
|
|
3146
|
+
},
|
|
3147
|
+
"set-visibility": {
|
|
3148
|
+
method: "setVisibility",
|
|
3149
|
+
description: "Set plan visibility",
|
|
3150
|
+
params: [
|
|
3151
|
+
{
|
|
3152
|
+
flag: "--id <id>",
|
|
3153
|
+
description: "Plan ID",
|
|
3154
|
+
required: true,
|
|
3155
|
+
sdkKey: "id"
|
|
3156
|
+
},
|
|
3157
|
+
{
|
|
3158
|
+
flag: "--is-public <bool>",
|
|
3159
|
+
description: "Public visibility",
|
|
3160
|
+
required: true,
|
|
3161
|
+
parse: parseBool,
|
|
3162
|
+
sdkKey: "isPublic"
|
|
3163
|
+
}
|
|
3164
|
+
]
|
|
3165
|
+
},
|
|
3166
|
+
"add-feature": {
|
|
3167
|
+
method: "addFeature",
|
|
3168
|
+
description: "Add a feature to a plan",
|
|
3169
|
+
params: [
|
|
3170
|
+
{
|
|
3171
|
+
flag: "--plan-id <id>",
|
|
3172
|
+
description: "Plan ID",
|
|
3173
|
+
required: true,
|
|
3174
|
+
sdkKey: "planId"
|
|
3175
|
+
},
|
|
3176
|
+
{
|
|
3177
|
+
flag: "--feature-id <id>",
|
|
3178
|
+
description: "Feature ID",
|
|
3179
|
+
required: true,
|
|
3180
|
+
sdkKey: "featureId"
|
|
3181
|
+
},
|
|
3182
|
+
{
|
|
3183
|
+
flag: "--enabled <bool>",
|
|
3184
|
+
description: "Whether feature is enabled",
|
|
3185
|
+
parse: parseBool,
|
|
3186
|
+
sdkKey: "enabled"
|
|
3187
|
+
},
|
|
3188
|
+
{
|
|
3189
|
+
flag: "--included-amount <n>",
|
|
3190
|
+
description: "Included amount",
|
|
3191
|
+
parse: parseNumber,
|
|
3192
|
+
sdkKey: "includedAmount"
|
|
3193
|
+
},
|
|
3194
|
+
{
|
|
3195
|
+
flag: "--unlimited <bool>",
|
|
3196
|
+
description: "Whether usage is unlimited",
|
|
3197
|
+
parse: parseBool,
|
|
3198
|
+
sdkKey: "unlimited"
|
|
3199
|
+
},
|
|
3200
|
+
{
|
|
3201
|
+
flag: "--overage-enabled <bool>",
|
|
3202
|
+
description: "Whether overage is enabled",
|
|
3203
|
+
parse: parseBool,
|
|
3204
|
+
sdkKey: "overageEnabled"
|
|
3205
|
+
},
|
|
3206
|
+
{
|
|
3207
|
+
flag: "--overage-unit-price <n>",
|
|
3208
|
+
description: "Overage unit price (fixed pricing)",
|
|
3209
|
+
parse: parseNumber,
|
|
3210
|
+
sdkKey: "overageUnitPrice"
|
|
3211
|
+
},
|
|
3212
|
+
{
|
|
3213
|
+
flag: "--pricing-mode <mode>",
|
|
3214
|
+
description: "Pricing mode: fixed or ai_model",
|
|
3215
|
+
sdkKey: "pricingMode"
|
|
3216
|
+
},
|
|
3217
|
+
{
|
|
3218
|
+
flag: "--margin <n>",
|
|
3219
|
+
description: "Margin percentage (ai_model pricing)",
|
|
3220
|
+
parse: parseNumber,
|
|
3221
|
+
sdkKey: "margin"
|
|
3222
|
+
},
|
|
3223
|
+
{
|
|
3224
|
+
flag: "--credits-per-unit <n>",
|
|
3225
|
+
description: "Credits per unit",
|
|
3226
|
+
parse: parseNumber,
|
|
3227
|
+
sdkKey: "creditsPerUnit"
|
|
3228
|
+
}
|
|
3229
|
+
]
|
|
3230
|
+
},
|
|
3231
|
+
"update-feature": {
|
|
3232
|
+
method: "updateFeature",
|
|
3233
|
+
description: "Update a feature on a plan",
|
|
3234
|
+
params: [
|
|
3235
|
+
{
|
|
3236
|
+
flag: "--plan-id <id>",
|
|
3237
|
+
description: "Plan ID",
|
|
3238
|
+
required: true,
|
|
3239
|
+
sdkKey: "planId"
|
|
3240
|
+
},
|
|
3241
|
+
{
|
|
3242
|
+
flag: "--feature-id <id>",
|
|
3243
|
+
description: "Feature ID",
|
|
3244
|
+
required: true,
|
|
3245
|
+
sdkKey: "featureId"
|
|
3246
|
+
},
|
|
3247
|
+
{
|
|
3248
|
+
flag: "--enabled <bool>",
|
|
3249
|
+
description: "Whether feature is enabled",
|
|
3250
|
+
parse: parseBool,
|
|
3251
|
+
sdkKey: "enabled"
|
|
3252
|
+
},
|
|
3253
|
+
{
|
|
3254
|
+
flag: "--included-amount <n>",
|
|
3255
|
+
description: "Included amount",
|
|
3256
|
+
parse: parseNumber,
|
|
3257
|
+
sdkKey: "includedAmount"
|
|
3258
|
+
},
|
|
3259
|
+
{
|
|
3260
|
+
flag: "--unlimited <bool>",
|
|
3261
|
+
description: "Whether usage is unlimited",
|
|
3262
|
+
parse: parseBool,
|
|
3263
|
+
sdkKey: "unlimited"
|
|
3264
|
+
},
|
|
3265
|
+
{
|
|
3266
|
+
flag: "--overage-enabled <bool>",
|
|
3267
|
+
description: "Whether overage is enabled",
|
|
3268
|
+
parse: parseBool,
|
|
3269
|
+
sdkKey: "overageEnabled"
|
|
3270
|
+
},
|
|
3271
|
+
{
|
|
3272
|
+
flag: "--overage-unit-price <n>",
|
|
3273
|
+
description: "Overage unit price (fixed pricing)",
|
|
3274
|
+
parse: parseNumber,
|
|
3275
|
+
sdkKey: "overageUnitPrice"
|
|
3276
|
+
},
|
|
3277
|
+
{
|
|
3278
|
+
flag: "--pricing-mode <mode>",
|
|
3279
|
+
description: "Pricing mode: fixed or ai_model",
|
|
3280
|
+
sdkKey: "pricingMode"
|
|
3281
|
+
},
|
|
3282
|
+
{
|
|
3283
|
+
flag: "--margin <n>",
|
|
3284
|
+
description: "Margin percentage (ai_model pricing)",
|
|
3285
|
+
parse: parseNumber,
|
|
3286
|
+
sdkKey: "margin"
|
|
3287
|
+
},
|
|
3288
|
+
{
|
|
3289
|
+
flag: "--credits-per-unit <n>",
|
|
3290
|
+
description: "Credits per unit",
|
|
3291
|
+
parse: parseNumber,
|
|
3292
|
+
sdkKey: "creditsPerUnit"
|
|
3293
|
+
}
|
|
3294
|
+
]
|
|
3295
|
+
},
|
|
3296
|
+
"remove-feature": {
|
|
3297
|
+
method: "removeFeature",
|
|
3298
|
+
description: "Remove a feature from a plan",
|
|
3299
|
+
params: [
|
|
3300
|
+
{
|
|
3301
|
+
flag: "--plan-id <id>",
|
|
3302
|
+
description: "Plan ID",
|
|
3303
|
+
required: true,
|
|
3304
|
+
sdkKey: "planId"
|
|
3305
|
+
},
|
|
3306
|
+
{
|
|
3307
|
+
flag: "--feature-id <id>",
|
|
3308
|
+
description: "Feature ID",
|
|
3309
|
+
required: true,
|
|
3310
|
+
sdkKey: "featureId"
|
|
3311
|
+
}
|
|
3312
|
+
]
|
|
3313
|
+
},
|
|
3314
|
+
"add-price": {
|
|
3315
|
+
method: "addPrice",
|
|
3316
|
+
description: "Add a price to a plan",
|
|
3317
|
+
params: [
|
|
3318
|
+
{
|
|
3319
|
+
flag: "--plan-id <id>",
|
|
3320
|
+
description: "Plan ID",
|
|
3321
|
+
required: true,
|
|
3322
|
+
sdkKey: "planId"
|
|
3323
|
+
},
|
|
3324
|
+
{
|
|
3325
|
+
flag: "--billing-interval <interval>",
|
|
3326
|
+
description: "Billing interval: weekly, monthly, quarterly, yearly, one_time",
|
|
3327
|
+
required: true,
|
|
3328
|
+
sdkKey: "billingInterval"
|
|
3329
|
+
},
|
|
3330
|
+
{
|
|
3331
|
+
flag: "--price <n>",
|
|
3332
|
+
description: "Price in cents",
|
|
3333
|
+
required: true,
|
|
3334
|
+
parse: parseNumber,
|
|
3335
|
+
sdkKey: "price"
|
|
3336
|
+
},
|
|
3337
|
+
{
|
|
3338
|
+
flag: "--trial-days <n>",
|
|
3339
|
+
description: "Trial days",
|
|
3340
|
+
parse: parseNumber,
|
|
3341
|
+
sdkKey: "trialDays"
|
|
3342
|
+
},
|
|
3343
|
+
{
|
|
3344
|
+
flag: "--is-default <bool>",
|
|
3345
|
+
description: "Set as default price",
|
|
3346
|
+
parse: parseBool,
|
|
3347
|
+
sdkKey: "isDefault"
|
|
3348
|
+
},
|
|
3349
|
+
{
|
|
3350
|
+
flag: "--included-balance <n>",
|
|
3351
|
+
description: "Included balance",
|
|
3352
|
+
parse: parseNumber,
|
|
3353
|
+
sdkKey: "includedBalance"
|
|
3354
|
+
},
|
|
3355
|
+
{
|
|
3356
|
+
flag: "--included-credits <n>",
|
|
3357
|
+
description: "Included credits",
|
|
3358
|
+
parse: parseNumber,
|
|
3359
|
+
sdkKey: "includedCredits"
|
|
3360
|
+
},
|
|
3361
|
+
{
|
|
3362
|
+
flag: "--intro-offer-enabled <bool>",
|
|
3363
|
+
description: "Enable intro offer",
|
|
3364
|
+
parse: parseBool,
|
|
3365
|
+
sdkKey: "introOfferEnabled"
|
|
3366
|
+
},
|
|
3367
|
+
{
|
|
3368
|
+
flag: "--intro-offer-discount-type <type>",
|
|
3369
|
+
description: "Intro offer discount type: percentage or amount",
|
|
3370
|
+
sdkKey: "introOfferDiscountType"
|
|
3371
|
+
},
|
|
3372
|
+
{
|
|
3373
|
+
flag: "--intro-offer-discount-value <n>",
|
|
3374
|
+
description: "Intro offer discount value",
|
|
3375
|
+
parse: parseNumber,
|
|
3376
|
+
sdkKey: "introOfferDiscountValue"
|
|
3377
|
+
},
|
|
3378
|
+
{
|
|
3379
|
+
flag: "--intro-offer-duration-cycles <n>",
|
|
3380
|
+
description: "Intro offer duration in cycles",
|
|
3381
|
+
parse: parseNumber,
|
|
3382
|
+
sdkKey: "introOfferDurationCycles"
|
|
3383
|
+
}
|
|
3384
|
+
]
|
|
3385
|
+
},
|
|
3386
|
+
"update-price": {
|
|
3387
|
+
method: "updatePrice",
|
|
3388
|
+
description: "Update a plan price",
|
|
3389
|
+
params: [
|
|
3390
|
+
{
|
|
3391
|
+
flag: "--plan-id <id>",
|
|
3392
|
+
description: "Plan ID",
|
|
3393
|
+
required: true,
|
|
3394
|
+
sdkKey: "planId"
|
|
3395
|
+
},
|
|
3396
|
+
{
|
|
3397
|
+
flag: "--price-id <id>",
|
|
3398
|
+
description: "Price ID",
|
|
3399
|
+
required: true,
|
|
3400
|
+
sdkKey: "priceId"
|
|
3401
|
+
},
|
|
3402
|
+
{
|
|
3403
|
+
flag: "--price <n>",
|
|
3404
|
+
description: "Price in cents",
|
|
3405
|
+
parse: parseNumber,
|
|
3406
|
+
sdkKey: "price"
|
|
3407
|
+
},
|
|
3408
|
+
{
|
|
3409
|
+
flag: "--is-default <bool>",
|
|
3410
|
+
description: "Set as default price",
|
|
3411
|
+
parse: parseBool,
|
|
3412
|
+
sdkKey: "isDefault"
|
|
3413
|
+
},
|
|
3414
|
+
{
|
|
3415
|
+
flag: "--trial-days <n>",
|
|
3416
|
+
description: "Trial days",
|
|
3417
|
+
parse: parseNumber,
|
|
3418
|
+
sdkKey: "trialDays"
|
|
3419
|
+
},
|
|
3420
|
+
{
|
|
3421
|
+
flag: "--included-balance <n>",
|
|
3422
|
+
description: "Included balance",
|
|
3423
|
+
parse: parseNumber,
|
|
3424
|
+
sdkKey: "includedBalance"
|
|
3425
|
+
},
|
|
3426
|
+
{
|
|
3427
|
+
flag: "--included-credits <n>",
|
|
3428
|
+
description: "Included credits",
|
|
3429
|
+
parse: parseNumber,
|
|
3430
|
+
sdkKey: "includedCredits"
|
|
3431
|
+
},
|
|
3432
|
+
{
|
|
3433
|
+
flag: "--intro-offer-enabled <bool>",
|
|
3434
|
+
description: "Enable intro offer",
|
|
3435
|
+
parse: parseBool,
|
|
3436
|
+
sdkKey: "introOfferEnabled"
|
|
3437
|
+
},
|
|
3438
|
+
{
|
|
3439
|
+
flag: "--intro-offer-discount-type <type>",
|
|
3440
|
+
description: "Intro offer discount type: percentage or amount",
|
|
3441
|
+
sdkKey: "introOfferDiscountType"
|
|
3442
|
+
},
|
|
3443
|
+
{
|
|
3444
|
+
flag: "--intro-offer-discount-value <n>",
|
|
3445
|
+
description: "Intro offer discount value",
|
|
3446
|
+
parse: parseNumber,
|
|
3447
|
+
sdkKey: "introOfferDiscountValue"
|
|
3448
|
+
},
|
|
3449
|
+
{
|
|
3450
|
+
flag: "--intro-offer-duration-cycles <n>",
|
|
3451
|
+
description: "Intro offer duration in cycles",
|
|
3452
|
+
parse: parseNumber,
|
|
3453
|
+
sdkKey: "introOfferDurationCycles"
|
|
3454
|
+
}
|
|
3455
|
+
]
|
|
3456
|
+
},
|
|
3457
|
+
"delete-price": {
|
|
3458
|
+
method: "deletePrice",
|
|
3459
|
+
description: "Delete a plan price",
|
|
3460
|
+
params: [
|
|
3461
|
+
{
|
|
3462
|
+
flag: "--plan-id <id>",
|
|
3463
|
+
description: "Plan ID",
|
|
3464
|
+
required: true,
|
|
3465
|
+
sdkKey: "planId"
|
|
3466
|
+
},
|
|
3467
|
+
{
|
|
3468
|
+
flag: "--price-id <id>",
|
|
3469
|
+
description: "Price ID",
|
|
3470
|
+
required: true,
|
|
3471
|
+
sdkKey: "priceId"
|
|
3472
|
+
}
|
|
3473
|
+
]
|
|
3474
|
+
},
|
|
3475
|
+
"set-default-price": {
|
|
3476
|
+
method: "setDefaultPrice",
|
|
3477
|
+
description: "Set a price as the default for a plan",
|
|
3478
|
+
params: [
|
|
3479
|
+
{
|
|
3480
|
+
flag: "--plan-id <id>",
|
|
3481
|
+
description: "Plan ID",
|
|
3482
|
+
required: true,
|
|
3483
|
+
sdkKey: "planId"
|
|
3484
|
+
},
|
|
3485
|
+
{
|
|
3486
|
+
flag: "--price-id <id>",
|
|
3487
|
+
description: "Price ID",
|
|
3488
|
+
required: true,
|
|
3489
|
+
sdkKey: "priceId"
|
|
3490
|
+
}
|
|
3491
|
+
]
|
|
3492
|
+
},
|
|
3493
|
+
"set-regional-prices": {
|
|
3494
|
+
method: "setRegionalPrices",
|
|
3495
|
+
description: "Set regional price overrides",
|
|
3496
|
+
params: [
|
|
3497
|
+
{
|
|
3498
|
+
flag: "--plan-id <id>",
|
|
3499
|
+
description: "Plan ID",
|
|
3500
|
+
required: true,
|
|
3501
|
+
sdkKey: "planId"
|
|
3502
|
+
},
|
|
3503
|
+
{
|
|
3504
|
+
flag: "--price-id <id>",
|
|
3505
|
+
description: "Price ID",
|
|
3506
|
+
required: true,
|
|
3507
|
+
sdkKey: "priceId"
|
|
3508
|
+
},
|
|
3509
|
+
{
|
|
3510
|
+
flag: "--overrides <json>",
|
|
3511
|
+
description: 'Regional overrides (JSON: [{currency: "EUR", price: 900}])',
|
|
3512
|
+
required: true,
|
|
3513
|
+
parse: parseJson,
|
|
3514
|
+
sdkKey: "overrides"
|
|
3515
|
+
}
|
|
3516
|
+
]
|
|
3517
|
+
},
|
|
3518
|
+
"delete-regional-prices": {
|
|
3519
|
+
method: "deleteRegionalPrices",
|
|
3520
|
+
description: "Delete regional price overrides",
|
|
3521
|
+
params: [
|
|
3522
|
+
{
|
|
3523
|
+
flag: "--plan-id <id>",
|
|
3524
|
+
description: "Plan ID",
|
|
3525
|
+
required: true,
|
|
3526
|
+
sdkKey: "planId"
|
|
3527
|
+
},
|
|
3528
|
+
{
|
|
3529
|
+
flag: "--price-id <id>",
|
|
3530
|
+
description: "Price ID",
|
|
3531
|
+
required: true,
|
|
3532
|
+
sdkKey: "priceId"
|
|
3533
|
+
}
|
|
3534
|
+
]
|
|
3535
|
+
}
|
|
3536
|
+
}
|
|
3537
|
+
};
|
|
3538
|
+
var featuresResource = {
|
|
3539
|
+
name: "features",
|
|
3540
|
+
description: "Manage features and check feature access",
|
|
3541
|
+
sdkProperty: "features",
|
|
3542
|
+
actions: {
|
|
3543
|
+
get: {
|
|
3544
|
+
method: "get",
|
|
3545
|
+
description: "Get feature access for a customer",
|
|
3546
|
+
params: [
|
|
3547
|
+
{
|
|
3548
|
+
flag: "--customer-id <id>",
|
|
3549
|
+
description: "Customer ID",
|
|
3550
|
+
required: true,
|
|
3551
|
+
sdkKey: "customerId"
|
|
3552
|
+
},
|
|
3553
|
+
{
|
|
3554
|
+
flag: "--code <code>",
|
|
3555
|
+
description: "Feature code",
|
|
3556
|
+
required: true,
|
|
3557
|
+
sdkKey: "code"
|
|
3558
|
+
}
|
|
3559
|
+
]
|
|
3560
|
+
},
|
|
3561
|
+
"can-use": {
|
|
3562
|
+
method: "canUse",
|
|
3563
|
+
description: "Check if a customer can use a feature",
|
|
3564
|
+
params: [
|
|
3565
|
+
{
|
|
3566
|
+
flag: "--customer-id <id>",
|
|
3567
|
+
description: "Customer ID",
|
|
3568
|
+
required: true,
|
|
3569
|
+
sdkKey: "customerId"
|
|
3570
|
+
},
|
|
3571
|
+
{
|
|
3572
|
+
flag: "--code <code>",
|
|
3573
|
+
description: "Feature code",
|
|
3574
|
+
required: true,
|
|
3575
|
+
sdkKey: "code"
|
|
3576
|
+
}
|
|
3577
|
+
]
|
|
3578
|
+
},
|
|
3579
|
+
list: {
|
|
3580
|
+
method: "list",
|
|
3581
|
+
description: "List features for a customer",
|
|
3582
|
+
params: [
|
|
3583
|
+
{
|
|
3584
|
+
flag: "--customer-id <id>",
|
|
3585
|
+
description: "Customer ID",
|
|
3586
|
+
required: true,
|
|
3587
|
+
sdkKey: "customerId"
|
|
3588
|
+
}
|
|
3589
|
+
]
|
|
3590
|
+
},
|
|
3591
|
+
create: {
|
|
3592
|
+
method: "create",
|
|
3593
|
+
description: "Create a feature",
|
|
3594
|
+
params: [
|
|
3595
|
+
{
|
|
3596
|
+
flag: "--code <code>",
|
|
3597
|
+
description: "Feature code",
|
|
3598
|
+
required: true,
|
|
3599
|
+
sdkKey: "code"
|
|
3600
|
+
},
|
|
3601
|
+
{
|
|
3602
|
+
flag: "--name <name>",
|
|
3603
|
+
description: "Feature name",
|
|
3604
|
+
required: true,
|
|
3605
|
+
sdkKey: "name"
|
|
3606
|
+
},
|
|
3607
|
+
{
|
|
3608
|
+
flag: "--type <type>",
|
|
3609
|
+
description: "Feature type: boolean, usage, or seats",
|
|
3610
|
+
required: true,
|
|
3611
|
+
sdkKey: "type"
|
|
3612
|
+
},
|
|
3613
|
+
{
|
|
3614
|
+
flag: "--description <desc>",
|
|
3615
|
+
description: "Feature description",
|
|
3616
|
+
sdkKey: "description"
|
|
3617
|
+
},
|
|
3618
|
+
{
|
|
3619
|
+
flag: "--unit-name <name>",
|
|
3620
|
+
description: "Unit name for metered features",
|
|
3621
|
+
sdkKey: "unitName"
|
|
3622
|
+
}
|
|
3623
|
+
]
|
|
3624
|
+
},
|
|
3625
|
+
update: {
|
|
3626
|
+
method: "update",
|
|
3627
|
+
description: "Update a feature",
|
|
3628
|
+
params: [
|
|
3629
|
+
{
|
|
3630
|
+
flag: "--code <code>",
|
|
3631
|
+
description: "Feature code",
|
|
3632
|
+
required: true,
|
|
3633
|
+
sdkKey: "code"
|
|
3634
|
+
},
|
|
3635
|
+
{
|
|
3636
|
+
flag: "--name <name>",
|
|
3637
|
+
description: "Feature name",
|
|
3638
|
+
sdkKey: "name"
|
|
3639
|
+
},
|
|
3640
|
+
{
|
|
3641
|
+
flag: "--description <desc>",
|
|
3642
|
+
description: "Feature description",
|
|
3643
|
+
sdkKey: "description"
|
|
3644
|
+
},
|
|
3645
|
+
{
|
|
3646
|
+
flag: "--unit-name <name>",
|
|
3647
|
+
description: "Unit name",
|
|
3648
|
+
sdkKey: "unitName"
|
|
3649
|
+
}
|
|
3650
|
+
]
|
|
3651
|
+
},
|
|
3652
|
+
delete: {
|
|
3653
|
+
method: "delete",
|
|
3654
|
+
description: "Delete a feature",
|
|
3655
|
+
params: [
|
|
3656
|
+
{
|
|
3657
|
+
flag: "--code <code>",
|
|
3658
|
+
description: "Feature code",
|
|
3659
|
+
required: true,
|
|
3660
|
+
sdkKey: "code"
|
|
3661
|
+
}
|
|
3662
|
+
]
|
|
3663
|
+
}
|
|
3664
|
+
}
|
|
3665
|
+
};
|
|
3666
|
+
var seatsResource = {
|
|
3667
|
+
name: "seats",
|
|
3668
|
+
description: "Manage seat allocations",
|
|
3669
|
+
sdkProperty: "seats",
|
|
3670
|
+
actions: {
|
|
3671
|
+
add: {
|
|
3672
|
+
method: "add",
|
|
3673
|
+
description: "Add seats for a customer",
|
|
3674
|
+
params: [
|
|
3675
|
+
{
|
|
3676
|
+
flag: "--customer-id <id>",
|
|
3677
|
+
description: "Customer ID",
|
|
3678
|
+
required: true,
|
|
3679
|
+
sdkKey: "customerId"
|
|
3680
|
+
},
|
|
3681
|
+
{
|
|
3682
|
+
flag: "--feature-code <code>",
|
|
3683
|
+
description: "Feature code",
|
|
3684
|
+
required: true,
|
|
3685
|
+
sdkKey: "featureCode"
|
|
3686
|
+
},
|
|
3687
|
+
{
|
|
3688
|
+
flag: "--count <n>",
|
|
3689
|
+
description: "Number of seats to add (defaults to 1)",
|
|
3690
|
+
parse: parseNumber,
|
|
3691
|
+
sdkKey: "count"
|
|
3692
|
+
}
|
|
3693
|
+
]
|
|
3694
|
+
},
|
|
3695
|
+
remove: {
|
|
3696
|
+
method: "remove",
|
|
3697
|
+
description: "Remove seats for a customer",
|
|
3698
|
+
params: [
|
|
3699
|
+
{
|
|
3700
|
+
flag: "--customer-id <id>",
|
|
3701
|
+
description: "Customer ID",
|
|
3702
|
+
required: true,
|
|
3703
|
+
sdkKey: "customerId"
|
|
3704
|
+
},
|
|
3705
|
+
{
|
|
3706
|
+
flag: "--feature-code <code>",
|
|
3707
|
+
description: "Feature code",
|
|
3708
|
+
required: true,
|
|
3709
|
+
sdkKey: "featureCode"
|
|
3710
|
+
},
|
|
3711
|
+
{
|
|
3712
|
+
flag: "--count <n>",
|
|
3713
|
+
description: "Number of seats to remove (defaults to 1)",
|
|
3714
|
+
parse: parseNumber,
|
|
3715
|
+
sdkKey: "count"
|
|
3716
|
+
}
|
|
3717
|
+
]
|
|
3718
|
+
},
|
|
3719
|
+
set: {
|
|
3720
|
+
method: "set",
|
|
3721
|
+
description: "Set exact seat count for a customer",
|
|
3722
|
+
params: [
|
|
3723
|
+
{
|
|
3724
|
+
flag: "--customer-id <id>",
|
|
3725
|
+
description: "Customer ID",
|
|
3726
|
+
required: true,
|
|
3727
|
+
sdkKey: "customerId"
|
|
3728
|
+
},
|
|
3729
|
+
{
|
|
3730
|
+
flag: "--feature-code <code>",
|
|
3731
|
+
description: "Feature code",
|
|
3732
|
+
required: true,
|
|
3733
|
+
sdkKey: "featureCode"
|
|
3734
|
+
},
|
|
3735
|
+
{
|
|
3736
|
+
flag: "--count <n>",
|
|
3737
|
+
description: "Exact seat count",
|
|
3738
|
+
required: true,
|
|
3739
|
+
parse: parseNumber,
|
|
3740
|
+
sdkKey: "count"
|
|
3741
|
+
}
|
|
3742
|
+
]
|
|
3743
|
+
},
|
|
3744
|
+
"set-all": {
|
|
3745
|
+
method: "setAll",
|
|
3746
|
+
description: "Set all seat counts for a customer at once",
|
|
3747
|
+
params: [
|
|
3748
|
+
{
|
|
3749
|
+
flag: "--customer-id <id>",
|
|
3750
|
+
description: "Customer ID",
|
|
3751
|
+
required: true,
|
|
3752
|
+
sdkKey: "customerId"
|
|
3753
|
+
},
|
|
3754
|
+
{
|
|
3755
|
+
flag: "--seats <json>",
|
|
3756
|
+
description: "Seats map (JSON: {featureCode: count})",
|
|
3757
|
+
required: true,
|
|
3758
|
+
parse: parseJson,
|
|
3759
|
+
sdkKey: "seats"
|
|
3760
|
+
}
|
|
3761
|
+
]
|
|
3762
|
+
},
|
|
3763
|
+
"get-balance": {
|
|
3764
|
+
method: "getBalance",
|
|
3765
|
+
description: "Get seat balance for a specific feature",
|
|
3766
|
+
params: [
|
|
3767
|
+
{
|
|
3768
|
+
flag: "--customer-id <id>",
|
|
3769
|
+
description: "Customer ID",
|
|
3770
|
+
required: true,
|
|
3771
|
+
sdkKey: "customerId"
|
|
3772
|
+
},
|
|
3773
|
+
{
|
|
3774
|
+
flag: "--feature-code <code>",
|
|
3775
|
+
description: "Feature code",
|
|
3776
|
+
required: true,
|
|
3777
|
+
sdkKey: "featureCode"
|
|
3778
|
+
}
|
|
3779
|
+
]
|
|
3780
|
+
},
|
|
3781
|
+
"get-all-balances": {
|
|
3782
|
+
method: "getAllBalances",
|
|
3783
|
+
description: "Get all seat balances for a customer",
|
|
3784
|
+
params: [
|
|
3785
|
+
{
|
|
3786
|
+
flag: "--customer-id <id>",
|
|
3787
|
+
description: "Customer ID",
|
|
3788
|
+
required: true,
|
|
3789
|
+
sdkKey: "customerId"
|
|
3790
|
+
}
|
|
3791
|
+
]
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
};
|
|
3795
|
+
var usageResource = {
|
|
3796
|
+
name: "usage",
|
|
3797
|
+
description: "Track usage events",
|
|
3798
|
+
sdkProperty: "usage",
|
|
3799
|
+
actions: {
|
|
3800
|
+
track: {
|
|
3801
|
+
method: "track",
|
|
3802
|
+
description: "Track a usage event",
|
|
3803
|
+
params: [
|
|
3804
|
+
{
|
|
3805
|
+
flag: "--feature <code>",
|
|
3806
|
+
description: "Feature code",
|
|
3807
|
+
required: true,
|
|
3808
|
+
sdkKey: "feature"
|
|
3809
|
+
},
|
|
3810
|
+
{
|
|
3811
|
+
flag: "--customer-id <id>",
|
|
3812
|
+
description: "Customer ID",
|
|
3813
|
+
required: true,
|
|
3814
|
+
sdkKey: "customerId"
|
|
3815
|
+
},
|
|
3816
|
+
{
|
|
3817
|
+
flag: "--value <n>",
|
|
3818
|
+
description: "Usage value (standard tracking)",
|
|
3819
|
+
parse: parseNumber,
|
|
3820
|
+
sdkKey: "value"
|
|
3821
|
+
},
|
|
3822
|
+
{
|
|
3823
|
+
flag: "--model <model>",
|
|
3824
|
+
description: "AI model name (model token tracking)",
|
|
3825
|
+
sdkKey: "model"
|
|
3826
|
+
},
|
|
3827
|
+
{
|
|
3828
|
+
flag: "--input-tokens <n>",
|
|
3829
|
+
description: "Input tokens (model tracking)",
|
|
3830
|
+
parse: parseNumber,
|
|
3831
|
+
sdkKey: "inputTokens"
|
|
3832
|
+
},
|
|
3833
|
+
{
|
|
3834
|
+
flag: "--output-tokens <n>",
|
|
3835
|
+
description: "Output tokens (model tracking)",
|
|
3836
|
+
parse: parseNumber,
|
|
3837
|
+
sdkKey: "outputTokens"
|
|
3838
|
+
},
|
|
3839
|
+
{
|
|
3840
|
+
flag: "--cache-read-tokens <n>",
|
|
3841
|
+
description: "Cache read tokens (model tracking)",
|
|
3842
|
+
parse: parseNumber,
|
|
3843
|
+
sdkKey: "cacheReadTokens"
|
|
3844
|
+
},
|
|
3845
|
+
{
|
|
3846
|
+
flag: "--cache-write-tokens <n>",
|
|
3847
|
+
description: "Cache write tokens (model tracking)",
|
|
3848
|
+
parse: parseNumber,
|
|
3849
|
+
sdkKey: "cacheWriteTokens"
|
|
3850
|
+
},
|
|
3851
|
+
{
|
|
3852
|
+
flag: "--idempotency-key <key>",
|
|
3853
|
+
description: "Idempotency key for deduplication",
|
|
3854
|
+
sdkKey: "idempotencyKey"
|
|
3855
|
+
},
|
|
3856
|
+
{
|
|
3857
|
+
flag: "--timestamp <ts>",
|
|
3858
|
+
description: "Event timestamp (ISO 8601)",
|
|
3859
|
+
sdkKey: "timestamp"
|
|
3860
|
+
},
|
|
3861
|
+
{
|
|
3862
|
+
flag: "--properties <json>",
|
|
3863
|
+
description: "Event properties (JSON: {key: value})",
|
|
3864
|
+
parse: parseJson,
|
|
3865
|
+
sdkKey: "properties"
|
|
3866
|
+
}
|
|
3867
|
+
],
|
|
3868
|
+
buildParams: (options) => {
|
|
3869
|
+
const params = {
|
|
3870
|
+
feature: options.feature,
|
|
3871
|
+
customerId: options.customerId
|
|
3872
|
+
};
|
|
3873
|
+
if (options.idempotencyKey)
|
|
3874
|
+
params.idempotencyKey = options.idempotencyKey;
|
|
3875
|
+
if (options.timestamp) params.timestamp = options.timestamp;
|
|
3876
|
+
if (options.properties)
|
|
3877
|
+
params.properties = parseJson(options.properties);
|
|
3878
|
+
if (options.model) {
|
|
3879
|
+
params.model = options.model;
|
|
3880
|
+
params.inputTokens = parseNumber(options.inputTokens);
|
|
3881
|
+
params.outputTokens = parseNumber(options.outputTokens);
|
|
3882
|
+
if (options.cacheReadTokens)
|
|
3883
|
+
params.cacheReadTokens = parseNumber(options.cacheReadTokens);
|
|
3884
|
+
if (options.cacheWriteTokens)
|
|
3885
|
+
params.cacheWriteTokens = parseNumber(options.cacheWriteTokens);
|
|
3886
|
+
} else {
|
|
3887
|
+
if (options.value) params.value = parseNumber(options.value);
|
|
3888
|
+
}
|
|
3889
|
+
return params;
|
|
3890
|
+
}
|
|
3891
|
+
},
|
|
3892
|
+
check: {
|
|
3893
|
+
method: "check",
|
|
3894
|
+
description: "Check if a usage event would be allowed",
|
|
3895
|
+
params: [
|
|
3896
|
+
{
|
|
3897
|
+
flag: "--customer-id <id>",
|
|
3898
|
+
description: "Customer ID",
|
|
3899
|
+
required: true,
|
|
3900
|
+
sdkKey: "customerId"
|
|
3901
|
+
},
|
|
3902
|
+
{
|
|
3903
|
+
flag: "--feature-code <code>",
|
|
3904
|
+
description: "Feature code",
|
|
3905
|
+
required: true,
|
|
3906
|
+
sdkKey: "featureCode"
|
|
3907
|
+
},
|
|
3908
|
+
{
|
|
3909
|
+
flag: "--quantity <n>",
|
|
3910
|
+
description: "Quantity to check",
|
|
3911
|
+
required: true,
|
|
3912
|
+
parse: parseNumber,
|
|
3913
|
+
sdkKey: "quantity"
|
|
3914
|
+
}
|
|
3915
|
+
]
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
};
|
|
3919
|
+
var portalResource = {
|
|
3920
|
+
name: "portal",
|
|
3921
|
+
description: "Customer portal access",
|
|
3922
|
+
sdkProperty: "portal",
|
|
3923
|
+
actions: {
|
|
3924
|
+
"get-url": {
|
|
3925
|
+
method: "getUrl",
|
|
3926
|
+
description: "Get a portal URL for a customer",
|
|
3927
|
+
params: [
|
|
3928
|
+
{
|
|
3929
|
+
flag: "--customer-id <id>",
|
|
3930
|
+
description: "Customer ID (provide this or --email)",
|
|
3931
|
+
sdkKey: "customerId"
|
|
3932
|
+
},
|
|
3933
|
+
{
|
|
3934
|
+
flag: "--email <email>",
|
|
3935
|
+
description: "Customer email (provide this or --customer-id)",
|
|
3936
|
+
sdkKey: "email"
|
|
3937
|
+
}
|
|
3938
|
+
],
|
|
3939
|
+
buildParams: (options) => {
|
|
3940
|
+
if (options.customerId) {
|
|
3941
|
+
return { customerId: options.customerId };
|
|
3942
|
+
}
|
|
3943
|
+
if (options.email) {
|
|
3944
|
+
return { email: options.email };
|
|
3945
|
+
}
|
|
3946
|
+
throw new Error("Either --customer-id or --email is required");
|
|
3947
|
+
}
|
|
3948
|
+
}
|
|
3949
|
+
}
|
|
3950
|
+
};
|
|
3951
|
+
var addonsResource = {
|
|
3952
|
+
name: "addons",
|
|
3953
|
+
description: "Manage addons",
|
|
3954
|
+
sdkProperty: "addons",
|
|
3955
|
+
actions: {
|
|
3956
|
+
"list-active": {
|
|
3957
|
+
method: "listActive",
|
|
3958
|
+
description: "List active addons for a customer",
|
|
3959
|
+
params: [
|
|
3960
|
+
{
|
|
3961
|
+
flag: "--customer-id <id>",
|
|
3962
|
+
description: "Customer ID",
|
|
3963
|
+
required: true,
|
|
3964
|
+
sdkKey: "customerId"
|
|
3965
|
+
}
|
|
3966
|
+
]
|
|
3967
|
+
},
|
|
3968
|
+
list: {
|
|
3969
|
+
method: "list",
|
|
3970
|
+
description: "List all addons",
|
|
3971
|
+
params: [
|
|
3972
|
+
{
|
|
3973
|
+
flag: "--limit <n>",
|
|
3974
|
+
description: "Max results",
|
|
3975
|
+
parse: parseNumber,
|
|
3976
|
+
sdkKey: "limit"
|
|
3977
|
+
},
|
|
3978
|
+
{
|
|
3979
|
+
flag: "--cursor <cursor>",
|
|
3980
|
+
description: "Pagination cursor",
|
|
3981
|
+
sdkKey: "cursor"
|
|
3982
|
+
}
|
|
3983
|
+
]
|
|
3984
|
+
},
|
|
3985
|
+
get: {
|
|
3986
|
+
method: "get",
|
|
3987
|
+
description: "Get addon details",
|
|
3988
|
+
params: [
|
|
3989
|
+
{
|
|
3990
|
+
flag: "--id <id>",
|
|
3991
|
+
description: "Addon ID",
|
|
3992
|
+
required: true,
|
|
3993
|
+
sdkKey: "id"
|
|
3994
|
+
}
|
|
3995
|
+
]
|
|
3996
|
+
},
|
|
3997
|
+
create: {
|
|
3998
|
+
method: "create",
|
|
3999
|
+
description: "Create an addon",
|
|
4000
|
+
params: [
|
|
4001
|
+
{
|
|
4002
|
+
flag: "--name <name>",
|
|
4003
|
+
description: "Addon name",
|
|
4004
|
+
required: true,
|
|
4005
|
+
sdkKey: "name"
|
|
4006
|
+
},
|
|
4007
|
+
{
|
|
4008
|
+
flag: "--base-price <n>",
|
|
4009
|
+
description: "Base price in cents",
|
|
4010
|
+
required: true,
|
|
4011
|
+
parse: parseNumber,
|
|
4012
|
+
sdkKey: "basePrice"
|
|
4013
|
+
},
|
|
4014
|
+
{
|
|
4015
|
+
flag: "--feature-id <id>",
|
|
4016
|
+
description: "Feature ID",
|
|
4017
|
+
required: true,
|
|
4018
|
+
sdkKey: "featureId"
|
|
4019
|
+
},
|
|
4020
|
+
{
|
|
4021
|
+
flag: "--consumption-model <model>",
|
|
4022
|
+
description: "Consumption model: boolean, metered, credits, or balance",
|
|
4023
|
+
required: true,
|
|
4024
|
+
sdkKey: "consumptionModel"
|
|
4025
|
+
},
|
|
4026
|
+
{
|
|
4027
|
+
flag: "--description <desc>",
|
|
4028
|
+
description: "Addon description",
|
|
4029
|
+
sdkKey: "description"
|
|
4030
|
+
},
|
|
4031
|
+
{
|
|
4032
|
+
flag: "--included-units <n>",
|
|
4033
|
+
description: "Included units (metered)",
|
|
4034
|
+
parse: parseNumber,
|
|
4035
|
+
sdkKey: "includedUnits"
|
|
4036
|
+
},
|
|
4037
|
+
{
|
|
4038
|
+
flag: "--overage-rate <n>",
|
|
4039
|
+
description: "Overage rate (metered/balance)",
|
|
4040
|
+
parse: parseNumber,
|
|
4041
|
+
sdkKey: "overageRate"
|
|
4042
|
+
},
|
|
4043
|
+
{
|
|
4044
|
+
flag: "--credit-cost <n>",
|
|
4045
|
+
description: "Credit cost (credits)",
|
|
4046
|
+
parse: parseNumber,
|
|
4047
|
+
sdkKey: "creditCost"
|
|
4048
|
+
}
|
|
4049
|
+
]
|
|
4050
|
+
},
|
|
4051
|
+
update: {
|
|
4052
|
+
method: "update",
|
|
4053
|
+
description: "Update an addon",
|
|
4054
|
+
params: [
|
|
4055
|
+
{
|
|
4056
|
+
flag: "--id <id>",
|
|
4057
|
+
description: "Addon ID",
|
|
4058
|
+
required: true,
|
|
4059
|
+
sdkKey: "id"
|
|
4060
|
+
},
|
|
4061
|
+
{
|
|
4062
|
+
flag: "--name <name>",
|
|
4063
|
+
description: "Addon name",
|
|
4064
|
+
sdkKey: "name"
|
|
4065
|
+
},
|
|
4066
|
+
{
|
|
4067
|
+
flag: "--description <desc>",
|
|
4068
|
+
description: "Addon description",
|
|
4069
|
+
sdkKey: "description"
|
|
4070
|
+
},
|
|
4071
|
+
{
|
|
4072
|
+
flag: "--base-price <n>",
|
|
4073
|
+
description: "Base price in cents",
|
|
4074
|
+
parse: parseNumber,
|
|
4075
|
+
sdkKey: "basePrice"
|
|
4076
|
+
},
|
|
4077
|
+
{
|
|
4078
|
+
flag: "--included-units <n>",
|
|
4079
|
+
description: "Included units",
|
|
4080
|
+
parse: parseNumber,
|
|
4081
|
+
sdkKey: "includedUnits"
|
|
4082
|
+
},
|
|
4083
|
+
{
|
|
4084
|
+
flag: "--overage-rate <n>",
|
|
4085
|
+
description: "Overage rate",
|
|
4086
|
+
parse: parseNumber,
|
|
4087
|
+
sdkKey: "overageRate"
|
|
4088
|
+
}
|
|
4089
|
+
]
|
|
4090
|
+
},
|
|
4091
|
+
delete: {
|
|
4092
|
+
method: "delete",
|
|
4093
|
+
description: "Delete an addon",
|
|
4094
|
+
params: [
|
|
4095
|
+
{
|
|
4096
|
+
flag: "--id <id>",
|
|
4097
|
+
description: "Addon ID",
|
|
4098
|
+
required: true,
|
|
4099
|
+
sdkKey: "id"
|
|
4100
|
+
}
|
|
4101
|
+
]
|
|
4102
|
+
}
|
|
4103
|
+
}
|
|
4104
|
+
};
|
|
4105
|
+
var creditPacksResource = {
|
|
4106
|
+
name: "credit-packs",
|
|
4107
|
+
description: "Manage credit packs",
|
|
4108
|
+
sdkProperty: "creditPacks",
|
|
4109
|
+
actions: {
|
|
4110
|
+
list: {
|
|
4111
|
+
method: "list",
|
|
4112
|
+
description: "List credit packs",
|
|
4113
|
+
params: []
|
|
4114
|
+
},
|
|
4115
|
+
create: {
|
|
4116
|
+
method: "create",
|
|
4117
|
+
description: "Create a credit pack",
|
|
4118
|
+
params: [
|
|
4119
|
+
{
|
|
4120
|
+
flag: "--name <name>",
|
|
4121
|
+
description: "Credit pack name",
|
|
4122
|
+
required: true,
|
|
4123
|
+
sdkKey: "name"
|
|
4124
|
+
},
|
|
4125
|
+
{
|
|
4126
|
+
flag: "--credits <n>",
|
|
4127
|
+
description: "Number of credits",
|
|
4128
|
+
required: true,
|
|
4129
|
+
parse: parseNumber,
|
|
4130
|
+
sdkKey: "credits"
|
|
4131
|
+
},
|
|
4132
|
+
{
|
|
4133
|
+
flag: "--price <n>",
|
|
4134
|
+
description: "Price in cents",
|
|
4135
|
+
required: true,
|
|
4136
|
+
parse: parseNumber,
|
|
4137
|
+
sdkKey: "price"
|
|
4138
|
+
},
|
|
4139
|
+
{
|
|
4140
|
+
flag: "--description <desc>",
|
|
4141
|
+
description: "Credit pack description",
|
|
4142
|
+
sdkKey: "description"
|
|
4143
|
+
},
|
|
4144
|
+
{
|
|
4145
|
+
flag: "--is-active <bool>",
|
|
4146
|
+
description: "Whether credit pack is active",
|
|
4147
|
+
parse: parseBool,
|
|
4148
|
+
sdkKey: "isActive"
|
|
4149
|
+
}
|
|
4150
|
+
]
|
|
4151
|
+
},
|
|
4152
|
+
update: {
|
|
4153
|
+
method: "update",
|
|
4154
|
+
description: "Update a credit pack",
|
|
4155
|
+
params: [
|
|
4156
|
+
{
|
|
4157
|
+
flag: "--id <id>",
|
|
4158
|
+
description: "Credit pack ID",
|
|
4159
|
+
required: true,
|
|
4160
|
+
sdkKey: "id"
|
|
4161
|
+
},
|
|
4162
|
+
{
|
|
4163
|
+
flag: "--name <name>",
|
|
4164
|
+
description: "Credit pack name",
|
|
4165
|
+
sdkKey: "name"
|
|
4166
|
+
},
|
|
4167
|
+
{
|
|
4168
|
+
flag: "--description <desc>",
|
|
4169
|
+
description: "Credit pack description",
|
|
4170
|
+
sdkKey: "description"
|
|
4171
|
+
},
|
|
4172
|
+
{
|
|
4173
|
+
flag: "--credits <n>",
|
|
4174
|
+
description: "Number of credits",
|
|
4175
|
+
parse: parseNumber,
|
|
4176
|
+
sdkKey: "credits"
|
|
4177
|
+
},
|
|
4178
|
+
{
|
|
4179
|
+
flag: "--price <n>",
|
|
4180
|
+
description: "Price in cents",
|
|
4181
|
+
parse: parseNumber,
|
|
4182
|
+
sdkKey: "price"
|
|
4183
|
+
},
|
|
4184
|
+
{
|
|
4185
|
+
flag: "--is-active <bool>",
|
|
4186
|
+
description: "Whether credit pack is active",
|
|
4187
|
+
parse: parseBool,
|
|
4188
|
+
sdkKey: "isActive"
|
|
4189
|
+
}
|
|
4190
|
+
]
|
|
4191
|
+
},
|
|
4192
|
+
delete: {
|
|
4193
|
+
method: "delete",
|
|
4194
|
+
description: "Delete a credit pack",
|
|
4195
|
+
params: [
|
|
4196
|
+
{
|
|
4197
|
+
flag: "--id <id>",
|
|
4198
|
+
description: "Credit pack ID",
|
|
4199
|
+
required: true,
|
|
4200
|
+
sdkKey: "id"
|
|
4201
|
+
}
|
|
4202
|
+
]
|
|
4203
|
+
}
|
|
4204
|
+
}
|
|
4205
|
+
};
|
|
4206
|
+
var webhooksResource = {
|
|
4207
|
+
name: "webhooks",
|
|
4208
|
+
description: "Manage webhook endpoints",
|
|
4209
|
+
sdkProperty: "webhooks",
|
|
4210
|
+
actions: {
|
|
4211
|
+
list: {
|
|
4212
|
+
method: "list",
|
|
4213
|
+
description: "List webhook endpoints",
|
|
4214
|
+
params: [
|
|
4215
|
+
{
|
|
4216
|
+
flag: "--limit <n>",
|
|
4217
|
+
description: "Max results",
|
|
4218
|
+
parse: parseNumber,
|
|
4219
|
+
sdkKey: "limit"
|
|
4220
|
+
},
|
|
4221
|
+
{
|
|
4222
|
+
flag: "--cursor <cursor>",
|
|
4223
|
+
description: "Pagination cursor",
|
|
4224
|
+
sdkKey: "cursor"
|
|
4225
|
+
}
|
|
4226
|
+
]
|
|
4227
|
+
},
|
|
4228
|
+
create: {
|
|
4229
|
+
method: "create",
|
|
4230
|
+
description: "Create a webhook endpoint",
|
|
4231
|
+
params: [
|
|
4232
|
+
{
|
|
4233
|
+
flag: "--url <url>",
|
|
4234
|
+
description: "Webhook URL",
|
|
4235
|
+
required: true,
|
|
4236
|
+
sdkKey: "url"
|
|
4237
|
+
},
|
|
4238
|
+
{
|
|
4239
|
+
flag: "--events <json>",
|
|
4240
|
+
description: 'Events to subscribe to (JSON array: ["subscription.created"])',
|
|
4241
|
+
required: true,
|
|
4242
|
+
parse: parseJson,
|
|
4243
|
+
sdkKey: "events"
|
|
4244
|
+
},
|
|
4245
|
+
{
|
|
4246
|
+
flag: "--description <desc>",
|
|
4247
|
+
description: "Webhook description",
|
|
4248
|
+
sdkKey: "description"
|
|
4249
|
+
}
|
|
4250
|
+
]
|
|
4251
|
+
},
|
|
4252
|
+
delete: {
|
|
4253
|
+
method: "delete",
|
|
4254
|
+
description: "Delete a webhook endpoint",
|
|
4255
|
+
params: [
|
|
4256
|
+
{
|
|
4257
|
+
flag: "--id <id>",
|
|
4258
|
+
description: "Webhook endpoint ID",
|
|
4259
|
+
required: true,
|
|
4260
|
+
sdkKey: "id"
|
|
4261
|
+
}
|
|
4262
|
+
]
|
|
4263
|
+
},
|
|
4264
|
+
test: {
|
|
4265
|
+
method: "test",
|
|
4266
|
+
description: "Send a test event to a webhook endpoint",
|
|
4267
|
+
params: [
|
|
4268
|
+
{
|
|
4269
|
+
flag: "--id <id>",
|
|
4270
|
+
description: "Webhook endpoint ID",
|
|
4271
|
+
required: true,
|
|
4272
|
+
sdkKey: "id"
|
|
4273
|
+
}
|
|
4274
|
+
]
|
|
4275
|
+
}
|
|
4276
|
+
}
|
|
4277
|
+
};
|
|
4278
|
+
var apiKeysResource = {
|
|
4279
|
+
name: "api-keys",
|
|
4280
|
+
description: "Manage API keys",
|
|
4281
|
+
sdkProperty: "apiKeys",
|
|
4282
|
+
actions: {
|
|
4283
|
+
list: {
|
|
4284
|
+
method: "list",
|
|
4285
|
+
description: "List API keys",
|
|
4286
|
+
params: [
|
|
4287
|
+
{
|
|
4288
|
+
flag: "--limit <n>",
|
|
4289
|
+
description: "Max results",
|
|
4290
|
+
parse: parseNumber,
|
|
4291
|
+
sdkKey: "limit"
|
|
4292
|
+
},
|
|
4293
|
+
{
|
|
4294
|
+
flag: "--cursor <cursor>",
|
|
4295
|
+
description: "Pagination cursor",
|
|
4296
|
+
sdkKey: "cursor"
|
|
4297
|
+
}
|
|
4298
|
+
]
|
|
4299
|
+
},
|
|
4300
|
+
create: {
|
|
4301
|
+
method: "create",
|
|
4302
|
+
description: "Create an API key",
|
|
4303
|
+
params: [
|
|
4304
|
+
{
|
|
4305
|
+
flag: "--name <name>",
|
|
4306
|
+
description: "API key name",
|
|
4307
|
+
required: true,
|
|
4308
|
+
sdkKey: "name"
|
|
4309
|
+
},
|
|
4310
|
+
{
|
|
4311
|
+
flag: "--expires-in-days <n>",
|
|
4312
|
+
description: "Expiration in days",
|
|
4313
|
+
parse: parseNumber,
|
|
4314
|
+
sdkKey: "expiresInDays"
|
|
4315
|
+
}
|
|
4316
|
+
]
|
|
4317
|
+
},
|
|
4318
|
+
delete: {
|
|
4319
|
+
method: "delete",
|
|
4320
|
+
description: "Delete an API key",
|
|
4321
|
+
params: [
|
|
4322
|
+
{
|
|
4323
|
+
flag: "--id <id>",
|
|
4324
|
+
description: "API key ID",
|
|
4325
|
+
required: true,
|
|
4326
|
+
sdkKey: "id"
|
|
4327
|
+
}
|
|
4328
|
+
]
|
|
4329
|
+
}
|
|
4330
|
+
}
|
|
4331
|
+
};
|
|
4332
|
+
var invoicesResource = {
|
|
4333
|
+
name: "invoices",
|
|
4334
|
+
description: "Manage invoices",
|
|
4335
|
+
sdkProperty: "invoices",
|
|
4336
|
+
actions: {
|
|
4337
|
+
list: {
|
|
4338
|
+
method: "list",
|
|
4339
|
+
description: "List invoices",
|
|
4340
|
+
params: [
|
|
4341
|
+
{
|
|
4342
|
+
flag: "--customer-id <id>",
|
|
4343
|
+
description: "Filter by customer ID",
|
|
4344
|
+
sdkKey: "customerId"
|
|
4345
|
+
},
|
|
4346
|
+
{
|
|
4347
|
+
flag: "--status <status>",
|
|
4348
|
+
description: "Filter by status",
|
|
4349
|
+
sdkKey: "status"
|
|
4350
|
+
},
|
|
4351
|
+
{
|
|
4352
|
+
flag: "--subscription-id <id>",
|
|
4353
|
+
description: "Filter by subscription ID",
|
|
4354
|
+
sdkKey: "subscriptionId"
|
|
4355
|
+
},
|
|
4356
|
+
{
|
|
4357
|
+
flag: "--limit <n>",
|
|
4358
|
+
description: "Max results",
|
|
4359
|
+
parse: parseNumber,
|
|
4360
|
+
sdkKey: "limit"
|
|
4361
|
+
},
|
|
4362
|
+
{
|
|
4363
|
+
flag: "--cursor <cursor>",
|
|
4364
|
+
description: "Pagination cursor",
|
|
4365
|
+
sdkKey: "cursor"
|
|
4366
|
+
}
|
|
4367
|
+
]
|
|
4368
|
+
},
|
|
4369
|
+
get: {
|
|
4370
|
+
method: "get",
|
|
4371
|
+
description: "Get invoice details",
|
|
4372
|
+
params: [
|
|
4373
|
+
{
|
|
4374
|
+
flag: "--id <id>",
|
|
4375
|
+
description: "Invoice ID",
|
|
4376
|
+
required: true,
|
|
4377
|
+
sdkKey: "id"
|
|
4378
|
+
}
|
|
4379
|
+
]
|
|
4380
|
+
},
|
|
4381
|
+
"create-adjustment": {
|
|
4382
|
+
method: "createAdjustment",
|
|
4383
|
+
description: "Create an adjustment invoice (negative amount = credit)",
|
|
4384
|
+
params: [
|
|
4385
|
+
{
|
|
4386
|
+
flag: "--customer-id <id>",
|
|
4387
|
+
description: "Customer ID",
|
|
4388
|
+
required: true,
|
|
4389
|
+
sdkKey: "customerId"
|
|
4390
|
+
},
|
|
4391
|
+
{
|
|
4392
|
+
flag: "--amount <n>",
|
|
4393
|
+
description: "Amount in cents (negative for credit)",
|
|
4394
|
+
required: true,
|
|
4395
|
+
parse: parseNumber,
|
|
4396
|
+
sdkKey: "amount"
|
|
4397
|
+
},
|
|
4398
|
+
{
|
|
4399
|
+
flag: "--description <desc>",
|
|
4400
|
+
description: "Adjustment description",
|
|
4401
|
+
sdkKey: "description"
|
|
4402
|
+
},
|
|
4403
|
+
{
|
|
4404
|
+
flag: "--metadata <json>",
|
|
4405
|
+
description: "Metadata (JSON)",
|
|
4406
|
+
parse: parseJson,
|
|
4407
|
+
sdkKey: "metadata"
|
|
4408
|
+
}
|
|
4409
|
+
]
|
|
4410
|
+
},
|
|
4411
|
+
"get-download-url": {
|
|
4412
|
+
method: "getDownloadUrl",
|
|
4413
|
+
description: "Get a signed download URL for an invoice PDF",
|
|
4414
|
+
params: [
|
|
4415
|
+
{
|
|
4416
|
+
flag: "--id <id>",
|
|
4417
|
+
description: "Invoice ID",
|
|
4418
|
+
required: true,
|
|
4419
|
+
sdkKey: "id"
|
|
4420
|
+
}
|
|
4421
|
+
]
|
|
4422
|
+
},
|
|
4423
|
+
send: {
|
|
4424
|
+
method: "send",
|
|
4425
|
+
description: "Send an invoice by email",
|
|
4426
|
+
params: [
|
|
4427
|
+
{
|
|
4428
|
+
flag: "--id <id>",
|
|
4429
|
+
description: "Invoice ID",
|
|
4430
|
+
required: true,
|
|
4431
|
+
sdkKey: "id"
|
|
4432
|
+
}
|
|
4433
|
+
]
|
|
4434
|
+
},
|
|
4435
|
+
"update-status": {
|
|
4436
|
+
method: "updateStatus",
|
|
4437
|
+
description: "Update invoice status (outstanding invoices only)",
|
|
4438
|
+
params: [
|
|
4439
|
+
{
|
|
4440
|
+
flag: "--id <id>",
|
|
4441
|
+
description: "Invoice ID",
|
|
4442
|
+
required: true,
|
|
4443
|
+
sdkKey: "id"
|
|
4444
|
+
},
|
|
4445
|
+
{
|
|
4446
|
+
flag: "--status <status>",
|
|
4447
|
+
description: "New status (paid or void)",
|
|
4448
|
+
required: true,
|
|
4449
|
+
sdkKey: "status"
|
|
4450
|
+
}
|
|
4451
|
+
]
|
|
4452
|
+
}
|
|
4453
|
+
}
|
|
4454
|
+
};
|
|
4455
|
+
var transactionsResource = {
|
|
4456
|
+
name: "transactions",
|
|
4457
|
+
description: "Manage transactions",
|
|
4458
|
+
sdkProperty: "transactions",
|
|
4459
|
+
actions: {
|
|
4460
|
+
list: {
|
|
4461
|
+
method: "list",
|
|
4462
|
+
description: "List transactions",
|
|
4463
|
+
params: [
|
|
4464
|
+
{
|
|
4465
|
+
flag: "--status <status>",
|
|
4466
|
+
description: "Filter by status",
|
|
4467
|
+
sdkKey: "status"
|
|
4468
|
+
},
|
|
4469
|
+
{
|
|
4470
|
+
flag: "--customer-email <email>",
|
|
4471
|
+
description: "Filter by customer email",
|
|
4472
|
+
sdkKey: "customerEmail"
|
|
4473
|
+
},
|
|
4474
|
+
{
|
|
4475
|
+
flag: "--limit <n>",
|
|
4476
|
+
description: "Max results",
|
|
4477
|
+
parse: parseNumber,
|
|
4478
|
+
sdkKey: "limit"
|
|
4479
|
+
},
|
|
4480
|
+
{
|
|
4481
|
+
flag: "--cursor <cursor>",
|
|
4482
|
+
description: "Pagination cursor",
|
|
4483
|
+
sdkKey: "cursor"
|
|
4484
|
+
}
|
|
4485
|
+
]
|
|
4486
|
+
},
|
|
4487
|
+
get: {
|
|
4488
|
+
method: "get",
|
|
4489
|
+
description: "Get transaction details",
|
|
4490
|
+
params: [
|
|
4491
|
+
{
|
|
4492
|
+
flag: "--id <id>",
|
|
4493
|
+
description: "Transaction ID",
|
|
4494
|
+
required: true,
|
|
4495
|
+
sdkKey: "id"
|
|
4496
|
+
}
|
|
4497
|
+
]
|
|
4498
|
+
},
|
|
4499
|
+
refund: {
|
|
4500
|
+
method: "refund",
|
|
4501
|
+
description: "Refund a transaction (full refund)",
|
|
4502
|
+
params: [
|
|
4503
|
+
{
|
|
4504
|
+
flag: "--id <id>",
|
|
4505
|
+
description: "Transaction ID",
|
|
4506
|
+
required: true,
|
|
4507
|
+
sdkKey: "id"
|
|
4508
|
+
}
|
|
4509
|
+
]
|
|
4510
|
+
},
|
|
4511
|
+
retry: {
|
|
4512
|
+
method: "retry",
|
|
4513
|
+
description: "Retry a failed transaction",
|
|
4514
|
+
params: [
|
|
4515
|
+
{
|
|
4516
|
+
flag: "--id <id>",
|
|
4517
|
+
description: "Transaction ID",
|
|
4518
|
+
required: true,
|
|
4519
|
+
sdkKey: "id"
|
|
4520
|
+
}
|
|
4521
|
+
]
|
|
4522
|
+
}
|
|
4523
|
+
}
|
|
4524
|
+
};
|
|
4525
|
+
var promoCodesResource = {
|
|
4526
|
+
name: "promo-codes",
|
|
4527
|
+
description: "Manage promo codes",
|
|
4528
|
+
sdkProperty: "promoCodes",
|
|
4529
|
+
actions: {
|
|
4530
|
+
list: {
|
|
4531
|
+
method: "list",
|
|
4532
|
+
description: "List promo codes",
|
|
4533
|
+
params: [
|
|
4534
|
+
{
|
|
4535
|
+
flag: "--limit <n>",
|
|
4536
|
+
description: "Max results",
|
|
4537
|
+
parse: parseNumber,
|
|
4538
|
+
sdkKey: "limit"
|
|
4539
|
+
},
|
|
4540
|
+
{
|
|
4541
|
+
flag: "--cursor <cursor>",
|
|
4542
|
+
description: "Pagination cursor",
|
|
4543
|
+
sdkKey: "cursor"
|
|
4544
|
+
}
|
|
4545
|
+
]
|
|
4546
|
+
},
|
|
4547
|
+
get: {
|
|
4548
|
+
method: "get",
|
|
4549
|
+
description: "Get promo code details",
|
|
4550
|
+
params: [
|
|
4551
|
+
{
|
|
4552
|
+
flag: "--id <id>",
|
|
4553
|
+
description: "Promo code ID",
|
|
4554
|
+
required: true,
|
|
4555
|
+
sdkKey: "id"
|
|
4556
|
+
}
|
|
4557
|
+
]
|
|
4558
|
+
},
|
|
4559
|
+
create: {
|
|
4560
|
+
method: "create",
|
|
4561
|
+
description: "Create a promo code",
|
|
4562
|
+
params: [
|
|
4563
|
+
{
|
|
4564
|
+
flag: "--code <code>",
|
|
4565
|
+
description: "Promo code string",
|
|
4566
|
+
required: true,
|
|
4567
|
+
sdkKey: "code"
|
|
4568
|
+
},
|
|
4569
|
+
{
|
|
4570
|
+
flag: "--discount-type <type>",
|
|
4571
|
+
description: "Discount type: percentage or amount",
|
|
4572
|
+
required: true,
|
|
4573
|
+
sdkKey: "discountType"
|
|
4574
|
+
},
|
|
4575
|
+
{
|
|
4576
|
+
flag: "--discount-value <n>",
|
|
4577
|
+
description: "Discount value",
|
|
4578
|
+
required: true,
|
|
4579
|
+
parse: parseNumber,
|
|
4580
|
+
sdkKey: "discountValue"
|
|
4581
|
+
},
|
|
4582
|
+
{
|
|
4583
|
+
flag: "--duration-cycles <n>",
|
|
4584
|
+
description: "Duration in billing cycles",
|
|
4585
|
+
parse: parseNumber,
|
|
4586
|
+
sdkKey: "durationCycles"
|
|
4587
|
+
},
|
|
4588
|
+
{
|
|
4589
|
+
flag: "--max-redemptions <n>",
|
|
4590
|
+
description: "Maximum number of redemptions",
|
|
4591
|
+
parse: parseNumber,
|
|
4592
|
+
sdkKey: "maxRedemptions"
|
|
4593
|
+
},
|
|
4594
|
+
{
|
|
4595
|
+
flag: "--expires-at <date>",
|
|
4596
|
+
description: "Expiration date (ISO 8601)",
|
|
4597
|
+
sdkKey: "expiresAt"
|
|
4598
|
+
},
|
|
4599
|
+
{
|
|
4600
|
+
flag: "--plan-ids <json>",
|
|
4601
|
+
description: "Restrict to plan IDs (JSON array)",
|
|
4602
|
+
parse: parseJson,
|
|
4603
|
+
sdkKey: "planIds"
|
|
4604
|
+
}
|
|
4605
|
+
]
|
|
4606
|
+
},
|
|
4607
|
+
update: {
|
|
4608
|
+
method: "update",
|
|
4609
|
+
description: "Update a promo code",
|
|
4610
|
+
params: [
|
|
4611
|
+
{
|
|
4612
|
+
flag: "--id <id>",
|
|
4613
|
+
description: "Promo code ID",
|
|
4614
|
+
required: true,
|
|
4615
|
+
sdkKey: "id"
|
|
4616
|
+
},
|
|
4617
|
+
{
|
|
4618
|
+
flag: "--max-redemptions <n>",
|
|
4619
|
+
description: "Maximum number of redemptions",
|
|
4620
|
+
parse: parseNumber,
|
|
4621
|
+
sdkKey: "maxRedemptions"
|
|
4622
|
+
},
|
|
4623
|
+
{
|
|
4624
|
+
flag: "--expires-at <date>",
|
|
4625
|
+
description: "Expiration date (ISO 8601)",
|
|
4626
|
+
sdkKey: "expiresAt"
|
|
4627
|
+
},
|
|
4628
|
+
{
|
|
4629
|
+
flag: "--active <bool>",
|
|
4630
|
+
description: "Whether promo code is active",
|
|
4631
|
+
parse: parseBool,
|
|
4632
|
+
sdkKey: "active"
|
|
4633
|
+
},
|
|
4634
|
+
{
|
|
4635
|
+
flag: "--plan-ids <json>",
|
|
4636
|
+
description: "Restrict to plan IDs (JSON array)",
|
|
4637
|
+
parse: parseJson,
|
|
4638
|
+
sdkKey: "planIds"
|
|
4639
|
+
}
|
|
4640
|
+
]
|
|
4641
|
+
}
|
|
4642
|
+
}
|
|
4643
|
+
};
|
|
4644
|
+
var planGroupsResource = {
|
|
4645
|
+
name: "plan-groups",
|
|
4646
|
+
description: "Manage plan groups",
|
|
4647
|
+
sdkProperty: "planGroups",
|
|
4648
|
+
actions: {
|
|
4649
|
+
list: {
|
|
4650
|
+
method: "list",
|
|
4651
|
+
description: "List plan groups",
|
|
4652
|
+
params: [
|
|
4653
|
+
{
|
|
4654
|
+
flag: "--limit <n>",
|
|
4655
|
+
description: "Max results",
|
|
4656
|
+
parse: parseNumber,
|
|
4657
|
+
sdkKey: "limit"
|
|
4658
|
+
},
|
|
4659
|
+
{
|
|
4660
|
+
flag: "--cursor <cursor>",
|
|
4661
|
+
description: "Pagination cursor",
|
|
4662
|
+
sdkKey: "cursor"
|
|
4663
|
+
}
|
|
4664
|
+
]
|
|
4665
|
+
},
|
|
4666
|
+
get: {
|
|
4667
|
+
method: "get",
|
|
4668
|
+
description: "Get plan group details",
|
|
4669
|
+
params: [
|
|
4670
|
+
{
|
|
4671
|
+
flag: "--id <id>",
|
|
4672
|
+
description: "Plan group ID",
|
|
4673
|
+
required: true,
|
|
4674
|
+
sdkKey: "id"
|
|
4675
|
+
}
|
|
4676
|
+
]
|
|
4677
|
+
},
|
|
4678
|
+
create: {
|
|
4679
|
+
method: "create",
|
|
4680
|
+
description: "Create a plan group",
|
|
4681
|
+
params: [
|
|
4682
|
+
{
|
|
4683
|
+
flag: "--name <name>",
|
|
4684
|
+
description: "Plan group name",
|
|
4685
|
+
required: true,
|
|
4686
|
+
sdkKey: "name"
|
|
4687
|
+
},
|
|
4688
|
+
{
|
|
4689
|
+
flag: "--description <desc>",
|
|
4690
|
+
description: "Plan group description",
|
|
4691
|
+
sdkKey: "description"
|
|
4692
|
+
},
|
|
4693
|
+
{
|
|
4694
|
+
flag: "--is-public <bool>",
|
|
4695
|
+
description: "Whether plan group is publicly visible",
|
|
4696
|
+
parse: parseBool,
|
|
4697
|
+
sdkKey: "isPublic"
|
|
4698
|
+
}
|
|
4699
|
+
]
|
|
4700
|
+
},
|
|
4701
|
+
update: {
|
|
4702
|
+
method: "update",
|
|
4703
|
+
description: "Update a plan group",
|
|
4704
|
+
params: [
|
|
4705
|
+
{
|
|
4706
|
+
flag: "--id <id>",
|
|
4707
|
+
description: "Plan group ID",
|
|
4708
|
+
required: true,
|
|
4709
|
+
sdkKey: "id"
|
|
4710
|
+
},
|
|
4711
|
+
{
|
|
4712
|
+
flag: "--name <name>",
|
|
4713
|
+
description: "Plan group name",
|
|
4714
|
+
sdkKey: "name"
|
|
4715
|
+
},
|
|
4716
|
+
{
|
|
4717
|
+
flag: "--description <desc>",
|
|
4718
|
+
description: "Plan group description",
|
|
4719
|
+
sdkKey: "description"
|
|
4720
|
+
},
|
|
4721
|
+
{
|
|
4722
|
+
flag: "--is-public <bool>",
|
|
4723
|
+
description: "Whether plan group is publicly visible",
|
|
4724
|
+
parse: parseBool,
|
|
4725
|
+
sdkKey: "isPublic"
|
|
4726
|
+
}
|
|
4727
|
+
]
|
|
4728
|
+
},
|
|
4729
|
+
delete: {
|
|
4730
|
+
method: "delete",
|
|
4731
|
+
description: "Delete a plan group",
|
|
4732
|
+
params: [
|
|
4733
|
+
{
|
|
4734
|
+
flag: "--id <id>",
|
|
4735
|
+
description: "Plan group ID",
|
|
4736
|
+
required: true,
|
|
4737
|
+
sdkKey: "id"
|
|
4738
|
+
}
|
|
4739
|
+
]
|
|
4740
|
+
},
|
|
4741
|
+
"add-plan": {
|
|
4742
|
+
method: "addPlan",
|
|
4743
|
+
description: "Add a plan to a group",
|
|
4744
|
+
params: [
|
|
4745
|
+
{
|
|
4746
|
+
flag: "--id <id>",
|
|
4747
|
+
description: "Plan group ID",
|
|
4748
|
+
required: true,
|
|
4749
|
+
sdkKey: "id"
|
|
4750
|
+
},
|
|
4751
|
+
{
|
|
4752
|
+
flag: "--plan-id <planId>",
|
|
4753
|
+
description: "Plan ID to add",
|
|
4754
|
+
required: true,
|
|
4755
|
+
sdkKey: "planId"
|
|
4756
|
+
},
|
|
4757
|
+
{
|
|
4758
|
+
flag: "--sort-order <n>",
|
|
4759
|
+
description: "Sort order",
|
|
4760
|
+
parse: parseNumber,
|
|
4761
|
+
sdkKey: "sortOrder"
|
|
4762
|
+
}
|
|
4763
|
+
]
|
|
4764
|
+
},
|
|
4765
|
+
"remove-plan": {
|
|
4766
|
+
method: "removePlan",
|
|
4767
|
+
description: "Remove a plan from a group",
|
|
4768
|
+
params: [
|
|
4769
|
+
{
|
|
4770
|
+
flag: "--id <id>",
|
|
4771
|
+
description: "Plan group ID",
|
|
4772
|
+
required: true,
|
|
4773
|
+
sdkKey: "id"
|
|
4774
|
+
},
|
|
4775
|
+
{
|
|
4776
|
+
flag: "--plan-id <planId>",
|
|
4777
|
+
description: "Plan ID to remove",
|
|
4778
|
+
required: true,
|
|
4779
|
+
sdkKey: "planId"
|
|
4780
|
+
}
|
|
4781
|
+
]
|
|
4782
|
+
},
|
|
4783
|
+
"reorder-plans": {
|
|
4784
|
+
method: "reorderPlans",
|
|
4785
|
+
description: "Reorder plans within a group",
|
|
4786
|
+
params: [
|
|
4787
|
+
{
|
|
4788
|
+
flag: "--id <id>",
|
|
4789
|
+
description: "Plan group ID",
|
|
4790
|
+
required: true,
|
|
4791
|
+
sdkKey: "id"
|
|
4792
|
+
},
|
|
4793
|
+
{
|
|
4794
|
+
flag: "--plan-ids <json>",
|
|
4795
|
+
description: "Ordered plan IDs (JSON array)",
|
|
4796
|
+
required: true,
|
|
4797
|
+
parse: parseJson,
|
|
4798
|
+
sdkKey: "planIds"
|
|
4799
|
+
}
|
|
4800
|
+
]
|
|
4801
|
+
}
|
|
4802
|
+
}
|
|
4803
|
+
};
|
|
4804
|
+
var resourceDefinitions = [
|
|
4805
|
+
customersResource,
|
|
4806
|
+
subscriptionsResource,
|
|
4807
|
+
plansResource,
|
|
4808
|
+
featuresResource,
|
|
4809
|
+
seatsResource,
|
|
4810
|
+
usageResource,
|
|
4811
|
+
portalResource,
|
|
4812
|
+
addonsResource,
|
|
4813
|
+
creditPacksResource,
|
|
4814
|
+
webhooksResource,
|
|
4815
|
+
apiKeysResource,
|
|
4816
|
+
invoicesResource,
|
|
4817
|
+
transactionsResource,
|
|
4818
|
+
promoCodesResource,
|
|
4819
|
+
planGroupsResource
|
|
4820
|
+
];
|
|
4821
|
+
|
|
4822
|
+
// src/utils/update-check.ts
|
|
4823
|
+
var fs6 = __toESM(require("fs"));
|
|
4824
|
+
var os3 = __toESM(require("os"));
|
|
4825
|
+
var path6 = __toESM(require("path"));
|
|
4826
|
+
var import_chalk15 = __toESM(require("chalk"));
|
|
4827
|
+
var CACHE_FILE = path6.join(os3.homedir(), ".commet", ".update-check");
|
|
4828
|
+
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
4829
|
+
var REGISTRY_URL = "https://registry.npmjs.org/commet/latest";
|
|
4830
|
+
function isNewerVersion(latest, current) {
|
|
4831
|
+
const l = latest.split(".").map(Number);
|
|
4832
|
+
const c = current.split(".").map(Number);
|
|
4833
|
+
for (let i = 0; i < 3; i++) {
|
|
4834
|
+
if ((l[i] ?? 0) > (c[i] ?? 0)) return true;
|
|
4835
|
+
if ((l[i] ?? 0) < (c[i] ?? 0)) return false;
|
|
4836
|
+
}
|
|
4837
|
+
return false;
|
|
4838
|
+
}
|
|
4839
|
+
function readCache() {
|
|
4840
|
+
try {
|
|
4841
|
+
return JSON.parse(fs6.readFileSync(CACHE_FILE, "utf8"));
|
|
4842
|
+
} catch {
|
|
4843
|
+
return null;
|
|
4844
|
+
}
|
|
4845
|
+
}
|
|
4846
|
+
function writeCache(cache) {
|
|
4847
|
+
try {
|
|
4848
|
+
fs6.writeFileSync(CACHE_FILE, JSON.stringify(cache), "utf8");
|
|
4849
|
+
} catch {
|
|
4850
|
+
}
|
|
4851
|
+
}
|
|
4852
|
+
function shouldSkip() {
|
|
4853
|
+
if (process.env.COMMET_NO_UPDATE_CHECK === "1") return true;
|
|
4854
|
+
if (process.env.CI) return true;
|
|
4855
|
+
const idx = process.argv.indexOf("--output");
|
|
4856
|
+
if (idx !== -1 && process.argv[idx + 1] === "agent") return true;
|
|
4857
|
+
return false;
|
|
4858
|
+
}
|
|
4859
|
+
var updateAvailable = null;
|
|
4860
|
+
function scheduleUpdateCheck(currentVersion) {
|
|
4861
|
+
if (shouldSkip()) return;
|
|
4862
|
+
const cache = readCache();
|
|
4863
|
+
if (cache && isNewerVersion(cache.latestVersion, currentVersion)) {
|
|
4864
|
+
updateAvailable = cache.latestVersion;
|
|
4865
|
+
}
|
|
4866
|
+
const needsFetch = !cache || Date.now() - cache.checkedAt > CHECK_INTERVAL_MS;
|
|
4867
|
+
if (!needsFetch) return;
|
|
4868
|
+
const controller = new AbortController();
|
|
4869
|
+
const timeout = setTimeout(() => controller.abort(), 3e3);
|
|
4870
|
+
fetch(REGISTRY_URL, { signal: controller.signal }).then((r) => r.json()).then((data) => {
|
|
4871
|
+
writeCache({ latestVersion: data.version, checkedAt: Date.now() });
|
|
4872
|
+
if (!updateAvailable && isNewerVersion(data.version, currentVersion)) {
|
|
4873
|
+
updateAvailable = data.version;
|
|
4874
|
+
}
|
|
4875
|
+
}).catch(() => {
|
|
4876
|
+
}).finally(() => clearTimeout(timeout));
|
|
4877
|
+
}
|
|
4878
|
+
function printUpdateNotification(currentVersion) {
|
|
4879
|
+
if (!updateAvailable) return;
|
|
4880
|
+
console.log("");
|
|
4881
|
+
console.log(
|
|
4882
|
+
` Update available: ${import_chalk15.default.dim(currentVersion)} \u2192 ${import_chalk15.default.green(updateAvailable)}`
|
|
4883
|
+
);
|
|
4884
|
+
console.log(import_chalk15.default.dim(` Run: npm i -g commet@latest`));
|
|
4885
|
+
}
|
|
4886
|
+
|
|
4887
|
+
// src/index.ts
|
|
4888
|
+
var program = new import_commander11.Command();
|
|
4889
|
+
program.name("commet").description(
|
|
4890
|
+
"Commet CLI \u2014 billing infrastructure as code.\nManage features, plans, and billing config from the command line."
|
|
4891
|
+
).version(package_default.version).addHelpText(
|
|
4892
|
+
"after",
|
|
4893
|
+
`
|
|
4894
|
+
Workflow:
|
|
4895
|
+
$ commet pull Sync remote \u2192 commet.config.ts
|
|
4896
|
+
$ commet push Push local changes \u2192 remote
|
|
4897
|
+
$ commet pull --dry-run See what's configured
|
|
4898
|
+
|
|
4899
|
+
For agents and CI:
|
|
4900
|
+
$ commet JSON capabilities when piped (no args)
|
|
4901
|
+
$ commet pull --output agent --yes Structured output, no prompts
|
|
4902
|
+
$ COMMET_API_KEY=ck_... commet push --yes CI pipeline
|
|
4903
|
+
|
|
4904
|
+
Run commet <command> --help for detailed usage and examples.
|
|
4905
|
+
`
|
|
4906
|
+
);
|
|
4907
|
+
program.addCommand(createCommand);
|
|
4908
|
+
program.addCommand(loginCommand);
|
|
4909
|
+
program.addCommand(logoutCommand);
|
|
4910
|
+
program.addCommand(linkCommand);
|
|
4911
|
+
program.addCommand(orgsCommand);
|
|
4912
|
+
program.addCommand(pushCommand);
|
|
4913
|
+
program.addCommand(pullCommand);
|
|
4914
|
+
program.addCommand(listenCommand);
|
|
4915
|
+
program.addCommand(apiKeyCommand);
|
|
4916
|
+
for (const def of resourceDefinitions) {
|
|
4917
|
+
program.addCommand(createResourceCommand(def));
|
|
4918
|
+
}
|
|
4919
|
+
program.enablePositionalOptions().passThroughOptions().option(
|
|
4920
|
+
"--output <format>",
|
|
4921
|
+
"Output format: human (default) or agent",
|
|
4922
|
+
"human"
|
|
4923
|
+
);
|
|
4924
|
+
program.action((options) => {
|
|
4925
|
+
if (options.output === "agent") {
|
|
4926
|
+
printAgentInfo();
|
|
4927
|
+
} else {
|
|
4928
|
+
printDefaultScreen();
|
|
4929
|
+
}
|
|
4930
|
+
});
|
|
4931
|
+
program.showSuggestionAfterError();
|
|
4932
|
+
program.exitOverride();
|
|
4933
|
+
installCrashHandler();
|
|
4934
|
+
markCommandStart();
|
|
4935
|
+
scheduleUpdateCheck(package_default.version);
|
|
4936
|
+
var commandName = process.argv[2] || "(default)";
|
|
4937
|
+
program.hook("postAction", () => {
|
|
4938
|
+
reportCommand(commandName, "success");
|
|
4939
|
+
printUpdateNotification(package_default.version);
|
|
4940
|
+
});
|
|
4941
|
+
try {
|
|
4942
|
+
program.parse(process.argv);
|
|
4943
|
+
} catch (error) {
|
|
4944
|
+
if (error instanceof Error) {
|
|
4945
|
+
const code = error.code;
|
|
4946
|
+
if (code === "commander.version" || code === "commander.help" || code === "commander.helpDisplayed") {
|
|
4947
|
+
process.exit(0);
|
|
4948
|
+
}
|
|
4949
|
+
reportCommand(commandName, "error", code);
|
|
4950
|
+
console.error(import_chalk16.default.red("Error:"), error.message);
|
|
4951
|
+
}
|
|
4952
|
+
process.exit(1);
|
|
4953
|
+
}
|
|
4954
|
+
function printAgentInfo() {
|
|
4955
|
+
const authenticated = authExists() || !!process.env.COMMET_API_KEY;
|
|
4956
|
+
const projectConfig = projectConfigExists() ? loadProjectConfig() : null;
|
|
4957
|
+
const configPath = findConfigFile(process.cwd());
|
|
4958
|
+
const setup = [];
|
|
4959
|
+
if (!authenticated) {
|
|
4960
|
+
setup.push(
|
|
4961
|
+
"Not authenticated. Run 'commet login' (interactive) or set COMMET_API_KEY env var."
|
|
4962
|
+
);
|
|
4963
|
+
}
|
|
4964
|
+
if (authenticated && !projectConfig && !process.env.COMMET_API_KEY) {
|
|
4965
|
+
setup.push(
|
|
4966
|
+
"No project linked. Run 'commet link --org <slug>' or 'commet orgs --json' to find organizations."
|
|
4967
|
+
);
|
|
4968
|
+
}
|
|
4969
|
+
const output = {
|
|
4970
|
+
version: package_default.version,
|
|
4971
|
+
authenticated,
|
|
4972
|
+
...setup.length > 0 ? { setup } : {},
|
|
4973
|
+
project: projectConfig ? {
|
|
4974
|
+
linked: true,
|
|
4975
|
+
orgId: projectConfig.orgId,
|
|
4976
|
+
orgName: projectConfig.orgName,
|
|
4977
|
+
mode: projectConfig.mode
|
|
4978
|
+
} : { linked: false },
|
|
4979
|
+
config: {
|
|
4980
|
+
exists: configPath !== null,
|
|
4981
|
+
path: configPath?.split("/").pop() ?? null
|
|
4982
|
+
},
|
|
4983
|
+
mcp: {
|
|
4984
|
+
url: "https://commet.co/mcp",
|
|
4985
|
+
sandbox: "https://sandbox.commet.co/mcp",
|
|
4986
|
+
hint: "For full billing CRUD (plans, features, customers, subscriptions), connect to the MCP server."
|
|
4987
|
+
},
|
|
4988
|
+
auth: {
|
|
4989
|
+
interactive: "commet login",
|
|
4990
|
+
ci: "Set COMMET_API_KEY environment variable"
|
|
4991
|
+
},
|
|
4992
|
+
commands: {
|
|
4993
|
+
pull: {
|
|
4994
|
+
description: "Pull remote config and generate commet.config.ts",
|
|
4995
|
+
usage: "commet pull --output agent --yes",
|
|
4996
|
+
preview: "commet pull --output agent --dry-run"
|
|
4997
|
+
},
|
|
4998
|
+
push: {
|
|
4999
|
+
description: "Push commet.config.ts to remote",
|
|
5000
|
+
usage: "commet push --output agent --yes",
|
|
5001
|
+
preview: "commet push --output agent --dry-run",
|
|
5002
|
+
ci: "COMMET_API_KEY=ck_... commet push --yes"
|
|
5003
|
+
},
|
|
5004
|
+
orgs: {
|
|
5005
|
+
description: "List available organizations",
|
|
5006
|
+
usage: "commet orgs --output agent"
|
|
5007
|
+
},
|
|
5008
|
+
link: {
|
|
5009
|
+
description: "Link/switch/unlink organization",
|
|
5010
|
+
usage: "commet link --org <slug-or-id>",
|
|
5011
|
+
clear: "commet link --clear"
|
|
5012
|
+
},
|
|
5013
|
+
listen: {
|
|
5014
|
+
description: "Forward webhook events to local server. Long-running streaming process.",
|
|
5015
|
+
usage: "commet listen <url> [--events <types>]"
|
|
5016
|
+
},
|
|
5017
|
+
create: {
|
|
5018
|
+
description: "Scaffold a new Commet app from template",
|
|
5019
|
+
usage: "commet create [name] -t <template> --org <slug> -y"
|
|
5020
|
+
},
|
|
5021
|
+
"api-key": {
|
|
5022
|
+
description: "Generate API key for CI",
|
|
5023
|
+
usage: "commet api-key --output agent"
|
|
5024
|
+
},
|
|
5025
|
+
login: {
|
|
5026
|
+
description: "Authenticate via browser. Requires a human \u2014 opens a device-code flow.",
|
|
5027
|
+
usage: "commet login"
|
|
5028
|
+
},
|
|
5029
|
+
logout: {
|
|
5030
|
+
description: "Log out of Commet",
|
|
5031
|
+
usage: "commet logout"
|
|
5032
|
+
}
|
|
5033
|
+
},
|
|
5034
|
+
resources: generateResourceSchema(resourceDefinitions)
|
|
5035
|
+
};
|
|
5036
|
+
console.log(JSON.stringify(output, null, 2));
|
|
5037
|
+
}
|
|
5038
|
+
function printDefaultScreen() {
|
|
5039
|
+
const version = import_chalk16.default.dim(`v${package_default.version}`);
|
|
5040
|
+
console.log(`
|
|
5041
|
+
${commetColor.bold("Commet")} ${version}`);
|
|
5042
|
+
console.log(import_chalk16.default.dim(" Billing infrastructure as code\n"));
|
|
5043
|
+
const authenticated = authExists();
|
|
5044
|
+
const projectConfig = projectConfigExists() ? loadProjectConfig() : null;
|
|
5045
|
+
const configFile = findConfigFile(process.cwd());
|
|
5046
|
+
if (authenticated) {
|
|
5047
|
+
console.log(import_chalk16.default.green(" \u2713 Authenticated"));
|
|
5048
|
+
} else {
|
|
5049
|
+
console.log(
|
|
5050
|
+
` ${import_chalk16.default.yellow("\u26A0")} Not logged in ${import_chalk16.default.dim("\u2192 commet login")}`
|
|
5051
|
+
);
|
|
5052
|
+
}
|
|
5053
|
+
if (projectConfig) {
|
|
5054
|
+
console.log(
|
|
5055
|
+
import_chalk16.default.green(
|
|
5056
|
+
` \u2713 ${projectConfig.orgName} ${import_chalk16.default.dim(`(${projectConfig.mode})`)}`
|
|
5057
|
+
)
|
|
5058
|
+
);
|
|
5059
|
+
console.log(import_chalk16.default.dim(` ${projectConfig.orgId}`));
|
|
5060
|
+
} else if (authenticated) {
|
|
5061
|
+
console.log(
|
|
5062
|
+
` ${import_chalk16.default.yellow("\u26A0")} No project linked ${import_chalk16.default.dim("\u2192 commet link")}`
|
|
5063
|
+
);
|
|
5064
|
+
}
|
|
5065
|
+
if (configFile) {
|
|
5066
|
+
const fileName = configFile.split("/").pop();
|
|
5067
|
+
console.log(import_chalk16.default.green(` \u2713 ${fileName}`));
|
|
5068
|
+
} else if (projectConfig) {
|
|
5069
|
+
console.log(
|
|
5070
|
+
` ${import_chalk16.default.yellow("\u26A0")} No config file ${import_chalk16.default.dim("\u2192 commet pull")}`
|
|
5071
|
+
);
|
|
5072
|
+
}
|
|
5073
|
+
const cmd = (name) => commetColor(name.padEnd(22));
|
|
5074
|
+
const dim = import_chalk16.default.dim;
|
|
5075
|
+
console.log(dim("\n Config"));
|
|
5076
|
+
console.log(` ${cmd("pull")}${dim("Sync remote \u2192 commet.config.ts")}`);
|
|
5077
|
+
console.log(` ${cmd("push")}${dim("Sync commet.config.ts \u2192 remote")}`);
|
|
5078
|
+
console.log(dim("\n Development"));
|
|
5079
|
+
console.log(` ${cmd("listen <url>")}${dim("Forward webhooks locally")}`);
|
|
5080
|
+
console.log(dim("\n Project"));
|
|
5081
|
+
console.log(` ${cmd("link")}${dim("Link / switch organization")}`);
|
|
2506
5082
|
console.log(` ${cmd("orgs")}${dim("List organizations")}`);
|
|
5083
|
+
console.log(dim("\n Resources (SDK)"));
|
|
5084
|
+
for (const def of resourceDefinitions) {
|
|
5085
|
+
console.log(` ${cmd(def.name)}${dim(def.description)}`);
|
|
5086
|
+
}
|
|
2507
5087
|
console.log(dim("\n Setup"));
|
|
2508
5088
|
console.log(` ${cmd("create")}${dim("Scaffold a new Commet app")}`);
|
|
2509
5089
|
console.log(` ${cmd("api-key")}${dim("Generate API key for CI")}`);
|