@riocrypto/common-server 1.0.1007 → 1.0.1009
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,7 +4,7 @@ declare class GoogleSheetsAPIClient {
|
|
|
4
4
|
googleAuth: any;
|
|
5
5
|
constructor(env: RioEnv);
|
|
6
6
|
getNextAvailableRow(sheetId: string): Promise<number>;
|
|
7
|
-
|
|
7
|
+
appendRowToNextAvailableRow(sheetId: string, rowData: string[]): Promise<void>;
|
|
8
8
|
}
|
|
9
9
|
export declare const googleSheetsAPIClient: GoogleSheetsAPIClient;
|
|
10
10
|
export {};
|
|
@@ -45,10 +45,10 @@ class GoogleSheetsAPIClient {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
// If no empty row found, return the next row after the last row
|
|
48
|
-
return data.length
|
|
48
|
+
return data.length;
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
appendRowToNextAvailableRow(sheetId, rowData) {
|
|
52
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
53
|
const authClientObject = yield this.googleAuth.getClient();
|
|
54
54
|
const sheets = googleapis_1.google.sheets({ version: "v4", auth: authClientObject });
|
|
@@ -56,11 +56,15 @@ class GoogleSheetsAPIClient {
|
|
|
56
56
|
if (nextAvailableRow === -1) {
|
|
57
57
|
throw new Error("Failed to find the next available row.");
|
|
58
58
|
}
|
|
59
|
-
const
|
|
59
|
+
const startColumnIndex = 1; // Column B (index 1)
|
|
60
|
+
const range = `${String.fromCharCode(65 + startColumnIndex)}${nextAvailableRow}`;
|
|
61
|
+
// Append empty cells for column A (if needed) and the actual data for other columns
|
|
62
|
+
const valuesToAppend = Array(startColumnIndex).fill("");
|
|
63
|
+
valuesToAppend.push(...rowData);
|
|
60
64
|
yield sheets.spreadsheets.values.append({
|
|
61
65
|
spreadsheetId: sheetId,
|
|
62
66
|
range,
|
|
63
|
-
valueInputOption: "
|
|
67
|
+
valueInputOption: "RAW",
|
|
64
68
|
requestBody: {
|
|
65
69
|
values: [rowData],
|
|
66
70
|
},
|