@imbricate/core 3.7.3 → 3.8.1

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.
@@ -5,6 +5,28 @@
5
5
  */
6
6
  import { ImbricateAuthor } from "../author/definition";
7
7
  import { ImbricateDatabaseSchema } from "./schema";
8
+ export declare enum IMBRICATE_QUERY_COMPARE_CONDITION {
9
+ EQUAL = "EQUAL"
10
+ }
11
+ export declare enum IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET {
12
+ PROPERTY_TYPE = "PROPERTY_TYPE",
13
+ PROPERTY_VALUE = "PROPERTY_VALUE"
14
+ }
15
+ export type ImbricateDocumentQueryPropertyFilterCondition = {
16
+ readonly target: IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET;
17
+ readonly condition: IMBRICATE_QUERY_COMPARE_CONDITION;
18
+ readonly value: any;
19
+ };
20
+ export type ImbricateDocumentQueryPropertyFilter = {
21
+ readonly propertyIdentifier: string;
22
+ readonly conditions: ImbricateDocumentQueryPropertyFilterCondition[];
23
+ };
24
+ export type ImbricateDocumentQueryAnnotationFilter = {
25
+ readonly namespace: string;
26
+ readonly identifier: string;
27
+ readonly condition: IMBRICATE_QUERY_COMPARE_CONDITION;
28
+ readonly value: any;
29
+ };
8
30
  /**
9
31
  * Query of the document
10
32
  *
@@ -14,6 +36,8 @@ import { ImbricateDatabaseSchema } from "./schema";
14
36
  export type ImbricateDocumentQuery = {
15
37
  readonly limit?: number;
16
38
  readonly skip?: number;
39
+ readonly propertyFilters?: ImbricateDocumentQueryPropertyFilter[];
40
+ readonly annotationFilters?: ImbricateDocumentQueryAnnotationFilter[];
17
41
  };
18
42
  /**
19
43
  * Edit record type of the document
@@ -5,7 +5,16 @@
5
5
  * @description Definition
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.IMBRICATE_DATABASE_EDIT_TYPE = void 0;
8
+ exports.IMBRICATE_DATABASE_EDIT_TYPE = exports.IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET = exports.IMBRICATE_QUERY_COMPARE_CONDITION = void 0;
9
+ var IMBRICATE_QUERY_COMPARE_CONDITION;
10
+ (function (IMBRICATE_QUERY_COMPARE_CONDITION) {
11
+ IMBRICATE_QUERY_COMPARE_CONDITION["EQUAL"] = "EQUAL";
12
+ })(IMBRICATE_QUERY_COMPARE_CONDITION || (exports.IMBRICATE_QUERY_COMPARE_CONDITION = IMBRICATE_QUERY_COMPARE_CONDITION = {}));
13
+ var IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET;
14
+ (function (IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET) {
15
+ IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET["PROPERTY_TYPE"] = "PROPERTY_TYPE";
16
+ IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET["PROPERTY_VALUE"] = "PROPERTY_VALUE";
17
+ })(IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET || (exports.IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET = IMBRICATE_QUERY_PROPERTY_CONDITION_TARGET = {}));
9
18
  /**
10
19
  * Edit record type of the document
11
20
  */
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @namespace Database
4
+ * @description Validate
5
+ */
6
+ import { ImbricateDocumentQuery } from "./definition";
7
+ /**
8
+ * Validate imbricate document query
9
+ *
10
+ * @param query query to validate
11
+ *
12
+ * @returns a string error message if validation failed
13
+ * null if validation passed
14
+ */
15
+ export declare const validateImbricateDocumentQuery: (query: ImbricateDocumentQuery) => string | null;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ /**
3
+ * @author WMXPY
4
+ * @namespace Database
5
+ * @description Validate
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.validateImbricateDocumentQuery = void 0;
9
+ /**
10
+ * Validate imbricate document query
11
+ *
12
+ * @param query query to validate
13
+ *
14
+ * @returns a string error message if validation failed
15
+ * null if validation passed
16
+ */
17
+ const validateImbricateDocumentQuery = (query) => {
18
+ if (typeof query !== "object") {
19
+ return "Query must be an object";
20
+ }
21
+ if (query.limit !== undefined && typeof query.limit !== "number" && query.limit <= 0) {
22
+ return "Limit must be a number greater than 0 or undefined";
23
+ }
24
+ if (query.skip !== undefined && typeof query.skip !== "number" && query.skip < 0) {
25
+ return "Skip must be a number greater than or equal to 0 or undefined";
26
+ }
27
+ if (query.propertyFilters !== undefined) {
28
+ if (!Array.isArray(query.propertyFilters)) {
29
+ return "Property filters must be an array";
30
+ }
31
+ for (const filter of query.propertyFilters) {
32
+ if (typeof filter.propertyIdentifier !== "string") {
33
+ return "Property identifier must be a string";
34
+ }
35
+ if (!Array.isArray(filter.conditions)) {
36
+ return "Conditions must be an array";
37
+ }
38
+ for (const condition of filter.conditions) {
39
+ if (typeof condition.target !== "string") {
40
+ return "Target must be a string";
41
+ }
42
+ if (typeof condition.condition !== "string") {
43
+ return "Condition must be a string";
44
+ }
45
+ }
46
+ }
47
+ }
48
+ if (query.annotationFilters !== undefined) {
49
+ if (!Array.isArray(query.annotationFilters)) {
50
+ return "Annotation filters must be an array";
51
+ }
52
+ for (const filter of query.annotationFilters) {
53
+ if (typeof filter.namespace !== "string") {
54
+ return "Namespace must be a string";
55
+ }
56
+ if (typeof filter.identifier !== "string") {
57
+ return "Identifier must be a string";
58
+ }
59
+ if (typeof filter.condition !== "string") {
60
+ return "Condition must be a string";
61
+ }
62
+ }
63
+ }
64
+ return null;
65
+ };
66
+ exports.validateImbricateDocumentQuery = validateImbricateDocumentQuery;
package/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from "./database/definition";
7
7
  export * from "./database/interface";
8
8
  export * from "./database/manager";
9
9
  export * from "./database/schema";
10
+ export * from "./database/validate";
10
11
  export * from "./document/definition";
11
12
  export * from "./document/interface";
12
13
  export * from "./document/property";
package/index.js CHANGED
@@ -23,6 +23,7 @@ __exportStar(require("./database/definition"), exports);
23
23
  __exportStar(require("./database/interface"), exports);
24
24
  __exportStar(require("./database/manager"), exports);
25
25
  __exportStar(require("./database/schema"), exports);
26
+ __exportStar(require("./database/validate"), exports);
26
27
  __exportStar(require("./document/definition"), exports);
27
28
  __exportStar(require("./document/interface"), exports);
28
29
  __exportStar(require("./document/property"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imbricate/core",
3
3
  "main": "index.js",
4
- "version": "3.7.3",
4
+ "version": "3.8.1",
5
5
  "description": "Imbricate Core, Notebook for Engineers",
6
6
  "repository": {
7
7
  "type": "git",