@laboratory-one/api-components 0.0.10 → 0.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/cjs/auth/auth.service.d.ts.map +1 -1
- package/dist/cjs/auth/auth.service.js +13 -2
- package/dist/cjs/auth/auth.service.js.map +1 -1
- package/dist/cjs/utils/datetime.util.d.ts +8 -0
- package/dist/cjs/utils/datetime.util.d.ts.map +1 -0
- package/dist/cjs/utils/datetime.util.js +46 -0
- package/dist/cjs/utils/datetime.util.js.map +1 -0
- package/dist/cjs/utils/{error.d.ts → error.util.d.ts} +1 -1
- package/dist/cjs/utils/error.util.d.ts.map +1 -0
- package/dist/cjs/utils/{error.js → error.util.js} +1 -1
- package/dist/cjs/utils/error.util.js.map +1 -0
- package/dist/cjs/utils/index.d.ts +4 -4
- package/dist/cjs/utils/index.d.ts.map +1 -1
- package/dist/cjs/utils/index.js +4 -4
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/{input.d.ts → input.util.d.ts} +1 -1
- package/dist/cjs/utils/input.util.d.ts.map +1 -0
- package/dist/cjs/utils/{input.js → input.util.js} +1 -1
- package/dist/cjs/utils/input.util.js.map +1 -0
- package/dist/cjs/utils/noop.util.d.ts +2 -0
- package/dist/cjs/utils/noop.util.d.ts.map +1 -0
- package/dist/cjs/utils/noop.util.js +6 -0
- package/dist/cjs/utils/noop.util.js.map +1 -0
- package/dist/cjs/utils/{string.d.ts → string.util.d.ts} +1 -1
- package/dist/cjs/utils/string.util.d.ts.map +1 -0
- package/dist/cjs/utils/{string.js → string.util.js} +1 -1
- package/dist/cjs/utils/string.util.js.map +1 -0
- package/dist/esm/auth/auth.service.d.ts.map +1 -1
- package/dist/esm/auth/auth.service.js +13 -2
- package/dist/esm/auth/auth.service.js.map +1 -1
- package/dist/esm/utils/datetime.util.d.ts +8 -0
- package/dist/esm/utils/datetime.util.d.ts.map +1 -0
- package/dist/esm/utils/{datetime.js → datetime.util.js} +13 -3
- package/dist/esm/utils/datetime.util.js.map +1 -0
- package/dist/esm/utils/{error.d.ts → error.util.d.ts} +1 -1
- package/dist/esm/utils/error.util.d.ts.map +1 -0
- package/dist/esm/utils/{error.js → error.util.js} +1 -1
- package/dist/esm/utils/error.util.js.map +1 -0
- package/dist/esm/utils/index.d.ts +4 -4
- package/dist/esm/utils/index.d.ts.map +1 -1
- package/dist/esm/utils/index.js +4 -4
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/{input.d.ts → input.util.d.ts} +1 -1
- package/dist/esm/utils/input.util.d.ts.map +1 -0
- package/dist/esm/utils/{input.js → input.util.js} +1 -1
- package/dist/esm/utils/input.util.js.map +1 -0
- package/dist/esm/utils/noop.util.d.ts +2 -0
- package/dist/esm/utils/noop.util.d.ts.map +1 -0
- package/dist/esm/utils/noop.util.js +2 -0
- package/dist/esm/utils/noop.util.js.map +1 -0
- package/dist/esm/utils/{string.d.ts → string.util.d.ts} +1 -1
- package/dist/esm/utils/string.util.d.ts.map +1 -0
- package/dist/esm/utils/{string.js → string.util.js} +1 -1
- package/dist/esm/utils/string.util.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/auth/auth.service.ts +13 -3
- package/src/utils/{datetime.ts → datetime.util.ts} +15 -2
- package/src/utils/index.ts +4 -4
- package/src/utils/noop.util.ts +1 -0
- package/dist/cjs/utils/datetime.d.ts +0 -6
- package/dist/cjs/utils/datetime.d.ts.map +0 -1
- package/dist/cjs/utils/datetime.js +0 -33
- package/dist/cjs/utils/datetime.js.map +0 -1
- package/dist/cjs/utils/error.d.ts.map +0 -1
- package/dist/cjs/utils/error.js.map +0 -1
- package/dist/cjs/utils/input.d.ts.map +0 -1
- package/dist/cjs/utils/input.js.map +0 -1
- package/dist/cjs/utils/noop.d.ts +0 -2
- package/dist/cjs/utils/noop.d.ts.map +0 -1
- package/dist/cjs/utils/noop.js +0 -6
- package/dist/cjs/utils/noop.js.map +0 -1
- package/dist/cjs/utils/string.d.ts.map +0 -1
- package/dist/cjs/utils/string.js.map +0 -1
- package/dist/esm/utils/datetime.d.ts +0 -6
- package/dist/esm/utils/datetime.d.ts.map +0 -1
- package/dist/esm/utils/datetime.js.map +0 -1
- package/dist/esm/utils/error.d.ts.map +0 -1
- package/dist/esm/utils/error.js.map +0 -1
- package/dist/esm/utils/input.d.ts.map +0 -1
- package/dist/esm/utils/input.js.map +0 -1
- package/dist/esm/utils/noop.d.ts +0 -2
- package/dist/esm/utils/noop.d.ts.map +0 -1
- package/dist/esm/utils/noop.js +0 -2
- package/dist/esm/utils/noop.js.map +0 -1
- package/dist/esm/utils/string.d.ts.map +0 -1
- package/dist/esm/utils/string.js.map +0 -1
- package/src/utils/noop.ts +0 -1
- /package/src/utils/{error.ts → error.util.ts} +0 -0
- /package/src/utils/{input.ts → input.util.ts} +0 -0
- /package/src/utils/{string.ts → string.util.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.d.ts","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.service.d.ts","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAGvE,qBACa,WAAW;IAIV,OAAO,CAAC,aAAa;IAHjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAC/D,OAAO,CAAC,UAAU,CAAgB;gBAEd,aAAa,EAAE,aAAa;IAW1C,MAAM,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAQlD,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;CAgBxD"}
|
|
@@ -6,6 +6,7 @@ const tslib_1 = require("tslib");
|
|
|
6
6
|
const common_1 = require("@nestjs/common");
|
|
7
7
|
const stytch = tslib_1.__importStar(require("stytch"));
|
|
8
8
|
const config_1 = require("@nestjs/config");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
9
10
|
let AuthService = AuthService_1 = class AuthService {
|
|
10
11
|
constructor(configService) {
|
|
11
12
|
this.configService = configService;
|
|
@@ -25,8 +26,18 @@ let AuthService = AuthService_1 = class AuthService {
|
|
|
25
26
|
}
|
|
26
27
|
async login(data) {
|
|
27
28
|
this.logger.debug('login');
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
try {
|
|
30
|
+
const res = await this.authClient.passwords.authenticate(data);
|
|
31
|
+
return res['status_code'] === 200;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error.error_type === 'email_not_found') {
|
|
35
|
+
(0, utils_1.handleError)('Email or password is wrong');
|
|
36
|
+
}
|
|
37
|
+
if (error.error_type === 'unauthorized_credentials') {
|
|
38
|
+
(0, utils_1.handleError)('Email or password is wrong');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
30
41
|
}
|
|
31
42
|
};
|
|
32
43
|
exports.AuthService = AuthService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.js","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":";;;;;AAAA,2CAAoD;AACpD,uDAAiC;AACjC,2CAA+C;
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":";;;;;AAAA,2CAAoD;AACpD,uDAAiC;AACjC,2CAA+C;AAG/C,oCAAuC;AAGhC,IAAM,WAAW,mBAAjB,MAAM,WAAW;IAItB,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAH/B,WAAM,GAAW,IAAI,eAAM,CAAC,aAAW,CAAC,IAAI,CAAC,CAAC;QAI7D,IAAI,CAAC,UAAU,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC;YAClC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,mBAAmB,CAAC;YAC/D,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,eAAe,CAAC;YACvD,GAAG,EACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,YAAY,CAAC,KAAK,MAAM;gBACrD,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI;gBAClB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI;SACvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAwB;QACnC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE5B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEzD,OAAO,GAAG,CAAC,aAAa,CAAC,KAAK,GAAG,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,IAAwB;QAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAE3B,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAC/D,OAAO,GAAG,CAAC,aAAa,CAAC,KAAK,GAAG,CAAC;QACpC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,KAAK,CAAC,UAAU,KAAK,iBAAiB,EAAE,CAAC;gBAC3C,IAAA,mBAAW,EAAC,4BAA4B,CAAC,CAAC;YAC5C,CAAC;YAED,IAAI,KAAK,CAAC,UAAU,KAAK,0BAA0B,EAAE,CAAC;gBACpD,IAAA,mBAAW,EAAC,4BAA4B,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AAvCY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;6CAKwB,sBAAa;GAJrC,WAAW,CAuCvB","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\nimport * as stytch from 'stytch';\nimport { ConfigService } from '@nestjs/config';\n\nimport { RegisterRequestDto } from '../user/dtos/register.request.dto';\nimport { handleError } from '../utils';\n\n@Injectable()\nexport class AuthService {\n private readonly logger: Logger = new Logger(AuthService.name);\n private authClient: stytch.Client;\n\n constructor(private configService: ConfigService) {\n this.authClient = new stytch.Client({\n project_id: this.configService.get<string>('STYTCH_PROJECT_ID'),\n secret: this.configService.get<string>('STYTCH_SECRET'),\n env:\n this.configService.get<string>('STYTCH_ENV') === 'test'\n ? stytch.envs.test\n : stytch.envs.live,\n });\n }\n\n async signup(data: RegisterRequestDto): Promise<boolean> {\n this.logger.debug('signup');\n\n const res = await this.authClient.passwords.create(data);\n\n return res['status_code'] === 200;\n }\n\n async login(data: RegisterRequestDto): Promise<boolean> {\n this.logger.debug('login');\n\n try {\n const res = await this.authClient.passwords.authenticate(data);\n return res['status_code'] === 200;\n } catch (error: any) {\n if (error.error_type === 'email_not_found') {\n handleError('Email or password is wrong');\n }\n\n if (error.error_type === 'unauthorized_credentials') {\n handleError('Email or password is wrong');\n }\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EServerDay, EHumanDay } from '../enums';
|
|
2
|
+
import { Moment } from 'moment';
|
|
3
|
+
export declare const serverDayToHumanReadable: (day: EServerDay) => EHumanDay;
|
|
4
|
+
export declare const getStartOfDateString: (date: Moment) => string;
|
|
5
|
+
export declare const getStartOfTodayString: () => string;
|
|
6
|
+
export declare const getCurrentHour: () => number;
|
|
7
|
+
export declare const getDateWithTz: (date: string, tz: number) => string;
|
|
8
|
+
//# sourceMappingURL=datetime.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime.util.d.ts","sourceRoot":"/","sources":["utils/datetime.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACjD,OAAe,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,eAAO,MAAM,wBAAwB,QAAS,UAAU,KAAG,SAmB1D,CAAC;AAEF,eAAO,MAAM,oBAAoB,SAAU,MAAM,KAAG,MAEnD,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAAO,MAExC,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,MAEjC,CAAC;AAEF,eAAO,MAAM,aAAa,SAAU,MAAM,MAAM,MAAM,KAAG,MAIxD,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDateWithTz = exports.getCurrentHour = exports.getStartOfTodayString = exports.getStartOfDateString = exports.serverDayToHumanReadable = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const enums_1 = require("../enums");
|
|
6
|
+
const moment_1 = tslib_1.__importDefault(require("moment"));
|
|
7
|
+
const serverDayToHumanReadable = (day) => {
|
|
8
|
+
switch (day) {
|
|
9
|
+
case enums_1.EServerDay.SUNDAY:
|
|
10
|
+
return enums_1.EHumanDay.SUNDAY;
|
|
11
|
+
case enums_1.EServerDay.MONDAY:
|
|
12
|
+
return enums_1.EHumanDay.MONDAY;
|
|
13
|
+
case enums_1.EServerDay.TUESDAY:
|
|
14
|
+
return enums_1.EHumanDay.TUESDAY;
|
|
15
|
+
case enums_1.EServerDay.WEDNESDAY:
|
|
16
|
+
return enums_1.EHumanDay.WEDNESDAY;
|
|
17
|
+
case enums_1.EServerDay.THURSDAY:
|
|
18
|
+
return enums_1.EHumanDay.THURSDAY;
|
|
19
|
+
case enums_1.EServerDay.FRIDAY:
|
|
20
|
+
return enums_1.EHumanDay.FRIDAY;
|
|
21
|
+
case enums_1.EServerDay.SATURDAY:
|
|
22
|
+
return enums_1.EHumanDay.SATURDAY;
|
|
23
|
+
default:
|
|
24
|
+
return enums_1.EHumanDay.SUNDAY;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.serverDayToHumanReadable = serverDayToHumanReadable;
|
|
28
|
+
const getStartOfDateString = (date) => {
|
|
29
|
+
return (0, moment_1.default)(date).utc().startOf('day').toDate().toISOString();
|
|
30
|
+
};
|
|
31
|
+
exports.getStartOfDateString = getStartOfDateString;
|
|
32
|
+
const getStartOfTodayString = () => {
|
|
33
|
+
return (0, exports.getStartOfDateString)((0, moment_1.default)());
|
|
34
|
+
};
|
|
35
|
+
exports.getStartOfTodayString = getStartOfTodayString;
|
|
36
|
+
const getCurrentHour = () => {
|
|
37
|
+
return (0, moment_1.default)().hour();
|
|
38
|
+
};
|
|
39
|
+
exports.getCurrentHour = getCurrentHour;
|
|
40
|
+
const getDateWithTz = (date, tz) => {
|
|
41
|
+
const dateMoment = (0, moment_1.default)(date).utcOffset(tz);
|
|
42
|
+
dateMoment.add(tz, 'hours');
|
|
43
|
+
return dateMoment.format('YYYY-MM-DD');
|
|
44
|
+
};
|
|
45
|
+
exports.getDateWithTz = getDateWithTz;
|
|
46
|
+
//# sourceMappingURL=datetime.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime.util.js","sourceRoot":"/","sources":["utils/datetime.util.ts"],"names":[],"mappings":";;;;AAAA,oCAAiD;AACjD,4DAAwC;AAEjC,MAAM,wBAAwB,GAAG,CAAC,GAAe,EAAa,EAAE;IACrE,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,kBAAU,CAAC,MAAM;YACpB,OAAO,iBAAS,CAAC,MAAM,CAAC;QAC1B,KAAK,kBAAU,CAAC,MAAM;YACpB,OAAO,iBAAS,CAAC,MAAM,CAAC;QAC1B,KAAK,kBAAU,CAAC,OAAO;YACrB,OAAO,iBAAS,CAAC,OAAO,CAAC;QAC3B,KAAK,kBAAU,CAAC,SAAS;YACvB,OAAO,iBAAS,CAAC,SAAS,CAAC;QAC7B,KAAK,kBAAU,CAAC,QAAQ;YACtB,OAAO,iBAAS,CAAC,QAAQ,CAAC;QAC5B,KAAK,kBAAU,CAAC,MAAM;YACpB,OAAO,iBAAS,CAAC,MAAM,CAAC;QAC1B,KAAK,kBAAU,CAAC,QAAQ;YACtB,OAAO,iBAAS,CAAC,QAAQ,CAAC;QAC5B;YACE,OAAO,iBAAS,CAAC,MAAM,CAAC;IAC5B,CAAC;AACH,CAAC,CAAC;AAnBW,QAAA,wBAAwB,4BAmBnC;AAEK,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAU,EAAE;IAC3D,OAAO,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;AAClE,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B;AAEK,MAAM,qBAAqB,GAAG,GAAW,EAAE;IAChD,OAAO,IAAA,4BAAoB,EAAC,IAAA,gBAAM,GAAE,CAAC,CAAC;AACxC,CAAC,CAAC;AAFW,QAAA,qBAAqB,yBAEhC;AAEK,MAAM,cAAc,GAAG,GAAW,EAAE;IACzC,OAAO,IAAA,gBAAM,GAAE,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC,CAAC;AAFW,QAAA,cAAc,kBAEzB;AAEK,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,EAAU,EAAU,EAAE;IAChE,MAAM,UAAU,GAAG,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC9C,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAC5B,OAAO,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AACzC,CAAC,CAAC;AAJW,QAAA,aAAa,iBAIxB","sourcesContent":["import { EServerDay, EHumanDay } from '../enums';\nimport moment, { Moment } from 'moment';\n\nexport const serverDayToHumanReadable = (day: EServerDay): EHumanDay => {\n switch (day) {\n case EServerDay.SUNDAY:\n return EHumanDay.SUNDAY;\n case EServerDay.MONDAY:\n return EHumanDay.MONDAY;\n case EServerDay.TUESDAY:\n return EHumanDay.TUESDAY;\n case EServerDay.WEDNESDAY:\n return EHumanDay.WEDNESDAY;\n case EServerDay.THURSDAY:\n return EHumanDay.THURSDAY;\n case EServerDay.FRIDAY:\n return EHumanDay.FRIDAY;\n case EServerDay.SATURDAY:\n return EHumanDay.SATURDAY;\n default:\n return EHumanDay.SUNDAY;\n }\n};\n\nexport const getStartOfDateString = (date: Moment): string => {\n return moment(date).utc().startOf('day').toDate().toISOString();\n};\n\nexport const getStartOfTodayString = (): string => {\n return getStartOfDateString(moment());\n};\n\nexport const getCurrentHour = (): number => {\n return moment().hour();\n};\n\nexport const getDateWithTz = (date: string, tz: number): string => {\n const dateMoment = moment(date).utcOffset(tz);\n dateMoment.add(tz, 'hours');\n return dateMoment.format('YYYY-MM-DD');\n};\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const handleError: (error: any) => never;
|
|
2
|
-
//# sourceMappingURL=error.d.ts.map
|
|
2
|
+
//# sourceMappingURL=error.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.util.d.ts","sourceRoot":"/","sources":["utils/error.util.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,UAAW,GAAG,UAQrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.util.js","sourceRoot":"/","sources":["utils/error.util.ts"],"names":[],"mappings":";;;AAAA,2CAA2D;AAEpD,MAAM,WAAW,GAAG,CAAC,KAAU,EAAE,EAAE;IACxC,IAAI,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,sBAAa,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,mBAAU,CAAC,WAAW,CAAC,CAAC;IAC1E,CAAC;SAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QACzB,MAAM,IAAI,sBAAa,CAAC,KAAK,CAAC,OAAO,EAAE,mBAAU,CAAC,WAAW,CAAC,CAAC;IACjE,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,sBAAa,CAAC,KAAK,EAAE,mBAAU,CAAC,WAAW,CAAC,CAAC;IACzD,CAAC;AACH,CAAC,CAAC;AARW,QAAA,WAAW,eAQtB","sourcesContent":["import { HttpException, HttpStatus } from '@nestjs/common';\n\nexport const handleError = (error: any) => {\n if (error['error_message']) {\n throw new HttpException(error['error_message'], HttpStatus.BAD_REQUEST);\n } else if (error.message) {\n throw new HttpException(error.message, HttpStatus.BAD_REQUEST);\n } else {\n throw new HttpException(error, HttpStatus.BAD_REQUEST);\n }\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './datetime';
|
|
2
|
-
export * from './error';
|
|
3
|
-
export * from './input';
|
|
4
|
-
export * from './string';
|
|
1
|
+
export * from './datetime.util';
|
|
2
|
+
export * from './error.util';
|
|
3
|
+
export * from './input.util';
|
|
4
|
+
export * from './string.util';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./datetime"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./error"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./input"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./string"), exports);
|
|
4
|
+
tslib_1.__exportStar(require("./datetime.util"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./error.util"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./input.util"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./string.util"), exports);
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC;AAChC,uDAA6B;AAC7B,uDAA6B;AAC7B,wDAA8B","sourcesContent":["export * from './datetime.util';\nexport * from './error.util';\nexport * from './input.util';\nexport * from './string.util';\n"]}
|
|
@@ -2,4 +2,4 @@ export declare const cleanString: (str: string) => string;
|
|
|
2
2
|
export declare const cleanStringAndLowercase: (str: string) => string;
|
|
3
3
|
export declare const cleanPhoneNumber: (str: string) => string;
|
|
4
4
|
export declare const utcOffsetToHours: (utcOffset: number) => number;
|
|
5
|
-
//# sourceMappingURL=input.d.ts.map
|
|
5
|
+
//# sourceMappingURL=input.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.util.d.ts","sourceRoot":"/","sources":["utils/input.util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,QAAS,MAAM,KAAG,MAEzC,CAAC;AAEF,eAAO,MAAM,uBAAuB,QAAS,MAAM,KAAG,MAGrD,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAS,MAAM,KAAG,MAY9C,CAAC;AAEF,eAAO,MAAM,gBAAgB,cAAe,MAAM,KAAG,MAQpD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.util.js","sourceRoot":"/","sources":["utils/input.util.ts"],"names":[],"mappings":";;;AAAO,MAAM,WAAW,GAAG,CAAC,GAAW,EAAU,EAAE;IACjD,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;AACpB,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB;AAEK,MAAM,uBAAuB,GAAG,CAAC,GAAW,EAAU,EAAE;IAC7D,MAAM,OAAO,GAAW,IAAA,mBAAW,EAAC,GAAG,CAAC,CAAC;IACzC,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC,CAAC;AAHW,QAAA,uBAAuB,2BAGlC;AAEK,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAU,EAAE;IACtD,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAE3B,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,OAAO,EAAE,CAAC;IACvB,CAAC;IAED,OAAO,KAAK,OAAO,EAAE,CAAC;AACxB,CAAC,CAAC;AAZW,QAAA,gBAAgB,oBAY3B;AAEK,MAAM,gBAAgB,GAAG,CAAC,SAAiB,EAAU,EAAE;IAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC,CAAC;IAEzC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,OAAO,EAAE,GAAG,KAAK,CAAC;IACpB,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC,CAAC;AARW,QAAA,gBAAgB,oBAQ3B","sourcesContent":["export const cleanString = (str: string): string => {\n return str.trim();\n};\n\nexport const cleanStringAndLowercase = (str: string): string => {\n const trimmed: string = cleanString(str);\n return trimmed.toLowerCase();\n};\n\nexport const cleanPhoneNumber = (str: string): string => {\n const trimmed = str.trim();\n\n if (trimmed.startsWith('+')) {\n return trimmed;\n }\n\n if (trimmed.startsWith('1')) {\n return `+${trimmed}`;\n }\n\n return `+1${trimmed}`;\n};\n\nexport const utcOffsetToHours = (utcOffset: number): number => {\n const hours = Math.floor(utcOffset / 60);\n\n if (hours > 0) {\n return 24 - hours;\n }\n\n return Math.abs(hours);\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.util.d.ts","sourceRoot":"/","sources":["utils/noop.util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,YAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.util.js","sourceRoot":"/","sources":["utils/noop.util.ts"],"names":[],"mappings":";;;AAAO,MAAM,QAAQ,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAApB,QAAA,QAAQ,YAAY","sourcesContent":["export const NoopUtil = () => {};\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const getInitial: (name: string) => string;
|
|
2
|
-
//# sourceMappingURL=string.d.ts.map
|
|
2
|
+
//# sourceMappingURL=string.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.util.d.ts","sourceRoot":"/","sources":["utils/string.util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,SAAU,MAAM,KAAG,MAEzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.util.js","sourceRoot":"/","sources":["utils/string.util.ts"],"names":[],"mappings":";;;AAAO,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE;IACjD,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB","sourcesContent":["export const getInitial = (name: string): string => {\n return name[0];\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.d.ts","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.service.d.ts","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAGvE,qBACa,WAAW;IAIV,OAAO,CAAC,aAAa;IAHjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAC/D,OAAO,CAAC,UAAU,CAAgB;gBAEd,aAAa,EAAE,aAAa;IAW1C,MAAM,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAQlD,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;CAgBxD"}
|
|
@@ -3,6 +3,7 @@ import { __decorate, __metadata } from "tslib";
|
|
|
3
3
|
import { Injectable, Logger } from '@nestjs/common';
|
|
4
4
|
import * as stytch from 'stytch';
|
|
5
5
|
import { ConfigService } from '@nestjs/config';
|
|
6
|
+
import { handleError } from '../utils';
|
|
6
7
|
let AuthService = AuthService_1 = class AuthService {
|
|
7
8
|
constructor(configService) {
|
|
8
9
|
this.configService = configService;
|
|
@@ -22,8 +23,18 @@ let AuthService = AuthService_1 = class AuthService {
|
|
|
22
23
|
}
|
|
23
24
|
async login(data) {
|
|
24
25
|
this.logger.debug('login');
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
try {
|
|
27
|
+
const res = await this.authClient.passwords.authenticate(data);
|
|
28
|
+
return res['status_code'] === 200;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (error.error_type === 'email_not_found') {
|
|
32
|
+
handleError('Email or password is wrong');
|
|
33
|
+
}
|
|
34
|
+
if (error.error_type === 'unauthorized_credentials') {
|
|
35
|
+
handleError('Email or password is wrong');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
27
38
|
}
|
|
28
39
|
};
|
|
29
40
|
AuthService = AuthService_1 = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.js","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGhC,IAAM,WAAW,mBAAjB,MAAM,WAAW;IAItB,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAH/B,WAAM,GAAW,IAAI,MAAM,CAAC,aAAW,CAAC,IAAI,CAAC,CAAC;QAI7D,IAAI,CAAC,UAAU,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC;YAClC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,mBAAmB,CAAC;YAC/D,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,eAAe,CAAC;YACvD,GAAG,EACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,YAAY,CAAC,KAAK,MAAM;gBACrD,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI;gBAClB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI;SACvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAwB;QACnC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE5B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEzD,OAAO,GAAG,CAAC,aAAa,CAAC,KAAK,GAAG,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,IAAwB;QAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAE3B,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAC/D,OAAO,GAAG,CAAC,aAAa,CAAC,KAAK,GAAG,CAAC;QACpC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,KAAK,CAAC,UAAU,KAAK,iBAAiB,EAAE,CAAC;gBAC3C,WAAW,CAAC,4BAA4B,CAAC,CAAC;YAC5C,CAAC;YAED,IAAI,KAAK,CAAC,UAAU,KAAK,0BAA0B,EAAE,CAAC;gBACpD,WAAW,CAAC,4BAA4B,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AAvCY,WAAW;IADvB,UAAU,EAAE;qCAKwB,aAAa;GAJrC,WAAW,CAuCvB","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\nimport * as stytch from 'stytch';\nimport { ConfigService } from '@nestjs/config';\n\nimport { RegisterRequestDto } from '../user/dtos/register.request.dto';\nimport { handleError } from '../utils';\n\n@Injectable()\nexport class AuthService {\n private readonly logger: Logger = new Logger(AuthService.name);\n private authClient: stytch.Client;\n\n constructor(private configService: ConfigService) {\n this.authClient = new stytch.Client({\n project_id: this.configService.get<string>('STYTCH_PROJECT_ID'),\n secret: this.configService.get<string>('STYTCH_SECRET'),\n env:\n this.configService.get<string>('STYTCH_ENV') === 'test'\n ? stytch.envs.test\n : stytch.envs.live,\n });\n }\n\n async signup(data: RegisterRequestDto): Promise<boolean> {\n this.logger.debug('signup');\n\n const res = await this.authClient.passwords.create(data);\n\n return res['status_code'] === 200;\n }\n\n async login(data: RegisterRequestDto): Promise<boolean> {\n this.logger.debug('login');\n\n try {\n const res = await this.authClient.passwords.authenticate(data);\n return res['status_code'] === 200;\n } catch (error: any) {\n if (error.error_type === 'email_not_found') {\n handleError('Email or password is wrong');\n }\n\n if (error.error_type === 'unauthorized_credentials') {\n handleError('Email or password is wrong');\n }\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EServerDay, EHumanDay } from '../enums';
|
|
2
|
+
import { Moment } from 'moment';
|
|
3
|
+
export declare const serverDayToHumanReadable: (day: EServerDay) => EHumanDay;
|
|
4
|
+
export declare const getStartOfDateString: (date: Moment) => string;
|
|
5
|
+
export declare const getStartOfTodayString: () => string;
|
|
6
|
+
export declare const getCurrentHour: () => number;
|
|
7
|
+
export declare const getDateWithTz: (date: string, tz: number) => string;
|
|
8
|
+
//# sourceMappingURL=datetime.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime.util.d.ts","sourceRoot":"/","sources":["utils/datetime.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACjD,OAAe,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,eAAO,MAAM,wBAAwB,QAAS,UAAU,KAAG,SAmB1D,CAAC;AAEF,eAAO,MAAM,oBAAoB,SAAU,MAAM,KAAG,MAEnD,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAAO,MAExC,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,MAEjC,CAAC;AAEF,eAAO,MAAM,aAAa,SAAU,MAAM,MAAM,MAAM,KAAG,MAIxD,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { EServerDay } from '../enums
|
|
2
|
-
import { EHumanDay } from '../enums/humanDay.enum';
|
|
1
|
+
import { EServerDay, EHumanDay } from '../enums';
|
|
3
2
|
import moment from 'moment';
|
|
4
3
|
export const serverDayToHumanReadable = (day) => {
|
|
5
4
|
switch (day) {
|
|
@@ -24,4 +23,15 @@ export const serverDayToHumanReadable = (day) => {
|
|
|
24
23
|
export const getStartOfDateString = (date) => {
|
|
25
24
|
return moment(date).utc().startOf('day').toDate().toISOString();
|
|
26
25
|
};
|
|
27
|
-
|
|
26
|
+
export const getStartOfTodayString = () => {
|
|
27
|
+
return getStartOfDateString(moment());
|
|
28
|
+
};
|
|
29
|
+
export const getCurrentHour = () => {
|
|
30
|
+
return moment().hour();
|
|
31
|
+
};
|
|
32
|
+
export const getDateWithTz = (date, tz) => {
|
|
33
|
+
const dateMoment = moment(date).utcOffset(tz);
|
|
34
|
+
dateMoment.add(tz, 'hours');
|
|
35
|
+
return dateMoment.format('YYYY-MM-DD');
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=datetime.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime.util.js","sourceRoot":"/","sources":["utils/datetime.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,MAAkB,MAAM,QAAQ,CAAC;AAExC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAe,EAAa,EAAE;IACrE,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,UAAU,CAAC,MAAM;YACpB,OAAO,SAAS,CAAC,MAAM,CAAC;QAC1B,KAAK,UAAU,CAAC,MAAM;YACpB,OAAO,SAAS,CAAC,MAAM,CAAC;QAC1B,KAAK,UAAU,CAAC,OAAO;YACrB,OAAO,SAAS,CAAC,OAAO,CAAC;QAC3B,KAAK,UAAU,CAAC,SAAS;YACvB,OAAO,SAAS,CAAC,SAAS,CAAC;QAC7B,KAAK,UAAU,CAAC,QAAQ;YACtB,OAAO,SAAS,CAAC,QAAQ,CAAC;QAC5B,KAAK,UAAU,CAAC,MAAM;YACpB,OAAO,SAAS,CAAC,MAAM,CAAC;QAC1B,KAAK,UAAU,CAAC,QAAQ;YACtB,OAAO,SAAS,CAAC,QAAQ,CAAC;QAC5B;YACE,OAAO,SAAS,CAAC,MAAM,CAAC;IAC5B,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAU,EAAE;IAC3D,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;AAClE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAW,EAAE;IAChD,OAAO,oBAAoB,CAAC,MAAM,EAAE,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAW,EAAE;IACzC,OAAO,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,EAAU,EAAU,EAAE;IAChE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC9C,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAC5B,OAAO,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AACzC,CAAC,CAAC","sourcesContent":["import { EServerDay, EHumanDay } from '../enums';\nimport moment, { Moment } from 'moment';\n\nexport const serverDayToHumanReadable = (day: EServerDay): EHumanDay => {\n switch (day) {\n case EServerDay.SUNDAY:\n return EHumanDay.SUNDAY;\n case EServerDay.MONDAY:\n return EHumanDay.MONDAY;\n case EServerDay.TUESDAY:\n return EHumanDay.TUESDAY;\n case EServerDay.WEDNESDAY:\n return EHumanDay.WEDNESDAY;\n case EServerDay.THURSDAY:\n return EHumanDay.THURSDAY;\n case EServerDay.FRIDAY:\n return EHumanDay.FRIDAY;\n case EServerDay.SATURDAY:\n return EHumanDay.SATURDAY;\n default:\n return EHumanDay.SUNDAY;\n }\n};\n\nexport const getStartOfDateString = (date: Moment): string => {\n return moment(date).utc().startOf('day').toDate().toISOString();\n};\n\nexport const getStartOfTodayString = (): string => {\n return getStartOfDateString(moment());\n};\n\nexport const getCurrentHour = (): number => {\n return moment().hour();\n};\n\nexport const getDateWithTz = (date: string, tz: number): string => {\n const dateMoment = moment(date).utcOffset(tz);\n dateMoment.add(tz, 'hours');\n return dateMoment.format('YYYY-MM-DD');\n};\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const handleError: (error: any) => never;
|
|
2
|
-
//# sourceMappingURL=error.d.ts.map
|
|
2
|
+
//# sourceMappingURL=error.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.util.d.ts","sourceRoot":"/","sources":["utils/error.util.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,UAAW,GAAG,UAQrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.util.js","sourceRoot":"/","sources":["utils/error.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE3D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAU,EAAE,EAAE;IACxC,IAAI,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,aAAa,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IAC1E,CAAC;SAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QACzB,MAAM,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IACjE,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IACzD,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { HttpException, HttpStatus } from '@nestjs/common';\n\nexport const handleError = (error: any) => {\n if (error['error_message']) {\n throw new HttpException(error['error_message'], HttpStatus.BAD_REQUEST);\n } else if (error.message) {\n throw new HttpException(error.message, HttpStatus.BAD_REQUEST);\n } else {\n throw new HttpException(error, HttpStatus.BAD_REQUEST);\n }\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './datetime';
|
|
2
|
-
export * from './error';
|
|
3
|
-
export * from './input';
|
|
4
|
-
export * from './string';
|
|
1
|
+
export * from './datetime.util';
|
|
2
|
+
export * from './error.util';
|
|
3
|
+
export * from './input.util';
|
|
4
|
+
export * from './string.util';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './datetime';
|
|
2
|
-
export * from './error';
|
|
3
|
-
export * from './input';
|
|
4
|
-
export * from './string';
|
|
1
|
+
export * from './datetime.util';
|
|
2
|
+
export * from './error.util';
|
|
3
|
+
export * from './input.util';
|
|
4
|
+
export * from './string.util';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC","sourcesContent":["export * from './datetime.util';\nexport * from './error.util';\nexport * from './input.util';\nexport * from './string.util';\n"]}
|
|
@@ -2,4 +2,4 @@ export declare const cleanString: (str: string) => string;
|
|
|
2
2
|
export declare const cleanStringAndLowercase: (str: string) => string;
|
|
3
3
|
export declare const cleanPhoneNumber: (str: string) => string;
|
|
4
4
|
export declare const utcOffsetToHours: (utcOffset: number) => number;
|
|
5
|
-
//# sourceMappingURL=input.d.ts.map
|
|
5
|
+
//# sourceMappingURL=input.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.util.d.ts","sourceRoot":"/","sources":["utils/input.util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,QAAS,MAAM,KAAG,MAEzC,CAAC;AAEF,eAAO,MAAM,uBAAuB,QAAS,MAAM,KAAG,MAGrD,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAS,MAAM,KAAG,MAY9C,CAAC;AAEF,eAAO,MAAM,gBAAgB,cAAe,MAAM,KAAG,MAQpD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.util.js","sourceRoot":"/","sources":["utils/input.util.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAU,EAAE;IACjD,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAW,EAAU,EAAE;IAC7D,MAAM,OAAO,GAAW,WAAW,CAAC,GAAG,CAAC,CAAC;IACzC,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAU,EAAE;IACtD,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAE3B,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,OAAO,EAAE,CAAC;IACvB,CAAC;IAED,OAAO,KAAK,OAAO,EAAE,CAAC;AACxB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,SAAiB,EAAU,EAAE;IAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC,CAAC;IAEzC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,OAAO,EAAE,GAAG,KAAK,CAAC;IACpB,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC,CAAC","sourcesContent":["export const cleanString = (str: string): string => {\n return str.trim();\n};\n\nexport const cleanStringAndLowercase = (str: string): string => {\n const trimmed: string = cleanString(str);\n return trimmed.toLowerCase();\n};\n\nexport const cleanPhoneNumber = (str: string): string => {\n const trimmed = str.trim();\n\n if (trimmed.startsWith('+')) {\n return trimmed;\n }\n\n if (trimmed.startsWith('1')) {\n return `+${trimmed}`;\n }\n\n return `+1${trimmed}`;\n};\n\nexport const utcOffsetToHours = (utcOffset: number): number => {\n const hours = Math.floor(utcOffset / 60);\n\n if (hours > 0) {\n return 24 - hours;\n }\n\n return Math.abs(hours);\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.util.d.ts","sourceRoot":"/","sources":["utils/noop.util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,YAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.util.js","sourceRoot":"/","sources":["utils/noop.util.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC","sourcesContent":["export const NoopUtil = () => {};\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const getInitial: (name: string) => string;
|
|
2
|
-
//# sourceMappingURL=string.d.ts.map
|
|
2
|
+
//# sourceMappingURL=string.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.util.d.ts","sourceRoot":"/","sources":["utils/string.util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,SAAU,MAAM,KAAG,MAEzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.util.js","sourceRoot":"/","sources":["utils/string.util.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE;IACjD,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC","sourcesContent":["export const getInitial = (name: string): string => {\n return name[0];\n};\n"]}
|