farseer-cli 1.0.8 → 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 +377 -0
- package/dist/commands/apps.js +91 -0
- package/dist/commands/checkout.js +164 -0
- package/dist/commands/config.js +141 -0
- package/dist/commands/diff.js +210 -0
- package/dist/commands/dimensions.js +130 -0
- package/dist/commands/files.js +88 -0
- package/dist/commands/install.js +82 -0
- package/dist/commands/list.js +77 -0
- package/dist/commands/login.js +109 -0
- package/dist/commands/logout.js +44 -0
- package/dist/commands/mcp-server.js +26 -0
- package/dist/commands/model.js +181 -0
- package/dist/commands/pull.js +286 -0
- package/dist/commands/push.js +235 -0
- package/dist/commands/run.js +336 -0
- package/dist/commands/status.js +178 -0
- package/dist/commands/variables.js +200 -0
- package/dist/commands/whoami.js +47 -0
- package/dist/index.js +163 -0
- package/dist/mcp/index.js +19 -0
- package/dist/mcp/prompts/workflows.js +403 -0
- package/dist/mcp/resources/documentation.js +158 -0
- package/dist/mcp/server.js +36 -0
- package/dist/mcp/tools/appTools.js +348 -0
- package/dist/mcp/tools/authTools.js +152 -0
- package/dist/mcp/tools/dataTools.js +358 -0
- package/dist/mcp/tools/modelTools.js +293 -0
- package/dist/mcp/tools/runTools.js +239 -0
- package/dist/mcp/tools/syncTools.js +383 -0
- package/dist/mcp/utils/helpers.js +142 -0
- package/dist/services/appSyncService.js +458 -0
- package/dist/services/configService.js +186 -0
- package/dist/services/farseerApi.js +426 -0
- package/dist/services/farseerFactory.js +297 -0
- package/dist/services/farseerService.js +647 -0
- package/dist/services/syncService.js +764 -0
- package/dist/utils/constants.js +21 -0
- package/dist/utils/helpers.js +446 -0
- package/dist/utils/logger.js +45 -0
- package/package.json +8 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerListCommand = registerListCommand;
|
|
4
|
+
const logger_1 = require("../utils/logger");
|
|
5
|
+
const farseerFactory_1 = require("../services/farseerFactory");
|
|
6
|
+
const helpers_1 = require("../utils/helpers");
|
|
7
|
+
function registerListCommand(program) {
|
|
8
|
+
program
|
|
9
|
+
.command('list [arg1] [arg2]')
|
|
10
|
+
.description('[DEPRECATED] Use "farseer files list" instead')
|
|
11
|
+
.option('--all', 'List all files (default: only scripts .ts, .js)')
|
|
12
|
+
.action(async (arg1, arg2, options) => {
|
|
13
|
+
logger_1.logger.warning('Deprecation: "farseer list" is deprecated. Use "farseer files list" instead.');
|
|
14
|
+
console.log();
|
|
15
|
+
const { organisation, tenant } = (0, helpers_1.resolveTenantWithOrgMapping)(arg1, arg2);
|
|
16
|
+
const result = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
|
|
17
|
+
if (!result) {
|
|
18
|
+
(0, farseerFactory_1.showLoginPrompt)(tenant);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
const authLabel = result.authType === 'apiKey' ? 'API key' : 'browser login';
|
|
22
|
+
logger_1.logger.info(`Fetching files from ${tenant} (using ${authLabel})...`);
|
|
23
|
+
let files;
|
|
24
|
+
try {
|
|
25
|
+
files = await result.client.listFiles();
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if ((0, farseerFactory_1.isAuthError)(error)) {
|
|
29
|
+
(0, farseerFactory_1.showLoginPrompt)(tenant);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
logger_1.logger.error('Failed to list files.');
|
|
33
|
+
if (error instanceof Error) {
|
|
34
|
+
logger_1.logger.dim(error.message);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
// Filter to scripts only unless --all is specified
|
|
40
|
+
if (!options.all) {
|
|
41
|
+
files = files.filter((f) => farseerFactory_1.DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.name.toLowerCase().endsWith(ext)));
|
|
42
|
+
}
|
|
43
|
+
if (files.length === 0) {
|
|
44
|
+
logger_1.logger.warning('No files found in Files/');
|
|
45
|
+
logger_1.logger.dim(options.all
|
|
46
|
+
? 'The folder might be empty or does not exist.'
|
|
47
|
+
: 'No script files (.ts, .js) found. Use --all to see all files.');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
logger_1.logger.header(`Files on ${tenant} (Files/)`);
|
|
51
|
+
// Group by directory
|
|
52
|
+
const grouped = {};
|
|
53
|
+
for (const file of files) {
|
|
54
|
+
const parts = file.path.split('/');
|
|
55
|
+
const fileName = parts.pop();
|
|
56
|
+
const dir = parts.length > 0 ? parts.join('/') + '/' : '';
|
|
57
|
+
if (!grouped[dir]) {
|
|
58
|
+
grouped[dir] = [];
|
|
59
|
+
}
|
|
60
|
+
grouped[dir].push(fileName);
|
|
61
|
+
}
|
|
62
|
+
// Sort directories
|
|
63
|
+
const dirs = Object.keys(grouped).sort();
|
|
64
|
+
for (const dir of dirs) {
|
|
65
|
+
if (dir) {
|
|
66
|
+
console.log(` ${dir}`);
|
|
67
|
+
}
|
|
68
|
+
const dirFiles = grouped[dir].sort();
|
|
69
|
+
for (const file of dirFiles) {
|
|
70
|
+
const prefix = dir ? ' ' : ' ';
|
|
71
|
+
console.log(`${prefix}${file}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
console.log();
|
|
75
|
+
logger_1.logger.dim(`Total: ${files.length} file(s)`);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerLoginCommand = registerLoginCommand;
|
|
7
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
|
+
const logger_1 = require("../utils/logger");
|
|
9
|
+
const configService_1 = require("../services/configService");
|
|
10
|
+
const farseerService_1 = require("../services/farseerService");
|
|
11
|
+
function registerLoginCommand(program) {
|
|
12
|
+
program
|
|
13
|
+
.command('login')
|
|
14
|
+
.description('Login to Farseer (opens browser or use --api-key)')
|
|
15
|
+
.option('--api-key', 'Login using API key instead of browser')
|
|
16
|
+
.option('--realm <realm>', 'Keycloak realm to use (default: master)')
|
|
17
|
+
.action(async (options) => {
|
|
18
|
+
if (options.apiKey) {
|
|
19
|
+
await loginWithApiKey();
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
await loginViaBrowser(options.realm);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async function loginViaBrowser(realm) {
|
|
27
|
+
const realmToUse = realm || 'master';
|
|
28
|
+
logger_1.logger.header('Farseer Login');
|
|
29
|
+
if (realm) {
|
|
30
|
+
logger_1.logger.info(`Using realm: ${realmToUse}`);
|
|
31
|
+
}
|
|
32
|
+
logger_1.logger.info('Opening browser for login...');
|
|
33
|
+
logger_1.logger.dim('Waiting for authentication (timeout: 5 minutes)...');
|
|
34
|
+
const result = await (0, farseerService_1.loginWithBrowser)(realmToUse);
|
|
35
|
+
if (!result) {
|
|
36
|
+
logger_1.logger.error('Login failed or timed out.');
|
|
37
|
+
logger_1.logger.dim('Try using --api-key for manual API key login.');
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
const expiresAt = new Date(Date.now() + result.expiresIn * 1000);
|
|
41
|
+
(0, configService_1.setUserAuth)({
|
|
42
|
+
accessToken: result.accessToken,
|
|
43
|
+
refreshToken: result.refreshToken,
|
|
44
|
+
expiresAt: expiresAt.toISOString(),
|
|
45
|
+
realm: realmToUse,
|
|
46
|
+
});
|
|
47
|
+
logger_1.logger.success('Login successful!');
|
|
48
|
+
logger_1.logger.dim(`Token expires at: ${expiresAt.toLocaleString()}`);
|
|
49
|
+
if (realm) {
|
|
50
|
+
logger_1.logger.dim(`Realm: ${realmToUse}`);
|
|
51
|
+
}
|
|
52
|
+
logger_1.logger.dim('You can now access any tenant you have permissions for.');
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
async function loginWithApiKey() {
|
|
56
|
+
logger_1.logger.header('Farseer Login (API Key)');
|
|
57
|
+
const answers = await inquirer_1.default.prompt([
|
|
58
|
+
{
|
|
59
|
+
type: 'input',
|
|
60
|
+
name: 'tenant',
|
|
61
|
+
message: 'Tenant ID (e.g., tthotels):',
|
|
62
|
+
validate: (input) => {
|
|
63
|
+
if (!input || input.trim() === '') {
|
|
64
|
+
return 'Tenant ID is required';
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: 'input',
|
|
71
|
+
name: 'organisation',
|
|
72
|
+
message: 'Organisation (leave empty if same as tenant):',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
type: 'password',
|
|
76
|
+
name: 'apiKey',
|
|
77
|
+
message: 'API Key:',
|
|
78
|
+
mask: '*',
|
|
79
|
+
validate: (input) => {
|
|
80
|
+
if (!input || input.trim() === '') {
|
|
81
|
+
return 'API Key is required';
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
]);
|
|
87
|
+
const tenant = answers.tenant.trim();
|
|
88
|
+
const organisation = answers.organisation.trim() || tenant;
|
|
89
|
+
const apiKey = answers.apiKey.trim();
|
|
90
|
+
const basePath = (0, configService_1.generateBasePath)(organisation);
|
|
91
|
+
logger_1.logger.info('Testing connection...');
|
|
92
|
+
const credential = {
|
|
93
|
+
type: 'apiKey',
|
|
94
|
+
tenantId: tenant,
|
|
95
|
+
apiKey: apiKey,
|
|
96
|
+
basePath: basePath,
|
|
97
|
+
};
|
|
98
|
+
const service = new farseerService_1.FarseerService(credential);
|
|
99
|
+
const isConnected = await service.testConnection();
|
|
100
|
+
if (!isConnected) {
|
|
101
|
+
logger_1.logger.error('Connection failed. Please check your credentials.');
|
|
102
|
+
logger_1.logger.dim(`Tried to connect to: ${basePath}`);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
(0, configService_1.setCredential)(tenant, credential);
|
|
106
|
+
logger_1.logger.success(`Successfully connected to ${tenant}!`);
|
|
107
|
+
logger_1.logger.dim(`Credentials saved for tenant: ${tenant}`);
|
|
108
|
+
logger_1.logger.dim(`Base path: ${basePath}`);
|
|
109
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerLogoutCommand = registerLogoutCommand;
|
|
4
|
+
const logger_1 = require("../utils/logger");
|
|
5
|
+
const configService_1 = require("../services/configService");
|
|
6
|
+
function registerLogoutCommand(program) {
|
|
7
|
+
program
|
|
8
|
+
.command('logout [tenant]')
|
|
9
|
+
.description('Logout from Farseer (remove credentials)')
|
|
10
|
+
.option('--all', 'Remove all credentials')
|
|
11
|
+
.action(async (tenant, options) => {
|
|
12
|
+
if (options.all) {
|
|
13
|
+
// Remove all credentials
|
|
14
|
+
const credentials = (0, configService_1.listCredentials)();
|
|
15
|
+
const tenants = Object.keys(credentials);
|
|
16
|
+
if (tenants.length === 0) {
|
|
17
|
+
logger_1.logger.info('No credentials stored.');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
for (const t of tenants) {
|
|
21
|
+
(0, configService_1.removeCredential)(t);
|
|
22
|
+
}
|
|
23
|
+
(0, configService_1.clearUserAuth)();
|
|
24
|
+
logger_1.logger.success(`Removed credentials for ${tenants.length} tenant(s).`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (tenant) {
|
|
28
|
+
// Remove specific tenant
|
|
29
|
+
const removed = (0, configService_1.removeCredential)(tenant);
|
|
30
|
+
if (removed) {
|
|
31
|
+
logger_1.logger.success(`Removed credentials for tenant: ${tenant}`);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
logger_1.logger.warning(`No credentials found for tenant: ${tenant}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// Remove user auth token
|
|
39
|
+
(0, configService_1.clearUserAuth)();
|
|
40
|
+
logger_1.logger.success('Logged out (user token cleared).');
|
|
41
|
+
logger_1.logger.dim('API key credentials are still stored. Use "farseer logout <tenant>" to remove specific ones.');
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP Server Command
|
|
4
|
+
*
|
|
5
|
+
* Starts the Farseer MCP (Model Context Protocol) server for AI assistant integration.
|
|
6
|
+
* This allows Claude, Cursor, and other AI assistants to directly use Farseer functionality.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.registerMcpServerCommand = registerMcpServerCommand;
|
|
10
|
+
const mcp_1 = require("../mcp");
|
|
11
|
+
function registerMcpServerCommand(program) {
|
|
12
|
+
program
|
|
13
|
+
.command('mcp-server')
|
|
14
|
+
.description('Start MCP server for AI assistant integration (Claude, Cursor, etc.)')
|
|
15
|
+
.action(async () => {
|
|
16
|
+
try {
|
|
17
|
+
await (0, mcp_1.startMcpServer)();
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
// MCP servers communicate errors via JSON-RPC, not stderr
|
|
21
|
+
// Only log to stderr for unexpected startup failures
|
|
22
|
+
console.error('Failed to start MCP server:', error instanceof Error ? error.message : 'Unknown error');
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerModelCommand = registerModelCommand;
|
|
4
|
+
const logger_1 = require("../utils/logger");
|
|
5
|
+
const farseerFactory_1 = require("../services/farseerFactory");
|
|
6
|
+
const helpers_1 = require("../utils/helpers");
|
|
7
|
+
function registerModelCommand(program) {
|
|
8
|
+
program
|
|
9
|
+
.command('model [tenant]')
|
|
10
|
+
.description('Export and display the model structure (dimensions, variables)')
|
|
11
|
+
.option('--json', 'Output raw JSON')
|
|
12
|
+
.option('--tables', 'Show only dimension tables')
|
|
13
|
+
.option('--variables', 'Show only variables')
|
|
14
|
+
.option('--variable <name>', 'Show details for specific variable')
|
|
15
|
+
.option('--table <name>', 'Show details for specific dimension table')
|
|
16
|
+
.action(async (tenantArg, options) => {
|
|
17
|
+
const { organisation, tenant } = (0, helpers_1.resolveTenantWithOrgMapping)(tenantArg);
|
|
18
|
+
const result = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
|
|
19
|
+
if (!result) {
|
|
20
|
+
(0, farseerFactory_1.showLoginPrompt)(tenant);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
const api = result.client;
|
|
24
|
+
try {
|
|
25
|
+
const model = await api.exportModel();
|
|
26
|
+
// Raw JSON output
|
|
27
|
+
if (options.json) {
|
|
28
|
+
console.log(JSON.stringify(model, null, 2));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// Specific variable details
|
|
32
|
+
if (options.variable) {
|
|
33
|
+
const variable = model.variables.find((v) => v.name.toLowerCase() === options.variable.toLowerCase());
|
|
34
|
+
if (!variable) {
|
|
35
|
+
logger_1.logger.error(`Variable "${options.variable}" not found.`);
|
|
36
|
+
logger_1.logger.dim('Available variables:');
|
|
37
|
+
model.variables.slice(0, 10).forEach((v) => logger_1.logger.dim(` - ${v.name}`));
|
|
38
|
+
if (model.variables.length > 10) {
|
|
39
|
+
logger_1.logger.dim(` ... and ${model.variables.length - 10} more`);
|
|
40
|
+
}
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
logger_1.logger.header(`Variable: ${variable.name}`);
|
|
44
|
+
console.log();
|
|
45
|
+
if (variable.description) {
|
|
46
|
+
console.log(` Description: ${variable.description}`);
|
|
47
|
+
}
|
|
48
|
+
if (variable.formula) {
|
|
49
|
+
console.log(` Formula: ${variable.formula}`);
|
|
50
|
+
}
|
|
51
|
+
console.log(` Dimensions: ${variable.tables.join(', ')}`);
|
|
52
|
+
if (variable.members.length > 0) {
|
|
53
|
+
console.log(` Specific members: ${variable.members.join(', ')}`);
|
|
54
|
+
}
|
|
55
|
+
console.log(` Roll-up type: ${variable.rollupType}`);
|
|
56
|
+
console.log(` Data type: ${variable.dataType}`);
|
|
57
|
+
if (variable.numberFormat) {
|
|
58
|
+
console.log(` Format: ${variable.numberFormat.type}${variable.numberFormat.formatString ? ` (${variable.numberFormat.formatString})` : ''}`);
|
|
59
|
+
}
|
|
60
|
+
console.log(` Readonly: ${variable.readonly}`);
|
|
61
|
+
console.log(` Calculate on demand: ${variable.calculateOnDemand}`);
|
|
62
|
+
if (variable.folderPath) {
|
|
63
|
+
console.log(` Folder: ${variable.folderPath.join(' / ')}`);
|
|
64
|
+
}
|
|
65
|
+
if (variable.cells && variable.cells.length > 0) {
|
|
66
|
+
console.log(` Cells with data: ${variable.cells.length}`);
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// Specific table details
|
|
71
|
+
if (options.table) {
|
|
72
|
+
const table = model.tables.find((t) => t.name.toLowerCase() === options.table.toLowerCase());
|
|
73
|
+
if (!table) {
|
|
74
|
+
logger_1.logger.error(`Table "${options.table}" not found.`);
|
|
75
|
+
logger_1.logger.dim('Available tables:');
|
|
76
|
+
model.tables.slice(0, 10).forEach((t) => logger_1.logger.dim(` - ${t.name}`));
|
|
77
|
+
if (model.tables.length > 10) {
|
|
78
|
+
logger_1.logger.dim(` ... and ${model.tables.length - 10} more`);
|
|
79
|
+
}
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
logger_1.logger.header(`Dimension Table: ${table.name}`);
|
|
83
|
+
console.log();
|
|
84
|
+
console.log(` Columns:`);
|
|
85
|
+
table.columns.forEach((col, i) => {
|
|
86
|
+
let colInfo = ` ${i + 1}. ${col.type}`;
|
|
87
|
+
if (col.name)
|
|
88
|
+
colInfo += ` (${col.name})`;
|
|
89
|
+
if (col.foreignKeyTableName)
|
|
90
|
+
colInfo += ` → ${col.foreignKeyTableName}`;
|
|
91
|
+
console.log(colInfo);
|
|
92
|
+
});
|
|
93
|
+
console.log(` Members: ${table.rows.length}`);
|
|
94
|
+
if (table.folderPath) {
|
|
95
|
+
console.log(` Folder: ${table.folderPath.join(' / ')}`);
|
|
96
|
+
}
|
|
97
|
+
if (table.rows.length > 0) {
|
|
98
|
+
console.log(` Sample members:`);
|
|
99
|
+
table.rows.slice(0, 5).forEach((row) => {
|
|
100
|
+
console.log(` - ${row[0]}`);
|
|
101
|
+
});
|
|
102
|
+
if (table.rows.length > 5) {
|
|
103
|
+
console.log(` ... and ${table.rows.length - 5} more`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
// Tables only
|
|
109
|
+
if (options.tables) {
|
|
110
|
+
logger_1.logger.header(`Dimension Tables (${model.tables.length})`);
|
|
111
|
+
console.log();
|
|
112
|
+
for (const table of model.tables) {
|
|
113
|
+
const fkColumns = table.columns.filter((c) => c.type === 'FOREIGN_KEY');
|
|
114
|
+
let info = ` 📋 ${table.name} (${table.rows.length} members)`;
|
|
115
|
+
if (fkColumns.length > 0) {
|
|
116
|
+
info += ` → ${fkColumns.map((c) => c.foreignKeyTableName).join(', ')}`;
|
|
117
|
+
}
|
|
118
|
+
console.log(info);
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
// Variables only
|
|
123
|
+
if (options.variables) {
|
|
124
|
+
logger_1.logger.header(`Variables (${model.variables.length})`);
|
|
125
|
+
console.log();
|
|
126
|
+
for (const variable of model.variables) {
|
|
127
|
+
console.log(` 📊 ${variable.name}`);
|
|
128
|
+
console.log(` Dimensions: ${variable.tables.join(', ')}`);
|
|
129
|
+
if (variable.formula) {
|
|
130
|
+
console.log(` Formula: ${variable.formula.substring(0, 50)}${variable.formula.length > 50 ? '...' : ''}`);
|
|
131
|
+
}
|
|
132
|
+
console.log();
|
|
133
|
+
}
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
// Default: summary
|
|
137
|
+
logger_1.logger.header(`Model Summary for ${tenant}`);
|
|
138
|
+
console.log();
|
|
139
|
+
console.log(` Dimension Tables: ${model.tables.length}`);
|
|
140
|
+
console.log(` Variables: ${model.variables.length}`);
|
|
141
|
+
console.log();
|
|
142
|
+
logger_1.logger.dim('Dimension Tables:');
|
|
143
|
+
model.tables.slice(0, 10).forEach((t) => {
|
|
144
|
+
logger_1.logger.dim(` - ${t.name} (${t.rows.length} members)`);
|
|
145
|
+
});
|
|
146
|
+
if (model.tables.length > 10) {
|
|
147
|
+
logger_1.logger.dim(` ... and ${model.tables.length - 10} more`);
|
|
148
|
+
}
|
|
149
|
+
console.log();
|
|
150
|
+
logger_1.logger.dim('Variables (first 10):');
|
|
151
|
+
model.variables.slice(0, 10).forEach((v) => {
|
|
152
|
+
logger_1.logger.dim(` - ${v.name} [${v.tables.join(', ')}]`);
|
|
153
|
+
});
|
|
154
|
+
if (model.variables.length > 10) {
|
|
155
|
+
logger_1.logger.dim(` ... and ${model.variables.length - 10} more`);
|
|
156
|
+
}
|
|
157
|
+
console.log();
|
|
158
|
+
logger_1.logger.dim('Use --tables, --variables, --table <name>, or --variable <name> for details.');
|
|
159
|
+
logger_1.logger.dim('Use --json for raw JSON output.');
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
163
|
+
if ((0, farseerFactory_1.isAuthError)(error)) {
|
|
164
|
+
(0, farseerFactory_1.showLoginPrompt)(tenant);
|
|
165
|
+
}
|
|
166
|
+
else if (errorMessage.includes('404')) {
|
|
167
|
+
logger_1.logger.error(`Tenant "${tenant}" not found or not accessible.`);
|
|
168
|
+
logger_1.logger.dim('Check that the tenant name is correct.');
|
|
169
|
+
}
|
|
170
|
+
else if (errorMessage.includes('ENOTFOUND') || errorMessage.includes('ECONNREFUSED')) {
|
|
171
|
+
logger_1.logger.error('Failed to connect to Farseer.');
|
|
172
|
+
logger_1.logger.dim('Check your network connection.');
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
logger_1.logger.error('Failed to export model.');
|
|
176
|
+
logger_1.logger.dim(errorMessage);
|
|
177
|
+
}
|
|
178
|
+
process.exit(1);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|