@sequenceholdings/studio-cli 0.5.1 → 0.5.3
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 +103 -38
- package/dist/agents/apply-chunks.d.ts +5 -1
- package/dist/agents/apply-chunks.js +4 -4
- package/dist/agents/commands.d.ts +10 -1
- package/dist/agents/commands.js +19 -2
- package/dist/app/adapters.d.ts +2 -2
- package/dist/app/adapters.js +18 -15
- package/dist/app/commands.d.ts +1 -1
- package/dist/app/commands.js +58 -20
- package/dist/app/deploy.d.ts +2 -0
- package/dist/app/deploy.js +25 -13
- package/dist/app/kinds.d.ts +6 -0
- package/dist/app/kinds.js +6 -0
- package/dist/app/manifest.js +1 -1
- package/dist/app/official-source.d.ts +10 -0
- package/dist/app/official-source.js +23 -0
- package/dist/app/prepare.d.ts +27 -0
- package/dist/app/prepare.js +58 -0
- package/dist/app/primitive-ids.d.ts +6 -0
- package/dist/app/primitive-ids.js +16 -0
- package/dist/app/primitive-scaffold.d.ts +0 -4
- package/dist/app/primitive-scaffold.js +7 -18
- package/dist/app/readme.js +17 -14
- package/dist/app/repository-index.d.ts +19 -0
- package/dist/app/repository-index.js +86 -0
- package/dist/app/scaffold.d.ts +12 -1
- package/dist/app/scaffold.js +31 -18
- package/dist/app/workspace-compile.d.ts +9 -0
- package/dist/app/workspace-compile.js +13 -1
- package/dist/app/workspace-scaffold.js +5 -1
- package/dist/auth.d.ts +17 -0
- package/dist/auth.js +29 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.js +38 -5
- package/dist/env-registry.d.ts +8 -0
- package/dist/env-registry.js +9 -1
- package/dist/envs/commands.js +14 -1
- package/dist/functions/manifest.d.ts +4 -1
- package/dist/functions/manifest.js +8 -2
- package/dist/main.js +6 -1
- package/dist/orm/delegate.js +5 -2
- package/dist/pipeline/clone-deploy.d.ts +1 -1
- package/dist/pipeline/clone-deploy.js +3 -2
- package/dist/pipeline/commands.js +3 -2
- package/dist/process/commands.d.ts +6 -3
- package/dist/process/commands.js +26 -10
- package/dist/repos/commands.js +1 -1
- package/dist/repos/pulls.d.ts +19 -1
- package/dist/repos/pulls.js +15 -2
- package/dist/templates/process/example-process/process.ts +20 -24
- package/dist/templates/process/package.json +1 -1
- package/package.json +8 -7
- package/templates/process/example-process/process.ts +20 -24
- package/templates/process/package.json +1 -1
package/dist/app/scaffold.d.ts
CHANGED
|
@@ -29,10 +29,21 @@ export declare function addPrimitiveToApp({ rootDir, kind, name, pipelineType, a
|
|
|
29
29
|
manifest: AppManifest;
|
|
30
30
|
entry: PrimitiveEntry;
|
|
31
31
|
}>;
|
|
32
|
+
/**
|
|
33
|
+
* The topmost directory on the way from `appRoot` to `absPath` that does not
|
|
34
|
+
* exist yet: what rolling back a failed scaffold must remove so it leaves no
|
|
35
|
+
* empty parent (e.g. `orm/`) behind.
|
|
36
|
+
*/
|
|
37
|
+
export declare function firstMissingDirectory({ appRoot, absPath }: {
|
|
38
|
+
appRoot: string;
|
|
39
|
+
absPath: string;
|
|
40
|
+
}): string;
|
|
32
41
|
export declare function printOrmPreparation({ primitives }: {
|
|
33
42
|
primitives: readonly PrimitiveEntry[];
|
|
34
43
|
}): void;
|
|
35
|
-
export declare function printInitNextSteps({ appRoot, manifest, }: {
|
|
44
|
+
export declare function printInitNextSteps({ appRoot, manifest, prepared, }: {
|
|
36
45
|
appRoot: string;
|
|
37
46
|
manifest: AppManifest;
|
|
47
|
+
/** true: dependencies installed and migrations authored; false: skipped; 'failed': partly done. */
|
|
48
|
+
prepared: boolean | 'failed';
|
|
38
49
|
}): void;
|
package/dist/app/scaffold.js
CHANGED
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
6
6
|
import { existsSync } from 'node:fs';
|
|
7
|
-
import { join, relative, resolve } from 'node:path';
|
|
7
|
+
import { join, relative, resolve, sep } from 'node:path';
|
|
8
8
|
import { currentVersion, isNewerVersion } from '../update-check.js';
|
|
9
9
|
import { extendDeployOrder, loadAppManifest, titleizeSlug, writeAppManifest, } from './manifest.js';
|
|
10
10
|
import { inspectScaffoldTarget, mergeGitignore, rollbackAppScaffold } from './scaffold-files.js';
|
|
11
11
|
import { readGitServiceSeedAtlasOrigin, renderAppReadme } from './readme.js';
|
|
12
12
|
import { writeScaffoldGuidance } from '../scaffold-guidance.js';
|
|
13
|
-
import { primitiveIdFor
|
|
13
|
+
import { primitiveIdFor } from './primitive-ids.js';
|
|
14
|
+
import { relativePathFor, scaffoldKind } from './primitive-scaffold.js';
|
|
14
15
|
import { joinAppWorkspace, scaffoldAppWorkspace, scaffoldSharedPackage } from './workspace-scaffold.js';
|
|
15
16
|
const LOG = '[seq-studio]';
|
|
16
17
|
const APP_MANIFEST_LABEL = 'sequence.app.yml';
|
|
@@ -117,6 +118,7 @@ export async function addPrimitiveToApp({ rootDir, kind, name, pipelineType, art
|
|
|
117
118
|
}
|
|
118
119
|
const workspacePath = join(appRoot, 'pnpm-workspace.yaml');
|
|
119
120
|
const previousWorkspace = existsSync(workspacePath) ? await readFile(workspacePath, 'utf8') : null;
|
|
121
|
+
const createdRoot = firstMissingDirectory({ appRoot, absPath });
|
|
120
122
|
try {
|
|
121
123
|
let entry = await scaffoldKind({ kind, appRoot, appId, name, pipelineType, artifactTemplate });
|
|
122
124
|
const orm = manifest.primitives.find((item) => item.kind === 'orm');
|
|
@@ -158,13 +160,28 @@ export async function addPrimitiveToApp({ rootDir, kind, name, pipelineType, art
|
|
|
158
160
|
catch (error) {
|
|
159
161
|
if (previousWorkspace !== null)
|
|
160
162
|
await writeFile(workspacePath, previousWorkspace, 'utf8');
|
|
161
|
-
// Safe: absPath
|
|
162
|
-
|
|
163
|
+
// Safe: createdRoot (absPath, or a parent such as orm/ that scaffolding
|
|
164
|
+
// created for it) did not exist before this invocation.
|
|
165
|
+
await rm(createdRoot, { recursive: true, force: true }).catch(() => {
|
|
163
166
|
/* best-effort */
|
|
164
167
|
});
|
|
165
168
|
throw error;
|
|
166
169
|
}
|
|
167
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* The topmost directory on the way from `appRoot` to `absPath` that does not
|
|
173
|
+
* exist yet: what rolling back a failed scaffold must remove so it leaves no
|
|
174
|
+
* empty parent (e.g. `orm/`) behind.
|
|
175
|
+
*/
|
|
176
|
+
export function firstMissingDirectory({ appRoot, absPath }) {
|
|
177
|
+
const segments = relative(appRoot, absPath).split(sep).filter(Boolean);
|
|
178
|
+
for (let depth = 1; depth <= segments.length; depth++) {
|
|
179
|
+
const candidate = join(appRoot, ...segments.slice(0, depth));
|
|
180
|
+
if (!existsSync(candidate))
|
|
181
|
+
return candidate;
|
|
182
|
+
}
|
|
183
|
+
return absPath;
|
|
184
|
+
}
|
|
168
185
|
export function printOrmPreparation({ primitives }) {
|
|
169
186
|
for (const entry of primitives.filter((item) => item.kind === 'orm')) {
|
|
170
187
|
console.log(` seq-studio orm generate ${entry.path}`);
|
|
@@ -172,7 +189,7 @@ export function printOrmPreparation({ primitives }) {
|
|
|
172
189
|
console.log(` # review and commit ${entry.path}/migrations/ before deploying`);
|
|
173
190
|
}
|
|
174
191
|
}
|
|
175
|
-
export function printInitNextSteps({ appRoot, manifest, }) {
|
|
192
|
+
export function printInitNextSteps({ appRoot, manifest, prepared, }) {
|
|
176
193
|
const rel = relative(process.cwd(), appRoot);
|
|
177
194
|
const display = !rel || rel.startsWith('..') ? appRoot : rel;
|
|
178
195
|
console.log(`${LOG} scaffolded app "${manifest.app.id}" in ${display}`);
|
|
@@ -181,22 +198,18 @@ export function printInitNextSteps({ appRoot, manifest, }) {
|
|
|
181
198
|
for (const entry of manifest.primitives) {
|
|
182
199
|
console.log(`${LOG} - ${entry.kind.padEnd(9)} ${entry.id} (${entry.path})`);
|
|
183
200
|
}
|
|
201
|
+
if (prepared === true)
|
|
202
|
+
console.log(`${LOG} installed dependencies and authored the first migration; commit pnpm-lock.yaml and migrations/`);
|
|
184
203
|
console.log('');
|
|
185
204
|
console.log('Next:');
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
console.log(' # or targeted:');
|
|
192
|
-
const fn = manifest.primitives.find((entry) => entry.kind === 'function');
|
|
193
|
-
if (fn) {
|
|
194
|
-
console.log(` seq-studio deploy --only ${fn.id} -e local --yes`);
|
|
195
|
-
}
|
|
196
|
-
const artifact = manifest.primitives.find((entry) => entry.kind === 'artifact');
|
|
197
|
-
if (artifact) {
|
|
198
|
-
console.log(` seq-studio deploy --only ${artifact.id} -e local --yes`);
|
|
205
|
+
if (display !== '.')
|
|
206
|
+
console.log(` cd ${display}`);
|
|
207
|
+
if (prepared === false) {
|
|
208
|
+
console.log(' pnpm install');
|
|
209
|
+
printOrmPreparation({ primitives: manifest.primitives });
|
|
199
210
|
}
|
|
211
|
+
console.log(' Push a branch and open a PR; checks run automatically, and merging to main publishes the app.');
|
|
212
|
+
console.log(` No repository yet? seq-studio repos create artifacts/${manifest.app.id} -e <env>, then push this app to it.`);
|
|
200
213
|
console.log(' # add another primitive later:');
|
|
201
214
|
console.log(' seq-studio add function list-types');
|
|
202
215
|
console.log(' seq-studio add package contracts');
|
|
@@ -6,6 +6,15 @@ interface CompileOptions {
|
|
|
6
6
|
packages: ReadonlyMap<string, WorkspacePackage>;
|
|
7
7
|
closure: readonly WorkspacePackage[];
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Whether esbuild is resolving a package import (`react`, `@scope/pkg`) rather
|
|
11
|
+
* than a file. An entry point or absolute path is a file even when it starts
|
|
12
|
+
* with a letter, as Windows paths (`C:\\app\\index.ts`) do.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isPackageImport({ path, kind }: {
|
|
15
|
+
path: string;
|
|
16
|
+
kind: string;
|
|
17
|
+
}): boolean;
|
|
9
18
|
export declare function compileWorkspaceFunction(options: CompileOptions): Promise<void>;
|
|
10
19
|
/**
|
|
11
20
|
* Rewrite only workspace imports in the artifact's own modules, then compile
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
import { mkdir, readFile, realpath, rm, writeFile } from 'node:fs/promises';
|
|
4
|
-
import { basename, dirname, extname, join, relative, resolve, sep } from 'node:path';
|
|
4
|
+
import { basename, dirname, extname, join, posix, relative, resolve, sep, win32 } from 'node:path';
|
|
5
5
|
import { build, transform } from 'esbuild';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import { containedPath, isWithin, resolveWorkspaceImport } from './workspace-model.js';
|
|
@@ -10,12 +10,24 @@ const relativeImport = ({ from, to }) => {
|
|
|
10
10
|
const path = slash(relative(dirname(from), to));
|
|
11
11
|
return path.startsWith('.') ? path : `./${path}`;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Whether esbuild is resolving a package import (`react`, `@scope/pkg`) rather
|
|
15
|
+
* than a file. An entry point or absolute path is a file even when it starts
|
|
16
|
+
* with a letter, as Windows paths (`C:\\app\\index.ts`) do.
|
|
17
|
+
*/
|
|
18
|
+
export function isPackageImport({ path, kind }) {
|
|
19
|
+
if (kind === 'entry-point' || posix.isAbsolute(path) || win32.isAbsolute(path))
|
|
20
|
+
return false;
|
|
21
|
+
return /^[^./]|^@/.test(path);
|
|
22
|
+
}
|
|
13
23
|
function workspaceCompilerPlugin({ sourceDir, packages, closure, browser, runtimeEntry, runtimeMain }) {
|
|
14
24
|
const allowed = [...(browser ? [] : [sourceDir]), ...closure.map((entry) => entry.dir)];
|
|
15
25
|
return {
|
|
16
26
|
name: 'sequence-app-workspace-source',
|
|
17
27
|
setup(builder) {
|
|
18
28
|
builder.onResolve({ filter: /^[^./]|^@/ }, async (args) => {
|
|
29
|
+
if (!isPackageImport(args))
|
|
30
|
+
return undefined;
|
|
19
31
|
const path = await resolveWorkspaceImport({ specifier: args.path, packages, browser, requireImport: args.kind === 'require-call' || args.kind === 'require-resolve' });
|
|
20
32
|
if (path)
|
|
21
33
|
return { path };
|
|
@@ -66,12 +66,16 @@ export async function joinAppWorkspace({ rootDir, manifest, entries, }) {
|
|
|
66
66
|
const pkg = packageSchema.parse(JSON.parse(await readFile(packagePath, 'utf8')));
|
|
67
67
|
const { pnpm, ...packageFields } = pkg;
|
|
68
68
|
mergeOverrides({ existing: overrides, incoming: pnpm?.overrides ?? {} });
|
|
69
|
+
// A function's packaged dependencies ship as-is and a deployed bundle cannot
|
|
70
|
+
// resolve a workspace: link, so functions opt in to shared packages explicitly.
|
|
71
|
+
// Artifacts and processes are bundled at build time, so the link is safe there.
|
|
72
|
+
const shared = entry.kind === 'function' ? [] : manifest.packages ?? [];
|
|
69
73
|
await writeFile(packagePath, `${JSON.stringify({
|
|
70
74
|
...packageFields,
|
|
71
75
|
name: `@${manifest.app.id}/primitive-${entry.id}`,
|
|
72
76
|
dependencies: {
|
|
73
77
|
...pkg.dependencies,
|
|
74
|
-
...Object.fromEntries(
|
|
78
|
+
...Object.fromEntries(shared.map((item) => [item.name, 'workspace:*'])),
|
|
75
79
|
},
|
|
76
80
|
}, null, 2)}\n`);
|
|
77
81
|
for (const name of ['pnpm-workspace.yaml', 'pnpm-lock.yaml', 'package-lock.json', 'yarn.lock', '.npmrc']) {
|
package/dist/auth.d.ts
CHANGED
|
@@ -31,6 +31,17 @@ export declare const AUTH0_AUDIENCE = "https://api.studio.com";
|
|
|
31
31
|
/** The realm name the built-in Sequence environments' tokens live under —
|
|
32
32
|
* also the implicit realm of the legacy flat fields in tokens.json. */
|
|
33
33
|
export declare const SEQUENCE_REALM = "sequence";
|
|
34
|
+
/**
|
|
35
|
+
* Reserved names for first-party deployments on the shared Sequence login
|
|
36
|
+
* (every built-in name except `local`). `envs add` saves them to config.toml
|
|
37
|
+
* after confirming the deployment really uses that login.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isSharedLoginDeploymentName(envName: string): boolean;
|
|
40
|
+
/** Whether a deployment's advertised Auth0 client is the shared Sequence login. */
|
|
41
|
+
export declare function usesSharedSequenceLogin({ clientId, audience }: {
|
|
42
|
+
clientId: string;
|
|
43
|
+
audience: string;
|
|
44
|
+
}): boolean;
|
|
34
45
|
export declare function isSequenceAuthEnvName(envName: string): boolean;
|
|
35
46
|
/**
|
|
36
47
|
* One Auth0 login context. Mirrors seqapi's `AuthRealm`
|
|
@@ -103,6 +114,12 @@ export declare class NotLoggedInError extends Error {
|
|
|
103
114
|
*/
|
|
104
115
|
export declare class UnsafeAuthTargetError extends Error {
|
|
105
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Run `fn` without opening a browser login: a missing or expired session
|
|
119
|
+
* raises `NotLoggedInError` instead. For commands such as `deploy --dry-run`
|
|
120
|
+
* that must never sign anyone in as a side effect.
|
|
121
|
+
*/
|
|
122
|
+
export declare function withoutAutoLogin<T>(fn: () => Promise<T>): Promise<T>;
|
|
106
123
|
export type AuthMode = 'm2m' | 'user';
|
|
107
124
|
export interface ResolvedAccessToken {
|
|
108
125
|
authMode: AuthMode;
|
package/dist/auth.js
CHANGED
|
@@ -70,6 +70,18 @@ const TRUSTED_LOOPBACK_AUTH0_AUDIENCES = new Set([
|
|
|
70
70
|
AUTH0_AUDIENCE,
|
|
71
71
|
SEQUENCE_STAGING_AUTH0_AUDIENCE,
|
|
72
72
|
]);
|
|
73
|
+
/**
|
|
74
|
+
* Reserved names for first-party deployments on the shared Sequence login
|
|
75
|
+
* (every built-in name except `local`). `envs add` saves them to config.toml
|
|
76
|
+
* after confirming the deployment really uses that login.
|
|
77
|
+
*/
|
|
78
|
+
export function isSharedLoginDeploymentName(envName) {
|
|
79
|
+
return envName !== 'local' && SEQUENCE_BUILTIN_ENVS.has(envName);
|
|
80
|
+
}
|
|
81
|
+
/** Whether a deployment's advertised Auth0 client is the shared Sequence login. */
|
|
82
|
+
export function usesSharedSequenceLogin({ clientId, audience }) {
|
|
83
|
+
return clientId === AUTH0_CLIENT_ID && audience === AUTH0_AUDIENCE;
|
|
84
|
+
}
|
|
73
85
|
export function isSequenceAuthEnvName(envName) {
|
|
74
86
|
return (envName === SEQUENCE_REALM ||
|
|
75
87
|
SEQUENCE_BUILTIN_ENVS.has(envName) ||
|
|
@@ -406,10 +418,27 @@ export class NotLoggedInError extends Error {
|
|
|
406
418
|
export class UnsafeAuthTargetError extends Error {
|
|
407
419
|
}
|
|
408
420
|
const AUTO_LOGIN_TIMEOUT_MS = 120_000;
|
|
421
|
+
let autoLoginSuppressed = 0;
|
|
409
422
|
function autoLoginEnabled() {
|
|
423
|
+
if (autoLoginSuppressed > 0)
|
|
424
|
+
return false;
|
|
410
425
|
const value = process.env.SEQAPI_AUTO_LOGIN?.trim().toLowerCase() ?? '1';
|
|
411
426
|
return !['0', 'false', 'no', 'off'].includes(value);
|
|
412
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* Run `fn` without opening a browser login: a missing or expired session
|
|
430
|
+
* raises `NotLoggedInError` instead. For commands such as `deploy --dry-run`
|
|
431
|
+
* that must never sign anyone in as a side effect.
|
|
432
|
+
*/
|
|
433
|
+
export async function withoutAutoLogin(fn) {
|
|
434
|
+
autoLoginSuppressed += 1;
|
|
435
|
+
try {
|
|
436
|
+
return await fn();
|
|
437
|
+
}
|
|
438
|
+
finally {
|
|
439
|
+
autoLoginSuppressed -= 1;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
413
442
|
function autoLoginTimeoutMs() {
|
|
414
443
|
const raw = process.env.SEQAPI_AUTO_LOGIN_TIMEOUT?.trim();
|
|
415
444
|
if (!raw)
|
package/dist/config.d.ts
CHANGED
|
@@ -55,6 +55,22 @@ export declare function resolveEnv({ config, requested, }: {
|
|
|
55
55
|
config: LatticeConfig;
|
|
56
56
|
requested?: string;
|
|
57
57
|
}): ResolvedEnv;
|
|
58
|
+
/**
|
|
59
|
+
* Save a first-party deployment under its reserved name (`staging`,
|
|
60
|
+
* `production`, `banksouth`) in config.toml. Those names sign in through the
|
|
61
|
+
* shared Sequence login, so the deployment must advertise exactly that login
|
|
62
|
+
* at its public `/api/auth/cli-config`; anything else is refused. The entry is
|
|
63
|
+
* appended, leaving the rest of the file as written.
|
|
64
|
+
*/
|
|
65
|
+
export declare function addSharedLoginEnvironment({ name, baseUrl: rawBaseUrl, fetchImpl, }: {
|
|
66
|
+
name: string;
|
|
67
|
+
baseUrl: string;
|
|
68
|
+
fetchImpl?: typeof fetch;
|
|
69
|
+
}): Promise<{
|
|
70
|
+
name: string;
|
|
71
|
+
baseUrl: string;
|
|
72
|
+
changed: boolean;
|
|
73
|
+
}>;
|
|
58
74
|
/** Resolve `--env <name>` against the config on disk. */
|
|
59
75
|
export declare function resolveConfiguredEnv({ requested, }: {
|
|
60
76
|
requested?: string;
|
package/dist/config.js
CHANGED
|
@@ -5,8 +5,9 @@ import { homedir } from 'node:os';
|
|
|
5
5
|
import { basename, dirname, join } from 'node:path';
|
|
6
6
|
import { promisify } from 'node:util';
|
|
7
7
|
import { parse as parseToml, stringify as stringifyToml } from 'smol-toml';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { validateDeploymentBaseUrl } from '@sequenceholdings/artifact-studio/deployment-validation';
|
|
9
|
+
import { isSequenceAuthEnvName, isSharedLoginDeploymentName, usesSharedSequenceLogin } from './auth.js';
|
|
10
|
+
import { fetchDeploymentLogin, readRegisteredEnvironmentUrls } from './env-registry.js';
|
|
10
11
|
import { resolvePreviewFromSlug } from './preview.js';
|
|
11
12
|
/**
|
|
12
13
|
* `--env preview:<branch-or-slug>` targets a per-PR Vercel preview deployment
|
|
@@ -194,9 +195,7 @@ export function resolveEnv({ config, requested, }) {
|
|
|
194
195
|
const env = config.envs[name];
|
|
195
196
|
if (!env) {
|
|
196
197
|
const known = Object.keys(config.envs).join(', ');
|
|
197
|
-
|
|
198
|
-
// them; point those at config.toml instead.
|
|
199
|
-
const addHint = isSequenceAuthEnvName(name)
|
|
198
|
+
const addHint = isSequenceAuthEnvName(name) && !isSharedLoginDeploymentName(name)
|
|
200
199
|
? `add an [env.${name}] entry to ${configPath()}`
|
|
201
200
|
: `register the deployment with: seq-studio envs add ${name} <url>`;
|
|
202
201
|
throw new Error(`Unknown env "${name}". Known envs: ${known}. ` +
|
|
@@ -204,6 +203,40 @@ export function resolveEnv({ config, requested, }) {
|
|
|
204
203
|
}
|
|
205
204
|
return { name, url: env.url };
|
|
206
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Save a first-party deployment under its reserved name (`staging`,
|
|
208
|
+
* `production`, `banksouth`) in config.toml. Those names sign in through the
|
|
209
|
+
* shared Sequence login, so the deployment must advertise exactly that login
|
|
210
|
+
* at its public `/api/auth/cli-config`; anything else is refused. The entry is
|
|
211
|
+
* appended, leaving the rest of the file as written.
|
|
212
|
+
*/
|
|
213
|
+
export async function addSharedLoginEnvironment({ name, baseUrl: rawBaseUrl, fetchImpl = fetch, }) {
|
|
214
|
+
if (!isSharedLoginDeploymentName(name)) {
|
|
215
|
+
throw new Error(`'${name}' is not a reserved first-party deployment name.`);
|
|
216
|
+
}
|
|
217
|
+
const baseUrl = validateDeploymentBaseUrl(rawBaseUrl).replace(/\/$/, '');
|
|
218
|
+
if (!baseUrl.startsWith('https://')) {
|
|
219
|
+
throw new Error(`'${name}' must be an HTTPS deployment under *.seqholdings.com, not ${baseUrl}.`);
|
|
220
|
+
}
|
|
221
|
+
const login = await fetchDeploymentLogin({ baseUrl, fetchImpl });
|
|
222
|
+
if (!usesSharedSequenceLogin(login)) {
|
|
223
|
+
throw new Error(`'${name}' is reserved for a deployment on the shared Sequence login, and ${baseUrl} uses its own ` +
|
|
224
|
+
`login. Register it under another name: seq-studio envs add <name> ${baseUrl}`);
|
|
225
|
+
}
|
|
226
|
+
const path = configPath();
|
|
227
|
+
const existing = existsSync(path) ? await readFile(path, 'utf8') : '';
|
|
228
|
+
const current = parseToml(existing).env?.[name]?.url;
|
|
229
|
+
if (current === baseUrl)
|
|
230
|
+
return { name, baseUrl, changed: false };
|
|
231
|
+
if (current !== undefined) {
|
|
232
|
+
throw new Error(`[env.${name}] in ${path} already points at ${current}; edit it there to change it.`);
|
|
233
|
+
}
|
|
234
|
+
await mkdir(dirname(path), { recursive: true });
|
|
235
|
+
const separator = existing === '' || existing.endsWith('\n\n') ? '' : existing.endsWith('\n') ? '\n' : '\n\n';
|
|
236
|
+
const table = `[env.${name}]\nurl = ${stringifyToml({ url: baseUrl }).trim().replace(/^url = /, '')}\n`;
|
|
237
|
+
await writeFile(path, existing + separator + table, { encoding: 'utf8', mode: 0o600 });
|
|
238
|
+
return { name, baseUrl, changed: true };
|
|
239
|
+
}
|
|
207
240
|
/** Resolve `--env <name>` against the config on disk. */
|
|
208
241
|
export async function resolveConfiguredEnv({ requested, }) {
|
|
209
242
|
return resolveEnv({ config: await readConfig(), requested });
|
package/dist/env-registry.d.ts
CHANGED
|
@@ -12,6 +12,14 @@ interface RegistrationResult {
|
|
|
12
12
|
realm: DiscoveredRealm;
|
|
13
13
|
}
|
|
14
14
|
export declare function seqapiConfigPath(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Read a deployment's public CLI login config (`/api/auth/cli-config`) without
|
|
17
|
+
* judging its audience; callers decide which login they will trust.
|
|
18
|
+
*/
|
|
19
|
+
export declare function fetchDeploymentLogin({ baseUrl, fetchImpl, }: {
|
|
20
|
+
baseUrl: string;
|
|
21
|
+
fetchImpl?: typeof fetch;
|
|
22
|
+
}): Promise<DiscoveredRealm>;
|
|
15
23
|
export declare function readRegisteredEnvironmentUrls({ configFile, }?: {
|
|
16
24
|
configFile?: string;
|
|
17
25
|
}): Promise<Record<string, {
|
package/dist/env-registry.js
CHANGED
|
@@ -30,6 +30,14 @@ function validateEnvironmentName(input) {
|
|
|
30
30
|
return name;
|
|
31
31
|
}
|
|
32
32
|
async function discoverRealm({ baseUrl, fetchImpl, }) {
|
|
33
|
+
const login = await fetchDeploymentLogin({ baseUrl, fetchImpl });
|
|
34
|
+
return { ...login, audience: validateDeploymentAudience({ audience: login.audience, baseUrl }) };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Read a deployment's public CLI login config (`/api/auth/cli-config`) without
|
|
38
|
+
* judging its audience; callers decide which login they will trust.
|
|
39
|
+
*/
|
|
40
|
+
export async function fetchDeploymentLogin({ baseUrl, fetchImpl = fetch, }) {
|
|
33
41
|
const url = `${baseUrl}${DISCOVERY_PATH}`;
|
|
34
42
|
let response;
|
|
35
43
|
try {
|
|
@@ -78,7 +86,7 @@ async function discoverRealm({ baseUrl, fetchImpl, }) {
|
|
|
78
86
|
return {
|
|
79
87
|
domain: validateAuth0Domain(domain),
|
|
80
88
|
clientId,
|
|
81
|
-
audience
|
|
89
|
+
audience,
|
|
82
90
|
organization: optionalString(Reflect.get(auth0, 'organization')),
|
|
83
91
|
m2mClientId: optionalString(Reflect.get(auth0, 'm2mClientId')),
|
|
84
92
|
};
|
package/dist/envs/commands.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { readConfig, configPath, manualEnvConfigHint } from '../config.js';
|
|
1
|
+
import { addSharedLoginEnvironment, readConfig, configPath, manualEnvConfigHint } from '../config.js';
|
|
2
|
+
import { isSharedLoginDeploymentName } from '../auth.js';
|
|
2
3
|
import { readRegisteredEnvironmentUrls, registerEnvironment, } from '../env-registry.js';
|
|
3
4
|
const ENVS_USAGE = `usage:
|
|
4
5
|
seq-studio envs list show the configured environments
|
|
@@ -9,6 +10,11 @@ const ENVS_USAGE = `usage:
|
|
|
9
10
|
deployment with "envs add"; it reads the deployment's public sign-in
|
|
10
11
|
settings, then "seq-studio login --env <name>" signs you in to it.
|
|
11
12
|
|
|
13
|
+
The reserved names staging, production and banksouth are for deployments
|
|
14
|
+
on the shared Sequence login. "envs add" saves one of them to config.toml
|
|
15
|
+
only after the deployment's sign-in settings confirm that login; then
|
|
16
|
+
"seq-studio login" signs you in.
|
|
17
|
+
|
|
12
18
|
Local worktrees are discovered from their .wt.env files. Entries in
|
|
13
19
|
${configPath()} are also honored.
|
|
14
20
|
`;
|
|
@@ -37,6 +43,13 @@ async function addCommand(rest) {
|
|
|
37
43
|
return 1;
|
|
38
44
|
}
|
|
39
45
|
try {
|
|
46
|
+
if (isSharedLoginDeploymentName(name.toLowerCase())) {
|
|
47
|
+
const added = await addSharedLoginEnvironment({ name: name.toLowerCase(), baseUrl });
|
|
48
|
+
console.log(`${added.changed ? 'Added' : 'Already configured:'} environment '${added.name}' -> ${added.baseUrl} ` +
|
|
49
|
+
`(shared Sequence login, saved in ${configPath()})`);
|
|
50
|
+
console.log('Next: seq-studio login');
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
40
53
|
const registration = await registerEnvironment({ name, baseUrl });
|
|
41
54
|
const verb = registration.replacing ? 'Updated' : 'Registered';
|
|
42
55
|
console.log(`${verb} environment '${registration.name}' -> ${registration.baseUrl}`);
|
|
@@ -136,6 +136,9 @@ export declare const managedFunctionManifestSchema: z.ZodObject<{
|
|
|
136
136
|
processes: z.ZodOptional<z.ZodObject<{
|
|
137
137
|
read: z.ZodArray<z.ZodString>;
|
|
138
138
|
}, z.core.$strict>>;
|
|
139
|
+
directory: z.ZodOptional<z.ZodObject<{
|
|
140
|
+
groups: z.ZodArray<z.ZodString>;
|
|
141
|
+
}, z.core.$strict>>;
|
|
139
142
|
roles: z.ZodOptional<z.ZodObject<{
|
|
140
143
|
definitions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
141
144
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -156,7 +159,7 @@ export declare const managedFunctionManifestSchema: z.ZodObject<{
|
|
|
156
159
|
}, z.core.$strip>>;
|
|
157
160
|
}, z.core.$strip>>>;
|
|
158
161
|
data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
159
|
-
tables: z.ZodDefault<z.ZodArray<z.ZodString
|
|
162
|
+
tables: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"platformUsers">, z.ZodString]>>>;
|
|
160
163
|
actions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
161
164
|
operations: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
162
165
|
query: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { storageScopesSchema, readStorageScopes } from '@sequenceholdings/storage';
|
|
2
2
|
import { postgresEgressError } from './egress-postgres.js';
|
|
3
|
-
import { cacheManifestSchema, managedFunctionWorkloadLimitsSchema } from '@sequenceholdings/managed-functions/config';
|
|
3
|
+
import { cacheManifestSchema, directoryScopesSchema, managedFunctionWorkloadLimitsSchema } from '@sequenceholdings/managed-functions/config';
|
|
4
4
|
import { functionProcessReadScopesSchema } from '@sequenceholdings/managed-functions/config';
|
|
5
5
|
import { isIP } from 'node:net';
|
|
6
6
|
import { z } from 'zod';
|
|
@@ -692,6 +692,7 @@ export const managedFunctionManifestSchema = z.object({
|
|
|
692
692
|
capabilities: z.object({
|
|
693
693
|
storage: storageScopesSchema.optional(),
|
|
694
694
|
processes: functionProcessReadScopesSchema.optional(),
|
|
695
|
+
directory: directoryScopesSchema.optional(),
|
|
695
696
|
roles: customRolesBlockSchema.optional(),
|
|
696
697
|
uses: capabilityPinsSchema,
|
|
697
698
|
gates: capabilityGatesSchema,
|
|
@@ -710,7 +711,12 @@ export const managedFunctionManifestSchema = z.object({
|
|
|
710
711
|
*/
|
|
711
712
|
data: z
|
|
712
713
|
.record(z.string().regex(/^[a-z][a-z0-9_]{0,40}$/, 'capabilities.data keys are ORM namespace names'), z.object({
|
|
713
|
-
|
|
714
|
+
// ORM emits this exact logical key for toPlatformUser joins; it is
|
|
715
|
+
// not a physical SQL table name or a general camelCase exception.
|
|
716
|
+
tables: z.array(z.union([
|
|
717
|
+
z.literal('platformUsers'),
|
|
718
|
+
z.string().regex(/^[a-z_][a-z0-9_]*$/, 'table names'),
|
|
719
|
+
])).max(64).default([]),
|
|
714
720
|
actions: z.array(z.string().regex(/^[a-z_][a-z0-9_]*$/, 'action names')).max(64).default([]),
|
|
715
721
|
/**
|
|
716
722
|
* ORM v2 persisted operations (GraphQL mutations/actions by name)
|
package/dist/main.js
CHANGED
|
@@ -56,13 +56,18 @@ const TOP_LEVEL_USAGE = `usage:
|
|
|
56
56
|
Where supported, --json writes structured stdout; check exit status and pagination.
|
|
57
57
|
Built-in env: local. Add your organization's deployment with
|
|
58
58
|
\`seq-studio envs add <name> <url>\`; custom entries live in ~/.config/lattice/config.toml.
|
|
59
|
+
If this CLI cannot complete a documented step, read that environment's docs
|
|
60
|
+
before trying another tool. \`seq-studio envs list\` prints each environment URL.
|
|
61
|
+
Docs: <url>/docs. Feedback guide: <url>/docs/raw/seq-studio/feedback.md.
|
|
62
|
+
Sequence: https://sequence.seqholdings.com/docs
|
|
63
|
+
and https://sequence.seqholdings.com/docs/raw/seq-studio/feedback.md.
|
|
59
64
|
`;
|
|
60
65
|
const PROCESS_USAGE = `usage:
|
|
61
66
|
seq-studio process init <dir>
|
|
62
67
|
seq-studio process lint [--dir <path>] [--offline]
|
|
63
68
|
seq-studio process plan [--dir <path>] [-e <env>]
|
|
64
69
|
seq-studio process apply [--dir <path>] [-e <env>] [--only <id1,id2,...>] [--platform-managed]
|
|
65
|
-
seq-studio process apply --repo
|
|
70
|
+
seq-studio process apply --repo <namespace>/<name> [--ref <r>] -e <env> [--only <id1,id2,...>] [--platform-managed]
|
|
66
71
|
seq-studio process promote <processId> --version <v> [-e <env>]
|
|
67
72
|
seq-studio process pull <processId> [--version <v>] [-e <env>] [--out <dir>] [--no-children]
|
|
68
73
|
seq-studio process test [-e <env>] [--offline]
|
package/dist/orm/delegate.js
CHANGED
|
@@ -172,11 +172,14 @@ async function loadOrmCli() {
|
|
|
172
172
|
throw err;
|
|
173
173
|
const message = err instanceof Error ? err.message : String(err);
|
|
174
174
|
if (isOrmPackageMissing(message)) {
|
|
175
|
-
console.error('seq-studio orm needs the @sequenceholdings/orm package.
|
|
176
|
-
'
|
|
175
|
+
console.error('seq-studio orm needs the @sequenceholdings/orm package. Add it to your app, then run the app\'s CLI:\n' +
|
|
176
|
+
' pnpm add -D @sequenceholdings/orm\n' +
|
|
177
|
+
' pnpm exec seq-studio orm …');
|
|
177
178
|
}
|
|
178
179
|
else {
|
|
179
180
|
console.error('@sequenceholdings/orm is installed but a dependency failed to load. Reinstall dependencies, then retry.\n' +
|
|
181
|
+
'A CLI installed globally with pnpm 11 cannot load drizzle-kit, which imports drizzle-orm without declaring it; ' +
|
|
182
|
+
'run the app\'s own CLI instead (`pnpm exec seq-studio orm …`).\n' +
|
|
180
183
|
` ${message}`);
|
|
181
184
|
}
|
|
182
185
|
return null;
|
|
@@ -4,7 +4,7 @@ export interface CloneDeployTarget {
|
|
|
4
4
|
}
|
|
5
5
|
export declare function assertCloneDeployAllowed(target: CloneDeployTarget): void;
|
|
6
6
|
export declare function parseCloneDeployRepo(repo: string): {
|
|
7
|
-
namespace:
|
|
7
|
+
namespace: string;
|
|
8
8
|
name: string;
|
|
9
9
|
};
|
|
10
10
|
export declare function readCloneHead(dir: string): Promise<{
|
|
@@ -21,11 +21,12 @@ export function assertCloneDeployAllowed(target) {
|
|
|
21
21
|
throw new Error(`pipeline deploy from a local clone is only supported on targets that do not require approval (got '${target.id}'). ` +
|
|
22
22
|
'Push the commit to that environment\'s git service, then deploy with --repo and --ref.');
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
/** `<namespace>/<repo>`; the server decides which namespaces may hold pipelines. */
|
|
25
|
+
const RELEASE_REPO = /^([a-z][a-z0-9-]*)\/([a-z][a-z0-9-]*)$/;
|
|
25
26
|
export function parseCloneDeployRepo(repo) {
|
|
26
27
|
const match = RELEASE_REPO.exec(repo);
|
|
27
28
|
if (!match) {
|
|
28
|
-
throw new Error(`--repo must be pipelines/<name> or
|
|
29
|
+
throw new Error(`--repo must be <namespace>/<name>, such as pipelines/<name> or your app's namespace (got '${repo}')`);
|
|
29
30
|
}
|
|
30
31
|
return { namespace: match[1], name: match[2] };
|
|
31
32
|
}
|
|
@@ -147,8 +147,9 @@ async function importPipelineSpec() {
|
|
|
147
147
|
if (err.code === 'ERR_MODULE_NOT_FOUND') {
|
|
148
148
|
const message = err instanceof Error ? err.message : String(err);
|
|
149
149
|
if (isPipelineSpecMissing(message)) {
|
|
150
|
-
console.error('seq-studio pipeline needs the @sequenceholdings/pipeline-spec package.
|
|
151
|
-
'
|
|
150
|
+
console.error('seq-studio pipeline needs the @sequenceholdings/pipeline-spec package. Add it to your app, then run the app\'s CLI:\n' +
|
|
151
|
+
' pnpm add -D @sequenceholdings/pipeline-spec\n' +
|
|
152
|
+
' pnpm exec seq-studio pipeline …');
|
|
152
153
|
}
|
|
153
154
|
else {
|
|
154
155
|
console.error('@sequenceholdings/pipeline-spec is installed but a dependency failed to load. Reinstall dependencies, then retry.\n' +
|
|
@@ -16,16 +16,19 @@ export type ProcessSourceSpec = {
|
|
|
16
16
|
ref?: string;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
* Parse the process-apply source flags. `--repo
|
|
19
|
+
* Parse the process-apply source flags. `--repo <namespace>/<name>` materializes
|
|
20
20
|
* from the platform git service; absent means local (cwd / LATTICE_PROCESSES_ROOT).
|
|
21
21
|
* `--git-url` is passed through to the underlying `resolveArtifactSource` when
|
|
22
22
|
* the repo flag is a full ns/name pair (future); today only git-service is
|
|
23
23
|
* supported.
|
|
24
24
|
*
|
|
25
|
-
* Process repos live
|
|
26
|
-
*
|
|
25
|
+
* Process repos live in `processes`, an `apps` monorepo, or a builder's own
|
|
26
|
+
* namespace. Platform namespaces that hold another kind are rejected to avoid
|
|
27
|
+
* cross-kind accidents.
|
|
27
28
|
*/
|
|
28
29
|
export declare function parseProcessSourceSpec(flags: Record<string, string | true>): ProcessSourceSpec;
|
|
30
|
+
/** The last segment of a directory path, whichever separator the platform uses. */
|
|
31
|
+
export declare function scaffoldName(dir: string): string;
|
|
29
32
|
export declare function initCommand(args: ParsedArgs): Promise<number>;
|
|
30
33
|
export declare function lintCommand(args: ParsedArgs): Promise<number>;
|
|
31
34
|
export declare function planCommand(args: ParsedArgs): Promise<number>;
|