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,11 +1,11 @@
|
|
|
1
|
-
import { recordDefinition } from './definitions/record';
|
|
2
|
-
import { keyProperties } from './definitions/key';
|
|
3
|
-
import { fieldProperties } from './definitions/field';
|
|
4
|
-
/**
|
|
5
|
-
* Create a new record.
|
|
6
|
-
* @param recordName
|
|
7
|
-
* @param definition
|
|
8
|
-
* @param keys
|
|
9
|
-
*/
|
|
10
|
-
export declare const create: (recordName: string, definition?: fieldProperties[], keys?: keyProperties[]) => Promise<recordDefinition | null>;
|
|
1
|
+
import { recordDefinition } from './definitions/record';
|
|
2
|
+
import { keyProperties } from './definitions/key';
|
|
3
|
+
import { fieldProperties } from './definitions/field';
|
|
4
|
+
/**
|
|
5
|
+
* Create a new record.
|
|
6
|
+
* @param recordName
|
|
7
|
+
* @param definition
|
|
8
|
+
* @param keys
|
|
9
|
+
*/
|
|
10
|
+
export declare const create: (recordName: string, definition?: fieldProperties[], keys?: keyProperties[]) => Promise<recordDefinition | null>;
|
|
11
11
|
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.create = void 0
|
|
7
|
-
require(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Create a new record.
|
|
13
|
-
* @param recordName
|
|
14
|
-
* @param definition
|
|
15
|
-
* @param keys
|
|
16
|
-
*/
|
|
17
|
-
const create = async (recordName, definition = [], keys = []) => {
|
|
18
|
-
const {
|
|
19
|
-
writeFile,
|
|
20
|
-
mkdir
|
|
21
|
-
} = require('fs/promises')
|
|
22
|
-
const {
|
|
23
|
-
existsSync
|
|
24
|
-
} = require('fs')
|
|
25
|
-
const databasePath = (0, _config.getSetting)('databasePath', 'database/')
|
|
26
|
-
if (recordName === '__RECORDS') {
|
|
27
|
-
return null
|
|
28
|
-
}
|
|
29
|
-
if (existsSync(`${databasePath}${recordName}.json`)) {
|
|
30
|
-
return null
|
|
31
|
-
}
|
|
32
|
-
await mkdir(databasePath, {
|
|
33
|
-
recursive: true
|
|
34
|
-
})
|
|
35
|
-
const recordContent = (0, _record.record)({
|
|
36
|
-
path: recordName,
|
|
37
|
-
definition,
|
|
38
|
-
keys
|
|
39
|
-
})
|
|
40
|
-
await writeFile(`${databasePath}${recordName}.json`, JSON.stringify(recordContent, null, 2))
|
|
41
|
-
await mkdir(`${databasePath}${recordName}`, {
|
|
42
|
-
recursive: true
|
|
43
|
-
})
|
|
44
|
-
await (0, _registerRecord.registerRecord)(recordName)
|
|
45
|
-
return recordContent
|
|
46
|
-
}
|
|
47
|
-
exports.create = create
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.create = void 0;
|
|
7
|
+
require("core-js/modules/es.json.stringify.js");
|
|
8
|
+
var _record = require("./definitions/record");
|
|
9
|
+
var _registerRecord = require("../utilities/registerRecord");
|
|
10
|
+
var _config = require("../utilities/config");
|
|
11
|
+
/**
|
|
12
|
+
* Create a new record.
|
|
13
|
+
* @param recordName
|
|
14
|
+
* @param definition
|
|
15
|
+
* @param keys
|
|
16
|
+
*/
|
|
17
|
+
const create = async (recordName, definition = [], keys = []) => {
|
|
18
|
+
const {
|
|
19
|
+
writeFile,
|
|
20
|
+
mkdir
|
|
21
|
+
} = require('fs/promises');
|
|
22
|
+
const {
|
|
23
|
+
existsSync
|
|
24
|
+
} = require('fs');
|
|
25
|
+
const databasePath = (0, _config.getSetting)('databasePath', 'database/');
|
|
26
|
+
if (recordName === '__RECORDS') {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (existsSync(`${databasePath}${recordName}.json`)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
await mkdir(databasePath, {
|
|
33
|
+
recursive: true
|
|
34
|
+
});
|
|
35
|
+
const recordContent = (0, _record.record)({
|
|
36
|
+
path: recordName,
|
|
37
|
+
definition,
|
|
38
|
+
keys
|
|
39
|
+
});
|
|
40
|
+
await writeFile(`${databasePath}${recordName}.json`, JSON.stringify(recordContent, null, 2));
|
|
41
|
+
await mkdir(`${databasePath}${recordName}`, {
|
|
42
|
+
recursive: true
|
|
43
|
+
});
|
|
44
|
+
await (0, _registerRecord.registerRecord)(recordName);
|
|
45
|
+
return recordContent;
|
|
46
|
+
};
|
|
47
|
+
exports.create = create;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export type fieldName = string;
|
|
2
|
-
export type fieldDefinition = {
|
|
3
|
-
name: fieldName;
|
|
4
|
-
type: string;
|
|
5
|
-
optional: boolean;
|
|
6
|
-
default?: any;
|
|
7
|
-
autoGenerate: boolean;
|
|
8
|
-
};
|
|
9
|
-
export type fieldProperties = {
|
|
10
|
-
name?: string;
|
|
11
|
-
type?: string;
|
|
12
|
-
optional?: boolean;
|
|
13
|
-
useDefault?: boolean;
|
|
14
|
-
defaultValue?: any;
|
|
15
|
-
autoGenerate?: boolean;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Generate a field for a record.
|
|
19
|
-
* @param properties
|
|
20
|
-
* @param properties.name
|
|
21
|
-
* @param properties.type
|
|
22
|
-
* @param properties.optional
|
|
23
|
-
* @param properties.useDefault
|
|
24
|
-
* @param properties.defaultValue
|
|
25
|
-
* @param properties.autoGenerate
|
|
26
|
-
*/
|
|
27
|
-
export declare const field: ({ name, type, optional, useDefault, defaultValue, autoGenerate }?: fieldProperties) => fieldDefinition;
|
|
1
|
+
export type fieldName = string;
|
|
2
|
+
export type fieldDefinition = {
|
|
3
|
+
name: fieldName;
|
|
4
|
+
type: string;
|
|
5
|
+
optional: boolean;
|
|
6
|
+
default?: any;
|
|
7
|
+
autoGenerate: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type fieldProperties = {
|
|
10
|
+
name?: string;
|
|
11
|
+
type?: string;
|
|
12
|
+
optional?: boolean;
|
|
13
|
+
useDefault?: boolean;
|
|
14
|
+
defaultValue?: any;
|
|
15
|
+
autoGenerate?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Generate a field for a record.
|
|
19
|
+
* @param properties
|
|
20
|
+
* @param properties.name
|
|
21
|
+
* @param properties.type
|
|
22
|
+
* @param properties.optional
|
|
23
|
+
* @param properties.useDefault
|
|
24
|
+
* @param properties.defaultValue
|
|
25
|
+
* @param properties.autoGenerate
|
|
26
|
+
*/
|
|
27
|
+
export declare const field: ({ name, type, optional, useDefault, defaultValue, autoGenerate }?: fieldProperties) => fieldDefinition;
|
|
28
28
|
//# sourceMappingURL=field.d.ts.map
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.field = void 0
|
|
7
|
-
/**
|
|
8
|
-
* Generate a field for a record.
|
|
9
|
-
* @param properties
|
|
10
|
-
* @param properties.name
|
|
11
|
-
* @param properties.type
|
|
12
|
-
* @param properties.optional
|
|
13
|
-
* @param properties.useDefault
|
|
14
|
-
* @param properties.defaultValue
|
|
15
|
-
* @param properties.autoGenerate
|
|
16
|
-
*/
|
|
17
|
-
const field = ({
|
|
18
|
-
name = '',
|
|
19
|
-
type = 'string',
|
|
20
|
-
optional = false,
|
|
21
|
-
useDefault = false,
|
|
22
|
-
defaultValue = '',
|
|
23
|
-
autoGenerate = false
|
|
24
|
-
} = {}) => {
|
|
25
|
-
const returnField = {
|
|
26
|
-
name,
|
|
27
|
-
type,
|
|
28
|
-
optional,
|
|
29
|
-
autoGenerate
|
|
30
|
-
}
|
|
31
|
-
if (useDefault) {
|
|
32
|
-
returnField
|
|
33
|
-
}
|
|
34
|
-
return returnField
|
|
35
|
-
}
|
|
36
|
-
exports.field = field
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.field = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Generate a field for a record.
|
|
9
|
+
* @param properties
|
|
10
|
+
* @param properties.name
|
|
11
|
+
* @param properties.type
|
|
12
|
+
* @param properties.optional
|
|
13
|
+
* @param properties.useDefault
|
|
14
|
+
* @param properties.defaultValue
|
|
15
|
+
* @param properties.autoGenerate
|
|
16
|
+
*/
|
|
17
|
+
const field = ({
|
|
18
|
+
name = '',
|
|
19
|
+
type = 'string',
|
|
20
|
+
optional = false,
|
|
21
|
+
useDefault = false,
|
|
22
|
+
defaultValue = '',
|
|
23
|
+
autoGenerate = false
|
|
24
|
+
} = {}) => {
|
|
25
|
+
const returnField = {
|
|
26
|
+
name,
|
|
27
|
+
type,
|
|
28
|
+
optional,
|
|
29
|
+
autoGenerate
|
|
30
|
+
};
|
|
31
|
+
if (useDefault) {
|
|
32
|
+
returnField['default'] = defaultValue;
|
|
33
|
+
}
|
|
34
|
+
return returnField;
|
|
35
|
+
};
|
|
36
|
+
exports.field = field;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { reference } from './keyReference';
|
|
2
|
-
import { fieldName } from './field';
|
|
3
|
-
export type indexType = string;
|
|
4
|
-
export type indexLocation = string;
|
|
5
|
-
export type keyDefinition = {
|
|
6
|
-
type: indexType;
|
|
7
|
-
fields: Array<fieldName>;
|
|
8
|
-
lookup: indexLocation;
|
|
9
|
-
references?: Array<reference>;
|
|
10
|
-
};
|
|
11
|
-
export type keyProperties = {
|
|
12
|
-
type?: indexType;
|
|
13
|
-
fields?: Array<fieldName>;
|
|
14
|
-
lookup?: indexLocation;
|
|
15
|
-
references?: Array<reference>;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Create a field key.
|
|
19
|
-
* @param properties
|
|
20
|
-
* @param properties.type
|
|
21
|
-
* @param properties.fields
|
|
22
|
-
* @param properties.lookup
|
|
23
|
-
* @param properties.references
|
|
24
|
-
*/
|
|
25
|
-
export declare const key: ({ type, fields, lookup, references }?: keyProperties) => keyDefinition;
|
|
1
|
+
import { reference } from './keyReference';
|
|
2
|
+
import { fieldName } from './field';
|
|
3
|
+
export type indexType = string;
|
|
4
|
+
export type indexLocation = string;
|
|
5
|
+
export type keyDefinition = {
|
|
6
|
+
type: indexType;
|
|
7
|
+
fields: Array<fieldName>;
|
|
8
|
+
lookup: indexLocation;
|
|
9
|
+
references?: Array<reference>;
|
|
10
|
+
};
|
|
11
|
+
export type keyProperties = {
|
|
12
|
+
type?: indexType;
|
|
13
|
+
fields?: Array<fieldName>;
|
|
14
|
+
lookup?: indexLocation;
|
|
15
|
+
references?: Array<reference>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Create a field key.
|
|
19
|
+
* @param properties
|
|
20
|
+
* @param properties.type
|
|
21
|
+
* @param properties.fields
|
|
22
|
+
* @param properties.lookup
|
|
23
|
+
* @param properties.references
|
|
24
|
+
*/
|
|
25
|
+
export declare const key: ({ type, fields, lookup, references }?: keyProperties) => keyDefinition;
|
|
26
26
|
//# sourceMappingURL=key.d.ts.map
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.key = void 0
|
|
7
|
-
require(
|
|
8
|
-
require(
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Create a field key.
|
|
12
|
-
* @param properties
|
|
13
|
-
* @param properties.type
|
|
14
|
-
* @param properties.fields
|
|
15
|
-
* @param properties.lookup
|
|
16
|
-
* @param properties.references
|
|
17
|
-
*/
|
|
18
|
-
const key = ({
|
|
19
|
-
type = 'index',
|
|
20
|
-
fields = [],
|
|
21
|
-
lookup = '',
|
|
22
|
-
references = []
|
|
23
|
-
} = {}) => {
|
|
24
|
-
switch (type) {
|
|
25
|
-
case 'primary':
|
|
26
|
-
case 'index':
|
|
27
|
-
case 'unique':
|
|
28
|
-
references = []
|
|
29
|
-
break
|
|
30
|
-
case 'multi':
|
|
31
|
-
if (fields.length < 2) {
|
|
32
|
-
throw new Error('Multi key indicated with less than two fields')
|
|
33
|
-
}
|
|
34
|
-
break
|
|
35
|
-
case 'foreign':
|
|
36
|
-
if (references.length < 1) {
|
|
37
|
-
throw new Error('Foreign key must have one reference to an external record')
|
|
38
|
-
}
|
|
39
|
-
break
|
|
40
|
-
default:
|
|
41
|
-
throw new Error('Unrecognized key type; must be index, primary, unique, multi, or foreign')
|
|
42
|
-
}
|
|
43
|
-
const keyDefinition = {
|
|
44
|
-
type,
|
|
45
|
-
fields,
|
|
46
|
-
lookup
|
|
47
|
-
}
|
|
48
|
-
if (typeof references !== 'undefined' && references.length > 0) {
|
|
49
|
-
keyDefinition
|
|
50
|
-
}
|
|
51
|
-
return keyDefinition
|
|
52
|
-
}
|
|
53
|
-
exports.key = key
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.key = void 0;
|
|
7
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
9
|
+
var _keyReference = require("./keyReference");
|
|
10
|
+
/**
|
|
11
|
+
* Create a field key.
|
|
12
|
+
* @param properties
|
|
13
|
+
* @param properties.type
|
|
14
|
+
* @param properties.fields
|
|
15
|
+
* @param properties.lookup
|
|
16
|
+
* @param properties.references
|
|
17
|
+
*/
|
|
18
|
+
const key = ({
|
|
19
|
+
type = 'index',
|
|
20
|
+
fields = [],
|
|
21
|
+
lookup = '',
|
|
22
|
+
references = []
|
|
23
|
+
} = {}) => {
|
|
24
|
+
switch (type) {
|
|
25
|
+
case 'primary':
|
|
26
|
+
case 'index':
|
|
27
|
+
case 'unique':
|
|
28
|
+
references = [];
|
|
29
|
+
break;
|
|
30
|
+
case 'multi':
|
|
31
|
+
if (fields.length < 2) {
|
|
32
|
+
throw new Error('Multi key indicated with less than two fields');
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
case 'foreign':
|
|
36
|
+
if (references.length < 1) {
|
|
37
|
+
throw new Error('Foreign key must have one reference to an external record');
|
|
38
|
+
}
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
throw new Error('Unrecognized key type; must be index, primary, unique, multi, or foreign');
|
|
42
|
+
}
|
|
43
|
+
const keyDefinition = {
|
|
44
|
+
type,
|
|
45
|
+
fields,
|
|
46
|
+
lookup
|
|
47
|
+
};
|
|
48
|
+
if (typeof references !== 'undefined' && references.length > 0) {
|
|
49
|
+
keyDefinition['references'] = references.map(_keyReference.keyReference);
|
|
50
|
+
}
|
|
51
|
+
return keyDefinition;
|
|
52
|
+
};
|
|
53
|
+
exports.key = key;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { fieldName } from './field';
|
|
2
|
-
import { recordPath } from './record';
|
|
3
|
-
export type reference = {
|
|
4
|
-
fields: fieldName[];
|
|
5
|
-
lookup: recordPath;
|
|
6
|
-
};
|
|
7
|
-
export type referenceProperties = {
|
|
8
|
-
fields?: fieldName[];
|
|
9
|
-
lookup?: recordPath;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Create a reference to a remote (foreign; existing on another record) key.
|
|
13
|
-
* @param properties
|
|
14
|
-
* @param properties.fields
|
|
15
|
-
* @param properties.lookup
|
|
16
|
-
*/
|
|
17
|
-
export declare const keyReference: ({ fields, lookup }?: referenceProperties) => reference;
|
|
1
|
+
import { fieldName } from './field';
|
|
2
|
+
import { recordPath } from './record';
|
|
3
|
+
export type reference = {
|
|
4
|
+
fields: fieldName[];
|
|
5
|
+
lookup: recordPath;
|
|
6
|
+
};
|
|
7
|
+
export type referenceProperties = {
|
|
8
|
+
fields?: fieldName[];
|
|
9
|
+
lookup?: recordPath;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Create a reference to a remote (foreign; existing on another record) key.
|
|
13
|
+
* @param properties
|
|
14
|
+
* @param properties.fields
|
|
15
|
+
* @param properties.lookup
|
|
16
|
+
*/
|
|
17
|
+
export declare const keyReference: ({ fields, lookup }?: referenceProperties) => reference;
|
|
18
18
|
//# sourceMappingURL=keyReference.d.ts.map
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.keyReference = void 0
|
|
7
|
-
/**
|
|
8
|
-
* Create a reference to a remote (foreign; existing on another record) key.
|
|
9
|
-
* @param properties
|
|
10
|
-
* @param properties.fields
|
|
11
|
-
* @param properties.lookup
|
|
12
|
-
*/
|
|
13
|
-
const keyReference = ({
|
|
14
|
-
fields = [],
|
|
15
|
-
lookup = ''
|
|
16
|
-
} = {}) => ({
|
|
17
|
-
fields,
|
|
18
|
-
lookup
|
|
19
|
-
})
|
|
20
|
-
exports.keyReference = keyReference
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.keyReference = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Create a reference to a remote (foreign; existing on another record) key.
|
|
9
|
+
* @param properties
|
|
10
|
+
* @param properties.fields
|
|
11
|
+
* @param properties.lookup
|
|
12
|
+
*/
|
|
13
|
+
const keyReference = ({
|
|
14
|
+
fields = [],
|
|
15
|
+
lookup = ''
|
|
16
|
+
} = {}) => ({
|
|
17
|
+
fields,
|
|
18
|
+
lookup
|
|
19
|
+
});
|
|
20
|
+
exports.keyReference = keyReference;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { fieldDefinition, fieldProperties } from './field';
|
|
2
|
-
import { keyDefinition, keyProperties } from './key';
|
|
3
|
-
export type recordPath = string;
|
|
4
|
-
export type entityPath = string;
|
|
5
|
-
export type recordDefinition = {
|
|
6
|
-
path: recordPath;
|
|
7
|
-
definition: fieldDefinition[];
|
|
8
|
-
keys: keyDefinition[];
|
|
9
|
-
entries: entityPath[];
|
|
10
|
-
};
|
|
11
|
-
export type recordProperties = {
|
|
12
|
-
path?: recordPath;
|
|
13
|
-
definition?: fieldProperties[];
|
|
14
|
-
keys?: keyProperties[];
|
|
15
|
-
entries?: entityPath[];
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @param properties
|
|
20
|
-
* @param properties.path
|
|
21
|
-
* @param properties.definition
|
|
22
|
-
* @param properties.keys
|
|
23
|
-
* @param properties.entries
|
|
24
|
-
*/
|
|
25
|
-
export declare const record: ({ path, definition, keys, entries }?: recordProperties) => recordDefinition;
|
|
1
|
+
import { fieldDefinition, fieldProperties } from './field';
|
|
2
|
+
import { keyDefinition, keyProperties } from './key';
|
|
3
|
+
export type recordPath = string;
|
|
4
|
+
export type entityPath = string;
|
|
5
|
+
export type recordDefinition = {
|
|
6
|
+
path: recordPath;
|
|
7
|
+
definition: fieldDefinition[];
|
|
8
|
+
keys: keyDefinition[];
|
|
9
|
+
entries: entityPath[];
|
|
10
|
+
};
|
|
11
|
+
export type recordProperties = {
|
|
12
|
+
path?: recordPath;
|
|
13
|
+
definition?: fieldProperties[];
|
|
14
|
+
keys?: keyProperties[];
|
|
15
|
+
entries?: entityPath[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param properties
|
|
20
|
+
* @param properties.path
|
|
21
|
+
* @param properties.definition
|
|
22
|
+
* @param properties.keys
|
|
23
|
+
* @param properties.entries
|
|
24
|
+
*/
|
|
25
|
+
export declare const record: ({ path, definition, keys, entries }?: recordProperties) => recordDefinition;
|
|
26
26
|
//# sourceMappingURL=record.d.ts.map
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.record = void 0
|
|
7
|
-
require(
|
|
8
|
-
require(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @param properties
|
|
14
|
-
* @param properties.path
|
|
15
|
-
* @param properties.definition
|
|
16
|
-
* @param properties.keys
|
|
17
|
-
* @param properties.entries
|
|
18
|
-
*/
|
|
19
|
-
const record = ({
|
|
20
|
-
path = '',
|
|
21
|
-
definition = [],
|
|
22
|
-
keys = [],
|
|
23
|
-
entries = []
|
|
24
|
-
} = {}) => {
|
|
25
|
-
return {
|
|
26
|
-
path,
|
|
27
|
-
definition: definition.map(_field.field),
|
|
28
|
-
keys: keys.map(_key.key),
|
|
29
|
-
entries
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.record = record
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.record = void 0;
|
|
7
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
9
|
+
var _field = require("./field");
|
|
10
|
+
var _key = require("./key");
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param properties
|
|
14
|
+
* @param properties.path
|
|
15
|
+
* @param properties.definition
|
|
16
|
+
* @param properties.keys
|
|
17
|
+
* @param properties.entries
|
|
18
|
+
*/
|
|
19
|
+
const record = ({
|
|
20
|
+
path = '',
|
|
21
|
+
definition = [],
|
|
22
|
+
keys = [],
|
|
23
|
+
entries = []
|
|
24
|
+
} = {}) => {
|
|
25
|
+
return {
|
|
26
|
+
path,
|
|
27
|
+
definition: definition.map(_field.field),
|
|
28
|
+
keys: keys.map(_key.key),
|
|
29
|
+
entries
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.record = record;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.describe = void 0
|
|
7
|
-
|
|
8
|
-
const describe = async (record = '__RECORDS') => {
|
|
9
|
-
const recordFile = await (0, _retrieveFile.retrieveFile)(`${record}.json`)
|
|
10
|
-
if (record === '__RECORDS') {
|
|
11
|
-
return recordFile.entries
|
|
12
|
-
}
|
|
13
|
-
return recordFile.definition
|
|
14
|
-
}
|
|
15
|
-
exports.describe = describe
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.describe = void 0;
|
|
7
|
+
var _retrieveFile = require("../utilities/retrieveFile");
|
|
8
|
+
const describe = async (record = '__RECORDS') => {
|
|
9
|
+
const recordFile = await (0, _retrieveFile.retrieveFile)(`${record}.json`);
|
|
10
|
+
if (record === '__RECORDS') {
|
|
11
|
+
return recordFile.entries;
|
|
12
|
+
}
|
|
13
|
+
return recordFile.definition;
|
|
14
|
+
};
|
|
15
|
+
exports.describe = describe;
|