@lowdefy/connection-google-sheets 4.0.0-alpha.1

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 (31) hide show
  1. package/LICENSE +201 -0
  2. package/dist/connections/GoogleSheet/GoogleSheet.js +35 -0
  3. package/dist/connections/GoogleSheet/GoogleSheetAppendMany/GoogleSheetAppendMany.js +34 -0
  4. package/dist/connections/GoogleSheet/GoogleSheetAppendMany/GoogleSheetAppendManySchema.json +40 -0
  5. package/dist/connections/GoogleSheet/GoogleSheetAppendMany/index.js +24 -0
  6. package/dist/connections/GoogleSheet/GoogleSheetAppendOne/GoogleSheetAppendOne.js +36 -0
  7. package/dist/connections/GoogleSheet/GoogleSheetAppendOne/GoogleSheetAppendOneSchema.json +33 -0
  8. package/dist/connections/GoogleSheet/GoogleSheetAppendOne/index.js +24 -0
  9. package/dist/connections/GoogleSheet/GoogleSheetDeleteOne/GoogleSheetDeleteOne.js +50 -0
  10. package/dist/connections/GoogleSheet/GoogleSheetDeleteOne/GoogleSheetDeleteOneSchema.json +40 -0
  11. package/dist/connections/GoogleSheet/GoogleSheetDeleteOne/index.js +24 -0
  12. package/dist/connections/GoogleSheet/GoogleSheetGetMany/GoogleSheetGetMany.js +50 -0
  13. package/dist/connections/GoogleSheet/GoogleSheetGetMany/GoogleSheetGetManySchema.json +43 -0
  14. package/dist/connections/GoogleSheet/GoogleSheetGetMany/index.js +24 -0
  15. package/dist/connections/GoogleSheet/GoogleSheetGetOne/GoogleSheetGetOne.js +43 -0
  16. package/dist/connections/GoogleSheet/GoogleSheetGetOne/GoogleSheetGetOneSchema.json +36 -0
  17. package/dist/connections/GoogleSheet/GoogleSheetGetOne/index.js +24 -0
  18. package/dist/connections/GoogleSheet/GoogleSheetSchema.json +88 -0
  19. package/dist/connections/GoogleSheet/GoogleSheetUpdateMany/GoogleSheetUpdateMany.js +57 -0
  20. package/dist/connections/GoogleSheet/GoogleSheetUpdateMany/GoogleSheetUpdateManySchema.json +55 -0
  21. package/dist/connections/GoogleSheet/GoogleSheetUpdateMany/index.js +24 -0
  22. package/dist/connections/GoogleSheet/GoogleSheetUpdateOne/GoogleSheetUpdateOne.js +69 -0
  23. package/dist/connections/GoogleSheet/GoogleSheetUpdateOne/GoogleSheetUpdateOneSchema.json +62 -0
  24. package/dist/connections/GoogleSheet/GoogleSheetUpdateOne/index.js +24 -0
  25. package/dist/connections/GoogleSheet/cleanRows.js +33 -0
  26. package/dist/connections/GoogleSheet/getSheet.js +57 -0
  27. package/dist/connections/GoogleSheet/mingoAggregation.js +38 -0
  28. package/dist/connections/GoogleSheet/mingoFilter.js +35 -0
  29. package/dist/connections/GoogleSheet/transformTypes.js +103 -0
  30. package/dist/index.js +7 -0
  31. package/package.json +60 -0
@@ -0,0 +1,103 @@
1
+ /*
2
+ Copyright 2020-2021 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
+ ,
20
+ number: (value)=>{
21
+ const number = Number(value);
22
+ if (isNaN(number)) return null;
23
+ return number;
24
+ },
25
+ boolean: (value)=>value === 'TRUE'
26
+ ,
27
+ date: (value)=>{
28
+ const date = moment.utc(value);
29
+ if (!date.isValid()) return null;
30
+ return date.toDate();
31
+ },
32
+ json: (value)=>{
33
+ try {
34
+ return JSON.parse(value);
35
+ } catch (_) {
36
+ return null;
37
+ }
38
+ }
39
+ };
40
+ const writeTransformers = {
41
+ string: (value)=>value
42
+ ,
43
+ number: (value)=>type.isNumber(value) ? value.toString() : value
44
+ ,
45
+ boolean: (value)=>{
46
+ if (value === true) return 'TRUE';
47
+ if (value === false) return 'FALSE';
48
+ return value;
49
+ },
50
+ date: (value)=>type.isDate(value) ? value.toISOString() : value
51
+ ,
52
+ json: (value)=>{
53
+ try {
54
+ return JSON.stringify(value);
55
+ } catch (_) {
56
+ return value;
57
+ }
58
+ }
59
+ };
60
+ const transformObject = ({ transformers , types })=>(object)=>{
61
+ Object.keys(object).forEach((key)=>{
62
+ if (types[key]) {
63
+ object[key] = transformers[types[key]](object[key]);
64
+ }
65
+ });
66
+ return object;
67
+ }
68
+ ;
69
+ function transformRead({ input , types ={
70
+ } }) {
71
+ if (type.isObject(input)) {
72
+ return transformObject({
73
+ transformers: readTransformers,
74
+ types
75
+ })(input);
76
+ }
77
+ if (type.isArray(input)) {
78
+ return input.map((obj)=>transformObject({
79
+ transformers: readTransformers,
80
+ types
81
+ })(obj)
82
+ );
83
+ }
84
+ throw new Error(`transformRead received invalid input type ${type.typeOf(input)}.`);
85
+ }
86
+ function transformWrite({ input , types ={
87
+ } }) {
88
+ if (type.isObject(input)) {
89
+ return transformObject({
90
+ transformers: writeTransformers,
91
+ types
92
+ })(input);
93
+ }
94
+ if (type.isArray(input)) {
95
+ return input.map((obj)=>transformObject({
96
+ transformers: writeTransformers,
97
+ types
98
+ })(obj)
99
+ );
100
+ }
101
+ throw new Error(`transformWrite received invalid input type ${type.typeOf(input)}.`);
102
+ }
103
+ export { transformRead, transformWrite };
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ import GoogleSheet from './connections/GoogleSheet/GoogleSheet.js';
2
+ export const connections = {
3
+ GoogleSheet
4
+ };
5
+ export default {
6
+ connections
7
+ };
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@lowdefy/connection-google-sheets",
3
+ "version": "4.0.0-alpha.1",
4
+ "licence": "Apache-2.0",
5
+ "description": "",
6
+ "homepage": "https://lowdefy.com",
7
+ "keywords": [
8
+ "lowdefy",
9
+ "lowdefy connection"
10
+ ],
11
+ "bugs": {
12
+ "url": "https://github.com/lowdefy/lowdefy/issues"
13
+ },
14
+ "contributors": [
15
+ {
16
+ "name": "Sam Tolmay",
17
+ "url": "https://github.com/SamTolmay"
18
+ },
19
+ {
20
+ "name": "Gerrie van Wyk",
21
+ "url": "https://github.com/Gervwyk"
22
+ }
23
+ ],
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/lowdefy/lowdefy.git"
27
+ },
28
+ "type": "module",
29
+ "exports": {
30
+ ".": "./dist/index.js",
31
+ "./connections/*": "./dist/connections/*"
32
+ },
33
+ "files": [
34
+ "dist/*"
35
+ ],
36
+ "scripts": {
37
+ "build": "yarn swc",
38
+ "clean": "rm -rf dist",
39
+ "prepare": "yarn build",
40
+ "swc": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
41
+ "test": "jest --coverage"
42
+ },
43
+ "dependencies": {
44
+ "@lowdefy/helpers": "4.0.0-alpha.1",
45
+ "google-spreadsheet": "3.1.15",
46
+ "mingo": "4.2.0",
47
+ "moment": "2.29.1"
48
+ },
49
+ "devDependencies": {
50
+ "@lowdefy/ajv": "4.0.0-alpha.1",
51
+ "@swc/cli": "0.1.52",
52
+ "@swc/core": "1.2.112",
53
+ "@swc/jest": "0.2.9",
54
+ "jest": "27.3.1"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "gitHead": "c97a8fa6b5a641e7d50df09f5601a9c586eeb65a"
60
+ }