farseer-cli 1.0.10 → 1.1.1
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 +422 -399
- 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 +467 -486
- 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,57 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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 syncTools_exports = {};
|
|
20
|
+
__export(syncTools_exports, {
|
|
21
|
+
registerSyncTools: () => registerSyncTools
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(syncTools_exports);
|
|
24
|
+
var import_zod = require("zod");
|
|
25
|
+
var import_diff = require("diff");
|
|
26
|
+
var import_syncService = require("../../services/syncService");
|
|
27
|
+
var import_appSyncService = require("../../services/appSyncService");
|
|
28
|
+
var import_farseerFactory = require("../../services/farseerFactory");
|
|
29
|
+
var import_helpers = require("../utils/helpers");
|
|
16
30
|
const pullSchema = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
force: zod_1.z.boolean().optional().describe('Force pull, overwriting local changes on conflicts'),
|
|
31
|
+
organisation: import_zod.z.string().optional().describe(
|
|
32
|
+
'Farseer organisation (subdomain, e.g. "salvus-2"). If omitted, uses checked-out org or saved mapping.'
|
|
33
|
+
),
|
|
34
|
+
tenant: import_zod.z.string().optional().describe('Tenant ID (e.g. "salvus-prodaja"). Uses checked-out tenant if omitted.'),
|
|
35
|
+
all: import_zod.z.boolean().optional().describe("Download all files, not just scripts (.ts, .js)"),
|
|
36
|
+
force: import_zod.z.boolean().optional().describe("Force pull, overwriting local changes on conflicts")
|
|
24
37
|
};
|
|
25
38
|
const pushSchema = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
|
|
30
|
-
tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
|
|
31
|
-
force: zod_1.z.boolean().optional().describe('Skip remote changes check (may overwrite remote changes)'),
|
|
39
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
40
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
41
|
+
force: import_zod.z.boolean().optional().describe("Skip remote changes check (may overwrite remote changes)")
|
|
32
42
|
};
|
|
33
43
|
const statusSchema = {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),
|
|
38
|
-
tenant: zod_1.z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),
|
|
39
|
-
all: zod_1.z.boolean().optional().describe('Show all files, not just scripts'),
|
|
44
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
45
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
46
|
+
all: import_zod.z.boolean().optional().describe("Show all files, not just scripts")
|
|
40
47
|
};
|
|
41
48
|
const diffSchema = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain)."),
|
|
50
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID"),
|
|
51
|
+
file: import_zod.z.string().optional().describe("Specific file path to diff. If omitted, shows all differences."),
|
|
52
|
+
showRemote: import_zod.z.boolean().optional().describe("Show only the remote content instead of diff")
|
|
46
53
|
};
|
|
47
54
|
const listFilesSchema = {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain)."),
|
|
56
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID"),
|
|
57
|
+
all: import_zod.z.boolean().optional().describe("Show all files, not just scripts")
|
|
51
58
|
};
|
|
52
59
|
function registerSyncTools(server) {
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
server.tool(
|
|
61
|
+
"farseer_pull",
|
|
62
|
+
`Pull (download) files and app configurations from a Farseer instance to the local repository.
|
|
55
63
|
|
|
56
64
|
What gets pulled:
|
|
57
65
|
- TypeScript/JavaScript scripts from Files/ folder (searched recursively)
|
|
@@ -67,65 +75,66 @@ Organisation and tenant:
|
|
|
67
75
|
- Organisation = subdomain (e.g. "salvus-2" for salvus-2.farseer.io)
|
|
68
76
|
- Tenant = workspace ID (e.g. "salvus-prodaja")
|
|
69
77
|
- Often they are the same. Only specify organisation when it differs from tenant.
|
|
70
|
-
- If checked out, both are resolved automatically.`,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
- If checked out, both are resolved automatically.`,
|
|
79
|
+
pullSchema,
|
|
80
|
+
async (params) => {
|
|
81
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
82
|
+
if (!resolved) {
|
|
83
|
+
return (0, import_helpers.tenantRequiredResponse)();
|
|
84
|
+
}
|
|
85
|
+
const { organisation, tenant } = resolved;
|
|
86
|
+
const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
87
|
+
if (!clientResult) {
|
|
88
|
+
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const syncService = new import_syncService.SyncService(tenant, clientResult.client);
|
|
92
|
+
const fileResult = await syncService.pull({ all: params.all, force: params.force });
|
|
93
|
+
let appResult = null;
|
|
94
|
+
if (clientResult.authType === "jwt") {
|
|
95
|
+
const appSyncService = new import_appSyncService.AppSyncService(tenant, clientResult.client);
|
|
96
|
+
appResult = await appSyncService.pull();
|
|
79
97
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
: { note: 'App sync requires browser login (JWT)' },
|
|
106
|
-
message: `Pulled ${fileResult.downloaded.length} files${appResult ? ` and ${appResult.created.length + appResult.updated.length} apps` : ''}`,
|
|
107
|
-
};
|
|
108
|
-
if (fileResult.conflicts.length > 0) {
|
|
109
|
-
response.conflicts = fileResult.conflicts.map((c) => ({
|
|
110
|
-
file: c.filePath,
|
|
111
|
-
type: c.type,
|
|
112
|
-
description: c.description,
|
|
113
|
-
}));
|
|
114
|
-
response.message = `Pulled ${fileResult.downloaded.length} files but ${fileResult.conflicts.length} conflict(s) need resolution`;
|
|
115
|
-
response.hint =
|
|
116
|
-
'Use force=true to overwrite local changes, or resolve conflicts via CLI: farseer pull <tenant>';
|
|
117
|
-
}
|
|
118
|
-
if (fileResult.conflictFilesWritten.length > 0) {
|
|
119
|
-
response.conflictFilesWritten = fileResult.conflictFilesWritten;
|
|
120
|
-
}
|
|
121
|
-
return (0, helpers_1.successResponse)(response);
|
|
98
|
+
const response = {
|
|
99
|
+
tenant,
|
|
100
|
+
organisation,
|
|
101
|
+
files: {
|
|
102
|
+
downloaded: fileResult.downloaded,
|
|
103
|
+
deleted: fileResult.deleted,
|
|
104
|
+
unchanged: fileResult.unchanged.length
|
|
105
|
+
},
|
|
106
|
+
apps: appResult ? {
|
|
107
|
+
created: appResult.created,
|
|
108
|
+
updated: appResult.updated,
|
|
109
|
+
deleted: appResult.deleted,
|
|
110
|
+
unchanged: appResult.unchanged.length
|
|
111
|
+
} : { note: "App sync requires browser login (JWT)" },
|
|
112
|
+
message: `Pulled ${fileResult.downloaded.length} files${appResult ? ` and ${appResult.created.length + appResult.updated.length} apps` : ""}`
|
|
113
|
+
};
|
|
114
|
+
if (fileResult.conflicts.length > 0) {
|
|
115
|
+
response.conflicts = fileResult.conflicts.map((c) => ({
|
|
116
|
+
file: c.filePath,
|
|
117
|
+
type: c.type,
|
|
118
|
+
description: c.description
|
|
119
|
+
}));
|
|
120
|
+
response.message = `Pulled ${fileResult.downloaded.length} files but ${fileResult.conflicts.length} conflict(s) need resolution`;
|
|
121
|
+
response.hint = "Use force=true to overwrite local changes, or resolve conflicts via CLI: farseer pull <tenant>";
|
|
122
122
|
}
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
if (fileResult.conflictFilesWritten.length > 0) {
|
|
124
|
+
response.conflictFilesWritten = fileResult.conflictFilesWritten;
|
|
125
125
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
return (0, import_helpers.successResponse)(response);
|
|
127
|
+
} catch (error) {
|
|
128
|
+
return (0, import_helpers.errorResponse)(
|
|
129
|
+
`Pull failed: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
130
|
+
"NETWORK_ERROR"
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
server.tool(
|
|
136
|
+
"farseer_push",
|
|
137
|
+
`Push (upload) local file and app changes to a Farseer instance.
|
|
129
138
|
|
|
130
139
|
What gets pushed:
|
|
131
140
|
- New/modified scripts from farseer-apps/<tenant>/files/
|
|
@@ -136,62 +145,71 @@ Important:
|
|
|
136
145
|
- Checks for unpulled remote changes first to prevent conflicts
|
|
137
146
|
- Use force=true to skip this check (may overwrite remote changes)
|
|
138
147
|
|
|
139
|
-
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
148
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
149
|
+
pushSchema,
|
|
150
|
+
async (params) => {
|
|
151
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
152
|
+
if (!resolved) {
|
|
153
|
+
return (0, import_helpers.tenantRequiredResponse)();
|
|
154
|
+
}
|
|
155
|
+
const { organisation, tenant } = resolved;
|
|
156
|
+
const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
157
|
+
if (!clientResult) {
|
|
158
|
+
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
const syncService = new import_syncService.SyncService(tenant, clientResult.client);
|
|
162
|
+
if (!params.force) {
|
|
163
|
+
const hasRemoteChanges = await syncService.checkRemoteChanges();
|
|
164
|
+
if (hasRemoteChanges) {
|
|
165
|
+
return (0, import_helpers.errorResponse)(
|
|
166
|
+
"Remote has unpulled changes. Pull first or use force=true to overwrite.",
|
|
167
|
+
"VALIDATION_ERROR"
|
|
168
|
+
);
|
|
169
|
+
}
|
|
143
170
|
}
|
|
144
|
-
const {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const hasRemoteChanges = await syncService.checkRemoteChanges();
|
|
154
|
-
if (hasRemoteChanges) {
|
|
155
|
-
return (0, helpers_1.errorResponse)('Remote has unpulled changes. Pull first or use force=true to overwrite.', 'VALIDATION_ERROR');
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
// Push files
|
|
159
|
-
const fileResult = await syncService.push({ force: params.force });
|
|
160
|
-
// Check for conflicts
|
|
161
|
-
if (fileResult.conflicts.length > 0) {
|
|
162
|
-
return (0, helpers_1.errorResponse)(`Push blocked by ${fileResult.conflicts.length} conflict(s):\n${fileResult.conflicts.map((c) => ` - ${c.filePath}: ${c.description}`).join('\n')}\n\nPull first or use force=true.`, 'VALIDATION_ERROR');
|
|
163
|
-
}
|
|
164
|
-
// Push apps (only with JWT auth)
|
|
165
|
-
let appResult = null;
|
|
166
|
-
if (clientResult.authType === 'jwt') {
|
|
167
|
-
const appSyncService = new appSyncService_1.AppSyncService(tenant, clientResult.client);
|
|
168
|
-
appResult = await appSyncService.push();
|
|
169
|
-
}
|
|
170
|
-
return (0, helpers_1.successResponse)({
|
|
171
|
-
tenant,
|
|
172
|
-
organisation,
|
|
173
|
-
files: {
|
|
174
|
-
uploaded: fileResult.uploaded,
|
|
175
|
-
updated: fileResult.updated,
|
|
176
|
-
deleted: fileResult.deleted,
|
|
177
|
-
unchanged: fileResult.unchanged.length,
|
|
178
|
-
},
|
|
179
|
-
apps: appResult
|
|
180
|
-
? {
|
|
181
|
-
created: appResult.created,
|
|
182
|
-
updated: appResult.updated,
|
|
183
|
-
unchanged: appResult.unchanged.length,
|
|
184
|
-
}
|
|
185
|
-
: { note: 'App sync requires browser login (JWT)' },
|
|
186
|
-
summary: `Pushed ${fileResult.uploaded.length + fileResult.updated.length} files${appResult ? ` and ${appResult.created.length + appResult.updated.length} apps` : ''}`,
|
|
187
|
-
});
|
|
171
|
+
const fileResult = await syncService.push({ force: params.force });
|
|
172
|
+
if (fileResult.conflicts.length > 0) {
|
|
173
|
+
return (0, import_helpers.errorResponse)(
|
|
174
|
+
`Push blocked by ${fileResult.conflicts.length} conflict(s):
|
|
175
|
+
${fileResult.conflicts.map((c) => ` - ${c.filePath}: ${c.description}`).join("\n")}
|
|
176
|
+
|
|
177
|
+
Pull first or use force=true.`,
|
|
178
|
+
"VALIDATION_ERROR"
|
|
179
|
+
);
|
|
188
180
|
}
|
|
189
|
-
|
|
190
|
-
|
|
181
|
+
let appResult = null;
|
|
182
|
+
if (clientResult.authType === "jwt") {
|
|
183
|
+
const appSyncService = new import_appSyncService.AppSyncService(tenant, clientResult.client);
|
|
184
|
+
appResult = await appSyncService.push();
|
|
191
185
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
186
|
+
return (0, import_helpers.successResponse)({
|
|
187
|
+
tenant,
|
|
188
|
+
organisation,
|
|
189
|
+
files: {
|
|
190
|
+
uploaded: fileResult.uploaded,
|
|
191
|
+
updated: fileResult.updated,
|
|
192
|
+
deleted: fileResult.deleted,
|
|
193
|
+
unchanged: fileResult.unchanged.length
|
|
194
|
+
},
|
|
195
|
+
apps: appResult ? {
|
|
196
|
+
created: appResult.created,
|
|
197
|
+
updated: appResult.updated,
|
|
198
|
+
unchanged: appResult.unchanged.length
|
|
199
|
+
} : { note: "App sync requires browser login (JWT)" },
|
|
200
|
+
summary: `Pushed ${fileResult.uploaded.length + fileResult.updated.length} files${appResult ? ` and ${appResult.created.length + appResult.updated.length} apps` : ""}`
|
|
201
|
+
});
|
|
202
|
+
} catch (error) {
|
|
203
|
+
return (0, import_helpers.errorResponse)(
|
|
204
|
+
`Push failed: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
205
|
+
"NETWORK_ERROR"
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
server.tool(
|
|
211
|
+
"farseer_status",
|
|
212
|
+
`Check the synchronization status between local files and the remote Farseer instance.
|
|
195
213
|
|
|
196
214
|
Shows which files are:
|
|
197
215
|
- Modified locally (changed since last sync)
|
|
@@ -202,66 +220,61 @@ Shows which files are:
|
|
|
202
220
|
|
|
203
221
|
Also shows app sync status if using JWT authentication.
|
|
204
222
|
|
|
205
|
-
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const hasChanges = fileStatus.modifiedLocally.length > 0 ||
|
|
225
|
-
fileStatus.modifiedRemotely.length > 0 ||
|
|
226
|
-
fileStatus.onlyLocal.length > 0 ||
|
|
227
|
-
fileStatus.onlyRemote.length > 0 ||
|
|
228
|
-
(fileStatus.conflicts && fileStatus.conflicts.length > 0);
|
|
229
|
-
return (0, helpers_1.successResponse)({
|
|
230
|
-
tenant,
|
|
231
|
-
organisation,
|
|
232
|
-
files: {
|
|
233
|
-
modifiedLocally: fileStatus.modifiedLocally,
|
|
234
|
-
modifiedRemotely: fileStatus.modifiedRemotely,
|
|
235
|
-
onlyLocal: fileStatus.onlyLocal,
|
|
236
|
-
onlyRemote: fileStatus.onlyRemote,
|
|
237
|
-
inSync: fileStatus.inSync.length,
|
|
238
|
-
conflicts: fileStatus.conflicts?.map((c) => ({
|
|
239
|
-
file: c.filePath,
|
|
240
|
-
type: c.type,
|
|
241
|
-
description: c.description,
|
|
242
|
-
})) ?? [],
|
|
243
|
-
},
|
|
244
|
-
apps: appStatus
|
|
245
|
-
? {
|
|
246
|
-
newLocal: appStatus.newLocal,
|
|
247
|
-
newRemote: appStatus.newRemote,
|
|
248
|
-
modified: appStatus.modified,
|
|
249
|
-
synced: appStatus.synced.length,
|
|
250
|
-
}
|
|
251
|
-
: { note: 'App sync requires browser login (JWT)' },
|
|
252
|
-
summary: fileStatus.conflicts?.length
|
|
253
|
-
? `${fileStatus.conflicts.length} conflict(s) detected`
|
|
254
|
-
: hasChanges
|
|
255
|
-
? 'Changes detected'
|
|
256
|
-
: 'Everything is in sync',
|
|
257
|
-
});
|
|
223
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
224
|
+
statusSchema,
|
|
225
|
+
async (params) => {
|
|
226
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
227
|
+
if (!resolved) {
|
|
228
|
+
return (0, import_helpers.tenantRequiredResponse)();
|
|
229
|
+
}
|
|
230
|
+
const { organisation, tenant } = resolved;
|
|
231
|
+
const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
232
|
+
if (!clientResult) {
|
|
233
|
+
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
234
|
+
}
|
|
235
|
+
try {
|
|
236
|
+
const syncService = new import_syncService.SyncService(tenant, clientResult.client);
|
|
237
|
+
const fileStatus = await syncService.getStatus({ all: params.all });
|
|
238
|
+
let appStatus = null;
|
|
239
|
+
if (clientResult.authType === "jwt") {
|
|
240
|
+
const appSyncService = new import_appSyncService.AppSyncService(tenant, clientResult.client);
|
|
241
|
+
appStatus = await appSyncService.getStatus();
|
|
258
242
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
243
|
+
const hasChanges = fileStatus.modifiedLocally.length > 0 || fileStatus.modifiedRemotely.length > 0 || fileStatus.onlyLocal.length > 0 || fileStatus.onlyRemote.length > 0 || fileStatus.conflicts && fileStatus.conflicts.length > 0;
|
|
244
|
+
return (0, import_helpers.successResponse)({
|
|
245
|
+
tenant,
|
|
246
|
+
organisation,
|
|
247
|
+
files: {
|
|
248
|
+
modifiedLocally: fileStatus.modifiedLocally,
|
|
249
|
+
modifiedRemotely: fileStatus.modifiedRemotely,
|
|
250
|
+
onlyLocal: fileStatus.onlyLocal,
|
|
251
|
+
onlyRemote: fileStatus.onlyRemote,
|
|
252
|
+
inSync: fileStatus.inSync.length,
|
|
253
|
+
conflicts: fileStatus.conflicts?.map((c) => ({
|
|
254
|
+
file: c.filePath,
|
|
255
|
+
type: c.type,
|
|
256
|
+
description: c.description
|
|
257
|
+
})) ?? []
|
|
258
|
+
},
|
|
259
|
+
apps: appStatus ? {
|
|
260
|
+
newLocal: appStatus.newLocal,
|
|
261
|
+
newRemote: appStatus.newRemote,
|
|
262
|
+
modified: appStatus.modified,
|
|
263
|
+
synced: appStatus.synced.length
|
|
264
|
+
} : { note: "App sync requires browser login (JWT)" },
|
|
265
|
+
summary: fileStatus.conflicts?.length ? `${fileStatus.conflicts.length} conflict(s) detected` : hasChanges ? "Changes detected" : "Everything is in sync"
|
|
266
|
+
});
|
|
267
|
+
} catch (error) {
|
|
268
|
+
return (0, import_helpers.errorResponse)(
|
|
269
|
+
`Status check failed: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
270
|
+
"NETWORK_ERROR"
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
);
|
|
275
|
+
server.tool(
|
|
276
|
+
"farseer_diff",
|
|
277
|
+
`Show the differences between local and remote versions of files.
|
|
265
278
|
|
|
266
279
|
Can show:
|
|
267
280
|
- Unified diff format (default)
|
|
@@ -269,115 +282,123 @@ Can show:
|
|
|
269
282
|
|
|
270
283
|
Useful for reviewing changes before pull or push.
|
|
271
284
|
|
|
272
|
-
If no file is specified, shows diffs for all changed files.`,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
note: changedFiles.length > 10
|
|
326
|
-
? `Showing first 10 of ${changedFiles.length} changed files`
|
|
327
|
-
: undefined,
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
catch (error) {
|
|
332
|
-
return (0, helpers_1.errorResponse)(`Diff failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'NETWORK_ERROR');
|
|
285
|
+
If no file is specified, shows diffs for all changed files.`,
|
|
286
|
+
diffSchema,
|
|
287
|
+
async (params) => {
|
|
288
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
289
|
+
if (!resolved) {
|
|
290
|
+
return (0, import_helpers.tenantRequiredResponse)();
|
|
291
|
+
}
|
|
292
|
+
const { organisation, tenant } = resolved;
|
|
293
|
+
const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
294
|
+
if (!clientResult) {
|
|
295
|
+
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
296
|
+
}
|
|
297
|
+
try {
|
|
298
|
+
const syncService = new import_syncService.SyncService(tenant, clientResult.client);
|
|
299
|
+
if (params.file) {
|
|
300
|
+
const { localContent, remoteContent } = await syncService.getFileDiff(params.file);
|
|
301
|
+
if (params.showRemote) {
|
|
302
|
+
return (0, import_helpers.successResponse)({
|
|
303
|
+
file: params.file,
|
|
304
|
+
remoteContent: remoteContent || "(file does not exist on remote)"
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
const diff = (0, import_diff.createPatch)(params.file, remoteContent || "", localContent || "", "remote", "local");
|
|
308
|
+
return (0, import_helpers.successResponse)({
|
|
309
|
+
file: params.file,
|
|
310
|
+
localExists: localContent !== null,
|
|
311
|
+
remoteExists: remoteContent !== null,
|
|
312
|
+
diff
|
|
313
|
+
});
|
|
314
|
+
} else {
|
|
315
|
+
const status = await syncService.getStatus();
|
|
316
|
+
const changedFiles = [
|
|
317
|
+
...status.modifiedLocally,
|
|
318
|
+
...status.modifiedRemotely,
|
|
319
|
+
...status.onlyLocal,
|
|
320
|
+
...status.onlyRemote
|
|
321
|
+
];
|
|
322
|
+
const diffs = [];
|
|
323
|
+
for (const f of changedFiles.slice(0, 10)) {
|
|
324
|
+
const { localContent, remoteContent } = await syncService.getFileDiff(f);
|
|
325
|
+
const diff = (0, import_diff.createPatch)(f, remoteContent || "", localContent || "", "remote", "local");
|
|
326
|
+
diffs.push({
|
|
327
|
+
file: f,
|
|
328
|
+
localExists: localContent !== null,
|
|
329
|
+
remoteExists: remoteContent !== null,
|
|
330
|
+
diff
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
return (0, import_helpers.successResponse)({
|
|
334
|
+
totalChangedFiles: changedFiles.length,
|
|
335
|
+
diffs,
|
|
336
|
+
note: changedFiles.length > 10 ? `Showing first 10 of ${changedFiles.length} changed files` : void 0
|
|
337
|
+
});
|
|
333
338
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
339
|
+
} catch (error) {
|
|
340
|
+
return (0, import_helpers.errorResponse)(
|
|
341
|
+
`Diff failed: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
342
|
+
"NETWORK_ERROR"
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
);
|
|
347
|
+
server.tool(
|
|
348
|
+
"farseer_list_files",
|
|
349
|
+
`List all files stored on the remote Farseer instance in the Files/ folder.
|
|
337
350
|
|
|
338
351
|
By default shows only script files (.ts, .js, .mjs, .cjs).
|
|
339
352
|
Use all=true to show all files including images, data files, etc.
|
|
340
353
|
|
|
341
|
-
Returns file paths relative to the Files/ folder.`,
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
// Group by directory
|
|
359
|
-
const byDirectory = {};
|
|
360
|
-
for (const file of files) {
|
|
361
|
-
const dir = file.path.includes('/') ? file.path.split('/').slice(0, -1).join('/') : '.';
|
|
362
|
-
if (!byDirectory[dir]) {
|
|
363
|
-
byDirectory[dir] = [];
|
|
364
|
-
}
|
|
365
|
-
byDirectory[dir].push(file.name);
|
|
366
|
-
}
|
|
367
|
-
return (0, helpers_1.successResponse)({
|
|
368
|
-
tenant,
|
|
369
|
-
organisation,
|
|
370
|
-
totalFiles: files.length,
|
|
371
|
-
files: files.map((f) => ({
|
|
372
|
-
name: f.name,
|
|
373
|
-
path: f.path,
|
|
374
|
-
reference: f.reference,
|
|
375
|
-
})),
|
|
376
|
-
byDirectory,
|
|
377
|
-
});
|
|
354
|
+
Returns file paths relative to the Files/ folder.`,
|
|
355
|
+
listFilesSchema,
|
|
356
|
+
async (params) => {
|
|
357
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
358
|
+
if (!resolved) {
|
|
359
|
+
return (0, import_helpers.tenantRequiredResponse)();
|
|
360
|
+
}
|
|
361
|
+
const { organisation, tenant } = resolved;
|
|
362
|
+
const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
363
|
+
if (!clientResult) {
|
|
364
|
+
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
365
|
+
}
|
|
366
|
+
try {
|
|
367
|
+
let files = await clientResult.client.listFiles();
|
|
368
|
+
if (!params.all) {
|
|
369
|
+
const scriptExtensions = [".ts", ".js", ".mjs", ".cjs"];
|
|
370
|
+
files = files.filter((f) => scriptExtensions.some((ext) => f.name.toLowerCase().endsWith(ext)));
|
|
378
371
|
}
|
|
379
|
-
|
|
380
|
-
|
|
372
|
+
const byDirectory = {};
|
|
373
|
+
for (const file of files) {
|
|
374
|
+
const dir = file.path.includes("/") ? file.path.split("/").slice(0, -1).join("/") : ".";
|
|
375
|
+
if (!byDirectory[dir]) {
|
|
376
|
+
byDirectory[dir] = [];
|
|
377
|
+
}
|
|
378
|
+
byDirectory[dir].push(file.name);
|
|
381
379
|
}
|
|
382
|
-
|
|
380
|
+
return (0, import_helpers.successResponse)({
|
|
381
|
+
tenant,
|
|
382
|
+
organisation,
|
|
383
|
+
totalFiles: files.length,
|
|
384
|
+
files: files.map((f) => ({
|
|
385
|
+
name: f.name,
|
|
386
|
+
path: f.path,
|
|
387
|
+
reference: f.reference
|
|
388
|
+
})),
|
|
389
|
+
byDirectory
|
|
390
|
+
});
|
|
391
|
+
} catch (error) {
|
|
392
|
+
return (0, import_helpers.errorResponse)(
|
|
393
|
+
`List files failed: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
394
|
+
"NETWORK_ERROR"
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
);
|
|
383
399
|
}
|
|
400
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
401
|
+
0 && (module.exports = {
|
|
402
|
+
registerSyncTools
|
|
403
|
+
});
|
|
404
|
+
//# sourceMappingURL=syncTools.js.map
|