@lowdefy/connection-google-sheets 4.0.0-alpha.26 → 4.0.0-alpha.29
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/package.json +6 -7
- package/dist/connections/GoogleSheet/GoogleSheet.js +0 -34
- package/dist/connections/GoogleSheet/GoogleSheetAppendMany/GoogleSheetAppendMany.js +0 -39
- package/dist/connections/GoogleSheet/GoogleSheetAppendMany/schema.js +0 -56
- package/dist/connections/GoogleSheet/GoogleSheetAppendOne/GoogleSheetAppendOne.js +0 -41
- package/dist/connections/GoogleSheet/GoogleSheetAppendOne/schema.js +0 -49
- package/dist/connections/GoogleSheet/GoogleSheetDeleteOne/GoogleSheetDeleteOne.js +0 -55
- package/dist/connections/GoogleSheet/GoogleSheetDeleteOne/schema.js +0 -56
- package/dist/connections/GoogleSheet/GoogleSheetGetMany/GoogleSheetGetMany.js +0 -55
- package/dist/connections/GoogleSheet/GoogleSheetGetMany/schema.js +0 -57
- package/dist/connections/GoogleSheet/GoogleSheetGetOne/GoogleSheetGetOne.js +0 -48
- package/dist/connections/GoogleSheet/GoogleSheetGetOne/schema.js +0 -50
- package/dist/connections/GoogleSheet/GoogleSheetUpdateMany/GoogleSheetUpdateMany.js +0 -62
- package/dist/connections/GoogleSheet/GoogleSheetUpdateMany/schema.js +0 -72
- package/dist/connections/GoogleSheet/GoogleSheetUpdateOne/GoogleSheetUpdateOne.js +0 -74
- package/dist/connections/GoogleSheet/GoogleSheetUpdateOne/schema.js +0 -79
- package/dist/connections/GoogleSheet/cleanRows.js +0 -32
- package/dist/connections/GoogleSheet/getSheet.js +0 -57
- package/dist/connections/GoogleSheet/mingoAggregation.js +0 -44
- package/dist/connections/GoogleSheet/mingoFilter.js +0 -34
- package/dist/connections/GoogleSheet/schema.js +0 -110
- package/dist/connections/GoogleSheet/transformTypes.js +0 -93
- package/dist/connections.js +0 -15
- package/dist/types.js +0 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/connection-google-sheets",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.29",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -35,20 +35,19 @@
|
|
|
35
35
|
"dist/*"
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
|
-
"build": "
|
|
38
|
+
"build": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
|
|
39
39
|
"clean": "rm -rf dist",
|
|
40
|
-
"
|
|
41
|
-
"swc": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
|
|
40
|
+
"prepublishOnly": "pnpm build",
|
|
42
41
|
"test": "jest --coverage"
|
|
43
42
|
},
|
|
44
43
|
"dependencies": {
|
|
45
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
44
|
+
"@lowdefy/helpers": "4.0.0-alpha.29",
|
|
46
45
|
"google-spreadsheet": "3.3.0",
|
|
47
46
|
"mingo": "6.0.6",
|
|
48
47
|
"moment": "2.29.4"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
|
-
"@lowdefy/ajv": "4.0.0-alpha.
|
|
50
|
+
"@lowdefy/ajv": "4.0.0-alpha.29",
|
|
52
51
|
"@swc/cli": "0.1.57",
|
|
53
52
|
"@swc/core": "1.2.194",
|
|
54
53
|
"@swc/jest": "0.2.21",
|
|
@@ -57,5 +56,5 @@
|
|
|
57
56
|
"publishConfig": {
|
|
58
57
|
"access": "public"
|
|
59
58
|
},
|
|
60
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "621a191ebc0a1569ee6669dc74c12f8be5a8c7f3"
|
|
61
60
|
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 GoogleSheetAppendMany from './GoogleSheetAppendMany/GoogleSheetAppendMany.js';
|
|
16
|
-
import GoogleSheetAppendOne from './GoogleSheetAppendOne/GoogleSheetAppendOne.js';
|
|
17
|
-
import GoogleSheetDeleteOne from './GoogleSheetDeleteOne/GoogleSheetDeleteOne.js';
|
|
18
|
-
import GoogleSheetGetMany from './GoogleSheetGetMany/GoogleSheetGetMany.js';
|
|
19
|
-
import GoogleSheetGetOne from './GoogleSheetGetOne/GoogleSheetGetOne.js';
|
|
20
|
-
import GoogleSheetUpdateOne from './GoogleSheetUpdateOne/GoogleSheetUpdateOne.js';
|
|
21
|
-
import GoogleSheetUpdateMany from './GoogleSheetUpdateMany/GoogleSheetUpdateMany.js';
|
|
22
|
-
import schema from './schema.js';
|
|
23
|
-
export default {
|
|
24
|
-
schema,
|
|
25
|
-
requests: {
|
|
26
|
-
GoogleSheetAppendMany,
|
|
27
|
-
GoogleSheetAppendOne,
|
|
28
|
-
GoogleSheetDeleteOne,
|
|
29
|
-
GoogleSheetGetMany,
|
|
30
|
-
GoogleSheetGetOne,
|
|
31
|
-
GoogleSheetUpdateOne,
|
|
32
|
-
GoogleSheetUpdateMany
|
|
33
|
-
}
|
|
34
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 { transformWrite } from '../transformTypes.js';
|
|
17
|
-
import schema from './schema.js';
|
|
18
|
-
async function GoogleSheetAppendMany({ request , connection }) {
|
|
19
|
-
const { rows , options ={} } = request;
|
|
20
|
-
const { raw } = options;
|
|
21
|
-
const sheet = await getSheet({
|
|
22
|
-
connection
|
|
23
|
-
});
|
|
24
|
-
await sheet.addRows(transformWrite({
|
|
25
|
-
input: rows,
|
|
26
|
-
types: connection.columnTypes
|
|
27
|
-
}), {
|
|
28
|
-
raw
|
|
29
|
-
});
|
|
30
|
-
return {
|
|
31
|
-
insertedCount: rows.length
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
GoogleSheetAppendMany.schema = schema;
|
|
35
|
-
GoogleSheetAppendMany.meta = {
|
|
36
|
-
checkRead: false,
|
|
37
|
-
checkWrite: true
|
|
38
|
-
};
|
|
39
|
-
export default GoogleSheetAppendMany;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 - GoogleSheetAppendMany',
|
|
18
|
-
type: 'object',
|
|
19
|
-
required: [
|
|
20
|
-
'rows'
|
|
21
|
-
],
|
|
22
|
-
properties: {
|
|
23
|
-
rows: {
|
|
24
|
-
type: 'array',
|
|
25
|
-
description: 'The rows to insert into the sheet. An an array of objects where keys are the column names and values are the values to insert.',
|
|
26
|
-
errorMessage: {
|
|
27
|
-
type: 'GoogleSheetAppendMany request property "rows" should be an array.'
|
|
28
|
-
},
|
|
29
|
-
items: {
|
|
30
|
-
type: 'object',
|
|
31
|
-
description: 'The row to insert into the sheet. An object where keys are the column names and values are the values to insert.',
|
|
32
|
-
errorMessage: {
|
|
33
|
-
type: 'GoogleSheetAppendMany request property "rows" should be an array of objects.'
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
options: {
|
|
38
|
-
type: 'object',
|
|
39
|
-
properties: {
|
|
40
|
-
raw: {
|
|
41
|
-
type: 'boolean',
|
|
42
|
-
description: 'Store raw values instead of converting as if typed into the sheets UI.',
|
|
43
|
-
errorMessage: {
|
|
44
|
-
type: 'GoogleSheetAppendMany request property "options.raw" should be a boolean.'
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
errorMessage: {
|
|
51
|
-
type: 'GoogleSheetAppendMany request properties should be an object.',
|
|
52
|
-
required: {
|
|
53
|
-
rows: 'GoogleSheetAppendMany request should have required property "rows".'
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 cleanRows from '../cleanRows.js';
|
|
17
|
-
import { transformWrite } from '../transformTypes.js';
|
|
18
|
-
import schema from './schema.js';
|
|
19
|
-
async function GoogleSheetAppendOne({ request , connection }) {
|
|
20
|
-
const { row , options ={} } = request;
|
|
21
|
-
const { raw } = options;
|
|
22
|
-
const sheet = await getSheet({
|
|
23
|
-
connection
|
|
24
|
-
});
|
|
25
|
-
const insertedRow = await sheet.addRow(transformWrite({
|
|
26
|
-
input: row,
|
|
27
|
-
types: connection.columnTypes
|
|
28
|
-
}), {
|
|
29
|
-
raw
|
|
30
|
-
});
|
|
31
|
-
return {
|
|
32
|
-
insertedCount: 1,
|
|
33
|
-
row: cleanRows(insertedRow)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
GoogleSheetAppendOne.schema = schema;
|
|
37
|
-
GoogleSheetAppendOne.meta = {
|
|
38
|
-
checkRead: false,
|
|
39
|
-
checkWrite: true
|
|
40
|
-
};
|
|
41
|
-
export default GoogleSheetAppendOne;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 - GoogleSheetAppendOne',
|
|
18
|
-
type: 'object',
|
|
19
|
-
required: [
|
|
20
|
-
'row'
|
|
21
|
-
],
|
|
22
|
-
properties: {
|
|
23
|
-
row: {
|
|
24
|
-
type: 'object',
|
|
25
|
-
description: 'The row to insert into the sheet. An object where keys are the column names and values are the values to insert.',
|
|
26
|
-
errorMessage: {
|
|
27
|
-
type: 'GoogleSheetAppendOne request property "row" should be an object.'
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
options: {
|
|
31
|
-
type: 'object',
|
|
32
|
-
properties: {
|
|
33
|
-
raw: {
|
|
34
|
-
type: 'boolean',
|
|
35
|
-
description: 'Store raw values instead of converting as if typed into the sheets UI.',
|
|
36
|
-
errorMessage: {
|
|
37
|
-
type: 'GoogleSheetAppendOne request property "options.raw" should be a boolean.'
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
errorMessage: {
|
|
44
|
-
type: 'GoogleSheetAppendOne request properties should be an object.',
|
|
45
|
-
required: {
|
|
46
|
-
row: 'GoogleSheetAppendOne request should have required property "row".'
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 GoogleSheetDeleteOne({ 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 = transformRead({
|
|
31
|
-
input: rows,
|
|
32
|
-
types: connection.columnTypes
|
|
33
|
-
});
|
|
34
|
-
rows = mingoFilter({
|
|
35
|
-
input: rows,
|
|
36
|
-
filter
|
|
37
|
-
});
|
|
38
|
-
if (rows.length === 0) {
|
|
39
|
-
return {
|
|
40
|
-
deletedCount: 0
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
const row = rows[0];
|
|
44
|
-
await row.delete();
|
|
45
|
-
return {
|
|
46
|
-
deletedCount: 1,
|
|
47
|
-
row: cleanRows(row)
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
GoogleSheetDeleteOne.schema = schema;
|
|
51
|
-
GoogleSheetDeleteOne.meta = {
|
|
52
|
-
checkRead: false,
|
|
53
|
-
checkWrite: true
|
|
54
|
-
};
|
|
55
|
-
export default GoogleSheetDeleteOne;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 - GoogleSheetDeleteOne',
|
|
18
|
-
type: 'object',
|
|
19
|
-
required: [
|
|
20
|
-
'filter'
|
|
21
|
-
],
|
|
22
|
-
properties: {
|
|
23
|
-
filter: {
|
|
24
|
-
type: 'object',
|
|
25
|
-
description: 'A MongoDB query expression to filter the data. The first row matched by the filter will be deleted.',
|
|
26
|
-
errorMessage: {
|
|
27
|
-
type: 'GoogleSheetDeleteOne request property "filter" should be an object.'
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
options: {
|
|
31
|
-
type: 'object',
|
|
32
|
-
properties: {
|
|
33
|
-
limit: {
|
|
34
|
-
type: 'number',
|
|
35
|
-
description: 'The maximum number of rows to fetch.',
|
|
36
|
-
errorMessage: {
|
|
37
|
-
type: 'GoogleSheetDeleteOne request property "options.limit" should be a number.'
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
skip: {
|
|
41
|
-
type: 'number',
|
|
42
|
-
description: 'The number of rows to skip from the top of the sheet.',
|
|
43
|
-
errorMessage: {
|
|
44
|
-
type: 'GoogleSheetDeleteOne request property "options.skip" should be a number.'
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
errorMessage: {
|
|
51
|
-
type: 'GoogleSheetDeleteOne request properties should be an object.',
|
|
52
|
-
required: {
|
|
53
|
-
filter: 'GoogleSheetDeleteOne request should have required property "filter".'
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 mingoAggregation from '../mingoAggregation.js';
|
|
19
|
-
import mingoFilter from '../mingoFilter.js';
|
|
20
|
-
import schema from './schema.js';
|
|
21
|
-
async function GoogleSheetGetMany({ request , connection }) {
|
|
22
|
-
const { filter , pipeline , options ={} } = request;
|
|
23
|
-
const { limit , skip } = options;
|
|
24
|
-
const sheet = await getSheet({
|
|
25
|
-
connection
|
|
26
|
-
});
|
|
27
|
-
let rows = await sheet.getRows({
|
|
28
|
-
limit,
|
|
29
|
-
offset: skip
|
|
30
|
-
});
|
|
31
|
-
rows = cleanRows(rows);
|
|
32
|
-
rows = transformRead({
|
|
33
|
-
input: rows,
|
|
34
|
-
types: connection.columnTypes
|
|
35
|
-
});
|
|
36
|
-
if (filter) {
|
|
37
|
-
rows = mingoFilter({
|
|
38
|
-
input: rows,
|
|
39
|
-
filter
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
if (pipeline) {
|
|
43
|
-
rows = mingoAggregation({
|
|
44
|
-
input: rows,
|
|
45
|
-
pipeline
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return rows;
|
|
49
|
-
}
|
|
50
|
-
GoogleSheetGetMany.schema = schema;
|
|
51
|
-
GoogleSheetGetMany.meta = {
|
|
52
|
-
checkRead: true,
|
|
53
|
-
checkWrite: false
|
|
54
|
-
};
|
|
55
|
-
export default GoogleSheetGetMany;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 - GoogleSheetGetMany',
|
|
18
|
-
type: 'object',
|
|
19
|
-
properties: {
|
|
20
|
-
filter: {
|
|
21
|
-
type: 'object',
|
|
22
|
-
description: 'A MongoDB query expression to filter the data.',
|
|
23
|
-
errorMessage: {
|
|
24
|
-
type: 'GoogleSheetGetMany request property "filter" should be an object.'
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
pipeline: {
|
|
28
|
-
type: 'array',
|
|
29
|
-
description: 'A MongoDB aggregation pipeline to transform the data.',
|
|
30
|
-
errorMessage: {
|
|
31
|
-
type: 'GoogleSheetGetMany request property "pipeline" should be an array.'
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
options: {
|
|
35
|
-
type: 'object',
|
|
36
|
-
properties: {
|
|
37
|
-
limit: {
|
|
38
|
-
type: 'number',
|
|
39
|
-
description: 'The maximum number of rows to fetch.',
|
|
40
|
-
errorMessage: {
|
|
41
|
-
type: 'GoogleSheetGetMany request property "options.limit" should be a number.'
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
skip: {
|
|
45
|
-
type: 'number',
|
|
46
|
-
description: 'The number of rows to skip from the top of the sheet.',
|
|
47
|
-
errorMessage: {
|
|
48
|
-
type: 'GoogleSheetGetMany request property "options.skip" should be a number.'
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
errorMessage: {
|
|
55
|
-
type: 'GoogleSheetGetMany request properties should be an object.'
|
|
56
|
-
}
|
|
57
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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: client_email,
|
|
22
|
-
private_key: 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;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 moment from 'moment';
|
|
17
|
-
const readTransformers = {
|
|
18
|
-
string: (value)=>value,
|
|
19
|
-
number: (value)=>{
|
|
20
|
-
const number = Number(value);
|
|
21
|
-
if (isNaN(number)) return null;
|
|
22
|
-
return number;
|
|
23
|
-
},
|
|
24
|
-
boolean: (value)=>value === 'TRUE',
|
|
25
|
-
date: (value)=>{
|
|
26
|
-
const date = moment.utc(value);
|
|
27
|
-
if (!date.isValid()) return null;
|
|
28
|
-
return date.toDate();
|
|
29
|
-
},
|
|
30
|
-
json: (value)=>{
|
|
31
|
-
try {
|
|
32
|
-
return JSON.parse(value);
|
|
33
|
-
} catch (_) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const writeTransformers = {
|
|
39
|
-
string: (value)=>value,
|
|
40
|
-
number: (value)=>type.isNumber(value) ? value.toString() : value,
|
|
41
|
-
boolean: (value)=>{
|
|
42
|
-
if (value === true) return 'TRUE';
|
|
43
|
-
if (value === false) return 'FALSE';
|
|
44
|
-
return value;
|
|
45
|
-
},
|
|
46
|
-
date: (value)=>type.isDate(value) ? value.toISOString() : value,
|
|
47
|
-
json: (value)=>{
|
|
48
|
-
try {
|
|
49
|
-
return JSON.stringify(value);
|
|
50
|
-
} catch (_) {
|
|
51
|
-
return value;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const transformObject = ({ transformers , types })=>(object)=>{
|
|
56
|
-
Object.keys(object).forEach((key)=>{
|
|
57
|
-
if (types[key]) {
|
|
58
|
-
object[key] = transformers[types[key]](object[key]);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
return object;
|
|
62
|
-
};
|
|
63
|
-
function transformRead({ input , types ={} }) {
|
|
64
|
-
if (type.isObject(input)) {
|
|
65
|
-
return transformObject({
|
|
66
|
-
transformers: readTransformers,
|
|
67
|
-
types
|
|
68
|
-
})(input);
|
|
69
|
-
}
|
|
70
|
-
if (type.isArray(input)) {
|
|
71
|
-
return input.map((obj)=>transformObject({
|
|
72
|
-
transformers: readTransformers,
|
|
73
|
-
types
|
|
74
|
-
})(obj));
|
|
75
|
-
}
|
|
76
|
-
throw new Error(`transformRead received invalid input type ${type.typeOf(input)}.`);
|
|
77
|
-
}
|
|
78
|
-
function transformWrite({ input , types ={} }) {
|
|
79
|
-
if (type.isObject(input)) {
|
|
80
|
-
return transformObject({
|
|
81
|
-
transformers: writeTransformers,
|
|
82
|
-
types
|
|
83
|
-
})(input);
|
|
84
|
-
}
|
|
85
|
-
if (type.isArray(input)) {
|
|
86
|
-
return input.map((obj)=>transformObject({
|
|
87
|
-
transformers: writeTransformers,
|
|
88
|
-
types
|
|
89
|
-
})(obj));
|
|
90
|
-
}
|
|
91
|
-
throw new Error(`transformWrite received invalid input type ${type.typeOf(input)}.`);
|
|
92
|
-
}
|
|
93
|
-
export { transformRead, transformWrite };
|
package/dist/connections.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 as GoogleSheet } from './connections/GoogleSheet/GoogleSheet.js';
|
package/dist/types.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/namespace */ /*
|
|
2
|
-
Copyright 2020-2022 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 * as connections from './connections.js';
|
|
16
|
-
export default {
|
|
17
|
-
connections: Object.keys(connections),
|
|
18
|
-
requests: Object.keys(connections).map((connection)=>Object.keys(connections[connection].requests)).flat()
|
|
19
|
-
};
|