@theholocron/slack-client 1.58.0-alpha.1 → 1.58.0-alpha.10
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/index.d.mts +7 -0
- package/dist/index.mjs +7 -2
- package/package.json +15 -15
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Options for `createSlackClient`. */
|
|
1
2
|
interface SlackClientOptions {
|
|
2
3
|
/** Slack bot/user OAuth token. */
|
|
3
4
|
token: string;
|
|
@@ -6,11 +7,16 @@ interface SlackClientOptions {
|
|
|
6
7
|
/** Override fetch for testing. Defaults to globalThis.fetch. */
|
|
7
8
|
fetch?: typeof fetch;
|
|
8
9
|
}
|
|
10
|
+
/** The response of Slack's `auth.test`, which checks a token. */
|
|
9
11
|
interface SlackAuthTest {
|
|
12
|
+
/** Always `true`: a response with `ok: false` is thrown as a `ProviderApiError` instead. */
|
|
10
13
|
ok: true;
|
|
14
|
+
/** The name of the workspace the token belongs to. */
|
|
11
15
|
team: string;
|
|
16
|
+
/** The name of the user the token belongs to. */
|
|
12
17
|
user: string;
|
|
13
18
|
}
|
|
19
|
+
/** Creates a Slack API client with `auth` and `chat` groups, both sharing one REST client. */
|
|
14
20
|
export declare function createSlackClient(opts: SlackClientOptions): {
|
|
15
21
|
auth: {
|
|
16
22
|
test: () => Promise<SlackAuthTest>;
|
|
@@ -19,5 +25,6 @@ export declare function createSlackClient(opts: SlackClientOptions): {
|
|
|
19
25
|
postMessage: (channel: string, text: string) => Promise<void>;
|
|
20
26
|
};
|
|
21
27
|
};
|
|
28
|
+
/** The client `createSlackClient` returns. */
|
|
22
29
|
export type SlackClient = ReturnType<typeof createSlackClient>;
|
|
23
30
|
export type { SlackAuthTest, SlackClientOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { ProviderApiError } from "@theholocron/http-client";
|
|
2
2
|
// src/auth/auth.ts
|
|
3
3
|
function auth(rest) {
|
|
4
|
-
return {
|
|
4
|
+
return {
|
|
5
|
+
/** Verify the token's identity (`POST auth.test`). */
|
|
6
|
+
test: () => rest.call("auth.test", {}) };
|
|
5
7
|
}
|
|
6
8
|
// src/chat/chat.ts
|
|
7
9
|
function chat(rest) {
|
|
8
|
-
return {
|
|
10
|
+
return {
|
|
11
|
+
/** Send a message to a channel (`POST chat.postMessage`). */
|
|
12
|
+
postMessage: async (channel, text) => {
|
|
9
13
|
await rest.call("chat.postMessage", {
|
|
10
14
|
channel,
|
|
11
15
|
text
|
|
@@ -45,6 +49,7 @@ function createSlackRestClient(opts) {
|
|
|
45
49
|
} };
|
|
46
50
|
}
|
|
47
51
|
// src/index.ts
|
|
52
|
+
/** Creates a Slack API client with `auth` and `chat` groups, both sharing one REST client. */
|
|
48
53
|
function createSlackClient(opts) {
|
|
49
54
|
const rest = createSlackRestClient(opts);
|
|
50
55
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/slack-client",
|
|
3
|
-
"version": "1.58.0-alpha.
|
|
3
|
+
"version": "1.58.0-alpha.10",
|
|
4
4
|
"description": "A TypeScript client for the Slack Web API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"slack",
|
|
@@ -32,22 +32,22 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@theholocron/http-client": "^1.58.0-alpha.
|
|
35
|
+
"@theholocron/http-client": "^1.58.0-alpha.10"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^26",
|
|
39
39
|
"@vitest/coverage-v8": "^5.0.5",
|
|
40
|
-
"@vitest/eslint-plugin": "^1.6.
|
|
41
|
-
"eslint": "^10.
|
|
42
|
-
"eslint-plugin-n": "^18.
|
|
43
|
-
"globals": "^17.
|
|
44
|
-
"tsdown": "^0.23.
|
|
40
|
+
"@vitest/eslint-plugin": "^1.6.28",
|
|
41
|
+
"eslint": "^10.14.0",
|
|
42
|
+
"eslint-plugin-n": "^18.5.0",
|
|
43
|
+
"globals": "^17.14.0",
|
|
44
|
+
"tsdown": "^0.23.4",
|
|
45
45
|
"typescript": "^5.9.3",
|
|
46
46
|
"vitest": "^5.0.5",
|
|
47
|
-
"@theholocron/
|
|
48
|
-
"@theholocron/
|
|
49
|
-
"@theholocron/
|
|
50
|
-
"@theholocron/vitest-config": "^8.9.0-alpha.
|
|
47
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.8",
|
|
48
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.8",
|
|
49
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.8",
|
|
50
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.8"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": ">=22.0.0"
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
|
-
"
|
|
60
|
-
"
|
|
59
|
+
"build": "tsdown && node ../scripts/check-bundle-size.mjs",
|
|
60
|
+
"lint:code": "eslint .",
|
|
61
|
+
"test:unit": "vitest run --coverage",
|
|
61
62
|
"test:watch": "vitest",
|
|
62
|
-
"
|
|
63
|
-
"verification.unitTests": "vitest run"
|
|
63
|
+
"typecheck": "tsc --noEmit"
|
|
64
64
|
}
|
|
65
65
|
}
|