@theokit/gateway-mattermost 0.1.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 +36 -0
- package/README.md +88 -0
- package/dist/index.cjs +323 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +218 -0
- package/dist/index.d.ts +218 -0
- package/dist/index.js +310 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { BasePlatformAdapter, OutboundMessage, SendResult, MessageEvent, MattermostMessageEvent } from '@theokit/gateway';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Public options + internal Mattermost shape narrowing.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
interface MattermostAdapterOptions {
|
|
9
|
+
/** Mattermost base URL, e.g. `https://mattermost.acme.com`. No trailing slash. (D400) */
|
|
10
|
+
readonly baseUrl: string;
|
|
11
|
+
/** Personal Access Token (D401). Get one in System Console → Integrations → Bot Accounts. */
|
|
12
|
+
readonly accessToken: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the bot should require an `@mention` in non-DM channels (D403).
|
|
15
|
+
* Default: `true`. Set `false` to respond to every message in joined channels.
|
|
16
|
+
*/
|
|
17
|
+
readonly requireMention?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Mattermost post shape (subset we read). Mirrors `@mattermost/types`
|
|
21
|
+
* Post but kept minimal so the package compiles without a hard dep
|
|
22
|
+
* on `@mattermost/types`.
|
|
23
|
+
*
|
|
24
|
+
* @public — exposed via `MattermostMessageEvent.mattermost.raw` typing.
|
|
25
|
+
*/
|
|
26
|
+
interface MattermostPost {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly user_id: string;
|
|
29
|
+
readonly channel_id: string;
|
|
30
|
+
readonly root_id: string;
|
|
31
|
+
readonly message: string;
|
|
32
|
+
readonly create_at: number;
|
|
33
|
+
readonly metadata?: {
|
|
34
|
+
readonly mentions?: ReadonlyArray<string>;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Mattermost channel shape (subset).
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
interface MattermostChannel {
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly team_id: string;
|
|
45
|
+
readonly type: "D" | "G" | "O" | "P" | (string & {});
|
|
46
|
+
readonly name?: string;
|
|
47
|
+
readonly display_name?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Minimal user shape returned by `getMe`.
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
interface MattermostUser {
|
|
55
|
+
readonly id: string;
|
|
56
|
+
readonly username: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Wrapper over `@mattermost/client` — lazy import + lifecycle.
|
|
61
|
+
*
|
|
62
|
+
* Owns:
|
|
63
|
+
* - Client4 (REST) for outbound posts + channel/user lookup.
|
|
64
|
+
* - WebSocketClient for real-time `posted` events.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
interface Client4Like {
|
|
68
|
+
setUrl(url: string): void;
|
|
69
|
+
setToken(token: string): void;
|
|
70
|
+
getMe(): Promise<{
|
|
71
|
+
id: string;
|
|
72
|
+
username: string;
|
|
73
|
+
}>;
|
|
74
|
+
getChannel(channelId: string): Promise<MattermostChannel>;
|
|
75
|
+
createPost(post: {
|
|
76
|
+
channel_id: string;
|
|
77
|
+
message: string;
|
|
78
|
+
root_id?: string;
|
|
79
|
+
}): Promise<MattermostPost>;
|
|
80
|
+
}
|
|
81
|
+
interface WebSocketClientLike {
|
|
82
|
+
initialize(url: string, token: string): void;
|
|
83
|
+
addMessageListener(listener: (msg: WSMessage) => void): void;
|
|
84
|
+
removeMessageListener(listener: (msg: WSMessage) => void): void;
|
|
85
|
+
close(): void;
|
|
86
|
+
}
|
|
87
|
+
interface WSMessage {
|
|
88
|
+
readonly event: string;
|
|
89
|
+
readonly data: Record<string, unknown>;
|
|
90
|
+
readonly broadcast?: {
|
|
91
|
+
readonly channel_id?: string;
|
|
92
|
+
readonly team_id?: string;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
interface MattermostClientHandle {
|
|
96
|
+
readonly client: Client4Like;
|
|
97
|
+
readonly ws: WebSocketClientLike;
|
|
98
|
+
readonly botUserId: string;
|
|
99
|
+
readonly botUsername: string;
|
|
100
|
+
/** Channel-id LRU cache (max 200) to avoid extra getChannel calls. */
|
|
101
|
+
readonly channelCache: Map<string, MattermostChannel>;
|
|
102
|
+
}
|
|
103
|
+
interface ConnectOptions {
|
|
104
|
+
readonly baseUrl: string;
|
|
105
|
+
readonly accessToken: string;
|
|
106
|
+
}
|
|
107
|
+
declare function connectMattermost(opts: ConnectOptions): Promise<MattermostClientHandle>;
|
|
108
|
+
/**
|
|
109
|
+
* Convert REST base URL to WebSocket URL:
|
|
110
|
+
* `https://x.com` → `wss://x.com/api/v4/websocket`
|
|
111
|
+
* `http://localhost:8065` → `ws://localhost:8065/api/v4/websocket`
|
|
112
|
+
*
|
|
113
|
+
* @public — exported for unit tests + consumer-side reuse.
|
|
114
|
+
*/
|
|
115
|
+
declare function wsUrlFromBase(baseUrl: string): string;
|
|
116
|
+
declare function getChannelCached(handle: MattermostClientHandle, channelId: string): Promise<MattermostChannel | undefined>;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* `MattermostAdapter` — implements BasePlatformAdapter over Client4 + WS.
|
|
120
|
+
* ADRs D397-D404.
|
|
121
|
+
*
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
declare class MattermostAdapter extends BasePlatformAdapter {
|
|
126
|
+
readonly platform: "mattermost";
|
|
127
|
+
private readonly opts;
|
|
128
|
+
private handle;
|
|
129
|
+
private inboundHandler;
|
|
130
|
+
private wsListener;
|
|
131
|
+
private connected;
|
|
132
|
+
constructor(opts: MattermostAdapterOptions);
|
|
133
|
+
connect(): Promise<boolean>;
|
|
134
|
+
disconnect(): Promise<void>;
|
|
135
|
+
sendMessage(out: OutboundMessage): Promise<SendResult>;
|
|
136
|
+
onInbound(handler: (event: MessageEvent) => Promise<void>): () => void;
|
|
137
|
+
/** Escape hatch: caller can drive REST directly when v0.1 doesn't expose a feature. */
|
|
138
|
+
getClient(): MattermostClientHandle | undefined;
|
|
139
|
+
private attachWsListener;
|
|
140
|
+
private processPostedEvent;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Parse the `data.post` JSON envelope from a Mattermost WS `posted` event.
|
|
144
|
+
*
|
|
145
|
+
* @public — exposed so consumers can drive their own WS listener too.
|
|
146
|
+
*/
|
|
147
|
+
declare function parsePostFromWS(msg: WSMessage): MattermostPost | undefined;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Typed errors for `@theokit/gateway-mattermost`.
|
|
151
|
+
*/
|
|
152
|
+
/** @knipignore — public input shape for `ConfigurationError` constructor (caller-extensible). */
|
|
153
|
+
interface ConfigurationErrorOptions {
|
|
154
|
+
readonly code: string;
|
|
155
|
+
readonly message?: string;
|
|
156
|
+
readonly detail?: string;
|
|
157
|
+
}
|
|
158
|
+
declare class ConfigurationError extends Error {
|
|
159
|
+
readonly name = "ConfigurationError";
|
|
160
|
+
readonly code: string;
|
|
161
|
+
readonly detail: string | undefined;
|
|
162
|
+
constructor(opts: ConfigurationErrorOptions);
|
|
163
|
+
}
|
|
164
|
+
declare class SDKNotInstalledError extends ConfigurationError {
|
|
165
|
+
constructor(pkgName: string);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Inbound dispatch pipeline (D403, EC-2).
|
|
170
|
+
*
|
|
171
|
+
* Order matters — these checks compose:
|
|
172
|
+
*
|
|
173
|
+
* 1. Loop guard: drop bot's own posts (D275 mirror).
|
|
174
|
+
* 2. DM channels: always respond.
|
|
175
|
+
* 3. `requireMention === false`: respond.
|
|
176
|
+
* 4. **Metadata.mentions** array contains bot user-id → respond (PRIORITY).
|
|
177
|
+
* 5. **Word-boundary text regex** `\b@${botUsername}\b` → respond.
|
|
178
|
+
* 6. Else: ignore.
|
|
179
|
+
*
|
|
180
|
+
* EC-2: substring match (`post.message.includes("@theo")`) catches
|
|
181
|
+
* `@theory_dept` and dispatches false-positive. The fix is two-fold:
|
|
182
|
+
* prefer the unambiguous `metadata.mentions` array (API-provided
|
|
183
|
+
* user-ids), and when text fallback is required, use `\b` boundaries.
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
/** @knipignore — input shape for `shouldRespond`; useful for callers wrapping the filter pipeline. */
|
|
187
|
+
interface ShouldRespondOptions {
|
|
188
|
+
readonly post: MattermostPost;
|
|
189
|
+
readonly channelType: "dm" | "group" | "thread";
|
|
190
|
+
readonly botUserId: string;
|
|
191
|
+
readonly botUsername: string;
|
|
192
|
+
readonly requireMention: boolean;
|
|
193
|
+
}
|
|
194
|
+
declare function shouldRespond(opts: ShouldRespondOptions): boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Word-boundary match for `@${botUsername}`. Word boundaries land at
|
|
197
|
+
* `\b` (start/end of `\w` regions), so `@theo` at the head of `@theory`
|
|
198
|
+
* does NOT match because `\b` is between `o` and `r` only when the
|
|
199
|
+
* NEXT char is a non-word char.
|
|
200
|
+
*
|
|
201
|
+
* @public — exported for unit tests + consumer-side reuse.
|
|
202
|
+
*/
|
|
203
|
+
declare function hasMentionWithBoundary(text: string, botUsername: string): boolean;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Inbound normalization: Mattermost Post → MattermostMessageEvent.
|
|
207
|
+
*
|
|
208
|
+
* Channel-type mapping (D402):
|
|
209
|
+
* - `D` (Direct) → `"dm"`
|
|
210
|
+
* - `G`/`O`/`P` (Group/Open/Private) → `"group"`
|
|
211
|
+
* - Posts with `root_id !== ""` → `"thread"` with `topicId = root_id` (D399).
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
declare function normalizeMattermostType(channel: MattermostChannel | undefined): "D" | "G" | "O" | "P" | (string & {});
|
|
215
|
+
declare function mapChannelType(rawType: string, hasRootId: boolean): "dm" | "group" | "thread";
|
|
216
|
+
declare function postToMessageEvent(post: MattermostPost, channel: MattermostChannel | undefined, senderUsername: string | undefined): MattermostMessageEvent;
|
|
217
|
+
|
|
218
|
+
export { ConfigurationError, MattermostAdapter, type MattermostAdapterOptions, type MattermostChannel, type MattermostPost, type MattermostUser, SDKNotInstalledError, connectMattermost, getChannelCached, hasMentionWithBoundary, mapChannelType, normalizeMattermostType, parsePostFromWS, postToMessageEvent, shouldRespond, wsUrlFromBase };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { BasePlatformAdapter, OutboundMessage, SendResult, MessageEvent, MattermostMessageEvent } from '@theokit/gateway';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Public options + internal Mattermost shape narrowing.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
interface MattermostAdapterOptions {
|
|
9
|
+
/** Mattermost base URL, e.g. `https://mattermost.acme.com`. No trailing slash. (D400) */
|
|
10
|
+
readonly baseUrl: string;
|
|
11
|
+
/** Personal Access Token (D401). Get one in System Console → Integrations → Bot Accounts. */
|
|
12
|
+
readonly accessToken: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the bot should require an `@mention` in non-DM channels (D403).
|
|
15
|
+
* Default: `true`. Set `false` to respond to every message in joined channels.
|
|
16
|
+
*/
|
|
17
|
+
readonly requireMention?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Mattermost post shape (subset we read). Mirrors `@mattermost/types`
|
|
21
|
+
* Post but kept minimal so the package compiles without a hard dep
|
|
22
|
+
* on `@mattermost/types`.
|
|
23
|
+
*
|
|
24
|
+
* @public — exposed via `MattermostMessageEvent.mattermost.raw` typing.
|
|
25
|
+
*/
|
|
26
|
+
interface MattermostPost {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly user_id: string;
|
|
29
|
+
readonly channel_id: string;
|
|
30
|
+
readonly root_id: string;
|
|
31
|
+
readonly message: string;
|
|
32
|
+
readonly create_at: number;
|
|
33
|
+
readonly metadata?: {
|
|
34
|
+
readonly mentions?: ReadonlyArray<string>;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Mattermost channel shape (subset).
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
interface MattermostChannel {
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly team_id: string;
|
|
45
|
+
readonly type: "D" | "G" | "O" | "P" | (string & {});
|
|
46
|
+
readonly name?: string;
|
|
47
|
+
readonly display_name?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Minimal user shape returned by `getMe`.
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
interface MattermostUser {
|
|
55
|
+
readonly id: string;
|
|
56
|
+
readonly username: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Wrapper over `@mattermost/client` — lazy import + lifecycle.
|
|
61
|
+
*
|
|
62
|
+
* Owns:
|
|
63
|
+
* - Client4 (REST) for outbound posts + channel/user lookup.
|
|
64
|
+
* - WebSocketClient for real-time `posted` events.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
interface Client4Like {
|
|
68
|
+
setUrl(url: string): void;
|
|
69
|
+
setToken(token: string): void;
|
|
70
|
+
getMe(): Promise<{
|
|
71
|
+
id: string;
|
|
72
|
+
username: string;
|
|
73
|
+
}>;
|
|
74
|
+
getChannel(channelId: string): Promise<MattermostChannel>;
|
|
75
|
+
createPost(post: {
|
|
76
|
+
channel_id: string;
|
|
77
|
+
message: string;
|
|
78
|
+
root_id?: string;
|
|
79
|
+
}): Promise<MattermostPost>;
|
|
80
|
+
}
|
|
81
|
+
interface WebSocketClientLike {
|
|
82
|
+
initialize(url: string, token: string): void;
|
|
83
|
+
addMessageListener(listener: (msg: WSMessage) => void): void;
|
|
84
|
+
removeMessageListener(listener: (msg: WSMessage) => void): void;
|
|
85
|
+
close(): void;
|
|
86
|
+
}
|
|
87
|
+
interface WSMessage {
|
|
88
|
+
readonly event: string;
|
|
89
|
+
readonly data: Record<string, unknown>;
|
|
90
|
+
readonly broadcast?: {
|
|
91
|
+
readonly channel_id?: string;
|
|
92
|
+
readonly team_id?: string;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
interface MattermostClientHandle {
|
|
96
|
+
readonly client: Client4Like;
|
|
97
|
+
readonly ws: WebSocketClientLike;
|
|
98
|
+
readonly botUserId: string;
|
|
99
|
+
readonly botUsername: string;
|
|
100
|
+
/** Channel-id LRU cache (max 200) to avoid extra getChannel calls. */
|
|
101
|
+
readonly channelCache: Map<string, MattermostChannel>;
|
|
102
|
+
}
|
|
103
|
+
interface ConnectOptions {
|
|
104
|
+
readonly baseUrl: string;
|
|
105
|
+
readonly accessToken: string;
|
|
106
|
+
}
|
|
107
|
+
declare function connectMattermost(opts: ConnectOptions): Promise<MattermostClientHandle>;
|
|
108
|
+
/**
|
|
109
|
+
* Convert REST base URL to WebSocket URL:
|
|
110
|
+
* `https://x.com` → `wss://x.com/api/v4/websocket`
|
|
111
|
+
* `http://localhost:8065` → `ws://localhost:8065/api/v4/websocket`
|
|
112
|
+
*
|
|
113
|
+
* @public — exported for unit tests + consumer-side reuse.
|
|
114
|
+
*/
|
|
115
|
+
declare function wsUrlFromBase(baseUrl: string): string;
|
|
116
|
+
declare function getChannelCached(handle: MattermostClientHandle, channelId: string): Promise<MattermostChannel | undefined>;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* `MattermostAdapter` — implements BasePlatformAdapter over Client4 + WS.
|
|
120
|
+
* ADRs D397-D404.
|
|
121
|
+
*
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
declare class MattermostAdapter extends BasePlatformAdapter {
|
|
126
|
+
readonly platform: "mattermost";
|
|
127
|
+
private readonly opts;
|
|
128
|
+
private handle;
|
|
129
|
+
private inboundHandler;
|
|
130
|
+
private wsListener;
|
|
131
|
+
private connected;
|
|
132
|
+
constructor(opts: MattermostAdapterOptions);
|
|
133
|
+
connect(): Promise<boolean>;
|
|
134
|
+
disconnect(): Promise<void>;
|
|
135
|
+
sendMessage(out: OutboundMessage): Promise<SendResult>;
|
|
136
|
+
onInbound(handler: (event: MessageEvent) => Promise<void>): () => void;
|
|
137
|
+
/** Escape hatch: caller can drive REST directly when v0.1 doesn't expose a feature. */
|
|
138
|
+
getClient(): MattermostClientHandle | undefined;
|
|
139
|
+
private attachWsListener;
|
|
140
|
+
private processPostedEvent;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Parse the `data.post` JSON envelope from a Mattermost WS `posted` event.
|
|
144
|
+
*
|
|
145
|
+
* @public — exposed so consumers can drive their own WS listener too.
|
|
146
|
+
*/
|
|
147
|
+
declare function parsePostFromWS(msg: WSMessage): MattermostPost | undefined;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Typed errors for `@theokit/gateway-mattermost`.
|
|
151
|
+
*/
|
|
152
|
+
/** @knipignore — public input shape for `ConfigurationError` constructor (caller-extensible). */
|
|
153
|
+
interface ConfigurationErrorOptions {
|
|
154
|
+
readonly code: string;
|
|
155
|
+
readonly message?: string;
|
|
156
|
+
readonly detail?: string;
|
|
157
|
+
}
|
|
158
|
+
declare class ConfigurationError extends Error {
|
|
159
|
+
readonly name = "ConfigurationError";
|
|
160
|
+
readonly code: string;
|
|
161
|
+
readonly detail: string | undefined;
|
|
162
|
+
constructor(opts: ConfigurationErrorOptions);
|
|
163
|
+
}
|
|
164
|
+
declare class SDKNotInstalledError extends ConfigurationError {
|
|
165
|
+
constructor(pkgName: string);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Inbound dispatch pipeline (D403, EC-2).
|
|
170
|
+
*
|
|
171
|
+
* Order matters — these checks compose:
|
|
172
|
+
*
|
|
173
|
+
* 1. Loop guard: drop bot's own posts (D275 mirror).
|
|
174
|
+
* 2. DM channels: always respond.
|
|
175
|
+
* 3. `requireMention === false`: respond.
|
|
176
|
+
* 4. **Metadata.mentions** array contains bot user-id → respond (PRIORITY).
|
|
177
|
+
* 5. **Word-boundary text regex** `\b@${botUsername}\b` → respond.
|
|
178
|
+
* 6. Else: ignore.
|
|
179
|
+
*
|
|
180
|
+
* EC-2: substring match (`post.message.includes("@theo")`) catches
|
|
181
|
+
* `@theory_dept` and dispatches false-positive. The fix is two-fold:
|
|
182
|
+
* prefer the unambiguous `metadata.mentions` array (API-provided
|
|
183
|
+
* user-ids), and when text fallback is required, use `\b` boundaries.
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
/** @knipignore — input shape for `shouldRespond`; useful for callers wrapping the filter pipeline. */
|
|
187
|
+
interface ShouldRespondOptions {
|
|
188
|
+
readonly post: MattermostPost;
|
|
189
|
+
readonly channelType: "dm" | "group" | "thread";
|
|
190
|
+
readonly botUserId: string;
|
|
191
|
+
readonly botUsername: string;
|
|
192
|
+
readonly requireMention: boolean;
|
|
193
|
+
}
|
|
194
|
+
declare function shouldRespond(opts: ShouldRespondOptions): boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Word-boundary match for `@${botUsername}`. Word boundaries land at
|
|
197
|
+
* `\b` (start/end of `\w` regions), so `@theo` at the head of `@theory`
|
|
198
|
+
* does NOT match because `\b` is between `o` and `r` only when the
|
|
199
|
+
* NEXT char is a non-word char.
|
|
200
|
+
*
|
|
201
|
+
* @public — exported for unit tests + consumer-side reuse.
|
|
202
|
+
*/
|
|
203
|
+
declare function hasMentionWithBoundary(text: string, botUsername: string): boolean;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Inbound normalization: Mattermost Post → MattermostMessageEvent.
|
|
207
|
+
*
|
|
208
|
+
* Channel-type mapping (D402):
|
|
209
|
+
* - `D` (Direct) → `"dm"`
|
|
210
|
+
* - `G`/`O`/`P` (Group/Open/Private) → `"group"`
|
|
211
|
+
* - Posts with `root_id !== ""` → `"thread"` with `topicId = root_id` (D399).
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
declare function normalizeMattermostType(channel: MattermostChannel | undefined): "D" | "G" | "O" | "P" | (string & {});
|
|
215
|
+
declare function mapChannelType(rawType: string, hasRootId: boolean): "dm" | "group" | "thread";
|
|
216
|
+
declare function postToMessageEvent(post: MattermostPost, channel: MattermostChannel | undefined, senderUsername: string | undefined): MattermostMessageEvent;
|
|
217
|
+
|
|
218
|
+
export { ConfigurationError, MattermostAdapter, type MattermostAdapterOptions, type MattermostChannel, type MattermostPost, type MattermostUser, SDKNotInstalledError, connectMattermost, getChannelCached, hasMentionWithBoundary, mapChannelType, normalizeMattermostType, parsePostFromWS, postToMessageEvent, shouldRespond, wsUrlFromBase };
|