joye-backend-utility 8.1.5 → 8.1.7

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
@@ -21,6 +21,7 @@ class database {
21
21
  con.model('Master_Theme_Data', schema_1.MasterThemeDataSchema);
22
22
  con.model('Master_Theme_Message', schema_1.MasterThemeMessageSchema);
23
23
  con.model('Organization', schema_1.OrganizationSchema);
24
+ con.model('Organization_Analytics', schema_1.OrganizationAnalyticsSchema);
24
25
  con.model('Platform', schema_1.PlatformSchema);
25
26
  con.model('User', schema_1.UserSchema);
26
27
  con.model('User_Log', schema_1.UserLogSchema);
@@ -12,6 +12,7 @@ export { MasterPredictionEmotionsMessageMappingSchema } from './masterPrediction
12
12
  export { MasterThemeDataSchema } from './masterThemeData';
13
13
  export { MasterThemeMessageSchema } from './masterThemeMessage';
14
14
  export { OrganizationSchema } from './organization';
15
+ export { OrganizationAnalyticsSchema } from './organization_analytics';
15
16
  export { PlatformSchema } from './platform';
16
17
  export { UserLogSchema } from './userLog';
17
18
  export { UserMeetingSchema } from './userMeeting';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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.UserEmotionalHealthDetailSchema = exports.UserEmotionalHealthSchema = exports.UserWellbeingDataSchema = exports.UserSuperPowerDataSchema = exports.MasterSuperPowerRuleSchema = exports.MasterSuperPowerDataSchema = exports.MasterEmotionalHealthSchema = exports.MasterEmotionalDriverSchema = exports.MasterEmotionsSchemaV2 = exports.ErrorLogSchema = void 0;
3
+ 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.OrganizationAnalyticsSchema = 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.UserEmotionalHealthDetailSchema = exports.UserEmotionalHealthSchema = exports.UserWellbeingDataSchema = exports.UserSuperPowerDataSchema = exports.MasterSuperPowerRuleSchema = exports.MasterSuperPowerDataSchema = exports.MasterEmotionalHealthSchema = exports.MasterEmotionalDriverSchema = exports.MasterEmotionsSchemaV2 = exports.ErrorLogSchema = exports.PageViewSchema = 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");
@@ -30,6 +30,8 @@ var masterThemeMessage_1 = require("./masterThemeMessage");
30
30
  Object.defineProperty(exports, "MasterThemeMessageSchema", { enumerable: true, get: function () { return masterThemeMessage_1.MasterThemeMessageSchema; } });
31
31
  var organization_1 = require("./organization");
32
32
  Object.defineProperty(exports, "OrganizationSchema", { enumerable: true, get: function () { return organization_1.OrganizationSchema; } });
33
+ var organization_analytics_1 = require("./organization_analytics");
34
+ Object.defineProperty(exports, "OrganizationAnalyticsSchema", { enumerable: true, get: function () { return organization_analytics_1.OrganizationAnalyticsSchema; } });
33
35
  var platform_1 = require("./platform");
34
36
  Object.defineProperty(exports, "PlatformSchema", { enumerable: true, get: function () { return platform_1.PlatformSchema; } });
35
37
  var userLog_1 = require("./userLog");
@@ -28,6 +28,18 @@ const MasterSuperPowerData = new mongoose_1.Schema({
28
28
  type: String,
29
29
  required: true,
30
30
  },
31
+ oddMonth: {
32
+ type: [String],
33
+ required: false,
34
+ },
35
+ evenMonth: {
36
+ type: [String],
37
+ required: false,
38
+ },
39
+ weightage: {
40
+ type: String,
41
+ required: false,
42
+ },
31
43
  });
32
44
  MasterSuperPowerData.index({ key: 1, order: 1 });
33
45
  exports.MasterSuperPowerDataSchema = MasterSuperPowerData;
@@ -44,6 +44,10 @@ const MasterSuperPowerRule = new mongoose_1.Schema({
44
44
  type: [String],
45
45
  required: false,
46
46
  },
47
+ feature: {
48
+ type: String,
49
+ required: false,
50
+ },
47
51
  });
48
52
  MasterSuperPowerRule.index({ dimensionKey: 1, rule: 1 });
49
53
  exports.MasterSuperPowerRuleSchema = MasterSuperPowerRule;
@@ -31,6 +31,10 @@ const MasterTrainingDays = new mongoose_1.Schema({
31
31
  required: false,
32
32
  default: '',
33
33
  },
34
+ write: {
35
+ type: String,
36
+ required: false,
37
+ },
34
38
  });
35
39
  MasterTrainingDays.index({ trainingKey: 1, day: 1 });
36
40
  exports.MasterTrainingDaysSchema = MasterTrainingDays;
@@ -0,0 +1,2 @@
1
+ import { Schema } from 'mongoose';
2
+ export declare const OrganizationAnalyticsSchema: Schema<import("mongoose").Document<any, any, any>, import("mongoose").Model<import("mongoose").Document<any, any, any>, any, any>, undefined, {}>;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrganizationAnalyticsSchema = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const OrganizationAnalytics = new mongoose_1.Schema({
6
+ // Identity (org-level)
7
+ platformKey: {
8
+ type: String,
9
+ required: true,
10
+ index: true,
11
+ },
12
+ tId: {
13
+ type: String,
14
+ required: true,
15
+ index: true,
16
+ },
17
+ year: {
18
+ type: Number,
19
+ required: true,
20
+ index: true,
21
+ },
22
+ // period slice stored in this document
23
+ periodType: {
24
+ type: String,
25
+ required: true,
26
+ index: true,
27
+ enum: ['summary', 'week', 'month'],
28
+ },
29
+ // Use null for unused fields so the unique compound index stays valid.
30
+ // For summary: week=null, month=null
31
+ // For week: week=1..52, month=null
32
+ // For month: week=null, month=1..12
33
+ week: {
34
+ type: Number,
35
+ required: false,
36
+ default: null,
37
+ },
38
+ month: {
39
+ type: Number,
40
+ required: false,
41
+ default: null,
42
+ },
43
+ status: {
44
+ type: String,
45
+ required: true,
46
+ index: true,
47
+ enum: ['pending', 'processing', 'complete', 'failed'],
48
+ default: 'pending',
49
+ },
50
+ // Grouping for a single report run/job execution.
51
+ reportBatchId: {
52
+ type: String,
53
+ required: true,
54
+ index: true,
55
+ },
56
+ reportStartDate: {
57
+ type: String,
58
+ required: false,
59
+ },
60
+ reportEndDate: {
61
+ type: String,
62
+ required: false,
63
+ },
64
+ // --- Summary-tab metrics (report-users Summary sheet; stored for summary/week/month) ---
65
+ registeredUsers: { type: Number, required: false },
66
+ activeUsers: { type: Number, required: false },
67
+ repeatUsers: { type: Number, required: false },
68
+ reportedUsersCount: { type: Number, required: false },
69
+ totalActivity: { type: Number, required: false },
70
+ detailedRowsCount: { type: Number, required: false },
71
+ activityPerUser: { type: Number, required: false },
72
+ averageUserTenure: { type: Number, required: false },
73
+ activePercent: { type: Number, required: false },
74
+ repeatPercent: { type: Number, required: false },
75
+ // Alias of activeUsers for week/month pivot columns in admin UI
76
+ activeUsersInPeriod: { type: Number, required: false },
77
+ // --- Counters-tab metrics (report-users Counters sheet) ---
78
+ // Mixed: nested object must round-trip cleanly on Cosmos/Mongoose updates.
79
+ counters: { type: mongoose_1.Schema.Types.Mixed, required: false },
80
+ // Job progress (resumable tenant-level aggregation; no per-user intermediate table)
81
+ totalUsers: { type: Number, required: false },
82
+ processedUsers: { type: Number, required: false, default: 0 },
83
+ processingUserOffset: { type: Number, required: false, default: 0 },
84
+ processingHeartbeatAt: { type: Number, required: false },
85
+ // Partial aggregates while processing (restored on resume)
86
+ processingPartial: { type: mongoose_1.Schema.Types.Mixed, required: false },
87
+ // Audit
88
+ generatedAt: { type: Number, required: false },
89
+ updatedAt: { type: Number, required: false },
90
+ errorMessage: { type: String, required: false },
91
+ });
92
+ // Uniqueness per org + year + period slice.
93
+ // NOTE: We include `week` and `month` in the unique key so we can enforce one doc per week/month.
94
+ // Unused fields must be stored as `null` (not omitted) to avoid collisions.
95
+ OrganizationAnalytics.index({ platformKey: 1, tId: 1, year: 1, periodType: 1, week: 1, month: 1 }, { unique: true });
96
+ // Common admin queries.
97
+ OrganizationAnalytics.index({ platformKey: 1, year: 1, periodType: 1, status: 1 }, { unique: false });
98
+ OrganizationAnalytics.index({ reportBatchId: 1 }, { unique: false });
99
+ exports.OrganizationAnalyticsSchema = OrganizationAnalytics;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joye-backend-utility",
3
- "version": "8.1.5",
3
+ "version": "8.1.7",
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",