♻️ Regenerate client to use UUID instead of id integers and update frontend (#1281)

This commit is contained in:
Abdul
2024-08-01 11:48:00 -07:00
committed by GitHub
parent 19049f2a74
commit 36767344aa
5 changed files with 80 additions and 41 deletions

View File

@@ -1,9 +1,9 @@
import axios from "axios"
import type {
AxiosError,
AxiosInstance,
AxiosRequestConfig,
AxiosResponse,
AxiosInstance,
} from "axios"
import { ApiError } from "./ApiError"
@@ -151,12 +151,12 @@ export const getHeaders = async (
)
if (isStringWithValue(token)) {
headers["Authorization"] = `Bearer ${token}`
headers.Authorization = `Bearer ${token}`
}
if (isStringWithValue(username) && isStringWithValue(password)) {
const credentials = base64(`${username}:${password}`)
headers["Authorization"] = `Basic ${credentials}`
headers.Authorization = `Basic ${credentials}`
}
if (options.body !== undefined) {

View File

@@ -19,8 +19,8 @@ export type ItemCreate = {
export type ItemPublic = {
title: string
description?: string | null
id: number
owner_id: number
id: string
owner_id: string
}
export type ItemUpdate = {
@@ -65,7 +65,7 @@ export type UserPublic = {
is_active?: boolean
is_superuser?: boolean
full_name?: string | null
id: number
id: string
}
export type UserRegister = {

View File

@@ -65,12 +65,15 @@ export const $ItemCreate = {
title: {
type: "string",
isRequired: true,
maxLength: 255,
minLength: 1,
},
description: {
type: "any-of",
contains: [
{
type: "string",
maxLength: 255,
},
{
type: "null",
@@ -85,12 +88,15 @@ export const $ItemPublic = {
title: {
type: "string",
isRequired: true,
maxLength: 255,
minLength: 1,
},
description: {
type: "any-of",
contains: [
{
type: "string",
maxLength: 255,
},
{
type: "null",
@@ -98,12 +104,14 @@ export const $ItemPublic = {
],
},
id: {
type: "number",
type: "string",
isRequired: true,
format: "uuid",
},
owner_id: {
type: "number",
type: "string",
isRequired: true,
format: "uuid",
},
},
} as const
@@ -115,6 +123,8 @@ export const $ItemUpdate = {
contains: [
{
type: "string",
maxLength: 255,
minLength: 1,
},
{
type: "null",
@@ -126,6 +136,7 @@ export const $ItemUpdate = {
contains: [
{
type: "string",
maxLength: 255,
},
{
type: "null",
@@ -169,6 +180,8 @@ export const $NewPassword = {
new_password: {
type: "string",
isRequired: true,
maxLength: 40,
minLength: 8,
},
},
} as const
@@ -191,10 +204,14 @@ export const $UpdatePassword = {
current_password: {
type: "string",
isRequired: true,
maxLength: 40,
minLength: 8,
},
new_password: {
type: "string",
isRequired: true,
maxLength: 40,
minLength: 8,
},
},
} as const
@@ -204,6 +221,8 @@ export const $UserCreate = {
email: {
type: "string",
isRequired: true,
format: "email",
maxLength: 255,
},
is_active: {
type: "boolean",
@@ -218,6 +237,7 @@ export const $UserCreate = {
contains: [
{
type: "string",
maxLength: 255,
},
{
type: "null",
@@ -227,6 +247,8 @@ export const $UserCreate = {
password: {
type: "string",
isRequired: true,
maxLength: 40,
minLength: 8,
},
},
} as const
@@ -236,6 +258,8 @@ export const $UserPublic = {
email: {
type: "string",
isRequired: true,
format: "email",
maxLength: 255,
},
is_active: {
type: "boolean",
@@ -250,6 +274,7 @@ export const $UserPublic = {
contains: [
{
type: "string",
maxLength: 255,
},
{
type: "null",
@@ -257,8 +282,9 @@ export const $UserPublic = {
],
},
id: {
type: "number",
type: "string",
isRequired: true,
format: "uuid",
},
},
} as const
@@ -268,16 +294,21 @@ export const $UserRegister = {
email: {
type: "string",
isRequired: true,
format: "email",
maxLength: 255,
},
password: {
type: "string",
isRequired: true,
maxLength: 40,
minLength: 8,
},
full_name: {
type: "any-of",
contains: [
{
type: "string",
maxLength: 255,
},
{
type: "null",
@@ -294,6 +325,8 @@ export const $UserUpdate = {
contains: [
{
type: "string",
format: "email",
maxLength: 255,
},
{
type: "null",
@@ -313,6 +346,7 @@ export const $UserUpdate = {
contains: [
{
type: "string",
maxLength: 255,
},
{
type: "null",
@@ -324,6 +358,8 @@ export const $UserUpdate = {
contains: [
{
type: "string",
maxLength: 40,
minLength: 8,
},
{
type: "null",
@@ -340,6 +376,7 @@ export const $UserUpdateMe = {
contains: [
{
type: "string",
maxLength: 255,
},
{
type: "null",
@@ -351,6 +388,8 @@ export const $UserUpdateMe = {
contains: [
{
type: "string",
format: "email",
maxLength: 255,
},
{
type: "null",

View File

@@ -4,20 +4,20 @@ import { request as __request } from "./core/request"
import type {
Body_login_login_access_token,
ItemCreate,
ItemPublic,
ItemUpdate,
ItemsPublic,
Message,
NewPassword,
Token,
UserPublic,
UpdatePassword,
UserCreate,
UserPublic,
UserRegister,
UsersPublic,
UserUpdate,
UserUpdateMe,
ItemCreate,
ItemPublic,
ItemsPublic,
ItemUpdate,
UsersPublic,
} from "./models"
export type TDataLoginAccessToken = {
@@ -50,7 +50,7 @@ export class LoginService {
formData: formData,
mediaType: "application/x-www-form-urlencoded",
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -85,7 +85,7 @@ export class LoginService {
email,
},
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -106,7 +106,7 @@ export class LoginService {
body: requestBody,
mediaType: "application/json",
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -128,7 +128,7 @@ export class LoginService {
email,
},
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -151,14 +151,14 @@ export type TDataRegisterUser = {
requestBody: UserRegister
}
export type TDataReadUserById = {
userId: number
userId: string
}
export type TDataUpdateUser = {
requestBody: UserUpdate
userId: number
userId: string
}
export type TDataDeleteUser = {
userId: number
userId: string
}
export class UsersService {
@@ -180,7 +180,7 @@ export class UsersService {
limit,
},
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -201,7 +201,7 @@ export class UsersService {
body: requestBody,
mediaType: "application/json",
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -248,7 +248,7 @@ export class UsersService {
body: requestBody,
mediaType: "application/json",
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -269,7 +269,7 @@ export class UsersService {
body: requestBody,
mediaType: "application/json",
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -290,7 +290,7 @@ export class UsersService {
body: requestBody,
mediaType: "application/json",
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -312,7 +312,7 @@ export class UsersService {
user_id: userId,
},
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -336,7 +336,7 @@ export class UsersService {
body: requestBody,
mediaType: "application/json",
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -356,7 +356,7 @@ export class UsersService {
user_id: userId,
},
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -382,7 +382,7 @@ export class UtilsService {
email_to: emailTo,
},
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -396,14 +396,14 @@ export type TDataCreateItem = {
requestBody: ItemCreate
}
export type TDataReadItem = {
id: number
id: string
}
export type TDataUpdateItem = {
id: number
id: string
requestBody: ItemUpdate
}
export type TDataDeleteItem = {
id: number
id: string
}
export class ItemsService {
@@ -425,7 +425,7 @@ export class ItemsService {
limit,
},
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -446,7 +446,7 @@ export class ItemsService {
body: requestBody,
mediaType: "application/json",
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -466,7 +466,7 @@ export class ItemsService {
id,
},
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -490,7 +490,7 @@ export class ItemsService {
body: requestBody,
mediaType: "application/json",
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}
@@ -510,7 +510,7 @@ export class ItemsService {
id,
},
errors: {
422: `Validation Error`,
422: "Validation Error",
},
})
}