@theholocron/holocron-plugin-slack 5.0.0-alpha.13 → 5.0.0-alpha.132

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 CHANGED
@@ -1,28 +1,8 @@
1
- import { AuthError, Notifications, ResolveTokenInput } from "@theholocron/cli";
1
+ import { AuthError, Notifications, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
2
+ import { SlackClient, SlackClientOptions, createSlackClient } from "@theholocron/slack-client";
2
3
  //#region src/auth.d.ts
3
4
  declare const resolveToken: (input?: ResolveTokenInput) => string;
4
5
  //#endregion
5
- //#region src/rest.d.ts
6
- interface SlackClientOptions {
7
- token: string;
8
- /** Override base URL for tests. Default: https://slack.com/api */
9
- baseUrl?: string;
10
- fetch?: typeof fetch;
11
- }
12
- interface SlackClient {
13
- auth: {
14
- test(): Promise<{
15
- ok: true;
16
- team: string;
17
- user: string;
18
- }>;
19
- };
20
- chat: {
21
- postMessage(channel: string, text: string): Promise<void>;
22
- };
23
- }
24
- declare function createSlackClient({ token, baseUrl, fetch: fetchImpl }: SlackClientOptions): SlackClient;
25
- //#endregion
26
6
  //#region src/capabilities/notifications.d.ts
27
7
  interface SlackNotificationsOptions {
28
8
  /** Default channel id used when `send()` is called without an explicit channel. */
@@ -41,20 +21,11 @@ declare class SlackNotifications implements Notifications {
41
21
  }
42
22
  //#endregion
43
23
  //#region src/verify-token.d.ts
44
- interface VerifyTokenSuccess {
45
- ok: true;
46
- subject: string;
47
- }
48
- interface VerifyTokenFailure {
49
- ok: false;
50
- message: string;
51
- }
52
- type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
53
24
  interface VerifyTokenOptions {
54
25
  baseUrl?: string;
55
26
  fetch?: typeof fetch;
56
27
  }
57
- declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult>;
28
+ declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
58
29
  //#endregion
59
30
  //#region src/index.d.ts
60
31
  interface SlackPluginOptions extends ResolveTokenInput, SlackNotificationsOptions {
package/dist/index.mjs CHANGED
@@ -1,4 +1,6 @@
1
- import { AuthError, ProviderApiError, createResolveToken } from "@theholocron/cli";
1
+ import { AuthError, createResolveToken } from "@theholocron/cli";
2
+ import { createSlackClient } from "@theholocron/slack-client";
3
+ import { errorMessage } from "@theholocron/misc-utils";
2
4
  //#region src/auth.ts
3
5
  const resolveToken = createResolveToken({
4
6
  envName: "HOLOCRON_SLACK_TOKEN",
@@ -24,34 +26,6 @@ var SlackNotifications = class {
24
26
  }
25
27
  };
26
28
  //#endregion
27
- //#region src/rest.ts
28
- function createSlackClient({ token, baseUrl, fetch: fetchImpl }) {
29
- const base = baseUrl ?? "https://slack.com/api";
30
- const f = fetchImpl ?? globalThis.fetch;
31
- async function call(method, body) {
32
- const res = await f(`${base}/${method}`, {
33
- method: "POST",
34
- headers: {
35
- "content-type": "application/json; charset=utf-8",
36
- authorization: `Bearer ${token}`
37
- },
38
- body: JSON.stringify(body)
39
- });
40
- const data = await res.json();
41
- if (!data.ok) throw new ProviderApiError(data.error ?? "unknown Slack error", res.status, data);
42
- return data;
43
- }
44
- return {
45
- auth: { test: () => call("auth.test", {}) },
46
- chat: { postMessage: async (channel, text) => {
47
- await call("chat.postMessage", {
48
- channel,
49
- text
50
- });
51
- } }
52
- };
53
- }
54
- //#endregion
55
29
  //#region src/verify-token.ts
56
30
  async function verifyToken(token, opts = {}) {
57
31
  const client = createSlackClient({
@@ -68,7 +42,7 @@ async function verifyToken(token, opts = {}) {
68
42
  } catch (err) {
69
43
  return {
70
44
  ok: false,
71
- message: err instanceof Error ? err.message : String(err)
45
+ message: errorMessage(err)
72
46
  };
73
47
  }
74
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-slack",
3
- "version": "5.0.0-alpha.13",
3
+ "version": "5.0.0-alpha.132",
4
4
  "description": "Holocron plugin for Slack. Implements the notifications capability via Slack's bot API.",
5
5
  "keywords": [
6
6
  "holocron",
@@ -8,12 +8,12 @@
8
8
  "plugin",
9
9
  "slack"
10
10
  ],
11
- "homepage": "https://github.com/theholocron/holocron/tree/main/packages/holocron-plugin-slack#readme",
11
+ "homepage": "https://github.com/theholocron/holocron/tree/main/plugins/holocron-plugin-slack#readme",
12
12
  "bugs": "https://github.com/theholocron/holocron/issues",
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "git+https://github.com/theholocron/holocron.git",
16
- "directory": "packages/holocron-plugin-slack"
16
+ "directory": "plugins/holocron-plugin-slack"
17
17
  },
18
18
  "license": "MIT",
19
19
  "author": "Newton Koumantzelis",
@@ -30,10 +30,13 @@
30
30
  "dist"
31
31
  ],
32
32
  "devDependencies": {
33
- "@theholocron/eslint-config": "^8.0.0",
34
- "@theholocron/tsconfig": "^8.0.0",
35
- "@theholocron/tsdown-config": "^8.0.0",
36
- "@theholocron/vitest-config": "^8.0.0",
33
+ "@theholocron/eslint-config": "^8.7.1",
34
+ "@theholocron/http-client": "^1.40.0",
35
+ "@theholocron/misc-utils": "^1.9.2",
36
+ "@theholocron/slack-client": "^1.40.0",
37
+ "@theholocron/tsconfig": "^8.7.1",
38
+ "@theholocron/tsdown-config": "^8.7.1",
39
+ "@theholocron/vitest-config": "^8.7.0",
37
40
  "@types/node": "^26",
38
41
  "@vitest/coverage-v8": "^4.1.11",
39
42
  "@vitest/eslint-plugin": "^1.6.27",
@@ -45,10 +48,12 @@
45
48
  "tsx": "4.23.12",
46
49
  "typescript": "^5.9.3",
47
50
  "vitest": "^4.1.11",
48
- "@theholocron/cli": "5.0.0-alpha.13"
51
+ "@theholocron/cli": "5.0.0-alpha.134"
49
52
  },
50
53
  "peerDependencies": {
51
- "@theholocron/cli": "5.0.0-alpha.13"
54
+ "@theholocron/misc-utils": "^1.9.2",
55
+ "@theholocron/slack-client": "^1.40.0",
56
+ "@theholocron/cli": "5.0.0-alpha.134"
52
57
  },
53
58
  "engines": {
54
59
  "node": ">=22"