@sequenceholdings/studio-cli 0.2.2 → 0.4.1
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 +616 -78
- package/dist/access/commands.d.ts +3 -0
- package/dist/access/commands.js +91 -0
- package/dist/agents/commands.d.ts +1 -1
- package/dist/agents/commands.js +5 -0
- package/dist/agents/scaffold.js +5 -7
- package/dist/agents/voice-authoring.d.ts +5 -0
- package/dist/agents/voice-authoring.js +75 -0
- package/dist/agents/voice-publication.d.ts +5 -0
- package/dist/agents/voice-publication.js +63 -0
- package/dist/agents/voice-shared.d.ts +20 -0
- package/dist/agents/voice-shared.js +112 -0
- package/dist/agents/voice.d.ts +3 -0
- package/dist/agents/voice.js +57 -0
- package/dist/app/adapters.d.ts +6 -0
- package/dist/app/adapters.js +17 -2
- package/dist/app/agent-refs.d.ts +16 -0
- package/dist/app/agent-refs.js +36 -0
- package/dist/app/application-registration.d.ts +36 -6
- package/dist/app/application-registration.js +60 -15
- package/dist/app/commands.js +19 -2
- package/dist/app/deploy.d.ts +3 -0
- package/dist/app/deploy.js +22 -6
- package/dist/app/env-bindings.d.ts +21 -0
- package/dist/app/env-bindings.js +184 -0
- package/dist/app/manifest-validation.js +8 -0
- package/dist/app/manifest.d.ts +32 -14
- package/dist/app/manifest.js +16 -6
- package/dist/app/primitive-scaffold.d.ts +4 -1
- package/dist/app/primitive-scaffold.js +4 -4
- package/dist/app/readme.js +1 -0
- package/dist/app/scaffold-files.js +1 -1
- package/dist/app/scaffold.d.ts +6 -4
- package/dist/app/scaffold.js +7 -4
- package/dist/app/workspace-scaffold.js +12 -7
- package/dist/argv.d.ts +7 -0
- package/dist/argv.js +56 -0
- package/dist/artifact/delegate.js +8 -4
- package/dist/atlas-client.d.ts +6 -0
- package/dist/atlas-client.js +39 -2
- package/dist/auth-cmds/commands.d.ts +1 -1
- package/dist/auth-cmds/commands.js +16 -0
- package/dist/auth.d.ts +32 -0
- package/dist/auth.js +170 -33
- package/dist/bin.js +23 -4
- package/dist/command-contract.d.ts +137 -0
- package/dist/command-contract.js +43 -0
- package/dist/command-help.d.ts +8 -0
- package/dist/command-help.js +71 -0
- package/dist/command-input.d.ts +15 -0
- package/dist/command-input.js +33 -0
- package/dist/functions/commands.d.ts +2 -1
- package/dist/functions/commands.js +78 -33
- package/dist/functions/deploy-preflight.d.ts +21 -0
- package/dist/functions/deploy-preflight.js +58 -0
- package/dist/functions/egress-postgres.d.ts +7 -0
- package/dist/functions/egress-postgres.js +36 -0
- package/dist/functions/manifest.d.ts +15 -1
- package/dist/functions/manifest.js +49 -12
- package/dist/functions/secret-reconcile.d.ts +3 -3
- package/dist/functions/secret-reconcile.js +5 -7
- package/dist/functions/source-selection.js +4 -1
- package/dist/main.d.ts +2 -0
- package/dist/main.js +75 -25
- package/dist/manifest-roles-notice.d.ts +33 -0
- package/dist/manifest-roles-notice.js +75 -0
- package/dist/orm/delegate.d.ts +16 -0
- package/dist/orm/delegate.js +142 -7
- package/dist/pipeline/clone-deploy.d.ts +37 -0
- package/dist/pipeline/clone-deploy.js +125 -0
- package/dist/pipeline/codegen.js +6 -2
- package/dist/pipeline/commands.js +21 -5
- package/dist/pipeline/lifecycle.d.ts +1 -0
- package/dist/pipeline/lifecycle.js +95 -44
- package/dist/pipeline/repin-orm.js +6 -2
- package/dist/pipeline/stage-secrets.d.ts +4 -1
- package/dist/pipeline/stage-secrets.js +7 -3
- package/dist/process/build.js +17 -0
- package/dist/process/codegen.js +16 -0
- package/dist/process/commands.d.ts +15 -7
- package/dist/process/commands.js +294 -98
- package/dist/process/lint.js +35 -0
- package/dist/process/plan-diff.js +9 -0
- package/dist/process/simulate.js +8 -0
- package/dist/release-age.d.ts +12 -0
- package/dist/release-age.js +24 -0
- package/dist/repos/commands.d.ts +10 -1
- package/dist/repos/commands.js +42 -8
- package/dist/repos/pulls.d.ts +3 -0
- package/dist/repos/pulls.js +131 -0
- package/dist/scaffold-guidance.d.ts +4 -0
- package/dist/scaffold-guidance.js +15 -0
- package/dist/secrets/commands.d.ts +1 -1
- package/dist/secrets/commands.js +97 -16
- package/dist/service-accounts/commands.d.ts +3 -0
- package/dist/service-accounts/commands.js +50 -0
- package/dist/storage/commands.js +23 -1
- package/dist/storage/gcs-download.d.ts +13 -0
- package/dist/storage/gcs-download.js +41 -0
- package/dist/storage/import-cycle.d.ts +41 -0
- package/dist/storage/import-cycle.js +123 -0
- package/dist/storage/import-files.d.ts +30 -0
- package/dist/storage/import-files.js +133 -0
- package/dist/storage/import-gcloud.d.ts +12 -0
- package/dist/storage/import-gcloud.js +54 -0
- package/dist/storage/import-identity.d.ts +12 -0
- package/dist/storage/import-identity.js +15 -0
- package/dist/storage/import-plan.d.ts +120 -0
- package/dist/storage/import-plan.js +189 -0
- package/dist/storage/import-preflight.d.ts +36 -0
- package/dist/storage/import-preflight.js +62 -0
- package/dist/storage/import-progress-map.d.ts +5 -0
- package/dist/storage/import-progress-map.js +22 -0
- package/dist/storage/import-recover.d.ts +97 -0
- package/dist/storage/import-recover.js +186 -0
- package/dist/storage/import-run.d.ts +14 -0
- package/dist/storage/import-run.js +140 -0
- package/dist/templates/guidance/AGENTS.md +10 -0
- package/dist/templates/guidance/CLAUDE.md +1 -0
- package/dist/templates/process/package.json +2 -2
- package/dist/templates/process/pnpm-workspace.yaml +7 -4
- package/dist/validation-detail.d.ts +2 -0
- package/dist/validation-detail.js +20 -0
- package/package.json +9 -9
- package/templates/guidance/AGENTS.md +10 -0
- package/templates/guidance/CLAUDE.md +1 -0
- package/templates/process/package.json +2 -2
- package/templates/process/pnpm-workspace.yaml +7 -4
package/dist/main.js
CHANGED
|
@@ -13,38 +13,45 @@
|
|
|
13
13
|
* seq-studio repos <sub> manage platform git-service repos
|
|
14
14
|
* seq-studio pipeline <sub> discover, query, author and operate Data Pipelines
|
|
15
15
|
* seq-studio auth <sub> manage git-service PATs
|
|
16
|
+
* seq-studio service-accounts <sub> provision runtime identities
|
|
17
|
+
* seq-studio access <sub> manage runtime resource access
|
|
16
18
|
* seq-studio envs <sub> add/list/refresh environments
|
|
17
19
|
* seq-studio login authenticate interactively with Auth0
|
|
18
20
|
* seq-studio logout remove cached user tokens
|
|
19
21
|
* seq-studio doctor check token + env + writer gate
|
|
20
22
|
* seq-studio help show usage
|
|
21
23
|
*/
|
|
22
|
-
import { parseArgs } from './
|
|
23
|
-
import {
|
|
24
|
+
import { parseArgs } from './argv.js';
|
|
25
|
+
import { renderCapabilities } from './command-contract.js';
|
|
26
|
+
import { staticHelp } from './command-help.js';
|
|
24
27
|
// Lazy-load artifact delegate: published @sequenceholdings/artifact-studio/cli
|
|
25
28
|
// still auto-runs runCli() at module load; importing it here breaks doctor/process.
|
|
26
29
|
const TOP_LEVEL_USAGE = `usage:
|
|
27
|
-
seq-studio init <dir> --with <kinds> scaffold an app monorepo (sequence.app.yml)
|
|
28
|
-
seq-studio add <kind> <name> add a primitive to the current app monorepo
|
|
29
|
-
seq-studio deploy -e <env> deploy primitives from sequence.app.yml
|
|
30
|
+
seq-studio init <dir> --with <kinds> [internal] scaffold an app monorepo (sequence.app.yml)
|
|
31
|
+
seq-studio add <kind> <name> [internal] add a primitive to the current app monorepo
|
|
32
|
+
seq-studio deploy -e <env> [internal] deploy primitives from sequence.app.yml
|
|
30
33
|
seq-studio process <sub> [args] lint | plan | apply | test | simulate | bundle | init
|
|
31
|
-
seq-studio artifact <sub> [args] init |
|
|
34
|
+
seq-studio artifact <sub> [args] init | whoami | link | env | status | list | show | validate | build | plan | deploy | dev | promote | pull | rollback
|
|
32
35
|
seq-studio functions <sub> [args] init | build | deploy | list | show | limits | invoke | logs | promote | rollback | delete
|
|
33
36
|
seq-studio storage <sub> [args] init | validate | apply | list | show | mkdir | upload | download | access | trash | restore | purge | operations | abort | delete
|
|
34
|
-
seq-studio agents <sub> [args] init | validate | plan | apply | list | show
|
|
37
|
+
seq-studio agents <sub> [args] init | validate | plan | apply | list | show | voice (internal)
|
|
35
38
|
seq-studio secrets <sub> [args] create | set | list | attach | detach | apply
|
|
36
|
-
seq-studio repos <sub> [args] list | namespaces | show | create | clone | pull | delete
|
|
37
|
-
seq-studio pipeline <sub> [args] search | describe | schema | sample | query |
|
|
38
|
-
seq-studio auth <sub> [args] pat create | pat list | pat revoke
|
|
39
|
-
seq-studio orm <sub> [args] init | generate | validate | plan | apply | execute | diff | migrate-from-yaml
|
|
39
|
+
seq-studio repos <sub> [args] list | namespaces | show | create | clone | pull | pulls | delete
|
|
40
|
+
seq-studio pipeline <sub> [args] list | assets | search | describe | schema | sample | query | init | validate | repin-orm | codegen | plan | adopt | unbind | deploy | status | migrate | promote | rollback | run-now
|
|
41
|
+
seq-studio auth <sub> [args] whoami | pat create | pat list | pat revoke
|
|
42
|
+
seq-studio orm <sub> [args] init | generate | validate | plan | apply | execute | diff | migrate-from-yaml | import
|
|
43
|
+
seq-studio service-accounts <sub> list | show | create (requires provisioning authority)
|
|
44
|
+
seq-studio access <sub> definitions | list | grant | revoke | resolve
|
|
40
45
|
seq-studio envs <sub> add | list | refresh environments
|
|
41
46
|
seq-studio login [--env <name>] authenticate in the browser
|
|
42
47
|
seq-studio logout [--env <name>] remove one realm's cached user tokens
|
|
43
|
-
seq-studio doctor [-e <env>]
|
|
48
|
+
seq-studio doctor [-e <env>] [--json] [--offline] diagnose config, auth, toolchain, and writer gate
|
|
44
49
|
seq-studio version print the installed version
|
|
50
|
+
seq-studio capabilities [--json] describe command availability and access
|
|
45
51
|
seq-studio help show this message
|
|
46
52
|
|
|
47
53
|
Authenticate with: seq-studio login
|
|
54
|
+
Where supported, --json writes structured stdout; check exit status and pagination.
|
|
48
55
|
Built-in env: local. Authenticated identities discover more via
|
|
49
56
|
\`seq-studio envs refresh\`; custom entries live in ~/.config/lattice/config.toml.
|
|
50
57
|
`;
|
|
@@ -52,8 +59,8 @@ const PROCESS_USAGE = `usage:
|
|
|
52
59
|
seq-studio process init <dir>
|
|
53
60
|
seq-studio process lint [--dir <path>] [--offline]
|
|
54
61
|
seq-studio process plan [--dir <path>] [-e <env>]
|
|
55
|
-
seq-studio process apply [--dir <path>] [-e <env>] [--only <id1,id2,...>]
|
|
56
|
-
seq-studio process apply --repo processes/<name> [--ref <r>] -e <env> [--only <id1,id2,...>]
|
|
62
|
+
seq-studio process apply [--dir <path>] [-e <env>] [--only <id1,id2,...>] [--platform-managed]
|
|
63
|
+
seq-studio process apply --repo processes/<name> [--ref <r>] -e <env> [--only <id1,id2,...>] [--platform-managed]
|
|
57
64
|
seq-studio process promote <processId> --version <v> [-e <env>]
|
|
58
65
|
seq-studio process pull <processId> [--version <v>] [-e <env>] [--out <dir>] [--no-children]
|
|
59
66
|
seq-studio process test [-e <env>] [--offline]
|
|
@@ -72,6 +79,21 @@ export async function run(argv = process.argv.slice(2)) {
|
|
|
72
79
|
console.log(TOP_LEVEL_USAGE);
|
|
73
80
|
return namespace ? 0 : 1;
|
|
74
81
|
}
|
|
82
|
+
if (namespace === 'capabilities' && hasHelpFlag(sub, rest)) {
|
|
83
|
+
console.log('usage: seq-studio capabilities [--json]');
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
if (namespace === 'artifact' && [sub, ...rest].some((arg) => arg === '--token' || arg?.startsWith('--token='))) {
|
|
87
|
+
console.error('Artifact Studio does not accept --token bearer injection. Authenticate with seq-studio login.');
|
|
88
|
+
return 1;
|
|
89
|
+
}
|
|
90
|
+
if (hasHelpFlag(sub, rest)) {
|
|
91
|
+
const help = staticHelp({ namespace, sub });
|
|
92
|
+
if (help) {
|
|
93
|
+
console.log(help);
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
75
97
|
switch (namespace) {
|
|
76
98
|
case 'init': {
|
|
77
99
|
const { runAppInitCommand } = await import('./app/commands.js');
|
|
@@ -114,6 +136,14 @@ export async function run(argv = process.argv.slice(2)) {
|
|
|
114
136
|
const { runReposCommand } = await import('./repos/commands.js');
|
|
115
137
|
return runReposCommand(sub, parseArgs(rest));
|
|
116
138
|
}
|
|
139
|
+
case 'service-accounts': {
|
|
140
|
+
const { runServiceAccountsCommand } = await import('./service-accounts/commands.js');
|
|
141
|
+
return runServiceAccountsCommand(sub, parseArgs(rest));
|
|
142
|
+
}
|
|
143
|
+
case 'access': {
|
|
144
|
+
const { runAccessCommand } = await import('./access/commands.js');
|
|
145
|
+
return runAccessCommand(sub, parseArgs(rest));
|
|
146
|
+
}
|
|
117
147
|
case 'auth': {
|
|
118
148
|
const { runAuthCommand } = await import('./auth-cmds/commands.js');
|
|
119
149
|
return runAuthCommand(sub, parseArgs(rest));
|
|
@@ -142,14 +172,26 @@ export async function run(argv = process.argv.slice(2)) {
|
|
|
142
172
|
console.log(currentVersion());
|
|
143
173
|
return 0;
|
|
144
174
|
}
|
|
175
|
+
case 'capabilities':
|
|
176
|
+
return runCapabilities([sub, ...rest].filter((value) => Boolean(value)));
|
|
145
177
|
case 'doctor':
|
|
146
|
-
return doctorCommand(parseArgs([sub, ...rest].filter(Boolean)));
|
|
178
|
+
return (await import('./process/commands.js')).doctorCommand(parseArgs([sub, ...rest].filter(Boolean)));
|
|
147
179
|
default:
|
|
148
180
|
console.error(`unknown command: ${namespace}`);
|
|
149
181
|
console.error(TOP_LEVEL_USAGE);
|
|
150
182
|
return 1;
|
|
151
183
|
}
|
|
152
184
|
}
|
|
185
|
+
function runCapabilities(argv) {
|
|
186
|
+
const args = parseArgs(argv);
|
|
187
|
+
const unknown = Object.keys(args.flags).find((flag) => flag !== 'json');
|
|
188
|
+
if (unknown || args.positional.length > 0 || (args.flags.json !== undefined && args.flags.json !== true)) {
|
|
189
|
+
console.error('usage: seq-studio capabilities [--json]');
|
|
190
|
+
return 1;
|
|
191
|
+
}
|
|
192
|
+
console.log(renderCapabilities({ json: args.flags.json === true }));
|
|
193
|
+
return 0;
|
|
194
|
+
}
|
|
153
195
|
async function runSessionCommand({ args, command, }) {
|
|
154
196
|
const usage = `usage: seq-studio ${command} [--env <name>]`;
|
|
155
197
|
if (args[0] === 'help' || args[0] === '--help' || args[0] === '-h') {
|
|
@@ -179,32 +221,37 @@ async function runSessionCommand({ args, command, }) {
|
|
|
179
221
|
return 0;
|
|
180
222
|
}
|
|
181
223
|
async function runProcessNamespace(sub, rest) {
|
|
224
|
+
if (hasHelpFlag(sub, rest)) {
|
|
225
|
+
console.log(PROCESS_USAGE);
|
|
226
|
+
return 0;
|
|
227
|
+
}
|
|
182
228
|
if (!sub) {
|
|
183
229
|
console.error(PROCESS_USAGE);
|
|
184
230
|
return 1;
|
|
185
231
|
}
|
|
186
|
-
const
|
|
232
|
+
const processCommands = await import('./process/commands.js');
|
|
233
|
+
const args = processCommands.parseArgs(sub === 'bundle' ? [sub, ...rest] : rest);
|
|
187
234
|
switch (sub) {
|
|
188
235
|
case 'init':
|
|
189
|
-
return initCommand(args);
|
|
236
|
+
return processCommands.initCommand(args);
|
|
190
237
|
case 'lint':
|
|
191
|
-
return lintCommand(args);
|
|
238
|
+
return processCommands.lintCommand(args);
|
|
192
239
|
case 'plan':
|
|
193
|
-
return planCommand(args);
|
|
240
|
+
return processCommands.planCommand(args);
|
|
194
241
|
case 'apply':
|
|
195
|
-
return applyCommand(args);
|
|
242
|
+
return processCommands.applyCommand(args);
|
|
196
243
|
case 'promote':
|
|
197
|
-
return promoteCommand(args);
|
|
244
|
+
return processCommands.promoteCommand(args);
|
|
198
245
|
case 'pull':
|
|
199
|
-
return pullCommand(args);
|
|
246
|
+
return processCommands.pullCommand(args);
|
|
200
247
|
case 'test':
|
|
201
|
-
return testCommand(args);
|
|
248
|
+
return processCommands.testCommand(args);
|
|
202
249
|
case 'simulate':
|
|
203
|
-
return simulateCommand(args);
|
|
250
|
+
return processCommands.simulateCommand(args);
|
|
204
251
|
case 'bundle':
|
|
205
252
|
// bundle command needs the subcommand (build/pull/inspect) in positional[0].
|
|
206
253
|
// parseArgs already includes it because we threaded sub into args.
|
|
207
|
-
return bundleCommand({
|
|
254
|
+
return processCommands.bundleCommand({
|
|
208
255
|
positional: args.positional.slice(1),
|
|
209
256
|
flags: args.flags,
|
|
210
257
|
});
|
|
@@ -223,3 +270,6 @@ async function runProcessNamespace(sub, rest) {
|
|
|
223
270
|
return 1;
|
|
224
271
|
}
|
|
225
272
|
}
|
|
273
|
+
function hasHelpFlag(sub, rest) {
|
|
274
|
+
return sub === 'help' || sub === '--help' || sub === '-h' || rest.some((arg) => arg === '--help' || arg === '-h');
|
|
275
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Role keys an artifact, managed function or ORM namespace manifest defines. */
|
|
2
|
+
export declare function hostRoleKeys(manifest: unknown): string[];
|
|
3
|
+
/** Runtime and collaborator role keys sequence.app.yml defines. */
|
|
4
|
+
export declare function applicationRoleKeys(manifest: unknown): string[];
|
|
5
|
+
export declare function manifestRolesNotice({ file, keys, where, }: {
|
|
6
|
+
file: string;
|
|
7
|
+
keys: readonly string[];
|
|
8
|
+
/** Where in Atlas these roles are managed. */
|
|
9
|
+
where: string;
|
|
10
|
+
}): string | null;
|
|
11
|
+
/**
|
|
12
|
+
* Print the notice for a manifest in `dir`, if it defines roles. Best-effort:
|
|
13
|
+
* a missing or unreadable file is the deploy's error to report, not this one's.
|
|
14
|
+
*/
|
|
15
|
+
export declare function warnOnManifestRoles({ dir, file, kind, }: {
|
|
16
|
+
dir: string;
|
|
17
|
+
file: string;
|
|
18
|
+
kind: 'host' | 'application';
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
/** Before `sub` deploys a host manifest from `args`, warn if it defines roles. */
|
|
21
|
+
export declare function warnBeforeHostDeploy({ sub, deploySub, args, file, }: {
|
|
22
|
+
sub: string | undefined;
|
|
23
|
+
/** The subcommand that deploys (`deploy`, `apply`). */
|
|
24
|
+
deploySub: string;
|
|
25
|
+
args: readonly string[];
|
|
26
|
+
file: string;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* The directory a command's argv points at that holds `file`: the first
|
|
30
|
+
* argument naming such a directory, else the working directory. Avoids
|
|
31
|
+
* guessing which arguments are flag values.
|
|
32
|
+
*/
|
|
33
|
+
export declare function manifestDirFromArgs(args: readonly string[], file: string): string;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Roles are created and edited in Atlas (the Permissions UI or the roles API)
|
|
3
|
+
* by capability admins. Role definitions in YAML — `capabilities.roles.definitions`
|
|
4
|
+
* in artifact.bundle.yml, managed-function.yml and namespace.yaml, and
|
|
5
|
+
* `roles` / `collaborators` in sequence.app.yml — are a deprecated one-time
|
|
6
|
+
* seed: a deploy creates any that don't exist yet and never updates them.
|
|
7
|
+
* Capabilities stay in YAML; they are the code's contract.
|
|
8
|
+
*
|
|
9
|
+
* Atlas only logs the drift, so the CLI tells the author before deploying.
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync } from 'node:fs';
|
|
12
|
+
import { readFile } from 'node:fs/promises';
|
|
13
|
+
import { join } from 'node:path';
|
|
14
|
+
import { load as loadYaml } from 'js-yaml';
|
|
15
|
+
function isRecord(value) {
|
|
16
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
17
|
+
}
|
|
18
|
+
function definitionKeys(block) {
|
|
19
|
+
if (!isRecord(block) || !isRecord(block.definitions))
|
|
20
|
+
return [];
|
|
21
|
+
return Object.keys(block.definitions);
|
|
22
|
+
}
|
|
23
|
+
/** Role keys an artifact, managed function or ORM namespace manifest defines. */
|
|
24
|
+
export function hostRoleKeys(manifest) {
|
|
25
|
+
if (!isRecord(manifest) || !isRecord(manifest.capabilities))
|
|
26
|
+
return [];
|
|
27
|
+
return definitionKeys(manifest.capabilities.roles).sort();
|
|
28
|
+
}
|
|
29
|
+
/** Runtime and collaborator role keys sequence.app.yml defines. */
|
|
30
|
+
export function applicationRoleKeys(manifest) {
|
|
31
|
+
if (!isRecord(manifest))
|
|
32
|
+
return [];
|
|
33
|
+
return [...definitionKeys(manifest.roles), ...definitionKeys(manifest.collaborators)].sort();
|
|
34
|
+
}
|
|
35
|
+
export function manifestRolesNotice({ file, keys, where, }) {
|
|
36
|
+
if (keys.length === 0)
|
|
37
|
+
return null;
|
|
38
|
+
return (`[seq-studio] ${file} defines roles (${keys.join(', ')}). Roles in YAML are a deprecated one-time seed: ` +
|
|
39
|
+
`a deploy creates any that don't exist yet and never updates them after. Create and edit roles in Atlas ` +
|
|
40
|
+
`(${where}) or through the roles API; keep capabilities in YAML.`);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Print the notice for a manifest in `dir`, if it defines roles. Best-effort:
|
|
44
|
+
* a missing or unreadable file is the deploy's error to report, not this one's.
|
|
45
|
+
*/
|
|
46
|
+
export async function warnOnManifestRoles({ dir, file, kind, }) {
|
|
47
|
+
let manifest;
|
|
48
|
+
try {
|
|
49
|
+
manifest = loadYaml(await readFile(join(dir, file), 'utf8'));
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const notice = manifestRolesNotice({
|
|
55
|
+
file,
|
|
56
|
+
keys: kind === 'host' ? hostRoleKeys(manifest) : applicationRoleKeys(manifest),
|
|
57
|
+
where: kind === 'host' ? 'Permissions → Roles' : 'Permissions → Applications → Edit roles',
|
|
58
|
+
});
|
|
59
|
+
if (notice)
|
|
60
|
+
console.warn(notice);
|
|
61
|
+
}
|
|
62
|
+
/** Before `sub` deploys a host manifest from `args`, warn if it defines roles. */
|
|
63
|
+
export async function warnBeforeHostDeploy({ sub, deploySub, args, file, }) {
|
|
64
|
+
if (sub !== deploySub)
|
|
65
|
+
return;
|
|
66
|
+
await warnOnManifestRoles({ dir: manifestDirFromArgs(args, file), file, kind: 'host' });
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The directory a command's argv points at that holds `file`: the first
|
|
70
|
+
* argument naming such a directory, else the working directory. Avoids
|
|
71
|
+
* guessing which arguments are flag values.
|
|
72
|
+
*/
|
|
73
|
+
export function manifestDirFromArgs(args, file) {
|
|
74
|
+
return args.find((arg) => !arg.startsWith('-') && existsSync(join(arg, file))) ?? '.';
|
|
75
|
+
}
|
package/dist/orm/delegate.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* `artifact`): resolve `--env` from `~/.config/lattice/config.toml`, set
|
|
6
6
|
* SEQUENCE_ORM_BASE_URL, share the seqapi token, forward argv.
|
|
7
7
|
*/
|
|
8
|
+
import { type SourceSpec } from '@sequenceholdings/artifact-studio/source-resolver';
|
|
8
9
|
/**
|
|
9
10
|
* Classify an ERR_MODULE_NOT_FOUND from importing `@sequenceholdings/orm/cli`:
|
|
10
11
|
* is the orm package itself absent, or is it present but a dependency (e.g.
|
|
@@ -14,4 +15,19 @@
|
|
|
14
15
|
* so a substring check would misread a missing dep as the orm package itself.
|
|
15
16
|
*/
|
|
16
17
|
export declare function isOrmPackageMissing(message: string): boolean;
|
|
18
|
+
export interface OrmRepoSelection {
|
|
19
|
+
spec: Extract<SourceSpec, {
|
|
20
|
+
kind: 'git-service';
|
|
21
|
+
}>;
|
|
22
|
+
path?: string;
|
|
23
|
+
/** argv with `--repo` / `--ref` / `--path` (and their values) removed. */
|
|
24
|
+
rest: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Pull `--repo <ns>/<name>`, `--ref <ref>`, and `--path <dir>` off the argv.
|
|
28
|
+
* Returns null when `--repo` is absent (the local-directory path, unchanged).
|
|
29
|
+
* The ORM CLI's own parser treats every non-flag token as the namespace dir,
|
|
30
|
+
* so these values must never be forwarded to it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function extractOrmRepoSelection(argv: readonly string[]): OrmRepoSelection | null;
|
|
17
33
|
export declare function runOrmCommand(sub: string | undefined, rest: string[]): Promise<number>;
|
package/dist/orm/delegate.js
CHANGED
|
@@ -5,15 +5,22 @@
|
|
|
5
5
|
* `artifact`): resolve `--env` from `~/.config/lattice/config.toml`, set
|
|
6
6
|
* SEQUENCE_ORM_BASE_URL, share the seqapi token, forward argv.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { parseSourceSpec, resolveArtifactSource, } from '@sequenceholdings/artifact-studio/source-resolver';
|
|
10
|
+
import { getAccessToken, tryGetAccessTokenWithMode } from '../auth.js';
|
|
9
11
|
import { resolveEnvWithDiscovery } from '../config.js';
|
|
10
12
|
import { normalizeShortEnvFlag, readEnvFromArgv } from '../env-flags.js';
|
|
11
13
|
import { REQUIRE_EXPLICIT_ENV_MESSAGE } from '../env-flags.js';
|
|
14
|
+
import { resolveFunctionSourceDir } from '../functions/source-selection.js';
|
|
15
|
+
import { warnBeforeHostDeploy } from '../manifest-roles-notice.js';
|
|
16
|
+
import { ORM_HELP } from '../command-help.js';
|
|
12
17
|
/**
|
|
13
18
|
* ORM subcommands that talk to Atlas — must not silently target `local`.
|
|
14
|
-
* `init`, `generate`, `validate`, `diff`,
|
|
19
|
+
* `init`, `generate`, `validate`, `diff`, `migrate-from-yaml`, and `import` are offline.
|
|
15
20
|
*/
|
|
16
21
|
const ORM_NETWORK_SUBS = new Set(['plan', 'apply', 'execute']);
|
|
22
|
+
/** Subcommands that may read their namespace from a git-service repo (`--repo`). */
|
|
23
|
+
const ORM_REPO_SUBS = new Set(['plan', 'apply']);
|
|
17
24
|
const ORM_USAGE = `usage:
|
|
18
25
|
seq-studio orm init <dir> scaffold a namespace package (v2: TypeScript schema + GraphQL documents)
|
|
19
26
|
seq-studio orm generate [dir] write schema.graphql + operations.manifest.json + typePolicies.gen.ts (offline; runs consumer codegen when codegen.ts is present)
|
|
@@ -22,10 +29,16 @@ const ORM_USAGE = `usage:
|
|
|
22
29
|
seq-studio orm validate [dir] parse + validate definitions and verify committed migrations are in sync
|
|
23
30
|
seq-studio orm plan [dir] -e <env> compile definitions and diff against the registry
|
|
24
31
|
seq-studio orm apply [dir] -e <env> author the migration, register, apply, and refresh the generated outputs (the everyday command)
|
|
32
|
+
seq-studio orm plan|apply --repo <ns>/<name> [--path <dir>] [--ref <ref>] -e <env>
|
|
33
|
+
plan/apply a namespace committed to a platform git-service repo (CI deploy-from-git);
|
|
34
|
+
--path selects the namespace directory (default: repo root). A remote apply never
|
|
35
|
+
authors migrations: the committed ledger must already match the definitions.
|
|
25
36
|
seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
|
|
26
37
|
execute one named persisted operation as the signed-in caller
|
|
27
38
|
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)
|
|
28
39
|
seq-studio orm migrate-from-yaml <dir> convert a v1 YAML namespace to the v2 TypeScript format (offline; migrations/ preserved)
|
|
40
|
+
seq-studio orm import [dir] --spec <file> | --table <t> --from <schema.table> --map <target=source,...>
|
|
41
|
+
plan a batched copy from an existing Postgres relation into an owned table (writes a SQL script; no database connection)
|
|
29
42
|
|
|
30
43
|
Environments: see \`seq-studio envs list\` (built-in: local; more are
|
|
31
44
|
discovered after you authenticate).
|
|
@@ -43,6 +56,113 @@ export function isOrmPackageMissing(message) {
|
|
|
43
56
|
const specifier = message.match(/Cannot find (?:package|module) '([^']+)'/)?.[1];
|
|
44
57
|
return specifier === '@sequenceholdings/orm' || (specifier?.startsWith('@sequenceholdings/orm/') ?? false);
|
|
45
58
|
}
|
|
59
|
+
const REPO_SOURCE_FLAGS = new Set(['--repo', '--ref', '--path']);
|
|
60
|
+
/**
|
|
61
|
+
* Pull `--repo <ns>/<name>`, `--ref <ref>`, and `--path <dir>` off the argv.
|
|
62
|
+
* Returns null when `--repo` is absent (the local-directory path, unchanged).
|
|
63
|
+
* The ORM CLI's own parser treats every non-flag token as the namespace dir,
|
|
64
|
+
* so these values must never be forwarded to it.
|
|
65
|
+
*/
|
|
66
|
+
export function extractOrmRepoSelection(argv) {
|
|
67
|
+
const values = {};
|
|
68
|
+
const rest = [];
|
|
69
|
+
for (let i = 0; i < argv.length; i++) {
|
|
70
|
+
const arg = argv[i];
|
|
71
|
+
if (arg === undefined)
|
|
72
|
+
continue;
|
|
73
|
+
const eq = arg.indexOf('=');
|
|
74
|
+
const name = eq === -1 ? arg : arg.slice(0, eq);
|
|
75
|
+
if (!REPO_SOURCE_FLAGS.has(name)) {
|
|
76
|
+
rest.push(arg);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const value = eq === -1 ? argv[++i] : arg.slice(eq + 1);
|
|
80
|
+
if (value === undefined || value.length === 0 || value.startsWith('-')) {
|
|
81
|
+
throw new Error(`${name} requires a value.`);
|
|
82
|
+
}
|
|
83
|
+
values[name.slice(2)] = value;
|
|
84
|
+
}
|
|
85
|
+
if (values.repo === undefined) {
|
|
86
|
+
const stray = Object.keys(values);
|
|
87
|
+
if (stray.length > 0)
|
|
88
|
+
throw new Error(`--${stray[0]} only applies together with --repo.`);
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const dir = positionalDir(rest);
|
|
92
|
+
if (dir !== undefined) {
|
|
93
|
+
throw new Error(`A [dir] argument (${dir}) cannot be combined with --repo; select a subdirectory with --path.`);
|
|
94
|
+
}
|
|
95
|
+
const spec = parseSourceSpec({
|
|
96
|
+
positional: [],
|
|
97
|
+
flags: { repo: values.repo, ...(values.ref !== undefined ? { ref: values.ref } : {}) },
|
|
98
|
+
});
|
|
99
|
+
if (spec.kind !== 'git-service')
|
|
100
|
+
throw new Error('--repo must name a platform git-service repository.');
|
|
101
|
+
return { spec, ...(values.path !== undefined ? { path: values.path } : {}), rest };
|
|
102
|
+
}
|
|
103
|
+
/** Mirrors the ORM CLI's positional(): the first non-flag token that is not the `--env` value. */
|
|
104
|
+
function positionalDir(args) {
|
|
105
|
+
for (let i = 0; i < args.length; i++) {
|
|
106
|
+
const arg = args[i];
|
|
107
|
+
if (arg === '--env') {
|
|
108
|
+
i += 1;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (arg !== undefined && !arg.startsWith('-'))
|
|
112
|
+
return arg;
|
|
113
|
+
}
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* A materialized repo is a bare source tree — no node_modules — so the
|
|
118
|
+
* namespace's `@sequenceholdings/orm` imports cannot resolve from it. Point
|
|
119
|
+
* them at the ORM package this CLI already runs (the ORM CLI's jiti alias
|
|
120
|
+
* hook), which is also the compiler version validating the definitions.
|
|
121
|
+
* An explicit SEQUENCE_ORM_MODULE_PATH always wins.
|
|
122
|
+
*/
|
|
123
|
+
function aliasOrmModuleForRemoteSource(envName) {
|
|
124
|
+
if (process.env[envName]?.trim())
|
|
125
|
+
return;
|
|
126
|
+
try {
|
|
127
|
+
process.env[envName] = fileURLToPath(import.meta.resolve('@sequenceholdings/orm/authoring'));
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
// Unresolvable here means the namespace's own imports decide; the load
|
|
131
|
+
// error names the missing module.
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async function runOrmFromRepo({ sub, selection, auth, targetUrl, ormCli, }) {
|
|
135
|
+
if (!auth || !targetUrl) {
|
|
136
|
+
console.error('[seq-studio] orm --repo needs a target environment and auth. Pass -e <env> and run `seq-studio login`.');
|
|
137
|
+
return 1;
|
|
138
|
+
}
|
|
139
|
+
const source = await resolveArtifactSource(selection.spec, {
|
|
140
|
+
authMode: auth.authMode,
|
|
141
|
+
baseUrl: targetUrl,
|
|
142
|
+
token: auth.token,
|
|
143
|
+
});
|
|
144
|
+
try {
|
|
145
|
+
const dir = await resolveFunctionSourceDir({
|
|
146
|
+
repoDir: source.dir,
|
|
147
|
+
...(selection.path !== undefined ? { path: selection.path } : {}),
|
|
148
|
+
});
|
|
149
|
+
aliasOrmModuleForRemoteSource(ormCli.ORM_MODULE_PATH_ENV);
|
|
150
|
+
// A local apply authors any missing migration into the working tree for
|
|
151
|
+
// review. A clone is discarded, so an authored migration would be applied
|
|
152
|
+
// unreviewed and then lost: require the committed ledger to be in sync.
|
|
153
|
+
if (sub === 'apply' && (await ormCli.runCli(['diff', dir, '--check'])) !== 0) {
|
|
154
|
+
console.error(`[seq-studio] ${selection.spec.namespace}/${selection.spec.name}${selection.path ? `/${selection.path}` : ''}: ` +
|
|
155
|
+
'committed migrations are out of date — run `seq-studio orm diff` in the repository, commit the migration, and retry.');
|
|
156
|
+
return 1;
|
|
157
|
+
}
|
|
158
|
+
const args = [dir, ...selection.rest];
|
|
159
|
+
await warnBeforeHostDeploy({ sub, deploySub: 'apply', args, file: 'namespace.yaml' });
|
|
160
|
+
return await ormCli.runCli([sub, ...args]);
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
await source.cleanup();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
46
166
|
async function loadOrmCli() {
|
|
47
167
|
try {
|
|
48
168
|
return await import('@sequenceholdings/orm/cli');
|
|
@@ -69,8 +189,20 @@ export async function runOrmCommand(sub, rest) {
|
|
|
69
189
|
}
|
|
70
190
|
const normalized = normalizeShortEnvFlag(rest);
|
|
71
191
|
if (normalized.includes('--help') || normalized.includes('-h')) {
|
|
72
|
-
|
|
73
|
-
return
|
|
192
|
+
console.log(ORM_HELP);
|
|
193
|
+
return 0;
|
|
194
|
+
}
|
|
195
|
+
let repoSelection;
|
|
196
|
+
try {
|
|
197
|
+
repoSelection = extractOrmRepoSelection(normalized);
|
|
198
|
+
}
|
|
199
|
+
catch (err) {
|
|
200
|
+
console.error(`[seq-studio] ${err instanceof Error ? err.message : String(err)}`);
|
|
201
|
+
return 1;
|
|
202
|
+
}
|
|
203
|
+
if (repoSelection && !ORM_REPO_SUBS.has(sub)) {
|
|
204
|
+
console.error(`[seq-studio] --repo applies only to: ${[...ORM_REPO_SUBS].join(', ')}`);
|
|
205
|
+
return 1;
|
|
74
206
|
}
|
|
75
207
|
const requested = readEnvFromArgv(normalized);
|
|
76
208
|
if (ORM_NETWORK_SUBS.has(sub) && !requested) {
|
|
@@ -83,13 +215,13 @@ export async function runOrmCommand(sub, rest) {
|
|
|
83
215
|
targetUrl = resolved.url;
|
|
84
216
|
process.env['SEQUENCE_ORM_BASE_URL'] = resolved.url;
|
|
85
217
|
}
|
|
86
|
-
const
|
|
218
|
+
const auth = await tryGetAccessTokenWithMode({
|
|
87
219
|
failClosedForM2m: true,
|
|
88
220
|
env: requested,
|
|
89
221
|
targetUrl,
|
|
90
222
|
});
|
|
91
|
-
if (
|
|
92
|
-
process.env['SEQUENCE_ORM_TOKEN'] = token;
|
|
223
|
+
if (auth)
|
|
224
|
+
process.env['SEQUENCE_ORM_TOKEN'] = auth.token;
|
|
93
225
|
// Lazy import keeps `process`/`doctor` from pulling in the optional ORM package.
|
|
94
226
|
const ormCli = await loadOrmCli();
|
|
95
227
|
if (!ormCli)
|
|
@@ -103,5 +235,8 @@ export async function runOrmCommand(sub, rest) {
|
|
|
103
235
|
return null;
|
|
104
236
|
}
|
|
105
237
|
});
|
|
238
|
+
if (repoSelection)
|
|
239
|
+
return runOrmFromRepo({ sub, selection: repoSelection, auth, targetUrl, ormCli });
|
|
240
|
+
await warnBeforeHostDeploy({ sub, deploySub: 'apply', args: normalized, file: 'namespace.yaml' });
|
|
106
241
|
return runCli([sub, ...normalized]);
|
|
107
242
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface CloneDeployTarget {
|
|
2
|
+
id: string;
|
|
3
|
+
requiresApproval: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function assertCloneDeployAllowed(target: CloneDeployTarget): void;
|
|
6
|
+
export declare function parseCloneDeployRepo(repo: string): {
|
|
7
|
+
namespace: 'pipelines' | 'apps';
|
|
8
|
+
name: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function readCloneHead(dir: string): Promise<{
|
|
11
|
+
sha: string;
|
|
12
|
+
branch: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare function pushCloneHead({ dir, cloneUrl, sha, branch, pat, }: {
|
|
15
|
+
dir: string;
|
|
16
|
+
cloneUrl: string;
|
|
17
|
+
sha: string;
|
|
18
|
+
branch: string;
|
|
19
|
+
pat: string;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
export interface PublishedClone {
|
|
22
|
+
sha: string;
|
|
23
|
+
branch: string;
|
|
24
|
+
repoId: string;
|
|
25
|
+
created: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Ensure `<repo>` exists on the target environment and contains this
|
|
29
|
+
* checkout's HEAD. Returns the SHA the caller should pass as `--ref`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function publishCloneForDeploy({ dir, repo, baseUrl, token, pat, }: {
|
|
32
|
+
dir: string;
|
|
33
|
+
repo: string;
|
|
34
|
+
baseUrl: string;
|
|
35
|
+
token: string;
|
|
36
|
+
pat?: string;
|
|
37
|
+
}): Promise<PublishedClone>;
|