@imbricate/core 3.0.1 → 3.0.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/interface.d.ts +9 -0
- package/document/interface.d.ts +20 -8
- package/document/property.d.ts +12 -0
- package/document/property.js +9 -0
- package/loader/origin-loader.d.ts +20 -0
- package/loader/origin-loader.js +20 -0
- package/loader/persistance.d.ts +6 -0
- package/loader/persistance.js +6 -0
- package/origin/interface.d.ts +5 -0
- package/package.json +1 -1
package/database/interface.d.ts
CHANGED
|
@@ -12,10 +12,17 @@ export interface IImbricateDatabase {
|
|
|
12
12
|
* Unique identifier of the database
|
|
13
13
|
*/
|
|
14
14
|
readonly uniqueIdentifier: string;
|
|
15
|
+
/**
|
|
16
|
+
* Name of the database
|
|
17
|
+
*/
|
|
15
18
|
readonly databaseName: string;
|
|
19
|
+
/**
|
|
20
|
+
* Schema of the database
|
|
21
|
+
*/
|
|
16
22
|
readonly schema: ImbricateDatabaseSchema;
|
|
17
23
|
/**
|
|
18
24
|
* Create a new document in the database
|
|
25
|
+
* If origin supports Document Edit Record, the edit record will be added by default
|
|
19
26
|
*
|
|
20
27
|
* @param properties properties of the document
|
|
21
28
|
* @param uniqueIdentifier unique identifier of the document, optional
|
|
@@ -27,6 +34,8 @@ export interface IImbricateDatabase {
|
|
|
27
34
|
/**
|
|
28
35
|
* Get one document from the database
|
|
29
36
|
*
|
|
37
|
+
* @param uniqueIdentifier unique identifier of the document
|
|
38
|
+
*
|
|
30
39
|
* @returns a promise of the documents in the database, null if not found
|
|
31
40
|
*/
|
|
32
41
|
getDocument(uniqueIdentifier: string): PromiseLike<IImbricateDocument | null>;
|
package/document/interface.d.ts
CHANGED
|
@@ -15,20 +15,26 @@ export interface IImbricateDocument {
|
|
|
15
15
|
*
|
|
16
16
|
* @param key key of the property
|
|
17
17
|
* @param value value of the property
|
|
18
|
+
* @param noEditRecord do not add edit record, optional
|
|
19
|
+
* Default to false, if set to true, the edit record will not be added to the document
|
|
18
20
|
*
|
|
19
21
|
* @returns a promise of the edit records of the document
|
|
20
|
-
* Note: the edit records will not be added to the document
|
|
22
|
+
* Note: the edit records will not be added to the document if `noEditRecord` is true,
|
|
23
|
+
* Call `addEditRecords` to add the edit records manually.
|
|
21
24
|
*/
|
|
22
|
-
putProperty(key: DocumentPropertyKey, value: DocumentPropertyValue): PromiseLike<DocumentEditRecord[]>;
|
|
25
|
+
putProperty(key: DocumentPropertyKey, value: DocumentPropertyValue, noEditRecord?: boolean): PromiseLike<DocumentEditRecord[]>;
|
|
23
26
|
/**
|
|
24
27
|
* Put and replace all properties of the document
|
|
25
28
|
*
|
|
26
29
|
* @param properties properties of the document
|
|
30
|
+
* @param noEditRecord do not add edit record, optional
|
|
31
|
+
* Default to false, if set to true, the edit record will not be added to the document
|
|
27
32
|
*
|
|
28
33
|
* @returns a promise of the edit records of the document
|
|
29
|
-
* Note: the edit records will not be added to the document
|
|
34
|
+
* Note: the edit records will not be added to the document if `noEditRecord` is true,
|
|
35
|
+
* Call `addEditRecords` to add the edit records manually.
|
|
30
36
|
*/
|
|
31
|
-
putProperties(properties: DocumentProperties): PromiseLike<DocumentEditRecord[]>;
|
|
37
|
+
putProperties(properties: DocumentProperties, noEditRecord?: boolean): PromiseLike<DocumentEditRecord[]>;
|
|
32
38
|
/**
|
|
33
39
|
* Get properties from the document
|
|
34
40
|
*
|
|
@@ -36,15 +42,21 @@ export interface IImbricateDocument {
|
|
|
36
42
|
*/
|
|
37
43
|
getProperties(): PromiseLike<DocumentProperties>;
|
|
38
44
|
/**
|
|
39
|
-
* Add edit records to the document
|
|
45
|
+
* Add edit records to the document, optional
|
|
46
|
+
* This method is optional, if not implemented, means the origin
|
|
47
|
+
* 1. The origin does not support edit records
|
|
48
|
+
* 2. The origin force to add edit records when put properties
|
|
40
49
|
*
|
|
41
50
|
* @param records document edit records
|
|
42
51
|
*/
|
|
43
|
-
addEditRecords(records: DocumentEditRecord[]): PromiseLike<void>;
|
|
52
|
+
addEditRecords?(records: DocumentEditRecord[]): PromiseLike<void>;
|
|
44
53
|
/**
|
|
45
|
-
* Get edit records of the document
|
|
54
|
+
* Get edit records of the document, optional
|
|
55
|
+
* This method is optional, if not implemented, means the origin
|
|
56
|
+
* 1. The origin does not support edit records
|
|
57
|
+
* 2. The origin force to add edit records when put properties
|
|
46
58
|
*
|
|
47
59
|
* @returns a promise of the edit records of the document
|
|
48
60
|
*/
|
|
49
|
-
getEditRecords(): PromiseLike<DocumentEditRecord[]>;
|
|
61
|
+
getEditRecords?(): PromiseLike<DocumentEditRecord[]>;
|
|
50
62
|
}
|
package/document/property.d.ts
CHANGED
|
@@ -3,16 +3,28 @@
|
|
|
3
3
|
* @namespace Document
|
|
4
4
|
* @description Property
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* Document properties
|
|
8
|
+
*
|
|
9
|
+
* STRING - string, store as plain text
|
|
10
|
+
* MARKDOWN - markdown, store as text object unique identifier. Display as markdown
|
|
11
|
+
*/
|
|
6
12
|
export declare enum IMBRICATE_PROPERTY_TYPE {
|
|
7
13
|
STRING = "STRING",
|
|
8
14
|
MARKDOWN = "MARKDOWN"
|
|
9
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Document properties
|
|
18
|
+
*/
|
|
10
19
|
export type DocumentProperties = Record<DocumentPropertyKey, DocumentPropertyValue>;
|
|
11
20
|
export type DocumentPropertyKey = string;
|
|
12
21
|
export type DocumentPropertyValue = {
|
|
13
22
|
readonly type: IMBRICATE_PROPERTY_TYPE;
|
|
14
23
|
readonly value: any;
|
|
15
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Edit record type of the document
|
|
27
|
+
*/
|
|
16
28
|
export declare enum IMBRICATE_DOCUMENT_EDIT_TYPE {
|
|
17
29
|
PUT = "PUT"
|
|
18
30
|
}
|
package/document/property.js
CHANGED
|
@@ -6,11 +6,20 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.IMBRICATE_DOCUMENT_EDIT_TYPE = exports.IMBRICATE_PROPERTY_TYPE = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* Document properties
|
|
11
|
+
*
|
|
12
|
+
* STRING - string, store as plain text
|
|
13
|
+
* MARKDOWN - markdown, store as text object unique identifier. Display as markdown
|
|
14
|
+
*/
|
|
9
15
|
var IMBRICATE_PROPERTY_TYPE;
|
|
10
16
|
(function (IMBRICATE_PROPERTY_TYPE) {
|
|
11
17
|
IMBRICATE_PROPERTY_TYPE["STRING"] = "STRING";
|
|
12
18
|
IMBRICATE_PROPERTY_TYPE["MARKDOWN"] = "MARKDOWN";
|
|
13
19
|
})(IMBRICATE_PROPERTY_TYPE || (exports.IMBRICATE_PROPERTY_TYPE = IMBRICATE_PROPERTY_TYPE = {}));
|
|
20
|
+
/**
|
|
21
|
+
* Edit record type of the document
|
|
22
|
+
*/
|
|
14
23
|
var IMBRICATE_DOCUMENT_EDIT_TYPE;
|
|
15
24
|
(function (IMBRICATE_DOCUMENT_EDIT_TYPE) {
|
|
16
25
|
IMBRICATE_DOCUMENT_EDIT_TYPE["PUT"] = "PUT";
|
|
@@ -5,5 +5,25 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { IImbricateOrigin } from "../origin/interface";
|
|
7
7
|
import { ImbricateOriginPersistance, ImbricateOriginPersistanceOrigin } from "./persistance";
|
|
8
|
+
/**
|
|
9
|
+
* Load imbricate origin from persistance origin
|
|
10
|
+
* This function will load the origin from the persistance origin
|
|
11
|
+
* and initialize the origin with the payloads
|
|
12
|
+
*
|
|
13
|
+
* @param origin origin to persistance to load
|
|
14
|
+
*
|
|
15
|
+
* @returns a promise of the loaded origin
|
|
16
|
+
* if the origin is not found, return null
|
|
17
|
+
*/
|
|
8
18
|
export declare const loadImbricateOriginFromPersistanceOrigin: (origin: ImbricateOriginPersistanceOrigin) => Promise<IImbricateOrigin | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Load imbricate origins from persistance
|
|
21
|
+
* This function will load all origins from the persistance
|
|
22
|
+
* and initialize the origins with the payloads
|
|
23
|
+
* If the origin is not found, it will be ignored
|
|
24
|
+
*
|
|
25
|
+
* @param persistance persistance to load origins
|
|
26
|
+
*
|
|
27
|
+
* @returns a promise of the loaded origins, if the origin is not found, return empty array
|
|
28
|
+
*/
|
|
9
29
|
export declare const loadImbricateOriginsFromPersistance: (persistance: ImbricateOriginPersistance) => Promise<IImbricateOrigin[]>;
|
package/loader/origin-loader.js
CHANGED
|
@@ -39,6 +39,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
exports.loadImbricateOriginsFromPersistance = exports.loadImbricateOriginFromPersistanceOrigin = void 0;
|
|
41
41
|
const persistance_1 = require("./persistance");
|
|
42
|
+
/**
|
|
43
|
+
* Load imbricate origin from persistance origin
|
|
44
|
+
* This function will load the origin from the persistance origin
|
|
45
|
+
* and initialize the origin with the payloads
|
|
46
|
+
*
|
|
47
|
+
* @param origin origin to persistance to load
|
|
48
|
+
*
|
|
49
|
+
* @returns a promise of the loaded origin
|
|
50
|
+
* if the origin is not found, return null
|
|
51
|
+
*/
|
|
42
52
|
const loadImbricateOriginFromPersistanceOrigin = (origin) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
53
|
switch (origin.originLoadType) {
|
|
44
54
|
case persistance_1.IMBRICATE_ORIGIN_LOAD_TYPE.NPM_PACKAGE: {
|
|
@@ -61,6 +71,16 @@ const loadImbricateOriginFromPersistanceOrigin = (origin) => __awaiter(void 0, v
|
|
|
61
71
|
return null;
|
|
62
72
|
});
|
|
63
73
|
exports.loadImbricateOriginFromPersistanceOrigin = loadImbricateOriginFromPersistanceOrigin;
|
|
74
|
+
/**
|
|
75
|
+
* Load imbricate origins from persistance
|
|
76
|
+
* This function will load all origins from the persistance
|
|
77
|
+
* and initialize the origins with the payloads
|
|
78
|
+
* If the origin is not found, it will be ignored
|
|
79
|
+
*
|
|
80
|
+
* @param persistance persistance to load origins
|
|
81
|
+
*
|
|
82
|
+
* @returns a promise of the loaded origins, if the origin is not found, return empty array
|
|
83
|
+
*/
|
|
64
84
|
const loadImbricateOriginsFromPersistance = (persistance) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
85
|
const origins = [];
|
|
66
86
|
for (const origin of persistance.origins) {
|
package/loader/persistance.d.ts
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
* @description Persistance
|
|
5
5
|
*/
|
|
6
6
|
import { OriginPayload } from "../origin/definition";
|
|
7
|
+
/**
|
|
8
|
+
* Imbricate Origin Load Type
|
|
9
|
+
*
|
|
10
|
+
* NPM_PACKAGE - load origin from npm package, as package name
|
|
11
|
+
* FILE_SYSTEM - load origin from file system, as file path
|
|
12
|
+
*/
|
|
7
13
|
export declare enum IMBRICATE_ORIGIN_LOAD_TYPE {
|
|
8
14
|
NPM_PACKAGE = "NPM_PACKAGE",
|
|
9
15
|
FILE_SYSTEM = "FILE_SYSTEM"
|
package/loader/persistance.js
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.IMBRICATE_ORIGIN_LOAD_TYPE = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* Imbricate Origin Load Type
|
|
11
|
+
*
|
|
12
|
+
* NPM_PACKAGE - load origin from npm package, as package name
|
|
13
|
+
* FILE_SYSTEM - load origin from file system, as file path
|
|
14
|
+
*/
|
|
9
15
|
var IMBRICATE_ORIGIN_LOAD_TYPE;
|
|
10
16
|
(function (IMBRICATE_ORIGIN_LOAD_TYPE) {
|
|
11
17
|
IMBRICATE_ORIGIN_LOAD_TYPE["NPM_PACKAGE"] = "NPM_PACKAGE";
|
package/origin/interface.d.ts
CHANGED
|
@@ -39,6 +39,11 @@ export interface IImbricateOrigin {
|
|
|
39
39
|
/**
|
|
40
40
|
* Dispose the origin, optional
|
|
41
41
|
* This method will be called when the origin is no longer needed
|
|
42
|
+
*
|
|
43
|
+
* If the origin needs to dispose resources, override this method
|
|
44
|
+
* else, do not implement this method
|
|
45
|
+
*
|
|
46
|
+
* Example: close database connection, or close file system
|
|
42
47
|
*/
|
|
43
48
|
dispose?(): PromiseLike<void>;
|
|
44
49
|
}
|