@sequenceholdings/studio-cli 0.6.1 → 0.6.4
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 +186 -21
- package/dist/app/commands.d.ts +1 -1
- package/dist/app/commands.js +11 -6
- package/dist/app/deploy.js +4 -3
- package/dist/app/env-bindings.d.ts +3 -4
- package/dist/app/env-bindings.js +14 -77
- package/dist/app/readme.js +2 -2
- package/dist/app/repository-admission.d.ts +5 -0
- package/dist/app/repository-admission.js +32 -0
- package/dist/app/scaffold-files.js +8 -1
- package/dist/artifact/delegate.d.ts +4 -0
- package/dist/artifact/delegate.js +18 -8
- package/dist/artifact/sandbox.d.ts +29 -0
- package/dist/artifact/sandbox.js +109 -0
- package/dist/atlas-client.d.ts +1 -0
- package/dist/atlas-client.js +11 -2
- package/dist/auth-cmds/commands.js +3 -0
- package/dist/command-contract.d.ts +8 -2
- package/dist/command-contract.js +3 -2
- package/dist/command-help.d.ts +7 -4
- package/dist/command-help.js +43 -3
- package/dist/env-flags.d.ts +6 -0
- package/dist/env-flags.js +23 -1
- package/dist/envs/commands.js +30 -4
- package/dist/feedback/commands.d.ts +3 -0
- package/dist/feedback/commands.js +108 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +14 -16
- package/dist/orm/delegate.js +30 -11
- package/dist/orm/discover-schema.d.ts +196 -0
- package/dist/orm/discover-schema.js +84 -0
- package/dist/orm/discover.d.ts +13 -0
- package/dist/orm/discover.js +289 -0
- package/dist/pipeline/lifecycle.js +2 -1
- package/dist/pipeline/repin-orm.js +8 -1
- package/dist/pipeline/source.js +3 -0
- package/dist/repos/commands.js +9 -0
- package/dist/repos/identity-file.d.ts +17 -0
- package/dist/repos/identity-file.js +39 -0
- package/dist/repos/identity.d.ts +2 -0
- package/dist/repos/identity.js +69 -0
- package/dist/sandbox-auth.d.ts +11 -0
- package/dist/sandbox-auth.js +22 -0
- package/dist/update-check.d.ts +3 -1
- package/dist/update-check.js +38 -12
- package/package.json +3 -3
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { open } from 'node:fs/promises';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { AtlasApiError, requestJsonOnce } from '../atlas-client.js';
|
|
4
|
+
const reportSchema = z.strictObject({
|
|
5
|
+
title: z.string().trim().min(1).max(160),
|
|
6
|
+
observedBehavior: z.string().trim().min(1).max(3000),
|
|
7
|
+
intent: z.string().max(1000).optional(), expectedBehavior: z.string().max(1000).optional(),
|
|
8
|
+
suggestion: z.string().max(1000).optional(), commandOrEndpoint: z.string().max(500).optional(),
|
|
9
|
+
sanitizedError: z.string().max(1000).optional(), workaround: z.string().max(1000).optional(),
|
|
10
|
+
impact: z.string().max(500).optional(), evidence: z.string().max(1000).optional(),
|
|
11
|
+
clientVersion: z.string().max(100).optional(), submissionId: z.uuid().optional(),
|
|
12
|
+
agent: z.strictObject({ application: z.string().max(100).optional(), provider: z.string().max(100).optional(),
|
|
13
|
+
modelId: z.string().max(200).optional(), version: z.string().max(100).optional() }).optional(),
|
|
14
|
+
});
|
|
15
|
+
const receiptSchema = z.object({ status: z.literal('recorded'), receiptId: z.string(),
|
|
16
|
+
ticketUrl: z.url(), message: z.string() });
|
|
17
|
+
export const FEEDBACK_HELP = `usage: seq-studio feedback submit --file report.json [-e <env>] [--json]
|
|
18
|
+
|
|
19
|
+
Submit a short, sanitized report using your normal Sequence credentials. Example:
|
|
20
|
+
{"title":"Deploy command retried unexpectedly","observedBehavior":"The command returned 503 before validation","agent":{"application":"Codex","provider":"OpenAI","modelId":"unknown"}}
|
|
21
|
+
|
|
22
|
+
Include errors, confusing behavior, missing docs or capabilities, repeated retries, and
|
|
23
|
+
successful workarounds even when the cause is uncertain. Do not search for duplicates
|
|
24
|
+
before submitting. Report each independent occurrence, including known issues; group
|
|
25
|
+
repeated symptoms within one incident. Do not suppress independent tasks or reporters.
|
|
26
|
+
Do not attach transcripts, customer records, secrets, or raw logs. Receipt confirms
|
|
27
|
+
Linear creation; otherwise keep your draft and submission evidence. Do not blindly
|
|
28
|
+
resubmit an uncertain write. submissionId is correlation, not idempotency.
|
|
29
|
+
Agent and model fields are client-reported.
|
|
30
|
+
`;
|
|
31
|
+
async function readReport(path) {
|
|
32
|
+
const file = await open(path, 'r').catch(() => {
|
|
33
|
+
throw new Error('Report file cannot be read. Check --file path and permissions; no request was sent.');
|
|
34
|
+
});
|
|
35
|
+
try {
|
|
36
|
+
const buffer = Buffer.alloc(12_289);
|
|
37
|
+
let size = 0;
|
|
38
|
+
for (;;) {
|
|
39
|
+
const chunk = await file.read(buffer, size, buffer.length - size, null);
|
|
40
|
+
size += chunk.bytesRead;
|
|
41
|
+
if (size > 12_288)
|
|
42
|
+
throw new Error('Report exceeds 12 KiB. Shorten and sanitize the draft.');
|
|
43
|
+
if (!chunk.bytesRead)
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
return JSON.parse(buffer.subarray(0, size).toString('utf8'));
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
throw new Error('Report file must be valid JSON. Correct it and make one new attempt.');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
await file.close();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export async function runFeedbackCommand(sub, args) {
|
|
58
|
+
if (!sub || args.flags.help === true) {
|
|
59
|
+
console.log(FEEDBACK_HELP);
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
if (sub !== 'submit' || args.positional.length || typeof args.flags.file !== 'string' ||
|
|
63
|
+
Object.keys(args.flags).some(key => !['file', 'json', 'env', 'e'].includes(key))) {
|
|
64
|
+
console.error(FEEDBACK_HELP);
|
|
65
|
+
return 1;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const raw = await readReport(args.flags.file);
|
|
69
|
+
const parsed = reportSchema.safeParse(raw);
|
|
70
|
+
if (!parsed.success)
|
|
71
|
+
throw new Error(`Invalid report: ${parsed.error.issues.map(i => `${i.path.join('.') || 'body'}: ${i.message}`).join('; ')}. Correct the file and make one new attempt.`);
|
|
72
|
+
const { buildContext, clientOptions } = await import('../functions/commands.js');
|
|
73
|
+
let context;
|
|
74
|
+
try {
|
|
75
|
+
context = await buildContext(args);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
throw new Error(`Feedback was not submitted: ${error instanceof Error ? error.message : 'Check the selected environment and credentials.'}`);
|
|
79
|
+
}
|
|
80
|
+
// Intentionally one write attempt. Timeout or 503 after dispatch can mean Linear created an issue.
|
|
81
|
+
const receipt = receiptSchema.parse(await requestJsonOnce({ ...clientOptions(context),
|
|
82
|
+
path: '/api/platform/agent-feedback', method: 'POST', body: parsed.data }));
|
|
83
|
+
console.log(args.flags.json ? JSON.stringify(receipt) : `${receipt.receiptId}: ${receipt.ticketUrl}\n${receipt.message}`);
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
console.error(feedbackErrorMessage(error));
|
|
88
|
+
return 1;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function feedbackErrorMessage(error) {
|
|
92
|
+
if (error instanceof AtlasApiError && error.status === 400) {
|
|
93
|
+
return `${error.message}. Correct the file and make one new attempt. Draft was not recorded.`;
|
|
94
|
+
}
|
|
95
|
+
if (error instanceof AtlasApiError && (error.status === 401 || error.status === 403)) {
|
|
96
|
+
return 'Authentication or permission failed. Check seq-studio login for this environment. Keep the draft.';
|
|
97
|
+
}
|
|
98
|
+
if (error instanceof AtlasApiError && error.status === 429) {
|
|
99
|
+
return `Intake rate limited before submission. Keep the draft and retry after ${error.retryAfterSeconds ?? 'the server Retry-After period'}${error.retryAfterSeconds ? ' seconds' : ''}, at most twice.`;
|
|
100
|
+
}
|
|
101
|
+
if (error instanceof Error && error.message.startsWith('Feedback was not submitted:'))
|
|
102
|
+
return error.message;
|
|
103
|
+
if (error instanceof Error && !(error instanceof AtlasApiError) &&
|
|
104
|
+
(error.message.startsWith('Invalid report:') || error.message.startsWith('Report ') || error.message.startsWith('Report file'))) {
|
|
105
|
+
return error.message;
|
|
106
|
+
}
|
|
107
|
+
return 'No confirmed receipt. Keep the sanitized draft; do not blindly resubmit after an uncertain write.';
|
|
108
|
+
}
|
package/dist/main.d.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* seq-studio templates <sub> publish and synchronize Git-backed templates
|
|
15
15
|
* seq-studio pipeline <sub> discover, query, author and operate Data Pipelines
|
|
16
16
|
* seq-studio auth <sub> manage Git authentication
|
|
17
|
+
* seq-studio feedback submit submit agent feedback
|
|
17
18
|
* seq-studio service-accounts <sub> provision runtime identities
|
|
18
19
|
* seq-studio access <sub> manage runtime resource access
|
|
19
20
|
* seq-studio envs <sub> add/list environments
|
package/dist/main.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* seq-studio templates <sub> publish and synchronize Git-backed templates
|
|
15
15
|
* seq-studio pipeline <sub> discover, query, author and operate Data Pipelines
|
|
16
16
|
* seq-studio auth <sub> manage Git authentication
|
|
17
|
+
* seq-studio feedback submit submit agent feedback
|
|
17
18
|
* seq-studio service-accounts <sub> provision runtime identities
|
|
18
19
|
* seq-studio access <sub> manage runtime resource access
|
|
19
20
|
* seq-studio envs <sub> add/list environments
|
|
@@ -25,7 +26,8 @@
|
|
|
25
26
|
import { parseArgs } from './argv.js';
|
|
26
27
|
import { renderCapabilities } from './command-contract.js';
|
|
27
28
|
import { staticHelp } from './command-help.js';
|
|
28
|
-
import {
|
|
29
|
+
import { ignoredSandboxEnvNotice } from './env-flags.js';
|
|
30
|
+
import { sandboxUsageFooter } from './sandbox-auth.js';
|
|
29
31
|
// Lazy-load artifact delegate: published @sequenceholdings/artifact-studio/cli
|
|
30
32
|
// still auto-runs runCli() at module load; importing it here breaks doctor/process.
|
|
31
33
|
const TOP_LEVEL_USAGE = `usage:
|
|
@@ -38,10 +40,11 @@ const TOP_LEVEL_USAGE = `usage:
|
|
|
38
40
|
seq-studio storage <sub> [args] init | validate | apply | list | show | mkdir | upload | download | access | trash | restore | purge | operations | abort | delete
|
|
39
41
|
seq-studio agents <sub> [args] init | validate | bundle | plan | apply | list | show | voice (internal)
|
|
40
42
|
seq-studio secrets <sub> [args] create | set | list | attach | detach | apply
|
|
41
|
-
seq-studio repos <sub> [args] list | namespaces | show | create | clone | pull | pulls | delete | ci
|
|
43
|
+
seq-studio repos <sub> [args] list | namespaces | show | identity | create | clone | pull | pulls | delete | ci
|
|
42
44
|
seq-studio templates <sub> [args] publish | sync | list
|
|
43
45
|
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
|
|
44
46
|
seq-studio auth <sub> [args] whoami | git-credential
|
|
47
|
+
seq-studio feedback submit --file report.json [-e <env>] [--json]
|
|
45
48
|
seq-studio orm <sub> [args] init | generate | validate | plan | apply | execute | read | sql | diff | migrate-from-yaml | import
|
|
46
49
|
seq-studio service-accounts <sub> list | show | create (requires provisioning authority)
|
|
47
50
|
seq-studio access <sub> definitions | list | grant | revoke | resolve
|
|
@@ -62,8 +65,6 @@ const TOP_LEVEL_USAGE = `usage:
|
|
|
62
65
|
If this CLI cannot complete a documented step, read that environment's docs
|
|
63
66
|
before trying another tool. \`seq-studio envs list\` prints each environment URL.
|
|
64
67
|
Docs: <url>/docs. Feedback guide: <url>/docs/raw/seq-studio/feedback.md.
|
|
65
|
-
Sequence: https://sequence.seqholdings.com/docs
|
|
66
|
-
and https://sequence.seqholdings.com/docs/raw/seq-studio/feedback.md.
|
|
67
68
|
`;
|
|
68
69
|
const PROCESS_USAGE = `usage:
|
|
69
70
|
seq-studio process init <dir>
|
|
@@ -93,19 +94,20 @@ const SUBCOMMANDS = {
|
|
|
93
94
|
storage: new Set(['init', 'validate', 'apply', 'list', 'show', 'mkdir', 'upload', 'import', 'uploads', 'reconcile', 'download', 'access', 'trash', 'restore', 'purge', 'operations', 'abort', 'delete']),
|
|
94
95
|
agents: new Set(['init', 'validate', 'bundle', 'plan', 'apply', 'list', 'show', 'voice']),
|
|
95
96
|
secrets: new Set(['create', 'set', 'list', 'attach', 'detach', 'apply', 'versions', 'set-default', 'pin']),
|
|
96
|
-
repos: new Set(['list', 'namespaces', 'show', 'create', 'clone', 'pull', 'pulls', 'delete', 'ci']),
|
|
97
|
+
repos: new Set(['list', 'namespaces', 'show', 'identity', 'create', 'clone', 'pull', 'pulls', 'delete', 'ci']),
|
|
97
98
|
templates: new Set(['publish', 'sync', 'list']),
|
|
98
99
|
'service-accounts': new Set(['list', 'show', 'create']),
|
|
99
100
|
access: new Set(['definitions', 'resolve', 'list', 'grant', 'revoke']),
|
|
100
101
|
auth: new Set(['whoami', 'git-credential', 'pat']),
|
|
101
|
-
|
|
102
|
+
feedback: new Set(['submit']),
|
|
103
|
+
orm: new Set(['init', 'generate', 'validate', 'plan', 'apply', 'execute', 'namespaces', 'describe', 'read', 'sql', 'diff', 'migrate-from-yaml', 'import']),
|
|
102
104
|
pipeline: new Set(['list', 'assets', 'search', 'describe', 'schema', 'sample', 'query', 'init', 'validate', 'repin-orm', 'codegen', 'adopt', 'unbind', 'plan', 'deploy', 'status', 'migrate', 'promote', 'rollback', 'run-now']),
|
|
103
105
|
envs: new Set(['add', 'list']),
|
|
104
106
|
};
|
|
105
107
|
export async function run(argv = process.argv.slice(2)) {
|
|
106
108
|
const [namespace, sub, ...rest] = argv;
|
|
107
109
|
if (!namespace || namespace === 'help' || namespace === '--help' || namespace === '-h') {
|
|
108
|
-
console.log(TOP_LEVEL_USAGE);
|
|
110
|
+
console.log(`${TOP_LEVEL_USAGE}${sandboxUsageFooter()}`);
|
|
109
111
|
return namespace ? 0 : 1;
|
|
110
112
|
}
|
|
111
113
|
if (namespace === 'capabilities' && hasHelpFlag(sub, rest)) {
|
|
@@ -116,15 +118,6 @@ export async function run(argv = process.argv.slice(2)) {
|
|
|
116
118
|
console.error('Artifact Studio does not accept --token bearer injection. Authenticate with seq-studio login.');
|
|
117
119
|
return 1;
|
|
118
120
|
}
|
|
119
|
-
// Same rule as --token: Artifact Studio uses only credentials the CLI obtained
|
|
120
|
-
// and realm-checked itself, never an injected bearer, so sandbox token mode
|
|
121
|
-
// does not reach it. Help stays available.
|
|
122
|
-
if (namespace === 'artifact' && !hasHelpFlag(sub, rest) &&
|
|
123
|
-
(process.env[SANDBOX_BASE_URL_ENV]?.trim() || process.env[SANDBOX_TOKEN_FILE_ENV]?.trim())) {
|
|
124
|
-
console.error(`Artifact Studio commands are not available in sandbox token mode (${SANDBOX_BASE_URL_ENV} / ${SANDBOX_TOKEN_FILE_ENV}). ` +
|
|
125
|
-
'Deploy artifacts from a signed-in seq-studio session.');
|
|
126
|
-
return 1;
|
|
127
|
-
}
|
|
128
121
|
if (hasHelpFlag(sub, rest) && sub && !['help', '--help', '-h'].includes(sub) &&
|
|
129
122
|
SUBCOMMANDS[namespace] && !SUBCOMMANDS[namespace].has(sub)) {
|
|
130
123
|
console.error(`unknown ${namespace} command: ${sub}. See seq-studio ${namespace} --help.`);
|
|
@@ -137,6 +130,9 @@ export async function run(argv = process.argv.slice(2)) {
|
|
|
137
130
|
return 0;
|
|
138
131
|
}
|
|
139
132
|
}
|
|
133
|
+
const ignoredEnv = ignoredSandboxEnvNotice([sub, ...rest].filter((a) => Boolean(a)));
|
|
134
|
+
if (ignoredEnv)
|
|
135
|
+
console.error(ignoredEnv);
|
|
140
136
|
switch (namespace) {
|
|
141
137
|
case 'init': {
|
|
142
138
|
const { runAppInitCommand } = await import('./app/commands.js');
|
|
@@ -191,6 +187,8 @@ export async function run(argv = process.argv.slice(2)) {
|
|
|
191
187
|
const { runAccessCommand } = await import('./access/commands.js');
|
|
192
188
|
return runAccessCommand(sub, parseArgs(rest));
|
|
193
189
|
}
|
|
190
|
+
case 'feedback':
|
|
191
|
+
return (await import('./feedback/commands.js')).runFeedbackCommand(sub, parseArgs(rest));
|
|
194
192
|
case 'auth': {
|
|
195
193
|
const { runAuthCommand } = await import('./auth-cmds/commands.js');
|
|
196
194
|
return runAuthCommand(sub, parseArgs(rest));
|
package/dist/orm/delegate.js
CHANGED
|
@@ -15,7 +15,7 @@ import { explicitOrSandboxEnv, normalizeShortEnvFlag, readEnvFromArgv } from '..
|
|
|
15
15
|
import { REQUIRE_EXPLICIT_ENV_MESSAGE } from '../env-flags.js';
|
|
16
16
|
import { resolveFunctionSourceDir } from '../functions/source-selection.js';
|
|
17
17
|
import { warnBeforeHostDeploy } from '../manifest-roles-notice.js';
|
|
18
|
-
import { ORM_HELP } from '../command-help.js';
|
|
18
|
+
import { ORM_DISCOVER_HELP, ORM_HELP } from '../command-help.js';
|
|
19
19
|
/**
|
|
20
20
|
* ORM subcommands that talk to Atlas — must not silently target `local`.
|
|
21
21
|
* `init`, `generate`, `validate`, `diff`, `migrate-from-yaml`, and `import` are offline.
|
|
@@ -41,6 +41,10 @@ const ORM_USAGE = `usage:
|
|
|
41
41
|
read rows of a deployed v2 namespace as the caller (row-level security applies)
|
|
42
42
|
seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param name[:type]=v]... | [--params <json-object>] [--json|--jsonl]
|
|
43
43
|
run read-only SQL against a deployed v2 namespace as the caller
|
|
44
|
+
seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]
|
|
45
|
+
list the namespaces you can read
|
|
46
|
+
seq-studio orm describe <namespace> [<table>] -e <env> [--json]
|
|
47
|
+
show a namespace's tables, views, and persisted operations, or one table's columns and actions
|
|
44
48
|
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)
|
|
45
49
|
seq-studio orm migrate-from-yaml <dir> convert a v1 YAML namespace to the v2 TypeScript format (offline; migrations/ preserved)
|
|
46
50
|
seq-studio orm import [dir] --spec <file> | --table <t> --from <schema.table> --map <target=source,...>
|
|
@@ -191,21 +195,36 @@ async function loadOrmCli() {
|
|
|
191
195
|
return null;
|
|
192
196
|
}
|
|
193
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Subcommands seq-studio implements itself rather than forwarding to the ORM
|
|
200
|
+
* CLI: discovery reads Atlas's registry, and ad-hoc reads go through the ORM
|
|
201
|
+
* client. None of them needs a namespace directory.
|
|
202
|
+
*/
|
|
203
|
+
const NATIVE_ORM_SUBS = new Set(['namespaces', 'describe', 'read', 'sql']);
|
|
204
|
+
async function runNativeOrmCommand(sub, rest) {
|
|
205
|
+
const help = rest.includes('--help') || rest.includes('-h');
|
|
206
|
+
if (sub === 'namespaces' || sub === 'describe') {
|
|
207
|
+
if (help) {
|
|
208
|
+
console.log(ORM_DISCOVER_HELP);
|
|
209
|
+
return 0;
|
|
210
|
+
}
|
|
211
|
+
const { ormDescribeCommand, ormNamespacesCommand } = await import('./discover.js');
|
|
212
|
+
return sub === 'namespaces' ? ormNamespacesCommand(parseArgs(rest)) : ormDescribeCommand(parseArgs(rest));
|
|
213
|
+
}
|
|
214
|
+
const { ORM_READ_USAGE, ormReadCommand, ormSqlCommand } = await import('./read.js');
|
|
215
|
+
if (help) {
|
|
216
|
+
console.log(ORM_READ_USAGE);
|
|
217
|
+
return 0;
|
|
218
|
+
}
|
|
219
|
+
return sub === 'read' ? ormReadCommand(parseArgs(rest)) : ormSqlCommand(parseArgs(rest));
|
|
220
|
+
}
|
|
194
221
|
export async function runOrmCommand(sub, rest) {
|
|
195
222
|
if (!sub || sub === 'help' || sub === '--help' || sub === '-h') {
|
|
196
223
|
console.log(ORM_USAGE);
|
|
197
224
|
return sub ? 0 : 1;
|
|
198
225
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const { ORM_READ_USAGE, ormReadCommand, ormSqlCommand } = await import('./read.js');
|
|
202
|
-
if (rest.includes('--help') || rest.includes('-h')) {
|
|
203
|
-
console.log(ORM_READ_USAGE);
|
|
204
|
-
return 0;
|
|
205
|
-
}
|
|
206
|
-
const args = parseArgs(rest);
|
|
207
|
-
return sub === 'read' ? ormReadCommand(args) : ormSqlCommand(args);
|
|
208
|
-
}
|
|
226
|
+
if (NATIVE_ORM_SUBS.has(sub))
|
|
227
|
+
return runNativeOrmCommand(sub, rest);
|
|
209
228
|
const normalized = normalizeShortEnvFlag(rest);
|
|
210
229
|
if (normalized.includes('--help') || normalized.includes('-h')) {
|
|
211
230
|
console.log(ORM_HELP);
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response shapes `orm namespaces` / `orm describe` rely on. Objects are loose:
|
|
3
|
+
* only the fields the CLI renders are checked, and `--json` passes the rest
|
|
4
|
+
* through unchanged.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export declare const namespaceListSchema: z.ZodObject<{
|
|
8
|
+
namespaces: z.ZodArray<z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
description: z.ZodNullable<z.ZodString>;
|
|
11
|
+
definition_format: z.ZodNullable<z.ZodNumber>;
|
|
12
|
+
table_count: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
13
|
+
operation_count: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
14
|
+
archived_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
15
|
+
}, z.core.$loose>>;
|
|
16
|
+
total: z.ZodNumber;
|
|
17
|
+
limit: z.ZodNumber;
|
|
18
|
+
offset: z.ZodNumber;
|
|
19
|
+
}, z.core.$loose>;
|
|
20
|
+
declare const columnSchema: z.ZodObject<{
|
|
21
|
+
name: z.ZodString;
|
|
22
|
+
type: z.ZodString;
|
|
23
|
+
enum_name: z.ZodNullable<z.ZodString>;
|
|
24
|
+
nullable: z.ZodBoolean;
|
|
25
|
+
unique: z.ZodBoolean;
|
|
26
|
+
primary_key: z.ZodBoolean;
|
|
27
|
+
description: z.ZodNullable<z.ZodString>;
|
|
28
|
+
deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
}, z.core.$loose>;
|
|
30
|
+
declare const tableSchema: z.ZodObject<{
|
|
31
|
+
source: z.ZodNullable<z.ZodString>;
|
|
32
|
+
actions: z.ZodArray<z.ZodObject<{
|
|
33
|
+
name: z.ZodString;
|
|
34
|
+
description: z.ZodNullable<z.ZodString>;
|
|
35
|
+
requires: z.ZodNullable<z.ZodString>;
|
|
36
|
+
params: z.ZodArray<z.ZodObject<{
|
|
37
|
+
name: z.ZodString;
|
|
38
|
+
type: z.ZodString;
|
|
39
|
+
nullable: z.ZodBoolean;
|
|
40
|
+
}, z.core.$loose>>;
|
|
41
|
+
}, z.core.$loose>>;
|
|
42
|
+
internal: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
+
description: z.ZodNullable<z.ZodString>;
|
|
44
|
+
primary_key: z.ZodArray<z.ZodString>;
|
|
45
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
46
|
+
name: z.ZodString;
|
|
47
|
+
type: z.ZodString;
|
|
48
|
+
enum_name: z.ZodNullable<z.ZodString>;
|
|
49
|
+
nullable: z.ZodBoolean;
|
|
50
|
+
unique: z.ZodBoolean;
|
|
51
|
+
primary_key: z.ZodBoolean;
|
|
52
|
+
description: z.ZodNullable<z.ZodString>;
|
|
53
|
+
deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
+
}, z.core.$loose>>;
|
|
55
|
+
links: z.ZodArray<z.ZodObject<{
|
|
56
|
+
name: z.ZodString;
|
|
57
|
+
kind: z.ZodNullable<z.ZodString>;
|
|
58
|
+
target: z.ZodNullable<z.ZodString>;
|
|
59
|
+
on: z.ZodString;
|
|
60
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, z.core.$loose>>;
|
|
62
|
+
table: z.ZodString;
|
|
63
|
+
}, z.core.$loose>;
|
|
64
|
+
declare const viewSchema: z.ZodObject<{
|
|
65
|
+
description: z.ZodNullable<z.ZodString>;
|
|
66
|
+
primary_key: z.ZodArray<z.ZodString>;
|
|
67
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
68
|
+
name: z.ZodString;
|
|
69
|
+
type: z.ZodString;
|
|
70
|
+
enum_name: z.ZodNullable<z.ZodString>;
|
|
71
|
+
nullable: z.ZodBoolean;
|
|
72
|
+
unique: z.ZodBoolean;
|
|
73
|
+
primary_key: z.ZodBoolean;
|
|
74
|
+
description: z.ZodNullable<z.ZodString>;
|
|
75
|
+
deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
76
|
+
}, z.core.$loose>>;
|
|
77
|
+
links: z.ZodArray<z.ZodObject<{
|
|
78
|
+
name: z.ZodString;
|
|
79
|
+
kind: z.ZodNullable<z.ZodString>;
|
|
80
|
+
target: z.ZodNullable<z.ZodString>;
|
|
81
|
+
on: z.ZodString;
|
|
82
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
83
|
+
}, z.core.$loose>>;
|
|
84
|
+
view: z.ZodString;
|
|
85
|
+
}, z.core.$loose>;
|
|
86
|
+
export declare const schemaViewSchema: z.ZodObject<{
|
|
87
|
+
namespace: z.ZodString;
|
|
88
|
+
description: z.ZodNullable<z.ZodString>;
|
|
89
|
+
version_id: z.ZodString;
|
|
90
|
+
definition_format: z.ZodNumber;
|
|
91
|
+
enums: z.ZodArray<z.ZodObject<{
|
|
92
|
+
name: z.ZodString;
|
|
93
|
+
values: z.ZodArray<z.ZodString>;
|
|
94
|
+
}, z.core.$loose>>;
|
|
95
|
+
tables: z.ZodArray<z.ZodObject<{
|
|
96
|
+
source: z.ZodNullable<z.ZodString>;
|
|
97
|
+
actions: z.ZodArray<z.ZodObject<{
|
|
98
|
+
name: z.ZodString;
|
|
99
|
+
description: z.ZodNullable<z.ZodString>;
|
|
100
|
+
requires: z.ZodNullable<z.ZodString>;
|
|
101
|
+
params: z.ZodArray<z.ZodObject<{
|
|
102
|
+
name: z.ZodString;
|
|
103
|
+
type: z.ZodString;
|
|
104
|
+
nullable: z.ZodBoolean;
|
|
105
|
+
}, z.core.$loose>>;
|
|
106
|
+
}, z.core.$loose>>;
|
|
107
|
+
internal: z.ZodOptional<z.ZodBoolean>;
|
|
108
|
+
description: z.ZodNullable<z.ZodString>;
|
|
109
|
+
primary_key: z.ZodArray<z.ZodString>;
|
|
110
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
111
|
+
name: z.ZodString;
|
|
112
|
+
type: z.ZodString;
|
|
113
|
+
enum_name: z.ZodNullable<z.ZodString>;
|
|
114
|
+
nullable: z.ZodBoolean;
|
|
115
|
+
unique: z.ZodBoolean;
|
|
116
|
+
primary_key: z.ZodBoolean;
|
|
117
|
+
description: z.ZodNullable<z.ZodString>;
|
|
118
|
+
deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
119
|
+
}, z.core.$loose>>;
|
|
120
|
+
links: z.ZodArray<z.ZodObject<{
|
|
121
|
+
name: z.ZodString;
|
|
122
|
+
kind: z.ZodNullable<z.ZodString>;
|
|
123
|
+
target: z.ZodNullable<z.ZodString>;
|
|
124
|
+
on: z.ZodString;
|
|
125
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
126
|
+
}, z.core.$loose>>;
|
|
127
|
+
table: z.ZodString;
|
|
128
|
+
}, z.core.$loose>>;
|
|
129
|
+
views: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
130
|
+
description: z.ZodNullable<z.ZodString>;
|
|
131
|
+
primary_key: z.ZodArray<z.ZodString>;
|
|
132
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
133
|
+
name: z.ZodString;
|
|
134
|
+
type: z.ZodString;
|
|
135
|
+
enum_name: z.ZodNullable<z.ZodString>;
|
|
136
|
+
nullable: z.ZodBoolean;
|
|
137
|
+
unique: z.ZodBoolean;
|
|
138
|
+
primary_key: z.ZodBoolean;
|
|
139
|
+
description: z.ZodNullable<z.ZodString>;
|
|
140
|
+
deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
141
|
+
}, z.core.$loose>>;
|
|
142
|
+
links: z.ZodArray<z.ZodObject<{
|
|
143
|
+
name: z.ZodString;
|
|
144
|
+
kind: z.ZodNullable<z.ZodString>;
|
|
145
|
+
target: z.ZodNullable<z.ZodString>;
|
|
146
|
+
on: z.ZodString;
|
|
147
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
148
|
+
}, z.core.$loose>>;
|
|
149
|
+
view: z.ZodString;
|
|
150
|
+
}, z.core.$loose>>>;
|
|
151
|
+
}, z.core.$loose>;
|
|
152
|
+
declare const operationSchema: z.ZodObject<{
|
|
153
|
+
name: z.ZodString;
|
|
154
|
+
kind: z.ZodString;
|
|
155
|
+
requires: z.ZodNullable<z.ZodObject<{
|
|
156
|
+
capability: z.ZodOptional<z.ZodString>;
|
|
157
|
+
role: z.ZodOptional<z.ZodString>;
|
|
158
|
+
}, z.core.$loose>>;
|
|
159
|
+
mutation_roots: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
160
|
+
table: z.ZodString;
|
|
161
|
+
op: z.ZodString;
|
|
162
|
+
}, z.core.$loose>>>;
|
|
163
|
+
}, z.core.$loose>;
|
|
164
|
+
export declare const operationsPageSchema: z.ZodObject<{
|
|
165
|
+
operations: z.ZodArray<z.ZodObject<{
|
|
166
|
+
name: z.ZodString;
|
|
167
|
+
kind: z.ZodString;
|
|
168
|
+
requires: z.ZodNullable<z.ZodObject<{
|
|
169
|
+
capability: z.ZodOptional<z.ZodString>;
|
|
170
|
+
role: z.ZodOptional<z.ZodString>;
|
|
171
|
+
}, z.core.$loose>>;
|
|
172
|
+
mutation_roots: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
173
|
+
table: z.ZodString;
|
|
174
|
+
op: z.ZodString;
|
|
175
|
+
}, z.core.$loose>>>;
|
|
176
|
+
}, z.core.$loose>>;
|
|
177
|
+
total: z.ZodNumber;
|
|
178
|
+
}, z.core.$loose>;
|
|
179
|
+
export type SchemaView = z.infer<typeof schemaViewSchema>;
|
|
180
|
+
export type Operation = z.infer<typeof operationSchema>;
|
|
181
|
+
export type Column = z.infer<typeof columnSchema>;
|
|
182
|
+
export type Relation = {
|
|
183
|
+
kind: 'table';
|
|
184
|
+
name: string;
|
|
185
|
+
relation: z.infer<typeof tableSchema>;
|
|
186
|
+
} | {
|
|
187
|
+
kind: 'view';
|
|
188
|
+
name: string;
|
|
189
|
+
relation: z.infer<typeof viewSchema>;
|
|
190
|
+
};
|
|
191
|
+
export declare function parseResponse<T>({ schema, body, what }: {
|
|
192
|
+
schema: z.ZodType<T>;
|
|
193
|
+
body: unknown;
|
|
194
|
+
what: string;
|
|
195
|
+
}): T;
|
|
196
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response shapes `orm namespaces` / `orm describe` rely on. Objects are loose:
|
|
3
|
+
* only the fields the CLI renders are checked, and `--json` passes the rest
|
|
4
|
+
* through unchanged.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
const namespaceSummarySchema = z.looseObject({
|
|
8
|
+
id: z.string(),
|
|
9
|
+
description: z.string().nullable(),
|
|
10
|
+
definition_format: z.number().nullable(),
|
|
11
|
+
table_count: z.number().nullable().optional(),
|
|
12
|
+
operation_count: z.number().nullable().optional(),
|
|
13
|
+
archived_at: z.string().nullable().optional(),
|
|
14
|
+
});
|
|
15
|
+
export const namespaceListSchema = z.looseObject({
|
|
16
|
+
namespaces: z.array(namespaceSummarySchema),
|
|
17
|
+
total: z.number(),
|
|
18
|
+
limit: z.number(),
|
|
19
|
+
offset: z.number(),
|
|
20
|
+
});
|
|
21
|
+
const requiresSchema = z.looseObject({ capability: z.string().optional(), role: z.string().optional() }).nullable();
|
|
22
|
+
const columnSchema = z.looseObject({
|
|
23
|
+
name: z.string(),
|
|
24
|
+
type: z.string(),
|
|
25
|
+
enum_name: z.string().nullable(),
|
|
26
|
+
nullable: z.boolean(),
|
|
27
|
+
unique: z.boolean(),
|
|
28
|
+
primary_key: z.boolean(),
|
|
29
|
+
description: z.string().nullable(),
|
|
30
|
+
deprecated: z.boolean().optional(),
|
|
31
|
+
});
|
|
32
|
+
const linkSchema = z.looseObject({
|
|
33
|
+
name: z.string(),
|
|
34
|
+
kind: z.string().nullable(),
|
|
35
|
+
target: z.string().nullable(),
|
|
36
|
+
on: z.string(),
|
|
37
|
+
namespace: z.string().optional(),
|
|
38
|
+
});
|
|
39
|
+
const actionSchema = z.looseObject({
|
|
40
|
+
name: z.string(),
|
|
41
|
+
description: z.string().nullable(),
|
|
42
|
+
requires: z.string().nullable(),
|
|
43
|
+
params: z.array(z.looseObject({ name: z.string(), type: z.string(), nullable: z.boolean() })),
|
|
44
|
+
});
|
|
45
|
+
const relationFields = {
|
|
46
|
+
description: z.string().nullable(),
|
|
47
|
+
primary_key: z.array(z.string()),
|
|
48
|
+
columns: z.array(columnSchema),
|
|
49
|
+
links: z.array(linkSchema),
|
|
50
|
+
};
|
|
51
|
+
const tableSchema = z.looseObject({
|
|
52
|
+
table: z.string(),
|
|
53
|
+
...relationFields,
|
|
54
|
+
source: z.string().nullable(),
|
|
55
|
+
actions: z.array(actionSchema),
|
|
56
|
+
internal: z.boolean().optional(),
|
|
57
|
+
});
|
|
58
|
+
const viewSchema = z.looseObject({ view: z.string(), ...relationFields });
|
|
59
|
+
export const schemaViewSchema = z.looseObject({
|
|
60
|
+
namespace: z.string(),
|
|
61
|
+
description: z.string().nullable(),
|
|
62
|
+
version_id: z.string(),
|
|
63
|
+
definition_format: z.number(),
|
|
64
|
+
enums: z.array(z.looseObject({ name: z.string(), values: z.array(z.string()) })),
|
|
65
|
+
tables: z.array(tableSchema),
|
|
66
|
+
views: z.array(viewSchema).default([]),
|
|
67
|
+
});
|
|
68
|
+
const operationSchema = z.looseObject({
|
|
69
|
+
name: z.string(),
|
|
70
|
+
kind: z.string(),
|
|
71
|
+
requires: requiresSchema,
|
|
72
|
+
mutation_roots: z.array(z.looseObject({ table: z.string(), op: z.string() })).default([]),
|
|
73
|
+
});
|
|
74
|
+
export const operationsPageSchema = z.looseObject({
|
|
75
|
+
operations: z.array(operationSchema),
|
|
76
|
+
total: z.number(),
|
|
77
|
+
});
|
|
78
|
+
export function parseResponse({ schema, body, what }) {
|
|
79
|
+
const parsed = schema.safeParse(body);
|
|
80
|
+
if (!parsed.success) {
|
|
81
|
+
throw new Error(`Unexpected ${what} response from Atlas: ${parsed.error.issues[0]?.message ?? 'invalid shape'}.`);
|
|
82
|
+
}
|
|
83
|
+
return parsed.data;
|
|
84
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `seq-studio orm namespaces` / `orm describe` — find the ORM data the caller
|
|
3
|
+
* can read before querying it with `orm read` / `orm sql`.
|
|
4
|
+
*
|
|
5
|
+
* Both are read-only views over Atlas's namespace registry, authorized as the
|
|
6
|
+
* caller: `namespaces` lists only namespaces the caller can read, and
|
|
7
|
+
* `describe` answers 404 for a namespace that is missing or unreadable alike.
|
|
8
|
+
* `describe` joins the active version's compiled schema with its active
|
|
9
|
+
* persisted-operation set.
|
|
10
|
+
*/
|
|
11
|
+
import type { ParsedArgs } from '../process/commands.js';
|
|
12
|
+
export declare function ormNamespacesCommand(args: ParsedArgs): Promise<number>;
|
|
13
|
+
export declare function ormDescribeCommand(args: ParsedArgs): Promise<number>;
|