@sequenceholdings/studio-cli 0.7.0 → 0.7.1

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 CHANGED
@@ -847,9 +847,10 @@ compiled to canonical SQL before registration.
847
847
  | `seq-studio orm plan [dir] -e <env>` | Compare the compiled namespace with registry state without applying database changes. |
848
848
  | `seq-studio orm diff [dir] [--check]` | Author the next committed migration, or verify the migration/snapshot chain offline for CI. |
849
849
  | `seq-studio orm apply [dir] -e <env>` | Author a migration if needed, register/apply the namespace, activate its operation set, publish roles/capabilities, and refresh generated outputs. |
850
- | `seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>` | Execute one named persisted operation from `operations.manifest.json` with variables from a JSON object file, as the signed-in caller. |
850
+ | `seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...` | Execute the deployed version's persisted operation by name, as the signed-in caller. Needs no checkout. |
851
+ | `seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>` | Execute one named persisted operation as hashed in this checkout's `operations.manifest.json`, with variables from a JSON object file, as the signed-in caller. |
851
852
  | `seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]` | List the namespaces you can read. |
852
- | `seq-studio orm describe <namespace> [<table>] -e <env> [--json]` | Show a namespace's tables, views, and persisted operations, or one table's columns, actions, and the operations that write it. |
853
+ | `seq-studio orm describe <namespace> [<table> \| --operations] -e <env> [--json]` | Show a namespace's tables, views, and persisted operations (with their variables), only its operations, or one table's columns, actions, and the operations that write it. |
853
854
  | `seq-studio orm read <namespace> <table> -e <env> [--where …] [--select …] [--order …] [--limit N] [--offset N] [--json\|--jsonl]` | Read rows of a deployed v2 namespace's table as the caller. |
854
855
  | `seq-studio orm sql <namespace> --query <sql> \| --file <path> -e <env> [--param …] [--json\|--jsonl]` | Run read-only SQL against a deployed v2 namespace as the caller. |
855
856
  | `seq-studio orm migrate-from-yaml <dir>` | Convert a legacy YAML namespace to TypeScript authoring while preserving its committed migrations. |
@@ -899,6 +900,7 @@ read-only.
899
900
  seq-studio orm namespaces -e <env> # NAMESPACE FORMAT TABLES OPERATIONS DESCRIPTION
900
901
  seq-studio orm namespaces -e <env> --limit 20 --offset 20 --json
901
902
  seq-studio orm describe lending -e <env> # tables, views, persisted operations
903
+ seq-studio orm describe lending --operations -e <env> # operations, requirements, variables
902
904
  seq-studio orm describe lending loans -e <env> # columns, enum values, links, actions
903
905
  ```
904
906
 
@@ -913,6 +915,30 @@ seq-studio orm describe lending loans -e <env> # columns, enum values, links
913
915
  primary key or unique), the values of its enums, its links and actions, and
914
916
  the persisted operations that write it. The column names are the ones `read`
915
917
  and `sql` accept.
918
+ - Each persisted operation lists the variables it declares as `name: type`, with
919
+ `!` when required and `= value` for a default. `--operations` prints only the
920
+ operations.
921
+
922
+ ### Running a deployed operation (`orm execute <namespace> <operation>`)
923
+
924
+ ```bash
925
+ seq-studio orm execute lending ListLoans -e <env> --var officer=<uuid> --var limit=5
926
+ seq-studio orm execute lending ListLoans -e <env> --variables-file variables.json
927
+ ```
928
+
929
+ The by-name form looks the operation up in the namespace's deployed version and
930
+ runs it as you, so it needs no checkout and runs what is deployed even when a
931
+ local clone is behind. `--var <name>=<value>` (repeatable) sets one variable
932
+ over the file: numbers and booleans parse by the declared type, lists, filter
933
+ inputs, and `jsonb` take JSON, and other types take the text as is. Use the file
934
+ for `null`. An unknown name lists the deployed operations, and an input error
935
+ lists the operation's variables.
936
+
937
+ The checkout form, `orm execute <operation> [dir]`, sends the hash from that
938
+ directory's `operations.manifest.json`. When the deployed version hashes the
939
+ operation differently, it prints the local hash, the deployed hash, the deployed
940
+ version, and the by-name command to run instead. The second argument picks the
941
+ form: an existing directory means a checkout.
916
942
  - A namespace you cannot read reports not found, the same as one that does not
917
943
  exist. `--json` prints the full description, including read and write
918
944
  policies, but not the generated GraphQL SDL.
@@ -1,5 +1,5 @@
1
1
  /** Help text reachable before command implementations, auth, optional SDKs, or Atlas clients load. */
2
- export declare const ORM_HELP = "usage:\n seq-studio orm init <dir>\n seq-studio orm generate [dir] [--migration-export] [--check]\n seq-studio orm validate [dir]\n seq-studio orm plan [dir] -e <env>\n seq-studio orm apply [dir] -e <env>\n seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>\n seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]\n seq-studio orm describe <namespace> [<table>] -e <env> [--json]\n seq-studio orm read <namespace> <table> -e <env> [--where <column>=<op>.<value>]... [--select <cols>] [--order <col>[.desc]] [--limit N] [--offset N] [--json|--jsonl]\n seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param <name>[:<type>]=<value>]... | [--params <json-object>] [--json|--jsonl]\n seq-studio orm diff [dir] [--check] [--allow-destructive] [--rebase]\n seq-studio orm migrate-from-yaml <dir>\n seq-studio orm import [dir] --spec <file> | --table <table> --from <schema.table> --map <target=source,...>\n\n -e/--env is required for commands that contact Atlas. Use seq-studio envs list\n to discover environments and seq-studio login to authenticate.\n namespaces lists what you can read; describe shows its tables and operations.\n Run seq-studio orm describe --help for the output.\n read and sql query a v2 namespace as you through its built-in read-only SQL.\n sql must name tables as <namespace>.<table> (FROM lending.loans, not FROM loans).\n Run seq-studio orm read --help for the filter grammar, parameters, and output formats.\n";
2
+ export declare const ORM_HELP = "usage:\n seq-studio orm init <dir>\n seq-studio orm generate [dir] [--migration-export] [--check]\n seq-studio orm validate [dir]\n seq-studio orm plan [dir] -e <env>\n seq-studio orm apply [dir] -e <env>\n seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...\n seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>\n seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]\n seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]\n seq-studio orm read <namespace> <table> -e <env> [--where <column>=<op>.<value>]... [--select <cols>] [--order <col>[.desc]] [--limit N] [--offset N] [--json|--jsonl]\n seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param <name>[:<type>]=<value>]... | [--params <json-object>] [--json|--jsonl]\n seq-studio orm diff [dir] [--check] [--allow-destructive] [--rebase]\n seq-studio orm migrate-from-yaml <dir>\n seq-studio orm import [dir] --spec <file> | --table <table> --from <schema.table> --map <target=source,...>\n\n -e/--env is required for commands that contact Atlas. Use seq-studio envs list\n to discover environments and seq-studio login to authenticate.\n namespaces lists what you can read; describe shows its tables and operations.\n Run seq-studio orm describe --help for the output.\n execute <namespace> <operation> runs the deployed version's persisted operation by\n name, with no checkout. Run seq-studio orm execute --help for both forms.\n read and sql query a v2 namespace as you through its built-in read-only SQL.\n sql must name tables as <namespace>.<table> (FROM lending.loans, not FROM loans).\n Run seq-studio orm read --help for the filter grammar, parameters, and output formats.\n";
3
3
  /** Artifact commands in sandbox token mode; shared by the offline and delegate usage. */
4
4
  export declare const ARTIFACT_SANDBOX_HELP = " In an agent sandbox (SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE), build, plan\n and deploy take --repo: push the app to a Git Service repository and deploy\n from it. Atlas builds Next.js applications; static applications are bundled\n from the repository and must declare no package.json dependencies or\n optionalDependencies, because the sandbox cannot reach a package registry.\n dev, login, logout, --git-url, --source-env, --pr and --env-url are\n unavailable there, and -e is ignored.\n";
5
5
  export declare const ARTIFACT_HELP = "usage:\n seq-studio artifact init <dir> [--template react-vite|nextjs]\n seq-studio artifact whoami -e <env>\n seq-studio artifact link [dir] -e <env> [--project <id>]\n seq-studio artifact env list|use <env>\n seq-studio artifact status [-e <env>]\n seq-studio artifact list -e <env> [--json]\n seq-studio artifact show <slug-or-id> -e <env> [--json]\n seq-studio artifact validate [dir]\n seq-studio artifact build|plan|deploy [dir | --repo <namespace>/<name> | --git-url <url>] [--ref <ref>] -e <env>\n seq-studio artifact dev [dir] -e <env> [--once] [--key <name>] [--link <package-dir>] [--port <port>]\n seq-studio artifact pull <project-id> -e <env> --out <dir>\n seq-studio artifact promote|rollback <deployment-id> -e <env>\n\n Help is available offline. Authenticate with seq-studio login. Build and deploy\n sources may be local, a platform git-service repo, or a public HTTPS Git URL;\n deployments target a named environment with -e. Local, preview, and official\n deployment workflows have different source and approval rules; see the public\n CLI README.\n\n In an agent sandbox (SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE), build, plan\n and deploy take --repo: push the app to a Git Service repository and deploy\n from it. Atlas builds Next.js applications; static applications are bundled\n from the repository and must declare no package.json dependencies or\n optionalDependencies, because the sandbox cannot reach a package registry.\n dev, login, logout, --git-url, --source-env, --pr and --env-url are\n unavailable there, and -e is ignored.\n";
@@ -7,7 +7,8 @@ export declare const PIPELINE_HELP = "usage:\n seq-studio pipeline list -e <env
7
7
  export declare const FUNCTIONS_USAGE = "usage:\n seq-studio functions init <dir> scaffold manifest, TypeScript handler, and docs pointers\n seq-studio functions build [--dir d] local pre-flight (manifest, lockfile, SDK timeout cap)\n seq-studio functions register -e <env> [--dir d] register a shell + initial secret declarations; no deploy\n seq-studio functions deploy -e <env> [-m msg] preflight, upload, then show version and lifecycle progress\n seq-studio functions list -e <env> [--match-local] functions visible on the environment\n seq-studio functions show -e <env> [--fn slug] detail for one function (versions, secrets)\n seq-studio functions limits [-e <env>] [--json] bundled defaults/caps, or deployed policy\n [--fn slug] also show effective runtime limits (requires -e)\n seq-studio functions dev [--dir path] [--port 8080] local HTTP server with cache context\n seq-studio functions invoke -e <env> [--data JSON | --data @file | --stdin]\n invoke a function and print its response\n seq-studio functions logs -e <env> [--limit N] [--since t] function logs (reader-gated)\n seq-studio functions promote <version> -e <env> make a version live\n seq-studio functions rollback [<version>] -e <env> redeploy a prior version\n seq-studio functions delete -e <env> [--yes] archive function + tear down its runtime\n (version history is retained)\n\n Flags: -e/--env <env|preview:<slug>> (required for network commands; see: seq-studio envs list) \u00B7 --fn <slug> \u00B7 --dir <path>\n --path <repo-subdirectory> (remote build/deploy only) select one function in a multi-function repo\n --from-env-file <path> (default: .env) source file for secret values\n --no-wait \u00B7 --yes\n --no-provision (deploy) update-only: error instead of registering a new\n shell, writing secret values, or attaching secrets (CI sweep)\n\n Local Atlas builds and runs deployed functions on this computer, including teardown.\n \"functions dev\" runs a standalone handler without Atlas registration.\n\n Configure per-function CPU and concurrency in managed-function.yml under limits.\n Run \"functions limits\" for valid settings; redeploy to apply manifest changes.\n Invocation rates are shared across Atlas replicas; 429 includes Retry-After.\n If the shared rate limiter is unavailable, invocation fails closed with 503.\n\n Source for build/deploy: a local --dir (default .), a platform git-service\n repo (--repo <ns>/<name>), or a public HTTPS git URL (--git-url <url>). --path selects\n a function directory within a remote repo; omit it for the existing root-manifest\n layout. --ref selects a branch/tag/commit (default: the repo's default branch).\n Remote sources record the pinned commit as provenance (never dirty) and NEVER\n read a repo-committed .env for secret values \u2014 provision secrets server-side\n or pass a local --from-env-file (resolved against your cwd).\n\n Interactive --repo builds clone over smart-HTTP using your seq-studio login\n and repository read access. No PAT is needed. Headless M2M builds use JSON\n materialize and accept only platform-managed --repo sources. Use --env to\n select the same environment for source and deployment.\n";
8
8
  export declare const REPOS_USAGE = "usage:\n seq-studio repos list -e <env> [--namespace <slug>] [--mine] repos visible on the environment\n seq-studio repos namespaces [create <slug>] -e <env> list or create namespaces\n seq-studio repos show <ns>/<name> -e <env> repo detail (branches, clone URL)\n seq-studio repos identity <ns>/<name> -e <env> [--write --dir .] show/install the server-issued identity receipt\n --adopt --write --yes admin-only legacy binding; commit the receipt via PR\n seq-studio repos create <ns>/<name> -e <env> [--default-branch b] [--git-backend walgit]\n create a repo seeded with a README; --git-backend\n walgit creates it empty (for pushing existing\n history); needs namespace write\n seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--output dir] [--force] [--full] [--transport auto|git|json]\n seq-studio repos clone --url <https://\u2026/repos/<id>/git> -e <env> [--ref r] [--output dir] [--full]\n seq-studio repos clone --id <uuid> -e <env> [--ref r] [--output dir] [--full]\n real Git clone using seq-studio login;\n configures login for subsequent git pull/push\n seq-studio repos pull <ns>/<name> -e <env> [--ref r] [--out dir] [--force]\n materialize the tree at a ref (JSON API)\n seq-studio repos pulls <list|show|create|diff|merge|close|comment|comments|review|reviews|checks> [args]\n review requests (see pulls --help)\n seq-studio repos delete <ns>/<name> -e <env> [--yes] delete a repo (confirm prompt)\n seq-studio repos ci init [--dir <repository>] create a native pipeline using platform defaults\n seq-studio repos ci show <ns>/<name> -e <env> --pr <number> [--json] inspect the server CI plan and runs\n seq-studio repos ci show <ns>/<name> -e <env> [--ref r] preview pipeline discovery or legacy checks\n seq-studio repos ci require <ns>/<name> --check <name> -e <env> disabled legacy control\n seq-studio repos ci import <ns>/<name> -e <env> [--ref r] disabled legacy control\n\n Flags: -e/--env <env> (required; see: seq-studio envs list)\n\n clone uses your login token (never written into the remote URL or Git config).\n A repository-local credential helper reads your current login for git pull/push.\n After expiry, run seq-studio login --env <env> again.\n --transport auto (default) and git both create a real Git checkout.\n Personal access tokens are retired; ATLAS_GIT_PAT is ignored.\n --transport json downloads files without .git; requires\n <ns>/<name>. repos pull also provides this files-only workflow.\n --ref accepts a branch, tag, or commit SHA (SHA \u2192 full clone, then checkout).\n Branch and tag clones are shallow (--depth 1). Pass --full for history.\n --output selects the clone directory (--out remains an alias).\n\n Authenticate JSON API calls with: seq-studio login\n Authenticate git clone/push with: seq-studio login --env <env>\n";
9
9
  export declare const PROCESS_RUNS_USAGE = "usage:\n seq-studio process runs start <process-id> -e <env> [--version <v>] [--run-id <id>]\n [--metadata-file <file.json>] [--title <text>] [--entity <type>:<id>] [--json]\n seq-studio process runs list -e <env> [--process <id>] [--status <status>]\n [--entity-type <type>] [--entity-id <id>] [--archived] [--limit 1..500] [--json]\n seq-studio process runs show <run-id> -e <env> [--wait [--timeout <seconds>]] [--json]\n seq-studio process runs cancel <run-id> -e <env> [--json]\n\n Runs start and are read as you: start needs invoker on the process, show and\n list return only runs you can view, and cancel needs invoker on the process.\n --version pins a published process version; omitted, the active version runs.\n --run-id makes start idempotent: repeating it for the same process returns the\n existing run instead of starting another. --metadata-file is a JSON object\n stored on the run.\n list returns the newest runs first, up to --limit (default 50, max 500); the run\n API has no cursor, so narrow with filters to reach older runs.\n --status: pending, running, completed, failed, cancelled, timed_out.\n show --wait polls until the run finishes (default timeout 600s); the run keeps\n going if the wait times out.\n";
10
- export declare const ORM_DISCOVER_HELP = "usage:\n seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]\n seq-studio orm describe <namespace> [<table>] -e <env> [--json]\n\n Find the ORM data you can read, then query it with orm read or orm sql.\n namespaces lists only namespaces you can read, ordered by name: format (v2 or\n v1), table and persisted-operation counts. It pages with --limit (default 50)\n and --offset; the total and the next page go to stderr.\n describe <namespace> lists its tables and views and the persisted operations\n it serves, with what each requires. describe <namespace> <table> lists the\n table's columns (types, nullability, keys), enum values, links, actions, and\n the persisted operations that write it. Column names are the ones orm read and\n orm sql accept.\n A namespace you cannot read reports not found, the same as a missing one.\n --json prints the full description (describe omits the generated GraphQL SDL).\n In an agent sandbox (SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE), -e is not needed.\n";
10
+ export declare const ORM_DISCOVER_HELP = "usage:\n seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]\n seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]\n\n Find the ORM data you can read, then query it with orm read or orm sql.\n namespaces lists only namespaces you can read, ordered by name: format (v2 or\n v1), table and persisted-operation counts. It pages with --limit (default 50)\n and --offset; the total and the next page go to stderr.\n describe <namespace> lists its tables and views and the persisted operations\n it serves, with what each requires and the variables it declares (name: type,\n ! when required). --operations prints only the operations, ready for\n orm execute <namespace> <operation>. describe <namespace> <table> lists the\n table's columns (types, nullability, keys), enum values, links, actions, and\n the persisted operations that write it. Column names are the ones orm read and\n orm sql accept.\n A namespace you cannot read reports not found, the same as a missing one.\n --json prints the full description (describe omits the generated GraphQL SDL).\n In an agent sandbox (SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE), -e is not needed.\n";
11
+ export declare const ORM_EXECUTE_HELP = "usage:\n seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...\n seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>\n\n Run one persisted operation as you. The server applies the operation's\n required capability or role and the namespace's row policies.\n By name: execute <namespace> <operation> looks the operation up in the\n namespace's deployed version and runs it. No checkout is needed, so it runs\n what is deployed even when a local clone is behind. List what you can run:\n seq-studio orm describe <namespace> --operations\n From a checkout: execute <operation> [dir] runs the operation as hashed in the\n namespace directory's operations.manifest.json (default dir: .). If the\n deployed version hashes it differently, execute prints both hashes and the\n by-name command instead of a bare 404.\n The form is chosen by the second argument: an existing directory means a\n checkout; otherwise it is <namespace> <operation>.\n --variables-file takes a JSON object. --var <name>=<value> (repeatable, by\n name only) sets one variable and wins over the file: numbers and booleans\n parse by the declared type, lists, filter inputs and jsonb take JSON, and other\n types take the text as is. Use the file for null.\n Output is the JSON response: {\"data\": ...}.\n In an agent sandbox (SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE), -e is not needed.\n";
11
12
  export declare function staticHelp({ namespace, sub }: {
12
13
  namespace: string;
13
14
  sub?: string;
@@ -5,9 +5,10 @@ export const ORM_HELP = `usage:
5
5
  seq-studio orm validate [dir]
6
6
  seq-studio orm plan [dir] -e <env>
7
7
  seq-studio orm apply [dir] -e <env>
8
+ seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...
8
9
  seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
9
10
  seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]
10
- seq-studio orm describe <namespace> [<table>] -e <env> [--json]
11
+ seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]
11
12
  seq-studio orm read <namespace> <table> -e <env> [--where <column>=<op>.<value>]... [--select <cols>] [--order <col>[.desc]] [--limit N] [--offset N] [--json|--jsonl]
12
13
  seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param <name>[:<type>]=<value>]... | [--params <json-object>] [--json|--jsonl]
13
14
  seq-studio orm diff [dir] [--check] [--allow-destructive] [--rebase]
@@ -18,6 +19,8 @@ export const ORM_HELP = `usage:
18
19
  to discover environments and seq-studio login to authenticate.
19
20
  namespaces lists what you can read; describe shows its tables and operations.
20
21
  Run seq-studio orm describe --help for the output.
22
+ execute <namespace> <operation> runs the deployed version's persisted operation by
23
+ name, with no checkout. Run seq-studio orm execute --help for both forms.
21
24
  read and sql query a v2 namespace as you through its built-in read-only SQL.
22
25
  sql must name tables as <namespace>.<table> (FROM lending.loans, not FROM loans).
23
26
  Run seq-studio orm read --help for the filter grammar, parameters, and output formats.
@@ -193,14 +196,16 @@ export const PROCESS_RUNS_USAGE = `usage:
193
196
  `;
194
197
  export const ORM_DISCOVER_HELP = `usage:
195
198
  seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]
196
- seq-studio orm describe <namespace> [<table>] -e <env> [--json]
199
+ seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]
197
200
 
198
201
  Find the ORM data you can read, then query it with orm read or orm sql.
199
202
  namespaces lists only namespaces you can read, ordered by name: format (v2 or
200
203
  v1), table and persisted-operation counts. It pages with --limit (default 50)
201
204
  and --offset; the total and the next page go to stderr.
202
205
  describe <namespace> lists its tables and views and the persisted operations
203
- it serves, with what each requires. describe <namespace> <table> lists the
206
+ it serves, with what each requires and the variables it declares (name: type,
207
+ ! when required). --operations prints only the operations, ready for
208
+ orm execute <namespace> <operation>. describe <namespace> <table> lists the
204
209
  table's columns (types, nullability, keys), enum values, links, actions, and
205
210
  the persisted operations that write it. Column names are the ones orm read and
206
211
  orm sql accept.
@@ -208,10 +213,35 @@ export const ORM_DISCOVER_HELP = `usage:
208
213
  --json prints the full description (describe omits the generated GraphQL SDL).
209
214
  In an agent sandbox (SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE), -e is not needed.
210
215
  `;
216
+ export const ORM_EXECUTE_HELP = `usage:
217
+ seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...
218
+ seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
219
+
220
+ Run one persisted operation as you. The server applies the operation's
221
+ required capability or role and the namespace's row policies.
222
+ By name: execute <namespace> <operation> looks the operation up in the
223
+ namespace's deployed version and runs it. No checkout is needed, so it runs
224
+ what is deployed even when a local clone is behind. List what you can run:
225
+ seq-studio orm describe <namespace> --operations
226
+ From a checkout: execute <operation> [dir] runs the operation as hashed in the
227
+ namespace directory's operations.manifest.json (default dir: .). If the
228
+ deployed version hashes it differently, execute prints both hashes and the
229
+ by-name command instead of a bare 404.
230
+ The form is chosen by the second argument: an existing directory means a
231
+ checkout; otherwise it is <namespace> <operation>.
232
+ --variables-file takes a JSON object. --var <name>=<value> (repeatable, by
233
+ name only) sets one variable and wins over the file: numbers and booleans
234
+ parse by the declared type, lists, filter inputs and jsonb take JSON, and other
235
+ types take the text as is. Use the file for null.
236
+ Output is the JSON response: {"data": ...}.
237
+ In an agent sandbox (SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE), -e is not needed.
238
+ `;
211
239
  /** read and sql print their own grammar help from the delegate. */
212
240
  function ormHelp(sub) {
213
241
  if (sub === 'namespaces' || sub === 'describe')
214
242
  return ORM_DISCOVER_HELP;
243
+ if (sub === 'execute')
244
+ return ORM_EXECUTE_HELP;
215
245
  return sub === 'read' || sub === 'sql' ? undefined : ORM_HELP;
216
246
  }
217
247
  export function staticHelp({ namespace, sub }) {
@@ -15,7 +15,7 @@ import { explicitOrSandboxEnv, normalizeShortEnvFlag, readEnvFromArgv } from '..
15
15
  import { REQUIRE_EXPLICIT_ENV_MESSAGE } from '../env-flags.js';
16
16
  import { resolveFunctionSourceDir } from '../functions/source-selection.js';
17
17
  import { warnBeforeHostDeploy } from '../manifest-roles-notice.js';
18
- import { ORM_DISCOVER_HELP, ORM_HELP } from '../command-help.js';
18
+ import { ORM_DISCOVER_HELP, ORM_EXECUTE_HELP, ORM_HELP } from '../command-help.js';
19
19
  /**
20
20
  * ORM subcommands that talk to Atlas — must not silently target `local`.
21
21
  * `init`, `generate`, `validate`, `diff`, `migrate-from-yaml`, and `import` are offline.
@@ -35,16 +35,18 @@ const ORM_USAGE = `usage:
35
35
  plan/apply a namespace committed to a platform git-service repo (CI deploy-from-git);
36
36
  --path selects the namespace directory (default: repo root). A remote apply never
37
37
  authors migrations: the committed ledger must already match the definitions.
38
+ seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...
39
+ run the deployed version's persisted operation by name as the caller (no checkout)
38
40
  seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
39
- execute one named persisted operation as the signed-in caller
41
+ run a persisted operation as hashed in this checkout's operations.manifest.json
40
42
  seq-studio orm read <namespace> <table> -e <env> [--where c=op.v]... [--select c,...] [--order c.desc] [--limit N] [--offset N] [--json|--jsonl]
41
43
  read rows of a deployed v2 namespace as the caller (row-level security applies)
42
44
  seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param name[:type]=v]... | [--params <json-object>] [--json|--jsonl]
43
45
  run read-only SQL against a deployed v2 namespace as the caller
44
46
  seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]
45
47
  list the namespaces you can read
46
- seq-studio orm describe <namespace> [<table>] -e <env> [--json]
47
- show a namespace's tables, views, and persisted operations, or one table's columns and actions
48
+ seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]
49
+ show a namespace's tables, views, and persisted operations (with variables), or one table's columns and actions
48
50
  seq-studio orm diff [dir] write/verify the committed migration standalone (--check is the offline CI gate; --allow-destructive consents; --rebase records a v1 -> v2 conversion)
49
51
  seq-studio orm migrate-from-yaml <dir> convert a v1 YAML namespace to the v2 TypeScript format (offline; migrations/ preserved)
50
52
  seq-studio orm import [dir] --spec <file> | --table <t> --from <schema.table> --map <target=source,...>
@@ -218,6 +220,21 @@ async function runNativeOrmCommand(sub, rest) {
218
220
  }
219
221
  return sub === 'read' ? ormReadCommand(parseArgs(rest)) : ormSqlCommand(parseArgs(rest));
220
222
  }
223
+ /**
224
+ * Help, and by-name execute: it reads the deployed version, so it needs neither
225
+ * a namespace directory nor the ORM package. Null for everything else.
226
+ */
227
+ async function runWithoutOrmPackage({ sub, rest, normalized }) {
228
+ if (normalized.includes('--help') || normalized.includes('-h')) {
229
+ console.log(sub === 'execute' ? ORM_EXECUTE_HELP : ORM_HELP);
230
+ return 0;
231
+ }
232
+ if (sub !== 'execute')
233
+ return null;
234
+ const { isDeployedExecute, ormExecuteDeployedCommand } = await import('./execute.js');
235
+ const args = parseArgs(rest);
236
+ return (await isDeployedExecute(args)) ? ormExecuteDeployedCommand(args) : null;
237
+ }
221
238
  export async function runOrmCommand(sub, rest) {
222
239
  if (!sub || sub === 'help' || sub === '--help' || sub === '-h') {
223
240
  console.log(ORM_USAGE);
@@ -226,10 +243,9 @@ export async function runOrmCommand(sub, rest) {
226
243
  if (NATIVE_ORM_SUBS.has(sub))
227
244
  return runNativeOrmCommand(sub, rest);
228
245
  const normalized = normalizeShortEnvFlag(rest);
229
- if (normalized.includes('--help') || normalized.includes('-h')) {
230
- console.log(ORM_HELP);
231
- return 0;
232
- }
246
+ const answered = await runWithoutOrmPackage({ sub, rest, normalized });
247
+ if (answered !== null)
248
+ return answered;
233
249
  let repoSelection;
234
250
  try {
235
251
  repoSelection = extractOrmRepoSelection(normalized);
@@ -149,8 +149,24 @@ export declare const schemaViewSchema: z.ZodObject<{
149
149
  view: z.ZodString;
150
150
  }, z.core.$loose>>>;
151
151
  }, z.core.$loose>;
152
+ /** A declared variable as the stored IR types it: scalar, enum, or a table's dynamic input. */
153
+ declare const variableSchema: z.ZodObject<{
154
+ name: z.ZodString;
155
+ type: z.ZodObject<{
156
+ kind: z.ZodString;
157
+ scalar: z.ZodOptional<z.ZodString>;
158
+ name: z.ZodOptional<z.ZodString>;
159
+ values: z.ZodOptional<z.ZodArray<z.ZodString>>;
160
+ input: z.ZodOptional<z.ZodString>;
161
+ table: z.ZodOptional<z.ZodString>;
162
+ }, z.core.$loose>;
163
+ nullable: z.ZodBoolean;
164
+ list: z.ZodBoolean;
165
+ default: z.ZodOptional<z.ZodUnknown>;
166
+ }, z.core.$loose>;
152
167
  declare const operationSchema: z.ZodObject<{
153
168
  name: z.ZodString;
169
+ op_hash: z.ZodString;
154
170
  kind: z.ZodString;
155
171
  requires: z.ZodNullable<z.ZodObject<{
156
172
  capability: z.ZodOptional<z.ZodString>;
@@ -160,10 +176,25 @@ declare const operationSchema: z.ZodObject<{
160
176
  table: z.ZodString;
161
177
  op: z.ZodString;
162
178
  }, z.core.$loose>>>;
179
+ variables: z.ZodOptional<z.ZodArray<z.ZodObject<{
180
+ name: z.ZodString;
181
+ type: z.ZodObject<{
182
+ kind: z.ZodString;
183
+ scalar: z.ZodOptional<z.ZodString>;
184
+ name: z.ZodOptional<z.ZodString>;
185
+ values: z.ZodOptional<z.ZodArray<z.ZodString>>;
186
+ input: z.ZodOptional<z.ZodString>;
187
+ table: z.ZodOptional<z.ZodString>;
188
+ }, z.core.$loose>;
189
+ nullable: z.ZodBoolean;
190
+ list: z.ZodBoolean;
191
+ default: z.ZodOptional<z.ZodUnknown>;
192
+ }, z.core.$loose>>>;
163
193
  }, z.core.$loose>;
164
194
  export declare const operationsPageSchema: z.ZodObject<{
165
195
  operations: z.ZodArray<z.ZodObject<{
166
196
  name: z.ZodString;
197
+ op_hash: z.ZodString;
167
198
  kind: z.ZodString;
168
199
  requires: z.ZodNullable<z.ZodObject<{
169
200
  capability: z.ZodOptional<z.ZodString>;
@@ -173,11 +204,52 @@ export declare const operationsPageSchema: z.ZodObject<{
173
204
  table: z.ZodString;
174
205
  op: z.ZodString;
175
206
  }, z.core.$loose>>>;
207
+ variables: z.ZodOptional<z.ZodArray<z.ZodObject<{
208
+ name: z.ZodString;
209
+ type: z.ZodObject<{
210
+ kind: z.ZodString;
211
+ scalar: z.ZodOptional<z.ZodString>;
212
+ name: z.ZodOptional<z.ZodString>;
213
+ values: z.ZodOptional<z.ZodArray<z.ZodString>>;
214
+ input: z.ZodOptional<z.ZodString>;
215
+ table: z.ZodOptional<z.ZodString>;
216
+ }, z.core.$loose>;
217
+ nullable: z.ZodBoolean;
218
+ list: z.ZodBoolean;
219
+ default: z.ZodOptional<z.ZodUnknown>;
220
+ }, z.core.$loose>>>;
176
221
  }, z.core.$loose>>;
177
222
  total: z.ZodNumber;
223
+ schema_version_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
224
+ }, z.core.$loose>;
225
+ /** `GET /api/orm/namespaces/<ns>/operations/<name>`: one operation of the active set. */
226
+ export declare const operationDetailSchema: z.ZodObject<{
227
+ name: z.ZodString;
228
+ op_hash: z.ZodString;
229
+ kind: z.ZodString;
230
+ requires: z.ZodNullable<z.ZodObject<{
231
+ capability: z.ZodOptional<z.ZodString>;
232
+ role: z.ZodOptional<z.ZodString>;
233
+ }, z.core.$loose>>;
234
+ variables: z.ZodArray<z.ZodObject<{
235
+ name: z.ZodString;
236
+ type: z.ZodObject<{
237
+ kind: z.ZodString;
238
+ scalar: z.ZodOptional<z.ZodString>;
239
+ name: z.ZodOptional<z.ZodString>;
240
+ values: z.ZodOptional<z.ZodArray<z.ZodString>>;
241
+ input: z.ZodOptional<z.ZodString>;
242
+ table: z.ZodOptional<z.ZodString>;
243
+ }, z.core.$loose>;
244
+ nullable: z.ZodBoolean;
245
+ list: z.ZodBoolean;
246
+ default: z.ZodOptional<z.ZodUnknown>;
247
+ }, z.core.$loose>>;
178
248
  }, z.core.$loose>;
179
249
  export type SchemaView = z.infer<typeof schemaViewSchema>;
180
250
  export type Operation = z.infer<typeof operationSchema>;
251
+ export type OperationDetail = z.infer<typeof operationDetailSchema>;
252
+ export type OperationVariable = z.infer<typeof variableSchema>;
181
253
  export type Column = z.infer<typeof columnSchema>;
182
254
  export type Relation = {
183
255
  kind: 'table';
@@ -65,15 +65,42 @@ export const schemaViewSchema = z.looseObject({
65
65
  tables: z.array(tableSchema),
66
66
  views: z.array(viewSchema).default([]),
67
67
  });
68
+ /** A declared variable as the stored IR types it: scalar, enum, or a table's dynamic input. */
69
+ const variableSchema = z.looseObject({
70
+ name: z.string(),
71
+ type: z.looseObject({
72
+ kind: z.string(),
73
+ scalar: z.string().optional(),
74
+ name: z.string().optional(),
75
+ values: z.array(z.string()).optional(),
76
+ input: z.string().optional(),
77
+ table: z.string().optional(),
78
+ }),
79
+ nullable: z.boolean(),
80
+ list: z.boolean(),
81
+ default: z.unknown().optional(),
82
+ });
68
83
  const operationSchema = z.looseObject({
69
84
  name: z.string(),
85
+ op_hash: z.string(),
70
86
  kind: z.string(),
71
87
  requires: requiresSchema,
72
88
  mutation_roots: z.array(z.looseObject({ table: z.string(), op: z.string() })).default([]),
89
+ /** Absent from servers that predate variables in the listing. */
90
+ variables: z.array(variableSchema).optional(),
73
91
  });
74
92
  export const operationsPageSchema = z.looseObject({
75
93
  operations: z.array(operationSchema),
76
94
  total: z.number(),
95
+ schema_version_id: z.string().nullable().optional(),
96
+ });
97
+ /** `GET /api/orm/namespaces/<ns>/operations/<name>`: one operation of the active set. */
98
+ export const operationDetailSchema = z.looseObject({
99
+ name: z.string(),
100
+ op_hash: z.string(),
101
+ kind: z.string(),
102
+ requires: requiresSchema,
103
+ variables: z.array(variableSchema),
77
104
  });
78
105
  export function parseResponse({ schema, body, what }) {
79
106
  const parsed = schema.safeParse(body);
@@ -14,6 +14,7 @@ import { validateCommandInput } from '../command-input.js';
14
14
  import { buildContext, clientOptions } from '../functions/commands.js';
15
15
  import { table } from '../text-table.js';
16
16
  import { namespaceListSchema, operationsPageSchema, parseResponse, schemaViewSchema, } from './discover-schema.js';
17
+ import { variablesLabel } from './execute.js';
17
18
  /** The server's maximum operations page; describe pages until it has them all. */
18
19
  const OPERATIONS_PAGE_SIZE = 500;
19
20
  const DESCRIPTION_WIDTH = 60;
@@ -141,9 +142,16 @@ function printOperations({ operations, heading }) {
141
142
  console.log(' (none)');
142
143
  return;
143
144
  }
145
+ // Servers that predate variables in the listing omit the field entirely.
146
+ const withVariables = operations.some((operation) => operation.variables !== undefined);
144
147
  table({
145
- headers: ['OPERATION', 'KIND', 'REQUIRES'],
146
- rows: operations.map((operation) => [operation.name, operation.kind, requiresLabel(operation.requires)]),
148
+ headers: ['OPERATION', 'KIND', 'REQUIRES', ...(withVariables ? ['VARIABLES'] : [])],
149
+ rows: operations.map((operation) => [
150
+ operation.name,
151
+ operation.kind,
152
+ requiresLabel(operation.requires),
153
+ ...(withVariables ? [variablesLabel(operation.variables ?? [])] : []),
154
+ ]),
147
155
  });
148
156
  }
149
157
  function printNamespace({ schema, operations }) {
@@ -233,7 +241,11 @@ function operationsWriting({ operations, name }) {
233
241
  export async function ormDescribeCommand(args) {
234
242
  try {
235
243
  const [namespace, tableName] = args.positional;
236
- validateCommandInput({ args, flags: {}, positional: tableName === undefined ? 1 : 2 });
244
+ validateCommandInput({ args, flags: { operations: 'boolean' }, positional: tableName === undefined ? 1 : 2 });
245
+ const onlyOperations = args.flags.operations === true;
246
+ if (onlyOperations && tableName !== undefined) {
247
+ throw new Error('--operations lists the whole namespace\'s operations; drop <table>.');
248
+ }
237
249
  const options = clientOptions(await buildContext(args));
238
250
  const encoded = encodeURIComponent(namespace);
239
251
  const [schemaBody, operations] = await Promise.all([
@@ -241,6 +253,17 @@ export async function ormDescribeCommand(args) {
241
253
  listAllOperations({ options, namespace: namespace }),
242
254
  ]);
243
255
  const schema = parseResponse({ schema: schemaViewSchema, body: schemaBody, what: 'schema' });
256
+ if (onlyOperations) {
257
+ if (args.flags.json === true) {
258
+ console.log(JSON.stringify({ namespace: schema.namespace, version_id: schema.version_id, operations }, null, 2));
259
+ }
260
+ else {
261
+ console.log(`${schema.namespace} ${formatLabel(schema.definition_format)} version ${schema.version_id}`);
262
+ printOperations({ operations, heading: 'Persisted operations:' });
263
+ console.error(`Run one: seq-studio orm execute ${schema.namespace} <operation> --var <name>=<value>`);
264
+ }
265
+ return 0;
266
+ }
244
267
  if (tableName === undefined) {
245
268
  // The generated GraphQL SDL is large and restates the tables; leave it out.
246
269
  const { sdl: _sdl, ...described } = schema;
@@ -249,6 +272,8 @@ export async function ormDescribeCommand(args) {
249
272
  else {
250
273
  printNamespace({ schema, operations });
251
274
  console.error(`Describe a table: seq-studio orm describe ${schema.namespace} <table>`);
275
+ if (operations.length > 0)
276
+ console.error(`Run an operation: seq-studio orm execute ${schema.namespace} <operation>`);
252
277
  }
253
278
  }
254
279
  else {
@@ -0,0 +1,33 @@
1
+ /**
2
+ * `seq-studio orm execute <namespace> <operation>` — run a deployed persisted
3
+ * operation by name, with no checkout.
4
+ *
5
+ * The data endpoint selects an operation by content hash, so a checkout's
6
+ * manifest only works while it matches what is deployed. This form asks the
7
+ * control plane for the ACTIVE version's operation (hash and declared
8
+ * variables) and posts that hash, so it always runs what is deployed. The
9
+ * server still applies the operation's requirements and the namespace's row
10
+ * policies to the caller.
11
+ */
12
+ import type { ParsedArgs } from '../process/commands.js';
13
+ import { type OperationDetail, type OperationVariable } from './discover-schema.js';
14
+ type Variables = Record<string, unknown>;
15
+ /**
16
+ * `<namespace> <operation>` when the second argument is an operation name and
17
+ * not a directory; otherwise the checkout form `<operation> [dir]`.
18
+ */
19
+ export declare function isDeployedExecute(args: ParsedArgs): Promise<boolean>;
20
+ /** `id: uuid!`, `ids: [uuid]`, `where: boolExp(loans)`, `limit: integer = 50`. */
21
+ export declare function variableLabel(variable: OperationVariable): string;
22
+ export declare function variablesLabel(variables: readonly OperationVariable[]): string;
23
+ /** One `--var` value, typed by the deployed operation's declaration. */
24
+ export declare function coerceVariable({ variable, raw }: {
25
+ variable: OperationVariable;
26
+ raw: string;
27
+ }): unknown;
28
+ export declare function parseVarFlags({ args, operation }: {
29
+ args: ParsedArgs;
30
+ operation: OperationDetail;
31
+ }): Variables;
32
+ export declare function ormExecuteDeployedCommand(args: ParsedArgs): Promise<number>;
33
+ export {};
@@ -0,0 +1,208 @@
1
+ /**
2
+ * `seq-studio orm execute <namespace> <operation>` — run a deployed persisted
3
+ * operation by name, with no checkout.
4
+ *
5
+ * The data endpoint selects an operation by content hash, so a checkout's
6
+ * manifest only works while it matches what is deployed. This form asks the
7
+ * control plane for the ACTIVE version's operation (hash and declared
8
+ * variables) and posts that hash, so it always runs what is deployed. The
9
+ * server still applies the operation's requirements and the namespace's row
10
+ * policies to the caller.
11
+ */
12
+ import { readFile, stat } from 'node:fs/promises';
13
+ import { resolve } from 'node:path';
14
+ import { getJsonOr404, postJsonResponse } from '../atlas-client.js';
15
+ import { printCliError } from '../cli-errors.js';
16
+ import { validateCommandInput } from '../command-input.js';
17
+ import { buildContext, clientOptions } from '../functions/commands.js';
18
+ import { operationDetailSchema, operationsPageSchema, parseResponse, } from './discover-schema.js';
19
+ /** The operation detail route's name grammar (a GraphQL name). */
20
+ const OPERATION_NAME = /^[_A-Za-z][_0-9A-Za-z]{0,254}$/;
21
+ /** The server's namespace grammar, without its reserved names. */
22
+ const NAMESPACE_NAME = /^[a-z][a-z0-9_]{0,40}$/;
23
+ const LISTED_NAMES = 20;
24
+ const NUMBER_SCALARS = new Set(['integer', 'double']);
25
+ const JSON_SCALARS = new Set(['jsonb']);
26
+ /**
27
+ * `<namespace> <operation>` when the second argument is an operation name and
28
+ * not a directory; otherwise the checkout form `<operation> [dir]`.
29
+ */
30
+ export async function isDeployedExecute(args) {
31
+ const [, second] = args.positional;
32
+ if (args.positional.length !== 2 || second === undefined || !OPERATION_NAME.test(second))
33
+ return false;
34
+ return !(await stat(second).catch(() => undefined))?.isDirectory();
35
+ }
36
+ /** `id: uuid!`, `ids: [uuid]`, `where: boolExp(loans)`, `limit: integer = 50`. */
37
+ export function variableLabel(variable) {
38
+ const { type } = variable;
39
+ const base = type.kind === 'scalar' ? type.scalar
40
+ : type.kind === 'enum' ? type.name
41
+ : type.kind === 'inputRef' ? `${type.input}(${type.table})`
42
+ : undefined;
43
+ const shown = variable.list ? `[${base ?? type.kind}]` : (base ?? type.kind);
44
+ const suffix = 'default' in variable ? ` = ${JSON.stringify(variable.default)}` : variable.nullable ? '' : '!';
45
+ return `${variable.name}: ${shown}${suffix}`;
46
+ }
47
+ export function variablesLabel(variables) {
48
+ return variables.map(variableLabel).join(', ');
49
+ }
50
+ function takesJson(variable) {
51
+ return variable.list || variable.type.kind === 'inputRef' || JSON_SCALARS.has(variable.type.scalar ?? '');
52
+ }
53
+ /** One `--var` value, typed by the deployed operation's declaration. */
54
+ export function coerceVariable({ variable, raw }) {
55
+ const label = `--var ${variable.name} (${variableLabel(variable)})`;
56
+ if (takesJson(variable)) {
57
+ try {
58
+ return JSON.parse(raw);
59
+ }
60
+ catch {
61
+ throw new Error(`${label} takes JSON, e.g. --var '${variable.name}=${variable.list ? '["a","b"]' : '{"status":{"_eq":"open"}}'}'.`);
62
+ }
63
+ }
64
+ const scalar = variable.type.kind === 'scalar' ? variable.type.scalar : undefined;
65
+ if (scalar === 'boolean') {
66
+ if (raw !== 'true' && raw !== 'false')
67
+ throw new Error(`${label} must be true or false.`);
68
+ return raw === 'true';
69
+ }
70
+ if (scalar !== undefined && NUMBER_SCALARS.has(scalar)) {
71
+ const value = Number(raw);
72
+ if (raw.trim() === '' || !Number.isFinite(value) || (scalar === 'integer' && !Number.isSafeInteger(value))) {
73
+ throw new Error(`${label}: '${raw}' is not a valid ${scalar}.`);
74
+ }
75
+ return value;
76
+ }
77
+ // Text-like scalars, enums, and bigint/numeric (sent as lossless decimal strings).
78
+ return raw;
79
+ }
80
+ export function parseVarFlags({ args, operation }) {
81
+ const entries = args.repeatedFlags?.var ?? [];
82
+ const declared = new Map(operation.variables.map((variable) => [variable.name, variable]));
83
+ const variables = {};
84
+ for (const entry of entries) {
85
+ const eq = entry.indexOf('=');
86
+ const name = eq > 0 ? entry.slice(0, eq) : '';
87
+ if (!name)
88
+ throw new Error(`Invalid --var '${entry}': expected <name>=<value>.`);
89
+ const variable = declared.get(name);
90
+ if (!variable) {
91
+ const known = operation.variables.length ? variablesLabel(operation.variables) : 'no variables';
92
+ throw new Error(`${operation.name} has no variable '${name}'. It declares: ${known}.`);
93
+ }
94
+ if (Object.hasOwn(variables, name))
95
+ throw new Error(`--var ${name} is given more than once.`);
96
+ variables[name] = coerceVariable({ variable, raw: entry.slice(eq + 1) });
97
+ }
98
+ return variables;
99
+ }
100
+ async function readVariablesFile(args) {
101
+ const file = args.flags['variables-file'];
102
+ if (typeof file !== 'string')
103
+ return {};
104
+ let parsed;
105
+ try {
106
+ parsed = JSON.parse(await readFile(resolve(file), 'utf8'));
107
+ }
108
+ catch (error) {
109
+ throw new Error(`Could not read JSON variables from ${file}: ${error instanceof Error ? error.message : String(error)}`);
110
+ }
111
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
112
+ throw new Error('--variables-file must contain a JSON object.');
113
+ return parsed;
114
+ }
115
+ /** The ACTIVE version's operation, or an error that says what is deployed instead. */
116
+ async function resolveDeployedOperation({ options, namespace, operation }) {
117
+ const encoded = encodeURIComponent(namespace);
118
+ const detail = await getJsonOr404({
119
+ ...options,
120
+ path: `/api/orm/namespaces/${encoded}/operations/${encodeURIComponent(operation)}`,
121
+ });
122
+ if (detail !== null)
123
+ return parseResponse({ schema: operationDetailSchema, body: detail, what: 'operation' });
124
+ const listing = await getJsonOr404({ ...options, path: `/api/orm/namespaces/${encoded}/operations?limit=500` });
125
+ if (listing === null) {
126
+ throw new Error(`Namespace '${namespace}' was not found, has no applied version, or you cannot read it. ` +
127
+ 'List the namespaces you can read: seq-studio orm namespaces');
128
+ }
129
+ const page = parseResponse({ schema: operationsPageSchema, body: listing, what: 'operations' });
130
+ throw new Error(missingOperationMessage({ namespace, operation, page }));
131
+ }
132
+ function missingOperationMessage({ namespace, operation, page }) {
133
+ if (page.total === 0) {
134
+ return `Namespace '${namespace}' has no deployed persisted operations. Apply its definitions first: seq-studio orm apply`;
135
+ }
136
+ const names = page.operations.map((listed) => listed.name);
137
+ const sameName = names.find((name) => name.toLowerCase() === operation.toLowerCase());
138
+ const version = page.schema_version_id ? ` (version ${page.schema_version_id})` : '';
139
+ const shown = names.slice(0, LISTED_NAMES).join(', ') + (page.total > LISTED_NAMES ? ', …' : '');
140
+ return [
141
+ `No operation '${operation}' in ${namespace}'s deployed version${version}.`,
142
+ ...(sameName ? [`Did you mean ${sameName}? Operation names are case-sensitive.`] : []),
143
+ `Deployed operations: ${shown}`,
144
+ `List them with their variables: seq-studio orm describe ${namespace} --operations`,
145
+ ].join('\n');
146
+ }
147
+ function parseEnvelope(body) {
148
+ try {
149
+ const parsed = JSON.parse(body);
150
+ return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : null;
151
+ }
152
+ catch {
153
+ return null;
154
+ }
155
+ }
156
+ function failureMessage({ namespace, operation, status, envelope }) {
157
+ const first = Array.isArray(envelope?.errors) ? envelope.errors[0] : undefined;
158
+ const code = typeof first?.extensions?.code === 'string' ? first.extensions.code : null;
159
+ const detail = typeof first?.message === 'string' ? `${first.message}${code ? ` (${code})` : ''}` : `HTTP ${status}`;
160
+ const lines = [`${namespace}.${operation.name} failed: ${detail}`];
161
+ if (code === 'BAD_USER_INPUT' && operation.variables.length > 0) {
162
+ lines.push(`Variables: ${variablesLabel(operation.variables)}`);
163
+ }
164
+ if ((code === 'FORBIDDEN' || status === 403) && operation.requires) {
165
+ const { capability, role } = operation.requires;
166
+ // The server usually names the requirement itself; add it only when it does not.
167
+ const named = [capability, role].some((requirement) => requirement && detail.includes(requirement));
168
+ if (!named) {
169
+ lines.push(`It requires ${[capability ? `capability ${capability}` : null, role ? `role ${role}` : null].filter(Boolean).join(' and ')}.`);
170
+ }
171
+ }
172
+ if (status === 404) {
173
+ lines.push('The deployed operation was not found when it ran; the namespace may have just been redeployed. Retry.');
174
+ }
175
+ return lines.join('\n');
176
+ }
177
+ export async function ormExecuteDeployedCommand(args) {
178
+ try {
179
+ validateCommandInput({ args, flags: { 'variables-file': 'string', var: 'string' }, positional: 2 });
180
+ const [namespace, operationName] = args.positional;
181
+ if (!NAMESPACE_NAME.test(namespace)) {
182
+ throw new Error(`'${namespace}' is not a namespace name and '${operationName}' is not a directory. ` +
183
+ 'Run a deployed operation with: seq-studio orm execute <namespace> <operation>; ' +
184
+ 'from a checkout: seq-studio orm execute <operation> [dir].');
185
+ }
186
+ const fileVariables = await readVariablesFile(args);
187
+ const options = clientOptions(await buildContext(args));
188
+ const operation = await resolveDeployedOperation({ options, namespace, operation: operationName });
189
+ const variables = { ...fileVariables, ...parseVarFlags({ args, operation }) };
190
+ const response = await postJsonResponse({
191
+ ...options,
192
+ path: `/api/data/v2/${namespace}`,
193
+ body: { op: operation.op_hash, variables },
194
+ });
195
+ const envelope = parseEnvelope(response.body);
196
+ const ok = response.status >= 200 && response.status < 300 && envelope !== null;
197
+ // A GraphQL envelope can carry partial data alongside errors: print it, then fail.
198
+ if (ok)
199
+ console.log(JSON.stringify(envelope, null, 2));
200
+ if (ok && !(Array.isArray(envelope.errors) && envelope.errors.length > 0))
201
+ return 0;
202
+ throw new Error(failureMessage({ namespace, operation, status: response.status, envelope }));
203
+ }
204
+ catch (error) {
205
+ printCliError(error);
206
+ return 1;
207
+ }
208
+ }
package/dist/orm/read.js CHANGED
@@ -192,8 +192,8 @@ export function buildReadSql({ plan, columnTypes }) {
192
192
  /** The ORM client's operation transport, served by the CLI's Atlas client. */
193
193
  function atlasTransport({ baseUrl, token }) {
194
194
  return async ({ namespace, op, variables }) => {
195
- // /_data/v2 is the canonical execution route, the same one `orm execute` uses.
196
- const response = await postJsonResponse({ baseUrl, token, path: `/_data/v2/${namespace}`, body: { op, variables } });
195
+ // The data endpoint `orm execute` uses; it shares the deployment gate of the /api/orm discovery routes.
196
+ const response = await postJsonResponse({ baseUrl, token, path: `/api/data/v2/${namespace}`, body: { op, variables } });
197
197
  let body = null;
198
198
  try {
199
199
  body = JSON.parse(response.body);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequenceholdings/studio-cli",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Unified Sequence Studio CLI — `seq-studio init` / `add` / `deploy` (app monorepos), `seq-studio agents`, `seq-studio process` (Lattice), `seq-studio artifact`, `seq-studio functions` / `secrets`, `seq-studio repos`, and `seq-studio auth whoami`. Includes Auth0 browser login shared with seqapi.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -42,11 +42,11 @@
42
42
  "tsx": "^4.20.3",
43
43
  "zod": "^4.1.13",
44
44
  "yaml": "^2.8.4",
45
- "@sequenceholdings/managed-functions": "0.4.5",
46
- "@sequenceholdings/storage": "0.1.2",
47
- "@sequenceholdings/agent-spec": "0.1.4",
48
45
  "@sequenceholdings/artifact-studio": "0.10.1",
49
- "@sequenceholdings/lattice": "0.1.7"
46
+ "@sequenceholdings/lattice": "0.1.7",
47
+ "@sequenceholdings/agent-spec": "0.1.4",
48
+ "@sequenceholdings/managed-functions": "0.4.5",
49
+ "@sequenceholdings/storage": "0.1.2"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@sequenceholdings/orm": "2.7.1",