farseer-cli 1.11.1 → 1.12.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 +60 -0
- package/dist/commands/app.js +56 -6
- package/dist/commands/app.js.map +2 -2
- package/dist/commands/dashboards.js +16 -2
- package/dist/commands/dashboards.js.map +2 -2
- package/dist/commands/sheets.js +46 -34
- package/dist/commands/sheets.js.map +2 -2
- package/dist/commands/variables.js +7 -1
- package/dist/commands/variables.js.map +2 -2
- package/dist/mcp/prompts/workflows.js +2 -0
- package/dist/mcp/prompts/workflows.js.map +2 -2
- package/dist/mcp/tools/appTools.js +56 -6
- package/dist/mcp/tools/appTools.js.map +2 -2
- package/dist/mcp/tools/dashboardTools.js +79 -69
- package/dist/mcp/tools/dashboardTools.js.map +2 -2
- package/dist/mcp/tools/sheetTools.js +48 -59
- package/dist/mcp/tools/sheetTools.js.map +2 -2
- package/dist/mcp/utils/helpers.js +39 -5
- package/dist/mcp/utils/helpers.js.map +2 -2
- package/dist/services/appSyncService.js +33 -1
- package/dist/services/appSyncService.js.map +2 -2
- package/dist/services/apps.js +199 -9
- package/dist/services/apps.js.map +3 -3
- package/dist/services/farseerService.js +11 -0
- package/dist/services/farseerService.js.map +2 -2
- package/dist/services/modelExport.js +4 -2
- package/dist/services/modelExport.js.map +2 -2
- package/dist/utils/entityResolver.js +114 -28
- package/dist/utils/entityResolver.js.map +2 -2
- package/dist/utils/helpers.js +5 -5
- package/dist/utils/helpers.js.map +2 -2
- package/dist/utils/{appResolver.js → nameResolver.js} +23 -23
- package/dist/utils/nameResolver.js.map +7 -0
- package/docs/cli-guide.md +16 -0
- package/package.json +1 -1
- package/dist/utils/appResolver.js.map +0 -7
package/README.md
CHANGED
|
@@ -515,10 +515,32 @@ farseer app configure My App --add-arg "Year=2025"
|
|
|
515
515
|
|
|
516
516
|
# Set description
|
|
517
517
|
farseer app configure My App --description "Imports data"
|
|
518
|
+
|
|
519
|
+
# Run it every morning at 06:00
|
|
520
|
+
farseer app configure My App --schedule "0 6 * * *"
|
|
521
|
+
|
|
522
|
+
# Pick the jobrunner and the container image it runs in
|
|
523
|
+
farseer app configure My App --runner runner-1 --runner-image runner-typescript:latest
|
|
524
|
+
|
|
525
|
+
# Give the run a machine of its own, sized large
|
|
526
|
+
farseer app configure My App --compute batch:l
|
|
518
527
|
```
|
|
519
528
|
|
|
520
529
|
Settings you don't pass are preserved — `configure` only changes what you specify.
|
|
521
530
|
|
|
531
|
+
| Flag | Sets |
|
|
532
|
+
|---|---|
|
|
533
|
+
| `--schedule <cron>` | Cron expression the app runs on. Five fields, or six when the first is seconds. Sent as written: nothing here checks it, because the UI and the API don't either, and a check in one surface only would make the same expression valid or invalid depending on where it was typed. A schedule the runner can't read means the job never runs. |
|
|
534
|
+
| `--runner <name>` | Which connected jobrunner runs the app. Unset means any of them. |
|
|
535
|
+
| `--runner-image <image>` | Container image, as `<repository>:<tag>` — the tenant's registry prefix is filled in — or a full registry reference. |
|
|
536
|
+
| `--compute <choice>` | `local`, `batch`, or `batch:<size>` with size `s`, `m`, `l` or `xl`. `local` runs the job in a container on the jobrunner's own machine; `batch` creates a machine for that one run, and bare `batch` takes the deployment's default size. |
|
|
537
|
+
|
|
538
|
+
Pass `none` to `--schedule`, `--runner` or `--runner-image` to clear it.
|
|
539
|
+
|
|
540
|
+
A runner that isn't connected, or one that can't run the compute you picked, is
|
|
541
|
+
reported as a warning rather than an error: these settings outlive any one
|
|
542
|
+
connection, so a jobrunner that happens to be restarting doesn't block you.
|
|
543
|
+
|
|
522
544
|
If you move the source folder to one that doesn't contain the app's current
|
|
523
545
|
entrypoint, pass `--entrypoint` in the same command — `configure` errors rather
|
|
524
546
|
than silently clearing or relocating the entrypoint.
|
|
@@ -673,6 +695,7 @@ Once configured, AI assistants have access to:
|
|
|
673
695
|
- `farseer_get_app` - Get app details
|
|
674
696
|
- `farseer_create_app` - Create new app
|
|
675
697
|
- `farseer_configure_app` - Configure app (scripts can be referenced by filename or full path)
|
|
698
|
+
- `predefinedActions` replaces the app's whole list. A secret argument's value reads back as `<secret>`; send `<secret>` to keep the stored value of the action with exactly that name; where two actions share a name, give the real value. `none` clears `schedule`, `runner` or `runnerImage`.
|
|
676
699
|
- `farseer_delete_app` - Delete app
|
|
677
700
|
- `farseer_run_app` - Run app locally
|
|
678
701
|
- `farseer_install` - Install dependencies (auto-creates package.json, supports adding extra npm packages)
|
|
@@ -779,6 +802,9 @@ apps/
|
|
|
779
802
|
{ "name": "Year", "defaultValue": "2025" },
|
|
780
803
|
{ "name": "Version", "defaultValue": "Plan" }
|
|
781
804
|
],
|
|
805
|
+
"schedule": "0 6 * * *",
|
|
806
|
+
"runnerImage": "europe-docker.pkg.dev/farseer/runners/runner-typescript:1.4.0",
|
|
807
|
+
"compute": "batch:l",
|
|
782
808
|
"_remote": {
|
|
783
809
|
"id": 123,
|
|
784
810
|
"reference": "123"
|
|
@@ -791,6 +817,40 @@ apps/
|
|
|
791
817
|
- For **existing apps**: `_remote` links local JSON to remote app
|
|
792
818
|
- Never edit `_remote` manually
|
|
793
819
|
|
|
820
|
+
`schedule`, `runnerImage` and `compute` are managed by whether the key is there.
|
|
821
|
+
A key present means the file decides that setting and `push` writes it —
|
|
822
|
+
including `null`, which clears it. A key absent means the file says nothing about
|
|
823
|
+
it and `push` leaves whatever the tenant has, so a config written before these
|
|
824
|
+
fields existed never clears a live schedule. `pull` writes all three, so pulling
|
|
825
|
+
once puts them under version control — including in a file that predates them,
|
|
826
|
+
which the first `pull` after upgrading rewrites to add the missing keys.
|
|
827
|
+
|
|
828
|
+
Two settings are not in the file, and are set with `app configure` or the
|
|
829
|
+
`farseer_configure_app` tool instead:
|
|
830
|
+
|
|
831
|
+
- **The runner.** The backend assigns a runner to a scheduled job that has none,
|
|
832
|
+
and stores it. A file cannot tell that assignment from a choice, so pulling it
|
|
833
|
+
would pin whatever the scheduler happened to pick, and pushing would clear it
|
|
834
|
+
only for the scheduler to assign it again.
|
|
835
|
+
- **Predefined actions.** The backend returns their values readable even for
|
|
836
|
+
arguments marked secret, so writing them to the file would put secrets in the
|
|
837
|
+
workspace and in git. `app show` and `farseer_get_app` show a secret
|
|
838
|
+
argument's value as `<secret>`. Pushing a file never touches the tenant's
|
|
839
|
+
actions.
|
|
840
|
+
|
|
841
|
+
`pull` removes `runner` and `predefinedActions` from a file an earlier version
|
|
842
|
+
wrote them into.
|
|
843
|
+
|
|
844
|
+
The file holds stored values, not the shorthands `app configure` accepts.
|
|
845
|
+
`runnerImage` must be the full registry reference: `push` sends it as written and
|
|
846
|
+
the API rejects a bare `<repository>:<tag>`. `none` is a flag keyword, so write
|
|
847
|
+
`null` in the file to clear a setting. `schedule` is sent as written and is not
|
|
848
|
+
checked here — see the note under `--schedule` above.
|
|
849
|
+
|
|
850
|
+
A teammate still on an older CLI drops these three keys from the file on their
|
|
851
|
+
next `pull`, because their version does not know about them; the tenant's own
|
|
852
|
+
settings are untouched and the next `pull` on this version puts the keys back.
|
|
853
|
+
|
|
794
854
|
---
|
|
795
855
|
|
|
796
856
|
## Configuration
|
package/dist/commands/app.js
CHANGED
|
@@ -36,7 +36,7 @@ var import_logger = require("../utils/logger");
|
|
|
36
36
|
var import_preflight = require("../services/preflight");
|
|
37
37
|
var import_apps = require("../services/apps");
|
|
38
38
|
var import_helpers = require("../utils/helpers");
|
|
39
|
-
var
|
|
39
|
+
var import_nameResolver = require("../utils/nameResolver");
|
|
40
40
|
function registerAppCommand(program) {
|
|
41
41
|
const appCmd = program.command("app").description("Manage apps on a Farseer instance").addHelpText(
|
|
42
42
|
"after",
|
|
@@ -45,7 +45,7 @@ Commands:
|
|
|
45
45
|
list [tenant] List all apps
|
|
46
46
|
show [tenant] <name...> Show app details
|
|
47
47
|
create [tenant] <name...> Create a new app
|
|
48
|
-
configure [tenant] <name...> Configure app (source folder, entrypoint, arguments)
|
|
48
|
+
configure [tenant] <name...> Configure app (source folder, entrypoint, arguments, schedule, runner, compute)
|
|
49
49
|
delete [tenant] <name...> Delete an app (requires --force)
|
|
50
50
|
|
|
51
51
|
Note: App names with spaces don't need quotes when the tenant comes from FARSEER_TENANT.
|
|
@@ -55,6 +55,7 @@ Examples:
|
|
|
55
55
|
$ farseer app show mycompany "My App" # Explicit tenant
|
|
56
56
|
$ farseer app show My App # Uses FARSEER_TENANT
|
|
57
57
|
$ farseer app configure "My App" --entrypoint index.ts
|
|
58
|
+
$ farseer app configure "My App" --schedule "0 6 * * *" --compute batch:l
|
|
58
59
|
`
|
|
59
60
|
);
|
|
60
61
|
appCmd.command("list [tenant]").description("List all apps on a Farseer instance").option("--details", "Show detailed information for each app").action(async (tenantArg, options) => {
|
|
@@ -81,6 +82,16 @@ Examples:
|
|
|
81
82
|
console.log(
|
|
82
83
|
` Status: ${details.status === "AVAILABLE" ? import_chalk.default.green(details.status) : import_chalk.default.yellow(details.status)}`
|
|
83
84
|
);
|
|
85
|
+
if (details.schedule) {
|
|
86
|
+
console.log(` Schedule: ${details.schedule}`);
|
|
87
|
+
}
|
|
88
|
+
if (details.runnerName) {
|
|
89
|
+
console.log(` Runner: ${details.runnerName}`);
|
|
90
|
+
}
|
|
91
|
+
if (details.runnerImage) {
|
|
92
|
+
console.log(` Runner image: ${details.runnerImage}`);
|
|
93
|
+
}
|
|
94
|
+
console.log(` Compute: ${(0, import_apps.formatCompute)(details.compute)}`);
|
|
84
95
|
const detailScripts = details.scriptFiles ?? [];
|
|
85
96
|
if (detailScripts.length > 0) {
|
|
86
97
|
const mainScript = detailScripts.find((s) => s.id === details.mainScriptFileId);
|
|
@@ -136,6 +147,10 @@ Examples:
|
|
|
136
147
|
if (app.description) {
|
|
137
148
|
console.log(` Description: ${app.description}`);
|
|
138
149
|
}
|
|
150
|
+
console.log(` Schedule: ${app.schedule || "(none)"}`);
|
|
151
|
+
console.log(` Runner: ${app.runnerName || "(any)"}`);
|
|
152
|
+
console.log(` Runner image: ${app.runnerImage || "(default)"}`);
|
|
153
|
+
console.log(` Compute: ${(0, import_apps.formatCompute)(app.compute)}`);
|
|
139
154
|
console.log();
|
|
140
155
|
const appScripts = app.scriptFiles ?? [];
|
|
141
156
|
if (appScripts.length > 0) {
|
|
@@ -159,11 +174,20 @@ Examples:
|
|
|
159
174
|
console.log(" Arguments: None");
|
|
160
175
|
}
|
|
161
176
|
console.log();
|
|
177
|
+
const actions = (0, import_apps.redactActionValues)(app.predefinedActions ?? [], app.expectedArguments);
|
|
178
|
+
if (actions.length > 0) {
|
|
179
|
+
console.log(" Predefined actions:");
|
|
180
|
+
for (const action of actions) {
|
|
181
|
+
const preset = Object.entries(action.runArguments ?? {}).map(([name, value]) => `${name}=${value}`).join(", ");
|
|
182
|
+
console.log(` - ${action.name}: ${import_chalk.default.dim(preset)}`);
|
|
183
|
+
}
|
|
184
|
+
console.log();
|
|
185
|
+
}
|
|
162
186
|
});
|
|
163
187
|
appCmd.command("create <args...>").description("Create a new app").action(async (args) => {
|
|
164
188
|
const { organisation, tenant, appName } = (0, import_helpers.parseAppArgs)(args);
|
|
165
189
|
const { client: api } = await (0, import_preflight.preflightForPair)(organisation, tenant);
|
|
166
|
-
const existing = (0,
|
|
190
|
+
const existing = (0, import_nameResolver.matchByName)(await (0, import_helpers.orExit)(api.listApps(), "Failed to list apps."), appName);
|
|
167
191
|
if (existing.length > 0) {
|
|
168
192
|
import_logger.logger.error(`App already exists: ${appName}`);
|
|
169
193
|
process.exit(1);
|
|
@@ -210,7 +234,7 @@ Examples:
|
|
|
210
234
|
process.exit(1);
|
|
211
235
|
}
|
|
212
236
|
});
|
|
213
|
-
appCmd.command("configure [args...]").description("Configure an app (
|
|
237
|
+
appCmd.command("configure [args...]").description("Configure an app (source folder, entrypoint, arguments, schedule, runner, compute)").option(
|
|
214
238
|
"--entrypoint <script>",
|
|
215
239
|
`Set the entrypoint script \u2014 must be a file in the app's source folder (e.g., "index.ts")`
|
|
216
240
|
).option(
|
|
@@ -221,7 +245,13 @@ Examples:
|
|
|
221
245
|
'Add argument in format "Name=DefaultValue" (can be used multiple times)',
|
|
222
246
|
collectArgs,
|
|
223
247
|
[]
|
|
224
|
-
).option("--description <desc>", "Set app description").option("--name <name>", "Rename the app").option("--id <id>", "Select the app by its numeric id (use when names collide)").
|
|
248
|
+
).option("--description <desc>", "Set app description").option("--name <name>", "Rename the app").option("--id <id>", "Select the app by its numeric id (use when names collide)").option("--schedule <cron>", 'Run the app on a cron schedule (e.g. "0 6 * * *"). Use "none" to clear.').option("--runner <name>", 'Set which jobrunner runs the app. Use "none" to clear.').option(
|
|
249
|
+
"--runner-image <image>",
|
|
250
|
+
'Set the container image, as "<repository>:<tag>" (e.g. "runner-typescript:latest") or a full registry reference. Use "none" to clear.'
|
|
251
|
+
).option(
|
|
252
|
+
"--compute <choice>",
|
|
253
|
+
`Where a run executes: ${import_apps.APP_COMPUTE_CHOICES.join(", ")}. "local" is a container on the jobrunner's own machine, "batch" a machine created for that run; the size suffix picks how much machine, and bare "batch" takes the deployment's default size.`
|
|
254
|
+
).action(async (args, options) => {
|
|
225
255
|
const { organisation, tenant, appName } = (0, import_helpers.parseAppArgs)(args, {
|
|
226
256
|
allowEmptyName: !!options.id,
|
|
227
257
|
command: "app configure"
|
|
@@ -254,6 +284,19 @@ Examples:
|
|
|
254
284
|
import_logger.logger.error(sourceFolderError);
|
|
255
285
|
process.exit(1);
|
|
256
286
|
}
|
|
287
|
+
const runSettings = await (0, import_helpers.orExit)(
|
|
288
|
+
(0, import_apps.applyRunSettings)(api, app, changes, {
|
|
289
|
+
schedule: options.schedule,
|
|
290
|
+
runner: options.runner,
|
|
291
|
+
runnerImage: options.runnerImage,
|
|
292
|
+
compute: options.compute
|
|
293
|
+
}),
|
|
294
|
+
"Failed to read the tenant's runner images."
|
|
295
|
+
);
|
|
296
|
+
if ("error" in runSettings) {
|
|
297
|
+
import_logger.logger.error(runSettings.error);
|
|
298
|
+
process.exit(1);
|
|
299
|
+
}
|
|
257
300
|
if (options.addArg && options.addArg.length > 0) {
|
|
258
301
|
const newArgs = [...app.expectedArguments];
|
|
259
302
|
for (const arg of options.addArg) {
|
|
@@ -279,7 +322,7 @@ Examples:
|
|
|
279
322
|
if (Object.keys(changes).length === 0) {
|
|
280
323
|
import_logger.logger.warning("No changes specified.");
|
|
281
324
|
import_logger.logger.dim(
|
|
282
|
-
"Use --entrypoint, --source-folder, --add-arg, --description, or --
|
|
325
|
+
"Use --entrypoint, --source-folder, --add-arg, --description, --name, --schedule, --runner, --runner-image or --compute to configure the app."
|
|
283
326
|
);
|
|
284
327
|
return;
|
|
285
328
|
}
|
|
@@ -309,6 +352,13 @@ Examples:
|
|
|
309
352
|
}).join(", ")}`
|
|
310
353
|
);
|
|
311
354
|
}
|
|
355
|
+
if ("schedule" in changes) console.log(` Schedule: ${updated.schedule || "(none)"}`);
|
|
356
|
+
if ("runnerName" in changes) console.log(` Runner: ${updated.runnerName || "(any)"}`);
|
|
357
|
+
if ("runnerImage" in changes) console.log(` Runner image: ${updated.runnerImage || "(default)"}`);
|
|
358
|
+
if (changes.compute) console.log(` Compute: ${(0, import_apps.formatCompute)(updated.compute)}`);
|
|
359
|
+
for (const warning of runSettings.warnings) {
|
|
360
|
+
import_logger.logger.warning(warning);
|
|
361
|
+
}
|
|
312
362
|
} catch (error) {
|
|
313
363
|
import_logger.logger.error("Failed to update app.");
|
|
314
364
|
if (error instanceof Error) {
|
package/dist/commands/app.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/app.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { preflight, preflightForPair } from '../services/preflight';\nimport { AppArgument, AppUpdateChanges, applySourceFolderChange } from '../services/apps';\nimport { orExit, parseAppArgs, resolveAppItemOrExit, resolveAppOrExit } from '../utils/helpers';\nimport { matchApps } from '../utils/appResolver';\n\nexport function registerAppCommand(program: Command): void {\n const appCmd = program\n .command('app')\n .description('Manage apps on a Farseer instance')\n .addHelpText(\n 'after',\n `\nCommands:\n list [tenant] List all apps\n show [tenant] <name...> Show app details\n create [tenant] <name...> Create a new app\n configure [tenant] <name...> Configure app (source folder, entrypoint, arguments)\n delete [tenant] <name...> Delete an app (requires --force)\n\nNote: App names with spaces don't need quotes when the tenant comes from FARSEER_TENANT.\n\nExamples:\n $ farseer app list mycompany # List all apps\n $ farseer app show mycompany \"My App\" # Explicit tenant\n $ farseer app show My App # Uses FARSEER_TENANT\n $ farseer app configure \"My App\" --entrypoint index.ts\n`,\n );\n\n // List apps\n appCmd\n .command('list [tenant]')\n .description('List all apps on a Farseer instance')\n .option('--details', 'Show detailed information for each app')\n .action(async (tenantArg, options) => {\n const { tenant, client: api, authType } = await preflight(tenantArg);\n const authLabel = authType === 'apiKey' ? 'API key' : 'browser login';\n logger.info(`Fetching apps from ${tenant} (using ${authLabel})...`);\n\n try {\n const apps = await api.listApps();\n\n if (apps.length === 0) {\n logger.warning('No apps found.');\n logger.dim('Create an app with: farseer app create <name>');\n return;\n }\n\n logger.header(`Apps on ${tenant}`);\n console.log();\n\n if (options.details) {\n // Fetch full details for each app\n for (const app of apps) {\n const details = await api.getApp(app.reference);\n if (details) {\n console.log(` \uD83D\uDCE6 ${chalk.bold(details.name)}`);\n if (details.description) {\n console.log(` ${chalk.dim(details.description)}`);\n }\n console.log(\n ` Status: ${details.status === 'AVAILABLE' ? chalk.green(details.status) : chalk.yellow(details.status)}`,\n );\n const detailScripts = details.scriptFiles ?? [];\n if (detailScripts.length > 0) {\n const mainScript = detailScripts.find((s) => s.id === details.mainScriptFileId);\n console.log(\n ` Entrypoint: ${mainScript ? chalk.cyan(mainScript.name) : chalk.red('Not set')}`,\n );\n console.log(` Scripts:`);\n for (const script of detailScripts) {\n const isMain = script.id === details.mainScriptFileId;\n console.log(\n ` ${isMain ? chalk.green('\u25B6') : ' '} ${script.name}${isMain ? chalk.dim(' (entrypoint)') : ''}`,\n );\n }\n } else {\n console.log(` Scripts: ${chalk.dim('None')}`);\n }\n if (details.expectedArguments.length > 0) {\n console.log(` Arguments:`);\n for (const arg of details.expectedArguments) {\n console.log(` - ${arg.name}: ${chalk.dim(arg.defaultValue ?? '')}`);\n }\n }\n console.log();\n }\n }\n } else {\n // Simple list\n for (const app of apps) {\n console.log(` \uD83D\uDCE6 ${app.name}`);\n }\n console.log();\n logger.dim(`Total: ${apps.length} app(s)`);\n logger.dim('Use --details to see more information.');\n }\n } catch (error) {\n logger.error('Failed to list apps.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Show app details\n appCmd\n .command('show [args...]')\n .description('Show details of an app')\n .option('--id <id>', 'Select the app by its numeric id (use when names collide)')\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args, {\n allowEmptyName: !!options.id,\n command: 'app show',\n });\n const { client: api } = await preflightForPair(organisation, tenant);\n const app = await resolveAppOrExit(api, { appName, id: options.id, tenant });\n\n logger.header(`App: ${app.name}`);\n console.log();\n console.log(` ID: ${app.id}`);\n console.log(` Status: ${app.status}`);\n if (app.description) {\n console.log(` Description: ${app.description}`);\n }\n console.log();\n\n const appScripts = app.scriptFiles ?? [];\n if (appScripts.length > 0) {\n console.log(' Scripts:');\n for (const script of appScripts) {\n const isMain = script.id === app.mainScriptFileId;\n console.log(\n ` ${isMain ? chalk.green('\u25B6') : ' '} ${script.name}${isMain ? chalk.dim(' (entrypoint)') : ''}`,\n );\n }\n } else {\n console.log(' Scripts: None');\n }\n console.log();\n\n if (app.expectedArguments.length > 0) {\n console.log(' Arguments:');\n for (const arg of app.expectedArguments) {\n console.log(` - ${arg.name}: ${chalk.dim(arg.defaultValue ?? '')}`);\n }\n } else {\n console.log(' Arguments: None');\n }\n console.log();\n });\n\n // Create app\n appCmd\n .command('create <args...>')\n .description('Create a new app')\n .action(async (args: string[]) => {\n const { organisation, tenant, appName } = parseAppArgs(args);\n const { client: api } = await preflightForPair(organisation, tenant);\n\n // Any name match means the name is taken \u2014 a collision still counts.\n const existing = matchApps(await orExit(api.listApps(), 'Failed to list apps.'), appName);\n if (existing.length > 0) {\n logger.error(`App already exists: ${appName}`);\n process.exit(1);\n }\n\n logger.info(`Creating app: ${appName}...`);\n\n try {\n const app = await api.createApp(appName);\n logger.success(`App created: ${app.name} (ID: ${app.id})`);\n logger.dim('Configure it with: farseer app configure \"' + appName + '\"');\n } catch (error) {\n logger.error('Failed to create app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Delete app\n appCmd\n .command('delete [args...]')\n .description('Delete an app')\n .option('--force', 'Skip confirmation')\n .option('--id <id>', 'Select the app by its numeric id (use when names collide)')\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args, {\n allowEmptyName: !!options.id,\n command: 'app delete',\n });\n const { client: api } = await preflightForPair(organisation, tenant);\n\n const item = await resolveAppItemOrExit(api, { appName, id: options.id, tenant });\n\n if (!options.force) {\n logger.warning(`This will permanently delete app: ${item.name}`);\n logger.dim('Use --force to skip this confirmation.');\n process.exit(1);\n }\n\n logger.info(`Deleting app: ${item.name}...`);\n\n try {\n await api.deleteApp(item.reference);\n\n // The folder API 200s even when nothing was deleted; confirm.\n const remaining = await api.listApps();\n if (remaining.some((a) => a.reference === item.reference)) {\n logger.error(`Delete reported success but \"${item.name}\" is still present.`);\n process.exit(1);\n }\n\n logger.success(`App deleted: ${item.name}`);\n } catch (error) {\n logger.error('Failed to delete app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Configure app\n appCmd\n .command('configure [args...]')\n .description('Configure an app (set source folder, entrypoint, arguments)')\n .option(\n '--entrypoint <script>',\n 'Set the entrypoint script \u2014 must be a file in the app\\'s source folder (e.g., \"index.ts\")',\n )\n .option(\n '--source-folder <path>',\n 'Set the source folder the app\\'s scripts come from (path under Files/, e.g. \"Scripts/MyApp\")',\n )\n .option(\n '--add-arg <arg>',\n 'Add argument in format \"Name=DefaultValue\" (can be used multiple times)',\n collectArgs,\n [],\n )\n .option('--description <desc>', 'Set app description')\n .option('--name <name>', 'Rename the app')\n .option('--id <id>', 'Select the app by its numeric id (use when names collide)')\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args, {\n allowEmptyName: !!options.id,\n command: 'app configure',\n });\n const { client: api } = await preflightForPair(organisation, tenant);\n\n const item = await resolveAppItemOrExit(api, { appName, id: options.id, tenant });\n\n const app = await orExit(api.getApp(item.reference), `Failed to load app details: ${item.name}`);\n if (!app) {\n logger.error(`Failed to load app details: ${item.name}`);\n process.exit(1);\n }\n\n // Build the set of changes. updateApp merges these onto the app's\n // current state, so anything left out here is preserved.\n const changes: AppUpdateChanges = {};\n\n if (options.name) {\n changes.name = options.name;\n }\n\n if (options.description !== undefined) {\n changes.description = options.description;\n }\n\n // Source folder + entrypoint. An app's scripts are derived from its\n // source folder, and the entrypoint must be one of those files. The\n // decision lives in applySourceFolderChange (shared with the MCP\n // configure_app tool); the 'cli' caller gets dimmed, flag-worded hints.\n const sourceFolderError = await orExit(\n applySourceFolderChange(\n api,\n app,\n changes,\n { sourceFolder: options.sourceFolder, entrypoint: options.entrypoint },\n 'cli',\n ),\n 'Failed to read the source folder.',\n );\n if (sourceFolderError) {\n logger.error(sourceFolderError);\n process.exit(1);\n }\n\n // Handle arguments\n if (options.addArg && options.addArg.length > 0) {\n const newArgs: AppArgument[] = [...app.expectedArguments];\n\n for (const arg of options.addArg) {\n const [name, defaultValue] = arg.split('=');\n if (!name || defaultValue === undefined) {\n logger.error(`Invalid argument format: ${arg}`);\n logger.dim('Use format: --add-arg \"Name=DefaultValue\"');\n process.exit(1);\n }\n\n // Check if arg already exists. Lookup is case-insensitive\n // (user-friendly: --add-arg JOBNAME=x updates an existing\n // jobName), but the written name uses the backend's stored\n // casing \u2014 validateExpectedArguments on the server is\n // case-sensitive, and writing the caller-supplied case\n // would silently rename the arg.\n //\n // --add-arg only sets the defaultValue on a string arg; any\n // existing axes (`dataType`, `fixed`, `options`, `secret`)\n // are preserved so updating a boolean/dropdown/locked arg\n // with --add-arg doesn't silently demote it.\n const existingIdx = newArgs.findIndex((a) => a.name.toLowerCase() === name.toLowerCase());\n if (existingIdx >= 0) {\n const existing = newArgs[existingIdx];\n newArgs[existingIdx] = {\n ...existing,\n defaultValue,\n };\n } else {\n newArgs.push({ name, dataType: 'string', defaultValue });\n }\n }\n\n changes.expectedArguments = newArgs;\n }\n\n if (Object.keys(changes).length === 0) {\n logger.warning('No changes specified.');\n logger.dim(\n 'Use --entrypoint, --source-folder, --add-arg, --description, or --name to configure the app.',\n );\n return;\n }\n\n logger.info(`Updating app: ${app.name}...`);\n\n try {\n const updated = await api.updateApp(item.reference, changes, app);\n logger.success(`App updated: ${updated.name}`);\n\n // Show summary of changes\n if (changes.name) console.log(` Name: ${updated.name}`);\n if (changes.description !== undefined)\n console.log(` Description: ${updated.description || '(empty)'}`);\n if (changes.sourceFolderId !== undefined || changes.mainScriptFileId !== undefined) {\n const updatedScripts = updated.scriptFiles ?? [];\n const mainScript = updatedScripts.find((s) => s.id === updated.mainScriptFileId);\n console.log(` Entrypoint: ${mainScript?.name ?? '(none)'}`);\n console.log(` Scripts: ${updatedScripts.map((s) => s.name).join(', ') || '(none)'}`);\n }\n if (changes.expectedArguments) {\n console.log(\n ` Arguments: ${updated.expectedArguments\n .map((a) => {\n const tags: string[] = [];\n if (a.fixed) tags.push('locked');\n if (a.dataType === 'boolean') tags.push('boolean');\n else if (a.options && a.options.length > 0) tags.push('dropdown');\n if (a.secret) tags.push('secret');\n const suffix = tags.length > 0 ? ` (${tags.join(', ')})` : '';\n return `${a.name}=${a.defaultValue ?? ''}${suffix}`;\n })\n .join(', ')}`,\n );\n }\n } catch (error) {\n logger.error('Failed to update app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n}\n\n// Helper to collect multiple --add-arg options\nfunction collectArgs(value: string, previous: string[]): string[] {\n return previous.concat([value]);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,oBAAuB;AACvB,uBAA4C;AAC5C,
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { preflight, preflightForPair } from '../services/preflight';\nimport {\n APP_COMPUTE_CHOICES,\n AppArgument,\n AppUpdateChanges,\n applyRunSettings,\n applySourceFolderChange,\n formatCompute,\n redactActionValues,\n} from '../services/apps';\nimport { orExit, parseAppArgs, resolveAppItemOrExit, resolveAppOrExit } from '../utils/helpers';\nimport { matchByName } from '../utils/nameResolver';\n\nexport function registerAppCommand(program: Command): void {\n const appCmd = program\n .command('app')\n .description('Manage apps on a Farseer instance')\n .addHelpText(\n 'after',\n `\nCommands:\n list [tenant] List all apps\n show [tenant] <name...> Show app details\n create [tenant] <name...> Create a new app\n configure [tenant] <name...> Configure app (source folder, entrypoint, arguments, schedule, runner, compute)\n delete [tenant] <name...> Delete an app (requires --force)\n\nNote: App names with spaces don't need quotes when the tenant comes from FARSEER_TENANT.\n\nExamples:\n $ farseer app list mycompany # List all apps\n $ farseer app show mycompany \"My App\" # Explicit tenant\n $ farseer app show My App # Uses FARSEER_TENANT\n $ farseer app configure \"My App\" --entrypoint index.ts\n $ farseer app configure \"My App\" --schedule \"0 6 * * *\" --compute batch:l\n`,\n );\n\n // List apps\n appCmd\n .command('list [tenant]')\n .description('List all apps on a Farseer instance')\n .option('--details', 'Show detailed information for each app')\n .action(async (tenantArg, options) => {\n const { tenant, client: api, authType } = await preflight(tenantArg);\n const authLabel = authType === 'apiKey' ? 'API key' : 'browser login';\n logger.info(`Fetching apps from ${tenant} (using ${authLabel})...`);\n\n try {\n const apps = await api.listApps();\n\n if (apps.length === 0) {\n logger.warning('No apps found.');\n logger.dim('Create an app with: farseer app create <name>');\n return;\n }\n\n logger.header(`Apps on ${tenant}`);\n console.log();\n\n if (options.details) {\n // Fetch full details for each app\n for (const app of apps) {\n const details = await api.getApp(app.reference);\n if (details) {\n console.log(` \uD83D\uDCE6 ${chalk.bold(details.name)}`);\n if (details.description) {\n console.log(` ${chalk.dim(details.description)}`);\n }\n console.log(\n ` Status: ${details.status === 'AVAILABLE' ? chalk.green(details.status) : chalk.yellow(details.status)}`,\n );\n if (details.schedule) {\n console.log(` Schedule: ${details.schedule}`);\n }\n if (details.runnerName) {\n console.log(` Runner: ${details.runnerName}`);\n }\n if (details.runnerImage) {\n console.log(` Runner image: ${details.runnerImage}`);\n }\n console.log(` Compute: ${formatCompute(details.compute)}`);\n const detailScripts = details.scriptFiles ?? [];\n if (detailScripts.length > 0) {\n const mainScript = detailScripts.find((s) => s.id === details.mainScriptFileId);\n console.log(\n ` Entrypoint: ${mainScript ? chalk.cyan(mainScript.name) : chalk.red('Not set')}`,\n );\n console.log(` Scripts:`);\n for (const script of detailScripts) {\n const isMain = script.id === details.mainScriptFileId;\n console.log(\n ` ${isMain ? chalk.green('\u25B6') : ' '} ${script.name}${isMain ? chalk.dim(' (entrypoint)') : ''}`,\n );\n }\n } else {\n console.log(` Scripts: ${chalk.dim('None')}`);\n }\n if (details.expectedArguments.length > 0) {\n console.log(` Arguments:`);\n for (const arg of details.expectedArguments) {\n console.log(` - ${arg.name}: ${chalk.dim(arg.defaultValue ?? '')}`);\n }\n }\n console.log();\n }\n }\n } else {\n // Simple list\n for (const app of apps) {\n console.log(` \uD83D\uDCE6 ${app.name}`);\n }\n console.log();\n logger.dim(`Total: ${apps.length} app(s)`);\n logger.dim('Use --details to see more information.');\n }\n } catch (error) {\n logger.error('Failed to list apps.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Show app details\n appCmd\n .command('show [args...]')\n .description('Show details of an app')\n .option('--id <id>', 'Select the app by its numeric id (use when names collide)')\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args, {\n allowEmptyName: !!options.id,\n command: 'app show',\n });\n const { client: api } = await preflightForPair(organisation, tenant);\n const app = await resolveAppOrExit(api, { appName, id: options.id, tenant });\n\n logger.header(`App: ${app.name}`);\n console.log();\n console.log(` ID: ${app.id}`);\n console.log(` Status: ${app.status}`);\n if (app.description) {\n console.log(` Description: ${app.description}`);\n }\n console.log(` Schedule: ${app.schedule || '(none)'}`);\n console.log(` Runner: ${app.runnerName || '(any)'}`);\n console.log(` Runner image: ${app.runnerImage || '(default)'}`);\n console.log(` Compute: ${formatCompute(app.compute)}`);\n console.log();\n\n const appScripts = app.scriptFiles ?? [];\n if (appScripts.length > 0) {\n console.log(' Scripts:');\n for (const script of appScripts) {\n const isMain = script.id === app.mainScriptFileId;\n console.log(\n ` ${isMain ? chalk.green('\u25B6') : ' '} ${script.name}${isMain ? chalk.dim(' (entrypoint)') : ''}`,\n );\n }\n } else {\n console.log(' Scripts: None');\n }\n console.log();\n\n if (app.expectedArguments.length > 0) {\n console.log(' Arguments:');\n for (const arg of app.expectedArguments) {\n console.log(` - ${arg.name}: ${chalk.dim(arg.defaultValue ?? '')}`);\n }\n } else {\n console.log(' Arguments: None');\n }\n console.log();\n\n const actions = redactActionValues(app.predefinedActions ?? [], app.expectedArguments);\n if (actions.length > 0) {\n console.log(' Predefined actions:');\n for (const action of actions) {\n const preset = Object.entries(action.runArguments ?? {})\n .map(([name, value]) => `${name}=${value}`)\n .join(', ');\n console.log(` - ${action.name}: ${chalk.dim(preset)}`);\n }\n console.log();\n }\n });\n\n // Create app\n appCmd\n .command('create <args...>')\n .description('Create a new app')\n .action(async (args: string[]) => {\n const { organisation, tenant, appName } = parseAppArgs(args);\n const { client: api } = await preflightForPair(organisation, tenant);\n\n // Any name match means the name is taken \u2014 a collision still counts.\n const existing = matchByName(await orExit(api.listApps(), 'Failed to list apps.'), appName);\n if (existing.length > 0) {\n logger.error(`App already exists: ${appName}`);\n process.exit(1);\n }\n\n logger.info(`Creating app: ${appName}...`);\n\n try {\n const app = await api.createApp(appName);\n logger.success(`App created: ${app.name} (ID: ${app.id})`);\n logger.dim('Configure it with: farseer app configure \"' + appName + '\"');\n } catch (error) {\n logger.error('Failed to create app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Delete app\n appCmd\n .command('delete [args...]')\n .description('Delete an app')\n .option('--force', 'Skip confirmation')\n .option('--id <id>', 'Select the app by its numeric id (use when names collide)')\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args, {\n allowEmptyName: !!options.id,\n command: 'app delete',\n });\n const { client: api } = await preflightForPair(organisation, tenant);\n\n const item = await resolveAppItemOrExit(api, { appName, id: options.id, tenant });\n\n if (!options.force) {\n logger.warning(`This will permanently delete app: ${item.name}`);\n logger.dim('Use --force to skip this confirmation.');\n process.exit(1);\n }\n\n logger.info(`Deleting app: ${item.name}...`);\n\n try {\n await api.deleteApp(item.reference);\n\n // The folder API 200s even when nothing was deleted; confirm.\n const remaining = await api.listApps();\n if (remaining.some((a) => a.reference === item.reference)) {\n logger.error(`Delete reported success but \"${item.name}\" is still present.`);\n process.exit(1);\n }\n\n logger.success(`App deleted: ${item.name}`);\n } catch (error) {\n logger.error('Failed to delete app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Configure app\n appCmd\n .command('configure [args...]')\n .description('Configure an app (source folder, entrypoint, arguments, schedule, runner, compute)')\n .option(\n '--entrypoint <script>',\n 'Set the entrypoint script \u2014 must be a file in the app\\'s source folder (e.g., \"index.ts\")',\n )\n .option(\n '--source-folder <path>',\n 'Set the source folder the app\\'s scripts come from (path under Files/, e.g. \"Scripts/MyApp\")',\n )\n .option(\n '--add-arg <arg>',\n 'Add argument in format \"Name=DefaultValue\" (can be used multiple times)',\n collectArgs,\n [],\n )\n .option('--description <desc>', 'Set app description')\n .option('--name <name>', 'Rename the app')\n .option('--id <id>', 'Select the app by its numeric id (use when names collide)')\n .option('--schedule <cron>', 'Run the app on a cron schedule (e.g. \"0 6 * * *\"). Use \"none\" to clear.')\n .option('--runner <name>', 'Set which jobrunner runs the app. Use \"none\" to clear.')\n .option(\n '--runner-image <image>',\n 'Set the container image, as \"<repository>:<tag>\" (e.g. \"runner-typescript:latest\") or a full registry reference. Use \"none\" to clear.',\n )\n .option(\n '--compute <choice>',\n `Where a run executes: ${APP_COMPUTE_CHOICES.join(', ')}. \"local\" is a container on the jobrunner's own machine, \"batch\" a machine created for that run; the size suffix picks how much machine, and bare \"batch\" takes the deployment's default size.`,\n )\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args, {\n allowEmptyName: !!options.id,\n command: 'app configure',\n });\n const { client: api } = await preflightForPair(organisation, tenant);\n\n const item = await resolveAppItemOrExit(api, { appName, id: options.id, tenant });\n\n const app = await orExit(api.getApp(item.reference), `Failed to load app details: ${item.name}`);\n if (!app) {\n logger.error(`Failed to load app details: ${item.name}`);\n process.exit(1);\n }\n\n // Build the set of changes. updateApp merges these onto the app's\n // current state, so anything left out here is preserved.\n const changes: AppUpdateChanges = {};\n\n if (options.name) {\n changes.name = options.name;\n }\n\n if (options.description !== undefined) {\n changes.description = options.description;\n }\n\n // Source folder + entrypoint. An app's scripts are derived from its\n // source folder, and the entrypoint must be one of those files. The\n // decision lives in applySourceFolderChange (shared with the MCP\n // configure_app tool); the 'cli' caller gets dimmed, flag-worded hints.\n const sourceFolderError = await orExit(\n applySourceFolderChange(\n api,\n app,\n changes,\n { sourceFolder: options.sourceFolder, entrypoint: options.entrypoint },\n 'cli',\n ),\n 'Failed to read the source folder.',\n );\n if (sourceFolderError) {\n logger.error(sourceFolderError);\n process.exit(1);\n }\n\n // Schedule, runner, image and compute. Shared with the MCP\n // configure_app tool so both surfaces take the same vocabulary.\n const runSettings = await orExit(\n applyRunSettings(api, app, changes, {\n schedule: options.schedule,\n runner: options.runner,\n runnerImage: options.runnerImage,\n compute: options.compute,\n }),\n \"Failed to read the tenant's runner images.\",\n );\n if ('error' in runSettings) {\n logger.error(runSettings.error);\n process.exit(1);\n }\n\n // Handle arguments\n if (options.addArg && options.addArg.length > 0) {\n const newArgs: AppArgument[] = [...app.expectedArguments];\n\n for (const arg of options.addArg) {\n const [name, defaultValue] = arg.split('=');\n if (!name || defaultValue === undefined) {\n logger.error(`Invalid argument format: ${arg}`);\n logger.dim('Use format: --add-arg \"Name=DefaultValue\"');\n process.exit(1);\n }\n\n // Check if arg already exists. Lookup is case-insensitive\n // (user-friendly: --add-arg JOBNAME=x updates an existing\n // jobName), but the written name uses the backend's stored\n // casing \u2014 validateExpectedArguments on the server is\n // case-sensitive, and writing the caller-supplied case\n // would silently rename the arg.\n //\n // --add-arg only sets the defaultValue on a string arg; any\n // existing axes (`dataType`, `fixed`, `options`, `secret`)\n // are preserved so updating a boolean/dropdown/locked arg\n // with --add-arg doesn't silently demote it.\n const existingIdx = newArgs.findIndex((a) => a.name.toLowerCase() === name.toLowerCase());\n if (existingIdx >= 0) {\n const existing = newArgs[existingIdx];\n newArgs[existingIdx] = {\n ...existing,\n defaultValue,\n };\n } else {\n newArgs.push({ name, dataType: 'string', defaultValue });\n }\n }\n\n changes.expectedArguments = newArgs;\n }\n\n if (Object.keys(changes).length === 0) {\n logger.warning('No changes specified.');\n logger.dim(\n 'Use --entrypoint, --source-folder, --add-arg, --description, --name, --schedule, --runner, --runner-image or --compute to configure the app.',\n );\n return;\n }\n\n logger.info(`Updating app: ${app.name}...`);\n\n try {\n const updated = await api.updateApp(item.reference, changes, app);\n logger.success(`App updated: ${updated.name}`);\n\n // Show summary of changes\n if (changes.name) console.log(` Name: ${updated.name}`);\n if (changes.description !== undefined)\n console.log(` Description: ${updated.description || '(empty)'}`);\n if (changes.sourceFolderId !== undefined || changes.mainScriptFileId !== undefined) {\n const updatedScripts = updated.scriptFiles ?? [];\n const mainScript = updatedScripts.find((s) => s.id === updated.mainScriptFileId);\n console.log(` Entrypoint: ${mainScript?.name ?? '(none)'}`);\n console.log(` Scripts: ${updatedScripts.map((s) => s.name).join(', ') || '(none)'}`);\n }\n if (changes.expectedArguments) {\n console.log(\n ` Arguments: ${updated.expectedArguments\n .map((a) => {\n const tags: string[] = [];\n if (a.fixed) tags.push('locked');\n if (a.dataType === 'boolean') tags.push('boolean');\n else if (a.options && a.options.length > 0) tags.push('dropdown');\n if (a.secret) tags.push('secret');\n const suffix = tags.length > 0 ? ` (${tags.join(', ')})` : '';\n return `${a.name}=${a.defaultValue ?? ''}${suffix}`;\n })\n .join(', ')}`,\n );\n }\n if ('schedule' in changes) console.log(` Schedule: ${updated.schedule || '(none)'}`);\n if ('runnerName' in changes) console.log(` Runner: ${updated.runnerName || '(any)'}`);\n if ('runnerImage' in changes) console.log(` Runner image: ${updated.runnerImage || '(default)'}`);\n if (changes.compute) console.log(` Compute: ${formatCompute(updated.compute)}`);\n\n for (const warning of runSettings.warnings) {\n logger.warning(warning);\n }\n } catch (error) {\n logger.error('Failed to update app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n}\n\n// Helper to collect multiple --add-arg options\nfunction collectArgs(value: string, previous: string[]): string[] {\n return previous.concat([value]);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,oBAAuB;AACvB,uBAA4C;AAC5C,kBAQO;AACP,qBAA6E;AAC7E,0BAA4B;AAErB,SAAS,mBAAmB,SAAwB;AACvD,QAAM,SAAS,QACV,QAAQ,KAAK,EACb,YAAY,mCAAmC,EAC/C;AAAA,IACG;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBJ;AAGJ,SACK,QAAQ,eAAe,EACvB,YAAY,qCAAqC,EACjD,OAAO,aAAa,wCAAwC,EAC5D,OAAO,OAAO,WAAW,YAAY;AAClC,UAAM,EAAE,QAAQ,QAAQ,KAAK,SAA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AS,SAAQ,IAAI,eAAe,QAAQ,YAAY,QAAQ,EAAE;AACpF,UAAI,gBAAgB,QAAS,SAAQ,IAAI,aAAa,QAAQ,cAAc,OAAO,EAAE;AACrF,UAAI,iBAAiB,QAAS,SAAQ,IAAI,mBAAmB,QAAQ,eAAe,WAAW,EAAE;AACjG,UAAI,QAAQ,QAAS,SAAQ,IAAI,kBAAc,2BAAc,QAAQ,OAAO,CAAC,EAAE;AAE/E,iBAAW,WAAW,YAAY,UAAU;AACxC,6BAAO,QAAQ,OAAO;AAAA,MAC1B;AAAA,IACJ,SAAS,OAAO;AACZ,2BAAO,MAAM,uBAAuB;AACpC,UAAI,iBAAiB,OAAO;AACxB,6BAAO,IAAI,MAAM,OAAO;AAAA,MAC5B;AACA,cAAQ,KAAK,CAAC;AAAA,IAClB;AAAA,EACJ,CAAC;AACT;AAGA,SAAS,YAAY,OAAe,UAA8B;AAC9D,SAAO,SAAS,OAAO,CAAC,KAAK,CAAC;AAClC;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
|
@@ -31,6 +31,7 @@ __export(dashboards_exports, {
|
|
|
31
31
|
registerDashboardsCommand: () => registerDashboardsCommand
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(dashboards_exports);
|
|
34
|
+
var farseer = __toESM(require("farseer-client"));
|
|
34
35
|
var import_chalk = __toESM(require("chalk"));
|
|
35
36
|
var import_logger = require("../utils/logger");
|
|
36
37
|
var import_authErrors = require("../services/authErrors");
|
|
@@ -68,11 +69,24 @@ function registerDashboardsCommand(program) {
|
|
|
68
69
|
dashboardsCmd.command("show <nameOrId> [org] [tenant]").description("Show dashboard details").option("--json", "Output raw JSON").option("--tiles", "Show tile details").action(async (nameOrId, first, second, options) => {
|
|
69
70
|
const { native: nativeClient, tenant } = await (0, import_preflight.preflight)(first, second);
|
|
70
71
|
try {
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
72
|
+
const selection = await (0, import_entityResolver.resolveDashboard)(nativeClient, nameOrId);
|
|
73
|
+
if (selection.kind === "ambiguous") {
|
|
74
|
+
import_logger.logger.error(
|
|
75
|
+
await (0, import_entityResolver.describeAmbiguity)(
|
|
76
|
+
nativeClient,
|
|
77
|
+
"dashboards",
|
|
78
|
+
nameOrId,
|
|
79
|
+
selection.matches,
|
|
80
|
+
farseer.FolderItemType.Dashboard
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
if (selection.kind === "notFound") {
|
|
73
86
|
import_logger.logger.error(`Dashboard "${nameOrId}" not found.`);
|
|
74
87
|
process.exit(1);
|
|
75
88
|
}
|
|
89
|
+
const resolved = selection.entity;
|
|
76
90
|
const dashboard = await nativeClient.dashboards.get(resolved.id);
|
|
77
91
|
if (options.json) {
|
|
78
92
|
console.log(JSON.stringify(dashboard, null, 2));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/dashboards.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { showLoginPrompt, isAuthError } from '../services/authErrors';\nimport { preflight } from '../services/preflight';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,oBAAuB;AACvB,wBAA6C;AAC7C,uBAA0B;AAC1B,
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport * as farseer from 'farseer-client';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { showLoginPrompt, isAuthError } from '../services/authErrors';\nimport { preflight } from '../services/preflight';\nimport { resolveDashboard, describeAmbiguity } from '../utils/entityResolver';\n\nexport function registerDashboardsCommand(program: Command): void {\n const dashboardsCmd = program.command('dashboards').description('List and inspect dashboards');\n\n // farseer dashboards list [org] [tenant]\n dashboardsCmd\n .command('list [org] [tenant]')\n .description('List all dashboards')\n .option('--json', 'Output raw JSON')\n .action(async (first, second, options) => {\n const { native: nativeClient, tenant } = await preflight(first, second);\n\n try {\n const dashboards = await nativeClient.dashboards.list();\n\n if (options.json) {\n const result = dashboards.map((d) => ({\n id: d.id,\n name: d.name,\n tileCount: d.tiles?.length || 0,\n }));\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n logger.header(`Dashboards (${dashboards.length})`);\n if (dashboards.length === 0) {\n logger.dim(' No dashboards found.');\n return;\n }\n for (const d of dashboards) {\n console.log(\n ` ${chalk.dim(String(d.id).padEnd(8))} ${chalk.bold(d.name)} ${chalk.dim(`(${d.tiles?.length || 0} tiles)`)}`,\n );\n }\n } catch (error) {\n handleDashboardError(error, tenant);\n }\n });\n\n // farseer dashboards show <nameOrId> [org] [tenant]\n dashboardsCmd\n .command('show <nameOrId> [org] [tenant]')\n .description('Show dashboard details')\n .option('--json', 'Output raw JSON')\n .option('--tiles', 'Show tile details')\n .action(async (nameOrId, first, second, options) => {\n const { native: nativeClient, tenant } = await preflight(first, second);\n\n try {\n const selection = await resolveDashboard(nativeClient, nameOrId);\n if (selection.kind === 'ambiguous') {\n logger.error(\n await describeAmbiguity(\n nativeClient,\n 'dashboards',\n nameOrId,\n selection.matches,\n farseer.FolderItemType.Dashboard,\n ),\n );\n process.exit(1);\n }\n if (selection.kind === 'notFound') {\n logger.error(`Dashboard \"${nameOrId}\" not found.`);\n process.exit(1);\n }\n const resolved = selection.entity;\n\n const dashboard = await nativeClient.dashboards.get(resolved.id);\n\n if (options.json) {\n console.log(JSON.stringify(dashboard, null, 2));\n return;\n }\n\n logger.header(`Dashboard: ${dashboard.name}`);\n console.log(` ID: ${dashboard.id}`);\n console.log(` Tiles: ${dashboard.tiles?.length || 0}`);\n\n if (options.tiles && dashboard.tiles && dashboard.tiles.length > 0) {\n console.log();\n console.log(' Tile Details:');\n for (const tile of dashboard.tiles) {\n const tileAny = tile as any;\n console.log(\n ` ${chalk.dim(String(tileAny.id).padEnd(8))} ${chalk.bold(tileAny.name || 'Unnamed')}`,\n );\n if (tileAny.type) {\n console.log(` Type: ${tileAny.type}`);\n }\n }\n }\n } catch (error) {\n handleDashboardError(error, tenant);\n }\n });\n}\n\nfunction handleDashboardError(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('Dashboard not found or tenant not accessible.');\n } else if (errorMessage.includes('ENOTFOUND') || errorMessage.includes('ECONNREFUSED')) {\n logger.error('Failed to connect to Farseer.');\n } else {\n logger.error('Dashboard operation failed.');\n logger.dim(errorMessage);\n }\n process.exit(1);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,cAAyB;AACzB,mBAAkB;AAClB,oBAAuB;AACvB,wBAA6C;AAC7C,uBAA0B;AAC1B,4BAAoD;AAE7C,SAAS,0BAA0B,SAAwB;AAC9D,QAAM,gBAAgB,QAAQ,QAAQ,YAAY,EAAE,YAAY,6BAA6B;AAG7F,gBACK,QAAQ,qBAAqB,EAC7B,YAAY,qBAAqB,EACjC,OAAO,UAAU,iBAAiB,EAClC,OAAO,OAAO,OAAO,QAAQ,YAAY;AACtC,UAAM,EAAE,QAAQ,cAAc,OAAO,IAAI,UAAM,4BAAU,OAAO,MAAM;AAEtE,QAAI;AACA,YAAM,aAAa,MAAM,aAAa,WAAW,KAAK;AAEtD,UAAI,QAAQ,MAAM;AACd,cAAM,SAAS,WAAW,IAAI,CAAC,OAAO;AAAA,UAClC,IAAI,EAAE;AAAA,UACN,MAAM,EAAE;AAAA,UACR,WAAW,EAAE,OAAO,UAAU;AAAA,QAClC,EAAE;AACF,gBAAQ,IAAI,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAC3C;AAAA,MACJ;AAEA,2BAAO,OAAO,eAAe,WAAW,MAAM,GA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AAI,aAAa,UAAU,EAAE,EAAE;AACvC,cAAQ,IAAI,aAAa,UAAU,OAAO,UAAU,CAAC,EAAE;AAEvD,UAAI,QAAQ,SAAS,UAAU,SAAS,UAAU,MAAM,SAAS,GAAG;AAChE,gBAAQ,IAAI;AACZ,gBAAQ,IAAI,iBAAiB;AAC7B,mBAAW,QAAQ,UAAU,OAAO;AAChC,gBAAM,UAAU;AAChB,kBAAQ;AAAA,YACJ,OAAO,aAAAA,QAAM,IAAI,OAAO,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,aAAAA,QAAM,KAAK,QAAQ,QAAQ,SAAS,CAAC;AAAA,UAC3F;AACA,cAAI,QAAQ,MAAM;AACd,oBAAQ,IAAI,eAAe,QAAQ,IAAI,EAAE;AAAA,UAC7C;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ,SAAS,OAAO;AACZ,2BAAqB,OAAO,MAAM;AAAA,IACtC;AAAA,EACJ,CAAC;AACT;AAEA,SAAS,qBAAqB,OAAgB,QAAsB;AAChE,QAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAE1E,UAAI,+BAAY,KAAK,GAAG;AACpB,2CAAgB,MAAM;AAAA,EAC1B,WAAW,aAAa,SAAS,KAAK,GAAG;AACrC,yBAAO,MAAM,+CAA+C;AAAA,EAChE,WAAW,aAAa,SAAS,WAAW,KAAK,aAAa,SAAS,cAAc,GAAG;AACpF,yBAAO,MAAM,+BAA+B;AAAA,EAChD,OAAO;AACH,yBAAO,MAAM,6BAA6B;AAC1C,yBAAO,IAAI,YAAY;AAAA,EAC3B;AACA,UAAQ,KAAK,CAAC;AAClB;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
package/dist/commands/sheets.js
CHANGED
|
@@ -38,25 +38,12 @@ var import_logger = require("../utils/logger");
|
|
|
38
38
|
var import_authErrors = require("../services/authErrors");
|
|
39
39
|
var import_preflight = require("../services/preflight");
|
|
40
40
|
var import_entityResolver = require("../utils/entityResolver");
|
|
41
|
-
var import_farseer_client = require("farseer-client");
|
|
42
41
|
function registerSheetsCommand(program) {
|
|
43
42
|
const sheetsCmd = program.command("sheets").description("List and inspect sheets");
|
|
44
43
|
sheetsCmd.command("list [org] [tenant]").description("List all sheets").option("--json", "Output raw JSON").action(async (first, second, options) => {
|
|
45
44
|
const { native: nativeClient, tenant } = await (0, import_preflight.preflight)(first, second);
|
|
46
45
|
try {
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
const entities = await nativeClient.entities.getAll([import_farseer_client.EntityType.Sheet]);
|
|
50
|
-
sheets = entities.map((e) => ({
|
|
51
|
-
id: e.id,
|
|
52
|
-
name: e.meta?.name || `Sheet ${e.id}`
|
|
53
|
-
}));
|
|
54
|
-
} catch {
|
|
55
|
-
sheets = [];
|
|
56
|
-
}
|
|
57
|
-
if (sheets.length === 0) {
|
|
58
|
-
sheets = await collectFolderItems(nativeClient, null, [], farseer.FolderItemType.Sheet);
|
|
59
|
-
}
|
|
46
|
+
const sheets = await (0, import_entityResolver.listSheets)(nativeClient);
|
|
60
47
|
if (options.json) {
|
|
61
48
|
console.log(JSON.stringify(sheets, null, 2));
|
|
62
49
|
return;
|
|
@@ -77,11 +64,24 @@ function registerSheetsCommand(program) {
|
|
|
77
64
|
sheetsCmd.command("show <nameOrId> [org] [tenant]").description("Show sheet configuration").option("--json", "Output raw JSON").action(async (nameOrId, first, second, options) => {
|
|
78
65
|
const { native: nativeClient, tenant } = await (0, import_preflight.preflight)(first, second);
|
|
79
66
|
try {
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
67
|
+
const selection = await (0, import_entityResolver.resolveSheet)(nativeClient, nameOrId);
|
|
68
|
+
if (selection.kind === "ambiguous") {
|
|
69
|
+
import_logger.logger.error(
|
|
70
|
+
await (0, import_entityResolver.describeAmbiguity)(
|
|
71
|
+
nativeClient,
|
|
72
|
+
"sheets",
|
|
73
|
+
nameOrId,
|
|
74
|
+
selection.matches,
|
|
75
|
+
farseer.FolderItemType.Sheet
|
|
76
|
+
)
|
|
77
|
+
);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
if (selection.kind === "notFound") {
|
|
82
81
|
import_logger.logger.error(`Sheet "${nameOrId}" not found.`);
|
|
83
82
|
process.exit(1);
|
|
84
83
|
}
|
|
84
|
+
const resolved = selection.entity;
|
|
85
85
|
const sheet = await nativeClient.sheets.get(resolved.id);
|
|
86
86
|
if (options.json) {
|
|
87
87
|
console.log(JSON.stringify(sheet, null, 2));
|
|
@@ -103,11 +103,24 @@ function registerSheetsCommand(program) {
|
|
|
103
103
|
sheetsCmd.command("data <nameOrId> [org] [tenant]").description("Get sheet data").option("--json", "Output raw JSON").option("--limit <n>", "Limit number of rows", parseInt).action(async (nameOrId, first, second, options) => {
|
|
104
104
|
const { native: nativeClient, tenant } = await (0, import_preflight.preflight)(first, second);
|
|
105
105
|
try {
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
106
|
+
const selection = await (0, import_entityResolver.resolveSheet)(nativeClient, nameOrId);
|
|
107
|
+
if (selection.kind === "ambiguous") {
|
|
108
|
+
import_logger.logger.error(
|
|
109
|
+
await (0, import_entityResolver.describeAmbiguity)(
|
|
110
|
+
nativeClient,
|
|
111
|
+
"sheets",
|
|
112
|
+
nameOrId,
|
|
113
|
+
selection.matches,
|
|
114
|
+
farseer.FolderItemType.Sheet
|
|
115
|
+
)
|
|
116
|
+
);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
if (selection.kind === "notFound") {
|
|
108
120
|
import_logger.logger.error(`Sheet "${nameOrId}" not found.`);
|
|
109
121
|
process.exit(1);
|
|
110
122
|
}
|
|
123
|
+
const resolved = selection.entity;
|
|
111
124
|
const sheet = await nativeClient.sheets.get(resolved.id);
|
|
112
125
|
const dataRequest = {
|
|
113
126
|
path: `/${resolved.id}`,
|
|
@@ -143,11 +156,24 @@ function registerSheetsCommand(program) {
|
|
|
143
156
|
sheetsCmd.command("set-data [org] [tenant]").description("Set sheet data from JSON file").requiredOption("--sheet <nameOrId>", "Sheet name or ID").requiredOption("--input <file>", "JSON file with sheet data").option("-y, --yes", "Skip confirmation").action(async (first, second, options) => {
|
|
144
157
|
const { native: nativeClient, tenant } = await (0, import_preflight.preflight)(first, second);
|
|
145
158
|
try {
|
|
146
|
-
const
|
|
147
|
-
if (
|
|
159
|
+
const selection = await (0, import_entityResolver.resolveSheet)(nativeClient, options.sheet);
|
|
160
|
+
if (selection.kind === "ambiguous") {
|
|
161
|
+
import_logger.logger.error(
|
|
162
|
+
await (0, import_entityResolver.describeAmbiguity)(
|
|
163
|
+
nativeClient,
|
|
164
|
+
"sheets",
|
|
165
|
+
options.sheet,
|
|
166
|
+
selection.matches,
|
|
167
|
+
farseer.FolderItemType.Sheet
|
|
168
|
+
)
|
|
169
|
+
);
|
|
170
|
+
process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
if (selection.kind === "notFound") {
|
|
148
173
|
import_logger.logger.error(`Sheet "${options.sheet}" not found.`);
|
|
149
174
|
process.exit(1);
|
|
150
175
|
}
|
|
176
|
+
const resolved = selection.entity;
|
|
151
177
|
if (!fs.existsSync(options.input)) {
|
|
152
178
|
import_logger.logger.error(`File not found: ${options.input}`);
|
|
153
179
|
process.exit(1);
|
|
@@ -169,20 +195,6 @@ function registerSheetsCommand(program) {
|
|
|
169
195
|
}
|
|
170
196
|
});
|
|
171
197
|
}
|
|
172
|
-
async function collectFolderItems(client, folderId, path, itemType) {
|
|
173
|
-
const items = [];
|
|
174
|
-
const results = await client.folders.listItemsBatch([{ id: folderId }]);
|
|
175
|
-
const children = results[0]?.items ?? [];
|
|
176
|
-
for (const child of children) {
|
|
177
|
-
if (child.type === itemType) {
|
|
178
|
-
items.push({ id: child.id, name: child.name, folderPath: path });
|
|
179
|
-
} else if (child.type === farseer.FolderItemType.Folder) {
|
|
180
|
-
const sub = await collectFolderItems(client, child.id, [...path, child.name], itemType);
|
|
181
|
-
items.push(...sub);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return items;
|
|
185
|
-
}
|
|
186
198
|
function handleSheetError(error, tenant) {
|
|
187
199
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
188
200
|
if ((0, import_authErrors.isAuthError)(error)) {
|