diff --git a/packages/client/src/common/debug-interceptors.ts b/packages/client/src/common/debug-interceptors.ts index 3bbed365138..6562dfc938f 100644 --- a/packages/client/src/common/debug-interceptors.ts +++ b/packages/client/src/common/debug-interceptors.ts @@ -47,11 +47,14 @@ export const addDebugInterceptors = (axiosInstance: axios.AxiosInstance) => { const _formatRequestLog = (config: AxiosRequestConfigWithMetadata): string => { const { method, url, headers, data } = config + + const fullUrl = config.baseURL ? new URL(url!, config.baseURL).toString() : url + return ( 'REQUEST: ' + JSON.stringify({ method: method?.toUpperCase(), - url, + url: fullUrl, timestamp: new Date().toISOString(), requestId: config.metadata?.id, headers, @@ -64,13 +67,14 @@ const _formatRequestLog = (config: AxiosRequestConfigWithMetadata): string => { const _formatResponseLog = (response: AxiosResponseWithMetadata): string => { const { config, status, headers, data } = response const duration = _formatDuration(response) + const fullUrl = config.baseURL ? new URL(response.config.url!, config.baseURL).toString() : response.config.url return ( 'RESPONSE: ' + JSON.stringify({ method: config.method?.toUpperCase(), status, - url: config.url, + url: fullUrl, timestamp: new Date().toISOString(), requestId: config.metadata?.id, duration, @@ -83,13 +87,15 @@ const _formatResponseLog = (response: AxiosResponseWithMetadata): string => { const _formatErrorLog = (error: AxiosErrorWithMetadata): string => { const duration = error ? _formatDuration(error) : 'N/A' + const fullUrl = error.config.baseURL ? new URL(error.config.url!, error.config.baseURL).toString() : error.config.url return ( 'ERROR: ' + JSON.stringify({ status: error.code, - url: error.config.url ?? 'N/A', + url: fullUrl, timestamp: new Date().toISOString(), + requestId: error.config.metadata?.id ?? 'N/A', duration, }) ) diff --git a/packages/common/src/conversation-transcript/message-types.d.ts b/packages/common/src/conversation-transcript/message-types.d.ts index 54effd9570c..330452c61e1 100644 --- a/packages/common/src/conversation-transcript/message-types.d.ts +++ b/packages/common/src/conversation-transcript/message-types.d.ts @@ -1,8 +1,17 @@ import * as sdk from '@botpress/sdk' -type AllMessageTypes = typeof sdk.messages.defaults & { markdown: typeof sdk.messages.markdown } +type ValueOf = T[keyof T] +type Merge = Omit & B -export type Message = { +type AllMessageTypes = Merge< + typeof sdk.messages.defaults, + { + markdown: typeof sdk.messages.markdown + bloc: typeof sdk.messages.markdownBloc + } +> + +export type Message = ValueOf<{ [K in keyof AllMessageTypes]: { type: K source: @@ -15,7 +24,7 @@ export type Message = { } payload: sdk.z.infer } -}[keyof AllMessageTypes] +}> export type MessageSource = Message['source']