@sequenceholdings/studio-cli 0.1.26 → 0.1.28
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 +265 -81
- package/dist/app/adapters.d.ts +9 -0
- package/dist/app/adapters.js +176 -0
- package/dist/app/commands.d.ts +2 -2
- package/dist/app/commands.js +98 -22
- package/dist/app/deploy.d.ts +9 -10
- package/dist/app/deploy.js +83 -141
- package/dist/app/graph.d.ts +15 -0
- package/dist/app/graph.js +36 -0
- package/dist/app/manifest-validation.d.ts +16 -0
- package/dist/app/manifest-validation.js +99 -0
- package/dist/app/manifest.d.ts +27 -9
- package/dist/app/manifest.js +23 -107
- package/dist/app/paths.d.ts +14 -0
- package/dist/app/paths.js +77 -0
- package/dist/app/primitive-scaffold.d.ts +18 -0
- package/dist/app/primitive-scaffold.js +136 -0
- package/dist/app/readme.d.ts +4 -18
- package/dist/app/readme.js +107 -229
- package/dist/app/run-deployment.d.ts +8 -0
- package/dist/app/run-deployment.js +50 -0
- package/dist/app/scaffold-files.d.ts +13 -0
- package/dist/app/scaffold-files.js +68 -0
- package/dist/app/scaffold.d.ts +11 -3
- package/dist/app/scaffold.js +77 -245
- package/dist/app/workspace-compile.d.ts +18 -0
- package/dist/app/workspace-compile.js +143 -0
- package/dist/app/workspace-model.d.ts +70 -0
- package/dist/app/workspace-model.js +159 -0
- package/dist/app/workspace-scaffold.d.ts +27 -0
- package/dist/app/workspace-scaffold.js +126 -0
- package/dist/app/workspace.d.ts +14 -0
- package/dist/app/workspace.js +147 -0
- package/dist/atlas-client.js +28 -6
- package/dist/auth-cmds/commands.d.ts +1 -1
- package/dist/auth-cmds/commands.js +5 -2
- package/dist/functions/commands.js +7 -1
- package/dist/functions/manifest.d.ts +18 -0
- package/dist/functions/manifest.js +29 -4
- package/dist/main.js +9 -4
- package/dist/orm/delegate.js +30 -23
- package/dist/pat-hints.js +1 -0
- package/dist/pipeline/commands.js +27 -9
- package/dist/pipeline/lifecycle.d.ts +2 -0
- package/dist/pipeline/lifecycle.js +91 -11
- package/dist/process/build.js +59 -43
- package/dist/process/codegen.d.ts +3 -2
- package/dist/process/codegen.js +143 -27
- package/dist/process/commands.d.ts +2 -0
- package/dist/process/commands.js +63 -18
- package/dist/process/discover.d.ts +6 -3
- package/dist/process/discover.js +11 -3
- package/dist/process/lint.d.ts +14 -0
- package/dist/process/lint.js +143 -5
- package/dist/process/plan-diff.d.ts +8 -0
- package/dist/process/plan-diff.js +61 -4
- package/dist/process/safety-baseline.d.ts +154 -0
- package/dist/process/safety-baseline.js +387 -0
- package/dist/process/simulate.js +64 -22
- package/dist/repos/commands.d.ts +1 -1
- package/dist/repos/commands.js +29 -3
- package/package.json +8 -7
|
@@ -8,8 +8,14 @@ import { z } from 'zod';
|
|
|
8
8
|
export const MF_MANIFEST_FILENAME = 'managed-function.yml';
|
|
9
9
|
const SECRET_NAME_RE = /^[A-Z][A-Z0-9_]*$/;
|
|
10
10
|
export const managedFunctionAuthorizationAdapterSchema = z.enum([
|
|
11
|
+
'encompass.global-metadata-read',
|
|
12
|
+
'encompass.loan-attachment-read',
|
|
13
|
+
'encompass.loan-document-read',
|
|
14
|
+
'encompass.loan-fields-read',
|
|
15
|
+
'encompass.loan-folder-read',
|
|
11
16
|
'encompass.loan-read-by-guid',
|
|
12
17
|
'encompass.loan-read-by-number',
|
|
18
|
+
'encompass.loan-read-full',
|
|
13
19
|
'encompass.loan-search',
|
|
14
20
|
]);
|
|
15
21
|
export const managedFunctionAuthorizationSchema = z
|
|
@@ -19,9 +25,29 @@ export const managedFunctionAuthorizationSchema = z
|
|
|
19
25
|
})
|
|
20
26
|
.strict();
|
|
21
27
|
const AUTHORIZATION_ADAPTER_BY_FUNCTION_ID = {
|
|
28
|
+
'encompass-get-attachment': 'encompass.loan-attachment-read',
|
|
29
|
+
'encompass-get-attachments-for-document': 'encompass.loan-attachment-read',
|
|
22
30
|
'encompass-get-common-loan-fields': 'encompass.loan-read-by-guid',
|
|
31
|
+
'encompass-get-document': 'encompass.loan-document-read',
|
|
32
|
+
'encompass-get-document-by-name': 'encompass.loan-document-read',
|
|
33
|
+
'encompass-get-document-folder': 'encompass.loan-document-read',
|
|
34
|
+
'encompass-get-field-info': 'encompass.global-metadata-read',
|
|
35
|
+
'encompass-get-loan': 'encompass.loan-read-full',
|
|
23
36
|
'encompass-get-loan-by-number': 'encompass.loan-read-by-number',
|
|
37
|
+
'encompass-get-loan-fields': 'encompass.loan-fields-read',
|
|
38
|
+
'encompass-get-loan-folder': 'encompass.loan-folder-read',
|
|
39
|
+
'encompass-get-loan-folder-settings': 'encompass.global-metadata-read',
|
|
40
|
+
'encompass-get-pipeline-canonical-names': 'encompass.global-metadata-read',
|
|
41
|
+
'encompass-get-schema-status': 'encompass.global-metadata-read',
|
|
42
|
+
'encompass-get-stacking-template': 'encompass.global-metadata-read',
|
|
43
|
+
'encompass-get-stacking-template-by-name': 'encompass.global-metadata-read',
|
|
44
|
+
'encompass-list-attachments': 'encompass.loan-attachment-read',
|
|
45
|
+
'encompass-list-documents': 'encompass.loan-document-read',
|
|
46
|
+
'encompass-list-loan-folder-settings': 'encompass.global-metadata-read',
|
|
47
|
+
'encompass-list-stacking-templates': 'encompass.global-metadata-read',
|
|
48
|
+
'encompass-search-fields': 'encompass.global-metadata-read',
|
|
24
49
|
'encompass-search-pipeline': 'encompass.loan-search',
|
|
50
|
+
'encompass-validate-field': 'encompass.global-metadata-read',
|
|
25
51
|
};
|
|
26
52
|
/** RFC 1035 label: alnum, optional inner dashes, max 63 chars. */
|
|
27
53
|
const DNS_LABEL_RE = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
@@ -570,7 +596,7 @@ export const managedFunctionManifestSchema = z.object({
|
|
|
570
596
|
.object({
|
|
571
597
|
memory_mb: z.number().int().min(128).max(2048).default(256),
|
|
572
598
|
timeout_seconds: z.number().int().min(1).max(540).default(60),
|
|
573
|
-
min_instances: z.number().int().min(0).max(10).default(
|
|
599
|
+
min_instances: z.number().int().min(0).max(10).default(1),
|
|
574
600
|
max_instances: z.number().int().min(1).max(10).default(3),
|
|
575
601
|
invoke_rate_per_minute: z.number().int().min(1).max(600).default(60),
|
|
576
602
|
})
|
|
@@ -586,7 +612,7 @@ export const managedFunctionManifestSchema = z.object({
|
|
|
586
612
|
.default({
|
|
587
613
|
memory_mb: 256,
|
|
588
614
|
timeout_seconds: 60,
|
|
589
|
-
min_instances:
|
|
615
|
+
min_instances: 1,
|
|
590
616
|
max_instances: 3,
|
|
591
617
|
invoke_rate_per_minute: 60,
|
|
592
618
|
}),
|
|
@@ -730,8 +756,7 @@ export const managedFunctionManifestSchema = z.object({
|
|
|
730
756
|
ctx.addIssue({
|
|
731
757
|
code: 'custom',
|
|
732
758
|
message: 'capabilities.data requires a top-level service_account — the platform service ' +
|
|
733
|
-
'account this function acts as for ORM data access (
|
|
734
|
-
'the account; the deployer needs the actor role on it)',
|
|
759
|
+
'account this function acts as for ORM data access (the deployer needs the actor role on it)',
|
|
735
760
|
path: ['service_account'],
|
|
736
761
|
});
|
|
737
762
|
}
|
package/dist/main.js
CHANGED
|
@@ -35,7 +35,7 @@ const TOP_LEVEL_USAGE = `usage:
|
|
|
35
35
|
seq-studio repos <sub> [args] list | namespaces | show | create | clone | pull | delete
|
|
36
36
|
seq-studio pipeline <sub> [args] init | validate — Data Pipelines stage specs
|
|
37
37
|
seq-studio auth <sub> [args] pat create | pat list | pat revoke
|
|
38
|
-
seq-studio orm <sub> [args] init | validate | plan | apply
|
|
38
|
+
seq-studio orm <sub> [args] init | generate | validate | plan | apply | execute | diff | migrate-from-yaml
|
|
39
39
|
seq-studio envs <sub> add | list | refresh environments
|
|
40
40
|
seq-studio login [--env <name>] authenticate in the browser
|
|
41
41
|
seq-studio logout [--env <name>] remove one realm's cached user tokens
|
|
@@ -49,9 +49,9 @@ const TOP_LEVEL_USAGE = `usage:
|
|
|
49
49
|
`;
|
|
50
50
|
const PROCESS_USAGE = `usage:
|
|
51
51
|
seq-studio process init <dir>
|
|
52
|
-
seq-studio process lint
|
|
53
|
-
seq-studio process plan [-e <env>]
|
|
54
|
-
seq-studio process apply [-e <env>] [--only <id1,id2,...>]
|
|
52
|
+
seq-studio process lint [--dir <path>] [--offline]
|
|
53
|
+
seq-studio process plan [--dir <path>] [-e <env>]
|
|
54
|
+
seq-studio process apply [--dir <path>] [-e <env>] [--only <id1,id2,...>]
|
|
55
55
|
seq-studio process apply --repo processes/<name> [--ref <r>] -e <env> [--only <id1,id2,...>]
|
|
56
56
|
seq-studio process promote <processId> --version <v> [-e <env>]
|
|
57
57
|
seq-studio process pull <processId> [--version <v>] [-e <env>] [--out <dir>] [--no-children]
|
|
@@ -63,6 +63,7 @@ const PROCESS_USAGE = `usage:
|
|
|
63
63
|
seq-studio process bundle inspect <bundle.json>
|
|
64
64
|
seq-studio process bundle list [-e <env>] [--limit N] [--cursor <hash>]
|
|
65
65
|
seq-studio process bundle publish <hash|bundle.json> [-e <env>]
|
|
66
|
+
seq-studio process safety-baseline [--repo-root <dir>] [--write]
|
|
66
67
|
`;
|
|
67
68
|
export async function run(argv = process.argv.slice(2)) {
|
|
68
69
|
const [namespace, sub, ...rest] = argv;
|
|
@@ -202,6 +203,10 @@ async function runProcessNamespace(sub, rest) {
|
|
|
202
203
|
positional: args.positional.slice(1),
|
|
203
204
|
flags: args.flags,
|
|
204
205
|
});
|
|
206
|
+
case 'safety-baseline': {
|
|
207
|
+
const { safetyBaselineCommand } = await import('./process/safety-baseline.js');
|
|
208
|
+
return safetyBaselineCommand({ flags: args.flags });
|
|
209
|
+
}
|
|
205
210
|
case 'help':
|
|
206
211
|
case '--help':
|
|
207
212
|
case '-h':
|
package/dist/orm/delegate.js
CHANGED
|
@@ -13,13 +13,15 @@ import { REQUIRE_EXPLICIT_ENV_MESSAGE } from '../env-flags.js';
|
|
|
13
13
|
* ORM subcommands that talk to Atlas — must not silently target `local`.
|
|
14
14
|
* `init`, `generate`, `validate`, `diff`, and `migrate-from-yaml` are offline.
|
|
15
15
|
*/
|
|
16
|
-
const ORM_NETWORK_SUBS = new Set(['plan', 'apply']);
|
|
16
|
+
const ORM_NETWORK_SUBS = new Set(['plan', 'apply', 'execute']);
|
|
17
17
|
const ORM_USAGE = `usage:
|
|
18
18
|
seq-studio orm init <dir> scaffold a namespace package (v2: TypeScript schema + GraphQL documents)
|
|
19
19
|
seq-studio orm generate [dir] write schema.graphql + operations.manifest.json + typePolicies.gen.ts (offline; runs consumer codegen when codegen.ts is present)
|
|
20
20
|
seq-studio orm validate [dir] parse + validate definitions and verify committed migrations are in sync
|
|
21
21
|
seq-studio orm plan [dir] -e <env> compile definitions and diff against the registry
|
|
22
22
|
seq-studio orm apply [dir] -e <env> author the migration, register, apply, and refresh the generated outputs (the everyday command)
|
|
23
|
+
seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
|
|
24
|
+
execute one named persisted operation as the signed-in caller
|
|
23
25
|
seq-studio orm diff [dir] write/verify the committed migration standalone (--check is the offline CI gate; --allow-destructive consents; --rebase records a v1 -> v2 conversion)
|
|
24
26
|
seq-studio orm migrate-from-yaml <dir> convert a v1 YAML namespace to the v2 TypeScript format (offline; migrations/ preserved)
|
|
25
27
|
|
|
@@ -39,12 +41,35 @@ export function isOrmPackageMissing(message) {
|
|
|
39
41
|
const specifier = message.match(/Cannot find (?:package|module) '([^']+)'/)?.[1];
|
|
40
42
|
return specifier === '@sequenceholdings/orm' || (specifier?.startsWith('@sequenceholdings/orm/') ?? false);
|
|
41
43
|
}
|
|
44
|
+
async function loadOrmCli() {
|
|
45
|
+
try {
|
|
46
|
+
return await import('@sequenceholdings/orm/cli');
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
if (err.code !== 'ERR_MODULE_NOT_FOUND')
|
|
50
|
+
throw err;
|
|
51
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
52
|
+
if (isOrmPackageMissing(message)) {
|
|
53
|
+
console.error('seq-studio orm needs the @sequenceholdings/orm package. Install it alongside the CLI:\n' +
|
|
54
|
+
' npm install @sequenceholdings/orm');
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
console.error('@sequenceholdings/orm is installed but a dependency failed to load. Reinstall dependencies, then retry.\n' +
|
|
58
|
+
` ${message}`);
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
42
63
|
export async function runOrmCommand(sub, rest) {
|
|
43
64
|
if (!sub || sub === 'help' || sub === '--help' || sub === '-h') {
|
|
44
65
|
console.log(ORM_USAGE);
|
|
45
66
|
return sub ? 0 : 1;
|
|
46
67
|
}
|
|
47
68
|
const normalized = normalizeShortEnvFlag(rest);
|
|
69
|
+
if (normalized.includes('--help') || normalized.includes('-h')) {
|
|
70
|
+
const ormCli = await loadOrmCli();
|
|
71
|
+
return ormCli ? ormCli.runCli([sub, ...normalized]) : 1;
|
|
72
|
+
}
|
|
48
73
|
const requested = readEnvFromArgv(normalized);
|
|
49
74
|
if (ORM_NETWORK_SUBS.has(sub) && !requested) {
|
|
50
75
|
console.error(`[seq-studio] ${REQUIRE_EXPLICIT_ENV_MESSAGE}`);
|
|
@@ -63,28 +88,10 @@ export async function runOrmCommand(sub, rest) {
|
|
|
63
88
|
});
|
|
64
89
|
if (token)
|
|
65
90
|
process.env['SEQUENCE_ORM_TOKEN'] = token;
|
|
66
|
-
// Lazy import keeps `process`/`doctor` from pulling in the
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
ormCli = await import('@sequenceholdings/orm/cli');
|
|
72
|
-
}
|
|
73
|
-
catch (err) {
|
|
74
|
-
if (err.code === 'ERR_MODULE_NOT_FOUND') {
|
|
75
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
76
|
-
if (isOrmPackageMissing(message)) {
|
|
77
|
-
console.error('seq-studio orm needs the @sequenceholdings/orm package. Install it alongside the CLI:\n' +
|
|
78
|
-
' npm install @sequenceholdings/orm');
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
console.error('@sequenceholdings/orm is installed but a dependency failed to load. Reinstall dependencies, then retry.\n' +
|
|
82
|
-
` ${message}`);
|
|
83
|
-
}
|
|
84
|
-
return 1;
|
|
85
|
-
}
|
|
86
|
-
throw err;
|
|
87
|
-
}
|
|
91
|
+
// Lazy import keeps `process`/`doctor` from pulling in the optional ORM package.
|
|
92
|
+
const ormCli = await loadOrmCli();
|
|
93
|
+
if (!ormCli)
|
|
94
|
+
return 1;
|
|
88
95
|
const { runCli, setTokenProvider } = ormCli;
|
|
89
96
|
setTokenProvider(async () => {
|
|
90
97
|
try {
|
package/dist/pat-hints.js
CHANGED
|
@@ -19,6 +19,7 @@ export function formatPatSetupHint({ envUrl, envName, indent = ' ', }) {
|
|
|
19
19
|
`${indent}Or create one in Atlas:`,
|
|
20
20
|
`${indent} 1. Open ${tokensUrl} and sign in`,
|
|
21
21
|
`${indent} 2. New token → scopes repo:read (add repo:write for push) → copy once`,
|
|
22
|
+
`${indent} Merge is a repository grant (Merge / Admin), not a PAT scope.`,
|
|
22
23
|
`${indent} 3. export ATLAS_GIT_PAT=<token>`,
|
|
23
24
|
`${indent} 4. Copy the clone URL from Repositories → Clone, then:`,
|
|
24
25
|
`${indent} ATLAS_GIT_PAT=<token> seq-studio repos clone --url <https://…/repos/<id>/git> -e ${envName}`,
|
|
@@ -43,28 +43,42 @@ const PIPELINE_USAGE = `usage:
|
|
|
43
43
|
(no Databricks CLI / DAB validate on Atlas); exit 1 on destructive findings
|
|
44
44
|
|
|
45
45
|
seq-studio pipeline deploy --repo pipelines/<slug> --ref <sha|branch> -e <env>
|
|
46
|
-
[--target <id>] [--approved-by <sub>]
|
|
46
|
+
[--target <id>] [--approved-by <sub>]
|
|
47
|
+
[--allow-destructive <resource-key> ...]
|
|
48
|
+
[--run-now] [--wait-timeout <duration>] [--no-wait] [--json]
|
|
47
49
|
plan then enqueue Trigger deploy (DAB bundle validate hard-gates before
|
|
48
50
|
bundle deploy). Default is plant-only: jobs/pipelines are created, not
|
|
49
|
-
run. Pass --run-now to run in-unit producer roots after bundle deploy
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
run. Pass --run-now to run in-unit producer roots after bundle deploy.
|
|
52
|
+
Serving refresh provisioning completes before producer trigger.after
|
|
53
|
+
tasks can run; failed producer status includes the remote Databricks
|
|
54
|
+
task/event error when available. Use a full 40-hex SHA for explicit
|
|
55
|
+
rollback deployments. --allow-destructive is repeatable and must name
|
|
56
|
+
every deletion/recreation finding; other destructive reasons stay blocked
|
|
57
|
+
|
|
58
|
+
seq-studio pipeline status --deployment-id <id> -e <env> [--json]
|
|
59
|
+
fetch the current status of a remote deployment without changing it
|
|
52
60
|
|
|
53
61
|
seq-studio pipeline promote --stage <slug> --version <v> -e <env>
|
|
54
|
-
[--target <id>] [--repo pipelines/<slug>] [--approved-by <you>]
|
|
62
|
+
[--target <id>] [--repo pipelines/<slug>] [--approved-by <you>]
|
|
63
|
+
[--wait-timeout <duration>] [--no-wait]
|
|
55
64
|
promote a validated version to the next environment (approvals are
|
|
56
65
|
self-recorded: --approved-by must name the authenticated caller)
|
|
57
66
|
|
|
58
67
|
seq-studio pipeline rollback --stage <slug> -e <env> [--target <id>] [--repo pipelines/<slug>]
|
|
59
|
-
[--approved-by <you>] [--no-wait]
|
|
68
|
+
[--approved-by <you>] [--wait-timeout <duration>] [--no-wait]
|
|
60
69
|
redeploy the previously retired deployment's version (production/
|
|
61
70
|
banksouth require --approved-by — approvals are explicit even for
|
|
62
71
|
rollbacks)
|
|
63
72
|
|
|
64
73
|
Unless --no-wait is set, deploy, promote, and rollback report status or
|
|
65
74
|
status-detail changes while waiting, then emit a 20-second progress heartbeat.
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
The default local wait window is 2 hours; --wait-timeout accepts a
|
|
76
|
+
positive duration such as 10m or 2h. A timeout stops only local polling:
|
|
77
|
+
the remote deployment continues, and the output includes its id and an
|
|
78
|
+
exact seq-studio pipeline status command for continued monitoring. Internal
|
|
79
|
+
operators may also use the equivalent seqapi command. Terminal output
|
|
80
|
+
includes the deployment id and elapsed time; it also includes a Trigger run
|
|
81
|
+
id when the deployment provides one.
|
|
68
82
|
|
|
69
83
|
seq-studio pipeline adopt --stage <slug> --ref <sha|branch> -e <env>
|
|
70
84
|
[--target <id>] --native-id <id> [--resource-key <key>] [--kind job|dlt_pipeline]
|
|
@@ -81,7 +95,7 @@ const PIPELINE_USAGE = `usage:
|
|
|
81
95
|
|
|
82
96
|
seq-studio pipeline run-now --stage <slug> -e <env> [--target <id>] [--repo pipelines/<slug>] [--json]
|
|
83
97
|
fire the stage's active deployment resource (job run-now / DLT
|
|
84
|
-
start_update) and print the Databricks run URL
|
|
98
|
+
start_update) and print the Databricks run URL.
|
|
85
99
|
|
|
86
100
|
-e/--env selects the Atlas connection. --target selects the logical target
|
|
87
101
|
advertised by that deployment; it is inferred when the endpoint exposes one target.
|
|
@@ -404,6 +418,10 @@ export async function runPipelineCommand(sub, args) {
|
|
|
404
418
|
const { pipelineDeployCommand } = await import('./lifecycle.js');
|
|
405
419
|
return pipelineDeployCommand(args);
|
|
406
420
|
}
|
|
421
|
+
case 'status': {
|
|
422
|
+
const { pipelineStatusCommand } = await import('./lifecycle.js');
|
|
423
|
+
return pipelineStatusCommand(args);
|
|
424
|
+
}
|
|
407
425
|
case 'promote': {
|
|
408
426
|
const { pipelinePromoteCommand } = await import('./lifecycle.js');
|
|
409
427
|
return pipelinePromoteCommand(args);
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { type ResolvedEnv } from '../config.js';
|
|
6
6
|
import type { ParsedArgs } from '../process/commands.js';
|
|
7
|
+
export declare const DEFAULT_DEPLOYMENT_WAIT_TIMEOUT_MS: number;
|
|
7
8
|
export interface PlanApiResponse {
|
|
8
9
|
plan: {
|
|
9
10
|
hasDestructive: boolean;
|
|
@@ -42,6 +43,7 @@ export interface DeploymentDetail {
|
|
|
42
43
|
export declare function deployEnvironmentForEnv(env: ResolvedEnv): string;
|
|
43
44
|
export declare function pipelinePlanCommand(args: ParsedArgs): Promise<number>;
|
|
44
45
|
export declare function pipelineDeployCommand(args: ParsedArgs): Promise<number>;
|
|
46
|
+
export declare function pipelineStatusCommand(args: ParsedArgs): Promise<number>;
|
|
45
47
|
export declare function pipelinePromoteCommand(args: ParsedArgs): Promise<number>;
|
|
46
48
|
export declare function pipelineRunNowCommand(args: ParsedArgs): Promise<number>;
|
|
47
49
|
export declare function pipelineRollbackCommand(args: ParsedArgs): Promise<number>;
|
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
import { getAccessToken, NotLoggedInError } from '../auth.js';
|
|
6
6
|
import { AtlasApiError, getJson, postJson } from '../atlas-client.js';
|
|
7
7
|
import { resolveEnvWithDiscovery } from '../config.js';
|
|
8
|
+
import { parseDurationMs } from '@sequenceholdings/lattice';
|
|
8
9
|
const LOG = '[seq-studio]';
|
|
9
10
|
const TERMINAL = new Set(['active', 'failed', 'retired']);
|
|
10
11
|
const POLL_INTERVAL_MS = 2000;
|
|
11
12
|
const HEARTBEAT_INTERVAL_MS = 20_000;
|
|
12
13
|
const PLAN_TIMEOUT_MS = 30 * 60 * 1000;
|
|
14
|
+
export const DEFAULT_DEPLOYMENT_WAIT_TIMEOUT_MS = 2 * 60 * 60 * 1000;
|
|
13
15
|
const FIRST_PARTY_TARGETS = [
|
|
14
16
|
{ id: 'dev', label: 'Development', requiresApproval: false },
|
|
15
17
|
{ id: 'staging', label: 'Staging', requiresApproval: false },
|
|
@@ -60,6 +62,23 @@ function flagString(flags, key) {
|
|
|
60
62
|
function flagOn(flags, key) {
|
|
61
63
|
return flags[key] === true || flags[key] === 'true';
|
|
62
64
|
}
|
|
65
|
+
function deploymentWaitTimeoutMs(args) {
|
|
66
|
+
const configured = flagString(args.flags, 'wait-timeout');
|
|
67
|
+
if (configured === undefined)
|
|
68
|
+
return DEFAULT_DEPLOYMENT_WAIT_TIMEOUT_MS;
|
|
69
|
+
const parsed = parseDurationMs(configured);
|
|
70
|
+
if (parsed === null || parsed <= 0 || !Number.isFinite(parsed)) {
|
|
71
|
+
throw new Error(`--wait-timeout must be a positive duration such as 2h (got "${configured}")`);
|
|
72
|
+
}
|
|
73
|
+
return parsed;
|
|
74
|
+
}
|
|
75
|
+
function repeatedFlagStrings(args, key) {
|
|
76
|
+
const repeated = args.repeatedFlags?.[key];
|
|
77
|
+
if (repeated)
|
|
78
|
+
return repeated;
|
|
79
|
+
const single = flagString(args.flags, key);
|
|
80
|
+
return single ? [single] : [];
|
|
81
|
+
}
|
|
63
82
|
export function deployEnvironmentForEnv(env) {
|
|
64
83
|
return env.name === 'local' ? 'dev' : env.name;
|
|
65
84
|
}
|
|
@@ -132,6 +151,8 @@ export async function pipelineDeployCommand(args) {
|
|
|
132
151
|
const deploymentId = flagString(args.flags, 'deployment-id');
|
|
133
152
|
const approvedBy = flagString(args.flags, 'approved-by');
|
|
134
153
|
const runNow = flagOn(args.flags, 'run-now');
|
|
154
|
+
const waitTimeoutMs = deploymentWaitTimeoutMs(args);
|
|
155
|
+
const allowDestructiveResourceKeys = repeatedFlagStrings(args, 'allow-destructive');
|
|
135
156
|
const { env, token } = await envAndToken(args);
|
|
136
157
|
let target;
|
|
137
158
|
try {
|
|
@@ -147,7 +168,7 @@ export async function pipelineDeployCommand(args) {
|
|
|
147
168
|
// Direct execute of a persisted plan.
|
|
148
169
|
const stageId = flagString(args.flags, 'stage-id');
|
|
149
170
|
if (!stageId) {
|
|
150
|
-
console.error('usage: seq-studio pipeline deploy --deployment-id <id> --stage-id <id> -e <env> [--target <id>] [--approved-by <sub>] [--run-now] [--no-wait]');
|
|
171
|
+
console.error('usage: seq-studio pipeline deploy --deployment-id <id> --stage-id <id> -e <env> [--target <id>] [--approved-by <sub>] [--allow-destructive <resource-key> ...] [--run-now] [--wait-timeout <duration>] [--no-wait]');
|
|
151
172
|
return 1;
|
|
152
173
|
}
|
|
153
174
|
enqueue = await postJson({
|
|
@@ -158,13 +179,16 @@ export async function pipelineDeployCommand(args) {
|
|
|
158
179
|
deploymentId,
|
|
159
180
|
environment: target.id,
|
|
160
181
|
...(approvedBy ? { approvedBy } : {}),
|
|
182
|
+
...(allowDestructiveResourceKeys.length > 0
|
|
183
|
+
? { allowDestructiveResourceKeys }
|
|
184
|
+
: {}),
|
|
161
185
|
runNow,
|
|
162
186
|
},
|
|
163
187
|
});
|
|
164
188
|
}
|
|
165
189
|
else {
|
|
166
190
|
if (!repo || !ref) {
|
|
167
|
-
console.error('usage: seq-studio pipeline deploy --repo pipelines/<slug> --ref <sha|branch> -e <env> [--target <id>] [--approved-by <sub>] [--run-now] [--no-wait]');
|
|
191
|
+
console.error('usage: seq-studio pipeline deploy --repo pipelines/<slug> --ref <sha|branch> -e <env> [--target <id>] [--approved-by <sub>] [--allow-destructive <resource-key> ...] [--run-now] [--wait-timeout <duration>] [--no-wait]');
|
|
168
192
|
return 1;
|
|
169
193
|
}
|
|
170
194
|
// Plan then deploy the first planning deployment.
|
|
@@ -175,7 +199,7 @@ export async function pipelineDeployCommand(args) {
|
|
|
175
199
|
ref,
|
|
176
200
|
environment: target.id,
|
|
177
201
|
});
|
|
178
|
-
if (plan.plan.hasDestructive) {
|
|
202
|
+
if (plan.plan.hasDestructive && allowDestructiveResourceKeys.length === 0) {
|
|
179
203
|
console.error(`${LOG} plan has destructive findings — refusing to deploy`);
|
|
180
204
|
if (args.flags.json === true || args.flags.json === 'true') {
|
|
181
205
|
console.log(JSON.stringify(plan, null, 2));
|
|
@@ -199,6 +223,9 @@ export async function pipelineDeployCommand(args) {
|
|
|
199
223
|
deploymentId: firstId,
|
|
200
224
|
environment: target.id,
|
|
201
225
|
...(approvedBy ? { approvedBy } : {}),
|
|
226
|
+
...(allowDestructiveResourceKeys.length > 0
|
|
227
|
+
? { allowDestructiveResourceKeys }
|
|
228
|
+
: {}),
|
|
202
229
|
runNow,
|
|
203
230
|
},
|
|
204
231
|
});
|
|
@@ -215,15 +242,52 @@ export async function pipelineDeployCommand(args) {
|
|
|
215
242
|
if (args.flags['no-wait'] === true || args.flags['no-wait'] === 'true') {
|
|
216
243
|
return 0;
|
|
217
244
|
}
|
|
218
|
-
return pollDeployment({
|
|
245
|
+
return pollDeployment({
|
|
246
|
+
baseUrl: env.url,
|
|
247
|
+
token,
|
|
248
|
+
deploymentId: enqueue.deploymentId,
|
|
249
|
+
environment: env.name,
|
|
250
|
+
timeoutMs: waitTimeoutMs,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
export async function pipelineStatusCommand(args) {
|
|
254
|
+
const deploymentId = flagString(args.flags, 'deployment-id');
|
|
255
|
+
if (!deploymentId) {
|
|
256
|
+
console.error('usage: seq-studio pipeline status --deployment-id <id> -e <env> [--json]');
|
|
257
|
+
return 1;
|
|
258
|
+
}
|
|
259
|
+
const { env, token } = await envAndToken(args);
|
|
260
|
+
const json = args.flags.json === true || args.flags.json === 'true';
|
|
261
|
+
try {
|
|
262
|
+
const detail = await getJson({
|
|
263
|
+
baseUrl: env.url,
|
|
264
|
+
token,
|
|
265
|
+
path: `/api/data-pipelines/deployments/${deploymentId}`,
|
|
266
|
+
});
|
|
267
|
+
if (json) {
|
|
268
|
+
console.log(JSON.stringify(detail, null, 2));
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
console.log(`${LOG} deployment ${deploymentId}: ${deploymentStatusLabel(detail)}`);
|
|
272
|
+
}
|
|
273
|
+
return detail.status === 'active' || !TERMINAL.has(detail.status) ? 0 : 1;
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
if (error instanceof AtlasApiError) {
|
|
277
|
+
console.error(`${LOG} status failed: ${error.message}`);
|
|
278
|
+
return 1;
|
|
279
|
+
}
|
|
280
|
+
throw error;
|
|
281
|
+
}
|
|
219
282
|
}
|
|
220
283
|
export async function pipelinePromoteCommand(args) {
|
|
221
284
|
const stage = flagString(args.flags, 'stage');
|
|
222
285
|
const version = flagString(args.flags, 'version');
|
|
223
286
|
const repo = flagString(args.flags, 'repo');
|
|
224
287
|
const approvedBy = flagString(args.flags, 'approved-by');
|
|
288
|
+
const waitTimeoutMs = deploymentWaitTimeoutMs(args);
|
|
225
289
|
if (!stage || !version) {
|
|
226
|
-
console.error('usage: seq-studio pipeline promote --stage <slug> --version <v> -e <env> [--repo pipelines/<slug>] [--approved-by <you>] [--no-wait]');
|
|
290
|
+
console.error('usage: seq-studio pipeline promote --stage <slug> --version <v> -e <env> [--repo pipelines/<slug>] [--approved-by <you>] [--wait-timeout <duration>] [--no-wait]');
|
|
227
291
|
return 1;
|
|
228
292
|
}
|
|
229
293
|
const { env, token } = await envAndToken(args);
|
|
@@ -273,7 +337,13 @@ export async function pipelinePromoteCommand(args) {
|
|
|
273
337
|
console.error(`${LOG} promote plan completed without a deployment id`);
|
|
274
338
|
return 1;
|
|
275
339
|
}
|
|
276
|
-
return pollDeployment({
|
|
340
|
+
return pollDeployment({
|
|
341
|
+
baseUrl: env.url,
|
|
342
|
+
token,
|
|
343
|
+
deploymentId,
|
|
344
|
+
environment: env.name,
|
|
345
|
+
timeoutMs: waitTimeoutMs,
|
|
346
|
+
});
|
|
277
347
|
}
|
|
278
348
|
export async function pipelineRunNowCommand(args) {
|
|
279
349
|
const stage = flagString(args.flags, 'stage');
|
|
@@ -330,8 +400,9 @@ export async function pipelineRollbackCommand(args) {
|
|
|
330
400
|
const stage = flagString(args.flags, 'stage');
|
|
331
401
|
const repo = flagString(args.flags, 'repo');
|
|
332
402
|
const approvedBy = flagString(args.flags, 'approved-by');
|
|
403
|
+
const waitTimeoutMs = deploymentWaitTimeoutMs(args);
|
|
333
404
|
if (!stage) {
|
|
334
|
-
console.error('usage: seq-studio pipeline rollback --stage <slug> -e <env> [--repo pipelines/<slug>] [--approved-by <you>] [--no-wait]');
|
|
405
|
+
console.error('usage: seq-studio pipeline rollback --stage <slug> -e <env> [--repo pipelines/<slug>] [--approved-by <you>] [--wait-timeout <duration>] [--no-wait]');
|
|
335
406
|
return 1;
|
|
336
407
|
}
|
|
337
408
|
const { env, token } = await envAndToken(args);
|
|
@@ -370,7 +441,13 @@ export async function pipelineRollbackCommand(args) {
|
|
|
370
441
|
console.log(`${LOG} enqueued rollback ${enqueue.deploymentId}`);
|
|
371
442
|
if (args.flags['no-wait'] === true || args.flags['no-wait'] === 'true')
|
|
372
443
|
return 0;
|
|
373
|
-
return pollDeployment({
|
|
444
|
+
return pollDeployment({
|
|
445
|
+
baseUrl: env.url,
|
|
446
|
+
token,
|
|
447
|
+
deploymentId: enqueue.deploymentId,
|
|
448
|
+
environment: env.name,
|
|
449
|
+
timeoutMs: waitTimeoutMs,
|
|
450
|
+
});
|
|
374
451
|
}
|
|
375
452
|
function printFindingsTable(findings) {
|
|
376
453
|
if (findings.length === 0) {
|
|
@@ -385,9 +462,8 @@ function printFindingsTable(findings) {
|
|
|
385
462
|
console.log(`${LOG} ${klass.padEnd(12)} ${f.resourceKey.padEnd(32)} ${f.message}`);
|
|
386
463
|
}
|
|
387
464
|
}
|
|
388
|
-
async function pollDeployment({ baseUrl, token, deploymentId, }) {
|
|
465
|
+
async function pollDeployment({ baseUrl, token, deploymentId, environment, timeoutMs, }) {
|
|
389
466
|
const started = Date.now();
|
|
390
|
-
const timeoutMs = 15 * 60 * 1000;
|
|
391
467
|
let lastLoggedLabel = null;
|
|
392
468
|
let lastLogAt = started;
|
|
393
469
|
while (Date.now() - started < timeoutMs) {
|
|
@@ -421,7 +497,11 @@ async function pollDeployment({ baseUrl, token, deploymentId, }) {
|
|
|
421
497
|
}
|
|
422
498
|
await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));
|
|
423
499
|
}
|
|
424
|
-
console.error(`${LOG} timed out waiting for deployment ${deploymentId}
|
|
500
|
+
console.error(`${LOG} timed out waiting for deployment ${deploymentId} ` +
|
|
501
|
+
`(${formatElapsed(Date.now() - started)}). The remote deployment is still running; ` +
|
|
502
|
+
`local polling stopped without cancelling it. Continue monitoring with: ` +
|
|
503
|
+
`seq-studio pipeline status --deployment-id ${deploymentId} -e ${environment} ` +
|
|
504
|
+
`(or, for internal operators: seqapi get /api/data-pipelines/deployments/${deploymentId} -e ${environment})`);
|
|
425
505
|
return 1;
|
|
426
506
|
}
|
|
427
507
|
async function enqueueAndWaitForPlan({ baseUrl, token, repo, ref, environment, }) {
|