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