@sequenceholdings/studio-cli 0.3.0 → 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 +465 -28
- 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 +31 -5
- package/dist/app/application-registration.js +58 -14
- package/dist/app/commands.js +19 -2
- package/dist/app/deploy.d.ts +3 -0
- package/dist/app/deploy.js +18 -4
- 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 +13 -9
- package/dist/app/manifest.js +1 -1
- 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.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/functions/commands.d.ts +1 -1
- package/dist/functions/commands.js +19 -3
- 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 +8 -0
- package/dist/functions/manifest.js +9 -0
- package/dist/functions/source-selection.js +4 -1
- package/dist/main.js +58 -20
- package/dist/orm/delegate.d.ts +16 -0
- package/dist/orm/delegate.js +140 -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.js +1 -1
- 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 +291 -99
- 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 +1 -1
- package/dist/repos/commands.js +36 -7
- package/dist/scaffold-guidance.d.ts +4 -0
- package/dist/scaffold-guidance.js +15 -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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type PreflightIssue, type PreflightManifest } from '@sequenceholdings/managed-functions/config';
|
|
2
|
+
/**
|
|
3
|
+
* Compare the manifest with the environment's published limits and features.
|
|
4
|
+
* A 404 means that deployment has no policy route yet; local SDK checks still run.
|
|
5
|
+
*/
|
|
6
|
+
export declare function preflightBeforeUpload({ client, rootDir, manifest, cliVersion, }: {
|
|
7
|
+
client: {
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
token: string;
|
|
10
|
+
};
|
|
11
|
+
rootDir: string;
|
|
12
|
+
manifest: PreflightManifest;
|
|
13
|
+
cliVersion: string;
|
|
14
|
+
}): Promise<PreflightIssue[]>;
|
|
15
|
+
/** Offline check for an SDK pin whose client timeout sits behind the platform. */
|
|
16
|
+
export declare function localSdkPreflight({ rootDir, manifest, cliVersion, }: {
|
|
17
|
+
rootDir: string;
|
|
18
|
+
manifest: PreflightManifest;
|
|
19
|
+
cliVersion: string;
|
|
20
|
+
}): Promise<PreflightIssue[]>;
|
|
21
|
+
export declare function reportPreflight(issues: readonly PreflightIssue[]): boolean;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { parseDeployedPolicy, preflightManagedFunction, sdkVersionFromPackageJson, } from '@sequenceholdings/managed-functions/config';
|
|
4
|
+
import { AtlasApiError, getJson } from '../atlas-client.js';
|
|
5
|
+
import { LOG } from '../cli-errors.js';
|
|
6
|
+
/**
|
|
7
|
+
* Compare the manifest with the environment's published limits and features.
|
|
8
|
+
* A 404 means that deployment has no policy route yet; local SDK checks still run.
|
|
9
|
+
*/
|
|
10
|
+
export async function preflightBeforeUpload({ client, rootDir, manifest, cliVersion, }) {
|
|
11
|
+
let body = null;
|
|
12
|
+
try {
|
|
13
|
+
body = await getJson({ ...client, path: '/api/managed-functions/limits' });
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (!(error instanceof AtlasApiError) || error.status !== 404)
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
const policy = parseDeployedPolicy(body);
|
|
20
|
+
return preflightManagedFunction({
|
|
21
|
+
manifest,
|
|
22
|
+
limits: policy.limits,
|
|
23
|
+
capabilities: policy.capabilities,
|
|
24
|
+
cliVersion,
|
|
25
|
+
sdkVersion: await declaredSdkVersion(rootDir),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** Offline check for an SDK pin whose client timeout sits behind the platform. */
|
|
29
|
+
export async function localSdkPreflight({ rootDir, manifest, cliVersion, }) {
|
|
30
|
+
return preflightManagedFunction({
|
|
31
|
+
manifest,
|
|
32
|
+
limits: null,
|
|
33
|
+
capabilities: null,
|
|
34
|
+
cliVersion,
|
|
35
|
+
sdkVersion: await declaredSdkVersion(rootDir),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export function reportPreflight(issues) {
|
|
39
|
+
if (issues.length === 0)
|
|
40
|
+
return false;
|
|
41
|
+
for (const issue of issues)
|
|
42
|
+
console.error(`${LOG} ${issue.message}`);
|
|
43
|
+
console.error(`${LOG} fix the above before deploying`);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
async function declaredSdkVersion(rootDir) {
|
|
47
|
+
try {
|
|
48
|
+
return sdkVersionFromPackageJson(await readFile(join(rootDir, 'package.json'), 'utf8'));
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (isMissingFile(error))
|
|
52
|
+
return null;
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function isMissingFile(error) {
|
|
57
|
+
return !!error && typeof error === 'object' && Reflect.get(error, 'code') === 'ENOENT';
|
|
58
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI-side copy of atlas/.../managed-functions/egress-postgres.ts. Authors
|
|
3
|
+
* usually do not have the deployment pin, so this checks shape only: Lakebase
|
|
4
|
+
* hostname class, port 5432, and sslmode=verify-full. The server checks the
|
|
5
|
+
* pin at upload.
|
|
6
|
+
*/
|
|
7
|
+
export declare function postgresEgressError(input: string): string | null;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI-side copy of atlas/.../managed-functions/egress-postgres.ts. Authors
|
|
3
|
+
* usually do not have the deployment pin, so this checks shape only: Lakebase
|
|
4
|
+
* hostname class, port 5432, and sslmode=verify-full. The server checks the
|
|
5
|
+
* pin at upload.
|
|
6
|
+
*/
|
|
7
|
+
const LAKEBASE_POSTGRES_HOST_RE = /^ep-[a-z0-9-]+\.database\.[a-z0-9-]+\.cloud\.databricks\.com$/;
|
|
8
|
+
export function postgresEgressError(input) {
|
|
9
|
+
let url;
|
|
10
|
+
try {
|
|
11
|
+
url = new URL(input.trim());
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return `egress entry is not a valid PostgreSQL URL: ${input}`;
|
|
15
|
+
}
|
|
16
|
+
if (url.protocol !== 'postgres:' && url.protocol !== 'postgresql:') {
|
|
17
|
+
return `PostgreSQL egress URLs must use the postgres:// scheme: ${input}`;
|
|
18
|
+
}
|
|
19
|
+
if (url.username !== '' || url.password !== '') {
|
|
20
|
+
return `PostgreSQL egress URLs must not embed credentials: ${input}`;
|
|
21
|
+
}
|
|
22
|
+
if (url.hash !== '')
|
|
23
|
+
return `PostgreSQL egress URLs must not include a fragment: ${input}`;
|
|
24
|
+
if (url.port !== '' && url.port !== '5432') {
|
|
25
|
+
return `PostgreSQL egress is restricted to port 5432: ${input}`;
|
|
26
|
+
}
|
|
27
|
+
const params = [...url.searchParams.entries()];
|
|
28
|
+
if (params.length !== 1 || params[0]?.[0] !== 'sslmode' || params[0]?.[1] !== 'verify-full') {
|
|
29
|
+
return `PostgreSQL egress requires exactly sslmode=verify-full: ${input}`;
|
|
30
|
+
}
|
|
31
|
+
const host = url.hostname.toLowerCase().replace(/\.$/, '');
|
|
32
|
+
if (!LAKEBASE_POSTGRES_HOST_RE.test(host)) {
|
|
33
|
+
return `PostgreSQL egress is restricted to the approved Lakebase database destination: ${input}`;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
@@ -67,6 +67,13 @@ export declare function manifestEgressIpRanges(entries: readonly string[]): stri
|
|
|
67
67
|
*/
|
|
68
68
|
export declare function egressBudgetError(entries: string[]): string | null;
|
|
69
69
|
export declare const managedFunctionManifestSchema: z.ZodObject<{
|
|
70
|
+
ontology: z.ZodOptional<z.ZodObject<{
|
|
71
|
+
version: z.ZodLiteral<1>;
|
|
72
|
+
read: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
73
|
+
write: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
74
|
+
produce: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
75
|
+
invoke: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
76
|
+
}, z.core.$strict>>;
|
|
70
77
|
cache: z.ZodOptional<z.ZodObject<{
|
|
71
78
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
72
79
|
tier: z.ZodDefault<z.ZodEnum<{
|
|
@@ -90,6 +97,7 @@ export declare const managedFunctionManifestSchema: z.ZodObject<{
|
|
|
90
97
|
cpu: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodNumber]>>;
|
|
91
98
|
concurrency: z.ZodDefault<z.ZodNumber>;
|
|
92
99
|
timeout_seconds: z.ZodDefault<z.ZodNumber>;
|
|
100
|
+
max_response_bytes: z.ZodDefault<z.ZodNumber>;
|
|
93
101
|
min_instances: z.ZodDefault<z.ZodNumber>;
|
|
94
102
|
max_instances: z.ZodDefault<z.ZodNumber>;
|
|
95
103
|
invoke_rate_per_minute: z.ZodDefault<z.ZodNumber>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { storageScopesSchema, readStorageScopes } from '@sequenceholdings/storage';
|
|
2
|
+
import { postgresEgressError } from './egress-postgres.js';
|
|
2
3
|
import { cacheManifestSchema, managedFunctionWorkloadLimitsSchema } from '@sequenceholdings/managed-functions/config';
|
|
3
4
|
import { isIP } from 'node:net';
|
|
4
5
|
import { z } from 'zod';
|
|
6
|
+
import { ontologyContractSchema } from '@sequenceholdings/orm/canonical';
|
|
5
7
|
/**
|
|
6
8
|
* CLI-side mirror of the server manifest schema at
|
|
7
9
|
* atlas/src/server/services/managed-functions/manifest.ts — same pattern
|
|
@@ -62,6 +64,10 @@ export function egressEntryError(input) {
|
|
|
62
64
|
const raw = input.trim();
|
|
63
65
|
if (!raw)
|
|
64
66
|
return 'egress entry is empty';
|
|
67
|
+
// Before the IPv4 check: a postgres URL whose host is an address is still
|
|
68
|
+
// a database entry, not an IP bypass.
|
|
69
|
+
if (/^postgres(ql)?:/i.test(raw))
|
|
70
|
+
return postgresEgressError(raw);
|
|
65
71
|
if (looksLikeIpv4EntryCli(raw)) {
|
|
66
72
|
return egressIpError(raw);
|
|
67
73
|
}
|
|
@@ -306,6 +312,8 @@ function partitionEgressEntries(entries) {
|
|
|
306
312
|
for (const entry of entries) {
|
|
307
313
|
if (egressEntryError(entry) !== null)
|
|
308
314
|
continue;
|
|
315
|
+
if (/^postgres(ql)?:/i.test(entry.trim()))
|
|
316
|
+
continue;
|
|
309
317
|
if (looksLikeIpv4EntryCli(entry.trim())) {
|
|
310
318
|
const normalized = normalizeEgressIpCli(entry);
|
|
311
319
|
if (!('error' in normalized))
|
|
@@ -585,6 +593,7 @@ const invocationIpRangeSchema = z
|
|
|
585
593
|
}
|
|
586
594
|
});
|
|
587
595
|
export const managedFunctionManifestSchema = z.object({
|
|
596
|
+
ontology: ontologyContractSchema.optional(),
|
|
588
597
|
cache: cacheManifestSchema.optional(),
|
|
589
598
|
schema_version: z.literal(1).default(1),
|
|
590
599
|
function: z.object({
|
|
@@ -11,7 +11,10 @@ export function parseFunctionsSourceSpec(args) {
|
|
|
11
11
|
if (dir !== undefined && (args.flags.repo !== undefined || args.flags['git-url'] !== undefined)) {
|
|
12
12
|
throw new Error('--dir cannot be combined with --repo / --git-url.');
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
// Functions select --path themselves after materializing (parseFunctionsSourceSelection /
|
|
15
|
+
// resolveFunctionSourceDir); the shared parser would otherwise apply it a second time.
|
|
16
|
+
const { path: _functionPath, ...flags } = args.flags;
|
|
17
|
+
return parseSourceSpec({ positional: dir === undefined ? [] : [dir], flags });
|
|
15
18
|
}
|
|
16
19
|
function validateFunctionRepoPath(path) {
|
|
17
20
|
const segments = path.split('/');
|
package/dist/main.js
CHANGED
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
* seq-studio doctor check token + env + writer gate
|
|
22
22
|
* seq-studio help show usage
|
|
23
23
|
*/
|
|
24
|
-
import { parseArgs } from './
|
|
25
|
-
import {
|
|
24
|
+
import { parseArgs } from './argv.js';
|
|
25
|
+
import { renderCapabilities } from './command-contract.js';
|
|
26
|
+
import { staticHelp } from './command-help.js';
|
|
26
27
|
// Lazy-load artifact delegate: published @sequenceholdings/artifact-studio/cli
|
|
27
28
|
// still auto-runs runCli() at module load; importing it here breaks doctor/process.
|
|
28
29
|
const TOP_LEVEL_USAGE = `usage:
|
|
@@ -30,25 +31,27 @@ const TOP_LEVEL_USAGE = `usage:
|
|
|
30
31
|
seq-studio add <kind> <name> [internal] add a primitive to the current app monorepo
|
|
31
32
|
seq-studio deploy -e <env> [internal] deploy primitives from sequence.app.yml
|
|
32
33
|
seq-studio process <sub> [args] lint | plan | apply | test | simulate | bundle | init
|
|
33
|
-
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
|
|
34
35
|
seq-studio functions <sub> [args] init | build | deploy | list | show | limits | invoke | logs | promote | rollback | delete
|
|
35
36
|
seq-studio storage <sub> [args] init | validate | apply | list | show | mkdir | upload | download | access | trash | restore | purge | operations | abort | delete
|
|
36
|
-
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)
|
|
37
38
|
seq-studio secrets <sub> [args] create | set | list | attach | detach | apply
|
|
38
39
|
seq-studio repos <sub> [args] list | namespaces | show | create | clone | pull | pulls | delete
|
|
39
|
-
seq-studio pipeline <sub> [args] search | describe | schema | sample | query |
|
|
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
|
|
40
41
|
seq-studio auth <sub> [args] whoami | pat create | pat list | pat revoke
|
|
41
|
-
seq-studio orm <sub> [args] init | generate | validate | plan | apply | execute | diff | migrate-from-yaml
|
|
42
|
+
seq-studio orm <sub> [args] init | generate | validate | plan | apply | execute | diff | migrate-from-yaml | import
|
|
42
43
|
seq-studio service-accounts <sub> list | show | create (requires provisioning authority)
|
|
43
44
|
seq-studio access <sub> definitions | list | grant | revoke | resolve
|
|
44
45
|
seq-studio envs <sub> add | list | refresh environments
|
|
45
46
|
seq-studio login [--env <name>] authenticate in the browser
|
|
46
47
|
seq-studio logout [--env <name>] remove one realm's cached user tokens
|
|
47
|
-
seq-studio doctor [-e <env>]
|
|
48
|
+
seq-studio doctor [-e <env>] [--json] [--offline] diagnose config, auth, toolchain, and writer gate
|
|
48
49
|
seq-studio version print the installed version
|
|
50
|
+
seq-studio capabilities [--json] describe command availability and access
|
|
49
51
|
seq-studio help show this message
|
|
50
52
|
|
|
51
53
|
Authenticate with: seq-studio login
|
|
54
|
+
Where supported, --json writes structured stdout; check exit status and pagination.
|
|
52
55
|
Built-in env: local. Authenticated identities discover more via
|
|
53
56
|
\`seq-studio envs refresh\`; custom entries live in ~/.config/lattice/config.toml.
|
|
54
57
|
`;
|
|
@@ -56,8 +59,8 @@ const PROCESS_USAGE = `usage:
|
|
|
56
59
|
seq-studio process init <dir>
|
|
57
60
|
seq-studio process lint [--dir <path>] [--offline]
|
|
58
61
|
seq-studio process plan [--dir <path>] [-e <env>]
|
|
59
|
-
seq-studio process apply [--dir <path>] [-e <env>] [--only <id1,id2,...>]
|
|
60
|
-
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]
|
|
61
64
|
seq-studio process promote <processId> --version <v> [-e <env>]
|
|
62
65
|
seq-studio process pull <processId> [--version <v>] [-e <env>] [--out <dir>] [--no-children]
|
|
63
66
|
seq-studio process test [-e <env>] [--offline]
|
|
@@ -76,6 +79,21 @@ export async function run(argv = process.argv.slice(2)) {
|
|
|
76
79
|
console.log(TOP_LEVEL_USAGE);
|
|
77
80
|
return namespace ? 0 : 1;
|
|
78
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
|
+
}
|
|
79
97
|
switch (namespace) {
|
|
80
98
|
case 'init': {
|
|
81
99
|
const { runAppInitCommand } = await import('./app/commands.js');
|
|
@@ -154,14 +172,26 @@ export async function run(argv = process.argv.slice(2)) {
|
|
|
154
172
|
console.log(currentVersion());
|
|
155
173
|
return 0;
|
|
156
174
|
}
|
|
175
|
+
case 'capabilities':
|
|
176
|
+
return runCapabilities([sub, ...rest].filter((value) => Boolean(value)));
|
|
157
177
|
case 'doctor':
|
|
158
|
-
return doctorCommand(parseArgs([sub, ...rest].filter(Boolean)));
|
|
178
|
+
return (await import('./process/commands.js')).doctorCommand(parseArgs([sub, ...rest].filter(Boolean)));
|
|
159
179
|
default:
|
|
160
180
|
console.error(`unknown command: ${namespace}`);
|
|
161
181
|
console.error(TOP_LEVEL_USAGE);
|
|
162
182
|
return 1;
|
|
163
183
|
}
|
|
164
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
|
+
}
|
|
165
195
|
async function runSessionCommand({ args, command, }) {
|
|
166
196
|
const usage = `usage: seq-studio ${command} [--env <name>]`;
|
|
167
197
|
if (args[0] === 'help' || args[0] === '--help' || args[0] === '-h') {
|
|
@@ -191,32 +221,37 @@ async function runSessionCommand({ args, command, }) {
|
|
|
191
221
|
return 0;
|
|
192
222
|
}
|
|
193
223
|
async function runProcessNamespace(sub, rest) {
|
|
224
|
+
if (hasHelpFlag(sub, rest)) {
|
|
225
|
+
console.log(PROCESS_USAGE);
|
|
226
|
+
return 0;
|
|
227
|
+
}
|
|
194
228
|
if (!sub) {
|
|
195
229
|
console.error(PROCESS_USAGE);
|
|
196
230
|
return 1;
|
|
197
231
|
}
|
|
198
|
-
const
|
|
232
|
+
const processCommands = await import('./process/commands.js');
|
|
233
|
+
const args = processCommands.parseArgs(sub === 'bundle' ? [sub, ...rest] : rest);
|
|
199
234
|
switch (sub) {
|
|
200
235
|
case 'init':
|
|
201
|
-
return initCommand(args);
|
|
236
|
+
return processCommands.initCommand(args);
|
|
202
237
|
case 'lint':
|
|
203
|
-
return lintCommand(args);
|
|
238
|
+
return processCommands.lintCommand(args);
|
|
204
239
|
case 'plan':
|
|
205
|
-
return planCommand(args);
|
|
240
|
+
return processCommands.planCommand(args);
|
|
206
241
|
case 'apply':
|
|
207
|
-
return applyCommand(args);
|
|
242
|
+
return processCommands.applyCommand(args);
|
|
208
243
|
case 'promote':
|
|
209
|
-
return promoteCommand(args);
|
|
244
|
+
return processCommands.promoteCommand(args);
|
|
210
245
|
case 'pull':
|
|
211
|
-
return pullCommand(args);
|
|
246
|
+
return processCommands.pullCommand(args);
|
|
212
247
|
case 'test':
|
|
213
|
-
return testCommand(args);
|
|
248
|
+
return processCommands.testCommand(args);
|
|
214
249
|
case 'simulate':
|
|
215
|
-
return simulateCommand(args);
|
|
250
|
+
return processCommands.simulateCommand(args);
|
|
216
251
|
case 'bundle':
|
|
217
252
|
// bundle command needs the subcommand (build/pull/inspect) in positional[0].
|
|
218
253
|
// parseArgs already includes it because we threaded sub into args.
|
|
219
|
-
return bundleCommand({
|
|
254
|
+
return processCommands.bundleCommand({
|
|
220
255
|
positional: args.positional.slice(1),
|
|
221
256
|
flags: args.flags,
|
|
222
257
|
});
|
|
@@ -235,3 +270,6 @@ async function runProcessNamespace(sub, rest) {
|
|
|
235
270
|
return 1;
|
|
236
271
|
}
|
|
237
272
|
}
|
|
273
|
+
function hasHelpFlag(sub, rest) {
|
|
274
|
+
return sub === 'help' || sub === '--help' || sub === '-h' || rest.some((arg) => arg === '--help' || arg === '-h');
|
|
275
|
+
}
|
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,16 +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';
|
|
12
15
|
import { warnBeforeHostDeploy } from '../manifest-roles-notice.js';
|
|
16
|
+
import { ORM_HELP } from '../command-help.js';
|
|
13
17
|
/**
|
|
14
18
|
* ORM subcommands that talk to Atlas — must not silently target `local`.
|
|
15
|
-
* `init`, `generate`, `validate`, `diff`,
|
|
19
|
+
* `init`, `generate`, `validate`, `diff`, `migrate-from-yaml`, and `import` are offline.
|
|
16
20
|
*/
|
|
17
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']);
|
|
18
24
|
const ORM_USAGE = `usage:
|
|
19
25
|
seq-studio orm init <dir> scaffold a namespace package (v2: TypeScript schema + GraphQL documents)
|
|
20
26
|
seq-studio orm generate [dir] write schema.graphql + operations.manifest.json + typePolicies.gen.ts (offline; runs consumer codegen when codegen.ts is present)
|
|
@@ -23,10 +29,16 @@ const ORM_USAGE = `usage:
|
|
|
23
29
|
seq-studio orm validate [dir] parse + validate definitions and verify committed migrations are in sync
|
|
24
30
|
seq-studio orm plan [dir] -e <env> compile definitions and diff against the registry
|
|
25
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.
|
|
26
36
|
seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
|
|
27
37
|
execute one named persisted operation as the signed-in caller
|
|
28
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)
|
|
29
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)
|
|
30
42
|
|
|
31
43
|
Environments: see \`seq-studio envs list\` (built-in: local; more are
|
|
32
44
|
discovered after you authenticate).
|
|
@@ -44,6 +56,113 @@ export function isOrmPackageMissing(message) {
|
|
|
44
56
|
const specifier = message.match(/Cannot find (?:package|module) '([^']+)'/)?.[1];
|
|
45
57
|
return specifier === '@sequenceholdings/orm' || (specifier?.startsWith('@sequenceholdings/orm/') ?? false);
|
|
46
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
|
+
}
|
|
47
166
|
async function loadOrmCli() {
|
|
48
167
|
try {
|
|
49
168
|
return await import('@sequenceholdings/orm/cli');
|
|
@@ -70,8 +189,20 @@ export async function runOrmCommand(sub, rest) {
|
|
|
70
189
|
}
|
|
71
190
|
const normalized = normalizeShortEnvFlag(rest);
|
|
72
191
|
if (normalized.includes('--help') || normalized.includes('-h')) {
|
|
73
|
-
|
|
74
|
-
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;
|
|
75
206
|
}
|
|
76
207
|
const requested = readEnvFromArgv(normalized);
|
|
77
208
|
if (ORM_NETWORK_SUBS.has(sub) && !requested) {
|
|
@@ -84,13 +215,13 @@ export async function runOrmCommand(sub, rest) {
|
|
|
84
215
|
targetUrl = resolved.url;
|
|
85
216
|
process.env['SEQUENCE_ORM_BASE_URL'] = resolved.url;
|
|
86
217
|
}
|
|
87
|
-
const
|
|
218
|
+
const auth = await tryGetAccessTokenWithMode({
|
|
88
219
|
failClosedForM2m: true,
|
|
89
220
|
env: requested,
|
|
90
221
|
targetUrl,
|
|
91
222
|
});
|
|
92
|
-
if (
|
|
93
|
-
process.env['SEQUENCE_ORM_TOKEN'] = token;
|
|
223
|
+
if (auth)
|
|
224
|
+
process.env['SEQUENCE_ORM_TOKEN'] = auth.token;
|
|
94
225
|
// Lazy import keeps `process`/`doctor` from pulling in the optional ORM package.
|
|
95
226
|
const ormCli = await loadOrmCli();
|
|
96
227
|
if (!ormCli)
|
|
@@ -104,6 +235,8 @@ export async function runOrmCommand(sub, rest) {
|
|
|
104
235
|
return null;
|
|
105
236
|
}
|
|
106
237
|
});
|
|
238
|
+
if (repoSelection)
|
|
239
|
+
return runOrmFromRepo({ sub, selection: repoSelection, auth, targetUrl, ormCli });
|
|
107
240
|
await warnBeforeHostDeploy({ sub, deploySub: 'apply', args: normalized, file: 'namespace.yaml' });
|
|
108
241
|
return runCli([sub, ...normalized]);
|
|
109
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>;
|