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.
- package/dist/commands/app.js +344 -316
- package/dist/commands/apps.js +83 -103
- package/dist/commands/checkout.js +156 -134
- package/dist/commands/config.js +126 -124
- package/dist/commands/diff.js +194 -169
- package/dist/commands/dimensions.js +122 -137
- package/dist/commands/files.js +77 -88
- package/dist/commands/install.js +77 -74
- package/dist/commands/list.js +74 -89
- package/dist/commands/login.js +101 -126
- package/dist/commands/logout.js +42 -57
- package/dist/commands/mcp-server.js +24 -39
- package/dist/commands/model.js +176 -184
- package/dist/commands/pull.js +276 -248
- package/dist/commands/push.js +222 -200
- package/dist/commands/run.js +322 -274
- package/dist/commands/status.js +170 -147
- package/dist/commands/variables.js +192 -168
- package/dist/commands/whoami.js +45 -61
- package/dist/index.js +115 -117
- package/dist/mcp/index.js +17 -33
- package/dist/mcp/prompts/workflows.js +146 -191
- package/dist/mcp/resources/documentation.js +149 -158
- package/dist/mcp/server.js +34 -50
- package/dist/mcp/tools/appTools.js +278 -307
- package/dist/mcp/tools/authTools.js +123 -130
- package/dist/mcp/tools/dataTools.js +271 -275
- package/dist/mcp/tools/modelTools.js +233 -265
- package/dist/mcp/tools/runTools.js +205 -199
- package/dist/mcp/tools/syncTools.js +315 -341
- package/dist/mcp/utils/helpers.js +124 -117
- package/dist/services/appSyncService.js +438 -379
- package/dist/services/configService.js +144 -154
- package/dist/services/farseerApi.js +401 -401
- package/dist/services/farseerFactory.js +274 -208
- package/dist/services/farseerService.js +488 -455
- package/dist/services/syncService.js +732 -657
- package/dist/utils/constants.js +20 -45
- package/dist/utils/helpers.js +366 -333
- package/dist/utils/logger.js +43 -74
- package/package.json +8 -1
- package/dist/commands/app.js.map +0 -7
- package/dist/commands/apps.js.map +0 -7
- package/dist/commands/checkout.js.map +0 -7
- package/dist/commands/config.js.map +0 -7
- package/dist/commands/diff.js.map +0 -7
- package/dist/commands/dimensions.js.map +0 -7
- package/dist/commands/files.js.map +0 -7
- package/dist/commands/install.js.map +0 -7
- package/dist/commands/list.js.map +0 -7
- package/dist/commands/login.js.map +0 -7
- package/dist/commands/logout.js.map +0 -7
- package/dist/commands/mcp-server.js.map +0 -7
- package/dist/commands/model.js.map +0 -7
- package/dist/commands/pull.js.map +0 -7
- package/dist/commands/push.js.map +0 -7
- package/dist/commands/run.js.map +0 -7
- package/dist/commands/status.js.map +0 -7
- package/dist/commands/variables.js.map +0 -7
- package/dist/commands/whoami.js.map +0 -7
- package/dist/index.js.map +0 -7
- package/dist/mcp/index.js.map +0 -7
- package/dist/mcp/prompts/workflows.js.map +0 -7
- package/dist/mcp/resources/documentation.js.map +0 -7
- package/dist/mcp/server.js.map +0 -7
- package/dist/mcp/tools/appTools.js.map +0 -7
- package/dist/mcp/tools/authTools.js.map +0 -7
- package/dist/mcp/tools/dataTools.js.map +0 -7
- package/dist/mcp/tools/modelTools.js.map +0 -7
- package/dist/mcp/tools/runTools.js.map +0 -7
- package/dist/mcp/tools/syncTools.js.map +0 -7
- package/dist/mcp/utils/helpers.js.map +0 -7
- package/dist/services/appSyncService.js.map +0 -7
- package/dist/services/configService.js.map +0 -7
- package/dist/services/farseerApi.js.map +0 -7
- package/dist/services/farseerFactory.js.map +0 -7
- package/dist/services/farseerService.js.map +0 -7
- package/dist/services/syncService.js.map +0 -7
- package/dist/utils/constants.js.map +0 -7
- package/dist/utils/helpers.js.map +0 -7
- package/dist/utils/logger.js.map +0 -7
|
@@ -1,67 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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 =
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
-
|
|
276
|
-
|
|
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
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
308
|
-
|
|
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
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
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
|