UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

148 lines • 5.77 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import * as DomainsAPI from "./domains.mjs"; import { BaseDomains, Domains, } from "./domains.mjs"; import * as DeploymentsAPI from "./deployments/deployments.mjs"; import { BaseDeployments, Deployments, } from "./deployments/deployments.mjs"; import { V4PagePaginationArray, } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseProjects = /* @__PURE__ */ (() => { class BaseProjects extends 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(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(path `/accounts/${account_id}/pages/projects`, (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(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(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(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(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(path `/accounts/${account_id}/pages/projects/${projectName}/purge_build_cache`, options)._thenUnwrap((obj) => obj.result); } } BaseProjects._key = Object.freeze([ 'pages', 'projects', ]); return BaseProjects; })(); export 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; Projects.BaseDeployments = BaseDeployments; Projects.Domains = Domains; Projects.BaseDomains = BaseDomains; return Projects; })(); //# sourceMappingURL=projects.mjs.map