UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

94 lines • 3.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Assets = exports.BaseAssets = 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"); var BaseAssets = /* @__PURE__ */ (() => { class BaseAssets extends resource_1.APIResource { /** * Check which of the provided file hashes are missing from the Pages asset store. * Returns a list of missing hashes that need to be uploaded. Used as part of the * Pages Direct Upload workflow. * * Authenticate with the JWT obtained from the upload-token endpoint: GET * /accounts/{account_id}/pages/projects/{project_name}/upload-token * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const assetCheckMissingResponse of client.pages.assets.checkMissing( * { * hashes: [ * 'a948904f2f0f479b8f936b8a0c5d9882', * 'b026324c6904b2a9cb4b88d6d61c81d1', * ], * }, * )) { * // ... * } * ``` */ checkMissing(body, options) { return this._client.getAPIList('/pages/assets/check-missing', (pagination_1.SinglePage), { body, method: 'post', ...options, }); } /** * Upload one or more files to the Pages asset store. Each file is identified by * its content hash and is uploaded using the same JSON shape as the Cloudflare KV * bulk write API. Used as part of the Pages Direct Upload workflow. * * Authenticate with the JWT obtained from the upload-token endpoint: GET * /accounts/{account_id}/pages/projects/{project_name}/upload-token * * @example * ```ts * const response = await client.pages.assets.upload({ * body: [ * { * base64: true, * key: 'b026324c6904b2a9cb4b88d6d61c81d1', * metadata: { contentType: 'text/plain' }, * value: 'SGVsbG8sIFdvcmxkIQ==', * }, * ], * }); * ``` */ upload(params, options) { const { body } = params; return this._client.post('/pages/assets/upload', { body: body, ...options }); } /** * Register the provided file hashes as recently uploaded to the Pages asset store. * Used as part of the Pages Direct Upload workflow so future deployments can avoid * re-uploading files that are already present. * * Authenticate with the JWT obtained from the upload-token endpoint: GET * /accounts/{account_id}/pages/projects/{project_name}/upload-token * * @example * ```ts * const response = await client.pages.assets.upsertHashes({ * hashes: [ * 'a948904f2f0f479b8f936b8a0c5d9882', * 'b026324c6904b2a9cb4b88d6d61c81d1', * ], * }); * ``` */ upsertHashes(body, options) { return this._client.post('/pages/assets/upsert-hashes', { body, ...options }); } } BaseAssets._key = Object.freeze(['pages', 'assets']); return BaseAssets; })(); exports.BaseAssets = BaseAssets; class Assets extends BaseAssets { } exports.Assets = Assets; //# sourceMappingURL=assets.js.map