@heroku-cli/heroku-connect-plugin 0.11.5-beta.0 → 0.12.0-beta.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 +36 -8
  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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@heroku-cli/heroku-connect-plugin",
3
3
  "description": "Heroku Connect CLI plugin",
4
- "version": "0.11.5-beta.0",
4
+ "version": "0.12.0-beta.0",
5
5
  "author": "Heroku",
6
6
  "repository": {
7
7
  "type": "git",
@@ -14,16 +14,38 @@
14
14
  "heroku-plugin"
15
15
  ],
16
16
  "license": "Apache-2.0",
17
- "main": "index.js",
17
+ "type": "module",
18
18
  "files": [
19
- "/index.js",
19
+ "/commands",
20
20
  "/lib",
21
- "/commands"
21
+ "oclif.manifest.json"
22
22
  ],
23
+ "oclif": {
24
+ "bin": "heroku",
25
+ "commands": "./commands",
26
+ "topics": {
27
+ "connect": {
28
+ "description": "manage connections for Heroku Connect"
29
+ },
30
+ "connect:mapping": {
31
+ "description": "manage mappings on a Heroku Connect addon"
32
+ },
33
+ "connect:notifications": {
34
+ "description": "manage notifications on a Heroku Connect addon"
35
+ },
36
+ "connect-events": {
37
+ "description": "manage connections for Heroku Connect Events Pilot"
38
+ },
39
+ "connect-events:stream": {
40
+ "description": "manage mappings on a Heroku Connect Events Pilot addon"
41
+ }
42
+ }
43
+ },
23
44
  "dependencies": {
45
+ "@heroku-cli/command": "^12.2.1",
24
46
  "@heroku/heroku-cli-util": "^8.0.15",
25
- "axios": "^1.12.0",
26
- "co": "4.6.0",
47
+ "@oclif/core": "^4.8.4",
48
+ "axios": "^1.13.5",
27
49
  "heroku-client": "^3.0.6",
28
50
  "inquirer": "^8.2.7"
29
51
  },
@@ -34,6 +56,7 @@
34
56
  "mocha": "^11.0.1",
35
57
  "mockdate": "^3.0.5",
36
58
  "nock": "^14.0.10",
59
+ "oclif": "^4.22.81",
37
60
  "sinon": "^21.0.0",
38
61
  "standard": "^17.1.0",
39
62
  "unexpected": "^13.2.1"
@@ -43,8 +66,13 @@
43
66
  "workflows-repo/**"
44
67
  ]
45
68
  },
69
+ "resolutions": {
70
+ "serialize-javascript": "^7.0.3"
71
+ },
46
72
  "scripts": {
47
- "test": "CONNECT_ADDON=connectqa mocha && standard",
48
- "style-fix": "standard --fix"
73
+ "test": "CONNECT_ADDON=connectqa mocha",
74
+ "posttest": "standard",
75
+ "style-fix": "standard --fix",
76
+ "build": "oclif manifest"
49
77
  }
50
78
  }
@@ -1,69 +0,0 @@
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 inquirer = require('inquirer')
6
-
7
- const fetchKeys = co.wrap(function * (appName, context) {
8
- const url = '/api/v3/apps/' + appName
9
- const response = yield api.request(context, 'GET', url)
10
- const keys = []// new Array(response.json.db_keys.length);
11
- response.data.db_keys.forEach(function (key) {
12
- const plan = (key.addon ? key.addon.plan : null) || 'Unknown Plan'
13
- keys.push({
14
- name: `${key.name} (${plan})`,
15
- value: key.name
16
- })
17
- })
18
- return yield Promise.resolve(keys)
19
- })
20
-
21
- module.exports = {
22
- topic: 'connect',
23
- command: 'db:set',
24
- description: 'Set database parameters',
25
- help: "Set a connection's database config var and schema name",
26
- flags: [
27
- { name: 'resource', description: 'specific connection resource name', hasValue: true },
28
- { name: 'db', description: 'Database config var name', hasValue: true },
29
- { name: 'schema', description: 'Database schema name', hasValue: true }
30
- ],
31
- needsApp: true,
32
- needsAuth: true,
33
- run: cli.command(co.wrap(function * (context, heroku) {
34
- const data = {
35
- db_key: context.flags.db,
36
- schema_name: context.flags.schema
37
- }
38
-
39
- const connection = yield api.withConnection(context, heroku)
40
- context.region = connection.region_url
41
-
42
- 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: yield 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
- ]).then(co.wrap(function * (answers) {
57
- for (const key in answers) {
58
- data[key] = answers[key]
59
- }
60
-
61
- yield cli.action('setting database parameters', co(function * () {
62
- const url = '/api/v3/connections/' + connection.id
63
- yield api.request(context, 'PATCH', url, data)
64
- }))
65
-
66
- cli.styledHash(data)
67
- }))
68
- }))
69
- }
@@ -1,33 +0,0 @@
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
-
6
- module.exports = {
7
- topic: 'connect:mapping',
8
- command: 'delete',
9
- description: 'Delete an existing mapping',
10
- help: 'Delete an existing mapping',
11
- args: [
12
- { name: 'mapping' }
13
- ],
14
- flags: [
15
- { name: 'resource', description: 'specific connection resource name', hasValue: true },
16
- { name: 'confirm', hasValue: true }
17
- ],
18
- needsApp: true,
19
- needsAuth: true,
20
- run: cli.command(co.wrap(function * (context, heroku) {
21
- yield cli.confirmApp(context.app, context.flags.confirm)
22
-
23
- yield cli.action('deleting mapping', co(function * () {
24
- const connection = yield api.withConnection(context, heroku)
25
- context.region = connection.region_url
26
- const mapping = yield api.withMapping(connection, context.args.mapping)
27
- const response = yield api.request(context, 'DELETE', '/api/v3/mappings/' + mapping.id)
28
- if (response.status !== 204) {
29
- throw new Error(response.data.message || 'unknown error')
30
- }
31
- }))
32
- }))
33
- }
@@ -1,33 +0,0 @@
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 diagnose = require('./diagnose')
6
-
7
- module.exports = {
8
- topic: 'connect:mapping',
9
- command: 'diagnose',
10
- description: 'Display diagnostic information about a mapping',
11
- help: 'Checks a mapping for common configuration errors. ',
12
- args: [
13
- { name: 'mapping' }
14
- ],
15
- flags: [
16
- { name: 'resource', description: 'specific connection resource name', hasValue: true },
17
- { name: 'verbose', char: 'v', description: 'display passed and skipped check information as well' }
18
- ],
19
- needsApp: true,
20
- needsAuth: true,
21
- run: cli.command(co.wrap(function * (context, heroku) {
22
- const connection = yield api.withConnection(context, heroku)
23
- context.region = connection.region_url
24
- const mapping = yield api.withMapping(connection, context.args.mapping)
25
- const results = yield cli.action('Diagnosing mapping', co(function * () {
26
- const url = '/api/v3/mappings/' + mapping.id + '/validations'
27
- return yield api.request(context, 'GET', url)
28
- }))
29
- cli.log() // Blank line to separate each section
30
- cli.styledHeader(mapping.object_name)
31
- diagnose.displayResults(results.data, context.flags)
32
- }))
33
- }
@@ -1,31 +0,0 @@
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
-
6
- module.exports = {
7
- topic: 'connect:mapping',
8
- command: 'reload',
9
- description: "Reload a mapping's data from Salesforce",
10
- help: "Reload a mapping's data from Salesforce",
11
- args: [
12
- { name: 'mapping' }
13
- ],
14
- flags: [
15
- { name: 'resource', description: 'specific connection resource name', hasValue: true }
16
- ],
17
- needsApp: true,
18
- needsAuth: true,
19
- run: cli.command(co.wrap(function * (context, heroku) {
20
- yield cli.action(`initiating reload of ${context.args.mapping}`, co(function * () {
21
- const connection = yield api.withConnection(context, heroku)
22
- context.region = connection.region_url
23
- const mapping = yield api.withMapping(connection, context.args.mapping)
24
-
25
- const response = yield api.request(context, 'POST', '/api/v3/mappings/' + mapping.id + '/actions/reload')
26
- if (response.status !== 202) {
27
- throw new Error(response.data.message || 'unknown error')
28
- }
29
- }))
30
- }))
31
- }
@@ -1,26 +0,0 @@
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
-
6
- module.exports = {
7
- topic: 'connect:mapping',
8
- command: 'state',
9
- description: 'return a mapping state',
10
- help: 'return a mapping state',
11
- args: [
12
- { name: 'mapping' }
13
- ],
14
- flags: [
15
- { name: 'resource', description: 'specific connection resource name', hasValue: true }
16
- ],
17
- needsApp: true,
18
- needsAuth: true,
19
- run: cli.command(co.wrap(function * (context, heroku) {
20
- const connection = yield api.withConnection(context, heroku)
21
- context.region = connection.region_url
22
- const mapping = yield api.withMapping(connection, context.args.mapping)
23
-
24
- cli.log(mapping.state)
25
- }))
26
- }
@@ -1,34 +0,0 @@
1
- 'use strict'
2
- const api = require('../../lib/connect/api.js')
3
- const cli = require('@heroku/heroku-cli-util')
4
-
5
- module.exports = {
6
- topic: 'connect:mapping',
7
- command: 'write-errors',
8
- description: 'Display the last 24 hours of write errors on this mapping',
9
- examples: [
10
- '$ heroku connect:mapping:write-errors -a myapp --resource herokuconnect-twisted-123 Account'
11
- ],
12
- args: [
13
- {
14
- name: 'name',
15
- optional: false,
16
- description: 'Name of the mapping to retrieve errors for'
17
- }
18
- ],
19
- flags: [
20
- {
21
- name: 'resource',
22
- description: 'specific connection resource name',
23
- hasValue: true
24
- },
25
- {
26
- name: 'json',
27
- description: 'print errors as styled JSON',
28
- hasValue: false
29
- }
30
- ],
31
- needsApp: true,
32
- needsAuth: true,
33
- run: cli.command(api.getWriteErrors)
34
- }
@@ -1,76 +0,0 @@
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')
6
-
7
- const LOCAL_PORT = 18000
8
-
9
- function callbackServer () {
10
- return new Promise(function (resolve, reject) {
11
- // Create a local server that can receive the user after authoriztion is complete
12
- http.createServer(function (request, response) {
13
- // Notify the user that the the authorization is complete
14
- response.writeHead(200, { 'Content-Type': 'text/html' })
15
- const res = '<html><body><h3>Authorization complete</h3><p>You may close this window and return to the terminal to continue.</p></body></html>'
16
- response.end(res)
17
-
18
- // Shut down the server so the command can exit
19
- request.socket.destroy()
20
- this.close()
21
-
22
- // Return control to the main command
23
- resolve()
24
- }).listen(LOCAL_PORT)
25
- })
26
- }
27
-
28
- function * run (context, heroku) {
29
- let redir
30
- yield cli.action('fetching authorizing URL', co(function * () {
31
- const connection = yield api.withConnection(context, heroku)
32
- context.region = connection.region_url
33
-
34
- const url = `/api/v3/connections/${connection.id}/authorize_url`
35
- const args = {
36
- environment: 'production',
37
- // Redirect to the local server created in callbackServer(), so the CLI
38
- // can respond immediately after successful authorization
39
- next: `http://localhost:${LOCAL_PORT}`
40
- }
41
-
42
- if (context.flags.environment) {
43
- args.environment = context.flags.environment
44
- }
45
-
46
- if (context.flags.environment === 'custom' && context.flags.domain) {
47
- args.domain = context.flags.domain
48
- }
49
-
50
- const response = yield api.request(context, 'POST', url, args)
51
- redir = response.data.redirect
52
-
53
- yield cli.open(redir)
54
- }))
55
-
56
- cli.log("\nIf your browser doesn't open, please copy the following URL to proceed:\n" + redir + '\n')
57
-
58
- yield cli.action('waiting for authorization', module.exports.callbackServer())
59
- }
60
-
61
- module.exports = {
62
- topic: 'connect',
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)),
75
- callbackServer
76
- }
@@ -1,68 +0,0 @@
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 inquirer = require('inquirer')
6
-
7
- const fetchKeys = co.wrap(function * (appName, context) {
8
- const url = `/api/v3/apps/${appName}`
9
- const response = yield api.request(context, 'GET', url)
10
- const keys = []// new Array(response.json.db_keys.length);
11
- response.data.db_keys.forEach(function (key) {
12
- keys.push({
13
- name: `${key.name} (${key.addon.plan})`,
14
- value: key.name
15
- })
16
- })
17
- return yield Promise.resolve(keys)
18
- })
19
-
20
- module.exports = {
21
- topic: 'connect-events',
22
- command: 'db:set',
23
- description: 'Set database parameters',
24
- help: "Set a connection's database config var and schema name",
25
- flags: [
26
- { name: 'resource', description: 'specific connection resource name', hasValue: true },
27
- { name: 'db', description: 'Database config var name', hasValue: true },
28
- { name: 'schema', description: 'Database schema name', hasValue: true }
29
- ],
30
- needsApp: true,
31
- needsAuth: true,
32
- run: cli.command(co.wrap(function * (context, heroku) {
33
- const data = {
34
- db_key: context.flags.db,
35
- schema_name: context.flags.schema
36
- }
37
-
38
- const connection = yield api.withConnection(context, heroku, api.ADDON_TYPE_EVENTS)
39
- context.region = connection.region_url
40
-
41
- inquirer.prompt([
42
- {
43
- name: 'db_key',
44
- type: 'list',
45
- message: "Select the config var that points to the database you'd like to use",
46
- choices: yield fetchKeys(connection.app_name, context),
47
- when: !context.flags.db
48
- },
49
- {
50
- name: 'schema_name',
51
- message: "Enter a schema name you'd like to use for the conneted data",
52
- default: context.flags.schema || 'salesforce',
53
- when: !context.flags.schema
54
- }
55
- ]).then(co.wrap(function * (answers) {
56
- for (const key in answers) {
57
- data[key] = answers[key]
58
- }
59
-
60
- yield cli.action('setting database parameters', co(function * () {
61
- const url = `/api/v3/kafka-connections/${connection.id}`
62
- yield api.request(context, 'PUT', url, data)
63
- }))
64
-
65
- cli.styledHash(data)
66
- }))
67
- }))
68
- }
@@ -1,32 +0,0 @@
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
-
6
- module.exports = {
7
- topic: 'connect-events:stream',
8
- command: 'create',
9
- description: 'Create a stream',
10
- help: 'Create a stream',
11
- args: [
12
- { name: 'stream' }
13
- ],
14
- flags: [
15
- { name: 'resource', description: 'specific connection resource name', hasValue: true }
16
- ],
17
- needsApp: true,
18
- needsAuth: true,
19
- run: cli.command(co.wrap(function * (context, heroku) {
20
- yield cli.action('creating stream', co(function * () {
21
- const connection = yield api.withConnection(context, heroku, api.ADDON_TYPE_EVENTS)
22
- context.region = connection.region_url
23
- const response = yield api.request(
24
- context, 'POST', `/api/v3/kafka-connections/${connection.id}/streams`,
25
- { object_name: context.args.stream }
26
- )
27
- if (response.status !== 201) {
28
- throw new Error(response.data.message || 'unknown error')
29
- }
30
- }))
31
- }))
32
- }
@@ -1,33 +0,0 @@
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
-
6
- module.exports = {
7
- topic: 'connect-events:stream',
8
- command: 'delete',
9
- description: 'Delete an existing stream',
10
- help: 'Delete an existing stream',
11
- args: [
12
- { name: 'stream' }
13
- ],
14
- flags: [
15
- { name: 'resource', description: 'specific connection resource name', hasValue: true },
16
- { name: 'confirm', hasValue: true }
17
- ],
18
- needsApp: true,
19
- needsAuth: true,
20
- run: cli.command(co.wrap(function * (context, heroku) {
21
- yield cli.confirmApp(context.app, context.flags.confirm)
22
-
23
- yield cli.action('deleting stream', co(function * () {
24
- const connection = yield api.withConnection(context, heroku, api.ADDON_TYPE_EVENTS)
25
- context.region = connection.region_url
26
- const stream = yield api.withStream(context, connection, context.args.stream)
27
- const response = yield api.request(context, 'DELETE', `/api/v3/streams/${stream.id}`)
28
- if (response.status !== 204) {
29
- throw new Error(response.data.message || 'unknown error')
30
- }
31
- }))
32
- }))
33
- }
@@ -1,26 +0,0 @@
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
-
6
- module.exports = {
7
- topic: 'connect-events:stream',
8
- command: 'state',
9
- description: 'return a stream state',
10
- help: 'return a stream state',
11
- args: [
12
- { name: 'stream' }
13
- ],
14
- flags: [
15
- { name: 'resource', description: 'specific connection resource name', hasValue: true }
16
- ],
17
- needsApp: true,
18
- needsAuth: true,
19
- run: cli.command(co.wrap(function * (context, heroku) {
20
- const connection = yield api.withConnection(context, heroku, api.ADDON_TYPE_EVENTS)
21
- context.region = connection.region_url
22
- const stream = yield api.withStream(context, connection, context.args.stream)
23
-
24
- cli.log(stream.state)
25
- }))
26
- }
package/index.js DELETED
@@ -1,50 +0,0 @@
1
- 'use strict'
2
- exports.topics = [
3
- {
4
- name: 'connect',
5
- description: 'manage connections for Heroku Connect'
6
- },
7
- {
8
- name: 'connect:mapping',
9
- description: 'manage mappings on a Heroku Connect addon'
10
- },
11
- {
12
- name: 'connect-events',
13
- description: 'manage connections for Heroku Connect Events Pilot'
14
- },
15
- {
16
- name: 'connect-events:stream',
17
- description: 'manage mappings on a Heroku Connect Events Pilot addon'
18
- }
19
- ]
20
-
21
- exports.commands = [
22
- require('./commands/connect/info'),
23
- require('./commands/connect/state'),
24
- require('./commands/connect/import'),
25
- require('./commands/connect/export'),
26
- require('./commands/connect/pause'),
27
- require('./commands/connect/resume'),
28
- require('./commands/connect/recover'),
29
- require('./commands/connect/sf-auth'),
30
- require('./commands/connect/db-set'),
31
- require('./commands/connect/diagnose'),
32
- require('./commands/connect/mapping-state'),
33
- require('./commands/connect/mapping-delete'),
34
- require('./commands/connect/mapping-reload'),
35
- require('./commands/connect/mapping-diagnose'),
36
- require('./commands/connect/mapping-write-errors'),
37
- require('./commands/connect/write-errors'),
38
-
39
- // Connect Events
40
- require('./commands/connect-events/info'),
41
- require('./commands/connect-events/state'),
42
- require('./commands/connect-events/pause'),
43
- require('./commands/connect-events/resume'),
44
- require('./commands/connect-events/recover'),
45
- require('./commands/connect-events/sf-auth'),
46
- require('./commands/connect-events/db-set'),
47
- require('./commands/connect-events/stream-state'),
48
- require('./commands/connect-events/stream-delete'),
49
- require('./commands/connect-events/stream-create')
50
- ]