@budibase/server 1.3.19-alpha.1 → 1.3.19
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/__mocks__/mongodb.ts +1 -1
- package/builder/assets/index.9ce4f8c5.css +6 -0
- package/builder/assets/index.a1f7532b.js +876 -0
- package/builder/assets/vendor.5e1fe644.css +1 -0
- package/builder/assets/vendor.67dbd8fa.js +248 -0
- package/builder/index.html +4 -2
- package/coverage/clover.xml +388 -441
- package/coverage/coverage-final.json +20 -20
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +8 -41
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +11 -68
- package/coverage/lcov-report/api/controllers/datasource.js.html +34 -73
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +46 -46
- package/coverage/lcov-report/api/controllers/integration.js.html +6 -6
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +2 -2
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +12 -207
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +13 -13
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +2 -2
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +5 -5
- package/coverage/lcov-report/api/routes/utils/validators.js.html +6 -9
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +1 -1
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +18 -18
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +20 -56
- package/coverage/lcov-report/events/AutomationEmitter.js.html +3 -3
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +37 -37
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +12 -12
- package/coverage/lcov-report/middleware/currentapp.js.html +40 -46
- package/coverage/lcov-report/middleware/index.html +15 -15
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +7 -7
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/utilities/budibaseDir.js.html +3 -3
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +16 -16
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +24 -24
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +2 -2
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +667 -780
- package/dist/api/controllers/application.js +5 -5
- package/dist/api/controllers/auth.js +0 -9
- package/dist/api/controllers/component.js +1 -14
- package/dist/api/controllers/datasource.js +8 -21
- package/dist/api/controllers/deploy/index.js +8 -1
- package/dist/api/controllers/integration.js +4 -4
- package/dist/api/controllers/row/external.js +1 -1
- package/dist/api/controllers/screen.js +2 -52
- package/dist/api/controllers/static/index.js +0 -1
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +0 -10
- package/dist/api/controllers/static/templates/preview.hbs +1 -5
- package/dist/api/index.js +1 -1
- package/dist/api/routes/application.js +2 -3
- package/dist/api/routes/index.js +0 -2
- package/dist/api/routes/public/tables.js +1 -1
- package/dist/api/routes/table.js +1 -1
- package/dist/api/routes/utils/validators.js +1 -2
- package/dist/app.js +0 -11
- package/dist/db/utils.js +1 -10
- package/dist/environment.js +0 -1
- package/dist/integrations/airtable.js +129 -126
- package/dist/integrations/arangodb.js +89 -86
- package/dist/integrations/base/query.js +2 -2
- package/dist/integrations/base/sqlTable.js +1 -3
- package/dist/integrations/couchdb.js +83 -80
- package/dist/integrations/dynamodb.js +164 -161
- package/dist/integrations/elasticsearch.js +138 -135
- package/dist/integrations/firebase.js +157 -154
- package/dist/integrations/googlesheets.js +327 -323
- package/dist/integrations/index.js +51 -99
- package/dist/integrations/microsoftSqlServer.js +243 -240
- package/dist/integrations/mongodb.js +242 -239
- package/dist/integrations/mysql.js +219 -215
- package/dist/integrations/oracle.js +322 -318
- package/dist/integrations/postgres.js +265 -262
- package/dist/integrations/redis.js +139 -134
- package/dist/integrations/rest.js +292 -289
- package/dist/integrations/s3.js +64 -61
- package/dist/integrations/snowflake.js +86 -83
- package/dist/middleware/currentapp.js +0 -2
- package/dist/migrations/functions/backfill/global.js +3 -0
- package/dist/migrations/functions/developerQuota.js +49 -0
- package/dist/{api/routes/plugin.js → migrations/functions/publishedAppsQuota.js} +21 -13
- package/dist/{api/controllers/plugin/url.js → migrations/functions/usageQuotas/syncDevelopers.js} +13 -13
- package/dist/{api/controllers/plugin/file.js → migrations/functions/usageQuotas/syncPublishedApps.js} +15 -13
- package/dist/migrations/index.js +10 -0
- package/dist/package.json +6 -9
- package/dist/tests/utilities/TestConfiguration.js +1 -1
- package/dist/threads/query.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +1 -110
- package/package.json +7 -10
- package/scripts/dev/manage.js +0 -1
- package/scripts/localdomain.js +1 -3
- package/specs/openapi.json +3 -3
- package/specs/openapi.yaml +3 -3
- package/specs/resources/query.js +1 -1
- package/src/api/controllers/application.ts +2 -1
- package/src/api/controllers/auth.js +0 -11
- package/src/api/controllers/component.js +2 -21
- package/src/api/controllers/datasource.js +8 -21
- package/src/api/controllers/deploy/index.ts +6 -1
- package/src/api/controllers/integration.js +4 -4
- package/src/api/controllers/row/external.js +1 -1
- package/src/api/controllers/screen.js +1 -66
- package/src/api/controllers/static/index.ts +1 -1
- package/src/api/controllers/static/templates/BudibaseApp.svelte +0 -10
- package/src/api/controllers/static/templates/preview.hbs +1 -5
- package/src/api/index.js +1 -1
- package/src/api/routes/application.ts +2 -13
- package/src/api/routes/index.ts +0 -2
- package/src/api/routes/public/tables.ts +1 -1
- package/src/api/routes/table.js +1 -1
- package/src/api/routes/tests/query.spec.js +25 -8
- package/src/api/routes/tests/user.spec.js +2 -0
- package/src/api/routes/utils/validators.js +1 -2
- package/src/app.ts +0 -14
- package/src/db/utils.js +0 -12
- package/src/definitions/openapi.ts +3 -3
- package/src/environment.js +0 -1
- package/src/integrations/airtable.ts +118 -116
- package/src/integrations/arangodb.ts +89 -87
- package/src/integrations/base/query.ts +2 -2
- package/src/integrations/base/sqlTable.ts +1 -3
- package/src/integrations/couchdb.ts +89 -83
- package/src/integrations/dynamodb.ts +175 -173
- package/src/integrations/elasticsearch.ts +122 -120
- package/src/integrations/firebase.ts +159 -157
- package/src/integrations/googlesheets.ts +338 -328
- package/src/integrations/index.ts +21 -64
- package/src/integrations/microsoftSqlServer.ts +251 -249
- package/src/integrations/mongodb.ts +258 -261
- package/src/integrations/mysql.ts +234 -229
- package/src/integrations/oracle.ts +380 -373
- package/src/integrations/postgres.ts +268 -264
- package/src/integrations/redis.ts +132 -128
- package/src/integrations/rest.ts +329 -324
- package/src/integrations/s3.ts +71 -68
- package/src/integrations/snowflake.ts +82 -80
- package/src/integrations/tests/{airtable.spec.ts → airtable.spec.js} +18 -21
- package/src/integrations/tests/{arangodb.spec.ts → arangodb.spec.js} +9 -12
- package/src/integrations/tests/{couchdb.spec.ts → couchdb.spec.js} +27 -33
- package/src/integrations/tests/{dynamodb.spec.ts → dynamodb.spec.js} +41 -45
- package/src/integrations/tests/{elasticsearch.spec.ts → elasticsearch.spec.js} +21 -22
- package/src/integrations/tests/{firebase.spec.ts → firebase.spec.js} +28 -33
- package/src/integrations/tests/{microsoftSqlServer.spec.ts → microsoftSqlServer.spec.js} +11 -12
- package/src/integrations/tests/{mongo.spec.ts → mongo.spec.js} +35 -46
- package/src/integrations/tests/{mysql.spec.ts → mysql.spec.js} +15 -17
- package/src/integrations/tests/{oracle.spec.ts → oracle.spec.js} +17 -19
- package/src/integrations/tests/{postgres.spec.ts → postgres.spec.js} +17 -19
- package/src/integrations/tests/{redis.spec.ts → redis.spec.js} +18 -27
- package/src/integrations/tests/{rest.spec.ts → rest.spec.js} +14 -22
- package/src/integrations/tests/{s3.spec.ts → s3.spec.js} +8 -10
- package/src/integrations/tests/{sql.spec.ts → sql.spec.js} +177 -228
- package/src/middleware/currentapp.js +0 -2
- package/src/migrations/functions/backfill/global.ts +3 -0
- package/src/migrations/functions/developerQuota.ts +15 -0
- package/src/migrations/functions/publishedAppsQuota.ts +13 -0
- package/src/migrations/functions/usageQuotas/syncDevelopers.ts +19 -0
- package/src/migrations/functions/usageQuotas/syncPublishedApps.ts +21 -0
- package/src/migrations/index.ts +16 -0
- package/src/module.d.ts +0 -2
- package/src/tests/utilities/TestConfiguration.js +1 -1
- package/src/threads/query.ts +2 -2
- package/src/utilities/fileSystem/index.js +0 -129
- package/builder/assets/index.1709d1b3.js +0 -1005
- package/builder/assets/index.8f621053.css +0 -6
- package/dist/api/controllers/plugin/github.js +0 -69
- package/dist/api/controllers/plugin/index.js +0 -200
- package/dist/api/controllers/plugin/npm.js +0 -58
- package/dist/api/controllers/plugin/uploaders.js +0 -11
- package/dist/api/controllers/plugin/utils.js +0 -26
- package/dist/watch.js +0 -77
- package/dist/websocket.js +0 -22
- package/src/api/controllers/plugin/file.ts +0 -15
- package/src/api/controllers/plugin/github.ts +0 -75
- package/src/api/controllers/plugin/index.ts +0 -215
- package/src/api/controllers/plugin/npm.ts +0 -56
- package/src/api/controllers/plugin/uploaders.ts +0 -4
- package/src/api/controllers/plugin/url.ts +0 -12
- package/src/api/controllers/plugin/utils.ts +0 -19
- package/src/api/routes/plugin.ts +0 -14
- package/src/watch.ts +0 -38
- package/src/websocket.ts +0 -26
|
@@ -18,361 +18,365 @@ const utils_1 = require("./utils");
|
|
|
18
18
|
const constants_1 = require("../constants");
|
|
19
19
|
const google_spreadsheet_1 = require("google-spreadsheet");
|
|
20
20
|
const environment_1 = __importDefault(require("../environment"));
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const {
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
docs: "https://developers.google.com/sheets/api/quickstart/nodejs",
|
|
32
|
-
description: "Create and collaborate on online spreadsheets in real-time and from any device. ",
|
|
33
|
-
friendlyName: "Google Sheets",
|
|
34
|
-
type: "Spreadsheet",
|
|
35
|
-
datasource: {
|
|
36
|
-
spreadsheetId: {
|
|
37
|
-
display: "Google Sheet URL",
|
|
38
|
-
type: types_1.DatasourceFieldType.STRING,
|
|
39
|
-
required: true,
|
|
21
|
+
var GoogleSheetsModule;
|
|
22
|
+
(function (GoogleSheetsModule) {
|
|
23
|
+
const { getGlobalDB } = require("@budibase/backend-core/tenancy");
|
|
24
|
+
const { getScopedConfig } = require("@budibase/backend-core/db");
|
|
25
|
+
const { Configs } = require("@budibase/backend-core/constants");
|
|
26
|
+
const fetch = require("node-fetch");
|
|
27
|
+
const SCHEMA = {
|
|
28
|
+
plus: true,
|
|
29
|
+
auth: {
|
|
30
|
+
type: "google",
|
|
40
31
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
type: types_1.QueryType.JSON,
|
|
52
|
-
required: true,
|
|
53
|
-
},
|
|
32
|
+
relationships: false,
|
|
33
|
+
docs: "https://developers.google.com/sheets/api/quickstart/nodejs",
|
|
34
|
+
description: "Create and collaborate on online spreadsheets in real-time and from any device. ",
|
|
35
|
+
friendlyName: "Google Sheets",
|
|
36
|
+
type: "Spreadsheet",
|
|
37
|
+
datasource: {
|
|
38
|
+
spreadsheetId: {
|
|
39
|
+
display: "Google Sheet URL",
|
|
40
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
41
|
+
required: true,
|
|
54
42
|
},
|
|
55
43
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
44
|
+
query: {
|
|
45
|
+
create: {
|
|
46
|
+
type: types_1.QueryType.FIELDS,
|
|
47
|
+
fields: {
|
|
48
|
+
sheet: {
|
|
49
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
50
|
+
required: true,
|
|
51
|
+
},
|
|
52
|
+
row: {
|
|
53
|
+
type: types_1.QueryType.JSON,
|
|
54
|
+
required: true,
|
|
55
|
+
},
|
|
62
56
|
},
|
|
63
57
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
rowIndex: {
|
|
73
|
-
type: types_1.DatasourceFieldType.STRING,
|
|
74
|
-
required: true,
|
|
75
|
-
},
|
|
76
|
-
row: {
|
|
77
|
-
type: types_1.QueryType.JSON,
|
|
78
|
-
required: true,
|
|
58
|
+
read: {
|
|
59
|
+
type: types_1.QueryType.FIELDS,
|
|
60
|
+
fields: {
|
|
61
|
+
sheet: {
|
|
62
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
63
|
+
required: true,
|
|
64
|
+
},
|
|
79
65
|
},
|
|
80
66
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
67
|
+
update: {
|
|
68
|
+
type: types_1.QueryType.FIELDS,
|
|
69
|
+
fields: {
|
|
70
|
+
sheet: {
|
|
71
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
72
|
+
required: true,
|
|
73
|
+
},
|
|
74
|
+
rowIndex: {
|
|
75
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
76
|
+
required: true,
|
|
77
|
+
},
|
|
78
|
+
row: {
|
|
79
|
+
type: types_1.QueryType.JSON,
|
|
80
|
+
required: true,
|
|
81
|
+
},
|
|
88
82
|
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
},
|
|
84
|
+
delete: {
|
|
85
|
+
type: types_1.QueryType.FIELDS,
|
|
86
|
+
fields: {
|
|
87
|
+
sheet: {
|
|
88
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
89
|
+
required: true,
|
|
90
|
+
},
|
|
91
|
+
rowIndex: {
|
|
92
|
+
type: types_1.DatasourceFieldType.NUMBER,
|
|
93
|
+
required: true,
|
|
94
|
+
},
|
|
92
95
|
},
|
|
93
96
|
},
|
|
94
97
|
},
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
this.client = new google_spreadsheet_1.GoogleSpreadsheet(spreadsheetId);
|
|
104
|
-
}
|
|
105
|
-
getBindingIdentifier() {
|
|
106
|
-
return "";
|
|
107
|
-
}
|
|
108
|
-
getStringConcat(parts) {
|
|
109
|
-
return "";
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Pull the spreadsheet ID out from a valid google sheets URL
|
|
113
|
-
* @param spreadsheetId - the URL or standard spreadsheetId of the google sheet
|
|
114
|
-
* @returns spreadsheet Id of the google sheet
|
|
115
|
-
*/
|
|
116
|
-
cleanSpreadsheetUrl(spreadsheetId) {
|
|
117
|
-
if (!spreadsheetId) {
|
|
118
|
-
throw new Error("You must set a spreadsheet ID in your configuration to fetch tables.");
|
|
98
|
+
};
|
|
99
|
+
class GoogleSheetsIntegration {
|
|
100
|
+
constructor(config) {
|
|
101
|
+
this.tables = {};
|
|
102
|
+
this.schemaErrors = {};
|
|
103
|
+
this.config = config;
|
|
104
|
+
const spreadsheetId = this.cleanSpreadsheetUrl(this.config.spreadsheetId);
|
|
105
|
+
this.client = new google_spreadsheet_1.GoogleSpreadsheet(spreadsheetId);
|
|
119
106
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
throw new Error(`Error authenticating with google sheets. ${json.error_description}`);
|
|
107
|
+
getBindingIdentifier() {
|
|
108
|
+
return "";
|
|
109
|
+
}
|
|
110
|
+
getStringConcat(parts) {
|
|
111
|
+
return "";
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Pull the spreadsheet ID out from a valid google sheets URL
|
|
115
|
+
* @param spreadsheetId - the URL or standard spreadsheetId of the google sheet
|
|
116
|
+
* @returns spreadsheet Id of the google sheet
|
|
117
|
+
*/
|
|
118
|
+
cleanSpreadsheetUrl(spreadsheetId) {
|
|
119
|
+
if (!spreadsheetId) {
|
|
120
|
+
throw new Error("You must set a spreadsheet ID in your configuration to fetch tables.");
|
|
135
121
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
122
|
+
const parts = spreadsheetId.split("/");
|
|
123
|
+
return parts.length > 5 ? parts[5] : spreadsheetId;
|
|
124
|
+
}
|
|
125
|
+
fetchAccessToken(payload) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
const response = yield fetch("https://www.googleapis.com/oauth2/v4/token", {
|
|
128
|
+
method: "POST",
|
|
129
|
+
body: JSON.stringify(Object.assign(Object.assign({}, payload), { grant_type: "refresh_token" })),
|
|
130
|
+
headers: {
|
|
131
|
+
"Content-Type": "application/json",
|
|
132
|
+
},
|
|
146
133
|
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
clientSecret: environment_1.default.GOOGLE_CLIENT_SECRET,
|
|
151
|
-
};
|
|
134
|
+
const json = yield response.json();
|
|
135
|
+
if (response.status !== 200) {
|
|
136
|
+
throw new Error(`Error authenticating with google sheets. ${json.error_description}`);
|
|
152
137
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
refresh_token: this.config.auth.refreshToken,
|
|
164
|
-
access_token: tokenResponse.access_token,
|
|
165
|
-
});
|
|
166
|
-
this.client.useOAuth2Client(oauthClient);
|
|
167
|
-
yield this.client.loadInfo();
|
|
168
|
-
}
|
|
169
|
-
catch (err) {
|
|
170
|
-
console.error("Error connecting to google sheets", err);
|
|
171
|
-
throw err;
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
buildSchema(datasourceId) {
|
|
176
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
-
yield this.connect();
|
|
178
|
-
const sheets = yield this.client.sheetsByIndex;
|
|
179
|
-
const tables = {};
|
|
180
|
-
for (let sheet of sheets) {
|
|
181
|
-
// must fetch rows to determine schema
|
|
182
|
-
yield sheet.getRows();
|
|
183
|
-
// build schema
|
|
184
|
-
const schema = {};
|
|
185
|
-
// build schema from headers
|
|
186
|
-
for (let header of sheet.headerValues) {
|
|
187
|
-
schema[header] = {
|
|
188
|
-
name: header,
|
|
189
|
-
type: constants_1.FieldTypes.STRING,
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
// create tables
|
|
193
|
-
tables[sheet.title] = {
|
|
194
|
-
_id: (0, utils_1.buildExternalTableId)(datasourceId, sheet.title),
|
|
195
|
-
name: sheet.title,
|
|
196
|
-
primary: ["rowNumber"],
|
|
197
|
-
schema,
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
this.tables = tables;
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
query(json) {
|
|
204
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
-
const sheet = json.endpoint.entityId;
|
|
206
|
-
const handlers = {
|
|
207
|
-
[constants_1.DataSourceOperation.CREATE]: () => this.create({ sheet, row: json.body }),
|
|
208
|
-
[constants_1.DataSourceOperation.READ]: () => this.read({ sheet }),
|
|
209
|
-
[constants_1.DataSourceOperation.UPDATE]: () => {
|
|
210
|
-
var _a, _b, _c;
|
|
211
|
-
return this.update({
|
|
212
|
-
// exclude the header row and zero index
|
|
213
|
-
rowIndex: ((_c = (_b = (_a = json.extra) === null || _a === void 0 ? void 0 : _a.idFilter) === null || _b === void 0 ? void 0 : _b.equal) === null || _c === void 0 ? void 0 : _c.rowNumber) - 2,
|
|
214
|
-
sheet,
|
|
215
|
-
row: json.body,
|
|
138
|
+
return json;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
connect() {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
try {
|
|
144
|
+
// Initialise oAuth client
|
|
145
|
+
const db = getGlobalDB();
|
|
146
|
+
let googleConfig = yield getScopedConfig(db, {
|
|
147
|
+
type: Configs.GOOGLE,
|
|
216
148
|
});
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
149
|
+
if (!googleConfig) {
|
|
150
|
+
googleConfig = {
|
|
151
|
+
clientID: environment_1.default.GOOGLE_CLIENT_ID,
|
|
152
|
+
clientSecret: environment_1.default.GOOGLE_CLIENT_SECRET,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const oauthClient = new google_auth_library_1.OAuth2Client({
|
|
156
|
+
clientId: googleConfig.clientID,
|
|
157
|
+
clientSecret: googleConfig.clientSecret,
|
|
224
158
|
});
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
159
|
+
const tokenResponse = yield this.fetchAccessToken({
|
|
160
|
+
client_id: googleConfig.clientID,
|
|
161
|
+
client_secret: googleConfig.clientSecret,
|
|
162
|
+
refresh_token: this.config.auth.refreshToken,
|
|
163
|
+
});
|
|
164
|
+
oauthClient.setCredentials({
|
|
165
|
+
refresh_token: this.config.auth.refreshToken,
|
|
166
|
+
access_token: tokenResponse.access_token,
|
|
167
|
+
});
|
|
168
|
+
this.client.useOAuth2Client(oauthClient);
|
|
169
|
+
yield this.client.loadInfo();
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
console.error("Error connecting to google sheets", err);
|
|
173
|
+
throw err;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
239
176
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
createTable(name) {
|
|
243
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
244
|
-
try {
|
|
177
|
+
buildSchema(datasourceId) {
|
|
178
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
245
179
|
yield this.connect();
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
updateTable(table) {
|
|
255
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
256
|
-
try {
|
|
257
|
-
yield this.connect();
|
|
258
|
-
const sheet = yield this.client.sheetsByTitle[table.name];
|
|
259
|
-
yield sheet.loadHeaderRow();
|
|
260
|
-
if (table._rename) {
|
|
261
|
-
const headers = [];
|
|
180
|
+
const sheets = yield this.client.sheetsByIndex;
|
|
181
|
+
const tables = {};
|
|
182
|
+
for (let sheet of sheets) {
|
|
183
|
+
// must fetch rows to determine schema
|
|
184
|
+
yield sheet.getRows();
|
|
185
|
+
// build schema
|
|
186
|
+
const schema = {};
|
|
187
|
+
// build schema from headers
|
|
262
188
|
for (let header of sheet.headerValues) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
189
|
+
schema[header] = {
|
|
190
|
+
name: header,
|
|
191
|
+
type: constants_1.FieldTypes.STRING,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
// create tables
|
|
195
|
+
tables[sheet.title] = {
|
|
196
|
+
_id: (0, utils_1.buildExternalTableId)(datasourceId, sheet.title),
|
|
197
|
+
name: sheet.title,
|
|
198
|
+
primary: ["rowNumber"],
|
|
199
|
+
schema,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
this.tables = tables;
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
query(json) {
|
|
206
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
+
const sheet = json.endpoint.entityId;
|
|
208
|
+
const handlers = {
|
|
209
|
+
[constants_1.DataSourceOperation.CREATE]: () => this.create({ sheet, row: json.body }),
|
|
210
|
+
[constants_1.DataSourceOperation.READ]: () => this.read({ sheet }),
|
|
211
|
+
[constants_1.DataSourceOperation.UPDATE]: () => {
|
|
212
|
+
var _a, _b, _c;
|
|
213
|
+
return this.update({
|
|
214
|
+
// exclude the header row and zero index
|
|
215
|
+
rowIndex: ((_c = (_b = (_a = json.extra) === null || _a === void 0 ? void 0 : _a.idFilter) === null || _b === void 0 ? void 0 : _b.equal) === null || _c === void 0 ? void 0 : _c.rowNumber) - 2,
|
|
216
|
+
sheet,
|
|
217
|
+
row: json.body,
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
[constants_1.DataSourceOperation.DELETE]: () => {
|
|
221
|
+
var _a, _b, _c;
|
|
222
|
+
return this.delete({
|
|
223
|
+
// exclude the header row and zero index
|
|
224
|
+
rowIndex: ((_c = (_b = (_a = json.extra) === null || _a === void 0 ? void 0 : _a.idFilter) === null || _b === void 0 ? void 0 : _b.equal) === null || _c === void 0 ? void 0 : _c.rowNumber) - 2,
|
|
225
|
+
sheet,
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
[constants_1.DataSourceOperation.CREATE_TABLE]: () => { var _a; return this.createTable((_a = json === null || json === void 0 ? void 0 : json.table) === null || _a === void 0 ? void 0 : _a.name); },
|
|
229
|
+
[constants_1.DataSourceOperation.UPDATE_TABLE]: () => this.updateTable(json.table),
|
|
230
|
+
[constants_1.DataSourceOperation.DELETE_TABLE]: () => { var _a; return this.deleteTable((_a = json === null || json === void 0 ? void 0 : json.table) === null || _a === void 0 ? void 0 : _a.name); },
|
|
231
|
+
};
|
|
232
|
+
const internalQueryMethod = handlers[json.endpoint.operation];
|
|
233
|
+
return yield internalQueryMethod();
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
buildRowObject(headers, values, rowNumber) {
|
|
237
|
+
const rowObject = { rowNumber };
|
|
238
|
+
for (let i = 0; i < headers.length; i++) {
|
|
239
|
+
rowObject._id = rowNumber;
|
|
240
|
+
rowObject[headers[i]] = values[i];
|
|
241
|
+
}
|
|
242
|
+
return rowObject;
|
|
243
|
+
}
|
|
244
|
+
createTable(name) {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
246
|
+
try {
|
|
247
|
+
yield this.connect();
|
|
248
|
+
const sheet = yield this.client.addSheet({ title: name });
|
|
249
|
+
return sheet;
|
|
250
|
+
}
|
|
251
|
+
catch (err) {
|
|
252
|
+
console.error("Error creating new table in google sheets", err);
|
|
253
|
+
throw err;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
updateTable(table) {
|
|
258
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
259
|
+
try {
|
|
260
|
+
yield this.connect();
|
|
261
|
+
const sheet = yield this.client.sheetsByTitle[table.name];
|
|
262
|
+
yield sheet.loadHeaderRow();
|
|
263
|
+
if (table._rename) {
|
|
264
|
+
const headers = [];
|
|
265
|
+
for (let header of sheet.headerValues) {
|
|
266
|
+
if (header === table._rename.old) {
|
|
267
|
+
headers.push(table._rename.updated);
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
headers.push(header);
|
|
271
|
+
}
|
|
268
272
|
}
|
|
273
|
+
yield sheet.setHeaderRow(headers);
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
let newField = Object.keys(table.schema).find(key => !sheet.headerValues.includes(key));
|
|
277
|
+
yield sheet.setHeaderRow([...sheet.headerValues, newField]);
|
|
269
278
|
}
|
|
270
|
-
yield sheet.setHeaderRow(headers);
|
|
271
279
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
280
|
+
catch (err) {
|
|
281
|
+
console.error("Error updating table in google sheets", err);
|
|
282
|
+
throw err;
|
|
275
283
|
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
285
|
-
try {
|
|
286
|
-
yield this.connect();
|
|
287
|
-
const sheetToDelete = yield this.client.sheetsByTitle[sheet];
|
|
288
|
-
return yield sheetToDelete.delete();
|
|
289
|
-
}
|
|
290
|
-
catch (err) {
|
|
291
|
-
console.error("Error deleting table in google sheets", err);
|
|
292
|
-
throw err;
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
create(query) {
|
|
297
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
298
|
-
try {
|
|
299
|
-
yield this.connect();
|
|
300
|
-
const sheet = yield this.client.sheetsByTitle[query.sheet];
|
|
301
|
-
const rowToInsert = typeof query.row === "string" ? JSON.parse(query.row) : query.row;
|
|
302
|
-
const row = yield sheet.addRow(rowToInsert);
|
|
303
|
-
return [
|
|
304
|
-
this.buildRowObject(sheet.headerValues, row._rawData, row._rowNumber),
|
|
305
|
-
];
|
|
306
|
-
}
|
|
307
|
-
catch (err) {
|
|
308
|
-
console.error("Error writing to google sheets", err);
|
|
309
|
-
throw err;
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
read(query) {
|
|
314
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
315
|
-
try {
|
|
316
|
-
yield this.connect();
|
|
317
|
-
const sheet = yield this.client.sheetsByTitle[query.sheet];
|
|
318
|
-
const rows = yield sheet.getRows();
|
|
319
|
-
const headerValues = sheet.headerValues;
|
|
320
|
-
const response = [];
|
|
321
|
-
for (let row of rows) {
|
|
322
|
-
response.push(this.buildRowObject(headerValues, row._rawData, row._rowNumber));
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
deleteTable(sheet) {
|
|
287
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
288
|
+
try {
|
|
289
|
+
yield this.connect();
|
|
290
|
+
const sheetToDelete = yield this.client.sheetsByTitle[sheet];
|
|
291
|
+
return yield sheetToDelete.delete();
|
|
323
292
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
293
|
+
catch (err) {
|
|
294
|
+
console.error("Error deleting table in google sheets", err);
|
|
295
|
+
throw err;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
create(query) {
|
|
300
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
301
|
+
try {
|
|
302
|
+
yield this.connect();
|
|
303
|
+
const sheet = yield this.client.sheetsByTitle[query.sheet];
|
|
304
|
+
const rowToInsert = typeof query.row === "string" ? JSON.parse(query.row) : query.row;
|
|
305
|
+
const row = yield sheet.addRow(rowToInsert);
|
|
306
|
+
return [
|
|
307
|
+
this.buildRowObject(sheet.headerValues, row._rawData, row._rowNumber),
|
|
308
|
+
];
|
|
309
|
+
}
|
|
310
|
+
catch (err) {
|
|
311
|
+
console.error("Error writing to google sheets", err);
|
|
312
|
+
throw err;
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
read(query) {
|
|
317
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
318
|
+
try {
|
|
319
|
+
yield this.connect();
|
|
320
|
+
const sheet = yield this.client.sheetsByTitle[query.sheet];
|
|
321
|
+
const rows = yield sheet.getRows();
|
|
322
|
+
const headerValues = sheet.headerValues;
|
|
323
|
+
const response = [];
|
|
324
|
+
for (let row of rows) {
|
|
325
|
+
response.push(this.buildRowObject(headerValues, row._rawData, row._rowNumber));
|
|
326
|
+
}
|
|
327
|
+
return response;
|
|
328
|
+
}
|
|
329
|
+
catch (err) {
|
|
330
|
+
console.error("Error reading from google sheets", err);
|
|
331
|
+
throw err;
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
update(query) {
|
|
336
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
337
|
+
try {
|
|
338
|
+
yield this.connect();
|
|
339
|
+
const sheet = yield this.client.sheetsByTitle[query.sheet];
|
|
340
|
+
const rows = yield sheet.getRows();
|
|
341
|
+
const row = rows[query.rowIndex];
|
|
342
|
+
if (row) {
|
|
343
|
+
const updateValues = typeof query.row === "string" ? JSON.parse(query.row) : query.row;
|
|
344
|
+
for (let key in updateValues) {
|
|
345
|
+
row[key] = updateValues[key];
|
|
346
|
+
}
|
|
347
|
+
yield row.save();
|
|
348
|
+
return [
|
|
349
|
+
this.buildRowObject(sheet.headerValues, row._rawData, row._rowNumber),
|
|
350
|
+
];
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
throw new Error("Row does not exist.");
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
catch (err) {
|
|
357
|
+
console.error("Error reading from google sheets", err);
|
|
358
|
+
throw err;
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
delete(query) {
|
|
363
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
335
364
|
yield this.connect();
|
|
336
365
|
const sheet = yield this.client.sheetsByTitle[query.sheet];
|
|
337
366
|
const rows = yield sheet.getRows();
|
|
338
367
|
const row = rows[query.rowIndex];
|
|
339
368
|
if (row) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
row[key] = updateValues[key];
|
|
343
|
-
}
|
|
344
|
-
yield row.save();
|
|
345
|
-
return [
|
|
346
|
-
this.buildRowObject(sheet.headerValues, row._rawData, row._rowNumber),
|
|
347
|
-
];
|
|
369
|
+
yield row.delete();
|
|
370
|
+
return [{ deleted: query.rowIndex }];
|
|
348
371
|
}
|
|
349
372
|
else {
|
|
350
373
|
throw new Error("Row does not exist.");
|
|
351
374
|
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
console.error("Error reading from google sheets", err);
|
|
355
|
-
throw err;
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
delete(query) {
|
|
360
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
361
|
-
yield this.connect();
|
|
362
|
-
const sheet = yield this.client.sheetsByTitle[query.sheet];
|
|
363
|
-
const rows = yield sheet.getRows();
|
|
364
|
-
const row = rows[query.rowIndex];
|
|
365
|
-
if (row) {
|
|
366
|
-
yield row.delete();
|
|
367
|
-
return [{ deleted: query.rowIndex }];
|
|
368
|
-
}
|
|
369
|
-
else {
|
|
370
|
-
throw new Error("Row does not exist.");
|
|
371
|
-
}
|
|
372
|
-
});
|
|
375
|
+
});
|
|
376
|
+
}
|
|
373
377
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
};
|
|
378
|
+
module.exports = {
|
|
379
|
+
schema: SCHEMA,
|
|
380
|
+
integration: GoogleSheetsIntegration,
|
|
381
|
+
};
|
|
382
|
+
})(GoogleSheetsModule || (GoogleSheetsModule = {}));
|