farseer-cli 1.0.10 → 1.1.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.
- package/README.md +19 -0
- package/dist/commands/app.js +348 -344
- package/dist/commands/app.js.map +7 -0
- package/dist/commands/apps.js +110 -82
- package/dist/commands/apps.js.map +7 -0
- package/dist/commands/cells.js +161 -0
- package/dist/commands/cells.js.map +7 -0
- package/dist/commands/checkout.js +140 -155
- package/dist/commands/checkout.js.map +7 -0
- package/dist/commands/config.js +128 -126
- package/dist/commands/config.js.map +7 -0
- package/dist/commands/dashboards.js +130 -0
- package/dist/commands/dashboards.js.map +7 -0
- package/dist/commands/diff.js +171 -193
- package/dist/commands/diff.js.map +7 -0
- package/dist/commands/dimensions.js +222 -119
- package/dist/commands/dimensions.js.map +7 -0
- package/dist/commands/files.js +96 -77
- package/dist/commands/files.js.map +7 -0
- package/dist/commands/formula.js +116 -0
- package/dist/commands/formula.js.map +7 -0
- package/dist/commands/install.js +74 -76
- package/dist/commands/install.js.map +7 -0
- package/dist/commands/list.js +91 -73
- package/dist/commands/list.js.map +7 -0
- package/dist/commands/login.js +137 -98
- package/dist/commands/login.js.map +7 -0
- package/dist/commands/logout.js +59 -41
- package/dist/commands/logout.js.map +7 -0
- package/dist/commands/mcp-server.js +36 -23
- package/dist/commands/mcp-server.js.map +7 -0
- package/dist/commands/model.js +186 -175
- package/dist/commands/model.js.map +7 -0
- package/dist/commands/pull.js +264 -274
- package/dist/commands/pull.js.map +7 -0
- package/dist/commands/push.js +209 -221
- package/dist/commands/push.js.map +7 -0
- package/dist/commands/run.js +276 -321
- package/dist/commands/run.js.map +7 -0
- package/dist/commands/sheets.js +200 -0
- package/dist/commands/sheets.js.map +7 -0
- package/dist/commands/status.js +149 -169
- package/dist/commands/status.js.map +7 -0
- package/dist/commands/variables.js +247 -188
- package/dist/commands/variables.js.map +7 -0
- package/dist/commands/whoami.js +65 -44
- package/dist/commands/whoami.js.map +7 -0
- package/dist/index.js +179 -115
- package/dist/index.js.map +7 -0
- package/dist/mcp/index.js +33 -16
- package/dist/mcp/index.js.map +7 -0
- package/dist/mcp/prompts/workflows.js +191 -145
- package/dist/mcp/prompts/workflows.js.map +7 -0
- package/dist/mcp/resources/documentation.js +158 -148
- package/dist/mcp/resources/documentation.js.map +7 -0
- package/dist/mcp/server.js +56 -33
- package/dist/mcp/server.js.map +7 -0
- package/dist/mcp/tools/appTools.js +309 -277
- package/dist/mcp/tools/appTools.js.map +7 -0
- package/dist/mcp/tools/authTools.js +130 -121
- package/dist/mcp/tools/authTools.js.map +7 -0
- package/dist/mcp/tools/cellTools.js +148 -0
- package/dist/mcp/tools/cellTools.js.map +7 -0
- package/dist/mcp/tools/dashboardTools.js +133 -0
- package/dist/mcp/tools/dashboardTools.js.map +7 -0
- package/dist/mcp/tools/dataTools.js +270 -267
- package/dist/mcp/tools/dataTools.js.map +7 -0
- package/dist/mcp/tools/modelTools.js +575 -229
- package/dist/mcp/tools/modelTools.js.map +7 -0
- package/dist/mcp/tools/runTools.js +201 -203
- package/dist/mcp/tools/runTools.js.map +7 -0
- package/dist/mcp/tools/sheetTools.js +240 -0
- package/dist/mcp/tools/sheetTools.js.map +7 -0
- package/dist/mcp/tools/syncTools.js +335 -314
- package/dist/mcp/tools/syncTools.js.map +7 -0
- package/dist/mcp/utils/helpers.js +117 -123
- package/dist/mcp/utils/helpers.js.map +7 -0
- package/dist/services/appSyncService.js +381 -437
- package/dist/services/appSyncService.js.map +7 -0
- package/dist/services/configService.js +154 -143
- package/dist/services/configService.js.map +7 -0
- package/dist/services/farseerApi.js +422 -399
- package/dist/services/farseerApi.js.map +7 -0
- package/dist/services/farseerFactory.js +208 -273
- package/dist/services/farseerFactory.js.map +7 -0
- package/dist/services/farseerService.js +467 -486
- package/dist/services/farseerService.js.map +7 -0
- package/dist/services/syncService.js +661 -731
- package/dist/services/syncService.js.map +7 -0
- package/dist/utils/constants.js +52 -19
- package/dist/utils/constants.js.map +7 -0
- package/dist/utils/entityResolver.js +78 -0
- package/dist/utils/entityResolver.js.map +7 -0
- package/dist/utils/helpers.js +331 -365
- package/dist/utils/helpers.js.map +7 -0
- package/dist/utils/logger.js +74 -42
- package/dist/utils/logger.js.map +7 -0
- package/package.json +3 -2
|
@@ -1,130 +1,233 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
11
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var dimensions_exports = {};
|
|
30
|
+
__export(dimensions_exports, {
|
|
31
|
+
registerDimensionsCommand: () => registerDimensionsCommand
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(dimensions_exports);
|
|
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");
|
|
38
|
+
var import_farseer_client = require("farseer-client");
|
|
11
39
|
function registerDimensionsCommand(program) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
for (const table of model.tables) {
|
|
40
|
-
const fkColumns = table.columns.filter((c) => c.type === 'FOREIGN_KEY');
|
|
41
|
-
let info = ` ${chalk_1.default.bold(table.name)} ${chalk_1.default.dim(`(${table.rows.length} members)`)}`;
|
|
42
|
-
if (fkColumns.length > 0) {
|
|
43
|
-
info += chalk_1.default.cyan(` -> ${fkColumns.map((c) => c.foreignKeyTableName).join(', ')}`);
|
|
44
|
-
}
|
|
45
|
-
console.log(info);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
handleModelError(error, tenant);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
// farseer dimension details (singular)
|
|
53
|
-
const dimensionCmd = program.command('dimension').description('Dimension table details');
|
|
54
|
-
dimensionCmd
|
|
55
|
-
.command('details <name>')
|
|
56
|
-
.description('Show dimension table details (columns, members)')
|
|
57
|
-
.option('--json', 'Output raw JSON')
|
|
58
|
-
.option('--members <n>', 'Number of sample members to show', '10')
|
|
59
|
-
.action(async (name, options) => {
|
|
60
|
-
const { organisation, tenant } = (0, helpers_1.resolveTenantWithOrgMapping)();
|
|
61
|
-
const result = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
|
|
62
|
-
if (!result) {
|
|
63
|
-
(0, farseerFactory_1.showLoginPrompt)(tenant);
|
|
64
|
-
process.exit(1);
|
|
40
|
+
const dimensionsCmd = program.command("dimensions").description("List and manage dimension tables");
|
|
41
|
+
dimensionsCmd.command("list [org] [tenant]").description("List all dimension tables").option("--json", "Output raw JSON").action(async (first, second, options) => {
|
|
42
|
+
const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(first, second);
|
|
43
|
+
const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
44
|
+
if (!result) {
|
|
45
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const model = await result.client.exportModel();
|
|
50
|
+
if (options.json) {
|
|
51
|
+
const tablesInfo = model.tables.map((t) => ({
|
|
52
|
+
name: t.name,
|
|
53
|
+
memberCount: t.rows.length,
|
|
54
|
+
columns: t.columns,
|
|
55
|
+
folderPath: t.folderPath
|
|
56
|
+
}));
|
|
57
|
+
console.log(JSON.stringify(tablesInfo, null, 2));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
import_logger.logger.header(`Dimension Tables (${model.tables.length})`);
|
|
61
|
+
console.log();
|
|
62
|
+
for (const table of model.tables) {
|
|
63
|
+
const fkColumns = table.columns.filter((c) => c.type === "FOREIGN_KEY");
|
|
64
|
+
let info = ` ${import_chalk.default.bold(table.name)} ${import_chalk.default.dim(`(${table.rows.length} members)`)}`;
|
|
65
|
+
if (fkColumns.length > 0) {
|
|
66
|
+
info += import_chalk.default.cyan(` -> ${fkColumns.map((c) => c.foreignKeyTableName).join(", ")}`);
|
|
65
67
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
colInfo += ` (${col.name})`;
|
|
90
|
-
if (col.foreignKeyTableName)
|
|
91
|
-
colInfo += chalk_1.default.cyan(` -> ${col.foreignKeyTableName}`);
|
|
92
|
-
console.log(colInfo);
|
|
93
|
-
});
|
|
94
|
-
console.log(` Members: ${table.rows.length}`);
|
|
95
|
-
if (table.folderPath) {
|
|
96
|
-
console.log(` Folder: ${table.folderPath.join(' / ')}`);
|
|
97
|
-
}
|
|
98
|
-
if (table.rows.length > 0) {
|
|
99
|
-
console.log();
|
|
100
|
-
console.log(` Sample members (first ${Math.min(memberLimit, table.rows.length)}):`);
|
|
101
|
-
table.rows.slice(0, memberLimit).forEach((row) => {
|
|
102
|
-
console.log(` - ${row[0]}`);
|
|
103
|
-
});
|
|
104
|
-
if (table.rows.length > memberLimit) {
|
|
105
|
-
logger_1.logger.dim(` ... and ${table.rows.length - memberLimit} more`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
68
|
+
console.log(info);
|
|
69
|
+
}
|
|
70
|
+
} catch (error) {
|
|
71
|
+
handleModelError(error, tenant);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const dimensionCmd = program.command("dimension").description("Dimension table details");
|
|
75
|
+
dimensionCmd.command("details <name>").description("Show dimension table details (columns, members)").option("--json", "Output raw JSON").option("--members <n>", "Number of sample members to show", "10").action(async (name, options) => {
|
|
76
|
+
const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)();
|
|
77
|
+
const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
78
|
+
if (!result) {
|
|
79
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
const model = await result.client.exportModel();
|
|
84
|
+
const table = model.tables.find((t) => t.name.toLowerCase() === name.toLowerCase());
|
|
85
|
+
if (!table) {
|
|
86
|
+
import_logger.logger.error(`Table "${name}" not found.`);
|
|
87
|
+
import_logger.logger.dim("Available tables:");
|
|
88
|
+
model.tables.slice(0, 10).forEach((t) => import_logger.logger.dim(` - ${t.name}`));
|
|
89
|
+
if (model.tables.length > 10) {
|
|
90
|
+
import_logger.logger.dim(` ... and ${model.tables.length - 10} more`);
|
|
108
91
|
}
|
|
109
|
-
|
|
110
|
-
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
if (options.json) {
|
|
95
|
+
console.log(JSON.stringify(table, null, 2));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const memberLimit = parseInt(options.members) || 10;
|
|
99
|
+
import_logger.logger.header(`Dimension Table: ${table.name}`);
|
|
100
|
+
console.log();
|
|
101
|
+
console.log(` Columns:`);
|
|
102
|
+
table.columns.forEach((col, i) => {
|
|
103
|
+
let colInfo = ` ${i + 1}. ${import_chalk.default.bold(col.type)}`;
|
|
104
|
+
if (col.name) colInfo += ` (${col.name})`;
|
|
105
|
+
if (col.foreignKeyTableName) colInfo += import_chalk.default.cyan(` -> ${col.foreignKeyTableName}`);
|
|
106
|
+
console.log(colInfo);
|
|
107
|
+
});
|
|
108
|
+
console.log(` Members: ${table.rows.length}`);
|
|
109
|
+
if (table.folderPath) {
|
|
110
|
+
console.log(` Folder: ${table.folderPath.join(" / ")}`);
|
|
111
|
+
}
|
|
112
|
+
if (table.rows.length > 0) {
|
|
113
|
+
console.log();
|
|
114
|
+
console.log(` Sample members (first ${Math.min(memberLimit, table.rows.length)}):`);
|
|
115
|
+
table.rows.slice(0, memberLimit).forEach((row) => {
|
|
116
|
+
console.log(` - ${row[0]}`);
|
|
117
|
+
});
|
|
118
|
+
if (table.rows.length > memberLimit) {
|
|
119
|
+
import_logger.logger.dim(` ... and ${table.rows.length - memberLimit} more`);
|
|
111
120
|
}
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
}
|
|
122
|
+
} catch (error) {
|
|
123
|
+
handleModelError(error, tenant);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
dimensionsCmd.command("members <tableName> [org] [tenant]").description("List all members of a dimension table").option("--json", "Output raw JSON").option("--limit <n>", "Limit number of members shown", parseInt).action(async (tableName, first, second, options) => {
|
|
127
|
+
const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(first, second);
|
|
128
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
129
|
+
if (!nativeClient) {
|
|
130
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
131
|
+
process.exit(1);
|
|
118
132
|
}
|
|
119
|
-
|
|
120
|
-
|
|
133
|
+
try {
|
|
134
|
+
await nativeClient.initTagMap();
|
|
135
|
+
const members = await nativeClient.getDimensionMembersForTable(tableName);
|
|
136
|
+
if (options.json) {
|
|
137
|
+
const result = members.map((m) => ({
|
|
138
|
+
id: m.id,
|
|
139
|
+
name: m.name,
|
|
140
|
+
parentId: m.ParentId
|
|
141
|
+
}));
|
|
142
|
+
console.log(JSON.stringify(result, null, 2));
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const limit = options.limit || members.length;
|
|
146
|
+
import_logger.logger.header(`Members of "${tableName}" (${members.length})`);
|
|
147
|
+
const display = members.slice(0, limit);
|
|
148
|
+
for (const m of display) {
|
|
149
|
+
const parentInfo = m.ParentId ? import_chalk.default.dim(` (parent: ${m.ParentId})`) : "";
|
|
150
|
+
console.log(` ${import_chalk.default.dim(String(m.id).padEnd(8))} ${m.name}${parentInfo}`);
|
|
151
|
+
}
|
|
152
|
+
if (members.length > limit) {
|
|
153
|
+
import_logger.logger.dim(` ... and ${members.length - limit} more`);
|
|
154
|
+
}
|
|
155
|
+
} catch (error) {
|
|
156
|
+
handleModelError(error, tenant);
|
|
121
157
|
}
|
|
122
|
-
|
|
123
|
-
|
|
158
|
+
});
|
|
159
|
+
dimensionsCmd.command("create-member [org] [tenant]").description("Create a new dimension member").requiredOption("--table <name>", "Dimension table name").requiredOption("--name <name>", "New member name").option("--parent <name>", "Parent member name").action(async (first, second, options) => {
|
|
160
|
+
const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(first, second);
|
|
161
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
162
|
+
if (!nativeClient) {
|
|
163
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
await nativeClient.initTagMap();
|
|
168
|
+
const table = await nativeClient.getDimensionTable(options.table);
|
|
169
|
+
const createEntity = {
|
|
170
|
+
type: import_farseer_client.EntityType.DimensionMember,
|
|
171
|
+
meta: { name: options.name },
|
|
172
|
+
relations: {
|
|
173
|
+
parent: { id: table.id }
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
if (options.parent) {
|
|
177
|
+
const parentMember = await nativeClient.getDimensionMember(options.table, options.parent);
|
|
178
|
+
createEntity.relations.parent = { id: parentMember.id };
|
|
179
|
+
}
|
|
180
|
+
const result = await nativeClient.entities.mutate({ created: [createEntity] });
|
|
181
|
+
import_logger.logger.success(`Created dimension member "${options.name}" in table "${options.table}".`);
|
|
182
|
+
if (result.created?.length > 0) {
|
|
183
|
+
import_logger.logger.dim(` ID: ${result.created[0].id}`);
|
|
184
|
+
}
|
|
185
|
+
} catch (error) {
|
|
186
|
+
handleModelError(error, tenant);
|
|
124
187
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
188
|
+
});
|
|
189
|
+
dimensionsCmd.command("delete-member [org] [tenant]").description("Delete a dimension member").requiredOption("--table <name>", "Dimension table name").requiredOption("--name <name>", "Member name to delete").option("-y, --yes", "Skip confirmation").action(async (first, second, options) => {
|
|
190
|
+
const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(first, second);
|
|
191
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
192
|
+
if (!nativeClient) {
|
|
193
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
194
|
+
process.exit(1);
|
|
128
195
|
}
|
|
129
|
-
|
|
196
|
+
try {
|
|
197
|
+
await nativeClient.initTagMap();
|
|
198
|
+
const member = await nativeClient.getDimensionMember(options.table, options.name);
|
|
199
|
+
if (!options.yes) {
|
|
200
|
+
import_logger.logger.warning(
|
|
201
|
+
`This will delete member "${options.name}" (ID: ${member.id}) from table "${options.table}".`
|
|
202
|
+
);
|
|
203
|
+
import_logger.logger.dim("Use -y to skip confirmation.");
|
|
204
|
+
process.exit(0);
|
|
205
|
+
}
|
|
206
|
+
await nativeClient.entities.mutate({
|
|
207
|
+
deleted: [{ id: member.id, type: import_farseer_client.EntityType.DimensionMember }]
|
|
208
|
+
});
|
|
209
|
+
import_logger.logger.success(`Deleted dimension member "${options.name}" from table "${options.table}".`);
|
|
210
|
+
} catch (error) {
|
|
211
|
+
handleModelError(error, tenant);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
function handleModelError(error, tenant) {
|
|
216
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
217
|
+
if ((0, import_farseerFactory.isAuthError)(error)) {
|
|
218
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
219
|
+
} else if (errorMessage.includes("404")) {
|
|
220
|
+
import_logger.logger.error(`Tenant "${tenant}" not found or not accessible.`);
|
|
221
|
+
} else if (errorMessage.includes("ENOTFOUND") || errorMessage.includes("ECONNREFUSED")) {
|
|
222
|
+
import_logger.logger.error("Failed to connect to Farseer.");
|
|
223
|
+
} else {
|
|
224
|
+
import_logger.logger.error("Failed to fetch model.");
|
|
225
|
+
import_logger.logger.dim(errorMessage);
|
|
226
|
+
}
|
|
227
|
+
process.exit(1);
|
|
130
228
|
}
|
|
229
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
230
|
+
0 && (module.exports = {
|
|
231
|
+
registerDimensionsCommand
|
|
232
|
+
});
|
|
233
|
+
//# sourceMappingURL=dimensions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/dimensions.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport {\n getFarseerClientWithFallback,\n getNativeFarseerClient,\n showLoginPrompt,\n isAuthError,\n} from '../services/farseerFactory';\nimport { resolveTenantWithOrgMapping } from '../utils/helpers';\nimport { EntityType } from 'farseer-client';\n\nexport function registerDimensionsCommand(program: Command): void {\n // farseer dimensions list\n const dimensionsCmd = program.command('dimensions').description('List and manage dimension tables');\n\n dimensionsCmd\n .command('list [org] [tenant]')\n .description('List all dimension tables')\n .option('--json', 'Output raw JSON')\n .action(async (first, second, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(first, second);\n const result = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n const model = await result.client.exportModel();\n\n if (options.json) {\n const tablesInfo = model.tables.map((t) => ({\n name: t.name,\n memberCount: t.rows.length,\n columns: t.columns,\n folderPath: t.folderPath,\n }));\n console.log(JSON.stringify(tablesInfo, null, 2));\n return;\n }\n\n logger.header(`Dimension Tables (${model.tables.length})`);\n console.log();\n for (const table of model.tables) {\n const fkColumns = table.columns.filter((c) => c.type === 'FOREIGN_KEY');\n let info = ` ${chalk.bold(table.name)} ${chalk.dim(`(${table.rows.length} members)`)}`;\n if (fkColumns.length > 0) {\n info += chalk.cyan(` -> ${fkColumns.map((c) => c.foreignKeyTableName).join(', ')}`);\n }\n console.log(info);\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer dimension details (singular)\n const dimensionCmd = program.command('dimension').description('Dimension table details');\n\n dimensionCmd\n .command('details <name>')\n .description('Show dimension table details (columns, members)')\n .option('--json', 'Output raw JSON')\n .option('--members <n>', 'Number of sample members to show', '10')\n .action(async (name, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping();\n const result = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n const model = await result.client.exportModel();\n const table = model.tables.find((t) => t.name.toLowerCase() === name.toLowerCase());\n\n if (!table) {\n logger.error(`Table \"${name}\" not found.`);\n logger.dim('Available tables:');\n model.tables.slice(0, 10).forEach((t) => logger.dim(` - ${t.name}`));\n if (model.tables.length > 10) {\n logger.dim(` ... and ${model.tables.length - 10} more`);\n }\n process.exit(1);\n }\n\n if (options.json) {\n console.log(JSON.stringify(table, null, 2));\n return;\n }\n\n const memberLimit = parseInt(options.members) || 10;\n\n logger.header(`Dimension Table: ${table.name}`);\n console.log();\n console.log(` Columns:`);\n table.columns.forEach((col, i) => {\n let colInfo = ` ${i + 1}. ${chalk.bold(col.type)}`;\n if (col.name) colInfo += ` (${col.name})`;\n if (col.foreignKeyTableName) colInfo += chalk.cyan(` -> ${col.foreignKeyTableName}`);\n console.log(colInfo);\n });\n console.log(` Members: ${table.rows.length}`);\n if (table.folderPath) {\n console.log(` Folder: ${table.folderPath.join(' / ')}`);\n }\n if (table.rows.length > 0) {\n console.log();\n console.log(` Sample members (first ${Math.min(memberLimit, table.rows.length)}):`);\n table.rows.slice(0, memberLimit).forEach((row) => {\n console.log(` - ${row[0]}`);\n });\n if (table.rows.length > memberLimit) {\n logger.dim(` ... and ${table.rows.length - memberLimit} more`);\n }\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer dimensions members <tableName> [org] [tenant]\n dimensionsCmd\n .command('members <tableName> [org] [tenant]')\n .description('List all members of a dimension table')\n .option('--json', 'Output raw JSON')\n .option('--limit <n>', 'Limit number of members shown', parseInt)\n .action(async (tableName, first, second, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(first, second);\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n\n if (!nativeClient) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n await nativeClient.initTagMap();\n const members = await nativeClient.getDimensionMembersForTable(tableName);\n\n if (options.json) {\n const result = members.map((m) => ({\n id: m.id,\n name: m.name,\n parentId: m.ParentId,\n }));\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n const limit = options.limit || members.length;\n logger.header(`Members of \"${tableName}\" (${members.length})`);\n const display = members.slice(0, limit);\n for (const m of display) {\n const parentInfo = m.ParentId ? chalk.dim(` (parent: ${m.ParentId})`) : '';\n console.log(` ${chalk.dim(String(m.id).padEnd(8))} ${m.name}${parentInfo}`);\n }\n if (members.length > limit) {\n logger.dim(` ... and ${members.length - limit} more`);\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer dimensions create-member [org] [tenant]\n dimensionsCmd\n .command('create-member [org] [tenant]')\n .description('Create a new dimension member')\n .requiredOption('--table <name>', 'Dimension table name')\n .requiredOption('--name <name>', 'New member name')\n .option('--parent <name>', 'Parent member name')\n .action(async (first, second, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(first, second);\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n\n if (!nativeClient) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n await nativeClient.initTagMap();\n const table = await nativeClient.getDimensionTable(options.table);\n\n const createEntity: any = {\n type: EntityType.DimensionMember,\n meta: { name: options.name },\n relations: {\n parent: { id: table.id },\n },\n };\n\n if (options.parent) {\n const parentMember = await nativeClient.getDimensionMember(options.table, options.parent);\n createEntity.relations.parent = { id: parentMember.id };\n }\n\n const result = await nativeClient.entities.mutate({ created: [createEntity] });\n logger.success(`Created dimension member \"${options.name}\" in table \"${options.table}\".`);\n if ((result as any).created?.length > 0) {\n logger.dim(` ID: ${(result as any).created[0].id}`);\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer dimensions delete-member [org] [tenant]\n dimensionsCmd\n .command('delete-member [org] [tenant]')\n .description('Delete a dimension member')\n .requiredOption('--table <name>', 'Dimension table name')\n .requiredOption('--name <name>', 'Member name to delete')\n .option('-y, --yes', 'Skip confirmation')\n .action(async (first, second, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(first, second);\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n\n if (!nativeClient) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n await nativeClient.initTagMap();\n const member = await nativeClient.getDimensionMember(options.table, options.name);\n\n if (!options.yes) {\n logger.warning(\n `This will delete member \"${options.name}\" (ID: ${member.id}) from table \"${options.table}\".`,\n );\n logger.dim('Use -y to skip confirmation.');\n process.exit(0);\n }\n\n await nativeClient.entities.mutate({\n deleted: [{ id: member.id, type: EntityType.DimensionMember }],\n });\n logger.success(`Deleted dimension member \"${options.name}\" from table \"${options.table}\".`);\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n}\n\nfunction handleModelError(error: unknown, tenant: string): void {\n const errorMessage = error instanceof Error ? error.message : String(error);\n\n if (isAuthError(error)) {\n showLoginPrompt(tenant);\n } else if (errorMessage.includes('404')) {\n logger.error(`Tenant \"${tenant}\" not found or not accessible.`);\n } else if (errorMessage.includes('ENOTFOUND') || errorMessage.includes('ECONNREFUSED')) {\n logger.error('Failed to connect to Farseer.');\n } else {\n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
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var files_exports = {};
|
|
20
|
+
__export(files_exports, {
|
|
21
|
+
registerFilesCommand: () => registerFilesCommand
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(files_exports);
|
|
24
|
+
var import_logger = require("../utils/logger");
|
|
25
|
+
var import_farseerFactory = require("../services/farseerFactory");
|
|
26
|
+
var import_helpers = require("../utils/helpers");
|
|
7
27
|
function registerFilesCommand(program) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.addHelpText('after', `
|
|
28
|
+
const filesCmd = program.command("files").description("Manage files on a Farseer instance").addHelpText(
|
|
29
|
+
"after",
|
|
30
|
+
`
|
|
12
31
|
Commands:
|
|
13
32
|
list [tenant] List all files on remote
|
|
14
33
|
|
|
@@ -16,73 +35,73 @@ Examples:
|
|
|
16
35
|
$ farseer files list # List script files
|
|
17
36
|
$ farseer files list --all # List all files
|
|
18
37
|
$ farseer files list mycompany # List files on specific tenant
|
|
19
|
-
`
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
`
|
|
39
|
+
);
|
|
40
|
+
filesCmd.command("list [org] [tenant]").description(
|
|
41
|
+
"List all files on a Farseer instance\n\nUsage: list <org> <tenant> OR list <tenant> (if org is known)"
|
|
42
|
+
).option("--all", "List all files (default: only scripts .ts, .js)").action(async (arg1, arg2, options) => {
|
|
43
|
+
const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(arg1, arg2);
|
|
44
|
+
const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
45
|
+
if (!result) {
|
|
46
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
const authLabel = result.authType === "apiKey" ? "API key" : "browser login";
|
|
50
|
+
import_logger.logger.info(`Fetching files from ${tenant} (using ${authLabel})...`);
|
|
51
|
+
let files;
|
|
52
|
+
try {
|
|
53
|
+
files = await result.client.listFiles();
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if ((0, import_farseerFactory.isAuthError)(error)) {
|
|
56
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
57
|
+
} else {
|
|
58
|
+
import_logger.logger.error("Failed to list files.");
|
|
59
|
+
if (error instanceof Error) {
|
|
60
|
+
import_logger.logger.dim(error.message);
|
|
31
61
|
}
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
// Sort directories
|
|
74
|
-
const dirs = Object.keys(grouped).sort();
|
|
75
|
-
for (const dir of dirs) {
|
|
76
|
-
if (dir) {
|
|
77
|
-
console.log(` ${dir}`);
|
|
78
|
-
}
|
|
79
|
-
const dirFiles = grouped[dir].sort();
|
|
80
|
-
for (const file of dirFiles) {
|
|
81
|
-
const prefix = dir ? ' ' : ' ';
|
|
82
|
-
console.log(`${prefix}${file}`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
console.log();
|
|
86
|
-
logger_1.logger.dim(`Total: ${files.length} file(s)`);
|
|
87
|
-
});
|
|
62
|
+
}
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
if (!options.all) {
|
|
66
|
+
files = files.filter(
|
|
67
|
+
(f) => import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.name.toLowerCase().endsWith(ext))
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
if (files.length === 0) {
|
|
71
|
+
import_logger.logger.warning("No files found in Files/");
|
|
72
|
+
import_logger.logger.dim(
|
|
73
|
+
options.all ? "The folder might be empty or does not exist." : "No script files (.ts, .js) found. Use --all to see all files."
|
|
74
|
+
);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
import_logger.logger.header(`Files on ${tenant} (Files/)`);
|
|
78
|
+
const grouped = {};
|
|
79
|
+
for (const file of files) {
|
|
80
|
+
const parts = file.path.split("/");
|
|
81
|
+
const fileName = parts.pop();
|
|
82
|
+
const dir = parts.length > 0 ? parts.join("/") + "/" : "";
|
|
83
|
+
if (!grouped[dir]) {
|
|
84
|
+
grouped[dir] = [];
|
|
85
|
+
}
|
|
86
|
+
grouped[dir].push(fileName);
|
|
87
|
+
}
|
|
88
|
+
const dirs = Object.keys(grouped).sort();
|
|
89
|
+
for (const dir of dirs) {
|
|
90
|
+
if (dir) {
|
|
91
|
+
console.log(` ${dir}`);
|
|
92
|
+
}
|
|
93
|
+
const dirFiles = grouped[dir].sort();
|
|
94
|
+
for (const file of dirFiles) {
|
|
95
|
+
const prefix = dir ? " " : " ";
|
|
96
|
+
console.log(`${prefix}${file}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
console.log();
|
|
100
|
+
import_logger.logger.dim(`Total: ${files.length} file(s)`);
|
|
101
|
+
});
|
|
88
102
|
}
|
|
103
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
104
|
+
0 && (module.exports = {
|
|
105
|
+
registerFilesCommand
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/files.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport { logger } from '../utils/logger';\nimport {\n getFarseerClientWithFallback,\n showLoginPrompt,\n isAuthError,\n DEFAULT_SCRIPT_EXTENSIONS,\n} from '../services/farseerFactory';\nimport { resolveTenantWithOrgMapping } from '../utils/helpers';\n\nexport function registerFilesCommand(program: Command): void {\n const filesCmd = program\n .command('files')\n .description('Manage files on a Farseer instance')\n .addHelpText(\n 'after',\n `\nCommands:\n list [tenant] List all files on remote\n\nExamples:\n $ farseer files list # List script files\n $ farseer files list --all # List all files\n $ farseer files list mycompany # List files on specific tenant\n`,\n );\n\n // List files\n filesCmd\n .command('list [org] [tenant]')\n .description(\n 'List all files on a Farseer instance\\n\\nUsage: list <org> <tenant> OR list <tenant> (if org is known)',\n )\n .option('--all', 'List all files (default: only scripts .ts, .js)')\n .action(async (arg1, arg2, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(arg1, arg2);\n const result = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const authLabel = result.authType === 'apiKey' ? 'API key' : 'browser login';\n logger.info(`Fetching files from ${tenant} (using ${authLabel})...`);\n\n let files;\n try {\n files = await result.client.listFiles();\n } catch (error) {\n if (isAuthError(error)) {\n showLoginPrompt(tenant);\n } else {\n logger.error('Failed to list files.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n }\n process.exit(1);\n }\n\n // Filter to scripts only unless --all is specified\n if (!options.all) {\n files = files.filter((f) =>\n DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.name.toLowerCase().endsWith(ext)),\n );\n }\n\n if (files.length === 0) {\n logger.warning('No files found in Files/');\n logger.dim(\n options.all\n ? 'The folder might be empty or does not exist.'\n : 'No script files (.ts, .js) found. Use --all to see all files.',\n );\n return;\n }\n\n logger.header(`Files on ${tenant} (Files/)`);\n\n // Group by directory\n const grouped: Record<string, string[]> = {};\n\n for (const file of files) {\n const parts = file.path.split('/');\n const fileName = parts.pop()!;\n const dir = parts.length > 0 ? parts.join('/') + '/' : '';\n\n if (!grouped[dir]) {\n grouped[dir] = [];\n }\n grouped[dir].push(fileName);\n }\n\n // Sort directories\n const dirs = Object.keys(grouped).sort();\n\n for (const dir of dirs) {\n if (dir) {\n console.log(` ${dir}`);\n }\n\n const dirFiles = grouped[dir].sort();\n for (const file of dirFiles) {\n const prefix = dir ? ' ' : ' ';\n console.log(`${prefix}${file}`);\n }\n }\n\n console.log();\n logger.dim(`Total: ${files.length} file(s)`);\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AACvB,4BAKO;AACP,qBAA4C;AAErC,SAAS,qBAAqB,SAAwB;AACzD,QAAM,WAAW,QACZ,QAAQ,OAAO,EACf,YAAY,oCAAoC,EAChD;AAAA,IACG;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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