@sheet2db/sdk 2.0.4 → 2.0.6
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/index.mjs +3 -2
- package/package.json +1 -1
- package/src/index.test.ts +1 -1
- package/src/index.ts +1 -1
package/dist/index.d.mts
CHANGED
@@ -120,7 +120,7 @@ declare class Sheet2DBClient {
|
|
120
120
|
useBasicAuthentication(username: string, password: string): void;
|
121
121
|
useJWTAuthentication(token: string): void;
|
122
122
|
useBearerTokenAuthentication(token: string): void;
|
123
|
-
Read<T = any>(options: ReadOptions
|
123
|
+
Read<T = any>(options: Partial<ReadOptions>, sheet?: string): Promise<T>;
|
124
124
|
Update(options: UpdateOptions, sheet?: string): Promise<{
|
125
125
|
updated: number;
|
126
126
|
}>;
|
package/dist/index.d.ts
CHANGED
@@ -120,7 +120,7 @@ declare class Sheet2DBClient {
|
|
120
120
|
useBasicAuthentication(username: string, password: string): void;
|
121
121
|
useJWTAuthentication(token: string): void;
|
122
122
|
useBearerTokenAuthentication(token: string): void;
|
123
|
-
Read<T = any>(options: ReadOptions
|
123
|
+
Read<T = any>(options: Partial<ReadOptions>, sheet?: string): Promise<T>;
|
124
124
|
Update(options: UpdateOptions, sheet?: string): Promise<{
|
125
125
|
updated: number;
|
126
126
|
}>;
|
package/dist/index.js
CHANGED
@@ -59,8 +59,9 @@ var Sheet2DBClient = class {
|
|
59
59
|
constructor(apiId, version = "v1") {
|
60
60
|
this.authentication = null;
|
61
61
|
if (!(apiId == null ? void 0 : apiId.trim())) throw new Error("apiId is required to create a Sheet2DBClient.");
|
62
|
+
const baseURL = typeof process != "undefined" && process.env.SHEET2DB_BASE_URL || "https://api.sheet2db.io/" + version + "/data/" + apiId;
|
62
63
|
this.axios = import_axios.default.create({
|
63
|
-
baseURL
|
64
|
+
baseURL,
|
64
65
|
paramsSerializer: {
|
65
66
|
serialize: (params) => new URLSearchParams(params).toString()
|
66
67
|
}
|
@@ -73,7 +74,7 @@ var Sheet2DBClient = class {
|
|
73
74
|
});
|
74
75
|
}
|
75
76
|
endpoint(sheet) {
|
76
|
-
return sheet ? `/${sheet}` : "
|
77
|
+
return sheet ? `/${sheet}` : "";
|
77
78
|
}
|
78
79
|
useBasicAuthentication(username, password) {
|
79
80
|
const token = isNode ? Buffer.from(`${username}:${password}`).toString("base64") : btoa(`${username}:${password}`);
|
package/dist/index.mjs
CHANGED
@@ -26,8 +26,9 @@ var Sheet2DBClient = class {
|
|
26
26
|
constructor(apiId, version = "v1") {
|
27
27
|
this.authentication = null;
|
28
28
|
if (!(apiId == null ? void 0 : apiId.trim())) throw new Error("apiId is required to create a Sheet2DBClient.");
|
29
|
+
const baseURL = typeof process != "undefined" && process.env.SHEET2DB_BASE_URL || "https://api.sheet2db.io/" + version + "/data/" + apiId;
|
29
30
|
this.axios = axios.create({
|
30
|
-
baseURL
|
31
|
+
baseURL,
|
31
32
|
paramsSerializer: {
|
32
33
|
serialize: (params) => new URLSearchParams(params).toString()
|
33
34
|
}
|
@@ -40,7 +41,7 @@ var Sheet2DBClient = class {
|
|
40
41
|
});
|
41
42
|
}
|
42
43
|
endpoint(sheet) {
|
43
|
-
return sheet ? `/${sheet}` : "
|
44
|
+
return sheet ? `/${sheet}` : "";
|
44
45
|
}
|
45
46
|
useBasicAuthentication(username, password) {
|
46
47
|
const token = isNode ? Buffer.from(`${username}:${password}`).toString("base64") : btoa(`${username}:${password}`);
|
package/package.json
CHANGED
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:
|
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
@@ -37,7 +37,7 @@ export class Sheet2DBClient {
|
|
37
37
|
this.authentication = 'Bearer ' + token
|
38
38
|
}
|
39
39
|
|
40
|
-
async Read<T = any>(options: ReadOptions
|
40
|
+
async Read<T = any>(options: Partial<ReadOptions>, sheet?: string): Promise<T> {
|
41
41
|
return this.axios.get(this.endpoint(sheet), {
|
42
42
|
params: options
|
43
43
|
}).then((res) => res.data)
|