@botpress/client 0.26.5 → 0.28.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/.turbo/turbo-build.log +7 -7
- package/.turbo/turbo-generate.log +1 -1
- package/dist/bundle.cjs +13 -13
- package/dist/bundle.cjs.map +4 -4
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +220 -2
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +4 -4
- package/package.json +2 -2
- package/readme.md +22 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "Botpress Client",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"type-fest": "^3.4.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@botpress/api": "0.
|
|
33
|
+
"@botpress/api": "0.39.0",
|
|
34
34
|
"@types/qs": "^6.9.7",
|
|
35
35
|
"esbuild": "^0.16.12",
|
|
36
36
|
"lodash": "^4.17.21",
|
package/readme.md
CHANGED
|
@@ -13,24 +13,33 @@ pnpm add @botpress/client # for pnpm
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
import { Client
|
|
16
|
+
import { Client } from '@botpress/client'
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
// 0. Type definitions for each operation's IO
|
|
19
|
+
type GetBotInput = ClientInputs['getBot']
|
|
20
|
+
type GetBotOutput = ClientOutputs['getBot']
|
|
19
21
|
|
|
20
22
|
const main = async () => {
|
|
21
23
|
const token = 'your-token'
|
|
22
24
|
const workspaceId = 'your-workspace-id'
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
const botId = 'your-bot-id'
|
|
26
|
+
const client = new Client({ token, workspaceId, botId })
|
|
27
|
+
|
|
28
|
+
// 1. plain operations
|
|
29
|
+
const { bot } = await client.getBot({ id: botId })
|
|
30
|
+
console.log('### bot', bot)
|
|
31
|
+
|
|
32
|
+
// 2. list utils with `.collect()` function
|
|
33
|
+
const [latestConversation] = await client.list
|
|
34
|
+
.conversations({ sortField: 'createdAt', sortDirection: 'desc', integrationName: 'telegram' })
|
|
35
|
+
.collect({ limit: 1 })
|
|
36
|
+
console.log('### latestConversation', latestConversation)
|
|
37
|
+
|
|
38
|
+
// 3. list utils with async generator and `for await` syntax
|
|
39
|
+
for await (const message of client.list.messages({ conversationId: latestConversation.id })) {
|
|
40
|
+
console.log(`### [${message.userId}]`, message.payload)
|
|
41
|
+
}
|
|
34
42
|
}
|
|
43
|
+
|
|
35
44
|
void main()
|
|
36
45
|
```
|