@servicelabsco/slabs-access-manager 0.1.193 → 0.1.194
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/dist/access/dtos/slack.message.attributes.dto.d.ts +1 -0
- package/dist/access/dtos/slack.message.attributes.dto.js.map +1 -1
- package/dist/access/entities/slack.message.entity.d.ts +1 -0
- package/dist/access/entities/slack.message.entity.js +4 -0
- package/dist/access/entities/slack.message.entity.js.map +1 -1
- package/dist/access/libraries/process.slack.message.d.ts +7 -0
- package/dist/access/libraries/process.slack.message.js +20 -2
- package/dist/access/libraries/process.slack.message.js.map +1 -1
- package/dist/migrations/1729240903500-AddSlackResponseColumnSysSlackMessagesTable.d.ts +5 -0
- package/dist/migrations/1729240903500-AddSlackResponseColumnSysSlackMessagesTable.js +15 -0
- package/dist/migrations/1729240903500-AddSlackResponseColumnSysSlackMessagesTable.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slack.message.attributes.dto.js","sourceRoot":"","sources":["../../../src/access/dtos/slack.message.attributes.dto.ts"],"names":[],"mappings":";;;AAAA,oFAA6E;AAC7E,MAAa,yBAA0B,SAAQ,6CAAmB;
|
|
1
|
+
{"version":3,"file":"slack.message.attributes.dto.js","sourceRoot":"","sources":["../../../src/access/dtos/slack.message.attributes.dto.ts"],"names":[],"mappings":";;;AAAA,oFAA6E;AAC7E,MAAa,yBAA0B,SAAQ,6CAAmB;CAEjE;AAFD,8DAEC"}
|
|
@@ -14,6 +14,7 @@ export declare class SlackMessageEntity extends CommonEntity {
|
|
|
14
14
|
source_type: string;
|
|
15
15
|
source_id: number;
|
|
16
16
|
attributes: SlackMessageAttributesDto;
|
|
17
|
+
response: any;
|
|
17
18
|
business: AccessBusinessEntity;
|
|
18
19
|
user: UserEntity;
|
|
19
20
|
slack_notification: SlackNotificationEntity;
|
|
@@ -62,6 +62,10 @@ __decorate([
|
|
|
62
62
|
(0, typeorm_1.Column)('json'),
|
|
63
63
|
__metadata("design:type", slack_message_attributes_dto_1.SlackMessageAttributesDto)
|
|
64
64
|
], SlackMessageEntity.prototype, "attributes", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, typeorm_1.Column)('json'),
|
|
67
|
+
__metadata("design:type", Object)
|
|
68
|
+
], SlackMessageEntity.prototype, "response", void 0);
|
|
65
69
|
__decorate([
|
|
66
70
|
(0, typeorm_1.ManyToOne)(() => access_business_entity_1.AccessBusinessEntity),
|
|
67
71
|
(0, typeorm_1.JoinColumn)({ name: 'business_id' }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slack.message.entity.js","sourceRoot":"","sources":["../../../src/access/entities/slack.message.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oFAAqG;AACrG,qCAAgE;AAChE,sGAAiG;AACjG,uFAAiF;AACjF,qEAAgE;AASzD,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,sCAAY;
|
|
1
|
+
{"version":3,"file":"slack.message.entity.js","sourceRoot":"","sources":["../../../src/access/entities/slack.message.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oFAAqG;AACrG,qCAAgE;AAChE,sGAAiG;AACjG,uFAAiF;AACjF,qEAAgE;AASzD,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,sCAAY;CA6CnD,CAAA;AA7CY,gDAAkB;AAE3B;IADC,IAAA,gBAAM,GAAE;;uDACW;AAGpB;IADC,IAAA,gBAAM,GAAE;;mDACO;AAGhB;IADC,IAAA,gBAAM,GAAE;;mDACO;AAGhB;IADC,IAAA,gBAAM,GAAE;;iEACqB;AAG9B;IADC,IAAA,gBAAM,GAAE;;qDACS;AAGlB;IADC,IAAA,gBAAM,GAAE;;oDACQ;AAGjB;IADC,IAAA,gBAAM,GAAE;;8DACkB;AAG3B;IADC,IAAA,gBAAM,EAAC,MAAM,CAAC;;mDACF;AAGb;IADC,IAAA,gBAAM,GAAE;;uDACW;AAGpB;IADC,IAAA,gBAAM,GAAE;;qDACS;AAGlB;IADC,IAAA,gBAAM,EAAC,MAAM,CAAC;8BACH,wDAAyB;sDAAC;AAGtC;IADC,IAAA,gBAAM,EAAC,MAAM,CAAC;;oDACD;AAG8D;IAA3E,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,6CAAoB,CAAC;IAAE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BAAW,6CAAoB;oDAAC;AAC7C;IAA7D,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,oCAAU,CAAC;IAAE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;8BAAO,oCAAU;gDAAC;AACU;IAAxF,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,mDAAuB,CAAC;IAAE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC;8BAAqB,mDAAuB;8DAAC;AAE7D;IAAvE,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC;IAAE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;8BAAS,kBAAkB;kDAAC;AAE9B;IAApE,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,2CAAiB,CAAC;IAAE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;8BAAO,2CAAiB;gDAAC;6BA5CpF,kBAAkB;IAD9B,IAAA,gBAAM,EAAC,oBAAoB,CAAC;GAChB,kBAAkB,CA6C9B"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { SlackMessageDataDto } from '../dtos/slack.message.data.dto';
|
|
2
|
+
import { BusinessAppIntegrationEntity } from '../entities/business.app.integration.entity';
|
|
3
|
+
import { SlackMessageEntity } from '../entities/slack.message.entity';
|
|
2
4
|
export declare class ProcessSlackMessage {
|
|
3
5
|
protected base_url: string;
|
|
4
6
|
protected token: string;
|
|
7
|
+
protected businessIntegration: BusinessAppIntegrationEntity;
|
|
5
8
|
process(data: SlackMessageDataDto): Promise<any>;
|
|
6
9
|
sendMessageToUser(email: string, payload: any): Promise<any>;
|
|
7
10
|
sendMessageToChannel(channelName: string, payload: any): Promise<any>;
|
|
@@ -13,4 +16,8 @@ export declare class ProcessSlackMessage {
|
|
|
13
16
|
getChannelId(channelName: string): Promise<any>;
|
|
14
17
|
send(end_point: string, params: any): Promise<any>;
|
|
15
18
|
validate(id: number): Promise<string>;
|
|
19
|
+
saveLog(res: any, { send_to, content }: {
|
|
20
|
+
send_to: string;
|
|
21
|
+
content: any;
|
|
22
|
+
}): Promise<SlackMessageEntity>;
|
|
16
23
|
}
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ProcessSlackMessage = void 0;
|
|
4
4
|
const business_app_integration_credential_entity_1 = require("../entities/business.app.integration.credential.entity");
|
|
5
5
|
const business_app_integration_entity_1 = require("../entities/business.app.integration.entity");
|
|
6
|
+
const slack_message_entity_1 = require("../entities/slack.message.entity");
|
|
7
|
+
const notification_type_enum_1 = require("../enums/notification.type.enum");
|
|
6
8
|
class ProcessSlackMessage {
|
|
7
9
|
constructor() {
|
|
8
10
|
this.base_url = 'https://slack.com/api';
|
|
@@ -21,12 +23,16 @@ class ProcessSlackMessage {
|
|
|
21
23
|
if (!userInfo)
|
|
22
24
|
return;
|
|
23
25
|
const getPayloads = await this.getCommonMessagePayload(userInfo.user.id, payload);
|
|
24
|
-
|
|
26
|
+
const res = await this.send(getPayloads.url, getPayloads.params);
|
|
27
|
+
await this.saveLog(res, { send_to: email, content: getPayloads.params });
|
|
28
|
+
return res;
|
|
25
29
|
}
|
|
26
30
|
async sendMessageToChannel(channelName, payload) {
|
|
27
31
|
const channelID = await this.getChannelId(channelName);
|
|
28
32
|
const getPayloads = await this.getCommonMessagePayload(channelID, payload);
|
|
29
|
-
|
|
33
|
+
const res = await this.send(getPayloads.url, getPayloads.params);
|
|
34
|
+
await this.saveLog(res, { send_to: channelName, content: getPayloads.params });
|
|
35
|
+
return res;
|
|
30
36
|
}
|
|
31
37
|
async getCommonMessagePayload(channelId, payload) {
|
|
32
38
|
const params = {
|
|
@@ -65,6 +71,7 @@ class ProcessSlackMessage {
|
|
|
65
71
|
}
|
|
66
72
|
catch (error) {
|
|
67
73
|
console.error('Error:', error);
|
|
74
|
+
return error;
|
|
68
75
|
}
|
|
69
76
|
}
|
|
70
77
|
async validate(id) {
|
|
@@ -74,8 +81,19 @@ class ProcessSlackMessage {
|
|
|
74
81
|
const integrationCredentials = await business_app_integration_credential_entity_1.BusinessAppIntegrationCredentialEntity.findOne({ where: { business_integration_id: id } });
|
|
75
82
|
if (!integrationCredentials?.access_token)
|
|
76
83
|
return;
|
|
84
|
+
this.businessIntegration = businessIntegration;
|
|
77
85
|
return integrationCredentials.access_token;
|
|
78
86
|
}
|
|
87
|
+
async saveLog(res, { send_to, content }) {
|
|
88
|
+
const log = slack_message_entity_1.SlackMessageEntity.create({ business_id: this.businessIntegration.business_id });
|
|
89
|
+
log.attributes = { send_to };
|
|
90
|
+
log.response = res;
|
|
91
|
+
log.content = content;
|
|
92
|
+
log.category = 'Outgoing';
|
|
93
|
+
log.type_id = notification_type_enum_1.NotificationTypeEnum.Outward;
|
|
94
|
+
log.message_identifier = res?.ts;
|
|
95
|
+
return log.save();
|
|
96
|
+
}
|
|
79
97
|
}
|
|
80
98
|
exports.ProcessSlackMessage = ProcessSlackMessage;
|
|
81
99
|
//# sourceMappingURL=process.slack.message.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.slack.message.js","sourceRoot":"","sources":["../../../src/access/libraries/process.slack.message.ts"],"names":[],"mappings":";;;AACA,uHAAgH;AAChH,iGAA2F;
|
|
1
|
+
{"version":3,"file":"process.slack.message.js","sourceRoot":"","sources":["../../../src/access/libraries/process.slack.message.ts"],"names":[],"mappings":";;;AACA,uHAAg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B,CAAC,YAAY,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,EAAqC;QAC3E,MAAM,GAAG,GAAG,yCAAkB,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,mBAAmB,CAAC,WAAW,EAAE,CAAC,CAAC;QAE7F,GAAG,CAAC,UAAU,GAAG,EAAE,OAAO,EAAE,CAAC;QAC7B,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC;QACnB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACtB,GAAG,CAAC,QAAQ,GAAG,UAAU,CAAC;QAC1B,GAAG,CAAC,OAAO,GAAG,6CAAoB,CAAC,OAAO,CAAC;QAC3C,GAAG,CAAC,kBAAkB,GAAG,GAAG,EAAE,EAAE,CAAC;QAEjC,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;CACJ;AApHD,kDAoHC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddSlackResponseColumnSysSlackMessagesTable1729240903500 = void 0;
|
|
4
|
+
const nestjs_utility_services_1 = require("@servicelabsco/nestjs-utility-services");
|
|
5
|
+
class AddSlackResponseColumnSysSlackMessagesTable1729240903500 extends nestjs_utility_services_1.MigrationUtility {
|
|
6
|
+
constructor() {
|
|
7
|
+
super('sys_slack_messages');
|
|
8
|
+
this.process();
|
|
9
|
+
}
|
|
10
|
+
process() {
|
|
11
|
+
this.json('response');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.AddSlackResponseColumnSysSlackMessagesTable1729240903500 = AddSlackResponseColumnSysSlackMessagesTable1729240903500;
|
|
15
|
+
//# sourceMappingURL=1729240903500-AddSlackResponseColumnSysSlackMessagesTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1729240903500-AddSlackResponseColumnSysSlackMessagesTable.js","sourceRoot":"","sources":["../../src/migrations/1729240903500-AddSlackResponseColumnSysSlackMessagesTable.ts"],"names":[],"mappings":";;;AAAA,oFAA0E;AAE1E,MAAa,wDAAyD,SAAQ,0CAAgB;IAC1F;QACI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAC5B,IAAI,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC;IAED,OAAO;QACH,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1B,CAAC;CACJ;AATD,4HASC"}
|
package/package.json
CHANGED