farseer-cli 1.0.9 → 1.0.10

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 +344 -316
  2. package/dist/commands/apps.js +83 -103
  3. package/dist/commands/checkout.js +156 -134
  4. package/dist/commands/config.js +126 -124
  5. package/dist/commands/diff.js +194 -169
  6. package/dist/commands/dimensions.js +122 -137
  7. package/dist/commands/files.js +77 -88
  8. package/dist/commands/install.js +77 -74
  9. package/dist/commands/list.js +74 -89
  10. package/dist/commands/login.js +101 -126
  11. package/dist/commands/logout.js +42 -57
  12. package/dist/commands/mcp-server.js +24 -39
  13. package/dist/commands/model.js +176 -184
  14. package/dist/commands/pull.js +276 -248
  15. package/dist/commands/push.js +222 -200
  16. package/dist/commands/run.js +322 -274
  17. package/dist/commands/status.js +170 -147
  18. package/dist/commands/variables.js +192 -168
  19. package/dist/commands/whoami.js +45 -61
  20. package/dist/index.js +115 -117
  21. package/dist/mcp/index.js +17 -33
  22. package/dist/mcp/prompts/workflows.js +146 -191
  23. package/dist/mcp/resources/documentation.js +149 -158
  24. package/dist/mcp/server.js +34 -50
  25. package/dist/mcp/tools/appTools.js +278 -307
  26. package/dist/mcp/tools/authTools.js +123 -130
  27. package/dist/mcp/tools/dataTools.js +271 -275
  28. package/dist/mcp/tools/modelTools.js +233 -265
  29. package/dist/mcp/tools/runTools.js +205 -199
  30. package/dist/mcp/tools/syncTools.js +315 -341
  31. package/dist/mcp/utils/helpers.js +124 -117
  32. package/dist/services/appSyncService.js +438 -379
  33. package/dist/services/configService.js +144 -154
  34. package/dist/services/farseerApi.js +401 -401
  35. package/dist/services/farseerFactory.js +274 -208
  36. package/dist/services/farseerService.js +488 -455
  37. package/dist/services/syncService.js +732 -657
  38. package/dist/utils/constants.js +20 -45
  39. package/dist/utils/helpers.js +366 -333
  40. package/dist/utils/logger.js +43 -74
  41. package/package.json +8 -1
  42. package/dist/commands/app.js.map +0 -7
  43. package/dist/commands/apps.js.map +0 -7
  44. package/dist/commands/checkout.js.map +0 -7
  45. package/dist/commands/config.js.map +0 -7
  46. package/dist/commands/diff.js.map +0 -7
  47. package/dist/commands/dimensions.js.map +0 -7
  48. package/dist/commands/files.js.map +0 -7
  49. package/dist/commands/install.js.map +0 -7
  50. package/dist/commands/list.js.map +0 -7
  51. package/dist/commands/login.js.map +0 -7
  52. package/dist/commands/logout.js.map +0 -7
  53. package/dist/commands/mcp-server.js.map +0 -7
  54. package/dist/commands/model.js.map +0 -7
  55. package/dist/commands/pull.js.map +0 -7
  56. package/dist/commands/push.js.map +0 -7
  57. package/dist/commands/run.js.map +0 -7
  58. package/dist/commands/status.js.map +0 -7
  59. package/dist/commands/variables.js.map +0 -7
  60. package/dist/commands/whoami.js.map +0 -7
  61. package/dist/index.js.map +0 -7
  62. package/dist/mcp/index.js.map +0 -7
  63. package/dist/mcp/prompts/workflows.js.map +0 -7
  64. package/dist/mcp/resources/documentation.js.map +0 -7
  65. package/dist/mcp/server.js.map +0 -7
  66. package/dist/mcp/tools/appTools.js.map +0 -7
  67. package/dist/mcp/tools/authTools.js.map +0 -7
  68. package/dist/mcp/tools/dataTools.js.map +0 -7
  69. package/dist/mcp/tools/modelTools.js.map +0 -7
  70. package/dist/mcp/tools/runTools.js.map +0 -7
  71. package/dist/mcp/tools/syncTools.js.map +0 -7
  72. package/dist/mcp/utils/helpers.js.map +0 -7
  73. package/dist/services/appSyncService.js.map +0 -7
  74. package/dist/services/configService.js.map +0 -7
  75. package/dist/services/farseerApi.js.map +0 -7
  76. package/dist/services/farseerFactory.js.map +0 -7
  77. package/dist/services/farseerService.js.map +0 -7
  78. package/dist/services/syncService.js.map +0 -7
  79. package/dist/utils/constants.js.map +0 -7
  80. package/dist/utils/helpers.js.map +0 -7
  81. package/dist/utils/logger.js.map +0 -7
@@ -1,67 +1,69 @@
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");
1
+ "use strict";
2
+ /**
3
+ * App Management Tools
4
+ *
5
+ * Tools for managing Farseer apps (Remote Jobs).
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.registerAppTools = registerAppTools;
9
+ const zod_1 = require("zod");
10
+ const farseerFactory_1 = require("../../services/farseerFactory");
11
+ const helpers_1 = require("../utils/helpers");
12
+ // Define schemas outside of tool registration to avoid deep type instantiation
26
13
  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")
14
+ organisation: zod_1.z
15
+ .string()
16
+ .optional()
17
+ .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
18
+ tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
19
+ details: zod_1.z.boolean().optional().describe('Include full details for each app'),
30
20
  };
31
21
  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)")
22
+ organisation: zod_1.z
23
+ .string()
24
+ .optional()
25
+ .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
26
+ tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
27
+ appName: zod_1.z.string().describe('Name of the app (can include spaces)'),
35
28
  };
36
29
  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")
30
+ organisation: zod_1.z
31
+ .string()
32
+ .optional()
33
+ .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
34
+ tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
35
+ appName: zod_1.z.string().describe('Name for the new app'),
40
36
  };
41
- const argumentSchema = import_zod.z.object({
42
- name: import_zod.z.string(),
43
- defaultValue: import_zod.z.string()
37
+ const argumentSchema = zod_1.z.object({
38
+ name: zod_1.z.string(),
39
+ defaultValue: zod_1.z.string(),
44
40
  });
45
41
  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")
42
+ organisation: zod_1.z
43
+ .string()
44
+ .optional()
45
+ .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
46
+ tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
47
+ appName: zod_1.z.string().describe('Name of the app to configure'),
48
+ entrypoint: zod_1.z.string().optional().describe('Main script filename (e.g., "index.ts")'),
49
+ scripts: zod_1.z.array(zod_1.z.string()).optional().describe('List of script filenames to include'),
50
+ description: zod_1.z.string().optional().describe('App description'),
51
+ arguments: zod_1.z.array(argumentSchema).optional().describe('App arguments with default values'),
52
+ newName: zod_1.z.string().optional().describe('Rename the app'),
54
53
  };
55
54
  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")
55
+ organisation: zod_1.z
56
+ .string()
57
+ .optional()
58
+ .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
59
+ tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
60
+ appName: zod_1.z.string().describe('Name of the app to delete'),
59
61
  };
60
62
  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.
63
+ // Cast to avoid TS2589 deep type instantiation with MCP SDK + Zod generics
64
+ const s = server;
65
+ // farseer_list_apps - List all apps
66
+ s.tool('farseer_list_apps', `List all apps (Remote Jobs) configured on a Farseer tenant.
65
67
 
66
68
  Apps are executable script configurations that include:
67
69
  - Entry point script
@@ -70,65 +72,61 @@ Apps are executable script configurations that include:
70
72
 
71
73
  Use details=true to include full information for each app.
72
74
 
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
- });
75
+ If no tenant is specified, uses the currently checked-out tenant.`, listAppsSchema, async (params) => {
76
+ const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
77
+ if (!resolved) {
78
+ return (0, helpers_1.tenantRequiredResponse)();
79
+ }
80
+ const { organisation, tenant } = resolved;
81
+ const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
82
+ if (!clientResult) {
83
+ return (0, helpers_1.authRequiredResponse)(tenant);
97
84
  }
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
- }))
85
+ try {
86
+ const appList = await clientResult.client.listApps();
87
+ if (!params.details) {
88
+ return (0, helpers_1.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
+ // Get full details for each app
99
+ const appsWithDetails = [];
100
+ for (const item of appList) {
101
+ const app = await clientResult.client.getApp(item.reference);
102
+ if (app) {
103
+ const appScripts = app.scriptFiles ?? [];
104
+ const mainScript = appScripts.find((s) => s.id === app.mainScriptFileId);
105
+ appsWithDetails.push({
106
+ name: app.name,
107
+ id: app.id,
108
+ description: app.description || '',
109
+ entrypoint: mainScript?.name || null,
110
+ scripts: appScripts.map((s) => s.name),
111
+ arguments: app.expectedArguments.map((a) => ({
112
+ name: a.name,
113
+ defaultValue: a.defaultValue,
114
+ })),
115
+ });
116
+ }
117
+ }
118
+ return (0, helpers_1.successResponse)({
119
+ tenant,
120
+ totalApps: appsWithDetails.length,
121
+ apps: appsWithDetails,
113
122
  });
114
- }
115
123
  }
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.
124
+ catch (error) {
125
+ return (0, helpers_1.errorResponse)(`List apps failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
126
+ }
127
+ });
128
+ // farseer_get_app - Get app details
129
+ s.tool('farseer_get_app', `Get detailed information about a specific Farseer app.
132
130
 
133
131
  Returns:
134
132
  - App name and description
@@ -136,56 +134,51 @@ Returns:
136
134
  - List of all included scripts
137
135
  - Expected arguments with their default values
138
136
 
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");
137
+ If no tenant is specified, uses the currently checked-out tenant.`, getAppSchema, async (params) => {
138
+ const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
139
+ if (!resolved) {
140
+ return (0, helpers_1.tenantRequiredResponse)();
141
+ }
142
+ const { organisation, tenant } = resolved;
143
+ const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
144
+ if (!clientResult) {
145
+ return (0, helpers_1.authRequiredResponse)(tenant);
155
146
  }
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.
147
+ try {
148
+ const app = await clientResult.client.getAppByName(params.appName);
149
+ if (!app) {
150
+ return (0, helpers_1.errorResponse)(`App "${params.appName}" not found`, 'NOT_FOUND');
151
+ }
152
+ const getAppScripts = app.scriptFiles ?? [];
153
+ const mainScript = getAppScripts.find((s) => s.id === app.mainScriptFileId);
154
+ return (0, helpers_1.successResponse)({
155
+ tenant,
156
+ app: {
157
+ id: app.id,
158
+ name: app.name,
159
+ description: app.description || '',
160
+ entrypoint: mainScript?.name || null,
161
+ scripts: getAppScripts.map((s) => ({
162
+ id: s.id,
163
+ name: s.name,
164
+ isEntrypoint: s.id === app.mainScriptFileId,
165
+ })),
166
+ arguments: app.expectedArguments.map((a) => ({
167
+ name: a.name,
168
+ type: a.type,
169
+ defaultValue: a.defaultValue,
170
+ })),
171
+ status: app.status,
172
+ lastHeartbeat: app.lastHeartbeat,
173
+ },
174
+ });
175
+ }
176
+ catch (error) {
177
+ return (0, helpers_1.errorResponse)(`Get app failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
178
+ }
179
+ });
180
+ // farseer_create_app - Create new app
181
+ s.tool('farseer_create_app', `Create a new Farseer app.
189
182
 
190
183
  A Farseer App is a named configuration that points to a TypeScript script and defines its arguments.
191
184
  The script uses farseer-client to interact with the Farseer API (import data, export reports, etc.).
@@ -199,43 +192,38 @@ Workflow to create a new app:
199
192
 
200
193
  Scripts should use \`new FarseerClient()\` with no arguments - credentials are injected via environment variables by the CLI at runtime.
201
194
 
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");
195
+ If no tenant is specified, uses the currently checked-out tenant.`, createAppSchema, async (params) => {
196
+ const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
197
+ if (!resolved) {
198
+ return (0, helpers_1.tenantRequiredResponse)();
199
+ }
200
+ const { organisation, tenant } = resolved;
201
+ const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
202
+ if (!clientResult) {
203
+ return (0, helpers_1.authRequiredResponse)(tenant);
204
+ }
205
+ try {
206
+ // Check if app already exists
207
+ const existing = await clientResult.client.getAppByName(params.appName);
208
+ if (existing) {
209
+ return (0, helpers_1.errorResponse)(`App "${params.appName}" already exists`, 'VALIDATION_ERROR');
210
+ }
211
+ const app = await clientResult.client.createApp(params.appName);
212
+ return (0, helpers_1.successResponse)({
213
+ tenant,
214
+ app: {
215
+ id: app.id,
216
+ name: app.name,
217
+ },
218
+ message: `App "${params.appName}" created. Use farseer_configure_app to set entrypoint, scripts, and arguments.`,
219
+ });
218
220
  }
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.
221
+ catch (error) {
222
+ return (0, helpers_1.errorResponse)(`Create app failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
223
+ }
224
+ });
225
+ // farseer_configure_app - Configure app settings
226
+ s.tool('farseer_configure_app', `Configure an existing Farseer app.
239
227
 
240
228
  You can set:
241
229
  - entrypoint: Main script to execute (e.g., "index.ts")
@@ -249,129 +237,112 @@ Important:
249
237
  - If you set scripts but not entrypoint, the first script becomes entrypoint
250
238
  - Arguments are passed to the script via command line
251
239
 
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;
240
+ If no tenant is specified, uses the currently checked-out tenant.`, configureAppSchema, async (params) => {
241
+ const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
242
+ if (!resolved) {
243
+ return (0, helpers_1.tenantRequiredResponse)();
274
244
  }
275
- if (params.description !== void 0) {
276
- update.description = params.description;
245
+ const { organisation, tenant } = resolved;
246
+ const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
247
+ if (!clientResult) {
248
+ return (0, helpers_1.authRequiredResponse)(tenant);
277
249
  }
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);
250
+ try {
251
+ const app = await clientResult.client.getAppByName(params.appName);
252
+ if (!app) {
253
+ return (0, helpers_1.errorResponse)(`App "${params.appName}" not found`, 'NOT_FOUND');
254
+ }
255
+ // Get available scripts for ID lookup
256
+ const availableScripts = await clientResult.client.getScriptFiles();
257
+ const scriptIdMap = new Map(availableScripts.map((s) => [s.name.toLowerCase(), s.id]));
258
+ // Build update payload
259
+ const update = {};
260
+ if (params.newName) {
261
+ update.name = params.newName;
262
+ }
263
+ if (params.description !== undefined) {
264
+ update.description = params.description;
265
+ }
266
+ if (params.arguments) {
267
+ update.expectedArguments = params.arguments.map((a) => ({
268
+ name: a.name,
269
+ type: 'variable',
270
+ defaultValue: a.defaultValue,
271
+ }));
272
+ }
273
+ if (params.scripts && params.scripts.length > 0) {
274
+ const scriptIds = [];
275
+ const notFound = [];
276
+ for (const scriptName of params.scripts) {
277
+ const id = scriptIdMap.get(scriptName.toLowerCase());
278
+ if (id) {
279
+ scriptIds.push(id);
280
+ }
281
+ else {
282
+ notFound.push(scriptName);
283
+ }
284
+ }
285
+ if (notFound.length > 0) {
286
+ return (0, helpers_1.errorResponse)(`Scripts not found on remote: ${notFound.join(', ')}. Push them first.`, 'VALIDATION_ERROR');
287
+ }
288
+ update.scriptFileIds = scriptIds;
289
+ // Set entrypoint to first script if not explicitly specified
290
+ if (!params.entrypoint && scriptIds.length > 0) {
291
+ update.mainScriptFileId = scriptIds[0];
292
+ }
293
+ }
294
+ if (params.entrypoint) {
295
+ const entrypointId = scriptIdMap.get(params.entrypoint.toLowerCase());
296
+ if (!entrypointId) {
297
+ return (0, helpers_1.errorResponse)(`Entrypoint script "${params.entrypoint}" not found on remote. Push it first.`, 'VALIDATION_ERROR');
298
+ }
299
+ update.mainScriptFileId = entrypointId;
294
300
  }
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
- }
301
+ // Apply update
302
+ const reference = app.id.toString();
303
+ await clientResult.client.updateApp(reference, update);
304
+ return (0, helpers_1.successResponse)({
305
+ tenant,
306
+ appName: params.newName || params.appName,
307
+ updated: Object.keys(update),
308
+ message: `App "${params.appName}" configured successfully`,
309
+ });
306
310
  }
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;
311
+ catch (error) {
312
+ return (0, helpers_1.errorResponse)(`Configure app failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
316
313
  }
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.
314
+ });
315
+ // farseer_delete_app - Delete app
316
+ s.tool('farseer_delete_app', `Delete an app from a Farseer tenant.
336
317
 
337
318
  WARNING: This is irreversible - the app will be permanently removed from the remote instance.
338
319
 
339
320
  This does NOT delete the script files, only the app configuration.
340
321
 
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");
322
+ If no tenant is specified, uses the currently checked-out tenant.`, deleteAppSchema, async (params) => {
323
+ const resolved = (0, helpers_1.resolveOrgAndTenant)(params);
324
+ if (!resolved) {
325
+ return (0, helpers_1.tenantRequiredResponse)();
326
+ }
327
+ const { organisation, tenant } = resolved;
328
+ const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
329
+ if (!clientResult) {
330
+ return (0, helpers_1.authRequiredResponse)(tenant);
357
331
  }
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
- );
332
+ try {
333
+ const app = await clientResult.client.getAppByName(params.appName);
334
+ if (!app) {
335
+ return (0, helpers_1.errorResponse)(`App "${params.appName}" not found`, 'NOT_FOUND');
336
+ }
337
+ await clientResult.client.deleteApp(app.id.toString());
338
+ return (0, helpers_1.successResponse)({
339
+ tenant,
340
+ deletedApp: params.appName,
341
+ message: `App "${params.appName}" has been deleted`,
342
+ });
343
+ }
344
+ catch (error) {
345
+ return (0, helpers_1.errorResponse)(`Delete app failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
346
+ }
347
+ });
372
348
  }
373
- // Annotate the CommonJS export names for ESM import in node:
374
- 0 && (module.exports = {
375
- registerAppTools
376
- });
377
- //# sourceMappingURL=appTools.js.map