czapp-shared 1.0.33 → 1.0.35

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
@@ -80,6 +80,19 @@ declare enum LearningStage {
80
80
  RETIRED = "RETIRED",
81
81
  QUEUED = "QUEUED"
82
82
  }
83
+ /**
84
+ * User-facing grouping of LearningStage, used by the dictionary tabs.
85
+ * NEW is an internal transition stage the user never selects, so it is
86
+ * presented together with LEARNING - the same pairing the stored procedures
87
+ * already use for the active learning set (learningStage IN ('NEW','LEARNING')).
88
+ */
89
+ declare enum LearningStageGroup {
90
+ QUEUED = "QUEUED",
91
+ LEARNING = "LEARNING",
92
+ RETIRED = "RETIRED"
93
+ }
94
+ declare const LEARNING_STAGES_IN_GROUP: Record<LearningStageGroup, LearningStage[]>;
95
+ declare const isLearningStageGroup: (value: unknown) => value is LearningStageGroup;
83
96
  declare enum Progress {
84
97
  WORSE = "WORSE",
85
98
  NONE = "NONE",
@@ -212,6 +225,14 @@ type Streaks = {
212
225
  flashcardStreak: number;
213
226
  testStreak: number;
214
227
  };
228
+ /**
229
+ * @name isFinalTest
230
+ * @description A lexeme pair in the LEARNING stage is shown once per flashcard review session
231
+ * across a 10-session cycle starting from the session where it was first marked known
232
+ * (firstKnownSessionDigit). This returns true when the given session count lands on the last
233
+ * session of that cycle, at which point the pair should be promoted to RETIRED.
234
+ */
235
+ declare const isFinalTest: (firstKnownSessionDigit: number, testsCompletedCount: number) => boolean;
215
236
  declare const deriveStreakFromVocabCheckActivity: (activity: IVocabCheckActivity[], today: DateString) => Streaks;
216
237
 
217
238
  interface IActivityCount {
@@ -263,7 +284,9 @@ declare enum ApiPath {
263
284
  LEXEMES_ALL = "/lexemes/all",
264
285
  LEXEMES_COUNT = "/lexemes/count/:language",
265
286
  LEXEMES_DELETE_ALL = "/lexemes/deleteAll",
287
+ LEXEMES_LEARNING_INFO = "/lexemes/learningInfo",
266
288
  LEXEMES_PAGE = "/lexemes/:length/:page",
289
+ LEXEMES_PAGE_BY_STAGE = "/lexemes/stage/:stageGroup/:length/:page",
267
290
  LEXEME_PAIR = "/lexemePair/:czId/:enId",
268
291
  LEXEME_PAIRS_BY_TEXT = "/lexemePairsByText/:inputText/:inputLang",
269
292
  LEXEME_PAIR_FAMILIARITY = "/lexemePair/:czId/:enId/:familiarity",
@@ -353,6 +376,7 @@ interface SelectLexemePairsByTextParams {
353
376
  interface SelectLexemesParams {
354
377
  page: number;
355
378
  length: number;
379
+ stageGroup?: LearningStageGroup;
356
380
  }
357
381
  interface SelectTestLexemesParams {
358
382
  testType: VocabCheckType;
@@ -431,4 +455,4 @@ type DeeplTranslation = {
431
455
  }>;
432
456
  };
433
457
 
434
- export { ApiMethod, ApiPath, AppError, type AutologinRequestBody, ClientPlatform, type ControllerResponse, type DateString, type DeeplTranslation, type DeleteLexemePairRequestParams, Familiarity, type HeatMapParams, type HeatMapResponseData, HttpStatusCode, type IActivityCount, type ICount, type ILexeme, type ILexemeIdPair, type ILexemeLearningInfo, type ILexemePair, type ILexemePairTexts, type ISession, type ITestResult, type IUserData, type IVocabCheckActivity, type InsertOrUpdateRequestBody, type InsertOrUpdateResponseData, Language, LearningStage, Lexeme, LexemePair, type LexemePairRequestBody, type LexemePairWithLang, type MySQLDate, Progress, type RecycleLexemePairParams, type RegisterPushTokenRequestBody, ReminderFrequency, type ResetTestUserParams, type Result, Scenario, type SelectAllTranslationsParams, type SelectLexemeCountParams, type SelectLexemePairParams, type SelectLexemePairsByTextParams, type SelectLexemesParams, type SelectTestLexemesParams, type SelectVocabCheckActivityParams, type SignInRequestBody, type SignInResponseData, type Streaks, type TestCompleteRequestBody, type TestCompleteResponseData, type TestInitRequestBody, type TestInitResponseData, type TranslationRequestBody, type TranslationResponseData, type UpdateLexemePairFamiliarityParams, type UpdateOnboardingStatusRequestBody, type UpdateUserRequestBody, VocabCheckType, convertJSDateStringToMySQLDate, dateDifferenceInDays, deriveStreakFromVocabCheckActivity, getFormattedDate, getMysqlDateIgnoreTZ, isClientDateTooFarFromServerDate, isExpired, isStringContainingInteger, isThePreviousDay, isTheSameDay, isValidJsDateString, isValidMysqlDateString, parameterReplace };
458
+ export { ApiMethod, ApiPath, AppError, type AutologinRequestBody, ClientPlatform, type ControllerResponse, type DateString, type DeeplTranslation, type DeleteLexemePairRequestParams, Familiarity, type HeatMapParams, type HeatMapResponseData, HttpStatusCode, type IActivityCount, type ICount, type ILexeme, type ILexemeIdPair, type ILexemeLearningInfo, type ILexemePair, type ILexemePairTexts, type ISession, type ITestResult, type IUserData, type IVocabCheckActivity, type InsertOrUpdateRequestBody, type InsertOrUpdateResponseData, LEARNING_STAGES_IN_GROUP, Language, LearningStage, LearningStageGroup, Lexeme, LexemePair, type LexemePairRequestBody, type LexemePairWithLang, type MySQLDate, Progress, type RecycleLexemePairParams, type RegisterPushTokenRequestBody, ReminderFrequency, type ResetTestUserParams, type Result, Scenario, type SelectAllTranslationsParams, type SelectLexemeCountParams, type SelectLexemePairParams, type SelectLexemePairsByTextParams, type SelectLexemesParams, type SelectTestLexemesParams, type SelectVocabCheckActivityParams, type SignInRequestBody, type SignInResponseData, type Streaks, type TestCompleteRequestBody, type TestCompleteResponseData, type TestInitRequestBody, type TestInitResponseData, type TranslationRequestBody, type TranslationResponseData, type UpdateLexemePairFamiliarityParams, type UpdateOnboardingStatusRequestBody, type UpdateUserRequestBody, VocabCheckType, convertJSDateStringToMySQLDate, dateDifferenceInDays, deriveStreakFromVocabCheckActivity, getFormattedDate, getMysqlDateIgnoreTZ, isClientDateTooFarFromServerDate, isExpired, isFinalTest, isLearningStageGroup, isStringContainingInteger, isThePreviousDay, isTheSameDay, isValidJsDateString, isValidMysqlDateString, parameterReplace };
package/dist/index.d.ts CHANGED
@@ -80,6 +80,19 @@ declare enum LearningStage {
80
80
  RETIRED = "RETIRED",
81
81
  QUEUED = "QUEUED"
82
82
  }
83
+ /**
84
+ * User-facing grouping of LearningStage, used by the dictionary tabs.
85
+ * NEW is an internal transition stage the user never selects, so it is
86
+ * presented together with LEARNING - the same pairing the stored procedures
87
+ * already use for the active learning set (learningStage IN ('NEW','LEARNING')).
88
+ */
89
+ declare enum LearningStageGroup {
90
+ QUEUED = "QUEUED",
91
+ LEARNING = "LEARNING",
92
+ RETIRED = "RETIRED"
93
+ }
94
+ declare const LEARNING_STAGES_IN_GROUP: Record<LearningStageGroup, LearningStage[]>;
95
+ declare const isLearningStageGroup: (value: unknown) => value is LearningStageGroup;
83
96
  declare enum Progress {
84
97
  WORSE = "WORSE",
85
98
  NONE = "NONE",
@@ -212,6 +225,14 @@ type Streaks = {
212
225
  flashcardStreak: number;
213
226
  testStreak: number;
214
227
  };
228
+ /**
229
+ * @name isFinalTest
230
+ * @description A lexeme pair in the LEARNING stage is shown once per flashcard review session
231
+ * across a 10-session cycle starting from the session where it was first marked known
232
+ * (firstKnownSessionDigit). This returns true when the given session count lands on the last
233
+ * session of that cycle, at which point the pair should be promoted to RETIRED.
234
+ */
235
+ declare const isFinalTest: (firstKnownSessionDigit: number, testsCompletedCount: number) => boolean;
215
236
  declare const deriveStreakFromVocabCheckActivity: (activity: IVocabCheckActivity[], today: DateString) => Streaks;
216
237
 
217
238
  interface IActivityCount {
@@ -263,7 +284,9 @@ declare enum ApiPath {
263
284
  LEXEMES_ALL = "/lexemes/all",
264
285
  LEXEMES_COUNT = "/lexemes/count/:language",
265
286
  LEXEMES_DELETE_ALL = "/lexemes/deleteAll",
287
+ LEXEMES_LEARNING_INFO = "/lexemes/learningInfo",
266
288
  LEXEMES_PAGE = "/lexemes/:length/:page",
289
+ LEXEMES_PAGE_BY_STAGE = "/lexemes/stage/:stageGroup/:length/:page",
267
290
  LEXEME_PAIR = "/lexemePair/:czId/:enId",
268
291
  LEXEME_PAIRS_BY_TEXT = "/lexemePairsByText/:inputText/:inputLang",
269
292
  LEXEME_PAIR_FAMILIARITY = "/lexemePair/:czId/:enId/:familiarity",
@@ -353,6 +376,7 @@ interface SelectLexemePairsByTextParams {
353
376
  interface SelectLexemesParams {
354
377
  page: number;
355
378
  length: number;
379
+ stageGroup?: LearningStageGroup;
356
380
  }
357
381
  interface SelectTestLexemesParams {
358
382
  testType: VocabCheckType;
@@ -431,4 +455,4 @@ type DeeplTranslation = {
431
455
  }>;
432
456
  };
433
457
 
434
- export { ApiMethod, ApiPath, AppError, type AutologinRequestBody, ClientPlatform, type ControllerResponse, type DateString, type DeeplTranslation, type DeleteLexemePairRequestParams, Familiarity, type HeatMapParams, type HeatMapResponseData, HttpStatusCode, type IActivityCount, type ICount, type ILexeme, type ILexemeIdPair, type ILexemeLearningInfo, type ILexemePair, type ILexemePairTexts, type ISession, type ITestResult, type IUserData, type IVocabCheckActivity, type InsertOrUpdateRequestBody, type InsertOrUpdateResponseData, Language, LearningStage, Lexeme, LexemePair, type LexemePairRequestBody, type LexemePairWithLang, type MySQLDate, Progress, type RecycleLexemePairParams, type RegisterPushTokenRequestBody, ReminderFrequency, type ResetTestUserParams, type Result, Scenario, type SelectAllTranslationsParams, type SelectLexemeCountParams, type SelectLexemePairParams, type SelectLexemePairsByTextParams, type SelectLexemesParams, type SelectTestLexemesParams, type SelectVocabCheckActivityParams, type SignInRequestBody, type SignInResponseData, type Streaks, type TestCompleteRequestBody, type TestCompleteResponseData, type TestInitRequestBody, type TestInitResponseData, type TranslationRequestBody, type TranslationResponseData, type UpdateLexemePairFamiliarityParams, type UpdateOnboardingStatusRequestBody, type UpdateUserRequestBody, VocabCheckType, convertJSDateStringToMySQLDate, dateDifferenceInDays, deriveStreakFromVocabCheckActivity, getFormattedDate, getMysqlDateIgnoreTZ, isClientDateTooFarFromServerDate, isExpired, isStringContainingInteger, isThePreviousDay, isTheSameDay, isValidJsDateString, isValidMysqlDateString, parameterReplace };
458
+ export { ApiMethod, ApiPath, AppError, type AutologinRequestBody, ClientPlatform, type ControllerResponse, type DateString, type DeeplTranslation, type DeleteLexemePairRequestParams, Familiarity, type HeatMapParams, type HeatMapResponseData, HttpStatusCode, type IActivityCount, type ICount, type ILexeme, type ILexemeIdPair, type ILexemeLearningInfo, type ILexemePair, type ILexemePairTexts, type ISession, type ITestResult, type IUserData, type IVocabCheckActivity, type InsertOrUpdateRequestBody, type InsertOrUpdateResponseData, LEARNING_STAGES_IN_GROUP, Language, LearningStage, LearningStageGroup, Lexeme, LexemePair, type LexemePairRequestBody, type LexemePairWithLang, type MySQLDate, Progress, type RecycleLexemePairParams, type RegisterPushTokenRequestBody, ReminderFrequency, type ResetTestUserParams, type Result, Scenario, type SelectAllTranslationsParams, type SelectLexemeCountParams, type SelectLexemePairParams, type SelectLexemePairsByTextParams, type SelectLexemesParams, type SelectTestLexemesParams, type SelectVocabCheckActivityParams, type SignInRequestBody, type SignInResponseData, type Streaks, type TestCompleteRequestBody, type TestCompleteResponseData, type TestInitRequestBody, type TestInitResponseData, type TranslationRequestBody, type TranslationResponseData, type UpdateLexemePairFamiliarityParams, type UpdateOnboardingStatusRequestBody, type UpdateUserRequestBody, VocabCheckType, convertJSDateStringToMySQLDate, dateDifferenceInDays, deriveStreakFromVocabCheckActivity, getFormattedDate, getMysqlDateIgnoreTZ, isClientDateTooFarFromServerDate, isExpired, isFinalTest, isLearningStageGroup, isStringContainingInteger, isThePreviousDay, isTheSameDay, isValidJsDateString, isValidMysqlDateString, parameterReplace };
package/dist/index.js CHANGED
@@ -25,8 +25,10 @@ __export(index_exports, {
25
25
  ClientPlatform: () => ClientPlatform,
26
26
  Familiarity: () => Familiarity,
27
27
  HttpStatusCode: () => HttpStatusCode,
28
+ LEARNING_STAGES_IN_GROUP: () => LEARNING_STAGES_IN_GROUP,
28
29
  Language: () => Language,
29
30
  LearningStage: () => LearningStage,
31
+ LearningStageGroup: () => LearningStageGroup,
30
32
  Lexeme: () => Lexeme,
31
33
  LexemePair: () => LexemePair,
32
34
  Progress: () => Progress,
@@ -40,6 +42,8 @@ __export(index_exports, {
40
42
  getMysqlDateIgnoreTZ: () => getMysqlDateIgnoreTZ,
41
43
  isClientDateTooFarFromServerDate: () => isClientDateTooFarFromServerDate,
42
44
  isExpired: () => isExpired,
45
+ isFinalTest: () => isFinalTest,
46
+ isLearningStageGroup: () => isLearningStageGroup,
43
47
  isStringContainingInteger: () => isStringContainingInteger,
44
48
  isThePreviousDay: () => isThePreviousDay,
45
49
  isTheSameDay: () => isTheSameDay,
@@ -137,6 +141,18 @@ var LearningStage = /* @__PURE__ */ ((LearningStage2) => {
137
141
  LearningStage2["QUEUED"] = "QUEUED";
138
142
  return LearningStage2;
139
143
  })(LearningStage || {});
144
+ var LearningStageGroup = /* @__PURE__ */ ((LearningStageGroup2) => {
145
+ LearningStageGroup2["QUEUED"] = "QUEUED";
146
+ LearningStageGroup2["LEARNING"] = "LEARNING";
147
+ LearningStageGroup2["RETIRED"] = "RETIRED";
148
+ return LearningStageGroup2;
149
+ })(LearningStageGroup || {});
150
+ var LEARNING_STAGES_IN_GROUP = {
151
+ ["QUEUED" /* QUEUED */]: ["QUEUED" /* QUEUED */],
152
+ ["LEARNING" /* LEARNING */]: ["NEW" /* NEW */, "LEARNING" /* LEARNING */],
153
+ ["RETIRED" /* RETIRED */]: ["RETIRED" /* RETIRED */]
154
+ };
155
+ var isLearningStageGroup = (value) => typeof value === "string" && Object.values(LearningStageGroup).includes(value);
140
156
  var Progress = /* @__PURE__ */ ((Progress2) => {
141
157
  Progress2["WORSE"] = "WORSE";
142
158
  Progress2["NONE"] = "NONE";
@@ -224,6 +240,10 @@ var parameterReplace = (path, params = []) => {
224
240
  };
225
241
 
226
242
  // src/concrete/vocabCheck.ts
243
+ var isFinalTest = (firstKnownSessionDigit, testsCompletedCount) => {
244
+ const currentSessionDigit = testsCompletedCount % 10;
245
+ return currentSessionDigit === (firstKnownSessionDigit + 9) % 10;
246
+ };
227
247
  var deriveStreakFromVocabCheckActivity = (activity, today) => {
228
248
  if (activity.length === 0) return { flashcardStreak: 0, testStreak: 0 };
229
249
  let flashcardStreak = 0;
@@ -294,7 +314,9 @@ var ApiPath = /* @__PURE__ */ ((ApiPath2) => {
294
314
  ApiPath2["LEXEMES_ALL"] = "/lexemes/all";
295
315
  ApiPath2["LEXEMES_COUNT"] = "/lexemes/count/:language";
296
316
  ApiPath2["LEXEMES_DELETE_ALL"] = "/lexemes/deleteAll";
317
+ ApiPath2["LEXEMES_LEARNING_INFO"] = "/lexemes/learningInfo";
297
318
  ApiPath2["LEXEMES_PAGE"] = "/lexemes/:length/:page";
319
+ ApiPath2["LEXEMES_PAGE_BY_STAGE"] = "/lexemes/stage/:stageGroup/:length/:page";
298
320
  ApiPath2["LEXEME_PAIR"] = "/lexemePair/:czId/:enId";
299
321
  ApiPath2["LEXEME_PAIRS_BY_TEXT"] = "/lexemePairsByText/:inputText/:inputLang";
300
322
  ApiPath2["LEXEME_PAIR_FAMILIARITY"] = "/lexemePair/:czId/:enId/:familiarity";
@@ -328,8 +350,10 @@ var ClientPlatform = /* @__PURE__ */ ((ClientPlatform2) => {
328
350
  ClientPlatform,
329
351
  Familiarity,
330
352
  HttpStatusCode,
353
+ LEARNING_STAGES_IN_GROUP,
331
354
  Language,
332
355
  LearningStage,
356
+ LearningStageGroup,
333
357
  Lexeme,
334
358
  LexemePair,
335
359
  Progress,
@@ -343,6 +367,8 @@ var ClientPlatform = /* @__PURE__ */ ((ClientPlatform2) => {
343
367
  getMysqlDateIgnoreTZ,
344
368
  isClientDateTooFarFromServerDate,
345
369
  isExpired,
370
+ isFinalTest,
371
+ isLearningStageGroup,
346
372
  isStringContainingInteger,
347
373
  isThePreviousDay,
348
374
  isTheSameDay,
package/dist/index.mjs CHANGED
@@ -86,6 +86,18 @@ var LearningStage = /* @__PURE__ */ ((LearningStage2) => {
86
86
  LearningStage2["QUEUED"] = "QUEUED";
87
87
  return LearningStage2;
88
88
  })(LearningStage || {});
89
+ var LearningStageGroup = /* @__PURE__ */ ((LearningStageGroup2) => {
90
+ LearningStageGroup2["QUEUED"] = "QUEUED";
91
+ LearningStageGroup2["LEARNING"] = "LEARNING";
92
+ LearningStageGroup2["RETIRED"] = "RETIRED";
93
+ return LearningStageGroup2;
94
+ })(LearningStageGroup || {});
95
+ var LEARNING_STAGES_IN_GROUP = {
96
+ ["QUEUED" /* QUEUED */]: ["QUEUED" /* QUEUED */],
97
+ ["LEARNING" /* LEARNING */]: ["NEW" /* NEW */, "LEARNING" /* LEARNING */],
98
+ ["RETIRED" /* RETIRED */]: ["RETIRED" /* RETIRED */]
99
+ };
100
+ var isLearningStageGroup = (value) => typeof value === "string" && Object.values(LearningStageGroup).includes(value);
89
101
  var Progress = /* @__PURE__ */ ((Progress2) => {
90
102
  Progress2["WORSE"] = "WORSE";
91
103
  Progress2["NONE"] = "NONE";
@@ -173,6 +185,10 @@ var parameterReplace = (path, params = []) => {
173
185
  };
174
186
 
175
187
  // src/concrete/vocabCheck.ts
188
+ var isFinalTest = (firstKnownSessionDigit, testsCompletedCount) => {
189
+ const currentSessionDigit = testsCompletedCount % 10;
190
+ return currentSessionDigit === (firstKnownSessionDigit + 9) % 10;
191
+ };
176
192
  var deriveStreakFromVocabCheckActivity = (activity, today) => {
177
193
  if (activity.length === 0) return { flashcardStreak: 0, testStreak: 0 };
178
194
  let flashcardStreak = 0;
@@ -243,7 +259,9 @@ var ApiPath = /* @__PURE__ */ ((ApiPath2) => {
243
259
  ApiPath2["LEXEMES_ALL"] = "/lexemes/all";
244
260
  ApiPath2["LEXEMES_COUNT"] = "/lexemes/count/:language";
245
261
  ApiPath2["LEXEMES_DELETE_ALL"] = "/lexemes/deleteAll";
262
+ ApiPath2["LEXEMES_LEARNING_INFO"] = "/lexemes/learningInfo";
246
263
  ApiPath2["LEXEMES_PAGE"] = "/lexemes/:length/:page";
264
+ ApiPath2["LEXEMES_PAGE_BY_STAGE"] = "/lexemes/stage/:stageGroup/:length/:page";
247
265
  ApiPath2["LEXEME_PAIR"] = "/lexemePair/:czId/:enId";
248
266
  ApiPath2["LEXEME_PAIRS_BY_TEXT"] = "/lexemePairsByText/:inputText/:inputLang";
249
267
  ApiPath2["LEXEME_PAIR_FAMILIARITY"] = "/lexemePair/:czId/:enId/:familiarity";
@@ -276,8 +294,10 @@ export {
276
294
  ClientPlatform,
277
295
  Familiarity,
278
296
  HttpStatusCode,
297
+ LEARNING_STAGES_IN_GROUP,
279
298
  Language,
280
299
  LearningStage,
300
+ LearningStageGroup,
281
301
  Lexeme,
282
302
  LexemePair,
283
303
  Progress,
@@ -291,6 +311,8 @@ export {
291
311
  getMysqlDateIgnoreTZ,
292
312
  isClientDateTooFarFromServerDate,
293
313
  isExpired,
314
+ isFinalTest,
315
+ isLearningStageGroup,
294
316
  isStringContainingInteger,
295
317
  isThePreviousDay,
296
318
  isTheSameDay,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "czapp-shared",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
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",
@@ -5,6 +5,21 @@ export type Streaks = {
5
5
  testStreak: number;
6
6
  }
7
7
 
8
+ /**
9
+ * @name isFinalTest
10
+ * @description A lexeme pair in the LEARNING stage is shown once per flashcard review session
11
+ * across a 10-session cycle starting from the session where it was first marked known
12
+ * (firstKnownSessionDigit). This returns true when the given session count lands on the last
13
+ * session of that cycle, at which point the pair should be promoted to RETIRED.
14
+ */
15
+ export const isFinalTest = (
16
+ firstKnownSessionDigit: number,
17
+ testsCompletedCount: number
18
+ ): boolean => {
19
+ const currentSessionDigit = testsCompletedCount % 10;
20
+ return currentSessionDigit === (firstKnownSessionDigit + 9) % 10;
21
+ }
22
+
8
23
  export const deriveStreakFromVocabCheckActivity = (activity: IVocabCheckActivity[], today: DateString): Streaks => {
9
24
  if (activity.length === 0) return { flashcardStreak: 0, testStreak: 0 };
10
25
  let flashcardStreak = 0;
package/src/design/api.ts CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  Familiarity,
6
6
  ITestResult,
7
7
  Language,
8
+ LearningStageGroup,
8
9
  MySQLDate,
9
10
  Scenario,
10
11
  IVocabCheckActivity,
@@ -38,7 +39,9 @@ export enum ApiPath {
38
39
  LEXEMES_ALL = '/lexemes/all',
39
40
  LEXEMES_COUNT = '/lexemes/count/:language',
40
41
  LEXEMES_DELETE_ALL = '/lexemes/deleteAll',
42
+ LEXEMES_LEARNING_INFO = '/lexemes/learningInfo',
41
43
  LEXEMES_PAGE = '/lexemes/:length/:page',
44
+ LEXEMES_PAGE_BY_STAGE = '/lexemes/stage/:stageGroup/:length/:page',
42
45
  LEXEME_PAIR = '/lexemePair/:czId/:enId',
43
46
  LEXEME_PAIRS_BY_TEXT = '/lexemePairsByText/:inputText/:inputLang',
44
47
  LEXEME_PAIR_FAMILIARITY = '/lexemePair/:czId/:enId/:familiarity',
@@ -133,6 +136,7 @@ export interface SelectLexemePairsByTextParams {
133
136
  export interface SelectLexemesParams {
134
137
  page: number;
135
138
  length: number;
139
+ stageGroup?: LearningStageGroup; // undefined means every learning stage
136
140
  }
137
141
  export interface SelectTestLexemesParams {
138
142
  testType: VocabCheckType;
@@ -33,6 +33,28 @@ export enum LearningStage {
33
33
  QUEUED = 'QUEUED',
34
34
  }
35
35
 
36
+ /**
37
+ * User-facing grouping of LearningStage, used by the dictionary tabs.
38
+ * NEW is an internal transition stage the user never selects, so it is
39
+ * presented together with LEARNING - the same pairing the stored procedures
40
+ * already use for the active learning set (learningStage IN ('NEW','LEARNING')).
41
+ */
42
+ export enum LearningStageGroup {
43
+ QUEUED = 'QUEUED',
44
+ LEARNING = 'LEARNING',
45
+ RETIRED = 'RETIRED',
46
+ }
47
+
48
+ export const LEARNING_STAGES_IN_GROUP: Record<LearningStageGroup, LearningStage[]> = {
49
+ [LearningStageGroup.QUEUED]: [LearningStage.QUEUED],
50
+ [LearningStageGroup.LEARNING]: [LearningStage.NEW, LearningStage.LEARNING],
51
+ [LearningStageGroup.RETIRED]: [LearningStage.RETIRED],
52
+ };
53
+
54
+ export const isLearningStageGroup = (value: unknown): value is LearningStageGroup =>
55
+ typeof value === 'string' &&
56
+ Object.values(LearningStageGroup).includes(value as LearningStageGroup);
57
+
36
58
  export enum Progress {
37
59
  WORSE = "WORSE",
38
60
  NONE = "NONE",
@@ -1,6 +1,6 @@
1
1
  import { expect } from 'chai';
2
2
  import { IVocabCheckActivity } from '../src';
3
- import { deriveStreakFromVocabCheckActivity } from '../src/concrete/vocabCheck';
3
+ import { deriveStreakFromVocabCheckActivity, isFinalTest } from '../src/concrete/vocabCheck';
4
4
 
5
5
 
6
6
 
@@ -47,3 +47,33 @@ describe('deriveStreakFromVocabCheckActivity', () => {
47
47
  });
48
48
 
49
49
  });
50
+
51
+ describe('isFinalTest', () => {
52
+ it('should return true if the firstKnownSessionDigit is 0 and the rightmost digit of the testsCompletedCount is 9', () => {
53
+ const firstKnownSessionDigit = 0;
54
+ const testsCompletedCount = 9;
55
+ expect(isFinalTest(firstKnownSessionDigit, testsCompletedCount)).to.be.true;
56
+ });
57
+ it('should return true for [1,0], [2,1] etc.', () => {
58
+ expect(isFinalTest(1, 0)).to.be.true;
59
+ expect(isFinalTest(2, 1)).to.be.true;
60
+ expect(isFinalTest(3, 2)).to.be.true;
61
+ expect(isFinalTest(4, 3)).to.be.true;
62
+ expect(isFinalTest(5, 4)).to.be.true;
63
+ expect(isFinalTest(6, 5)).to.be.true;
64
+ expect(isFinalTest(7, 6)).to.be.true;
65
+ expect(isFinalTest(8, 7)).to.be.true;
66
+ expect(isFinalTest(9, 8)).to.be.true;
67
+ })
68
+ it('should return false for invalid params', () => {
69
+ expect(isFinalTest(1, 1)).to.be.false;
70
+ expect(isFinalTest(1, 2)).to.be.false;
71
+ expect(isFinalTest(1, 3)).to.be.false;
72
+ expect(isFinalTest(1, 4)).to.be.false;
73
+ expect(isFinalTest(1, 5)).to.be.false;
74
+ expect(isFinalTest(1, 6)).to.be.false;
75
+ expect(isFinalTest(1, 7)).to.be.false;
76
+ expect(isFinalTest(1, 8)).to.be.false;
77
+ expect(isFinalTest(1, 9)).to.be.false;
78
+ })
79
+ });