@sequenceholdings/studio-cli 0.9.15 → 0.9.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/dist/atlas-client.d.ts +2 -1
- package/dist/atlas-client.js +5 -4
- package/dist/auth.js +19 -4
- package/dist/command-help.d.ts +2 -2
- package/dist/command-help.js +9 -5
- package/dist/env-registry.d.ts +5 -1
- package/dist/env-registry.js +11 -2
- package/dist/host-token.d.ts +36 -0
- package/dist/host-token.js +83 -0
- package/dist/orm/apply-source.d.ts +45 -2
- package/dist/orm/apply-source.js +82 -14
- package/dist/orm/delegate.js +30 -34
- package/dist/orm/deployment-policy.js +29 -12
- package/dist/orm/help.d.ts +1 -1
- package/dist/orm/help.js +1 -1
- package/dist/orm/history.d.ts +2 -0
- package/dist/orm/history.js +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -917,11 +917,11 @@ compiled to canonical SQL before registration.
|
|
|
917
917
|
| `seq-studio orm validate [dir]` | Parse and compile the namespace, then verify its committed migration chain is current. |
|
|
918
918
|
| `seq-studio orm plan [dir] -e <env>` | Compare the compiled namespace with registry state without applying database changes; when available, print the live activation's source and provenance. |
|
|
919
919
|
| `seq-studio orm diff [dir] [--check]` | Author the next committed migration, or verify the migration/snapshot chain offline for CI. |
|
|
920
|
-
| `seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait] [--unverified-source "<reason>"]` | Author a migration if needed, register/apply the namespace, activate its operation set, publish its declared capabilities, and refresh generated outputs. Waits until the new version is live (prints `live:`; default up to 20m); `--no-wait` returns once queued. |
|
|
920
|
+
| `seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait] [--unverified-source "<reason>"] [--source-env <env>]` | Author a migration if needed, register/apply the namespace, activate its operation set, publish its declared capabilities, and refresh generated outputs. Waits until the new version is live (prints `live:`; default up to 20m); `--no-wait` returns once queued. `--source-env` verifies a checkout of another registered environment's Git Service; sign in there first. |
|
|
921
921
|
| `seq-studio orm history <namespace> -e <env> [--limit N] [--json]` | List every change to the namespace's live schema and operations, newest first, with the actor and the Git Service source. `apply` from a clone of the target environment's Git Service (or `--repo`) sends its commit and package path; Atlas checks it and records `verified`, `ci`, `break_glass` or `reported`. Environments with `ORM_REQUIRE_VERIFIED_SOURCE=1`, and namespaces pinned with `--mode source`, refuse unverified applies; a namespace admin can override with `orm apply --unverified-source "<reason>"`. |
|
|
922
922
|
| `seq-studio orm deployment-policy <namespace> -e <env> [--json]` | Inspect whether a namespace permits manual deployment, requires its enrolled repository's verified CI deployment, or is pinned to a verified source repository, branch and package path. |
|
|
923
923
|
| `seq-studio orm deployment-policy <namespace> -e <env> --mode ci --repo <ns>/<name> --branch <branch> --target <target-key>` | Explicitly enroll an existing namespace. Requires namespace Admin, repository Admin, and an automatic branch policy already bound to this exact namespace. |
|
|
924
|
-
| `seq-studio orm deployment-policy <namespace> -e <env> --mode source --repo <ns>/<name> --branch <branch> --path <dir
|
|
924
|
+
| `seq-studio orm deployment-policy <namespace> -e <env> --mode source --repo <ns>/<name> --branch <branch> --path <dir> [--source-env <env>]` | Keep direct applies but accept only ones Atlas verifies came from that repository, branch and package directory. Requires namespace Admin and repository Read; `--source-env` finds the repository in another registered environment and checks Read with your sign-in there. |
|
|
925
925
|
| `seq-studio orm deployment-policy <namespace> -e <env> --mode manual` | Restore direct, permission-checked deployment; requires namespace Admin. |
|
|
926
926
|
| `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. |
|
|
927
927
|
| `seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>` | Execute an operation from the checkout's manifest through the installed ORM package, with variables from a JSON object file, as the signed-in caller. |
|
|
@@ -1146,7 +1146,8 @@ definition, and supply only parameter values at runtime. Bind values with
|
|
|
1146
1146
|
shared manifest. `orm apply` and `orm execute` use the same lifecycle as GraphQL.
|
|
1147
1147
|
|
|
1148
1148
|
SQL reads currently support inner/left/right/full joins with `ON`, cross joins,
|
|
1149
|
-
`UNION`/`UNION ALL`, correlated EXISTS, non-recursive CTEs
|
|
1149
|
+
`UNION`/`UNION ALL`, correlated EXISTS, non-recursive CTEs (including
|
|
1150
|
+
`MATERIALIZED` and `NOT MATERIALIZED` hints),
|
|
1150
1151
|
grouping, supported aggregates, ordering, and limits. Unsupported SQL and
|
|
1151
1152
|
unsupported policies fail compilation. Results use column metadata plus row
|
|
1152
1153
|
arrays, with bigint and numeric values represented as strings. SQL writes,
|
|
@@ -1834,6 +1835,11 @@ successfully. Help does not initialize files, authenticate, or deploy.
|
|
|
1834
1835
|
| `seq-studio artifact promote <deployment-id> -e <env>` | `promote <deployment-id> --env <env>` |
|
|
1835
1836
|
| `seq-studio artifact rollback <deployment-id> -e <env>` | `rollback <deployment-id> --env <env>` |
|
|
1836
1837
|
|
|
1838
|
+
`artifact init` derives the initial bundle name, project ID, and title from the
|
|
1839
|
+
destination directory's final path component on both Windows and Unix. Review
|
|
1840
|
+
those fields in `artifact.bundle.yml` before the first deploy; the project ID
|
|
1841
|
+
becomes the deployed project's slug.
|
|
1842
|
+
|
|
1837
1843
|
Artifact commands reject unknown options before authentication or network
|
|
1838
1844
|
access, so a misspelled flag cannot be silently ignored. `seq-studio artifact
|
|
1839
1845
|
deploy` validates explicit manifest bindings: the selected
|
package/dist/atlas-client.d.ts
CHANGED
|
@@ -48,9 +48,10 @@ export declare function postJsonResponse({ baseUrl, token, path, body, headers,
|
|
|
48
48
|
headers?: Record<string, string>;
|
|
49
49
|
timeoutMs?: number;
|
|
50
50
|
}): Promise<AtlasResponse>;
|
|
51
|
-
export declare function putJson<T>({ baseUrl, token, path, body, }: ClientOptions & {
|
|
51
|
+
export declare function putJson<T>({ baseUrl, token, path, body, headers, }: ClientOptions & {
|
|
52
52
|
path: string;
|
|
53
53
|
body?: unknown;
|
|
54
|
+
headers?: Record<string, string>;
|
|
54
55
|
}): Promise<T>;
|
|
55
56
|
export declare function patchJson<T>({ baseUrl, token, path, body, }: ClientOptions & {
|
|
56
57
|
path: string;
|
package/dist/atlas-client.js
CHANGED
|
@@ -9,6 +9,7 @@ import { createPlatformTransport, createOperatorPlatformClient, } from "@sequenc
|
|
|
9
9
|
import { validationDetail } from "./validation-detail.js";
|
|
10
10
|
import { edgeAuthHeaders } from "./edge-auth-headers.js";
|
|
11
11
|
import { sandboxBearerFor } from "./sandbox-auth.js";
|
|
12
|
+
import { devboxHostToken } from "./host-token.js";
|
|
12
13
|
import { errorCode, isTransient503 } from "./transient-503.js";
|
|
13
14
|
import { fetchWithCliAttribution } from "./cli-attribution.js";
|
|
14
15
|
const MAX_503_RETRIES = 5;
|
|
@@ -57,7 +58,7 @@ async function authenticatedFetch({ baseUrl, init = {}, path, token, retry503 =
|
|
|
57
58
|
timeoutMs,
|
|
58
59
|
auth: {
|
|
59
60
|
kind: "operator",
|
|
60
|
-
bearer: async () => (await sandboxBearerFor(baseUrl)) ?? token,
|
|
61
|
+
bearer: async () => (await sandboxBearerFor(baseUrl)) ?? (await devboxHostToken(baseUrl)) ?? token,
|
|
61
62
|
},
|
|
62
63
|
edgeHeaders: () => edgeAuthHeaders(baseUrl),
|
|
63
64
|
});
|
|
@@ -261,14 +262,14 @@ export async function postJsonResponse({ baseUrl, token, path, body, headers = {
|
|
|
261
262
|
body: await response.text(),
|
|
262
263
|
};
|
|
263
264
|
}
|
|
264
|
-
export async function putJson({ baseUrl, token, path, body, }) {
|
|
265
|
+
export async function putJson({ baseUrl, token, path, body, headers, }) {
|
|
265
266
|
const response = await authenticatedFetch({
|
|
266
267
|
baseUrl,
|
|
267
268
|
token,
|
|
268
269
|
path,
|
|
269
270
|
init: {
|
|
270
271
|
method: "PUT",
|
|
271
|
-
headers: { "Content-Type": "application/json" },
|
|
272
|
+
headers: { ...headers, "Content-Type": "application/json" },
|
|
272
273
|
body: body === undefined ? undefined : JSON.stringify(body),
|
|
273
274
|
},
|
|
274
275
|
});
|
|
@@ -342,7 +343,7 @@ export function operatorPlatformClient({ baseUrl, token, }) {
|
|
|
342
343
|
return createOperatorPlatformClient({
|
|
343
344
|
fetchImpl: fetchWithCliAttribution,
|
|
344
345
|
baseUrl,
|
|
345
|
-
bearer: async () => (await sandboxBearerFor(baseUrl)) ?? token,
|
|
346
|
+
bearer: async () => (await sandboxBearerFor(baseUrl)) ?? (await devboxHostToken(baseUrl)) ?? token,
|
|
346
347
|
edgeHeaders: () => edgeAuthHeaders(baseUrl),
|
|
347
348
|
});
|
|
348
349
|
}
|
package/dist/auth.js
CHANGED
|
@@ -6,6 +6,7 @@ import { join } from 'node:path';
|
|
|
6
6
|
import { validateDeploymentAudience, validateDeploymentBaseUrl, } from '@sequenceholdings/artifact-studio/deployment-validation';
|
|
7
7
|
import { withCrossProcessFileLock } from './file-lock.js';
|
|
8
8
|
import { isSandboxOrigin, readSandboxToken, SandboxAuthError, sandboxTarget } from './sandbox-auth.js';
|
|
9
|
+
import { devboxHostToken } from './host-token.js';
|
|
9
10
|
function hasErrorCode(error, code) {
|
|
10
11
|
return error instanceof Error && Reflect.get(error, 'code') === code;
|
|
11
12
|
}
|
|
@@ -485,11 +486,25 @@ async function sandboxAccessToken(targetUrl) {
|
|
|
485
486
|
}
|
|
486
487
|
return { authMode: 'sandbox', token: await readSandboxToken(sandbox) };
|
|
487
488
|
}
|
|
489
|
+
/**
|
|
490
|
+
* A devbox owner's login, written per host by the control plane (host-token.ts).
|
|
491
|
+
* It is that person's identity, so it resolves as `user`; keyed by the request's
|
|
492
|
+
* own host, it can only ever go where it was minted.
|
|
493
|
+
*/
|
|
494
|
+
async function devboxAccessToken(targetUrl) {
|
|
495
|
+
const token = targetUrl ? await devboxHostToken(targetUrl) : null;
|
|
496
|
+
return token ? { authMode: 'user', token } : null;
|
|
497
|
+
}
|
|
498
|
+
/** A token the environment supplies rather than a login: the sandbox bearer, else a devbox owner token. */
|
|
499
|
+
async function ambientAccessToken(targetUrl) {
|
|
500
|
+
return (await sandboxAccessToken(targetUrl)) ?? devboxAccessToken(targetUrl);
|
|
501
|
+
}
|
|
488
502
|
async function resolveAccessTokenWithMode(options) {
|
|
489
|
-
// Sandbox token mode replaces every other source, before any realm lookup
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
503
|
+
// Sandbox token mode replaces every other source, before any realm lookup;
|
|
504
|
+
// then a devbox owner's login for the target host.
|
|
505
|
+
const ambient = await ambientAccessToken(options?.targetUrl);
|
|
506
|
+
if (ambient)
|
|
507
|
+
return ambient;
|
|
493
508
|
const realm = await realmForEnv(options?.env, { targetUrl: options?.targetUrl });
|
|
494
509
|
if (options?.targetUrl)
|
|
495
510
|
validateRealmTarget({ realm, targetUrl: options.targetUrl });
|
package/dist/command-help.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ 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
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. \"break_glass\" is an admin override made with\n orm apply --unverified-source \"<reason>\". * marks the live activation.\n History starts with 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 seq-studio orm deployment-policy <namespace> -e <env> --mode source --repo <ns>/<name> --branch <branch> --path <dir
|
|
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] [--unverified-source \"<reason>\"]\n seq-studio orm history <namespace> -e <env> [--limit N] [--json]\n seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci|source] [--repo <ns>/<name> --branch <branch> (--target <target-key> | --path <dir>)] [--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. Source-pinned namespaces accept only applies Atlas verifies against\n their repository, branch and package path, and an environment can require a\n verified source for every apply. A namespace admin may record an audited\n exception with --unverified-source \"<reason>\". deployment-policy reads or
|
|
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 seq-studio orm deployment-policy <namespace> -e <env> --mode source --repo <ns>/<name> --branch <branch> --path <dir> [--source-env <env>]\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\n Source mode keeps direct applies but accepts only ones Atlas verifies came\n from that repository, branch and package directory (pass --path . for the\n repository root). It requires namespace Admin and repository Read. Namespace\n admins can still apply with --unverified-source \"<reason>\", which is recorded.\n --source-env names the environment whose Git Service holds the repository when\n it is not this one's (sign in there too); applies must then pass the same\n --source-env from a clean clone of that repository.\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] [--unverified-source \"<reason>\"] [--source-env <env>]\n seq-studio orm history <namespace> -e <env> [--limit N] [--json]\n seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci|source] [--repo <ns>/<name> --branch <branch> (--target <target-key> | --path <dir> [--source-env <env>])] [--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. Source-pinned namespaces accept only applies Atlas verifies against\n their repository, branch and package path, and an environment can require a\n verified source for every apply. A namespace admin may record an audited\n exception with --unverified-source \"<reason>\". --source-env <env> applies from a\n clone of another environment's Git Service, which Atlas verifies there with your\n sign-in for it. 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";
|
|
7
7
|
/** Artifact commands in sandbox token mode; shared by the offline and delegate usage. */
|
|
8
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";
|
|
9
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";
|
package/dist/command-help.js
CHANGED
|
@@ -28,7 +28,7 @@ export const ORM_DEPLOYMENT_POLICY_HELP = `usage:
|
|
|
28
28
|
seq-studio orm deployment-policy <namespace> -e <env> [--json]
|
|
29
29
|
seq-studio orm deployment-policy <namespace> -e <env> --mode ci --repo <ns>/<name> --branch <branch> --target <target-key>
|
|
30
30
|
seq-studio orm deployment-policy <namespace> -e <env> --mode manual
|
|
31
|
-
seq-studio orm deployment-policy <namespace> -e <env> --mode source --repo <ns>/<name> --branch <branch> --path <dir>
|
|
31
|
+
seq-studio orm deployment-policy <namespace> -e <env> --mode source --repo <ns>/<name> --branch <branch> --path <dir> [--source-env <env>]
|
|
32
32
|
|
|
33
33
|
Existing namespaces default to manual deployment. CI mode rejects direct ORM
|
|
34
34
|
registration, schema apply, and operations-only activation on the server;
|
|
@@ -41,15 +41,18 @@ export const ORM_DEPLOYMENT_POLICY_HELP = `usage:
|
|
|
41
41
|
from that repository, branch and package directory (pass --path . for the
|
|
42
42
|
repository root). It requires namespace Admin and repository Read. Namespace
|
|
43
43
|
admins can still apply with --unverified-source "<reason>", which is recorded.
|
|
44
|
+
--source-env names the environment whose Git Service holds the repository when
|
|
45
|
+
it is not this one's (sign in there too); applies must then pass the same
|
|
46
|
+
--source-env from a clean clone of that repository.
|
|
44
47
|
`;
|
|
45
48
|
export const ORM_HELP = `usage:
|
|
46
49
|
seq-studio orm init <dir> [--repo <ns>/<name>]
|
|
47
50
|
seq-studio orm generate [dir] [--migration-export] [--check]
|
|
48
51
|
seq-studio orm validate [dir]
|
|
49
52
|
seq-studio orm plan [dir] -e <env>
|
|
50
|
-
seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait] [--unverified-source "<reason>"]
|
|
53
|
+
seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait] [--unverified-source "<reason>"] [--source-env <env>]
|
|
51
54
|
seq-studio orm history <namespace> -e <env> [--limit N] [--json]
|
|
52
|
-
seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci|source] [--repo <ns>/<name> --branch <branch> (--target <target-key> | --path <dir>)] [--json]
|
|
55
|
+
seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci|source] [--repo <ns>/<name> --branch <branch> (--target <target-key> | --path <dir> [--source-env <env>])] [--json]
|
|
53
56
|
seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...
|
|
54
57
|
seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
|
|
55
58
|
seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]
|
|
@@ -71,8 +74,9 @@ export const ORM_HELP = `usage:
|
|
|
71
74
|
workflow. Source-pinned namespaces accept only applies Atlas verifies against
|
|
72
75
|
their repository, branch and package path, and an environment can require a
|
|
73
76
|
verified source for every apply. A namespace admin may record an audited
|
|
74
|
-
exception with --unverified-source "<reason>".
|
|
75
|
-
|
|
77
|
+
exception with --unverified-source "<reason>". --source-env <env> applies from a
|
|
78
|
+
clone of another environment's Git Service, which Atlas verifies there with your
|
|
79
|
+
sign-in for it. deployment-policy reads or explicitly changes this namespace setting.
|
|
76
80
|
namespaces lists what you can read; describe shows its tables and operations.
|
|
77
81
|
Run seq-studio orm describe --help for the output.
|
|
78
82
|
execute <namespace> <operation> runs the deployed version's persisted operation by
|
package/dist/env-registry.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ interface DiscoveredRealm {
|
|
|
5
5
|
organization?: string;
|
|
6
6
|
m2mClientId?: string;
|
|
7
7
|
}
|
|
8
|
+
/** A deployment's public CLI login, and the CLI environment name it advertises for itself. */
|
|
9
|
+
interface DeploymentLogin extends DiscoveredRealm {
|
|
10
|
+
cliEnvironment?: string;
|
|
11
|
+
}
|
|
8
12
|
interface RegistrationResult {
|
|
9
13
|
name: string;
|
|
10
14
|
baseUrl: string;
|
|
@@ -19,7 +23,7 @@ export declare function seqapiConfigPath(): string;
|
|
|
19
23
|
export declare function fetchDeploymentLogin({ baseUrl, fetchImpl, }: {
|
|
20
24
|
baseUrl: string;
|
|
21
25
|
fetchImpl?: typeof fetch;
|
|
22
|
-
}): Promise<
|
|
26
|
+
}): Promise<DeploymentLogin>;
|
|
23
27
|
export declare function readRegisteredEnvironmentUrls({ configFile, }?: {
|
|
24
28
|
configFile?: string;
|
|
25
29
|
}): Promise<Record<string, {
|
package/dist/env-registry.js
CHANGED
|
@@ -3,7 +3,7 @@ import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { dirname, join } from 'node:path';
|
|
5
5
|
import { validateDeploymentAudience, validateDeploymentBaseUrl, } from '@sequenceholdings/artifact-studio/deployment-validation';
|
|
6
|
-
import { deleteRealmTokens, isSequenceAuthEnvName, validateAuth0Domain, } from './auth.js';
|
|
6
|
+
import { deleteRealmTokens, isSequenceAuthEnvName, isSharedLoginDeploymentName, usesSharedSequenceLogin, validateAuth0Domain, } from './auth.js';
|
|
7
7
|
import { withCrossProcessFileLock } from './file-lock.js';
|
|
8
8
|
const DISCOVERY_PATH = '/api/auth/cli-config';
|
|
9
9
|
const ENV_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
@@ -30,7 +30,14 @@ function validateEnvironmentName(input) {
|
|
|
30
30
|
return name;
|
|
31
31
|
}
|
|
32
32
|
async function discoverRealm({ baseUrl, fetchImpl, }) {
|
|
33
|
-
const login = await fetchDeploymentLogin({ baseUrl, fetchImpl });
|
|
33
|
+
const { cliEnvironment, ...login } = await fetchDeploymentLogin({ baseUrl, fetchImpl });
|
|
34
|
+
// A tenant registration never trusts the shared Sequence login, so a first-party deployment
|
|
35
|
+
// is saved under its reserved name instead: say which, rather than refuse its audience.
|
|
36
|
+
if (usesSharedSequenceLogin(login)) {
|
|
37
|
+
const reserved = cliEnvironment && isSharedLoginDeploymentName(cliEnvironment) ? cliEnvironment : '<staging|production|banksouth>';
|
|
38
|
+
throw new Error(`${baseUrl} signs in with the shared Sequence login, so it is a first-party deployment. ` +
|
|
39
|
+
`Save it under its first-party name instead: seq-studio envs add ${reserved} ${baseUrl}`);
|
|
40
|
+
}
|
|
34
41
|
return { ...login, audience: validateDeploymentAudience({ audience: login.audience, baseUrl }) };
|
|
35
42
|
}
|
|
36
43
|
/**
|
|
@@ -83,12 +90,14 @@ export async function fetchDeploymentLogin({ baseUrl, fetchImpl = fetch, }) {
|
|
|
83
90
|
if (missing.length > 0 || !domain || !clientId || !audience) {
|
|
84
91
|
throw new Error(`${url} response is missing auth0.{${missing.join(', ')}}.`);
|
|
85
92
|
}
|
|
93
|
+
const cliEnvironment = isRecord(data) ? optionalString(Reflect.get(data, 'cliEnvironment')) : undefined;
|
|
86
94
|
return {
|
|
87
95
|
domain: validateAuth0Domain(domain),
|
|
88
96
|
clientId,
|
|
89
97
|
audience,
|
|
90
98
|
organization: optionalString(Reflect.get(auth0, 'organization')),
|
|
91
99
|
m2mClientId: optionalString(Reflect.get(auth0, 'm2mClientId')),
|
|
100
|
+
...(cliEnvironment ? { cliEnvironment } : {}),
|
|
92
101
|
};
|
|
93
102
|
}
|
|
94
103
|
async function loadConfig(configFile) {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Devbox host tokens.
|
|
3
|
+
*
|
|
4
|
+
* On a seq-code devbox that serves a Claude cloud session, the control plane
|
|
5
|
+
* writes the box owner's own short-lived Sequence login for each Atlas
|
|
6
|
+
* deployment it can vouch for into a directory, one file per host, and
|
|
7
|
+
* replaces them before they expire:
|
|
8
|
+
*
|
|
9
|
+
* SEQ_DEVBOX_TOKEN_DIR/<host> e.g. staging.example.seqholdings.com
|
|
10
|
+
*
|
|
11
|
+
* A request to an origin whose host has a live file uses it ahead of the login
|
|
12
|
+
* cache; every other origin resolves exactly as before. Unlike sandbox token
|
|
13
|
+
* mode this pins nothing: `-e` still picks the deployment, and a deployment
|
|
14
|
+
* with no file (or `-e local`) falls through to the usual login.
|
|
15
|
+
*
|
|
16
|
+
* The file is read again for each request, so a rotation mid-command is picked
|
|
17
|
+
* up. A token whose `exp` is past (or within a minute of it) is ignored rather
|
|
18
|
+
* than sent: the login cache, if any, is the better answer then.
|
|
19
|
+
*/
|
|
20
|
+
export declare const DEVBOX_TOKEN_DIR_ENV = "SEQ_DEVBOX_TOKEN_DIR";
|
|
21
|
+
/** The file name a token for `url` lives under, or null for an origin that never has one. */
|
|
22
|
+
export declare function devboxTokenHost(url: string): string | null;
|
|
23
|
+
/** The JWT's `exp`, read without verifying it: the server verifies, this only avoids sending a dead token. */
|
|
24
|
+
export declare function jwtExpiry(token: string): number | null;
|
|
25
|
+
/**
|
|
26
|
+
* The live devbox token for a request to `url`, or null outside a devbox, for
|
|
27
|
+
* a host with no file, or for an expired, unreadable or malformed one. Never
|
|
28
|
+
* throws: a broken file must not stop the ordinary login path.
|
|
29
|
+
*
|
|
30
|
+
* Also null under `SEQAPI_AUTH_MODE=m2m`, matching seqapi: an explicitly
|
|
31
|
+
* requested machine identity must not be swapped for the box owner's login.
|
|
32
|
+
*/
|
|
33
|
+
export declare function devboxHostToken(url: string, { env, now }?: {
|
|
34
|
+
env?: NodeJS.ProcessEnv;
|
|
35
|
+
now?: number;
|
|
36
|
+
}): Promise<string | null>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Devbox host tokens.
|
|
3
|
+
*
|
|
4
|
+
* On a seq-code devbox that serves a Claude cloud session, the control plane
|
|
5
|
+
* writes the box owner's own short-lived Sequence login for each Atlas
|
|
6
|
+
* deployment it can vouch for into a directory, one file per host, and
|
|
7
|
+
* replaces them before they expire:
|
|
8
|
+
*
|
|
9
|
+
* SEQ_DEVBOX_TOKEN_DIR/<host> e.g. staging.example.seqholdings.com
|
|
10
|
+
*
|
|
11
|
+
* A request to an origin whose host has a live file uses it ahead of the login
|
|
12
|
+
* cache; every other origin resolves exactly as before. Unlike sandbox token
|
|
13
|
+
* mode this pins nothing: `-e` still picks the deployment, and a deployment
|
|
14
|
+
* with no file (or `-e local`) falls through to the usual login.
|
|
15
|
+
*
|
|
16
|
+
* The file is read again for each request, so a rotation mid-command is picked
|
|
17
|
+
* up. A token whose `exp` is past (or within a minute of it) is ignored rather
|
|
18
|
+
* than sent: the login cache, if any, is the better answer then.
|
|
19
|
+
*/
|
|
20
|
+
import { readFile } from 'node:fs/promises';
|
|
21
|
+
import { join } from 'node:path';
|
|
22
|
+
export const DEVBOX_TOKEN_DIR_ENV = 'SEQ_DEVBOX_TOKEN_DIR';
|
|
23
|
+
const HOST = /^[a-z0-9.-]+(?::\d{1,5})?$/;
|
|
24
|
+
const EXPIRY_MARGIN_SECONDS = 60;
|
|
25
|
+
/** The file name a token for `url` lives under, or null for an origin that never has one. */
|
|
26
|
+
export function devboxTokenHost(url) {
|
|
27
|
+
let parsed;
|
|
28
|
+
try {
|
|
29
|
+
parsed = new URL(url);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
// Loopback Atlas (the box's own) signs its own tokens; the control plane never writes one for it.
|
|
35
|
+
if (parsed.protocol !== 'https:')
|
|
36
|
+
return null;
|
|
37
|
+
const host = parsed.host.toLowerCase();
|
|
38
|
+
return HOST.test(host) ? host : null;
|
|
39
|
+
}
|
|
40
|
+
/** The JWT's `exp`, read without verifying it: the server verifies, this only avoids sending a dead token. */
|
|
41
|
+
export function jwtExpiry(token) {
|
|
42
|
+
const payload = token.split('.')[1];
|
|
43
|
+
if (!payload)
|
|
44
|
+
return null;
|
|
45
|
+
try {
|
|
46
|
+
const exp = JSON.parse(Buffer.from(payload, 'base64url').toString('utf8')).exp;
|
|
47
|
+
return typeof exp === 'number' && Number.isFinite(exp) ? exp : null;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The live devbox token for a request to `url`, or null outside a devbox, for
|
|
55
|
+
* a host with no file, or for an expired, unreadable or malformed one. Never
|
|
56
|
+
* throws: a broken file must not stop the ordinary login path.
|
|
57
|
+
*
|
|
58
|
+
* Also null under `SEQAPI_AUTH_MODE=m2m`, matching seqapi: an explicitly
|
|
59
|
+
* requested machine identity must not be swapped for the box owner's login.
|
|
60
|
+
*/
|
|
61
|
+
export async function devboxHostToken(url, { env = process.env, now = Date.now() } = {}) {
|
|
62
|
+
if (env.SEQAPI_AUTH_MODE?.trim().toLowerCase() === 'm2m')
|
|
63
|
+
return null;
|
|
64
|
+
const dir = env[DEVBOX_TOKEN_DIR_ENV]?.trim();
|
|
65
|
+
if (!dir)
|
|
66
|
+
return null;
|
|
67
|
+
const host = devboxTokenHost(url);
|
|
68
|
+
if (!host)
|
|
69
|
+
return null;
|
|
70
|
+
let token;
|
|
71
|
+
try {
|
|
72
|
+
token = (await readFile(join(dir, host), 'utf8')).trim();
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
if (!token || /[\s\0]/.test(token))
|
|
78
|
+
return null;
|
|
79
|
+
const exp = jwtExpiry(token);
|
|
80
|
+
if (exp === null || exp * 1000 <= now + EXPIRY_MARGIN_SECONDS * 1000)
|
|
81
|
+
return null;
|
|
82
|
+
return token;
|
|
83
|
+
}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
/** Mirrors `SOURCE_ENV` in `@sequenceholdings/orm/cli`; older pinned packages ignore it. */
|
|
2
2
|
export declare const ORM_SOURCE_ENV = "SEQUENCE_ORM_SOURCE";
|
|
3
|
+
/** Mirrors `SOURCE_AUTHORIZATION_ENV` in `@sequenceholdings/orm/cli`; older pinned packages ignore it. */
|
|
4
|
+
export declare const ORM_SOURCE_AUTHORIZATION_ENV = "SEQUENCE_ORM_SOURCE_AUTHORIZATION";
|
|
3
5
|
export interface OrmApplySource {
|
|
4
6
|
repository_id: string;
|
|
5
7
|
commit: string;
|
|
6
8
|
path: string;
|
|
7
9
|
dirty?: boolean;
|
|
10
|
+
/** The registered environment whose Git Service holds the repository, when it is not the target's. */
|
|
11
|
+
source_environment?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Another environment whose Git Service holds the source, with the caller's own token there. */
|
|
14
|
+
export interface OrmSourceEnvironment {
|
|
15
|
+
name: string;
|
|
16
|
+
url: string;
|
|
17
|
+
token: string;
|
|
8
18
|
}
|
|
9
19
|
/** The Git Service repository a clone's origin names, when that origin is the target environment's own Git Service. */
|
|
10
20
|
export declare function gitServiceRepoIdFromOrigin({ originUrl, targetUrl }: {
|
|
@@ -37,11 +47,41 @@ export declare function takeUnverifiedSourceFlag({ sub, argv }: {
|
|
|
37
47
|
} | {
|
|
38
48
|
error: string;
|
|
39
49
|
};
|
|
50
|
+
/** Pull `--source-env <env>` (or `=env`) off the argv; only `apply` accepts it. */
|
|
51
|
+
export declare function takeSourceEnvFlag({ sub, argv }: {
|
|
52
|
+
sub: string;
|
|
53
|
+
argv: readonly string[];
|
|
54
|
+
}): {
|
|
55
|
+
sourceEnv?: string;
|
|
56
|
+
args: string[];
|
|
57
|
+
} | {
|
|
58
|
+
error: string;
|
|
59
|
+
};
|
|
60
|
+
/** `--unverified-source` and `--source-env` off the argv, in one pass for the delegate. */
|
|
61
|
+
export declare function takeApplySourceFlags({ sub, argv }: {
|
|
62
|
+
sub: string;
|
|
63
|
+
argv: readonly string[];
|
|
64
|
+
}): {
|
|
65
|
+
unverifiedReason?: string;
|
|
66
|
+
sourceEnv?: string;
|
|
67
|
+
args: string[];
|
|
68
|
+
} | {
|
|
69
|
+
error: string;
|
|
70
|
+
};
|
|
71
|
+
export declare const SOURCE_ENV_WITH_REPO_ERROR = "--source-env applies to a local checkout; apply from a clean clone of that environment's repository instead of --repo";
|
|
72
|
+
/** The `--source-env` environment and the caller's own token there, or why it cannot be used. */
|
|
73
|
+
export declare function resolveOrmSourceEnvironment({ requested }: {
|
|
74
|
+
requested: string;
|
|
75
|
+
}): Promise<OrmSourceEnvironment | {
|
|
76
|
+
error: string;
|
|
77
|
+
}>;
|
|
40
78
|
export interface ApplySourceCapabilities {
|
|
41
79
|
/** The target records apply sources; an older Atlas rejects the unknown `source` field. */
|
|
42
80
|
records: boolean;
|
|
43
81
|
/** The target refuses applies whose source it cannot verify. */
|
|
44
82
|
enforced: boolean;
|
|
83
|
+
/** The target can verify a source held in another environment's Git Service. */
|
|
84
|
+
sourceEnvironment: boolean;
|
|
45
85
|
}
|
|
46
86
|
export declare function applySourceCapabilities({ targetUrl, token }: {
|
|
47
87
|
targetUrl: string;
|
|
@@ -53,18 +93,20 @@ export declare function applySourceCapabilities({ targetUrl, token }: {
|
|
|
53
93
|
* succeed when the target enforces verified sources and this one plainly will
|
|
54
94
|
* not verify, so the caller stops before registering anything.
|
|
55
95
|
*/
|
|
56
|
-
export declare function exportApplySource({ auth, targetUrl, resolve, unverifiedReason, dryRun }: {
|
|
96
|
+
export declare function exportApplySource({ auth, targetUrl, resolve, unverifiedReason, sourceEnvironment, dryRun }: {
|
|
57
97
|
auth: {
|
|
58
98
|
token: string;
|
|
59
99
|
} | null;
|
|
60
100
|
targetUrl: string;
|
|
61
101
|
resolve: () => Promise<OrmApplySource | null>;
|
|
62
102
|
unverifiedReason?: string;
|
|
103
|
+
/** The source is a clone of this environment's Git Service, not the target's. */
|
|
104
|
+
sourceEnvironment?: OrmSourceEnvironment;
|
|
63
105
|
/** A rehearsal on a disposable fork activates nothing, so it is never refused for its source. */
|
|
64
106
|
dryRun?: boolean;
|
|
65
107
|
}): Promise<string | null>;
|
|
66
108
|
/** `orm apply <dir>` from a local checkout; every other subcommand sends no source. */
|
|
67
|
-
export declare function exportLocalApplySource({ sub, auth, targetUrl, dir, unverifiedReason, dryRun }: {
|
|
109
|
+
export declare function exportLocalApplySource({ sub, auth, targetUrl, dir, unverifiedReason, sourceEnvironment, dryRun }: {
|
|
68
110
|
sub: string;
|
|
69
111
|
auth: {
|
|
70
112
|
token: string;
|
|
@@ -72,5 +114,6 @@ export declare function exportLocalApplySource({ sub, auth, targetUrl, dir, unve
|
|
|
72
114
|
targetUrl: string | undefined;
|
|
73
115
|
dir?: string;
|
|
74
116
|
unverifiedReason?: string;
|
|
117
|
+
sourceEnvironment?: OrmSourceEnvironment;
|
|
75
118
|
dryRun?: boolean;
|
|
76
119
|
}): Promise<string | null>;
|
package/dist/orm/apply-source.js
CHANGED
|
@@ -8,8 +8,12 @@
|
|
|
8
8
|
import { execFileSync } from 'node:child_process';
|
|
9
9
|
import { resolveRepo } from '@sequenceholdings/artifact-studio/git-service-client';
|
|
10
10
|
import { localGitMetadata, localSourceRoot } from '@sequenceholdings/artifact-studio/source-resolver';
|
|
11
|
+
import { tryGetAccessTokenWithMode } from '../auth.js';
|
|
12
|
+
import { resolveConfiguredEnv } from '../config.js';
|
|
11
13
|
/** Mirrors `SOURCE_ENV` in `@sequenceholdings/orm/cli`; older pinned packages ignore it. */
|
|
12
14
|
export const ORM_SOURCE_ENV = 'SEQUENCE_ORM_SOURCE';
|
|
15
|
+
/** Mirrors `SOURCE_AUTHORIZATION_ENV` in `@sequenceholdings/orm/cli`; older pinned packages ignore it. */
|
|
16
|
+
export const ORM_SOURCE_AUTHORIZATION_ENV = 'SEQUENCE_ORM_SOURCE_AUTHORIZATION';
|
|
13
17
|
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
18
|
/** The Git Service repository a clone's origin names, when that origin is the target environment's own Git Service. */
|
|
15
19
|
export function gitServiceRepoIdFromOrigin({ originUrl, targetUrl }) {
|
|
@@ -68,31 +72,93 @@ export function takeUnverifiedSourceFlag({ sub, argv }) {
|
|
|
68
72
|
return { error: `${UNVERIFIED_SOURCE_FLAG} applies only to apply` };
|
|
69
73
|
return reason === undefined ? { args } : { reason, args };
|
|
70
74
|
}
|
|
75
|
+
const SOURCE_ENV_FLAG = '--source-env';
|
|
76
|
+
/** Pull `--source-env <env>` (or `=env`) off the argv; only `apply` accepts it. */
|
|
77
|
+
export function takeSourceEnvFlag({ sub, argv }) {
|
|
78
|
+
const args = [];
|
|
79
|
+
let sourceEnv;
|
|
80
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
81
|
+
const arg = argv[index];
|
|
82
|
+
if (arg !== SOURCE_ENV_FLAG && !arg.startsWith(`${SOURCE_ENV_FLAG}=`)) {
|
|
83
|
+
args.push(arg);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const value = arg === SOURCE_ENV_FLAG ? argv[(index += 1)] : arg.slice(SOURCE_ENV_FLAG.length + 1);
|
|
87
|
+
if (value === undefined || value.trim() === '' || value.startsWith('-'))
|
|
88
|
+
return { error: `${SOURCE_ENV_FLAG} needs an environment name, e.g. ${SOURCE_ENV_FLAG} banksouth` };
|
|
89
|
+
sourceEnv = value.trim();
|
|
90
|
+
}
|
|
91
|
+
if (sourceEnv !== undefined && sub !== 'apply')
|
|
92
|
+
return { error: `${SOURCE_ENV_FLAG} applies only to apply` };
|
|
93
|
+
return sourceEnv === undefined ? { args } : { sourceEnv, args };
|
|
94
|
+
}
|
|
95
|
+
/** `--unverified-source` and `--source-env` off the argv, in one pass for the delegate. */
|
|
96
|
+
export function takeApplySourceFlags({ sub, argv }) {
|
|
97
|
+
const unverified = takeUnverifiedSourceFlag({ sub, argv });
|
|
98
|
+
if ('error' in unverified)
|
|
99
|
+
return unverified;
|
|
100
|
+
const source = takeSourceEnvFlag({ sub, argv: unverified.args });
|
|
101
|
+
if ('error' in source)
|
|
102
|
+
return source;
|
|
103
|
+
return { args: source.args, ...(unverified.reason ? { unverifiedReason: unverified.reason } : {}), ...(source.sourceEnv ? { sourceEnv: source.sourceEnv } : {}) };
|
|
104
|
+
}
|
|
105
|
+
export const SOURCE_ENV_WITH_REPO_ERROR = `${SOURCE_ENV_FLAG} applies to a local checkout; apply from a clean clone of that environment's repository instead of --repo`;
|
|
106
|
+
/** The `--source-env` environment and the caller's own token there, or why it cannot be used. */
|
|
107
|
+
export async function resolveOrmSourceEnvironment({ requested }) {
|
|
108
|
+
const env = await resolveConfiguredEnv({ requested });
|
|
109
|
+
const auth = await tryGetAccessTokenWithMode({ failClosedForM2m: true, env: env.name, targetUrl: env.url });
|
|
110
|
+
if (!auth || auth.authMode === 'sandbox')
|
|
111
|
+
return { error: `${SOURCE_ENV_FLAG} ${env.name} needs your own sign-in there: run seq-studio login -e ${env.name}` };
|
|
112
|
+
return { name: env.name, url: env.url, token: auth.token };
|
|
113
|
+
}
|
|
114
|
+
/** Name the source environment on the claim and hand its credential to the pinned ORM package, which sends it only with the apply. */
|
|
115
|
+
function attachSourceEnvironment({ source, sourceEnvironment }) {
|
|
116
|
+
if (!sourceEnvironment)
|
|
117
|
+
return source;
|
|
118
|
+
process.env[ORM_SOURCE_AUTHORIZATION_ENV] = sourceEnvironment.token;
|
|
119
|
+
return { ...source, source_environment: sourceEnvironment.name };
|
|
120
|
+
}
|
|
121
|
+
const NO_CAPABILITIES = { records: false, enforced: false, sourceEnvironment: false };
|
|
71
122
|
export async function applySourceCapabilities({ targetUrl, token }) {
|
|
72
123
|
try {
|
|
73
124
|
const response = await fetch(new URL('/api/orm/runtime-capabilities', targetUrl), { headers: { authorization: `Bearer ${token}` } });
|
|
74
125
|
if (!response.ok)
|
|
75
|
-
return
|
|
126
|
+
return NO_CAPABILITIES;
|
|
76
127
|
const body = await response.json();
|
|
77
128
|
if (typeof body !== 'object' || body === null)
|
|
78
|
-
return
|
|
129
|
+
return NO_CAPABILITIES;
|
|
79
130
|
const records = 'activationSource' in body && body.activationSource === true;
|
|
80
|
-
return {
|
|
131
|
+
return {
|
|
132
|
+
records,
|
|
133
|
+
enforced: records && 'requireVerifiedSource' in body && body.requireVerifiedSource === true,
|
|
134
|
+
sourceEnvironment: records && 'activationSourceEnvironment' in body && body.activationSourceEnvironment === true,
|
|
135
|
+
};
|
|
81
136
|
}
|
|
82
137
|
catch {
|
|
83
|
-
return
|
|
138
|
+
return NO_CAPABILITIES;
|
|
84
139
|
}
|
|
85
140
|
}
|
|
141
|
+
function unverifiableSourceRefusal({ problem, sourceEnvironment }) {
|
|
142
|
+
const required = sourceEnvironment ? `--source-env ${sourceEnvironment.name} applies only` : 'This environment applies ORM changes only';
|
|
143
|
+
return `${required} from a pushed commit Atlas can verify, and this checkout ${problem}. ` +
|
|
144
|
+
`Commit and push the package (run \`seq-studio orm diff\` first so its migration is committed), then apply again${sourceEnvironment ? '' : ' or use --repo'}. ` +
|
|
145
|
+
`Namespace admins can override with ${UNVERIFIED_SOURCE_FLAG} "<reason>".`;
|
|
146
|
+
}
|
|
86
147
|
/**
|
|
87
148
|
* Hand the apply's Git Service source, and any override reason, to the pinned
|
|
88
149
|
* ORM package, which sends them with the apply. Returns why the apply cannot
|
|
89
150
|
* succeed when the target enforces verified sources and this one plainly will
|
|
90
151
|
* not verify, so the caller stops before registering anything.
|
|
91
152
|
*/
|
|
92
|
-
export async function exportApplySource({ auth, targetUrl, resolve, unverifiedReason, dryRun = false }) {
|
|
153
|
+
export async function exportApplySource({ auth, targetUrl, resolve, unverifiedReason, sourceEnvironment, dryRun = false }) {
|
|
93
154
|
delete process.env[ORM_SOURCE_ENV];
|
|
94
155
|
delete process.env[ORM_UNVERIFIED_SOURCE_REASON_ENV];
|
|
95
|
-
|
|
156
|
+
delete process.env[ORM_SOURCE_AUTHORIZATION_ENV];
|
|
157
|
+
const capabilities = auth ? await applySourceCapabilities({ targetUrl, token: auth.token }) : NO_CAPABILITIES;
|
|
158
|
+
if (sourceEnvironment && !capabilities.sourceEnvironment) {
|
|
159
|
+
return `${targetUrl} cannot verify a source in another environment's Git Service yet; apply without --source-env, ` +
|
|
160
|
+
'which records the activation as reported, once this Atlas supports it.';
|
|
161
|
+
}
|
|
96
162
|
if (!capabilities.records)
|
|
97
163
|
return null;
|
|
98
164
|
if (unverifiedReason)
|
|
@@ -105,14 +171,14 @@ export async function exportApplySource({ auth, targetUrl, resolve, unverifiedRe
|
|
|
105
171
|
console.warn(`[seq-studio] could not resolve the apply source: ${error instanceof Error ? error.message : String(error)}`);
|
|
106
172
|
}
|
|
107
173
|
if (source)
|
|
108
|
-
process.env[ORM_SOURCE_ENV] = JSON.stringify(source);
|
|
109
|
-
const
|
|
174
|
+
process.env[ORM_SOURCE_ENV] = JSON.stringify(attachSourceEnvironment({ source, sourceEnvironment }));
|
|
175
|
+
const gitService = sourceEnvironment ? `${sourceEnvironment.name}'s Git Service` : 'this environment\'s Git Service';
|
|
176
|
+
const problem = !source ? `is not a clone of ${gitService}` : source.dirty ? 'has uncommitted changes in the ORM package' : null;
|
|
110
177
|
if (!problem)
|
|
111
178
|
return null;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
`Namespace admins can override with ${UNVERIFIED_SOURCE_FLAG} "<reason>".`;
|
|
179
|
+
// --source-env asks for a verified apply, so an unverifiable checkout is refused wherever the target does not enforce.
|
|
180
|
+
if ((capabilities.enforced || sourceEnvironment) && !unverifiedReason && !dryRun) {
|
|
181
|
+
return unverifiableSourceRefusal({ problem, sourceEnvironment });
|
|
116
182
|
}
|
|
117
183
|
if (dryRun)
|
|
118
184
|
return null;
|
|
@@ -120,8 +186,10 @@ export async function exportApplySource({ auth, targetUrl, resolve, unverifiedRe
|
|
|
120
186
|
return null;
|
|
121
187
|
}
|
|
122
188
|
/** `orm apply <dir>` from a local checkout; every other subcommand sends no source. */
|
|
123
|
-
export async function exportLocalApplySource({ sub, auth, targetUrl, dir = '.', unverifiedReason, dryRun }) {
|
|
189
|
+
export async function exportLocalApplySource({ sub, auth, targetUrl, dir = '.', unverifiedReason, sourceEnvironment, dryRun }) {
|
|
124
190
|
if (sub !== 'apply' || !targetUrl)
|
|
125
191
|
return null;
|
|
126
|
-
|
|
192
|
+
// The clone's origin must be the Git Service that holds the source: the source environment's, when one is named.
|
|
193
|
+
const originUrl = sourceEnvironment?.url ?? targetUrl;
|
|
194
|
+
return exportApplySource({ auth, targetUrl, unverifiedReason, sourceEnvironment, dryRun, resolve: async () => localOrmApplySource({ dir, targetUrl: originUrl }) });
|
|
127
195
|
}
|
package/dist/orm/delegate.js
CHANGED
|
@@ -18,7 +18,7 @@ import { resolveFunctionSourceDir } from '../functions/source-selection.js';
|
|
|
18
18
|
import { warnBeforeHostDeploy } from '../manifest-roles-notice.js';
|
|
19
19
|
import { ORM_DEPLOYMENT_POLICY_HELP, ORM_DISCOVER_HELP, ORM_EXECUTE_HELP, ORM_HELP, ORM_HISTORY_HELP } from '../command-help.js';
|
|
20
20
|
import { ormVersionMismatch, requiresSchemaVersionCheck } from './version-guard.js';
|
|
21
|
-
import { exportApplySource, exportLocalApplySource, repoOrmApplySource,
|
|
21
|
+
import { exportApplySource, exportLocalApplySource, repoOrmApplySource, resolveOrmSourceEnvironment, SOURCE_ENV_WITH_REPO_ERROR, takeApplySourceFlags, } from './apply-source.js';
|
|
22
22
|
/**
|
|
23
23
|
* ORM subcommands that talk to Atlas — must not silently target `local`.
|
|
24
24
|
* `init`, `generate`, `validate`, `diff`, `migrate-from-yaml`, and `import` are offline.
|
|
@@ -114,7 +114,9 @@ function aliasOrmModuleForRemoteSource(envName) {
|
|
|
114
114
|
// error names the missing module.
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
async function runOrmFromRepo({ sub, selection, auth, targetUrl, ormCli, unverifiedReason, }) {
|
|
117
|
+
async function runOrmFromRepo({ sub, selection, auth, targetUrl, ormCli, unverifiedReason, sourceEnv, }) {
|
|
118
|
+
if (sourceEnv)
|
|
119
|
+
return failWith(SOURCE_ENV_WITH_REPO_ERROR);
|
|
118
120
|
if (!auth || !targetUrl) {
|
|
119
121
|
console.error('[seq-studio] orm --repo needs a target environment and auth. Pass -e <env> and run `seq-studio login`.');
|
|
120
122
|
return 1;
|
|
@@ -130,10 +132,8 @@ async function runOrmFromRepo({ sub, selection, auth, targetUrl, ormCli, unverif
|
|
|
130
132
|
...(selection.path !== undefined ? { path: selection.path } : {}),
|
|
131
133
|
});
|
|
132
134
|
const mismatch = await ormVersionMismatch(dir);
|
|
133
|
-
if (mismatch)
|
|
134
|
-
|
|
135
|
-
return 1;
|
|
136
|
-
}
|
|
135
|
+
if (mismatch)
|
|
136
|
+
return failWith(mismatch);
|
|
137
137
|
aliasOrmModuleForRemoteSource(ormCli.ORM_MODULE_PATH_ENV);
|
|
138
138
|
// A local apply authors any missing migration into the working tree for
|
|
139
139
|
// review. A clone is discarded, so an authored migration would be applied
|
|
@@ -147,10 +147,8 @@ async function runOrmFromRepo({ sub, selection, auth, targetUrl, ormCli, unverif
|
|
|
147
147
|
targetUrl, token: auth.token, namespace: selection.spec.namespace, name: selection.spec.name,
|
|
148
148
|
commit: source.provenance.gitCommit, path: selection.path,
|
|
149
149
|
}) }) : null;
|
|
150
|
-
if (refusal)
|
|
151
|
-
|
|
152
|
-
return 1;
|
|
153
|
-
}
|
|
150
|
+
if (refusal)
|
|
151
|
+
return failWith(refusal);
|
|
154
152
|
const args = [dir, ...selection.rest];
|
|
155
153
|
await warnBeforeHostDeploy({ sub, deploySub: 'apply', args, file: 'namespace.yaml' });
|
|
156
154
|
return await ormCli.runCli([sub, ...args]);
|
|
@@ -266,6 +264,10 @@ async function runOrmInitWithRepo(normalized) {
|
|
|
266
264
|
// The environment is for the repository setup; init itself is offline.
|
|
267
265
|
return runInitWithRepo({ args, target, scaffold: () => runOrmCommand('init', withoutEnvFlag(initArgv)) });
|
|
268
266
|
}
|
|
267
|
+
function failWith(message) {
|
|
268
|
+
console.error(`[seq-studio] ${message}`);
|
|
269
|
+
return 1;
|
|
270
|
+
}
|
|
269
271
|
export async function runOrmCommand(sub, rest) {
|
|
270
272
|
if (!sub || sub === 'help' || sub === '--help' || sub === '-h') {
|
|
271
273
|
console.log(ORM_USAGE);
|
|
@@ -273,12 +275,10 @@ export async function runOrmCommand(sub, rest) {
|
|
|
273
275
|
}
|
|
274
276
|
if (NATIVE_ORM_SUBS.has(sub))
|
|
275
277
|
return runNativeOrmCommand(sub, rest);
|
|
276
|
-
const
|
|
277
|
-
if ('error' in
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
const { reason: unverifiedReason, args: normalized } = unverified;
|
|
278
|
+
const flags = takeApplySourceFlags({ sub, argv: normalizeShortEnvFlag(rest) });
|
|
279
|
+
if ('error' in flags)
|
|
280
|
+
return failWith(flags.error);
|
|
281
|
+
const { unverifiedReason, sourceEnv, args: normalized } = flags;
|
|
282
282
|
const repoInit = sub === 'init' ? await runOrmInitWithRepo(normalized) : null;
|
|
283
283
|
if (repoInit !== null)
|
|
284
284
|
return repoInit;
|
|
@@ -290,18 +290,13 @@ export async function runOrmCommand(sub, rest) {
|
|
|
290
290
|
repoSelection = extractOrmRepoSelection(normalized);
|
|
291
291
|
}
|
|
292
292
|
catch (err) {
|
|
293
|
-
|
|
294
|
-
return 1;
|
|
295
|
-
}
|
|
296
|
-
if (repoSelection && !ORM_REPO_SUBS.has(sub)) {
|
|
297
|
-
console.error(`[seq-studio] --repo applies only to: ${[...ORM_REPO_SUBS].join(', ')}`);
|
|
298
|
-
return 1;
|
|
293
|
+
return failWith(err instanceof Error ? err.message : String(err));
|
|
299
294
|
}
|
|
295
|
+
if (repoSelection && !ORM_REPO_SUBS.has(sub))
|
|
296
|
+
return failWith(`--repo applies only to: ${[...ORM_REPO_SUBS].join(', ')}`);
|
|
300
297
|
const requested = explicitOrSandboxEnv(readEnvFromArgv(normalized));
|
|
301
|
-
if (ORM_NETWORK_SUBS.has(sub) && !requested)
|
|
302
|
-
|
|
303
|
-
return 1;
|
|
304
|
-
}
|
|
298
|
+
if (ORM_NETWORK_SUBS.has(sub) && !requested)
|
|
299
|
+
return failWith(REQUIRE_EXPLICIT_ENV_MESSAGE);
|
|
305
300
|
let targetUrl;
|
|
306
301
|
if (requested) {
|
|
307
302
|
const resolved = await resolveConfiguredEnv({ requested });
|
|
@@ -334,17 +329,18 @@ export async function runOrmCommand(sub, rest) {
|
|
|
334
329
|
}
|
|
335
330
|
});
|
|
336
331
|
if (repoSelection)
|
|
337
|
-
return runOrmFromRepo({ sub, selection: repoSelection, auth, targetUrl, ormCli, unverifiedReason });
|
|
338
|
-
return runLocalOrm({ sub, normalized, auth, targetUrl, unverifiedReason, runCli });
|
|
332
|
+
return runOrmFromRepo({ sub, selection: repoSelection, auth, targetUrl, ormCli, unverifiedReason, sourceEnv });
|
|
333
|
+
return runLocalOrm({ sub, normalized, auth, targetUrl, unverifiedReason, sourceEnv, runCli });
|
|
339
334
|
}
|
|
340
335
|
/** A namespace directory on disk: check its ORM version, attach the apply source, then forward. */
|
|
341
|
-
async function runLocalOrm({ sub, normalized, auth, targetUrl, unverifiedReason, runCli }) {
|
|
336
|
+
async function runLocalOrm({ sub, normalized, auth, targetUrl, unverifiedReason, sourceEnv, runCli }) {
|
|
337
|
+
const sourceEnvironment = sourceEnv ? await resolveOrmSourceEnvironment({ requested: sourceEnv }) : undefined;
|
|
338
|
+
if (sourceEnvironment && 'error' in sourceEnvironment)
|
|
339
|
+
return failWith(sourceEnvironment.error);
|
|
342
340
|
const problem = (requiresSchemaVersionCheck(sub) ? await ormVersionMismatch(positionalDir(normalized) ?? '.') : null) ??
|
|
343
|
-
await exportLocalApplySource({ sub, auth, targetUrl, dir: positionalDir(normalized), unverifiedReason, dryRun: normalized.includes('--dry-run') });
|
|
344
|
-
if (problem)
|
|
345
|
-
|
|
346
|
-
return 1;
|
|
347
|
-
}
|
|
341
|
+
await exportLocalApplySource({ sub, auth, targetUrl, dir: positionalDir(normalized), unverifiedReason, sourceEnvironment, dryRun: normalized.includes('--dry-run') });
|
|
342
|
+
if (problem)
|
|
343
|
+
return failWith(problem);
|
|
348
344
|
await warnBeforeHostDeploy({ sub, deploySub: 'apply', args: normalized, file: 'namespace.yaml' });
|
|
349
345
|
return runCli([sub, ...normalized]);
|
|
350
346
|
}
|
|
@@ -3,6 +3,8 @@ import { getJson, putJson } from '../atlas-client.js';
|
|
|
3
3
|
import { printCliError } from '../cli-errors.js';
|
|
4
4
|
import { requiredStringFlag, validateCommandInput } from '../command-input.js';
|
|
5
5
|
import { buildContext, clientOptions } from '../functions/commands.js';
|
|
6
|
+
import { getAccessTokenWithMode } from '../auth.js';
|
|
7
|
+
import { resolveConfiguredEnv } from '../config.js';
|
|
6
8
|
function repository(args) {
|
|
7
9
|
const repo = requiredStringFlag({ args, key: 'repo' }).split('/');
|
|
8
10
|
if (repo.length !== 2 || !repo[0] || !repo[1])
|
|
@@ -10,30 +12,39 @@ function repository(args) {
|
|
|
10
12
|
return { repositoryNamespace: repo[0], repositoryName: repo[1], branch: requiredStringFlag({ args, key: 'branch' }) };
|
|
11
13
|
}
|
|
12
14
|
function selection(args) {
|
|
13
|
-
validateCommandInput({ args, flags: { mode: 'string', repo: 'string', branch: 'string', target: 'string', path: 'string' }, positional: 1 });
|
|
15
|
+
validateCommandInput({ args, flags: { mode: 'string', repo: 'string', branch: 'string', target: 'string', path: 'string', 'source-env': 'string' }, positional: 1 });
|
|
14
16
|
const mode = args.flags.mode;
|
|
15
17
|
if (mode !== undefined && mode !== 'manual' && mode !== 'ci' && mode !== 'source')
|
|
16
18
|
throw new Error('--mode must be manual, ci or source.');
|
|
17
19
|
if (mode === undefined || mode === 'manual') {
|
|
18
|
-
if (['repo', 'branch', 'target', 'path'].some(key => args.flags[key] !== undefined))
|
|
19
|
-
throw new Error('--repo, --branch, --target and --
|
|
20
|
+
if (['repo', 'branch', 'target', 'path', 'source-env'].some(key => args.flags[key] !== undefined))
|
|
21
|
+
throw new Error('--repo, --branch, --target, --path and --source-env require --mode ci or source.');
|
|
20
22
|
return { mode };
|
|
21
23
|
}
|
|
22
24
|
if (mode === 'ci') {
|
|
23
|
-
if (args.flags.path !== undefined)
|
|
24
|
-
throw new Error('--path
|
|
25
|
+
if (args.flags.path !== undefined || args.flags['source-env'] !== undefined)
|
|
26
|
+
throw new Error('--path and --source-env apply only to --mode source.');
|
|
25
27
|
return { mode, ...repository(args), target: requiredStringFlag({ args, key: 'target' }) };
|
|
26
28
|
}
|
|
27
29
|
if (args.flags.target !== undefined)
|
|
28
30
|
throw new Error('--target applies only to --mode ci.');
|
|
29
|
-
|
|
31
|
+
const sourceEnv = args.flags['source-env'];
|
|
32
|
+
return { mode, ...repository(args), path: requiredStringFlag({ args, key: 'path' }), ...(typeof sourceEnv === 'string' ? { sourceEnv } : {}) };
|
|
30
33
|
}
|
|
31
34
|
function describe(policy) {
|
|
32
35
|
if (policy.mode === 'manual')
|
|
33
36
|
return 'manual deployment';
|
|
34
37
|
if (policy.mode === 'ci')
|
|
35
38
|
return `CI-managed (${policy.repository_id}, ${policy.branch}, ${policy.target_key})`;
|
|
36
|
-
|
|
39
|
+
const repository = policy.source_environment ? `${policy.source_environment}'s ${policy.repository_id}` : policy.repository_id;
|
|
40
|
+
return `direct applies only from ${policy.branch}:${policy.path === '' ? '.' : policy.path} in ${repository}, verified by Atlas`;
|
|
41
|
+
}
|
|
42
|
+
async function sourceEnvironmentClient(requested) {
|
|
43
|
+
const env = await resolveConfiguredEnv({ requested });
|
|
44
|
+
const auth = await getAccessTokenWithMode({ env: env.name, targetUrl: env.url });
|
|
45
|
+
if (auth.authMode === 'sandbox')
|
|
46
|
+
throw new Error(`--source-env ${env.name} needs your own sign-in there: run seq-studio login -e ${env.name}`);
|
|
47
|
+
return { name: env.name, options: { baseUrl: env.url, token: auth.token } };
|
|
37
48
|
}
|
|
38
49
|
export async function ormDeploymentPolicyCommand(args) {
|
|
39
50
|
try {
|
|
@@ -45,12 +56,18 @@ export async function ormDeploymentPolicyCommand(args) {
|
|
|
45
56
|
result = await getJson({ ...options, path });
|
|
46
57
|
else if (!('repositoryNamespace' in selected))
|
|
47
58
|
result = await putJson({ ...options, path, body: { mode: 'manual' } });
|
|
48
|
-
else {
|
|
59
|
+
else if (selected.mode === 'ci') {
|
|
49
60
|
const repositoryId = (await resolveRepo({ ...options, namespace: selected.repositoryNamespace, name: selected.repositoryName })).id;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
61
|
+
result = await putJson({ ...options, path, body: { mode: 'ci', repository_id: repositoryId, branch: selected.branch, target_key: selected.target } });
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// A source in another environment is found there, with the caller's own token, which Atlas uses to confirm read access.
|
|
65
|
+
const source = selected.sourceEnv ? await sourceEnvironmentClient(selected.sourceEnv) : null;
|
|
66
|
+
const repositoryId = (await resolveRepo({ ...(source?.options ?? options), namespace: selected.repositoryNamespace, name: selected.repositoryName })).id;
|
|
67
|
+
const body = { mode: 'source', repository_id: repositoryId, branch: selected.branch, path: selected.path,
|
|
68
|
+
...(source ? { source_environment: source.name } : {}) };
|
|
69
|
+
result = await putJson({ ...options, path, body,
|
|
70
|
+
...(source ? { headers: { 'x-sequence-source-authorization': `Bearer ${source.options.token}` } } : {}) });
|
|
54
71
|
}
|
|
55
72
|
if (args.flags.json === true)
|
|
56
73
|
console.log(JSON.stringify(result, null, 2));
|
package/dist/orm/help.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ORM_USAGE = "usage:\n seq-studio orm init <dir> [--repo <ns>/<name>]\n scaffold a namespace package (v2: TypeScript schema + GraphQL documents);\n --repo scaffolds into a git-service repo (see Init into a repo below)\n seq-studio orm generate [dir] write schema.graphql + operations.manifest.json + typePolicies.gen.ts (offline; runs consumer codegen when codegen.ts is present)\n seq-studio orm generate [dir] --migration-export [--check]\n export reviewed ORM inputs for a coordinated pipeline migration; --check verifies without writing\n seq-studio orm validate [dir] parse + validate definitions and verify committed migrations are in sync\n seq-studio orm plan [dir] -e <env> compile definitions and diff against the registry\n seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait] [--unverified-source \"<reason>\"]\n author the migration, register, apply, and refresh the generated outputs (the everyday command);\n waits until the new version is live (default up to 20m; e.g. --timeout 90s), --no-wait returns once queued\n seq-studio orm plan|apply --repo <ns>/<name> [--path <dir>] [--ref <ref>] -e <env>\n plan/apply a namespace committed to a platform git-service repo (CI deploy-from-git);\n --path selects the namespace directory (default: repo root). A remote apply never\n authors migrations: the committed ledger must already match the definitions.\n seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...\n run the deployed version's persisted operation by name as the caller (no checkout)\n seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>\n execute from the checkout manifest through the installed ORM package\n both execute forms accept --variables-file - (or /dev/stdin) for JSON stdin until EOF\n seq-studio orm read <namespace> <table> -e <env> [--where c=op.v]... [--select c,...] [--order c.desc] [--limit N] [--offset N] [--json|--jsonl]\n read rows of a deployed v2 namespace as the caller (row-level security applies)\n seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param name[:type]=v]... | [--params <json-object>] [--json|--jsonl]\n run read-only SQL against a deployed v2 namespace as the caller\n qualify tables and double-quote mixed-case columns (e.g. SELECT \"loanNumber\" FROM lending.loans)\n seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]\n list the namespaces you can read\n seq-studio orm history <namespace> -e <env> [--limit N] [--json]\n seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci|source] [--repo <ns>/<name> --branch <branch> (--target <target-key> | --path <dir>)] [--json]\n inspect or explicitly change the namespace's deployment controller\n seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]\n show a namespace's tables, views, and persisted operations (with variables), or one table's columns and actions\n 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)\n seq-studio orm migrate-from-yaml <dir> convert a v1 YAML namespace to the v2 TypeScript format (offline; migrations/ preserved)\n seq-studio orm import [dir] --spec <file> | --table <t> --from <schema.table> --map <target=source,...>\n plan a batched copy from an existing Postgres relation into an owned table (writes a SQL script; no database connection)\n\n Environments: see `seq-studio envs list` (built-in: local; more are\n discovered after you authenticate).\n Authenticate with: seq-studio login\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";
|
|
1
|
+
export declare const ORM_USAGE = "usage:\n seq-studio orm init <dir> [--repo <ns>/<name>]\n scaffold a namespace package (v2: TypeScript schema + GraphQL documents);\n --repo scaffolds into a git-service repo (see Init into a repo below)\n seq-studio orm generate [dir] write schema.graphql + operations.manifest.json + typePolicies.gen.ts (offline; runs consumer codegen when codegen.ts is present)\n seq-studio orm generate [dir] --migration-export [--check]\n export reviewed ORM inputs for a coordinated pipeline migration; --check verifies without writing\n seq-studio orm validate [dir] parse + validate definitions and verify committed migrations are in sync\n seq-studio orm plan [dir] -e <env> compile definitions and diff against the registry\n seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait] [--unverified-source \"<reason>\"] [--source-env <env>]\n author the migration, register, apply, and refresh the generated outputs (the everyday command);\n waits until the new version is live (default up to 20m; e.g. --timeout 90s), --no-wait returns once queued\n seq-studio orm plan|apply --repo <ns>/<name> [--path <dir>] [--ref <ref>] -e <env>\n plan/apply a namespace committed to a platform git-service repo (CI deploy-from-git);\n --path selects the namespace directory (default: repo root). A remote apply never\n authors migrations: the committed ledger must already match the definitions.\n seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...\n run the deployed version's persisted operation by name as the caller (no checkout)\n seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>\n execute from the checkout manifest through the installed ORM package\n both execute forms accept --variables-file - (or /dev/stdin) for JSON stdin until EOF\n seq-studio orm read <namespace> <table> -e <env> [--where c=op.v]... [--select c,...] [--order c.desc] [--limit N] [--offset N] [--json|--jsonl]\n read rows of a deployed v2 namespace as the caller (row-level security applies)\n seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param name[:type]=v]... | [--params <json-object>] [--json|--jsonl]\n run read-only SQL against a deployed v2 namespace as the caller\n qualify tables and double-quote mixed-case columns (e.g. SELECT \"loanNumber\" FROM lending.loans)\n seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]\n list the namespaces you can read\n seq-studio orm history <namespace> -e <env> [--limit N] [--json]\n seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci|source] [--repo <ns>/<name> --branch <branch> (--target <target-key> | --path <dir>)] [--json]\n inspect or explicitly change the namespace's deployment controller\n seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]\n show a namespace's tables, views, and persisted operations (with variables), or one table's columns and actions\n 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)\n seq-studio orm migrate-from-yaml <dir> convert a v1 YAML namespace to the v2 TypeScript format (offline; migrations/ preserved)\n seq-studio orm import [dir] --spec <file> | --table <t> --from <schema.table> --map <target=source,...>\n plan a batched copy from an existing Postgres relation into an owned table (writes a SQL script; no database connection)\n\n Environments: see `seq-studio envs list` (built-in: local; more are\n discovered after you authenticate).\n Authenticate with: seq-studio login\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";
|
package/dist/orm/help.js
CHANGED
|
@@ -8,7 +8,7 @@ export const ORM_USAGE = `usage:
|
|
|
8
8
|
export reviewed ORM inputs for a coordinated pipeline migration; --check verifies without writing
|
|
9
9
|
seq-studio orm validate [dir] parse + validate definitions and verify committed migrations are in sync
|
|
10
10
|
seq-studio orm plan [dir] -e <env> compile definitions and diff against the registry
|
|
11
|
-
seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait] [--unverified-source "<reason>"]
|
|
11
|
+
seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait] [--unverified-source "<reason>"] [--source-env <env>]
|
|
12
12
|
author the migration, register, apply, and refresh the generated outputs (the everyday command);
|
|
13
13
|
waits until the new version is live (default up to 20m; e.g. --timeout 90s), --no-wait returns once queued
|
|
14
14
|
seq-studio orm plan|apply --repo <ns>/<name> [--path <dir>] [--ref <ref>] -e <env>
|
package/dist/orm/history.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export interface ActivationRow {
|
|
|
6
6
|
operation_set_id: string | null;
|
|
7
7
|
provenance_class: 'repository_verified' | 'ci_intent' | 'reported';
|
|
8
8
|
source_repository_id: string | null;
|
|
9
|
+
/** Absent on an older Atlas; null for this deployment's own Git Service. */
|
|
10
|
+
source_environment?: string | null;
|
|
9
11
|
source_commit: string | null;
|
|
10
12
|
source_branch: string | null;
|
|
11
13
|
source_path: string | null;
|
package/dist/orm/history.js
CHANGED
|
@@ -21,7 +21,7 @@ export function formatActivation({ row, active }) {
|
|
|
21
21
|
const claimed = row.reported_source;
|
|
22
22
|
const where = row.provenance_class === 'reported'
|
|
23
23
|
? `reported${typeof claimed?.commit === 'string' ? ` ${claimed.commit.slice(0, 12)}` : ''}${typeof claimed?.verification_failure === 'string' ? ` (${claimed.verification_failure})` : ''}`
|
|
24
|
-
: `${row.provenance_class === 'ci_intent' ? 'ci' : 'verified'} ${row.source_commit?.slice(0, 12)} on ${row.source_branch} at ${row.source_path === '' ? '.' : row.source_path}`;
|
|
24
|
+
: `${row.provenance_class === 'ci_intent' ? 'ci' : 'verified'} ${row.source_commit?.slice(0, 12)} on ${row.source_environment ? `${row.source_environment}:` : ''}${row.source_branch} at ${row.source_path === '' ? '.' : row.source_path}`;
|
|
25
25
|
return `${active ? '*' : ' '} ${row.activated_at.slice(0, 19).replace('T', ' ')}Z ${what.padEnd(28)} ${actor.padEnd(32)} ${where}`;
|
|
26
26
|
}
|
|
27
27
|
export async function ormHistoryCommand(args) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sequenceholdings/studio-cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.16",
|
|
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": {
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
"yaml": "^2.8.4",
|
|
46
46
|
"zod": "4.6.6",
|
|
47
47
|
"@sequenceholdings/agent-spec": "0.1.5",
|
|
48
|
+
"@sequenceholdings/artifact-studio": "0.11.15",
|
|
48
49
|
"@sequenceholdings/lattice": "0.1.8",
|
|
49
|
-
"@sequenceholdings/managed-functions": "0.5.
|
|
50
|
-
"@sequenceholdings/artifact-studio": "0.11.14",
|
|
50
|
+
"@sequenceholdings/managed-functions": "0.5.11",
|
|
51
51
|
"@sequenceholdings/storage": "0.1.7",
|
|
52
52
|
"@sequenceholdings/platform": "0.1.4"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@sequenceholdings/
|
|
56
|
-
"@sequenceholdings/
|
|
55
|
+
"@sequenceholdings/orm": "2.10.0",
|
|
56
|
+
"@sequenceholdings/pipeline-spec": "0.3.10"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|
|
59
59
|
"@sequenceholdings/orm": {
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"@types/semver": "^7.8.0",
|
|
70
70
|
"typescript": "^5.6.0",
|
|
71
71
|
"vitest": "^4.1.12",
|
|
72
|
-
"@sequenceholdings/orm": "2.
|
|
73
|
-
"@sequenceholdings/pipeline-spec": "0.3.
|
|
72
|
+
"@sequenceholdings/orm": "2.10.0",
|
|
73
|
+
"@sequenceholdings/pipeline-spec": "0.3.10"
|
|
74
74
|
},
|
|
75
75
|
"engines": {
|
|
76
76
|
"node": ">=20"
|