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.
- package/dist/commands/app.js +344 -316
- package/dist/commands/apps.js +83 -103
- package/dist/commands/checkout.js +156 -134
- package/dist/commands/config.js +126 -124
- package/dist/commands/diff.js +194 -169
- package/dist/commands/dimensions.js +122 -137
- package/dist/commands/files.js +77 -88
- package/dist/commands/install.js +77 -74
- package/dist/commands/list.js +74 -89
- package/dist/commands/login.js +101 -126
- package/dist/commands/logout.js +42 -57
- package/dist/commands/mcp-server.js +24 -39
- package/dist/commands/model.js +176 -184
- package/dist/commands/pull.js +276 -248
- package/dist/commands/push.js +222 -200
- package/dist/commands/run.js +322 -274
- package/dist/commands/status.js +170 -147
- package/dist/commands/variables.js +192 -168
- package/dist/commands/whoami.js +45 -61
- package/dist/index.js +115 -117
- package/dist/mcp/index.js +17 -33
- package/dist/mcp/prompts/workflows.js +146 -191
- package/dist/mcp/resources/documentation.js +149 -158
- package/dist/mcp/server.js +34 -50
- package/dist/mcp/tools/appTools.js +278 -307
- package/dist/mcp/tools/authTools.js +123 -130
- package/dist/mcp/tools/dataTools.js +271 -275
- package/dist/mcp/tools/modelTools.js +233 -265
- package/dist/mcp/tools/runTools.js +205 -199
- package/dist/mcp/tools/syncTools.js +315 -341
- package/dist/mcp/utils/helpers.js +124 -117
- package/dist/services/appSyncService.js +438 -379
- package/dist/services/configService.js +144 -154
- package/dist/services/farseerApi.js +401 -401
- package/dist/services/farseerFactory.js +274 -208
- package/dist/services/farseerService.js +488 -455
- package/dist/services/syncService.js +732 -657
- package/dist/utils/constants.js +20 -45
- package/dist/utils/helpers.js +366 -333
- package/dist/utils/logger.js +43 -74
- package/package.json +8 -1
- package/dist/commands/app.js.map +0 -7
- package/dist/commands/apps.js.map +0 -7
- package/dist/commands/checkout.js.map +0 -7
- package/dist/commands/config.js.map +0 -7
- package/dist/commands/diff.js.map +0 -7
- package/dist/commands/dimensions.js.map +0 -7
- package/dist/commands/files.js.map +0 -7
- package/dist/commands/install.js.map +0 -7
- package/dist/commands/list.js.map +0 -7
- package/dist/commands/login.js.map +0 -7
- package/dist/commands/logout.js.map +0 -7
- package/dist/commands/mcp-server.js.map +0 -7
- package/dist/commands/model.js.map +0 -7
- package/dist/commands/pull.js.map +0 -7
- package/dist/commands/push.js.map +0 -7
- package/dist/commands/run.js.map +0 -7
- package/dist/commands/status.js.map +0 -7
- package/dist/commands/variables.js.map +0 -7
- package/dist/commands/whoami.js.map +0 -7
- package/dist/index.js.map +0 -7
- package/dist/mcp/index.js.map +0 -7
- package/dist/mcp/prompts/workflows.js.map +0 -7
- package/dist/mcp/resources/documentation.js.map +0 -7
- package/dist/mcp/server.js.map +0 -7
- package/dist/mcp/tools/appTools.js.map +0 -7
- package/dist/mcp/tools/authTools.js.map +0 -7
- package/dist/mcp/tools/dataTools.js.map +0 -7
- package/dist/mcp/tools/modelTools.js.map +0 -7
- package/dist/mcp/tools/runTools.js.map +0 -7
- package/dist/mcp/tools/syncTools.js.map +0 -7
- package/dist/mcp/utils/helpers.js.map +0 -7
- package/dist/services/appSyncService.js.map +0 -7
- package/dist/services/configService.js.map +0 -7
- package/dist/services/farseerApi.js.map +0 -7
- package/dist/services/farseerFactory.js.map +0 -7
- package/dist/services/farseerService.js.map +0 -7
- package/dist/services/syncService.js.map +0 -7
- package/dist/utils/constants.js.map +0 -7
- package/dist/utils/helpers.js.map +0 -7
- package/dist/utils/logger.js.map +0 -7
|
@@ -1,176 +1,200 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
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
|
-
|
|
135
|
-
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
package/dist/commands/whoami.js
CHANGED
|
@@ -1,63 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|