Update deps and Zammad version (6.4.1)

This commit is contained in:
Darren Clarke 2025-01-15 14:15:02 +01:00
parent 07ee819520
commit 9e5ea2fc41
40 changed files with 973 additions and 849 deletions

View file

@ -10,27 +10,29 @@ const userMetadataIndexName = "user_metadata";
const baseURL = `https://${process.env.OPENSEARCH_USERNAME}:${process.env.OPENSEARCH_PASSWORD}@${process.env.OPENSEARCH_URL}`;
const createClient = () => new Client({
node: baseURL,
auth: {
username: process.env.OPENSEARCH_USERNAME!,
password: process.env.OPENSEARCH_PASSWORD!,
},
ssl: {
rejectUnauthorized: false,
},
});
const createClient = () =>
new Client({
node: baseURL,
auth: {
username: process.env.OPENSEARCH_USERNAME!,
password: process.env.OPENSEARCH_PASSWORD!,
},
ssl: {
rejectUnauthorized: false,
},
});
const createUserClient = (username: string, password: string) => new Client({
node: baseURL,
auth: {
username,
password,
},
ssl: {
rejectUnauthorized: false,
},
});
const createUserClient = (username: string, password: string) =>
new Client({
node: baseURL,
auth: {
username,
password,
},
ssl: {
rejectUnauthorized: false,
},
});
export const checkAuth = async (username: string, password: string) => {
const client = createUserClient(username, password);
@ -115,7 +117,7 @@ export const getUserMetadata = async (username: string) => {
await client.create({
id: username,
index: userMetadataIndexName,
body: { username, savedSearches: [] }
body: { username, savedSearches: [] },
});
res = await client.get({
@ -132,7 +134,7 @@ export const saveUserMetadata = async (username: string, metadata: any) => {
await client.update({
id: username,
index: userMetadataIndexName,
body: { doc: { username, ...metadata } }
body: { doc: { username, ...metadata } },
});
};
@ -181,7 +183,7 @@ const getIndexPattern: any = async (index: string) => {
sort: ["updated_at:desc"],
});
if (res.body.hits.total.value === 0) {
if (res?.body?.hits?.total?.valueOf() === 0) {
// eslint-disable-next-line no-use-before-define
return createCurrentUserIndexPattern(index);
}
@ -226,7 +228,7 @@ interface createUserVisualizationProps {
}
export const createUserVisualization = async (
props: createUserVisualizationProps
props: createUserVisualizationProps,
) => {
const { email, query, visualizationID, title, description } = props;
const userIndex = await getCurrentUserIndex(email);
@ -279,7 +281,7 @@ interface updateVisualizationProps {
}
export const updateUserVisualization = async (
props: updateVisualizationProps
props: updateVisualizationProps,
) => {
const { email, id, query, title, description } = props;
const userIndex = await getCurrentUserIndex(email);
@ -469,10 +471,18 @@ export const performQuery = async (searchQuery: any, limit: number) => {
const results = hits.map((hit: any) => ({
...hit._source,
id: hit._id,
incident: Array.isArray(hit._source.incident) ? hit._source.incident.join(", ") : hit._source.incident,
technology: Array.isArray(hit._source.technology) ? hit._source.technology.join(", ") : hit._source.technology,
targeted_group: Array.isArray(hit._source.targeted_group) ? hit._source.targeted_group.join(", ") : hit._source.targeted_group,
country: Array.isArray(hit._source.country) ? hit._source.country.join(", ") : hit._source.country,
incident: Array.isArray(hit._source.incident)
? hit._source.incident.join(", ")
: hit._source.incident,
technology: Array.isArray(hit._source.technology)
? hit._source.technology.join(", ")
: hit._source.technology,
targeted_group: Array.isArray(hit._source.targeted_group)
? hit._source.targeted_group.join(", ")
: hit._source.targeted_group,
country: Array.isArray(hit._source.country)
? hit._source.country.join(", ")
: hit._source.country,
}));
return results;
@ -570,7 +580,6 @@ export const getTemplates = async (limit: number) => {
},
};
const rawResponse = await client.search({
index: globalIndex,
size: limit,