Skip to content

Commit 3cf71b2

Browse files
committed
chore: ie 11 support
1 parent 4645992 commit 3cf71b2

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

packages/algoliasearch/src/__tests__/default.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,15 @@ describe('default preset', () => {
198198
await expect(
199199
index.saveObjectsWithTransformation([{ objectID: 'bar', baz: 42 }], { waitForTasks: true })
200200
).rejects.toThrow(
201-
'`transformation.region` must be provided at client instantiation before calling this method.'
201+
'`options.transformation.region` must be provided at client instantiation before calling this method.'
202202
);
203203

204204
await expect(
205205
index.partialUpdateObjectsWithTransformation([{ objectID: 'bar', baz: 42 }], {
206206
waitForTasks: true,
207207
})
208208
).rejects.toThrow(
209-
'`transformation.region` must be provided at client instantiation before calling this method.'
209+
'`options.transformation.region` must be provided at client instantiation before calling this method.'
210210
);
211211
});
212212

packages/algoliasearch/src/builds/browser.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ import {
207207
createIngestionClient,
208208
partialUpdateObjectsWithTransformation,
209209
saveObjectsWithTransformation,
210+
transformationConfigurationError,
210211
} from '../ingestion';
211212
import {
212213
AlgoliaSearchOptions,
@@ -261,7 +262,9 @@ export default function algoliasearch(
261262

262263
if (options && options.transformation) {
263264
if (!options.transformation.region) {
264-
throw new Error('`region` must be provided when leveraging the transformation pipeline');
265+
throw transformationConfigurationError(
266+
'`region` must be provided when leveraging the transformation pipeline'
267+
);
265268
}
266269

267270
ingestionTransporter = createIngestionClient({ ...options, ...commonOptions });

packages/algoliasearch/src/builds/node.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ import {
209209
createIngestionClient,
210210
partialUpdateObjectsWithTransformation,
211211
saveObjectsWithTransformation,
212+
transformationConfigurationError,
212213
} from '../ingestion';
213214
import {
214215
AlgoliaSearchOptions,
@@ -261,7 +262,9 @@ export default function algoliasearch(
261262

262263
if (options && options.transformation) {
263264
if (!options.transformation.region) {
264-
throw new Error('`region` must be provided when leveraging the transformation pipeline');
265+
throw transformationConfigurationError(
266+
'`region` must be provided when leveraging the transformation pipeline'
267+
);
265268
}
266269

267270
ingestionTransporter = createIngestionClient({ ...options, ...commonOptions });

packages/algoliasearch/src/ingestion.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ export function createIngestionClient(
2121
options: SearchClientOptions & ClientTransporterOptions & TransformationOptions
2222
): IngestionClient {
2323
if (!options || !options.transformation || !options.transformation.region) {
24-
throw new Error('`region` must be provided when leveraging the transformation pipeline');
24+
throw transformationConfigurationError(
25+
'`region` must be provided when leveraging the transformation pipeline'
26+
);
2527
}
2628

2729
if (options.transformation.region !== 'eu' && options.transformation.region !== 'us') {
28-
throw new Error('`region` is required and must be one of the following: eu, us');
30+
throw transformationConfigurationError(
31+
'`region` is required and must be one of the following: eu, us'
32+
);
2933
}
3034

3135
const appId = options.appId;
@@ -71,19 +75,27 @@ export function createIngestionClient(
7175
requestOptions?: RequestOptions
7276
): Promise<WatchResponse> {
7377
if (!indexName) {
74-
throw new Error('Parameter `indexName` is required when calling `push`.');
78+
throw transformationConfigurationError(
79+
'Parameter `indexName` is required when calling `push`.'
80+
);
7581
}
7682

7783
if (!pushTaskPayload) {
78-
throw new Error('Parameter `pushTaskPayload` is required when calling `push`.');
84+
throw transformationConfigurationError(
85+
'Parameter `pushTaskPayload` is required when calling `push`.'
86+
);
7987
}
8088

8189
if (!pushTaskPayload.action) {
82-
throw new Error('Parameter `pushTaskPayload.action` is required when calling `push`.');
90+
throw transformationConfigurationError(
91+
'Parameter `pushTaskPayload.action` is required when calling `push`.'
92+
);
8393
}
8494

8595
if (!pushTaskPayload.records) {
86-
throw new Error('Parameter `pushTaskPayload.records` is required when calling `push`.');
96+
throw transformationConfigurationError(
97+
'Parameter `pushTaskPayload.records` is required when calling `push`.'
98+
);
8799
}
88100

89101
const opts: RequestOptions = requestOptions || { queryParameters: {} };
@@ -112,7 +124,7 @@ export function saveObjectsWithTransformation(indexName: string, client?: Ingest
112124
requestOptions?: RequestOptions & ChunkOptions & SaveObjectsOptions & PushOptions
113125
): Promise<WatchResponse> => {
114126
if (!client) {
115-
throw new Error(
127+
throw transformationConfigurationError(
116128
'`options.transformation.region` must be provided at client instantiation before calling this method.'
117129
);
118130
}
@@ -144,7 +156,7 @@ export function partialUpdateObjectsWithTransformation(
144156
requestOptions?: RequestOptions & ChunkOptions & PartialUpdateObjectsOptions & PushOptions
145157
): Promise<WatchResponse> => {
146158
if (!client) {
147-
throw new Error(
159+
throw transformationConfigurationError(
148160
'`options.transformation.region` must be provided at client instantiation before calling this method.'
149161
);
150162
}
@@ -166,3 +178,10 @@ export function partialUpdateObjectsWithTransformation(
166178
);
167179
};
168180
}
181+
182+
export function transformationConfigurationError(message: string): Error {
183+
return {
184+
name: 'TransformationConfigurationError',
185+
message,
186+
};
187+
}

0 commit comments

Comments
 (0)