farseer-cli 1.0.4 → 1.0.6

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/commands/push.ts"],
4
- "sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport inquirer from 'inquirer';\nimport { logger } from '../utils/logger';\nimport { getFarseerClientWithFallback, showLoginPrompt, ensureFreshToken } from '../services/farseerFactory';\nimport { SyncService } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport { GitService } from '../services/gitService';\nimport { getTenantFilesDir, resolveTenantWithOrgMapping, isInRemotejobsRepo } from '../utils/helpers';\nimport { CLI_GIT_AUTHOR } from '../utils/constants';\nimport * as fs from 'fs';\n\nexport function registerPushCommand(program: Command): void {\n program\n .command('push [arg1] [arg2]')\n .description('Push local files to Farseer instance\\n\\nUsage: push <org> <tenant> OR push <tenant> (if org is known)')\n .option('--git', 'Enable git operations (commit & push) - internal use only')\n .option('-m, --message <message>', 'Commit message (required when using --git)')\n .option('--force', 'Force push even if remote has changes')\n .action(async (arg1, arg2, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(arg1, arg2);\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!clientResult) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const filesDir = getTenantFilesDir(tenant);\n\n if (!fs.existsSync(filesDir)) {\n logger.error(`Local folder not found: apps/${tenant}/files/`);\n logger.dim('Run \"farseer pull <tenant>\" first to initialize the folder.');\n process.exit(1);\n }\n\n // Git operations are opt-in with --git flag (internal developer feature)\n const inRemotejobsRepo = isInRemotejobsRepo();\n const gitDisabledByEnv = !!process.env.FARSEER_NO_GIT;\n\n // Git enabled ONLY if:\n // 1. User explicitly requested it (--git flag)\n // 2. We're in remotejobs repo (safety check)\n // 3. FARSEER_NO_GIT env var is not set\n const gitEnabled = options.git === true && inRemotejobsRepo && !gitDisabledByEnv;\n\n // Show error if --git requested but not in remotejobs repo\n if (options.git === true && !inRemotejobsRepo) {\n logger.error('Git operations are only available in remotejobs repository.');\n process.exit(1);\n }\n\n // Validate message is provided when using git\n if (gitEnabled && !options.message) {\n logger.error('Commit message is required when using git.');\n logger.dim('Use: farseer push <tenant> --git -m \"Your message\"');\n process.exit(1);\n }\n\n const gitService = new GitService();\n const syncService = new SyncService(tenant, clientResult.client);\n\n // Step 1: Git pull to ensure we're up to date\n if (gitEnabled) {\n logger.info('Pulling latest changes from git...');\n const gitPullResult = await gitService.pull();\n\n if (!gitPullResult.success) {\n logger.error('Git pull failed.');\n logger.dim(gitPullResult.message);\n process.exit(1);\n }\n\n logger.dim(gitPullResult.message);\n }\n\n // Step 2: Check if remote has unpulled changes\n if (!options.force) {\n logger.info('Checking for remote changes...');\n\n const hasRemoteChanges = await syncService.checkRemoteChanges();\n\n if (hasRemoteChanges) {\n logger.error('Remote has changes that are not synced locally.');\n logger.dim(`Run 'farseer pull ${tenant}' first, then try pushing again.`);\n logger.dim('Or use --force to push anyway (will overwrite remote changes).');\n process.exit(1);\n }\n\n logger.dim('Remote is in sync.');\n }\n\n // Step 3: Show what will be pushed (using fast status check that doesn't download remote content)\n const status = await syncService.getStatusFast();\n\n const filesToPush = [\n ...status.modifiedLocally,\n ...status.onlyLocal,\n ];\n\n const filesToDelete = status.modifiedRemotely.filter((f) =>\n !fs.existsSync(`${filesDir}/${f}`)\n );\n\n // Check app changes too (works with both JWT and API key)\n let appStatus = { newLocal: [] as string[], modified: [] as string[], newRemote: [] as string[], synced: [] as string[] };\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n appStatus = await appSyncService.getStatus();\n\n const hasFileChanges = filesToPush.length > 0 || filesToDelete.length > 0;\n const hasAppChanges = appStatus.newLocal.length > 0 || appStatus.modified.length > 0;\n\n if (!hasFileChanges && !hasAppChanges) {\n logger.success('Nothing to push. Everything is in sync.');\n return;\n }\n\n console.log();\n logger.header('Changes to push:');\n\n if (filesToPush.length > 0) {\n for (const file of filesToPush) {\n const isNew = status.onlyLocal.includes(file);\n if (isNew) {\n console.log(chalk.green(` + ${file}`));\n } else {\n console.log(chalk.yellow(` M ${file}`));\n }\n }\n }\n\n if (filesToDelete.length > 0) {\n for (const file of filesToDelete) {\n console.log(chalk.red(` - ${file}`));\n }\n }\n\n // Show app changes\n if (appStatus.newLocal.length > 0) {\n console.log(chalk.green('New apps:'));\n for (const app of appStatus.newLocal) {\n console.log(chalk.green(` + ${app}`));\n }\n }\n\n if (appStatus.modified.length > 0) {\n console.log(chalk.yellow('Modified apps:'));\n for (const app of appStatus.modified) {\n console.log(chalk.yellow(` ~ ${app}`));\n }\n }\n\n console.log();\n\n const totalChanges = filesToPush.length + filesToDelete.length + appStatus.newLocal.length + appStatus.modified.length;\n\n // Step 4: Confirm push\n const confirm = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'proceed',\n message: `Push ${totalChanges} change(s) to ${tenant}?`,\n default: true,\n },\n ]);\n\n if (!confirm.proceed) {\n logger.info('Push cancelled.');\n return;\n }\n\n // Ensure token is fresh before push operations (may have expired during user input)\n await ensureFreshToken(clientResult.client);\n\n try {\n // Step 5: Push files only if there are file changes\n let result = { uploaded: [] as string[], updated: [] as string[], deleted: [] as string[], unchanged: [] as string[] };\n\n if (hasFileChanges) {\n logger.info(`Pushing files to ${tenant}...`);\n result = await syncService.push();\n\n console.log();\n\n if (result.uploaded.length > 0) {\n console.log(chalk.green('Uploaded files (new):'));\n for (const file of result.uploaded) {\n console.log(chalk.green(` + ${file}`));\n }\n console.log();\n }\n\n if (result.updated.length > 0) {\n console.log(chalk.yellow('Updated files:'));\n for (const file of result.updated) {\n console.log(chalk.yellow(` M ${file}`));\n }\n console.log();\n }\n\n if (result.deleted.length > 0) {\n console.log(chalk.red('Deleted files:'));\n for (const file of result.deleted) {\n console.log(chalk.red(` - ${file}`));\n }\n console.log();\n }\n }\n\n // Step 6: Push apps only if there are app changes\n let appResult = { created: [] as string[], updated: [] as string[], deleted: [] as string[], unchanged: [] as string[] };\n\n if (hasAppChanges) {\n logger.info(`Pushing apps to ${tenant}...`);\n appResult = await appSyncService.push();\n\n if (appResult.created.length > 0) {\n console.log(chalk.green('Created apps:'));\n for (const app of appResult.created) {\n console.log(chalk.green(` + ${app}`));\n }\n console.log();\n }\n\n if (appResult.updated.length > 0) {\n console.log(chalk.yellow('Updated apps:'));\n for (const app of appResult.updated) {\n console.log(chalk.yellow(` ~ ${app}`));\n }\n console.log();\n }\n\n if (appResult.deleted.length > 0) {\n console.log(chalk.red('Deleted apps:'));\n for (const app of appResult.deleted) {\n console.log(chalk.red(` - ${app}`));\n }\n console.log();\n }\n }\n\n // Step 7: Git commit & push\n if (gitEnabled) {\n logger.info('Committing changes to git...');\n\n const appsPath = `apps/${tenant}`;\n await gitService.add([appsPath]);\n\n const commitMessage = `[${tenant}] ${options.message}\n\nFiles: +${result.uploaded.length} ~${result.updated.length} -${result.deleted.length}\nApps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length}\n\n\uD83E\uDD16 Generated with Farseer CLI`;\n\n const commitResult = await gitService.commit(commitMessage, CLI_GIT_AUTHOR);\n\n if (commitResult.success) {\n logger.dim(`Committed: ${commitResult.commitHash}`);\n\n logger.info('Pushing to git remote...');\n const pushResult = await gitService.push();\n\n if (pushResult.success) {\n logger.dim(pushResult.message);\n } else {\n logger.warning('Failed to push to git remote.');\n logger.dim(pushResult.message);\n logger.dim('You may need to push manually.');\n }\n } else {\n logger.warning('Failed to commit changes.');\n logger.dim(commitResult.message);\n }\n }\n\n console.log();\n logger.success('Push complete!');\n logger.dim(`Files: +${result.uploaded.length} ~${result.updated.length} -${result.deleted.length}`);\n logger.dim(`Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length}`);\n } catch (error) {\n logger.error('Push failed.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n}\n"],
5
- "mappings": ";;;;;;;;;;;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AA+B;AAC9C,iCAAO,IAAI,WAAW,OAAO;AAC7B,iCAAO,IAAI,gCAAgC;AAAA,UAC/C;AAAA,QACJ,OAAO;AACH,+BAAO,QAAQ,2BAA2B;AAC1C,+BAAO,IAAI,aAAa,OAAO;AAAA,QACnC;AAAA,MACJ;AAEA,cAAQ,IAAI;AACZ,2BAAO,QAAQ,gBAAgB;AAC/B,2BAAO,IAAI,WAAW,OAAO,SAAS,MAAM,KAAK,OAAO,QAAQ,MAAM,KAAK,OAAO,QAAQ,MAAM,EAAE;AAClG,2BAAO,IAAI,UAAU,UAAU,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,EAAE;AAAA,IAC7G,SAAS,OAAO;AACZ,2BAAO,MAAM,cAAc;AAC3B,UAAI,iBAAiB,OAAO;AACxB,6BAAO,IAAI,MAAM,OAAO;AAAA,MAC5B;AACA,cAAQ,KAAK,CAAC;AAAA,IAClB;AAAA,EACJ,CAAC;AACT;",
4
+ "sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport inquirer from 'inquirer';\nimport { logger } from '../utils/logger';\nimport { getFarseerClientWithFallback, showLoginPrompt, ensureFreshToken } from '../services/farseerFactory';\nimport { SyncService } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport { getTenantFilesDir, resolveTenantWithOrgMapping } from '../utils/helpers';\nimport * as fs from 'fs';\n\nexport function registerPushCommand(program: Command): void {\n program\n .command('push [arg1] [arg2]')\n .description('Push local files to Farseer instance\\n\\nUsage: push <org> <tenant> OR push <tenant> (if org is known)')\n .option('--force', 'Force push even if remote has changes')\n .option('-y, --yes', 'Skip confirmation prompt (auto-confirm)')\n .action(async (arg1, arg2, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(arg1, arg2);\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!clientResult) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const filesDir = getTenantFilesDir(tenant);\n\n if (!fs.existsSync(filesDir)) {\n logger.error(`Local folder not found: farseer-apps/${tenant}/files/`);\n logger.dim('Run \"farseer pull <tenant>\" first to initialize the folder.');\n process.exit(1);\n }\n\n const syncService = new SyncService(tenant, clientResult.client);\n\n // Step 1: Check if remote has unpulled changes\n if (!options.force) {\n logger.info('Checking for remote changes...');\n\n const hasRemoteChanges = await syncService.checkRemoteChanges();\n\n if (hasRemoteChanges) {\n logger.error('Remote has changes that are not synced locally.');\n logger.dim(`Run 'farseer pull ${tenant}' first, then try pushing again.`);\n logger.dim('Or use --force to push anyway (will overwrite remote changes).');\n process.exit(1);\n }\n\n logger.dim('Remote is in sync.');\n }\n\n // Step 2: Show what will be pushed (using fast status check that doesn't download remote content)\n const status = await syncService.getStatusFast();\n\n const filesToPush = [\n ...status.modifiedLocally,\n ...status.onlyLocal,\n ];\n\n const filesToDelete = status.modifiedRemotely.filter((f) =>\n !fs.existsSync(`${filesDir}/${f}`)\n );\n\n // Check app changes too\n let appStatus = { newLocal: [] as string[], modified: [] as string[], newRemote: [] as string[], synced: [] as string[] };\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n appStatus = await appSyncService.getStatus();\n\n const hasFileChanges = filesToPush.length > 0 || filesToDelete.length > 0;\n const hasAppChanges = appStatus.newLocal.length > 0 || appStatus.modified.length > 0;\n\n if (!hasFileChanges && !hasAppChanges) {\n logger.success('Nothing to push. Everything is in sync.');\n return;\n }\n\n console.log();\n logger.header('Changes to push:');\n\n if (filesToPush.length > 0) {\n for (const file of filesToPush) {\n const isNew = status.onlyLocal.includes(file);\n if (isNew) {\n console.log(chalk.green(` + ${file}`));\n } else {\n console.log(chalk.yellow(` M ${file}`));\n }\n }\n }\n\n if (filesToDelete.length > 0) {\n for (const file of filesToDelete) {\n console.log(chalk.red(` - ${file}`));\n }\n }\n\n // Show app changes\n if (appStatus.newLocal.length > 0) {\n console.log(chalk.green('New apps:'));\n for (const app of appStatus.newLocal) {\n console.log(chalk.green(` + ${app}`));\n }\n }\n\n if (appStatus.modified.length > 0) {\n console.log(chalk.yellow('Modified apps:'));\n for (const app of appStatus.modified) {\n console.log(chalk.yellow(` ~ ${app}`));\n }\n }\n\n console.log();\n\n const totalChanges = filesToPush.length + filesToDelete.length + appStatus.newLocal.length + appStatus.modified.length;\n\n // Step 3: Confirm push (skip if --yes flag is set)\n if (!options.yes) {\n const confirm = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'proceed',\n message: `Push ${totalChanges} change(s) to ${tenant}?`,\n default: true,\n },\n ]);\n\n if (!confirm.proceed) {\n logger.info('Push cancelled.');\n return;\n }\n }\n\n // Ensure token is fresh before push operations (may have expired during user input)\n await ensureFreshToken(clientResult.client);\n\n try {\n // Step 4: Push files only if there are file changes\n let result = { uploaded: [] as string[], updated: [] as string[], deleted: [] as string[], unchanged: [] as string[] };\n\n if (hasFileChanges) {\n logger.info(`Pushing files to ${tenant}...`);\n result = await syncService.push();\n\n console.log();\n\n if (result.uploaded.length > 0) {\n console.log(chalk.green('Uploaded files (new):'));\n for (const file of result.uploaded) {\n console.log(chalk.green(` + ${file}`));\n }\n console.log();\n }\n\n if (result.updated.length > 0) {\n console.log(chalk.yellow('Updated files:'));\n for (const file of result.updated) {\n console.log(chalk.yellow(` M ${file}`));\n }\n console.log();\n }\n\n if (result.deleted.length > 0) {\n console.log(chalk.red('Deleted files:'));\n for (const file of result.deleted) {\n console.log(chalk.red(` - ${file}`));\n }\n console.log();\n }\n }\n\n // Step 5: Push apps only if there are app changes\n let appResult = { created: [] as string[], updated: [] as string[], deleted: [] as string[], unchanged: [] as string[] };\n\n if (hasAppChanges) {\n logger.info(`Pushing apps to ${tenant}...`);\n appResult = await appSyncService.push();\n\n if (appResult.created.length > 0) {\n console.log(chalk.green('Created apps:'));\n for (const app of appResult.created) {\n console.log(chalk.green(` + ${app}`));\n }\n console.log();\n }\n\n if (appResult.updated.length > 0) {\n console.log(chalk.yellow('Updated apps:'));\n for (const app of appResult.updated) {\n console.log(chalk.yellow(` ~ ${app}`));\n }\n console.log();\n }\n\n if (appResult.deleted.length > 0) {\n console.log(chalk.red('Deleted apps:'));\n for (const app of appResult.deleted) {\n console.log(chalk.red(` - ${app}`));\n }\n console.log();\n }\n }\n\n console.log();\n logger.success('Push complete!');\n logger.dim(`Files: +${result.uploaded.length} ~${result.updated.length} -${result.deleted.length}`);\n logger.dim(`Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length}`);\n } catch (error) {\n logger.error('Push failed.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,sBAAqB;AACrB,oBAAuB;AACvB,4BAAgF;AAChF,yBAA4B;AAC5B,4BAA+B;AAC/B,qBAA+D;AAC/D,SAAoB;AAEb,SAAS,oBAAoB,SAAwB;AACxD,UACK,QAAQ,oBAAoB,EAC5B,YAAY,uGAAuG,EACnH,OAAO,WAAW,uCAAuC,EACzD,OAAO,aAAa,yCAAyC,EAC7D,OAAO,OAAO,MAAM,MAAM,YAAY;AACnC,UAAM,EAAE,cAAc,OAAO,QAAI,4CAA4B,MAAM,IAAI;AACvE,UAAM,eAAe,UAAM,oDAA6B,cAAc,MAAM;AAE5E,QAAI,CAAC,cAAc;AACf,iDAAgB,MAAM;AACtB,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,UAAM,eAAW,kCAAkB,MAAM;AAEzC,QAAI,CAAC,GAAG,WAAW,QAAQ,GAAG;AAC1B,2BAAO,MAAM,wCAAwC,MAAM,SAAS;AACpE,2BAAO,IAAI,6DAA6D;AACxE,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,UAAM,cAAc,IAAI,+BAAY,QAAQ,aAAa,MAAM;AAG/D,QAAI,CAAC,QAAQ,OAAO;AAChB,2BAAO,KAAK,gCAAgC;AAE5C,YAAM,mBAAmB,MAAM,YAAY,mBA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,CAAC;AAAA,UAC1C;AACA,kBAAQ,IAAI;AAAA,QAChB;AAEA,YAAI,UAAU,QAAQ,SAAS,GAAG;AAC9B,kBAAQ,IAAI,aAAAA,QAAM,IAAI,eAAe,CAAC;AACtC,qBAAW,OAAO,UAAU,SAAS;AACjC,oBAAQ,IAAI,aAAAA,QAAM,IAAI,OAAO,GAAG,EAAE,CAAC;AAAA,UACvC;AACA,kBAAQ,IAAI;AAAA,QAChB;AAAA,MACJ;AAEA,cAAQ,IAAI;AACZ,2BAAO,QAAQ,gBAAgB;AAC/B,2BAAO,IAAI,WAAW,OAAO,SAAS,MAAM,KAAK,OAAO,QAAQ,MAAM,KAAK,OAAO,QAAQ,MAAM,EAAE;AAClG,2BAAO,IAAI,UAAU,UAAU,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,EAAE;AAAA,IAC7G,SAAS,OAAO;AACZ,2BAAO,MAAM,cAAc;AAC3B,UAAI,iBAAiB,OAAO;AACxB,6BAAO,IAAI,MAAM,OAAO;AAAA,MAC5B;AACA,cAAQ,KAAK,CAAC;AAAA,IAClB;AAAA,EACJ,CAAC;AACT;",
6
6
  "names": ["chalk", "inquirer"]
7
7
  }
@@ -0,0 +1,176 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var variables_exports = {};
29
+ __export(variables_exports, {
30
+ registerVariablesCommand: () => registerVariablesCommand
31
+ });
32
+ module.exports = __toCommonJS(variables_exports);
33
+ var fs = __toESM(require("fs"));
34
+ var import_chalk = __toESM(require("chalk"));
35
+ var import_logger = require("../utils/logger");
36
+ var import_farseerFactory = require("../services/farseerFactory");
37
+ var import_helpers = require("../utils/helpers");
38
+ function registerVariablesCommand(program) {
39
+ const variablesCmd = program.command("variables").description("List and manage variables");
40
+ variablesCmd.command("list [first] [second]").description("List all variables").option("--json", "Output raw JSON").action(async (first, second, options) => {
41
+ const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(first, second);
42
+ const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
43
+ if (!result) {
44
+ (0, import_farseerFactory.showLoginPrompt)(tenant);
45
+ process.exit(1);
46
+ }
47
+ try {
48
+ const model = await result.client.exportModel();
49
+ if (options.json) {
50
+ console.log(JSON.stringify(model.variables, null, 2));
51
+ return;
52
+ }
53
+ import_logger.logger.header(`Variables (${model.variables.length})`);
54
+ console.log();
55
+ for (const variable of model.variables) {
56
+ const flags = [];
57
+ if (variable.readonly) flags.push("readonly");
58
+ if (variable.calculateOnDemand) flags.push("on-demand");
59
+ const flagStr = flags.length > 0 ? import_chalk.default.dim(` [${flags.join(", ")}]`) : "";
60
+ console.log(` ${import_chalk.default.bold(variable.name)}${flagStr}`);
61
+ console.log(` Dimensions: ${variable.tables.join(", ")}`);
62
+ console.log(` Rollup: ${variable.rollupType} | Type: ${variable.dataType}`);
63
+ if (variable.formula) {
64
+ console.log(` Formula: ${import_chalk.default.dim(variable.formula.substring(0, 80))}${variable.formula.length > 80 ? "..." : ""}`);
65
+ }
66
+ console.log();
67
+ }
68
+ } catch (error) {
69
+ handleModelError(error, tenant);
70
+ }
71
+ });
72
+ const variableCmd = program.command("variable").description("Variable details and export");
73
+ variableCmd.command("details <name>").description("Show variable details (dimensions, formula, rollup, etc.)").option("--json", "Output raw JSON").action(async (name, options) => {
74
+ const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)();
75
+ const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
76
+ if (!result) {
77
+ (0, import_farseerFactory.showLoginPrompt)(tenant);
78
+ process.exit(1);
79
+ }
80
+ try {
81
+ const model = await result.client.exportModel();
82
+ const variable = model.variables.find(
83
+ (v) => v.name.toLowerCase() === name.toLowerCase()
84
+ );
85
+ if (!variable) {
86
+ import_logger.logger.error(`Variable "${name}" not found.`);
87
+ import_logger.logger.dim("Available variables:");
88
+ model.variables.slice(0, 10).forEach((v) => import_logger.logger.dim(` - ${v.name}`));
89
+ if (model.variables.length > 10) {
90
+ import_logger.logger.dim(` ... and ${model.variables.length - 10} more`);
91
+ }
92
+ process.exit(1);
93
+ }
94
+ if (options.json) {
95
+ console.log(JSON.stringify(variable, null, 2));
96
+ return;
97
+ }
98
+ import_logger.logger.header(`Variable: ${variable.name}`);
99
+ console.log();
100
+ if (variable.description) {
101
+ console.log(` Description: ${variable.description}`);
102
+ }
103
+ if (variable.formula) {
104
+ console.log(` Formula: ${variable.formula}`);
105
+ }
106
+ console.log(` Dimensions: ${variable.tables.join(", ")}`);
107
+ if (variable.members.length > 0) {
108
+ console.log(` Specific members: ${variable.members.join(", ")}`);
109
+ }
110
+ console.log(` Roll-up type: ${variable.rollupType}`);
111
+ console.log(` Data type: ${variable.dataType}`);
112
+ if (variable.numberFormat) {
113
+ console.log(` Format: ${variable.numberFormat.type}${variable.numberFormat.formatString ? ` (${variable.numberFormat.formatString})` : ""}`);
114
+ }
115
+ console.log(` Readonly: ${variable.readonly}`);
116
+ console.log(` Calculate on demand: ${variable.calculateOnDemand}`);
117
+ if (variable.folderPath) {
118
+ console.log(` Folder: ${variable.folderPath.join(" / ")}`);
119
+ }
120
+ if (variable.cells && variable.cells.length > 0) {
121
+ console.log(` Cells with data: ${variable.cells.length}`);
122
+ }
123
+ } catch (error) {
124
+ handleModelError(error, tenant);
125
+ }
126
+ });
127
+ variableCmd.command("export <name>").description("Export variable data to CSV file").option("--output <file>", "Output file path").option("--format <format>", "Output format: csv, json, xlsx", "csv").option("--limit <n>", "Limit number of rows", parseInt).action(async (name, options) => {
128
+ const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)();
129
+ const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
130
+ if (!nativeClient) {
131
+ (0, import_farseerFactory.showLoginPrompt)(tenant);
132
+ process.exit(1);
133
+ }
134
+ try {
135
+ import_logger.logger.info(`Exporting variable "${name}" from ${tenant}...`);
136
+ const exportRequest = {
137
+ formula: name,
138
+ format: options.format || "csv"
139
+ };
140
+ if (options.limit) {
141
+ exportRequest.limit = options.limit;
142
+ }
143
+ const blob = await nativeClient.export.exportFormula(exportRequest);
144
+ const content = await blob.text();
145
+ const outputFile = options.output || `${name.replace(/[^a-zA-Z0-9_-]/g, "_")}.${options.format || "csv"}`;
146
+ fs.writeFileSync(outputFile, content, "utf-8");
147
+ import_logger.logger.success(`Exported to ${outputFile}`);
148
+ const lines = content.split("\n").filter((l) => l.trim()).length;
149
+ import_logger.logger.dim(`${lines - 1} data rows`);
150
+ } catch (error) {
151
+ const errorMessage = error instanceof Error ? error.message : String(error);
152
+ import_logger.logger.error(`Failed to export variable "${name}".`);
153
+ import_logger.logger.dim(errorMessage);
154
+ process.exit(1);
155
+ }
156
+ });
157
+ }
158
+ function handleModelError(error, tenant) {
159
+ const errorMessage = error instanceof Error ? error.message : String(error);
160
+ if ((0, import_farseerFactory.isAuthError)(error)) {
161
+ (0, import_farseerFactory.showLoginPrompt)(tenant);
162
+ } else if (errorMessage.includes("404")) {
163
+ import_logger.logger.error(`Tenant "${tenant}" not found or not accessible.`);
164
+ } else if (errorMessage.includes("ENOTFOUND") || errorMessage.includes("ECONNREFUSED")) {
165
+ import_logger.logger.error("Failed to connect to Farseer.");
166
+ } else {
167
+ import_logger.logger.error("Failed to fetch model.");
168
+ import_logger.logger.dim(errorMessage);
169
+ }
170
+ process.exit(1);
171
+ }
172
+ // Annotate the CommonJS export names for ESM import in node:
173
+ 0 && (module.exports = {
174
+ registerVariablesCommand
175
+ });
176
+ //# sourceMappingURL=variables.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/commands/variables.ts"],
4
+ "sourcesContent": ["import { Command } from 'commander';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { getFarseerClientWithFallback, getNativeFarseerClient, showLoginPrompt, isAuthError } from '../services/farseerFactory';\nimport { resolveTenantWithOrgMapping } from '../utils/helpers';\n\nexport function registerVariablesCommand(program: Command): void {\n // farseer variables list\n const variablesCmd = program\n .command('variables')\n .description('List and manage variables');\n\n variablesCmd\n .command('list [first] [second]')\n .description('List all variables')\n .option('--json', 'Output raw JSON')\n .action(async (first, second, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(first, second);\n const result = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n const model = await result.client.exportModel();\n\n if (options.json) {\n console.log(JSON.stringify(model.variables, null, 2));\n return;\n }\n\n logger.header(`Variables (${model.variables.length})`);\n console.log();\n for (const variable of model.variables) {\n const flags = [];\n if (variable.readonly) flags.push('readonly');\n if (variable.calculateOnDemand) flags.push('on-demand');\n const flagStr = flags.length > 0 ? chalk.dim(` [${flags.join(', ')}]`) : '';\n\n console.log(` ${chalk.bold(variable.name)}${flagStr}`);\n console.log(` Dimensions: ${variable.tables.join(', ')}`);\n console.log(` Rollup: ${variable.rollupType} | Type: ${variable.dataType}`);\n if (variable.formula) {\n console.log(` Formula: ${chalk.dim(variable.formula.substring(0, 80))}${variable.formula.length > 80 ? '...' : ''}`);\n }\n console.log();\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer variable details / export (singular)\n const variableCmd = program\n .command('variable')\n .description('Variable details and export');\n\n variableCmd\n .command('details <name>')\n .description('Show variable details (dimensions, formula, rollup, etc.)')\n .option('--json', 'Output raw JSON')\n .action(async (name, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping();\n const result = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n const model = await result.client.exportModel();\n const variable = model.variables.find(\n v => v.name.toLowerCase() === name.toLowerCase()\n );\n\n if (!variable) {\n logger.error(`Variable \"${name}\" not found.`);\n logger.dim('Available variables:');\n model.variables.slice(0, 10).forEach(v => logger.dim(` - ${v.name}`));\n if (model.variables.length > 10) {\n logger.dim(` ... and ${model.variables.length - 10} more`);\n }\n process.exit(1);\n }\n\n if (options.json) {\n console.log(JSON.stringify(variable, null, 2));\n return;\n }\n\n logger.header(`Variable: ${variable.name}`);\n console.log();\n if (variable.description) {\n console.log(` Description: ${variable.description}`);\n }\n if (variable.formula) {\n console.log(` Formula: ${variable.formula}`);\n }\n console.log(` Dimensions: ${variable.tables.join(', ')}`);\n if (variable.members.length > 0) {\n console.log(` Specific members: ${variable.members.join(', ')}`);\n }\n console.log(` Roll-up type: ${variable.rollupType}`);\n console.log(` Data type: ${variable.dataType}`);\n if (variable.numberFormat) {\n console.log(` Format: ${variable.numberFormat.type}${variable.numberFormat.formatString ? ` (${variable.numberFormat.formatString})` : ''}`);\n }\n console.log(` Readonly: ${variable.readonly}`);\n console.log(` Calculate on demand: ${variable.calculateOnDemand}`);\n if (variable.folderPath) {\n console.log(` Folder: ${variable.folderPath.join(' / ')}`);\n }\n if (variable.cells && variable.cells.length > 0) {\n console.log(` Cells with data: ${variable.cells.length}`);\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n variableCmd\n .command('export <name>')\n .description('Export variable data to CSV file')\n .option('--output <file>', 'Output file path')\n .option('--format <format>', 'Output format: csv, json, xlsx', 'csv')\n .option('--limit <n>', 'Limit number of rows', parseInt)\n .action(async (name, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping();\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n\n if (!nativeClient) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n logger.info(`Exporting variable \"${name}\" from ${tenant}...`);\n\n const exportRequest: any = {\n formula: name,\n format: options.format || 'csv',\n };\n if (options.limit) {\n exportRequest.limit = options.limit;\n }\n\n const blob = await nativeClient.export.exportFormula(exportRequest);\n const content = await blob.text();\n\n const outputFile = options.output || `${name.replace(/[^a-zA-Z0-9_-]/g, '_')}.${options.format || 'csv'}`;\n fs.writeFileSync(outputFile, content, 'utf-8');\n\n logger.success(`Exported to ${outputFile}`);\n const lines = content.split('\\n').filter(l => l.trim()).length;\n logger.dim(`${lines - 1} data rows`);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n logger.error(`Failed to export variable \"${name}\".`);\n logger.dim(errorMessage);\n process.exit(1);\n }\n });\n}\n\nfunction handleModelError(error: unknown, tenant: string): void {\n const errorMessage = error instanceof Error ? error.message : String(error);\n\n if (isAuthError(error)) {\n showLoginPrompt(tenant);\n } else if (errorMessage.includes('404')) {\n logger.error(`Tenant \"${tenant}\" not found or not accessible.`);\n } else if (errorMessage.includes('ENOTFOUND') || errorMessage.includes('ECONNREFUSED')) {\n logger.error('Failed to connect to Farseer.');\n } else {\n logger.error('Failed to fetch model.');\n logger.dim(error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AG;AACpF,yBAAO,MAAM,+BAA+B;AAAA,EAChD,OAAO;AACH,yBAAO,MAAM,wBAAwB;AACrC,yBAAO,IAAI,YAAY;AAAA,EAC3B;AACA,UAAQ,KAAK,CAAC;AAClB;",
6
+ "names": ["chalk"]
7
+ }
package/dist/index.js CHANGED
@@ -38,6 +38,8 @@ var import_install = require("./commands/install");
38
38
  var import_whoami = require("./commands/whoami");
39
39
  var import_app = require("./commands/app");
40
40
  var import_model = require("./commands/model");
41
+ var import_variables = require("./commands/variables");
42
+ var import_dimensions = require("./commands/dimensions");
41
43
  var import_checkout = require("./commands/checkout");
42
44
  var import_mcp_server = require("./commands/mcp-server");
43
45
  const originalEmit = process.emit;
@@ -52,12 +54,18 @@ program.configureHelp({
52
54
  visibleCommands: () => []
53
55
  // Hide all commands from default list
54
56
  });
55
- program.name("farseer").description("CLI tool for syncing Farseer App scripts between local repository and Farseer instances").version(import_constants.CLI_VERSION).addHelpText("after", `
57
+ program.name("farseer").description("CLI tool for syncing Farseer App scripts between local folder and Farseer instances").version(import_constants.CLI_VERSION).addHelpText("after", `
58
+ ${import_chalk.default.bold.underline("Tenant Resolution")}
59
+ Most commands accept ${import_chalk.default.cyan("[org] [tenant]")} arguments:
60
+ ${import_chalk.default.green("$")} farseer checkout ${import_chalk.default.cyan("salvus-2 salvus-prodaja")} ${import_chalk.default.dim("First time: specify <org> <tenant>")}
61
+ ${import_chalk.default.green("$")} farseer pull ${import_chalk.default.cyan("salvus-prodaja")} ${import_chalk.default.dim("After that: just <tenant> (org is remembered)")}
62
+ ${import_chalk.default.green("$")} farseer push ${import_chalk.default.dim("Or omit entirely if checked out")}
63
+
56
64
  ${import_chalk.default.bold.underline("Authentication")}
57
- login Login via browser (OAuth) or use --api-key
65
+ login Login via browser (OAuth)
58
66
  logout [tenant] Logout and remove credentials
59
67
  whoami Show login status and configured tenants
60
- checkout [tenant] Set default tenant (verifies auth & pulls)
68
+ checkout [org] [tenant] Set default tenant (verifies auth & pulls)
61
69
  ${import_chalk.default.dim("--no-pull")} Skip automatic pull
62
70
 
63
71
  ${import_chalk.default.bold.underline("Configuration")} ${import_chalk.default.dim("(farseer config <command>)")}
@@ -70,12 +78,11 @@ ${import_chalk.default.bold.underline("Configuration")} ${import_chalk.default.
70
78
  config test <tenant> Test connection to tenant
71
79
 
72
80
  ${import_chalk.default.bold.underline("Sync Operations")} ${import_chalk.default.dim("(tenant optional if checked out)")}
73
- pull [tenant] Pull files and apps from remote
74
- ${import_chalk.default.dim("--no-git")} Skip git operations
81
+ pull [org] [tenant] Pull files and apps from remote
75
82
  ${import_chalk.default.dim("--all")} Download all files (not just .ts/.js)
76
- push [tenant] Push local changes to remote
77
- ${import_chalk.default.dim("-m, --message <msg>")} Commit message (required)
78
- ${import_chalk.default.dim("--no-git")} Skip git operations
83
+ push [org] [tenant] Push local changes to remote
84
+ ${import_chalk.default.dim("-y, --yes")} Skip confirmation prompt
85
+ ${import_chalk.default.dim("--force")} Push even if remote has changes
79
86
  status [tenant] Show sync status (local vs remote)
80
87
  ${import_chalk.default.dim("--all")} Show all files (not just .ts/.js)
81
88
  diff [tenant] [file] Show file differences
@@ -98,6 +105,19 @@ ${import_chalk.default.bold.underline("Running & Development")} ${import_chalk.
98
105
  run-script [tenant] <file> Run script directly (no app wrapper)
99
106
  install [tenant] Install npm dependencies (npm install)
100
107
 
108
+ ${import_chalk.default.bold.underline("Variables")} ${import_chalk.default.dim("(tenant optional if checked out)")}
109
+ variables list [tenant] List all variables
110
+ variable details <name> Show variable details (dimensions, formula, etc.)
111
+ variable export <name> Export variable data to CSV
112
+ ${import_chalk.default.dim("--output <file>")} Output file path
113
+ ${import_chalk.default.dim("--format <csv|json|xlsx>")} Output format (default: csv)
114
+ ${import_chalk.default.dim("--limit <n>")} Limit number of rows
115
+
116
+ ${import_chalk.default.bold.underline("Dimensions")} ${import_chalk.default.dim("(tenant optional if checked out)")}
117
+ dimensions list [tenant] List all dimension tables
118
+ dimension details <name> Show table details (columns, members)
119
+ ${import_chalk.default.dim("--members <n>")} Number of sample members (default: 10)
120
+
101
121
  ${import_chalk.default.bold.underline("Model Inspection")} ${import_chalk.default.dim("(tenant optional if checked out)")}
102
122
  model [tenant] Show model structure (dimensions, variables)
103
123
  ${import_chalk.default.dim("--variables")} List all variables
@@ -108,13 +128,19 @@ ${import_chalk.default.bold.underline("File Management")} ${import_chalk.defaul
108
128
  files list [tenant] List files on remote
109
129
  ${import_chalk.default.dim("--all")} Show all files (not just scripts)
110
130
 
131
+ ${import_chalk.default.bold.underline("MCP Server")} ${import_chalk.default.dim("(AI assistant integration)")}
132
+ mcp-server Start MCP server for Claude, Cursor, etc.
133
+
111
134
  ${import_chalk.default.bold.underline("Examples")}
112
135
  ${import_chalk.default.green("$")} farseer login ${import_chalk.default.dim("Login via browser")}
113
- ${import_chalk.default.green("$")} farseer config set myco --api-key xxx ${import_chalk.default.dim("Add tenant with API key")}
114
- ${import_chalk.default.green("$")} farseer pull mycompany --no-git ${import_chalk.default.dim("Download scripts & apps")}
115
- ${import_chalk.default.green("$")} farseer push mycompany -m "Fix bug" ${import_chalk.default.dim("Upload changes")}
116
- ${import_chalk.default.green("$")} farseer run mycompany "My App" ${import_chalk.default.dim("Run app locally")}
117
- ${import_chalk.default.green("$")} farseer model mycompany --variables ${import_chalk.default.dim("List all variables")}
136
+ ${import_chalk.default.green("$")} farseer checkout salvus-2 salvus-prod ${import_chalk.default.dim("First time: org + tenant")}
137
+ ${import_chalk.default.green("$")} farseer pull salvus-prod ${import_chalk.default.dim("Next time: just tenant")}
138
+ ${import_chalk.default.green("$")} farseer push ${import_chalk.default.dim("If checked out: no args needed")}
139
+ ${import_chalk.default.green("$")} farseer push -y ${import_chalk.default.dim("Push without confirmation")}
140
+ ${import_chalk.default.green("$")} farseer run "My App" ${import_chalk.default.dim("Run app locally")}
141
+ ${import_chalk.default.green("$")} farseer variables list ${import_chalk.default.dim("List all variables")}
142
+ ${import_chalk.default.green("$")} farseer variable details "Revenue" ${import_chalk.default.dim("Show variable details")}
143
+ ${import_chalk.default.green("$")} farseer dimensions list ${import_chalk.default.dim("List dimension tables")}
118
144
  `);
119
145
  (0, import_login.registerLoginCommand)(program);
120
146
  (0, import_logout.registerLogoutCommand)(program);
@@ -123,6 +149,8 @@ ${import_chalk.default.bold.underline("Examples")}
123
149
  (0, import_list.registerListCommand)(program);
124
150
  (0, import_files.registerFilesCommand)(program);
125
151
  (0, import_app.registerAppCommand)(program);
152
+ (0, import_variables.registerVariablesCommand)(program);
153
+ (0, import_dimensions.registerDimensionsCommand)(program);
126
154
  (0, import_model.registerModelCommand)(program);
127
155
  (0, import_status.registerStatusCommand)(program);
128
156
  (0, import_diff.registerDiffCommand)(program);
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["#!/usr/bin/env node\n\n// Suppress punycode deprecation warning (comes from dependencies like axios)\nconst originalEmit = process.emit;\n// @ts-expect-error - overriding process.emit\nprocess.emit = function (name: string, data: unknown, ...args: unknown[]) {\n if (name === 'warning' && typeof data === 'object' && data !== null && 'name' in data && data.name === 'DeprecationWarning' && 'message' in data && typeof data.message === 'string' && data.message.includes('punycode')) {\n return false;\n }\n // @ts-expect-error - calling original emit\n return originalEmit.apply(process, [name, data, ...args]);\n};\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport { CLI_VERSION } from './utils/constants';\nimport { registerLoginCommand } from './commands/login';\nimport { registerLogoutCommand } from './commands/logout';\nimport { registerConfigCommand } from './commands/config';\nimport { registerListCommand } from './commands/list';\nimport { registerFilesCommand } from './commands/files';\nimport { registerStatusCommand } from './commands/status';\nimport { registerDiffCommand } from './commands/diff';\nimport { registerPullCommand } from './commands/pull';\nimport { registerPushCommand } from './commands/push';\nimport { registerRunCommand } from './commands/run';\nimport { registerInstallCommand } from './commands/install';\nimport { registerWhoamiCommand } from './commands/whoami';\nimport { registerAppCommand } from './commands/app';\nimport { registerModelCommand } from './commands/model';\nimport { registerCheckoutCommand } from './commands/checkout';\nimport { registerMcpServerCommand } from './commands/mcp-server';\n\nconst program = new Command();\n\n// Configure help to hide default command list (we show our own custom list)\nprogram.configureHelp({\n visibleCommands: () => [], // Hide all commands from default list\n});\n\nprogram\n .name('farseer')\n .description('CLI tool for syncing Farseer App scripts between local repository and Farseer instances')\n .version(CLI_VERSION)\n .addHelpText('after', `\n${chalk.bold.underline('Authentication')}\n login Login via browser (OAuth) or use --api-key\n logout [tenant] Logout and remove credentials\n whoami Show login status and configured tenants\n checkout [tenant] Set default tenant (verifies auth & pulls)\n ${chalk.dim('--no-pull')} Skip automatic pull\n\n${chalk.bold.underline('Configuration')} ${chalk.dim('(farseer config <command>)')}\n config set <tenant> Set API key for a tenant\n ${chalk.dim('--api-key <key>')} API key (required)\n ${chalk.dim('--org <name>')} Organisation if different from tenant\n config remove <tenant> Remove credentials\n config list List all configured tenants\n config show <tenant> Show full credentials (incl. API key)\n config test <tenant> Test connection to tenant\n\n${chalk.bold.underline('Sync Operations')} ${chalk.dim('(tenant optional if checked out)')}\n pull [tenant] Pull files and apps from remote\n ${chalk.dim('--no-git')} Skip git operations\n ${chalk.dim('--all')} Download all files (not just .ts/.js)\n push [tenant] Push local changes to remote\n ${chalk.dim('-m, --message <msg>')} Commit message (required)\n ${chalk.dim('--no-git')} Skip git operations\n status [tenant] Show sync status (local vs remote)\n ${chalk.dim('--all')} Show all files (not just .ts/.js)\n diff [tenant] [file] Show file differences\n\n${chalk.bold.underline('App Management')} ${chalk.dim('(tenant optional if checked out)')}\n app list [tenant] List all apps\n ${chalk.dim('--details')} Show details for each app\n app show [tenant] <name> Show app details\n app create [tenant] <name> Create new app\n app configure [tenant] <name> Configure app\n ${chalk.dim('--entrypoint <script>')} Set main script\n ${chalk.dim('--scripts <list>')} Comma-separated scripts\n ${chalk.dim('--add-arg <Name=Value>')} Add argument (repeatable)\n ${chalk.dim('--description <text>')} Set description\n app delete [tenant] <name> Delete app (requires --force)\n\n${chalk.bold.underline('Running & Development')} ${chalk.dim('(tenant optional if checked out)')}\n run [tenant] <app> Run app locally with injected credentials\n ${chalk.dim('--arg <Name=Value>')} Override argument (repeatable)\n run-script [tenant] <file> Run script directly (no app wrapper)\n install [tenant] Install npm dependencies (npm install)\n\n${chalk.bold.underline('Model Inspection')} ${chalk.dim('(tenant optional if checked out)')}\n model [tenant] Show model structure (dimensions, variables)\n ${chalk.dim('--variables')} List all variables\n ${chalk.dim('--tables')} List all dimension tables\n ${chalk.dim('--variable <name>')} Show dimensions for variable\n\n${chalk.bold.underline('File Management')} ${chalk.dim('(farseer files <command>)')}\n files list [tenant] List files on remote\n ${chalk.dim('--all')} Show all files (not just scripts)\n\n${chalk.bold.underline('Examples')}\n ${chalk.green('$')} farseer login ${chalk.dim('Login via browser')}\n ${chalk.green('$')} farseer config set myco --api-key xxx ${chalk.dim('Add tenant with API key')}\n ${chalk.green('$')} farseer pull mycompany --no-git ${chalk.dim('Download scripts & apps')}\n ${chalk.green('$')} farseer push mycompany -m \"Fix bug\" ${chalk.dim('Upload changes')}\n ${chalk.green('$')} farseer run mycompany \"My App\" ${chalk.dim('Run app locally')}\n ${chalk.green('$')} farseer model mycompany --variables ${chalk.dim('List all variables')}\n`);\n\n// Register all commands (hidden from default help, shown in custom help above)\nregisterLoginCommand(program);\nregisterLogoutCommand(program);\nregisterCheckoutCommand(program);\nregisterConfigCommand(program);\nregisterListCommand(program);\nregisterFilesCommand(program);\nregisterAppCommand(program);\nregisterModelCommand(program);\nregisterStatusCommand(program);\nregisterDiffCommand(program);\nregisterPullCommand(program);\nregisterPushCommand(program);\nregisterRunCommand(program);\nregisterInstallCommand(program);\nregisterWhoamiCommand(program);\nregisterMcpServerCommand(program);\n\n// Parse arguments\nprogram.parse();\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAaA,uBAAwB;AACxB,mBAAkB;AAClB,uBAA4B;AAC5B,mBAAqC;AACrC,oBAAsC;AACtC,oBAAsC;AACtC,kB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,2CAA2C,aAAAA,QAAM,IAAI,yBAAyB,CAAC;AAAA,IAC/F,aAAAA,QAAM,MAAM,GAAG,CAAC,2CAA2C,aAAAA,QAAM,IAAI,yBAAyB,CAAC;AAAA,IAC/F,aAAAA,QAAM,MAAM,GAAG,CAAC,2CAA2C,aAAAA,QAAM,IAAI,gBAAgB,CAAC;AAAA,IACtF,aAAAA,QAAM,MAAM,GAAG,CAAC,2CAA2C,aAAAA,QAAM,IAAI,iBAAiB,CAAC;AAAA,IACvF,aAAAA,QAAM,MAAM,GAAG,CAAC,2CAA2C,aAAAA,QAAM,IAAI,oBAAoB,CAAC;AAAA,CAC7F;AAAA,IAGD,mCAAqB,OAAO;AAAA,IAC5B,qCAAsB,OAAO;AAAA,IAC7B,yCAAwB,OAAO;AAAA,IAC/B,qCAAsB,OAAO;AAAA,IAC7B,iCAAoB,OAAO;AAAA,IAC3B,mCAAqB,OAAO;AAAA,IAC5B,+BAAmB,OAAO;AAAA,IAC1B,mCAAqB,OAAO;AAAA,IAC5B,qCAAsB,OAAO;AAAA,IAC7B,iCAAoB,OAAO;AAAA,IAC3B,iCAAoB,OAAO;AAAA,IAC3B,iCAAoB,OAAO;AAAA,IAC3B,+BAAmB,OAAO;AAAA,IAC1B,uCAAuB,OAAO;AAAA,IAC9B,qCAAsB,OAAO;AAAA,IAC7B,4CAAyB,OAAO;AAGhC,QAAQ,MAAM;",
4
+ "sourcesContent": ["#!/usr/bin/env node\n\n// Suppress punycode deprecation warning (comes from dependencies like axios)\nconst originalEmit = process.emit;\n// @ts-expect-error - overriding process.emit\nprocess.emit = function (name: string, data: unknown, ...args: unknown[]) {\n if (name === 'warning' && typeof data === 'object' && data !== null && 'name' in data && data.name === 'DeprecationWarning' && 'message' in data && typeof data.message === 'string' && data.message.includes('punycode')) {\n return false;\n }\n // @ts-expect-error - calling original emit\n return originalEmit.apply(process, [name, data, ...args]);\n};\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport { CLI_VERSION } from './utils/constants';\nimport { registerLoginCommand } from './commands/login';\nimport { registerLogoutCommand } from './commands/logout';\nimport { registerConfigCommand } from './commands/config';\nimport { registerListCommand } from './commands/list';\nimport { registerFilesCommand } from './commands/files';\nimport { registerStatusCommand } from './commands/status';\nimport { registerDiffCommand } from './commands/diff';\nimport { registerPullCommand } from './commands/pull';\nimport { registerPushCommand } from './commands/push';\nimport { registerRunCommand } from './commands/run';\nimport { registerInstallCommand } from './commands/install';\nimport { registerWhoamiCommand } from './commands/whoami';\nimport { registerAppCommand } from './commands/app';\nimport { registerModelCommand } from './commands/model';\nimport { registerVariablesCommand } from './commands/variables';\nimport { registerDimensionsCommand } from './commands/dimensions';\nimport { registerCheckoutCommand } from './commands/checkout';\nimport { registerMcpServerCommand } from './commands/mcp-server';\n\nconst program = new Command();\n\n// Configure help to hide default command list (we show our own custom list)\nprogram.configureHelp({\n visibleCommands: () => [], // Hide all commands from default list\n});\n\nprogram\n .name('farseer')\n .description('CLI tool for syncing Farseer App scripts between local folder and Farseer instances')\n .version(CLI_VERSION)\n .addHelpText('after', `\n${chalk.bold.underline('Tenant Resolution')}\n Most commands accept ${chalk.cyan('[org] [tenant]')} arguments:\n ${chalk.green('$')} farseer checkout ${chalk.cyan('salvus-2 salvus-prodaja')} ${chalk.dim('First time: specify <org> <tenant>')}\n ${chalk.green('$')} farseer pull ${chalk.cyan('salvus-prodaja')} ${chalk.dim('After that: just <tenant> (org is remembered)')}\n ${chalk.green('$')} farseer push ${chalk.dim('Or omit entirely if checked out')}\n\n${chalk.bold.underline('Authentication')}\n login Login via browser (OAuth)\n logout [tenant] Logout and remove credentials\n whoami Show login status and configured tenants\n checkout [org] [tenant] Set default tenant (verifies auth & pulls)\n ${chalk.dim('--no-pull')} Skip automatic pull\n\n${chalk.bold.underline('Configuration')} ${chalk.dim('(farseer config <command>)')}\n config set <tenant> Set API key for a tenant\n ${chalk.dim('--api-key <key>')} API key (required)\n ${chalk.dim('--org <name>')} Organisation if different from tenant\n config remove <tenant> Remove credentials\n config list List all configured tenants\n config show <tenant> Show full credentials (incl. API key)\n config test <tenant> Test connection to tenant\n\n${chalk.bold.underline('Sync Operations')} ${chalk.dim('(tenant optional if checked out)')}\n pull [org] [tenant] Pull files and apps from remote\n ${chalk.dim('--all')} Download all files (not just .ts/.js)\n push [org] [tenant] Push local changes to remote\n ${chalk.dim('-y, --yes')} Skip confirmation prompt\n ${chalk.dim('--force')} Push even if remote has changes\n status [tenant] Show sync status (local vs remote)\n ${chalk.dim('--all')} Show all files (not just .ts/.js)\n diff [tenant] [file] Show file differences\n\n${chalk.bold.underline('App Management')} ${chalk.dim('(tenant optional if checked out)')}\n app list [tenant] List all apps\n ${chalk.dim('--details')} Show details for each app\n app show [tenant] <name> Show app details\n app create [tenant] <name> Create new app\n app configure [tenant] <name> Configure app\n ${chalk.dim('--entrypoint <script>')} Set main script\n ${chalk.dim('--scripts <list>')} Comma-separated scripts\n ${chalk.dim('--add-arg <Name=Value>')} Add argument (repeatable)\n ${chalk.dim('--description <text>')} Set description\n app delete [tenant] <name> Delete app (requires --force)\n\n${chalk.bold.underline('Running & Development')} ${chalk.dim('(tenant optional if checked out)')}\n run [tenant] <app> Run app locally with injected credentials\n ${chalk.dim('--arg <Name=Value>')} Override argument (repeatable)\n run-script [tenant] <file> Run script directly (no app wrapper)\n install [tenant] Install npm dependencies (npm install)\n\n${chalk.bold.underline('Variables')} ${chalk.dim('(tenant optional if checked out)')}\n variables list [tenant] List all variables\n variable details <name> Show variable details (dimensions, formula, etc.)\n variable export <name> Export variable data to CSV\n ${chalk.dim('--output <file>')} Output file path\n ${chalk.dim('--format <csv|json|xlsx>')} Output format (default: csv)\n ${chalk.dim('--limit <n>')} Limit number of rows\n\n${chalk.bold.underline('Dimensions')} ${chalk.dim('(tenant optional if checked out)')}\n dimensions list [tenant] List all dimension tables\n dimension details <name> Show table details (columns, members)\n ${chalk.dim('--members <n>')} Number of sample members (default: 10)\n\n${chalk.bold.underline('Model Inspection')} ${chalk.dim('(tenant optional if checked out)')}\n model [tenant] Show model structure (dimensions, variables)\n ${chalk.dim('--variables')} List all variables\n ${chalk.dim('--tables')} List all dimension tables\n ${chalk.dim('--variable <name>')} Show dimensions for variable\n\n${chalk.bold.underline('File Management')} ${chalk.dim('(farseer files <command>)')}\n files list [tenant] List files on remote\n ${chalk.dim('--all')} Show all files (not just scripts)\n\n${chalk.bold.underline('MCP Server')} ${chalk.dim('(AI assistant integration)')}\n mcp-server Start MCP server for Claude, Cursor, etc.\n\n${chalk.bold.underline('Examples')}\n ${chalk.green('$')} farseer login ${chalk.dim('Login via browser')}\n ${chalk.green('$')} farseer checkout salvus-2 salvus-prod ${chalk.dim('First time: org + tenant')}\n ${chalk.green('$')} farseer pull salvus-prod ${chalk.dim('Next time: just tenant')}\n ${chalk.green('$')} farseer push ${chalk.dim('If checked out: no args needed')}\n ${chalk.green('$')} farseer push -y ${chalk.dim('Push without confirmation')}\n ${chalk.green('$')} farseer run \"My App\" ${chalk.dim('Run app locally')}\n ${chalk.green('$')} farseer variables list ${chalk.dim('List all variables')}\n ${chalk.green('$')} farseer variable details \"Revenue\" ${chalk.dim('Show variable details')}\n ${chalk.green('$')} farseer dimensions list ${chalk.dim('List dimension tables')}\n`);\n\n// Register all commands (hidden from default help, shown in custom help above)\nregisterLoginCommand(program);\nregisterLogoutCommand(program);\nregisterCheckoutCommand(program);\nregisterConfigCommand(program);\nregisterListCommand(program);\nregisterFilesCommand(program);\nregisterAppCommand(program);\nregisterVariablesCommand(program);\nregisterDimensionsCommand(program);\nregisterModelCommand(program);\nregisterStatusCommand(program);\nregisterDiffCommand(program);\nregisterPullCommand(program);\nregisterPushCommand(program);\nregisterRunCommand(program);\nregisterInstallCommand(program);\nregisterWhoamiCommand(program);\nregisterMcpServerCommand(program);\n\n// Parse arguments\nprogram.parse();\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAaA,uBAAwB;AACxB,mBAAkB;AAClB,uBAA4B;AAC5B,mBAAqC;AACrC,oBAA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,aAAAA,QAAM,IAAI,2BAA2B,CAAC;AAAA,IAClG,aAAAA,QAAM,MAAM,GAAG,CAAC,4CAA4C,aAAAA,QAAM,IAAI,iBAAiB,CAAC;AAAA,IACxF,aAAAA,QAAM,MAAM,GAAG,CAAC,4CAA4C,aAAAA,QAAM,IAAI,oBAAoB,CAAC;AAAA,IAC3F,aAAAA,QAAM,MAAM,GAAG,CAAC,4CAA4C,aAAAA,QAAM,IAAI,uBAAuB,CAAC;AAAA,IAC9F,aAAAA,QAAM,MAAM,GAAG,CAAC,4CAA4C,aAAAA,QAAM,IAAI,uBAAuB,CAAC;AAAA,CACjG;AAAA,IAGD,mCAAqB,OAAO;AAAA,IAC5B,qCAAsB,OAAO;AAAA,IAC7B,yCAAwB,OAAO;AAAA,IAC/B,qCAAsB,OAAO;AAAA,IAC7B,iCAAoB,OAAO;AAAA,IAC3B,mCAAqB,OAAO;AAAA,IAC5B,+BAAmB,OAAO;AAAA,IAC1B,2CAAyB,OAAO;AAAA,IAChC,6CAA0B,OAAO;AAAA,IACjC,mCAAqB,OAAO;AAAA,IAC5B,qCAAsB,OAAO;AAAA,IAC7B,iCAAoB,OAAO;AAAA,IAC3B,iCAAoB,OAAO;AAAA,IAC3B,iCAAoB,OAAO;AAAA,IAC3B,+BAAmB,OAAO;AAAA,IAC1B,uCAAuB,OAAO;AAAA,IAC9B,qCAAsB,OAAO;AAAA,IAC7B,4CAAyB,OAAO;AAGhC,QAAQ,MAAM;",
6
6
  "names": ["chalk"]
7
7
  }
@@ -41,6 +41,10 @@ const copyAppSchema = {
41
41
  sourceApp: import_zod.z.string().describe("Name of app to copy"),
42
42
  newAppName: import_zod.z.string().describe("Name for the new app")
43
43
  };
44
+ const exportDataSchema = {
45
+ tenant: import_zod.z.string().describe("Tenant name"),
46
+ variableName: import_zod.z.string().describe("Variable to export")
47
+ };
44
48
  const debugSyncSchema = {
45
49
  tenant: import_zod.z.string().describe("Tenant name")
46
50
  };
@@ -251,7 +255,19 @@ main().catch(farseer.handleUnknownError);
251
255
  5. Push with farseer_push
252
256
  6. Create app with farseer_create_app
253
257
  7. Configure with farseer_configure_app
254
- 8. Test with farseer_run_app`
258
+ 8. Test with farseer_run_app
259
+
260
+ ALTERNATIVE: For simple imports without a script, use the farseer_create_import_job tool directly.
261
+ It handles the full workflow (create metadata, add rows, undo previous, commit) in a single call.
262
+ Use farseer_create_import_job when:
263
+ - Data is already available (no need to fetch from external source)
264
+ - The import is a one-time or simple operation
265
+ - You want to quickly import without creating a full script
266
+
267
+ Use a script when:
268
+ - Data comes from external sources (APIs, databases, files)
269
+ - Complex data transformation is needed
270
+ - The import runs on a schedule as an App`
255
271
  }
256
272
  }
257
273
  ]
@@ -309,6 +325,53 @@ Note: Do NOT include "_remote" for new apps - CLI adds it after first push.
309
325
  };
310
326
  }
311
327
  );
328
+ anyServer.prompt(
329
+ "export_data",
330
+ "Guide for exporting variable data from Farseer.",
331
+ exportDataSchema,
332
+ async (params) => {
333
+ const { tenant, variableName } = params;
334
+ return {
335
+ messages: [
336
+ {
337
+ role: "user",
338
+ content: {
339
+ type: "text",
340
+ text: `Exporting data for variable "${variableName}" from tenant "${tenant}".
341
+
342
+ Steps to follow:
343
+
344
+ 1. Use farseer_get_variable to understand the variable:
345
+ - What dimensions does it span?
346
+ - What is its data type?
347
+
348
+ 2. Choose export method:
349
+
350
+ **Option A: Quick export (farseer_export_variable_data)**
351
+ - Uses ExportApi.exportFormula() internally
352
+ - Returns CSV/JSON data inline
353
+ - Good for quick inspection or small datasets
354
+ - Use 'limit' parameter for large datasets
355
+
356
+ **Option B: Structured export (farseer_load_variable_data)**
357
+ - Uses data.loadFarseerVariable() internally
358
+ - Can specify which dimensions to include as columns
359
+ - Returns structured CSV data
360
+ - Good when you need specific dimension breakdowns
361
+
362
+ **Option C: CLI export (farseer variable export)**
363
+ - Saves CSV/JSON/XLSX to a local file
364
+ - Best for saving data locally for analysis
365
+
366
+ 3. For analysis:
367
+ - Parse the CSV data returned by the tools
368
+ - Summarize, filter, or transform as needed`
369
+ }
370
+ }
371
+ ]
372
+ };
373
+ }
374
+ );
312
375
  anyServer.prompt(
313
376
  "debug_sync_issues",
314
377
  "Troubleshoot synchronization problems between local and remote.",