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,54 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 modelTools_exports = {};
|
|
19
|
-
__export(modelTools_exports, {
|
|
20
|
-
registerModelTools: () => registerModelTools
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(modelTools_exports);
|
|
23
|
-
var import_zod = require("zod");
|
|
24
|
-
var import_farseerFactory = require("../../services/farseerFactory");
|
|
25
|
-
var import_helpers = require("../utils/helpers");
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Model Inspection Tools
|
|
4
|
+
*
|
|
5
|
+
* Tools for exploring Farseer data models (dimensions, variables, formulas).
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.registerModelTools = registerModelTools;
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
const farseerFactory_1 = require("../../services/farseerFactory");
|
|
11
|
+
const helpers_1 = require("../utils/helpers");
|
|
12
|
+
// Define schemas outside of tool registration to avoid deep type instantiation
|
|
26
13
|
const exportModelSchema = {
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
tenant: zod_1.z.string().optional().describe('Tenant ID (e.g. "salvus-prodaja"). Uses checked-out tenant if omitted.'),
|
|
15
|
+
organisation: zod_1.z
|
|
16
|
+
.string()
|
|
17
|
+
.optional()
|
|
18
|
+
.describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
|
|
29
19
|
};
|
|
30
20
|
const listTablesSchema = {
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
tenant: zod_1.z.string().optional().describe('Tenant ID (e.g. "salvus-prodaja"). Uses checked-out tenant if omitted.'),
|
|
22
|
+
organisation: zod_1.z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
|
|
33
26
|
};
|
|
34
27
|
const listVariablesSchema = {
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
tenant: zod_1.z.string().optional().describe('Tenant ID (e.g. "salvus-prodaja"). Uses checked-out tenant if omitted.'),
|
|
29
|
+
organisation: zod_1.z
|
|
30
|
+
.string()
|
|
31
|
+
.optional()
|
|
32
|
+
.describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
|
|
37
33
|
};
|
|
38
34
|
const getTableSchema = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
organisation: zod_1.z
|
|
36
|
+
.string()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
|
|
39
|
+
tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
|
|
40
|
+
tableName: zod_1.z.string().describe('Name of the dimension table'),
|
|
42
41
|
};
|
|
43
42
|
const getVariableSchema = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
organisation: zod_1.z
|
|
44
|
+
.string()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
|
|
47
|
+
tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
|
|
48
|
+
variableName: zod_1.z.string().describe('Name of the variable'),
|
|
47
49
|
};
|
|
48
50
|
function registerModelTools(server) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
`Export the complete data model structure from a Farseer tenant.
|
|
51
|
+
// farseer_export_model - Export complete model
|
|
52
|
+
server.tool('farseer_export_model', `Export the complete data model structure from a Farseer tenant.
|
|
52
53
|
|
|
53
54
|
Returns:
|
|
54
55
|
- All dimension tables with member counts and foreign key relationships
|
|
@@ -59,61 +60,57 @@ This is essential for understanding a tenant's data structure before writing imp
|
|
|
59
60
|
The model export can be large for complex tenants. Use farseer_list_tables or
|
|
60
61
|
farseer_list_variables for a summary view.
|
|
61
62
|
|
|
62
|
-
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
);
|
|
114
|
-
server.tool(
|
|
115
|
-
"farseer_list_tables",
|
|
116
|
-
`List all dimension tables in a Farseer tenant model.
|
|
63
|
+
If no tenant is specified, uses the currently checked-out tenant.`, exportModelSchema, async (params) => {
|
|
64
|
+
const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
|
|
65
|
+
if (!resolved) {
|
|
66
|
+
return (0, helpers_1.tenantRequiredResponse)();
|
|
67
|
+
}
|
|
68
|
+
const { organisation, tenant } = resolved;
|
|
69
|
+
const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
|
|
70
|
+
if (!clientResult) {
|
|
71
|
+
return (0, helpers_1.authRequiredResponse)(tenant);
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const model = await clientResult.client.exportModel();
|
|
75
|
+
// Process tables
|
|
76
|
+
const tables = model.tables.map((t) => ({
|
|
77
|
+
name: t.name,
|
|
78
|
+
memberCount: t.rows?.length || 0,
|
|
79
|
+
columns: t.columns.map((c) => ({
|
|
80
|
+
type: c.type,
|
|
81
|
+
name: c.name,
|
|
82
|
+
foreignKeyTable: c.foreignKeyTableName,
|
|
83
|
+
})),
|
|
84
|
+
foreignKeys: t.columns.filter((c) => c.type === 'FOREIGN_KEY').map((c) => c.foreignKeyTableName),
|
|
85
|
+
folderPath: t.folderPath,
|
|
86
|
+
}));
|
|
87
|
+
// Process variables
|
|
88
|
+
const variables = model.variables.map((v) => ({
|
|
89
|
+
name: v.name,
|
|
90
|
+
dimensions: v.tables || [],
|
|
91
|
+
formula: v.formula || undefined,
|
|
92
|
+
rollupType: v.rollupType,
|
|
93
|
+
numberFormat: v.numberFormat,
|
|
94
|
+
readonly: v.readonly,
|
|
95
|
+
calculateOnDemand: v.calculateOnDemand,
|
|
96
|
+
folderPath: v.folderPath,
|
|
97
|
+
}));
|
|
98
|
+
return (0, helpers_1.successResponse)({
|
|
99
|
+
tenant,
|
|
100
|
+
summary: {
|
|
101
|
+
tableCount: tables.length,
|
|
102
|
+
variableCount: variables.length,
|
|
103
|
+
},
|
|
104
|
+
tables,
|
|
105
|
+
variables,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
return (0, helpers_1.errorResponse)(`Export model failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
// farseer_list_tables - List dimension tables
|
|
113
|
+
server.tool('farseer_list_tables', `List all dimension tables in a Farseer tenant model.
|
|
117
114
|
|
|
118
115
|
Dimension tables define the structure of data:
|
|
119
116
|
- Product, Region, Customer (business dimensions)
|
|
@@ -122,42 +119,37 @@ Dimension tables define the structure of data:
|
|
|
122
119
|
|
|
123
120
|
Returns table names, member counts, and foreign key relationships.
|
|
124
121
|
|
|
125
|
-
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
);
|
|
158
|
-
server.tool(
|
|
159
|
-
"farseer_list_variables",
|
|
160
|
-
`List all variables defined in a Farseer tenant model.
|
|
122
|
+
If no tenant is specified, uses the currently checked-out tenant.`, listTablesSchema, async (params) => {
|
|
123
|
+
const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
|
|
124
|
+
if (!resolved) {
|
|
125
|
+
return (0, helpers_1.tenantRequiredResponse)();
|
|
126
|
+
}
|
|
127
|
+
const { organisation, tenant } = resolved;
|
|
128
|
+
const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
|
|
129
|
+
if (!clientResult) {
|
|
130
|
+
return (0, helpers_1.authRequiredResponse)(tenant);
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const model = await clientResult.client.exportModel();
|
|
134
|
+
const tables = model.tables.map((t) => ({
|
|
135
|
+
name: t.name,
|
|
136
|
+
memberCount: t.rows?.length || 0,
|
|
137
|
+
foreignKeys: t.columns.filter((c) => c.type === 'FOREIGN_KEY').map((c) => c.foreignKeyTableName),
|
|
138
|
+
}));
|
|
139
|
+
// Sort by name
|
|
140
|
+
tables.sort((a, b) => a.name.localeCompare(b.name));
|
|
141
|
+
return (0, helpers_1.successResponse)({
|
|
142
|
+
tenant,
|
|
143
|
+
totalTables: tables.length,
|
|
144
|
+
tables,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
return (0, helpers_1.errorResponse)(`List tables failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
// farseer_list_variables - List variables
|
|
152
|
+
server.tool('farseer_list_variables', `List all variables defined in a Farseer tenant model.
|
|
161
153
|
|
|
162
154
|
Variables store data and calculations - they are the core of the data model.
|
|
163
155
|
|
|
@@ -166,44 +158,39 @@ Each variable has:
|
|
|
166
158
|
- Optional formula for calculated values
|
|
167
159
|
- Roll-up type (how values aggregate up hierarchies)
|
|
168
160
|
|
|
169
|
-
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
);
|
|
204
|
-
server.tool(
|
|
205
|
-
"farseer_get_table",
|
|
206
|
-
`Get detailed information about a specific dimension table.
|
|
161
|
+
If no tenant is specified, uses the currently checked-out tenant.`, listVariablesSchema, async (params) => {
|
|
162
|
+
const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
|
|
163
|
+
if (!resolved) {
|
|
164
|
+
return (0, helpers_1.tenantRequiredResponse)();
|
|
165
|
+
}
|
|
166
|
+
const { organisation, tenant } = resolved;
|
|
167
|
+
const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
|
|
168
|
+
if (!clientResult) {
|
|
169
|
+
return (0, helpers_1.authRequiredResponse)(tenant);
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
const model = await clientResult.client.exportModel();
|
|
173
|
+
const variables = model.variables.map((v) => ({
|
|
174
|
+
name: v.name,
|
|
175
|
+
dimensions: v.tables || [],
|
|
176
|
+
hasFormula: !!v.formula,
|
|
177
|
+
rollupType: v.rollupType,
|
|
178
|
+
readonly: v.readonly,
|
|
179
|
+
}));
|
|
180
|
+
// Sort by name
|
|
181
|
+
variables.sort((a, b) => a.name.localeCompare(b.name));
|
|
182
|
+
return (0, helpers_1.successResponse)({
|
|
183
|
+
tenant,
|
|
184
|
+
totalVariables: variables.length,
|
|
185
|
+
variables,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
return (0, helpers_1.errorResponse)(`List variables failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
// farseer_get_table - Get dimension table details
|
|
193
|
+
server.tool('farseer_get_table', `Get detailed information about a specific dimension table.
|
|
207
194
|
|
|
208
195
|
Returns:
|
|
209
196
|
- Table columns with their types
|
|
@@ -213,57 +200,50 @@ Returns:
|
|
|
213
200
|
|
|
214
201
|
This helps understand the structure needed for import scripts.
|
|
215
202
|
|
|
216
|
-
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
if (!clientResult) {
|
|
226
|
-
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
227
|
-
}
|
|
228
|
-
try {
|
|
229
|
-
const model = await clientResult.client.exportModel();
|
|
230
|
-
const table = model.tables.find(
|
|
231
|
-
(t) => t.name.toLowerCase() === params.tableName.toLowerCase()
|
|
232
|
-
);
|
|
233
|
-
if (!table) {
|
|
234
|
-
return (0, import_helpers.errorResponse)(`Table "${params.tableName}" not found`, "NOT_FOUND");
|
|
203
|
+
If no tenant is specified, uses the currently checked-out tenant.`, getTableSchema, async (params) => {
|
|
204
|
+
const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
|
|
205
|
+
if (!resolved) {
|
|
206
|
+
return (0, helpers_1.tenantRequiredResponse)();
|
|
207
|
+
}
|
|
208
|
+
const { organisation, tenant } = resolved;
|
|
209
|
+
const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
|
|
210
|
+
if (!clientResult) {
|
|
211
|
+
return (0, helpers_1.authRequiredResponse)(tenant);
|
|
235
212
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
213
|
+
try {
|
|
214
|
+
const model = await clientResult.client.exportModel();
|
|
215
|
+
const table = model.tables.find((t) => t.name.toLowerCase() === params.tableName.toLowerCase());
|
|
216
|
+
if (!table) {
|
|
217
|
+
return (0, helpers_1.errorResponse)(`Table "${params.tableName}" not found`, 'NOT_FOUND');
|
|
218
|
+
}
|
|
219
|
+
// Get sample members (first column is usually the primary key / name)
|
|
220
|
+
const primaryKeyColumn = table.columns.find((c) => c.type === 'PRIMARY_KEY');
|
|
221
|
+
let sampleMembers = [];
|
|
222
|
+
if (table.rows && table.rows.length > 0) {
|
|
223
|
+
const pkIndex = primaryKeyColumn ? table.columns.indexOf(primaryKeyColumn) : 0;
|
|
224
|
+
sampleMembers = table.rows.slice(0, 20).map((row) => String(row[pkIndex]));
|
|
225
|
+
}
|
|
226
|
+
return (0, helpers_1.successResponse)({
|
|
227
|
+
tenant,
|
|
228
|
+
table: {
|
|
229
|
+
name: table.name,
|
|
230
|
+
columns: table.columns.map((c) => ({
|
|
231
|
+
type: c.type,
|
|
232
|
+
name: c.name,
|
|
233
|
+
foreignKeyTable: c.foreignKeyTableName,
|
|
234
|
+
})),
|
|
235
|
+
memberCount: table.rows?.length || 0,
|
|
236
|
+
sampleMembers,
|
|
237
|
+
folderPath: table.folderPath,
|
|
238
|
+
},
|
|
239
|
+
});
|
|
241
240
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
name: c.name,
|
|
249
|
-
foreignKeyTable: c.foreignKeyTableName
|
|
250
|
-
})),
|
|
251
|
-
memberCount: table.rows?.length || 0,
|
|
252
|
-
sampleMembers,
|
|
253
|
-
folderPath: table.folderPath
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
} catch (error) {
|
|
257
|
-
return (0, import_helpers.errorResponse)(
|
|
258
|
-
`Get table failed: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
259
|
-
"NETWORK_ERROR"
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
);
|
|
264
|
-
server.tool(
|
|
265
|
-
"farseer_get_variable",
|
|
266
|
-
`Get detailed information about a specific variable.
|
|
241
|
+
catch (error) {
|
|
242
|
+
return (0, helpers_1.errorResponse)(`Get table failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
// farseer_get_variable - Get variable details
|
|
246
|
+
server.tool('farseer_get_variable', `Get detailed information about a specific variable.
|
|
267
247
|
|
|
268
248
|
Returns:
|
|
269
249
|
- Dimensions the variable spans
|
|
@@ -274,52 +254,40 @@ Returns:
|
|
|
274
254
|
|
|
275
255
|
This is essential for understanding what dimensions and values are needed for imports.
|
|
276
256
|
|
|
277
|
-
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
257
|
+
If no tenant is specified, uses the currently checked-out tenant.`, getVariableSchema, async (params) => {
|
|
258
|
+
const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
|
|
259
|
+
if (!resolved) {
|
|
260
|
+
return (0, helpers_1.tenantRequiredResponse)();
|
|
261
|
+
}
|
|
262
|
+
const { organisation, tenant } = resolved;
|
|
263
|
+
const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
|
|
264
|
+
if (!clientResult) {
|
|
265
|
+
return (0, helpers_1.authRequiredResponse)(tenant);
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
const model = await clientResult.client.exportModel();
|
|
269
|
+
const variable = model.variables.find((v) => v.name.toLowerCase() === params.variableName.toLowerCase());
|
|
270
|
+
if (!variable) {
|
|
271
|
+
return (0, helpers_1.errorResponse)(`Variable "${params.variableName}" not found`, 'NOT_FOUND');
|
|
272
|
+
}
|
|
273
|
+
return (0, helpers_1.successResponse)({
|
|
274
|
+
tenant,
|
|
275
|
+
variable: {
|
|
276
|
+
name: variable.name,
|
|
277
|
+
description: variable.description,
|
|
278
|
+
formula: variable.formula,
|
|
279
|
+
dimensions: variable.tables || [],
|
|
280
|
+
rollupType: variable.rollupType,
|
|
281
|
+
dataType: variable.dataType,
|
|
282
|
+
numberFormat: variable.numberFormat,
|
|
283
|
+
readonly: variable.readonly,
|
|
284
|
+
calculateOnDemand: variable.calculateOnDemand,
|
|
285
|
+
folderPath: variable.folderPath,
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
return (0, helpers_1.errorResponse)(`Get variable failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
|
|
296
291
|
}
|
|
297
|
-
|
|
298
|
-
tenant,
|
|
299
|
-
variable: {
|
|
300
|
-
name: variable.name,
|
|
301
|
-
description: variable.description,
|
|
302
|
-
formula: variable.formula,
|
|
303
|
-
dimensions: variable.tables || [],
|
|
304
|
-
rollupType: variable.rollupType,
|
|
305
|
-
dataType: variable.dataType,
|
|
306
|
-
numberFormat: variable.numberFormat,
|
|
307
|
-
readonly: variable.readonly,
|
|
308
|
-
calculateOnDemand: variable.calculateOnDemand,
|
|
309
|
-
folderPath: variable.folderPath
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
} catch (error) {
|
|
313
|
-
return (0, import_helpers.errorResponse)(
|
|
314
|
-
`Get variable failed: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
315
|
-
"NETWORK_ERROR"
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
);
|
|
292
|
+
});
|
|
320
293
|
}
|
|
321
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
322
|
-
0 && (module.exports = {
|
|
323
|
-
registerModelTools
|
|
324
|
-
});
|
|
325
|
-
//# sourceMappingURL=modelTools.js.map
|