@usestatemachines/cli 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +34 -2
- package/dist/agents/bundled.d.ts +5 -0
- package/dist/agents/bundled.js +6 -0
- package/dist/agents/destinations.d.ts +13 -0
- package/dist/agents/destinations.js +16 -0
- package/dist/api-internal.d.ts +62 -0
- package/dist/api-internal.js +348 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +4 -0
- package/dist/command.d.ts +119 -0
- package/dist/command.js +195 -0
- package/dist/commands/api/command.d.ts +15 -0
- package/dist/commands/api/command.js +38 -0
- package/dist/commands/api/run.d.ts +4 -0
- package/dist/commands/api/run.js +24 -0
- package/dist/commands/apps/command.d.ts +19 -0
- package/dist/commands/apps/command.js +29 -0
- package/dist/commands/apps/list.d.ts +8 -0
- package/dist/commands/apps/list.js +10 -0
- package/dist/commands/connect/command.d.ts +34 -0
- package/dist/commands/connect/command.js +70 -0
- package/dist/commands/connect/run.d.ts +10 -0
- package/dist/commands/connect/run.js +71 -0
- package/dist/commands/doctor/command.d.ts +29 -0
- package/dist/commands/doctor/command.js +36 -0
- package/dist/commands/doctor/run.d.ts +13 -0
- package/dist/commands/doctor/run.js +12 -0
- package/dist/commands/env/command.d.ts +5 -0
- package/dist/commands/env/command.js +19 -0
- package/dist/commands/env/pull.d.ts +6 -0
- package/dist/commands/env/pull.js +6 -0
- package/dist/commands/environments/command.d.ts +121 -0
- package/dist/commands/environments/command.js +170 -0
- package/dist/commands/environments/create.d.ts +9 -0
- package/dist/commands/environments/create.js +42 -0
- package/dist/commands/environments/delete.d.ts +7 -0
- package/dist/commands/environments/delete.js +48 -0
- package/dist/commands/environments/get.d.ts +39 -0
- package/dist/commands/environments/get.js +5 -0
- package/dist/commands/environments/list.d.ts +41 -0
- package/dist/commands/environments/list.js +18 -0
- package/dist/commands/environments/wait.d.ts +39 -0
- package/dist/commands/environments/wait.js +21 -0
- package/dist/commands/init/command.d.ts +68 -0
- package/dist/commands/init/command.js +90 -0
- package/dist/commands/init/run.d.ts +8 -0
- package/dist/commands/init/run.js +422 -0
- package/dist/commands/link/command.d.ts +13 -0
- package/dist/commands/link/command.js +32 -0
- package/dist/commands/link/run.d.ts +12 -0
- package/dist/commands/link/run.js +7 -0
- package/dist/commands/login/command.d.ts +1 -0
- package/dist/commands/login/command.js +43 -0
- package/dist/commands/login/run.d.ts +30 -0
- package/dist/commands/login/run.js +43 -0
- package/dist/commands/login/schema.d.ts +33 -0
- package/dist/commands/login/schema.js +33 -0
- package/dist/commands/logout/command.d.ts +1 -0
- package/dist/commands/logout/command.js +24 -0
- package/dist/commands/logout/run.d.ts +10 -0
- package/dist/commands/logout/run.js +19 -0
- package/dist/commands/logout/schema.d.ts +10 -0
- package/dist/commands/logout/schema.js +10 -0
- package/dist/commands/profiles/command.d.ts +2 -0
- package/dist/commands/profiles/command.js +29 -0
- package/dist/commands/profiles/list.d.ts +20 -0
- package/dist/commands/profiles/list.js +10 -0
- package/dist/commands/profiles/schema.d.ts +24 -0
- package/dist/commands/profiles/schema.js +19 -0
- package/dist/commands/profiles/use.d.ts +7 -0
- package/dist/commands/profiles/use.js +7 -0
- package/dist/commands/requests/command.d.ts +39 -0
- package/dist/commands/requests/command.js +65 -0
- package/dist/commands/requests/get.d.ts +32 -0
- package/dist/commands/requests/get.js +15 -0
- package/dist/commands/requests/list.d.ts +27 -0
- package/dist/commands/requests/list.js +25 -0
- package/dist/commands/snapshots/command.d.ts +48 -0
- package/dist/commands/snapshots/command.js +80 -0
- package/dist/commands/snapshots/create.d.ts +7 -0
- package/dist/commands/snapshots/create.js +26 -0
- package/dist/commands/snapshots/delete.d.ts +34 -0
- package/dist/commands/snapshots/delete.js +8 -0
- package/dist/commands/snapshots/get.d.ts +35 -0
- package/dist/commands/snapshots/get.js +5 -0
- package/dist/commands/snapshots/list.d.ts +37 -0
- package/dist/commands/snapshots/list.js +10 -0
- package/dist/commands/unlink/command.d.ts +1 -0
- package/dist/commands/unlink/command.js +15 -0
- package/dist/commands/unlink/run.d.ts +7 -0
- package/dist/commands/unlink/run.js +8 -0
- package/dist/commands/whoami/command.d.ts +28 -0
- package/dist/commands/whoami/command.js +44 -0
- package/dist/commands/whoami/run.d.ts +5 -0
- package/dist/commands/whoami/run.js +39 -0
- package/dist/commands/workspaces/command.d.ts +33 -0
- package/dist/commands/workspaces/command.js +73 -0
- package/dist/commands/workspaces/list.d.ts +5 -0
- package/dist/commands/workspaces/list.js +42 -0
- package/dist/commands/workspaces/use.d.ts +5 -0
- package/dist/commands/workspaces/use.js +18 -0
- package/dist/config/project.d.ts +21 -0
- package/dist/config/project.js +105 -0
- package/dist/config/schema.d.ts +616 -0
- package/dist/config/schema.js +282 -0
- package/dist/context-types.d.ts +89 -0
- package/dist/context-types.js +56 -0
- package/dist/context.d.ts +13 -0
- package/dist/context.js +290 -0
- package/dist/credentials/sealing.d.ts +10 -0
- package/dist/credentials/sealing.js +72 -0
- package/dist/credentials/store.d.ts +17 -0
- package/dist/credentials/store.js +156 -0
- package/dist/doctor.d.ts +4 -0
- package/dist/doctor.js +239 -0
- package/dist/env-file.d.ts +10 -0
- package/dist/env-file.js +254 -0
- package/dist/errors.d.ts +784 -0
- package/dist/errors.js +459 -0
- package/dist/flags.d.ts +22 -0
- package/dist/flags.js +56 -0
- package/dist/generated/internal.d.ts +138 -0
- package/dist/generated/internal.js +2627 -0
- package/dist/generated/retry.d.ts +1 -0
- package/dist/generated/retry.js +11 -0
- package/dist/help.d.ts +408 -0
- package/dist/help.js +220 -0
- package/dist/io-types.d.ts +127 -0
- package/dist/io-types.js +1 -0
- package/dist/io.d.ts +13 -0
- package/dist/io.js +1017 -0
- package/dist/keys.d.ts +50 -0
- package/dist/keys.js +691 -0
- package/dist/link.d.ts +6 -0
- package/dist/link.js +58 -0
- package/dist/login.d.ts +92 -0
- package/dist/login.js +965 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +126 -0
- package/dist/native-helper.d.ts +1 -0
- package/dist/native-helper.js +2 -0
- package/dist/output.d.ts +8 -0
- package/dist/output.js +135 -0
- package/dist/parser.d.ts +28 -0
- package/dist/parser.js +250 -0
- package/dist/program-types.d.ts +67 -0
- package/dist/program-types.js +14 -0
- package/dist/programs.d.ts +2 -0
- package/dist/programs.js +44 -0
- package/dist/project-roots.d.ts +3 -0
- package/dist/project-roots.js +26 -0
- package/dist/prompt.d.ts +3 -0
- package/dist/prompt.js +61 -0
- package/dist/registry.d.ts +2 -0
- package/dist/registry.js +44 -0
- package/dist/resources/create.d.ts +9 -0
- package/dist/resources/create.js +55 -0
- package/dist/resources/read.d.ts +15 -0
- package/dist/resources/read.js +69 -0
- package/dist/resources/schema.d.ts +177 -0
- package/dist/resources/schema.js +158 -0
- package/dist/text.d.ts +3 -0
- package/dist/text.js +19 -0
- package/dist/update.d.ts +22 -0
- package/dist/update.js +126 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/package.json +52 -3
package/dist/link.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { linkResultSchema } from './commands/link/command.js';
|
|
3
|
+
import { type AccountContext } from './context-types.js';
|
|
4
|
+
export declare function linkWorkspace(context: AccountContext, input: {
|
|
5
|
+
readonly force: boolean;
|
|
6
|
+
}): Promise<z.infer<typeof linkResultSchema>>;
|
package/dist/link.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { allWorkspaces } from './context.js';
|
|
2
|
+
import { organizationIdSchema, workspaceIdSchema, } from './context-types.js';
|
|
3
|
+
import { CliError } from './errors.js';
|
|
4
|
+
export async function linkWorkspace(context, input) {
|
|
5
|
+
const selected = context.globals.workspace ??
|
|
6
|
+
context.io.host.environment.STATEMACHINES_WORKSPACE;
|
|
7
|
+
let workspace;
|
|
8
|
+
if (selected !== undefined && selected !== null) {
|
|
9
|
+
workspace = await context.findWorkspace(selected);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
const workspaces = await allWorkspaces(context.sdk);
|
|
13
|
+
const first = workspaces[0];
|
|
14
|
+
if (first === undefined) {
|
|
15
|
+
throw new CliError('cli.not_linked', {
|
|
16
|
+
message: 'No accessible workspaces are available.',
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
if (context.globals.yes && workspaces.length === 1) {
|
|
20
|
+
workspace = { id: workspaceIdSchema.parse(first.id), name: first.name };
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
if (context.presentation.mode !== 'interactive') {
|
|
24
|
+
throw new CliError('cli.input_required', {
|
|
25
|
+
message: 'Choose a workspace with --workspace, or use --yes when there is one workspace.',
|
|
26
|
+
next: [
|
|
27
|
+
{
|
|
28
|
+
command: 'statemachines link --workspace <id>',
|
|
29
|
+
reason: 'Choose the workspace to link.',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const id = await context.io.prompt.select('Choose a workspace', workspaces.map((value) => ({ value: value.id, label: value.name })), { signal: context.io.signal, deadline: null });
|
|
35
|
+
workspace = await context.findWorkspace(id);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (context.account.kind === 'workspace-key' &&
|
|
39
|
+
workspace.id !== context.account.workspaceId) {
|
|
40
|
+
throw new CliError('cli.workspace_mismatch');
|
|
41
|
+
}
|
|
42
|
+
const organization = organizationIdSchema.safeParse(context.account.kind === 'cli-token'
|
|
43
|
+
? context.account.organizationId
|
|
44
|
+
: (await context.sdk.me()).organization?.id);
|
|
45
|
+
if (!organization.success) {
|
|
46
|
+
throw new CliError('cli.invalid_response');
|
|
47
|
+
}
|
|
48
|
+
const organizationId = organization.data;
|
|
49
|
+
const link = await context.projects.link({ organizationId, workspaceId: workspace.id }, input.force);
|
|
50
|
+
if (context.account.kind === 'cli-token') {
|
|
51
|
+
await context.accounts.setWorkspace({
|
|
52
|
+
account: context.account,
|
|
53
|
+
workspace: workspace.id,
|
|
54
|
+
mode: 'if-unset',
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return { path: link.path, organizationId, workspace };
|
|
58
|
+
}
|
package/dist/login.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { AnonymousApi, AuthenticatedInternalApi } from './api-internal.js';
|
|
3
|
+
import type { CommandEvent } from './command.js';
|
|
4
|
+
import type { loginProgressSchema, loginResultSchema } from './commands/login/schema.js';
|
|
5
|
+
import type { logoutResultSchema } from './commands/logout/schema.js';
|
|
6
|
+
import type { profilesResultSchema } from './commands/profiles/schema.js';
|
|
7
|
+
import { type SecretRef } from './config/schema.js';
|
|
8
|
+
import { type Account, type ApiOrigin, type ProfileName, type WorkspaceId } from './context-types.js';
|
|
9
|
+
import type { EffectOptions, Io } from './io-types.js';
|
|
10
|
+
import type { EnvironmentFiles, ProgramKeys } from './program-types.js';
|
|
11
|
+
export declare const recoveryReportSchema: z.ZodObject<{
|
|
12
|
+
acknowledged: z.ZodArray<z.ZodString>;
|
|
13
|
+
revoked: z.ZodArray<z.ZodString>;
|
|
14
|
+
pending: z.ZodArray<z.ZodString>;
|
|
15
|
+
unconfirmed: z.ZodArray<z.ZodString>;
|
|
16
|
+
}, z.core.$strict>;
|
|
17
|
+
export type LoginResult = z.infer<typeof loginResultSchema>;
|
|
18
|
+
export type LoginProgress = z.infer<typeof loginProgressSchema>;
|
|
19
|
+
export type LoginInput = {
|
|
20
|
+
profile: ProfileName | null;
|
|
21
|
+
origin: ApiOrigin | null;
|
|
22
|
+
mode: 'wait' | 'no-wait' | 'resume';
|
|
23
|
+
browser: boolean;
|
|
24
|
+
replace: boolean;
|
|
25
|
+
interactive: boolean;
|
|
26
|
+
};
|
|
27
|
+
export interface AccountClients {
|
|
28
|
+
anonymous(origin: ApiOrigin): AnonymousApi;
|
|
29
|
+
authenticated(origin: ApiOrigin, token: string): Pick<AuthenticatedInternalApi, 'collected' | 'revokeCurrent' | 'createKey' | 'revokeKey'>;
|
|
30
|
+
validateKey(origin: ApiOrigin, key: string, options: EffectOptions): Promise<{
|
|
31
|
+
id: string;
|
|
32
|
+
workspaceId: WorkspaceId;
|
|
33
|
+
kind: 'dashboard' | 'cli_run' | 'env_pull';
|
|
34
|
+
expiresAt: string | null;
|
|
35
|
+
}>;
|
|
36
|
+
defaultWorkspace(origin: ApiOrigin, token: string, options: EffectOptions): Promise<WorkspaceId | null>;
|
|
37
|
+
}
|
|
38
|
+
export interface Accounts {
|
|
39
|
+
inspect(options?: EffectOptions): Promise<{
|
|
40
|
+
defaultProfile: string | null;
|
|
41
|
+
profiles: {
|
|
42
|
+
name: string;
|
|
43
|
+
origin: ApiOrigin;
|
|
44
|
+
organizationId: string;
|
|
45
|
+
store: SecretRef['store'];
|
|
46
|
+
idleExpiresAt: string;
|
|
47
|
+
expiresAt: string;
|
|
48
|
+
}[];
|
|
49
|
+
pendingAcknowledgements: number;
|
|
50
|
+
pendingRevocations: number;
|
|
51
|
+
pendingCleanup: number;
|
|
52
|
+
}>;
|
|
53
|
+
login(input: LoginInput, options?: EffectOptions): AsyncIterable<CommandEvent<LoginResult, LoginProgress>>;
|
|
54
|
+
logout(input: {
|
|
55
|
+
profiles: 'all' | ProfileName | null;
|
|
56
|
+
}, options?: EffectOptions): Promise<z.infer<typeof logoutResultSchema>>;
|
|
57
|
+
list(options?: EffectOptions): Promise<z.infer<typeof profilesResultSchema>>;
|
|
58
|
+
use(profile: ProfileName, options?: EffectOptions): Promise<{
|
|
59
|
+
profile: string;
|
|
60
|
+
}>;
|
|
61
|
+
setWorkspace(input: {
|
|
62
|
+
account: Extract<Account, {
|
|
63
|
+
kind: 'cli-token';
|
|
64
|
+
}>;
|
|
65
|
+
workspace: WorkspaceId;
|
|
66
|
+
mode: 'replace' | 'if-unset';
|
|
67
|
+
}, options?: EffectOptions): Promise<void>;
|
|
68
|
+
reconcile(reason: 'next-command' | 'login' | 'logout' | 'doctor', options?: EffectOptions): Promise<z.infer<typeof recoveryReportSchema>>;
|
|
69
|
+
}
|
|
70
|
+
export interface AccountAuthentication {
|
|
71
|
+
withCredential<Value>(selection: {
|
|
72
|
+
profile: ProfileName | null;
|
|
73
|
+
expectedOrigin: ApiOrigin | null;
|
|
74
|
+
}, action: (value: {
|
|
75
|
+
account: Extract<Account, {
|
|
76
|
+
kind: 'cli-token';
|
|
77
|
+
}>;
|
|
78
|
+
defaultWorkspace: WorkspaceId | null;
|
|
79
|
+
token: string;
|
|
80
|
+
}) => Promise<Value>, options?: EffectOptions): Promise<Value>;
|
|
81
|
+
}
|
|
82
|
+
export declare function createAccounts(input: {
|
|
83
|
+
io: Io;
|
|
84
|
+
version: string;
|
|
85
|
+
clients: AccountClients;
|
|
86
|
+
environmentFiles: EnvironmentFiles;
|
|
87
|
+
options?: EffectOptions;
|
|
88
|
+
}): {
|
|
89
|
+
accounts: Accounts;
|
|
90
|
+
authentication: AccountAuthentication;
|
|
91
|
+
programKeys: ProgramKeys;
|
|
92
|
+
};
|