@xano/cli 0.0.13 → 0.0.15
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 +97 -12
- package/dist/commands/profile/create/index.d.ts +2 -0
- package/dist/commands/profile/create/index.js +15 -0
- package/dist/commands/profile/edit/index.d.ts +4 -0
- package/dist/commands/profile/edit/index.js +37 -1
- package/dist/commands/profile/list/index.js +5 -0
- package/dist/commands/profile/project/index.d.ts +6 -0
- package/dist/commands/profile/project/index.js +54 -0
- package/dist/commands/profile/token/index.d.ts +6 -0
- package/dist/commands/profile/token/index.js +54 -0
- package/dist/commands/profile/wizard/index.d.ts +1 -0
- package/dist/commands/profile/wizard/index.js +70 -0
- package/dist/commands/run/env/delete/index.d.ts +13 -0
- package/dist/commands/run/env/delete/index.js +65 -0
- package/dist/commands/run/env/get/index.d.ts +13 -0
- package/dist/commands/run/env/get/index.js +52 -0
- package/dist/commands/run/env/list/index.d.ts +11 -0
- package/dist/commands/run/env/list/index.js +58 -0
- package/dist/commands/run/env/set/index.d.ts +13 -0
- package/dist/commands/run/env/set/index.js +51 -0
- package/dist/commands/{ephemeral/run/job → run/exec}/index.d.ts +4 -3
- package/dist/commands/run/exec/index.js +353 -0
- package/dist/commands/{ephemeral/run/service → run/info}/index.d.ts +3 -5
- package/dist/commands/run/info/index.js +160 -0
- package/dist/commands/run/projects/create/index.d.ts +13 -0
- package/dist/commands/run/projects/create/index.js +75 -0
- package/dist/commands/run/projects/delete/index.d.ts +13 -0
- package/dist/commands/run/projects/delete/index.js +65 -0
- package/dist/commands/run/projects/list/index.d.ts +12 -0
- package/dist/commands/run/projects/list/index.js +66 -0
- package/dist/commands/run/projects/update/index.d.ts +15 -0
- package/dist/commands/run/projects/update/index.js +86 -0
- package/dist/commands/run/secrets/delete/index.d.ts +13 -0
- package/dist/commands/run/secrets/delete/index.js +65 -0
- package/dist/commands/run/secrets/get/index.d.ts +13 -0
- package/dist/commands/run/secrets/get/index.js +52 -0
- package/dist/commands/run/secrets/list/index.d.ts +11 -0
- package/dist/commands/run/secrets/list/index.js +62 -0
- package/dist/commands/run/secrets/set/index.d.ts +15 -0
- package/dist/commands/run/secrets/set/index.js +74 -0
- package/dist/commands/run/sessions/delete/index.d.ts +13 -0
- package/dist/commands/run/sessions/delete/index.js +65 -0
- package/dist/commands/run/sessions/get/index.d.ts +13 -0
- package/dist/commands/run/sessions/get/index.js +72 -0
- package/dist/commands/run/sessions/list/index.d.ts +12 -0
- package/dist/commands/run/sessions/list/index.js +64 -0
- package/dist/commands/run/sessions/start/index.d.ts +13 -0
- package/dist/commands/run/sessions/start/index.js +56 -0
- package/dist/commands/run/sessions/stop/index.d.ts +13 -0
- package/dist/commands/run/sessions/stop/index.js +56 -0
- package/dist/commands/run/sink/get/index.d.ts +13 -0
- package/dist/commands/run/sink/get/index.js +63 -0
- package/dist/lib/base-run-command.d.ts +41 -0
- package/dist/lib/base-run-command.js +73 -0
- package/dist/lib/run-http-client.d.ts +58 -0
- package/dist/lib/run-http-client.js +136 -0
- package/dist/lib/run-types.d.ts +226 -0
- package/dist/lib/run-types.js +5 -0
- package/oclif.manifest.json +1423 -306
- package/package.json +1 -1
- package/dist/commands/ephemeral/run/job/index.js +0 -311
- package/dist/commands/ephemeral/run/service/index.js +0 -287
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
3
|
+
export default class RunSecretsList extends BaseRunCommand {
|
|
4
|
+
static args = {};
|
|
5
|
+
static flags = {
|
|
6
|
+
...BaseRunCommand.baseFlags,
|
|
7
|
+
output: Flags.string({
|
|
8
|
+
char: 'o',
|
|
9
|
+
description: 'Output format',
|
|
10
|
+
required: false,
|
|
11
|
+
default: 'table',
|
|
12
|
+
options: ['table', 'json'],
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
static description = 'List all secret keys';
|
|
16
|
+
static examples = [
|
|
17
|
+
`$ xano run secrets list
|
|
18
|
+
NAME TYPE REPO
|
|
19
|
+
docker-registry kubernetes.io/dockerconfigjson ghcr.io
|
|
20
|
+
service-account kubernetes.io/service-account-token -
|
|
21
|
+
`,
|
|
22
|
+
`$ xano run secrets list -o json
|
|
23
|
+
{ "secrets": [{ "name": "docker-registry", "type": "kubernetes.io/dockerconfigjson", "repo": "ghcr.io" }] }
|
|
24
|
+
`,
|
|
25
|
+
];
|
|
26
|
+
async run() {
|
|
27
|
+
const { flags } = await this.parse(RunSecretsList);
|
|
28
|
+
// Initialize with project required
|
|
29
|
+
await this.initRunCommandWithProject(flags.profile);
|
|
30
|
+
try {
|
|
31
|
+
const url = this.httpClient.buildProjectUrl('/secret/key');
|
|
32
|
+
const result = await this.httpClient.get(url);
|
|
33
|
+
if (flags.output === 'json') {
|
|
34
|
+
this.outputJson(result);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
if (result.secrets.length === 0) {
|
|
38
|
+
this.log('No secrets found.');
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// Print header
|
|
42
|
+
this.log('NAME TYPE REPO');
|
|
43
|
+
this.log('-'.repeat(80));
|
|
44
|
+
for (const secret of result.secrets) {
|
|
45
|
+
const name = secret.name.slice(0, 24).padEnd(24);
|
|
46
|
+
const type = secret.type.padEnd(37);
|
|
47
|
+
const repo = secret.repo || '-';
|
|
48
|
+
this.log(`${name} ${type} ${repo}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (error instanceof Error) {
|
|
55
|
+
this.error(`Failed to list secrets: ${error.message}`);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.error(`Failed to list secrets: ${String(error)}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
2
|
+
export default class RunSecretsSet extends BaseRunCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static flags: {
|
|
7
|
+
type: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
value: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
repo: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
static description: string;
|
|
13
|
+
static examples: string[];
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
3
|
+
export default class RunSecretsSet extends BaseRunCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
name: Args.string({
|
|
6
|
+
description: 'Secret name',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static flags = {
|
|
11
|
+
...BaseRunCommand.baseFlags,
|
|
12
|
+
type: Flags.string({
|
|
13
|
+
char: 't',
|
|
14
|
+
description: 'Secret type',
|
|
15
|
+
required: true,
|
|
16
|
+
options: ['dockerconfigjson', 'service-account-token'],
|
|
17
|
+
}),
|
|
18
|
+
value: Flags.string({
|
|
19
|
+
char: 'v',
|
|
20
|
+
description: 'Secret value',
|
|
21
|
+
required: true,
|
|
22
|
+
}),
|
|
23
|
+
repo: Flags.string({
|
|
24
|
+
char: 'r',
|
|
25
|
+
description: 'Repository (for dockerconfigjson type)',
|
|
26
|
+
required: false,
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
static description = 'Set a secret';
|
|
30
|
+
static examples = [
|
|
31
|
+
`$ xano run secrets set docker-registry -t dockerconfigjson -v '{"auths":{"ghcr.io":{"auth":"..."}}}' -r ghcr.io
|
|
32
|
+
Secret 'docker-registry' set successfully!
|
|
33
|
+
`,
|
|
34
|
+
`$ xano run secrets set service-key -t service-account-token -v 'token-value-here'
|
|
35
|
+
Secret 'service-key' set successfully!
|
|
36
|
+
`,
|
|
37
|
+
];
|
|
38
|
+
async run() {
|
|
39
|
+
const { args, flags } = await this.parse(RunSecretsSet);
|
|
40
|
+
// Initialize with project required
|
|
41
|
+
await this.initRunCommandWithProject(flags.profile);
|
|
42
|
+
// Map short type to full type
|
|
43
|
+
const typeMap = {
|
|
44
|
+
'dockerconfigjson': 'kubernetes.io/dockerconfigjson',
|
|
45
|
+
'service-account-token': 'kubernetes.io/service-account-token',
|
|
46
|
+
};
|
|
47
|
+
const secretType = typeMap[flags.type];
|
|
48
|
+
if (!secretType) {
|
|
49
|
+
this.error(`Invalid secret type: ${flags.type}`);
|
|
50
|
+
}
|
|
51
|
+
const input = {
|
|
52
|
+
name: args.name,
|
|
53
|
+
secret: {
|
|
54
|
+
name: args.name,
|
|
55
|
+
type: secretType,
|
|
56
|
+
value: flags.value,
|
|
57
|
+
...(flags.repo && { repo: flags.repo }),
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
try {
|
|
61
|
+
const url = this.httpClient.buildProjectUrl('/secret');
|
|
62
|
+
await this.httpClient.patch(url, input);
|
|
63
|
+
this.log(`Secret '${args.name}' set successfully!`);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (error instanceof Error) {
|
|
67
|
+
this.error(`Failed to set secret: ${error.message}`);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
this.error(`Failed to set secret: ${String(error)}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
2
|
+
export default class RunSessionsDelete extends BaseRunCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
sessionId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static flags: {
|
|
7
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
static description: string;
|
|
11
|
+
static examples: string[];
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
3
|
+
export default class RunSessionsDelete extends BaseRunCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
sessionId: Args.string({
|
|
6
|
+
description: 'Session ID',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static flags = {
|
|
11
|
+
...BaseRunCommand.baseFlags,
|
|
12
|
+
force: Flags.boolean({
|
|
13
|
+
char: 'f',
|
|
14
|
+
description: 'Skip confirmation prompt',
|
|
15
|
+
required: false,
|
|
16
|
+
default: false,
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
static description = 'Delete a session';
|
|
20
|
+
static examples = [
|
|
21
|
+
`$ xano run sessions delete abc123-def456
|
|
22
|
+
Are you sure you want to delete session 'abc123-def456'? (y/N)
|
|
23
|
+
Session deleted successfully!
|
|
24
|
+
`,
|
|
25
|
+
`$ xano run sessions delete abc123-def456 --force
|
|
26
|
+
Session deleted successfully!
|
|
27
|
+
`,
|
|
28
|
+
];
|
|
29
|
+
async run() {
|
|
30
|
+
const { args, flags } = await this.parse(RunSessionsDelete);
|
|
31
|
+
// Initialize with project required
|
|
32
|
+
await this.initRunCommandWithProject(flags.profile);
|
|
33
|
+
// Confirm deletion unless --force is used
|
|
34
|
+
if (!flags.force) {
|
|
35
|
+
const readline = await import('node:readline');
|
|
36
|
+
const rl = readline.createInterface({
|
|
37
|
+
input: process.stdin,
|
|
38
|
+
output: process.stdout,
|
|
39
|
+
});
|
|
40
|
+
const confirmed = await new Promise((resolve) => {
|
|
41
|
+
rl.question(`Are you sure you want to delete session '${args.sessionId}'? (y/N) `, (answer) => {
|
|
42
|
+
rl.close();
|
|
43
|
+
resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
if (!confirmed) {
|
|
47
|
+
this.log('Deletion cancelled.');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const url = this.httpClient.buildProjectUrl(`/run/session/${args.sessionId}`);
|
|
53
|
+
await this.httpClient.delete(url);
|
|
54
|
+
this.log('Session deleted successfully!');
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
if (error instanceof Error) {
|
|
58
|
+
this.error(`Failed to delete session: ${error.message}`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.error(`Failed to delete session: ${String(error)}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
2
|
+
export default class RunSessionsGet extends BaseRunCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
sessionId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static flags: {
|
|
7
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
static description: string;
|
|
11
|
+
static examples: string[];
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
3
|
+
export default class RunSessionsGet extends BaseRunCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
sessionId: Args.string({
|
|
6
|
+
description: 'Session ID',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static flags = {
|
|
11
|
+
...BaseRunCommand.baseFlags,
|
|
12
|
+
output: Flags.string({
|
|
13
|
+
char: 'o',
|
|
14
|
+
description: 'Output format',
|
|
15
|
+
required: false,
|
|
16
|
+
default: 'summary',
|
|
17
|
+
options: ['summary', 'json'],
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
static description = 'Get session details';
|
|
21
|
+
static examples = [
|
|
22
|
+
`$ xano run sessions get abc123-def456
|
|
23
|
+
Session Details:
|
|
24
|
+
ID: abc123-def456
|
|
25
|
+
Name: My Session
|
|
26
|
+
Status: running
|
|
27
|
+
Access: private
|
|
28
|
+
URL: https://session.xano.io/abc123
|
|
29
|
+
Uptime: 3600s
|
|
30
|
+
`,
|
|
31
|
+
`$ xano run sessions get abc123-def456 -o json
|
|
32
|
+
{ "id": "abc123-def456", "name": "My Session", "status": "running", ... }
|
|
33
|
+
`,
|
|
34
|
+
];
|
|
35
|
+
async run() {
|
|
36
|
+
const { args, flags } = await this.parse(RunSessionsGet);
|
|
37
|
+
// Initialize (no project required for session details)
|
|
38
|
+
await this.initRunCommand(flags.profile);
|
|
39
|
+
try {
|
|
40
|
+
const url = this.httpClient.buildSessionUrl(args.sessionId);
|
|
41
|
+
const session = await this.httpClient.get(url);
|
|
42
|
+
if (flags.output === 'json') {
|
|
43
|
+
this.outputJson(session);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.log('Session Details:');
|
|
47
|
+
this.log(` ID: ${session.id}`);
|
|
48
|
+
this.log(` Name: ${session.name}`);
|
|
49
|
+
this.log(` Status: ${session.status}`);
|
|
50
|
+
this.log(` Access: ${session.access}`);
|
|
51
|
+
if (session.url) {
|
|
52
|
+
this.log(` URL: ${session.url}`);
|
|
53
|
+
}
|
|
54
|
+
if (session.uptime !== null) {
|
|
55
|
+
this.log(` Uptime: ${session.uptime}s`);
|
|
56
|
+
}
|
|
57
|
+
this.log(` Created: ${session.createdAt}`);
|
|
58
|
+
if (session.projectId) {
|
|
59
|
+
this.log(` Project: ${session.projectId}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (error instanceof Error) {
|
|
65
|
+
this.error(`Failed to get session: ${error.message}`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.error(`Failed to get session: ${String(error)}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
2
|
+
export default class RunSessionsList extends BaseRunCommand {
|
|
3
|
+
static args: {};
|
|
4
|
+
static flags: {
|
|
5
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
};
|
|
8
|
+
static description: string;
|
|
9
|
+
static examples: string[];
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
private outputTable;
|
|
12
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
3
|
+
export default class RunSessionsList extends BaseRunCommand {
|
|
4
|
+
static args = {};
|
|
5
|
+
static flags = {
|
|
6
|
+
...BaseRunCommand.baseFlags,
|
|
7
|
+
output: Flags.string({
|
|
8
|
+
char: 'o',
|
|
9
|
+
description: 'Output format',
|
|
10
|
+
required: false,
|
|
11
|
+
default: 'table',
|
|
12
|
+
options: ['table', 'json'],
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
static description = 'List all sessions for the project';
|
|
16
|
+
static examples = [
|
|
17
|
+
`$ xano run sessions list
|
|
18
|
+
ID STATE CREATED
|
|
19
|
+
abc123-def456-ghi789 running 2024-01-15T10:30:00Z
|
|
20
|
+
xyz789-uvw456-rst123 stopped 2024-01-14T09:00:00Z
|
|
21
|
+
`,
|
|
22
|
+
`$ xano run sessions list -o json
|
|
23
|
+
{ "items": [{ "id": "abc123-def456-ghi789", "state": "running", ... }] }
|
|
24
|
+
`,
|
|
25
|
+
];
|
|
26
|
+
async run() {
|
|
27
|
+
const { flags } = await this.parse(RunSessionsList);
|
|
28
|
+
// Initialize with project required
|
|
29
|
+
await this.initRunCommandWithProject(flags.profile);
|
|
30
|
+
try {
|
|
31
|
+
const url = this.httpClient.buildProjectUrl('/run/session');
|
|
32
|
+
const result = await this.httpClient.get(url);
|
|
33
|
+
if (flags.output === 'json') {
|
|
34
|
+
this.outputJson(result);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.outputTable(result.items);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (error instanceof Error) {
|
|
42
|
+
this.error(`Failed to list sessions: ${error.message}`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.error(`Failed to list sessions: ${String(error)}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
outputTable(sessions) {
|
|
50
|
+
if (sessions.length === 0) {
|
|
51
|
+
this.log('No sessions found.');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// Print header
|
|
55
|
+
this.log('ID STATE CREATED');
|
|
56
|
+
this.log('-'.repeat(75));
|
|
57
|
+
for (const session of sessions) {
|
|
58
|
+
const id = session.id.padEnd(36);
|
|
59
|
+
const state = session.state.slice(0, 10).padEnd(10);
|
|
60
|
+
const created = session.created_at;
|
|
61
|
+
this.log(`${id} ${state} ${created}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
2
|
+
export default class RunSessionsStart extends BaseRunCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
sessionId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static flags: {
|
|
7
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
static description: string;
|
|
11
|
+
static examples: string[];
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
3
|
+
export default class RunSessionsStart extends BaseRunCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
sessionId: Args.string({
|
|
6
|
+
description: 'Session ID',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static flags = {
|
|
11
|
+
...BaseRunCommand.baseFlags,
|
|
12
|
+
output: Flags.string({
|
|
13
|
+
char: 'o',
|
|
14
|
+
description: 'Output format',
|
|
15
|
+
required: false,
|
|
16
|
+
default: 'summary',
|
|
17
|
+
options: ['summary', 'json'],
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
static description = 'Start a session';
|
|
21
|
+
static examples = [
|
|
22
|
+
`$ xano run sessions start abc123-def456
|
|
23
|
+
Session started successfully!
|
|
24
|
+
ID: abc123-def456
|
|
25
|
+
State: running
|
|
26
|
+
`,
|
|
27
|
+
`$ xano run sessions start abc123-def456 -o json
|
|
28
|
+
{ "id": "abc123-def456", "state": "running", ... }
|
|
29
|
+
`,
|
|
30
|
+
];
|
|
31
|
+
async run() {
|
|
32
|
+
const { args, flags } = await this.parse(RunSessionsStart);
|
|
33
|
+
// Initialize with project required
|
|
34
|
+
await this.initRunCommandWithProject(flags.profile);
|
|
35
|
+
try {
|
|
36
|
+
const url = this.httpClient.buildProjectUrl(`/run/session/${args.sessionId}/start`);
|
|
37
|
+
const session = await this.httpClient.post(url, {});
|
|
38
|
+
if (flags.output === 'json') {
|
|
39
|
+
this.outputJson(session);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.log('Session started successfully!');
|
|
43
|
+
this.log(` ID: ${session.id}`);
|
|
44
|
+
this.log(` State: ${session.state}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (error instanceof Error) {
|
|
49
|
+
this.error(`Failed to start session: ${error.message}`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
this.error(`Failed to start session: ${String(error)}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
2
|
+
export default class RunSessionsStop extends BaseRunCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
sessionId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static flags: {
|
|
7
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
static description: string;
|
|
11
|
+
static examples: string[];
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
3
|
+
export default class RunSessionsStop extends BaseRunCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
sessionId: Args.string({
|
|
6
|
+
description: 'Session ID',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static flags = {
|
|
11
|
+
...BaseRunCommand.baseFlags,
|
|
12
|
+
output: Flags.string({
|
|
13
|
+
char: 'o',
|
|
14
|
+
description: 'Output format',
|
|
15
|
+
required: false,
|
|
16
|
+
default: 'summary',
|
|
17
|
+
options: ['summary', 'json'],
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
static description = 'Stop a session';
|
|
21
|
+
static examples = [
|
|
22
|
+
`$ xano run sessions stop abc123-def456
|
|
23
|
+
Session stopped successfully!
|
|
24
|
+
ID: abc123-def456
|
|
25
|
+
State: stopped
|
|
26
|
+
`,
|
|
27
|
+
`$ xano run sessions stop abc123-def456 -o json
|
|
28
|
+
{ "id": "abc123-def456", "state": "stopped", ... }
|
|
29
|
+
`,
|
|
30
|
+
];
|
|
31
|
+
async run() {
|
|
32
|
+
const { args, flags } = await this.parse(RunSessionsStop);
|
|
33
|
+
// Initialize with project required
|
|
34
|
+
await this.initRunCommandWithProject(flags.profile);
|
|
35
|
+
try {
|
|
36
|
+
const url = this.httpClient.buildProjectUrl(`/run/session/${args.sessionId}/stop`);
|
|
37
|
+
const session = await this.httpClient.post(url, {});
|
|
38
|
+
if (flags.output === 'json') {
|
|
39
|
+
this.outputJson(session);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.log('Session stopped successfully!');
|
|
43
|
+
this.log(` ID: ${session.id}`);
|
|
44
|
+
this.log(` State: ${session.state}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (error instanceof Error) {
|
|
49
|
+
this.error(`Failed to stop session: ${error.message}`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
this.error(`Failed to stop session: ${String(error)}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
2
|
+
export default class RunSinkGet extends BaseRunCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
sessionId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static flags: {
|
|
7
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
static description: string;
|
|
11
|
+
static examples: string[];
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import BaseRunCommand from '../../../../lib/base-run-command.js';
|
|
3
|
+
export default class RunSinkGet extends BaseRunCommand {
|
|
4
|
+
static args = {
|
|
5
|
+
sessionId: Args.string({
|
|
6
|
+
description: 'Session ID',
|
|
7
|
+
required: true,
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
static flags = {
|
|
11
|
+
...BaseRunCommand.baseFlags,
|
|
12
|
+
output: Flags.string({
|
|
13
|
+
char: 'o',
|
|
14
|
+
description: 'Output format',
|
|
15
|
+
required: false,
|
|
16
|
+
default: 'summary',
|
|
17
|
+
options: ['summary', 'json'],
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
static description = 'Get sink data for a completed session';
|
|
21
|
+
static examples = [
|
|
22
|
+
`$ xano run sink get abc123-def456
|
|
23
|
+
Sink Data:
|
|
24
|
+
Tables: 3
|
|
25
|
+
- users (5 rows)
|
|
26
|
+
- orders (12 rows)
|
|
27
|
+
- products (8 rows)
|
|
28
|
+
Logs: 15 entries
|
|
29
|
+
`,
|
|
30
|
+
`$ xano run sink get abc123-def456 -o json
|
|
31
|
+
{ "tables": [...], "logs": [...] }
|
|
32
|
+
`,
|
|
33
|
+
];
|
|
34
|
+
async run() {
|
|
35
|
+
const { args, flags } = await this.parse(RunSinkGet);
|
|
36
|
+
// Initialize (no project required for sink data)
|
|
37
|
+
await this.initRunCommand(flags.profile);
|
|
38
|
+
try {
|
|
39
|
+
const url = this.httpClient.buildSessionUrl(args.sessionId, '/sink');
|
|
40
|
+
const sinkData = await this.httpClient.get(url);
|
|
41
|
+
if (flags.output === 'json') {
|
|
42
|
+
this.outputJson(sinkData);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.log('Sink Data:');
|
|
46
|
+
this.log(` Tables: ${sinkData.tables.length}`);
|
|
47
|
+
for (const table of sinkData.tables) {
|
|
48
|
+
const rowCount = table.content?.length || 0;
|
|
49
|
+
this.log(` - ${table.name} (${rowCount} rows)`);
|
|
50
|
+
}
|
|
51
|
+
this.log(` Logs: ${sinkData.logs.length} entries`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error instanceof Error) {
|
|
56
|
+
this.error(`Failed to get sink data: ${error.message}`);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this.error(`Failed to get sink data: ${String(error)}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base command for all run commands
|
|
3
|
+
*/
|
|
4
|
+
import BaseCommand from '../base-command.js';
|
|
5
|
+
import { RunHttpClient } from './run-http-client.js';
|
|
6
|
+
export interface ProfileConfig {
|
|
7
|
+
account_origin?: string;
|
|
8
|
+
instance_origin: string;
|
|
9
|
+
access_token: string;
|
|
10
|
+
workspace?: string;
|
|
11
|
+
branch?: string;
|
|
12
|
+
project?: string;
|
|
13
|
+
run_base_url?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface CredentialsFile {
|
|
16
|
+
profiles: {
|
|
17
|
+
[key: string]: ProfileConfig;
|
|
18
|
+
};
|
|
19
|
+
default?: string;
|
|
20
|
+
}
|
|
21
|
+
export default abstract class BaseRunCommand extends BaseCommand {
|
|
22
|
+
protected httpClient: RunHttpClient;
|
|
23
|
+
protected profile: ProfileConfig;
|
|
24
|
+
protected profileName: string;
|
|
25
|
+
/**
|
|
26
|
+
* Initialize the run command with profile and HTTP client
|
|
27
|
+
*/
|
|
28
|
+
protected initRunCommand(profileFlag?: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Initialize with project required
|
|
31
|
+
*/
|
|
32
|
+
protected initRunCommandWithProject(profileFlag?: string): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Load credentials from file
|
|
35
|
+
*/
|
|
36
|
+
protected loadCredentials(): CredentialsFile;
|
|
37
|
+
/**
|
|
38
|
+
* Format a response for JSON output
|
|
39
|
+
*/
|
|
40
|
+
protected outputJson(data: unknown): void;
|
|
41
|
+
}
|