@stacksjs/chat 0.70.1 → 0.70.2
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.js +1 -3236
- package/package.json +1 -4
- package/dist/slack.d.ts +0 -70
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/chat",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.70.
|
|
4
|
+
"version": "0.70.2",
|
|
5
5
|
"description": "Easily interact with chat APIs.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": ["Chris Breuer <chris@stacksjs.org>"],
|
|
@@ -33,9 +33,6 @@
|
|
|
33
33
|
"typecheck": "bun tsc --noEmit",
|
|
34
34
|
"prepublishOnly": "bun run build"
|
|
35
35
|
},
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"@novu/slack": "^0.24.1"
|
|
38
|
-
},
|
|
39
36
|
"devDependencies": {
|
|
40
37
|
"@stacksjs/cli": "0.70.1",
|
|
41
38
|
"@stacksjs/config": "0.70.1",
|
package/dist/slack.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { ChatMessage, ChatOptions, ChatResult } from '@stacksjs/types';
|
|
2
|
-
|
|
3
|
-
export declare class SlackDriver extends BaseChatDriver {
|
|
4
|
-
public name = 'slack'
|
|
5
|
-
private provider: SlackProvider
|
|
6
|
-
|
|
7
|
-
constructor() {
|
|
8
|
-
super()
|
|
9
|
-
const env = config.services.slack
|
|
10
|
-
|
|
11
|
-
this.provider = new SlackProvider({
|
|
12
|
-
applicationId: env?.appId ?? '',
|
|
13
|
-
clientId: env?.clientId ?? '',
|
|
14
|
-
secretKey: env?.secret ?? '',
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public async send(message: ChatMessage, options?: ChatOptions): Promise<ChatResult> {
|
|
19
|
-
const logContext = {
|
|
20
|
-
provider: this.name,
|
|
21
|
-
to: message.to,
|
|
22
|
-
subject: message.subject || 'No subject',
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
log.info('Sending message via Slack...', logContext)
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
this.validateMessage(message)
|
|
29
|
-
|
|
30
|
-
const payload = {
|
|
31
|
-
...message,
|
|
32
|
-
...options,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const response = await this.sendWithRetry(payload)
|
|
36
|
-
return this.handleSuccess(message, response.id)
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
return this.handleError(error, message)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
private async sendWithRetry(payload: any, attempt = 1): Promise<any> {
|
|
44
|
-
try {
|
|
45
|
-
const response = await this.provider.sendMessage(payload)
|
|
46
|
-
|
|
47
|
-
log.info(`[${this.name}] Message sent successfully`, {
|
|
48
|
-
attempt,
|
|
49
|
-
messageId: response.id,
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
return response
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
if (attempt < (config.services.slack?.maxRetries ?? 3)) {
|
|
56
|
-
const retryTimeout = config.services.slack?.retryTimeout ?? 1000
|
|
57
|
-
log.warn(`[${this.name}] Message send failed, retrying (${attempt}/${config.services.slack?.maxRetries ?? 3})`)
|
|
58
|
-
await new Promise(resolve => setTimeout(resolve, retryTimeout))
|
|
59
|
-
return this.sendWithRetry(payload, attempt + 1)
|
|
60
|
-
}
|
|
61
|
-
throw error
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
export declare const driver: unknown;
|
|
66
|
-
export declare function send(message: ChatMessage, options?: ChatOptions): Promise<ChatResult>;
|
|
67
|
-
|
|
68
|
-
export { SlackDriver as Driver }
|
|
69
|
-
|
|
70
|
-
export default SlackDriver;
|