@sequenceholdings/studio-cli 0.9.24 → 0.9.26
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 +14 -2
- package/dist/app-preview/commands.d.ts +7 -0
- package/dist/app-preview/commands.js +264 -0
- package/dist/app-preview/fingerprint.d.ts +20 -0
- package/dist/app-preview/fingerprint.js +32 -0
- package/dist/app-preview/install.d.ts +31 -0
- package/dist/app-preview/install.js +53 -0
- package/dist/app-preview/namespace-probe.d.ts +13 -0
- package/dist/app-preview/namespace-probe.js +50 -0
- package/dist/app-preview/plan.d.ts +28 -0
- package/dist/app-preview/plan.js +41 -0
- package/dist/app-preview/run.d.ts +32 -0
- package/dist/app-preview/run.js +48 -0
- package/dist/app-preview/runners.d.ts +73 -0
- package/dist/app-preview/runners.js +226 -0
- package/dist/app-preview/secrets.d.ts +48 -0
- package/dist/app-preview/secrets.js +104 -0
- package/dist/app-preview/target.d.ts +28 -0
- package/dist/app-preview/target.js +62 -0
- package/dist/artifact/delegate.d.ts +0 -11
- package/dist/artifact/delegate.js +6 -127
- package/dist/artifact/sandbox.js +1 -1
- package/dist/auth.js +1 -3
- package/dist/command-help.d.ts +3 -3
- package/dist/command-help.js +7 -3
- package/dist/config.d.ts +0 -7
- package/dist/config.js +0 -12
- package/dist/edge-auth-headers.js +1 -18
- package/dist/functions/commands.d.ts +15 -0
- package/dist/functions/commands.js +67 -11
- package/dist/main.js +1 -1
- package/dist/registry/lifecycle-commands.js +7 -0
- package/dist/repos/commands.d.ts +1 -4
- package/dist/repos/commands.js +2 -19
- package/dist/templates/catalog.d.ts +1 -1
- package/dist/templates/catalog.js +1 -1
- package/package.json +10 -10
- package/release-summary.json +3 -1
- package/dist/preview.d.ts +0 -90
- package/dist/preview.js +0 -292
|
@@ -22,7 +22,6 @@ import { getAccessTokenWithMode, tryGetAccessTokenWithMode } from '../auth.js';
|
|
|
22
22
|
import { ARTIFACT_SANDBOX_HELP, INIT_INTO_REPO_HELP } from '../command-help.js';
|
|
23
23
|
import { readConfig, resolveConfiguredEnv } from '../config.js';
|
|
24
24
|
import { normalizeShortEnvFlag, readEnvFromArgv, withoutEnvFlag } from '../env-flags.js';
|
|
25
|
-
import { PREVIEW_DOMAIN, PREVIEW_PROJECT, resolvePreviewByPr } from '../preview.js';
|
|
26
25
|
import { sandboxTarget } from '../sandbox-auth.js';
|
|
27
26
|
import { runSandboxArtifactCommand } from './sandbox.js';
|
|
28
27
|
const ARTIFACT_USAGE = `usage:
|
|
@@ -82,14 +81,6 @@ const ARTIFACT_USAGE = `usage:
|
|
|
82
81
|
capability workspace IDs against -e. It does not scan source text or arbitrary
|
|
83
82
|
config values for URLs or UUIDs. Repository identity checks still apply.
|
|
84
83
|
|
|
85
|
-
Per-PR preview environments (https://studio-atlas-git-<slug>.preview.seqholdings.com):
|
|
86
|
-
-e preview:<branch-or-slug> compute the preview host from a branch name
|
|
87
|
-
--pr <number> resolve the preview host from a PR (handles long slugs)
|
|
88
|
-
--env-url <url> target an explicit preview URL (escape hatch)
|
|
89
|
-
|
|
90
|
-
Preview deploys sit behind a Cloudflare WAF gate. Off the company network/VPN,
|
|
91
|
-
set PREVIEW_ACCESS_HEADER=<secret> and the CLI sends it as x-preview-access.
|
|
92
|
-
|
|
93
84
|
Authenticate with: seq-studio login
|
|
94
85
|
|
|
95
86
|
${INIT_INTO_REPO_HELP}
|
|
@@ -158,40 +149,19 @@ export async function runArtifactCommand(sub, rest) {
|
|
|
158
149
|
// artifact plan -e staging` would land `-e` as positional and
|
|
159
150
|
// `staging` as the next positional, with `flags.env` undefined.
|
|
160
151
|
const normalizedRest = normalizeShortEnvFlag(rest);
|
|
161
|
-
// Pull off seq-studio-only preview flags (`--pr`, `--env-url`) so they're not
|
|
162
|
-
// forwarded to artifact-studio (its parser would store them as stray flags).
|
|
163
|
-
const { rest: forwardRest, prNumber, envUrl } = extractPreviewFlags(normalizedRest);
|
|
164
152
|
// Resolve --env if present so we can map to lattice config URLs. We
|
|
165
153
|
// pull from the cleaned argv so both `-e` and `--env` paths work.
|
|
166
|
-
const requested = readEnvFromArgv(
|
|
154
|
+
const requested = readEnvFromArgv(normalizedRest);
|
|
167
155
|
let resolved;
|
|
168
|
-
let argvForCli =
|
|
169
|
-
if (
|
|
170
|
-
const validated = validatePreviewEnvUrl(envUrl);
|
|
171
|
-
// Explicit override wins over everything. Keep the user's --env name if
|
|
172
|
-
// they gave one, else label it `preview`.
|
|
173
|
-
resolved = { name: requested ?? 'preview', url: validated };
|
|
174
|
-
argvForCli = ensureEnvFlag(forwardRest, resolved.name);
|
|
175
|
-
}
|
|
176
|
-
else if (prNumber !== undefined) {
|
|
177
|
-
const preview = await resolvePreviewByPr({ pr: prNumber });
|
|
178
|
-
resolved = { name: `preview:${preview.slug}`, url: preview.url };
|
|
179
|
-
argvForCli = ensureEnvFlag(forwardRest, resolved.name);
|
|
180
|
-
}
|
|
181
|
-
else if (requested) {
|
|
156
|
+
let argvForCli = normalizedRest;
|
|
157
|
+
if (requested) {
|
|
182
158
|
resolved = await resolveConfiguredEnv({ requested });
|
|
183
|
-
//
|
|
159
|
+
// Forward the canonical name when resolution normalized the requested one.
|
|
184
160
|
if (resolved.name !== requested)
|
|
185
|
-
argvForCli = ensureEnvFlag(
|
|
161
|
+
argvForCli = ensureEnvFlag(normalizedRest, resolved.name);
|
|
186
162
|
}
|
|
187
|
-
if (resolved)
|
|
163
|
+
if (resolved)
|
|
188
164
|
process.env['ARTIFACT_STUDIO_BASE_URL'] = resolved.url;
|
|
189
|
-
// When targeting a preview host, thread the Cloudflare WAF bypass header so
|
|
190
|
-
// deploys work off the company network/VPN (mirrors atlas-ui-shot). Harmless
|
|
191
|
-
// on built-in envs, so we only gate it on the host actually being a preview.
|
|
192
|
-
if (isPreviewUrl(resolved.url))
|
|
193
|
-
applyPreviewAccessHeader();
|
|
194
|
-
}
|
|
195
165
|
// Always hand artifact-studio the configured env map (config.toml +
|
|
196
166
|
// registered deployments). Commands that resolve an env *name*
|
|
197
167
|
// without an explicit --env flag — the stored `.artifact-studio/config.json`
|
|
@@ -232,41 +202,6 @@ function artifactCredential(auth) {
|
|
|
232
202
|
throw new Error('Sandbox tokens reach Artifact Studio only in sandbox token mode.');
|
|
233
203
|
return { authMode: auth.authMode, token: auth.token };
|
|
234
204
|
}
|
|
235
|
-
/**
|
|
236
|
-
* Strip the seq-studio-only `--pr <number>` and `--env-url <url>` flags from
|
|
237
|
-
* argv and return the rest (forwarded to artifact-studio) plus the parsed
|
|
238
|
-
* values. These never reach artifact-studio — they're consumed here to resolve
|
|
239
|
-
* the preview base URL.
|
|
240
|
-
*/
|
|
241
|
-
export function extractPreviewFlags(argv) {
|
|
242
|
-
const rest = [];
|
|
243
|
-
let prNumber;
|
|
244
|
-
let envUrl;
|
|
245
|
-
for (let i = 0; i < argv.length; i++) {
|
|
246
|
-
const arg = argv[i];
|
|
247
|
-
if (arg === undefined)
|
|
248
|
-
continue;
|
|
249
|
-
const [flag, inlineValue] = splitInlineValue(arg);
|
|
250
|
-
if (flag === '--pr') {
|
|
251
|
-
const value = inlineValue ?? takeValue(argv, i, () => (i += 1));
|
|
252
|
-
const parsed = Number(value);
|
|
253
|
-
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
254
|
-
throw new Error(`--pr requires a positive integer (got "${value ?? ''}").`);
|
|
255
|
-
}
|
|
256
|
-
prNumber = parsed;
|
|
257
|
-
}
|
|
258
|
-
else if (flag === '--env-url') {
|
|
259
|
-
const value = inlineValue ?? takeValue(argv, i, () => (i += 1));
|
|
260
|
-
if (!value)
|
|
261
|
-
throw new Error('--env-url requires a URL value.');
|
|
262
|
-
envUrl = value;
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
rest.push(arg);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
return { rest, prNumber, envUrl };
|
|
269
|
-
}
|
|
270
205
|
function splitInlineValue(arg) {
|
|
271
206
|
const eq = arg.indexOf('=');
|
|
272
207
|
if (arg.startsWith('--') && eq !== -1)
|
|
@@ -305,48 +240,6 @@ function ensureEnvFlag(argv, name) {
|
|
|
305
240
|
out.push('--env', name);
|
|
306
241
|
return out;
|
|
307
242
|
}
|
|
308
|
-
function stripTrailingSlash(url) {
|
|
309
|
-
return url.replace(/\/+$/, '');
|
|
310
|
-
}
|
|
311
|
-
function validatePreviewEnvUrl(value) {
|
|
312
|
-
const trimmed = stripTrailingSlash(value.trim());
|
|
313
|
-
let parsed;
|
|
314
|
-
try {
|
|
315
|
-
parsed = new URL(trimmed);
|
|
316
|
-
}
|
|
317
|
-
catch {
|
|
318
|
-
throw new Error(`--env-url must be a valid URL (got "${value}").`);
|
|
319
|
-
}
|
|
320
|
-
if (parsed.username || parsed.password) {
|
|
321
|
-
throw new Error('--env-url must not include a username/password component.');
|
|
322
|
-
}
|
|
323
|
-
if (parsed.protocol !== 'https:') {
|
|
324
|
-
throw new Error(`--env-url must be an https preview URL on *.${PREVIEW_DOMAIN} (got "${parsed.protocol}//").`);
|
|
325
|
-
}
|
|
326
|
-
if (parsed.pathname !== '' && parsed.pathname !== '/') {
|
|
327
|
-
throw new Error('--env-url must be an origin URL without a path component.');
|
|
328
|
-
}
|
|
329
|
-
if (parsed.search || parsed.hash) {
|
|
330
|
-
throw new Error('--env-url must not include querystring or hash components.');
|
|
331
|
-
}
|
|
332
|
-
const host = parsed.hostname.toLowerCase();
|
|
333
|
-
if (!host.endsWith(`.${PREVIEW_DOMAIN}`)) {
|
|
334
|
-
throw new Error(`--env-url must be an https preview URL on *.${PREVIEW_DOMAIN} (got "${parsed.hostname}").`);
|
|
335
|
-
}
|
|
336
|
-
const expectedPrefix = `${PREVIEW_PROJECT}-git-`;
|
|
337
|
-
if (!host.startsWith(expectedPrefix)) {
|
|
338
|
-
throw new Error(`--env-url must target a ${PREVIEW_PROJECT} preview alias (expected host starting with "${expectedPrefix}", got "${parsed.hostname}").`);
|
|
339
|
-
}
|
|
340
|
-
return parsed.origin;
|
|
341
|
-
}
|
|
342
|
-
function isPreviewUrl(url) {
|
|
343
|
-
try {
|
|
344
|
-
return new URL(url).hostname.endsWith(`.${PREVIEW_DOMAIN}`);
|
|
345
|
-
}
|
|
346
|
-
catch {
|
|
347
|
-
return false;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
243
|
/** Subcommands whose first positional is the local application directory (artifact-studio's `[dir]`). */
|
|
351
244
|
const DIRECTORY_SUBCOMMANDS = new Set(['validate', 'build', 'plan', 'deploy', 'dev']);
|
|
352
245
|
/**
|
|
@@ -382,17 +275,3 @@ function applyBreakGlassHeader() {
|
|
|
382
275
|
}
|
|
383
276
|
process.env['ARTIFACT_STUDIO_EXTRA_HEADERS'] = JSON.stringify({ ...existing, [BREAK_GLASS_HEADER]: reason });
|
|
384
277
|
}
|
|
385
|
-
/**
|
|
386
|
-
* Thread the Cloudflare WAF bypass header through artifact-studio's HTTP client
|
|
387
|
-
* via ARTIFACT_STUDIO_EXTRA_HEADERS (read in artifact-studio/src/api.ts). Reads
|
|
388
|
-
* the secret from PREVIEW_ACCESS_HEADER — the same env var atlas-ui-shot uses.
|
|
389
|
-
* No-op when the secret isn't set (engineer is expected to be on the VPN).
|
|
390
|
-
*/
|
|
391
|
-
function applyPreviewAccessHeader() {
|
|
392
|
-
const secret = process.env['PREVIEW_ACCESS_HEADER']?.trim();
|
|
393
|
-
if (!secret)
|
|
394
|
-
return;
|
|
395
|
-
process.env['ARTIFACT_STUDIO_EXTRA_HEADERS'] = JSON.stringify({
|
|
396
|
-
'x-preview-access': secret,
|
|
397
|
-
});
|
|
398
|
-
}
|
package/dist/artifact/sandbox.js
CHANGED
|
@@ -26,7 +26,7 @@ const SANDBOX_REFUSED_COMMANDS = {
|
|
|
26
26
|
logout: 'Atlas supplies the sandbox token, so there is no login.',
|
|
27
27
|
};
|
|
28
28
|
/** Flags that reach a source or deployment other than the sandbox's one Atlas origin. */
|
|
29
|
-
const SANDBOX_REFUSED_FLAGS = ['--git-url', '--source-env'
|
|
29
|
+
const SANDBOX_REFUSED_FLAGS = ['--git-url', '--source-env'];
|
|
30
30
|
/** Commands whose source is a build; in a sandbox it must come from a Git Service repository. */
|
|
31
31
|
const SANDBOX_REPOSITORY_COMMANDS = new Set(['build', 'plan', 'deploy']);
|
|
32
32
|
/** Commands that take no --env, so the sandbox environment is not added to their argv. */
|
package/dist/auth.js
CHANGED
|
@@ -88,9 +88,7 @@ export function isSequenceAuthEnvName(envName) {
|
|
|
88
88
|
return (envName === SEQUENCE_REALM ||
|
|
89
89
|
SEQUENCE_BUILTIN_ENVS.has(envName) ||
|
|
90
90
|
envName === 'worktree' ||
|
|
91
|
-
envName.startsWith('local:')
|
|
92
|
-
envName === 'preview' ||
|
|
93
|
-
envName.startsWith('preview:'));
|
|
91
|
+
envName.startsWith('local:'));
|
|
94
92
|
}
|
|
95
93
|
// Both hostnames terminate at Sequence's one Auth0 tenant. Keep this explicit:
|
|
96
94
|
// discovery must never be able to select an arbitrary credential recipient.
|
package/dist/command-help.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ export declare const ORM_HISTORY_HELP = "usage:\n seq-studio orm history <names
|
|
|
5
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
6
|
export declare const ORM_HELP = "usage:\n seq-studio orm init <dir> [--repo <ns>/<name>]\n seq-studio orm build [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 run <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...\n seq-studio orm run <operation> [dir] --variables-file <file> -e <env>\n seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]\n seq-studio orm show <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 show --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 run --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
|
-
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
|
|
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
|
|
10
|
-
export declare const FUNCTIONS_USAGE = "usage:\n seq-studio function 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 function build [--dir d] local pre-flight (manifest, lockfile, SDK timeout cap)\n seq-studio function register -e <env> [--dir d] register a shell + initial secret declarations; no deploy\n seq-studio function deploy -e <env> [-m msg] preflight, upload, then show version and lifecycle progress\n seq-studio function list -e <env> [--match-local] functions visible on the environment\n seq-studio function 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 function limits [-e <env>] [--json] bundled defaults/caps, or deployed policy\n [--fn slug] also show effective runtime limits (requires -e)\n seq-studio function dev [--dir path] [--port 8080] local HTTP server with cache context\n seq-studio function run -e <env> [--data JSON | --data @file | --stdin]\n invoke a function and print its response\n seq-studio function logs -e <env> [--limit N] [--since t] function logs (reader-gated)\n seq-studio function promote <version> -e <env> [--fn <slug>]\n make a version live\n seq-studio function rollback [<version>] -e <env> [--fn <slug>]\n redeploy a prior version\n seq-studio function delete -e <env> [--fn <slug>] [--yes]\n archive function + tear down its runtime\n (version history is retained)\n\n Flags: -e/--env <env
|
|
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 and --source-env are unavailable there, and\n -e is ignored.\n";
|
|
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 and --source-env are unavailable there, and\n -e is ignored.\n";
|
|
10
|
+
export declare const FUNCTIONS_USAGE = "usage:\n seq-studio function 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 function build [--dir d] local pre-flight (manifest, lockfile, SDK timeout cap)\n seq-studio function register -e <env> [--dir d] register a shell + initial secret declarations; no deploy\n seq-studio function deploy -e <env> [-m msg] preflight, upload, then show version and lifecycle progress\n seq-studio function list -e <env> [--match-local] functions visible on the environment\n seq-studio function 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 function limits [-e <env>] [--json] bundled defaults/caps, or deployed policy\n [--fn slug] also show effective runtime limits (requires -e)\n seq-studio function dev [--dir path] [--port 8080] local HTTP server with cache context\n seq-studio function run -e <env> [--data JSON | --data @file | --stdin]\n invoke a function and print its response\n seq-studio function logs -e <env> [--limit N] [--since t] function logs (reader-gated)\n seq-studio function promote <version> -e <env> [--fn <slug>]\n make a version live\n seq-studio function rollback [<version>] -e <env> [--fn <slug>]\n redeploy a prior version\n seq-studio function delete -e <env> [--fn <slug>] [--yes]\n archive function + tear down its runtime\n (version history is retained)\n\n Flags: -e/--env <env> (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 --adopt (deploy, local Atlas only) take over a function that a database fork copied from\n another runtime, so it deploys and runs here under its own slug. Refused unless\n the local Atlas runs on a personal development database branch. The runtime the\n function was copied from is not contacted or changed.\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";
|
|
11
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 a failed clone leaves no partial checkout\n seq-studio repos attach-login [dir] -e <env> [--remote origin] bind the login credential helper to an\n existing checkout (plain git clone, or\n after an upgrade moved seq-studio)\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|edit|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";
|
|
12
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";
|
|
13
13
|
export declare const ORM_DISCOVER_HELP = "usage:\n seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]\n seq-studio orm show <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
|
@@ -93,8 +93,8 @@ export const ARTIFACT_SANDBOX_HELP = ` In an agent sandbox (SEQ_STUDIO_BASE_URL
|
|
|
93
93
|
from it. Atlas builds Next.js applications; static applications are bundled
|
|
94
94
|
from the repository and must declare no package.json dependencies or
|
|
95
95
|
optionalDependencies, because the sandbox cannot reach a package registry.
|
|
96
|
-
dev, login, logout, --git-url
|
|
97
|
-
|
|
96
|
+
dev, login, logout, --git-url and --source-env are unavailable there, and
|
|
97
|
+
-e is ignored.
|
|
98
98
|
`;
|
|
99
99
|
export const ARTIFACT_HELP = `usage:
|
|
100
100
|
seq-studio artifact init <dir> [--template react-vite|nextjs] [--repo <namespace>/<name>]
|
|
@@ -142,13 +142,17 @@ export const FUNCTIONS_USAGE = `usage:
|
|
|
142
142
|
archive function + tear down its runtime
|
|
143
143
|
(version history is retained)
|
|
144
144
|
|
|
145
|
-
Flags: -e/--env <env
|
|
145
|
+
Flags: -e/--env <env> (required for network commands; see: seq-studio envs list) · --fn <slug> · --dir <path>
|
|
146
146
|
--fn selects a deployed function without a local manifest; otherwise the manifest in --dir (default .) supplies its slug
|
|
147
147
|
--path <repo-subdirectory> (remote build/deploy only) select one function in a multi-function repo
|
|
148
148
|
--from-env-file <path> (default: .env) source file for secret values
|
|
149
149
|
--no-wait · --yes
|
|
150
150
|
--no-provision (deploy) update-only: error instead of registering a new
|
|
151
151
|
shell, writing secret values, or attaching secrets (CI sweep)
|
|
152
|
+
--adopt (deploy, local Atlas only) take over a function that a database fork copied from
|
|
153
|
+
another runtime, so it deploys and runs here under its own slug. Refused unless
|
|
154
|
+
the local Atlas runs on a personal development database branch. The runtime the
|
|
155
|
+
function was copied from is not contacted or changed.
|
|
152
156
|
|
|
153
157
|
Local Atlas builds and runs deployed functions on this computer, including teardown.
|
|
154
158
|
"functions dev" runs a standalone handler without Atlas registration.
|
package/dist/config.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { type CliOrg, type OrgRegistry } from './orgs.js';
|
|
2
|
-
/**
|
|
3
|
-
* `--env preview:<branch-or-slug>` targets a per-PR Vercel preview deployment
|
|
4
|
-
* without a config.toml entry. The slug after the prefix is run through the
|
|
5
|
-
* canonical branch→slug transform (see `preview.ts`). PR-number resolution and
|
|
6
|
-
* the Cloudflare WAF bypass header live in `artifact/delegate.ts`.
|
|
7
|
-
*/
|
|
8
|
-
export declare const PREVIEW_ENV_PREFIX = "preview:";
|
|
9
2
|
export declare const ENV_NAMES: string[];
|
|
10
3
|
export interface LatticeConfig {
|
|
11
4
|
envs: Record<string, {
|
package/dist/config.js
CHANGED
|
@@ -11,15 +11,7 @@ import { parse as parseToml, stringify as stringifyToml } from 'smol-toml';
|
|
|
11
11
|
import { validateDeploymentBaseUrl } from '@sequenceholdings/artifact-studio/deployment-validation';
|
|
12
12
|
import { isSequenceAuthEnvName, isSharedLoginDeploymentName, usesSharedSequenceLogin } from './auth.js';
|
|
13
13
|
import { fetchDeploymentLogin, readRegisteredEnvironmentUrls } from './env-registry.js';
|
|
14
|
-
import { resolvePreviewFromSlug } from './preview.js';
|
|
15
14
|
import { SANDBOX_ENV_NAME, sandboxTarget } from './sandbox-auth.js';
|
|
16
|
-
/**
|
|
17
|
-
* `--env preview:<branch-or-slug>` targets a per-PR Vercel preview deployment
|
|
18
|
-
* without a config.toml entry. The slug after the prefix is run through the
|
|
19
|
-
* canonical branch→slug transform (see `preview.ts`). PR-number resolution and
|
|
20
|
-
* the Cloudflare WAF bypass header live in `artifact/delegate.ts`.
|
|
21
|
-
*/
|
|
22
|
-
export const PREVIEW_ENV_PREFIX = 'preview:';
|
|
23
15
|
/**
|
|
24
16
|
* Only `local` ships in the published package. Every other environment is
|
|
25
17
|
* one the user configures: `seq-studio envs add <name> <url>` for an OpCo
|
|
@@ -199,10 +191,6 @@ export function resolveEnv({ config, requested, }) {
|
|
|
199
191
|
if (sandbox)
|
|
200
192
|
return sandbox;
|
|
201
193
|
const name = requested ?? config.defaultEnv;
|
|
202
|
-
if (name.startsWith(PREVIEW_ENV_PREFIX)) {
|
|
203
|
-
const { slug, url } = resolvePreviewFromSlug(name.slice(PREVIEW_ENV_PREFIX.length));
|
|
204
|
-
return { name: `${PREVIEW_ENV_PREFIX}${slug}`, url };
|
|
205
|
-
}
|
|
206
194
|
const staged = resolveStagedEnv({ config, name });
|
|
207
195
|
if (staged)
|
|
208
196
|
return staged;
|
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
import { PREVIEW_DOMAIN } from './preview.js';
|
|
2
1
|
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
2
|
/** Only send Cloudflare credentials to HTTPS origins in the company domain. */
|
|
20
3
|
function cfAccessHeaders(baseUrl) {
|
|
21
4
|
const clientId = process.env.CF_ACCESS_CLIENT_ID?.trim();
|
|
@@ -36,5 +19,5 @@ function cfAccessHeaders(baseUrl) {
|
|
|
36
19
|
}
|
|
37
20
|
}
|
|
38
21
|
export function edgeAuthHeaders(baseUrl) {
|
|
39
|
-
return
|
|
22
|
+
return cfAccessHeaders(baseUrl);
|
|
40
23
|
}
|
|
@@ -77,6 +77,21 @@ export declare function promptHidden(question: string): Promise<string>;
|
|
|
77
77
|
export declare function printError(error: unknown): void;
|
|
78
78
|
export declare function functionsInitCommand(args: ParsedArgs): Promise<number>;
|
|
79
79
|
export declare function functionsBuildCommand(args: ParsedArgs): Promise<number>;
|
|
80
|
+
/**
|
|
81
|
+
* Rebind a function row that a database fork copied to the local Atlas being deployed to.
|
|
82
|
+
* Only a local Atlas on a personal or devbox database branch offers this; anywhere else it is refused.
|
|
83
|
+
*/
|
|
84
|
+
export declare function adoptIntoLocalRuntime({ ctx, functionId }: {
|
|
85
|
+
ctx: CommandContext;
|
|
86
|
+
functionId: string;
|
|
87
|
+
}): Promise<{
|
|
88
|
+
ok: true;
|
|
89
|
+
adopted: boolean;
|
|
90
|
+
from: string;
|
|
91
|
+
} | {
|
|
92
|
+
ok: false;
|
|
93
|
+
message: string;
|
|
94
|
+
}>;
|
|
80
95
|
export declare function functionsDeployCommand(args: ParsedArgs): Promise<number>;
|
|
81
96
|
export declare function pollVersion({ ctx, functionId, versionId, egressNote, immutableRelease, }: {
|
|
82
97
|
ctx: CommandContext;
|
|
@@ -509,6 +509,33 @@ async function getFunctionDetail(ctx, functionId) {
|
|
|
509
509
|
throw error;
|
|
510
510
|
}
|
|
511
511
|
}
|
|
512
|
+
const ADOPTED_FROM = {
|
|
513
|
+
hosted: 'a hosted runtime',
|
|
514
|
+
'other-local-workspace': 'another local workspace',
|
|
515
|
+
'never-deployed': 'a runtime that never deployed it',
|
|
516
|
+
};
|
|
517
|
+
/**
|
|
518
|
+
* Rebind a function row that a database fork copied to the local Atlas being deployed to.
|
|
519
|
+
* Only a local Atlas on a personal or devbox database branch offers this; anywhere else it is refused.
|
|
520
|
+
*/
|
|
521
|
+
export async function adoptIntoLocalRuntime({ ctx, functionId }) {
|
|
522
|
+
try {
|
|
523
|
+
const result = await postJson({
|
|
524
|
+
...clientOptions(ctx),
|
|
525
|
+
path: `/api/managed-functions/${functionId}/local-adoption`,
|
|
526
|
+
});
|
|
527
|
+
return { ok: true, adopted: result.adopted === true, from: ADOPTED_FROM[result.from ?? ''] ?? 'another runtime' };
|
|
528
|
+
}
|
|
529
|
+
catch (error) {
|
|
530
|
+
if (error instanceof AtlasApiError && error.status === 404) {
|
|
531
|
+
return { ok: false, message: `--adopt works only against a local Atlas; ${ctx.env.name} does not offer it` };
|
|
532
|
+
}
|
|
533
|
+
if (error instanceof AtlasApiError && (error.status === 409 || error.status === 403)) {
|
|
534
|
+
return { ok: false, message: error.message };
|
|
535
|
+
}
|
|
536
|
+
throw error;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
512
539
|
export async function functionsDeployCommand(args) {
|
|
513
540
|
// Fail before source resolution / auth so a missing `-e` never becomes
|
|
514
541
|
// `fetch failed` against localhost. `buildContext` enforces the same rule.
|
|
@@ -611,18 +638,31 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
611
638
|
...clientOptions(ctx),
|
|
612
639
|
path: `/api/managed-functions?slug=${encodeURIComponent(slug)}`,
|
|
613
640
|
});
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
641
|
+
let existingShell = functions.find((f) => f.slug === slug) ?? null;
|
|
642
|
+
// Adoption changes the copied row, so it waits for the confirmation below like every other
|
|
643
|
+
// write. It also clears a copied immutable release, so those refusals wait for it too.
|
|
644
|
+
const adopting = existingShell !== null && flagBool(args.flags, 'adopt');
|
|
645
|
+
const immutableRefusal = (shell) => {
|
|
646
|
+
if (shell?.immutableRelease === true) {
|
|
647
|
+
return 'this function is an immutable release. Create a new function ID; this identity cannot be redeployed.';
|
|
648
|
+
}
|
|
649
|
+
if (manifest.function.immutable_release === true && shell?.activeVersionId) {
|
|
650
|
+
return 'immutable release opt-in must precede first activation. Create a new function ID.';
|
|
651
|
+
}
|
|
652
|
+
return null;
|
|
653
|
+
};
|
|
654
|
+
if (!adopting) {
|
|
655
|
+
const refusal = immutableRefusal(existingShell);
|
|
656
|
+
if (refusal) {
|
|
657
|
+
console.error(`${LOG} ${refusal}`);
|
|
658
|
+
return 1;
|
|
659
|
+
}
|
|
622
660
|
}
|
|
623
|
-
const shellAction = existingShell
|
|
624
|
-
? `
|
|
625
|
-
:
|
|
661
|
+
const shellAction = !existingShell
|
|
662
|
+
? `will register new shell on ${ctx.env.name}`
|
|
663
|
+
: adopting
|
|
664
|
+
? `existing shell on ${ctx.env.name}; adopted into this local Atlas if another runtime owns it`
|
|
665
|
+
: `existing shell on ${ctx.env.name}`;
|
|
626
666
|
let versions = [];
|
|
627
667
|
if (existingShell) {
|
|
628
668
|
try {
|
|
@@ -778,6 +818,22 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
778
818
|
const ok = await confirmYes({ preview, confirmed });
|
|
779
819
|
if (!ok)
|
|
780
820
|
return 1;
|
|
821
|
+
if (adopting && existingShell) {
|
|
822
|
+
const adoption = await adoptIntoLocalRuntime({ ctx, functionId: existingShell.id });
|
|
823
|
+
if (!adoption.ok) {
|
|
824
|
+
console.error(`${LOG} ${adoption.message}`);
|
|
825
|
+
return 1;
|
|
826
|
+
}
|
|
827
|
+
if (adoption.adopted) {
|
|
828
|
+
console.log(`${LOG} adopted ${slug} into this local Atlas (it came from ${adoption.from}); the runtime it was copied from is untouched`);
|
|
829
|
+
existingShell = await resolveFunction({ ctx, args: { positional: [], flags: { fn: slug } }, required: false });
|
|
830
|
+
}
|
|
831
|
+
const refusal = immutableRefusal(existingShell);
|
|
832
|
+
if (refusal) {
|
|
833
|
+
console.error(`${LOG} ${refusal}`);
|
|
834
|
+
return 1;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
781
837
|
// Ensure the function shell exists before reconciling secrets (which need the fn id).
|
|
782
838
|
let fn = existingShell;
|
|
783
839
|
let createdShell = false;
|
package/dist/main.js
CHANGED
|
@@ -219,7 +219,7 @@ async function checkStagedEnv(args) {
|
|
|
219
219
|
const requested = requestedEnv(args);
|
|
220
220
|
if (!requested || !(requested.includes('/') || requested === 'staging' || requested === 'prod'))
|
|
221
221
|
return null;
|
|
222
|
-
if (requested.startsWith('
|
|
222
|
+
if (requested.startsWith('local:'))
|
|
223
223
|
return null;
|
|
224
224
|
const [{ resolveConfiguredEnv }, { UsageError }, { printCliError }] = await Promise.all([
|
|
225
225
|
import('./config.js'), import('./exit-codes.js'), import('./cli-errors.js'),
|
|
@@ -24,6 +24,13 @@ export const LIFECYCLE_COMMANDS = [
|
|
|
24
24
|
description: 'Deploy an app workspace',
|
|
25
25
|
lifecycle: 'preview', access: 'authenticated', subcommands: [], checkSubcommands: false, telemetry: 'command',
|
|
26
26
|
run: async ({ sub, rest }) => (await import('../lifecycle/commands.js')).runApplyCommand(await parse(present([sub, ...rest]))),
|
|
27
|
+
}, {
|
|
28
|
+
name: 'preview',
|
|
29
|
+
group: 'lifecycle', usage: 'preview [dir] -e local stand up this app on a local Atlas and print where to open it',
|
|
30
|
+
description: 'Preview an app on a local Atlas running on a personal development database branch',
|
|
31
|
+
internal: true,
|
|
32
|
+
lifecycle: 'internal', access: 'authenticated', subcommands: [], checkSubcommands: false, telemetry: 'command',
|
|
33
|
+
run: async ({ sub, rest }) => (await import('../app-preview/commands.js')).runPreviewCommand(await parse(present([sub, ...rest]))),
|
|
27
34
|
}, {
|
|
28
35
|
name: 'affected',
|
|
29
36
|
group: 'lifecycle', usage: 'affected [--base <rev>] which targets this change reaches, as seq-ci plans it',
|
package/dist/repos/commands.d.ts
CHANGED
|
@@ -47,10 +47,7 @@ export declare function smartHttpCloneDepth({ ref, full, }: {
|
|
|
47
47
|
/**
|
|
48
48
|
* buildContext for repos commands: rejects a valueless -e/--env (which would
|
|
49
49
|
* silently fall back to the default environment — dangerous with `delete
|
|
50
|
-
* --yes`)
|
|
51
|
-
* artifact-studio's HTTP client, which resolveRepo/materializeRepo use
|
|
52
|
-
* (mirrors applyPreviewAccessHeader in ../artifact/delegate.ts — studio-cli's
|
|
53
|
-
* own atlas-client reads PREVIEW_ACCESS_HEADER directly).
|
|
50
|
+
* --yes`).
|
|
54
51
|
*/
|
|
55
52
|
export declare function reposContext(args: ParsedArgs): Promise<CommandContext>;
|
|
56
53
|
/** Smart-HTTP clone base (aligned with PLA-83: `…/repos/<id>/git`). */
|
package/dist/repos/commands.js
CHANGED
|
@@ -24,7 +24,6 @@ import { initializeRepositoryPipeline } from './ci-init.js';
|
|
|
24
24
|
import { showRepositoryPrCi } from './ci-status.js';
|
|
25
25
|
import { AtlasApiError, deleteNoContent, getJson, getJsonOr404, postJson, } from '../atlas-client.js';
|
|
26
26
|
import { printCliError } from '../cli-errors.js';
|
|
27
|
-
import { PREVIEW_DOMAIN } from '../preview.js';
|
|
28
27
|
import { confirmYes } from '../prompt.js';
|
|
29
28
|
import { guideClonedCheckout } from '../scaffold-guidance.js';
|
|
30
29
|
import { buildContext, clientOptions, flagBool, LOG, } from '../functions/commands.js';
|
|
@@ -73,29 +72,13 @@ export function smartHttpCloneDepth({ ref, full, }) {
|
|
|
73
72
|
/**
|
|
74
73
|
* buildContext for repos commands: rejects a valueless -e/--env (which would
|
|
75
74
|
* silently fall back to the default environment — dangerous with `delete
|
|
76
|
-
* --yes`)
|
|
77
|
-
* artifact-studio's HTTP client, which resolveRepo/materializeRepo use
|
|
78
|
-
* (mirrors applyPreviewAccessHeader in ../artifact/delegate.ts — studio-cli's
|
|
79
|
-
* own atlas-client reads PREVIEW_ACCESS_HEADER directly).
|
|
75
|
+
* --yes`).
|
|
80
76
|
*/
|
|
81
77
|
export async function reposContext(args) {
|
|
82
78
|
if (args.flags.env === true || args.flags.e === true) {
|
|
83
79
|
throw new Error('-e/--env requires a value — see: seq-studio envs list.');
|
|
84
80
|
}
|
|
85
|
-
|
|
86
|
-
const secret = process.env.PREVIEW_ACCESS_HEADER?.trim();
|
|
87
|
-
if (secret && isPreviewHost(ctx.env.url)) {
|
|
88
|
-
process.env.ARTIFACT_STUDIO_EXTRA_HEADERS = JSON.stringify({ 'x-preview-access': secret });
|
|
89
|
-
}
|
|
90
|
-
return ctx;
|
|
91
|
-
}
|
|
92
|
-
function isPreviewHost(baseUrl) {
|
|
93
|
-
try {
|
|
94
|
-
return new URL(baseUrl).hostname.toLowerCase().endsWith(`.${PREVIEW_DOMAIN}`);
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
81
|
+
return buildContext(args);
|
|
99
82
|
}
|
|
100
83
|
async function listAllPages(ctx, basePath) {
|
|
101
84
|
const sep = basePath.includes('?') ? '&' : '?';
|
|
@@ -28,7 +28,7 @@ export function validateTemplatePublishRoute(from, to) {
|
|
|
28
28
|
if (from !== 'banksouth' && from !== 'staging') {
|
|
29
29
|
throw new Error('publish requires --from banksouth or --from staging.');
|
|
30
30
|
}
|
|
31
|
-
if (to === 'local' || to.startsWith('local:')
|
|
31
|
+
if (to === 'local' || to.startsWith('local:')) {
|
|
32
32
|
throw new Error('--to must be a deployed environment or all.');
|
|
33
33
|
}
|
|
34
34
|
if (from === 'staging' && to !== 'staging') {
|