@xpr/nestjs-slack 0.3.0 → 0.4.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/package.json +1 -1
- package/slack.d.ts +2 -2
- package/slack.js +2 -2
- package/utils.d.ts +1 -1
- package/utils.js +13 -6
package/package.json
CHANGED
package/slack.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type CustomTransportStrategy, type MessageHandler, Server } from
|
|
2
|
-
import { App, type AppOptions } from
|
|
1
|
+
import { type CustomTransportStrategy, type MessageHandler, Server } from "@nestjs/microservices";
|
|
2
|
+
import { App, type AppOptions } from "@slack/bolt";
|
|
3
3
|
export type SlackOptions = {
|
|
4
4
|
/**
|
|
5
5
|
* Slack application options with required types
|
package/slack.js
CHANGED
|
@@ -24,7 +24,7 @@ class Slack extends microservices_1.Server {
|
|
|
24
24
|
this.#app && (await this.#app.stop());
|
|
25
25
|
}
|
|
26
26
|
on() {
|
|
27
|
-
throw new Error(
|
|
27
|
+
throw new Error("Use SlackEvent decorator to register events");
|
|
28
28
|
}
|
|
29
29
|
unwrap() {
|
|
30
30
|
return this.#app;
|
|
@@ -61,7 +61,7 @@ class Slack extends microservices_1.Server {
|
|
|
61
61
|
this.options.slack.logger = (0, utils_1.adjustLogger)(this.logger);
|
|
62
62
|
}
|
|
63
63
|
this.#app = new bolt_1.App(this.options.slack);
|
|
64
|
-
this.logger.log(
|
|
64
|
+
this.logger.log("Bolt app created");
|
|
65
65
|
}
|
|
66
66
|
return this.#app;
|
|
67
67
|
}
|
package/utils.d.ts
CHANGED
package/utils.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.adjustLogger = adjustLogger;
|
|
|
6
6
|
const microservices_1 = require("@nestjs/microservices");
|
|
7
7
|
const bolt_1 = require("@slack/bolt");
|
|
8
8
|
const normalizePattern = (pattern) => {
|
|
9
|
-
if (typeof pattern ===
|
|
9
|
+
if (typeof pattern === "string") {
|
|
10
10
|
return pattern;
|
|
11
11
|
}
|
|
12
12
|
if (pattern instanceof RegExp) {
|
|
@@ -37,18 +37,25 @@ function messageDecorator(type, pattern) {
|
|
|
37
37
|
})(target, key, descriptor);
|
|
38
38
|
}
|
|
39
39
|
function adjustLogger(logger) {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
// minimal logger interface required by the library
|
|
41
|
+
for (const method of ["debug", "info", "warn", "error"]) {
|
|
42
|
+
if (typeof logger[method] !== "function") {
|
|
43
|
+
throw new Error(`Logger must implement "${method}" method`);
|
|
44
|
+
}
|
|
42
45
|
}
|
|
46
|
+
const noop = () => {
|
|
47
|
+
};
|
|
43
48
|
return Object.assign(logger, {
|
|
44
49
|
setLevel(_) {
|
|
45
50
|
// don't allow library to set the level
|
|
46
51
|
},
|
|
47
|
-
setName(
|
|
48
|
-
//
|
|
52
|
+
setName(name) {
|
|
53
|
+
// setContext is alias for setName
|
|
54
|
+
(logger.setName ?? logger.setContext ?? noop)(name);
|
|
49
55
|
},
|
|
50
56
|
getLevel() {
|
|
51
|
-
// always return the lowest supported level
|
|
57
|
+
// always return the lowest supported level (by library, not real logger)
|
|
58
|
+
// to avoid filtering log messages by library instead of real logger
|
|
52
59
|
return bolt_1.LogLevel.DEBUG;
|
|
53
60
|
},
|
|
54
61
|
});
|