@xpr/nestjs-slack 0.9.3 → 1.0.1
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/decorators.d.ts +40 -1
- package/decorators.js +2 -1
- package/package.json +56 -1
- package/slack.js +3 -1
package/decorators.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ActionConstraints, OptionsConstraints, ShortcutConstraints, ViewConstraints } from '@slack/bolt';
|
|
2
2
|
import { type Pattern } from './utils';
|
|
3
|
-
|
|
3
|
+
import type { AllMiddlewareArgs, AnyMiddlewareArgs, SlackActionMiddlewareArgs, SlackCommandMiddlewareArgs, SlackEventMiddlewareArgs, SlackOptionsMiddlewareArgs, SlackShortcutMiddlewareArgs, SlackViewMiddlewareArgs } from '@slack/bolt/dist/types';
|
|
4
4
|
export { Pattern };
|
|
5
|
+
export type EndpointArgs<T extends AnyMiddlewareArgs> = T & AllMiddlewareArgs;
|
|
5
6
|
/**
|
|
6
7
|
* @see https://tools.slack.dev/bolt-js/reference/
|
|
7
8
|
*/
|
|
@@ -12,11 +13,16 @@ export declare const EventTypes: {
|
|
|
12
13
|
Action: string;
|
|
13
14
|
View: string;
|
|
14
15
|
Option: string;
|
|
16
|
+
Message: string;
|
|
15
17
|
};
|
|
16
18
|
/**
|
|
17
19
|
* Decorator for Slack controller
|
|
18
20
|
*/
|
|
19
21
|
export declare function SlackController(): ClassDecorator;
|
|
22
|
+
/**
|
|
23
|
+
* Arguments for the slack event handler
|
|
24
|
+
*/
|
|
25
|
+
export type SlackEventArgs = EndpointArgs<SlackEventMiddlewareArgs>;
|
|
20
26
|
/**
|
|
21
27
|
* Decorator for event events
|
|
22
28
|
* @see guide https://tools.slack.dev/bolt-js/concepts/event-listening
|
|
@@ -24,6 +30,13 @@ export declare function SlackController(): ClassDecorator;
|
|
|
24
30
|
* @param event
|
|
25
31
|
*/
|
|
26
32
|
export declare function SlackEvent(event: string): MethodDecorator;
|
|
33
|
+
/**
|
|
34
|
+
* Arguments for the slack shortcut handler
|
|
35
|
+
*/
|
|
36
|
+
export type SlackShortcutArgs = EndpointArgs<SlackShortcutMiddlewareArgs>;
|
|
37
|
+
/**
|
|
38
|
+
* Shortcut id
|
|
39
|
+
*/
|
|
27
40
|
export type ShortCutId = Pattern | ShortcutConstraints;
|
|
28
41
|
/**
|
|
29
42
|
* Decorator for shortcut events
|
|
@@ -32,6 +45,10 @@ export type ShortCutId = Pattern | ShortcutConstraints;
|
|
|
32
45
|
* @param shortcutId
|
|
33
46
|
*/
|
|
34
47
|
export declare function SlackShortcut(shortcutId: ShortCutId): MethodDecorator;
|
|
48
|
+
/**
|
|
49
|
+
* Arguments for the slack command handler
|
|
50
|
+
*/
|
|
51
|
+
export type SlackCommandArgs = EndpointArgs<SlackCommandMiddlewareArgs>;
|
|
35
52
|
/**
|
|
36
53
|
* Decorator for command events
|
|
37
54
|
* @see guide https://tools.slack.dev/bolt-js/concepts/commands
|
|
@@ -39,6 +56,13 @@ export declare function SlackShortcut(shortcutId: ShortCutId): MethodDecorator;
|
|
|
39
56
|
* @param commandId
|
|
40
57
|
*/
|
|
41
58
|
export declare function SlackCommand(commandId: Pattern): MethodDecorator;
|
|
59
|
+
/**
|
|
60
|
+
* Arguments for the slack action handler
|
|
61
|
+
*/
|
|
62
|
+
export type SlackActionArgs = EndpointArgs<SlackActionMiddlewareArgs>;
|
|
63
|
+
/**
|
|
64
|
+
* Action id
|
|
65
|
+
*/
|
|
42
66
|
export type ActionId = Pattern | ActionConstraints;
|
|
43
67
|
/**
|
|
44
68
|
* Decorator for action events
|
|
@@ -46,6 +70,13 @@ export type ActionId = Pattern | ActionConstraints;
|
|
|
46
70
|
* @param actionId
|
|
47
71
|
*/
|
|
48
72
|
export declare function SlackAction(actionId: ActionId): MethodDecorator;
|
|
73
|
+
/**
|
|
74
|
+
* Arguments for the slack view handler
|
|
75
|
+
*/
|
|
76
|
+
export type SlackViewArgs = EndpointArgs<SlackViewMiddlewareArgs>;
|
|
77
|
+
/**
|
|
78
|
+
* View id
|
|
79
|
+
*/
|
|
49
80
|
export type ViewId = Pattern | ViewConstraints;
|
|
50
81
|
/**
|
|
51
82
|
* Decorator for view events
|
|
@@ -53,6 +84,13 @@ export type ViewId = Pattern | ViewConstraints;
|
|
|
53
84
|
* @param viewId
|
|
54
85
|
*/
|
|
55
86
|
export declare function SlackView(viewId: ViewId): MethodDecorator;
|
|
87
|
+
/**
|
|
88
|
+
* Arguments for the slack option handler
|
|
89
|
+
*/
|
|
90
|
+
export type SlackOptionArgs = EndpointArgs<SlackOptionsMiddlewareArgs>;
|
|
91
|
+
/**
|
|
92
|
+
* Options id
|
|
93
|
+
*/
|
|
56
94
|
export type OptionId = OptionsConstraints;
|
|
57
95
|
/**
|
|
58
96
|
* Decorator for options events
|
|
@@ -60,6 +98,7 @@ export type OptionId = OptionsConstraints;
|
|
|
60
98
|
* @param optionId
|
|
61
99
|
*/
|
|
62
100
|
export declare function SlackOption(optionId: OptionId): MethodDecorator;
|
|
101
|
+
export type SlackMessageArgs = EndpointArgs<SlackEventMiddlewareArgs<'message'>>;
|
|
63
102
|
/**
|
|
64
103
|
* Decorator for message events
|
|
65
104
|
*
|
package/decorators.js
CHANGED
|
@@ -21,6 +21,7 @@ exports.EventTypes = {
|
|
|
21
21
|
Action: 'action',
|
|
22
22
|
View: 'view',
|
|
23
23
|
Option: 'option',
|
|
24
|
+
Message: 'message',
|
|
24
25
|
};
|
|
25
26
|
/**
|
|
26
27
|
* Decorator for Slack controller
|
|
@@ -89,5 +90,5 @@ function SlackOption(optionId) {
|
|
|
89
90
|
* @param pattern
|
|
90
91
|
*/
|
|
91
92
|
function SlackMessage(pattern = '*') {
|
|
92
|
-
return (0, utils_1.
|
|
93
|
+
return (0, utils_1.eventDecorator)(exports.EventTypes.Message, pattern);
|
|
93
94
|
}
|
package/package.json
CHANGED
|
@@ -1 +1,56 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "@xpr/nestjs-slack",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "NestJS server implementation of the Slack Assistant",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc -p tsconfig-lib.json"
|
|
8
|
+
},
|
|
9
|
+
"author": "Ziv Perry",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"slack",
|
|
13
|
+
"nestjs",
|
|
14
|
+
"assistant",
|
|
15
|
+
"ai"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20.0.0",
|
|
19
|
+
"npm": ">=10.0.0"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/ziv/nestjs-slack.git",
|
|
24
|
+
"directory": "packages/nestjs-slack-assistant"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/ziv/nestjs-slack/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/ziv/nestjs-slack#readme",
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@tsconfig/node20": "^20.1.4",
|
|
32
|
+
"@types/node": "^22.10.6",
|
|
33
|
+
"semantic-release": "^24.2.3",
|
|
34
|
+
"semantic-release-monorepo": "^8.0.2"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@nestjs/common": "^11.0.1",
|
|
38
|
+
"@nestjs/microservices": ">=11.0.13",
|
|
39
|
+
"@slack/bolt": ">=4.2.1",
|
|
40
|
+
"reflect-metadata": ">=0.2.2"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"*.js",
|
|
44
|
+
"*.d.ts",
|
|
45
|
+
"readme.md"
|
|
46
|
+
],
|
|
47
|
+
"release": {
|
|
48
|
+
"extends": "semantic-release-monorepo",
|
|
49
|
+
"plugins": [
|
|
50
|
+
"@semantic-release/commit-analyzer",
|
|
51
|
+
"@semantic-release/release-notes-generator",
|
|
52
|
+
"@semantic-release/npm",
|
|
53
|
+
"@semantic-release/github"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
package/slack.js
CHANGED
|
@@ -35,6 +35,9 @@ class Slack extends microservices_1.Server {
|
|
|
35
35
|
register(handler) {
|
|
36
36
|
const { type, event } = handler.extras;
|
|
37
37
|
switch (type) {
|
|
38
|
+
case decorators_1.EventTypes.Message:
|
|
39
|
+
this.app().message(event, handler);
|
|
40
|
+
break;
|
|
38
41
|
case decorators_1.EventTypes.Shortcut:
|
|
39
42
|
this.app().shortcut(event, handler);
|
|
40
43
|
break;
|
|
@@ -42,7 +45,6 @@ class Slack extends microservices_1.Server {
|
|
|
42
45
|
this.app().action(event, handler);
|
|
43
46
|
break;
|
|
44
47
|
case decorators_1.EventTypes.Event:
|
|
45
|
-
// todo improve by providing types for events names
|
|
46
48
|
this.app().event(event, handler);
|
|
47
49
|
break;
|
|
48
50
|
case decorators_1.EventTypes.Command:
|