heroku 10.13.2 → 10.13.3-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 (79) hide show
  1. package/lib/commands/pg/backups/cancel.js +4 -4
  2. package/lib/commands/pg/backups/capture.js +5 -5
  3. package/lib/commands/pg/backups/delete.js +2 -2
  4. package/lib/commands/pg/backups/download.js +3 -3
  5. package/lib/commands/pg/backups/index.js +2 -2
  6. package/lib/commands/pg/backups/info.js +3 -3
  7. package/lib/commands/pg/backups/restore.js +5 -5
  8. package/lib/commands/pg/backups/schedule.js +7 -7
  9. package/lib/commands/pg/backups/schedules.js +2 -2
  10. package/lib/commands/pg/backups/unschedule.js +6 -5
  11. package/lib/commands/pg/backups/url.js +3 -3
  12. package/lib/commands/pg/bloat.js +5 -4
  13. package/lib/commands/pg/blocking.js +5 -4
  14. package/lib/commands/pg/connection-pooling/attach.js +5 -6
  15. package/lib/commands/pg/copy.js +6 -7
  16. package/lib/commands/pg/credentials/create.js +4 -4
  17. package/lib/commands/pg/credentials/destroy.js +4 -4
  18. package/lib/commands/pg/credentials/repair-default.js +4 -4
  19. package/lib/commands/pg/credentials/rotate.js +4 -4
  20. package/lib/commands/pg/credentials/url.js +4 -4
  21. package/lib/commands/pg/credentials.js +4 -4
  22. package/lib/commands/pg/diagnose.js +6 -5
  23. package/lib/commands/pg/info.js +5 -3
  24. package/lib/commands/pg/kill.js +6 -5
  25. package/lib/commands/pg/killall.js +4 -4
  26. package/lib/commands/pg/links/create.js +10 -8
  27. package/lib/commands/pg/links/destroy.js +4 -4
  28. package/lib/commands/pg/links/index.js +14 -8
  29. package/lib/commands/pg/locks.js +5 -4
  30. package/lib/commands/pg/maintenance/index.js +4 -4
  31. package/lib/commands/pg/maintenance/run.js +4 -4
  32. package/lib/commands/pg/maintenance/window.js +4 -4
  33. package/lib/commands/pg/outliers.d.ts +2 -2
  34. package/lib/commands/pg/outliers.js +9 -7
  35. package/lib/commands/pg/promote.js +5 -4
  36. package/lib/commands/pg/ps.js +6 -5
  37. package/lib/commands/pg/psql.js +6 -4
  38. package/lib/commands/pg/pull.d.ts +1 -1
  39. package/lib/commands/pg/pull.js +4 -4
  40. package/lib/commands/pg/push.d.ts +1 -1
  41. package/lib/commands/pg/push.js +4 -4
  42. package/lib/commands/pg/reset.js +4 -4
  43. package/lib/commands/pg/settings/index.js +2 -2
  44. package/lib/commands/pg/unfollow.js +5 -5
  45. package/lib/commands/pg/upgrade/cancel.js +5 -5
  46. package/lib/commands/pg/upgrade/dryrun.js +5 -5
  47. package/lib/commands/pg/upgrade/index.js +5 -5
  48. package/lib/commands/pg/upgrade/prepare.js +5 -5
  49. package/lib/commands/pg/upgrade/run.js +5 -5
  50. package/lib/commands/pg/upgrade/wait.js +9 -4
  51. package/lib/commands/pg/vacuum-stats.js +5 -4
  52. package/lib/commands/pg/wait.js +6 -4
  53. package/lib/commands/run/detached.d.ts +1 -0
  54. package/lib/commands/run/detached.js +5 -1
  55. package/lib/commands/run/index.d.ts +1 -0
  56. package/lib/commands/run/index.js +7 -2
  57. package/lib/commands/run/inside.js +1 -6
  58. package/lib/lib/addons/resolve.d.ts +6 -7
  59. package/lib/lib/pg/backups.js +4 -4
  60. package/lib/lib/pg/fetcher.d.ts +3 -34
  61. package/lib/lib/pg/fetcher.js +3 -92
  62. package/lib/lib/pg/psql.d.ts +5 -36
  63. package/lib/lib/pg/psql.js +17 -195
  64. package/lib/lib/pg/push_pull.d.ts +2 -7
  65. package/lib/lib/pg/push_pull.js +9 -7
  66. package/lib/lib/pg/setter.js +3 -3
  67. package/lib/lib/pg/types.d.ts +10 -15
  68. package/lib/lib/pg/util.d.ts +6 -32
  69. package/lib/lib/pg/util.js +3 -70
  70. package/lib/lib/run/helpers.d.ts +10 -0
  71. package/lib/lib/run/helpers.js +22 -1
  72. package/oclif.manifest.json +142 -130
  73. package/package.json +4 -6
  74. package/lib/lib/pg/bastion.d.ts +0 -29
  75. package/lib/lib/pg/bastion.js +0 -121
  76. package/lib/lib/pg/config.d.ts +0 -2
  77. package/lib/lib/pg/config.js +0 -13
  78. package/lib/lib/pg/host.d.ts +0 -1
  79. package/lib/lib/pg/host.js +0 -6
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const command_1 = require("@heroku-cli/command");
4
4
  const core_1 = require("@oclif/core");
5
- const host_1 = require("../../../lib/pg/host");
5
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
6
6
  const backups_1 = require("../../../lib/pg/backups");
7
7
  class Cancel extends command_1.Command {
8
8
  async run() {
@@ -16,15 +16,15 @@ class Cancel extends command_1.Command {
16
16
  if (!num) {
17
17
  core_1.ux.error(`Invalid Backup: ${backup_id}`);
18
18
  }
19
- ({ body: transfer } = await this.heroku.get(`/client/v11/apps/${app}/transfers/${num}`, { hostname: (0, host_1.default)() }));
19
+ ({ body: transfer } = await this.heroku.get(`/client/v11/apps/${app}/transfers/${num}`, { hostname: heroku_cli_util_1.utils.pg.host() }));
20
20
  }
21
21
  else {
22
- const { body: transfers } = await this.heroku.get(`/client/v11/apps/${app}/transfers`, { hostname: (0, host_1.default)() });
22
+ const { body: transfers } = await this.heroku.get(`/client/v11/apps/${app}/transfers`, { hostname: heroku_cli_util_1.utils.pg.host() });
23
23
  transfer = this.sortByCreatedAtDesc(transfers).find(t => !t.finished_at);
24
24
  }
25
25
  if (transfer) {
26
26
  core_1.ux.action.start(`Cancelling ${pgbackups.name(transfer)}`);
27
- this.heroku.post(`/client/v11/apps/${app}/transfers/${transfer.uuid}/actions/cancel`, { hostname: (0, host_1.default)() });
27
+ this.heroku.post(`/client/v11/apps/${app}/transfers/${transfer.uuid}/actions/cancel`, { hostname: heroku_cli_util_1.utils.pg.host() });
28
28
  core_1.ux.action.stop();
29
29
  }
30
30
  else {
@@ -4,8 +4,7 @@ const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const backups_1 = require("../../../lib/pg/backups");
7
- const fetcher_1 = require("../../../lib/pg/fetcher");
8
- const host_1 = require("../../../lib/pg/host");
7
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
9
8
  const tsheredoc_1 = require("tsheredoc");
10
9
  const nls_1 = require("../../../nls");
11
10
  class Capture extends command_1.Command {
@@ -15,10 +14,11 @@ class Capture extends command_1.Command {
15
14
  const { app, 'wait-interval': waitInterval, verbose } = flags;
16
15
  const { database } = args;
17
16
  const interval = Math.max(3, Number.parseInt(waitInterval || '3', 10));
18
- const db = await (0, fetcher_1.getAddon)(this.heroku, app, database);
17
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
18
+ const { addon: db } = await dbResolver.getAttachment(app, database);
19
19
  const pgBackupsApi = (0, backups_1.default)(app, this.heroku);
20
20
  try {
21
- const { body: dbInfo } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: (0, host_1.default)() });
21
+ const { body: dbInfo } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: heroku_cli_util_1.utils.pg.host() });
22
22
  const dbProtected = /On/.test(((_a = dbInfo.info.find(attribute => attribute.name === 'Continuous Protection')) === null || _a === void 0 ? void 0 : _a.values[0]) || '');
23
23
  if (dbProtected) {
24
24
  core_1.ux.warn('Continuous protection is already enabled for this database. Logical backups of large databases are likely to fail.');
@@ -35,7 +35,7 @@ class Capture extends command_1.Command {
35
35
  `, { exit: 1 });
36
36
  }
37
37
  core_1.ux.action.start(`Starting backup of ${color_1.default.yellow(db.name)}`);
38
- const { body: backup } = await this.heroku.post(`/client/v11/databases/${db.id}/backups`, { hostname: (0, host_1.default)() });
38
+ const { body: backup } = await this.heroku.post(`/client/v11/databases/${db.id}/backups`, { hostname: heroku_cli_util_1.utils.pg.host() });
39
39
  core_1.ux.action.stop();
40
40
  core_1.ux.log((0, tsheredoc_1.default) `
41
41
 
@@ -4,7 +4,7 @@ const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const confirmCommand_1 = require("../../../lib/confirmCommand");
7
- const host_1 = require("../../../lib/pg/host");
7
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
8
8
  const backups_1 = require("../../../lib/pg/backups");
9
9
  class Delete extends command_1.Command {
10
10
  async run() {
@@ -18,7 +18,7 @@ class Delete extends command_1.Command {
18
18
  if (!num) {
19
19
  throw new Error(`Invalid Backup: ${backup_id}`);
20
20
  }
21
- await this.heroku.delete(`/client/v11/apps/${app}/transfers/${num}`, { hostname: (0, host_1.default)() });
21
+ await this.heroku.delete(`/client/v11/apps/${app}/transfers/${num}`, { hostname: heroku_cli_util_1.utils.pg.host() });
22
22
  core_1.ux.action.stop();
23
23
  }
24
24
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
- const host_1 = require("../../../lib/pg/host");
6
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
7
7
  const backups_1 = require("../../../lib/pg/backups");
8
8
  const lodash_1 = require("lodash");
9
9
  const download_1 = require("../../../lib/pg/download");
@@ -32,7 +32,7 @@ class Download extends command_1.Command {
32
32
  throw new Error(`Invalid Backup: ${backup_id}`);
33
33
  }
34
34
  else {
35
- const { body: transfers } = await this.heroku.get(`/client/v11/apps/${app}/transfers`, { hostname: (0, host_1.default)() });
35
+ const { body: transfers } = await this.heroku.get(`/client/v11/apps/${app}/transfers`, { hostname: heroku_cli_util_1.utils.pg.host() });
36
36
  const lastBackup = (0, lodash_1.sortBy)(transfers.filter(t => t.succeeded && t.to_type === 'gof3r'), 'created_at')
37
37
  .pop();
38
38
  if (!lastBackup)
@@ -40,7 +40,7 @@ class Download extends command_1.Command {
40
40
  num = lastBackup.num;
41
41
  }
42
42
  core_1.ux.action.status = `fetching url of #${num}`;
43
- const { body: info } = await this.heroku.post(`/client/v11/apps/${app}/transfers/${num}/actions/public-url`, { hostname: (0, host_1.default)() });
43
+ const { body: info } = await this.heroku.post(`/client/v11/apps/${app}/transfers/${num}/actions/public-url`, { hostname: heroku_cli_util_1.utils.pg.host() });
44
44
  core_1.ux.action.stop(`done, #${num}`);
45
45
  await (0, download_1.default)(info.url, output, { progress: true });
46
46
  }
@@ -5,11 +5,11 @@ const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
7
7
  const backups_1 = require("../../../lib/pg/backups");
8
- const host_1 = require("../../../lib/pg/host");
8
+ const heroku_cli_util_2 = require("@heroku/heroku-cli-util");
9
9
  class Index extends command_1.Command {
10
10
  async run() {
11
11
  const { flags: { app } } = await this.parse(Index);
12
- const { body: transfers } = await this.heroku.get(`/client/v11/apps/${app}/transfers`, { hostname: (0, host_1.default)() });
12
+ const { body: transfers } = await this.heroku.get(`/client/v11/apps/${app}/transfers`, { hostname: heroku_cli_util_2.utils.pg.host() });
13
13
  // NOTE that the sort order is descending
14
14
  transfers.sort((transferA, transferB) => {
15
15
  if (transferA.created_at > transferB.created_at) {
@@ -4,7 +4,7 @@ const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
7
- const host_1 = require("../../../lib/pg/host");
7
+ const heroku_cli_util_2 = require("@heroku/heroku-cli-util");
8
8
  const backups_1 = require("../../../lib/pg/backups");
9
9
  const lodash_1 = require("lodash");
10
10
  function status(backup) {
@@ -41,7 +41,7 @@ class Info extends command_1.Command {
41
41
  throw new Error(`Invalid ID: ${id}`);
42
42
  }
43
43
  else {
44
- let { body: transfers } = await this.heroku.get(`/client/v11/apps/${app}/transfers`, { hostname: (0, host_1.default)() });
44
+ let { body: transfers } = await this.heroku.get(`/client/v11/apps/${app}/transfers`, { hostname: heroku_cli_util_2.utils.pg.host() });
45
45
  transfers = (0, lodash_1.sortBy)(transfers, 'created_at');
46
46
  const backups = transfers.filter(t => t.from_type === 'pg_dump' && t.to_type === 'gof3r');
47
47
  const lastBackup = backups.pop();
@@ -49,7 +49,7 @@ class Info extends command_1.Command {
49
49
  throw new Error(`No backups. Capture one with ${color_1.default.cyan.bold('heroku pg:backups:capture')}`);
50
50
  backupID = lastBackup.num;
51
51
  }
52
- const { body: backup } = await this.heroku.get(`/client/v11/apps/${app}/transfers/${backupID}?verbose=true`, { hostname: (0, host_1.default)() });
52
+ const { body: backup } = await this.heroku.get(`/client/v11/apps/${app}/transfers/${backupID}?verbose=true`, { hostname: heroku_cli_util_2.utils.pg.host() });
53
53
  return backup;
54
54
  };
55
55
  this.displayBackup = (backup, app) => {
@@ -6,8 +6,7 @@ const core_1 = require("@oclif/core");
6
6
  const tsheredoc_1 = require("tsheredoc");
7
7
  const confirmCommand_1 = require("../../../lib/confirmCommand");
8
8
  const backups_1 = require("../../../lib/pg/backups");
9
- const fetcher_1 = require("../../../lib/pg/fetcher");
10
- const host_1 = require("../../../lib/pg/host");
9
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
11
10
  const nls_1 = require("../../../nls");
12
11
  function dropboxURL(url) {
13
12
  if (url.match(/^https?:\/\/www\.dropbox\.com/) && !url.endsWith('dl=1')) {
@@ -25,7 +24,8 @@ class Restore extends command_1.Command {
25
24
  const { flags, args } = await this.parse(Restore);
26
25
  const { app, 'wait-interval': waitInterval, extensions, confirm, verbose } = flags;
27
26
  const interval = Math.max(3, waitInterval);
28
- const { addon: db } = await (0, fetcher_1.getAttachment)(this.heroku, app, args.database);
27
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
28
+ const { addon: db } = await dbResolver.getAttachment(app, args.database);
29
29
  const { name, wait } = (0, backups_1.default)(app, this.heroku);
30
30
  let backupURL;
31
31
  let backupName = args.backup;
@@ -40,7 +40,7 @@ class Restore extends command_1.Command {
40
40
  else {
41
41
  backupApp = app;
42
42
  }
43
- const { body: transfers } = await this.heroku.get(`/client/v11/apps/${backupApp}/transfers`, { hostname: (0, host_1.default)() });
43
+ const { body: transfers } = await this.heroku.get(`/client/v11/apps/${backupApp}/transfers`, { hostname: heroku_cli_util_1.utils.pg.host() });
44
44
  const backups = transfers.filter(t => t.from_type === 'pg_dump' && t.to_type === 'gof3r');
45
45
  let backup;
46
46
  if (backupName) {
@@ -76,7 +76,7 @@ class Restore extends command_1.Command {
76
76
  Stop a running restore with ${color_1.default.cyan.bold('heroku pg:backups:cancel')}.
77
77
  `));
78
78
  const { body: restore } = await this.heroku.post(`/client/v11/databases/${db.id}/restores`, {
79
- body: { backup_url: backupURL, extensions: this.getSortedExtensions(extensions) }, hostname: (0, host_1.default)(),
79
+ body: { backup_url: backupURL, extensions: this.getSortedExtensions(extensions) }, hostname: heroku_cli_util_1.utils.pg.host(),
80
80
  });
81
81
  core_1.ux.action.stop();
82
82
  await wait('Restoring', restore.uuid, interval, verbose, db.app.id);
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
- const host_1 = require("../../../lib/pg/host");
7
- const fetcher_1 = require("../../../lib/pg/fetcher");
6
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
8
7
  const nls_1 = require("../../../nls");
9
8
  const TZ = {
10
9
  PST: 'America/Los_Angeles',
@@ -39,10 +38,11 @@ class Schedule extends command_1.Command {
39
38
  const { app } = flags;
40
39
  const { database } = args;
41
40
  const schedule = this.parseDate(flags.at);
42
- const attachment = await (0, fetcher_1.getAttachment)(this.heroku, app, database);
43
- const db = attachment.addon;
41
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
42
+ const attachment = await dbResolver.getAttachment(app, database);
43
+ const { addon: db, name } = attachment;
44
44
  const at = color_1.default.cyan(`${schedule.hour}:00 ${schedule.timezone}`);
45
- const pgResponse = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: (0, host_1.default)() })
45
+ const pgResponse = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: heroku_cli_util_1.utils.pg.host() })
46
46
  .catch((error) => {
47
47
  if (error.statusCode !== 404)
48
48
  throw error;
@@ -57,9 +57,9 @@ class Schedule extends command_1.Command {
57
57
  }
58
58
  }
59
59
  core_1.ux.action.start(`Scheduling automatic daily backups of ${color_1.default.yellow(db.name)} at ${at}`);
60
- schedule.schedule_name = attachment.name + '_URL';
60
+ schedule.schedule_name = name + '_URL';
61
61
  await this.heroku.post(`/client/v11/databases/${db.id}/transfer-schedules`, {
62
- body: schedule, hostname: (0, host_1.default)(),
62
+ body: schedule, hostname: heroku_cli_util_1.utils.pg.host(),
63
63
  });
64
64
  core_1.ux.action.stop();
65
65
  }
@@ -4,14 +4,14 @@ const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
7
- const host_1 = require("../../../lib/pg/host");
7
+ const heroku_cli_util_2 = require("@heroku/heroku-cli-util");
8
8
  const fetcher_1 = require("../../../lib/pg/fetcher");
9
9
  class Schedules extends command_1.Command {
10
10
  async run() {
11
11
  const { flags } = await this.parse(Schedules);
12
12
  const { app } = flags;
13
13
  const db = await (0, fetcher_1.arbitraryAppDB)(this.heroku, app);
14
- const { body: schedules } = await this.heroku.get(`/client/v11/databases/${db.id}/transfer-schedules`, { hostname: (0, host_1.default)() });
14
+ const { body: schedules } = await this.heroku.get(`/client/v11/databases/${db.id}/transfer-schedules`, { hostname: heroku_cli_util_2.utils.pg.host() });
15
15
  if (schedules.length === 0) {
16
16
  core_1.ux.warn(`No backup schedules found on ${color_1.default.app(app)}\nUse ${color_1.default.cyan.bold('heroku pg:backups:schedule')} to set one up`);
17
17
  }
@@ -4,7 +4,7 @@ const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const fetcher_1 = require("../../../lib/pg/fetcher");
7
- const host_1 = require("../../../lib/pg/host");
7
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
8
8
  const nls_1 = require("../../../nls");
9
9
  class Unschedule extends command_1.Command {
10
10
  async run() {
@@ -14,7 +14,7 @@ class Unschedule extends command_1.Command {
14
14
  let db = database;
15
15
  if (!db) {
16
16
  const appDB = await (0, fetcher_1.arbitraryAppDB)(this.heroku, app);
17
- const { body: schedules } = await this.heroku.get(`/client/v11/databases/${appDB.id}/transfer-schedules`, { hostname: (0, host_1.default)() });
17
+ const { body: schedules } = await this.heroku.get(`/client/v11/databases/${appDB.id}/transfer-schedules`, { hostname: heroku_cli_util_1.utils.pg.host() });
18
18
  if (schedules.length === 0)
19
19
  throw new Error(`No schedules on ${color_1.default.app(app)}`);
20
20
  if (schedules.length > 1) {
@@ -24,12 +24,13 @@ class Unschedule extends command_1.Command {
24
24
  db = schedules[0].name;
25
25
  }
26
26
  core_1.ux.action.start(`Unscheduling ${color_1.default.green(db)} daily backups`);
27
- const addon = await (0, fetcher_1.getAddon)(this.heroku, app, db);
28
- const { body: schedules } = await this.heroku.get(`/client/v11/databases/${addon.id}/transfer-schedules`, { hostname: (0, host_1.default)() });
27
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
28
+ const { addon } = await dbResolver.getAttachment(app, db);
29
+ const { body: schedules } = await this.heroku.get(`/client/v11/databases/${addon.id}/transfer-schedules`, { hostname: heroku_cli_util_1.utils.pg.host() });
29
30
  const schedule = schedules.find(s => s.name.match(new RegExp(`${db}`, 'i')));
30
31
  if (!schedule)
31
32
  throw new Error(`No daily backups found for ${color_1.default.yellow(addon.name)}`);
32
- await this.heroku.delete(`/client/v11/databases/${addon.id}/transfer-schedules/${schedule.uuid}`, { hostname: (0, host_1.default)() });
33
+ await this.heroku.delete(`/client/v11/databases/${addon.id}/transfer-schedules/${schedule.uuid}`, { hostname: heroku_cli_util_1.utils.pg.host() });
33
34
  core_1.ux.action.stop();
34
35
  }
35
36
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
- const host_1 = require("../../../lib/pg/host");
6
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
7
7
  const backups_1 = require("../../../lib/pg/backups");
8
8
  const lodash_1 = require("lodash");
9
9
  class Url extends command_1.Command {
@@ -18,14 +18,14 @@ class Url extends command_1.Command {
18
18
  throw new Error(`Invalid Backup: ${backup_id}`);
19
19
  }
20
20
  else {
21
- const { body: transfers } = await this.heroku.get(`/client/v11/apps/${app}/transfers`, { hostname: (0, host_1.default)() });
21
+ const { body: transfers } = await this.heroku.get(`/client/v11/apps/${app}/transfers`, { hostname: heroku_cli_util_1.utils.pg.host() });
22
22
  const lastBackup = (0, lodash_1.sortBy)(transfers.filter(t => t.succeeded && t.to_type === 'gof3r'), 'created_at')
23
23
  .pop();
24
24
  if (!lastBackup)
25
25
  throw new Error(`No backups on ${color_1.default.app(app)}. Capture one with ${color_1.default.cyan.bold('heroku pg:backups:capture')}`);
26
26
  num = lastBackup.num;
27
27
  }
28
- const { body: info } = await this.heroku.post(`/client/v11/apps/${app}/transfers/${num}/actions/public-url`, { hostname: (0, host_1.default)() });
28
+ const { body: info } = await this.heroku.post(`/client/v11/apps/${app}/transfers/${num}/actions/public-url`, { hostname: heroku_cli_util_1.utils.pg.host() });
29
29
  core_1.ux.log(info.url);
30
30
  }
31
31
  }
@@ -2,8 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const command_1 = require("@heroku-cli/command");
4
4
  const core_1 = require("@oclif/core");
5
- const fetcher_1 = require("../../lib/pg/fetcher");
6
- const psql_1 = require("../../lib/pg/psql");
5
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
7
6
  const nls_1 = require("../../nls");
8
7
  const query = `
9
8
  WITH constants AS (
@@ -71,8 +70,10 @@ class Bloat extends command_1.Command {
71
70
  async run() {
72
71
  const { flags, args } = await this.parse(Bloat);
73
72
  const { app } = flags;
74
- const db = await (0, fetcher_1.database)(this.heroku, app, args.database);
75
- const output = await (0, psql_1.exec)(db, query);
73
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
74
+ const db = await dbResolver.getDatabase(app, args.database);
75
+ const psqlService = new heroku_cli_util_1.utils.pg.PsqlService(db);
76
+ const output = await psqlService.execQuery(query);
76
77
  process.stdout.write(output);
77
78
  }
78
79
  }
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const command_1 = require("@heroku-cli/command");
4
4
  const core_1 = require("@oclif/core");
5
5
  const tsheredoc_1 = require("tsheredoc");
6
- const fetcher_1 = require("../../lib/pg/fetcher");
7
- const psql_1 = require("../../lib/pg/psql");
6
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
8
7
  const nls_1 = require("../../nls");
9
8
  class Blocking extends command_1.Command {
10
9
  async run() {
@@ -26,8 +25,10 @@ class Blocking extends command_1.Command {
26
25
  ON bl.transactionid = kl.transactionid AND bl.pid != kl.pid
27
26
  WHERE NOT bl.granted
28
27
  `;
29
- const db = await (0, fetcher_1.database)(this.heroku, app, args.database);
30
- const output = await (0, psql_1.exec)(db, query);
28
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
29
+ const db = await dbResolver.getDatabase(app, args.database);
30
+ const psqlService = new heroku_cli_util_1.utils.pg.PsqlService(db);
31
+ const output = await psqlService.execQuery(query);
31
32
  core_1.ux.log(output);
32
33
  }
33
34
  }
@@ -3,22 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
- const host_1 = require("../../../lib/pg/host");
7
6
  const tsheredoc_1 = require("tsheredoc");
8
7
  const util_1 = require("../../../lib/pg/util");
9
- const fetcher_1 = require("../../../lib/pg/fetcher");
8
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
10
9
  const nls_1 = require("../../../nls");
11
10
  class Attach extends command_1.Command {
12
11
  async run() {
13
12
  const { flags, args } = await this.parse(Attach);
14
13
  const { app } = flags;
15
- const db = await (0, fetcher_1.getAddon)(this.heroku, app, args.database);
16
- const { body: addon } = await this.heroku.get(`/addons/${encodeURIComponent(db.name)}`);
14
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
15
+ const { addon: db } = await dbResolver.getAttachment(app, args.database);
17
16
  if ((0, util_1.essentialPlan)(db))
18
17
  core_1.ux.error('You can’t perform this operation on Essential-tier databases.');
19
- core_1.ux.action.start(`Enabling Connection Pooling on ${color_1.default.yellow(addon.name)} to ${color_1.default.magenta(app)}`);
18
+ core_1.ux.action.start(`Enabling Connection Pooling on ${color_1.default.yellow(db.name)} to ${color_1.default.magenta(app)}`);
20
19
  const { body: attachment } = await this.heroku.post(`/client/v11/databases/${encodeURIComponent(db.name)}/connection-pooling`, {
21
- body: { name: flags.as, credential: 'default', app: app }, hostname: (0, host_1.default)(),
20
+ body: { name: flags.as, credential: 'default', app: app }, hostname: heroku_cli_util_1.utils.pg.host(),
22
21
  });
23
22
  core_1.ux.action.stop();
24
23
  core_1.ux.action.start(`Setting ${color_1.default.cyan(attachment.name)} config vars and restarting ${color_1.default.magenta(app)}`);
@@ -3,14 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
- const host_1 = require("../../lib/pg/host");
7
6
  const backups_1 = require("../../lib/pg/backups");
8
- const fetcher_1 = require("../../lib/pg/fetcher");
9
- const util_1 = require("../../lib/pg/util");
7
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
10
8
  const confirmCommand_1 = require("../../lib/confirmCommand");
11
9
  const getAttachmentInfo = async function (heroku, db, app) {
10
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(heroku);
12
11
  if (db.match(/^postgres:\/\//)) {
13
- const conn = (0, util_1.parsePostgresConnectionString)(db);
12
+ const conn = heroku_cli_util_1.utils.pg.DatabaseResolver.parsePostgresConnectionString(db);
14
13
  const host = `${conn.host}:${conn.port}`;
15
14
  return {
16
15
  name: conn.database ? `database ${conn.database} on ${host}` : `database on ${host}`,
@@ -18,7 +17,7 @@ const getAttachmentInfo = async function (heroku, db, app) {
18
17
  confirm: conn.database || conn.host,
19
18
  };
20
19
  }
21
- const attachment = await (0, fetcher_1.getAttachment)(heroku, app, db);
20
+ const attachment = await dbResolver.getAttachment(app, db);
22
21
  if (!attachment)
23
22
  throw new Error(`${db} not found on ${color_1.default.magenta(app)}`);
24
23
  const { body: addon } = await heroku.get(`/addons/${attachment.addon.name}`);
@@ -52,12 +51,12 @@ class Copy extends command_1.Command {
52
51
  body: {
53
52
  from_name: source.name, from_url: source.url, to_name: target.name, to_url: target.url,
54
53
  },
55
- hostname: (0, host_1.default)(),
54
+ hostname: heroku_cli_util_1.utils.pg.host(),
56
55
  });
57
56
  core_1.ux.action.stop();
58
57
  if (source.attachment) {
59
58
  const { body: credentials } = await this.heroku.get(`/postgres/v0/databases/${source.attachment.addon.name}/credentials`, {
60
- hostname: (0, host_1.default)(),
59
+ hostname: heroku_cli_util_1.utils.pg.host(),
61
60
  headers: {
62
61
  Authorization: `Basic ${Buffer.from(`:${this.heroku.auth}`).toString('base64')}`,
63
62
  },
@@ -4,21 +4,21 @@ const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const tsheredoc_1 = require("tsheredoc");
7
- const fetcher_1 = require("../../../lib/pg/fetcher");
8
- const host_1 = require("../../../lib/pg/host");
7
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
9
8
  const util_1 = require("../../../lib/pg/util");
10
9
  const nls_1 = require("../../../nls");
11
10
  class Create extends command_1.Command {
12
11
  async run() {
13
12
  const { flags, args } = await this.parse(Create);
14
13
  const { app, name } = flags;
15
- const { addon: db } = await (0, fetcher_1.getAttachment)(this.heroku, app, args.database);
14
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
15
+ const { addon: db } = await dbResolver.getAttachment(app, args.database);
16
16
  if ((0, util_1.essentialPlan)(db)) {
17
17
  throw new Error("You can't create a custom credential on Essential-tier databases.");
18
18
  }
19
19
  const data = { name };
20
20
  core_1.ux.action.start(`Creating credential ${color_1.default.cyan.bold(name)}`);
21
- await this.heroku.post(`/postgres/v0/databases/${db.name}/credentials`, { hostname: (0, host_1.default)(), body: data });
21
+ await this.heroku.post(`/postgres/v0/databases/${db.name}/credentials`, { hostname: heroku_cli_util_1.utils.pg.host(), body: data });
22
22
  core_1.ux.action.stop();
23
23
  const attachCmd = `heroku addons:attach ${db.name} --credential ${name} -a ${app}`;
24
24
  const psqlCmd = `heroku pg:psql ${db.name} -a ${app}`;
@@ -4,8 +4,7 @@ const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const util_1 = require("../../../lib/pg/util");
7
- const fetcher_1 = require("../../../lib/pg/fetcher");
8
- const host_1 = require("../../../lib/pg/host");
7
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
9
8
  const confirmCommand_1 = require("../../../lib/confirmCommand");
10
9
  const nls_1 = require("../../../nls");
11
10
  class Destroy extends command_1.Command {
@@ -16,7 +15,8 @@ class Destroy extends command_1.Command {
16
15
  if (name === 'default') {
17
16
  throw new Error('Default credential cannot be destroyed.');
18
17
  }
19
- const db = await (0, fetcher_1.getAddon)(this.heroku, app, database);
18
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
19
+ const { addon: db } = await dbResolver.getAttachment(app, database);
20
20
  if ((0, util_1.essentialPlan)(db)) {
21
21
  throw new Error("You can't destroy the default credential on Essential-tier databases.");
22
22
  }
@@ -28,7 +28,7 @@ class Destroy extends command_1.Command {
28
28
  .join(', ')} before destroying.`);
29
29
  await (0, confirmCommand_1.default)(app, confirm);
30
30
  core_1.ux.action.start(`Destroying credential ${color_1.default.cyan.bold(name)}`);
31
- await this.heroku.delete(`/postgres/v0/databases/${db.name}/credentials/${encodeURIComponent(name)}`, { hostname: (0, host_1.default)() });
31
+ await this.heroku.delete(`/postgres/v0/databases/${db.name}/credentials/${encodeURIComponent(name)}`, { hostname: heroku_cli_util_1.utils.pg.host() });
32
32
  core_1.ux.action.stop();
33
33
  core_1.ux.log(`The credential has been destroyed within ${db.name}.`);
34
34
  core_1.ux.log(`Database objects owned by ${name} will be assigned to the default credential.`);
@@ -2,18 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const command_1 = require("@heroku-cli/command");
4
4
  const core_1 = require("@oclif/core");
5
- const fetcher_1 = require("../../../lib/pg/fetcher");
5
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
6
6
  const util_1 = require("../../../lib/pg/util");
7
7
  const confirmCommand_1 = require("../../../lib/confirmCommand");
8
8
  const tsheredoc_1 = require("tsheredoc");
9
- const host_1 = require("../../../lib/pg/host");
10
9
  const nls_1 = require("../../../nls");
11
10
  class RepairDefault extends command_1.Command {
12
11
  async run() {
13
12
  const { flags, args } = await this.parse(RepairDefault);
14
13
  const { app, confirm } = flags;
15
14
  const { database } = args;
16
- const db = await (0, fetcher_1.getAddon)(this.heroku, app, database);
15
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
16
+ const { addon: db } = await dbResolver.getAttachment(app, database);
17
17
  if ((0, util_1.essentialPlan)(db))
18
18
  throw new Error("You can't perform this operation on Essential-tier databases.");
19
19
  await (0, confirmCommand_1.default)(app, confirm, (0, tsheredoc_1.default)(`
@@ -22,7 +22,7 @@ class RepairDefault extends command_1.Command {
22
22
  This command will also grant the default credential admin option for all additional credentials.
23
23
  `));
24
24
  core_1.ux.action.start('Resetting permissions and object ownership for default role to factory settings');
25
- await this.heroku.post(`/postgres/v0/databases/${db.name}/repair-default`, { hostname: (0, host_1.default)() });
25
+ await this.heroku.post(`/postgres/v0/databases/${db.name}/repair-default`, { hostname: heroku_cli_util_1.utils.pg.host() });
26
26
  core_1.ux.action.stop();
27
27
  }
28
28
  }
@@ -4,15 +4,15 @@ const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const confirmCommand_1 = require("../../../lib/confirmCommand");
7
- const fetcher_1 = require("../../../lib/pg/fetcher");
8
- const host_1 = require("../../../lib/pg/host");
7
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
9
8
  const util_1 = require("../../../lib/pg/util");
10
9
  const nls_1 = require("../../../nls");
11
10
  class Rotate extends command_1.Command {
12
11
  async run() {
13
12
  const { flags, args } = await this.parse(Rotate);
14
13
  const { app, all, confirm, name, force } = flags;
15
- const { addon: db } = await (0, fetcher_1.getAttachment)(this.heroku, app, args.database);
14
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
15
+ const { addon: db } = await dbResolver.getAttachment(app, args.database);
16
16
  const warnings = [];
17
17
  const cred = name || 'default';
18
18
  if (all && name !== undefined) {
@@ -48,7 +48,7 @@ class Rotate extends command_1.Command {
48
48
  }
49
49
  await (0, confirmCommand_1.default)(app, confirm, `Destructive Action\n${warnings.join('\n')}`);
50
50
  const options = {
51
- hostname: (0, host_1.default)(),
51
+ hostname: heroku_cli_util_1.utils.pg.host(),
52
52
  body: { forced: force !== null && force !== void 0 ? force : undefined },
53
53
  headers: {
54
54
  Authorization: `Basic ${Buffer.from(`:${this.heroku.auth}`).toString('base64')}`,
@@ -4,8 +4,7 @@ const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const util_1 = require("../../../lib/pg/util");
7
- const fetcher_1 = require("../../../lib/pg/fetcher");
8
- const host_1 = require("../../../lib/pg/host");
7
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
9
8
  const url_1 = require("url");
10
9
  const tsheredoc_1 = require("tsheredoc");
11
10
  const nls_1 = require("../../../nls");
@@ -14,12 +13,13 @@ class Url extends command_1.Command {
14
13
  const { flags, args } = await this.parse(Url);
15
14
  const { app, name } = flags;
16
15
  const { database } = args;
17
- const db = await (0, fetcher_1.getAddon)(this.heroku, app, database);
16
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
17
+ const { addon: db } = await dbResolver.getAttachment(app, database);
18
18
  if ((0, util_1.legacyEssentialPlan)(db) && name !== 'default') {
19
19
  core_1.ux.error('Legacy Essential-tier databases do not support named credentials.');
20
20
  }
21
21
  const { body: credInfo } = await this.heroku.get(`/postgres/v0/databases/${db.name}/credentials/${encodeURIComponent(name)}`, {
22
- hostname: (0, host_1.default)(),
22
+ hostname: heroku_cli_util_1.utils.pg.host(),
23
23
  headers: {
24
24
  Authorization: `Basic ${Buffer.from(`:${this.heroku.auth}`).toString('base64')}`,
25
25
  },
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const command_1 = require("@heroku-cli/command");
4
4
  const core_1 = require("@oclif/core");
5
5
  const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
6
- const host_1 = require("../../lib/pg/host");
7
- const fetcher_1 = require("../../lib/pg/fetcher");
6
+ const heroku_cli_util_2 = require("@heroku/heroku-cli-util");
8
7
  const util_1 = require("../../lib/pg/util");
9
8
  const nls_1 = require("../../nls");
10
9
  class Credentials extends command_1.Command {
@@ -12,9 +11,10 @@ class Credentials extends command_1.Command {
12
11
  const { flags, args } = await this.parse(Credentials);
13
12
  const { app } = flags;
14
13
  const { database } = args;
15
- const addon = await (0, fetcher_1.getAddon)(this.heroku, app, database);
14
+ const dbResolver = new heroku_cli_util_2.utils.pg.DatabaseResolver(this.heroku);
15
+ const { addon } = await dbResolver.getAttachment(app, database);
16
16
  const { body: credentials } = await this.heroku.get(`/postgres/v0/databases/${addon.id}/credentials`, {
17
- hostname: (0, host_1.default)(),
17
+ hostname: heroku_cli_util_2.utils.pg.host(),
18
18
  headers: {
19
19
  Authorization: `Basic ${Buffer.from(`:${this.heroku.auth}`).toString('base64')}`,
20
20
  },