@bagelink/sdk 1.6.29 → 1.6.34

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Neveh Allon
3
+ Copyright (c) 2023 Bagel Studio
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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 = 0 < Object.keys(this._filter).length ? `?filter={${Object.entries(this._filter).map(([k, v]) => `${k}:${v}`).join(",")}}` : "";
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 = 0 < Object.keys(this._filter).length ? `?filter={${Object.entries(this._filter).map(([k, v]) => `${k}:${v}`).join(",")}}` : "";
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
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@bagelink/sdk",
3
3
  "type": "module",
4
- "version": "1.6.29",
4
+ "version": "1.6.34",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
- "name": "Neveh Allon",
8
- "email": "neveh@bagelstudio.co.il",
9
- "url": "https://github.com/nevehallon"
7
+ "name": "Bagel Studio",
8
+ "email": "hi@bagelstudio.co.il"
10
9
  },
11
10
  "license": "MIT",
12
11
  "homepage": "https://github.com/bageldb/bagelink/tree/master/packages/sdk#readme",
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 = 0 < Object.keys(this._filter).length
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 'files_v2'
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: {