@sequenceholdings/studio-cli 0.9.9 → 0.9.12

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.
Files changed (44) hide show
  1. package/README.md +159 -24
  2. package/dist/artifact/delegate.js +8 -4
  3. package/dist/atlas-client.js +6 -57
  4. package/dist/auth.d.ts +0 -1
  5. package/dist/auth.js +9 -1
  6. package/dist/bin.js +7 -2
  7. package/dist/cli-attribution.d.ts +3 -0
  8. package/dist/cli-attribution.js +24 -0
  9. package/dist/command-contract.d.ts +8 -2
  10. package/dist/command-contract.js +3 -2
  11. package/dist/command-help.d.ts +5 -3
  12. package/dist/command-help.js +37 -4
  13. package/dist/command-telemetry.d.ts +11 -0
  14. package/dist/command-telemetry.js +97 -0
  15. package/dist/edge-auth-headers.d.ts +1 -0
  16. package/dist/edge-auth-headers.js +40 -0
  17. package/dist/functions/commands.js +1 -1
  18. package/dist/functions/manifest.js +2 -1
  19. package/dist/main.d.ts +2 -0
  20. package/dist/main.js +50 -3
  21. package/dist/orm/apply-source.d.ts +53 -0
  22. package/dist/orm/apply-source.js +86 -0
  23. package/dist/orm/delegate.js +27 -41
  24. package/dist/orm/deployment-policy.d.ts +2 -0
  25. package/dist/orm/deployment-policy.js +49 -0
  26. package/dist/orm/help.d.ts +1 -0
  27. package/dist/orm/help.js +44 -0
  28. package/dist/orm/history.d.ts +23 -0
  29. package/dist/orm/history.js +58 -0
  30. package/dist/orm/read.d.ts +1 -1
  31. package/dist/orm/read.js +4 -2
  32. package/dist/pipeline/commands.js +2 -1
  33. package/dist/pipeline/templates.js +5 -2
  34. package/dist/principals/commands.d.ts +1 -1
  35. package/dist/principals/commands.js +50 -2
  36. package/dist/process/build.js +6 -0
  37. package/dist/process/codegen.js +2 -0
  38. package/dist/process/commands.js +5 -2
  39. package/dist/process/plan-diff.js +4 -0
  40. package/dist/repos/git-credential.d.ts +8 -1
  41. package/dist/repos/git-credential.js +50 -4
  42. package/dist/templates/guidance/AGENTS.md +5 -0
  43. package/package.json +8 -8
  44. package/templates/guidance/AGENTS.md +5 -0
@@ -6,6 +6,7 @@
6
6
  * SEQUENCE_ORM_BASE_URL, share the seqapi token, forward argv.
7
7
  */
8
8
  import { fileURLToPath } from 'node:url';
9
+ import { ORM_USAGE } from './help.js';
9
10
  import { parseArgs } from '../argv.js';
10
11
  import { parseSourceSpec, resolveArtifactSource, } from '@sequenceholdings/artifact-studio/source-resolver';
11
12
  import { getAccessToken, tryGetAccessTokenWithMode } from '../auth.js';
@@ -15,8 +16,9 @@ import { explicitOrSandboxEnv, normalizeShortEnvFlag, readEnvFromArgv, withoutEn
15
16
  import { REQUIRE_EXPLICIT_ENV_MESSAGE } from '../env-flags.js';
16
17
  import { resolveFunctionSourceDir } from '../functions/source-selection.js';
17
18
  import { warnBeforeHostDeploy } from '../manifest-roles-notice.js';
18
- import { INIT_INTO_REPO_HELP, ORM_DISCOVER_HELP, ORM_EXECUTE_HELP, ORM_HELP } from '../command-help.js';
19
+ import { ORM_DEPLOYMENT_POLICY_HELP, ORM_DISCOVER_HELP, ORM_EXECUTE_HELP, ORM_HELP, ORM_HISTORY_HELP } from '../command-help.js';
19
20
  import { ormVersionMismatch, requiresSchemaVersionCheck } from './version-guard.js';
21
+ import { exportApplySource, exportLocalApplySource, repoOrmApplySource } from './apply-source.js';
20
22
  /**
21
23
  * ORM subcommands that talk to Atlas — must not silently target `local`.
22
24
  * `init`, `generate`, `validate`, `diff`, `migrate-from-yaml`, and `import` are offline.
@@ -24,45 +26,6 @@ import { ormVersionMismatch, requiresSchemaVersionCheck } from './version-guard.
24
26
  const ORM_NETWORK_SUBS = new Set(['plan', 'apply', 'execute']);
25
27
  /** Subcommands that may read their namespace from a git-service repo (`--repo`). */
26
28
  const ORM_REPO_SUBS = new Set(['plan', 'apply']);
27
- const ORM_USAGE = `usage:
28
- seq-studio orm init <dir> [--repo <ns>/<name>]
29
- scaffold a namespace package (v2: TypeScript schema + GraphQL documents);
30
- --repo scaffolds into a git-service repo (see Init into a repo below)
31
- seq-studio orm generate [dir] write schema.graphql + operations.manifest.json + typePolicies.gen.ts (offline; runs consumer codegen when codegen.ts is present)
32
- seq-studio orm generate [dir] --migration-export [--check]
33
- export reviewed ORM inputs for a coordinated pipeline migration; --check verifies without writing
34
- seq-studio orm validate [dir] parse + validate definitions and verify committed migrations are in sync
35
- seq-studio orm plan [dir] -e <env> compile definitions and diff against the registry
36
- seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait]
37
- author the migration, register, apply, and refresh the generated outputs (the everyday command);
38
- waits until the new version is live (default up to 20m; e.g. --timeout 90s), --no-wait returns once queued
39
- seq-studio orm plan|apply --repo <ns>/<name> [--path <dir>] [--ref <ref>] -e <env>
40
- plan/apply a namespace committed to a platform git-service repo (CI deploy-from-git);
41
- --path selects the namespace directory (default: repo root). A remote apply never
42
- authors migrations: the committed ledger must already match the definitions.
43
- seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...
44
- run the deployed version's persisted operation by name as the caller (no checkout)
45
- seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
46
- execute from the checkout manifest through the installed ORM package
47
- both execute forms accept --variables-file - (or /dev/stdin) for JSON stdin until EOF
48
- seq-studio orm read <namespace> <table> -e <env> [--where c=op.v]... [--select c,...] [--order c.desc] [--limit N] [--offset N] [--json|--jsonl]
49
- read rows of a deployed v2 namespace as the caller (row-level security applies)
50
- seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param name[:type]=v]... | [--params <json-object>] [--json|--jsonl]
51
- run read-only SQL against a deployed v2 namespace as the caller
52
- seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]
53
- list the namespaces you can read
54
- seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]
55
- show a namespace's tables, views, and persisted operations (with variables), or one table's columns and actions
56
- 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)
57
- seq-studio orm migrate-from-yaml <dir> convert a v1 YAML namespace to the v2 TypeScript format (offline; migrations/ preserved)
58
- seq-studio orm import [dir] --spec <file> | --table <t> --from <schema.table> --map <target=source,...>
59
- plan a batched copy from an existing Postgres relation into an owned table (writes a SQL script; no database connection)
60
-
61
- Environments: see \`seq-studio envs list\` (built-in: local; more are
62
- discovered after you authenticate).
63
- Authenticate with: seq-studio login
64
-
65
- ${INIT_INTO_REPO_HELP}`;
66
29
  /**
67
30
  * Classify an ERR_MODULE_NOT_FOUND from importing `@sequenceholdings/orm/cli`:
68
31
  * is the orm package itself absent, or is it present but a dependency (e.g.
@@ -180,6 +143,12 @@ async function runOrmFromRepo({ sub, selection, auth, targetUrl, ormCli, }) {
180
143
  'committed migrations are out of date — run `seq-studio orm diff` in the repository, commit the migration, and retry.');
181
144
  return 1;
182
145
  }
146
+ if (sub === 'apply') {
147
+ await exportApplySource({ auth, targetUrl, resolve: () => repoOrmApplySource({
148
+ targetUrl, token: auth.token, namespace: selection.spec.namespace, name: selection.spec.name,
149
+ commit: source.provenance.gitCommit, path: selection.path,
150
+ }) });
151
+ }
183
152
  const args = [dir, ...selection.rest];
184
153
  await warnBeforeHostDeploy({ sub, deploySub: 'apply', args, file: 'namespace.yaml' });
185
154
  return await ormCli.runCli([sub, ...args]);
@@ -221,9 +190,25 @@ export function formatOrmDependencyFailure(message) {
221
190
  * CLI: discovery reads Atlas's registry, and ad-hoc reads go through the ORM
222
191
  * client. None of them needs a namespace directory.
223
192
  */
224
- const NATIVE_ORM_SUBS = new Set(['namespaces', 'describe', 'operation', 'read', 'sql']);
193
+ const NATIVE_ORM_SUBS = new Set(['namespaces', 'describe', 'operation', 'read', 'sql', 'deployment-policy', 'history']);
225
194
  async function runNativeOrmCommand(sub, rest) {
226
195
  const help = rest.includes('--help') || rest.includes('-h');
196
+ if (sub === 'history') {
197
+ if (help) {
198
+ console.log(ORM_HISTORY_HELP);
199
+ return 0;
200
+ }
201
+ const { ormHistoryCommand } = await import('./history.js');
202
+ return ormHistoryCommand(parseArgs(rest));
203
+ }
204
+ if (sub === 'deployment-policy') {
205
+ if (help) {
206
+ console.log(ORM_DEPLOYMENT_POLICY_HELP);
207
+ return 0;
208
+ }
209
+ const { ormDeploymentPolicyCommand } = await import('./deployment-policy.js');
210
+ return ormDeploymentPolicyCommand(parseArgs(rest));
211
+ }
227
212
  if (sub === 'namespaces' || sub === 'describe' || sub === 'operation') {
228
213
  if (help) {
229
214
  console.log(ORM_DISCOVER_HELP);
@@ -350,6 +335,7 @@ export async function runOrmCommand(sub, rest) {
350
335
  return 1;
351
336
  }
352
337
  }
338
+ await exportLocalApplySource({ sub, auth, targetUrl, dir: positionalDir(normalized) });
353
339
  await warnBeforeHostDeploy({ sub, deploySub: 'apply', args: normalized, file: 'namespace.yaml' });
354
340
  return runCli([sub, ...normalized]);
355
341
  }
@@ -0,0 +1,2 @@
1
+ import type { ParsedArgs } from '../argv.js';
2
+ export declare function ormDeploymentPolicyCommand(args: ParsedArgs): Promise<number>;
@@ -0,0 +1,49 @@
1
+ import { resolveRepo } from '@sequenceholdings/artifact-studio/git-service-client';
2
+ import { getJson, putJson } from '../atlas-client.js';
3
+ import { printCliError } from '../cli-errors.js';
4
+ import { requiredStringFlag, validateCommandInput } from '../command-input.js';
5
+ import { buildContext, clientOptions } from '../functions/commands.js';
6
+ function selection(args) {
7
+ validateCommandInput({ args, flags: { mode: 'string', repo: 'string', branch: 'string', target: 'string' }, positional: 1 });
8
+ const mode = args.flags.mode;
9
+ if (mode !== undefined && mode !== 'manual' && mode !== 'ci')
10
+ throw new Error('--mode must be manual or ci.');
11
+ if (mode !== 'ci') {
12
+ if (['repo', 'branch', 'target'].some(key => args.flags[key] !== undefined))
13
+ throw new Error('--repo, --branch and --target require --mode ci.');
14
+ return { mode };
15
+ }
16
+ const repo = requiredStringFlag({ args, key: 'repo' }).split('/');
17
+ if (repo.length !== 2 || !repo[0] || !repo[1])
18
+ throw new Error('--repo must be <namespace>/<name>.');
19
+ return { mode, repositoryNamespace: repo[0], repositoryName: repo[1],
20
+ branch: requiredStringFlag({ args, key: 'branch' }), target: requiredStringFlag({ args, key: 'target' }) };
21
+ }
22
+ export async function ormDeploymentPolicyCommand(args) {
23
+ try {
24
+ const selected = selection(args);
25
+ const options = clientOptions(await buildContext(args));
26
+ const path = `/api/orm/namespaces/${encodeURIComponent(args.positional[0])}/deployment-policy`;
27
+ let result;
28
+ if (selected.mode === undefined)
29
+ result = await getJson({ ...options, path });
30
+ else {
31
+ const body = selected.mode === 'ci'
32
+ ? { mode: 'ci', repository_id: (await resolveRepo({ ...options, namespace: selected.repositoryNamespace, name: selected.repositoryName })).id,
33
+ branch: selected.branch, target_key: selected.target }
34
+ : { mode: 'manual' };
35
+ result = await putJson({ ...options, path, body });
36
+ }
37
+ if (args.flags.json === true)
38
+ console.log(JSON.stringify(result, null, 2));
39
+ else {
40
+ const policy = result.deployment_policy;
41
+ console.log(`${result.namespace}: ${policy.mode === 'manual' ? 'manual deployment' : `CI-managed (${policy.repository_id}, ${policy.branch}, ${policy.target_key})`}`);
42
+ }
43
+ return 0;
44
+ }
45
+ catch (error) {
46
+ printCliError(error);
47
+ return 1;
48
+ }
49
+ }
@@ -0,0 +1 @@
1
+ export declare const ORM_USAGE = "usage:\n seq-studio orm init <dir> [--repo <ns>/<name>]\n scaffold a namespace package (v2: TypeScript schema + GraphQL documents);\n --repo scaffolds into a git-service repo (see Init into a repo below)\n seq-studio orm generate [dir] write schema.graphql + operations.manifest.json + typePolicies.gen.ts (offline; runs consumer codegen when codegen.ts is present)\n seq-studio orm generate [dir] --migration-export [--check]\n export reviewed ORM inputs for a coordinated pipeline migration; --check verifies without writing\n seq-studio orm validate [dir] parse + validate definitions and verify committed migrations are in sync\n seq-studio orm plan [dir] -e <env> compile definitions and diff against the registry\n seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait]\n author the migration, register, apply, and refresh the generated outputs (the everyday command);\n waits until the new version is live (default up to 20m; e.g. --timeout 90s), --no-wait returns once queued\n seq-studio orm plan|apply --repo <ns>/<name> [--path <dir>] [--ref <ref>] -e <env>\n plan/apply a namespace committed to a platform git-service repo (CI deploy-from-git);\n --path selects the namespace directory (default: repo root). A remote apply never\n authors migrations: the committed ledger must already match the definitions.\n seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...\n run the deployed version's persisted operation by name as the caller (no checkout)\n seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>\n execute from the checkout manifest through the installed ORM package\n both execute forms accept --variables-file - (or /dev/stdin) for JSON stdin until EOF\n seq-studio orm read <namespace> <table> -e <env> [--where c=op.v]... [--select c,...] [--order c.desc] [--limit N] [--offset N] [--json|--jsonl]\n read rows of a deployed v2 namespace as the caller (row-level security applies)\n seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param name[:type]=v]... | [--params <json-object>] [--json|--jsonl]\n run read-only SQL against a deployed v2 namespace as the caller\n qualify tables and double-quote mixed-case columns (e.g. SELECT \"loanNumber\" FROM lending.loans)\n seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]\n list the namespaces you can read\n seq-studio orm history <namespace> -e <env> [--limit N] [--json]\n seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci] [--repo <ns>/<name> --branch <branch> --target <target-key>] [--json]\n inspect or explicitly change the namespace's deployment controller\n seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]\n show a namespace's tables, views, and persisted operations (with variables), or one table's columns and actions\n 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)\n seq-studio orm migrate-from-yaml <dir> convert a v1 YAML namespace to the v2 TypeScript format (offline; migrations/ preserved)\n seq-studio orm import [dir] --spec <file> | --table <t> --from <schema.table> --map <target=source,...>\n plan a batched copy from an existing Postgres relation into an owned table (writes a SQL script; no database connection)\n\n Environments: see `seq-studio envs list` (built-in: local; more are\n discovered after you authenticate).\n Authenticate with: seq-studio login\n\n Init into a repo: --repo <ns>/<name> on an init command creates that platform\n git-service repo if missing (same name rules as repos create), then clones it\n into <dir> and scaffolds there, or, when <dir> is inside a Git checkout, sets\n it as that checkout's origin (a different existing origin is refused). It\n needs -e <env>, or an agent sandbox. Nothing is committed or pushed; the\n command prints the git add, commit, and push to run.\n In a git-service checkout (with or without --repo), orm init, functions init\n and artifact init also declare the scaffold under resources in\n .seq/repository.yml, so repository CI checks and deploys it. A scaffold inside\n a declared application is not declared; add it to that app with seq-studio add.\n";
@@ -0,0 +1,44 @@
1
+ import { INIT_INTO_REPO_HELP } from '../command-help.js';
2
+ export const ORM_USAGE = `usage:
3
+ seq-studio orm init <dir> [--repo <ns>/<name>]
4
+ scaffold a namespace package (v2: TypeScript schema + GraphQL documents);
5
+ --repo scaffolds into a git-service repo (see Init into a repo below)
6
+ seq-studio orm generate [dir] write schema.graphql + operations.manifest.json + typePolicies.gen.ts (offline; runs consumer codegen when codegen.ts is present)
7
+ seq-studio orm generate [dir] --migration-export [--check]
8
+ export reviewed ORM inputs for a coordinated pipeline migration; --check verifies without writing
9
+ seq-studio orm validate [dir] parse + validate definitions and verify committed migrations are in sync
10
+ seq-studio orm plan [dir] -e <env> compile definitions and diff against the registry
11
+ seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait]
12
+ author the migration, register, apply, and refresh the generated outputs (the everyday command);
13
+ waits until the new version is live (default up to 20m; e.g. --timeout 90s), --no-wait returns once queued
14
+ seq-studio orm plan|apply --repo <ns>/<name> [--path <dir>] [--ref <ref>] -e <env>
15
+ plan/apply a namespace committed to a platform git-service repo (CI deploy-from-git);
16
+ --path selects the namespace directory (default: repo root). A remote apply never
17
+ authors migrations: the committed ledger must already match the definitions.
18
+ seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...
19
+ run the deployed version's persisted operation by name as the caller (no checkout)
20
+ seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
21
+ execute from the checkout manifest through the installed ORM package
22
+ both execute forms accept --variables-file - (or /dev/stdin) for JSON stdin until EOF
23
+ seq-studio orm read <namespace> <table> -e <env> [--where c=op.v]... [--select c,...] [--order c.desc] [--limit N] [--offset N] [--json|--jsonl]
24
+ read rows of a deployed v2 namespace as the caller (row-level security applies)
25
+ seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param name[:type]=v]... | [--params <json-object>] [--json|--jsonl]
26
+ run read-only SQL against a deployed v2 namespace as the caller
27
+ qualify tables and double-quote mixed-case columns (e.g. SELECT "loanNumber" FROM lending.loans)
28
+ seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]
29
+ list the namespaces you can read
30
+ seq-studio orm history <namespace> -e <env> [--limit N] [--json]
31
+ seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci] [--repo <ns>/<name> --branch <branch> --target <target-key>] [--json]
32
+ inspect or explicitly change the namespace's deployment controller
33
+ seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]
34
+ show a namespace's tables, views, and persisted operations (with variables), or one table's columns and actions
35
+ 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)
36
+ seq-studio orm migrate-from-yaml <dir> convert a v1 YAML namespace to the v2 TypeScript format (offline; migrations/ preserved)
37
+ seq-studio orm import [dir] --spec <file> | --table <t> --from <schema.table> --map <target=source,...>
38
+ plan a batched copy from an existing Postgres relation into an owned table (writes a SQL script; no database connection)
39
+
40
+ Environments: see \`seq-studio envs list\` (built-in: local; more are
41
+ discovered after you authenticate).
42
+ Authenticate with: seq-studio login
43
+
44
+ ${INIT_INTO_REPO_HELP}`;
@@ -0,0 +1,23 @@
1
+ import type { ParsedArgs } from '../argv.js';
2
+ export interface ActivationRow {
3
+ id: string;
4
+ kind: 'schema' | 'operations' | 'attest';
5
+ version_id: string;
6
+ operation_set_id: string | null;
7
+ provenance_class: 'repository_verified' | 'ci_intent' | 'reported';
8
+ source_repository_id: string | null;
9
+ source_commit: string | null;
10
+ source_branch: string | null;
11
+ source_path: string | null;
12
+ intent_id: string | null;
13
+ ledger_ordinal: number | null;
14
+ reported_source: Record<string, unknown> | null;
15
+ actor_sub: string;
16
+ activated_at: string;
17
+ }
18
+ /** One line per activation: when, who, what moved, and where it came from. */
19
+ export declare function formatActivation({ row, active }: {
20
+ row: ActivationRow;
21
+ active: boolean;
22
+ }): string;
23
+ export declare function ormHistoryCommand(args: ParsedArgs): Promise<number>;
@@ -0,0 +1,58 @@
1
+ import { getJson } from '../atlas-client.js';
2
+ import { printCliError } from '../cli-errors.js';
3
+ import { validateCommandInput } from '../command-input.js';
4
+ import { buildContext, clientOptions } from '../functions/commands.js';
5
+ const DEFAULT_LIMIT = 20;
6
+ function limitFlag(args) {
7
+ const raw = args.flags.limit;
8
+ if (raw === undefined)
9
+ return DEFAULT_LIMIT;
10
+ const limit = Number(raw);
11
+ if (!Number.isInteger(limit) || limit < 1 || limit > 500)
12
+ throw new Error('--limit must be an integer from 1 to 500.');
13
+ return limit;
14
+ }
15
+ /** One line per activation: when, who, what moved, and where it came from. */
16
+ export function formatActivation({ row, active }) {
17
+ const actor = row.actor_sub.replace(/^google-apps\|/, '');
18
+ const what = row.kind === 'schema' ? `schema ${row.version_id.slice(0, 8)}${row.ledger_ordinal === null ? '' : ` (ledger ${row.ledger_ordinal})`}`
19
+ : row.kind === 'operations' ? `operations ${row.operation_set_id?.slice(0, 8) ?? '-'}`
20
+ : `attest ${row.version_id.slice(0, 8)}`;
21
+ const claimed = row.reported_source;
22
+ const where = row.provenance_class === 'reported'
23
+ ? `reported${typeof claimed?.commit === 'string' ? ` ${claimed.commit.slice(0, 12)}` : ''}${typeof claimed?.verification_failure === 'string' ? ` (${claimed.verification_failure})` : ''}`
24
+ : `${row.provenance_class === 'ci_intent' ? 'ci' : 'verified'} ${row.source_commit?.slice(0, 12)} on ${row.source_branch} at ${row.source_path === '' ? '.' : row.source_path}`;
25
+ return `${active ? '*' : ' '} ${row.activated_at.slice(0, 19).replace('T', ' ')}Z ${what.padEnd(28)} ${actor.padEnd(32)} ${where}`;
26
+ }
27
+ export async function ormHistoryCommand(args) {
28
+ try {
29
+ validateCommandInput({ args, flags: { limit: 'string' }, positional: 1 });
30
+ const namespace = args.positional[0];
31
+ if (!namespace)
32
+ throw new Error('usage: seq-studio orm history <namespace> -e <env> [--limit N] [--json]');
33
+ const limit = limitFlag(args);
34
+ const options = clientOptions(await buildContext(args));
35
+ const result = await getJson({
36
+ ...options,
37
+ path: `/api/orm/namespaces/${encodeURIComponent(namespace)}?versions_limit=1&ledger_limit=1&activations_limit=${limit}`,
38
+ });
39
+ if (result.activations === undefined)
40
+ throw new Error('This Atlas does not record activation history yet.');
41
+ if (args.flags.json === true) {
42
+ console.log(JSON.stringify({ namespace, activations: result.activations, activations_total: result.activations_total }, null, 2));
43
+ return 0;
44
+ }
45
+ if (result.activations.length === 0) {
46
+ console.log(`${namespace}: no activations recorded yet (history starts with the first apply after it shipped)`);
47
+ return 0;
48
+ }
49
+ console.log(`${namespace}: ${result.activations_total ?? result.activations.length} activation(s), newest first; * = live`);
50
+ for (const row of result.activations)
51
+ console.log(formatActivation({ row, active: row.id === result.namespace.active_activation_id }));
52
+ return 0;
53
+ }
54
+ catch (error) {
55
+ printCliError(error);
56
+ return 1;
57
+ }
58
+ }
@@ -12,7 +12,7 @@
12
12
  */
13
13
  import type { SqlQueryParameter, SqlQueryVariables } from '@sequenceholdings/orm/client';
14
14
  import type { ParsedArgs } from '../process/commands.js';
15
- export declare const ORM_READ_USAGE = "usage:\n seq-studio orm read <namespace> <table> -e <env> [--where <column>=<op>.<value>]...\n [--select <col,...>] [--order <column>[.asc|.desc]]... [--limit N] [--offset N] [--json | --jsonl]\n seq-studio orm sql <namespace> (--query <sql> | --file <path>) -e <env>\n [--param <name>[:<type>]=<value>]... | [--params <json-object>] [--json | --jsonl]\n\n Reads run as you against an ORM v2 namespace: its grants, row-level security,\n and a read-only SQL grammar apply on the server, which returns at most 1,000 rows.\n\n --where operators: eq, ne, gt, gte, lt, lte, in, is\n --where status=eq.open --where balance=gte.1000 --where id=in.(a,b,c) --where closed_at=is.null\n sql binds :name placeholders. --param types: text (default), uuid, date, timestamptz,\n numeric, bigint, integer, double, boolean. --params takes the wire shape, e.g.\n '{\"limit\": {\"type\": \"integer\", \"value\": 5}}', and allows null values.\n sql must reference every table as <namespace>.<table> (SELECT id FROM lending.loans, not\n FROM loans); unqualified names and queries without a table (SELECT 1) are rejected.\n The grammar is read-only SELECT with joins, CTEs, UNION, aggregates, and comparison\n operators (no LIKE or IN).\n --json prints a JSON array of row objects; --jsonl prints one row object per line.\n Without either, rows print as a table. Counts, truncation, and paging hints go to stderr.\n";
15
+ export declare const ORM_READ_USAGE = "usage:\n seq-studio orm read <namespace> <table> -e <env> [--where <column>=<op>.<value>]...\n [--select <col,...>] [--order <column>[.asc|.desc]]... [--limit N] [--offset N] [--json | --jsonl]\n seq-studio orm sql <namespace> (--query <sql> | --file <path>) -e <env>\n [--param <name>[:<type>]=<value>]... | [--params <json-object>] [--json | --jsonl]\n\n Reads run as you against an ORM v2 namespace: its grants, row-level security,\n and a read-only SQL grammar apply on the server, which returns at most 1,000 rows.\n\n --where operators: eq, ne, gt, gte, lt, lte, in, is\n --where status=eq.open --where balance=gte.1000 --where id=in.(a,b,c) --where closed_at=is.null\n sql binds :name placeholders. --param types: text (default), uuid, date, timestamptz,\n numeric, bigint, integer, double, boolean. --params takes the wire shape, e.g.\n '{\"limit\": {\"type\": \"integer\", \"value\": 5}}', and allows null values.\n sql must reference every table as <namespace>.<table> (SELECT id FROM lending.loans, not\n FROM loans); unqualified names and queries without a table (SELECT 1) are rejected.\n Quote mixed-case column names: SELECT \"loanNumber\" FROM lending.loans.\n The grammar is read-only SELECT with joins, CTEs, UNION, aggregates, and comparison\n operators (no LIKE or IN).\n --json prints a JSON array of row objects; --jsonl prints one row object per line.\n Without either, rows print as a table. Counts, truncation, and paging hints go to stderr.\n";
16
16
  export interface ReadFilter {
17
17
  column: string;
18
18
  op: string;
package/dist/orm/read.js CHANGED
@@ -32,6 +32,7 @@ export const ORM_READ_USAGE = `usage:
32
32
  '{"limit": {"type": "integer", "value": 5}}', and allows null values.
33
33
  sql must reference every table as <namespace>.<table> (SELECT id FROM lending.loans, not
34
34
  FROM loans); unqualified names and queries without a table (SELECT 1) are rejected.
35
+ Quote mixed-case column names: SELECT "loanNumber" FROM lending.loans.
35
36
  The grammar is read-only SELECT with joins, CTEs, UNION, aggregates, and comparison
36
37
  operators (no LIKE or IN).
37
38
  --json prints a JSON array of row objects; --jsonl prints one row object per line.
@@ -301,8 +302,9 @@ function isRejectedSql(error) {
301
302
  return error instanceof Error && error.name === 'OrmOperationError' && Reflect.get(error, 'code') === 'BAD_USER_INPUT';
302
303
  }
303
304
  export function sqlGrammarHint(namespace) {
304
- return `[seq-studio] hint: reference every table as <namespace>.<table> (e.g. SELECT count(*) FROM ${namespace}.<table>); `
305
- + 'unqualified names and queries without a table are rejected. The grammar is read-only SELECT with joins, '
305
+ return `[seq-studio] hint: check table qualification (e.g. SELECT count(*) FROM ${namespace}.<table>) `
306
+ + 'and double-quote mixed-case columns (e.g. SELECT "loanNumber" FROM '
307
+ + `${namespace}.<table>). Unqualified tables and queries without a table are rejected. The grammar is read-only SELECT with joins, `
306
308
  + 'CTEs, UNION, aggregates (count, sum, avg, min, max), lower/upper/length, and comparison operators; '
307
309
  + 'it has no LIKE or IN. See: seq-studio orm sql --help.';
308
310
  }
@@ -11,6 +11,7 @@
11
11
  * The SDK is lazy-imported like `@sequenceholdings/orm` so public installs of
12
12
  * the CLI without the package get a clear install hint instead of a crash.
13
13
  */
14
+ import { cliAttributionHeaders } from '../cli-attribution.js';
14
15
  import { pipelineSourceError } from './source.js';
15
16
  import { mkdir, readFile, writeFile } from 'node:fs/promises';
16
17
  import { existsSync } from 'node:fs';
@@ -277,7 +278,7 @@ export function buildExternalAssetsRequest({ source, knownOrigins, token, }) {
277
278
  return {
278
279
  url,
279
280
  init: {
280
- headers: { authorization: `Bearer ${token}` },
281
+ headers: { authorization: `Bearer ${token}`, ...cliAttributionHeaders() },
281
282
  redirect: 'manual',
282
283
  },
283
284
  };
@@ -30,6 +30,9 @@ const INGESTION_BODY = `
30
30
  # Where the ingestion code runs: databricks (API pulls) | edge-worker (on-prem VM).
31
31
  # ('upload' is reserved — not yet supported.)
32
32
  runtime: databricks
33
+ # Optional source schema for both raw files and materialized source tables.
34
+ # Omitted preserves legacy bronze paths; changing an existing stage needs migration.
35
+ # source_schema: raw
33
36
  # databricks runtime pulls from an external system (symbolic refs, never secrets).
34
37
  # Secure-by-default: declare a credential for authenticated APIs. Attach a
35
38
  # managed secret to it per deploy target (seq-studio secrets attach <NAME>
@@ -48,8 +51,8 @@ source:
48
51
  feeds:
49
52
  # One feed = one stream of raw files into the volume landing zone.
50
53
  # The platform derives (per-source catalog, never the deployment catalog):
51
- # /Volumes/src_<source>/bronze/<feed>/batch_id=<ts>/, the bronze table
52
- # src_<source>.bronze.<feed>, envelope columns (batch_id, ingested_at,
54
+ # /Volumes/src_<source>/<source_schema>/<feed>/batch_id=<ts>/, the source table
55
+ # src_<source>.<source_schema>.<feed>, envelope columns (batch_id, ingested_at,
53
56
  # source_system, content_hash), and a presence manifest for full_snapshot.
54
57
  my_feed:
55
58
  # full_snapshot | incremental | event_stream
@@ -1,3 +1,3 @@
1
1
  import type { ParsedArgs } from '../process/commands.js';
2
- export declare const PRINCIPALS_USAGE = "usage:\n seq-studio principals search <query> -e <env> [--types user,group,service-account,organization] [--limit <n>]\n seq-studio principals users search <query> -e <env> [--limit <n>]\n seq-studio principals groups list -e <env> [--search <query>] [--limit <n>] [--page <n>]\n seq-studio principals groups show <group-id> -e <env> [--limit <n>] [--offset <n>]\n\n Find the people, groups, service accounts and organizations YOU may grant\n access to, with the exact ids seq-studio access grant takes. Results are JSON;\n each principal carries \"grant\": { \"principalType\", \"principalId\" }.\n Queries need at least 2 characters. search defaults to user,group,service-account.\n\n You see exactly what the Atlas pickers show you, never more:\n people: active users in your organization (Sequence operators: everyone);\n groups: groups you belong to (platform admins: every group), never deleted ones;\n service accounts: accounts you hold actor on; organizations: your own tenant.\n groups show lists a visible group's active members, paged (default 50 per\n page); a group you can't see is reported as not found.\n Authenticate: seq-studio login --env <env> (agent sandbox tokens work too).\n";
2
+ export declare const PRINCIPALS_USAGE = "usage:\n seq-studio principals search <query> -e <env> [--types user,group,service-account,organization] [--limit <n>]\n seq-studio principals users search <query> -e <env> [--limit <n>]\n seq-studio principals groups list -e <env> [--search <query>] [--limit <n>] [--page <n>]\n seq-studio principals groups show <group-id> -e <env> [--limit <n>] [--offset <n>]\n seq-studio principals groups create <name> -e <env> [--description <text>] [--request-id <uuid>]\n seq-studio principals groups members add <group-id> -e <env> --principal-id <user-sub> [--principal-id <user-sub> ...]\n seq-studio principals groups members remove <group-id> -e <env> --principal-id <user-sub>\n\n Find the people, groups, service accounts and organizations YOU may grant\n access to, with the exact ids seq-studio access grant takes. Results are JSON;\n each principal carries \"grant\": { \"principalType\", \"principalId\" }.\n Queries need at least 2 characters. search defaults to user,group,service-account.\n\n You see exactly what the Atlas pickers show you, never more:\n people: active users in your organization (Sequence operators: everyone);\n groups: groups you belong to (platform admins: every group), never deleted ones;\n service accounts: accounts you hold actor on; organizations: your own tenant.\n groups show lists a visible group's active members, paged (default 50 per\n page); a group you can't see is reported as not found.\n Create makes a local group with you as admin. It prints its request UUID\n before sending; reuse --request-id <uuid> to safely retry an uncertain result.\n Member IDs are the authenticated subjects returned by users search, not\n emails or directory row IDs. Add accepts 1\u201350 IDs, leaves existing roles\n unchanged, and rejects disabled or out-of-tenant users. Managing members\n requires permission to administer a CLI-created group in your tenant.\n Remove revokes one member and refuses to\n remove the last group admin. Members may always leave their own group.\n Mutation receipts are JSON.\n Authenticate: seq-studio login --env <env> (agent sandbox tokens work too).\n";
3
3
  export declare function runPrincipalsCommand(sub: string | undefined, args: ParsedArgs): Promise<number>;
@@ -1,6 +1,7 @@
1
- import { getJson } from '../atlas-client.js';
1
+ import { randomUUID } from 'node:crypto';
2
+ import { getJson, requestJsonOnce } from '../atlas-client.js';
2
3
  import { printCliError } from '../cli-errors.js';
3
- import { validateCommandInput, wantsHelp } from '../command-input.js';
4
+ import { requiredStringFlag, validateCommandInput, wantsHelp } from '../command-input.js';
4
5
  import { buildContext, clientOptions } from '../functions/commands.js';
5
6
  const SEARCH_TYPES = ['user', 'group', 'service-account', 'organization'];
6
7
  export const PRINCIPALS_USAGE = `usage:
@@ -8,6 +9,9 @@ export const PRINCIPALS_USAGE = `usage:
8
9
  seq-studio principals users search <query> -e <env> [--limit <n>]
9
10
  seq-studio principals groups list -e <env> [--search <query>] [--limit <n>] [--page <n>]
10
11
  seq-studio principals groups show <group-id> -e <env> [--limit <n>] [--offset <n>]
12
+ seq-studio principals groups create <name> -e <env> [--description <text>] [--request-id <uuid>]
13
+ seq-studio principals groups members add <group-id> -e <env> --principal-id <user-sub> [--principal-id <user-sub> ...]
14
+ seq-studio principals groups members remove <group-id> -e <env> --principal-id <user-sub>
11
15
 
12
16
  Find the people, groups, service accounts and organizations YOU may grant
13
17
  access to, with the exact ids seq-studio access grant takes. Results are JSON;
@@ -20,6 +24,15 @@ export const PRINCIPALS_USAGE = `usage:
20
24
  service accounts: accounts you hold actor on; organizations: your own tenant.
21
25
  groups show lists a visible group's active members, paged (default 50 per
22
26
  page); a group you can't see is reported as not found.
27
+ Create makes a local group with you as admin. It prints its request UUID
28
+ before sending; reuse --request-id <uuid> to safely retry an uncertain result.
29
+ Member IDs are the authenticated subjects returned by users search, not
30
+ emails or directory row IDs. Add accepts 1–50 IDs, leaves existing roles
31
+ unchanged, and rejects disabled or out-of-tenant users. Managing members
32
+ requires permission to administer a CLI-created group in your tenant.
33
+ Remove revokes one member and refuses to
34
+ remove the last group admin. Members may always leave their own group.
35
+ Mutation receipts are JSON.
23
36
  Authenticate: seq-studio login --env <env> (agent sandbox tokens work too).
24
37
  `;
25
38
  function withGrant(principal) {
@@ -105,12 +118,47 @@ function present(shape, body) {
105
118
  members: (record.members ?? []).map(withGrant),
106
119
  };
107
120
  }
121
+ async function mutateGroup(args) {
122
+ const [action, target, verb] = args.positional;
123
+ if (action === 'create') {
124
+ validateCommandInput({ args, flags: { description: 'string', 'request-id': 'string' }, positional: 2 });
125
+ if (!target?.trim() || target.trim().length > 200)
126
+ throw new Error('Group name must be 1–200 characters.');
127
+ const id = typeof args.flags['request-id'] === 'string' ? args.flags['request-id'] : randomUUID();
128
+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id))
129
+ throw new Error('--request-id must be a UUID.');
130
+ const description = args.flags.description;
131
+ const body = { id, name: target.trim(), ...(typeof description === 'string' ? { description: description.trim() } : {}) };
132
+ const ctx = await buildContext(args);
133
+ console.error(`Group request ID: ${id} (reuse with --request-id to retry)`);
134
+ return requestJsonOnce({ ...clientOptions(ctx), path: '/api/authz/principals/groups', method: 'POST', body });
135
+ }
136
+ if (action === 'members' && (target === 'add' || target === 'remove')) {
137
+ validateCommandInput({ args, flags: { 'principal-id': 'string' }, positional: 3 });
138
+ if (!verb?.trim())
139
+ throw new Error('A group ID is required.');
140
+ const ids = args.repeatedFlags?.['principal-id'] ?? [requiredStringFlag({ args, key: 'principal-id' })];
141
+ if (ids.length < 1 || ids.length > (target === 'add' ? 50 : 1) || new Set(ids).size !== ids.length || ids.some((id) => !id.includes('|') || /[#*\s]/.test(id))) {
142
+ throw new Error('Pass distinct authenticated user subjects with --principal-id (1–50 for add, one for remove).');
143
+ }
144
+ const ctx = await buildContext(args);
145
+ const path = `/api/authz/principals/groups/${encodeURIComponent(verb)}/members`;
146
+ return target === 'add'
147
+ ? requestJsonOnce({ ...clientOptions(ctx), path, method: 'POST', body: { principalIds: ids } })
148
+ : requestJsonOnce({ ...clientOptions(ctx), path: `${path}/${encodeURIComponent(ids[0])}`, method: 'DELETE' });
149
+ }
150
+ throw new Error('Usage: seq-studio principals groups create|members add|members remove. See: seq-studio principals --help');
151
+ }
108
152
  export async function runPrincipalsCommand(sub, args) {
109
153
  if (!sub || wantsHelp({ sub, args })) {
110
154
  console.log(PRINCIPALS_USAGE);
111
155
  return sub ? 0 : 1;
112
156
  }
113
157
  try {
158
+ if (sub === 'groups' && (args.positional[0] === 'create' || args.positional[0] === 'members')) {
159
+ console.log(JSON.stringify(await mutateGroup(args), null, 2));
160
+ return 0;
161
+ }
114
162
  const { path, shape } = requestPath(sub, args);
115
163
  const ctx = await buildContext(args);
116
164
  const body = await getJson({ ...clientOptions(ctx), path });
@@ -293,6 +293,11 @@ function serializeNodeMetadata(node) {
293
293
  }
294
294
  case 'subprocess': {
295
295
  const subprocess = node;
296
+ // Child title/entity mappers serialize only when authored, so existing
297
+ // bundles keep their hashes.
298
+ const childMappers = {};
299
+ serializeMapperSlot(childMappers, 'child_title_mapper', subprocess.child_title);
300
+ serializeMapperSlot(childMappers, 'child_entity_mapper', subprocess.child_entity);
296
301
  const smeta = {
297
302
  process_id: subprocess.process,
298
303
  version: subprocess.version ?? '',
@@ -304,6 +309,7 @@ function serializeNodeMetadata(node) {
304
309
  ...(subprocess.supervisor_retry !== undefined
305
310
  ? { supervisor_retry: serializeRetryConfig(subprocess.supervisor_retry) }
306
311
  : {}),
312
+ ...childMappers,
307
313
  };
308
314
  const meta = { subprocess: smeta };
309
315
  serializeMapperSlot(meta, 'input_mapper', subprocess.input);
@@ -171,6 +171,8 @@ function emitNode(node, ctx) {
171
171
  : null,
172
172
  bindings(m.bindings),
173
173
  mapper('input', m.input_mapper_source, m.input_mapper_expr, ctx),
174
+ mapper('child_title', sub.child_title_mapper_source, sub.child_title_mapper_expr, ctx),
175
+ mapper('child_entity', sub.child_entity_mapper_source, sub.child_entity_mapper_expr, ctx),
174
176
  requiredMapper('output', sub.output_mapper_source, sub.output_mapper_expr, ctx, `subprocess node "${node.id}"`),
175
177
  tail,
176
178
  ]);
@@ -225,9 +225,12 @@ async function tryBuildAgentLoader(args) {
225
225
  return undefined;
226
226
  // Agent loader is only meaningful when we have a target env + token.
227
227
  // If either fails to resolve, skip the check; lint will emit a warning
228
- // for multi-edge agent nodes instead of failing.
228
+ // for multi-edge agent nodes instead of failing. The check is optional, so
229
+ // it never opens a browser login (CI sandboxes would wait out the timeout).
229
230
  try {
230
- const { env, token } = await getEnvAndToken(args);
231
+ const requested = typeof args.flags.env === 'string' ? args.flags.env : undefined;
232
+ const env = await resolveConfiguredEnv({ requested });
233
+ const token = await getAccessToken({ env: env.name, targetUrl: env.url, allowInteractiveLogin: false });
231
234
  return buildAgentSchemaLoader({ baseUrl: env.url, token });
232
235
  }
233
236
  catch {
@@ -241,6 +241,10 @@ const SUBPROCESS_BEHAVIORAL_FIELDS = [
241
241
  'on_child_error',
242
242
  'output_mapper_source',
243
243
  'output_mapper_expr',
244
+ 'child_title_mapper_source',
245
+ 'child_title_mapper_expr',
246
+ 'child_entity_mapper_source',
247
+ 'child_entity_mapper_expr',
244
248
  'supervisor_retry',
245
249
  ];
246
250
  function diffNode(a, b) {
@@ -7,10 +7,17 @@ export declare function gitCredentialResponse({ input, operation, envName, clone
7
7
  envName?: string;
8
8
  cloneUrl?: string;
9
9
  }): Promise<string>;
10
+ /** Select the stable launcher that invoked this CLI, not the first one on a later Git PATH. */
11
+ export declare function resolveGitHelperLauncher({ scriptPath, launcherHint, searchPath, }?: {
12
+ scriptPath?: string;
13
+ launcherHint?: string;
14
+ searchPath?: string;
15
+ }): Promise<string>;
10
16
  /** Store only a helper command, bound to this environment and repository URL. */
11
- export declare function configureGitLogin({ destDir, envName, cloneUrl, }: {
17
+ export declare function configureGitLogin({ destDir, envName, cloneUrl, launcherPath, }: {
12
18
  destDir: string;
13
19
  envName: string;
14
20
  cloneUrl: string;
21
+ launcherPath?: string;
15
22
  }): Promise<void>;
16
23
  export declare function gitCredentialCommand(args: ParsedArgs): Promise<number>;