@botpress/client 0.40.0 → 0.41.1

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.
@@ -1,4 +1,4 @@
1
- import { Client, errorFrom } from '../../src'
1
+ import { Client, errorFrom } from '../src'
2
2
 
3
3
  const main = async () => {
4
4
  const client = new Client()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/client",
3
- "version": "0.40.0",
3
+ "version": "0.41.1",
4
4
  "description": "Botpress Client",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -13,15 +13,13 @@
13
13
  },
14
14
  "scripts": {
15
15
  "check:type": "tsc --noEmit",
16
- "build:type": "tsup ./src/index.ts --dts-resolve --dts-only",
16
+ "build:type": "tsup --tsconfig tsconfig.build.json ./src/index.ts --dts-resolve --dts-only",
17
17
  "build:browser": "ts-node -T ./build.ts --browser",
18
18
  "build:node": "ts-node -T ./build.ts --node",
19
19
  "build:bundle": "ts-node -T ./build.ts --bundle",
20
20
  "build": "pnpm build:type && pnpm build:node && pnpm build:browser && pnpm build:bundle",
21
21
  "generate": "ts-node ./openapi.ts",
22
- "test:manual": "vitest tests/manual/file-upload",
23
- "test:e2e": "ts-node -T ./tests/e2e/node.ts",
24
- "test": "pnpm run test:e2e"
22
+ "test:e2e": "ts-node -T ./e2e/node.ts"
25
23
  },
26
24
  "dependencies": {
27
25
  "axios": "^1.6.1",
@@ -31,7 +29,7 @@
31
29
  "type-fest": "^3.4.0"
32
30
  },
33
31
  "devDependencies": {
34
- "@botpress/api": "0.59.0",
32
+ "@botpress/api": "0.68.1",
35
33
  "@types/qs": "^6.9.7",
36
34
  "esbuild": "^0.16.12",
37
35
  "lodash": "^4.17.21",
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "rootDir": "./src",
6
+ "outDir": "./dist"
7
+ },
8
+ "include": ["src/**/*"]
9
+ }
@@ -1,88 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
-
3
- /**
4
- * This a test to be run manually to test the custom file creation/upload method added in the client.
5
- *
6
- * Follow these steps to run it:
7
- * 1. Run Tilt on the Skynet repository using the `files-api` mode and make sure a "DEV_BYPASS_USAGE_CHECKS" env var with a string value of "true" is passed to the `files-api` Tilt resource so that we can use the predefined bot ID below.
8
- * 2. Then run `pnpm test:manual` in the terminal to run this test.
9
- */
10
- import { Client } from '../../src'
11
-
12
- describe('uploadFile', () => {
13
- const client = new Client({
14
- apiUrl: 'http://localhost:5986',
15
- botId: '87e67c78-e5d3-4cf7-97de-82b1f3907879',
16
- token: 'bp_pat_abcdefghijklmnopqrstuvwxyz0123456789',
17
- })
18
-
19
- const testContent = 'aaa'
20
-
21
- async function test(content: Buffer | ArrayBuffer | Uint8Array | Blob | string) {
22
- const response = await client.uploadFile({
23
- key: 'test.txt',
24
- content: content as any,
25
- })
26
-
27
- expect(response.file.key).toBe('test.txt')
28
- expect(response.file.url, 'File URL should have been returned').toBeTruthy()
29
-
30
- const fetchedContent = await fetch(response.file.url).then((res) => res.text())
31
- expect(fetchedContent).toBe(testContent)
32
- }
33
-
34
- it('works with a string', async () => {
35
- await test(testContent)
36
- })
37
-
38
- it('works with a Uint8Array', async () => {
39
- const encoder = new TextEncoder()
40
- const uint8Array = encoder.encode(testContent)
41
- await test(uint8Array)
42
- })
43
-
44
- it('works with a Buffer', async () => {
45
- const buffer = Buffer.from(testContent)
46
- await test(buffer)
47
- })
48
-
49
- it('works with an ArrayBuffer', async () => {
50
- const encoder = new TextEncoder()
51
- const uint8Array = encoder.encode(testContent)
52
- const arrayBuffer = uint8Array.buffer
53
- await test(arrayBuffer)
54
- })
55
-
56
- it('works with a Blob', async () => {
57
- const blob = new Blob([testContent], { type: 'text/plain' })
58
- await test(blob)
59
- })
60
-
61
- it('works with a URL', async () => {
62
- const sourceUrl = 'https://docs.botpress.cloud/docs/content/whatsapp-banner.png'
63
-
64
- const response = await client.uploadFile({
65
- key: 'whatsapp-banner.png',
66
- url: sourceUrl,
67
- })
68
-
69
- expect(response.file.key).toBe('whatsapp-banner.png')
70
- expect(response.file.url, 'File URL should have been returned').toBeTruthy()
71
-
72
- const download = await fetch(response.file.url)
73
- expect(download.status).toBe(200)
74
- })
75
-
76
- it('public URL is immediately accessible when requested', async () => {
77
- const sourceUrl = 'https://docs.botpress.cloud/docs/content/whatsapp-banner.png'
78
-
79
- const response = await client.uploadFile({
80
- key: 'whatsapp-banner.png',
81
- url: sourceUrl,
82
- publicContentImmediatelyAccessible: true,
83
- })
84
-
85
- const download = await fetch(response.file.url)
86
- expect(download.status).toBe(200)
87
- })
88
- })
File without changes