@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
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { environment, pages, requestResult } from '../../resources/read.js';
|
|
2
|
+
export async function run(input, context) {
|
|
3
|
+
await environment(context, input.environmentId);
|
|
4
|
+
const status = input.status;
|
|
5
|
+
const filter = status === undefined
|
|
6
|
+
? {}
|
|
7
|
+
: status === '2xx' ||
|
|
8
|
+
status === '3xx' ||
|
|
9
|
+
status === '4xx' ||
|
|
10
|
+
status === '5xx'
|
|
11
|
+
? { statusClass: status }
|
|
12
|
+
: { responseStatus: Number(status) };
|
|
13
|
+
const page = await pages(input, (query) => context.sdk.requests.list({
|
|
14
|
+
...query,
|
|
15
|
+
...filter,
|
|
16
|
+
environmentId: input.environmentId,
|
|
17
|
+
...(input.app === undefined ? {} : { appName: input.app }),
|
|
18
|
+
}));
|
|
19
|
+
return { data: page.data.map(requestResult), nextCursor: page.nextCursor };
|
|
20
|
+
}
|
|
21
|
+
export function text(result) {
|
|
22
|
+
return result.data.length === 0
|
|
23
|
+
? 'No requests.\n'
|
|
24
|
+
: `${result.data.map((value) => `${value.id}\t${value.method}\t${value.path}\t${value.responseStatus}\t${value.durationMs} ms`).join('\n')}\n`;
|
|
25
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const createInputSchema: z.ZodObject<{
|
|
3
|
+
environmentId: z.ZodString;
|
|
4
|
+
wait: z.ZodDefault<z.ZodBoolean>;
|
|
5
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
export declare const snapshotsCreateCommand: import("../../command.js").RegisteredCommand;
|
|
8
|
+
export declare const listInputSchema: z.ZodObject<{
|
|
9
|
+
limit: z.ZodOptional<z.ZodString>;
|
|
10
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
11
|
+
all: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
|
+
export declare const listResultSchema: z.ZodObject<{
|
|
14
|
+
data: z.ZodArray<z.ZodObject<{
|
|
15
|
+
id: z.ZodString;
|
|
16
|
+
workspaceId: z.ZodString;
|
|
17
|
+
environmentId: z.ZodString;
|
|
18
|
+
environmentName: z.ZodNullable<z.ZodString>;
|
|
19
|
+
name: z.ZodNullable<z.ZodString>;
|
|
20
|
+
status: z.ZodString;
|
|
21
|
+
failure: z.ZodNullable<z.ZodObject<{
|
|
22
|
+
code: z.ZodString;
|
|
23
|
+
message: z.ZodString;
|
|
24
|
+
}, z.core.$strict>>;
|
|
25
|
+
sizeBytes: z.ZodNullable<z.ZodNumber>;
|
|
26
|
+
apps: z.ZodArray<z.ZodObject<{
|
|
27
|
+
appId: z.ZodString;
|
|
28
|
+
name: z.ZodString;
|
|
29
|
+
version: z.ZodString;
|
|
30
|
+
versionId: z.ZodString;
|
|
31
|
+
setup: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
32
|
+
services: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
33
|
+
sizeBytes: z.ZodNullable<z.ZodNumber>;
|
|
34
|
+
}, z.core.$strict>>;
|
|
35
|
+
createdBy: z.ZodObject<{
|
|
36
|
+
id: z.ZodNullable<z.ZodString>;
|
|
37
|
+
name: z.ZodNullable<z.ZodString>;
|
|
38
|
+
type: z.ZodString;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
createdAt: z.ZodString;
|
|
41
|
+
readyAt: z.ZodNullable<z.ZodString>;
|
|
42
|
+
deletedAt: z.ZodNullable<z.ZodString>;
|
|
43
|
+
}, z.core.$strict>>;
|
|
44
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
45
|
+
}, z.core.$strict>;
|
|
46
|
+
export declare const snapshotsListCommand: import("../../command.js").RegisteredCommand;
|
|
47
|
+
export declare const snapshotsGetCommand: import("../../command.js").RegisteredCommand;
|
|
48
|
+
export declare const snapshotsDeleteCommand: import("../../command.js").RegisteredCommand;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineCommand } from '../../command.js';
|
|
3
|
+
import { idArgument, idempotencyKeySchema, idInputSchema, pageFlags, pageInput, snapshotResultSchema, waitFlag, } from '../../resources/schema.js';
|
|
4
|
+
export const createInputSchema = z.strictObject({
|
|
5
|
+
environmentId: z.string().min(1),
|
|
6
|
+
wait: z.boolean().default(false),
|
|
7
|
+
idempotencyKey: idempotencyKeySchema,
|
|
8
|
+
});
|
|
9
|
+
export const snapshotsCreateCommand = defineCommand({
|
|
10
|
+
name: ['snapshots', 'create'],
|
|
11
|
+
summary: 'Create a snapshot of an environment.',
|
|
12
|
+
need: 'workspace',
|
|
13
|
+
destructive: false,
|
|
14
|
+
streams: false,
|
|
15
|
+
arguments: [
|
|
16
|
+
{
|
|
17
|
+
name: 'environment-id',
|
|
18
|
+
key: 'environmentId',
|
|
19
|
+
required: true,
|
|
20
|
+
many: false,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
flags: [
|
|
24
|
+
waitFlag,
|
|
25
|
+
{
|
|
26
|
+
name: 'idempotency-key',
|
|
27
|
+
key: 'idempotencyKey',
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'Reuse a key to retry the same create.',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
input: createInputSchema,
|
|
33
|
+
result: snapshotResultSchema,
|
|
34
|
+
progress: z.never(),
|
|
35
|
+
load: () => import('./create.js'),
|
|
36
|
+
});
|
|
37
|
+
export const listInputSchema = z.strictObject(pageInput);
|
|
38
|
+
export const listResultSchema = z.strictObject({
|
|
39
|
+
data: z.array(snapshotResultSchema),
|
|
40
|
+
nextCursor: z.string().nullable(),
|
|
41
|
+
});
|
|
42
|
+
export const snapshotsListCommand = defineCommand({
|
|
43
|
+
name: ['snapshots', 'list'],
|
|
44
|
+
summary: 'List snapshots in the workspace.',
|
|
45
|
+
need: 'workspace',
|
|
46
|
+
destructive: false,
|
|
47
|
+
streams: false,
|
|
48
|
+
arguments: [],
|
|
49
|
+
flags: pageFlags,
|
|
50
|
+
input: listInputSchema,
|
|
51
|
+
result: listResultSchema,
|
|
52
|
+
progress: z.never(),
|
|
53
|
+
load: () => import('./list.js'),
|
|
54
|
+
});
|
|
55
|
+
export const snapshotsGetCommand = defineCommand({
|
|
56
|
+
name: ['snapshots', 'get'],
|
|
57
|
+
summary: 'Show a snapshot.',
|
|
58
|
+
need: 'workspace',
|
|
59
|
+
destructive: false,
|
|
60
|
+
streams: false,
|
|
61
|
+
arguments: [idArgument],
|
|
62
|
+
flags: [],
|
|
63
|
+
input: idInputSchema,
|
|
64
|
+
result: snapshotResultSchema,
|
|
65
|
+
progress: z.never(),
|
|
66
|
+
load: () => import('./get.js'),
|
|
67
|
+
});
|
|
68
|
+
export const snapshotsDeleteCommand = defineCommand({
|
|
69
|
+
name: ['snapshots', 'delete'],
|
|
70
|
+
summary: 'Delete a snapshot.',
|
|
71
|
+
need: 'workspace',
|
|
72
|
+
destructive: true,
|
|
73
|
+
streams: false,
|
|
74
|
+
arguments: [idArgument],
|
|
75
|
+
flags: [],
|
|
76
|
+
input: idInputSchema,
|
|
77
|
+
result: snapshotResultSchema,
|
|
78
|
+
progress: z.never(),
|
|
79
|
+
load: () => import('./delete.js'),
|
|
80
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { WorkspaceContext } from '../../context-types.js';
|
|
3
|
+
import { resourceText } from '../../resources/read.js';
|
|
4
|
+
import type { snapshotResultSchema } from '../../resources/schema.js';
|
|
5
|
+
import type { createInputSchema } from './command.js';
|
|
6
|
+
export declare function run(input: z.infer<typeof createInputSchema>, context: WorkspaceContext): Promise<z.infer<typeof snapshotResultSchema>>;
|
|
7
|
+
export declare const text: typeof resourceText;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createKey, resourceError } from '../../resources/create.js';
|
|
2
|
+
import { environment, resourceText, snapshotResult, } from '../../resources/read.js';
|
|
3
|
+
export async function run(input, context) {
|
|
4
|
+
await environment(context, input.environmentId);
|
|
5
|
+
const idempotencyKey = createKey(input.idempotencyKey, context);
|
|
6
|
+
let id;
|
|
7
|
+
try {
|
|
8
|
+
const created = await context.sdk.snapshots.create({ environmentId: input.environmentId }, { wait: false, idempotencyKey, signal: context.io.signal });
|
|
9
|
+
id = created.id;
|
|
10
|
+
const result = input.wait
|
|
11
|
+
? await context.sdk.snapshots.wait(id, {
|
|
12
|
+
status: 'ready',
|
|
13
|
+
signal: context.io.signal,
|
|
14
|
+
})
|
|
15
|
+
: created;
|
|
16
|
+
return snapshotResult(result);
|
|
17
|
+
}
|
|
18
|
+
catch (cause) {
|
|
19
|
+
throw await resourceError(cause, context, {
|
|
20
|
+
resource: 'snapshot',
|
|
21
|
+
idempotencyKey,
|
|
22
|
+
...(id === undefined ? {} : { id }),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export const text = resourceText;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { WorkspaceContext } from '../../context-types.js';
|
|
3
|
+
import type { idInputSchema, snapshotResultSchema } from '../../resources/schema.js';
|
|
4
|
+
export declare function run(input: z.infer<typeof idInputSchema>, context: WorkspaceContext): Promise<{
|
|
5
|
+
id: string;
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
environmentId: string;
|
|
8
|
+
environmentName: string | null;
|
|
9
|
+
name: string | null;
|
|
10
|
+
status: string;
|
|
11
|
+
failure: {
|
|
12
|
+
code: string;
|
|
13
|
+
message: string;
|
|
14
|
+
} | null;
|
|
15
|
+
sizeBytes: number | null;
|
|
16
|
+
apps: {
|
|
17
|
+
appId: string;
|
|
18
|
+
name: string;
|
|
19
|
+
version: string;
|
|
20
|
+
versionId: string;
|
|
21
|
+
setup: Record<string, z.JSONType>;
|
|
22
|
+
services: Record<string, z.JSONType>;
|
|
23
|
+
sizeBytes: number | null;
|
|
24
|
+
}[];
|
|
25
|
+
createdBy: {
|
|
26
|
+
id: string | null;
|
|
27
|
+
name: string | null;
|
|
28
|
+
type: string;
|
|
29
|
+
};
|
|
30
|
+
createdAt: string;
|
|
31
|
+
readyAt: string | null;
|
|
32
|
+
deletedAt: string | null;
|
|
33
|
+
}>;
|
|
34
|
+
export declare function text(result: z.infer<typeof snapshotResultSchema>): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { snapshot, snapshotResult } from '../../resources/read.js';
|
|
2
|
+
export async function run(input, context) {
|
|
3
|
+
await snapshot(context, input.id);
|
|
4
|
+
return snapshotResult(await context.sdk.snapshots.delete(input.id));
|
|
5
|
+
}
|
|
6
|
+
export function text(result) {
|
|
7
|
+
return `Deleted ${result.id}\n`;
|
|
8
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { WorkspaceContext } from '../../context-types.js';
|
|
3
|
+
import { resourceText } from '../../resources/read.js';
|
|
4
|
+
import type { idInputSchema } from '../../resources/schema.js';
|
|
5
|
+
export declare function run(input: z.infer<typeof idInputSchema>, context: WorkspaceContext): Promise<{
|
|
6
|
+
id: string;
|
|
7
|
+
workspaceId: string;
|
|
8
|
+
environmentId: string;
|
|
9
|
+
environmentName: string | null;
|
|
10
|
+
name: string | null;
|
|
11
|
+
status: string;
|
|
12
|
+
failure: {
|
|
13
|
+
code: string;
|
|
14
|
+
message: string;
|
|
15
|
+
} | null;
|
|
16
|
+
sizeBytes: number | null;
|
|
17
|
+
apps: {
|
|
18
|
+
appId: string;
|
|
19
|
+
name: string;
|
|
20
|
+
version: string;
|
|
21
|
+
versionId: string;
|
|
22
|
+
setup: Record<string, z.JSONType>;
|
|
23
|
+
services: Record<string, z.JSONType>;
|
|
24
|
+
sizeBytes: number | null;
|
|
25
|
+
}[];
|
|
26
|
+
createdBy: {
|
|
27
|
+
id: string | null;
|
|
28
|
+
name: string | null;
|
|
29
|
+
type: string;
|
|
30
|
+
};
|
|
31
|
+
createdAt: string;
|
|
32
|
+
readyAt: string | null;
|
|
33
|
+
deletedAt: string | null;
|
|
34
|
+
}>;
|
|
35
|
+
export declare const text: typeof resourceText;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { WorkspaceContext } from '../../context-types.js';
|
|
3
|
+
import type { listInputSchema, listResultSchema } from './command.js';
|
|
4
|
+
export declare function run(input: z.infer<typeof listInputSchema>, context: WorkspaceContext): Promise<{
|
|
5
|
+
data: {
|
|
6
|
+
id: string;
|
|
7
|
+
workspaceId: string;
|
|
8
|
+
environmentId: string;
|
|
9
|
+
environmentName: string | null;
|
|
10
|
+
name: string | null;
|
|
11
|
+
status: string;
|
|
12
|
+
failure: {
|
|
13
|
+
code: string;
|
|
14
|
+
message: string;
|
|
15
|
+
} | null;
|
|
16
|
+
sizeBytes: number | null;
|
|
17
|
+
apps: {
|
|
18
|
+
appId: string;
|
|
19
|
+
name: string;
|
|
20
|
+
version: string;
|
|
21
|
+
versionId: string;
|
|
22
|
+
setup: Record<string, z.JSONType>;
|
|
23
|
+
services: Record<string, z.JSONType>;
|
|
24
|
+
sizeBytes: number | null;
|
|
25
|
+
}[];
|
|
26
|
+
createdBy: {
|
|
27
|
+
id: string | null;
|
|
28
|
+
name: string | null;
|
|
29
|
+
type: string;
|
|
30
|
+
};
|
|
31
|
+
createdAt: string;
|
|
32
|
+
readyAt: string | null;
|
|
33
|
+
deletedAt: string | null;
|
|
34
|
+
}[];
|
|
35
|
+
nextCursor: string | null;
|
|
36
|
+
}>;
|
|
37
|
+
export declare function text(result: z.infer<typeof listResultSchema>): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { pages, resourceText, snapshotResult } from '../../resources/read.js';
|
|
2
|
+
export async function run(input, context) {
|
|
3
|
+
const page = await pages(input, (query) => context.sdk.snapshots.list({ ...query, workspaceId: context.workspace.id }));
|
|
4
|
+
return { data: page.data.map(snapshotResult), nextCursor: page.nextCursor };
|
|
5
|
+
}
|
|
6
|
+
export function text(result) {
|
|
7
|
+
return result.data.length === 0
|
|
8
|
+
? 'No snapshots.\n'
|
|
9
|
+
: result.data.map(resourceText).join('');
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const unlinkCommand: import("../../command.js").RegisteredCommand;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineCommand } from '../../command.js';
|
|
3
|
+
export const unlinkCommand = defineCommand({
|
|
4
|
+
name: ['unlink'],
|
|
5
|
+
summary: 'Remove this repository’s workspace link.',
|
|
6
|
+
need: 'public',
|
|
7
|
+
destructive: false,
|
|
8
|
+
streams: false,
|
|
9
|
+
arguments: [],
|
|
10
|
+
flags: [],
|
|
11
|
+
input: z.strictObject({}),
|
|
12
|
+
result: z.strictObject({ path: z.string().nullable() }),
|
|
13
|
+
progress: z.never(),
|
|
14
|
+
load: () => import('./run.js'),
|
|
15
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const whoamiResultSchema: z.ZodObject<{
|
|
3
|
+
user: z.ZodNullable<z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
name: z.ZodNullable<z.ZodString>;
|
|
6
|
+
email: z.ZodNullable<z.ZodString>;
|
|
7
|
+
}, z.core.$strict>>;
|
|
8
|
+
organization: z.ZodNullable<z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
role: z.ZodNullable<z.ZodString>;
|
|
12
|
+
}, z.core.$strict>>;
|
|
13
|
+
credential: z.ZodObject<{
|
|
14
|
+
kind: z.ZodString;
|
|
15
|
+
id: z.ZodNullable<z.ZodString>;
|
|
16
|
+
expiresAt: z.ZodNullable<z.ZodString>;
|
|
17
|
+
idleExpiresAt: z.ZodNullable<z.ZodString>;
|
|
18
|
+
}, z.core.$strict>;
|
|
19
|
+
profile: z.ZodNullable<z.ZodString>;
|
|
20
|
+
origin: z.ZodString;
|
|
21
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
22
|
+
workspace: z.ZodNullable<z.ZodObject<{
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
name: z.ZodString;
|
|
25
|
+
source: z.ZodString;
|
|
26
|
+
}, z.core.$strict>>;
|
|
27
|
+
}, z.core.$strict>;
|
|
28
|
+
export declare const whoamiCommand: import("../../command.js").RegisteredCommand;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineCommand } from '../../command.js';
|
|
3
|
+
export const whoamiResultSchema = z.strictObject({
|
|
4
|
+
user: z
|
|
5
|
+
.strictObject({
|
|
6
|
+
id: z.string(),
|
|
7
|
+
name: z.string().nullable(),
|
|
8
|
+
email: z.string().nullable(),
|
|
9
|
+
})
|
|
10
|
+
.nullable(),
|
|
11
|
+
organization: z
|
|
12
|
+
.strictObject({
|
|
13
|
+
id: z.string(),
|
|
14
|
+
name: z.string(),
|
|
15
|
+
role: z.string().nullable(),
|
|
16
|
+
})
|
|
17
|
+
.nullable(),
|
|
18
|
+
credential: z.strictObject({
|
|
19
|
+
kind: z.string(),
|
|
20
|
+
id: z.string().nullable(),
|
|
21
|
+
expiresAt: z.string().nullable(),
|
|
22
|
+
idleExpiresAt: z.string().nullable(),
|
|
23
|
+
}),
|
|
24
|
+
profile: z.string().nullable(),
|
|
25
|
+
origin: z.string(),
|
|
26
|
+
permissions: z.array(z.string()),
|
|
27
|
+
workspace: z
|
|
28
|
+
.strictObject({ id: z.string(), name: z.string(), source: z.string() })
|
|
29
|
+
.nullable(),
|
|
30
|
+
});
|
|
31
|
+
export const whoamiCommand = defineCommand({
|
|
32
|
+
name: ['whoami'],
|
|
33
|
+
summary: 'Show the active credential, organization, and workspace.',
|
|
34
|
+
need: 'account',
|
|
35
|
+
workspace: true,
|
|
36
|
+
destructive: false,
|
|
37
|
+
streams: false,
|
|
38
|
+
arguments: [],
|
|
39
|
+
flags: [],
|
|
40
|
+
input: z.strictObject({}),
|
|
41
|
+
result: whoamiResultSchema,
|
|
42
|
+
progress: z.never(),
|
|
43
|
+
load: () => import('./run.js'),
|
|
44
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { AccountContext } from '../../context-types.js';
|
|
3
|
+
import type { whoamiResultSchema } from './command.js';
|
|
4
|
+
export declare function run(_input: object, context: AccountContext): Promise<z.infer<typeof whoamiResultSchema>>;
|
|
5
|
+
export declare function text(value: z.infer<typeof whoamiResultSchema>): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export async function run(_input, context) {
|
|
2
|
+
const me = await context.sdk.me();
|
|
3
|
+
const workspace = await context.resolveWorkspace();
|
|
4
|
+
const credential = me.credential;
|
|
5
|
+
return {
|
|
6
|
+
user: me.user === null
|
|
7
|
+
? null
|
|
8
|
+
: { id: me.user.id, name: me.user.name, email: me.user.email },
|
|
9
|
+
organization: me.organization === null
|
|
10
|
+
? null
|
|
11
|
+
: {
|
|
12
|
+
id: me.organization.id,
|
|
13
|
+
name: me.organization.name,
|
|
14
|
+
role: me.organization.role,
|
|
15
|
+
},
|
|
16
|
+
credential: {
|
|
17
|
+
kind: credential.kind,
|
|
18
|
+
id: 'id' in credential && typeof credential.id === 'string'
|
|
19
|
+
? credential.id
|
|
20
|
+
: null,
|
|
21
|
+
expiresAt: 'expiresAt' in credential && credential.expiresAt instanceof Date
|
|
22
|
+
? credential.expiresAt.toISOString()
|
|
23
|
+
: null,
|
|
24
|
+
idleExpiresAt: 'idleExpiresAt' in credential &&
|
|
25
|
+
credential.idleExpiresAt instanceof Date
|
|
26
|
+
? credential.idleExpiresAt.toISOString()
|
|
27
|
+
: null,
|
|
28
|
+
},
|
|
29
|
+
profile: context.account.kind === 'cli-token' ? context.account.profile : null,
|
|
30
|
+
origin: context.account.origin,
|
|
31
|
+
permissions: me.permissions,
|
|
32
|
+
workspace: workspace === null
|
|
33
|
+
? null
|
|
34
|
+
: { id: workspace.id, name: workspace.name, source: workspace.source },
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function text(value) {
|
|
38
|
+
return `${value.user?.email ?? value.credential.kind}\nOrganization: ${value.organization?.name ?? 'None'}\nCredential: ${value.credential.kind}\nOrigin: ${value.origin}\nWorkspace: ${value.workspace === null ? 'Not selected' : `${value.workspace.name} (${value.workspace.source})`}\n`;
|
|
39
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const workspaceResultSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
createdAt: z.ZodString;
|
|
6
|
+
archivedAt: z.ZodNullable<z.ZodString>;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
export declare const listInputSchema: z.ZodObject<{
|
|
9
|
+
limit: z.ZodOptional<z.ZodString>;
|
|
10
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
11
|
+
all: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
|
+
export declare const listResultSchema: z.ZodObject<{
|
|
14
|
+
data: z.ZodArray<z.ZodObject<{
|
|
15
|
+
id: z.ZodString;
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
createdAt: z.ZodString;
|
|
18
|
+
archivedAt: z.ZodNullable<z.ZodString>;
|
|
19
|
+
}, z.core.$strict>>;
|
|
20
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
21
|
+
}, z.core.$strict>;
|
|
22
|
+
export declare const workspacesListCommand: import("../../command.js").RegisteredCommand;
|
|
23
|
+
export declare const useInputSchema: z.ZodObject<{
|
|
24
|
+
workspace: z.ZodString;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
export declare const useResultSchema: z.ZodObject<{
|
|
27
|
+
profile: z.ZodString;
|
|
28
|
+
workspace: z.ZodObject<{
|
|
29
|
+
id: z.ZodString;
|
|
30
|
+
name: z.ZodString;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
export declare const workspacesUseCommand: import("../../command.js").RegisteredCommand;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineCommand } from '../../command.js';
|
|
3
|
+
export const workspaceResultSchema = z.strictObject({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
name: z.string(),
|
|
6
|
+
createdAt: z.string(),
|
|
7
|
+
archivedAt: z.string().nullable(),
|
|
8
|
+
});
|
|
9
|
+
export const listInputSchema = z.strictObject({
|
|
10
|
+
limit: z
|
|
11
|
+
.string()
|
|
12
|
+
.regex(/^[1-9]\d*$/)
|
|
13
|
+
.optional(),
|
|
14
|
+
cursor: z.string().min(1).optional(),
|
|
15
|
+
all: z.boolean().default(false),
|
|
16
|
+
});
|
|
17
|
+
export const listResultSchema = z.strictObject({
|
|
18
|
+
data: z.array(workspaceResultSchema),
|
|
19
|
+
nextCursor: z.string().nullable(),
|
|
20
|
+
});
|
|
21
|
+
export const workspacesListCommand = defineCommand({
|
|
22
|
+
name: ['workspaces', 'list'],
|
|
23
|
+
summary: 'List accessible workspaces.',
|
|
24
|
+
need: 'account',
|
|
25
|
+
destructive: false,
|
|
26
|
+
streams: false,
|
|
27
|
+
arguments: [],
|
|
28
|
+
flags: [
|
|
29
|
+
{
|
|
30
|
+
name: 'limit',
|
|
31
|
+
key: 'limit',
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'Maximum results per page.',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'cursor',
|
|
37
|
+
key: 'cursor',
|
|
38
|
+
type: 'string',
|
|
39
|
+
description: 'Continue from this cursor.',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'all',
|
|
43
|
+
key: 'all',
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
negatedName: null,
|
|
46
|
+
description: 'Read every page.',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
input: listInputSchema,
|
|
50
|
+
result: listResultSchema,
|
|
51
|
+
progress: z.never(),
|
|
52
|
+
load: () => import('./list.js'),
|
|
53
|
+
});
|
|
54
|
+
export const useInputSchema = z.strictObject({ workspace: z.string().min(1) });
|
|
55
|
+
export const useResultSchema = z.strictObject({
|
|
56
|
+
profile: z.string(),
|
|
57
|
+
workspace: z.strictObject({ id: z.string(), name: z.string() }),
|
|
58
|
+
});
|
|
59
|
+
export const workspacesUseCommand = defineCommand({
|
|
60
|
+
name: ['workspaces', 'use'],
|
|
61
|
+
summary: 'Set the profile’s default workspace.',
|
|
62
|
+
need: 'account',
|
|
63
|
+
destructive: false,
|
|
64
|
+
streams: false,
|
|
65
|
+
arguments: [
|
|
66
|
+
{ name: 'workspace', key: 'workspace', required: true, many: false },
|
|
67
|
+
],
|
|
68
|
+
flags: [],
|
|
69
|
+
input: useInputSchema,
|
|
70
|
+
result: useResultSchema,
|
|
71
|
+
progress: z.never(),
|
|
72
|
+
load: () => import('./use.js'),
|
|
73
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { AccountContext } from '../../context-types.js';
|
|
3
|
+
import type { listInputSchema, listResultSchema } from './command.js';
|
|
4
|
+
export declare function run(input: z.infer<typeof listInputSchema>, context: AccountContext): Promise<z.infer<typeof listResultSchema>>;
|
|
5
|
+
export declare function text(result: z.infer<typeof listResultSchema>): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CliError } from '../../errors.js';
|
|
2
|
+
export async function run(input, context) {
|
|
3
|
+
const limit = input.limit === undefined ? undefined : Number(input.limit);
|
|
4
|
+
if (limit !== undefined && (!Number.isSafeInteger(limit) || limit > 100)) {
|
|
5
|
+
throw new CliError('cli.invalid_arguments', {
|
|
6
|
+
message: 'Use a limit between 1 and 100.',
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
const data = [];
|
|
10
|
+
let cursor = input.cursor;
|
|
11
|
+
let nextCursor = null;
|
|
12
|
+
const seen = new Set();
|
|
13
|
+
do {
|
|
14
|
+
const page = await context.sdk.workspaces.list({
|
|
15
|
+
...(limit === undefined ? {} : { limit }),
|
|
16
|
+
...(cursor === undefined ? {} : { cursor }),
|
|
17
|
+
});
|
|
18
|
+
data.push(...page.data.map((workspace) => ({
|
|
19
|
+
id: workspace.id,
|
|
20
|
+
name: workspace.name,
|
|
21
|
+
createdAt: workspace.createdAt.toISOString(),
|
|
22
|
+
archivedAt: workspace.archivedAt?.toISOString() ?? null,
|
|
23
|
+
})));
|
|
24
|
+
nextCursor = page.nextCursor;
|
|
25
|
+
if (!input.all || nextCursor === null) {
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
if (seen.has(nextCursor)) {
|
|
29
|
+
throw new CliError('cli.invalid_response');
|
|
30
|
+
}
|
|
31
|
+
seen.add(nextCursor);
|
|
32
|
+
cursor = nextCursor;
|
|
33
|
+
} while (input.all && nextCursor !== null);
|
|
34
|
+
return { data, nextCursor };
|
|
35
|
+
}
|
|
36
|
+
export function text(result) {
|
|
37
|
+
return result.data.length === 0
|
|
38
|
+
? 'No workspaces.\n'
|
|
39
|
+
: `${result.data
|
|
40
|
+
.map((workspace) => `${workspace.id}\t${workspace.name}`)
|
|
41
|
+
.join('\n')}\n`;
|
|
42
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { AccountContext } from '../../context-types.js';
|
|
3
|
+
import type { useInputSchema, useResultSchema } from './command.js';
|
|
4
|
+
export declare function run(input: z.infer<typeof useInputSchema>, context: AccountContext): Promise<z.infer<typeof useResultSchema>>;
|
|
5
|
+
export declare function text(value: z.infer<typeof useResultSchema>): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CliError } from '../../errors.js';
|
|
2
|
+
export async function run(input, context) {
|
|
3
|
+
if (context.account.kind !== 'cli-token') {
|
|
4
|
+
throw new CliError('cli.invalid_arguments', {
|
|
5
|
+
message: 'A workspace key has a fixed workspace. Sign in to set a profile’s default.',
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
const workspace = await context.findWorkspace(input.workspace);
|
|
9
|
+
await context.accounts.setWorkspace({
|
|
10
|
+
account: context.account,
|
|
11
|
+
workspace: workspace.id,
|
|
12
|
+
mode: 'replace',
|
|
13
|
+
});
|
|
14
|
+
return { profile: context.account.profile, workspace };
|
|
15
|
+
}
|
|
16
|
+
export function text(value) {
|
|
17
|
+
return `Default workspace: ${value.workspace.name}\n`;
|
|
18
|
+
}
|