@botpress/client 0.20.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.
- package/.turbo/turbo-build.log +5 -5
- package/.turbo/turbo-generate.log +1 -1
- package/dist/bundle.cjs +11 -11
- package/dist/bundle.cjs.map +4 -4
- package/dist/client.d.ts +10 -0
- package/dist/config.d.ts +2 -18
- package/dist/errors.d.ts +39 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +3 -67
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +4 -4
- package/dist/types.d.ts +50 -0
- package/package.json +1 -1
- package/readme.md +2 -2
package/dist/types.d.ts
ADDED
|
@@ -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
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,
|
|
16
|
+
import { Client, ClientOutputs } from '@botpress/client'
|
|
17
17
|
|
|
18
|
-
type Bot =
|
|
18
|
+
type Bot = ClientOutputs['listBots']['bots'][number]
|
|
19
19
|
|
|
20
20
|
const main = async () => {
|
|
21
21
|
const token = 'your-token'
|