@imbricate/core 3.8.1 → 3.8.2
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/database/definition.d.ts +9 -6
- package/database/definition.js +6 -1
- package/database/validate.js +20 -13
- package/package.json +1 -1
package/database/definition.d.ts
CHANGED
|
@@ -6,24 +6,27 @@
|
|
|
6
6
|
import { ImbricateAuthor } from "../author/definition";
|
|
7
7
|
import { ImbricateDatabaseSchema } from "./schema";
|
|
8
8
|
export declare enum IMBRICATE_QUERY_COMPARE_CONDITION {
|
|
9
|
-
EQUAL = "EQUAL"
|
|
9
|
+
EQUAL = "EQUAL",
|
|
10
|
+
EXIST = "EXIST"
|
|
11
|
+
}
|
|
12
|
+
export declare enum IMBRICATE_QUERY_ATTRIBUTE {
|
|
13
|
+
VALUE = "VALUE"
|
|
10
14
|
}
|
|
11
15
|
export declare enum IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET {
|
|
12
16
|
PROPERTY_TYPE = "PROPERTY_TYPE",
|
|
13
17
|
PROPERTY_VALUE = "PROPERTY_VALUE"
|
|
14
18
|
}
|
|
15
|
-
export type
|
|
19
|
+
export type ImbricateDocumentQueryPropertyFilter = {
|
|
20
|
+
readonly propertyIdentifier: string;
|
|
16
21
|
readonly target: IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET;
|
|
22
|
+
readonly attribute: IMBRICATE_QUERY_ATTRIBUTE;
|
|
17
23
|
readonly condition: IMBRICATE_QUERY_COMPARE_CONDITION;
|
|
18
24
|
readonly value: any;
|
|
19
25
|
};
|
|
20
|
-
export type ImbricateDocumentQueryPropertyFilter = {
|
|
21
|
-
readonly propertyIdentifier: string;
|
|
22
|
-
readonly conditions: ImbricateDocumentQueryPropertyFilterCondition[];
|
|
23
|
-
};
|
|
24
26
|
export type ImbricateDocumentQueryAnnotationFilter = {
|
|
25
27
|
readonly namespace: string;
|
|
26
28
|
readonly identifier: string;
|
|
29
|
+
readonly attribute: IMBRICATE_QUERY_ATTRIBUTE;
|
|
27
30
|
readonly condition: IMBRICATE_QUERY_COMPARE_CONDITION;
|
|
28
31
|
readonly value: any;
|
|
29
32
|
};
|
package/database/definition.js
CHANGED
|
@@ -5,11 +5,16 @@
|
|
|
5
5
|
* @description Definition
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.IMBRICATE_DATABASE_EDIT_TYPE = exports.IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET = exports.IMBRICATE_QUERY_COMPARE_CONDITION = void 0;
|
|
8
|
+
exports.IMBRICATE_DATABASE_EDIT_TYPE = exports.IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET = exports.IMBRICATE_QUERY_ATTRIBUTE = exports.IMBRICATE_QUERY_COMPARE_CONDITION = void 0;
|
|
9
9
|
var IMBRICATE_QUERY_COMPARE_CONDITION;
|
|
10
10
|
(function (IMBRICATE_QUERY_COMPARE_CONDITION) {
|
|
11
11
|
IMBRICATE_QUERY_COMPARE_CONDITION["EQUAL"] = "EQUAL";
|
|
12
|
+
IMBRICATE_QUERY_COMPARE_CONDITION["EXIST"] = "EXIST";
|
|
12
13
|
})(IMBRICATE_QUERY_COMPARE_CONDITION || (exports.IMBRICATE_QUERY_COMPARE_CONDITION = IMBRICATE_QUERY_COMPARE_CONDITION = {}));
|
|
14
|
+
var IMBRICATE_QUERY_ATTRIBUTE;
|
|
15
|
+
(function (IMBRICATE_QUERY_ATTRIBUTE) {
|
|
16
|
+
IMBRICATE_QUERY_ATTRIBUTE["VALUE"] = "VALUE";
|
|
17
|
+
})(IMBRICATE_QUERY_ATTRIBUTE || (exports.IMBRICATE_QUERY_ATTRIBUTE = IMBRICATE_QUERY_ATTRIBUTE = {}));
|
|
13
18
|
var IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET;
|
|
14
19
|
(function (IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET) {
|
|
15
20
|
IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET["PROPERTY_TYPE"] = "PROPERTY_TYPE";
|
package/database/validate.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.validateImbricateDocumentQuery = void 0;
|
|
9
|
+
const definition_1 = require("./definition");
|
|
9
10
|
/**
|
|
10
11
|
* Validate imbricate document query
|
|
11
12
|
*
|
|
@@ -18,10 +19,10 @@ const validateImbricateDocumentQuery = (query) => {
|
|
|
18
19
|
if (typeof query !== "object") {
|
|
19
20
|
return "Query must be an object";
|
|
20
21
|
}
|
|
21
|
-
if (query.limit !== undefined && typeof query.limit !== "number"
|
|
22
|
+
if (query.limit !== undefined && (typeof query.limit !== "number" || query.limit <= 0)) {
|
|
22
23
|
return "Limit must be a number greater than 0 or undefined";
|
|
23
24
|
}
|
|
24
|
-
if (query.skip !== undefined && typeof query.skip !== "number"
|
|
25
|
+
if (query.skip !== undefined && (typeof query.skip !== "number" || query.skip < 0)) {
|
|
25
26
|
return "Skip must be a number greater than or equal to 0 or undefined";
|
|
26
27
|
}
|
|
27
28
|
if (query.propertyFilters !== undefined) {
|
|
@@ -32,16 +33,17 @@ const validateImbricateDocumentQuery = (query) => {
|
|
|
32
33
|
if (typeof filter.propertyIdentifier !== "string") {
|
|
33
34
|
return "Property identifier must be a string";
|
|
34
35
|
}
|
|
35
|
-
if (
|
|
36
|
-
|
|
36
|
+
if (typeof filter.target !== "string"
|
|
37
|
+
|| !Object.values(definition_1.IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET).includes(filter.target)) {
|
|
38
|
+
return "Target must be a valid target";
|
|
37
39
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
if (typeof filter.attribute !== "string"
|
|
41
|
+
|| !Object.values(definition_1.IMBRICATE_QUERY_ATTRIBUTE).includes(filter.attribute)) {
|
|
42
|
+
return "Attribute must be a valid attribute";
|
|
43
|
+
}
|
|
44
|
+
if (typeof filter.condition !== "string"
|
|
45
|
+
|| !Object.values(definition_1.IMBRICATE_QUERY_COMPARE_CONDITION).includes(filter.condition)) {
|
|
46
|
+
return "Condition must be a valid condition";
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
}
|
|
@@ -56,8 +58,13 @@ const validateImbricateDocumentQuery = (query) => {
|
|
|
56
58
|
if (typeof filter.identifier !== "string") {
|
|
57
59
|
return "Identifier must be a string";
|
|
58
60
|
}
|
|
59
|
-
if (typeof filter.
|
|
60
|
-
|
|
61
|
+
if (typeof filter.attribute !== "string"
|
|
62
|
+
|| !Object.values(definition_1.IMBRICATE_QUERY_ATTRIBUTE).includes(filter.attribute)) {
|
|
63
|
+
return "Attribute must be a valid attribute";
|
|
64
|
+
}
|
|
65
|
+
if (typeof filter.condition !== "string"
|
|
66
|
+
|| !Object.values(definition_1.IMBRICATE_QUERY_COMPARE_CONDITION).includes(filter.condition)) {
|
|
67
|
+
return "Condition must be a valid condition";
|
|
61
68
|
}
|
|
62
69
|
}
|
|
63
70
|
}
|