cloudflare
Version:
The official TypeScript library for the Cloudflare API
80 lines • 3.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Versions = exports.BaseVersions = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../core/resource.js");
const pagination_1 = require("../../../core/pagination.js");
const uploads_1 = require("../../../internal/uploads.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseVersions = /* @__PURE__ */ (() => {
class BaseVersions extends resource_1.APIResource {
/**
* Upload a Worker Version without deploying to Cloudflare's network. You can find
* more about the multipart metadata on our docs:
* https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/.
*
* @example
* ```ts
* const version =
* await client.workers.scripts.versions.create(
* 'this-is_my_script-01',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* metadata: { main_module: 'worker.js' },
* },
* );
* ```
*/
create(scriptName, params, options) {
const { account_id, bindings_inherit, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/workers/scripts/${scriptName}/versions`, (0, uploads_1.multipartFormRequestOptions)({ query: { bindings_inherit }, body, ...options }, this._client))._thenUnwrap((obj) => obj.result);
}
/**
* List of Worker Versions. The first version in the list is the latest version.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const versionListResponse of client.workers.scripts.versions.list(
* 'this-is_my_script-01',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(scriptName, params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/workers/scripts/${scriptName}/versions`, (pagination_1.V4PagePagination), { query, ...options });
}
/**
* Retrieves detailed information about a specific version of a Worker script.
*
* @example
* ```ts
* const version = await client.workers.scripts.versions.get(
* 'bcf48806-b317-4351-9ee7-36e7d557d4de',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* script_name: 'this-is_my_script-01',
* },
* );
* ```
*/
get(versionID, params, options) {
const { account_id, script_name } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/workers/scripts/${script_name}/versions/${versionID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseVersions._key = Object.freeze([
'workers',
'scripts',
'versions',
]);
return BaseVersions;
})();
exports.BaseVersions = BaseVersions;
class Versions extends BaseVersions {
}
exports.Versions = Versions;
//# sourceMappingURL=versions.js.map