json-fs-query 1.0.4 → 1.0.6
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 +47 -47
- package/dist/data/introspect/definitions/field.d.ts +27 -27
- package/dist/data/introspect/definitions/field.js +36 -36
- package/dist/data/introspect/definitions/key.d.ts +25 -25
- package/dist/data/introspect/definitions/key.js +53 -53
- package/dist/data/introspect/definitions/keyReference.d.ts +17 -17
- package/dist/data/introspect/definitions/keyReference.js +20 -20
- package/dist/data/introspect/definitions/record.d.ts +25 -25
- package/dist/data/introspect/definitions/record.js +32 -32
- package/dist/data/introspect/describe.js +15 -15
- package/dist/data/introspect/drop.js +37 -37
- package/dist/data/introspect/index.d.ts +7 -7
- package/dist/data/introspect/index.js +30 -30
- package/dist/data/introspect/policies/foreignKeyExists.d.ts +8 -8
- package/dist/data/introspect/policies/foreignKeyExists.js +25 -25
- package/dist/data/introspect/policies/hasDependents.d.ts +12 -12
- package/dist/data/introspect/policies/hasDependents.js +52 -52
- package/dist/data/introspect/policies/keyGenerate.d.ts +1 -1
- package/dist/data/introspect/policies/keyGenerate.js +17 -17
- package/dist/data/introspect/policies/keyUnique.d.ts +9 -9
- package/dist/data/introspect/policies/keyUnique.js +31 -31
- package/dist/data/introspect/policies/typeCheck.d.ts +11 -11
- package/dist/data/introspect/policies/typeCheck.js +57 -57
- package/dist/data/introspect/policies/typeEnum.d.ts +1 -1
- package/dist/data/introspect/policies/typeEnum.js +9 -9
- package/dist/data/introspect/policies/useDefault.d.ts +1 -1
- package/dist/data/introspect/policies/useDefault.js +8 -8
- package/dist/data/queries/deleteEntity.d.ts +1 -1
- package/dist/data/queries/deleteEntity.js +100 -100
- package/dist/data/queries/groupBy.d.ts +1 -1
- package/dist/data/queries/groupBy.js +22 -22
- package/dist/data/queries/insertEntity.d.ts +1 -1
- package/dist/data/queries/insertEntity.js +117 -117
- package/dist/data/queries/joinEntity.d.ts +1 -1
- package/dist/data/queries/joinEntity.js +32 -32
- package/dist/data/queries/joinEntity.min.js +1 -1
- package/dist/data/queries/limitOffset.d.ts +7 -7
- package/dist/data/queries/limitOffset.js +21 -21
- package/dist/data/queries/mergeJoins.d.ts +1 -1
- package/dist/data/queries/mergeJoins.js +19 -19
- package/dist/data/queries/mergeJoins.min.js +1 -1
- package/dist/data/queries/parser.d.ts +1 -1
- package/dist/data/queries/parser.js +19 -19
- package/dist/data/queries/parser.min.js +1 -1
- package/dist/data/queries/query.d.ts +1 -1
- package/dist/data/queries/query.js +18 -18
- package/dist/data/queries/query.min.js +1 -1
- package/dist/data/queries/readEntity.js +14 -14
- package/dist/data/queries/selectFields.d.ts +9 -9
- package/dist/data/queries/selectFields.js +36 -36
- package/dist/data/queries/sortBy.d.ts +1 -1
- package/dist/data/queries/sortBy.js +15 -15
- package/dist/data/queries/sortBy.min.js +1 -1
- package/dist/data/queries/updateEntity.d.ts +1 -1
- package/dist/data/queries/updateEntity.js +190 -190
- package/dist/data/queries/where.d.ts +6 -6
- package/dist/data/queries/where.js +56 -56
- package/dist/data/utilities/computeKeyValue.d.ts +12 -12
- package/dist/data/utilities/computeKeyValue.js +26 -26
- package/dist/data/utilities/config.d.ts +27 -27
- package/dist/data/utilities/config.js +45 -45
- package/dist/data/utilities/deregisterRecord.d.ts +7 -7
- package/dist/data/utilities/deregisterRecord.js +34 -34
- package/dist/data/utilities/getConditionIndexedList.js +47 -47
- package/dist/data/utilities/getConditionIndexedList.min.js +1 -1
- package/dist/data/utilities/getJoinIndexedList.js +76 -76
- package/dist/data/utilities/getJoinIndexedList.min.js +1 -1
- package/dist/data/utilities/getMatchingIndexes.js +28 -28
- package/dist/data/utilities/getMatchingIndexes.min.js +1 -1
- package/dist/data/utilities/matchIndexedJoins.js +61 -61
- package/dist/data/utilities/matchIndexedJoins.min.js +1 -1
- package/dist/data/utilities/mergeJoin.js +44 -44
- 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 +25 -25
- package/dist/data/utilities/parsers/findConditions.d.ts +14 -14
- package/dist/data/utilities/parsers/findConditions.js +28 -28
- 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 +22 -22
- package/dist/data/utilities/parsers/findInsertValues.d.ts +12 -12
- package/dist/data/utilities/parsers/findInsertValues.js +34 -34
- package/dist/data/utilities/parsers/findJoinClauses.d.ts +12 -12
- package/dist/data/utilities/parsers/findJoinClauses.js +27 -27
- 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 +22 -22
- package/dist/data/utilities/parsers/findLimit.d.ts +8 -8
- package/dist/data/utilities/parsers/findLimit.js +22 -22
- package/dist/data/utilities/parsers/findMergeJoins.d.ts +11 -11
- package/dist/data/utilities/parsers/findMergeJoins.js +26 -26
- 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 +22 -22
- package/dist/data/utilities/parsers/findSelects.d.ts +11 -11
- package/dist/data/utilities/parsers/findSelects.js +30 -30
- 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 +30 -30
- 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 +34 -34
- package/dist/data/utilities/parsers/isEntityProperty.js +6 -6
- package/dist/data/utilities/parsers/parseLiteralValue.d.ts +11 -11
- package/dist/data/utilities/parsers/parseLiteralValue.js +34 -34
- package/dist/data/utilities/parsers/parseQuery.d.ts +32 -32
- package/dist/data/utilities/parsers/parseQuery.js +51 -51
- package/dist/data/utilities/parsers/parseQuery.min.js +1 -1
- package/dist/data/utilities/parsers/removeFromQuery.js +6 -6
- package/dist/data/utilities/parsers/splitEntityProperty.js +13 -13
- package/dist/data/utilities/parsers/splitQueries.js +9 -9
- package/dist/data/utilities/reconcileJoin.js +26 -26
- package/dist/data/utilities/reconcileJoins.js +26 -26
- package/dist/data/utilities/reconcileJoins.min.js +1 -1
- package/dist/data/utilities/registerRecord.d.ts +7 -7
- package/dist/data/utilities/registerRecord.js +67 -67
- package/dist/data/utilities/removeFromIndex.d.ts +13 -13
- package/dist/data/utilities/removeFromIndex.js +44 -46
- package/dist/data/utilities/restrictIndexedList.js +45 -45
- package/dist/data/utilities/retrieveFile.js +28 -28
- package/dist/data/utilities/retrieveFile.min.js +1 -1
- package/dist/data/utilities/retrieveIndexes.d.ts +1 -1
- package/dist/data/utilities/retrieveIndexes.js +24 -24
- package/dist/data/utilities/retrieveIndexes.min.js +1 -1
- package/dist/data/utilities/retrieveRecord.js +9 -9
- package/dist/data/utilities/retrieveRecords.js +21 -21
- package/dist/data/utilities/retrieveRecords.min.js +1 -1
- package/dist/data/utilities/runQuery.d.ts +1 -1
- package/dist/data/utilities/runQuery.js +87 -87
- package/dist/data/utilities/updateIndex.d.ts +16 -16
- package/dist/data/utilities/updateIndex.js +56 -56
- package/dist/data/utilities/useJoinClause.d.ts +5 -5
- package/dist/data/utilities/useJoinClause.js +51 -51
- package/dist/index.d.ts +4 -4
- package/dist/index.js +42 -42
- package/package.json +9 -5
|
@@ -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
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.mergeJoin = void 0
|
|
7
|
-
require(
|
|
8
|
-
require(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const mergeJoin = async (propertyA = '', propertyB = '', dataSets = {}) => {
|
|
13
|
-
const {
|
|
14
|
-
entity: entityA,
|
|
15
|
-
property: propA
|
|
16
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(propertyA)
|
|
17
|
-
const {
|
|
18
|
-
entity: entityB,
|
|
19
|
-
property: propB
|
|
20
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(propertyB)
|
|
21
|
-
dataSets = await (0, _readEntity.readEntity)(entityA, dataSets)
|
|
22
|
-
dataSets = await (0, _readEntity.readEntity)(entityB, dataSets)
|
|
23
|
-
dataSets[entityA] = dataSets[entityA].map(dataA => {
|
|
24
|
-
const matches = (0, _where.where)(dataSets[entityB], {
|
|
25
|
-
property: propB,
|
|
26
|
-
comparator: '=',
|
|
27
|
-
value: dataA[propA]
|
|
28
|
-
})
|
|
29
|
-
if (!matches.length) {
|
|
30
|
-
return dataA
|
|
31
|
-
}
|
|
32
|
-
const mergeMatch = matches[0]
|
|
33
|
-
for (const prop in mergeMatch) {
|
|
34
|
-
if (prop === propB) {
|
|
35
|
-
// Skip the condition property since it is irrelevant
|
|
36
|
-
continue
|
|
37
|
-
}
|
|
38
|
-
dataA[`${entityB}.${prop}`] = mergeMatch[prop]
|
|
39
|
-
}
|
|
40
|
-
return dataA
|
|
41
|
-
})
|
|
42
|
-
return dataSets
|
|
43
|
-
}
|
|
44
|
-
exports.mergeJoin = mergeJoin
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
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
|
+
const mergeJoin = async (propertyA = '', propertyB = '', dataSets = {}) => {
|
|
13
|
+
const {
|
|
14
|
+
entity: entityA,
|
|
15
|
+
property: propA
|
|
16
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(propertyA);
|
|
17
|
+
const {
|
|
18
|
+
entity: entityB,
|
|
19
|
+
property: propB
|
|
20
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(propertyB);
|
|
21
|
+
dataSets = await (0, _readEntity.readEntity)(entityA, dataSets);
|
|
22
|
+
dataSets = await (0, _readEntity.readEntity)(entityB, dataSets);
|
|
23
|
+
dataSets[entityA] = dataSets[entityA].map(dataA => {
|
|
24
|
+
const matches = (0, _where.where)(dataSets[entityB], {
|
|
25
|
+
property: propB,
|
|
26
|
+
comparator: '=',
|
|
27
|
+
value: dataA[propA]
|
|
28
|
+
});
|
|
29
|
+
if (!matches.length) {
|
|
30
|
+
return dataA;
|
|
31
|
+
}
|
|
32
|
+
const mergeMatch = matches[0];
|
|
33
|
+
for (const prop in mergeMatch) {
|
|
34
|
+
if (prop === propB) {
|
|
35
|
+
// Skip the condition property since it is irrelevant
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
dataA[`${entityB}.${prop}`] = mergeMatch[prop];
|
|
39
|
+
}
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.findCommand = void 0
|
|
7
|
-
|
|
8
|
-
const commandMatch = /^(delete|insert|read|update)\s+([a-z0-9_-]+)[\w\n]*/i
|
|
9
|
-
/**
|
|
10
|
-
* Extract command clauses from the query.
|
|
11
|
-
* @param parsed
|
|
12
|
-
* @param query
|
|
13
|
-
*/
|
|
14
|
-
const findCommand = (parsed, query) => {
|
|
15
|
-
const commandFound = query.match(commandMatch)
|
|
16
|
-
parsed
|
|
17
|
-
parsed
|
|
18
|
-
if (commandFound) {
|
|
19
|
-
parsed
|
|
20
|
-
parsed
|
|
21
|
-
return (0, _removeFromQuery.removeFromQuery)(commandFound[0], query)
|
|
22
|
-
}
|
|
23
|
-
return query
|
|
24
|
-
}
|
|
25
|
-
exports.findCommand = findCommand
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
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
|
+
/**
|
|
10
|
+
* Extract command clauses from the query.
|
|
11
|
+
* @param parsed
|
|
12
|
+
* @param query
|
|
13
|
+
*/
|
|
14
|
+
const findCommand = (parsed, query) => {
|
|
15
|
+
const commandFound = query.match(commandMatch);
|
|
16
|
+
parsed['command'] = undefined;
|
|
17
|
+
parsed['entity'] = undefined;
|
|
18
|
+
if (commandFound) {
|
|
19
|
+
parsed['command'] = commandFound[1];
|
|
20
|
+
parsed['entity'] = commandFound[2];
|
|
21
|
+
return (0, _removeFromQuery.removeFromQuery)(commandFound[0], query);
|
|
22
|
+
}
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
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
|
|
10
|
-
/**
|
|
11
|
-
* Extract condition clauses from the query.
|
|
12
|
-
* @param parsed
|
|
13
|
-
* @param query
|
|
14
|
-
*/
|
|
15
|
-
const findConditions = (parsed, query) => {
|
|
16
|
-
const conditionsFound = query.matchAll(conditionMatch)
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
for (const condition of conditionsFound) {
|
|
19
|
-
parsed
|
|
20
|
-
property: condition[3],
|
|
21
|
-
comparator: condition[4],
|
|
22
|
-
value: (0, _parseLiteralValue.parseLiteralValue)(condition, 6)
|
|
23
|
-
})
|
|
24
|
-
query = (0, _removeFromQuery.removeFromQuery)(condition[0], query)
|
|
25
|
-
}
|
|
26
|
-
return query
|
|
27
|
-
}
|
|
28
|
-
exports.findConditions = findConditions
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
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
|
+
/**
|
|
11
|
+
* Extract condition clauses from the query.
|
|
12
|
+
* @param parsed
|
|
13
|
+
* @param query
|
|
14
|
+
*/
|
|
15
|
+
const findConditions = (parsed, query) => {
|
|
16
|
+
const conditionsFound = query.matchAll(conditionMatch);
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
for (const condition of conditionsFound) {
|
|
19
|
+
parsed['conditions'].push({
|
|
20
|
+
property: condition[3],
|
|
21
|
+
comparator: condition[4],
|
|
22
|
+
value: (0, _parseLiteralValue.parseLiteralValue)(condition, 6)
|
|
23
|
+
});
|
|
24
|
+
query = (0, _removeFromQuery.removeFromQuery)(condition[0], query);
|
|
25
|
+
}
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.findGroupBy = void 0
|
|
7
|
-
|
|
8
|
-
const groupMatch = /group\s+by\s+(,?[a-z0-9._-]+)+/i
|
|
9
|
-
/**
|
|
10
|
-
* Extract the group by clauses from the query.
|
|
11
|
-
* @param parsed
|
|
12
|
-
* @param query
|
|
13
|
-
*/
|
|
14
|
-
const findGroupBy = (parsed, query) => {
|
|
15
|
-
const groupFound = query.match(groupMatch)
|
|
16
|
-
if (groupFound) {
|
|
17
|
-
parsed
|
|
18
|
-
return (0, _removeFromQuery.removeFromQuery)(groupFound[0], query)
|
|
19
|
-
}
|
|
20
|
-
return query
|
|
21
|
-
}
|
|
22
|
-
exports.findGroupBy = findGroupBy
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findGroupBy = void 0;
|
|
7
|
+
var _removeFromQuery = require("./removeFromQuery");
|
|
8
|
+
const groupMatch = /group\s+by\s+(,?[a-z0-9._-]+)+/i;
|
|
9
|
+
/**
|
|
10
|
+
* Extract the group by clauses from the query.
|
|
11
|
+
* @param parsed
|
|
12
|
+
* @param query
|
|
13
|
+
*/
|
|
14
|
+
const findGroupBy = (parsed, query) => {
|
|
15
|
+
const groupFound = query.match(groupMatch);
|
|
16
|
+
if (groupFound) {
|
|
17
|
+
parsed['groupBy'] = groupFound ? groupFound[1] : undefined;
|
|
18
|
+
return (0, _removeFromQuery.removeFromQuery)(groupFound[0], query);
|
|
19
|
+
}
|
|
20
|
+
return query;
|
|
21
|
+
};
|
|
22
|
+
exports.findGroupBy = findGroupBy;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ParsedQuery } from './parseQuery';
|
|
2
|
-
export type ParsedInsertRow = {
|
|
3
|
-
[field: string]: any;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* Extract an insert's "values field = value, field2 = value2" clause from the query, the same way
|
|
7
|
-
* findUpdateValues() does for "set". insertEntity() accepts an array of rows for bulk inserts, but
|
|
8
|
-
* a query string only describes a single row for now - wrapped in a one-element array to match.
|
|
9
|
-
* @param parsed
|
|
10
|
-
* @param query
|
|
11
|
-
*/
|
|
12
|
-
export declare const findInsertValues: (parsed: ParsedQuery, query: string) => string;
|
|
1
|
+
import { ParsedQuery } from './parseQuery';
|
|
2
|
+
export type ParsedInsertRow = {
|
|
3
|
+
[field: string]: any;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Extract an insert's "values field = value, field2 = value2" clause from the query, the same way
|
|
7
|
+
* findUpdateValues() does for "set". insertEntity() accepts an array of rows for bulk inserts, but
|
|
8
|
+
* a query string only describes a single row for now - wrapped in a one-element array to match.
|
|
9
|
+
* @param parsed
|
|
10
|
+
* @param query
|
|
11
|
+
*/
|
|
12
|
+
export declare const findInsertValues: (parsed: ParsedQuery, query: string) => string;
|
|
13
13
|
//# sourceMappingURL=findInsertValues.d.ts.map
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.findInsertValues = void 0
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const literal = '(?:["\'][^"\']*[\'"]|[0-9]+|\\[.*?]|null|true|false)'
|
|
10
|
-
const valuesClauseMatch = new RegExp(`(values)\\s+([a-z0-9_-]+\\s*=\\s*${literal}(?:\\s*,\\s*[a-z0-9_-]+\\s*=\\s*${literal})*)`, 'i')
|
|
11
|
-
const assignmentMatch = /([a-z0-9_-]+)\s*=\s*(["'](.*?)['"]|([0-9]+)|(\[.*?])|(null)|(true)|(false))/ig
|
|
12
|
-
/**
|
|
13
|
-
* Extract an insert's "values field = value, field2 = value2" clause from the query, the same way
|
|
14
|
-
* findUpdateValues() does for "set". insertEntity() accepts an array of rows for bulk inserts, but
|
|
15
|
-
* a query string only describes a single row for now - wrapped in a one-element array to match.
|
|
16
|
-
* @param parsed
|
|
17
|
-
* @param query
|
|
18
|
-
*/
|
|
19
|
-
const findInsertValues = (parsed, query) => {
|
|
20
|
-
const clauseFound = query.match(valuesClauseMatch)
|
|
21
|
-
parsed
|
|
22
|
-
if (!clauseFound) {
|
|
23
|
-
return query
|
|
24
|
-
}
|
|
25
|
-
const row = {}
|
|
26
|
-
const assignmentsFound = clauseFound[2].matchAll(assignmentMatch)
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
for (const assignment of assignmentsFound) {
|
|
29
|
-
row[assignment[1]] = (0, _parseLiteralValue.parseLiteralValue)(assignment, 3)
|
|
30
|
-
}
|
|
31
|
-
parsed
|
|
32
|
-
return (0, _removeFromQuery.removeFromQuery)(clauseFound[0], query)
|
|
33
|
-
}
|
|
34
|
-
exports.findInsertValues = findInsertValues
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findInsertValues = void 0;
|
|
7
|
+
var _removeFromQuery = require("./removeFromQuery");
|
|
8
|
+
var _parseLiteralValue = require("./parseLiteralValue");
|
|
9
|
+
const literal = '(?:["\'][^"\']*[\'"]|[0-9]+|\\[.*?]|null|true|false)';
|
|
10
|
+
const valuesClauseMatch = new RegExp(`(values)\\s+([a-z0-9_-]+\\s*=\\s*${literal}(?:\\s*,\\s*[a-z0-9_-]+\\s*=\\s*${literal})*)`, 'i');
|
|
11
|
+
const assignmentMatch = /([a-z0-9_-]+)\s*=\s*(["'](.*?)['"]|([0-9]+)|(\[.*?])|(null)|(true)|(false))/ig;
|
|
12
|
+
/**
|
|
13
|
+
* Extract an insert's "values field = value, field2 = value2" clause from the query, the same way
|
|
14
|
+
* findUpdateValues() does for "set". insertEntity() accepts an array of rows for bulk inserts, but
|
|
15
|
+
* a query string only describes a single row for now - wrapped in a one-element array to match.
|
|
16
|
+
* @param parsed
|
|
17
|
+
* @param query
|
|
18
|
+
*/
|
|
19
|
+
const findInsertValues = (parsed, query) => {
|
|
20
|
+
const clauseFound = query.match(valuesClauseMatch);
|
|
21
|
+
parsed['insertValues'] = [];
|
|
22
|
+
if (!clauseFound) {
|
|
23
|
+
return query;
|
|
24
|
+
}
|
|
25
|
+
const row = {};
|
|
26
|
+
const assignmentsFound = clauseFound[2].matchAll(assignmentMatch);
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
for (const assignment of assignmentsFound) {
|
|
29
|
+
row[assignment[1]] = (0, _parseLiteralValue.parseLiteralValue)(assignment, 3);
|
|
30
|
+
}
|
|
31
|
+
parsed['insertValues'] = [row];
|
|
32
|
+
return (0, _removeFromQuery.removeFromQuery)(clauseFound[0], query);
|
|
33
|
+
};
|
|
34
|
+
exports.findInsertValues = findInsertValues;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ParsedQuery } from './parseQuery';
|
|
2
|
-
export type ParsedJoinClause = {
|
|
3
|
-
propertyA: string;
|
|
4
|
-
comparator: string;
|
|
5
|
-
propertyB: string;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Extract condition clauses from the query.
|
|
9
|
-
* @param parsed
|
|
10
|
-
* @param query
|
|
11
|
-
*/
|
|
12
|
-
export declare const findJoinClauses: (parsed: ParsedQuery, query: string) => string;
|
|
1
|
+
import { ParsedQuery } from './parseQuery';
|
|
2
|
+
export type ParsedJoinClause = {
|
|
3
|
+
propertyA: string;
|
|
4
|
+
comparator: string;
|
|
5
|
+
propertyB: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Extract condition clauses from the query.
|
|
9
|
+
* @param parsed
|
|
10
|
+
* @param query
|
|
11
|
+
*/
|
|
12
|
+
export declare const findJoinClauses: (parsed: ParsedQuery, query: string) => string;
|
|
13
13
|
//# sourceMappingURL=findJoinClauses.d.ts.map
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.findJoinClauses = void 0
|
|
7
|
-
|
|
8
|
-
const joinClauseMatch = /(and)?\s*on\s+([a-z0-9_-]+\.[a-z0-9_-]+)\s+(=|!=|>|<|>=|<=|in|between|like)\s+([a-z0-9_-]+\.[a-z0-9_-]+)/ig
|
|
9
|
-
/**
|
|
10
|
-
* Extract condition clauses from the query.
|
|
11
|
-
* @param parsed
|
|
12
|
-
* @param query
|
|
13
|
-
*/
|
|
14
|
-
const findJoinClauses = (parsed, query) => {
|
|
15
|
-
const joinClausesFound = query.matchAll(joinClauseMatch)
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
for (const joinClause of joinClausesFound) {
|
|
18
|
-
parsed
|
|
19
|
-
propertyA: joinClause[2],
|
|
20
|
-
comparator: joinClause[3],
|
|
21
|
-
propertyB: joinClause[4]
|
|
22
|
-
})
|
|
23
|
-
query = (0, _removeFromQuery.removeFromQuery)(joinClause[0], query)
|
|
24
|
-
}
|
|
25
|
-
return query
|
|
26
|
-
}
|
|
27
|
-
exports.findJoinClauses = findJoinClauses
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findJoinClauses = void 0;
|
|
7
|
+
var _removeFromQuery = require("./removeFromQuery");
|
|
8
|
+
const joinClauseMatch = /(and)?\s*on\s+([a-z0-9_-]+\.[a-z0-9_-]+)\s+(=|!=|>|<|>=|<=|in|between|like)\s+([a-z0-9_-]+\.[a-z0-9_-]+)/ig;
|
|
9
|
+
/**
|
|
10
|
+
* Extract condition clauses from the query.
|
|
11
|
+
* @param parsed
|
|
12
|
+
* @param query
|
|
13
|
+
*/
|
|
14
|
+
const findJoinClauses = (parsed, query) => {
|
|
15
|
+
const joinClausesFound = query.matchAll(joinClauseMatch);
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
for (const joinClause of joinClausesFound) {
|
|
18
|
+
parsed['joinClauses'].push({
|
|
19
|
+
propertyA: joinClause[2],
|
|
20
|
+
comparator: joinClause[3],
|
|
21
|
+
propertyB: joinClause[4]
|
|
22
|
+
});
|
|
23
|
+
query = (0, _removeFromQuery.removeFromQuery)(joinClause[0], query);
|
|
24
|
+
}
|
|
25
|
+
return query;
|
|
26
|
+
};
|
|
27
|
+
exports.findJoinClauses = findJoinClauses;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findJoinClauses=void 0;var _removeFromQuery=require("./removeFromQuery");const joinClauseMatch=/(and)?\s*on\s+([a-z0-9_-]+\.[a-z0-9_-]+)\s+(=|!=|>|<|>=|<=|in|between|like)\s+([a-z0-9_-]+\.[a-z0-9_-]+)/gi,findJoinClauses=(e,o)=>{const r=o.matchAll(joinClauseMatch);for(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findJoinClauses=void 0;var _removeFromQuery=require("./removeFromQuery");const joinClauseMatch=/(and)?\s*on\s+([a-z0-9_-]+\.[a-z0-9_-]+)\s+(=|!=|>|<|>=|<=|in|between|like)\s+([a-z0-9_-]+\.[a-z0-9_-]+)/gi,findJoinClauses=(e,o)=>{const r=o.matchAll(joinClauseMatch);for(const s of r)e.joinClauses.push({propertyA:s[2],comparator:s[3],propertyB:s[4]}),o=(0,_removeFromQuery.removeFromQuery)(s[0],o);return o};exports.findJoinClauses=findJoinClauses;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ParsedQuery } from './parseQuery';
|
|
2
|
-
export type ParsedJoinEntity = string;
|
|
3
|
-
/**
|
|
4
|
-
* Extract the main join entity from the query.
|
|
5
|
-
* @param parsed
|
|
6
|
-
* @param query
|
|
7
|
-
*/
|
|
8
|
-
export declare const findJoinEntity: (parsed: ParsedQuery, query: string) => string;
|
|
1
|
+
import { ParsedQuery } from './parseQuery';
|
|
2
|
+
export type ParsedJoinEntity = string;
|
|
3
|
+
/**
|
|
4
|
+
* Extract the main join entity from the query.
|
|
5
|
+
* @param parsed
|
|
6
|
+
* @param query
|
|
7
|
+
*/
|
|
8
|
+
export declare const findJoinEntity: (parsed: ParsedQuery, query: string) => string;
|
|
9
9
|
//# sourceMappingURL=findJoinEntity.d.ts.map
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.findJoinEntity = void 0
|
|
7
|
-
|
|
8
|
-
const joinEntityMatch = /\.([a-z0-9_-]+)/i
|
|
9
|
-
/**
|
|
10
|
-
* Extract the main join entity from the query.
|
|
11
|
-
* @param parsed
|
|
12
|
-
* @param query
|
|
13
|
-
*/
|
|
14
|
-
const findJoinEntity = (parsed, query) => {
|
|
15
|
-
const joinEntityFound = query.match(joinEntityMatch)
|
|
16
|
-
if (joinEntityFound) {
|
|
17
|
-
parsed
|
|
18
|
-
return (0, _removeFromQuery.removeFromQuery)(joinEntityFound[0], query)
|
|
19
|
-
}
|
|
20
|
-
return query
|
|
21
|
-
}
|
|
22
|
-
exports.findJoinEntity = findJoinEntity
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findJoinEntity = void 0;
|
|
7
|
+
var _removeFromQuery = require("./removeFromQuery");
|
|
8
|
+
const joinEntityMatch = /\.([a-z0-9_-]+)/i;
|
|
9
|
+
/**
|
|
10
|
+
* Extract the main join entity from the query.
|
|
11
|
+
* @param parsed
|
|
12
|
+
* @param query
|
|
13
|
+
*/
|
|
14
|
+
const findJoinEntity = (parsed, query) => {
|
|
15
|
+
const joinEntityFound = query.match(joinEntityMatch);
|
|
16
|
+
if (joinEntityFound) {
|
|
17
|
+
parsed['joinEntity'] = joinEntityFound ? joinEntityFound[1] : undefined;
|
|
18
|
+
return (0, _removeFromQuery.removeFromQuery)(joinEntityFound[0], query);
|
|
19
|
+
}
|
|
20
|
+
return query;
|
|
21
|
+
};
|
|
22
|
+
exports.findJoinEntity = findJoinEntity;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ParsedQuery } from './parseQuery';
|
|
2
|
-
export type ParsedLimit = number;
|
|
3
|
-
/**
|
|
4
|
-
* Extract the limit clauses from the query.
|
|
5
|
-
* @param parsed
|
|
6
|
-
* @param query
|
|
7
|
-
*/
|
|
8
|
-
export declare const findLimit: (parsed: ParsedQuery, query: string) => string;
|
|
1
|
+
import { ParsedQuery } from './parseQuery';
|
|
2
|
+
export type ParsedLimit = number;
|
|
3
|
+
/**
|
|
4
|
+
* Extract the limit clauses from the query.
|
|
5
|
+
* @param parsed
|
|
6
|
+
* @param query
|
|
7
|
+
*/
|
|
8
|
+
export declare const findLimit: (parsed: ParsedQuery, query: string) => string;
|
|
9
9
|
//# sourceMappingURL=findLimit.d.ts.map
|