cloudflare
Version:
The official TypeScript library for the Cloudflare API
89 lines • 3.44 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import { SinglePage } from "../../core/pagination.mjs";
export var BaseAssets = /* @__PURE__ */ (() => {
class BaseAssets extends 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', (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;
})();
export class Assets extends BaseAssets {
}
//# sourceMappingURL=assets.mjs.map