@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
@@ -1,24 +1,28 @@
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 * as api from '../../lib/connect/api.js'
2
+ import { Command, flags } from '@heroku-cli/command'
3
+ import cli from '@heroku/heroku-cli-util'
5
4
 
6
- module.exports = {
7
- topic: 'connect-events',
8
- command: 'resume',
9
- description: 'Resume a connection',
10
- help: 'Resumes a paused connection',
11
- flags: [
12
- { name: 'resource', description: 'specific connection resource name', hasValue: true }
13
- ],
14
- needsApp: true,
15
- needsAuth: true,
16
- run: cli.command(co.wrap(function * (context, heroku) {
17
- cli.action('resuming connection', co(function * () {
18
- const connection = yield api.withConnection(context, heroku, api.ADDON_TYPE_EVENTS)
5
+ export default class ConnectEventsResume extends Command {
6
+ static description = 'Resume a connection'
7
+
8
+ static flags = {
9
+ app: flags.app({ required: true }),
10
+ resource: flags.string({ description: 'specific connection resource name' })
11
+ }
12
+
13
+ async run () {
14
+ const { flags } = await this.parse(ConnectEventsResume)
15
+ const context = {
16
+ app: flags.app,
17
+ flags,
18
+ auth: { password: this.heroku.auth }
19
+ }
20
+
21
+ await cli.action('resuming connection', (async function () {
22
+ const connection = await api.withConnection(context, this.heroku, api.ADDON_TYPE_EVENTS)
19
23
  context.region = connection.region_url
20
24
  const url = `/api/v3/kafka-connections/${connection.id}/actions/resume`
21
- yield api.request(context, 'POST', url)
22
- }))
23
- }))
25
+ await api.request(context, 'POST', url)
26
+ }.bind(this))())
27
+ }
24
28
  }
@@ -1,12 +1,11 @@
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 http = require('http')
1
+ import * as api from '../../../lib/connect/api.js'
2
+ import { Command, flags } from '@heroku-cli/command'
3
+ import cli from '@heroku/heroku-cli-util'
4
+ import http from 'http'
6
5
 
7
6
  const LOCAL_PORT = 18000
8
7
 
9
- function callbackServer () {
8
+ export function callbackServer () {
10
9
  return new Promise(function (resolve, reject) {
11
10
  // Create a local server that can receive the user after authoriztion is complete
12
11
  http.createServer(function (request, response) {
@@ -25,10 +24,10 @@ function callbackServer () {
25
24
  })
26
25
  }
27
26
 
28
- function * run (context, heroku) {
27
+ async function authenticate (context, heroku) {
29
28
  let redir
30
- yield cli.action('fetching authorizing URL', co(function * () {
31
- const connection = yield api.withConnection(context, heroku, api.ADDON_TYPE_EVENTS)
29
+ await cli.action('fetching authorizing URL', (async function () {
30
+ const connection = await api.withConnection(context, heroku, api.ADDON_TYPE_EVENTS)
32
31
  context.region = connection.region_url
33
32
 
34
33
  const url = `/api/v3/kafka-connections/${connection.id}/authorize_url`
@@ -47,29 +46,36 @@ function * run (context, heroku) {
47
46
  args.domain = context.flags.domain
48
47
  }
49
48
 
50
- const response = yield api.request(context, 'POST', url, args)
49
+ const response = await api.request(context, 'POST', url, args)
51
50
  redir = response.data.redirect
52
51
 
53
- yield cli.open(redir)
54
- }))
52
+ await cli.open(redir)
53
+ })())
55
54
 
56
55
  cli.log("\nIf your browser doesn't open, please copy the following URL to proceed:\n" + redir + '\n')
57
56
 
58
- yield cli.action('waiting for authorization', callbackServer())
57
+ await cli.action('waiting for authorization', callbackServer())
59
58
  }
60
59
 
61
- module.exports = {
62
- topic: 'connect-events',
63
- command: 'sf:auth',
64
- description: 'Authorize access to Salesforce for your connection',
65
- help: 'Opens a browser to authorize a connection to a Salesforce Org',
66
- flags: [
67
- { name: 'callback', char: 'c', description: 'final callback URL', hasValue: true },
68
- { name: 'environment', char: 'e', description: '"production", "sandbox", or "custom" [defaults to "production"]', hasValue: true },
69
- { name: 'domain', char: 'd', description: 'specify a custom login domain (if using a "custom" environment)', hasValue: true },
70
- { name: 'resource', description: 'specific connection resource name', hasValue: true }
71
- ],
72
- needsApp: true,
73
- needsAuth: true,
74
- run: cli.command(co.wrap(run))
60
+ export default class ConnectEventsSfAuth extends Command {
61
+ static description = 'Authorize access to Salesforce for your connection'
62
+
63
+ static flags = {
64
+ app: flags.app({ required: true }),
65
+ callback: flags.string({ char: 'c', description: 'final callback URL' }),
66
+ environment: flags.string({ char: 'e', description: '"production", "sandbox", or "custom" [defaults to "production"]' }),
67
+ domain: flags.string({ char: 'd', description: 'specify a custom login domain (if using a "custom" environment)' }),
68
+ resource: flags.string({ description: 'specific connection resource name' })
69
+ }
70
+
71
+ async run () {
72
+ const { flags } = await this.parse(ConnectEventsSfAuth)
73
+ const context = {
74
+ app: flags.app,
75
+ flags,
76
+ auth: { password: this.heroku.auth }
77
+ }
78
+
79
+ await authenticate(context, this.heroku)
80
+ }
75
81
  }
@@ -1,10 +1,9 @@
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 * as api from '../../lib/connect/api.js'
2
+ import { Command, flags } from '@heroku-cli/command'
3
+ import cli from '@heroku/heroku-cli-util'
5
4
 
6
- function * run (context, heroku) {
7
- const connections = yield api.withUserConnections(context, context.app, context.flags, heroku, true, api.ADDON_TYPE_EVENTS)
5
+ async function run (context, heroku) {
6
+ const connections = await api.withUserConnections(context, context.app, context.flags, heroku, true, api.ADDON_TYPE_EVENTS)
8
7
 
9
8
  if (context.flags.json) {
10
9
  cli.styledJSON(connections)
@@ -19,16 +18,23 @@ function * run (context, heroku) {
19
18
  }
20
19
  }
21
20
 
22
- module.exports = {
23
- topic: 'connect-events',
24
- command: 'state',
25
- description: 'return the connection(s) state',
26
- help: 'returns the state key of the selected connections',
27
- flags: [
28
- { name: 'resource', description: 'specific connection resource name', hasValue: true },
29
- { name: 'json', description: 'print output as json', hasValue: false }
30
- ],
31
- needsApp: true,
32
- needsAuth: true,
33
- run: cli.command(co.wrap(run))
21
+ export default class ConnectEventsState extends Command {
22
+ static description = 'return the connection(s) state'
23
+
24
+ static flags = {
25
+ app: flags.app({ required: true }),
26
+ resource: flags.string({ description: 'specific connection resource name' }),
27
+ json: flags.boolean({ description: 'print output as json' })
28
+ }
29
+
30
+ async run () {
31
+ const { flags } = await this.parse(ConnectEventsState)
32
+ const context = {
33
+ app: flags.app,
34
+ flags,
35
+ auth: { password: this.heroku.auth }
36
+ }
37
+
38
+ await run(context, this.heroku)
39
+ }
34
40
  }
@@ -0,0 +1,39 @@
1
+ import * as api from '../../../lib/connect/api.js'
2
+ import { Command, flags } from '@heroku-cli/command'
3
+ import { Args } from '@oclif/core'
4
+ import cli from '@heroku/heroku-cli-util'
5
+
6
+ export default class ConnectEventsStreamCreate extends Command {
7
+ static description = 'Create a stream'
8
+
9
+ static args = {
10
+ stream: Args.string()
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(ConnectEventsStreamCreate)
20
+ const context = {
21
+ app: flags.app,
22
+ flags,
23
+ args,
24
+ auth: { password: this.heroku.auth }
25
+ }
26
+
27
+ await cli.action('creating stream', (async function () {
28
+ const connection = await api.withConnection(context, this.heroku, api.ADDON_TYPE_EVENTS)
29
+ context.region = connection.region_url
30
+ const response = await api.request(
31
+ context, 'POST', `/api/v3/kafka-connections/${connection.id}/streams`,
32
+ { object_name: args.stream }
33
+ )
34
+ if (response.status !== 201) {
35
+ throw new Error(response.data.message || 'unknown error')
36
+ }
37
+ }.bind(this))())
38
+ }
39
+ }
@@ -0,0 +1,40 @@
1
+ import * as api from '../../../lib/connect/api.js'
2
+ import { Command, flags } from '@heroku-cli/command'
3
+ import { Args } from '@oclif/core'
4
+ import cli from '@heroku/heroku-cli-util'
5
+
6
+ export default class ConnectEventsStreamDelete extends Command {
7
+ static description = 'Delete an existing stream'
8
+
9
+ static args = {
10
+ stream: Args.string()
11
+ }
12
+
13
+ static flags = {
14
+ app: flags.app({ required: true }),
15
+ resource: flags.string({ description: 'specific connection resource name' }),
16
+ confirm: flags.string()
17
+ }
18
+
19
+ async run () {
20
+ const { args, flags } = await this.parse(ConnectEventsStreamDelete)
21
+ const context = {
22
+ app: flags.app,
23
+ flags,
24
+ args,
25
+ auth: { password: this.heroku.auth }
26
+ }
27
+
28
+ await cli.confirmApp(flags.app, flags.confirm)
29
+
30
+ await cli.action('deleting stream', (async function () {
31
+ const connection = await api.withConnection(context, this.heroku, api.ADDON_TYPE_EVENTS)
32
+ context.region = connection.region_url
33
+ const stream = await api.withStream(context, connection, args.stream)
34
+ const response = await api.request(context, 'DELETE', `/api/v3/streams/${stream.id}`)
35
+ if (response.status !== 204) {
36
+ throw new Error(response.data.message || 'unknown error')
37
+ }
38
+ }.bind(this))())
39
+ }
40
+ }
@@ -0,0 +1,33 @@
1
+ import * as api from '../../../lib/connect/api.js'
2
+ import { Command, flags } from '@heroku-cli/command'
3
+ import { Args } from '@oclif/core'
4
+ import cli from '@heroku/heroku-cli-util'
5
+
6
+ export default class ConnectEventsStreamState extends Command {
7
+ static description = 'return a stream state'
8
+
9
+ static args = {
10
+ stream: Args.string()
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(ConnectEventsStreamState)
20
+ const context = {
21
+ app: flags.app,
22
+ flags,
23
+ args,
24
+ auth: { password: this.heroku.auth }
25
+ }
26
+
27
+ const connection = await api.withConnection(context, this.heroku, api.ADDON_TYPE_EVENTS)
28
+ context.region = connection.region_url
29
+ const stream = await api.withStream(context, connection, args.stream)
30
+
31
+ cli.log(stream.state)
32
+ }
33
+ }
@@ -1,4 +1,4 @@
1
- const axios = require('axios')
1
+ import axios from 'axios'
2
2
 
3
3
  class ConnectClient {
4
4
  constructor (context) {
@@ -16,14 +16,15 @@ class ConnectClient {
16
16
  return this.client.get(`${detailUrl}?deep=true`)
17
17
  }
18
18
 
19
- request ({ baseURL, method, url, data }) {
19
+ request ({ baseURL, method, url, data, params }) {
20
20
  return this.client({
21
21
  baseURL,
22
22
  method,
23
23
  url,
24
- data
24
+ data,
25
+ params
25
26
  })
26
27
  }
27
28
  }
28
29
 
29
- exports.ConnectClient = ConnectClient
30
+ export { ConnectClient }
@@ -1,4 +1,5 @@
1
- const axios = require('axios')
1
+ import axios from 'axios'
2
+
2
3
  const baseURL = process.env.CONNECT_DISCOVERY_SERVER || (process.env.CONNECT_ADDON === 'connectqa'
3
4
  ? 'https://hc-central-qa.herokai.com'
4
5
  : 'https://hc-central.heroku.com')
@@ -29,4 +30,4 @@ class DiscoveryClient {
29
30
  }
30
31
  }
31
32
 
32
- exports.DiscoveryClient = DiscoveryClient
33
+ export { DiscoveryClient }
@@ -1,13 +1,11 @@
1
- 'use strict'
2
- const cli = require('@heroku/heroku-cli-util')
3
- const co = require('co')
4
- const { ConnectClient } = require('../clients/connect')
5
- const { DiscoveryClient } = require('../clients/discovery')
1
+ import cli from '@heroku/heroku-cli-util'
2
+ import { ConnectClient } from '../clients/connect.js'
3
+ import { DiscoveryClient } from '../clients/discovery.js'
6
4
 
7
- exports.ADDON_TYPE_SYNC = 1
8
- exports.ADDON_TYPE_EVENTS = 2
5
+ export const ADDON_TYPE_SYNC = 1
6
+ export const ADDON_TYPE_EVENTS = 2
9
7
 
10
- const request = exports.request = function (context, method, url, data) {
8
+ export function request (context, method, url, data, params) {
11
9
  if (!context.region) {
12
10
  throw new Error('Must provide region URL')
13
11
  }
@@ -16,149 +14,129 @@ const request = exports.request = function (context, method, url, data) {
16
14
  baseURL: context.region,
17
15
  method,
18
16
  url,
19
- data
17
+ data,
18
+ params
20
19
  })
21
20
  }
22
21
 
23
- const withUserConnections = exports.withUserConnections = co.wrap(function * (context, appName, flags, allowNone, heroku, addonType) {
22
+ export async function withUserConnections (context, appName, flags, allowNone, heroku, addonType) {
24
23
  const connectClient = new ConnectClient(context)
25
24
  const discoveryClient = new DiscoveryClient(context)
26
25
 
27
- const searchResponse = yield discoveryClient.searchConnections(appName, context.flags.resource, addonType)
26
+ const searchResponse = await discoveryClient.searchConnections(appName, context.flags.resource, addonType)
28
27
  const connections = searchResponse.data.results
29
28
 
30
29
  if (connections.length === 0) {
31
- return yield Promise.resolve([])
30
+ return []
32
31
  }
33
32
 
34
- const fetchConnectionDetailFuncs = connections.map(function (c) {
35
- return co(function * () {
36
- const response = yield connectClient.getDetails(c)
37
- const mergedDetails = {
38
- ...c,
39
- ...response.data
40
- }
41
- return yield Promise.resolve(mergedDetails)
42
- })
33
+ const fetchConnectionDetailFuncs = connections.map(async function (c) {
34
+ const response = await connectClient.getDetails(c)
35
+ return {
36
+ ...c,
37
+ ...response.data
38
+ }
43
39
  })
44
40
 
45
- const aggregatedConnectionsData = yield Promise.all(fetchConnectionDetailFuncs)
46
- return yield Promise.resolve(aggregatedConnectionsData)
47
- })
41
+ const aggregatedConnectionsData = await Promise.all(fetchConnectionDetailFuncs)
42
+ return aggregatedConnectionsData
43
+ }
48
44
 
49
- const withConnection = exports.withConnection = function (context, heroku, addonType) {
50
- return co(function * () {
51
- const connectClient = new ConnectClient(context)
52
- const discoveryClient = new DiscoveryClient(context)
45
+ export async function withConnection (context, heroku, addonType) {
46
+ const connectClient = new ConnectClient(context)
47
+ const discoveryClient = new DiscoveryClient(context)
53
48
 
54
- const searchResponse = yield discoveryClient.searchConnections(context.app, context.flags.resource, addonType)
55
- const connections = searchResponse.data.results
49
+ const searchResponse = await discoveryClient.searchConnections(context.app, context.flags.resource, addonType)
50
+ const connections = searchResponse.data.results
56
51
 
57
- if (connections.length === 0) {
58
- yield Promise.reject(Error('No connection(s) found'))
59
- } else if (connections.length > 1) {
60
- throw new Error("Multiple connections found. Please use '--resource' to specify a single connection by resource name. Use 'connect:info' to list the resource names.")
61
- } else {
62
- const match = connections[0]
63
- const matchDetailResponse = yield connectClient.getDetails(match)
64
- const matchWithDetails = {
65
- ...match,
66
- ...matchDetailResponse.data
67
- }
68
- return yield Promise.resolve(matchWithDetails)
52
+ if (connections.length === 0) {
53
+ throw Error('No connection(s) found')
54
+ } else if (connections.length > 1) {
55
+ throw new Error("Multiple connections found. Please use '--resource' to specify a single connection by resource name. Use 'connect:info' to list the resource names.")
56
+ } else {
57
+ const match = connections[0]
58
+ const matchDetailResponse = await connectClient.getDetails(match)
59
+ return {
60
+ ...match,
61
+ ...matchDetailResponse.data
69
62
  }
70
- })
63
+ }
71
64
  }
72
65
 
73
- const withMapping = exports.withMapping = function (connection, objectName) {
74
- return co(function * () {
75
- const objectNameLower = objectName.toLowerCase()
76
- let mapping
77
- connection.mappings.forEach(function (m) {
78
- if (m.object_name.toLowerCase() === objectNameLower) {
79
- mapping = m
80
- }
81
- })
82
- if (mapping !== undefined) {
83
- return yield Promise.resolve(mapping)
84
- } else {
85
- throw new Error(`No mapping configured for ${objectName}`)
66
+ export async function withMapping (connection, objectName) {
67
+ const objectNameLower = objectName?.toLowerCase()
68
+ let mapping
69
+ connection.mappings.forEach(function (m) {
70
+ if (m.object_name.toLowerCase() === objectNameLower) {
71
+ mapping = m
86
72
  }
87
73
  })
74
+ if (mapping !== undefined) {
75
+ return mapping
76
+ } else {
77
+ throw new Error(`No mapping configured for ${objectName}`)
78
+ }
88
79
  }
89
80
 
90
- exports.withStream = function (context, connection, objectName) {
91
- return co(function * () {
92
- if (!connection.streams) {
93
- connection.streams = yield getStreams(context, connection)
94
- }
95
- const objectNameLower = objectName.toLowerCase()
96
- let stream
97
- connection.streams.forEach(function (s) {
98
- if (s.object_name.toLowerCase() === objectNameLower) {
99
- stream = s
100
- }
101
- })
102
- if (stream !== undefined) {
103
- return yield Promise.resolve(stream)
104
- } else {
105
- throw new Error(`No stream configured for ${objectName}`)
81
+ export async function withStream (context, connection, objectName) {
82
+ if (!connection.streams) {
83
+ connection.streams = await getStreams(context, connection)
84
+ }
85
+ const objectNameLower = objectName?.toLowerCase()
86
+ let stream
87
+ connection.streams.forEach(function (s) {
88
+ if (s.object_name.toLowerCase() === objectNameLower) {
89
+ stream = s
106
90
  }
107
91
  })
92
+ if (stream !== undefined) {
93
+ return stream
94
+ } else {
95
+ throw new Error(`No stream configured for ${objectName}`)
96
+ }
108
97
  }
109
98
 
110
- const getStreams = exports.getStreams = function (context, connection) {
111
- return co(function * () {
112
- const connectClient = new ConnectClient(context)
113
- const response = yield connectClient.request({
114
- baseURL: connection.region_url,
115
- method: 'GET',
116
- url: `${connection.detail_url}/streams`,
117
- data: null
118
- })
119
- const streams = response.data.results
120
- return yield Promise.resolve(streams)
99
+ export async function getStreams (context, connection) {
100
+ const connectClient = new ConnectClient(context)
101
+ const response = await connectClient.request({
102
+ baseURL: connection.region_url,
103
+ method: 'GET',
104
+ url: `${connection.detail_url}/streams`,
105
+ data: null
121
106
  })
107
+ return response.data.results
122
108
  }
123
109
 
124
- exports.withStreams = function (context, connections) {
125
- return co(function * () {
126
- const fetchConnectionStreams = connections.map(function (c) {
127
- return co(function * () {
128
- c.streams = yield getStreams(context, c)
129
- return yield Promise.resolve(c)
130
- })
131
- })
132
- const aggregatedConnectionsResponse = yield Promise.all(fetchConnectionStreams)
133
- return yield Promise.resolve(aggregatedConnectionsResponse)
110
+ export async function withStreams (context, connections) {
111
+ const fetchConnectionStreams = connections.map(async function (c) {
112
+ c.streams = await getStreams(context, c)
113
+ return c
134
114
  })
115
+ return await Promise.all(fetchConnectionStreams)
135
116
  }
136
117
 
137
- exports.requestAppAccess = function (context, app, flags, allowNone, heroku, addonType) {
138
- return co(function * () {
139
- const discoveryClient = new DiscoveryClient(context)
140
- const response = yield discoveryClient.requestAppAccess(app, addonType)
141
- yield Promise.resolve(response.json)
142
- return yield withUserConnections(context, app, flags, allowNone, heroku, addonType)
143
- })
118
+ export async function requestAppAccess (context, app, flags, allowNone, heroku, addonType) {
119
+ const discoveryClient = new DiscoveryClient(context)
120
+ await discoveryClient.requestAppAccess(app, addonType)
121
+ return await withUserConnections(context, app, flags, allowNone, heroku, addonType)
144
122
  }
145
123
 
146
- exports.getWriteErrors = co.wrap(function * (context, heroku) {
124
+ export async function getWriteErrors (context, heroku) {
147
125
  let url, action
148
126
  const mappingName = context.args.name
149
- const connection = yield withConnection(context, heroku)
127
+ const connection = await withConnection(context, heroku)
150
128
  context.region = connection.region_url
151
129
  if (!mappingName) {
152
130
  url = `/api/v3/connections/${connection.id}/errors`
153
131
  action = `Retrieving write errors for ${connection.name}`
154
132
  } else {
155
- const mapping = yield withMapping(connection, mappingName)
133
+ const mapping = await withMapping(connection, mappingName)
156
134
  url = `/api/v3/mappings/${mapping.id}/errors`
157
135
  action = `Retrieving write errors for ${mappingName} on ${connection.name}`
158
136
  }
159
- const results = yield cli.action(action, co(function * () {
160
- return yield request(context, 'GET', url)
161
- }))
137
+ const results = await cli.action(action, (async function () {
138
+ return await request(context, 'GET', url)
139
+ })())
162
140
  const errors = results.data
163
141
 
164
142
  if (errors.count === 0) {
@@ -178,4 +156,4 @@ exports.getWriteErrors = co.wrap(function * (context, heroku) {
178
156
  })
179
157
  }
180
158
  }
181
- })
159
+ }