joye-backend-utility 8.0.9 → 8.1.0

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/database.js CHANGED
@@ -60,10 +60,13 @@ class database {
60
60
  con.model('Error_Log', schema_1.ErrorLogSchema);
61
61
  con.model('Master_Emotion_v2', schema_1.MasterEmotionsSchemaV2);
62
62
  con.model('Master_Emotional_Driver', schema_1.MasterEmotionalDriverSchema);
63
+ con.model('Master_Emotional_Health', schema_1.MasterEmotionalHealthSchema);
63
64
  con.model('Master_Super_Power_Data', schema_1.MasterSuperPowerDataSchema);
64
65
  con.model('Master_Super_Power_Rule', schema_1.MasterSuperPowerRuleSchema);
65
66
  con.model('User_Super_Power_Data', schema_1.UserSuperPowerDataSchema);
66
67
  con.model('User_Wellbeing_Data', schema_1.UserWellbeingDataSchema);
68
+ con.model('User_Emotional_Health', schema_1.UserEmotionalHealthSchema);
69
+ con.model('User_Emotional_Health_Detail', schema_1.UserEmotionalHealthDetailSchema);
67
70
  };
68
71
  this.connectToDatabase = () => {
69
72
  const env = config_1.NODE_ENV || 'development';
package/dist/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export { createHashPassword, createUuid } from './util';
4
4
  export { createToken, jwtVerify } from './jwt';
5
5
  export { getPreviousWorkday, get2ndLastPreviousWorkday, addDays, addMinutes, addYears, getCurrentDateTime, getCurrentUtcTime, newDate, getDatesBetweenRange, getMoment, getCurrentEpoch, } from './dateTime';
6
6
  export { RedisClient } from './redisClient';
7
+ export { hasDailySuggestionFlag } from './userAnalytic';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
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;
3
+ exports.hasDailySuggestionFlag = 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
4
  const database_1 = require("./database");
5
5
  exports.default = database_1.default;
6
6
  var util_1 = require("./util");
@@ -24,3 +24,5 @@ Object.defineProperty(exports, "getMoment", { enumerable: true, get: function ()
24
24
  Object.defineProperty(exports, "getCurrentEpoch", { enumerable: true, get: function () { return dateTime_1.getCurrentEpoch; } });
25
25
  var redisClient_1 = require("./redisClient");
26
26
  Object.defineProperty(exports, "RedisClient", { enumerable: true, get: function () { return redisClient_1.RedisClient; } });
27
+ var userAnalytic_1 = require("./userAnalytic");
28
+ Object.defineProperty(exports, "hasDailySuggestionFlag", { enumerable: true, get: function () { return userAnalytic_1.hasDailySuggestionFlag; } });
@@ -51,7 +51,10 @@ export { PageViewSchema } from './pageView';
51
51
  export { ErrorLogSchema } from './errorLog';
52
52
  export { MasterEmotionsSchemaV2 } from './masterEmotionV2';
53
53
  export { MasterEmotionalDriverSchema } from './master_emotional_driver';
54
+ export { MasterEmotionalHealthSchema } from './master_emotional_health';
54
55
  export { MasterSuperPowerDataSchema } from './masterSuperPowerData';
55
56
  export { MasterSuperPowerRuleSchema } from './masterSuperPowerRule';
56
57
  export { UserSuperPowerDataSchema } from './userSuperPowerData';
57
58
  export { UserWellbeingDataSchema } from './user_wellbeing_data';
59
+ export { UserEmotionalHealthSchema } from './user_emotional_health';
60
+ export { UserEmotionalHealthDetailSchema } from './user_emotional_health_detail';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PageViewSchema = exports.AIPromptsSchema = exports.UserAnalyticSchema = exports.AIResponsesTrackingSchema = exports.UserProfileSchema = exports.UserChatSessionSchema = exports.FeatureFeedbackSchema = exports.UserWeekActivitySchema = exports.UserTrainingRemindersSchema = exports.UserTrainingDailyDataSchema = exports.MasterTrainingDaysSchema = exports.UserTrainingWeekDataSchema = exports.UserTrainingDataSchema = exports.MasterTrainingWeekSchema = exports.MasterTrainingSchema = exports.userJoyLevelQaSchema = exports.userGoalSchema = exports.OrganizationUserAttrPermissionSchema = exports.TimezoneSchema = exports.UserVideoSchema = exports.UserFeedbackSchema = exports.UserReminderSchema = exports.MasterLinkCardSchema = exports.UserRecommendationSchema = exports.MasterSuggestionsParameterSchema = exports.MasterSuggestionsMessageSchema = exports.MasterBlessingsDataSchema = exports.MasterVideoSchema = exports.DatabaseInfoSchema = exports.UserSchema = exports.UserNotificationLogSchema = exports.UserMessageLogSchema = exports.UserMessageSchema = exports.UserMeetingSchema = exports.UserLogSchema = exports.PlatformSchema = exports.OrganizationSchema = exports.MasterThemeMessageSchema = exports.MasterThemeDataSchema = exports.MasterPredictionEmotionsMessageMappingSchema = exports.MasterPredictionEmotionMessageSchema = exports.MasterPredictionEmotionSchema = exports.MasterPodcastSchema = exports.MasterEmotionMessageTypeThemeMappingSchema = exports.MasterEmotionsMessageMappingSchemaV2 = exports.MasterEmotionsMessageMappingSchema = exports.MasterEmotionsSchema = exports.MasterDataSchema = exports.MasterAppSettingSchema = exports.BrewSchema = void 0;
4
- exports.UserWellbeingDataSchema = exports.UserSuperPowerDataSchema = exports.MasterSuperPowerRuleSchema = exports.MasterSuperPowerDataSchema = exports.MasterEmotionalDriverSchema = exports.MasterEmotionsSchemaV2 = exports.ErrorLogSchema = void 0;
4
+ exports.UserEmotionalHealthDetailSchema = exports.UserEmotionalHealthSchema = exports.UserWellbeingDataSchema = exports.UserSuperPowerDataSchema = exports.MasterSuperPowerRuleSchema = exports.MasterSuperPowerDataSchema = exports.MasterEmotionalHealthSchema = exports.MasterEmotionalDriverSchema = exports.MasterEmotionsSchemaV2 = exports.ErrorLogSchema = void 0;
5
5
  var brew_1 = require("./brew");
6
6
  Object.defineProperty(exports, "BrewSchema", { enumerable: true, get: function () { return brew_1.BrewSchema; } });
7
7
  var masterAppSetting_1 = require("./masterAppSetting");
@@ -108,6 +108,8 @@ var masterEmotionV2_1 = require("./masterEmotionV2");
108
108
  Object.defineProperty(exports, "MasterEmotionsSchemaV2", { enumerable: true, get: function () { return masterEmotionV2_1.MasterEmotionsSchemaV2; } });
109
109
  var master_emotional_driver_1 = require("./master_emotional_driver");
110
110
  Object.defineProperty(exports, "MasterEmotionalDriverSchema", { enumerable: true, get: function () { return master_emotional_driver_1.MasterEmotionalDriverSchema; } });
111
+ var master_emotional_health_1 = require("./master_emotional_health");
112
+ Object.defineProperty(exports, "MasterEmotionalHealthSchema", { enumerable: true, get: function () { return master_emotional_health_1.MasterEmotionalHealthSchema; } });
111
113
  var masterSuperPowerData_1 = require("./masterSuperPowerData");
112
114
  Object.defineProperty(exports, "MasterSuperPowerDataSchema", { enumerable: true, get: function () { return masterSuperPowerData_1.MasterSuperPowerDataSchema; } });
113
115
  var masterSuperPowerRule_1 = require("./masterSuperPowerRule");
@@ -116,3 +118,7 @@ var userSuperPowerData_1 = require("./userSuperPowerData");
116
118
  Object.defineProperty(exports, "UserSuperPowerDataSchema", { enumerable: true, get: function () { return userSuperPowerData_1.UserSuperPowerDataSchema; } });
117
119
  var user_wellbeing_data_1 = require("./user_wellbeing_data");
118
120
  Object.defineProperty(exports, "UserWellbeingDataSchema", { enumerable: true, get: function () { return user_wellbeing_data_1.UserWellbeingDataSchema; } });
121
+ var user_emotional_health_1 = require("./user_emotional_health");
122
+ Object.defineProperty(exports, "UserEmotionalHealthSchema", { enumerable: true, get: function () { return user_emotional_health_1.UserEmotionalHealthSchema; } });
123
+ var user_emotional_health_detail_1 = require("./user_emotional_health_detail");
124
+ Object.defineProperty(exports, "UserEmotionalHealthDetailSchema", { enumerable: true, get: function () { return user_emotional_health_detail_1.UserEmotionalHealthDetailSchema; } });
@@ -0,0 +1,2 @@
1
+ import { Schema } from 'mongoose';
2
+ export declare const MasterEmotionalHealthSchema: Schema<import("mongoose").Document<any, any, any>, import("mongoose").Model<import("mongoose").Document<any, any, any>, any, any>, undefined, {}>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MasterEmotionalHealthSchema = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const MasterEmotionalHealth = new mongoose_1.Schema({
6
+ key: {
7
+ type: String,
8
+ required: true,
9
+ index: true,
10
+ },
11
+ title: {
12
+ type: String,
13
+ required: true,
14
+ },
15
+ type: {
16
+ type: String,
17
+ required: true,
18
+ enum: ['risk', 'driver'],
19
+ },
20
+ emotions: {
21
+ type: [String],
22
+ required: false,
23
+ default: [],
24
+ },
25
+ });
26
+ MasterEmotionalHealth.index({ key: 1 });
27
+ MasterEmotionalHealth.index({ type: 1 });
28
+ exports.MasterEmotionalHealthSchema = MasterEmotionalHealth;
@@ -126,6 +126,11 @@ const UserAnalytic = new mongoose_1.Schema({
126
126
  type: Object,
127
127
  required: false,
128
128
  },
129
+ /** Denormalized from `dailySuggestion != null` for indexed queue-cron filters (avoid `$ne: null`). */
130
+ hasDailySuggestion: {
131
+ type: Boolean,
132
+ required: false,
133
+ },
129
134
  fallbackData: {
130
135
  // To show the data is a fallback data from UI initiated /emotion-data request
131
136
  type: Boolean,
@@ -139,5 +144,6 @@ const UserAnalytic = new mongoose_1.Schema({
139
144
  });
140
145
  UserAnalytic.index({ employeeId: 1, weekNumber: -1, year: -1, date: -1 });
141
146
  UserAnalytic.index({ employeeId: 1, month: -1, year: -1, date: -1 });
142
- UserAnalytic.index({ year: 1, weekNumber: 1, bucket: 1 });
147
+ UserAnalytic.index({ year: 1, weekNumber: 1, bucket: 1, _id: 1 });
148
+ UserAnalytic.index({ year: 1, weekNumber: 1, hasDailySuggestion: 1, bucket: 1, _id: 1 });
143
149
  exports.UserAnalyticSchema = UserAnalytic;
@@ -0,0 +1,2 @@
1
+ import { Schema } from 'mongoose';
2
+ export declare const UserEmotionalHealthSchema: Schema<import("mongoose").Document<any, any, any>, import("mongoose").Model<import("mongoose").Document<any, any, any>, any, any>, undefined, {}>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserEmotionalHealthSchema = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const countField = { type: Number, required: false, default: 0 };
6
+ const scoreField = { type: Number, required: false };
7
+ const UserEmotionalHealth = new mongoose_1.Schema({
8
+ employeeId: {
9
+ type: String,
10
+ required: true,
11
+ index: true,
12
+ },
13
+ date: {
14
+ type: Date,
15
+ required: true,
16
+ },
17
+ workPressure: scoreField,
18
+ workPressureCount: countField,
19
+ burnoutRisk: scoreField,
20
+ burnoutRiskCount: countField,
21
+ lonelinessRisk: scoreField,
22
+ lonelinessRiskCount: countField,
23
+ stressAnxietyRisk: scoreField,
24
+ stressAnxietyRiskCount: countField,
25
+ irritabilityRisk: scoreField,
26
+ irritabilityRiskCount: countField,
27
+ psychologicalSafety: scoreField,
28
+ psychologicalSafetyCount: countField,
29
+ goodRelationships: scoreField,
30
+ goodRelationshipsCount: countField,
31
+ positivity: scoreField,
32
+ positivityCount: countField,
33
+ goodMotivation: scoreField,
34
+ goodMotivationCount: countField,
35
+ recovery: scoreField,
36
+ recoveryCount: countField,
37
+ bCount: countField,
38
+ gCount: countField,
39
+ mmCount: countField,
40
+ updatedTimestamp: {
41
+ type: Number,
42
+ required: false,
43
+ },
44
+ });
45
+ UserEmotionalHealth.index({ employeeId: 1, date: -1 });
46
+ exports.UserEmotionalHealthSchema = UserEmotionalHealth;
@@ -0,0 +1,2 @@
1
+ import { Schema } from 'mongoose';
2
+ export declare const UserEmotionalHealthDetailSchema: Schema<import("mongoose").Document<any, any, any>, import("mongoose").Model<import("mongoose").Document<any, any, any>, any, any>, undefined, {}>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserEmotionalHealthDetailSchema = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const UserEmotionalHealthDetail = new mongoose_1.Schema({
6
+ employeeId: {
7
+ type: String,
8
+ required: true,
9
+ index: true,
10
+ },
11
+ date: {
12
+ type: Date,
13
+ required: true,
14
+ },
15
+ emotionKey: {
16
+ type: String,
17
+ required: true,
18
+ },
19
+ type: {
20
+ type: String,
21
+ required: true,
22
+ enum: ['risk', 'driver'],
23
+ },
24
+ count: {
25
+ type: Number,
26
+ required: false,
27
+ default: 0,
28
+ },
29
+ emotionalHealthKey: {
30
+ type: String,
31
+ required: true,
32
+ index: true,
33
+ },
34
+ });
35
+ UserEmotionalHealthDetail.index({ employeeId: 1, date: -1 });
36
+ UserEmotionalHealthDetail.index({ employeeId: 1, date: -1, emotionalHealthKey: 1, emotionKey: 1 });
37
+ UserEmotionalHealthDetail.index({ employeeId: 1, emotionalHealthKey: 1, type: 1, date: -1 });
38
+ exports.UserEmotionalHealthDetailSchema = UserEmotionalHealthDetail;
@@ -0,0 +1,2 @@
1
+ /** Cosmos-indexable flag: true when `dailySuggestion` is stored on `User_Analytic`. */
2
+ export declare function hasDailySuggestionFlag(dailySuggestion: unknown): boolean;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasDailySuggestionFlag = void 0;
4
+ /** Cosmos-indexable flag: true when `dailySuggestion` is stored on `User_Analytic`. */
5
+ function hasDailySuggestionFlag(dailySuggestion) {
6
+ return dailySuggestion != null;
7
+ }
8
+ exports.hasDailySuggestionFlag = hasDailySuggestionFlag;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joye-backend-utility",
3
- "version": "8.0.9",
3
+ "version": "8.1.0",
4
4
  "description": "Joye backend utility for db functions and common functions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",