Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (
requestOptions?: ClearSynonymsOptions & RequestOptions
): Readonly> => {
const { forwardToReplicas, ...options } = requestOptions || {};
const mappedRequestOptions = createMappedRequestOptions(options);
if (forwardToReplicas) {
mappedRequestOptions.queryParameters.forwardToReplicas = 1; // eslint-disable-line functional/immutable-data
}
return createWaitablePromise(
base.transporter.write(
{
method: MethodEnum.Post,
path: encode('1/indexes/%s/synonyms/clear', base.indexName),
},
mappedRequestOptions
),
(response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
);
};
};
return (
requestOptions?: RequestOptions & ClearRulesOptions
): Readonly> => {
const { forwardToReplicas, ...options } = requestOptions || {};
const mappedRequestOptions = createMappedRequestOptions(options);
if (forwardToReplicas) {
mappedRequestOptions.queryParameters.forwardToReplicas = 1; // eslint-disable-line functional/immutable-data
}
return createWaitablePromise(
base.transporter.write(
{
method: MethodEnum.Post,
path: encode('1/indexes/%s/rules/clear', base.indexName),
},
mappedRequestOptions
),
(response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
);
};
};
transporterRequest() {
return {
method: MethodEnum.Post,
path: 'save',
data: {},
cacheable: false,
};
},
return (
query: string,
requestOptions?: SearchSynonymsOptions & RequestOptions
): Readonly> => {
return base.transporter.read(
{
method: MethodEnum.Post,
path: encode('1/indexes/%s/synonyms/search', base.indexName),
data: {
query,
},
},
requestOptions
);
};
};
const wait: Wait = (response, waitRequestOptions) => {
return createRetryablePromise(retry => {
return getApiKey(base)(response.key, waitRequestOptions).catch((apiError: ApiError) => {
if (apiError.status === 404) {
throw apiError;
}
return retry();
});
});
};
return createWaitablePromise(
base.transporter.write(
{
method: MethodEnum.Post,
path: '1/keys',
data,
},
options
),
wait
);
};
};
return (
filters: DeleteByFiltersOptions,
requestOptions?: RequestOptions
): Readonly> => {
return createWaitablePromise(
base.transporter.write(
{
method: MethodEnum.Post,
path: encode('1/indexes/%s/deleteByQuery', base.indexName),
data: filters,
},
requestOptions
),
(response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
);
};
};
request: (data: object): Readonly>> =>
base.transporter.read(
{
method: MethodEnum.Post,
path: encode('1/indexes/%s/browse', base.indexName),
data,
},
requestOptions
),
});
return (
queries: readonly MultipleQueriesQuery[],
requestOptions?: RequestOptions & MultipleQueriesOptions
): Readonly>> => {
const requests = queries.map(query => {
return {
...query,
params: serializeQueryParameters(query.params || {}),
};
});
return base.transporter.read(
{
method: MethodEnum.Post,
path: '1/indexes/*/queries',
data: {
requests,
},
cacheable: true,
},
requestOptions
);
};
};
objectIDs: readonly string[],
requestOptions?: RequestOptions & GetObjectsOptions
): Readonly>> => {
const { attributesToRetrieve, ...options } = requestOptions || {};
const requests = objectIDs.map(objectID => {
return {
indexName: base.indexName,
objectID,
...(attributesToRetrieve ? { attributesToRetrieve } : {}),
};
});
return base.transporter.read(
{
method: MethodEnum.Post,
path: '1/indexes/*/objects',
data: {
requests,
},
},
options
);
};
};
return (
query: string,
requestOptions?: SearchUserIDsOptions & RequestOptions
): Readonly> => {
return base.transporter.read(
{
method: MethodEnum.Post,
path: '1/clusters/mapping/search',
data: {
query,
},
},
requestOptions
);
};
};