@imbricate/core 3.6.4 → 3.7.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/definition.d.ts +24 -5
- package/database/definition.js +2 -0
- package/database/interface.d.ts +45 -1
- package/database/manager.d.ts +7 -0
- package/document/definition.d.ts +32 -4
- package/document/definition.js +10 -0
- package/document/interface.d.ts +30 -1
- package/document/property.d.ts +0 -6
- package/document/property.js +1 -8
- package/package.json +1 -1
package/database/definition.d.ts
CHANGED
|
@@ -19,18 +19,37 @@ export type ImbricateDocumentQuery = {
|
|
|
19
19
|
* Edit record type of the document
|
|
20
20
|
*/
|
|
21
21
|
export declare enum IMBRICATE_DATABASE_EDIT_TYPE {
|
|
22
|
-
PUT_SCHEMA = "PUT_SCHEMA"
|
|
22
|
+
PUT_SCHEMA = "PUT_SCHEMA",
|
|
23
|
+
PUT_ANNOTATION = "PUT_ANNOTATION",
|
|
24
|
+
DELETE_ANNOTATION = "DELETE_ANNOTATION"
|
|
23
25
|
}
|
|
24
|
-
export type
|
|
25
|
-
readonly
|
|
26
|
-
readonly
|
|
26
|
+
export type DatabaseEditOperationPutAnnotation = {
|
|
27
|
+
readonly annotationNamespace: string;
|
|
28
|
+
readonly annotationIdentifier: string;
|
|
29
|
+
readonly data: any;
|
|
30
|
+
};
|
|
31
|
+
export type DatabaseEditOperationDeleteAnnotation = {
|
|
32
|
+
readonly annotationNamespace: string;
|
|
33
|
+
readonly annotationIdentifier: string;
|
|
34
|
+
};
|
|
35
|
+
export type DatabaseEditOperationValue<T extends IMBRICATE_DATABASE_EDIT_TYPE> = T extends IMBRICATE_DATABASE_EDIT_TYPE.PUT_SCHEMA ? ImbricateDatabaseSchema : T extends IMBRICATE_DATABASE_EDIT_TYPE.PUT_ANNOTATION ? DatabaseEditOperationPutAnnotation : T extends IMBRICATE_DATABASE_EDIT_TYPE.DELETE_ANNOTATION ? DatabaseEditOperationDeleteAnnotation : never;
|
|
36
|
+
export type DatabaseEditOperation<T extends IMBRICATE_DATABASE_EDIT_TYPE> = {
|
|
37
|
+
readonly action: T;
|
|
38
|
+
readonly value: DatabaseEditOperationValue<T>;
|
|
27
39
|
};
|
|
28
40
|
export type DatabaseEditRecord = {
|
|
29
41
|
readonly uniqueIdentifier: string;
|
|
30
42
|
readonly editAt: Date;
|
|
31
|
-
readonly operations: DatabaseEditOperation
|
|
43
|
+
readonly operations: Array<DatabaseEditOperation<IMBRICATE_DATABASE_EDIT_TYPE>>;
|
|
32
44
|
readonly author?: ImbricateAuthor;
|
|
33
45
|
};
|
|
46
|
+
export type DatabaseAnnotations = Record<DatabaseAnnotationKey, DatabaseAnnotationValue>;
|
|
47
|
+
export type DatabaseAnnotationKey = string;
|
|
48
|
+
export type DatabaseAnnotationValue = {
|
|
49
|
+
readonly namespace: string;
|
|
50
|
+
readonly identifier: string;
|
|
51
|
+
readonly data: any;
|
|
52
|
+
};
|
|
34
53
|
export type ImbricateDatabaseAuditOptions = {
|
|
35
54
|
/**
|
|
36
55
|
* Do not add edit record, this is controlled an function may vary by origin
|
package/database/definition.js
CHANGED
|
@@ -12,4 +12,6 @@ exports.IMBRICATE_DATABASE_EDIT_TYPE = void 0;
|
|
|
12
12
|
var IMBRICATE_DATABASE_EDIT_TYPE;
|
|
13
13
|
(function (IMBRICATE_DATABASE_EDIT_TYPE) {
|
|
14
14
|
IMBRICATE_DATABASE_EDIT_TYPE["PUT_SCHEMA"] = "PUT_SCHEMA";
|
|
15
|
+
IMBRICATE_DATABASE_EDIT_TYPE["PUT_ANNOTATION"] = "PUT_ANNOTATION";
|
|
16
|
+
IMBRICATE_DATABASE_EDIT_TYPE["DELETE_ANNOTATION"] = "DELETE_ANNOTATION";
|
|
15
17
|
})(IMBRICATE_DATABASE_EDIT_TYPE || (exports.IMBRICATE_DATABASE_EDIT_TYPE = IMBRICATE_DATABASE_EDIT_TYPE = {}));
|
package/database/interface.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { ImbricateDocumentAuditOptions } from "../document/definition";
|
|
7
7
|
import { IImbricateDocument } from "../document/interface";
|
|
8
8
|
import { DocumentProperties } from "../document/property";
|
|
9
|
-
import { DatabaseEditRecord, ImbricateDatabaseAuditOptions, ImbricateDocumentQuery } from "./definition";
|
|
9
|
+
import { DatabaseAnnotations, DatabaseEditRecord, ImbricateDatabaseAuditOptions, ImbricateDocumentQuery } from "./definition";
|
|
10
10
|
import { ImbricateDatabaseSchema } from "./schema";
|
|
11
11
|
export interface IImbricateDatabase {
|
|
12
12
|
/**
|
|
@@ -21,6 +21,10 @@ export interface IImbricateDatabase {
|
|
|
21
21
|
* Schema of the database
|
|
22
22
|
*/
|
|
23
23
|
readonly schema: ImbricateDatabaseSchema;
|
|
24
|
+
/**
|
|
25
|
+
* Annotations of the database
|
|
26
|
+
*/
|
|
27
|
+
readonly annotations: DatabaseAnnotations;
|
|
24
28
|
/**
|
|
25
29
|
* Put and replace the schema of the database
|
|
26
30
|
* Existing documents will still be kept, and stays unchanged
|
|
@@ -59,6 +63,46 @@ export interface IImbricateDatabase {
|
|
|
59
63
|
* @returns a promise of the documents in the database
|
|
60
64
|
*/
|
|
61
65
|
queryDocuments(query: ImbricateDocumentQuery): PromiseLike<IImbricateDocument[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Count documents in the database
|
|
68
|
+
*
|
|
69
|
+
* @param query query of the documents
|
|
70
|
+
*
|
|
71
|
+
* @returns a promise of the count of the documents in the database
|
|
72
|
+
*/
|
|
73
|
+
countDocuments(query: ImbricateDocumentQuery): PromiseLike<number>;
|
|
74
|
+
/**
|
|
75
|
+
* Remove a document from the database
|
|
76
|
+
*
|
|
77
|
+
* @param uniqueIdentifier unique identifier of the document
|
|
78
|
+
* @param auditOptions audit options of the document
|
|
79
|
+
*/
|
|
80
|
+
removeDocument(uniqueIdentifier: string, auditOptions?: ImbricateDocumentAuditOptions): PromiseLike<void>;
|
|
81
|
+
/**
|
|
82
|
+
* put annotation to the database
|
|
83
|
+
*
|
|
84
|
+
* @param namespace namespace of the annotation
|
|
85
|
+
* @param identifier identifier of the annotation
|
|
86
|
+
* @param value value of the annotation
|
|
87
|
+
* @param auditOptions audit options of the database
|
|
88
|
+
*
|
|
89
|
+
* @returns a promise of the edit records of the database
|
|
90
|
+
* Note: if the origin supports Document Edit Record, the edit record will be added by default
|
|
91
|
+
* If you do not want to add the edit record, set `noEditRecord` to true in audit options
|
|
92
|
+
*/
|
|
93
|
+
putAnnotation(namespace: string, identifier: string, value: any, auditOptions?: ImbricateDatabaseAuditOptions): PromiseLike<DatabaseEditRecord[]>;
|
|
94
|
+
/**
|
|
95
|
+
* Delete annotation from the database
|
|
96
|
+
*
|
|
97
|
+
* @param namespace namespace of the annotation
|
|
98
|
+
* @param identifier identifier of the annotation
|
|
99
|
+
* @param auditOptions audit options of the database
|
|
100
|
+
*
|
|
101
|
+
* @returns a promise of the edit records of the database
|
|
102
|
+
* Note: if the origin supports Document Edit Record, the edit record will be added by default
|
|
103
|
+
* If you do not want to add the edit record, set `noEditRecord` to true in audit options
|
|
104
|
+
*/
|
|
105
|
+
deleteAnnotation(namespace: string, identifier: string, auditOptions?: ImbricateDatabaseAuditOptions): PromiseLike<DatabaseEditRecord[]>;
|
|
62
106
|
/**
|
|
63
107
|
* Add edit records to the database, optional
|
|
64
108
|
* This method is optional, if not implemented, means the origin
|
package/database/manager.d.ts
CHANGED
|
@@ -31,4 +31,11 @@ export interface IImbricateDatabaseManager {
|
|
|
31
31
|
* @returns a promise of the created database
|
|
32
32
|
*/
|
|
33
33
|
createDatabase(databaseName: string, schema: ImbricateDatabaseSchemaForCreation, auditOptions?: ImbricateDatabaseAuditOptions): PromiseLike<IImbricateDatabase>;
|
|
34
|
+
/**
|
|
35
|
+
* Remove a database from the origin
|
|
36
|
+
*
|
|
37
|
+
* @param uniqueIdentifier unique identifier of the database
|
|
38
|
+
* @param auditOptions audit options of deletion
|
|
39
|
+
*/
|
|
40
|
+
removeDatabase(uniqueIdentifier: string, auditOptions?: ImbricateDatabaseAuditOptions): PromiseLike<void>;
|
|
34
41
|
}
|
package/document/definition.d.ts
CHANGED
|
@@ -4,18 +4,46 @@
|
|
|
4
4
|
* @description Definition
|
|
5
5
|
*/
|
|
6
6
|
import { ImbricateAuthor } from "../author/definition";
|
|
7
|
-
import { DocumentPropertyKey, DocumentPropertyValue,
|
|
8
|
-
|
|
7
|
+
import { DocumentPropertyKey, DocumentPropertyValue, IMBRICATE_PROPERTY_TYPE } from "./property";
|
|
8
|
+
/**
|
|
9
|
+
* Edit record type of the document
|
|
10
|
+
*/
|
|
11
|
+
export declare enum IMBRICATE_DOCUMENT_EDIT_TYPE {
|
|
12
|
+
PUT_PROPERTY = "PUT_PROPERTY",
|
|
13
|
+
PUT_ANNOTATION = "PUT_ANNOTATION",
|
|
14
|
+
DELETE_ANNOTATION = "DELETE_ANNOTATION"
|
|
15
|
+
}
|
|
16
|
+
export type DocumentEditOperationValuePutProperty = {
|
|
9
17
|
readonly key: DocumentPropertyKey;
|
|
10
|
-
readonly action: IMBRICATE_DOCUMENT_EDIT_TYPE;
|
|
11
18
|
readonly value: DocumentPropertyValue<IMBRICATE_PROPERTY_TYPE>;
|
|
12
19
|
};
|
|
20
|
+
export type DocumentEditOperationPutAnnotation = {
|
|
21
|
+
readonly annotationNamespace: string;
|
|
22
|
+
readonly annotationIdentifier: string;
|
|
23
|
+
readonly data: any;
|
|
24
|
+
};
|
|
25
|
+
export type DocumentEditOperationDeleteAnnotation = {
|
|
26
|
+
readonly annotationNamespace: string;
|
|
27
|
+
readonly annotationIdentifier: string;
|
|
28
|
+
};
|
|
29
|
+
export type DocumentEditOperationValue<T extends IMBRICATE_DOCUMENT_EDIT_TYPE> = T extends IMBRICATE_DOCUMENT_EDIT_TYPE.PUT_PROPERTY ? DocumentEditOperationValuePutProperty : T extends IMBRICATE_DOCUMENT_EDIT_TYPE.PUT_ANNOTATION ? DocumentEditOperationPutAnnotation : T extends IMBRICATE_DOCUMENT_EDIT_TYPE.DELETE_ANNOTATION ? DocumentEditOperationDeleteAnnotation : never;
|
|
30
|
+
export type DocumentEditOperation<T extends IMBRICATE_DOCUMENT_EDIT_TYPE> = {
|
|
31
|
+
readonly action: T;
|
|
32
|
+
readonly value: DocumentEditOperationValue<T>;
|
|
33
|
+
};
|
|
13
34
|
export type DocumentEditRecord = {
|
|
14
35
|
readonly uniqueIdentifier: string;
|
|
15
36
|
readonly editAt: Date;
|
|
16
|
-
readonly operations: DocumentEditOperation
|
|
37
|
+
readonly operations: Array<DocumentEditOperation<IMBRICATE_DOCUMENT_EDIT_TYPE>>;
|
|
17
38
|
readonly author?: ImbricateAuthor;
|
|
18
39
|
};
|
|
40
|
+
export type DocumentAnnotations = Record<DocumentAnnotationKey, DocumentAnnotationValue>;
|
|
41
|
+
export type DocumentAnnotationKey = string;
|
|
42
|
+
export type DocumentAnnotationValue = {
|
|
43
|
+
readonly namespace: string;
|
|
44
|
+
readonly identifier: string;
|
|
45
|
+
readonly data: any;
|
|
46
|
+
};
|
|
19
47
|
export type ImbricateDocumentAuditOptions = {
|
|
20
48
|
/**
|
|
21
49
|
* Do not add edit record, this is controlled an function may vary by origin
|
package/document/definition.js
CHANGED
|
@@ -5,3 +5,13 @@
|
|
|
5
5
|
* @description Definition
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.IMBRICATE_DOCUMENT_EDIT_TYPE = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* Edit record type of the document
|
|
11
|
+
*/
|
|
12
|
+
var IMBRICATE_DOCUMENT_EDIT_TYPE;
|
|
13
|
+
(function (IMBRICATE_DOCUMENT_EDIT_TYPE) {
|
|
14
|
+
IMBRICATE_DOCUMENT_EDIT_TYPE["PUT_PROPERTY"] = "PUT_PROPERTY";
|
|
15
|
+
IMBRICATE_DOCUMENT_EDIT_TYPE["PUT_ANNOTATION"] = "PUT_ANNOTATION";
|
|
16
|
+
IMBRICATE_DOCUMENT_EDIT_TYPE["DELETE_ANNOTATION"] = "DELETE_ANNOTATION";
|
|
17
|
+
})(IMBRICATE_DOCUMENT_EDIT_TYPE || (exports.IMBRICATE_DOCUMENT_EDIT_TYPE = IMBRICATE_DOCUMENT_EDIT_TYPE = {}));
|
package/document/interface.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @namespace Document
|
|
4
4
|
* @description Interface
|
|
5
5
|
*/
|
|
6
|
-
import { DocumentEditRecord, ImbricateDocumentAuditOptions } from "./definition";
|
|
6
|
+
import { DocumentAnnotations, DocumentEditRecord, ImbricateDocumentAuditOptions } from "./definition";
|
|
7
7
|
import { DocumentProperties, DocumentPropertyKey, DocumentPropertyValue, IMBRICATE_PROPERTY_TYPE } from "./property";
|
|
8
8
|
export interface IImbricateDocument {
|
|
9
9
|
/**
|
|
@@ -14,6 +14,10 @@ export interface IImbricateDocument {
|
|
|
14
14
|
* Properties of the document
|
|
15
15
|
*/
|
|
16
16
|
readonly properties: DocumentProperties;
|
|
17
|
+
/**
|
|
18
|
+
* Annotations of the database
|
|
19
|
+
*/
|
|
20
|
+
readonly annotations: DocumentAnnotations;
|
|
17
21
|
/**
|
|
18
22
|
* Update a property from the document
|
|
19
23
|
*
|
|
@@ -37,6 +41,31 @@ export interface IImbricateDocument {
|
|
|
37
41
|
* Call `addEditRecords` to add the edit records manually.
|
|
38
42
|
*/
|
|
39
43
|
putProperties(properties: DocumentProperties, auditOptions?: ImbricateDocumentAuditOptions): PromiseLike<DocumentEditRecord[]>;
|
|
44
|
+
/**
|
|
45
|
+
* put annotation to the document
|
|
46
|
+
*
|
|
47
|
+
* @param namespace namespace of the annotation
|
|
48
|
+
* @param identifier identifier of the annotation
|
|
49
|
+
* @param value value of the annotation
|
|
50
|
+
* @param auditOptions audit options of the document
|
|
51
|
+
*
|
|
52
|
+
* @returns a promise of the edit records of the document
|
|
53
|
+
* Note: if the origin supports Document Edit Record, the edit record will be added by default
|
|
54
|
+
* If you do not want to add the edit record, set `noEditRecord` to true in audit options
|
|
55
|
+
*/
|
|
56
|
+
putAnnotation(namespace: string, identifier: string, value: any, auditOptions?: ImbricateDocumentAuditOptions): PromiseLike<DocumentEditRecord[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Delete annotation from the document
|
|
59
|
+
*
|
|
60
|
+
* @param namespace namespace of the annotation
|
|
61
|
+
* @param identifier identifier of the annotation
|
|
62
|
+
* @param auditOptions audit options of the document
|
|
63
|
+
*
|
|
64
|
+
* @returns a promise of the edit records of the document
|
|
65
|
+
* Note: if the origin supports Document Edit Record, the edit record will be added by default
|
|
66
|
+
* If you do not want to add the edit record, set `noEditRecord` to true in audit options
|
|
67
|
+
*/
|
|
68
|
+
deleteAnnotation(namespace: string, identifier: string, auditOptions?: ImbricateDocumentAuditOptions): PromiseLike<DocumentEditRecord[]>;
|
|
40
69
|
/**
|
|
41
70
|
* Add edit records to the document, optional
|
|
42
71
|
* This method is optional, if not implemented, means the origin
|
package/document/property.d.ts
CHANGED
|
@@ -69,9 +69,3 @@ export type DocumentPropertyValueObjectReference = {
|
|
|
69
69
|
readonly documentUniqueIdentifier: string;
|
|
70
70
|
};
|
|
71
71
|
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.JSON ? string : T extends IMBRICATE_PROPERTY_TYPE.IMBRISCRIPT ? string : T extends IMBRICATE_PROPERTY_TYPE.DATE ? string : T extends IMBRICATE_PROPERTY_TYPE.LABEL ? string[] : T extends IMBRICATE_PROPERTY_TYPE.REFERENCE ? DocumentPropertyValueObjectReference[] : never;
|
|
72
|
-
/**
|
|
73
|
-
* Edit record type of the document
|
|
74
|
-
*/
|
|
75
|
-
export declare enum IMBRICATE_DOCUMENT_EDIT_TYPE {
|
|
76
|
-
PUT = "PUT"
|
|
77
|
-
}
|
package/document/property.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @description Property
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
8
|
+
exports.IMBRICATE_PROPERTY_TYPE = void 0;
|
|
9
9
|
/**
|
|
10
10
|
* Document properties
|
|
11
11
|
*/
|
|
@@ -52,10 +52,3 @@ var IMBRICATE_PROPERTY_TYPE;
|
|
|
52
52
|
*/
|
|
53
53
|
IMBRICATE_PROPERTY_TYPE["REFERENCE"] = "REFERENCE";
|
|
54
54
|
})(IMBRICATE_PROPERTY_TYPE || (exports.IMBRICATE_PROPERTY_TYPE = IMBRICATE_PROPERTY_TYPE = {}));
|
|
55
|
-
/**
|
|
56
|
-
* Edit record type of the document
|
|
57
|
-
*/
|
|
58
|
-
var IMBRICATE_DOCUMENT_EDIT_TYPE;
|
|
59
|
-
(function (IMBRICATE_DOCUMENT_EDIT_TYPE) {
|
|
60
|
-
IMBRICATE_DOCUMENT_EDIT_TYPE["PUT"] = "PUT";
|
|
61
|
-
})(IMBRICATE_DOCUMENT_EDIT_TYPE || (exports.IMBRICATE_DOCUMENT_EDIT_TYPE = IMBRICATE_DOCUMENT_EDIT_TYPE = {}));
|