@imbricate/core 3.0.1 → 3.0.3
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/definition.d.ts +2 -2
- package/document/interface.d.ts +21 -9
- package/document/property/definition.d.ts +7 -0
- package/document/property/definition.js +7 -0
- package/document/property/triage-base.d.ts +24 -0
- package/document/property/triage-base.js +56 -0
- package/document/property/triage-manager.d.ts +30 -0
- package/document/property/triage-manager.js +50 -0
- package/document/property/triage.d.ts +8 -0
- package/document/property/triage.js +13 -0
- package/document/property.d.ts +16 -3
- package/document/property.js +9 -0
- package/index.d.ts +3 -0
- package/index.js +3 -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/definition.d.ts
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* @description Definition
|
|
5
5
|
*/
|
|
6
6
|
import { ImbricateAuthor } from "../author/definition";
|
|
7
|
-
import { DocumentPropertyKey, DocumentPropertyValue, IMBRICATE_DOCUMENT_EDIT_TYPE } from "./property";
|
|
7
|
+
import { DocumentPropertyKey, DocumentPropertyValue, IMBRICATE_DOCUMENT_EDIT_TYPE, IMBRICATE_PROPERTY_TYPE } from "./property";
|
|
8
8
|
export type DocumentEditOperation = {
|
|
9
9
|
readonly key: DocumentPropertyKey;
|
|
10
10
|
readonly action: IMBRICATE_DOCUMENT_EDIT_TYPE;
|
|
11
|
-
readonly value: DocumentPropertyValue
|
|
11
|
+
readonly value: DocumentPropertyValue<IMBRICATE_PROPERTY_TYPE>;
|
|
12
12
|
};
|
|
13
13
|
export type DocumentEditRecord = {
|
|
14
14
|
readonly uniqueIdentifier: string;
|
package/document/interface.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @description Interface
|
|
5
5
|
*/
|
|
6
6
|
import { DocumentEditRecord } from "./definition";
|
|
7
|
-
import { DocumentProperties, DocumentPropertyKey, DocumentPropertyValue } from "./property";
|
|
7
|
+
import { DocumentProperties, DocumentPropertyKey, DocumentPropertyValue, IMBRICATE_PROPERTY_TYPE } from "./property";
|
|
8
8
|
export interface IImbricateDocument {
|
|
9
9
|
/**
|
|
10
10
|
* Unique identifier of the database
|
|
@@ -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<IMBRICATE_PROPERTY_TYPE>, 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
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Document_Property
|
|
4
|
+
* @description Definition
|
|
5
|
+
*/
|
|
6
|
+
import { DocumentPropertyKey, DocumentPropertyValue, IMBRICATE_PROPERTY_TYPE } from "../property";
|
|
7
|
+
export type DocumentPropertyTriageFunction<T extends IMBRICATE_PROPERTY_TYPE, Result> = (propertyKey: DocumentPropertyKey, value: DocumentPropertyValue<T>) => Result;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Document_Property
|
|
4
|
+
* @description Triage Base
|
|
5
|
+
*/
|
|
6
|
+
import { DocumentProperties, DocumentPropertyKey, IMBRICATE_PROPERTY_TYPE } from "../property";
|
|
7
|
+
import { DocumentPropertyTriageFunction } from "./definition";
|
|
8
|
+
export declare class ImbricateDocumentPropertyTriageBase<Result> {
|
|
9
|
+
private readonly _triageFunctionsByKey;
|
|
10
|
+
private readonly _triageFunctionsByType;
|
|
11
|
+
protected constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Set triage function for property key,
|
|
14
|
+
* This action will override document value based triage functions
|
|
15
|
+
*
|
|
16
|
+
* @param propertyKey property key
|
|
17
|
+
* @param triageFunction triage function
|
|
18
|
+
* @returns triage manager
|
|
19
|
+
*/
|
|
20
|
+
forPropertyKey<T extends IMBRICATE_PROPERTY_TYPE>(propertyKey: DocumentPropertyKey, triageFunction: DocumentPropertyTriageFunction<T, Result>): this;
|
|
21
|
+
forString(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.STRING, Result>): this;
|
|
22
|
+
forMarkdown(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.MARKDOWN, Result>): this;
|
|
23
|
+
protected _collect(properties: DocumentProperties): Map<DocumentPropertyKey, Result>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @author WMXPY
|
|
4
|
+
* @namespace Document_Property
|
|
5
|
+
* @description Triage Base
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ImbricateDocumentPropertyTriageBase = void 0;
|
|
9
|
+
const property_1 = require("../property");
|
|
10
|
+
class ImbricateDocumentPropertyTriageBase {
|
|
11
|
+
constructor() {
|
|
12
|
+
this._triageFunctionsByKey = new Map();
|
|
13
|
+
this._triageFunctionsByType = new Map();
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Set triage function for property key,
|
|
17
|
+
* This action will override document value based triage functions
|
|
18
|
+
*
|
|
19
|
+
* @param propertyKey property key
|
|
20
|
+
* @param triageFunction triage function
|
|
21
|
+
* @returns triage manager
|
|
22
|
+
*/
|
|
23
|
+
forPropertyKey(propertyKey, triageFunction) {
|
|
24
|
+
this._triageFunctionsByKey.set(propertyKey, triageFunction);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
forString(triageFunction) {
|
|
28
|
+
this._triageFunctionsByType.set(property_1.IMBRICATE_PROPERTY_TYPE.STRING, triageFunction);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
forMarkdown(triageFunction) {
|
|
32
|
+
this._triageFunctionsByType.set(property_1.IMBRICATE_PROPERTY_TYPE.MARKDOWN, triageFunction);
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
_collect(properties) {
|
|
36
|
+
const keys = Object.keys(properties);
|
|
37
|
+
const result = new Map();
|
|
38
|
+
for (const key of keys) {
|
|
39
|
+
const property = properties[key];
|
|
40
|
+
const triageFunction = this._triageFunctionsByKey.get(key);
|
|
41
|
+
if (typeof triageFunction === "function") {
|
|
42
|
+
const value = triageFunction(key, property);
|
|
43
|
+
result.set(key, value);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const typeFunction = this._triageFunctionsByType.get(property.type);
|
|
47
|
+
if (typeof typeFunction === "function") {
|
|
48
|
+
const value = typeFunction(key, property);
|
|
49
|
+
result.set(key, value);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.ImbricateDocumentPropertyTriageBase = ImbricateDocumentPropertyTriageBase;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Document_Property
|
|
4
|
+
* @description Triage Manager
|
|
5
|
+
*/
|
|
6
|
+
import { DocumentProperties, DocumentPropertyKey } from "../property";
|
|
7
|
+
import { ImbricateDocumentPropertyTriageBase } from "./triage-base";
|
|
8
|
+
export declare class ImbricateDocumentPropertyTriageManager<Result> extends ImbricateDocumentPropertyTriageBase<Result> {
|
|
9
|
+
static create<Result>(properties: DocumentProperties): ImbricateDocumentPropertyTriageManager<Result>;
|
|
10
|
+
private readonly _properties;
|
|
11
|
+
private constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Collect the result as array
|
|
14
|
+
*
|
|
15
|
+
* @returns collected result as array
|
|
16
|
+
*/
|
|
17
|
+
collectAsArray(): Result[];
|
|
18
|
+
/**
|
|
19
|
+
* Collect the result as map
|
|
20
|
+
*
|
|
21
|
+
* @returns collected result as map
|
|
22
|
+
*/
|
|
23
|
+
collectAsMap(): Map<DocumentPropertyKey, Result>;
|
|
24
|
+
/**
|
|
25
|
+
* Collect the result as object
|
|
26
|
+
*
|
|
27
|
+
* @returns collected result as object
|
|
28
|
+
*/
|
|
29
|
+
collectAsObject(): Record<DocumentPropertyKey, Result>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @author WMXPY
|
|
4
|
+
* @namespace Document_Property
|
|
5
|
+
* @description Triage Manager
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ImbricateDocumentPropertyTriageManager = void 0;
|
|
9
|
+
const triage_base_1 = require("./triage-base");
|
|
10
|
+
class ImbricateDocumentPropertyTriageManager extends triage_base_1.ImbricateDocumentPropertyTriageBase {
|
|
11
|
+
static create(properties) {
|
|
12
|
+
return new ImbricateDocumentPropertyTriageManager(properties);
|
|
13
|
+
}
|
|
14
|
+
constructor(properties) {
|
|
15
|
+
super();
|
|
16
|
+
this._properties = properties;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Collect the result as array
|
|
20
|
+
*
|
|
21
|
+
* @returns collected result as array
|
|
22
|
+
*/
|
|
23
|
+
collectAsArray() {
|
|
24
|
+
const result = super._collect(this._properties);
|
|
25
|
+
return Array.from(result.values());
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Collect the result as map
|
|
29
|
+
*
|
|
30
|
+
* @returns collected result as map
|
|
31
|
+
*/
|
|
32
|
+
collectAsMap() {
|
|
33
|
+
return super._collect(this._properties);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Collect the result as object
|
|
37
|
+
*
|
|
38
|
+
* @returns collected result as object
|
|
39
|
+
*/
|
|
40
|
+
collectAsObject() {
|
|
41
|
+
const result = super._collect(this._properties);
|
|
42
|
+
const keys = Array.from(result.keys());
|
|
43
|
+
const object = {};
|
|
44
|
+
for (const key of keys) {
|
|
45
|
+
object[key] = result.get(key);
|
|
46
|
+
}
|
|
47
|
+
return object;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.ImbricateDocumentPropertyTriageManager = ImbricateDocumentPropertyTriageManager;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Document_Property
|
|
4
|
+
* @description Triage
|
|
5
|
+
*/
|
|
6
|
+
import { DocumentProperties } from "../property";
|
|
7
|
+
import { ImbricateDocumentPropertyTriageManager } from "./triage-manager";
|
|
8
|
+
export declare const triageImbricateDocumentProperties: <Result>(properties: DocumentProperties) => ImbricateDocumentPropertyTriageManager<Result>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @author WMXPY
|
|
4
|
+
* @namespace Document_Property
|
|
5
|
+
* @description Triage
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.triageImbricateDocumentProperties = void 0;
|
|
9
|
+
const triage_manager_1 = require("./triage-manager");
|
|
10
|
+
const triageImbricateDocumentProperties = (properties) => {
|
|
11
|
+
return triage_manager_1.ImbricateDocumentPropertyTriageManager.create(properties);
|
|
12
|
+
};
|
|
13
|
+
exports.triageImbricateDocumentProperties = triageImbricateDocumentProperties;
|
package/document/property.d.ts
CHANGED
|
@@ -3,16 +3,29 @@
|
|
|
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
|
}
|
|
10
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Document properties
|
|
18
|
+
*/
|
|
19
|
+
export type DocumentProperties = Record<DocumentPropertyKey, DocumentPropertyValue<IMBRICATE_PROPERTY_TYPE>>;
|
|
11
20
|
export type DocumentPropertyKey = string;
|
|
12
|
-
export type DocumentPropertyValue = {
|
|
21
|
+
export type DocumentPropertyValue<T extends IMBRICATE_PROPERTY_TYPE> = {
|
|
13
22
|
readonly type: IMBRICATE_PROPERTY_TYPE;
|
|
14
|
-
readonly value:
|
|
23
|
+
readonly value: DocumentPropertyValueObject<T>;
|
|
15
24
|
};
|
|
25
|
+
export type DocumentPropertyValueObject<T extends IMBRICATE_PROPERTY_TYPE> = T extends IMBRICATE_PROPERTY_TYPE.STRING ? string : T extends IMBRICATE_PROPERTY_TYPE.MARKDOWN ? string : never;
|
|
26
|
+
/**
|
|
27
|
+
* Edit record type of the document
|
|
28
|
+
*/
|
|
16
29
|
export declare enum IMBRICATE_DOCUMENT_EDIT_TYPE {
|
|
17
30
|
PUT = "PUT"
|
|
18
31
|
}
|
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";
|
package/index.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ export * from "./database/schema";
|
|
|
10
10
|
export * from "./document/definition";
|
|
11
11
|
export * from "./document/interface";
|
|
12
12
|
export * from "./document/property";
|
|
13
|
+
export * from "./document/property/definition";
|
|
14
|
+
export * from "./document/property/triage";
|
|
15
|
+
export * from "./document/property/triage-manager";
|
|
13
16
|
export * from "./document/validate";
|
|
14
17
|
export * from "./loader/definition";
|
|
15
18
|
export * from "./loader/origin-loader";
|
package/index.js
CHANGED
|
@@ -26,6 +26,9 @@ __exportStar(require("./database/schema"), exports);
|
|
|
26
26
|
__exportStar(require("./document/definition"), exports);
|
|
27
27
|
__exportStar(require("./document/interface"), exports);
|
|
28
28
|
__exportStar(require("./document/property"), exports);
|
|
29
|
+
__exportStar(require("./document/property/definition"), exports);
|
|
30
|
+
__exportStar(require("./document/property/triage"), exports);
|
|
31
|
+
__exportStar(require("./document/property/triage-manager"), exports);
|
|
29
32
|
__exportStar(require("./document/validate"), exports);
|
|
30
33
|
__exportStar(require("./loader/definition"), exports);
|
|
31
34
|
__exportStar(require("./loader/origin-loader"), exports);
|
|
@@ -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
|
}
|