czapp-shared 1.0.34 → 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
@@ -225,6 +225,14 @@ type Streaks = {
225
225
  flashcardStreak: number;
226
226
  testStreak: number;
227
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;
228
236
  declare const deriveStreakFromVocabCheckActivity: (activity: IVocabCheckActivity[], today: DateString) => Streaks;
229
237
 
230
238
  interface IActivityCount {
@@ -447,4 +455,4 @@ type DeeplTranslation = {
447
455
  }>;
448
456
  };
449
457
 
450
- 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, isLearningStageGroup, 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
@@ -225,6 +225,14 @@ type Streaks = {
225
225
  flashcardStreak: number;
226
226
  testStreak: number;
227
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;
228
236
  declare const deriveStreakFromVocabCheckActivity: (activity: IVocabCheckActivity[], today: DateString) => Streaks;
229
237
 
230
238
  interface IActivityCount {
@@ -447,4 +455,4 @@ type DeeplTranslation = {
447
455
  }>;
448
456
  };
449
457
 
450
- 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, isLearningStageGroup, 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
@@ -42,6 +42,7 @@ __export(index_exports, {
42
42
  getMysqlDateIgnoreTZ: () => getMysqlDateIgnoreTZ,
43
43
  isClientDateTooFarFromServerDate: () => isClientDateTooFarFromServerDate,
44
44
  isExpired: () => isExpired,
45
+ isFinalTest: () => isFinalTest,
45
46
  isLearningStageGroup: () => isLearningStageGroup,
46
47
  isStringContainingInteger: () => isStringContainingInteger,
47
48
  isThePreviousDay: () => isThePreviousDay,
@@ -239,6 +240,10 @@ var parameterReplace = (path, params = []) => {
239
240
  };
240
241
 
241
242
  // src/concrete/vocabCheck.ts
243
+ var isFinalTest = (firstKnownSessionDigit, testsCompletedCount) => {
244
+ const currentSessionDigit = testsCompletedCount % 10;
245
+ return currentSessionDigit === (firstKnownSessionDigit + 9) % 10;
246
+ };
242
247
  var deriveStreakFromVocabCheckActivity = (activity, today) => {
243
248
  if (activity.length === 0) return { flashcardStreak: 0, testStreak: 0 };
244
249
  let flashcardStreak = 0;
@@ -362,6 +367,7 @@ var ClientPlatform = /* @__PURE__ */ ((ClientPlatform2) => {
362
367
  getMysqlDateIgnoreTZ,
363
368
  isClientDateTooFarFromServerDate,
364
369
  isExpired,
370
+ isFinalTest,
365
371
  isLearningStageGroup,
366
372
  isStringContainingInteger,
367
373
  isThePreviousDay,
package/dist/index.mjs CHANGED
@@ -185,6 +185,10 @@ var parameterReplace = (path, params = []) => {
185
185
  };
186
186
 
187
187
  // src/concrete/vocabCheck.ts
188
+ var isFinalTest = (firstKnownSessionDigit, testsCompletedCount) => {
189
+ const currentSessionDigit = testsCompletedCount % 10;
190
+ return currentSessionDigit === (firstKnownSessionDigit + 9) % 10;
191
+ };
188
192
  var deriveStreakFromVocabCheckActivity = (activity, today) => {
189
193
  if (activity.length === 0) return { flashcardStreak: 0, testStreak: 0 };
190
194
  let flashcardStreak = 0;
@@ -307,6 +311,7 @@ export {
307
311
  getMysqlDateIgnoreTZ,
308
312
  isClientDateTooFarFromServerDate,
309
313
  isExpired,
314
+ isFinalTest,
310
315
  isLearningStageGroup,
311
316
  isStringContainingInteger,
312
317
  isThePreviousDay,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "czapp-shared",
3
- "version": "1.0.34",
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;
@@ -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
+ });