czapp-shared 1.0.8 → 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
7
  */
8
- declare const convertJSDateObjectToMySQLDateString: (date: Date) => MySQLDate | undefined;
8
+ declare const getMysqlDateIgnoreTZ: (date: Date) => MySQLDate | undefined;
9
+ /**
10
+ * @name getMysqlDateAllowingForTZ
11
+ * @param date
12
+ */
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;
@@ -158,10 +162,10 @@ interface ICount {
158
162
 
159
163
  declare class Lexeme implements ILexeme {
160
164
  text: string;
161
- id: number | undefined;
165
+ id: number | null;
162
166
  dateAdded: MySQLDate;
163
167
  userId: string;
164
- constructor();
168
+ constructor(userId: string);
165
169
  }
166
170
  declare class LexemePair implements ILexemePair {
167
171
  czechLexeme: ILexeme;
@@ -175,18 +179,12 @@ declare class LexemePair implements ILexemePair {
175
179
  learningStage: LearningStage;
176
180
  notes: string;
177
181
  userId: string;
178
- constructor(englishLexeme: Lexeme, czechLexeme: Lexeme);
182
+ constructor(userId: string, englishLexeme: Lexeme, czechLexeme: Lexeme);
179
183
  }
180
184
 
181
185
  declare const isStringContainingInteger: (str: any) => boolean;
182
186
  declare const parameterReplace: (path: string, params?: string[]) => string;
183
187
 
184
- declare enum Language$1 {
185
- CZECH = "cz",
186
- ENGLISH = "en",
187
- UNKNOWN = "UNKNOWN"
188
- }
189
-
190
188
  interface IUserData {
191
189
  currentStreakEnd: MySQLDate | undefined;
192
190
  currentStreakLength: number;
@@ -252,12 +250,12 @@ interface TestInitRequestBody {
252
250
  interface TestCompleteRequestBody {
253
251
  clientDate: MySQLDate;
254
252
  results: ITestResult[];
255
- vocabCheckType: string;
253
+ vocabCheckType: VocabCheckType;
256
254
  }
257
255
  interface TranslationRequestBody {
258
256
  q: string;
259
- source: Language$1;
260
- target: Language$1;
257
+ source: Language;
258
+ target: Language;
261
259
  }
262
260
  type LexemePairRequestBody = {
263
261
  czLexeme: ILexeme;
@@ -265,8 +263,8 @@ type LexemePairRequestBody = {
265
263
  pairingNotes: string;
266
264
  };
267
265
  interface UpdateUserRequestBody {
268
- learningLanguage: Language$1;
269
- uiLanguage: Language$1;
266
+ learningLanguage: Language;
267
+ uiLanguage: Language;
270
268
  }
271
269
  interface AutologinRequestBody {
272
270
  clientDate: MySQLDate;
@@ -284,35 +282,35 @@ interface SignInRequestBody {
284
282
  */
285
283
  interface SelectAllTranslationsParams {
286
284
  sourceText: string;
287
- sourceLang: string;
285
+ sourceLang: Language;
288
286
  }
289
287
  interface SelectLexemeCountParams {
290
- language: Language$1;
288
+ language: Language;
291
289
  }
292
290
  interface SelectLexemePairParams {
293
- czId: string;
294
- enId: string;
291
+ czId: number;
292
+ enId: number;
295
293
  }
296
294
  interface SelectLexemePairsByTextParams {
297
295
  inputText: string;
298
- inputLang: string;
296
+ inputLang: Language;
299
297
  }
300
298
  interface SelectLexemesParams {
301
- page: string;
302
- length: string;
299
+ page: number;
300
+ length: number;
303
301
  }
304
302
  interface SelectTestLexemesParams {
305
- testType: string;
306
- testLength: string;
303
+ testType: VocabCheckType;
304
+ testLength: number;
307
305
  }
308
306
  interface UpdateLexemePairFamiliarityParams {
309
- czId: string;
310
- enId: string;
311
- familiarity: string;
307
+ czId: number;
308
+ enId: number;
309
+ familiarity: Familiarity;
312
310
  }
313
311
  interface DeleteLexemePairRequestParams {
314
- czId: string;
315
- enId: string;
312
+ czId: number;
313
+ enId: number;
316
314
  }
317
315
  interface ResetTestUserParams {
318
316
  flashcardReviewCompletedCount: number;
@@ -327,7 +325,7 @@ interface ControllerResponse<T> {
327
325
  data: T;
328
326
  }
329
327
  type TranslationResponseData = {
330
- detectedSourceLanguage: string;
328
+ detectedSourceLanguage: Language;
331
329
  translations: Array<{
332
330
  translatedText: string;
333
331
  }>;
@@ -351,10 +349,10 @@ interface TestCompleteResponseData {
351
349
  rewardPointsDelta: number;
352
350
  }
353
351
  type DeeplTranslation = {
354
- detectedSourceLanguage: string;
352
+ detectedSourceLanguage: Language;
355
353
  translations: Array<{
356
354
  translatedText: string;
357
355
  }>;
358
356
  };
359
357
 
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 };
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
7
  */
8
- declare const convertJSDateObjectToMySQLDateString: (date: Date) => MySQLDate | undefined;
8
+ declare const getMysqlDateIgnoreTZ: (date: Date) => MySQLDate | undefined;
9
+ /**
10
+ * @name getMysqlDateAllowingForTZ
11
+ * @param date
12
+ */
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;
@@ -158,10 +162,10 @@ interface ICount {
158
162
 
159
163
  declare class Lexeme implements ILexeme {
160
164
  text: string;
161
- id: number | undefined;
165
+ id: number | null;
162
166
  dateAdded: MySQLDate;
163
167
  userId: string;
164
- constructor();
168
+ constructor(userId: string);
165
169
  }
166
170
  declare class LexemePair implements ILexemePair {
167
171
  czechLexeme: ILexeme;
@@ -175,18 +179,12 @@ declare class LexemePair implements ILexemePair {
175
179
  learningStage: LearningStage;
176
180
  notes: string;
177
181
  userId: string;
178
- constructor(englishLexeme: Lexeme, czechLexeme: Lexeme);
182
+ constructor(userId: string, englishLexeme: Lexeme, czechLexeme: Lexeme);
179
183
  }
180
184
 
181
185
  declare const isStringContainingInteger: (str: any) => boolean;
182
186
  declare const parameterReplace: (path: string, params?: string[]) => string;
183
187
 
184
- declare enum Language$1 {
185
- CZECH = "cz",
186
- ENGLISH = "en",
187
- UNKNOWN = "UNKNOWN"
188
- }
189
-
190
188
  interface IUserData {
191
189
  currentStreakEnd: MySQLDate | undefined;
192
190
  currentStreakLength: number;
@@ -252,12 +250,12 @@ interface TestInitRequestBody {
252
250
  interface TestCompleteRequestBody {
253
251
  clientDate: MySQLDate;
254
252
  results: ITestResult[];
255
- vocabCheckType: string;
253
+ vocabCheckType: VocabCheckType;
256
254
  }
257
255
  interface TranslationRequestBody {
258
256
  q: string;
259
- source: Language$1;
260
- target: Language$1;
257
+ source: Language;
258
+ target: Language;
261
259
  }
262
260
  type LexemePairRequestBody = {
263
261
  czLexeme: ILexeme;
@@ -265,8 +263,8 @@ type LexemePairRequestBody = {
265
263
  pairingNotes: string;
266
264
  };
267
265
  interface UpdateUserRequestBody {
268
- learningLanguage: Language$1;
269
- uiLanguage: Language$1;
266
+ learningLanguage: Language;
267
+ uiLanguage: Language;
270
268
  }
271
269
  interface AutologinRequestBody {
272
270
  clientDate: MySQLDate;
@@ -284,35 +282,35 @@ interface SignInRequestBody {
284
282
  */
285
283
  interface SelectAllTranslationsParams {
286
284
  sourceText: string;
287
- sourceLang: string;
285
+ sourceLang: Language;
288
286
  }
289
287
  interface SelectLexemeCountParams {
290
- language: Language$1;
288
+ language: Language;
291
289
  }
292
290
  interface SelectLexemePairParams {
293
- czId: string;
294
- enId: string;
291
+ czId: number;
292
+ enId: number;
295
293
  }
296
294
  interface SelectLexemePairsByTextParams {
297
295
  inputText: string;
298
- inputLang: string;
296
+ inputLang: Language;
299
297
  }
300
298
  interface SelectLexemesParams {
301
- page: string;
302
- length: string;
299
+ page: number;
300
+ length: number;
303
301
  }
304
302
  interface SelectTestLexemesParams {
305
- testType: string;
306
- testLength: string;
303
+ testType: VocabCheckType;
304
+ testLength: number;
307
305
  }
308
306
  interface UpdateLexemePairFamiliarityParams {
309
- czId: string;
310
- enId: string;
311
- familiarity: string;
307
+ czId: number;
308
+ enId: number;
309
+ familiarity: Familiarity;
312
310
  }
313
311
  interface DeleteLexemePairRequestParams {
314
- czId: string;
315
- enId: string;
312
+ czId: number;
313
+ enId: number;
316
314
  }
317
315
  interface ResetTestUserParams {
318
316
  flashcardReviewCompletedCount: number;
@@ -327,7 +325,7 @@ interface ControllerResponse<T> {
327
325
  data: T;
328
326
  }
329
327
  type TranslationResponseData = {
330
- detectedSourceLanguage: string;
328
+ detectedSourceLanguage: Language;
331
329
  translations: Array<{
332
330
  translatedText: string;
333
331
  }>;
@@ -351,10 +349,10 @@ interface TestCompleteResponseData {
351
349
  rewardPointsDelta: number;
352
350
  }
353
351
  type DeeplTranslation = {
354
- detectedSourceLanguage: string;
352
+ detectedSourceLanguage: Language;
355
353
  translations: Array<{
356
354
  translatedText: string;
357
355
  }>;
358
356
  };
359
357
 
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 };
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.8",
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,6 +1,5 @@
1
- import { Language } from '../../dist/index';
2
1
  import { ILexeme, ILexemeIdPair, ILexemePair } from './lexemes';
3
- import { ITestResult, MySQLDate, Scenario, VocabCheckType } from './types';
2
+ import { Familiarity, ITestResult, Language, MySQLDate, Scenario, VocabCheckType } from './types';
4
3
  import { IUserData } from './user';
5
4
 
6
5
  export enum HttpStatusCode {
@@ -51,7 +50,7 @@ export interface TestInitRequestBody {
51
50
  export interface TestCompleteRequestBody {
52
51
  clientDate: MySQLDate
53
52
  results: ITestResult[]
54
- vocabCheckType: string
53
+ vocabCheckType: VocabCheckType
55
54
  }
56
55
  export interface TranslationRequestBody {
57
56
  q: string;
@@ -84,35 +83,35 @@ export interface SignInRequestBody {
84
83
  */
85
84
  export interface SelectAllTranslationsParams {
86
85
  sourceText: string;
87
- sourceLang: string;
86
+ sourceLang: Language;
88
87
  }
89
88
  export interface SelectLexemeCountParams {
90
89
  language: Language;
91
90
  }
92
91
  export interface SelectLexemePairParams {
93
- czId: string;
94
- enId: string;
92
+ czId: number;
93
+ enId: number;
95
94
  }
96
95
  export interface SelectLexemePairsByTextParams {
97
96
  inputText: string;
98
- inputLang: string;
97
+ inputLang: Language;
99
98
  }
100
99
  export interface SelectLexemesParams {
101
- page: string;
102
- length: string;
100
+ page: number;
101
+ length: number;
103
102
  }
104
103
  export interface SelectTestLexemesParams {
105
- testType: string;
106
- testLength: string;
104
+ testType: VocabCheckType;
105
+ testLength: number;
107
106
  }
108
107
  export interface UpdateLexemePairFamiliarityParams {
109
- czId: string;
110
- enId: string;
111
- familiarity: string;
108
+ czId: number;
109
+ enId: number;
110
+ familiarity: Familiarity;
112
111
  }
113
112
  export interface DeleteLexemePairRequestParams {
114
- czId: string;
115
- enId: string;
113
+ czId: number;
114
+ enId: number;
116
115
  }
117
116
  export interface ResetTestUserParams {
118
117
  flashcardReviewCompletedCount: number;
@@ -135,7 +134,7 @@ export interface ControllerResponse<T> {
135
134
 
136
135
  // Response Data
137
136
  export type TranslationResponseData = {
138
- detectedSourceLanguage: string,
137
+ detectedSourceLanguage: Language,
139
138
  translations: Array<{
140
139
  translatedText: string
141
140
  }>
@@ -161,7 +160,7 @@ export interface TestCompleteResponseData {
161
160
 
162
161
  // other
163
162
  export type DeeplTranslation = {
164
- detectedSourceLanguage: string,
163
+ detectedSourceLanguage: Language,
165
164
  translations: Array<{
166
165
  translatedText: string
167
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;
@@ -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