@venturialstd/slack 0.1.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/dist/slack/clients/slack.client.d.ts +12 -0
- package/dist/slack/clients/slack.client.js +95 -0
- package/dist/slack/clients/slack.client.js.map +1 -0
- package/dist/slack/constants/slack.constants.d.ts +3 -0
- package/dist/slack/constants/slack.constants.js +7 -0
- package/dist/slack/constants/slack.constants.js.map +1 -0
- package/dist/slack/constants/slack.event.constant.d.ts +7 -0
- package/dist/slack/constants/slack.event.constant.js +11 -0
- package/dist/slack/constants/slack.event.constant.js.map +1 -0
- package/dist/slack/dtos/slack-webhook-event.dto.d.ts +21 -0
- package/dist/slack/dtos/slack-webhook-event.dto.js +139 -0
- package/dist/slack/dtos/slack-webhook-event.dto.js.map +1 -0
- package/dist/slack/index.d.ts +3 -0
- package/dist/slack/index.js +8 -0
- package/dist/slack/index.js.map +1 -0
- package/dist/slack/interfaces/logger.interface.d.ts +8 -0
- package/dist/slack/interfaces/logger.interface.js +3 -0
- package/dist/slack/interfaces/logger.interface.js.map +1 -0
- package/dist/slack/slack.module.d.ts +4 -0
- package/dist/slack/slack.module.js +36 -0
- package/dist/slack/slack.module.js.map +1 -0
- package/dist/slack/tsconfig.build.tsbuildinfo +1 -0
- package/dist/slack/types/slack.event.type.d.ts +20 -0
- package/dist/slack/types/slack.event.type.js +3 -0
- package/dist/slack/types/slack.event.type.js.map +1 -0
- package/package.json +25 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class SlackClient {
|
|
2
|
+
private logger;
|
|
3
|
+
private botToken?;
|
|
4
|
+
constructor(logger: any, botToken?: string | undefined);
|
|
5
|
+
private initializeClient;
|
|
6
|
+
listChannels(): Promise<import("@slack/web-api").ConversationsListResponse>;
|
|
7
|
+
postMessage(channelId: string, text: string): Promise<import("@slack/web-api").ChatPostMessageResponse>;
|
|
8
|
+
replyToThread(channelId: string, threadTs: string, text: string): Promise<import("@slack/web-api").ChatPostMessageResponse>;
|
|
9
|
+
addReaction(channelId: string, timestamp: string, reaction: string): Promise<import("@slack/web-api").ReactionsAddResponse>;
|
|
10
|
+
getChannelHistory(channelId: string, limit?: number): Promise<import("@slack/web-api").ConversationsHistoryResponse>;
|
|
11
|
+
getThreadReplies(channelId: string, threadTs: string): Promise<import("@slack/web-api").ConversationsRepliesResponse>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
var SlackClient_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.SlackClient = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const web_api_1 = require("@slack/web-api");
|
|
19
|
+
let SlackClient = SlackClient_1 = class SlackClient {
|
|
20
|
+
logger;
|
|
21
|
+
botToken;
|
|
22
|
+
constructor(logger, botToken) {
|
|
23
|
+
this.logger = logger;
|
|
24
|
+
this.botToken = botToken;
|
|
25
|
+
this.logger.setContext(SlackClient_1.name);
|
|
26
|
+
}
|
|
27
|
+
async initializeClient() {
|
|
28
|
+
try {
|
|
29
|
+
const token = this.botToken;
|
|
30
|
+
if (!token) {
|
|
31
|
+
throw new Error('Slack bot token not configured');
|
|
32
|
+
}
|
|
33
|
+
const client = new web_api_1.WebClient(token);
|
|
34
|
+
const auth = await client.auth.test();
|
|
35
|
+
this.logger.log(`Slack connected: ${auth.user} (${auth.team})`);
|
|
36
|
+
return client;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
this.logger.error('Error connecting slack', error);
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async listChannels() {
|
|
44
|
+
const client = await this.initializeClient();
|
|
45
|
+
return await client.conversations.list({
|
|
46
|
+
types: 'public_channel,private_channel',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async postMessage(channelId, text) {
|
|
50
|
+
const client = await this.initializeClient();
|
|
51
|
+
return await client.chat.postMessage({
|
|
52
|
+
channel: channelId,
|
|
53
|
+
text: text,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async replyToThread(channelId, threadTs, text) {
|
|
57
|
+
const client = await this.initializeClient();
|
|
58
|
+
return await client.chat.postMessage({
|
|
59
|
+
channel: channelId,
|
|
60
|
+
text: text,
|
|
61
|
+
thread_ts: threadTs,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async addReaction(channelId, timestamp, reaction) {
|
|
65
|
+
const client = await this.initializeClient();
|
|
66
|
+
return await client.reactions.add({
|
|
67
|
+
channel: channelId,
|
|
68
|
+
timestamp: timestamp,
|
|
69
|
+
name: reaction,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
async getChannelHistory(channelId, limit = 10) {
|
|
73
|
+
const client = await this.initializeClient();
|
|
74
|
+
return await client.conversations.history({
|
|
75
|
+
channel: channelId,
|
|
76
|
+
limit: limit,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async getThreadReplies(channelId, threadTs) {
|
|
80
|
+
const client = await this.initializeClient();
|
|
81
|
+
return await client.conversations.replies({
|
|
82
|
+
channel: channelId,
|
|
83
|
+
ts: threadTs,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
exports.SlackClient = SlackClient;
|
|
88
|
+
exports.SlackClient = SlackClient = SlackClient_1 = __decorate([
|
|
89
|
+
(0, common_1.Injectable)(),
|
|
90
|
+
__param(0, (0, common_1.Inject)('SLACK_LOGGER')),
|
|
91
|
+
__param(1, (0, common_1.Optional)()),
|
|
92
|
+
__param(1, (0, common_1.Inject)('SLACK_BOT_TOKEN')),
|
|
93
|
+
__metadata("design:paramtypes", [Object, String])
|
|
94
|
+
], SlackClient);
|
|
95
|
+
//# sourceMappingURL=slack.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack.client.js","sourceRoot":"","sources":["../../../clients/slack.client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA8D;AAC9D,4CAA2C;AAGpC,IAAM,WAAW,mBAAjB,MAAM,WAAW;IAEY;IACe;IAFjD,YACkC,MAAW,EACI,QAAiB;QADhC,WAAM,GAAN,MAAM,CAAK;QACI,aAAQ,GAAR,QAAQ,CAAS;QAEhE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,aAAW,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAEO,KAAK,CAAC,gBAAgB;QAC5B,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC;YAE5B,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;YACpD,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,mBAAS,CAAC,KAAK,CAAC,CAAC;YAEpC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACtC,IAAI,CAAC,MAAM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AI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,SAAiB,EAAE,QAAgB,EAAE;QAC3D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC7C,OAAO,MAAM,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC;YACxC,OAAO,EAAE,SAAS;YAClB,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,SAAiB,EAAE,QAAgB;QACxD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC7C,OAAO,MAAM,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC;YACxC,OAAO,EAAE,SAAS;YAClB,EAAE,EAAE,QAAQ;SACb,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA3EY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,cAAc,CAAC,CAAA;IACtB,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;;GAH7B,WAAW,CA2EvB","sourcesContent":["import { Inject, Injectable, Optional } from '@nestjs/common';\r\nimport { WebClient } from '@slack/web-api';\r\n\r\n@Injectable()\r\nexport class SlackClient {\r\n constructor(\r\n @Inject('SLACK_LOGGER') private logger: any,\r\n @Optional() @Inject('SLACK_BOT_TOKEN') private botToken?: string,\r\n ) {\r\n this.logger.setContext(SlackClient.name);\r\n }\r\n\r\n private async initializeClient(): Promise<WebClient> {\r\n try {\r\n const token = this.botToken;\r\n\r\n if (!token) {\r\n throw new Error('Slack bot token not configured');\r\n }\r\n const client = new WebClient(token);\r\n\r\n const auth = await client.auth.test();\r\n this.logger.log(`Slack connected: ${auth.user} (${auth.team})`);\r\n\r\n return client;\r\n } catch (error) {\r\n this.logger.error('Error connecting slack', error as Error);\r\n throw error;\r\n }\r\n }\r\n\r\n async listChannels() {\r\n const client = await this.initializeClient();\r\n return await client.conversations.list({\r\n types: 'public_channel,private_channel',\r\n });\r\n }\r\n\r\n async postMessage(channelId: string, text: string) {\r\n const client = await this.initializeClient();\r\n return await client.chat.postMessage({\r\n channel: channelId,\r\n text: text,\r\n });\r\n }\r\n\r\n async replyToThread(channelId: string, threadTs: string, text: string) {\r\n const client = await this.initializeClient();\r\n return await client.chat.postMessage({\r\n channel: channelId,\r\n text: text,\r\n thread_ts: threadTs,\r\n });\r\n }\r\n\r\n async addReaction(channelId: string, timestamp: string, reaction: string) {\r\n const client = await this.initializeClient();\r\n return await client.reactions.add({\r\n channel: channelId,\r\n timestamp: timestamp,\r\n name: reaction,\r\n });\r\n }\r\n\r\n async getChannelHistory(channelId: string, limit: number = 10) {\r\n const client = await this.initializeClient();\r\n return await client.conversations.history({\r\n channel: channelId,\r\n limit: limit,\r\n });\r\n }\r\n\r\n async getThreadReplies(channelId: string, threadTs: string) {\r\n const client = await this.initializeClient();\r\n return await client.conversations.replies({\r\n channel: channelId,\r\n ts: threadTs,\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack.constants.js","sourceRoot":"","sources":["../../../constants/slack.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG;IAChC,qBAAqB,EAAE,gCAAgC;CACxD,CAAC","sourcesContent":["export const SLACK_SETTING_KEYS = {\r\n CREDENTIALS_BOT_TOKEN: 'GLOBAL:SLACK:GENERAL:BOT_TOKEN',\r\n};\r\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SLACK_EVENTS = exports.EVENT_EMITTER_SLACK_EVENTS = void 0;
|
|
4
|
+
exports.EVENT_EMITTER_SLACK_EVENTS = {
|
|
5
|
+
WEBHOOK_INCOMING_MESSAGE: 'slack_webhook_incoming_message',
|
|
6
|
+
};
|
|
7
|
+
exports.SLACK_EVENTS = {
|
|
8
|
+
URL_VERIFICATION: 'url_verification',
|
|
9
|
+
EVENT_CALLBACK: 'event_callback',
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=slack.event.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack.event.constant.js","sourceRoot":"","sources":["../../../constants/slack.event.constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,0BAA0B,GAAG;IACxC,wBAAwB,EAAE,gCAAgC;CAClD,CAAC;AAEE,QAAA,YAAY,GAAG;IAC1B,gBAAgB,EAAE,kBAAkB;IACpC,cAAc,EAAE,gBAAgB;CACjC,CAAC","sourcesContent":["export const EVENT_EMITTER_SLACK_EVENTS = {\r\n WEBHOOK_INCOMING_MESSAGE: 'slack_webhook_incoming_message',\r\n} as const;\r\n\r\nexport const SLACK_EVENTS = {\r\n URL_VERIFICATION: 'url_verification',\r\n EVENT_CALLBACK: 'event_callback',\r\n};\r\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare class SlackEventDto {
|
|
2
|
+
type: string;
|
|
3
|
+
user?: string;
|
|
4
|
+
text?: string;
|
|
5
|
+
channel: string;
|
|
6
|
+
ts: string;
|
|
7
|
+
thread_ts?: string;
|
|
8
|
+
bot_id?: string;
|
|
9
|
+
client_msg_id?: string;
|
|
10
|
+
team?: string;
|
|
11
|
+
event_ts?: string;
|
|
12
|
+
channel_type?: string;
|
|
13
|
+
blocks?: unknown[];
|
|
14
|
+
}
|
|
15
|
+
export declare class SlackWebhookEventDto {
|
|
16
|
+
type: string;
|
|
17
|
+
challenge?: string;
|
|
18
|
+
token?: string;
|
|
19
|
+
team_id?: string;
|
|
20
|
+
event?: SlackEventDto;
|
|
21
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SlackWebhookEventDto = exports.SlackEventDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_transformer_1 = require("class-transformer");
|
|
15
|
+
const class_validator_1 = require("class-validator");
|
|
16
|
+
class SlackEventDto {
|
|
17
|
+
type;
|
|
18
|
+
user;
|
|
19
|
+
text;
|
|
20
|
+
channel;
|
|
21
|
+
ts;
|
|
22
|
+
thread_ts;
|
|
23
|
+
bot_id;
|
|
24
|
+
client_msg_id;
|
|
25
|
+
team;
|
|
26
|
+
event_ts;
|
|
27
|
+
channel_type;
|
|
28
|
+
blocks;
|
|
29
|
+
}
|
|
30
|
+
exports.SlackEventDto = SlackEventDto;
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, swagger_1.ApiProperty)(),
|
|
33
|
+
(0, class_validator_1.IsString)(),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], SlackEventDto.prototype, "type", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
38
|
+
(0, class_validator_1.IsOptional)(),
|
|
39
|
+
(0, class_validator_1.IsString)(),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], SlackEventDto.prototype, "user", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
44
|
+
(0, class_validator_1.IsOptional)(),
|
|
45
|
+
(0, class_validator_1.IsString)(),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], SlackEventDto.prototype, "text", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, swagger_1.ApiProperty)(),
|
|
50
|
+
(0, class_validator_1.IsString)(),
|
|
51
|
+
__metadata("design:type", String)
|
|
52
|
+
], SlackEventDto.prototype, "channel", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, swagger_1.ApiProperty)(),
|
|
55
|
+
(0, class_validator_1.IsString)(),
|
|
56
|
+
__metadata("design:type", String)
|
|
57
|
+
], SlackEventDto.prototype, "ts", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
60
|
+
(0, class_validator_1.IsOptional)(),
|
|
61
|
+
(0, class_validator_1.IsString)(),
|
|
62
|
+
__metadata("design:type", String)
|
|
63
|
+
], SlackEventDto.prototype, "thread_ts", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
66
|
+
(0, class_validator_1.IsOptional)(),
|
|
67
|
+
(0, class_validator_1.IsString)(),
|
|
68
|
+
__metadata("design:type", String)
|
|
69
|
+
], SlackEventDto.prototype, "bot_id", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
72
|
+
(0, class_validator_1.IsOptional)(),
|
|
73
|
+
(0, class_validator_1.IsString)(),
|
|
74
|
+
__metadata("design:type", String)
|
|
75
|
+
], SlackEventDto.prototype, "client_msg_id", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
78
|
+
(0, class_validator_1.IsOptional)(),
|
|
79
|
+
(0, class_validator_1.IsString)(),
|
|
80
|
+
__metadata("design:type", String)
|
|
81
|
+
], SlackEventDto.prototype, "team", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
84
|
+
(0, class_validator_1.IsOptional)(),
|
|
85
|
+
(0, class_validator_1.IsString)(),
|
|
86
|
+
__metadata("design:type", String)
|
|
87
|
+
], SlackEventDto.prototype, "event_ts", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
90
|
+
(0, class_validator_1.IsOptional)(),
|
|
91
|
+
(0, class_validator_1.IsString)(),
|
|
92
|
+
__metadata("design:type", String)
|
|
93
|
+
], SlackEventDto.prototype, "channel_type", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
96
|
+
(0, class_validator_1.IsOptional)(),
|
|
97
|
+
(0, class_validator_1.IsArray)(),
|
|
98
|
+
__metadata("design:type", Array)
|
|
99
|
+
], SlackEventDto.prototype, "blocks", void 0);
|
|
100
|
+
class SlackWebhookEventDto {
|
|
101
|
+
type;
|
|
102
|
+
challenge;
|
|
103
|
+
token;
|
|
104
|
+
team_id;
|
|
105
|
+
event;
|
|
106
|
+
}
|
|
107
|
+
exports.SlackWebhookEventDto = SlackWebhookEventDto;
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, swagger_1.ApiProperty)(),
|
|
110
|
+
(0, class_validator_1.IsString)(),
|
|
111
|
+
__metadata("design:type", String)
|
|
112
|
+
], SlackWebhookEventDto.prototype, "type", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
115
|
+
(0, class_validator_1.IsOptional)(),
|
|
116
|
+
(0, class_validator_1.IsString)(),
|
|
117
|
+
__metadata("design:type", String)
|
|
118
|
+
], SlackWebhookEventDto.prototype, "challenge", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
121
|
+
(0, class_validator_1.IsOptional)(),
|
|
122
|
+
(0, class_validator_1.IsString)(),
|
|
123
|
+
__metadata("design:type", String)
|
|
124
|
+
], SlackWebhookEventDto.prototype, "token", void 0);
|
|
125
|
+
__decorate([
|
|
126
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
127
|
+
(0, class_validator_1.IsOptional)(),
|
|
128
|
+
(0, class_validator_1.IsString)(),
|
|
129
|
+
__metadata("design:type", String)
|
|
130
|
+
], SlackWebhookEventDto.prototype, "team_id", void 0);
|
|
131
|
+
__decorate([
|
|
132
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
133
|
+
(0, class_validator_1.IsOptional)(),
|
|
134
|
+
(0, class_validator_1.IsObject)(),
|
|
135
|
+
(0, class_validator_1.ValidateNested)(),
|
|
136
|
+
(0, class_transformer_1.Type)(() => SlackEventDto),
|
|
137
|
+
__metadata("design:type", SlackEventDto)
|
|
138
|
+
], SlackWebhookEventDto.prototype, "event", void 0);
|
|
139
|
+
//# sourceMappingURL=slack-webhook-event.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack-webhook-event.dto.js","sourceRoot":"","sources":["../../../dtos/slack-webhook-event.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmE;AACnE,yDAAyC;AACzC,qDAA0F;AAE1F,MAAa,aAAa;IAGxB,IAAI,CAAS;IAKb,IAAI,CAAU;IAKd,IAAI,CAAU;IAId,OAAO,CAAS;IAIhB,EAAE,CAAS;IAKX,SAAS,CAAU;IAKnB,MAAM,CAAU;IAKhB,aAAa,CAAU;IAKvB,IAAI,CAAU;IAKd,QAAQ,CAAU;IAKlB,YAAY,CAAU;IAKtB,MAAM,CAAa;CACpB;AAzDD,sCAyDC;AAtDC;IAFC,IAAA,qBAAW,GAAE;IACb,IAAA,0BAAQ,GAAE;;2CACE;AAKb;IAHC,IAAA,6BAAmB,GAAE;IACrB,IAAA,4BAAU,G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;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;mDACI;AAKf;IAHC,IAAA,6BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;qDACM;AAOjB;IALC,IAAA,6BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,aAAa,CAAC;8BAClB,aAAa;mDAAC","sourcesContent":["import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';\r\nimport { Type } from 'class-transformer';\r\nimport { IsArray, IsObject, IsOptional, IsString, ValidateNested } from 'class-validator';\r\n\r\nexport class SlackEventDto {\r\n @ApiProperty()\r\n @IsString()\r\n type: string;\r\n\r\n @ApiPropertyOptional()\r\n @IsOptional()\r\n @IsString()\r\n user?: string;\r\n\r\n @ApiPropertyOptional()\r\n @IsOptional()\r\n @IsString()\r\n text?: string;\r\n\r\n @ApiProperty()\r\n @IsString()\r\n channel: string;\r\n\r\n @ApiProperty()\r\n @IsString()\r\n ts: string;\r\n\r\n @ApiPropertyOptional()\r\n @IsOptional()\r\n @IsString()\r\n thread_ts?: string;\r\n\r\n @ApiPropertyOptional()\r\n @IsOptional()\r\n @IsString()\r\n bot_id?: string;\r\n\r\n @ApiPropertyOptional()\r\n @IsOptional()\r\n @IsString()\r\n client_msg_id?: string;\r\n\r\n @ApiPropertyOptional()\r\n @IsOptional()\r\n @IsString()\r\n team?: string;\r\n\r\n @ApiPropertyOptional()\r\n @IsOptional()\r\n @IsString()\r\n event_ts?: string;\r\n\r\n @ApiPropertyOptional()\r\n @IsOptional()\r\n @IsString()\r\n channel_type?: string;\r\n\r\n @ApiPropertyOptional()\r\n @IsOptional()\r\n @IsArray()\r\n blocks?: unknown[];\r\n}\r\n\r\nexport class SlackWebhookEventDto {\r\n @ApiProperty()\r\n @IsString()\r\n type: string;\r\n\r\n @ApiPropertyOptional()\r\n @IsOptional()\r\n @IsString()\r\n challenge?: string;\r\n\r\n @ApiPropertyOptional()\r\n @IsOptional()\r\n @IsString()\r\n token?: string;\r\n\r\n @ApiPropertyOptional()\r\n @IsOptional()\r\n @IsString()\r\n team_id?: string;\r\n\r\n @ApiPropertyOptional()\r\n @IsOptional()\r\n @IsObject()\r\n @ValidateNested()\r\n @Type(() => SlackEventDto)\r\n event?: SlackEventDto;\r\n}\r\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SlackModule = exports.SlackClient = void 0;
|
|
4
|
+
var slack_client_1 = require("./clients/slack.client");
|
|
5
|
+
Object.defineProperty(exports, "SlackClient", { enumerable: true, get: function () { return slack_client_1.SlackClient; } });
|
|
6
|
+
var slack_module_1 = require("./slack.module");
|
|
7
|
+
Object.defineProperty(exports, "SlackModule", { enumerable: true, get: function () { return slack_module_1.SlackModule; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;AAAA,uDAAqD;AAA5C,2GAAA,WAAW,OAAA;AAEpB,+CAA6C;AAApC,2GAAA,WAAW,OAAA","sourcesContent":["export { SlackClient } from './clients/slack.client';\nexport { ILogger } from './interfaces/logger.interface';\nexport { SlackModule } from './slack.module';\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ILogger {
|
|
2
|
+
setContext(context: string): void;
|
|
3
|
+
error(message: string, meta?: Record<string, any>): any;
|
|
4
|
+
warn(message: string, meta?: Record<string, any>): any;
|
|
5
|
+
debug(message: string, meta?: Record<string, any>): any;
|
|
6
|
+
verbose(message: string, meta?: Record<string, any>): any;
|
|
7
|
+
log(message: string, meta?: Record<string, any>): any;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.interface.js","sourceRoot":"","sources":["../../../interfaces/logger.interface.ts"],"names":[],"mappings":"","sourcesContent":["export interface ILogger {\n setContext(context: string): void;\n error(message: string, meta?: Record<string, any>): any;\n warn(message: string, meta?: Record<string, any>): any;\n debug(message: string, meta?: Record<string, any>): any;\n verbose(message: string, meta?: Record<string, any>): any;\n log(message: string, meta?: Record<string, any>): any;\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 SlackModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SlackModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const slack_client_1 = require("./clients/slack.client");
|
|
13
|
+
let SlackModule = SlackModule_1 = class SlackModule {
|
|
14
|
+
static forRoot(loggerClass, botToken) {
|
|
15
|
+
return {
|
|
16
|
+
module: SlackModule_1,
|
|
17
|
+
providers: [
|
|
18
|
+
slack_client_1.SlackClient,
|
|
19
|
+
{
|
|
20
|
+
provide: 'SLACK_LOGGER',
|
|
21
|
+
useClass: loggerClass,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
provide: 'SLACK_BOT_TOKEN',
|
|
25
|
+
useValue: botToken,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
exports: [slack_client_1.SlackClient],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.SlackModule = SlackModule;
|
|
33
|
+
exports.SlackModule = SlackModule = SlackModule_1 = __decorate([
|
|
34
|
+
(0, common_1.Module)({})
|
|
35
|
+
], SlackModule);
|
|
36
|
+
//# sourceMappingURL=slack.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack.module.js","sourceRoot":"","sources":["../../slack.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA6D;AAE7D,yDAAqD;AAG9C,IAAM,WAAW,mBAAjB,MAAM,WAAW;IACtB,MAAM,CAAC,OAAO,CAAC,WAAsB,EAAE,QAAiB;QACtD,OAAO;YACL,MAAM,EAAE,aAAW;YAEnB,SAAS,EAAE;gBACT,0BAAW;gBAEX;oBACE,OAAO,EAAE,cAAc;oBACvB,QAAQ,EAAE,WAAW;iBACtB;gBACD;oBACE,OAAO,EAAE,iBAAiB;oBAC1B,QAAQ,EAAE,QAAQ;iBACnB;aACF;YACD,OAAO,EAAE,CAAC,0BAAW,CAAC;SACvB,CAAC;IACJ,CAAC;CACF,CAAA;AApBY,kCAAW;sBAAX,WAAW;IADvB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,WAAW,CAoBvB","sourcesContent":["import { DynamicModule, Module, Type } from '@nestjs/common';\r\n\r\nimport { SlackClient } from './clients/slack.client';\r\n\r\n@Module({})\r\nexport class SlackModule {\r\n static forRoot(loggerClass: Type<any>, botToken?: string): DynamicModule {\r\n return {\r\n module: SlackModule,\r\n\r\n providers: [\r\n SlackClient,\r\n\r\n {\r\n provide: 'SLACK_LOGGER',\r\n useClass: loggerClass,\r\n },\r\n {\r\n provide: 'SLACK_BOT_TOKEN',\r\n useValue: botToken,\r\n },\r\n ],\r\n exports: [SlackClient],\r\n };\r\n }\r\n}\r\n"]}
|