farseer-cli 1.3.0 → 1.5.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 +102 -30
- package/dist/commands/checkout.js +3 -8
- package/dist/commands/checkout.js.map +2 -2
- package/dist/commands/dimensions.js +8 -8
- package/dist/commands/dimensions.js.map +2 -2
- package/dist/commands/model.js +29 -13
- package/dist/commands/model.js.map +2 -2
- package/dist/commands/pull.js +159 -46
- package/dist/commands/pull.js.map +2 -2
- package/dist/commands/push.js +185 -75
- package/dist/commands/push.js.map +2 -2
- package/dist/commands/run.js +31 -30
- package/dist/commands/run.js.map +2 -2
- package/dist/commands/status.js +26 -33
- package/dist/commands/status.js.map +2 -2
- package/dist/commands/variables.js +2 -2
- package/dist/commands/variables.js.map +2 -2
- package/dist/index.js +5 -3
- package/dist/index.js.map +2 -2
- package/dist/mcp/tools/appTools.js +6 -20
- package/dist/mcp/tools/appTools.js.map +2 -2
- package/dist/mcp/tools/authTools.js +2 -1
- package/dist/mcp/tools/authTools.js.map +2 -2
- package/dist/mcp/tools/cellTools.js +2 -10
- package/dist/mcp/tools/cellTools.js.map +2 -2
- package/dist/mcp/tools/dashboardTools.js +12 -23
- package/dist/mcp/tools/dashboardTools.js.map +2 -2
- package/dist/mcp/tools/dataTools.js +5 -16
- package/dist/mcp/tools/dataTools.js.map +2 -2
- package/dist/mcp/tools/folderTools.js +3 -11
- package/dist/mcp/tools/folderTools.js.map +2 -2
- package/dist/mcp/tools/modelTools.js +61 -69
- package/dist/mcp/tools/modelTools.js.map +2 -2
- package/dist/mcp/tools/runTools.js +3 -8
- package/dist/mcp/tools/runTools.js.map +2 -2
- package/dist/mcp/tools/sheetTools.js +11 -22
- package/dist/mcp/tools/sheetTools.js.map +2 -2
- package/dist/mcp/tools/syncTools.js +132 -47
- package/dist/mcp/tools/syncTools.js.map +2 -2
- package/dist/mcp/utils/helpers.js +2 -2
- package/dist/mcp/utils/helpers.js.map +2 -2
- package/dist/services/appSyncService.js +3 -2
- package/dist/services/appSyncService.js.map +2 -2
- package/dist/services/farseerApi.js +120 -72
- package/dist/services/farseerApi.js.map +2 -2
- package/dist/services/farseerFactory.js +1 -1
- package/dist/services/farseerFactory.js.map +2 -2
- package/dist/services/farseerService.js +87 -47
- package/dist/services/farseerService.js.map +2 -2
- package/dist/services/syncService.js +322 -182
- package/dist/services/syncService.js.map +3 -3
- package/dist/utils/cliOptions.js +36 -0
- package/dist/utils/cliOptions.js.map +7 -0
- package/dist/utils/errorFormatter.js +152 -0
- package/dist/utils/errorFormatter.js.map +7 -0
- package/dist/utils/fileLogger.js +13 -0
- package/dist/utils/fileLogger.js.map +2 -2
- package/dist/utils/fileValidation.js +180 -0
- package/dist/utils/fileValidation.js.map +7 -0
- package/dist/utils/helpers.js +85 -14
- package/dist/utils/helpers.js.map +2 -2
- package/docs/cli-guide.md +49 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -263,15 +263,21 @@ All sync commands use the checked-out tenant by default. You can specify a diffe
|
|
|
263
263
|
Download scripts and apps from Farseer instance.
|
|
264
264
|
|
|
265
265
|
```bash
|
|
266
|
-
# Pull for checked-out tenant
|
|
266
|
+
# Pull for checked-out tenant (asks before merging into a dirty tree)
|
|
267
267
|
farseer pull
|
|
268
268
|
|
|
269
|
+
# Skip the dirty-tree confirmation prompt
|
|
270
|
+
farseer pull -y
|
|
271
|
+
|
|
269
272
|
# Pull for specific tenant
|
|
270
273
|
farseer pull other-tenant
|
|
271
274
|
|
|
272
275
|
# Download all files (not just .ts/.js)
|
|
273
276
|
farseer pull --all
|
|
274
277
|
|
|
278
|
+
# Hard-reset local to match remote (overwrite edits, delete local-only)
|
|
279
|
+
farseer pull --force
|
|
280
|
+
|
|
275
281
|
# Pull scripts + specific extra extensions
|
|
276
282
|
farseer pull --include-ext .json --include-ext .txt
|
|
277
283
|
|
|
@@ -279,42 +285,96 @@ farseer pull --include-ext .json --include-ext .txt
|
|
|
279
285
|
farseer pull --include-folder Config --include-folder "App Logs"
|
|
280
286
|
```
|
|
281
287
|
|
|
282
|
-
**
|
|
283
|
-
1. Fetches
|
|
284
|
-
2. Downloads app configurations
|
|
285
|
-
3.
|
|
286
|
-
4.
|
|
287
|
-
5.
|
|
288
|
+
**Default behaviour:**
|
|
289
|
+
1. Fetches files from `Files/` folder on instance.
|
|
290
|
+
2. Downloads app configurations.
|
|
291
|
+
3. If local has uncommitted changes, **asks before merging** so it doesn't silently mix remote into your work in progress (use `-y` to skip the prompt).
|
|
292
|
+
4. Per-file conflict prompts when local and remote both moved — see [Conflict resolution](#conflict-resolution) below.
|
|
293
|
+
5. Saves to `farseer-apps/<tenant>/files/` and `farseer-apps/<tenant>/apps/`, creates `package.json` if missing, updates sync tracking file.
|
|
294
|
+
|
|
295
|
+
**`--force` (destructive):**
|
|
296
|
+
- Hard reset local to remote within the current sync scope: overwrites local edits, restores files you deleted locally, AND removes local-only files.
|
|
297
|
+
- Scope-aware: a default `pull --force` only mirrors scripts. Previously-pulled out-of-scope files (e.g. a `.csv` you grabbed once with `--include-ext .csv`) survive a default `pull --force` because they're invisible to this run. To wipe everything, pass `--all` or pass the same `--include-ext` / `--include-folder` flags you used to pull them.
|
|
298
|
+
- **Always asks for confirmation** — `-y` does NOT bypass this.
|
|
299
|
+
|
|
300
|
+
##### Conflict resolution
|
|
301
|
+
|
|
302
|
+
When `farseer pull` finds a file edited on BOTH sides, it prompts you per file. The choice list depends on the conflict type — both-modified gets the full menu, delete-vs-edit gets only the two choices that actually make sense.
|
|
303
|
+
|
|
304
|
+
**Both modified (or both newly added at the same path):**
|
|
305
|
+
|
|
306
|
+
| Choice | What happens |
|
|
307
|
+
|---|---|
|
|
308
|
+
| **Keep local version** | Your local file wins; sync state records that you've taken a stance, next push uploads your version. |
|
|
309
|
+
| **Use remote version (overwrite local)** | Remote wins; your local edit is discarded. |
|
|
310
|
+
| **Keep both (save remote as `.remote` file)** | Local stays untouched, remote version saved alongside as `<name>.remote.<ext>`. You decide later. |
|
|
311
|
+
| **Merge with markers (git-style)** | File is rewritten with `<<<<<<< LOCAL` / `=======` / `>>>>>>> REMOTE` blocks around both versions. Only offered for text files — binaries skip this option to avoid corruption. Open in your editor, pick what you want, remove the marker lines, then `farseer push`. The push pre-flight refuses any file that still contains LOCAL or REMOTE markers, so accidentally-unfinished resolves never reach the backend. |
|
|
312
|
+
|
|
313
|
+
**Locally modified, remote deleted** *(only two choices — there is no "remote version" to keep)*:
|
|
314
|
+
|
|
315
|
+
| Choice | What happens |
|
|
316
|
+
|---|---|
|
|
317
|
+
| **Keep local** | Your modified file stays; next push will recreate it on remote. |
|
|
318
|
+
| **Accept deletion** | Local file is removed to match remote. |
|
|
319
|
+
|
|
320
|
+
**Locally deleted, remote modified** *(mirror image — only two choices)*:
|
|
321
|
+
|
|
322
|
+
| Choice | What happens |
|
|
323
|
+
|---|---|
|
|
324
|
+
| **Keep deleted** | Stay deleted; next push will delete it on remote too. |
|
|
325
|
+
| **Restore remote version** | The remote version is downloaded back into your tree. |
|
|
326
|
+
|
|
327
|
+
After a `merge_markers` resolve, `farseer push` works without `--force` — the drift check sees only "local diverged from baseline" since the pull just ran. `--force` is only needed if someone else pushed AGAIN in the meantime.
|
|
288
328
|
|
|
289
329
|
#### `farseer push [tenant]`
|
|
290
330
|
|
|
291
331
|
Upload local changes to Farseer instance.
|
|
292
332
|
|
|
293
333
|
```bash
|
|
294
|
-
# Push changes
|
|
334
|
+
# Push changes (asks for confirmation by default)
|
|
295
335
|
farseer push
|
|
296
336
|
|
|
297
|
-
#
|
|
337
|
+
# Skip the confirmation prompt for non-destructive pushes
|
|
338
|
+
farseer push -y
|
|
339
|
+
|
|
340
|
+
# Mirror local → remote: overwrite drift AND delete remote-only files
|
|
298
341
|
farseer push --force
|
|
299
342
|
|
|
300
|
-
# Include extra file types in
|
|
343
|
+
# Include extra file types in the push set
|
|
301
344
|
farseer push --include-ext .json
|
|
302
345
|
```
|
|
303
346
|
|
|
304
|
-
**
|
|
305
|
-
1.
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
347
|
+
**Default behaviour:**
|
|
348
|
+
1. **Pre-flight** — refuses any local file the backend would refuse anyway:
|
|
349
|
+
- Extension not on the [backend whitelist](#sync-includes-extra-file-types).
|
|
350
|
+
- Filename longer than 256 chars or empty after trimming.
|
|
351
|
+
- File body empty (0 bytes — common cause of opaque `BadRequest`).
|
|
352
|
+
- Unresolved git-style merge markers (`<<<<<<< LOCAL` / `=======` / `>>>>>>> REMOTE`) left over from a `merge_markers` pull — see [Conflict resolution](#conflict-resolution).
|
|
353
|
+
|
|
354
|
+
Reported up-front in a single grouped section; nothing leaves your machine until those are fixed.
|
|
355
|
+
2. **Drift check** — if the remote has changes you haven't pulled (added or deleted files within your sync scope), push refuses and lists the exact files that are blocking, plus the matching `farseer pull` command (with the same `--include-ext` / `--include-folder` flags so it actually fetches them).
|
|
356
|
+
3. **Plan preview** — shows added/modified/deleted files (and any conflicts) using the same buckets `farseer status` shows. Asks for confirmation (`-y` skips).
|
|
357
|
+
4. Uploads/updates/deletes files on instance, then app configurations.
|
|
358
|
+
|
|
359
|
+
**Conflict-only push exits non-zero** — if every candidate file hits a service-side conflict (someone else edited the same file content), push prints `Push did nothing — N conflict(s) blocked the upload` and exits 1. CI scripts can branch on this.
|
|
360
|
+
|
|
361
|
+
**Out-of-scope files are invisible** — a `.json` or `.csv` next to your scripts won't be pushed under default `farseer push`. The push CLI does NOT have an `--all` flag (only `pull` and `status` do); broaden the push set with `--include-ext` / `--include-folder` instead. Hidden paths (any segment starting with `.`, like `.vscode/`) are skipped even by `pull --all` — they require explicit `--include-folder .vscode` to be picked up, on either side.
|
|
362
|
+
|
|
363
|
+
**`--force` (destructive — true mirror):**
|
|
364
|
+
- Skips the drift check AND deletes remote files that have no local counterpart (within the scope you declared via `--include-ext` / `--include-folder`).
|
|
365
|
+
- **Always asks for confirmation** — `-y` does NOT bypass this.
|
|
309
366
|
|
|
310
367
|
#### `farseer status [tenant]`
|
|
311
368
|
|
|
312
369
|
Compare local files with remote instance.
|
|
313
370
|
|
|
314
371
|
```bash
|
|
315
|
-
#
|
|
372
|
+
# Fast (default): list-only, trusts the last sync for remote-side state
|
|
316
373
|
farseer status
|
|
317
374
|
|
|
375
|
+
# Deep: also hashes remote contents to detect remote-side edits
|
|
376
|
+
farseer status --deep
|
|
377
|
+
|
|
318
378
|
# Check all files
|
|
319
379
|
farseer status --all
|
|
320
380
|
|
|
@@ -322,23 +382,30 @@ farseer status --all
|
|
|
322
382
|
farseer status --include-ext .json --include-folder Config
|
|
323
383
|
```
|
|
324
384
|
|
|
325
|
-
Output
|
|
385
|
+
Output uses explicit add/modify/delete buckets per side, so a deletion never shows up as `M`:
|
|
386
|
+
|
|
326
387
|
```
|
|
327
|
-
Comparing local with remote...
|
|
388
|
+
Comparing local (apps/<tenant>/files/) with remote (Files/)...
|
|
328
389
|
|
|
329
|
-
|
|
390
|
+
Local changes:
|
|
391
|
+
+ Scripts/new-script.ts
|
|
330
392
|
M Scripts/import-sales.ts
|
|
393
|
+
- Scripts/old-helper.ts
|
|
331
394
|
|
|
332
|
-
|
|
333
|
-
|
|
395
|
+
Remote changes:
|
|
396
|
+
+ Data/from-other-dev.xlsx
|
|
397
|
+
M Scripts/sync-actuals.ts (by Matej)
|
|
398
|
+
- Scripts/legacy.ts
|
|
334
399
|
|
|
335
|
-
|
|
336
|
-
+ Scripts/new-script.ts
|
|
337
|
-
|
|
338
|
-
Only on remote:
|
|
339
|
-
- Data/old-file.xlsx
|
|
400
|
+
Run with --deep to also check for remote-side content edits.
|
|
340
401
|
```
|
|
341
402
|
|
|
403
|
+
Remote-modified entries pick up a `(by <name>)` suffix when the recorded sync metadata knows who last uploaded the file; everything else is bare `+` / `M` / `-`. The legend is consistent across `status` and the `push` plan preview.
|
|
404
|
+
|
|
405
|
+
In default fast mode the engine trusts the recorded baseline for remote — it can detect remote adds and deletes from the listing alone, but **not** remote-side content edits. Pass `--deep` when you want every remote file hashed.
|
|
406
|
+
|
|
407
|
+
`farseer status` and the preview that `farseer push` shows before its confirmation prompt come from the same status engine, so they always agree on which files are added / modified / deleted. If status says nothing is changed, push will say "Nothing to push"; if status lists three modified files, push lists the same three.
|
|
408
|
+
|
|
342
409
|
#### `farseer diff [tenant] [file]`
|
|
343
410
|
|
|
344
411
|
Show file differences.
|
|
@@ -562,9 +629,9 @@ Once configured, AI assistants have access to:
|
|
|
562
629
|
- `farseer_checkout_clear` - Clear default tenant
|
|
563
630
|
|
|
564
631
|
**Sync Operations:**
|
|
565
|
-
- `farseer_pull` - Pull scripts and apps from remote
|
|
566
|
-
- `farseer_push` - Push local changes to remote
|
|
567
|
-
- `farseer_status` - Compare local vs remote state
|
|
632
|
+
- `farseer_pull` - Pull scripts and apps from remote. `force=true` overwrites local edits with remote on conflicts (does NOT wipe local-only files — that destructive step lives behind the CLI's interactive confirm; use `farseer pull --force` from a shell when you actually want a hard reset). Per-file conflict resolutions (keep_local / keep_remote / keep_both / merge_markers) are CLI-only because they require an interactive prompt; the MCP path either lets the conflict bubble up in the response (`conflicts[]` field) or `force=true` to overwrite.
|
|
633
|
+
- `farseer_push` - Push local changes to remote. `force=true` skips the drift check; `mirror=true` (separate parameter) also deletes remote files that have no local counterpart. The two are independent — combine when you want both. Returns `files.rejected[]` for any files the backend pre-flight refused (extension whitelist, name length, empty body, unresolved git-style conflict markers from a prior `merge_markers` pull). If every candidate was rejected and nothing was uploaded/updated/deleted, the call returns `VALIDATION_ERROR` instead of a silent no-op success.
|
|
634
|
+
- `farseer_status` - Compare local vs remote state. Default (fast) mode trusts the recorded baseline for remote-side state; pass `deep=true` to also hash every remote file and detect content edits made since last pull. The fast-mode response is **byte-for-byte the same** view that `farseer push` shows in its confirmation preview — the two commands are guaranteed not to disagree.
|
|
568
635
|
- `farseer_diff` - Show file differences
|
|
569
636
|
- `farseer_list_files` - List remote files
|
|
570
637
|
|
|
@@ -733,7 +800,12 @@ apps/
|
|
|
733
800
|
|
|
734
801
|
### Sync Includes (Extra File Types)
|
|
735
802
|
|
|
736
|
-
By default, `pull`/`push`/`status` only sync script files (`.ts`, `.js
|
|
803
|
+
By default, `pull`/`push`/`status` only sync script files (`.ts`, `.js`). To broaden the set:
|
|
804
|
+
- `pull --all` / `status --all` syncs everything (push CLI does not have `--all`; use `--include-ext` / `--include-folder` to broaden a push).
|
|
805
|
+
- `--include-ext <ext>` / `--include-folder <folder>` adds inline scope to a single command (works on all four sync verbs: pull, push, status, checkout).
|
|
806
|
+
- Persistent includes via `farseer config include` (below) apply to every run without re-typing the flags.
|
|
807
|
+
|
|
808
|
+
**Hidden files** (anything with a path segment starting with `.` — `.env`, `.git/`, `.vscode/`, …) require **explicit opt-in** via `--include-ext` or `--include-folder` even under `--all`. This protects against a stray credential file in the working tree leaking on a force push. The CLI never picks them up just because they happen to have a whitelisted extension.
|
|
737
809
|
|
|
738
810
|
**Persistent config (set once, always applies):**
|
|
739
811
|
|
|
@@ -38,10 +38,11 @@ var import_farseerFactory = require("../services/farseerFactory");
|
|
|
38
38
|
var import_syncService = require("../services/syncService");
|
|
39
39
|
var import_appSyncService = require("../services/appSyncService");
|
|
40
40
|
var import_helpers = require("../utils/helpers");
|
|
41
|
+
var import_cliOptions = require("../utils/cliOptions");
|
|
41
42
|
var fs = __toESM(require("fs"));
|
|
42
43
|
var path = __toESM(require("path"));
|
|
43
44
|
function registerCheckoutCommand(program) {
|
|
44
|
-
program.command("checkout [org] [tenant]").description("Set default tenant for commands (runs auth check and pull)").option("--no-pull", "Skip automatic pull").option("--clear", "Clear current checkout").option("--include-ext <ext>", "Include extra file extension for pull (repeatable)", collectValues, []).option("--include-folder <folder>", "Include all files in folder for pull (repeatable)", collectValues, []).action(async (first, second, options) => {
|
|
45
|
+
program.command("checkout [org] [tenant]").description("Set default tenant for commands (runs auth check and pull)").option("--no-pull", "Skip automatic pull").option("--clear", "Clear current checkout").option("--include-ext <ext>", "Include extra file extension for pull (repeatable)", import_cliOptions.collectValues, []).option("--include-folder <folder>", "Include all files in folder for pull (repeatable)", import_cliOptions.collectValues, []).action(async (first, second, options) => {
|
|
45
46
|
if (options.clear) {
|
|
46
47
|
(0, import_configService.clearCurrentTenant)();
|
|
47
48
|
import_logger.logger.success("Checkout cleared. You now need to specify tenant for each command.");
|
|
@@ -91,7 +92,7 @@ function registerCheckoutCommand(program) {
|
|
|
91
92
|
if (!fs.existsSync(packageJsonPath)) {
|
|
92
93
|
createDefaultPackageJson(tenant, packageJsonPath);
|
|
93
94
|
}
|
|
94
|
-
const includeExtensions = normalizeExtensions(options.includeExt);
|
|
95
|
+
const includeExtensions = (0, import_cliOptions.normalizeExtensions)(options.includeExt);
|
|
95
96
|
const includeFolders = options.includeFolder;
|
|
96
97
|
const result = await syncService.pull({
|
|
97
98
|
all: false,
|
|
@@ -123,12 +124,6 @@ function registerCheckoutCommand(program) {
|
|
|
123
124
|
import_logger.logger.dim(" farseer push");
|
|
124
125
|
});
|
|
125
126
|
}
|
|
126
|
-
function collectValues(value, previous) {
|
|
127
|
-
return previous.concat([value]);
|
|
128
|
-
}
|
|
129
|
-
function normalizeExtensions(exts) {
|
|
130
|
-
return exts.map((ext) => ext.startsWith(".") ? ext.toLowerCase() : `.${ext.toLowerCase()}`);
|
|
131
|
-
}
|
|
132
127
|
function createDefaultPackageJson(tenant, packageJsonPath) {
|
|
133
128
|
const packageJson = {
|
|
134
129
|
name: `farseer-${tenant}`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/checkout.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport {\n getCurrentCheckout,\n setCurrentCheckout,\n clearCurrentTenant,\n saveTenantOrgMapping,\n} from '../services/configService';\nimport { getFarseerClientWithFallback, showLoginPrompt } from '../services/farseerFactory';\nimport { SyncService } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport { getTenantDir, ensureDirectoryExists } from '../utils/helpers';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nexport function registerCheckoutCommand(program: Command): void {\n program\n .command('checkout [org] [tenant]')\n .description('Set default tenant for commands (runs auth check and pull)')\n .option('--no-pull', 'Skip automatic pull')\n .option('--clear', 'Clear current checkout')\n .option('--include-ext <ext>', 'Include extra file extension for pull (repeatable)', collectValues, [])\n .option('--include-folder <folder>', 'Include all files in folder for pull (repeatable)', collectValues, [])\n .action(async (first, second, options) => {\n // Handle --clear flag\n if (options.clear) {\n clearCurrentTenant();\n logger.success('Checkout cleared. You now need to specify tenant for each command.');\n return;\n }\n\n // If no arguments specified, show current checkout status\n if (!first) {\n const current = getCurrentCheckout();\n if (current) {\n if (current.organisation === current.tenant) {\n logger.info(`Currently checked out: ${chalk.bold(current.tenant)}`);\n } else {\n logger.info(\n `Currently checked out: ${chalk.bold(current.tenant)} (org: ${chalk.bold(current.organisation)})`,\n );\n }\n logger.dim('Run \"farseer checkout <tenant>\" to switch tenants.');\n logger.dim('Run \"farseer checkout --clear\" to clear checkout.');\n } else {\n logger.info('No tenant currently checked out.');\n logger.dim('Run \"farseer checkout <tenant>\" to set a default tenant.');\n logger.dim('Run \"farseer checkout <org> <tenant>\" if organisation and tenant differ.');\n }\n return;\n }\n\n // Determine organisation and tenant\n // If two arguments: first=organisation, second=tenant\n // If one argument: organisation=tenant=first\n const organisation = second ? first : first;\n const tenant = second || first;\n\n logger.info(`Checking out tenant: ${chalk.bold(tenant)} (org: ${chalk.bold(organisation)})...`);\n console.log();\n\n // Step 1: Verify authentication\n logger.info('Verifying authentication...');\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!clientResult) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const authLabel = clientResult.authType === 'apiKey' ? 'API key' : 'browser login';\n logger.success(`Authenticated (using ${authLabel})`);\n\n // Step 2: Set as current checkout and save org-tenant mapping\n setCurrentCheckout(organisation, tenant);\n saveTenantOrgMapping(tenant, organisation);\n\n // Step 3: Auto-pull (unless --no-pull)\n if (options.pull) {\n console.log();\n logger.info('Pulling latest files and apps...');\n\n const syncService = new SyncService(tenant, clientResult.client);\n const tenantDir = getTenantDir(tenant);\n ensureDirectoryExists(tenantDir);\n\n try {\n // Ensure package.json exists\n const packageJsonPath = path.join(tenantDir, 'package.json');\n if (!fs.existsSync(packageJsonPath)) {\n createDefaultPackageJson(tenant, packageJsonPath);\n }\n\n // Pull files (scripts + includes by default)\n const includeExtensions = normalizeExtensions(options.includeExt);\n const includeFolders = options.includeFolder as string[];\n const result = await syncService.pull({\n all: false,\n includeExtensions: includeExtensions.length > 0 ? includeExtensions : undefined,\n includeFolders: includeFolders.length > 0 ? includeFolders : undefined,\n });\n logger.dim(\n `Files: +${result.downloaded.length} -${result.deleted.length} (${result.unchanged.length} unchanged)`,\n );\n\n // Pull apps\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n const appResult = await appSyncService.pull();\n logger.dim(\n `Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length} (${appResult.unchanged.length} unchanged)`,\n );\n\n logger.success('Pull complete!');\n } catch (error) {\n logger.warning('Pull failed, but checkout is complete.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n }\n }\n\n // Final message\n console.log();\n logger.success(`Tenant ${chalk.bold(tenant)} is now checked out.`);\n logger.dim('You can now run commands without specifying the tenant:');\n logger.dim(' farseer status');\n logger.dim(' farseer model --variables');\n logger.dim(' farseer apps');\n logger.dim(' farseer push');\n });\n}\n\nfunction
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,oBAAuB;AACvB,2BAKO;AACP,4BAA8D;AAC9D,yBAA4B;AAC5B,4BAA+B;AAC/B,qBAAoD;AACpD,SAAoB;AACpB,WAAsB;AAEf,SAAS,wBAAwB,SAAwB;AAC5D,UACK,QAAQ,yBAAyB,EACjC,YAAY,4DAA4D,EACxE,OAAO,aAAa,qBAAqB,EACzC,OAAO,WAAW,wBAAwB,EAC1C,OAAO,uBAAuB,sDAAsD,
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport {\n getCurrentCheckout,\n setCurrentCheckout,\n clearCurrentTenant,\n saveTenantOrgMapping,\n} from '../services/configService';\nimport { getFarseerClientWithFallback, showLoginPrompt } from '../services/farseerFactory';\nimport { SyncService } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport { getTenantDir, ensureDirectoryExists } from '../utils/helpers';\nimport { collectValues, normalizeExtensions } from '../utils/cliOptions';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nexport function registerCheckoutCommand(program: Command): void {\n program\n .command('checkout [org] [tenant]')\n .description('Set default tenant for commands (runs auth check and pull)')\n .option('--no-pull', 'Skip automatic pull')\n .option('--clear', 'Clear current checkout')\n .option('--include-ext <ext>', 'Include extra file extension for pull (repeatable)', collectValues, [])\n .option('--include-folder <folder>', 'Include all files in folder for pull (repeatable)', collectValues, [])\n .action(async (first, second, options) => {\n // Handle --clear flag\n if (options.clear) {\n clearCurrentTenant();\n logger.success('Checkout cleared. You now need to specify tenant for each command.');\n return;\n }\n\n // If no arguments specified, show current checkout status\n if (!first) {\n const current = getCurrentCheckout();\n if (current) {\n if (current.organisation === current.tenant) {\n logger.info(`Currently checked out: ${chalk.bold(current.tenant)}`);\n } else {\n logger.info(\n `Currently checked out: ${chalk.bold(current.tenant)} (org: ${chalk.bold(current.organisation)})`,\n );\n }\n logger.dim('Run \"farseer checkout <tenant>\" to switch tenants.');\n logger.dim('Run \"farseer checkout --clear\" to clear checkout.');\n } else {\n logger.info('No tenant currently checked out.');\n logger.dim('Run \"farseer checkout <tenant>\" to set a default tenant.');\n logger.dim('Run \"farseer checkout <org> <tenant>\" if organisation and tenant differ.');\n }\n return;\n }\n\n // Determine organisation and tenant\n // If two arguments: first=organisation, second=tenant\n // If one argument: organisation=tenant=first\n const organisation = second ? first : first;\n const tenant = second || first;\n\n logger.info(`Checking out tenant: ${chalk.bold(tenant)} (org: ${chalk.bold(organisation)})...`);\n console.log();\n\n // Step 1: Verify authentication\n logger.info('Verifying authentication...');\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!clientResult) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const authLabel = clientResult.authType === 'apiKey' ? 'API key' : 'browser login';\n logger.success(`Authenticated (using ${authLabel})`);\n\n // Step 2: Set as current checkout and save org-tenant mapping\n setCurrentCheckout(organisation, tenant);\n saveTenantOrgMapping(tenant, organisation);\n\n // Step 3: Auto-pull (unless --no-pull)\n if (options.pull) {\n console.log();\n logger.info('Pulling latest files and apps...');\n\n const syncService = new SyncService(tenant, clientResult.client);\n const tenantDir = getTenantDir(tenant);\n ensureDirectoryExists(tenantDir);\n\n try {\n // Ensure package.json exists\n const packageJsonPath = path.join(tenantDir, 'package.json');\n if (!fs.existsSync(packageJsonPath)) {\n createDefaultPackageJson(tenant, packageJsonPath);\n }\n\n // Pull files (scripts + includes by default)\n const includeExtensions = normalizeExtensions(options.includeExt);\n const includeFolders = options.includeFolder as string[];\n const result = await syncService.pull({\n all: false,\n includeExtensions: includeExtensions.length > 0 ? includeExtensions : undefined,\n includeFolders: includeFolders.length > 0 ? includeFolders : undefined,\n });\n logger.dim(\n `Files: +${result.downloaded.length} -${result.deleted.length} (${result.unchanged.length} unchanged)`,\n );\n\n // Pull apps\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n const appResult = await appSyncService.pull();\n logger.dim(\n `Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length} (${appResult.unchanged.length} unchanged)`,\n );\n\n logger.success('Pull complete!');\n } catch (error) {\n logger.warning('Pull failed, but checkout is complete.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n }\n }\n\n // Final message\n console.log();\n logger.success(`Tenant ${chalk.bold(tenant)} is now checked out.`);\n logger.dim('You can now run commands without specifying the tenant:');\n logger.dim(' farseer status');\n logger.dim(' farseer model --variables');\n logger.dim(' farseer apps');\n logger.dim(' farseer push');\n });\n}\n\nfunction createDefaultPackageJson(tenant: string, packageJsonPath: string): void {\n const packageJson = {\n name: `farseer-${tenant}`,\n version: '1.0.0',\n description: `Farseer scripts for ${tenant}`,\n type: 'module',\n scripts: {\n build: 'tsc',\n },\n dependencies: {\n 'farseer-client':\n 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client/release-1.4.5.tar',\n arquero: '^7.0.1',\n xlsx: '^0.18.5',\n xmldom: '^0.6.0',\n },\n devDependencies: {\n '@types/node': '^22.5.0',\n '@types/xmldom': '^0.1.34',\n 'ts-node': '^10.9.2',\n typescript: '^5.5.4',\n },\n };\n\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8');\n logger.dim(`Created package.json for ${tenant}`);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,oBAAuB;AACvB,2BAKO;AACP,4BAA8D;AAC9D,yBAA4B;AAC5B,4BAA+B;AAC/B,qBAAoD;AACpD,wBAAmD;AACnD,SAAoB;AACpB,WAAsB;AAEf,SAAS,wBAAwB,SAAwB;AAC5D,UACK,QAAQ,yBAAyB,EACjC,YAAY,4DAA4D,EACxE,OAAO,aAAa,qBAAqB,EACzC,OAAO,WAAW,wBAAwB,EAC1C,OAAO,uBAAuB,sDAAsD,iCAAe,CAAC,CAAC,EACrG,OAAO,6BAA6B,qDAAqD,iCAAe,CAAC,CAAC,EAC1G,OAAO,OAAO,OAAO,QAAQ,YAAY;AAEtC,QAAI,QAAQ,OAAO;AACf,mDAAmB;AACnB,2BAAO,QAAQ,oEAAoE;AACnF;AAAA,IACJ;AAGA,QAAI,CAAC,OAAO;AACR,YAAM,cAAU,yCAAmB;AACnC,UAAI,SAAS;AACT,YAAI,QAAQ,iBAAiB,QA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SAAS;AAAA,MACT,MAAM;AAAA,MACN,QAAQ;AAAA,IACZ;AAAA,IACA,iBAAiB;AAAA,MACb,eAAe;AAAA,MACf,iBAAiB;AAAA,MACjB,WAAW;AAAA,MACX,YAAY;AAAA,IAChB;AAAA,EACJ;AAEA,KAAG,cAAc,iBAAiB,KAAK,UAAU,aAAa,MAAM,CAAC,GAAG,OAAO;AAC/E,uBAAO,IAAI,4BAA4B,MAAM,EAAE;AACnD;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
|
@@ -47,11 +47,10 @@ function registerDimensionsCommand(program) {
|
|
|
47
47
|
process.exit(1);
|
|
48
48
|
}
|
|
49
49
|
try {
|
|
50
|
-
const model = await result.client.exportModel();
|
|
50
|
+
const model = await result.client.exportModel({ types: ["DTAB"] });
|
|
51
51
|
if (options.json) {
|
|
52
52
|
const tablesInfo = model.tables.map((t) => ({
|
|
53
53
|
name: t.name,
|
|
54
|
-
memberCount: t.rows.length,
|
|
55
54
|
columns: t.columns,
|
|
56
55
|
folderPath: t.folderPath
|
|
57
56
|
}));
|
|
@@ -62,12 +61,13 @@ function registerDimensionsCommand(program) {
|
|
|
62
61
|
console.log();
|
|
63
62
|
for (const table of model.tables) {
|
|
64
63
|
const fkColumns = table.columns.filter((c) => c.type === "FOREIGN_KEY");
|
|
65
|
-
let info = ` ${import_chalk.default.bold(table.name)}
|
|
64
|
+
let info = ` ${import_chalk.default.bold(table.name)}`;
|
|
66
65
|
if (fkColumns.length > 0) {
|
|
67
66
|
info += import_chalk.default.cyan(` -> ${fkColumns.map((c) => c.foreignKeyTableName).join(", ")}`);
|
|
68
67
|
}
|
|
69
68
|
console.log(info);
|
|
70
69
|
}
|
|
70
|
+
import_logger.logger.dim("Run `farseer dimension details <name>` to see members for a specific table.");
|
|
71
71
|
} catch (error) {
|
|
72
72
|
handleModelError(error, tenant);
|
|
73
73
|
}
|
|
@@ -81,14 +81,14 @@ function registerDimensionsCommand(program) {
|
|
|
81
81
|
process.exit(1);
|
|
82
82
|
}
|
|
83
83
|
try {
|
|
84
|
-
const
|
|
85
|
-
const table = model.tables.find((t) => t.name.toLowerCase() === name.toLowerCase());
|
|
84
|
+
const table = await result.client.loadDimensionTableWithMembers(name);
|
|
86
85
|
if (!table) {
|
|
87
86
|
import_logger.logger.error(`Table "${name}" not found.`);
|
|
87
|
+
const tablesOnly = await result.client.exportModel({ types: ["DTAB"] });
|
|
88
88
|
import_logger.logger.dim("Available tables:");
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
import_logger.logger.dim(` ... and ${
|
|
89
|
+
tablesOnly.tables.slice(0, 10).forEach((t) => import_logger.logger.dim(` - ${t.name}`));
|
|
90
|
+
if (tablesOnly.tables.length > 10) {
|
|
91
|
+
import_logger.logger.dim(` ... and ${tablesOnly.tables.length - 10} more`);
|
|
92
92
|
}
|
|
93
93
|
process.exit(1);
|
|
94
94
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/dimensions.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport * as fs from 'fs';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport {\n getFarseerClientWithFallback,\n getNativeFarseerClient,\n showLoginPrompt,\n isAuthError,\n} from '../services/farseerFactory';\nimport { resolveTenantWithOrgMapping } from '../utils/helpers';\nimport { EntityType } from 'farseer-client';\n\nexport function registerDimensionsCommand(program: Command): void {\n // farseer dimensions list\n const dimensionsCmd = program.command('dimensions').description('List and manage dimension tables');\n\n dimensionsCmd\n .command('list [org] [tenant]')\n .description('List all dimension tables')\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 const tablesInfo = model.tables.map((t) => ({\n name: t.name,\n memberCount: t.rows.length,\n columns: t.columns,\n folderPath: t.folderPath,\n }));\n console.log(JSON.stringify(tablesInfo, null, 2));\n return;\n }\n\n logger.header(`Dimension Tables (${model.tables.length})`);\n console.log();\n for (const table of model.tables) {\n const fkColumns = table.columns.filter((c) => c.type === 'FOREIGN_KEY');\n let info = ` ${chalk.bold(table.name)} ${chalk.dim(`(${table.rows.length} members)`)}`;\n if (fkColumns.length > 0) {\n info += chalk.cyan(` -> ${fkColumns.map((c) => c.foreignKeyTableName).join(', ')}`);\n }\n console.log(info);\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer dimension details (singular)\n const dimensionCmd = program.command('dimension').description('Dimension table details');\n\n dimensionCmd\n .command('details <name>')\n .description('Show dimension table details (columns, members)')\n .option('--json', 'Output raw JSON')\n .option('--members <n>', 'Number of sample members to show', '10')\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 table = model.tables.find((t) => t.name.toLowerCase() === name.toLowerCase());\n\n if (!table) {\n logger.error(`Table \"${name}\" not found.`);\n logger.dim('Available tables:');\n model.tables.slice(0, 10).forEach((t) => logger.dim(` - ${t.name}`));\n if (model.tables.length > 10) {\n logger.dim(` ... and ${model.tables.length - 10} more`);\n }\n process.exit(1);\n }\n\n if (options.json) {\n console.log(JSON.stringify(table, null, 2));\n return;\n }\n\n const memberLimit = parseInt(options.members) || 10;\n\n logger.header(`Dimension Table: ${table.name}`);\n console.log();\n console.log(` Columns:`);\n table.columns.forEach((col, i) => {\n let colInfo = ` ${i + 1}. ${chalk.bold(col.type)}`;\n if (col.name) colInfo += ` (${col.name})`;\n if (col.foreignKeyTableName) colInfo += chalk.cyan(` -> ${col.foreignKeyTableName}`);\n console.log(colInfo);\n });\n console.log(` Members: ${table.rows.length}`);\n if (table.folderPath) {\n console.log(` Folder: ${table.folderPath.join(' / ')}`);\n }\n if (table.rows.length > 0) {\n console.log();\n console.log(` Sample members (first ${Math.min(memberLimit, table.rows.length)}):`);\n table.rows.slice(0, memberLimit).forEach((row) => {\n console.log(` - ${row[0]}`);\n });\n if (table.rows.length > memberLimit) {\n logger.dim(` ... and ${table.rows.length - memberLimit} more`);\n }\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer dimensions members <tableName> [org] [tenant]\n dimensionsCmd\n .command('members <tableName> [org] [tenant]')\n .description('List all members of a dimension table')\n .option('--json', 'Output raw JSON')\n .option('--limit <n>', 'Limit number of members shown', parseInt)\n .option('--output <file>', 'Export members to CSV file')\n .action(async (tableName, first, second, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(first, second);\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n\n if (!nativeClient) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n await nativeClient.initTagMap();\n const members = await nativeClient.getDimensionMembersForTable(tableName);\n\n // CSV export\n if (options.output) {\n const csvLines = ['id,name,parentId'];\n for (const m of members) {\n const name = m.name.includes(',') ? `\"${m.name}\"` : m.name;\n csvLines.push(`${m.id},${name},${m.ParentId ?? ''}`);\n }\n fs.writeFileSync(options.output, csvLines.join('\\n'), 'utf-8');\n logger.success(`Exported ${members.length} members to ${options.output}`);\n return;\n }\n\n if (options.json) {\n const result = members.map((m) => ({\n id: m.id,\n name: m.name,\n parentId: m.ParentId,\n }));\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n const limit = options.limit || members.length;\n logger.header(`Members of \"${tableName}\" (${members.length})`);\n const display = members.slice(0, limit);\n for (const m of display) {\n const parentInfo = m.ParentId ? chalk.dim(` (parent: ${m.ParentId})`) : '';\n console.log(` ${chalk.dim(String(m.id).padEnd(8))} ${m.name}${parentInfo}`);\n }\n if (members.length > limit) {\n logger.dim(` ... and ${members.length - limit} more`);\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer dimensions create-member [org] [tenant]\n dimensionsCmd\n .command('create-member [org] [tenant]')\n .description('Create a new dimension member')\n .requiredOption('--table <name>', 'Dimension table name')\n .requiredOption('--name <name>', 'New member name')\n .option('--parent <name>', 'Parent member name')\n .action(async (first, second, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(first, second);\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n\n if (!nativeClient) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n await nativeClient.initTagMap();\n const table = await nativeClient.getDimensionTable(options.table);\n\n const createEntity: any = {\n type: EntityType.DimensionMember,\n meta: { name: options.name },\n relations: {\n parent: {\n key: { id: table.id, type: EntityType.DimensionTable },\n order: 0,\n },\n },\n dimensionMember: { data: {} },\n };\n\n if (options.parent) {\n const parentMember = await nativeClient.getDimensionMember(options.table, options.parent);\n createEntity.relations.parent = {\n key: { id: parentMember.id, type: EntityType.DimensionMember },\n order: 0,\n };\n }\n\n const result = await nativeClient.entities.mutate({ created: [createEntity] });\n logger.success(`Created dimension member \"${options.name}\" in table \"${options.table}\".`);\n if ((result as any).created?.length > 0) {\n logger.dim(` ID: ${(result as any).created[0].id}`);\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer dimensions delete-member [org] [tenant]\n dimensionsCmd\n .command('delete-member [org] [tenant]')\n .description('Delete a dimension member')\n .requiredOption('--table <name>', 'Dimension table name')\n .requiredOption('--name <name>', 'Member name to delete')\n .option('-y, --yes', 'Skip confirmation')\n .action(async (first, second, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(first, second);\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n\n if (!nativeClient) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n await nativeClient.initTagMap();\n const member = await nativeClient.getDimensionMember(options.table, options.name);\n\n if (!options.yes) {\n logger.warning(\n `This will delete member \"${options.name}\" (ID: ${member.id}) from table \"${options.table}\".`,\n );\n logger.dim('Use -y to skip confirmation.');\n process.exit(0);\n }\n\n await nativeClient.entities.mutate({\n deleted: [{ id: member.id, type: EntityType.DimensionMember }],\n });\n logger.success(`Deleted dimension member \"${options.name}\" from table \"${options.table}\".`);\n } catch (error) {\n handleModelError(error, tenant);\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(errorMessage);\n }\n process.exit(1);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAoB;AACpB,mBAAkB;AAClB,oBAAuB;AACvB,4BAKO;AACP,qBAA4C;AAC5C,4BAA2B;AAEpB,SAAS,0BAA0B,SAAwB;AAE9D,QAAM,gBAAgB,QAAQ,QAAQ,YAAY,EAAE,YAAY,kCAAkC;AAElG,gBACK,QAAQ,qBAAqB,EAC7B,YAAY,2BAA2B,EACvC,OAAO,UAAU,iBAAiB,EAClC,OAAO,OAAO,OAAO,QAAQ,YAAY;AACtC,UAAM,EAAE,cAAc,OAAO,QAAI,4CAA4B,OAAO,MAAM;AAC1E,UAAM,SAAS,UAAM,oDAA6B,cAAc,MAAM;AAEtE,QAAI,CAAC,QAAQ;AACT,iDAAgB,MAAM;AACtB,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,QAAI;
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport * as fs from 'fs';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport {\n getFarseerClientWithFallback,\n getNativeFarseerClient,\n showLoginPrompt,\n isAuthError,\n} from '../services/farseerFactory';\nimport { resolveTenantWithOrgMapping } from '../utils/helpers';\nimport { EntityType } from 'farseer-client';\n\nexport function registerDimensionsCommand(program: Command): void {\n // farseer dimensions list\n const dimensionsCmd = program.command('dimensions').description('List and manage dimension tables');\n\n dimensionsCmd\n .command('list [org] [tenant]')\n .description('List all dimension tables')\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 // DTAB-only \u2014 pulling members for every dimension breaks\n // the response limit on large tenants. Member counts come\n // from `dimension details`.\n const model = await result.client.exportModel({ types: ['DTAB'] });\n\n if (options.json) {\n const tablesInfo = model.tables.map((t) => ({\n name: t.name,\n columns: t.columns,\n folderPath: t.folderPath,\n }));\n console.log(JSON.stringify(tablesInfo, null, 2));\n return;\n }\n\n logger.header(`Dimension Tables (${model.tables.length})`);\n console.log();\n for (const table of model.tables) {\n const fkColumns = table.columns.filter((c) => c.type === 'FOREIGN_KEY');\n let info = ` ${chalk.bold(table.name)}`;\n if (fkColumns.length > 0) {\n info += chalk.cyan(` -> ${fkColumns.map((c) => c.foreignKeyTableName).join(', ')}`);\n }\n console.log(info);\n }\n logger.dim('Run `farseer dimension details <name>` to see members for a specific table.');\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer dimension details (singular)\n const dimensionCmd = program.command('dimension').description('Dimension table details');\n\n dimensionCmd\n .command('details <name>')\n .description('Show dimension table details (columns, members)')\n .option('--json', 'Output raw JSON')\n .option('--members <n>', 'Number of sample members to show', '10')\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 // Use the dedicated entities-API path to fetch one\n // table's members. `/model/export` with `tableGids`\n // would be the \"obvious\" choice, but on large tenants\n // we see 500s for some tables there (rama-side\n // scoping bug, tracked separately). The entities path\n // is single-table by construction and known-good.\n const table = await result.client.loadDimensionTableWithMembers(name);\n\n if (!table) {\n logger.error(`Table \"${name}\" not found.`);\n // Re-fetch the list to suggest available tables.\n // Cheap \u2014 DTAB-only.\n const tablesOnly = await result.client.exportModel({ types: ['DTAB'] });\n logger.dim('Available tables:');\n tablesOnly.tables.slice(0, 10).forEach((t) => logger.dim(` - ${t.name}`));\n if (tablesOnly.tables.length > 10) {\n logger.dim(` ... and ${tablesOnly.tables.length - 10} more`);\n }\n process.exit(1);\n }\n\n if (options.json) {\n console.log(JSON.stringify(table, null, 2));\n return;\n }\n\n const memberLimit = parseInt(options.members) || 10;\n\n logger.header(`Dimension Table: ${table.name}`);\n console.log();\n console.log(` Columns:`);\n table.columns.forEach((col, i) => {\n let colInfo = ` ${i + 1}. ${chalk.bold(col.type)}`;\n if (col.name) colInfo += ` (${col.name})`;\n if (col.foreignKeyTableName) colInfo += chalk.cyan(` -> ${col.foreignKeyTableName}`);\n console.log(colInfo);\n });\n console.log(` Members: ${table.rows.length}`);\n if (table.folderPath) {\n console.log(` Folder: ${table.folderPath.join(' / ')}`);\n }\n if (table.rows.length > 0) {\n console.log();\n console.log(` Sample members (first ${Math.min(memberLimit, table.rows.length)}):`);\n table.rows.slice(0, memberLimit).forEach((row) => {\n console.log(` - ${row[0]}`);\n });\n if (table.rows.length > memberLimit) {\n logger.dim(` ... and ${table.rows.length - memberLimit} more`);\n }\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer dimensions members <tableName> [org] [tenant]\n dimensionsCmd\n .command('members <tableName> [org] [tenant]')\n .description('List all members of a dimension table')\n .option('--json', 'Output raw JSON')\n .option('--limit <n>', 'Limit number of members shown', parseInt)\n .option('--output <file>', 'Export members to CSV file')\n .action(async (tableName, first, second, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(first, second);\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n\n if (!nativeClient) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n await nativeClient.initTagMap();\n const members = await nativeClient.getDimensionMembersForTable(tableName);\n\n // CSV export\n if (options.output) {\n const csvLines = ['id,name,parentId'];\n for (const m of members) {\n const name = m.name.includes(',') ? `\"${m.name}\"` : m.name;\n csvLines.push(`${m.id},${name},${m.ParentId ?? ''}`);\n }\n fs.writeFileSync(options.output, csvLines.join('\\n'), 'utf-8');\n logger.success(`Exported ${members.length} members to ${options.output}`);\n return;\n }\n\n if (options.json) {\n const result = members.map((m) => ({\n id: m.id,\n name: m.name,\n parentId: m.ParentId,\n }));\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n const limit = options.limit || members.length;\n logger.header(`Members of \"${tableName}\" (${members.length})`);\n const display = members.slice(0, limit);\n for (const m of display) {\n const parentInfo = m.ParentId ? chalk.dim(` (parent: ${m.ParentId})`) : '';\n console.log(` ${chalk.dim(String(m.id).padEnd(8))} ${m.name}${parentInfo}`);\n }\n if (members.length > limit) {\n logger.dim(` ... and ${members.length - limit} more`);\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer dimensions create-member [org] [tenant]\n dimensionsCmd\n .command('create-member [org] [tenant]')\n .description('Create a new dimension member')\n .requiredOption('--table <name>', 'Dimension table name')\n .requiredOption('--name <name>', 'New member name')\n .option('--parent <name>', 'Parent member name')\n .action(async (first, second, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(first, second);\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n\n if (!nativeClient) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n await nativeClient.initTagMap();\n const table = await nativeClient.getDimensionTable(options.table);\n\n const createEntity: any = {\n type: EntityType.DimensionMember,\n meta: { name: options.name },\n relations: {\n parent: {\n key: { id: table.id, type: EntityType.DimensionTable },\n order: 0,\n },\n },\n dimensionMember: { data: {} },\n };\n\n if (options.parent) {\n const parentMember = await nativeClient.getDimensionMember(options.table, options.parent);\n createEntity.relations.parent = {\n key: { id: parentMember.id, type: EntityType.DimensionMember },\n order: 0,\n };\n }\n\n const result = await nativeClient.entities.mutate({ created: [createEntity] });\n logger.success(`Created dimension member \"${options.name}\" in table \"${options.table}\".`);\n if ((result as any).created?.length > 0) {\n logger.dim(` ID: ${(result as any).created[0].id}`);\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer dimensions delete-member [org] [tenant]\n dimensionsCmd\n .command('delete-member [org] [tenant]')\n .description('Delete a dimension member')\n .requiredOption('--table <name>', 'Dimension table name')\n .requiredOption('--name <name>', 'Member name to delete')\n .option('-y, --yes', 'Skip confirmation')\n .action(async (first, second, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(first, second);\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n\n if (!nativeClient) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n await nativeClient.initTagMap();\n const member = await nativeClient.getDimensionMember(options.table, options.name);\n\n if (!options.yes) {\n logger.warning(\n `This will delete member \"${options.name}\" (ID: ${member.id}) from table \"${options.table}\".`,\n );\n logger.dim('Use -y to skip confirmation.');\n process.exit(0);\n }\n\n await nativeClient.entities.mutate({\n deleted: [{ id: member.id, type: EntityType.DimensionMember }],\n });\n logger.success(`Deleted dimension member \"${options.name}\" from table \"${options.table}\".`);\n } catch (error) {\n handleModelError(error, tenant);\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(errorMessage);\n }\n process.exit(1);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;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Aa,SAAS,KAAK,GAAG;AACrC,yBAAO,MAAM,WAAW,MAAM,gCAAgC;AAAA,EAClE,WAAW,aAAa,SAAS,WAAW,KAAK,aAAa,SAAS,cAAc,GAAG;AACpF,yBAAO,MAAM,+BAA+B;AAAA,EAChD,OAAO;AACH,yBAAO,MAAM,wBAAwB;AACrC,yBAAO,IAAI,YAAY;AAAA,EAC3B;AACA,UAAQ,KAAK,CAAC;AAClB;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
package/dist/commands/model.js
CHANGED
|
@@ -34,7 +34,31 @@ function registerModelCommand(program) {
|
|
|
34
34
|
}
|
|
35
35
|
const api = result.client;
|
|
36
36
|
try {
|
|
37
|
-
|
|
37
|
+
let model;
|
|
38
|
+
if (options.variable || options.variables) {
|
|
39
|
+
model = await api.exportModel({ types: ["VAR"] });
|
|
40
|
+
} else if (options.table) {
|
|
41
|
+
const table = await api.loadDimensionTableWithMembers(options.table);
|
|
42
|
+
if (!table) {
|
|
43
|
+
import_logger.logger.error(`Table "${options.table}" not found.`);
|
|
44
|
+
const summary = await api.exportModel({ types: ["DTAB"] });
|
|
45
|
+
import_logger.logger.dim("Available tables:");
|
|
46
|
+
summary.tables.slice(0, 10).forEach((t) => import_logger.logger.dim(` - ${t.name}`));
|
|
47
|
+
if (summary.tables.length > 10) {
|
|
48
|
+
import_logger.logger.dim(` ... and ${summary.tables.length - 10} more`);
|
|
49
|
+
}
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
model = {
|
|
53
|
+
tables: [table],
|
|
54
|
+
variables: [],
|
|
55
|
+
dependencies: { tables: [], members: [], variables: [] }
|
|
56
|
+
};
|
|
57
|
+
} else if (options.tables) {
|
|
58
|
+
model = await api.exportModel({ types: ["DTAB"] });
|
|
59
|
+
} else {
|
|
60
|
+
model = await api.exportModel({ types: ["DTAB", "VAR"] });
|
|
61
|
+
}
|
|
38
62
|
if (options.json) {
|
|
39
63
|
console.log(JSON.stringify(model, null, 2));
|
|
40
64
|
return;
|
|
@@ -79,16 +103,7 @@ function registerModelCommand(program) {
|
|
|
79
103
|
return;
|
|
80
104
|
}
|
|
81
105
|
if (options.table) {
|
|
82
|
-
const table = model.tables
|
|
83
|
-
if (!table) {
|
|
84
|
-
import_logger.logger.error(`Table "${options.table}" not found.`);
|
|
85
|
-
import_logger.logger.dim("Available tables:");
|
|
86
|
-
model.tables.slice(0, 10).forEach((t) => import_logger.logger.dim(` - ${t.name}`));
|
|
87
|
-
if (model.tables.length > 10) {
|
|
88
|
-
import_logger.logger.dim(` ... and ${model.tables.length - 10} more`);
|
|
89
|
-
}
|
|
90
|
-
process.exit(1);
|
|
91
|
-
}
|
|
106
|
+
const table = model.tables[0];
|
|
92
107
|
import_logger.logger.header(`Dimension Table: ${table.name}`);
|
|
93
108
|
console.log();
|
|
94
109
|
console.log(` Columns:`);
|
|
@@ -118,12 +133,13 @@ function registerModelCommand(program) {
|
|
|
118
133
|
console.log();
|
|
119
134
|
for (const table of model.tables) {
|
|
120
135
|
const fkColumns = table.columns.filter((c) => c.type === "FOREIGN_KEY");
|
|
121
|
-
let info = ` \u{1F4CB} ${table.name}
|
|
136
|
+
let info = ` \u{1F4CB} ${table.name}`;
|
|
122
137
|
if (fkColumns.length > 0) {
|
|
123
138
|
info += ` \u2192 ${fkColumns.map((c) => c.foreignKeyTableName).join(", ")}`;
|
|
124
139
|
}
|
|
125
140
|
console.log(info);
|
|
126
141
|
}
|
|
142
|
+
import_logger.logger.dim("Run with --table <name> to see members for a specific table.");
|
|
127
143
|
return;
|
|
128
144
|
}
|
|
129
145
|
if (options.variables) {
|
|
@@ -148,7 +164,7 @@ function registerModelCommand(program) {
|
|
|
148
164
|
console.log();
|
|
149
165
|
import_logger.logger.dim("Dimension Tables:");
|
|
150
166
|
model.tables.slice(0, 10).forEach((t) => {
|
|
151
|
-
import_logger.logger.dim(` - ${t.name}
|
|
167
|
+
import_logger.logger.dim(` - ${t.name}`);
|
|
152
168
|
});
|
|
153
169
|
if (model.tables.length > 10) {
|
|
154
170
|
import_logger.logger.dim(` ... and ${model.tables.length - 10} more`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/model.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport { logger } from '../utils/logger';\nimport { getFarseerClientWithFallback, showLoginPrompt, isAuthError } from '../services/farseerFactory';\nimport { resolveTenantWithOrgMapping } from '../utils/helpers';\n\nexport function registerModelCommand(program: Command): void {\n program\n .command('model [tenant]')\n .description('Export and display the model structure (dimensions, variables)')\n .option('--json', 'Output raw JSON')\n .option('--tables', 'Show only dimension tables')\n .option('--variables', 'Show only variables')\n .option('--variable <name>', 'Show details for specific variable')\n .option('--table <name>', 'Show details for specific dimension table')\n .action(async (tenantArg, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(tenantArg);\n const result = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const api = result.client;\n\n try {\n const model = await api.exportModel();\n\n // Raw JSON output\n if (options.json) {\n console.log(JSON.stringify(model, null, 2));\n return;\n }\n\n // Specific variable details\n if (options.variable) {\n const variable = model.variables.find(\n (v) => v.name.toLowerCase() === options.variable.toLowerCase(),\n );\n if (!variable) {\n logger.error(`Variable \"${options.variable}\" 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 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(\n ` Format: ${variable.numberFormat.type}${variable.numberFormat.formatString ? ` (${variable.numberFormat.formatString})` : ''}`,\n );\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 return;\n }\n\n // Specific table details\n if (options.table) {\n const table = model.tables.find((t) => t.name.toLowerCase() === options.table.toLowerCase());\n if (!table) {\n logger.error(`Table \"${options.table}\" not found.`);\n logger.dim('Available tables:');\n model.tables.slice(0, 10).forEach((t) => logger.dim(` - ${t.name}`));\n if (model.tables.length > 10) {\n logger.dim(` ... and ${model.tables.length - 10} more`);\n }\n process.exit(1);\n }\n\n logger.header(`Dimension Table: ${table.name}`);\n console.log();\n console.log(` Columns:`);\n table.columns.forEach((col, i) => {\n let colInfo = ` ${i + 1}. ${col.type}`;\n if (col.name) colInfo += ` (${col.name})`;\n if (col.foreignKeyTableName) colInfo += ` \u2192 ${col.foreignKeyTableName}`;\n console.log(colInfo);\n });\n console.log(` Members: ${table.rows.length}`);\n if (table.folderPath) {\n console.log(` Folder: ${table.folderPath.join(' / ')}`);\n }\n if (table.rows.length > 0) {\n console.log(` Sample members:`);\n table.rows.slice(0, 5).forEach((row) => {\n console.log(` - ${row[0]}`);\n });\n if (table.rows.length > 5) {\n console.log(` ... and ${table.rows.length - 5} more`);\n }\n }\n return;\n }\n\n // Tables only\n if (options.tables) {\n logger.header(`Dimension Tables (${model.tables.length})`);\n console.log();\n for (const table of model.tables) {\n const fkColumns = table.columns.filter((c) => c.type === 'FOREIGN_KEY');\n let info = ` \uD83D\uDCCB ${table.name} (${table.rows.length} members)`;\n if (fkColumns.length > 0) {\n info += ` \u2192 ${fkColumns.map((c) => c.foreignKeyTableName).join(', ')}`;\n }\n console.log(info);\n }\n return;\n }\n\n // Variables only\n if (options.variables) {\n logger.header(`Variables (${model.variables.length})`);\n console.log();\n for (const variable of model.variables) {\n console.log(` \uD83D\uDCCA ${variable.name}`);\n console.log(` Dimensions: ${variable.tables.join(', ')}`);\n if (variable.formula) {\n console.log(\n ` Formula: ${variable.formula.substring(0, 50)}${variable.formula.length > 50 ? '...' : ''}`,\n );\n }\n console.log();\n }\n return;\n }\n\n // Default: summary\n logger.header(`Model Summary for ${tenant}`);\n console.log();\n console.log(` Dimension Tables: ${model.tables.length}`);\n console.log(` Variables: ${model.variables.length}`);\n console.log();\n\n logger.dim('Dimension Tables:');\n model.tables.slice(0, 10).forEach((t) => {\n logger.dim(` - ${t.name} (${t.rows.length} members)`);\n });\n if (model.tables.length > 10) {\n logger.dim(` ... and ${model.tables.length - 10} more`);\n }\n console.log();\n\n logger.dim('Variables (first 10):');\n model.variables.slice(0, 10).forEach((v) => {\n logger.dim(` - ${v.name} [${v.tables.join(', ')}]`);\n });\n if (model.variables.length > 10) {\n logger.dim(` ... and ${model.variables.length - 10} more`);\n }\n console.log();\n\n logger.dim('Use --tables, --variables, --table <name>, or --variable <name> for details.');\n logger.dim('Use --json for raw JSON output.');\n } catch (error) {\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 logger.dim('Check that the tenant name is correct.');\n } else if (errorMessage.includes('ENOTFOUND') || errorMessage.includes('ECONNREFUSED')) {\n logger.error('Failed to connect to Farseer.');\n logger.dim('Check your network connection.');\n } else {\n logger.error('Failed to export model.');\n logger.dim(errorMessage);\n }\n process.exit(1);\n }\n });\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AACvB,4BAA2E;AAC3E,qBAA4C;AAErC,SAAS,qBAAqB,SAAwB;AACzD,UACK,QAAQ,gBAAgB,EACxB,YAAY,gEAAgE,EAC5E,OAAO,UAAU,iBAAiB,EAClC,OAAO,YAAY,4BAA4B,EAC/C,OAAO,eAAe,qBAAqB,EAC3C,OAAO,qBAAqB,oCAAoC,EAChE,OAAO,kBAAkB,2CAA2C,EACpE,OAAO,OAAO,WAAW,YAAY;AAClC,UAAM,EAAE,cAAc,OAAO,QAAI,4CAA4B,SAAS;AACtE,UAAM,SAAS,UAAM,oDAA6B,cAAc,MAAM;AAEtE,QAAI,CAAC,QAAQ;AACT,iDAAgB,MAAM;AACtB,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,UAAM,MAAM,OAAO;AAEnB,QAAI;AACA,
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport { logger } from '../utils/logger';\nimport { getFarseerClientWithFallback, showLoginPrompt, isAuthError } from '../services/farseerFactory';\nimport { resolveTenantWithOrgMapping } from '../utils/helpers';\n\nexport function registerModelCommand(program: Command): void {\n program\n .command('model [tenant]')\n .description('Export and display the model structure (dimensions, variables)')\n .option('--json', 'Output raw JSON')\n .option('--tables', 'Show only dimension tables')\n .option('--variables', 'Show only variables')\n .option('--variable <name>', 'Show details for specific variable')\n .option('--table <name>', 'Show details for specific dimension table')\n .action(async (tenantArg, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(tenantArg);\n const result = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const api = result.client;\n\n try {\n // Pick the smallest scope that satisfies the requested\n // output. An unscoped DTAB+DMEM+VAR fetch breaks the\n // response limit on large tenants; `--json` is the\n // worst case because it asks for the whole thing.\n let model;\n if (options.variable || options.variables) {\n model = await api.exportModel({ types: ['VAR'] });\n } else if (options.table) {\n // Single-table member fetch via entities API.\n // `/model/export` with `tableGids` 500s for some\n // tables on large tenants (separate backend bug);\n // the entities path is reliable.\n const table = await api.loadDimensionTableWithMembers(options.table);\n if (!table) {\n logger.error(`Table \"${options.table}\" not found.`);\n const summary = await api.exportModel({ types: ['DTAB'] });\n logger.dim('Available tables:');\n summary.tables.slice(0, 10).forEach((t) => logger.dim(` - ${t.name}`));\n if (summary.tables.length > 10) {\n logger.dim(` ... and ${summary.tables.length - 10} more`);\n }\n process.exit(1);\n }\n model = {\n tables: [table],\n variables: [],\n dependencies: { tables: [], members: [], variables: [] },\n };\n } else if (options.tables) {\n model = await api.exportModel({ types: ['DTAB'] });\n } else {\n // Default summary view \u2014 counts of tables /\n // variables and a name preview, no member rows.\n model = await api.exportModel({ types: ['DTAB', 'VAR'] });\n }\n\n // Raw JSON output\n if (options.json) {\n console.log(JSON.stringify(model, null, 2));\n return;\n }\n\n // Specific variable details\n if (options.variable) {\n const variable = model.variables.find(\n (v) => v.name.toLowerCase() === options.variable.toLowerCase(),\n );\n if (!variable) {\n logger.error(`Variable \"${options.variable}\" 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 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(\n ` Format: ${variable.numberFormat.type}${variable.numberFormat.formatString ? ` (${variable.numberFormat.formatString})` : ''}`,\n );\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 return;\n }\n\n // Specific table details. The dispatch above already\n // resolved name \u2192 single-table fetch and exited if the\n // table didn't exist, so model.tables is exactly [target].\n if (options.table) {\n const table = model.tables[0];\n\n logger.header(`Dimension Table: ${table.name}`);\n console.log();\n console.log(` Columns:`);\n table.columns.forEach((col, i) => {\n let colInfo = ` ${i + 1}. ${col.type}`;\n if (col.name) colInfo += ` (${col.name})`;\n if (col.foreignKeyTableName) colInfo += ` \u2192 ${col.foreignKeyTableName}`;\n console.log(colInfo);\n });\n console.log(` Members: ${table.rows.length}`);\n if (table.folderPath) {\n console.log(` Folder: ${table.folderPath.join(' / ')}`);\n }\n if (table.rows.length > 0) {\n console.log(` Sample members:`);\n table.rows.slice(0, 5).forEach((row) => {\n console.log(` - ${row[0]}`);\n });\n if (table.rows.length > 5) {\n console.log(` ... and ${table.rows.length - 5} more`);\n }\n }\n return;\n }\n\n // Tables only\n if (options.tables) {\n logger.header(`Dimension Tables (${model.tables.length})`);\n console.log();\n for (const table of model.tables) {\n const fkColumns = table.columns.filter((c) => c.type === 'FOREIGN_KEY');\n let info = ` \uD83D\uDCCB ${table.name}`;\n if (fkColumns.length > 0) {\n info += ` \u2192 ${fkColumns.map((c) => c.foreignKeyTableName).join(', ')}`;\n }\n console.log(info);\n }\n logger.dim('Run with --table <name> to see members for a specific table.');\n return;\n }\n\n // Variables only\n if (options.variables) {\n logger.header(`Variables (${model.variables.length})`);\n console.log();\n for (const variable of model.variables) {\n console.log(` \uD83D\uDCCA ${variable.name}`);\n console.log(` Dimensions: ${variable.tables.join(', ')}`);\n if (variable.formula) {\n console.log(\n ` Formula: ${variable.formula.substring(0, 50)}${variable.formula.length > 50 ? '...' : ''}`,\n );\n }\n console.log();\n }\n return;\n }\n\n // Default: summary\n logger.header(`Model Summary for ${tenant}`);\n console.log();\n console.log(` Dimension Tables: ${model.tables.length}`);\n console.log(` Variables: ${model.variables.length}`);\n console.log();\n\n logger.dim('Dimension Tables:');\n model.tables.slice(0, 10).forEach((t) => {\n logger.dim(` - ${t.name}`);\n });\n if (model.tables.length > 10) {\n logger.dim(` ... and ${model.tables.length - 10} more`);\n }\n console.log();\n\n logger.dim('Variables (first 10):');\n model.variables.slice(0, 10).forEach((v) => {\n logger.dim(` - ${v.name} [${v.tables.join(', ')}]`);\n });\n if (model.variables.length > 10) {\n logger.dim(` ... and ${model.variables.length - 10} more`);\n }\n console.log();\n\n logger.dim('Use --tables, --variables, --table <name>, or --variable <name> for details.');\n logger.dim('Use --json for raw JSON output.');\n } catch (error) {\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 logger.dim('Check that the tenant name is correct.');\n } else if (errorMessage.includes('ENOTFOUND') || errorMessage.includes('ECONNREFUSED')) {\n logger.error('Failed to connect to Farseer.');\n logger.dim('Check your network connection.');\n } else {\n logger.error('Failed to export model.');\n logger.dim(errorMessage);\n }\n process.exit(1);\n }\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AACvB,4BAA2E;AAC3E,qBAA4C;AAErC,SAAS,qBAAqB,SAAwB;AACzD,UACK,QAAQ,gBAAgB,EACxB,YAAY,gEAAgE,EAC5E,OAAO,UAAU,iBAAiB,EAClC,OAAO,YAAY,4BAA4B,EAC/C,OAAO,eAAe,qBAAqB,EAC3C,OAAO,qBAAqB,oCAAoC,EAChE,OAAO,kBAAkB,2CAA2C,EACpE,OAAO,OAAO,WAAW,YAAY;AAClC,UAAM,EAAE,cAAc,OAAO,QAAI,4CAA4B,SAAS;AACtE,UAAM,SAAS,UAAM,oDAA6B,cAAc,MAAM;AAEtE,QAAI,CAAC,QAAQ;AACT,iDAAgB,MAAM;AACtB,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,UAAM,MAAM,OAAO;AAEnB,QAAI;AAKA,UAAI;AACJ,UAAI,QAAQ,YAAY,QAAQ,WAAW;AACvC,gBAAQ,MAAM,IAAI,YAAY,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;AAAA,MACpD,WAA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