@algolia/client-common 5.55.2 → 5.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/common.d.cts CHANGED
@@ -1,3 +1,96 @@
1
+ type Headers = Record<string, string>;
2
+ type QueryParameters = Record<string, any>;
3
+ /**
4
+ * The method of the request.
5
+ */
6
+ type Method = 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT';
7
+ type Request = {
8
+ method: Method;
9
+ /**
10
+ * The path of the REST API to send the request to.
11
+ */
12
+ path: string;
13
+ queryParameters: QueryParameters;
14
+ data?: Array<Record<string, any>> | Record<string, any> | undefined;
15
+ headers: Headers;
16
+ /**
17
+ * If the given request should persist on the cache. Keep in mind,
18
+ * that some methods may have this option enabled by default.
19
+ */
20
+ cacheable?: boolean | undefined;
21
+ /**
22
+ * Some POST methods in the Algolia REST API uses the `read` transporter.
23
+ * This information is defined at the spec level.
24
+ */
25
+ useReadTransporter?: boolean | undefined;
26
+ };
27
+ type EndRequest = Pick<Request, 'headers' | 'method'> & {
28
+ /**
29
+ * The full URL of the REST API.
30
+ */
31
+ url: string;
32
+ /**
33
+ * The connection timeout, in milliseconds.
34
+ */
35
+ connectTimeout: number;
36
+ /**
37
+ * The response timeout, in milliseconds.
38
+ */
39
+ responseTimeout: number;
40
+ data?: string | Uint8Array | undefined;
41
+ };
42
+ type Response = {
43
+ /**
44
+ * The body of the response.
45
+ */
46
+ content: string;
47
+ /**
48
+ * The headers of the response, with lower-cased names. Optional so that custom requesters that
49
+ * don't capture headers remain valid, in which case the `WithHTTPInfo` methods expose no headers.
50
+ */
51
+ headers?: Headers | undefined;
52
+ /**
53
+ * Whether the API call is timed out or not.
54
+ */
55
+ isTimedOut: boolean;
56
+ /**
57
+ * The HTTP status code of the response.
58
+ */
59
+ status: number;
60
+ };
61
+ type Requester = {
62
+ /**
63
+ * Sends the given `request` to the server.
64
+ */
65
+ send: (request: EndRequest) => Promise<Response>;
66
+ /**
67
+ * Sends the given `request` and returns a raw byte stream for streaming responses (e.g. SSE).
68
+ */
69
+ sendStream?: (request: EndRequest) => Promise<ReadableStream<Uint8Array>>;
70
+ };
71
+
72
+ /**
73
+ * The full HTTP response of an API call, as returned by the `WithHTTPInfo` variant of each method.
74
+ */
75
+ type AlgoliaHttpResponse<TData> = {
76
+ /**
77
+ * The HTTP status code of the response.
78
+ */
79
+ status: number;
80
+ /**
81
+ * The headers of the response, with lower-cased names. Undefined when the requester does not capture headers.
82
+ */
83
+ headers?: Headers | undefined;
84
+ /**
85
+ * The raw body of the response.
86
+ */
87
+ content: string;
88
+ /**
89
+ * The deserialized body of the response.
90
+ */
91
+ data: TData;
92
+ };
93
+
1
94
  type Cache = {
2
95
  /**
3
96
  * Gets the value of the given `key`.
@@ -169,75 +262,13 @@ type Logger = {
169
262
  */
170
263
  info: (message: string, args?: any | undefined) => Promise<void>;
171
264
  /**
172
- * Logs error messages.
173
- */
174
- error: (message: string, args?: any | undefined) => Promise<void>;
175
- };
176
-
177
- type Headers = Record<string, string>;
178
- type QueryParameters = Record<string, any>;
179
- /**
180
- * The method of the request.
181
- */
182
- type Method = 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT';
183
- type Request = {
184
- method: Method;
185
- /**
186
- * The path of the REST API to send the request to.
187
- */
188
- path: string;
189
- queryParameters: QueryParameters;
190
- data?: Array<Record<string, any>> | Record<string, any> | undefined;
191
- headers: Headers;
192
- /**
193
- * If the given request should persist on the cache. Keep in mind,
194
- * that some methods may have this option enabled by default.
265
+ * Logs warning messages. When not implemented, warnings fall back to `console.warn` so they stay visible with the default no-op logger.
195
266
  */
196
- cacheable?: boolean | undefined;
267
+ warn?: (message: string, args?: any | undefined) => Promise<void>;
197
268
  /**
198
- * Some POST methods in the Algolia REST API uses the `read` transporter.
199
- * This information is defined at the spec level.
200
- */
201
- useReadTransporter?: boolean | undefined;
202
- };
203
- type EndRequest = Pick<Request, 'headers' | 'method'> & {
204
- /**
205
- * The full URL of the REST API.
206
- */
207
- url: string;
208
- /**
209
- * The connection timeout, in milliseconds.
210
- */
211
- connectTimeout: number;
212
- /**
213
- * The response timeout, in milliseconds.
214
- */
215
- responseTimeout: number;
216
- data?: string | Uint8Array | undefined;
217
- };
218
- type Response = {
219
- /**
220
- * The body of the response.
221
- */
222
- content: string;
223
- /**
224
- * Whether the API call is timed out or not.
225
- */
226
- isTimedOut: boolean;
227
- /**
228
- * The HTTP status code of the response.
229
- */
230
- status: number;
231
- };
232
- type Requester = {
233
- /**
234
- * Sends the given `request` to the server.
235
- */
236
- send: (request: EndRequest) => Promise<Response>;
237
- /**
238
- * Sends the given `request` and returns a raw byte stream for streaming responses (e.g. SSE).
269
+ * Logs error messages.
239
270
  */
240
- sendStream?: (request: EndRequest) => Promise<ReadableStream<Uint8Array>>;
271
+ error: (message: string, args?: any | undefined) => Promise<void>;
241
272
  };
242
273
 
243
274
  type RequestOptions = Pick<Request, 'cacheable'> & {
@@ -374,6 +405,12 @@ type TransporterOptions = {
374
405
  */
375
406
  compress?: (data: string) => Promise<Uint8Array>;
376
407
  compression?: 'gzip';
408
+ /**
409
+ * Where the generated Request-ID is sent: as the `Request-ID` header, or as the
410
+ * `x-algolia-request-id` query parameter. When undefined, no Request-ID is sent.
411
+ * A caller-supplied Request-ID is never overwritten.
412
+ */
413
+ requestIdChannel?: 'headers' | 'queryParameters' | undefined;
377
414
  };
378
415
  type Transporter = TransporterOptions & {
379
416
  /**
@@ -383,6 +420,18 @@ type Transporter = TransporterOptions & {
383
420
  request: <TResponse>(baseRequest: Request, baseRequestOptions?: RequestOptions) => Promise<TResponse>;
384
421
  requestStream: (baseRequest: Request, baseRequestOptions?: RequestOptions) => AsyncGenerator<ServerSentEvent>;
385
422
  };
423
+ /**
424
+ * The transporter returned by `createTransporter`. Kept separate from `Transporter` so that
425
+ * existing implementations of `Transporter` remain type-valid.
426
+ */
427
+ type TransporterWithHttpInfo = Transporter & {
428
+ /**
429
+ * Performs a request and returns the full HTTP response information — status code,
430
+ * headers (when the requester captures them), raw body and deserialized data.
431
+ * Both the requests and the responses caches are bypassed: it always hits the network.
432
+ */
433
+ requestWithHttpInfo: <TData>(baseRequest: Request, baseRequestOptions?: RequestOptions) => Promise<AlgoliaHttpResponse<TData>>;
434
+ };
386
435
 
387
436
  type AuthMode = 'WithinHeaders' | 'WithinQueryParameters';
388
437
  type OverriddenTransporterOptions = 'baseHeaders' | 'baseQueryParameters' | 'hosts';
@@ -474,11 +523,16 @@ declare function getAlgoliaAgent({ algoliaAgents, client, version }: GetAlgoliaA
474
523
 
475
524
  declare function createNullLogger(): Logger;
476
525
 
526
+ /**
527
+ * Prefers the logger's optional `warn` method and falls back to `console.warn`, so warnings stay visible with the default no-op logger.
528
+ */
529
+ declare function logWarning(logger: Logger, message: string): void;
530
+
477
531
  declare const COMPRESSION_THRESHOLD = 750;
478
532
 
479
533
  declare function createStatefulHost(host: Host, status?: StatefulHost['status']): StatefulHost;
480
534
 
481
- declare function createTransporter({ hosts, hostsCache, baseHeaders, logger, baseQueryParameters, algoliaAgent, timeouts, requester, requestsCache, responsesCache, compress, compression, }: TransporterOptions): Transporter;
535
+ declare function createTransporter({ hosts, hostsCache, baseHeaders, logger, baseQueryParameters, algoliaAgent, timeouts, requester, requestsCache, responsesCache, compress, compression, requestIdChannel, }: TransporterOptions): TransporterWithHttpInfo;
482
536
 
483
537
  declare class AlgoliaError extends Error {
484
538
  name: string;
@@ -495,18 +549,20 @@ declare class IndexAlreadyExistsError extends AlgoliaError {
495
549
  }
496
550
  declare class ErrorWithStackTrace extends AlgoliaError {
497
551
  stackTrace: StackFrame[];
498
- constructor(message: string, stackTrace: StackFrame[], name: string);
552
+ correlationId?: string | undefined;
553
+ constructor(message: string, stackTrace: StackFrame[], name: string, correlationId?: string | undefined);
499
554
  }
500
555
  declare class RetryError extends ErrorWithStackTrace {
501
- constructor(stackTrace: StackFrame[]);
556
+ constructor(stackTrace: StackFrame[], correlationId?: string | undefined);
502
557
  }
503
558
  declare class ApiError extends ErrorWithStackTrace {
504
559
  status: number;
505
- constructor(message: string, status: number, stackTrace: StackFrame[], name?: string);
560
+ constructor(message: string, status: number, stackTrace: StackFrame[], name?: string, correlationId?: string | undefined);
506
561
  }
507
562
  declare class DeserializationError extends AlgoliaError {
508
563
  response: Response;
509
- constructor(message: string, response: Response);
564
+ correlationId?: string | undefined;
565
+ constructor(message: string, response: Response, correlationId?: string | undefined);
510
566
  }
511
567
  type DetailedErrorWithMessage = {
512
568
  message: string;
@@ -523,7 +579,7 @@ type DetailedError = {
523
579
  };
524
580
  declare class DetailedApiError extends ApiError {
525
581
  error: DetailedError;
526
- constructor(message: string, status: number, error: DetailedError, stackTrace: StackFrame[]);
582
+ constructor(message: string, status: number, error: DetailedError, stackTrace: StackFrame[], correlationId?: string | undefined);
527
583
  }
528
584
 
529
585
  declare function shuffle<TData>(array: TData[]): TData[];
@@ -532,7 +588,19 @@ declare function serializeQueryParameters(parameters: QueryParameters): string;
532
588
  declare function serializeData(request: Request, requestOptions: RequestOptions): string | undefined;
533
589
  declare function serializeHeaders(baseHeaders: Headers, requestHeaders: Headers, requestOptionsHeaders?: Headers | undefined): Headers;
534
590
  declare function deserializeSuccess<TObject>(response: Response): TObject;
535
- declare function deserializeFailure({ content, status }: Response, stackFrame: StackFrame[]): Error;
591
+ declare function deserializeSuccessWithHttpInfo<TData>(response: Response): AlgoliaHttpResponse<TData>;
592
+ declare function getCorrelationId(headers: Headers | undefined): string | undefined;
593
+ declare function getLastCorrelationId(stackTrace: StackFrame[]): string | undefined;
594
+ declare function deserializeFailure(response: Response, stackFrame: StackFrame[]): Error;
595
+
596
+ declare function generateRequestId(): string;
597
+ /**
598
+ * Returns request options carrying a Request-ID on the transporter's channel, so that every
599
+ * request a multi-request helper performs shares the same ID. Returns the options unchanged
600
+ * when the channel is off or when a Request-ID is already supplied. Never apply ahead of a
601
+ * cacheable operation: the ID enters the cache key and defeats caching and deduplication.
602
+ */
603
+ declare function withRequestId(transporter: Pick<Transporter, 'requestIdChannel' | 'baseHeaders' | 'baseQueryParameters'>, requestOptions?: RequestOptions | undefined): RequestOptions | undefined;
536
604
 
537
605
  declare function isNetworkError({ isTimedOut, status }: Omit<Response, 'content'>): boolean;
538
606
  declare function isRetryable({ isTimedOut, status }: Omit<Response, 'content'>): boolean;
@@ -543,4 +611,4 @@ declare function stackFrameWithoutCredentials(stackFrame: StackFrame): StackFram
543
611
 
544
612
  declare function validateRequired(field: string, method: string, value: unknown): void;
545
613
 
546
- export { type AlgoliaAgent, type AlgoliaAgentOptions, AlgoliaError, ApiError, type AuthMode, type BrowserLocalStorageCacheItem, type BrowserLocalStorageOptions, COMPRESSION_THRESHOLD, type Cache, type CacheEvents, type ChunkedHelperOptions, type ClientOptions, type CreateClientOptions, type CreateIterablePromise, DEFAULT_CONNECT_TIMEOUT_BROWSER, DEFAULT_CONNECT_TIMEOUT_NODE, DEFAULT_READ_TIMEOUT_BROWSER, DEFAULT_READ_TIMEOUT_NODE, DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES, DEFAULT_WRITE_TIMEOUT_BROWSER, DEFAULT_WRITE_TIMEOUT_NODE, DeserializationError, DetailedApiError, type DetailedError, type DetailedErrorWithMessage, type DetailedErrorWithTypeID, type EndRequest, ErrorWithStackTrace, type FallbackableCacheOptions, type GetAlgoliaAgent, type Headers, type Host, IndexAlreadyExistsError, IndexNotFoundError, IndicesInSameAppError, type IterableOptions, LogLevelEnum, type LogLevelType, type Logger, type MemoryCacheOptions, type Method, type QueryParameters, type Request, type RequestOptions, type Requester, type Response, RetryError, type ServerSentEvent, type StackFrame, type StatefulHost, type StreamEvent, type Timeouts, type Transporter, type TransporterOptions, createAlgoliaAgent, createAuth, createBrowserLocalStorageCache, createFallbackableCache, createIterablePromise, createMemoryCache, createNullCache, createNullLogger, createStatefulHost, createTransporter, deserializeFailure, deserializeSuccess, getAlgoliaAgent, isNetworkError, isRetryable, isSuccess, iterSSEEvents, serializeData, serializeHeaders, serializeQueryParameters, serializeUrl, shuffle, stackFrameWithoutCredentials, stackTraceWithoutCredentials, validateRequired };
614
+ export { type AlgoliaAgent, type AlgoliaAgentOptions, AlgoliaError, type AlgoliaHttpResponse, ApiError, type AuthMode, type BrowserLocalStorageCacheItem, type BrowserLocalStorageOptions, COMPRESSION_THRESHOLD, type Cache, type CacheEvents, type ChunkedHelperOptions, type ClientOptions, type CreateClientOptions, type CreateIterablePromise, DEFAULT_CONNECT_TIMEOUT_BROWSER, DEFAULT_CONNECT_TIMEOUT_NODE, DEFAULT_READ_TIMEOUT_BROWSER, DEFAULT_READ_TIMEOUT_NODE, DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES, DEFAULT_WRITE_TIMEOUT_BROWSER, DEFAULT_WRITE_TIMEOUT_NODE, DeserializationError, DetailedApiError, type DetailedError, type DetailedErrorWithMessage, type DetailedErrorWithTypeID, type EndRequest, ErrorWithStackTrace, type FallbackableCacheOptions, type GetAlgoliaAgent, type Headers, type Host, IndexAlreadyExistsError, IndexNotFoundError, IndicesInSameAppError, type IterableOptions, LogLevelEnum, type LogLevelType, type Logger, type MemoryCacheOptions, type Method, type QueryParameters, type Request, type RequestOptions, type Requester, type Response, RetryError, type ServerSentEvent, type StackFrame, type StatefulHost, type StreamEvent, type Timeouts, type Transporter, type TransporterOptions, type TransporterWithHttpInfo, createAlgoliaAgent, createAuth, createBrowserLocalStorageCache, createFallbackableCache, createIterablePromise, createMemoryCache, createNullCache, createNullLogger, createStatefulHost, createTransporter, deserializeFailure, deserializeSuccess, deserializeSuccessWithHttpInfo, generateRequestId, getAlgoliaAgent, getCorrelationId, getLastCorrelationId, isNetworkError, isRetryable, isSuccess, iterSSEEvents, logWarning, serializeData, serializeHeaders, serializeQueryParameters, serializeUrl, shuffle, stackFrameWithoutCredentials, stackTraceWithoutCredentials, validateRequired, withRequestId };
package/dist/common.d.ts CHANGED
@@ -1,3 +1,96 @@
1
+ type Headers = Record<string, string>;
2
+ type QueryParameters = Record<string, any>;
3
+ /**
4
+ * The method of the request.
5
+ */
6
+ type Method = 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT';
7
+ type Request = {
8
+ method: Method;
9
+ /**
10
+ * The path of the REST API to send the request to.
11
+ */
12
+ path: string;
13
+ queryParameters: QueryParameters;
14
+ data?: Array<Record<string, any>> | Record<string, any> | undefined;
15
+ headers: Headers;
16
+ /**
17
+ * If the given request should persist on the cache. Keep in mind,
18
+ * that some methods may have this option enabled by default.
19
+ */
20
+ cacheable?: boolean | undefined;
21
+ /**
22
+ * Some POST methods in the Algolia REST API uses the `read` transporter.
23
+ * This information is defined at the spec level.
24
+ */
25
+ useReadTransporter?: boolean | undefined;
26
+ };
27
+ type EndRequest = Pick<Request, 'headers' | 'method'> & {
28
+ /**
29
+ * The full URL of the REST API.
30
+ */
31
+ url: string;
32
+ /**
33
+ * The connection timeout, in milliseconds.
34
+ */
35
+ connectTimeout: number;
36
+ /**
37
+ * The response timeout, in milliseconds.
38
+ */
39
+ responseTimeout: number;
40
+ data?: string | Uint8Array | undefined;
41
+ };
42
+ type Response = {
43
+ /**
44
+ * The body of the response.
45
+ */
46
+ content: string;
47
+ /**
48
+ * The headers of the response, with lower-cased names. Optional so that custom requesters that
49
+ * don't capture headers remain valid, in which case the `WithHTTPInfo` methods expose no headers.
50
+ */
51
+ headers?: Headers | undefined;
52
+ /**
53
+ * Whether the API call is timed out or not.
54
+ */
55
+ isTimedOut: boolean;
56
+ /**
57
+ * The HTTP status code of the response.
58
+ */
59
+ status: number;
60
+ };
61
+ type Requester = {
62
+ /**
63
+ * Sends the given `request` to the server.
64
+ */
65
+ send: (request: EndRequest) => Promise<Response>;
66
+ /**
67
+ * Sends the given `request` and returns a raw byte stream for streaming responses (e.g. SSE).
68
+ */
69
+ sendStream?: (request: EndRequest) => Promise<ReadableStream<Uint8Array>>;
70
+ };
71
+
72
+ /**
73
+ * The full HTTP response of an API call, as returned by the `WithHTTPInfo` variant of each method.
74
+ */
75
+ type AlgoliaHttpResponse<TData> = {
76
+ /**
77
+ * The HTTP status code of the response.
78
+ */
79
+ status: number;
80
+ /**
81
+ * The headers of the response, with lower-cased names. Undefined when the requester does not capture headers.
82
+ */
83
+ headers?: Headers | undefined;
84
+ /**
85
+ * The raw body of the response.
86
+ */
87
+ content: string;
88
+ /**
89
+ * The deserialized body of the response.
90
+ */
91
+ data: TData;
92
+ };
93
+
1
94
  type Cache = {
2
95
  /**
3
96
  * Gets the value of the given `key`.
@@ -169,75 +262,13 @@ type Logger = {
169
262
  */
170
263
  info: (message: string, args?: any | undefined) => Promise<void>;
171
264
  /**
172
- * Logs error messages.
173
- */
174
- error: (message: string, args?: any | undefined) => Promise<void>;
175
- };
176
-
177
- type Headers = Record<string, string>;
178
- type QueryParameters = Record<string, any>;
179
- /**
180
- * The method of the request.
181
- */
182
- type Method = 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT';
183
- type Request = {
184
- method: Method;
185
- /**
186
- * The path of the REST API to send the request to.
187
- */
188
- path: string;
189
- queryParameters: QueryParameters;
190
- data?: Array<Record<string, any>> | Record<string, any> | undefined;
191
- headers: Headers;
192
- /**
193
- * If the given request should persist on the cache. Keep in mind,
194
- * that some methods may have this option enabled by default.
265
+ * Logs warning messages. When not implemented, warnings fall back to `console.warn` so they stay visible with the default no-op logger.
195
266
  */
196
- cacheable?: boolean | undefined;
267
+ warn?: (message: string, args?: any | undefined) => Promise<void>;
197
268
  /**
198
- * Some POST methods in the Algolia REST API uses the `read` transporter.
199
- * This information is defined at the spec level.
200
- */
201
- useReadTransporter?: boolean | undefined;
202
- };
203
- type EndRequest = Pick<Request, 'headers' | 'method'> & {
204
- /**
205
- * The full URL of the REST API.
206
- */
207
- url: string;
208
- /**
209
- * The connection timeout, in milliseconds.
210
- */
211
- connectTimeout: number;
212
- /**
213
- * The response timeout, in milliseconds.
214
- */
215
- responseTimeout: number;
216
- data?: string | Uint8Array | undefined;
217
- };
218
- type Response = {
219
- /**
220
- * The body of the response.
221
- */
222
- content: string;
223
- /**
224
- * Whether the API call is timed out or not.
225
- */
226
- isTimedOut: boolean;
227
- /**
228
- * The HTTP status code of the response.
229
- */
230
- status: number;
231
- };
232
- type Requester = {
233
- /**
234
- * Sends the given `request` to the server.
235
- */
236
- send: (request: EndRequest) => Promise<Response>;
237
- /**
238
- * Sends the given `request` and returns a raw byte stream for streaming responses (e.g. SSE).
269
+ * Logs error messages.
239
270
  */
240
- sendStream?: (request: EndRequest) => Promise<ReadableStream<Uint8Array>>;
271
+ error: (message: string, args?: any | undefined) => Promise<void>;
241
272
  };
242
273
 
243
274
  type RequestOptions = Pick<Request, 'cacheable'> & {
@@ -374,6 +405,12 @@ type TransporterOptions = {
374
405
  */
375
406
  compress?: (data: string) => Promise<Uint8Array>;
376
407
  compression?: 'gzip';
408
+ /**
409
+ * Where the generated Request-ID is sent: as the `Request-ID` header, or as the
410
+ * `x-algolia-request-id` query parameter. When undefined, no Request-ID is sent.
411
+ * A caller-supplied Request-ID is never overwritten.
412
+ */
413
+ requestIdChannel?: 'headers' | 'queryParameters' | undefined;
377
414
  };
378
415
  type Transporter = TransporterOptions & {
379
416
  /**
@@ -383,6 +420,18 @@ type Transporter = TransporterOptions & {
383
420
  request: <TResponse>(baseRequest: Request, baseRequestOptions?: RequestOptions) => Promise<TResponse>;
384
421
  requestStream: (baseRequest: Request, baseRequestOptions?: RequestOptions) => AsyncGenerator<ServerSentEvent>;
385
422
  };
423
+ /**
424
+ * The transporter returned by `createTransporter`. Kept separate from `Transporter` so that
425
+ * existing implementations of `Transporter` remain type-valid.
426
+ */
427
+ type TransporterWithHttpInfo = Transporter & {
428
+ /**
429
+ * Performs a request and returns the full HTTP response information — status code,
430
+ * headers (when the requester captures them), raw body and deserialized data.
431
+ * Both the requests and the responses caches are bypassed: it always hits the network.
432
+ */
433
+ requestWithHttpInfo: <TData>(baseRequest: Request, baseRequestOptions?: RequestOptions) => Promise<AlgoliaHttpResponse<TData>>;
434
+ };
386
435
 
387
436
  type AuthMode = 'WithinHeaders' | 'WithinQueryParameters';
388
437
  type OverriddenTransporterOptions = 'baseHeaders' | 'baseQueryParameters' | 'hosts';
@@ -474,11 +523,16 @@ declare function getAlgoliaAgent({ algoliaAgents, client, version }: GetAlgoliaA
474
523
 
475
524
  declare function createNullLogger(): Logger;
476
525
 
526
+ /**
527
+ * Prefers the logger's optional `warn` method and falls back to `console.warn`, so warnings stay visible with the default no-op logger.
528
+ */
529
+ declare function logWarning(logger: Logger, message: string): void;
530
+
477
531
  declare const COMPRESSION_THRESHOLD = 750;
478
532
 
479
533
  declare function createStatefulHost(host: Host, status?: StatefulHost['status']): StatefulHost;
480
534
 
481
- declare function createTransporter({ hosts, hostsCache, baseHeaders, logger, baseQueryParameters, algoliaAgent, timeouts, requester, requestsCache, responsesCache, compress, compression, }: TransporterOptions): Transporter;
535
+ declare function createTransporter({ hosts, hostsCache, baseHeaders, logger, baseQueryParameters, algoliaAgent, timeouts, requester, requestsCache, responsesCache, compress, compression, requestIdChannel, }: TransporterOptions): TransporterWithHttpInfo;
482
536
 
483
537
  declare class AlgoliaError extends Error {
484
538
  name: string;
@@ -495,18 +549,20 @@ declare class IndexAlreadyExistsError extends AlgoliaError {
495
549
  }
496
550
  declare class ErrorWithStackTrace extends AlgoliaError {
497
551
  stackTrace: StackFrame[];
498
- constructor(message: string, stackTrace: StackFrame[], name: string);
552
+ correlationId?: string | undefined;
553
+ constructor(message: string, stackTrace: StackFrame[], name: string, correlationId?: string | undefined);
499
554
  }
500
555
  declare class RetryError extends ErrorWithStackTrace {
501
- constructor(stackTrace: StackFrame[]);
556
+ constructor(stackTrace: StackFrame[], correlationId?: string | undefined);
502
557
  }
503
558
  declare class ApiError extends ErrorWithStackTrace {
504
559
  status: number;
505
- constructor(message: string, status: number, stackTrace: StackFrame[], name?: string);
560
+ constructor(message: string, status: number, stackTrace: StackFrame[], name?: string, correlationId?: string | undefined);
506
561
  }
507
562
  declare class DeserializationError extends AlgoliaError {
508
563
  response: Response;
509
- constructor(message: string, response: Response);
564
+ correlationId?: string | undefined;
565
+ constructor(message: string, response: Response, correlationId?: string | undefined);
510
566
  }
511
567
  type DetailedErrorWithMessage = {
512
568
  message: string;
@@ -523,7 +579,7 @@ type DetailedError = {
523
579
  };
524
580
  declare class DetailedApiError extends ApiError {
525
581
  error: DetailedError;
526
- constructor(message: string, status: number, error: DetailedError, stackTrace: StackFrame[]);
582
+ constructor(message: string, status: number, error: DetailedError, stackTrace: StackFrame[], correlationId?: string | undefined);
527
583
  }
528
584
 
529
585
  declare function shuffle<TData>(array: TData[]): TData[];
@@ -532,7 +588,19 @@ declare function serializeQueryParameters(parameters: QueryParameters): string;
532
588
  declare function serializeData(request: Request, requestOptions: RequestOptions): string | undefined;
533
589
  declare function serializeHeaders(baseHeaders: Headers, requestHeaders: Headers, requestOptionsHeaders?: Headers | undefined): Headers;
534
590
  declare function deserializeSuccess<TObject>(response: Response): TObject;
535
- declare function deserializeFailure({ content, status }: Response, stackFrame: StackFrame[]): Error;
591
+ declare function deserializeSuccessWithHttpInfo<TData>(response: Response): AlgoliaHttpResponse<TData>;
592
+ declare function getCorrelationId(headers: Headers | undefined): string | undefined;
593
+ declare function getLastCorrelationId(stackTrace: StackFrame[]): string | undefined;
594
+ declare function deserializeFailure(response: Response, stackFrame: StackFrame[]): Error;
595
+
596
+ declare function generateRequestId(): string;
597
+ /**
598
+ * Returns request options carrying a Request-ID on the transporter's channel, so that every
599
+ * request a multi-request helper performs shares the same ID. Returns the options unchanged
600
+ * when the channel is off or when a Request-ID is already supplied. Never apply ahead of a
601
+ * cacheable operation: the ID enters the cache key and defeats caching and deduplication.
602
+ */
603
+ declare function withRequestId(transporter: Pick<Transporter, 'requestIdChannel' | 'baseHeaders' | 'baseQueryParameters'>, requestOptions?: RequestOptions | undefined): RequestOptions | undefined;
536
604
 
537
605
  declare function isNetworkError({ isTimedOut, status }: Omit<Response, 'content'>): boolean;
538
606
  declare function isRetryable({ isTimedOut, status }: Omit<Response, 'content'>): boolean;
@@ -543,4 +611,4 @@ declare function stackFrameWithoutCredentials(stackFrame: StackFrame): StackFram
543
611
 
544
612
  declare function validateRequired(field: string, method: string, value: unknown): void;
545
613
 
546
- export { type AlgoliaAgent, type AlgoliaAgentOptions, AlgoliaError, ApiError, type AuthMode, type BrowserLocalStorageCacheItem, type BrowserLocalStorageOptions, COMPRESSION_THRESHOLD, type Cache, type CacheEvents, type ChunkedHelperOptions, type ClientOptions, type CreateClientOptions, type CreateIterablePromise, DEFAULT_CONNECT_TIMEOUT_BROWSER, DEFAULT_CONNECT_TIMEOUT_NODE, DEFAULT_READ_TIMEOUT_BROWSER, DEFAULT_READ_TIMEOUT_NODE, DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES, DEFAULT_WRITE_TIMEOUT_BROWSER, DEFAULT_WRITE_TIMEOUT_NODE, DeserializationError, DetailedApiError, type DetailedError, type DetailedErrorWithMessage, type DetailedErrorWithTypeID, type EndRequest, ErrorWithStackTrace, type FallbackableCacheOptions, type GetAlgoliaAgent, type Headers, type Host, IndexAlreadyExistsError, IndexNotFoundError, IndicesInSameAppError, type IterableOptions, LogLevelEnum, type LogLevelType, type Logger, type MemoryCacheOptions, type Method, type QueryParameters, type Request, type RequestOptions, type Requester, type Response, RetryError, type ServerSentEvent, type StackFrame, type StatefulHost, type StreamEvent, type Timeouts, type Transporter, type TransporterOptions, createAlgoliaAgent, createAuth, createBrowserLocalStorageCache, createFallbackableCache, createIterablePromise, createMemoryCache, createNullCache, createNullLogger, createStatefulHost, createTransporter, deserializeFailure, deserializeSuccess, getAlgoliaAgent, isNetworkError, isRetryable, isSuccess, iterSSEEvents, serializeData, serializeHeaders, serializeQueryParameters, serializeUrl, shuffle, stackFrameWithoutCredentials, stackTraceWithoutCredentials, validateRequired };
614
+ export { type AlgoliaAgent, type AlgoliaAgentOptions, AlgoliaError, type AlgoliaHttpResponse, ApiError, type AuthMode, type BrowserLocalStorageCacheItem, type BrowserLocalStorageOptions, COMPRESSION_THRESHOLD, type Cache, type CacheEvents, type ChunkedHelperOptions, type ClientOptions, type CreateClientOptions, type CreateIterablePromise, DEFAULT_CONNECT_TIMEOUT_BROWSER, DEFAULT_CONNECT_TIMEOUT_NODE, DEFAULT_READ_TIMEOUT_BROWSER, DEFAULT_READ_TIMEOUT_NODE, DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES, DEFAULT_WRITE_TIMEOUT_BROWSER, DEFAULT_WRITE_TIMEOUT_NODE, DeserializationError, DetailedApiError, type DetailedError, type DetailedErrorWithMessage, type DetailedErrorWithTypeID, type EndRequest, ErrorWithStackTrace, type FallbackableCacheOptions, type GetAlgoliaAgent, type Headers, type Host, IndexAlreadyExistsError, IndexNotFoundError, IndicesInSameAppError, type IterableOptions, LogLevelEnum, type LogLevelType, type Logger, type MemoryCacheOptions, type Method, type QueryParameters, type Request, type RequestOptions, type Requester, type Response, RetryError, type ServerSentEvent, type StackFrame, type StatefulHost, type StreamEvent, type Timeouts, type Transporter, type TransporterOptions, type TransporterWithHttpInfo, createAlgoliaAgent, createAuth, createBrowserLocalStorageCache, createFallbackableCache, createIterablePromise, createMemoryCache, createNullCache, createNullLogger, createStatefulHost, createTransporter, deserializeFailure, deserializeSuccess, deserializeSuccessWithHttpInfo, generateRequestId, getAlgoliaAgent, getCorrelationId, getLastCorrelationId, isNetworkError, isRetryable, isSuccess, iterSSEEvents, logWarning, serializeData, serializeHeaders, serializeQueryParameters, serializeUrl, shuffle, stackFrameWithoutCredentials, stackTraceWithoutCredentials, validateRequired, withRequestId };