@bagelink/sdk 1.6.21 → 1.6.31
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/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/index.ts +10 -10
package/dist/index.cjs
CHANGED
|
@@ -771,7 +771,7 @@ class DataRequest {
|
|
|
771
771
|
if (!this.data_table) {
|
|
772
772
|
throw new Error("Data table not set");
|
|
773
773
|
}
|
|
774
|
-
const filterStr =
|
|
774
|
+
const filterStr = Object.keys(this._filter).length > 0 ? `?filter={${Object.entries(this._filter).map(([k, v]) => `${k}:${v}`).join(",")}}` : "";
|
|
775
775
|
const url = `/data/${this.data_table}${this.itemID ? `/${this.itemID}` : ""}${filterStr}`;
|
|
776
776
|
try {
|
|
777
777
|
const { data } = await axios.get(url);
|
package/dist/index.mjs
CHANGED
|
@@ -765,7 +765,7 @@ class DataRequest {
|
|
|
765
765
|
if (!this.data_table) {
|
|
766
766
|
throw new Error("Data table not set");
|
|
767
767
|
}
|
|
768
|
-
const filterStr =
|
|
768
|
+
const filterStr = Object.keys(this._filter).length > 0 ? `?filter={${Object.entries(this._filter).map(([k, v]) => `${k}:${v}`).join(",")}}` : "";
|
|
769
769
|
const url = `/data/${this.data_table}${this.itemID ? `/${this.itemID}` : ""}${filterStr}`;
|
|
770
770
|
try {
|
|
771
771
|
const { data } = await axios.get(url);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -42,7 +42,7 @@ class DataRequest<T extends Tables = Tables> {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
async post(item: { [key: string]: any }): Promise<{ [key: string]: any }> {
|
|
45
|
-
if (!this.data_table) {throw new Error('Data table not set')}
|
|
45
|
+
if (!this.data_table) { throw new Error('Data table not set') }
|
|
46
46
|
const { data } = await axios.post(`/data/${this.data_table}`, item)
|
|
47
47
|
return data
|
|
48
48
|
}
|
|
@@ -55,8 +55,8 @@ class DataRequest<T extends Tables = Tables> {
|
|
|
55
55
|
async get(): Promise<
|
|
56
56
|
TableToTypeMapping[T] | TableToTypeMapping[T][] | undefined
|
|
57
57
|
> {
|
|
58
|
-
if (!this.data_table) {throw new Error('Data table not set')}
|
|
59
|
-
const filterStr =
|
|
58
|
+
if (!this.data_table) { throw new Error('Data table not set') }
|
|
59
|
+
const filterStr = Object.keys(this._filter).length > 0
|
|
60
60
|
? `?filter={${Object.entries(this._filter)
|
|
61
61
|
.map(([k, v]) => `${k}:${v}`)
|
|
62
62
|
.join(',')}}`
|
|
@@ -80,7 +80,7 @@ class DataRequest<T extends Tables = Tables> {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
async delete(): Promise<TableToTypeMapping[T][]> {
|
|
83
|
-
if (!this.data_table) {throw new Error('Data table not set')}
|
|
83
|
+
if (!this.data_table) { throw new Error('Data table not set') }
|
|
84
84
|
const { data } = await axios.delete(
|
|
85
85
|
`/data/${this.data_table}/${this.itemID}`,
|
|
86
86
|
)
|
|
@@ -89,8 +89,8 @@ class DataRequest<T extends Tables = Tables> {
|
|
|
89
89
|
|
|
90
90
|
async put(updatedItem: { [key: string]: any }): Promise<{ [key: string]: any }> {
|
|
91
91
|
const { data_table, itemID } = this
|
|
92
|
-
if (!data_table) {throw new Error('Data table not set')}
|
|
93
|
-
if (!itemID) {throw new Error('Item ID not set')}
|
|
92
|
+
if (!data_table) { throw new Error('Data table not set') }
|
|
93
|
+
if (!itemID) { throw new Error('Item ID not set') }
|
|
94
94
|
const { data } = await axios.put(
|
|
95
95
|
`/data/${data_table}/${itemID}`,
|
|
96
96
|
updatedItem,
|
|
@@ -195,7 +195,7 @@ export class Bagel {
|
|
|
195
195
|
constructor({ host, fileBaseUrl, fileVersion, onError }: { [key: string]: any }) {
|
|
196
196
|
this.host = host?.replace(/\/$/, '')
|
|
197
197
|
this.fileBaseUrl = fileBaseUrl?.replace(/\/$/, '')
|
|
198
|
-
this.fileVersion = fileVersion || 'files' // Default to '
|
|
198
|
+
this.fileVersion = fileVersion || 'files' // Default to 'files'
|
|
199
199
|
if (!this.host) {
|
|
200
200
|
return this
|
|
201
201
|
}
|
|
@@ -237,14 +237,14 @@ export class Bagel {
|
|
|
237
237
|
): Promise<T> {
|
|
238
238
|
this._setAuthorization()
|
|
239
239
|
endpoint = this._endpointCleaner(endpoint)
|
|
240
|
-
if ((/undefined|null/).test(endpoint)) {throw new Error(`Invalid endpoint: ${endpoint}`)}
|
|
240
|
+
if ((/undefined|null/).test(endpoint)) { throw new Error(`Invalid endpoint: ${endpoint}`) }
|
|
241
241
|
|
|
242
242
|
if (query) {
|
|
243
243
|
const queryParams = Object.entries(query)
|
|
244
244
|
.filter(([_, value]) => !!value)
|
|
245
245
|
.map(([key, value]) => `${key}=${value}`)
|
|
246
246
|
.join('&')
|
|
247
|
-
if (queryParams) {endpoint = `${endpoint}?${queryParams}`}
|
|
247
|
+
if (queryParams) { endpoint = `${endpoint}?${queryParams}` }
|
|
248
248
|
}
|
|
249
249
|
const url = `/${endpoint}`
|
|
250
250
|
return axios
|
|
@@ -321,7 +321,7 @@ export class Bagel {
|
|
|
321
321
|
const formData = new FormData()
|
|
322
322
|
formData.append('file', file)
|
|
323
323
|
let url = '/static_files/upload'
|
|
324
|
-
if (options?.topic) {url = `/static_files/upload?topic=${options.topic}`}
|
|
324
|
+
if (options?.topic) { url = `/static_files/upload?topic=${options.topic}` }
|
|
325
325
|
// get an indication of the progress
|
|
326
326
|
const { data } = await axios.post<T>(url, formData, {
|
|
327
327
|
headers: {
|