czapp-shared 1.0.10 → 1.0.12
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 +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +8 -8
- package/dist/index.mjs +7 -7
- package/package.json +1 -1
- package/src/concrete/date.ts +0 -15
- package/src/design/api.ts +6 -0
- package/test/date.test.ts +6 -13
package/dist/index.d.mts
CHANGED
|
@@ -6,11 +6,6 @@
|
|
|
6
6
|
* @returns MySQLDate in the format "2021-01-01 07:41:23" or undefined if the input date is invalid
|
|
7
7
|
*/
|
|
8
8
|
declare const getMysqlDateIgnoreTZ: (date: Date) => MySQLDate | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* @name getMysqlDateAllowingForTZ
|
|
11
|
-
* @param date
|
|
12
|
-
*/
|
|
13
|
-
declare const getMysqlDateAllowingForTZ: (date: Date) => MySQLDate;
|
|
14
9
|
/**
|
|
15
10
|
* @name convertJSDateStringToMySQLDate
|
|
16
11
|
* @description Converts a JavaScript Date object to a MySQL date string
|
|
@@ -247,6 +242,11 @@ declare enum ApiPath {
|
|
|
247
242
|
USER = "/user",
|
|
248
243
|
USER_RESET_TEST = "/user/test/reset/:flashcardReviewCompletedCount/:currentStreakEnd"
|
|
249
244
|
}
|
|
245
|
+
declare enum ClientPlatform {
|
|
246
|
+
IOS = "ios",
|
|
247
|
+
ANDROID = "android",
|
|
248
|
+
WEB = "web"
|
|
249
|
+
}
|
|
250
250
|
/**
|
|
251
251
|
* Request payloads
|
|
252
252
|
*/
|
|
@@ -278,6 +278,7 @@ interface AutologinRequestBody {
|
|
|
278
278
|
interface InsertOrUpdateRequestBody {
|
|
279
279
|
czLexeme: ILexeme;
|
|
280
280
|
enLexeme: ILexeme;
|
|
281
|
+
clientDate: MySQLDate;
|
|
281
282
|
pairingNotes: string;
|
|
282
283
|
}
|
|
283
284
|
interface SignInRequestBody {
|
|
@@ -362,4 +363,4 @@ type DeeplTranslation = {
|
|
|
362
363
|
}>;
|
|
363
364
|
};
|
|
364
365
|
|
|
365
|
-
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,
|
|
366
|
+
export { ApiMethod, ApiPath, AppError, type AutologinRequestBody, ClientPlatform, 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, getMysqlDateIgnoreTZ, isClientDateTooFarFromServerDate, isStringContainingInteger, isThePreviousDay, isTheSameDay, isValidJsDateString, isValidMysqlDateString, parameterReplace };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,11 +6,6 @@
|
|
|
6
6
|
* @returns MySQLDate in the format "2021-01-01 07:41:23" or undefined if the input date is invalid
|
|
7
7
|
*/
|
|
8
8
|
declare const getMysqlDateIgnoreTZ: (date: Date) => MySQLDate | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* @name getMysqlDateAllowingForTZ
|
|
11
|
-
* @param date
|
|
12
|
-
*/
|
|
13
|
-
declare const getMysqlDateAllowingForTZ: (date: Date) => MySQLDate;
|
|
14
9
|
/**
|
|
15
10
|
* @name convertJSDateStringToMySQLDate
|
|
16
11
|
* @description Converts a JavaScript Date object to a MySQL date string
|
|
@@ -247,6 +242,11 @@ declare enum ApiPath {
|
|
|
247
242
|
USER = "/user",
|
|
248
243
|
USER_RESET_TEST = "/user/test/reset/:flashcardReviewCompletedCount/:currentStreakEnd"
|
|
249
244
|
}
|
|
245
|
+
declare enum ClientPlatform {
|
|
246
|
+
IOS = "ios",
|
|
247
|
+
ANDROID = "android",
|
|
248
|
+
WEB = "web"
|
|
249
|
+
}
|
|
250
250
|
/**
|
|
251
251
|
* Request payloads
|
|
252
252
|
*/
|
|
@@ -278,6 +278,7 @@ interface AutologinRequestBody {
|
|
|
278
278
|
interface InsertOrUpdateRequestBody {
|
|
279
279
|
czLexeme: ILexeme;
|
|
280
280
|
enLexeme: ILexeme;
|
|
281
|
+
clientDate: MySQLDate;
|
|
281
282
|
pairingNotes: string;
|
|
282
283
|
}
|
|
283
284
|
interface SignInRequestBody {
|
|
@@ -362,4 +363,4 @@ type DeeplTranslation = {
|
|
|
362
363
|
}>;
|
|
363
364
|
};
|
|
364
365
|
|
|
365
|
-
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,
|
|
366
|
+
export { ApiMethod, ApiPath, AppError, type AutologinRequestBody, ClientPlatform, 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, getMysqlDateIgnoreTZ, isClientDateTooFarFromServerDate, isStringContainingInteger, isThePreviousDay, isTheSameDay, isValidJsDateString, isValidMysqlDateString, parameterReplace };
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ __export(src_exports, {
|
|
|
22
22
|
ApiMethod: () => ApiMethod,
|
|
23
23
|
ApiPath: () => ApiPath,
|
|
24
24
|
AppError: () => AppError,
|
|
25
|
+
ClientPlatform: () => ClientPlatform,
|
|
25
26
|
Familiarity: () => Familiarity,
|
|
26
27
|
HttpStatusCode: () => HttpStatusCode,
|
|
27
28
|
Language: () => Language,
|
|
@@ -35,7 +36,6 @@ __export(src_exports, {
|
|
|
35
36
|
convertJSDateStringToMySQLDate: () => convertJSDateStringToMySQLDate,
|
|
36
37
|
dateDifferenceInDays: () => dateDifferenceInDays,
|
|
37
38
|
getFormattedDate: () => getFormattedDate,
|
|
38
|
-
getMysqlDateAllowingForTZ: () => getMysqlDateAllowingForTZ,
|
|
39
39
|
getMysqlDateIgnoreTZ: () => getMysqlDateIgnoreTZ,
|
|
40
40
|
isClientDateTooFarFromServerDate: () => isClientDateTooFarFromServerDate,
|
|
41
41
|
isStringContainingInteger: () => isStringContainingInteger,
|
|
@@ -61,12 +61,6 @@ var getMysqlDateIgnoreTZ = (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
|
-
};
|
|
70
64
|
var convertJSDateStringToMySQLDate = (date) => {
|
|
71
65
|
let dateStr;
|
|
72
66
|
try {
|
|
@@ -259,11 +253,18 @@ var ApiPath = /* @__PURE__ */ ((ApiPath2) => {
|
|
|
259
253
|
ApiPath2["USER_RESET_TEST"] = "/user/test/reset/:flashcardReviewCompletedCount/:currentStreakEnd";
|
|
260
254
|
return ApiPath2;
|
|
261
255
|
})(ApiPath || {});
|
|
256
|
+
var ClientPlatform = /* @__PURE__ */ ((ClientPlatform2) => {
|
|
257
|
+
ClientPlatform2["IOS"] = "ios";
|
|
258
|
+
ClientPlatform2["ANDROID"] = "android";
|
|
259
|
+
ClientPlatform2["WEB"] = "web";
|
|
260
|
+
return ClientPlatform2;
|
|
261
|
+
})(ClientPlatform || {});
|
|
262
262
|
// Annotate the CommonJS export names for ESM import in node:
|
|
263
263
|
0 && (module.exports = {
|
|
264
264
|
ApiMethod,
|
|
265
265
|
ApiPath,
|
|
266
266
|
AppError,
|
|
267
|
+
ClientPlatform,
|
|
267
268
|
Familiarity,
|
|
268
269
|
HttpStatusCode,
|
|
269
270
|
Language,
|
|
@@ -277,7 +278,6 @@ var ApiPath = /* @__PURE__ */ ((ApiPath2) => {
|
|
|
277
278
|
convertJSDateStringToMySQLDate,
|
|
278
279
|
dateDifferenceInDays,
|
|
279
280
|
getFormattedDate,
|
|
280
|
-
getMysqlDateAllowingForTZ,
|
|
281
281
|
getMysqlDateIgnoreTZ,
|
|
282
282
|
isClientDateTooFarFromServerDate,
|
|
283
283
|
isStringContainingInteger,
|
package/dist/index.mjs
CHANGED
|
@@ -12,12 +12,6 @@ var getMysqlDateIgnoreTZ = (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
|
-
};
|
|
21
15
|
var convertJSDateStringToMySQLDate = (date) => {
|
|
22
16
|
let dateStr;
|
|
23
17
|
try {
|
|
@@ -210,10 +204,17 @@ var ApiPath = /* @__PURE__ */ ((ApiPath2) => {
|
|
|
210
204
|
ApiPath2["USER_RESET_TEST"] = "/user/test/reset/:flashcardReviewCompletedCount/:currentStreakEnd";
|
|
211
205
|
return ApiPath2;
|
|
212
206
|
})(ApiPath || {});
|
|
207
|
+
var ClientPlatform = /* @__PURE__ */ ((ClientPlatform2) => {
|
|
208
|
+
ClientPlatform2["IOS"] = "ios";
|
|
209
|
+
ClientPlatform2["ANDROID"] = "android";
|
|
210
|
+
ClientPlatform2["WEB"] = "web";
|
|
211
|
+
return ClientPlatform2;
|
|
212
|
+
})(ClientPlatform || {});
|
|
213
213
|
export {
|
|
214
214
|
ApiMethod,
|
|
215
215
|
ApiPath,
|
|
216
216
|
AppError,
|
|
217
|
+
ClientPlatform,
|
|
217
218
|
Familiarity,
|
|
218
219
|
HttpStatusCode,
|
|
219
220
|
Language,
|
|
@@ -227,7 +228,6 @@ export {
|
|
|
227
228
|
convertJSDateStringToMySQLDate,
|
|
228
229
|
dateDifferenceInDays,
|
|
229
230
|
getFormattedDate,
|
|
230
|
-
getMysqlDateAllowingForTZ,
|
|
231
231
|
getMysqlDateIgnoreTZ,
|
|
232
232
|
isClientDateTooFarFromServerDate,
|
|
233
233
|
isStringContainingInteger,
|
package/package.json
CHANGED
package/src/concrete/date.ts
CHANGED
|
@@ -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
|
@@ -41,6 +41,11 @@ export enum ApiPath {
|
|
|
41
41
|
USER_RESET_TEST = '/user/test/reset/:flashcardReviewCompletedCount/:currentStreakEnd',
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
export enum ClientPlatform {
|
|
45
|
+
IOS = 'ios',
|
|
46
|
+
ANDROID = 'android',
|
|
47
|
+
WEB = 'web'
|
|
48
|
+
}
|
|
44
49
|
|
|
45
50
|
/**
|
|
46
51
|
* Request payloads
|
|
@@ -73,6 +78,7 @@ export interface AutologinRequestBody {
|
|
|
73
78
|
export interface InsertOrUpdateRequestBody {
|
|
74
79
|
czLexeme: ILexeme;
|
|
75
80
|
enLexeme: ILexeme;
|
|
81
|
+
clientDate: MySQLDate;
|
|
76
82
|
pairingNotes: string;
|
|
77
83
|
}
|
|
78
84
|
export interface SignInRequestBody {
|
package/test/date.test.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
2
|
import {
|
|
3
3
|
getMysqlDateIgnoreTZ,
|
|
4
|
-
convertJSDateStringToMySQLDate,
|
|
4
|
+
convertJSDateStringToMySQLDate,
|
|
5
|
+
dateDifferenceInDays,
|
|
6
|
+
isClientDateTooFarFromServerDate,
|
|
5
7
|
isThePreviousDay,
|
|
6
|
-
isTheSameDay,
|
|
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";
|