@algolia/client-common 5.0.0-alpha.52 → 5.0.0-alpha.54

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.
@@ -1,3 +1,3 @@
1
- import type { TransporterOptions, Transporter } from '../types';
2
- export declare function createTransporter({ hosts, hostsCache, baseHeaders, baseQueryParameters, algoliaAgent, timeouts, requester, requestsCache, responsesCache, }: TransporterOptions): Transporter;
1
+ import type { TransporterOptions, Transporter } from '../types';
2
+ export declare function createTransporter({ hosts, hostsCache, baseHeaders, baseQueryParameters, algoliaAgent, timeouts, requester, requestsCache, responsesCache, }: TransporterOptions): Transporter;
3
3
  //# sourceMappingURL=createTransporter.d.ts.map
@@ -1,38 +1,38 @@
1
- import type { Response, StackFrame } from '../types';
2
- export declare class AlgoliaError extends Error {
3
- name: string;
4
- constructor(message: string, name: string);
5
- }
6
- export declare class ErrorWithStackTrace extends AlgoliaError {
7
- stackTrace: StackFrame[];
8
- constructor(message: string, stackTrace: StackFrame[], name: string);
9
- }
10
- export declare class RetryError extends ErrorWithStackTrace {
11
- constructor(stackTrace: StackFrame[]);
12
- }
13
- export declare class ApiError extends ErrorWithStackTrace {
14
- status: number;
15
- constructor(message: string, status: number, stackTrace: StackFrame[], name?: string);
16
- }
17
- export declare class DeserializationError extends AlgoliaError {
18
- response: Response;
19
- constructor(message: string, response: Response);
20
- }
21
- export type DetailedErrorWithMessage = {
22
- message: string;
23
- label: string;
24
- };
25
- export type DetailedErrorWithTypeID = {
26
- id: string;
27
- type: string;
28
- name?: string;
29
- };
30
- export type DetailedError = {
31
- code: string;
32
- details?: DetailedErrorWithMessage[] | DetailedErrorWithTypeID[];
33
- };
34
- export declare class DetailedApiError extends ApiError {
35
- error: DetailedError;
36
- constructor(message: string, status: number, error: DetailedError, stackTrace: StackFrame[]);
37
- }
1
+ import type { Response, StackFrame } from '../types';
2
+ export declare class AlgoliaError extends Error {
3
+ name: string;
4
+ constructor(message: string, name: string);
5
+ }
6
+ export declare class ErrorWithStackTrace extends AlgoliaError {
7
+ stackTrace: StackFrame[];
8
+ constructor(message: string, stackTrace: StackFrame[], name: string);
9
+ }
10
+ export declare class RetryError extends ErrorWithStackTrace {
11
+ constructor(stackTrace: StackFrame[]);
12
+ }
13
+ export declare class ApiError extends ErrorWithStackTrace {
14
+ status: number;
15
+ constructor(message: string, status: number, stackTrace: StackFrame[], name?: string);
16
+ }
17
+ export declare class DeserializationError extends AlgoliaError {
18
+ response: Response;
19
+ constructor(message: string, response: Response);
20
+ }
21
+ export type DetailedErrorWithMessage = {
22
+ message: string;
23
+ label: string;
24
+ };
25
+ export type DetailedErrorWithTypeID = {
26
+ id: string;
27
+ type: string;
28
+ name?: string;
29
+ };
30
+ export type DetailedError = {
31
+ code: string;
32
+ details?: DetailedErrorWithMessage[] | DetailedErrorWithTypeID[];
33
+ };
34
+ export declare class DetailedApiError extends ApiError {
35
+ error: DetailedError;
36
+ constructor(message: string, status: number, error: DetailedError, stackTrace: StackFrame[]);
37
+ }
38
38
  //# sourceMappingURL=errors.d.ts.map
@@ -1,9 +1,9 @@
1
- import type { Headers, Host, QueryParameters, Request, RequestOptions, Response, StackFrame } from '../types';
2
- export declare function shuffle<TData>(array: TData[]): TData[];
3
- export declare function serializeUrl(host: Host, path: string, queryParameters: QueryParameters): string;
4
- export declare function serializeQueryParameters(parameters: QueryParameters): string;
5
- export declare function serializeData(request: Request, requestOptions: RequestOptions): string | undefined;
6
- export declare function serializeHeaders(baseHeaders: Headers, requestHeaders: Headers, requestOptionsHeaders?: Headers): Headers;
7
- export declare function deserializeSuccess<TObject>(response: Response): TObject;
8
- export declare function deserializeFailure({ content, status }: Response, stackFrame: StackFrame[]): Error;
1
+ import type { Headers, Host, QueryParameters, Request, RequestOptions, Response, StackFrame } from '../types';
2
+ export declare function shuffle<TData>(array: TData[]): TData[];
3
+ export declare function serializeUrl(host: Host, path: string, queryParameters: QueryParameters): string;
4
+ export declare function serializeQueryParameters(parameters: QueryParameters): string;
5
+ export declare function serializeData(request: Request, requestOptions: RequestOptions): string | undefined;
6
+ export declare function serializeHeaders(baseHeaders: Headers, requestHeaders: Headers, requestOptionsHeaders?: Headers): Headers;
7
+ export declare function deserializeSuccess<TObject>(response: Response): TObject;
8
+ export declare function deserializeFailure({ content, status }: Response, stackFrame: StackFrame[]): Error;
9
9
  //# sourceMappingURL=helpers.d.ts.map
@@ -1,7 +1,7 @@
1
- export * from './createTransporter';
2
- export * from './createStatefulHost';
3
- export * from './errors';
4
- export * from './helpers';
5
- export * from './responses';
6
- export * from './stackTrace';
1
+ export * from './createTransporter';
2
+ export * from './createStatefulHost';
3
+ export * from './errors';
4
+ export * from './helpers';
5
+ export * from './responses';
6
+ export * from './stackTrace';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
- import type { Response } from '../types';
2
- export declare function isNetworkError({ isTimedOut, status, }: Omit<Response, 'content'>): boolean;
3
- export declare function isRetryable({ isTimedOut, status, }: Omit<Response, 'content'>): boolean;
4
- export declare function isSuccess({ status }: Pick<Response, 'status'>): boolean;
1
+ import type { Response } from '../types';
2
+ export declare function isNetworkError({ isTimedOut, status, }: Omit<Response, 'content'>): boolean;
3
+ export declare function isRetryable({ isTimedOut, status, }: Omit<Response, 'content'>): boolean;
4
+ export declare function isSuccess({ status }: Pick<Response, 'status'>): boolean;
5
5
  //# sourceMappingURL=responses.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { StackFrame } from '../types';
2
- export declare function stackTraceWithoutCredentials(stackTrace: StackFrame[]): StackFrame[];
3
- export declare function stackFrameWithoutCredentials(stackFrame: StackFrame): StackFrame;
1
+ import type { StackFrame } from '../types';
2
+ export declare function stackTraceWithoutCredentials(stackTrace: StackFrame[]): StackFrame[];
3
+ export declare function stackFrameWithoutCredentials(stackFrame: StackFrame): StackFrame;
4
4
  //# sourceMappingURL=stackTrace.d.ts.map
@@ -1,47 +1,47 @@
1
- export type Cache = {
2
- /**
3
- * Gets the value of the given `key`.
4
- */
5
- get: <TValue>(key: Record<string, any> | string, defaultValue: () => Promise<TValue>, events?: CacheEvents<TValue>) => Promise<TValue>;
6
- /**
7
- * Sets the given value with the given `key`.
8
- */
9
- set: <TValue>(key: Record<string, any> | string, value: TValue) => Promise<TValue>;
10
- /**
11
- * Deletes the given `key`.
12
- */
13
- delete: (key: Record<string, any> | string) => Promise<void>;
14
- /**
15
- * Clears the cache.
16
- */
17
- clear: () => Promise<void>;
18
- };
19
- export type CacheEvents<TValue> = {
20
- /**
21
- * The callback when the given `key` is missing from the cache.
22
- */
23
- miss: (value: TValue) => Promise<any>;
24
- };
25
- export type MemoryCacheOptions = {
26
- /**
27
- * If keys and values should be serialized using `JSON.stringify`.
28
- */
29
- serializable?: boolean;
30
- };
31
- export type BrowserLocalStorageOptions = {
32
- /**
33
- * The cache key.
34
- */
35
- key: string;
36
- /**
37
- * The native local storage implementation.
38
- */
39
- localStorage?: Storage;
40
- };
41
- export type FallbackableCacheOptions = {
42
- /**
43
- * List of caches order by priority.
44
- */
45
- caches: Cache[];
46
- };
1
+ export type Cache = {
2
+ /**
3
+ * Gets the value of the given `key`.
4
+ */
5
+ get: <TValue>(key: Record<string, any> | string, defaultValue: () => Promise<TValue>, events?: CacheEvents<TValue>) => Promise<TValue>;
6
+ /**
7
+ * Sets the given value with the given `key`.
8
+ */
9
+ set: <TValue>(key: Record<string, any> | string, value: TValue) => Promise<TValue>;
10
+ /**
11
+ * Deletes the given `key`.
12
+ */
13
+ delete: (key: Record<string, any> | string) => Promise<void>;
14
+ /**
15
+ * Clears the cache.
16
+ */
17
+ clear: () => Promise<void>;
18
+ };
19
+ export type CacheEvents<TValue> = {
20
+ /**
21
+ * The callback when the given `key` is missing from the cache.
22
+ */
23
+ miss: (value: TValue) => Promise<any>;
24
+ };
25
+ export type MemoryCacheOptions = {
26
+ /**
27
+ * If keys and values should be serialized using `JSON.stringify`.
28
+ */
29
+ serializable?: boolean;
30
+ };
31
+ export type BrowserLocalStorageOptions = {
32
+ /**
33
+ * The cache key.
34
+ */
35
+ key: string;
36
+ /**
37
+ * The native local storage implementation.
38
+ */
39
+ localStorage?: Storage;
40
+ };
41
+ export type FallbackableCacheOptions = {
42
+ /**
43
+ * List of caches order by priority.
44
+ */
45
+ caches: Cache[];
46
+ };
47
47
  //# sourceMappingURL=cache.d.ts.map
@@ -1,12 +1,12 @@
1
- import type { AlgoliaAgentOptions, TransporterOptions } from './transporter';
2
- export type AuthMode = 'WithinHeaders' | 'WithinQueryParameters';
3
- type OverriddenTransporterOptions = 'baseHeaders' | 'baseQueryParameters' | 'hosts';
4
- export type CreateClientOptions = Omit<TransporterOptions, OverriddenTransporterOptions | 'algoliaAgent'> & Partial<Pick<TransporterOptions, OverriddenTransporterOptions>> & {
5
- appId: string;
6
- apiKey: string;
7
- authMode?: AuthMode;
8
- algoliaAgents: AlgoliaAgentOptions[];
9
- };
10
- export type ClientOptions = Partial<Omit<CreateClientOptions, 'apiKey' | 'appId'>>;
11
- export {};
1
+ import type { AlgoliaAgentOptions, TransporterOptions } from './transporter';
2
+ export type AuthMode = 'WithinHeaders' | 'WithinQueryParameters';
3
+ type OverriddenTransporterOptions = 'baseHeaders' | 'baseQueryParameters' | 'hosts';
4
+ export type CreateClientOptions = Omit<TransporterOptions, OverriddenTransporterOptions | 'algoliaAgent'> & Partial<Pick<TransporterOptions, OverriddenTransporterOptions>> & {
5
+ appId: string;
6
+ apiKey: string;
7
+ authMode?: AuthMode;
8
+ algoliaAgents: AlgoliaAgentOptions[];
9
+ };
10
+ export type ClientOptions = Partial<Omit<CreateClientOptions, 'apiKey' | 'appId'>>;
11
+ export {};
12
12
  //# sourceMappingURL=createClient.d.ts.map
@@ -1,36 +1,36 @@
1
- export type IterableOptions<TResponse> = Partial<{
2
- /**
3
- * The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
4
- */
5
- aggregator: (response: TResponse) => void;
6
- /**
7
- * The `validate` condition to throw an error and its message.
8
- */
9
- error: {
10
- /**
11
- * The function to validate the error condition.
12
- */
13
- validate: (response: TResponse) => boolean;
14
- /**
15
- * The error message to throw.
16
- */
17
- message: (response: TResponse) => string;
18
- };
19
- /**
20
- * The function to decide how long to wait between iterations.
21
- */
22
- timeout: () => number;
23
- }>;
24
- export type CreateIterablePromise<TResponse> = IterableOptions<TResponse> & {
25
- /**
26
- * The function to run, which returns a promise.
27
- *
28
- * The `previousResponse` parameter (`undefined` on the first call) allows you to build your request with incremental logic, to iterate on `page` or `cursor` for example.
29
- */
30
- func: (previousResponse?: TResponse) => Promise<TResponse>;
31
- /**
32
- * The validator function. It receive the resolved return of the API call.
33
- */
34
- validate: (response: TResponse) => boolean;
35
- };
1
+ export type IterableOptions<TResponse> = Partial<{
2
+ /**
3
+ * The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
4
+ */
5
+ aggregator: (response: TResponse) => void;
6
+ /**
7
+ * The `validate` condition to throw an error and its message.
8
+ */
9
+ error: {
10
+ /**
11
+ * The function to validate the error condition.
12
+ */
13
+ validate: (response: TResponse) => boolean;
14
+ /**
15
+ * The error message to throw.
16
+ */
17
+ message: (response: TResponse) => string;
18
+ };
19
+ /**
20
+ * The function to decide how long to wait between iterations.
21
+ */
22
+ timeout: () => number;
23
+ }>;
24
+ export type CreateIterablePromise<TResponse> = IterableOptions<TResponse> & {
25
+ /**
26
+ * The function to run, which returns a promise.
27
+ *
28
+ * The `previousResponse` parameter (`undefined` on the first call) allows you to build your request with incremental logic, to iterate on `page` or `cursor` for example.
29
+ */
30
+ func: (previousResponse?: TResponse) => Promise<TResponse>;
31
+ /**
32
+ * The validator function. It receive the resolved return of the API call.
33
+ */
34
+ validate: (response: TResponse) => boolean;
35
+ };
36
36
  //# sourceMappingURL=createIterablePromise.d.ts.map
@@ -1,33 +1,33 @@
1
- export type Host = {
2
- /**
3
- * The host URL.
4
- */
5
- url: string;
6
- /**
7
- * The accepted transporter.
8
- */
9
- accept: 'read' | 'readWrite' | 'write';
10
- /**
11
- * The protocol of the host URL.
12
- */
13
- protocol: 'http' | 'https';
14
- };
15
- export type StatefulHost = Host & {
16
- /**
17
- * The status of the host.
18
- */
19
- status: 'down' | 'timed out' | 'up';
20
- /**
21
- * The last update of the host status, used to compare with the expiration delay.
22
- */
23
- lastUpdate: number;
24
- /**
25
- * Returns whether the host is up or not.
26
- */
27
- isUp: () => boolean;
28
- /**
29
- * Returns whether the host is timed out or not.
30
- */
31
- isTimedOut: () => boolean;
32
- };
1
+ export type Host = {
2
+ /**
3
+ * The host URL.
4
+ */
5
+ url: string;
6
+ /**
7
+ * The accepted transporter.
8
+ */
9
+ accept: 'read' | 'readWrite' | 'write';
10
+ /**
11
+ * The protocol of the host URL.
12
+ */
13
+ protocol: 'http' | 'https';
14
+ };
15
+ export type StatefulHost = Host & {
16
+ /**
17
+ * The status of the host.
18
+ */
19
+ status: 'down' | 'timed out' | 'up';
20
+ /**
21
+ * The last update of the host status, used to compare with the expiration delay.
22
+ */
23
+ lastUpdate: number;
24
+ /**
25
+ * Returns whether the host is up or not.
26
+ */
27
+ isUp: () => boolean;
28
+ /**
29
+ * Returns whether the host is timed out or not.
30
+ */
31
+ isTimedOut: () => boolean;
32
+ };
33
33
  //# sourceMappingURL=host.d.ts.map
@@ -1,7 +1,7 @@
1
- export * from './cache';
2
- export * from './createClient';
3
- export * from './createIterablePromise';
4
- export * from './host';
5
- export * from './requester';
6
- export * from './transporter';
1
+ export * from './cache';
2
+ export * from './createClient';
3
+ export * from './createIterablePromise';
4
+ export * from './host';
5
+ export * from './requester';
6
+ export * from './transporter';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,66 +1,66 @@
1
- import type { Headers, QueryParameters } from './transporter';
2
- /**
3
- * The method of the request.
4
- */
5
- export type Method = 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT';
6
- export type Request = {
7
- method: Method;
8
- /**
9
- * The path of the REST API to send the request to.
10
- */
11
- path: string;
12
- queryParameters: QueryParameters;
13
- data?: Array<Record<string, any>> | Record<string, any>;
14
- headers: Headers;
15
- /**
16
- * If the given request should persist on the cache. Keep in mind,
17
- * that some methods may have this option enabled by default.
18
- */
19
- cacheable?: boolean;
20
- /**
21
- * Some POST methods in the Algolia REST API uses the `read` transporter.
22
- * This information is defined at the spec level.
23
- */
24
- useReadTransporter?: boolean;
25
- };
26
- export type EndRequest = Pick<Request, 'headers' | 'method'> & {
27
- /**
28
- * The full URL of the REST API.
29
- */
30
- url: string;
31
- /**
32
- * The connection timeout, in milliseconds.
33
- */
34
- connectTimeout: number;
35
- /**
36
- * The response timeout, in milliseconds.
37
- */
38
- responseTimeout: number;
39
- data?: string;
40
- };
41
- export type Response = {
42
- /**
43
- * The body of the response.
44
- */
45
- content: string;
46
- /**
47
- * Whether the API call is timed out or not.
48
- */
49
- isTimedOut: boolean;
50
- /**
51
- * The HTTP status code of the response.
52
- */
53
- status: number;
54
- };
55
- export type Requester = {
56
- /**
57
- * Sends the given `request` to the server.
58
- */
59
- send: (request: EndRequest) => Promise<Response>;
60
- };
61
- export type EchoResponse = Omit<EndRequest, 'data'> & Pick<Request, 'data' | 'path'> & {
62
- host: string;
63
- algoliaAgent: string;
64
- searchParams?: Record<string, string>;
65
- };
1
+ import type { Headers, QueryParameters } from './transporter';
2
+ /**
3
+ * The method of the request.
4
+ */
5
+ export type Method = 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT';
6
+ export type Request = {
7
+ method: Method;
8
+ /**
9
+ * The path of the REST API to send the request to.
10
+ */
11
+ path: string;
12
+ queryParameters: QueryParameters;
13
+ data?: Array<Record<string, any>> | Record<string, any>;
14
+ headers: Headers;
15
+ /**
16
+ * If the given request should persist on the cache. Keep in mind,
17
+ * that some methods may have this option enabled by default.
18
+ */
19
+ cacheable?: boolean;
20
+ /**
21
+ * Some POST methods in the Algolia REST API uses the `read` transporter.
22
+ * This information is defined at the spec level.
23
+ */
24
+ useReadTransporter?: boolean;
25
+ };
26
+ export type EndRequest = Pick<Request, 'headers' | 'method'> & {
27
+ /**
28
+ * The full URL of the REST API.
29
+ */
30
+ url: string;
31
+ /**
32
+ * The connection timeout, in milliseconds.
33
+ */
34
+ connectTimeout: number;
35
+ /**
36
+ * The response timeout, in milliseconds.
37
+ */
38
+ responseTimeout: number;
39
+ data?: string;
40
+ };
41
+ export type Response = {
42
+ /**
43
+ * The body of the response.
44
+ */
45
+ content: string;
46
+ /**
47
+ * Whether the API call is timed out or not.
48
+ */
49
+ isTimedOut: boolean;
50
+ /**
51
+ * The HTTP status code of the response.
52
+ */
53
+ status: number;
54
+ };
55
+ export type Requester = {
56
+ /**
57
+ * Sends the given `request` to the server.
58
+ */
59
+ send: (request: EndRequest) => Promise<Response>;
60
+ };
61
+ export type EchoResponse = Omit<EndRequest, 'data'> & Pick<Request, 'data' | 'path'> & {
62
+ host: string;
63
+ algoliaAgent: string;
64
+ searchParams?: Record<string, string>;
65
+ };
66
66
  //# sourceMappingURL=requester.d.ts.map