@things-factory/worklist 6.0.18 → 6.0.21

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.
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bid = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const auth_base_1 = require("@things-factory/auth-base");
6
+ const activity_instance_1 = require("../../service/activity-instance/activity-instance");
7
+ const common_1 = require("../common");
8
+ async function bid(activityInstance, context) {
9
+ const { domain, user, tx } = context.state;
10
+ const { id, assignees } = activityInstance;
11
+ var origin = id
12
+ ? await tx.getRepository(activity_instance_1.ActivityInstance).findOne({
13
+ where: { domain: { id: domain.id }, id },
14
+ relations: [
15
+ 'domain',
16
+ 'activity',
17
+ 'assigneeRole',
18
+ 'supervisoryRole',
19
+ 'updater',
20
+ 'creator',
21
+ 'starter',
22
+ 'terminator'
23
+ ]
24
+ })
25
+ : null;
26
+ const bid = await tx.getRepository(activity_instance_1.ActivityInstance).save(Object.assign(Object.assign(Object.assign({}, origin), activityInstance), { transaction: 'bid', state: activity_instance_1.ActivityInstanceStatus.Posted, domain, creator: user, updater: user }));
27
+ const assignedUsers = await tx.getRepository(auth_base_1.User).findBy({
28
+ email: (0, typeorm_1.In)(assignees || [])
29
+ });
30
+ if (bid.threadsMin === 0 && bid.assigneeRoleId) {
31
+ await (0, common_1.createActivityThreadsForAllRoleUsers)('post', bid, context);
32
+ }
33
+ if (assignedUsers.length > 0) {
34
+ await (0, common_1.createActivityThreadsForUsers)('post', bid, assignedUsers, context);
35
+ }
36
+ return await tx.getRepository(activity_instance_1.ActivityInstance).findOneBy({ id: bid.id });
37
+ }
38
+ exports.bid = bid;
39
+ //# sourceMappingURL=bid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bid.js","sourceRoot":"","sources":["../../../server/controllers/activity-instance/bid.ts"],"names":[],"mappings":";;;AAAA,qCAA4B;AAE5B,yDAAg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A6B,EAAC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;KACzE;IAED,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,oCAAgB,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAA;AAC3E,CAAC;AA3CD,kBA2CC","sourcesContent":["import { In } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\n\nimport { ActivityInstance, ActivityInstanceStatus } from '../../service/activity-instance/activity-instance'\nimport { ActivityInstancePost } from '../../service/activity-instance/activity-instance-type'\nimport { createActivityThreadsForAllRoleUsers, createActivityThreadsForUsers } from '../common'\n\nexport async function bid(activityInstance: ActivityInstancePost, context: ResolverContext): Promise<ActivityInstance> {\n const { domain, user, tx } = context.state\n const { id, assignees } = activityInstance\n\n var origin = id\n ? await tx.getRepository(ActivityInstance).findOne({\n where: { domain: { id: domain.id }, id },\n relations: [\n 'domain',\n 'activity',\n 'assigneeRole',\n 'supervisoryRole',\n 'updater',\n 'creator',\n 'starter',\n 'terminator'\n ]\n })\n : null\n\n const bid = await tx.getRepository(ActivityInstance).save({\n ...origin,\n ...activityInstance,\n transaction: 'bid',\n state: ActivityInstanceStatus.Posted,\n domain,\n creator: user,\n updater: user\n })\n\n const assignedUsers = await tx.getRepository(User).findBy({\n email: In(assignees || [])\n })\n\n if (bid.threadsMin === 0 && bid.assigneeRoleId) {\n await createActivityThreadsForAllRoleUsers('post', bid, context)\n }\n\n if (assignedUsers.length > 0) {\n await createActivityThreadsForUsers('post', bid, assignedUsers, context)\n }\n\n return await tx.getRepository(ActivityInstance).findOneBy({ id: bid.id })\n}\n"]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.callWebhook = void 0;
4
+ const auth_base_1 = require("@things-factory/auth-base");
5
+ const shell_1 = require("@things-factory/shell");
6
+ async function callWebhook(domain, tag, data) {
7
+ /*
8
+ TODO webhook callback의 다양한 subscription 조건을 지원한다.
9
+ - activity의 client에 해당하는 application
10
+ - activityInstance의 starter에 해당하는 application
11
+ - 모든 이벤트를 받고자하는 application
12
+ - 특정 activity들의 이벤트를 받고자하는 application
13
+ */
14
+ const applications = await (0, shell_1.getRepository)(auth_base_1.Application).findBy({ domain: { id: domain.id } });
15
+ const options = {
16
+ method: 'post',
17
+ headers: {
18
+ 'x-things-factory-domain': domain.name,
19
+ 'Content-Type': 'application/json'
20
+ },
21
+ body: {
22
+ tag,
23
+ data
24
+ }
25
+ };
26
+ try {
27
+ applications
28
+ .filter(app => app.webhook)
29
+ .every(app => {
30
+ const webhook = app.webhook;
31
+ fetch(webhook, options);
32
+ });
33
+ }
34
+ catch (err) {
35
+ console.error(err);
36
+ }
37
+ }
38
+ exports.callWebhook = callWebhook;
39
+ //# sourceMappingURL=call-webhook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call-webhook.js","sourceRoot":"","sources":["../../server/controllers/call-webhook.ts"],"names":[],"mappings":";;;AAAA,yDAAuD;AACvD,iDAA6D;AAEtD,KAAK,UAAU,WAAW,CAAC,MAAc,EAAE,GAAW,EAAE,IAAS;IACtE;;;;;;MAME;IAEF,MAAM,YAAY,GAAG,MAAM,IAAA,qBAAa,EAAC,uBAAW,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IAC3F,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;QACF,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,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACzB,CAAC,CAAC,CAAA;KACL;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;KACnB;AACH,CAAC;AAjCD,kCAiCC","sourcesContent":["import { Application } from '@things-factory/auth-base'\nimport { Domain, getRepository } from '@things-factory/shell'\n\nexport async function callWebhook(domain: Domain, tag: string, data: any) {\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 getRepository(Application).findBy({ domain: { id: domain.id } })\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"]}