cloudflare
Version:
The official TypeScript library for the Cloudflare API
154 lines • 6.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Projects = exports.BaseProjects = void 0;
const tslib_1 = require("../../../internal/tslib.js");
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../core/resource.js");
const DomainsAPI = tslib_1.__importStar(require("./domains.js"));
const domains_1 = require("./domains.js");
const DeploymentsAPI = tslib_1.__importStar(require("./deployments/deployments.js"));
const deployments_1 = require("./deployments/deployments.js");
const pagination_1 = require("../../../core/pagination.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseProjects = /* @__PURE__ */ (() => {
class BaseProjects extends resource_1.APIResource {
/**
* Create a Cloudflare Pages project for configuring and deploying a site or
* application.
*
* @example
* ```ts
* const project = await client.pages.projects.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* name: 'my-pages-app',
* production_branch: 'main',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/pages/projects`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* List the Cloudflare Pages projects in an account.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const project of client.pages.projects.list({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* })) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/pages/projects`, (pagination_1.V4PagePaginationArray), { query, ...options });
}
/**
* Permanently delete a Cloudflare Pages project and its deployments.
*
* @example
* ```ts
* const project = await client.pages.projects.delete(
* 'this-is-my-project-01',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(projectName, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/pages/projects/${projectName}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Update the build, deployment, source, or environment settings for a Cloudflare
* Pages project. To delete an environment variable, set its key to `null`.
*
* @example
* ```ts
* const project = await client.pages.projects.edit(
* 'this-is-my-project-01',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
edit(projectName, params, options) {
const { account_id, ...body } = params;
return this._client.patch((0, path_1.path) `/accounts/${account_id}/pages/projects/${projectName}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Retrieve the configuration and deployment settings for a Cloudflare Pages
* project.
*
* @example
* ```ts
* const project = await client.pages.projects.get(
* 'this-is-my-project-01',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(projectName, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/pages/projects/${projectName}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Get a short-lived JWT for Pages Direct Upload asset operations.
*
* @example
* ```ts
* const response = await client.pages.projects.getUploadToken(
* 'this-is-my-project-01',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
getUploadToken(projectName, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/pages/projects/${projectName}/upload-token`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Remove cached build artifacts so subsequent builds run without the project's
* existing build cache.
*
* @example
* ```ts
* const response =
* await client.pages.projects.purgeBuildCache(
* 'this-is-my-project-01',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
purgeBuildCache(projectName, params, options) {
const { account_id } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/pages/projects/${projectName}/purge_build_cache`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseProjects._key = Object.freeze([
'pages',
'projects',
]);
return BaseProjects;
})();
exports.BaseProjects = BaseProjects;
var Projects = /* @__PURE__ */ (() => {
class Projects extends BaseProjects {
constructor() {
super(...arguments);
this.deployments = new DeploymentsAPI.Deployments(this._client);
this.domains = new DomainsAPI.Domains(this._client);
}
}
Projects.Deployments = deployments_1.Deployments;
Projects.BaseDeployments = deployments_1.BaseDeployments;
Projects.Domains = domains_1.Domains;
Projects.BaseDomains = domains_1.BaseDomains;
return Projects;
})();
exports.Projects = Projects;
//# sourceMappingURL=projects.js.map