@riocrypto/common-server 1.0.1004 → 1.0.1006
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.
|
@@ -4,6 +4,7 @@ declare class GoogleSheetsAPIClient {
|
|
|
4
4
|
googleAuth: any;
|
|
5
5
|
constructor(env: RioEnv);
|
|
6
6
|
getSheetValues(sheetId: string, range: string): Promise<any[][] | null | undefined>;
|
|
7
|
+
getNextAvailableRow(sheetId: string): Promise<number>;
|
|
7
8
|
}
|
|
8
9
|
export declare const googleSheetsAPIClient: GoogleSheetsAPIClient;
|
|
9
10
|
export {};
|
|
@@ -30,5 +30,28 @@ class GoogleSheetsAPIClient {
|
|
|
30
30
|
return response.data.values;
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
+
getNextAvailableRow(sheetId) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const authClientObject = yield this.googleAuth.getClient();
|
|
36
|
+
const sheets = googleapis_1.google.sheets({ version: "v4", auth: authClientObject });
|
|
37
|
+
const response = yield sheets.spreadsheets.values.get({
|
|
38
|
+
spreadsheetId: sheetId,
|
|
39
|
+
range: "A:A",
|
|
40
|
+
});
|
|
41
|
+
const data = response.data.values;
|
|
42
|
+
if (!data || data.length === 0) {
|
|
43
|
+
// If the sheet is completely empty, return the first row (1)
|
|
44
|
+
return 1;
|
|
45
|
+
}
|
|
46
|
+
// Find the first empty row
|
|
47
|
+
for (let i = 0; i < data.length; i++) {
|
|
48
|
+
if (data[i].length === 0) {
|
|
49
|
+
return i + 1;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// If no empty row found, return the next row after the last row
|
|
53
|
+
return data.length + 1;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
33
56
|
}
|
|
34
57
|
exports.googleSheetsAPIClient = new GoogleSheetsAPIClient(process.env.RIO_ENV || process.env.NEXT_PUBLIC_RIO_ENV);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1006",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@aws-sdk/client-s3": "^3.297.0",
|
|
25
25
|
"@everapi/currencyapi-js": "^1.0.6",
|
|
26
26
|
"@google-cloud/storage": "^6.9.5",
|
|
27
|
-
"@riocrypto/common": "^1.0.
|
|
27
|
+
"@riocrypto/common": "^1.0.869",
|
|
28
28
|
"@types/express": "^4.17.13",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"ccxt": "^3.0.30",
|