@things-factory/notification 4.3.609 → 4.3.671

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/notification",
3
- "version": "4.3.609",
3
+ "version": "4.3.671",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -26,14 +26,14 @@
26
26
  "@material/mwc-button": "^0.25.3",
27
27
  "@material/mwc-formfield": "^0.25.3",
28
28
  "@material/mwc-switch": "^0.25.3",
29
- "@things-factory/auth-base": "^4.3.591",
30
- "@things-factory/i18n-base": "^4.3.591",
31
- "@things-factory/layout-base": "^4.3.591",
32
- "@things-factory/setting-base": "^4.3.609",
33
- "@things-factory/shell": "^4.3.591",
29
+ "@things-factory/auth-base": "^4.3.671",
30
+ "@things-factory/i18n-base": "^4.3.671",
31
+ "@things-factory/layout-base": "^4.3.671",
32
+ "@things-factory/setting-base": "^4.3.671",
33
+ "@things-factory/shell": "^4.3.671",
34
34
  "clipboard": "^2.0.6",
35
35
  "firebase": "^8.0.1",
36
36
  "firebase-admin": "^9.4.1"
37
37
  },
38
- "gitHead": "9442aa55ff704d8adf03b277522aa17a21fb6d3a"
38
+ "gitHead": "ef524cb207378186ec71917d9a8546363d4300b2"
39
39
  }
@@ -1,182 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.notify = exports.unregister = exports.register = exports.sendNotification = exports.getConfig = void 0;
7
- const node_fetch_1 = __importDefault(require("node-fetch"));
8
- const env_1 = require("@things-factory/env");
9
- const admin = require('firebase-admin');
10
- const debug = require('debug')('things-factory:notification:fcm');
11
- const fcmconf = env_1.config.get('notification') || {};
12
- const { fcm, vapidKey } = fcmconf;
13
- const { serviceAccount, appConfig, serverKey } = fcm || {};
14
- const { subject, publicKey, privateKey } = vapidKey || {};
15
- if (serviceAccount) {
16
- try {
17
- admin.initializeApp({
18
- credential: admin.credential.cert(serviceAccount)
19
- });
20
- var messaging = admin.messaging();
21
- }
22
- catch (err) {
23
- env_1.logger.error('incorrect notification configuration');
24
- env_1.logger.error(err);
25
- }
26
- }
27
- function getConfig() {
28
- return messaging
29
- ? {
30
- appConfig,
31
- vapidPublicKey: publicKey
32
- }
33
- : {};
34
- }
35
- exports.getConfig = getConfig;
36
- /**
37
- * sendNotification
38
- *
39
- * @param receiver user.id who will receive notification
40
- * @param message message object to be sent
41
- */
42
- async function sendNotification({ receivers, message }) {
43
- if (!messaging) {
44
- return;
45
- }
46
- notify(Object.assign({ receivers }, message));
47
- }
48
- exports.sendNotification = sendNotification;
49
- async function register(user, { subscription }) {
50
- if (!messaging || !subscription || !user) {
51
- return false;
52
- }
53
- try {
54
- var notification_key = await getDeviceGroup(user.id);
55
- if (!notification_key) {
56
- await postDeviceGroup({
57
- operation: 'create',
58
- notification_key_name: user.id,
59
- registration_ids: [subscription]
60
- });
61
- }
62
- else {
63
- await postDeviceGroup({
64
- operation: 'add',
65
- notification_key_name: user.id,
66
- notification_key,
67
- registration_ids: [subscription]
68
- });
69
- }
70
- return true;
71
- }
72
- catch (err) {
73
- return;
74
- }
75
- }
76
- exports.register = register;
77
- async function unregister(user, { subscription }) {
78
- if (!messaging || !subscription || !user) {
79
- return false;
80
- }
81
- try {
82
- var notification_key = await getDeviceGroup(user.id);
83
- if (notification_key) {
84
- await postDeviceGroup({
85
- operation: 'remove',
86
- notification_key_name: user.id,
87
- notification_key,
88
- registration_ids: [subscription]
89
- });
90
- }
91
- return true;
92
- }
93
- catch (err) {
94
- return;
95
- }
96
- }
97
- exports.unregister = unregister;
98
- async function notify({ receivers, privileges, tokens, topic, title, body, data, image, actions }) {
99
- if (!messaging) {
100
- return;
101
- }
102
- // Caution: non-string attributes are not allowed in FCM payload validation
103
- var notification = {
104
- title: title || '',
105
- body: body || '',
106
- image: image || ''
107
- };
108
- if (tokens && tokens instanceof Array && tokens.length > 0) {
109
- if (tokens.length > 1) {
110
- let response = await messaging.sendMulticast({
111
- notification,
112
- data,
113
- tokens
114
- });
115
- debug('send-all', response);
116
- }
117
- else {
118
- let token = tokens[0];
119
- let response = await messaging.send({
120
- notification,
121
- data,
122
- token
123
- });
124
- debug('send', response);
125
- }
126
- }
127
- if (topic) {
128
- debug('send to topic', topic);
129
- let response = await messaging.send({
130
- notification,
131
- data,
132
- topic
133
- });
134
- debug('send-topic', response);
135
- }
136
- if (receivers && receivers instanceof Array) {
137
- debug('send to receivers', receivers);
138
- for (let receiver of receivers) {
139
- var notification_key = await getDeviceGroup(receiver);
140
- if (notification_key) {
141
- await messaging.sendToDeviceGroup(notification_key, {
142
- notification,
143
- data
144
- });
145
- }
146
- }
147
- }
148
- }
149
- exports.notify = notify;
150
- async function postDeviceGroup(body) {
151
- var response = await (0, node_fetch_1.default)('https://fcm.googleapis.com/fcm/notification', {
152
- method: 'POST',
153
- headers: {
154
- 'Content-Type': 'application/json',
155
- Authorization: `key=${serverKey}`,
156
- project_id: appConfig.messagingSenderId
157
- },
158
- body: JSON.stringify(body)
159
- });
160
- if (response.ok) {
161
- const { notification_key } = await response.json();
162
- return notification_key;
163
- }
164
- else {
165
- debug('postDeviceGroup-notok', response.status, await response.text());
166
- }
167
- }
168
- async function getDeviceGroup(notificationKeyName) {
169
- var response = await (0, node_fetch_1.default)(`https://fcm.googleapis.com/fcm/notification?notification_key_name=${notificationKeyName}`, {
170
- method: 'GET',
171
- headers: {
172
- 'Content-Type': 'application/json',
173
- Authorization: `key=${serverKey}`,
174
- project_id: appConfig.messagingSenderId
175
- }
176
- });
177
- if (response.ok) {
178
- const { notification_key } = await response.json();
179
- return notification_key;
180
- }
181
- }
182
- //# sourceMappingURL=fcm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fcm.js","sourceRoot":"","sources":["../../server/controllers/fcm.ts"],"names":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@@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./fcm"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAqB"}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./service"), exports);
18
- __exportStar(require("./migrations"), exports);
19
- __exportStar(require("./middlewares"), exports);
20
- __exportStar(require("./controllers"), exports);
21
- require("./routes");
22
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,+CAA4B;AAC5B,gDAA6B;AAC7B,gDAA6B;AAE7B,oBAAiB"}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initMiddlewares = void 0;
4
- const notification_middleware_1 = require("./notification-middleware");
5
- function initMiddlewares(app) {
6
- app.use(notification_middleware_1.notificationMiddleware);
7
- }
8
- exports.initMiddlewares = initMiddlewares;
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/middlewares/index.ts"],"names":[],"mappings":";;;AAAA,uEAAkE;AAElE,SAAgB,eAAe,CAAC,GAAG;IACjC,GAAG,CAAC,GAAG,CAAC,gDAAsB,CAAC,CAAA;AACjC,CAAC;AAFD,0CAEC"}
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.notificationMiddleware = void 0;
4
- const shell_1 = require("@things-factory/shell");
5
- const fcm_1 = require("../controllers/fcm");
6
- const debug = require('debug')('things-factory:notification:notification-middleware');
7
- function notifier(context) {
8
- return async function ({ receivers, privileges, tokens, topic, subject = 'info', title, body,
9
- // data,
10
- image, url, actions, timestamp = new Date(), mode = 'background' }) {
11
- const { domain, user } = context.state;
12
- try {
13
- if (mode === 'background') {
14
- /* for send webpush notification message */
15
- await (0, fcm_1.notify)({
16
- receivers,
17
- privileges,
18
- tokens,
19
- topic,
20
- title,
21
- body,
22
- data: {
23
- url,
24
- timestamp
25
- },
26
- image,
27
- actions
28
- });
29
- }
30
- else {
31
- /* for send publish notification to clients */
32
- // TODO CONFIRM data format
33
- await shell_1.pubsub.publish('notification', {
34
- notification: {
35
- domain,
36
- subject,
37
- title,
38
- body,
39
- image,
40
- url,
41
- timestamp
42
- }
43
- });
44
- }
45
- }
46
- catch (err) {
47
- debug(err);
48
- }
49
- };
50
- }
51
- async function notificationMiddleware(context, next) {
52
- if (!context.state.notify) {
53
- context.state.notify = notifier(context);
54
- }
55
- await next();
56
- }
57
- exports.notificationMiddleware = notificationMiddleware;
58
- //# sourceMappingURL=notification-middleware.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notification-middleware.js","sourceRoot":"","sources":["../../server/middlewares/notification-middleware.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAG9C,4CAA2C;AAE3C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,qDAAqD,CAAC,CAAA;AAErF,SAAS,QAAQ,CAAC,OAAO;IACvB,OAAO,KAAK,WAAW,EACrB,SAAS,EACT,UAAU,EACV,MAAM,EACN,KAAK,EACL,OAAO,GAAG,MAAM,EAChB,KAAK,EACL,IAAI;IACJ,QAAQ;IACR,KAAK,EACL,GAAG,EACH,OAAO,EACP,SAAS,GAAG,IAAI,IAAI,EAAE,EACtB,IAAI,GAAG,YAAY,EACpB;QACC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEtC,IAAI;YACF,IAAI,IAAI,KAAK,YAAY,EAAE;gBACzB,2CAA2C;gBAE3C,MAAM,IAAA,YAAM,EAAC;oBACX,SAAS;oBACT,UAAU;oBACV,MAAM;oBACN,KAAK;oBACL,KAAK;oBACL,IAAI;oBACJ,IAAI,EAAE;wBACJ,GAAG;wBACH,SAAS;qBACV;oBACD,KAAK;oBACL,OAAO;iBACR,CAAC,CAAA;aACH;iBAAM;gBACL,8CAA8C;gBAC9C,2BAA2B;gBAC3B,MAAM,cAAM,CAAC,OAAO,CAAC,cAAc,EAAE;oBACnC,YAAY,EAAE;wBACZ,MAAM;wBACN,OAAO;wBACP,KAAK;wBACL,IAAI;wBACJ,KAAK;wBACL,GAAG;wBACH,SAAS;qBACV;iBACF,CAAC,CAAA;aACH;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,KAAK,CAAC,GAAG,CAAC,CAAA;SACX;IACH,CAAC,CAAA;AACH,CAAC;AAEM,KAAK,UAAU,sBAAsB,CAAC,OAAY,EAAE,IAAS;IAClE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE;QACzB,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;KACzC;IAED,MAAM,IAAI,EAAE,CAAA;AACd,CAAC;AAND,wDAMC"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.migrations = void 0;
4
- const glob = require('glob');
5
- const path = require('path');
6
- exports.migrations = [];
7
- glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function (file) {
8
- if (file.indexOf('index.js') !== -1)
9
- return;
10
- exports.migrations = exports.migrations.concat(Object.values(require(path.resolve(file))) || []);
11
- });
12
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/migrations/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEjB,QAAA,UAAU,GAAG,EAAE,CAAA;AAE1B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAS,IAAI;IACzE,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAAE,OAAM;IAC3C,kBAAU,GAAG,kBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;AAClF,CAAC,CAAC,CAAA"}
@@ -1,62 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.notificationRouter = void 0;
18
- const koa_router_1 = __importDefault(require("koa-router"));
19
- const typeorm_1 = require("typeorm");
20
- const auth_base_1 = require("@things-factory/auth-base");
21
- const fcm_1 = require("../controllers/fcm");
22
- const debug = require('debug')('things-factory:notification:notification-router');
23
- exports.notificationRouter = new koa_router_1.default({
24
- prefix: '/notification'
25
- });
26
- exports.notificationRouter.get('/config', async (context, next) => {
27
- const config = (0, fcm_1.getConfig)();
28
- context.type = 'application/json';
29
- context.body = config;
30
- });
31
- exports.notificationRouter.post('/register', async (context, next) => {
32
- const { user } = context.state;
33
- const { body } = context.request;
34
- context.body = await (0, fcm_1.register)(user, body);
35
- context.status = 200;
36
- });
37
- exports.notificationRouter.post('/unregister', async (context, next) => {
38
- const { user } = context.state;
39
- const { body } = context.request;
40
- context.body = await (0, fcm_1.unregister)(user, body);
41
- context.status = 200;
42
- });
43
- exports.notificationRouter.post('/notify', async (context, next) => {
44
- const { user, domain, notify } = context.state;
45
- const repository = (0, typeorm_1.getRepository)(auth_base_1.User);
46
- var _a = context.request.body, { receivers } = _a, options = __rest(_a, ["receivers"]);
47
- debug('post:/notify', receivers, receivers.split(','), options);
48
- // TODO filter only users having current domain privilege
49
- receivers = (await Promise.all(receivers
50
- .split(',')
51
- .map(email => email.trim())
52
- .map(async (email) => {
53
- var receiver = await repository.findOne({ email });
54
- return receiver && receiver.id;
55
- }))).filter(receiver => !!receiver);
56
- debug('post:/notify', receivers, user.id);
57
- await notify(Object.assign({ receivers: receivers.length > 0 ? receivers : [user.id] }, options));
58
- context.body = {
59
- success: true
60
- };
61
- });
62
- //# sourceMappingURL=notification-router.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notification-router.js","sourceRoot":"","sources":["../../server/routers/notification-router.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4DAA+B;AAC/B,qCAAuC;AACvC,yDAAgD;AAChD,4CAA4E;AAE5E,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,iDAAiD,CAAC,CAAA;AAEpE,QAAA,kBAAkB,GAAG,IAAI,oBAAM,CAAC;IAC3C,MAAM,EAAE,eAAe;CACxB,CAAC,CAAA;AAEF,0BAAkB,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACxD,MAAM,MAAM,GAAG,IAAA,eAAS,GAAE,CAAA;IAE1B,OAAO,CAAC,IAAI,GAAG,kBAAkB,CAAA;IACjC,OAAO,CAAC,IAAI,GAAG,MAAM,CAAA;AACvB,CAAC,CAAC,CAAA;AAEF,0BAAkB,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAC3D,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAC9B,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,CAAA;IAChC,OAAO,CAAC,IAAI,GAAG,MAAM,IAAA,cAAQ,EAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACzC,OAAO,CAAC,MAAM,GAAG,GAAG,CAAA;AACtB,CAAC,CAAC,CAAA;AAEF,0BAAkB,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE,O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K,CAAC,cAAc,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAA;IAEzC,MAAM,MAAM,iBACV,SAAS,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,IACpD,OAAO,EACV,CAAA;IAEF,OAAO,CAAC,IAAI,GAAG;QACb,OAAO,EAAE,IAAI;KACd,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const notification_router_1 = require("./routers/notification-router");
4
- const debug = require('debug')('things-factory:notification:routes');
5
- process.on('bootstrap-module-global-public-route', (app, globalPublicRouter) => {
6
- });
7
- process.on('bootstrap-module-global-private-route', (app, globalPrivateRouter) => {
8
- });
9
- process.on('bootstrap-module-domain-public-route', (app, domainPublicRouter) => {
10
- });
11
- process.on('bootstrap-module-domain-private-route', (app, domainPrivateRouter) => {
12
- domainPrivateRouter.use('', notification_router_1.notificationRouter.routes(), notification_router_1.notificationRouter.allowedMethods());
13
- });
14
- //# sourceMappingURL=routes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,uEAAkE;AAElE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oCAAoC,CAAC,CAAA;AAEpE,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;AACtF,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;AACxF,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;AACtF,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF,mBAAmB,CAAC,GAAG,CAAC,EAAE,EAAE,wCAAkB,CAAC,MAAM,EAAE,EAAE,wCAAkB,CAAC,cAAc,EAAE,CAAC,CAAA;AAC/F,CAAC,CAAC,CAAA"}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.schema = exports.entities = void 0;
18
- /* EXPORT ENTITY TYPES */
19
- __exportStar(require("./notification/notification"), exports);
20
- /* IMPORT ENTITIES AND RESOLVERS */
21
- const notification_1 = require("./notification");
22
- exports.entities = [
23
- /* ENTITIES */
24
- ...notification_1.entities
25
- ];
26
- exports.schema = {
27
- typeDefs: Object.assign({}, notification_1.typeDefs),
28
- resolverClasses: [
29
- /* RESOLVER CLASSES */
30
- ...notification_1.resolvers
31
- ],
32
- directives: Object.assign({}, notification_1.directives)
33
- };
34
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yBAAyB;AACzB,8DAA2C;AAE3C,mCAAmC;AACnC,iDAKuB;AAEV,QAAA,QAAQ,GAAG;IACtB,cAAc;IACd,GAAG,uBAAoB;CACxB,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,QAAQ,oBACH,uBAAoB,CACxB;IACD,eAAe,EAAE;QACf,sBAAsB;QACtB,GAAG,wBAAqB;KACzB;IACD,UAAU,oBACL,yBAAsB,CAC1B;CACF,CAAA"}
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.directiveNotification = exports.notificationDirectiveTypeDefs = void 0;
4
- const graphql_tag_1 = require("graphql-tag");
5
- const graphql_1 = require("graphql");
6
- const utils_1 = require("@graphql-tools/utils");
7
- const debug = require('debug')('things-factory:notification:directive-notification');
8
- const DIRECTIVE = 'notification';
9
- exports.notificationDirectiveTypeDefs = (0, graphql_tag_1.gql) `
10
- directive @notification(
11
- receivers: String
12
- topic: String
13
- subject: String # info
14
- title: String
15
- body: String
16
- image: String
17
- url: String
18
- # timestamp = String(Date.now())
19
- mode: String # background
20
- ) on FIELD_DEFINITION
21
- `;
22
- const directiveNotification = (schema) => (0, utils_1.mapSchema)(schema, {
23
- [utils_1.MapperKind.OBJECT_FIELD]: (fieldConfig, fieldName, typeName, schema) => {
24
- var _a;
25
- const notificationDirective = (_a = (0, utils_1.getDirective)(schema, fieldConfig, DIRECTIVE)) === null || _a === void 0 ? void 0 : _a[0];
26
- if (notificationDirective) {
27
- const { resolve = graphql_1.defaultFieldResolver, args } = fieldConfig;
28
- if (!args) {
29
- throw new Error(`Unexpected Error. args should be defined in @notification directive for field ${fieldName}.`);
30
- }
31
- const { receivers, topic, subject = 'info', title, body, image, url, mode = 'background' } = notificationDirective;
32
- const timestamp = Date.now();
33
- fieldConfig.resolve = async function (source, args, context, info) {
34
- const result = await resolve.call(this, source, args, context, info);
35
- const { domain, user, notify } = context.state;
36
- if (!notify) {
37
- debug('notify not set');
38
- }
39
- else {
40
- try {
41
- await notify({
42
- receivers: [user.id],
43
- notificationDirective,
44
- timestamp: new Date()
45
- });
46
- }
47
- catch (err) {
48
- debug(err);
49
- }
50
- }
51
- return result;
52
- };
53
- return fieldConfig;
54
- }
55
- }
56
- });
57
- exports.directiveNotification = directiveNotification;
58
- //# sourceMappingURL=directive-notification.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"directive-notification.js","sourceRoot":"","sources":["../../../server/service/notification/directive-notification.ts"],"names":[],"mappings":";;;AAAA,6CAAiC;AACjC,qCAA6D;AAC7D,gDAA0E;AAE1E,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,CAAA;AAEpF,MAAM,SAAS,GAAG,cAAc,CAAA;AAEnB,QAAA,6BAA6B,GAAG,IAAA,iBAAG,EAAA;;;;;;;;;;;;CAY/C,CAAA;AACM,MAAM,qBAAqB,GAAG,CAAC,MAAqB,EAAE,EAAE,CAC7D,IAAA,iBAAS,EAAC,MAAM,EAAE;IAChB,CAAC,kBAAU,CAAC,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE;;QACtE,MAAM,qBAAqB,GAAG,MAAA,IAAA,oBAAY,EAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,0CAAG,CAAC,CAAC,CAAA;QAC/E,IAAI,qBAAqB,EAAE;YACzB,MAAM,EAAE,OAAO,GAAG,8BAAoB,EAAE,IAAI,EAAE,GAAG,WAAW,CAAA;YAE5D,IAAI,CAAC,IAAI,EAAE;gBACT,MAAM,IAAI,KAAK,CAAC,iFAAiF,SAAS,GAAG,CAAC,CAAA;aAC/G;YAED,MAAM,EACJ,SAAS,EACT,KAAK,EACL,OAAO,GAAG,MAAM,EAChB,KAAK,EACL,IAAI,EACJ,KAAK,EACL,GAAG,EACH,IAAI,GAAG,YAAY,EACpB,GAAG,qBAAqB,CAAA;YACzB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YAE5B,WAAW,CAAC,OAAO,GAAG,KAAK,WAAW,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI;gBAC/D,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;gBAEpE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;gBAE9C,IAAI,CAAC,MAAM,EAAE;oBACX,KAAK,CAAC,gBAAgB,CAAC,CAAA;iBACxB;qBAAM;oBACL,IAAI;wBACF,MAAM,MAAM,CAAC;4BACX,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;4BACpB,qBAAqB;4BACrB,SAAS,EAAE,IAAI,IAAI,EAAE;yBACtB,CAAC,CAAA;qBACH;oBAAC,OAAO,GAAG,EAAE;wBACZ,KAAK,CAAC,GAAG,CAAC,CAAA;qBACX;iBACF;gBAED,OAAO,MAAM,CAAA;YACf,CAAC,CAAA;YAED,OAAO,WAAW,CAAA;SACnB;IACH,CAAC;CACF,CAAC,CAAA;AAhDS,QAAA,qBAAqB,yBAgD9B"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.directives = exports.resolvers = exports.entities = exports.typeDefs = void 0;
4
- const notification_resolver_1 = require("./notification-resolver");
5
- const directive_notification_1 = require("./directive-notification");
6
- exports.typeDefs = {
7
- notificationDirectiveTypeDefs: directive_notification_1.notificationDirectiveTypeDefs
8
- };
9
- exports.entities = [];
10
- exports.resolvers = [notification_resolver_1.NotificationResolver];
11
- exports.directives = {
12
- notification: directive_notification_1.directiveNotification
13
- };
14
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/notification/index.ts"],"names":[],"mappings":";;;AAAA,mEAA8D;AAC9D,qEAA+F;AAElF,QAAA,QAAQ,GAAG;IACtB,6BAA6B,EAA7B,sDAA6B;CAC9B,CAAA;AACY,QAAA,QAAQ,GAAG,EAAE,CAAA;AACb,QAAA,SAAS,GAAG,CAAC,4CAAoB,CAAC,CAAA;AAClC,QAAA,UAAU,GAAG;IACxB,YAAY,EAAE,8CAAqB;CACpC,CAAA"}
@@ -1,57 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.NotificationResolver = void 0;
16
- const type_graphql_1 = require("type-graphql");
17
- const shell_1 = require("@things-factory/shell");
18
- const graphql_subscriptions_1 = require("graphql-subscriptions");
19
- const notification_1 = require("./notification");
20
- const debug = require('debug')('things-factory:notification:notification-subscription');
21
- let NotificationResolver = class NotificationResolver {
22
- notification(payload, subject) {
23
- return payload.notification;
24
- }
25
- };
26
- __decorate([
27
- (0, type_graphql_1.Subscription)({
28
- subscribe: (0, graphql_subscriptions_1.withFilter)(() => shell_1.pubsub.asyncIterator('notification'), (payload, variables, context, info) => {
29
- /* normally, subscription context doesn't have domain */
30
- const { domain, user } = context.state;
31
- const { subjects = [] } = variables;
32
- const { notification: { subject, domain: pdomain } } = payload;
33
- const subdomain = pdomain === null || pdomain === void 0 ? void 0 : pdomain.subdomain;
34
- if (subdomain) {
35
- if (domain === null || domain === void 0 ? void 0 : domain.subdomain) {
36
- if (subdomain !== domain.subdomain) {
37
- return false;
38
- }
39
- }
40
- else if (!user.domains.find(d => d.subdomain === subdomain)) {
41
- return false;
42
- }
43
- }
44
- return !subject || subjects.indexOf(subject) !== -1;
45
- })
46
- }),
47
- __param(0, (0, type_graphql_1.Root)()),
48
- __param(1, (0, type_graphql_1.Arg)('subjects', type => [String], { nullable: true })),
49
- __metadata("design:type", Function),
50
- __metadata("design:paramtypes", [Object, Array]),
51
- __metadata("design:returntype", notification_1.Notification)
52
- ], NotificationResolver.prototype, "notification", null);
53
- NotificationResolver = __decorate([
54
- (0, type_graphql_1.Resolver)()
55
- ], NotificationResolver);
56
- exports.NotificationResolver = NotificationResolver;
57
- //# sourceMappingURL=notification-resolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notification-resolver.js","sourceRoot":"","sources":["../../../server/service/notification/notification-resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAgE;AAChE,iDAA8C;AAC9C,iEAAkD;AAClD,iDAA6C;AAE7C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,uDAAuD,CAAC,CAAA;AAGhF,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IA6B/B,YAAY,CACF,OAAuC,EACQ,OAAiB;QAExE,OAAO,OAAO,CAAC,YAAY,CAAA;IAC7B,CAAC;CACF,CAAA;AAlCC;IAAC,IAAA,2BAAY,EAAC;QACZ,SAAS,EAAE,IAAA,kCAAU,EACnB,GAAG,EAAE,CAAC,cAAM,CAAC,aAAa,CAAC,cAAc,CAAC,EAC1C,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;YACpC,wDAAwD;YACxD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;YAEtC,MAAM,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,SAAS,CAAA;YACnC,MAAM,EACJ,YAAY,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAC3C,GAAG,OAAO,CAAA;YAEX,MAAM,SAAS,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAA;YAEpC,IAAI,SAAS,EAAE;gBACb,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,EAAE;oBACrB,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,EAAE;wBAClC,OAAO,KAAK,CAAA;qBACb;iBACF;qBAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,EAAE;oBAC7D,OAAO,KAAK,CAAA;iBACb;aACF;YAED,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;QACrD,CAAC,CACF;KACF,CAAC;IAEC,WAAA,IAAA,mBAAI,GAAE,CAAA;IACN,WAAA,IAAA,kBAAG,EAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;;oCACrD,2BAAY;wDAEd;AAlCU,oBAAoB;IADhC,IAAA,uBAAQ,GAAE;GACE,oBAAoB,CAmChC;AAnCY,oDAAoB"}
@@ -1,58 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var _a;
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.Notification = void 0;
14
- const type_graphql_1 = require("type-graphql");
15
- const shell_1 = require("@things-factory/shell");
16
- let Notification = class Notification {
17
- };
18
- __decorate([
19
- (0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true }),
20
- __metadata("design:type", typeof (_a = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _a : Object)
21
- ], Notification.prototype, "domain", void 0);
22
- __decorate([
23
- (0, type_graphql_1.Field)({ nullable: true }),
24
- __metadata("design:type", String)
25
- ], Notification.prototype, "subject", void 0);
26
- __decorate([
27
- (0, type_graphql_1.Field)({ nullable: true }),
28
- __metadata("design:type", String)
29
- ], Notification.prototype, "type", void 0);
30
- __decorate([
31
- (0, type_graphql_1.Field)(),
32
- __metadata("design:type", String)
33
- ], Notification.prototype, "title", void 0);
34
- __decorate([
35
- (0, type_graphql_1.Field)(),
36
- __metadata("design:type", String)
37
- ], Notification.prototype, "body", void 0);
38
- __decorate([
39
- (0, type_graphql_1.Field)({ nullable: true }),
40
- __metadata("design:type", String)
41
- ], Notification.prototype, "url", void 0);
42
- __decorate([
43
- (0, type_graphql_1.Field)({ nullable: true }),
44
- __metadata("design:type", String)
45
- ], Notification.prototype, "image", void 0);
46
- __decorate([
47
- (0, type_graphql_1.Field)(type => shell_1.ScalarAny, { nullable: true }),
48
- __metadata("design:type", Object)
49
- ], Notification.prototype, "property", void 0);
50
- __decorate([
51
- (0, type_graphql_1.Field)({ nullable: true }),
52
- __metadata("design:type", Date)
53
- ], Notification.prototype, "timestamp", void 0);
54
- Notification = __decorate([
55
- (0, type_graphql_1.ObjectType)()
56
- ], Notification);
57
- exports.Notification = Notification;
58
- //# sourceMappingURL=notification.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notification.js","sourceRoot":"","sources":["../../../server/service/notification/notification.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAAgD;AAChD,iDAAyD;AAGlD,IAAM,YAAY,GAAlB,MAAM,YAAY;CA2BxB,CAAA;AA1BC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;kDACjC,cAAM,oBAAN,cAAM;4CAAA;AAEf;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACV;AAEhB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACb;AAEb;IAAC,IAAA,oBAAK,GAAE;;2CACK;AAEb;IAAC,IAAA,oBAAK,GAAE;;0CACI;AAEZ;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACf;AAEX;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACb;AAEb;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CAChC;AAEb;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACf,IAAI;+CAAA;AA1BJ,YAAY;IADxB,IAAA,yBAAU,GAAE;GACA,YAAY,CA2BxB;AA3BY,oCAAY"}