@sequenceholdings/studio-cli 0.1.31 → 0.2.0
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 +335 -26
- package/dist/artifact/delegate.js +11 -2
- package/dist/atlas-client.d.ts +16 -0
- package/dist/atlas-client.js +26 -0
- package/dist/functions/bundle.js +4 -2
- package/dist/functions/commands.d.ts +12 -2
- package/dist/functions/commands.js +176 -14
- package/dist/functions/dev.d.ts +3 -0
- package/dist/functions/dev.js +97 -0
- package/dist/functions/egress-preview.d.ts +2 -1
- package/dist/functions/egress-preview.js +3 -2
- package/dist/functions/manifest.d.ts +18 -1
- package/dist/functions/manifest.js +19 -29
- package/dist/main.js +6 -1
- package/dist/pipeline/commands.js +16 -10
- package/dist/pipeline/lifecycle.d.ts +1 -0
- package/dist/pipeline/lifecycle.js +105 -28
- package/dist/pipeline/migrations.js +6 -1
- package/dist/pipeline/stage-secrets.d.ts +95 -0
- package/dist/pipeline/stage-secrets.js +166 -0
- package/dist/pipeline/templates.d.ts +1 -1
- package/dist/pipeline/templates.js +37 -3
- package/dist/process/build.js +1 -0
- package/dist/process/codegen.js +1 -0
- package/dist/process/lint.js +12 -7
- package/dist/process/plan-diff.js +1 -0
- package/dist/process/safety-baseline.d.ts +3 -3
- package/dist/process/safety-baseline.js +4 -5
- package/dist/process/simulate.js +7 -2
- package/dist/repos/commands.d.ts +11 -1
- package/dist/repos/commands.js +37 -11
- package/dist/secrets/commands.d.ts +1 -1
- package/dist/secrets/commands.js +73 -3
- package/dist/storage/commands.d.ts +2 -0
- package/dist/storage/commands.js +215 -0
- package/dist/templates/process/pnpm-workspace.yaml +3 -0
- package/package.json +7 -5
- package/templates/process/pnpm-workspace.yaml +3 -0
|
@@ -31,7 +31,10 @@ const INGESTION_BODY = `
|
|
|
31
31
|
# ('upload' is reserved — not yet supported.)
|
|
32
32
|
runtime: databricks
|
|
33
33
|
# databricks runtime pulls from an external system (symbolic refs, never secrets).
|
|
34
|
-
# Secure-by-default: declare a credential
|
|
34
|
+
# Secure-by-default: declare a credential for authenticated APIs. Attach a
|
|
35
|
+
# managed secret to it per deploy target (seq-studio secrets attach <NAME>
|
|
36
|
+
# --stage <stage>, or plan/deploy attaches MY_SOURCE_CREDENTIAL by convention)
|
|
37
|
+
# and read it in code with pipeline_runtime.get_credential("my_source_credential").
|
|
35
38
|
# For genuinely keyless / public sources, omit credential entirely (do not
|
|
36
39
|
# invent a sentinel binding) — e.g. source: { system: espn }.
|
|
37
40
|
source:
|
|
@@ -153,6 +156,36 @@ def main() -> None:
|
|
|
153
156
|
raise NotImplementedError("implement the {{name}} stage")
|
|
154
157
|
|
|
155
158
|
|
|
159
|
+
if __name__ == "__main__":
|
|
160
|
+
main()
|
|
161
|
+
`;
|
|
162
|
+
const INGESTION_ENTRYPOINT_STUB = `# Databricks notebook source
|
|
163
|
+
"""Entrypoint for the {{name}} ingestion stage.
|
|
164
|
+
|
|
165
|
+
Fetch from the source and land raw batches under \`landing(<feed>)\`; the
|
|
166
|
+
platform materializes bronze. Never hardcode a credential: the spec's
|
|
167
|
+
\`source.credential\` is attached to a managed secret per deploy target
|
|
168
|
+
(\`seq-studio secrets attach <NAME> --stage {{name}}\`, or automatically by
|
|
169
|
+
\`seq-studio pipeline plan|deploy\` when a secret named after it exists), and
|
|
170
|
+
read here with \`get_credential\`.
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
# COMMAND ----------
|
|
174
|
+
|
|
175
|
+
import sys
|
|
176
|
+
|
|
177
|
+
# Serverless notebook tasks only see this notebook's directory; the platform
|
|
178
|
+
# passes the bundle root (where pipeline_runtime is vendored) as a widget.
|
|
179
|
+
sys.path.insert(0, dbutils.widgets.get("bundle_root")) # noqa: F821 - notebook global
|
|
180
|
+
|
|
181
|
+
from pipeline_runtime import get_credential, landing
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def main() -> None:
|
|
185
|
+
credential = get_credential("my_source_credential") # the spec's source.credential
|
|
186
|
+
raise NotImplementedError("fetch from the source with the credential and land batches under landing(<feed>)")
|
|
187
|
+
|
|
188
|
+
|
|
156
189
|
if __name__ == "__main__":
|
|
157
190
|
main()
|
|
158
191
|
`;
|
|
@@ -163,6 +196,7 @@ export function renderStageTemplate(name, type) {
|
|
|
163
196
|
body.replace(/\{\{name\}\}/g, name).replace(/\{\{snake\}\}/g, name.replace(/-/g, '_')));
|
|
164
197
|
}
|
|
165
198
|
/** Serving stages are declarative — no entrypoint stub. */
|
|
166
|
-
export function renderEntrypointStub(name) {
|
|
167
|
-
|
|
199
|
+
export function renderEntrypointStub(name, type = 'transformation') {
|
|
200
|
+
const template = type === 'ingestion' ? INGESTION_ENTRYPOINT_STUB : ENTRYPOINT_STUB;
|
|
201
|
+
return template.replace(/\{\{name\}\}/g, name);
|
|
168
202
|
}
|
package/dist/process/build.js
CHANGED
|
@@ -380,6 +380,7 @@ function serializeNodeMetadata(node) {
|
|
|
380
380
|
// NOTE: `middleware` (e.g. withRetry) is serialized generically for every
|
|
381
381
|
// node kind in `serializeNode` above — don't duplicate it here.
|
|
382
382
|
serializeMapperSlot(meta, 'input_mapper', mf.input);
|
|
383
|
+
serializeMapperSlot(meta, 'output_mapper', mf.output);
|
|
383
384
|
return meta;
|
|
384
385
|
}
|
|
385
386
|
default:
|
package/dist/process/codegen.js
CHANGED
|
@@ -219,6 +219,7 @@ function emitNode(node, ctx) {
|
|
|
219
219
|
bindings(m.bindings),
|
|
220
220
|
middleware(m.middleware, ctx),
|
|
221
221
|
mapper('input', m.input_mapper_source, m.input_mapper_expr, ctx),
|
|
222
|
+
mapper('output', undefined, m.output_mapper_expr, ctx),
|
|
222
223
|
tail,
|
|
223
224
|
];
|
|
224
225
|
return call('defineManagedFunctionNode', fields);
|
package/dist/process/lint.js
CHANGED
|
@@ -137,6 +137,9 @@ function lintJsonataExpressions(processId, node, errors) {
|
|
|
137
137
|
add('supervisor_retry.retryIf', subprocess.supervisor_retry?.retryIf);
|
|
138
138
|
break;
|
|
139
139
|
}
|
|
140
|
+
case 'managed_function':
|
|
141
|
+
add('output', node.output);
|
|
142
|
+
break;
|
|
140
143
|
}
|
|
141
144
|
const middleware = 'middleware' in node ? node.middleware : undefined;
|
|
142
145
|
if (Array.isArray(middleware)) {
|
|
@@ -383,13 +386,15 @@ function lintRouteRulesEdges(processId, node, errors) {
|
|
|
383
386
|
}
|
|
384
387
|
function lintManagedFunctionNode(processId, node, errors) {
|
|
385
388
|
const edgeIds = new Set(node.outgoing_edges.map((e) => e.id));
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
389
|
+
if (node.output === undefined) {
|
|
390
|
+
for (const required of ['success', 'error']) {
|
|
391
|
+
if (!edgeIds.has(required)) {
|
|
392
|
+
errors.push({
|
|
393
|
+
process_id: processId,
|
|
394
|
+
node_id: node.id,
|
|
395
|
+
message: `managed_function node must declare outgoing edge "${required}"`,
|
|
396
|
+
});
|
|
397
|
+
}
|
|
393
398
|
}
|
|
394
399
|
}
|
|
395
400
|
if (!node.function?.trim()) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* process definition and derive the observed corpus maxima for each statically
|
|
4
4
|
* measurable safety-profile dimension. `seq-studio process safety-baseline`
|
|
5
5
|
* prints the report (`--write` refreshes the committed copy at
|
|
6
|
-
* atlas/lattice/SAFETY_PROFILE_BASELINE.md)
|
|
6
|
+
* atlas/lattice/SAFETY_PROFILE_BASELINE.md). safety-baseline.test.ts asserts
|
|
7
7
|
* the committed DEFAULT_LATTICE_SAFETY_PROFILE fits the whole corpus, which is
|
|
8
8
|
* the backwards-compatibility gate for the profile's defaults.
|
|
9
9
|
*
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
* Determinism: roots and processes are iterated in sorted order, provenance
|
|
27
27
|
* and metadata are pinned to fixed values, and every observation is a pure
|
|
28
28
|
* function of the committed sources, so two derivations over the same tree
|
|
29
|
-
* are deep-equal (asserted by the test)
|
|
30
|
-
*
|
|
29
|
+
* are deep-equal (asserted by the test). The report is an on-demand snapshot,
|
|
30
|
+
* refreshed when a reviewer needs to inspect the measured corpus.
|
|
31
31
|
*/
|
|
32
32
|
import type { LatticeSafetyProfile } from '@sequenceholdings/lattice';
|
|
33
33
|
/** Repo-relative path of the committed, generated baseline report. */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* process definition and derive the observed corpus maxima for each statically
|
|
4
4
|
* measurable safety-profile dimension. `seq-studio process safety-baseline`
|
|
5
5
|
* prints the report (`--write` refreshes the committed copy at
|
|
6
|
-
* atlas/lattice/SAFETY_PROFILE_BASELINE.md)
|
|
6
|
+
* atlas/lattice/SAFETY_PROFILE_BASELINE.md). safety-baseline.test.ts asserts
|
|
7
7
|
* the committed DEFAULT_LATTICE_SAFETY_PROFILE fits the whole corpus, which is
|
|
8
8
|
* the backwards-compatibility gate for the profile's defaults.
|
|
9
9
|
*
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
* Determinism: roots and processes are iterated in sorted order, provenance
|
|
27
27
|
* and metadata are pinned to fixed values, and every observation is a pure
|
|
28
28
|
* function of the committed sources, so two derivations over the same tree
|
|
29
|
-
* are deep-equal (asserted by the test)
|
|
30
|
-
*
|
|
29
|
+
* are deep-equal (asserted by the test). The report is an on-demand snapshot,
|
|
30
|
+
* refreshed when a reviewer needs to inspect the measured corpus.
|
|
31
31
|
*/
|
|
32
32
|
import { readdir, readFile, stat, writeFile } from 'node:fs/promises';
|
|
33
33
|
import { join, relative } from 'node:path';
|
|
@@ -57,8 +57,7 @@ const CANONICAL_METADATA = {
|
|
|
57
57
|
* process.ts goes through a single tsx transform (vitest) but `__name2` when
|
|
58
58
|
* the CLI itself already runs under the tsx loader (chained transforms pick a
|
|
59
59
|
* collision-free suffix). The suffix carries no information — canonical byte
|
|
60
|
-
* measurements strip it so
|
|
61
|
-
* The byte-identical report test catches any new helper drifting the same way.
|
|
60
|
+
* measurements strip it so on-demand reports remain comparable across lanes.
|
|
62
61
|
*/
|
|
63
62
|
const normalizeTransformArtifacts = (serialized) => serialized.replace(/\b__name\d+\b/g, '__name');
|
|
64
63
|
async function isDir(path) {
|
package/dist/process/simulate.js
CHANGED
|
@@ -192,9 +192,14 @@ async function dispatchInProcess(args) {
|
|
|
192
192
|
return { edge_id: delay.outgoing_edges[0]?.id };
|
|
193
193
|
}
|
|
194
194
|
case 'managed_function': {
|
|
195
|
-
// Simulation cannot call live managed functions
|
|
195
|
+
// Simulation cannot call live managed functions. Preserve the legacy
|
|
196
|
+
// transport stub (`success`) when no mapper is authored; mapped nodes
|
|
197
|
+
// walk their first authored business edge because there is no real
|
|
198
|
+
// response against which to evaluate the expression.
|
|
196
199
|
return {
|
|
197
|
-
edge_id:
|
|
200
|
+
edge_id: args.node.output === undefined
|
|
201
|
+
? 'success'
|
|
202
|
+
: args.node.outgoing_edges[0]?.id,
|
|
198
203
|
payload: { _simulated: true, kind: 'managed_function' },
|
|
199
204
|
};
|
|
200
205
|
}
|
package/dist/repos/commands.d.ts
CHANGED
|
@@ -13,6 +13,16 @@ export declare function parseRepoPath(input: string | undefined): {
|
|
|
13
13
|
* list, or `pull --ref --out x` fetching the default branch). Error instead.
|
|
14
14
|
*/
|
|
15
15
|
export declare function stringFlag(flags: ParsedArgs['flags'], key: string): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Branch and tag clones fetch one commit. A full history walk reads every
|
|
18
|
+
* object out of git-service storage before the pack starts. Commit SHAs
|
|
19
|
+
* stay full so the following checkout can see that object. `--full` opts
|
|
20
|
+
* back into history.
|
|
21
|
+
*/
|
|
22
|
+
export declare function smartHttpCloneDepth({ ref, full, }: {
|
|
23
|
+
ref?: string;
|
|
24
|
+
full: boolean;
|
|
25
|
+
}): number | undefined;
|
|
16
26
|
/** Smart-HTTP clone base (aligned with PLA-83: `…/repos/<id>/git`). */
|
|
17
27
|
export declare function cloneUrl(ctx: CommandContext, repoId: string): string;
|
|
18
28
|
/**
|
|
@@ -96,6 +106,6 @@ export declare function reposCiRequireCommand(args: ParsedArgs): Promise<number>
|
|
|
96
106
|
export declare function reposCiImportCommand(args: ParsedArgs): Promise<number>;
|
|
97
107
|
export declare function reposCiCommand(args: ParsedArgs): Promise<number>;
|
|
98
108
|
export declare function reposDeleteCommand(args: ParsedArgs): Promise<number>;
|
|
99
|
-
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 create <ns>/<name> -e <env> [--default-branch b] [--git-backend gcs_isomorphic|walgit]\n create a repo (GCS default, seed README;\n walgit starts empty on main; needs namespace write)\n seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--
|
|
109
|
+
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 create <ns>/<name> -e <env> [--default-branch b] [--git-backend gcs_isomorphic|walgit]\n create a repo (GCS default, seed README;\n walgit starts empty on main; needs namespace write)\n seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--output dir] [--force] [--full]\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 smart-HTTP when ATLAS_GIT_PAT is set;\n otherwise JSON materialize (<ns>/<name>)\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 delete <ns>/<name> -e <env> [--yes] delete a repo (confirm prompt)\n seq-studio repos ci show <ns>/<name> -e <env> [--ref r] preview discovered CI checks\n seq-studio repos ci require <ns>/<name> --check <name> -e <env> reserved (refuses write until sandboxed runner)\n seq-studio repos ci import <ns>/<name> -e <env> [--ref r] reserved (refuses write until sandboxed runner)\n\n Flags: -e/--env <env> (required; see: seq-studio envs list)\n\n clone prefers real git clone (PAT via askpass \u2014 never written into the remote\n URL). Without ATLAS_GIT_PAT, <ns>/<name> falls back to the JSON API and prints\n how to get a PAT (seq-studio or Atlas UI /settings/tokens).\n PAT without Auth0 login: use --id from Repositories \u2192 Clone\n (or --url with the environment's canonical HTTPS origin).\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: ATLAS_GIT_PAT (from Atlas Settings \u2192 Tokens)\n";
|
|
100
110
|
export declare function runReposCommand(sub: string | undefined, args: ParsedArgs): Promise<number>;
|
|
101
111
|
export {};
|
package/dist/repos/commands.js
CHANGED
|
@@ -22,7 +22,7 @@ import { printCliError } from '../cli-errors.js';
|
|
|
22
22
|
import { PREVIEW_DOMAIN } from '../preview.js';
|
|
23
23
|
import { confirmYes } from '../prompt.js';
|
|
24
24
|
import { buildContext, clientOptions, flagBool, LOG, } from '../functions/commands.js';
|
|
25
|
-
import { resolveGitPatFromEnv, runGitClone, } from './git-clone.js';
|
|
25
|
+
import { looksLikeCommitSha, resolveGitPatFromEnv, runGitClone, } from './git-clone.js';
|
|
26
26
|
import { formatPatSetupHint } from '../pat-hints.js';
|
|
27
27
|
import { tryGetAccessToken } from '../auth.js';
|
|
28
28
|
import { resolveEnvWithDiscovery } from '../config.js';
|
|
@@ -52,6 +52,19 @@ export function stringFlag(flags, key) {
|
|
|
52
52
|
throw new Error(`--${key} requires a value.`);
|
|
53
53
|
return value;
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Branch and tag clones fetch one commit. A full history walk reads every
|
|
57
|
+
* object out of git-service storage before the pack starts. Commit SHAs
|
|
58
|
+
* stay full so the following checkout can see that object. `--full` opts
|
|
59
|
+
* back into history.
|
|
60
|
+
*/
|
|
61
|
+
export function smartHttpCloneDepth({ ref, full, }) {
|
|
62
|
+
if (full)
|
|
63
|
+
return undefined;
|
|
64
|
+
if (ref != null && looksLikeCommitSha(ref))
|
|
65
|
+
return undefined;
|
|
66
|
+
return 1;
|
|
67
|
+
}
|
|
55
68
|
/**
|
|
56
69
|
* buildContext for repos commands: rejects a valueless -e/--env (which would
|
|
57
70
|
* silently fall back to the default environment — dangerous with `delete
|
|
@@ -341,7 +354,15 @@ export async function reposPullCommand(args) {
|
|
|
341
354
|
*/
|
|
342
355
|
export async function reposCloneCommand(args, deps = {}) {
|
|
343
356
|
const force = flagBool(args.flags, 'force');
|
|
357
|
+
const full = flagBool(args.flags, 'full');
|
|
344
358
|
const ref = stringFlag(args.flags, 'ref');
|
|
359
|
+
const depth = smartHttpCloneDepth({ ref, full });
|
|
360
|
+
const outputFlag = stringFlag(args.flags, 'output');
|
|
361
|
+
const outFlag = stringFlag(args.flags, 'out');
|
|
362
|
+
if (outputFlag !== undefined && outFlag !== undefined) {
|
|
363
|
+
throw new Error('Pass only one of --output or --out.');
|
|
364
|
+
}
|
|
365
|
+
const output = outputFlag ?? outFlag;
|
|
345
366
|
const pat = resolveGitPatFromEnv();
|
|
346
367
|
const urlFlag = stringFlag(args.flags, 'url');
|
|
347
368
|
const idFlag = stringFlag(args.flags, 'id');
|
|
@@ -367,7 +388,7 @@ export async function reposCloneCommand(args, deps = {}) {
|
|
|
367
388
|
const targetUrl = urlFlag
|
|
368
389
|
? normalizeCloneUrl(urlFlag, env)
|
|
369
390
|
: cloneUrl({ env, token: '' }, idFlag);
|
|
370
|
-
const destDir = resolve(
|
|
391
|
+
const destDir = resolve(output ?? defaultOutFromCloneTarget({ url: targetUrl, id: idFlag }));
|
|
371
392
|
prepareCloneDest({ destDir, force });
|
|
372
393
|
const clone = deps.gitClone ?? runGitClone;
|
|
373
394
|
await clone({
|
|
@@ -375,16 +396,17 @@ export async function reposCloneCommand(args, deps = {}) {
|
|
|
375
396
|
destDir,
|
|
376
397
|
pat,
|
|
377
398
|
...(ref ? { ref } : {}),
|
|
399
|
+
...(depth != null ? { depth } : {}),
|
|
378
400
|
});
|
|
379
401
|
console.log(`${LOG} cloned ${targetUrl} → ${destDir}` +
|
|
380
402
|
(ref ? ` (ref ${ref})` : '') +
|
|
381
|
-
` via smart-HTTP`);
|
|
403
|
+
` via smart-HTTP${depth != null ? ` (depth ${depth})` : ''}`);
|
|
382
404
|
return 0;
|
|
383
405
|
}
|
|
384
406
|
// <ns>/<name> path — needs Auth0 for resolveRepo (JSON API) whether or not
|
|
385
407
|
// we then use smart-HTTP. Without Auth0, point users at --url from the UI.
|
|
386
408
|
if (!positional) {
|
|
387
|
-
console.error('usage: seq-studio repos clone <ns>/<name> | --url <clone-url> | --id <uuid> -e <env> [--ref r] [--
|
|
409
|
+
console.error('usage: seq-studio repos clone <ns>/<name> | --url <clone-url> | --id <uuid> -e <env> [--ref r] [--output dir] [--full]');
|
|
388
410
|
return 1;
|
|
389
411
|
}
|
|
390
412
|
const { namespace, name } = parseRepoPath(positional);
|
|
@@ -406,7 +428,7 @@ export async function reposCloneCommand(args, deps = {}) {
|
|
|
406
428
|
throw new Error(lines.join('\n'));
|
|
407
429
|
}
|
|
408
430
|
const ctx = await reposContext(args);
|
|
409
|
-
const destDir = resolve(
|
|
431
|
+
const destDir = resolve(output ?? name);
|
|
410
432
|
if (pat) {
|
|
411
433
|
prepareCloneDest({ destDir, force });
|
|
412
434
|
const resolved = await resolveRepo({ ...clientOptions(ctx), namespace, name });
|
|
@@ -417,10 +439,11 @@ export async function reposCloneCommand(args, deps = {}) {
|
|
|
417
439
|
destDir,
|
|
418
440
|
pat,
|
|
419
441
|
...(ref ? { ref } : {}),
|
|
442
|
+
...(depth != null ? { depth } : {}),
|
|
420
443
|
});
|
|
421
444
|
console.log(`${LOG} cloned ${namespace}/${name} → ${destDir}` +
|
|
422
445
|
(ref ? ` (ref ${ref})` : '') +
|
|
423
|
-
` via smart-HTTP`);
|
|
446
|
+
` via smart-HTTP${depth != null ? ` (depth ${depth})` : ''}`);
|
|
424
447
|
return 0;
|
|
425
448
|
}
|
|
426
449
|
assertDestWritable({ destDir, force });
|
|
@@ -775,9 +798,9 @@ export const REPOS_USAGE = `usage:
|
|
|
775
798
|
seq-studio repos create <ns>/<name> -e <env> [--default-branch b] [--git-backend gcs_isomorphic|walgit]
|
|
776
799
|
create a repo (GCS default, seed README;
|
|
777
800
|
walgit starts empty on main; needs namespace write)
|
|
778
|
-
seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--
|
|
779
|
-
seq-studio repos clone --url <https://…/repos/<id>/git> -e <env> [--ref r] [--
|
|
780
|
-
seq-studio repos clone --id <uuid> -e <env> [--ref r] [--
|
|
801
|
+
seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--output dir] [--force] [--full]
|
|
802
|
+
seq-studio repos clone --url <https://…/repos/<id>/git> -e <env> [--ref r] [--output dir] [--full]
|
|
803
|
+
seq-studio repos clone --id <uuid> -e <env> [--ref r] [--output dir] [--full]
|
|
781
804
|
smart-HTTP when ATLAS_GIT_PAT is set;
|
|
782
805
|
otherwise JSON materialize (<ns>/<name>)
|
|
783
806
|
seq-studio repos pull <ns>/<name> -e <env> [--ref r] [--out dir] [--force]
|
|
@@ -792,8 +815,11 @@ export const REPOS_USAGE = `usage:
|
|
|
792
815
|
clone prefers real git clone (PAT via askpass — never written into the remote
|
|
793
816
|
URL). Without ATLAS_GIT_PAT, <ns>/<name> falls back to the JSON API and prints
|
|
794
817
|
how to get a PAT (seq-studio or Atlas UI /settings/tokens).
|
|
795
|
-
PAT without Auth0 login: use --
|
|
796
|
-
|
|
818
|
+
PAT without Auth0 login: use --id from Repositories → Clone
|
|
819
|
+
(or --url with the environment's canonical HTTPS origin).
|
|
820
|
+
--ref accepts a branch, tag, or commit SHA (SHA → full clone, then checkout).
|
|
821
|
+
Branch and tag clones are shallow (--depth 1). Pass --full for history.
|
|
822
|
+
--output selects the clone directory (--out remains an alias).
|
|
797
823
|
|
|
798
824
|
Authenticate JSON API calls with: seq-studio login
|
|
799
825
|
Authenticate git clone/push with: ATLAS_GIT_PAT (from Atlas Settings → Tokens)
|
|
@@ -22,5 +22,5 @@ export declare function secretsSetDefaultCommand(args: ParsedArgs): Promise<numb
|
|
|
22
22
|
* UI: pin + redeploy the function's active version / pin only / cancel.
|
|
23
23
|
*/
|
|
24
24
|
export declare function secretsPinCommand(args: ParsedArgs): Promise<number>;
|
|
25
|
-
export declare const SECRETS_USAGE = "usage:\n seq-studio secrets create <NAME> -e <env> [--org <slug>] [--description text]\n register an org-owned secret\n seq-studio secrets set <NAME> -e <env> [--org <slug>] [--from-file <path>]\n set the shared default value (write-only)\n seq-studio secrets list -e <env> secrets you can see (never values)\n seq-studio secrets attach <NAME> --fn <slug> -e <env> [--org <slug>]\n mount default on a function env var\n seq-studio secrets detach <NAME> --fn <slug> -e <env> [--org <slug>]\n remove attachment\n seq-studio secrets apply --from-env-file .env -e <env> push defaults + attach (keys default from manifest)\n seq-studio secrets versions <NAME> -e <env> [--org <slug>] value version history (never values)\n seq-studio secrets set-default <NAME> [version] -e <env> [--org <slug>]\n point the default at a prior version (editor)\n seq-studio secrets pin <NAME> --fn <slug> [version] -e <env> [--org <slug>]\n pin one function to a version (sticky; --unpin clears)\n\n Note: for the common deploy loop, secrets declared in managed-function.yml are\n reconciled automatically by `seq-studio functions deploy` using a local .env.\n Use `secrets` commands for CI (no .env), bulk/multi-function ops, or write-only\n value changes without a redeploy.\n\n Flags: -e/--env <env> (required; see: seq-studio envs list)\n --org <slug> (target/select managed-scope org; required when a name exists in multiple orgs)\n set: --from-file <path> (non-interactive; file is not echoed)\n --fn <slug> \u00B7 --env-var <NAME> \u00B7 --yes\n --functions <f1,f2> \u00B7 --keys <K1,K2> \u00B7 --all (override key selection)\n set-default: [version|version-row-id] (defaults to the most recent non-default) \u00B7 --yes\n pin: [version|version-row-id] (defaults to the current default) \u00B7 --unpin \u00B7 --yes (redeploy) \u00B7 --yes --no-redeploy\n";
|
|
25
|
+
export declare const SECRETS_USAGE = "usage:\n seq-studio secrets create <NAME> -e <env> [--org <slug>] [--description text]\n register an org-owned secret\n seq-studio secrets set <NAME> -e <env> [--org <slug>] [--from-file <path>]\n set the shared default value (write-only)\n seq-studio secrets list -e <env> secrets you can see (never values)\n seq-studio secrets attach <NAME> --fn <slug> -e <env> [--org <slug>]\n mount default on a function env var\n seq-studio secrets detach <NAME> --fn <slug> -e <env> [--org <slug>]\n remove attachment\n seq-studio secrets attach <NAME> --stage <slug> -e <env> [--target <id>] [--credential <name>]\n attach to a pipeline stage's credential for one deploy target\n seq-studio secrets detach <NAME> --stage <slug> -e <env> [--target <id>] [--credential <name>]\n remove it (the stage's copy is deleted now)\n seq-studio secrets apply --from-env-file .env -e <env> push defaults + attach (keys default from manifest)\n seq-studio secrets versions <NAME> -e <env> [--org <slug>] value version history (never values)\n seq-studio secrets set-default <NAME> [version] -e <env> [--org <slug>]\n point the default at a prior version (editor)\n seq-studio secrets pin <NAME> --fn <slug> [version] -e <env> [--org <slug>]\n pin one function to a version (sticky; --unpin clears)\n\n Note: for the common deploy loop, secrets declared in managed-function.yml are\n reconciled automatically by `seq-studio functions deploy` using a local .env.\n Use `secrets` commands for CI (no .env), bulk/multi-function ops, or write-only\n value changes without a redeploy.\n\n Pipelines: managed secrets are the preferred way to give a stage a credential.\n Declare source.credential in the stage spec and read it in code with\n pipeline_runtime.get_credential(\"<name>\"). `seq-studio pipeline plan|deploy`\n attaches the secret named by convention (abrigo_oauth -> ABRIGO_OAUTH) when\n you can edit it (stages already deployed the legacy way are left alone); use\n `secrets attach --stage` for any other name.\n\n Flags: -e/--env <env> (required; see: seq-studio envs list)\n --org <slug> (target/select managed-scope org; required when a name exists in multiple orgs)\n set: --from-file <path> (non-interactive; file is not echoed)\n --fn <slug> \u00B7 --env-var <NAME> \u00B7 --yes\n --stage <slug> \u00B7 --target <id> (deploy target; default from -e) \u00B7 --credential <name>\n (the spec's source.credential; default: NAME lowercased) \u00B7 --repo <ns>/<name> (disambiguate)\n --functions <f1,f2> \u00B7 --keys <K1,K2> \u00B7 --all (override key selection)\n set-default: [version|version-row-id] (defaults to the most recent non-default) \u00B7 --yes\n pin: [version|version-row-id] (defaults to the current default) \u00B7 --unpin \u00B7 --yes (redeploy) \u00B7 --yes --no-redeploy\n";
|
|
26
26
|
export declare function runSecretsCommand(sub: string | undefined, args: ParsedArgs): Promise<number>;
|
package/dist/secrets/commands.js
CHANGED
|
@@ -5,6 +5,8 @@ import { buildContext, clientOptions, flagBool, parseDotenv, pollVersion, printE
|
|
|
5
5
|
import { clarifyApplyFailureReason } from '../cli-errors.js';
|
|
6
6
|
import { confirmChoice, confirmYes } from '../prompt.js';
|
|
7
7
|
import { AtlasApiError, deleteJson, getJson, patchJson, postJson, putJson } from '../atlas-client.js';
|
|
8
|
+
import { resolvePipelineTarget } from '../pipeline/lifecycle.js';
|
|
9
|
+
import { attachSecretToStage, detachSecretFromStage, listStageBindings, resolveStage, symbolicForSecretName, } from '../pipeline/stage-secrets.js';
|
|
8
10
|
export const LOG = '[seq-studio]';
|
|
9
11
|
const VERSION_ROW_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
10
12
|
/** Match a version arg by stable row id, or by gcpVersion when unambiguous. */
|
|
@@ -219,7 +221,7 @@ export async function secretsSetCommand(args) {
|
|
|
219
221
|
body: { value },
|
|
220
222
|
});
|
|
221
223
|
console.log(`${LOG} set default value for "${name}"`);
|
|
222
|
-
console.log(`${LOG} functions
|
|
224
|
+
console.log(`${LOG} functions and pipeline stages tracking this secret need a redeploy to pick up the new version`);
|
|
223
225
|
return 0;
|
|
224
226
|
}
|
|
225
227
|
// ---------------------------------------------------------------------------
|
|
@@ -243,11 +245,63 @@ export async function secretsListCommand(args) {
|
|
|
243
245
|
// ---------------------------------------------------------------------------
|
|
244
246
|
// attach / detach
|
|
245
247
|
// ---------------------------------------------------------------------------
|
|
248
|
+
/** `--stage` flags shared by attach/detach: the stage, credential and deploy target. */
|
|
249
|
+
async function resolveStageAttachment({ args, ctx, name }) {
|
|
250
|
+
const stageSlug = args.flags.stage;
|
|
251
|
+
const repo = typeof args.flags.repo === 'string' ? args.flags.repo : undefined;
|
|
252
|
+
const symbolic = typeof args.flags.credential === 'string' ? args.flags.credential : symbolicForSecretName(name);
|
|
253
|
+
const [stage, target] = await Promise.all([
|
|
254
|
+
resolveStage({ client: clientOptions(ctx), slug: stageSlug, ...(repo ? { repo } : {}) }),
|
|
255
|
+
resolvePipelineTarget({ args, env: ctx.env, token: ctx.token }),
|
|
256
|
+
]);
|
|
257
|
+
return { stage, symbolic, deployTarget: target.id };
|
|
258
|
+
}
|
|
259
|
+
async function secretsAttachToStage(args, name) {
|
|
260
|
+
const ctx = await buildContext(args);
|
|
261
|
+
const secret = await resolveSecretByName({ ctx, name, org: orgFlag(args) });
|
|
262
|
+
const { stage, symbolic, deployTarget } = await resolveStageAttachment({ args, ctx, name });
|
|
263
|
+
const preview = [
|
|
264
|
+
`${LOG} attach preview:`,
|
|
265
|
+
`${LOG} secret: ${name}`,
|
|
266
|
+
`${LOG} stage: ${stage.slug} (${stage.repo})`,
|
|
267
|
+
`${LOG} credential: ${symbolic}`,
|
|
268
|
+
`${LOG} target: ${deployTarget}`,
|
|
269
|
+
`${LOG} note: the stage's code can read this value at runtime`,
|
|
270
|
+
];
|
|
271
|
+
if (!(await confirmYes({ preview, confirmed: flagBool(args.flags, 'yes') })))
|
|
272
|
+
return 1;
|
|
273
|
+
await attachSecretToStage({ client: clientOptions(ctx), stageId: stage.id, deployTarget, symbolic, secretId: secret.id });
|
|
274
|
+
console.log(`${LOG} attached "${name}" to ${stage.slug} as ${symbolic} for ${deployTarget}`);
|
|
275
|
+
console.log(`${LOG} plan and deploy the stage to copy it; read it with pipeline_runtime.get_credential("${symbolic}")`);
|
|
276
|
+
return 0;
|
|
277
|
+
}
|
|
278
|
+
async function secretsDetachFromStage(args, name) {
|
|
279
|
+
const ctx = await buildContext(args);
|
|
280
|
+
const secret = await resolveSecretByName({ ctx, name, org: orgFlag(args) });
|
|
281
|
+
const { stage, symbolic, deployTarget } = await resolveStageAttachment({ args, ctx, name });
|
|
282
|
+
// Detach addresses the stage's credential, so confirm NAME is what's attached
|
|
283
|
+
// there — never delete a different (e.g. replacement) secret's binding.
|
|
284
|
+
const binding = (await listStageBindings({ client: clientOptions(ctx), stageId: stage.id })).find((row) => row.deployTarget === deployTarget && row.symbolic === symbolic);
|
|
285
|
+
if (!binding) {
|
|
286
|
+
console.error(`${LOG} nothing is attached to ${stage.slug}'s ${symbolic} for ${deployTarget}`);
|
|
287
|
+
return 1;
|
|
288
|
+
}
|
|
289
|
+
if (binding.secretId !== secret.id) {
|
|
290
|
+
console.error(`${LOG} ${stage.slug}'s ${symbolic} for ${deployTarget} is attached to ${binding.secretName}, not ${name}; nothing detached`);
|
|
291
|
+
return 1;
|
|
292
|
+
}
|
|
293
|
+
await detachSecretFromStage({ client: clientOptions(ctx), stageId: stage.id, deployTarget, symbolic });
|
|
294
|
+
console.log(`${LOG} detached ${symbolic} from ${stage.slug} for ${deployTarget}; its copy was deleted`);
|
|
295
|
+
return 0;
|
|
296
|
+
}
|
|
246
297
|
export async function secretsAttachCommand(args) {
|
|
247
298
|
const name = args.positional[0];
|
|
299
|
+
if (name && typeof args.flags.stage === 'string')
|
|
300
|
+
return secretsAttachToStage(args, name);
|
|
248
301
|
const fnSlug = typeof args.flags.fn === 'string' ? args.flags.fn : args.positional[1];
|
|
249
302
|
if (!name || !fnSlug) {
|
|
250
|
-
console.error('usage: seq-studio secrets attach <NAME> --fn <slug> -e <env> [--org <slug>] [--env-var NAME]'
|
|
303
|
+
console.error('usage: seq-studio secrets attach <NAME> --fn <slug> -e <env> [--org <slug>] [--env-var NAME]\n' +
|
|
304
|
+
' seq-studio secrets attach <NAME> --stage <slug> -e <env> [--target <id>] [--credential <name>] [--repo <ns>/<name>] [--org <slug>]');
|
|
251
305
|
return 1;
|
|
252
306
|
}
|
|
253
307
|
const ctx = await buildContext(args);
|
|
@@ -280,9 +334,12 @@ export async function secretsAttachCommand(args) {
|
|
|
280
334
|
}
|
|
281
335
|
export async function secretsDetachCommand(args) {
|
|
282
336
|
const name = args.positional[0];
|
|
337
|
+
if (name && typeof args.flags.stage === 'string')
|
|
338
|
+
return secretsDetachFromStage(args, name);
|
|
283
339
|
const fnSlug = typeof args.flags.fn === 'string' ? args.flags.fn : args.positional[1];
|
|
284
340
|
if (!name || !fnSlug) {
|
|
285
|
-
console.error('usage: seq-studio secrets detach <NAME> --fn <slug> -e <env> [--org <slug>]'
|
|
341
|
+
console.error('usage: seq-studio secrets detach <NAME> --fn <slug> -e <env> [--org <slug>]\n' +
|
|
342
|
+
' seq-studio secrets detach <NAME> --stage <slug> -e <env> [--target <id>] [--credential <name>] [--repo <ns>/<name>]');
|
|
286
343
|
return 1;
|
|
287
344
|
}
|
|
288
345
|
const ctx = await buildContext(args);
|
|
@@ -705,6 +762,10 @@ export const SECRETS_USAGE = `usage:
|
|
|
705
762
|
mount default on a function env var
|
|
706
763
|
seq-studio secrets detach <NAME> --fn <slug> -e <env> [--org <slug>]
|
|
707
764
|
remove attachment
|
|
765
|
+
seq-studio secrets attach <NAME> --stage <slug> -e <env> [--target <id>] [--credential <name>]
|
|
766
|
+
attach to a pipeline stage's credential for one deploy target
|
|
767
|
+
seq-studio secrets detach <NAME> --stage <slug> -e <env> [--target <id>] [--credential <name>]
|
|
768
|
+
remove it (the stage's copy is deleted now)
|
|
708
769
|
seq-studio secrets apply --from-env-file .env -e <env> push defaults + attach (keys default from manifest)
|
|
709
770
|
seq-studio secrets versions <NAME> -e <env> [--org <slug>] value version history (never values)
|
|
710
771
|
seq-studio secrets set-default <NAME> [version] -e <env> [--org <slug>]
|
|
@@ -717,10 +778,19 @@ export const SECRETS_USAGE = `usage:
|
|
|
717
778
|
Use \`secrets\` commands for CI (no .env), bulk/multi-function ops, or write-only
|
|
718
779
|
value changes without a redeploy.
|
|
719
780
|
|
|
781
|
+
Pipelines: managed secrets are the preferred way to give a stage a credential.
|
|
782
|
+
Declare source.credential in the stage spec and read it in code with
|
|
783
|
+
pipeline_runtime.get_credential("<name>"). \`seq-studio pipeline plan|deploy\`
|
|
784
|
+
attaches the secret named by convention (abrigo_oauth -> ABRIGO_OAUTH) when
|
|
785
|
+
you can edit it (stages already deployed the legacy way are left alone); use
|
|
786
|
+
\`secrets attach --stage\` for any other name.
|
|
787
|
+
|
|
720
788
|
Flags: -e/--env <env> (required; see: seq-studio envs list)
|
|
721
789
|
--org <slug> (target/select managed-scope org; required when a name exists in multiple orgs)
|
|
722
790
|
set: --from-file <path> (non-interactive; file is not echoed)
|
|
723
791
|
--fn <slug> · --env-var <NAME> · --yes
|
|
792
|
+
--stage <slug> · --target <id> (deploy target; default from -e) · --credential <name>
|
|
793
|
+
(the spec's source.credential; default: NAME lowercased) · --repo <ns>/<name> (disambiguate)
|
|
724
794
|
--functions <f1,f2> · --keys <K1,K2> · --all (override key selection)
|
|
725
795
|
set-default: [version|version-row-id] (defaults to the most recent non-default) · --yes
|
|
726
796
|
pin: [version|version-row-id] (defaults to the current default) · --unpin · --yes (redeploy) · --yes --no-redeploy
|