farseer-cli 1.10.2 → 1.11.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 +7 -0
- package/dist/commands/app.js +15 -12
- package/dist/commands/app.js.map +2 -2
- package/dist/commands/apps.js +3 -3
- package/dist/commands/apps.js.map +2 -2
- package/dist/commands/cells.js +3 -3
- package/dist/commands/cells.js.map +2 -2
- package/dist/commands/config.js +23 -15
- package/dist/commands/config.js.map +2 -2
- package/dist/commands/dashboards.js +3 -3
- package/dist/commands/dashboards.js.map +2 -2
- package/dist/commands/dimensions.js +3 -3
- package/dist/commands/dimensions.js.map +2 -2
- package/dist/commands/files.js +5 -4
- package/dist/commands/files.js.map +2 -2
- package/dist/commands/formula.js +3 -3
- package/dist/commands/formula.js.map +2 -2
- package/dist/commands/list.js +5 -4
- package/dist/commands/list.js.map +2 -2
- package/dist/commands/login.js +6 -5
- package/dist/commands/login.js.map +2 -2
- package/dist/commands/model.js +5 -4
- package/dist/commands/model.js.map +2 -2
- package/dist/commands/push.js +5 -7
- package/dist/commands/push.js.map +2 -2
- package/dist/commands/run.js +3 -3
- package/dist/commands/run.js.map +2 -2
- package/dist/commands/sheets.js +3 -3
- package/dist/commands/sheets.js.map +2 -2
- package/dist/commands/variables.js +5 -4
- package/dist/commands/variables.js.map +2 -2
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +2 -2
- package/dist/mcp/tools/appTools.js +30 -60
- package/dist/mcp/tools/appTools.js.map +2 -2
- package/dist/mcp/tools/cellTools.js +4 -6
- package/dist/mcp/tools/cellTools.js.map +2 -2
- package/dist/mcp/tools/dashboardTools.js +34 -56
- package/dist/mcp/tools/dashboardTools.js.map +2 -2
- package/dist/mcp/tools/dataTools.js +17 -38
- package/dist/mcp/tools/dataTools.js.map +2 -2
- package/dist/mcp/tools/folderTools.js +7 -11
- package/dist/mcp/tools/folderTools.js.map +2 -2
- package/dist/mcp/tools/modelTools.js +104 -159
- package/dist/mcp/tools/modelTools.js.map +2 -2
- package/dist/mcp/tools/runTools.js +5 -11
- package/dist/mcp/tools/runTools.js.map +2 -2
- package/dist/mcp/tools/sheetTools.js +31 -51
- package/dist/mcp/tools/sheetTools.js.map +2 -2
- package/dist/mcp/tools/syncTools.js +27 -57
- package/dist/mcp/tools/syncTools.js.map +2 -2
- package/dist/mcp/utils/session.js +2 -2
- package/dist/mcp/utils/session.js.map +2 -2
- package/dist/services/appSyncService.js.map +1 -1
- package/dist/services/apps.js +149 -0
- package/dist/services/apps.js.map +7 -0
- package/dist/services/authErrors.js +77 -0
- package/dist/services/authErrors.js.map +7 -0
- package/dist/services/configService.js +7 -4
- package/dist/services/configService.js.map +2 -2
- package/dist/services/credentials.js +87 -0
- package/dist/services/credentials.js.map +7 -0
- package/dist/services/farseerService.js +247 -112
- package/dist/services/farseerService.js.map +2 -2
- package/dist/services/httpError.js +35 -0
- package/dist/services/httpError.js.map +7 -0
- package/dist/services/modelExport.js +63 -0
- package/dist/services/modelExport.js.map +7 -0
- package/dist/services/organisation.js +88 -0
- package/dist/services/organisation.js.map +7 -0
- package/dist/services/preflight.js +10 -13
- package/dist/services/preflight.js.map +2 -2
- package/dist/services/syncService.js +2 -2
- package/dist/services/syncService.js.map +2 -2
- package/dist/utils/constants.js +2 -5
- package/dist/utils/constants.js.map +2 -2
- package/dist/utils/fileLogger.js +24 -1
- package/dist/utils/fileLogger.js.map +2 -2
- package/dist/utils/folderMatch.js +49 -0
- package/dist/utils/folderMatch.js.map +7 -0
- package/dist/utils/helpers.js +26 -0
- package/dist/utils/helpers.js.map +2 -2
- package/dist/utils/syncScope.js +44 -0
- package/dist/utils/syncScope.js.map +7 -0
- package/docs/api-reference.md +13 -1
- package/package.json +1 -1
- package/dist/services/farseerApi.js +0 -716
- package/dist/services/farseerApi.js.map +0 -7
- package/dist/services/farseerFactory.js +0 -288
- package/dist/services/farseerFactory.js.map +0 -7
|
@@ -35,9 +35,10 @@ var import_zod = require("zod");
|
|
|
35
35
|
var fs = __toESM(require("fs"));
|
|
36
36
|
var path = __toESM(require("path"));
|
|
37
37
|
var os = __toESM(require("os"));
|
|
38
|
-
var
|
|
38
|
+
var import_session = require("../utils/session");
|
|
39
39
|
var import_helpers = require("../utils/helpers");
|
|
40
40
|
var import_errorFormatter = require("../../utils/errorFormatter");
|
|
41
|
+
var import_folderMatch = require("../../utils/folderMatch");
|
|
41
42
|
var farseer = __toESM(require("farseer-client"));
|
|
42
43
|
var import_farseer_client = require("farseer-client");
|
|
43
44
|
const ROLLUP_TYPE_MAP = {
|
|
@@ -125,6 +126,34 @@ const getTableSchema = {
|
|
|
125
126
|
const getVariableSchema = {
|
|
126
127
|
variableName: import_zod.z.string().describe("Name of the variable")
|
|
127
128
|
};
|
|
129
|
+
async function folderFor(nativeClient, folderPath) {
|
|
130
|
+
try {
|
|
131
|
+
let currentFolderId = null;
|
|
132
|
+
for (const segment of folderPath) {
|
|
133
|
+
const parentItems = await nativeClient.folders.listItemsBatch([{ id: currentFolderId }]);
|
|
134
|
+
const folders = (parentItems[0]?.items ?? []).filter(
|
|
135
|
+
(i) => i.type === farseer.FolderItemType.Folder
|
|
136
|
+
);
|
|
137
|
+
const existing = (0, import_folderMatch.matchFolderSegment)(folders, segment);
|
|
138
|
+
if (existing) {
|
|
139
|
+
currentFolderId = existing.id;
|
|
140
|
+
} else {
|
|
141
|
+
const newFolder = await nativeClient.folders.create({
|
|
142
|
+
parentId: currentFolderId,
|
|
143
|
+
name: segment,
|
|
144
|
+
allowedTypes: null
|
|
145
|
+
});
|
|
146
|
+
currentFolderId = newFolder.id;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return { folderId: currentFolderId };
|
|
150
|
+
} catch (error) {
|
|
151
|
+
if (error instanceof import_folderMatch.AmbiguousFolderError) {
|
|
152
|
+
return { error: (0, import_helpers.errorResponse)(error.message, "VALIDATION_ERROR") };
|
|
153
|
+
}
|
|
154
|
+
return { folderId: null };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
128
157
|
function registerModelTools(server) {
|
|
129
158
|
server.tool(
|
|
130
159
|
"farseer_export_model",
|
|
@@ -141,18 +170,12 @@ and only a summary is returned. Use the Read tool to inspect the file if needed.
|
|
|
141
170
|
For a quick overview without the full export, use farseer_list_tables or farseer_list_variables.`,
|
|
142
171
|
exportModelSchema,
|
|
143
172
|
async (params) => {
|
|
144
|
-
const
|
|
145
|
-
if (!
|
|
146
|
-
|
|
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
|
-
}
|
|
173
|
+
const gate = await (0, import_session.requireSession)();
|
|
174
|
+
if (!gate.ok) return gate.response;
|
|
175
|
+
const { tenant, client } = gate.session;
|
|
153
176
|
try {
|
|
154
177
|
const types = params.includeMembers ? ["DTAB", "DMEM", "VAR"] : ["DTAB", "VAR"];
|
|
155
|
-
const model = await
|
|
178
|
+
const model = await client.exportModel({
|
|
156
179
|
types
|
|
157
180
|
});
|
|
158
181
|
const tables = model.tables.map((t) => ({
|
|
@@ -228,17 +251,11 @@ Dimension tables define the structure of data:
|
|
|
228
251
|
Returns table names, member counts, and foreign key relationships.`,
|
|
229
252
|
listTablesSchema,
|
|
230
253
|
async () => {
|
|
231
|
-
const
|
|
232
|
-
if (!
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
const { organisation, tenant } = resolved;
|
|
236
|
-
const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
237
|
-
if (!clientResult) {
|
|
238
|
-
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
239
|
-
}
|
|
254
|
+
const gate = await (0, import_session.requireSession)();
|
|
255
|
+
if (!gate.ok) return gate.response;
|
|
256
|
+
const { tenant, client } = gate.session;
|
|
240
257
|
try {
|
|
241
|
-
const model = await
|
|
258
|
+
const model = await client.exportModel({ types: ["DTAB"] });
|
|
242
259
|
const tables = model.tables.map((t) => ({
|
|
243
260
|
name: t.name,
|
|
244
261
|
foreignKeys: t.columns.filter((c) => c.type === "FOREIGN_KEY").map((c) => c.foreignKeyTableName)
|
|
@@ -266,17 +283,11 @@ Each variable has:
|
|
|
266
283
|
- Roll-up type (how values aggregate up hierarchies)`,
|
|
267
284
|
listVariablesSchema,
|
|
268
285
|
async () => {
|
|
269
|
-
const
|
|
270
|
-
if (!
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
const { organisation, tenant } = resolved;
|
|
274
|
-
const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
275
|
-
if (!clientResult) {
|
|
276
|
-
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
277
|
-
}
|
|
286
|
+
const gate = await (0, import_session.requireSession)();
|
|
287
|
+
if (!gate.ok) return gate.response;
|
|
288
|
+
const { tenant, client, native: nativeClient } = gate.session;
|
|
278
289
|
try {
|
|
279
|
-
const model = await
|
|
290
|
+
const model = await client.exportModel({ types: ["VAR"] });
|
|
280
291
|
const variables = model.variables.map((v) => ({
|
|
281
292
|
name: v.name,
|
|
282
293
|
entityGid: v.gid ?? null,
|
|
@@ -286,20 +297,17 @@ Each variable has:
|
|
|
286
297
|
readonly: v.readonly
|
|
287
298
|
}));
|
|
288
299
|
if (variables.some((v) => v.entityGid === null)) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
v.entityGid = tag.id;
|
|
298
|
-
} catch {
|
|
299
|
-
}
|
|
300
|
+
try {
|
|
301
|
+
await nativeClient.initTagMap();
|
|
302
|
+
for (const v of variables) {
|
|
303
|
+
if (v.entityGid !== null) continue;
|
|
304
|
+
try {
|
|
305
|
+
const tag = await nativeClient.getVariable(v.name);
|
|
306
|
+
v.entityGid = tag.id;
|
|
307
|
+
} catch {
|
|
300
308
|
}
|
|
301
|
-
} catch {
|
|
302
309
|
}
|
|
310
|
+
} catch {
|
|
303
311
|
}
|
|
304
312
|
}
|
|
305
313
|
variables.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -326,17 +334,11 @@ Returns:
|
|
|
326
334
|
This helps understand the structure needed for import scripts.`,
|
|
327
335
|
getTableSchema,
|
|
328
336
|
async (params) => {
|
|
329
|
-
const
|
|
330
|
-
if (!
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
const { organisation, tenant } = resolved;
|
|
334
|
-
const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
335
|
-
if (!clientResult) {
|
|
336
|
-
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
337
|
-
}
|
|
337
|
+
const gate = await (0, import_session.requireSession)();
|
|
338
|
+
if (!gate.ok) return gate.response;
|
|
339
|
+
const { tenant, client } = gate.session;
|
|
338
340
|
try {
|
|
339
|
-
const table = await
|
|
341
|
+
const table = await client.loadDimensionTableWithMembers(params.tableName);
|
|
340
342
|
if (!table) {
|
|
341
343
|
return (0, import_helpers.errorResponse)(`Table "${params.tableName}" not found`, "NOT_FOUND");
|
|
342
344
|
}
|
|
@@ -379,17 +381,11 @@ Returns:
|
|
|
379
381
|
This is essential for understanding what dimensions and values are needed for imports.`,
|
|
380
382
|
getVariableSchema,
|
|
381
383
|
async (params) => {
|
|
382
|
-
const
|
|
383
|
-
if (!
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
const { organisation, tenant } = resolved;
|
|
387
|
-
const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
388
|
-
if (!clientResult) {
|
|
389
|
-
return (0, import_helpers.authRequiredResponse)(tenant);
|
|
390
|
-
}
|
|
384
|
+
const gate = await (0, import_session.requireSession)();
|
|
385
|
+
if (!gate.ok) return gate.response;
|
|
386
|
+
const { tenant, client, native: nativeClient } = gate.session;
|
|
391
387
|
try {
|
|
392
|
-
const model = await
|
|
388
|
+
const model = await client.exportModel({ types: ["VAR"] });
|
|
393
389
|
const variable = model.variables.find(
|
|
394
390
|
(v) => v.name.toLowerCase() === params.variableName.toLowerCase()
|
|
395
391
|
);
|
|
@@ -398,14 +394,11 @@ This is essential for understanding what dimensions and values are needed for im
|
|
|
398
394
|
}
|
|
399
395
|
let entityGid = variable.gid ?? null;
|
|
400
396
|
if (entityGid === null) {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
entityGid = tag.id;
|
|
407
|
-
} catch {
|
|
408
|
-
}
|
|
397
|
+
try {
|
|
398
|
+
await nativeClient.initTagMap();
|
|
399
|
+
const tag = await nativeClient.getVariable(variable.name);
|
|
400
|
+
entityGid = tag.id;
|
|
401
|
+
} catch {
|
|
409
402
|
}
|
|
410
403
|
}
|
|
411
404
|
return (0, import_helpers.successResponse)({
|
|
@@ -444,11 +437,9 @@ Returns the computed value along with cell metadata (readonly, calculated, froze
|
|
|
444
437
|
evaluateFormulaSchema,
|
|
445
438
|
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
446
439
|
async (params) => {
|
|
447
|
-
const
|
|
448
|
-
if (!
|
|
449
|
-
const {
|
|
450
|
-
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
451
|
-
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
440
|
+
const gate = await (0, import_session.requireSession)();
|
|
441
|
+
if (!gate.ok) return gate.response;
|
|
442
|
+
const { tenant, native: nativeClient } = gate.session;
|
|
452
443
|
try {
|
|
453
444
|
let formula = params.formula;
|
|
454
445
|
const isSimpleIdentifier = !formula.startsWith('"') && !/[+\-*/()>,<!=]/.test(formula);
|
|
@@ -488,11 +479,9 @@ For large tables (500+ members), automatically exports to a CSV file and returns
|
|
|
488
479
|
instead of inline data, to avoid overwhelming the context window.`,
|
|
489
480
|
listDimensionMembersSchema,
|
|
490
481
|
async (params) => {
|
|
491
|
-
const
|
|
492
|
-
if (!
|
|
493
|
-
const {
|
|
494
|
-
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
495
|
-
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
482
|
+
const gate = await (0, import_session.requireSession)();
|
|
483
|
+
if (!gate.ok) return gate.response;
|
|
484
|
+
const { tenant, native: nativeClient } = gate.session;
|
|
496
485
|
try {
|
|
497
486
|
await nativeClient.initTagMap();
|
|
498
487
|
const members = await nativeClient.getDimensionMembersForTable(params.tableName);
|
|
@@ -557,11 +546,9 @@ Actions:
|
|
|
557
546
|
WARNING: Delete is destructive and may affect data. Use with caution.`,
|
|
558
547
|
manageDimensionMembersSchema,
|
|
559
548
|
async (params) => {
|
|
560
|
-
const
|
|
561
|
-
if (!
|
|
562
|
-
const {
|
|
563
|
-
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
564
|
-
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
549
|
+
const gate = await (0, import_session.requireSession)();
|
|
550
|
+
if (!gate.ok) return gate.response;
|
|
551
|
+
const { tenant, native: nativeClient } = gate.session;
|
|
565
552
|
try {
|
|
566
553
|
await nativeClient.initTagMap();
|
|
567
554
|
if (params.action === "create") {
|
|
@@ -635,11 +622,9 @@ Creates an empty table that you can then add members to with farseer_manage_dime
|
|
|
635
622
|
},
|
|
636
623
|
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
637
624
|
async (params) => {
|
|
638
|
-
const
|
|
639
|
-
if (!
|
|
640
|
-
const {
|
|
641
|
-
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
642
|
-
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
625
|
+
const gate = await (0, import_session.requireSession)();
|
|
626
|
+
if (!gate.ok) return gate.response;
|
|
627
|
+
const { tenant, native: nativeClient } = gate.session;
|
|
643
628
|
try {
|
|
644
629
|
await nativeClient.initTagMap();
|
|
645
630
|
const createEntity = {
|
|
@@ -647,30 +632,14 @@ Creates an empty table that you can then add members to with farseer_manage_dime
|
|
|
647
632
|
meta: { name: params.name, description: null }
|
|
648
633
|
};
|
|
649
634
|
if (params.folderPath && params.folderPath.length > 0) {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
currentFolderId = existing.id;
|
|
659
|
-
} else {
|
|
660
|
-
const newFolder = await nativeClient.folders.create({
|
|
661
|
-
parentId: currentFolderId,
|
|
662
|
-
name: segment,
|
|
663
|
-
allowedTypes: null
|
|
664
|
-
});
|
|
665
|
-
currentFolderId = newFolder.id;
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
if (currentFolderId) {
|
|
669
|
-
createEntity.relations = {
|
|
670
|
-
folder: { key: { id: currentFolderId, type: import_farseer_client.EntityType.Folder }, order: 0 }
|
|
671
|
-
};
|
|
672
|
-
}
|
|
673
|
-
} catch {
|
|
635
|
+
const placed = await folderFor(nativeClient, params.folderPath);
|
|
636
|
+
if ("error" in placed) {
|
|
637
|
+
return placed.error;
|
|
638
|
+
}
|
|
639
|
+
if (placed.folderId) {
|
|
640
|
+
createEntity.relations = {
|
|
641
|
+
folder: { key: { id: placed.folderId, type: import_farseer_client.EntityType.Folder }, order: 0 }
|
|
642
|
+
};
|
|
674
643
|
}
|
|
675
644
|
}
|
|
676
645
|
const result = await nativeClient.entities.mutate({ created: [createEntity] });
|
|
@@ -707,11 +676,9 @@ Example:
|
|
|
707
676
|
createVariableSchema,
|
|
708
677
|
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
709
678
|
async (params) => {
|
|
710
|
-
const
|
|
711
|
-
if (!
|
|
712
|
-
const {
|
|
713
|
-
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
714
|
-
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
679
|
+
const gate = await (0, import_session.requireSession)();
|
|
680
|
+
if (!gate.ok) return gate.response;
|
|
681
|
+
const { tenant, native: nativeClient } = gate.session;
|
|
715
682
|
try {
|
|
716
683
|
await nativeClient.initTagMap();
|
|
717
684
|
const tableGids = [];
|
|
@@ -744,30 +711,14 @@ Example:
|
|
|
744
711
|
createEntity.numberFormat = params.numberFormat;
|
|
745
712
|
}
|
|
746
713
|
if (params.folderPath && params.folderPath.length > 0) {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
currentFolderId = existing.id;
|
|
756
|
-
} else {
|
|
757
|
-
const newFolder = await nativeClient.folders.create({
|
|
758
|
-
parentId: currentFolderId,
|
|
759
|
-
name: segment,
|
|
760
|
-
allowedTypes: null
|
|
761
|
-
});
|
|
762
|
-
currentFolderId = newFolder.id;
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
if (currentFolderId) {
|
|
766
|
-
createEntity.relations = {
|
|
767
|
-
folder: { key: { id: currentFolderId, type: import_farseer_client.EntityType.Folder }, order: 0 }
|
|
768
|
-
};
|
|
769
|
-
}
|
|
770
|
-
} catch {
|
|
714
|
+
const placed = await folderFor(nativeClient, params.folderPath);
|
|
715
|
+
if ("error" in placed) {
|
|
716
|
+
return placed.error;
|
|
717
|
+
}
|
|
718
|
+
if (placed.folderId) {
|
|
719
|
+
createEntity.relations = {
|
|
720
|
+
folder: { key: { id: placed.folderId, type: import_farseer_client.EntityType.Folder }, order: 0 }
|
|
721
|
+
};
|
|
771
722
|
}
|
|
772
723
|
}
|
|
773
724
|
const result = await nativeClient.entities.mutate({ created: [createEntity] });
|
|
@@ -802,11 +753,9 @@ Updatable fields:
|
|
|
802
753
|
updateVariableSchema,
|
|
803
754
|
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
804
755
|
async (params) => {
|
|
805
|
-
const
|
|
806
|
-
if (!
|
|
807
|
-
const {
|
|
808
|
-
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
809
|
-
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
756
|
+
const gate = await (0, import_session.requireSession)();
|
|
757
|
+
if (!gate.ok) return gate.response;
|
|
758
|
+
const { tenant, native: nativeClient } = gate.session;
|
|
810
759
|
try {
|
|
811
760
|
await nativeClient.initTagMap();
|
|
812
761
|
const variable = await nativeClient.getVariable(params.name);
|
|
@@ -891,11 +840,9 @@ for the specified variable across all dimensions and time periods.
|
|
|
891
840
|
Use this to clear old template data or reset a variable before re-importing.`,
|
|
892
841
|
deleteVariableDataSchema,
|
|
893
842
|
async (params) => {
|
|
894
|
-
const
|
|
895
|
-
if (!
|
|
896
|
-
const {
|
|
897
|
-
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
898
|
-
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
843
|
+
const gate = await (0, import_session.requireSession)();
|
|
844
|
+
if (!gate.ok) return gate.response;
|
|
845
|
+
const { tenant, native: nativeClient } = gate.session;
|
|
899
846
|
try {
|
|
900
847
|
await nativeClient.initTagMap();
|
|
901
848
|
const variable = await nativeClient.getVariable(params.variableName);
|
|
@@ -924,11 +871,9 @@ Resolves the variable by name and permanently deletes it along with all its data
|
|
|
924
871
|
WARNING: This is destructive and cannot be undone.`,
|
|
925
872
|
deleteVariableSchema,
|
|
926
873
|
async (params) => {
|
|
927
|
-
const
|
|
928
|
-
if (!
|
|
929
|
-
const {
|
|
930
|
-
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
931
|
-
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
874
|
+
const gate = await (0, import_session.requireSession)();
|
|
875
|
+
if (!gate.ok) return gate.response;
|
|
876
|
+
const { tenant, native: nativeClient } = gate.session;
|
|
932
877
|
try {
|
|
933
878
|
await nativeClient.initTagMap();
|
|
934
879
|
const variable = await nativeClient.getVariable(params.variableName);
|