@revoengine/cli 1.0.14 → 1.0.16
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 +57 -21
- package/dist/src/cli.js +5 -1
- package/dist/src/client.d.ts +25 -14
- package/dist/src/client.js +67 -34
- package/dist/src/commands/component.js +1 -0
- package/dist/src/commands/env.js +1 -5
- package/dist/src/commands/index.d.ts +1 -0
- package/dist/src/commands/index.js +1 -0
- package/dist/src/commands/migrate.js +12 -2
- package/dist/src/commands/service-accounts.d.ts +2 -0
- package/dist/src/commands/service-accounts.js +149 -0
- package/dist/src/commands/terminal-browser.d.ts +29 -1
- package/dist/src/commands/terminal-browser.js +165 -34
- package/dist/src/commands/terminal-file.d.ts +21 -0
- package/dist/src/commands/terminal-file.js +160 -0
- package/dist/src/commands/terminal-operational-log.js +2 -2
- package/dist/src/commands/terminal-policy.d.ts +11 -2
- package/dist/src/commands/terminal-policy.js +27 -2
- package/dist/src/commands/terminal-pty.js +2 -0
- package/dist/src/commands/terminal-reconnect-grace.d.ts +19 -0
- package/dist/src/commands/terminal-reconnect-grace.js +59 -1
- package/dist/src/commands/terminal-sandbox.js +7 -0
- package/dist/src/commands/terminal-secure-browser.d.ts +1 -0
- package/dist/src/commands/terminal-secure-browser.js +2 -1
- package/dist/src/commands/terminal-service.d.ts +4 -3
- package/dist/src/commands/terminal-service.js +23 -19
- package/dist/src/commands/terminal.d.ts +29 -1
- package/dist/src/commands/terminal.js +508 -107
- package/dist/src/component-lock.d.ts +4 -0
- package/dist/src/component-lock.js +21 -2
- package/dist/src/config.d.ts +0 -3
- package/dist/src/config.js +0 -2
- package/dist/src/metadata-backfill.js +50 -1
- package/dist/src/migration.d.ts +10 -2
- package/dist/src/migration.js +159 -69
- package/dist/src/resource-inventory.d.ts +3 -2
- package/dist/src/resource-inventory.js +6 -1
- package/dist/src/resource-syncs/account-principal.d.ts +22 -0
- package/dist/src/resource-syncs/account-principal.js +86 -0
- package/dist/src/resource-syncs/database-view-sync.d.ts +0 -1
- package/dist/src/resource-syncs/database-view-sync.js +1 -12
- package/dist/src/resource-syncs/group-sync.d.ts +10 -0
- package/dist/src/resource-syncs/group-sync.js +92 -20
- package/dist/src/resource-syncs/identity-migration.d.ts +19 -0
- package/dist/src/resource-syncs/identity-migration.js +108 -0
- package/dist/src/resource-syncs/job-template-sync.d.ts +4 -0
- package/dist/src/resource-syncs/job-template-sync.js +55 -12
- package/dist/src/resource-syncs/service-account-sync.d.ts +98 -0
- package/dist/src/resource-syncs/service-account-sync.js +620 -0
- package/dist/src/sync-output.js +3 -0
- package/dist/src/tracked-resources.d.ts +1 -1
- package/dist/src/tracked-resources.js +5 -1
- package/dist/src/types.d.ts +12 -0
- package/dist/src/ui.js +4 -1
- package/dist/src/workspace-diff.d.ts +1 -0
- package/dist/src/workspace-diff.js +4 -1
- package/package.json +6 -5
- package/scripts/ensure-pty-helper.mjs +0 -9
package/README.md
CHANGED
|
@@ -77,26 +77,43 @@ revo terminal status
|
|
|
77
77
|
An approved terminal can run as a per-user background service on macOS or Linux. The service uses the active project at installation, or an explicit `--project <name>`; use the same project when uninstalling after a switch.
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
|
-
revo terminal service install --workspace "$HOME/projects/my-project"
|
|
81
|
-
revo terminal service uninstall --workspace "$HOME/projects/my-project"
|
|
82
|
-
revo terminal disconnect --workspace "$HOME/projects/my-project"
|
|
80
|
+
revo terminal service install --workspace "$HOME/projects/my-project" --name "Work Mac"
|
|
81
|
+
revo terminal service uninstall --workspace "$HOME/projects/my-project" --name "Work Mac"
|
|
82
|
+
revo terminal disconnect --workspace "$HOME/projects/my-project" --name "Work Mac"
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
The service starts at login, reconnects automatically, and pins the selected project profile at installation
|
|
85
|
+
Stop the foreground runner before installing its service. The service starts at login, reconnects automatically, and pins the selected terminal UUID and project profile at installation. Multiple terminals can share one machine and workspace when they have distinct names; pass the same `--name` to `connect`, `service install|uninstall`, and `disconnect`. Without `--name`, the CLI uses the machine hostname. If two registrations have the same name, the CLI refuses an ambiguous choice; use `revo terminal status` to find the UUID and pass `--terminal-id <uuid>`. A legacy workspace service must be uninstalled before installing a terminal-specific service. Uninstall stops the selected service but keeps its grant and local registration. `disconnect` revokes only the selected grant and removes its local credential; uninstall its service first. On macOS, service logs are in `~/Library/Logs/RevoEngine/`. On Linux, inspect them with `journalctl --user -u <unit-name>`; `install` prints the unit name. Linux user services normally stop after logout unless an administrator enables user lingering.
|
|
86
86
|
|
|
87
87
|
Runner credentials are stored in `runner.json` beside the CLI configuration. Each executed shell command writes raw output to a private `runner-logs/<executionId>.log` there, capped at 10 MB per file. Logs older than 24 hours are removed when the next command starts; a runner left idle does not perform timed cleanup. Optional CLI HTTP tracing writes sanitized request metadata under the project `.revoengine/logs/http-trace/`. These are separate from the Assistant's server-side tool history and do not form a complete local transcript. Treat runner logs as sensitive because command output may contain secrets.
|
|
88
88
|
|
|
89
89
|
Terminal connection and execution metadata is also written under the CLI configuration at `logs/terminal/<agentTerminalId>/debug.log`. Each line has `[ISO UTC timestamp][severity][assistantThreadId][assistantMessageId] event` followed by allowlisted metadata such as the execution ID, operation, sandbox, exit code, and reconnect delay. Commands, browser URLs, input, output, and credentials are excluded. On the first write after UTC midnight or after a restart, the completed day moves to `YYYY-MM-DD-debug.log.gz`; archives older than 30 days are removed. The log directory is private (`0700`) and files are `0600`. Runner/service stderr remains available for startup failures that occur before this operational log is ready.
|
|
90
90
|
|
|
91
|
-
The Agent terminal has independent command and network grants. Grants are ceilings; each execution frame carries the requested sandbox and `networkAccess=none|local|full`, so a Full grant does not silently widen a workspace or local-only call. Workspace commands keep writes inside the registered workspace and a private temporary directory; a workspace shell with external networking uses `workspace-network`. An explicit `unrestricted` command requests host file access without adding network access. A localhost development server must request Local network access to bind its port. macOS uses Seatbelt for workspace isolation and host plus local-only network; Linux uses `bwrap` and fails closed for shell Local access because enforceable localhost-only isolation is unavailable there. Missing isolation support fails closed. The runner requires a complete `terminal_policy_v2` execution frame from Realtime, including requested command/network modes, grant revision and optional expiry. Temporary scope expiry stops affected work and closes Browser sessions using that scope. Workspace patches and stdin for a running process are supported. A personal API key is required.
|
|
91
|
+
The Agent terminal has independent command and network grants. Grants are ceilings; each execution frame carries the requested sandbox and `networkAccess=none|local|full`, so a Full grant does not silently widen a workspace or local-only call. Workspace commands keep writes inside the registered workspace and a private temporary directory; a workspace shell with external networking uses `workspace-network`. An explicit `unrestricted` command requests host file access without adding network access. A localhost development server must request Local network access to bind its port. macOS uses Seatbelt for workspace isolation and host plus local-only network; Linux uses `bwrap` and fails closed for shell Local access because enforceable localhost-only isolation is unavailable there. Missing isolation support fails closed. The runner requires a complete `terminal_policy_v2` execution frame from Realtime, including requested command/network modes, grant revision and optional expiry. New runners advertise `terminal_policy_selective_v1`: an increased grant takes effect on subsequent calls without disconnecting; a reduced grant stops only commands and Browser sessions no longer covered by the current grant or an unexpired temporary scope. Temporary scope expiry stops affected work and closes Browser sessions using that scope. Workspace patches and stdin for a running process are supported. A personal API key is required.
|
|
92
92
|
|
|
93
|
-
Browser actions use Playwright's Chromium headless shell. The CLI's npm install downloads
|
|
93
|
+
Browser actions use Playwright's Chromium headless shell. The CLI's npm install downloads that browser into Playwright's per-user cache without requiring Python 3; a separate Chrome installation is not required. If npm scripts were disabled or the download was interrupted, reinstall the CLI with scripts enabled before using Browser. Linux hosts still need Playwright's system libraries; an administrator can install them with `npx playwright install-deps chromium`.
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
On macOS, workspace commands may use Unix-domain sockets only inside their own private temporary directory. This lets build tools exchange worker messages without enabling IP networking or access to workspace, other-command or host-service sockets. Local development servers still need Local network access and must bind to localhost. Ordinary process deadlines cover the whole lifetime, not startup. The runner advertises `background_shell_v1`: `terminal.start` with `background=true` and `timeout_ms=null` keeps a dev server or watcher on the existing execution ID without the ordinary lifetime timer. Status, output, stdin, PTY and cancel remain available; hiding the terminal view does not stop the process. Scope expiry, revocation, runner stop and the three-minute disconnect grace still apply. Reuse a healthy project server or check fresh HTTP readiness after starting it.
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
The terminal approval UI supports Allow once, Allow for 15 minutes, Allow for 1 hour, Allow for 8 hours, Allow for 24 hours and Allow for this thread. Whole-thread access requires this runner's `terminal_thread_scope_v1` capability. It covers only the requested Commands and Network levels, survives later messages and short reconnects, and carries no hourly deadline. Disconnect, thread deletion and a device grant revision change revoke it. Realtime rechecks the consent on heartbeat, including idle Browser contexts; scope revocation closes only the affected context. Process `background` mode and the one-hour Browser idle retention are independent of this approval duration.
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
The runner keeps a separate browser context for each connected assistant chat, so navigation, DOM inspection, clicks, form controls, waiting, scrolling, and screenshots share that chat's cookies and page state. Completed actions return a stable browserSessionId, activeTabId and tab inventory (ID, title, sanitized URL and active flag), plus sessionCreated. Use tabs, new_tab with a URL, select_tab or close_tab with tabId, and close to manage the session. Other actions accept tabId. Selecting a tab brings it to the foreground without navigation; popup tabs receive IDs and return to their opener when closed. Tab-aware operations require browser_tabs_v1 in Realtime and Gateway. Browser sessions expire after one hour idle (up to four per runner and sixteen tabs per session), on a Local or Full network lease expiry, or when the runner stops or its access is revoked. A one-time Browser network approval closes its context immediately after that action finishes. DOM results include bounded selector hints for interactive elements without their field values. The Browser action supports `fill`, `check`, `select`, `press`, `scroll`, and `wait_for` as well as navigation, DOM, and click. Ordinary `fill` rejects password and secret-like controls; the Assistant may request a one-time secure credential dialog, which encrypts the value to this runner and fills it in memory without sending it in model tool arguments. The tab-aware handoff authenticates its target tab ID and rejects a switched page even on the same origin. Screenshots can capture the viewport (default), the full page, one selected element, or a bounded viewport crop. For viewport capture, an optional selector limits only the returned DOM text; the image still covers the viewport. Element capture requires a selector. Full-page and crop capture reject selectors. A screenshot is uploaded and attached automatically; calling `save_image` on its local path uploads a second copy. For custom Playwright E2E scripts, run them as ordinary terminal commands in the project, using the requested sandbox and network grant; the Browser action does not execute arbitrary JavaScript.
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
The Browser bridge advertises `browser_timeout_v1`. Agent calls can set `action_timeout_ms` between 1 and 120000 ms for Playwright navigation, interactions, DOM reads and capture. Omitted values retain navigation 30 s, interaction/DOM 10 s and capture 20 s defaults. Selector waits accept `wait_timeout_ms` up to 120000 ms and are capped by the operation timeout when both are supplied. These budgets never extend access expiry or retry an interaction. At a capacity limit the agent can list and close a selected tab, or close its own chat Browser session; closing a session discards its cookies.
|
|
103
|
+
|
|
104
|
+
### Device workspaces and direct transfer
|
|
105
|
+
|
|
106
|
+
The saved `agentTerminalId` identifies the device across terminal restarts. `deviceId` is an alias. Connecting another directory with the same profile and terminal name reuses the saved device secret and registers a pending workspace under that device. Approve its access in AI Agents → Terminals → Workspaces. A running device refreshes its contract; it does not need a second runner. Ambiguous older duplicate registrations require `--terminal-id`. Services remain pinned to the device UUID and original service directory.
|
|
107
|
+
|
|
108
|
+
Current runners advertise `terminal_workspaces_v1`, `browser_control_v1` and `file_transfer_v1`. Gateway can request socket reconnect without stopping the CLI. Temporary transport/dependency failures retry and resume within three minutes; authentication failures and revocation stop retry. Newly installed services stop on fatal authentication and restart other failed processes. Reinstall existing services to adopt that supervisor behavior. CLI stop does not persist local processes or browser cookies. Changing workspace grant revision conservatively terminates workspace-bound work and contexts.
|
|
109
|
+
|
|
110
|
+
Browser inventory exposes its owning chat and workspace. The model can explicitly close permitted same-actor sessions/tabs to free the four-session/sixteen-tab capacity; active sessions are never silently evicted. Inventory/cleanup preserves the existing network lease. Local/full scope changes recreate the browser context and require browser workflow recovery.
|
|
111
|
+
|
|
112
|
+
`upload_file` and `download_file` stream an explicit authorized workspace file directly to/from GCS HTTPS signed/resumable URLs with permitted headers. Full network permission is required. WebSocket carries metadata only. Resumable uploads report committed offsets and partial completion; do not finalize a Storage upload before completion or blindly repeat an uncertain upload. Downloads commit atomically and do not overwrite unless explicitly requested. The stream's idle timeout is 90 seconds; grant expiry and runner lifetime still apply. Signed URLs/headers are credentials and must not be copied into logs or source files.
|
|
113
|
+
|
|
114
|
+
Interactive PTY commands use the optional native `node-pty` package. An unavailable native build does not block CLI installation; PTY requests return `pty_unavailable` until the optional package can be installed. To skip native installation when PTY is not needed, install locally with `npm install --omit=optional @revoengine/cli` and run `npx revo`; npm 11.9 may still install the optional dependency during a global installation. On macOS, the runner verifies the spawn helper's executable permission when a PTY starts. Ordinary commands and local development servers run with pipes.
|
|
115
|
+
|
|
116
|
+
Local Browser mode filters HTTP and WebSocket requests and disables WebRTC, WebTransport, Worker and SharedWorker before page scripts. Worker-dependent pages may not work in this mode; Chromium is not enclosed in an OS network sandbox. A temporary Local or Full network lease closes the Browser context at expiry when the current permanent grant does not cover it, including before a queued secure credential fill. A lost WebSocket connection, a controlled Realtime restart, or a temporary dependency outage retains running processes and Browser contexts for one three-minute reconnect period; repeated failures do not renew it. Receiving `ready` alone does not reset that period while executions still await resume confirmation. Handshake, ready and execution resume each have a ten-second transport deadline. Access revocation and malformed runner frames stop the runner and its processes. Grant revision changes reject older execute frames and stop only work outside the remaining permanent or temporary scope. A network upgrade preserves the original temporary lease for a subsequent downgrade.
|
|
100
117
|
|
|
101
118
|
`save_image` validates the canonical path of the opened file descriptor and reads the image from that same descriptor (up to 30 MiB). It rejects the upload if the descriptor path cannot be verified, including when `lsof` is unavailable on macOS or `/proc/self/fd` cannot be resolved on Linux.
|
|
102
119
|
|
|
@@ -144,7 +161,7 @@ Avoid putting tokens directly in shell history. Prefer environment variables for
|
|
|
144
161
|
|
|
145
162
|
### Cross-environment migration
|
|
146
163
|
|
|
147
|
-
Saved projects are required by `revo migrate --from/--to` and are also accepted through `--project` or the compatible `--env` alias. Examples use `source` and `target` for migration roles. Both may use the production API URL shown below, with separate API keys for their respective instances; the profile name itself does not select an API
|
|
164
|
+
Saved projects are required by `revo migrate --from/--to` and are also accepted through `--project` or the compatible `--env` alias. Examples use `source` and `target` for migration roles. Both may use the production API URL shown below, with separate API keys for their respective instances; the profile name itself does not select an API.
|
|
148
165
|
|
|
149
166
|
```bash
|
|
150
167
|
revo projects add source --url https://api.revoengine.com
|
|
@@ -152,9 +169,7 @@ revo projects add target --url https://api.revoengine.com
|
|
|
152
169
|
revo projects list
|
|
153
170
|
```
|
|
154
171
|
|
|
155
|
-
`projects add` prompts for an API key
|
|
156
|
-
|
|
157
|
-
A production profile requires an interactive confirmation before the first remote write in every invocation. `--yes`, `--force`, and non-interactive CI do not bypass this guard.
|
|
172
|
+
`projects add` prompts for an API key and validates the profile. Use `--token <apiKey>` to supply the key directly or `--offline` to skip validation. Remove an unused profile with `revo projects remove <name>`.
|
|
158
173
|
|
|
159
174
|
Runtime configuration precedence is:
|
|
160
175
|
|
|
@@ -329,7 +344,7 @@ revo migrate plan --from source --to target --skip-groups
|
|
|
329
344
|
revo migrate run --from source --to target --skip-groups --yes
|
|
330
345
|
```
|
|
331
346
|
|
|
332
|
-
The migration model is source-wins upsert. Missing target resources are created and changed resources are updated. Target-only resources are reported as exclusions and are not deleted. A failed phase prevents all later phases from writing; earlier verified writes are not rolled back. Named migration includes Materialized View and access-group writes in its selected scope without the additional repository force gates; destructive column removal still requires `--force`.
|
|
347
|
+
The migration model is source-wins upsert. Missing target resources are created and changed resources are updated. Target-only resources are reported as exclusions and are not deleted. A failed phase prevents all later phases from writing; earlier verified writes are not rolled back. Named migration includes Materialized View and access-group writes in its selected scope without the additional repository force gates; destructive column removal still requires `--force`.
|
|
333
348
|
|
|
334
349
|
Plans project earlier phase results into later dependencies: a Schedule can plan against a Job Template or Materialized View that an earlier phase will create. After each phase verifies its writes, the next phase resolves the actual target UUIDs and versions again before writing. A failed readback stops subsequent phases; `verify` uses a fresh source pull to detect remaining changes.
|
|
335
350
|
|
|
@@ -344,14 +359,17 @@ Full pull, deployment, and migration use this fixed dependency order:
|
|
|
344
359
|
| 1 | `database-table` | `database-tables` | `DatabaseTables/` | Tables, columns, and partitions; destructive DDL remains guarded. |
|
|
345
360
|
| 2 | `database-view` | `database-views` | `DatabaseViews/` | STRUCTURED and RAW_SQL views, including materialized views; target schemas must be ready first. |
|
|
346
361
|
| 3 | `component` | `component` | `Components/` | Portable code, libraries, and elements. Libraries are deployed before executable components. |
|
|
347
|
-
| 4 | `
|
|
348
|
-
| 5 | `
|
|
349
|
-
| 6 | `
|
|
350
|
-
| 7 | `
|
|
351
|
-
| 8 | `
|
|
352
|
-
| 9 | `
|
|
362
|
+
| 4 | `service-account` | `service-accounts` | `ServiceAccounts/` | Owner identities are resolved before dependent Groups and Job Templates; secrets are target-local. |
|
|
363
|
+
| 5 | `job-template` | `job-templates` | `JobTemplates/` | Resolves Component and Service Account dependencies by Stable Key. Pull skips WIP templates without a Stable Key or with an unkeyed Component and reports each skip. |
|
|
364
|
+
| 6 | `endpoint` | `endpoints` | `Endpoints/` | Resolves Component dependencies and route ordering. |
|
|
365
|
+
| 7 | `schedule` | `schedules` | `Schedules/` | Targets Job Templates or Materialized Views. New schedules are inactive by default. |
|
|
366
|
+
| 8 | `event` | `events` | `Events/` | Supports Job Template event targets. Manifests retain `custom: true/false` alongside `type`; new events are inactive by default. |
|
|
367
|
+
| 9 | `group` | `groups` | `Groups/` | Group owners use Stable Keys; Service Account owners resolve early; human users and memberships remain target-local. |
|
|
368
|
+
| 10 | `role-group` | `role-groups` | `RoleGroups/` | Role assignments run last; members and user identifiers remain target-local. |
|
|
353
369
|
|
|
354
|
-
|
|
370
|
+
Active Materialized View refresh Schedules are reported in Database View plans but do not block push, repository deployment, or named migration. Updating a view preserves Schedule activation; API write failures and readback verification failures are still reported.
|
|
371
|
+
|
|
372
|
+
`--resources all` selects all ten families. Singular, plural, and common compact aliases are accepted where the command parser documents them, but the selectors above are the canonical values.
|
|
355
373
|
|
|
356
374
|
Existing `database-schema` selectors and `revo database-schemas` commands remain accepted as compatibility aliases. New table manifests use `DatabaseTables/**/database-table.json`; older `DatabaseSchemas/**/database-schema.json` files remain readable and are relocated by the next successful table pull. A locally edited manifest still needs `--force` before pull replaces it. The manifest `kind` and `databaseSchemas` lock and plan keys retain their existing schema names for format compatibility.
|
|
357
375
|
|
|
@@ -501,3 +519,21 @@ npm run check
|
|
|
501
519
|
npm test
|
|
502
520
|
npm pack --dry-run
|
|
503
521
|
```
|
|
522
|
+
|
|
523
|
+
## Service Accounts in migration
|
|
524
|
+
|
|
525
|
+
`revo metadata plan --resources service-account` and `revo metadata apply` assign Stable Keys explicitly.
|
|
526
|
+
`revo service-accounts pull --all`, `plan --all`, and `push --all --yes` manage the portable definition.
|
|
527
|
+
The same family is included in `revo pull --all`, repository `diff`/`plan`/`deploy`, and named `migrate plan`/`run`/`verify`.
|
|
528
|
+
Select it alone with `--resources service-account`. Named profiles (`--project`/`--env`), URL/token environment variables,
|
|
529
|
+
and the ordinary authenticated runtime work through the existing config resolution. `--force` retains the existing drift policy.
|
|
530
|
+
|
|
531
|
+
The portable manifest contains the Stable Key, name, and Stable Key of a Group or Service Account owner.
|
|
532
|
+
Group USER owners and Job Template `triggerUser` references to Service Accounts are resolved to target `userId` at write time.
|
|
533
|
+
Human principals are reported for manual configuration; an account with a human owner needs a target account with the exact Stable Key before it can be adopted.
|
|
534
|
+
A missing or circular owner dependency blocks writes. Groups and accounts are created in dependency order before their consumers.
|
|
535
|
+
|
|
536
|
+
API keys and secrets cannot be exported. Every newly created Service Account is active and has platform access but has no migrated credentials.
|
|
537
|
+
The push result contains `credentials: { stableKey, environment, policy: "target-local", status: "configure-manually" }`.
|
|
538
|
+
Existing target secrets remain local and are never compared, copied, rotated, or exposed in manifests, plans, lock files, or HTTP trace.
|
|
539
|
+
Memberships, ACL, other account metadata, and `metadataAdvanced` remain outside this sync contract.
|
package/dist/src/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
3
3
|
import { RevoClient } from "./client.js";
|
|
4
4
|
import { readComponentLock } from "./component-lock.js";
|
|
5
5
|
import { getActiveEnvironmentName } from "./config.js";
|
|
6
|
-
import { handleAuthCommand, handleComponentCommand, handleDatabaseTablesCommand, handleDatabaseViewsCommand, handleDeployCommand, handleDiffCommand, handleEndpointsCommand, handleEnvCommand, handleEventsCommand, handleGroupsCommand, handleInfoCommand, handleJobTemplatesCommand, handleMetadataCommand, handleMigrateCommand, handlePlanCommand, handlePullCommand, handleProjectCommand, handleRequestCommand, handleRoleGroupsCommand, handleSearchCommand, handleSchedulesCommand, handleTerminalCommand, } from "./commands/index.js";
|
|
6
|
+
import { handleAuthCommand, handleComponentCommand, handleDatabaseTablesCommand, handleDatabaseViewsCommand, handleDeployCommand, handleDiffCommand, handleEndpointsCommand, handleEnvCommand, handleEventsCommand, handleGroupsCommand, handleInfoCommand, handleJobTemplatesCommand, handleMetadataCommand, handleMigrateCommand, handlePlanCommand, handlePullCommand, handleProjectCommand, handleRequestCommand, handleRoleGroupsCommand, handleServiceAccountsCommand, handleSearchCommand, handleSchedulesCommand, handleTerminalCommand, } from "./commands/index.js";
|
|
7
7
|
import { createHttpTraceSession, finalizeHttpTraceSession, withHttpTraceSession, } from "./http-trace.js";
|
|
8
8
|
import { resolveProjectRoot } from "./project.js";
|
|
9
9
|
import { withRequestQueue } from "./request-queue.js";
|
|
@@ -293,6 +293,10 @@ async function runMain(args, argv) {
|
|
|
293
293
|
await handleRequestCommand(context);
|
|
294
294
|
return;
|
|
295
295
|
}
|
|
296
|
+
if (command === 'service-accounts') {
|
|
297
|
+
await handleServiceAccountsCommand(context);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
296
300
|
if (command === 'role-groups') {
|
|
297
301
|
await handleRoleGroupsCommand(context);
|
|
298
302
|
return;
|
package/dist/src/client.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { RequestQueue } from './request-queue.ts';
|
|
2
|
-
import type { ComponentRecord, DatabaseSchemaRecord, DatabaseViewRecord, EndpointRecord, EventRecord, GroupRecord, JobTemplateRecord, RoleGroupRecord, ScheduleRecord } from './types.ts';
|
|
2
|
+
import type { ComponentRecord, DatabaseSchemaRecord, DatabaseViewRecord, EndpointRecord, EventRecord, GroupRecord, JobTemplateRecord, RoleGroupRecord, ServiceAccountRecord, ScheduleRecord } from './types.ts';
|
|
3
3
|
export type RequestOptions = {
|
|
4
4
|
query?: Record<string, unknown>;
|
|
5
5
|
body?: unknown;
|
|
6
|
+
sensitiveAccountPayload?: boolean;
|
|
6
7
|
headers?: HeadersInit;
|
|
7
8
|
authGuard?: boolean;
|
|
8
9
|
spinnerLabel?: string;
|
|
9
|
-
productionWrite?: boolean;
|
|
10
10
|
timeoutMs?: number;
|
|
11
11
|
queueTimeoutMs?: number;
|
|
12
12
|
signal?: AbortSignal;
|
|
@@ -140,6 +140,13 @@ export type EndpointCreatePayload = Omit<EndpointWritePayload, 'version'> & {
|
|
|
140
140
|
path: string;
|
|
141
141
|
method: string;
|
|
142
142
|
};
|
|
143
|
+
export type ServiceAccountWritePayload = {
|
|
144
|
+
name?: string;
|
|
145
|
+
metadata?: Record<string, unknown>;
|
|
146
|
+
ownerId?: string;
|
|
147
|
+
ownerType?: 'USER' | 'GROUP';
|
|
148
|
+
version?: number;
|
|
149
|
+
};
|
|
143
150
|
export type RoleGroupListRequest = {
|
|
144
151
|
path?: string;
|
|
145
152
|
query?: Record<string, unknown>;
|
|
@@ -210,6 +217,7 @@ export type ScheduleCreatePayload = {
|
|
|
210
217
|
targetConfig?: Record<string, unknown> | null;
|
|
211
218
|
};
|
|
212
219
|
export type JobTemplateUpdatePayload = {
|
|
220
|
+
triggerUser?: string;
|
|
213
221
|
version: number;
|
|
214
222
|
name?: string;
|
|
215
223
|
category?: string | null;
|
|
@@ -221,6 +229,7 @@ export type JobTemplateUpdatePayload = {
|
|
|
221
229
|
inputs?: unknown;
|
|
222
230
|
};
|
|
223
231
|
export type JobTemplateCreatePayload = {
|
|
232
|
+
triggerUser?: string;
|
|
224
233
|
name: string;
|
|
225
234
|
category?: string | null;
|
|
226
235
|
desc?: string;
|
|
@@ -243,12 +252,12 @@ export type GroupWritePayload = {
|
|
|
243
252
|
category?: string | null;
|
|
244
253
|
desc?: string;
|
|
245
254
|
ownerId?: string;
|
|
246
|
-
ownerType?: 'GROUP';
|
|
255
|
+
ownerType?: 'USER' | 'GROUP';
|
|
247
256
|
};
|
|
248
257
|
export type GroupCreatePayload = Omit<GroupWritePayload, 'version'> & {
|
|
249
258
|
name: string;
|
|
250
259
|
ownerId: string;
|
|
251
|
-
ownerType: 'GROUP';
|
|
260
|
+
ownerType: 'USER' | 'GROUP';
|
|
252
261
|
members: string[];
|
|
253
262
|
};
|
|
254
263
|
export type RoleGroupWritePayload = {
|
|
@@ -279,13 +288,7 @@ export type ClientOptions = {
|
|
|
279
288
|
token?: string;
|
|
280
289
|
envName?: string;
|
|
281
290
|
environmentName?: string;
|
|
282
|
-
production?: true;
|
|
283
291
|
fetch?: typeof fetch;
|
|
284
|
-
confirmProductionWrite?: (details: {
|
|
285
|
-
baseUrl: string;
|
|
286
|
-
method: string;
|
|
287
|
-
path: string;
|
|
288
|
-
}) => Promise<boolean>;
|
|
289
292
|
trustedServiceOrigins?: string[];
|
|
290
293
|
maxRetries?: number;
|
|
291
294
|
retryDelayMs?: number;
|
|
@@ -323,11 +326,8 @@ export declare class RevoClient {
|
|
|
323
326
|
baseUrl: string;
|
|
324
327
|
instance: string;
|
|
325
328
|
token: string;
|
|
326
|
-
production: boolean;
|
|
327
329
|
environmentName: string;
|
|
328
330
|
fetchImpl: typeof fetch | undefined;
|
|
329
|
-
private productionWriteConfirmed;
|
|
330
|
-
private confirmProductionWrite;
|
|
331
331
|
private trustedServiceOrigins;
|
|
332
332
|
private maxRetries;
|
|
333
333
|
private retryDelayMs;
|
|
@@ -348,7 +348,6 @@ export declare class RevoClient {
|
|
|
348
348
|
profile: unknown;
|
|
349
349
|
}>;
|
|
350
350
|
request(method: string, path: string, options?: RequestOptions): Promise<ApiResponse>;
|
|
351
|
-
private assertProductionWriteConfirmed;
|
|
352
351
|
requestData<T = unknown>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
353
352
|
me(options?: {
|
|
354
353
|
force?: boolean;
|
|
@@ -405,6 +404,18 @@ export declare class RevoClient {
|
|
|
405
404
|
createComponent(body: unknown): Promise<unknown>;
|
|
406
405
|
updateComponent(componentId: string, body: unknown): Promise<unknown>;
|
|
407
406
|
deleteComponent(componentId: string): Promise<ApiResponse<unknown>>;
|
|
407
|
+
private accountForSync;
|
|
408
|
+
getAccount(userId: string): Promise<ServiceAccountRecord>;
|
|
409
|
+
listAllServiceAccounts(): Promise<{
|
|
410
|
+
serviceAccounts: ServiceAccountRecord[];
|
|
411
|
+
}>;
|
|
412
|
+
getServiceAccount(userId: string): Promise<ServiceAccountRecord>;
|
|
413
|
+
createServiceAccount(body: ServiceAccountWritePayload & {
|
|
414
|
+
name: string;
|
|
415
|
+
ownerId: string;
|
|
416
|
+
ownerType: 'USER' | 'GROUP';
|
|
417
|
+
}): Promise<ServiceAccountRecord>;
|
|
418
|
+
updateServiceAccount(userId: string, body: ServiceAccountWritePayload): Promise<ServiceAccountRecord>;
|
|
408
419
|
listRoleGroups(options?: RoleGroupListRequest): Promise<unknown>;
|
|
409
420
|
listAllRoleGroups(): Promise<{
|
|
410
421
|
roleGroups: RoleGroupRecord[];
|
package/dist/src/client.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { setTimeout as waitForDelay } from 'node:timers/promises';
|
|
2
2
|
import { AUTH_VALIDATION_TTL_MS, buildAuthValidationKey, DEFAULT_BASE_URL, readAuthValidationState, resolveRuntimeConfig, saveAuthValidationState, } from "./config.js";
|
|
3
3
|
import { beginHttpTraceRequest, completeHttpTraceRequest, responseSize, } from "./http-trace.js";
|
|
4
|
-
import { isInteractiveTerminal, promptConfirm } from "./prompt.js";
|
|
5
4
|
import { currentRequestQueue, RequestQueue } from "./request-queue.js";
|
|
6
5
|
import { createSpinner } from "./spinner.js";
|
|
7
6
|
import { mapWithConcurrency } from "./utils.js";
|
|
@@ -263,12 +262,6 @@ function normalizeToken(token) {
|
|
|
263
262
|
}
|
|
264
263
|
return token.startsWith('Bearer ') ? token : `Bearer ${token}`;
|
|
265
264
|
}
|
|
266
|
-
async function confirmProductionWriteInTerminal(details) {
|
|
267
|
-
if (!isInteractiveTerminal()) {
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
return promptConfirm(`PRODUCTION: send ${details.method} ${details.path} to ${details.baseUrl}?`, false);
|
|
271
|
-
}
|
|
272
265
|
function defaultSpinnerLabel(method, path) {
|
|
273
266
|
const upperMethod = method.toUpperCase();
|
|
274
267
|
if (path === '/api/v1/me') {
|
|
@@ -412,11 +405,8 @@ export class RevoClient {
|
|
|
412
405
|
baseUrl;
|
|
413
406
|
instance;
|
|
414
407
|
token;
|
|
415
|
-
production;
|
|
416
408
|
environmentName;
|
|
417
409
|
fetchImpl;
|
|
418
|
-
productionWriteConfirmed = false;
|
|
419
|
-
confirmProductionWrite;
|
|
420
410
|
trustedServiceOrigins;
|
|
421
411
|
maxRetries;
|
|
422
412
|
retryDelayMs;
|
|
@@ -426,10 +416,8 @@ export class RevoClient {
|
|
|
426
416
|
this.baseUrl = config.baseUrl;
|
|
427
417
|
this.instance = config.instance || '';
|
|
428
418
|
this.token = config.token;
|
|
429
|
-
this.production = options.production === true || config.production === true;
|
|
430
419
|
this.environmentName = options.environmentName || options.envName || '';
|
|
431
420
|
this.fetchImpl = options.fetch || globalThis.fetch;
|
|
432
|
-
this.confirmProductionWrite = options.confirmProductionWrite || confirmProductionWriteInTerminal;
|
|
433
421
|
this.trustedServiceOrigins = resolveTrustedServiceOrigins(options.trustedServiceOrigins);
|
|
434
422
|
this.maxRetries = options.maxRetries ?? 0;
|
|
435
423
|
this.retryDelayMs = options.retryDelayMs ?? 100;
|
|
@@ -502,9 +490,6 @@ export class RevoClient {
|
|
|
502
490
|
}
|
|
503
491
|
async request(method, path, options = {}) {
|
|
504
492
|
this.assertReady();
|
|
505
|
-
if (options.productionWrite !== false) {
|
|
506
|
-
await this.assertProductionWriteConfirmed(method, path);
|
|
507
|
-
}
|
|
508
493
|
if (options.authGuard !== false && path !== '/api/v1/me') {
|
|
509
494
|
await this.validateSession();
|
|
510
495
|
}
|
|
@@ -536,7 +521,7 @@ export class RevoClient {
|
|
|
536
521
|
const traceRequest = beginHttpTraceRequest({
|
|
537
522
|
method,
|
|
538
523
|
url,
|
|
539
|
-
body: body,
|
|
524
|
+
body: options.sensitiveAccountPayload ? '[account payload omitted]' : body,
|
|
540
525
|
context: this.environmentName ? { environment: this.environmentName } : undefined,
|
|
541
526
|
});
|
|
542
527
|
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
@@ -614,10 +599,13 @@ export class RevoClient {
|
|
|
614
599
|
status: response.status,
|
|
615
600
|
ok: accepted,
|
|
616
601
|
responseHeaders: response.headers,
|
|
617
|
-
responseData: data,
|
|
602
|
+
responseData: options.sensitiveAccountPayload ? '[account payload omitted]' : data,
|
|
618
603
|
responseBytes: responseSize(data, response.headers),
|
|
619
604
|
});
|
|
620
605
|
if (!response.ok && response.status !== 304) {
|
|
606
|
+
if (options.sensitiveAccountPayload) {
|
|
607
|
+
data = { message: `Account request failed (HTTP ${response.status}).` };
|
|
608
|
+
}
|
|
621
609
|
if (response.status === 401) {
|
|
622
610
|
saveAuthValidationState({
|
|
623
611
|
key: this.authValidationKey,
|
|
@@ -663,21 +651,6 @@ export class RevoClient {
|
|
|
663
651
|
spinner.stop();
|
|
664
652
|
}
|
|
665
653
|
}
|
|
666
|
-
async assertProductionWriteConfirmed(method, path) {
|
|
667
|
-
const normalizedMethod = method.toUpperCase();
|
|
668
|
-
if (!this.production || this.productionWriteConfirmed || !['POST', 'PUT', 'PATCH', 'DELETE'].includes(normalizedMethod)) {
|
|
669
|
-
return;
|
|
670
|
-
}
|
|
671
|
-
const confirmed = await this.confirmProductionWrite({
|
|
672
|
-
baseUrl: this.baseUrl,
|
|
673
|
-
method: normalizedMethod,
|
|
674
|
-
path,
|
|
675
|
-
});
|
|
676
|
-
if (!confirmed) {
|
|
677
|
-
throw new Error('Production write cancelled. Confirm the operation in an interactive terminal.');
|
|
678
|
-
}
|
|
679
|
-
this.productionWriteConfirmed = true;
|
|
680
|
-
}
|
|
681
654
|
async requestData(method, path, options = {}) {
|
|
682
655
|
const response = await this.request(method, path, options);
|
|
683
656
|
return response.data;
|
|
@@ -935,7 +908,6 @@ export class RevoClient {
|
|
|
935
908
|
try {
|
|
936
909
|
return await this.requestData('POST', '/api/v1/databases/views/preview', {
|
|
937
910
|
body,
|
|
938
|
-
productionWrite: false,
|
|
939
911
|
spinnerLabel: 'Previewing Database View',
|
|
940
912
|
timeoutMs: 30_000,
|
|
941
913
|
});
|
|
@@ -1069,7 +1041,6 @@ export class RevoClient {
|
|
|
1069
1041
|
}
|
|
1070
1042
|
async *debugComponentStream(requestPath, body) {
|
|
1071
1043
|
this.assertReady();
|
|
1072
|
-
await this.assertProductionWriteConfirmed('POST', requestPath);
|
|
1073
1044
|
await this.validateSession();
|
|
1074
1045
|
const url = buildUrl(this.baseUrl, requestPath);
|
|
1075
1046
|
assertCredentialDestination(this.baseUrl, url, true, this.trustedServiceOrigins);
|
|
@@ -1206,6 +1177,68 @@ export class RevoClient {
|
|
|
1206
1177
|
spinnerLabel: 'Deleting component',
|
|
1207
1178
|
});
|
|
1208
1179
|
}
|
|
1180
|
+
accountForSync(value) {
|
|
1181
|
+
const wrapper = isRecord(value) && isRecord(value.data) ? value.data : value;
|
|
1182
|
+
if (!isRecord(wrapper)) {
|
|
1183
|
+
throw new Error('Invalid account response.');
|
|
1184
|
+
}
|
|
1185
|
+
const record = {};
|
|
1186
|
+
for (const field of ['userId', 'name', 'serviceAccount', 'ownerId', 'ownerType', 'version', 'deletedAt']) {
|
|
1187
|
+
if (wrapper[field] !== undefined) {
|
|
1188
|
+
Object.assign(record, { [field]: wrapper[field] });
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
const metadata = isRecord(wrapper.metadata) ? wrapper.metadata : wrapper.metaData;
|
|
1192
|
+
if (isRecord(metadata)) {
|
|
1193
|
+
record.metadata = metadata;
|
|
1194
|
+
}
|
|
1195
|
+
return record;
|
|
1196
|
+
}
|
|
1197
|
+
async getAccount(userId) {
|
|
1198
|
+
return this.accountForSync(await this.requestData('GET', `/api/v1/accounts/${encodeURIComponent(userId)}`, { sensitiveAccountPayload: true }));
|
|
1199
|
+
}
|
|
1200
|
+
async listAllServiceAccounts() {
|
|
1201
|
+
const serviceAccounts = [];
|
|
1202
|
+
let skip = 0;
|
|
1203
|
+
const seenIds = new Set();
|
|
1204
|
+
while (true) {
|
|
1205
|
+
// Use unfiltered page sizes/total for offsets: /accounts also lists humans.
|
|
1206
|
+
const page = unwrapListPage(await this.requestData('GET', '/api/v1/accounts', {
|
|
1207
|
+
sensitiveAccountPayload: true,
|
|
1208
|
+
query: { take: COMPONENT_LIST_PAGE_SIZE, skip, count: true },
|
|
1209
|
+
}));
|
|
1210
|
+
for (const item of page.items) {
|
|
1211
|
+
const account = this.accountForSync(item);
|
|
1212
|
+
if (account.serviceAccount === true && !account.deletedAt) {
|
|
1213
|
+
if (!account.userId || seenIds.has(account.userId)) {
|
|
1214
|
+
throw new Error('Invalid or repeated account ID while listing service accounts.');
|
|
1215
|
+
}
|
|
1216
|
+
seenIds.add(account.userId);
|
|
1217
|
+
serviceAccounts.push(account);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
skip += page.items.length;
|
|
1221
|
+
if (page.items.length === 0 || (page.total !== null && skip >= page.total)
|
|
1222
|
+
|| (page.total === null && page.items.length < COMPONENT_LIST_PAGE_SIZE)) {
|
|
1223
|
+
break;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
return { serviceAccounts };
|
|
1227
|
+
}
|
|
1228
|
+
async getServiceAccount(userId) {
|
|
1229
|
+
const account = await this.getAccount(userId);
|
|
1230
|
+
if (account.serviceAccount !== true || account.deletedAt) {
|
|
1231
|
+
throw new Error('Account is not an active service account.');
|
|
1232
|
+
}
|
|
1233
|
+
return account;
|
|
1234
|
+
}
|
|
1235
|
+
async createServiceAccount(body) {
|
|
1236
|
+
return this.accountForSync(await this.requestData('POST', '/api/v1/accounts/createServiceAccount', { body, sensitiveAccountPayload: true }));
|
|
1237
|
+
}
|
|
1238
|
+
async updateServiceAccount(userId, body) {
|
|
1239
|
+
await this.getServiceAccount(userId);
|
|
1240
|
+
return this.accountForSync(await this.requestData('PUT', `/api/v1/accounts/${encodeURIComponent(userId)}`, { body, sensitiveAccountPayload: true }));
|
|
1241
|
+
}
|
|
1209
1242
|
async listRoleGroups(options = {}) {
|
|
1210
1243
|
return this.requestData('GET', options.path || '/api/v1/role-groups', {
|
|
1211
1244
|
query: options.query,
|
|
@@ -617,6 +617,7 @@ function migrateComponentLockIdentity(cwd, identity, localCatalog, remoteCatalog
|
|
|
617
617
|
components: migratedComponents,
|
|
618
618
|
groups: lock.groups,
|
|
619
619
|
roleGroups: lock.roleGroups,
|
|
620
|
+
serviceAccounts: lock.serviceAccounts,
|
|
620
621
|
jobTemplates: lock.jobTemplates,
|
|
621
622
|
schedules: lock.schedules,
|
|
622
623
|
events: lock.events,
|
package/dist/src/commands/env.js
CHANGED
|
@@ -160,13 +160,11 @@ async function handleEnvAdd(context) {
|
|
|
160
160
|
await probe.validateSession({ force: true });
|
|
161
161
|
instance = probe.instance;
|
|
162
162
|
}
|
|
163
|
-
const production = await promptConfirm('Is this a production project?', existing?.production === true);
|
|
164
163
|
const existed = Boolean(existing);
|
|
165
164
|
saveEnvironmentProfile(name, {
|
|
166
165
|
baseUrl,
|
|
167
166
|
token,
|
|
168
167
|
...(instance ? { instance } : {}),
|
|
169
|
-
...(production ? { production: true } : {}),
|
|
170
168
|
}, { activate: true });
|
|
171
169
|
println(`${existed ? 'Updated' : 'Saved'} project "${name}" in ${getConfigDir()}.`);
|
|
172
170
|
println(`Active project: ${name}.`);
|
|
@@ -180,7 +178,6 @@ function handleEnvList(context) {
|
|
|
180
178
|
print(Object.fromEntries(Object.keys(profiles).sort().map((name) => [name, {
|
|
181
179
|
baseUrl: profiles[name].baseUrl,
|
|
182
180
|
instance: profiles[name].instance || null,
|
|
183
|
-
...(profiles[name].production ? { production: true } : {}),
|
|
184
181
|
tokenConfigured: Boolean(profiles[name].token),
|
|
185
182
|
}])));
|
|
186
183
|
return;
|
|
@@ -189,8 +186,7 @@ function handleEnvList(context) {
|
|
|
189
186
|
for (const name of names) {
|
|
190
187
|
const profile = name === DEFAULT_ENV_NAME ? defaultRuntime : profiles[name];
|
|
191
188
|
const instanceSuffix = profile.instance ? ` (instance ${profile.instance})` : '';
|
|
192
|
-
|
|
193
|
-
println(`${name === active ? '*' : ' '} ${paint(name.padEnd(16), ANSI.bold + ANSI.cyan)} ${profile.baseUrl}${instanceSuffix}${productionSuffix}`);
|
|
189
|
+
println(`${name === active ? '*' : ' '} ${paint(name.padEnd(16), ANSI.bold + ANSI.cyan)} ${profile.baseUrl}${instanceSuffix}`);
|
|
194
190
|
}
|
|
195
191
|
}
|
|
196
192
|
function handleEnvSet(context) {
|
|
@@ -12,6 +12,7 @@ export * from './metadata.ts';
|
|
|
12
12
|
export * from './migrate.ts';
|
|
13
13
|
export * from './project.ts';
|
|
14
14
|
export * from './request.ts';
|
|
15
|
+
export * from './service-accounts.ts';
|
|
15
16
|
export * from './role-groups.ts';
|
|
16
17
|
export * from './search.ts';
|
|
17
18
|
export * from './terminal.ts';
|
|
@@ -12,6 +12,7 @@ export * from "./metadata.js";
|
|
|
12
12
|
export * from "./migrate.js";
|
|
13
13
|
export * from "./project.js";
|
|
14
14
|
export * from "./request.js";
|
|
15
|
+
export * from "./service-accounts.js";
|
|
15
16
|
export * from "./role-groups.js";
|
|
16
17
|
export * from "./search.js";
|
|
17
18
|
export * from "./terminal.js";
|
|
@@ -30,6 +30,8 @@ const RESOURCE_ALIASES = {
|
|
|
30
30
|
events: 'event',
|
|
31
31
|
group: 'group',
|
|
32
32
|
groups: 'group',
|
|
33
|
+
'service-account': 'service-account',
|
|
34
|
+
'service-accounts': 'service-account',
|
|
33
35
|
'role-group': 'role-group',
|
|
34
36
|
'role-groups': 'role-group',
|
|
35
37
|
rolegroup: 'role-group',
|
|
@@ -39,6 +41,7 @@ const MIGRATION_RESOURCE_ORDER = [
|
|
|
39
41
|
'database-table',
|
|
40
42
|
'database-view',
|
|
41
43
|
'component',
|
|
44
|
+
'service-account',
|
|
42
45
|
'job-template',
|
|
43
46
|
'endpoint',
|
|
44
47
|
'schedule',
|
|
@@ -60,7 +63,7 @@ function readMigrationResources(context, commandLabel = 'Migration') {
|
|
|
60
63
|
for (const value of values) {
|
|
61
64
|
const resource = RESOURCE_ALIASES[value];
|
|
62
65
|
if (!resource) {
|
|
63
|
-
throw new Error(`${commandLabel} currently supports: database-table, database-view, component, job-template, endpoint, schedule, event, group, role-group, or all.`);
|
|
66
|
+
throw new Error(`${commandLabel} currently supports: database-table, database-view, component, job-template, endpoint, schedule, event, group, role-group, service-account, or all.`);
|
|
64
67
|
}
|
|
65
68
|
if (!resources.includes(resource)) {
|
|
66
69
|
resources.push(resource);
|
|
@@ -114,6 +117,9 @@ function printMigrationPlan(context, plan) {
|
|
|
114
117
|
: 'configured workspace';
|
|
115
118
|
context.println(`Source snapshot: ${plan.sourcePull.pulled} pulled, ${plan.sourcePull.pruned} pruned, ${plan.sourcePull.skipped} skipped in ${pullLocation}.`);
|
|
116
119
|
}
|
|
120
|
+
if (plan.identityOrder?.length) {
|
|
121
|
+
context.println(`Identity order before consumers: ${plan.identityOrder.map((node) => `${node.resource}:${node.stableKey}`).join(' -> ')}.`);
|
|
122
|
+
}
|
|
117
123
|
for (const phase of plan.phases) {
|
|
118
124
|
const pull = plan.sourcePull.byResource[phase.resource];
|
|
119
125
|
if (pull) {
|
|
@@ -184,6 +190,10 @@ function printMigrationPlan(context, plan) {
|
|
|
184
190
|
blockers: phase.blockers,
|
|
185
191
|
});
|
|
186
192
|
}
|
|
193
|
+
if (phase.resource === 'service-account' && plan.serviceAccounts) {
|
|
194
|
+
printSyncPlan(context.println, { title: `${phaseLabel} phase ${phase.order} / Service Account`, environment: plan.to,
|
|
195
|
+
counts: phase.operations, items: plan.serviceAccounts.items, warnings: phase.warnings, blockers: phase.blockers });
|
|
196
|
+
}
|
|
187
197
|
if (phase.resource === 'job-template' && plan.jobTemplates) {
|
|
188
198
|
printSyncPlan(context.println, {
|
|
189
199
|
title: `${phaseLabel} phase ${phase.order} / Job Template`,
|
|
@@ -644,7 +654,7 @@ export async function handleMigrateCommand(context) {
|
|
|
644
654
|
const dryRun = readBoolFlag(context.args, ['dry-run']);
|
|
645
655
|
const subcommand = dryRun ? 'plan' : requestedSubcommand;
|
|
646
656
|
if (requestedSubcommand !== 'plan' && requestedSubcommand !== 'run' && requestedSubcommand !== 'verify') {
|
|
647
|
-
throw new Error('Unknown migrate command. Usage: revo migrate <plan|run|verify> --from <env> --to <env> [--resources database-table,database-view,component,job-template,endpoint,schedule,event,group,role-group] [--skip-groups] [--dry-run]');
|
|
657
|
+
throw new Error('Unknown migrate command. Usage: revo migrate <plan|run|verify> --from <env> --to <env> [--resources database-table,database-view,component,job-template,endpoint,schedule,event,group,role-group,service-account] [--skip-groups] [--dry-run]');
|
|
648
658
|
}
|
|
649
659
|
const input = readMigrationInput(context);
|
|
650
660
|
const json = readBoolFlag(context.args, ['json']);
|