@bagelink/vue 1.8.43 → 1.8.45

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "1.8.43",
4
+ "version": "1.8.45",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -1,26 +1,31 @@
1
- import type { AxiosResponse } from 'axios'
1
+ import type { AxiosInstance, AxiosResponse } from 'axios'
2
2
  import type { BglFile, BglFilePatch, UploadOptions } from './upload.types.d.ts'
3
3
  import axios from 'axios'
4
4
 
5
- // Using default 'files' endpoint - axios baseURL will be configured via SDK init
6
- const FILES_ENDPOINT = 'api/files'
5
+ let api: AxiosInstance = axios
6
+
7
+ export function createUploadApi(options: { baseURL?: string } = {}) {
8
+ if (options.baseURL !== undefined) {
9
+ api = axios.create({ baseURL: options.baseURL })
10
+ }
11
+ }
7
12
 
8
13
  export const files = {
9
14
  get: async (pathKey?: string): Promise<AxiosResponse<BglFile>> => {
10
- return axios.get(`/${FILES_ENDPOINT}/`, { params: { path_key: pathKey } })
15
+ return api.get('/files', { params: { path_key: pathKey } })
11
16
  },
12
17
 
13
18
  put: async (
14
19
  bglFilePatch: BglFilePatch,
15
20
  pathKey?: string
16
21
  ): Promise<AxiosResponse<BglFile>> => {
17
- return axios.put(`/${FILES_ENDPOINT}/`, bglFilePatch, {
22
+ return api.put('/files', bglFilePatch, {
18
23
  params: { path_key: pathKey },
19
24
  })
20
25
  },
21
26
 
22
27
  delete: async (pathKey?: string) => {
23
- return axios.delete(`/${FILES_ENDPOINT}/${pathKey}`, {
28
+ return api.delete(`/files/${pathKey}`, {
24
29
  params: { path_key: pathKey },
25
30
  })
26
31
  },
@@ -33,7 +38,7 @@ export const files = {
33
38
  // Backend expects multipart field name "file"
34
39
  formData.append('file', file)
35
40
  formData.append('upload', file)
36
- return axios.post(`/${FILES_ENDPOINT}/upload`, formData, {
41
+ return api.post('/files/upload', formData, {
37
42
  headers: { 'Content-Type': 'multipart/form-data' },
38
43
  onUploadProgress: options?.onUploadProgress,
39
44
  params: { dir_path: options?.dirPath, tags: options?.tags },
@@ -41,7 +46,7 @@ export const files = {
41
46
  },
42
47
 
43
48
  list: async (dirPath?: string): Promise<AxiosResponse<BglFile[]>> => {
44
- return axios.get(`/${FILES_ENDPOINT}/list`, {
49
+ return api.get('/files/list', {
45
50
  params: { dir_path: dirPath },
46
51
  })
47
52
  },
@@ -21,6 +21,7 @@ export { default as TableField } from './TableField.vue'
21
21
  export { default as TelInput } from './TelInput.vue'
22
22
  export { default as TextInput } from './TextInput.vue'
23
23
  export { default as ToggleInput } from './ToggleInput.vue'
24
- export { default as UploadInput } from './Upload/UploadInput.vue'
24
+ export { createUploadApi } from './Upload/upload'
25
25
 
26
+ export { default as UploadInput } from './Upload/UploadInput.vue'
26
27
  export { useFileUpload } from './Upload/useFileUpload'