@certik/skynet 0.23.0 → 0.24.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/CHANGELOG.md +6 -0
- package/dist/slack.d.ts +6 -1
- package/dist/slack.js +2 -5
- package/package.json +1 -3
- package/src/slack.ts +16 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.24.0
|
|
4
|
+
|
|
5
|
+
- BREAKING: `slack` `postMessageToConversation` no longer accepts `ChatPostMessageArguments` when `conversationId` is provided; pass a full `ChatPostMessageArguments` payload with `conversationId` omitted instead
|
|
6
|
+
- `slack`: improve type-safety for `postMessageToConversation` and post the payload directly
|
|
7
|
+
- Remove unused `md5` dependency and `@types/md5`
|
|
8
|
+
|
|
3
9
|
## 0.23.0
|
|
4
10
|
|
|
5
11
|
- Added `goalert` module with `sendGoAlertAlert` helper
|
package/dist/slack.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { ChatPostMessageArguments } from "@slack/web-api";
|
|
2
2
|
declare function postMessageToConversation({ conversationId, message, token, verbose, }: {
|
|
3
3
|
conversationId: string;
|
|
4
|
-
message: string
|
|
4
|
+
message: string;
|
|
5
|
+
token?: string;
|
|
6
|
+
verbose?: boolean;
|
|
7
|
+
} | {
|
|
8
|
+
conversationId: undefined;
|
|
9
|
+
message: ChatPostMessageArguments;
|
|
5
10
|
token?: string;
|
|
6
11
|
verbose?: boolean;
|
|
7
12
|
}): Promise<void>;
|
package/dist/slack.js
CHANGED
|
@@ -14,14 +14,11 @@ async function postMessageToConversation({
|
|
|
14
14
|
}
|
|
15
15
|
try {
|
|
16
16
|
const client = getClient(token);
|
|
17
|
-
const post = typeof
|
|
17
|
+
const post = typeof conversationId === "string" ? { channel: conversationId, text: message } : message;
|
|
18
18
|
if (verbose) {
|
|
19
19
|
console.log(`posting to slack conversation ${conversationId}:`, JSON.stringify(post, null, 2));
|
|
20
20
|
}
|
|
21
|
-
await client.chat.postMessage(
|
|
22
|
-
channel: conversationId,
|
|
23
|
-
...post
|
|
24
|
-
});
|
|
21
|
+
await client.chat.postMessage(post);
|
|
25
22
|
} catch (error) {
|
|
26
23
|
console.error("failed to post slack message", error);
|
|
27
24
|
throw error;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@certik/skynet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Skynet Shared JS library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -121,7 +121,6 @@
|
|
|
121
121
|
"chalk": "^5.6.2",
|
|
122
122
|
"execa": "^9.6.1",
|
|
123
123
|
"express": "^5.2.1",
|
|
124
|
-
"md5": "^2.3.0",
|
|
125
124
|
"meow": "^14.0.0",
|
|
126
125
|
"p-memoize": "^8.0.0",
|
|
127
126
|
"p-throttle": "^8.1.0",
|
|
@@ -133,7 +132,6 @@
|
|
|
133
132
|
"@eslint/js": "^9.39.2",
|
|
134
133
|
"@types/bun": "^1.3.6",
|
|
135
134
|
"@types/express": "^5.0.6",
|
|
136
|
-
"@types/md5": "^2.3.6",
|
|
137
135
|
"@types/which": "^3.0.4",
|
|
138
136
|
"eslint": "^9.39.2",
|
|
139
137
|
"eslint-plugin-import": "^2.32.0",
|
package/src/slack.ts
CHANGED
|
@@ -11,12 +11,19 @@ async function postMessageToConversation({
|
|
|
11
11
|
message,
|
|
12
12
|
token,
|
|
13
13
|
verbose,
|
|
14
|
-
}:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
}:
|
|
15
|
+
| {
|
|
16
|
+
conversationId: string;
|
|
17
|
+
message: string;
|
|
18
|
+
token?: string;
|
|
19
|
+
verbose?: boolean;
|
|
20
|
+
}
|
|
21
|
+
| {
|
|
22
|
+
conversationId?: undefined;
|
|
23
|
+
message: ChatPostMessageArguments;
|
|
24
|
+
token?: string;
|
|
25
|
+
verbose?: boolean;
|
|
26
|
+
}) {
|
|
20
27
|
if (!token) {
|
|
21
28
|
throw new Error("missing slack token");
|
|
22
29
|
}
|
|
@@ -24,16 +31,13 @@ async function postMessageToConversation({
|
|
|
24
31
|
try {
|
|
25
32
|
const client = getClient(token);
|
|
26
33
|
|
|
27
|
-
const post = typeof
|
|
34
|
+
const post = typeof conversationId === "string" ? { channel: conversationId, text: message } : message;
|
|
28
35
|
|
|
29
36
|
if (verbose) {
|
|
30
|
-
console.log(`posting to slack
|
|
37
|
+
console.log(`posting to slack:`, JSON.stringify(post, null, 2));
|
|
31
38
|
}
|
|
32
39
|
|
|
33
|
-
await client.chat.postMessage(
|
|
34
|
-
channel: conversationId,
|
|
35
|
-
...post,
|
|
36
|
-
});
|
|
40
|
+
await client.chat.postMessage(post);
|
|
37
41
|
} catch (error) {
|
|
38
42
|
console.error("failed to post slack message", error);
|
|
39
43
|
|