farseer-cli 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/dimensions.js +145 -0
- package/dist/commands/dimensions.js.map +7 -0
- package/dist/commands/variables.js +176 -0
- package/dist/commands/variables.js.map +7 -0
- package/dist/index.js +19 -1
- package/dist/index.js.map +2 -2
- package/dist/mcp/prompts/workflows.js +64 -1
- package/dist/mcp/prompts/workflows.js.map +2 -2
- package/dist/mcp/server.js +4 -1
- package/dist/mcp/server.js.map +2 -2
- package/dist/mcp/tools/dataTools.js +366 -0
- package/dist/mcp/tools/dataTools.js.map +7 -0
- package/dist/services/farseerFactory.js +52 -0
- package/dist/services/farseerFactory.js.map +2 -2
- package/dist/utils/constants.js +3 -0
- package/dist/utils/constants.js.map +2 -2
- package/package.json +1 -1
- package/dist/commands/app.d.ts +0 -2
- package/dist/commands/apps.d.ts +0 -2
- package/dist/commands/checkout.d.ts +0 -2
- package/dist/commands/config.d.ts +0 -2
- package/dist/commands/diff.d.ts +0 -2
- package/dist/commands/install.d.ts +0 -2
- package/dist/commands/list.d.ts +0 -2
- package/dist/commands/login.d.ts +0 -2
- package/dist/commands/logout.d.ts +0 -2
- package/dist/commands/mcp-server.d.ts +0 -8
- package/dist/commands/model.d.ts +0 -2
- package/dist/commands/pull.d.ts +0 -2
- package/dist/commands/push.d.ts +0 -2
- package/dist/commands/run.d.ts +0 -2
- package/dist/commands/setup.d.ts +0 -2
- package/dist/commands/setup.js +0 -137
- package/dist/commands/status.d.ts +0 -2
- package/dist/commands/unsetup.d.ts +0 -2
- package/dist/commands/unsetup.js +0 -122
- package/dist/commands/whoami.d.ts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/mcp/index.d.ts +0 -7
- package/dist/mcp/prompts/workflows.d.ts +0 -7
- package/dist/mcp/resources/documentation.d.ts +0 -8
- package/dist/mcp/server.d.ts +0 -7
- package/dist/mcp/tools/appTools.d.ts +0 -7
- package/dist/mcp/tools/authTools.d.ts +0 -7
- package/dist/mcp/tools/modelTools.d.ts +0 -7
- package/dist/mcp/tools/runTools.d.ts +0 -7
- package/dist/mcp/tools/syncTools.d.ts +0 -7
- package/dist/mcp/utils/helpers.d.ts +0 -69
- package/dist/services/appSyncService.d.ts +0 -75
- package/dist/services/configService.d.ts +0 -39
- package/dist/services/farseerApi.d.ts +0 -166
- package/dist/services/farseerFactory.d.ts +0 -88
- package/dist/services/farseerService.d.ts +0 -96
- package/dist/services/gitService.d.ts +0 -31
- package/dist/services/syncService.d.ts +0 -44
- package/dist/utils/constants.d.ts +0 -7
- package/dist/utils/helpers.d.ts +0 -69
- package/dist/utils/logger.d.ts +0 -14
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/mcp/prompts/workflows.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Workflow Prompts\n *\n * Reusable prompt templates for common Farseer workflows.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\n\n// Define schemas outside of prompt registration to avoid deep type instantiation\nconst setupTenantSchema = {\n tenant: z.string().describe('Tenant name to setup'),\n};\n\nconst createAppSchema = {\n tenant: z.string().describe('Tenant name'),\n appName: z.string().describe('Name for the new app'),\n scriptName: z.string().optional().describe('Main script filename (default: index.ts)'),\n};\n\nconst understandModelSchema = {\n tenant: z.string().describe('Tenant name'),\n};\n\nconst writeImportScriptSchema = {\n tenant: z.string().describe('Tenant name'),\n variableName: z.string().describe('Target variable to import into'),\n};\n\nconst copyAppSchema = {\n tenant: z.string().describe('Tenant name'),\n sourceApp: z.string().describe('Name of app to copy'),\n newAppName: z.string().describe('Name for the new app'),\n};\n\nconst debugSyncSchema = {\n tenant: z.string().describe('Tenant name'),\n};\n\nexport function registerWorkflowPrompts(server: McpServer): void {\n // Cast to any to avoid very deep generic type instantiation from the MCP SDK\n const anyServer = server as any;\n // Setup new tenant\n anyServer.prompt(\n 'setup_new_tenant',\n 'Guide for setting up a new Farseer tenant: login, checkout, pull, install dependencies.',\n setupTenantSchema,\n async (params: { tenant: string }) => {\n const { tenant } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `You are setting up a new Farseer tenant \"${tenant}\".\n\nSteps to follow:\n\n1. First, check authentication status with farseer_whoami\n2. If not logged in, inform the user to run \"farseer login\" in terminal (MCP cannot do browser login)\n3. Use farseer_checkout to set \"${tenant}\" as the default tenant (this also pulls files and apps)\n4. Tell user to run \"farseer install ${tenant}\" in terminal to install npm dependencies\n5. Use farseer_list_apps to show available apps\n6. Use farseer_export_model to understand the data structure\n\nAfter setup, the user can:\n- Run apps with farseer_run_app\n- Edit scripts in apps/${tenant}/files/Scripts/\n- Push changes with farseer_push\n- Check model with farseer_get_variable or farseer_get_table`,\n },\n },\n ],\n };\n },\n );\n\n // Create new app\n anyServer.prompt(\n 'create_new_app',\n 'Guide for creating a new Farseer app from scratch.',\n createAppSchema,\n async (params: { tenant: string; appName: string; scriptName?: string }) => {\n const { tenant, appName, scriptName } = params;\n const script = scriptName || 'index.ts';\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Creating a new Farseer app \"${appName}\" for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Check if the script \"${script}\" exists with farseer_status\n2. If script doesn't exist locally:\n - Create the script file at apps/${tenant}/files/Scripts/${script}\n - Push with farseer_push\n\n3. Use farseer_create_app to create the app named \"${appName}\"\n\n4. Use farseer_configure_app to set:\n - entrypoint: \"${script}\"\n - scripts: [\"${script}\"]\n - Add arguments if needed\n\n5. Test with farseer_run_app\n\nScript template to create:\n\\`\\`\\`typescript\nimport * as farseer from 'farseer-client';\n\nconst args = process.argv.slice(2);\nconsole.log('Arguments:', args);\n\nconst client = new farseer.FarseerClient();\n\nasync function main() {\n await client.initTagMap();\n\n // Your code here\n console.log('App running successfully');\n}\n\nmain().catch(farseer.handleUnknownError);\n\\`\\`\\``,\n },\n },\n ],\n };\n },\n );\n\n // Understand model\n anyServer.prompt(\n 'understand_model',\n 'Explore and understand the data model of a Farseer tenant.',\n understandModelSchema,\n async (params: { tenant: string }) => {\n const { tenant } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Analyzing the data model for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Use farseer_export_model to get the full model structure\n\n2. Review dimension tables:\n - Use farseer_list_tables for overview\n - Key dimensions usually include: Products, Regions, Time (Months, Years), Versions\n - Check foreign key relationships between tables\n\n3. Review variables:\n - Use farseer_list_variables for overview\n - Use farseer_get_variable for specific variable details\n - Note which dimensions each variable has\n\n4. For import scripts, you need to know:\n - Target variable name\n - All dimensions the variable has\n - Valid members for each dimension\n\nKey concepts:\n- Dimensions structure the data (Product, Region, Month, Year, Version)\n- Variables store values at dimension intersections\n- Formulas calculate values automatically\n- Roll-up types determine aggregation (SUM, AVERAGE, etc.)\n\nCommon dimension tables:\n- Months, Years (time)\n- Versions (Plan, Actual, Forecast)\n- Products, Categories, Brands\n- Regions, Entities, Cost Centers`,\n },\n },\n ],\n };\n },\n );\n\n // Write import script\n anyServer.prompt(\n 'write_import_script',\n 'Guide for writing a data import script.',\n writeImportScriptSchema,\n async (params: { tenant: string; variableName: string }) => {\n const { tenant, variableName } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Writing an import script for variable \"${variableName}\" in tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Use farseer_get_variable to understand the target variable:\n - What dimensions does it have?\n - What is the roll-up type?\n\n2. Use farseer_get_table for each dimension to see valid members\n\n3. Create the import script with this pattern:\n\n\\`\\`\\`typescript\nimport * as farseer from 'farseer-client';\n\nconst client = new farseer.FarseerClient();\n\nasync function main() {\n await client.initTagMap();\n\n // Create import job with column definitions\n const importJob = await client.createImportJob({\n title: 'Import ${variableName}',\n columns: [\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Product' },\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Years' },\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Months' },\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Versions' },\n { type: 'VARIABLE', variableName: '${variableName}' },\n ],\n labels: ['auto', 'import-${variableName.toLowerCase().replace(/\\s+/g, '-')}']\n });\n\n // Add rows - each row matches column order\n const rows = [\n ['ProductA', 'Y2025', 'M1', 'Plan', 1000],\n ['ProductB', 'Y2025', 'M1', 'Plan', 2000],\n ];\n\n await importJob.addRows(rows);\n await importJob.flushRows();\n await importJob.undoPrevious(); // Remove previous import\n await importJob.commit();\n\n console.log('Import completed!');\n}\n\nmain().catch(farseer.handleUnknownError);\n\\`\\`\\`\n\n4. Save script to apps/${tenant}/files/Scripts/\n5. Push with farseer_push\n6. Create app with farseer_create_app\n7. Configure with farseer_configure_app\n8. Test with farseer_run_app`,\n },\n },\n ],\n };\n },\n );\n\n // Copy existing app\n anyServer.prompt(\n 'copy_app',\n 'Guide for copying an existing app to create a new one.',\n copyAppSchema,\n async (params: { tenant: string; sourceApp: string; newAppName: string }) => {\n const { tenant, sourceApp, newAppName } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Copying app \"${sourceApp}\" to create \"${newAppName}\" for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Pull latest with farseer_pull to get current app JSON\n\n2. Use farseer_get_app to see the source app configuration\n\n3. The app JSON files are in apps/${tenant}/apps/\n\n Copy the source JSON file and modify:\n - Change \"name\" to \"${newAppName}\"\n - **IMPORTANT: Remove \"_remote\" field** (this makes it a new app)\n - Modify arguments, description as needed\n\n4. JSON format for new app:\n\\`\\`\\`json\n{\n \"name\": \"${newAppName}\",\n \"description\": \"Copied from ${sourceApp}\",\n \"entrypoint\": \"script.ts\",\n \"scripts\": [\"script.ts\"],\n \"arguments\": [\n { \"name\": \"Year\", \"defaultValue\": \"2025\" }\n ]\n}\n\\`\\`\\`\n\nNote: Do NOT include \"_remote\" for new apps - CLI adds it after first push.\n\n5. Push with farseer_push to create the new app\n\n6. Test with farseer_run_app`,\n },\n },\n ],\n };\n },\n );\n\n // Debug sync issues\n anyServer.prompt(\n 'debug_sync_issues',\n 'Troubleshoot synchronization problems between local and remote.',\n debugSyncSchema,\n async (params: { tenant: string }) => {\n const { tenant } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Debugging sync issues for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Check authentication: farseer_whoami\n - Is JWT valid?\n - Is tenant checked out?\n\n2. Check sync status: farseer_status\n - Are there modified files?\n - Are there only-local or only-remote files?\n\n3. If files show as modified:\n - Use farseer_diff to see differences\n - Decide: pull (accept remote) or push (upload local)\n\n4. Common issues and solutions:\n\n **\"No credentials found\"**\n \u2192 User needs to run \"farseer login\" in terminal\n \u2192 Or configure API key: \"farseer config set ${tenant} --api-key KEY\"\n\n **\"Remote has changes\"**\n \u2192 Pull first with farseer_pull\n \u2192 Then push with farseer_push\n\n **\"Token expired\"**\n \u2192 User needs to run \"farseer login\" again\n\n **Apps not syncing**\n \u2192 Need JWT login (browser), not API key\n \u2192 API key only syncs files, not apps\n\n5. Force resolution:\n - To accept remote: farseer_pull (overwrites local)\n - To accept local: farseer_push with force=true (overwrites remote)\n\n6. Check specific file diff:\n - Use farseer_diff with file parameter to see exact changes`,\n },\n },\n ],\n };\n },\n );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iBAAkB;AAGlB,MAAM,oBAAoB;AAAA,EACtB,QAAQ,aAAE,OAAO,EAAE,SAAS,sBAAsB;AACtD;AAEA,MAAM,kBAAkB;AAAA,EACpB,QAAQ,aAAE,OAAO,EAAE,SAAS,aAAa;AAAA,EACzC,SAAS,aAAE,OAAO,EAAE,SAAS,sBAAsB;AAAA,EACnD,YAAY,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,0CAA0C;AACzF;AAEA,MAAM,w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iDAMY,YAAY;AAAA;AAAA,mCAE1B,aAAa,YAAY,EAAE,QAAQ,QAAQ,GAAG,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAoBzD,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * Workflow Prompts\n *\n * Reusable prompt templates for common Farseer workflows.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\n\n// Define schemas outside of prompt registration to avoid deep type instantiation\nconst setupTenantSchema = {\n tenant: z.string().describe('Tenant name to setup'),\n};\n\nconst createAppSchema = {\n tenant: z.string().describe('Tenant name'),\n appName: z.string().describe('Name for the new app'),\n scriptName: z.string().optional().describe('Main script filename (default: index.ts)'),\n};\n\nconst understandModelSchema = {\n tenant: z.string().describe('Tenant name'),\n};\n\nconst writeImportScriptSchema = {\n tenant: z.string().describe('Tenant name'),\n variableName: z.string().describe('Target variable to import into'),\n};\n\nconst copyAppSchema = {\n tenant: z.string().describe('Tenant name'),\n sourceApp: z.string().describe('Name of app to copy'),\n newAppName: z.string().describe('Name for the new app'),\n};\n\nconst exportDataSchema = {\n tenant: z.string().describe('Tenant name'),\n variableName: z.string().describe('Variable to export'),\n};\n\nconst debugSyncSchema = {\n tenant: z.string().describe('Tenant name'),\n};\n\nexport function registerWorkflowPrompts(server: McpServer): void {\n // Cast to any to avoid very deep generic type instantiation from the MCP SDK\n const anyServer = server as any;\n // Setup new tenant\n anyServer.prompt(\n 'setup_new_tenant',\n 'Guide for setting up a new Farseer tenant: login, checkout, pull, install dependencies.',\n setupTenantSchema,\n async (params: { tenant: string }) => {\n const { tenant } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `You are setting up a new Farseer tenant \"${tenant}\".\n\nSteps to follow:\n\n1. First, check authentication status with farseer_whoami\n2. If not logged in, inform the user to run \"farseer login\" in terminal (MCP cannot do browser login)\n3. Use farseer_checkout to set \"${tenant}\" as the default tenant (this also pulls files and apps)\n4. Tell user to run \"farseer install ${tenant}\" in terminal to install npm dependencies\n5. Use farseer_list_apps to show available apps\n6. Use farseer_export_model to understand the data structure\n\nAfter setup, the user can:\n- Run apps with farseer_run_app\n- Edit scripts in apps/${tenant}/files/Scripts/\n- Push changes with farseer_push\n- Check model with farseer_get_variable or farseer_get_table`,\n },\n },\n ],\n };\n },\n );\n\n // Create new app\n anyServer.prompt(\n 'create_new_app',\n 'Guide for creating a new Farseer app from scratch.',\n createAppSchema,\n async (params: { tenant: string; appName: string; scriptName?: string }) => {\n const { tenant, appName, scriptName } = params;\n const script = scriptName || 'index.ts';\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Creating a new Farseer app \"${appName}\" for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Check if the script \"${script}\" exists with farseer_status\n2. If script doesn't exist locally:\n - Create the script file at apps/${tenant}/files/Scripts/${script}\n - Push with farseer_push\n\n3. Use farseer_create_app to create the app named \"${appName}\"\n\n4. Use farseer_configure_app to set:\n - entrypoint: \"${script}\"\n - scripts: [\"${script}\"]\n - Add arguments if needed\n\n5. Test with farseer_run_app\n\nScript template to create:\n\\`\\`\\`typescript\nimport * as farseer from 'farseer-client';\n\nconst args = process.argv.slice(2);\nconsole.log('Arguments:', args);\n\nconst client = new farseer.FarseerClient();\n\nasync function main() {\n await client.initTagMap();\n\n // Your code here\n console.log('App running successfully');\n}\n\nmain().catch(farseer.handleUnknownError);\n\\`\\`\\``,\n },\n },\n ],\n };\n },\n );\n\n // Understand model\n anyServer.prompt(\n 'understand_model',\n 'Explore and understand the data model of a Farseer tenant.',\n understandModelSchema,\n async (params: { tenant: string }) => {\n const { tenant } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Analyzing the data model for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Use farseer_export_model to get the full model structure\n\n2. Review dimension tables:\n - Use farseer_list_tables for overview\n - Key dimensions usually include: Products, Regions, Time (Months, Years), Versions\n - Check foreign key relationships between tables\n\n3. Review variables:\n - Use farseer_list_variables for overview\n - Use farseer_get_variable for specific variable details\n - Note which dimensions each variable has\n\n4. For import scripts, you need to know:\n - Target variable name\n - All dimensions the variable has\n - Valid members for each dimension\n\nKey concepts:\n- Dimensions structure the data (Product, Region, Month, Year, Version)\n- Variables store values at dimension intersections\n- Formulas calculate values automatically\n- Roll-up types determine aggregation (SUM, AVERAGE, etc.)\n\nCommon dimension tables:\n- Months, Years (time)\n- Versions (Plan, Actual, Forecast)\n- Products, Categories, Brands\n- Regions, Entities, Cost Centers`,\n },\n },\n ],\n };\n },\n );\n\n // Write import script\n anyServer.prompt(\n 'write_import_script',\n 'Guide for writing a data import script.',\n writeImportScriptSchema,\n async (params: { tenant: string; variableName: string }) => {\n const { tenant, variableName } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Writing an import script for variable \"${variableName}\" in tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Use farseer_get_variable to understand the target variable:\n - What dimensions does it have?\n - What is the roll-up type?\n\n2. Use farseer_get_table for each dimension to see valid members\n\n3. Create the import script with this pattern:\n\n\\`\\`\\`typescript\nimport * as farseer from 'farseer-client';\n\nconst client = new farseer.FarseerClient();\n\nasync function main() {\n await client.initTagMap();\n\n // Create import job with column definitions\n const importJob = await client.createImportJob({\n title: 'Import ${variableName}',\n columns: [\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Product' },\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Years' },\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Months' },\n { type: 'DIMENSION_TABLE', dimensionTableName: 'Versions' },\n { type: 'VARIABLE', variableName: '${variableName}' },\n ],\n labels: ['auto', 'import-${variableName.toLowerCase().replace(/\\s+/g, '-')}']\n });\n\n // Add rows - each row matches column order\n const rows = [\n ['ProductA', 'Y2025', 'M1', 'Plan', 1000],\n ['ProductB', 'Y2025', 'M1', 'Plan', 2000],\n ];\n\n await importJob.addRows(rows);\n await importJob.flushRows();\n await importJob.undoPrevious(); // Remove previous import\n await importJob.commit();\n\n console.log('Import completed!');\n}\n\nmain().catch(farseer.handleUnknownError);\n\\`\\`\\`\n\n4. Save script to apps/${tenant}/files/Scripts/\n5. Push with farseer_push\n6. Create app with farseer_create_app\n7. Configure with farseer_configure_app\n8. Test with farseer_run_app\n\nALTERNATIVE: For simple imports without a script, use the farseer_create_import_job tool directly.\nIt handles the full workflow (create metadata, add rows, undo previous, commit) in a single call.\nUse farseer_create_import_job when:\n- Data is already available (no need to fetch from external source)\n- The import is a one-time or simple operation\n- You want to quickly import without creating a full script\n\nUse a script when:\n- Data comes from external sources (APIs, databases, files)\n- Complex data transformation is needed\n- The import runs on a schedule as an App`,\n },\n },\n ],\n };\n },\n );\n\n // Copy existing app\n anyServer.prompt(\n 'copy_app',\n 'Guide for copying an existing app to create a new one.',\n copyAppSchema,\n async (params: { tenant: string; sourceApp: string; newAppName: string }) => {\n const { tenant, sourceApp, newAppName } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Copying app \"${sourceApp}\" to create \"${newAppName}\" for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Pull latest with farseer_pull to get current app JSON\n\n2. Use farseer_get_app to see the source app configuration\n\n3. The app JSON files are in apps/${tenant}/apps/\n\n Copy the source JSON file and modify:\n - Change \"name\" to \"${newAppName}\"\n - **IMPORTANT: Remove \"_remote\" field** (this makes it a new app)\n - Modify arguments, description as needed\n\n4. JSON format for new app:\n\\`\\`\\`json\n{\n \"name\": \"${newAppName}\",\n \"description\": \"Copied from ${sourceApp}\",\n \"entrypoint\": \"script.ts\",\n \"scripts\": [\"script.ts\"],\n \"arguments\": [\n { \"name\": \"Year\", \"defaultValue\": \"2025\" }\n ]\n}\n\\`\\`\\`\n\nNote: Do NOT include \"_remote\" for new apps - CLI adds it after first push.\n\n5. Push with farseer_push to create the new app\n\n6. Test with farseer_run_app`,\n },\n },\n ],\n };\n },\n );\n\n // Export data\n anyServer.prompt(\n 'export_data',\n 'Guide for exporting variable data from Farseer.',\n exportDataSchema,\n async (params: { tenant: string; variableName: string }) => {\n const { tenant, variableName } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Exporting data for variable \"${variableName}\" from tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Use farseer_get_variable to understand the variable:\n - What dimensions does it span?\n - What is its data type?\n\n2. Choose export method:\n\n **Option A: Quick export (farseer_export_variable_data)**\n - Uses ExportApi.exportFormula() internally\n - Returns CSV/JSON data inline\n - Good for quick inspection or small datasets\n - Use 'limit' parameter for large datasets\n\n **Option B: Structured export (farseer_load_variable_data)**\n - Uses data.loadFarseerVariable() internally\n - Can specify which dimensions to include as columns\n - Returns structured CSV data\n - Good when you need specific dimension breakdowns\n\n **Option C: CLI export (farseer variable export)**\n - Saves CSV/JSON/XLSX to a local file\n - Best for saving data locally for analysis\n\n3. For analysis:\n - Parse the CSV data returned by the tools\n - Summarize, filter, or transform as needed`,\n },\n },\n ],\n };\n },\n );\n\n // Debug sync issues\n anyServer.prompt(\n 'debug_sync_issues',\n 'Troubleshoot synchronization problems between local and remote.',\n debugSyncSchema,\n async (params: { tenant: string }) => {\n const { tenant } = params;\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Debugging sync issues for tenant \"${tenant}\".\n\nSteps to follow:\n\n1. Check authentication: farseer_whoami\n - Is JWT valid?\n - Is tenant checked out?\n\n2. Check sync status: farseer_status\n - Are there modified files?\n - Are there only-local or only-remote files?\n\n3. If files show as modified:\n - Use farseer_diff to see differences\n - Decide: pull (accept remote) or push (upload local)\n\n4. Common issues and solutions:\n\n **\"No credentials found\"**\n \u2192 User needs to run \"farseer login\" in terminal\n \u2192 Or configure API key: \"farseer config set ${tenant} --api-key KEY\"\n\n **\"Remote has changes\"**\n \u2192 Pull first with farseer_pull\n \u2192 Then push with farseer_push\n\n **\"Token expired\"**\n \u2192 User needs to run \"farseer login\" again\n\n **Apps not syncing**\n \u2192 Need JWT login (browser), not API key\n \u2192 API key only syncs files, not apps\n\n5. Force resolution:\n - To accept remote: farseer_pull (overwrites local)\n - To accept local: farseer_push with force=true (overwrites remote)\n\n6. Check specific file diff:\n - Use farseer_diff with file parameter to see exact changes`,\n },\n },\n ],\n };\n },\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iBAAkB;AAGlB,MAAM,oBAAoB;AAAA,EACtB,QAAQ,aAAE,OAAO,EAAE,SAAS,sBAAsB;AACtD;AAEA,MAAM,kBAAkB;AAAA,EACpB,QAAQ,aAAE,OAAO,EAAE,SAAS,aAAa;AAAA,EACzC,SAAS,aAAE,OAAO,EAAE,SAAS,sBAAsB;AAAA,EACnD,YAAY,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,0CAA0C;AACzF;AAEA,MAAM,wBAAwB;AAAA,EAC1B,QAAQ,aAAE,OAAO,EAAE,SAAS,aAAa;AAC7C;AAEA,MAAM,0BAA0B;AAAA,EAC5B,QAAQ,aAAE,OAAO,EAAE,SAAS,aAAa;AAAA,EACzC,cAAc,aAAE,OAAO,EAAE,SAAS,gCAAgC;AACtE;AAEA,MAAM,gBAAgB;AAAA,EAClB,QAAQ,aAAE,OAAO,EAAE,SAAS,aAAa;AAAA,EACzC,WAAW,aAAE,OAAO,EAAE,SAAS,qBAAqB;AAAA,EACpD,YAAY,aAAE,OAAO,EAAE,SAAS,sBAAsB;AAC1D;AAEA,MAAM,mBAAmB;AAAA,EACrB,QAAQ,aAAE,OAAO,EAAE,SAAS,aAAa;AAAA,EACzC,cAAc,aAAE,OAAO,EAAE,SAAS,oBAAoB;AAC1D;AAEA,MAAM,kBAAkB;AAAA,EACpB,QAAQ,aAAE,OAAO,EAAE,SAAS,aAAa;AAC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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sDAoB5B,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAmB/B;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/mcp/server.js
CHANGED
|
@@ -21,23 +21,26 @@ __export(server_exports, {
|
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(server_exports);
|
|
23
23
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
24
|
+
var import_constants = require("../utils/constants");
|
|
24
25
|
var import_authTools = require("./tools/authTools");
|
|
25
26
|
var import_syncTools = require("./tools/syncTools");
|
|
26
27
|
var import_appTools = require("./tools/appTools");
|
|
27
28
|
var import_modelTools = require("./tools/modelTools");
|
|
28
29
|
var import_runTools = require("./tools/runTools");
|
|
30
|
+
var import_dataTools = require("./tools/dataTools");
|
|
29
31
|
var import_documentation = require("./resources/documentation");
|
|
30
32
|
var import_workflows = require("./prompts/workflows");
|
|
31
33
|
function createMcpServer() {
|
|
32
34
|
const server = new import_mcp.McpServer({
|
|
33
35
|
name: "farseer-cli",
|
|
34
|
-
version:
|
|
36
|
+
version: import_constants.CLI_VERSION
|
|
35
37
|
});
|
|
36
38
|
(0, import_authTools.registerAuthTools)(server);
|
|
37
39
|
(0, import_syncTools.registerSyncTools)(server);
|
|
38
40
|
(0, import_appTools.registerAppTools)(server);
|
|
39
41
|
(0, import_modelTools.registerModelTools)(server);
|
|
40
42
|
(0, import_runTools.registerRunTools)(server);
|
|
43
|
+
(0, import_dataTools.registerDataTools)(server);
|
|
41
44
|
(0, import_documentation.registerDocumentationResources)(server);
|
|
42
45
|
(0, import_workflows.registerWorkflowPrompts)(server);
|
|
43
46
|
return server;
|
package/dist/mcp/server.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mcp/server.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * MCP Server Configuration\n *\n * Creates and configures the Farseer MCP server with all tools, resources, and prompts.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { registerAuthTools } from './tools/authTools';\nimport { registerSyncTools } from './tools/syncTools';\nimport { registerAppTools } from './tools/appTools';\nimport { registerModelTools } from './tools/modelTools';\nimport { registerRunTools } from './tools/runTools';\nimport { registerDocumentationResources } from './resources/documentation';\nimport { registerWorkflowPrompts } from './prompts/workflows';\n\nexport function createMcpServer(): McpServer {\n const server = new McpServer({\n name: 'farseer-cli',\n version:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,iBAA0B;AAC1B,uBAAkC;AAClC,uBAAkC;AAClC,sBAAiC;AACjC,wBAAmC;AACnC,sBAAiC;AACjC,2BAA+C;AAC/C,uBAAwC;AAEjC,SAAS,kBAA6B;AACzC,QAAM,SAAS,IAAI,qBAAU;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA,EACb,CAAC;AAGD,0CAAkB,MAAM;AACxB,0CAAkB,MAAM;AACxB,wCAAiB,MAAM;AACvB,4CAAmB,MAAM;AACzB,wCAAiB,MAAM;
|
|
4
|
+
"sourcesContent": ["/**\n * MCP Server Configuration\n *\n * Creates and configures the Farseer MCP server with all tools, resources, and prompts.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { CLI_VERSION } from '../utils/constants';\nimport { registerAuthTools } from './tools/authTools';\nimport { registerSyncTools } from './tools/syncTools';\nimport { registerAppTools } from './tools/appTools';\nimport { registerModelTools } from './tools/modelTools';\nimport { registerRunTools } from './tools/runTools';\nimport { registerDataTools } from './tools/dataTools';\nimport { registerDocumentationResources } from './resources/documentation';\nimport { registerWorkflowPrompts } from './prompts/workflows';\n\nexport function createMcpServer(): McpServer {\n const server = new McpServer({\n name: 'farseer-cli',\n version: CLI_VERSION,\n });\n\n // Register all tools\n registerAuthTools(server);\n registerSyncTools(server);\n registerAppTools(server);\n registerModelTools(server);\n registerRunTools(server);\n registerDataTools(server);\n\n // Register resources (documentation)\n registerDocumentationResources(server);\n\n // Register prompts (workflow templates)\n registerWorkflowPrompts(server);\n\n return server;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,iBAA0B;AAC1B,uBAA4B;AAC5B,uBAAkC;AAClC,uBAAkC;AAClC,sBAAiC;AACjC,wBAAmC;AACnC,sBAAiC;AACjC,uBAAkC;AAClC,2BAA+C;AAC/C,uBAAwC;AAEjC,SAAS,kBAA6B;AACzC,QAAM,SAAS,IAAI,qBAAU;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA,EACb,CAAC;AAGD,0CAAkB,MAAM;AACxB,0CAAkB,MAAM;AACxB,wCAAiB,MAAM;AACvB,4CAAmB,MAAM;AACzB,wCAAiB,MAAM;AACvB,0CAAkB,MAAM;AAGxB,2DAA+B,MAAM;AAGrC,gDAAwB,MAAM;AAE9B,SAAO;AACX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var dataTools_exports = {};
|
|
19
|
+
__export(dataTools_exports, {
|
|
20
|
+
registerDataTools: () => registerDataTools
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(dataTools_exports);
|
|
23
|
+
var import_zod = require("zod");
|
|
24
|
+
var import_farseerFactory = require("../../services/farseerFactory");
|
|
25
|
+
var import_configService = require("../../services/configService");
|
|
26
|
+
var import_helpers = require("../utils/helpers");
|
|
27
|
+
async function extractErrorMessage(error) {
|
|
28
|
+
if (error instanceof Error) return error.message;
|
|
29
|
+
if (error && typeof error === "object" && "status" in error && "statusText" in error) {
|
|
30
|
+
const resp = error;
|
|
31
|
+
const body = resp.text ? await resp.text() : "";
|
|
32
|
+
return `HTTP ${resp.status} ${resp.statusText}${body ? ": " + body : ""}`;
|
|
33
|
+
}
|
|
34
|
+
return String(error);
|
|
35
|
+
}
|
|
36
|
+
const exportVariableDataSchema = {
|
|
37
|
+
tenant: import_zod.z.string().optional().describe("Tenant name (optional if checked out)"),
|
|
38
|
+
variableName: import_zod.z.string().describe("Name of the variable to export"),
|
|
39
|
+
format: import_zod.z.enum(["csv", "json"]).optional().describe("Output format (default: csv)"),
|
|
40
|
+
limit: import_zod.z.number().optional().describe("Maximum number of rows to return")
|
|
41
|
+
};
|
|
42
|
+
const loadVariableDataSchema = {
|
|
43
|
+
tenant: import_zod.z.string().optional().describe("Tenant name (optional if checked out)"),
|
|
44
|
+
variableName: import_zod.z.string().describe("Name of the variable to load"),
|
|
45
|
+
dimensions: import_zod.z.array(import_zod.z.string()).optional().describe("Dimension table names to include as columns in the export")
|
|
46
|
+
};
|
|
47
|
+
const createImportJobSchema = {
|
|
48
|
+
tenant: import_zod.z.string().optional().describe("Tenant name (optional if checked out)"),
|
|
49
|
+
title: import_zod.z.string().describe("Import job title (shown in import history)"),
|
|
50
|
+
columns: import_zod.z.array(import_zod.z.object({
|
|
51
|
+
type: import_zod.z.enum(["DIMENSION_TABLE", "VARIABLE", "DATE", "DESCRIPTION"]).describe("Column type"),
|
|
52
|
+
dimensionTableName: import_zod.z.string().optional().describe("For DIMENSION_TABLE: name of the dimension table"),
|
|
53
|
+
variableName: import_zod.z.string().optional().describe("For VARIABLE: name of the variable"),
|
|
54
|
+
columnName: import_zod.z.string().optional().describe("Column header name"),
|
|
55
|
+
dateFormat: import_zod.z.string().optional().describe("For DATE: date format string"),
|
|
56
|
+
dimensionsNames: import_zod.z.array(import_zod.z.object({
|
|
57
|
+
tableName: import_zod.z.string(),
|
|
58
|
+
memberName: import_zod.z.string()
|
|
59
|
+
})).optional().describe("For VARIABLE: fixed dimension members (filters) for this variable column")
|
|
60
|
+
})).describe("Column definitions matching the data structure"),
|
|
61
|
+
rows: import_zod.z.array(import_zod.z.array(import_zod.z.union([import_zod.z.string(), import_zod.z.number(), import_zod.z.null()]))).describe("Data rows - each row is an array of values matching column order"),
|
|
62
|
+
labels: import_zod.z.array(import_zod.z.string()).optional().describe("Labels for grouping import jobs (used by undoPrevious to revert jobs with same labels)"),
|
|
63
|
+
undoPrevious: import_zod.z.boolean().optional().describe("Revert previous import jobs with the same labels before committing (default: false)"),
|
|
64
|
+
importDimensions: import_zod.z.boolean().optional().describe("Auto-create any missing dimension members before committing (default: false)"),
|
|
65
|
+
overwriteCells: import_zod.z.boolean().optional().describe("Overwrite existing cell values (default: false - adds to existing values)")
|
|
66
|
+
};
|
|
67
|
+
const createFileSchema = {
|
|
68
|
+
tenant: import_zod.z.string().optional().describe("Tenant name (optional if checked out)"),
|
|
69
|
+
fileName: import_zod.z.string().describe("Name of the file to create or update"),
|
|
70
|
+
folderPath: import_zod.z.array(import_zod.z.string()).optional().describe('Folder path as array (e.g., ["Files", "Reports"]). Default: ["Files"]'),
|
|
71
|
+
content: import_zod.z.string().describe("File content as text string")
|
|
72
|
+
};
|
|
73
|
+
function registerDataTools(server) {
|
|
74
|
+
server.tool(
|
|
75
|
+
"farseer_export_variable_data",
|
|
76
|
+
`Export data from a Farseer variable as CSV or JSON.
|
|
77
|
+
|
|
78
|
+
Uses the ExportApi.exportFormula() method to export variable data.
|
|
79
|
+
The variable name is passed as the formula, and the result contains
|
|
80
|
+
all data cells for that variable across all its dimensions.
|
|
81
|
+
|
|
82
|
+
Returns the raw CSV/JSON text inline so you can analyze it directly.
|
|
83
|
+
|
|
84
|
+
Use the 'limit' parameter to restrict row count for large variables.
|
|
85
|
+
|
|
86
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
87
|
+
exportVariableDataSchema,
|
|
88
|
+
async (params) => {
|
|
89
|
+
const { tenant: tenantArg, variableName, format = "csv", limit } = params;
|
|
90
|
+
const checkout = (0, import_configService.getCurrentCheckout)();
|
|
91
|
+
const tenant = tenantArg || checkout?.tenant;
|
|
92
|
+
const organisation = tenantArg || checkout?.organisation;
|
|
93
|
+
if (!tenant || !organisation) {
|
|
94
|
+
return (0, import_helpers.tenantRequiredResponse)();
|
|
95
|
+
}
|
|
96
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
97
|
+
if (!nativeClient) {
|
|
98
|
+
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
const exportRequest = {
|
|
102
|
+
formula: variableName,
|
|
103
|
+
format
|
|
104
|
+
};
|
|
105
|
+
if (limit) {
|
|
106
|
+
exportRequest.limit = limit;
|
|
107
|
+
}
|
|
108
|
+
const blob = await nativeClient.export.exportFormula(exportRequest);
|
|
109
|
+
const text = await blob.text();
|
|
110
|
+
const lines = text.split("\n").filter((l) => l.trim()).length;
|
|
111
|
+
return (0, import_helpers.successResponse)({
|
|
112
|
+
tenant,
|
|
113
|
+
variable: variableName,
|
|
114
|
+
format,
|
|
115
|
+
rowCount: Math.max(0, lines - 1),
|
|
116
|
+
data: text
|
|
117
|
+
});
|
|
118
|
+
} catch (error) {
|
|
119
|
+
return (0, import_helpers.errorResponse)(
|
|
120
|
+
`Export variable data failed: ${await extractErrorMessage(error)}`,
|
|
121
|
+
"NETWORK_ERROR"
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
server.tool(
|
|
127
|
+
"farseer_load_variable_data",
|
|
128
|
+
`Load data from a Farseer variable into a structured CSV format.
|
|
129
|
+
|
|
130
|
+
Uses the ExportApi.exportFormula() method to export variable data as CSV.
|
|
131
|
+
Returns all data cells for the variable across all its dimensions.
|
|
132
|
+
|
|
133
|
+
You can optionally specify which dimensions to include for documentation,
|
|
134
|
+
but the export returns all dimensions by default.
|
|
135
|
+
|
|
136
|
+
Example usage:
|
|
137
|
+
- Load "Revenue" data
|
|
138
|
+
- Load "Revenue" with dimensions ["Product", "Years", "Months"]
|
|
139
|
+
|
|
140
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
141
|
+
loadVariableDataSchema,
|
|
142
|
+
async (params) => {
|
|
143
|
+
const { tenant: tenantArg, variableName, dimensions } = params;
|
|
144
|
+
const checkout = (0, import_configService.getCurrentCheckout)();
|
|
145
|
+
const tenant = tenantArg || checkout?.tenant;
|
|
146
|
+
const organisation = tenantArg || checkout?.organisation;
|
|
147
|
+
if (!tenant || !organisation) {
|
|
148
|
+
return (0, import_helpers.tenantRequiredResponse)();
|
|
149
|
+
}
|
|
150
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
151
|
+
if (!nativeClient) {
|
|
152
|
+
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
const blob = await nativeClient.export.exportFormula({
|
|
156
|
+
formula: variableName,
|
|
157
|
+
format: "csv"
|
|
158
|
+
});
|
|
159
|
+
const text = await blob.text();
|
|
160
|
+
const lines = text.split("\n").filter((l) => l.trim()).length;
|
|
161
|
+
const rowCount = Math.max(0, lines - 1);
|
|
162
|
+
return (0, import_helpers.successResponse)({
|
|
163
|
+
tenant,
|
|
164
|
+
variable: variableName,
|
|
165
|
+
dimensions: dimensions || "all",
|
|
166
|
+
rowCount,
|
|
167
|
+
data: text
|
|
168
|
+
});
|
|
169
|
+
} catch (error) {
|
|
170
|
+
return (0, import_helpers.errorResponse)(
|
|
171
|
+
`Load variable data failed: ${await extractErrorMessage(error)}`,
|
|
172
|
+
"NETWORK_ERROR"
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
server.tool(
|
|
178
|
+
"farseer_create_import_job",
|
|
179
|
+
`Create and execute a complete data import job on a Farseer instance.
|
|
180
|
+
|
|
181
|
+
This tool handles the full import workflow in a single call:
|
|
182
|
+
1. Builds import metadata from column definitions
|
|
183
|
+
2. Creates the import job
|
|
184
|
+
3. Adds all data rows
|
|
185
|
+
4. Optionally creates missing dimension members (importDimensions)
|
|
186
|
+
5. Optionally reverts previous imports with same labels (undoPrevious)
|
|
187
|
+
6. Commits the import
|
|
188
|
+
|
|
189
|
+
Column types:
|
|
190
|
+
- DIMENSION_TABLE: Maps to a dimension table (e.g., Product, Years, Months)
|
|
191
|
+
- VARIABLE: Maps to a variable that will receive data values
|
|
192
|
+
- Can include dimensionsNames to fix specific dimension members for this column
|
|
193
|
+
- DATE: Date column with format string
|
|
194
|
+
- DESCRIPTION: Cell description/comment
|
|
195
|
+
|
|
196
|
+
The 'labels' parameter is important for the undoPrevious feature:
|
|
197
|
+
when undoPrevious is true, all previously committed imports with the
|
|
198
|
+
same labels will be reverted before this import is committed.
|
|
199
|
+
This is useful for idempotent re-imports.
|
|
200
|
+
|
|
201
|
+
The 'overwriteCells' parameter controls whether existing values are
|
|
202
|
+
overwritten (true) or accumulated (false, default).
|
|
203
|
+
|
|
204
|
+
Example columns for importing revenue data:
|
|
205
|
+
[
|
|
206
|
+
{ "type": "DIMENSION_TABLE", "dimensionTableName": "Product" },
|
|
207
|
+
{ "type": "DIMENSION_TABLE", "dimensionTableName": "Years" },
|
|
208
|
+
{ "type": "DIMENSION_TABLE", "dimensionTableName": "Months" },
|
|
209
|
+
{ "type": "VARIABLE", "variableName": "Revenue",
|
|
210
|
+
"dimensionsNames": [
|
|
211
|
+
{ "tableName": "Versions", "memberName": "Actual" }
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
]
|
|
215
|
+
|
|
216
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
217
|
+
createImportJobSchema,
|
|
218
|
+
async (params) => {
|
|
219
|
+
const {
|
|
220
|
+
tenant: tenantArg,
|
|
221
|
+
title,
|
|
222
|
+
columns,
|
|
223
|
+
rows,
|
|
224
|
+
labels,
|
|
225
|
+
undoPrevious = false,
|
|
226
|
+
importDimensions = false,
|
|
227
|
+
overwriteCells = false
|
|
228
|
+
} = params;
|
|
229
|
+
const checkout = (0, import_configService.getCurrentCheckout)();
|
|
230
|
+
const tenant = tenantArg || checkout?.tenant;
|
|
231
|
+
const organisation = tenantArg || checkout?.organisation;
|
|
232
|
+
if (!tenant || !organisation) {
|
|
233
|
+
return (0, import_helpers.tenantRequiredResponse)();
|
|
234
|
+
}
|
|
235
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
236
|
+
if (!nativeClient) {
|
|
237
|
+
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
238
|
+
}
|
|
239
|
+
try {
|
|
240
|
+
await nativeClient.initTagMap();
|
|
241
|
+
const metadataColumns = columns.map((col) => {
|
|
242
|
+
switch (col.type) {
|
|
243
|
+
case "DIMENSION_TABLE":
|
|
244
|
+
return {
|
|
245
|
+
type: "DIMENSION_TABLE",
|
|
246
|
+
dimensionTableName: col.dimensionTableName,
|
|
247
|
+
columnName: col.columnName
|
|
248
|
+
};
|
|
249
|
+
case "VARIABLE":
|
|
250
|
+
return {
|
|
251
|
+
type: "VARIABLE",
|
|
252
|
+
variableName: col.variableName,
|
|
253
|
+
columnName: col.columnName || col.variableName,
|
|
254
|
+
dimensionsNames: col.dimensionsNames
|
|
255
|
+
};
|
|
256
|
+
case "DATE":
|
|
257
|
+
return {
|
|
258
|
+
type: "DATE",
|
|
259
|
+
dateFormat: col.dateFormat,
|
|
260
|
+
columnName: col.columnName
|
|
261
|
+
};
|
|
262
|
+
case "DESCRIPTION":
|
|
263
|
+
return {
|
|
264
|
+
type: "DESCRIPTION",
|
|
265
|
+
columnName: col.columnName
|
|
266
|
+
};
|
|
267
|
+
default:
|
|
268
|
+
return {
|
|
269
|
+
type: "NONE",
|
|
270
|
+
columnName: col.columnName
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
const metadata = await nativeClient.buildImportJobMetadata(metadataColumns);
|
|
275
|
+
if (overwriteCells) {
|
|
276
|
+
metadata.overwriteCells = true;
|
|
277
|
+
}
|
|
278
|
+
const importActions = await nativeClient.createImportJob({
|
|
279
|
+
title,
|
|
280
|
+
metadata,
|
|
281
|
+
labels
|
|
282
|
+
});
|
|
283
|
+
await importActions.addRows(rows);
|
|
284
|
+
await importActions.flushRows();
|
|
285
|
+
if (importDimensions) {
|
|
286
|
+
await importActions.importDimensions();
|
|
287
|
+
}
|
|
288
|
+
if (undoPrevious) {
|
|
289
|
+
await importActions.undoPrevious();
|
|
290
|
+
}
|
|
291
|
+
const report = await importActions.commit();
|
|
292
|
+
return (0, import_helpers.successResponse)({
|
|
293
|
+
tenant,
|
|
294
|
+
title,
|
|
295
|
+
rowCount: rows.length,
|
|
296
|
+
labels: labels || [],
|
|
297
|
+
undoPrevious,
|
|
298
|
+
importDimensions,
|
|
299
|
+
overwriteCells,
|
|
300
|
+
commitReport: report
|
|
301
|
+
});
|
|
302
|
+
} catch (error) {
|
|
303
|
+
return (0, import_helpers.errorResponse)(
|
|
304
|
+
`Import job failed: ${await extractErrorMessage(error)}`,
|
|
305
|
+
"NETWORK_ERROR"
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
server.tool(
|
|
311
|
+
"farseer_create_file",
|
|
312
|
+
`Create or update a file on a Farseer instance.
|
|
313
|
+
|
|
314
|
+
This creates a file in the specified folder on the Farseer file system.
|
|
315
|
+
If a file with the same name already exists in that folder, it will be updated.
|
|
316
|
+
|
|
317
|
+
The folderPath is an array of folder names, starting from the root.
|
|
318
|
+
Default is ["Files"] which is the standard files folder.
|
|
319
|
+
|
|
320
|
+
Common use cases:
|
|
321
|
+
- Creating CSV report files
|
|
322
|
+
- Uploading configuration files
|
|
323
|
+
- Saving processed data outputs
|
|
324
|
+
|
|
325
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
326
|
+
createFileSchema,
|
|
327
|
+
async (params) => {
|
|
328
|
+
const { tenant: tenantArg, fileName, folderPath = ["Files"], content } = params;
|
|
329
|
+
const checkout = (0, import_configService.getCurrentCheckout)();
|
|
330
|
+
const tenant = tenantArg || checkout?.tenant;
|
|
331
|
+
const organisation = tenantArg || checkout?.organisation;
|
|
332
|
+
if (!tenant || !organisation) {
|
|
333
|
+
return (0, import_helpers.tenantRequiredResponse)();
|
|
334
|
+
}
|
|
335
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
336
|
+
if (!nativeClient) {
|
|
337
|
+
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
338
|
+
}
|
|
339
|
+
try {
|
|
340
|
+
const folder = await nativeClient.getItemByPath(folderPath);
|
|
341
|
+
const buffer = Buffer.from(content, "utf-8");
|
|
342
|
+
await nativeClient.createOrUpdateFarseerFile(
|
|
343
|
+
{ name: fileName, folderId: folder.id },
|
|
344
|
+
buffer
|
|
345
|
+
);
|
|
346
|
+
return (0, import_helpers.successResponse)({
|
|
347
|
+
tenant,
|
|
348
|
+
fileName,
|
|
349
|
+
folderPath,
|
|
350
|
+
size: buffer.length,
|
|
351
|
+
message: `File "${fileName}" created/updated in ${folderPath.join("/")}`
|
|
352
|
+
});
|
|
353
|
+
} catch (error) {
|
|
354
|
+
return (0, import_helpers.errorResponse)(
|
|
355
|
+
`Create file failed: ${await extractErrorMessage(error)}`,
|
|
356
|
+
"NETWORK_ERROR"
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
363
|
+
0 && (module.exports = {
|
|
364
|
+
registerDataTools
|
|
365
|
+
});
|
|
366
|
+
//# sourceMappingURL=dataTools.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 { getNativeFarseerClient } from '../../services/farseerFactory';\nimport { getCurrentCheckout } from '../../services/configService';\nimport {\n successResponse,\n errorResponse,\n authRequiredResponse,\n tenantRequiredResponse,\n} from '../utils/helpers';\n\nasync function extractErrorMessage(error: unknown): Promise<string> {\n if (error instanceof Error) return error.message;\n if (error && typeof error === 'object' && 'status' in error && 'statusText' in error) {\n const resp = error as { status: number; statusText: string; text?: () => Promise<string> };\n const body = resp.text ? await resp.text() : '';\n return `HTTP ${resp.status} ${resp.statusText}${body ? ': ' + body : ''}`;\n }\n return String(error);\n}\n\n// Define schemas outside of tool registration to avoid deep type instantiation\nconst exportVariableDataSchema = {\n tenant: z.string().optional().describe('Tenant name (optional if checked out)'),\n variableName: z.string().describe('Name of the variable to export'),\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 tenant: z.string().optional().describe('Tenant name (optional if checked out)'),\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 tenant: z.string().optional().describe('Tenant name (optional if checked out)'),\n title: z.string().describe('Import job title (shown in import history)'),\n columns: z.array(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.array(z.object({\n tableName: z.string(),\n memberName: z.string(),\n })).optional().describe('For VARIABLE: fixed dimension members (filters) for this variable column'),\n })).describe('Column definitions matching the data structure'),\n rows: z.array(z.array(z.union([z.string(), z.number(), z.null()]))).describe('Data rows - each row is an array of values matching column order'),\n labels: z.array(z.string()).optional().describe('Labels for grouping import jobs (used by undoPrevious to revert jobs with same labels)'),\n undoPrevious: z.boolean().optional().describe('Revert previous import jobs with the same labels before committing (default: false)'),\n importDimensions: z.boolean().optional().describe('Auto-create any missing dimension members before committing (default: false)'),\n overwriteCells: z.boolean().optional().describe('Overwrite existing cell values (default: false - adds to existing values)'),\n};\n\nconst createFileSchema = {\n tenant: z.string().optional().describe('Tenant name (optional if checked out)'),\n fileName: z.string().describe('Name of the file to create or update'),\n folderPath: z.array(z.string()).optional().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 or JSON.\n\nUses the ExportApi.exportFormula() method to export variable data.\nThe variable name is passed as the formula, and the result contains\nall data cells for that variable across all its dimensions.\n\nReturns the raw CSV/JSON text inline so you can analyze it directly.\n\nUse the 'limit' parameter to restrict row count for large variables.\n\nIf no tenant is specified, uses the currently checked-out tenant.`,\n exportVariableDataSchema,\n async (params: { tenant?: string; variableName: string; format?: 'csv' | 'json'; limit?: number }) => {\n const { tenant: tenantArg, variableName, format = 'csv', limit } = params;\n const checkout = getCurrentCheckout();\n const tenant = tenantArg || checkout?.tenant;\n const organisation = tenantArg || checkout?.organisation;\n\n if (!tenant || !organisation) {\n return tenantRequiredResponse();\n }\n\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n if (!nativeClient) {\n return authRequiredResponse(tenant);\n }\n\n try {\n const exportRequest: any = {\n formula: variableName,\n format,\n };\n if (limit) {\n exportRequest.limit = limit;\n }\n\n const blob = await nativeClient.export.exportFormula(exportRequest);\n const text = await blob.text();\n\n const lines = text.split('\\n').filter(l => l.trim()).length;\n\n return successResponse({\n tenant,\n variable: variableName,\n format,\n rowCount: Math.max(0, lines - 1),\n data: text,\n });\n } catch (error) {\n return errorResponse(\n `Export variable data failed: ${await extractErrorMessage(error)}`,\n 'NETWORK_ERROR'\n );\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\nUses the ExportApi.exportFormula() method to export variable data as CSV.\nReturns all data cells for the variable across all its dimensions.\n\nYou can optionally specify which dimensions to include for documentation,\nbut the export returns all dimensions by default.\n\nExample usage:\n- Load \"Revenue\" data\n- Load \"Revenue\" with dimensions [\"Product\", \"Years\", \"Months\"]\n\nIf no tenant is specified, uses the currently checked-out tenant.`,\n loadVariableDataSchema,\n async (params: { tenant?: string; variableName: string; dimensions?: string[] }) => {\n const { tenant: tenantArg, variableName, dimensions } = params;\n const checkout = getCurrentCheckout();\n const tenant = tenantArg || checkout?.tenant;\n const organisation = tenantArg || checkout?.organisation;\n\n if (!tenant || !organisation) {\n return tenantRequiredResponse();\n }\n\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n if (!nativeClient) {\n return authRequiredResponse(tenant);\n }\n\n try {\n const blob = await nativeClient.export.exportFormula({\n formula: variableName,\n format: 'csv',\n });\n const text = await blob.text();\n\n const lines = text.split('\\n').filter(l => l.trim()).length;\n const rowCount = Math.max(0, lines - 1);\n\n return successResponse({\n tenant,\n variable: variableName,\n dimensions: dimensions || 'all',\n rowCount,\n data: text,\n });\n } catch (error) {\n return errorResponse(\n `Load variable data failed: ${await extractErrorMessage(error)}`,\n 'NETWORK_ERROR'\n );\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\nIf no tenant is specified, uses the currently checked-out tenant.`,\n createImportJobSchema,\n async (params: {\n tenant?: string;\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 {\n tenant: tenantArg,\n title,\n columns,\n rows,\n labels,\n undoPrevious = false,\n importDimensions = false,\n overwriteCells = false,\n } = params;\n const checkout = getCurrentCheckout();\n const tenant = tenantArg || checkout?.tenant;\n const organisation = tenantArg || checkout?.organisation;\n\n if (!tenant || !organisation) {\n return tenantRequiredResponse();\n }\n\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n if (!nativeClient) {\n return authRequiredResponse(tenant);\n }\n\n try {\n await nativeClient.initTagMap();\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(\n `Import job failed: ${await extractErrorMessage(error)}`,\n 'NETWORK_ERROR'\n );\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\nIf no tenant is specified, uses the currently checked-out tenant.`,\n createFileSchema,\n async (params: {\n tenant?: string;\n fileName: string;\n folderPath?: string[];\n content: string;\n }) => {\n const { tenant: tenantArg, fileName, folderPath = ['Files'], content } = params;\n const checkout = getCurrentCheckout();\n const tenant = tenantArg || checkout?.tenant;\n const organisation = tenantArg || checkout?.organisation;\n\n if (!tenant || !organisation) {\n return tenantRequiredResponse();\n }\n\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n if (!nativeClient) {\n return authRequiredResponse(tenant);\n }\n\n try {\n const folder = await nativeClient.getItemByPath(folderPath);\n const buffer = Buffer.from(content, 'utf-8');\n\n await nativeClient.createOrUpdateFarseerFile(\n { name: fileName, folderId: folder.id } as any,\n buffer\n );\n\n return successResponse({\n tenant,\n fileName,\n folderPath,\n size: buffer.length,\n message: `File \"${fileName}\" created/updated in ${folderPath.join('/')}`,\n });\n } catch (error) {\n return errorResponse(\n `Create file failed: ${await extractErrorMessage(error)}`,\n 'NETWORK_ERROR'\n );\n }\n }\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AC;AAAA,MACL,SAAS,OAAO;AACZ,mBAAO;AAAA,UACH,uBAAuB,MAAM,oBAAoB,KAAK,CAAC;AAAA,UACvD;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
var farseerFactory_exports = {};
|
|
19
29
|
__export(farseerFactory_exports, {
|
|
@@ -22,10 +32,12 @@ __export(farseerFactory_exports, {
|
|
|
22
32
|
getAvailableAuth: () => getAvailableAuth,
|
|
23
33
|
getFarseerClient: () => getFarseerClient,
|
|
24
34
|
getFarseerClientWithFallback: () => getFarseerClientWithFallback,
|
|
35
|
+
getNativeFarseerClient: () => getNativeFarseerClient,
|
|
25
36
|
isAuthError: () => isAuthError,
|
|
26
37
|
showLoginPrompt: () => showLoginPrompt
|
|
27
38
|
});
|
|
28
39
|
module.exports = __toCommonJS(farseerFactory_exports);
|
|
40
|
+
var farseer = __toESM(require("farseer-client"));
|
|
29
41
|
var import_farseerService = require("./farseerService");
|
|
30
42
|
var import_farseerApi = require("./farseerApi");
|
|
31
43
|
var import_configService = require("./configService");
|
|
@@ -166,6 +178,45 @@ async function ensureFreshToken(client) {
|
|
|
166
178
|
}
|
|
167
179
|
return false;
|
|
168
180
|
}
|
|
181
|
+
async function getNativeFarseerClient(organisation, tenant) {
|
|
182
|
+
const basePath = (0, import_configService.generateBasePath)(organisation);
|
|
183
|
+
const auth = (0, import_configService.getUserAuth)();
|
|
184
|
+
if (auth) {
|
|
185
|
+
let accessToken = auth.accessToken;
|
|
186
|
+
if (!(0, import_configService.isUserAuthValid)()) {
|
|
187
|
+
const refreshed = await (0, import_farseerService2.refreshAccessToken)(auth.refreshToken, auth.realm || "master");
|
|
188
|
+
if (refreshed) {
|
|
189
|
+
(0, import_configService.setUserAuth)({
|
|
190
|
+
accessToken: refreshed.accessToken,
|
|
191
|
+
refreshToken: refreshed.refreshToken,
|
|
192
|
+
expiresAt: new Date(Date.now() + refreshed.expiresIn * 1e3).toISOString(),
|
|
193
|
+
realm: auth.realm
|
|
194
|
+
});
|
|
195
|
+
accessToken = refreshed.accessToken;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if ((0, import_configService.isUserAuthValid)()) {
|
|
199
|
+
return new farseer.FarseerClient({
|
|
200
|
+
basePath,
|
|
201
|
+
headers: {
|
|
202
|
+
"X-TENANT-ID": tenant,
|
|
203
|
+
"Authorization": `Bearer ${accessToken}`
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const credential = (0, import_configService.getCredential)(tenant);
|
|
209
|
+
if (credential) {
|
|
210
|
+
return new farseer.FarseerClient({
|
|
211
|
+
basePath: credential.basePath,
|
|
212
|
+
headers: {
|
|
213
|
+
"X-TENANT-ID": credential.tenantId,
|
|
214
|
+
"X-API-KEY": credential.apiKey
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
169
220
|
// Annotate the CommonJS export names for ESM import in node:
|
|
170
221
|
0 && (module.exports = {
|
|
171
222
|
DEFAULT_SCRIPT_EXTENSIONS,
|
|
@@ -173,6 +224,7 @@ async function ensureFreshToken(client) {
|
|
|
173
224
|
getAvailableAuth,
|
|
174
225
|
getFarseerClient,
|
|
175
226
|
getFarseerClientWithFallback,
|
|
227
|
+
getNativeFarseerClient,
|
|
176
228
|
isAuthError,
|
|
177
229
|
showLoginPrompt
|
|
178
230
|
});
|