@kelviq/cli 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,18 @@
1
1
  import { Command } from 'commander';
2
+ export declare const TEMPLATES: {
3
+ readonly saas: "// kelviq.config.ts — pricing-as-code for Kelviq.\n// Defines products, features, and plans as typed, versioned TypeScript.\n// Sync this file with your Kelviq account using `kelviq pull` / `kelviq push`.\nimport { product, feature, plan } from '@kelviq/cli/config';\n\nexport const app = product({\n identifier: 'my-app',\n name: 'My App',\n taxCode: 'saas',\n});\n\nexport const exportData = feature({\n identifier: 'export-data',\n name: 'Export data',\n type: 'BOOLEAN',\n});\n\nexport const historyRetention = feature({\n identifier: 'history-retention',\n name: 'History retention (days)',\n type: 'CUSTOMIZABLE',\n});\n\nexport const free = plan({\n identifier: 'free',\n name: 'Free',\n product: 'my-app',\n entitlements: [{ feature: 'history-retention', value: 7 }],\n prices: [\n {\n priceType: 'FREE',\n currency: 'USD',\n freeTrial: false,\n trialPeriod: 0,\n enabled: true,\n taxBehavior: 'EXCLUSIVE',\n },\n ],\n});\n\nexport const pro = plan({\n identifier: 'pro',\n name: 'Pro',\n product: 'my-app',\n entitlements: [\n { feature: 'export-data', value: true },\n { feature: 'history-retention', value: 90 },\n ],\n prices: [\n {\n priceType: 'PAID',\n currency: 'USD',\n freeTrial: false,\n trialPeriod: 0,\n enabled: true,\n taxBehavior: 'EXCLUSIVE',\n chargeCatalogPrice: [\n {\n feature: null,\n priceModel: 'FLAT',\n paymentType: 'ADVANCE_COMMITMENT',\n reset: 'NEVER',\n charges: [\n { chargePeriod: 'MONTHLY', priceData: { amount: 29 } },\n { chargePeriod: 'YEARLY', priceData: { amount: 290 } },\n ],\n },\n ],\n },\n ],\n});\n";
4
+ readonly usage: "// kelviq.config.ts — pricing-as-code for Kelviq.\n// Defines products, features, and plans as typed, versioned TypeScript.\n// Sync this file with your Kelviq account using `kelviq pull` / `kelviq push`.\nimport { product, feature, plan } from '@kelviq/cli/config';\n\nexport const app = product({\n identifier: 'my-app',\n name: 'My App',\n taxCode: 'saas',\n});\n\n// A METER feature needs featureDetails: the API rejects it without them.\nexport const aiCredits = feature({\n identifier: 'ai-credits',\n name: 'AI credits',\n type: 'METER',\n featureDetails: {\n featureSubType: 'PRE_AGGREGATED_USAGE',\n units: { singular: 'credit', plural: 'credits' },\n },\n});\n\nexport const free = plan({\n identifier: 'free',\n name: 'Free',\n product: 'my-app',\n entitlements: [{ feature: 'ai-credits', value: 1000, reset: 'EVERY_MONTH', hardLimit: true }],\n prices: [\n {\n priceType: 'FREE',\n currency: 'USD',\n freeTrial: false,\n trialPeriod: 0,\n enabled: true,\n taxBehavior: 'EXCLUSIVE',\n },\n ],\n});\n\n// $29/month with 10,000 credits included, then $0.01 per credit, billed monthly in arrears.\nexport const pro = plan({\n identifier: 'pro',\n name: 'Pro',\n product: 'my-app',\n entitlements: [{ feature: 'ai-credits', value: 10000, reset: 'EVERY_MONTH', hardLimit: false }],\n prices: [\n {\n priceType: 'PAID',\n currency: 'USD',\n freeTrial: false,\n trialPeriod: 0,\n enabled: true,\n taxBehavior: 'EXCLUSIVE',\n chargeCatalogPrice: [\n {\n feature: null,\n priceModel: 'FLAT',\n paymentType: 'ADVANCE_COMMITMENT',\n reset: 'NEVER',\n charges: [{ chargePeriod: 'MONTHLY', priceData: { amount: 29 } }],\n },\n {\n feature: 'ai-credits',\n priceModel: 'TIERED',\n paymentType: 'PAY_AS_YOU_GO',\n reset: 'EVERY_MONTH',\n charges: [\n {\n chargePeriod: 'MONTHLY',\n priceData: { currency: 'USD' },\n tiers: [\n { upTo: 10000, unitAmount: 0, flatAmount: 0 },\n { upTo: 'inf', unitAmount: 0.01, flatAmount: 0 },\n ],\n },\n ],\n },\n ],\n },\n ],\n});\n";
5
+ readonly license: "// kelviq.config.ts — pricing-as-code for Kelviq.\n// Defines products, features, and plans as typed, versioned TypeScript.\n// Sync this file with your Kelviq account using `kelviq pull` / `kelviq push`.\nimport { product, feature, plan } from '@kelviq/cli/config';\n\nexport const app = product({\n identifier: 'my-app',\n name: 'My App',\n taxCode: 'software',\n});\n\nexport const proFeatures = feature({\n identifier: 'pro-features',\n name: 'Pro features',\n type: 'BOOLEAN',\n});\n\n// Every order for this plan issues a license key, valid on up to 3 devices.\nexport const pro = plan({\n identifier: 'pro',\n name: 'Pro',\n product: 'my-app',\n license: {\n enabled: true,\n activationLimitEnabled: true,\n activationLimit: 3,\n hasExpiry: false,\n },\n entitlements: [{ feature: 'pro-features', value: true }],\n prices: [\n {\n priceType: 'PAID',\n currency: 'USD',\n freeTrial: false,\n trialPeriod: 0,\n enabled: true,\n taxBehavior: 'EXCLUSIVE',\n chargeCatalogPrice: [\n {\n feature: null,\n priceModel: 'FLAT',\n paymentType: 'ADVANCE_COMMITMENT',\n reset: 'NEVER',\n charges: [\n { chargePeriod: 'MONTHLY', priceData: { amount: 9 } },\n { chargePeriod: 'YEARLY', priceData: { amount: 90 } },\n ],\n },\n ],\n },\n ],\n});\n";
6
+ };
7
+ export type TemplateName = keyof typeof TEMPLATES;
8
+ export declare const TEMPLATE_NAMES: TemplateName[];
9
+ /** Kept for callers that referenced the original single starter. */
10
+ export declare const STARTER_CONFIG = "// kelviq.config.ts \u2014 pricing-as-code for Kelviq.\n// Defines products, features, and plans as typed, versioned TypeScript.\n// Sync this file with your Kelviq account using `kelviq pull` / `kelviq push`.\nimport { product, feature, plan } from '@kelviq/cli/config';\n\nexport const app = product({\n identifier: 'my-app',\n name: 'My App',\n taxCode: 'saas',\n});\n\nexport const exportData = feature({\n identifier: 'export-data',\n name: 'Export data',\n type: 'BOOLEAN',\n});\n\nexport const historyRetention = feature({\n identifier: 'history-retention',\n name: 'History retention (days)',\n type: 'CUSTOMIZABLE',\n});\n\nexport const free = plan({\n identifier: 'free',\n name: 'Free',\n product: 'my-app',\n entitlements: [{ feature: 'history-retention', value: 7 }],\n prices: [\n {\n priceType: 'FREE',\n currency: 'USD',\n freeTrial: false,\n trialPeriod: 0,\n enabled: true,\n taxBehavior: 'EXCLUSIVE',\n },\n ],\n});\n\nexport const pro = plan({\n identifier: 'pro',\n name: 'Pro',\n product: 'my-app',\n entitlements: [\n { feature: 'export-data', value: true },\n { feature: 'history-retention', value: 90 },\n ],\n prices: [\n {\n priceType: 'PAID',\n currency: 'USD',\n freeTrial: false,\n trialPeriod: 0,\n enabled: true,\n taxBehavior: 'EXCLUSIVE',\n chargeCatalogPrice: [\n {\n feature: null,\n priceModel: 'FLAT',\n paymentType: 'ADVANCE_COMMITMENT',\n reset: 'NEVER',\n charges: [\n { chargePeriod: 'MONTHLY', priceData: { amount: 29 } },\n { chargePeriod: 'YEARLY', priceData: { amount: 290 } },\n ],\n },\n ],\n },\n ],\n});\n";
2
11
  export interface InitOptions {
3
12
  output?: string;
4
13
  force?: boolean;
14
+ /** Which starter catalog to write: `saas` (default), `usage`, or `license`. */
15
+ template?: string;
5
16
  }
6
17
  export interface InitIO {
7
18
  stdout: NodeJS.WritableStream;
@@ -5,40 +5,219 @@ import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
5
5
  import { dirname, resolve } from 'node:path';
6
6
  import { INIT_HINT, printHint } from '../cli-ui/hints.js';
7
7
  const DEFAULT_OUTPUT = 'kelviq.config.ts';
8
- // A commented, compiling example — see CLI plan 004 Step 4. Imports from the
9
- // published `@kelviq/cli/config` subpath (src/config-format/index.ts,
10
- // exported via package.json's "./config" export).
11
- const STARTER_CONFIG = `// kelviq.config.ts — pricing-as-code for Kelviq.
8
+ // Complete, pushable starter catalogs — every price sets the fields the
9
+ // server would otherwise default, every METER feature carries the details
10
+ // the API requires, and seats/usage are modelled the way the docs say
11
+ // (`product-catalog/seat-based-pricing`, `product-catalog/usage-based-billing`).
12
+ // Imports from the published `@kelviq/cli/config` subpath.
13
+ const HEADER = `// kelviq.config.ts — pricing-as-code for Kelviq.
12
14
  // Defines products, features, and plans as typed, versioned TypeScript.
13
15
  // Sync this file with your Kelviq account using \`kelviq pull\` / \`kelviq push\`.
14
16
  import { product, feature, plan } from '@kelviq/cli/config';
15
-
17
+ `;
18
+ const SAAS_TEMPLATE = `${HEADER}
16
19
  export const app = product({
17
20
  identifier: 'my-app',
18
21
  name: 'My App',
19
22
  taxCode: 'saas',
20
23
  });
21
24
 
22
- export const seats = feature({
23
- identifier: 'seats',
24
- name: 'Seats',
25
+ export const exportData = feature({
26
+ identifier: 'export-data',
27
+ name: 'Export data',
28
+ type: 'BOOLEAN',
29
+ });
30
+
31
+ export const historyRetention = feature({
32
+ identifier: 'history-retention',
33
+ name: 'History retention (days)',
25
34
  type: 'CUSTOMIZABLE',
26
35
  });
27
36
 
37
+ export const free = plan({
38
+ identifier: 'free',
39
+ name: 'Free',
40
+ product: 'my-app',
41
+ entitlements: [{ feature: 'history-retention', value: 7 }],
42
+ prices: [
43
+ {
44
+ priceType: 'FREE',
45
+ currency: 'USD',
46
+ freeTrial: false,
47
+ trialPeriod: 0,
48
+ enabled: true,
49
+ taxBehavior: 'EXCLUSIVE',
50
+ },
51
+ ],
52
+ });
53
+
54
+ export const pro = plan({
55
+ identifier: 'pro',
56
+ name: 'Pro',
57
+ product: 'my-app',
58
+ entitlements: [
59
+ { feature: 'export-data', value: true },
60
+ { feature: 'history-retention', value: 90 },
61
+ ],
62
+ prices: [
63
+ {
64
+ priceType: 'PAID',
65
+ currency: 'USD',
66
+ freeTrial: false,
67
+ trialPeriod: 0,
68
+ enabled: true,
69
+ taxBehavior: 'EXCLUSIVE',
70
+ chargeCatalogPrice: [
71
+ {
72
+ feature: null,
73
+ priceModel: 'FLAT',
74
+ paymentType: 'ADVANCE_COMMITMENT',
75
+ reset: 'NEVER',
76
+ charges: [
77
+ { chargePeriod: 'MONTHLY', priceData: { amount: 29 } },
78
+ { chargePeriod: 'YEARLY', priceData: { amount: 290 } },
79
+ ],
80
+ },
81
+ ],
82
+ },
83
+ ],
84
+ });
85
+ `;
86
+ const USAGE_TEMPLATE = `${HEADER}
87
+ export const app = product({
88
+ identifier: 'my-app',
89
+ name: 'My App',
90
+ taxCode: 'saas',
91
+ });
92
+
93
+ // A METER feature needs featureDetails: the API rejects it without them.
94
+ export const aiCredits = feature({
95
+ identifier: 'ai-credits',
96
+ name: 'AI credits',
97
+ type: 'METER',
98
+ featureDetails: {
99
+ featureSubType: 'PRE_AGGREGATED_USAGE',
100
+ units: { singular: 'credit', plural: 'credits' },
101
+ },
102
+ });
103
+
104
+ export const free = plan({
105
+ identifier: 'free',
106
+ name: 'Free',
107
+ product: 'my-app',
108
+ entitlements: [{ feature: 'ai-credits', value: 1000, reset: 'EVERY_MONTH', hardLimit: true }],
109
+ prices: [
110
+ {
111
+ priceType: 'FREE',
112
+ currency: 'USD',
113
+ freeTrial: false,
114
+ trialPeriod: 0,
115
+ enabled: true,
116
+ taxBehavior: 'EXCLUSIVE',
117
+ },
118
+ ],
119
+ });
120
+
121
+ // $29/month with 10,000 credits included, then $0.01 per credit, billed monthly in arrears.
28
122
  export const pro = plan({
29
123
  identifier: 'pro',
30
124
  name: 'Pro',
31
125
  product: 'my-app',
32
- entitlements: [{ feature: 'seats', value: 5 }],
126
+ entitlements: [{ feature: 'ai-credits', value: 10000, reset: 'EVERY_MONTH', hardLimit: false }],
33
127
  prices: [
34
128
  {
35
129
  priceType: 'PAID',
36
130
  currency: 'USD',
37
- // Full charge shape: see Kelviq docs → api-reference/plans/update-plan-prices
131
+ freeTrial: false,
132
+ trialPeriod: 0,
133
+ enabled: true,
134
+ taxBehavior: 'EXCLUSIVE',
135
+ chargeCatalogPrice: [
136
+ {
137
+ feature: null,
138
+ priceModel: 'FLAT',
139
+ paymentType: 'ADVANCE_COMMITMENT',
140
+ reset: 'NEVER',
141
+ charges: [{ chargePeriod: 'MONTHLY', priceData: { amount: 29 } }],
142
+ },
143
+ {
144
+ feature: 'ai-credits',
145
+ priceModel: 'TIERED',
146
+ paymentType: 'PAY_AS_YOU_GO',
147
+ reset: 'EVERY_MONTH',
148
+ charges: [
149
+ {
150
+ chargePeriod: 'MONTHLY',
151
+ priceData: { currency: 'USD' },
152
+ tiers: [
153
+ { upTo: 10000, unitAmount: 0, flatAmount: 0 },
154
+ { upTo: 'inf', unitAmount: 0.01, flatAmount: 0 },
155
+ ],
156
+ },
157
+ ],
158
+ },
159
+ ],
38
160
  },
39
161
  ],
40
162
  });
41
163
  `;
164
+ const LICENSE_TEMPLATE = `${HEADER}
165
+ export const app = product({
166
+ identifier: 'my-app',
167
+ name: 'My App',
168
+ taxCode: 'software',
169
+ });
170
+
171
+ export const proFeatures = feature({
172
+ identifier: 'pro-features',
173
+ name: 'Pro features',
174
+ type: 'BOOLEAN',
175
+ });
176
+
177
+ // Every order for this plan issues a license key, valid on up to 3 devices.
178
+ export const pro = plan({
179
+ identifier: 'pro',
180
+ name: 'Pro',
181
+ product: 'my-app',
182
+ license: {
183
+ enabled: true,
184
+ activationLimitEnabled: true,
185
+ activationLimit: 3,
186
+ hasExpiry: false,
187
+ },
188
+ entitlements: [{ feature: 'pro-features', value: true }],
189
+ prices: [
190
+ {
191
+ priceType: 'PAID',
192
+ currency: 'USD',
193
+ freeTrial: false,
194
+ trialPeriod: 0,
195
+ enabled: true,
196
+ taxBehavior: 'EXCLUSIVE',
197
+ chargeCatalogPrice: [
198
+ {
199
+ feature: null,
200
+ priceModel: 'FLAT',
201
+ paymentType: 'ADVANCE_COMMITMENT',
202
+ reset: 'NEVER',
203
+ charges: [
204
+ { chargePeriod: 'MONTHLY', priceData: { amount: 9 } },
205
+ { chargePeriod: 'YEARLY', priceData: { amount: 90 } },
206
+ ],
207
+ },
208
+ ],
209
+ },
210
+ ],
211
+ });
212
+ `;
213
+ export const TEMPLATES = {
214
+ saas: SAAS_TEMPLATE,
215
+ usage: USAGE_TEMPLATE,
216
+ license: LICENSE_TEMPLATE,
217
+ };
218
+ export const TEMPLATE_NAMES = Object.keys(TEMPLATES);
219
+ /** Kept for callers that referenced the original single starter. */
220
+ export const STARTER_CONFIG = SAAS_TEMPLATE;
42
221
  /**
43
222
  * Writes the starter config to `options.output` (default `kelviq.config.ts`
44
223
  * in the current directory). Returns a non-zero exit code and writes nothing
@@ -46,13 +225,18 @@ export const pro = plan({
46
225
  */
47
226
  export function runInit(options, io) {
48
227
  const targetPath = resolve(options.output ?? DEFAULT_OUTPUT);
228
+ const templateName = options.template ?? 'saas';
229
+ if (!(templateName in TEMPLATES)) {
230
+ io.stdout.write(`Unknown template "${templateName}". Use one of: ${TEMPLATE_NAMES.join(', ')}.\n`);
231
+ return 1;
232
+ }
49
233
  if (existsSync(targetPath) && !options.force) {
50
234
  io.stdout.write(`${targetPath} already exists. Use --force to overwrite.\n`);
51
235
  return 1;
52
236
  }
53
237
  mkdirSync(dirname(targetPath), { recursive: true });
54
- writeFileSync(targetPath, STARTER_CONFIG);
55
- io.stdout.write(`Wrote starter config to ${targetPath}\n`);
238
+ writeFileSync(targetPath, TEMPLATES[templateName]);
239
+ io.stdout.write(`Wrote ${templateName} starter config to ${targetPath}\n`);
56
240
  printHint(io.stdout, INIT_HINT);
57
241
  return 0;
58
242
  }
@@ -62,6 +246,7 @@ export function registerInitCommand(program) {
62
246
  .description('Generate a starter kelviq.config.ts file for pricing-as-code.')
63
247
  .option('-o, --output <path>', 'Path to write the config file', DEFAULT_OUTPUT)
64
248
  .option('--force', 'Overwrite the file if it already exists', false)
249
+ .option('--template <name>', `Starter catalog to write: ${TEMPLATE_NAMES.join(', ')}`, 'saas')
65
250
  .action((opts) => {
66
251
  const exitCode = runInit(opts, { stdout: process.stdout });
67
252
  process.exitCode = exitCode;
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,sEAAsE;AACtE,uBAAuB;AACvB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,S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AC7F,MAAM,CAAC,CAAC,IAAiB,EAAE,EAAE;QAC5B,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3D,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC9B,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { Command } from 'commander';
2
+ import type { ApiPlan, RawCatalog } from '../sync/fetch-catalog.js';
3
+ export interface StatusOptions {
4
+ prod?: boolean;
5
+ json?: boolean;
6
+ }
7
+ export interface StatusIO {
8
+ stdout: NodeJS.WritableStream;
9
+ stderr: NodeJS.WritableStream;
10
+ env?: NodeJS.ProcessEnv;
11
+ configDir?: string;
12
+ }
13
+ export interface PlanStatus {
14
+ identifier: string;
15
+ name: string;
16
+ product: string | null;
17
+ version: number | null;
18
+ isLatest: boolean;
19
+ isVisible: boolean;
20
+ prices: number;
21
+ entitlements: number;
22
+ licenseKeys: boolean;
23
+ }
24
+ /** The exact `kelviq status --json` document. */
25
+ export interface StatusJsonDocument {
26
+ environment: 'sandbox' | 'production';
27
+ products: Array<{
28
+ identifier: string;
29
+ name: string;
30
+ }>;
31
+ features: Array<{
32
+ identifier: string;
33
+ name: string;
34
+ type: string;
35
+ }>;
36
+ plans: PlanStatus[];
37
+ }
38
+ /** Keeps one entry per plan identifier: the one marked `isLatest`, else the highest version. */
39
+ export declare function latestPlans(plans: ApiPlan[]): ApiPlan[];
40
+ export declare function buildStatus(raw: RawCatalog, environment: 'sandbox' | 'production'): StatusJsonDocument;
41
+ export declare function renderStatus(doc: StatusJsonDocument): string;
42
+ export declare function runStatus(options: StatusOptions, io: StatusIO): Promise<number>;
43
+ export declare function registerStatusCommand(program: Command): void;
@@ -0,0 +1,133 @@
1
+ import { authHintLine, messageCarriesAuthStatus } from '../cli-ui/auth-hint.js';
2
+ import { createSpinner } from '../cli-ui/spinner.js';
3
+ import { style } from '../cli-ui/style.js';
4
+ import { loadCliConfig, resolveEnv } from '../core/config.js';
5
+ import { KelviqHttpClient } from '../core/http.js';
6
+ import { fetchCatalog } from '../sync/fetch-catalog.js';
7
+ import { plural } from '../sync/render-plan.js';
8
+ /** Keeps one entry per plan identifier: the one marked `isLatest`, else the highest version. */
9
+ export function latestPlans(plans) {
10
+ const byIdentifier = new Map();
11
+ for (const plan of plans) {
12
+ const list = byIdentifier.get(plan.identifier) ?? [];
13
+ list.push(plan);
14
+ byIdentifier.set(plan.identifier, list);
15
+ }
16
+ const out = [];
17
+ for (const versions of byIdentifier.values()) {
18
+ const marked = versions.find((v) => v.isLatest === true);
19
+ out.push(marked ?? versions.reduce((best, v) => ((v.version ?? 0) > (best.version ?? 0) ? v : best)));
20
+ }
21
+ return out.sort((a, b) => a.identifier.localeCompare(b.identifier));
22
+ }
23
+ export function buildStatus(raw, environment) {
24
+ const productIdentifierByUuid = new Map(raw.products.map((p) => [p.id, p.identifier]));
25
+ const plans = latestPlans(raw.plans).map((plan) => {
26
+ const productRef = plan.product;
27
+ const product = typeof productRef === 'string'
28
+ ? (productIdentifierByUuid.get(productRef) ?? productRef)
29
+ : (productRef?.identifier ?? (productRef?.id ? productIdentifierByUuid.get(productRef.id) : undefined) ?? null);
30
+ const license = plan.license;
31
+ return {
32
+ identifier: plan.identifier,
33
+ name: plan.name,
34
+ product: product ?? null,
35
+ version: plan.version ?? null,
36
+ isLatest: plan.isLatest === true,
37
+ isVisible: plan.isVisible !== false,
38
+ prices: raw.planPrices[plan.identifier]?.length ?? 0,
39
+ entitlements: raw.planEntitlements[plan.identifier]?.length ?? 0,
40
+ licenseKeys: license?.enabled === true,
41
+ };
42
+ });
43
+ return {
44
+ environment,
45
+ products: raw.products.map((p) => ({ identifier: p.identifier, name: p.name })).sort((a, b) => a.identifier.localeCompare(b.identifier)),
46
+ features: raw.features
47
+ .map((f) => ({ identifier: f.identifier, name: f.name, type: String(f.featureType) }))
48
+ .sort((a, b) => a.identifier.localeCompare(b.identifier)),
49
+ plans,
50
+ };
51
+ }
52
+ function pad(value, width) {
53
+ return value.length >= width ? value : value + ' '.repeat(width - value.length);
54
+ }
55
+ export function renderStatus(doc) {
56
+ const lines = [`Environment : ${doc.environment}`, ''];
57
+ lines.push(`Products (${doc.products.length})`);
58
+ const productWidth = Math.max(0, ...doc.products.map((p) => p.identifier.length));
59
+ for (const p of doc.products)
60
+ lines.push(` ${pad(p.identifier, productWidth)} ${p.name}`);
61
+ lines.push('', `Features (${doc.features.length})`);
62
+ const featureWidth = Math.max(0, ...doc.features.map((f) => f.identifier.length));
63
+ for (const f of doc.features)
64
+ lines.push(` ${pad(f.identifier, featureWidth)} ${pad(f.type, 12)} ${f.name}`);
65
+ lines.push('', `Plans (${doc.plans.length})`);
66
+ const planWidth = Math.max(0, ...doc.plans.map((p) => p.identifier.length));
67
+ for (const p of doc.plans) {
68
+ const bits = [
69
+ `product ${p.product ?? '?'}`,
70
+ p.version === null ? 'version ?' : `v${p.version}${p.isLatest ? '' : ' (not latest)'}`,
71
+ p.prices === 0 ? style.fail('no prices') : plural(p.prices, 'price'),
72
+ plural(p.entitlements, 'entitlement'),
73
+ p.isVisible ? 'visible' : 'hidden',
74
+ ...(p.licenseKeys ? ['license keys'] : []),
75
+ ];
76
+ lines.push(` ${pad(p.identifier, planWidth)} ${pad(p.name, 20)} ${bits.join(' · ')}`);
77
+ }
78
+ return lines.join('\n') + '\n';
79
+ }
80
+ export async function runStatus(options, io) {
81
+ try {
82
+ const config = loadCliConfig(io.env ?? process.env, io.configDir);
83
+ const resolved = resolveEnv(config, Boolean(options.prod));
84
+ const http = new KelviqHttpClient({
85
+ serverApiKey: resolved.key,
86
+ baseUrl: resolved.baseUrl,
87
+ edgeUrl: resolved.edgeUrl,
88
+ userAgent: config.userAgent,
89
+ });
90
+ let raw;
91
+ if (options.json) {
92
+ raw = await fetchCatalog(http);
93
+ }
94
+ else {
95
+ const spinner = createSpinner(io.stderr);
96
+ spinner.start(`Fetching ${resolved.envName} catalog...`);
97
+ try {
98
+ raw = await fetchCatalog(http);
99
+ }
100
+ catch (err) {
101
+ spinner.stop();
102
+ throw err;
103
+ }
104
+ spinner.stop();
105
+ }
106
+ const doc = buildStatus(raw, resolved.envName);
107
+ io.stdout.write(options.json ? `${JSON.stringify(doc)}\n` : renderStatus(doc));
108
+ return 0;
109
+ }
110
+ catch (err) {
111
+ const message = err instanceof Error ? err.message : String(err);
112
+ if (options.json) {
113
+ io.stdout.write(`${JSON.stringify({ error: `status failed: ${message}` })}\n`);
114
+ }
115
+ else {
116
+ io.stderr.write(`status failed: ${message}\n`);
117
+ if (messageCarriesAuthStatus(message))
118
+ io.stderr.write(`${authHintLine()}\n`);
119
+ }
120
+ return 1;
121
+ }
122
+ }
123
+ export function registerStatusCommand(program) {
124
+ program
125
+ .command('status')
126
+ .description('Show the live catalog of an environment: products, features, and the latest version of each plan with its price and entitlement counts.')
127
+ .option('--prod', 'Read the production environment instead of sandbox', false)
128
+ .option('--json', 'Machine-readable output', false)
129
+ .action(async (opts) => {
130
+ process.exitCode = await runStatus(opts, { stdout: process.stdout, stderr: process.stderr });
131
+ });
132
+ }
133
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAkChD,gGAAgG;AAChG,MAAM,UAA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C,OAAO,CAAC;gBAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,EAAE,IAAI,CAAC,CAAC;QAChF,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,yIAAyI,CAAC;SACtJ,MAAM,CAAC,QAAQ,EAAE,oDAAoD,EAAE,KAAK,CAAC;SAC7E,MAAM,CAAC,QAAQ,EAAE,yBAAyB,EAAE,KAAK,CAAC;SAClD,MAAM,CAAC,KAAK,EAAE,IAAmB,EAAE,EAAE;QACpC,OAAO,CAAC,QAAQ,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/F,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { Command } from 'commander';
2
+ export declare const KNOWN_WEBHOOK_EVENTS: readonly string[];
3
+ export declare const DEFAULT_SECRET_VARIABLE = "KELVIQ_WEBHOOK_SECRET";
4
+ export interface ApiWebhookEndpoint {
5
+ id: string;
6
+ url: string;
7
+ enabled?: boolean;
8
+ events?: string[];
9
+ secret?: string;
10
+ }
11
+ export interface WebhookIO {
12
+ stdin: NodeJS.ReadableStream;
13
+ stdout: NodeJS.WritableStream;
14
+ stderr: NodeJS.WritableStream;
15
+ isTTY: boolean;
16
+ env?: NodeJS.ProcessEnv;
17
+ configDir?: string;
18
+ }
19
+ export interface WebhookListOptions {
20
+ prod?: boolean;
21
+ json?: boolean;
22
+ }
23
+ export interface WebhookAddOptions {
24
+ events?: string;
25
+ writeSecret?: string;
26
+ variable?: string;
27
+ printSecret?: boolean;
28
+ prod?: boolean;
29
+ yes?: boolean;
30
+ json?: boolean;
31
+ }
32
+ export declare function runWebhookList(options: WebhookListOptions, io: WebhookIO): Promise<number>;
33
+ export declare function parseEvents(raw: string | undefined): {
34
+ events: string[];
35
+ unknown: string[];
36
+ };
37
+ export declare function runWebhookAdd(url: string, options: WebhookAddOptions, io: WebhookIO): Promise<number>;
38
+ export declare function registerWebhookCommand(program: Command): void;