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,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.isEntityProperty = void 0
|
|
7
|
-
const isEntityProperty = property => /^[a-z0-9_-]+\.([a-z0-9_-]+)$/i.test(property)
|
|
8
|
-
exports.isEntityProperty = isEntityProperty
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isEntityProperty = void 0;
|
|
7
|
+
const isEntityProperty = property => /^[a-z0-9_-]+\.([a-z0-9_-]+)$/i.test(property);
|
|
8
|
+
exports.isEntityProperty = isEntityProperty;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export type LiteralValue = string | number | boolean | null | any[];
|
|
2
|
-
/**
|
|
3
|
-
* Several parsers (findConditions, findInsertValues, findUpdateValues) capture a query-string
|
|
4
|
-
* literal into one of six consecutive alternation groups depending on its shape - quoted string,
|
|
5
|
-
* number, array, null, true, false - since a single regex can't otherwise tell them apart. Given
|
|
6
|
-
* the match and the index of the first of those six groups (which shifts depending on how many
|
|
7
|
-
* groups come before it in the parent regex), return the literal with its real JS type.
|
|
8
|
-
* @param match
|
|
9
|
-
* @param baseIndex
|
|
10
|
-
*/
|
|
11
|
-
export declare const parseLiteralValue: (match: RegExpMatchArray, baseIndex: number) => LiteralValue;
|
|
1
|
+
export type LiteralValue = string | number | boolean | null | any[];
|
|
2
|
+
/**
|
|
3
|
+
* Several parsers (findConditions, findInsertValues, findUpdateValues) capture a query-string
|
|
4
|
+
* literal into one of six consecutive alternation groups depending on its shape - quoted string,
|
|
5
|
+
* number, array, null, true, false - since a single regex can't otherwise tell them apart. Given
|
|
6
|
+
* the match and the index of the first of those six groups (which shifts depending on how many
|
|
7
|
+
* groups come before it in the parent regex), return the literal with its real JS type.
|
|
8
|
+
* @param match
|
|
9
|
+
* @param baseIndex
|
|
10
|
+
*/
|
|
11
|
+
export declare const parseLiteralValue: (match: RegExpMatchArray, baseIndex: number) => LiteralValue;
|
|
12
12
|
//# sourceMappingURL=parseLiteralValue.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.parseLiteralValue = void 0
|
|
5
|
+
});
|
|
6
|
+
exports.parseLiteralValue = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Several parsers (findConditions, findInsertValues, findUpdateValues) capture a query-string
|
|
9
9
|
* literal into one of six consecutive alternation groups depending on its shape - quoted string,
|
|
@@ -15,20 +15,20 @@ exports.parseLiteralValue = void 0
|
|
|
15
15
|
*/
|
|
16
16
|
const parseLiteralValue = (match, baseIndex) => {
|
|
17
17
|
if (typeof match[baseIndex] !== 'undefined') {
|
|
18
|
-
return match[baseIndex]
|
|
18
|
+
return match[baseIndex];
|
|
19
19
|
}
|
|
20
20
|
if (typeof match[baseIndex + 1] !== 'undefined') {
|
|
21
|
-
return Number(match[baseIndex + 1])
|
|
21
|
+
return Number(match[baseIndex + 1]);
|
|
22
22
|
}
|
|
23
23
|
if (typeof match[baseIndex + 2] !== 'undefined') {
|
|
24
|
-
return JSON.parse(match[baseIndex + 2])
|
|
24
|
+
return JSON.parse(match[baseIndex + 2]);
|
|
25
25
|
}
|
|
26
26
|
if (typeof match[baseIndex + 3] !== 'undefined') {
|
|
27
|
-
return null
|
|
27
|
+
return null;
|
|
28
28
|
}
|
|
29
29
|
if (typeof match[baseIndex + 4] !== 'undefined') {
|
|
30
|
-
return true
|
|
30
|
+
return true;
|
|
31
31
|
}
|
|
32
|
-
return false
|
|
33
|
-
}
|
|
34
|
-
exports.parseLiteralValue = parseLiteralValue
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
exports.parseLiteralValue = parseLiteralValue;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { ParsedCommand, ParsedEntity } from './findCommand';
|
|
2
|
-
import { ParsedInsertRow } from './findInsertValues';
|
|
3
|
-
import { ParsedUpdateValues } from './findUpdateValues';
|
|
4
|
-
import { ParsedJoinEntity } from './findJoinEntity';
|
|
5
|
-
import { ParsedSelect } from './findSelects';
|
|
6
|
-
import { ParsedCondition } from './findConditions';
|
|
7
|
-
import { ParsedJoinClause } from './findJoinClauses';
|
|
8
|
-
import { ParsedMergeJoin } from './findMergeJoins';
|
|
9
|
-
import { ParsedSortClause } from './findSortClauses';
|
|
10
|
-
import { ParsedGroupBy } from './findGroupBy';
|
|
11
|
-
import { ParsedLimit } from './findLimit';
|
|
12
|
-
import { ParsedOffset } from './findOffset';
|
|
13
|
-
export type ParsedQuery = {
|
|
14
|
-
command: ParsedCommand | undefined;
|
|
15
|
-
entity: ParsedEntity | undefined;
|
|
16
|
-
joinEntity: ParsedJoinEntity | undefined;
|
|
17
|
-
selectClauses: ParsedSelect[];
|
|
18
|
-
insertValues: ParsedInsertRow[];
|
|
19
|
-
updateValues: ParsedUpdateValues;
|
|
20
|
-
conditions: ParsedCondition[];
|
|
21
|
-
joinClauses: ParsedJoinClause[];
|
|
22
|
-
mergeJoins: ParsedMergeJoin[];
|
|
23
|
-
sortClauses: ParsedSortClause[];
|
|
24
|
-
groupBy: ParsedGroupBy | undefined;
|
|
25
|
-
limit: ParsedLimit | undefined;
|
|
26
|
-
offset: ParsedOffset | undefined;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Break a query down into its components.
|
|
30
|
-
* @param query
|
|
31
|
-
*/
|
|
32
|
-
export declare const parseQuery: (query: string) => ParsedQuery;
|
|
1
|
+
import { ParsedCommand, ParsedEntity } from './findCommand';
|
|
2
|
+
import { ParsedInsertRow } from './findInsertValues';
|
|
3
|
+
import { ParsedUpdateValues } from './findUpdateValues';
|
|
4
|
+
import { ParsedJoinEntity } from './findJoinEntity';
|
|
5
|
+
import { ParsedSelect } from './findSelects';
|
|
6
|
+
import { ParsedCondition } from './findConditions';
|
|
7
|
+
import { ParsedJoinClause } from './findJoinClauses';
|
|
8
|
+
import { ParsedMergeJoin } from './findMergeJoins';
|
|
9
|
+
import { ParsedSortClause } from './findSortClauses';
|
|
10
|
+
import { ParsedGroupBy } from './findGroupBy';
|
|
11
|
+
import { ParsedLimit } from './findLimit';
|
|
12
|
+
import { ParsedOffset } from './findOffset';
|
|
13
|
+
export type ParsedQuery = {
|
|
14
|
+
command: ParsedCommand | undefined;
|
|
15
|
+
entity: ParsedEntity | undefined;
|
|
16
|
+
joinEntity: ParsedJoinEntity | undefined;
|
|
17
|
+
selectClauses: ParsedSelect[];
|
|
18
|
+
insertValues: ParsedInsertRow[];
|
|
19
|
+
updateValues: ParsedUpdateValues;
|
|
20
|
+
conditions: ParsedCondition[];
|
|
21
|
+
joinClauses: ParsedJoinClause[];
|
|
22
|
+
mergeJoins: ParsedMergeJoin[];
|
|
23
|
+
sortClauses: ParsedSortClause[];
|
|
24
|
+
groupBy: ParsedGroupBy | undefined;
|
|
25
|
+
limit: ParsedLimit | undefined;
|
|
26
|
+
offset: ParsedOffset | undefined;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Break a query down into its components.
|
|
30
|
+
* @param query
|
|
31
|
+
*/
|
|
32
|
+
export declare const parseQuery: (query: string) => ParsedQuery;
|
|
33
33
|
//# sourceMappingURL=parseQuery.d.ts.map
|
|
@@ -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.parseQuery = void 0
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault
|
|
5
|
+
});
|
|
6
|
+
exports.parseQuery = void 0;
|
|
7
|
+
var _siFunciona = _interopRequireDefault(require("si-funciona"));
|
|
8
|
+
var _findCommand = require("./findCommand");
|
|
9
|
+
var _findInsertValues = require("./findInsertValues");
|
|
10
|
+
var _findUpdateValues = require("./findUpdateValues");
|
|
11
|
+
var _findJoinEntity = require("./findJoinEntity");
|
|
12
|
+
var _findSelects = require("./findSelects");
|
|
13
|
+
var _findConditions = require("./findConditions");
|
|
14
|
+
var _findJoinClauses = require("./findJoinClauses");
|
|
15
|
+
var _findMergeJoins = require("./findMergeJoins");
|
|
16
|
+
var _findSortClauses = require("./findSortClauses");
|
|
17
|
+
var _findGroupBy = require("./findGroupBy");
|
|
18
|
+
var _findLimit = require("./findLimit");
|
|
19
|
+
var _findOffset = require("./findOffset");
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
21
|
/**
|
|
22
22
|
* Break a query down into its components.
|
|
23
23
|
* @param query
|
|
@@ -37,15 +37,15 @@ const parseQuery = query => {
|
|
|
37
37
|
groupBy: undefined,
|
|
38
38
|
limit: undefined,
|
|
39
39
|
offset: undefined
|
|
40
|
-
}
|
|
40
|
+
};
|
|
41
41
|
const {
|
|
42
42
|
curry,
|
|
43
43
|
pipe
|
|
44
|
-
} = _siFunciona.default
|
|
45
|
-
query = pipe(curry(_findCommand.findCommand)(parsedQuery), curry(_findInsertValues.findInsertValues)(parsedQuery), curry(_findUpdateValues.findUpdateValues)(parsedQuery), curry(_findJoinEntity.findJoinEntity)(parsedQuery), curry(_findSelects.findSelects)(parsedQuery), curry(_findConditions.findConditions)(parsedQuery), curry(_findJoinClauses.findJoinClauses)(parsedQuery), curry(_findMergeJoins.findMergeJoins)(parsedQuery), curry(_findSortClauses.findSortClauses)(parsedQuery), curry(_findGroupBy.findGroupBy)(parsedQuery), curry(_findLimit.findLimit)(parsedQuery), curry(_findOffset.findOffset)(parsedQuery))(query)
|
|
44
|
+
} = _siFunciona.default;
|
|
45
|
+
query = pipe(curry(_findCommand.findCommand)(parsedQuery), curry(_findInsertValues.findInsertValues)(parsedQuery), curry(_findUpdateValues.findUpdateValues)(parsedQuery), curry(_findJoinEntity.findJoinEntity)(parsedQuery), curry(_findSelects.findSelects)(parsedQuery), curry(_findConditions.findConditions)(parsedQuery), curry(_findJoinClauses.findJoinClauses)(parsedQuery), curry(_findMergeJoins.findMergeJoins)(parsedQuery), curry(_findSortClauses.findSortClauses)(parsedQuery), curry(_findGroupBy.findGroupBy)(parsedQuery), curry(_findLimit.findLimit)(parsedQuery), curry(_findOffset.findOffset)(parsedQuery))(query);
|
|
46
46
|
if (query) {
|
|
47
|
-
throw new Error(`Unrecognized query value: ${query}`)
|
|
47
|
+
throw new Error(`Unrecognized query value: ${query}`);
|
|
48
48
|
}
|
|
49
|
-
return parsedQuery
|
|
50
|
-
}
|
|
51
|
-
exports.parseQuery = parseQuery
|
|
49
|
+
return parsedQuery;
|
|
50
|
+
};
|
|
51
|
+
exports.parseQuery = parseQuery;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseQuery=void 0;var _siFunciona=_interopRequireDefault(require("si-funciona")),_findCommand=require("./findCommand"),_findInsertValues=require("./findInsertValues"),_findUpdateValues=require("./findUpdateValues"),_findJoinEntity=require("./findJoinEntity"),_findSelects=require("./findSelects"),_findConditions=require("./findConditions"),_findJoinClauses=require("./findJoinClauses"),_findMergeJoins=require("./findMergeJoins"),_findSortClauses=require("./findSortClauses"),_findGroupBy=require("./findGroupBy"),_findLimit=require("./findLimit"),_findOffset=require("./findOffset");function _interopRequireDefault(i){return i&&i.__esModule?i:{default:i}}const parseQuery=i=>{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseQuery=void 0;var _siFunciona=_interopRequireDefault(require("si-funciona")),_findCommand=require("./findCommand"),_findInsertValues=require("./findInsertValues"),_findUpdateValues=require("./findUpdateValues"),_findJoinEntity=require("./findJoinEntity"),_findSelects=require("./findSelects"),_findConditions=require("./findConditions"),_findJoinClauses=require("./findJoinClauses"),_findMergeJoins=require("./findMergeJoins"),_findSortClauses=require("./findSortClauses"),_findGroupBy=require("./findGroupBy"),_findLimit=require("./findLimit"),_findOffset=require("./findOffset");function _interopRequireDefault(i){return i&&i.__esModule?i:{default:i}}const parseQuery=i=>{const e={command:void 0,entity:void 0,joinEntity:void 0,selectClauses:[],insertValues:[],updateValues:{},conditions:[],joinClauses:[],mergeJoins:[],sortClauses:[],groupBy:void 0,limit:void 0,offset:void 0},{curry:n,pipe:r}=_siFunciona.default;if(i=r(n(_findCommand.findCommand)(e),n(_findInsertValues.findInsertValues)(e),n(_findUpdateValues.findUpdateValues)(e),n(_findJoinEntity.findJoinEntity)(e),n(_findSelects.findSelects)(e),n(_findConditions.findConditions)(e),n(_findJoinClauses.findJoinClauses)(e),n(_findMergeJoins.findMergeJoins)(e),n(_findSortClauses.findSortClauses)(e),n(_findGroupBy.findGroupBy)(e),n(_findLimit.findLimit)(e),n(_findOffset.findOffset)(e))(i))throw new Error(`Unrecognized query value: ${i}`);return e};exports.parseQuery=parseQuery;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.removeFromQuery = void 0
|
|
7
|
-
const removeFromQuery = (substring, query) => query.replace(substring, '').trim()
|
|
8
|
-
exports.removeFromQuery = removeFromQuery
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.removeFromQuery = void 0;
|
|
7
|
+
const removeFromQuery = (substring, query) => query.replace(substring, '').trim();
|
|
8
|
+
exports.removeFromQuery = removeFromQuery;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.splitEntityProperty = void 0
|
|
7
|
-
const entityMatch = /^[a-z0-9_-]+/i
|
|
8
|
-
const propertyMatch = /\.([a-z0-9_-]+)$/i
|
|
9
|
-
const splitEntityProperty = entityProp => {
|
|
10
|
-
const entityFound = entityProp.match(entityMatch)
|
|
11
|
-
if (!entityFound) {
|
|
12
|
-
throw new Error(`Unable to use property: ${entityProp}`)
|
|
13
|
-
}
|
|
14
|
-
const propFound = entityProp.match(propertyMatch)
|
|
15
|
-
if (!propFound) {
|
|
16
|
-
throw new Error(`Unable to use property: ${entityProp}`)
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
entity: entityFound[0],
|
|
20
|
-
property: propFound[1]
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.splitEntityProperty = splitEntityProperty
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.splitEntityProperty = void 0;
|
|
7
|
+
const entityMatch = /^[a-z0-9_-]+/i;
|
|
8
|
+
const propertyMatch = /\.([a-z0-9_-]+)$/i;
|
|
9
|
+
const splitEntityProperty = entityProp => {
|
|
10
|
+
const entityFound = entityProp.match(entityMatch);
|
|
11
|
+
if (!entityFound) {
|
|
12
|
+
throw new Error(`Unable to use property: ${entityProp}`);
|
|
13
|
+
}
|
|
14
|
+
const propFound = entityProp.match(propertyMatch);
|
|
15
|
+
if (!propFound) {
|
|
16
|
+
throw new Error(`Unable to use property: ${entityProp}`);
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
entity: entityFound[0],
|
|
20
|
+
property: propFound[1]
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
exports.splitEntityProperty = splitEntityProperty;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.splitQueries = void 0
|
|
7
|
-
require(
|
|
8
|
-
require(
|
|
9
|
-
const queryMatch = /\s*(?=(?:delete|insert|read|update)\s+[a-z0-9._-]+)\s*/i
|
|
10
|
-
const splitQueries = (queries = '') => queries.split(queryMatch).filter(query => query.length > 0)
|
|
11
|
-
exports.splitQueries = splitQueries
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.splitQueries = void 0;
|
|
7
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
9
|
+
const queryMatch = /\s*(?=(?:delete|insert|read|update)\s+[a-z0-9._-]+)\s*/i;
|
|
10
|
+
const splitQueries = (queries = '') => queries.split(queryMatch).filter(query => query.length > 0);
|
|
11
|
+
exports.splitQueries = splitQueries;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.reconcileJoin = void 0
|
|
7
|
-
require(
|
|
8
|
-
require(
|
|
9
|
-
|
|
5
|
+
});
|
|
6
|
+
exports.reconcileJoin = void 0;
|
|
7
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
9
|
+
var _where = require("../queries/where");
|
|
10
10
|
const reconcileJoin = (dataSet, entityName, entityKey, joinEntity, joinProp) => {
|
|
11
|
-
const entity = dataSet[entityName][entityKey]
|
|
11
|
+
const entity = dataSet[entityName][entityKey];
|
|
12
12
|
if (Object.prototype.hasOwnProperty.call(entity, joinEntity) && Array.isArray(entity[joinEntity])) {
|
|
13
13
|
entity[joinEntity].forEach((mergedEntity, k) => {
|
|
14
14
|
const matchedEntity = (0, _where.where)(dataSet[joinEntity], {
|
|
15
15
|
property: joinProp,
|
|
16
16
|
comparator: '=',
|
|
17
17
|
value: mergedEntity[joinProp]
|
|
18
|
-
})
|
|
18
|
+
});
|
|
19
19
|
if (matchedEntity.length) {
|
|
20
|
-
dataSet[entityName][entityKey][joinEntity][k] = matchedEntity[0]
|
|
20
|
+
dataSet[entityName][entityKey][joinEntity][k] = matchedEntity[0];
|
|
21
21
|
}
|
|
22
|
-
})
|
|
22
|
+
});
|
|
23
23
|
}
|
|
24
|
-
return dataSet
|
|
25
|
-
}
|
|
26
|
-
exports.reconcileJoin = reconcileJoin
|
|
24
|
+
return dataSet;
|
|
25
|
+
};
|
|
26
|
+
exports.reconcileJoin = reconcileJoin;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.reconcileJoins = void 0
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
});
|
|
6
|
+
exports.reconcileJoins = void 0;
|
|
7
|
+
var _splitEntityProperty = require("./parsers/splitEntityProperty");
|
|
8
|
+
var _reconcileJoin = require("./reconcileJoin");
|
|
9
9
|
const reconcileJoins = (propertyA, propertyB, dataSet) => {
|
|
10
10
|
const {
|
|
11
11
|
entity: entityA,
|
|
12
12
|
property: propA
|
|
13
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(propertyA)
|
|
13
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(propertyA);
|
|
14
14
|
const {
|
|
15
15
|
entity: entityB,
|
|
16
16
|
property: propB
|
|
17
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(propertyB)
|
|
17
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(propertyB);
|
|
18
18
|
for (const entityName in dataSet) {
|
|
19
19
|
for (const entityKey in dataSet[entityName]) {
|
|
20
|
-
dataSet = (0, _reconcileJoin.reconcileJoin)(dataSet, entityName, entityKey, entityA, propA)
|
|
21
|
-
dataSet = (0, _reconcileJoin.reconcileJoin)(dataSet, entityName, entityKey, entityB, propB)
|
|
20
|
+
dataSet = (0, _reconcileJoin.reconcileJoin)(dataSet, entityName, entityKey, entityA, propA);
|
|
21
|
+
dataSet = (0, _reconcileJoin.reconcileJoin)(dataSet, entityName, entityKey, entityB, propB);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
return dataSet
|
|
25
|
-
}
|
|
26
|
-
exports.reconcileJoins = reconcileJoins
|
|
24
|
+
return dataSet;
|
|
25
|
+
};
|
|
26
|
+
exports.reconcileJoins = reconcileJoins;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.reconcileJoins=void 0;var _splitEntityProperty=require("./parsers/splitEntityProperty"),_reconcileJoin=require("./reconcileJoin");const reconcileJoins=(e,r,t)=>{const{entity:i,property:o}=(0,_splitEntityProperty.splitEntityProperty)(e),{entity:n,property:c}=(0,_splitEntityProperty.splitEntityProperty)(r);for(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.reconcileJoins=void 0;var _splitEntityProperty=require("./parsers/splitEntityProperty"),_reconcileJoin=require("./reconcileJoin");const reconcileJoins=(e,r,t)=>{const{entity:i,property:o}=(0,_splitEntityProperty.splitEntityProperty)(e),{entity:n,property:c}=(0,_splitEntityProperty.splitEntityProperty)(r);for(const e in t)for(const r in t[e])t=(0,_reconcileJoin.reconcileJoin)(t,e,r,i,o),t=(0,_reconcileJoin.reconcileJoin)(t,e,r,n,c);return t};exports.reconcileJoins=reconcileJoins;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { recordDefinition } from '../introspect/definitions/record';
|
|
2
|
-
/**
|
|
3
|
-
* Add a record's filename to the __RECORDS registry, creating the registry file the first time
|
|
4
|
-
* a record is created if it doesn't already exist.
|
|
5
|
-
* @param recordName
|
|
6
|
-
*/
|
|
7
|
-
export declare const registerRecord: (recordName: string) => Promise<recordDefinition>;
|
|
1
|
+
import { recordDefinition } from '../introspect/definitions/record';
|
|
2
|
+
/**
|
|
3
|
+
* Add a record's filename to the __RECORDS registry, creating the registry file the first time
|
|
4
|
+
* a record is created if it doesn't already exist.
|
|
5
|
+
* @param recordName
|
|
6
|
+
*/
|
|
7
|
+
export declare const registerRecord: (recordName: string) => Promise<recordDefinition>;
|
|
8
8
|
//# sourceMappingURL=registerRecord.d.ts.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.registerRecord = void 0
|
|
7
|
-
require(
|
|
8
|
-
require(
|
|
9
|
-
|
|
5
|
+
});
|
|
6
|
+
exports.registerRecord = void 0;
|
|
7
|
+
require("core-js/modules/es.array.includes.js");
|
|
8
|
+
require("core-js/modules/es.json.stringify.js");
|
|
9
|
+
var _config = require("./config");
|
|
10
10
|
const {
|
|
11
11
|
readFile,
|
|
12
12
|
writeFile
|
|
13
|
-
} = require('fs/promises')
|
|
13
|
+
} = require('fs/promises');
|
|
14
14
|
/**
|
|
15
15
|
* __RECORDS is itself an ordinary record - path/definition/keys/entries - whose entries are the
|
|
16
16
|
* filenames of every other record that has been created. This is the schema it's given the first
|
|
@@ -42,26 +42,26 @@ const defaultRegistry = () => ({
|
|
|
42
42
|
}],
|
|
43
43
|
keys: [],
|
|
44
44
|
entries: []
|
|
45
|
-
})
|
|
45
|
+
});
|
|
46
46
|
/**
|
|
47
47
|
* Add a record's filename to the __RECORDS registry, creating the registry file the first time
|
|
48
48
|
* a record is created if it doesn't already exist.
|
|
49
49
|
* @param recordName
|
|
50
50
|
*/
|
|
51
51
|
const registerRecord = async recordName => {
|
|
52
|
-
const databasePath = (0, _config.getSetting)('databasePath', 'database/')
|
|
53
|
-
const registryPath = `${databasePath}__RECORDS.json
|
|
54
|
-
let registry
|
|
52
|
+
const databasePath = (0, _config.getSetting)('databasePath', 'database/');
|
|
53
|
+
const registryPath = `${databasePath}__RECORDS.json`;
|
|
54
|
+
let registry;
|
|
55
55
|
try {
|
|
56
|
-
registry = JSON.parse(await readFile(registryPath, 'utf8'))
|
|
56
|
+
registry = JSON.parse(await readFile(registryPath, 'utf8'));
|
|
57
57
|
} catch (err) {
|
|
58
|
-
registry = defaultRegistry()
|
|
58
|
+
registry = defaultRegistry();
|
|
59
59
|
}
|
|
60
|
-
const fileName = `${recordName}.json
|
|
60
|
+
const fileName = `${recordName}.json`;
|
|
61
61
|
if (!registry.entries.includes(fileName)) {
|
|
62
|
-
registry.entries.push(fileName)
|
|
62
|
+
registry.entries.push(fileName);
|
|
63
63
|
}
|
|
64
|
-
await writeFile(registryPath, JSON.stringify(registry, null, 2))
|
|
65
|
-
return registry
|
|
66
|
-
}
|
|
67
|
-
exports.registerRecord = registerRecord
|
|
64
|
+
await writeFile(registryPath, JSON.stringify(registry, null, 2));
|
|
65
|
+
return registry;
|
|
66
|
+
};
|
|
67
|
+
exports.registerRecord = registerRecord;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { keyDefinition } from '../introspect/definitions/key';
|
|
2
|
-
import { recordPath } from '../introspect/definitions/record';
|
|
3
|
-
import { indexEntry } from './updateIndex';
|
|
4
|
-
/**
|
|
5
|
-
* Remove a single entry file from the index that backs one of a record's keys, dropping a value
|
|
6
|
-
* entirely once its last file is removed. A key with no lookup, or an index file that doesn't
|
|
7
|
-
* exist yet, is left untouched.
|
|
8
|
-
* @param path
|
|
9
|
-
* @param key
|
|
10
|
-
* @param value
|
|
11
|
-
* @param fileName
|
|
12
|
-
*/
|
|
13
|
-
export declare const removeFromIndex: (path?: recordPath, key?: keyDefinition, value?: any, fileName?: string) => Promise<indexEntry[] | null>;
|
|
1
|
+
import { keyDefinition } from '../introspect/definitions/key';
|
|
2
|
+
import { recordPath } from '../introspect/definitions/record';
|
|
3
|
+
import { indexEntry } from './updateIndex';
|
|
4
|
+
/**
|
|
5
|
+
* Remove a single entry file from the index that backs one of a record's keys, dropping a value
|
|
6
|
+
* entirely once its last file is removed. A key with no lookup, or an index file that doesn't
|
|
7
|
+
* exist yet, is left untouched.
|
|
8
|
+
* @param path
|
|
9
|
+
* @param key
|
|
10
|
+
* @param value
|
|
11
|
+
* @param fileName
|
|
12
|
+
*/
|
|
13
|
+
export declare const removeFromIndex: (path?: recordPath, key?: keyDefinition, value?: any, fileName?: string) => Promise<indexEntry[] | null>;
|
|
14
14
|
//# sourceMappingURL=removeFromIndex.d.ts.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.removeFromIndex = void 0
|
|
7
|
-
require(
|
|
8
|
-
require(
|
|
9
|
-
require(
|
|
10
|
-
require(
|
|
11
|
-
|
|
5
|
+
});
|
|
6
|
+
exports.removeFromIndex = void 0;
|
|
7
|
+
require("core-js/modules/es.json.stringify.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
9
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
10
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
11
|
+
var _config = require("./config");
|
|
12
12
|
const {
|
|
13
13
|
readFile,
|
|
14
14
|
writeFile
|
|
15
|
-
} = require('fs/promises')
|
|
15
|
+
} = require('fs/promises');
|
|
16
16
|
/**
|
|
17
17
|
* Remove a single entry file from the index that backs one of a record's keys, dropping a value
|
|
18
18
|
* entirely once its last file is removed. A key with no lookup, or an index file that doesn't
|
|
@@ -24,23 +24,21 @@ const {
|
|
|
24
24
|
*/
|
|
25
25
|
const removeFromIndex = async (path = '', key = null, value = undefined, fileName = '') => {
|
|
26
26
|
if (!key || !key.lookup) {
|
|
27
|
-
return null
|
|
27
|
+
return null;
|
|
28
28
|
}
|
|
29
|
-
const databasePath = (0, _config.getSetting)('databasePath', 'database/')
|
|
30
|
-
const indexPath = `${databasePath}__indexes/${path}/${key.lookup}
|
|
31
|
-
let index = []
|
|
29
|
+
const databasePath = (0, _config.getSetting)('databasePath', 'database/');
|
|
30
|
+
const indexPath = `${databasePath}__indexes/${path}/${key.lookup}`;
|
|
31
|
+
let index = [];
|
|
32
32
|
try {
|
|
33
|
-
index = JSON.parse(await readFile(indexPath, 'utf8'))
|
|
33
|
+
index = JSON.parse(await readFile(indexPath, 'utf8'));
|
|
34
34
|
} catch (err) {
|
|
35
|
-
return null
|
|
35
|
+
return null;
|
|
36
36
|
}
|
|
37
|
-
index = index.map(entry => entry.value == value
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
exports.removeFromIndex = removeFromIndex
|
|
37
|
+
index = index.map(entry => entry.value == value ? {
|
|
38
|
+
value: entry.value,
|
|
39
|
+
record: entry.record.filter(record => record !== fileName)
|
|
40
|
+
} : entry).filter(entry => entry.record.length);
|
|
41
|
+
await writeFile(indexPath, JSON.stringify(index, null, 2));
|
|
42
|
+
return index;
|
|
43
|
+
};
|
|
44
|
+
exports.removeFromIndex = removeFromIndex;
|