@powfix/core-js 0.14.5 → 0.15.0-beta-1
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/client/constants/index.browser.d.ts +6 -0
- package/dist/{src → client}/constants/index.browser.js +6 -6
- package/dist/client/index.browser.d.ts +7 -0
- package/dist/{src → client}/index.browser.js +7 -7
- package/dist/{src → client}/interfaces/Point3.d.ts +1 -1
- package/dist/client/interfaces/index.browser.d.ts +4 -0
- package/dist/{src → client}/interfaces/index.browser.js +4 -4
- package/dist/{src → client}/managers/SessionManager.d.ts +2 -2
- package/dist/{src → client}/managers/SessionManager.type.d.ts +1 -1
- package/dist/client/managers/index.browser.d.ts +2 -0
- package/dist/{src → client}/managers/index.browser.js +2 -2
- package/dist/client/scripts/index.browser.d.ts +1 -0
- package/dist/{src → client}/scripts/index.browser.js +1 -1
- package/dist/client/services/index.browser.d.ts +1 -0
- package/dist/{src → client}/services/index.browser.js +1 -1
- package/dist/{src → client}/services/time/TimeService.d.ts +1 -1
- package/dist/client/services/time/index.d.ts +2 -0
- package/dist/client/services/time/index.js +18 -0
- package/dist/client/types/index.browser.d.ts +2 -0
- package/dist/{src → client}/types/index.browser.js +2 -2
- package/dist/{src → client}/utils/ArrayUtils.js +2 -2
- package/dist/{src → client}/utils/CoordinateUtils.d.ts +1 -1
- package/dist/{src → client}/utils/DateUtils.d.ts +1 -1
- package/dist/{src → client}/utils/DateUtils.js +17 -17
- package/dist/{src → client}/utils/JuminNumberUtils.js +2 -2
- package/dist/{src → client}/utils/ObjectIdUtils.js +3 -3
- package/dist/{src → client}/utils/Point3Utils.d.ts +1 -1
- package/dist/{src → client}/utils/Sequencer.js +2 -2
- package/dist/{src → client}/utils/UuidUtils.js +5 -2
- package/dist/{src → client}/utils/global/fallbackIfNull.js +2 -2
- package/dist/{src → client}/utils/global/fallbackIfUndefined.js +2 -2
- package/dist/client/utils/global/index.d.ts +11 -0
- package/dist/client/utils/global/index.js +27 -0
- package/dist/{src → client}/utils/global/processFirstNonNullish.js +2 -2
- package/dist/client/utils/index.browser.d.ts +17 -0
- package/dist/client/utils/index.browser.js +33 -0
- package/dist/client/utils/try-catch/index.d.ts +1 -0
- package/dist/{src/interfaces/nodejs/db → client/utils/try-catch}/index.js +1 -1
- package/dist/server/constants/COORDINATE.d.ts +7 -0
- package/dist/server/constants/COORDINATE.js +10 -0
- package/dist/server/constants/CRUD.d.ts +9 -0
- package/dist/server/constants/CRUD.js +22 -0
- package/dist/server/constants/DATE.d.ts +13 -0
- package/dist/server/constants/DATE.js +26 -0
- package/dist/server/constants/DISTANCE.d.ts +13 -0
- package/dist/server/constants/DISTANCE.js +18 -0
- package/dist/server/constants/DURATION.d.ts +16 -0
- package/dist/server/constants/DURATION.js +21 -0
- package/dist/server/constants/NOT_NULL.d.ts +1 -0
- package/dist/server/constants/NOT_NULL.js +4 -0
- package/dist/server/constants/index.browser.d.ts +6 -0
- package/dist/server/constants/index.browser.js +22 -0
- package/dist/server/constants/index.d.ts +2 -0
- package/dist/{src/interfaces → server/constants}/index.js +2 -2
- package/dist/server/constants/nodejs/index.d.ts +2 -0
- package/dist/{src → server}/constants/nodejs/index.js +2 -2
- package/dist/server/index.browser.d.ts +7 -0
- package/dist/server/index.browser.js +23 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/{src → server}/index.js +8 -8
- package/dist/server/interfaces/Coordinate.d.ts +8 -0
- package/dist/server/interfaces/Point2.d.ts +4 -0
- package/dist/server/interfaces/Point3.d.ts +4 -0
- package/dist/server/interfaces/StorageProvider.d.ts +7 -0
- package/dist/server/interfaces/index.browser.d.ts +4 -0
- package/dist/server/interfaces/index.browser.js +20 -0
- package/dist/server/interfaces/index.d.ts +2 -0
- package/dist/server/interfaces/index.js +18 -0
- package/dist/server/interfaces/nodejs/db/index.d.ts +1 -0
- package/dist/server/interfaces/nodejs/db/index.js +17 -0
- package/dist/{src → server}/interfaces/nodejs/db/sequelize/Hook.d.ts +2 -2
- package/dist/{src → server}/interfaces/nodejs/db/sequelize/HookFn.d.ts +1 -1
- package/dist/server/interfaces/nodejs/db/sequelize/UpsertOptions.d.ts +4 -0
- package/dist/server/interfaces/nodejs/db/sequelize/UpsertOptions.js +2 -0
- package/dist/server/interfaces/nodejs/db/sequelize/index.d.ts +6 -0
- package/dist/server/interfaces/nodejs/db/sequelize/index.js +22 -0
- package/dist/server/interfaces/nodejs/index.d.ts +1 -0
- package/dist/{src/utils/try-catch → server/interfaces/nodejs}/index.js +1 -1
- package/dist/server/managers/SessionManager.d.ts +15 -0
- package/dist/server/managers/SessionManager.js +134 -0
- package/dist/server/managers/SessionManager.type.d.ts +9 -0
- package/dist/server/managers/SessionManager.type.js +2 -0
- package/dist/{src → server}/managers/TransactionManager.d.ts +2 -2
- package/dist/{src → server}/managers/TransactionManager.js +13 -13
- package/dist/{src → server}/managers/TransactionManager.types.d.ts +1 -1
- package/dist/server/managers/TransactionManager.types.js +2 -0
- package/dist/server/managers/index.browser.d.ts +2 -0
- package/dist/server/managers/index.browser.js +18 -0
- package/dist/server/managers/index.d.ts +2 -0
- package/dist/server/managers/index.js +18 -0
- package/dist/server/scripts/base64Polyfill.d.ts +1 -0
- package/dist/server/scripts/base64Polyfill.js +14 -0
- package/dist/server/scripts/index.browser.d.ts +1 -0
- package/dist/{index.browser.js → server/scripts/index.browser.js} +1 -1
- package/dist/server/scripts/index.d.ts +1 -0
- package/dist/{index.js → server/scripts/index.js} +1 -1
- package/dist/server/services/index.browser.d.ts +1 -0
- package/dist/{src/scripts/index.js → server/services/index.browser.js} +1 -1
- package/dist/server/services/index.d.ts +2 -0
- package/dist/{src/constants → server/services}/index.js +2 -2
- package/dist/{src → server}/services/redis/RedisPublisher.d.ts +1 -1
- package/dist/{src → server}/services/redis/RedisPublisher.js +2 -2
- package/dist/{src → server}/services/redis/RedisSubscriber.d.ts +2 -2
- package/dist/{src → server}/services/redis/RedisSubscriber.js +5 -5
- package/dist/server/services/redis/index.d.ts +3 -0
- package/dist/{src → server}/services/redis/index.js +3 -3
- package/dist/server/services/time/TimeService.d.ts +31 -0
- package/dist/server/services/time/TimeService.js +180 -0
- package/dist/server/services/time/TimeService.type.d.ts +21 -0
- package/dist/server/services/time/TimeService.type.js +2 -0
- package/dist/server/services/time/index.d.ts +2 -0
- package/dist/server/services/time/index.js +18 -0
- package/dist/server/types/IntRage.d.ts +3 -0
- package/dist/server/types/IntRage.js +2 -0
- package/dist/server/types/PartialExcept.d.ts +1 -0
- package/dist/server/types/PartialExcept.js +2 -0
- package/dist/server/types/UpsertResult.js +2 -0
- package/dist/server/types/index.browser.d.ts +2 -0
- package/dist/server/types/index.browser.js +18 -0
- package/dist/server/types/index.d.ts +2 -0
- package/dist/server/types/index.js +18 -0
- package/dist/server/utils/ArrayUtils.d.ts +12 -0
- package/dist/server/utils/ArrayUtils.js +30 -0
- package/dist/server/utils/AxiosUtils.d.ts +5 -0
- package/dist/server/utils/AxiosUtils.js +53 -0
- package/dist/server/utils/BooleanUtils.d.ts +1 -0
- package/dist/server/utils/BooleanUtils.js +8 -0
- package/dist/server/utils/Calc.d.ts +4 -0
- package/dist/server/utils/Calc.js +27 -0
- package/dist/server/utils/CoordinateUtils.d.ts +8 -0
- package/dist/server/utils/CoordinateUtils.js +42 -0
- package/dist/server/utils/DateUtils.d.ts +24 -0
- package/dist/server/utils/DateUtils.js +310 -0
- package/dist/server/utils/JuminNumberUtils.d.ts +4 -0
- package/dist/server/utils/JuminNumberUtils.js +50 -0
- package/dist/server/utils/NumberUtils.d.ts +4 -0
- package/dist/server/utils/NumberUtils.js +25 -0
- package/dist/server/utils/ObjectIdUtils.d.ts +4 -0
- package/dist/server/utils/ObjectIdUtils.js +24 -0
- package/dist/server/utils/Point3Utils.d.ts +4 -0
- package/dist/server/utils/Point3Utils.js +12 -0
- package/dist/server/utils/RandomUtils.d.ts +8 -0
- package/dist/server/utils/RandomUtils.js +64 -0
- package/dist/server/utils/Sequencer.d.ts +38 -0
- package/dist/server/utils/Sequencer.js +148 -0
- package/dist/server/utils/StringUtils.d.ts +5 -0
- package/dist/server/utils/StringUtils.js +37 -0
- package/dist/server/utils/UuidUtils.d.ts +14 -0
- package/dist/server/utils/UuidUtils.js +49 -0
- package/dist/server/utils/Validator.d.ts +48 -0
- package/dist/server/utils/Validator.js +118 -0
- package/dist/server/utils/global/between.d.ts +1 -0
- package/dist/server/utils/global/between.js +7 -0
- package/dist/server/utils/global/castArray.d.ts +1 -0
- package/dist/server/utils/global/castArray.js +6 -0
- package/dist/server/utils/global/circularDistance.d.ts +1 -0
- package/dist/server/utils/global/circularDistance.js +14 -0
- package/dist/server/utils/global/fallbackIfEqual.d.ts +1 -0
- package/dist/server/utils/global/fallbackIfEqual.js +9 -0
- package/dist/server/utils/global/fallbackIfNull.d.ts +1 -0
- package/dist/server/utils/global/fallbackIfNull.js +7 -0
- package/dist/server/utils/global/fallbackIfUndefined.d.ts +1 -0
- package/dist/server/utils/global/fallbackIfUndefined.js +7 -0
- package/dist/server/utils/global/firstNonNullish.d.ts +1 -0
- package/dist/server/utils/global/firstNonNullish.js +13 -0
- package/dist/server/utils/global/flat.d.ts +14 -0
- package/dist/server/utils/global/flat.js +117 -0
- package/dist/server/utils/global/index.d.ts +11 -0
- package/dist/server/utils/global/index.js +27 -0
- package/dist/server/utils/global/processFirstNonNullish.d.ts +1 -0
- package/dist/server/utils/global/processFirstNonNullish.js +11 -0
- package/dist/server/utils/global/pureEnum.d.ts +8 -0
- package/dist/server/utils/global/pureEnum.js +14 -0
- package/dist/server/utils/global/sleep.d.ts +1 -0
- package/dist/server/utils/global/sleep.js +5 -0
- package/dist/server/utils/index.browser.d.ts +17 -0
- package/dist/server/utils/index.browser.js +33 -0
- package/dist/server/utils/index.d.ts +2 -0
- package/dist/server/utils/index.js +18 -0
- package/dist/{src → server}/utils/nodejs/HookUtils.d.ts +1 -1
- package/dist/server/utils/nodejs/index.d.ts +2 -0
- package/dist/{src → server}/utils/nodejs/index.js +3 -3
- package/dist/{src → server}/utils/nodejs/sequelize-utils/SequelizeUtils.d.ts +1 -1
- package/dist/{src → server}/utils/nodejs/sequelize-utils/SequelizeUtils.js +8 -8
- package/dist/server/utils/nodejs/sequelize-utils/index.d.ts +1 -0
- package/dist/{src → server}/utils/nodejs/sequelize-utils/index.js +2 -2
- package/dist/server/utils/nodejs/sequelize-utils/types.js +2 -0
- package/dist/server/utils/try-catch/TryCatch.d.ts +24 -0
- package/dist/server/utils/try-catch/TryCatch.js +78 -0
- package/dist/server/utils/try-catch/index.d.ts +1 -0
- package/dist/{src/interfaces/nodejs → server/utils/try-catch}/index.js +1 -1
- package/package.json +56 -52
- package/dist/index.browser.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/src/constants/index.browser.d.ts +0 -6
- package/dist/src/constants/index.d.ts +0 -2
- package/dist/src/constants/nodejs/index.d.ts +0 -2
- package/dist/src/index.browser.d.ts +0 -7
- package/dist/src/index.d.ts +0 -8
- package/dist/src/interfaces/index.browser.d.ts +0 -4
- package/dist/src/interfaces/index.d.ts +0 -2
- package/dist/src/interfaces/nodejs/db/index.d.ts +0 -1
- package/dist/src/interfaces/nodejs/db/sequelize/UpsertOptions.d.ts +0 -4
- package/dist/src/interfaces/nodejs/db/sequelize/index.d.ts +0 -6
- package/dist/src/interfaces/nodejs/db/sequelize/index.js +0 -22
- package/dist/src/interfaces/nodejs/index.d.ts +0 -1
- package/dist/src/managers/index.browser.d.ts +0 -2
- package/dist/src/managers/index.d.ts +0 -2
- package/dist/src/managers/index.js +0 -18
- package/dist/src/scripts/index.browser.d.ts +0 -1
- package/dist/src/scripts/index.d.ts +0 -1
- package/dist/src/services/index.browser.d.ts +0 -1
- package/dist/src/services/index.d.ts +0 -2
- package/dist/src/services/index.js +0 -18
- package/dist/src/services/redis/index.d.ts +0 -3
- package/dist/src/services/time/index.d.ts +0 -2
- package/dist/src/services/time/index.js +0 -18
- package/dist/src/types/index.browser.d.ts +0 -2
- package/dist/src/types/index.d.ts +0 -2
- package/dist/src/types/index.js +0 -18
- package/dist/src/utils/global/index.d.ts +0 -11
- package/dist/src/utils/global/index.js +0 -27
- package/dist/src/utils/index.browser.d.ts +0 -17
- package/dist/src/utils/index.browser.js +0 -33
- package/dist/src/utils/index.d.ts +0 -2
- package/dist/src/utils/index.js +0 -18
- package/dist/src/utils/nodejs/index.d.ts +0 -2
- package/dist/src/utils/nodejs/sequelize-utils/index.d.ts +0 -1
- package/dist/src/utils/try-catch/index.d.ts +0 -1
- /package/dist/{src → client}/constants/COORDINATE.d.ts +0 -0
- /package/dist/{src → client}/constants/COORDINATE.js +0 -0
- /package/dist/{src → client}/constants/CRUD.d.ts +0 -0
- /package/dist/{src → client}/constants/CRUD.js +0 -0
- /package/dist/{src → client}/constants/DATE.d.ts +0 -0
- /package/dist/{src → client}/constants/DATE.js +0 -0
- /package/dist/{src → client}/constants/DISTANCE.d.ts +0 -0
- /package/dist/{src → client}/constants/DISTANCE.js +0 -0
- /package/dist/{src → client}/constants/DURATION.d.ts +0 -0
- /package/dist/{src → client}/constants/DURATION.js +0 -0
- /package/dist/{src → client}/constants/NOT_NULL.d.ts +0 -0
- /package/dist/{src → client}/constants/NOT_NULL.js +0 -0
- /package/dist/{src → client}/interfaces/Coordinate.d.ts +0 -0
- /package/dist/{src → client}/interfaces/Coordinate.js +0 -0
- /package/dist/{src → client}/interfaces/Point2.d.ts +0 -0
- /package/dist/{src → client}/interfaces/Point2.js +0 -0
- /package/dist/{src → client}/interfaces/Point3.js +0 -0
- /package/dist/{src → client}/interfaces/StorageProvider.d.ts +0 -0
- /package/dist/{src → client}/interfaces/StorageProvider.js +0 -0
- /package/dist/{src → client}/managers/SessionManager.js +0 -0
- /package/dist/{src → client}/managers/SessionManager.type.js +0 -0
- /package/dist/{src → client}/scripts/base64Polyfill.d.ts +0 -0
- /package/dist/{src → client}/scripts/base64Polyfill.js +0 -0
- /package/dist/{src → client}/services/time/TimeService.js +0 -0
- /package/dist/{src → client}/services/time/TimeService.type.d.ts +0 -0
- /package/dist/{src → client}/services/time/TimeService.type.js +0 -0
- /package/dist/{src → client}/types/IntRage.d.ts +0 -0
- /package/dist/{src → client}/types/IntRage.js +0 -0
- /package/dist/{src → client}/types/PartialExcept.d.ts +0 -0
- /package/dist/{src → client}/types/PartialExcept.js +0 -0
- /package/dist/{src → client}/utils/ArrayUtils.d.ts +0 -0
- /package/dist/{src → client}/utils/AxiosUtils.d.ts +0 -0
- /package/dist/{src → client}/utils/AxiosUtils.js +0 -0
- /package/dist/{src → client}/utils/BooleanUtils.d.ts +0 -0
- /package/dist/{src → client}/utils/BooleanUtils.js +0 -0
- /package/dist/{src → client}/utils/Calc.d.ts +0 -0
- /package/dist/{src → client}/utils/Calc.js +0 -0
- /package/dist/{src → client}/utils/CoordinateUtils.js +0 -0
- /package/dist/{src → client}/utils/JuminNumberUtils.d.ts +0 -0
- /package/dist/{src → client}/utils/NumberUtils.d.ts +0 -0
- /package/dist/{src → client}/utils/NumberUtils.js +0 -0
- /package/dist/{src → client}/utils/ObjectIdUtils.d.ts +0 -0
- /package/dist/{src → client}/utils/Point3Utils.js +0 -0
- /package/dist/{src → client}/utils/RandomUtils.d.ts +0 -0
- /package/dist/{src → client}/utils/RandomUtils.js +0 -0
- /package/dist/{src → client}/utils/Sequencer.d.ts +0 -0
- /package/dist/{src → client}/utils/StringUtils.d.ts +0 -0
- /package/dist/{src → client}/utils/StringUtils.js +0 -0
- /package/dist/{src → client}/utils/UuidUtils.d.ts +0 -0
- /package/dist/{src → client}/utils/Validator.d.ts +0 -0
- /package/dist/{src → client}/utils/Validator.js +0 -0
- /package/dist/{src → client}/utils/global/between.d.ts +0 -0
- /package/dist/{src → client}/utils/global/between.js +0 -0
- /package/dist/{src → client}/utils/global/castArray.d.ts +0 -0
- /package/dist/{src → client}/utils/global/castArray.js +0 -0
- /package/dist/{src → client}/utils/global/circularDistance.d.ts +0 -0
- /package/dist/{src → client}/utils/global/circularDistance.js +0 -0
- /package/dist/{src → client}/utils/global/fallbackIfEqual.d.ts +0 -0
- /package/dist/{src → client}/utils/global/fallbackIfEqual.js +0 -0
- /package/dist/{src → client}/utils/global/fallbackIfNull.d.ts +0 -0
- /package/dist/{src → client}/utils/global/fallbackIfUndefined.d.ts +0 -0
- /package/dist/{src → client}/utils/global/firstNonNullish.d.ts +0 -0
- /package/dist/{src → client}/utils/global/firstNonNullish.js +0 -0
- /package/dist/{src → client}/utils/global/flat.d.ts +0 -0
- /package/dist/{src → client}/utils/global/flat.js +0 -0
- /package/dist/{src → client}/utils/global/processFirstNonNullish.d.ts +0 -0
- /package/dist/{src → client}/utils/global/pureEnum.d.ts +0 -0
- /package/dist/{src → client}/utils/global/pureEnum.js +0 -0
- /package/dist/{src → client}/utils/global/sleep.d.ts +0 -0
- /package/dist/{src → client}/utils/global/sleep.js +0 -0
- /package/dist/{src → client}/utils/try-catch/TryCatch.d.ts +0 -0
- /package/dist/{src → client}/utils/try-catch/TryCatch.js +0 -0
- /package/dist/{src → server}/constants/nodejs/TransactionManagerLogLevel.d.ts +0 -0
- /package/dist/{src → server}/constants/nodejs/TransactionManagerLogLevel.js +0 -0
- /package/dist/{src → server}/constants/nodejs/TransactionManagerTimeoutAction.d.ts +0 -0
- /package/dist/{src → server}/constants/nodejs/TransactionManagerTimeoutAction.js +0 -0
- /package/dist/{src/interfaces/nodejs/db/sequelize/Hook.js → server/interfaces/Coordinate.js} +0 -0
- /package/dist/{src/interfaces/nodejs/db/sequelize/HookFn.js → server/interfaces/Point2.js} +0 -0
- /package/dist/{src/interfaces/nodejs/db/sequelize/HookType.js → server/interfaces/Point3.js} +0 -0
- /package/dist/{src/interfaces/nodejs/db/sequelize/ReloadOption.js → server/interfaces/StorageProvider.js} +0 -0
- /package/dist/{src/interfaces/nodejs/db/sequelize/TransactionOption.js → server/interfaces/nodejs/db/sequelize/Hook.js} +0 -0
- /package/dist/{src/interfaces/nodejs/db/sequelize/UpsertOptions.js → server/interfaces/nodejs/db/sequelize/HookFn.js} +0 -0
- /package/dist/{src → server}/interfaces/nodejs/db/sequelize/HookType.d.ts +0 -0
- /package/dist/{src/managers/TransactionManager.types.js → server/interfaces/nodejs/db/sequelize/HookType.js} +0 -0
- /package/dist/{src → server}/interfaces/nodejs/db/sequelize/ReloadOption.d.ts +0 -0
- /package/dist/{src/types/UpsertResult.js → server/interfaces/nodejs/db/sequelize/ReloadOption.js} +0 -0
- /package/dist/{src → server}/interfaces/nodejs/db/sequelize/TransactionOption.d.ts +0 -0
- /package/dist/{src/utils/nodejs/sequelize-utils/types.js → server/interfaces/nodejs/db/sequelize/TransactionOption.js} +0 -0
- /package/dist/{src → server}/services/redis/RedisClient.d.ts +0 -0
- /package/dist/{src → server}/services/redis/RedisClient.js +0 -0
- /package/dist/{src → server}/types/UpsertResult.d.ts +0 -0
- /package/dist/{src → server}/utils/nodejs/HookUtils.js +0 -0
- /package/dist/{src → server}/utils/nodejs/sequelize-utils/types.d.ts +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DISTANCE = void 0;
|
|
4
|
+
class DISTANCE {
|
|
5
|
+
}
|
|
6
|
+
exports.DISTANCE = DISTANCE;
|
|
7
|
+
(function (DISTANCE) {
|
|
8
|
+
let UNIT;
|
|
9
|
+
(function (UNIT) {
|
|
10
|
+
UNIT["FEET"] = "FEET";
|
|
11
|
+
UNIT["KILOMETERS"] = "KILOMETERS";
|
|
12
|
+
UNIT["MILLIMETERS"] = "MILLIMETERS";
|
|
13
|
+
UNIT["CENTIMETERS"] = "CENTIMETERS";
|
|
14
|
+
UNIT["METERS"] = "METERS";
|
|
15
|
+
UNIT["MILES"] = "MILES";
|
|
16
|
+
UNIT["YARDS"] = "YARDS";
|
|
17
|
+
})(UNIT = DISTANCE.UNIT || (DISTANCE.UNIT = {}));
|
|
18
|
+
})(DISTANCE || (exports.DISTANCE = DISTANCE = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class DURATION {
|
|
2
|
+
}
|
|
3
|
+
export declare namespace DURATION {
|
|
4
|
+
enum UNIT {
|
|
5
|
+
NANOSECONDS = "NANOSECONDS",
|
|
6
|
+
MICROSECONDS = "MICROSECONDS",
|
|
7
|
+
MILLISECONDS = "MILLISECONDS",
|
|
8
|
+
SECONDS = "SECONDS",
|
|
9
|
+
MINUTES = "MINUTES",
|
|
10
|
+
HOURS = "HOURS",
|
|
11
|
+
DAYS = "DAYS",
|
|
12
|
+
YEARS = "YEARS",
|
|
13
|
+
DECADES = "DECADES",
|
|
14
|
+
CENTURIES = "CENTURIES"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DURATION = void 0;
|
|
4
|
+
class DURATION {
|
|
5
|
+
}
|
|
6
|
+
exports.DURATION = DURATION;
|
|
7
|
+
(function (DURATION) {
|
|
8
|
+
let UNIT;
|
|
9
|
+
(function (UNIT) {
|
|
10
|
+
UNIT["NANOSECONDS"] = "NANOSECONDS";
|
|
11
|
+
UNIT["MICROSECONDS"] = "MICROSECONDS";
|
|
12
|
+
UNIT["MILLISECONDS"] = "MILLISECONDS";
|
|
13
|
+
UNIT["SECONDS"] = "SECONDS";
|
|
14
|
+
UNIT["MINUTES"] = "MINUTES";
|
|
15
|
+
UNIT["HOURS"] = "HOURS";
|
|
16
|
+
UNIT["DAYS"] = "DAYS";
|
|
17
|
+
UNIT["YEARS"] = "YEARS";
|
|
18
|
+
UNIT["DECADES"] = "DECADES";
|
|
19
|
+
UNIT["CENTURIES"] = "CENTURIES";
|
|
20
|
+
})(UNIT = DURATION.UNIT || (DURATION.UNIT = {}));
|
|
21
|
+
})(DURATION || (exports.DURATION = DURATION = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const NOT_NULL: unique symbol;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./COORDINATE.js"), exports);
|
|
18
|
+
__exportStar(require("./CRUD.js"), exports);
|
|
19
|
+
__exportStar(require("./DATE.js"), exports);
|
|
20
|
+
__exportStar(require("./DISTANCE.js"), exports);
|
|
21
|
+
__exportStar(require("./DURATION.js"), exports);
|
|
22
|
+
__exportStar(require("./NOT_NULL.js"), exports);
|
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./index.browser"), exports);
|
|
18
|
-
__exportStar(require("./nodejs"), exports);
|
|
17
|
+
__exportStar(require("./index.browser.js"), exports);
|
|
18
|
+
__exportStar(require("./nodejs/index.js"), exports);
|
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./TransactionManagerLogLevel"), exports);
|
|
18
|
-
__exportStar(require("./TransactionManagerTimeoutAction"), exports);
|
|
17
|
+
__exportStar(require("./TransactionManagerLogLevel.js"), exports);
|
|
18
|
+
__exportStar(require("./TransactionManagerTimeoutAction.js"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './constants/index.browser.js';
|
|
2
|
+
export * from './interfaces/index.browser.js';
|
|
3
|
+
export * from './managers/index.browser.js';
|
|
4
|
+
export * from './scripts/index.browser.js';
|
|
5
|
+
export * from './services/index.browser.js';
|
|
6
|
+
export * from './types/index.browser.js';
|
|
7
|
+
export * from './utils/index.browser.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants/index.browser.js"), exports);
|
|
18
|
+
__exportStar(require("./interfaces/index.browser.js"), exports);
|
|
19
|
+
__exportStar(require("./managers/index.browser.js"), exports);
|
|
20
|
+
__exportStar(require("./scripts/index.browser.js"), exports);
|
|
21
|
+
__exportStar(require("./services/index.browser.js"), exports);
|
|
22
|
+
__exportStar(require("./types/index.browser.js"), exports);
|
|
23
|
+
__exportStar(require("./utils/index.browser.js"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './index.browser.js';
|
|
2
|
+
export * from './constants/index.js';
|
|
3
|
+
export * from './interfaces/index.js';
|
|
4
|
+
export * from './managers/index.js';
|
|
5
|
+
export * from './scripts/index.js';
|
|
6
|
+
export * from './services/index.js';
|
|
7
|
+
export * from './types/index.js';
|
|
8
|
+
export * from './utils/index.js';
|
|
@@ -14,11 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./index.browser"), exports);
|
|
18
|
-
__exportStar(require("./constants"), exports);
|
|
19
|
-
__exportStar(require("./interfaces"), exports);
|
|
20
|
-
__exportStar(require("./managers"), exports);
|
|
21
|
-
__exportStar(require("./scripts"), exports);
|
|
22
|
-
__exportStar(require("./services"), exports);
|
|
23
|
-
__exportStar(require("./types"), exports);
|
|
24
|
-
__exportStar(require("./utils"), exports);
|
|
17
|
+
__exportStar(require("./index.browser.js"), exports);
|
|
18
|
+
__exportStar(require("./constants/index.js"), exports);
|
|
19
|
+
__exportStar(require("./interfaces/index.js"), exports);
|
|
20
|
+
__exportStar(require("./managers/index.js"), exports);
|
|
21
|
+
__exportStar(require("./scripts/index.js"), exports);
|
|
22
|
+
__exportStar(require("./services/index.js"), exports);
|
|
23
|
+
__exportStar(require("./types/index.js"), exports);
|
|
24
|
+
__exportStar(require("./utils/index.js"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface StorageProvider {
|
|
2
|
+
key?: () => string;
|
|
3
|
+
set: (key: string, value: string) => Promise<void> | void;
|
|
4
|
+
get: (key: string) => Promise<string | null> | (string | null);
|
|
5
|
+
remove: (key: string) => Promise<void> | void;
|
|
6
|
+
clear?: () => Promise<void> | void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Coordinate.js"), exports);
|
|
18
|
+
__exportStar(require("./Point2.js"), exports);
|
|
19
|
+
__exportStar(require("./Point3.js"), exports);
|
|
20
|
+
__exportStar(require("./StorageProvider.js"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./index.browser.js"), exports);
|
|
18
|
+
__exportStar(require("./nodejs/index.js"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sequelize/index.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./sequelize/index.js"), exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ModelCtor } from "sequelize-typescript";
|
|
2
|
-
import { HookType } from "./HookType";
|
|
3
|
-
import { HookFn } from "./HookFn";
|
|
2
|
+
import { HookType } from "./HookType.js";
|
|
3
|
+
import { HookFn } from "./HookFn.js";
|
|
4
4
|
export interface Hook {
|
|
5
5
|
model: ModelCtor;
|
|
6
6
|
hookType: HookType;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Hooks, SequelizeHooks } from "sequelize/types/hooks";
|
|
2
2
|
import { Attributes, CreationAttributes } from "sequelize/types/model";
|
|
3
|
-
import { HookType } from "./HookType";
|
|
3
|
+
import { HookType } from "./HookType.js";
|
|
4
4
|
export type HookFn = SequelizeHooks<Hooks['_model'], Attributes<Hooks>, CreationAttributes<Hooks>>[HookType];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Hook.js"), exports);
|
|
18
|
+
__exportStar(require("./HookFn.js"), exports);
|
|
19
|
+
__exportStar(require("./HookType.js"), exports);
|
|
20
|
+
__exportStar(require("./ReloadOption.js"), exports);
|
|
21
|
+
__exportStar(require("./TransactionOption.js"), exports);
|
|
22
|
+
__exportStar(require("./UpsertOptions.js"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './db/index.js';
|
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./db/index.js"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { StorageProvider } from "../interfaces/StorageProvider.js";
|
|
3
|
+
import EventEmitter from 'eventemitter3';
|
|
4
|
+
import { SessionManagerEvent, SessionManagerOptions } from "./SessionManager.type.js";
|
|
5
|
+
export declare class SessionManager extends EventEmitter<SessionManagerEvent> {
|
|
6
|
+
private static readonly DEFAULT_AUTHORIZATION_STORAGE_KEY;
|
|
7
|
+
protected api: AxiosInstance;
|
|
8
|
+
protected storageProvider: StorageProvider;
|
|
9
|
+
constructor(options: SessionManagerOptions);
|
|
10
|
+
private get key();
|
|
11
|
+
hasAuthorization(): Promise<boolean>;
|
|
12
|
+
getAuthorization(): Promise<string | null>;
|
|
13
|
+
setAuthorization(authorization?: string | null): Promise<string | null>;
|
|
14
|
+
removeAuthorization(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SessionManager = void 0;
|
|
16
|
+
const jwt_decode_1 = require("jwt-decode");
|
|
17
|
+
const moment_1 = __importDefault(require("moment"));
|
|
18
|
+
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
19
|
+
class SessionManager extends eventemitter3_1.default {
|
|
20
|
+
constructor(options) {
|
|
21
|
+
super();
|
|
22
|
+
// Init service parameters
|
|
23
|
+
this.api = options.api;
|
|
24
|
+
this.storageProvider = options.storageProvider;
|
|
25
|
+
// Logging
|
|
26
|
+
console.log('SessionManager initialized', Date.now(), options.api);
|
|
27
|
+
}
|
|
28
|
+
get key() {
|
|
29
|
+
try {
|
|
30
|
+
if (this.storageProvider.key) {
|
|
31
|
+
return this.storageProvider.key();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
console.error(e);
|
|
36
|
+
}
|
|
37
|
+
return SessionManager.DEFAULT_AUTHORIZATION_STORAGE_KEY;
|
|
38
|
+
}
|
|
39
|
+
hasAuthorization() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return !!(yield this.getAuthorization());
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
getAuthorization() {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
return this.storageProvider.get(this.key);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
setAuthorization(authorization) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
if (authorization === null) {
|
|
52
|
+
yield this.removeAuthorization();
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
let nextAuthorization = yield (() => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
if (authorization === undefined) {
|
|
57
|
+
return yield this.getAuthorization();
|
|
58
|
+
}
|
|
59
|
+
return authorization;
|
|
60
|
+
}))();
|
|
61
|
+
if (!nextAuthorization) {
|
|
62
|
+
console.log('nextAuthorization is null or undefined');
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
// Replace Bearer prefix
|
|
67
|
+
nextAuthorization = nextAuthorization.replace(/^Bearer\s+/, '');
|
|
68
|
+
const decoded = (0, jwt_decode_1.jwtDecode)(nextAuthorization);
|
|
69
|
+
if (!decoded) {
|
|
70
|
+
console.warn('JWT decode failed');
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
console.log('Session:JWT decoded');
|
|
74
|
+
(() => {
|
|
75
|
+
console.log(' - User', decoded.uuid);
|
|
76
|
+
console.log(' - IAT', ...(() => {
|
|
77
|
+
if (!decoded.iat) {
|
|
78
|
+
return [decoded.iat];
|
|
79
|
+
}
|
|
80
|
+
const iat = moment_1.default.unix(decoded.iat);
|
|
81
|
+
if (!iat.isValid()) {
|
|
82
|
+
return [decoded.iat];
|
|
83
|
+
}
|
|
84
|
+
return [decoded.iat, iat.format(), iat.diff(Date.now(), 'days'), 'days left'];
|
|
85
|
+
})());
|
|
86
|
+
console.log(' - NBF', ...(() => {
|
|
87
|
+
if (!decoded.nbf) {
|
|
88
|
+
return [decoded.nbf];
|
|
89
|
+
}
|
|
90
|
+
const nbf = moment_1.default.unix(decoded.nbf);
|
|
91
|
+
if (!nbf.isValid()) {
|
|
92
|
+
return [decoded.nbf];
|
|
93
|
+
}
|
|
94
|
+
return [decoded.nbf, nbf.format(), nbf.diff(Date.now(), 'days'), 'days left'];
|
|
95
|
+
})());
|
|
96
|
+
console.log(' - EXP', ...(() => {
|
|
97
|
+
if (!decoded.exp) {
|
|
98
|
+
return [decoded.exp];
|
|
99
|
+
}
|
|
100
|
+
const exp = moment_1.default.unix(decoded.exp);
|
|
101
|
+
if (!exp.isValid()) {
|
|
102
|
+
return [decoded.exp];
|
|
103
|
+
}
|
|
104
|
+
return [decoded.exp, exp.format(), exp.diff(Date.now(), 'days'), 'days left'];
|
|
105
|
+
})());
|
|
106
|
+
})();
|
|
107
|
+
// AsyncStorage 에 토큰 저장
|
|
108
|
+
yield this.storageProvider.set(this.key, nextAuthorization);
|
|
109
|
+
// API Instance header 설정
|
|
110
|
+
this.api.defaults.headers.common.Authorization = `Bearer ${nextAuthorization}`;
|
|
111
|
+
// Emit
|
|
112
|
+
this.emit('AUTHORIZATION_CHANGED', nextAuthorization);
|
|
113
|
+
// Return
|
|
114
|
+
return nextAuthorization;
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
console.error(e);
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
removeAuthorization() {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
// API Instance header 에서 토큰 제거
|
|
125
|
+
delete this.api.defaults.headers.common.Authorization;
|
|
126
|
+
// 스토리지에서 authorization 제거
|
|
127
|
+
yield this.storageProvider.remove(this.key);
|
|
128
|
+
// Emit
|
|
129
|
+
this.emit('AUTHORIZATION_CHANGED', null);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.SessionManager = SessionManager;
|
|
134
|
+
SessionManager.DEFAULT_AUTHORIZATION_STORAGE_KEY = 'AUTHORIZATION';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { StorageProvider } from "../interfaces/StorageProvider.js";
|
|
3
|
+
export interface SessionManagerOptions {
|
|
4
|
+
api: AxiosInstance;
|
|
5
|
+
storageProvider: StorageProvider;
|
|
6
|
+
}
|
|
7
|
+
export type SessionManagerEvent = {
|
|
8
|
+
AUTHORIZATION_CHANGED: (authorization: string | null) => void;
|
|
9
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Transaction } from "sequelize";
|
|
2
2
|
import EventEmitter from 'eventemitter3';
|
|
3
|
-
import { TransactionManagerLogLevel, TransactionManagerTimeoutAction } from "../constants";
|
|
4
|
-
import { TransactionManagerAddOption, TransactionManagerEventTypes } from "./TransactionManager.types";
|
|
3
|
+
import { TransactionManagerLogLevel, TransactionManagerTimeoutAction } from "../constants/index.js";
|
|
4
|
+
import { TransactionManagerAddOption, TransactionManagerEventTypes } from "./TransactionManager.types.js";
|
|
5
5
|
export declare class TransactionManager {
|
|
6
6
|
static DEFAULT_TIMEOUT: number;
|
|
7
7
|
static DEFAULT_ACTION: TransactionManagerTimeoutAction;
|
|
@@ -14,16 +14,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.TransactionManager = void 0;
|
|
16
16
|
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
17
|
-
const
|
|
17
|
+
const index_js_1 = require("../constants/index.js");
|
|
18
18
|
const LOG_TAG = '[TransactionManager]';
|
|
19
19
|
class TransactionManager {
|
|
20
20
|
constructor() {
|
|
21
21
|
// Members
|
|
22
|
-
this.logLevel =
|
|
22
|
+
this.logLevel = index_js_1.TransactionManagerLogLevel.VERBOSE;
|
|
23
23
|
this.transactionTimeoutMap = new Map();
|
|
24
24
|
// Emitter
|
|
25
25
|
this.emitter = new eventemitter3_1.default();
|
|
26
|
-
if (this.logLevel <=
|
|
26
|
+
if (this.logLevel <= index_js_1.TransactionManagerLogLevel.VERBOSE) {
|
|
27
27
|
console.log(LOG_TAG, 'TransactionManager instance initialized');
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -36,7 +36,7 @@ class TransactionManager {
|
|
|
36
36
|
}
|
|
37
37
|
setLogLevel(logLevel) {
|
|
38
38
|
this.logLevel = logLevel;
|
|
39
|
-
if (this.logLevel <=
|
|
39
|
+
if (this.logLevel <= index_js_1.TransactionManagerLogLevel.VERBOSE) {
|
|
40
40
|
console.log(LOG_TAG, 'log level changed to', logLevel);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -49,7 +49,7 @@ class TransactionManager {
|
|
|
49
49
|
add(transaction, option) {
|
|
50
50
|
var _a, _b;
|
|
51
51
|
if (this.transactionTimeoutMap.has(transaction)) {
|
|
52
|
-
if (this.logLevel <=
|
|
52
|
+
if (this.logLevel <= index_js_1.TransactionManagerLogLevel.ERROR) {
|
|
53
53
|
console.error(LOG_TAG, 'transaction already exists');
|
|
54
54
|
}
|
|
55
55
|
return;
|
|
@@ -69,7 +69,7 @@ class TransactionManager {
|
|
|
69
69
|
if (transactionTimeout != null) {
|
|
70
70
|
clearTimeout(transactionTimeout.handler);
|
|
71
71
|
this.transactionTimeoutMap.delete(transaction);
|
|
72
|
-
if (this.logLevel <=
|
|
72
|
+
if (this.logLevel <= index_js_1.TransactionManagerLogLevel.VERBOSE) {
|
|
73
73
|
console.log(LOG_TAG, this.getTransactionLogArg(transaction), 'removed');
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -89,7 +89,7 @@ class TransactionManager {
|
|
|
89
89
|
let handled = false;
|
|
90
90
|
const finished = transaction === null || transaction === void 0 ? void 0 : transaction.finished;
|
|
91
91
|
if (finished != null) {
|
|
92
|
-
if (this.logLevel <=
|
|
92
|
+
if (this.logLevel <= index_js_1.TransactionManagerLogLevel.VERBOSE) {
|
|
93
93
|
console.log(LOG_TAG, this.getTransactionLogArg(transaction), `is already handled(${finished}) after`, reason);
|
|
94
94
|
}
|
|
95
95
|
this.remove(transaction);
|
|
@@ -98,18 +98,18 @@ class TransactionManager {
|
|
|
98
98
|
try {
|
|
99
99
|
let finished;
|
|
100
100
|
switch (action) {
|
|
101
|
-
case
|
|
101
|
+
case index_js_1.TransactionManagerTimeoutAction.ROLLBACK: {
|
|
102
102
|
yield transaction.rollback();
|
|
103
103
|
finished = 'rollback';
|
|
104
104
|
break;
|
|
105
105
|
}
|
|
106
|
-
case
|
|
106
|
+
case index_js_1.TransactionManagerTimeoutAction.COMMIT: {
|
|
107
107
|
yield transaction.commit();
|
|
108
108
|
finished = 'commit';
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
111
111
|
default: {
|
|
112
|
-
if (this.logLevel <=
|
|
112
|
+
if (this.logLevel <= index_js_1.TransactionManagerLogLevel.ERROR) {
|
|
113
113
|
console.error(LOG_TAG, `unknown action`, action);
|
|
114
114
|
}
|
|
115
115
|
break;
|
|
@@ -117,12 +117,12 @@ class TransactionManager {
|
|
|
117
117
|
}
|
|
118
118
|
handled = finished != null;
|
|
119
119
|
if (finished != null) {
|
|
120
|
-
if (this.logLevel <=
|
|
120
|
+
if (this.logLevel <= index_js_1.TransactionManagerLogLevel.ERROR) {
|
|
121
121
|
console.error(LOG_TAG, this.getTransactionLogArg(transaction), `handled(${finished}) after`, reason);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
else {
|
|
125
|
-
if (this.logLevel <=
|
|
125
|
+
if (this.logLevel <= index_js_1.TransactionManagerLogLevel.ERROR) {
|
|
126
126
|
console.error(LOG_TAG, this.getTransactionLogArg(transaction), `not handled 🚫`);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -148,4 +148,4 @@ class TransactionManager {
|
|
|
148
148
|
}
|
|
149
149
|
exports.TransactionManager = TransactionManager;
|
|
150
150
|
TransactionManager.DEFAULT_TIMEOUT = 60 * 1000;
|
|
151
|
-
TransactionManager.DEFAULT_ACTION =
|
|
151
|
+
TransactionManager.DEFAULT_ACTION = index_js_1.TransactionManagerTimeoutAction.ROLLBACK;
|