@heroku-cli/heroku-connect-plugin 0.11.5 → 0.12.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.
Files changed (45) hide show
  1. package/README.md +15 -13
  2. package/commands/connect/db/set.js +69 -0
  3. package/commands/connect/diagnose.js +36 -31
  4. package/commands/connect/export.js +29 -24
  5. package/commands/connect/import.js +32 -25
  6. package/commands/connect/info.js +27 -23
  7. package/commands/connect/mapping/delete.js +35 -0
  8. package/commands/connect/mapping/diagnose.js +35 -0
  9. package/commands/connect/mapping/reload.js +33 -0
  10. package/commands/connect/mapping/state.js +28 -0
  11. package/commands/connect/mapping/write-errors.js +28 -0
  12. package/commands/connect/notifications/acknowledge.js +34 -0
  13. package/commands/connect/notifications/index.js +57 -0
  14. package/commands/connect/pause.js +25 -20
  15. package/commands/connect/recover.js +27 -21
  16. package/commands/connect/resume.js +25 -20
  17. package/commands/connect/sf/auth.js +75 -0
  18. package/commands/connect/state.js +32 -29
  19. package/commands/connect/write-errors.js +24 -23
  20. package/commands/connect-events/db/set.js +72 -0
  21. package/commands/connect-events/info.js +27 -24
  22. package/commands/connect-events/pause.js +24 -20
  23. package/commands/connect-events/recover.js +26 -21
  24. package/commands/connect-events/resume.js +24 -20
  25. package/commands/connect-events/{sf-auth.js → sf/auth.js} +33 -27
  26. package/commands/connect-events/state.js +24 -18
  27. package/commands/connect-events/stream/create.js +39 -0
  28. package/commands/connect-events/stream/delete.js +40 -0
  29. package/commands/connect-events/stream/state.js +33 -0
  30. package/lib/clients/connect.js +5 -4
  31. package/lib/clients/discovery.js +3 -2
  32. package/lib/connect/api.js +85 -107
  33. package/package.json +44 -11
  34. package/commands/connect/db-set.js +0 -69
  35. package/commands/connect/mapping-delete.js +0 -33
  36. package/commands/connect/mapping-diagnose.js +0 -33
  37. package/commands/connect/mapping-reload.js +0 -31
  38. package/commands/connect/mapping-state.js +0 -26
  39. package/commands/connect/mapping-write-errors.js +0 -34
  40. package/commands/connect/sf-auth.js +0 -76
  41. package/commands/connect-events/db-set.js +0 -68
  42. package/commands/connect-events/stream-create.js +0 -32
  43. package/commands/connect-events/stream-delete.js +0 -33
  44. package/commands/connect-events/stream-state.js +0 -26
  45. package/index.js +0 -50
package/README.md CHANGED
@@ -16,19 +16,21 @@ $ heroku help connect
16
16
  ## Commands
17
17
 
18
18
  ```text
19
- heroku connect:db:set - Set database parameters
20
- heroku connect:diagnose - Display diagnostic information about a connection
21
- heroku connect:export - Export a mapping configuration JSON file
22
- heroku connect:import FILE - Import a mapping configuration JSON file
23
- heroku connect:info - Display connection information
24
- heroku connect:mapping:state MAPPING - Return the state of a mapping
25
- heroku connect:mapping:delete MAPPING - Delete an existing mapping
26
- heroku connect:mapping:reload MAPPING - Reload a mapping's data from Salesforce
27
- heroku connect:pause - Pause a connection
28
- heroku connect:resume - Resume a connection
29
- heroku connect:restart - Restart a connection
30
- heroku connect:sf:auth - Authenticate a connection to Salesforce
31
- heroku connect:state - Return the state flag for a single connection
19
+ heroku connect:db:set - Set database parameters
20
+ heroku connect:diagnose - Display diagnostic information about a connection
21
+ heroku connect:export - Export a mapping configuration JSON file
22
+ heroku connect:import FILE - Import a mapping configuration JSON file
23
+ heroku connect:info - Display connection information
24
+ heroku connect:mapping:state MAPPING - Return the state of a mapping
25
+ heroku connect:mapping:delete MAPPING - Delete an existing mapping
26
+ heroku connect:mapping:reload MAPPING - Reload a mapping's data from Salesforce
27
+ heroku connect:notifications - List unacknowledged notifications
28
+ heroku connect:notifications:acknowledge - Acknowledge pending notifications
29
+ heroku connect:pause - Pause a connection
30
+ heroku connect:resume - Resume a connection
31
+ heroku connect:restart - Restart a connection
32
+ heroku connect:sf:auth - Authenticate a connection to Salesforce
33
+ heroku connect:state - Return the state flag for a single connection
32
34
  ```
33
35
 
34
36
  ## Examples
@@ -0,0 +1,69 @@
1
+ import * as api from '../../../lib/connect/api.js'
2
+ import cli from '@heroku/heroku-cli-util'
3
+ import inquirer from 'inquirer'
4
+ import { Command, flags } from '@heroku-cli/command'
5
+
6
+ async function fetchKeys (appName, context) {
7
+ const url = '/api/v3/apps/' + appName
8
+ const response = await api.request(context, 'GET', url)
9
+ const keys = []// new Array(response.json.db_keys.length);
10
+ response.data.db_keys.forEach(function (key) {
11
+ const plan = (key.addon ? key.addon.plan : null) || 'Unknown Plan'
12
+ keys.push({
13
+ name: `${key.name} (${plan})`,
14
+ value: key.name
15
+ })
16
+ })
17
+ return keys
18
+ }
19
+
20
+ export default class DbSet extends Command {
21
+ static description = 'Set database parameters'
22
+
23
+ static flags = {
24
+ app: flags.app({ required: true }),
25
+ resource: flags.string({ description: 'specific connection resource name' }),
26
+ db: flags.string({ description: 'Database config var name' }),
27
+ schema: flags.string({ description: 'Database schema name' })
28
+ }
29
+
30
+ async run () {
31
+ const { args, flags } = await this.parse(DbSet)
32
+ const context = { app: flags.app, flags, args, auth: { password: this.heroku.auth } }
33
+
34
+ const data = {
35
+ db_key: context.flags.db,
36
+ schema_name: context.flags.schema
37
+ }
38
+
39
+ const connection = await api.withConnection(context, this.heroku)
40
+ context.region = connection.region_url
41
+
42
+ const answers = await inquirer.prompt([
43
+ {
44
+ name: 'db_key',
45
+ type: 'list',
46
+ message: "Select the config var that points to the database you'd like to use",
47
+ choices: await fetchKeys(connection.app_name, context),
48
+ when: !context.flags.db
49
+ },
50
+ {
51
+ name: 'schema_name',
52
+ message: "Enter a schema name you'd like to use for the conneted data",
53
+ default: context.flags.schema || 'salesforce',
54
+ when: !context.flags.schema
55
+ }
56
+ ])
57
+
58
+ for (const key in answers) {
59
+ data[key] = answers[key]
60
+ }
61
+
62
+ await cli.action('setting database parameters', (async function () {
63
+ const url = '/api/v3/connections/' + connection.id
64
+ await api.request(context, 'PATCH', url, data)
65
+ })())
66
+
67
+ cli.styledHash(data)
68
+ }
69
+ }
@@ -1,7 +1,6 @@
1
- 'use strict'
2
- const api = require('../../lib/connect/api.js')
3
- const cli = require('@heroku/heroku-cli-util')
4
- const co = require('co')
1
+ import { Command, flags } from '@heroku-cli/command'
2
+ import cli from '@heroku/heroku-cli-util'
3
+ import * as api from '../../lib/connect/api.js'
5
4
 
6
5
  function displayResults (results, flags) {
7
6
  results.errors.forEach(displayResult('RED', 'red'))
@@ -38,26 +37,32 @@ function timeout (duration) {
38
37
  })
39
38
  }
40
39
 
41
- module.exports = {
42
- topic: 'connect',
43
- command: 'diagnose',
44
- description: 'Display diagnostic information about a connection',
45
- help: 'Checks a connection for common configuration errors. ',
46
- flags: [
47
- { name: 'resource', description: 'specific connection resource name', hasValue: true },
48
- { name: 'verbose', char: 'v', description: 'display passed and skipped check information as well' }
49
- ],
50
- needsApp: true,
51
- needsAuth: true,
52
- run: cli.command(co.wrap(function * (context, heroku) {
40
+ export default class ConnectDiagnose extends Command {
41
+ static description = 'Display diagnostic information about a connection'
42
+
43
+ static flags = {
44
+ app: flags.app({ required: true }),
45
+ resource: flags.string({ description: 'specific connection resource name' }),
46
+ verbose: flags.boolean({ char: 'v', description: 'display passed and skipped check information as well' })
47
+ }
48
+
49
+ async run () {
50
+ const { flags } = await this.parse(ConnectDiagnose)
51
+ const context = {
52
+ app: flags.app,
53
+ flags,
54
+ args: {},
55
+ auth: { password: this.heroku.auth }
56
+ }
57
+
53
58
  let mappingResults
54
59
  let didDisplayAnything = false
55
- const connection = yield api.withConnection(context, heroku)
60
+ const connection = await api.withConnection(context, this.heroku)
56
61
  context.region = connection.region_url
57
- const results = yield cli.action('Diagnosing connection', co(function * () {
62
+ const results = await cli.action('Diagnosing connection', (async function () {
58
63
  const url = '/api/v3/connections/' + connection.id + '/validations'
59
64
  try {
60
- const { data: { result_url: resultUrl } } = yield api.request(context, 'POST', url)
65
+ const { data: { result_url: resultUrl } } = await api.request(context, 'POST', url)
61
66
 
62
67
  let i = 0
63
68
 
@@ -66,7 +71,7 @@ module.exports = {
66
71
  cli.error('There was an issue retrieving validations')
67
72
  break
68
73
  }
69
- const response = yield api.request(context, 'GET', resultUrl)
74
+ const response = await api.request(context, 'GET', resultUrl)
70
75
 
71
76
  if (response.status === 200) {
72
77
  return response.data
@@ -74,35 +79,35 @@ module.exports = {
74
79
 
75
80
  i++
76
81
 
77
- yield timeout(500)
82
+ await timeout(500)
78
83
  }
79
84
  } catch (err) {
80
85
  cli.error(err)
81
86
  }
82
- }))
87
+ })())
83
88
 
84
89
  cli.log() // Blank line to separate each section
85
90
  cli.styledHeader(`Connection: ${connection.name || connection.internal_name}`)
86
- if (shouldDisplay(results, context.flags)) {
91
+ if (shouldDisplay(results, flags)) {
87
92
  didDisplayAnything = true
88
- displayResults(results, context.flags)
93
+ displayResults(results, flags)
89
94
  }
90
95
 
91
96
  for (const objectName in results.mappings) {
92
97
  mappingResults = results.mappings[objectName]
93
- if (shouldDisplay(mappingResults, context.flags)) {
98
+ if (shouldDisplay(mappingResults, flags)) {
94
99
  didDisplayAnything = true
95
100
  cli.log() // Blank line to separate each section
96
101
  cli.styledHeader(objectName)
97
- displayResults(mappingResults, context.flags)
102
+ displayResults(mappingResults, flags)
98
103
  }
99
104
  }
100
105
 
101
- if (!didDisplayAnything && !context.flags.verbose) {
106
+ if (!didDisplayAnything && !flags.verbose) {
102
107
  cli.log(cli.color.green('Everything appears to be fine'))
103
108
  }
104
- })),
105
-
106
- // Additional exports for code sharing
107
- displayResults
109
+ }
108
110
  }
111
+
112
+ // Additional exports for code sharing
113
+ export { displayResults }
@@ -1,35 +1,40 @@
1
- 'use strict'
2
- const api = require('../../lib/connect/api.js')
3
- const cli = require('@heroku/heroku-cli-util')
4
- const co = require('co')
5
- const fs = require('fs')
1
+ import { Command, flags } from '@heroku-cli/command'
2
+ import cli from '@heroku/heroku-cli-util'
3
+ import * as api from '../../lib/connect/api.js'
4
+ import fs from 'fs'
5
+
6
+ export default class ConnectExport extends Command {
7
+ static description = 'Export configuration from a connection'
8
+
9
+ static flags = {
10
+ app: flags.app({ required: true }),
11
+ resource: flags.string({ description: 'specific connection resource name' })
12
+ }
13
+
14
+ async run () {
15
+ const { flags } = await this.parse(ConnectExport)
16
+ const context = {
17
+ app: flags.app,
18
+ flags,
19
+ args: {},
20
+ auth: { password: this.heroku.auth }
21
+ }
6
22
 
7
- module.exports = {
8
- topic: 'connect',
9
- command: 'export',
10
- description: 'Export configuration from a connection',
11
- help: 'Exports the mapping configuration from a connection as a json file',
12
- flags: [
13
- { name: 'resource', description: 'specific connection resource name', hasValue: true }
14
- ],
15
- needsApp: true,
16
- needsAuth: true,
17
- run: cli.command(co.wrap(function * (context, heroku) {
18
23
  let connection, response
19
24
 
20
- yield cli.action('fetching configuration', co(function * () {
21
- connection = yield api.withConnection(context, heroku)
25
+ await cli.action('fetching configuration', (async function () {
26
+ connection = await api.withConnection(context, this.heroku)
22
27
  context.region = connection.region_url
23
28
  const url = '/api/v3/connections/' + connection.id + '/actions/export'
24
- response = yield api.request(context, 'GET', url)
25
- }))
29
+ response = await api.request(context, 'GET', url)
30
+ }.bind(this))())
26
31
 
27
32
  const fName = connection.app_name + '-' + (connection.resource_name || '') + '.json'
28
33
 
29
- yield cli.action('writing configuration to file', {
34
+ await cli.action('writing configuration to file', {
30
35
  success: fName
31
- }, co(function * () {
36
+ }, (async function () {
32
37
  fs.writeFileSync(fName, JSON.stringify(response.data, null, 4))
33
- }))
34
- }))
38
+ })())
39
+ }
35
40
  }
@@ -1,30 +1,37 @@
1
- 'use strict'
2
- const api = require('../../lib/connect/api.js')
3
- const cli = require('@heroku/heroku-cli-util')
4
- const co = require('co')
5
- const fs = require('fs')
1
+ import { Command, flags } from '@heroku-cli/command'
2
+ import { Args } from '@oclif/core'
3
+ import cli from '@heroku/heroku-cli-util'
4
+ import * as api from '../../lib/connect/api.js'
5
+ import fs from 'fs'
6
6
 
7
- module.exports = {
8
- topic: 'connect',
9
- command: 'import',
10
- description: 'Import configuration from an export file',
11
- help: 'Imports the mapping configuration from a json export file',
12
- args: [
13
- { name: 'file', desciption: 'JSON export file name' }
14
- ],
15
- flags: [
16
- { name: 'resource', description: 'specific connection resource name', hasValue: true }
17
- ],
18
- needsApp: true,
19
- needsAuth: true,
20
- run: cli.command(co.wrap(function * (context, heroku) {
21
- const fName = context.args.file
22
- yield cli.action(`uploading ${fName}`, co(function * () {
23
- const connection = yield api.withConnection(context, heroku)
7
+ export default class ConnectImport extends Command {
8
+ static description = 'Import configuration from an export file'
9
+
10
+ static args = {
11
+ file: Args.string({ description: 'JSON export file name' })
12
+ }
13
+
14
+ static flags = {
15
+ app: flags.app({ required: true }),
16
+ resource: flags.string({ description: 'specific connection resource name' })
17
+ }
18
+
19
+ async run () {
20
+ const { args, flags } = await this.parse(ConnectImport)
21
+ const context = {
22
+ app: flags.app,
23
+ flags,
24
+ args,
25
+ auth: { password: this.heroku.auth }
26
+ }
27
+
28
+ const fName = args.file
29
+ await cli.action(`uploading ${fName}`, (async function () {
30
+ const connection = await api.withConnection(context, this.heroku)
24
31
  context.region = connection.region_url
25
32
  const url = '/api/v3/connections/' + connection.id + '/actions/import'
26
33
  const data = JSON.parse(fs.readFileSync(fName, 'utf8'))
27
- yield api.request(context, 'POST', url, data)
28
- }))
29
- }))
34
+ await api.request(context, 'POST', url, data)
35
+ }.bind(this))())
36
+ }
30
37
  }
@@ -1,28 +1,32 @@
1
- 'use strict'
2
- const api = require('../../lib/connect/api.js')
3
- const cli = require('@heroku/heroku-cli-util')
4
- const co = require('co')
1
+ import { Command, flags } from '@heroku-cli/command'
2
+ import cli from '@heroku/heroku-cli-util'
3
+ import * as api from '../../lib/connect/api.js'
4
+
5
+ export default class ConnectInfo extends Command {
6
+ static description = 'display connection information'
7
+
8
+ static flags = {
9
+ app: flags.app({ required: true }),
10
+ resource: flags.string({ description: 'specific connection resource name' }),
11
+ 'check-for-new': flags.boolean({ char: 'c', description: 'check for access to any new connections' })
12
+ }
13
+
14
+ async run () {
15
+ const { flags } = await this.parse(ConnectInfo)
16
+ const context = {
17
+ app: flags.app,
18
+ flags,
19
+ args: {},
20
+ auth: { password: this.heroku.auth }
21
+ }
5
22
 
6
- module.exports = {
7
- topic: 'connect',
8
- command: 'info',
9
- default: false,
10
- description: 'display connection information',
11
- help: 'display connection information',
12
- flags: [
13
- { name: 'resource', description: 'specific connection resource name', hasValue: true },
14
- { name: 'check-for-new', char: 'c', description: 'check for access to any new connections', hasValue: false }
15
- ],
16
- needsApp: true,
17
- needsAuth: true,
18
- run: cli.command(co.wrap(function * (context, heroku) {
19
23
  let connections
20
- if (context.flags['check-for-new']) {
21
- connections = yield api.requestAppAccess(context, context.app, context.flags, true, heroku)
24
+ if (flags['check-for-new']) {
25
+ connections = await api.requestAppAccess(context, flags.app, flags, true, this.heroku)
22
26
  } else {
23
- connections = yield api.withUserConnections(context, context.app, context.flags, true, heroku)
27
+ connections = await api.withUserConnections(context, flags.app, flags, true, this.heroku)
24
28
  if (connections.length === 0) {
25
- connections = yield api.requestAppAccess(context, context.app, context.flags, true, heroku)
29
+ connections = await api.requestAppAccess(context, flags.app, flags, true, this.heroku)
26
30
  }
27
31
  }
28
32
 
@@ -31,7 +35,7 @@ module.exports = {
31
35
  cli.error('No connection found. You may need to use addons:open to make it accessible to the CLI.')
32
36
  cli.error('')
33
37
  cli.error('For Example:')
34
- cli.error(`heroku addons:open ${instanceName} -a ${context.app}`)
38
+ cli.error(`heroku addons:open ${instanceName} -a ${flags.app}`)
35
39
  } else {
36
40
  connections.forEach(function (connection) {
37
41
  cli.styledHeader(`Connection [${connection.id}] / ${connection.resource_name} (${connection.state})`)
@@ -51,5 +55,5 @@ module.exports = {
51
55
  cli.log()
52
56
  })
53
57
  }
54
- }))
58
+ }
55
59
  }
@@ -0,0 +1,35 @@
1
+ import * as api from '../../../lib/connect/api.js'
2
+ import cli from '@heroku/heroku-cli-util'
3
+ import { Command, flags } from '@heroku-cli/command'
4
+ import { Args } from '@oclif/core'
5
+
6
+ export default class MappingDelete extends Command {
7
+ static description = 'Delete an existing mapping'
8
+
9
+ static args = {
10
+ mapping: Args.string({ description: 'mapping name' })
11
+ }
12
+
13
+ static flags = {
14
+ app: flags.app({ required: true }),
15
+ resource: flags.string({ description: 'specific connection resource name' }),
16
+ confirm: flags.string({ description: 'app name to confirm deletion' })
17
+ }
18
+
19
+ async run () {
20
+ const { args, flags } = await this.parse(MappingDelete)
21
+ const context = { app: flags.app, flags, args, auth: { password: this.heroku.auth } }
22
+
23
+ await cli.confirmApp(flags.app, flags.confirm)
24
+
25
+ await cli.action('deleting mapping', (async function () {
26
+ const connection = await api.withConnection(context, this.heroku)
27
+ context.region = connection.region_url
28
+ const mapping = await api.withMapping(connection, context.args.mapping)
29
+ const response = await api.request(context, 'DELETE', '/api/v3/mappings/' + mapping.id)
30
+ if (response.status !== 204) {
31
+ throw new Error(response.data.message || 'unknown error')
32
+ }
33
+ }.bind(this))())
34
+ }
35
+ }
@@ -0,0 +1,35 @@
1
+ import * as api from '../../../lib/connect/api.js'
2
+ import cli from '@heroku/heroku-cli-util'
3
+ import { displayResults } from '../diagnose.js'
4
+ import { Command, flags } from '@heroku-cli/command'
5
+ import { Args } from '@oclif/core'
6
+
7
+ export default class MappingDiagnose extends Command {
8
+ static description = 'Display diagnostic information about a mapping'
9
+
10
+ static args = {
11
+ mapping: Args.string({ description: 'mapping name' })
12
+ }
13
+
14
+ static flags = {
15
+ app: flags.app({ required: true }),
16
+ resource: flags.string({ description: 'specific connection resource name' }),
17
+ verbose: flags.boolean({ char: 'v', description: 'display passed and skipped check information as well' })
18
+ }
19
+
20
+ async run () {
21
+ const { args, flags } = await this.parse(MappingDiagnose)
22
+ const context = { app: flags.app, flags, args, auth: { password: this.heroku.auth } }
23
+
24
+ const connection = await api.withConnection(context, this.heroku)
25
+ context.region = connection.region_url
26
+ const mapping = await api.withMapping(connection, context.args.mapping)
27
+ const results = await cli.action('Diagnosing mapping', (async function () {
28
+ const url = '/api/v3/mappings/' + mapping.id + '/validations'
29
+ return await api.request(context, 'GET', url)
30
+ })())
31
+ cli.log() // Blank line to separate each section
32
+ cli.styledHeader(mapping.object_name)
33
+ displayResults(results.data, flags)
34
+ }
35
+ }
@@ -0,0 +1,33 @@
1
+ import * as api from '../../../lib/connect/api.js'
2
+ import cli from '@heroku/heroku-cli-util'
3
+ import { Command, flags } from '@heroku-cli/command'
4
+ import { Args } from '@oclif/core'
5
+
6
+ export default class MappingReload extends Command {
7
+ static description = "Reload a mapping's data from Salesforce"
8
+
9
+ static args = {
10
+ mapping: Args.string({ description: 'mapping name' })
11
+ }
12
+
13
+ static flags = {
14
+ app: flags.app({ required: true }),
15
+ resource: flags.string({ description: 'specific connection resource name' })
16
+ }
17
+
18
+ async run () {
19
+ const { args, flags } = await this.parse(MappingReload)
20
+ const context = { app: flags.app, flags, args, auth: { password: this.heroku.auth } }
21
+
22
+ await cli.action(`initiating reload of ${args.mapping}`, (async function () {
23
+ const connection = await api.withConnection(context, this.heroku)
24
+ context.region = connection.region_url
25
+ const mapping = await api.withMapping(connection, context.args.mapping)
26
+
27
+ const response = await api.request(context, 'POST', '/api/v3/mappings/' + mapping.id + '/actions/reload')
28
+ if (response.status !== 202) {
29
+ throw new Error(response.data.message || 'unknown error')
30
+ }
31
+ }.bind(this))())
32
+ }
33
+ }
@@ -0,0 +1,28 @@
1
+ import * as api from '../../../lib/connect/api.js'
2
+ import cli from '@heroku/heroku-cli-util'
3
+ import { Command, flags } from '@heroku-cli/command'
4
+ import { Args } from '@oclif/core'
5
+
6
+ export default class MappingState extends Command {
7
+ static description = 'return a mapping state'
8
+
9
+ static args = {
10
+ mapping: Args.string({ description: 'mapping name' })
11
+ }
12
+
13
+ static flags = {
14
+ app: flags.app({ required: true }),
15
+ resource: flags.string({ description: 'specific connection resource name' })
16
+ }
17
+
18
+ async run () {
19
+ const { args, flags } = await this.parse(MappingState)
20
+ const context = { app: flags.app, flags, args, auth: { password: this.heroku.auth } }
21
+
22
+ const connection = await api.withConnection(context, this.heroku)
23
+ context.region = connection.region_url
24
+ const mapping = await api.withMapping(connection, context.args.mapping)
25
+
26
+ cli.log(mapping.state)
27
+ }
28
+ }
@@ -0,0 +1,28 @@
1
+ import * as api from '../../../lib/connect/api.js'
2
+ import { Command, flags } from '@heroku-cli/command'
3
+ import { Args } from '@oclif/core'
4
+
5
+ export default class MappingWriteErrors extends Command {
6
+ static description = 'Display the last 24 hours of write errors on this mapping'
7
+
8
+ static examples = [
9
+ '$ heroku connect:mapping:write-errors -a myapp --resource herokuconnect-twisted-123 Account'
10
+ ]
11
+
12
+ static args = {
13
+ name: Args.string({ description: 'Name of the mapping to retrieve errors for', required: true })
14
+ }
15
+
16
+ static flags = {
17
+ app: flags.app({ required: true }),
18
+ resource: flags.string({ description: 'specific connection resource name' }),
19
+ json: flags.boolean({ description: 'print errors as styled JSON' })
20
+ }
21
+
22
+ async run () {
23
+ const { args, flags } = await this.parse(MappingWriteErrors)
24
+ const context = { app: flags.app, flags, args, auth: { password: this.heroku.auth } }
25
+
26
+ await api.getWriteErrors(context, this.heroku)
27
+ }
28
+ }
@@ -0,0 +1,34 @@
1
+ import * as api from '../../../lib/connect/api.js'
2
+ import { Command, flags } from '@heroku-cli/command'
3
+
4
+ export default class NotificationsAcknowledge extends Command {
5
+ static description = 'Acknowledges notifications matching the given criteria'
6
+
7
+ static flags = {
8
+ app: flags.app({ required: true }),
9
+ after: flags.string({ description: 'start date for notifications' }),
10
+ before: flags.string({ description: 'end date for notifications' }),
11
+ 'event-type': flags.string({ description: 'type of event to filter by' }),
12
+ resource: flags.string({ description: 'specific connection resource name' })
13
+ }
14
+
15
+ async run () {
16
+ const { args, flags } = await this.parse(NotificationsAcknowledge)
17
+ const context = { app: flags.app, flags, args, auth: { password: this.heroku.auth } }
18
+
19
+ const connection = await api.withConnection(context, this.heroku)
20
+ context.region = connection.region_url
21
+
22
+ const params = {
23
+ page_size: 1000,
24
+ after: context.flags.after,
25
+ before: context.flags.before,
26
+ event_type: context.flags['event-type']
27
+ }
28
+
29
+ const response = await api.request(context, 'POST', '/api/v3/connections/' + connection.id + '/notifications/acknowledge', null, params)
30
+ if (response.status !== 204) {
31
+ throw new Error(response.data.message || 'unknown error')
32
+ }
33
+ }
34
+ }