@nocobase/plugin-notifications 0.5.0-alpha.37 → 0.7.0-alpha.2
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 +201 -21
- package/esm/collections/notification_logs.d.ts +3 -0
- package/esm/collections/notification_logs.js +24 -0
- package/esm/collections/notification_logs.js.map +1 -0
- package/esm/collections/notification_services.d.ts +3 -0
- package/esm/collections/notification_services.js +24 -0
- package/esm/collections/notification_services.js.map +1 -0
- package/esm/collections/notifications.d.ts +3 -0
- package/esm/collections/notifications.js +41 -0
- package/esm/collections/notifications.js.map +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +2 -0
- package/esm/index.js.map +1 -0
- package/esm/models/Notification.d.ts +9 -0
- package/esm/models/Notification.js +86 -0
- package/esm/models/Notification.js.map +1 -0
- package/esm/models/NotificationLog.d.ts +3 -0
- package/esm/models/NotificationLog.js +4 -0
- package/esm/models/NotificationLog.js.map +1 -0
- package/esm/models/NotificationService.d.ts +9 -0
- package/esm/models/NotificationService.js +32 -0
- package/esm/models/NotificationService.js.map +1 -0
- package/esm/models/index.d.ts +3 -0
- package/esm/models/index.js +4 -0
- package/esm/models/index.js.map +1 -0
- package/esm/server.d.ts +5 -0
- package/esm/server.js +24 -0
- package/esm/server.js.map +1 -0
- package/lib/collections/notification_logs.d.ts +2 -2
- package/lib/collections/notification_logs.js +23 -33
- package/lib/collections/notification_logs.js.map +1 -1
- package/lib/collections/notification_services.d.ts +2 -2
- package/lib/collections/notification_services.js +23 -33
- package/lib/collections/notification_services.js.map +1 -1
- package/lib/collections/notifications.d.ts +2 -2
- package/lib/collections/notifications.js +40 -47
- package/lib/collections/notifications.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +9 -0
- package/lib/index.js.map +1 -0
- package/lib/models/Notification.d.ts +3 -1
- package/lib/models/Notification.js +83 -149
- package/lib/models/Notification.js.map +1 -1
- package/lib/models/NotificationLog.js +4 -21
- package/lib/models/NotificationLog.js.map +1 -1
- package/lib/models/NotificationService.d.ts +4 -1
- package/lib/models/NotificationService.js +27 -76
- package/lib/models/NotificationService.js.map +1 -1
- package/lib/models/index.js +11 -36
- package/lib/models/index.js.map +1 -1
- package/lib/server.d.ts +5 -3
- package/lib/server.js +25 -103
- package/lib/server.js.map +1 -1
- package/package.json +19 -4
- package/tsconfig.build.json +9 -0
- package/lib/collections/notification_logs.d.ts.map +0 -1
- package/lib/collections/notification_services.d.ts.map +0 -1
- package/lib/collections/notifications.d.ts.map +0 -1
- package/lib/models/Notification.d.ts.map +0 -1
- package/lib/models/NotificationLog.d.ts.map +0 -1
- package/lib/models/NotificationService.d.ts.map +0 -1
- package/lib/models/index.d.ts.map +0 -1
- package/lib/server.d.ts.map +0 -1
|
@@ -1,88 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return data;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
|
-
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
16
|
-
function adopt(value) {
|
|
17
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
18
|
-
resolve(value);
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
9
|
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
23
|
-
function fulfilled(value) {
|
|
24
|
-
try {
|
|
25
|
-
step(generator.next(value));
|
|
26
|
-
} catch (e) {
|
|
27
|
-
reject(e);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function rejected(value) {
|
|
32
|
-
try {
|
|
33
|
-
step(generator["throw"](value));
|
|
34
|
-
} catch (e) {
|
|
35
|
-
reject(e);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function step(result) {
|
|
40
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
44
|
-
});
|
|
45
10
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return mod && mod.__esModule ? mod : {
|
|
49
|
-
"default": mod
|
|
50
|
-
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
13
|
};
|
|
52
|
-
|
|
53
|
-
Object.defineProperty(exports, "__esModule", {
|
|
54
|
-
value: true
|
|
55
|
-
});
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
15
|
exports.NotificationService = void 0;
|
|
57
|
-
|
|
58
16
|
const database_1 = require("@nocobase/database");
|
|
59
|
-
|
|
60
17
|
const nodemailer_1 = __importDefault(require("nodemailer"));
|
|
61
|
-
|
|
62
18
|
class NotificationService extends database_1.Model {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this._transporter = null;
|
|
22
|
+
}
|
|
23
|
+
get transporter() {
|
|
24
|
+
if (this._transporter) {
|
|
25
|
+
return this._transporter;
|
|
26
|
+
}
|
|
27
|
+
return this._transporter = NotificationService.createTransport(this.options);
|
|
28
|
+
}
|
|
29
|
+
send(options) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const { from } = this.options;
|
|
32
|
+
const mailOptions = Object.assign({ from }, options);
|
|
33
|
+
return this.transporter.sendMail(mailOptions);
|
|
34
|
+
});
|
|
66
35
|
}
|
|
67
|
-
|
|
68
|
-
return this._transporter = NotificationService.createTransport(this.options);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
send(options) {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
const from = this.options.from;
|
|
74
|
-
const mailOptions = Object.assign({
|
|
75
|
-
from
|
|
76
|
-
}, options);
|
|
77
|
-
console.log({
|
|
78
|
-
mailOptions
|
|
79
|
-
});
|
|
80
|
-
return this.transporter.sendMail(mailOptions);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
36
|
}
|
|
85
|
-
|
|
86
37
|
exports.NotificationService = NotificationService;
|
|
87
38
|
NotificationService.createTransport = nodemailer_1.default.createTransport;
|
|
88
|
-
//# sourceMappingURL=NotificationService.js.map
|
|
39
|
+
//# sourceMappingURL=NotificationService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["models/NotificationService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iDAA2C;AAC3C,4DAAoC;AAEpC,MAAa,mBAAoB,SAAQ,gBAAK;
|
|
1
|
+
{"version":3,"file":"NotificationService.js","sourceRoot":"","sources":["../../src/models/NotificationService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iDAA2C;AAC3C,4DAAoC;AAEpC,MAAa,mBAAoB,SAAQ,gBAAK;IAA9C;;QAKU,iBAAY,GAAG,IAAI,CAAC;IAiB9B,CAAC;IAfC,IAAI,WAAW;QACb,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,OAAO,IAAI,CAAC,YAAY,CAAC;SAC1B;QACD,OAAO,IAAI,CAAC,YAAY,GAAG,mBAAmB,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/E,CAAC;IAEK,IAAI,CAAC,OAAO;;YAChB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;YAC9B,MAAM,WAAW,mBACf,IAAI,IACD,OAAO,CACX,CAAC;YACF,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAChD,CAAC;KAAA;;AArBH,kDAsBC;AAnBQ,mCAAe,GAAG,oBAAU,CAAC,eAAe,CAAC","sourcesContent":["import { Model } from '@nocobase/database';\nimport nodemailer from 'nodemailer';\n\nexport class NotificationService extends Model {\n [key: string]: any;\n\n static createTransport = nodemailer.createTransport;\n\n private _transporter = null;\n\n get transporter() {\n if (this._transporter) {\n return this._transporter;\n }\n return this._transporter = NotificationService.createTransport(this.options);\n }\n\n async send(options) {\n const { from } = this.options;\n const mailOptions = {\n from,\n ...options,\n };\n return this.transporter.sendMail(mailOptions);\n }\n}\n"]}
|
package/lib/models/index.js
CHANGED
|
@@ -1,41 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
|
-
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
Object.defineProperty(o, k2, {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function get() {
|
|
20
|
-
return m[k];
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
} : function (o, m, k, k2) {
|
|
24
|
-
if (k2 === undefined) k2 = k;
|
|
25
|
-
o[k2] = m[k];
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
29
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
11
|
};
|
|
31
|
-
|
|
32
|
-
Object.defineProperty(exports, "__esModule", {
|
|
33
|
-
value: true
|
|
34
|
-
});
|
|
35
|
-
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
13
|
__exportStar(require("./Notification"), exports);
|
|
37
|
-
|
|
38
14
|
__exportStar(require("./NotificationLog"), exports);
|
|
39
|
-
|
|
40
15
|
__exportStar(require("./NotificationService"), exports);
|
|
41
|
-
//# sourceMappingURL=index.js.map
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
package/lib/models/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA+B;AAC/B,oDAAkC;AAClC,wDAAsC","
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA+B;AAC/B,oDAAkC;AAClC,wDAAsC","sourcesContent":["export * from './Notification';\nexport * from './NotificationLog';\nexport * from './NotificationService';\n"]}
|
package/lib/server.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Plugin } from '@nocobase/server';
|
|
2
|
+
export default class PluginNotifications extends Plugin {
|
|
3
|
+
load(): Promise<void>;
|
|
4
|
+
getName(): string;
|
|
5
|
+
}
|
package/lib/server.js
CHANGED
|
@@ -1,108 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return data;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
|
-
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
Object.defineProperty(o, k2, {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function get() {
|
|
20
|
-
return m[k];
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
} : function (o, m, k, k2) {
|
|
24
|
-
if (k2 === undefined) k2 = k;
|
|
25
|
-
o[k2] = m[k];
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
var __setModuleDefault = void 0 && (void 0).__setModuleDefault || (Object.create ? function (o, v) {
|
|
29
|
-
Object.defineProperty(o, "default", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
value: v
|
|
32
|
-
});
|
|
33
|
-
} : function (o, v) {
|
|
34
|
-
o["default"] = v;
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
var __importStar = void 0 && (void 0).__importStar || function (mod) {
|
|
38
|
-
if (mod && mod.__esModule) return mod;
|
|
39
|
-
var result = {};
|
|
40
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
41
|
-
|
|
42
|
-
__setModuleDefault(result, mod);
|
|
43
|
-
|
|
44
|
-
return result;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
48
|
-
function adopt(value) {
|
|
49
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
50
|
-
resolve(value);
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
51
9
|
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
55
|
-
function fulfilled(value) {
|
|
56
|
-
try {
|
|
57
|
-
step(generator.next(value));
|
|
58
|
-
} catch (e) {
|
|
59
|
-
reject(e);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function rejected(value) {
|
|
64
|
-
try {
|
|
65
|
-
step(generator["throw"](value));
|
|
66
|
-
} catch (e) {
|
|
67
|
-
reject(e);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function step(result) {
|
|
72
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
76
|
-
});
|
|
77
10
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return mod && mod.__esModule ? mod : {
|
|
81
|
-
"default": mod
|
|
82
|
-
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
83
13
|
};
|
|
84
|
-
|
|
85
|
-
Object.defineProperty(exports, "__esModule", {
|
|
86
|
-
value: true
|
|
87
|
-
});
|
|
88
|
-
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
89
15
|
const path_1 = __importDefault(require("path"));
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
};
|
|
108
|
-
//# sourceMappingURL=server.js.map
|
|
16
|
+
const server_1 = require("@nocobase/server");
|
|
17
|
+
class PluginNotifications extends server_1.Plugin {
|
|
18
|
+
load() {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
yield this.app.db.import({
|
|
21
|
+
directory: path_1.default.resolve(__dirname, 'collections'),
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
getName() {
|
|
26
|
+
return this.getPackageName(__dirname);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = PluginNotifications;
|
|
30
|
+
//# sourceMappingURL=server.js.map
|
package/lib/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,6CAA0C;AAE1C,MAAqB,mBAAoB,SAAQ,eAAM;IAC/C,IAAI;;YACR,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC;gBACvB,SAAS,EAAE,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC;aAClD,CAAC,CAAC;QACL,CAAC;KAAA;IAED,OAAO;QACL,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;CACF;AAVD,sCAUC","sourcesContent":["import path from 'path';\nimport { Plugin } from '@nocobase/server';\n\nexport default class PluginNotifications extends Plugin {\n async load() {\n await this.app.db.import({\n directory: path.resolve(__dirname, 'collections'),\n });\n }\n\n getName(): string {\n return this.getPackageName(__dirname);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-notifications",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-alpha.2",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"licenses": [
|
|
7
|
+
{
|
|
8
|
+
"type": "Apache-2.0",
|
|
9
|
+
"url": "http://www.apache.org/licenses/LICENSE-2.0"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "rimraf -rf lib esm dist && npm run build:cjs && npm run build:esm",
|
|
14
|
+
"build:cjs": "tsc --project tsconfig.build.json",
|
|
15
|
+
"build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm"
|
|
16
|
+
},
|
|
6
17
|
"dependencies": {
|
|
7
|
-
"@nocobase/server": "^0.5.0-alpha.37",
|
|
8
18
|
"nodemailer": "^6.6.1"
|
|
9
19
|
},
|
|
10
|
-
"
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@nocobase/test": "0.7.0-alpha.2",
|
|
22
|
+
"@types/nodemailer": "6.4.4",
|
|
23
|
+
"nodemailer-mock": "^1.5.11"
|
|
24
|
+
},
|
|
25
|
+
"gitHead": "0e0e99ef79c0b25bb0b45ecaa477c049cb16afee"
|
|
11
26
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["collections/notification_logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;;AAElD,wBAqBkB","file":"notification_logs.d.ts","sourcesContent":["import { TableOptions } from '@nocobase/database';\n\nexport default {\n name: 'notification_logs',\n model: 'NotificationLog',\n title: '通知日志',\n fields: [\n {\n title: '接收人',\n type: 'json',\n name: 'receiver',\n },\n {\n title: '状态',\n type: 'string',\n name: 'state',\n },\n {\n title: '详情',\n type: 'json',\n name: 'response',\n },\n ]\n} as TableOptions;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["collections/notification_services.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;;AAElD,wBAqBkB","file":"notification_services.d.ts","sourcesContent":["import { TableOptions } from '@nocobase/database';\n\nexport default {\n name: 'notification_services',\n model: 'NotificationService',\n title: '通知服务',\n fields: [\n {\n title: '类型',\n type: 'string',\n name: 'type',\n },\n {\n title: '服务名称',\n type: 'string',\n name: 'title',\n },\n {\n title: '配置信息',\n type: 'json',\n name: 'options',\n },\n ]\n} as TableOptions;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["collections/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;;AAElD,wBAsCkB","file":"notifications.d.ts","sourcesContent":["import { TableOptions } from '@nocobase/database';\n\nexport default {\n name: 'notifications',\n model: 'Notification',\n title: '通知',\n fields: [\n {\n type: 'uid',\n name: 'name',\n prefix: 'n_',\n },\n {\n title: '主题',\n type: 'string',\n name: 'subject',\n },\n {\n title: '内容',\n type: 'text',\n name: 'body',\n },\n {\n title: '接收人配置',\n type: 'json',\n name: 'receiver_options',\n },\n {\n title: '发送服务',\n type: 'belongsTo',\n name: 'service',\n target: 'notification_services',\n },\n {\n title: '日志',\n type: 'hasMany',\n name: 'logs',\n target: 'notification_logs',\n },\n ]\n} as TableOptions;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["models/Notification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAI3C,qBAAa,YAAa,SAAQ,KAAK;IAE/B,qBAAqB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAevC,IAAI,CAAC,OAAO,GAAE,GAAQ;IAqC5B,UAAU;IAIV,OAAO,CAAC,IAAI,KAAA;CAKb","file":"Notification.d.ts","sourcesContent":["import { Model } from '@nocobase/database';\nimport { NotificationService } from './NotificationService';\nimport _ from 'lodash';\n\nexport class Notification extends Model {\n\n async getReceiversByOptions(): Promise<any[]> {\n const { data, fromTable, filter, dataField } = this.receiver_options;\n let receivers = [];\n if (data) {\n receivers = Array.isArray(data) ? data : [data];\n } else if (fromTable) {\n const M = this.database.getModel(fromTable);\n const rows = await M.findAll(M.parseApiJson2({\n filter,\n }));\n receivers = rows.map(row => row[dataField]);\n }\n return receivers;\n }\n\n async send(options: any = {}) {\n if (!this.service) {\n this.service = await this.getService();\n }\n const receivers = await this.getReceiversByOptions();\n let { to } = options;\n if (to) {\n to = Array.isArray(to) ? to : [to];\n receivers.push(...to);\n }\n console.log(receivers)\n for (const receiver of receivers) {\n try {\n const response = await (this.service as NotificationService).send({\n to: receiver,\n subject: this.getSubject(),\n html: this.getBody(options),\n });\n await this.createLog({\n receiver,\n state: 'success',\n response,\n });\n await new Promise((resolve) => {\n setTimeout(resolve, 100);\n });\n } catch (error) {\n console.error(error);\n await this.createLog({\n receiver,\n state: 'fail',\n response: {},\n });\n }\n }\n }\n\n getSubject() {\n return this.subject;\n }\n\n getBody(data) {\n const compiled = _.template(this.body)\n const body = compiled(data);\n return body;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["models/NotificationLog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,qBAAa,eAAgB,SAAQ,KAAK;CAEzC","file":"NotificationLog.d.ts","sourcesContent":["import { Model } from '@nocobase/database';\n\nexport class NotificationLog extends Model {\n\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["models/NotificationService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAG3C,qBAAa,mBAAoB,SAAQ,KAAK;IAE5C,MAAM,CAAC,eAAe,MAA8B;IAEpD,IAAI,WAAW,QAKd;IAEK,IAAI,CAAC,OAAO,KAAA;CASnB","file":"NotificationService.d.ts","sourcesContent":["import { Model } from '@nocobase/database';\nimport nodemailer from 'nodemailer';\n\nexport class NotificationService extends Model {\n\n static createTransport = nodemailer.createTransport;\n\n get transporter() {\n if (this._transporter) {\n return this._transporter;\n }\n return this._transporter = NotificationService.createTransport(this.options);\n }\n\n async send(options) {\n const { from } = this.options;\n const mailOptions = {\n from,\n ...options,\n };\n console.log({ mailOptions });\n return this.transporter.sendMail(mailOptions);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["models/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC","file":"index.d.ts","sourcesContent":["export * from './Notification';\nexport * from './NotificationLog';\nexport * from './NotificationService';\n"]}
|
package/lib/server.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;;AAKjD,wBAOkB","file":"server.d.ts","sourcesContent":["import path from 'path';\nimport Database, { registerModels } from '@nocobase/database';\nimport { PluginOptions } from '@nocobase/server';\nimport * as models from './models';\n\nregisterModels(models);\n\nexport default {\n name: 'notifications',\n async load() {\n this.app.db.import({\n directory: path.resolve(__dirname, 'collections'),\n });\n }\n} as PluginOptions\n"]}
|