czapp-shared 1.0.20 → 1.0.22

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Czapp Shared
2
2
  This is a shared library for Czapp projects. It contains common types and utils that is are needed by both client and
3
- server repositories.
3
+ server repositories. It is hosted in a public NPM repo.
4
4
 
5
5
  ## Installation
6
6
  To install:
@@ -13,7 +13,7 @@ npm install czapp-shared
13
13
  import { MyType } from 'czapp-shared';
14
14
  ```
15
15
 
16
- ## Development
16
+ ## Development Using Yalc
17
17
  Note `npm link` does not work. Use Yalc instead.
18
18
 
19
19
  First install Yalc globally:
@@ -30,7 +30,19 @@ Then in the project that you want to use this package, run the following command
30
30
  ```bash
31
31
  yalc add czapp-shared
32
32
  ```
33
+ This will overwrite the dependency line in package.json with `"czapp-shared": "file:.yalc/czapp-shared",`
34
+ It is then necessary to run `npm install`, which replaces the `node_modules/czapp-shared` folder with a symlink that
35
+ points to the project's `.yalc` folder which contains the latest published changes for the shared lib. Now the package
36
+ can be built and will use the yalc version of the shared library. Also, the IDE should find all sources and allow easy
37
+ navigation between the package to the shared library sources.
33
38
 
39
+ Don't commit the package.json with the Yalc entry though!. To easily revert back to the original dependency line so that
40
+ package.json can be committed, run this in the root of the dependent package:
41
+ ```bash
42
+ yalc remove czapp-shared
43
+ ```
44
+
45
+ ### Watch mode
34
46
  To run the project in watch mode:
35
47
  ```bash
36
48
  npm run watch
@@ -38,18 +50,19 @@ npm run watch
38
50
 
39
51
  TODO - make yalc republish after every change. At the moment it is manual. Run `yalc publish` after every change.
40
52
 
53
+ ### Build
41
54
  To build the project (generate the artifacts):
42
55
  ```bash
43
- To build:
44
- ```bash
45
56
  npm run build
46
57
  ```
47
58
 
59
+ ### Test
48
60
  To run unit tests:
49
61
  ```bash
50
62
  npm run test:unit
51
63
  ```
52
64
 
65
+ ### Release
53
66
  To release new version, and types and then run this...
54
67
 
55
68
  ```bash
package/dist/index.d.mts CHANGED
@@ -49,7 +49,16 @@ declare const dateDifferenceInDays: (date1: MySQLDate, date2: MySQLDate) => numb
49
49
  declare const isThePreviousDay: (date: MySQLDate, referenceDate: MySQLDate) => boolean;
50
50
  declare const isTheSameDay: (date1: MySQLDate, date2: MySQLDate) => boolean;
51
51
  declare const getFormattedDate: (date: Date) => string;
52
+ declare const isExpired: (date: MySQLDate) => boolean;
52
53
 
54
+ interface ISession {
55
+ sessionToken: string | undefined;
56
+ deviceId: string | undefined;
57
+ googleSub: string;
58
+ sessionExpiry: MySQLDate | null;
59
+ sessionCreated: MySQLDate;
60
+ lastAutoLogin: MySQLDate;
61
+ }
53
62
  declare enum Language {
54
63
  CZECH = "CZECH",
55
64
  ENGLISH = "ENGLISH",
@@ -294,7 +303,6 @@ interface InsertOrUpdateRequestBody {
294
303
  pairingNotes: string;
295
304
  }
296
305
  interface SignInRequestBody {
297
- rememberMe: boolean;
298
306
  }
299
307
  interface UpdateOnboardingStatusRequestBody {
300
308
  onboardingStatus: boolean;
@@ -369,8 +377,8 @@ interface InsertOrUpdateResponseData {
369
377
  newMappingInserted?: boolean;
370
378
  }
371
379
  interface SignInResponseData {
372
- expiryDate: number;
373
- user: IUserData;
380
+ user: Partial<IUserData>;
381
+ sessionToken: string | undefined;
374
382
  }
375
383
  interface TestInitResponseData {
376
384
  lexemePairs: ILexemePair[];
@@ -394,4 +402,4 @@ type DeeplTranslation = {
394
402
  }>;
395
403
  };
396
404
 
397
- 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 ITestResult, type IUserData, type InsertOrUpdateRequestBody, type InsertOrUpdateResponseData, Language, LearningStage, Lexeme, LexemePair, type LexemePairRequestBody, type LexemePairWithLang, type MySQLDate, Progress, type RecycleLexemePairParams, 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 UpdateOnboardingStatusRequestBody, type UpdateUserRequestBody, VocabCheckType, convertJSDateStringToMySQLDate, dateDifferenceInDays, getFormattedDate, getMysqlDateIgnoreTZ, isClientDateTooFarFromServerDate, isStringContainingInteger, isThePreviousDay, isTheSameDay, isValidJsDateString, isValidMysqlDateString, parameterReplace };
405
+ 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 ISession, type ITestResult, type IUserData, type InsertOrUpdateRequestBody, type InsertOrUpdateResponseData, Language, LearningStage, Lexeme, LexemePair, type LexemePairRequestBody, type LexemePairWithLang, type MySQLDate, Progress, type RecycleLexemePairParams, 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 UpdateOnboardingStatusRequestBody, type UpdateUserRequestBody, VocabCheckType, convertJSDateStringToMySQLDate, dateDifferenceInDays, getFormattedDate, getMysqlDateIgnoreTZ, isClientDateTooFarFromServerDate, isExpired, isStringContainingInteger, isThePreviousDay, isTheSameDay, isValidJsDateString, isValidMysqlDateString, parameterReplace };
package/dist/index.d.ts CHANGED
@@ -49,7 +49,16 @@ declare const dateDifferenceInDays: (date1: MySQLDate, date2: MySQLDate) => numb
49
49
  declare const isThePreviousDay: (date: MySQLDate, referenceDate: MySQLDate) => boolean;
50
50
  declare const isTheSameDay: (date1: MySQLDate, date2: MySQLDate) => boolean;
51
51
  declare const getFormattedDate: (date: Date) => string;
52
+ declare const isExpired: (date: MySQLDate) => boolean;
52
53
 
54
+ interface ISession {
55
+ sessionToken: string | undefined;
56
+ deviceId: string | undefined;
57
+ googleSub: string;
58
+ sessionExpiry: MySQLDate | null;
59
+ sessionCreated: MySQLDate;
60
+ lastAutoLogin: MySQLDate;
61
+ }
53
62
  declare enum Language {
54
63
  CZECH = "CZECH",
55
64
  ENGLISH = "ENGLISH",
@@ -294,7 +303,6 @@ interface InsertOrUpdateRequestBody {
294
303
  pairingNotes: string;
295
304
  }
296
305
  interface SignInRequestBody {
297
- rememberMe: boolean;
298
306
  }
299
307
  interface UpdateOnboardingStatusRequestBody {
300
308
  onboardingStatus: boolean;
@@ -369,8 +377,8 @@ interface InsertOrUpdateResponseData {
369
377
  newMappingInserted?: boolean;
370
378
  }
371
379
  interface SignInResponseData {
372
- expiryDate: number;
373
- user: IUserData;
380
+ user: Partial<IUserData>;
381
+ sessionToken: string | undefined;
374
382
  }
375
383
  interface TestInitResponseData {
376
384
  lexemePairs: ILexemePair[];
@@ -394,4 +402,4 @@ type DeeplTranslation = {
394
402
  }>;
395
403
  };
396
404
 
397
- 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 ITestResult, type IUserData, type InsertOrUpdateRequestBody, type InsertOrUpdateResponseData, Language, LearningStage, Lexeme, LexemePair, type LexemePairRequestBody, type LexemePairWithLang, type MySQLDate, Progress, type RecycleLexemePairParams, 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 UpdateOnboardingStatusRequestBody, type UpdateUserRequestBody, VocabCheckType, convertJSDateStringToMySQLDate, dateDifferenceInDays, getFormattedDate, getMysqlDateIgnoreTZ, isClientDateTooFarFromServerDate, isStringContainingInteger, isThePreviousDay, isTheSameDay, isValidJsDateString, isValidMysqlDateString, parameterReplace };
405
+ 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 ISession, type ITestResult, type IUserData, type InsertOrUpdateRequestBody, type InsertOrUpdateResponseData, Language, LearningStage, Lexeme, LexemePair, type LexemePairRequestBody, type LexemePairWithLang, type MySQLDate, Progress, type RecycleLexemePairParams, 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 UpdateOnboardingStatusRequestBody, type UpdateUserRequestBody, VocabCheckType, convertJSDateStringToMySQLDate, dateDifferenceInDays, getFormattedDate, getMysqlDateIgnoreTZ, isClientDateTooFarFromServerDate, isExpired, isStringContainingInteger, isThePreviousDay, isTheSameDay, isValidJsDateString, isValidMysqlDateString, parameterReplace };
package/dist/index.js CHANGED
@@ -38,6 +38,7 @@ __export(index_exports, {
38
38
  getFormattedDate: () => getFormattedDate,
39
39
  getMysqlDateIgnoreTZ: () => getMysqlDateIgnoreTZ,
40
40
  isClientDateTooFarFromServerDate: () => isClientDateTooFarFromServerDate,
41
+ isExpired: () => isExpired,
41
42
  isStringContainingInteger: () => isStringContainingInteger,
42
43
  isThePreviousDay: () => isThePreviousDay,
43
44
  isTheSameDay: () => isTheSameDay,
@@ -104,6 +105,11 @@ var getFormattedDate = (date) => {
104
105
  const day = date.getDate().toString().padStart(2, "0");
105
106
  return `${year}-${month}-${day}`;
106
107
  };
108
+ var isExpired = (date) => {
109
+ const now = /* @__PURE__ */ new Date();
110
+ const dateObj = new Date(date);
111
+ return dateObj.getTime() < now.getTime();
112
+ };
107
113
 
108
114
  // src/design/types.ts
109
115
  var Language = /* @__PURE__ */ ((Language2) => {
@@ -285,6 +291,7 @@ var ClientPlatform = /* @__PURE__ */ ((ClientPlatform2) => {
285
291
  getFormattedDate,
286
292
  getMysqlDateIgnoreTZ,
287
293
  isClientDateTooFarFromServerDate,
294
+ isExpired,
288
295
  isStringContainingInteger,
289
296
  isThePreviousDay,
290
297
  isTheSameDay,
package/dist/index.mjs CHANGED
@@ -55,6 +55,11 @@ var getFormattedDate = (date) => {
55
55
  const day = date.getDate().toString().padStart(2, "0");
56
56
  return `${year}-${month}-${day}`;
57
57
  };
58
+ var isExpired = (date) => {
59
+ const now = /* @__PURE__ */ new Date();
60
+ const dateObj = new Date(date);
61
+ return dateObj.getTime() < now.getTime();
62
+ };
58
63
 
59
64
  // src/design/types.ts
60
65
  var Language = /* @__PURE__ */ ((Language2) => {
@@ -235,6 +240,7 @@ export {
235
240
  getFormattedDate,
236
241
  getMysqlDateIgnoreTZ,
237
242
  isClientDateTooFarFromServerDate,
243
+ isExpired,
238
244
  isStringContainingInteger,
239
245
  isThePreviousDay,
240
246
  isTheSameDay,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "czapp-shared",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
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",
@@ -107,3 +107,9 @@ export const getFormattedDate = (date: Date) => {
107
107
 
108
108
  return `${year}-${month}-${day}`;
109
109
  }
110
+
111
+ export const isExpired = (date: MySQLDate): boolean => {
112
+ const now = new Date();
113
+ const dateObj = new Date(date);
114
+ return dateObj.getTime() < now.getTime();
115
+ }
@@ -9,7 +9,7 @@ export class Lexeme implements ILexeme {
9
9
  userId: string = "";
10
10
  constructor(userId: string) {
11
11
  this.userId = userId;
12
- this.dateAdded = getMysqlDateIgnoreTZ(new Date());
12
+ this.dateAdded = getMysqlDateIgnoreTZ(new Date())!;
13
13
  }
14
14
  }
15
15
 
package/src/design/api.ts CHANGED
@@ -87,7 +87,6 @@ export interface InsertOrUpdateRequestBody {
87
87
  pairingNotes: string;
88
88
  }
89
89
  export interface SignInRequestBody {
90
- rememberMe: boolean;
91
90
  }
92
91
 
93
92
  export interface UpdateOnboardingStatusRequestBody {
@@ -171,8 +170,8 @@ export interface InsertOrUpdateResponseData {
171
170
  newMappingInserted?: boolean
172
171
  }
173
172
  export interface SignInResponseData {
174
- expiryDate: number;
175
- user: IUserData;
173
+ user: Partial<IUserData>;
174
+ sessionToken: string | undefined;
176
175
  }
177
176
  export interface TestInitResponseData {
178
177
  lexemePairs: ILexemePair[];
@@ -1,5 +1,14 @@
1
1
  import { ILexemePair } from './lexemes';
2
2
 
3
+ export interface ISession {
4
+ sessionToken: string | undefined;
5
+ deviceId: string | undefined;
6
+ googleSub: string;
7
+ sessionExpiry: MySQLDate | null; // null means no expiry date
8
+ sessionCreated: MySQLDate;
9
+ lastAutoLogin: MySQLDate;
10
+ }
11
+
3
12
  export enum Language {
4
13
  CZECH = "CZECH",
5
14
  ENGLISH = "ENGLISH",