Merge branch 'develop' into 'main'
Develop See merge request digiresilience/link/link-stack!9
This commit is contained in:
commit
2e17aee178
40 changed files with 700 additions and 568 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-frontend",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
"@mui/icons-material": "^5",
|
||||
"@mui/material": "^5",
|
||||
"@mui/material-nextjs": "^5.16.6",
|
||||
"@mui/x-data-grid-pro": "^7.12.0",
|
||||
"@mui/x-date-pickers-pro": "^7.12.0",
|
||||
"@mui/x-data-grid-pro": "^7.12.1",
|
||||
"@mui/x-date-pickers-pro": "^7.12.1",
|
||||
"@mui/x-license": "^7.12.0",
|
||||
"@link-stack/bridge-common": "*",
|
||||
"@link-stack/bridge-ui": "*",
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
"react-timer-hook": "^3.0.7",
|
||||
"sharp": "^0.33.4",
|
||||
"tss-react": "^4.9.12",
|
||||
"tsx": "^4.16.5",
|
||||
"tsx": "^4.17.0",
|
||||
"@link-stack/ui": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-migrations",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"migrate:up:all": "tsx migrate.ts up:all",
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
"dotenv": "^16.4.5",
|
||||
"kysely": "0.26.1",
|
||||
"pg": "^8.12.0",
|
||||
"tsx": "^4.16.5"
|
||||
"tsx": "^4.17.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-whatsapp",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"main": "build/main/index.js",
|
||||
"author": "Darren Clarke <darren@redaranj.com>",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
"@link-stack/typescript-config": "*",
|
||||
"@types/node": "*",
|
||||
"dotenv-cli": "^7.4.2",
|
||||
"tsx": "^4.16.5",
|
||||
"tsx": "^4.17.0",
|
||||
"typescript": "^5.5.4"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
"outDir": "build/main",
|
||||
"rootDir": "src",
|
||||
"skipLibCheck": true,
|
||||
"types": ["jest", "node", "long"],
|
||||
"types": ["node", "long"],
|
||||
"lib": ["es2020", "DOM"],
|
||||
"composite": true
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-worker",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"type": "module",
|
||||
"main": "build/main/index.js",
|
||||
"author": "Darren Clarke <darren@redaranj.com>",
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
"jest": "^29.7.0",
|
||||
"kysely": "^0.27.3",
|
||||
"pg": "^8.12.0",
|
||||
"remeda": "^2.10.0",
|
||||
"remeda": "^2.11.0",
|
||||
"twilio": "^5.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ const sendToLeafcutter = async (tickets: LabelStudioTicket[]) => {
|
|||
},
|
||||
body: JSON.stringify({ tickets: finalTickets }),
|
||||
});
|
||||
console.log({ result });
|
||||
|
||||
};
|
||||
*/
|
||||
const importLeafcutterTask = async (): Promise<void> => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/leafcutter",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"scripts": {
|
||||
"dev": "next dev -p 3001",
|
||||
"login": "aws sso login --sso-session cdr",
|
||||
|
|
@ -22,8 +22,8 @@
|
|||
"@mui/icons-material": "^5",
|
||||
"@mui/material": "^5",
|
||||
"@mui/material-nextjs": "^5.16.6",
|
||||
"@mui/x-data-grid-pro": "^7.12.0",
|
||||
"@mui/x-date-pickers-pro": "^7.12.0",
|
||||
"@mui/x-data-grid-pro": "^7.12.1",
|
||||
"@mui/x-date-pickers-pro": "^7.12.1",
|
||||
"@opensearch-project/opensearch": "^2.11.0",
|
||||
"cryptr": "^6.3.0",
|
||||
"date-fns": "^3.6.0",
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@types/node": "^22.1.0",
|
||||
"@types/node": "^22.2.0",
|
||||
"@types/react": "18.3.3",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"babel-loader": "^9.1.3",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ export const TicketCreateDialog: FC<TicketCreateDialogProps> = ({
|
|||
);
|
||||
const [liveFormState, setLiveFormState] = useState(formState);
|
||||
const updateFormState = (field: string, value: any) => {
|
||||
console.log({ value });
|
||||
const newState = { ...liveFormState };
|
||||
newState.values[field] = value;
|
||||
setLiveFormState(newState);
|
||||
|
|
@ -59,7 +58,6 @@ export const TicketCreateDialog: FC<TicketCreateDialogProps> = ({
|
|||
useEffect(() => {
|
||||
const fetchUsers = async () => {
|
||||
const result = await getCustomersAction();
|
||||
console.log({ result });
|
||||
setCustomers(result);
|
||||
};
|
||||
|
||||
|
|
@ -69,7 +67,6 @@ export const TicketCreateDialog: FC<TicketCreateDialogProps> = ({
|
|||
useEffect(() => {
|
||||
const fetchGroups = async () => {
|
||||
const result = await getGroupsAction();
|
||||
console.log({ result });
|
||||
setGroups(result);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,14 +3,19 @@
|
|||
import { executeREST } from "app/_lib/zammad";
|
||||
|
||||
export const getGroupsAction = async () => {
|
||||
const groups = await executeREST({
|
||||
path: "/api/v1/groups",
|
||||
});
|
||||
const allGroups = groups ?? [];
|
||||
const formattedGroups = allGroups.map((group: any) => ({
|
||||
label: group.name,
|
||||
value: `gid://zammad/Group/${group.id}`,
|
||||
}));
|
||||
try {
|
||||
const groups = await executeREST({
|
||||
path: "/api/v1/groups",
|
||||
});
|
||||
const allGroups = groups ?? [];
|
||||
const formattedGroups = allGroups.map((group: any) => ({
|
||||
label: group.name,
|
||||
value: `gid://zammad/Group/${group.id}`,
|
||||
}));
|
||||
|
||||
return formattedGroups;
|
||||
return formattedGroups;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,75 +16,82 @@ const overviewLookup = {
|
|||
};
|
||||
|
||||
export const getOverviewTicketCountsAction = async () => {
|
||||
const recent = await executeREST({ path: "/api/v1/recent_view" });
|
||||
const countResult = await executeGraphQL({
|
||||
query: getTicketOverviewCountsQuery,
|
||||
});
|
||||
const overviews = countResult?.ticketOverviews?.edges ?? [];
|
||||
const counts = overviews.reduce((acc: any, overview: any) => {
|
||||
const name = overview.node.name;
|
||||
const key = Object.keys(overviewLookup)
|
||||
.find((k) => overviewLookup[k] === name)
|
||||
?.toLowerCase();
|
||||
if (key) {
|
||||
acc[key] = overview.node.ticketCount ?? 0;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
counts.recent = recent.length;
|
||||
try {
|
||||
const recent = await executeREST({ path: "/api/v1/recent_view" });
|
||||
const countResult = await executeGraphQL({
|
||||
query: getTicketOverviewCountsQuery,
|
||||
});
|
||||
const overviews = countResult?.ticketOverviews?.edges ?? [];
|
||||
const counts = overviews.reduce((acc: any, overview: any) => {
|
||||
const name = overview.node.name;
|
||||
const key = Object.keys(overviewLookup)
|
||||
.find((k) => overviewLookup[k] === name)
|
||||
?.toLowerCase();
|
||||
if (key) {
|
||||
acc[key] = overview.node.ticketCount ?? 0;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
counts.recent = recent.length;
|
||||
|
||||
return counts;
|
||||
return counts;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
export const getOverviewTicketsAction = async (name: string) => {
|
||||
let tickets = [];
|
||||
let error = null;
|
||||
|
||||
if (name === "Recent") {
|
||||
const recent = await executeREST({ path: "/api/v1/recent_view" });
|
||||
try {
|
||||
if (name === "Recent") {
|
||||
const recent = await executeREST({ path: "/api/v1/recent_view" });
|
||||
|
||||
for (const rec of recent) {
|
||||
const tkt = await executeREST({
|
||||
path: `/api/v1/tickets/${rec.o_id}`,
|
||||
for (const rec of recent) {
|
||||
const tkt = await executeREST({
|
||||
path: `/api/v1/tickets/${rec.o_id}`,
|
||||
});
|
||||
tickets.push({
|
||||
...tkt,
|
||||
internalId: tkt.id,
|
||||
createdAt: tkt.created_at,
|
||||
updatedAt: tkt.updated_at,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const fullName = overviewLookup[name];
|
||||
const countResult = await executeGraphQL({
|
||||
query: getTicketOverviewCountsQuery,
|
||||
});
|
||||
tickets.push({
|
||||
...tkt,
|
||||
internalId: tkt.id,
|
||||
createdAt: tkt.created_at,
|
||||
updatedAt: tkt.updated_at,
|
||||
const overviewID = countResult?.ticketOverviews?.edges?.find(
|
||||
(overview: any) => overview.node.name === fullName,
|
||||
)?.node?.id;
|
||||
|
||||
const ticketsResult = await executeGraphQL({
|
||||
query: getTicketsByOverviewQuery,
|
||||
variables: { overviewId: overviewID, pageSize: 250 },
|
||||
});
|
||||
|
||||
const edges = ticketsResult?.ticketsByOverview?.edges;
|
||||
if (edges) {
|
||||
tickets = edges.map((edge: any) => edge.node);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const fullName = overviewLookup[name];
|
||||
const countResult = await executeGraphQL({
|
||||
query: getTicketOverviewCountsQuery,
|
||||
});
|
||||
const overviewID = countResult?.ticketOverviews?.edges?.find(
|
||||
(overview: any) => overview.node.name === fullName,
|
||||
)?.node?.id;
|
||||
|
||||
console.log({ overviewID });
|
||||
|
||||
const ticketsResult = await executeGraphQL({
|
||||
query: getTicketsByOverviewQuery,
|
||||
variables: { overviewId: overviewID, pageSize: 250 },
|
||||
const sortedTickets = tickets.sort((a: any, b: any) => {
|
||||
if (a.internalId < b.internalId) {
|
||||
return 1;
|
||||
}
|
||||
if (a.internalId > b.internalId) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
const edges = ticketsResult?.ticketsByOverview?.edges;
|
||||
if (edges) {
|
||||
tickets = edges.map((edge: any) => edge.node);
|
||||
}
|
||||
return { tickets: sortedTickets };
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return { tickets, message: e.message ?? "" };
|
||||
}
|
||||
|
||||
const sortedTickets = tickets.sort((a: any, b: any) => {
|
||||
if (a.internalId < b.internalId) {
|
||||
return 1;
|
||||
}
|
||||
if (a.internalId > b.internalId) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
return { tickets: sortedTickets, error };
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,10 +3,15 @@ import { executeGraphQL } from "app/_lib/zammad";
|
|||
import { searchQuery } from "@/app/_graphql/searchQuery";
|
||||
|
||||
export const searchAllAction = async (query: string, limit: number) => {
|
||||
const result = await executeGraphQL({
|
||||
query: searchQuery,
|
||||
variables: { search: query, limit },
|
||||
});
|
||||
try {
|
||||
const result = await executeGraphQL({
|
||||
query: searchQuery,
|
||||
variables: { search: query, limit },
|
||||
});
|
||||
|
||||
return result?.search;
|
||||
return result?.search;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export const createTicketAction = async (
|
|||
try {
|
||||
const ticket = {
|
||||
groupId: formData.get("groupId"),
|
||||
customerId: `gid://zammad/User/3`, // { email: formData.get("customerId") },
|
||||
customerId: formData.get("customerId"),
|
||||
title: formData.get("title"),
|
||||
article: {
|
||||
internal: true,
|
||||
|
|
@ -23,23 +23,20 @@ export const createTicketAction = async (
|
|||
},
|
||||
};
|
||||
|
||||
console.log({ ticket });
|
||||
|
||||
const result = await executeGraphQL({
|
||||
await executeGraphQL({
|
||||
query: createTicketMutation,
|
||||
variables: {
|
||||
input: ticket,
|
||||
},
|
||||
});
|
||||
|
||||
console.log({ result });
|
||||
return {
|
||||
...currentState,
|
||||
values: ticket,
|
||||
success: true,
|
||||
};
|
||||
} catch (e: any) {
|
||||
console.log({ e });
|
||||
console.error(e.message);
|
||||
return {
|
||||
success: false,
|
||||
values: {},
|
||||
|
|
@ -61,13 +58,12 @@ export const createTicketArticleAction = async (
|
|||
},
|
||||
});
|
||||
|
||||
console.log({ result });
|
||||
return {
|
||||
result,
|
||||
success: true,
|
||||
};
|
||||
} catch (e: any) {
|
||||
console.log({ e });
|
||||
console.error(e.message);
|
||||
return {
|
||||
success: false,
|
||||
message: e?.message ?? "Unknown error",
|
||||
|
|
@ -114,16 +110,14 @@ export const updateTicketAction = async (
|
|||
tags: ticketInfo.tags,
|
||||
},
|
||||
});
|
||||
console.log({ tagsResult });
|
||||
}
|
||||
|
||||
console.log({ result });
|
||||
return {
|
||||
result,
|
||||
success: true,
|
||||
};
|
||||
} catch (e: any) {
|
||||
console.log({ e });
|
||||
console.error(e.message);
|
||||
return {
|
||||
success: false,
|
||||
message: e?.message ?? "Unknown error",
|
||||
|
|
@ -132,55 +126,80 @@ export const updateTicketAction = async (
|
|||
};
|
||||
|
||||
export const getTicketAction = async (id: string) => {
|
||||
const ticketData = await executeGraphQL({
|
||||
query: getTicketQuery,
|
||||
variables: { ticketId: `gid://zammad/Ticket/${id}` },
|
||||
});
|
||||
console.log({ td: ticketData.ticket });
|
||||
return ticketData?.ticket;
|
||||
try {
|
||||
const ticketData = await executeGraphQL({
|
||||
query: getTicketQuery,
|
||||
variables: { ticketId: `gid://zammad/Ticket/${id}` },
|
||||
});
|
||||
|
||||
return ticketData?.ticket;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
export const getTicketArticlesAction = async (id: string) => {
|
||||
const ticketData = await executeGraphQL({
|
||||
query: getTicketArticlesQuery,
|
||||
variables: { ticketId: `gid://zammad/Ticket/${id}` },
|
||||
});
|
||||
try {
|
||||
const ticketData = await executeGraphQL({
|
||||
query: getTicketArticlesQuery,
|
||||
variables: { ticketId: `gid://zammad/Ticket/${id}` },
|
||||
});
|
||||
|
||||
return ticketData?.ticketArticles;
|
||||
return ticketData?.ticketArticles;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
export const getTicketStatesAction = async () => {
|
||||
const states = await executeREST({
|
||||
path: "/api/v1/ticket_states",
|
||||
});
|
||||
try {
|
||||
const states = await executeREST({
|
||||
path: "/api/v1/ticket_states",
|
||||
});
|
||||
|
||||
const formattedStates =
|
||||
states?.map((state: any) => ({
|
||||
value: `gid://zammad/Ticket::State/${state.id}`,
|
||||
label: state.name,
|
||||
})) ?? [];
|
||||
const formattedStates =
|
||||
states?.map((state: any) => ({
|
||||
value: `gid://zammad/Ticket::State/${state.id}`,
|
||||
label: state.name,
|
||||
})) ?? [];
|
||||
|
||||
return formattedStates;
|
||||
return formattedStates;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
export const getTagsAction = async () => {
|
||||
const { tags } = await executeREST({
|
||||
path: "/api/v1/tags",
|
||||
});
|
||||
try {
|
||||
const { tags } = await executeREST({
|
||||
path: "/api/v1/tags",
|
||||
});
|
||||
|
||||
return tags;
|
||||
return tags;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
export const getTicketPrioritiesAction = async () => {
|
||||
const priorities = await executeREST({
|
||||
path: "/api/v1/ticket_priorities",
|
||||
});
|
||||
try {
|
||||
const priorities = await executeREST({
|
||||
path: "/api/v1/ticket_priorities",
|
||||
});
|
||||
|
||||
const formattedPriorities =
|
||||
priorities?.map((priority: any) => ({
|
||||
value: `gid://zammad/Ticket::Priority/${priority.id}`,
|
||||
label: priority.name,
|
||||
})) ?? [];
|
||||
const formattedPriorities =
|
||||
priorities?.map((priority: any) => ({
|
||||
value: `gid://zammad/Ticket::Priority/${priority.id}`,
|
||||
label: priority.name,
|
||||
})) ?? [];
|
||||
|
||||
return formattedPriorities;
|
||||
return formattedPriorities;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,48 +3,63 @@
|
|||
import { executeREST } from "app/_lib/zammad";
|
||||
|
||||
export const getAgentsAction = async () => {
|
||||
const users = await executeREST({
|
||||
path: "/api/v1/users",
|
||||
});
|
||||
const agents = users?.filter((user: any) => user.role_ids.includes(2)) ?? [];
|
||||
const formattedAgents = agents
|
||||
.map((agent: any) => ({
|
||||
label: `${agent.firstname} ${agent.lastname}`,
|
||||
value: `gid://zammad/User/${agent.id}`,
|
||||
}))
|
||||
.sort((a: any, b: any) => a.label.localeCompare(b.label));
|
||||
try {
|
||||
const users = await executeREST({
|
||||
path: "/api/v1/users",
|
||||
});
|
||||
const agents =
|
||||
users?.filter((user: any) => user.role_ids.includes(2)) ?? [];
|
||||
const formattedAgents = agents
|
||||
.map((agent: any) => ({
|
||||
label: `${agent.firstname} ${agent.lastname}`,
|
||||
value: `gid://zammad/User/${agent.id}`,
|
||||
}))
|
||||
.sort((a: any, b: any) => a.label.localeCompare(b.label));
|
||||
|
||||
return formattedAgents;
|
||||
return formattedAgents;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
export const getCustomersAction = async () => {
|
||||
const users = await executeREST({
|
||||
path: "/api/v1/users",
|
||||
});
|
||||
console.log({ users });
|
||||
const customers =
|
||||
users?.filter((user: any) => user.role_ids.includes(3)) ?? [];
|
||||
const formattedCustomers = customers
|
||||
.map((customer: any) => ({
|
||||
label: customer.login,
|
||||
value: `gid://zammad/User/${customer.id}`,
|
||||
}))
|
||||
.sort((a: any, b: any) => a.label.localeCompare(b.label));
|
||||
try {
|
||||
const users = await executeREST({
|
||||
path: "/api/v1/users",
|
||||
});
|
||||
const customers =
|
||||
users?.filter((user: any) => user.role_ids.includes(3)) ?? [];
|
||||
const formattedCustomers = customers
|
||||
.map((customer: any) => ({
|
||||
label: customer.login,
|
||||
value: `gid://zammad/User/${customer.id}`,
|
||||
}))
|
||||
.sort((a: any, b: any) => a.label.localeCompare(b.label));
|
||||
|
||||
return formattedCustomers;
|
||||
return formattedCustomers;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
export const getUsersAction = async () => {
|
||||
const users = await executeREST({
|
||||
path: "/api/v1/users",
|
||||
});
|
||||
console.log({ users });
|
||||
const formattedUsers = users
|
||||
.map((customer: any) => ({
|
||||
label: customer.login,
|
||||
value: `gid://zammad/User/${customer.id}`,
|
||||
}))
|
||||
.sort((a: any, b: any) => a.label.localeCompare(b.label));
|
||||
try {
|
||||
const users = await executeREST({
|
||||
path: "/api/v1/users",
|
||||
});
|
||||
console.log({ users });
|
||||
const formattedUsers = users
|
||||
.map((customer: any) => ({
|
||||
label: customer.login,
|
||||
value: `gid://zammad/User/${customer.id}`,
|
||||
}))
|
||||
.sort((a: any, b: any) => a.label.localeCompare(b.label));
|
||||
|
||||
return formattedUsers;
|
||||
return formattedUsers;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,22 +1,36 @@
|
|||
"use client";
|
||||
|
||||
import { FC, PropsWithChildren, useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useSession } from "next-auth/react";
|
||||
|
||||
export const CSRFProvider: FC<PropsWithChildren> = ({ children }) => {
|
||||
const { data: session, status, update } = useSession();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(async () => {
|
||||
const checkSession = async () => {
|
||||
console.log("Checking session status...");
|
||||
console.log(status);
|
||||
if (status === "authenticated") {
|
||||
const response = await fetch("/api/v1/users/me");
|
||||
const token = response.headers.get("CSRF-Token");
|
||||
update({ csrfToken: token });
|
||||
const response = await fetch("/api/v1/users/me", {
|
||||
method: "GET",
|
||||
});
|
||||
|
||||
if (response.status !== 200 && !!router) {
|
||||
console.log("redirecting");
|
||||
window.location.href = "/auth/sso";
|
||||
} else {
|
||||
const token = response.headers.get("CSRF-Token");
|
||||
update({ zammadCsrfToken: token });
|
||||
}
|
||||
}
|
||||
}, 30000);
|
||||
};
|
||||
|
||||
const interval = setInterval(checkSession, 15000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, [session, status, update]);
|
||||
}, [session, status, update, router]);
|
||||
|
||||
return children;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ export const authOptions: NextAuthOptions = {
|
|||
}
|
||||
|
||||
if (session && trigger === "update") {
|
||||
token.zammadCsrfToken = session.csrfToken;
|
||||
token.zammadCsrfToken = session.zammadCsrfToken;
|
||||
}
|
||||
return token;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { getServerSession } from "app/_lib/authentication";
|
||||
import { redirect } from "next/navigation";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
const getHeaders = async () => {
|
||||
|
|
@ -9,6 +10,7 @@ const getHeaders = async () => {
|
|||
Accept: "application/json",
|
||||
// @ts-ignore
|
||||
"X-CSRF-Token": session.user.zammadCsrfToken,
|
||||
"X-Browser-Fingerprint": `${session.expires}`,
|
||||
Cookie: allCookies
|
||||
.map((cookie: any) => `${cookie.name}=${cookie.value}`)
|
||||
.join("; "),
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ const rewriteURL = (
|
|||
const destinationURL = request.url.replace(originBaseURL, destinationBaseURL);
|
||||
console.log(`Rewriting ${request.url} to ${destinationURL}`);
|
||||
const requestHeaders = new Headers(request.headers);
|
||||
// console.log({ beforeHeaders: requestHeaders });
|
||||
|
||||
for (const [key, value] of Object.entries(headers)) {
|
||||
requestHeaders.set(key, value as string);
|
||||
}
|
||||
requestHeaders.delete("connection");
|
||||
// console.log({ afterHeaders: requestHeaders });
|
||||
|
||||
return NextResponse.rewrite(new URL(destinationURL), {
|
||||
request: { headers: requestHeaders },
|
||||
});
|
||||
|
|
@ -26,7 +26,15 @@ const checkRewrites = async (request: NextRequestWithAuth) => {
|
|||
const zammadURL = process.env.ZAMMAD_URL ?? "http://zammad-nginx:8080";
|
||||
const opensearchDashboardsURL =
|
||||
process.env.OPENSEARCH_DASHBOARDS_URL ?? "http://macmini:5601";
|
||||
const zammadPaths = ["/zammad", "/api/v1", "/auth/sso", "/assets", "/mobile"];
|
||||
const zammadPaths = [
|
||||
"/zammad",
|
||||
"/api/v1",
|
||||
"/auth/sso",
|
||||
"/assets",
|
||||
"/mobile",
|
||||
"/graphql",
|
||||
"/cable",
|
||||
];
|
||||
const { token } = request.nextauth;
|
||||
const email = token?.email?.toLowerCase() ?? "unknown";
|
||||
let headers = { "x-forwarded-user": email };
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/link",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
|
@ -24,8 +24,8 @@
|
|||
"@mui/icons-material": "^5",
|
||||
"@mui/material": "^5",
|
||||
"@mui/material-nextjs": "^5.16.6",
|
||||
"@mui/x-data-grid-pro": "^7.12.0",
|
||||
"@mui/x-date-pickers-pro": "^7.12.0",
|
||||
"@mui/x-data-grid-pro": "^7.12.1",
|
||||
"@mui/x-date-pickers-pro": "^7.12.1",
|
||||
"date-fns": "^3.6.0",
|
||||
"graphql": "^16.9.0",
|
||||
"graphql-request": "^7.1.0",
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@types/node": "^22.1.0",
|
||||
"@types/node": "^22.2.0",
|
||||
"@types/react": "18.3.3",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"babel-loader": "^9.1.3",
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"target": "esnext",
|
||||
"strict": false,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": true,
|
||||
|
|
|
|||
710
package-lock.json
generated
710
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,15 +1,16 @@
|
|||
{
|
||||
"name": "@link-stack",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"description": "Link from the Center for Digital Resilience",
|
||||
"scripts": {
|
||||
"dev": "dotenv -- turbo dev",
|
||||
"build": "dotenv -- turbo build",
|
||||
"migrate": "dotenv -- npm run migrate --workspace=database",
|
||||
"lint": "dotenv turbo lint",
|
||||
"update-version": "find . -name 'package.json' -exec sed -i -E 's/\"version\": \"[^\"]+\"/\"version\": \"2.1.1\"/' {} +",
|
||||
"upgrade:setup": "npm i -g npm-check-updates",
|
||||
"upgrade:check": "ncu && ncu -ws",
|
||||
"upgrade:all": "ncu -u -x eslint -x kysely && ncu -ws -u -x eslint -x kysely && npm i",
|
||||
"upgrade": "ncu -u -x eslint -x kysely && ncu -ws -u -x eslint -x kysely && npm i",
|
||||
"clean": "rm -f package-lock.json && rm -rf node_modules && rm -rf .turbo && rm -rf apps/*/node_modules && rm -rf apps/*/package-lock.json && rm -rf apps/*/.next && rm -rf packages/*/node_modules && rm -rf apps/*/.next && rm -rf packages/*/.turbo && rm -rf packages/*/build && rm -rf docker/zammad/addons/*",
|
||||
"docker:all:up": "node docker/scripts/docker.js all up",
|
||||
"docker:all:down": "node docker/scripts/docker.js all down",
|
||||
|
|
@ -50,7 +51,8 @@
|
|||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"dotenv-cli": "latest",
|
||||
"eslint": "^8"
|
||||
"eslint": "^8",
|
||||
"typescript": "latest"
|
||||
},
|
||||
"overrides": {
|
||||
"eslint-config-next": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-common",
|
||||
"version": "2.2.0",
|
||||
"version": "2.1.1",
|
||||
"main": "build/main/index.js",
|
||||
"type": "module",
|
||||
"author": "Darren Clarke <darren@redaranj.com>",
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
"@babel/preset-typescript": "7.24.7",
|
||||
"prettier": "^3.3.3",
|
||||
"@link-stack/typescript-config": "*",
|
||||
"tsx": "^4.16.5",
|
||||
"tsx": "^4.17.0",
|
||||
"typescript": "^5.5.4"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,12 @@ export class Service {
|
|||
req: NextRequest,
|
||||
{ params: { service, token } }: ServiceParams,
|
||||
): Promise<NextResponse> {
|
||||
const table = getServiceTable(service);
|
||||
const row = await db
|
||||
.selectFrom(table)
|
||||
.selectAll()
|
||||
.where("token", "=", token ?? "NEVER_MATCH")
|
||||
.executeTakeFirstOrThrow();
|
||||
const json = await req.json();
|
||||
const worker = await getWorkerUtils();
|
||||
await worker.addJob(`${service}/send-${service}-message`, {
|
||||
|
|
@ -88,7 +94,17 @@ export class Service {
|
|||
...json,
|
||||
});
|
||||
|
||||
return NextResponse.json({ response: "ok" });
|
||||
const response = {
|
||||
response: "ok",
|
||||
result: {
|
||||
to: json.to,
|
||||
from: row?.phoneNumber ?? null,
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
};
|
||||
|
||||
console.log(response);
|
||||
return NextResponse.json(response);
|
||||
}
|
||||
|
||||
async receiveMessage(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-ui",
|
||||
"version": "0.2.0",
|
||||
"version": "2.1.1",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json"
|
||||
},
|
||||
|
|
@ -13,8 +13,8 @@
|
|||
"@link-stack/signal-api": "*",
|
||||
"@mui/icons-material": "^5",
|
||||
"@mui/material": "^5",
|
||||
"@mui/x-data-grid-pro": "^7.12.0",
|
||||
"@mui/x-date-pickers-pro": "^7.12.0",
|
||||
"@mui/x-data-grid-pro": "^7.12.1",
|
||||
"@mui/x-date-pickers-pro": "^7.12.1",
|
||||
"date-fns": "^3.6.0",
|
||||
"kysely": "0.26.1",
|
||||
"material-ui-popup-state": "^5.1.2",
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@types/node": "^22.1.0",
|
||||
"@types/node": "^22.2.0",
|
||||
"@types/react": "18.3.3",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@types/uuid": "^10.0.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/eslint-config",
|
||||
"version": "0.3.10",
|
||||
"version": "2.1.1",
|
||||
"description": "amigo's eslint config",
|
||||
"author": "Abel Luck <abel@guardianproject.info>",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
|
|
@ -10,14 +10,14 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@rushstack/eslint-patch": "^1.10.4",
|
||||
"@typescript-eslint/eslint-plugin": "^8.0.1",
|
||||
"@typescript-eslint/parser": "^8.0.1",
|
||||
"@typescript-eslint/eslint-plugin": "^8.1.0",
|
||||
"@typescript-eslint/parser": "^8.1.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-config-xo-space": "^0.35.0",
|
||||
"eslint-plugin-cypress": "^3.4.0",
|
||||
"eslint-plugin-cypress": "^3.5.0",
|
||||
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-jest": "^28.7.0",
|
||||
"eslint-plugin-jest": "^28.8.0",
|
||||
"eslint-plugin-promise": "^7.1.0",
|
||||
"eslint-plugin-unicorn": "55.0.0",
|
||||
"@babel/eslint-parser": "7.25.1"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/jest-config",
|
||||
"version": "0.0.1",
|
||||
"version": "2.1.1",
|
||||
"description": "",
|
||||
"author": "Abel Luck <abel@guardianproject.info>",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/leafcutter-ui",
|
||||
"version": "0.2.0",
|
||||
"version": "2.1.1",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json"
|
||||
},
|
||||
|
|
@ -11,8 +11,8 @@
|
|||
"@emotion/styled": "^11.13.0",
|
||||
"@mui/icons-material": "^5",
|
||||
"@mui/material": "^5",
|
||||
"@mui/x-data-grid-pro": "^7.12.0",
|
||||
"@mui/x-date-pickers-pro": "^7.12.0",
|
||||
"@mui/x-data-grid-pro": "^7.12.1",
|
||||
"@mui/x-date-pickers-pro": "^7.12.1",
|
||||
"@link-stack/opensearch-common": "*",
|
||||
"date-fns": "^3.6.0",
|
||||
"material-ui-popup-state": "^5.1.2",
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@types/node": "^22.1.0",
|
||||
"@types/node": "^22.2.0",
|
||||
"@types/react": "18.3.3",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"babel-loader": "^9.1.3",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/opensearch-common",
|
||||
"version": "0.2.0",
|
||||
"version": "2.1.1",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json"
|
||||
},
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@types/node": "^22.1.0",
|
||||
"@types/node": "^22.2.0",
|
||||
"@types/react": "18.3.3",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"babel-loader": "^9.1.3",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/signal-api",
|
||||
"version": "1.0.0",
|
||||
"version": "2.1.1",
|
||||
"type": "module",
|
||||
"main": "build/index.js",
|
||||
"exports": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/typescript-config",
|
||||
"version": "0.1.4",
|
||||
"version": "2.1.1",
|
||||
"description": "Shared TypeScript config",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"author": "Abel Luck <abel@guardianproject.info>",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/ui",
|
||||
"version": "1.0.0",
|
||||
"version": "2.1.1",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json"
|
||||
|
|
@ -9,14 +9,14 @@
|
|||
"dependencies": {
|
||||
"@mui/icons-material": "^5",
|
||||
"@mui/material": "^5",
|
||||
"@mui/x-data-grid-pro": "^7.12.0",
|
||||
"@mui/x-date-pickers-pro": "^7.12.0",
|
||||
"@mui/x-data-grid-pro": "^7.12.1",
|
||||
"@mui/x-date-pickers-pro": "^7.12.1",
|
||||
"next": "14.2.5",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.1.0",
|
||||
"@types/node": "^22.2.0",
|
||||
"@types/react": "18.3.3",
|
||||
"typescript": "^5.5.4"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@link-stack/zammad-addon-bridge",
|
||||
"displayName": "Bridge",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.1",
|
||||
"description": "An addon that adds CDR Bridge channels to Zammad.",
|
||||
"scripts": {
|
||||
"build": "node '../../node_modules/@link-stack/zammad-addon-common/dist/build.js'",
|
||||
|
|
|
|||
|
|
@ -61,16 +61,16 @@ class CommunicateCdrSignalJob < ApplicationJob
|
|||
|
||||
return if has_error
|
||||
|
||||
article.to = result['result']['recipient']
|
||||
article.from = result['result']['source']
|
||||
article.to = result['result']['to']
|
||||
article.from = result['result']['from']
|
||||
|
||||
message_id = format('%<source>s@%<timestamp>s', source: result['result']['source'],
|
||||
message_id = format('%<from>s@%<timestamp>s', from: result['result']['from'],
|
||||
timestamp: result['result']['timestamp'])
|
||||
article.preferences['cdr_signal'] = {
|
||||
timestamp: result['result']['timestamp'],
|
||||
message_id: message_id,
|
||||
from: result['result']['source'],
|
||||
to: result['result']['recipient']
|
||||
from: result['result']['from'],
|
||||
to: result['result']['to']
|
||||
}
|
||||
|
||||
# set delivery status
|
||||
|
|
|
|||
|
|
@ -61,16 +61,16 @@ class CommunicateCdrWhatsappJob < ApplicationJob
|
|||
|
||||
return if has_error
|
||||
|
||||
article.to = result['result']['recipient']
|
||||
article.from = result['result']['source']
|
||||
article.to = result['result']['to']
|
||||
article.from = result['result']['from']
|
||||
|
||||
message_id = format('%<source>s@%<timestamp>s', source: result['result']['source'],
|
||||
message_id = format('%<from>s@%<timestamp>s', from: result['result']['from'],
|
||||
timestamp: result['result']['timestamp'])
|
||||
article.preferences['cdr_whatsapp'] = {
|
||||
timestamp: result['result']['timestamp'],
|
||||
message_id: message_id,
|
||||
from: result['result']['source'],
|
||||
to: result['result']['recipient']
|
||||
from: result['result']['from'],
|
||||
to: result['result']['to']
|
||||
}
|
||||
|
||||
# set delivery status
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class CdrSignal
|
|||
end
|
||||
|
||||
def self.message_id(message_raw)
|
||||
format('%<source>s@%<timestamp>s', source: message_raw['source'], timestamp: message_raw['timestamp'])
|
||||
format('%<from>s@%<timestamp>s', from: message_raw['from'], timestamp: message_raw['timestamp'])
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class CdrWhatsapp
|
|||
end
|
||||
|
||||
def self.message_id(message_raw)
|
||||
format('%<source>s@%<timestamp>s', source: message_raw['source'], timestamp: message_raw['timestamp'])
|
||||
format('%<from>s@%<timestamp>s', from: message_raw['from'], timestamp: message_raw['timestamp'])
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/zammad-addon-common",
|
||||
"version": "1.0.0",
|
||||
"version": "2.1.1",
|
||||
"description": "",
|
||||
"bin": {
|
||||
"zpm-build": "./dist/build.js",
|
||||
|
|
@ -9,6 +9,10 @@
|
|||
"scripts": {
|
||||
"build": "tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5",
|
||||
"@types/node": "^22"
|
||||
},
|
||||
"author": "",
|
||||
"license": "AGPL-3.0-or-later"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
"compilerOptions": {
|
||||
"incremental": true,
|
||||
"target": "es2020",
|
||||
"lib": [
|
||||
"es2020"
|
||||
],
|
||||
"lib": ["es2020"],
|
||||
"moduleResolution": "node",
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
|
|
@ -22,9 +20,6 @@
|
|||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"outDir": "dist",
|
||||
"types": [
|
||||
"node",
|
||||
"jest"
|
||||
]
|
||||
"types": ["node"]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@link-stack/zammad-addon-hardening",
|
||||
"displayName": "Hardening",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.1",
|
||||
"description": "A Zammad addon that hardens a Zammad instance according to CDR's needs.",
|
||||
"scripts": {
|
||||
"build": "node '../../node_modules/@link-stack/zammad-addon-common/dist/build.js'",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@link-stack/zammad-addon-leafcutter",
|
||||
"displayName": "Leafcutter",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.1",
|
||||
"description": "Adds a common set of tags for Leafcutter uses.",
|
||||
"scripts": {
|
||||
"build": "node '../../node_modules/@link-stack/zammad-addon-common/dist/build.js'",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue