From dc634d2b2686a51afcff5e830445ca7790eb1209 Mon Sep 17 00:00:00 2001 From: Taiichiro Nagase Date: Wed, 21 Jan 2026 23:12:59 +0900 Subject: [PATCH] fix(core): support fetch option --- packages/client/src/LangfuseClient.ts | 19 +++++++++++++++++++ packages/core/src/api/Client.ts | 2 ++ .../annotationQueues/client/Client.ts | 12 ++++++++++++ .../blobStorageIntegrations/client/Client.ts | 5 +++++ .../api/resources/comments/client/Client.ts | 5 +++++ .../resources/datasetItems/client/Client.ts | 6 ++++++ .../datasetRunItems/client/Client.ts | 4 ++++ .../api/resources/datasets/client/Client.ts | 8 ++++++++ .../api/api/resources/health/client/Client.ts | 3 +++ .../api/resources/ingestion/client/Client.ts | 3 +++ .../resources/llmConnections/client/Client.ts | 4 ++++ .../api/api/resources/media/client/Client.ts | 5 +++++ .../api/resources/metrics/client/Client.ts | 3 +++ .../api/resources/metricsV2/client/Client.ts | 3 +++ .../api/api/resources/models/client/Client.ts | 6 ++++++ .../resources/observations/client/Client.ts | 4 ++++ .../resources/observationsV2/client/Client.ts | 3 +++ .../resources/opentelemetry/client/Client.ts | 3 +++ .../resources/organizations/client/Client.ts | 10 ++++++++++ .../api/resources/projects/client/Client.ts | 9 +++++++++ .../resources/promptVersion/client/Client.ts | 3 +++ .../api/resources/prompts/client/Client.ts | 6 ++++++ .../api/api/resources/scim/client/Client.ts | 9 +++++++++ .../api/api/resources/score/client/Client.ts | 4 ++++ .../resources/scoreConfigs/client/Client.ts | 6 ++++++ .../api/resources/scoreV2/client/Client.ts | 4 ++++ .../api/resources/sessions/client/Client.ts | 4 ++++ .../api/api/resources/trace/client/Client.ts | 6 ++++++ packages/core/src/api/core/fetcher/Fetcher.ts | 3 ++- 29 files changed, 161 insertions(+), 1 deletion(-) diff --git a/packages/client/src/LangfuseClient.ts b/packages/client/src/LangfuseClient.ts index 4750b45af..8abf2ee49 100644 --- a/packages/client/src/LangfuseClient.ts +++ b/packages/client/src/LangfuseClient.ts @@ -49,6 +49,24 @@ export interface LangfuseClientParams { * Additional HTTP headers to include with API requests. */ additionalHeaders?: Record; + + /** + * Custom fetch function to use for HTTP requests. + * Useful for testing, proxying, or customizing request behavior. + * + * @example + * ```typescript + * const customFetch = async (url, init) => { + * console.log('Making request to:', url); + * return fetch(url, init); + * }; + * + * const langfuse = new LangfuseClient({ + * fetch: customFetch + * }); + * ``` + */ + fetch?: typeof fetch; } /** @@ -284,6 +302,7 @@ export class LangfuseClient { xLangfuseSdkName: "javascript", environment: "", // noop as baseUrl is set headers: params?.additionalHeaders, + fetch: params?.fetch, }); logger.debug("Initialized LangfuseClient with params:", { diff --git a/packages/core/src/api/Client.ts b/packages/core/src/api/Client.ts index dbed62d75..40ec60242 100644 --- a/packages/core/src/api/Client.ts +++ b/packages/core/src/api/Client.ts @@ -49,6 +49,8 @@ export declare namespace LangfuseAPIClient { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { diff --git a/packages/core/src/api/api/resources/annotationQueues/client/Client.ts b/packages/core/src/api/api/resources/annotationQueues/client/Client.ts index fd55791e9..3c9812a21 100644 --- a/packages/core/src/api/api/resources/annotationQueues/client/Client.ts +++ b/packages/core/src/api/api/resources/annotationQueues/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace AnnotationQueues { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -131,6 +133,7 @@ export class AnnotationQueues { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -259,6 +262,7 @@ export class AnnotationQueues { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -380,6 +384,7 @@ export class AnnotationQueues { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -521,6 +526,7 @@ export class AnnotationQueues { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -645,6 +651,7 @@ export class AnnotationQueues { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -776,6 +783,7 @@ export class AnnotationQueues { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -908,6 +916,7 @@ export class AnnotationQueues { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -1034,6 +1043,7 @@ export class AnnotationQueues { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -1165,6 +1175,7 @@ export class AnnotationQueues { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -1296,6 +1307,7 @@ export class AnnotationQueues { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/blobStorageIntegrations/client/Client.ts b/packages/core/src/api/api/resources/blobStorageIntegrations/client/Client.ts index 2a9752df6..f1b3fefbf 100644 --- a/packages/core/src/api/api/resources/blobStorageIntegrations/client/Client.ts +++ b/packages/core/src/api/api/resources/blobStorageIntegrations/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace BlobStorageIntegrations { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -117,6 +119,7 @@ export class BlobStorageIntegrations { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -256,6 +259,7 @@ export class BlobStorageIntegrations { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -379,6 +383,7 @@ export class BlobStorageIntegrations { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/comments/client/Client.ts b/packages/core/src/api/api/resources/comments/client/Client.ts index 72afae746..763804164 100644 --- a/packages/core/src/api/api/resources/comments/client/Client.ts +++ b/packages/core/src/api/api/resources/comments/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Comments { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -127,6 +129,7 @@ export class Comments { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -273,6 +276,7 @@ export class Comments { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -394,6 +398,7 @@ export class Comments { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/datasetItems/client/Client.ts b/packages/core/src/api/api/resources/datasetItems/client/Client.ts index 2fe9e002c..0e8222087 100644 --- a/packages/core/src/api/api/resources/datasetItems/client/Client.ts +++ b/packages/core/src/api/api/resources/datasetItems/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace DatasetItems { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -130,6 +132,7 @@ export class DatasetItems { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -249,6 +252,7 @@ export class DatasetItems { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -396,6 +400,7 @@ export class DatasetItems { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -517,6 +522,7 @@ export class DatasetItems { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/datasetRunItems/client/Client.ts b/packages/core/src/api/api/resources/datasetRunItems/client/Client.ts index 920e1828e..0092ed701 100644 --- a/packages/core/src/api/api/resources/datasetRunItems/client/Client.ts +++ b/packages/core/src/api/api/resources/datasetRunItems/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace DatasetRunItems { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -128,6 +130,7 @@ export class DatasetRunItems { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -267,6 +270,7 @@ export class DatasetRunItems { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/datasets/client/Client.ts b/packages/core/src/api/api/resources/datasets/client/Client.ts index 923ad0e00..f146be252 100644 --- a/packages/core/src/api/api/resources/datasets/client/Client.ts +++ b/packages/core/src/api/api/resources/datasets/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Datasets { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -131,6 +133,7 @@ export class Datasets { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -252,6 +255,7 @@ export class Datasets { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -382,6 +386,7 @@ export class Datasets { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -506,6 +511,7 @@ export class Datasets { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -630,6 +636,7 @@ export class Datasets { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -767,6 +774,7 @@ export class Datasets { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/health/client/Client.ts b/packages/core/src/api/api/resources/health/client/Client.ts index f7a0428e1..50279ff19 100644 --- a/packages/core/src/api/api/resources/health/client/Client.ts +++ b/packages/core/src/api/api/resources/health/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Health { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -114,6 +116,7 @@ export class Health { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/ingestion/client/Client.ts b/packages/core/src/api/api/resources/ingestion/client/Client.ts index 60e3dcc12..7a0baa469 100644 --- a/packages/core/src/api/api/resources/ingestion/client/Client.ts +++ b/packages/core/src/api/api/resources/ingestion/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Ingestion { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -187,6 +189,7 @@ export class Ingestion { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/llmConnections/client/Client.ts b/packages/core/src/api/api/resources/llmConnections/client/Client.ts index 7b40b185d..06f05ea2c 100644 --- a/packages/core/src/api/api/resources/llmConnections/client/Client.ts +++ b/packages/core/src/api/api/resources/llmConnections/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace LlmConnections { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -131,6 +133,7 @@ export class LlmConnections { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -264,6 +267,7 @@ export class LlmConnections { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/media/client/Client.ts b/packages/core/src/api/api/resources/media/client/Client.ts index e3bcd1acc..b61000810 100644 --- a/packages/core/src/api/api/resources/media/client/Client.ts +++ b/packages/core/src/api/api/resources/media/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Media { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -118,6 +120,7 @@ export class Media { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -250,6 +253,7 @@ export class Media { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { data: undefined, rawResponse: _response.rawResponse }; @@ -378,6 +382,7 @@ export class Media { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/metrics/client/Client.ts b/packages/core/src/api/api/resources/metrics/client/Client.ts index 5170c9201..79e01bcca 100644 --- a/packages/core/src/api/api/resources/metrics/client/Client.ts +++ b/packages/core/src/api/api/resources/metrics/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Metrics { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -130,6 +132,7 @@ export class Metrics { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/metricsV2/client/Client.ts b/packages/core/src/api/api/resources/metricsV2/client/Client.ts index 09ede1405..af17ad62f 100644 --- a/packages/core/src/api/api/resources/metricsV2/client/Client.ts +++ b/packages/core/src/api/api/resources/metricsV2/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace MetricsV2 { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -226,6 +228,7 @@ export class MetricsV2 { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/models/client/Client.ts b/packages/core/src/api/api/resources/models/client/Client.ts index cd58104da..e1329afb8 100644 --- a/packages/core/src/api/api/resources/models/client/Client.ts +++ b/packages/core/src/api/api/resources/models/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Models { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -132,6 +134,7 @@ export class Models { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -266,6 +269,7 @@ export class Models { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -385,6 +389,7 @@ export class Models { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -506,6 +511,7 @@ export class Models { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { data: undefined, rawResponse: _response.rawResponse }; diff --git a/packages/core/src/api/api/resources/observations/client/Client.ts b/packages/core/src/api/api/resources/observations/client/Client.ts index 9508f7082..c94435faf 100644 --- a/packages/core/src/api/api/resources/observations/client/Client.ts +++ b/packages/core/src/api/api/resources/observations/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Observations { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -118,6 +120,7 @@ export class Observations { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -316,6 +319,7 @@ export class Observations { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/observationsV2/client/Client.ts b/packages/core/src/api/api/resources/observationsV2/client/Client.ts index f63f04f1a..a5e882fea 100644 --- a/packages/core/src/api/api/resources/observationsV2/client/Client.ts +++ b/packages/core/src/api/api/resources/observationsV2/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace ObservationsV2 { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -231,6 +233,7 @@ export class ObservationsV2 { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/opentelemetry/client/Client.ts b/packages/core/src/api/api/resources/opentelemetry/client/Client.ts index 7bcaceada..2322e7324 100644 --- a/packages/core/src/api/api/resources/opentelemetry/client/Client.ts +++ b/packages/core/src/api/api/resources/opentelemetry/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Opentelemetry { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -173,6 +175,7 @@ export class Opentelemetry { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/organizations/client/Client.ts b/packages/core/src/api/api/resources/organizations/client/Client.ts index b0f26f04f..ac0bdb185 100644 --- a/packages/core/src/api/api/resources/organizations/client/Client.ts +++ b/packages/core/src/api/api/resources/organizations/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Organizations { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -115,6 +117,7 @@ export class Organizations { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -242,6 +245,7 @@ export class Organizations { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -368,6 +372,7 @@ export class Organizations { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -489,6 +494,7 @@ export class Organizations { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -619,6 +625,7 @@ export class Organizations { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -748,6 +755,7 @@ export class Organizations { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -866,6 +874,7 @@ export class Organizations { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -984,6 +993,7 @@ export class Organizations { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/projects/client/Client.ts b/packages/core/src/api/api/resources/projects/client/Client.ts index f5d4480ca..810069c0b 100644 --- a/packages/core/src/api/api/resources/projects/client/Client.ts +++ b/packages/core/src/api/api/resources/projects/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Projects { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -113,6 +115,7 @@ export class Projects { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -241,6 +244,7 @@ export class Projects { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -372,6 +376,7 @@ export class Projects { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -493,6 +498,7 @@ export class Projects { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -614,6 +620,7 @@ export class Projects { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -745,6 +752,7 @@ export class Projects { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -869,6 +877,7 @@ export class Projects { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/promptVersion/client/Client.ts b/packages/core/src/api/api/resources/promptVersion/client/Client.ts index b6c38196e..c519da32b 100644 --- a/packages/core/src/api/api/resources/promptVersion/client/Client.ts +++ b/packages/core/src/api/api/resources/promptVersion/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace PromptVersion { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -130,6 +132,7 @@ export class PromptVersion { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/prompts/client/Client.ts b/packages/core/src/api/api/resources/prompts/client/Client.ts index 94e45efff..9b6443321 100644 --- a/packages/core/src/api/api/resources/prompts/client/Client.ts +++ b/packages/core/src/api/api/resources/prompts/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Prompts { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -135,6 +137,7 @@ export class Prompts { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -290,6 +293,7 @@ export class Prompts { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -430,6 +434,7 @@ export class Prompts { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -567,6 +572,7 @@ export class Prompts { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { data: undefined, rawResponse: _response.rawResponse }; diff --git a/packages/core/src/api/api/resources/scim/client/Client.ts b/packages/core/src/api/api/resources/scim/client/Client.ts index d85f2100e..1cfb5d584 100644 --- a/packages/core/src/api/api/resources/scim/client/Client.ts +++ b/packages/core/src/api/api/resources/scim/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Scim { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -115,6 +117,7 @@ export class Scim { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -233,6 +236,7 @@ export class Scim { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -351,6 +355,7 @@ export class Scim { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -489,6 +494,7 @@ export class Scim { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -621,6 +627,7 @@ export class Scim { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -742,6 +749,7 @@ export class Scim { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -863,6 +871,7 @@ export class Scim { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/score/client/Client.ts b/packages/core/src/api/api/resources/score/client/Client.ts index e7cce3d8b..6f293294a 100644 --- a/packages/core/src/api/api/resources/score/client/Client.ts +++ b/packages/core/src/api/api/resources/score/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Score { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -135,6 +137,7 @@ export class Score { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -256,6 +259,7 @@ export class Score { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { data: undefined, rawResponse: _response.rawResponse }; diff --git a/packages/core/src/api/api/resources/scoreConfigs/client/Client.ts b/packages/core/src/api/api/resources/scoreConfigs/client/Client.ts index 777dcedba..fd02a17fb 100644 --- a/packages/core/src/api/api/resources/scoreConfigs/client/Client.ts +++ b/packages/core/src/api/api/resources/scoreConfigs/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace ScoreConfigs { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -128,6 +130,7 @@ export class ScoreConfigs { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -262,6 +265,7 @@ export class ScoreConfigs { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -383,6 +387,7 @@ export class ScoreConfigs { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -517,6 +522,7 @@ export class ScoreConfigs { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/scoreV2/client/Client.ts b/packages/core/src/api/api/resources/scoreV2/client/Client.ts index f584d8ef0..3c88e5cec 100644 --- a/packages/core/src/api/api/resources/scoreV2/client/Client.ts +++ b/packages/core/src/api/api/resources/scoreV2/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace ScoreV2 { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -227,6 +229,7 @@ export class ScoreV2 { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -348,6 +351,7 @@ export class ScoreV2 { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/sessions/client/Client.ts b/packages/core/src/api/api/resources/sessions/client/Client.ts index 15d3d44e9..eea6f2ec2 100644 --- a/packages/core/src/api/api/resources/sessions/client/Client.ts +++ b/packages/core/src/api/api/resources/sessions/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Sessions { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -147,6 +149,7 @@ export class Sessions { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -268,6 +271,7 @@ export class Sessions { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/api/resources/trace/client/Client.ts b/packages/core/src/api/api/resources/trace/client/Client.ts index 2d1e7c83f..317a62e8b 100644 --- a/packages/core/src/api/api/resources/trace/client/Client.ts +++ b/packages/core/src/api/api/resources/trace/client/Client.ts @@ -28,6 +28,8 @@ export declare namespace Trace { string, string | core.Supplier | null | undefined >; + /** Custom fetch function to use for HTTP requests */ + fetch?: typeof fetch; } export interface RequestOptions { @@ -118,6 +120,7 @@ export class Trace { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -239,6 +242,7 @@ export class Trace { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -444,6 +448,7 @@ export class Trace { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { @@ -570,6 +575,7 @@ export class Trace { : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, + fetch: this._options.fetch, }); if (_response.ok) { return { diff --git a/packages/core/src/api/core/fetcher/Fetcher.ts b/packages/core/src/api/core/fetcher/Fetcher.ts index a74add353..cbe25d2a6 100644 --- a/packages/core/src/api/core/fetcher/Fetcher.ts +++ b/packages/core/src/api/core/fetcher/Fetcher.ts @@ -43,6 +43,7 @@ export declare namespace Fetcher { | "arrayBuffer" | "binary-response"; duplex?: "half"; + fetch?: typeof fetch; } export type Error = @@ -105,7 +106,7 @@ export async function fetcherImpl( body: args.body, type: args.requestType === "json" ? "json" : "other", }); - const fetchFn = await getFetchFn(); + const fetchFn = args.fetch ?? (await getFetchFn()); try { const response = await requestWithRetries(