@heroku/sdk 0.6.1 → 0.6.3

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.
@@ -1,14 +1,16 @@
1
1
  import type { DashboardBackendClient } from '../services/dashboard-backend.js';
2
2
  import type { DataClient } from '../services/data.js';
3
3
  import type { MetricsClient } from '../services/metrics.js';
4
+ import type { NotificationsClient } from '../services/notifications.js';
4
5
  import type { PlatformClient } from '../services/platform.js';
5
6
  import type { RepositoriesApiClient } from '../services/repositories-api.js';
6
7
  import type { RepositoriesClient } from '../services/repositories.js';
7
- export type ServiceName = 'dashboardBackend' | 'data' | 'metrics' | 'platform' | 'repositories' | 'repositoriesApi';
8
+ export type ServiceName = 'dashboardBackend' | 'data' | 'metrics' | 'notifications' | 'platform' | 'repositories' | 'repositoriesApi';
8
9
  type BaseResourceCtx = {
9
10
  dashboardBackend: DashboardBackendClient;
10
11
  data: DataClient;
11
12
  metrics: MetricsClient;
13
+ notifications: NotificationsClient;
12
14
  platform: PlatformClient;
13
15
  repositories: RepositoriesClient;
14
16
  };
@@ -2,6 +2,7 @@ import type { HerokuApiClientOptions } from '@heroku/heroku-fetch';
2
2
  import type { DashboardBackendClient } from '../services/dashboard-backend.js';
3
3
  import type { DataClient } from '../services/data.js';
4
4
  import type { MetricsClient } from '../services/metrics.js';
5
+ import type { NotificationsClient } from '../services/notifications.js';
5
6
  import type { PlatformClient } from '../services/platform.js';
6
7
  import type { RepositoriesApiClient } from '../services/repositories-api.js';
7
8
  import type { RepositoriesClient } from '../services/repositories.js';
@@ -21,6 +22,7 @@ export declare class HerokuSDK<const Exts extends readonly ResourceExtension[] =
21
22
  get dashboardBackend(): ApplyExtensions<DashboardBackendClient, ExtensionsFor<Exts, 'dashboardBackend'>>;
22
23
  get data(): ApplyExtensions<DataClient, ExtensionsFor<Exts, 'data'>>;
23
24
  get metrics(): ApplyExtensions<MetricsClient, ExtensionsFor<Exts, 'metrics'>>;
25
+ get notifications(): ApplyExtensions<NotificationsClient, ExtensionsFor<Exts, 'notifications'>>;
24
26
  get platform(): ApplyExtensions<PlatformClient, ExtensionsFor<Exts, 'platform'>>;
25
27
  get repositories(): ApplyExtensions<RepositoriesClient, ExtensionsFor<Exts, 'repositories'>>;
26
28
  get repositoriesApi(): ApplyExtensions<RepositoriesApiClient, ExtensionsFor<Exts, 'repositoriesApi'>>;
@@ -1,6 +1,7 @@
1
1
  import { createDashboardBackendClient } from '../services/dashboard-backend.js';
2
2
  import { createDataClient } from '../services/data.js';
3
3
  import { createMetricsClient } from '../services/metrics.js';
4
+ import { createNotificationsClient } from '../services/notifications.js';
4
5
  import { createPlatformClient } from '../services/platform.js';
5
6
  import { createRepositoriesApiClient } from '../services/repositories-api.js';
6
7
  import { createRepositoriesClient } from '../services/repositories.js';
@@ -22,10 +23,12 @@ export class HerokuSDK {
22
23
  #data;
23
24
  #extensionsByService;
24
25
  #metrics;
26
+ #notifications;
25
27
  #platform;
26
28
  #rawDashboardBackend;
27
29
  #rawData;
28
30
  #rawMetrics;
31
+ #rawNotifications;
29
32
  #rawPlatform;
30
33
  #rawRepositories;
31
34
  #rawRepositoriesApi;
@@ -48,6 +51,10 @@ export class HerokuSDK {
48
51
  this.#metrics ??= mergeExtensions(this.#getRawMetrics(), this.#extensionsByService.get('metrics') ?? [], this.#getCtx());
49
52
  return this.#metrics;
50
53
  }
54
+ get notifications() {
55
+ this.#notifications ??= mergeExtensions(this.#getRawNotifications(), this.#extensionsByService.get('notifications') ?? [], this.#getCtx());
56
+ return this.#notifications;
57
+ }
51
58
  get platform() {
52
59
  this.#platform ??= mergeExtensions(this.#getRawPlatform(), this.#extensionsByService.get('platform') ?? [], this.#getCtx());
53
60
  return this.#platform;
@@ -83,6 +90,10 @@ export class HerokuSDK {
83
90
  enumerable: true,
84
91
  get: () => this.#getRawMetrics(),
85
92
  },
93
+ notifications: {
94
+ enumerable: true,
95
+ get: () => this.#getRawNotifications(),
96
+ },
86
97
  platform: {
87
98
  enumerable: true,
88
99
  get: () => this.#getRawPlatform(),
@@ -110,6 +121,10 @@ export class HerokuSDK {
110
121
  this.#rawMetrics ??= createMetricsClient(this.#getClientOptions('metrics'));
111
122
  return this.#rawMetrics;
112
123
  }
124
+ #getRawNotifications() {
125
+ this.#rawNotifications ??= createNotificationsClient(this.#clientOptions);
126
+ return this.#rawNotifications;
127
+ }
113
128
  #getRawPlatform() {
114
129
  this.#rawPlatform ??= createPlatformClient(this.#getClientOptions('platform'));
115
130
  return this.#rawPlatform;
@@ -1,11 +1,8 @@
1
- import type { DatabaseInfoResult } from '@heroku/types/data';
1
+ import type { DatabaseCancelUpgradeResult, DatabaseDryRunUpgradeOpts, DatabaseDryRunUpgradeResult, DatabaseInfoResult, DatabasePrepareUpgradeOpts, DatabasePrepareUpgradeResult, DatabaseRunUpgradeOpts, DatabaseRunUpgradeResult, DatabaseUpgradeWaitStatusResult } from '@heroku/types/data';
2
2
  import type { ResourceCtx } from '../../core/extend-resource.js';
3
3
  export type DatabaseOptions = {
4
4
  signal?: AbortSignal;
5
5
  };
6
- export type DatabaseUpgradeBody = {
7
- version?: string;
8
- };
9
6
  export type DatabaseDescribeResult = DatabaseInfoResult & {
10
7
  following?: string;
11
8
  'hot_standby?'?: boolean;
@@ -14,41 +11,17 @@ export type DatabaseDescribeResult = DatabaseInfoResult & {
14
11
  postgres_version?: string;
15
12
  'standalone?'?: boolean;
16
13
  };
17
- export type DatabaseUpgradeWaitResult = {
18
- 'error?': boolean;
19
- message: string;
20
- step: string;
21
- 'waiting?': boolean;
22
- };
23
- export type DatabaseUpgradeResponse = {
24
- message: string;
25
- };
26
- type DatabaseDataClient = {
27
- database: {
28
- cancelUpgrade(name: string): Promise<DatabaseUpgradeResponse>;
29
- dryRunUpgrade(name: string, body: DatabaseUpgradeBody): Promise<DatabaseUpgradeResponse>;
30
- info(name: string): Promise<DatabaseDescribeResult>;
31
- prepareUpgrade(name: string, body: DatabaseUpgradeBody): Promise<DatabaseUpgradeResponse>;
32
- runUpgrade(name: string, body: DatabaseUpgradeBody): Promise<DatabaseUpgradeResponse>;
33
- upgradeWaitStatus(name: string): Promise<DatabaseUpgradeWaitResult>;
34
- };
35
- };
36
- type DatabaseCtx = {
37
- data: DatabaseDataClient;
38
- platform: ResourceCtx['platform'];
39
- };
40
- export declare function describe(ctx: DatabaseCtx, appIdentity: string, addonIdentity?: string, options?: DatabaseOptions): Promise<DatabaseDescribeResult>;
41
- export declare function upgradeWaitStatus(ctx: DatabaseCtx, appIdentity: string, addonIdentity?: string, options?: DatabaseOptions): Promise<DatabaseUpgradeWaitResult>;
42
- export declare function dryRunUpgrade(ctx: DatabaseCtx, appIdentity: string, addonIdentity?: string, body?: DatabaseUpgradeBody, options?: DatabaseOptions): Promise<DatabaseUpgradeResponse>;
43
- export declare function runUpgrade(ctx: DatabaseCtx, appIdentity: string, addonIdentity?: string, body?: DatabaseUpgradeBody, options?: DatabaseOptions): Promise<DatabaseUpgradeResponse>;
44
- export declare function prepareUpgrade(ctx: DatabaseCtx, appIdentity: string, addonIdentity?: string, body?: DatabaseUpgradeBody, options?: DatabaseOptions): Promise<DatabaseUpgradeResponse>;
45
- export declare function cancelUpgrade(ctx: DatabaseCtx, appIdentity: string, addonIdentity?: string, options?: DatabaseOptions): Promise<DatabaseUpgradeResponse>;
14
+ export declare function describe(ctx: Pick<ResourceCtx, 'data' | 'platform'>, appIdentity: string, addonIdentity?: string, options?: DatabaseOptions): Promise<DatabaseDescribeResult>;
15
+ export declare function upgradeWaitStatus(ctx: Pick<ResourceCtx, 'data' | 'platform'>, appIdentity: string, addonIdentity?: string, options?: DatabaseOptions): Promise<DatabaseUpgradeWaitStatusResult>;
16
+ export declare function dryRunUpgrade(ctx: Pick<ResourceCtx, 'data' | 'platform'>, appIdentity: string, addonIdentity?: string, body?: DatabaseDryRunUpgradeOpts, options?: DatabaseOptions): Promise<DatabaseDryRunUpgradeResult>;
17
+ export declare function runUpgrade(ctx: Pick<ResourceCtx, 'data' | 'platform'>, appIdentity: string, addonIdentity?: string, body?: DatabaseRunUpgradeOpts, options?: DatabaseOptions): Promise<DatabaseRunUpgradeResult>;
18
+ export declare function prepareUpgrade(ctx: Pick<ResourceCtx, 'data' | 'platform'>, appIdentity: string, addonIdentity?: string, body?: DatabasePrepareUpgradeOpts, options?: DatabaseOptions): Promise<DatabasePrepareUpgradeResult>;
19
+ export declare function cancelUpgrade(ctx: Pick<ResourceCtx, 'data' | 'platform'>, appIdentity: string, addonIdentity?: string, options?: DatabaseOptions): Promise<DatabaseCancelUpgradeResult>;
46
20
  export declare const databaseExtensions: import("../../core/extend-resource.js").ResourceExtension<"data", "database", {
47
- cancelUpgrade: (appIdentity: string, addonIdentity?: string, options?: DatabaseOptions) => Promise<DatabaseUpgradeResponse>;
21
+ cancelUpgrade: (appIdentity: string, addonIdentity?: string, options?: DatabaseOptions) => Promise<DatabaseCancelUpgradeResult>;
48
22
  describe: (appIdentity: string, addonIdentity?: string, options?: DatabaseOptions) => Promise<DatabaseDescribeResult>;
49
- dryRunUpgrade: (appIdentity: string, addonIdentity?: string, body?: DatabaseUpgradeBody, options?: DatabaseOptions) => Promise<DatabaseUpgradeResponse>;
50
- prepareUpgrade: (appIdentity: string, addonIdentity?: string, body?: DatabaseUpgradeBody, options?: DatabaseOptions) => Promise<DatabaseUpgradeResponse>;
51
- runUpgrade: (appIdentity: string, addonIdentity?: string, body?: DatabaseUpgradeBody, options?: DatabaseOptions) => Promise<DatabaseUpgradeResponse>;
52
- upgradeWaitStatus: (appIdentity: string, addonIdentity?: string, options?: DatabaseOptions) => Promise<DatabaseUpgradeWaitResult>;
23
+ dryRunUpgrade: (appIdentity: string, addonIdentity?: string, body?: DatabaseDryRunUpgradeOpts, options?: DatabaseOptions) => Promise<DatabaseDryRunUpgradeResult>;
24
+ prepareUpgrade: (appIdentity: string, addonIdentity?: string, body?: DatabasePrepareUpgradeOpts, options?: DatabaseOptions) => Promise<DatabasePrepareUpgradeResult>;
25
+ runUpgrade: (appIdentity: string, addonIdentity?: string, body?: DatabaseRunUpgradeOpts, options?: DatabaseOptions) => Promise<DatabaseRunUpgradeResult>;
26
+ upgradeWaitStatus: (appIdentity: string, addonIdentity?: string, options?: DatabaseOptions) => Promise<DatabaseUpgradeWaitStatusResult>;
53
27
  }>;
54
- export {};
@@ -30,15 +30,11 @@ export async function cancelUpgrade(ctx, appIdentity, addonIdentity, options = {
30
30
  const addon = await resolvePgDatabase(ctx, { appIdentity, input: addonIdentity, ...options });
31
31
  return ctx.data.database.cancelUpgrade(addon.id);
32
32
  }
33
- export const databaseExtensions = extendResource('data', 'database', rawCtx => {
34
- // Bridge heroku-types' loose client types to the adapter's strongly-typed contract
35
- const ctx = rawCtx;
36
- return {
37
- cancelUpgrade: (appIdentity, addonIdentity, options) => cancelUpgrade(ctx, appIdentity, addonIdentity, options),
38
- describe: (appIdentity, addonIdentity, options) => describe(ctx, appIdentity, addonIdentity, options),
39
- dryRunUpgrade: (appIdentity, addonIdentity, body, options) => dryRunUpgrade(ctx, appIdentity, addonIdentity, body, options),
40
- prepareUpgrade: (appIdentity, addonIdentity, body, options) => prepareUpgrade(ctx, appIdentity, addonIdentity, body, options),
41
- runUpgrade: (appIdentity, addonIdentity, body, options) => runUpgrade(ctx, appIdentity, addonIdentity, body, options),
42
- upgradeWaitStatus: (appIdentity, addonIdentity, options) => upgradeWaitStatus(ctx, appIdentity, addonIdentity, options),
43
- };
44
- });
33
+ export const databaseExtensions = extendResource('data', 'database', ctx => ({
34
+ cancelUpgrade: (appIdentity, addonIdentity, options) => cancelUpgrade(ctx, appIdentity, addonIdentity, options),
35
+ describe: (appIdentity, addonIdentity, options) => describe(ctx, appIdentity, addonIdentity, options),
36
+ dryRunUpgrade: (appIdentity, addonIdentity, body, options) => dryRunUpgrade(ctx, appIdentity, addonIdentity, body, options),
37
+ prepareUpgrade: (appIdentity, addonIdentity, body, options) => prepareUpgrade(ctx, appIdentity, addonIdentity, body, options),
38
+ runUpgrade: (appIdentity, addonIdentity, body, options) => runUpgrade(ctx, appIdentity, addonIdentity, body, options),
39
+ upgradeWaitStatus: (appIdentity, addonIdentity, options) => upgradeWaitStatus(ctx, appIdentity, addonIdentity, options),
40
+ }));
@@ -16,17 +16,7 @@ export type CredentialInfo = {
16
16
  state: string;
17
17
  uuid: string;
18
18
  };
19
- type CredentialsDataClient = {
20
- postgresDatabase: {
21
- listCredentials(name: string): Promise<CredentialInfo[]>;
22
- };
23
- };
24
- type CredentialsCtx = {
25
- data: CredentialsDataClient;
26
- platform: ResourceCtx['platform'];
27
- };
28
- export declare function listCredentials(ctx: CredentialsCtx, appIdentity: string, addonIdentity?: string, options?: ListCredentialsOptions): Promise<CredentialInfo[]>;
19
+ export declare function listCredentials(ctx: Pick<ResourceCtx, 'data' | 'platform'>, appIdentity: string, addonIdentity?: string, options?: ListCredentialsOptions): Promise<CredentialInfo[]>;
29
20
  export declare const postgresDatabaseExtensions: import("../../core/extend-resource.js").ResourceExtension<"data", "postgresDatabase", {
30
21
  listCredentials: (appIdentity: string, addonIdentity?: string, options?: ListCredentialsOptions) => Promise<CredentialInfo[]>;
31
22
  }>;
32
- export {};
@@ -5,10 +5,6 @@ export async function listCredentials(ctx, appIdentity, addonIdentity, options =
5
5
  const addon = await resolvePgDatabase(ctx, { appIdentity, input: addonIdentity, ...options });
6
6
  return ctx.data.postgresDatabase.listCredentials(addon.id);
7
7
  }
8
- export const postgresDatabaseExtensions = extendResource('data', 'postgresDatabase', rawCtx => {
9
- // Bridge heroku-types' loose client types to the adapter's strongly-typed contract
10
- const ctx = rawCtx;
11
- return {
12
- listCredentials: (appIdentity, addonIdentity, options) => listCredentials(ctx, appIdentity, addonIdentity, options),
13
- };
14
- });
8
+ export const postgresDatabaseExtensions = extendResource('data', 'postgresDatabase', ctx => ({
9
+ listCredentials: (appIdentity, addonIdentity, options) => listCredentials(ctx, appIdentity, addonIdentity, options),
10
+ }));
@@ -1,49 +1,9 @@
1
+ import type { TransferListByAppResult } from '@heroku/types/data';
1
2
  import type { ResourceCtx } from '../../core/extend-resource.js';
2
3
  export type TransferOptions = {
3
4
  signal?: AbortSignal;
4
5
  };
5
- export type BackupTransfer = {
6
- canceled_at: string;
7
- created_at: string;
8
- deleted_at: string;
9
- finished_at: string;
10
- from_name: string;
11
- from_type: string;
12
- from_url: string;
13
- logs: Array<{
14
- created_at: string;
15
- level: string;
16
- message: string;
17
- }>;
18
- num: number;
19
- num_keep: number;
20
- options: Record<string, unknown>;
21
- processed_bytes: number;
22
- purged_at: string;
23
- schedule?: {
24
- uuid: string;
25
- };
26
- source_bytes: number;
27
- started_at: string;
28
- succeeded: boolean;
29
- to_name: string;
30
- to_type: string;
31
- to_url: string;
32
- updated_at: string;
33
- uuid: string;
34
- warnings: number;
35
- };
36
- type TransferDataClient = {
37
- transfer: {
38
- listByApp(name: string): Promise<BackupTransfer[]>;
39
- };
40
- };
41
- type TransferCtx = {
42
- data: TransferDataClient;
43
- platform: ResourceCtx['platform'];
44
- };
45
- export declare function listByApp(ctx: TransferCtx, appIdentity: string, addonIdentity?: string, options?: TransferOptions): Promise<BackupTransfer[]>;
6
+ export declare function listByApp(ctx: Pick<ResourceCtx, 'data' | 'platform'>, appIdentity: string, addonIdentity?: string, options?: TransferOptions): Promise<TransferListByAppResult>;
46
7
  export declare const transferExtensions: import("../../core/extend-resource.js").ResourceExtension<"data", "transfer", {
47
- listByApp: (appIdentity: string, addonIdentity?: string, options?: TransferOptions) => Promise<BackupTransfer[]>;
8
+ listByApp: (appIdentity: string, addonIdentity?: string, options?: TransferOptions) => Promise<TransferListByAppResult>;
48
9
  }>;
49
- export {};
@@ -14,10 +14,6 @@ export async function listByApp(ctx, appIdentity, addonIdentity, options = {}) {
14
14
  }
15
15
  return ctx.data.transfer.listByApp(addon.id);
16
16
  }
17
- export const transferExtensions = extendResource('data', 'transfer', rawCtx => {
18
- // Bridge heroku-types' loose client types to the adapter's strongly-typed contract
19
- const ctx = rawCtx;
20
- return {
21
- listByApp: (appIdentity, addonIdentity, options) => listByApp(ctx, appIdentity, addonIdentity, options),
22
- };
23
- });
17
+ export const transferExtensions = extendResource('data', 'transfer', ctx => ({
18
+ listByApp: (appIdentity, addonIdentity, options) => listByApp(ctx, appIdentity, addonIdentity, options),
19
+ }));
@@ -19,6 +19,7 @@ export function buildCtx(stubs = {}) {
19
19
  dashboardBackend: {},
20
20
  data: {},
21
21
  metrics: {},
22
+ notifications: {},
22
23
  platform: platform,
23
24
  repositories: {},
24
25
  };
@@ -0,0 +1,5 @@
1
+ import type { HerokuApiClientOptions } from '@heroku/heroku-fetch';
2
+ import type { HerokuClient } from '@heroku/types/notifications';
3
+ import type { RoutesClientExtras } from '../core/create-client.js';
4
+ export type NotificationsClient = HerokuClient & RoutesClientExtras<HerokuClient>;
5
+ export declare function createNotificationsClient(options?: HerokuApiClientOptions): NotificationsClient;
@@ -0,0 +1,11 @@
1
+ import * as routes from '@heroku/types/notifications/routes';
2
+ import { createClient } from '../core/create-client.js';
3
+ const DEFAULT_NOTIFICATIONS_BASE_URL = 'https://telex.heroku.com';
4
+ export function createNotificationsClient(options = {}) {
5
+ const baseUrl = process.env.HEROKU_NOTIFICATIONS_HOST ?? DEFAULT_NOTIFICATIONS_BASE_URL;
6
+ return createClient(routes, {
7
+ baseUrl,
8
+ service: 'custom',
9
+ ...options,
10
+ });
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heroku/sdk",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Heroku SDK",
5
5
  "author": "Heroku",
6
6
  "type": "module",
@@ -34,6 +34,10 @@
34
34
  "types": "./dist/services/repositories-api.d.ts",
35
35
  "default": "./dist/services/repositories-api.js"
36
36
  },
37
+ "./notifications": {
38
+ "types": "./dist/services/notifications.d.ts",
39
+ "default": "./dist/services/notifications.js"
40
+ },
37
41
  "./extensions/platform": {
38
42
  "types": "./dist/resources/extensions/platform.d.ts",
39
43
  "default": "./dist/resources/extensions/platform.js"
@@ -141,7 +145,7 @@
141
145
  },
142
146
  "dependencies": {
143
147
  "@heroku/heroku-fetch": "^0.1.4",
144
- "@heroku/types": "^4.7.0",
148
+ "@heroku/types": "^5.0.0",
145
149
  "debug": "^4.4.0"
146
150
  }
147
151
  }