fix(connection-google-sheets): Revert mingo system imports.

This commit is contained in:
Gervwyk 2022-02-02 16:21:19 +02:00
parent f894cb421e
commit 66a42c7dc5

View File

@ -16,7 +16,26 @@
import { type } from '@lowdefy/helpers';
import mingo from 'mingo';
import 'mingo/init/system';
// TODO: fix build to work with:
// import 'mingo/init/system';
import { useOperators, OperatorType } from 'mingo/core.js';
import * as accumulatorOperators from 'mingo/operators/accumulator/index.js';
import * as expressionOperators from 'mingo/operators/expression/index.js';
import * as pipelineOperators from 'mingo/operators/pipeline/index.js';
import * as queryOperators from 'mingo/operators/query/index.js';
import * as projectionOperators from 'mingo/operators/projection/index.js';
// "import * as" is returning different object structures when the connection is being
// imported in the build or when running the tests.
// So we check for the a default object with all the named exports, otherwise the
// returned object has all the named exports.
useOperators(OperatorType.ACCUMULATOR, accumulatorOperators.default || accumulatorOperators);
useOperators(OperatorType.EXPRESSION, expressionOperators.default || expressionOperators);
useOperators(OperatorType.PIPELINE, pipelineOperators.default || pipelineOperators);
useOperators(OperatorType.QUERY, queryOperators.default || queryOperators);
useOperators(OperatorType.PROJECTION, projectionOperators.default || projectionOperators);
function mingoAggregation({ input = [], pipeline = [] }) {
if (!type.isArray(input)) {