json-fs-query 1.0.4 → 1.0.5
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/browser/jsonFsQuery.js +10158 -27750
- package/browser/jsonFsQuery.min.js +1 -1
- package/dist/data/introspect/create.d.ts +10 -10
- package/dist/data/introspect/create.js +21 -21
- package/dist/data/introspect/definitions/field.d.ts +27 -27
- package/dist/data/introspect/definitions/field.js +9 -9
- package/dist/data/introspect/definitions/key.d.ts +25 -25
- package/dist/data/introspect/definitions/key.js +19 -19
- package/dist/data/introspect/definitions/keyReference.d.ts +17 -17
- package/dist/data/introspect/definitions/keyReference.js +6 -6
- package/dist/data/introspect/definitions/record.d.ts +25 -25
- package/dist/data/introspect/definitions/record.js +11 -11
- package/dist/data/introspect/describe.js +10 -10
- package/dist/data/introspect/drop.js +22 -22
- package/dist/data/introspect/index.d.ts +7 -7
- package/dist/data/introspect/index.js +19 -19
- package/dist/data/introspect/policies/foreignKeyExists.d.ts +8 -8
- package/dist/data/introspect/policies/foreignKeyExists.js +11 -11
- package/dist/data/introspect/policies/hasDependents.d.ts +12 -12
- package/dist/data/introspect/policies/hasDependents.js +21 -21
- package/dist/data/introspect/policies/keyGenerate.d.ts +1 -1
- package/dist/data/introspect/policies/keyGenerate.js +12 -12
- package/dist/data/introspect/policies/keyUnique.d.ts +9 -9
- package/dist/data/introspect/policies/keyUnique.js +12 -12
- package/dist/data/introspect/policies/typeCheck.d.ts +11 -11
- package/dist/data/introspect/policies/typeCheck.js +23 -23
- package/dist/data/introspect/policies/typeEnum.d.ts +1 -1
- package/dist/data/introspect/policies/typeEnum.js +14 -14
- package/dist/data/introspect/policies/useDefault.d.ts +1 -1
- package/dist/data/introspect/policies/useDefault.js +13 -13
- package/dist/data/queries/deleteEntity.d.ts +1 -1
- package/dist/data/queries/deleteEntity.js +57 -57
- package/dist/data/queries/groupBy.d.ts +1 -1
- package/dist/data/queries/groupBy.js +14 -14
- package/dist/data/queries/insertEntity.d.ts +1 -1
- package/dist/data/queries/insertEntity.js +56 -56
- package/dist/data/queries/joinEntity.d.ts +1 -1
- package/dist/data/queries/joinEntity.js +18 -18
- package/dist/data/queries/joinEntity.min.js +1 -1
- package/dist/data/queries/limitOffset.d.ts +7 -7
- package/dist/data/queries/limitOffset.js +10 -10
- package/dist/data/queries/mergeJoins.d.ts +1 -1
- package/dist/data/queries/mergeJoins.js +12 -12
- package/dist/data/queries/mergeJoins.min.js +1 -1
- package/dist/data/queries/parser.d.ts +1 -1
- package/dist/data/queries/parser.js +30 -30
- package/dist/data/queries/parser.min.js +1 -1
- package/dist/data/queries/query.d.ts +1 -1
- package/dist/data/queries/query.js +13 -13
- package/dist/data/queries/query.min.js +1 -1
- package/dist/data/queries/readEntity.js +9 -9
- package/dist/data/queries/selectFields.d.ts +9 -9
- package/dist/data/queries/selectFields.js +17 -17
- package/dist/data/queries/sortBy.d.ts +1 -1
- package/dist/data/queries/sortBy.js +25 -25
- package/dist/data/queries/sortBy.min.js +1 -1
- package/dist/data/queries/updateEntity.d.ts +1 -1
- package/dist/data/queries/updateEntity.js +74 -74
- package/dist/data/queries/where.d.ts +6 -6
- package/dist/data/queries/where.js +29 -29
- package/dist/data/utilities/computeKeyValue.d.ts +12 -12
- package/dist/data/utilities/computeKeyValue.js +11 -11
- package/dist/data/utilities/config.d.ts +27 -27
- package/dist/data/utilities/config.js +12 -12
- package/dist/data/utilities/deregisterRecord.d.ts +7 -7
- package/dist/data/utilities/deregisterRecord.js +20 -20
- package/dist/data/utilities/getConditionIndexedList.js +27 -27
- package/dist/data/utilities/getConditionIndexedList.min.js +1 -1
- package/dist/data/utilities/getJoinIndexedList.js +39 -39
- package/dist/data/utilities/getJoinIndexedList.min.js +1 -1
- package/dist/data/utilities/getMatchingIndexes.js +15 -15
- package/dist/data/utilities/getMatchingIndexes.min.js +1 -1
- package/dist/data/utilities/matchIndexedJoins.js +24 -24
- package/dist/data/utilities/matchIndexedJoins.min.js +1 -1
- package/dist/data/utilities/mergeJoin.js +23 -23
- package/dist/data/utilities/mergeJoin.min.js +1 -1
- package/dist/data/utilities/parsers/findCommand.d.ts +9 -9
- package/dist/data/utilities/parsers/findCommand.js +15 -15
- package/dist/data/utilities/parsers/findConditions.d.ts +14 -14
- package/dist/data/utilities/parsers/findConditions.js +14 -14
- package/dist/data/utilities/parsers/findConditions.min.js +1 -1
- package/dist/data/utilities/parsers/findGroupBy.d.ts +8 -8
- package/dist/data/utilities/parsers/findGroupBy.js +12 -12
- package/dist/data/utilities/parsers/findInsertValues.d.ts +12 -12
- package/dist/data/utilities/parsers/findInsertValues.js +19 -19
- package/dist/data/utilities/parsers/findJoinClauses.d.ts +12 -12
- package/dist/data/utilities/parsers/findJoinClauses.js +13 -13
- package/dist/data/utilities/parsers/findJoinClauses.min.js +1 -1
- package/dist/data/utilities/parsers/findJoinEntity.d.ts +8 -8
- package/dist/data/utilities/parsers/findJoinEntity.js +12 -12
- package/dist/data/utilities/parsers/findLimit.d.ts +8 -8
- package/dist/data/utilities/parsers/findLimit.js +12 -12
- package/dist/data/utilities/parsers/findMergeJoins.d.ts +11 -11
- package/dist/data/utilities/parsers/findMergeJoins.js +13 -13
- package/dist/data/utilities/parsers/findMergeJoins.min.js +1 -1
- package/dist/data/utilities/parsers/findOffset.d.ts +8 -8
- package/dist/data/utilities/parsers/findOffset.js +12 -12
- package/dist/data/utilities/parsers/findSelects.d.ts +11 -11
- package/dist/data/utilities/parsers/findSelects.js +15 -15
- package/dist/data/utilities/parsers/findSelects.min.js +1 -1
- package/dist/data/utilities/parsers/findSortClauses.d.ts +11 -11
- package/dist/data/utilities/parsers/findSortClauses.js +15 -15
- package/dist/data/utilities/parsers/findSortClauses.min.js +1 -1
- package/dist/data/utilities/parsers/findUpdateValues.d.ts +14 -14
- package/dist/data/utilities/parsers/findUpdateValues.js +17 -17
- package/dist/data/utilities/parsers/isEntityProperty.js +8 -8
- package/dist/data/utilities/parsers/parseLiteralValue.d.ts +11 -11
- package/dist/data/utilities/parsers/parseLiteralValue.js +12 -12
- package/dist/data/utilities/parsers/parseQuery.d.ts +32 -32
- package/dist/data/utilities/parsers/parseQuery.js +25 -25
- package/dist/data/utilities/parsers/parseQuery.min.js +1 -1
- package/dist/data/utilities/parsers/removeFromQuery.js +8 -8
- package/dist/data/utilities/parsers/splitEntityProperty.js +23 -23
- package/dist/data/utilities/parsers/splitQueries.js +11 -11
- package/dist/data/utilities/reconcileJoin.js +14 -14
- package/dist/data/utilities/reconcileJoins.js +13 -13
- package/dist/data/utilities/reconcileJoins.min.js +1 -1
- package/dist/data/utilities/registerRecord.d.ts +7 -7
- package/dist/data/utilities/registerRecord.js +20 -20
- package/dist/data/utilities/removeFromIndex.d.ts +13 -13
- package/dist/data/utilities/removeFromIndex.js +24 -26
- package/dist/data/utilities/restrictIndexedList.js +18 -18
- package/dist/data/utilities/retrieveFile.js +19 -19
- package/dist/data/utilities/retrieveFile.min.js +1 -1
- package/dist/data/utilities/retrieveIndexes.d.ts +1 -1
- package/dist/data/utilities/retrieveIndexes.js +13 -13
- package/dist/data/utilities/retrieveIndexes.min.js +1 -1
- package/dist/data/utilities/retrieveRecord.js +7 -7
- package/dist/data/utilities/retrieveRecords.js +14 -14
- package/dist/data/utilities/retrieveRecords.min.js +1 -1
- package/dist/data/utilities/runQuery.d.ts +1 -1
- package/dist/data/utilities/runQuery.js +49 -49
- package/dist/data/utilities/updateIndex.d.ts +16 -16
- package/dist/data/utilities/updateIndex.js +25 -25
- package/dist/data/utilities/useJoinClause.d.ts +5 -5
- package/dist/data/utilities/useJoinClause.js +22 -22
- package/dist/index.d.ts +4 -4
- package/dist/index.js +25 -25
- package/package.json +4 -4
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.getConditionIndexedList = void 0
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
});
|
|
6
|
+
exports.getConditionIndexedList = void 0;
|
|
7
|
+
var _isEntityProperty = require("./parsers/isEntityProperty");
|
|
8
|
+
var _splitEntityProperty = require("./parsers/splitEntityProperty");
|
|
9
|
+
var _retrieveRecord = require("./retrieveRecord");
|
|
10
|
+
var _where = require("../queries/where");
|
|
11
|
+
var _retrieveFile = require("./retrieveFile");
|
|
12
|
+
var _getMatchingIndexes = require("./getMatchingIndexes");
|
|
13
13
|
const getConditionIndexedList = async (parsed, recordData, dataSet) => {
|
|
14
|
-
const reducedConditions = []
|
|
14
|
+
const reducedConditions = [];
|
|
15
15
|
for (const condition of parsed.conditions) {
|
|
16
|
-
let entity = parsed.entity
|
|
17
|
-
let property = condition.property
|
|
16
|
+
let entity = parsed.entity;
|
|
17
|
+
let property = condition.property;
|
|
18
18
|
if ((0, _isEntityProperty.isEntityProperty)(property)) {
|
|
19
|
-
const entityProperty = (0, _splitEntityProperty.splitEntityProperty)(property)
|
|
20
|
-
entity = entityProperty.entity
|
|
21
|
-
property = entityProperty.property
|
|
19
|
+
const entityProperty = (0, _splitEntityProperty.splitEntityProperty)(property);
|
|
20
|
+
entity = entityProperty.entity;
|
|
21
|
+
property = entityProperty.property;
|
|
22
22
|
}
|
|
23
23
|
if (!Object.prototype.hasOwnProperty.call(recordData, entity)) {
|
|
24
|
-
recordData[entity] = await (0, _retrieveRecord.retrieveRecord)(entity)
|
|
24
|
+
recordData[entity] = await (0, _retrieveRecord.retrieveRecord)(entity);
|
|
25
25
|
}
|
|
26
|
-
const indexed = {}
|
|
26
|
+
const indexed = {};
|
|
27
27
|
const retrieveMatchedFiles = async (entity, property, recordData, condition, dataSet, indexed) => {
|
|
28
28
|
const matchedRecords = (0, _where.where)(indexed[entity][property], {
|
|
29
29
|
property: 'value',
|
|
30
30
|
comparator: condition.comparator,
|
|
31
31
|
value: condition.value
|
|
32
|
-
})
|
|
32
|
+
});
|
|
33
33
|
for (const matchedRecord of matchedRecords) {
|
|
34
34
|
for (const file of matchedRecord.record) {
|
|
35
|
-
dataSet[entity].push(await (0, _retrieveFile.retrieveFile)(`${entity}/${file}`))
|
|
35
|
+
dataSet[entity].push(await (0, _retrieveFile.retrieveFile)(`${entity}/${file}`));
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
}
|
|
39
|
-
const isIndexed = await (0, _getMatchingIndexes.getMatchingIndexes)(entity, property, recordData, condition, dataSet, indexed, retrieveMatchedFiles)
|
|
38
|
+
};
|
|
39
|
+
const isIndexed = await (0, _getMatchingIndexes.getMatchingIndexes)(entity, property, recordData, condition, dataSet, indexed, retrieveMatchedFiles);
|
|
40
40
|
if (!isIndexed) {
|
|
41
|
-
reducedConditions.push(condition)
|
|
41
|
+
reducedConditions.push(condition);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
parsed.conditions = reducedConditions
|
|
45
|
-
return parsed
|
|
46
|
-
}
|
|
47
|
-
exports.getConditionIndexedList = getConditionIndexedList
|
|
44
|
+
parsed.conditions = reducedConditions;
|
|
45
|
+
return parsed;
|
|
46
|
+
};
|
|
47
|
+
exports.getConditionIndexedList = getConditionIndexedList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getConditionIndexedList=void 0;var _isEntityProperty=require("./parsers/isEntityProperty"),_splitEntityProperty=require("./parsers/splitEntityProperty"),_retrieveRecord=require("./retrieveRecord"),_where=require("../queries/where"),_retrieveFile=require("./retrieveFile"),_getMatchingIndexes=require("./getMatchingIndexes");const getConditionIndexedList=async(e,t,r)=>{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getConditionIndexedList=void 0;var _isEntityProperty=require("./parsers/isEntityProperty"),_splitEntityProperty=require("./parsers/splitEntityProperty"),_retrieveRecord=require("./retrieveRecord"),_where=require("../queries/where"),_retrieveFile=require("./retrieveFile"),_getMatchingIndexes=require("./getMatchingIndexes");const getConditionIndexedList=async(e,t,r)=>{const i=[];for(const o of e.conditions){let n=e.entity,s=o.property;if((0,_isEntityProperty.isEntityProperty)(s)){const e=(0,_splitEntityProperty.splitEntityProperty)(s);n=e.entity,s=e.property}Object.prototype.hasOwnProperty.call(t,n)||(t[n]=await(0,_retrieveRecord.retrieveRecord)(n));const p={},c=async(e,t,r,i,o,n)=>{const s=(0,_where.where)(n[e][t],{property:"value",comparator:i.comparator,value:i.value});for(const t of s)for(const r of t.record)o[e].push(await(0,_retrieveFile.retrieveFile)(`${e}/${r}`))};await(0,_getMatchingIndexes.getMatchingIndexes)(n,s,t,o,r,p,c)||i.push(o)}return e.conditions=i,e};exports.getConditionIndexedList=getConditionIndexedList;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.getJoinIndexedList = void 0
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault
|
|
5
|
+
});
|
|
6
|
+
exports.getJoinIndexedList = void 0;
|
|
7
|
+
var _siFunciona = _interopRequireDefault(require("si-funciona"));
|
|
8
|
+
var _splitEntityProperty = require("./parsers/splitEntityProperty");
|
|
9
|
+
var _retrieveRecord = require("./retrieveRecord");
|
|
10
|
+
var _getMatchingIndexes = require("./getMatchingIndexes");
|
|
11
|
+
var _matchIndexedJoins = require("./matchIndexedJoins");
|
|
12
|
+
var _restrictIndexedList = require("./restrictIndexedList");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
const getJoinIndexedList = async (parsed, recordData, dataSets) => {
|
|
15
|
-
const reducedJoins = []
|
|
16
|
-
const indexed = {}
|
|
17
|
-
let firstIteration = true
|
|
18
|
-
const entity = parsed.entity
|
|
19
|
-
const joinEntity = parsed.joinEntity
|
|
20
|
-
const joinClauses = parsed.joinClauses
|
|
15
|
+
const reducedJoins = [];
|
|
16
|
+
const indexed = {};
|
|
17
|
+
let firstIteration = true;
|
|
18
|
+
const entity = parsed.entity;
|
|
19
|
+
const joinEntity = parsed.joinEntity;
|
|
20
|
+
const joinClauses = parsed.joinClauses;
|
|
21
21
|
if (!dataSets[entity].length) {
|
|
22
22
|
// Nothing indexed entity's own rows yet (no WHERE condition narrowed them down ahead of this -
|
|
23
23
|
// that only happens via getConditionIndexedList, called just before this). The loop below can't
|
|
@@ -26,51 +26,51 @@ const getJoinIndexedList = async (parsed, recordData, dataSets) => {
|
|
|
26
26
|
// needs the real clauses to do the join itself. Previously this fell through to the loop,
|
|
27
27
|
// which never ran, leaving reducedJoins (and so parsed.joinClauses) empty regardless of what
|
|
28
28
|
// was actually parsed - silently discarding every join clause whenever the query had no WHERE.
|
|
29
|
-
return parsed
|
|
29
|
+
return parsed;
|
|
30
30
|
}
|
|
31
31
|
if (!joinClauses.length) {
|
|
32
32
|
// A WHERE condition DID index entity's own rows above, but this query has no join at all -
|
|
33
33
|
// joinEntity is undefined. The loop below writes dataSets[entity][anEntity][joinEntity]
|
|
34
34
|
// unconditionally; left unguarded, that assigns a literal "undefined" key (object[undefined]
|
|
35
35
|
// coerces to the string "undefined") onto every row, since there's no join to actually attach.
|
|
36
|
-
return parsed
|
|
36
|
+
return parsed;
|
|
37
37
|
}
|
|
38
38
|
for (const anEntity in dataSets[entity]) {
|
|
39
|
-
const currentEntity = dataSets[entity][anEntity]
|
|
39
|
+
const currentEntity = dataSets[entity][anEntity];
|
|
40
40
|
// Loop over each of the main entities
|
|
41
|
-
const filterJoins = {}
|
|
42
|
-
filterJoins[entity] = [_siFunciona.default.cloneObject(currentEntity)]
|
|
41
|
+
const filterJoins = {};
|
|
42
|
+
filterJoins[entity] = [_siFunciona.default.cloneObject(currentEntity)];
|
|
43
43
|
for (const joinClause of joinClauses) {
|
|
44
|
-
let indexedClone = _siFunciona.default.cloneObject(indexed)
|
|
44
|
+
let indexedClone = _siFunciona.default.cloneObject(indexed);
|
|
45
45
|
const {
|
|
46
46
|
entity: entityA,
|
|
47
47
|
property: propertyA
|
|
48
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyA)
|
|
48
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyA);
|
|
49
49
|
const {
|
|
50
50
|
entity: entityB,
|
|
51
51
|
property: propertyB
|
|
52
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyB)
|
|
52
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyB);
|
|
53
53
|
// Get the record for the entities A and B, store on the recordData
|
|
54
54
|
if (!Object.prototype.hasOwnProperty.call(recordData, entityA)) {
|
|
55
|
-
recordData[entityA] = await (0, _retrieveRecord.retrieveRecord)(entityA)
|
|
55
|
+
recordData[entityA] = await (0, _retrieveRecord.retrieveRecord)(entityA);
|
|
56
56
|
}
|
|
57
57
|
if (!Object.prototype.hasOwnProperty.call(recordData, entityB)) {
|
|
58
|
-
recordData[entityB] = await (0, _retrieveRecord.retrieveRecord)(entityB)
|
|
58
|
+
recordData[entityB] = await (0, _retrieveRecord.retrieveRecord)(entityB);
|
|
59
59
|
}
|
|
60
|
-
indexedClone = (0, _restrictIndexedList.restrictIndexedList)(joinClause, filterJoins, indexedClone)
|
|
61
|
-
const retrieveMatchedFiles = (0, _matchIndexedJoins.matchIndexedJoins)(entity, indexedClone, dataSets)
|
|
60
|
+
indexedClone = (0, _restrictIndexedList.restrictIndexedList)(joinClause, filterJoins, indexedClone);
|
|
61
|
+
const retrieveMatchedFiles = (0, _matchIndexedJoins.matchIndexedJoins)(entity, indexedClone, dataSets);
|
|
62
62
|
// Check if there are matching keys for the join condition
|
|
63
|
-
const matchAResult = await (0, _getMatchingIndexes.getMatchingIndexes)(entityA, propertyA, recordData, joinClause, filterJoins, indexed)
|
|
64
|
-
const matchBResult = await (0, _getMatchingIndexes.getMatchingIndexes)(entityB, propertyB, recordData, joinClause, filterJoins, indexed, retrieveMatchedFiles)
|
|
65
|
-
const isIndexed = matchAResult || matchBResult
|
|
63
|
+
const matchAResult = await (0, _getMatchingIndexes.getMatchingIndexes)(entityA, propertyA, recordData, joinClause, filterJoins, indexed);
|
|
64
|
+
const matchBResult = await (0, _getMatchingIndexes.getMatchingIndexes)(entityB, propertyB, recordData, joinClause, filterJoins, indexed, retrieveMatchedFiles);
|
|
65
|
+
const isIndexed = matchAResult || matchBResult;
|
|
66
66
|
if (!isIndexed && firstIteration) {
|
|
67
|
-
reducedJoins.push(joinClause)
|
|
68
|
-
firstIteration = false
|
|
67
|
+
reducedJoins.push(joinClause);
|
|
68
|
+
firstIteration = false;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
dataSets[entity][anEntity][joinEntity] = filterJoins[joinEntity]
|
|
71
|
+
dataSets[entity][anEntity][joinEntity] = filterJoins[joinEntity];
|
|
72
72
|
}
|
|
73
|
-
parsed.joinClauses = reducedJoins
|
|
74
|
-
return parsed
|
|
75
|
-
}
|
|
76
|
-
exports.getJoinIndexedList = getJoinIndexedList
|
|
73
|
+
parsed.joinClauses = reducedJoins;
|
|
74
|
+
return parsed;
|
|
75
|
+
};
|
|
76
|
+
exports.getJoinIndexedList = getJoinIndexedList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getJoinIndexedList=void 0;var _siFunciona=_interopRequireDefault(require("si-funciona")),_splitEntityProperty=require("./parsers/splitEntityProperty"),_retrieveRecord=require("./retrieveRecord"),_getMatchingIndexes=require("./getMatchingIndexes"),_matchIndexedJoins=require("./matchIndexedJoins"),_restrictIndexedList=require("./restrictIndexedList");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const getJoinIndexedList=async(e,t,r)=>{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getJoinIndexedList=void 0;var _siFunciona=_interopRequireDefault(require("si-funciona")),_splitEntityProperty=require("./parsers/splitEntityProperty"),_retrieveRecord=require("./retrieveRecord"),_getMatchingIndexes=require("./getMatchingIndexes"),_matchIndexedJoins=require("./matchIndexedJoins"),_restrictIndexedList=require("./restrictIndexedList");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const getJoinIndexedList=async(e,t,r)=>{const i=[],n={};let o=!0;const s=e.entity,c=e.joinEntity,d=e.joinClauses;if(!r[s].length)return e;if(!d.length)return e;for(const e in r[s]){const a=r[s][e],p={};p[s]=[_siFunciona.default.cloneObject(a)];for(const e of d){let c=_siFunciona.default.cloneObject(n);const{entity:d,property:a}=(0,_splitEntityProperty.splitEntityProperty)(e.propertyA),{entity:u,property:l}=(0,_splitEntityProperty.splitEntityProperty)(e.propertyB);Object.prototype.hasOwnProperty.call(t,d)||(t[d]=await(0,_retrieveRecord.retrieveRecord)(d)),Object.prototype.hasOwnProperty.call(t,u)||(t[u]=await(0,_retrieveRecord.retrieveRecord)(u)),c=(0,_restrictIndexedList.restrictIndexedList)(e,p,c);const y=(0,_matchIndexedJoins.matchIndexedJoins)(s,c,r),_=await(0,_getMatchingIndexes.getMatchingIndexes)(d,a,t,e,p,n),x=await(0,_getMatchingIndexes.getMatchingIndexes)(u,l,t,e,p,n,y);!(_||x)&&o&&(i.push(e),o=!1)}r[s][e][c]=p[c]}return e.joinClauses=i,e};exports.getJoinIndexedList=getJoinIndexedList;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.getMatchingIndexes = void 0
|
|
7
|
-
require(
|
|
8
|
-
|
|
5
|
+
});
|
|
6
|
+
exports.getMatchingIndexes = void 0;
|
|
7
|
+
require("core-js/modules/es.array.includes.js");
|
|
8
|
+
var _retrieveIndexes = require("./retrieveIndexes");
|
|
9
9
|
const getMatchingIndexes = async (entity, property, recordData, clause, dataSet, indexed, cb = null) => {
|
|
10
|
-
let isIndexed = false
|
|
10
|
+
let isIndexed = false;
|
|
11
11
|
for (const key of recordData[entity].keys) {
|
|
12
12
|
if (key.fields.includes(property)) {
|
|
13
|
-
dataSet[entity] = []
|
|
13
|
+
dataSet[entity] = [];
|
|
14
14
|
if (!Object.prototype.hasOwnProperty.call(indexed, entity)) {
|
|
15
|
-
indexed[entity] = {}
|
|
15
|
+
indexed[entity] = {};
|
|
16
16
|
}
|
|
17
17
|
if (!Object.prototype.hasOwnProperty.call(indexed[entity], property)) {
|
|
18
|
-
indexed[entity][property] = (await (0, _retrieveIndexes.retrieveIndexes)(entity, [property], recordData))[property]
|
|
18
|
+
indexed[entity][property] = (await (0, _retrieveIndexes.retrieveIndexes)(entity, [property], recordData))[property];
|
|
19
19
|
}
|
|
20
20
|
if (typeof cb === 'function') {
|
|
21
|
-
await cb(entity, property, recordData, clause, dataSet, indexed)
|
|
21
|
+
await cb(entity, property, recordData, clause, dataSet, indexed);
|
|
22
22
|
}
|
|
23
|
-
isIndexed = true
|
|
23
|
+
isIndexed = true;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
return isIndexed
|
|
27
|
-
}
|
|
28
|
-
exports.getMatchingIndexes = getMatchingIndexes
|
|
26
|
+
return isIndexed;
|
|
27
|
+
};
|
|
28
|
+
exports.getMatchingIndexes = getMatchingIndexes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getMatchingIndexes=void 0,require("core-js/modules/es.array.includes.js");var _retrieveIndexes=require("./retrieveIndexes");const getMatchingIndexes=async(e,t,r,s,n,i
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getMatchingIndexes=void 0,require("core-js/modules/es.array.includes.js");var _retrieveIndexes=require("./retrieveIndexes");const getMatchingIndexes=async(e,t,r,s,n,o,i=null)=>{let a=!1;for(const c of r[e].keys)c.fields.includes(t)&&(n[e]=[],Object.prototype.hasOwnProperty.call(o,e)||(o[e]={}),Object.prototype.hasOwnProperty.call(o[e],t)||(o[e][t]=(await(0,_retrieveIndexes.retrieveIndexes)(e,[t],r))[t]),"function"==typeof i&&await i(e,t,r,s,n,o),a=!0);return a};exports.getMatchingIndexes=getMatchingIndexes;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.matchIndexedJoins = void 0
|
|
7
|
-
require(
|
|
8
|
-
require(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault
|
|
5
|
+
});
|
|
6
|
+
exports.matchIndexedJoins = void 0;
|
|
7
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.reduce.js");
|
|
9
|
+
var _siFunciona = _interopRequireDefault(require("si-funciona"));
|
|
10
|
+
var _where = require("../queries/where");
|
|
11
|
+
var _retrieveFile = require("./retrieveFile");
|
|
12
|
+
var _splitEntityProperty = require("./parsers/splitEntityProperty");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
const matchIndexedJoins = (entity, indexedClone, dataSets) => async (focusEntity, property, recordData, joinClause, filterJoins, indexed) => {
|
|
15
15
|
const {
|
|
16
16
|
entity: entityA,
|
|
17
17
|
property: propertyA
|
|
18
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyA)
|
|
18
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyA);
|
|
19
19
|
const {
|
|
20
20
|
entity: entityB,
|
|
21
21
|
property: propertyB
|
|
22
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyB)
|
|
22
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyB);
|
|
23
23
|
const properties = [{
|
|
24
24
|
entityFirst: entityA,
|
|
25
25
|
propertyFirst: propertyA,
|
|
@@ -30,32 +30,32 @@ const matchIndexedJoins = (entity, indexedClone, dataSets) => async (focusEntity
|
|
|
30
30
|
propertyFirst: propertyB,
|
|
31
31
|
entitySecond: entityA,
|
|
32
32
|
propertySecond: propertyA
|
|
33
|
-
}]
|
|
33
|
+
}];
|
|
34
34
|
for (const checkProp of properties) {
|
|
35
35
|
if (!Object.prototype.hasOwnProperty.call(indexedClone, checkProp.entitySecond)) {
|
|
36
|
-
indexedClone[checkProp.entitySecond] = _siFunciona.default.cloneObject(indexed[checkProp.entitySecond])
|
|
36
|
+
indexedClone[checkProp.entitySecond] = _siFunciona.default.cloneObject(indexed[checkProp.entitySecond]);
|
|
37
37
|
}
|
|
38
38
|
const matchedRecords = indexedClone[checkProp.entitySecond][checkProp.propertySecond].reduce((dataA, dataB) => _siFunciona.default.mergeArrays(dataA, (0, _where.where)(indexedClone[checkProp.entityFirst][checkProp.propertyFirst], {
|
|
39
39
|
property: 'value',
|
|
40
40
|
comparator: joinClause.comparator,
|
|
41
41
|
value: dataB.value
|
|
42
|
-
})), [])
|
|
43
|
-
const skipPush = checkProp.entityFirst === entity
|
|
42
|
+
})), []);
|
|
43
|
+
const skipPush = checkProp.entityFirst === entity;
|
|
44
44
|
if (!Object.prototype.hasOwnProperty.call(dataSets, checkProp.entityFirst)) {
|
|
45
|
-
dataSets[checkProp.entityFirst] = []
|
|
45
|
+
dataSets[checkProp.entityFirst] = [];
|
|
46
46
|
}
|
|
47
47
|
for (const matchedRecord of matchedRecords) {
|
|
48
48
|
for (const file of matchedRecord.record) {
|
|
49
|
-
let entityRecord = file
|
|
49
|
+
let entityRecord = file;
|
|
50
50
|
if (typeof file === 'string') {
|
|
51
|
-
entityRecord = await (0, _retrieveFile.retrieveFile)(`${checkProp.entityFirst}/${file}`)
|
|
51
|
+
entityRecord = await (0, _retrieveFile.retrieveFile)(`${checkProp.entityFirst}/${file}`);
|
|
52
52
|
}
|
|
53
53
|
if (!skipPush) {
|
|
54
|
-
dataSets[checkProp.entityFirst].push(entityRecord)
|
|
54
|
+
dataSets[checkProp.entityFirst].push(entityRecord);
|
|
55
55
|
}
|
|
56
|
-
filterJoins[checkProp.entityFirst].push(entityRecord)
|
|
56
|
+
filterJoins[checkProp.entityFirst].push(entityRecord);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
}
|
|
61
|
-
exports.matchIndexedJoins = matchIndexedJoins
|
|
60
|
+
};
|
|
61
|
+
exports.matchIndexedJoins = matchIndexedJoins;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.matchIndexedJoins=void 0,require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.reduce.js");var _siFunciona=_interopRequireDefault(require("si-funciona")),_where=require("../queries/where"),_retrieveFile=require("./retrieveFile"),_splitEntityProperty=require("./parsers/splitEntityProperty");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const matchIndexedJoins=(e,t,r)=>async(i,o,n,s,p,y)=>{const{entity:c,property:u}=(0,_splitEntityProperty.splitEntityProperty)(s.propertyA),{entity:a,property:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.matchIndexedJoins=void 0,require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.reduce.js");var _siFunciona=_interopRequireDefault(require("si-funciona")),_where=require("../queries/where"),_retrieveFile=require("./retrieveFile"),_splitEntityProperty=require("./parsers/splitEntityProperty");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const matchIndexedJoins=(e,t,r)=>async(i,o,n,s,p,y)=>{const{entity:c,property:u}=(0,_splitEntityProperty.splitEntityProperty)(s.propertyA),{entity:a,property:d}=(0,_splitEntityProperty.splitEntityProperty)(s.propertyB),l=[{entityFirst:c,propertyFirst:u,entitySecond:a,propertySecond:d},{entityFirst:a,propertyFirst:d,entitySecond:c,propertySecond:u}];for(const i of l){Object.prototype.hasOwnProperty.call(t,i.entitySecond)||(t[i.entitySecond]=_siFunciona.default.cloneObject(y[i.entitySecond]));const o=t[i.entitySecond][i.propertySecond].reduce(((e,r)=>_siFunciona.default.mergeArrays(e,(0,_where.where)(t[i.entityFirst][i.propertyFirst],{property:"value",comparator:s.comparator,value:r.value}))),[]),n=i.entityFirst===e;Object.prototype.hasOwnProperty.call(r,i.entityFirst)||(r[i.entityFirst]=[]);for(const e of o)for(const t of e.record){let e=t;"string"==typeof t&&(e=await(0,_retrieveFile.retrieveFile)(`${i.entityFirst}/${t}`)),n||r[i.entityFirst].push(e),p[i.entityFirst].push(e)}}};exports.matchIndexedJoins=matchIndexedJoins;
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.mergeJoin = void 0
|
|
7
|
-
require(
|
|
8
|
-
require(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
});
|
|
6
|
+
exports.mergeJoin = void 0;
|
|
7
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
9
|
+
var _readEntity = require("../queries/readEntity");
|
|
10
|
+
var _splitEntityProperty = require("./parsers/splitEntityProperty");
|
|
11
|
+
var _where = require("../queries/where");
|
|
12
12
|
const mergeJoin = async (propertyA = '', propertyB = '', dataSets = {}) => {
|
|
13
13
|
const {
|
|
14
14
|
entity: entityA,
|
|
15
15
|
property: propA
|
|
16
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(propertyA)
|
|
16
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(propertyA);
|
|
17
17
|
const {
|
|
18
18
|
entity: entityB,
|
|
19
19
|
property: propB
|
|
20
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(propertyB)
|
|
21
|
-
dataSets = await (0, _readEntity.readEntity)(entityA, dataSets)
|
|
22
|
-
dataSets = await (0, _readEntity.readEntity)(entityB, dataSets)
|
|
20
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(propertyB);
|
|
21
|
+
dataSets = await (0, _readEntity.readEntity)(entityA, dataSets);
|
|
22
|
+
dataSets = await (0, _readEntity.readEntity)(entityB, dataSets);
|
|
23
23
|
dataSets[entityA] = dataSets[entityA].map(dataA => {
|
|
24
24
|
const matches = (0, _where.where)(dataSets[entityB], {
|
|
25
25
|
property: propB,
|
|
26
26
|
comparator: '=',
|
|
27
27
|
value: dataA[propA]
|
|
28
|
-
})
|
|
28
|
+
});
|
|
29
29
|
if (!matches.length) {
|
|
30
|
-
return dataA
|
|
30
|
+
return dataA;
|
|
31
31
|
}
|
|
32
|
-
const mergeMatch = matches[0]
|
|
32
|
+
const mergeMatch = matches[0];
|
|
33
33
|
for (const prop in mergeMatch) {
|
|
34
34
|
if (prop === propB) {
|
|
35
35
|
// Skip the condition property since it is irrelevant
|
|
36
|
-
continue
|
|
36
|
+
continue;
|
|
37
37
|
}
|
|
38
|
-
dataA[`${entityB}.${prop}`] = mergeMatch[prop]
|
|
38
|
+
dataA[`${entityB}.${prop}`] = mergeMatch[prop];
|
|
39
39
|
}
|
|
40
|
-
return dataA
|
|
41
|
-
})
|
|
42
|
-
return dataSets
|
|
43
|
-
}
|
|
44
|
-
exports.mergeJoin = mergeJoin
|
|
40
|
+
return dataA;
|
|
41
|
+
});
|
|
42
|
+
return dataSets;
|
|
43
|
+
};
|
|
44
|
+
exports.mergeJoin = mergeJoin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mergeJoin=void 0,require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.map.js");var _readEntity=require("../queries/readEntity"),_splitEntityProperty=require("./parsers/splitEntityProperty"),_where=require("../queries/where");const mergeJoin=async(e="",r="",t={})=>{const{entity:i,property:o}=(0,_splitEntityProperty.splitEntityProperty)(e),{entity:n,property:s}=(0,_splitEntityProperty.splitEntityProperty)(r);return t=await(0,_readEntity.readEntity)(i,t),(t=await(0,_readEntity.readEntity)(n,t))[i]=t[i].map((e=>{const r=(0,_where.where)(t[n],{property:s,comparator:"=",value:e[o]});if(!r.length)return e;const i=r[0];for(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mergeJoin=void 0,require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.map.js");var _readEntity=require("../queries/readEntity"),_splitEntityProperty=require("./parsers/splitEntityProperty"),_where=require("../queries/where");const mergeJoin=async(e="",r="",t={})=>{const{entity:i,property:o}=(0,_splitEntityProperty.splitEntityProperty)(e),{entity:n,property:s}=(0,_splitEntityProperty.splitEntityProperty)(r);return t=await(0,_readEntity.readEntity)(i,t),(t=await(0,_readEntity.readEntity)(n,t))[i]=t[i].map((e=>{const r=(0,_where.where)(t[n],{property:s,comparator:"=",value:e[o]});if(!r.length)return e;const i=r[0];for(const r in i)r!==s&&(e[`${n}.${r}`]=i[r]);return e})),t};exports.mergeJoin=mergeJoin;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ParsedQuery } from './parseQuery';
|
|
2
|
-
export type ParsedCommand = string | 'delete' | 'insert' | 'read' | 'update';
|
|
3
|
-
export type ParsedEntity = string;
|
|
4
|
-
/**
|
|
5
|
-
* Extract command clauses from the query.
|
|
6
|
-
* @param parsed
|
|
7
|
-
* @param query
|
|
8
|
-
*/
|
|
9
|
-
export declare const findCommand: (parsed: ParsedQuery, query: string) => string;
|
|
1
|
+
import { ParsedQuery } from './parseQuery';
|
|
2
|
+
export type ParsedCommand = string | 'delete' | 'insert' | 'read' | 'update';
|
|
3
|
+
export type ParsedEntity = string;
|
|
4
|
+
/**
|
|
5
|
+
* Extract command clauses from the query.
|
|
6
|
+
* @param parsed
|
|
7
|
+
* @param query
|
|
8
|
+
*/
|
|
9
|
+
export declare const findCommand: (parsed: ParsedQuery, query: string) => string;
|
|
10
10
|
//# sourceMappingURL=findCommand.d.ts.map
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.findCommand = void 0
|
|
7
|
-
|
|
8
|
-
const commandMatch = /^(delete|insert|read|update)\s+([a-z0-9_-]+)[\w\n]*/i
|
|
5
|
+
});
|
|
6
|
+
exports.findCommand = void 0;
|
|
7
|
+
var _removeFromQuery = require("./removeFromQuery");
|
|
8
|
+
const commandMatch = /^(delete|insert|read|update)\s+([a-z0-9_-]+)[\w\n]*/i;
|
|
9
9
|
/**
|
|
10
10
|
* Extract command clauses from the query.
|
|
11
11
|
* @param parsed
|
|
12
12
|
* @param query
|
|
13
13
|
*/
|
|
14
14
|
const findCommand = (parsed, query) => {
|
|
15
|
-
const commandFound = query.match(commandMatch)
|
|
16
|
-
parsed
|
|
17
|
-
parsed
|
|
15
|
+
const commandFound = query.match(commandMatch);
|
|
16
|
+
parsed['command'] = undefined;
|
|
17
|
+
parsed['entity'] = undefined;
|
|
18
18
|
if (commandFound) {
|
|
19
|
-
parsed
|
|
20
|
-
parsed
|
|
21
|
-
return (0, _removeFromQuery.removeFromQuery)(commandFound[0], query)
|
|
19
|
+
parsed['command'] = commandFound[1];
|
|
20
|
+
parsed['entity'] = commandFound[2];
|
|
21
|
+
return (0, _removeFromQuery.removeFromQuery)(commandFound[0], query);
|
|
22
22
|
}
|
|
23
|
-
return query
|
|
24
|
-
}
|
|
25
|
-
exports.findCommand = findCommand
|
|
23
|
+
return query;
|
|
24
|
+
};
|
|
25
|
+
exports.findCommand = findCommand;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { LiteralValue } from './parseLiteralValue';
|
|
2
|
-
import { ParsedQuery } from './parseQuery';
|
|
3
|
-
export type ConditionValue = LiteralValue;
|
|
4
|
-
export type ParsedCondition = {
|
|
5
|
-
property: string;
|
|
6
|
-
comparator: string;
|
|
7
|
-
value: ConditionValue;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Extract condition clauses from the query.
|
|
11
|
-
* @param parsed
|
|
12
|
-
* @param query
|
|
13
|
-
*/
|
|
14
|
-
export declare const findConditions: (parsed: ParsedQuery, query: string) => string;
|
|
1
|
+
import { LiteralValue } from './parseLiteralValue';
|
|
2
|
+
import { ParsedQuery } from './parseQuery';
|
|
3
|
+
export type ConditionValue = LiteralValue;
|
|
4
|
+
export type ParsedCondition = {
|
|
5
|
+
property: string;
|
|
6
|
+
comparator: string;
|
|
7
|
+
value: ConditionValue;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Extract condition clauses from the query.
|
|
11
|
+
* @param parsed
|
|
12
|
+
* @param query
|
|
13
|
+
*/
|
|
14
|
+
export declare const findConditions: (parsed: ParsedQuery, query: string) => string;
|
|
15
15
|
//# sourceMappingURL=findConditions.d.ts.map
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.findConditions = void 0
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const conditionMatch = /(and|or)?\s*(where)\s+([a-z0-9_-]+\.?[a-z0-9_-]*)\s+(=|!=|>|<|>=|<=|in|between|like)\s+(["'](.*)['"]|([0-9]+)|(\[.*])|(null)|(true)|(false))/ig
|
|
5
|
+
});
|
|
6
|
+
exports.findConditions = void 0;
|
|
7
|
+
var _removeFromQuery = require("./removeFromQuery");
|
|
8
|
+
var _parseLiteralValue = require("./parseLiteralValue");
|
|
9
|
+
const conditionMatch = /(and|or)?\s*(where)\s+([a-z0-9_-]+\.?[a-z0-9_-]*)\s+(=|!=|>|<|>=|<=|in|between|like)\s+(["'](.*)['"]|([0-9]+)|(\[.*])|(null)|(true)|(false))/ig;
|
|
10
10
|
/**
|
|
11
11
|
* Extract condition clauses from the query.
|
|
12
12
|
* @param parsed
|
|
13
13
|
* @param query
|
|
14
14
|
*/
|
|
15
15
|
const findConditions = (parsed, query) => {
|
|
16
|
-
const conditionsFound = query.matchAll(conditionMatch)
|
|
16
|
+
const conditionsFound = query.matchAll(conditionMatch);
|
|
17
17
|
// @ts-ignore
|
|
18
18
|
for (const condition of conditionsFound) {
|
|
19
|
-
parsed
|
|
19
|
+
parsed['conditions'].push({
|
|
20
20
|
property: condition[3],
|
|
21
21
|
comparator: condition[4],
|
|
22
22
|
value: (0, _parseLiteralValue.parseLiteralValue)(condition, 6)
|
|
23
|
-
})
|
|
24
|
-
query = (0, _removeFromQuery.removeFromQuery)(condition[0], query)
|
|
23
|
+
});
|
|
24
|
+
query = (0, _removeFromQuery.removeFromQuery)(condition[0], query);
|
|
25
25
|
}
|
|
26
|
-
return query
|
|
27
|
-
}
|
|
28
|
-
exports.findConditions = findConditions
|
|
26
|
+
return query;
|
|
27
|
+
};
|
|
28
|
+
exports.findConditions = findConditions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findConditions=void 0;var _removeFromQuery=require("./removeFromQuery"),_parseLiteralValue=require("./parseLiteralValue");const conditionMatch=/(and|or)?\s*(where)\s+([a-z0-9_-]+\.?[a-z0-9_-]*)\s+(=|!=|>|<|>=|<=|in|between|like)\s+(["'](.*)['"]|([0-9]+)|(\[.*])|(null)|(true)|(false))/gi,findConditions=(e,r)=>{const o=r.matchAll(conditionMatch);for(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findConditions=void 0;var _removeFromQuery=require("./removeFromQuery"),_parseLiteralValue=require("./parseLiteralValue");const conditionMatch=/(and|or)?\s*(where)\s+([a-z0-9_-]+\.?[a-z0-9_-]*)\s+(=|!=|>|<|>=|<=|in|between|like)\s+(["'](.*)['"]|([0-9]+)|(\[.*])|(null)|(true)|(false))/gi,findConditions=(e,r)=>{const o=r.matchAll(conditionMatch);for(const i of o)e.conditions.push({property:i[3],comparator:i[4],value:(0,_parseLiteralValue.parseLiteralValue)(i,6)}),r=(0,_removeFromQuery.removeFromQuery)(i[0],r);return r};exports.findConditions=findConditions;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ParsedQuery } from './parseQuery';
|
|
2
|
-
export type ParsedGroupBy = string;
|
|
3
|
-
/**
|
|
4
|
-
* Extract the group by clauses from the query.
|
|
5
|
-
* @param parsed
|
|
6
|
-
* @param query
|
|
7
|
-
*/
|
|
8
|
-
export declare const findGroupBy: (parsed: ParsedQuery, query: string) => string;
|
|
1
|
+
import { ParsedQuery } from './parseQuery';
|
|
2
|
+
export type ParsedGroupBy = string;
|
|
3
|
+
/**
|
|
4
|
+
* Extract the group by clauses from the query.
|
|
5
|
+
* @param parsed
|
|
6
|
+
* @param query
|
|
7
|
+
*/
|
|
8
|
+
export declare const findGroupBy: (parsed: ParsedQuery, query: string) => string;
|
|
9
9
|
//# sourceMappingURL=findGroupBy.d.ts.map
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.findGroupBy = void 0
|
|
7
|
-
|
|
8
|
-
const groupMatch = /group\s+by\s+(,?[a-z0-9._-]+)+/i
|
|
5
|
+
});
|
|
6
|
+
exports.findGroupBy = void 0;
|
|
7
|
+
var _removeFromQuery = require("./removeFromQuery");
|
|
8
|
+
const groupMatch = /group\s+by\s+(,?[a-z0-9._-]+)+/i;
|
|
9
9
|
/**
|
|
10
10
|
* Extract the group by clauses from the query.
|
|
11
11
|
* @param parsed
|
|
12
12
|
* @param query
|
|
13
13
|
*/
|
|
14
14
|
const findGroupBy = (parsed, query) => {
|
|
15
|
-
const groupFound = query.match(groupMatch)
|
|
15
|
+
const groupFound = query.match(groupMatch);
|
|
16
16
|
if (groupFound) {
|
|
17
|
-
parsed
|
|
18
|
-
return (0, _removeFromQuery.removeFromQuery)(groupFound[0], query)
|
|
17
|
+
parsed['groupBy'] = groupFound ? groupFound[1] : undefined;
|
|
18
|
+
return (0, _removeFromQuery.removeFromQuery)(groupFound[0], query);
|
|
19
19
|
}
|
|
20
|
-
return query
|
|
21
|
-
}
|
|
22
|
-
exports.findGroupBy = findGroupBy
|
|
20
|
+
return query;
|
|
21
|
+
};
|
|
22
|
+
exports.findGroupBy = findGroupBy;
|