farseer-cli 1.0.8 → 1.0.9

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.
Files changed (81) hide show
  1. package/dist/commands/app.js +349 -0
  2. package/dist/commands/app.js.map +7 -0
  3. package/dist/commands/apps.js +111 -0
  4. package/dist/commands/apps.js.map +7 -0
  5. package/dist/commands/checkout.js +142 -0
  6. package/dist/commands/checkout.js.map +7 -0
  7. package/dist/commands/config.js +139 -0
  8. package/dist/commands/config.js.map +7 -0
  9. package/dist/commands/diff.js +185 -0
  10. package/dist/commands/diff.js.map +7 -0
  11. package/dist/commands/dimensions.js +145 -0
  12. package/dist/commands/dimensions.js.map +7 -0
  13. package/dist/commands/files.js +99 -0
  14. package/dist/commands/files.js.map +7 -0
  15. package/dist/commands/install.js +79 -0
  16. package/dist/commands/install.js.map +7 -0
  17. package/dist/commands/list.js +92 -0
  18. package/dist/commands/list.js.map +7 -0
  19. package/dist/commands/login.js +134 -0
  20. package/dist/commands/login.js.map +7 -0
  21. package/dist/commands/logout.js +59 -0
  22. package/dist/commands/logout.js.map +7 -0
  23. package/dist/commands/mcp-server.js +41 -0
  24. package/dist/commands/mcp-server.js.map +7 -0
  25. package/dist/commands/model.js +189 -0
  26. package/dist/commands/model.js.map +7 -0
  27. package/dist/commands/pull.js +258 -0
  28. package/dist/commands/pull.js.map +7 -0
  29. package/dist/commands/push.js +213 -0
  30. package/dist/commands/push.js.map +7 -0
  31. package/dist/commands/run.js +288 -0
  32. package/dist/commands/run.js.map +7 -0
  33. package/dist/commands/status.js +155 -0
  34. package/dist/commands/status.js.map +7 -0
  35. package/dist/commands/variables.js +176 -0
  36. package/dist/commands/variables.js.map +7 -0
  37. package/dist/commands/whoami.js +63 -0
  38. package/dist/commands/whoami.js.map +7 -0
  39. package/dist/index.js +165 -0
  40. package/dist/index.js.map +7 -0
  41. package/dist/mcp/index.js +35 -0
  42. package/dist/mcp/index.js.map +7 -0
  43. package/dist/mcp/prompts/workflows.js +448 -0
  44. package/dist/mcp/prompts/workflows.js.map +7 -0
  45. package/dist/mcp/resources/documentation.js +167 -0
  46. package/dist/mcp/resources/documentation.js.map +7 -0
  47. package/dist/mcp/server.js +52 -0
  48. package/dist/mcp/server.js.map +7 -0
  49. package/dist/mcp/tools/appTools.js +377 -0
  50. package/dist/mcp/tools/appTools.js.map +7 -0
  51. package/dist/mcp/tools/authTools.js +159 -0
  52. package/dist/mcp/tools/authTools.js.map +7 -0
  53. package/dist/mcp/tools/dataTools.js +362 -0
  54. package/dist/mcp/tools/dataTools.js.map +7 -0
  55. package/dist/mcp/tools/modelTools.js +325 -0
  56. package/dist/mcp/tools/modelTools.js.map +7 -0
  57. package/dist/mcp/tools/runTools.js +233 -0
  58. package/dist/mcp/tools/runTools.js.map +7 -0
  59. package/dist/mcp/tools/syncTools.js +409 -0
  60. package/dist/mcp/tools/syncTools.js.map +7 -0
  61. package/dist/mcp/utils/helpers.js +135 -0
  62. package/dist/mcp/utils/helpers.js.map +7 -0
  63. package/dist/services/appSyncService.js +399 -0
  64. package/dist/services/appSyncService.js.map +7 -0
  65. package/dist/services/configService.js +196 -0
  66. package/dist/services/configService.js.map +7 -0
  67. package/dist/services/farseerApi.js +426 -0
  68. package/dist/services/farseerApi.js.map +7 -0
  69. package/dist/services/farseerFactory.js +231 -0
  70. package/dist/services/farseerFactory.js.map +7 -0
  71. package/dist/services/farseerService.js +614 -0
  72. package/dist/services/farseerService.js.map +7 -0
  73. package/dist/services/syncService.js +689 -0
  74. package/dist/services/syncService.js.map +7 -0
  75. package/dist/utils/constants.js +46 -0
  76. package/dist/utils/constants.js.map +7 -0
  77. package/dist/utils/helpers.js +413 -0
  78. package/dist/utils/helpers.js.map +7 -0
  79. package/dist/utils/logger.js +76 -0
  80. package/dist/utils/logger.js.map +7 -0
  81. package/package.json +1 -1
@@ -0,0 +1,167 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
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
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var documentation_exports = {};
29
+ __export(documentation_exports, {
30
+ registerDocumentationResources: () => registerDocumentationResources
31
+ });
32
+ module.exports = __toCommonJS(documentation_exports);
33
+ var fs = __toESM(require("fs"));
34
+ var path = __toESM(require("path"));
35
+ const DOCS = [
36
+ {
37
+ name: "how-farseer-works",
38
+ uri: "farseer://docs/how-farseer-works",
39
+ title: "How Farseer Works",
40
+ description: "Core Farseer concepts: Dimensions, Variables, Formulas, Versions. ESSENTIAL reading for understanding the data model.",
41
+ filePath: "../../../docs/how-farseer-works.md"
42
+ },
43
+ {
44
+ name: "cli-guide",
45
+ uri: "farseer://docs/cli-guide",
46
+ title: "CLI Guide",
47
+ description: "Complete guide to Farseer CLI commands: pull, push, apps, run, model, checkout.",
48
+ filePath: "../../../docs/cli-guide.md"
49
+ },
50
+ {
51
+ name: "api-reference",
52
+ uri: "farseer://docs/api-reference",
53
+ title: "farseer-client API Reference",
54
+ description: "Full API documentation for farseer-client: FarseerClient, queries, imports, dimensions, variables.",
55
+ filePath: "../../../docs/api-reference.md"
56
+ },
57
+ {
58
+ name: "new-app-template",
59
+ uri: "farseer://docs/new-app-template",
60
+ title: "New App Template",
61
+ description: "Template and structure for creating new Farseer apps (Remote Jobs).",
62
+ filePath: "../../../docs/new-app-template.md"
63
+ },
64
+ {
65
+ name: "troubleshooting",
66
+ uri: "farseer://docs/troubleshooting",
67
+ title: "Troubleshooting Guide",
68
+ description: "Common issues and solutions: auth errors, sync conflicts, API errors, performance.",
69
+ filePath: "../../../docs/troubleshooting.md"
70
+ },
71
+ {
72
+ name: "import-workflows",
73
+ uri: "farseer://docs/import-workflows",
74
+ title: "Import Workflows",
75
+ description: "Patterns for data imports: CSV, Excel, API, batch processing, error handling.",
76
+ filePath: "../../../docs/import-workflows.md"
77
+ },
78
+ {
79
+ name: "arquero-patterns",
80
+ uri: "farseer://docs/arquero-patterns",
81
+ title: "Arquero Data Processing",
82
+ description: "Using Arquero for data transformation: filtering, grouping, pivoting, joins.",
83
+ filePath: "../../../docs/arquero-patterns.md"
84
+ },
85
+ {
86
+ name: "query-formulas",
87
+ uri: "farseer://docs/query-formulas",
88
+ title: "Query and Formula Guide",
89
+ description: "Querying data and understanding formulas: filters, aggregations, formula syntax.",
90
+ filePath: "../../../docs/query-formulas.md"
91
+ },
92
+ {
93
+ name: "model-export",
94
+ uri: "farseer://docs/model-export",
95
+ title: "Model Export Guide",
96
+ description: "Understanding model exports: tables, variables, relationships, folder structure.",
97
+ filePath: "../../../docs/model-export.md"
98
+ }
99
+ ];
100
+ function loadDocContent(doc) {
101
+ try {
102
+ const fullPath = path.resolve(__dirname, doc.filePath);
103
+ return fs.readFileSync(fullPath, "utf-8");
104
+ } catch (error) {
105
+ return `# ${doc.title}
106
+
107
+ [Documentation file not found: ${doc.filePath}]
108
+
109
+ This may happen if the CLI was installed globally and documentation files were not included in the package.`;
110
+ }
111
+ }
112
+ function registerDocumentationResources(server) {
113
+ server.resource(
114
+ "farseer-docs-list",
115
+ "farseer://docs",
116
+ {
117
+ description: "List of all available Farseer documentation",
118
+ mimeType: "application/json"
119
+ },
120
+ () => {
121
+ return {
122
+ contents: [
123
+ {
124
+ uri: "farseer://docs",
125
+ mimeType: "application/json",
126
+ text: JSON.stringify(
127
+ DOCS.map((doc) => ({
128
+ name: doc.name,
129
+ uri: doc.uri,
130
+ title: doc.title,
131
+ description: doc.description
132
+ })),
133
+ null,
134
+ 2
135
+ )
136
+ }
137
+ ]
138
+ };
139
+ }
140
+ );
141
+ for (const doc of DOCS) {
142
+ server.resource(
143
+ doc.name,
144
+ doc.uri,
145
+ {
146
+ description: doc.description,
147
+ mimeType: "text/markdown"
148
+ },
149
+ () => {
150
+ return {
151
+ contents: [
152
+ {
153
+ uri: doc.uri,
154
+ mimeType: "text/markdown",
155
+ text: loadDocContent(doc)
156
+ }
157
+ ]
158
+ };
159
+ }
160
+ );
161
+ }
162
+ }
163
+ // Annotate the CommonJS export names for ESM import in node:
164
+ 0 && (module.exports = {
165
+ registerDocumentationResources
166
+ });
167
+ //# sourceMappingURL=documentation.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/mcp/resources/documentation.ts"],
4
+ "sourcesContent": ["/**\n * Documentation Resources\n *\n * Exposes Farseer documentation as MCP resources for AI assistants.\n * Documentation is read from files at runtime (bundled with npm package).\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\ninterface DocResource {\n name: string;\n uri: string;\n title: string;\n description: string;\n filePath: string;\n}\n\n// Documentation metadata - actual content loaded on demand\nconst DOCS: DocResource[] = [\n {\n name: 'how-farseer-works',\n uri: 'farseer://docs/how-farseer-works',\n title: 'How Farseer Works',\n description:\n 'Core Farseer concepts: Dimensions, Variables, Formulas, Versions. ESSENTIAL reading for understanding the data model.',\n filePath: '../../../docs/how-farseer-works.md',\n },\n {\n name: 'cli-guide',\n uri: 'farseer://docs/cli-guide',\n title: 'CLI Guide',\n description: 'Complete guide to Farseer CLI commands: pull, push, apps, run, model, checkout.',\n filePath: '../../../docs/cli-guide.md',\n },\n {\n name: 'api-reference',\n uri: 'farseer://docs/api-reference',\n title: 'farseer-client API Reference',\n description:\n 'Full API documentation for farseer-client: FarseerClient, queries, imports, dimensions, variables.',\n filePath: '../../../docs/api-reference.md',\n },\n {\n name: 'new-app-template',\n uri: 'farseer://docs/new-app-template',\n title: 'New App Template',\n description: 'Template and structure for creating new Farseer apps (Remote Jobs).',\n filePath: '../../../docs/new-app-template.md',\n },\n {\n name: 'troubleshooting',\n uri: 'farseer://docs/troubleshooting',\n title: 'Troubleshooting Guide',\n description: 'Common issues and solutions: auth errors, sync conflicts, API errors, performance.',\n filePath: '../../../docs/troubleshooting.md',\n },\n {\n name: 'import-workflows',\n uri: 'farseer://docs/import-workflows',\n title: 'Import Workflows',\n description: 'Patterns for data imports: CSV, Excel, API, batch processing, error handling.',\n filePath: '../../../docs/import-workflows.md',\n },\n {\n name: 'arquero-patterns',\n uri: 'farseer://docs/arquero-patterns',\n title: 'Arquero Data Processing',\n description: 'Using Arquero for data transformation: filtering, grouping, pivoting, joins.',\n filePath: '../../../docs/arquero-patterns.md',\n },\n {\n name: 'query-formulas',\n uri: 'farseer://docs/query-formulas',\n title: 'Query and Formula Guide',\n description: 'Querying data and understanding formulas: filters, aggregations, formula syntax.',\n filePath: '../../../docs/query-formulas.md',\n },\n {\n name: 'model-export',\n uri: 'farseer://docs/model-export',\n title: 'Model Export Guide',\n description: 'Understanding model exports: tables, variables, relationships, folder structure.',\n filePath: '../../../docs/model-export.md',\n },\n];\n\nfunction loadDocContent(doc: DocResource): string {\n try {\n const fullPath = path.resolve(__dirname, doc.filePath);\n return fs.readFileSync(fullPath, 'utf-8');\n } catch (error) {\n return `# ${doc.title}\\n\\n[Documentation file not found: ${doc.filePath}]\\n\\nThis may happen if the CLI was installed globally and documentation files were not included in the package.`;\n }\n}\n\nexport function registerDocumentationResources(server: McpServer): void {\n // Register list of all docs\n server.resource(\n 'farseer-docs-list',\n 'farseer://docs',\n {\n description: 'List of all available Farseer documentation',\n mimeType: 'application/json',\n },\n () => {\n return {\n contents: [\n {\n uri: 'farseer://docs',\n mimeType: 'application/json',\n text: JSON.stringify(\n DOCS.map((doc) => ({\n name: doc.name,\n uri: doc.uri,\n title: doc.title,\n description: doc.description,\n })),\n null,\n 2\n ),\n },\n ],\n };\n }\n );\n\n // Register each doc individually\n for (const doc of DOCS) {\n server.resource(\n doc.name,\n doc.uri,\n {\n description: doc.description,\n mimeType: 'text/markdown',\n },\n () => {\n return {\n contents: [\n {\n uri: doc.uri,\n mimeType: 'text/markdown',\n text: loadDocContent(doc),\n },\n ],\n };\n }\n );\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,SAAoB;AACpB,WAAsB;AAWtB,MAAM,OAAsB;AAAA,EACxB;AAAA,IACI,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aACI;AAAA,IACJ,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,IACb,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aACI;AAAA,IACJ,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,IACb,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,IACb,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,IACb,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,IACb,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,IACb,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,IACb,UAAU;AAAA,EACd;AACJ;AAEA,SAAS,eAAe,KAA0B;AAC9C,MAAI;AACA,UAAM,WAAW,KAAK,QAAQ,WAAW,IAAI,QAAQ;AACrD,WAAO,GAAG,aAAa,UAAU,OAAO;AAAA,EAC5C,SAAS,OAAO;AACZ,WAAO,KAAK,IAAI,KAAK;AAAA;AAAA,iCAAsC,IAAI,QAAQ;AAAA;AAAA;AAAA,EAC3E;AACJ;AAEO,SAAS,+BAA+B,QAAyB;AAEpE,SAAO;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,MACI,aAAa;AAAA,MACb,UAAU;AAAA,IACd;AAAA,IACA,MAAM;AACF,aAAO;AAAA,QACH,UAAU;AAAA,UACN;AAAA,YACI,KAAK;AAAA,YACL,UAAU;AAAA,YACV,MAAM,KAAK;AAAA,cACP,KAAK,IAAI,CAAC,SAAS;AAAA,gBACf,MAAM,IAAI;AAAA,gBACV,KAAK,IAAI;AAAA,gBACT,OAAO,IAAI;AAAA,gBACX,aAAa,IAAI;AAAA,cACrB,EAAE;AAAA,cACF;AAAA,cACA;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AAGA,aAAW,OAAO,MAAM;AACpB,WAAO;AAAA,MACH,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ;AAAA,QACI,aAAa,IAAI;AAAA,QACjB,UAAU;AAAA,MACd;AAAA,MACA,MAAM;AACF,eAAO;AAAA,UACH,UAAU;AAAA,YACN;AAAA,cACI,KAAK,IAAI;AAAA,cACT,UAAU;AAAA,cACV,MAAM,eAAe,GAAG;AAAA,YAC5B;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,52 @@
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 server_exports = {};
19
+ __export(server_exports, {
20
+ createMcpServer: () => createMcpServer
21
+ });
22
+ module.exports = __toCommonJS(server_exports);
23
+ var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
24
+ var import_constants = require("../utils/constants");
25
+ var import_authTools = require("./tools/authTools");
26
+ var import_syncTools = require("./tools/syncTools");
27
+ var import_appTools = require("./tools/appTools");
28
+ var import_modelTools = require("./tools/modelTools");
29
+ var import_runTools = require("./tools/runTools");
30
+ var import_dataTools = require("./tools/dataTools");
31
+ var import_documentation = require("./resources/documentation");
32
+ var import_workflows = require("./prompts/workflows");
33
+ function createMcpServer() {
34
+ const server = new import_mcp.McpServer({
35
+ name: "farseer-cli",
36
+ version: import_constants.CLI_VERSION
37
+ });
38
+ (0, import_authTools.registerAuthTools)(server);
39
+ (0, import_syncTools.registerSyncTools)(server);
40
+ (0, import_appTools.registerAppTools)(server);
41
+ (0, import_modelTools.registerModelTools)(server);
42
+ (0, import_runTools.registerRunTools)(server);
43
+ (0, import_dataTools.registerDataTools)(server);
44
+ (0, import_documentation.registerDocumentationResources)(server);
45
+ (0, import_workflows.registerWorkflowPrompts)(server);
46
+ return server;
47
+ }
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ createMcpServer
51
+ });
52
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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 { 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
+ "names": []
7
+ }
@@ -0,0 +1,377 @@
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 appTools_exports = {};
19
+ __export(appTools_exports, {
20
+ registerAppTools: () => registerAppTools
21
+ });
22
+ module.exports = __toCommonJS(appTools_exports);
23
+ var import_zod = require("zod");
24
+ var import_farseerFactory = require("../../services/farseerFactory");
25
+ var import_helpers = require("../utils/helpers");
26
+ const listAppsSchema = {
27
+ organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
28
+ tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
29
+ details: import_zod.z.boolean().optional().describe("Include full details for each app")
30
+ };
31
+ const getAppSchema = {
32
+ organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
33
+ tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
34
+ appName: import_zod.z.string().describe("Name of the app (can include spaces)")
35
+ };
36
+ const createAppSchema = {
37
+ organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
38
+ tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
39
+ appName: import_zod.z.string().describe("Name for the new app")
40
+ };
41
+ const argumentSchema = import_zod.z.object({
42
+ name: import_zod.z.string(),
43
+ defaultValue: import_zod.z.string()
44
+ });
45
+ const configureAppSchema = {
46
+ organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
47
+ tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
48
+ appName: import_zod.z.string().describe("Name of the app to configure"),
49
+ entrypoint: import_zod.z.string().optional().describe('Main script filename (e.g., "index.ts")'),
50
+ scripts: import_zod.z.array(import_zod.z.string()).optional().describe("List of script filenames to include"),
51
+ description: import_zod.z.string().optional().describe("App description"),
52
+ arguments: import_zod.z.array(argumentSchema).optional().describe("App arguments with default values"),
53
+ newName: import_zod.z.string().optional().describe("Rename the app")
54
+ };
55
+ const deleteAppSchema = {
56
+ organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
57
+ tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
58
+ appName: import_zod.z.string().describe("Name of the app to delete")
59
+ };
60
+ function registerAppTools(server) {
61
+ const s = server;
62
+ s.tool(
63
+ "farseer_list_apps",
64
+ `List all apps (Remote Jobs) configured on a Farseer tenant.
65
+
66
+ Apps are executable script configurations that include:
67
+ - Entry point script
68
+ - List of included scripts
69
+ - Expected arguments with default values
70
+
71
+ Use details=true to include full information for each app.
72
+
73
+ If no tenant is specified, uses the currently checked-out tenant.`,
74
+ listAppsSchema,
75
+ async (params) => {
76
+ const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
77
+ if (!resolved) {
78
+ return (0, import_helpers.tenantRequiredResponse)();
79
+ }
80
+ const { organisation, tenant } = resolved;
81
+ const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
82
+ if (!clientResult) {
83
+ return (0, import_helpers.authRequiredResponse)(tenant);
84
+ }
85
+ try {
86
+ const appList = await clientResult.client.listApps();
87
+ if (!params.details) {
88
+ return (0, import_helpers.successResponse)({
89
+ tenant,
90
+ totalApps: appList.length,
91
+ apps: appList.map((a) => ({
92
+ name: a.name,
93
+ id: a.id,
94
+ reference: a.reference
95
+ }))
96
+ });
97
+ }
98
+ const appsWithDetails = [];
99
+ for (const item of appList) {
100
+ const app = await clientResult.client.getApp(item.reference);
101
+ if (app) {
102
+ const mainScript = app.scriptFiles.find((s2) => s2.id === app.mainScriptFileId);
103
+ appsWithDetails.push({
104
+ name: app.name,
105
+ id: app.id,
106
+ description: app.description || "",
107
+ entrypoint: mainScript?.name || null,
108
+ scripts: app.scriptFiles.map((s2) => s2.name),
109
+ arguments: app.expectedArguments.map((a) => ({
110
+ name: a.name,
111
+ defaultValue: a.defaultValue
112
+ }))
113
+ });
114
+ }
115
+ }
116
+ return (0, import_helpers.successResponse)({
117
+ tenant,
118
+ totalApps: appsWithDetails.length,
119
+ apps: appsWithDetails
120
+ });
121
+ } catch (error) {
122
+ return (0, import_helpers.errorResponse)(
123
+ `List apps failed: ${error instanceof Error ? error.message : "Unknown error"}`,
124
+ "NETWORK_ERROR"
125
+ );
126
+ }
127
+ }
128
+ );
129
+ s.tool(
130
+ "farseer_get_app",
131
+ `Get detailed information about a specific Farseer app.
132
+
133
+ Returns:
134
+ - App name and description
135
+ - Entry point script (main script that runs)
136
+ - List of all included scripts
137
+ - Expected arguments with their default values
138
+
139
+ If no tenant is specified, uses the currently checked-out tenant.`,
140
+ getAppSchema,
141
+ async (params) => {
142
+ const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
143
+ if (!resolved) {
144
+ return (0, import_helpers.tenantRequiredResponse)();
145
+ }
146
+ const { organisation, tenant } = resolved;
147
+ const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
148
+ if (!clientResult) {
149
+ return (0, import_helpers.authRequiredResponse)(tenant);
150
+ }
151
+ try {
152
+ const app = await clientResult.client.getAppByName(params.appName);
153
+ if (!app) {
154
+ return (0, import_helpers.errorResponse)(`App "${params.appName}" not found`, "NOT_FOUND");
155
+ }
156
+ const mainScript = app.scriptFiles.find((s2) => s2.id === app.mainScriptFileId);
157
+ return (0, import_helpers.successResponse)({
158
+ tenant,
159
+ app: {
160
+ id: app.id,
161
+ name: app.name,
162
+ description: app.description || "",
163
+ entrypoint: mainScript?.name || null,
164
+ scripts: app.scriptFiles.map((s2) => ({
165
+ id: s2.id,
166
+ name: s2.name,
167
+ isEntrypoint: s2.id === app.mainScriptFileId
168
+ })),
169
+ arguments: app.expectedArguments.map((a) => ({
170
+ name: a.name,
171
+ type: a.type,
172
+ defaultValue: a.defaultValue
173
+ })),
174
+ status: app.status,
175
+ lastHeartbeat: app.lastHeartbeat
176
+ }
177
+ });
178
+ } catch (error) {
179
+ return (0, import_helpers.errorResponse)(
180
+ `Get app failed: ${error instanceof Error ? error.message : "Unknown error"}`,
181
+ "NETWORK_ERROR"
182
+ );
183
+ }
184
+ }
185
+ );
186
+ s.tool(
187
+ "farseer_create_app",
188
+ `Create a new Farseer app.
189
+
190
+ A Farseer App is a named configuration that points to a TypeScript script and defines its arguments.
191
+ The script uses farseer-client to interact with the Farseer API (import data, export reports, etc.).
192
+
193
+ Workflow to create a new app:
194
+ 1. Write the script at farseer-apps/<tenant>/files/Scripts/<name>.ts
195
+ 2. Push the script to remote with farseer_push (scripts must exist on remote first)
196
+ 3. Create the app with this tool (farseer_create_app)
197
+ 4. Configure it with farseer_configure_app (set entrypoint, scripts, arguments)
198
+ 5. Run it with farseer_run_app (CLI injects auth credentials automatically)
199
+
200
+ Scripts should use \`new FarseerClient()\` with no arguments - credentials are injected via environment variables by the CLI at runtime.
201
+
202
+ If no tenant is specified, uses the currently checked-out tenant.`,
203
+ createAppSchema,
204
+ async (params) => {
205
+ const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
206
+ if (!resolved) {
207
+ return (0, import_helpers.tenantRequiredResponse)();
208
+ }
209
+ const { organisation, tenant } = resolved;
210
+ const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
211
+ if (!clientResult) {
212
+ return (0, import_helpers.authRequiredResponse)(tenant);
213
+ }
214
+ try {
215
+ const existing = await clientResult.client.getAppByName(params.appName);
216
+ if (existing) {
217
+ return (0, import_helpers.errorResponse)(`App "${params.appName}" already exists`, "VALIDATION_ERROR");
218
+ }
219
+ const app = await clientResult.client.createApp(params.appName);
220
+ return (0, import_helpers.successResponse)({
221
+ tenant,
222
+ app: {
223
+ id: app.id,
224
+ name: app.name
225
+ },
226
+ message: `App "${params.appName}" created. Use farseer_configure_app to set entrypoint, scripts, and arguments.`
227
+ });
228
+ } catch (error) {
229
+ return (0, import_helpers.errorResponse)(
230
+ `Create app failed: ${error instanceof Error ? error.message : "Unknown error"}`,
231
+ "NETWORK_ERROR"
232
+ );
233
+ }
234
+ }
235
+ );
236
+ s.tool(
237
+ "farseer_configure_app",
238
+ `Configure an existing Farseer app.
239
+
240
+ You can set:
241
+ - entrypoint: Main script to execute (e.g., "index.ts")
242
+ - scripts: List of scripts to include in the app
243
+ - description: App description
244
+ - arguments: List of expected arguments with default values
245
+ - newName: Rename the app
246
+
247
+ Important:
248
+ - Scripts must exist on the remote (push them first)
249
+ - If you set scripts but not entrypoint, the first script becomes entrypoint
250
+ - Arguments are passed to the script via command line
251
+
252
+ If no tenant is specified, uses the currently checked-out tenant.`,
253
+ configureAppSchema,
254
+ async (params) => {
255
+ const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
256
+ if (!resolved) {
257
+ return (0, import_helpers.tenantRequiredResponse)();
258
+ }
259
+ const { organisation, tenant } = resolved;
260
+ const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
261
+ if (!clientResult) {
262
+ return (0, import_helpers.authRequiredResponse)(tenant);
263
+ }
264
+ try {
265
+ const app = await clientResult.client.getAppByName(params.appName);
266
+ if (!app) {
267
+ return (0, import_helpers.errorResponse)(`App "${params.appName}" not found`, "NOT_FOUND");
268
+ }
269
+ const availableScripts = await clientResult.client.getScriptFiles();
270
+ const scriptIdMap = new Map(availableScripts.map((s2) => [s2.name.toLowerCase(), s2.id]));
271
+ const update = {};
272
+ if (params.newName) {
273
+ update.name = params.newName;
274
+ }
275
+ if (params.description !== void 0) {
276
+ update.description = params.description;
277
+ }
278
+ if (params.arguments) {
279
+ update.expectedArguments = params.arguments.map((a) => ({
280
+ name: a.name,
281
+ type: "variable",
282
+ defaultValue: a.defaultValue
283
+ }));
284
+ }
285
+ if (params.scripts && params.scripts.length > 0) {
286
+ const scriptIds = [];
287
+ const notFound = [];
288
+ for (const scriptName of params.scripts) {
289
+ const id = scriptIdMap.get(scriptName.toLowerCase());
290
+ if (id) {
291
+ scriptIds.push(id);
292
+ } else {
293
+ notFound.push(scriptName);
294
+ }
295
+ }
296
+ if (notFound.length > 0) {
297
+ return (0, import_helpers.errorResponse)(
298
+ `Scripts not found on remote: ${notFound.join(", ")}. Push them first.`,
299
+ "VALIDATION_ERROR"
300
+ );
301
+ }
302
+ update.scriptFileIds = scriptIds;
303
+ if (!params.entrypoint && scriptIds.length > 0) {
304
+ update.mainScriptFileId = scriptIds[0];
305
+ }
306
+ }
307
+ if (params.entrypoint) {
308
+ const entrypointId = scriptIdMap.get(params.entrypoint.toLowerCase());
309
+ if (!entrypointId) {
310
+ return (0, import_helpers.errorResponse)(
311
+ `Entrypoint script "${params.entrypoint}" not found on remote. Push it first.`,
312
+ "VALIDATION_ERROR"
313
+ );
314
+ }
315
+ update.mainScriptFileId = entrypointId;
316
+ }
317
+ const reference = app.id.toString();
318
+ await clientResult.client.updateApp(reference, update);
319
+ return (0, import_helpers.successResponse)({
320
+ tenant,
321
+ appName: params.newName || params.appName,
322
+ updated: Object.keys(update),
323
+ message: `App "${params.appName}" configured successfully`
324
+ });
325
+ } catch (error) {
326
+ return (0, import_helpers.errorResponse)(
327
+ `Configure app failed: ${error instanceof Error ? error.message : "Unknown error"}`,
328
+ "NETWORK_ERROR"
329
+ );
330
+ }
331
+ }
332
+ );
333
+ s.tool(
334
+ "farseer_delete_app",
335
+ `Delete an app from a Farseer tenant.
336
+
337
+ WARNING: This is irreversible - the app will be permanently removed from the remote instance.
338
+
339
+ This does NOT delete the script files, only the app configuration.
340
+
341
+ If no tenant is specified, uses the currently checked-out tenant.`,
342
+ deleteAppSchema,
343
+ async (params) => {
344
+ const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
345
+ if (!resolved) {
346
+ return (0, import_helpers.tenantRequiredResponse)();
347
+ }
348
+ const { organisation, tenant } = resolved;
349
+ const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
350
+ if (!clientResult) {
351
+ return (0, import_helpers.authRequiredResponse)(tenant);
352
+ }
353
+ try {
354
+ const app = await clientResult.client.getAppByName(params.appName);
355
+ if (!app) {
356
+ return (0, import_helpers.errorResponse)(`App "${params.appName}" not found`, "NOT_FOUND");
357
+ }
358
+ await clientResult.client.deleteApp(app.id.toString());
359
+ return (0, import_helpers.successResponse)({
360
+ tenant,
361
+ deletedApp: params.appName,
362
+ message: `App "${params.appName}" has been deleted`
363
+ });
364
+ } catch (error) {
365
+ return (0, import_helpers.errorResponse)(
366
+ `Delete app failed: ${error instanceof Error ? error.message : "Unknown error"}`,
367
+ "NETWORK_ERROR"
368
+ );
369
+ }
370
+ }
371
+ );
372
+ }
373
+ // Annotate the CommonJS export names for ESM import in node:
374
+ 0 && (module.exports = {
375
+ registerAppTools
376
+ });
377
+ //# sourceMappingURL=appTools.js.map