json-fs-query 1.1.0 → 2.1.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.
- package/LICENSE +674 -674
- package/README.md +326 -98
- package/browser/jsonFsQuery.js +12819 -10934
- package/browser/jsonFsQuery.min.js +1 -1
- package/dist/data/introspect/create.d.ts +1 -1
- package/dist/data/introspect/create.js +35 -4
- package/dist/data/introspect/create.min.js +1 -1
- package/dist/data/introspect/definitions/field.d.ts +6 -2
- package/dist/data/introspect/definitions/field.js +7 -1
- package/dist/data/introspect/definitions/field.min.js +1 -1
- package/dist/data/introspect/index.d.ts +6 -3
- package/dist/data/introspect/index.js +10 -19
- package/dist/data/introspect/index.min.js +1 -1
- package/dist/data/introspect/policies/foreignKeyExists.js +28 -28
- package/dist/data/introspect/policies/hasDependents.js +53 -53
- package/dist/data/introspect/policies/keyUnique.js +34 -34
- package/dist/data/introspect/policies/typeCheck.d.ts +9 -1
- package/dist/data/introspect/policies/typeCheck.js +20 -2
- package/dist/data/introspect/policies/typeCheck.min.js +1 -1
- package/dist/data/queries/createRecord.d.ts +11 -0
- package/dist/data/queries/createRecord.js +58 -0
- package/dist/data/queries/createRecord.min.js +1 -0
- package/dist/data/queries/deleteEntity.js +100 -100
- package/dist/data/queries/describeRecord.d.ts +9 -0
- package/dist/data/queries/describeRecord.js +29 -0
- package/dist/data/queries/describeRecord.min.js +1 -0
- package/dist/data/queries/dropRecord.d.ts +9 -0
- package/dist/data/queries/dropRecord.js +61 -0
- package/dist/data/queries/dropRecord.min.js +1 -0
- package/dist/data/queries/insertEntity.js +122 -117
- package/dist/data/queries/insertEntity.min.js +1 -1
- package/dist/data/queries/parser.d.ts +1 -1
- package/dist/data/queries/parser.js +7 -15
- package/dist/data/queries/parser.min.js +1 -1
- package/dist/data/queries/query.d.ts +6 -0
- package/dist/data/queries/query.js +15 -6
- package/dist/data/queries/query.min.js +1 -1
- package/dist/data/queries/queryStatus.d.ts +15 -0
- package/dist/data/queries/queryStatus.js +52 -0
- package/dist/data/queries/queryStatus.min.js +1 -0
- package/dist/data/queries/quote.d.ts +11 -0
- package/dist/data/queries/quote.js +17 -0
- package/dist/data/queries/quote.min.js +1 -0
- package/dist/data/queries/showRecords.d.ts +6 -0
- package/dist/data/queries/showRecords.js +21 -0
- package/dist/data/queries/showRecords.min.js +1 -0
- package/dist/data/queries/sortBy.js +40 -27
- package/dist/data/queries/sortBy.min.js +1 -1
- package/dist/data/queries/updateEntity.js +245 -193
- package/dist/data/queries/updateEntity.min.js +1 -1
- package/dist/data/queries/where.d.ts +7 -7
- package/dist/data/queries/where.js +85 -67
- package/dist/data/queries/where.min.js +1 -1
- package/dist/data/utilities/compareAs.d.ts +19 -19
- package/dist/data/utilities/compareAs.js +57 -57
- package/dist/data/utilities/config.d.ts +15 -0
- package/dist/data/utilities/config.js +31 -1
- package/dist/data/utilities/config.min.js +1 -1
- package/dist/data/utilities/databaseLock.d.ts +16 -0
- package/dist/data/utilities/databaseLock.js +63 -0
- package/dist/data/utilities/databaseLock.min.js +1 -0
- package/dist/data/utilities/fieldType.d.ts +15 -15
- package/dist/data/utilities/fieldType.js +22 -22
- package/dist/data/utilities/getConditionIndexedList.js +47 -47
- package/dist/data/utilities/matchIndexedJoins.js +62 -62
- package/dist/data/utilities/mergeJoin.js +47 -47
- package/dist/data/utilities/parsers/findConditions.d.ts +19 -15
- package/dist/data/utilities/parsers/findConditions.js +34 -8
- package/dist/data/utilities/parsers/findConditions.min.js +1 -1
- package/dist/data/utilities/parsers/findInsertValues.js +3 -2
- package/dist/data/utilities/parsers/findInsertValues.min.js +1 -1
- package/dist/data/utilities/parsers/findJoinEntity.js +3 -1
- package/dist/data/utilities/parsers/findJoinEntity.min.js +1 -1
- package/dist/data/utilities/parsers/findSelects.js +6 -3
- package/dist/data/utilities/parsers/findSelects.min.js +1 -1
- package/dist/data/utilities/parsers/findSortClauses.js +5 -2
- package/dist/data/utilities/parsers/findSortClauses.min.js +1 -1
- package/dist/data/utilities/parsers/findUpdateValues.js +3 -2
- package/dist/data/utilities/parsers/findUpdateValues.min.js +1 -1
- package/dist/data/utilities/parsers/maskStrings.d.ts +39 -0
- package/dist/data/utilities/parsers/maskStrings.js +127 -0
- package/dist/data/utilities/parsers/maskStrings.min.js +1 -0
- package/dist/data/utilities/parsers/parseCreate.d.ts +20 -0
- package/dist/data/utilities/parsers/parseCreate.js +332 -0
- package/dist/data/utilities/parsers/parseCreate.min.js +1 -0
- package/dist/data/utilities/parsers/parseLiteralValue.d.ts +18 -1
- package/dist/data/utilities/parsers/parseLiteralValue.js +34 -5
- package/dist/data/utilities/parsers/parseLiteralValue.min.js +1 -1
- package/dist/data/utilities/parsers/parseQuery.d.ts +3 -0
- package/dist/data/utilities/parsers/parseQuery.js +28 -2
- package/dist/data/utilities/parsers/parseQuery.min.js +1 -1
- package/dist/data/utilities/parsers/parseSchemaStatement.d.ts +13 -0
- package/dist/data/utilities/parsers/parseSchemaStatement.js +82 -0
- package/dist/data/utilities/parsers/parseSchemaStatement.min.js +1 -0
- package/dist/data/utilities/parsers/scanQuery.d.ts +52 -0
- package/dist/data/utilities/parsers/scanQuery.js +158 -0
- package/dist/data/utilities/parsers/scanQuery.min.js +1 -0
- package/dist/data/utilities/parsers/splitQueries.d.ts +6 -0
- package/dist/data/utilities/parsers/splitQueries.js +20 -2
- package/dist/data/utilities/parsers/splitQueries.min.js +1 -1
- package/dist/data/utilities/parsers/startsQuery.d.ts +5 -0
- package/dist/data/utilities/parsers/startsQuery.js +10 -0
- package/dist/data/utilities/parsers/startsQuery.min.js +1 -0
- package/dist/data/utilities/recordExists.d.ts +6 -0
- package/dist/data/utilities/recordExists.js +18 -0
- package/dist/data/utilities/recordExists.min.js +1 -0
- package/dist/data/utilities/removeFromIndex.d.ts +14 -14
- package/dist/data/utilities/removeFromIndex.js +45 -45
- package/dist/data/utilities/runQuery.js +135 -112
- package/dist/data/utilities/runQuery.min.js +1 -1
- package/dist/data/utilities/updateIndex.d.ts +17 -17
- package/dist/data/utilities/updateIndex.js +57 -57
- package/dist/data/utilities/useJoinClause.js +56 -56
- package/dist/index.d.ts +2 -0
- package/dist/index.js +14 -0
- package/dist/index.min.js +1 -1
- package/package.json +68 -60
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
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
|
-
const getConditionIndexedList = async (parsed, recordData, dataSet) => {
|
|
14
|
-
const reducedConditions = [];
|
|
15
|
-
for (const condition of parsed.conditions) {
|
|
16
|
-
let entity = parsed.entity;
|
|
17
|
-
let property = condition.property;
|
|
18
|
-
if ((0, _isEntityProperty.isEntityProperty)(property)) {
|
|
19
|
-
const entityProperty = (0, _splitEntityProperty.splitEntityProperty)(property);
|
|
20
|
-
entity = entityProperty.entity;
|
|
21
|
-
property = entityProperty.property;
|
|
22
|
-
}
|
|
23
|
-
if (!Object.prototype.hasOwnProperty.call(recordData, entity)) {
|
|
24
|
-
recordData[entity] = await (0, _retrieveRecord.retrieveRecord)(entity);
|
|
25
|
-
}
|
|
26
|
-
const indexed = {};
|
|
27
|
-
const retrieveMatchedFiles = async (entity, property, recordData, condition, dataSet, indexed) => {
|
|
28
|
-
const matchedRecords = (0, _where.where)(indexed[entity][property], {
|
|
29
|
-
property: 'value',
|
|
30
|
-
comparator: condition.comparator,
|
|
31
|
-
value: condition.value,
|
|
32
|
-
type: condition.type
|
|
33
|
-
});
|
|
34
|
-
for (const matchedRecord of matchedRecords) {
|
|
35
|
-
for (const file of matchedRecord.record) {
|
|
36
|
-
dataSet[entity].push(await (0, _retrieveFile.retrieveFile)(`${entity}/${file}`));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const isIndexed = await (0, _getMatchingIndexes.getMatchingIndexes)(entity, property, recordData, condition, dataSet, indexed, retrieveMatchedFiles);
|
|
41
|
-
if (!isIndexed) {
|
|
42
|
-
reducedConditions.push(condition);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
parsed.conditions = reducedConditions;
|
|
46
|
-
return parsed;
|
|
47
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
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
|
+
const getConditionIndexedList = async (parsed, recordData, dataSet) => {
|
|
14
|
+
const reducedConditions = [];
|
|
15
|
+
for (const condition of parsed.conditions) {
|
|
16
|
+
let entity = parsed.entity;
|
|
17
|
+
let property = condition.property;
|
|
18
|
+
if ((0, _isEntityProperty.isEntityProperty)(property)) {
|
|
19
|
+
const entityProperty = (0, _splitEntityProperty.splitEntityProperty)(property);
|
|
20
|
+
entity = entityProperty.entity;
|
|
21
|
+
property = entityProperty.property;
|
|
22
|
+
}
|
|
23
|
+
if (!Object.prototype.hasOwnProperty.call(recordData, entity)) {
|
|
24
|
+
recordData[entity] = await (0, _retrieveRecord.retrieveRecord)(entity);
|
|
25
|
+
}
|
|
26
|
+
const indexed = {};
|
|
27
|
+
const retrieveMatchedFiles = async (entity, property, recordData, condition, dataSet, indexed) => {
|
|
28
|
+
const matchedRecords = (0, _where.where)(indexed[entity][property], {
|
|
29
|
+
property: 'value',
|
|
30
|
+
comparator: condition.comparator,
|
|
31
|
+
value: condition.value,
|
|
32
|
+
type: condition.type
|
|
33
|
+
});
|
|
34
|
+
for (const matchedRecord of matchedRecords) {
|
|
35
|
+
for (const file of matchedRecord.record) {
|
|
36
|
+
dataSet[entity].push(await (0, _retrieveFile.retrieveFile)(`${entity}/${file}`));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const isIndexed = await (0, _getMatchingIndexes.getMatchingIndexes)(entity, property, recordData, condition, dataSet, indexed, retrieveMatchedFiles);
|
|
41
|
+
if (!isIndexed) {
|
|
42
|
+
reducedConditions.push(condition);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
parsed.conditions = reducedConditions;
|
|
46
|
+
return parsed;
|
|
47
|
+
};
|
|
48
48
|
exports.getConditionIndexedList = getConditionIndexedList;
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
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
|
-
var _fieldType = require("./fieldType");
|
|
14
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
-
const matchIndexedJoins = (entity, indexedClone, dataSets) => async (focusEntity, property, recordData, joinClause, filterJoins, indexed) => {
|
|
16
|
-
const {
|
|
17
|
-
entity: entityA,
|
|
18
|
-
property: propertyA
|
|
19
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyA);
|
|
20
|
-
const {
|
|
21
|
-
entity: entityB,
|
|
22
|
-
property: propertyB
|
|
23
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyB);
|
|
24
|
-
const properties = [{
|
|
25
|
-
entityFirst: entityA,
|
|
26
|
-
propertyFirst: propertyA,
|
|
27
|
-
entitySecond: entityB,
|
|
28
|
-
propertySecond: propertyB
|
|
29
|
-
}, {
|
|
30
|
-
entityFirst: entityB,
|
|
31
|
-
propertyFirst: propertyB,
|
|
32
|
-
entitySecond: entityA,
|
|
33
|
-
propertySecond: propertyA
|
|
34
|
-
}];
|
|
35
|
-
for (const checkProp of properties) {
|
|
36
|
-
if (!Object.prototype.hasOwnProperty.call(indexedClone, checkProp.entitySecond)) {
|
|
37
|
-
indexedClone[checkProp.entitySecond] = _siFunciona.default.cloneObject(indexed[checkProp.entitySecond]);
|
|
38
|
-
}
|
|
39
|
-
const matchedRecords = indexedClone[checkProp.entitySecond][checkProp.propertySecond].reduce((dataA, dataB) => _siFunciona.default.mergeArrays(dataA, (0, _where.where)(indexedClone[checkProp.entityFirst][checkProp.propertyFirst], {
|
|
40
|
-
property: 'value',
|
|
41
|
-
comparator: joinClause.comparator,
|
|
42
|
-
value: dataB.value,
|
|
43
|
-
type: (0, _fieldType.fieldType)(recordData[checkProp.entityFirst], checkProp.propertyFirst)
|
|
44
|
-
})), []);
|
|
45
|
-
const skipPush = checkProp.entityFirst === entity;
|
|
46
|
-
if (!Object.prototype.hasOwnProperty.call(dataSets, checkProp.entityFirst)) {
|
|
47
|
-
dataSets[checkProp.entityFirst] = [];
|
|
48
|
-
}
|
|
49
|
-
for (const matchedRecord of matchedRecords) {
|
|
50
|
-
for (const file of matchedRecord.record) {
|
|
51
|
-
let entityRecord = file;
|
|
52
|
-
if (typeof file === 'string') {
|
|
53
|
-
entityRecord = await (0, _retrieveFile.retrieveFile)(`${checkProp.entityFirst}/${file}`);
|
|
54
|
-
}
|
|
55
|
-
if (!skipPush) {
|
|
56
|
-
dataSets[checkProp.entityFirst].push(entityRecord);
|
|
57
|
-
}
|
|
58
|
-
filterJoins[checkProp.entityFirst].push(entityRecord);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
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
|
+
var _fieldType = require("./fieldType");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
const matchIndexedJoins = (entity, indexedClone, dataSets) => async (focusEntity, property, recordData, joinClause, filterJoins, indexed) => {
|
|
16
|
+
const {
|
|
17
|
+
entity: entityA,
|
|
18
|
+
property: propertyA
|
|
19
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyA);
|
|
20
|
+
const {
|
|
21
|
+
entity: entityB,
|
|
22
|
+
property: propertyB
|
|
23
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyB);
|
|
24
|
+
const properties = [{
|
|
25
|
+
entityFirst: entityA,
|
|
26
|
+
propertyFirst: propertyA,
|
|
27
|
+
entitySecond: entityB,
|
|
28
|
+
propertySecond: propertyB
|
|
29
|
+
}, {
|
|
30
|
+
entityFirst: entityB,
|
|
31
|
+
propertyFirst: propertyB,
|
|
32
|
+
entitySecond: entityA,
|
|
33
|
+
propertySecond: propertyA
|
|
34
|
+
}];
|
|
35
|
+
for (const checkProp of properties) {
|
|
36
|
+
if (!Object.prototype.hasOwnProperty.call(indexedClone, checkProp.entitySecond)) {
|
|
37
|
+
indexedClone[checkProp.entitySecond] = _siFunciona.default.cloneObject(indexed[checkProp.entitySecond]);
|
|
38
|
+
}
|
|
39
|
+
const matchedRecords = indexedClone[checkProp.entitySecond][checkProp.propertySecond].reduce((dataA, dataB) => _siFunciona.default.mergeArrays(dataA, (0, _where.where)(indexedClone[checkProp.entityFirst][checkProp.propertyFirst], {
|
|
40
|
+
property: 'value',
|
|
41
|
+
comparator: joinClause.comparator,
|
|
42
|
+
value: dataB.value,
|
|
43
|
+
type: (0, _fieldType.fieldType)(recordData[checkProp.entityFirst], checkProp.propertyFirst)
|
|
44
|
+
})), []);
|
|
45
|
+
const skipPush = checkProp.entityFirst === entity;
|
|
46
|
+
if (!Object.prototype.hasOwnProperty.call(dataSets, checkProp.entityFirst)) {
|
|
47
|
+
dataSets[checkProp.entityFirst] = [];
|
|
48
|
+
}
|
|
49
|
+
for (const matchedRecord of matchedRecords) {
|
|
50
|
+
for (const file of matchedRecord.record) {
|
|
51
|
+
let entityRecord = file;
|
|
52
|
+
if (typeof file === 'string') {
|
|
53
|
+
entityRecord = await (0, _retrieveFile.retrieveFile)(`${checkProp.entityFirst}/${file}`);
|
|
54
|
+
}
|
|
55
|
+
if (!skipPush) {
|
|
56
|
+
dataSets[checkProp.entityFirst].push(entityRecord);
|
|
57
|
+
}
|
|
58
|
+
filterJoins[checkProp.entityFirst].push(entityRecord);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
63
|
exports.matchIndexedJoins = matchIndexedJoins;
|
|
@@ -1,48 +1,48 @@
|
|
|
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
|
-
var _retrieveRecord = require("./retrieveRecord");
|
|
13
|
-
var _fieldType = require("./fieldType");
|
|
14
|
-
const mergeJoin = async (propertyA = '', propertyB = '', dataSets = {}) => {
|
|
15
|
-
const {
|
|
16
|
-
entity: entityA,
|
|
17
|
-
property: propA
|
|
18
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(propertyA);
|
|
19
|
-
const {
|
|
20
|
-
entity: entityB,
|
|
21
|
-
property: propB
|
|
22
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(propertyB);
|
|
23
|
-
dataSets = await (0, _readEntity.readEntity)(entityA, dataSets);
|
|
24
|
-
dataSets = await (0, _readEntity.readEntity)(entityB, dataSets);
|
|
25
|
-
const typeB = (0, _fieldType.fieldType)(await (0, _retrieveRecord.retrieveRecord)(entityB), propB);
|
|
26
|
-
dataSets[entityA] = dataSets[entityA].map(dataA => {
|
|
27
|
-
const matches = (0, _where.where)(dataSets[entityB], {
|
|
28
|
-
property: propB,
|
|
29
|
-
comparator: '=',
|
|
30
|
-
value: dataA[propA],
|
|
31
|
-
type: typeB
|
|
32
|
-
});
|
|
33
|
-
if (!matches.length) {
|
|
34
|
-
return dataA;
|
|
35
|
-
}
|
|
36
|
-
const mergeMatch = matches[0];
|
|
37
|
-
for (const prop in mergeMatch) {
|
|
38
|
-
if (prop === propB) {
|
|
39
|
-
// Skip the condition property since it is irrelevant
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
dataA[`${entityB}.${prop}`] = mergeMatch[prop];
|
|
43
|
-
}
|
|
44
|
-
return dataA;
|
|
45
|
-
});
|
|
46
|
-
return dataSets;
|
|
47
|
-
};
|
|
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
|
+
var _retrieveRecord = require("./retrieveRecord");
|
|
13
|
+
var _fieldType = require("./fieldType");
|
|
14
|
+
const mergeJoin = async (propertyA = '', propertyB = '', dataSets = {}) => {
|
|
15
|
+
const {
|
|
16
|
+
entity: entityA,
|
|
17
|
+
property: propA
|
|
18
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(propertyA);
|
|
19
|
+
const {
|
|
20
|
+
entity: entityB,
|
|
21
|
+
property: propB
|
|
22
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(propertyB);
|
|
23
|
+
dataSets = await (0, _readEntity.readEntity)(entityA, dataSets);
|
|
24
|
+
dataSets = await (0, _readEntity.readEntity)(entityB, dataSets);
|
|
25
|
+
const typeB = (0, _fieldType.fieldType)(await (0, _retrieveRecord.retrieveRecord)(entityB), propB);
|
|
26
|
+
dataSets[entityA] = dataSets[entityA].map(dataA => {
|
|
27
|
+
const matches = (0, _where.where)(dataSets[entityB], {
|
|
28
|
+
property: propB,
|
|
29
|
+
comparator: '=',
|
|
30
|
+
value: dataA[propA],
|
|
31
|
+
type: typeB
|
|
32
|
+
});
|
|
33
|
+
if (!matches.length) {
|
|
34
|
+
return dataA;
|
|
35
|
+
}
|
|
36
|
+
const mergeMatch = matches[0];
|
|
37
|
+
for (const prop in mergeMatch) {
|
|
38
|
+
if (prop === propB) {
|
|
39
|
+
// Skip the condition property since it is irrelevant
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
dataA[`${entityB}.${prop}`] = mergeMatch[prop];
|
|
43
|
+
}
|
|
44
|
+
return dataA;
|
|
45
|
+
});
|
|
46
|
+
return dataSets;
|
|
47
|
+
};
|
|
48
48
|
exports.mergeJoin = mergeJoin;
|
|
@@ -1,16 +1,20 @@
|
|
|
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
|
-
type?: string;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Extract condition clauses from the query
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
|
|
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
|
+
type?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Extract condition clauses from the query: `where <field> <comparator> <value>`, or `where <field> is null`,
|
|
12
|
+
* `is not null`, `exists` or `does not exist` (no value), each further one joined with `and where`. A comparison
|
|
13
|
+
* with the literal null (`= null`) is refused: it would never match, as null equals nothing (see where). `or where` is refused until or is built (TASKS: the where-clauses epic): it used to be read the same as
|
|
14
|
+
* `and where`, which silently returned the wrong rows.
|
|
15
|
+
* @param parsed
|
|
16
|
+
* @param query
|
|
17
|
+
* @throws {Error} For `or where`, and for a comparison with null.
|
|
18
|
+
*/
|
|
19
|
+
export declare const findConditions: (parsed: ParsedQuery, query: string) => string;
|
|
16
20
|
//# sourceMappingURL=findConditions.d.ts.map
|
|
@@ -4,24 +4,50 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.findConditions = void 0;
|
|
7
|
+
require("core-js/modules/es.array.includes.js");
|
|
7
8
|
var _removeFromQuery = require("./removeFromQuery");
|
|
8
9
|
var _parseLiteralValue = require("./parseLiteralValue");
|
|
9
|
-
|
|
10
|
+
var _maskStrings = require("./maskStrings");
|
|
11
|
+
// `and`/`or`/`where` count only as whole words: in `on t.x = u.color where ...` the `or` is part of the name `color`
|
|
12
|
+
const conditionMatch = new RegExp(`(^|[^a-z0-9._-])(?:(and|or)\\s+)?(where)\\s+([a-z0-9_-]+\\.?[a-z0-9_-]*)\\s+(?:(is\\s+not\\s+null|is\\s+null|exists|does\\s+not\\s+exist)(?![a-z0-9_.-])|(=|!=|>|<|>=|<=|in|between|like)\\s+(${_maskStrings.placeholderSource}|(${_parseLiteralValue.numberSource})|${_maskStrings.arraySource}|(null)|(true)|(false)))`, 'ig');
|
|
10
13
|
/**
|
|
11
|
-
* Extract condition clauses from the query
|
|
14
|
+
* Extract condition clauses from the query: `where <field> <comparator> <value>`, or `where <field> is null`,
|
|
15
|
+
* `is not null`, `exists` or `does not exist` (no value), each further one joined with `and where`. A comparison
|
|
16
|
+
* with the literal null (`= null`) is refused: it would never match, as null equals nothing (see where). `or where` is refused until or is built (TASKS: the where-clauses epic): it used to be read the same as
|
|
17
|
+
* `and where`, which silently returned the wrong rows.
|
|
12
18
|
* @param parsed
|
|
13
19
|
* @param query
|
|
20
|
+
* @throws {Error} For `or where`, and for a comparison with null.
|
|
14
21
|
*/
|
|
15
22
|
const findConditions = (parsed, query) => {
|
|
16
23
|
const conditionsFound = query.matchAll(conditionMatch);
|
|
17
24
|
// @ts-ignore
|
|
18
25
|
for (const condition of conditionsFound) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
if (typeof condition[2] !== 'undefined' && condition[2].toLowerCase() === 'or') {
|
|
27
|
+
throw new Error('`or where` is not supported yet: use `and where`, or run one query per alternative');
|
|
28
|
+
}
|
|
29
|
+
if (typeof condition[5] !== 'undefined') {
|
|
30
|
+
parsed['conditions'].push({
|
|
31
|
+
property: condition[4],
|
|
32
|
+
comparator: condition[5].toLowerCase().replace(/\s+/g, ' '),
|
|
33
|
+
value: null
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
const value = (0, _parseLiteralValue.parseLiteralValue)(condition, 8);
|
|
37
|
+
if (value === null) {
|
|
38
|
+
throw new Error(`\`${condition[4]} ${condition[6]} null\` never matches (null equals nothing, as in SQL): use \`${condition[4]} is null\` or \`${condition[4]} is not null\``);
|
|
39
|
+
}
|
|
40
|
+
if (condition[6].toLowerCase() === 'between' && Array.isArray(value) && value.includes(null)) {
|
|
41
|
+
throw new Error(`\`${condition[4]} between\` can't have a null bound: it would never match`);
|
|
42
|
+
}
|
|
43
|
+
parsed['conditions'].push({
|
|
44
|
+
property: condition[4],
|
|
45
|
+
comparator: condition[6],
|
|
46
|
+
value
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
// Leave out the character before the condition (group 1): it isn't part of it, and an earlier removal may have trimmed it
|
|
50
|
+
query = (0, _removeFromQuery.removeFromQuery)(condition[0].slice(condition[1].length), query);
|
|
25
51
|
}
|
|
26
52
|
return query;
|
|
27
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findConditions=void 0;var _removeFromQuery=require("./removeFromQuery"),_parseLiteralValue=require("./parseLiteralValue");const conditionMatch
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findConditions=void 0,require("core-js/modules/es.array.includes.js");var _removeFromQuery=require("./removeFromQuery"),_parseLiteralValue=require("./parseLiteralValue"),_maskStrings=require("./maskStrings");const conditionMatch=new RegExp(`(^|[^a-z0-9._-])(?:(and|or)\\s+)?(where)\\s+([a-z0-9_-]+\\.?[a-z0-9_-]*)\\s+(?:(is\\s+not\\s+null|is\\s+null|exists|does\\s+not\\s+exist)(?![a-z0-9_.-])|(=|!=|>|<|>=|<=|in|between|like)\\s+(${_maskStrings.placeholderSource}|(${_parseLiteralValue.numberSource})|${_maskStrings.arraySource}|(null)|(true)|(false)))`,"ig"),findConditions=(e,r)=>{const o=r.matchAll(conditionMatch);for(const n of o){if(void 0!==n[2]&&"or"===n[2].toLowerCase())throw new Error("`or where` is not supported yet: use `and where`, or run one query per alternative");if(void 0!==n[5])e.conditions.push({property:n[4],comparator:n[5].toLowerCase().replace(/\s+/g," "),value:null});else{const r=(0,_parseLiteralValue.parseLiteralValue)(n,8);if(null===r)throw new Error(`\`${n[4]} ${n[6]} null\` never matches (null equals nothing, as in SQL): use \`${n[4]} is null\` or \`${n[4]} is not null\``);if("between"===n[6].toLowerCase()&&Array.isArray(r)&&r.includes(null))throw new Error(`\`${n[4]} between\` can't have a null bound: it would never match`);e.conditions.push({property:n[4],comparator:n[6],value:r})}r=(0,_removeFromQuery.removeFromQuery)(n[0].slice(n[1].length),r)}return r};exports.findConditions=findConditions;
|
|
@@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.findInsertValues = void 0;
|
|
7
7
|
var _removeFromQuery = require("./removeFromQuery");
|
|
8
8
|
var _parseLiteralValue = require("./parseLiteralValue");
|
|
9
|
-
|
|
9
|
+
var _maskStrings = require("./maskStrings");
|
|
10
|
+
const literal = `(?:${_maskStrings.placeholderSource.replace('(', '(?:')}|${_parseLiteralValue.numberSource}|${_maskStrings.arraySource.replace('(', '(?:')}|null|true|false)`;
|
|
10
11
|
const valuesClauseMatch = new RegExp(`(values)\\s+([a-z0-9_-]+\\s*=\\s*${literal}(?:\\s*,\\s*[a-z0-9_-]+\\s*=\\s*${literal})*)`, 'i');
|
|
11
|
-
const assignmentMatch =
|
|
12
|
+
const assignmentMatch = new RegExp(`([a-z0-9_-]+)\\s*=\\s*(${_maskStrings.placeholderSource}|(${_parseLiteralValue.numberSource})|${_maskStrings.arraySource}|(null)|(true)|(false))`, 'ig');
|
|
12
13
|
/**
|
|
13
14
|
* Extract an insert's "values field = value, field2 = value2" clause from the query, the same way
|
|
14
15
|
* findUpdateValues() does for "set". insertEntity() accepts an array of rows for bulk inserts, but
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findInsertValues=void 0;var _removeFromQuery=require("./removeFromQuery"),_parseLiteralValue=require("./parseLiteralValue");const literal
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findInsertValues=void 0;var _removeFromQuery=require("./removeFromQuery"),_parseLiteralValue=require("./parseLiteralValue"),_maskStrings=require("./maskStrings");const literal=`(?:${_maskStrings.placeholderSource.replace("(","(?:")}|${_parseLiteralValue.numberSource}|${_maskStrings.arraySource.replace("(","(?:")}|null|true|false)`,valuesClauseMatch=new RegExp(`(values)\\s+([a-z0-9_-]+\\s*=\\s*${literal}(?:\\s*,\\s*[a-z0-9_-]+\\s*=\\s*${literal})*)`,"i"),assignmentMatch=new RegExp(`([a-z0-9_-]+)\\s*=\\s*(${_maskStrings.placeholderSource}|(${_parseLiteralValue.numberSource})|${_maskStrings.arraySource}|(null)|(true)|(false))`,"ig"),findInsertValues=(e,r)=>{const a=r.match(valuesClauseMatch);if(e.insertValues=[],!a)return r;const s={},l=a[2].matchAll(assignmentMatch);for(const e of l)s[e[1]]=(0,_parseLiteralValue.parseLiteralValue)(e,3);return e.insertValues=[s],(0,_removeFromQuery.removeFromQuery)(a[0],r)};exports.findInsertValues=findInsertValues;
|
|
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.findJoinEntity = void 0;
|
|
7
7
|
var _removeFromQuery = require("./removeFromQuery");
|
|
8
|
-
|
|
8
|
+
// Only straight after the entity (findCommand leaves `.joined ...`): a `.` later on is a number's (`1.5`) or a
|
|
9
|
+
// condition's `entity.field`, not the join
|
|
10
|
+
const joinEntityMatch = /^\.([a-z0-9_-]+)/i;
|
|
9
11
|
/**
|
|
10
12
|
* Extract the main join entity from the query.
|
|
11
13
|
* @param parsed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findJoinEntity=void 0;var _removeFromQuery=require("./removeFromQuery");const joinEntityMatch
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findJoinEntity=void 0;var _removeFromQuery=require("./removeFromQuery");const joinEntityMatch=/^\.([a-z0-9_-]+)/i,findJoinEntity=(t,e)=>{const i=e.match(joinEntityMatch);return i?(t.joinEntity=i?i[1]:void 0,(0,_removeFromQuery.removeFromQuery)(i[0],e)):e};exports.findJoinEntity=findJoinEntity;
|
|
@@ -5,8 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.findSelects = void 0;
|
|
7
7
|
var _removeFromQuery = require("./removeFromQuery");
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
// One field is a name, then optionally `as <alias>` (`as` as a whole word); fields are separated by commas. The first
|
|
9
|
+
// field used to accept an alias without `as`, so in `select name where a = 1` the word `where` became the alias.
|
|
10
|
+
const selectField = '[a-z0-9=._-]+(?:\\s+as\\s+[a-z0-9_-]+)?';
|
|
11
|
+
const selectClausesMatch = new RegExp(`select\\s+${selectField}(?:\\s*,\\s*${selectField})*`, 'i');
|
|
12
|
+
const selectClauseMatch = /(select)?\s*,?\s*([a-z0-9=._-]+)(?:\s+as\s+([a-z0-9_-]+))?/ig;
|
|
10
13
|
/**
|
|
11
14
|
* Extract select clauses from the query.
|
|
12
15
|
* @param parsed
|
|
@@ -20,7 +23,7 @@ const findSelects = (parsed, query) => {
|
|
|
20
23
|
for (const selectClause of selectClausesFound) {
|
|
21
24
|
parsed['selectClauses'].push({
|
|
22
25
|
property: selectClause[2],
|
|
23
|
-
alias: selectClause[
|
|
26
|
+
alias: selectClause[3]
|
|
24
27
|
});
|
|
25
28
|
}
|
|
26
29
|
return (0, _removeFromQuery.removeFromQuery)(selectsFound[0], query);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findSelects=void 0;var _removeFromQuery=require("./removeFromQuery");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findSelects=void 0;var _removeFromQuery=require("./removeFromQuery");const selectField="[a-z0-9=._-]+(?:\\s+as\\s+[a-z0-9_-]+)?",selectClausesMatch=new RegExp(`select\\s+${selectField}(?:\\s*,\\s*${selectField})*`,"i"),selectClauseMatch=/(select)?\s*,?\s*([a-z0-9=._-]+)(?:\s+as\s+([a-z0-9_-]+))?/gi,findSelects=(e,s)=>{const t=s.match(selectClausesMatch);if(t){const r=t[0].matchAll(selectClauseMatch);for(const s of r)e.selectClauses.push({property:s[2],alias:s[3]});return(0,_removeFromQuery.removeFromQuery)(t[0],s)}return s};exports.findSelects=findSelects;
|
|
@@ -5,8 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.findSortClauses = void 0;
|
|
7
7
|
var _removeFromQuery = require("./removeFromQuery");
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
// One rule is a field, then optionally asc or desc as a whole word. Rules are separated by commas, so the list ends
|
|
9
|
+
// at the first word that doesn't follow a comma: in `sort a limit 1`, `limit` starts the next clause.
|
|
10
|
+
const sortRule = '[a-z0-9._-]+(?:\\s+(?:asc|desc)(?![a-z0-9._-]))?';
|
|
11
|
+
const sortMatch = new RegExp(`sort\\s+${sortRule}(?:\\s*,\\s*${sortRule})*`, 'i');
|
|
12
|
+
const sortRuleMatch = /(sort)?\s*,?\s*([a-z0-9._-]+)(?:\s+(asc|desc)(?![a-z0-9._-]))?/ig;
|
|
10
13
|
/**
|
|
11
14
|
* Extract sort clauses from the query.
|
|
12
15
|
* @param parsed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findSortClauses=void 0;var _removeFromQuery=require("./removeFromQuery");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findSortClauses=void 0;var _removeFromQuery=require("./removeFromQuery");const sortRule="[a-z0-9._-]+(?:\\s+(?:asc|desc)(?![a-z0-9._-]))?",sortMatch=new RegExp(`sort\\s+${sortRule}(?:\\s*,\\s*${sortRule})*`,"i"),sortRuleMatch=/(sort)?\s*,?\s*([a-z0-9._-]+)(?:\s+(asc|desc)(?![a-z0-9._-]))?/gi,findSortClauses=(e,r)=>{const s=r.match(sortMatch);if(s){const o=s[0].matchAll(sortRuleMatch);for(const r of o)e.sortClauses.push({property:r[2],direction:r[3]||"asc"});return(0,_removeFromQuery.removeFromQuery)(s[0],r)}return r};exports.findSortClauses=findSortClauses;
|
|
@@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.findUpdateValues = void 0;
|
|
7
7
|
var _removeFromQuery = require("./removeFromQuery");
|
|
8
8
|
var _parseLiteralValue = require("./parseLiteralValue");
|
|
9
|
-
|
|
9
|
+
var _maskStrings = require("./maskStrings");
|
|
10
|
+
const literal = `(?:${_maskStrings.placeholderSource.replace('(', '(?:')}|${_parseLiteralValue.numberSource}|${_maskStrings.arraySource.replace('(', '(?:')}|null|true|false)`;
|
|
10
11
|
const setClauseMatch = new RegExp(`(set)\\s+([a-z0-9_-]+\\s*=\\s*${literal}(?:\\s*,\\s*[a-z0-9_-]+\\s*=\\s*${literal})*)`, 'i');
|
|
11
|
-
const assignmentMatch =
|
|
12
|
+
const assignmentMatch = new RegExp(`([a-z0-9_-]+)\\s*=\\s*(${_maskStrings.placeholderSource}|(${_parseLiteralValue.numberSource})|${_maskStrings.arraySource}|(null)|(true)|(false))`, 'ig');
|
|
12
13
|
/**
|
|
13
14
|
* Extract an update's "set field = value, field2 = value2" clause from the query. Uses a two-pass
|
|
14
15
|
* match, unlike the other parsers here: the set clause's own boundary is found first (so it can
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findUpdateValues=void 0;var _removeFromQuery=require("./removeFromQuery"),_parseLiteralValue=require("./parseLiteralValue");const literal
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findUpdateValues=void 0;var _removeFromQuery=require("./removeFromQuery"),_parseLiteralValue=require("./parseLiteralValue"),_maskStrings=require("./maskStrings");const literal=`(?:${_maskStrings.placeholderSource.replace("(","(?:")}|${_parseLiteralValue.numberSource}|${_maskStrings.arraySource.replace("(","(?:")}|null|true|false)`,setClauseMatch=new RegExp(`(set)\\s+([a-z0-9_-]+\\s*=\\s*${literal}(?:\\s*,\\s*[a-z0-9_-]+\\s*=\\s*${literal})*)`,"i"),assignmentMatch=new RegExp(`([a-z0-9_-]+)\\s*=\\s*(${_maskStrings.placeholderSource}|(${_parseLiteralValue.numberSource})|${_maskStrings.arraySource}|(null)|(true)|(false))`,"ig"),findUpdateValues=(e,r)=>{const a=r.match(setClauseMatch);if(e.updateValues={},!a)return r;const s=a[2].matchAll(assignmentMatch);for(const r of s)e.updateValues[r[1]]=(0,_parseLiteralValue.parseLiteralValue)(r,3);return(0,_removeFromQuery.removeFromQuery)(a[0],r)};exports.findUpdateValues=findUpdateValues;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regex source matching one placeholder from maskStrings, with the hex-encoded value as its only group. The
|
|
3
|
+
* find* parsers use it where they would otherwise match a quoted string.
|
|
4
|
+
*/
|
|
5
|
+
export declare const placeholderSource = "\\u0000([0-9a-f]*)\\u0000";
|
|
6
|
+
/**
|
|
7
|
+
* Regex source matching one placeholder from maskArrays, with the hex-encoded JSON of the array as its only group.
|
|
8
|
+
* The find* parsers use it where they would otherwise match `[...]`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const arraySource = "\\u0001([0-9a-f]*)\\u0001";
|
|
11
|
+
/**
|
|
12
|
+
* Turn the hex of a placeholder back into the string's value.
|
|
13
|
+
* @param hex
|
|
14
|
+
*/
|
|
15
|
+
export declare const fromPlaceholder: (hex: string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Replace every quoted string in a query with a placeholder holding its value (with the escapes applied), so that
|
|
18
|
+
* nothing inside a string (a keyword, a quote, `and`, a `]`) can be matched by the find* parsers.
|
|
19
|
+
* @param query
|
|
20
|
+
* @throws {Error} For an unclosed string, comment or bracket, or a NUL or SOH character outside a string (which
|
|
21
|
+
* could otherwise pass for a placeholder).
|
|
22
|
+
*/
|
|
23
|
+
export declare const maskStrings: (query: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Put every placeholder back the way it would be written in a query: strings quoted, arrays as JSON. For error
|
|
26
|
+
* messages, and for reading an array's text as JSON.
|
|
27
|
+
* @param text
|
|
28
|
+
* @param quote - wrap strings with JSON's double quotes (the default) or with single quotes
|
|
29
|
+
*/
|
|
30
|
+
export declare const unmaskStrings: (text: string, quote?: "json" | "'") => string;
|
|
31
|
+
/**
|
|
32
|
+
* Replace every array (outermost brackets only, so a nested array stays inside its parent) with a placeholder holding
|
|
33
|
+
* its JSON, so that the find* parsers never have to find where an array ends, and nothing inside one (a `.`, a `]`,
|
|
34
|
+
* a keyword) can be matched by them. Run it on the output of maskStrings, where no `[` or `]` is inside a string.
|
|
35
|
+
* @param masked
|
|
36
|
+
* @throws {Error} For an array which is not valid JSON once its strings are put back.
|
|
37
|
+
*/
|
|
38
|
+
export declare const maskArrays: (masked: string) => string;
|
|
39
|
+
//# sourceMappingURL=maskStrings.d.ts.map
|