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)
);
};
};
requestOptions?: ListUserIDsOptions & RequestOptions
): Readonly> => {
const { page, hitsPerPage, ...options } = requestOptions || {};
const mappedRequestOptions = createMappedRequestOptions(options);
if (page) {
mappedRequestOptions.queryParameters.page = page; // eslint-disable-line functional/immutable-data
}
if (hitsPerPage) {
mappedRequestOptions.queryParameters.hitsPerPage = hitsPerPage; // eslint-disable-line functional/immutable-data
}
return base.transporter.read(
{
method: MethodEnum.Get,
path: '1/clusters/mapping',
},
mappedRequestOptions
);
};
};
if (length) {
mappedRequestOptions.queryParameters.length = length; // eslint-disable-line functional/immutable-data
}
if (offset) {
mappedRequestOptions.queryParameters.offset = offset; // eslint-disable-line functional/immutable-data
}
if (type) {
mappedRequestOptions.queryParameters.type = type; // eslint-disable-line functional/immutable-data
}
return base.transporter.read(
{
method: MethodEnum.Get,
path: '1/logs',
},
mappedRequestOptions
);
};
};
return (
objectID: string,
requestOptions?: RequestOptions & GetObjectOptions
): Readonly> => {
const { attributesToRetrieve, ...options } = requestOptions || {};
const mappedRequestOptions = createMappedRequestOptions(options);
if (attributesToRetrieve) {
mappedRequestOptions.queryParameters.attributesToRetrieve = attributesToRetrieve; // eslint-disable-line functional/immutable-data
}
return base.transporter.read(
{
method: MethodEnum.Get,
path: encode('1/indexes/%s/%s', base.indexName, objectID),
},
mappedRequestOptions
);
};
};
return (requestOptions?: RequestOptions): Readonly> => {
const mappedRequestOptions = createMappedRequestOptions(requestOptions);
// eslint-disable-next-line functional/immutable-data
mappedRequestOptions.queryParameters.getVersion = '2';
return base.transporter.read(
{
method: MethodEnum.Get,
path: encode('1/indexes/%s/settings', base.indexName),
},
mappedRequestOptions
);
};
};
return (
userID: string,
requestOptions?: RequestOptions
): Readonly> => {
const mappedRequestOptions = createMappedRequestOptions(requestOptions);
// eslint-disable-next-line functional/immutable-data
mappedRequestOptions.headers['X-Algolia-User-ID'] = userID;
return base.transporter.write(
{
method: MethodEnum.Delete,
path: '1/clusters/mapping',
},
mappedRequestOptions
);
};
};
return (
objectID: string,
requestOptions?: 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.Delete,
path: encode('1/indexes/%s/rules/%s', base.indexName, objectID),
},
mappedRequestOptions
),
(response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
);
};
};
return (
objectID: string,
requestOptions?: RequestOptions & DeleteSynonymOptions
): 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.Delete,
path: encode('1/indexes/%s/synonyms/%s', base.indexName, objectID),
},
mappedRequestOptions
),
(response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
);
};
};
return (
settings: Settings,
requestOptions?: RequestOptions & SetSettingsOptions
): 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.Put,
path: encode('1/indexes/%s/settings', base.indexName),
data: settings,
},
mappedRequestOptions
),
(response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
);
};
};