@heroku/sdk 0.6.4 → 0.7.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.
- package/dist/resources/data/backup/capture-and-wait.d.ts +19 -0
- package/dist/resources/data/backup/capture-and-wait.js +14 -0
- package/dist/resources/data/backup/index.d.ts +5 -0
- package/dist/resources/data/backup/index.js +6 -0
- package/dist/resources/data/restore/index.d.ts +5 -0
- package/dist/resources/data/restore/index.js +6 -0
- package/dist/resources/data/restore/restore-and-wait.d.ts +24 -0
- package/dist/resources/data/restore/restore-and-wait.js +15 -0
- package/dist/resources/data/transfer-schedule.d.ts +19 -0
- package/dist/resources/data/transfer-schedule.js +22 -0
- package/dist/resources/data/wait-for-transfer.d.ts +64 -0
- package/dist/resources/data/wait-for-transfer.js +80 -0
- package/dist/resources/extensions/data.d.ts +4 -1
- package/dist/resources/extensions/data.js +4 -1
- package/package.json +9 -1
- package/dist/resources/data/transfer.d.ts +0 -9
- package/dist/resources/data/transfer.js +0 -19
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BackupCreateResult, TransferInfoByAppResult } from '@heroku/types/data';
|
|
2
|
+
import type { ResourceCtx } from '../../../core/extend-resource.js';
|
|
3
|
+
import type { ResolvedAddOn } from '../../platform/add-on/index.js';
|
|
4
|
+
import type { WaitForTransferOptions } from '../wait-for-transfer.js';
|
|
5
|
+
import { Poller } from '../../../utils/poller.js';
|
|
6
|
+
export type CaptureAndWaitOptions = WaitForTransferOptions & {
|
|
7
|
+
/**
|
|
8
|
+
* Progress hooks fired once before capturing the backup `poller.onStart(addon)`
|
|
9
|
+
* and once after the backup is created `poller.onStop(addon)`.
|
|
10
|
+
*/
|
|
11
|
+
capturePoller?: Poller<ResolvedAddOn>;
|
|
12
|
+
/**
|
|
13
|
+
* Progress hooks fired once before waiting for the transfer to
|
|
14
|
+
* complete `poller.onStart(backup)` and once after the transfer
|
|
15
|
+
* finishes successfully `poller.onStop(backup)`.
|
|
16
|
+
*/
|
|
17
|
+
waitPoller?: Poller<BackupCreateResult>;
|
|
18
|
+
};
|
|
19
|
+
export declare function captureAndWait(ctx: Pick<ResourceCtx, 'data' | 'platform'>, appIdentity: string, addonIdentity?: string, options?: CaptureAndWaitOptions): Promise<TransferInfoByAppResult>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { resolvePgDatabase } from '../internal/resolve-pg-database.js';
|
|
2
|
+
import { waitForTransfer } from '../wait-for-transfer.js';
|
|
3
|
+
export async function captureAndWait(ctx, appIdentity, addonIdentity, options = {}) {
|
|
4
|
+
const { capturePoller, signal, waitPoller } = options;
|
|
5
|
+
signal?.throwIfAborted();
|
|
6
|
+
const addon = await resolvePgDatabase(ctx, { appIdentity, input: addonIdentity, ...options });
|
|
7
|
+
capturePoller?.onStart?.(addon);
|
|
8
|
+
const backup = await ctx.data.backup.create(addon.id);
|
|
9
|
+
capturePoller?.onStop?.(addon);
|
|
10
|
+
waitPoller?.onStart?.(backup);
|
|
11
|
+
const transfer = await waitForTransfer(ctx, addon.app.name, backup.uuid, options);
|
|
12
|
+
waitPoller?.onStop?.(backup);
|
|
13
|
+
return transfer;
|
|
14
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CaptureAndWaitOptions } from './capture-and-wait.js';
|
|
2
|
+
export { captureAndWait, type CaptureAndWaitOptions } from './capture-and-wait.js';
|
|
3
|
+
export declare const backupExtensions: import("../../../core/extend-resource.js").ResourceExtension<"data", "backup", {
|
|
4
|
+
captureAndWait: (appIdentity: string, addonIdentity?: string, options?: CaptureAndWaitOptions) => Promise<import("@heroku/types/data").TransferInfoByAppResult>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { extendResource } from '../../../core/extend-resource.js';
|
|
2
|
+
import { captureAndWait } from './capture-and-wait.js';
|
|
3
|
+
export { captureAndWait } from './capture-and-wait.js';
|
|
4
|
+
export const backupExtensions = extendResource('data', 'backup', ctx => ({
|
|
5
|
+
captureAndWait: (appIdentity, addonIdentity, options) => captureAndWait(ctx, appIdentity, addonIdentity, options),
|
|
6
|
+
}));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RestoreAndWaitOptions } from './restore-and-wait.js';
|
|
2
|
+
export { restoreAndWait, type RestoreAndWaitOptions } from './restore-and-wait.js';
|
|
3
|
+
export declare const restoreExtensions: import("../../../core/extend-resource.js").ResourceExtension<"data", "restore", {
|
|
4
|
+
restoreAndWait: (appIdentity: string, addonIdentity: string | undefined, backupUrl: string, options?: RestoreAndWaitOptions) => Promise<import("@heroku/types/data").TransferInfoByAppResult>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { extendResource } from '../../../core/extend-resource.js';
|
|
2
|
+
import { restoreAndWait } from './restore-and-wait.js';
|
|
3
|
+
export { restoreAndWait } from './restore-and-wait.js';
|
|
4
|
+
export const restoreExtensions = extendResource('data', 'restore', ctx => ({
|
|
5
|
+
restoreAndWait: (appIdentity, addonIdentity, backupUrl, options) => restoreAndWait(ctx, appIdentity, addonIdentity, backupUrl, options),
|
|
6
|
+
}));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RestoreCreateResult, TransferInfoByAppResult } from '@heroku/types/data';
|
|
2
|
+
import type { ResourceCtx } from '../../../core/extend-resource.js';
|
|
3
|
+
import type { ResolvedAddOn } from '../../platform/add-on/index.js';
|
|
4
|
+
import type { WaitForTransferOptions } from '../wait-for-transfer.js';
|
|
5
|
+
import { Poller } from '../../../utils/poller.js';
|
|
6
|
+
export type RestoreAndWaitOptions = WaitForTransferOptions & {
|
|
7
|
+
/**
|
|
8
|
+
* Extension names to preinstall on the restore target.
|
|
9
|
+
*/
|
|
10
|
+
extensions?: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Progress hooks fired once before creating the restore
|
|
13
|
+
* `poller.onStart(addon)` and once after the restore is
|
|
14
|
+
* created `poller.onStop(addon)`.
|
|
15
|
+
*/
|
|
16
|
+
restorePoller?: Poller<ResolvedAddOn>;
|
|
17
|
+
/**
|
|
18
|
+
* Progress hooks fired once before waiting for the restore to
|
|
19
|
+
* complete `poller.onStart(restore)` and once after the restore
|
|
20
|
+
* reaches a terminal state `poller.onStop(restore)`.
|
|
21
|
+
*/
|
|
22
|
+
waitPoller?: Poller<RestoreCreateResult>;
|
|
23
|
+
};
|
|
24
|
+
export declare function restoreAndWait(ctx: Pick<ResourceCtx, 'data' | 'platform'>, appIdentity: string, addonIdentity: string | undefined, backupUrl: string, options?: RestoreAndWaitOptions): Promise<TransferInfoByAppResult>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { resolvePgDatabase } from '../internal/resolve-pg-database.js';
|
|
2
|
+
import { waitForTransfer } from '../wait-for-transfer.js';
|
|
3
|
+
export async function restoreAndWait(ctx, appIdentity, addonIdentity, backupUrl, options = {}) {
|
|
4
|
+
const { extensions, restorePoller, signal, waitPoller } = options;
|
|
5
|
+
signal?.throwIfAborted();
|
|
6
|
+
const addon = await resolvePgDatabase(ctx, { appIdentity, input: addonIdentity, ...options });
|
|
7
|
+
restorePoller?.onStart?.(addon);
|
|
8
|
+
// eslint-disable-next-line camelcase
|
|
9
|
+
const restore = await ctx.data.restore.create(addon.id, { backup_url: backupUrl, extensions });
|
|
10
|
+
restorePoller?.onStop?.(addon);
|
|
11
|
+
waitPoller?.onStart?.(restore);
|
|
12
|
+
const transfer = await waitForTransfer(ctx, addon.app.name, restore.uuid, options);
|
|
13
|
+
waitPoller?.onStop?.(restore);
|
|
14
|
+
return transfer;
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TransferScheduleCreateOpts, TransferScheduleCreateResult, TransferScheduleDeleteResult } from '@heroku/types/data';
|
|
2
|
+
import type { ResourceCtx } from '../../core/extend-resource.js';
|
|
3
|
+
export type TransferSchedule = {
|
|
4
|
+
hour: number;
|
|
5
|
+
name: string;
|
|
6
|
+
timezone: string;
|
|
7
|
+
uuid: string;
|
|
8
|
+
};
|
|
9
|
+
export type TransferScheduleOptions = {
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
};
|
|
12
|
+
export declare function list(ctx: Pick<ResourceCtx, 'data' | 'platform'>, appIdentity: string, addonIdentity?: string, options?: TransferScheduleOptions): Promise<TransferSchedule[]>;
|
|
13
|
+
export declare function create(ctx: Pick<ResourceCtx, 'data' | 'platform'>, appIdentity: string, addonIdentity: string | undefined, body: TransferScheduleCreateOpts, options?: TransferScheduleOptions): Promise<TransferScheduleCreateResult>;
|
|
14
|
+
export declare function del(ctx: Pick<ResourceCtx, 'data' | 'platform'>, appIdentity: string, addonIdentity: string | undefined, scheduleId: string, options?: TransferScheduleOptions): Promise<TransferScheduleDeleteResult>;
|
|
15
|
+
export declare const transferScheduleExtensions: import("../../core/extend-resource.js").ResourceExtension<"data", "transferSchedule", {
|
|
16
|
+
create: (appIdentity: string, addonIdentity: string | undefined, body: TransferScheduleCreateOpts, options?: TransferScheduleOptions) => Promise<TransferScheduleCreateResult>;
|
|
17
|
+
delete: (appIdentity: string, addonIdentity: string | undefined, scheduleId: string, options?: TransferScheduleOptions) => Promise<TransferScheduleDeleteResult>;
|
|
18
|
+
list: (appIdentity: string, addonIdentity?: string, options?: TransferScheduleOptions) => Promise<TransferSchedule[]>;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { extendResource } from '../../core/extend-resource.js';
|
|
2
|
+
import { resolvePgDatabase } from './internal/resolve-pg-database.js';
|
|
3
|
+
export async function list(ctx, appIdentity, addonIdentity, options = {}) {
|
|
4
|
+
options.signal?.throwIfAborted();
|
|
5
|
+
const addon = await resolvePgDatabase(ctx, { appIdentity, input: addonIdentity, ...options });
|
|
6
|
+
return ctx.data.transferSchedule.list(addon.id);
|
|
7
|
+
}
|
|
8
|
+
export async function create(ctx, appIdentity, addonIdentity, body, options = {}) {
|
|
9
|
+
options.signal?.throwIfAborted();
|
|
10
|
+
const addon = await resolvePgDatabase(ctx, { appIdentity, input: addonIdentity, ...options });
|
|
11
|
+
return ctx.data.transferSchedule.create(addon.id, body);
|
|
12
|
+
}
|
|
13
|
+
export async function del(ctx, appIdentity, addonIdentity, scheduleId, options = {}) {
|
|
14
|
+
options.signal?.throwIfAborted();
|
|
15
|
+
const addon = await resolvePgDatabase(ctx, { appIdentity, input: addonIdentity, ...options });
|
|
16
|
+
return ctx.data.transferSchedule.delete(addon.id, scheduleId);
|
|
17
|
+
}
|
|
18
|
+
export const transferScheduleExtensions = extendResource('data', 'transferSchedule', ctx => ({
|
|
19
|
+
create: (appIdentity, addonIdentity, body, options) => create(ctx, appIdentity, addonIdentity, body, options),
|
|
20
|
+
delete: (appIdentity, addonIdentity, scheduleId, options) => del(ctx, appIdentity, addonIdentity, scheduleId, options),
|
|
21
|
+
list: (appIdentity, addonIdentity, options) => list(ctx, appIdentity, addonIdentity, options),
|
|
22
|
+
}));
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { TransferInfoByAppResult } from '@heroku/types/data';
|
|
2
|
+
import type { ResourceCtx } from '../../core/extend-resource.js';
|
|
3
|
+
/**
|
|
4
|
+
* Thrown by `waitForTransfer` when the transfer reaches a terminal state
|
|
5
|
+
* with `succeeded: false`.
|
|
6
|
+
*/
|
|
7
|
+
export declare class TransferFailedError extends Error {
|
|
8
|
+
readonly transfer: TransferInfoByAppResult;
|
|
9
|
+
readonly id = "transfer_failed";
|
|
10
|
+
constructor(transfer: TransferInfoByAppResult);
|
|
11
|
+
get body(): {
|
|
12
|
+
id: string;
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Thrown by `waitForTransfer` when `timeoutMs` elapses before the
|
|
18
|
+
* transfer reaches a terminal state.
|
|
19
|
+
*/
|
|
20
|
+
export declare class TransferTimeoutError extends Error {
|
|
21
|
+
readonly transferId: string;
|
|
22
|
+
readonly timeoutMs: number;
|
|
23
|
+
readonly id = "transfer_timeout";
|
|
24
|
+
constructor(transferId: string, timeoutMs: number);
|
|
25
|
+
get body(): {
|
|
26
|
+
id: string;
|
|
27
|
+
message: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export type WaitForTransferOptions = {
|
|
31
|
+
/**
|
|
32
|
+
* Polling interval in milliseconds. Defaults to 3000 (3s)
|
|
33
|
+
*/
|
|
34
|
+
intervalMs?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Fired after every wait poll with the latest transfer record,
|
|
37
|
+
* letting callers drive a status display.
|
|
38
|
+
*/
|
|
39
|
+
onPoll?: (transfer: TransferInfoByAppResult | undefined) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Abort signal to cancel the operation.
|
|
42
|
+
*/
|
|
43
|
+
signal?: AbortSignal;
|
|
44
|
+
/**
|
|
45
|
+
* Maximum total time to wait before throwing `TransferTimeoutError`.
|
|
46
|
+
* If omitted, polls until the transfer finishes or `signal` aborts.
|
|
47
|
+
*/
|
|
48
|
+
timeoutMs?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Fetch full log lines when `true`.
|
|
51
|
+
*/
|
|
52
|
+
verbose?: boolean;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Poll `data.transfer.infoByApp` until the transfer reaches a terminal
|
|
56
|
+
* state (`finished_at` set).
|
|
57
|
+
*
|
|
58
|
+
* Throws `TransferFailedError` if the transfer fails or `TransferTimeoutError`
|
|
59
|
+
* if the transfer does not finish before timeout.
|
|
60
|
+
*/
|
|
61
|
+
export declare function waitForTransfer(ctx: Pick<ResourceCtx, 'data'>, appIdentity: string, transferId: string, options?: WaitForTransferOptions): Promise<TransferInfoByAppResult>;
|
|
62
|
+
export declare const transferExtensions: import("../../core/extend-resource.js").ResourceExtension<"data", "transfer", {
|
|
63
|
+
waitForTransfer: (appIdentity: string, transferId: string, options?: WaitForTransferOptions) => Promise<TransferInfoByAppResult>;
|
|
64
|
+
}>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { extendResource } from '../../core/extend-resource.js';
|
|
2
|
+
import { wait } from '../../utils/wait.js';
|
|
3
|
+
const DEFAULT_INTERVAL_MS = 3000;
|
|
4
|
+
const MAX_FAILURES = 20;
|
|
5
|
+
/**
|
|
6
|
+
* Thrown by `waitForTransfer` when the transfer reaches a terminal state
|
|
7
|
+
* with `succeeded: false`.
|
|
8
|
+
*/
|
|
9
|
+
export class TransferFailedError extends Error {
|
|
10
|
+
transfer;
|
|
11
|
+
id = 'transfer_failed';
|
|
12
|
+
constructor(transfer) {
|
|
13
|
+
super('An error occurred and the transfer did not finish.');
|
|
14
|
+
this.transfer = transfer;
|
|
15
|
+
this.name = 'TransferFailedError';
|
|
16
|
+
}
|
|
17
|
+
get body() {
|
|
18
|
+
return { id: this.id, message: this.message };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Thrown by `waitForTransfer` when `timeoutMs` elapses before the
|
|
23
|
+
* transfer reaches a terminal state.
|
|
24
|
+
*/
|
|
25
|
+
export class TransferTimeoutError extends Error {
|
|
26
|
+
transferId;
|
|
27
|
+
timeoutMs;
|
|
28
|
+
id = 'transfer_timeout';
|
|
29
|
+
constructor(transferId, timeoutMs) {
|
|
30
|
+
super(`Transfer '${transferId}' did not finish within ${timeoutMs}ms`);
|
|
31
|
+
this.transferId = transferId;
|
|
32
|
+
this.timeoutMs = timeoutMs;
|
|
33
|
+
this.name = 'TransferTimeoutError';
|
|
34
|
+
}
|
|
35
|
+
get body() {
|
|
36
|
+
return { id: this.id, message: this.message };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Poll `data.transfer.infoByApp` until the transfer reaches a terminal
|
|
41
|
+
* state (`finished_at` set).
|
|
42
|
+
*
|
|
43
|
+
* Throws `TransferFailedError` if the transfer fails or `TransferTimeoutError`
|
|
44
|
+
* if the transfer does not finish before timeout.
|
|
45
|
+
*/
|
|
46
|
+
export async function waitForTransfer(ctx, appIdentity, transferId, options = {}) {
|
|
47
|
+
const { intervalMs = DEFAULT_INTERVAL_MS, onPoll, signal, timeoutMs, verbose, } = options;
|
|
48
|
+
signal?.throwIfAborted();
|
|
49
|
+
const data = signal ? ctx.data.withOptions({ signal }) : ctx.data;
|
|
50
|
+
const deadline = timeoutMs === undefined ? undefined : Date.now() + timeoutMs;
|
|
51
|
+
let failures = 0;
|
|
52
|
+
let transfer;
|
|
53
|
+
while (true) {
|
|
54
|
+
signal?.throwIfAborted();
|
|
55
|
+
try {
|
|
56
|
+
transfer = await data.transfer.infoByApp(appIdentity, transferId, { verbose });
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
failures++;
|
|
60
|
+
if (failures > MAX_FAILURES) {
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
onPoll?.(transfer);
|
|
65
|
+
if (transfer?.finished_at) {
|
|
66
|
+
if (transfer.succeeded) {
|
|
67
|
+
return transfer;
|
|
68
|
+
}
|
|
69
|
+
const verboseTransfer = verbose ? transfer : await data.transfer.infoByApp(appIdentity, transferId, { verbose: true });
|
|
70
|
+
throw new TransferFailedError(verboseTransfer);
|
|
71
|
+
}
|
|
72
|
+
if (deadline !== undefined && Date.now() >= deadline) {
|
|
73
|
+
throw new TransferTimeoutError(transferId, timeoutMs);
|
|
74
|
+
}
|
|
75
|
+
await wait(intervalMs, signal);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export const transferExtensions = extendResource('data', 'transfer', ctx => ({
|
|
79
|
+
waitForTransfer: (appIdentity, transferId, options) => waitForTransfer(ctx, appIdentity, transferId, options),
|
|
80
|
+
}));
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
export { backupExtensions } from '../data/backup/index.js';
|
|
1
2
|
export { databaseExtensions } from '../data/database.js';
|
|
2
3
|
export { maintenanceExtensions } from '../data/maintenance.js';
|
|
3
4
|
export { postgresDatabaseExtensions } from '../data/postgres-database.js';
|
|
4
5
|
export { redisExtensions } from '../data/redis/index.js';
|
|
5
|
-
export {
|
|
6
|
+
export { restoreExtensions } from '../data/restore/index.js';
|
|
7
|
+
export { type TransferSchedule, transferScheduleExtensions } from '../data/transfer-schedule.js';
|
|
8
|
+
export { transferExtensions, TransferFailedError, TransferTimeoutError, } from '../data/wait-for-transfer.js';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
export { backupExtensions } from '../data/backup/index.js';
|
|
1
2
|
export { databaseExtensions } from '../data/database.js';
|
|
2
3
|
export { maintenanceExtensions } from '../data/maintenance.js';
|
|
3
4
|
export { postgresDatabaseExtensions } from '../data/postgres-database.js';
|
|
4
5
|
export { redisExtensions } from '../data/redis/index.js';
|
|
5
|
-
export {
|
|
6
|
+
export { restoreExtensions } from '../data/restore/index.js';
|
|
7
|
+
export { transferScheduleExtensions } from '../data/transfer-schedule.js';
|
|
8
|
+
export { transferExtensions, TransferFailedError, TransferTimeoutError, } from '../data/wait-for-transfer.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heroku/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Heroku SDK",
|
|
5
5
|
"author": "Heroku",
|
|
6
6
|
"type": "module",
|
|
@@ -98,10 +98,18 @@
|
|
|
98
98
|
"types": "./dist/resources/platform/vpn-connection/index.d.ts",
|
|
99
99
|
"default": "./dist/resources/platform/vpn-connection/index.js"
|
|
100
100
|
},
|
|
101
|
+
"./resources/data/backup": {
|
|
102
|
+
"types": "./dist/resources/data/backup/index.d.ts",
|
|
103
|
+
"default": "./dist/resources/data/backup/index.js"
|
|
104
|
+
},
|
|
101
105
|
"./resources/data/redis": {
|
|
102
106
|
"types": "./dist/resources/data/redis/index.d.ts",
|
|
103
107
|
"default": "./dist/resources/data/redis/index.js"
|
|
104
108
|
},
|
|
109
|
+
"./resources/data/restore": {
|
|
110
|
+
"types": "./dist/resources/data/restore/index.d.ts",
|
|
111
|
+
"default": "./dist/resources/data/restore/index.js"
|
|
112
|
+
},
|
|
105
113
|
"./resources/*": {
|
|
106
114
|
"types": "./dist/resources/*.d.ts",
|
|
107
115
|
"default": "./dist/resources/*.js"
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { TransferListByAppResult } from '@heroku/types/data';
|
|
2
|
-
import type { ResourceCtx } from '../../core/extend-resource.js';
|
|
3
|
-
export type TransferOptions = {
|
|
4
|
-
signal?: AbortSignal;
|
|
5
|
-
};
|
|
6
|
-
export declare function listByApp(ctx: Pick<ResourceCtx, 'data' | 'platform'>, appIdentity: string, addonIdentity?: string, options?: TransferOptions): Promise<TransferListByAppResult>;
|
|
7
|
-
export declare const transferExtensions: import("../../core/extend-resource.js").ResourceExtension<"data", "transfer", {
|
|
8
|
-
listByApp: (appIdentity: string, addonIdentity?: string, options?: TransferOptions) => Promise<TransferListByAppResult>;
|
|
9
|
-
}>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { extendResource } from '../../core/extend-resource.js';
|
|
2
|
-
import { resolvePgDatabase } from './internal/resolve-pg-database.js';
|
|
3
|
-
export async function listByApp(ctx, appIdentity, addonIdentity, options = {}) {
|
|
4
|
-
options.signal?.throwIfAborted();
|
|
5
|
-
let addon;
|
|
6
|
-
try {
|
|
7
|
-
addon = await resolvePgDatabase(ctx, { appIdentity, input: addonIdentity, ...options });
|
|
8
|
-
}
|
|
9
|
-
catch (error) {
|
|
10
|
-
if (error instanceof Error && 'statusCode' in error && error.statusCode === 404) {
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
13
|
-
throw error;
|
|
14
|
-
}
|
|
15
|
-
return ctx.data.transfer.listByApp(addon.id);
|
|
16
|
-
}
|
|
17
|
-
export const transferExtensions = extendResource('data', 'transfer', ctx => ({
|
|
18
|
-
listByApp: (appIdentity, addonIdentity, options) => listByApp(ctx, appIdentity, addonIdentity, options),
|
|
19
|
-
}));
|