@lowdefy/connection-google-sheets 0.0.0-experimental-20231123101256

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.
Files changed (25) hide show
  1. package/LICENSE +201 -0
  2. package/dist/connections/GoogleSheet/GoogleSheet.js +34 -0
  3. package/dist/connections/GoogleSheet/GoogleSheetAppendMany/GoogleSheetAppendMany.js +39 -0
  4. package/dist/connections/GoogleSheet/GoogleSheetAppendMany/schema.js +56 -0
  5. package/dist/connections/GoogleSheet/GoogleSheetAppendOne/GoogleSheetAppendOne.js +41 -0
  6. package/dist/connections/GoogleSheet/GoogleSheetAppendOne/schema.js +49 -0
  7. package/dist/connections/GoogleSheet/GoogleSheetDeleteOne/GoogleSheetDeleteOne.js +55 -0
  8. package/dist/connections/GoogleSheet/GoogleSheetDeleteOne/schema.js +56 -0
  9. package/dist/connections/GoogleSheet/GoogleSheetGetMany/GoogleSheetGetMany.js +55 -0
  10. package/dist/connections/GoogleSheet/GoogleSheetGetMany/schema.js +57 -0
  11. package/dist/connections/GoogleSheet/GoogleSheetGetOne/GoogleSheetGetOne.js +48 -0
  12. package/dist/connections/GoogleSheet/GoogleSheetGetOne/schema.js +50 -0
  13. package/dist/connections/GoogleSheet/GoogleSheetUpdateMany/GoogleSheetUpdateMany.js +62 -0
  14. package/dist/connections/GoogleSheet/GoogleSheetUpdateMany/schema.js +72 -0
  15. package/dist/connections/GoogleSheet/GoogleSheetUpdateOne/GoogleSheetUpdateOne.js +74 -0
  16. package/dist/connections/GoogleSheet/GoogleSheetUpdateOne/schema.js +79 -0
  17. package/dist/connections/GoogleSheet/cleanRows.js +32 -0
  18. package/dist/connections/GoogleSheet/getSheet.js +57 -0
  19. package/dist/connections/GoogleSheet/mingoAggregation.js +44 -0
  20. package/dist/connections/GoogleSheet/mingoFilter.js +34 -0
  21. package/dist/connections/GoogleSheet/schema.js +110 -0
  22. package/dist/connections/GoogleSheet/transformTypes.js +93 -0
  23. package/dist/connections.js +15 -0
  24. package/dist/types.js +19 -0
  25. package/package.json +59 -0
@@ -0,0 +1,48 @@
1
+ /*
2
+ Copyright 2020-2023 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import cleanRows from '../cleanRows.js';
16
+ import getSheet from '../getSheet.js';
17
+ import { transformRead } from '../transformTypes.js';
18
+ import mingoFilter from '../mingoFilter.js';
19
+ import schema from './schema.js';
20
+ async function GoogleSheetGetOne({ request, connection }) {
21
+ const { filter, options = {} } = request;
22
+ const { limit, skip } = options;
23
+ const sheet = await getSheet({
24
+ connection
25
+ });
26
+ let rows = await sheet.getRows({
27
+ limit,
28
+ offset: skip
29
+ });
30
+ rows = cleanRows(rows);
31
+ rows = transformRead({
32
+ input: rows,
33
+ types: connection.columnTypes
34
+ });
35
+ if (filter) {
36
+ rows = mingoFilter({
37
+ input: rows,
38
+ filter
39
+ });
40
+ }
41
+ return rows[0] ?? null;
42
+ }
43
+ GoogleSheetGetOne.schema = schema;
44
+ GoogleSheetGetOne.meta = {
45
+ checkRead: true,
46
+ checkWrite: false
47
+ };
48
+ export default GoogleSheetGetOne;
@@ -0,0 +1,50 @@
1
+ /*
2
+ Copyright 2020-2023 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ export default {
16
+ $schema: 'http://json-schema.org/draft-07/schema#',
17
+ title: 'Lowdefy Request Schema - GoogleSheetGetOne',
18
+ type: 'object',
19
+ properties: {
20
+ filter: {
21
+ type: 'object',
22
+ description: 'A MongoDB query expression to filter the data.',
23
+ errorMessage: {
24
+ type: 'GoogleSheetGetOne request property "filter" should be an object.'
25
+ }
26
+ },
27
+ options: {
28
+ type: 'object',
29
+ properties: {
30
+ limit: {
31
+ type: 'number',
32
+ description: 'The maximum number of rows to fetch.',
33
+ errorMessage: {
34
+ type: 'GoogleSheetGetOne request property "options.limit" should be a number.'
35
+ }
36
+ },
37
+ skip: {
38
+ type: 'number',
39
+ description: 'The number of rows to skip from the top of the sheet.',
40
+ errorMessage: {
41
+ type: 'GoogleSheetGetOne request property "options.skip" should be a number.'
42
+ }
43
+ }
44
+ }
45
+ }
46
+ },
47
+ errorMessage: {
48
+ type: 'GoogleSheetGetOne request properties should be an object.'
49
+ }
50
+ };
@@ -0,0 +1,62 @@
1
+ /*
2
+ Copyright 2020-2023 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import getSheet from '../getSheet.js';
16
+ import { transformRead, transformWrite } from '../transformTypes.js';
17
+ import mingoFilter from '../mingoFilter.js';
18
+ import schema from './schema.js';
19
+ async function GoogleSheetUpdateMany({ request, connection }) {
20
+ const { filter, update, options = {} } = request;
21
+ const { limit, skip, raw } = options;
22
+ const sheet = await getSheet({
23
+ connection
24
+ });
25
+ let rows = await sheet.getRows({
26
+ limit,
27
+ offset: skip
28
+ });
29
+ rows = transformRead({
30
+ input: rows,
31
+ types: connection.columnTypes
32
+ });
33
+ rows = mingoFilter({
34
+ input: rows,
35
+ filter
36
+ });
37
+ const transformedUpdate = transformWrite({
38
+ input: update,
39
+ types: connection.columnTypes
40
+ });
41
+ if (rows.length === 0) {
42
+ return {
43
+ modifiedCount: 0
44
+ };
45
+ }
46
+ const promises = rows.map(async (row)=>{
47
+ Object.assign(row, transformedUpdate);
48
+ await row.save({
49
+ raw
50
+ });
51
+ });
52
+ await Promise.all(promises);
53
+ return {
54
+ modifiedCount: rows.length
55
+ };
56
+ }
57
+ GoogleSheetUpdateMany.schema = schema;
58
+ GoogleSheetUpdateMany.meta = {
59
+ checkRead: false,
60
+ checkWrite: true
61
+ };
62
+ export default GoogleSheetUpdateMany;
@@ -0,0 +1,72 @@
1
+ /*
2
+ Copyright 2020-2023 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ export default {
16
+ $schema: 'http://json-schema.org/draft-07/schema#',
17
+ title: 'Lowdefy Request Schema - GoogleSheetUpdateMany',
18
+ type: 'object',
19
+ required: [
20
+ 'update',
21
+ 'filter'
22
+ ],
23
+ properties: {
24
+ filter: {
25
+ type: 'object',
26
+ description: 'A MongoDB query expression to filter the data. All rows matched by the filter will be updated.',
27
+ errorMessage: {
28
+ type: 'GoogleSheetUpdateMany request property "filter" should be an object.'
29
+ }
30
+ },
31
+ update: {
32
+ type: 'object',
33
+ description: 'The update to apply to the row. An object where keys are the column names and values are the updated values.',
34
+ errorMessage: {
35
+ type: 'GoogleSheetUpdateMany request property "update" should be an object.'
36
+ }
37
+ },
38
+ options: {
39
+ type: 'object',
40
+ properties: {
41
+ limit: {
42
+ type: 'number',
43
+ description: 'The maximum number of rows to fetch.',
44
+ errorMessage: {
45
+ type: 'GoogleSheetUpdateMany request property "options.limit" should be a number.'
46
+ }
47
+ },
48
+ raw: {
49
+ type: 'boolean',
50
+ description: 'Store raw values instead of converting as if typed into the sheets UI.',
51
+ errorMessage: {
52
+ type: 'GoogleSheetUpdateMany request property "options.raw" should be a boolean.'
53
+ }
54
+ },
55
+ skip: {
56
+ type: 'number',
57
+ description: 'The number of rows to skip from the top of the sheet.',
58
+ errorMessage: {
59
+ type: 'GoogleSheetUpdateMany request property "options.skip" should be a number.'
60
+ }
61
+ }
62
+ }
63
+ }
64
+ },
65
+ errorMessage: {
66
+ type: 'GoogleSheetUpdateMany request properties should be an object.',
67
+ required: {
68
+ filter: 'GoogleSheetUpdateMany request should have required property "filter".',
69
+ update: 'GoogleSheetUpdateMany request should have required property "update".'
70
+ }
71
+ }
72
+ };
@@ -0,0 +1,74 @@
1
+ /*
2
+ Copyright 2020-2023 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import cleanRows from '../cleanRows.js';
16
+ import getSheet from '../getSheet.js';
17
+ import { transformRead, transformWrite } from '../transformTypes.js';
18
+ import mingoFilter from '../mingoFilter.js';
19
+ import schema from './schema.js';
20
+ async function GoogleSheetUpdateOne({ request, connection }) {
21
+ const { filter, update, options = {} } = request;
22
+ const { limit, skip, upsert, raw } = options;
23
+ const sheet = await getSheet({
24
+ connection
25
+ });
26
+ let rows = await sheet.getRows({
27
+ limit,
28
+ offset: skip
29
+ });
30
+ rows = transformRead({
31
+ input: rows,
32
+ types: connection.columnTypes
33
+ });
34
+ rows = mingoFilter({
35
+ input: rows,
36
+ filter
37
+ });
38
+ const transformedUpdate = transformWrite({
39
+ input: update,
40
+ types: connection.columnTypes
41
+ });
42
+ if (rows.length === 0) {
43
+ if (upsert) {
44
+ const insertedRow = await sheet.addRow(transformedUpdate, {
45
+ raw
46
+ });
47
+ return {
48
+ modifiedCount: 1,
49
+ upserted: true,
50
+ row: cleanRows(insertedRow)
51
+ };
52
+ }
53
+ return {
54
+ modifiedCount: 0,
55
+ upserted: false
56
+ };
57
+ }
58
+ const row = rows[0];
59
+ Object.assign(row, transformedUpdate);
60
+ await row.save({
61
+ raw
62
+ });
63
+ return {
64
+ modifiedCount: 1,
65
+ upserted: false,
66
+ row: cleanRows(row)
67
+ };
68
+ }
69
+ GoogleSheetUpdateOne.schema = schema;
70
+ GoogleSheetUpdateOne.meta = {
71
+ checkRead: false,
72
+ checkWrite: true
73
+ };
74
+ export default GoogleSheetUpdateOne;
@@ -0,0 +1,79 @@
1
+ /*
2
+ Copyright 2020-2023 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ export default {
16
+ $schema: 'http://json-schema.org/draft-07/schema#',
17
+ title: 'Lowdefy Request Schema - GoogleSheetUpdateOne',
18
+ type: 'object',
19
+ required: [
20
+ 'update',
21
+ 'filter'
22
+ ],
23
+ properties: {
24
+ filter: {
25
+ type: 'object',
26
+ description: 'A MongoDB query expression to filter the data. The first row matched by the filter will be updated.',
27
+ errorMessage: {
28
+ type: 'GoogleSheetUpdateOne request property "filter" should be an object.'
29
+ }
30
+ },
31
+ update: {
32
+ type: 'object',
33
+ description: 'The update to apply to the row. An object where keys are the column names and values are the updated values.',
34
+ errorMessage: {
35
+ type: 'GoogleSheetUpdateOne request property "update" should be an object.'
36
+ }
37
+ },
38
+ options: {
39
+ type: 'object',
40
+ properties: {
41
+ limit: {
42
+ type: 'number',
43
+ description: 'The maximum number of rows to fetch.',
44
+ errorMessage: {
45
+ type: 'GoogleSheetUpdateOne request property "options.limit" should be a number.'
46
+ }
47
+ },
48
+ raw: {
49
+ type: 'boolean',
50
+ description: 'Store raw values instead of converting as if typed into the sheets UI.',
51
+ errorMessage: {
52
+ type: 'GoogleSheetUpdateOne request property "options.raw" should be a boolean.'
53
+ }
54
+ },
55
+ skip: {
56
+ type: 'number',
57
+ description: 'The number of rows to skip from the top of the sheet.',
58
+ errorMessage: {
59
+ type: 'GoogleSheetUpdateOne request property "options.skip" should be a number.'
60
+ }
61
+ },
62
+ upsert: {
63
+ type: 'boolean',
64
+ description: 'Insert the row if no rows are matched by the filter.',
65
+ errorMessage: {
66
+ type: 'GoogleSheetUpdateOne request property "options.upsert" should be a boolean.'
67
+ }
68
+ }
69
+ }
70
+ }
71
+ },
72
+ errorMessage: {
73
+ type: 'GoogleSheetUpdateOne request properties should be an object.',
74
+ required: {
75
+ filter: 'GoogleSheetUpdateOne request should have required property "filter".',
76
+ update: 'GoogleSheetUpdateOne request should have required property "update".'
77
+ }
78
+ }
79
+ };
@@ -0,0 +1,32 @@
1
+ /*
2
+ Copyright 2020-2023 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { type } from '@lowdefy/helpers';
16
+ function cleanRow(row) {
17
+ // eslint-disable-next-line no-unused-vars
18
+ const { _sheet, ...rest } = row;
19
+ return {
20
+ ...rest
21
+ };
22
+ }
23
+ function cleanRows(input) {
24
+ if (type.isObject(input)) {
25
+ return cleanRow(input);
26
+ }
27
+ if (type.isArray(input)) {
28
+ return input.map((row)=>cleanRow(row));
29
+ }
30
+ throw new Error(`cleanRows received invalid input type ${type.typeOf(input)}.`);
31
+ }
32
+ export default cleanRows;
@@ -0,0 +1,57 @@
1
+ /*
2
+ Copyright 2020-2023 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { GoogleSpreadsheet } from 'google-spreadsheet';
16
+ async function authenticate({ doc, apiKey, client_email, private_key }) {
17
+ if (apiKey) {
18
+ doc.useApiKey(apiKey);
19
+ } else {
20
+ await doc.useServiceAccountAuth({
21
+ client_email,
22
+ private_key
23
+ });
24
+ }
25
+ }
26
+ function getSheetFromDoc({ doc, sheetId, sheetIndex }) {
27
+ let sheet;
28
+ if (sheetId) {
29
+ sheet = doc.sheetsById[sheetId];
30
+ if (!sheet) {
31
+ throw new Error(`Could not find sheet with sheetId "${sheetId}"`);
32
+ }
33
+ } else {
34
+ sheet = doc.sheetsByIndex[sheetIndex];
35
+ if (!sheet) {
36
+ throw new Error(`Could not find sheet with sheetIndex ${sheetIndex}`);
37
+ }
38
+ }
39
+ return sheet;
40
+ }
41
+ async function getSheet({ connection }) {
42
+ const { apiKey, client_email, private_key, sheetId, sheetIndex, spreadsheetId } = connection;
43
+ const doc = new GoogleSpreadsheet(spreadsheetId);
44
+ await authenticate({
45
+ doc,
46
+ apiKey,
47
+ client_email,
48
+ private_key
49
+ });
50
+ await doc.loadInfo();
51
+ return getSheetFromDoc({
52
+ doc,
53
+ sheetId,
54
+ sheetIndex
55
+ });
56
+ }
57
+ export default getSheet;
@@ -0,0 +1,44 @@
1
+ /*
2
+ Copyright 2020-2023 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { type } from '@lowdefy/helpers';
16
+ import mingo from 'mingo';
17
+ // TODO: fix build to work with:
18
+ import 'mingo/init/system';
19
+ // import { useOperators, OperatorType } from 'mingo/core.js';
20
+ // import * as accumulatorOperators from 'mingo/operators/accumulator/index.js';
21
+ // import * as expressionOperators from 'mingo/operators/expression/index.js';
22
+ // import * as pipelineOperators from 'mingo/operators/pipeline/index.js';
23
+ // import * as queryOperators from 'mingo/operators/query/index.js';
24
+ // import * as projectionOperators from 'mingo/operators/projection/index.js';
25
+ // // "import * as" is returning different object structures when the connection is being
26
+ // // imported in the build or when running the tests.
27
+ // // So we check for the a default object with all the named exports, otherwise the
28
+ // // returned object has all the named exports.
29
+ // useOperators(OperatorType.ACCUMULATOR, accumulatorOperators.default || accumulatorOperators);
30
+ // useOperators(OperatorType.EXPRESSION, expressionOperators.default || expressionOperators);
31
+ // useOperators(OperatorType.PIPELINE, pipelineOperators.default || pipelineOperators);
32
+ // useOperators(OperatorType.QUERY, queryOperators.default || queryOperators);
33
+ // useOperators(OperatorType.PROJECTION, projectionOperators.default || projectionOperators);
34
+ function mingoAggregation({ input = [], pipeline = [] }) {
35
+ if (!type.isArray(input)) {
36
+ throw new Error('Mingo aggregation error. Argument "input" should be an array.');
37
+ }
38
+ if (!type.isArray(pipeline)) {
39
+ throw new Error('Mingo aggregation error. Argument "pipeline" should be an array.');
40
+ }
41
+ const aggregator = new mingo.Aggregator(pipeline);
42
+ return aggregator.run(input);
43
+ }
44
+ export default mingoAggregation;
@@ -0,0 +1,34 @@
1
+ /*
2
+ Copyright 2020-2023 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { type } from '@lowdefy/helpers';
16
+ import mingoAggregation from './mingoAggregation.js';
17
+ function mingoFilter({ input = [], filter = {} }) {
18
+ if (!type.isObject(filter)) {
19
+ throw new Error('Mingo filter error. Argument "filter" should be an object.');
20
+ }
21
+ if (!type.isArray(input)) {
22
+ throw new Error('Mingo filter error. Argument "input" should be an array.');
23
+ }
24
+ const pipeline = [
25
+ {
26
+ $match: filter
27
+ }
28
+ ];
29
+ return mingoAggregation({
30
+ input,
31
+ pipeline
32
+ });
33
+ }
34
+ export default mingoFilter;
@@ -0,0 +1,110 @@
1
+ /*
2
+ Copyright 2020-2023 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ export default {
16
+ $schema: 'http://json-schema.org/draft-07/schema#',
17
+ title: 'Lowdefy Connection Schema - GoogleSheet',
18
+ type: 'object',
19
+ required: [
20
+ 'spreadsheetId'
21
+ ],
22
+ properties: {
23
+ apiKey: {
24
+ type: 'string',
25
+ description: 'API key for your google project.',
26
+ errorMessage: {
27
+ type: 'GoogleSheet connection property "apiKey" should be a string.'
28
+ }
29
+ },
30
+ client_email: {
31
+ type: 'string',
32
+ description: 'The email of your service account.',
33
+ errorMessage: {
34
+ type: 'GoogleSheet connection property "client_email" should be a string.'
35
+ }
36
+ },
37
+ private_key: {
38
+ type: 'string',
39
+ description: 'The private key for your service account.',
40
+ errorMessage: {
41
+ type: 'GoogleSheet connection property "private_key" should be a string.'
42
+ }
43
+ },
44
+ sheetId: {
45
+ type: 'string',
46
+ description: 'The ID of the worksheet. Can be found in the URL as the "gid" parameter. One of "sheetId" or "sheetIndex" is required.',
47
+ errorMessage: {
48
+ type: 'GoogleSheet connection property "sheetId" should be a string.'
49
+ }
50
+ },
51
+ sheetIndex: {
52
+ type: 'number',
53
+ description: 'The position of the worksheet as they appear in the Google sheets UI. Starts from 0. One of "sheetId" or "sheetIndex" is required.',
54
+ errorMessage: {
55
+ type: 'GoogleSheet connection property "sheetIndex" should be a number.'
56
+ }
57
+ },
58
+ spreadsheetId: {
59
+ type: 'string',
60
+ description: 'document ID from the URL of the spreadsheet.',
61
+ errorMessage: {
62
+ type: 'GoogleSheet connection property "spreadsheetId" should be a string.'
63
+ }
64
+ },
65
+ columnTypes: {
66
+ type: 'object',
67
+ description: 'Define types for columns in the spreadsheet.',
68
+ patternProperties: {
69
+ '^.*$': {
70
+ type: 'string',
71
+ enum: [
72
+ 'string',
73
+ 'number',
74
+ 'boolean',
75
+ 'date',
76
+ 'json'
77
+ ],
78
+ errorMessage: {
79
+ enum: 'GoogleSheet connection property "{{ instancePath }}" should be one of "string", "number", "boolean", "date", or "json".'
80
+ }
81
+ }
82
+ },
83
+ errorMessage: {
84
+ type: 'GoogleSheet connection property "columnTypes" should be an object.'
85
+ }
86
+ },
87
+ read: {
88
+ type: 'boolean',
89
+ default: true,
90
+ description: 'Allow reads from the spreadsheet.',
91
+ errorMessage: {
92
+ type: 'GoogleSheet connection property "read" should be a boolean.'
93
+ }
94
+ },
95
+ write: {
96
+ type: 'boolean',
97
+ default: false,
98
+ description: 'Allow writes to the spreadsheet.',
99
+ errorMessage: {
100
+ type: 'GoogleSheet connection property "write" should be a boolean.'
101
+ }
102
+ }
103
+ },
104
+ errorMessage: {
105
+ type: 'GoogleSheet connection properties should be an object.',
106
+ required: {
107
+ spreadsheetId: 'GoogleSheet connection should have required property "spreadsheetId".'
108
+ }
109
+ }
110
+ };