farseer-cli 1.11.0 → 1.11.2
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 +31 -35
- package/dist/commands/app.js.map +2 -2
- package/dist/commands/dashboards.js +16 -2
- package/dist/commands/dashboards.js.map +2 -2
- package/dist/commands/run.js +10 -12
- package/dist/commands/run.js.map +2 -2
- package/dist/commands/sheets.js +46 -34
- package/dist/commands/sheets.js.map +2 -2
- package/dist/commands/variables.js +7 -1
- package/dist/commands/variables.js.map +2 -2
- package/dist/mcp/tools/appTools.js +35 -20
- package/dist/mcp/tools/appTools.js.map +2 -2
- package/dist/mcp/tools/dashboardTools.js +79 -69
- package/dist/mcp/tools/dashboardTools.js.map +2 -2
- package/dist/mcp/tools/runTools.js +12 -7
- package/dist/mcp/tools/runTools.js.map +2 -2
- package/dist/mcp/tools/sheetTools.js +48 -59
- package/dist/mcp/tools/sheetTools.js.map +2 -2
- package/dist/mcp/utils/helpers.js +75 -0
- package/dist/mcp/utils/helpers.js.map +2 -2
- package/dist/services/farseerService.js +0 -11
- package/dist/services/farseerService.js.map +2 -2
- package/dist/services/modelExport.js +4 -2
- package/dist/services/modelExport.js.map +2 -2
- package/dist/utils/entityResolver.js +114 -28
- package/dist/utils/entityResolver.js.map +2 -2
- package/dist/utils/helpers.js +81 -10
- package/dist/utils/helpers.js.map +3 -3
- package/dist/utils/nameResolver.js +63 -0
- package/dist/utils/nameResolver.js.map +7 -0
- package/package.json +1 -1
package/dist/commands/sheets.js
CHANGED
|
@@ -38,25 +38,12 @@ var import_logger = require("../utils/logger");
|
|
|
38
38
|
var import_authErrors = require("../services/authErrors");
|
|
39
39
|
var import_preflight = require("../services/preflight");
|
|
40
40
|
var import_entityResolver = require("../utils/entityResolver");
|
|
41
|
-
var import_farseer_client = require("farseer-client");
|
|
42
41
|
function registerSheetsCommand(program) {
|
|
43
42
|
const sheetsCmd = program.command("sheets").description("List and inspect sheets");
|
|
44
43
|
sheetsCmd.command("list [org] [tenant]").description("List all sheets").option("--json", "Output raw JSON").action(async (first, second, options) => {
|
|
45
44
|
const { native: nativeClient, tenant } = await (0, import_preflight.preflight)(first, second);
|
|
46
45
|
try {
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
const entities = await nativeClient.entities.getAll([import_farseer_client.EntityType.Sheet]);
|
|
50
|
-
sheets = entities.map((e) => ({
|
|
51
|
-
id: e.id,
|
|
52
|
-
name: e.meta?.name || `Sheet ${e.id}`
|
|
53
|
-
}));
|
|
54
|
-
} catch {
|
|
55
|
-
sheets = [];
|
|
56
|
-
}
|
|
57
|
-
if (sheets.length === 0) {
|
|
58
|
-
sheets = await collectFolderItems(nativeClient, null, [], farseer.FolderItemType.Sheet);
|
|
59
|
-
}
|
|
46
|
+
const sheets = await (0, import_entityResolver.listSheets)(nativeClient);
|
|
60
47
|
if (options.json) {
|
|
61
48
|
console.log(JSON.stringify(sheets, null, 2));
|
|
62
49
|
return;
|
|
@@ -77,11 +64,24 @@ function registerSheetsCommand(program) {
|
|
|
77
64
|
sheetsCmd.command("show <nameOrId> [org] [tenant]").description("Show sheet configuration").option("--json", "Output raw JSON").action(async (nameOrId, first, second, options) => {
|
|
78
65
|
const { native: nativeClient, tenant } = await (0, import_preflight.preflight)(first, second);
|
|
79
66
|
try {
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
67
|
+
const selection = await (0, import_entityResolver.resolveSheet)(nativeClient, nameOrId);
|
|
68
|
+
if (selection.kind === "ambiguous") {
|
|
69
|
+
import_logger.logger.error(
|
|
70
|
+
await (0, import_entityResolver.describeAmbiguity)(
|
|
71
|
+
nativeClient,
|
|
72
|
+
"sheets",
|
|
73
|
+
nameOrId,
|
|
74
|
+
selection.matches,
|
|
75
|
+
farseer.FolderItemType.Sheet
|
|
76
|
+
)
|
|
77
|
+
);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
if (selection.kind === "notFound") {
|
|
82
81
|
import_logger.logger.error(`Sheet "${nameOrId}" not found.`);
|
|
83
82
|
process.exit(1);
|
|
84
83
|
}
|
|
84
|
+
const resolved = selection.entity;
|
|
85
85
|
const sheet = await nativeClient.sheets.get(resolved.id);
|
|
86
86
|
if (options.json) {
|
|
87
87
|
console.log(JSON.stringify(sheet, null, 2));
|
|
@@ -103,11 +103,24 @@ function registerSheetsCommand(program) {
|
|
|
103
103
|
sheetsCmd.command("data <nameOrId> [org] [tenant]").description("Get sheet data").option("--json", "Output raw JSON").option("--limit <n>", "Limit number of rows", parseInt).action(async (nameOrId, first, second, options) => {
|
|
104
104
|
const { native: nativeClient, tenant } = await (0, import_preflight.preflight)(first, second);
|
|
105
105
|
try {
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
106
|
+
const selection = await (0, import_entityResolver.resolveSheet)(nativeClient, nameOrId);
|
|
107
|
+
if (selection.kind === "ambiguous") {
|
|
108
|
+
import_logger.logger.error(
|
|
109
|
+
await (0, import_entityResolver.describeAmbiguity)(
|
|
110
|
+
nativeClient,
|
|
111
|
+
"sheets",
|
|
112
|
+
nameOrId,
|
|
113
|
+
selection.matches,
|
|
114
|
+
farseer.FolderItemType.Sheet
|
|
115
|
+
)
|
|
116
|
+
);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
if (selection.kind === "notFound") {
|
|
108
120
|
import_logger.logger.error(`Sheet "${nameOrId}" not found.`);
|
|
109
121
|
process.exit(1);
|
|
110
122
|
}
|
|
123
|
+
const resolved = selection.entity;
|
|
111
124
|
const sheet = await nativeClient.sheets.get(resolved.id);
|
|
112
125
|
const dataRequest = {
|
|
113
126
|
path: `/${resolved.id}`,
|
|
@@ -143,11 +156,24 @@ function registerSheetsCommand(program) {
|
|
|
143
156
|
sheetsCmd.command("set-data [org] [tenant]").description("Set sheet data from JSON file").requiredOption("--sheet <nameOrId>", "Sheet name or ID").requiredOption("--input <file>", "JSON file with sheet data").option("-y, --yes", "Skip confirmation").action(async (first, second, options) => {
|
|
144
157
|
const { native: nativeClient, tenant } = await (0, import_preflight.preflight)(first, second);
|
|
145
158
|
try {
|
|
146
|
-
const
|
|
147
|
-
if (
|
|
159
|
+
const selection = await (0, import_entityResolver.resolveSheet)(nativeClient, options.sheet);
|
|
160
|
+
if (selection.kind === "ambiguous") {
|
|
161
|
+
import_logger.logger.error(
|
|
162
|
+
await (0, import_entityResolver.describeAmbiguity)(
|
|
163
|
+
nativeClient,
|
|
164
|
+
"sheets",
|
|
165
|
+
options.sheet,
|
|
166
|
+
selection.matches,
|
|
167
|
+
farseer.FolderItemType.Sheet
|
|
168
|
+
)
|
|
169
|
+
);
|
|
170
|
+
process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
if (selection.kind === "notFound") {
|
|
148
173
|
import_logger.logger.error(`Sheet "${options.sheet}" not found.`);
|
|
149
174
|
process.exit(1);
|
|
150
175
|
}
|
|
176
|
+
const resolved = selection.entity;
|
|
151
177
|
if (!fs.existsSync(options.input)) {
|
|
152
178
|
import_logger.logger.error(`File not found: ${options.input}`);
|
|
153
179
|
process.exit(1);
|
|
@@ -169,20 +195,6 @@ function registerSheetsCommand(program) {
|
|
|
169
195
|
}
|
|
170
196
|
});
|
|
171
197
|
}
|
|
172
|
-
async function collectFolderItems(client, folderId, path, itemType) {
|
|
173
|
-
const items = [];
|
|
174
|
-
const results = await client.folders.listItemsBatch([{ id: folderId }]);
|
|
175
|
-
const children = results[0]?.items ?? [];
|
|
176
|
-
for (const child of children) {
|
|
177
|
-
if (child.type === itemType) {
|
|
178
|
-
items.push({ id: child.id, name: child.name, folderPath: path });
|
|
179
|
-
} else if (child.type === farseer.FolderItemType.Folder) {
|
|
180
|
-
const sub = await collectFolderItems(client, child.id, [...path, child.name], itemType);
|
|
181
|
-
items.push(...sub);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return items;
|
|
185
|
-
}
|
|
186
198
|
function handleSheetError(error, tenant) {
|
|
187
199
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
188
200
|
if ((0, import_authErrors.isAuthError)(error)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/sheets.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport * as fs from 'fs';\nimport * as farseer from 'farseer-client';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { showLoginPrompt, isAuthError } from '../services/authErrors';\nimport { preflight } from '../services/preflight';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAoB;AACpB,cAAyB;AACzB,mBAAkB;AAClB,oBAAuB;AACvB,wBAA6C;AAC7C,uBAA0B;AAC1B,
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport * as fs from 'fs';\nimport * as farseer from 'farseer-client';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { showLoginPrompt, isAuthError } from '../services/authErrors';\nimport { preflight } from '../services/preflight';\nimport { resolveSheet, describeAmbiguity, listSheets } from '../utils/entityResolver';\n\nexport function registerSheetsCommand(program: Command): void {\n const sheetsCmd = program.command('sheets').description('List and inspect sheets');\n\n // farseer sheets list [org] [tenant]\n sheetsCmd\n .command('list [org] [tenant]')\n .description('List all sheets')\n .option('--json', 'Output raw JSON')\n .action(async (first, second, options) => {\n const { native: nativeClient, tenant } = await preflight(first, second);\n\n try {\n const sheets = await listSheets(nativeClient);\n\n if (options.json) {\n console.log(JSON.stringify(sheets, null, 2));\n return;\n }\n\n logger.header(`Sheets (${sheets.length})`);\n if (sheets.length === 0) {\n logger.dim(' No sheets found.');\n return;\n }\n for (const sheet of sheets) {\n const folder = sheet.folderPath?.length ? chalk.dim(` (${sheet.folderPath.join(' / ')})`) : '';\n console.log(` ${chalk.dim(String(sheet.id).padEnd(8))} ${chalk.bold(sheet.name)}${folder}`);\n }\n } catch (error) {\n handleSheetError(error, tenant);\n }\n });\n\n // farseer sheets show <nameOrId> [org] [tenant]\n sheetsCmd\n .command('show <nameOrId> [org] [tenant]')\n .description('Show sheet configuration')\n .option('--json', 'Output raw JSON')\n .action(async (nameOrId, first, second, options) => {\n const { native: nativeClient, tenant } = await preflight(first, second);\n\n try {\n const selection = await resolveSheet(nativeClient, nameOrId);\n if (selection.kind === 'ambiguous') {\n logger.error(\n await describeAmbiguity(\n nativeClient,\n 'sheets',\n nameOrId,\n selection.matches,\n farseer.FolderItemType.Sheet,\n ),\n );\n process.exit(1);\n }\n if (selection.kind === 'notFound') {\n logger.error(`Sheet \"${nameOrId}\" not found.`);\n process.exit(1);\n }\n const resolved = selection.entity;\n\n const sheet = await nativeClient.sheets.get(resolved.id);\n\n if (options.json) {\n console.log(JSON.stringify(sheet, null, 2));\n return;\n }\n\n logger.header(`Sheet: ${sheet.name}`);\n console.log(` ID: ${sheet.id}`);\n console.log(` Stacked: ${sheet.stacked}`);\n if (sheet.rows) {\n console.log(` Rows: ${JSON.stringify(sheet.rows)}`);\n }\n if (sheet.columns) {\n console.log(` Columns: ${JSON.stringify(sheet.columns)}`);\n }\n } catch (error) {\n handleSheetError(error, tenant);\n }\n });\n\n // farseer sheets data <nameOrId> [org] [tenant]\n sheetsCmd\n .command('data <nameOrId> [org] [tenant]')\n .description('Get sheet data')\n .option('--json', 'Output raw JSON')\n .option('--limit <n>', 'Limit number of rows', parseInt)\n .action(async (nameOrId, first, second, options) => {\n const { native: nativeClient, tenant } = await preflight(first, second);\n\n try {\n const selection = await resolveSheet(nativeClient, nameOrId);\n if (selection.kind === 'ambiguous') {\n logger.error(\n await describeAmbiguity(\n nativeClient,\n 'sheets',\n nameOrId,\n selection.matches,\n farseer.FolderItemType.Sheet,\n ),\n );\n process.exit(1);\n }\n if (selection.kind === 'notFound') {\n logger.error(`Sheet \"${nameOrId}\" not found.`);\n process.exit(1);\n }\n const resolved = selection.entity;\n\n const sheet = await nativeClient.sheets.get(resolved.id);\n const dataRequest: any = {\n path: `/${resolved.id}`,\n includeData: true,\n stacked: sheet.stacked,\n rows: sheet.rows,\n columns: sheet.columns,\n sharing: sheet.sharing,\n };\n\n const data = await nativeClient.sheets.getData(dataRequest);\n\n if (options.json) {\n console.log(JSON.stringify(data, null, 2));\n return;\n }\n\n logger.header(`Sheet Data: ${resolved.name}`);\n const dataObj = data as any;\n if (dataObj.cells && Array.isArray(dataObj.cells)) {\n const limit = options.limit || dataObj.cells.length;\n const cells = dataObj.cells.slice(0, limit);\n console.log(\n ` Cells: ${cells.length}${dataObj.cells.length > limit ? ` (of ${dataObj.cells.length})` : ''}`,\n );\n for (const cell of cells) {\n console.log(` ${JSON.stringify(cell)}`);\n }\n } else {\n console.log(JSON.stringify(data, null, 2));\n }\n } catch (error) {\n handleSheetError(error, tenant);\n }\n });\n\n // farseer sheets set-data [org] [tenant]\n sheetsCmd\n .command('set-data [org] [tenant]')\n .description('Set sheet data from JSON file')\n .requiredOption('--sheet <nameOrId>', 'Sheet name or ID')\n .requiredOption('--input <file>', 'JSON file with sheet data')\n .option('-y, --yes', 'Skip confirmation')\n .action(async (first, second, options) => {\n const { native: nativeClient, tenant } = await preflight(first, second);\n\n try {\n const selection = await resolveSheet(nativeClient, options.sheet);\n if (selection.kind === 'ambiguous') {\n logger.error(\n await describeAmbiguity(\n nativeClient,\n 'sheets',\n options.sheet,\n selection.matches,\n farseer.FolderItemType.Sheet,\n ),\n );\n process.exit(1);\n }\n if (selection.kind === 'notFound') {\n logger.error(`Sheet \"${options.sheet}\" not found.`);\n process.exit(1);\n }\n const resolved = selection.entity;\n\n if (!fs.existsSync(options.input)) {\n logger.error(`File not found: ${options.input}`);\n process.exit(1);\n }\n\n const inputData = JSON.parse(fs.readFileSync(options.input, 'utf-8'));\n\n if (!options.yes) {\n logger.warning(`This will update data in sheet \"${resolved.name}\" (ID: ${resolved.id}).`);\n logger.dim('Use -y to skip confirmation.');\n process.exit(0);\n }\n\n const setDataRequest: any = {\n sheetId: resolved.id,\n ...inputData,\n };\n\n await nativeClient.sheets.setData(setDataRequest);\n logger.success(`Sheet data updated for \"${resolved.name}\".`);\n } catch (error) {\n handleSheetError(error, tenant);\n }\n });\n}\n\nfunction handleSheetError(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('Sheet not found or tenant not accessible.');\n } else if (errorMessage.includes('ENOTFOUND') || errorMessage.includes('ECONNREFUSED')) {\n logger.error('Failed to connect to Farseer.');\n } else {\n logger.error('Sheet operation failed.');\n logger.dim(errorMessage);\n }\n process.exit(1);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAoB;AACpB,cAAyB;AACzB,mBAAkB;AAClB,oBAAuB;AACvB,wBAA6C;AAC7C,uBAA0B;AAC1B,4BAA4D;AAErD,SAAS,sBAAsB,SAAwB;AAC1D,QAAM,YAAY,QAAQ,QAAQ,QAAQ,EAAE,YAAY,yBAAyB;AAGjF,YACK,QAAQ,qBAAqB,EAC7B,YAAY,iBAAiB,EAC7B,OAAO,UAAU,iBAAiB,EAClC,OAAO,OAAO,OAAO,QAAQ,YAAY;AACtC,UAAM,EAAE,QAAQ,cAAc,OAAO,IAAI,UAAM,4BAAU,OAAO,MAAM;AAEtE,QAAI;AACA,YAAM,SAAS,UAAM,kCAAW,YAAY;AAE5C,UAAI,QAAQ,MAAM;AACd,gBAAQ,IAAI,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAC3C;AAAA,MACJ;AAEA,2BAAO,OAAO,WAAW,OAAO,MAAM,GAAG;AACzC,UAAI,OAAO,WAAW,GAAG;AACrB,6BAAO,IAAI,oBAAoB;AAC/B;AAAA,MACJ;AACA,iBAAW,SAAS,QAAQ;AACxB,cAAM,SAAS,MAAM,YAAY,SAAS,aAAAA,QAAM,IAAI,KAAK,MAAM,W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AQ,KAAK,GAAG;AAC/B,6BAAO,MAAM,mBAAmB,QAAQ,KAAK,EAAE;AAC/C,gBAAQ,KAAK,CAAC;AAAA,MAClB;AAEA,YAAM,YAAY,KAAK,MAAM,GAAG,aAAa,QAAQ,OAAO,OAAO,CAAC;AAEpE,UAAI,CAAC,QAAQ,KAAK;AACd,6BAAO,QAAQ,mCAAmC,SAAS,IAAI,UAAU,SAAS,EAAE,IAAI;AACxF,6BAAO,IAAI,8BAA8B;AACzC,gBAAQ,KAAK,CAAC;AAAA,MAClB;AAEA,YAAM,iBAAsB;AAAA,QACxB,SAAS,SAAS;AAAA,QAClB,GAAG;AAAA,MACP;AAEA,YAAM,aAAa,OAAO,QAAQ,cAAc;AAChD,2BAAO,QAAQ,2BAA2B,SAAS,IAAI,IAAI;AAAA,IAC/D,SAAS,OAAO;AACZ,uBAAiB,OAAO,MAAM;AAAA,IAClC;AAAA,EACJ,CAAC;AACT;AAEA,SAAS,iBAAiB,OAAgB,QAAsB;AAC5D,QAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAE1E,UAAI,+BAAY,KAAK,GAAG;AACpB,2CAAgB,MAAM;AAAA,EAC1B,WAAW,aAAa,SAAS,KAAK,GAAG;AACrC,yBAAO,MAAM,2CAA2C;AAAA,EAC5D,WAAW,aAAa,SAAS,WAAW,KAAK,aAAa,SAAS,cAAc,GAAG;AACpF,yBAAO,MAAM,+BAA+B;AAAA,EAChD,OAAO;AACH,yBAAO,MAAM,yBAAyB;AACtC,yBAAO,IAAI,YAAY;AAAA,EAC3B;AACA,UAAQ,KAAK,CAAC;AAClB;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
|
@@ -34,6 +34,7 @@ module.exports = __toCommonJS(variables_exports);
|
|
|
34
34
|
var fs = __toESM(require("fs"));
|
|
35
35
|
var import_chalk = __toESM(require("chalk"));
|
|
36
36
|
var import_logger = require("../utils/logger");
|
|
37
|
+
var import_nameResolver = require("../utils/nameResolver");
|
|
37
38
|
var import_authErrors = require("../services/authErrors");
|
|
38
39
|
var import_preflight = require("../services/preflight");
|
|
39
40
|
var import_modelExport = require("../services/modelExport");
|
|
@@ -73,7 +74,12 @@ function registerVariablesCommand(program) {
|
|
|
73
74
|
const { tenant, client } = await (0, import_preflight.preflight)();
|
|
74
75
|
try {
|
|
75
76
|
const model = await client.exportModel({ types: ["VAR"] });
|
|
76
|
-
const
|
|
77
|
+
const matches = (0, import_nameResolver.matchByName)(model.variables, name);
|
|
78
|
+
if (matches.length > 1) {
|
|
79
|
+
import_logger.logger.error((0, import_nameResolver.formatAmbiguous)("variables", name, matches, (v) => String(v.gid ?? v.name)));
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
const variable = matches[0];
|
|
77
83
|
if (!variable) {
|
|
78
84
|
import_logger.logger.error(`Variable "${name}" not found.`);
|
|
79
85
|
import_logger.logger.dim("Available variables:");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/variables.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { showLoginPrompt, isAuthError } from '../services/authErrors';\nimport { preflight } from '../services/preflight';\nimport { formatVariableMembers } from '../services/modelExport';\n\nexport function registerVariablesCommand(program: Command): void {\n // farseer variables list\n const variablesCmd = program.command('variables').description('List and manage variables');\n\n variablesCmd\n .command('list [org] [tenant]')\n .description('List all variables')\n .option('--json', 'Output raw JSON')\n .action(async (first, second, options) => {\n const { tenant, client } = await preflight(first, second);\n\n try {\n // VAR-only \u2014 pulling the full dimension member matrix\n // breaks the response limit on large tenants.\n const model = await client.exportModel({ types: ['VAR'] });\n\n if (options.json) {\n console.log(JSON.stringify(model.variables, null, 2));\n return;\n }\n\n logger.header(`Variables (${model.variables.length})`);\n console.log();\n for (const variable of model.variables) {\n const flags = [];\n if (variable.readonly) flags.push('readonly');\n if (variable.calculateOnDemand) flags.push('on-demand');\n const flagStr = flags.length > 0 ? chalk.dim(` [${flags.join(', ')}]`) : '';\n\n console.log(` ${chalk.bold(variable.name)}${flagStr}`);\n console.log(` Dimensions: ${variable.tables.join(', ')}`);\n console.log(` Rollup: ${variable.rollupType} | Type: ${variable.dataType}`);\n if (variable.formula) {\n console.log(\n ` Formula: ${chalk.dim(variable.formula.substring(0, 80))}${variable.formula.length > 80 ? '...' : ''}`,\n );\n }\n console.log();\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer variable details / export (singular)\n const variableCmd = program.command('variable').description('Variable details and export');\n\n variableCmd\n .command('details <name>')\n .description('Show variable details (dimensions, formula, rollup, etc.)')\n .option('--json', 'Output raw JSON')\n .action(async (name, options) => {\n const { tenant, client } = await preflight();\n\n try {\n const model = await client.exportModel({ types: ['VAR'] });\n const variable = model.variables.find((v) => v.name.toLowerCase() === name.toLowerCase());\n\n if (!variable) {\n logger.error(`Variable \"${name}\" not found.`);\n logger.dim('Available variables:');\n model.variables.slice(0, 10).forEach((v) => logger.dim(` - ${v.name}`));\n if (model.variables.length > 10) {\n logger.dim(` ... and ${model.variables.length - 10} more`);\n }\n process.exit(1);\n }\n\n if (options.json) {\n console.log(JSON.stringify(variable, null, 2));\n return;\n }\n\n logger.header(`Variable: ${variable.name}`);\n console.log();\n if (variable.description) {\n console.log(` Description: ${variable.description}`);\n }\n if (variable.formula) {\n console.log(` Formula: ${variable.formula}`);\n }\n console.log(` Dimensions: ${variable.tables.join(', ')}`);\n if (variable.members.length > 0) {\n console.log(` Specific members: ${formatVariableMembers(variable.members)}`);\n }\n console.log(` Roll-up type: ${variable.rollupType}`);\n console.log(` Data type: ${variable.dataType}`);\n if (variable.numberFormat) {\n console.log(\n ` Format: ${variable.numberFormat.type}${variable.numberFormat.formatString ? ` (${variable.numberFormat.formatString})` : ''}`,\n );\n }\n console.log(` Readonly: ${variable.readonly}`);\n console.log(` Calculate on demand: ${variable.calculateOnDemand}`);\n if (variable.folderPath) {\n console.log(` Folder: ${variable.folderPath.join(' / ')}`);\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer variables create [org] [tenant]\n variablesCmd\n .command('create [org] [tenant]')\n .description('Create a new variable')\n .requiredOption('--name <name>', 'Variable name')\n .option('--dimensions <csv>', 'Comma-separated dimension table names')\n .option('--formula <expr>', 'Formula expression')\n .option('--rollup <type>', 'Rollup type (Sum, Average, Min, Max, Last, First, Count)')\n .option('--data-type <type>', 'Data type (Decimal, Integer, Text)', 'Decimal')\n .option('--description <text>', 'Variable description')\n .option('--readonly', 'Set variable as read-only')\n .action(async (first, second, options) => {\n const { native: nativeClient } = await preflight(first, second);\n\n try {\n await nativeClient.initTagMap();\n\n // Resolve dimension table names to IDs\n const tableGids: number[] = [];\n if (options.dimensions) {\n const tableNames = options.dimensions.split(',').map((s: string) => s.trim());\n for (const tableName of tableNames) {\n const table = await nativeClient.getDimensionTable(tableName);\n tableGids.push(table.id);\n }\n }\n\n const createEntity: any = {\n type: 'VAR',\n meta: {\n name: options.name,\n description: options.description || null,\n },\n variable: {\n tableGids,\n rollupType: options.rollup || 'Sum',\n dataType: options.dataType || 'Decimal',\n readonly: options.readonly || false,\n },\n };\n\n if (options.formula) {\n createEntity.calculation = { formula: options.formula };\n }\n\n const result = await nativeClient.entities.mutate({ created: [createEntity] });\n logger.success(`Created variable \"${options.name}\".`);\n if ((result as any).created?.length > 0) {\n logger.dim(` ID: ${(result as any).created[0].id}`);\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n logger.error(`Failed to create variable \"${options.name}\".`);\n logger.dim(errorMessage);\n process.exit(1);\n }\n });\n\n // farseer variables update [org] [tenant]\n variablesCmd\n .command('update [org] [tenant]')\n .description('Update an existing variable')\n .requiredOption('--name <name>', 'Variable name')\n .option('--dimensions <csv>', 'New comma-separated dimension table names (replaces all)')\n .option('--formula <expr>', 'New formula expression')\n .option('--rollup <type>', 'New rollup type')\n .option('--description <text>', 'New description')\n .option('--readonly', 'Set as read-only')\n .option('--no-readonly', 'Set as editable')\n .action(async (first, second, options) => {\n const { native: nativeClient } = await preflight(first, second);\n\n try {\n await nativeClient.initTagMap();\n const variable = await nativeClient.getVariable(options.name);\n\n const updateEntity: any = {\n id: variable.id,\n type: 'VAR',\n };\n\n if (options.description !== undefined) {\n updateEntity.meta = { name: variable.name, description: options.description };\n }\n\n const variableUpdate: any = {};\n if (options.dimensions) {\n const tableNames = options.dimensions.split(',').map((s: string) => s.trim());\n const tableGids: number[] = [];\n for (const tableName of tableNames) {\n const table = await nativeClient.getDimensionTable(tableName);\n tableGids.push(table.id);\n }\n variableUpdate.tableGids = tableGids;\n }\n if (options.rollup) variableUpdate.rollupType = options.rollup;\n if (options.readonly !== undefined) variableUpdate.readonly = options.readonly;\n if (Object.keys(variableUpdate).length > 0) {\n updateEntity.variable = variableUpdate;\n }\n\n if (options.formula !== undefined) {\n updateEntity.calculation = { formula: options.formula };\n }\n\n await nativeClient.entities.mutate({ updated: [updateEntity] });\n logger.success(`Updated variable \"${options.name}\".`);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n logger.error(`Failed to update variable \"${options.name}\".`);\n logger.dim(errorMessage);\n process.exit(1);\n }\n });\n\n variableCmd\n .command('export <name>')\n .description('Export variable data to CSV file')\n .option('--output <file>', 'Output file path')\n .option('--format <format>', 'Output format: csv, json, xlsx', 'csv')\n .option('--limit <n>', 'Limit number of rows', parseInt)\n .action(async (name, options) => {\n const { native: nativeClient, tenant } = await preflight();\n\n try {\n logger.info(`Exporting variable \"${name}\" from ${tenant}...`);\n\n const exportRequest: any = {\n formula: `\"${name}\"`,\n format: options.format || 'csv',\n };\n if (options.limit) {\n exportRequest.limit = options.limit;\n }\n\n const blob = await nativeClient.export.exportFormula(exportRequest);\n const content = await blob.text();\n\n const outputFile =\n options.output || `${name.replace(/[^a-zA-Z0-9_-]/g, '_')}.${options.format || 'csv'}`;\n fs.writeFileSync(outputFile, content, 'utf-8');\n\n logger.success(`Exported to ${outputFile}`);\n const lines = content.split('\\n').filter((l) => l.trim()).length;\n logger.dim(`${lines - 1} data rows`);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n logger.error(`Failed to export variable \"${name}\".`);\n logger.dim(errorMessage);\n process.exit(1);\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 logger.error('Failed to fetch model.');\n logger.dim(errorMessage);\n }\n process.exit(1);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAoB;AAEpB,mBAAkB;AAClB,oBAAuB;AACvB,wBAA6C;AAC7C,uBAA0B;AAC1B,yBAAsC;AAE/B,SAAS,yBAAyB,SAAwB;AAE7D,QAAM,eAAe,QAAQ,QAAQ,WAAW,EAAE,YAAY,2BAA2B;AAEzF,eACK,QAAQ,qBAAqB,EAC7B,YAAY,oBAAoB,EAChC,OAAO,UAAU,iBAAiB,EAClC,OAAO,OAAO,OAAO,QAAQ,YAAY;AACtC,UAAM,EAAE,QAAQ,OAAO,IAAI,UAAM,4BAAU,OAAO,MAAM;AAExD,QAAI;AAGA,YAAM,QAAQ,MAAM,OAAO,YAAY,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;AAEzD,UAAI,QAAQ,MAAM;AACd,gBAAQ,IAAI,KAAK,UAAU,MAAM,WAAW,MAAM,CAAC,CAAC;AACpD;AAAA,MACJ;AAEA,2BAAO,OAAO,cAAc,MAAM,UAAU,MAAM,GAAG;AACrD,cAAQ,IAAI;AACZ,iBAAW,YAAY,MAAM,WAAW;AACpC,cAAM,QAAQ,CAAC;AACf,YAAI,SAAS,SAAU,OAAM,KAAK,UAAU;AAC5C,YAAI,SAAS,kBAAmB,OAAM,KAAK,WAAW;AACtD,cAAM,UAAU,MAAM,SAAS,IAAI,aAAAA,QAAM,IAAI,KAAK,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI;AAEzE,gBAAQ,IAAI,KAAK,aAAAA,QAAM,KAAK,SAAS,IAAI,CAAC,GAAG,OAAO,EAAE;AACtD,gBAAQ,IAAI,mBAAmB,SAAS,OAAO,KAAK,IAAI,CAAC,EAAE;AAC3D,gBAAQ,IAAI,eAAe,SAAS,UAAU,YAAY,SAAS,QAAQ,EAAE;AAC7E,YAAI,SAAS,SAAS;AAClB,kBAAQ;AAAA,YACJ,gBAAgB,aAAAA,QAAM,IAAI,SAAS,QAAQ,UAAU,GAAG,EAAE,CAAC,CAAC,GAAG,SAAS,QAAQ,SAAS,KAAK,QAAQ,EAAE;AAAA,UAC5G;AAAA,QACJ;AACA,gBAAQ,IAAI;AAAA,MAChB;AAAA,IACJ,SAAS,OAAO;AACZ,uBAAiB,OAAO,MAAM;AAAA,IAClC;AAAA,EACJ,CAAC;AAGL,QAAM,cAAc,QAAQ,QAAQ,UAAU,EAAE,YAAY,6BAA6B;AAEzF,cACK,QAAQ,gBAAgB,EACxB,YAAY,2DAA2D,EACvE,OAAO,UAAU,iBAAiB,EAClC,OAAO,OAAO,MAAM,YAAY;AAC7B,UAAM,EAAE,QAAQ,OAAO,IAAI,UAAM,4BAAU;AAE3C,QAAI;AACA,YAAM,QAAQ,MAAM,OAAO,YAAY,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;AACzD,YAAM,WAAW,MAAM,
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { matchByName, formatAmbiguous } from '../utils/nameResolver';\nimport { showLoginPrompt, isAuthError } from '../services/authErrors';\nimport { preflight } from '../services/preflight';\nimport { formatVariableMembers } from '../services/modelExport';\n\nexport function registerVariablesCommand(program: Command): void {\n // farseer variables list\n const variablesCmd = program.command('variables').description('List and manage variables');\n\n variablesCmd\n .command('list [org] [tenant]')\n .description('List all variables')\n .option('--json', 'Output raw JSON')\n .action(async (first, second, options) => {\n const { tenant, client } = await preflight(first, second);\n\n try {\n // VAR-only \u2014 pulling the full dimension member matrix\n // breaks the response limit on large tenants.\n const model = await client.exportModel({ types: ['VAR'] });\n\n if (options.json) {\n console.log(JSON.stringify(model.variables, null, 2));\n return;\n }\n\n logger.header(`Variables (${model.variables.length})`);\n console.log();\n for (const variable of model.variables) {\n const flags = [];\n if (variable.readonly) flags.push('readonly');\n if (variable.calculateOnDemand) flags.push('on-demand');\n const flagStr = flags.length > 0 ? chalk.dim(` [${flags.join(', ')}]`) : '';\n\n console.log(` ${chalk.bold(variable.name)}${flagStr}`);\n console.log(` Dimensions: ${variable.tables.join(', ')}`);\n console.log(` Rollup: ${variable.rollupType} | Type: ${variable.dataType}`);\n if (variable.formula) {\n console.log(\n ` Formula: ${chalk.dim(variable.formula.substring(0, 80))}${variable.formula.length > 80 ? '...' : ''}`,\n );\n }\n console.log();\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer variable details / export (singular)\n const variableCmd = program.command('variable').description('Variable details and export');\n\n variableCmd\n .command('details <name>')\n .description('Show variable details (dimensions, formula, rollup, etc.)')\n .option('--json', 'Output raw JSON')\n .action(async (name, options) => {\n const { tenant, client } = await preflight();\n\n try {\n const model = await client.exportModel({ types: ['VAR'] });\n const matches = matchByName(model.variables, name);\n if (matches.length > 1) {\n logger.error(formatAmbiguous('variables', name, matches, (v) => String(v.gid ?? v.name)));\n process.exit(1);\n }\n const variable = matches[0];\n\n if (!variable) {\n logger.error(`Variable \"${name}\" not found.`);\n logger.dim('Available variables:');\n model.variables.slice(0, 10).forEach((v) => logger.dim(` - ${v.name}`));\n if (model.variables.length > 10) {\n logger.dim(` ... and ${model.variables.length - 10} more`);\n }\n process.exit(1);\n }\n\n if (options.json) {\n console.log(JSON.stringify(variable, null, 2));\n return;\n }\n\n logger.header(`Variable: ${variable.name}`);\n console.log();\n if (variable.description) {\n console.log(` Description: ${variable.description}`);\n }\n if (variable.formula) {\n console.log(` Formula: ${variable.formula}`);\n }\n console.log(` Dimensions: ${variable.tables.join(', ')}`);\n if (variable.members.length > 0) {\n console.log(` Specific members: ${formatVariableMembers(variable.members)}`);\n }\n console.log(` Roll-up type: ${variable.rollupType}`);\n console.log(` Data type: ${variable.dataType}`);\n if (variable.numberFormat) {\n console.log(\n ` Format: ${variable.numberFormat.type}${variable.numberFormat.formatString ? ` (${variable.numberFormat.formatString})` : ''}`,\n );\n }\n console.log(` Readonly: ${variable.readonly}`);\n console.log(` Calculate on demand: ${variable.calculateOnDemand}`);\n if (variable.folderPath) {\n console.log(` Folder: ${variable.folderPath.join(' / ')}`);\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer variables create [org] [tenant]\n variablesCmd\n .command('create [org] [tenant]')\n .description('Create a new variable')\n .requiredOption('--name <name>', 'Variable name')\n .option('--dimensions <csv>', 'Comma-separated dimension table names')\n .option('--formula <expr>', 'Formula expression')\n .option('--rollup <type>', 'Rollup type (Sum, Average, Min, Max, Last, First, Count)')\n .option('--data-type <type>', 'Data type (Decimal, Integer, Text)', 'Decimal')\n .option('--description <text>', 'Variable description')\n .option('--readonly', 'Set variable as read-only')\n .action(async (first, second, options) => {\n const { native: nativeClient } = await preflight(first, second);\n\n try {\n await nativeClient.initTagMap();\n\n // Resolve dimension table names to IDs\n const tableGids: number[] = [];\n if (options.dimensions) {\n const tableNames = options.dimensions.split(',').map((s: string) => s.trim());\n for (const tableName of tableNames) {\n const table = await nativeClient.getDimensionTable(tableName);\n tableGids.push(table.id);\n }\n }\n\n const createEntity: any = {\n type: 'VAR',\n meta: {\n name: options.name,\n description: options.description || null,\n },\n variable: {\n tableGids,\n rollupType: options.rollup || 'Sum',\n dataType: options.dataType || 'Decimal',\n readonly: options.readonly || false,\n },\n };\n\n if (options.formula) {\n createEntity.calculation = { formula: options.formula };\n }\n\n const result = await nativeClient.entities.mutate({ created: [createEntity] });\n logger.success(`Created variable \"${options.name}\".`);\n if ((result as any).created?.length > 0) {\n logger.dim(` ID: ${(result as any).created[0].id}`);\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n logger.error(`Failed to create variable \"${options.name}\".`);\n logger.dim(errorMessage);\n process.exit(1);\n }\n });\n\n // farseer variables update [org] [tenant]\n variablesCmd\n .command('update [org] [tenant]')\n .description('Update an existing variable')\n .requiredOption('--name <name>', 'Variable name')\n .option('--dimensions <csv>', 'New comma-separated dimension table names (replaces all)')\n .option('--formula <expr>', 'New formula expression')\n .option('--rollup <type>', 'New rollup type')\n .option('--description <text>', 'New description')\n .option('--readonly', 'Set as read-only')\n .option('--no-readonly', 'Set as editable')\n .action(async (first, second, options) => {\n const { native: nativeClient } = await preflight(first, second);\n\n try {\n await nativeClient.initTagMap();\n const variable = await nativeClient.getVariable(options.name);\n\n const updateEntity: any = {\n id: variable.id,\n type: 'VAR',\n };\n\n if (options.description !== undefined) {\n updateEntity.meta = { name: variable.name, description: options.description };\n }\n\n const variableUpdate: any = {};\n if (options.dimensions) {\n const tableNames = options.dimensions.split(',').map((s: string) => s.trim());\n const tableGids: number[] = [];\n for (const tableName of tableNames) {\n const table = await nativeClient.getDimensionTable(tableName);\n tableGids.push(table.id);\n }\n variableUpdate.tableGids = tableGids;\n }\n if (options.rollup) variableUpdate.rollupType = options.rollup;\n if (options.readonly !== undefined) variableUpdate.readonly = options.readonly;\n if (Object.keys(variableUpdate).length > 0) {\n updateEntity.variable = variableUpdate;\n }\n\n if (options.formula !== undefined) {\n updateEntity.calculation = { formula: options.formula };\n }\n\n await nativeClient.entities.mutate({ updated: [updateEntity] });\n logger.success(`Updated variable \"${options.name}\".`);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n logger.error(`Failed to update variable \"${options.name}\".`);\n logger.dim(errorMessage);\n process.exit(1);\n }\n });\n\n variableCmd\n .command('export <name>')\n .description('Export variable data to CSV file')\n .option('--output <file>', 'Output file path')\n .option('--format <format>', 'Output format: csv, json, xlsx', 'csv')\n .option('--limit <n>', 'Limit number of rows', parseInt)\n .action(async (name, options) => {\n const { native: nativeClient, tenant } = await preflight();\n\n try {\n logger.info(`Exporting variable \"${name}\" from ${tenant}...`);\n\n const exportRequest: any = {\n formula: `\"${name}\"`,\n format: options.format || 'csv',\n };\n if (options.limit) {\n exportRequest.limit = options.limit;\n }\n\n const blob = await nativeClient.export.exportFormula(exportRequest);\n const content = await blob.text();\n\n const outputFile =\n options.output || `${name.replace(/[^a-zA-Z0-9_-]/g, '_')}.${options.format || 'csv'}`;\n fs.writeFileSync(outputFile, content, 'utf-8');\n\n logger.success(`Exported to ${outputFile}`);\n const lines = content.split('\\n').filter((l) => l.trim()).length;\n logger.dim(`${lines - 1} data rows`);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n logger.error(`Failed to export variable \"${name}\".`);\n logger.dim(errorMessage);\n process.exit(1);\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 logger.error('Failed to fetch model.');\n logger.dim(errorMessage);\n }\n process.exit(1);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAoB;AAEpB,mBAAkB;AAClB,oBAAuB;AACvB,0BAA6C;AAC7C,wBA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G;AACpB,2CAAgB,MAAM;AAAA,EAC1B,WAAW,aAAa,SAAS,KAAK,GAAG;AACrC,yBAAO,MAAM,WAAW,MAAM,gCAAgC;AAAA,EAClE,WAAW,aAAa,SAAS,WAAW,KAAK,aAAa,SAAS,cAAc,GAAG;AACpF,yBAAO,MAAM,+BAA+B;AAAA,EAChD,OAAO;AACH,yBAAO,MAAM,wBAAwB;AACrC,yBAAO,IAAI,YAAY;AAAA,EAC3B;AACA,UAAQ,KAAK,CAAC;AAClB;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
|
@@ -26,12 +26,14 @@ var import_zod = require("zod");
|
|
|
26
26
|
var import_session = require("../utils/session");
|
|
27
27
|
var import_apps = require("../../services/apps");
|
|
28
28
|
var import_helpers = require("../utils/helpers");
|
|
29
|
+
var import_nameResolver = require("../../utils/nameResolver");
|
|
29
30
|
var import_errorFormatter = require("../../utils/errorFormatter");
|
|
30
31
|
const listAppsSchema = {
|
|
31
32
|
details: import_zod.z.boolean().optional().describe("Include full details for each app")
|
|
32
33
|
};
|
|
33
34
|
const getAppSchema = {
|
|
34
|
-
appName: import_zod.z.string().describe("Name of the app (can include spaces)")
|
|
35
|
+
appName: import_zod.z.string().optional().describe("Name of the app (can include spaces). Omit if using appId."),
|
|
36
|
+
appId: import_zod.z.string().optional().describe("Numeric app id \u2014 use instead of appName when names collide.")
|
|
35
37
|
};
|
|
36
38
|
const createAppSchema = {
|
|
37
39
|
appName: import_zod.z.string().describe("Name for the new app")
|
|
@@ -54,7 +56,8 @@ const argumentSchema = import_zod.z.object({
|
|
|
54
56
|
path: ["defaultValue"]
|
|
55
57
|
});
|
|
56
58
|
const configureAppSchema = {
|
|
57
|
-
appName: import_zod.z.string().describe("Name of the app to configure"),
|
|
59
|
+
appName: import_zod.z.string().optional().describe("Name of the app to configure. Omit if using appId."),
|
|
60
|
+
appId: import_zod.z.string().optional().describe("Numeric app id \u2014 use instead of appName when names collide."),
|
|
58
61
|
entrypoint: import_zod.z.string().optional().describe(`Main script filename \u2014 must be a file in the app's source folder (e.g., "index.ts")`),
|
|
59
62
|
sourceFolder: import_zod.z.string().optional().describe(`Source folder the app's scripts come from (path under Files/, e.g. "Scripts/MyApp")`),
|
|
60
63
|
description: import_zod.z.string().optional().describe("App description"),
|
|
@@ -62,7 +65,8 @@ const configureAppSchema = {
|
|
|
62
65
|
newName: import_zod.z.string().optional().describe("Rename the app")
|
|
63
66
|
};
|
|
64
67
|
const deleteAppSchema = {
|
|
65
|
-
appName: import_zod.z.string().describe("Name of the app to delete")
|
|
68
|
+
appName: import_zod.z.string().optional().describe("Name of the app to delete. Omit if using appId."),
|
|
69
|
+
appId: import_zod.z.string().optional().describe("Numeric app id \u2014 use instead of appName when names collide.")
|
|
66
70
|
};
|
|
67
71
|
function registerAppTools(server) {
|
|
68
72
|
const s = server;
|
|
@@ -141,10 +145,14 @@ Returns:
|
|
|
141
145
|
if (!gate.ok) return gate.response;
|
|
142
146
|
const { tenant, client } = gate.session;
|
|
143
147
|
try {
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
148
|
+
const resolution = await (0, import_helpers.resolveAppForMcp)(client, {
|
|
149
|
+
appName: params.appName,
|
|
150
|
+
id: params.appId
|
|
151
|
+
});
|
|
152
|
+
if ("error" in resolution) {
|
|
153
|
+
return resolution.error;
|
|
147
154
|
}
|
|
155
|
+
const app = resolution.app;
|
|
148
156
|
const getAppScripts = app.scriptFiles ?? [];
|
|
149
157
|
const mainScript = getAppScripts.find((s2) => s2.id === app.mainScriptFileId);
|
|
150
158
|
return (0, import_helpers.successResponse)({
|
|
@@ -197,8 +205,8 @@ Scripts should use \`new FarseerClient()\` with no arguments - credentials are i
|
|
|
197
205
|
if (!gate.ok) return gate.response;
|
|
198
206
|
const { tenant, client } = gate.session;
|
|
199
207
|
try {
|
|
200
|
-
const existing = await client.
|
|
201
|
-
if (existing) {
|
|
208
|
+
const existing = (0, import_nameResolver.matchByName)(await client.listApps(), params.appName);
|
|
209
|
+
if (existing.length > 0) {
|
|
202
210
|
return (0, import_helpers.errorResponse)(`App "${params.appName}" already exists`, "VALIDATION_ERROR");
|
|
203
211
|
}
|
|
204
212
|
const app = await client.createApp(params.appName);
|
|
@@ -244,10 +252,14 @@ Important:
|
|
|
244
252
|
if (!gate.ok) return gate.response;
|
|
245
253
|
const { tenant, client } = gate.session;
|
|
246
254
|
try {
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
255
|
+
const resolution = await (0, import_helpers.resolveAppForMcp)(client, {
|
|
256
|
+
appName: params.appName,
|
|
257
|
+
id: params.appId
|
|
258
|
+
});
|
|
259
|
+
if ("error" in resolution) {
|
|
260
|
+
return resolution.error;
|
|
250
261
|
}
|
|
262
|
+
const app = resolution.app;
|
|
251
263
|
const changes = {};
|
|
252
264
|
if (params.newName) {
|
|
253
265
|
changes.name = params.newName;
|
|
@@ -288,9 +300,9 @@ Important:
|
|
|
288
300
|
await client.updateApp(reference, changes, app);
|
|
289
301
|
return (0, import_helpers.successResponse)({
|
|
290
302
|
tenant,
|
|
291
|
-
appName: params.newName ||
|
|
303
|
+
appName: params.newName || app.name,
|
|
292
304
|
updated: Object.keys(changes),
|
|
293
|
-
message: `App "${
|
|
305
|
+
message: `App "${app.name}" configured successfully`
|
|
294
306
|
});
|
|
295
307
|
} catch (error) {
|
|
296
308
|
return (0, import_helpers.errorResponse)(`Configure app failed: ${await (0, import_errorFormatter.formatClientError)(error)}`, "NETWORK_ERROR");
|
|
@@ -310,23 +322,26 @@ This does NOT delete the script files, only the app configuration.`,
|
|
|
310
322
|
if (!gate.ok) return gate.response;
|
|
311
323
|
const { tenant, client } = gate.session;
|
|
312
324
|
try {
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
325
|
+
const resolution = await (0, import_helpers.resolveAppItemForMcp)(client, {
|
|
326
|
+
appName: params.appName,
|
|
327
|
+
id: params.appId
|
|
328
|
+
});
|
|
329
|
+
if ("error" in resolution) {
|
|
330
|
+
return resolution.error;
|
|
317
331
|
}
|
|
332
|
+
const appItem = resolution.item;
|
|
318
333
|
await client.deleteApp(appItem.reference);
|
|
319
334
|
const remaining = await client.listApps();
|
|
320
335
|
if (remaining.some((a) => a.reference === appItem.reference)) {
|
|
321
336
|
return (0, import_helpers.errorResponse)(
|
|
322
|
-
`Delete reported success but "${
|
|
337
|
+
`Delete reported success but "${appItem.name}" is still present`,
|
|
323
338
|
"NETWORK_ERROR"
|
|
324
339
|
);
|
|
325
340
|
}
|
|
326
341
|
return (0, import_helpers.successResponse)({
|
|
327
342
|
tenant,
|
|
328
|
-
deletedApp:
|
|
329
|
-
message: `App "${
|
|
343
|
+
deletedApp: appItem.name,
|
|
344
|
+
message: `App "${appItem.name}" has been deleted`
|
|
330
345
|
});
|
|
331
346
|
} catch (error) {
|
|
332
347
|
return (0, import_helpers.errorResponse)(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/mcp/tools/appTools.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * App Management Tools\n *\n * Tools for managing Farseer apps (Remote Jobs).\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { requireSession } from '../utils/session';\nimport { AppArgument, AppDeleteRefusedError, AppUpdateChanges, applySourceFolderChange } from '../../services/apps';\nimport { successResponse, errorResponse } from '../utils/helpers';\nimport { formatClientError } from '../../utils/errorFormatter';\n\n// Define schemas outside of tool registration to avoid deep type instantiation\nconst listAppsSchema = {\n details: z.boolean().optional().describe('Include full details for each app'),\n};\n\nconst getAppSchema = {\n appName: z.string().describe('Name of the app (can include spaces)'),\n};\n\nconst createAppSchema = {\n appName: z.string().describe('Name for the new app'),\n};\n\nexport const argumentSchema = z\n .object({\n name: z.string(),\n dataType: z.enum(['string', 'boolean']).optional().describe('Data type. Defaults to \"string\" if omitted.'),\n fixed: z\n .boolean()\n .optional()\n .describe('Lock the value at run time so users cannot override it (admin sets, user reads only).'),\n options: z\n .array(z.string())\n .optional()\n .describe('Closed allowed-value set. Only meaningful for string dataType.'),\n defaultValue: z.string().optional(),\n secret: z.boolean().optional().describe('Mask the value in inputs and logs.'),\n })\n // Cross-axis checks mirror the backend's `validateExpectedArguments` so an\n // LLM caller gets pre-request feedback. Backend stays authoritative \u2014 these\n // catch the same shapes earlier, they don't replace the validator.\n .refine(\n (a) => a.dataType !== 'boolean' || a.defaultValue === undefined || ['true', 'false'].includes(a.defaultValue),\n {\n message: 'Boolean argument defaultValue must be \"true\" or \"false\"',\n path: ['defaultValue'],\n },\n )\n .refine((a) => !a.options || a.defaultValue === undefined || a.options.includes(a.defaultValue), {\n message: 'defaultValue must be one of the options',\n path: ['defaultValue'],\n });\n\nconst configureAppSchema = {\n appName: z.string().describe('Name of the app to configure'),\n entrypoint: z\n .string()\n .optional()\n .describe('Main script filename \u2014 must be a file in the app\\'s source folder (e.g., \"index.ts\")'),\n sourceFolder: z\n .string()\n .optional()\n .describe('Source folder the app\\'s scripts come from (path under Files/, e.g. \"Scripts/MyApp\")'),\n description: z.string().optional().describe('App description'),\n arguments: z.array(argumentSchema).optional().describe('App arguments with default values'),\n newName: z.string().optional().describe('Rename the app'),\n};\n\nconst deleteAppSchema = {\n appName: z.string().describe('Name of the app to delete'),\n};\n\nexport function registerAppTools(server: McpServer): void {\n // Cast to avoid TS2589 deep type instantiation with MCP SDK + Zod generics\n const s: any = server;\n\n // farseer_list_apps - List all apps\n s.tool(\n 'farseer_list_apps',\n `List all apps (Remote Jobs) configured on a Farseer tenant.\n\nApps are executable script configurations that include:\n- Entry point script\n- List of included scripts\n- Expected arguments with default values\n\nUse details=true to include full information for each app.`,\n listAppsSchema,\n async (params: { details?: boolean }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const appList = await client.listApps();\n\n if (!params.details) {\n return successResponse({\n tenant,\n totalApps: appList.length,\n apps: appList.map((a) => ({\n name: a.name,\n reference: a.reference,\n })),\n });\n }\n\n // Get full details for each app\n const appsWithDetails = [];\n for (const item of appList) {\n const app = await client.getApp(item.reference);\n if (app) {\n const appScripts = app.scriptFiles ?? [];\n const mainScript = appScripts.find((s) => s.id === app.mainScriptFileId);\n appsWithDetails.push({\n name: app.name,\n id: app.id,\n description: app.description || '',\n entrypoint: mainScript?.name || null,\n scripts: appScripts.map((s) => s.name),\n arguments: app.expectedArguments.map((a) => ({\n name: a.name,\n dataType: a.dataType,\n ...(a.fixed !== undefined ? { fixed: a.fixed } : {}),\n ...(a.options !== undefined ? { options: a.options } : {}),\n ...(a.defaultValue !== undefined ? { defaultValue: a.defaultValue } : {}),\n ...(a.secret !== undefined ? { secret: a.secret } : {}),\n })),\n });\n }\n }\n\n return successResponse({\n tenant,\n totalApps: appsWithDetails.length,\n apps: appsWithDetails,\n });\n } catch (error) {\n return errorResponse(`List apps failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_get_app - Get app details\n s.tool(\n 'farseer_get_app',\n `Get detailed information about a specific Farseer app.\n\nReturns:\n- App name and description\n- Entry point script (main script that runs)\n- List of all included scripts\n- Expected arguments with their default values`,\n getAppSchema,\n async (params: { appName: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const app = await client.getAppByName(params.appName);\n\n if (!app) {\n return errorResponse(`App \"${params.appName}\" not found`, 'NOT_FOUND');\n }\n\n const getAppScripts = app.scriptFiles ?? [];\n const mainScript = getAppScripts.find((s) => s.id === app.mainScriptFileId);\n\n return successResponse({\n tenant,\n app: {\n id: app.id,\n name: app.name,\n description: app.description || '',\n entrypoint: mainScript?.name || null,\n scripts: getAppScripts.map((s) => ({\n id: s.id,\n name: s.name,\n isEntrypoint: s.id === app.mainScriptFileId,\n })),\n arguments: app.expectedArguments.map((a) => ({\n name: a.name,\n dataType: a.dataType,\n ...(a.fixed !== undefined ? { fixed: a.fixed } : {}),\n ...(a.options !== undefined ? { options: a.options } : {}),\n ...(a.defaultValue !== undefined ? { defaultValue: a.defaultValue } : {}),\n ...(a.secret !== undefined ? { secret: a.secret } : {}),\n })),\n status: app.status,\n lastHeartbeat: app.lastHeartbeat,\n },\n });\n } catch (error) {\n return errorResponse(`Get app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_create_app - Create new app\n s.tool(\n 'farseer_create_app',\n `Create a new Farseer app.\n\nA Farseer App is a named configuration that points to a TypeScript script and defines its arguments.\nThe script uses farseer-client to interact with the Farseer API (import data, export reports, etc.).\n\nWorkflow to create a new app:\n1. Write the script at farseer-apps/<tenant>/files/Scripts/<name>.ts\n2. Push the script to remote with farseer_push (scripts must exist on remote first)\n3. Create the app with this tool (farseer_create_app)\n4. Configure it with farseer_configure_app (set entrypoint, scripts, arguments)\n5. Run it with farseer_run_app (CLI injects auth credentials automatically)\n\nScripts should use \\`new FarseerClient()\\` with no arguments - credentials are injected via environment variables by the CLI at runtime.`,\n createAppSchema,\n async (params: { appName: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n // Check if app already exists\n const existing = await client.getAppByName(params.appName);\n if (existing) {\n return errorResponse(`App \"${params.appName}\" already exists`, 'VALIDATION_ERROR');\n }\n\n const app = await client.createApp(params.appName);\n\n return successResponse({\n tenant,\n app: {\n id: app.id,\n name: app.name,\n },\n message: `App \"${params.appName}\" created. Use farseer_configure_app to set entrypoint, scripts, and arguments.`,\n });\n } catch (error) {\n return errorResponse(`Create app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_configure_app - Configure app settings\n s.tool(\n 'farseer_configure_app',\n `Configure an existing Farseer app.\n\nYou can set:\n- sourceFolder: Folder under Files/ the app's scripts come from (e.g. \"Scripts/MyApp\")\n- entrypoint: Main script to execute \u2014 must be a file in the source folder (e.g., \"index.ts\")\n- description: App description\n- arguments: List of expected arguments. Each has a name, optional dataType\n ('string' | 'boolean' \u2014 defaults to 'string'), optional fixed (locks the\n value at run time), optional options (closed allowed-value set, string\n dataType only), optional defaultValue, and optional secret.\n- newName: Rename the app\n\nImportant:\n- The app's scripts are derived from its source folder; the entrypoint must be\n one of those files. To use a script from another folder, set sourceFolder first.\n- Changing sourceFolder to a folder that doesn't contain the current entrypoint\n requires passing entrypoint in the same call.\n- Settings you don't pass are preserved (this only changes what you specify).\n- Arguments are passed to the script as a JSON-encoded FARSEER_ARGS env var\n- Boolean dataType requires defaultValue \u2208 { \"true\", \"false\" }; defaultValue\n must be one of options when options is set`,\n configureAppSchema,\n async (params: {\n appName: string;\n entrypoint?: string;\n sourceFolder?: string;\n description?: string;\n arguments?: Array<{\n name: string;\n dataType?: 'string' | 'boolean';\n fixed?: boolean;\n options?: string[];\n defaultValue?: string;\n secret?: boolean;\n }>;\n newName?: string;\n }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const app = await client.getAppByName(params.appName);\n if (!app) {\n return errorResponse(`App \"${params.appName}\" not found`, 'NOT_FOUND');\n }\n\n // The set of changes. updateApp merges these onto the app's\n // current state, so anything left out here is preserved.\n const changes: AppUpdateChanges = {};\n\n if (params.newName) {\n changes.name = params.newName;\n }\n\n if (params.description !== undefined) {\n changes.description = params.description;\n }\n\n if (params.arguments) {\n // PUT semantics on the backend: this `expectedArguments`\n // array replaces the existing one wholesale. So if the\n // caller supplies a name but omits axes (dataType, fixed,\n // options, secret), we look up the existing arg by name\n // and carry those fields over. Without this merge, a\n // configure_app call that only re-sets defaultValue would\n // silently clear the secret flag or demote a dropdown\n // back to a plain string variable.\n //\n // Lookup is case-insensitive for convenience (caller\n // shouldn't have to remember exact casing to update an\n // existing arg), but on the write we keep the backend's\n // stored casing: validateExpectedArguments on the server\n // is case-sensitive (seen.has(arg.name)), so writing\n // back caller-supplied case would silently rename the\n // arg (e.g. jobName \u2192 JOBNAME) and break the next push.\n const existingByName = new Map(app.expectedArguments.map((e) => [e.name.toLowerCase(), e]));\n changes.expectedArguments = params.arguments.map((a) => {\n const existing = existingByName.get(a.name.toLowerCase());\n const arg: AppArgument = {\n name: existing?.name ?? a.name,\n dataType: a.dataType ?? existing?.dataType ?? 'string',\n };\n const fixed = a.fixed ?? existing?.fixed;\n if (fixed !== undefined) arg.fixed = fixed;\n const options = a.options ?? existing?.options;\n if (options !== undefined) arg.options = options;\n const defaultValue = a.defaultValue ?? existing?.defaultValue;\n if (defaultValue !== undefined) arg.defaultValue = defaultValue;\n const secret = a.secret ?? existing?.secret;\n if (secret !== undefined) arg.secret = secret;\n return arg;\n });\n }\n\n // Source folder + entrypoint. An app's scripts derive from its\n // source folder, and the entrypoint must be one of those files.\n // The decision lives in applySourceFolderChange (shared with the\n // CLI `app configure` command); the 'mcp' caller gets a plain,\n // param-worded error string.\n const sourceFolderError = await applySourceFolderChange(\n client,\n app,\n changes,\n { sourceFolder: params.sourceFolder, entrypoint: params.entrypoint },\n 'mcp',\n );\n if (sourceFolderError) {\n return errorResponse(sourceFolderError, 'VALIDATION_ERROR');\n }\n\n const reference = app.id.toString();\n await client.updateApp(reference, changes, app);\n\n return successResponse({\n tenant,\n appName: params.newName || params.appName,\n updated: Object.keys(changes),\n message: `App \"${params.appName}\" configured successfully`,\n });\n } catch (error) {\n return errorResponse(`Configure app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_delete_app - Delete app\n s.tool(\n 'farseer_delete_app',\n `Delete an app from a Farseer tenant.\n\nWARNING: This is irreversible - the app will be permanently removed from the remote instance.\n\nThis does NOT delete the script files, only the app configuration.`,\n deleteAppSchema,\n async (params: { appName: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const allApps = await client.listApps();\n const appItem = allApps.find((a) => a.name.toLowerCase() === params.appName.toLowerCase());\n if (!appItem) {\n return errorResponse(`App \"${params.appName}\" not found`, 'NOT_FOUND');\n }\n\n await client.deleteApp(appItem.reference);\n\n // The folder API 200s even when nothing was deleted; confirm.\n const remaining = await client.listApps();\n if (remaining.some((a) => a.reference === appItem.reference)) {\n return errorResponse(\n `Delete reported success but \"${params.appName}\" is still present`,\n 'NETWORK_ERROR',\n );\n }\n\n return successResponse({\n tenant,\n deletedApp: params.appName,\n message: `App \"${params.appName}\" has been deleted`,\n });\n } catch (error) {\n // A guard refusal is not retryable \u2014 nothing was deleted and a\n // retry cannot change that. Don't let it read as a transport blip.\n return errorResponse(\n `Delete app failed: ${await formatClientError(error)}`,\n error instanceof AppDeleteRefusedError ? 'VALIDATION_ERROR' : 'NETWORK_ERROR',\n );\n }\n },\n );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iBAAkB;AAClB,qBAA+B;AAC/B,kBAA8F;AAC9F,
|
|
4
|
+
"sourcesContent": ["/**\n * App Management Tools\n *\n * Tools for managing Farseer apps (Remote Jobs).\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { requireSession } from '../utils/session';\nimport { AppArgument, AppDeleteRefusedError, AppUpdateChanges, applySourceFolderChange } from '../../services/apps';\nimport { successResponse, errorResponse, resolveAppItemForMcp, resolveAppForMcp } from '../utils/helpers';\nimport { matchByName } from '../../utils/nameResolver';\nimport { formatClientError } from '../../utils/errorFormatter';\n\n// Define schemas outside of tool registration to avoid deep type instantiation\nconst listAppsSchema = {\n details: z.boolean().optional().describe('Include full details for each app'),\n};\n\nconst getAppSchema = {\n appName: z.string().optional().describe('Name of the app (can include spaces). Omit if using appId.'),\n appId: z.string().optional().describe('Numeric app id \u2014 use instead of appName when names collide.'),\n};\n\nconst createAppSchema = {\n appName: z.string().describe('Name for the new app'),\n};\n\nexport const argumentSchema = z\n .object({\n name: z.string(),\n dataType: z.enum(['string', 'boolean']).optional().describe('Data type. Defaults to \"string\" if omitted.'),\n fixed: z\n .boolean()\n .optional()\n .describe('Lock the value at run time so users cannot override it (admin sets, user reads only).'),\n options: z\n .array(z.string())\n .optional()\n .describe('Closed allowed-value set. Only meaningful for string dataType.'),\n defaultValue: z.string().optional(),\n secret: z.boolean().optional().describe('Mask the value in inputs and logs.'),\n })\n // Cross-axis checks mirror the backend's `validateExpectedArguments` so an\n // LLM caller gets pre-request feedback. Backend stays authoritative \u2014 these\n // catch the same shapes earlier, they don't replace the validator.\n .refine(\n (a) => a.dataType !== 'boolean' || a.defaultValue === undefined || ['true', 'false'].includes(a.defaultValue),\n {\n message: 'Boolean argument defaultValue must be \"true\" or \"false\"',\n path: ['defaultValue'],\n },\n )\n .refine((a) => !a.options || a.defaultValue === undefined || a.options.includes(a.defaultValue), {\n message: 'defaultValue must be one of the options',\n path: ['defaultValue'],\n });\n\nconst configureAppSchema = {\n appName: z.string().optional().describe('Name of the app to configure. Omit if using appId.'),\n appId: z.string().optional().describe('Numeric app id \u2014 use instead of appName when names collide.'),\n entrypoint: z\n .string()\n .optional()\n .describe('Main script filename \u2014 must be a file in the app\\'s source folder (e.g., \"index.ts\")'),\n sourceFolder: z\n .string()\n .optional()\n .describe('Source folder the app\\'s scripts come from (path under Files/, e.g. \"Scripts/MyApp\")'),\n description: z.string().optional().describe('App description'),\n arguments: z.array(argumentSchema).optional().describe('App arguments with default values'),\n newName: z.string().optional().describe('Rename the app'),\n};\n\nconst deleteAppSchema = {\n appName: z.string().optional().describe('Name of the app to delete. Omit if using appId.'),\n appId: z.string().optional().describe('Numeric app id \u2014 use instead of appName when names collide.'),\n};\n\nexport function registerAppTools(server: McpServer): void {\n // Cast to avoid TS2589 deep type instantiation with MCP SDK + Zod generics\n const s: any = server;\n\n // farseer_list_apps - List all apps\n s.tool(\n 'farseer_list_apps',\n `List all apps (Remote Jobs) configured on a Farseer tenant.\n\nApps are executable script configurations that include:\n- Entry point script\n- List of included scripts\n- Expected arguments with default values\n\nUse details=true to include full information for each app.`,\n listAppsSchema,\n async (params: { details?: boolean }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const appList = await client.listApps();\n\n if (!params.details) {\n return successResponse({\n tenant,\n totalApps: appList.length,\n apps: appList.map((a) => ({\n name: a.name,\n reference: a.reference,\n })),\n });\n }\n\n // Get full details for each app\n const appsWithDetails = [];\n for (const item of appList) {\n const app = await client.getApp(item.reference);\n if (app) {\n const appScripts = app.scriptFiles ?? [];\n const mainScript = appScripts.find((s) => s.id === app.mainScriptFileId);\n appsWithDetails.push({\n name: app.name,\n id: app.id,\n description: app.description || '',\n entrypoint: mainScript?.name || null,\n scripts: appScripts.map((s) => s.name),\n arguments: app.expectedArguments.map((a) => ({\n name: a.name,\n dataType: a.dataType,\n ...(a.fixed !== undefined ? { fixed: a.fixed } : {}),\n ...(a.options !== undefined ? { options: a.options } : {}),\n ...(a.defaultValue !== undefined ? { defaultValue: a.defaultValue } : {}),\n ...(a.secret !== undefined ? { secret: a.secret } : {}),\n })),\n });\n }\n }\n\n return successResponse({\n tenant,\n totalApps: appsWithDetails.length,\n apps: appsWithDetails,\n });\n } catch (error) {\n return errorResponse(`List apps failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_get_app - Get app details\n s.tool(\n 'farseer_get_app',\n `Get detailed information about a specific Farseer app.\n\nReturns:\n- App name and description\n- Entry point script (main script that runs)\n- List of all included scripts\n- Expected arguments with their default values`,\n getAppSchema,\n async (params: { appName?: string; appId?: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const resolution = await resolveAppForMcp(client, {\n appName: params.appName,\n id: params.appId,\n });\n if ('error' in resolution) {\n return resolution.error;\n }\n const app = resolution.app;\n\n const getAppScripts = app.scriptFiles ?? [];\n const mainScript = getAppScripts.find((s) => s.id === app.mainScriptFileId);\n\n return successResponse({\n tenant,\n app: {\n id: app.id,\n name: app.name,\n description: app.description || '',\n entrypoint: mainScript?.name || null,\n scripts: getAppScripts.map((s) => ({\n id: s.id,\n name: s.name,\n isEntrypoint: s.id === app.mainScriptFileId,\n })),\n arguments: app.expectedArguments.map((a) => ({\n name: a.name,\n dataType: a.dataType,\n ...(a.fixed !== undefined ? { fixed: a.fixed } : {}),\n ...(a.options !== undefined ? { options: a.options } : {}),\n ...(a.defaultValue !== undefined ? { defaultValue: a.defaultValue } : {}),\n ...(a.secret !== undefined ? { secret: a.secret } : {}),\n })),\n status: app.status,\n lastHeartbeat: app.lastHeartbeat,\n },\n });\n } catch (error) {\n return errorResponse(`Get app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_create_app - Create new app\n s.tool(\n 'farseer_create_app',\n `Create a new Farseer app.\n\nA Farseer App is a named configuration that points to a TypeScript script and defines its arguments.\nThe script uses farseer-client to interact with the Farseer API (import data, export reports, etc.).\n\nWorkflow to create a new app:\n1. Write the script at farseer-apps/<tenant>/files/Scripts/<name>.ts\n2. Push the script to remote with farseer_push (scripts must exist on remote first)\n3. Create the app with this tool (farseer_create_app)\n4. Configure it with farseer_configure_app (set entrypoint, scripts, arguments)\n5. Run it with farseer_run_app (CLI injects auth credentials automatically)\n\nScripts should use \\`new FarseerClient()\\` with no arguments - credentials are injected via environment variables by the CLI at runtime.`,\n createAppSchema,\n async (params: { appName: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n // Any name match means the name is taken \u2014 a collision still counts.\n const existing = matchByName(await client.listApps(), params.appName);\n if (existing.length > 0) {\n return errorResponse(`App \"${params.appName}\" already exists`, 'VALIDATION_ERROR');\n }\n\n const app = await client.createApp(params.appName);\n\n return successResponse({\n tenant,\n app: {\n id: app.id,\n name: app.name,\n },\n message: `App \"${params.appName}\" created. Use farseer_configure_app to set entrypoint, scripts, and arguments.`,\n });\n } catch (error) {\n return errorResponse(`Create app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_configure_app - Configure app settings\n s.tool(\n 'farseer_configure_app',\n `Configure an existing Farseer app.\n\nYou can set:\n- sourceFolder: Folder under Files/ the app's scripts come from (e.g. \"Scripts/MyApp\")\n- entrypoint: Main script to execute \u2014 must be a file in the source folder (e.g., \"index.ts\")\n- description: App description\n- arguments: List of expected arguments. Each has a name, optional dataType\n ('string' | 'boolean' \u2014 defaults to 'string'), optional fixed (locks the\n value at run time), optional options (closed allowed-value set, string\n dataType only), optional defaultValue, and optional secret.\n- newName: Rename the app\n\nImportant:\n- The app's scripts are derived from its source folder; the entrypoint must be\n one of those files. To use a script from another folder, set sourceFolder first.\n- Changing sourceFolder to a folder that doesn't contain the current entrypoint\n requires passing entrypoint in the same call.\n- Settings you don't pass are preserved (this only changes what you specify).\n- Arguments are passed to the script as a JSON-encoded FARSEER_ARGS env var\n- Boolean dataType requires defaultValue \u2208 { \"true\", \"false\" }; defaultValue\n must be one of options when options is set`,\n configureAppSchema,\n async (params: {\n appName?: string;\n appId?: string;\n entrypoint?: string;\n sourceFolder?: string;\n description?: string;\n arguments?: Array<{\n name: string;\n dataType?: 'string' | 'boolean';\n fixed?: boolean;\n options?: string[];\n defaultValue?: string;\n secret?: boolean;\n }>;\n newName?: string;\n }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const resolution = await resolveAppForMcp(client, {\n appName: params.appName,\n id: params.appId,\n });\n if ('error' in resolution) {\n return resolution.error;\n }\n const app = resolution.app;\n\n // The set of changes. updateApp merges these onto the app's\n // current state, so anything left out here is preserved.\n const changes: AppUpdateChanges = {};\n\n if (params.newName) {\n changes.name = params.newName;\n }\n\n if (params.description !== undefined) {\n changes.description = params.description;\n }\n\n if (params.arguments) {\n // PUT semantics on the backend: this `expectedArguments`\n // array replaces the existing one wholesale. So if the\n // caller supplies a name but omits axes (dataType, fixed,\n // options, secret), we look up the existing arg by name\n // and carry those fields over. Without this merge, a\n // configure_app call that only re-sets defaultValue would\n // silently clear the secret flag or demote a dropdown\n // back to a plain string variable.\n //\n // Lookup is case-insensitive for convenience (caller\n // shouldn't have to remember exact casing to update an\n // existing arg), but on the write we keep the backend's\n // stored casing: validateExpectedArguments on the server\n // is case-sensitive (seen.has(arg.name)), so writing\n // back caller-supplied case would silently rename the\n // arg (e.g. jobName \u2192 JOBNAME) and break the next push.\n const existingByName = new Map(app.expectedArguments.map((e) => [e.name.toLowerCase(), e]));\n changes.expectedArguments = params.arguments.map((a) => {\n const existing = existingByName.get(a.name.toLowerCase());\n const arg: AppArgument = {\n name: existing?.name ?? a.name,\n dataType: a.dataType ?? existing?.dataType ?? 'string',\n };\n const fixed = a.fixed ?? existing?.fixed;\n if (fixed !== undefined) arg.fixed = fixed;\n const options = a.options ?? existing?.options;\n if (options !== undefined) arg.options = options;\n const defaultValue = a.defaultValue ?? existing?.defaultValue;\n if (defaultValue !== undefined) arg.defaultValue = defaultValue;\n const secret = a.secret ?? existing?.secret;\n if (secret !== undefined) arg.secret = secret;\n return arg;\n });\n }\n\n // Source folder + entrypoint. An app's scripts derive from its\n // source folder, and the entrypoint must be one of those files.\n // The decision lives in applySourceFolderChange (shared with the\n // CLI `app configure` command); the 'mcp' caller gets a plain,\n // param-worded error string.\n const sourceFolderError = await applySourceFolderChange(\n client,\n app,\n changes,\n { sourceFolder: params.sourceFolder, entrypoint: params.entrypoint },\n 'mcp',\n );\n if (sourceFolderError) {\n return errorResponse(sourceFolderError, 'VALIDATION_ERROR');\n }\n\n const reference = app.id.toString();\n await client.updateApp(reference, changes, app);\n\n return successResponse({\n tenant,\n appName: params.newName || app.name,\n updated: Object.keys(changes),\n message: `App \"${app.name}\" configured successfully`,\n });\n } catch (error) {\n return errorResponse(`Configure app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_delete_app - Delete app\n s.tool(\n 'farseer_delete_app',\n `Delete an app from a Farseer tenant.\n\nWARNING: This is irreversible - the app will be permanently removed from the remote instance.\n\nThis does NOT delete the script files, only the app configuration.`,\n deleteAppSchema,\n async (params: { appName?: string; appId?: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const resolution = await resolveAppItemForMcp(client, {\n appName: params.appName,\n id: params.appId,\n });\n if ('error' in resolution) {\n return resolution.error;\n }\n const appItem = resolution.item;\n\n await client.deleteApp(appItem.reference);\n\n // The folder API 200s even when nothing was deleted; confirm.\n const remaining = await client.listApps();\n if (remaining.some((a) => a.reference === appItem.reference)) {\n return errorResponse(\n `Delete reported success but \"${appItem.name}\" is still present`,\n 'NETWORK_ERROR',\n );\n }\n\n return successResponse({\n tenant,\n deletedApp: appItem.name,\n message: `App \"${appItem.name}\" has been deleted`,\n });\n } catch (error) {\n // A guard refusal is not retryable \u2014 nothing was deleted and a\n // retry cannot change that. Don't let it read as a transport blip.\n return errorResponse(\n `Delete app failed: ${await formatClientError(error)}`,\n error instanceof AppDeleteRefusedError ? 'VALIDATION_ERROR' : 'NETWORK_ERROR',\n );\n }\n },\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iBAAkB;AAClB,qBAA+B;AAC/B,kBAA8F;AAC9F,qBAAuF;AACvF,0BAA4B;AAC5B,4BAAkC;AAGlC,MAAM,iBAAiB;AAAA,EACnB,SAAS,aAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,mCAAmC;AAChF;AAEA,MAAM,eAAe;AAAA,EACjB,SAAS,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,4DAA4D;AAAA,EACpG,OAAO,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,kEAA6D;AACvG;AAEA,MAAM,kBAAkB;AAAA,EACpB,SAAS,aAAE,OAAO,EAAE,SAAS,sBAAsB;AACvD;AAEO,MAAM,iBAAiB,aACzB,OAAO;AAAA,EACJ,MAAM,aAAE,OAAO;AAAA,E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