joye-backend-utility 8.2.13 → 9.0.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/database.js +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -1
- package/dist/schema/accessTier.d.ts +1 -0
- package/dist/schema/accessTier.js +17 -1
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.js +2 -1
- package/dist/tierAccess.d.ts +5 -0
- package/dist/tierAccess.js +12 -1
- package/package.json +1 -1
package/dist/database.js
CHANGED
|
@@ -74,6 +74,7 @@ class database {
|
|
|
74
74
|
con.model('Access_Tier', schema_1.AccessTierSchema);
|
|
75
75
|
con.model('Access_Entitlement', schema_1.AccessEntitlementSchema);
|
|
76
76
|
con.model('Access_Trial_Policy', schema_1.AccessTrialPolicySchema);
|
|
77
|
+
con.model('Access_History', schema_1.AccessHistorySchema);
|
|
77
78
|
};
|
|
78
79
|
this.connectToDatabase = () => {
|
|
79
80
|
const env = config_1.NODE_ENV || 'development';
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { getPreviousWorkday, get2ndLastPreviousWorkday, addDays, addMinutes, add
|
|
|
6
6
|
export { RedisClient } from './redisClient';
|
|
7
7
|
export { hasDailySuggestionFlag } from './userAnalytic';
|
|
8
8
|
export { LlmBatchJobSchema, LLM_BATCH_IN_PROGRESS_ITEM_STATUSES } from './schema/llm_batch_job';
|
|
9
|
-
export { AccessFeatureSchema, AccessTierSchema, AccessEntitlementSchema, AccessTrialPolicySchema } from './schema/accessTier';
|
|
10
|
-
export { entitlementInForce, expandTierChain, tiersToGrant, collectGrantedFeatures } from './tierAccess';
|
|
9
|
+
export { AccessFeatureSchema, AccessTierSchema, AccessEntitlementSchema, AccessTrialPolicySchema, AccessHistorySchema } from './schema/accessTier';
|
|
10
|
+
export { DEFAULT_TIER_KEY, entitlementInForce, expandTierChain, grantKeysOrDefault, tiersToGrant, collectGrantedFeatures } from './tierAccess';
|
|
11
11
|
export type { TierRecord, FeatureRecord, EntitlementWindow } from './tierAccess';
|
|
12
12
|
export type { LlmBatchItemStatus, LlmBatchJobStatus, LlmBatchProvider } from './schema/llm_batch_job';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.collectGrantedFeatures = exports.tiersToGrant = exports.expandTierChain = exports.entitlementInForce = exports.AccessTrialPolicySchema = exports.AccessEntitlementSchema = exports.AccessTierSchema = exports.AccessFeatureSchema = exports.LLM_BATCH_IN_PROGRESS_ITEM_STATUSES = exports.LlmBatchJobSchema = 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;
|
|
3
|
+
exports.collectGrantedFeatures = exports.tiersToGrant = exports.grantKeysOrDefault = exports.expandTierChain = exports.entitlementInForce = exports.DEFAULT_TIER_KEY = exports.AccessHistorySchema = exports.AccessTrialPolicySchema = exports.AccessEntitlementSchema = exports.AccessTierSchema = exports.AccessFeatureSchema = exports.LLM_BATCH_IN_PROGRESS_ITEM_STATUSES = exports.LlmBatchJobSchema = 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");
|
|
@@ -34,8 +34,11 @@ Object.defineProperty(exports, "AccessFeatureSchema", { enumerable: true, get: f
|
|
|
34
34
|
Object.defineProperty(exports, "AccessTierSchema", { enumerable: true, get: function () { return accessTier_1.AccessTierSchema; } });
|
|
35
35
|
Object.defineProperty(exports, "AccessEntitlementSchema", { enumerable: true, get: function () { return accessTier_1.AccessEntitlementSchema; } });
|
|
36
36
|
Object.defineProperty(exports, "AccessTrialPolicySchema", { enumerable: true, get: function () { return accessTier_1.AccessTrialPolicySchema; } });
|
|
37
|
+
Object.defineProperty(exports, "AccessHistorySchema", { enumerable: true, get: function () { return accessTier_1.AccessHistorySchema; } });
|
|
37
38
|
var tierAccess_1 = require("./tierAccess");
|
|
39
|
+
Object.defineProperty(exports, "DEFAULT_TIER_KEY", { enumerable: true, get: function () { return tierAccess_1.DEFAULT_TIER_KEY; } });
|
|
38
40
|
Object.defineProperty(exports, "entitlementInForce", { enumerable: true, get: function () { return tierAccess_1.entitlementInForce; } });
|
|
39
41
|
Object.defineProperty(exports, "expandTierChain", { enumerable: true, get: function () { return tierAccess_1.expandTierChain; } });
|
|
42
|
+
Object.defineProperty(exports, "grantKeysOrDefault", { enumerable: true, get: function () { return tierAccess_1.grantKeysOrDefault; } });
|
|
40
43
|
Object.defineProperty(exports, "tiersToGrant", { enumerable: true, get: function () { return tierAccess_1.tiersToGrant; } });
|
|
41
44
|
Object.defineProperty(exports, "collectGrantedFeatures", { enumerable: true, get: function () { return tierAccess_1.collectGrantedFeatures; } });
|
|
@@ -3,3 +3,4 @@ export declare const AccessFeatureSchema: Schema<import("mongoose").Document<any
|
|
|
3
3
|
export declare const AccessTierSchema: Schema<import("mongoose").Document<any, any, any>, import("mongoose").Model<import("mongoose").Document<any, any, any>, any, any>, undefined, {}>;
|
|
4
4
|
export declare const AccessEntitlementSchema: Schema<import("mongoose").Document<any, any, any>, import("mongoose").Model<import("mongoose").Document<any, any, any>, any, any>, undefined, {}>;
|
|
5
5
|
export declare const AccessTrialPolicySchema: Schema<import("mongoose").Document<any, any, any>, import("mongoose").Model<import("mongoose").Document<any, any, any>, any, any>, undefined, {}>;
|
|
6
|
+
export declare const AccessHistorySchema: Schema<import("mongoose").Document<any, any, any>, import("mongoose").Model<import("mongoose").Document<any, any, any>, any, any>, undefined, {}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AccessTrialPolicySchema = exports.AccessEntitlementSchema = exports.AccessTierSchema = exports.AccessFeatureSchema = void 0;
|
|
3
|
+
exports.AccessHistorySchema = exports.AccessTrialPolicySchema = exports.AccessEntitlementSchema = exports.AccessTierSchema = exports.AccessFeatureSchema = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
5
|
const featureSchema = new mongoose_1.Schema({
|
|
6
6
|
key: { type: String, required: true, unique: true },
|
|
@@ -54,7 +54,23 @@ const trialPolicySchema = new mongoose_1.Schema({
|
|
|
54
54
|
updatedAt: { type: Number, required: true },
|
|
55
55
|
}, { collection: 'trial_policies' });
|
|
56
56
|
trialPolicySchema.index({ platformKey: 1, tId: 1 }, { unique: true });
|
|
57
|
+
const historySchema = new mongoose_1.Schema({
|
|
58
|
+
platformKey: { type: String, required: true, index: true },
|
|
59
|
+
tId: { type: String, default: '' },
|
|
60
|
+
userId: { type: String, default: '' },
|
|
61
|
+
subject: { type: String, required: true, enum: ['entitlement', 'trial'] },
|
|
62
|
+
action: { type: String, required: true, enum: ['assigned', 'updated', 'cancelled', 'extended'] },
|
|
63
|
+
refId: { type: String, default: '' },
|
|
64
|
+
tierKey: { type: String, default: '' },
|
|
65
|
+
summary: { type: String, default: '' },
|
|
66
|
+
before: { type: mongoose_1.Schema.Types.Mixed, default: null },
|
|
67
|
+
after: { type: mongoose_1.Schema.Types.Mixed, default: null },
|
|
68
|
+
actor: { type: String, default: 'admin' },
|
|
69
|
+
at: { type: Number, required: true },
|
|
70
|
+
}, { collection: 'access_history' });
|
|
71
|
+
historySchema.index({ platformKey: 1, tId: 1, userId: 1, at: 1 });
|
|
57
72
|
exports.AccessFeatureSchema = featureSchema;
|
|
58
73
|
exports.AccessTierSchema = tierSchema;
|
|
59
74
|
exports.AccessEntitlementSchema = entitlementSchema;
|
|
60
75
|
exports.AccessTrialPolicySchema = trialPolicySchema;
|
|
76
|
+
exports.AccessHistorySchema = historySchema;
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -61,4 +61,4 @@ export { UserSuperPowerDataSchema } from './userSuperPowerData';
|
|
|
61
61
|
export { UserWellbeingDataSchema } from './user_wellbeing_data';
|
|
62
62
|
export { UserEmotionalHealthSchema } from './user_emotional_health';
|
|
63
63
|
export { UserEmotionalHealthDetailSchema } from './user_emotional_health_detail';
|
|
64
|
-
export { AccessFeatureSchema, AccessTierSchema, AccessEntitlementSchema, AccessTrialPolicySchema } from './accessTier';
|
|
64
|
+
export { AccessFeatureSchema, AccessTierSchema, AccessEntitlementSchema, AccessTrialPolicySchema, AccessHistorySchema } from './accessTier';
|
package/dist/schema/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
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.UserConsentHistorySchema = 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.AccessTrialPolicySchema = exports.AccessEntitlementSchema = exports.AccessTierSchema = exports.AccessFeatureSchema = exports.UserEmotionalHealthDetailSchema = exports.UserEmotionalHealthSchema = exports.UserWellbeingDataSchema = exports.UserSuperPowerDataSchema = exports.MasterSuperPowerRuleSchema = exports.MasterSuperPowerDataSchema = exports.MasterEmotionalHealthSchema = exports.MasterEmotionalDriverSchema = exports.MasterEmotionsSchemaV2 = exports.ErrorLogSchema = exports.PageViewSchema = exports.AIPromptsSchema = exports.LlmBatchJobSchema = void 0;
|
|
4
|
+
exports.AccessHistorySchema = exports.AccessTrialPolicySchema = exports.AccessEntitlementSchema = exports.AccessTierSchema = exports.AccessFeatureSchema = exports.UserEmotionalHealthDetailSchema = exports.UserEmotionalHealthSchema = exports.UserWellbeingDataSchema = exports.UserSuperPowerDataSchema = exports.MasterSuperPowerRuleSchema = exports.MasterSuperPowerDataSchema = exports.MasterEmotionalHealthSchema = exports.MasterEmotionalDriverSchema = exports.MasterEmotionsSchemaV2 = exports.ErrorLogSchema = exports.PageViewSchema = exports.AIPromptsSchema = exports.LlmBatchJobSchema = 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");
|
|
@@ -133,3 +133,4 @@ Object.defineProperty(exports, "AccessFeatureSchema", { enumerable: true, get: f
|
|
|
133
133
|
Object.defineProperty(exports, "AccessTierSchema", { enumerable: true, get: function () { return accessTier_1.AccessTierSchema; } });
|
|
134
134
|
Object.defineProperty(exports, "AccessEntitlementSchema", { enumerable: true, get: function () { return accessTier_1.AccessEntitlementSchema; } });
|
|
135
135
|
Object.defineProperty(exports, "AccessTrialPolicySchema", { enumerable: true, get: function () { return accessTier_1.AccessTrialPolicySchema; } });
|
|
136
|
+
Object.defineProperty(exports, "AccessHistorySchema", { enumerable: true, get: function () { return accessTier_1.AccessHistorySchema; } });
|
package/dist/tierAccess.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export declare type EntitlementWindow = {
|
|
|
17
17
|
export declare function entitlementInForce(row: EntitlementWindow, now: number): boolean;
|
|
18
18
|
export declare function expandTierChain(tierKey: string, tiers: Map<string, TierRecord>, visiting?: Set<string>): string[];
|
|
19
19
|
export declare function tiersToGrant(tierKeys: string[], tiers: Map<string, TierRecord>): string[];
|
|
20
|
+
export declare const DEFAULT_TIER_KEY = "base";
|
|
21
|
+
export declare function grantKeysOrDefault(grantedTierKeys: string[], tiers: Map<string, TierRecord>): {
|
|
22
|
+
tierKeys: string[];
|
|
23
|
+
usingDefault: boolean;
|
|
24
|
+
};
|
|
20
25
|
export declare function collectGrantedFeatures(grantedTierKeys: string[], tiers: Map<string, TierRecord>, features: Map<string, FeatureRecord>): {
|
|
21
26
|
tierKeys: string[];
|
|
22
27
|
grantedBy: Map<string, string[]>;
|
package/dist/tierAccess.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.collectGrantedFeatures = exports.tiersToGrant = exports.expandTierChain = exports.entitlementInForce = void 0;
|
|
3
|
+
exports.collectGrantedFeatures = exports.grantKeysOrDefault = exports.DEFAULT_TIER_KEY = exports.tiersToGrant = exports.expandTierChain = exports.entitlementInForce = void 0;
|
|
4
4
|
function entitlementInForce(row, now) {
|
|
5
5
|
if (row.status !== 'active')
|
|
6
6
|
return false;
|
|
@@ -48,6 +48,17 @@ function tiersToGrant(tierKeys, tiers) {
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
exports.tiersToGrant = tiersToGrant;
|
|
51
|
+
exports.DEFAULT_TIER_KEY = 'base';
|
|
52
|
+
function grantKeysOrDefault(grantedTierKeys, tiers) {
|
|
53
|
+
if (grantedTierKeys.length > 0) {
|
|
54
|
+
return { tierKeys: grantedTierKeys, usingDefault: false };
|
|
55
|
+
}
|
|
56
|
+
if (!tiers.has(exports.DEFAULT_TIER_KEY)) {
|
|
57
|
+
return { tierKeys: [], usingDefault: false };
|
|
58
|
+
}
|
|
59
|
+
return { tierKeys: [exports.DEFAULT_TIER_KEY], usingDefault: true };
|
|
60
|
+
}
|
|
61
|
+
exports.grantKeysOrDefault = grantKeysOrDefault;
|
|
51
62
|
function collectGrantedFeatures(grantedTierKeys, tiers, features) {
|
|
52
63
|
const tierKeys = [];
|
|
53
64
|
const seenTiers = new Set();
|