czapp-shared 1.0.7 → 1.0.9

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/dist/index.d.mts CHANGED
@@ -1,11 +1,16 @@
1
1
  /**
2
- * @name convertJSDateObjectToMySQLDateString
3
- * @description Converts a JavaScript Date object to a MySQL date string
2
+ * @name getMysqlDateIgnoreTZ
3
+ * @description Converts a JavaScript Date object to a MySQL date string by ignoring the timezone
4
4
  * @param date
5
5
  * @type Date
6
- * @returns MySQLDate in the format "2021-01-01 07:41:23"
6
+ * @returns MySQLDate in the format "2021-01-01 07:41:23" or undefined if the input date is invalid
7
+ */
8
+ declare const getMysqlDateIgnoreTZ: (date: Date) => MySQLDate | undefined;
9
+ /**
10
+ * @name getMysqlDateAllowingForTZ
11
+ * @param date
7
12
  */
8
- declare const convertJSDateObjectToMySQLDateString: (date: Date) => MySQLDate | undefined;
13
+ declare const getMysqlDateAllowingForTZ: (date: Date) => MySQLDate;
9
14
  /**
10
15
  * @name convertJSDateStringToMySQLDate
11
16
  * @description Converts a JavaScript Date object to a MySQL date string
@@ -46,14 +51,13 @@ declare const isClientDateTooFarFromServerDate: (clientDateMySQLFormat: MySQLDat
46
51
  * @returns number
47
52
  */
48
53
  declare const dateDifferenceInDays: (date1: MySQLDate, date2: MySQLDate) => number;
49
- declare const getClientDate: (date: Date) => string;
50
54
  declare const isThePreviousDay: (date: MySQLDate, referenceDate: MySQLDate) => boolean;
51
55
  declare const isTheSameDay: (date1: MySQLDate, date2: MySQLDate) => boolean;
52
56
  declare const getFormattedDate: (date: Date) => string;
53
57
 
54
58
  declare enum Language {
55
- CZECH = "cz",
56
- ENGLISH = "en",
59
+ CZECH = "CZECH",
60
+ ENGLISH = "ENGLISH",
57
61
  UNKNOWN = "UNKNOWN"
58
62
  }
59
63
  type Result<T> = [T, undefined] | [undefined, Error];
@@ -63,8 +67,8 @@ declare enum Familiarity {
63
67
  UNKNOWN = "UNKNOWN"
64
68
  }
65
69
  declare enum VocabCheckType {
66
- FLASHCARD = "flashcard",
67
- TEST = "test"
70
+ FLASHCARD = "FLASHCARD",
71
+ TEST = "TEST"
68
72
  }
69
73
  declare enum LearningStage {
70
74
  NEW = "NEW",
@@ -72,9 +76,9 @@ declare enum LearningStage {
72
76
  RETIRED = "RETIRED"
73
77
  }
74
78
  declare enum Progress {
75
- WORSE = 0,
76
- NONE = 1,
77
- IMPROVED = 2
79
+ WORSE = "WORSE",
80
+ NONE = "NONE",
81
+ IMPROVED = "IMPROVED"
78
82
  }
79
83
  interface ITestResult {
80
84
  lexemePair: ILexemePair;
@@ -83,9 +87,9 @@ interface ITestResult {
83
87
  }
84
88
  type MySQLDate = `${number}-${number}-${number} ${number}:${number}:${number}`;
85
89
  declare enum ReminderFrequency {
86
- ALWAYS = "always",
87
- DAILY = "daily",
88
- NEVER = "never"
90
+ ALWAYS = "ALWAYS",
91
+ DAILY = "DAILY",
92
+ NEVER = "NEVER"
89
93
  }
90
94
  declare enum AppError {
91
95
  NONE = "No error",
@@ -125,7 +129,7 @@ declare enum Scenario {
125
129
  }
126
130
 
127
131
  interface ILexeme {
128
- id: number | undefined;
132
+ id: number | null;
129
133
  dateAdded: MySQLDate;
130
134
  text: string;
131
135
  userId: string;
@@ -136,9 +140,9 @@ interface ILexemePair {
136
140
  englishLexeme: ILexeme;
137
141
  familiarity: Familiarity;
138
142
  firstKnownSessionDigit: number | null;
139
- lastFlashcardReview: MySQLDate;
143
+ lastFlashcardReview: MySQLDate | null;
140
144
  lastModified: MySQLDate;
141
- lastTested: MySQLDate;
145
+ lastTested: MySQLDate | null;
142
146
  learningStage: LearningStage;
143
147
  notes: string;
144
148
  userId: string;
@@ -152,13 +156,16 @@ type LexemePairWithLang = {
152
156
  englishLexeme: ILexeme;
153
157
  langToFocus: Language;
154
158
  };
159
+ interface ICount {
160
+ count: number;
161
+ }
155
162
 
156
163
  declare class Lexeme implements ILexeme {
157
164
  text: string;
158
- id: number | undefined;
165
+ id: number | null;
159
166
  dateAdded: MySQLDate;
160
167
  userId: string;
161
- constructor();
168
+ constructor(userId: string);
162
169
  }
163
170
  declare class LexemePair implements ILexemePair {
164
171
  czechLexeme: ILexeme;
@@ -172,12 +179,33 @@ declare class LexemePair implements ILexemePair {
172
179
  learningStage: LearningStage;
173
180
  notes: string;
174
181
  userId: string;
175
- constructor(englishLexeme: Lexeme, czechLexeme: Lexeme);
182
+ constructor(userId: string, englishLexeme: Lexeme, czechLexeme: Lexeme);
176
183
  }
177
184
 
178
185
  declare const isStringContainingInteger: (str: any) => boolean;
179
186
  declare const parameterReplace: (path: string, params?: string[]) => string;
180
187
 
188
+ interface IUserData {
189
+ currentStreakEnd: MySQLDate | undefined;
190
+ currentStreakLength: number;
191
+ email: string;
192
+ flashcardReviewCompletedCount: number;
193
+ googleSub: string;
194
+ highStreakEnd: MySQLDate | undefined;
195
+ highStreakLength: number;
196
+ lastModified: MySQLDate;
197
+ lastWordAdded: string;
198
+ learningLanguage: Language;
199
+ lexemePairCount: number;
200
+ name: string;
201
+ phone: string;
202
+ rewardPoints: number;
203
+ signUpDate: MySQLDate;
204
+ testsCompletedCount: number;
205
+ testsUnlocked: boolean;
206
+ uiLanguage: Language;
207
+ }
208
+
181
209
  declare enum HttpStatusCode {
182
210
  OK = 200,
183
211
  BAD_REQUEST = 400,
@@ -216,16 +244,78 @@ declare enum ApiPath {
216
244
  /**
217
245
  * Request payloads
218
246
  */
219
- interface TestCompletePayload {
247
+ interface TestInitRequestBody {
248
+ vocabCheckType: VocabCheckType;
249
+ }
250
+ interface TestCompleteRequestBody {
220
251
  clientDate: MySQLDate;
221
252
  results: ITestResult[];
222
- vocabCheckType: string;
253
+ vocabCheckType: VocabCheckType;
223
254
  }
224
- type LexemePairPayload = {
255
+ interface TranslationRequestBody {
256
+ q: string;
257
+ source: Language;
258
+ target: Language;
259
+ }
260
+ type LexemePairRequestBody = {
225
261
  czLexeme: ILexeme;
226
262
  enLexeme: ILexeme;
227
263
  pairingNotes: string;
228
264
  };
265
+ interface UpdateUserRequestBody {
266
+ learningLanguage: Language;
267
+ uiLanguage: Language;
268
+ }
269
+ interface AutologinRequestBody {
270
+ clientDate: MySQLDate;
271
+ }
272
+ interface InsertOrUpdateRequestBody {
273
+ czLexeme: ILexeme;
274
+ enLexeme: ILexeme;
275
+ pairingNotes: string;
276
+ }
277
+ interface SignInRequestBody {
278
+ rememberMe: boolean;
279
+ }
280
+ /**
281
+ * Request Params
282
+ */
283
+ interface SelectAllTranslationsParams {
284
+ sourceText: string;
285
+ sourceLang: Language;
286
+ }
287
+ interface SelectLexemeCountParams {
288
+ language: Language;
289
+ }
290
+ interface SelectLexemePairParams {
291
+ czId: number;
292
+ enId: number;
293
+ }
294
+ interface SelectLexemePairsByTextParams {
295
+ inputText: string;
296
+ inputLang: Language;
297
+ }
298
+ interface SelectLexemesParams {
299
+ page: number;
300
+ length: number;
301
+ }
302
+ interface SelectTestLexemesParams {
303
+ testType: VocabCheckType;
304
+ testLength: number;
305
+ }
306
+ interface UpdateLexemePairFamiliarityParams {
307
+ czId: number;
308
+ enId: number;
309
+ familiarity: Familiarity;
310
+ }
311
+ interface DeleteLexemePairRequestParams {
312
+ czId: number;
313
+ enId: number;
314
+ }
315
+ interface ResetTestUserParams {
316
+ flashcardReviewCompletedCount: number;
317
+ testsUnlocked: boolean;
318
+ }
229
319
  /**
230
320
  * Response payloads
231
321
  */
@@ -234,41 +324,35 @@ interface ControllerResponse<T> {
234
324
  status: HttpStatusCode;
235
325
  data: T;
236
326
  }
237
- interface TestInitResponseData {
238
- lexemePairs: ILexemePair[];
239
- vocabCheckType: VocabCheckType;
240
- }
327
+ type TranslationResponseData = {
328
+ detectedSourceLanguage: Language;
329
+ translations: Array<{
330
+ translatedText: string;
331
+ }>;
332
+ };
241
333
  interface InsertOrUpdateResponseData {
242
334
  scenario: Scenario;
243
335
  lexemeIdPair: ILexemeIdPair;
244
336
  newMappingInserted?: boolean;
245
337
  }
338
+ interface SignInResponseData {
339
+ expiryDate: number;
340
+ user: IUserData;
341
+ }
342
+ interface TestInitResponseData {
343
+ lexemePairs: ILexemePair[];
344
+ vocabCheckType: VocabCheckType;
345
+ }
346
+ interface TestCompleteResponseData {
347
+ user: IUserData;
348
+ testResultIds: number[];
349
+ rewardPointsDelta: number;
350
+ }
246
351
  type DeeplTranslation = {
247
- detectedSourceLanguage: string;
352
+ detectedSourceLanguage: Language;
248
353
  translations: Array<{
249
354
  translatedText: string;
250
355
  }>;
251
356
  };
252
357
 
253
- interface IUserData {
254
- currentStreakEnd: MySQLDate | undefined;
255
- currentStreakLength: number;
256
- email: string;
257
- flashcardReviewCompletedCount: number;
258
- googleSub: string;
259
- highStreakEnd: MySQLDate | undefined;
260
- highStreakLength: number;
261
- lastModified: MySQLDate;
262
- lastWordAdded: string;
263
- learningLanguage: Language;
264
- lexemePairCount: number;
265
- name: string;
266
- phone: string;
267
- rewardPoints: number;
268
- signUpDate: MySQLDate;
269
- testsCompletedCount: number;
270
- testsUnlocked: boolean;
271
- uiLanguage: Language;
272
- }
273
-
274
- export { ApiMethod, ApiPath, AppError, type ControllerResponse, type DeeplTranslation, Familiarity, HttpStatusCode, type ILexeme, type ILexemeIdPair, type ILexemePair, type ITestResult, type IUserData, type InsertOrUpdateResponseData, Language, LearningStage, Lexeme, LexemePair, type LexemePairPayload, type LexemePairWithLang, type MySQLDate, Progress, ReminderFrequency, type Result, Scenario, type TestCompletePayload, type TestInitResponseData, VocabCheckType, convertJSDateObjectToMySQLDateString, convertJSDateStringToMySQLDate, dateDifferenceInDays, getClientDate, getFormattedDate, isClientDateTooFarFromServerDate, isStringContainingInteger, isThePreviousDay, isTheSameDay, isValidJsDateString, isValidMysqlDateString, parameterReplace };
358
+ 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, convertJSDateStringToMySQLDate, dateDifferenceInDays, getFormattedDate, getMysqlDateAllowingForTZ, getMysqlDateIgnoreTZ, isClientDateTooFarFromServerDate, isStringContainingInteger, isThePreviousDay, isTheSameDay, isValidJsDateString, isValidMysqlDateString, parameterReplace };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,16 @@
1
1
  /**
2
- * @name convertJSDateObjectToMySQLDateString
3
- * @description Converts a JavaScript Date object to a MySQL date string
2
+ * @name getMysqlDateIgnoreTZ
3
+ * @description Converts a JavaScript Date object to a MySQL date string by ignoring the timezone
4
4
  * @param date
5
5
  * @type Date
6
- * @returns MySQLDate in the format "2021-01-01 07:41:23"
6
+ * @returns MySQLDate in the format "2021-01-01 07:41:23" or undefined if the input date is invalid
7
+ */
8
+ declare const getMysqlDateIgnoreTZ: (date: Date) => MySQLDate | undefined;
9
+ /**
10
+ * @name getMysqlDateAllowingForTZ
11
+ * @param date
7
12
  */
8
- declare const convertJSDateObjectToMySQLDateString: (date: Date) => MySQLDate | undefined;
13
+ declare const getMysqlDateAllowingForTZ: (date: Date) => MySQLDate;
9
14
  /**
10
15
  * @name convertJSDateStringToMySQLDate
11
16
  * @description Converts a JavaScript Date object to a MySQL date string
@@ -46,14 +51,13 @@ declare const isClientDateTooFarFromServerDate: (clientDateMySQLFormat: MySQLDat
46
51
  * @returns number
47
52
  */
48
53
  declare const dateDifferenceInDays: (date1: MySQLDate, date2: MySQLDate) => number;
49
- declare const getClientDate: (date: Date) => string;
50
54
  declare const isThePreviousDay: (date: MySQLDate, referenceDate: MySQLDate) => boolean;
51
55
  declare const isTheSameDay: (date1: MySQLDate, date2: MySQLDate) => boolean;
52
56
  declare const getFormattedDate: (date: Date) => string;
53
57
 
54
58
  declare enum Language {
55
- CZECH = "cz",
56
- ENGLISH = "en",
59
+ CZECH = "CZECH",
60
+ ENGLISH = "ENGLISH",
57
61
  UNKNOWN = "UNKNOWN"
58
62
  }
59
63
  type Result<T> = [T, undefined] | [undefined, Error];
@@ -63,8 +67,8 @@ declare enum Familiarity {
63
67
  UNKNOWN = "UNKNOWN"
64
68
  }
65
69
  declare enum VocabCheckType {
66
- FLASHCARD = "flashcard",
67
- TEST = "test"
70
+ FLASHCARD = "FLASHCARD",
71
+ TEST = "TEST"
68
72
  }
69
73
  declare enum LearningStage {
70
74
  NEW = "NEW",
@@ -72,9 +76,9 @@ declare enum LearningStage {
72
76
  RETIRED = "RETIRED"
73
77
  }
74
78
  declare enum Progress {
75
- WORSE = 0,
76
- NONE = 1,
77
- IMPROVED = 2
79
+ WORSE = "WORSE",
80
+ NONE = "NONE",
81
+ IMPROVED = "IMPROVED"
78
82
  }
79
83
  interface ITestResult {
80
84
  lexemePair: ILexemePair;
@@ -83,9 +87,9 @@ interface ITestResult {
83
87
  }
84
88
  type MySQLDate = `${number}-${number}-${number} ${number}:${number}:${number}`;
85
89
  declare enum ReminderFrequency {
86
- ALWAYS = "always",
87
- DAILY = "daily",
88
- NEVER = "never"
90
+ ALWAYS = "ALWAYS",
91
+ DAILY = "DAILY",
92
+ NEVER = "NEVER"
89
93
  }
90
94
  declare enum AppError {
91
95
  NONE = "No error",
@@ -125,7 +129,7 @@ declare enum Scenario {
125
129
  }
126
130
 
127
131
  interface ILexeme {
128
- id: number | undefined;
132
+ id: number | null;
129
133
  dateAdded: MySQLDate;
130
134
  text: string;
131
135
  userId: string;
@@ -136,9 +140,9 @@ interface ILexemePair {
136
140
  englishLexeme: ILexeme;
137
141
  familiarity: Familiarity;
138
142
  firstKnownSessionDigit: number | null;
139
- lastFlashcardReview: MySQLDate;
143
+ lastFlashcardReview: MySQLDate | null;
140
144
  lastModified: MySQLDate;
141
- lastTested: MySQLDate;
145
+ lastTested: MySQLDate | null;
142
146
  learningStage: LearningStage;
143
147
  notes: string;
144
148
  userId: string;
@@ -152,13 +156,16 @@ type LexemePairWithLang = {
152
156
  englishLexeme: ILexeme;
153
157
  langToFocus: Language;
154
158
  };
159
+ interface ICount {
160
+ count: number;
161
+ }
155
162
 
156
163
  declare class Lexeme implements ILexeme {
157
164
  text: string;
158
- id: number | undefined;
165
+ id: number | null;
159
166
  dateAdded: MySQLDate;
160
167
  userId: string;
161
- constructor();
168
+ constructor(userId: string);
162
169
  }
163
170
  declare class LexemePair implements ILexemePair {
164
171
  czechLexeme: ILexeme;
@@ -172,12 +179,33 @@ declare class LexemePair implements ILexemePair {
172
179
  learningStage: LearningStage;
173
180
  notes: string;
174
181
  userId: string;
175
- constructor(englishLexeme: Lexeme, czechLexeme: Lexeme);
182
+ constructor(userId: string, englishLexeme: Lexeme, czechLexeme: Lexeme);
176
183
  }
177
184
 
178
185
  declare const isStringContainingInteger: (str: any) => boolean;
179
186
  declare const parameterReplace: (path: string, params?: string[]) => string;
180
187
 
188
+ interface IUserData {
189
+ currentStreakEnd: MySQLDate | undefined;
190
+ currentStreakLength: number;
191
+ email: string;
192
+ flashcardReviewCompletedCount: number;
193
+ googleSub: string;
194
+ highStreakEnd: MySQLDate | undefined;
195
+ highStreakLength: number;
196
+ lastModified: MySQLDate;
197
+ lastWordAdded: string;
198
+ learningLanguage: Language;
199
+ lexemePairCount: number;
200
+ name: string;
201
+ phone: string;
202
+ rewardPoints: number;
203
+ signUpDate: MySQLDate;
204
+ testsCompletedCount: number;
205
+ testsUnlocked: boolean;
206
+ uiLanguage: Language;
207
+ }
208
+
181
209
  declare enum HttpStatusCode {
182
210
  OK = 200,
183
211
  BAD_REQUEST = 400,
@@ -216,16 +244,78 @@ declare enum ApiPath {
216
244
  /**
217
245
  * Request payloads
218
246
  */
219
- interface TestCompletePayload {
247
+ interface TestInitRequestBody {
248
+ vocabCheckType: VocabCheckType;
249
+ }
250
+ interface TestCompleteRequestBody {
220
251
  clientDate: MySQLDate;
221
252
  results: ITestResult[];
222
- vocabCheckType: string;
253
+ vocabCheckType: VocabCheckType;
223
254
  }
224
- type LexemePairPayload = {
255
+ interface TranslationRequestBody {
256
+ q: string;
257
+ source: Language;
258
+ target: Language;
259
+ }
260
+ type LexemePairRequestBody = {
225
261
  czLexeme: ILexeme;
226
262
  enLexeme: ILexeme;
227
263
  pairingNotes: string;
228
264
  };
265
+ interface UpdateUserRequestBody {
266
+ learningLanguage: Language;
267
+ uiLanguage: Language;
268
+ }
269
+ interface AutologinRequestBody {
270
+ clientDate: MySQLDate;
271
+ }
272
+ interface InsertOrUpdateRequestBody {
273
+ czLexeme: ILexeme;
274
+ enLexeme: ILexeme;
275
+ pairingNotes: string;
276
+ }
277
+ interface SignInRequestBody {
278
+ rememberMe: boolean;
279
+ }
280
+ /**
281
+ * Request Params
282
+ */
283
+ interface SelectAllTranslationsParams {
284
+ sourceText: string;
285
+ sourceLang: Language;
286
+ }
287
+ interface SelectLexemeCountParams {
288
+ language: Language;
289
+ }
290
+ interface SelectLexemePairParams {
291
+ czId: number;
292
+ enId: number;
293
+ }
294
+ interface SelectLexemePairsByTextParams {
295
+ inputText: string;
296
+ inputLang: Language;
297
+ }
298
+ interface SelectLexemesParams {
299
+ page: number;
300
+ length: number;
301
+ }
302
+ interface SelectTestLexemesParams {
303
+ testType: VocabCheckType;
304
+ testLength: number;
305
+ }
306
+ interface UpdateLexemePairFamiliarityParams {
307
+ czId: number;
308
+ enId: number;
309
+ familiarity: Familiarity;
310
+ }
311
+ interface DeleteLexemePairRequestParams {
312
+ czId: number;
313
+ enId: number;
314
+ }
315
+ interface ResetTestUserParams {
316
+ flashcardReviewCompletedCount: number;
317
+ testsUnlocked: boolean;
318
+ }
229
319
  /**
230
320
  * Response payloads
231
321
  */
@@ -234,41 +324,35 @@ interface ControllerResponse<T> {
234
324
  status: HttpStatusCode;
235
325
  data: T;
236
326
  }
237
- interface TestInitResponseData {
238
- lexemePairs: ILexemePair[];
239
- vocabCheckType: VocabCheckType;
240
- }
327
+ type TranslationResponseData = {
328
+ detectedSourceLanguage: Language;
329
+ translations: Array<{
330
+ translatedText: string;
331
+ }>;
332
+ };
241
333
  interface InsertOrUpdateResponseData {
242
334
  scenario: Scenario;
243
335
  lexemeIdPair: ILexemeIdPair;
244
336
  newMappingInserted?: boolean;
245
337
  }
338
+ interface SignInResponseData {
339
+ expiryDate: number;
340
+ user: IUserData;
341
+ }
342
+ interface TestInitResponseData {
343
+ lexemePairs: ILexemePair[];
344
+ vocabCheckType: VocabCheckType;
345
+ }
346
+ interface TestCompleteResponseData {
347
+ user: IUserData;
348
+ testResultIds: number[];
349
+ rewardPointsDelta: number;
350
+ }
246
351
  type DeeplTranslation = {
247
- detectedSourceLanguage: string;
352
+ detectedSourceLanguage: Language;
248
353
  translations: Array<{
249
354
  translatedText: string;
250
355
  }>;
251
356
  };
252
357
 
253
- interface IUserData {
254
- currentStreakEnd: MySQLDate | undefined;
255
- currentStreakLength: number;
256
- email: string;
257
- flashcardReviewCompletedCount: number;
258
- googleSub: string;
259
- highStreakEnd: MySQLDate | undefined;
260
- highStreakLength: number;
261
- lastModified: MySQLDate;
262
- lastWordAdded: string;
263
- learningLanguage: Language;
264
- lexemePairCount: number;
265
- name: string;
266
- phone: string;
267
- rewardPoints: number;
268
- signUpDate: MySQLDate;
269
- testsCompletedCount: number;
270
- testsUnlocked: boolean;
271
- uiLanguage: Language;
272
- }
273
-
274
- export { ApiMethod, ApiPath, AppError, type ControllerResponse, type DeeplTranslation, Familiarity, HttpStatusCode, type ILexeme, type ILexemeIdPair, type ILexemePair, type ITestResult, type IUserData, type InsertOrUpdateResponseData, Language, LearningStage, Lexeme, LexemePair, type LexemePairPayload, type LexemePairWithLang, type MySQLDate, Progress, ReminderFrequency, type Result, Scenario, type TestCompletePayload, type TestInitResponseData, VocabCheckType, convertJSDateObjectToMySQLDateString, convertJSDateStringToMySQLDate, dateDifferenceInDays, getClientDate, getFormattedDate, isClientDateTooFarFromServerDate, isStringContainingInteger, isThePreviousDay, isTheSameDay, isValidJsDateString, isValidMysqlDateString, parameterReplace };
358
+ 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, convertJSDateStringToMySQLDate, dateDifferenceInDays, getFormattedDate, getMysqlDateAllowingForTZ, getMysqlDateIgnoreTZ, isClientDateTooFarFromServerDate, isStringContainingInteger, isThePreviousDay, isTheSameDay, isValidJsDateString, isValidMysqlDateString, parameterReplace };
package/dist/index.js CHANGED
@@ -32,11 +32,11 @@ __export(src_exports, {
32
32
  ReminderFrequency: () => ReminderFrequency,
33
33
  Scenario: () => Scenario,
34
34
  VocabCheckType: () => VocabCheckType,
35
- convertJSDateObjectToMySQLDateString: () => convertJSDateObjectToMySQLDateString,
36
35
  convertJSDateStringToMySQLDate: () => convertJSDateStringToMySQLDate,
37
36
  dateDifferenceInDays: () => dateDifferenceInDays,
38
- getClientDate: () => getClientDate,
39
37
  getFormattedDate: () => getFormattedDate,
38
+ getMysqlDateAllowingForTZ: () => getMysqlDateAllowingForTZ,
39
+ getMysqlDateIgnoreTZ: () => getMysqlDateIgnoreTZ,
40
40
  isClientDateTooFarFromServerDate: () => isClientDateTooFarFromServerDate,
41
41
  isStringContainingInteger: () => isStringContainingInteger,
42
42
  isThePreviousDay: () => isThePreviousDay,
@@ -48,7 +48,7 @@ __export(src_exports, {
48
48
  module.exports = __toCommonJS(src_exports);
49
49
 
50
50
  // src/concrete/date.ts
51
- var convertJSDateObjectToMySQLDateString = (date) => {
51
+ var getMysqlDateIgnoreTZ = (date) => {
52
52
  let dateStr;
53
53
  try {
54
54
  dateStr = date.toISOString().slice(0, 19).replace("T", " ");
@@ -61,6 +61,12 @@ var convertJSDateObjectToMySQLDateString = (date) => {
61
61
  return dateStr;
62
62
  }
63
63
  };
64
+ var getMysqlDateAllowingForTZ = (date) => {
65
+ const zeroPad = (num) => {
66
+ return num < 10 ? `0${num}` : num.toString();
67
+ };
68
+ return `${date.getFullYear()}-${zeroPad(date.getMonth() + 1)}-${zeroPad(date.getDate())} ${zeroPad(date.getHours())}:${zeroPad(date.getMinutes())}:${zeroPad(date.getSeconds())}`;
69
+ };
64
70
  var convertJSDateStringToMySQLDate = (date) => {
65
71
  let dateStr;
66
72
  try {
@@ -78,7 +84,7 @@ var isValidJsDateString = (dateStr) => {
78
84
  return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/.test(dateStr);
79
85
  };
80
86
  var isClientDateTooFarFromServerDate = (clientDateMySQLFormat, serverDate) => {
81
- const serverDateMysqlFormat = convertJSDateObjectToMySQLDateString(serverDate);
87
+ const serverDateMysqlFormat = getMysqlDateIgnoreTZ(serverDate);
82
88
  if (!serverDateMysqlFormat) return true;
83
89
  return Math.abs(dateDifferenceInDays(clientDateMySQLFormat, serverDateMysqlFormat)) > 1;
84
90
  };
@@ -90,12 +96,6 @@ var dateDifferenceInDays = (date1, date2) => {
90
96
  const difference = dateObj_2.getTime() - dateObj_1.getTime();
91
97
  return difference / (1e3 * 3600 * 24);
92
98
  };
93
- var getClientDate = (date) => {
94
- return `${date.getFullYear()}-${zeroPad(date.getMonth() + 1)}-${zeroPad(date.getDate())} ${zeroPad(date.getHours())}:${zeroPad(date.getMinutes())}:${zeroPad(date.getSeconds())}`;
95
- };
96
- var zeroPad = (num) => {
97
- return num < 10 ? `0${num}` : num.toString();
98
- };
99
99
  var isThePreviousDay = (date, referenceDate) => {
100
100
  const previousDay = new Date(referenceDate);
101
101
  previousDay.setDate(new Date(referenceDate).getDate() - 1);
@@ -113,8 +113,8 @@ var getFormattedDate = (date) => {
113
113
 
114
114
  // src/design/types.ts
115
115
  var Language = /* @__PURE__ */ ((Language2) => {
116
- Language2["CZECH"] = "cz";
117
- Language2["ENGLISH"] = "en";
116
+ Language2["CZECH"] = "CZECH";
117
+ Language2["ENGLISH"] = "ENGLISH";
118
118
  Language2["UNKNOWN"] = "UNKNOWN";
119
119
  return Language2;
120
120
  })(Language || {});
@@ -125,8 +125,8 @@ var Familiarity = /* @__PURE__ */ ((Familiarity2) => {
125
125
  return Familiarity2;
126
126
  })(Familiarity || {});
127
127
  var VocabCheckType = /* @__PURE__ */ ((VocabCheckType2) => {
128
- VocabCheckType2["FLASHCARD"] = "flashcard";
129
- VocabCheckType2["TEST"] = "test";
128
+ VocabCheckType2["FLASHCARD"] = "FLASHCARD";
129
+ VocabCheckType2["TEST"] = "TEST";
130
130
  return VocabCheckType2;
131
131
  })(VocabCheckType || {});
132
132
  var LearningStage = /* @__PURE__ */ ((LearningStage2) => {
@@ -136,15 +136,15 @@ var LearningStage = /* @__PURE__ */ ((LearningStage2) => {
136
136
  return LearningStage2;
137
137
  })(LearningStage || {});
138
138
  var Progress = /* @__PURE__ */ ((Progress2) => {
139
- Progress2[Progress2["WORSE"] = 0] = "WORSE";
140
- Progress2[Progress2["NONE"] = 1] = "NONE";
141
- Progress2[Progress2["IMPROVED"] = 2] = "IMPROVED";
139
+ Progress2["WORSE"] = "WORSE";
140
+ Progress2["NONE"] = "NONE";
141
+ Progress2["IMPROVED"] = "IMPROVED";
142
142
  return Progress2;
143
143
  })(Progress || {});
144
144
  var ReminderFrequency = /* @__PURE__ */ ((ReminderFrequency2) => {
145
- ReminderFrequency2["ALWAYS"] = "always";
146
- ReminderFrequency2["DAILY"] = "daily";
147
- ReminderFrequency2["NEVER"] = "never";
145
+ ReminderFrequency2["ALWAYS"] = "ALWAYS";
146
+ ReminderFrequency2["DAILY"] = "DAILY";
147
+ ReminderFrequency2["NEVER"] = "NEVER";
148
148
  return ReminderFrequency2;
149
149
  })(ReminderFrequency || {});
150
150
  var AppError = /* @__PURE__ */ ((AppError2) => {
@@ -188,19 +188,21 @@ var Scenario = /* @__PURE__ */ ((Scenario2) => {
188
188
 
189
189
  // src/concrete/lexeme.ts
190
190
  var Lexeme = class {
191
- constructor() {
191
+ constructor(userId) {
192
192
  this.text = "";
193
- this.id = void 0;
193
+ this.id = null;
194
194
  this.userId = "";
195
- this.dateAdded = convertJSDateObjectToMySQLDateString(/* @__PURE__ */ new Date());
195
+ this.userId = userId;
196
+ this.dateAdded = getMysqlDateIgnoreTZ(/* @__PURE__ */ new Date());
196
197
  }
197
198
  };
198
199
  var LexemePair = class {
199
- constructor(englishLexeme, czechLexeme) {
200
+ constructor(userId, englishLexeme, czechLexeme) {
200
201
  this.familiarity = "UNKNOWN" /* UNKNOWN */;
201
202
  this.learningStage = "NEW" /* NEW */;
202
203
  this.notes = "";
203
204
  this.userId = "";
205
+ this.userId = userId;
204
206
  this.czechLexeme = czechLexeme;
205
207
  this.englishLexeme = englishLexeme;
206
208
  }
@@ -270,11 +272,11 @@ var ApiPath = /* @__PURE__ */ ((ApiPath2) => {
270
272
  ReminderFrequency,
271
273
  Scenario,
272
274
  VocabCheckType,
273
- convertJSDateObjectToMySQLDateString,
274
275
  convertJSDateStringToMySQLDate,
275
276
  dateDifferenceInDays,
276
- getClientDate,
277
277
  getFormattedDate,
278
+ getMysqlDateAllowingForTZ,
279
+ getMysqlDateIgnoreTZ,
278
280
  isClientDateTooFarFromServerDate,
279
281
  isStringContainingInteger,
280
282
  isThePreviousDay,
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/concrete/date.ts
2
- var convertJSDateObjectToMySQLDateString = (date) => {
2
+ var getMysqlDateIgnoreTZ = (date) => {
3
3
  let dateStr;
4
4
  try {
5
5
  dateStr = date.toISOString().slice(0, 19).replace("T", " ");
@@ -12,6 +12,12 @@ var convertJSDateObjectToMySQLDateString = (date) => {
12
12
  return dateStr;
13
13
  }
14
14
  };
15
+ var getMysqlDateAllowingForTZ = (date) => {
16
+ const zeroPad = (num) => {
17
+ return num < 10 ? `0${num}` : num.toString();
18
+ };
19
+ return `${date.getFullYear()}-${zeroPad(date.getMonth() + 1)}-${zeroPad(date.getDate())} ${zeroPad(date.getHours())}:${zeroPad(date.getMinutes())}:${zeroPad(date.getSeconds())}`;
20
+ };
15
21
  var convertJSDateStringToMySQLDate = (date) => {
16
22
  let dateStr;
17
23
  try {
@@ -29,7 +35,7 @@ var isValidJsDateString = (dateStr) => {
29
35
  return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/.test(dateStr);
30
36
  };
31
37
  var isClientDateTooFarFromServerDate = (clientDateMySQLFormat, serverDate) => {
32
- const serverDateMysqlFormat = convertJSDateObjectToMySQLDateString(serverDate);
38
+ const serverDateMysqlFormat = getMysqlDateIgnoreTZ(serverDate);
33
39
  if (!serverDateMysqlFormat) return true;
34
40
  return Math.abs(dateDifferenceInDays(clientDateMySQLFormat, serverDateMysqlFormat)) > 1;
35
41
  };
@@ -41,12 +47,6 @@ var dateDifferenceInDays = (date1, date2) => {
41
47
  const difference = dateObj_2.getTime() - dateObj_1.getTime();
42
48
  return difference / (1e3 * 3600 * 24);
43
49
  };
44
- var getClientDate = (date) => {
45
- return `${date.getFullYear()}-${zeroPad(date.getMonth() + 1)}-${zeroPad(date.getDate())} ${zeroPad(date.getHours())}:${zeroPad(date.getMinutes())}:${zeroPad(date.getSeconds())}`;
46
- };
47
- var zeroPad = (num) => {
48
- return num < 10 ? `0${num}` : num.toString();
49
- };
50
50
  var isThePreviousDay = (date, referenceDate) => {
51
51
  const previousDay = new Date(referenceDate);
52
52
  previousDay.setDate(new Date(referenceDate).getDate() - 1);
@@ -64,8 +64,8 @@ var getFormattedDate = (date) => {
64
64
 
65
65
  // src/design/types.ts
66
66
  var Language = /* @__PURE__ */ ((Language2) => {
67
- Language2["CZECH"] = "cz";
68
- Language2["ENGLISH"] = "en";
67
+ Language2["CZECH"] = "CZECH";
68
+ Language2["ENGLISH"] = "ENGLISH";
69
69
  Language2["UNKNOWN"] = "UNKNOWN";
70
70
  return Language2;
71
71
  })(Language || {});
@@ -76,8 +76,8 @@ var Familiarity = /* @__PURE__ */ ((Familiarity2) => {
76
76
  return Familiarity2;
77
77
  })(Familiarity || {});
78
78
  var VocabCheckType = /* @__PURE__ */ ((VocabCheckType2) => {
79
- VocabCheckType2["FLASHCARD"] = "flashcard";
80
- VocabCheckType2["TEST"] = "test";
79
+ VocabCheckType2["FLASHCARD"] = "FLASHCARD";
80
+ VocabCheckType2["TEST"] = "TEST";
81
81
  return VocabCheckType2;
82
82
  })(VocabCheckType || {});
83
83
  var LearningStage = /* @__PURE__ */ ((LearningStage2) => {
@@ -87,15 +87,15 @@ var LearningStage = /* @__PURE__ */ ((LearningStage2) => {
87
87
  return LearningStage2;
88
88
  })(LearningStage || {});
89
89
  var Progress = /* @__PURE__ */ ((Progress2) => {
90
- Progress2[Progress2["WORSE"] = 0] = "WORSE";
91
- Progress2[Progress2["NONE"] = 1] = "NONE";
92
- Progress2[Progress2["IMPROVED"] = 2] = "IMPROVED";
90
+ Progress2["WORSE"] = "WORSE";
91
+ Progress2["NONE"] = "NONE";
92
+ Progress2["IMPROVED"] = "IMPROVED";
93
93
  return Progress2;
94
94
  })(Progress || {});
95
95
  var ReminderFrequency = /* @__PURE__ */ ((ReminderFrequency2) => {
96
- ReminderFrequency2["ALWAYS"] = "always";
97
- ReminderFrequency2["DAILY"] = "daily";
98
- ReminderFrequency2["NEVER"] = "never";
96
+ ReminderFrequency2["ALWAYS"] = "ALWAYS";
97
+ ReminderFrequency2["DAILY"] = "DAILY";
98
+ ReminderFrequency2["NEVER"] = "NEVER";
99
99
  return ReminderFrequency2;
100
100
  })(ReminderFrequency || {});
101
101
  var AppError = /* @__PURE__ */ ((AppError2) => {
@@ -139,19 +139,21 @@ var Scenario = /* @__PURE__ */ ((Scenario2) => {
139
139
 
140
140
  // src/concrete/lexeme.ts
141
141
  var Lexeme = class {
142
- constructor() {
142
+ constructor(userId) {
143
143
  this.text = "";
144
- this.id = void 0;
144
+ this.id = null;
145
145
  this.userId = "";
146
- this.dateAdded = convertJSDateObjectToMySQLDateString(/* @__PURE__ */ new Date());
146
+ this.userId = userId;
147
+ this.dateAdded = getMysqlDateIgnoreTZ(/* @__PURE__ */ new Date());
147
148
  }
148
149
  };
149
150
  var LexemePair = class {
150
- constructor(englishLexeme, czechLexeme) {
151
+ constructor(userId, englishLexeme, czechLexeme) {
151
152
  this.familiarity = "UNKNOWN" /* UNKNOWN */;
152
153
  this.learningStage = "NEW" /* NEW */;
153
154
  this.notes = "";
154
155
  this.userId = "";
156
+ this.userId = userId;
155
157
  this.czechLexeme = czechLexeme;
156
158
  this.englishLexeme = englishLexeme;
157
159
  }
@@ -220,11 +222,11 @@ export {
220
222
  ReminderFrequency,
221
223
  Scenario,
222
224
  VocabCheckType,
223
- convertJSDateObjectToMySQLDateString,
224
225
  convertJSDateStringToMySQLDate,
225
226
  dateDifferenceInDays,
226
- getClientDate,
227
227
  getFormattedDate,
228
+ getMysqlDateAllowingForTZ,
229
+ getMysqlDateIgnoreTZ,
228
230
  isClientDateTooFarFromServerDate,
229
231
  isStringContainingInteger,
230
232
  isThePreviousDay,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "czapp-shared",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "This is a shared library for Czapp projects. It contains common code that is used across multiple projects.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,14 +1,14 @@
1
1
  import { MySQLDate } from '../index';
2
2
 
3
3
  /**
4
- * @name convertJSDateObjectToMySQLDateString
5
- * @description Converts a JavaScript Date object to a MySQL date string
4
+ * @name getMysqlDateIgnoreTZ
5
+ * @description Converts a JavaScript Date object to a MySQL date string by ignoring the timezone
6
6
  * @param date
7
7
  * @type Date
8
- * @returns MySQLDate in the format "2021-01-01 07:41:23"
8
+ * @returns MySQLDate in the format "2021-01-01 07:41:23" or undefined if the input date is invalid
9
9
  */
10
10
 
11
- export const convertJSDateObjectToMySQLDateString = (date: Date): MySQLDate | undefined => {
11
+ export const getMysqlDateIgnoreTZ = (date: Date): MySQLDate | undefined => {
12
12
  let dateStr: string;
13
13
  try {
14
14
  dateStr = date.toISOString().slice(0, 19).replace('T', ' ');
@@ -22,6 +22,20 @@ export const convertJSDateObjectToMySQLDateString = (date: Date): MySQLDate | un
22
22
  }
23
23
  }
24
24
 
25
+ /**
26
+ * @name getMysqlDateAllowingForTZ
27
+ * @param date
28
+ */
29
+ export const getMysqlDateAllowingForTZ = (date: Date): MySQLDate => {
30
+ const zeroPad = (num: number): string => {
31
+ return num < 10 ? `0${num}` : num.toString();
32
+ }
33
+ return `${date.getFullYear()}-${zeroPad(date.getMonth() + 1)}-${zeroPad(date.getDate())} ${zeroPad(date.getHours())}:${zeroPad(date.getMinutes())}:${zeroPad(date.getSeconds())}` as MySQLDate;
34
+ }
35
+
36
+
37
+
38
+
25
39
  /**
26
40
  * @name convertJSDateStringToMySQLDate
27
41
  * @description Converts a JavaScript Date object to a MySQL date string
@@ -69,7 +83,7 @@ export const isValidJsDateString = (dateStr: string): boolean => {
69
83
  * @returns boolean
70
84
  */
71
85
  export const isClientDateTooFarFromServerDate = (clientDateMySQLFormat: MySQLDate, serverDate: Date): boolean => {
72
- const serverDateMysqlFormat = convertJSDateObjectToMySQLDateString(serverDate);
86
+ const serverDateMysqlFormat = getMysqlDateIgnoreTZ(serverDate);
73
87
  if (!serverDateMysqlFormat) return true;
74
88
  return Math.abs(dateDifferenceInDays(clientDateMySQLFormat, serverDateMysqlFormat)) > 1;
75
89
  }
@@ -91,14 +105,6 @@ export const dateDifferenceInDays = (date1: MySQLDate, date2: MySQLDate): number
91
105
  return difference / (1000 * 3600 * 24);
92
106
  }
93
107
 
94
- export const getClientDate = (date: Date): string => {
95
- return `${date.getFullYear()}-${zeroPad(date.getMonth() + 1)}-${zeroPad(date.getDate())} ${zeroPad(date.getHours())}:${zeroPad(date.getMinutes())}:${zeroPad(date.getSeconds())}`;
96
- }
97
-
98
- const zeroPad = (num: number): string => {
99
- return num < 10 ? `0${num}` : num.toString();
100
- }
101
-
102
108
  export const isThePreviousDay = (date: MySQLDate, referenceDate: MySQLDate): boolean => {
103
109
  const previousDay = new Date(referenceDate);
104
110
  previousDay.setDate(new Date(referenceDate).getDate() - 1);
@@ -1,14 +1,15 @@
1
1
  import { ILexeme, ILexemePair } from '../design/lexemes';
2
2
  import { Familiarity, LearningStage, MySQLDate } from '../design/types';
3
- import { convertJSDateObjectToMySQLDateString } from './date';
3
+ import { getMysqlDateIgnoreTZ } from './date';
4
4
 
5
5
  export class Lexeme implements ILexeme {
6
6
  text: string = '';
7
- id: number | undefined = undefined;
7
+ id: number | null = null;
8
8
  dateAdded: MySQLDate;
9
9
  userId: string = "";
10
- constructor() {
11
- this.dateAdded = convertJSDateObjectToMySQLDateString(new Date());
10
+ constructor(userId: string) {
11
+ this.userId = userId;
12
+ this.dateAdded = getMysqlDateIgnoreTZ(new Date());
12
13
  }
13
14
  }
14
15
 
@@ -25,7 +26,8 @@ export class LexemePair implements ILexemePair {
25
26
  notes: string = "";
26
27
  userId: string = "";
27
28
 
28
- constructor (englishLexeme: Lexeme, czechLexeme: Lexeme) {
29
+ constructor (userId:string, englishLexeme: Lexeme, czechLexeme: Lexeme) {
30
+ this.userId = userId;
29
31
  this.czechLexeme = czechLexeme;
30
32
  this.englishLexeme = englishLexeme;
31
33
  }
package/src/design/api.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ILexeme, ILexemeIdPair, ILexemePair } from './lexemes';
2
- import { ITestResult, MySQLDate, Scenario, VocabCheckType } from './types';
2
+ import { Familiarity, ITestResult, Language, MySQLDate, Scenario, VocabCheckType } from './types';
3
+ import { IUserData } from './user';
3
4
 
4
5
  export enum HttpStatusCode {
5
6
  OK = 200,
@@ -43,18 +44,81 @@ export enum ApiPath {
43
44
  /**
44
45
  * Request payloads
45
46
  */
46
-
47
- export interface TestCompletePayload {
47
+ export interface TestInitRequestBody {
48
+ vocabCheckType: VocabCheckType
49
+ }
50
+ export interface TestCompleteRequestBody {
48
51
  clientDate: MySQLDate
49
52
  results: ITestResult[]
50
- vocabCheckType: string
53
+ vocabCheckType: VocabCheckType
51
54
  }
52
-
53
- export type LexemePairPayload = {
55
+ export interface TranslationRequestBody {
56
+ q: string;
57
+ source: Language;
58
+ target: Language;
59
+ }
60
+ export type LexemePairRequestBody = {
54
61
  czLexeme: ILexeme
55
62
  enLexeme: ILexeme;
56
63
  pairingNotes: string;
57
64
  }
65
+ export interface UpdateUserRequestBody {
66
+ learningLanguage: Language;
67
+ uiLanguage: Language;
68
+ }
69
+ export interface AutologinRequestBody {
70
+ clientDate: MySQLDate;
71
+ }
72
+ export interface InsertOrUpdateRequestBody {
73
+ czLexeme: ILexeme;
74
+ enLexeme: ILexeme;
75
+ pairingNotes: string;
76
+ }
77
+ export interface SignInRequestBody {
78
+ rememberMe: boolean;
79
+ }
80
+
81
+ /**
82
+ * Request Params
83
+ */
84
+ export interface SelectAllTranslationsParams {
85
+ sourceText: string;
86
+ sourceLang: Language;
87
+ }
88
+ export interface SelectLexemeCountParams {
89
+ language: Language;
90
+ }
91
+ export interface SelectLexemePairParams {
92
+ czId: number;
93
+ enId: number;
94
+ }
95
+ export interface SelectLexemePairsByTextParams {
96
+ inputText: string;
97
+ inputLang: Language;
98
+ }
99
+ export interface SelectLexemesParams {
100
+ page: number;
101
+ length: number;
102
+ }
103
+ export interface SelectTestLexemesParams {
104
+ testType: VocabCheckType;
105
+ testLength: number;
106
+ }
107
+ export interface UpdateLexemePairFamiliarityParams {
108
+ czId: number;
109
+ enId: number;
110
+ familiarity: Familiarity;
111
+ }
112
+ export interface DeleteLexemePairRequestParams {
113
+ czId: number;
114
+ enId: number;
115
+ }
116
+ export interface ResetTestUserParams {
117
+ flashcardReviewCompletedCount: number;
118
+ testsUnlocked: boolean;
119
+ }
120
+
121
+
58
122
 
59
123
  /**
60
124
  * Response payloads
@@ -69,21 +133,34 @@ export interface ControllerResponse<T> {
69
133
  }
70
134
 
71
135
  // Response Data
72
-
73
- export interface TestInitResponseData {
74
- lexemePairs: ILexemePair[];
75
- vocabCheckType: VocabCheckType;
136
+ export type TranslationResponseData = {
137
+ detectedSourceLanguage: Language,
138
+ translations: Array<{
139
+ translatedText: string
140
+ }>
76
141
  }
77
-
78
142
  export interface InsertOrUpdateResponseData {
79
143
  scenario: Scenario,
80
144
  lexemeIdPair: ILexemeIdPair,
81
145
  newMappingInserted?: boolean
82
146
  }
147
+ export interface SignInResponseData {
148
+ expiryDate: number;
149
+ user: IUserData;
150
+ }
151
+ export interface TestInitResponseData {
152
+ lexemePairs: ILexemePair[];
153
+ vocabCheckType: VocabCheckType;
154
+ }
155
+ export interface TestCompleteResponseData {
156
+ user: IUserData;
157
+ testResultIds: number[];
158
+ rewardPointsDelta: number;
159
+ }
83
160
 
84
161
  // other
85
162
  export type DeeplTranslation = {
86
- detectedSourceLanguage: string,
163
+ detectedSourceLanguage: Language,
87
164
  translations: Array<{
88
165
  translatedText: string
89
166
  }>
@@ -1,7 +1,7 @@
1
1
  import { Familiarity, Language, LearningStage, MySQLDate } from './types';
2
2
 
3
3
  export interface ILexeme {
4
- id: number | undefined;
4
+ id: number | null;
5
5
  dateAdded: MySQLDate;
6
6
  text: string;
7
7
  userId: string;
@@ -13,9 +13,9 @@ export interface ILexemePair {
13
13
  englishLexeme: ILexeme;
14
14
  familiarity: Familiarity;
15
15
  firstKnownSessionDigit: number | null,
16
- lastFlashcardReview: MySQLDate,
16
+ lastFlashcardReview: MySQLDate | null,
17
17
  lastModified: MySQLDate;
18
- lastTested: MySQLDate;
18
+ lastTested: MySQLDate | null;
19
19
  learningStage: LearningStage,
20
20
  notes: string;
21
21
  userId: string;
@@ -32,6 +32,9 @@ export type LexemePairWithLang = {
32
32
  langToFocus: Language
33
33
  }
34
34
 
35
+ export interface ICount {
36
+ count: number;
37
+ }
35
38
 
36
39
 
37
40
 
@@ -1,8 +1,8 @@
1
1
  import { ILexemePair } from './lexemes';
2
2
 
3
3
  export enum Language {
4
- CZECH = 'cz',
5
- ENGLISH = 'en',
4
+ CZECH = "CZECH",
5
+ ENGLISH = "ENGLISH",
6
6
  UNKNOWN = 'UNKNOWN'
7
7
  }
8
8
  export type Result<T> = [T, undefined] | [undefined, Error];
@@ -13,8 +13,8 @@ export enum Familiarity {
13
13
  UNKNOWN = "UNKNOWN",
14
14
  }
15
15
  export enum VocabCheckType {
16
- FLASHCARD = 'flashcard',
17
- TEST = 'test',
16
+ FLASHCARD = "FLASHCARD",
17
+ TEST = "TEST",
18
18
  }
19
19
 
20
20
  export enum LearningStage {
@@ -24,9 +24,9 @@ export enum LearningStage {
24
24
  }
25
25
 
26
26
  export enum Progress {
27
- WORSE,
28
- NONE,
29
- IMPROVED
27
+ WORSE = "WORSE",
28
+ NONE = "NONE",
29
+ IMPROVED = "IMPROVED",
30
30
  }
31
31
 
32
32
  export interface ITestResult {
@@ -38,9 +38,9 @@ export interface ITestResult {
38
38
  export type MySQLDate = `${number}-${number}-${number} ${number}:${number}:${number}`;
39
39
 
40
40
  export enum ReminderFrequency {
41
- ALWAYS = "always",
42
- DAILY = "daily",
43
- NEVER = "never",
41
+ ALWAYS = "ALWAYS",
42
+ DAILY = "DAILY",
43
+ NEVER = "NEVER",
44
44
  }
45
45
 
46
46
  export enum AppError {
@@ -1,11 +1,11 @@
1
1
  import { expect } from 'chai';
2
2
  import {
3
- convertJSDateObjectToMySQLDateString,
4
- convertJSDateStringToMySQLDate, dateDifferenceInDays, isClientDateTooFarFromServerDate,
3
+ getMysqlDateIgnoreTZ,
4
+ convertJSDateStringToMySQLDate, dateDifferenceInDays, getMysqlDateAllowingForTZ, isClientDateTooFarFromServerDate,
5
5
  isThePreviousDay,
6
6
  isTheSameDay, isValidJsDateString, isValidMysqlDateString,
7
7
  MySQLDate
8
- } from '../../src';
8
+ } from '../src';
9
9
  describe('Date', () => {
10
10
  describe('isTheSameDay', () => {
11
11
  it('should return true if both dates are the same calendar day', () => {
@@ -48,14 +48,25 @@ describe('Date', () => {
48
48
  });
49
49
  });
50
50
 
51
- describe('convertJSDateObjectToMySQLDateString', () =>{
51
+ describe('getMysqlDateIgnoreTZ', () =>{
52
52
  it('should convert a JavaScript date object to a MySQL date string', () => {
53
53
  const date = new Date("2021-01-01T07:41:23.000Z");
54
- expect(convertJSDateObjectToMySQLDateString(date)).to.equal("2021-01-01 07:41:23");
54
+ expect(getMysqlDateIgnoreTZ(date)).to.equal("2021-01-01 07:41:23");
55
55
  });
56
56
  it('should return undefined if the input date is invalid', () => {
57
57
  const date = new Date("not a date");
58
- expect(convertJSDateObjectToMySQLDateString(date)).to.be.undefined;
58
+ expect(getMysqlDateIgnoreTZ(date)).to.be.undefined;
59
+ });
60
+ });
61
+
62
+ describe('getMysqlDateAllowingForTZ', () => {
63
+ it('should convert a JavaScript date object to a MySQL date string', () => {
64
+ const date = new Date("2021-01-01T07:41:23.000Z");
65
+ expect(getMysqlDateAllowingForTZ(date)).to.equal("2021-01-01 07:41:23");
66
+ });
67
+ it('should return undefined if the input date is invalid', () => {
68
+ const date = new Date("not a date");
69
+ expect(getMysqlDateAllowingForTZ(date)).to.be.undefined;
59
70
  });
60
71
  });
61
72
 
File without changes