@botpress/client 0.22.0 → 0.23.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.
package/dist/types.d.ts CHANGED
@@ -1,13 +1,12 @@
1
1
  /// <reference types="node" />
2
2
  import { Client as AutoGeneratedClient } from './gen';
3
- import { UpsertFileInput } from './gen/operations/upsertFile';
4
- import { GetFileResponse } from './gen/operations/getFile';
3
+ import { UpsertFileInput, UpsertFileResponse } from './gen/operations/upsertFile';
5
4
  export type { Message, Conversation, User, State, Event, File, Bot, Integration, Issue, IssueEvent, Account, Workspace, Usage, } from './gen/models';
6
5
  type UploadFileInput = Omit<UpsertFileInput, 'size'> & {
7
6
  content?: Buffer | string;
8
7
  url?: string;
9
8
  };
10
- type UploadFileOutput = GetFileResponse;
9
+ type UploadFileOutput = UpsertFileResponse;
11
10
  type Simplify<T> = T extends (...args: infer A) => infer R ? (...args: Simplify<A>) => Simplify<R> : T extends Promise<infer R> ? Promise<Simplify<R>> : T extends Buffer ? Buffer : T extends object ? T extends infer O ? {
12
11
  [K in keyof O]: Simplify<O[K]>;
13
12
  } : never : T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/client",
3
- "version": "0.22.0",
3
+ "version": "0.23.1",
4
4
  "description": "Botpress Client",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -12,16 +12,16 @@
12
12
  "https": false
13
13
  },
14
14
  "scripts": {
15
- "type:check": "tsc --noEmit",
15
+ "check:type": "tsc --noEmit",
16
16
  "build:type": "tsc --emitDeclarationOnly --declaration",
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": "pnpm run e2e:test",
23
22
  "test:manual": "vitest tests/manual/file-upload",
24
- "e2e:test": "ts-node -T ./tests/e2e/node.ts && ts-node -T ./tests/e2e/browser"
23
+ "test:e2e": "ts-node -T ./tests/e2e/node.ts && ts-node -T ./tests/e2e/browser",
24
+ "test": "pnpm run test:e2e"
25
25
  },
26
26
  "dependencies": {
27
27
  "axios": "^1.6.1",
@@ -30,7 +30,7 @@
30
30
  "type-fest": "^3.4.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@botpress/api": "0.31.0",
33
+ "@botpress/api": "0.32.3",
34
34
  "@types/qs": "^6.9.7",
35
35
  "esbuild": "^0.16.12",
36
36
  "lodash": "^4.17.21",
@@ -23,8 +23,10 @@ describe('uploadFile', () => {
23
23
  })
24
24
 
25
25
  expect(response.file.key).toBe('test.txt')
26
- expect(response.file.status).toBe('upload_completed')
27
26
  expect(response.file.url, 'File URL should have been returned').toBeTruthy()
27
+
28
+ const content = await fetch(response.file.url).then((res) => res.text())
29
+ expect(content).toBe('aaa')
28
30
  })
29
31
 
30
32
  it('works with plain text', async () => {
@@ -34,18 +36,24 @@ describe('uploadFile', () => {
34
36
  })
35
37
 
36
38
  expect(response.file.key).toBe('test.txt')
37
- expect(response.file.status).toBe('upload_completed')
38
39
  expect(response.file.url, 'File URL should have been returned').toBeTruthy()
40
+
41
+ const content = await fetch(response.file.url).then((res) => res.text())
42
+ expect(content).toBe('aaa')
39
43
  })
40
44
 
41
45
  it('works with a URL', async () => {
46
+ const sourceUrl = 'https://docs.botpress.cloud/docs/content/whatsapp-banner.png'
47
+
42
48
  const response = await client.uploadFile({
43
49
  key: 'whatsapp-banner.png',
44
- url: 'https://docs.botpress.cloud/docs/content/whatsapp-banner.png',
50
+ url: sourceUrl,
45
51
  })
46
52
 
47
53
  expect(response.file.key).toBe('whatsapp-banner.png')
48
- expect(response.file.status).toBe('upload_completed')
49
54
  expect(response.file.url, 'File URL should have been returned').toBeTruthy()
55
+
56
+ const download = await fetch(response.file.url)
57
+ expect(download.status).toBe(200)
50
58
  })
51
59
  })