@imbricate/core 3.6.2 → 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.
@@ -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 DatabaseEditOperation = {
25
- readonly action: IMBRICATE_DATABASE_EDIT_TYPE;
26
- readonly value: ImbricateDatabaseSchema;
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
@@ -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 = {}));
@@ -3,9 +3,10 @@
3
3
  * @namespace Database
4
4
  * @description Interface
5
5
  */
6
+ import { ImbricateDocumentAuditOptions } from "../document/definition";
6
7
  import { IImbricateDocument } from "../document/interface";
7
8
  import { DocumentProperties } from "../document/property";
8
- import { DatabaseEditRecord, ImbricateDatabaseAuditOptions, ImbricateDocumentQuery } from "./definition";
9
+ import { DatabaseAnnotations, DatabaseEditRecord, ImbricateDatabaseAuditOptions, ImbricateDocumentQuery } from "./definition";
9
10
  import { ImbricateDatabaseSchema } from "./schema";
10
11
  export interface IImbricateDatabase {
11
12
  /**
@@ -20,6 +21,10 @@ export interface IImbricateDatabase {
20
21
  * Schema of the database
21
22
  */
22
23
  readonly schema: ImbricateDatabaseSchema;
24
+ /**
25
+ * Annotations of the database
26
+ */
27
+ readonly annotations: DatabaseAnnotations;
23
28
  /**
24
29
  * Put and replace the schema of the database
25
30
  * Existing documents will still be kept, and stays unchanged
@@ -41,7 +46,7 @@ export interface IImbricateDatabase {
41
46
  *
42
47
  * @returns a promise of the created document
43
48
  */
44
- createDocument(properties: DocumentProperties, auditOptions?: ImbricateDatabaseAuditOptions): PromiseLike<IImbricateDocument>;
49
+ createDocument(properties: DocumentProperties, auditOptions?: ImbricateDocumentAuditOptions): PromiseLike<IImbricateDocument>;
45
50
  /**
46
51
  * Get one document from the database
47
52
  *
@@ -58,6 +63,46 @@ export interface IImbricateDatabase {
58
63
  * @returns a promise of the documents in the database
59
64
  */
60
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[]>;
61
106
  /**
62
107
  * Add edit records to the database, optional
63
108
  * This method is optional, if not implemented, means the origin
@@ -3,6 +3,7 @@
3
3
  * @namespace Database
4
4
  * @description Manager
5
5
  */
6
+ import { ImbricateDatabaseAuditOptions } from "./definition";
6
7
  import { IImbricateDatabase } from "./interface";
7
8
  import { ImbricateDatabaseSchemaForCreation } from "./schema";
8
9
  export interface IImbricateDatabaseManager {
@@ -25,10 +26,16 @@ export interface IImbricateDatabaseManager {
25
26
  *
26
27
  * @param databaseName name of the database
27
28
  * @param schema schema of the database
28
- * @param uniqueIdentifier unique identifier of the database, optional
29
- * if not provided, a unique identifier will be generated
29
+ * @param auditOptions audit options of the database
30
30
  *
31
31
  * @returns a promise of the created database
32
32
  */
33
- createDatabase(databaseName: string, schema: ImbricateDatabaseSchemaForCreation, uniqueIdentifier?: string): PromiseLike<IImbricateDatabase>;
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
  }
@@ -4,18 +4,46 @@
4
4
  * @description Definition
5
5
  */
6
6
  import { ImbricateAuthor } from "../author/definition";
7
- import { DocumentPropertyKey, DocumentPropertyValue, IMBRICATE_DOCUMENT_EDIT_TYPE, IMBRICATE_PROPERTY_TYPE } from "./property";
8
- export type DocumentEditOperation = {
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
@@ -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 = {}));
@@ -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
@@ -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
- }
@@ -5,7 +5,7 @@
5
5
  * @description Property
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.IMBRICATE_DOCUMENT_EDIT_TYPE = exports.IMBRICATE_PROPERTY_TYPE = void 0;
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 = {}));
package/index.d.ts CHANGED
@@ -22,7 +22,9 @@ export * from "./loader/persistence";
22
22
  export * from "./origin/definition";
23
23
  export * from "./origin/interface";
24
24
  export * from "./origin/search";
25
+ export * from "./static/definition";
25
26
  export * from "./static/interface";
26
27
  export * from "./static/manager";
28
+ export * from "./text/definition";
27
29
  export * from "./text/interface";
28
30
  export * from "./text/manager";
package/index.js CHANGED
@@ -38,7 +38,9 @@ __exportStar(require("./loader/persistence"), exports);
38
38
  __exportStar(require("./origin/definition"), exports);
39
39
  __exportStar(require("./origin/interface"), exports);
40
40
  __exportStar(require("./origin/search"), exports);
41
+ __exportStar(require("./static/definition"), exports);
41
42
  __exportStar(require("./static/interface"), exports);
42
43
  __exportStar(require("./static/manager"), exports);
44
+ __exportStar(require("./text/definition"), exports);
43
45
  __exportStar(require("./text/interface"), exports);
44
46
  __exportStar(require("./text/manager"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imbricate/core",
3
3
  "main": "index.js",
4
- "version": "3.6.2",
4
+ "version": "3.7.0",
5
5
  "description": "Imbricate Core, Notebook for Engineers",
6
6
  "repository": {
7
7
  "type": "git",
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @namespace Static
4
+ * @description Definition
5
+ */
6
+ import { ImbricateAuthor } from "../author/definition";
7
+ export type ImbricateStaticAuditOptions = {
8
+ /**
9
+ * Static author, this is controlled an function may vary by origin
10
+ */
11
+ readonly author?: ImbricateAuthor;
12
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * @author WMXPY
4
+ * @namespace Static
5
+ * @description Definition
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,11 +3,16 @@
3
3
  * @namespace Static
4
4
  * @description Interface
5
5
  */
6
+ import { ImbricateAuthor } from "../author/definition";
6
7
  export interface IImbricateStatic {
7
8
  /**
8
9
  * Unique identifier of the static object
9
10
  */
10
11
  readonly uniqueIdentifier: string;
12
+ /**
13
+ * Author of the text object
14
+ */
15
+ readonly author?: ImbricateAuthor;
11
16
  /**
12
17
  * Get the content of the static object
13
18
  *
@@ -3,6 +3,7 @@
3
3
  * @namespace Static
4
4
  * @description Manager
5
5
  */
6
+ import { ImbricateStaticAuditOptions } from "./definition";
6
7
  import { IImbricateStatic } from "./interface";
7
8
  export interface IImbricateStaticManager {
8
9
  /**
@@ -17,10 +18,9 @@ export interface IImbricateStaticManager {
17
18
  * Patch a new static object if you want to change the content
18
19
  *
19
20
  * @param content content of the static object, encoded in base64
20
- * @param uniqueIdentifier unique identifier of the static object, optional
21
- * if not provided, a unique identifier will be generated
21
+ * @param auditOptions audit options of the static object
22
22
  *
23
23
  * @returns a promise of the created static object
24
24
  */
25
- createInBase64(content: string, uniqueIdentifier?: string): PromiseLike<IImbricateStatic>;
25
+ createInBase64(content: string, auditOptions?: ImbricateStaticAuditOptions): PromiseLike<IImbricateStatic>;
26
26
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @namespace Text
4
+ * @description Definition
5
+ */
6
+ import { ImbricateAuthor } from "../author/definition";
7
+ export type ImbricateTextAuditOptions = {
8
+ /**
9
+ * Text author, this is controlled an function may vary by origin
10
+ */
11
+ readonly author?: ImbricateAuthor;
12
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * @author WMXPY
4
+ * @namespace Text
5
+ * @description Definition
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,11 +3,16 @@
3
3
  * @namespace Text
4
4
  * @description Interface
5
5
  */
6
+ import { ImbricateAuthor } from "../author/definition";
6
7
  export interface IImbricateText {
7
8
  /**
8
9
  * Unique identifier of the text object
9
10
  */
10
11
  readonly uniqueIdentifier: string;
12
+ /**
13
+ * Author of the text object
14
+ */
15
+ readonly author?: ImbricateAuthor;
11
16
  /**
12
17
  * Get the content of the text object
13
18
  *
package/text/manager.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * @namespace Text
4
4
  * @description Manager
5
5
  */
6
+ import { ImbricateTextAuditOptions } from "./definition";
6
7
  import { IImbricateText } from "./interface";
7
8
  export interface IImbricateTextManager {
8
9
  /**
@@ -17,10 +18,9 @@ export interface IImbricateTextManager {
17
18
  * Patch a new text object if you want to change the content
18
19
  *
19
20
  * @param content content of the text
20
- * @param uniqueIdentifier unique identifier of the text object, optional
21
- * if not provided, a unique identifier will be generated
21
+ * @param auditOptions audit options of the text
22
22
  *
23
23
  * @returns a promise of the text object
24
24
  */
25
- createText(content: string, uniqueIdentifier?: string): PromiseLike<IImbricateText>;
25
+ createText(content: string, auditOptions?: ImbricateTextAuditOptions): PromiseLike<IImbricateText>;
26
26
  }