farseer-cli 1.0.9 → 1.0.10

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.
Files changed (81) hide show
  1. package/dist/commands/app.js +344 -316
  2. package/dist/commands/apps.js +83 -103
  3. package/dist/commands/checkout.js +156 -134
  4. package/dist/commands/config.js +126 -124
  5. package/dist/commands/diff.js +194 -169
  6. package/dist/commands/dimensions.js +122 -137
  7. package/dist/commands/files.js +77 -88
  8. package/dist/commands/install.js +77 -74
  9. package/dist/commands/list.js +74 -89
  10. package/dist/commands/login.js +101 -126
  11. package/dist/commands/logout.js +42 -57
  12. package/dist/commands/mcp-server.js +24 -39
  13. package/dist/commands/model.js +176 -184
  14. package/dist/commands/pull.js +276 -248
  15. package/dist/commands/push.js +222 -200
  16. package/dist/commands/run.js +322 -274
  17. package/dist/commands/status.js +170 -147
  18. package/dist/commands/variables.js +192 -168
  19. package/dist/commands/whoami.js +45 -61
  20. package/dist/index.js +115 -117
  21. package/dist/mcp/index.js +17 -33
  22. package/dist/mcp/prompts/workflows.js +146 -191
  23. package/dist/mcp/resources/documentation.js +149 -158
  24. package/dist/mcp/server.js +34 -50
  25. package/dist/mcp/tools/appTools.js +278 -307
  26. package/dist/mcp/tools/authTools.js +123 -130
  27. package/dist/mcp/tools/dataTools.js +271 -275
  28. package/dist/mcp/tools/modelTools.js +233 -265
  29. package/dist/mcp/tools/runTools.js +205 -199
  30. package/dist/mcp/tools/syncTools.js +315 -341
  31. package/dist/mcp/utils/helpers.js +124 -117
  32. package/dist/services/appSyncService.js +438 -379
  33. package/dist/services/configService.js +144 -154
  34. package/dist/services/farseerApi.js +401 -401
  35. package/dist/services/farseerFactory.js +274 -208
  36. package/dist/services/farseerService.js +488 -455
  37. package/dist/services/syncService.js +732 -657
  38. package/dist/utils/constants.js +20 -45
  39. package/dist/utils/helpers.js +366 -333
  40. package/dist/utils/logger.js +43 -74
  41. package/package.json +8 -1
  42. package/dist/commands/app.js.map +0 -7
  43. package/dist/commands/apps.js.map +0 -7
  44. package/dist/commands/checkout.js.map +0 -7
  45. package/dist/commands/config.js.map +0 -7
  46. package/dist/commands/diff.js.map +0 -7
  47. package/dist/commands/dimensions.js.map +0 -7
  48. package/dist/commands/files.js.map +0 -7
  49. package/dist/commands/install.js.map +0 -7
  50. package/dist/commands/list.js.map +0 -7
  51. package/dist/commands/login.js.map +0 -7
  52. package/dist/commands/logout.js.map +0 -7
  53. package/dist/commands/mcp-server.js.map +0 -7
  54. package/dist/commands/model.js.map +0 -7
  55. package/dist/commands/pull.js.map +0 -7
  56. package/dist/commands/push.js.map +0 -7
  57. package/dist/commands/run.js.map +0 -7
  58. package/dist/commands/status.js.map +0 -7
  59. package/dist/commands/variables.js.map +0 -7
  60. package/dist/commands/whoami.js.map +0 -7
  61. package/dist/index.js.map +0 -7
  62. package/dist/mcp/index.js.map +0 -7
  63. package/dist/mcp/prompts/workflows.js.map +0 -7
  64. package/dist/mcp/resources/documentation.js.map +0 -7
  65. package/dist/mcp/server.js.map +0 -7
  66. package/dist/mcp/tools/appTools.js.map +0 -7
  67. package/dist/mcp/tools/authTools.js.map +0 -7
  68. package/dist/mcp/tools/dataTools.js.map +0 -7
  69. package/dist/mcp/tools/modelTools.js.map +0 -7
  70. package/dist/mcp/tools/runTools.js.map +0 -7
  71. package/dist/mcp/tools/syncTools.js.map +0 -7
  72. package/dist/mcp/utils/helpers.js.map +0 -7
  73. package/dist/services/appSyncService.js.map +0 -7
  74. package/dist/services/configService.js.map +0 -7
  75. package/dist/services/farseerApi.js.map +0 -7
  76. package/dist/services/farseerFactory.js.map +0 -7
  77. package/dist/services/farseerService.js.map +0 -7
  78. package/dist/services/syncService.js.map +0 -7
  79. package/dist/utils/constants.js.map +0 -7
  80. package/dist/utils/helpers.js.map +0 -7
  81. package/dist/utils/logger.js.map +0 -7
@@ -1,176 +1,200 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var variables_exports = {};
29
- __export(variables_exports, {
30
- registerVariablesCommand: () => registerVariablesCommand
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
31
17
  });
32
- module.exports = __toCommonJS(variables_exports);
33
- var fs = __toESM(require("fs"));
34
- var import_chalk = __toESM(require("chalk"));
35
- var import_logger = require("../utils/logger");
36
- var import_farseerFactory = require("../services/farseerFactory");
37
- var import_helpers = require("../utils/helpers");
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.registerVariablesCommand = registerVariablesCommand;
40
+ const fs = __importStar(require("fs"));
41
+ const chalk_1 = __importDefault(require("chalk"));
42
+ const logger_1 = require("../utils/logger");
43
+ const farseerFactory_1 = require("../services/farseerFactory");
44
+ const helpers_1 = require("../utils/helpers");
38
45
  function registerVariablesCommand(program) {
39
- const variablesCmd = program.command("variables").description("List and manage variables");
40
- variablesCmd.command("list [org] [tenant]").description("List all variables").option("--json", "Output raw JSON").action(async (first, second, options) => {
41
- const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(first, second);
42
- const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
43
- if (!result) {
44
- (0, import_farseerFactory.showLoginPrompt)(tenant);
45
- process.exit(1);
46
- }
47
- try {
48
- const model = await result.client.exportModel();
49
- if (options.json) {
50
- console.log(JSON.stringify(model.variables, null, 2));
51
- return;
52
- }
53
- import_logger.logger.header(`Variables (${model.variables.length})`);
54
- console.log();
55
- for (const variable of model.variables) {
56
- const flags = [];
57
- if (variable.readonly) flags.push("readonly");
58
- if (variable.calculateOnDemand) flags.push("on-demand");
59
- const flagStr = flags.length > 0 ? import_chalk.default.dim(` [${flags.join(", ")}]`) : "";
60
- console.log(` ${import_chalk.default.bold(variable.name)}${flagStr}`);
61
- console.log(` Dimensions: ${variable.tables.join(", ")}`);
62
- console.log(` Rollup: ${variable.rollupType} | Type: ${variable.dataType}`);
63
- if (variable.formula) {
64
- console.log(` Formula: ${import_chalk.default.dim(variable.formula.substring(0, 80))}${variable.formula.length > 80 ? "..." : ""}`);
46
+ // farseer variables list
47
+ const variablesCmd = program.command('variables').description('List and manage variables');
48
+ variablesCmd
49
+ .command('list [org] [tenant]')
50
+ .description('List all variables')
51
+ .option('--json', 'Output raw JSON')
52
+ .action(async (first, second, options) => {
53
+ const { organisation, tenant } = (0, helpers_1.resolveTenantWithOrgMapping)(first, second);
54
+ const result = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
55
+ if (!result) {
56
+ (0, farseerFactory_1.showLoginPrompt)(tenant);
57
+ process.exit(1);
65
58
  }
66
- console.log();
67
- }
68
- } catch (error) {
69
- handleModelError(error, tenant);
70
- }
71
- });
72
- const variableCmd = program.command("variable").description("Variable details and export");
73
- variableCmd.command("details <name>").description("Show variable details (dimensions, formula, rollup, etc.)").option("--json", "Output raw JSON").action(async (name, options) => {
74
- const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)();
75
- const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
76
- if (!result) {
77
- (0, import_farseerFactory.showLoginPrompt)(tenant);
78
- process.exit(1);
79
- }
80
- try {
81
- const model = await result.client.exportModel();
82
- const variable = model.variables.find(
83
- (v) => v.name.toLowerCase() === name.toLowerCase()
84
- );
85
- if (!variable) {
86
- import_logger.logger.error(`Variable "${name}" not found.`);
87
- import_logger.logger.dim("Available variables:");
88
- model.variables.slice(0, 10).forEach((v) => import_logger.logger.dim(` - ${v.name}`));
89
- if (model.variables.length > 10) {
90
- import_logger.logger.dim(` ... and ${model.variables.length - 10} more`);
59
+ try {
60
+ const model = await result.client.exportModel();
61
+ if (options.json) {
62
+ console.log(JSON.stringify(model.variables, null, 2));
63
+ return;
64
+ }
65
+ logger_1.logger.header(`Variables (${model.variables.length})`);
66
+ console.log();
67
+ for (const variable of model.variables) {
68
+ const flags = [];
69
+ if (variable.readonly)
70
+ flags.push('readonly');
71
+ if (variable.calculateOnDemand)
72
+ flags.push('on-demand');
73
+ const flagStr = flags.length > 0 ? chalk_1.default.dim(` [${flags.join(', ')}]`) : '';
74
+ console.log(` ${chalk_1.default.bold(variable.name)}${flagStr}`);
75
+ console.log(` Dimensions: ${variable.tables.join(', ')}`);
76
+ console.log(` Rollup: ${variable.rollupType} | Type: ${variable.dataType}`);
77
+ if (variable.formula) {
78
+ console.log(` Formula: ${chalk_1.default.dim(variable.formula.substring(0, 80))}${variable.formula.length > 80 ? '...' : ''}`);
79
+ }
80
+ console.log();
81
+ }
82
+ }
83
+ catch (error) {
84
+ handleModelError(error, tenant);
85
+ }
86
+ });
87
+ // farseer variable details / export (singular)
88
+ const variableCmd = program.command('variable').description('Variable details and export');
89
+ variableCmd
90
+ .command('details <name>')
91
+ .description('Show variable details (dimensions, formula, rollup, etc.)')
92
+ .option('--json', 'Output raw JSON')
93
+ .action(async (name, options) => {
94
+ const { organisation, tenant } = (0, helpers_1.resolveTenantWithOrgMapping)();
95
+ const result = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
96
+ if (!result) {
97
+ (0, farseerFactory_1.showLoginPrompt)(tenant);
98
+ process.exit(1);
99
+ }
100
+ try {
101
+ const model = await result.client.exportModel();
102
+ const variable = model.variables.find((v) => v.name.toLowerCase() === name.toLowerCase());
103
+ if (!variable) {
104
+ logger_1.logger.error(`Variable "${name}" not found.`);
105
+ logger_1.logger.dim('Available variables:');
106
+ model.variables.slice(0, 10).forEach((v) => logger_1.logger.dim(` - ${v.name}`));
107
+ if (model.variables.length > 10) {
108
+ logger_1.logger.dim(` ... and ${model.variables.length - 10} more`);
109
+ }
110
+ process.exit(1);
111
+ }
112
+ if (options.json) {
113
+ console.log(JSON.stringify(variable, null, 2));
114
+ return;
115
+ }
116
+ logger_1.logger.header(`Variable: ${variable.name}`);
117
+ console.log();
118
+ if (variable.description) {
119
+ console.log(` Description: ${variable.description}`);
120
+ }
121
+ if (variable.formula) {
122
+ console.log(` Formula: ${variable.formula}`);
123
+ }
124
+ console.log(` Dimensions: ${variable.tables.join(', ')}`);
125
+ if (variable.members.length > 0) {
126
+ console.log(` Specific members: ${variable.members.join(', ')}`);
127
+ }
128
+ console.log(` Roll-up type: ${variable.rollupType}`);
129
+ console.log(` Data type: ${variable.dataType}`);
130
+ if (variable.numberFormat) {
131
+ console.log(` Format: ${variable.numberFormat.type}${variable.numberFormat.formatString ? ` (${variable.numberFormat.formatString})` : ''}`);
132
+ }
133
+ console.log(` Readonly: ${variable.readonly}`);
134
+ console.log(` Calculate on demand: ${variable.calculateOnDemand}`);
135
+ if (variable.folderPath) {
136
+ console.log(` Folder: ${variable.folderPath.join(' / ')}`);
137
+ }
138
+ if (variable.cells && variable.cells.length > 0) {
139
+ console.log(` Cells with data: ${variable.cells.length}`);
140
+ }
91
141
  }
92
- process.exit(1);
93
- }
94
- if (options.json) {
95
- console.log(JSON.stringify(variable, null, 2));
96
- return;
97
- }
98
- import_logger.logger.header(`Variable: ${variable.name}`);
99
- console.log();
100
- if (variable.description) {
101
- console.log(` Description: ${variable.description}`);
102
- }
103
- if (variable.formula) {
104
- console.log(` Formula: ${variable.formula}`);
105
- }
106
- console.log(` Dimensions: ${variable.tables.join(", ")}`);
107
- if (variable.members.length > 0) {
108
- console.log(` Specific members: ${variable.members.join(", ")}`);
109
- }
110
- console.log(` Roll-up type: ${variable.rollupType}`);
111
- console.log(` Data type: ${variable.dataType}`);
112
- if (variable.numberFormat) {
113
- console.log(` Format: ${variable.numberFormat.type}${variable.numberFormat.formatString ? ` (${variable.numberFormat.formatString})` : ""}`);
114
- }
115
- console.log(` Readonly: ${variable.readonly}`);
116
- console.log(` Calculate on demand: ${variable.calculateOnDemand}`);
117
- if (variable.folderPath) {
118
- console.log(` Folder: ${variable.folderPath.join(" / ")}`);
119
- }
120
- if (variable.cells && variable.cells.length > 0) {
121
- console.log(` Cells with data: ${variable.cells.length}`);
122
- }
123
- } catch (error) {
124
- handleModelError(error, tenant);
142
+ catch (error) {
143
+ handleModelError(error, tenant);
144
+ }
145
+ });
146
+ variableCmd
147
+ .command('export <name>')
148
+ .description('Export variable data to CSV file')
149
+ .option('--output <file>', 'Output file path')
150
+ .option('--format <format>', 'Output format: csv, json, xlsx', 'csv')
151
+ .option('--limit <n>', 'Limit number of rows', parseInt)
152
+ .action(async (name, options) => {
153
+ const { organisation, tenant } = (0, helpers_1.resolveTenantWithOrgMapping)();
154
+ const nativeClient = await (0, farseerFactory_1.getNativeFarseerClient)(organisation, tenant);
155
+ if (!nativeClient) {
156
+ (0, farseerFactory_1.showLoginPrompt)(tenant);
157
+ process.exit(1);
158
+ }
159
+ try {
160
+ logger_1.logger.info(`Exporting variable "${name}" from ${tenant}...`);
161
+ const exportRequest = {
162
+ formula: name,
163
+ format: options.format || 'csv',
164
+ };
165
+ if (options.limit) {
166
+ exportRequest.limit = options.limit;
167
+ }
168
+ const blob = await nativeClient.export.exportFormula(exportRequest);
169
+ const content = await blob.text();
170
+ const outputFile = options.output || `${name.replace(/[^a-zA-Z0-9_-]/g, '_')}.${options.format || 'csv'}`;
171
+ fs.writeFileSync(outputFile, content, 'utf-8');
172
+ logger_1.logger.success(`Exported to ${outputFile}`);
173
+ const lines = content.split('\n').filter((l) => l.trim()).length;
174
+ logger_1.logger.dim(`${lines - 1} data rows`);
175
+ }
176
+ catch (error) {
177
+ const errorMessage = error instanceof Error ? error.message : String(error);
178
+ logger_1.logger.error(`Failed to export variable "${name}".`);
179
+ logger_1.logger.dim(errorMessage);
180
+ process.exit(1);
181
+ }
182
+ });
183
+ }
184
+ function handleModelError(error, tenant) {
185
+ const errorMessage = error instanceof Error ? error.message : String(error);
186
+ if ((0, farseerFactory_1.isAuthError)(error)) {
187
+ (0, farseerFactory_1.showLoginPrompt)(tenant);
125
188
  }
126
- });
127
- variableCmd.command("export <name>").description("Export variable data to CSV file").option("--output <file>", "Output file path").option("--format <format>", "Output format: csv, json, xlsx", "csv").option("--limit <n>", "Limit number of rows", parseInt).action(async (name, options) => {
128
- const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)();
129
- const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
130
- if (!nativeClient) {
131
- (0, import_farseerFactory.showLoginPrompt)(tenant);
132
- process.exit(1);
189
+ else if (errorMessage.includes('404')) {
190
+ logger_1.logger.error(`Tenant "${tenant}" not found or not accessible.`);
133
191
  }
134
- try {
135
- import_logger.logger.info(`Exporting variable "${name}" from ${tenant}...`);
136
- const exportRequest = {
137
- formula: name,
138
- format: options.format || "csv"
139
- };
140
- if (options.limit) {
141
- exportRequest.limit = options.limit;
142
- }
143
- const blob = await nativeClient.export.exportFormula(exportRequest);
144
- const content = await blob.text();
145
- const outputFile = options.output || `${name.replace(/[^a-zA-Z0-9_-]/g, "_")}.${options.format || "csv"}`;
146
- fs.writeFileSync(outputFile, content, "utf-8");
147
- import_logger.logger.success(`Exported to ${outputFile}`);
148
- const lines = content.split("\n").filter((l) => l.trim()).length;
149
- import_logger.logger.dim(`${lines - 1} data rows`);
150
- } catch (error) {
151
- const errorMessage = error instanceof Error ? error.message : String(error);
152
- import_logger.logger.error(`Failed to export variable "${name}".`);
153
- import_logger.logger.dim(errorMessage);
154
- process.exit(1);
192
+ else if (errorMessage.includes('ENOTFOUND') || errorMessage.includes('ECONNREFUSED')) {
193
+ logger_1.logger.error('Failed to connect to Farseer.');
155
194
  }
156
- });
157
- }
158
- function handleModelError(error, tenant) {
159
- const errorMessage = error instanceof Error ? error.message : String(error);
160
- if ((0, import_farseerFactory.isAuthError)(error)) {
161
- (0, import_farseerFactory.showLoginPrompt)(tenant);
162
- } else if (errorMessage.includes("404")) {
163
- import_logger.logger.error(`Tenant "${tenant}" not found or not accessible.`);
164
- } else if (errorMessage.includes("ENOTFOUND") || errorMessage.includes("ECONNREFUSED")) {
165
- import_logger.logger.error("Failed to connect to Farseer.");
166
- } else {
167
- import_logger.logger.error("Failed to fetch model.");
168
- import_logger.logger.dim(errorMessage);
169
- }
170
- process.exit(1);
195
+ else {
196
+ logger_1.logger.error('Failed to fetch model.');
197
+ logger_1.logger.dim(errorMessage);
198
+ }
199
+ process.exit(1);
171
200
  }
172
- // Annotate the CommonJS export names for ESM import in node:
173
- 0 && (module.exports = {
174
- registerVariablesCommand
175
- });
176
- //# sourceMappingURL=variables.js.map
@@ -1,63 +1,47 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var whoami_exports = {};
19
- __export(whoami_exports, {
20
- registerWhoamiCommand: () => registerWhoamiCommand
21
- });
22
- module.exports = __toCommonJS(whoami_exports);
23
- var import_logger = require("../utils/logger");
24
- var import_configService = require("../services/configService");
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerWhoamiCommand = registerWhoamiCommand;
4
+ const logger_1 = require("../utils/logger");
5
+ const configService_1 = require("../services/configService");
25
6
  function registerWhoamiCommand(program) {
26
- program.command("whoami").description("Show current login status and configured tenants").action(async () => {
27
- import_logger.logger.header("Farseer Status");
28
- const userAuth = (0, import_configService.getUserAuth)();
29
- if (userAuth) {
30
- if ((0, import_configService.isUserAuthValid)()) {
31
- const expiresAt = new Date(userAuth.expiresAt);
32
- import_logger.logger.success("Logged in via browser");
33
- import_logger.logger.dim(`Token expires: ${expiresAt.toLocaleString()}`);
34
- } else {
35
- import_logger.logger.warning("Browser login expired");
36
- import_logger.logger.dim("Run: farseer login");
37
- }
38
- } else {
39
- import_logger.logger.dim("Not logged in via browser");
40
- }
41
- console.log();
42
- const credentials = (0, import_configService.listCredentials)();
43
- const tenants = Object.keys(credentials);
44
- if (tenants.length > 0) {
45
- import_logger.logger.info(`Configured tenants (${tenants.length}):`);
46
- for (const tenant of tenants) {
47
- const cred = credentials[tenant];
48
- const keyPreview = cred.apiKey.substring(0, 8) + "...";
49
- console.log(` ${tenant}`);
50
- console.log(` Base: ${cred.basePath}`);
51
- console.log(` Key: ${keyPreview}`);
52
- }
53
- } else {
54
- import_logger.logger.dim("No tenants configured");
55
- import_logger.logger.dim("Run: farseer config set <tenant> --api-key <key>");
56
- }
57
- });
7
+ program
8
+ .command('whoami')
9
+ .description('Show current login status and configured tenants')
10
+ .action(async () => {
11
+ logger_1.logger.header('Farseer Status');
12
+ // Check user auth (browser login)
13
+ const userAuth = (0, configService_1.getUserAuth)();
14
+ if (userAuth) {
15
+ if ((0, configService_1.isUserAuthValid)()) {
16
+ const expiresAt = new Date(userAuth.expiresAt);
17
+ logger_1.logger.success('Logged in via browser');
18
+ logger_1.logger.dim(`Token expires: ${expiresAt.toLocaleString()}`);
19
+ }
20
+ else {
21
+ logger_1.logger.warning('Browser login expired');
22
+ logger_1.logger.dim('Run: farseer login');
23
+ }
24
+ }
25
+ else {
26
+ logger_1.logger.dim('Not logged in via browser');
27
+ }
28
+ console.log();
29
+ // List configured tenants (API key)
30
+ const credentials = (0, configService_1.listCredentials)();
31
+ const tenants = Object.keys(credentials);
32
+ if (tenants.length > 0) {
33
+ logger_1.logger.info(`Configured tenants (${tenants.length}):`);
34
+ for (const tenant of tenants) {
35
+ const cred = credentials[tenant];
36
+ const keyPreview = cred.apiKey.substring(0, 8) + '...';
37
+ console.log(` ${tenant}`);
38
+ console.log(` Base: ${cred.basePath}`);
39
+ console.log(` Key: ${keyPreview}`);
40
+ }
41
+ }
42
+ else {
43
+ logger_1.logger.dim('No tenants configured');
44
+ logger_1.logger.dim('Run: farseer config set <tenant> --api-key <key>');
45
+ }
46
+ });
58
47
  }
59
- // Annotate the CommonJS export names for ESM import in node:
60
- 0 && (module.exports = {
61
- registerWhoamiCommand
62
- });
63
- //# sourceMappingURL=whoami.js.map