@wavyx/pdcli 0.2.0 → 0.3.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/CHANGELOG.md +15 -0
- package/README.md +16 -2
- package/oclif.manifest.json +5232 -768
- package/package.json +3 -1
- package/src/base-command.js +30 -2
- package/src/commands/api.js +6 -2
- package/src/commands/backup.js +53 -0
- package/src/commands/file/download.js +35 -0
- package/src/commands/file/get.js +26 -0
- package/src/commands/file/list.js +40 -0
- package/src/commands/file/upload.js +42 -0
- package/src/commands/filter/get.js +26 -0
- package/src/commands/filter/list.js +43 -0
- package/src/commands/goal/list.js +37 -0
- package/src/commands/lead/create.js +58 -0
- package/src/commands/lead/delete.js +39 -0
- package/src/commands/lead/get.js +26 -0
- package/src/commands/lead/list.js +50 -0
- package/src/commands/lead/update.js +71 -0
- package/src/commands/note/create.js +42 -0
- package/src/commands/note/delete.js +39 -0
- package/src/commands/note/get.js +26 -0
- package/src/commands/note/list.js +49 -0
- package/src/commands/note/update.js +45 -0
- package/src/commands/pipeline/get.js +26 -0
- package/src/commands/pipeline/list.js +37 -0
- package/src/commands/project/create.js +48 -0
- package/src/commands/project/delete.js +39 -0
- package/src/commands/project/get.js +26 -0
- package/src/commands/project/list.js +39 -0
- package/src/commands/project/update.js +63 -0
- package/src/commands/stage/get.js +26 -0
- package/src/commands/stage/list.js +41 -0
- package/src/commands/webhook/create.js +75 -0
- package/src/commands/webhook/delete.js +39 -0
- package/src/commands/webhook/list.js +33 -0
- package/src/lib/backup.js +122 -0
- package/src/lib/client.js +67 -0
- package/src/lib/entity-view.js +7 -2
- package/src/lib/output/csv.js +26 -0
- package/src/lib/output/index.js +9 -1
- package/src/lib/output/yaml.js +9 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core'
|
|
2
|
+
import chalk from 'chalk'
|
|
3
|
+
import BaseCommand from '../../base-command.js'
|
|
4
|
+
import { confirmAction } from '../../lib/confirm.js'
|
|
5
|
+
import { CliError } from '../../lib/errors.js'
|
|
6
|
+
|
|
7
|
+
export default class NoteDeleteCommand extends BaseCommand {
|
|
8
|
+
static description = 'Delete a note'
|
|
9
|
+
|
|
10
|
+
static examples = [
|
|
11
|
+
'<%= config.bin %> note delete 5',
|
|
12
|
+
'<%= config.bin %> note delete 5 --yes',
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
static args = {
|
|
16
|
+
id: Args.integer({ required: true, description: 'Note ID' }),
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static flags = {
|
|
20
|
+
...BaseCommand.baseFlags,
|
|
21
|
+
yes: Flags.boolean({
|
|
22
|
+
char: 'y',
|
|
23
|
+
description: 'Skip the confirmation prompt',
|
|
24
|
+
default: false,
|
|
25
|
+
}),
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async run() {
|
|
29
|
+
const { args, flags } = await this.parse(NoteDeleteCommand)
|
|
30
|
+
|
|
31
|
+
const ok = await confirmAction(`Delete note ${args.id}?`, flags.yes)
|
|
32
|
+
if (!ok) {
|
|
33
|
+
throw new CliError('Aborted', { exitCode: 1 })
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
await this.apiClient.del(`/api/v1/notes/${args.id}`)
|
|
37
|
+
this.log(chalk.green(`Deleted note ${args.id}`))
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Args } from '@oclif/core'
|
|
2
|
+
import BaseCommand from '../../base-command.js'
|
|
3
|
+
import { outputRecord } from '../../lib/entity-view.js'
|
|
4
|
+
|
|
5
|
+
export default class NoteGetCommand extends BaseCommand {
|
|
6
|
+
static description = 'Get a note by ID'
|
|
7
|
+
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> note get 5',
|
|
10
|
+
'<%= config.bin %> note get 5 --output json',
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
static flags = {
|
|
14
|
+
...BaseCommand.baseFlags,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static args = {
|
|
18
|
+
id: Args.integer({ required: true, description: 'Note ID' }),
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async run() {
|
|
22
|
+
const { args } = await this.parse(NoteGetCommand)
|
|
23
|
+
const body = await this.apiClient.get(`/api/v1/notes/${args.id}`)
|
|
24
|
+
await outputRecord(this, body.data)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core'
|
|
2
|
+
import BaseCommand from '../../base-command.js'
|
|
3
|
+
import { collectPages } from '../../lib/pagination.js'
|
|
4
|
+
|
|
5
|
+
const columns = {
|
|
6
|
+
id: { header: 'ID' },
|
|
7
|
+
content: {
|
|
8
|
+
header: 'Content',
|
|
9
|
+
get: (row) => (row.content ?? '').slice(0, 60),
|
|
10
|
+
},
|
|
11
|
+
deal_id: { header: 'Deal' },
|
|
12
|
+
person_id: { header: 'Person' },
|
|
13
|
+
org_id: { header: 'Org' },
|
|
14
|
+
add_time: { header: 'Created' },
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default class NoteListCommand extends BaseCommand {
|
|
18
|
+
static description = 'List notes'
|
|
19
|
+
|
|
20
|
+
static examples = [
|
|
21
|
+
'<%= config.bin %> note list',
|
|
22
|
+
'<%= config.bin %> note list --deal 42 --output json',
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
static flags = {
|
|
26
|
+
...BaseCommand.baseFlags,
|
|
27
|
+
deal: Flags.integer({ description: 'Filter by deal ID' }),
|
|
28
|
+
person: Flags.integer({ description: 'Filter by person ID' }),
|
|
29
|
+
org: Flags.integer({ description: 'Filter by organization ID' }),
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async run() {
|
|
33
|
+
const { flags } = await this.parse(NoteListCommand)
|
|
34
|
+
const limit = flags.limit ?? 100
|
|
35
|
+
|
|
36
|
+
const query = {
|
|
37
|
+
deal_id: flags.deal,
|
|
38
|
+
person_id: flags.person,
|
|
39
|
+
org_id: flags.org,
|
|
40
|
+
limit: Math.min(limit, 100),
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const items = await collectPages(
|
|
44
|
+
this.apiClient.pageV1('/api/v1/notes', query),
|
|
45
|
+
limit,
|
|
46
|
+
)
|
|
47
|
+
await this.outputResults(items, columns)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core'
|
|
2
|
+
import BaseCommand from '../../base-command.js'
|
|
3
|
+
import { buildWriteBody } from '../../lib/input.js'
|
|
4
|
+
import { outputRecord } from '../../lib/entity-view.js'
|
|
5
|
+
import { CliError } from '../../lib/errors.js'
|
|
6
|
+
|
|
7
|
+
export default class NoteUpdateCommand extends BaseCommand {
|
|
8
|
+
static description = 'Update a note (only provided fields change)'
|
|
9
|
+
|
|
10
|
+
static examples = [
|
|
11
|
+
'<%= config.bin %> note update 5 --content "Revised note"',
|
|
12
|
+
'<%= config.bin %> note update 5 --body \'{"pinned_to_deal_flag":1}\'',
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
static args = {
|
|
16
|
+
id: Args.integer({ required: true, description: 'Note ID' }),
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static flags = {
|
|
20
|
+
...BaseCommand.baseFlags,
|
|
21
|
+
content: Flags.string({ description: 'Note content' }),
|
|
22
|
+
body: Flags.string({ description: 'Raw JSON body to merge (flags win)' }),
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async run() {
|
|
26
|
+
const { args, flags } = await this.parse(NoteUpdateCommand)
|
|
27
|
+
|
|
28
|
+
const body = buildWriteBody({
|
|
29
|
+
typed: {
|
|
30
|
+
content: flags.content,
|
|
31
|
+
},
|
|
32
|
+
rawBody: flags.body,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
if (Object.keys(body).length === 0) {
|
|
36
|
+
throw new CliError(
|
|
37
|
+
'Nothing to update — pass at least one field flag, --field, or --body',
|
|
38
|
+
{ exitCode: 64 },
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const res = await this.apiClient.put(`/api/v1/notes/${args.id}`, { body })
|
|
43
|
+
await outputRecord(this, res.data)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Args } from '@oclif/core'
|
|
2
|
+
import BaseCommand from '../../base-command.js'
|
|
3
|
+
import { outputRecord } from '../../lib/entity-view.js'
|
|
4
|
+
|
|
5
|
+
export default class PipelineGetCommand extends BaseCommand {
|
|
6
|
+
static description = 'Get a pipeline by ID'
|
|
7
|
+
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> pipeline get 1',
|
|
10
|
+
'<%= config.bin %> pipeline get 1 --output json',
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
static flags = {
|
|
14
|
+
...BaseCommand.baseFlags,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static args = {
|
|
18
|
+
id: Args.integer({ required: true, description: 'Pipeline ID' }),
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async run() {
|
|
22
|
+
const { args } = await this.parse(PipelineGetCommand)
|
|
23
|
+
const body = await this.apiClient.get(`/api/v2/pipelines/${args.id}`)
|
|
24
|
+
await outputRecord(this, body.data)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import BaseCommand from '../../base-command.js'
|
|
2
|
+
import { collectPages } from '../../lib/pagination.js'
|
|
3
|
+
|
|
4
|
+
const columns = {
|
|
5
|
+
id: { header: 'ID' },
|
|
6
|
+
name: { header: 'Name' },
|
|
7
|
+
is_deal_probability_enabled: { header: 'Probability' },
|
|
8
|
+
order_nr: { header: 'Order' },
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default class PipelineListCommand extends BaseCommand {
|
|
12
|
+
static description = 'List pipelines'
|
|
13
|
+
|
|
14
|
+
static examples = [
|
|
15
|
+
'<%= config.bin %> pipeline list',
|
|
16
|
+
'<%= config.bin %> pipeline list --output json',
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
static flags = {
|
|
20
|
+
...BaseCommand.baseFlags,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async run() {
|
|
24
|
+
const { flags } = await this.parse(PipelineListCommand)
|
|
25
|
+
const limit = flags.limit ?? 100
|
|
26
|
+
|
|
27
|
+
const query = {
|
|
28
|
+
limit: Math.min(limit, 100),
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const items = await collectPages(
|
|
32
|
+
this.apiClient.pageV2('/api/v2/pipelines', query),
|
|
33
|
+
limit,
|
|
34
|
+
)
|
|
35
|
+
await this.outputResults(items, columns)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core'
|
|
2
|
+
import BaseCommand from '../../base-command.js'
|
|
3
|
+
import { buildWriteBody } from '../../lib/input.js'
|
|
4
|
+
import { outputRecord } from '../../lib/entity-view.js'
|
|
5
|
+
|
|
6
|
+
export default class ProjectCreateCommand extends BaseCommand {
|
|
7
|
+
static description = 'Create a project'
|
|
8
|
+
|
|
9
|
+
static examples = [
|
|
10
|
+
'<%= config.bin %> project create --title "Launch"',
|
|
11
|
+
'<%= config.bin %> project create --title "Launch" --owner 3 --status open',
|
|
12
|
+
'<%= config.bin %> project create --title "Raw" --body \'{"deal_ids":[1,2]}\'',
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
static flags = {
|
|
16
|
+
...BaseCommand.baseFlags,
|
|
17
|
+
title: Flags.string({ required: true, description: 'Project title' }),
|
|
18
|
+
description: Flags.string({ description: 'Project description' }),
|
|
19
|
+
status: Flags.string({ description: 'Project status' }),
|
|
20
|
+
'start-date': Flags.string({ description: 'Start date (YYYY-MM-DD)' }),
|
|
21
|
+
'end-date': Flags.string({ description: 'End date (YYYY-MM-DD)' }),
|
|
22
|
+
owner: Flags.integer({ description: 'Owner (user) ID' }),
|
|
23
|
+
board: Flags.integer({ description: 'Board ID' }),
|
|
24
|
+
phase: Flags.integer({ description: 'Phase ID' }),
|
|
25
|
+
body: Flags.string({ description: 'Raw JSON body to merge (flags win)' }),
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async run() {
|
|
29
|
+
const { flags } = await this.parse(ProjectCreateCommand)
|
|
30
|
+
|
|
31
|
+
const body = buildWriteBody({
|
|
32
|
+
typed: {
|
|
33
|
+
title: flags.title,
|
|
34
|
+
description: flags.description,
|
|
35
|
+
status: flags.status,
|
|
36
|
+
start_date: flags['start-date'],
|
|
37
|
+
end_date: flags['end-date'],
|
|
38
|
+
owner_id: flags.owner,
|
|
39
|
+
board_id: flags.board,
|
|
40
|
+
phase_id: flags.phase,
|
|
41
|
+
},
|
|
42
|
+
rawBody: flags.body,
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const res = await this.apiClient.post('/api/v2/projects', { body })
|
|
46
|
+
await outputRecord(this, res.data)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core'
|
|
2
|
+
import chalk from 'chalk'
|
|
3
|
+
import BaseCommand from '../../base-command.js'
|
|
4
|
+
import { confirmAction } from '../../lib/confirm.js'
|
|
5
|
+
import { CliError } from '../../lib/errors.js'
|
|
6
|
+
|
|
7
|
+
export default class ProjectDeleteCommand extends BaseCommand {
|
|
8
|
+
static description = 'Delete a project'
|
|
9
|
+
|
|
10
|
+
static examples = [
|
|
11
|
+
'<%= config.bin %> project delete 7',
|
|
12
|
+
'<%= config.bin %> project delete 7 --yes',
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
static args = {
|
|
16
|
+
id: Args.integer({ required: true, description: 'Project ID' }),
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static flags = {
|
|
20
|
+
...BaseCommand.baseFlags,
|
|
21
|
+
yes: Flags.boolean({
|
|
22
|
+
char: 'y',
|
|
23
|
+
description: 'Skip the confirmation prompt',
|
|
24
|
+
default: false,
|
|
25
|
+
}),
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async run() {
|
|
29
|
+
const { args, flags } = await this.parse(ProjectDeleteCommand)
|
|
30
|
+
|
|
31
|
+
const ok = await confirmAction(`Delete project ${args.id}?`, flags.yes)
|
|
32
|
+
if (!ok) {
|
|
33
|
+
throw new CliError('Aborted', { exitCode: 1 })
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
await this.apiClient.del(`/api/v2/projects/${args.id}`)
|
|
37
|
+
this.log(chalk.green(`Deleted project ${args.id}`))
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Args } from '@oclif/core'
|
|
2
|
+
import BaseCommand from '../../base-command.js'
|
|
3
|
+
import { outputRecord } from '../../lib/entity-view.js'
|
|
4
|
+
|
|
5
|
+
export default class ProjectGetCommand extends BaseCommand {
|
|
6
|
+
static description = 'Get a project by ID'
|
|
7
|
+
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> project get 3',
|
|
10
|
+
'<%= config.bin %> project get 3 --output json',
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
static flags = {
|
|
14
|
+
...BaseCommand.baseFlags,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static args = {
|
|
18
|
+
id: Args.integer({ required: true, description: 'Project ID' }),
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async run() {
|
|
22
|
+
const { args } = await this.parse(ProjectGetCommand)
|
|
23
|
+
const body = await this.apiClient.get(`/api/v2/projects/${args.id}`)
|
|
24
|
+
await outputRecord(this, body.data)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import BaseCommand from '../../base-command.js'
|
|
2
|
+
import { collectPages } from '../../lib/pagination.js'
|
|
3
|
+
|
|
4
|
+
const columns = {
|
|
5
|
+
id: { header: 'ID' },
|
|
6
|
+
title: { header: 'Title' },
|
|
7
|
+
status: { header: 'Status' },
|
|
8
|
+
owner_id: { header: 'Owner' },
|
|
9
|
+
start_date: { header: 'Start' },
|
|
10
|
+
end_date: { header: 'End' },
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default class ProjectListCommand extends BaseCommand {
|
|
14
|
+
static description = 'List projects'
|
|
15
|
+
|
|
16
|
+
static examples = [
|
|
17
|
+
'<%= config.bin %> project list',
|
|
18
|
+
'<%= config.bin %> project list --output json',
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
static flags = {
|
|
22
|
+
...BaseCommand.baseFlags,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async run() {
|
|
26
|
+
const { flags } = await this.parse(ProjectListCommand)
|
|
27
|
+
const limit = flags.limit ?? 100
|
|
28
|
+
|
|
29
|
+
const query = {
|
|
30
|
+
limit: Math.min(limit, 100),
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const items = await collectPages(
|
|
34
|
+
this.apiClient.pageV2('/api/v2/projects', query),
|
|
35
|
+
limit,
|
|
36
|
+
)
|
|
37
|
+
await this.outputResults(items, columns)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core'
|
|
2
|
+
import BaseCommand from '../../base-command.js'
|
|
3
|
+
import { buildWriteBody } from '../../lib/input.js'
|
|
4
|
+
import { outputRecord } from '../../lib/entity-view.js'
|
|
5
|
+
import { CliError } from '../../lib/errors.js'
|
|
6
|
+
|
|
7
|
+
export default class ProjectUpdateCommand extends BaseCommand {
|
|
8
|
+
static description =
|
|
9
|
+
'Update a project (v2 PATCH — only provided fields change)'
|
|
10
|
+
|
|
11
|
+
static examples = [
|
|
12
|
+
'<%= config.bin %> project update 7 --title "Relaunch"',
|
|
13
|
+
'<%= config.bin %> project update 7 --status closed',
|
|
14
|
+
'<%= config.bin %> project update 7 --owner 9',
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
static args = {
|
|
18
|
+
id: Args.integer({ required: true, description: 'Project ID' }),
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static flags = {
|
|
22
|
+
...BaseCommand.baseFlags,
|
|
23
|
+
title: Flags.string({ description: 'Project title' }),
|
|
24
|
+
description: Flags.string({ description: 'Project description' }),
|
|
25
|
+
status: Flags.string({ description: 'Project status' }),
|
|
26
|
+
'start-date': Flags.string({ description: 'Start date (YYYY-MM-DD)' }),
|
|
27
|
+
'end-date': Flags.string({ description: 'End date (YYYY-MM-DD)' }),
|
|
28
|
+
owner: Flags.integer({ description: 'Owner (user) ID' }),
|
|
29
|
+
board: Flags.integer({ description: 'Board ID' }),
|
|
30
|
+
phase: Flags.integer({ description: 'Phase ID' }),
|
|
31
|
+
body: Flags.string({ description: 'Raw JSON body to merge (flags win)' }),
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async run() {
|
|
35
|
+
const { args, flags } = await this.parse(ProjectUpdateCommand)
|
|
36
|
+
|
|
37
|
+
const body = buildWriteBody({
|
|
38
|
+
typed: {
|
|
39
|
+
title: flags.title,
|
|
40
|
+
description: flags.description,
|
|
41
|
+
status: flags.status,
|
|
42
|
+
start_date: flags['start-date'],
|
|
43
|
+
end_date: flags['end-date'],
|
|
44
|
+
owner_id: flags.owner,
|
|
45
|
+
board_id: flags.board,
|
|
46
|
+
phase_id: flags.phase,
|
|
47
|
+
},
|
|
48
|
+
rawBody: flags.body,
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
if (Object.keys(body).length === 0) {
|
|
52
|
+
throw new CliError(
|
|
53
|
+
'Nothing to update — pass at least one field flag or --body',
|
|
54
|
+
{ exitCode: 64 },
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const res = await this.apiClient.patch(`/api/v2/projects/${args.id}`, {
|
|
59
|
+
body,
|
|
60
|
+
})
|
|
61
|
+
await outputRecord(this, res.data)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Args } from '@oclif/core'
|
|
2
|
+
import BaseCommand from '../../base-command.js'
|
|
3
|
+
import { outputRecord } from '../../lib/entity-view.js'
|
|
4
|
+
|
|
5
|
+
export default class StageGetCommand extends BaseCommand {
|
|
6
|
+
static description = 'Get a stage by ID'
|
|
7
|
+
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> stage get 5',
|
|
10
|
+
'<%= config.bin %> stage get 5 --output json',
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
static flags = {
|
|
14
|
+
...BaseCommand.baseFlags,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static args = {
|
|
18
|
+
id: Args.integer({ required: true, description: 'Stage ID' }),
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async run() {
|
|
22
|
+
const { args } = await this.parse(StageGetCommand)
|
|
23
|
+
const body = await this.apiClient.get(`/api/v2/stages/${args.id}`)
|
|
24
|
+
await outputRecord(this, body.data)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core'
|
|
2
|
+
import BaseCommand from '../../base-command.js'
|
|
3
|
+
import { collectPages } from '../../lib/pagination.js'
|
|
4
|
+
|
|
5
|
+
const columns = {
|
|
6
|
+
id: { header: 'ID' },
|
|
7
|
+
name: { header: 'Name' },
|
|
8
|
+
pipeline_id: { header: 'Pipeline' },
|
|
9
|
+
deal_probability: { header: 'Probability' },
|
|
10
|
+
order_nr: { header: 'Order' },
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default class StageListCommand extends BaseCommand {
|
|
14
|
+
static description = 'List stages'
|
|
15
|
+
|
|
16
|
+
static examples = [
|
|
17
|
+
'<%= config.bin %> stage list',
|
|
18
|
+
'<%= config.bin %> stage list --pipeline 1 --output json',
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
static flags = {
|
|
22
|
+
...BaseCommand.baseFlags,
|
|
23
|
+
pipeline: Flags.integer({ description: 'Filter by pipeline ID' }),
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async run() {
|
|
27
|
+
const { flags } = await this.parse(StageListCommand)
|
|
28
|
+
const limit = flags.limit ?? 100
|
|
29
|
+
|
|
30
|
+
const query = {
|
|
31
|
+
pipeline_id: flags.pipeline,
|
|
32
|
+
limit: Math.min(limit, 100),
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const items = await collectPages(
|
|
36
|
+
this.apiClient.pageV2('/api/v2/stages', query),
|
|
37
|
+
limit,
|
|
38
|
+
)
|
|
39
|
+
await this.outputResults(items, columns)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core'
|
|
2
|
+
import BaseCommand from '../../base-command.js'
|
|
3
|
+
import { buildWriteBody } from '../../lib/input.js'
|
|
4
|
+
import { outputRecord } from '../../lib/entity-view.js'
|
|
5
|
+
|
|
6
|
+
export default class WebhookCreateCommand extends BaseCommand {
|
|
7
|
+
static description = 'Create a webhook'
|
|
8
|
+
|
|
9
|
+
static examples = [
|
|
10
|
+
'<%= config.bin %> webhook create --url https://example.com/hook --event-action change --event-object deal',
|
|
11
|
+
'<%= config.bin %> webhook create --url https://example.com/hook --event-action "*" --event-object "*"',
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
static flags = {
|
|
15
|
+
...BaseCommand.baseFlags,
|
|
16
|
+
url: Flags.string({
|
|
17
|
+
required: true,
|
|
18
|
+
description: 'Webhook subscription URL',
|
|
19
|
+
}),
|
|
20
|
+
'event-action': Flags.string({
|
|
21
|
+
required: true,
|
|
22
|
+
description: 'Event action to subscribe to',
|
|
23
|
+
options: ['create', 'change', 'delete', '*'],
|
|
24
|
+
}),
|
|
25
|
+
'event-object': Flags.string({
|
|
26
|
+
required: true,
|
|
27
|
+
description: 'Event object to subscribe to',
|
|
28
|
+
options: [
|
|
29
|
+
'activity',
|
|
30
|
+
'deal',
|
|
31
|
+
'lead',
|
|
32
|
+
'note',
|
|
33
|
+
'organization',
|
|
34
|
+
'person',
|
|
35
|
+
'product',
|
|
36
|
+
'user',
|
|
37
|
+
'pipeline',
|
|
38
|
+
'stage',
|
|
39
|
+
'*',
|
|
40
|
+
],
|
|
41
|
+
}),
|
|
42
|
+
name: Flags.string({ description: 'Webhook name' }),
|
|
43
|
+
version: Flags.string({
|
|
44
|
+
description: 'Webhook payload version',
|
|
45
|
+
default: '2.0',
|
|
46
|
+
}),
|
|
47
|
+
'http-auth-user': Flags.string({
|
|
48
|
+
description: 'HTTP basic auth username for the endpoint',
|
|
49
|
+
dependsOn: ['http-auth-password'],
|
|
50
|
+
}),
|
|
51
|
+
'http-auth-password': Flags.string({
|
|
52
|
+
description: 'HTTP basic auth password for the endpoint',
|
|
53
|
+
dependsOn: ['http-auth-user'],
|
|
54
|
+
}),
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async run() {
|
|
58
|
+
const { flags } = await this.parse(WebhookCreateCommand)
|
|
59
|
+
|
|
60
|
+
const body = buildWriteBody({
|
|
61
|
+
typed: {
|
|
62
|
+
subscription_url: flags.url,
|
|
63
|
+
event_action: flags['event-action'],
|
|
64
|
+
event_object: flags['event-object'],
|
|
65
|
+
version: flags.version,
|
|
66
|
+
name: flags.name,
|
|
67
|
+
http_auth_user: flags['http-auth-user'],
|
|
68
|
+
http_auth_password: flags['http-auth-password'],
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
const res = await this.apiClient.post('/api/v1/webhooks', { body })
|
|
73
|
+
await outputRecord(this, res.data)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core'
|
|
2
|
+
import chalk from 'chalk'
|
|
3
|
+
import BaseCommand from '../../base-command.js'
|
|
4
|
+
import { confirmAction } from '../../lib/confirm.js'
|
|
5
|
+
import { CliError } from '../../lib/errors.js'
|
|
6
|
+
|
|
7
|
+
export default class WebhookDeleteCommand extends BaseCommand {
|
|
8
|
+
static description = 'Delete a webhook'
|
|
9
|
+
|
|
10
|
+
static examples = [
|
|
11
|
+
'<%= config.bin %> webhook delete 3',
|
|
12
|
+
'<%= config.bin %> webhook delete 3 --yes',
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
static args = {
|
|
16
|
+
id: Args.integer({ required: true, description: 'Webhook ID' }),
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static flags = {
|
|
20
|
+
...BaseCommand.baseFlags,
|
|
21
|
+
yes: Flags.boolean({
|
|
22
|
+
char: 'y',
|
|
23
|
+
description: 'Skip the confirmation prompt',
|
|
24
|
+
default: false,
|
|
25
|
+
}),
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async run() {
|
|
29
|
+
const { args, flags } = await this.parse(WebhookDeleteCommand)
|
|
30
|
+
|
|
31
|
+
const ok = await confirmAction(`Delete webhook ${args.id}?`, flags.yes)
|
|
32
|
+
if (!ok) {
|
|
33
|
+
throw new CliError('Aborted', { exitCode: 1 })
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
await this.apiClient.del(`/api/v1/webhooks/${args.id}`)
|
|
37
|
+
this.log(chalk.green(`Deleted webhook ${args.id}`))
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import BaseCommand from '../../base-command.js'
|
|
2
|
+
|
|
3
|
+
const columns = {
|
|
4
|
+
id: { header: 'ID' },
|
|
5
|
+
subscription_url: { header: 'URL' },
|
|
6
|
+
event_action: { header: 'Action' },
|
|
7
|
+
event_object: { header: 'Object' },
|
|
8
|
+
version: { header: 'Version' },
|
|
9
|
+
is_active: {
|
|
10
|
+
header: 'Active',
|
|
11
|
+
get: (row) => row.is_active ?? row.active_flag ?? '',
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default class WebhookListCommand extends BaseCommand {
|
|
16
|
+
static description = 'List webhooks'
|
|
17
|
+
|
|
18
|
+
static examples = [
|
|
19
|
+
'<%= config.bin %> webhook list',
|
|
20
|
+
'<%= config.bin %> webhook list --output json',
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
static flags = {
|
|
24
|
+
...BaseCommand.baseFlags,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async run() {
|
|
28
|
+
await this.parse(WebhookListCommand)
|
|
29
|
+
|
|
30
|
+
const body = await this.apiClient.get('/api/v1/webhooks')
|
|
31
|
+
await this.outputResults(body.data, columns)
|
|
32
|
+
}
|
|
33
|
+
}
|