From d1424b3c9c417c893e4d19bcc52a03ef19fb81a7 Mon Sep 17 00:00:00 2001 From: Pablo Lara Date: Sat, 16 Nov 2024 15:57:28 +0100 Subject: [PATCH] fix: resolve breaking changes caused by updated API specs --- actions/auth/auth.ts | 4 ++-- actions/invitations/invitation.ts | 4 ++-- actions/providers/providers.ts | 8 ++++---- actions/scans/scans.ts | 6 +++--- actions/users/users.ts | 2 +- auth.config.ts | 2 +- types/components.ts | 30 +++++++++++++++--------------- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/actions/auth/auth.ts b/actions/auth/auth.ts index 4973e3f8e2..d5ec199b06 100644 --- a/actions/auth/auth.ts +++ b/actions/auth/auth.ts @@ -62,7 +62,7 @@ export const createNewUser = async ( const bodyData = { data: { - type: "User", + type: "users", attributes: { name: formData.name, email: formData.email, @@ -99,7 +99,7 @@ export const getToken = async (formData: z.infer) => { const bodyData = { data: { - type: "Token", + type: "tokens", attributes: { email: formData.email, password: formData.password, diff --git a/actions/invitations/invitation.ts b/actions/invitations/invitation.ts index 7fc99ce33c..654d9fd982 100644 --- a/actions/invitations/invitation.ts +++ b/actions/invitations/invitation.ts @@ -56,7 +56,7 @@ export const sendInvite = async (formData: FormData) => { const body = JSON.stringify({ data: { - type: "Invitation", + type: "invitations", attributes: { email, }, @@ -104,7 +104,7 @@ export const updateInvite = async (formData: FormData) => { }, body: JSON.stringify({ data: { - type: "Invitation", + type: "invitations", id: invitationId, attributes: { email: invitationEmail, diff --git a/actions/providers/providers.ts b/actions/providers/providers.ts index 29a8a114c7..fc5cd97bb7 100644 --- a/actions/providers/providers.ts +++ b/actions/providers/providers.ts @@ -90,7 +90,7 @@ export const updateProvider = async (formData: FormData) => { }, body: JSON.stringify({ data: { - type: "Provider", + type: "providers", id: providerId, attributes: { alias: providerAlias, @@ -129,7 +129,7 @@ export const addProvider = async (formData: FormData) => { }, body: JSON.stringify({ data: { - type: "Provider", + type: "providers", attributes: { provider: providerType, uid: providerUid, @@ -209,7 +209,7 @@ export const addCredentialsProvider = async (formData: FormData) => { const bodyData = { data: { - type: "ProviderSecret", + type: "provider-secrets", attributes: { secret_type: secretType, secret, @@ -219,7 +219,7 @@ export const addCredentialsProvider = async (formData: FormData) => { provider: { data: { id: providerId, - type: "Provider", + type: "providers", }, }, }, diff --git a/actions/scans/scans.ts b/actions/scans/scans.ts index 866918cf86..367446daaa 100644 --- a/actions/scans/scans.ts +++ b/actions/scans/scans.ts @@ -91,14 +91,14 @@ export const scanOnDemand = async (formData: FormData) => { }, body: JSON.stringify({ data: { - type: "Scan", + type: "scans", attributes: { name: scanName, }, relationships: { provider: { data: { - type: "Provider", + type: "providers", id: providerId, }, }, @@ -136,7 +136,7 @@ export const updateScan = async (formData: FormData) => { }, body: JSON.stringify({ data: { - type: "Scan", + type: "scans", id: scanId, attributes: { name: scanName, diff --git a/actions/users/users.ts b/actions/users/users.ts index 903d0be120..30a5b26d1f 100644 --- a/actions/users/users.ts +++ b/actions/users/users.ts @@ -69,7 +69,7 @@ export const updateUser = async (formData: FormData) => { }, body: JSON.stringify({ data: { - type: "User", + type: "users", id: userId, attributes: { name: userName, diff --git a/auth.config.ts b/auth.config.ts index 4639f8bf37..56c44a14e5 100644 --- a/auth.config.ts +++ b/auth.config.ts @@ -16,7 +16,7 @@ const refreshAccessToken = async (token: JwtPayload) => { const bodyData = { data: { - type: "TokenRefresh", + type: "tokens-refresh", attributes: { refresh: (token as any).refreshToken, }, diff --git a/types/components.ts b/types/components.ts index 2299d0bffe..52b553cce0 100644 --- a/types/components.ts +++ b/types/components.ts @@ -102,7 +102,7 @@ export interface ApiError { } export interface InvitationProps { - type: "Invitation"; + type: "invitations"; id: string; attributes: { inserted_at: string; @@ -115,7 +115,7 @@ export interface InvitationProps { relationships: { inviter: { data: { - type: "User"; + type: "users"; id: string; }; }; @@ -126,7 +126,7 @@ export interface InvitationProps { } export interface UserProps { - type: "User"; + type: "users"; id: string; attributes: { name: string; @@ -140,7 +140,7 @@ export interface UserProps { count: number; }; data: Array<{ - type: "Membership"; + type: "memberships"; id: string; }>; }; @@ -175,7 +175,7 @@ export interface ProviderProps { } export interface ScanProps { - type: "Scan"; + type: "scans"; id: string; attributes: { name: string; @@ -203,20 +203,20 @@ export interface ScanProps { provider: { data: { id: string; - type: "Provider"; + type: "providers"; }; }; task: { data: { id: string; - type: "Task"; + type: "tasks"; }; }; }; } export interface FindingProps { - type: "Finding"; + type: "findings"; id: string; attributes: { uid: string; @@ -264,13 +264,13 @@ export interface FindingProps { relationships: { resources: { data: { - type: "Resource"; + type: "resources"; id: string; }[]; }; scan: { data: { - type: "Scan"; + type: "scans"; id: string; }; attributes: { @@ -290,7 +290,7 @@ export interface FindingProps { }; resource: { data: { - type: "Resource"; + type: "resources"; id: string; }[]; id: string; @@ -307,7 +307,7 @@ export interface FindingProps { relationships: { provider: { data: { - type: "Provider"; + type: "providers"; id: string; }; }; @@ -316,7 +316,7 @@ export interface FindingProps { count: number; }; data: { - type: "Finding"; + type: "findings"; id: string; }[]; }; @@ -327,7 +327,7 @@ export interface FindingProps { }; provider: { data: { - type: "Provider"; + type: "providers"; id: string; }; attributes: { @@ -344,7 +344,7 @@ export interface FindingProps { relationships: { secret: { data: { - type: "ProviderSecret"; + type: "provider-secrets"; id: string; }; };