farseer-cli 1.10.3 → 1.11.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 +5 -0
- package/dist/commands/app.js +41 -42
- package/dist/commands/app.js.map +2 -2
- package/dist/commands/apps.js +3 -3
- package/dist/commands/apps.js.map +2 -2
- package/dist/commands/cells.js +3 -3
- package/dist/commands/cells.js.map +2 -2
- package/dist/commands/config.js +23 -15
- package/dist/commands/config.js.map +2 -2
- package/dist/commands/dashboards.js +3 -3
- package/dist/commands/dashboards.js.map +2 -2
- package/dist/commands/dimensions.js +3 -3
- package/dist/commands/dimensions.js.map +2 -2
- package/dist/commands/files.js +5 -4
- package/dist/commands/files.js.map +2 -2
- package/dist/commands/formula.js +3 -3
- package/dist/commands/formula.js.map +2 -2
- package/dist/commands/list.js +5 -4
- package/dist/commands/list.js.map +2 -2
- package/dist/commands/login.js +6 -5
- package/dist/commands/login.js.map +2 -2
- package/dist/commands/model.js +5 -4
- package/dist/commands/model.js.map +2 -2
- package/dist/commands/push.js +5 -7
- package/dist/commands/push.js.map +2 -2
- package/dist/commands/run.js +13 -15
- package/dist/commands/run.js.map +2 -2
- package/dist/commands/sheets.js +3 -3
- package/dist/commands/sheets.js.map +2 -2
- package/dist/commands/variables.js +5 -4
- package/dist/commands/variables.js.map +2 -2
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +2 -2
- package/dist/mcp/tools/appTools.js +38 -23
- package/dist/mcp/tools/appTools.js.map +2 -2
- package/dist/mcp/tools/dataTools.js +5 -2
- package/dist/mcp/tools/dataTools.js.map +2 -2
- package/dist/mcp/tools/modelTools.js +45 -48
- package/dist/mcp/tools/modelTools.js.map +2 -2
- package/dist/mcp/tools/runTools.js +12 -7
- package/dist/mcp/tools/runTools.js.map +2 -2
- package/dist/mcp/utils/helpers.js +41 -0
- package/dist/mcp/utils/helpers.js.map +2 -2
- package/dist/mcp/utils/session.js +2 -2
- package/dist/mcp/utils/session.js.map +2 -2
- package/dist/services/appSyncService.js.map +1 -1
- package/dist/services/apps.js +149 -0
- package/dist/services/apps.js.map +7 -0
- package/dist/services/authErrors.js +77 -0
- package/dist/services/authErrors.js.map +7 -0
- package/dist/services/configService.js +7 -4
- package/dist/services/configService.js.map +2 -2
- package/dist/services/credentials.js +87 -0
- package/dist/services/credentials.js.map +7 -0
- package/dist/services/farseerService.js +247 -123
- package/dist/services/farseerService.js.map +2 -2
- package/dist/services/httpError.js +35 -0
- package/dist/services/httpError.js.map +7 -0
- package/dist/services/modelExport.js +63 -0
- package/dist/services/modelExport.js.map +7 -0
- package/dist/services/organisation.js +88 -0
- package/dist/services/organisation.js.map +7 -0
- package/dist/services/preflight.js +10 -13
- package/dist/services/preflight.js.map +2 -2
- package/dist/services/syncService.js +2 -2
- package/dist/services/syncService.js.map +2 -2
- package/dist/utils/appResolver.js +63 -0
- package/dist/utils/appResolver.js.map +7 -0
- package/dist/utils/constants.js +2 -5
- package/dist/utils/constants.js.map +2 -2
- package/dist/utils/fileLogger.js +24 -1
- package/dist/utils/fileLogger.js.map +2 -2
- package/dist/utils/folderMatch.js +49 -0
- package/dist/utils/folderMatch.js.map +7 -0
- package/dist/utils/helpers.js +98 -1
- package/dist/utils/helpers.js.map +3 -3
- package/dist/utils/syncScope.js +44 -0
- package/dist/utils/syncScope.js.map +7 -0
- package/docs/api-reference.md +13 -1
- package/package.json +1 -1
- package/dist/services/farseerApi.js +0 -716
- package/dist/services/farseerApi.js.map +0 -7
- package/dist/services/farseerFactory.js +0 -276
- package/dist/services/farseerFactory.js.map +0 -7
|
@@ -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/farseerFactory';\nimport { preflight } from '../services/preflight';\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: ${variable.members.join(', ')}`);\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,
|
|
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,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
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
package/dist/mcp/index.js
CHANGED
|
@@ -29,7 +29,7 @@ var import_fileLogger = require("../utils/fileLogger");
|
|
|
29
29
|
async function startMcpServer(options = {}) {
|
|
30
30
|
process.env.FARSEER_MCP = "1";
|
|
31
31
|
import_fileLogger.fileLogger.init();
|
|
32
|
-
import_fileLogger.fileLogger.installCrashHandlers();
|
|
32
|
+
import_fileLogger.fileLogger.installCrashHandlers({ exitOnRejection: false });
|
|
33
33
|
import_fileLogger.fileLogger.log("mcp", "MCP server starting");
|
|
34
34
|
const pin = (0, import_launchPin.resolveLaunchPin)(options, process.env);
|
|
35
35
|
if (pin) {
|
package/dist/mcp/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mcp/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * MCP Server Entry Point\n *\n * Starts the Farseer MCP server for AI assistant integration.\n * Uses stdio transport for CLI compatibility.\n */\n\nimport { createMcpServer } from './server';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { setLaunchTenant } from './utils/tenantPin';\nimport { resolveLaunchPin } from './utils/launchPin';\nimport type { McpServerOptions } from './utils/launchPin';\nimport { fileLogger } from '../utils/fileLogger';\n\nexport type { McpServerOptions };\n\nexport async function startMcpServer(options: McpServerOptions = {}): Promise<void> {\n // Signal MCP context so logger and progress output avoid stdout\n process.env.FARSEER_MCP = '1';\n\n // Initialize file logging (crash handlers especially important for long-lived MCP process)\n fileLogger.init();\n fileLogger.installCrashHandlers();\n fileLogger.log('mcp', 'MCP server starting');\n\n // Bind this server to a single tenant for its lifetime if one was supplied at\n // launch \u2014 via --tenant/--org, or the FARSEER_TENANT/FARSEER_ORG env (the\n // channel Mindseer already uses). The pin lives only in memory; the global\n // checkout in ~/.farseer/config.json is never read or written, so it can't\n // collide with the CLI or with other concurrent servers. Launched without a\n // tenant, the server connects unbound and an agent binds it once via\n // farseer_select_tenant.\n const pin = resolveLaunchPin(options, process.env);\n if (pin) {\n setLaunchTenant(pin);\n fileLogger.log('mcp', `Launch-pinned to tenant ${pin.tenant} (org ${pin.organisation})`);\n } else {\n fileLogger.log('mcp', 'Started without a tenant; awaiting farseer_select_tenant');\n }\n\n const server = createMcpServer();\n\n // Use stdio transport for CLI integration\n const transport = new StdioServerTransport();\n await server.connect(transport);\n\n fileLogger.log('mcp', 'MCP server connected');\n // Log to stderr since stdout is reserved for MCP protocol\n console.error('Farseer MCP server started');\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,oBAAgC;AAChC,mBAAqC;AACrC,uBAAgC;AAChC,uBAAiC;AAEjC,wBAA2B;AAI3B,eAAsB,eAAe,UAA4B,CAAC,GAAkB;AAEhF,UAAQ,IAAI,cAAc;AAG1B,+BAAW,KAAK;
|
|
4
|
+
"sourcesContent": ["/**\n * MCP Server Entry Point\n *\n * Starts the Farseer MCP server for AI assistant integration.\n * Uses stdio transport for CLI compatibility.\n */\n\nimport { createMcpServer } from './server';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { setLaunchTenant } from './utils/tenantPin';\nimport { resolveLaunchPin } from './utils/launchPin';\nimport type { McpServerOptions } from './utils/launchPin';\nimport { fileLogger } from '../utils/fileLogger';\n\nexport type { McpServerOptions };\n\nexport async function startMcpServer(options: McpServerOptions = {}): Promise<void> {\n // Signal MCP context so logger and progress output avoid stdout\n process.env.FARSEER_MCP = '1';\n\n // Initialize file logging (crash handlers especially important for long-lived MCP process)\n fileLogger.init();\n // Each tool already answers its caller, so a rejection that got past one is\n // logged rather than made fatal to every other conversation in the session.\n fileLogger.installCrashHandlers({ exitOnRejection: false });\n fileLogger.log('mcp', 'MCP server starting');\n\n // Bind this server to a single tenant for its lifetime if one was supplied at\n // launch \u2014 via --tenant/--org, or the FARSEER_TENANT/FARSEER_ORG env (the\n // channel Mindseer already uses). The pin lives only in memory; the global\n // checkout in ~/.farseer/config.json is never read or written, so it can't\n // collide with the CLI or with other concurrent servers. Launched without a\n // tenant, the server connects unbound and an agent binds it once via\n // farseer_select_tenant.\n const pin = resolveLaunchPin(options, process.env);\n if (pin) {\n setLaunchTenant(pin);\n fileLogger.log('mcp', `Launch-pinned to tenant ${pin.tenant} (org ${pin.organisation})`);\n } else {\n fileLogger.log('mcp', 'Started without a tenant; awaiting farseer_select_tenant');\n }\n\n const server = createMcpServer();\n\n // Use stdio transport for CLI integration\n const transport = new StdioServerTransport();\n await server.connect(transport);\n\n fileLogger.log('mcp', 'MCP server connected');\n // Log to stderr since stdout is reserved for MCP protocol\n console.error('Farseer MCP server started');\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,oBAAgC;AAChC,mBAAqC;AACrC,uBAAgC;AAChC,uBAAiC;AAEjC,wBAA2B;AAI3B,eAAsB,eAAe,UAA4B,CAAC,GAAkB;AAEhF,UAAQ,IAAI,cAAc;AAG1B,+BAAW,KAAK;AAGhB,+BAAW,qBAAqB,EAAE,iBAAiB,MAAM,CAAC;AAC1D,+BAAW,IAAI,OAAO,qBAAqB;AAS3C,QAAM,UAAM,mCAAiB,SAAS,QAAQ,GAAG;AACjD,MAAI,KAAK;AACL,0CAAgB,GAAG;AACnB,iCAAW,IAAI,OAAO,2BAA2B,IAAI,MAAM,SAAS,IAAI,YAAY,GAAG;AAAA,EAC3F,OAAO;AACH,iCAAW,IAAI,OAAO,0DAA0D;AAAA,EACpF;AAEA,QAAM,aAAS,+BAAgB;AAG/B,QAAM,YAAY,IAAI,kCAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAE9B,+BAAW,IAAI,OAAO,sBAAsB;AAE5C,UAAQ,MAAM,4BAA4B;AAC9C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -24,14 +24,16 @@ __export(appTools_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(appTools_exports);
|
|
25
25
|
var import_zod = require("zod");
|
|
26
26
|
var import_session = require("../utils/session");
|
|
27
|
-
var
|
|
27
|
+
var import_apps = require("../../services/apps");
|
|
28
28
|
var import_helpers = require("../utils/helpers");
|
|
29
|
+
var import_appResolver = require("../../utils/appResolver");
|
|
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_appResolver.matchApps)(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;
|
|
@@ -274,7 +286,7 @@ Important:
|
|
|
274
286
|
return arg;
|
|
275
287
|
});
|
|
276
288
|
}
|
|
277
|
-
const sourceFolderError = await (0,
|
|
289
|
+
const sourceFolderError = await (0, import_apps.applySourceFolderChange)(
|
|
278
290
|
client,
|
|
279
291
|
app,
|
|
280
292
|
changes,
|
|
@@ -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,28 +322,31 @@ 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)(
|
|
333
348
|
`Delete app failed: ${await (0, import_errorFormatter.formatClientError)(error)}`,
|
|
334
|
-
error instanceof
|
|
349
|
+
error instanceof import_apps.AppDeleteRefusedError ? "VALIDATION_ERROR" : "NETWORK_ERROR"
|
|
335
350
|
);
|
|
336
351
|
}
|
|
337
352
|
}
|
|
@@ -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 {\n AppArgument,\n AppDeleteRefusedError,\n AppUpdateChanges,\n applySourceFolderChange,\n} from '../../services/farseerApi';\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,
|
|
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 { matchApps } from '../../utils/appResolver';\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 = matchApps(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,yBAA0B;AAC1B,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,OAA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EAAE,QAAQ,OAAO,IAAI,KAAK;AAEhC,UAAI;AACA,cAAM,aAAa,UAAM,qCAAqB,QAAQ;AAAA,UAClD,SAAS,OAAO;AAAA,UAChB,IAAI,OAAO;AAAA,QACf,CAAC;AACD,YAAI,WAAW,YAAY;AACvB,iBAAO,WAAW;AAAA,QACtB;AACA,cAAM,UAAU,WAAW;AAE3B,cAAM,OAAO,UAAU,QAAQ,SAAS;AAGxC,cAAM,YAAY,MAAM,OAAO,SAAS;AACxC,YAAI,UAAU,KAAK,CAAC,MAAM,EAAE,cAAc,QAAQ,SAAS,GAAG;AAC1D,qBAAO;AAAA,YACH,gCAAgC,QAAQ,IAAI;AAAA,YAC5C;AAAA,UACJ;AAAA,QACJ;AAEA,mBAAO,gCAAgB;AAAA,UACnB;AAAA,UACA,YAAY,QAAQ;AAAA,UACpB,SAAS,QAAQ,QAAQ,IAAI;AAAA,QACjC,CAAC;AAAA,MACL,SAAS,OAAO;AAGZ,mBAAO;AAAA,UACH,sBAAsB,UAAM,yCAAkB,KAAK,CAAC;AAAA,UACpD,iBAAiB,oCAAwB,qBAAqB;AAAA,QAClE;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;",
|
|
6
6
|
"names": ["s"]
|
|
7
7
|
}
|
|
@@ -322,10 +322,13 @@ Common use cases:
|
|
|
322
322
|
async (params) => {
|
|
323
323
|
const gate = await (0, import_session.requireSession)();
|
|
324
324
|
if (!gate.ok) return gate.response;
|
|
325
|
-
const { tenant, native: nativeClient } = gate.session;
|
|
325
|
+
const { tenant, client, native: nativeClient } = gate.session;
|
|
326
326
|
try {
|
|
327
327
|
const folderPath = params.folderPath || ["Files"];
|
|
328
|
-
const folder = await
|
|
328
|
+
const folder = await client.getFolderByPath(folderPath);
|
|
329
|
+
if (!folder) {
|
|
330
|
+
return (0, import_helpers.errorResponse)(`Folder "${folderPath.join("/")}" not found`, "NOT_FOUND");
|
|
331
|
+
}
|
|
329
332
|
const buffer = Buffer.from(params.content, "utf-8");
|
|
330
333
|
await nativeClient.createOrUpdateFarseerFile(
|
|
331
334
|
{ name: params.fileName, folderId: folder.id },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/mcp/tools/dataTools.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Data Operation Tools\n *\n * MCP tools for data export, import jobs, and file management on Farseer instances.\n * These use the native farseer-client for full API access.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as os from 'os';\nimport * as farseer from 'farseer-client';\nimport { requireSession } from '../utils/session';\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 exportVariableDataSchema = {\n variableName: z.string().describe('Name of the variable to export'),\n filters: z\n .array(z.array(z.string()).length(2))\n .optional()\n .describe(\n 'Dimension filters as [tableName, memberName] pairs (e.g., [[\"Months\",\"M1\"],[\"Brand\",\"0000032\"]]). Filters the export to specific dimension members.',\n ),\n format: z.enum(['csv', 'json']).optional().describe('Output format (default: csv)'),\n limit: z.number().optional().describe('Maximum number of rows to return'),\n};\n\nconst loadVariableDataSchema = {\n variableName: z.string().describe('Name of the variable to load'),\n dimensions: z.array(z.string()).optional().describe('Dimension table names to include as columns in the export'),\n};\n\nconst createImportJobSchema = {\n title: z.string().describe('Import job title (shown in import history)'),\n columns: z\n .array(\n z.object({\n type: z.enum(['DIMENSION_TABLE', 'VARIABLE', 'DATE', 'DESCRIPTION']).describe('Column type'),\n dimensionTableName: z.string().optional().describe('For DIMENSION_TABLE: name of the dimension table'),\n variableName: z.string().optional().describe('For VARIABLE: name of the variable'),\n columnName: z.string().optional().describe('Column header name'),\n dateFormat: z.string().optional().describe('For DATE: date format string'),\n dimensionsNames: z\n .array(\n z.object({\n tableName: z.string(),\n memberName: z.string(),\n }),\n )\n .optional()\n .describe('For VARIABLE: fixed dimension members (filters) for this variable column'),\n }),\n )\n .describe('Column definitions matching the data structure'),\n rows: z\n .array(z.array(z.union([z.string(), z.number(), z.null()])))\n .describe('Data rows - each row is an array of values matching column order'),\n labels: z\n .array(z.string())\n .optional()\n .describe('Labels for grouping import jobs (used by undoPrevious to revert jobs with same labels)'),\n undoPrevious: z\n .boolean()\n .optional()\n .describe('Revert previous import jobs with the same labels before committing (default: false)'),\n importDimensions: z\n .boolean()\n .optional()\n .describe('Auto-create any missing dimension members before committing (default: false)'),\n overwriteCells: z\n .boolean()\n .optional()\n .describe('Overwrite existing cell values (default: false - adds to existing values)'),\n};\n\nconst createFileSchema = {\n fileName: z.string().describe('Name of the file to create or update'),\n folderPath: z\n .array(z.string())\n .optional()\n .describe('Folder path as array (e.g., [\"Files\", \"Reports\"]). Default: [\"Files\"]'),\n content: z.string().describe('File content as text string'),\n};\n\nexport function registerDataTools(server: McpServer): void {\n // farseer_export_variable_data - Export variable data\n server.tool(\n 'farseer_export_variable_data',\n `Export data from a Farseer variable as CSV.\n\nBuilds an export configuration from the variable's dimensions and uses\nthe evaluator export endpoint. Works on all server versions.\n\nFor small results (under 500 rows), returns data inline.\nFor large results (500+ rows), automatically exports to a temp file and returns the path \u2014\nuse the Read tool to inspect the file contents.\n\nUse the 'limit' parameter to restrict row count for large variables.`,\n exportVariableDataSchema,\n // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas\n async (params: {\n variableName: string;\n filters?: Array<Array<string>>;\n format?: 'csv' | 'json';\n limit?: number;\n }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const text = await exportVariableAsCsv(nativeClient, params.variableName, params.limit, params.filters);\n\n const lines = text.split('\\n').filter((l) => l.trim());\n const rowCount = Math.max(0, lines.length - 1);\n\n const CSV_THRESHOLD = 500;\n\n // Large result \u2014 export to file\n if (rowCount >= CSV_THRESHOLD) {\n const tmpDir = os.tmpdir();\n const safeName = params.variableName.replace(/[^a-zA-Z0-9_-]/g, '_');\n const filePath = path.join(tmpDir, `farseer_${tenant}_${safeName}.csv`);\n fs.writeFileSync(filePath, text, 'utf-8');\n\n const previewLines = lines.slice(0, 6).join('\\n');\n\n return successResponse({\n tenant,\n variable: params.variableName,\n format: 'csv',\n rowCount,\n exportedToFile: filePath,\n message: `Variable has ${rowCount} rows \u2014 exported to file. Use Read tool to inspect.`,\n preview: previewLines,\n });\n }\n\n return successResponse({\n tenant,\n variable: params.variableName,\n format: 'csv',\n rowCount,\n data: text,\n });\n } catch (error) {\n return errorResponse(`Export variable data failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_load_variable_data - Load variable data with specific dimensions\n server.tool(\n 'farseer_load_variable_data',\n `Load data from a Farseer variable into a structured CSV format.\n\nExports all data cells for the variable. You can optionally filter to\nspecific dimensions only.\n\nFor small results (under 500 rows), returns data inline.\nFor large results (500+ rows), automatically exports to a temp CSV file and returns the path.\n\nExample usage:\n- Load \"Revenue\" data (all dimensions)\n- Load \"Revenue\" with dimensions [\"Product\", \"Years\", \"Months\"]`,\n loadVariableDataSchema,\n // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas\n async (params: { variableName: string; dimensions?: string[] }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const text = await exportVariableAsCsv(nativeClient, params.variableName);\n\n const lines = text.split('\\n').filter((l) => l.trim());\n const rowCount = Math.max(0, lines.length - 1);\n\n const CSV_THRESHOLD = 500;\n\n // Large result \u2014 export to file\n if (rowCount >= CSV_THRESHOLD) {\n const tmpDir = os.tmpdir();\n const safeName = params.variableName.replace(/[^a-zA-Z0-9_-]/g, '_');\n const filePath = path.join(tmpDir, `farseer_${tenant}_${safeName}_data.csv`);\n fs.writeFileSync(filePath, text, 'utf-8');\n\n const previewLines = lines.slice(0, 6).join('\\n');\n\n return successResponse({\n tenant,\n variable: params.variableName,\n dimensions: params.dimensions || 'all',\n rowCount,\n exportedToFile: filePath,\n message: `Variable has ${rowCount} rows \u2014 exported to CSV. Use Read tool to inspect.`,\n preview: previewLines,\n });\n }\n\n return successResponse({\n tenant,\n variable: params.variableName,\n dimensions: params.dimensions || 'all',\n rowCount,\n data: text,\n });\n } catch (error) {\n return errorResponse(`Load variable data failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_create_import_job - Create and execute import job\n server.tool(\n 'farseer_create_import_job',\n `Create and execute a complete data import job on a Farseer instance.\n\nThis tool handles the full import workflow in a single call:\n1. Builds import metadata from column definitions\n2. Creates the import job\n3. Adds all data rows\n4. Optionally creates missing dimension members (importDimensions)\n5. Optionally reverts previous imports with same labels (undoPrevious)\n6. Commits the import\n\nColumn types:\n- DIMENSION_TABLE: Maps to a dimension table (e.g., Product, Years, Months)\n- VARIABLE: Maps to a variable that will receive data values\n - Can include dimensionsNames to fix specific dimension members for this column\n- DATE: Date column with format string\n- DESCRIPTION: Cell description/comment\n\nThe 'labels' parameter is important for the undoPrevious feature:\nwhen undoPrevious is true, all previously committed imports with the\nsame labels will be reverted before this import is committed.\nThis is useful for idempotent re-imports.\n\nThe 'overwriteCells' parameter controls whether existing values are\noverwritten (true) or accumulated (false, default).\n\nExample columns for importing revenue data:\n[\n { \"type\": \"DIMENSION_TABLE\", \"dimensionTableName\": \"Product\" },\n { \"type\": \"DIMENSION_TABLE\", \"dimensionTableName\": \"Years\" },\n { \"type\": \"DIMENSION_TABLE\", \"dimensionTableName\": \"Months\" },\n { \"type\": \"VARIABLE\", \"variableName\": \"Revenue\",\n \"dimensionsNames\": [\n { \"tableName\": \"Versions\", \"memberName\": \"Actual\" }\n ]\n }\n]`,\n createImportJobSchema,\n // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas\n async (params: {\n title: string;\n columns: Array<{\n type: 'DIMENSION_TABLE' | 'VARIABLE' | 'DATE' | 'DESCRIPTION';\n dimensionTableName?: string;\n variableName?: string;\n columnName?: string;\n dateFormat?: string;\n dimensionsNames?: Array<{ tableName: string; memberName: string }>;\n }>;\n rows: Array<Array<string | number | null>>;\n labels?: string[];\n undoPrevious?: boolean;\n importDimensions?: boolean;\n overwriteCells?: boolean;\n }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n await nativeClient.initTagMap();\n\n const {\n title,\n columns,\n rows,\n labels,\n undoPrevious = false,\n importDimensions = false,\n overwriteCells = false,\n } = params;\n\n // Build metadata columns\n const metadataColumns = columns.map((col) => {\n switch (col.type) {\n case 'DIMENSION_TABLE':\n return {\n type: 'DIMENSION_TABLE' as const,\n dimensionTableName: col.dimensionTableName!,\n columnName: col.columnName,\n };\n case 'VARIABLE':\n return {\n type: 'VARIABLE' as const,\n variableName: col.variableName!,\n columnName: col.columnName || col.variableName!,\n dimensionsNames: col.dimensionsNames,\n };\n case 'DATE':\n return {\n type: 'DATE' as const,\n dateFormat: col.dateFormat!,\n columnName: col.columnName,\n };\n case 'DESCRIPTION':\n return {\n type: 'DESCRIPTION' as const,\n columnName: col.columnName,\n };\n default:\n return {\n type: 'NONE' as const,\n columnName: col.columnName,\n };\n }\n });\n\n // Build metadata\n const metadata = await nativeClient.buildImportJobMetadata(metadataColumns as any);\n\n if (overwriteCells) {\n (metadata as any).overwriteCells = true;\n }\n\n // Create import job\n const importActions = await nativeClient.createImportJob({\n title,\n metadata,\n labels,\n });\n\n // Add rows\n await importActions.addRows(rows as any);\n await importActions.flushRows();\n\n // Import dimensions if needed\n if (importDimensions) {\n await importActions.importDimensions();\n }\n\n // Undo previous if needed\n if (undoPrevious) {\n await importActions.undoPrevious();\n }\n\n // Commit\n const report = await importActions.commit();\n\n return successResponse({\n tenant,\n title,\n rowCount: rows.length,\n labels: labels || [],\n undoPrevious,\n importDimensions,\n overwriteCells,\n commitReport: report,\n });\n } catch (error) {\n return errorResponse(`Import job failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_create_file - Create or update file on instance\n server.tool(\n 'farseer_create_file',\n `Create or update a file on a Farseer instance.\n\nThis creates a file in the specified folder on the Farseer file system.\nIf a file with the same name already exists in that folder, it will be updated.\n\nThe folderPath is an array of folder names, starting from the root.\nDefault is [\"Files\"] which is the standard files folder.\n\nCommon use cases:\n- Creating CSV report files\n- Uploading configuration files\n- Saving processed data outputs`,\n createFileSchema,\n async (params: { fileName: string; folderPath?: string[]; content: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const folderPath = params.folderPath || ['Files'];\n const folder = await nativeClient.getItemByPath(folderPath);\n const buffer = Buffer.from(params.content, 'utf-8');\n\n await nativeClient.createOrUpdateFarseerFile(\n { name: params.fileName, folderId: folder.id } as any,\n buffer,\n );\n\n return successResponse({\n tenant,\n fileName: params.fileName,\n folderPath,\n size: buffer.length,\n message: `File \"${params.fileName}\" created/updated in ${folderPath.join('/')}`,\n });\n } catch (error) {\n return errorResponse(`Create file failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n}\n\n/**\n * Export variable data as CSV using evaluatorExport (works on all server versions).\n * Falls back to exportFormula if evaluatorExport fails.\n */\n/**\n * Export variable data as CSV using exportFormula.\n * Wraps the variable name in quotes as required by the API.\n * Supports dimension filters: [[\"Months\",\"M1\"],[\"Brand\",\"0000032\"]]\n * becomes sum(\"VarName\", \"Months\">\"M1\", \"Brand\">\"0000032\")\n */\nasync function exportVariableAsCsv(\n client: farseer.FarseerClient,\n variableName: string,\n limit?: number,\n filters?: Array<Array<string>>,\n): Promise<string> {\n let formula: string;\n if (filters && filters.length > 0) {\n const filterParts = filters.map(([table, member]) => `\"${table}\">\"${member}\"`).join(', ');\n formula = `sum(\"${variableName}\", ${filterParts})`;\n } else {\n formula = `\"${variableName}\"`;\n }\n\n const blob = await client.export.exportFormula({\n formula,\n format: farseer.ExportFormat.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,UACnB;AAAA,UACA;AAAA,UACA,UAAU,KAAK;AAAA,UACf,QAAQ,UAAU,CAAC;AAAA,UACnB;AAAA,UACA;AAAA,UACA;AAAA,UACA,cAAc;AAAA,QAClB,CAAC;AAAA,MACL,SAAS,OAAO;AACZ,mBAAO,8BAAc,sBAAsB,UAAM,yCAAkB,KAAK,CAAC,IAAI,eAAe;AAAA,MAChG;AAAA,IACJ;AAAA,EACJ;AAGA,SAAO;AAAA,IACH;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAYA;AAAA,IACA,OAAO,WAAyE;AAC5E,YAAM,OAAO,UAAM,+BAAe;AAClC,UAAI,CAAC,KAAK,GAAI,QAAO,KAAK;AAC1B,YAAM,EAAE,QAAQ,QAAQ,aAAa,IAAI,KAAK;
|
|
4
|
+
"sourcesContent": ["/**\n * Data Operation Tools\n *\n * MCP tools for data export, import jobs, and file management on Farseer instances.\n * These use the native farseer-client for full API access.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as os from 'os';\nimport * as farseer from 'farseer-client';\nimport { requireSession } from '../utils/session';\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 exportVariableDataSchema = {\n variableName: z.string().describe('Name of the variable to export'),\n filters: z\n .array(z.array(z.string()).length(2))\n .optional()\n .describe(\n 'Dimension filters as [tableName, memberName] pairs (e.g., [[\"Months\",\"M1\"],[\"Brand\",\"0000032\"]]). Filters the export to specific dimension members.',\n ),\n format: z.enum(['csv', 'json']).optional().describe('Output format (default: csv)'),\n limit: z.number().optional().describe('Maximum number of rows to return'),\n};\n\nconst loadVariableDataSchema = {\n variableName: z.string().describe('Name of the variable to load'),\n dimensions: z.array(z.string()).optional().describe('Dimension table names to include as columns in the export'),\n};\n\nconst createImportJobSchema = {\n title: z.string().describe('Import job title (shown in import history)'),\n columns: z\n .array(\n z.object({\n type: z.enum(['DIMENSION_TABLE', 'VARIABLE', 'DATE', 'DESCRIPTION']).describe('Column type'),\n dimensionTableName: z.string().optional().describe('For DIMENSION_TABLE: name of the dimension table'),\n variableName: z.string().optional().describe('For VARIABLE: name of the variable'),\n columnName: z.string().optional().describe('Column header name'),\n dateFormat: z.string().optional().describe('For DATE: date format string'),\n dimensionsNames: z\n .array(\n z.object({\n tableName: z.string(),\n memberName: z.string(),\n }),\n )\n .optional()\n .describe('For VARIABLE: fixed dimension members (filters) for this variable column'),\n }),\n )\n .describe('Column definitions matching the data structure'),\n rows: z\n .array(z.array(z.union([z.string(), z.number(), z.null()])))\n .describe('Data rows - each row is an array of values matching column order'),\n labels: z\n .array(z.string())\n .optional()\n .describe('Labels for grouping import jobs (used by undoPrevious to revert jobs with same labels)'),\n undoPrevious: z\n .boolean()\n .optional()\n .describe('Revert previous import jobs with the same labels before committing (default: false)'),\n importDimensions: z\n .boolean()\n .optional()\n .describe('Auto-create any missing dimension members before committing (default: false)'),\n overwriteCells: z\n .boolean()\n .optional()\n .describe('Overwrite existing cell values (default: false - adds to existing values)'),\n};\n\nconst createFileSchema = {\n fileName: z.string().describe('Name of the file to create or update'),\n folderPath: z\n .array(z.string())\n .optional()\n .describe('Folder path as array (e.g., [\"Files\", \"Reports\"]). Default: [\"Files\"]'),\n content: z.string().describe('File content as text string'),\n};\n\nexport function registerDataTools(server: McpServer): void {\n // farseer_export_variable_data - Export variable data\n server.tool(\n 'farseer_export_variable_data',\n `Export data from a Farseer variable as CSV.\n\nBuilds an export configuration from the variable's dimensions and uses\nthe evaluator export endpoint. Works on all server versions.\n\nFor small results (under 500 rows), returns data inline.\nFor large results (500+ rows), automatically exports to a temp file and returns the path \u2014\nuse the Read tool to inspect the file contents.\n\nUse the 'limit' parameter to restrict row count for large variables.`,\n exportVariableDataSchema,\n // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas\n async (params: {\n variableName: string;\n filters?: Array<Array<string>>;\n format?: 'csv' | 'json';\n limit?: number;\n }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const text = await exportVariableAsCsv(nativeClient, params.variableName, params.limit, params.filters);\n\n const lines = text.split('\\n').filter((l) => l.trim());\n const rowCount = Math.max(0, lines.length - 1);\n\n const CSV_THRESHOLD = 500;\n\n // Large result \u2014 export to file\n if (rowCount >= CSV_THRESHOLD) {\n const tmpDir = os.tmpdir();\n const safeName = params.variableName.replace(/[^a-zA-Z0-9_-]/g, '_');\n const filePath = path.join(tmpDir, `farseer_${tenant}_${safeName}.csv`);\n fs.writeFileSync(filePath, text, 'utf-8');\n\n const previewLines = lines.slice(0, 6).join('\\n');\n\n return successResponse({\n tenant,\n variable: params.variableName,\n format: 'csv',\n rowCount,\n exportedToFile: filePath,\n message: `Variable has ${rowCount} rows \u2014 exported to file. Use Read tool to inspect.`,\n preview: previewLines,\n });\n }\n\n return successResponse({\n tenant,\n variable: params.variableName,\n format: 'csv',\n rowCount,\n data: text,\n });\n } catch (error) {\n return errorResponse(`Export variable data failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_load_variable_data - Load variable data with specific dimensions\n server.tool(\n 'farseer_load_variable_data',\n `Load data from a Farseer variable into a structured CSV format.\n\nExports all data cells for the variable. You can optionally filter to\nspecific dimensions only.\n\nFor small results (under 500 rows), returns data inline.\nFor large results (500+ rows), automatically exports to a temp CSV file and returns the path.\n\nExample usage:\n- Load \"Revenue\" data (all dimensions)\n- Load \"Revenue\" with dimensions [\"Product\", \"Years\", \"Months\"]`,\n loadVariableDataSchema,\n // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas\n async (params: { variableName: string; dimensions?: string[] }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const text = await exportVariableAsCsv(nativeClient, params.variableName);\n\n const lines = text.split('\\n').filter((l) => l.trim());\n const rowCount = Math.max(0, lines.length - 1);\n\n const CSV_THRESHOLD = 500;\n\n // Large result \u2014 export to file\n if (rowCount >= CSV_THRESHOLD) {\n const tmpDir = os.tmpdir();\n const safeName = params.variableName.replace(/[^a-zA-Z0-9_-]/g, '_');\n const filePath = path.join(tmpDir, `farseer_${tenant}_${safeName}_data.csv`);\n fs.writeFileSync(filePath, text, 'utf-8');\n\n const previewLines = lines.slice(0, 6).join('\\n');\n\n return successResponse({\n tenant,\n variable: params.variableName,\n dimensions: params.dimensions || 'all',\n rowCount,\n exportedToFile: filePath,\n message: `Variable has ${rowCount} rows \u2014 exported to CSV. Use Read tool to inspect.`,\n preview: previewLines,\n });\n }\n\n return successResponse({\n tenant,\n variable: params.variableName,\n dimensions: params.dimensions || 'all',\n rowCount,\n data: text,\n });\n } catch (error) {\n return errorResponse(`Load variable data failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_create_import_job - Create and execute import job\n server.tool(\n 'farseer_create_import_job',\n `Create and execute a complete data import job on a Farseer instance.\n\nThis tool handles the full import workflow in a single call:\n1. Builds import metadata from column definitions\n2. Creates the import job\n3. Adds all data rows\n4. Optionally creates missing dimension members (importDimensions)\n5. Optionally reverts previous imports with same labels (undoPrevious)\n6. Commits the import\n\nColumn types:\n- DIMENSION_TABLE: Maps to a dimension table (e.g., Product, Years, Months)\n- VARIABLE: Maps to a variable that will receive data values\n - Can include dimensionsNames to fix specific dimension members for this column\n- DATE: Date column with format string\n- DESCRIPTION: Cell description/comment\n\nThe 'labels' parameter is important for the undoPrevious feature:\nwhen undoPrevious is true, all previously committed imports with the\nsame labels will be reverted before this import is committed.\nThis is useful for idempotent re-imports.\n\nThe 'overwriteCells' parameter controls whether existing values are\noverwritten (true) or accumulated (false, default).\n\nExample columns for importing revenue data:\n[\n { \"type\": \"DIMENSION_TABLE\", \"dimensionTableName\": \"Product\" },\n { \"type\": \"DIMENSION_TABLE\", \"dimensionTableName\": \"Years\" },\n { \"type\": \"DIMENSION_TABLE\", \"dimensionTableName\": \"Months\" },\n { \"type\": \"VARIABLE\", \"variableName\": \"Revenue\",\n \"dimensionsNames\": [\n { \"tableName\": \"Versions\", \"memberName\": \"Actual\" }\n ]\n }\n]`,\n createImportJobSchema,\n // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas\n async (params: {\n title: string;\n columns: Array<{\n type: 'DIMENSION_TABLE' | 'VARIABLE' | 'DATE' | 'DESCRIPTION';\n dimensionTableName?: string;\n variableName?: string;\n columnName?: string;\n dateFormat?: string;\n dimensionsNames?: Array<{ tableName: string; memberName: string }>;\n }>;\n rows: Array<Array<string | number | null>>;\n labels?: string[];\n undoPrevious?: boolean;\n importDimensions?: boolean;\n overwriteCells?: boolean;\n }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n await nativeClient.initTagMap();\n\n const {\n title,\n columns,\n rows,\n labels,\n undoPrevious = false,\n importDimensions = false,\n overwriteCells = false,\n } = params;\n\n // Build metadata columns\n const metadataColumns = columns.map((col) => {\n switch (col.type) {\n case 'DIMENSION_TABLE':\n return {\n type: 'DIMENSION_TABLE' as const,\n dimensionTableName: col.dimensionTableName!,\n columnName: col.columnName,\n };\n case 'VARIABLE':\n return {\n type: 'VARIABLE' as const,\n variableName: col.variableName!,\n columnName: col.columnName || col.variableName!,\n dimensionsNames: col.dimensionsNames,\n };\n case 'DATE':\n return {\n type: 'DATE' as const,\n dateFormat: col.dateFormat!,\n columnName: col.columnName,\n };\n case 'DESCRIPTION':\n return {\n type: 'DESCRIPTION' as const,\n columnName: col.columnName,\n };\n default:\n return {\n type: 'NONE' as const,\n columnName: col.columnName,\n };\n }\n });\n\n // Build metadata\n const metadata = await nativeClient.buildImportJobMetadata(metadataColumns as any);\n\n if (overwriteCells) {\n (metadata as any).overwriteCells = true;\n }\n\n // Create import job\n const importActions = await nativeClient.createImportJob({\n title,\n metadata,\n labels,\n });\n\n // Add rows\n await importActions.addRows(rows as any);\n await importActions.flushRows();\n\n // Import dimensions if needed\n if (importDimensions) {\n await importActions.importDimensions();\n }\n\n // Undo previous if needed\n if (undoPrevious) {\n await importActions.undoPrevious();\n }\n\n // Commit\n const report = await importActions.commit();\n\n return successResponse({\n tenant,\n title,\n rowCount: rows.length,\n labels: labels || [],\n undoPrevious,\n importDimensions,\n overwriteCells,\n commitReport: report,\n });\n } catch (error) {\n return errorResponse(`Import job failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_create_file - Create or update file on instance\n server.tool(\n 'farseer_create_file',\n `Create or update a file on a Farseer instance.\n\nThis creates a file in the specified folder on the Farseer file system.\nIf a file with the same name already exists in that folder, it will be updated.\n\nThe folderPath is an array of folder names, starting from the root.\nDefault is [\"Files\"] which is the standard files folder.\n\nCommon use cases:\n- Creating CSV report files\n- Uploading configuration files\n- Saving processed data outputs`,\n createFileSchema,\n async (params: { fileName: string; folderPath?: string[]; content: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client, native: nativeClient } = gate.session;\n\n try {\n const folderPath = params.folderPath || ['Files'];\n // Not nativeClient.getItemByPath: for a single-segment path that\n // name-searches the whole tenant and refuses on more than one\n // loose match, so a second folder called \"Files\" breaks it.\n const folder = await client.getFolderByPath(folderPath);\n if (!folder) {\n return errorResponse(`Folder \"${folderPath.join('/')}\" not found`, 'NOT_FOUND');\n }\n const buffer = Buffer.from(params.content, 'utf-8');\n\n await nativeClient.createOrUpdateFarseerFile(\n { name: params.fileName, folderId: folder.id } as any,\n buffer,\n );\n\n return successResponse({\n tenant,\n fileName: params.fileName,\n folderPath,\n size: buffer.length,\n message: `File \"${params.fileName}\" created/updated in ${folderPath.join('/')}`,\n });\n } catch (error) {\n return errorResponse(`Create file failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n}\n\n/**\n * Export variable data as CSV using evaluatorExport (works on all server versions).\n * Falls back to exportFormula if evaluatorExport fails.\n */\n/**\n * Export variable data as CSV using exportFormula.\n * Wraps the variable name in quotes as required by the API.\n * Supports dimension filters: [[\"Months\",\"M1\"],[\"Brand\",\"0000032\"]]\n * becomes sum(\"VarName\", \"Months\">\"M1\", \"Brand\">\"0000032\")\n */\nasync function exportVariableAsCsv(\n client: farseer.FarseerClient,\n variableName: string,\n limit?: number,\n filters?: Array<Array<string>>,\n): Promise<string> {\n let formula: string;\n if (filters && filters.length > 0) {\n const filterParts = filters.map(([table, member]) => `\"${table}\">\"${member}\"`).join(', ');\n formula = `sum(\"${variableName}\", ${filterParts})`;\n } else {\n formula = `\"${variableName}\"`;\n }\n\n const blob = await client.export.exportFormula({\n formula,\n format: farseer.ExportFormat.Csv,\n limit,\n });\n return await blob.text();\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,iBAAkB;AAClB,SAAoB;AACpB,WAAsB;AACtB,SAAoB;AACpB,cAAyB;AACzB,qBAA+B;AAC/B,qBAA+C;AAC/C,4BAAkC;AAGlC,MAAM,2BAA2B;AAAA,EAC7B,cAAc,aAAE,OAAO,EAAE,SAAS,gCAAgC;AAAA,EAClE,SAAS,aACJ,MAAM,aAAE,MAAM,aAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,EACnC,SAAS,EACT;AAAA,IACG;AAAA,EACJ;AAAA,EACJ,QAAQ,aAAE,KAAK,CAAC,OAAO,MAAM,CAAC,EAAE,SAAS,EAAE,SAAS,8BAA8B;AAAA,EAClF,OAAO,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,kCAAkC;AAC5E;AAEA,MAAM,yBAAyB;AAAA,EAC3B,cAAc,aAAE,OAAO,EAAE,SAAS,8BAA8B;AAAA,EAChE,YAAY,aAAE,MAAM,aAAE,OAAO,CAAC,EAAE,SAAS,EAAE,SAAS,2DAA2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