@nocobase/plugin-notification-manager 1.4.0-alpha.20241105053324 → 1.4.0-alpha.3
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/externalVersion.js
CHANGED
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"react": "18.2.0",
|
|
12
12
|
"antd": "5.12.8",
|
|
13
|
-
"@nocobase/client": "1.4.0-alpha.
|
|
14
|
-
"@nocobase/utils": "1.4.0-alpha.
|
|
15
|
-
"@nocobase/server": "1.4.0-alpha.
|
|
16
|
-
"@nocobase/logger": "1.4.0-alpha.
|
|
13
|
+
"@nocobase/client": "1.4.0-alpha.3",
|
|
14
|
+
"@nocobase/utils": "1.4.0-alpha.3",
|
|
15
|
+
"@nocobase/server": "1.4.0-alpha.3",
|
|
16
|
+
"@nocobase/logger": "1.4.0-alpha.3",
|
|
17
17
|
"@formily/react": "2.3.0",
|
|
18
18
|
"@formily/core": "2.3.0",
|
|
19
19
|
"react-i18next": "11.18.6",
|
|
20
|
-
"@nocobase/database": "1.4.0-alpha.
|
|
20
|
+
"@nocobase/database": "1.4.0-alpha.3",
|
|
21
21
|
"@formily/shared": "2.3.2",
|
|
22
22
|
"@ant-design/icons": "5.2.6",
|
|
23
23
|
"@formily/antd-v5": "1.2.2",
|
|
24
|
-
"@nocobase/plugin-workflow": "1.4.0-alpha.
|
|
24
|
+
"@nocobase/plugin-workflow": "1.4.0-alpha.3"
|
|
25
25
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
export { default, COLLECTION_NAME, ChannelsCollectionDefinition, BaseNotificationChannel, parseUserSelectionConfig, } from './server';
|
|
9
|
+
export { default, COLLECTION_NAME, ChannelsCollectionDefinition, BaseNotificationChannel, parseUserSelectionConfig, SendFnType, } from './server';
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,7 @@ __export(src_exports, {
|
|
|
39
39
|
BaseNotificationChannel: () => import_server.BaseNotificationChannel,
|
|
40
40
|
COLLECTION_NAME: () => import_server.COLLECTION_NAME,
|
|
41
41
|
ChannelsCollectionDefinition: () => import_server.ChannelsCollectionDefinition,
|
|
42
|
+
SendFnType: () => import_server.SendFnType,
|
|
42
43
|
default: () => import_server.default,
|
|
43
44
|
parseUserSelectionConfig: () => import_server.parseUserSelectionConfig
|
|
44
45
|
});
|
|
@@ -49,5 +50,6 @@ var import_server = __toESM(require("./server"));
|
|
|
49
50
|
BaseNotificationChannel,
|
|
50
51
|
COLLECTION_NAME,
|
|
51
52
|
ChannelsCollectionDefinition,
|
|
53
|
+
SendFnType,
|
|
52
54
|
parseUserSelectionConfig
|
|
53
55
|
});
|
package/dist/server/manager.js
CHANGED
|
@@ -32,6 +32,7 @@ __export(manager_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(manager_exports);
|
|
33
33
|
var import_utils = require("@nocobase/utils");
|
|
34
34
|
var import_constant = require("../constant");
|
|
35
|
+
var import_compile = require("./utils/compile");
|
|
35
36
|
class NotificationManager {
|
|
36
37
|
plugin;
|
|
37
38
|
channelTypes = new import_utils.Registry();
|
|
@@ -48,10 +49,11 @@ class NotificationManager {
|
|
|
48
49
|
async send(params) {
|
|
49
50
|
this.plugin.logger.info("receive sending message request", params);
|
|
50
51
|
const channelsRepo = this.plugin.app.db.getRepository(import_constant.COLLECTION_NAME.channels);
|
|
52
|
+
const messageData = { ...params.receivers ? { receivers: params.receivers } : {}, ...params.message };
|
|
51
53
|
const logData = {
|
|
52
54
|
triggerFrom: params.triggerFrom,
|
|
53
55
|
channelName: params.channelName,
|
|
54
|
-
message:
|
|
56
|
+
message: messageData
|
|
55
57
|
};
|
|
56
58
|
try {
|
|
57
59
|
const channel = await channelsRepo.findOne({ filterByTk: params.channelName });
|
|
@@ -60,6 +62,7 @@ class NotificationManager {
|
|
|
60
62
|
const instance = new Channel(this.plugin.app);
|
|
61
63
|
logData.channelTitle = channel.title;
|
|
62
64
|
logData.notificationType = channel.notificationType;
|
|
65
|
+
logData.receivers = params.receivers;
|
|
63
66
|
const result = await instance.send({ message: params.message, channel, receivers: params.receivers });
|
|
64
67
|
logData.status = result.status;
|
|
65
68
|
logData.reason = result.reason;
|
|
@@ -78,8 +81,9 @@ class NotificationManager {
|
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
async sendToUsers(options) {
|
|
81
|
-
const { userIds, channels, message, data } = options;
|
|
82
84
|
this.plugin.logger.info(`notificationManager.sendToUsers options: ${JSON.stringify(options)}`);
|
|
85
|
+
const { userIds, channels, message: template = {}, data = {} } = options;
|
|
86
|
+
const message = (0, import_compile.compile)(template, data);
|
|
83
87
|
return await Promise.all(
|
|
84
88
|
channels.map(
|
|
85
89
|
(channelName) => this.send({ channelName, message, triggerFrom: "sendToUsers", receivers: { value: userIds, type: "userId" } })
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export declare function compile(template: Record<string, any>, data: Record<string, any>): Record<string, any>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var compile_exports = {};
|
|
28
|
+
__export(compile_exports, {
|
|
29
|
+
compile: () => compile
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(compile_exports);
|
|
32
|
+
var import_utils = require("@nocobase/utils");
|
|
33
|
+
function compile(template, data) {
|
|
34
|
+
if (!template) {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
const result = Object.keys(template).reduce((object, key) => {
|
|
38
|
+
let c;
|
|
39
|
+
let value = object[key];
|
|
40
|
+
switch (typeof template[key]) {
|
|
41
|
+
case "object":
|
|
42
|
+
value = compile(template[key], data);
|
|
43
|
+
break;
|
|
44
|
+
case "string":
|
|
45
|
+
c = import_utils.Handlebars.compile(template[key]);
|
|
46
|
+
value = c(data);
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
return Object.assign(object, { [key]: value });
|
|
52
|
+
}, {});
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
compile
|
|
58
|
+
});
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"description": "Provides a unified management service that includes channel configuration, logging, and other features, supporting the configuration of various notification channels, including in-app message and email.",
|
|
5
5
|
"displayName.zh-CN": "通知管理",
|
|
6
6
|
"description.zh-CN": "提供统一的管理服务,涵盖渠道配置、日志记录等功能,支持多种通知渠道的配置,包括站内信和电子邮件等。",
|
|
7
|
-
"version": "1.4.0-alpha.
|
|
7
|
+
"version": "1.4.0-alpha.3",
|
|
8
8
|
"main": "dist/server/index.js",
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@ant-design/icons": "5.x",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"keywords": [
|
|
30
30
|
"Notification"
|
|
31
31
|
],
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "9268a5b29cbbe9f83255e5cd66fa82f012aab46a"
|
|
33
33
|
}
|