farseer-cli 1.0.9 → 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 +50 -18
- package/dist/commands/app.js.map +2 -2
- package/dist/commands/apps.js +14 -6
- package/dist/commands/apps.js.map +2 -2
- package/dist/commands/cells.js +161 -0
- package/dist/commands/cells.js.map +7 -0
- package/dist/commands/checkout.js +10 -3
- package/dist/commands/checkout.js.map +2 -2
- package/dist/commands/config.js +6 -2
- package/dist/commands/config.js.map +2 -2
- package/dist/commands/dashboards.js +130 -0
- package/dist/commands/dashboards.js.map +7 -0
- package/dist/commands/diff.js +4 -1
- package/dist/commands/diff.js.map +2 -2
- package/dist/commands/dimensions.js +91 -3
- package/dist/commands/dimensions.js.map +2 -2
- package/dist/commands/files.js +12 -4
- package/dist/commands/files.js.map +2 -2
- package/dist/commands/formula.js +116 -0
- package/dist/commands/formula.js.map +7 -0
- package/dist/commands/install.js +1 -0
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/list.js +4 -1
- package/dist/commands/list.js.map +2 -2
- package/dist/commands/login.js +16 -2
- package/dist/commands/login.js.map +2 -2
- package/dist/commands/logout.js +4 -1
- package/dist/commands/logout.js.map +2 -2
- package/dist/commands/mcp-server.js +2 -4
- package/dist/commands/mcp-server.js.map +2 -2
- package/dist/commands/model.js +8 -5
- package/dist/commands/model.js.map +2 -2
- package/dist/commands/pull.js +50 -32
- package/dist/commands/pull.js.map +2 -2
- package/dist/commands/push.js +21 -11
- package/dist/commands/push.js.map +2 -2
- package/dist/commands/run.js +6 -3
- package/dist/commands/run.js.map +2 -2
- package/dist/commands/sheets.js +200 -0
- package/dist/commands/sheets.js.map +7 -0
- package/dist/commands/status.js +4 -1
- package/dist/commands/status.js.map +2 -2
- package/dist/commands/variables.js +88 -5
- package/dist/commands/variables.js.map +2 -2
- package/dist/commands/whoami.js +5 -0
- package/dist/commands/whoami.js.map +2 -2
- package/dist/index.js +64 -2
- package/dist/index.js.map +2 -2
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/prompts/workflows.js +1 -0
- package/dist/mcp/prompts/workflows.js.map +1 -1
- package/dist/mcp/resources/documentation.js +1 -0
- package/dist/mcp/resources/documentation.js.map +2 -2
- package/dist/mcp/server.js +7 -0
- package/dist/mcp/server.js.map +2 -2
- package/dist/mcp/tools/appTools.js +7 -4
- package/dist/mcp/tools/appTools.js.map +2 -2
- package/dist/mcp/tools/authTools.js +2 -0
- package/dist/mcp/tools/authTools.js.map +2 -2
- 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 +22 -23
- package/dist/mcp/tools/dataTools.js.map +2 -2
- package/dist/mcp/tools/modelTools.js +317 -3
- package/dist/mcp/tools/modelTools.js.map +2 -2
- package/dist/mcp/tools/runTools.js +12 -8
- package/dist/mcp/tools/runTools.js.map +2 -2
- package/dist/mcp/tools/sheetTools.js +240 -0
- package/dist/mcp/tools/sheetTools.js.map +7 -0
- package/dist/mcp/tools/syncTools.js +6 -11
- package/dist/mcp/tools/syncTools.js.map +2 -2
- package/dist/mcp/utils/helpers.js +2 -1
- package/dist/mcp/utils/helpers.js.map +2 -2
- package/dist/services/appSyncService.js +60 -57
- package/dist/services/appSyncService.js.map +2 -2
- package/dist/services/configService.js +1 -0
- package/dist/services/configService.js.map +2 -2
- package/dist/services/farseerApi.js +11 -6
- package/dist/services/farseerApi.js.map +2 -2
- package/dist/services/farseerFactory.js +2 -1
- package/dist/services/farseerFactory.js.map +2 -2
- package/dist/services/farseerService.js +34 -35
- package/dist/services/farseerService.js.map +2 -2
- package/dist/services/syncService.js +20 -15
- package/dist/services/syncService.js.map +2 -2
- package/dist/utils/constants.js +15 -7
- package/dist/utils/constants.js.map +3 -3
- package/dist/utils/entityResolver.js +78 -0
- package/dist/utils/entityResolver.js.map +7 -0
- package/dist/utils/helpers.js +2 -3
- package/dist/utils/helpers.js.map +2 -2
- package/dist/utils/logger.js +1 -0
- package/dist/utils/logger.js.map +2 -2
- package/package.json +10 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -37,62 +38,62 @@ var import_logger = require("../utils/logger");
|
|
|
37
38
|
function sanitizeDiacritics(text) {
|
|
38
39
|
const diacriticMap = {
|
|
39
40
|
// Croatian
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
\u010D: "c",
|
|
42
|
+
\u010C: "C",
|
|
43
|
+
\u0107: "c",
|
|
44
|
+
\u0106: "C",
|
|
45
|
+
\u0161: "s",
|
|
46
|
+
\u0160: "S",
|
|
47
|
+
\u017E: "z",
|
|
48
|
+
\u017D: "Z",
|
|
49
|
+
\u0111: "d",
|
|
50
|
+
\u0110: "D",
|
|
50
51
|
// German/Other common
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
\u00E4: "a",
|
|
53
|
+
\u00C4: "A",
|
|
54
|
+
\u00F6: "o",
|
|
55
|
+
\u00D6: "O",
|
|
56
|
+
\u00FC: "u",
|
|
57
|
+
\u00DC: "U",
|
|
58
|
+
\u00DF: "ss",
|
|
58
59
|
// Polish
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
\u0105: "a",
|
|
61
|
+
\u0104: "A",
|
|
62
|
+
\u0119: "e",
|
|
63
|
+
\u0118: "E",
|
|
64
|
+
\u0142: "l",
|
|
65
|
+
\u0141: "L",
|
|
66
|
+
\u0144: "n",
|
|
67
|
+
\u0143: "N",
|
|
68
|
+
\u00F3: "o",
|
|
69
|
+
\u00D3: "O",
|
|
70
|
+
\u015B: "s",
|
|
71
|
+
\u015A: "S",
|
|
72
|
+
\u017A: "z",
|
|
73
|
+
\u0179: "Z",
|
|
74
|
+
\u017C: "z",
|
|
75
|
+
\u017B: "Z",
|
|
75
76
|
// French/Spanish
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
77
|
+
\u00E0: "a",
|
|
78
|
+
\u00E1: "a",
|
|
79
|
+
\u00E2: "a",
|
|
80
|
+
\u00E8: "e",
|
|
81
|
+
\u00E9: "e",
|
|
82
|
+
\u00EA: "e",
|
|
83
|
+
\u00EB: "e",
|
|
84
|
+
\u00EC: "i",
|
|
85
|
+
\u00ED: "i",
|
|
86
|
+
\u00EE: "i",
|
|
87
|
+
\u00EF: "i",
|
|
88
|
+
\u00F2: "o",
|
|
89
|
+
\u00F4: "o",
|
|
90
|
+
\u00F9: "u",
|
|
91
|
+
\u00FA: "u",
|
|
92
|
+
\u00FB: "u",
|
|
93
|
+
\u00F1: "n",
|
|
94
|
+
\u00D1: "N",
|
|
95
|
+
\u00E7: "c",
|
|
96
|
+
\u00C7: "C"
|
|
96
97
|
};
|
|
97
98
|
return text.split("").map((char) => diacriticMap[char] || char).join("");
|
|
98
99
|
}
|
|
@@ -151,12 +152,13 @@ class AppSyncService {
|
|
|
151
152
|
* Convert remote app to local config format
|
|
152
153
|
*/
|
|
153
154
|
remoteToLocal(remote, reference) {
|
|
154
|
-
const
|
|
155
|
+
const scriptFiles = remote.scriptFiles ?? [];
|
|
156
|
+
const mainScript = scriptFiles.find((s) => s.id === remote.mainScriptFileId);
|
|
155
157
|
return {
|
|
156
158
|
name: remote.name,
|
|
157
159
|
description: remote.description || "",
|
|
158
160
|
entrypoint: mainScript?.name || null,
|
|
159
|
-
scripts:
|
|
161
|
+
scripts: scriptFiles.map((s) => s.name),
|
|
160
162
|
arguments: remote.expectedArguments.map((a) => ({
|
|
161
163
|
name: a.name,
|
|
162
164
|
defaultValue: a.defaultValue
|
|
@@ -173,10 +175,11 @@ class AppSyncService {
|
|
|
173
175
|
areAppsEqual(local, remote) {
|
|
174
176
|
if (local.name !== remote.name) return false;
|
|
175
177
|
if ((local.description || "") !== (remote.description || "")) return false;
|
|
176
|
-
const
|
|
178
|
+
const remoteScriptFiles = remote.scriptFiles ?? [];
|
|
179
|
+
const remoteEntrypoint = remoteScriptFiles.find((s) => s.id === remote.mainScriptFileId)?.name || null;
|
|
177
180
|
if (local.entrypoint !== remoteEntrypoint) return false;
|
|
178
181
|
const localScripts = [...local.scripts].sort();
|
|
179
|
-
const remoteScripts = [...
|
|
182
|
+
const remoteScripts = [...remoteScriptFiles.map((s) => s.name)].sort();
|
|
180
183
|
if (JSON.stringify(localScripts) !== JSON.stringify(remoteScripts)) return false;
|
|
181
184
|
const localArgs = local.arguments.map((a) => `${a.name}=${a.defaultValue}`).sort();
|
|
182
185
|
const remoteArgs = remote.expectedArguments.map((a) => `${a.name}=${a.defaultValue}`).sort();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/services/appSyncService.ts"],
|
|
4
|
-
"sourcesContent": ["import * as fs from 'fs';\nimport * as path from 'path';\nimport { RemoteApp, AppArgument } from './farseerApi';\nimport { IFarseerClient } from './farseerFactory';\nimport { getTenantAppsDir, ensureDirectoryExists, fetchWithConcurrency } from '../utils/helpers';\nimport { logger } from '../utils/logger';\n\n// Local app config format (stored in apps/*.json)\nexport interface LocalAppConfig {\n name: string;\n description: string;\n entrypoint: string | null; // Script filename (e.g., \"index.ts\")\n scripts: string[]; // List of script filenames\n arguments: {\n name: string;\n defaultValue: string;\n }[];\n _remote?: {\n id: number;\n reference: string;\n };\n}\n\nexport interface AppSyncResult {\n created: string[];\n updated: string[];\n deleted: string[];\n unchanged: string[];\n}\n\nexport interface AppSyncStatus {\n newLocal: string[]; // Local apps not on remote\n newRemote: string[]; // Remote apps not locally\n modified: string[]; // Apps that differ\n synced: string[]; // Apps in sync\n}\n\n/**\n * Sanitize Croatian diacritics and other special characters to ASCII equivalents\n */\nfunction sanitizeDiacritics(text: string): string {\n const diacriticMap: Record<string, string> = {\n // Croatian\n '\u010D': 'c', '\u010C': 'C',\n '\u0107': 'c', '\u0106': 'C',\n '\u0161': 's', '\u0160': 'S',\n '\u017E': 'z', '\u017D': 'Z',\n '\u0111': 'd', '\u0110': 'D',\n // German/Other common\n '\u00E4': 'a', '\u00C4': 'A',\n '\u00F6': 'o', '\u00D6': 'O',\n '\u00FC': 'u', '\u00DC': 'U',\n '\u00DF': 'ss',\n // Polish\n '\u0105': 'a', '\u0104': 'A',\n '\u0119': 'e', '\u0118': 'E',\n '\u0142': 'l', '\u0141': 'L',\n '\u0144': 'n', '\u0143': 'N',\n '\u00F3': 'o', '\u00D3': 'O',\n '\u015B': 's', '\u015A': 'S',\n '\u017A': 'z', '\u0179': 'Z',\n '\u017C': 'z', '\u017B': 'Z',\n // French/Spanish\n '\u00E0': 'a', '\u00E1': 'a', '\u00E2': 'a',\n '\u00E8': 'e', '\u00E9': 'e', '\u00EA': 'e', '\u00EB': 'e',\n '\u00EC': 'i', '\u00ED': 'i', '\u00EE': 'i', '\u00EF': 'i',\n '\u00F2': 'o', '\u00F4': 'o',\n '\u00F9': 'u', '\u00FA': 'u', '\u00FB': 'u',\n '\u00F1': 'n', '\u00D1': 'N',\n '\u00E7': 'c', '\u00C7': 'C',\n };\n\n return text.split('').map(char => diacriticMap[char] || char).join('');\n}\n\n/**\n * Service for syncing app configurations between local JSON files and remote Farseer instance\n */\nexport class AppSyncService {\n private api: IFarseerClient;\n private appsDir: string;\n\n constructor(tenant: string, api: IFarseerClient) {\n this.api = api;\n this.appsDir = getTenantAppsDir(tenant);\n }\n\n /**\n * Get filename for an app (keep original name, just sanitize for filesystem)\n */\n private getAppFilename(name: string): string {\n return sanitizeDiacritics(name)\n .replace(/[<>:\"/\\\\|?*]/g, '') // Remove invalid filename characters\n .trim() + '.json';\n }\n\n /**\n * Load all local app configs\n */\n loadLocalApps(): Map<string, LocalAppConfig> {\n const apps = new Map<string, LocalAppConfig>();\n\n if (!fs.existsSync(this.appsDir)) {\n return apps;\n }\n\n const files = fs.readdirSync(this.appsDir).filter(f => f.endsWith('.json'));\n\n for (const file of files) {\n try {\n const content = fs.readFileSync(path.join(this.appsDir, file), 'utf-8');\n const config = JSON.parse(content) as LocalAppConfig;\n apps.set(config.name.toLowerCase(), config);\n } catch {\n // Skip invalid files\n }\n }\n\n return apps;\n }\n\n /**\n * Save a local app config\n */\n saveLocalApp(config: LocalAppConfig): void {\n ensureDirectoryExists(this.appsDir);\n const filename = this.getAppFilename(config.name);\n const filePath = path.join(this.appsDir, filename);\n fs.writeFileSync(filePath, JSON.stringify(config, null, 2), 'utf-8');\n }\n\n /**\n * Delete a local app config\n */\n deleteLocalApp(name: string): boolean {\n const filename = this.getAppFilename(name);\n const filePath = path.join(this.appsDir, filename);\n\n if (fs.existsSync(filePath)) {\n fs.unlinkSync(filePath);\n return true;\n }\n return false;\n }\n\n /**\n * Convert remote app to local config format\n */\n private remoteToLocal(remote: RemoteApp, reference: string): LocalAppConfig {\n const mainScript = remote.scriptFiles.find(s => s.id === remote.mainScriptFileId);\n\n return {\n name: remote.name,\n description: remote.description || '',\n entrypoint: mainScript?.name || null,\n scripts: remote.scriptFiles.map(s => s.name),\n arguments: remote.expectedArguments.map(a => ({\n name: a.name,\n defaultValue: a.defaultValue,\n })),\n _remote: {\n id: remote.id,\n reference: reference,\n },\n };\n }\n\n /**\n * Check if local and remote app configs are equivalent\n */\n private areAppsEqual(local: LocalAppConfig, remote: RemoteApp): boolean {\n // Compare name\n if (local.name !== remote.name) return false;\n\n // Compare description\n if ((local.description || '') !== (remote.description || '')) return false;\n\n // Compare entrypoint\n const remoteEntrypoint = remote.scriptFiles.find(s => s.id === remote.mainScriptFileId)?.name || null;\n if (local.entrypoint !== remoteEntrypoint) return false;\n\n // Compare scripts\n const localScripts = [...local.scripts].sort();\n const remoteScripts = [...remote.scriptFiles.map(s => s.name)].sort();\n if (JSON.stringify(localScripts) !== JSON.stringify(remoteScripts)) return false;\n\n // Compare arguments\n const localArgs = local.arguments.map(a => `${a.name}=${a.defaultValue}`).sort();\n const remoteArgs = remote.expectedArguments.map(a => `${a.name}=${a.defaultValue}`).sort();\n if (JSON.stringify(localArgs) !== JSON.stringify(remoteArgs)) return false;\n\n return true;\n }\n\n /**\n * Pull apps from remote and save locally\n */\n async pull(): Promise<AppSyncResult> {\n const result: AppSyncResult = {\n created: [],\n updated: [],\n deleted: [],\n unchanged: [],\n };\n\n // Load local apps\n const localApps = this.loadLocalApps();\n\n // Fetch remote apps\n const remoteAppList = await this.api.listApps();\n const remoteApps = new Map<string, { app: RemoteApp; reference: string }>();\n\n // Fetch app details in parallel with concurrency limit\n logger.dim(`Fetching ${remoteAppList.length} apps in parallel...`);\n const appDetails = await fetchWithConcurrency(\n remoteAppList,\n async (item, index) => {\n const app = await this.api.getApp(item.reference);\n // Show progress every 10 apps\n if ((index + 1) % 10 === 0 || index === remoteAppList.length - 1) {\n process.stdout.write(`\\r Progress: ${index + 1}/${remoteAppList.length} apps`);\n }\n return { app, reference: item.reference };\n },\n 15\n );\n // Clear progress line\n if (remoteAppList.length > 0) {\n process.stdout.write('\\r' + ' '.repeat(50) + '\\r');\n }\n\n for (const { app, reference } of appDetails) {\n if (app) {\n remoteApps.set(app.name.toLowerCase(), { app, reference });\n }\n }\n\n // Process remote apps\n for (const [key, { app, reference }] of remoteApps) {\n const localConfig = this.remoteToLocal(app, reference);\n const existingLocal = localApps.get(key);\n\n if (!existingLocal) {\n // New app from remote\n this.saveLocalApp(localConfig);\n result.created.push(app.name);\n } else if (!this.areAppsEqual(existingLocal, app)) {\n // App changed on remote - update local\n this.saveLocalApp(localConfig);\n result.updated.push(app.name);\n } else {\n result.unchanged.push(app.name);\n }\n }\n\n // Check for apps deleted on remote\n for (const [key, local] of localApps) {\n if (!remoteApps.has(key) && local._remote) {\n // App was synced before but now deleted on remote\n this.deleteLocalApp(local.name);\n result.deleted.push(local.name);\n }\n }\n\n return result;\n }\n\n /**\n * Push local apps to remote\n */\n async push(): Promise<AppSyncResult> {\n const result: AppSyncResult = {\n created: [],\n updated: [],\n deleted: [],\n unchanged: [],\n };\n\n // Load local apps\n const localApps = this.loadLocalApps();\n\n // Fetch remote apps\n const remoteAppList = await this.api.listApps();\n const remoteApps = new Map<string, { app: RemoteApp; reference: string }>();\n\n // Fetch app details in parallel with concurrency limit\n const appDetails = await fetchWithConcurrency(\n remoteAppList,\n async (item) => {\n const app = await this.api.getApp(item.reference);\n return { app, reference: item.reference };\n },\n 15\n );\n\n for (const { app, reference } of appDetails) {\n if (app) {\n remoteApps.set(app.name.toLowerCase(), { app, reference });\n }\n }\n\n // Get available scripts for ID lookup\n // Build maps for both path-based and filename-based lookup (backward compatibility)\n const availableScripts = await this.api.getScriptFiles();\n const scriptIdByPath = new Map<string, string>();\n const scriptIdByName = new Map<string, string>();\n\n for (const s of availableScripts) {\n // s.name now contains full path (e.g., \"Scripts/test.ts\")\n const pathKey = s.name.toLowerCase();\n const filenameKey = s.name.split('/').pop()?.toLowerCase() || pathKey;\n\n scriptIdByPath.set(pathKey, s.id);\n // For filename lookup, only set if not already set (first match wins for ambiguous names)\n if (!scriptIdByName.has(filenameKey)) {\n scriptIdByName.set(filenameKey, s.id);\n }\n }\n\n // Helper to find script ID by path or filename\n const findScriptId = (scriptRef: string): string | undefined => {\n const key = scriptRef.toLowerCase();\n // Try exact path match first\n const byPath = scriptIdByPath.get(key);\n if (byPath) return byPath;\n // Try with Scripts/ prefix\n const withPrefix = scriptIdByPath.get(`scripts/${key}`);\n if (withPrefix) return withPrefix;\n // Fall back to filename match\n return scriptIdByName.get(key.split('/').pop() || key);\n };\n\n // Process local apps\n for (const [key, local] of localApps) {\n const remote = remoteApps.get(key);\n\n if (!remote) {\n // New local app - create on remote\n try {\n const created = await this.api.createApp(local.name);\n\n // Update with config (API requires name and description)\n const update = this.buildUpdatePayload(local, findScriptId);\n update.name = local.name;\n update.description = local.description;\n await this.api.updateApp(created.id.toString(), update);\n\n // Update local with remote ID\n local._remote = {\n id: created.id,\n reference: created.id.toString(),\n };\n this.saveLocalApp(local);\n\n result.created.push(local.name);\n } catch (error) {\n console.error(`Failed to create app ${local.name}:`, error);\n }\n } else if (!this.areAppsEqual(local, remote.app)) {\n // App differs - update remote\n try {\n const update = this.buildUpdatePayload(local, findScriptId);\n update.name = local.name;\n update.description = local.description;\n\n await this.api.updateApp(remote.reference, update);\n result.updated.push(local.name);\n } catch (error) {\n console.error(`Failed to update app ${local.name}:`, error);\n }\n } else {\n result.unchanged.push(local.name);\n }\n }\n\n // Note: We don't auto-delete remote apps when deleted locally\n // User must use \"farseer app delete\" explicitly\n\n return result;\n }\n\n /**\n * Build update payload for API\n */\n private buildUpdatePayload(\n local: LocalAppConfig,\n findScriptId: (scriptRef: string) => string | undefined\n ): {\n name?: string;\n description?: string;\n expectedArguments?: AppArgument[];\n mainScriptFileId?: string | null;\n scriptFileIds?: string[];\n } {\n const update: {\n name?: string;\n description?: string;\n expectedArguments?: AppArgument[];\n mainScriptFileId?: string | null;\n scriptFileIds?: string[];\n } = {};\n\n // Arguments\n if (local.arguments.length > 0) {\n update.expectedArguments = local.arguments.map(a => ({\n name: a.name,\n type: 'variable' as const,\n defaultValue: a.defaultValue,\n }));\n }\n\n // Scripts - lookup by path or filename\n if (local.scripts.length > 0) {\n const scriptIds: string[] = [];\n for (const scriptRef of local.scripts) {\n const id = findScriptId(scriptRef);\n if (id) {\n scriptIds.push(id);\n }\n }\n if (scriptIds.length > 0) {\n update.scriptFileIds = scriptIds;\n }\n }\n\n // Entrypoint - lookup by path or filename\n if (local.entrypoint) {\n const entrypointId = findScriptId(local.entrypoint);\n if (entrypointId) {\n update.mainScriptFileId = entrypointId;\n }\n }\n\n return update;\n }\n\n /**\n * Get sync status without making changes\n */\n async getStatus(): Promise<AppSyncStatus> {\n const status: AppSyncStatus = {\n newLocal: [],\n newRemote: [],\n modified: [],\n synced: [],\n };\n\n // Load local apps\n const localApps = this.loadLocalApps();\n\n // Fetch remote apps\n const remoteAppList = await this.api.listApps();\n const remoteApps = new Map<string, { app: RemoteApp; reference: string }>();\n\n // Fetch app details in parallel with concurrency limit\n const appDetails = await fetchWithConcurrency(\n remoteAppList,\n async (item) => {\n const app = await this.api.getApp(item.reference);\n return { app, reference: item.reference };\n },\n 15\n );\n\n for (const { app, reference } of appDetails) {\n if (app) {\n remoteApps.set(app.name.toLowerCase(), { app, reference });\n }\n }\n\n // Check local apps\n for (const [key, local] of localApps) {\n const remote = remoteApps.get(key);\n\n if (!remote) {\n status.newLocal.push(local.name);\n } else if (!this.areAppsEqual(local, remote.app)) {\n status.modified.push(local.name);\n } else {\n status.synced.push(local.name);\n }\n }\n\n // Check for new remote apps\n for (const [key, { app }] of remoteApps) {\n if (!localApps.has(key)) {\n status.newRemote.push(app.name);\n }\n }\n\n return status;\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import * as fs from 'fs';\nimport * as path from 'path';\nimport { RemoteApp, AppArgument } from './farseerApi';\nimport { IFarseerClient } from './farseerFactory';\nimport { getTenantAppsDir, ensureDirectoryExists, fetchWithConcurrency } from '../utils/helpers';\nimport { logger } from '../utils/logger';\n\n// Local app config format (stored in apps/*.json)\nexport interface LocalAppConfig {\n name: string;\n description: string;\n entrypoint: string | null; // Script filename (e.g., \"index.ts\")\n scripts: string[]; // List of script filenames\n arguments: {\n name: string;\n defaultValue: string;\n }[];\n _remote?: {\n id: number;\n reference: string;\n };\n}\n\nexport interface AppSyncResult {\n created: string[];\n updated: string[];\n deleted: string[];\n unchanged: string[];\n}\n\nexport interface AppSyncStatus {\n newLocal: string[]; // Local apps not on remote\n newRemote: string[]; // Remote apps not locally\n modified: string[]; // Apps that differ\n synced: string[]; // Apps in sync\n}\n\n/**\n * Sanitize Croatian diacritics and other special characters to ASCII equivalents\n */\nfunction sanitizeDiacritics(text: string): string {\n const diacriticMap: Record<string, string> = {\n // Croatian\n \u010D: 'c',\n \u010C: 'C',\n \u0107: 'c',\n \u0106: 'C',\n \u0161: 's',\n \u0160: 'S',\n \u017E: 'z',\n \u017D: 'Z',\n \u0111: 'd',\n \u0110: 'D',\n // German/Other common\n \u00E4: 'a',\n \u00C4: 'A',\n \u00F6: 'o',\n \u00D6: 'O',\n \u00FC: 'u',\n \u00DC: 'U',\n \u00DF: 'ss',\n // Polish\n \u0105: 'a',\n \u0104: 'A',\n \u0119: 'e',\n \u0118: 'E',\n \u0142: 'l',\n \u0141: 'L',\n \u0144: 'n',\n \u0143: 'N',\n \u00F3: 'o',\n \u00D3: 'O',\n \u015B: 's',\n \u015A: 'S',\n \u017A: 'z',\n \u0179: 'Z',\n \u017C: 'z',\n \u017B: 'Z',\n // French/Spanish\n \u00E0: 'a',\n \u00E1: 'a',\n \u00E2: 'a',\n \u00E8: 'e',\n \u00E9: 'e',\n \u00EA: 'e',\n \u00EB: 'e',\n \u00EC: 'i',\n \u00ED: 'i',\n \u00EE: 'i',\n \u00EF: 'i',\n \u00F2: 'o',\n \u00F4: 'o',\n \u00F9: 'u',\n \u00FA: 'u',\n \u00FB: 'u',\n \u00F1: 'n',\n \u00D1: 'N',\n \u00E7: 'c',\n \u00C7: 'C',\n };\n\n return text\n .split('')\n .map((char) => diacriticMap[char] || char)\n .join('');\n}\n\n/**\n * Service for syncing app configurations between local JSON files and remote Farseer instance\n */\nexport class AppSyncService {\n private api: IFarseerClient;\n private appsDir: string;\n\n constructor(tenant: string, api: IFarseerClient) {\n this.api = api;\n this.appsDir = getTenantAppsDir(tenant);\n }\n\n /**\n * Get filename for an app (keep original name, just sanitize for filesystem)\n */\n private getAppFilename(name: string): string {\n return (\n sanitizeDiacritics(name)\n .replace(/[<>:\"/\\\\|?*]/g, '') // Remove invalid filename characters\n .trim() + '.json'\n );\n }\n\n /**\n * Load all local app configs\n */\n loadLocalApps(): Map<string, LocalAppConfig> {\n const apps = new Map<string, LocalAppConfig>();\n\n if (!fs.existsSync(this.appsDir)) {\n return apps;\n }\n\n const files = fs.readdirSync(this.appsDir).filter((f) => f.endsWith('.json'));\n\n for (const file of files) {\n try {\n const content = fs.readFileSync(path.join(this.appsDir, file), 'utf-8');\n const config = JSON.parse(content) as LocalAppConfig;\n apps.set(config.name.toLowerCase(), config);\n } catch {\n // Skip invalid files\n }\n }\n\n return apps;\n }\n\n /**\n * Save a local app config\n */\n saveLocalApp(config: LocalAppConfig): void {\n ensureDirectoryExists(this.appsDir);\n const filename = this.getAppFilename(config.name);\n const filePath = path.join(this.appsDir, filename);\n fs.writeFileSync(filePath, JSON.stringify(config, null, 2), 'utf-8');\n }\n\n /**\n * Delete a local app config\n */\n deleteLocalApp(name: string): boolean {\n const filename = this.getAppFilename(name);\n const filePath = path.join(this.appsDir, filename);\n\n if (fs.existsSync(filePath)) {\n fs.unlinkSync(filePath);\n return true;\n }\n return false;\n }\n\n /**\n * Convert remote app to local config format\n */\n private remoteToLocal(remote: RemoteApp, reference: string): LocalAppConfig {\n const scriptFiles = remote.scriptFiles ?? [];\n const mainScript = scriptFiles.find((s) => s.id === remote.mainScriptFileId);\n\n return {\n name: remote.name,\n description: remote.description || '',\n entrypoint: mainScript?.name || null,\n scripts: scriptFiles.map((s) => s.name),\n arguments: remote.expectedArguments.map((a) => ({\n name: a.name,\n defaultValue: a.defaultValue,\n })),\n _remote: {\n id: remote.id,\n reference: reference,\n },\n };\n }\n\n /**\n * Check if local and remote app configs are equivalent\n */\n private areAppsEqual(local: LocalAppConfig, remote: RemoteApp): boolean {\n // Compare name\n if (local.name !== remote.name) return false;\n\n // Compare description\n if ((local.description || '') !== (remote.description || '')) return false;\n\n // Compare entrypoint\n const remoteScriptFiles = remote.scriptFiles ?? [];\n const remoteEntrypoint = remoteScriptFiles.find((s) => s.id === remote.mainScriptFileId)?.name || null;\n if (local.entrypoint !== remoteEntrypoint) return false;\n\n // Compare scripts\n const localScripts = [...local.scripts].sort();\n const remoteScripts = [...remoteScriptFiles.map((s) => s.name)].sort();\n if (JSON.stringify(localScripts) !== JSON.stringify(remoteScripts)) return false;\n\n // Compare arguments\n const localArgs = local.arguments.map((a) => `${a.name}=${a.defaultValue}`).sort();\n const remoteArgs = remote.expectedArguments.map((a) => `${a.name}=${a.defaultValue}`).sort();\n if (JSON.stringify(localArgs) !== JSON.stringify(remoteArgs)) return false;\n\n return true;\n }\n\n /**\n * Pull apps from remote and save locally\n */\n async pull(): Promise<AppSyncResult> {\n const result: AppSyncResult = {\n created: [],\n updated: [],\n deleted: [],\n unchanged: [],\n };\n\n // Load local apps\n const localApps = this.loadLocalApps();\n\n // Fetch remote apps\n const remoteAppList = await this.api.listApps();\n const remoteApps = new Map<string, { app: RemoteApp; reference: string }>();\n\n // Fetch app details in parallel with concurrency limit\n logger.dim(`Fetching ${remoteAppList.length} apps in parallel...`);\n const appDetails = await fetchWithConcurrency(\n remoteAppList,\n async (item, index) => {\n const app = await this.api.getApp(item.reference);\n // Show progress every 10 apps\n if ((index + 1) % 10 === 0 || index === remoteAppList.length - 1) {\n process.stdout.write(`\\r Progress: ${index + 1}/${remoteAppList.length} apps`);\n }\n return { app, reference: item.reference };\n },\n 15,\n );\n // Clear progress line\n if (remoteAppList.length > 0) {\n process.stdout.write('\\r' + ' '.repeat(50) + '\\r');\n }\n\n for (const { app, reference } of appDetails) {\n if (app) {\n remoteApps.set(app.name.toLowerCase(), { app, reference });\n }\n }\n\n // Process remote apps\n for (const [key, { app, reference }] of remoteApps) {\n const localConfig = this.remoteToLocal(app, reference);\n const existingLocal = localApps.get(key);\n\n if (!existingLocal) {\n // New app from remote\n this.saveLocalApp(localConfig);\n result.created.push(app.name);\n } else if (!this.areAppsEqual(existingLocal, app)) {\n // App changed on remote - update local\n this.saveLocalApp(localConfig);\n result.updated.push(app.name);\n } else {\n result.unchanged.push(app.name);\n }\n }\n\n // Check for apps deleted on remote\n for (const [key, local] of localApps) {\n if (!remoteApps.has(key) && local._remote) {\n // App was synced before but now deleted on remote\n this.deleteLocalApp(local.name);\n result.deleted.push(local.name);\n }\n }\n\n return result;\n }\n\n /**\n * Push local apps to remote\n */\n async push(): Promise<AppSyncResult> {\n const result: AppSyncResult = {\n created: [],\n updated: [],\n deleted: [],\n unchanged: [],\n };\n\n // Load local apps\n const localApps = this.loadLocalApps();\n\n // Fetch remote apps\n const remoteAppList = await this.api.listApps();\n const remoteApps = new Map<string, { app: RemoteApp; reference: string }>();\n\n // Fetch app details in parallel with concurrency limit\n const appDetails = await fetchWithConcurrency(\n remoteAppList,\n async (item) => {\n const app = await this.api.getApp(item.reference);\n return { app, reference: item.reference };\n },\n 15,\n );\n\n for (const { app, reference } of appDetails) {\n if (app) {\n remoteApps.set(app.name.toLowerCase(), { app, reference });\n }\n }\n\n // Get available scripts for ID lookup\n // Build maps for both path-based and filename-based lookup (backward compatibility)\n const availableScripts = await this.api.getScriptFiles();\n const scriptIdByPath = new Map<string, string>();\n const scriptIdByName = new Map<string, string>();\n\n for (const s of availableScripts) {\n // s.name now contains full path (e.g., \"Scripts/test.ts\")\n const pathKey = s.name.toLowerCase();\n const filenameKey = s.name.split('/').pop()?.toLowerCase() || pathKey;\n\n scriptIdByPath.set(pathKey, s.id);\n // For filename lookup, only set if not already set (first match wins for ambiguous names)\n if (!scriptIdByName.has(filenameKey)) {\n scriptIdByName.set(filenameKey, s.id);\n }\n }\n\n // Helper to find script ID by path or filename\n const findScriptId = (scriptRef: string): string | undefined => {\n const key = scriptRef.toLowerCase();\n // Try exact path match first\n const byPath = scriptIdByPath.get(key);\n if (byPath) return byPath;\n // Try with Scripts/ prefix\n const withPrefix = scriptIdByPath.get(`scripts/${key}`);\n if (withPrefix) return withPrefix;\n // Fall back to filename match\n return scriptIdByName.get(key.split('/').pop() || key);\n };\n\n // Process local apps\n for (const [key, local] of localApps) {\n const remote = remoteApps.get(key);\n\n if (!remote) {\n // New local app - create on remote\n try {\n const created = await this.api.createApp(local.name);\n\n // Update with config (API requires name and description)\n const update = this.buildUpdatePayload(local, findScriptId);\n update.name = local.name;\n update.description = local.description;\n await this.api.updateApp(created.id.toString(), update);\n\n // Update local with remote ID\n local._remote = {\n id: created.id,\n reference: created.id.toString(),\n };\n this.saveLocalApp(local);\n\n result.created.push(local.name);\n } catch (error) {\n console.error(`Failed to create app ${local.name}:`, error);\n }\n } else if (!this.areAppsEqual(local, remote.app)) {\n // App differs - update remote\n try {\n const update = this.buildUpdatePayload(local, findScriptId);\n update.name = local.name;\n update.description = local.description;\n\n await this.api.updateApp(remote.reference, update);\n result.updated.push(local.name);\n } catch (error) {\n console.error(`Failed to update app ${local.name}:`, error);\n }\n } else {\n result.unchanged.push(local.name);\n }\n }\n\n // Note: We don't auto-delete remote apps when deleted locally\n // User must use \"farseer app delete\" explicitly\n\n return result;\n }\n\n /**\n * Build update payload for API\n */\n private buildUpdatePayload(\n local: LocalAppConfig,\n findScriptId: (scriptRef: string) => string | undefined,\n ): {\n name?: string;\n description?: string;\n expectedArguments?: AppArgument[];\n mainScriptFileId?: string | null;\n scriptFileIds?: string[];\n } {\n const update: {\n name?: string;\n description?: string;\n expectedArguments?: AppArgument[];\n mainScriptFileId?: string | null;\n scriptFileIds?: string[];\n } = {};\n\n // Arguments\n if (local.arguments.length > 0) {\n update.expectedArguments = local.arguments.map((a) => ({\n name: a.name,\n type: 'variable' as const,\n defaultValue: a.defaultValue,\n }));\n }\n\n // Scripts - lookup by path or filename\n if (local.scripts.length > 0) {\n const scriptIds: string[] = [];\n for (const scriptRef of local.scripts) {\n const id = findScriptId(scriptRef);\n if (id) {\n scriptIds.push(id);\n }\n }\n if (scriptIds.length > 0) {\n update.scriptFileIds = scriptIds;\n }\n }\n\n // Entrypoint - lookup by path or filename\n if (local.entrypoint) {\n const entrypointId = findScriptId(local.entrypoint);\n if (entrypointId) {\n update.mainScriptFileId = entrypointId;\n }\n }\n\n return update;\n }\n\n /**\n * Get sync status without making changes\n */\n async getStatus(): Promise<AppSyncStatus> {\n const status: AppSyncStatus = {\n newLocal: [],\n newRemote: [],\n modified: [],\n synced: [],\n };\n\n // Load local apps\n const localApps = this.loadLocalApps();\n\n // Fetch remote apps\n const remoteAppList = await this.api.listApps();\n const remoteApps = new Map<string, { app: RemoteApp; reference: string }>();\n\n // Fetch app details in parallel with concurrency limit\n const appDetails = await fetchWithConcurrency(\n remoteAppList,\n async (item) => {\n const app = await this.api.getApp(item.reference);\n return { app, reference: item.reference };\n },\n 15,\n );\n\n for (const { app, reference } of appDetails) {\n if (app) {\n remoteApps.set(app.name.toLowerCase(), { app, reference });\n }\n }\n\n // Check local apps\n for (const [key, local] of localApps) {\n const remote = remoteApps.get(key);\n\n if (!remote) {\n status.newLocal.push(local.name);\n } else if (!this.areAppsEqual(local, remote.app)) {\n status.modified.push(local.name);\n } else {\n status.synced.push(local.name);\n }\n }\n\n // Check for new remote apps\n for (const [key, { app }] of remoteApps) {\n if (!localApps.has(key)) {\n status.newRemote.push(app.name);\n }\n }\n\n return status;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,WAAsB;AAGtB,qBAA8E;AAC9E,oBAAuB;AAmCvB,SAAS,mBAAmB,MAAsB;AAC9C,QAAM,eA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eAAW,EAAE,KAAK,UAAU,KAAK,YAAY;AACzC,UAAI,KAAK;AACL,mBAAW,IAAI,IAAI,KAAK,YAAY,GAAG,EAAE,KAAK,UAAU,CAAC;AAAA,MAC7D;AAAA,IACJ;AAGA,eAAW,CAAC,KAAK,KAAK,KAAK,WAAW;AAClC,YAAM,SAAS,WAAW,IAAI,GAAG;AAEjC,UAAI,CAAC,QAAQ;AACT,eAAO,SAAS,KAAK,MAAM,IAAI;AAAA,MACnC,WAAW,CAAC,KAAK,aAAa,OAAO,OAAO,GAAG,GAAG;AAC9C,eAAO,SAAS,KAAK,MAAM,IAAI;AAAA,MACnC,OAAO;AACH,eAAO,OAAO,KAAK,MAAM,IAAI;AAAA,MACjC;AAAA,IACJ;AAGA,eAAW,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,YAAY;AACrC,UAAI,CAAC,UAAU,IAAI,GAAG,GAAG;AACrB,eAAO,UAAU,KAAK,IAAI,IAAI;AAAA,MAClC;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/services/configService.ts"],
|
|
4
|
-
"sourcesContent": ["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as os from 'os';\n\nexport interface ApiKeyCredential {\n type: 'apiKey';\n tenantId: string;\n apiKey: string;\n basePath: string;\n}\n\nexport interface UserAuth {\n accessToken: string;\n refreshToken: string;\n expiresAt: string;\n tenant?: string; // Tenant used for login (Keycloak client ID)\n realm?: string; // Keycloak realm (default: master)\n}\n\nexport interface CurrentCheckout {\n organisation: string;
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as os from 'os';\n\nexport interface ApiKeyCredential {\n type: 'apiKey';\n tenantId: string;\n apiKey: string;\n basePath: string;\n}\n\nexport interface UserAuth {\n accessToken: string;\n refreshToken: string;\n expiresAt: string;\n tenant?: string; // Tenant used for login (Keycloak client ID)\n realm?: string; // Keycloak realm (default: master)\n}\n\nexport interface CurrentCheckout {\n organisation: string; // For URL: https://<organisation>.farseer.io\n tenant: string; // For X-TENANT-ID header\n}\n\nexport interface FarseerConfig {\n credentials: Record<string, ApiKeyCredential>;\n userAuth?: UserAuth;\n currentTenant?: string; // Deprecated: use currentCheckout\n currentCheckout?: CurrentCheckout; // Organisation + tenant\n tenantOrgMapping?: Record<string, string>; // Tenant -> Organisation mapping\n}\n\nconst CONFIG_DIR = path.join(os.homedir(), '.farseer');\nconst CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');\n\nfunction ensureConfigDir(): void {\n if (!fs.existsSync(CONFIG_DIR)) {\n fs.mkdirSync(CONFIG_DIR, { recursive: true });\n }\n}\n\nfunction getDefaultConfig(): FarseerConfig {\n return {\n credentials: {},\n userAuth: undefined,\n };\n}\n\nexport function loadConfig(): FarseerConfig {\n ensureConfigDir();\n\n if (!fs.existsSync(CONFIG_FILE)) {\n return getDefaultConfig();\n }\n\n try {\n const content = fs.readFileSync(CONFIG_FILE, 'utf-8');\n return JSON.parse(content) as FarseerConfig;\n } catch {\n return getDefaultConfig();\n }\n}\n\nexport function saveConfig(config: FarseerConfig): void {\n ensureConfigDir();\n fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), 'utf-8');\n}\n\nexport function getCredential(tenant: string): ApiKeyCredential | undefined {\n const config = loadConfig();\n return config.credentials[tenant];\n}\n\nexport function setCredential(tenant: string, credential: ApiKeyCredential): void {\n const config = loadConfig();\n config.credentials[tenant] = credential;\n saveConfig(config);\n}\n\nexport function removeCredential(tenant: string): boolean {\n const config = loadConfig();\n if (config.credentials[tenant]) {\n delete config.credentials[tenant];\n saveConfig(config);\n return true;\n }\n return false;\n}\n\nexport function listCredentials(): Record<string, ApiKeyCredential> {\n const config = loadConfig();\n return config.credentials;\n}\n\nexport function getUserAuth(): UserAuth | undefined {\n const config = loadConfig();\n return config.userAuth;\n}\n\nexport function setUserAuth(auth: UserAuth): void {\n const config = loadConfig();\n config.userAuth = auth;\n saveConfig(config);\n}\n\nexport function clearUserAuth(): void {\n const config = loadConfig();\n config.userAuth = undefined;\n saveConfig(config);\n}\n\nexport function isUserAuthValid(): boolean {\n const auth = getUserAuth();\n if (!auth) return false;\n\n const expiresAt = new Date(auth.expiresAt);\n // Add 10 second buffer to proactively refresh before actual expiry\n // Note: Keycloak tokens typically last 60 seconds, so buffer must be small\n const bufferMs = 10 * 1000;\n return expiresAt.getTime() > Date.now() + bufferMs;\n}\n\nexport function generateBasePath(organisation: string): string {\n return `https://${organisation}.farseer.io/api/v3`;\n}\n\n// Current checkout management\nexport function getCurrentCheckout(): CurrentCheckout | undefined {\n const config = loadConfig();\n // Support both new and old format\n if (config.currentCheckout) {\n return config.currentCheckout;\n }\n // Fallback to old format (tenant only, assume same as org)\n if (config.currentTenant) {\n return { organisation: config.currentTenant, tenant: config.currentTenant };\n }\n return undefined;\n}\n\nexport function getCurrentTenant(): string | undefined {\n const checkout = getCurrentCheckout();\n return checkout?.tenant;\n}\n\nexport function getCurrentOrganisation(): string | undefined {\n const checkout = getCurrentCheckout();\n return checkout?.organisation;\n}\n\nexport function setCurrentCheckout(organisation: string, tenant: string): void {\n const config = loadConfig();\n config.currentCheckout = { organisation, tenant };\n config.currentTenant = tenant; // Keep for backward compatibility\n saveConfig(config);\n}\n\nexport function setCurrentTenant(tenant: string): void {\n // Assume organisation = tenant when only tenant is specified\n setCurrentCheckout(tenant, tenant);\n}\n\nexport function clearCurrentTenant(): void {\n const config = loadConfig();\n config.currentTenant = undefined;\n config.currentCheckout = undefined;\n saveConfig(config);\n}\n\n// Tenant-Organisation mapping\nexport function saveTenantOrgMapping(tenant: string, organisation: string): void {\n const config = loadConfig();\n if (!config.tenantOrgMapping) {\n config.tenantOrgMapping = {};\n }\n config.tenantOrgMapping[tenant] = organisation;\n saveConfig(config);\n}\n\nexport function getT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,QAAsB;AAEnD,qBAAmB,QAAQ,MAAM;AACrC;AAEO,SAAS,qBAA2B;AACvC,QAAM,SAAS,WAAW;AAC1B,SAAO,gBAAgB;AACvB,SAAO,kBAAkB;AACzB,aAAW,MAAM;AACrB;AAGO,SAAS,qBAAqB,QAAgB,cAA4B;AAC7E,QAAM,SAAS,WAAW;AAC1B,MAAI,CAAC,OAAO,kBAAkB;AAC1B,WAAO,mBAAmB,CAAC;AAAA,EAC/B;AACA,SAAO,iBAAiB,MAAM,IAAI;AAClC,aAAW,MAAM;AACrB;AAEO,SAAS,aAAa,QAAoC;AAC7D,QAAM,SAAS,WAAW;AAC1B,SAAO,OAAO,mBAAmB,MAAM;AAC3C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -44,7 +45,7 @@ class FarseerApi {
|
|
|
44
45
|
this.client = import_axios.default.create({
|
|
45
46
|
baseURL: basePath,
|
|
46
47
|
headers: {
|
|
47
|
-
|
|
48
|
+
Authorization: `Bearer ${accessToken}`,
|
|
48
49
|
"Content-Type": "application/json",
|
|
49
50
|
"x-api-version": "3.3.0",
|
|
50
51
|
"X-TENANT-ID": this.tenantId
|
|
@@ -174,8 +175,10 @@ class FarseerApi {
|
|
|
174
175
|
console.error(`API Error: ${status} "${message}" (path: ${folderPath.join("/")})`);
|
|
175
176
|
if (data?.code === "Forbidden") {
|
|
176
177
|
const errorMessage = data?.message || "Access denied";
|
|
177
|
-
throw new Error(
|
|
178
|
-
|
|
178
|
+
throw new Error(
|
|
179
|
+
`Access denied: ${errorMessage}
|
|
180
|
+
You may need to use --tenant-id to specify a different tenant ID.`
|
|
181
|
+
);
|
|
179
182
|
}
|
|
180
183
|
}
|
|
181
184
|
return [];
|
|
@@ -222,7 +225,7 @@ You may need to use --tenant-id to specify a different tenant ID.`);
|
|
|
222
225
|
await this.client.delete(`/farseerFiles/${reference}`);
|
|
223
226
|
}
|
|
224
227
|
async ensureFolderPath(folderPath) {
|
|
225
|
-
|
|
228
|
+
const currentPath = [];
|
|
226
229
|
for (const segment of folderPath) {
|
|
227
230
|
currentPath.push(segment);
|
|
228
231
|
try {
|
|
@@ -264,7 +267,7 @@ You may need to use --tenant-id to specify a different tenant ID.`);
|
|
|
264
267
|
}
|
|
265
268
|
async getFileMetadata(reference) {
|
|
266
269
|
try {
|
|
267
|
-
const response = await this.
|
|
270
|
+
const response = await this.client.get(`/farseerFiles/${reference}/metadata`);
|
|
268
271
|
const data = response.data;
|
|
269
272
|
return {
|
|
270
273
|
uploadTime: data.uploadTime,
|
|
@@ -282,7 +285,9 @@ You may need to use --tenant-id to specify a different tenant ID.`);
|
|
|
282
285
|
}
|
|
283
286
|
isTextFile(filename) {
|
|
284
287
|
const ext = filename.toLowerCase().split(".").pop() || "";
|
|
285
|
-
return ["ts", "js", "mjs", "cjs", "json", "txt", "md", "csv", "xml", "html", "css", "yaml", "yml"].includes(
|
|
288
|
+
return ["ts", "js", "mjs", "cjs", "json", "txt", "md", "csv", "xml", "html", "css", "yaml", "yml"].includes(
|
|
289
|
+
ext
|
|
290
|
+
);
|
|
286
291
|
}
|
|
287
292
|
isBinaryFile(filename) {
|
|
288
293
|
return !this.isTextFile(filename);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/services/farseerApi.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * FarseerApi - Direct HTTP API client using JWT Bearer token authentication\n *\n * This is an alternative to FarseerService that doesn't use farseer-client library.\n * Use this when authenticating via browser login (Keycloak JWT token) instead of API key.\n */\n\nimport axios, { AxiosInstance, InternalAxiosRequestConfig } from 'axios';\nimport { getCredential, getUserAuth, setUserAuth } from './configService';\nimport { refreshAccessToken } from './farseerService';\n\nexport interface RemoteFile {\n name: string;\n path: string;\n reference: string;\n}\n\ninterface FolderItem {\n id: number;\n name: string;\n type: 'folder' | 'farseer-file';\n reference?: string;\n}\n\ninterface FolderContent {\n items: FolderItem[];\n}\n\n// App (Remote Job) types\nexport interface AppArgument {\n name: string;\n type: 'variable';\n defaultValue: string;\n}\n\nexport interface AppScriptFile {\n id: string;\n name: string;\n}\n\nexport interface RemoteApp {\n id: number;\n name: string;\n description: string;\n expectedArguments: AppArgument[];\n status: string;\n lastHeartbeat: string;\n mainScriptFileId: string | null;\n scriptFiles: AppScriptFile[];\n creationType: string;\n predefinedActions: unknown[];\n}\n\nexport interface AppListItem {\n id: number;\n name: string;\n type: string;\n reference: string;\n}\n\nexport class FarseerApi {\n private client: AxiosInstance;\n private tenant: string;\n private tenantId: string;\n\n private isRefreshing = false;\n private refreshSubscribers: ((token: string) => void)[] = [];\n\n constructor(accessToken: string, tenant: string, tenantId?: string) {\n this.tenant = tenant;\n this.tenantId = tenantId || tenant;\n\n // Try to get basePath from existing config, or generate from tenant name\n const credential = getCredential(tenant);\n const basePath = credential?.basePath || `https://${tenant}.farseer.io/api/v3`;\n\n this.client = axios.create({\n baseURL: basePath,\n headers: {\n 'Authorization': `Bearer ${accessToken}`,\n 'Content-Type': 'application/json',\n 'x-api-version': '3.3.0',\n 'X-TENANT-ID': this.tenantId,\n },\n });\n\n // Add response interceptor for automatic token refresh on 401\n this.client.interceptors.response.use(\n (response) => response,\n async (error) => {\n const originalRequest = error.config as InternalAxiosRequestConfig & { _retry?: boolean };\n\n // Only handle 401 errors and avoid infinite loops\n if (error.response?.status === 401 && !originalRequest._retry) {\n originalRequest._retry = true;\n\n // If already refreshing, wait for the new token\n if (this.isRefreshing) {\n return new Promise((resolve) => {\n this.refreshSubscribers.push((token: string) => {\n originalRequest.headers['Authorization'] = `Bearer ${token}`;\n resolve(this.client(originalRequest));\n });\n });\n }\n\n this.isRefreshing = true;\n\n try {\n const auth = getUserAuth();\n if (!auth?.refreshToken) {\n throw new Error('No refresh token available');\n }\n\n const refreshed = await refreshAccessToken(auth.refreshToken, auth.realm || 'master');\n if (!refreshed) {\n throw new Error('Token refresh failed');\n }\n\n // Save the new token\n setUserAuth({\n accessToken: refreshed.accessToken,\n refreshToken: refreshed.refreshToken,\n expiresAt: new Date(Date.now() + refreshed.expiresIn * 1000).toISOString(),\n realm: auth.realm,\n });\n\n // Update this client's token\n this.updateAccessToken(refreshed.accessToken);\n\n // Notify all waiting requests\n this.refreshSubscribers.forEach((callback) => callback(refreshed.accessToken));\n this.refreshSubscribers = [];\n\n // Retry the original request\n originalRequest.headers['Authorization'] = `Bearer ${refreshed.accessToken}`;\n return this.client(originalRequest);\n } catch (refreshError) {\n // Token refresh failed - let the error propagate\n this.refreshSubscribers = [];\n throw error;\n } finally {\n this.isRefreshing = false;\n }\n }\n\n return Promise.reject(error);\n }\n );\n }\n\n /**\n * Update the access token (used when token is refreshed)\n */\n updateAccessToken(newToken: string): void {\n this.client.defaults.headers['Authorization'] = `Bearer ${newToken}`;\n }\n\n async testConnection(): Promise<boolean> {\n try {\n await this.getItemByPath(['Files']);\n return true;\n } catch {\n return false;\n }\n }\n\n async getFilesFolder(): Promise<{ id: number; name: string; type: string } | null> {\n try {\n const item = await this.getItemByPath(['Files']);\n return {\n id: item.id,\n name: item.name,\n type: item.type,\n };\n } catch {\n return null;\n }\n }\n\n private async listFolderItems(folderId: number | null): Promise<FolderContent> {\n // Body is array: [{ id: null }] for root, [{ id: folderId }] for specific folder\n const response = await this.client.post('/folders/items', [{ id: folderId }]);\n return response.data[0] || { items: [] };\n }\n\n private async findFolderByName(parentId: number | null, name: string): Promise<FolderItem | null> {\n const content = await this.listFolderItems(parentId);\n const folder = content.items?.find(\n (item) => item.name.toLowerCase() === name.toLowerCase() && item.type.toLowerCase() === 'folder'\n );\n return folder || null;\n }\n\n private async getItemByPath(path: string[]): Promise<FolderItem> {\n let currentId: number | null = null;\n\n for (const segment of path) {\n const folder = await this.findFolderByName(currentId, segment);\n if (!folder) {\n throw new Error(`Folder not found: ${segment}`);\n }\n currentId = folder.id;\n }\n\n if (currentId === null) {\n throw new Error('Path is empty');\n }\n\n // Return a minimal FolderItem with the found id\n return { id: currentId, name: path[path.length - 1], type: 'folder' };\n }\n\n async listFiles(folderPath: string[] = ['Files']): Promise<RemoteFile[]> {\n const files: RemoteFile[] = [];\n\n try {\n const folder = await this.getItemByPath(folderPath);\n const folderContent = await this.listFolderItems(folder.id);\n\n for (const item of folderContent.items || []) {\n const itemPath = [...folderPath.slice(1), item.name].join('/');\n const itemType = item.type.toLowerCase();\n\n if (itemType === 'folder') {\n const subFiles = await this.listFiles([...folderPath, item.name]);\n files.push(...subFiles);\n } else if ((itemType === 'farseer-file' || itemType === 'farseer_file') && item.reference) {\n files.push({\n name: item.name,\n path: itemPath,\n reference: item.reference,\n });\n }\n }\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const status = error.response?.status;\n const data = error.response?.data;\n const message = typeof data === 'string' ? data : (data?.message || JSON.stringify(data));\n console.error(`API Error: ${status} \"${message}\" (path: ${folderPath.join('/')})`);\n if (data?.code === 'Forbidden') {\n const errorMessage = data?.message || 'Access denied';\n throw new Error(`Access denied: ${errorMessage}\\nYou may need to use --tenant-id to specify a different tenant ID.`);\n }\n }\n return [];\n }\n\n return files;\n }\n\n async getFileContent(reference: string): Promise<string> {\n const response = await this.client.get(`/farseerFiles/${reference}`, {\n responseType: 'text',\n });\n return response.data;\n }\n\n async getFileContentAsBuffer(reference: string): Promise<Buffer> {\n const response = await this.client.get(`/farseerFiles/${reference}`, {\n responseType: 'arraybuffer',\n });\n return Buffer.from(response.data);\n }\n\n async createFile(content: string | Buffer, fileName: string, folderPath: string[] = ['Files']): Promise<void> {\n await this.ensureFolderPath(folderPath);\n\n const folder = await this.getItemByPath(folderPath);\n\n const formData = new FormData();\n const blob = content instanceof Buffer ? new Blob([content]) : new Blob([content]);\n formData.append('file', blob, fileName);\n formData.append('category', 'GENERAL');\n formData.append('folderId', folder.id.toString());\n\n await this.client.post('/farseerFiles', formData, {\n headers: {\n 'Content-Type': 'multipart/form-data',\n },\n });\n }\n\n async updateFile(reference: string, content: string | Buffer, fileName: string): Promise<void> {\n const formData = new FormData();\n const blob = content instanceof Buffer ? new Blob([content]) : new Blob([content]);\n formData.append('file', blob, fileName);\n\n await this.client.put(`/farseerFiles/${reference}`, formData, {\n headers: {\n 'Content-Type': 'multipart/form-data',\n },\n });\n }\n\n async deleteFile(reference: string): Promise<void> {\n await this.client.delete(`/farseerFiles/${reference}`);\n }\n\n private async ensureFolderPath(folderPath: string[]): Promise<void> {\n let currentPath: string[] = [];\n\n for (const segment of folderPath) {\n currentPath.push(segment);\n try {\n await this.getItemByPath(currentPath);\n } catch {\n if (currentPath.length > 1) {\n const parentPath = currentPath.slice(0, -1);\n const parent = await this.getItemByPath(parentPath);\n await this.client.post('/folders', {\n parentId: parent.id,\n name: segment,\n allowedTypes: [],\n });\n }\n }\n }\n }\n\n async getFileByPath(filePath: string): Promise<RemoteFile | null> {\n const pathParts = ['Files', ...filePath.split('/')];\n const fileName = pathParts.pop()!;\n const folderPath = pathParts;\n\n try {\n const folder = await this.getItemByPath(folderPath);\n const folderContent = await this.listFolderItems(folder.id);\n\n for (const item of folderContent.items || []) {\n const itemType = item.type.toLowerCase();\n if (item.name === fileName && (itemType === 'farseer-file' || itemType === 'farseer_file') && item.reference) {\n return {\n name: item.name,\n path: filePath,\n reference: item.reference,\n };\n }\n }\n } catch {\n return null;\n }\n\n return null;\n }\n\n async getFileMetadata(reference: string): Promise<import('./farseerFactory').FileMetadata | null> {\n try {\n const response = await this.axios.get(`/farseerFiles/${reference}/metadata`);\n const data = response.data;\n\n return {\n uploadTime: data.uploadTime,\n uploader: data.uploader ? {\n id: data.uploader.id,\n email: data.uploader.email || '',\n firstName: data.uploader.firstName || '',\n lastName: data.uploader.lastName || '',\n } : undefined,\n size: data.size,\n };\n } catch (error) {\n // Metadata fetch failed - non-critical, continue without it\n return null;\n }\n }\n\n isTextFile(filename: string): boolean {\n const ext = filename.toLowerCase().split('.').pop() || '';\n return ['ts', 'js', 'mjs', 'cjs', 'json', 'txt', 'md', 'csv', 'xml', 'html', 'css', 'yaml', 'yml'].includes(ext);\n }\n\n isBinaryFile(filename: string): boolean {\n return !this.isTextFile(filename);\n }\n\n // ==================== Apps (Remote Jobs) API ====================\n\n /**\n * Get the Apps folder ID\n */\n async getAppsFolderId(): Promise<number | null> {\n const content = await this.listFolderItems(null);\n const appsFolder = content.items?.find(\n (item) => item.name.toLowerCase() === 'apps' && item.type.toLowerCase() === 'folder'\n );\n return appsFolder?.id || null;\n }\n\n /**\n * List all apps (Remote Jobs) on the tenant, including those in subfolders\n */\n async listApps(): Promise<AppListItem[]> {\n const appsFolderId = await this.getAppsFolderId();\n if (!appsFolderId) {\n return [];\n }\n\n return this.listAppsRecursive(appsFolderId);\n }\n\n /**\n * Recursively list all apps in a folder and its subfolders\n */\n private async listAppsRecursive(folderId: number): Promise<AppListItem[]> {\n const apps: AppListItem[] = [];\n const content = await this.listFolderItems(folderId);\n\n for (const item of content.items || []) {\n const itemType = item.type.toLowerCase();\n\n if (itemType === 'remote_job') {\n // Found an app\n apps.push({\n id: item.id,\n name: item.name,\n type: item.type,\n reference: item.reference || '',\n });\n } else if (itemType === 'folder') {\n // Recurse into subfolder\n const subApps = await this.listAppsRecursive(item.id);\n apps.push(...subApps);\n }\n }\n\n return apps;\n }\n\n /**\n * Get app details by reference ID\n */\n async getApp(referenceId: string): Promise<RemoteApp | null> {\n try {\n const response = await this.client.get(`/remoteJobs/${referenceId}`);\n return response.data;\n } catch {\n return null;\n }\n }\n\n /**\n * Get app by name\n */\n async getAppByName(name: string): Promise<RemoteApp | null> {\n const apps = await this.listApps();\n const app = apps.find((a) => a.name.toLowerCase() === name.toLowerCase());\n if (!app) {\n return null;\n }\n return this.getApp(app.reference);\n }\n\n /**\n * Create a new app\n */\n async createApp(name: string): Promise<RemoteApp> {\n const appsFolderId = await this.getAppsFolderId();\n if (!appsFolderId) {\n throw new Error('Apps folder not found');\n }\n\n const response = await this.client.post('/remoteJobs', {\n folderId: appsFolderId,\n name,\n });\n return response.data;\n }\n\n /**\n * Update an app\n */\n async updateApp(\n referenceId: string,\n update: {\n name?: string;\n description?: string;\n expectedArguments?: AppArgument[];\n mainScriptFileId?: string | null;\n scriptFileIds?: string[];\n }\n ): Promise<RemoteApp> {\n await this.client.put(`/remoteJobs/${referenceId}`, {\n ...update,\n schedule: null,\n runnerName: null,\n predefinedActions: [],\n });\n // API returns 204 No Content, so fetch the updated app\n const app = await this.getApp(referenceId);\n if (!app) {\n throw new Error('Failed to fetch updated app');\n }\n return app;\n }\n\n /**\n * Delete an app\n */\n async deleteApp(referenceId: string): Promise<void> {\n await this.client.delete(`/remoteJobs/${referenceId}`);\n }\n\n /**\n * Run an app with arguments\n */\n async runApp(\n referenceId: string,\n args: Record<string, string> = {}\n ): Promise<{ executionId: string }> {\n const response = await this.client.post(`/remoteJobs/${referenceId}/run`, {\n arguments: args,\n });\n return response.data;\n }\n\n /**\n * Get script files available for apps (searches all .ts/.js files in Files folder)\n * Returns full path relative to Files/ folder (e.g., \"Scripts/test.ts\", \"Scripts/subfolder/helper.ts\")\n */\n async getScriptFiles(): Promise<AppScriptFile[]> {\n // listFiles already searches recursively, so just filter for .ts/.js files\n const allFiles = await this.listFiles(['Files']);\n return allFiles\n .filter(f => f.name.endsWith('.ts') || f.name.endsWith('.js'))\n .map(f => ({\n id: f.reference,\n name: f.path, // Use full path to support scripts in subfolders\n }));\n }\n\n // ==================== Model Export API ====================\n\n /**\n * Export the entire model structure - all dimension tables, variables, and configurations.\n * Essential for understanding a tenant's data model.\n */\n async exportModel(): Promise<ModelExport> {\n const response = await this.client.post('/model/export');\n return response.data;\n }\n}\n\n// Model Export types\nexport interface ModelExport {\n tables: ModelExportTable[];\n variables: ModelExportVariable[];\n dependencies: {\n tables: string[];\n members: string[];\n variables: string[];\n };\n}\n\nexport interface ModelExportTable {\n name: string;\n columns: ModelExportColumn[];\n defaultMember?: string | null;\n folderPath?: string[];\n rows: any[][];\n autoIncrementTemplate?: string | null;\n}\n\nexport interface ModelExportColumn {\n name?: string;\n type: string; // PRIMARY_KEY, FORMULA, ORDER, ACTIVE, DESCRIPTION, FOREIGN_KEY, NUMBER, TEXT, DATE, FILE\n foreignKeyTableName?: string;\n}\n\nexport interface ModelExportVariable {\n name: string;\n description?: string | null;\n formula?: string | null;\n tables: string[];\n members: string[];\n rollupType: string; // SUM, AVERAGE, CLOSING STATE, BEGINNING STATE, FORMULA, MAX, MIN\n dataType: string; // DECIMAL, INTEGER\n numberFormat?: {\n type: string; // NUMBER, CURRENCY, PERCENTAGE, DATE, CUSTOM\n custom?: boolean;\n formatString?: string;\n decimals?: number;\n };\n numberValidation?: {\n min?: number | null;\n max?: number | null;\n };\n topDownMapping?: string | null;\n readonly: boolean;\n calculateOnDemand: boolean;\n zConstraint?: boolean;\n active?: boolean;\n optimizeCalculation?: boolean;\n useHierarchy?: boolean;\n folderPath?: string[];\n cells?: ModelExportCell[];\n}\n\nexport interface ModelExportCell {\n value: number;\n members: string[];\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * FarseerApi - Direct HTTP API client using JWT Bearer token authentication\n *\n * This is an alternative to FarseerService that doesn't use farseer-client library.\n * Use this when authenticating via browser login (Keycloak JWT token) instead of API key.\n */\n\nimport axios, { AxiosInstance, InternalAxiosRequestConfig } from 'axios';\nimport { getCredential, getUserAuth, setUserAuth } from './configService';\nimport { refreshAccessToken } from './farseerService';\n\nexport interface RemoteFile {\n name: string;\n path: string;\n reference: string;\n}\n\ninterface FolderItem {\n id: number;\n name: string;\n type: 'folder' | 'farseer-file';\n reference?: string;\n}\n\ninterface FolderContent {\n items: FolderItem[];\n}\n\n// App (Remote Job) types\nexport interface AppArgument {\n name: string;\n type: 'variable';\n defaultValue: string;\n}\n\nexport interface AppScriptFile {\n id: string;\n name: string;\n}\n\nexport interface RemoteApp {\n id: number;\n name: string;\n description: string;\n expectedArguments: AppArgument[];\n status: string;\n lastHeartbeat: string;\n mainScriptFileId: string | null;\n scriptFiles?: AppScriptFile[];\n sourceFolderId?: number;\n creationType: string;\n predefinedActions: unknown[];\n}\n\nexport interface AppListItem {\n id: number;\n name: string;\n type: string;\n reference: string;\n}\n\nexport class FarseerApi {\n private client: AxiosInstance;\n private tenant: string;\n private tenantId: string;\n\n private isRefreshing = false;\n private refreshSubscribers: ((token: string) => void)[] = [];\n\n constructor(accessToken: string, tenant: string, tenantId?: string) {\n this.tenant = tenant;\n this.tenantId = tenantId || tenant;\n\n // Try to get basePath from existing config, or generate from tenant name\n const credential = getCredential(tenant);\n const basePath = credential?.basePath || `https://${tenant}.farseer.io/api/v3`;\n\n this.client = axios.create({\n baseURL: basePath,\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'Content-Type': 'application/json',\n 'x-api-version': '3.3.0',\n 'X-TENANT-ID': this.tenantId,\n },\n });\n\n // Add response interceptor for automatic token refresh on 401\n this.client.interceptors.response.use(\n (response) => response,\n async (error) => {\n const originalRequest = error.config as InternalAxiosRequestConfig & { _retry?: boolean };\n\n // Only handle 401 errors and avoid infinite loops\n if (error.response?.status === 401 && !originalRequest._retry) {\n originalRequest._retry = true;\n\n // If already refreshing, wait for the new token\n if (this.isRefreshing) {\n return new Promise((resolve) => {\n this.refreshSubscribers.push((token: string) => {\n originalRequest.headers['Authorization'] = `Bearer ${token}`;\n resolve(this.client(originalRequest));\n });\n });\n }\n\n this.isRefreshing = true;\n\n try {\n const auth = getUserAuth();\n if (!auth?.refreshToken) {\n throw new Error('No refresh token available');\n }\n\n const refreshed = await refreshAccessToken(auth.refreshToken, auth.realm || 'master');\n if (!refreshed) {\n throw new Error('Token refresh failed');\n }\n\n // Save the new token\n setUserAuth({\n accessToken: refreshed.accessToken,\n refreshToken: refreshed.refreshToken,\n expiresAt: new Date(Date.now() + refreshed.expiresIn * 1000).toISOString(),\n realm: auth.realm,\n });\n\n // Update this client's token\n this.updateAccessToken(refreshed.accessToken);\n\n // Notify all waiting requests\n this.refreshSubscribers.forEach((callback) => callback(refreshed.accessToken));\n this.refreshSubscribers = [];\n\n // Retry the original request\n originalRequest.headers['Authorization'] = `Bearer ${refreshed.accessToken}`;\n return this.client(originalRequest);\n } catch (refreshError) {\n // Token refresh failed - let the error propagate\n this.refreshSubscribers = [];\n throw error;\n } finally {\n this.isRefreshing = false;\n }\n }\n\n return Promise.reject(error);\n },\n );\n }\n\n /**\n * Update the access token (used when token is refreshed)\n */\n updateAccessToken(newToken: string): void {\n this.client.defaults.headers['Authorization'] = `Bearer ${newToken}`;\n }\n\n async testConnection(): Promise<boolean> {\n try {\n await this.getItemByPath(['Files']);\n return true;\n } catch {\n return false;\n }\n }\n\n async getFilesFolder(): Promise<{ id: number; name: string; type: string } | null> {\n try {\n const item = await this.getItemByPath(['Files']);\n return {\n id: item.id,\n name: item.name,\n type: item.type,\n };\n } catch {\n return null;\n }\n }\n\n private async listFolderItems(folderId: number | null): Promise<FolderContent> {\n // Body is array: [{ id: null }] for root, [{ id: folderId }] for specific folder\n const response = await this.client.post('/folders/items', [{ id: folderId }]);\n return response.data[0] || { items: [] };\n }\n\n private async findFolderByName(parentId: number | null, name: string): Promise<FolderItem | null> {\n const content = await this.listFolderItems(parentId);\n const folder = content.items?.find(\n (item) => item.name.toLowerCase() === name.toLowerCase() && item.type.toLowerCase() === 'folder',\n );\n return folder || null;\n }\n\n private async getItemByPath(path: string[]): Promise<FolderItem> {\n let currentId: number | null = null;\n\n for (const segment of path) {\n const folder = await this.findFolderByName(currentId, segment);\n if (!folder) {\n throw new Error(`Folder not found: ${segment}`);\n }\n currentId = folder.id;\n }\n\n if (currentId === null) {\n throw new Error('Path is empty');\n }\n\n // Return a minimal FolderItem with the found id\n return { id: currentId, name: path[path.length - 1], type: 'folder' };\n }\n\n async listFiles(folderPath: string[] = ['Files']): Promise<RemoteFile[]> {\n const files: RemoteFile[] = [];\n\n try {\n const folder = await this.getItemByPath(folderPath);\n const folderContent = await this.listFolderItems(folder.id);\n\n for (const item of folderContent.items || []) {\n const itemPath = [...folderPath.slice(1), item.name].join('/');\n const itemType = item.type.toLowerCase();\n\n if (itemType === 'folder') {\n const subFiles = await this.listFiles([...folderPath, item.name]);\n files.push(...subFiles);\n } else if ((itemType === 'farseer-file' || itemType === 'farseer_file') && item.reference) {\n files.push({\n name: item.name,\n path: itemPath,\n reference: item.reference,\n });\n }\n }\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const status = error.response?.status;\n const data = error.response?.data;\n const message = typeof data === 'string' ? data : data?.message || JSON.stringify(data);\n console.error(`API Error: ${status} \"${message}\" (path: ${folderPath.join('/')})`);\n if (data?.code === 'Forbidden') {\n const errorMessage = data?.message || 'Access denied';\n throw new Error(\n `Access denied: ${errorMessage}\\nYou may need to use --tenant-id to specify a different tenant ID.`,\n );\n }\n }\n return [];\n }\n\n return files;\n }\n\n async getFileContent(reference: string): Promise<string> {\n const response = await this.client.get(`/farseerFiles/${reference}`, {\n responseType: 'text',\n });\n return response.data;\n }\n\n async getFileContentAsBuffer(reference: string): Promise<Buffer> {\n const response = await this.client.get(`/farseerFiles/${reference}`, {\n responseType: 'arraybuffer',\n });\n return Buffer.from(response.data);\n }\n\n async createFile(content: string | Buffer, fileName: string, folderPath: string[] = ['Files']): Promise<void> {\n await this.ensureFolderPath(folderPath);\n\n const folder = await this.getItemByPath(folderPath);\n\n const formData = new FormData();\n const blob = content instanceof Buffer ? new Blob([content]) : new Blob([content]);\n formData.append('file', blob, fileName);\n formData.append('category', 'GENERAL');\n formData.append('folderId', folder.id.toString());\n\n await this.client.post('/farseerFiles', formData, {\n headers: {\n 'Content-Type': 'multipart/form-data',\n },\n });\n }\n\n async updateFile(reference: string, content: string | Buffer, fileName: string): Promise<void> {\n const formData = new FormData();\n const blob = content instanceof Buffer ? new Blob([content]) : new Blob([content]);\n formData.append('file', blob, fileName);\n\n await this.client.put(`/farseerFiles/${reference}`, formData, {\n headers: {\n 'Content-Type': 'multipart/form-data',\n },\n });\n }\n\n async deleteFile(reference: string): Promise<void> {\n await this.client.delete(`/farseerFiles/${reference}`);\n }\n\n private async ensureFolderPath(folderPath: string[]): Promise<void> {\n const currentPath: string[] = [];\n\n for (const segment of folderPath) {\n currentPath.push(segment);\n try {\n await this.getItemByPath(currentPath);\n } catch {\n if (currentPath.length > 1) {\n const parentPath = currentPath.slice(0, -1);\n const parent = await this.getItemByPath(parentPath);\n await this.client.post('/folders', {\n parentId: parent.id,\n name: segment,\n allowedTypes: [],\n });\n }\n }\n }\n }\n\n async getFileByPath(filePath: string): Promise<RemoteFile | null> {\n const pathParts = ['Files', ...filePath.split('/')];\n const fileName = pathParts.pop()!;\n const folderPath = pathParts;\n\n try {\n const folder = await this.getItemByPath(folderPath);\n const folderContent = await this.listFolderItems(folder.id);\n\n for (const item of folderContent.items || []) {\n const itemType = item.type.toLowerCase();\n if (\n item.name === fileName &&\n (itemType === 'farseer-file' || itemType === 'farseer_file') &&\n item.reference\n ) {\n return {\n name: item.name,\n path: filePath,\n reference: item.reference,\n };\n }\n }\n } catch {\n return null;\n }\n\n return null;\n }\n\n async getFileMetadata(reference: string): Promise<import('./farseerFactory').FileMetadata | null> {\n try {\n const response = await this.client.get(`/farseerFiles/${reference}/metadata`);\n const data = response.data;\n\n return {\n uploadTime: data.uploadTime,\n uploader: data.uploader\n ? {\n id: data.uploader.id,\n email: data.uploader.email || '',\n firstName: data.uploader.firstName || '',\n lastName: data.uploader.lastName || '',\n }\n : undefined,\n size: data.size,\n };\n } catch (error) {\n // Metadata fetch failed - non-critical, continue without it\n return null;\n }\n }\n\n isTextFile(filename: string): boolean {\n const ext = filename.toLowerCase().split('.').pop() || '';\n return ['ts', 'js', 'mjs', 'cjs', 'json', 'txt', 'md', 'csv', 'xml', 'html', 'css', 'yaml', 'yml'].includes(\n ext,\n );\n }\n\n isBinaryFile(filename: string): boolean {\n return !this.isTextFile(filename);\n }\n\n // ==================== Apps (Remote Jobs) API ====================\n\n /**\n * Get the Apps folder ID\n */\n async getAppsFolderId(): Promise<number | null> {\n const content = await this.listFolderItems(null);\n const appsFolder = content.items?.find(\n (item) => item.name.toLowerCase() === 'apps' && item.type.toLowerCase() === 'folder',\n );\n return appsFolder?.id || null;\n }\n\n /**\n * List all apps (Remote Jobs) on the tenant, including those in subfolders\n */\n async listApps(): Promise<AppListItem[]> {\n const appsFolderId = await this.getAppsFolderId();\n if (!appsFolderId) {\n return [];\n }\n\n return this.listAppsRecursive(appsFolderId);\n }\n\n /**\n * Recursively list all apps in a folder and its subfolders\n */\n private async listAppsRecursive(folderId: number): Promise<AppListItem[]> {\n const apps: AppListItem[] = [];\n const content = await this.listFolderItems(folderId);\n\n for (const item of content.items || []) {\n const itemType = item.type.toLowerCase();\n\n if (itemType === 'remote_job') {\n // Found an app\n apps.push({\n id: item.id,\n name: item.name,\n type: item.type,\n reference: item.reference || '',\n });\n } else if (itemType === 'folder') {\n // Recurse into subfolder\n const subApps = await this.listAppsRecursive(item.id);\n apps.push(...subApps);\n }\n }\n\n return apps;\n }\n\n /**\n * Get app details by reference ID\n */\n async getApp(referenceId: string): Promise<RemoteApp | null> {\n try {\n const response = await this.client.get(`/remoteJobs/${referenceId}`);\n return response.data;\n } catch {\n return null;\n }\n }\n\n /**\n * Get app by name\n */\n async getAppByName(name: string): Promise<RemoteApp | null> {\n const apps = await this.listApps();\n const app = apps.find((a) => a.name.toLowerCase() === name.toLowerCase());\n if (!app) {\n return null;\n }\n return this.getApp(app.reference);\n }\n\n /**\n * Create a new app\n */\n async createApp(name: string): Promise<RemoteApp> {\n const appsFolderId = await this.getAppsFolderId();\n if (!appsFolderId) {\n throw new Error('Apps folder not found');\n }\n\n const response = await this.client.post('/remoteJobs', {\n folderId: appsFolderId,\n name,\n });\n return response.data;\n }\n\n /**\n * Update an app\n */\n async updateApp(\n referenceId: string,\n update: {\n name?: string;\n description?: string;\n expectedArguments?: AppArgument[];\n mainScriptFileId?: string | null;\n scriptFileIds?: string[];\n },\n ): Promise<RemoteApp> {\n await this.client.put(`/remoteJobs/${referenceId}`, {\n ...update,\n schedule: null,\n runnerName: null,\n predefinedActions: [],\n });\n // API returns 204 No Content, so fetch the updated app\n const app = await this.getApp(referenceId);\n if (!app) {\n throw new Error('Failed to fetch updated app');\n }\n return app;\n }\n\n /**\n * Delete an app\n */\n async deleteApp(referenceId: string): Promise<void> {\n await this.client.delete(`/remoteJobs/${referenceId}`);\n }\n\n /**\n * Run an app with arguments\n */\n async runApp(referenceId: string, args: Record<string, string> = {}): Promise<{ executionId: string }> {\n const response = await this.client.post(`/remoteJobs/${referenceId}/run`, {\n arguments: args,\n });\n return response.data;\n }\n\n /**\n * Get script files available for apps (searches all .ts/.js files in Files folder)\n * Returns full path relative to Files/ folder (e.g., \"Scripts/test.ts\", \"Scripts/subfolder/helper.ts\")\n */\n async getScriptFiles(): Promise<AppScriptFile[]> {\n // listFiles already searches recursively, so just filter for .ts/.js files\n const allFiles = await this.listFiles(['Files']);\n return allFiles\n .filter((f) => f.name.endsWith('.ts') || f.name.endsWith('.js'))\n .map((f) => ({\n id: f.reference,\n name: f.path, // Use full path to support scripts in subfolders\n }));\n }\n\n // ==================== Model Export API ====================\n\n /**\n * Export the entire model structure - all dimension tables, variables, and configurations.\n * Essential for understanding a tenant's data model.\n */\n async exportModel(): Promise<ModelExport> {\n const response = await this.client.post('/model/export');\n return response.data;\n }\n}\n\n// Model Export types\nexport interface ModelExport {\n tables: ModelExportTable[];\n variables: ModelExportVariable[];\n dependencies: {\n tables: string[];\n members: string[];\n variables: string[];\n };\n}\n\nexport interface ModelExportTable {\n name: string;\n columns: ModelExportColumn[];\n defaultMember?: string | null;\n folderPath?: string[];\n rows: any[][];\n autoIncrementTemplate?: string | null;\n}\n\nexport interface ModelExportColumn {\n name?: string;\n type: string; // PRIMARY_KEY, FORMULA, ORDER, ACTIVE, DESCRIPTION, FOREIGN_KEY, NUMBER, TEXT, DATE, FILE\n foreignKeyTableName?: string;\n}\n\nexport interface ModelExportVariable {\n name: string;\n description?: string | null;\n formula?: string | null;\n tables: string[];\n members: string[];\n rollupType: string; // SUM, AVERAGE, CLOSING STATE, BEGINNING STATE, FORMULA, MAX, MIN\n dataType: string; // DECIMAL, INTEGER\n numberFormat?: {\n type: string; // NUMBER, CURRENCY, PERCENTAGE, DATE, CUSTOM\n custom?: boolean;\n formatString?: string;\n decimals?: number;\n };\n numberValidation?: {\n min?: number | null;\n max?: number | null;\n };\n topDownMapping?: string | null;\n readonly: boolean;\n calculateOnDemand: boolean;\n zConstraint?: boolean;\n active?: boolean;\n optimizeCalculation?: boolean;\n useHierarchy?: boolean;\n folderPath?: string[];\n cells?: ModelExportCell[];\n}\n\nexport interface ModelExportCell {\n value: number;\n members: string[];\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,mBAAiE;AACjE,2BAAwD;AACxD,4BAAmC;AAoD5B,MAAM,WAAW;AAAA,EAQpB,YAAY,aAAqB,QAAgB,UAAmB;AAHpE,SAAQ,eAAe;AACvB,SAAQ,qBAAkD,CAAC;AAGvD,SAAK,SAAS;AACd,SAAK,WAAW,YAAY;AAG5B,UAAM,iBAAa,oCAAc,MAAM;AACvC,UAAM,WAAW,YAAY,YAAY,WAAW,MAAM;AAE1D,SAAK,SAAS,aAAAA,QAAM,OAAO;AAAA,MACvB,SAAS;AAAA,MACT,SAAS;AAAA,QACL,eAAe,UAAU,WAAW;AAAA,QACpC,gBAAgB;AAAA,QAChB,iBAAiB;AAAA,QACjB,eAAe,KAAK;AAAA,MACxB;AAAA,IACJ,CAAC;AAGD,SAAK,OAAO,aAAa,SAAS;AAAA,MAC9B,CAAC,aAAa;AAAA,MACd,OAAO,UAAU;AACb,cAAM,kBAAkB,MAAM;AAG9B,YAAI,MAAM,UAAU,WAAW,OAAO,CAAC,gBAAgB,QAAQ;AAC3D,0BAAgB,SAAS;AAGzB,cAAI,KAAK,cAAc;A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IAAI,MAAM,6BAA6B;AAAA,IACjD;AACA,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAU,aAAoC;AAChD,UAAM,KAAK,OAAO,OAAO,eAAe,WAAW,EAAE;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAO,aAAqB,OAA+B,CAAC,GAAqC;AACnG,UAAM,WAAW,MAAM,KAAK,OAAO,KAAK,eAAe,WAAW,QAAQ;AAAA,MACtE,WAAW;AAAA,IACf,CAAC;AACD,WAAO,SAAS;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,iBAA2C;AAE7C,UAAM,WAAW,MAAM,KAAK,UAAU,CAAC,OAAO,CAAC;AAC/C,WAAO,SACF,OAAO,CAAC,MAAM,EAAE,KAAK,SAAS,KAAK,KAAK,EAAE,KAAK,SAAS,KAAK,CAAC,EAC9D,IAAI,CAAC,OAAO;AAAA,MACT,IAAI,EAAE;AAAA,MACN,MAAM,EAAE;AAAA;AAAA,IACZ,EAAE;AAAA,EACV;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,cAAoC;AACtC,UAAM,WAAW,MAAM,KAAK,OAAO,KAAK,eAAe;AACvD,WAAO,SAAS;AAAA,EACpB;AACJ;",
|
|
6
6
|
"names": ["axios"]
|
|
7
7
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -200,7 +201,7 @@ async function getNativeFarseerClient(organisation, tenant) {
|
|
|
200
201
|
basePath,
|
|
201
202
|
headers: {
|
|
202
203
|
"X-TENANT-ID": tenant,
|
|
203
|
-
|
|
204
|
+
Authorization: `Bearer ${accessToken}`
|
|
204
205
|
}
|
|
205
206
|
});
|
|
206
207
|
}
|