@imbricate/core 3.2.0 → 3.3.0
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/schema.d.ts +19 -3
- package/database/schema.js +11 -0
- package/document/property.d.ts +16 -1
- package/document/property.js +10 -0
- package/document/validate.js +11 -2
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/origin/interface.d.ts +8 -0
- package/origin/search.d.ts +33 -0
- package/origin/search.js +14 -0
- package/package.json +1 -1
package/database/schema.d.ts
CHANGED
|
@@ -7,7 +7,22 @@ import { IMBRICATE_PROPERTY_TYPE } from "../document/property";
|
|
|
7
7
|
export type ImbricateDatabaseSchemaProperty<T extends IMBRICATE_PROPERTY_TYPE> = {
|
|
8
8
|
readonly propertyIdentifier: string;
|
|
9
9
|
} & ImbricateDatabaseSchemaPropertyForCreation<T>;
|
|
10
|
-
export type
|
|
10
|
+
export type ImbricateDatabaseSchemaPropertyOptionsReferenceDatabase = {
|
|
11
|
+
readonly originUniqueIdentifier: string;
|
|
12
|
+
readonly databaseUniqueIdentifier: string;
|
|
13
|
+
};
|
|
14
|
+
export type ImbricateDatabaseSchemaPropertyOptionsLabelOption = {
|
|
15
|
+
readonly labelIdentifier: string;
|
|
16
|
+
readonly labelName: string;
|
|
17
|
+
};
|
|
18
|
+
export type ImbricateDatabaseSchemaPropertyOptionsLabel = {
|
|
19
|
+
/**
|
|
20
|
+
* Allow multiple labels
|
|
21
|
+
*/
|
|
22
|
+
readonly allowMultiple: boolean;
|
|
23
|
+
readonly labelOptions: ImbricateDatabaseSchemaPropertyOptionsLabelOption[];
|
|
24
|
+
};
|
|
25
|
+
export type ImbricateDatabaseSchemaPropertyOptionsReference = {
|
|
11
26
|
/**
|
|
12
27
|
* Allow multiple references
|
|
13
28
|
*/
|
|
@@ -16,8 +31,9 @@ export type ImbricateDatabaseSchemaPropertyOptions<T extends IMBRICATE_PROPERTY_
|
|
|
16
31
|
* Allow references from these databases
|
|
17
32
|
* If empty, allow references from all databases
|
|
18
33
|
*/
|
|
19
|
-
readonly databases:
|
|
20
|
-
}
|
|
34
|
+
readonly databases: ImbricateDatabaseSchemaPropertyOptionsReferenceDatabase[];
|
|
35
|
+
};
|
|
36
|
+
export type ImbricateDatabaseSchemaPropertyOptions<T extends IMBRICATE_PROPERTY_TYPE> = T extends IMBRICATE_PROPERTY_TYPE.BOOLEAN ? {} : T extends IMBRICATE_PROPERTY_TYPE.STRING ? {} : T extends IMBRICATE_PROPERTY_TYPE.NUMBER ? {} : T extends IMBRICATE_PROPERTY_TYPE.MARKDOWN ? {} : T extends IMBRICATE_PROPERTY_TYPE.DATE ? {} : T extends IMBRICATE_PROPERTY_TYPE.LABEL ? ImbricateDatabaseSchemaPropertyOptionsLabel : T extends IMBRICATE_PROPERTY_TYPE.REFERENCE ? ImbricateDatabaseSchemaPropertyOptionsReference : never;
|
|
21
37
|
export type ImbricateDatabaseSchemaPropertyForCreation<T extends IMBRICATE_PROPERTY_TYPE> = {
|
|
22
38
|
readonly propertyName: string;
|
|
23
39
|
readonly propertyType: T;
|
package/database/schema.js
CHANGED
|
@@ -33,6 +33,17 @@ const validateImbricateSchemaProperty = (property) => {
|
|
|
33
33
|
if (typeof property.propertyOptions.allowMultiple !== "boolean") {
|
|
34
34
|
return "Property options allowMultiple must be a boolean";
|
|
35
35
|
}
|
|
36
|
+
if (!Array.isArray(property.propertyOptions.databases)) {
|
|
37
|
+
return "Property options databases must be an array";
|
|
38
|
+
}
|
|
39
|
+
for (const database of property.propertyOptions.databases) {
|
|
40
|
+
if (typeof database.originUniqueIdentifier !== "string") {
|
|
41
|
+
return "Database originUniqueIdentifier must be a string";
|
|
42
|
+
}
|
|
43
|
+
if (typeof database.databaseUniqueIdentifier !== "string") {
|
|
44
|
+
return "Database databaseUniqueIdentifier must be a string";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
36
47
|
break;
|
|
37
48
|
}
|
|
38
49
|
}
|
package/document/property.d.ts
CHANGED
|
@@ -23,6 +23,16 @@ export declare enum IMBRICATE_PROPERTY_TYPE {
|
|
|
23
23
|
* MARKDOWN - markdown, store as text object unique identifier. Display as markdown
|
|
24
24
|
*/
|
|
25
25
|
MARKDOWN = "MARKDOWN",
|
|
26
|
+
/**
|
|
27
|
+
* DATE - date, store as string in ISO format
|
|
28
|
+
* For example - 2000-01-01T00:00:00.000Z
|
|
29
|
+
*/
|
|
30
|
+
DATE = "DATE",
|
|
31
|
+
/**
|
|
32
|
+
* LABEL - label, store as a list of label id
|
|
33
|
+
* Note: Label is always stored as an array, even if it is a single label
|
|
34
|
+
*/
|
|
35
|
+
LABEL = "LABEL",
|
|
26
36
|
/**
|
|
27
37
|
* REFERENCE - reference, store as a list of other document unique identifier
|
|
28
38
|
* Note: Reference is always stored as an array, even if it is a single reference
|
|
@@ -44,7 +54,12 @@ export type DocumentPropertyValue<T extends IMBRICATE_PROPERTY_TYPE> = {
|
|
|
44
54
|
readonly type: T;
|
|
45
55
|
readonly value: DocumentPropertyValueObject<T>;
|
|
46
56
|
};
|
|
47
|
-
export type
|
|
57
|
+
export type DocumentPropertyValueObjectReference = {
|
|
58
|
+
readonly originUniqueIdentifier: string;
|
|
59
|
+
readonly databaseUniqueIdentifier: string;
|
|
60
|
+
readonly documentUniqueIdentifier: string;
|
|
61
|
+
};
|
|
62
|
+
export type DocumentPropertyValueObject<T extends IMBRICATE_PROPERTY_TYPE> = T extends IMBRICATE_PROPERTY_TYPE.BOOLEAN ? boolean : T extends IMBRICATE_PROPERTY_TYPE.STRING ? string : T extends IMBRICATE_PROPERTY_TYPE.NUMBER ? number : T extends IMBRICATE_PROPERTY_TYPE.MARKDOWN ? string : T extends IMBRICATE_PROPERTY_TYPE.DATE ? string : T extends IMBRICATE_PROPERTY_TYPE.LABEL ? string[] : T extends IMBRICATE_PROPERTY_TYPE.REFERENCE ? DocumentPropertyValueObjectReference[] : never;
|
|
48
63
|
/**
|
|
49
64
|
* Edit record type of the document
|
|
50
65
|
*/
|
package/document/property.js
CHANGED
|
@@ -27,6 +27,16 @@ var IMBRICATE_PROPERTY_TYPE;
|
|
|
27
27
|
* MARKDOWN - markdown, store as text object unique identifier. Display as markdown
|
|
28
28
|
*/
|
|
29
29
|
IMBRICATE_PROPERTY_TYPE["MARKDOWN"] = "MARKDOWN";
|
|
30
|
+
/**
|
|
31
|
+
* DATE - date, store as string in ISO format
|
|
32
|
+
* For example - 2000-01-01T00:00:00.000Z
|
|
33
|
+
*/
|
|
34
|
+
IMBRICATE_PROPERTY_TYPE["DATE"] = "DATE";
|
|
35
|
+
/**
|
|
36
|
+
* LABEL - label, store as a list of label id
|
|
37
|
+
* Note: Label is always stored as an array, even if it is a single label
|
|
38
|
+
*/
|
|
39
|
+
IMBRICATE_PROPERTY_TYPE["LABEL"] = "LABEL";
|
|
30
40
|
/**
|
|
31
41
|
* REFERENCE - reference, store as a list of other document unique identifier
|
|
32
42
|
* Note: Reference is always stored as an array, even if it is a single reference
|
package/document/validate.js
CHANGED
|
@@ -65,8 +65,17 @@ const validateImbricateProperties = (properties, schema) => {
|
|
|
65
65
|
return `Property ${key} value must be an array of string`;
|
|
66
66
|
}
|
|
67
67
|
for (const reference of value.value) {
|
|
68
|
-
if (typeof reference !== "
|
|
69
|
-
return `Property ${key}
|
|
68
|
+
if (typeof reference !== "object") {
|
|
69
|
+
return `Property ${key} reference must be an object`;
|
|
70
|
+
}
|
|
71
|
+
if (typeof reference.originUniqueIdentifier !== "string") {
|
|
72
|
+
return `Property ${key} reference originUniqueIdentifier must be a string`;
|
|
73
|
+
}
|
|
74
|
+
if (typeof reference.databaseUniqueIdentifier !== "string") {
|
|
75
|
+
return `Property ${key} reference databaseUniqueIdentifier must be a string`;
|
|
76
|
+
}
|
|
77
|
+
if (typeof reference.documentUniqueIdentifier !== "string") {
|
|
78
|
+
return `Property ${key} reference documentUniqueIdentifier must be a string`;
|
|
70
79
|
}
|
|
71
80
|
}
|
|
72
81
|
break;
|
package/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export * from "./loader/origin-loader";
|
|
|
19
19
|
export * from "./loader/persistence";
|
|
20
20
|
export * from "./origin/definition";
|
|
21
21
|
export * from "./origin/interface";
|
|
22
|
+
export * from "./origin/search";
|
|
22
23
|
export * from "./static/interface";
|
|
23
24
|
export * from "./static/manager";
|
|
24
25
|
export * from "./text/interface";
|
package/index.js
CHANGED
|
@@ -35,6 +35,7 @@ __exportStar(require("./loader/origin-loader"), exports);
|
|
|
35
35
|
__exportStar(require("./loader/persistence"), exports);
|
|
36
36
|
__exportStar(require("./origin/definition"), exports);
|
|
37
37
|
__exportStar(require("./origin/interface"), exports);
|
|
38
|
+
__exportStar(require("./origin/search"), exports);
|
|
38
39
|
__exportStar(require("./static/interface"), exports);
|
|
39
40
|
__exportStar(require("./static/manager"), exports);
|
|
40
41
|
__exportStar(require("./text/interface"), exports);
|
package/origin/interface.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { IImbricateDatabaseManager } from "../database/manager";
|
|
|
7
7
|
import { IImbricateStaticManager } from "../static/manager";
|
|
8
8
|
import { IImbricateTextManager } from "../text/manager";
|
|
9
9
|
import { OriginPayload } from "./definition";
|
|
10
|
+
import { ImbricateSearchItem } from "./search";
|
|
10
11
|
export interface IImbricateOrigin {
|
|
11
12
|
/**
|
|
12
13
|
* Unique identifier of the origin
|
|
@@ -46,4 +47,11 @@ export interface IImbricateOrigin {
|
|
|
46
47
|
* Example: close database connection, or close file system
|
|
47
48
|
*/
|
|
48
49
|
dispose?(): PromiseLike<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Search for items in the origin
|
|
52
|
+
*
|
|
53
|
+
* @param keyword the keyword to search
|
|
54
|
+
* @returns the search
|
|
55
|
+
*/
|
|
56
|
+
search(keyword: string): PromiseLike<ImbricateSearchItem>;
|
|
49
57
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Origin
|
|
4
|
+
* @description Search
|
|
5
|
+
*/
|
|
6
|
+
export declare enum IMBRICATE_SEARCH_TARGET_TYPE {
|
|
7
|
+
DATABASE = "DATABASE",
|
|
8
|
+
DOCUMENT = "DOCUMENT",
|
|
9
|
+
MARKDOWN = "MARKDOWN"
|
|
10
|
+
}
|
|
11
|
+
export type ImbricateSearchTargetSwitch<T extends IMBRICATE_SEARCH_TARGET_TYPE> = T extends IMBRICATE_SEARCH_TARGET_TYPE.DATABASE ? {
|
|
12
|
+
databaseUniqueIdentifier: string;
|
|
13
|
+
} : T extends IMBRICATE_SEARCH_TARGET_TYPE.DOCUMENT ? {
|
|
14
|
+
databaseUniqueIdentifier: string;
|
|
15
|
+
documentUniqueIdentifier: string;
|
|
16
|
+
} : T extends IMBRICATE_SEARCH_TARGET_TYPE.MARKDOWN ? {
|
|
17
|
+
databaseUniqueIdentifier: string;
|
|
18
|
+
documentUniqueIdentifier: string;
|
|
19
|
+
propertyUniqueIdentifier: string;
|
|
20
|
+
lineNumber: number;
|
|
21
|
+
} : never;
|
|
22
|
+
export type ImbricateSearchTarget<T extends IMBRICATE_SEARCH_TARGET_TYPE> = {
|
|
23
|
+
readonly type: T;
|
|
24
|
+
readonly target: ImbricateSearchTargetSwitch<T>;
|
|
25
|
+
};
|
|
26
|
+
export type ImbricateSearchItem = {
|
|
27
|
+
readonly target: ImbricateSearchTarget<IMBRICATE_SEARCH_TARGET_TYPE>;
|
|
28
|
+
readonly primary: string;
|
|
29
|
+
readonly secondary: string;
|
|
30
|
+
};
|
|
31
|
+
export type ImbricateSearchResult = {
|
|
32
|
+
readonly items: ImbricateSearchItem[];
|
|
33
|
+
};
|
package/origin/search.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @author WMXPY
|
|
4
|
+
* @namespace Origin
|
|
5
|
+
* @description Search
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.IMBRICATE_SEARCH_TARGET_TYPE = void 0;
|
|
9
|
+
var IMBRICATE_SEARCH_TARGET_TYPE;
|
|
10
|
+
(function (IMBRICATE_SEARCH_TARGET_TYPE) {
|
|
11
|
+
IMBRICATE_SEARCH_TARGET_TYPE["DATABASE"] = "DATABASE";
|
|
12
|
+
IMBRICATE_SEARCH_TARGET_TYPE["DOCUMENT"] = "DOCUMENT";
|
|
13
|
+
IMBRICATE_SEARCH_TARGET_TYPE["MARKDOWN"] = "MARKDOWN";
|
|
14
|
+
})(IMBRICATE_SEARCH_TARGET_TYPE || (exports.IMBRICATE_SEARCH_TARGET_TYPE = IMBRICATE_SEARCH_TARGET_TYPE = {}));
|