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,45 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.restrictIndexedList = void 0
|
|
7
|
-
|
|
8
|
-
const restrictIndexedList = (joinClause, filterJoins, indexedClone) => {
|
|
9
|
-
const {
|
|
10
|
-
entity: entityA,
|
|
11
|
-
property: propertyA
|
|
12
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyA)
|
|
13
|
-
const {
|
|
14
|
-
entity: entityB,
|
|
15
|
-
property: propertyB
|
|
16
|
-
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyB)
|
|
17
|
-
if (Object.prototype.hasOwnProperty.call(filterJoins, entityA)) {
|
|
18
|
-
const existingEntities = filterJoins[entityA]
|
|
19
|
-
if (!Object.prototype.hasOwnProperty.call(indexedClone, entityA)) {
|
|
20
|
-
indexedClone[entityA] = {}
|
|
21
|
-
}
|
|
22
|
-
if (!Object.prototype.hasOwnProperty.call(indexedClone[entityA], propertyA)) {
|
|
23
|
-
indexedClone[entityA][propertyA] = {}
|
|
24
|
-
}
|
|
25
|
-
indexedClone[entityA][propertyA] = [{
|
|
26
|
-
value: existingEntities[0][propertyA],
|
|
27
|
-
record: existingEntities
|
|
28
|
-
}]
|
|
29
|
-
}
|
|
30
|
-
if (Object.prototype.hasOwnProperty.call(filterJoins, entityB)) {
|
|
31
|
-
const existingEntities = filterJoins[entityB]
|
|
32
|
-
if (!Object.prototype.hasOwnProperty.call(indexedClone, entityB)) {
|
|
33
|
-
indexedClone[entityB] = {}
|
|
34
|
-
}
|
|
35
|
-
if (!Object.prototype.hasOwnProperty.call(indexedClone[entityB], propertyB)) {
|
|
36
|
-
indexedClone[entityB][propertyB] = {}
|
|
37
|
-
}
|
|
38
|
-
indexedClone[entityB][propertyB] = [{
|
|
39
|
-
value: existingEntities[0][propertyB],
|
|
40
|
-
record: existingEntities
|
|
41
|
-
}]
|
|
42
|
-
}
|
|
43
|
-
return indexedClone
|
|
44
|
-
}
|
|
45
|
-
exports.restrictIndexedList = restrictIndexedList
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.restrictIndexedList = void 0;
|
|
7
|
+
var _splitEntityProperty = require("./parsers/splitEntityProperty");
|
|
8
|
+
const restrictIndexedList = (joinClause, filterJoins, indexedClone) => {
|
|
9
|
+
const {
|
|
10
|
+
entity: entityA,
|
|
11
|
+
property: propertyA
|
|
12
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyA);
|
|
13
|
+
const {
|
|
14
|
+
entity: entityB,
|
|
15
|
+
property: propertyB
|
|
16
|
+
} = (0, _splitEntityProperty.splitEntityProperty)(joinClause.propertyB);
|
|
17
|
+
if (Object.prototype.hasOwnProperty.call(filterJoins, entityA)) {
|
|
18
|
+
const existingEntities = filterJoins[entityA];
|
|
19
|
+
if (!Object.prototype.hasOwnProperty.call(indexedClone, entityA)) {
|
|
20
|
+
indexedClone[entityA] = {};
|
|
21
|
+
}
|
|
22
|
+
if (!Object.prototype.hasOwnProperty.call(indexedClone[entityA], propertyA)) {
|
|
23
|
+
indexedClone[entityA][propertyA] = {};
|
|
24
|
+
}
|
|
25
|
+
indexedClone[entityA][propertyA] = [{
|
|
26
|
+
value: existingEntities[0][propertyA],
|
|
27
|
+
record: existingEntities
|
|
28
|
+
}];
|
|
29
|
+
}
|
|
30
|
+
if (Object.prototype.hasOwnProperty.call(filterJoins, entityB)) {
|
|
31
|
+
const existingEntities = filterJoins[entityB];
|
|
32
|
+
if (!Object.prototype.hasOwnProperty.call(indexedClone, entityB)) {
|
|
33
|
+
indexedClone[entityB] = {};
|
|
34
|
+
}
|
|
35
|
+
if (!Object.prototype.hasOwnProperty.call(indexedClone[entityB], propertyB)) {
|
|
36
|
+
indexedClone[entityB][propertyB] = {};
|
|
37
|
+
}
|
|
38
|
+
indexedClone[entityB][propertyB] = [{
|
|
39
|
+
value: existingEntities[0][propertyB],
|
|
40
|
+
record: existingEntities
|
|
41
|
+
}];
|
|
42
|
+
}
|
|
43
|
+
return indexedClone;
|
|
44
|
+
};
|
|
45
|
+
exports.restrictIndexedList = restrictIndexedList;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require(
|
|
4
|
-
Object.defineProperty(exports,
|
|
5
|
-
value: true
|
|
6
|
-
})
|
|
7
|
-
exports.retrieveFile = void 0
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function _interopRequireWildcard
|
|
11
|
-
const retrieveFile = async path => {
|
|
12
|
-
let retrieveFn = url => fetch(url).then(res => res.json())
|
|
13
|
-
const relativePath = jsEnv.isBrowser ? (0, _config.getSetting)('relativePath', '') : ''
|
|
14
|
-
if (jsEnv.isNode) {
|
|
15
|
-
const {
|
|
16
|
-
readFile
|
|
17
|
-
} = require('fs/promises')
|
|
18
|
-
retrieveFn = url => readFile(url).then(res => JSON.parse(res))
|
|
19
|
-
}
|
|
20
|
-
const databasePath = (0, _config.getSetting)('databasePath', 'database/')
|
|
21
|
-
const fetchUrl = `${relativePath}${databasePath}${path}
|
|
22
|
-
const recordInfo = await retrieveFn(fetchUrl).catch(err => console.error(err))
|
|
23
|
-
if (!recordInfo) {
|
|
24
|
-
throw new Error(`Could not read ${path}`)
|
|
25
|
-
}
|
|
26
|
-
return recordInfo
|
|
27
|
-
}
|
|
28
|
-
exports.retrieveFile = retrieveFile
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/esnext.weak-map.delete-all.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.retrieveFile = void 0;
|
|
8
|
+
var jsEnv = _interopRequireWildcard(require("browser-or-node"));
|
|
9
|
+
var _config = require("./config");
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
|
+
const retrieveFile = async path => {
|
|
12
|
+
let retrieveFn = url => fetch(url).then(res => res.json());
|
|
13
|
+
const relativePath = jsEnv.isBrowser ? (0, _config.getSetting)('relativePath', '') : '';
|
|
14
|
+
if (jsEnv.isNode) {
|
|
15
|
+
const {
|
|
16
|
+
readFile
|
|
17
|
+
} = require('fs/promises');
|
|
18
|
+
retrieveFn = url => readFile(url).then(res => JSON.parse(res));
|
|
19
|
+
}
|
|
20
|
+
const databasePath = (0, _config.getSetting)('databasePath', 'database/');
|
|
21
|
+
const fetchUrl = `${relativePath}${databasePath}${path}`;
|
|
22
|
+
const recordInfo = await retrieveFn(fetchUrl).catch(err => console.error(err));
|
|
23
|
+
if (!recordInfo) {
|
|
24
|
+
throw new Error(`Could not read ${path}`);
|
|
25
|
+
}
|
|
26
|
+
return recordInfo;
|
|
27
|
+
};
|
|
28
|
+
exports.retrieveFile = retrieveFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("core-js/modules/esnext.weak-map.delete-all.js"),Object.defineProperty(exports,"__esModule",{value:!0}),exports.retrieveFile=void 0;var jsEnv=_interopRequireWildcard(require("browser-or-node")),_config=require("./config");function _interopRequireWildcard(e,r){if("function"==typeof WeakMap)var t=new WeakMap,i=new WeakMap;return(_interopRequireWildcard=function(e,r){if(!r&&e&&e.__esModule)return e;var o,n,a={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return a;if(o=r?i:t){if(o.has(e))return o.get(e);o.set(e,a)}for(const r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((n=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,r))&&(n.get||n.set)?o(a,r,n):a[r]=e[r]);return a})(e,r)}const retrieveFile=async e=>{let r=e=>fetch(e).then((e=>e.json()))
|
|
1
|
+
"use strict";require("core-js/modules/esnext.weak-map.delete-all.js"),Object.defineProperty(exports,"__esModule",{value:!0}),exports.retrieveFile=void 0;var jsEnv=_interopRequireWildcard(require("browser-or-node")),_config=require("./config");function _interopRequireWildcard(e,r){if("function"==typeof WeakMap)var t=new WeakMap,i=new WeakMap;return(_interopRequireWildcard=function(e,r){if(!r&&e&&e.__esModule)return e;var o,n,a={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return a;if(o=r?i:t){if(o.has(e))return o.get(e);o.set(e,a)}for(const r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((n=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,r))&&(n.get||n.set)?o(a,r,n):a[r]=e[r]);return a})(e,r)}const retrieveFile=async e=>{let r=e=>fetch(e).then((e=>e.json()));const t=jsEnv.isBrowser?(0,_config.getSetting)("relativePath",""):"";if(jsEnv.isNode){const{readFile:e}=require("fs/promises");r=r=>e(r).then((e=>JSON.parse(e)))}const i=`${t}${(0,_config.getSetting)("databasePath","database/")}${e}`,o=await r(i).catch((e=>console.error(e)));if(!o)throw new Error(`Could not read ${e}`);return o};exports.retrieveFile=retrieveFile;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const retrieveIndexes: (entity?: string, properties?: any[], recordData?: {}) => Promise<{}>;
|
|
1
|
+
export declare const retrieveIndexes: (entity?: string, properties?: any[], recordData?: {}) => Promise<{}>;
|
|
2
2
|
//# sourceMappingURL=retrieveIndexes.d.ts.map
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.retrieveIndexes = void 0
|
|
7
|
-
require(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const retrieveIndexes = async (entity = '', properties = [], recordData = {}) => {
|
|
11
|
-
if (!Object.prototype.hasOwnProperty.call(recordData, entity)) {
|
|
12
|
-
recordData[entity] = await (0, _retrieveRecord.retrieveRecord)(entity)
|
|
13
|
-
}
|
|
14
|
-
const indexSet = {}
|
|
15
|
-
for (const property of properties) {
|
|
16
|
-
for (const key of recordData[entity].keys) {
|
|
17
|
-
if (key.fields.includes(property)) {
|
|
18
|
-
indexSet[property] = await (0, _retrieveFile.retrieveFile)(`__indexes/${entity}/${key.lookup}`)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return indexSet
|
|
23
|
-
}
|
|
24
|
-
exports.retrieveIndexes = retrieveIndexes
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.retrieveIndexes = void 0;
|
|
7
|
+
require("core-js/modules/es.array.includes.js");
|
|
8
|
+
var _retrieveFile = require("./retrieveFile");
|
|
9
|
+
var _retrieveRecord = require("./retrieveRecord");
|
|
10
|
+
const retrieveIndexes = async (entity = '', properties = [], recordData = {}) => {
|
|
11
|
+
if (!Object.prototype.hasOwnProperty.call(recordData, entity)) {
|
|
12
|
+
recordData[entity] = await (0, _retrieveRecord.retrieveRecord)(entity);
|
|
13
|
+
}
|
|
14
|
+
const indexSet = {};
|
|
15
|
+
for (const property of properties) {
|
|
16
|
+
for (const key of recordData[entity].keys) {
|
|
17
|
+
if (key.fields.includes(property)) {
|
|
18
|
+
indexSet[property] = await (0, _retrieveFile.retrieveFile)(`__indexes/${entity}/${key.lookup}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return indexSet;
|
|
23
|
+
};
|
|
24
|
+
exports.retrieveIndexes = retrieveIndexes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.retrieveIndexes=void 0,require("core-js/modules/es.array.includes.js");var _retrieveFile=require("./retrieveFile"),_retrieveRecord=require("./retrieveRecord");const retrieveIndexes=async(e="",r=[],t={})=>{Object.prototype.hasOwnProperty.call(t,e)||(t[e]=await(0,_retrieveRecord.retrieveRecord)(e));const i={};for(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.retrieveIndexes=void 0,require("core-js/modules/es.array.includes.js");var _retrieveFile=require("./retrieveFile"),_retrieveRecord=require("./retrieveRecord");const retrieveIndexes=async(e="",r=[],t={})=>{Object.prototype.hasOwnProperty.call(t,e)||(t[e]=await(0,_retrieveRecord.retrieveRecord)(e));const i={};for(const o of r)for(const r of t[e].keys)r.fields.includes(o)&&(i[o]=await(0,_retrieveFile.retrieveFile)(`__indexes/${e}/${r.lookup}`));return i};exports.retrieveIndexes=retrieveIndexes;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.retrieveRecord = void 0
|
|
7
|
-
|
|
8
|
-
const retrieveRecord = async (entity = '') => await (0, _retrieveFile.retrieveFile)(`${entity}.json`)
|
|
9
|
-
exports.retrieveRecord = retrieveRecord
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.retrieveRecord = void 0;
|
|
7
|
+
var _retrieveFile = require("./retrieveFile");
|
|
8
|
+
const retrieveRecord = async (entity = '') => await (0, _retrieveFile.retrieveFile)(`${entity}.json`);
|
|
9
|
+
exports.retrieveRecord = retrieveRecord;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.retrieveRecords = void 0
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const retrieveRecords = async (entity = '') => {
|
|
10
|
-
const recordFile = await (0, _retrieveRecord.retrieveRecord)(entity)
|
|
11
|
-
const dataSet = []
|
|
12
|
-
for (const file of recordFile.entries) {
|
|
13
|
-
const data = await (0, _retrieveFile.retrieveFile)(`${recordFile.path}/${file}`).catch(err => console.error(err))
|
|
14
|
-
if (!data) {
|
|
15
|
-
throw new Error(`Could not read entity ${file}`)
|
|
16
|
-
}
|
|
17
|
-
dataSet.push(data)
|
|
18
|
-
}
|
|
19
|
-
return dataSet
|
|
20
|
-
}
|
|
21
|
-
exports.retrieveRecords = retrieveRecords
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.retrieveRecords = void 0;
|
|
7
|
+
var _retrieveFile = require("./retrieveFile");
|
|
8
|
+
var _retrieveRecord = require("./retrieveRecord");
|
|
9
|
+
const retrieveRecords = async (entity = '') => {
|
|
10
|
+
const recordFile = await (0, _retrieveRecord.retrieveRecord)(entity);
|
|
11
|
+
const dataSet = [];
|
|
12
|
+
for (const file of recordFile.entries) {
|
|
13
|
+
const data = await (0, _retrieveFile.retrieveFile)(`${recordFile.path}/${file}`).catch(err => console.error(err));
|
|
14
|
+
if (!data) {
|
|
15
|
+
throw new Error(`Could not read entity ${file}`);
|
|
16
|
+
}
|
|
17
|
+
dataSet.push(data);
|
|
18
|
+
}
|
|
19
|
+
return dataSet;
|
|
20
|
+
};
|
|
21
|
+
exports.retrieveRecords = retrieveRecords;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.retrieveRecords=void 0;var _retrieveFile=require("./retrieveFile"),_retrieveRecord=require("./retrieveRecord");const retrieveRecords=async(e="")=>{const r=await(0,_retrieveRecord.retrieveRecord)(e),t=[];for(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.retrieveRecords=void 0;var _retrieveFile=require("./retrieveFile"),_retrieveRecord=require("./retrieveRecord");const retrieveRecords=async(e="")=>{const r=await(0,_retrieveRecord.retrieveRecord)(e),t=[];for(const e of r.entries){const o=await(0,_retrieveFile.retrieveFile)(`${r.path}/${e}`).catch((e=>console.error(e)));if(!o)throw new Error(`Could not read entity ${e}`);t.push(o)}return t};exports.retrieveRecords=retrieveRecords;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const runQuery: (parsed: any) => Promise<any>;
|
|
1
|
+
export declare const runQuery: (parsed: any) => Promise<any>;
|
|
2
2
|
//# sourceMappingURL=runQuery.d.ts.map
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.runQuery = void 0
|
|
7
|
-
require(
|
|
8
|
-
require(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const runQuery = async parsed => {
|
|
24
|
-
const recordData = {
|
|
25
|
-
[parsed.entity]: await (0, _retrieveRecord.retrieveRecord)(parsed.entity)
|
|
26
|
-
}
|
|
27
|
-
if (typeof parsed.joinEntity !== 'undefined') {
|
|
28
|
-
recordData[parsed.joinEntity] = await (0, _retrieveRecord.retrieveRecord)(parsed.joinEntity)
|
|
29
|
-
}
|
|
30
|
-
let dataSet = {
|
|
31
|
-
[parsed.entity]: []
|
|
32
|
-
}
|
|
33
|
-
// A condition that's indexed but genuinely matches nothing leaves dataSet[entity] at [] - the
|
|
34
|
-
// same state it starts in before anything has looked at it at all. readEntity() (below) can't
|
|
35
|
-
// tell those two states apart on its own (it reloads whenever the array is empty, regardless of
|
|
36
|
-
// why), so capture here, before that ambiguity can happen, whether every condition actually got
|
|
37
|
-
// resolved this way - if so, dataSet[entity] is already correct and must not be reloaded.
|
|
38
|
-
const hadConditions = parsed.conditions.length > 0
|
|
39
|
-
parsed = await (0, _getConditionIndexedList.getConditionIndexedList)(parsed, recordData, dataSet)
|
|
40
|
-
const conditionsFullyIndexed = hadConditions && parsed.conditions.length === 0
|
|
41
|
-
parsed = await (0, _getJoinIndexedList.getJoinIndexedList)(parsed, recordData, dataSet)
|
|
42
|
-
// delete/update act on whatever is already in dataSet[entity] - unlike read, which loads
|
|
43
|
-
// everything and lets the where-reduce below narrow it down afterward, they never get a second
|
|
44
|
-
// pass. So the matching rows have to be fully resolved (indexed conditions already are, via
|
|
45
|
-
// getConditionIndexedList above; anything left in parsed.conditions is not) before either runs.
|
|
46
|
-
if (parsed.command === 'delete' || parsed.command === 'update') {
|
|
47
|
-
if (!conditionsFullyIndexed) {
|
|
48
|
-
dataSet = await (0, _readEntity.readEntity)(parsed.entity, dataSet)
|
|
49
|
-
}
|
|
50
|
-
dataSet[parsed.entity] = parsed.conditions.reduce((remainingData, condition) => (0, _where.where)(remainingData, condition), dataSet[parsed.entity])
|
|
51
|
-
}
|
|
52
|
-
switch (parsed.command) {
|
|
53
|
-
case 'delete':
|
|
54
|
-
dataSet = await (0, _deleteEntity.deleteEntity)(parsed.entity, dataSet)
|
|
55
|
-
break
|
|
56
|
-
case 'insert':
|
|
57
|
-
dataSet = await (0, _insertEntity.insertEntity)(parsed.entity, parsed.insertValues, dataSet)
|
|
58
|
-
break
|
|
59
|
-
case 'read':
|
|
60
|
-
if (!conditionsFullyIndexed) {
|
|
61
|
-
dataSet = await (0, _readEntity.readEntity)(parsed.entity, dataSet)
|
|
62
|
-
}
|
|
63
|
-
break
|
|
64
|
-
case 'update':
|
|
65
|
-
dataSet = await (0, _updateEntity.updateEntity)(parsed.entity, parsed.updateValues, dataSet)
|
|
66
|
-
break
|
|
67
|
-
default:
|
|
68
|
-
throw new Error(`Unknown command: ${parsed.command}`)
|
|
69
|
-
}
|
|
70
|
-
dataSet = await (0, _joinEntity.joinEntity)(parsed.entity, parsed.joinEntity, dataSet, parsed.joinClauses, conditionsFullyIndexed)
|
|
71
|
-
dataSet = await (0, _mergeJoins.mergeJoins)(dataSet, parsed.mergeJoins)
|
|
72
|
-
// delete/update already had parsed.conditions applied above, before they ran. Re-applying the
|
|
73
|
-
// same conditions here would be wrong, not just redundant, for update specifically: if the
|
|
74
|
-
// update just changed the very field a condition filters on, re-checking that condition against
|
|
75
|
-
// the now-changed data would filter the just-updated rows back out.
|
|
76
|
-
if (parsed.command !== 'delete' && parsed.command !== 'update') {
|
|
77
|
-
dataSet[parsed.entity] = parsed.conditions.reduce((remainingData, condition) => {
|
|
78
|
-
return (0, _where.where)(remainingData, condition)
|
|
79
|
-
}, dataSet[parsed.entity])
|
|
80
|
-
}
|
|
81
|
-
dataSet[parsed.entity] = (0, _sortBy.sortBy)(dataSet[parsed.entity], parsed.sortClauses)
|
|
82
|
-
dataSet[parsed.entity] = (0, _limitOffset.limitOffset)(dataSet[parsed.entity], parsed.offset, parsed.limit)
|
|
83
|
-
dataSet[parsed.entity] = (0, _groupBy.groupBy)(dataSet[parsed.entity], parsed.groupBy)
|
|
84
|
-
dataSet[parsed.entity] = (0, _selectFields.selectFields)(dataSet[parsed.entity], parsed.selectClauses)
|
|
85
|
-
return dataSet
|
|
86
|
-
}
|
|
87
|
-
exports.runQuery = runQuery
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.runQuery = void 0;
|
|
7
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.reduce.js");
|
|
9
|
+
var _deleteEntity = require("../queries/deleteEntity");
|
|
10
|
+
var _insertEntity = require("../queries/insertEntity");
|
|
11
|
+
var _readEntity = require("../queries/readEntity");
|
|
12
|
+
var _updateEntity = require("../queries/updateEntity");
|
|
13
|
+
var _joinEntity = require("../queries/joinEntity");
|
|
14
|
+
var _mergeJoins = require("../queries/mergeJoins");
|
|
15
|
+
var _where = require("../queries/where");
|
|
16
|
+
var _sortBy = require("../queries/sortBy");
|
|
17
|
+
var _groupBy = require("../queries/groupBy");
|
|
18
|
+
var _limitOffset = require("../queries/limitOffset");
|
|
19
|
+
var _selectFields = require("../queries/selectFields");
|
|
20
|
+
var _retrieveRecord = require("./retrieveRecord");
|
|
21
|
+
var _getConditionIndexedList = require("./getConditionIndexedList");
|
|
22
|
+
var _getJoinIndexedList = require("./getJoinIndexedList");
|
|
23
|
+
const runQuery = async parsed => {
|
|
24
|
+
const recordData = {
|
|
25
|
+
[parsed.entity]: await (0, _retrieveRecord.retrieveRecord)(parsed.entity)
|
|
26
|
+
};
|
|
27
|
+
if (typeof parsed.joinEntity !== 'undefined') {
|
|
28
|
+
recordData[parsed.joinEntity] = await (0, _retrieveRecord.retrieveRecord)(parsed.joinEntity);
|
|
29
|
+
}
|
|
30
|
+
let dataSet = {
|
|
31
|
+
[parsed.entity]: []
|
|
32
|
+
};
|
|
33
|
+
// A condition that's indexed but genuinely matches nothing leaves dataSet[entity] at [] - the
|
|
34
|
+
// same state it starts in before anything has looked at it at all. readEntity() (below) can't
|
|
35
|
+
// tell those two states apart on its own (it reloads whenever the array is empty, regardless of
|
|
36
|
+
// why), so capture here, before that ambiguity can happen, whether every condition actually got
|
|
37
|
+
// resolved this way - if so, dataSet[entity] is already correct and must not be reloaded.
|
|
38
|
+
const hadConditions = parsed.conditions.length > 0;
|
|
39
|
+
parsed = await (0, _getConditionIndexedList.getConditionIndexedList)(parsed, recordData, dataSet);
|
|
40
|
+
const conditionsFullyIndexed = hadConditions && parsed.conditions.length === 0;
|
|
41
|
+
parsed = await (0, _getJoinIndexedList.getJoinIndexedList)(parsed, recordData, dataSet);
|
|
42
|
+
// delete/update act on whatever is already in dataSet[entity] - unlike read, which loads
|
|
43
|
+
// everything and lets the where-reduce below narrow it down afterward, they never get a second
|
|
44
|
+
// pass. So the matching rows have to be fully resolved (indexed conditions already are, via
|
|
45
|
+
// getConditionIndexedList above; anything left in parsed.conditions is not) before either runs.
|
|
46
|
+
if (parsed.command === 'delete' || parsed.command === 'update') {
|
|
47
|
+
if (!conditionsFullyIndexed) {
|
|
48
|
+
dataSet = await (0, _readEntity.readEntity)(parsed.entity, dataSet);
|
|
49
|
+
}
|
|
50
|
+
dataSet[parsed.entity] = parsed.conditions.reduce((remainingData, condition) => (0, _where.where)(remainingData, condition), dataSet[parsed.entity]);
|
|
51
|
+
}
|
|
52
|
+
switch (parsed.command) {
|
|
53
|
+
case 'delete':
|
|
54
|
+
dataSet = await (0, _deleteEntity.deleteEntity)(parsed.entity, dataSet);
|
|
55
|
+
break;
|
|
56
|
+
case 'insert':
|
|
57
|
+
dataSet = await (0, _insertEntity.insertEntity)(parsed.entity, parsed.insertValues, dataSet);
|
|
58
|
+
break;
|
|
59
|
+
case 'read':
|
|
60
|
+
if (!conditionsFullyIndexed) {
|
|
61
|
+
dataSet = await (0, _readEntity.readEntity)(parsed.entity, dataSet);
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
case 'update':
|
|
65
|
+
dataSet = await (0, _updateEntity.updateEntity)(parsed.entity, parsed.updateValues, dataSet);
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
throw new Error(`Unknown command: ${parsed.command}`);
|
|
69
|
+
}
|
|
70
|
+
dataSet = await (0, _joinEntity.joinEntity)(parsed.entity, parsed.joinEntity, dataSet, parsed.joinClauses, conditionsFullyIndexed);
|
|
71
|
+
dataSet = await (0, _mergeJoins.mergeJoins)(dataSet, parsed.mergeJoins);
|
|
72
|
+
// delete/update already had parsed.conditions applied above, before they ran. Re-applying the
|
|
73
|
+
// same conditions here would be wrong, not just redundant, for update specifically: if the
|
|
74
|
+
// update just changed the very field a condition filters on, re-checking that condition against
|
|
75
|
+
// the now-changed data would filter the just-updated rows back out.
|
|
76
|
+
if (parsed.command !== 'delete' && parsed.command !== 'update') {
|
|
77
|
+
dataSet[parsed.entity] = parsed.conditions.reduce((remainingData, condition) => {
|
|
78
|
+
return (0, _where.where)(remainingData, condition);
|
|
79
|
+
}, dataSet[parsed.entity]);
|
|
80
|
+
}
|
|
81
|
+
dataSet[parsed.entity] = (0, _sortBy.sortBy)(dataSet[parsed.entity], parsed.sortClauses);
|
|
82
|
+
dataSet[parsed.entity] = (0, _limitOffset.limitOffset)(dataSet[parsed.entity], parsed.offset, parsed.limit);
|
|
83
|
+
dataSet[parsed.entity] = (0, _groupBy.groupBy)(dataSet[parsed.entity], parsed.groupBy);
|
|
84
|
+
dataSet[parsed.entity] = (0, _selectFields.selectFields)(dataSet[parsed.entity], parsed.selectClauses);
|
|
85
|
+
return dataSet;
|
|
86
|
+
};
|
|
87
|
+
exports.runQuery = runQuery;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { keyDefinition } from '../introspect/definitions/key';
|
|
2
|
-
import { recordPath } from '../introspect/definitions/record';
|
|
3
|
-
export type indexEntry = {
|
|
4
|
-
value: any;
|
|
5
|
-
record: string[];
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Add a single entry file to the index that backs one of a record's keys, creating the index
|
|
9
|
-
* file (and its __indexes/{record} directory) the first time a value is indexed. Keys with no
|
|
10
|
-
* lookup (multi-field keys are not indexed here) are left untouched.
|
|
11
|
-
* @param path
|
|
12
|
-
* @param key
|
|
13
|
-
* @param value
|
|
14
|
-
* @param fileName
|
|
15
|
-
*/
|
|
16
|
-
export declare const updateIndex: (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
|
+
export type indexEntry = {
|
|
4
|
+
value: any;
|
|
5
|
+
record: string[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Add a single entry file to the index that backs one of a record's keys, creating the index
|
|
9
|
+
* file (and its __indexes/{record} directory) the first time a value is indexed. Keys with no
|
|
10
|
+
* lookup (multi-field keys are not indexed here) are left untouched.
|
|
11
|
+
* @param path
|
|
12
|
+
* @param key
|
|
13
|
+
* @param value
|
|
14
|
+
* @param fileName
|
|
15
|
+
*/
|
|
16
|
+
export declare const updateIndex: (path?: recordPath, key?: keyDefinition, value?: any, fileName?: string) => Promise<indexEntry[] | null>;
|
|
17
17
|
//# sourceMappingURL=updateIndex.d.ts.map
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.updateIndex = void 0
|
|
7
|
-
require(
|
|
8
|
-
require(
|
|
9
|
-
require(
|
|
10
|
-
require(
|
|
11
|
-
|
|
12
|
-
const {
|
|
13
|
-
readFile,
|
|
14
|
-
writeFile,
|
|
15
|
-
mkdir
|
|
16
|
-
} = require('fs/promises')
|
|
17
|
-
/**
|
|
18
|
-
* Add a single entry file to the index that backs one of a record's keys, creating the index
|
|
19
|
-
* file (and its __indexes/{record} directory) the first time a value is indexed. Keys with no
|
|
20
|
-
* lookup (multi-field keys are not indexed here) are left untouched.
|
|
21
|
-
* @param path
|
|
22
|
-
* @param key
|
|
23
|
-
* @param value
|
|
24
|
-
* @param fileName
|
|
25
|
-
*/
|
|
26
|
-
const updateIndex = async (path = '', key = null, value = undefined, fileName = '') => {
|
|
27
|
-
if (!key || !key.lookup) {
|
|
28
|
-
return null
|
|
29
|
-
}
|
|
30
|
-
const databasePath = (0, _config.getSetting)('databasePath', 'database/')
|
|
31
|
-
const indexDir = `${databasePath}__indexes/${path}
|
|
32
|
-
const indexPath = `${indexDir}/${key.lookup}
|
|
33
|
-
let index = []
|
|
34
|
-
try {
|
|
35
|
-
index = JSON.parse(await readFile(indexPath, 'utf8'))
|
|
36
|
-
} catch (err) {
|
|
37
|
-
index = []
|
|
38
|
-
}
|
|
39
|
-
const existingEntry = index.find(entry => entry.value == value)
|
|
40
|
-
if (existingEntry) {
|
|
41
|
-
if (!existingEntry.record.includes(fileName)) {
|
|
42
|
-
existingEntry.record.push(fileName)
|
|
43
|
-
}
|
|
44
|
-
} else {
|
|
45
|
-
index.push({
|
|
46
|
-
value,
|
|
47
|
-
record: [fileName]
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
await mkdir(indexDir, {
|
|
51
|
-
recursive: true
|
|
52
|
-
})
|
|
53
|
-
await writeFile(indexPath, JSON.stringify(index, null, 2))
|
|
54
|
-
return index
|
|
55
|
-
}
|
|
56
|
-
exports.updateIndex = updateIndex
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.updateIndex = void 0;
|
|
7
|
+
require("core-js/modules/es.array.includes.js");
|
|
8
|
+
require("core-js/modules/es.json.stringify.js");
|
|
9
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
10
|
+
require("core-js/modules/esnext.iterator.find.js");
|
|
11
|
+
var _config = require("./config");
|
|
12
|
+
const {
|
|
13
|
+
readFile,
|
|
14
|
+
writeFile,
|
|
15
|
+
mkdir
|
|
16
|
+
} = require('fs/promises');
|
|
17
|
+
/**
|
|
18
|
+
* Add a single entry file to the index that backs one of a record's keys, creating the index
|
|
19
|
+
* file (and its __indexes/{record} directory) the first time a value is indexed. Keys with no
|
|
20
|
+
* lookup (multi-field keys are not indexed here) are left untouched.
|
|
21
|
+
* @param path
|
|
22
|
+
* @param key
|
|
23
|
+
* @param value
|
|
24
|
+
* @param fileName
|
|
25
|
+
*/
|
|
26
|
+
const updateIndex = async (path = '', key = null, value = undefined, fileName = '') => {
|
|
27
|
+
if (!key || !key.lookup) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const databasePath = (0, _config.getSetting)('databasePath', 'database/');
|
|
31
|
+
const indexDir = `${databasePath}__indexes/${path}`;
|
|
32
|
+
const indexPath = `${indexDir}/${key.lookup}`;
|
|
33
|
+
let index = [];
|
|
34
|
+
try {
|
|
35
|
+
index = JSON.parse(await readFile(indexPath, 'utf8'));
|
|
36
|
+
} catch (err) {
|
|
37
|
+
index = [];
|
|
38
|
+
}
|
|
39
|
+
const existingEntry = index.find(entry => entry.value == value);
|
|
40
|
+
if (existingEntry) {
|
|
41
|
+
if (!existingEntry.record.includes(fileName)) {
|
|
42
|
+
existingEntry.record.push(fileName);
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
index.push({
|
|
46
|
+
value,
|
|
47
|
+
record: [fileName]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
await mkdir(indexDir, {
|
|
51
|
+
recursive: true
|
|
52
|
+
});
|
|
53
|
+
await writeFile(indexPath, JSON.stringify(index, null, 2));
|
|
54
|
+
return index;
|
|
55
|
+
};
|
|
56
|
+
exports.updateIndex = updateIndex;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const useJoinClause: ({ propertyA, comparator, propertyB }?: {
|
|
2
|
-
propertyA?: any;
|
|
3
|
-
comparator?: string;
|
|
4
|
-
propertyB?: any;
|
|
5
|
-
}, dataSets?: {}, filterJoins?: {}) => Promise<{}>;
|
|
1
|
+
export declare const useJoinClause: ({ propertyA, comparator, propertyB }?: {
|
|
2
|
+
propertyA?: any;
|
|
3
|
+
comparator?: string;
|
|
4
|
+
propertyB?: any;
|
|
5
|
+
}, dataSets?: {}, filterJoins?: {}) => Promise<{}>;
|
|
6
6
|
//# sourceMappingURL=useJoinClause.d.ts.map
|