@memberjunction/notifications 0.0.1 → 3.3.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/NotificationEngine.d.ts +65 -0
- package/dist/NotificationEngine.d.ts.map +1 -0
- package/dist/NotificationEngine.js +285 -0
- package/dist/NotificationEngine.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +90 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +31 -7
- package/README.md +0 -45
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { BaseEngine, IMetadataProvider, UserInfo } from '@memberjunction/core';
|
|
2
|
+
import { SendNotificationParams, NotificationResult } from './types';
|
|
3
|
+
export declare class NotificationEngine extends BaseEngine<NotificationEngine> {
|
|
4
|
+
/**
|
|
5
|
+
* Returns the singleton instance of the NotificationEngine
|
|
6
|
+
*/
|
|
7
|
+
static get Instance(): NotificationEngine;
|
|
8
|
+
/**
|
|
9
|
+
* Configures the notification engine.
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This does NOT load notification types - UserInfoEngine handles that.
|
|
12
|
+
* UserInfoEngine is auto-configured via @RegisterForStartup() and loads notification types
|
|
13
|
+
* into its cache. This engine just provides the delivery mechanism.
|
|
14
|
+
*
|
|
15
|
+
* @param forceRefresh - If true, reloads data even if already loaded
|
|
16
|
+
* @param contextUser - User context for database operations (required on server)
|
|
17
|
+
* @param provider - Optional metadata provider override
|
|
18
|
+
*/
|
|
19
|
+
Config(forceRefresh?: boolean, contextUser?: UserInfo, provider?: IMetadataProvider): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Get a notification type by name (case-insensitive) or ID.
|
|
22
|
+
* Uses UserInfoEngine's cached notification types.
|
|
23
|
+
*
|
|
24
|
+
* @param nameOrId - The notification type name or UUID
|
|
25
|
+
* @returns The notification type entity or null if not found
|
|
26
|
+
*/
|
|
27
|
+
private getNotificationType;
|
|
28
|
+
/**
|
|
29
|
+
* Send a notification using the unified notification system.
|
|
30
|
+
*
|
|
31
|
+
* This method:
|
|
32
|
+
* 1. Looks up the notification type from cache
|
|
33
|
+
* 2. Checks user preferences for delivery method
|
|
34
|
+
* 3. Creates in-app notification if applicable
|
|
35
|
+
* 4. Sends email/SMS using templates if applicable
|
|
36
|
+
*
|
|
37
|
+
* @param params - Notification parameters
|
|
38
|
+
* @param contextUser - User context for database operations
|
|
39
|
+
* @returns Result indicating success and delivery details
|
|
40
|
+
*/
|
|
41
|
+
SendNotification(params: SendNotificationParams, contextUser: UserInfo): Promise<NotificationResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Resolve the effective delivery channels based on force, preference, and type defaults.
|
|
44
|
+
* Uses the new boolean column approach for flexible multi-channel selection.
|
|
45
|
+
*/
|
|
46
|
+
private resolveDeliveryChannels;
|
|
47
|
+
/**
|
|
48
|
+
* Get user preferences for a notification type from UserInfoEngine's cache.
|
|
49
|
+
* Preferences are still cached in UserInfoEngine (user-specific data).
|
|
50
|
+
*/
|
|
51
|
+
private getUserPreferences;
|
|
52
|
+
/**
|
|
53
|
+
* Create in-app notification record
|
|
54
|
+
*/
|
|
55
|
+
private createInAppNotification;
|
|
56
|
+
/**
|
|
57
|
+
* Send email notification using template
|
|
58
|
+
*/
|
|
59
|
+
private sendEmail;
|
|
60
|
+
/**
|
|
61
|
+
* Send SMS notification using template
|
|
62
|
+
*/
|
|
63
|
+
private sendSMS;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=NotificationEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationEngine.d.ts","sourceRoot":"","sources":["../src/NotificationEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAY,QAAQ,EAA2C,MAAM,sBAAsB,CAAC;AAMlI,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAoB,MAAM,SAAS,CAAC;AASvF,qBAAa,kBAAmB,SAAQ,UAAU,CAAC,kBAAkB,CAAC;IACpE;;OAEG;IACH,WAAkB,QAAQ,IAAI,kBAAkB,CAE/C;IAED;;;;;;;;;;OAUG;IACU,MAAM,CACjB,YAAY,GAAE,OAAe,EAC7B,WAAW,CAAC,EAAE,QAAQ,EACtB,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,OAAO,CAAC,IAAI,CAAC;IAQhB;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IAY3B;;;;;;;;;;;;OAYG;IACU,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,EAAE,WAAW,EAAE,QAAQ,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA8DjH;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAoC/B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAuB1B;;OAEG;YACW,uBAAuB;IAgCrC;;OAEG;YACW,SAAS;IAsDvB;;OAEG;YACW,OAAO;CAqDtB"}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationEngine = void 0;
|
|
4
|
+
const core_1 = require("@memberjunction/core");
|
|
5
|
+
const core_entities_1 = require("@memberjunction/core-entities");
|
|
6
|
+
const templates_1 = require("@memberjunction/templates");
|
|
7
|
+
const communication_engine_1 = require("@memberjunction/communication-engine");
|
|
8
|
+
const communication_types_1 = require("@memberjunction/communication-types");
|
|
9
|
+
const sqlserver_dataprovider_1 = require("@memberjunction/sqlserver-dataprovider");
|
|
10
|
+
/*
|
|
11
|
+
* Unified notification engine that handles in-app, email, and SMS delivery
|
|
12
|
+
* based on notification types and user preferences.
|
|
13
|
+
*
|
|
14
|
+
* This engine relies on UserInfoEngine for notification types and preferences.
|
|
15
|
+
* UserInfoEngine loads and caches all notification metadata via BaseEngine.
|
|
16
|
+
*/
|
|
17
|
+
class NotificationEngine extends core_1.BaseEngine {
|
|
18
|
+
/**
|
|
19
|
+
* Returns the singleton instance of the NotificationEngine
|
|
20
|
+
*/
|
|
21
|
+
static get Instance() {
|
|
22
|
+
return super.getInstance();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Configures the notification engine.
|
|
26
|
+
*
|
|
27
|
+
* NOTE: This does NOT load notification types - UserInfoEngine handles that.
|
|
28
|
+
* UserInfoEngine is auto-configured via @RegisterForStartup() and loads notification types
|
|
29
|
+
* into its cache. This engine just provides the delivery mechanism.
|
|
30
|
+
*
|
|
31
|
+
* @param forceRefresh - If true, reloads data even if already loaded
|
|
32
|
+
* @param contextUser - User context for database operations (required on server)
|
|
33
|
+
* @param provider - Optional metadata provider override
|
|
34
|
+
*/
|
|
35
|
+
async Config(forceRefresh = false, contextUser, provider) {
|
|
36
|
+
// Ensure UserInfoEngine is configured (it loads notification types)
|
|
37
|
+
await core_entities_1.UserInfoEngine.Instance.Config(forceRefresh, contextUser, provider);
|
|
38
|
+
// BaseEngine Load with empty configs - we don't load our own data
|
|
39
|
+
await this.Load([], provider || core_1.Metadata.Provider, forceRefresh, contextUser);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get a notification type by name (case-insensitive) or ID.
|
|
43
|
+
* Uses UserInfoEngine's cached notification types.
|
|
44
|
+
*
|
|
45
|
+
* @param nameOrId - The notification type name or UUID
|
|
46
|
+
* @returns The notification type entity or null if not found
|
|
47
|
+
*/
|
|
48
|
+
getNotificationType(nameOrId) {
|
|
49
|
+
const types = core_entities_1.UserInfoEngine.Instance.NotificationTypes;
|
|
50
|
+
// Try by ID first
|
|
51
|
+
const byId = types.find(t => t.ID === nameOrId);
|
|
52
|
+
if (byId)
|
|
53
|
+
return byId;
|
|
54
|
+
// Try by name (case-insensitive)
|
|
55
|
+
const lowerName = nameOrId.toLowerCase();
|
|
56
|
+
return types.find(t => t.Name.toLowerCase() === lowerName) || null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Send a notification using the unified notification system.
|
|
60
|
+
*
|
|
61
|
+
* This method:
|
|
62
|
+
* 1. Looks up the notification type from cache
|
|
63
|
+
* 2. Checks user preferences for delivery method
|
|
64
|
+
* 3. Creates in-app notification if applicable
|
|
65
|
+
* 4. Sends email/SMS using templates if applicable
|
|
66
|
+
*
|
|
67
|
+
* @param params - Notification parameters
|
|
68
|
+
* @param contextUser - User context for database operations
|
|
69
|
+
* @returns Result indicating success and delivery details
|
|
70
|
+
*/
|
|
71
|
+
async SendNotification(params, contextUser) {
|
|
72
|
+
this.TryThrowIfNotLoaded();
|
|
73
|
+
const result = {
|
|
74
|
+
success: true,
|
|
75
|
+
deliveryChannels: { inApp: false, email: false, sms: false },
|
|
76
|
+
errors: [],
|
|
77
|
+
};
|
|
78
|
+
try {
|
|
79
|
+
// Look up notification type from cache
|
|
80
|
+
const type = this.getNotificationType(params.typeNameOrId);
|
|
81
|
+
if (!type) {
|
|
82
|
+
throw new Error(`Notification type not found: ${params.typeNameOrId}`);
|
|
83
|
+
}
|
|
84
|
+
// looks up user preference from cache
|
|
85
|
+
const prefs = this.getUserPreferences(params.userId, type.ID);
|
|
86
|
+
// Determine delivery channels
|
|
87
|
+
const channels = this.resolveDeliveryChannels(params, prefs, type);
|
|
88
|
+
result.deliveryChannels = channels;
|
|
89
|
+
// Early return if user has opted out (all channels disabled)
|
|
90
|
+
if (!channels.inApp && !channels.email && !channels.sms) {
|
|
91
|
+
(0, core_1.LogStatus)(`User has opted out or all channels disabled for notification type: ${type.Name}`);
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
// 5. Create in-app notification if enabled (awaited - fast DB insert)
|
|
95
|
+
if (channels.inApp) {
|
|
96
|
+
result.inAppNotificationId = await this.createInAppNotification(params, type, contextUser);
|
|
97
|
+
}
|
|
98
|
+
// 6. Send email if enabled - fire and forget (don't block)
|
|
99
|
+
if (channels.email) {
|
|
100
|
+
result.emailSent = true; // Optimistically set - actual send is async
|
|
101
|
+
this.sendEmail(params, type, contextUser).catch((error) => {
|
|
102
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
103
|
+
(0, core_1.LogError)(`Email delivery failed for notification type ${type.Name}: ${errorMessage}`);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// 7. Send SMS if enabled - fire and forget (don't block)
|
|
107
|
+
if (channels.sms) {
|
|
108
|
+
result.smsSent = true; // Optimistically set - actual send is async
|
|
109
|
+
this.sendSMS(params, type, contextUser).catch((error) => {
|
|
110
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
111
|
+
(0, core_1.LogError)(`SMS delivery failed for notification type ${type.Name}: ${errorMessage}`);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
118
|
+
result.success = false;
|
|
119
|
+
result.errors?.push(errorMessage);
|
|
120
|
+
(0, core_1.LogError)(`Notification delivery failed: ${errorMessage}`);
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Resolve the effective delivery channels based on force, preference, and type defaults.
|
|
126
|
+
* Uses the new boolean column approach for flexible multi-channel selection.
|
|
127
|
+
*/
|
|
128
|
+
resolveDeliveryChannels(params, prefs, type) {
|
|
129
|
+
// If forceDeliveryChannels is specified, use it directly
|
|
130
|
+
if (params.forceDeliveryChannels) {
|
|
131
|
+
return params.forceDeliveryChannels;
|
|
132
|
+
}
|
|
133
|
+
// Check if user has opted out entirely (master switch)
|
|
134
|
+
if (prefs && !prefs.Enabled) {
|
|
135
|
+
return { inApp: false, email: false, sms: false };
|
|
136
|
+
}
|
|
137
|
+
// Determine each channel: user pref (if allowed and set) > type default
|
|
138
|
+
const allowUserPref = type.AllowUserPreference !== false;
|
|
139
|
+
// Resolve InApp channel
|
|
140
|
+
const inApp = (allowUserPref && prefs?.InAppEnabled != null)
|
|
141
|
+
? prefs.InAppEnabled
|
|
142
|
+
: (type.DefaultInApp ?? false);
|
|
143
|
+
// Resolve Email channel
|
|
144
|
+
const email = (allowUserPref && prefs?.EmailEnabled != null)
|
|
145
|
+
? prefs.EmailEnabled
|
|
146
|
+
: (type.DefaultEmail ?? false);
|
|
147
|
+
// Resolve SMS channel
|
|
148
|
+
const sms = (allowUserPref && prefs?.SMSEnabled != null)
|
|
149
|
+
? prefs.SMSEnabled
|
|
150
|
+
: (type.DefaultSMS ?? false);
|
|
151
|
+
return { inApp, email, sms };
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get user preferences for a notification type from UserInfoEngine's cache.
|
|
155
|
+
* Preferences are still cached in UserInfoEngine (user-specific data).
|
|
156
|
+
*/
|
|
157
|
+
getUserPreferences(userId, typeId) {
|
|
158
|
+
// Use cached preferences from UserInfoEngine (user-specific)
|
|
159
|
+
const pref = core_entities_1.UserInfoEngine.Instance.GetUserPreferenceForType(userId, typeId);
|
|
160
|
+
// If preference exists, return it
|
|
161
|
+
if (pref) {
|
|
162
|
+
return pref;
|
|
163
|
+
}
|
|
164
|
+
// If no preference exists and the type doesn't allow user preferences, return null
|
|
165
|
+
const type = this.getNotificationType(typeId);
|
|
166
|
+
if (type && !type.AllowUserPreference) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
// If we reach here, the user hasn't set a preference yet
|
|
170
|
+
// Return null to use type defaults
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Create in-app notification record
|
|
175
|
+
*/
|
|
176
|
+
async createInAppNotification(params, type, contextUser) {
|
|
177
|
+
const md = new core_1.Metadata();
|
|
178
|
+
const notification = await md.GetEntityObject('User Notifications', contextUser);
|
|
179
|
+
notification.UserID = params.userId;
|
|
180
|
+
notification.NotificationTypeID = type.ID;
|
|
181
|
+
notification.Title = params.title;
|
|
182
|
+
notification.Message = params.message;
|
|
183
|
+
notification.Unread = true;
|
|
184
|
+
if (params.resourceTypeId) {
|
|
185
|
+
notification.ResourceTypeID = params.resourceTypeId;
|
|
186
|
+
}
|
|
187
|
+
if (params.resourceRecordId) {
|
|
188
|
+
notification.ResourceRecordID = params.resourceRecordId;
|
|
189
|
+
}
|
|
190
|
+
if (params.resourceConfiguration) {
|
|
191
|
+
notification.ResourceConfiguration = JSON.stringify(params.resourceConfiguration);
|
|
192
|
+
}
|
|
193
|
+
if (await notification.Save()) {
|
|
194
|
+
(0, core_1.LogStatus)(`In-app notification created: ${notification.ID} for type: ${type.Name}`);
|
|
195
|
+
return notification.ID;
|
|
196
|
+
}
|
|
197
|
+
throw new Error('Failed to save in-app notification');
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Send email notification using template
|
|
201
|
+
*/
|
|
202
|
+
async sendEmail(params, type, contextUser) {
|
|
203
|
+
// Access EmailTemplateID
|
|
204
|
+
const emailTemplateId = type.EmailTemplateID;
|
|
205
|
+
if (!emailTemplateId) {
|
|
206
|
+
(0, core_1.LogStatus)(`No email template configured for notification type: ${type.Name}`);
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
// Load and configure template engine (loads all template metadata)
|
|
210
|
+
const templateEngine = templates_1.TemplateEngineServer.Instance;
|
|
211
|
+
await templateEngine.Config(false, contextUser);
|
|
212
|
+
// Find the email template from the cached Templates array
|
|
213
|
+
const templateEntity = templateEngine.Templates.find((t) => t.ID === emailTemplateId);
|
|
214
|
+
if (!templateEntity) {
|
|
215
|
+
throw new Error(`Email template not found: ${emailTemplateId}`);
|
|
216
|
+
}
|
|
217
|
+
// Get user from cache (server-side optimization - no database query)
|
|
218
|
+
const user = sqlserver_dataprovider_1.UserCache.Instance.Users.find((u) => u.ID === params.userId);
|
|
219
|
+
if (!user) {
|
|
220
|
+
throw new Error('User not found for email delivery');
|
|
221
|
+
}
|
|
222
|
+
if (!user.Email) {
|
|
223
|
+
throw new Error('User has no email address configured');
|
|
224
|
+
}
|
|
225
|
+
// Configure and send via CommunicationEngine
|
|
226
|
+
const commEngine = communication_engine_1.CommunicationEngine.Instance;
|
|
227
|
+
await commEngine.Config(false, contextUser);
|
|
228
|
+
const message = new communication_types_1.Message();
|
|
229
|
+
message.From = process.env.NOTIFICATION_FROM_EMAIL || 'notifications@memberjunction.com';
|
|
230
|
+
message.To = user.Email;
|
|
231
|
+
message.HTMLBodyTemplate = templateEntity;
|
|
232
|
+
message.ContextData = params.templateData || {};
|
|
233
|
+
message.Subject = params.title;
|
|
234
|
+
const sendResult = await commEngine.SendSingleMessage('SendGrid', 'Email', message, undefined, false);
|
|
235
|
+
const success = sendResult?.Success === true;
|
|
236
|
+
if (success) {
|
|
237
|
+
(0, core_1.LogStatus)(`Email sent successfully to ${user.Email} for notification type: ${type.Name}`);
|
|
238
|
+
}
|
|
239
|
+
return success;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Send SMS notification using template
|
|
243
|
+
*/
|
|
244
|
+
async sendSMS(params, type, contextUser) {
|
|
245
|
+
// Access SMSTemplateID
|
|
246
|
+
const smsTemplateId = type.SMSTemplateID;
|
|
247
|
+
if (!smsTemplateId) {
|
|
248
|
+
(0, core_1.LogStatus)(`No SMS template configured for notification type: ${type.Name}`);
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
// Load and configure template engine (loads all template metadata)
|
|
252
|
+
const templateEngine = templates_1.TemplateEngineServer.Instance;
|
|
253
|
+
await templateEngine.Config(false, contextUser);
|
|
254
|
+
// Find the SMS template from the cached Templates array
|
|
255
|
+
const templateEntity = templateEngine.Templates.find((t) => t.ID === smsTemplateId);
|
|
256
|
+
if (!templateEntity) {
|
|
257
|
+
throw new Error(`SMS template not found: ${smsTemplateId}`);
|
|
258
|
+
}
|
|
259
|
+
// Get user from cache (server-side optimization - no database query)
|
|
260
|
+
const user = sqlserver_dataprovider_1.UserCache.Instance.Users.find((u) => u.ID === params.userId);
|
|
261
|
+
if (!user) {
|
|
262
|
+
throw new Error('User not found for SMS delivery');
|
|
263
|
+
}
|
|
264
|
+
// Type assertion since UserInfo doesn't have Phone property yet
|
|
265
|
+
const userWithPhone = user;
|
|
266
|
+
if (!userWithPhone.Phone) {
|
|
267
|
+
throw new Error('User has no phone number configured');
|
|
268
|
+
}
|
|
269
|
+
// Send via CommunicationEngine - let it handle template rendering
|
|
270
|
+
const commEngine = communication_engine_1.CommunicationEngine.Instance;
|
|
271
|
+
await commEngine.Config(false, contextUser);
|
|
272
|
+
const message = new communication_types_1.Message();
|
|
273
|
+
message.To = userWithPhone.Phone;
|
|
274
|
+
message.BodyTemplate = templateEntity;
|
|
275
|
+
message.ContextData = params.templateData || {};
|
|
276
|
+
const sendResult = await commEngine.SendSingleMessage('Twilio', 'Standard SMS', message, undefined, false);
|
|
277
|
+
const success = sendResult?.Success === true;
|
|
278
|
+
if (success) {
|
|
279
|
+
(0, core_1.LogStatus)(`SMS sent successfully to ${userWithPhone.Phone} for notification type: ${type.Name}`);
|
|
280
|
+
}
|
|
281
|
+
return success;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
exports.NotificationEngine = NotificationEngine;
|
|
285
|
+
//# sourceMappingURL=NotificationEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationEngine.js","sourceRoot":"","sources":["../src/NotificationEngine.ts"],"names":[],"mappings":";;;AAAA,+CAAkI;AAClI,iEAAqJ;AACrJ,yDAAiE;AACjE,+EAA2E;AAC3E,6EAA8D;AAC9D,mFAAmE;AAGnE;;;;;;GAMG;AACH,MAAa,kBAAmB,SAAQ,iBAA8B;IACpE;;OAEG;IACI,MAAM,KAAK,QAAQ;QACxB,OAAO,KAAK,CAAC,WAAW,EAAsB,CAAC;IACjD,CAAC;IAED;;;;;;;;;;OAUG;IACI,KAAK,CAAC,MAAM,CACjB,eAAwB,KAAK,EAC7B,WAAsB,EACtB,QAA4B;QAE5B,oEAAoE;QACpE,MAAM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Junction with multi-channel delivery support.
|
|
5
|
+
* Extends BaseEngine for cached notification types and auto-refresh capabilities.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Cached notification types (loaded once, auto-refreshed on changes)
|
|
9
|
+
* - User delivery preferences (In-App, Email, SMS per channel)
|
|
10
|
+
* - Template-based email/SMS formatting
|
|
11
|
+
* - Integration with CommunicationEngine for external delivery
|
|
12
|
+
* - Automatic in-app notification creation
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { NotificationEngine } from '@memberjunction/notifications';
|
|
17
|
+
*
|
|
18
|
+
* // Initialize at server startup
|
|
19
|
+
* await NotificationEngine.Instance.Config(false, contextUser);
|
|
20
|
+
*
|
|
21
|
+
* // Send a notification
|
|
22
|
+
* const result = await NotificationEngine.Instance.SendNotification({
|
|
23
|
+
* userId: contextUser.ID,
|
|
24
|
+
* typeNameOrId: 'Agent Completion',
|
|
25
|
+
* title: 'Task Complete',
|
|
26
|
+
* message: 'Your AI agent has finished processing',
|
|
27
|
+
* templateData: {
|
|
28
|
+
* agentName: 'My Agent',
|
|
29
|
+
* conversationUrl: 'https://...'
|
|
30
|
+
* }
|
|
31
|
+
* }, contextUser);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export { NotificationEngine } from './NotificationEngine';
|
|
35
|
+
export { SendNotificationParams, NotificationResult, DeliveryChannels } from './types';
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @memberjunction/notifications
|
|
4
|
+
*
|
|
5
|
+
* Unified notification engine for MemberJunction with multi-channel delivery support.
|
|
6
|
+
* Extends BaseEngine for cached notification types and auto-refresh capabilities.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Cached notification types (loaded once, auto-refreshed on changes)
|
|
10
|
+
* - User delivery preferences (In-App, Email, SMS per channel)
|
|
11
|
+
* - Template-based email/SMS formatting
|
|
12
|
+
* - Integration with CommunicationEngine for external delivery
|
|
13
|
+
* - Automatic in-app notification creation
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { NotificationEngine } from '@memberjunction/notifications';
|
|
18
|
+
*
|
|
19
|
+
* // Initialize at server startup
|
|
20
|
+
* await NotificationEngine.Instance.Config(false, contextUser);
|
|
21
|
+
*
|
|
22
|
+
* // Send a notification
|
|
23
|
+
* const result = await NotificationEngine.Instance.SendNotification({
|
|
24
|
+
* userId: contextUser.ID,
|
|
25
|
+
* typeNameOrId: 'Agent Completion',
|
|
26
|
+
* title: 'Task Complete',
|
|
27
|
+
* message: 'Your AI agent has finished processing',
|
|
28
|
+
* templateData: {
|
|
29
|
+
* agentName: 'My Agent',
|
|
30
|
+
* conversationUrl: 'https://...'
|
|
31
|
+
* }
|
|
32
|
+
* }, contextUser);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.NotificationEngine = void 0;
|
|
37
|
+
var NotificationEngine_1 = require("./NotificationEngine");
|
|
38
|
+
Object.defineProperty(exports, "NotificationEngine", { enumerable: true, get: function () { return NotificationEngine_1.NotificationEngine; } });
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;;;AAEH,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Individual channel settings for notification delivery.
|
|
3
|
+
* Each channel can be independently enabled or disabled.
|
|
4
|
+
*/
|
|
5
|
+
export interface DeliveryChannels {
|
|
6
|
+
/**
|
|
7
|
+
* Whether in-app notifications are enabled
|
|
8
|
+
*/
|
|
9
|
+
inApp: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether email notifications are enabled
|
|
12
|
+
*/
|
|
13
|
+
email: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether SMS notifications are enabled
|
|
16
|
+
*/
|
|
17
|
+
sms: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Parameters for sending a notification through the unified notification system
|
|
21
|
+
*/
|
|
22
|
+
export interface SendNotificationParams {
|
|
23
|
+
/**
|
|
24
|
+
* User ID to send notification to
|
|
25
|
+
*/
|
|
26
|
+
userId: string;
|
|
27
|
+
/**
|
|
28
|
+
* Notification type name (e.g., 'Agent Completion') or UUID
|
|
29
|
+
*/
|
|
30
|
+
typeNameOrId: string;
|
|
31
|
+
/**
|
|
32
|
+
* Short notification title (used for in-app and email subject)
|
|
33
|
+
*/
|
|
34
|
+
title: string;
|
|
35
|
+
/**
|
|
36
|
+
* Full notification message (used for in-app display)
|
|
37
|
+
*/
|
|
38
|
+
message: string;
|
|
39
|
+
/**
|
|
40
|
+
* Optional resource type ID for linking notification to a specific resource
|
|
41
|
+
*/
|
|
42
|
+
resourceTypeId?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Optional resource record ID for linking notification to a specific record
|
|
45
|
+
*/
|
|
46
|
+
resourceRecordId?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Optional navigation context stored as JSON (conversation ID, artifact details, etc.)
|
|
49
|
+
*/
|
|
50
|
+
resourceConfiguration?: any;
|
|
51
|
+
/**
|
|
52
|
+
* Data object for template rendering (email/SMS templates)
|
|
53
|
+
*/
|
|
54
|
+
templateData?: Record<string, any>;
|
|
55
|
+
/**
|
|
56
|
+
* Force specific delivery channels, overriding user preferences and type defaults.
|
|
57
|
+
* When specified, these channels are used instead of resolving from preferences.
|
|
58
|
+
*/
|
|
59
|
+
forceDeliveryChannels?: DeliveryChannels;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Result of sending a notification
|
|
63
|
+
*/
|
|
64
|
+
export interface NotificationResult {
|
|
65
|
+
/**
|
|
66
|
+
* Whether the notification operation succeeded overall
|
|
67
|
+
*/
|
|
68
|
+
success: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* ID of the created in-app notification (if created)
|
|
71
|
+
*/
|
|
72
|
+
inAppNotificationId?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Whether email was sent successfully
|
|
75
|
+
*/
|
|
76
|
+
emailSent?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Whether SMS was sent successfully
|
|
79
|
+
*/
|
|
80
|
+
smsSent?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Actual delivery channels used (after resolving preferences)
|
|
83
|
+
*/
|
|
84
|
+
deliveryChannels: DeliveryChannels;
|
|
85
|
+
/**
|
|
86
|
+
* Any errors that occurred during notification delivery
|
|
87
|
+
*/
|
|
88
|
+
errors?: string[];
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,GAAG,EAAE,OAAO,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,qBAAqB,CAAC,EAAE,GAAG,CAAC;IAE5B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEnC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,gBAAgB,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/notifications",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
]
|
|
3
|
+
"version": "3.3.0",
|
|
4
|
+
"description": "MemberJunction: Unified Notification System with Multi-Channel Delivery",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"/dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "ts-node-dev src/index.ts",
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"author": "MemberJunction.com",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"ts-node-dev": "^2.0.0",
|
|
19
|
+
"typescript": "^5.4.5"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@memberjunction/global": "3.3.0",
|
|
23
|
+
"@memberjunction/core": "3.3.0",
|
|
24
|
+
"@memberjunction/core-entities": "3.3.0",
|
|
25
|
+
"@memberjunction/templates": "3.3.0",
|
|
26
|
+
"@memberjunction/communication-engine": "3.3.0",
|
|
27
|
+
"@memberjunction/communication-types": "3.3.0",
|
|
28
|
+
"@memberjunction/sqlserver-dataprovider": "3.3.0"
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/MemberJunction/MJ"
|
|
33
|
+
}
|
|
10
34
|
}
|
package/README.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# @memberjunction/notifications
|
|
2
|
-
|
|
3
|
-
## ⚠️ IMPORTANT NOTICE ⚠️
|
|
4
|
-
|
|
5
|
-
**This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
|
|
6
|
-
|
|
7
|
-
This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
|
|
8
|
-
|
|
9
|
-
## Purpose
|
|
10
|
-
|
|
11
|
-
This package exists to:
|
|
12
|
-
1. Configure OIDC trusted publishing for the package name `@memberjunction/notifications`
|
|
13
|
-
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
15
|
-
|
|
16
|
-
## What is OIDC Trusted Publishing?
|
|
17
|
-
|
|
18
|
-
OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
|
|
19
|
-
|
|
20
|
-
## Setup Instructions
|
|
21
|
-
|
|
22
|
-
To properly configure OIDC trusted publishing for this package:
|
|
23
|
-
|
|
24
|
-
1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
28
|
-
|
|
29
|
-
## DO NOT USE THIS PACKAGE
|
|
30
|
-
|
|
31
|
-
This package is a placeholder for OIDC configuration only. It:
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
36
|
-
|
|
37
|
-
## More Information
|
|
38
|
-
|
|
39
|
-
For more details about npm's trusted publishing feature, see:
|
|
40
|
-
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
-
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
**Maintained for OIDC setup purposes only**
|