slackblock 1.0.1 → 2.0.0-beta.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 +66 -0
- package/README.md +228 -69
- package/dist/block.cjs +79 -124
- package/dist/block.cjs.map +1 -1
- package/dist/{block.d.mts → block.d.cts} +129 -94
- package/dist/block.d.ts +129 -94
- package/dist/block.mjs +80 -114
- package/dist/block.mjs.map +1 -1
- package/dist/index.cjs +283 -184
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -0
- package/dist/index.d.ts +20 -6
- package/dist/index.mjs +276 -174
- package/dist/index.mjs.map +1 -1
- package/dist/types.d-BHoTwZUO.d.cts +124 -0
- package/dist/types.d-BHoTwZUO.d.ts +124 -0
- package/package.json +20 -33
- package/dist/index.d.mts +0 -8
- package/dist/types.d-uPVIHLKj.d.mts +0 -57
- package/dist/types.d-uPVIHLKj.d.ts +0 -57
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { KnownBlock, Block as Block$1, MessageAttachment, MessageMetadata, EntityMetadata } from '@slack/types';
|
|
2
|
+
|
|
3
|
+
type Channel = {
|
|
4
|
+
channel: string;
|
|
5
|
+
};
|
|
6
|
+
type Text = {
|
|
7
|
+
text: string;
|
|
8
|
+
};
|
|
9
|
+
type MarkdownText = {
|
|
10
|
+
markdown_text: string;
|
|
11
|
+
};
|
|
12
|
+
type ChannelAndText = Channel & Text;
|
|
13
|
+
type ChannelAndBlocks = Channel & Partial<Text> & {
|
|
14
|
+
blocks: Array<KnownBlock | Block$1>;
|
|
15
|
+
};
|
|
16
|
+
type ChannelAndAttachments = Channel & Partial<Text> & {
|
|
17
|
+
attachments: MessageAttachment[];
|
|
18
|
+
};
|
|
19
|
+
type ChannelAndMarkdownText = Channel & MarkdownText;
|
|
20
|
+
type LinkNames = {
|
|
21
|
+
link_names?: boolean;
|
|
22
|
+
};
|
|
23
|
+
type Parse = {
|
|
24
|
+
parse?: 'full' | 'none';
|
|
25
|
+
};
|
|
26
|
+
type Unfurls = {
|
|
27
|
+
unfurl_links?: boolean;
|
|
28
|
+
unfurl_media?: boolean;
|
|
29
|
+
};
|
|
30
|
+
type IconEmoji = {
|
|
31
|
+
as_user?: false;
|
|
32
|
+
icon_url?: never;
|
|
33
|
+
icon_emoji?: string;
|
|
34
|
+
};
|
|
35
|
+
type IconURL = {
|
|
36
|
+
as_user?: false;
|
|
37
|
+
icon_emoji?: never;
|
|
38
|
+
icon_url?: string;
|
|
39
|
+
};
|
|
40
|
+
type Username = {
|
|
41
|
+
as_user?: false;
|
|
42
|
+
username?: string;
|
|
43
|
+
};
|
|
44
|
+
type WithinThreadReply = {
|
|
45
|
+
thread_ts?: string;
|
|
46
|
+
reply_broadcast?: false;
|
|
47
|
+
};
|
|
48
|
+
type BroadcastedThreadReply = {
|
|
49
|
+
thread_ts: string;
|
|
50
|
+
reply_broadcast: boolean;
|
|
51
|
+
};
|
|
52
|
+
type ChatPostMessageMetadata = {
|
|
53
|
+
metadata?: Partial<MessageMetadata> & {
|
|
54
|
+
entities?: EntityMetadata[];
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
type MessageContents = ChannelAndText | ChannelAndBlocks | ChannelAndAttachments | ChannelAndMarkdownText;
|
|
58
|
+
type ReplyInThread = WithinThreadReply | BroadcastedThreadReply;
|
|
59
|
+
type Authorship = ((IconEmoji | IconURL) & Username) | {
|
|
60
|
+
as_user: true;
|
|
61
|
+
icon_emoji?: never;
|
|
62
|
+
icon_url?: never;
|
|
63
|
+
username?: never;
|
|
64
|
+
};
|
|
65
|
+
type ChatPostMessageArguments = {
|
|
66
|
+
token?: string;
|
|
67
|
+
} & MessageContents & ReplyInThread & Authorship & Parse & LinkNames & ChatPostMessageMetadata & Unfurls & {
|
|
68
|
+
mrkdwn?: boolean;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
type Block = KnownBlock | Block$1;
|
|
72
|
+
|
|
73
|
+
type InteractiveBlockElement = JSX.Element;
|
|
74
|
+
|
|
75
|
+
type InputBlockElement = JSX.Element;
|
|
76
|
+
type BlockElement = JSX.Element;
|
|
77
|
+
|
|
78
|
+
type SlackMessageContents =
|
|
79
|
+
| Omit<ChannelAndText, 'channel'>
|
|
80
|
+
| Omit<ChannelAndBlocks, 'channel'>
|
|
81
|
+
| Omit<ChannelAndAttachments, 'channel'>
|
|
82
|
+
| Omit<ChannelAndMarkdownText, 'channel'>;
|
|
83
|
+
|
|
84
|
+
type SlackAuthorship =
|
|
85
|
+
| ((IconEmoji | IconURL) & Username)
|
|
86
|
+
| {
|
|
87
|
+
as_user: true;
|
|
88
|
+
icon_emoji?: never;
|
|
89
|
+
icon_url?: never;
|
|
90
|
+
username?: never;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
type SlackThreadReply = WithinThreadReply | BroadcastedThreadReply;
|
|
94
|
+
|
|
95
|
+
type SlackMessageBase = SlackMessageContents
|
|
96
|
+
& SlackThreadReply
|
|
97
|
+
& SlackAuthorship
|
|
98
|
+
& Parse
|
|
99
|
+
& LinkNames
|
|
100
|
+
& Unfurls
|
|
101
|
+
& ChatPostMessageMetadata
|
|
102
|
+
& {mrkdwn?: boolean};
|
|
103
|
+
|
|
104
|
+
type SlackMessage = SlackMessageBase & Omit<ChatPostMessageArguments, 'channel' | 'token'>;
|
|
105
|
+
|
|
106
|
+
type AnyFunction = (...parameters: unknown[]) => unknown;
|
|
107
|
+
|
|
108
|
+
type AnyConstructor = new (...parameters: unknown[]) => unknown;
|
|
109
|
+
|
|
110
|
+
type WithType = {
|
|
111
|
+
type?: string | AnyFunction | AnyConstructor;
|
|
112
|
+
};
|
|
113
|
+
type BElement = JSX.Element & WithType;
|
|
114
|
+
type Element = BElement;
|
|
115
|
+
type Child =
|
|
116
|
+
| string
|
|
117
|
+
| Element
|
|
118
|
+
| Child[]
|
|
119
|
+
| boolean
|
|
120
|
+
| undefined
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-types -- React children can be null.
|
|
122
|
+
| null;
|
|
123
|
+
|
|
124
|
+
export type { Block as B, Child as C, Element as E, InteractiveBlockElement as I, SlackMessage as S, InputBlockElement as a, BlockElement as b };
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "slackblock",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
4
|
"description": "JSX-based Slack message renderer",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": ">=
|
|
6
|
+
"node": ">=20"
|
|
7
7
|
},
|
|
8
|
-
"
|
|
8
|
+
"type": "module",
|
|
9
9
|
"main": "dist/index.cjs",
|
|
10
10
|
"module": "dist/index.mjs",
|
|
11
11
|
"types": "dist/index.d.ts",
|
|
@@ -33,29 +33,18 @@
|
|
|
33
33
|
"default": "./dist/block.cjs"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
+
"sideEffects": false,
|
|
36
37
|
"files": [
|
|
37
38
|
"dist",
|
|
38
39
|
"README.md",
|
|
39
40
|
"LICENSE",
|
|
40
41
|
"CHANGELOG.md"
|
|
41
42
|
],
|
|
42
|
-
"scripts": {
|
|
43
|
-
"prepare": "husky install",
|
|
44
|
-
"test": "pnpm run test:tsc && pnpm run test:lint && pnpm run test:unit",
|
|
45
|
-
"test:tsc": "tsc -p ./src -p ./test --noEmit",
|
|
46
|
-
"test:lint": "xo",
|
|
47
|
-
"test:unit": "vitest run",
|
|
48
|
-
"prebuild": "pnpm run clean",
|
|
49
|
-
"clean": "rimraf ./dist",
|
|
50
|
-
"build": "tsup",
|
|
51
|
-
"prepublish": "pnpm run test && pnpm run build"
|
|
52
|
-
},
|
|
53
43
|
"repository": {
|
|
54
44
|
"type": "git",
|
|
55
45
|
"url": "git+https://github.com/kolyaventuri/block.git"
|
|
56
46
|
},
|
|
57
47
|
"keywords": [
|
|
58
|
-
"react",
|
|
59
48
|
"slack",
|
|
60
49
|
"message",
|
|
61
50
|
"bot"
|
|
@@ -67,42 +56,40 @@
|
|
|
67
56
|
},
|
|
68
57
|
"homepage": "https://github.com/kolyaventuri/block#readme",
|
|
69
58
|
"devDependencies": {
|
|
59
|
+
"@changesets/cli": "^2.30.0",
|
|
70
60
|
"@types/node": "25.0.10",
|
|
71
|
-
"@types/react": "^19.2.9",
|
|
72
61
|
"@typescript-eslint/eslint-plugin": "^8.53.1",
|
|
73
62
|
"@typescript-eslint/parser": "^8.53.1",
|
|
63
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
74
64
|
"eslint": "^9.39.2",
|
|
75
65
|
"eslint-config-xo": "^0.49.0",
|
|
76
|
-
"eslint-config-xo-react": "^0.29.0",
|
|
77
66
|
"eslint-config-xo-typescript": "^9.0.0",
|
|
78
|
-
"eslint-plugin-react": "^7.37.5",
|
|
79
|
-
"eslint-plugin-react-hooks": "^7.0.1",
|
|
80
67
|
"husky": "^9.1.7",
|
|
68
|
+
"knip": "^5.85.0",
|
|
81
69
|
"lint-staged": "^16.2.7",
|
|
82
|
-
"react": "^19.2.3",
|
|
83
70
|
"rimraf": "^6.1.2",
|
|
84
71
|
"tsup": "^8.5.1",
|
|
85
72
|
"typescript": "^5.9.3",
|
|
86
73
|
"vitest": "^4.0.18",
|
|
87
74
|
"xo": "^1.2.3"
|
|
88
75
|
},
|
|
89
|
-
"peerDependencies": {
|
|
90
|
-
"react": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
91
|
-
},
|
|
92
76
|
"dependencies": {
|
|
93
|
-
"@slack/types": "^2.19.0"
|
|
94
|
-
"@slack/web-api": "^7.14.1"
|
|
95
|
-
},
|
|
96
|
-
"pnpm": {
|
|
97
|
-
"overrides": {
|
|
98
|
-
"@eslint/plugin-kit": "^0.3.4",
|
|
99
|
-
"minimatch": "^10.2.3",
|
|
100
|
-
"rollup": "^4.59.0"
|
|
101
|
-
}
|
|
77
|
+
"@slack/types": "^2.19.0"
|
|
102
78
|
},
|
|
103
79
|
"lint-staged": {
|
|
104
80
|
"*.{ts,tsx}": [
|
|
105
81
|
"xo"
|
|
106
82
|
]
|
|
83
|
+
},
|
|
84
|
+
"scripts": {
|
|
85
|
+
"test": "pnpm run test:tsc && pnpm run test:lint && pnpm run test:knip && pnpm run test:unit",
|
|
86
|
+
"test:tsc": "tsc -p tsconfig.json --noEmit && tsc -p test/tsconfig.json --noEmit",
|
|
87
|
+
"test:lint": "xo --fix",
|
|
88
|
+
"test:knip": "knip",
|
|
89
|
+
"test:unit": "vitest run",
|
|
90
|
+
"prebuild": "pnpm run clean",
|
|
91
|
+
"clean": "rimraf ./dist",
|
|
92
|
+
"build": "tsup",
|
|
93
|
+
"release": "pnpm run build && changeset publish"
|
|
107
94
|
}
|
|
108
|
-
}
|
|
95
|
+
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { ChatPostMessageArguments } from '@slack/web-api';
|
|
3
|
-
import { ChannelAndText, ChannelAndBlocks, ChannelAndAttachments, ChannelAndMarkdownText, WithinThreadReply, BroadcastedThreadReply, IconEmoji, IconURL, Username, Parse, LinkNames, Unfurls, ChatPostMessageMetadata } from '@slack/web-api/dist/types/request/chat';
|
|
4
|
-
|
|
5
|
-
type InteractiveBlockElement = ReactElement<any, any>;
|
|
6
|
-
type StandardBlockElement = ReactElement<any, any>;
|
|
7
|
-
|
|
8
|
-
type InputBlockElement = ReactElement<any, any>;
|
|
9
|
-
type BlockElement = InteractiveBlockElement | StandardBlockElement | InputBlockElement;
|
|
10
|
-
|
|
11
|
-
type SlackMessageContents =
|
|
12
|
-
| Omit<ChannelAndText, 'channel'>
|
|
13
|
-
| Omit<ChannelAndBlocks, 'channel'>
|
|
14
|
-
| Omit<ChannelAndAttachments, 'channel'>
|
|
15
|
-
| Omit<ChannelAndMarkdownText, 'channel'>;
|
|
16
|
-
|
|
17
|
-
type SlackAuthorship =
|
|
18
|
-
| ((IconEmoji | IconURL) & Username)
|
|
19
|
-
| {
|
|
20
|
-
as_user: true;
|
|
21
|
-
icon_emoji?: never;
|
|
22
|
-
icon_url?: never;
|
|
23
|
-
username?: never;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
type SlackThreadReply = WithinThreadReply | BroadcastedThreadReply;
|
|
27
|
-
|
|
28
|
-
type SlackMessageBase = SlackMessageContents
|
|
29
|
-
& SlackThreadReply
|
|
30
|
-
& SlackAuthorship
|
|
31
|
-
& Parse
|
|
32
|
-
& LinkNames
|
|
33
|
-
& Unfurls
|
|
34
|
-
& ChatPostMessageMetadata
|
|
35
|
-
& {mrkdwn?: boolean};
|
|
36
|
-
|
|
37
|
-
type SlackMessage = SlackMessageBase & Omit<ChatPostMessageArguments, 'channel' | 'token'>;
|
|
38
|
-
|
|
39
|
-
type AnyFunction = (...parameters: any[]) => any;
|
|
40
|
-
|
|
41
|
-
type AnyConstructor = new (...parameters: any[]) => any;
|
|
42
|
-
|
|
43
|
-
type WithType = {
|
|
44
|
-
type?: string | AnyFunction | AnyConstructor;
|
|
45
|
-
};
|
|
46
|
-
type BElement = ReactElement<any, any> & WithType;
|
|
47
|
-
type Element = BElement;
|
|
48
|
-
type Child =
|
|
49
|
-
| string
|
|
50
|
-
| Element
|
|
51
|
-
| Child[]
|
|
52
|
-
| boolean
|
|
53
|
-
| undefined
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-types -- React children can be null.
|
|
55
|
-
| null;
|
|
56
|
-
|
|
57
|
-
export type { BlockElement as B, Child as C, Element as E, InteractiveBlockElement as I, SlackMessage as S, InputBlockElement as a };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { ChatPostMessageArguments } from '@slack/web-api';
|
|
3
|
-
import { ChannelAndText, ChannelAndBlocks, ChannelAndAttachments, ChannelAndMarkdownText, WithinThreadReply, BroadcastedThreadReply, IconEmoji, IconURL, Username, Parse, LinkNames, Unfurls, ChatPostMessageMetadata } from '@slack/web-api/dist/types/request/chat';
|
|
4
|
-
|
|
5
|
-
type InteractiveBlockElement = ReactElement<any, any>;
|
|
6
|
-
type StandardBlockElement = ReactElement<any, any>;
|
|
7
|
-
|
|
8
|
-
type InputBlockElement = ReactElement<any, any>;
|
|
9
|
-
type BlockElement = InteractiveBlockElement | StandardBlockElement | InputBlockElement;
|
|
10
|
-
|
|
11
|
-
type SlackMessageContents =
|
|
12
|
-
| Omit<ChannelAndText, 'channel'>
|
|
13
|
-
| Omit<ChannelAndBlocks, 'channel'>
|
|
14
|
-
| Omit<ChannelAndAttachments, 'channel'>
|
|
15
|
-
| Omit<ChannelAndMarkdownText, 'channel'>;
|
|
16
|
-
|
|
17
|
-
type SlackAuthorship =
|
|
18
|
-
| ((IconEmoji | IconURL) & Username)
|
|
19
|
-
| {
|
|
20
|
-
as_user: true;
|
|
21
|
-
icon_emoji?: never;
|
|
22
|
-
icon_url?: never;
|
|
23
|
-
username?: never;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
type SlackThreadReply = WithinThreadReply | BroadcastedThreadReply;
|
|
27
|
-
|
|
28
|
-
type SlackMessageBase = SlackMessageContents
|
|
29
|
-
& SlackThreadReply
|
|
30
|
-
& SlackAuthorship
|
|
31
|
-
& Parse
|
|
32
|
-
& LinkNames
|
|
33
|
-
& Unfurls
|
|
34
|
-
& ChatPostMessageMetadata
|
|
35
|
-
& {mrkdwn?: boolean};
|
|
36
|
-
|
|
37
|
-
type SlackMessage = SlackMessageBase & Omit<ChatPostMessageArguments, 'channel' | 'token'>;
|
|
38
|
-
|
|
39
|
-
type AnyFunction = (...parameters: any[]) => any;
|
|
40
|
-
|
|
41
|
-
type AnyConstructor = new (...parameters: any[]) => any;
|
|
42
|
-
|
|
43
|
-
type WithType = {
|
|
44
|
-
type?: string | AnyFunction | AnyConstructor;
|
|
45
|
-
};
|
|
46
|
-
type BElement = ReactElement<any, any> & WithType;
|
|
47
|
-
type Element = BElement;
|
|
48
|
-
type Child =
|
|
49
|
-
| string
|
|
50
|
-
| Element
|
|
51
|
-
| Child[]
|
|
52
|
-
| boolean
|
|
53
|
-
| undefined
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-types -- React children can be null.
|
|
55
|
-
| null;
|
|
56
|
-
|
|
57
|
-
export type { BlockElement as B, Child as C, Element as E, InteractiveBlockElement as I, SlackMessage as S, InputBlockElement as a };
|