czapp-shared 1.0.9 → 1.0.11

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
@@ -104,7 +104,8 @@ declare enum AppError {
104
104
  REQUEST_UPDATE_USER_SETTINGS_FAILED = "Failed to update user settings",
105
105
  REQUEST_INSERT_OR_UPDATE_LEXEME_PAIR_FAILED = "Failed to insert or update lexeme pair",
106
106
  REQUEST_TRANSLATION_FAILED = "Failed to get translation",
107
- REQUEST_TEST_COMPLETE_FAILED = "Failed to complete test"
107
+ REQUEST_TEST_COMPLETE_FAILED = "Failed to complete test",
108
+ REQUEST_TEST_SKIP_FAILED = "Failed to skip to the next deck"
108
109
  }
109
110
  declare enum Scenario {
110
111
  S1_INSERT_HAPPY_PATH = "Insert, happy path",
@@ -159,6 +160,11 @@ type LexemePairWithLang = {
159
160
  interface ICount {
160
161
  count: number;
161
162
  }
163
+ interface ILexemeLearningInfo {
164
+ newCount: number;
165
+ learningCount: number;
166
+ retiredCount: number;
167
+ }
162
168
 
163
169
  declare class Lexeme implements ILexeme {
164
170
  text: string;
@@ -202,7 +208,6 @@ interface IUserData {
202
208
  rewardPoints: number;
203
209
  signUpDate: MySQLDate;
204
210
  testsCompletedCount: number;
205
- testsUnlocked: boolean;
206
211
  uiLanguage: Language;
207
212
  }
208
213
 
@@ -236,10 +241,11 @@ declare enum ApiPath {
236
241
  SIGN_OUT = "/signOut",
237
242
  TEST_COMPLETE = "/test/complete",
238
243
  TEST_INIT = "/test/init",
244
+ TEST_SKIP_DECK = "/test/skipDeck",
239
245
  TRANSLATE = "/translate",
240
246
  TRANSLATIONS_ALL = "/lexemes/allTranslations/:sourceText/:sourceLang",
241
247
  USER = "/user",
242
- USER_RESET_TEST = "/user/test/reset/:flashcardReviewCompletedCount/:testsUnlocked"
248
+ USER_RESET_TEST = "/user/test/reset/:flashcardReviewCompletedCount/:currentStreakEnd"
243
249
  }
244
250
  /**
245
251
  * Request payloads
@@ -272,6 +278,7 @@ interface AutologinRequestBody {
272
278
  interface InsertOrUpdateRequestBody {
273
279
  czLexeme: ILexeme;
274
280
  enLexeme: ILexeme;
281
+ clientDate: MySQLDate;
275
282
  pairingNotes: string;
276
283
  }
277
284
  interface SignInRequestBody {
@@ -314,7 +321,7 @@ interface DeleteLexemePairRequestParams {
314
321
  }
315
322
  interface ResetTestUserParams {
316
323
  flashcardReviewCompletedCount: number;
317
- testsUnlocked: boolean;
324
+ currentStreakEnd: MySQLDate;
318
325
  }
319
326
  /**
320
327
  * Response payloads
@@ -341,6 +348,7 @@ interface SignInResponseData {
341
348
  }
342
349
  interface TestInitResponseData {
343
350
  lexemePairs: ILexemePair[];
351
+ lexemeLearningInfo: ILexemeLearningInfo;
344
352
  vocabCheckType: VocabCheckType;
345
353
  }
346
354
  interface TestCompleteResponseData {
@@ -355,4 +363,4 @@ type DeeplTranslation = {
355
363
  }>;
356
364
  };
357
365
 
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 };
366
+ export { ApiMethod, ApiPath, AppError, type AutologinRequestBody, type ControllerResponse, type DeeplTranslation, type DeleteLexemePairRequestParams, Familiarity, HttpStatusCode, type ICount, type ILexeme, type ILexemeIdPair, type ILexemeLearningInfo, 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
@@ -104,7 +104,8 @@ declare enum AppError {
104
104
  REQUEST_UPDATE_USER_SETTINGS_FAILED = "Failed to update user settings",
105
105
  REQUEST_INSERT_OR_UPDATE_LEXEME_PAIR_FAILED = "Failed to insert or update lexeme pair",
106
106
  REQUEST_TRANSLATION_FAILED = "Failed to get translation",
107
- REQUEST_TEST_COMPLETE_FAILED = "Failed to complete test"
107
+ REQUEST_TEST_COMPLETE_FAILED = "Failed to complete test",
108
+ REQUEST_TEST_SKIP_FAILED = "Failed to skip to the next deck"
108
109
  }
109
110
  declare enum Scenario {
110
111
  S1_INSERT_HAPPY_PATH = "Insert, happy path",
@@ -159,6 +160,11 @@ type LexemePairWithLang = {
159
160
  interface ICount {
160
161
  count: number;
161
162
  }
163
+ interface ILexemeLearningInfo {
164
+ newCount: number;
165
+ learningCount: number;
166
+ retiredCount: number;
167
+ }
162
168
 
163
169
  declare class Lexeme implements ILexeme {
164
170
  text: string;
@@ -202,7 +208,6 @@ interface IUserData {
202
208
  rewardPoints: number;
203
209
  signUpDate: MySQLDate;
204
210
  testsCompletedCount: number;
205
- testsUnlocked: boolean;
206
211
  uiLanguage: Language;
207
212
  }
208
213
 
@@ -236,10 +241,11 @@ declare enum ApiPath {
236
241
  SIGN_OUT = "/signOut",
237
242
  TEST_COMPLETE = "/test/complete",
238
243
  TEST_INIT = "/test/init",
244
+ TEST_SKIP_DECK = "/test/skipDeck",
239
245
  TRANSLATE = "/translate",
240
246
  TRANSLATIONS_ALL = "/lexemes/allTranslations/:sourceText/:sourceLang",
241
247
  USER = "/user",
242
- USER_RESET_TEST = "/user/test/reset/:flashcardReviewCompletedCount/:testsUnlocked"
248
+ USER_RESET_TEST = "/user/test/reset/:flashcardReviewCompletedCount/:currentStreakEnd"
243
249
  }
244
250
  /**
245
251
  * Request payloads
@@ -272,6 +278,7 @@ interface AutologinRequestBody {
272
278
  interface InsertOrUpdateRequestBody {
273
279
  czLexeme: ILexeme;
274
280
  enLexeme: ILexeme;
281
+ clientDate: MySQLDate;
275
282
  pairingNotes: string;
276
283
  }
277
284
  interface SignInRequestBody {
@@ -314,7 +321,7 @@ interface DeleteLexemePairRequestParams {
314
321
  }
315
322
  interface ResetTestUserParams {
316
323
  flashcardReviewCompletedCount: number;
317
- testsUnlocked: boolean;
324
+ currentStreakEnd: MySQLDate;
318
325
  }
319
326
  /**
320
327
  * Response payloads
@@ -341,6 +348,7 @@ interface SignInResponseData {
341
348
  }
342
349
  interface TestInitResponseData {
343
350
  lexemePairs: ILexemePair[];
351
+ lexemeLearningInfo: ILexemeLearningInfo;
344
352
  vocabCheckType: VocabCheckType;
345
353
  }
346
354
  interface TestCompleteResponseData {
@@ -355,4 +363,4 @@ type DeeplTranslation = {
355
363
  }>;
356
364
  };
357
365
 
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 };
366
+ export { ApiMethod, ApiPath, AppError, type AutologinRequestBody, type ControllerResponse, type DeeplTranslation, type DeleteLexemePairRequestParams, Familiarity, HttpStatusCode, type ICount, type ILexeme, type ILexemeIdPair, type ILexemeLearningInfo, 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
@@ -161,6 +161,7 @@ var AppError = /* @__PURE__ */ ((AppError2) => {
161
161
  AppError2["REQUEST_INSERT_OR_UPDATE_LEXEME_PAIR_FAILED"] = "Failed to insert or update lexeme pair";
162
162
  AppError2["REQUEST_TRANSLATION_FAILED"] = "Failed to get translation";
163
163
  AppError2["REQUEST_TEST_COMPLETE_FAILED"] = "Failed to complete test";
164
+ AppError2["REQUEST_TEST_SKIP_FAILED"] = "Failed to skip to the next deck";
164
165
  return AppError2;
165
166
  })(AppError || {});
166
167
  var Scenario = /* @__PURE__ */ ((Scenario2) => {
@@ -251,10 +252,11 @@ var ApiPath = /* @__PURE__ */ ((ApiPath2) => {
251
252
  ApiPath2["SIGN_OUT"] = "/signOut";
252
253
  ApiPath2["TEST_COMPLETE"] = "/test/complete";
253
254
  ApiPath2["TEST_INIT"] = "/test/init";
255
+ ApiPath2["TEST_SKIP_DECK"] = "/test/skipDeck";
254
256
  ApiPath2["TRANSLATE"] = "/translate";
255
257
  ApiPath2["TRANSLATIONS_ALL"] = "/lexemes/allTranslations/:sourceText/:sourceLang";
256
258
  ApiPath2["USER"] = "/user";
257
- ApiPath2["USER_RESET_TEST"] = "/user/test/reset/:flashcardReviewCompletedCount/:testsUnlocked";
259
+ ApiPath2["USER_RESET_TEST"] = "/user/test/reset/:flashcardReviewCompletedCount/:currentStreakEnd";
258
260
  return ApiPath2;
259
261
  })(ApiPath || {});
260
262
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.mjs CHANGED
@@ -112,6 +112,7 @@ var AppError = /* @__PURE__ */ ((AppError2) => {
112
112
  AppError2["REQUEST_INSERT_OR_UPDATE_LEXEME_PAIR_FAILED"] = "Failed to insert or update lexeme pair";
113
113
  AppError2["REQUEST_TRANSLATION_FAILED"] = "Failed to get translation";
114
114
  AppError2["REQUEST_TEST_COMPLETE_FAILED"] = "Failed to complete test";
115
+ AppError2["REQUEST_TEST_SKIP_FAILED"] = "Failed to skip to the next deck";
115
116
  return AppError2;
116
117
  })(AppError || {});
117
118
  var Scenario = /* @__PURE__ */ ((Scenario2) => {
@@ -202,10 +203,11 @@ var ApiPath = /* @__PURE__ */ ((ApiPath2) => {
202
203
  ApiPath2["SIGN_OUT"] = "/signOut";
203
204
  ApiPath2["TEST_COMPLETE"] = "/test/complete";
204
205
  ApiPath2["TEST_INIT"] = "/test/init";
206
+ ApiPath2["TEST_SKIP_DECK"] = "/test/skipDeck";
205
207
  ApiPath2["TRANSLATE"] = "/translate";
206
208
  ApiPath2["TRANSLATIONS_ALL"] = "/lexemes/allTranslations/:sourceText/:sourceLang";
207
209
  ApiPath2["USER"] = "/user";
208
- ApiPath2["USER_RESET_TEST"] = "/user/test/reset/:flashcardReviewCompletedCount/:testsUnlocked";
210
+ ApiPath2["USER_RESET_TEST"] = "/user/test/reset/:flashcardReviewCompletedCount/:currentStreakEnd";
209
211
  return ApiPath2;
210
212
  })(ApiPath || {});
211
213
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "czapp-shared",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
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",
@@ -7,7 +7,6 @@ import { MySQLDate } from '../index';
7
7
  * @type Date
8
8
  * @returns MySQLDate in the format "2021-01-01 07:41:23" or undefined if the input date is invalid
9
9
  */
10
-
11
10
  export const getMysqlDateIgnoreTZ = (date: Date): MySQLDate | undefined => {
12
11
  let dateStr: string;
13
12
  try {
@@ -22,20 +21,6 @@ export const getMysqlDateIgnoreTZ = (date: Date): MySQLDate | undefined => {
22
21
  }
23
22
  }
24
23
 
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
-
39
24
  /**
40
25
  * @name convertJSDateStringToMySQLDate
41
26
  * @description Converts a JavaScript Date object to a MySQL date string
package/src/design/api.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILexeme, ILexemeIdPair, ILexemePair } from './lexemes';
1
+ import { ILexeme, ILexemeIdPair, ILexemeLearningInfo, ILexemePair } from './lexemes';
2
2
  import { Familiarity, ITestResult, Language, MySQLDate, Scenario, VocabCheckType } from './types';
3
3
  import { IUserData } from './user';
4
4
 
@@ -34,10 +34,11 @@ export enum ApiPath {
34
34
  SIGN_OUT = '/signOut',
35
35
  TEST_COMPLETE = '/test/complete',
36
36
  TEST_INIT = '/test/init',
37
+ TEST_SKIP_DECK = '/test/skipDeck',
37
38
  TRANSLATE = '/translate',
38
39
  TRANSLATIONS_ALL = '/lexemes/allTranslations/:sourceText/:sourceLang',
39
40
  USER = '/user',
40
- USER_RESET_TEST = '/user/test/reset/:flashcardReviewCompletedCount/:testsUnlocked',
41
+ USER_RESET_TEST = '/user/test/reset/:flashcardReviewCompletedCount/:currentStreakEnd',
41
42
  }
42
43
 
43
44
 
@@ -72,6 +73,7 @@ export interface AutologinRequestBody {
72
73
  export interface InsertOrUpdateRequestBody {
73
74
  czLexeme: ILexeme;
74
75
  enLexeme: ILexeme;
76
+ clientDate: MySQLDate;
75
77
  pairingNotes: string;
76
78
  }
77
79
  export interface SignInRequestBody {
@@ -115,7 +117,7 @@ export interface DeleteLexemePairRequestParams {
115
117
  }
116
118
  export interface ResetTestUserParams {
117
119
  flashcardReviewCompletedCount: number;
118
- testsUnlocked: boolean;
120
+ currentStreakEnd: MySQLDate;
119
121
  }
120
122
 
121
123
 
@@ -150,6 +152,7 @@ export interface SignInResponseData {
150
152
  }
151
153
  export interface TestInitResponseData {
152
154
  lexemePairs: ILexemePair[];
155
+ lexemeLearningInfo: ILexemeLearningInfo;
153
156
  vocabCheckType: VocabCheckType;
154
157
  }
155
158
  export interface TestCompleteResponseData {
@@ -36,5 +36,11 @@ export interface ICount {
36
36
  count: number;
37
37
  }
38
38
 
39
+ export interface ILexemeLearningInfo {
40
+ newCount: number;
41
+ learningCount: number;
42
+ retiredCount: number;
43
+ }
44
+
39
45
 
40
46
 
@@ -57,6 +57,7 @@ export enum AppError {
57
57
  REQUEST_INSERT_OR_UPDATE_LEXEME_PAIR_FAILED = 'Failed to insert or update lexeme pair',
58
58
  REQUEST_TRANSLATION_FAILED = 'Failed to get translation',
59
59
  REQUEST_TEST_COMPLETE_FAILED = 'Failed to complete test',
60
+ REQUEST_TEST_SKIP_FAILED = "Failed to skip to the next deck"
60
61
  }
61
62
 
62
63
  export enum Scenario {
@@ -17,6 +17,5 @@ export interface IUserData {
17
17
  rewardPoints: number,
18
18
  signUpDate: MySQLDate,
19
19
  testsCompletedCount: number,
20
- testsUnlocked: boolean,
21
20
  uiLanguage: Language,
22
21
  }
package/test/date.test.ts CHANGED
@@ -1,9 +1,13 @@
1
1
  import { expect } from 'chai';
2
2
  import {
3
3
  getMysqlDateIgnoreTZ,
4
- convertJSDateStringToMySQLDate, dateDifferenceInDays, getMysqlDateAllowingForTZ, isClientDateTooFarFromServerDate,
4
+ convertJSDateStringToMySQLDate,
5
+ dateDifferenceInDays,
6
+ isClientDateTooFarFromServerDate,
5
7
  isThePreviousDay,
6
- isTheSameDay, isValidJsDateString, isValidMysqlDateString,
8
+ isTheSameDay,
9
+ isValidJsDateString,
10
+ isValidMysqlDateString,
7
11
  MySQLDate
8
12
  } from '../src';
9
13
  describe('Date', () => {
@@ -59,17 +63,6 @@ describe('Date', () => {
59
63
  });
60
64
  });
61
65
 
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;
70
- });
71
- });
72
-
73
66
  describe('convertJSDateStringToMySQLDateString', ()=> {
74
67
  it('should convert a JavaScript date string to a MySQL date string', () => {
75
68
  const date = "2021-01-01T07:41:23.000Z";