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,104 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
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 dataTools_exports = {};
|
|
20
|
+
__export(dataTools_exports, {
|
|
21
|
+
registerDataTools: () => registerDataTools
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(dataTools_exports);
|
|
24
|
+
var import_zod = require("zod");
|
|
25
|
+
var import_farseerFactory = require("../../services/farseerFactory");
|
|
26
|
+
var import_helpers = require("../utils/helpers");
|
|
13
27
|
async function extractErrorMessage(error) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return String(error);
|
|
28
|
+
if (error instanceof Error) return error.message;
|
|
29
|
+
if (error && typeof error === "object" && "status" in error && "statusText" in error) {
|
|
30
|
+
const resp = error;
|
|
31
|
+
const body = resp.text ? await resp.text() : "";
|
|
32
|
+
return `HTTP ${resp.status} ${resp.statusText}${body ? ": " + body : ""}`;
|
|
33
|
+
}
|
|
34
|
+
return String(error);
|
|
22
35
|
}
|
|
23
|
-
// Define schemas outside of tool registration to avoid deep type instantiation
|
|
24
36
|
const exportVariableDataSchema = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
variableName: zod_1.z.string().describe('Name of the variable to export'),
|
|
31
|
-
format: zod_1.z.enum(['csv', 'json']).optional().describe('Output format (default: csv)'),
|
|
32
|
-
limit: zod_1.z.number().optional().describe('Maximum number of rows to return'),
|
|
37
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
38
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
39
|
+
variableName: import_zod.z.string().describe("Name of the variable to export"),
|
|
40
|
+
format: import_zod.z.enum(["csv", "json"]).optional().describe("Output format (default: csv)"),
|
|
41
|
+
limit: import_zod.z.number().optional().describe("Maximum number of rows to return")
|
|
33
42
|
};
|
|
34
43
|
const loadVariableDataSchema = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
|
|
40
|
-
variableName: zod_1.z.string().describe('Name of the variable to load'),
|
|
41
|
-
dimensions: zod_1.z.array(zod_1.z.string()).optional().describe('Dimension table names to include as columns in the export'),
|
|
44
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
45
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
46
|
+
variableName: import_zod.z.string().describe("Name of the variable to load"),
|
|
47
|
+
dimensions: import_zod.z.array(import_zod.z.string()).optional().describe("Dimension table names to include as columns in the export")
|
|
42
48
|
};
|
|
43
49
|
const createImportJobSchema = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
.array(zod_1.z.array(zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.null()])))
|
|
68
|
-
.describe('Data rows - each row is an array of values matching column order'),
|
|
69
|
-
labels: zod_1.z
|
|
70
|
-
.array(zod_1.z.string())
|
|
71
|
-
.optional()
|
|
72
|
-
.describe('Labels for grouping import jobs (used by undoPrevious to revert jobs with same labels)'),
|
|
73
|
-
undoPrevious: zod_1.z
|
|
74
|
-
.boolean()
|
|
75
|
-
.optional()
|
|
76
|
-
.describe('Revert previous import jobs with the same labels before committing (default: false)'),
|
|
77
|
-
importDimensions: zod_1.z
|
|
78
|
-
.boolean()
|
|
79
|
-
.optional()
|
|
80
|
-
.describe('Auto-create any missing dimension members before committing (default: false)'),
|
|
81
|
-
overwriteCells: zod_1.z
|
|
82
|
-
.boolean()
|
|
83
|
-
.optional()
|
|
84
|
-
.describe('Overwrite existing cell values (default: false - adds to existing values)'),
|
|
50
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
51
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
52
|
+
title: import_zod.z.string().describe("Import job title (shown in import history)"),
|
|
53
|
+
columns: import_zod.z.array(
|
|
54
|
+
import_zod.z.object({
|
|
55
|
+
type: import_zod.z.enum(["DIMENSION_TABLE", "VARIABLE", "DATE", "DESCRIPTION"]).describe("Column type"),
|
|
56
|
+
dimensionTableName: import_zod.z.string().optional().describe("For DIMENSION_TABLE: name of the dimension table"),
|
|
57
|
+
variableName: import_zod.z.string().optional().describe("For VARIABLE: name of the variable"),
|
|
58
|
+
columnName: import_zod.z.string().optional().describe("Column header name"),
|
|
59
|
+
dateFormat: import_zod.z.string().optional().describe("For DATE: date format string"),
|
|
60
|
+
dimensionsNames: import_zod.z.array(
|
|
61
|
+
import_zod.z.object({
|
|
62
|
+
tableName: import_zod.z.string(),
|
|
63
|
+
memberName: import_zod.z.string()
|
|
64
|
+
})
|
|
65
|
+
).optional().describe("For VARIABLE: fixed dimension members (filters) for this variable column")
|
|
66
|
+
})
|
|
67
|
+
).describe("Column definitions matching the data structure"),
|
|
68
|
+
rows: import_zod.z.array(import_zod.z.array(import_zod.z.union([import_zod.z.string(), import_zod.z.number(), import_zod.z.null()]))).describe("Data rows - each row is an array of values matching column order"),
|
|
69
|
+
labels: import_zod.z.array(import_zod.z.string()).optional().describe("Labels for grouping import jobs (used by undoPrevious to revert jobs with same labels)"),
|
|
70
|
+
undoPrevious: import_zod.z.boolean().optional().describe("Revert previous import jobs with the same labels before committing (default: false)"),
|
|
71
|
+
importDimensions: import_zod.z.boolean().optional().describe("Auto-create any missing dimension members before committing (default: false)"),
|
|
72
|
+
overwriteCells: import_zod.z.boolean().optional().describe("Overwrite existing cell values (default: false - adds to existing values)")
|
|
85
73
|
};
|
|
86
74
|
const createFileSchema = {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
fileName: zod_1.z.string().describe('Name of the file to create or update'),
|
|
93
|
-
folderPath: zod_1.z
|
|
94
|
-
.array(zod_1.z.string())
|
|
95
|
-
.optional()
|
|
96
|
-
.describe('Folder path as array (e.g., ["Files", "Reports"]). Default: ["Files"]'),
|
|
97
|
-
content: zod_1.z.string().describe('File content as text string'),
|
|
75
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
76
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
77
|
+
fileName: import_zod.z.string().describe("Name of the file to create or update"),
|
|
78
|
+
folderPath: import_zod.z.array(import_zod.z.string()).optional().describe('Folder path as array (e.g., ["Files", "Reports"]). Default: ["Files"]'),
|
|
79
|
+
content: import_zod.z.string().describe("File content as text string")
|
|
98
80
|
};
|
|
99
81
|
function registerDataTools(server) {
|
|
100
|
-
|
|
101
|
-
|
|
82
|
+
server.tool(
|
|
83
|
+
"farseer_export_variable_data",
|
|
84
|
+
`Export data from a Farseer variable as CSV or JSON.
|
|
102
85
|
|
|
103
86
|
Uses the ExportApi.exportFormula() method to export variable data.
|
|
104
87
|
The variable name is passed as the formula, and the result contains
|
|
@@ -108,43 +91,48 @@ Returns the raw CSV/JSON text inline so you can analyze it directly.
|
|
|
108
91
|
|
|
109
92
|
Use the 'limit' parameter to restrict row count for large variables.
|
|
110
93
|
|
|
111
|
-
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
94
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
95
|
+
exportVariableDataSchema,
|
|
112
96
|
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
113
97
|
async (params) => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
98
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
99
|
+
if (!resolved) {
|
|
100
|
+
return (0, import_helpers.tenantRequiredResponse)();
|
|
101
|
+
}
|
|
102
|
+
const { organisation, tenant } = resolved;
|
|
103
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
104
|
+
if (!nativeClient) {
|
|
105
|
+
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const exportRequest = {
|
|
109
|
+
formula: params.variableName,
|
|
110
|
+
format: params.format || "csv"
|
|
111
|
+
};
|
|
112
|
+
if (params.limit) {
|
|
113
|
+
exportRequest.limit = params.limit;
|
|
122
114
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
// farseer_load_variable_data - Load variable data with specific dimensions
|
|
147
|
-
server.tool('farseer_load_variable_data', `Load data from a Farseer variable into a structured CSV format.
|
|
115
|
+
const blob = await nativeClient.export.exportFormula(exportRequest);
|
|
116
|
+
const text = await blob.text();
|
|
117
|
+
const lines = text.split("\n").filter((l) => l.trim()).length;
|
|
118
|
+
return (0, import_helpers.successResponse)({
|
|
119
|
+
tenant,
|
|
120
|
+
variable: params.variableName,
|
|
121
|
+
format: params.format || "csv",
|
|
122
|
+
rowCount: Math.max(0, lines - 1),
|
|
123
|
+
data: text
|
|
124
|
+
});
|
|
125
|
+
} catch (error) {
|
|
126
|
+
return (0, import_helpers.errorResponse)(
|
|
127
|
+
`Export variable data failed: ${await extractErrorMessage(error)}`,
|
|
128
|
+
"NETWORK_ERROR"
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
server.tool(
|
|
134
|
+
"farseer_load_variable_data",
|
|
135
|
+
`Load data from a Farseer variable into a structured CSV format.
|
|
148
136
|
|
|
149
137
|
Uses the ExportApi.exportFormula() method to export variable data as CSV.
|
|
150
138
|
Returns all data cells for the variable across all its dimensions.
|
|
@@ -156,40 +144,42 @@ Example usage:
|
|
|
156
144
|
- Load "Revenue" data
|
|
157
145
|
- Load "Revenue" with dimensions ["Product", "Years", "Months"]
|
|
158
146
|
|
|
159
|
-
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
147
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
148
|
+
loadVariableDataSchema,
|
|
160
149
|
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
161
150
|
async (params) => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
151
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
152
|
+
if (!resolved) {
|
|
153
|
+
return (0, import_helpers.tenantRequiredResponse)();
|
|
154
|
+
}
|
|
155
|
+
const { organisation, tenant } = resolved;
|
|
156
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
157
|
+
if (!nativeClient) {
|
|
158
|
+
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
const blob = await nativeClient.export.exportFormula({
|
|
162
|
+
formula: params.variableName,
|
|
163
|
+
format: "csv"
|
|
164
|
+
});
|
|
165
|
+
const text = await blob.text();
|
|
166
|
+
const lines = text.split("\n").filter((l) => l.trim()).length;
|
|
167
|
+
const rowCount = Math.max(0, lines - 1);
|
|
168
|
+
return (0, import_helpers.successResponse)({
|
|
169
|
+
tenant,
|
|
170
|
+
variable: params.variableName,
|
|
171
|
+
dimensions: params.dimensions || "all",
|
|
172
|
+
rowCount,
|
|
173
|
+
data: text
|
|
174
|
+
});
|
|
175
|
+
} catch (error) {
|
|
176
|
+
return (0, import_helpers.errorResponse)(`Load variable data failed: ${await extractErrorMessage(error)}`, "NETWORK_ERROR");
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
server.tool(
|
|
181
|
+
"farseer_create_import_job",
|
|
182
|
+
`Create and execute a complete data import job on a Farseer instance.
|
|
193
183
|
|
|
194
184
|
This tool handles the full import workflow in a single call:
|
|
195
185
|
1. Builds import metadata from column definitions
|
|
@@ -226,96 +216,99 @@ Example columns for importing revenue data:
|
|
|
226
216
|
}
|
|
227
217
|
]
|
|
228
218
|
|
|
229
|
-
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
219
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
220
|
+
createImportJobSchema,
|
|
230
221
|
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
231
222
|
async (params) => {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
223
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
224
|
+
if (!resolved) {
|
|
225
|
+
return (0, import_helpers.tenantRequiredResponse)();
|
|
226
|
+
}
|
|
227
|
+
const { organisation, tenant } = resolved;
|
|
228
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
229
|
+
if (!nativeClient) {
|
|
230
|
+
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
231
|
+
}
|
|
232
|
+
try {
|
|
233
|
+
await nativeClient.initTagMap();
|
|
234
|
+
const {
|
|
235
|
+
title,
|
|
236
|
+
columns,
|
|
237
|
+
rows,
|
|
238
|
+
labels,
|
|
239
|
+
undoPrevious = false,
|
|
240
|
+
importDimensions = false,
|
|
241
|
+
overwriteCells = false
|
|
242
|
+
} = params;
|
|
243
|
+
const metadataColumns = columns.map((col) => {
|
|
244
|
+
switch (col.type) {
|
|
245
|
+
case "DIMENSION_TABLE":
|
|
246
|
+
return {
|
|
247
|
+
type: "DIMENSION_TABLE",
|
|
248
|
+
dimensionTableName: col.dimensionTableName,
|
|
249
|
+
columnName: col.columnName
|
|
250
|
+
};
|
|
251
|
+
case "VARIABLE":
|
|
252
|
+
return {
|
|
253
|
+
type: "VARIABLE",
|
|
254
|
+
variableName: col.variableName,
|
|
255
|
+
columnName: col.columnName || col.variableName,
|
|
256
|
+
dimensionsNames: col.dimensionsNames
|
|
257
|
+
};
|
|
258
|
+
case "DATE":
|
|
259
|
+
return {
|
|
260
|
+
type: "DATE",
|
|
261
|
+
dateFormat: col.dateFormat,
|
|
262
|
+
columnName: col.columnName
|
|
263
|
+
};
|
|
264
|
+
case "DESCRIPTION":
|
|
265
|
+
return {
|
|
266
|
+
type: "DESCRIPTION",
|
|
267
|
+
columnName: col.columnName
|
|
268
|
+
};
|
|
269
|
+
default:
|
|
270
|
+
return {
|
|
271
|
+
type: "NONE",
|
|
272
|
+
columnName: col.columnName
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
const metadata = await nativeClient.buildImportJobMetadata(metadataColumns);
|
|
277
|
+
if (overwriteCells) {
|
|
278
|
+
metadata.overwriteCells = true;
|
|
235
279
|
}
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
280
|
+
const importActions = await nativeClient.createImportJob({
|
|
281
|
+
title,
|
|
282
|
+
metadata,
|
|
283
|
+
labels
|
|
284
|
+
});
|
|
285
|
+
await importActions.addRows(rows);
|
|
286
|
+
await importActions.flushRows();
|
|
287
|
+
if (importDimensions) {
|
|
288
|
+
await importActions.importDimensions();
|
|
240
289
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const { title, columns, rows, labels, undoPrevious = false, importDimensions = false, overwriteCells = false, } = params;
|
|
244
|
-
// Build metadata columns
|
|
245
|
-
const metadataColumns = columns.map((col) => {
|
|
246
|
-
switch (col.type) {
|
|
247
|
-
case 'DIMENSION_TABLE':
|
|
248
|
-
return {
|
|
249
|
-
type: 'DIMENSION_TABLE',
|
|
250
|
-
dimensionTableName: col.dimensionTableName,
|
|
251
|
-
columnName: col.columnName,
|
|
252
|
-
};
|
|
253
|
-
case 'VARIABLE':
|
|
254
|
-
return {
|
|
255
|
-
type: 'VARIABLE',
|
|
256
|
-
variableName: col.variableName,
|
|
257
|
-
columnName: col.columnName || col.variableName,
|
|
258
|
-
dimensionsNames: col.dimensionsNames,
|
|
259
|
-
};
|
|
260
|
-
case 'DATE':
|
|
261
|
-
return {
|
|
262
|
-
type: 'DATE',
|
|
263
|
-
dateFormat: col.dateFormat,
|
|
264
|
-
columnName: col.columnName,
|
|
265
|
-
};
|
|
266
|
-
case 'DESCRIPTION':
|
|
267
|
-
return {
|
|
268
|
-
type: 'DESCRIPTION',
|
|
269
|
-
columnName: col.columnName,
|
|
270
|
-
};
|
|
271
|
-
default:
|
|
272
|
-
return {
|
|
273
|
-
type: 'NONE',
|
|
274
|
-
columnName: col.columnName,
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
// Build metadata
|
|
279
|
-
const metadata = await nativeClient.buildImportJobMetadata(metadataColumns);
|
|
280
|
-
if (overwriteCells) {
|
|
281
|
-
metadata.overwriteCells = true;
|
|
282
|
-
}
|
|
283
|
-
// Create import job
|
|
284
|
-
const importActions = await nativeClient.createImportJob({
|
|
285
|
-
title,
|
|
286
|
-
metadata,
|
|
287
|
-
labels,
|
|
288
|
-
});
|
|
289
|
-
// Add rows
|
|
290
|
-
await importActions.addRows(rows);
|
|
291
|
-
await importActions.flushRows();
|
|
292
|
-
// Import dimensions if needed
|
|
293
|
-
if (importDimensions) {
|
|
294
|
-
await importActions.importDimensions();
|
|
295
|
-
}
|
|
296
|
-
// Undo previous if needed
|
|
297
|
-
if (undoPrevious) {
|
|
298
|
-
await importActions.undoPrevious();
|
|
299
|
-
}
|
|
300
|
-
// Commit
|
|
301
|
-
const report = await importActions.commit();
|
|
302
|
-
return (0, helpers_1.successResponse)({
|
|
303
|
-
tenant,
|
|
304
|
-
title,
|
|
305
|
-
rowCount: rows.length,
|
|
306
|
-
labels: labels || [],
|
|
307
|
-
undoPrevious,
|
|
308
|
-
importDimensions,
|
|
309
|
-
overwriteCells,
|
|
310
|
-
commitReport: report,
|
|
311
|
-
});
|
|
290
|
+
if (undoPrevious) {
|
|
291
|
+
await importActions.undoPrevious();
|
|
312
292
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
293
|
+
const report = await importActions.commit();
|
|
294
|
+
return (0, import_helpers.successResponse)({
|
|
295
|
+
tenant,
|
|
296
|
+
title,
|
|
297
|
+
rowCount: rows.length,
|
|
298
|
+
labels: labels || [],
|
|
299
|
+
undoPrevious,
|
|
300
|
+
importDimensions,
|
|
301
|
+
overwriteCells,
|
|
302
|
+
commitReport: report
|
|
303
|
+
});
|
|
304
|
+
} catch (error) {
|
|
305
|
+
return (0, import_helpers.errorResponse)(`Import job failed: ${await extractErrorMessage(error)}`, "NETWORK_ERROR");
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
server.tool(
|
|
310
|
+
"farseer_create_file",
|
|
311
|
+
`Create or update a file on a Farseer instance.
|
|
319
312
|
|
|
320
313
|
This creates a file in the specified folder on the Farseer file system.
|
|
321
314
|
If a file with the same name already exists in that folder, it will be updated.
|
|
@@ -328,31 +321,41 @@ Common use cases:
|
|
|
328
321
|
- Uploading configuration files
|
|
329
322
|
- Saving processed data outputs
|
|
330
323
|
|
|
331
|
-
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
324
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
325
|
+
createFileSchema,
|
|
326
|
+
async (params) => {
|
|
327
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
328
|
+
if (!resolved) {
|
|
329
|
+
return (0, import_helpers.tenantRequiredResponse)();
|
|
330
|
+
}
|
|
331
|
+
const { organisation, tenant } = resolved;
|
|
332
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
333
|
+
if (!nativeClient) {
|
|
334
|
+
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
335
|
+
}
|
|
336
|
+
try {
|
|
337
|
+
const folderPath = params.folderPath || ["Files"];
|
|
338
|
+
const folder = await nativeClient.getItemByPath(folderPath);
|
|
339
|
+
const buffer = Buffer.from(params.content, "utf-8");
|
|
340
|
+
await nativeClient.createOrUpdateFarseerFile(
|
|
341
|
+
{ name: params.fileName, folderId: folder.id },
|
|
342
|
+
buffer
|
|
343
|
+
);
|
|
344
|
+
return (0, import_helpers.successResponse)({
|
|
345
|
+
tenant,
|
|
346
|
+
fileName: params.fileName,
|
|
347
|
+
folderPath,
|
|
348
|
+
size: buffer.length,
|
|
349
|
+
message: `File "${params.fileName}" created/updated in ${folderPath.join("/")}`
|
|
350
|
+
});
|
|
351
|
+
} catch (error) {
|
|
352
|
+
return (0, import_helpers.errorResponse)(`Create file failed: ${await extractErrorMessage(error)}`, "NETWORK_ERROR");
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
);
|
|
358
356
|
}
|
|
357
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
358
|
+
0 && (module.exports = {
|
|
359
|
+
registerDataTools
|
|
360
|
+
});
|
|
361
|
+
//# sourceMappingURL=dataTools.js.map
|