@botpress/client 0.19.0 → 0.20.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.
@@ -0,0 +1,50 @@
1
+ /// <reference types="node" />
2
+ import { Client as AutoGeneratedClient } from './gen';
3
+ import { CreateFileInput } from './gen/operations/createFile';
4
+ import { GetFileResponse } from './gen/operations/getFile';
5
+ export type { Message, Conversation, User, State, Event, File, Bot, Integration, Issue, IssueEvent, Account, Workspace, Usage, } from './gen/models';
6
+ type CreateAndUploadFileInput = Omit<CreateFileInput, 'size'> & {
7
+ content?: Buffer | string;
8
+ url?: string;
9
+ };
10
+ type CreateAndUploadFileOutput = GetFileResponse;
11
+ 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
+ [K in keyof O]: Simplify<O[K]>;
13
+ } : never : T;
14
+ type AsyncFunc = (...args: any[]) => Promise<any>;
15
+ export type IClient = Simplify<AutoGeneratedClient & {
16
+ createAndUploadFile: (input: CreateAndUploadFileInput) => Promise<CreateAndUploadFileOutput>;
17
+ }>;
18
+ export type Operation = Simplify<keyof {
19
+ [K in keyof IClient as IClient[K] extends AsyncFunc ? K : never]: IClient[K];
20
+ }>;
21
+ /**
22
+ * @deprecated Use ClientInputs instead
23
+ */
24
+ export type ClientParams<T extends Operation> = Simplify<Parameters<IClient[T]>[0]>;
25
+ /**
26
+ * @deprecated Use ClientOutputs instead
27
+ */
28
+ export type ClientReturn<T extends Operation> = Simplify<Awaited<ReturnType<IClient[T]>>>;
29
+ export type ClientInputs = Simplify<{
30
+ [T in Operation]: Parameters<IClient[T]>[0];
31
+ }>;
32
+ export type ClientOutputs = Simplify<{
33
+ [T in Operation]: Awaited<ReturnType<IClient[T]>>;
34
+ }>;
35
+ type Headers = Record<string, string | string[]>;
36
+ export type ClientProps = {
37
+ integrationId?: string;
38
+ workspaceId?: string;
39
+ botId?: string;
40
+ token?: string;
41
+ apiUrl?: string;
42
+ timeout?: number;
43
+ headers?: Headers;
44
+ };
45
+ export type ClientConfig = {
46
+ apiUrl: string;
47
+ headers: Headers;
48
+ withCredentials: boolean;
49
+ timeout: number;
50
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/client",
3
- "version": "0.19.0",
3
+ "version": "0.20.1",
4
4
  "description": "Botpress Client",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
package/readme.md CHANGED
@@ -13,9 +13,9 @@ pnpm add @botpress/client # for pnpm
13
13
  ## Usage
14
14
 
15
15
  ```ts
16
- import { Client, ClientReturn } from '@botpress/client'
16
+ import { Client, ClientOutputs } from '@botpress/client'
17
17
 
18
- type Bot = ClientReturn<'listBots'>['bots'][number]
18
+ type Bot = ClientOutputs['listBots']['bots'][number]
19
19
 
20
20
  const main = async () => {
21
21
  const token = 'your-token'
@@ -19,7 +19,7 @@ describe('createAndUploadFile', () => {
19
19
  it('works with a buffer', async () => {
20
20
  const response = await client.createAndUploadFile({
21
21
  name: 'test.txt',
22
- data: Buffer.from('aaa'),
22
+ content: Buffer.from('aaa'),
23
23
  })
24
24
 
25
25
  expect(response.file.name).toBe('test.txt')
@@ -30,7 +30,7 @@ describe('createAndUploadFile', () => {
30
30
  it('works with plain text', async () => {
31
31
  const response = await client.createAndUploadFile({
32
32
  name: 'test.txt',
33
- data: 'aaa',
33
+ content: 'aaa',
34
34
  })
35
35
 
36
36
  expect(response.file.name).toBe('test.txt')