joye-backend-utility 5.1.10 → 5.1.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/config/index.d.ts +2 -2
- package/dist/config/index.js +8 -8
- package/dist/database.d.ts +26 -26
- package/dist/database.js +142 -141
- package/dist/dateTime.d.ts +11 -11
- package/dist/dateTime.js +82 -82
- package/dist/index.d.ts +6 -6
- package/dist/index.js +26 -26
- package/dist/jwt.d.ts +3 -3
- package/dist/jwt.js +40 -40
- package/dist/redisClient.d.ts +6 -6
- package/dist/redisClient.js +34 -34
- package/dist/schema/brew.d.ts +2 -2
- package/dist/schema/brew.js +160 -160
- package/dist/schema/databaseInfo.d.ts +2 -2
- package/dist/schema/databaseInfo.js +35 -35
- package/dist/schema/index.d.ts +38 -37
- package/dist/schema/index.js +79 -77
- package/dist/schema/masterAppSetting.d.ts +2 -2
- package/dist/schema/masterAppSetting.js +24 -24
- package/dist/schema/masterBlessingsData.d.ts +2 -2
- package/dist/schema/masterBlessingsData.js +41 -41
- package/dist/schema/masterData.d.ts +2 -2
- package/dist/schema/masterData.js +28 -28
- package/dist/schema/masterEmotion.d.ts +2 -2
- package/dist/schema/masterEmotion.js +115 -115
- package/dist/schema/masterEmotionMessageMapping.d.ts +2 -2
- package/dist/schema/masterEmotionMessageMapping.js +16 -16
- package/dist/schema/masterEmotionMessageTypeThemeMapping.d.ts +2 -2
- package/dist/schema/masterEmotionMessageTypeThemeMapping.js +23 -23
- package/dist/schema/masterLinkCard.d.ts +2 -2
- package/dist/schema/masterLinkCard.js +28 -28
- package/dist/schema/masterPodcast.d.ts +2 -2
- package/dist/schema/masterPodcast.js +37 -37
- package/dist/schema/masterPredictionEmotion.d.ts +2 -2
- package/dist/schema/masterPredictionEmotion.js +27 -27
- package/dist/schema/masterPredictionEmotionMessage.d.ts +2 -2
- package/dist/schema/masterPredictionEmotionMessage.js +26 -26
- package/dist/schema/masterPredictionEmotionMessageMapping.d.ts +2 -2
- package/dist/schema/masterPredictionEmotionMessageMapping.js +16 -16
- package/dist/schema/masterSuggestionsMessage.model.d.ts +2 -2
- package/dist/schema/masterSuggestionsMessage.model.js +31 -31
- package/dist/schema/masterSuggestionsParameter.model.d.ts +2 -2
- package/dist/schema/masterSuggestionsParameter.model.js +23 -23
- package/dist/schema/masterThemeData.d.ts +2 -2
- package/dist/schema/masterThemeData.js +48 -48
- package/dist/schema/masterThemeMessage.d.ts +2 -2
- package/dist/schema/masterThemeMessage.js +13 -13
- package/dist/schema/masterTraining.d.ts +2 -2
- package/dist/schema/masterTraining.js +29 -29
- package/dist/schema/masterTrainingWeek.d.ts +2 -2
- package/dist/schema/masterTrainingWeek.js +32 -32
- package/dist/schema/masterVideo.d.ts +2 -2
- package/dist/schema/masterVideo.js +33 -33
- package/dist/schema/organization.d.ts +2 -2
- package/dist/schema/organization.js +79 -79
- package/dist/schema/organizationUserAttrPermission.d.ts +2 -2
- package/dist/schema/organizationUserAttrPermission.js +59 -59
- package/dist/schema/platform.d.ts +2 -2
- package/dist/schema/platform.js +28 -28
- package/dist/schema/timezones.d.ts +2 -2
- package/dist/schema/timezones.js +26 -26
- package/dist/schema/user.d.ts +2 -2
- package/dist/schema/user.js +202 -202
- package/dist/schema/userFeedback.d.ts +2 -2
- package/dist/schema/userFeedback.js +24 -24
- package/dist/schema/userGoal.d.ts +2 -2
- package/dist/schema/userGoal.js +38 -38
- package/dist/schema/userJoyLevelQa.d.ts +2 -2
- package/dist/schema/userJoyLevelQa.js +49 -49
- package/dist/schema/userLog.d.ts +2 -2
- package/dist/schema/userLog.js +22 -22
- package/dist/schema/userMeeting.d.ts +2 -2
- package/dist/schema/userMeeting.js +22 -22
- package/dist/schema/userMessages.d.ts +2 -2
- package/dist/schema/userMessages.js +24 -24
- package/dist/schema/userMessagesLog.d.ts +2 -2
- package/dist/schema/userMessagesLog.js +69 -69
- package/dist/schema/userRecommendation.d.ts +2 -2
- package/dist/schema/userRecommendation.js +24 -24
- package/dist/schema/userReminder.d.ts +2 -2
- package/dist/schema/userReminder.js +61 -61
- package/dist/schema/userTrainingData.d.ts +2 -2
- package/dist/schema/userTrainingData.js +41 -37
- package/dist/schema/userTrainingWeekData.d.ts +2 -2
- package/dist/schema/userTrainingWeekData.js +40 -36
- package/dist/schema/userVideo.d.ts +2 -2
- package/dist/schema/userVideo.js +50 -50
- package/dist/schema/userWeekActivity.d.ts +2 -0
- package/dist/schema/userWeekActivity.js +90 -0
- package/dist/util.d.ts +2 -2
- package/dist/util.js +13 -13
- package/package.json +1 -1
package/dist/config/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const CREDENTIALS: boolean;
|
|
2
|
-
export declare const NODE_ENV: string, PORT: string, DB_HOST: string, DB_PORT: string, DB_DATABASE: string, SECRET_KEY: string, LOG_FORMAT: string, LOG_DIR: string, ORIGIN: string, DB_USER: string, DB_PASSWORD: string, DB_KEY: string;
|
|
1
|
+
export declare const CREDENTIALS: boolean;
|
|
2
|
+
export declare const NODE_ENV: string, PORT: string, DB_HOST: string, DB_PORT: string, DB_DATABASE: string, SECRET_KEY: string, LOG_FORMAT: string, LOG_DIR: string, ORIGIN: string, DB_USER: string, DB_PASSWORD: string, DB_KEY: string;
|
package/dist/config/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.DB_KEY = exports.DB_PASSWORD = exports.DB_USER = exports.ORIGIN = exports.LOG_DIR = exports.LOG_FORMAT = exports.SECRET_KEY = exports.DB_DATABASE = exports.DB_PORT = exports.DB_HOST = exports.PORT = exports.NODE_ENV = exports.CREDENTIALS = void 0;
|
|
5
|
-
const dotenv_1 = require("dotenv");
|
|
6
|
-
(0, dotenv_1.config)({ path: `.env.${process.env.NODE_ENV || 'development'}.local` });
|
|
7
|
-
exports.CREDENTIALS = process.env.CREDENTIALS === 'true';
|
|
8
|
-
_a = process.env, exports.NODE_ENV = _a.NODE_ENV, exports.PORT = _a.PORT, exports.DB_HOST = _a.DB_HOST, exports.DB_PORT = _a.DB_PORT, exports.DB_DATABASE = _a.DB_DATABASE, exports.SECRET_KEY = _a.SECRET_KEY, exports.LOG_FORMAT = _a.LOG_FORMAT, exports.LOG_DIR = _a.LOG_DIR, exports.ORIGIN = _a.ORIGIN, exports.DB_USER = _a.DB_USER, exports.DB_PASSWORD = _a.DB_PASSWORD, exports.DB_KEY = _a.DB_KEY;
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.DB_KEY = exports.DB_PASSWORD = exports.DB_USER = exports.ORIGIN = exports.LOG_DIR = exports.LOG_FORMAT = exports.SECRET_KEY = exports.DB_DATABASE = exports.DB_PORT = exports.DB_HOST = exports.PORT = exports.NODE_ENV = exports.CREDENTIALS = void 0;
|
|
5
|
+
const dotenv_1 = require("dotenv");
|
|
6
|
+
(0, dotenv_1.config)({ path: `.env.${process.env.NODE_ENV || 'development'}.local` });
|
|
7
|
+
exports.CREDENTIALS = process.env.CREDENTIALS === 'true';
|
|
8
|
+
_a = process.env, exports.NODE_ENV = _a.NODE_ENV, exports.PORT = _a.PORT, exports.DB_HOST = _a.DB_HOST, exports.DB_PORT = _a.DB_PORT, exports.DB_DATABASE = _a.DB_DATABASE, exports.SECRET_KEY = _a.SECRET_KEY, exports.LOG_FORMAT = _a.LOG_FORMAT, exports.LOG_DIR = _a.LOG_DIR, exports.ORIGIN = _a.ORIGIN, exports.DB_USER = _a.DB_USER, exports.DB_PASSWORD = _a.DB_PASSWORD, exports.DB_KEY = _a.DB_KEY;
|
package/dist/database.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { Connection } from 'mongoose';
|
|
2
|
-
export default class database {
|
|
3
|
-
defaultConnection: Connection;
|
|
4
|
-
env: string;
|
|
5
|
-
private static connectionStates;
|
|
6
|
-
static connections: {};
|
|
7
|
-
modelSchemaInConnection: (con: any) => Promise<void>;
|
|
8
|
-
connectToDatabase: () => void;
|
|
9
|
-
connectionFactory: (key: any, url: any) => Promise<Connection>;
|
|
10
|
-
closeDbConnection: (dbConnection: Connection) => void;
|
|
11
|
-
getConnectionInfo: (key: any) => {
|
|
12
|
-
name: any;
|
|
13
|
-
id: any;
|
|
14
|
-
host: any;
|
|
15
|
-
status: any;
|
|
16
|
-
};
|
|
17
|
-
static find: (model: any, filter?: object, sort?: number, fields?: {}) => Promise<any>;
|
|
18
|
-
static findWithSkip: (model: any, filter?: object, sort?: number, fields?: {}, skipCount?: number, limitCount?: number) => Promise<any>;
|
|
19
|
-
static findNumberOfRecords: (model: any, filter?: object, sort?: number, fields?: {}) => Promise<any>;
|
|
20
|
-
static findOne: (model: any, query: object) => Promise<any>;
|
|
21
|
-
static findById: (model: any, id: string) => Promise<any>;
|
|
22
|
-
static create: (model: any, payload: object) => Promise<any>;
|
|
23
|
-
static findByIdAndUpdate: (model: any, id: string, payload: object) => Promise<any>;
|
|
24
|
-
static findByIdAndDelete: (model: any, id: string) => Promise<any>;
|
|
25
|
-
static findWithLimit: (model: any, filter?: object, sort?: {}, fields?: {}, limit?: number) => Promise<any>;
|
|
26
|
-
}
|
|
1
|
+
import { Connection } from 'mongoose';
|
|
2
|
+
export default class database {
|
|
3
|
+
defaultConnection: Connection;
|
|
4
|
+
env: string;
|
|
5
|
+
private static connectionStates;
|
|
6
|
+
static connections: {};
|
|
7
|
+
modelSchemaInConnection: (con: any) => Promise<void>;
|
|
8
|
+
connectToDatabase: () => void;
|
|
9
|
+
connectionFactory: (key: any, url: any) => Promise<Connection>;
|
|
10
|
+
closeDbConnection: (dbConnection: Connection) => void;
|
|
11
|
+
getConnectionInfo: (key: any) => {
|
|
12
|
+
name: any;
|
|
13
|
+
id: any;
|
|
14
|
+
host: any;
|
|
15
|
+
status: any;
|
|
16
|
+
};
|
|
17
|
+
static find: (model: any, filter?: object, sort?: number, fields?: {}) => Promise<any>;
|
|
18
|
+
static findWithSkip: (model: any, filter?: object, sort?: number, fields?: {}, skipCount?: number, limitCount?: number) => Promise<any>;
|
|
19
|
+
static findNumberOfRecords: (model: any, filter?: object, sort?: number, fields?: {}) => Promise<any>;
|
|
20
|
+
static findOne: (model: any, query: object) => Promise<any>;
|
|
21
|
+
static findById: (model: any, id: string) => Promise<any>;
|
|
22
|
+
static create: (model: any, payload: object) => Promise<any>;
|
|
23
|
+
static findByIdAndUpdate: (model: any, id: string, payload: object) => Promise<any>;
|
|
24
|
+
static findByIdAndDelete: (model: any, id: string) => Promise<any>;
|
|
25
|
+
static findWithLimit: (model: any, filter?: object, sort?: {}, fields?: {}, limit?: number) => Promise<any>;
|
|
26
|
+
}
|
package/dist/database.js
CHANGED
|
@@ -1,141 +1,142 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const mongoose_1 = require("mongoose");
|
|
4
|
-
const config_1 = require("./config");
|
|
5
|
-
const schema_1 = require("./schema");
|
|
6
|
-
class database {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.env = config_1.NODE_ENV || 'development';
|
|
9
|
-
this.modelSchemaInConnection = async (con) => {
|
|
10
|
-
con.model('Brew', schema_1.BrewSchema);
|
|
11
|
-
con.model('Master_App_Setting', schema_1.MasterAppSettingSchema);
|
|
12
|
-
con.model('Master_Data', schema_1.MasterDataSchema);
|
|
13
|
-
con.model('Master_Emotion', schema_1.MasterEmotionsSchema);
|
|
14
|
-
con.model('Master_Emotion_Message_Mapping', schema_1.MasterEmotionsMessageMappingSchema);
|
|
15
|
-
con.model('Master_Emotion_Message_Type_Theme_Mapping', schema_1.MasterEmotionMessageTypeThemeMappingSchema);
|
|
16
|
-
con.model('Master_Podcast', schema_1.MasterPodcastSchema);
|
|
17
|
-
con.model('Master_Prediction_Emotion', schema_1.MasterPredictionEmotionSchema);
|
|
18
|
-
con.model('Master_Prediction_Emotion_Message', schema_1.MasterPredictionEmotionMessageSchema);
|
|
19
|
-
con.model('Master_Prediction_Emotion_Message_Mapping', schema_1.MasterPredictionEmotionsMessageMappingSchema);
|
|
20
|
-
con.model('Master_Theme_Data', schema_1.MasterThemeDataSchema);
|
|
21
|
-
con.model('Master_Theme_Message', schema_1.MasterThemeMessageSchema);
|
|
22
|
-
con.model('Organization', schema_1.OrganizationSchema);
|
|
23
|
-
con.model('Platform', schema_1.PlatformSchema);
|
|
24
|
-
con.model('User', schema_1.UserSchema);
|
|
25
|
-
con.model('User_Log', schema_1.UserLogSchema);
|
|
26
|
-
con.model('User_Meeting', schema_1.UserMeetingSchema);
|
|
27
|
-
con.model('User_Message', schema_1.UserMessageSchema);
|
|
28
|
-
con.model('User_Message_Log', schema_1.UserMessageLogSchema);
|
|
29
|
-
con.model('Database_Info', schema_1.DatabaseInfoSchema);
|
|
30
|
-
con.model('Master_Video', schema_1.MasterVideoSchema);
|
|
31
|
-
con.model('Master_Blessings_Data', schema_1.MasterBlessingsDataSchema);
|
|
32
|
-
con.model('Master_Suggestions_Message', schema_1.MasterSuggestionsMessageSchema);
|
|
33
|
-
con.model('Master_Suggestions_Parameter', schema_1.MasterSuggestionsParameterSchema);
|
|
34
|
-
con.model('User_Recommendation', schema_1.UserRecommendationSchema);
|
|
35
|
-
con.model('Master_Link_Card', schema_1.MasterLinkCardSchema);
|
|
36
|
-
con.model('User_Reminder', schema_1.UserReminderSchema);
|
|
37
|
-
con.model('User_Feedback', schema_1.UserFeedbackSchema);
|
|
38
|
-
con.model('User_Video', schema_1.UserVideoSchema);
|
|
39
|
-
con.model('Timezone', schema_1.TimezoneSchema);
|
|
40
|
-
con.model('Organization_User_Attr_Permission', schema_1.OrganizationUserAttrPermissionSchema);
|
|
41
|
-
con.model('User_Goal', schema_1.userGoalSchema);
|
|
42
|
-
con.model('User_Joy_Level_Qa', schema_1.userJoyLevelQaSchema);
|
|
43
|
-
con.model('User_Training_Data', schema_1.UserTrainingDataSchema);
|
|
44
|
-
con.model('User_Training_Week_Data', schema_1.UserTrainingWeekDataSchema);
|
|
45
|
-
con.model('Master_Training', schema_1.MasterTrainingSchema);
|
|
46
|
-
con.model('Master_Training_Week', schema_1.MasterTrainingWeekSchema);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
database.
|
|
116
|
-
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const mongoose_1 = require("mongoose");
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const schema_1 = require("./schema");
|
|
6
|
+
class database {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.env = config_1.NODE_ENV || 'development';
|
|
9
|
+
this.modelSchemaInConnection = async (con) => {
|
|
10
|
+
con.model('Brew', schema_1.BrewSchema);
|
|
11
|
+
con.model('Master_App_Setting', schema_1.MasterAppSettingSchema);
|
|
12
|
+
con.model('Master_Data', schema_1.MasterDataSchema);
|
|
13
|
+
con.model('Master_Emotion', schema_1.MasterEmotionsSchema);
|
|
14
|
+
con.model('Master_Emotion_Message_Mapping', schema_1.MasterEmotionsMessageMappingSchema);
|
|
15
|
+
con.model('Master_Emotion_Message_Type_Theme_Mapping', schema_1.MasterEmotionMessageTypeThemeMappingSchema);
|
|
16
|
+
con.model('Master_Podcast', schema_1.MasterPodcastSchema);
|
|
17
|
+
con.model('Master_Prediction_Emotion', schema_1.MasterPredictionEmotionSchema);
|
|
18
|
+
con.model('Master_Prediction_Emotion_Message', schema_1.MasterPredictionEmotionMessageSchema);
|
|
19
|
+
con.model('Master_Prediction_Emotion_Message_Mapping', schema_1.MasterPredictionEmotionsMessageMappingSchema);
|
|
20
|
+
con.model('Master_Theme_Data', schema_1.MasterThemeDataSchema);
|
|
21
|
+
con.model('Master_Theme_Message', schema_1.MasterThemeMessageSchema);
|
|
22
|
+
con.model('Organization', schema_1.OrganizationSchema);
|
|
23
|
+
con.model('Platform', schema_1.PlatformSchema);
|
|
24
|
+
con.model('User', schema_1.UserSchema);
|
|
25
|
+
con.model('User_Log', schema_1.UserLogSchema);
|
|
26
|
+
con.model('User_Meeting', schema_1.UserMeetingSchema);
|
|
27
|
+
con.model('User_Message', schema_1.UserMessageSchema);
|
|
28
|
+
con.model('User_Message_Log', schema_1.UserMessageLogSchema);
|
|
29
|
+
con.model('Database_Info', schema_1.DatabaseInfoSchema);
|
|
30
|
+
con.model('Master_Video', schema_1.MasterVideoSchema);
|
|
31
|
+
con.model('Master_Blessings_Data', schema_1.MasterBlessingsDataSchema);
|
|
32
|
+
con.model('Master_Suggestions_Message', schema_1.MasterSuggestionsMessageSchema);
|
|
33
|
+
con.model('Master_Suggestions_Parameter', schema_1.MasterSuggestionsParameterSchema);
|
|
34
|
+
con.model('User_Recommendation', schema_1.UserRecommendationSchema);
|
|
35
|
+
con.model('Master_Link_Card', schema_1.MasterLinkCardSchema);
|
|
36
|
+
con.model('User_Reminder', schema_1.UserReminderSchema);
|
|
37
|
+
con.model('User_Feedback', schema_1.UserFeedbackSchema);
|
|
38
|
+
con.model('User_Video', schema_1.UserVideoSchema);
|
|
39
|
+
con.model('Timezone', schema_1.TimezoneSchema);
|
|
40
|
+
con.model('Organization_User_Attr_Permission', schema_1.OrganizationUserAttrPermissionSchema);
|
|
41
|
+
con.model('User_Goal', schema_1.userGoalSchema);
|
|
42
|
+
con.model('User_Joy_Level_Qa', schema_1.userJoyLevelQaSchema);
|
|
43
|
+
con.model('User_Training_Data', schema_1.UserTrainingDataSchema);
|
|
44
|
+
con.model('User_Training_Week_Data', schema_1.UserTrainingWeekDataSchema);
|
|
45
|
+
con.model('Master_Training', schema_1.MasterTrainingSchema);
|
|
46
|
+
con.model('Master_Training_Week', schema_1.MasterTrainingWeekSchema);
|
|
47
|
+
con.model('User_Week_Activity', schema_1.UserWeekActivitySchema);
|
|
48
|
+
};
|
|
49
|
+
this.connectToDatabase = () => {
|
|
50
|
+
const env = config_1.NODE_ENV || 'development';
|
|
51
|
+
const dbConnection = {
|
|
52
|
+
url: `mongodb://${config_1.DB_HOST}:${config_1.DB_PORT}/${config_1.DB_DATABASE}`,
|
|
53
|
+
options: {
|
|
54
|
+
useNewUrlParser: true,
|
|
55
|
+
useUnifiedTopology: true,
|
|
56
|
+
useFindAndModify: false,
|
|
57
|
+
user: config_1.DB_USER || '',
|
|
58
|
+
pass: config_1.DB_PASSWORD || '',
|
|
59
|
+
// autoIndex: false, // True only for development
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
if (env !== 'production') {
|
|
63
|
+
(0, mongoose_1.set)('debug', true);
|
|
64
|
+
}
|
|
65
|
+
let url = dbConnection.url;
|
|
66
|
+
if (process.env.ENABLE_SSL === 'yes') {
|
|
67
|
+
url = `${dbConnection.url}?ssl=true&replicaSet=globaldb&retrywrites=false`;
|
|
68
|
+
}
|
|
69
|
+
(0, mongoose_1.createConnection)(url, dbConnection.options, (err, dbConnection) => {
|
|
70
|
+
if (err) {
|
|
71
|
+
console.log('Connection error', err);
|
|
72
|
+
}
|
|
73
|
+
this.modelSchemaInConnection(dbConnection);
|
|
74
|
+
database.connections[`${config_1.DB_KEY}`] = dbConnection;
|
|
75
|
+
console.log('Connected to database');
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
this.connectionFactory = async (key, url) => {
|
|
79
|
+
const options = {
|
|
80
|
+
useNewUrlParser: true,
|
|
81
|
+
useUnifiedTopology: true,
|
|
82
|
+
useFindAndModify: false,
|
|
83
|
+
// autoIndex: false, // True only for development
|
|
84
|
+
};
|
|
85
|
+
const connection = await (0, mongoose_1.createConnection)(url, options);
|
|
86
|
+
this.modelSchemaInConnection(connection);
|
|
87
|
+
database.connections[`${key}`] = connection;
|
|
88
|
+
return connection;
|
|
89
|
+
};
|
|
90
|
+
this.closeDbConnection = (dbConnection) => {
|
|
91
|
+
if (dbConnection) {
|
|
92
|
+
dbConnection.close();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
this.getConnectionInfo = key => {
|
|
96
|
+
if (database.connections[`${key}`]) {
|
|
97
|
+
return {
|
|
98
|
+
name: database.connections[`${key}`].name,
|
|
99
|
+
id: database.connections[`${key}`].id,
|
|
100
|
+
host: database.connections[`${key}`].host,
|
|
101
|
+
status: database.connectionStates[database.connections[`${key}`].readyState],
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.default = database;
|
|
109
|
+
database.connectionStates = {
|
|
110
|
+
0: 'disconnected',
|
|
111
|
+
1: 'connected',
|
|
112
|
+
2: 'connecting',
|
|
113
|
+
3: 'disconnecting',
|
|
114
|
+
};
|
|
115
|
+
database.connections = {};
|
|
116
|
+
database.find = (model, filter = {}, sort = 1, fields = {}) => {
|
|
117
|
+
return model.find(filter, fields).sort({ _id: sort });
|
|
118
|
+
};
|
|
119
|
+
database.findWithSkip = (model, filter = {}, sort = 1, fields = {}, skipCount = 0, limitCount = 100) => {
|
|
120
|
+
return model.find(filter, fields).skip(skipCount).limit(limitCount).sort({ _id: sort });
|
|
121
|
+
};
|
|
122
|
+
database.findNumberOfRecords = (model, filter = {}, sort = 1, fields = {}) => {
|
|
123
|
+
return model.find(filter, fields).sort({ _id: sort }).count();
|
|
124
|
+
};
|
|
125
|
+
database.findOne = (model, query) => {
|
|
126
|
+
return model.findOne(query);
|
|
127
|
+
};
|
|
128
|
+
database.findById = (model, id) => {
|
|
129
|
+
return model.findOne({ _id: mongoose_1.Types.ObjectId(id) }).sort({ _id: -1 });
|
|
130
|
+
};
|
|
131
|
+
database.create = (model, payload) => {
|
|
132
|
+
return model.create(payload);
|
|
133
|
+
};
|
|
134
|
+
database.findByIdAndUpdate = (model, id, payload) => {
|
|
135
|
+
return model.findByIdAndUpdate(id, payload, { new: true });
|
|
136
|
+
};
|
|
137
|
+
database.findByIdAndDelete = (model, id) => {
|
|
138
|
+
return model.findByIdAndDelete(id);
|
|
139
|
+
};
|
|
140
|
+
database.findWithLimit = (model, filter = {}, sort = {}, fields = {}, limit = 100) => {
|
|
141
|
+
return model.find(filter, fields).sort(sort).limit(limit);
|
|
142
|
+
};
|
package/dist/dateTime.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export declare const getCurrentDateTime: (date: string, format?: string) => string;
|
|
2
|
-
export declare const getMoment: () => any;
|
|
3
|
-
export declare const newDate: () => any;
|
|
4
|
-
export declare const getDatesBetweenRange: (start: string, end: string) => string[];
|
|
5
|
-
export declare const getCurrentUtcTime: (format?: string) => string;
|
|
6
|
-
export declare const addDays: (date: string, day: number) => string;
|
|
7
|
-
export declare const addYears: (date: string, year: number, format?: string) => string;
|
|
8
|
-
export declare const addMinutes: (date: string, minute: number, format?: string) => string;
|
|
9
|
-
export declare const getPreviousWorkday: () => any;
|
|
10
|
-
export declare const get2ndLastPreviousWorkday: () => any;
|
|
11
|
-
export declare const getCurrentEpoch: () => any;
|
|
1
|
+
export declare const getCurrentDateTime: (date: string, format?: string) => string;
|
|
2
|
+
export declare const getMoment: () => any;
|
|
3
|
+
export declare const newDate: () => any;
|
|
4
|
+
export declare const getDatesBetweenRange: (start: string, end: string) => string[];
|
|
5
|
+
export declare const getCurrentUtcTime: (format?: string) => string;
|
|
6
|
+
export declare const addDays: (date: string, day: number) => string;
|
|
7
|
+
export declare const addYears: (date: string, year: number, format?: string) => string;
|
|
8
|
+
export declare const addMinutes: (date: string, minute: number, format?: string) => string;
|
|
9
|
+
export declare const getPreviousWorkday: () => any;
|
|
10
|
+
export declare const get2ndLastPreviousWorkday: () => any;
|
|
11
|
+
export declare const getCurrentEpoch: () => any;
|
package/dist/dateTime.js
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCurrentEpoch = exports.get2ndLastPreviousWorkday = exports.getPreviousWorkday = exports.addMinutes = exports.addYears = exports.addDays = exports.getCurrentUtcTime = exports.getDatesBetweenRange = exports.newDate = exports.getMoment = exports.getCurrentDateTime = void 0;
|
|
4
|
-
const moment = require('moment');
|
|
5
|
-
const dateFormat = 'YYYY-MM-DD';
|
|
6
|
-
const getCurrentDateTime = (date, format = dateFormat) => {
|
|
7
|
-
return moment(date).format(format);
|
|
8
|
-
};
|
|
9
|
-
exports.getCurrentDateTime = getCurrentDateTime;
|
|
10
|
-
const getMoment = () => moment;
|
|
11
|
-
exports.getMoment = getMoment;
|
|
12
|
-
const newDate = () => {
|
|
13
|
-
const newDate = moment.utc().toDate();
|
|
14
|
-
return newDate;
|
|
15
|
-
};
|
|
16
|
-
exports.newDate = newDate;
|
|
17
|
-
const getDatesBetweenRange = (start, end) => {
|
|
18
|
-
const datePayload = {
|
|
19
|
-
startDate: moment(start, 'DD-MM-YYYY'),
|
|
20
|
-
endDate: moment(end, 'DD-MM-YYYY'),
|
|
21
|
-
};
|
|
22
|
-
const dates = [];
|
|
23
|
-
const currentDate = datePayload.startDate;
|
|
24
|
-
while (currentDate.isSameOrBefore(datePayload.endDate)) {
|
|
25
|
-
dates.push(currentDate.format('DD-MM-YYYY'));
|
|
26
|
-
currentDate.add(1, 'days');
|
|
27
|
-
}
|
|
28
|
-
return dates;
|
|
29
|
-
};
|
|
30
|
-
exports.getDatesBetweenRange = getDatesBetweenRange;
|
|
31
|
-
const getCurrentUtcTime = (format) => {
|
|
32
|
-
const newDate = moment.utc();
|
|
33
|
-
if (format) {
|
|
34
|
-
return newDate.format(format);
|
|
35
|
-
}
|
|
36
|
-
return newDate.toISOString();
|
|
37
|
-
};
|
|
38
|
-
exports.getCurrentUtcTime = getCurrentUtcTime;
|
|
39
|
-
const addDays = (date, day) => {
|
|
40
|
-
return moment(date, dateFormat).add(day, 'days').format(dateFormat);
|
|
41
|
-
};
|
|
42
|
-
exports.addDays = addDays;
|
|
43
|
-
const addYears = (date, year, format) => {
|
|
44
|
-
const newDate = moment(date).add(year, 'years');
|
|
45
|
-
if (format) {
|
|
46
|
-
return newDate.format(format);
|
|
47
|
-
}
|
|
48
|
-
return newDate.toISOString();
|
|
49
|
-
};
|
|
50
|
-
exports.addYears = addYears;
|
|
51
|
-
const addMinutes = (date, minute, format) => {
|
|
52
|
-
const newDate = moment(date).add(minute, 'minutes');
|
|
53
|
-
if (format) {
|
|
54
|
-
return newDate.format(format);
|
|
55
|
-
}
|
|
56
|
-
return newDate.toISOString();
|
|
57
|
-
};
|
|
58
|
-
exports.addMinutes = addMinutes;
|
|
59
|
-
const getPreviousWorkday = () => {
|
|
60
|
-
const workday = moment();
|
|
61
|
-
const day = workday.day();
|
|
62
|
-
let diff = 1;
|
|
63
|
-
if (day == 1) {
|
|
64
|
-
diff = day + 2;
|
|
65
|
-
}
|
|
66
|
-
return workday.subtract(diff, 'days').format('DD-MM-yyyy');
|
|
67
|
-
};
|
|
68
|
-
exports.getPreviousWorkday = getPreviousWorkday;
|
|
69
|
-
const get2ndLastPreviousWorkday = () => {
|
|
70
|
-
const workday = moment();
|
|
71
|
-
const day = workday.day();
|
|
72
|
-
let diff = 2;
|
|
73
|
-
if (day == 1 || day == 2) {
|
|
74
|
-
diff = 4;
|
|
75
|
-
}
|
|
76
|
-
return workday.subtract(diff, 'days').format('DD-MM-yyyy');
|
|
77
|
-
};
|
|
78
|
-
exports.get2ndLastPreviousWorkday = get2ndLastPreviousWorkday;
|
|
79
|
-
const getCurrentEpoch = () => {
|
|
80
|
-
return moment.utc().valueOf();
|
|
81
|
-
};
|
|
82
|
-
exports.getCurrentEpoch = getCurrentEpoch;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCurrentEpoch = exports.get2ndLastPreviousWorkday = exports.getPreviousWorkday = exports.addMinutes = exports.addYears = exports.addDays = exports.getCurrentUtcTime = exports.getDatesBetweenRange = exports.newDate = exports.getMoment = exports.getCurrentDateTime = void 0;
|
|
4
|
+
const moment = require('moment');
|
|
5
|
+
const dateFormat = 'YYYY-MM-DD';
|
|
6
|
+
const getCurrentDateTime = (date, format = dateFormat) => {
|
|
7
|
+
return moment(date).format(format);
|
|
8
|
+
};
|
|
9
|
+
exports.getCurrentDateTime = getCurrentDateTime;
|
|
10
|
+
const getMoment = () => moment;
|
|
11
|
+
exports.getMoment = getMoment;
|
|
12
|
+
const newDate = () => {
|
|
13
|
+
const newDate = moment.utc().toDate();
|
|
14
|
+
return newDate;
|
|
15
|
+
};
|
|
16
|
+
exports.newDate = newDate;
|
|
17
|
+
const getDatesBetweenRange = (start, end) => {
|
|
18
|
+
const datePayload = {
|
|
19
|
+
startDate: moment(start, 'DD-MM-YYYY'),
|
|
20
|
+
endDate: moment(end, 'DD-MM-YYYY'),
|
|
21
|
+
};
|
|
22
|
+
const dates = [];
|
|
23
|
+
const currentDate = datePayload.startDate;
|
|
24
|
+
while (currentDate.isSameOrBefore(datePayload.endDate)) {
|
|
25
|
+
dates.push(currentDate.format('DD-MM-YYYY'));
|
|
26
|
+
currentDate.add(1, 'days');
|
|
27
|
+
}
|
|
28
|
+
return dates;
|
|
29
|
+
};
|
|
30
|
+
exports.getDatesBetweenRange = getDatesBetweenRange;
|
|
31
|
+
const getCurrentUtcTime = (format) => {
|
|
32
|
+
const newDate = moment.utc();
|
|
33
|
+
if (format) {
|
|
34
|
+
return newDate.format(format);
|
|
35
|
+
}
|
|
36
|
+
return newDate.toISOString();
|
|
37
|
+
};
|
|
38
|
+
exports.getCurrentUtcTime = getCurrentUtcTime;
|
|
39
|
+
const addDays = (date, day) => {
|
|
40
|
+
return moment(date, dateFormat).add(day, 'days').format(dateFormat);
|
|
41
|
+
};
|
|
42
|
+
exports.addDays = addDays;
|
|
43
|
+
const addYears = (date, year, format) => {
|
|
44
|
+
const newDate = moment(date).add(year, 'years');
|
|
45
|
+
if (format) {
|
|
46
|
+
return newDate.format(format);
|
|
47
|
+
}
|
|
48
|
+
return newDate.toISOString();
|
|
49
|
+
};
|
|
50
|
+
exports.addYears = addYears;
|
|
51
|
+
const addMinutes = (date, minute, format) => {
|
|
52
|
+
const newDate = moment(date).add(minute, 'minutes');
|
|
53
|
+
if (format) {
|
|
54
|
+
return newDate.format(format);
|
|
55
|
+
}
|
|
56
|
+
return newDate.toISOString();
|
|
57
|
+
};
|
|
58
|
+
exports.addMinutes = addMinutes;
|
|
59
|
+
const getPreviousWorkday = () => {
|
|
60
|
+
const workday = moment();
|
|
61
|
+
const day = workday.day();
|
|
62
|
+
let diff = 1;
|
|
63
|
+
if (day == 1) {
|
|
64
|
+
diff = day + 2;
|
|
65
|
+
}
|
|
66
|
+
return workday.subtract(diff, 'days').format('DD-MM-yyyy');
|
|
67
|
+
};
|
|
68
|
+
exports.getPreviousWorkday = getPreviousWorkday;
|
|
69
|
+
const get2ndLastPreviousWorkday = () => {
|
|
70
|
+
const workday = moment();
|
|
71
|
+
const day = workday.day();
|
|
72
|
+
let diff = 2;
|
|
73
|
+
if (day == 1 || day == 2) {
|
|
74
|
+
diff = 4;
|
|
75
|
+
}
|
|
76
|
+
return workday.subtract(diff, 'days').format('DD-MM-yyyy');
|
|
77
|
+
};
|
|
78
|
+
exports.get2ndLastPreviousWorkday = get2ndLastPreviousWorkday;
|
|
79
|
+
const getCurrentEpoch = () => {
|
|
80
|
+
return moment.utc().valueOf();
|
|
81
|
+
};
|
|
82
|
+
exports.getCurrentEpoch = getCurrentEpoch;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import database from './database';
|
|
2
|
-
export default database;
|
|
3
|
-
export { createHashPassword, createUuid } from './util';
|
|
4
|
-
export { createToken, jwtVerify } from './jwt';
|
|
5
|
-
export { getPreviousWorkday, get2ndLastPreviousWorkday, addDays, addMinutes, addYears, getCurrentDateTime, getCurrentUtcTime, newDate, getDatesBetweenRange, getMoment, getCurrentEpoch, } from './dateTime';
|
|
6
|
-
export { RedisClient } from './redisClient';
|
|
1
|
+
import database from './database';
|
|
2
|
+
export default database;
|
|
3
|
+
export { createHashPassword, createUuid } from './util';
|
|
4
|
+
export { createToken, jwtVerify } from './jwt';
|
|
5
|
+
export { getPreviousWorkday, get2ndLastPreviousWorkday, addDays, addMinutes, addYears, getCurrentDateTime, getCurrentUtcTime, newDate, getDatesBetweenRange, getMoment, getCurrentEpoch, } from './dateTime';
|
|
6
|
+
export { RedisClient } from './redisClient';
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RedisClient = exports.getCurrentEpoch = exports.getMoment = exports.getDatesBetweenRange = exports.newDate = exports.getCurrentUtcTime = exports.getCurrentDateTime = exports.addYears = exports.addMinutes = exports.addDays = exports.get2ndLastPreviousWorkday = exports.getPreviousWorkday = exports.jwtVerify = exports.createToken = exports.createUuid = exports.createHashPassword = void 0;
|
|
4
|
-
const database_1 = require("./database");
|
|
5
|
-
exports.default = database_1.default;
|
|
6
|
-
var util_1 = require("./util");
|
|
7
|
-
Object.defineProperty(exports, "createHashPassword", { enumerable: true, get: function () { return util_1.createHashPassword; } });
|
|
8
|
-
Object.defineProperty(exports, "createUuid", { enumerable: true, get: function () { return util_1.createUuid; } });
|
|
9
|
-
var jwt_1 = require("./jwt");
|
|
10
|
-
Object.defineProperty(exports, "createToken", { enumerable: true, get: function () { return jwt_1.createToken; } });
|
|
11
|
-
Object.defineProperty(exports, "jwtVerify", { enumerable: true, get: function () { return jwt_1.jwtVerify; } });
|
|
12
|
-
// export { OrganizationModel, UserModel, PlatformModel } from './models';
|
|
13
|
-
var dateTime_1 = require("./dateTime");
|
|
14
|
-
Object.defineProperty(exports, "getPreviousWorkday", { enumerable: true, get: function () { return dateTime_1.getPreviousWorkday; } });
|
|
15
|
-
Object.defineProperty(exports, "get2ndLastPreviousWorkday", { enumerable: true, get: function () { return dateTime_1.get2ndLastPreviousWorkday; } });
|
|
16
|
-
Object.defineProperty(exports, "addDays", { enumerable: true, get: function () { return dateTime_1.addDays; } });
|
|
17
|
-
Object.defineProperty(exports, "addMinutes", { enumerable: true, get: function () { return dateTime_1.addMinutes; } });
|
|
18
|
-
Object.defineProperty(exports, "addYears", { enumerable: true, get: function () { return dateTime_1.addYears; } });
|
|
19
|
-
Object.defineProperty(exports, "getCurrentDateTime", { enumerable: true, get: function () { return dateTime_1.getCurrentDateTime; } });
|
|
20
|
-
Object.defineProperty(exports, "getCurrentUtcTime", { enumerable: true, get: function () { return dateTime_1.getCurrentUtcTime; } });
|
|
21
|
-
Object.defineProperty(exports, "newDate", { enumerable: true, get: function () { return dateTime_1.newDate; } });
|
|
22
|
-
Object.defineProperty(exports, "getDatesBetweenRange", { enumerable: true, get: function () { return dateTime_1.getDatesBetweenRange; } });
|
|
23
|
-
Object.defineProperty(exports, "getMoment", { enumerable: true, get: function () { return dateTime_1.getMoment; } });
|
|
24
|
-
Object.defineProperty(exports, "getCurrentEpoch", { enumerable: true, get: function () { return dateTime_1.getCurrentEpoch; } });
|
|
25
|
-
var redisClient_1 = require("./redisClient");
|
|
26
|
-
Object.defineProperty(exports, "RedisClient", { enumerable: true, get: function () { return redisClient_1.RedisClient; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisClient = exports.getCurrentEpoch = exports.getMoment = exports.getDatesBetweenRange = exports.newDate = exports.getCurrentUtcTime = exports.getCurrentDateTime = exports.addYears = exports.addMinutes = exports.addDays = exports.get2ndLastPreviousWorkday = exports.getPreviousWorkday = exports.jwtVerify = exports.createToken = exports.createUuid = exports.createHashPassword = void 0;
|
|
4
|
+
const database_1 = require("./database");
|
|
5
|
+
exports.default = database_1.default;
|
|
6
|
+
var util_1 = require("./util");
|
|
7
|
+
Object.defineProperty(exports, "createHashPassword", { enumerable: true, get: function () { return util_1.createHashPassword; } });
|
|
8
|
+
Object.defineProperty(exports, "createUuid", { enumerable: true, get: function () { return util_1.createUuid; } });
|
|
9
|
+
var jwt_1 = require("./jwt");
|
|
10
|
+
Object.defineProperty(exports, "createToken", { enumerable: true, get: function () { return jwt_1.createToken; } });
|
|
11
|
+
Object.defineProperty(exports, "jwtVerify", { enumerable: true, get: function () { return jwt_1.jwtVerify; } });
|
|
12
|
+
// export { OrganizationModel, UserModel, PlatformModel } from './models';
|
|
13
|
+
var dateTime_1 = require("./dateTime");
|
|
14
|
+
Object.defineProperty(exports, "getPreviousWorkday", { enumerable: true, get: function () { return dateTime_1.getPreviousWorkday; } });
|
|
15
|
+
Object.defineProperty(exports, "get2ndLastPreviousWorkday", { enumerable: true, get: function () { return dateTime_1.get2ndLastPreviousWorkday; } });
|
|
16
|
+
Object.defineProperty(exports, "addDays", { enumerable: true, get: function () { return dateTime_1.addDays; } });
|
|
17
|
+
Object.defineProperty(exports, "addMinutes", { enumerable: true, get: function () { return dateTime_1.addMinutes; } });
|
|
18
|
+
Object.defineProperty(exports, "addYears", { enumerable: true, get: function () { return dateTime_1.addYears; } });
|
|
19
|
+
Object.defineProperty(exports, "getCurrentDateTime", { enumerable: true, get: function () { return dateTime_1.getCurrentDateTime; } });
|
|
20
|
+
Object.defineProperty(exports, "getCurrentUtcTime", { enumerable: true, get: function () { return dateTime_1.getCurrentUtcTime; } });
|
|
21
|
+
Object.defineProperty(exports, "newDate", { enumerable: true, get: function () { return dateTime_1.newDate; } });
|
|
22
|
+
Object.defineProperty(exports, "getDatesBetweenRange", { enumerable: true, get: function () { return dateTime_1.getDatesBetweenRange; } });
|
|
23
|
+
Object.defineProperty(exports, "getMoment", { enumerable: true, get: function () { return dateTime_1.getMoment; } });
|
|
24
|
+
Object.defineProperty(exports, "getCurrentEpoch", { enumerable: true, get: function () { return dateTime_1.getCurrentEpoch; } });
|
|
25
|
+
var redisClient_1 = require("./redisClient");
|
|
26
|
+
Object.defineProperty(exports, "RedisClient", { enumerable: true, get: function () { return redisClient_1.RedisClient; } });
|