@algolia/client-common 5.0.0-alpha.7 → 5.0.0-alpha.70
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/client-common.cjs.js +140 -197
- package/dist/client-common.esm.node.js +140 -198
- package/dist/index.d.ts +9 -9
- package/dist/src/cache/createBrowserLocalStorageCache.d.ts +2 -2
- package/dist/src/cache/createBrowserLocalStorageCache.d.ts.map +1 -1
- package/dist/src/cache/createFallbackableCache.d.ts +2 -2
- package/dist/src/cache/createFallbackableCache.d.ts.map +1 -1
- package/dist/src/cache/createMemoryCache.d.ts +2 -2
- package/dist/src/cache/createMemoryCache.d.ts.map +1 -1
- package/dist/src/cache/createNullCache.d.ts +2 -2
- package/dist/src/cache/createNullCache.d.ts.map +1 -1
- package/dist/src/cache/index.d.ts +4 -4
- package/dist/src/cache/index.d.ts.map +1 -1
- package/dist/src/constants.d.ts +6 -6
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/createAlgoliaAgent.d.ts +2 -2
- package/dist/src/createAlgoliaAgent.d.ts.map +1 -1
- package/dist/src/createAuth.d.ts +5 -5
- package/dist/src/createAuth.d.ts.map +1 -1
- package/dist/src/createEchoRequester.d.ts +6 -6
- package/dist/src/createEchoRequester.d.ts.map +1 -1
- package/dist/src/createIterablePromise.d.ts +12 -12
- package/dist/src/createIterablePromise.d.ts.map +1 -1
- package/dist/src/getAlgoliaAgent.d.ts +7 -7
- package/dist/src/getAlgoliaAgent.d.ts.map +1 -1
- package/dist/src/transporter/createStatefulHost.d.ts +2 -2
- package/dist/src/transporter/createStatefulHost.d.ts.map +1 -1
- package/dist/src/transporter/createTransporter.d.ts +2 -2
- package/dist/src/transporter/createTransporter.d.ts.map +1 -1
- package/dist/src/transporter/errors.d.ts +37 -20
- package/dist/src/transporter/errors.d.ts.map +1 -1
- package/dist/src/transporter/helpers.d.ts +8 -8
- package/dist/src/transporter/helpers.d.ts.map +1 -1
- package/dist/src/transporter/index.d.ts +6 -6
- package/dist/src/transporter/index.d.ts.map +1 -1
- package/dist/src/transporter/responses.d.ts +4 -4
- package/dist/src/transporter/responses.d.ts.map +1 -1
- package/dist/src/transporter/stackTrace.d.ts +3 -3
- package/dist/src/transporter/stackTrace.d.ts.map +1 -1
- package/dist/src/types/cache.d.ts +46 -46
- package/dist/src/types/cache.d.ts.map +1 -1
- package/dist/src/types/createClient.d.ts +11 -11
- package/dist/src/types/createClient.d.ts.map +1 -1
- package/dist/src/types/createIterablePromise.d.ts +35 -35
- package/dist/src/types/createIterablePromise.d.ts.map +1 -1
- package/dist/src/types/host.d.ts +32 -32
- package/dist/src/types/host.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +6 -6
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/requester.d.ts +65 -65
- package/dist/src/types/requester.d.ts.map +1 -1
- package/dist/src/types/transporter.d.ts +127 -127
- package/dist/src/types/transporter.d.ts.map +1 -1
- package/package.json +9 -8
- package/src/createEchoRequester.ts +2 -2
- package/src/transporter/createTransporter.ts +4 -1
- package/src/transporter/errors.ts +38 -2
- package/src/transporter/helpers.ts +14 -6
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
StackFrame,
|
|
9
9
|
} from '../types';
|
|
10
10
|
|
|
11
|
-
import { ApiError, DeserializationError } from './errors';
|
|
11
|
+
import { ApiError, DeserializationError, DetailedApiError } from './errors';
|
|
12
12
|
|
|
13
13
|
export function shuffle<TData>(array: TData[]): TData[] {
|
|
14
14
|
const shuffledArray = array;
|
|
@@ -49,11 +49,11 @@ export function serializeQueryParameters(parameters: QueryParameters): string {
|
|
|
49
49
|
return Object.keys(parameters)
|
|
50
50
|
.map(
|
|
51
51
|
(key) =>
|
|
52
|
-
`${key}=${
|
|
52
|
+
`${key}=${encodeURIComponent(
|
|
53
53
|
isObjectOrArray(parameters[key])
|
|
54
54
|
? JSON.stringify(parameters[key])
|
|
55
55
|
: parameters[key]
|
|
56
|
-
}`
|
|
56
|
+
)}`
|
|
57
57
|
)
|
|
58
58
|
.join('&');
|
|
59
59
|
}
|
|
@@ -109,11 +109,19 @@ export function deserializeFailure(
|
|
|
109
109
|
{ content, status }: Response,
|
|
110
110
|
stackFrame: StackFrame[]
|
|
111
111
|
): Error {
|
|
112
|
-
let message = content;
|
|
113
112
|
try {
|
|
114
|
-
|
|
113
|
+
const parsed = JSON.parse(content);
|
|
114
|
+
if ('error' in parsed) {
|
|
115
|
+
return new DetailedApiError(
|
|
116
|
+
parsed.message,
|
|
117
|
+
status,
|
|
118
|
+
parsed.error,
|
|
119
|
+
stackFrame
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
return new ApiError(parsed.message, status, stackFrame);
|
|
115
123
|
} catch (e) {
|
|
116
124
|
// ..
|
|
117
125
|
}
|
|
118
|
-
return new ApiError(
|
|
126
|
+
return new ApiError(content, status, stackFrame);
|
|
119
127
|
}
|