@xpr/nestjs-slack 1.0.2 → 2.0.0
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 +33 -3
- package/decorators.js +29 -1
- package/index.d.ts +1 -0
- package/package.json +1 -1
- package/slack.d.ts +8 -1
- package/slack.js +1 -2
- package/utils.d.ts +1 -0
package/decorators.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ActionConstraints, OptionsConstraints, ShortcutConstraints, ViewConstraints } from "@slack/bolt";
|
|
2
1
|
import { type Pattern } from "./utils";
|
|
3
|
-
import type { AllMiddlewareArgs, AnyMiddlewareArgs, SlackActionMiddlewareArgs, SlackCommandMiddlewareArgs, SlackEventMiddlewareArgs, SlackOptionsMiddlewareArgs, SlackShortcutMiddlewareArgs, SlackViewMiddlewareArgs } from "@slack/bolt/dist/types";
|
|
2
|
+
import type { ActionConstraints, AllMiddlewareArgs, AnyMiddlewareArgs, OptionsConstraints, ShortcutConstraints, SlackActionMiddlewareArgs, SlackCommandMiddlewareArgs, SlackEventMiddlewareArgs, SlackOptionsMiddlewareArgs, SlackShortcutMiddlewareArgs, SlackViewMiddlewareArgs, ViewConstraints } from "@slack/bolt/dist/types";
|
|
4
3
|
export { Pattern };
|
|
5
4
|
export type EndpointArgs<T extends AnyMiddlewareArgs> = T & AllMiddlewareArgs;
|
|
6
5
|
/**
|
|
@@ -16,15 +15,45 @@ export declare const EventTypes: {
|
|
|
16
15
|
Message: string;
|
|
17
16
|
};
|
|
18
17
|
/**
|
|
19
|
-
* Decorator for Slack controller
|
|
18
|
+
* Decorator for Slack/Bolt application controller
|
|
19
|
+
*
|
|
20
|
+
* @example slack controller:
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { SlackController } from '@xpr/nestjs-slack';
|
|
23
|
+
*
|
|
24
|
+
* @SlackController()
|
|
25
|
+
* class MySlackController {
|
|
26
|
+
* // add decorated methods
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
20
29
|
*/
|
|
21
30
|
export declare function SlackController(): ClassDecorator;
|
|
22
31
|
/**
|
|
23
32
|
* Arguments for the slack event handler
|
|
33
|
+
*
|
|
34
|
+
* See {@link SlackEvent}
|
|
24
35
|
*/
|
|
25
36
|
export type SlackEventArgs = EndpointArgs<SlackEventMiddlewareArgs>;
|
|
26
37
|
/**
|
|
27
38
|
* Decorator for event events
|
|
39
|
+
*
|
|
40
|
+
* Usage:
|
|
41
|
+
* ```ts
|
|
42
|
+
* import {
|
|
43
|
+
* SlackController,
|
|
44
|
+
* SlackEvent,
|
|
45
|
+
* SlackEventArgs,
|
|
46
|
+
* } from '@xpr/nestjs-slack';
|
|
47
|
+
*
|
|
48
|
+
* @SlackController()
|
|
49
|
+
* class MySlackController {
|
|
50
|
+
*
|
|
51
|
+
* @SlackEvent('event_name')
|
|
52
|
+
* foo(args: SlackEventArgs) {
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
28
57
|
* @see guide https://tools.slack.dev/bolt-js/concepts/event-listening
|
|
29
58
|
* @see api https://api.slack.com/apis/events-api
|
|
30
59
|
* @param event
|
|
@@ -107,3 +136,4 @@ export type SlackMessageArgs = EndpointArgs<SlackEventMiddlewareArgs<"message">>
|
|
|
107
136
|
* @param pattern
|
|
108
137
|
*/
|
|
109
138
|
export declare function SlackMessage(pattern?: Pattern): MethodDecorator;
|
|
139
|
+
//# sourceMappingURL=decorators.d.ts.map
|
package/decorators.js
CHANGED
|
@@ -24,13 +24,41 @@ exports.EventTypes = {
|
|
|
24
24
|
Message: "message",
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
|
-
* Decorator for Slack controller
|
|
27
|
+
* Decorator for Slack/Bolt application controller
|
|
28
|
+
*
|
|
29
|
+
* @example slack controller:
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { SlackController } from '@xpr/nestjs-slack';
|
|
32
|
+
*
|
|
33
|
+
* @SlackController()
|
|
34
|
+
* class MySlackController {
|
|
35
|
+
* // add decorated methods
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
28
38
|
*/
|
|
29
39
|
function SlackController() {
|
|
30
40
|
return (target) => (0, common_1.Controller)()(target);
|
|
31
41
|
}
|
|
32
42
|
/**
|
|
33
43
|
* Decorator for event events
|
|
44
|
+
*
|
|
45
|
+
* Usage:
|
|
46
|
+
* ```ts
|
|
47
|
+
* import {
|
|
48
|
+
* SlackController,
|
|
49
|
+
* SlackEvent,
|
|
50
|
+
* SlackEventArgs,
|
|
51
|
+
* } from '@xpr/nestjs-slack';
|
|
52
|
+
*
|
|
53
|
+
* @SlackController()
|
|
54
|
+
* class MySlackController {
|
|
55
|
+
*
|
|
56
|
+
* @SlackEvent('event_name')
|
|
57
|
+
* foo(args: SlackEventArgs) {
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
34
62
|
* @see guide https://tools.slack.dev/bolt-js/concepts/event-listening
|
|
35
63
|
* @see api https://api.slack.com/apis/events-api
|
|
36
64
|
* @param event
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
package/slack.d.ts
CHANGED
|
@@ -2,10 +2,16 @@ import { type CustomTransportStrategy, type MessageHandler, Server } from "@nest
|
|
|
2
2
|
import { App, type AppOptions } from "@slack/bolt";
|
|
3
3
|
export type SlackOptions = {
|
|
4
4
|
/**
|
|
5
|
-
* Slack application options with required types
|
|
5
|
+
* Slack application options with required types.
|
|
6
6
|
* @see https://github.com/slackapi/bolt-js
|
|
7
7
|
*/
|
|
8
8
|
slack: AppOptions;
|
|
9
|
+
/**
|
|
10
|
+
* Whether to inject NestJS logger into the Slack app.
|
|
11
|
+
* The injected logger override any provided in the `slack` options.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
injectNestjsLogger?: boolean;
|
|
9
15
|
};
|
|
10
16
|
export default class Slack extends Server implements CustomTransportStrategy {
|
|
11
17
|
#private;
|
|
@@ -27,3 +33,4 @@ export default class Slack extends Server implements CustomTransportStrategy {
|
|
|
27
33
|
*/
|
|
28
34
|
protected app(): App;
|
|
29
35
|
}
|
|
36
|
+
//# sourceMappingURL=slack.d.ts.map
|
package/slack.js
CHANGED
|
@@ -64,8 +64,7 @@ class Slack extends microservices_1.Server {
|
|
|
64
64
|
*/
|
|
65
65
|
app() {
|
|
66
66
|
if (!this.#app) {
|
|
67
|
-
|
|
68
|
-
if (!this.options.slack.logger) {
|
|
67
|
+
if (this.options.injectNestjsLogger && !this.options.slack.logger) {
|
|
69
68
|
this.options.slack.logger = (0, utils_1.adjustLogger)(this.logger);
|
|
70
69
|
}
|
|
71
70
|
this.#app = new bolt_1.App(this.options.slack);
|
package/utils.d.ts
CHANGED
|
@@ -13,3 +13,4 @@ export declare function eventDecorator<T>(type: string, event: T): MethodDecorat
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function messageDecorator(type: string, pattern: Pattern): MethodDecorator;
|
|
15
15
|
export declare function adjustLogger(logger: any): Logger;
|
|
16
|
+
//# sourceMappingURL=utils.d.ts.map
|