UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

1,147 lines • 66 kB
"use strict";
var _BaseCloudflare_instances, _BaseCloudflare_encoder, _BaseCloudflare_baseURLOverridden, _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Cloudflare = exports.BaseCloudflare = void 0;
const tslib_1 = require("./internal/tslib.js");
const uuid_1 = require("./internal/utils/uuid.js");
const values_1 = require("./internal/utils/values.js");
const sleep_1 = require("./internal/utils/sleep.js");
const errors_1 = require("./internal/errors.js");
const detect_platform_1 = require("./internal/detect-platform.js");
const Shims = tslib_1.__importStar(require("./internal/shims.js"));
const Opts = tslib_1.__importStar(require("./internal/request-options.js"));
const query_1 = require("./internal/utils/query.js");
const version_1 = require("./version.js");
const Errors = tslib_1.__importStar(require("./core/error.js"));
const Pagination = tslib_1.__importStar(require("./core/pagination.js"));
const Uploads = tslib_1.__importStar(require("./core/uploads.js"));
const API = tslib_1.__importStar(require("./resources/index.js"));
const api_promise_1 = require("./core/api-promise.js");
const abuse_reports_1 = require("./resources/abuse-reports/abuse-reports.js");
const accounts_1 = require("./resources/accounts/accounts.js");
const acm_1 = require("./resources/acm/acm.js");
const addressing_1 = require("./resources/addressing/addressing.js");
const ai_audit_1 = require("./resources/ai-audit/ai-audit.js");
const ai_gateway_1 = require("./resources/ai-gateway/ai-gateway.js");
const ai_security_1 = require("./resources/ai-security/ai-security.js");
const ai_1 = require("./resources/ai/ai.js");
const aisearch_1 = require("./resources/aisearch/aisearch.js");
const alerting_1 = require("./resources/alerting/alerting.js");
const analytics_query_1 = require("./resources/analytics-query/analytics-query.js");
const api_gateway_1 = require("./resources/api-gateway/api-gateway.js");
const argo_1 = require("./resources/argo/argo.js");
const audit_logs_1 = require("./resources/audit-logs/audit-logs.js");
const basin_catalog_1 = require("./resources/basin-catalog/basin-catalog.js");
const billing_1 = require("./resources/billing/billing.js");
const bot_management_1 = require("./resources/bot-management/bot-management.js");
const botnet_feed_1 = require("./resources/botnet-feed/botnet-feed.js");
const brand_protection_1 = require("./resources/brand-protection/brand-protection.js");
const browser_rendering_1 = require("./resources/browser-rendering/browser-rendering.js");
const cache_1 = require("./resources/cache/cache.js");
const calls_1 = require("./resources/calls/calls.js");
const certificate_authorities_1 = require("./resources/certificate-authorities/certificate-authorities.js");
const client_certificates_1 = require("./resources/client-certificates/client-certificates.js");
const cloud_connector_1 = require("./resources/cloud-connector/cloud-connector.js");
const cloudforce_one_1 = require("./resources/cloudforce-one/cloudforce-one.js");
const connectivity_1 = require("./resources/connectivity/connectivity.js");
const containers_1 = require("./resources/containers/containers.js");
const content_scanning_1 = require("./resources/content-scanning/content-scanning.js");
const csam_scanner_1 = require("./resources/csam-scanner/csam-scanner.js");
const custom_certificates_1 = require("./resources/custom-certificates/custom-certificates.js");
const custom_csrs_1 = require("./resources/custom-csrs/custom-csrs.js");
const custom_hostnames_1 = require("./resources/custom-hostnames/custom-hostnames.js");
const custom_nameservers_1 = require("./resources/custom-nameservers/custom-nameservers.js");
const custom_pages_1 = require("./resources/custom-pages/custom-pages.js");
const d1_1 = require("./resources/d1/d1.js");
const dcv_delegation_1 = require("./resources/dcv-delegation/dcv-delegation.js");
const ddos_protection_1 = require("./resources/ddos-protection/ddos-protection.js");
const diagnostics_1 = require("./resources/diagnostics/diagnostics.js");
const dls_1 = require("./resources/dls/dls.js");
const dns_firewall_1 = require("./resources/dns-firewall/dns-firewall.js");
const dns_1 = require("./resources/dns/dns.js");
const durable_objects_1 = require("./resources/durable-objects/durable-objects.js");
const email_auth_1 = require("./resources/email-auth/email-auth.js");
const email_routing_1 = require("./resources/email-routing/email-routing.js");
const email_security_1 = require("./resources/email-security/email-security.js");
const email_sending_1 = require("./resources/email-sending/email-sending.js");
const field_extractors_1 = require("./resources/field-extractors/field-extractors.js");
const filters_1 = require("./resources/filters/filters.js");
const firewall_1 = require("./resources/firewall/firewall.js");
const flagship_1 = require("./resources/flagship/flagship.js");
const fraud_1 = require("./resources/fraud/fraud.js");
const google_tag_gateway_1 = require("./resources/google-tag-gateway/google-tag-gateway.js");
const healthchecks_1 = require("./resources/healthchecks/healthchecks.js");
const hostnames_1 = require("./resources/hostnames/hostnames.js");
const hyperdrive_1 = require("./resources/hyperdrive/hyperdrive.js");
const iam_1 = require("./resources/iam/iam.js");
const images_1 = require("./resources/images/images.js");
const intel_1 = require("./resources/intel/intel.js");
const ips_1 = require("./resources/ips/ips.js");
const keyless_certificates_1 = require("./resources/keyless-certificates/keyless-certificates.js");
const kv_1 = require("./resources/kv/kv.js");
const leaked_credential_checks_1 = require("./resources/leaked-credential-checks/leaked-credential-checks.js");
const load_balancers_1 = require("./resources/load-balancers/load-balancers.js");
const logpush_1 = require("./resources/logpush/logpush.js");
const logs_1 = require("./resources/logs/logs.js");
const magic_cloud_networking_1 = require("./resources/magic-cloud-networking/magic-cloud-networking.js");
const magic_network_monitoring_1 = require("./resources/magic-network-monitoring/magic-network-monitoring.js");
const magic_transit_1 = require("./resources/magic-transit/magic-transit.js");
const managed_defense_1 = require("./resources/managed-defense/managed-defense.js");
const managed_transforms_1 = require("./resources/managed-transforms/managed-transforms.js");
const memberships_1 = require("./resources/memberships/memberships.js");
const moq_1 = require("./resources/moq/moq.js");
const mtls_certificates_1 = require("./resources/mtls-certificates/mtls-certificates.js");
const network_interconnects_1 = require("./resources/network-interconnects/network-interconnects.js");
const organizations_1 = require("./resources/organizations/organizations.js");
const origin_ca_certificates_1 = require("./resources/origin-ca-certificates/origin-ca-certificates.js");
const origin_post_quantum_encryption_1 = require("./resources/origin-post-quantum-encryption/origin-post-quantum-encryption.js");
const origin_tls_client_auth_1 = require("./resources/origin-tls-client-auth/origin-tls-client-auth.js");
const origin_tls_compliance_modes_1 = require("./resources/origin-tls-compliance-modes/origin-tls-compliance-modes.js");
const page_rules_1 = require("./resources/page-rules/page-rules.js");
const page_shield_1 = require("./resources/page-shield/page-shield.js");
const pages_1 = require("./resources/pages/pages.js");
const pipelines_1 = require("./resources/pipelines/pipelines.js");
const precursor_1 = require("./resources/precursor/precursor.js");
const queues_1 = require("./resources/queues/queues.js");
const r2_data_catalog_1 = require("./resources/r2-data-catalog/r2-data-catalog.js");
const r2_1 = require("./resources/r2/r2.js");
const radar_1 = require("./resources/radar/radar.js");
const rate_limits_1 = require("./resources/rate-limits/rate-limits.js");
const realtime_kit_1 = require("./resources/realtime-kit/realtime-kit.js");
const registrar_sandbox_1 = require("./resources/registrar-sandbox/registrar-sandbox.js");
const registrar_1 = require("./resources/registrar/registrar.js");
const request_tracers_1 = require("./resources/request-tracers/request-tracers.js");
const resource_sharing_1 = require("./resources/resource-sharing/resource-sharing.js");
const resource_tagging_1 = require("./resources/resource-tagging/resource-tagging.js");
const rules_1 = require("./resources/rules/rules.js");
const rulesets_1 = require("./resources/rulesets/rulesets.js");
const rum_1 = require("./resources/rum/rum.js");
const schema_validation_1 = require("./resources/schema-validation/schema-validation.js");
const secrets_store_1 = require("./resources/secrets-store/secrets-store.js");
const security_center_1 = require("./resources/security-center/security-center.js");
const security_txt_1 = require("./resources/security-txt/security-txt.js");
const snippets_1 = require("./resources/snippets/snippets.js");
const spectrum_1 = require("./resources/spectrum/spectrum.js");
const speed_1 = require("./resources/speed/speed.js");
const ssl_1 = require("./resources/ssl/ssl.js");
const stream_1 = require("./resources/stream/stream.js");
const tenant_custom_nameservers_1 = require("./resources/tenant-custom-nameservers/tenant-custom-nameservers.js");
const tenants_1 = require("./resources/tenants/tenants.js");
const token_validation_1 = require("./resources/token-validation/token-validation.js");
const turnstile_1 = require("./resources/turnstile/turnstile.js");
const url_normalization_1 = require("./resources/url-normalization/url-normalization.js");
const url_scanner_1 = require("./resources/url-scanner/url-scanner.js");
const user_1 = require("./resources/user/user.js");
const vectorize_1 = require("./resources/vectorize/vectorize.js");
const vulnerability_scanner_1 = require("./resources/vulnerability-scanner/vulnerability-scanner.js");
const waiting_rooms_1 = require("./resources/waiting-rooms/waiting-rooms.js");
const web3_1 = require("./resources/web3/web3.js");
const workers_for_platforms_1 = require("./resources/workers-for-platforms/workers-for-platforms.js");
const workers_1 = require("./resources/workers/workers.js");
const workflows_1 = require("./resources/workflows/workflows.js");
const zaraz_1 = require("./resources/zaraz/zaraz.js");
const zero_trust_1 = require("./resources/zero-trust/zero-trust.js");
const zones_1 = require("./resources/zones/zones.js");
const headers_1 = require("./internal/headers.js");
const env_1 = require("./internal/utils/env.js");
const log_1 = require("./internal/utils/log.js");
const values_2 = require("./internal/utils/values.js");
var BaseCloudflare = /* @__PURE__ */ (() => {
    /**
     * Base class for Cloudflare API clients.
     */
    class BaseCloudflare {
        /**
         * API Client for interfacing with the Cloudflare API.
         *
         * @param {string | null | undefined} [opts.apiToken=process.env['CLOUDFLARE_API_TOKEN'] ?? null]
         * @param {string | null | undefined} [opts.apiKey=process.env['CLOUDFLARE_API_KEY'] ?? null]
         * @param {string | null | undefined} [opts.apiEmail=process.env['CLOUDFLARE_EMAIL'] ?? null]
         * @param {string | null | undefined} [opts.userServiceKey=process.env['CLOUDFLARE_API_USER_SERVICE_KEY'] ?? null]
         * @param {string} [opts.baseURL=process.env['CLOUDFLARE_BASE_URL'] ?? https://api.cloudflare.com/client/v4] - Override the default base URL for the API.
         * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
         * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
         * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
         * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
         * @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
         * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
         * @param {string | null} [opts.apiVersion] - Define the version to target for the API.
         */
        constructor({ baseURL = (0, env_1.readEnv)('CLOUDFLARE_BASE_URL'), apiVersion = null, apiToken = (0, env_1.readEnv)('CLOUDFLARE_API_TOKEN') ?? null, apiKey = (0, env_1.readEnv)('CLOUDFLARE_API_KEY') ?? null, apiEmail = (0, env_1.readEnv)('CLOUDFLARE_EMAIL') ?? null, userServiceKey = (0, env_1.readEnv)('CLOUDFLARE_API_USER_SERVICE_KEY') ?? null, ...opts } = {}) {
            _BaseCloudflare_instances.add(this);
            _BaseCloudflare_encoder.set(this, void 0);
            const options = {
                apiToken,
                apiKey,
                apiEmail,
                userServiceKey,
                ...opts,
                baseURL: baseURL || `https://api.cloudflare.com/client/v4`,
                apiVersion: apiVersion || new Date().toISOString().slice(0, 10),
            };
            this.baseURL = options.baseURL;
            this.timeout = options.timeout ?? BaseCloudflare.DEFAULT_TIMEOUT /* 1 minute */;
            this.logger = options.logger ?? console;
            const defaultLogLevel = 'warn';
            // Set default logLevel early so that we can log a warning in parseLogLevel.
            this.logLevel = defaultLogLevel;
            this.logLevel =
                (0, log_1.parseLogLevel)(options.logLevel, 'ClientOptions.logLevel', this) ??
                    (0, log_1.parseLogLevel)((0, env_1.readEnv)('CLOUDFLARE_LOG'), "process.env['CLOUDFLARE_LOG']", this) ??
                    defaultLogLevel;
            this.fetchOptions = options.fetchOptions;
            this.maxRetries = options.maxRetries ?? 2;
            this.fetch = options.fetch ?? Shims.getDefaultFetch();
            tslib_1.__classPrivateFieldSet(this, _BaseCloudflare_encoder, Opts.FallbackEncoder, "f");
            const customHeadersEnv = (0, env_1.readEnv)('CLOUDFLARE_CUSTOM_HEADERS');
            if (customHeadersEnv) {
                const parsed = {};
                for (const line of customHeadersEnv.split('\n')) {
                    const colon = line.indexOf(':');
                    if (colon >= 0) {
                        parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
                    }
                }
                options.defaultHeaders = { ...parsed, ...options.defaultHeaders };
            }
            this._options = options;
            this.apiToken = apiToken;
            this.apiKey = apiKey;
            this.apiEmail = apiEmail;
            this.userServiceKey = userServiceKey;
            this.apiVersion = options.apiVersion;
        }
        /**
         * Create a new client instance re-using the same options given to the current client with optional overriding.
         */
        withOptions(options) {
            const client = new this.constructor({
                ...this._options,
                baseURL: this.baseURL,
                maxRetries: this.maxRetries,
                timeout: this.timeout,
                logger: this.logger,
                logLevel: this.logLevel,
                fetch: this.fetch,
                fetchOptions: this.fetchOptions,
                apiToken: this.apiToken,
                apiKey: this.apiKey,
                apiEmail: this.apiEmail,
                userServiceKey: this.userServiceKey,
                apiVersion: this.apiVersion,
                ...options,
            });
            return client;
        }
        defaultQuery() {
            return this._options.defaultQuery;
        }
        validateHeaders({ values, nulls }) {
            if (this.apiEmail && values.get('x-auth-email')) {
                return;
            }
            if (nulls.has('x-auth-email')) {
                return;
            }
            if (this.apiKey && values.get('x-auth-key')) {
                return;
            }
            if (nulls.has('x-auth-key')) {
                return;
            }
            if (this.apiToken && values.get('authorization')) {
                return;
            }
            if (nulls.has('authorization')) {
                return;
            }
            if (this.userServiceKey && values.get('x-auth-user-service-key')) {
                return;
            }
            if (nulls.has('x-auth-user-service-key')) {
                return;
            }
            throw new Error('Could not resolve authentication method. Expected one of apiEmail, apiKey, apiToken or userServiceKey to be set. Or for one of the "X-Auth-Email", "X-Auth-Key", "Authorization" or "X-Auth-User-Service-Key" headers to be explicitly omitted');
        }
        async authHeaders(opts) {
            return (0, headers_1.buildHeaders)([
                await this.apiEmailAuth(opts),
                await this.apiKeyAuth(opts),
                await this.apiTokenAuth(opts),
                await this.userServiceKeyAuth(opts),
            ]);
        }
        async apiEmailAuth(opts) {
            if (this.apiEmail == null) {
                return undefined;
            }
            return (0, headers_1.buildHeaders)([{ 'X-Auth-Email': this.apiEmail }]);
        }
        async apiKeyAuth(opts) {
            if (this.apiKey == null) {
                return undefined;
            }
            return (0, headers_1.buildHeaders)([{ 'X-Auth-Key': this.apiKey }]);
        }
        async apiTokenAuth(opts) {
            if (this.apiToken == null) {
                return undefined;
            }
            return (0, headers_1.buildHeaders)([{ Authorization: `Bearer ${this.apiToken}` }]);
        }
        async userServiceKeyAuth(opts) {
            if (this.userServiceKey == null) {
                return undefined;
            }
            return (0, headers_1.buildHeaders)([{ 'X-Auth-User-Service-Key': this.userServiceKey }]);
        }
        stringifyQuery(query) {
            return (0, query_1.stringifyQuery)(query);
        }
        getUserAgent() {
            return `${this.constructor.name}/JS ${version_1.VERSION}`;
        }
        defaultIdempotencyKey() {
            return `stainless-node-retry-${(0, uuid_1.uuid4)()}`;
        }
        makeStatusError(status, error, message, headers) {
            return Errors.APIError.generate(status, error, message, headers);
        }
        buildURL(path, query, defaultBaseURL) {
            const baseURL = (!tslib_1.__classPrivateFieldGet(this, _BaseCloudflare_instances, "m", _BaseCloudflare_baseURLOverridden).call(this) && defaultBaseURL) || this.baseURL;
            const url = (0, values_1.isAbsoluteURL)(path) ?
                new URL(path)
                : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
            const defaultQuery = this.defaultQuery();
            const pathQuery = Object.fromEntries(url.searchParams);
            if (!(0, values_2.isEmptyObj)(defaultQuery) || !(0, values_2.isEmptyObj)(pathQuery)) {
                query = { ...pathQuery, ...defaultQuery, ...query };
            }
            if (typeof query === 'object' && query && !Array.isArray(query)) {
                url.search = this.stringifyQuery(query);
            }
            return url.toString();
        }
        /**
         * Used as a callback for mutating the given `FinalRequestOptions` object.
         */
        async prepareOptions(options) { }
        /**
         * Used as a callback for mutating the given `RequestInit` object.
         *
         * This is useful for cases where you want to add certain headers based off of
         * the request properties, e.g. `method` or `url`.
         */
        async prepareRequest(request, { url, options }) { }
        get(path, opts) {
            return this.methodRequest('get', path, opts);
        }
        post(path, opts) {
            return this.methodRequest('post', path, opts);
        }
        patch(path, opts) {
            return this.methodRequest('patch', path, opts);
        }
        put(path, opts) {
            return this.methodRequest('put', path, opts);
        }
        delete(path, opts) {
            return this.methodRequest('delete', path, opts);
        }
        methodRequest(method, path, opts) {
            return this.request(Promise.resolve(opts).then((opts) => {
                return { method, path, ...opts };
            }));
        }
        request(options, remainingRetries = null) {
            return new api_promise_1.APIPromise(this, this.makeRequest(options, remainingRetries, undefined));
        }
        async makeRequest(optionsInput, retriesRemaining, retryOfRequestLogID) {
            const options = await optionsInput;
            const maxRetries = options.maxRetries ?? this.maxRetries;
            if (retriesRemaining == null) {
                retriesRemaining = maxRetries;
            }
            await this.prepareOptions(options);
            const { req, url, timeout } = await this.buildRequest(options, {
                retryCount: maxRetries - retriesRemaining,
            });
            await this.prepareRequest(req, { url, options });
            /** Not an API request ID, just for correlating local log entries. */
            const requestLogID = 'log_' + ((Math.random() * (1 << 24)) | 0).toString(16).padStart(6, '0');
            const retryLogStr = retryOfRequestLogID === undefined ? '' : `, retryOf: ${retryOfRequestLogID}`;
            const startTime = Date.now();
            (0, log_1.loggerFor)(this).debug(`[${requestLogID}] sending request`, (0, log_1.formatRequestDetails)({
                retryOfRequestLogID,
                method: options.method,
                url,
                options,
                headers: req.headers,
            }));
            if (options.signal?.aborted) {
                throw new Errors.APIUserAbortError();
            }
            const controller = new AbortController();
            const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(errors_1.castToError);
            const headersTime = Date.now();
            if (response instanceof globalThis.Error) {
                const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
                if (options.signal?.aborted) {
                    throw new Errors.APIUserAbortError();
                }
                // detect native connection timeout errors
                // deno throws "TypeError: error sending request for url (https://example/): client error (Connect): tcp connect error: Operation timed out (os error 60): Operation timed out (os error 60)"
                // undici throws "TypeError: fetch failed" with cause "ConnectTimeoutError: Connect Timeout Error (attempted address: example:443, timeout: 1ms)"
                // others do not provide enough information to distinguish timeouts from other connection errors
                const isTimeout = (0, errors_1.isAbortError)(response) ||
                    /timed? ?out/i.test(String(response) + ('cause' in response ? String(response.cause) : ''));
                if (retriesRemaining) {
                    (0, log_1.loggerFor)(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${retryMessage}`);
                    (0, log_1.loggerFor)(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (${retryMessage})`, (0, log_1.formatRequestDetails)({
                        retryOfRequestLogID,
                        url,
                        durationMs: headersTime - startTime,
                        message: response.message,
                    }));
                    return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID);
                }
                (0, log_1.loggerFor)(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - error; no more retries left`);
                (0, log_1.loggerFor)(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (error; no more retries left)`, (0, log_1.formatRequestDetails)({
                    retryOfRequestLogID,
                    url,
                    durationMs: headersTime - startTime,
                    message: response.message,
                }));
                if (isTimeout) {
                    throw new Errors.APIConnectionTimeoutError();
                }
                throw new Errors.APIConnectionError({ cause: response });
            }
            const responseInfo = `[${requestLogID}${retryLogStr}] ${req.method} ${url} ${response.ok ? 'succeeded' : 'failed'} with status ${response.status} in ${headersTime - startTime}ms`;
            if (!response.ok) {
                const shouldRetry = await this.shouldRetry(response);
                if (retriesRemaining && shouldRetry) {
                    const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
                    // We don't need the body of this response.
                    await Shims.CancelReadableStream(response.body);
                    (0, log_1.loggerFor)(this).info(`${responseInfo} - ${retryMessage}`);
                    (0, log_1.loggerFor)(this).debug(`[${requestLogID}] response error (${retryMessage})`, (0, log_1.formatRequestDetails)({
                        retryOfRequestLogID,
                        url: response.url,
                        status: response.status,
                        headers: response.headers,
                        durationMs: headersTime - startTime,
                    }));
                    return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID, response.headers);
                }
                const retryMessage = shouldRetry ? `error; no more retries left` : `error; not retryable`;
                (0, log_1.loggerFor)(this).info(`${responseInfo} - ${retryMessage}`);
                const errText = await response.text().catch((err) => (0, errors_1.castToError)(err).message);
                const errJSON = (0, values_1.safeJSON)(errText);
                const errMessage = errJSON ? undefined : errText;
                (0, log_1.loggerFor)(this).debug(`[${requestLogID}] response error (${retryMessage})`, (0, log_1.formatRequestDetails)({
                    retryOfRequestLogID,
                    url: response.url,
                    status: response.status,
                    headers: response.headers,
                    message: errMessage,
                    durationMs: Date.now() - startTime,
                }));
                const err = this.makeStatusError(response.status, errJSON, errMessage, response.headers);
                throw err;
            }
            (0, log_1.loggerFor)(this).info(responseInfo);
            (0, log_1.loggerFor)(this).debug(`[${requestLogID}] response start`, (0, log_1.formatRequestDetails)({
                retryOfRequestLogID,
                url: response.url,
                status: response.status,
                headers: response.headers,
                durationMs: headersTime - startTime,
            }));
            return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
        }
        getAPIList(path, Page, opts) {
            return this.requestAPIList(Page, opts && 'then' in opts ?
                opts.then((opts) => ({ method: 'get', path, ...opts }))
                : { method: 'get', path, ...opts });
        }
        requestAPIList(Page, options) {
            const request = this.makeRequest(options, null, undefined);
            return new Pagination.PagePromise(this, request, Page);
        }
        async fetchWithTimeout(url, init, ms, controller) {
            const { signal, method, ...options } = init || {};
            const abort = this._makeAbort(controller);
            if (signal)
                signal.addEventListener('abort', abort, { once: true });
            const timeout = setTimeout(abort, ms);
            const isReadableBody = (globalThis.ReadableStream && options.body instanceof globalThis.ReadableStream) ||
                (typeof options.body === 'object' && options.body !== null && Symbol.asyncIterator in options.body);
            const fetchOptions = {
                signal: controller.signal,
                ...(isReadableBody ? { duplex: 'half' } : {}),
                method: 'GET',
                ...options,
            };
            if (method) {
                // Custom methods like 'patch' need to be uppercased
                // See https://github.com/nodejs/undici/issues/2294
                fetchOptions.method = method.toUpperCase();
            }
            try {
                // use undefined this binding; fetch errors if bound to something else in browser/cloudflare
                return await this.fetch.call(undefined, url, fetchOptions);
            }
            finally {
                clearTimeout(timeout);
            }
        }
        async shouldRetry(response) {
            // Note this is not a standard header.
            const shouldRetryHeader = response.headers.get('x-should-retry');
            // If the server explicitly says whether or not to retry, obey.
            if (shouldRetryHeader === 'true')
                return true;
            if (shouldRetryHeader === 'false')
                return false;
            // Retry on request timeouts.
            if (response.status === 408)
                return true;
            // Retry on lock timeouts.
            if (response.status === 409)
                return true;
            // Retry on rate limits.
            if (response.status === 429)
                return true;
            // Retry internal errors.
            if (response.status >= 500)
                return true;
            return false;
        }
        async retryRequest(options, retriesRemaining, requestLogID, responseHeaders) {
            let timeoutMillis;
            // Note the `retry-after-ms` header may not be standard, but is a good idea and we'd like proactive support for it.
            const retryAfterMillisHeader = responseHeaders?.get('retry-after-ms');
            if (retryAfterMillisHeader) {
                const timeoutMs = parseFloat(retryAfterMillisHeader);
                if (!Number.isNaN(timeoutMs)) {
                    timeoutMillis = timeoutMs;
                }
            }
            // About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
            const retryAfterHeader = responseHeaders?.get('retry-after');
            if (retryAfterHeader && !timeoutMillis) {
                const timeoutSeconds = parseFloat(retryAfterHeader);
                if (!Number.isNaN(timeoutSeconds)) {
                    timeoutMillis = timeoutSeconds * 1000;
                }
                else {
                    timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
                }
            }
            // If the API asks us to wait a certain amount of time, just do what it
            // says, but otherwise calculate a default
            if (timeoutMillis === undefined) {
                const maxRetries = options.maxRetries ?? this.maxRetries;
                timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
            }
            await (0, sleep_1.sleep)(timeoutMillis);
            return this.makeRequest(options, retriesRemaining - 1, requestLogID);
        }
        calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries) {
            const initialRetryDelay = 0.5;
            const maxRetryDelay = 8.0;
            const numRetries = maxRetries - retriesRemaining;
            // Apply exponential backoff, but not more than the max.
            const sleepSeconds = Math.min(initialRetryDelay * Math.pow(2, numRetries), maxRetryDelay);
            // Apply some jitter, take up to at most 25 percent of the retry time.
            const jitter = 1 - Math.random() * 0.25;
            return sleepSeconds * jitter * 1000;
        }
        async buildRequest(inputOptions, { retryCount = 0 } = {}) {
            const options = { ...inputOptions };
            const { method, path, query, defaultBaseURL } = options;
            const url = this.buildURL(path, query, defaultBaseURL);
            if ('timeout' in options)
                (0, values_1.validatePositiveInteger)('timeout', options.timeout);
            options.timeout = options.timeout ?? this.timeout;
            const { bodyHeaders, body } = this.buildBody({ options });
            const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
            const req = {
                method,
                headers: reqHeaders,
                ...(options.signal && { signal: options.signal }),
                ...(globalThis.ReadableStream &&
                    body instanceof globalThis.ReadableStream && { duplex: 'half' }),
                ...(body && { body }),
                ...(this.fetchOptions ?? {}),
                ...(options.fetchOptions ?? {}),
            };
            return { req, url, timeout: options.timeout };
        }
        async buildHeaders({ options, method, bodyHeaders, retryCount, }) {
            let idempotencyHeaders = {};
            if (this.idempotencyHeader && method !== 'get') {
                if (!options.idempotencyKey)
                    options.idempotencyKey = this.defaultIdempotencyKey();
                idempotencyHeaders[this.idempotencyHeader] = options.idempotencyKey;
            }
            const headers = (0, headers_1.buildHeaders)([
                idempotencyHeaders,
                {
                    Accept: 'application/json',
                    'User-Agent': this.getUserAgent(),
                    'api-version': this.apiVersion,
                    'X-Stainless-Retry-Count': String(retryCount),
                    ...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}),
                    ...(0, detect_platform_1.getPlatformHeaders)(),
                    'X-Auth-Key': this.apiKey,
                    'X-Auth-Email': this.apiEmail,
                },
                await this.authHeaders(options),
                this._options.defaultHeaders,
                bodyHeaders,
                options.headers,
            ]);
            this.validateHeaders(headers);
            return headers.values;
        }
        _makeAbort(controller) {
            // note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
            //       would capture all request options, and cause a memory leak.
            return () => controller.abort();
        }
        buildBody({ options }) {
            const { body, headers: rawHeaders } = options;
            if (!body) {
                // A resource method always passes a `body` key when its operation defines a
                // request body, even if the caller omitted an optional body param. Keep the
                // content-type for those, and only elide it for operations with no body at
                // all (e.g. GET/DELETE).
                if (body == null && 'body' in options) {
                    return tslib_1.__classPrivateFieldGet(this, _BaseCloudflare_encoder, "f").call(this, { body, headers: (0, headers_1.buildHeaders)([rawHeaders]) });
                }
                return { bodyHeaders: undefined, body: undefined };
            }
            const headers = (0, headers_1.buildHeaders)([rawHeaders]);
            if (
            // Pass raw type verbatim
            ArrayBuffer.isView(body) ||
                body instanceof ArrayBuffer ||
                body instanceof DataView ||
                (typeof body === 'string' &&
                    // Preserve legacy string encoding behavior for now
                    headers.values.has('content-type')) ||
                // `Blob` is superset of `File`
                (globalThis.Blob && body instanceof globalThis.Blob) ||
                // `FormData` -> `multipart/form-data`
                body instanceof FormData ||
                // `URLSearchParams` -> `application/x-www-form-urlencoded`
                body instanceof URLSearchParams ||
                // Send chunked stream (each chunk has own `length`)
                (globalThis.ReadableStream && body instanceof globalThis.ReadableStream)) {
                return { bodyHeaders: undefined, body: body };
            }
            else if (typeof body === 'object' &&
                (Symbol.asyncIterator in body ||
                    (Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
                return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body) };
            }
            else if (typeof body === 'object' &&
                headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
                return {
                    bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
                    body: this.stringifyQuery(body),
                };
            }
            else {
                return tslib_1.__classPrivateFieldGet(this, _BaseCloudflare_encoder, "f").call(this, { body, headers });
            }
        }
    }
    _BaseCloudflare_encoder = new WeakMap(), _BaseCloudflare_instances = new WeakSet(), _BaseCloudflare_baseURLOverridden = function _BaseCloudflare_baseURLOverridden() {
        return this.baseURL !== 'https://api.cloudflare.com/client/v4';
    };
    BaseCloudflare.DEFAULT_TIMEOUT = 60000; // 1 minute
    return BaseCloudflare;
})();
exports.BaseCloudflare = BaseCloudflare;
var Cloudflare = /* @__PURE__ */ (() => {
    /**
     * API Client for interfacing with the Cloudflare API.
     */
    class Cloudflare extends BaseCloudflare {
        constructor() {
            super(...arguments);
            this.accounts = new API.Accounts(this);
            this.organizations = new API.Organizations(this);
            this.tenants = new API.Tenants(this);
            this.originCACertificates = new API.OriginCACertificates(this);
            this.ips = new API.IPs(this);
            this.memberships = new API.Memberships(this);
            this.user = new API.User(this);
            this.zones = new API.Zones(this);
            this.loadBalancers = new API.LoadBalancers(this);
            this.cache = new API.Cache(this);
            this.ssl = new API.SSL(this);
            this.acm = new API.ACM(this);
            this.analyticsQuery = new API.AnalyticsQuery(this);
            this.argo = new API.Argo(this);
            this.certificateAuthorities = new API.CertificateAuthorities(this);
            this.clientCertificates = new API.ClientCertificates(this);
            this.customCertificates = new API.CustomCertificates(this);
            this.customCsrs = new API.CustomCsrs(this);
            this.customHostnames = new API.CustomHostnames(this);
            this.customNameservers = new API.CustomNameservers(this);
            this.tenantCustomNameservers = new API.TenantCustomNameservers(this);
            this.dnsFirewall = new API.DNSFirewall(this);
            this.dns = new API.DNS(this);
            this.emailSecurity = new API.EmailSecurity(this);
            this.emailAuth = new API.EmailAuth(this);
            this.emailRouting = new API.EmailRouting(this);
            this.emailSending = new API.EmailSending(this);
            this.filters = new API.Filters(this);
            this.firewall = new API.Firewall(this);
            this.healthchecks = new API.Healthchecks(this);
            this.keylessCertificates = new API.KeylessCertificates(this);
            this.logpush = new API.Logpush(this);
            this.logs = new API.Logs(this);
            this.originTLSClientAuth = new API.OriginTLSClientAuth(this);
            this.pageRules = new API.PageRules(this);
            this.rateLimits = new API.RateLimits(this);
            this.waitingRooms = new API.WaitingRooms(this);
            this.web3 = new API.Web3(this);
            this.workers = new API.Workers(this);
            this.kv = new API.KV(this);
            this.durableObjects = new API.DurableObjects(this);
            this.containers = new API.Containers(this);
            this.queues = new API.Queues(this);
            this.apiGateway = new API.APIGateway(this);
            this.managedTransforms = new API.ManagedTransforms(this);
            this.pageShield = new API.PageShield(this);
            this.rulesets = new API.Rulesets(this);
            this.urlNormalization = new API.URLNormalization(this);
            this.spectrum = new API.Spectrum(this);
            this.addressing = new API.Addressing(this);
            this.dls = new API.DLS(this);
            this.auditLogs = new API.AuditLogs(this);
            this.billing = new API.Billing(this);
            this.brandProtection = new API.BrandProtection(this);
            this.diagnostics = new API.Diagnostics(this);
            this.images = new API.Images(this);
            this.intel = new API.Intel(this);
            this.magicTransit = new API.MagicTransit(this);
            this.DDoSProtection = new API.DDoSProtection(this);
            this.magicNetworkMonitoring = new API.MagicNetworkMonitoring(this);
            this.magicCloudNetworking = new API.MagicCloudNetworking(this);
            this.networkInterconnects = new API.NetworkInterconnects(this);
            this.mtlsCertificates = new API.MTLSCertificates(this);
            this.pages = new API.Pages(this);
            /**
             * Registrar API for searching, checking, registering, and managing domains through Cloudflare Registrar.
             *
             * ## Prerequisites
             *
             * Before using this API, ensure:
             *
             * 1. **Cloudflare account** — the caller must have a valid Cloudflare account.
             * 2. **Billing profile** — the account must have a billing profile with a valid,
             *   current default payment method (credit card or other accepted method).
             *   This cannot be set up via API — the account owner must configure billing
             *   at `https://dash.cloudflare.com/{account_id}/billing/payment-info` before
             *   calling `POST /registrations`.
             * 3. **API authentication** — use an API token or API key with the appropriate
             *   Registrar permissions for the operations you are calling.
             *
             * ## Terminology: domain extension
             *
             * Throughout this API, "extension" refers to the domain extension part of a fully
             * qualified domain name — the portion after the registrable label. For example,
             * in `example.co.uk`, the extension is `co.uk` (not just `uk`). This covers both
             * top-level domains like `com` and multi-level extensions like `co.uk`. This is
             * distinct from other uses of the word "extension" (e.g., EPP extensions).
             *
             * ## Supported extensions
             *
             * This API supports programmatic registration for all extensions supported by
             * the dashboard experience, with the following exceptions:
             *
             * `giving`, `mom`, `inc`, `lol`, `sh`, `link`, `cc`, `new`
             *
             * Cloudflare Registrar supports 400+ extensions in the dashboard. Extensions
             * listed above can be registered at `https://dash.cloudflare.com/{account_id}/domains/registrations`.
             *
             * ## Typical workflow
             *
             * 1. **Search** — call `GET /domain-search?q={keyword}` to discover available domains.
             * 2. **Check** — call `POST /domain-check` with candidate domains to verify real-time
             *   availability and pricing.
             * 3. **Review the response** — if `registrable: false`, inspect `reason` to
             *   understand whether the domain is unavailable, the extension is not supported
             *   by this API, the extension is not supported by Cloudflare Registrar at all,
             *   or the extension's registry has frozen new registrations.
             * 4. **Handle premium domains** — if `tier: premium`, premium registration is
             *   not currently supported by this API. Surface the premium pricing to the user,
             *   but do not proceed to `POST /registrations` for that domain.
             * 5. **Observe the registration schema** — call `GET /extensions/:extension_name`
             *   to discover the required values for registering this extension.
             * 6. **Register** — call `POST /registrations` with the chosen domain name for
             *   supported non-premium registrations.
             * 7. **Confirm completion** — if the response is `201 Created`, registration
             *   completed within the default timeout and no polling is needed.
             * 8. **Poll when needed** — if the response is `202 Accepted`, poll
             *   `links.self` from the workflow response.
             * 9. **Stop for user action** — if `state: action_required`, stop polling and
             *   surface `context.action` to the user.
             *   The workflow will not resolve on its own.
             * 10. **Continue when blocked** — if `state: blocked`, continue polling and
             *   inform the user that a third party, such as the extension registry or losing
             *   registrar, is delaying progress.
             * 11. **Review failures before retrying** — if `state: failed`, review
             *   `error.code` and `error.message`, then decide whether user action or a new
             *   Check call is needed.
             *
             * **All successful domain registrations are non-refundable.** Once the registration
             * workflow completes with `state: succeeded`, the charge cannot be reversed.
             * Confirm pricing and domain choice with the user before calling `POST /registrations`.
             *
             * ## Default behavior for mutating operations
             *
             * By default, mutating operations such as create and update hold the connection
             * for a bounded, server-defined amount of time while the operation completes.
             * In most cases, the response contains a completed workflow status and no
             * polling is required.
             *
             * - **Completed within the synchronous wait window:** Returns `201` (create)
             * or `200` (update) with a `workflow_status` where `state: succeeded` and
             * `completed: true`.
             * - **Still processing after the synchronous wait window:** Returns
             * `202 Accepted` with a `workflow_status` where `completed: false`. Use
             * the `links.self` URL to poll for completion.
             *
             * ## Non-blocking mode
             *
             * To receive an immediate `202 Accepted` response without waiting, send the
             * `Prefer: respond-async` request header (RFC 7240). The server will acknowledge
             * it with a `Preference-Applied: respond-async` response header.
             *
             * ## Polling
             *
             * When the response is `202`, poll the workflow status endpoint indicated by
             * `links.self` in the response body until the workflow reaches a terminal
             * state or requires user action.
             */
            this.registrar = new API.Registrar(this);
            /**
             * Use the Registrar Sandbox API to test domain search, availability checks,
             * registration, and domain management flows without buying real domains.
             *
             * **This API is a test environment for the production Registrar API.**
             *
             * ## Prerequisites
             *
             * Before using this API, make sure you have:
             *
             * 1. **Cloudflare account** — the caller must have a valid Cloudflare account.
             * 2. **API authentication** — create an API token with Registrar Sandbox permissions.
             *
             * ## How the Sandbox API differs from the production Registrar API
             *
             * Because the Sandbox API is intended for testing, it behaves differently from
             * the production Registrar API in a few important ways:
             *
             * 1. **No billing** — you will not be charged real money for purchasing a domain.
             * 2. **No real domains** — purchased domains are test records and will not be
             *   reachable on the Internet.
             * 3. **No DNS zones** — purchasing a domain does not create a zone resource.
             * 4. **No Registration Express Mode** — you must provide full contact data.
             *
             * Sandbox purchases are still persisted. If you purchase a domain in the sandbox,
             * that domain will not be available for others to purchase in the sandbox.
             *
             * ## Terminology: domain extension
             *
             * Throughout this API, "extension" refers to the domain extension part of a fully
             * qualified domain name — the portion after the registrable label. For example,
             * in `example.co.uk`, the extension is `co.uk` (not just `uk`). This covers both
             * top-level domains like `com` and multi-level extensions like `co.uk`. This is
             * distinct from other uses of the word "extension" (e.g., EPP extensions).
             *
             * ## Supported extensions
             *
             * The Sandbox API currently supports programmatic registration for these
             * extensions:
             *
             * `com`, `net`
             *
             * The production Registrar API supports 40+ extensions.
             *
             * Cloudflare Registrar supports 400+ extensions in the dashboard. Extensions
             * not listed above can be registered at `https://dash.cloudflare.com/{account_id}/domains/registrations`.
             *
             * ## Typical workflow
             *
             * 1. **Search** — call `GET /domain-search?q={keyword}` to discover available domains.
             * 2. **Check** — call `POST /domain-check` with candidate domains to verify real-time
             *   availability and pricing.
             * 3. **Review the response** — if `registrable: false`, inspect `reason` to
             *   understand whether the domain is unavailable, the extension is not supported
             *   by this API, the extension is not supported by Cloudflare Registrar at all,
             *   or the extension's registry has frozen new registrations.
             * 4. **Handle premium domains** — if `tier: premium`, premium registration is
             *   not currently supported by this API. The Sandbox API currently supports
             *   only `com` and `net`, which do not have premium registrations, but clients
             *   should still handle this response for consistency with the production
             *   Registrar API. Surface the premium pricing to the user, but do not proceed
             *   to `POST /registrations` for that domain.
             * 5. **Observe the registration schema** — call `GET /extensions/:extension_name`
             *   to discover the required values for registering this extension.
             * 6. **Register** — call `POST /registrations` with the chosen domain name for
             *   supported non-premium registrations.
             * 7. **Confirm completion** — if the response is `201 Created`, registration
             *   completed within the default timeout and no polling is needed.
             * 8. **Poll when needed** — if the response is `202 Accepted`, poll
             *   `links.self` from the workflow response.
             * 9. **Stop for user action** — if `state: action_required`, stop polling and
             *   surface `context.action` to the user.
             *   The workflow will not resolve on its own.
             * 10. **Continue when blocked** — if `state: blocked`, continue polling and
             *   inform the user that a third party, such as the extension registry or losing
             *   registrar, is delaying progress.
             * 11. **Review failures before retrying** — if `state: failed`, review
             *   `error.code` and `error.message`, then decide whether user action or a new
             *   Check call is needed.
             *
             * ## Default behavior for mutating operations
             *
             * By default, mutating operations such as create and update hold the connection
             * for a bounded, server-defined amount of time while the operation completes.
             * In most cases, the response contains a completed workflow status and no
             * polling is required.
             *
             * - **Completed within the synchronous wait window:** Returns `201` (create)
             * or `200` (update) with a `workflow_status` where `state: succeeded` and
             * `completed: true`.
             * - **Still processing after the synchronous wait window:** Returns
             * `202 Accepted` with a `workflow_status` where `completed: false`. Use
             * the `links.self` URL to poll for completion.
             *
             * ## Non-blocking mode
             *
             * To receive an immediate `202 Accepted` response without waiting, send the
             * `Prefer: respond-async` request header (RFC 7240). The server will acknowledge
             * it with a `Preference-Applied: respond-async` response header.
             *
             * ## Polling
             *
             * When the response is `202`, poll the workflow status endpoint indicated by
             * `links.self` in the response body until the workflow reaches a terminal
             * state or requires user action.
             */
            this.registrarSandbox = new API.RegistrarSandbox(this);
            this.requestTracers = new API.RequestTracers(this);
            this.rules = new API.Rules(this);
            this.stream = new API.Stream(this);
            this.alerting = new API.Alerting(this);
            this.d1 = new API.D1Resource(this);
            this.r2 = new API.R2(this);
            this.r2DataCatalog = new API.R2DataCatalog(this);
            this.basinCatalog = new API.BasinCatalog(this);
            this.workersForPlatforms = new API.WorkersForPlatforms(this);
            this.zeroTrust = new API.ZeroTrust(this);
            this.turnstile = new API.Turnstile(this);
            this.connectivity = new API.Connectivity(this);
            this.hyperdrive = new API.HyperdriveResource(this);
            this.rum = new API.RUM(this);
            this.vectorize = new API.Vectorize(this);
            this.urlScanner = new API.URLScanner(this);
            this.vulnerabilityScanner = new API.VulnerabilityScanner(this);
            this.radar = new API.Radar(this);
            this.botManagement = new API.BotManagement(this);
            this.fraud = new API.Fraud(this);
            this.precursor = new API.Precursor(this);
            this.originPostQuantumEncryption = new API.OriginPostQuantumEncryption(this);
            this.originTLSComplianceModes = new API.OriginTLSComplianceModes(this);
            this.googleTagGateway = new API.GoogleTagGateway(this);
            this.zaraz = new API.Zaraz(this);
            this.speed = new API.Speed(this);
            this.dcvDelegation = new API.DCVDelegation(this);
            this.hostnames = new API.Hostnames(this);
            this.snippets = new API.Snippets(this);
            this.realtimeKit = new API.RealtimeKit(this);
            this.calls = new API.Calls(this);
            this.moq = new API.MoQ(this);
            this.managedDefense = new API.ManagedDefense(this);
            this.cloudforceOne = new API.CloudforceOne(this);
            this.aiGateway = new API.AIGateway(this);
            this.flagship = new API.Flagship(this);
            this.iam = new API.IAM(this);
            this.cloudConnector = new API.CloudConnector(this);
            this.botnetFeed = new API.BotnetFeed(this);
            this.securityTXT = new API.SecurityTXT(this);
            this.workflows = new API.Workflows(this);
            this.resourceSharing = new API.ResourceSharing(this);
            this.resourceTagging = new API.ResourceTagging(this);
            this.leakedCredentialChecks = new API.LeakedCredentialChecks(this);
            this.contentScanning = new API.ContentScanning(this);
            this.aiSecurity = new API.AISecurity(this);
            this.csamScanner = new API.CsamScanner(this);
            this.abuseReports = new API.AbuseReports(this);
            this.ai = new API.AI(this);
            this.aiAudit = new API.AIAudit(this);
            this.aiSearch = new API.AISearch(this);
            this.securityCenter = new API.SecurityCenter(this);
            this.browserRendering = new API.BrowserRendering(this);
            this.customPages = new API.CustomPages(this);
            this.secretsStore = new API.SecretsStore(this);
            this.pipelines = new API.Pipelines(this);
            this.schemaValidation = new API.SchemaValidation(this);
            this.tokenValidation = new API.TokenValidation(this);
            this.fieldExtractors = new API.FieldExtractors(this);
        }
    }
    _a = Cloudflare;
    Cloudflare.Cloudflare = _a;
    Cloudflare.CloudflareError = Errors.CloudflareError;
    Cloudflare.APIError = Errors.APIError;
    Cloudflare.APIConnectionError = Errors.APIConnectionError;
    Cloudflare.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
    Cloudflare.APIUserAbortError = Errors.APIUserAbortError;
    Cloudflare.NotFoundError = Errors.NotFoundError;
    Cloudflare.ConflictError = Errors.ConflictError;
    Cloudflare.RateLimitError = Errors.RateLimitError;
    Cloudflare.BadRequestError = Errors.BadRequestError;
    Cloudflare.AuthenticationError = Errors.AuthenticationError;
    Cloudflare.InternalServerError = Errors.InternalServerError;
    Cloudflare.PermissionDeniedError = Errors.PermissionDeniedError;
    Cloudflare.UnprocessableEntityError = Errors.UnprocessableEntityError;
    Cloudflare.toFile = Uploads.toFile;
    Cloudflare.Accounts = accounts_1.Accounts;
    Cloudflare.Organizations = organizations_1.Organizations;
    Cloudflare.Tenants = tenants_1.Tenants;
    Cloudflare.OriginCACertificates = origin_ca_certificates_1.OriginCACertificates;
    Cloudflare.IPs = ips_1.IPs;
    Cloudflare.Memberships = memberships_1.Memberships;
    Cloudflare.User = user_1.User;
    Cloudflare.Zones = zones_1.Zones;
    Cloudflare.LoadBalancers = load_balancers_1.LoadBalancers;
    Cloudflare.Cache = cache_1.Cache;
    Cloudflare.SSL = ssl_1.SSL;
    Cloudflare.ACM = acm_1.ACM;
    Cloudflare.AnalyticsQuery = analytics_query_1.AnalyticsQuery;
    Cloudflare.Argo = argo_1.Argo;
    Cloudflare.CertificateAuthorities = certificate_authorities_1.CertificateAuthorities;
    Cloudflare.ClientCertificates = client_certificates_1.ClientCertificates;
    Cloudflare.CustomCertificates = custom_certificates_1.CustomCertificates;
    Cloudflare.CustomCsrs = custom_csrs_1.CustomCsrs;
    Cloudflare.CustomHostnames = custom_hostnames_1.CustomHostnames;
    Cloudflare.CustomNameservers = custom_nameservers_1.CustomNameservers;
    Cloudflare.TenantCustomNameservers = tenant_custom_nameservers_1.TenantCustomNameservers;
    Cloudflare.DNSFirewall = dns_firewall_1.DNSFirewall;
    Cloudflare.DNS = dns_1.DNS;
    Cloudflare.EmailSecurity = email_security_1.EmailSecurity;
    Cloudflare.EmailAuth = email_auth_1.EmailAuth;
    Cloudflare.EmailRouting = email_routing_1.EmailRouting;
    Cloudflare.EmailSending = email_sending_1.EmailSending;
    Cloudflare.Filters = filters_1.Filters;
    Cloudflare.Firewall = firewall_1.Firewall;
    Cloudflare.Healthchecks = healthchecks_1.Healthchecks;
    Cloudflare.KeylessCertificates = keyless_certificates_1.KeylessCertificates;
    Cloudflare.Logpush = logpush_1.Logpush;
    Cloudflare.Logs = logs_1.Logs;
    Cloudflare.OriginTLSClientAuth = origin_tls_client_auth_1.OriginTLSClientAuth;
    Cloudflare.PageRules = page_rules_1.PageRules;
    Cloudflare.RateLimits = rate_limits_1.RateLimits;
    Cloudflare.WaitingRooms = waiting_rooms_1.WaitingRooms;
    Cloudflare.Web3 = web3_1.Web3;
    Cloudflare.Workers = workers_1.Workers;
    Cloudflare.KV = kv_1.KV;
    Cloudflare.DurableObjects = durable_objects_1.DurableObjects;
    Cloudflare.Containers = containers_1.Containers;
    Cloudflare.Queues = queues_1.Queues;
    Cloudflare.APIGateway = api_gateway_1.APIGateway;
    Cloudflare.ManagedTransforms = managed_transforms_1.ManagedTransforms;
    Cloudflare.PageShield = page_shield_1.PageShield;
    Cloudflare.Rulesets = rulesets_1.Rulesets;
    Cloudflare.URLNormalization = url_normalization_1.URLNormalization;
    Cloudflare.Spectrum = spectrum_1.Spectrum;
    Cloudflare.Addressing = addressing_1.Addressing;
    Cloudflare.DLS = dls_1.DLS;
    Cloudflare.AuditLogs = audit_logs_1.AuditLogs;
    Cloudflare.Billing = billing_1.Billing;
    Cloudflare.BrandProtection = brand_protection_1.BrandProtection;
    Cloudflare.Diagnostics = diagnostics_1.Diagnostics;
    Cloudflare.Images = images_1.Images;
    Cloudflare.Intel = intel_1.Intel;
    Cloudflare.MagicTransit = magic_transit_1.MagicTransit;
    Cloudflare.DDoSProtection = ddos_protection_1.DDoSProtection;
    Cloudflare.MagicNetworkMonitoring = magic_network_monitoring_1.MagicNetworkMonitoring;
    Cloudflare.MagicCloudNetworking = magic_cloud_networking_1.MagicCloudNetworking;
    Cloudflare.NetworkInterconnects = network_interconnects_1.NetworkInterconnects;
    Cloudflare.MTLSCertificates = mtls_certificates_1.MTLSCertificates;
    Cloudflare.Pages = pages_1.Pages;
    Cloudflare.Registrar = registrar_1.Registrar;
    Cloudflare.RegistrarSandbox = registrar_sandbox_1.RegistrarSandbox;
    Cloudflare.RequestTracers = request_tracers_1.RequestTracers;
    Cloudflare.Rules = rules_1.Rules;
    Cloudflare.Stream = stream_1.Stream;
    Cloudflare.Alerting = alerting_1.Alerting;
    Cloudflare.D1Resource = d1_1.D1Resource;
    Cloudflare.R2 = r2_1.R2;
    Cloudflare.R2DataCatalog = r2_data_catalog_1.R2DataCatalog;
    Cloudflare.BasinCatalog = basin_catalog_1.BasinCatalog;
    Cloudflare.WorkersForPlatforms = workers_for_platforms_1.WorkersForPlatforms;
    Cloudflare.ZeroTrust = zero_trust_1.ZeroTrust;
    Cloudflare.Turnstile = turnstile_1.Turnstile;
    Cloudflare.Connectivity = connectivity_1.Connectivity;
    Cloudflare.HyperdriveResource = hyperdrive_1.HyperdriveResource;
    Cloudflare.RUM = rum_1.RUM;
    Cloudflare.Vectorize = vectorize_1.Vectorize;
    Cloudflare.URLScanner = url_scanner_1.URLScanner;
    Cloudflare.VulnerabilityScanner = vulnerability_scanner_1.VulnerabilityScanner;
    Cloudflare.Radar = radar_1.Radar;
    Cloudflare.BotManagement = bot_management_1.BotManagement;
    Cloudflare.Fraud = fraud_1.Fraud;
    Cloudflare.Precursor = precursor_1.Precursor;
    Cloudflare.OriginPostQuantumEncryption = origin_post_quantum_encryption_1.OriginPostQuantumEncryption;
    Cloudflare.OriginTLSComplianceModes = origin_tls_compliance_modes_1.OriginTLSComplianceModes;
    Cloudflare.GoogleTagGateway = google_tag_gateway_1.GoogleTagGateway;
    Cloudflare.Zaraz = zaraz_1.Zaraz;
    Cloudflare.Speed = speed_1.Speed;
    Cloudflare.DCVDelegation = dcv_delegation_1.DCVDelegation;
    Cloudflare.Hostnames = hostnames_1.Hostnames;
    Cloudflare.Snippets = snippets_1.Snippets;
    Cloudflare.RealtimeKit = realtime_kit_1.RealtimeKit;
    Cloudflare.Calls = calls_1.Calls;
    Cloudflare.MoQ = moq_1.MoQ;
    Cloudflare.ManagedDefense = managed_defense_1.ManagedDefense;
    Cloudflare.CloudforceOne = cloudforce_one_1.CloudforceOne;
    Cloudflare.AIGateway = ai_gateway_1.AIGateway;
    Cloudflare.Flagship = flagship_1.Flagship;
    Cloudflare.IAM = iam_1.IAM;
    Cloudflare.CloudConnector = cloud_connector_1.CloudConnector;
    Cloudflare.BotnetFeed = botnet_feed_1.BotnetFeed;
    Cloudflare.SecurityTXT = security_txt_1.SecurityTXT;
    Cloudflare.Workflows = workflows_1.Workflows;
    Cloudflare.ResourceSharing = resource_sharing_1.ResourceSharing;
    Cloudflare.ResourceTagging = resource_tagging_1.ResourceTagging;
    Cloudflare.LeakedCredentialChecks = leaked_credential_checks_1.LeakedCredentialChecks;
    Cloudflare.ContentScanning = content_scanning_1.ContentScanning;
    Cloudflare.AISecurity = ai_security_1.AISecurity;
    Cloudflare.CsamScanner = csam_scanner_1.CsamScanner;
    Cloudflare.AbuseReports = abuse_reports_1.AbuseReports;
    Cloudflare.AI = ai_1.AI;
    Cloudflare.AIAudit = ai_audit_1.AIAudit;
    Cloudflare.AISearch = aisearch_1.AISearch;
    Cloudflare.SecurityCenter = security_center_1.SecurityCenter;
    Cloudflare.BrowserRendering = browser_rendering_1.BrowserRendering;
    Cloudflare.CustomPages = custom_pages_1.CustomPages;
    Cloudflare.SecretsStore = secrets_store_1.SecretsStore;
    Cloudflare.Pipelines = pipelines_1.Pipelines;
    Cloudflare.SchemaValidation = schema_validation_1.SchemaValidation;
    Cloudflare.TokenValidation = token_validation_1.TokenValidation;
    Cloudflare.FieldExtractors = field_extractors_1.FieldExtractors;
    return Cloudflare;
})();
exports.Cloudflare = Cloudflare;
//# sourceMappingURL=client.js.map