farseer-cli 1.11.2 → 1.13.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 +88 -10
- package/dist/commands/app.js +54 -4
- package/dist/commands/app.js.map +2 -2
- package/dist/commands/login.js +60 -26
- package/dist/commands/login.js.map +2 -2
- package/dist/commands/logout.js +37 -12
- package/dist/commands/logout.js.map +3 -3
- package/dist/commands/run.js +10 -27
- package/dist/commands/run.js.map +2 -2
- package/dist/commands/whoami.js +10 -14
- package/dist/commands/whoami.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 +54 -4
- package/dist/mcp/tools/appTools.js.map +2 -2
- package/dist/mcp/tools/authTools.js +5 -2
- package/dist/mcp/tools/authTools.js.map +2 -2
- package/dist/mcp/tools/runTools.js +5 -18
- package/dist/mcp/tools/runTools.js.map +2 -2
- package/dist/mcp/utils/helpers.js +16 -6
- package/dist/mcp/utils/helpers.js.map +3 -3
- package/dist/mcp/utils/session.js +14 -9
- package/dist/mcp/utils/session.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/authErrors.js +2 -2
- package/dist/services/authErrors.js.map +2 -2
- package/dist/services/configService.js +45 -9
- package/dist/services/configService.js.map +2 -2
- package/dist/services/credentials.js +10 -7
- package/dist/services/credentials.js.map +2 -2
- package/dist/services/farseerService.js +95 -36
- package/dist/services/farseerService.js.map +2 -2
- package/dist/services/preflight.js +3 -2
- package/dist/services/preflight.js.map +2 -2
- package/dist/services/realms.js +67 -0
- package/dist/services/realms.js.map +7 -0
- package/docs/cli-guide.md +16 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -188,15 +188,26 @@ Farseer CLI supports two authentication methods:
|
|
|
188
188
|
# Default realm (master)
|
|
189
189
|
farseer login
|
|
190
190
|
|
|
191
|
-
#
|
|
191
|
+
# An organisation with its own realm: the CLI looks the realm up
|
|
192
|
+
farseer login --org acme
|
|
193
|
+
|
|
194
|
+
# Or name the realm directly (case-insensitive)
|
|
192
195
|
farseer login --realm acme
|
|
196
|
+
|
|
197
|
+
# Farseer staff, into a customer realm with a Farseer account
|
|
198
|
+
farseer login --org acme --idp-hint farseer-master
|
|
193
199
|
```
|
|
194
200
|
|
|
195
201
|
Opens Keycloak login in browser. Features:
|
|
196
202
|
- Automatic token refresh
|
|
197
|
-
-
|
|
203
|
+
- One login per realm, kept side by side; each command uses the one for its organisation's realm
|
|
204
|
+
- Access to all tenants you have permissions for in that realm
|
|
198
205
|
- Full functionality (scripts + apps)
|
|
199
206
|
|
|
207
|
+
A customer realm's login opens the organisation's own sign-in, as the web app does. Farseer staff have no password there and go through the `farseer-master` provider instead; if the browser has no Farseer session yet, the same tab asks for the Farseer login first.
|
|
208
|
+
|
|
209
|
+
`farseer logout` ends every browser login (`--realm <realm>` for one) at Keycloak and removes it locally.
|
|
210
|
+
|
|
200
211
|
### API Key Login
|
|
201
212
|
|
|
202
213
|
```bash
|
|
@@ -515,10 +526,32 @@ farseer app configure My App --add-arg "Year=2025"
|
|
|
515
526
|
|
|
516
527
|
# Set description
|
|
517
528
|
farseer app configure My App --description "Imports data"
|
|
529
|
+
|
|
530
|
+
# Run it every morning at 06:00
|
|
531
|
+
farseer app configure My App --schedule "0 6 * * *"
|
|
532
|
+
|
|
533
|
+
# Pick the jobrunner and the container image it runs in
|
|
534
|
+
farseer app configure My App --runner runner-1 --runner-image runner-typescript:latest
|
|
535
|
+
|
|
536
|
+
# Give the run a machine of its own, sized large
|
|
537
|
+
farseer app configure My App --compute batch:l
|
|
518
538
|
```
|
|
519
539
|
|
|
520
540
|
Settings you don't pass are preserved — `configure` only changes what you specify.
|
|
521
541
|
|
|
542
|
+
| Flag | Sets |
|
|
543
|
+
|---|---|
|
|
544
|
+
| `--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. |
|
|
545
|
+
| `--runner <name>` | Which connected jobrunner runs the app. Unset means any of them. |
|
|
546
|
+
| `--runner-image <image>` | Container image, as `<repository>:<tag>` — the tenant's registry prefix is filled in — or a full registry reference. |
|
|
547
|
+
| `--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. |
|
|
548
|
+
|
|
549
|
+
Pass `none` to `--schedule`, `--runner` or `--runner-image` to clear it.
|
|
550
|
+
|
|
551
|
+
A runner that isn't connected, or one that can't run the compute you picked, is
|
|
552
|
+
reported as a warning rather than an error: these settings outlive any one
|
|
553
|
+
connection, so a jobrunner that happens to be restarting doesn't block you.
|
|
554
|
+
|
|
522
555
|
If you move the source folder to one that doesn't contain the app's current
|
|
523
556
|
entrypoint, pass `--entrypoint` in the same command — `configure` errors rather
|
|
524
557
|
than silently clearing or relocating the entrypoint.
|
|
@@ -673,6 +706,7 @@ Once configured, AI assistants have access to:
|
|
|
673
706
|
- `farseer_get_app` - Get app details
|
|
674
707
|
- `farseer_create_app` - Create new app
|
|
675
708
|
- `farseer_configure_app` - Configure app (scripts can be referenced by filename or full path)
|
|
709
|
+
- `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
710
|
- `farseer_delete_app` - Delete app
|
|
677
711
|
- `farseer_run_app` - Run app locally
|
|
678
712
|
- `farseer_install` - Install dependencies (auto-creates package.json, supports adding extra npm packages)
|
|
@@ -779,6 +813,9 @@ apps/
|
|
|
779
813
|
{ "name": "Year", "defaultValue": "2025" },
|
|
780
814
|
{ "name": "Version", "defaultValue": "Plan" }
|
|
781
815
|
],
|
|
816
|
+
"schedule": "0 6 * * *",
|
|
817
|
+
"runnerImage": "europe-docker.pkg.dev/farseer/runners/runner-typescript:1.4.0",
|
|
818
|
+
"compute": "batch:l",
|
|
782
819
|
"_remote": {
|
|
783
820
|
"id": 123,
|
|
784
821
|
"reference": "123"
|
|
@@ -791,6 +828,40 @@ apps/
|
|
|
791
828
|
- For **existing apps**: `_remote` links local JSON to remote app
|
|
792
829
|
- Never edit `_remote` manually
|
|
793
830
|
|
|
831
|
+
`schedule`, `runnerImage` and `compute` are managed by whether the key is there.
|
|
832
|
+
A key present means the file decides that setting and `push` writes it —
|
|
833
|
+
including `null`, which clears it. A key absent means the file says nothing about
|
|
834
|
+
it and `push` leaves whatever the tenant has, so a config written before these
|
|
835
|
+
fields existed never clears a live schedule. `pull` writes all three, so pulling
|
|
836
|
+
once puts them under version control — including in a file that predates them,
|
|
837
|
+
which the first `pull` after upgrading rewrites to add the missing keys.
|
|
838
|
+
|
|
839
|
+
Two settings are not in the file, and are set with `app configure` or the
|
|
840
|
+
`farseer_configure_app` tool instead:
|
|
841
|
+
|
|
842
|
+
- **The runner.** The backend assigns a runner to a scheduled job that has none,
|
|
843
|
+
and stores it. A file cannot tell that assignment from a choice, so pulling it
|
|
844
|
+
would pin whatever the scheduler happened to pick, and pushing would clear it
|
|
845
|
+
only for the scheduler to assign it again.
|
|
846
|
+
- **Predefined actions.** The backend returns their values readable even for
|
|
847
|
+
arguments marked secret, so writing them to the file would put secrets in the
|
|
848
|
+
workspace and in git. `app show` and `farseer_get_app` show a secret
|
|
849
|
+
argument's value as `<secret>`. Pushing a file never touches the tenant's
|
|
850
|
+
actions.
|
|
851
|
+
|
|
852
|
+
`pull` removes `runner` and `predefinedActions` from a file an earlier version
|
|
853
|
+
wrote them into.
|
|
854
|
+
|
|
855
|
+
The file holds stored values, not the shorthands `app configure` accepts.
|
|
856
|
+
`runnerImage` must be the full registry reference: `push` sends it as written and
|
|
857
|
+
the API rejects a bare `<repository>:<tag>`. `none` is a flag keyword, so write
|
|
858
|
+
`null` in the file to clear a setting. `schedule` is sent as written and is not
|
|
859
|
+
checked here — see the note under `--schedule` above.
|
|
860
|
+
|
|
861
|
+
A teammate still on an older CLI drops these three keys from the file on their
|
|
862
|
+
next `pull`, because their version does not know about them; the tenant's own
|
|
863
|
+
settings are untouched and the next `pull` on this version puts the keys back.
|
|
864
|
+
|
|
794
865
|
---
|
|
795
866
|
|
|
796
867
|
## Configuration
|
|
@@ -811,11 +882,16 @@ apps/
|
|
|
811
882
|
"basePath": "https://my-org.farseer.io/api/v3"
|
|
812
883
|
}
|
|
813
884
|
},
|
|
814
|
-
"
|
|
815
|
-
"
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
885
|
+
"userAuths": {
|
|
886
|
+
"master": {
|
|
887
|
+
"accessToken": "...",
|
|
888
|
+
"refreshToken": "...",
|
|
889
|
+
"expiresAt": "2025-01-28T10:00:00Z",
|
|
890
|
+
"realm": "master"
|
|
891
|
+
}
|
|
892
|
+
},
|
|
893
|
+
"organisationRealms": {
|
|
894
|
+
"acme": "ACME"
|
|
819
895
|
},
|
|
820
896
|
"tenantOrgMapping": {
|
|
821
897
|
"my-tenant": "my-org"
|
|
@@ -945,9 +1021,11 @@ farseer app configure "My App" --entrypoint index.ts
|
|
|
945
1021
|
### Login Issues with Different Realm
|
|
946
1022
|
|
|
947
1023
|
```bash
|
|
948
|
-
#
|
|
949
|
-
farseer login --
|
|
950
|
-
|
|
1024
|
+
# Let the organisation name its realm
|
|
1025
|
+
farseer login --org acme
|
|
1026
|
+
|
|
1027
|
+
# Farseer staff: a customer realm's own form has no password for you
|
|
1028
|
+
farseer login --org acme --idp-hint farseer-master
|
|
951
1029
|
```
|
|
952
1030
|
|
|
953
1031
|
---
|
package/dist/commands/app.js
CHANGED
|
@@ -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,6 +174,15 @@ 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);
|
|
@@ -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 { 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)\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 = 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 (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,SAAS,IAAI,UAAM,4BAAU,SAAS;AACnE,UAAM,YAAY,aAAa,WAAW,YAAY;AACtD,yBAAO,KAAK,sBAAsB,M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a,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
|
}
|
package/dist/commands/login.js
CHANGED
|
@@ -34,41 +34,44 @@ module.exports = __toCommonJS(login_exports);
|
|
|
34
34
|
var import_inquirer = __toESM(require("inquirer"));
|
|
35
35
|
var import_logger = require("../utils/logger");
|
|
36
36
|
var import_configService = require("../services/configService");
|
|
37
|
+
var import_realms = require("../services/realms");
|
|
37
38
|
var import_farseerService = require("../services/farseerService");
|
|
38
39
|
var import_helpers = require("../utils/helpers");
|
|
40
|
+
const MASTER_IDP_HINT = "farseer-master";
|
|
39
41
|
function registerLoginCommand(program) {
|
|
40
|
-
program.command("login").description("Login to Farseer (opens browser or use --api-key)").option("--api-key", "Login using API key instead of browser").option("--realm <realm>", "Keycloak realm to use (default: master)").
|
|
42
|
+
program.command("login").description("Login to Farseer (opens browser or use --api-key)").option("--api-key", "Login using API key instead of browser").option("--org <organisation>", "Log in to the Keycloak realm of this organisation's tenants (e.g. jgl)").option("--realm <realm>", "Keycloak realm to use (default: master)").option(
|
|
43
|
+
"--idp-hint <hint>",
|
|
44
|
+
`Identity provider to log in through (default: the organisation's own; Farseer staff: "${MASTER_IDP_HINT}")`
|
|
45
|
+
).option("--no-idp-hint", "Use the realm's own login form, ignoring the organisation's identity provider").action(async (options) => {
|
|
41
46
|
if (options.apiKey) {
|
|
42
47
|
await loginWithApiKey();
|
|
43
48
|
} else {
|
|
44
|
-
await loginViaBrowser(options
|
|
49
|
+
await loginViaBrowser(options);
|
|
45
50
|
}
|
|
46
51
|
});
|
|
47
52
|
}
|
|
48
|
-
async function loginViaBrowser(realm) {
|
|
49
|
-
let realmToUse = realm || "master";
|
|
53
|
+
async function loginViaBrowser({ org, realm, idpHint }) {
|
|
50
54
|
import_logger.logger.header("Farseer Login");
|
|
51
|
-
if (realm) {
|
|
52
|
-
import_logger.logger.
|
|
53
|
-
|
|
54
|
-
if (!resolved) {
|
|
55
|
-
import_logger.logger.error(`Realm "${realm}" not found on Keycloak server.`);
|
|
56
|
-
import_logger.logger.dim("Check the realm name and try again (realm names are case-sensitive).");
|
|
57
|
-
import_logger.logger.dim("Example: farseer login --realm JGL");
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
realmToUse = resolved;
|
|
61
|
-
if (resolved !== realm) {
|
|
62
|
-
import_logger.logger.info(`Realm resolved to: ${resolved}`);
|
|
63
|
-
} else {
|
|
64
|
-
import_logger.logger.info(`Using realm: ${realmToUse}`);
|
|
65
|
-
}
|
|
55
|
+
if (org && realm) {
|
|
56
|
+
import_logger.logger.error("Pass either --org or --realm, not both.");
|
|
57
|
+
process.exit(1);
|
|
66
58
|
}
|
|
59
|
+
const target = org ? await realmOfOrganisationOrExit(org) : { realm: realm ? await resolveRealmOrExit(realm) : import_configService.DEFAULT_REALM };
|
|
60
|
+
const realmToUse = target.realm;
|
|
61
|
+
const hintToUse = resolveIdpHint(idpHint, target.idpHint);
|
|
67
62
|
import_logger.logger.info("Opening browser for login...");
|
|
68
63
|
import_logger.logger.dim("Waiting for authentication (timeout: 5 minutes)...");
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
if (hintToUse) {
|
|
65
|
+
import_logger.logger.dim(`Identity provider: ${hintToUse}`);
|
|
66
|
+
} else if (realmToUse !== import_configService.DEFAULT_REALM) {
|
|
67
|
+
import_logger.logger.dim(`Farseer staff: add --idp-hint ${MASTER_IDP_HINT} to log in with your Farseer account.`);
|
|
68
|
+
}
|
|
69
|
+
const result = await (0, import_farseerService.loginWithBrowser)(realmToUse, {
|
|
70
|
+
idpHint: hintToUse,
|
|
71
|
+
viaMasterSession: hintToUse === MASTER_IDP_HINT
|
|
72
|
+
});
|
|
73
|
+
if (!result.ok) {
|
|
74
|
+
import_logger.logger.error(`Login failed or timed out${result.error ? ` (${result.error})` : ""}.`);
|
|
72
75
|
import_logger.logger.dim("Try using --api-key for manual API key login.");
|
|
73
76
|
process.exit(1);
|
|
74
77
|
}
|
|
@@ -80,13 +83,44 @@ async function loginViaBrowser(realm) {
|
|
|
80
83
|
realm: realmToUse
|
|
81
84
|
});
|
|
82
85
|
import_logger.logger.success("Login successful!");
|
|
86
|
+
import_logger.logger.dim(`Realm: ${realmToUse}`);
|
|
83
87
|
import_logger.logger.dim(`Token expires at: ${expiresAt.toLocaleString()}`);
|
|
84
|
-
|
|
85
|
-
import_logger.logger.dim(`Realm: ${realmToUse}`);
|
|
86
|
-
}
|
|
87
|
-
import_logger.logger.dim("You can now access any tenant you have permissions for.");
|
|
88
|
+
import_logger.logger.dim(`You can now access any tenant in realm "${realmToUse}" you have permissions for.`);
|
|
88
89
|
process.exit(0);
|
|
89
90
|
}
|
|
91
|
+
async function realmOfOrganisationOrExit(organisation) {
|
|
92
|
+
import_logger.logger.info(`Looking up the realm of organisation: ${organisation}...`);
|
|
93
|
+
const config = await (0, import_realms.fetchOrganisationKeycloakConfig)(organisation);
|
|
94
|
+
if (!config) {
|
|
95
|
+
import_logger.logger.error(`Could not read the login configuration of "${organisation}".`);
|
|
96
|
+
import_logger.logger.dim(`Check that https://${organisation}.farseer.io is reachable, or pass --realm <realm> instead.`);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
(0, import_configService.saveOrganisationRealm)(organisation, config.realm);
|
|
100
|
+
import_logger.logger.info(`Using realm: ${config.realm}`);
|
|
101
|
+
return config;
|
|
102
|
+
}
|
|
103
|
+
async function resolveRealmOrExit(realm) {
|
|
104
|
+
import_logger.logger.info(`Resolving realm: ${realm}...`);
|
|
105
|
+
const resolved = await (0, import_farseerService.resolveRealm)(realm);
|
|
106
|
+
if (!resolved) {
|
|
107
|
+
import_logger.logger.error(`Realm "${realm}" not found on Keycloak server.`);
|
|
108
|
+
import_logger.logger.dim("Check the realm name and try again (realm names are case-sensitive).");
|
|
109
|
+
import_logger.logger.dim("Or let the organisation pick it: farseer login --org jgl");
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
import_logger.logger.info(resolved !== realm ? `Realm resolved to: ${resolved}` : `Using realm: ${resolved}`);
|
|
113
|
+
return resolved;
|
|
114
|
+
}
|
|
115
|
+
function resolveIdpHint(idpHint, organisationHint) {
|
|
116
|
+
if (typeof idpHint === "string") {
|
|
117
|
+
return idpHint;
|
|
118
|
+
}
|
|
119
|
+
if (idpHint === false) {
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
return organisationHint;
|
|
123
|
+
}
|
|
90
124
|
async function loginWithApiKey() {
|
|
91
125
|
import_logger.logger.header("Farseer Login (API Key)");
|
|
92
126
|
const answers = await import_inquirer.default.prompt([
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/login.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport inquirer from 'inquirer';\nimport { logger } from '../utils/logger';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAqB;AACrB,oBAAuB;AACvB,
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport inquirer from 'inquirer';\nimport { logger } from '../utils/logger';\nimport {\n setCredential,\n setUserAuth,\n generateBasePath,\n saveOrganisationRealm,\n ApiKeyCredential,\n DEFAULT_REALM,\n} from '../services/configService';\nimport { fetchOrganisationKeycloakConfig, type OrganisationKeycloakConfig } from '../services/realms';\nimport { loginWithBrowser, resolveRealm, FarseerService } from '../services/farseerService';\nimport { connectionFailureMessage } from '../utils/helpers';\n\n/** Keycloak identity provider that brokers a master-realm account into a customer realm. */\nconst MASTER_IDP_HINT = 'farseer-master';\n\nexport function registerLoginCommand(program: Command): void {\n program\n .command('login')\n .description('Login to Farseer (opens browser or use --api-key)')\n .option('--api-key', 'Login using API key instead of browser')\n .option('--org <organisation>', \"Log in to the Keycloak realm of this organisation's tenants (e.g. jgl)\")\n .option('--realm <realm>', 'Keycloak realm to use (default: master)')\n .option(\n '--idp-hint <hint>',\n `Identity provider to log in through (default: the organisation's own; Farseer staff: \"${MASTER_IDP_HINT}\")`,\n )\n .option('--no-idp-hint', \"Use the realm's own login form, ignoring the organisation's identity provider\")\n .action(async (options) => {\n if (options.apiKey) {\n await loginWithApiKey();\n } else {\n await loginViaBrowser(options);\n }\n });\n}\n\ninterface BrowserLoginOptions {\n org?: string;\n realm?: string;\n idpHint?: string | boolean;\n}\n\nasync function loginViaBrowser({ org, realm, idpHint }: BrowserLoginOptions): Promise<void> {\n logger.header('Farseer Login');\n\n if (org && realm) {\n logger.error('Pass either --org or --realm, not both.');\n process.exit(1);\n }\n\n const target = org\n ? await realmOfOrganisationOrExit(org)\n : { realm: realm ? await resolveRealmOrExit(realm) : DEFAULT_REALM };\n const realmToUse = target.realm;\n\n // Same default as the web app: the organisation's own provider. An @farseer.io\n // account has no password in a customer realm, so staff go through the\n // farseer-master broker instead, which federates their master-realm session.\n const hintToUse = resolveIdpHint(idpHint, target.idpHint);\n\n logger.info('Opening browser for login...');\n logger.dim('Waiting for authentication (timeout: 5 minutes)...');\n if (hintToUse) {\n logger.dim(`Identity provider: ${hintToUse}`);\n } else if (realmToUse !== DEFAULT_REALM) {\n logger.dim(`Farseer staff: add --idp-hint ${MASTER_IDP_HINT} to log in with your Farseer account.`);\n }\n\n const result = await loginWithBrowser(realmToUse, {\n idpHint: hintToUse,\n viaMasterSession: hintToUse === MASTER_IDP_HINT,\n });\n\n if (!result.ok) {\n logger.error(`Login failed or timed out${result.error ? ` (${result.error})` : ''}.`);\n logger.dim('Try using --api-key for manual API key login.');\n process.exit(1);\n }\n\n const expiresAt = new Date(Date.now() + result.expiresIn * 1000);\n\n setUserAuth({\n accessToken: result.accessToken,\n refreshToken: result.refreshToken,\n expiresAt: expiresAt.toISOString(),\n realm: realmToUse,\n });\n\n logger.success('Login successful!');\n logger.dim(`Realm: ${realmToUse}`);\n logger.dim(`Token expires at: ${expiresAt.toLocaleString()}`);\n logger.dim(`You can now access any tenant in realm \"${realmToUse}\" you have permissions for.`);\n process.exit(0);\n}\n\nasync function realmOfOrganisationOrExit(organisation: string): Promise<OrganisationKeycloakConfig> {\n logger.info(`Looking up the realm of organisation: ${organisation}...`);\n const config = await fetchOrganisationKeycloakConfig(organisation);\n if (!config) {\n logger.error(`Could not read the login configuration of \"${organisation}\".`);\n logger.dim(`Check that https://${organisation}.farseer.io is reachable, or pass --realm <realm> instead.`);\n process.exit(1);\n }\n saveOrganisationRealm(organisation, config.realm);\n logger.info(`Using realm: ${config.realm}`);\n return config;\n}\n\n/** Realm names are case-sensitive, and people type them from the org name. */\nasync function resolveRealmOrExit(realm: string): Promise<string> {\n logger.info(`Resolving realm: ${realm}...`);\n const resolved = await resolveRealm(realm);\n if (!resolved) {\n logger.error(`Realm \"${realm}\" not found on Keycloak server.`);\n logger.dim('Check the realm name and try again (realm names are case-sensitive).');\n logger.dim('Or let the organisation pick it: farseer login --org jgl');\n process.exit(1);\n }\n logger.info(resolved !== realm ? `Realm resolved to: ${resolved}` : `Using realm: ${resolved}`);\n return resolved;\n}\n\n/**\n * `--idp-hint <hint>` picks the provider, `--no-idp-hint` forces the realm's own form\n * (commander gives us `false` for it), and anything else falls back to the\n * organisation's own provider \u2014 none with `--realm`, which names no organisation.\n */\nfunction resolveIdpHint(idpHint: string | boolean | undefined, organisationHint?: string): string | undefined {\n if (typeof idpHint === 'string') {\n return idpHint;\n }\n if (idpHint === false) {\n return undefined;\n }\n return organisationHint;\n}\n\nasync function loginWithApiKey(): Promise<void> {\n logger.header('Farseer Login (API Key)');\n\n const answers = await inquirer.prompt([\n {\n type: 'input',\n name: 'tenant',\n message: 'Tenant ID (e.g., tthotels):',\n validate: (input) => {\n if (!input || input.trim() === '') {\n return 'Tenant ID is required';\n }\n return true;\n },\n },\n {\n type: 'input',\n name: 'organisation',\n message: 'Organisation (leave empty if same as tenant):',\n },\n {\n type: 'password',\n name: 'apiKey',\n message: 'API Key:',\n mask: '*',\n validate: (input) => {\n if (!input || input.trim() === '') {\n return 'API Key is required';\n }\n return true;\n },\n },\n ]);\n\n const tenant = answers.tenant.trim();\n const organisation = answers.organisation.trim() || tenant;\n const apiKey = answers.apiKey.trim();\n const basePath = generateBasePath(organisation);\n\n logger.info('Testing connection...');\n\n const credential: ApiKeyCredential = {\n type: 'apiKey',\n tenantId: tenant,\n apiKey: apiKey,\n basePath: basePath,\n };\n\n const service = new FarseerService({ kind: 'apiKey', credential });\n const connection = await service.checkConnection();\n\n if (!connection.ok) {\n logger.error(connectionFailureMessage(connection.reason, basePath, tenant));\n logger.dim(connection.message);\n process.exit(1);\n }\n\n setCredential(tenant, credential);\n\n logger.success(`Successfully connected to ${tenant}!`);\n logger.dim(`Credentials saved for tenant: ${tenant}`);\n logger.dim(`Base path: ${basePath}`);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAqB;AACrB,oBAAuB;AACvB,2BAOO;AACP,oBAAiF;AACjF,4BAA+D;AAC/D,qBAAyC;AAGzC,MAAM,kBAAkB;AAEjB,SAAS,qBAAqB,SAAwB;AACzD,UACK,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