cloudflare
Version:
The official TypeScript library for the Cloudflare API
98 lines • 4.11 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as DirectUploadsAPI from "./direct-uploads.mjs";
import { BaseDirectUploads, DirectUploads, } from "./direct-uploads.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseV2 = /* @__PURE__ */ (() => {
class BaseV2 extends APIResource {
/**
* List up to 10000 images from CF Images, with up to 1000 results per page. Use
* the optional parameters below to get a specific range of images. Pagination is
* supported via continuation_token.
*
* **Metadata Filtering (Optional):**
*
* You can optionally filter images by custom metadata fields using the
* `meta.<field>[<operator>]=<value>` syntax.
*
* **Supported Operators:**
*
* - `eq` / `eq:string` / `eq:number` / `eq:boolean` - Exact match
* - `gt` / `gt:number` - Greater than (number only)
* - `gte` / `gte:number` - Greater than or equal (number only)
* - `lt` / `lt:number` - Less than (number only)
* - `lte` / `lte:number` - Less than or equal (number only)
* - `in` / `in:string` / `in:number` - Match any value in list (pipe-separated)
*
* **Metadata Filter Constraints:**
*
* - Maximum 5 metadata filters per request
* - Maximum 5 levels of nesting (e.g., `meta.first.second.third.fourth.fifth`)
* - Maximum 10 elements for list operators (`in`)
* - Supports string, number, and boolean value types
* - Range operators (`gt`, `gte`, `lt`, `lte`) only accept numeric values
*
* **Filter Consistency:** Filters are combined with AND logic. The system does not
* validate whether filter combinations are logically consistent. For example,
* `meta.priority[eq:number]=5&meta.priority[lte:number]=3` will return zero
* results because no value can satisfy both conditions simultaneously. It is the
* caller's responsibility to ensure filter combinations make sense.
*
* **Examples:**
*
* ```
* # List all images
* /images/v2
*
* # Filter by metadata [eq]
* /images/v2?meta.status[eq:string]=active
*
* # Filter by metadata [in]
* /images/v2?meta.status[in]=pending|deleted|flagged
*
* # Filter by metadata [in:number]
* /images/v2?meta.ratings[in:number]=4|5
*
* # Filter by metadata range [gte:number]
* /images/v2?meta.priority[gte:number]=1
*
* # Filter by bounded range
* /images/v2?meta.priority[gte:number]=1&meta.priority[lte:number]=5
*
* # Filter by nested metadata
* /images/v2?meta.region.name[eq]=eu-west
*
* # Combine metadata filters with creator
* /images/v2?meta.status[eq]=active&creator=user123
*
* # Multiple metadata filters (AND logic)
* /images/v2?meta.status[eq]=active&meta.priority[eq:number]=5
* ```
*
* @example
* ```ts
* const v2s = await client.images.v2.list({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.get(path `/accounts/${account_id}/images/v2`, { query, ...options })._thenUnwrap((obj) => obj.result);
}
}
BaseV2._key = Object.freeze(['images', 'v2']);
return BaseV2;
})();
export var V2 = /* @__PURE__ */ (() => {
class V2 extends BaseV2 {
constructor() {
super(...arguments);
this.directUploads = new DirectUploadsAPI.DirectUploads(this._client);
}
}
V2.DirectUploads = DirectUploads;
V2.BaseDirectUploads = BaseDirectUploads;
return V2;
})();
//# sourceMappingURL=v2.mjs.map