@nocobase/plugin-notification-manager 1.4.0-alpha.20240928155737
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/LICENSE.txt +123 -0
- package/README.md +1 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/Management.d.ts +10 -0
- package/dist/client/hooks/channel.d.ts +14 -0
- package/dist/client/hooks/index.d.ts +29 -0
- package/dist/client/index.d.ts +21 -0
- package/dist/client/index.js +10 -0
- package/dist/client/locale/index.d.ts +12 -0
- package/dist/client/manager/channel/components/ConfigForm.d.ts +10 -0
- package/dist/client/manager/channel/components/index.d.ts +13 -0
- package/dist/client/manager/channel/context.d.ts +25 -0
- package/dist/client/manager/channel/hooks.d.ts +45 -0
- package/dist/client/manager/channel/schemas/form.d.ts +43 -0
- package/dist/client/manager/channel/schemas/index.d.ts +11 -0
- package/dist/client/manager/channel/types.d.ts +27 -0
- package/dist/client/manager/log/components/Manager.d.ts +13 -0
- package/dist/client/manager/log/components/index.d.ts +8 -0
- package/dist/client/manager/log/hooks.d.ts +8 -0
- package/dist/client/manager/log/schemas/index.d.ts +71 -0
- package/dist/client/manager/log/types.d.ts +24 -0
- package/dist/client/manager/message/components/Manager.d.ts +13 -0
- package/dist/client/manager/message/components/MessageConfigForm/index.d.ts +12 -0
- package/dist/client/manager/message/components/MessageInput.d.ts +11 -0
- package/dist/client/manager/message/components/ReceiverConfigForm/Users/Select.d.ts +18 -0
- package/dist/client/manager/message/components/ReceiverConfigForm/Users/UsersAddition.d.ts +10 -0
- package/dist/client/manager/message/components/index.d.ts +8 -0
- package/dist/client/manager/message/components/useSendAction.d.ts +11 -0
- package/dist/client/manager/message/schemas/form.d.ts +34 -0
- package/dist/client/manager/message/schemas/index.d.ts +10 -0
- package/dist/client/manager/message/types.d.ts +25 -0
- package/dist/client/notification-manager.d.ts +13 -0
- package/dist/collections/channel.d.ts +11 -0
- package/dist/collections/channel.js +145 -0
- package/dist/collections/messageLog.d.ts +11 -0
- package/dist/collections/messageLog.js +155 -0
- package/dist/constant.d.ts +14 -0
- package/dist/constant.js +42 -0
- package/dist/externalVersion.js +25 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +51 -0
- package/dist/locale/en-US.json +39 -0
- package/dist/locale/zh-CN.json +41 -0
- package/dist/server/base-notification-channel.d.ts +22 -0
- package/dist/server/base-notification-channel.js +40 -0
- package/dist/server/collections/channels.d.ts +10 -0
- package/dist/server/collections/channels.js +44 -0
- package/dist/server/collections/messageLogs.d.ts +10 -0
- package/dist/server/collections/messageLogs.js +44 -0
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.js +51 -0
- package/dist/server/manager.d.ts +22 -0
- package/dist/server/manager.js +102 -0
- package/dist/server/plugin.d.ts +25 -0
- package/dist/server/plugin.js +93 -0
- package/dist/server/types.d.ts +49 -0
- package/dist/server/types.js +24 -0
- package/package.json +33 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Notification Management": "通知管理",
|
|
3
|
+
"Notification": "通知",
|
|
4
|
+
"Channels": "渠道",
|
|
5
|
+
"Channel": "渠道",
|
|
6
|
+
"Channel title": "渠道名称",
|
|
7
|
+
"Content": "内容",
|
|
8
|
+
"Receivers":"接收人",
|
|
9
|
+
"Receiver": "接收人",
|
|
10
|
+
"Add new receiver": "新增接收人",
|
|
11
|
+
"Templates": "模板",
|
|
12
|
+
"Logs": "日志",
|
|
13
|
+
"Title": "标题",
|
|
14
|
+
"Description": "描述",
|
|
15
|
+
"Notification type": "通知类型",
|
|
16
|
+
"Actions": "操作",
|
|
17
|
+
"Channel name": "渠道标识",
|
|
18
|
+
"Channel display name": "渠道名称",
|
|
19
|
+
"Configure": "编辑",
|
|
20
|
+
"Add new": "新增",
|
|
21
|
+
"Trigger from": "触发来源",
|
|
22
|
+
"Status": "状态",
|
|
23
|
+
"Created at": "发送时间",
|
|
24
|
+
"Delete record": "删除记录",
|
|
25
|
+
"Are you sure you want to delete it?": "确定要删除吗?",
|
|
26
|
+
"Deleted successfully!": "删除成功!",
|
|
27
|
+
"Add user": "添加用户",
|
|
28
|
+
"Select users": "选择用户",
|
|
29
|
+
"Query users": "查询用户",
|
|
30
|
+
"Receiver type": "接收人类型",
|
|
31
|
+
"Manual input": "手动输入",
|
|
32
|
+
"Select user": "选择用户",
|
|
33
|
+
"No channel enabled yet": "暂无启用的渠道",
|
|
34
|
+
"Success": "成功",
|
|
35
|
+
"Failure": "失败",
|
|
36
|
+
"Reason": "原因",
|
|
37
|
+
"Failed reason": "失败原因",
|
|
38
|
+
"Log detail": "日志详情",
|
|
39
|
+
"Message": "消息内容",
|
|
40
|
+
"Notification manager": "通知管理"
|
|
41
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
import { Application } from '@nocobase/server';
|
|
10
|
+
import { ChannelOptions } from './types';
|
|
11
|
+
export declare abstract class BaseNotificationChannel<Message = any> {
|
|
12
|
+
protected app: Application;
|
|
13
|
+
constructor(app: Application);
|
|
14
|
+
abstract send(params: {
|
|
15
|
+
channel: ChannelOptions;
|
|
16
|
+
message: Message;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
message: Message;
|
|
19
|
+
status: 'success' | 'fail';
|
|
20
|
+
reason?: string;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 base_notification_channel_exports = {};
|
|
28
|
+
__export(base_notification_channel_exports, {
|
|
29
|
+
BaseNotificationChannel: () => BaseNotificationChannel
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(base_notification_channel_exports);
|
|
32
|
+
class BaseNotificationChannel {
|
|
33
|
+
constructor(app) {
|
|
34
|
+
this.app = app;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
BaseNotificationChannel
|
|
40
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
declare const _default: import("@nocobase/database").CollectionOptions;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
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 __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var channels_exports = {};
|
|
38
|
+
__export(channels_exports, {
|
|
39
|
+
default: () => channels_default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(channels_exports);
|
|
42
|
+
var import_database = require("@nocobase/database");
|
|
43
|
+
var import_channel = __toESM(require("../../collections/channel"));
|
|
44
|
+
var channels_default = (0, import_database.defineCollection)(import_channel.default);
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
declare const _default: import("@nocobase/database").CollectionOptions;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
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 __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var messageLogs_exports = {};
|
|
38
|
+
__export(messageLogs_exports, {
|
|
39
|
+
default: () => messageLogs_default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(messageLogs_exports);
|
|
42
|
+
var import_database = require("@nocobase/database");
|
|
43
|
+
var import_messageLog = __toESM(require("../../collections/messageLog"));
|
|
44
|
+
var messageLogs_default = (0, import_database.defineCollection)(import_messageLog.default);
|
|
@@ -0,0 +1,11 @@
|
|
|
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 { BaseNotificationChannel } from './base-notification-channel';
|
|
10
|
+
export { default } from './plugin';
|
|
11
|
+
export * from './types';
|
|
@@ -0,0 +1,51 @@
|
|
|
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 __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var server_exports = {};
|
|
39
|
+
__export(server_exports, {
|
|
40
|
+
BaseNotificationChannel: () => import_base_notification_channel.BaseNotificationChannel,
|
|
41
|
+
default: () => import_plugin.default
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(server_exports);
|
|
44
|
+
var import_base_notification_channel = require("./base-notification-channel");
|
|
45
|
+
var import_plugin = __toESM(require("./plugin"));
|
|
46
|
+
__reExport(server_exports, require("./types"), module.exports);
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
BaseNotificationChannel,
|
|
50
|
+
...require("./types")
|
|
51
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
import PluginNotificationManagerServer from './plugin';
|
|
10
|
+
import type { RegisterServerTypeFnParams, SendOptions, WriteLogOptions } from './types';
|
|
11
|
+
export declare class NotificationManager implements NotificationManager {
|
|
12
|
+
private plugin;
|
|
13
|
+
private notificationTypes;
|
|
14
|
+
constructor({ plugin }: {
|
|
15
|
+
plugin: PluginNotificationManagerServer;
|
|
16
|
+
});
|
|
17
|
+
registerType({ type, Channel }: RegisterServerTypeFnParams): void;
|
|
18
|
+
createSendingRecord: (options: WriteLogOptions) => Promise<any>;
|
|
19
|
+
parseReceivers(receiverType: any, receiversConfig: any, processor: any, node: any): Promise<unknown[]>;
|
|
20
|
+
send(params: SendOptions): Promise<any>;
|
|
21
|
+
}
|
|
22
|
+
export default NotificationManager;
|
|
@@ -0,0 +1,102 @@
|
|
|
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 manager_exports = {};
|
|
28
|
+
__export(manager_exports, {
|
|
29
|
+
NotificationManager: () => NotificationManager,
|
|
30
|
+
default: () => manager_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(manager_exports);
|
|
33
|
+
var import_utils = require("@nocobase/utils");
|
|
34
|
+
var import_constant = require("../constant");
|
|
35
|
+
class NotificationManager {
|
|
36
|
+
plugin;
|
|
37
|
+
notificationTypes = new import_utils.Registry();
|
|
38
|
+
constructor({ plugin }) {
|
|
39
|
+
this.plugin = plugin;
|
|
40
|
+
}
|
|
41
|
+
registerType({ type, Channel }) {
|
|
42
|
+
this.notificationTypes.register(type, { Channel });
|
|
43
|
+
}
|
|
44
|
+
createSendingRecord = async (options) => {
|
|
45
|
+
const logsRepo = this.plugin.app.db.getRepository(import_constant.COLLECTION_NAME.logs);
|
|
46
|
+
return logsRepo.create({ values: options });
|
|
47
|
+
};
|
|
48
|
+
async parseReceivers(receiverType, receiversConfig, processor, node) {
|
|
49
|
+
const configAssignees = processor.getParsedValue(node.config.assignees ?? [], node.id).flat().filter(Boolean);
|
|
50
|
+
const assignees = /* @__PURE__ */ new Set();
|
|
51
|
+
const UserRepo = processor.options.plugin.app.db.getRepository("users");
|
|
52
|
+
for (const item of configAssignees) {
|
|
53
|
+
if (typeof item === "object") {
|
|
54
|
+
const result = await UserRepo.find({
|
|
55
|
+
...item,
|
|
56
|
+
fields: ["id"],
|
|
57
|
+
transaction: processor.transaction
|
|
58
|
+
});
|
|
59
|
+
result.forEach((item2) => assignees.add(item2.id));
|
|
60
|
+
} else {
|
|
61
|
+
assignees.add(item);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return [...assignees];
|
|
65
|
+
}
|
|
66
|
+
async send(params) {
|
|
67
|
+
this.plugin.logger.info("receive sending message request", params);
|
|
68
|
+
const channelsRepo = this.plugin.app.db.getRepository(import_constant.COLLECTION_NAME.channels);
|
|
69
|
+
const logData = {
|
|
70
|
+
triggerFrom: params.triggerFrom,
|
|
71
|
+
channelName: params.channelName,
|
|
72
|
+
message: params.message
|
|
73
|
+
};
|
|
74
|
+
try {
|
|
75
|
+
const channel = await channelsRepo.findOne({ filterByTk: params.channelName });
|
|
76
|
+
if (channel) {
|
|
77
|
+
const Channel = this.notificationTypes.get(channel.notificationType).Channel;
|
|
78
|
+
const instance = new Channel(this.plugin.app);
|
|
79
|
+
logData.channelTitle = channel.title;
|
|
80
|
+
logData.notificationType = channel.notificationType;
|
|
81
|
+
const result = await instance.send({ message: params.message, channel });
|
|
82
|
+
logData.status = result.status;
|
|
83
|
+
logData.reason = result.reason;
|
|
84
|
+
} else {
|
|
85
|
+
logData.status = "failure";
|
|
86
|
+
logData.reason = "channel not found";
|
|
87
|
+
}
|
|
88
|
+
this.createSendingRecord(logData);
|
|
89
|
+
return logData;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
logData.status = "failure";
|
|
92
|
+
logData.reason = error.reason;
|
|
93
|
+
this.createSendingRecord(logData);
|
|
94
|
+
return logData;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
var manager_default = NotificationManager;
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
NotificationManager
|
|
102
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
import type { Logger } from '@nocobase/logger';
|
|
10
|
+
import { Plugin } from '@nocobase/server';
|
|
11
|
+
import { RegisterServerTypeFnParams, SendOptions } from './types';
|
|
12
|
+
export declare class PluginNotificationManagerServer extends Plugin {
|
|
13
|
+
private manager;
|
|
14
|
+
logger: Logger;
|
|
15
|
+
registerChannelType(params: RegisterServerTypeFnParams): void;
|
|
16
|
+
send(options: SendOptions): Promise<any>;
|
|
17
|
+
afterAdd(): Promise<void>;
|
|
18
|
+
beforeLoad(): Promise<void>;
|
|
19
|
+
load(): Promise<void>;
|
|
20
|
+
install(): Promise<void>;
|
|
21
|
+
afterEnable(): Promise<void>;
|
|
22
|
+
afterDisable(): Promise<void>;
|
|
23
|
+
remove(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export default PluginNotificationManagerServer;
|
|
@@ -0,0 +1,93 @@
|
|
|
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 __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var plugin_exports = {};
|
|
38
|
+
__export(plugin_exports, {
|
|
39
|
+
PluginNotificationManagerServer: () => PluginNotificationManagerServer,
|
|
40
|
+
default: () => plugin_default
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
43
|
+
var import_server = require("@nocobase/server");
|
|
44
|
+
var import_manager = __toESM(require("./manager"));
|
|
45
|
+
class PluginNotificationManagerServer extends import_server.Plugin {
|
|
46
|
+
manager;
|
|
47
|
+
logger;
|
|
48
|
+
registerChannelType(params) {
|
|
49
|
+
this.manager.registerType(params);
|
|
50
|
+
}
|
|
51
|
+
async send(options) {
|
|
52
|
+
return await this.manager.send(options);
|
|
53
|
+
}
|
|
54
|
+
async afterAdd() {
|
|
55
|
+
this.logger = this.createLogger({
|
|
56
|
+
dirname: "notification-manager",
|
|
57
|
+
filename: "%DATE%.log",
|
|
58
|
+
transports: ["dailyRotateFile"]
|
|
59
|
+
});
|
|
60
|
+
this.manager = new import_manager.default({ plugin: this });
|
|
61
|
+
}
|
|
62
|
+
async beforeLoad() {
|
|
63
|
+
this.app.resourceManager.registerActionHandler("messages:send", async (ctx, next) => {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
const sendOptions = (_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values;
|
|
66
|
+
this.manager.send(sendOptions);
|
|
67
|
+
next();
|
|
68
|
+
});
|
|
69
|
+
this.app.acl.registerSnippet({
|
|
70
|
+
name: "pm.notification.channels",
|
|
71
|
+
actions: ["notificationChannels:*"]
|
|
72
|
+
});
|
|
73
|
+
this.app.acl.registerSnippet({
|
|
74
|
+
name: "pm.notification.logs",
|
|
75
|
+
actions: ["notificationSendLogs:*"]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
async load() {
|
|
79
|
+
}
|
|
80
|
+
async install() {
|
|
81
|
+
}
|
|
82
|
+
async afterEnable() {
|
|
83
|
+
}
|
|
84
|
+
async afterDisable() {
|
|
85
|
+
}
|
|
86
|
+
async remove() {
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
var plugin_default = PluginNotificationManagerServer;
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
PluginNotificationManagerServer
|
|
93
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
import { Application } from '@nocobase/server';
|
|
10
|
+
import { BaseNotificationChannel } from './base-notification-channel';
|
|
11
|
+
/**
|
|
12
|
+
* This file is part of the NocoBase (R) project.
|
|
13
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
14
|
+
* Authors: NocoBase Team.
|
|
15
|
+
*
|
|
16
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
17
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
18
|
+
*/
|
|
19
|
+
export interface ChannelOptions {
|
|
20
|
+
name: string;
|
|
21
|
+
options: Record<string, any>;
|
|
22
|
+
notificationType: string;
|
|
23
|
+
}
|
|
24
|
+
export type WriteLogOptions = {
|
|
25
|
+
status: 'success' | 'failure';
|
|
26
|
+
message: Record<string, any>;
|
|
27
|
+
triggerFrom: string;
|
|
28
|
+
reason?: string;
|
|
29
|
+
channelName: string;
|
|
30
|
+
channelTitle: string;
|
|
31
|
+
};
|
|
32
|
+
export type SendFnType<Message> = (args: {
|
|
33
|
+
message: Message;
|
|
34
|
+
channel: ChannelOptions;
|
|
35
|
+
}) => Promise<{
|
|
36
|
+
message: Message;
|
|
37
|
+
status: 'success' | 'fail';
|
|
38
|
+
reason?: string;
|
|
39
|
+
}>;
|
|
40
|
+
export interface SendOptions {
|
|
41
|
+
channelName: string;
|
|
42
|
+
message: Record<string, any>;
|
|
43
|
+
triggerFrom: string;
|
|
44
|
+
}
|
|
45
|
+
export type NotificationChannelConstructor = new (app: Application) => BaseNotificationChannel;
|
|
46
|
+
export type RegisterServerTypeFnParams = {
|
|
47
|
+
type: string;
|
|
48
|
+
Channel: NotificationChannelConstructor;
|
|
49
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var types_exports = {};
|
|
24
|
+
module.exports = __toCommonJS(types_exports);
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nocobase/plugin-notification-manager",
|
|
3
|
+
"displayName": "Notification manager",
|
|
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
|
+
"displayName.zh-CN": "通知管理",
|
|
6
|
+
"description.zh-CN": "提供统一的管理服务,涵盖渠道配置、日志记录等功能,支持多种通知渠道的配置,包括站内信和电子邮件等。",
|
|
7
|
+
"version": "1.4.0-alpha.20240928155737",
|
|
8
|
+
"main": "dist/server/index.js",
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@ant-design/icons": "5.x",
|
|
11
|
+
"@formily/antd-v5": "^1.x",
|
|
12
|
+
"@formily/react": "2.x",
|
|
13
|
+
"@formily/shared": "2.x",
|
|
14
|
+
"@types/cron": "^2.0.1",
|
|
15
|
+
"antd": "5.x",
|
|
16
|
+
"cron": "^2.3.1",
|
|
17
|
+
"react": "^18.2.0",
|
|
18
|
+
"react-i18next": "^11.15.1"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@nocobase/actions": "1.x",
|
|
22
|
+
"@nocobase/client": "1.x",
|
|
23
|
+
"@nocobase/database": "1.x",
|
|
24
|
+
"@nocobase/plugin-workflow": ">=0.17.0-alpha.3",
|
|
25
|
+
"@nocobase/server": "1.x",
|
|
26
|
+
"@nocobase/test": "1.x",
|
|
27
|
+
"@nocobase/utils": "1.x"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"Notification"
|
|
31
|
+
],
|
|
32
|
+
"gitHead": "f2765665126f5e9b5ae01f9ca6e8a151916554b4"
|
|
33
|
+
}
|
package/server.d.ts
ADDED
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/server/index.js');
|