Files
botpress--botpress/packages/client/src/tables/index.ts
T
2026-07-13 13:34:48 +08:00

36 lines
1005 B
TypeScript

import axiosRetry from 'axios-retry'
import * as common from '../common'
import * as gen from '../gen/tables'
import * as types from '../types'
type IClient = common.types.Simplify<gen.Client>
export type Operation = common.types.Operation<IClient>
export type ClientInputs = common.types.Inputs<IClient>
export type ClientOutputs = common.types.Outputs<IClient>
export type ClientProps = common.types.CommonClientProps & {
token: string
botId: string
integrationId?: string
integrationAlias?: string
}
export class Client extends gen.Client {
public readonly config: Readonly<types.ClientConfig>
public constructor(clientProps: ClientProps) {
const clientConfig = common.config.getClientConfig(clientProps)
const axiosInstance = common.axios.createAxiosInstance(clientConfig)
super(axiosInstance, {
toApiError: common.errors.toApiError,
})
if (clientProps.retry) {
axiosRetry(axiosInstance, clientProps.retry)
}
this.config = clientConfig
}
}