@botpress/client
Advanced tools
Comparing version 0.23.0 to 0.23.1
@@ -9,2 +9,3 @@ import { AxiosError } from 'axios'; | ||
key: string; | ||
url: string; | ||
size: number | null; | ||
@@ -27,2 +28,3 @@ contentType: string; | ||
key: string; | ||
url: string; | ||
size: number | null; | ||
@@ -29,0 +31,0 @@ contentType: string; |
@@ -1215,7 +1215,7 @@ export interface Bot { | ||
/** | ||
* If the file is not uploaded yet, this will be set to a `null` value. | ||
* URL to retrieve the file content. This URL will be ready to use once the file is uploaded. | ||
* | ||
* If the file has a `public_content` policy, this will contain the permanent public URL to retrieve the file, otherwise this will contain a temporary pre-signed URL to download the file which should be used shortly after retrieving and should not be stored long-term as the URL will expire after a short timeframe. | ||
*/ | ||
url: string | null; | ||
url: string; | ||
/** | ||
@@ -1222,0 +1222,0 @@ * File size in bytes. Non-null if file upload status is "COMPLETE". |
@@ -35,7 +35,7 @@ export interface GetFileRequestHeaders { | ||
/** | ||
* If the file is not uploaded yet, this will be set to a `null` value. | ||
* URL to retrieve the file content. This URL will be ready to use once the file is uploaded. | ||
* | ||
* If the file has a `public_content` policy, this will contain the permanent public URL to retrieve the file, otherwise this will contain a temporary pre-signed URL to download the file which should be used shortly after retrieving and should not be stored long-term as the URL will expire after a short timeframe. | ||
*/ | ||
url: string | null; | ||
url: string; | ||
/** | ||
@@ -42,0 +42,0 @@ * File size in bytes. Non-null if file upload status is "COMPLETE". |
@@ -38,7 +38,7 @@ export interface ListFilesRequestHeaders { | ||
/** | ||
* If the file is not uploaded yet, this will be set to a `null` value. | ||
* URL to retrieve the file content. This URL will be ready to use once the file is uploaded. | ||
* | ||
* If the file has a `public_content` policy, this will contain the permanent public URL to retrieve the file, otherwise this will contain a temporary pre-signed URL to download the file which should be used shortly after retrieving and should not be stored long-term as the URL will expire after a short timeframe. | ||
*/ | ||
url: string | null; | ||
url: string; | ||
/** | ||
@@ -45,0 +45,0 @@ * File size in bytes. Non-null if file upload status is "COMPLETE". |
@@ -45,7 +45,7 @@ export interface UpdateFileMetadataRequestHeaders { | ||
/** | ||
* If the file is not uploaded yet, this will be set to a `null` value. | ||
* URL to retrieve the file content. This URL will be ready to use once the file is uploaded. | ||
* | ||
* If the file has a `public_content` policy, this will contain the permanent public URL to retrieve the file, otherwise this will contain a temporary pre-signed URL to download the file which should be used shortly after retrieving and should not be stored long-term as the URL will expire after a short timeframe. | ||
*/ | ||
url: string | null; | ||
url: string; | ||
/** | ||
@@ -52,0 +52,0 @@ * File size in bytes. Non-null if file upload status is "COMPLETE". |
@@ -60,2 +60,8 @@ export interface UpsertFileRequestHeaders { | ||
/** | ||
* URL to retrieve the file content. This URL will be ready to use once the file is uploaded. | ||
* | ||
* If the file has a `public_content` policy, this will contain the permanent public URL to retrieve the file, otherwise this will contain a temporary pre-signed URL to download the file which should be used shortly after retrieving and should not be stored long-term as the URL will expire after a short timeframe. | ||
*/ | ||
url: string; | ||
/** | ||
* File size in bytes. Non-null if file upload status is "COMPLETE". | ||
@@ -62,0 +68,0 @@ */ |
/// <reference types="node" /> | ||
import { Client as AutoGeneratedClient } from './gen'; | ||
import { GetFileResponse } from './gen/operations/getFile'; | ||
import { UpsertFileInput } from './gen/operations/upsertFile'; | ||
import { UpsertFileInput, UpsertFileResponse } from './gen/operations/upsertFile'; | ||
export type { Message, Conversation, User, State, Event, File, Bot, Integration, Issue, IssueEvent, Account, Workspace, Usage, } from './gen/models'; | ||
@@ -10,3 +9,3 @@ type UploadFileInput = Omit<UpsertFileInput, 'size'> & { | ||
}; | ||
type UploadFileOutput = GetFileResponse; | ||
type UploadFileOutput = UpsertFileResponse; | ||
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 ? { | ||
@@ -13,0 +12,0 @@ [K in keyof O]: Simplify<O[K]>; |
{ | ||
"name": "@botpress/client", | ||
"version": "0.23.0", | ||
"version": "0.23.1", | ||
"description": "Botpress Client", | ||
@@ -33,3 +33,3 @@ "main": "./dist/index.cjs", | ||
"devDependencies": { | ||
"@botpress/api": "0.32.1", | ||
"@botpress/api": "0.32.3", | ||
"@types/qs": "^6.9.7", | ||
@@ -36,0 +36,0 @@ "esbuild": "^0.16.12", |
@@ -26,4 +26,6 @@ import { describe, expect, it } from 'vitest' | ||
expect(response.file.key).toBe('test.txt') | ||
expect(response.file.status).toBe('upload_completed') | ||
expect(response.file.url, 'File URL should have been returned').toBeTruthy() | ||
const content = await fetch(response.file.url).then((res) => res.text()) | ||
expect(content).toBe('aaa') | ||
}) | ||
@@ -38,16 +40,22 @@ | ||
expect(response.file.key).toBe('test.txt') | ||
expect(response.file.status).toBe('upload_completed') | ||
expect(response.file.url, 'File URL should have been returned').toBeTruthy() | ||
const content = await fetch(response.file.url).then((res) => res.text()) | ||
expect(content).toBe('aaa') | ||
}) | ||
it('works with a URL', async () => { | ||
const sourceUrl = 'https://docs.botpress.cloud/docs/content/whatsapp-banner.png' | ||
const response = await client.uploadFile({ | ||
key: 'whatsapp-banner.png', | ||
url: 'https://docs.botpress.cloud/docs/content/whatsapp-banner.png', | ||
url: sourceUrl, | ||
}) | ||
expect(response.file.key).toBe('whatsapp-banner.png') | ||
expect(response.file.status).toBe('upload_completed') | ||
expect(response.file.url, 'File URL should have been returned').toBeTruthy() | ||
const download = await fetch(response.file.url) | ||
expect(download.status).toBe(200) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3603844
14556