UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

62 lines • 2.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TimeTravel = exports.BaseTimeTravel = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../../core/resource.js"); const path_1 = require("../../../internal/utils/path.js"); var BaseTimeTravel = /* @__PURE__ */ (() => { class BaseTimeTravel extends resource_1.APIResource { /** * Retrieve the current bookmark, or the nearest bookmark at or before a provided * timestamp. Bookmarks can be used with the restore endpoint to revert the * database to a previous point in time. * * @example * ```ts * const response = * await client.d1.database.timeTravel.getBookmark( * 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ getBookmark(databaseID, params, options) { const { account_id, ...query } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/d1/database/${databaseID}/time_travel/bookmark`, { query, ...options, })._thenUnwrap((obj) => obj.result); } /** * Restore a D1 database to a previous point in time either via a bookmark or a * timestamp. * * @example * ```ts * const response = * await client.d1.database.timeTravel.restore( * 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ restore(databaseID, params, options) { const { account_id, bookmark, timestamp } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/d1/database/${databaseID}/time_travel/restore`, { query: { bookmark, timestamp }, ...options, })._thenUnwrap((obj) => obj.result); } } BaseTimeTravel._key = Object.freeze([ 'd1', 'database', 'timeTravel', ]); return BaseTimeTravel; })(); exports.BaseTimeTravel = BaseTimeTravel; class TimeTravel extends BaseTimeTravel { } exports.TimeTravel = TimeTravel; //# sourceMappingURL=time-travel.js.map