-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
112 lines (103 loc) · 2.4 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { InsertMeaning } from "./db/schema/meanings";
import { PartOfSpeech } from "./db/schema/part_of_speechs";
import { InsertRoot } from "./db/schema/roots";
import { InsertWord } from "./db/schema/words";
type LoginInputs = {
usernameOrEmail: string;
password: string;
};
type ForgotPassword = {
forgotPasswordEmail: string;
};
type Prettify<T> = { [K in keyof T]: T[K] } & {};
type SignupInputs =
| "name"
| "username"
| "email"
| "password"
| "confirmPassword";
type SignupForm = Record<SignupInputs, string>;
type SignupRequest = Omit<SignupForm, "confirmPassword">; // Omit confirmPassword from SignUpInputs to create SignUpRequest
type ReplaceNullWithUndefined<T> = T extends null ? undefined : T;
type ToUndefinedProps<T> = {
// Replace null with undefined
[P in keyof T]: ReplaceNullWithUndefined<T[P]>;
};
type WordInput = ToUndefinedProps<
// Replace null with undefined since null is not allowed in Input value prop of NextUI
Prettify<
Partial<
Omit<InsertWord, "rootId" | "created_at" | "updated_at" | "id"> &
{
language: string
root: string;
attributes: string;
}
>
>
>;
type Meaning = {
meaning: string;
image: FileList | null;
example?: {
sentence: string | undefined;
author: string | undefined;
};
partOfSpeechId: number | undefined;
attributes: string;
};
type MeaningInputs = Partial<Meaning>;
type WordForm = Prettify<
WordInput & {
meanings: MeaningInputs[];
}
>;
type WordFormSubmit = Prettify<{
name: string;
language?: string;
phonetic?: string;
root?: string;
prefix?: string;
suffix?: string;
meanings: {
meaning: string;
partOfSpeechId: number;
attributes?: string;
example?: {
sentence: string;
author: 'string | number';
}
}[]
}>;
type WordSearchResult = {
word_data: {
word_id: number;
word_name: string;
phonetic: string;
prefix: string;
suffix: string;
attributes?: {
attribute_id: number;
attribute: string;
}[];
root: {
root: string;
language_en: string;
language_tr: string;
language_code: string;
};
meanings: {
meaning_id: number;
meaning: string;
part_of_speech: string;
sentence: string | null;
author: string | null;
attributes?: [
{
attribute_id: number;
attribute: string;
}
]
}[];
}
}