@budibase/server 2.3.18-alpha.14 → 2.3.18-alpha.16

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.
@@ -8,14 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  const types_1 = require("@budibase/types");
13
16
  const google_auth_library_1 = require("google-auth-library");
14
17
  const utils_1 = require("./utils");
15
18
  const constants_1 = require("../constants");
16
19
  const google_spreadsheet_1 = require("google-spreadsheet");
20
+ const node_fetch_1 = __importDefault(require("node-fetch"));
17
21
  const backend_core_1 = require("@budibase/backend-core");
18
- const fetch = require("node-fetch");
19
22
  const SCHEMA = {
20
23
  plus: true,
21
24
  auth: {
@@ -116,7 +119,7 @@ class GoogleSheetsIntegration {
116
119
  }
117
120
  fetchAccessToken(payload) {
118
121
  return __awaiter(this, void 0, void 0, function* () {
119
- const response = yield fetch("https://www.googleapis.com/oauth2/v4/token", {
122
+ const response = yield (0, node_fetch_1.default)("https://www.googleapis.com/oauth2/v4/token", {
120
123
  method: "POST",
121
124
  body: JSON.stringify(Object.assign(Object.assign({}, payload), { grant_type: "refresh_token" })),
122
125
  headers: {
@@ -134,7 +137,7 @@ class GoogleSheetsIntegration {
134
137
  return __awaiter(this, void 0, void 0, function* () {
135
138
  try {
136
139
  // Initialise oAuth client
137
- let googleConfig = yield backend_core_1.configs.getGoogleConfig();
140
+ let googleConfig = yield backend_core_1.configs.getGoogleDatasourceConfig();
138
141
  if (!googleConfig) {
139
142
  throw new backend_core_1.HTTPError("Google config not found", 400);
140
143
  }
@@ -163,7 +166,7 @@ class GoogleSheetsIntegration {
163
166
  buildSchema(datasourceId) {
164
167
  return __awaiter(this, void 0, void 0, function* () {
165
168
  yield this.connect();
166
- const sheets = yield this.client.sheetsByIndex;
169
+ const sheets = this.client.sheetsByIndex;
167
170
  const tables = {};
168
171
  for (let sheet of sheets) {
169
172
  // must fetch rows to determine schema
@@ -244,7 +247,7 @@ class GoogleSheetsIntegration {
244
247
  return __awaiter(this, void 0, void 0, function* () {
245
248
  try {
246
249
  yield this.connect();
247
- const sheet = yield this.client.sheetsByTitle[table.name];
250
+ const sheet = this.client.sheetsByTitle[table.name];
248
251
  yield sheet.loadHeaderRow();
249
252
  if (table._rename) {
250
253
  const headers = [];
@@ -259,8 +262,12 @@ class GoogleSheetsIntegration {
259
262
  yield sheet.setHeaderRow(headers);
260
263
  }
261
264
  else {
262
- let newField = Object.keys(table.schema).find(key => !sheet.headerValues.includes(key));
263
- yield sheet.setHeaderRow([...sheet.headerValues, newField]);
265
+ const updatedHeaderValues = [...sheet.headerValues];
266
+ const newField = Object.keys(table.schema).find(key => !sheet.headerValues.includes(key));
267
+ if (newField) {
268
+ updatedHeaderValues.push(newField);
269
+ }
270
+ yield sheet.setHeaderRow(updatedHeaderValues);
264
271
  }
265
272
  }
266
273
  catch (err) {
@@ -273,7 +280,7 @@ class GoogleSheetsIntegration {
273
280
  return __awaiter(this, void 0, void 0, function* () {
274
281
  try {
275
282
  yield this.connect();
276
- const sheetToDelete = yield this.client.sheetsByTitle[sheet];
283
+ const sheetToDelete = this.client.sheetsByTitle[sheet];
277
284
  return yield sheetToDelete.delete();
278
285
  }
279
286
  catch (err) {
@@ -286,7 +293,7 @@ class GoogleSheetsIntegration {
286
293
  return __awaiter(this, void 0, void 0, function* () {
287
294
  try {
288
295
  yield this.connect();
289
- const sheet = yield this.client.sheetsByTitle[query.sheet];
296
+ const sheet = this.client.sheetsByTitle[query.sheet];
290
297
  const rowToInsert = typeof query.row === "string" ? JSON.parse(query.row) : query.row;
291
298
  const row = yield sheet.addRow(rowToInsert);
292
299
  return [
@@ -303,7 +310,7 @@ class GoogleSheetsIntegration {
303
310
  return __awaiter(this, void 0, void 0, function* () {
304
311
  try {
305
312
  yield this.connect();
306
- const sheet = yield this.client.sheetsByTitle[query.sheet];
313
+ const sheet = this.client.sheetsByTitle[query.sheet];
307
314
  const rows = yield sheet.getRows();
308
315
  const headerValues = sheet.headerValues;
309
316
  const response = [];
@@ -322,7 +329,7 @@ class GoogleSheetsIntegration {
322
329
  return __awaiter(this, void 0, void 0, function* () {
323
330
  try {
324
331
  yield this.connect();
325
- const sheet = yield this.client.sheetsByTitle[query.sheet];
332
+ const sheet = this.client.sheetsByTitle[query.sheet];
326
333
  const rows = yield sheet.getRows();
327
334
  const row = rows[query.rowIndex];
328
335
  if (row) {
@@ -348,7 +355,7 @@ class GoogleSheetsIntegration {
348
355
  delete(query) {
349
356
  return __awaiter(this, void 0, void 0, function* () {
350
357
  yield this.connect();
351
- const sheet = yield this.client.sheetsByTitle[query.sheet];
358
+ const sheet = this.client.sheetsByTitle[query.sheet];
352
359
  const rows = yield sheet.getRows();
353
360
  const row = rows[query.rowIndex];
354
361
  if (row) {
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.3.18-alpha.13",
4
+ "version": "2.3.18-alpha.15",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -43,11 +43,11 @@
43
43
  "license": "GPL-3.0",
44
44
  "dependencies": {
45
45
  "@apidevtools/swagger-parser": "10.0.3",
46
- "@budibase/backend-core": "2.3.18-alpha.13",
47
- "@budibase/client": "2.3.18-alpha.13",
48
- "@budibase/pro": "2.3.18-alpha.13",
49
- "@budibase/string-templates": "2.3.18-alpha.13",
50
- "@budibase/types": "2.3.18-alpha.13",
46
+ "@budibase/backend-core": "2.3.18-alpha.15",
47
+ "@budibase/client": "2.3.18-alpha.15",
48
+ "@budibase/pro": "2.3.18-alpha.15",
49
+ "@budibase/string-templates": "2.3.18-alpha.15",
50
+ "@budibase/types": "2.3.18-alpha.15",
51
51
  "@bull-board/api": "3.7.0",
52
52
  "@bull-board/koa": "3.9.4",
53
53
  "@elastic/elasticsearch": "7.10.0",
@@ -87,6 +87,7 @@
87
87
  "koa-send": "5.0.0",
88
88
  "koa-session": "5.12.0",
89
89
  "koa-static": "5.0.0",
90
+ "koa-useragent": "^4.1.0",
90
91
  "koa2-ratelimit": "1.1.1",
91
92
  "lodash": "4.17.21",
92
93
  "memorystream": "0.3.1",
package/dist/startup.js CHANGED
@@ -141,6 +141,9 @@ function startup(app, server) {
141
141
  // get the references to the queue promises, don't await as
142
142
  // they will never end, unless the processing stops
143
143
  let queuePromises = [];
144
+ // configure events to use the pro audit log write
145
+ // can't integrate directly into backend-core due to cyclic issues
146
+ queuePromises.push(backend_core_1.events.processors.init(pro.sdk.auditLogs.write));
144
147
  queuePromises.push(automations.init());
145
148
  queuePromises.push(initPro());
146
149
  if (app) {