before delete 3software
This commit is contained in:
@@ -7,9 +7,10 @@ interface Chat {
|
||||
bot_can_ban: boolean
|
||||
user_count: number
|
||||
last_update_time: number
|
||||
description?: string
|
||||
logo?: string
|
||||
owner_id: number
|
||||
description: string | null
|
||||
logo: string | null
|
||||
owner_id?: number
|
||||
invite_link: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
@@ -1,21 +1,28 @@
|
||||
interface User {
|
||||
interface CompanyParams {
|
||||
name: string
|
||||
description: string
|
||||
address: string
|
||||
site: string
|
||||
phone: string
|
||||
email: string
|
||||
logo: string
|
||||
[key: string]: string | number
|
||||
}
|
||||
|
||||
interface Company extends CompanyParams {
|
||||
id: number
|
||||
project_id: number
|
||||
telegram_id: number
|
||||
firstname?: string
|
||||
lastname?: string
|
||||
username?: string
|
||||
photo: string
|
||||
phone: string
|
||||
settings?: {
|
||||
language?: string
|
||||
fontSize?: number
|
||||
timezone: number
|
||||
}
|
||||
[key: string]: string | number
|
||||
}
|
||||
|
||||
interface CompanyMask {
|
||||
company_id: number
|
||||
company_list: number[]
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type {
|
||||
Company,
|
||||
CompanyParams
|
||||
CompanyParams,
|
||||
CompanyMask
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
interface ProjectParams {
|
||||
name: string
|
||||
description?: string
|
||||
logo?: string
|
||||
description: string
|
||||
logo: string
|
||||
is_logo_bg: boolean
|
||||
[key: string]: unknown
|
||||
}
|
||||
@@ -14,25 +14,7 @@ interface Project extends ProjectParams {
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
interface RawProjectParams {
|
||||
name: string
|
||||
description?: string
|
||||
logo?: string
|
||||
is_logo_bg: number
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
interface RawProject extends RawProjectParams{
|
||||
id: number
|
||||
is_archived: number
|
||||
chat_count: number
|
||||
user_count: number
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type {
|
||||
Project,
|
||||
ProjectParams,
|
||||
RawProject,
|
||||
RawProjectParams
|
||||
ProjectParams
|
||||
}
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
interface User {
|
||||
interface UserParams {
|
||||
fullname: string
|
||||
department: string
|
||||
role: string
|
||||
phone: string
|
||||
email: string
|
||||
is_blocked: boolean
|
||||
company_id: number | null
|
||||
}
|
||||
|
||||
interface User extends UserParams {
|
||||
id: number
|
||||
project_id: number
|
||||
telegram_id: number
|
||||
firstname?: string
|
||||
lastname?: string
|
||||
username?: string
|
||||
photo: string
|
||||
phone: string
|
||||
settings?: {
|
||||
language?: string
|
||||
fontSize?: number
|
||||
timezone: number
|
||||
}
|
||||
firstname: string | null
|
||||
lastname: string | null
|
||||
username: string | null
|
||||
photo: string | null
|
||||
is_leave: boolean
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type {
|
||||
User
|
||||
User,
|
||||
UserParams
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
export function clientConverter<TClient, TServer extends Record<string, unknown>>(
|
||||
data: TServer | null | undefined,
|
||||
booleanFields: Array<keyof TClient>
|
||||
): TClient {
|
||||
if (!data) {
|
||||
throw new Error("Invalid data: null or undefined");
|
||||
}
|
||||
|
||||
return Object.entries(data).reduce((acc, [key, value]) => {
|
||||
const typedKey = key as keyof TClient;
|
||||
return {
|
||||
...acc,
|
||||
[typedKey]: booleanFields.includes(typedKey)
|
||||
? Boolean(value)
|
||||
: value
|
||||
};
|
||||
}, {} as TClient);
|
||||
}
|
||||
|
||||
export function serverConverter<TClient, TServer extends Record<string, unknown>>(
|
||||
data: TClient | null | undefined,
|
||||
booleanFields: Array<keyof TClient>
|
||||
): TServer {
|
||||
if (!data) {
|
||||
throw new Error("Invalid data: null or undefined");
|
||||
}
|
||||
|
||||
return Object.entries(data).reduce((acc, [key, value]) => {
|
||||
const typedKey = key as keyof TClient;
|
||||
return {
|
||||
...acc,
|
||||
[key]: booleanFields.includes(typedKey)
|
||||
? value ? 1 : 0
|
||||
: value
|
||||
};
|
||||
}, {} as TServer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user