@theholocron/holocron-plugin-slack 5.0.0-alpha.278 → 5.0.0-alpha.279
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 +14 -0
- package/dist/index.mjs +9 -0
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { AuthError, Notifications, PluginToken, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
2
2
|
import { SlackClient, SlackClientOptions, createSlackClient } from "@theholocron/slack-client";
|
|
3
|
+
/** Resolves the Slack bot token from `--token`, `HOLOCRON_SLACK_TOKEN`, `SLACK_BOT_TOKEN` or the keyring entry for `slack`, and throws `AuthError` when none is set. */
|
|
3
4
|
export declare const resolveToken: import("@theholocron/cli").TokenResolver;
|
|
4
5
|
/** Every token this plugin takes, for `holocron doctor tokens`. */
|
|
5
6
|
export declare const tokens: PluginToken[];
|
|
7
|
+
/** Options for the Slack `notifications` capability. */
|
|
6
8
|
interface SlackNotificationsOptions {
|
|
7
9
|
/** Default channel id used when `send()` is called without an explicit channel. */
|
|
8
10
|
defaultChannel?: string;
|
|
9
11
|
}
|
|
12
|
+
/** `notifications` capability for Slack: posts messages to a channel as the bot. */
|
|
10
13
|
export declare class SlackNotifications implements Notifications {
|
|
11
14
|
/** Memoized client thunk — resolves the token on first authenticated call. */
|
|
12
15
|
private readonly client;
|
|
13
16
|
private readonly opts;
|
|
17
|
+
/** Capability key; always `"notifications"`. */
|
|
14
18
|
readonly key: "notifications";
|
|
19
|
+
/** Provider name; always `"slack"`. */
|
|
15
20
|
readonly providerName = "slack";
|
|
16
21
|
constructor(
|
|
17
22
|
/** Memoized client thunk — resolves the token on first authenticated call. */
|
|
@@ -22,19 +27,27 @@ interface VerifyTokenOptions {
|
|
|
22
27
|
baseUrl?: string;
|
|
23
28
|
fetch?: typeof fetch;
|
|
24
29
|
}
|
|
30
|
+
/** Checks a Slack bot token with `auth.test` and reports the bot user and workspace, or why it was rejected. */
|
|
25
31
|
export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
|
|
32
|
+
/** Options for the Slack plugin: the token lookup inputs plus the notification defaults. */
|
|
26
33
|
export interface SlackPluginOptions extends ResolveTokenInput, SlackNotificationsOptions {
|
|
27
34
|
/** Override base URL for tests. Default: https://slack.com/api */
|
|
28
35
|
baseUrl?: string;
|
|
36
|
+
/** Override `fetch` for tests. */
|
|
29
37
|
fetch?: typeof fetch;
|
|
30
38
|
}
|
|
39
|
+
/** Shared state for one Slack plugin instance: its options and a lazily created client. */
|
|
31
40
|
export interface PluginContext {
|
|
41
|
+
/** The options the plugin was created with. */
|
|
32
42
|
options: SlackPluginOptions;
|
|
33
43
|
/** Memoized client — the token is resolved on first use, not at plugin load. */
|
|
34
44
|
client: () => SlackClient;
|
|
35
45
|
}
|
|
46
|
+
/** Builds the plugin context from its options. */
|
|
36
47
|
export declare function createContext(options?: SlackPluginOptions): PluginContext;
|
|
48
|
+
/** Builds the `notifications` capability for the context. */
|
|
37
49
|
export declare function notifications(ctx: PluginContext): Notifications;
|
|
50
|
+
/** Creates the Slack plugin: its `connection` probe and the `notifications` capability. */
|
|
38
51
|
export declare function createPlugin(options?: SlackPluginOptions): {
|
|
39
52
|
name: string;
|
|
40
53
|
probes: {
|
|
@@ -44,5 +57,6 @@ export declare function createPlugin(options?: SlackPluginOptions): {
|
|
|
44
57
|
notifications: () => Notifications;
|
|
45
58
|
};
|
|
46
59
|
};
|
|
60
|
+
/** Hint printed by `holocron auth set slack` when no token is supplied or the token is rejected; explains how to create a bot token. */
|
|
47
61
|
export declare const AUTH_HINT: string;
|
|
48
62
|
export { AuthError, type ResolveTokenInput, type SlackClient, type SlackClientOptions, type SlackNotificationsOptions, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createSlackClient };
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { AuthError, connectionProbe, createResolveToken } from "@theholocron/cli
|
|
|
2
2
|
import { createSlackClient } from "@theholocron/slack-client";
|
|
3
3
|
import { errorMessage } from "@theholocron/misc-utils";
|
|
4
4
|
// src/auth.ts
|
|
5
|
+
/** Resolves the Slack bot token from `--token`, `HOLOCRON_SLACK_TOKEN`, `SLACK_BOT_TOKEN` or the keyring entry for `slack`, and throws `AuthError` when none is set. */
|
|
5
6
|
const resolveToken = createResolveToken({
|
|
6
7
|
envName: "HOLOCRON_SLACK_TOKEN",
|
|
7
8
|
vendorEnvName: "SLACK_BOT_TOKEN",
|
|
@@ -11,10 +12,13 @@ const resolveToken = createResolveToken({
|
|
|
11
12
|
/** Every token this plugin takes, for `holocron doctor tokens`. */
|
|
12
13
|
const tokens = [resolveToken.token];
|
|
13
14
|
// src/capabilities/notifications.ts
|
|
15
|
+
/** `notifications` capability for Slack: posts messages to a channel as the bot. */
|
|
14
16
|
var SlackNotifications = class {
|
|
15
17
|
client;
|
|
16
18
|
opts;
|
|
19
|
+
/** Capability key; always `"notifications"`. */
|
|
17
20
|
key = "notifications";
|
|
21
|
+
/** Provider name; always `"slack"`. */
|
|
18
22
|
providerName = "slack";
|
|
19
23
|
constructor(client, opts) {
|
|
20
24
|
this.client = client;
|
|
@@ -27,6 +31,7 @@ var SlackNotifications = class {
|
|
|
27
31
|
}
|
|
28
32
|
};
|
|
29
33
|
// src/verify-token.ts
|
|
34
|
+
/** Checks a Slack bot token with `auth.test` and reports the bot user and workspace, or why it was rejected. */
|
|
30
35
|
async function verifyToken(token, opts = {}) {
|
|
31
36
|
const client = createSlackClient({
|
|
32
37
|
token,
|
|
@@ -47,6 +52,7 @@ async function verifyToken(token, opts = {}) {
|
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
54
|
// src/index.ts
|
|
55
|
+
/** Builds the plugin context from its options. */
|
|
50
56
|
function createContext(options = {}) {
|
|
51
57
|
let client;
|
|
52
58
|
return {
|
|
@@ -58,9 +64,11 @@ function createContext(options = {}) {
|
|
|
58
64
|
})
|
|
59
65
|
};
|
|
60
66
|
}
|
|
67
|
+
/** Builds the `notifications` capability for the context. */
|
|
61
68
|
function notifications(ctx) {
|
|
62
69
|
return new SlackNotifications(ctx.client, ctx.options);
|
|
63
70
|
}
|
|
71
|
+
/** Creates the Slack plugin: its `connection` probe and the `notifications` capability. */
|
|
64
72
|
function createPlugin(options = {}) {
|
|
65
73
|
const ctx = createContext(options);
|
|
66
74
|
return {
|
|
@@ -78,5 +86,6 @@ function createPlugin(options = {}) {
|
|
|
78
86
|
capabilities: { notifications: () => notifications(ctx) }
|
|
79
87
|
};
|
|
80
88
|
}
|
|
89
|
+
/** Hint printed by `holocron auth set slack` when no token is supplied or the token is rejected; explains how to create a bot token. */
|
|
81
90
|
const AUTH_HINT = "create a Slack app at https://api.slack.com/apps, add the chat:write bot scope, install it to your workspace, copy the Bot User OAuth Token (xoxb-...), then run: holocron auth set slack <xoxb-TOKEN>";
|
|
82
91
|
export { AUTH_HINT, AuthError, SlackNotifications, createContext, createPlugin, createSlackClient, notifications, resolveToken, tokens, verifyToken };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-slack",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.279",
|
|
4
4
|
"description": "Holocron plugin for Slack. Implements the notifications capability via Slack's bot API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"holocron",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"tsx": "4.23.15",
|
|
42
42
|
"typescript": "^5.9.3",
|
|
43
43
|
"vitest": "^5.0.5",
|
|
44
|
+
"@theholocron/cli": "5.0.0-alpha.279",
|
|
44
45
|
"@theholocron/eslint-config": "^8.9.0-alpha.4",
|
|
45
46
|
"@theholocron/http-client": "^1.58.0-alpha.3",
|
|
46
47
|
"@theholocron/misc-utils": "^1.16.1-alpha.3",
|
|
47
48
|
"@theholocron/slack-client": "^1.58.0-alpha.3",
|
|
48
|
-
"@theholocron/cli": "5.0.0-alpha.278",
|
|
49
49
|
"@theholocron/tsconfig": "^8.9.0-alpha.4",
|
|
50
50
|
"@theholocron/tsdown-config": "^8.9.0-alpha.4",
|
|
51
51
|
"@theholocron/vitest-config": "^8.9.0-alpha.4"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@theholocron/misc-utils": "^1.16.0",
|
|
55
55
|
"@theholocron/slack-client": "^1.43.1",
|
|
56
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
56
|
+
"@theholocron/cli": "5.0.0-alpha.279"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=22"
|