@things-factory/worklist 9.0.0-beta.25 → 9.0.0-beta.29
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.
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.callWebhook = callWebhook;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
4
6
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
5
7
|
const shell_1 = require("@things-factory/shell");
|
|
6
8
|
async function callWebhook(domain, tag, data, tx) {
|
|
@@ -30,7 +32,7 @@ async function callWebhook(domain, tag, data, tx) {
|
|
|
30
32
|
.filter(app => app.webhook)
|
|
31
33
|
.every(app => {
|
|
32
34
|
const webhook = app.webhook;
|
|
33
|
-
|
|
35
|
+
(0, node_fetch_1.default)(webhook, options);
|
|
34
36
|
});
|
|
35
37
|
}
|
|
36
38
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-webhook.js","sourceRoot":"","sources":["../../../server/controllers/activity-installation/call-webhook.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"call-webhook.js","sourceRoot":"","sources":["../../../server/controllers/activity-installation/call-webhook.ts"],"names":[],"mappings":";;AAMA,kCAmCC;;AAzCD,oEAA8B;AAG9B,yDAAuD;AACvD,iDAA6D;AAEtD,KAAK,UAAU,WAAW,CAAC,MAAc,EAAE,GAAW,EAAE,IAAS,EAAE,EAAkB;IAC1F;;;;;;MAME;IAEF,MAAM,YAAY,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,uBAAW,CAAC,CAAC,CAAC,CAAC,IAAA,qBAAa,EAAC,uBAAW,CAAC,CAAC,CAAC,MAAM,CAAC;QAClG,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE;KAC1B,CAAC,CAAA;IACF,MAAM,OAAO,GAAG;QACd,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,yBAAyB,EAAE,MAAM,CAAC,IAAI;YACtC,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE;YACJ,GAAG;YACH,IAAI;SACE;KACT,CAAA;IAED,IAAI,CAAC;QACH,YAAY;aACT,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC;aAC1B,KAAK,CAAC,GAAG,CAAC,EAAE;YACX,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAA;YAE3B,IAAA,oBAAK,EAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACzB,CAAC,CAAC,CAAA;IACN,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACpB,CAAC;AACH,CAAC","sourcesContent":["import fetch from 'node-fetch'\n\nimport { EntityManager } from 'typeorm'\nimport { Application } from '@things-factory/auth-base'\nimport { Domain, getRepository } from '@things-factory/shell'\n\nexport async function callWebhook(domain: Domain, tag: string, data: any, tx?: EntityManager) {\n /* \n TODO webhook callback의 다양한 subscription 조건을 지원한다. \n - activity의 client에 해당하는 application\n - activityInstance의 starter에 해당하는 application\n - 모든 이벤트를 받고자하는 application\n - 특정 activity들의 이벤트를 받고자하는 application\n */\n\n const applications = await (tx ? tx.getRepository(Application) : getRepository(Application)).findBy({\n domain: { id: domain.id }\n })\n const options = {\n method: 'post',\n headers: {\n 'x-things-factory-domain': domain.name,\n 'Content-Type': 'application/json'\n },\n body: {\n tag,\n data\n } as any\n }\n\n try {\n applications\n .filter(app => app.webhook)\n .every(app => {\n const webhook = app.webhook\n\n fetch(webhook, options)\n })\n } catch (err) {\n console.error(err)\n }\n}\n"]}
|