@lowdefy/connection-google-sheets 5.6.0 → 6.0.0
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.
|
@@ -13,15 +13,23 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { GoogleSpreadsheet } from 'google-spreadsheet';
|
|
16
|
-
|
|
16
|
+
import { JWT } from 'google-auth-library';
|
|
17
|
+
// google-spreadsheet v4+ takes the auth object in the constructor instead of the
|
|
18
|
+
// v3 doc.useApiKey / doc.useServiceAccountAuth methods. An API key gives read-only
|
|
19
|
+
// access; a service account (JWT) is needed for writes.
|
|
20
|
+
function getAuth({ apiKey, client_email, private_key }) {
|
|
17
21
|
if (apiKey) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
client_email,
|
|
22
|
-
private_key
|
|
23
|
-
});
|
|
22
|
+
return {
|
|
23
|
+
apiKey
|
|
24
|
+
};
|
|
24
25
|
}
|
|
26
|
+
return new JWT({
|
|
27
|
+
email: client_email,
|
|
28
|
+
key: private_key,
|
|
29
|
+
scopes: [
|
|
30
|
+
'https://www.googleapis.com/auth/spreadsheets'
|
|
31
|
+
]
|
|
32
|
+
});
|
|
25
33
|
}
|
|
26
34
|
function getSheetFromDoc({ doc, sheetId, sheetIndex }) {
|
|
27
35
|
let sheet;
|
|
@@ -40,13 +48,12 @@ function getSheetFromDoc({ doc, sheetId, sheetIndex }) {
|
|
|
40
48
|
}
|
|
41
49
|
async function getSheet({ connection }) {
|
|
42
50
|
const { apiKey, client_email, private_key, sheetId, sheetIndex, spreadsheetId } = connection;
|
|
43
|
-
const
|
|
44
|
-
await authenticate({
|
|
45
|
-
doc,
|
|
51
|
+
const auth = getAuth({
|
|
46
52
|
apiKey,
|
|
47
53
|
client_email,
|
|
48
54
|
private_key
|
|
49
55
|
});
|
|
56
|
+
const doc = new GoogleSpreadsheet(spreadsheetId, auth);
|
|
50
57
|
await doc.loadInfo();
|
|
51
58
|
return getSheetFromDoc({
|
|
52
59
|
doc,
|
|
@@ -14,23 +14,8 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { type } from '@lowdefy/helpers';
|
|
16
16
|
import mingo from 'mingo';
|
|
17
|
-
//
|
|
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);
|
|
17
|
+
// mingo v7 autoloads all operators for objects (Aggregator/Query) created from
|
|
18
|
+
// the default module, so the old `import 'mingo/init/system'` is no longer needed.
|
|
34
19
|
function mingoAggregation({ input = [], pipeline = [] }) {
|
|
35
20
|
if (!type.isArray(input)) {
|
|
36
21
|
throw new Error('Mingo aggregation error. Argument "input" should be an array.');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/connection-google-sheets",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -35,16 +35,17 @@
|
|
|
35
35
|
"dist/*"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@lowdefy/helpers": "
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
38
|
+
"@lowdefy/helpers": "6.0.0",
|
|
39
|
+
"dayjs": "1.11.20",
|
|
40
|
+
"google-auth-library": "9.15.1",
|
|
41
|
+
"google-spreadsheet": "5.3.0",
|
|
42
|
+
"mingo": "7.2.1"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@jest/globals": "28.1.3",
|
|
45
|
-
"@lowdefy/ajv": "
|
|
46
|
-
"@swc/cli": "0.8.
|
|
47
|
-
"@swc/core": "1.15.
|
|
46
|
+
"@lowdefy/ajv": "6.0.0",
|
|
47
|
+
"@swc/cli": "0.8.1",
|
|
48
|
+
"@swc/core": "1.15.32",
|
|
48
49
|
"@swc/jest": "0.2.39",
|
|
49
50
|
"jest": "28.1.3"
|
|
50
51
|
},
|