@sequenceholdings/studio-cli 0.1.30 → 0.1.35
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 +225 -16
- 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 +1 -1
- package/dist/repos/commands.js +15 -7
- 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 +2 -0
- package/package.json +9 -7
- package/templates/process/pnpm-workspace.yaml +2 -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
|
@@ -96,6 +96,6 @@ export declare function reposCiRequireCommand(args: ParsedArgs): Promise<number>
|
|
|
96
96
|
export declare function reposCiImportCommand(args: ParsedArgs): Promise<number>;
|
|
97
97
|
export declare function reposCiCommand(args: ParsedArgs): Promise<number>;
|
|
98
98
|
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] [--
|
|
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] [--output dir] [--force]\n seq-studio repos clone --url <https://\u2026/repos/<id>/git> -e <env> [--ref r] [--output dir]\n seq-studio repos clone --id <uuid> -e <env> [--ref r] [--output dir]\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 clone then checkout).\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
100
|
export declare function runReposCommand(sub: string | undefined, args: ParsedArgs): Promise<number>;
|
|
101
101
|
export {};
|
package/dist/repos/commands.js
CHANGED
|
@@ -342,6 +342,12 @@ export async function reposPullCommand(args) {
|
|
|
342
342
|
export async function reposCloneCommand(args, deps = {}) {
|
|
343
343
|
const force = flagBool(args.flags, 'force');
|
|
344
344
|
const ref = stringFlag(args.flags, 'ref');
|
|
345
|
+
const outputFlag = stringFlag(args.flags, 'output');
|
|
346
|
+
const outFlag = stringFlag(args.flags, 'out');
|
|
347
|
+
if (outputFlag !== undefined && outFlag !== undefined) {
|
|
348
|
+
throw new Error('Pass only one of --output or --out.');
|
|
349
|
+
}
|
|
350
|
+
const output = outputFlag ?? outFlag;
|
|
345
351
|
const pat = resolveGitPatFromEnv();
|
|
346
352
|
const urlFlag = stringFlag(args.flags, 'url');
|
|
347
353
|
const idFlag = stringFlag(args.flags, 'id');
|
|
@@ -367,7 +373,7 @@ export async function reposCloneCommand(args, deps = {}) {
|
|
|
367
373
|
const targetUrl = urlFlag
|
|
368
374
|
? normalizeCloneUrl(urlFlag, env)
|
|
369
375
|
: cloneUrl({ env, token: '' }, idFlag);
|
|
370
|
-
const destDir = resolve(
|
|
376
|
+
const destDir = resolve(output ?? defaultOutFromCloneTarget({ url: targetUrl, id: idFlag }));
|
|
371
377
|
prepareCloneDest({ destDir, force });
|
|
372
378
|
const clone = deps.gitClone ?? runGitClone;
|
|
373
379
|
await clone({
|
|
@@ -384,7 +390,7 @@ export async function reposCloneCommand(args, deps = {}) {
|
|
|
384
390
|
// <ns>/<name> path — needs Auth0 for resolveRepo (JSON API) whether or not
|
|
385
391
|
// we then use smart-HTTP. Without Auth0, point users at --url from the UI.
|
|
386
392
|
if (!positional) {
|
|
387
|
-
console.error('usage: seq-studio repos clone <ns>/<name> | --url <clone-url> | --id <uuid> -e <env> [--ref r] [--
|
|
393
|
+
console.error('usage: seq-studio repos clone <ns>/<name> | --url <clone-url> | --id <uuid> -e <env> [--ref r] [--output dir]');
|
|
388
394
|
return 1;
|
|
389
395
|
}
|
|
390
396
|
const { namespace, name } = parseRepoPath(positional);
|
|
@@ -406,7 +412,7 @@ export async function reposCloneCommand(args, deps = {}) {
|
|
|
406
412
|
throw new Error(lines.join('\n'));
|
|
407
413
|
}
|
|
408
414
|
const ctx = await reposContext(args);
|
|
409
|
-
const destDir = resolve(
|
|
415
|
+
const destDir = resolve(output ?? name);
|
|
410
416
|
if (pat) {
|
|
411
417
|
prepareCloneDest({ destDir, force });
|
|
412
418
|
const resolved = await resolveRepo({ ...clientOptions(ctx), namespace, name });
|
|
@@ -775,9 +781,9 @@ export const REPOS_USAGE = `usage:
|
|
|
775
781
|
seq-studio repos create <ns>/<name> -e <env> [--default-branch b] [--git-backend gcs_isomorphic|walgit]
|
|
776
782
|
create a repo (GCS default, seed README;
|
|
777
783
|
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] [--
|
|
784
|
+
seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--output dir] [--force]
|
|
785
|
+
seq-studio repos clone --url <https://…/repos/<id>/git> -e <env> [--ref r] [--output dir]
|
|
786
|
+
seq-studio repos clone --id <uuid> -e <env> [--ref r] [--output dir]
|
|
781
787
|
smart-HTTP when ATLAS_GIT_PAT is set;
|
|
782
788
|
otherwise JSON materialize (<ns>/<name>)
|
|
783
789
|
seq-studio repos pull <ns>/<name> -e <env> [--ref r] [--out dir] [--force]
|
|
@@ -792,8 +798,10 @@ export const REPOS_USAGE = `usage:
|
|
|
792
798
|
clone prefers real git clone (PAT via askpass — never written into the remote
|
|
793
799
|
URL). Without ATLAS_GIT_PAT, <ns>/<name> falls back to the JSON API and prints
|
|
794
800
|
how to get a PAT (seq-studio or Atlas UI /settings/tokens).
|
|
795
|
-
PAT without Auth0 login: use --
|
|
801
|
+
PAT without Auth0 login: use --id from Repositories → Clone
|
|
802
|
+
(or --url with the environment's canonical HTTPS origin).
|
|
796
803
|
--ref accepts a branch, tag, or commit SHA (SHA → clone then checkout).
|
|
804
|
+
--output selects the clone directory (--out remains an alias).
|
|
797
805
|
|
|
798
806
|
Authenticate JSON API calls with: seq-studio login
|
|
799
807
|
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
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { createReadStream, createWriteStream } from 'node:fs';
|
|
2
|
+
import { readFile, stat, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { basename, resolve } from 'node:path';
|
|
4
|
+
import { Readable } from 'node:stream';
|
|
5
|
+
import { pipeline } from 'node:stream/promises';
|
|
6
|
+
import { randomUUID } from 'node:crypto';
|
|
7
|
+
import { load as yaml } from 'js-yaml';
|
|
8
|
+
import { storageClient, workspaceManifestSchema, startUploadSchema, updateStorageAccessSchema, } from '@sequenceholdings/storage';
|
|
9
|
+
import { getAccessTokenWithMode } from '../auth.js';
|
|
10
|
+
import { resolveEnvWithDiscovery } from '../config.js';
|
|
11
|
+
import { getJson, postJson, putJson, patchJson, deleteJson, } from '../atlas-client.js';
|
|
12
|
+
import { printCliError } from '../cli-errors.js';
|
|
13
|
+
import { REQUIRE_EXPLICIT_ENV_MESSAGE } from '../env-flags.js';
|
|
14
|
+
const usage = `usage:
|
|
15
|
+
seq-studio storage init <workspace-name> [--out workspace.yml]
|
|
16
|
+
seq-studio storage validate [workspace.yml]
|
|
17
|
+
seq-studio storage apply [workspace.yml] -e <env>
|
|
18
|
+
seq-studio storage list -e <env> [--workspace <id>] [--parent <id>] [--trash] [--cursor <cursor>]
|
|
19
|
+
seq-studio storage show --workspace <id> [--node <id>] -e <env>
|
|
20
|
+
seq-studio storage mkdir <name> --workspace <id> [--parent <id>] -e <env>
|
|
21
|
+
seq-studio storage upload <file> --workspace <id> [--path <path>] [--parent <id>] [--replace <file-id> --revision <n>] [--resume <upload-id>] -e <env>
|
|
22
|
+
seq-studio storage download --workspace <id> --node <id> --out <file> [--version <id>] -e <env>
|
|
23
|
+
seq-studio storage trash|restore|purge --workspace <id> --node <id> --revision <n> [-e <env>] [--yes]
|
|
24
|
+
seq-studio storage access --workspace <id> [--node <id>] [--file <access.json>] -e <env>
|
|
25
|
+
seq-studio storage operations --workspace <id> [--retry <operation-id>] -e <env>
|
|
26
|
+
seq-studio storage abort --workspace <id> --upload <id> -e <env>
|
|
27
|
+
seq-studio storage delete --workspace <id> --revision <n> --yes -e <env>
|
|
28
|
+
|
|
29
|
+
Workspaces are provisioned from YAML; paths create folders at upload time.
|
|
30
|
+
Uploads print their session ID to stderr for retry. Resume uses the same original file.
|
|
31
|
+
Use -e local or -e local:<worktree> for the standard local Atlas target.`;
|
|
32
|
+
export async function runStorageCommand(sub, args) {
|
|
33
|
+
if (!sub || sub === 'help' || args.flags.help) {
|
|
34
|
+
console.log(usage);
|
|
35
|
+
return sub ? 0 : 1;
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const flag = (name) => typeof args.flags[name] === 'string' ? args.flags[name] : undefined;
|
|
39
|
+
const required = (name) => {
|
|
40
|
+
const value = flag(name);
|
|
41
|
+
if (!value)
|
|
42
|
+
throw new Error(`--${name} is required`);
|
|
43
|
+
return value;
|
|
44
|
+
};
|
|
45
|
+
const print = (value) => console.log(JSON.stringify(value, null, 2));
|
|
46
|
+
if (sub === 'init') {
|
|
47
|
+
const name = args.positional[0];
|
|
48
|
+
const manifest = workspaceManifestSchema.parse({ workspace: { name } });
|
|
49
|
+
const output = resolve(flag('out') ?? 'workspace.yml');
|
|
50
|
+
await writeFile(output, `workspace:\n name: ${manifest.workspace.name}\n description: ""\n`, { flag: 'wx' });
|
|
51
|
+
console.log(output);
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
const manifest = sub === 'validate' || sub === 'apply'
|
|
55
|
+
? workspaceManifestSchema.parse(yaml(await readFile(resolve(args.positional[0] ?? 'workspace.yml'), 'utf8')))
|
|
56
|
+
: null;
|
|
57
|
+
if (sub === 'validate') {
|
|
58
|
+
console.log('Workspace manifest is valid');
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
if (!flag('env'))
|
|
62
|
+
throw new Error(REQUIRE_EXPLICIT_ENV_MESSAGE);
|
|
63
|
+
const env = await resolveEnvWithDiscovery({ requested: flag('env') });
|
|
64
|
+
const { token } = await getAccessTokenWithMode({
|
|
65
|
+
env: env.name,
|
|
66
|
+
targetUrl: env.url,
|
|
67
|
+
});
|
|
68
|
+
const client = storageClient({
|
|
69
|
+
async request(method, path, body) {
|
|
70
|
+
const options = { baseUrl: env.url, token, path, body };
|
|
71
|
+
switch (method) {
|
|
72
|
+
case 'GET':
|
|
73
|
+
return getJson(options);
|
|
74
|
+
case 'POST':
|
|
75
|
+
return postJson(options);
|
|
76
|
+
case 'PUT':
|
|
77
|
+
return putJson(options);
|
|
78
|
+
case 'PATCH':
|
|
79
|
+
return patchJson(options);
|
|
80
|
+
case 'DELETE':
|
|
81
|
+
return deleteJson(options);
|
|
82
|
+
default:
|
|
83
|
+
throw new Error('Unsupported storage method');
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
if (sub === 'apply' && manifest) {
|
|
88
|
+
print(await client.apply(manifest));
|
|
89
|
+
return 0;
|
|
90
|
+
}
|
|
91
|
+
const list = {
|
|
92
|
+
cursor: flag('cursor'),
|
|
93
|
+
q: flag('q'),
|
|
94
|
+
limit: flag('limit') ? Number(flag('limit')) : undefined,
|
|
95
|
+
};
|
|
96
|
+
if (sub === 'list' && !flag('workspace')) {
|
|
97
|
+
print(await client.list(list));
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
const workspace = client.workspace(required('workspace'));
|
|
101
|
+
const revision = () => {
|
|
102
|
+
const n = Number(required('revision'));
|
|
103
|
+
if (!Number.isInteger(n) || n < 0)
|
|
104
|
+
throw new Error('--revision must be a nonnegative integer');
|
|
105
|
+
return n;
|
|
106
|
+
};
|
|
107
|
+
switch (sub) {
|
|
108
|
+
case 'list':
|
|
109
|
+
print(await workspace.list({
|
|
110
|
+
...list,
|
|
111
|
+
parentId: flag('parent'),
|
|
112
|
+
trash: args.flags.trash === true,
|
|
113
|
+
}));
|
|
114
|
+
break;
|
|
115
|
+
case 'show':
|
|
116
|
+
print(flag('node')
|
|
117
|
+
? await workspace.getNode(required('node'))
|
|
118
|
+
: await workspace.get());
|
|
119
|
+
break;
|
|
120
|
+
case 'mkdir': {
|
|
121
|
+
if (!args.positional[0])
|
|
122
|
+
throw new Error('Folder name is required');
|
|
123
|
+
print(await workspace.createFolder(args.positional[0], flag('parent') ?? null));
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case 'upload': {
|
|
127
|
+
if (!args.positional[0])
|
|
128
|
+
throw new Error('Source file is required');
|
|
129
|
+
const file = resolve(args.positional[0]);
|
|
130
|
+
const info = await stat(file);
|
|
131
|
+
if (!info.isFile())
|
|
132
|
+
throw new Error('Upload source must be a regular file');
|
|
133
|
+
const session = flag('resume')
|
|
134
|
+
? await workspace.uploads.get(required('resume'))
|
|
135
|
+
: await workspace.uploads.start(startUploadSchema.parse({
|
|
136
|
+
path: flag('path') ?? basename(file),
|
|
137
|
+
parentId: flag('parent') ?? null,
|
|
138
|
+
size: info.size,
|
|
139
|
+
fileId: flag('replace'),
|
|
140
|
+
expectedRevision: flag('replace') ? revision() : undefined,
|
|
141
|
+
contentType: flag('content-type') ?? 'application/octet-stream',
|
|
142
|
+
idempotencyKey: flag('idempotency-key') ?? randomUUID(),
|
|
143
|
+
}));
|
|
144
|
+
console.error(`Upload session: ${session.id}`);
|
|
145
|
+
const controller = new AbortController();
|
|
146
|
+
const cancel = () => controller.abort();
|
|
147
|
+
process.once('SIGINT', cancel);
|
|
148
|
+
try {
|
|
149
|
+
print(await workspace.uploads.resume(session.id, createReadStream(file), {
|
|
150
|
+
size: info.size,
|
|
151
|
+
signal: controller.signal,
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
process.removeListener('SIGINT', cancel);
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case 'download': {
|
|
160
|
+
const output = resolve(required('out'));
|
|
161
|
+
const signed = await workspace.download(required('node'), {
|
|
162
|
+
versionId: flag('version'),
|
|
163
|
+
});
|
|
164
|
+
const response = await fetch(signed.url, { redirect: 'error' });
|
|
165
|
+
if (!response.ok || !response.body)
|
|
166
|
+
throw new Error(`Download failed (${response.status})`);
|
|
167
|
+
await pipeline(Readable.fromWeb(response.body), createWriteStream(output, { flags: 'wx' }));
|
|
168
|
+
console.log(output);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
case 'trash':
|
|
172
|
+
print(await workspace.trash(required('node'), revision()));
|
|
173
|
+
break;
|
|
174
|
+
case 'restore':
|
|
175
|
+
print(await workspace.restore(required('node'), revision()));
|
|
176
|
+
break;
|
|
177
|
+
case 'purge':
|
|
178
|
+
if (args.flags.yes !== true)
|
|
179
|
+
throw new Error('Permanent deletion requires --yes; trash is recoverable until purge');
|
|
180
|
+
print(await workspace.purge(required('node'), revision()));
|
|
181
|
+
break;
|
|
182
|
+
case 'delete':
|
|
183
|
+
if (args.flags.yes !== true)
|
|
184
|
+
throw new Error('Workspace deletion requires --yes and permanently deletes its files and history');
|
|
185
|
+
print(await workspace.delete(revision()));
|
|
186
|
+
break;
|
|
187
|
+
case 'access': {
|
|
188
|
+
const input = flag('file')
|
|
189
|
+
? updateStorageAccessSchema.parse(JSON.parse(await readFile(required('file'), 'utf8')))
|
|
190
|
+
: null;
|
|
191
|
+
print(input
|
|
192
|
+
? await workspace.setAccess(input, flag('node'))
|
|
193
|
+
: await workspace.access(flag('node')));
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
case 'operations':
|
|
197
|
+
print(flag('retry')
|
|
198
|
+
? await workspace.retryOperation(required('retry'))
|
|
199
|
+
: await workspace.operations({ before: flag('cursor') }));
|
|
200
|
+
break;
|
|
201
|
+
case 'abort': {
|
|
202
|
+
const aborted = await workspace.uploads.abort(required('upload'));
|
|
203
|
+
print({ id: aborted.id, state: aborted.state });
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
default:
|
|
207
|
+
throw new Error(`Unknown storage command: ${sub}\n${usage}`);
|
|
208
|
+
}
|
|
209
|
+
return 0;
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
printCliError(error);
|
|
213
|
+
return 1;
|
|
214
|
+
}
|
|
215
|
+
}
|