Build and type fixes

This commit is contained in:
Darren Clarke 2023-05-24 20:27:57 +00:00
parent d5bd58ac3e
commit 656f3fbe71
64 changed files with 1878 additions and 1501 deletions

View file

@ -103,7 +103,7 @@ export const getUserMetadata = async (username: string) => {
}
return res?.body._source;
}
};
export const saveUserMetadata = async (username: string, metadata: any) => {
const client = createClient();
@ -112,7 +112,7 @@ export const saveUserMetadata = async (username: string, metadata: any) => {
index: userMetadataIndexName,
body: { doc: { username, ...metadata } }
});
}
};
/* User */
@ -130,13 +130,13 @@ const getCurrentUserIndex = async (email: string) => {
const indicesResponse = await client.indices.get({
index: `.kibana_*_${userIndexName}_1`,
})
});
const currentUserIndex = Object.keys(indicesResponse.body)[0];
return currentUserIndex;
}
};
const getIndexPattern = async (index: string) => {
const getIndexPattern: any = async (index: string) => {
const client = createClient();
const query = {
query: {
@ -335,6 +335,7 @@ export const performQuery = async (searchQuery: any, limit: number) => {
if (searchQuery.relativeDate.values.length > 0) {
searchQuery.relativeDate.values.forEach((value: string) => {
// @ts-expect-error
body.query.bool.must.push({
range: {
date: {
@ -347,6 +348,7 @@ export const performQuery = async (searchQuery: any, limit: number) => {
if (searchQuery.startDate.values.length > 0) {
searchQuery.startDate.values.forEach((value: string) => {
// @ts-expect-error
body.query.bool.must.push({
range: {
date: {
@ -359,6 +361,7 @@ export const performQuery = async (searchQuery: any, limit: number) => {
if (searchQuery.endDate.values.length > 0) {
searchQuery.endDate.values.forEach((value: string) => {
// @ts-expect-error
body.query.bool.must.push({
range: {
date: {
@ -370,54 +373,63 @@ export const performQuery = async (searchQuery: any, limit: number) => {
}
if (searchQuery.incidentType.values.length > 0) {
// @ts-expect-error
body.query.bool.must.push({
terms: { "incident.keyword": searchQuery.incidentType.values },
});
}
if (searchQuery.targetedGroup.values.length > 0) {
// @ts-expect-error
body.query.bool.must.push({
terms: { "targeted_group.keyword": searchQuery.targetedGroup.values },
});
}
if (searchQuery.platform.values.length > 0) {
// @ts-expect-error
body.query.bool.must.push({
terms: { "technology.keyword": searchQuery.platform.values },
});
}
if (searchQuery.device.values.length > 0) {
// @ts-expect-error
body.query.bool.must.push({
terms: { "technology.keyword": searchQuery.device.values },
});
}
if (searchQuery.service.values.length > 0) {
// @ts-expect-error
body.query.bool.must.push({
terms: { "technology.keyword": searchQuery.service.values },
});
}
if (searchQuery.maker.values.length > 0) {
// @ts-expect-error
body.query.bool.must.push({
terms: { "technology.keyword": searchQuery.maker.values },
});
}
if (searchQuery.subregion.values.length > 0) {
// @ts-expect-error
body.query.bool.must.push({
terms: { "region.keyword": searchQuery.subregion.values },
});
}
if (searchQuery.country.values.length > 0) {
// @ts-expect-error
body.query.bool.must.push({
terms: { "country.keyword": searchQuery.country.values },
});
}
if (searchQuery.continent.values.length > 0) {
// @ts-expect-error
body.query.bool.must.push({
terms: { "continent.keyword": searchQuery.continent.values },
});