@sheet2db/sdk 2.0.3 → 2.0.4

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheet2db/sdk",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "dependencies": {
@@ -14,7 +14,8 @@
14
14
  "tsup": "^8.5.0",
15
15
  "jest": "^29.7.0",
16
16
  "ts-jest": "^29.3.4",
17
- "@types/jest": "^29.5.14"
17
+ "@types/jest": "^29.5.14",
18
+ "ts-node":"^10.9.2"
18
19
  },
19
20
  "scripts": {
20
21
  "build": "tsup src/index.ts --format esm,cjs --dts",
package/src/index.test.ts CHANGED
@@ -57,7 +57,7 @@ describe('Sheet2DBClient', () => {
57
57
 
58
58
  mockedAxios.get.mockResolvedValueOnce({ data: fakeData });
59
59
 
60
- const result = await client.Read({ filter: "name:eq:test", format: "rows", sortDirection: "asc", offset: 0 }, 'users');
60
+ const result = await client.Read({ filter: "name:eq:test", format: "rows", sortDirection: "asc", offset: "0" }, 'users');
61
61
  expect(mockedAxios.get).toHaveBeenCalledWith('/users', { params: { filter: "name:eq:test", format: "rows", sortDirection: "asc", offset: 0 } });
62
62
  expect(result).toEqual(fakeData);
63
63
  });
package/src/index.ts CHANGED
@@ -7,8 +7,9 @@ export class Sheet2DBClient {
7
7
  axios: AxiosInstance
8
8
  constructor(apiId: string, version = 'v1' as const) {
9
9
  if (!apiId?.trim()) throw new Error('apiId is required to create a Sheet2DBClient.');
10
+ const baseURL = (typeof process != 'undefined' && process.env.SHEET2DB_BASE_URL) || 'https://api.sheet2db.io/' + version + '/data/' + apiId
10
11
  this.axios = axios.create({
11
- baseURL: (typeof process != 'undefined' && process.env.SHEET2DB_BASE_URL) || 'https://api.sheet2db.io/' + version + '/data/' + apiId,
12
+ baseURL: baseURL,
12
13
  paramsSerializer: {
13
14
  serialize: (params) => new URLSearchParams(params).toString()
14
15
  }
@@ -21,7 +22,7 @@ export class Sheet2DBClient {
21
22
  });
22
23
  }
23
24
  private endpoint(sheet?: string): string {
24
- return sheet ? `/${sheet}` : '/';
25
+ return sheet ? `/${sheet}` : '';
25
26
  }
26
27
  useBasicAuthentication(username: string, password: string) {
27
28
  const token = isNode ? Buffer.from(`${username}:${password}`).toString('base64') : btoa(`${username}:${password}`)
@@ -61,7 +62,7 @@ export class Sheet2DBClient {
61
62
  }
62
63
 
63
64
  async DeleteSheet(sheet: string): Promise<{ ok: true }> {
64
- if(!sheet) throw new Error("sheet is required to Delete Sheet")
65
+ if (!sheet) throw new Error("sheet is required to Delete Sheet")
65
66
  return this.axios.delete(this.endpoint(sheet)).then((res) => res.data)
66
67
  }
67
68
  }