@respan/cli 0.2.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/bin/dev.js +3 -0
- package/bin/run.js +10 -0
- package/dist/commands/auth/login.d.ts +14 -0
- package/dist/commands/auth/login.js +26 -0
- package/dist/commands/auth/logout.d.ts +12 -0
- package/dist/commands/auth/logout.js +18 -0
- package/dist/commands/auth/status.d.ts +12 -0
- package/dist/commands/auth/status.js +24 -0
- package/dist/commands/config/get.d.ts +15 -0
- package/dist/commands/config/get.js +15 -0
- package/dist/commands/config/list.d.ts +12 -0
- package/dist/commands/config/list.js +18 -0
- package/dist/commands/config/set.d.ts +16 -0
- package/dist/commands/config/set.js +18 -0
- package/dist/commands/datasets/add-spans.d.ts +16 -0
- package/dist/commands/datasets/add-spans.js +24 -0
- package/dist/commands/datasets/create-span.d.ts +16 -0
- package/dist/commands/datasets/create-span.js +36 -0
- package/dist/commands/datasets/create.d.ts +14 -0
- package/dist/commands/datasets/create.js +26 -0
- package/dist/commands/datasets/get-span.d.ts +16 -0
- package/dist/commands/datasets/get-span.js +23 -0
- package/dist/commands/datasets/get.d.ts +15 -0
- package/dist/commands/datasets/get.js +20 -0
- package/dist/commands/datasets/list.d.ts +14 -0
- package/dist/commands/datasets/list.js +23 -0
- package/dist/commands/datasets/spans.d.ts +15 -0
- package/dist/commands/datasets/spans.js +20 -0
- package/dist/commands/datasets/update.d.ts +17 -0
- package/dist/commands/datasets/update.js +32 -0
- package/dist/commands/evaluators/create.d.ts +16 -0
- package/dist/commands/evaluators/create.js +38 -0
- package/dist/commands/evaluators/get.d.ts +15 -0
- package/dist/commands/evaluators/get.js +20 -0
- package/dist/commands/evaluators/list.d.ts +14 -0
- package/dist/commands/evaluators/list.js +26 -0
- package/dist/commands/evaluators/run.d.ts +18 -0
- package/dist/commands/evaluators/run.js +41 -0
- package/dist/commands/evaluators/update.d.ts +18 -0
- package/dist/commands/evaluators/update.js +41 -0
- package/dist/commands/experiments/create.d.ts +16 -0
- package/dist/commands/experiments/create.js +39 -0
- package/dist/commands/experiments/get.d.ts +15 -0
- package/dist/commands/experiments/get.js +20 -0
- package/dist/commands/experiments/list.d.ts +14 -0
- package/dist/commands/experiments/list.js +23 -0
- package/dist/commands/logs/create.d.ts +16 -0
- package/dist/commands/logs/create.js +38 -0
- package/dist/commands/logs/get.d.ts +15 -0
- package/dist/commands/logs/get.js +20 -0
- package/dist/commands/logs/list.d.ts +18 -0
- package/dist/commands/logs/list.js +51 -0
- package/dist/commands/logs/summary.d.ts +14 -0
- package/dist/commands/logs/summary.js +23 -0
- package/dist/commands/prompts/create-version.d.ts +19 -0
- package/dist/commands/prompts/create-version.js +44 -0
- package/dist/commands/prompts/create.d.ts +14 -0
- package/dist/commands/prompts/create.js +26 -0
- package/dist/commands/prompts/get.d.ts +15 -0
- package/dist/commands/prompts/get.js +20 -0
- package/dist/commands/prompts/list.d.ts +13 -0
- package/dist/commands/prompts/list.js +22 -0
- package/dist/commands/prompts/update.d.ts +17 -0
- package/dist/commands/prompts/update.js +32 -0
- package/dist/commands/prompts/versions.d.ts +15 -0
- package/dist/commands/prompts/versions.js +20 -0
- package/dist/commands/traces/get.d.ts +15 -0
- package/dist/commands/traces/get.js +20 -0
- package/dist/commands/traces/list.d.ts +19 -0
- package/dist/commands/traces/list.js +47 -0
- package/dist/commands/traces/summary.d.ts +14 -0
- package/dist/commands/traces/summary.js +23 -0
- package/dist/commands/users/create.d.ts +16 -0
- package/dist/commands/users/create.js +38 -0
- package/dist/commands/users/get.d.ts +15 -0
- package/dist/commands/users/get.js +20 -0
- package/dist/commands/users/list.d.ts +16 -0
- package/dist/commands/users/list.js +38 -0
- package/dist/commands/users/update.d.ts +18 -0
- package/dist/commands/users/update.js +38 -0
- package/dist/commands/whoami.d.ts +12 -0
- package/dist/commands/whoami.js +21 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/auth.d.ts +16 -0
- package/dist/lib/auth.js +40 -0
- package/dist/lib/banner.d.ts +2 -0
- package/dist/lib/banner.js +117 -0
- package/dist/lib/base-command.d.ts +20 -0
- package/dist/lib/base-command.js +74 -0
- package/dist/lib/config.d.ts +26 -0
- package/dist/lib/config.js +81 -0
- package/dist/lib/output.d.ts +6 -0
- package/dist/lib/output.js +95 -0
- package/dist/lib/pagination.d.ts +12 -0
- package/dist/lib/pagination.js +34 -0
- package/dist/lib/spinner.d.ts +11 -0
- package/dist/lib/spinner.js +56 -0
- package/oclif.manifest.json +2886 -0
- package/package.json +52 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
3
|
+
class PromptsCreateVersion extends BaseCommand {
|
|
4
|
+
async run() {
|
|
5
|
+
const { args, flags } = await this.parse(PromptsCreateVersion);
|
|
6
|
+
this.globalFlags = flags;
|
|
7
|
+
try {
|
|
8
|
+
const client = this.getClient();
|
|
9
|
+
let messages;
|
|
10
|
+
try {
|
|
11
|
+
messages = JSON.parse(flags.messages);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
this.error('Invalid JSON for --messages');
|
|
15
|
+
}
|
|
16
|
+
// createVersion requires prompt_id, messages (string[]), and model (required)
|
|
17
|
+
const messagesStr = Array.isArray(messages) ? messages.map((m) => typeof m === 'string' ? m : JSON.stringify(m)) : [String(messages)];
|
|
18
|
+
const createBody = {
|
|
19
|
+
prompt_id: args['prompt-id'],
|
|
20
|
+
messages: messagesStr,
|
|
21
|
+
model: flags.model || 'gpt-4o',
|
|
22
|
+
};
|
|
23
|
+
if (flags.temperature)
|
|
24
|
+
createBody.temperature = parseFloat(flags.temperature);
|
|
25
|
+
if (flags['max-tokens'])
|
|
26
|
+
createBody.max_tokens = flags['max-tokens'];
|
|
27
|
+
const data = await this.spin('Creating prompt version', () => client.prompts.createVersion(createBody));
|
|
28
|
+
this.log(JSON.stringify(data, null, 2));
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
this.handleError(error);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
PromptsCreateVersion.description = 'Create a new version of a prompt';
|
|
36
|
+
PromptsCreateVersion.args = { 'prompt-id': Args.string({ description: 'Prompt ID', required: true }) };
|
|
37
|
+
PromptsCreateVersion.flags = {
|
|
38
|
+
...BaseCommand.baseFlags,
|
|
39
|
+
messages: Flags.string({ description: 'Messages as JSON array string', required: true }),
|
|
40
|
+
model: Flags.string({ description: 'Model name' }),
|
|
41
|
+
temperature: Flags.string({ description: 'Temperature value' }),
|
|
42
|
+
'max-tokens': Flags.integer({ description: 'Max tokens' }),
|
|
43
|
+
};
|
|
44
|
+
export default PromptsCreateVersion;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
|
+
export default class PromptsCreate extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
3
|
+
class PromptsCreate extends BaseCommand {
|
|
4
|
+
async run() {
|
|
5
|
+
const { flags } = await this.parse(PromptsCreate);
|
|
6
|
+
this.globalFlags = flags;
|
|
7
|
+
try {
|
|
8
|
+
const client = this.getClient();
|
|
9
|
+
const body = { name: flags.name };
|
|
10
|
+
if (flags.description)
|
|
11
|
+
body.description = flags.description;
|
|
12
|
+
const data = await this.spin('Creating prompt', () => client.prompts.createPrompt(body));
|
|
13
|
+
this.log(JSON.stringify(data, null, 2));
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
this.handleError(error);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
PromptsCreate.description = 'Create a new prompt';
|
|
21
|
+
PromptsCreate.flags = {
|
|
22
|
+
...BaseCommand.baseFlags,
|
|
23
|
+
name: Flags.string({ description: 'Prompt name', required: true }),
|
|
24
|
+
description: Flags.string({ description: 'Prompt description' }),
|
|
25
|
+
};
|
|
26
|
+
export default PromptsCreate;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
|
+
export default class PromptsGet extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
static flags: {
|
|
8
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
3
|
+
class PromptsGet extends BaseCommand {
|
|
4
|
+
async run() {
|
|
5
|
+
const { args, flags } = await this.parse(PromptsGet);
|
|
6
|
+
this.globalFlags = flags;
|
|
7
|
+
try {
|
|
8
|
+
const client = this.getClient();
|
|
9
|
+
const data = await this.spin('Fetching prompt', () => client.prompts.retrievePrompts({ prompt_id: args.id }));
|
|
10
|
+
this.log(JSON.stringify(data, null, 2));
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
this.handleError(error);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
PromptsGet.description = 'Get a specific prompt';
|
|
18
|
+
PromptsGet.args = { id: Args.string({ description: 'Prompt ID', required: true }) };
|
|
19
|
+
PromptsGet.flags = { ...BaseCommand.baseFlags };
|
|
20
|
+
export default PromptsGet;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
|
+
export default class PromptsList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
3
|
+
class PromptsList extends BaseCommand {
|
|
4
|
+
async run() {
|
|
5
|
+
const { flags } = await this.parse(PromptsList);
|
|
6
|
+
this.globalFlags = flags;
|
|
7
|
+
try {
|
|
8
|
+
const client = this.getClient();
|
|
9
|
+
const data = await this.spin('Fetching prompts', () => client.prompts.retrievePrompts());
|
|
10
|
+
this.outputResult(data, ['id', 'name', 'description', 'is_active', 'current_version', 'updated_at']);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
this.handleError(error);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
PromptsList.description = 'List prompts';
|
|
18
|
+
PromptsList.flags = {
|
|
19
|
+
...BaseCommand.baseFlags,
|
|
20
|
+
limit: Flags.integer({ description: 'Number of results per page', default: 50 }),
|
|
21
|
+
};
|
|
22
|
+
export default PromptsList;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
|
+
export default class PromptsUpdate extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
static flags: {
|
|
8
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
3
|
+
class PromptsUpdate extends BaseCommand {
|
|
4
|
+
async run() {
|
|
5
|
+
const { args, flags } = await this.parse(PromptsUpdate);
|
|
6
|
+
this.globalFlags = flags;
|
|
7
|
+
try {
|
|
8
|
+
const client = this.getClient();
|
|
9
|
+
const updateBody = {};
|
|
10
|
+
if (flags.name)
|
|
11
|
+
updateBody.name = flags.name;
|
|
12
|
+
if (flags.description)
|
|
13
|
+
updateBody.description = flags.description;
|
|
14
|
+
const data = await this.spin('Updating prompt', () => client.prompts.updatePrompt({
|
|
15
|
+
prompt_id: args.id,
|
|
16
|
+
body: updateBody,
|
|
17
|
+
}));
|
|
18
|
+
this.log(JSON.stringify(data, null, 2));
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
this.handleError(error);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
PromptsUpdate.description = 'Update a prompt';
|
|
26
|
+
PromptsUpdate.args = { id: Args.string({ description: 'Prompt ID', required: true }) };
|
|
27
|
+
PromptsUpdate.flags = {
|
|
28
|
+
...BaseCommand.baseFlags,
|
|
29
|
+
name: Flags.string({ description: 'Prompt name' }),
|
|
30
|
+
description: Flags.string({ description: 'Prompt description' }),
|
|
31
|
+
};
|
|
32
|
+
export default PromptsUpdate;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
|
+
export default class PromptsVersions extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
'prompt-id': import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
static flags: {
|
|
8
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
3
|
+
class PromptsVersions extends BaseCommand {
|
|
4
|
+
async run() {
|
|
5
|
+
const { args, flags } = await this.parse(PromptsVersions);
|
|
6
|
+
this.globalFlags = flags;
|
|
7
|
+
try {
|
|
8
|
+
const client = this.getClient();
|
|
9
|
+
const data = await this.spin('Fetching prompt versions', () => client.prompts.retrieveVersions({ prompt_id: args['prompt-id'] }));
|
|
10
|
+
this.outputResult(data, ['id', 'version', 'is_active', 'created_at']);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
this.handleError(error);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
PromptsVersions.description = 'List versions of a prompt';
|
|
18
|
+
PromptsVersions.args = { 'prompt-id': Args.string({ description: 'Prompt ID', required: true }) };
|
|
19
|
+
PromptsVersions.flags = { ...BaseCommand.baseFlags };
|
|
20
|
+
export default PromptsVersions;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
|
+
export default class TracesGet extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
static flags: {
|
|
8
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
3
|
+
class TracesGet extends BaseCommand {
|
|
4
|
+
async run() {
|
|
5
|
+
const { args, flags } = await this.parse(TracesGet);
|
|
6
|
+
this.globalFlags = flags;
|
|
7
|
+
try {
|
|
8
|
+
const client = this.getClient();
|
|
9
|
+
const data = await this.spin('Fetching trace', () => client.traces.retrieveTrace({ trace_unique_id: args.id }));
|
|
10
|
+
this.log(JSON.stringify(data, null, 2));
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
this.handleError(error);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
TracesGet.description = 'Get a specific trace';
|
|
18
|
+
TracesGet.args = { id: Args.string({ description: 'Trace ID', required: true }) };
|
|
19
|
+
TracesGet.flags = { ...BaseCommand.baseFlags };
|
|
20
|
+
export default TracesGet;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
|
+
export default class TracesList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'sort-by': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
'start-time': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'end-time': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
environment: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
filter: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
};
|
|
18
|
+
run(): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
3
|
+
import { extractPagination, formatPaginationInfo } from '../../lib/pagination.js';
|
|
4
|
+
class TracesList extends BaseCommand {
|
|
5
|
+
async run() {
|
|
6
|
+
const { flags } = await this.parse(TracesList);
|
|
7
|
+
this.globalFlags = flags;
|
|
8
|
+
try {
|
|
9
|
+
const client = this.getClient();
|
|
10
|
+
const params = {
|
|
11
|
+
page_size: flags.limit,
|
|
12
|
+
page: flags.page,
|
|
13
|
+
};
|
|
14
|
+
if (flags['sort-by'])
|
|
15
|
+
params.sort_by = flags['sort-by'];
|
|
16
|
+
if (flags['start-time'])
|
|
17
|
+
params.start_time = flags['start-time'];
|
|
18
|
+
if (flags['end-time'])
|
|
19
|
+
params.end_time = flags['end-time'];
|
|
20
|
+
if (flags.environment)
|
|
21
|
+
params.environment = flags.environment;
|
|
22
|
+
if (flags.filter && flags.filter.length > 0)
|
|
23
|
+
params.filters = flags.filter;
|
|
24
|
+
const data = await this.spin('Fetching traces', () => client.traces.list(params));
|
|
25
|
+
this.outputResult(data, [
|
|
26
|
+
'trace_unique_id', 'name', 'duration', 'span_count', 'total_cost', 'error_count', 'start_time',
|
|
27
|
+
]);
|
|
28
|
+
const pagination = extractPagination(data, flags.page);
|
|
29
|
+
this.log(formatPaginationInfo(pagination));
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
this.handleError(error);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
TracesList.description = 'List traces';
|
|
37
|
+
TracesList.flags = {
|
|
38
|
+
...BaseCommand.baseFlags,
|
|
39
|
+
limit: Flags.integer({ description: 'Number of results per page', default: 10 }),
|
|
40
|
+
page: Flags.integer({ description: 'Page number', default: 1 }),
|
|
41
|
+
'sort-by': Flags.string({ description: 'Sort field', default: '-timestamp' }),
|
|
42
|
+
'start-time': Flags.string({ description: 'Start time filter (ISO 8601)' }),
|
|
43
|
+
'end-time': Flags.string({ description: 'End time filter (ISO 8601)' }),
|
|
44
|
+
environment: Flags.string({ description: 'Environment filter' }),
|
|
45
|
+
filter: Flags.string({ description: 'Filter expression', multiple: true }),
|
|
46
|
+
};
|
|
47
|
+
export default TracesList;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
|
+
export default class TracesSummary extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
'start-time': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
'end-time': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
3
|
+
class TracesSummary extends BaseCommand {
|
|
4
|
+
async run() {
|
|
5
|
+
const { flags } = await this.parse(TracesSummary);
|
|
6
|
+
this.globalFlags = flags;
|
|
7
|
+
try {
|
|
8
|
+
const client = this.getClient();
|
|
9
|
+
const data = await this.spin('Fetching traces summary', () => client.traces.retrieveTracesSummary({ start_time: flags['start-time'], end_time: flags['end-time'] }));
|
|
10
|
+
this.log(JSON.stringify(data, null, 2));
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
this.handleError(error);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
TracesSummary.description = 'Get a summary of traces for a time range';
|
|
18
|
+
TracesSummary.flags = {
|
|
19
|
+
...BaseCommand.baseFlags,
|
|
20
|
+
'start-time': Flags.string({ description: 'Start time (ISO 8601)', required: true }),
|
|
21
|
+
'end-time': Flags.string({ description: 'End time (ISO 8601)', required: true }),
|
|
22
|
+
};
|
|
23
|
+
export default TracesSummary;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
|
+
export default class UsersCreate extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
identifier: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
email: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
metadata: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'api-key': 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
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
3
|
+
class UsersCreate extends BaseCommand {
|
|
4
|
+
async run() {
|
|
5
|
+
const { flags } = await this.parse(UsersCreate);
|
|
6
|
+
this.globalFlags = flags;
|
|
7
|
+
try {
|
|
8
|
+
const client = this.getClient();
|
|
9
|
+
const body = { customer_identifier: flags.identifier };
|
|
10
|
+
if (flags.name)
|
|
11
|
+
body.name = flags.name;
|
|
12
|
+
if (flags.email)
|
|
13
|
+
body.email = flags.email;
|
|
14
|
+
if (flags.metadata) {
|
|
15
|
+
try {
|
|
16
|
+
body.metadata = JSON.parse(flags.metadata);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
this.error('Invalid JSON for --metadata');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const data = await this.spin('Creating user', () => client.users.updateUser(body));
|
|
23
|
+
this.log(JSON.stringify(data, null, 2));
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
this.handleError(error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
UsersCreate.description = 'Create a new user (customer)';
|
|
31
|
+
UsersCreate.flags = {
|
|
32
|
+
...BaseCommand.baseFlags,
|
|
33
|
+
identifier: Flags.string({ description: 'Customer identifier', required: true }),
|
|
34
|
+
name: Flags.string({ description: 'Customer name' }),
|
|
35
|
+
email: Flags.string({ description: 'Customer email' }),
|
|
36
|
+
metadata: Flags.string({ description: 'Metadata as JSON string' }),
|
|
37
|
+
};
|
|
38
|
+
export default UsersCreate;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
|
+
export default class UsersGet extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
static flags: {
|
|
8
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
3
|
+
class UsersGet extends BaseCommand {
|
|
4
|
+
async run() {
|
|
5
|
+
const { args, flags } = await this.parse(UsersGet);
|
|
6
|
+
this.globalFlags = flags;
|
|
7
|
+
try {
|
|
8
|
+
const client = this.getClient();
|
|
9
|
+
const data = await this.spin('Fetching user', () => client.users.retrieveUser({ customer_identifier: args.id }));
|
|
10
|
+
this.log(JSON.stringify(data, null, 2));
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
this.handleError(error);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
UsersGet.description = 'Get a specific user (customer)';
|
|
18
|
+
UsersGet.args = { id: Args.string({ description: 'Customer identifier', required: true }) };
|
|
19
|
+
UsersGet.flags = { ...BaseCommand.baseFlags };
|
|
20
|
+
export default UsersGet;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
|
+
export default class UsersList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'sort-by': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
environment: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'api-key': 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
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
3
|
+
import { extractPagination, formatPaginationInfo } from '../../lib/pagination.js';
|
|
4
|
+
class UsersList extends BaseCommand {
|
|
5
|
+
async run() {
|
|
6
|
+
const { flags } = await this.parse(UsersList);
|
|
7
|
+
this.globalFlags = flags;
|
|
8
|
+
try {
|
|
9
|
+
const client = this.getClient();
|
|
10
|
+
const params = {
|
|
11
|
+
page_size: flags.limit,
|
|
12
|
+
page: flags.page,
|
|
13
|
+
};
|
|
14
|
+
if (flags['sort-by'])
|
|
15
|
+
params.sort_by = flags['sort-by'];
|
|
16
|
+
if (flags.environment)
|
|
17
|
+
params.environment = flags.environment;
|
|
18
|
+
const data = await this.spin('Fetching users', () => client.users.list(params));
|
|
19
|
+
this.outputResult(data, [
|
|
20
|
+
'customer_identifier', 'name', 'email', 'number_of_requests', 'total_cost', 'last_active_timeframe',
|
|
21
|
+
]);
|
|
22
|
+
const pagination = extractPagination(data, flags.page);
|
|
23
|
+
this.log(formatPaginationInfo(pagination));
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
this.handleError(error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
UsersList.description = 'List users (customers)';
|
|
31
|
+
UsersList.flags = {
|
|
32
|
+
...BaseCommand.baseFlags,
|
|
33
|
+
limit: Flags.integer({ description: 'Number of results per page', default: 20 }),
|
|
34
|
+
page: Flags.integer({ description: 'Page number', default: 1 }),
|
|
35
|
+
'sort-by': Flags.string({ description: 'Sort field' }),
|
|
36
|
+
environment: Flags.string({ description: 'Environment filter' }),
|
|
37
|
+
};
|
|
38
|
+
export default UsersList;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
2
|
+
export default class UsersUpdate extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
static flags: {
|
|
8
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
email: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
metadata: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
3
|
+
class UsersUpdate extends BaseCommand {
|
|
4
|
+
async run() {
|
|
5
|
+
const { args, flags } = await this.parse(UsersUpdate);
|
|
6
|
+
this.globalFlags = flags;
|
|
7
|
+
try {
|
|
8
|
+
const client = this.getClient();
|
|
9
|
+
const body = { customer_identifier: args.id };
|
|
10
|
+
if (flags.name)
|
|
11
|
+
body.name = flags.name;
|
|
12
|
+
if (flags.email)
|
|
13
|
+
body.email = flags.email;
|
|
14
|
+
if (flags.metadata) {
|
|
15
|
+
try {
|
|
16
|
+
body.metadata = JSON.parse(flags.metadata);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
this.error('Invalid JSON for --metadata');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const data = await this.spin('Updating user', () => client.users.updateUser(body));
|
|
23
|
+
this.log(JSON.stringify(data, null, 2));
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
this.handleError(error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
UsersUpdate.description = 'Update a user (customer)';
|
|
31
|
+
UsersUpdate.args = { id: Args.string({ description: 'Customer identifier', required: true }) };
|
|
32
|
+
UsersUpdate.flags = {
|
|
33
|
+
...BaseCommand.baseFlags,
|
|
34
|
+
name: Flags.string({ description: 'Customer name' }),
|
|
35
|
+
email: Flags.string({ description: 'Customer email' }),
|
|
36
|
+
metadata: Flags.string({ description: 'Metadata as JSON string' }),
|
|
37
|
+
};
|
|
38
|
+
export default UsersUpdate;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommand } from '../lib/base-command.js';
|
|
2
|
+
export default class Whoami extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|