czapp-shared 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/dist/index.d.mts +268 -229
- package/dist/index.d.ts +268 -229
- package/dist/index.js +149 -114
- package/dist/index.mjs +144 -113
- package/package.json +3 -3
- package/src/{util.ts → concrete/date.ts} +1 -1
- package/src/concrete/lexeme.ts +32 -0
- package/src/concrete/string.ts +9 -0
- package/src/design/api.ts +172 -0
- package/src/design/lexemes.ts +40 -0
- package/src/{types.ts → design/types.ts} +13 -122
- package/src/{user.ts → design/user.ts} +13 -12
- package/src/index.ts +8 -4
- package/test/String.ts +31 -0
- package/src/lexemes.ts +0 -114
package/README.md
CHANGED
|
@@ -14,6 +14,24 @@ import { MyType } from 'czapp-shared';
|
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Development
|
|
17
|
+
To link the local copy of the package to another project, first in the root of the czapp-shared project run:
|
|
18
|
+
```bash
|
|
19
|
+
npm link
|
|
20
|
+
```
|
|
21
|
+
... then in the root of the project you want to link to run:
|
|
22
|
+
```bash
|
|
23
|
+
npm link czapp-shared
|
|
24
|
+
```
|
|
25
|
+
This will create a symlink in the node_modules folder of the project you want to link to that points to the local copy
|
|
26
|
+
of the package.
|
|
27
|
+
|
|
28
|
+
To run the project in watch mode:
|
|
29
|
+
```bash
|
|
30
|
+
npm run watch
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
To build the project (generate the artifacts):
|
|
34
|
+
```bash
|
|
17
35
|
To build:
|
|
18
36
|
```bash
|
|
19
37
|
npm run build
|
package/dist/index.d.mts
CHANGED
|
@@ -1,45 +1,132 @@
|
|
|
1
|
-
import { RowDataPacket } from 'mysql2';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
2
|
+
* @name convertJSDateObjectToMySQLDateString
|
|
3
|
+
* @description Converts a JavaScript Date object to a MySQL date string
|
|
4
|
+
* @param date
|
|
5
|
+
* @type Date
|
|
6
|
+
* @returns MySQLDate in the format "2021-01-01 07:41:23"
|
|
5
7
|
*/
|
|
8
|
+
declare const convertJSDateObjectToMySQLDateString: (date: Date) => MySQLDate | undefined;
|
|
6
9
|
/**
|
|
7
|
-
* @
|
|
8
|
-
* @description
|
|
9
|
-
*
|
|
10
|
+
* @name convertJSDateStringToMySQLDate
|
|
11
|
+
* @description Converts a JavaScript Date object to a MySQL date string
|
|
12
|
+
* @param date in the format "2021-01-01T07:41:23.000Z"
|
|
13
|
+
* @type string
|
|
14
|
+
* @returns date in the format "2021-01-01 07:41:23"
|
|
15
|
+
* @returns undefined if the input date is invalid
|
|
10
16
|
*/
|
|
11
|
-
|
|
12
|
-
id: number | undefined;
|
|
13
|
-
dateAdded: string;
|
|
14
|
-
text: string;
|
|
15
|
-
userId: string;
|
|
16
|
-
}
|
|
17
|
+
declare const convertJSDateStringToMySQLDate: (date: string) => MySQLDate | undefined;
|
|
17
18
|
/**
|
|
18
|
-
* @
|
|
19
|
-
* @description
|
|
20
|
-
*
|
|
19
|
+
* @name isValidMysqlDateString
|
|
20
|
+
* @description Checks if a string representation of date/time is in the format "2021-01-01 07:41:23"
|
|
21
|
+
* @param dateStr
|
|
22
|
+
* @returns boolean
|
|
21
23
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
lastFlashcardReview: MySQLDate;
|
|
31
|
-
lastModified: MySQLDate;
|
|
32
|
-
lastTested: MySQLDate;
|
|
33
|
-
learningStage: LearningStage;
|
|
34
|
-
notes: string;
|
|
35
|
-
userId: string;
|
|
36
|
-
}
|
|
24
|
+
declare const isValidMysqlDateString: (dateStr: string) => boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @name isValidJsDateString
|
|
27
|
+
* @description Checks if a string representation of date/time is in the format "2021-01-01T07:41:23.000Z"
|
|
28
|
+
* @param dateStr
|
|
29
|
+
* @returns boolean
|
|
30
|
+
*/
|
|
31
|
+
declare const isValidJsDateString: (dateStr: string) => boolean;
|
|
37
32
|
/**
|
|
38
|
-
*
|
|
33
|
+
* @name isClientDateTooFarFromServerDate
|
|
34
|
+
* @description Checks if the client date is more than one day away from the server date
|
|
35
|
+
* @param clientDateMySQLFormat date in MySQL format
|
|
36
|
+
* @param serverDate date object representation of the current time on the server
|
|
37
|
+
* @returns boolean
|
|
39
38
|
*/
|
|
39
|
+
declare const isClientDateTooFarFromServerDate: (clientDateMySQLFormat: MySQLDate, serverDate: Date) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* @name dateDifferenceInDays
|
|
42
|
+
* @description Calculates the difference in days between two dates and returns a positive integer
|
|
43
|
+
* if the first date is before the second date, and a negative integer if the first date is after the second date
|
|
44
|
+
* @param date1 date in MySQL format
|
|
45
|
+
* @param date2 date in MySQL format
|
|
46
|
+
* @returns number
|
|
47
|
+
*/
|
|
48
|
+
declare const dateDifferenceInDays: (date1: MySQLDate, date2: MySQLDate) => number;
|
|
49
|
+
declare const getClientDate: (date: Date) => string;
|
|
50
|
+
declare const isThePreviousDay: (date: MySQLDate, referenceDate: MySQLDate) => boolean;
|
|
51
|
+
declare const isTheSameDay: (date1: MySQLDate, date2: MySQLDate) => boolean;
|
|
52
|
+
declare const getFormattedDate: (date: Date) => string;
|
|
53
|
+
|
|
54
|
+
declare enum Language {
|
|
55
|
+
CZECH = "cz",
|
|
56
|
+
ENGLISH = "en",
|
|
57
|
+
UNKNOWN = "UNKNOWN"
|
|
58
|
+
}
|
|
59
|
+
type Result<T> = [T, undefined] | [undefined, Error];
|
|
60
|
+
declare enum Familiarity {
|
|
61
|
+
KNOWN = "KNOWN",
|
|
62
|
+
ALMOST = "ALMOST",
|
|
63
|
+
UNKNOWN = "UNKNOWN"
|
|
64
|
+
}
|
|
65
|
+
declare enum VocabCheckType {
|
|
66
|
+
FLASHCARD = "flashcard",
|
|
67
|
+
TEST = "test"
|
|
68
|
+
}
|
|
69
|
+
declare enum LearningStage {
|
|
70
|
+
NEW = "NEW",
|
|
71
|
+
LEARNING = "LEARNING",
|
|
72
|
+
RETIRED = "RETIRED"
|
|
73
|
+
}
|
|
74
|
+
declare enum Progress {
|
|
75
|
+
WORSE = 0,
|
|
76
|
+
NONE = 1,
|
|
77
|
+
IMPROVED = 2
|
|
78
|
+
}
|
|
79
|
+
interface ITestResult {
|
|
80
|
+
lexemePair: ILexemePair;
|
|
81
|
+
progress: Progress;
|
|
82
|
+
thinkingTimeSecs: number;
|
|
83
|
+
}
|
|
84
|
+
type MySQLDate = `${number}-${number}-${number} ${number}:${number}:${number}`;
|
|
85
|
+
declare enum ReminderFrequency {
|
|
86
|
+
ALWAYS = "always",
|
|
87
|
+
DAILY = "daily",
|
|
88
|
+
NEVER = "never"
|
|
89
|
+
}
|
|
90
|
+
declare enum AppError {
|
|
91
|
+
NONE = "No error",
|
|
92
|
+
REQUEST_AUTOLOGIN_FAILED = "Failed to auto-login",
|
|
93
|
+
REQUEST_DELETE_ALL_USER_DATA_FAILED = "Failed to delete all user data",
|
|
94
|
+
REQUEST_DELETE_LEXEME_PAIR_FAILED = "Failed to delete lexeme pair",
|
|
95
|
+
REQUEST_SIGN_IN_FAILED = "Failed to sign in",
|
|
96
|
+
REQUEST_SIGN_OUT_FAILED = "Failed to sign out",
|
|
97
|
+
REQUEST_GET_LEXEMES_FAILED = "Failed to get lexemes",
|
|
98
|
+
REQUEST_GET_LEXEMES_FOR_TEST_FAILED = "Failed to get lexemes for test",
|
|
99
|
+
REQUEST_UPDATE_FAMILIARITY_FAILED = "Failed to update familiarity",
|
|
100
|
+
REQUEST_UPDATE_USER_SETTINGS_FAILED = "Failed to update user settings",
|
|
101
|
+
REQUEST_INSERT_OR_UPDATE_LEXEME_PAIR_FAILED = "Failed to insert or update lexeme pair",
|
|
102
|
+
REQUEST_TRANSLATION_FAILED = "Failed to get translation",
|
|
103
|
+
REQUEST_TEST_COMPLETE_FAILED = "Failed to complete test"
|
|
104
|
+
}
|
|
105
|
+
declare enum Scenario {
|
|
106
|
+
S1_INSERT_HAPPY_PATH = "Insert, happy path",
|
|
107
|
+
S2_INSERT_ENGLISH_LEXEME_AND_MAPPING_DUPLICATE_CZECH_LEXEME_FOUND_AND_USED = "Insert English lexeme and mapping, duplicate Czech lexeme found and used",
|
|
108
|
+
S3_INSERT_CZECH_LEXEME_AND_MAPPING_DUPLICATE_ENGLISH_LEXEME_FOUND_AND_USED = "Insert Czech lexeme and mapping, duplicate English lexeme found and used",
|
|
109
|
+
S4_INSERT_MAPPING_ONLY_DUPLICATE_CZECH_AND_ENGLISH_LEXEMES_FOUND_AND_USED = "Insert mapping only, duplicate Czech and English lexemes found and used",
|
|
110
|
+
S5_NO_INSERT_REQUIRED_DUPLICATE_LEXEMES_AND_PAIRING_FOUND = "No insert required, duplicate lexemes and pairing found",
|
|
111
|
+
S6_NO_UPDATE_REQUIRED_NO_CHANGES_DETECTED = "No update required, no changes detected",
|
|
112
|
+
S7_CZECH_LEXEME_UPDATED = "Scenario 7: Czech lexeme updated",
|
|
113
|
+
S8_CZECH_LEXEME_DELETED_DUPLICATE_CZECH_LEXEME_CAN_BE_USED = "Scenario 8: Czech lexeme deleted, duplicate Czech lexeme can be used can be used",
|
|
114
|
+
S9_CZECH_LEXEME_AND_MAPPING_DELETED_DISCOVERED_LEXEMES_AND_MAPPING_CAN_BE_USED = "Scenario 9: Czech lexeme and mapping deleted, discovered lexemes and mapping can be used",
|
|
115
|
+
S10_MAPPING_UPDATED_TO_USE_NEW_CZECH_LEXEME = "Scenario 10: Mapping updated to use new Czech lexeme",
|
|
116
|
+
S11_MAPPING_UPDATED_TO_USE_DUPLICATE_CZECH_LEXEME = "Scenario 11: Mapping updated to use duplicate Czech lexeme",
|
|
117
|
+
S12_MAPPING_DELETED_DUPLICATE_MAPPING_CAN_BE_USED_WHEN_CZECH_LEXEME_MODIFIED = "Scenario 12: Mapping deleted, duplicate mapping can be used when Czech lexeme modified",
|
|
118
|
+
S13_ENGLISH_LEXEME_UPDATED = "Scenario 13: English lexeme updated",
|
|
119
|
+
S14_ENGLISH_LEXEME_DELETED_DUPLICATE_ENGLISH_LEXEME_CAN_BE_USED = "Scenario 14: English lexeme deleted, duplicate English lexeme can be used",
|
|
120
|
+
S15_ENGLISH_LEXEME_AND_MAPPING_DELETED_DISCOVERED_LEXEMES_AND_MAPPING_CAN_BE_USED = "Scenario 15: English lexeme and mapping deleted, discovered lexemes and mapping can be used",
|
|
121
|
+
S16_MAPPING_UPDATED_TO_USE_NEW_ENGLISH_LEXEME = "Scenario 16: Mapping updated to use new English lexeme",
|
|
122
|
+
S17_MAPPING_UPDATED_TO_USE_DUPLICATE_ENGLISH_LEXEME = "Scenario 17: Mapping updated to use duplicate English lexeme",
|
|
123
|
+
S18_MAPPING_DELETED_DUPLICATE_MAPPING_CAN_BE_USED_WHEN_ENGLISH_LEXEME_MODIFIED = "Scenario 18: Mapping deleted, duplicate mapping can be used when English lexeme modified",
|
|
124
|
+
ERROR = "Error"
|
|
125
|
+
}
|
|
126
|
+
|
|
40
127
|
interface ILexeme {
|
|
41
128
|
id: number | undefined;
|
|
42
|
-
dateAdded:
|
|
129
|
+
dateAdded: MySQLDate;
|
|
43
130
|
text: string;
|
|
44
131
|
userId: string;
|
|
45
132
|
}
|
|
@@ -56,16 +143,26 @@ interface ILexemePair {
|
|
|
56
143
|
notes: string;
|
|
57
144
|
userId: string;
|
|
58
145
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
146
|
+
interface ILexemeIdPair {
|
|
147
|
+
czId: number;
|
|
148
|
+
enId: number;
|
|
149
|
+
}
|
|
64
150
|
type LexemePairWithLang = {
|
|
65
151
|
czechLexeme: ILexeme;
|
|
66
152
|
englishLexeme: ILexeme;
|
|
67
153
|
langToFocus: Language;
|
|
68
154
|
};
|
|
155
|
+
interface ICount {
|
|
156
|
+
count: number;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
declare class Lexeme implements ILexeme {
|
|
160
|
+
text: string;
|
|
161
|
+
id: number | undefined;
|
|
162
|
+
dateAdded: MySQLDate;
|
|
163
|
+
userId: string;
|
|
164
|
+
constructor();
|
|
165
|
+
}
|
|
69
166
|
declare class LexemePair implements ILexemePair {
|
|
70
167
|
czechLexeme: ILexeme;
|
|
71
168
|
dateAdded: MySQLDate;
|
|
@@ -78,43 +175,53 @@ declare class LexemePair implements ILexemePair {
|
|
|
78
175
|
learningStage: LearningStage;
|
|
79
176
|
notes: string;
|
|
80
177
|
userId: string;
|
|
81
|
-
constructor(englishLexeme:
|
|
178
|
+
constructor(englishLexeme: Lexeme, czechLexeme: Lexeme);
|
|
82
179
|
}
|
|
83
180
|
|
|
84
|
-
declare
|
|
181
|
+
declare const isStringContainingInteger: (str: any) => boolean;
|
|
182
|
+
declare const parameterReplace: (path: string, params?: string[]) => string;
|
|
183
|
+
|
|
184
|
+
declare enum Language$1 {
|
|
85
185
|
CZECH = "cz",
|
|
86
186
|
ENGLISH = "en",
|
|
87
187
|
UNKNOWN = "UNKNOWN"
|
|
88
188
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
189
|
+
|
|
190
|
+
interface IUserData {
|
|
191
|
+
currentStreakEnd: MySQLDate | undefined;
|
|
192
|
+
currentStreakLength: number;
|
|
193
|
+
email: string;
|
|
194
|
+
flashcardReviewCompletedCount: number;
|
|
195
|
+
googleSub: string;
|
|
196
|
+
highStreakEnd: MySQLDate | undefined;
|
|
197
|
+
highStreakLength: number;
|
|
198
|
+
lastModified: MySQLDate;
|
|
199
|
+
lastWordAdded: string;
|
|
200
|
+
learningLanguage: Language;
|
|
201
|
+
lexemePairCount: number;
|
|
202
|
+
name: string;
|
|
203
|
+
phone: string;
|
|
204
|
+
rewardPoints: number;
|
|
205
|
+
signUpDate: MySQLDate;
|
|
206
|
+
testsCompletedCount: number;
|
|
207
|
+
testsUnlocked: boolean;
|
|
208
|
+
uiLanguage: Language;
|
|
109
209
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
210
|
+
|
|
211
|
+
declare enum HttpStatusCode {
|
|
212
|
+
OK = 200,
|
|
213
|
+
BAD_REQUEST = 400,
|
|
214
|
+
UNAUTHORIZED = 401,
|
|
215
|
+
NOT_FOUND = 404,
|
|
216
|
+
TIMEOUT = 408,
|
|
217
|
+
ABORTED = 409,
|
|
218
|
+
INTERNAL_SERVER_ERROR = 500
|
|
113
219
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
220
|
+
declare enum ApiMethod {
|
|
221
|
+
GET = "GET",
|
|
222
|
+
POST = "POST",
|
|
223
|
+
PUT = "PUT",
|
|
224
|
+
DELETE = "DELETE"
|
|
118
225
|
}
|
|
119
226
|
declare enum ApiPath {
|
|
120
227
|
AUTOLOGIN = "/autologin",
|
|
@@ -136,186 +243,118 @@ declare enum ApiPath {
|
|
|
136
243
|
USER = "/user",
|
|
137
244
|
USER_RESET_TEST = "/user/test/reset/:flashcardReviewCompletedCount/:testsUnlocked"
|
|
138
245
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
246
|
+
/**
|
|
247
|
+
* Request payloads
|
|
248
|
+
*/
|
|
249
|
+
interface TestInitRequestBody {
|
|
250
|
+
vocabCheckType: VocabCheckType;
|
|
144
251
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
REQUEST_DELETE_LEXEME_PAIR_FAILED = "Failed to delete lexeme pair",
|
|
150
|
-
REQUEST_SIGN_IN_FAILED = "Failed to sign in",
|
|
151
|
-
REQUEST_SIGN_OUT_FAILED = "Failed to sign out",
|
|
152
|
-
REQUEST_GET_LEXEMES_FAILED = "Failed to get lexemes",
|
|
153
|
-
REQUEST_GET_LEXEMES_FOR_TEST_FAILED = "Failed to get lexemes for test",
|
|
154
|
-
REQUEST_UPDATE_FAMILIARITY_FAILED = "Failed to update familiarity",
|
|
155
|
-
REQUEST_UPDATE_USER_SETTINGS_FAILED = "Failed to update user settings",
|
|
156
|
-
REQUEST_INSERT_OR_UPDATE_LEXEME_PAIR_FAILED = "Failed to insert or update lexeme pair",
|
|
157
|
-
REQUEST_TRANSLATION_FAILED = "Failed to get translation",
|
|
158
|
-
REQUEST_TEST_COMPLETE_FAILED = "Failed to complete test"
|
|
252
|
+
interface TestCompleteRequestBody {
|
|
253
|
+
clientDate: MySQLDate;
|
|
254
|
+
results: ITestResult[];
|
|
255
|
+
vocabCheckType: string;
|
|
159
256
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
NOT_FOUND = 404,
|
|
165
|
-
TIMEOUT = 408,
|
|
166
|
-
ABORTED = 409,
|
|
167
|
-
INTERNAL_SERVER_ERROR = 500
|
|
257
|
+
interface TranslationRequestBody {
|
|
258
|
+
q: string;
|
|
259
|
+
source: Language$1;
|
|
260
|
+
target: Language$1;
|
|
168
261
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
262
|
+
type LexemePairRequestBody = {
|
|
263
|
+
czLexeme: ILexeme;
|
|
264
|
+
enLexeme: ILexeme;
|
|
265
|
+
pairingNotes: string;
|
|
266
|
+
};
|
|
267
|
+
interface UpdateUserRequestBody {
|
|
268
|
+
learningLanguage: Language$1;
|
|
269
|
+
uiLanguage: Language$1;
|
|
173
270
|
}
|
|
174
|
-
interface
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
271
|
+
interface AutologinRequestBody {
|
|
272
|
+
clientDate: MySQLDate;
|
|
273
|
+
}
|
|
274
|
+
interface InsertOrUpdateRequestBody {
|
|
275
|
+
czLexeme: ILexeme;
|
|
276
|
+
enLexeme: ILexeme;
|
|
277
|
+
pairingNotes: string;
|
|
278
|
+
}
|
|
279
|
+
interface SignInRequestBody {
|
|
280
|
+
rememberMe: boolean;
|
|
178
281
|
}
|
|
179
|
-
type DeeplTranslation = {
|
|
180
|
-
detectedSourceLanguage: string;
|
|
181
|
-
translations: Array<{
|
|
182
|
-
translatedText: string;
|
|
183
|
-
}>;
|
|
184
|
-
};
|
|
185
282
|
/**
|
|
186
|
-
*
|
|
283
|
+
* Request Params
|
|
187
284
|
*/
|
|
188
|
-
interface
|
|
189
|
-
|
|
285
|
+
interface SelectAllTranslationsParams {
|
|
286
|
+
sourceText: string;
|
|
287
|
+
sourceLang: string;
|
|
190
288
|
}
|
|
191
|
-
interface
|
|
192
|
-
|
|
289
|
+
interface SelectLexemeCountParams {
|
|
290
|
+
language: Language$1;
|
|
193
291
|
}
|
|
194
|
-
interface
|
|
195
|
-
|
|
292
|
+
interface SelectLexemePairParams {
|
|
293
|
+
czId: string;
|
|
294
|
+
enId: string;
|
|
196
295
|
}
|
|
197
|
-
interface
|
|
198
|
-
|
|
296
|
+
interface SelectLexemePairsByTextParams {
|
|
297
|
+
inputText: string;
|
|
298
|
+
inputLang: string;
|
|
199
299
|
}
|
|
200
|
-
interface
|
|
300
|
+
interface SelectLexemesParams {
|
|
301
|
+
page: string;
|
|
302
|
+
length: string;
|
|
201
303
|
}
|
|
202
|
-
interface
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
name: string;
|
|
206
|
-
email: string;
|
|
207
|
-
phone: string;
|
|
208
|
-
signUpDate: Date;
|
|
209
|
-
lastModified: Date;
|
|
210
|
-
learningLanguage: string;
|
|
211
|
-
flashcardReviewCompletedCount: number;
|
|
212
|
-
currentStreakLength: number;
|
|
213
|
-
currentStreakEnd: MySQLDate | undefined;
|
|
214
|
-
highStreakLength: number;
|
|
215
|
-
highStreakEnd: MySQLDate | undefined;
|
|
216
|
-
testsUnlocked: boolean;
|
|
217
|
-
rewardPoints: number;
|
|
304
|
+
interface SelectTestLexemesParams {
|
|
305
|
+
testType: string;
|
|
306
|
+
testLength: string;
|
|
218
307
|
}
|
|
219
|
-
interface
|
|
220
|
-
|
|
308
|
+
interface UpdateLexemePairFamiliarityParams {
|
|
309
|
+
czId: string;
|
|
310
|
+
enId: string;
|
|
311
|
+
familiarity: string;
|
|
221
312
|
}
|
|
222
|
-
interface
|
|
223
|
-
|
|
224
|
-
|
|
313
|
+
interface DeleteLexemePairRequestParams {
|
|
314
|
+
czId: string;
|
|
315
|
+
enId: string;
|
|
225
316
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
S3_INSERT_CZECH_LEXEME_AND_MAPPING_DUPLICATE_ENGLISH_LEXEME_FOUND_AND_USED = "Insert Czech lexeme and mapping, duplicate English lexeme found and used",
|
|
230
|
-
S4_INSERT_MAPPING_ONLY_DUPLICATE_CZECH_AND_ENGLISH_LEXEMES_FOUND_AND_USED = "Insert mapping only, duplicate Czech and English lexemes found and used",
|
|
231
|
-
S5_NO_INSERT_REQUIRED_DUPLICATE_LEXEMES_AND_PAIRING_FOUND = "No insert required, duplicate lexemes and pairing found",
|
|
232
|
-
S6_NO_UPDATE_REQUIRED_NO_CHANGES_DETECTED = "No update required, no changes detected",
|
|
233
|
-
S7_CZECH_LEXEME_UPDATED = "Scenario 7: Czech lexeme updated",
|
|
234
|
-
S8_CZECH_LEXEME_DELETED_DUPLICATE_CZECH_LEXEME_CAN_BE_USED = "Scenario 8: Czech lexeme deleted, duplicate Czech lexeme can be used can be used",
|
|
235
|
-
S9_CZECH_LEXEME_AND_MAPPING_DELETED_DISCOVERED_LEXEMES_AND_MAPPING_CAN_BE_USED = "Scenario 9: Czech lexeme and mapping deleted, discovered lexemes and mapping can be used",
|
|
236
|
-
S10_MAPPING_UPDATED_TO_USE_NEW_CZECH_LEXEME = "Scenario 10: Mapping updated to use new Czech lexeme",
|
|
237
|
-
S11_MAPPING_UPDATED_TO_USE_DUPLICATE_CZECH_LEXEME = "Scenario 11: Mapping updated to use duplicate Czech lexeme",
|
|
238
|
-
S12_MAPPING_DELETED_DUPLICATE_MAPPING_CAN_BE_USED_WHEN_CZECH_LEXEME_MODIFIED = "Scenario 12: Mapping deleted, duplicate mapping can be used when Czech lexeme modified",
|
|
239
|
-
S13_ENGLISH_LEXEME_UPDATED = "Scenario 13: English lexeme updated",
|
|
240
|
-
S14_ENGLISH_LEXEME_DELETED_DUPLICATE_ENGLISH_LEXEME_CAN_BE_USED = "Scenario 14: English lexeme deleted, duplicate English lexeme can be used",
|
|
241
|
-
S15_ENGLISH_LEXEME_AND_MAPPING_DELETED_DISCOVERED_LEXEMES_AND_MAPPING_CAN_BE_USED = "Scenario 15: English lexeme and mapping deleted, discovered lexemes and mapping can be used",
|
|
242
|
-
S16_MAPPING_UPDATED_TO_USE_NEW_ENGLISH_LEXEME = "Scenario 16: Mapping updated to use new English lexeme",
|
|
243
|
-
S17_MAPPING_UPDATED_TO_USE_DUPLICATE_ENGLISH_LEXEME = "Scenario 17: Mapping updated to use duplicate English lexeme",
|
|
244
|
-
S18_MAPPING_DELETED_DUPLICATE_MAPPING_CAN_BE_USED_WHEN_ENGLISH_LEXEME_MODIFIED = "Scenario 18: Mapping deleted, duplicate mapping can be used when English lexeme modified",
|
|
245
|
-
ERROR = "Error"
|
|
317
|
+
interface ResetTestUserParams {
|
|
318
|
+
flashcardReviewCompletedCount: number;
|
|
319
|
+
testsUnlocked: boolean;
|
|
246
320
|
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* @name convertJSDateObjectToMySQLDateString
|
|
250
|
-
* @description Converts a JavaScript Date object to a MySQL date string
|
|
251
|
-
* @param date
|
|
252
|
-
* @type Date
|
|
253
|
-
* @returns MySQLDate in the format "2021-01-01 07:41:23"
|
|
254
|
-
*/
|
|
255
|
-
declare const convertJSDateObjectToMySQLDateString: (date: Date) => MySQLDate | undefined;
|
|
256
|
-
/**
|
|
257
|
-
* @name convertJSDateStringToMySQLDate
|
|
258
|
-
* @description Converts a JavaScript Date object to a MySQL date string
|
|
259
|
-
* @param date in the format "2021-01-01T07:41:23.000Z"
|
|
260
|
-
* @type string
|
|
261
|
-
* @returns date in the format "2021-01-01 07:41:23"
|
|
262
|
-
* @returns undefined if the input date is invalid
|
|
263
|
-
*/
|
|
264
|
-
declare const convertJSDateStringToMySQLDate: (date: string) => MySQLDate | undefined;
|
|
265
321
|
/**
|
|
266
|
-
*
|
|
267
|
-
* @description Checks if a string representation of date/time is in the format "2021-01-01 07:41:23"
|
|
268
|
-
* @param dateStr
|
|
269
|
-
* @returns boolean
|
|
270
|
-
*/
|
|
271
|
-
declare const isValidMysqlDateString: (dateStr: string) => boolean;
|
|
272
|
-
/**
|
|
273
|
-
* @name isValidJsDateString
|
|
274
|
-
* @description Checks if a string representation of date/time is in the format "2021-01-01T07:41:23.000Z"
|
|
275
|
-
* @param dateStr
|
|
276
|
-
* @returns boolean
|
|
277
|
-
*/
|
|
278
|
-
declare const isValidJsDateString: (dateStr: string) => boolean;
|
|
279
|
-
/**
|
|
280
|
-
* @name isClientDateTooFarFromServerDate
|
|
281
|
-
* @description Checks if the client date is more than one day away from the server date
|
|
282
|
-
* @param clientDateMySQLFormat date in MySQL format
|
|
283
|
-
* @param serverDate date object representation of the current time on the server
|
|
284
|
-
* @returns boolean
|
|
322
|
+
* Response payloads
|
|
285
323
|
*/
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
324
|
+
interface ControllerResponse<T> {
|
|
325
|
+
message: string;
|
|
326
|
+
status: HttpStatusCode;
|
|
327
|
+
data: T;
|
|
328
|
+
}
|
|
329
|
+
type TranslationResponseData = {
|
|
330
|
+
detectedSourceLanguage: string;
|
|
331
|
+
translations: Array<{
|
|
332
|
+
translatedText: string;
|
|
333
|
+
}>;
|
|
334
|
+
};
|
|
335
|
+
interface InsertOrUpdateResponseData {
|
|
336
|
+
scenario: Scenario;
|
|
337
|
+
lexemeIdPair: ILexemeIdPair;
|
|
338
|
+
newMappingInserted?: boolean;
|
|
339
|
+
}
|
|
340
|
+
interface SignInResponseData {
|
|
341
|
+
expiryDate: number;
|
|
342
|
+
user: IUserData;
|
|
343
|
+
}
|
|
344
|
+
interface TestInitResponseData {
|
|
345
|
+
lexemePairs: ILexemePair[];
|
|
346
|
+
vocabCheckType: VocabCheckType;
|
|
347
|
+
}
|
|
348
|
+
interface TestCompleteResponseData {
|
|
349
|
+
user: IUserData;
|
|
350
|
+
testResultIds: number[];
|
|
351
|
+
rewardPointsDelta: number;
|
|
352
|
+
}
|
|
353
|
+
type DeeplTranslation = {
|
|
354
|
+
detectedSourceLanguage: string;
|
|
355
|
+
translations: Array<{
|
|
356
|
+
translatedText: string;
|
|
357
|
+
}>;
|
|
319
358
|
};
|
|
320
359
|
|
|
321
|
-
export { ApiMethod, ApiPath, AppError, type
|
|
360
|
+
export { ApiMethod, ApiPath, AppError, type AutologinRequestBody, type ControllerResponse, type DeeplTranslation, type DeleteLexemePairRequestParams, Familiarity, HttpStatusCode, type ICount, type ILexeme, type ILexemeIdPair, type ILexemePair, type ITestResult, type IUserData, type InsertOrUpdateRequestBody, type InsertOrUpdateResponseData, Language, LearningStage, Lexeme, LexemePair, type LexemePairRequestBody, type LexemePairWithLang, type MySQLDate, Progress, ReminderFrequency, type ResetTestUserParams, type Result, Scenario, type SelectAllTranslationsParams, type SelectLexemeCountParams, type SelectLexemePairParams, type SelectLexemePairsByTextParams, type SelectLexemesParams, type SelectTestLexemesParams, type SignInRequestBody, type SignInResponseData, type TestCompleteRequestBody, type TestCompleteResponseData, type TestInitRequestBody, type TestInitResponseData, type TranslationRequestBody, type TranslationResponseData, type UpdateLexemePairFamiliarityParams, type UpdateUserRequestBody, VocabCheckType, convertJSDateObjectToMySQLDateString, convertJSDateStringToMySQLDate, dateDifferenceInDays, getClientDate, getFormattedDate, isClientDateTooFarFromServerDate, isStringContainingInteger, isThePreviousDay, isTheSameDay, isValidJsDateString, isValidMysqlDateString, parameterReplace };
|