@sequenceholdings/studio-cli 0.9.9 → 0.9.12
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 +159 -24
- package/dist/artifact/delegate.js +8 -4
- package/dist/atlas-client.js +6 -57
- package/dist/auth.d.ts +0 -1
- package/dist/auth.js +9 -1
- package/dist/bin.js +7 -2
- package/dist/cli-attribution.d.ts +3 -0
- package/dist/cli-attribution.js +24 -0
- package/dist/command-contract.d.ts +8 -2
- package/dist/command-contract.js +3 -2
- package/dist/command-help.d.ts +5 -3
- package/dist/command-help.js +37 -4
- package/dist/command-telemetry.d.ts +11 -0
- package/dist/command-telemetry.js +97 -0
- package/dist/edge-auth-headers.d.ts +1 -0
- package/dist/edge-auth-headers.js +40 -0
- package/dist/functions/commands.js +1 -1
- package/dist/functions/manifest.js +2 -1
- package/dist/main.d.ts +2 -0
- package/dist/main.js +50 -3
- package/dist/orm/apply-source.d.ts +53 -0
- package/dist/orm/apply-source.js +86 -0
- package/dist/orm/delegate.js +27 -41
- package/dist/orm/deployment-policy.d.ts +2 -0
- package/dist/orm/deployment-policy.js +49 -0
- package/dist/orm/help.d.ts +1 -0
- package/dist/orm/help.js +44 -0
- package/dist/orm/history.d.ts +23 -0
- package/dist/orm/history.js +58 -0
- package/dist/orm/read.d.ts +1 -1
- package/dist/orm/read.js +4 -2
- package/dist/pipeline/commands.js +2 -1
- package/dist/pipeline/templates.js +5 -2
- package/dist/principals/commands.d.ts +1 -1
- package/dist/principals/commands.js +50 -2
- package/dist/process/build.js +6 -0
- package/dist/process/codegen.js +2 -0
- package/dist/process/commands.js +5 -2
- package/dist/process/plan-diff.js +4 -0
- package/dist/repos/git-credential.d.ts +8 -1
- package/dist/repos/git-credential.js +50 -4
- package/dist/templates/guidance/AGENTS.md +5 -0
- package/package.json +8 -8
- package/templates/guidance/AGENTS.md +5 -0
package/dist/command-help.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export { PIPELINE_HELP } from './pipeline/help.js';
|
|
2
2
|
/** `--repo` on every init command; shared so the commands describe it identically. */
|
|
3
3
|
export declare const INIT_INTO_REPO_HELP = " Init into a repo: --repo <ns>/<name> on an init command creates that platform\n git-service repo if missing (same name rules as repos create), then clones it\n into <dir> and scaffolds there, or, when <dir> is inside a Git checkout, sets\n it as that checkout's origin (a different existing origin is refused). It\n needs -e <env>, or an agent sandbox. Nothing is committed or pushed; the\n command prints the git add, commit, and push to run.\n In a git-service checkout (with or without --repo), orm init, functions init\n and artifact init also declare the scaffold under resources in\n .seq/repository.yml, so repository CI checks and deploys it. A scaffold inside\n a declared application is not declared; add it to that app with seq-studio add.\n";
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const ORM_HISTORY_HELP = "usage:\n seq-studio orm history <namespace> -e <env> [--limit N] [--json]\n\n Lists every change to the namespace's live schema and operations, newest\n first: when, who, what moved, and the Git Service source. \"verified\" and \"ci\"\n sources were checked by Atlas against the repository; \"reported\" means Atlas\n could not tie the change to a pushed commit on a release branch, with the\n reason when one was claimed. * marks the live activation. History starts with\n the first apply after the environment recorded it.\n";
|
|
5
|
+
export declare const ORM_DEPLOYMENT_POLICY_HELP = "usage:\n seq-studio orm deployment-policy <namespace> -e <env> [--json]\n seq-studio orm deployment-policy <namespace> -e <env> --mode ci --repo <ns>/<name> --branch <branch> --target <target-key>\n seq-studio orm deployment-policy <namespace> -e <env> --mode manual\n\n Existing namespaces default to manual deployment. CI mode rejects direct ORM\n registration, schema apply, and operations-only activation on the server;\n only the enrolled repository's verified merge deployment may activate changes.\n Enabling CI mode requires namespace Admin, repository Admin, and an existing\n automatic branch binding to this namespace. Restoring manual mode requires\n namespace Admin. This changes deployment policy; it does not deploy source.\n";
|
|
6
|
+
export declare const ORM_HELP = "usage:\n seq-studio orm init <dir> [--repo <ns>/<name>]\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> [--timeout <duration>] [--no-wait]\n seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci] [--repo <ns>/<name> --branch <branch> --target <target-key>] [--json]\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 operation show <namespace> <name> -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 Schema commands require the ORM loaded by seq-studio to satisfy the v2\n namespace's package.json @sequenceholdings/orm range before compiling.\n apply waits until the new version is live and serving (default up to 20m), then\n prints \"live:\"; --no-wait returns once the apply is queued.\n CI-managed namespaces reject direct apply; use the enrolled repository's merge\n workflow. deployment-policy reads or explicitly changes this namespace setting.\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\n Init into a repo: --repo <ns>/<name> on an init command creates that platform\n git-service repo if missing (same name rules as repos create), then clones it\n into <dir> and scaffolds there, or, when <dir> is inside a Git checkout, sets\n it as that checkout's origin (a different existing origin is refused). It\n needs -e <env>, or an agent sandbox. Nothing is committed or pushed; the\n command prints the git add, commit, and push to run.\n In a git-service checkout (with or without --repo), orm init, functions init\n and artifact init also declare the scaffold under resources in\n .seq/repository.yml, so repository CI checks and deploys it. A scaffold inside\n a declared application is not declared; add it to that app with seq-studio add.\n";
|
|
5
7
|
/** Artifact commands in sandbox token mode; shared by the offline and delegate usage. */
|
|
6
8
|
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";
|
|
7
|
-
export declare const ARTIFACT_HELP = "usage:\n seq-studio artifact init <dir> [--template react-vite|nextjs] [--repo <namespace>/<name>]\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>] [--local-secrets <bindings.json>] [--bundler turbopack|webpack]\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 Init into a repo: --repo <ns>/<name> on an init command creates that platform\n git-service repo if missing (same name rules as repos create), then clones it\n into <dir> and scaffolds there, or, when <dir> is inside a Git checkout, sets\n it as that checkout's origin (a different existing origin is refused). It\n needs -e <env>, or an agent sandbox. Nothing is committed or pushed; the\n command prints the git add, commit, and push to run.\n In a git-service checkout (with or without --repo), orm init, functions init\n and artifact init also declare the scaffold under resources in\n .seq/repository.yml, so repository CI checks and deploys it. A scaffold inside\n a declared application is not declared; add it to that app with seq-studio add.\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";
|
|
8
|
-
export declare const FUNCTIONS_USAGE = "usage:\n seq-studio functions init <dir> [--repo <ns>/<name>] scaffold manifest, TypeScript handler, and docs pointers;\n --repo scaffolds into a git-service repo (see Init into a repo)\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 (input/output schemas, versions, secrets)\n [--schema] function identity plus input/output JSON Schemas, as JSON (any caller who can see it)\n [--json] [--version id|name] reader-gated release provenance\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>
|
|
9
|
+
export declare const ARTIFACT_HELP = "usage:\n seq-studio artifact init <dir> [--template react-vite|nextjs] [--repo <namespace>/<name>]\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>] [--secret-source local|hosted|none] [--local-secrets <bindings.json>] [--bundler turbopack|webpack]\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 Init into a repo: --repo <ns>/<name> on an init command creates that platform\n git-service repo if missing (same name rules as repos create), then clones it\n into <dir> and scaffolds there, or, when <dir> is inside a Git checkout, sets\n it as that checkout's origin (a different existing origin is refused). It\n needs -e <env>, or an agent sandbox. Nothing is committed or pushed; the\n command prints the git add, commit, and push to run.\n In a git-service checkout (with or without --repo), orm init, functions init\n and artifact init also declare the scaffold under resources in\n .seq/repository.yml, so repository CI checks and deploys it. A scaffold inside\n a declared application is not declared; add it to that app with seq-studio add.\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";
|
|
10
|
+
export declare const FUNCTIONS_USAGE = "usage:\n seq-studio functions init <dir> [--repo <ns>/<name>] scaffold manifest, TypeScript handler, and docs pointers;\n --repo scaffolds into a git-service repo (see Init into a repo)\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 (input/output schemas, versions, secrets)\n [--schema] function identity plus input/output JSON Schemas, as JSON (any caller who can see it)\n [--json] [--version id|name] reader-gated release provenance\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> [--fn <slug>]\n make a version live\n seq-studio functions rollback [<version>] -e <env> [--fn <slug>]\n redeploy a prior version\n seq-studio functions delete -e <env> [--fn <slug>] [--yes]\n 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 --fn selects a deployed function without a local manifest; otherwise the manifest in --dir (default .) supplies its slug\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 Local deploys record repository-wide gitDirty, including unignored files\n outside --dir. Check git status at the repository root before deploying.\n\n Workspace dependencies are compiled from packages declared in a containing\n sequence.app.yml, within the source repository. Only the selected function is\n deployed: no sibling primitives or Application registration. Shared Node packages\n can set package.json seqStudio.source to a root source entry for clean builds.\n Package build scripts are not run. Local secret paths remain relative to --dir.\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\n Init into a repo: --repo <ns>/<name> on an init command creates that platform\n git-service repo if missing (same name rules as repos create), then clones it\n into <dir> and scaffolds there, or, when <dir> is inside a Git checkout, sets\n it as that checkout's origin (a different existing origin is refused). It\n needs -e <env>, or an agent sandbox. Nothing is committed or pushed; the\n command prints the git add, commit, and push to run.\n In a git-service checkout (with or without --repo), orm init, functions init\n and artifact init also declare the scaffold under resources in\n .seq/repository.yml, so repository CI checks and deploys it. A scaffold inside\n a declared application is not declared; add it to that app with seq-studio add.\n";
|
|
9
11
|
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. Returns once\n the repo resolves by name, so clone can follow\n at once. The init commands take --repo\n <ns>/<name> to create, clone, and scaffold\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|resolve|unresolve|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";
|
|
10
12
|
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 retry <run-id> -e <env> [--run-id <new-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>]]\n [--steps [--node <node-id>] [--full]] [--json]\n seq-studio process runs cancel <run-id> -e <env> [--json]\n\n Runs start and are read as you: start and retry need invoker on the process,\n show and list return only runs you can view, and cancel needs invoker on the\n process.\n start prints the new run's id. Omit --run-id for a fresh id on every start.\n --run-id names exactly one run: repeating it for the same process returns that\n run, whatever its status, instead of starting another. To run a failed run\n again, retry it rather than inventing a new id.\n --version pins a published process version; omitted, the active version runs.\n --metadata-file is a JSON object stored on the run.\n retry (CLI 0.9.0+) starts a new run of a failed, cancelled or timed_out run's\n process version with the same metadata, entity and title, linked to the\n original in its lineage, and prints the new id. Other statuses are refused.\n Like start, a retry waits queued while the process is at its concurrent-run\n limit.\n --run-id on retry names the new run, so repeating the retry returns it.\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. show prints the run's error when it failed.\n show --steps (CLI 0.9.1+) prints each step's status, edge, error, input and\n output, with the same viewer permission as show. Inputs, outputs and errors\n over 2000 characters are cut to a preview; --full prints them whole.\n --node narrows to one node. With --json, --steps returns { run, steps } with\n the same bounds; each step's truncated map names its cut fields and their full\n length. A failure in a node's input mapper happens before its step\n starts, so it shows only as the run's error.\n";
|
|
11
13
|
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 seq-studio orm operation show <namespace> <name> -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 omits SDL, adds active set/schema IDs and ops hash; retry on a mismatch.\n operation show prints one active persisted operation's registered GraphQL\n document; --json includes its hash, declared variables, and requirements.\n Missing and unreadable operations both report not found.\n In an agent sandbox (SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE), -e is not needed.\n";
|
package/dist/command-help.js
CHANGED
|
@@ -13,12 +13,35 @@ export const INIT_INTO_REPO_HELP = ` Init into a repo: --repo <ns>/<name> on an
|
|
|
13
13
|
.seq/repository.yml, so repository CI checks and deploys it. A scaffold inside
|
|
14
14
|
a declared application is not declared; add it to that app with seq-studio add.
|
|
15
15
|
`;
|
|
16
|
+
export const ORM_HISTORY_HELP = `usage:
|
|
17
|
+
seq-studio orm history <namespace> -e <env> [--limit N] [--json]
|
|
18
|
+
|
|
19
|
+
Lists every change to the namespace's live schema and operations, newest
|
|
20
|
+
first: when, who, what moved, and the Git Service source. "verified" and "ci"
|
|
21
|
+
sources were checked by Atlas against the repository; "reported" means Atlas
|
|
22
|
+
could not tie the change to a pushed commit on a release branch, with the
|
|
23
|
+
reason when one was claimed. * marks the live activation. History starts with
|
|
24
|
+
the first apply after the environment recorded it.
|
|
25
|
+
`;
|
|
26
|
+
export const ORM_DEPLOYMENT_POLICY_HELP = `usage:
|
|
27
|
+
seq-studio orm deployment-policy <namespace> -e <env> [--json]
|
|
28
|
+
seq-studio orm deployment-policy <namespace> -e <env> --mode ci --repo <ns>/<name> --branch <branch> --target <target-key>
|
|
29
|
+
seq-studio orm deployment-policy <namespace> -e <env> --mode manual
|
|
30
|
+
|
|
31
|
+
Existing namespaces default to manual deployment. CI mode rejects direct ORM
|
|
32
|
+
registration, schema apply, and operations-only activation on the server;
|
|
33
|
+
only the enrolled repository's verified merge deployment may activate changes.
|
|
34
|
+
Enabling CI mode requires namespace Admin, repository Admin, and an existing
|
|
35
|
+
automatic branch binding to this namespace. Restoring manual mode requires
|
|
36
|
+
namespace Admin. This changes deployment policy; it does not deploy source.
|
|
37
|
+
`;
|
|
16
38
|
export const ORM_HELP = `usage:
|
|
17
39
|
seq-studio orm init <dir> [--repo <ns>/<name>]
|
|
18
40
|
seq-studio orm generate [dir] [--migration-export] [--check]
|
|
19
41
|
seq-studio orm validate [dir]
|
|
20
42
|
seq-studio orm plan [dir] -e <env>
|
|
21
43
|
seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait]
|
|
44
|
+
seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci] [--repo <ns>/<name> --branch <branch> --target <target-key>] [--json]
|
|
22
45
|
seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...
|
|
23
46
|
seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
|
|
24
47
|
seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]
|
|
@@ -36,6 +59,8 @@ export const ORM_HELP = `usage:
|
|
|
36
59
|
namespace's package.json @sequenceholdings/orm range before compiling.
|
|
37
60
|
apply waits until the new version is live and serving (default up to 20m), then
|
|
38
61
|
prints "live:"; --no-wait returns once the apply is queued.
|
|
62
|
+
CI-managed namespaces reject direct apply; use the enrolled repository's merge
|
|
63
|
+
workflow. deployment-policy reads or explicitly changes this namespace setting.
|
|
39
64
|
namespaces lists what you can read; describe shows its tables and operations.
|
|
40
65
|
Run seq-studio orm describe --help for the output.
|
|
41
66
|
execute <namespace> <operation> runs the deployed version's persisted operation by
|
|
@@ -64,7 +89,7 @@ export const ARTIFACT_HELP = `usage:
|
|
|
64
89
|
seq-studio artifact show <slug-or-id> -e <env> [--json]
|
|
65
90
|
seq-studio artifact validate [dir]
|
|
66
91
|
seq-studio artifact build|plan|deploy [dir | --repo <namespace>/<name> | --git-url <url>] [--ref <ref>] -e <env>
|
|
67
|
-
seq-studio artifact dev [dir] -e <env> [--once] [--key <name>] [--link <package-dir>] [--port <port>] [--local-secrets <bindings.json>] [--bundler turbopack|webpack]
|
|
92
|
+
seq-studio artifact dev [dir] -e <env> [--once] [--key <name>] [--link <package-dir>] [--port <port>] [--secret-source local|hosted|none] [--local-secrets <bindings.json>] [--bundler turbopack|webpack]
|
|
68
93
|
seq-studio artifact pull <project-id> -e <env> --out <dir>
|
|
69
94
|
seq-studio artifact promote|rollback <deployment-id> -e <env>
|
|
70
95
|
|
|
@@ -92,12 +117,16 @@ export const FUNCTIONS_USAGE = `usage:
|
|
|
92
117
|
seq-studio functions invoke -e <env> [--data JSON | --data @file | --stdin]
|
|
93
118
|
invoke a function and print its response
|
|
94
119
|
seq-studio functions logs -e <env> [--limit N] [--since t] function logs (reader-gated)
|
|
95
|
-
seq-studio functions promote <version> -e <env>
|
|
96
|
-
|
|
97
|
-
seq-studio functions
|
|
120
|
+
seq-studio functions promote <version> -e <env> [--fn <slug>]
|
|
121
|
+
make a version live
|
|
122
|
+
seq-studio functions rollback [<version>] -e <env> [--fn <slug>]
|
|
123
|
+
redeploy a prior version
|
|
124
|
+
seq-studio functions delete -e <env> [--fn <slug>] [--yes]
|
|
125
|
+
archive function + tear down its runtime
|
|
98
126
|
(version history is retained)
|
|
99
127
|
|
|
100
128
|
Flags: -e/--env <env|preview:<slug>> (required for network commands; see: seq-studio envs list) · --fn <slug> · --dir <path>
|
|
129
|
+
--fn selects a deployed function without a local manifest; otherwise the manifest in --dir (default .) supplies its slug
|
|
101
130
|
--path <repo-subdirectory> (remote build/deploy only) select one function in a multi-function repo
|
|
102
131
|
--from-env-file <path> (default: .env) source file for secret values
|
|
103
132
|
--no-wait · --yes
|
|
@@ -268,6 +297,10 @@ export const ORM_EXECUTE_HELP = `usage:
|
|
|
268
297
|
`;
|
|
269
298
|
/** read and sql print their own grammar help from the delegate. */
|
|
270
299
|
function ormHelp(sub) {
|
|
300
|
+
if (sub === 'history')
|
|
301
|
+
return ORM_HISTORY_HELP;
|
|
302
|
+
if (sub === 'deployment-policy')
|
|
303
|
+
return ORM_DEPLOYMENT_POLICY_HELP;
|
|
271
304
|
if (sub === 'namespaces' || sub === 'describe')
|
|
272
305
|
return ORM_DISCOVER_HELP;
|
|
273
306
|
if (sub === 'execute')
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Called only after the existing auth path has verified the token and target. */
|
|
2
|
+
export declare function recordAuthenticatedCliTarget(baseUrl: string, token: string): void;
|
|
3
|
+
export declare function beginCommandTelemetry(): number;
|
|
4
|
+
export declare function telemetryEnabled(): Promise<boolean>;
|
|
5
|
+
export declare function setTelemetryEnabled(enabled: boolean): Promise<void>;
|
|
6
|
+
export declare function finishCommandTelemetry(input: {
|
|
7
|
+
command: string | null;
|
|
8
|
+
startedAt: number;
|
|
9
|
+
exitCode: number;
|
|
10
|
+
error?: unknown;
|
|
11
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
import { currentVersion } from './update-check.js';
|
|
6
|
+
import { edgeAuthHeaders } from './edge-auth-headers.js';
|
|
7
|
+
const preferencePath = () => join(homedir(), '.config', 'lattice', 'telemetry.json');
|
|
8
|
+
const targets = new Map();
|
|
9
|
+
let active = false;
|
|
10
|
+
function commandOutcome(exitCode, error) {
|
|
11
|
+
if (exitCode === 0)
|
|
12
|
+
return 'success';
|
|
13
|
+
if (exitCode === 130 || exitCode === 143)
|
|
14
|
+
return 'cancelled';
|
|
15
|
+
if (error instanceof Error && error.name === 'AbortError')
|
|
16
|
+
return 'cancelled';
|
|
17
|
+
return 'failure';
|
|
18
|
+
}
|
|
19
|
+
function commandHttpStatus(error) {
|
|
20
|
+
if (typeof error !== 'object' || error === null || !('status' in error))
|
|
21
|
+
return undefined;
|
|
22
|
+
const status = Number(error.status);
|
|
23
|
+
return Number.isInteger(status) && status >= 400 && status <= 599 ? status : undefined;
|
|
24
|
+
}
|
|
25
|
+
function commandErrorCategory(error, status) {
|
|
26
|
+
if (status === 401)
|
|
27
|
+
return 'auth';
|
|
28
|
+
if (status === 403)
|
|
29
|
+
return 'permission';
|
|
30
|
+
if (status === 400 || status === 422)
|
|
31
|
+
return 'validation';
|
|
32
|
+
if (status === 408 || status === 504)
|
|
33
|
+
return 'timeout';
|
|
34
|
+
if (status && status >= 500)
|
|
35
|
+
return 'server';
|
|
36
|
+
if (error instanceof Error && error.name === 'TimeoutError')
|
|
37
|
+
return 'timeout';
|
|
38
|
+
const cause = error instanceof Error ? error.cause : undefined;
|
|
39
|
+
const code = typeof cause === 'object' && cause !== null && 'code' in cause ? cause.code : undefined;
|
|
40
|
+
if (typeof code === 'string' && ['ECONNREFUSED', 'ECONNRESET', 'ENOTFOUND', 'EAI_AGAIN', 'ENETUNREACH'].includes(code))
|
|
41
|
+
return 'network';
|
|
42
|
+
return 'unknown';
|
|
43
|
+
}
|
|
44
|
+
/** Called only after the existing auth path has verified the token and target. */
|
|
45
|
+
export function recordAuthenticatedCliTarget(baseUrl, token) {
|
|
46
|
+
if (!active)
|
|
47
|
+
return;
|
|
48
|
+
targets.set(baseUrl.replace(/\/$/, ''), token);
|
|
49
|
+
}
|
|
50
|
+
export function beginCommandTelemetry() {
|
|
51
|
+
targets.clear();
|
|
52
|
+
active = true;
|
|
53
|
+
return performance.now();
|
|
54
|
+
}
|
|
55
|
+
export async function telemetryEnabled() {
|
|
56
|
+
if (process.env.SEQ_STUDIO_TELEMETRY?.toLowerCase() === 'off')
|
|
57
|
+
return false;
|
|
58
|
+
try {
|
|
59
|
+
return JSON.parse(await readFile(preferencePath(), 'utf8')).enabled !== false;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export async function setTelemetryEnabled(enabled) {
|
|
66
|
+
const path = preferencePath();
|
|
67
|
+
await mkdir(dirname(path), { recursive: true });
|
|
68
|
+
await writeFile(path, JSON.stringify({ enabled }) + '\n', { mode: 0o600 });
|
|
69
|
+
}
|
|
70
|
+
export async function finishCommandTelemetry(input) {
|
|
71
|
+
active = false;
|
|
72
|
+
const target = targets.size === 1 ? [...targets][0] : null;
|
|
73
|
+
targets.clear();
|
|
74
|
+
if (!input.command || !target || !(await telemetryEnabled()))
|
|
75
|
+
return;
|
|
76
|
+
const [baseUrl, token] = target;
|
|
77
|
+
const durationMs = Math.max(0, Math.min(86_400_000, Math.round(performance.now() - input.startedAt)));
|
|
78
|
+
const httpStatus = commandHttpStatus(input.error);
|
|
79
|
+
const outcome = commandOutcome(input.exitCode, input.error);
|
|
80
|
+
const errorCategory = outcome === 'failure' ? commandErrorCategory(input.error, httpStatus) : undefined;
|
|
81
|
+
try {
|
|
82
|
+
await fetch(new URL('/api/platform/cli-command-events', baseUrl), {
|
|
83
|
+
method: 'POST', redirect: 'error', signal: AbortSignal.timeout(1_500),
|
|
84
|
+
headers: {
|
|
85
|
+
Authorization: `Bearer ${token}`,
|
|
86
|
+
'Content-Type': 'application/json',
|
|
87
|
+
'x-sequence-client': 'seq-studio',
|
|
88
|
+
'x-sequence-client-version': currentVersion(),
|
|
89
|
+
...edgeAuthHeaders(baseUrl),
|
|
90
|
+
},
|
|
91
|
+
body: JSON.stringify({ id: randomUUID(), command: input.command, outcome, durationMs, errorCategory, httpStatus }),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// Best effort: telemetry cannot change a command result.
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function edgeAuthHeaders(baseUrl: string): Record<string, string>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PREVIEW_DOMAIN } from './preview.js';
|
|
2
|
+
const CF_ACCESS_DOMAIN = 'seqholdings.com';
|
|
3
|
+
function previewAccessHeaders(baseUrl) {
|
|
4
|
+
const secret = process.env.PREVIEW_ACCESS_HEADER?.trim();
|
|
5
|
+
if (!secret)
|
|
6
|
+
return {};
|
|
7
|
+
try {
|
|
8
|
+
const parsed = new URL(baseUrl);
|
|
9
|
+
if (parsed.protocol !== 'https:')
|
|
10
|
+
return {};
|
|
11
|
+
if (!parsed.hostname.toLowerCase().endsWith(`.${PREVIEW_DOMAIN}`))
|
|
12
|
+
return {};
|
|
13
|
+
return { 'x-preview-access': secret };
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Only send Cloudflare credentials to HTTPS origins in the company domain. */
|
|
20
|
+
function cfAccessHeaders(baseUrl) {
|
|
21
|
+
const clientId = process.env.CF_ACCESS_CLIENT_ID?.trim();
|
|
22
|
+
const clientSecret = process.env.CF_ACCESS_CLIENT_SECRET?.trim();
|
|
23
|
+
if (!clientId || !clientSecret)
|
|
24
|
+
return {};
|
|
25
|
+
try {
|
|
26
|
+
const parsed = new URL(baseUrl);
|
|
27
|
+
if (parsed.protocol !== 'https:')
|
|
28
|
+
return {};
|
|
29
|
+
const hostname = parsed.hostname.toLowerCase();
|
|
30
|
+
if (hostname !== CF_ACCESS_DOMAIN && !hostname.endsWith(`.${CF_ACCESS_DOMAIN}`))
|
|
31
|
+
return {};
|
|
32
|
+
return { 'CF-Access-Client-Id': clientId, 'CF-Access-Client-Secret': clientSecret };
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function edgeAuthHeaders(baseUrl) {
|
|
39
|
+
return { ...previewAccessHeaders(baseUrl), ...cfAccessHeaders(baseUrl) };
|
|
40
|
+
}
|
|
@@ -606,7 +606,8 @@ export const managedFunctionManifestSchema = z.object({
|
|
|
606
606
|
description: z.string().max(2000).optional(),
|
|
607
607
|
immutable_release: functionImmutableReleaseSchema.optional(),
|
|
608
608
|
}),
|
|
609
|
-
runtime
|
|
609
|
+
/** Omitted means Node 24; Atlas keeps each stored version on its admitted runtime. */
|
|
610
|
+
runtime: z.enum(['nodejs20', 'nodejs24']).default('nodejs24'),
|
|
610
611
|
entrypoint: z.string().min(1).max(255).default('handler'),
|
|
611
612
|
limits: managedFunctionWorkloadLimitsSchema,
|
|
612
613
|
/**
|
package/dist/main.d.ts
CHANGED
|
@@ -24,4 +24,6 @@
|
|
|
24
24
|
* seq-studio doctor check token + env + writer gate
|
|
25
25
|
* seq-studio help show usage
|
|
26
26
|
*/
|
|
27
|
+
/** Only command words from the router; never operands, flags, paths, or arguments. */
|
|
28
|
+
export declare function commandTelemetryName(argv: string[]): string | null;
|
|
27
29
|
export declare function run(argv?: string[]): Promise<number>;
|
package/dist/main.js
CHANGED
|
@@ -48,14 +48,15 @@ const TOP_LEVEL_USAGE = `usage:
|
|
|
48
48
|
seq-studio pipeline <sub> [args] list | assets | search | describe | schema | sample | query | init | validate | repin-orm | codegen | plan | adopt | unbind | retire | deploy | status | migrate | promote | rollback | run-now
|
|
49
49
|
seq-studio auth <sub> [args] whoami | git-credential
|
|
50
50
|
seq-studio feedback submit --file report.json [-e <env>] [--json]
|
|
51
|
-
seq-studio orm <sub> [args] init | generate | validate | plan | apply | execute | read | sql | diff | migrate-from-yaml | import
|
|
51
|
+
seq-studio orm <sub> [args] init | generate | validate | plan | apply | deployment-policy | execute | read | sql | diff | migrate-from-yaml | import
|
|
52
52
|
seq-studio service-accounts <sub> list | show | create (requires provisioning authority)
|
|
53
53
|
seq-studio access <sub> definitions | list | grant | revoke | resolve
|
|
54
|
-
seq-studio principals <sub> search | users search | groups list
|
|
54
|
+
seq-studio principals <sub> search | users search | groups list/show/create/members
|
|
55
55
|
seq-studio envs <sub> add | list environments
|
|
56
56
|
seq-studio login [--env <name>] authenticate in the browser
|
|
57
57
|
seq-studio logout [--env <name>] remove one realm's cached user tokens
|
|
58
58
|
seq-studio doctor [-e <env>] [--json] [--offline] diagnose config, auth, toolchain, and writer gate
|
|
59
|
+
seq-studio telemetry enable|disable|status control authenticated command metrics
|
|
59
60
|
seq-studio version print the installed version
|
|
60
61
|
seq-studio capabilities [--json] describe command availability and access
|
|
61
62
|
seq-studio help show this message
|
|
@@ -108,10 +109,37 @@ const SUBCOMMANDS = {
|
|
|
108
109
|
principals: new Set(['search', 'users', 'groups']),
|
|
109
110
|
auth: new Set(['whoami', 'git-credential', 'pat']),
|
|
110
111
|
feedback: new Set(['submit']),
|
|
111
|
-
orm: new Set(['init', 'generate', 'validate', 'plan', 'apply', 'execute', 'namespaces', 'describe', 'read', 'sql', 'diff', 'migrate-from-yaml', 'import']),
|
|
112
|
+
orm: new Set(['init', 'generate', 'validate', 'plan', 'apply', 'history', 'deployment-policy', 'execute', 'namespaces', 'describe', 'read', 'sql', 'diff', 'migrate-from-yaml', 'import']),
|
|
112
113
|
pipeline: new Set(['list', 'assets', 'search', 'describe', 'schema', 'sample', 'query', 'init', 'validate', 'repin-orm', 'codegen', 'adopt', 'unbind', 'retire', 'plan', 'deploy', 'status', 'migrate', 'promote', 'rollback', 'run-now']),
|
|
113
114
|
envs: new Set(['add', 'list']),
|
|
114
115
|
};
|
|
116
|
+
const TELEMETRY_EXCLUDED = new Set(['validate', 'telemetry', 'version', 'capabilities', 'help', 'login', 'logout', 'envs']);
|
|
117
|
+
const TELEMETRY_TOP_LEVEL = new Set(['init', 'add', 'deploy', 'doctor']);
|
|
118
|
+
const TELEMETRY_NESTED = {
|
|
119
|
+
'process runs': new Set(['start', 'retry', 'list', 'show', 'cancel']),
|
|
120
|
+
'process bundle': new Set(['build', 'pull', 'archive', 'inspect', 'list', 'publish']),
|
|
121
|
+
};
|
|
122
|
+
/** Only command words from the router; never operands, flags, paths, or arguments. */
|
|
123
|
+
export function commandTelemetryName(argv) {
|
|
124
|
+
if (argv.some((arg) => arg === '--help' || arg === '-h'))
|
|
125
|
+
return null;
|
|
126
|
+
const [namespace, sub] = argv;
|
|
127
|
+
if (!namespace || TELEMETRY_EXCLUDED.has(namespace))
|
|
128
|
+
return null;
|
|
129
|
+
if (namespace === 'doctor' && (argv.includes('--offline') || argv.includes('--offline=true')))
|
|
130
|
+
return null;
|
|
131
|
+
if (namespace === 'auth' && sub === 'git-credential')
|
|
132
|
+
return null;
|
|
133
|
+
if (TELEMETRY_TOP_LEVEL.has(namespace))
|
|
134
|
+
return namespace;
|
|
135
|
+
if (!sub || !SUBCOMMANDS[namespace]?.has(sub))
|
|
136
|
+
return null;
|
|
137
|
+
const command = `${namespace} ${sub}`;
|
|
138
|
+
const nested = TELEMETRY_NESTED[command];
|
|
139
|
+
if (!nested)
|
|
140
|
+
return command;
|
|
141
|
+
return argv[2] && nested.has(argv[2]) ? `${command} ${argv[2]}` : null;
|
|
142
|
+
}
|
|
115
143
|
export async function run(argv = process.argv.slice(2)) {
|
|
116
144
|
if (!requestsMachineOutput(argv))
|
|
117
145
|
return dispatch(argv);
|
|
@@ -254,6 +282,25 @@ async function dispatch(argv) {
|
|
|
254
282
|
return runCapabilities([sub, ...rest].filter((value) => Boolean(value)));
|
|
255
283
|
case 'doctor':
|
|
256
284
|
return (await import('./process/commands.js')).doctorCommand(parseArgs([sub, ...rest].filter(Boolean)));
|
|
285
|
+
case 'telemetry': {
|
|
286
|
+
const { setTelemetryEnabled, telemetryEnabled } = await import('./command-telemetry.js');
|
|
287
|
+
if (sub === '--help' || sub === '-h' || sub === 'help') {
|
|
288
|
+
console.log('usage: seq-studio telemetry enable|disable|status');
|
|
289
|
+
return 0;
|
|
290
|
+
}
|
|
291
|
+
if (rest.length > 0) {
|
|
292
|
+
console.error('usage: seq-studio telemetry enable|disable|status');
|
|
293
|
+
return 1;
|
|
294
|
+
}
|
|
295
|
+
if (sub === 'enable' || sub === 'disable')
|
|
296
|
+
await setTelemetryEnabled(sub === 'enable');
|
|
297
|
+
else if (sub !== 'status') {
|
|
298
|
+
console.error('usage: seq-studio telemetry enable|disable|status');
|
|
299
|
+
return 1;
|
|
300
|
+
}
|
|
301
|
+
console.log(`Command telemetry: ${await telemetryEnabled() ? 'on' : 'off'}`);
|
|
302
|
+
return 0;
|
|
303
|
+
}
|
|
257
304
|
default:
|
|
258
305
|
console.error(`unknown command: ${namespace}`);
|
|
259
306
|
console.error(TOP_LEVEL_USAGE);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Mirrors `SOURCE_ENV` in `@sequenceholdings/orm/cli`; older pinned packages ignore it. */
|
|
2
|
+
export declare const ORM_SOURCE_ENV = "SEQUENCE_ORM_SOURCE";
|
|
3
|
+
export interface OrmApplySource {
|
|
4
|
+
repository_id: string;
|
|
5
|
+
commit: string;
|
|
6
|
+
path: string;
|
|
7
|
+
dirty?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** The Git Service repository a clone's origin names, when that origin is the target environment's own Git Service. */
|
|
10
|
+
export declare function gitServiceRepoIdFromOrigin({ originUrl, targetUrl }: {
|
|
11
|
+
originUrl: string;
|
|
12
|
+
targetUrl: string;
|
|
13
|
+
}): string | null;
|
|
14
|
+
/** Source of an apply from a local checkout; null outside a clone of the target's Git Service. */
|
|
15
|
+
export declare function localOrmApplySource({ dir, targetUrl }: {
|
|
16
|
+
dir: string;
|
|
17
|
+
targetUrl: string;
|
|
18
|
+
}): OrmApplySource | null;
|
|
19
|
+
/** Source of an apply materialized from `--repo`; the commit is the one the resolver pinned. */
|
|
20
|
+
export declare function repoOrmApplySource({ targetUrl, token, namespace, name, commit, path }: {
|
|
21
|
+
targetUrl: string;
|
|
22
|
+
token: string;
|
|
23
|
+
namespace: string;
|
|
24
|
+
name: string;
|
|
25
|
+
commit: string | null;
|
|
26
|
+
path: string | undefined;
|
|
27
|
+
}): Promise<OrmApplySource | null>;
|
|
28
|
+
/** Whether the target records apply sources; an older Atlas rejects the unknown `source` field. */
|
|
29
|
+
export declare function targetRecordsApplySource({ targetUrl, token }: {
|
|
30
|
+
targetUrl: string;
|
|
31
|
+
token: string;
|
|
32
|
+
}): Promise<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* Hand the apply's Git Service source to the pinned ORM package, which sends
|
|
35
|
+
* it for the namespace's activation history. Best effort: an unresolvable
|
|
36
|
+
* source or an older Atlas leaves the activation recorded as `reported`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function exportApplySource({ auth, targetUrl, resolve }: {
|
|
39
|
+
auth: {
|
|
40
|
+
token: string;
|
|
41
|
+
} | null;
|
|
42
|
+
targetUrl: string;
|
|
43
|
+
resolve: () => Promise<OrmApplySource | null>;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
/** `orm apply <dir>` from a local checkout; every other subcommand sends no source. */
|
|
46
|
+
export declare function exportLocalApplySource({ sub, auth, targetUrl, dir }: {
|
|
47
|
+
sub: string;
|
|
48
|
+
auth: {
|
|
49
|
+
token: string;
|
|
50
|
+
} | null;
|
|
51
|
+
targetUrl: string | undefined;
|
|
52
|
+
dir?: string;
|
|
53
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Git Service source an `orm apply` came from. The pinned ORM package
|
|
3
|
+
* reads it from SEQUENCE_ORM_SOURCE and sends it with the apply; Atlas checks
|
|
4
|
+
* it against Git Service and records the result on the namespace's activation
|
|
5
|
+
* history. A claim never authorizes anything, so a missing or wrong one only
|
|
6
|
+
* means the activation is recorded as `reported`.
|
|
7
|
+
*/
|
|
8
|
+
import { execFileSync } from 'node:child_process';
|
|
9
|
+
import { resolveRepo } from '@sequenceholdings/artifact-studio/git-service-client';
|
|
10
|
+
import { localGitMetadata, localSourceRoot } from '@sequenceholdings/artifact-studio/source-resolver';
|
|
11
|
+
/** Mirrors `SOURCE_ENV` in `@sequenceholdings/orm/cli`; older pinned packages ignore it. */
|
|
12
|
+
export const ORM_SOURCE_ENV = 'SEQUENCE_ORM_SOURCE';
|
|
13
|
+
const GIT_SERVICE_REPO_PATH = /^\/api\/git-service\/repos\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\/git\/?$/i;
|
|
14
|
+
/** The Git Service repository a clone's origin names, when that origin is the target environment's own Git Service. */
|
|
15
|
+
export function gitServiceRepoIdFromOrigin({ originUrl, targetUrl }) {
|
|
16
|
+
try {
|
|
17
|
+
const origin = new URL(originUrl);
|
|
18
|
+
if (origin.host !== new URL(targetUrl).host)
|
|
19
|
+
return null;
|
|
20
|
+
return origin.pathname.match(GIT_SERVICE_REPO_PATH)?.[1]?.toLowerCase() ?? null;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Source of an apply from a local checkout; null outside a clone of the target's Git Service. */
|
|
27
|
+
export function localOrmApplySource({ dir, targetUrl }) {
|
|
28
|
+
let originUrl;
|
|
29
|
+
try {
|
|
30
|
+
originUrl = String(execFileSync('git', ['remote', 'get-url', 'origin'], { cwd: dir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] })).trim();
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const repositoryId = gitServiceRepoIdFromOrigin({ originUrl, targetUrl });
|
|
36
|
+
const { gitCommit, gitDirty } = localGitMetadata(dir);
|
|
37
|
+
if (!repositoryId || !gitCommit)
|
|
38
|
+
return null;
|
|
39
|
+
return { repository_id: repositoryId, commit: gitCommit, path: localSourceRoot(dir), ...(gitDirty === null ? {} : { dirty: gitDirty }) };
|
|
40
|
+
}
|
|
41
|
+
/** Source of an apply materialized from `--repo`; the commit is the one the resolver pinned. */
|
|
42
|
+
export async function repoOrmApplySource({ targetUrl, token, namespace, name, commit, path }) {
|
|
43
|
+
if (!commit)
|
|
44
|
+
return null;
|
|
45
|
+
const repo = await resolveRepo({ baseUrl: targetUrl, token, namespace, name });
|
|
46
|
+
return { repository_id: repo.id, commit, path: path ?? '.', dirty: false };
|
|
47
|
+
}
|
|
48
|
+
/** Whether the target records apply sources; an older Atlas rejects the unknown `source` field. */
|
|
49
|
+
export async function targetRecordsApplySource({ targetUrl, token }) {
|
|
50
|
+
try {
|
|
51
|
+
const response = await fetch(new URL('/api/orm/runtime-capabilities', targetUrl), { headers: { authorization: `Bearer ${token}` } });
|
|
52
|
+
if (!response.ok)
|
|
53
|
+
return false;
|
|
54
|
+
const body = await response.json();
|
|
55
|
+
return typeof body === 'object' && body !== null && 'activationSource' in body && body.activationSource === true;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Hand the apply's Git Service source to the pinned ORM package, which sends
|
|
63
|
+
* it for the namespace's activation history. Best effort: an unresolvable
|
|
64
|
+
* source or an older Atlas leaves the activation recorded as `reported`.
|
|
65
|
+
*/
|
|
66
|
+
export async function exportApplySource({ auth, targetUrl, resolve }) {
|
|
67
|
+
delete process.env[ORM_SOURCE_ENV];
|
|
68
|
+
if (!auth || !(await targetRecordsApplySource({ targetUrl, token: auth.token })))
|
|
69
|
+
return;
|
|
70
|
+
try {
|
|
71
|
+
const source = await resolve();
|
|
72
|
+
if (source)
|
|
73
|
+
process.env[ORM_SOURCE_ENV] = JSON.stringify(source);
|
|
74
|
+
else
|
|
75
|
+
console.warn('[seq-studio] apply source unknown (not a clone of this environment\'s Git Service); the activation is recorded as reported');
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
console.warn(`[seq-studio] could not resolve the apply source: ${error instanceof Error ? error.message : String(error)}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** `orm apply <dir>` from a local checkout; every other subcommand sends no source. */
|
|
82
|
+
export async function exportLocalApplySource({ sub, auth, targetUrl, dir = '.' }) {
|
|
83
|
+
if (sub !== 'apply' || !targetUrl)
|
|
84
|
+
return;
|
|
85
|
+
await exportApplySource({ auth, targetUrl, resolve: async () => localOrmApplySource({ dir, targetUrl }) });
|
|
86
|
+
}
|