@sequenceholdings/studio-cli 0.1.27 → 0.1.29
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 +255 -72
- 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 +105 -233
- 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 +8 -3
- 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 +7 -6
|
@@ -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
|
@@ -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/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, }) {
|
package/dist/process/build.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { execSync } from 'node:child_process';
|
|
6
6
|
import { finalizeBundleIdentity, forEachSerializedNode, } from '@sequenceholdings/lattice/bundle';
|
|
7
|
-
import { parseDurationMs, serializeRetryConfig, } from '@sequenceholdings/lattice/define';
|
|
7
|
+
import { isJsonataExpr, parseDurationMs, serializeRetryConfig, } from '@sequenceholdings/lattice/define';
|
|
8
8
|
export async function buildBundleFromProcesses(defs, options) {
|
|
9
9
|
if (defs.length === 0) {
|
|
10
10
|
throw new Error('no lattice process definitions found in configured roots');
|
|
@@ -84,6 +84,9 @@ function serializeProcess(input) {
|
|
|
84
84
|
...(input.process.tags && input.process.tags.length > 0
|
|
85
85
|
? { tags: input.process.tags }
|
|
86
86
|
: {}),
|
|
87
|
+
...(input.process.input_schema !== undefined
|
|
88
|
+
? { input_schema: input.process.input_schema }
|
|
89
|
+
: {}),
|
|
87
90
|
...(input.process.max_iterations !== undefined
|
|
88
91
|
? { max_iterations: input.process.max_iterations }
|
|
89
92
|
: {}),
|
|
@@ -113,6 +116,20 @@ function serializeProcess(input) {
|
|
|
113
116
|
: {}),
|
|
114
117
|
};
|
|
115
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Emit a mapper slot into node metadata: a function serializes to
|
|
121
|
+
* `<base>_source` (its `Function.toString()`), a `jsonata()` expression to
|
|
122
|
+
* `<base>_expr`. The two forms are mutually exclusive per slot by
|
|
123
|
+
* construction here; registration re-enforces that for hand-built bundles.
|
|
124
|
+
*/
|
|
125
|
+
function serializeMapperSlot(meta, base, value) {
|
|
126
|
+
if (typeof value === 'function') {
|
|
127
|
+
meta[`${base}_source`] = value.toString();
|
|
128
|
+
}
|
|
129
|
+
else if (isJsonataExpr(value)) {
|
|
130
|
+
meta[`${base}_expr`] = value.expr;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
116
133
|
/**
|
|
117
134
|
* Serialize one node definition to its bundle form. Extracted so parallel
|
|
118
135
|
* sub-nodes round-trip through the exact same path as top-level nodes —
|
|
@@ -161,10 +178,7 @@ function serializeNodeMetadata(node) {
|
|
|
161
178
|
if (native.run_as?.service_account) {
|
|
162
179
|
meta.run_as = { service_account: native.run_as.service_account };
|
|
163
180
|
}
|
|
164
|
-
|
|
165
|
-
if (typeof nativeInputMapper === 'function') {
|
|
166
|
-
meta.input_mapper_source = nativeInputMapper.toString();
|
|
167
|
-
}
|
|
181
|
+
serializeMapperSlot(meta, 'input_mapper', native.input);
|
|
168
182
|
return meta;
|
|
169
183
|
}
|
|
170
184
|
case 'agent': {
|
|
@@ -172,6 +186,9 @@ function serializeNodeMetadata(node) {
|
|
|
172
186
|
const meta = {
|
|
173
187
|
agent_id: agent.agent.id,
|
|
174
188
|
};
|
|
189
|
+
if (agent.agent.version !== undefined) {
|
|
190
|
+
meta.agent_version = agent.agent.version;
|
|
191
|
+
}
|
|
175
192
|
if (agent.timeout !== undefined)
|
|
176
193
|
meta.timeout = agent.timeout;
|
|
177
194
|
if (agent.workflowId !== undefined)
|
|
@@ -180,10 +197,11 @@ function serializeNodeMetadata(node) {
|
|
|
180
197
|
meta.on_reset_edge_id = agent.on_reset_edge_id;
|
|
181
198
|
if (agent.bindings)
|
|
182
199
|
meta.bindings = agent.bindings;
|
|
183
|
-
|
|
184
|
-
if (
|
|
185
|
-
meta.
|
|
200
|
+
// Per-node service-account override — omitted when unset for hash stability.
|
|
201
|
+
if (agent.run_as?.service_account) {
|
|
202
|
+
meta.run_as = { service_account: agent.run_as.service_account };
|
|
186
203
|
}
|
|
204
|
+
serializeMapperSlot(meta, 'input_mapper', agent.input);
|
|
187
205
|
return meta;
|
|
188
206
|
}
|
|
189
207
|
case 'human': {
|
|
@@ -199,11 +217,13 @@ function serializeNodeMetadata(node) {
|
|
|
199
217
|
meta.complete_label = human.completeLabel;
|
|
200
218
|
if (human.hideTimeoutEdgeFromAdvance)
|
|
201
219
|
meta.hide_timeout_edge_from_advance = true;
|
|
202
|
-
// advance_allowed is
|
|
203
|
-
//
|
|
204
|
-
// hook). Serialize the
|
|
205
|
-
|
|
206
|
-
|
|
220
|
+
// advance_allowed is a static ACL object, a `(ctx) => ACL` mapper, or a
|
|
221
|
+
// jsonata() expression, resolved per-step at entry (the per-branch
|
|
222
|
+
// fan-out assignment hook). Serialize the dynamic forms like the other
|
|
223
|
+
// mapper slots.
|
|
224
|
+
if (typeof human.advance_allowed === 'function' ||
|
|
225
|
+
isJsonataExpr(human.advance_allowed)) {
|
|
226
|
+
serializeMapperSlot(meta, 'advance_allowed_mapper', human.advance_allowed);
|
|
207
227
|
}
|
|
208
228
|
else if (human.advance_allowed) {
|
|
209
229
|
meta.advance_allowed = human.advance_allowed;
|
|
@@ -217,15 +237,15 @@ function serializeNodeMetadata(node) {
|
|
|
217
237
|
if (email === true) {
|
|
218
238
|
meta.email_notification = true;
|
|
219
239
|
}
|
|
220
|
-
else if (typeof email === 'function') {
|
|
240
|
+
else if (typeof email === 'function' || isJsonataExpr(email)) {
|
|
241
|
+
// Bare template forms: a fn or a jsonata() expression IS the "ready"
|
|
242
|
+
// template.
|
|
221
243
|
meta.email_notification = true;
|
|
222
|
-
meta
|
|
244
|
+
serializeMapperSlot(meta, 'email_notification_template', email);
|
|
223
245
|
}
|
|
224
246
|
else if (email && typeof email === 'object') {
|
|
225
247
|
meta.email_notification = true;
|
|
226
|
-
|
|
227
|
-
meta.email_notification_template_source = email.template.toString();
|
|
228
|
-
}
|
|
248
|
+
serializeMapperSlot(meta, 'email_notification_template', email.template);
|
|
229
249
|
if (email.timezone)
|
|
230
250
|
meta.email_notification_timezone = email.timezone;
|
|
231
251
|
if (email.reminders && email.reminders.length > 0) {
|
|
@@ -235,6 +255,7 @@ function serializeNodeMetadata(node) {
|
|
|
235
255
|
...(typeof r.template === 'function'
|
|
236
256
|
? { template_source: r.template.toString() }
|
|
237
257
|
: {}),
|
|
258
|
+
...(isJsonataExpr(r.template) ? { template_expr: r.template.expr } : {}),
|
|
238
259
|
}));
|
|
239
260
|
}
|
|
240
261
|
// Deploy-env allowlist (plain data, no sandboxed fn). Copied so the
|
|
@@ -244,57 +265,52 @@ function serializeNodeMetadata(node) {
|
|
|
244
265
|
meta.email_notification_enabled_environments = [...email.enabledEnvironments];
|
|
245
266
|
}
|
|
246
267
|
}
|
|
247
|
-
// dueDate `(ctx) => Date
|
|
248
|
-
|
|
249
|
-
meta.due_date_source = human.dueDate.toString();
|
|
250
|
-
}
|
|
268
|
+
// dueDate `(ctx) => Date` (or jsonata → ISO string), computed per-run.
|
|
269
|
+
serializeMapperSlot(meta, 'due_date', human.dueDate);
|
|
251
270
|
if (human.bindings)
|
|
252
271
|
meta.bindings = human.bindings;
|
|
253
272
|
if (Array.isArray(human.artifact_refs)) {
|
|
254
273
|
meta.artifact_refs = human.artifact_refs;
|
|
255
274
|
}
|
|
256
|
-
else
|
|
257
|
-
meta
|
|
275
|
+
else {
|
|
276
|
+
serializeMapperSlot(meta, 'artifact_refs_mapper', human.artifact_refs);
|
|
258
277
|
}
|
|
259
278
|
// First-class comment-chain opt-in — packed alongside artifact_refs (NOT
|
|
260
279
|
// inside the author `metadata` bag), so it serializes as its own node
|
|
261
280
|
// field that the inbox/process-activity reads at `node.metadata.comments`.
|
|
262
281
|
if (human.comments)
|
|
263
282
|
meta.comments = human.comments;
|
|
264
|
-
|
|
265
|
-
if (typeof humanInputMapper === 'function') {
|
|
266
|
-
meta.input_mapper_source = humanInputMapper.toString();
|
|
267
|
-
}
|
|
283
|
+
serializeMapperSlot(meta, 'input_mapper', human.input);
|
|
268
284
|
return meta;
|
|
269
285
|
}
|
|
270
286
|
case 'subprocess': {
|
|
271
287
|
const subprocess = node;
|
|
272
|
-
const toSource = (fn) => fn.toString();
|
|
273
288
|
const smeta = {
|
|
274
289
|
process_id: subprocess.process,
|
|
275
290
|
version: subprocess.version ?? '',
|
|
276
291
|
bundle_hash: '',
|
|
277
292
|
on_child_error: subprocess.on_child_error,
|
|
278
|
-
|
|
293
|
+
...(typeof subprocess.output === 'function'
|
|
294
|
+
? { output_mapper_source: subprocess.output.toString() }
|
|
295
|
+
: { output_mapper_expr: subprocess.output.expr }),
|
|
279
296
|
...(subprocess.supervisor_retry !== undefined
|
|
280
297
|
? { supervisor_retry: serializeRetryConfig(subprocess.supervisor_retry) }
|
|
281
298
|
: {}),
|
|
282
299
|
};
|
|
283
300
|
const meta = { subprocess: smeta };
|
|
284
|
-
|
|
285
|
-
meta.input_mapper_source = toSource(subprocess.input);
|
|
286
|
-
}
|
|
301
|
+
serializeMapperSlot(meta, 'input_mapper', subprocess.input);
|
|
287
302
|
if (subprocess.bindings)
|
|
288
303
|
meta.bindings = subprocess.bindings;
|
|
289
304
|
return meta;
|
|
290
305
|
}
|
|
291
306
|
case 'parallel': {
|
|
292
307
|
const parallel = node;
|
|
293
|
-
const toSource = (fn) => fn.toString();
|
|
294
308
|
const pmeta = {
|
|
295
309
|
mode: parallel.branches ? 'static' : 'dynamic',
|
|
296
310
|
on_branch_error: parallel.on_branch_error,
|
|
297
|
-
|
|
311
|
+
...(typeof parallel.join === 'function'
|
|
312
|
+
? { join_source: parallel.join.toString() }
|
|
313
|
+
: { join_expr: parallel.join.expr }),
|
|
298
314
|
};
|
|
299
315
|
// Serialized only when non-default ('eager') so existing barrier
|
|
300
316
|
// bundles keep their hashes; a missing field reads as 'barrier'.
|
|
@@ -314,7 +330,12 @@ function serializeNodeMetadata(node) {
|
|
|
314
330
|
}));
|
|
315
331
|
}
|
|
316
332
|
else {
|
|
317
|
-
|
|
333
|
+
if (typeof parallel.fan_out === 'function') {
|
|
334
|
+
pmeta.fan_out_source = parallel.fan_out.toString();
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
pmeta.fan_out_expr = parallel.fan_out.expr;
|
|
338
|
+
}
|
|
318
339
|
if (parallel.max_fanout !== undefined)
|
|
319
340
|
pmeta.max_fanout = parallel.max_fanout;
|
|
320
341
|
pmeta.branch = serializeNode(parallel.branch);
|
|
@@ -326,9 +347,7 @@ function serializeNodeMetadata(node) {
|
|
|
326
347
|
// executes it and the runner reads the directive from its payload input.
|
|
327
348
|
// (Nesting it under `parallel` left it unread, disabling selective
|
|
328
349
|
// re-run + epoch invalidation entirely.)
|
|
329
|
-
|
|
330
|
-
meta.input_mapper_source = toSource(parallel.input);
|
|
331
|
-
}
|
|
350
|
+
serializeMapperSlot(meta, 'input_mapper', parallel.input);
|
|
332
351
|
if (parallel.bindings)
|
|
333
352
|
meta.bindings = parallel.bindings;
|
|
334
353
|
return meta;
|
|
@@ -360,10 +379,7 @@ function serializeNodeMetadata(node) {
|
|
|
360
379
|
}
|
|
361
380
|
// NOTE: `middleware` (e.g. withRetry) is serialized generically for every
|
|
362
381
|
// node kind in `serializeNode` above — don't duplicate it here.
|
|
363
|
-
|
|
364
|
-
if (typeof inputMapper === 'function') {
|
|
365
|
-
meta.input_mapper_source = inputMapper.toString();
|
|
366
|
-
}
|
|
382
|
+
serializeMapperSlot(meta, 'input_mapper', mf.input);
|
|
367
383
|
return meta;
|
|
368
384
|
}
|
|
369
385
|
default:
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* published from the UI can be pulled back into a local tree.
|
|
5
5
|
*
|
|
6
6
|
* Fidelity notes (the bundle is a compiled artifact, not the original source):
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
7
|
+
* - JS mapper bodies are the build-time `Function.toString()` strings; JSONata
|
|
8
|
+
* mapper expressions are reconstructed as `jsonata('…')`. Both rebuild to
|
|
9
|
+
* the same content-addressed bundle fields.
|
|
9
10
|
* - Automation bodies live in the Atlas image; only the registry id is
|
|
10
11
|
* emitted (`function: '<id>'`).
|
|
11
12
|
* - Co-located subprocess pins (version / bundle_hash) are dropped — they are
|