@lowdefy/operators-mql 4.0.0-alpha.28 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/operators-mql",
3
- "version": "4.0.0-alpha.28",
3
+ "version": "4.0.0-alpha.29",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -36,15 +36,14 @@
36
36
  "dist/*"
37
37
  ],
38
38
  "scripts": {
39
- "build": "yarn swc",
39
+ "build": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
40
40
  "clean": "rm -rf dist",
41
- "prepare": "yarn build",
42
- "swc": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
41
+ "prepublishOnly": "pnpm build",
43
42
  "test": "jest --coverage"
44
43
  },
45
44
  "dependencies": {
46
- "@lowdefy/helpers": "4.0.0-alpha.28",
47
- "@lowdefy/operators": "4.0.0-alpha.28",
45
+ "@lowdefy/helpers": "4.0.0-alpha.29",
46
+ "@lowdefy/operators": "4.0.0-alpha.29",
48
47
  "mingo": "6.0.6"
49
48
  },
50
49
  "devDependencies": {
@@ -57,5 +56,5 @@
57
56
  "publishConfig": {
58
57
  "access": "public"
59
58
  },
60
- "gitHead": "d0bad6be18362c0ceea1c18239c61bba0ba59300"
59
+ "gitHead": "621a191ebc0a1569ee6669dc74c12f8be5a8c7f3"
61
60
  }
@@ -1,129 +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 mingo from 'mingo';
16
- import { get, type } from '@lowdefy/helpers';
17
- import { runClass } from '@lowdefy/operators';
18
- // TODO: fix build to work with:
19
- // import 'mingo/init/system';
20
- import { useOperators, OperatorType } from 'mingo/core.js';
21
- import * as accumulatorOperators from 'mingo/operators/accumulator/index.js';
22
- import * as expressionOperators from 'mingo/operators/expression/index.js';
23
- import * as pipelineOperators from 'mingo/operators/pipeline/index.js';
24
- import * as queryOperators from 'mingo/operators/query/index.js';
25
- import * as projectionOperators from 'mingo/operators/projection/index.js';
26
- // "import * as" is returning different object structures when the connection is being
27
- // imported in the build or when running the tests.
28
- // So we check for the a default object with all the named exports, otherwise the
29
- // returned object has all the named exports.
30
- useOperators(OperatorType.ACCUMULATOR, accumulatorOperators.default || accumulatorOperators);
31
- useOperators(OperatorType.EXPRESSION, expressionOperators.default || expressionOperators);
32
- useOperators(OperatorType.PIPELINE, pipelineOperators.default || pipelineOperators);
33
- useOperators(OperatorType.QUERY, queryOperators.default || queryOperators);
34
- useOperators(OperatorType.PROJECTION, projectionOperators.default || projectionOperators);
35
- function aggregate(data, pipeline) {
36
- if (data === null) {
37
- data = [];
38
- }
39
- if (!type.isArray(data)) {
40
- throw new Error('Data must be of type array.');
41
- }
42
- if (!type.isArray(pipeline)) {
43
- throw new Error('Pipeline must be of type array.');
44
- }
45
- const agg = new mingo.Aggregator(pipeline);
46
- return agg.run(data);
47
- }
48
- function expr(data, expr1) {
49
- if (data === null) {
50
- data = {};
51
- }
52
- if (!type.isObject(data)) {
53
- throw new Error('Data must be of type object.');
54
- }
55
- const agg = new mingo.Aggregator([
56
- {
57
- $project: {
58
- value: expr1
59
- }
60
- },
61
- ]);
62
- const res = agg.run([
63
- data
64
- ]);
65
- return get(res, '0.value', {
66
- default: null
67
- });
68
- }
69
- function test(data, test1) {
70
- if (data === null) {
71
- data = {};
72
- }
73
- if (!type.isObject(data)) {
74
- throw new Error('Data must be of type object.');
75
- }
76
- if (!type.isObject(test1)) {
77
- throw new Error('Query test must be of type object.');
78
- }
79
- const query = new mingo.Query(test1);
80
- return query.test(data);
81
- }
82
- const meta = {
83
- aggregate: {
84
- namedArgs: [
85
- 'on',
86
- 'pipeline'
87
- ],
88
- validTypes: [
89
- 'array',
90
- 'object'
91
- ]
92
- },
93
- expr: {
94
- namedArgs: [
95
- 'on',
96
- 'expr'
97
- ],
98
- validTypes: [
99
- 'array',
100
- 'object'
101
- ]
102
- },
103
- test: {
104
- namedArgs: [
105
- 'on',
106
- 'test'
107
- ],
108
- validTypes: [
109
- 'array',
110
- 'object'
111
- ]
112
- }
113
- };
114
- const functions = {
115
- aggregate,
116
- expr,
117
- test
118
- };
119
- function mql({ params , location , methodName }) {
120
- return runClass({
121
- functions,
122
- location,
123
- meta,
124
- methodName,
125
- operator: '_mql',
126
- params
127
- });
128
- }
129
- export default mql;
@@ -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 _mql } from './operators/shared/mql.js';
@@ -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 _mql } from './operators/shared/mql.js';
package/dist/types.js DELETED
@@ -1,22 +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 * as client from './operatorsClient.js';
16
- import * as server from './operatorsServer.js';
17
- export default {
18
- operators: {
19
- client: Object.keys(client),
20
- server: Object.keys(server)
21
- }
22
- };