@imbricate/core 3.0.3 → 3.0.4
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 +18 -0
- package/database/definition.js +8 -0
- package/database/interface.d.ts +31 -1
- package/package.json +1 -1
package/database/definition.d.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* @namespace Database
|
|
4
4
|
* @description Definition
|
|
5
5
|
*/
|
|
6
|
+
import { ImbricateAuthor } from "../author/definition";
|
|
7
|
+
import { ImbricateDatabaseSchema } from "./schema";
|
|
6
8
|
/**
|
|
7
9
|
* Query of the document
|
|
8
10
|
*
|
|
@@ -13,3 +15,19 @@ export type ImbricateDocumentQuery = {
|
|
|
13
15
|
readonly limit?: number;
|
|
14
16
|
readonly skip?: number;
|
|
15
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Edit record type of the document
|
|
20
|
+
*/
|
|
21
|
+
export declare enum IMBRICATE_DATABASE_EDIT_TYPE {
|
|
22
|
+
PUT_SCHEMA = "PUT_SCHEMA"
|
|
23
|
+
}
|
|
24
|
+
export type DatabaseEditOperation = {
|
|
25
|
+
readonly action: IMBRICATE_DATABASE_EDIT_TYPE;
|
|
26
|
+
readonly value: ImbricateDatabaseSchema;
|
|
27
|
+
};
|
|
28
|
+
export type DatabaseEditRecord = {
|
|
29
|
+
readonly uniqueIdentifier: string;
|
|
30
|
+
readonly editAt: Date;
|
|
31
|
+
readonly author: ImbricateAuthor;
|
|
32
|
+
readonly operations: DatabaseEditOperation[];
|
|
33
|
+
};
|
package/database/definition.js
CHANGED
|
@@ -5,3 +5,11 @@
|
|
|
5
5
|
* @description Definition
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.IMBRICATE_DATABASE_EDIT_TYPE = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* Edit record type of the document
|
|
11
|
+
*/
|
|
12
|
+
var IMBRICATE_DATABASE_EDIT_TYPE;
|
|
13
|
+
(function (IMBRICATE_DATABASE_EDIT_TYPE) {
|
|
14
|
+
IMBRICATE_DATABASE_EDIT_TYPE["PUT_SCHEMA"] = "PUT_SCHEMA";
|
|
15
|
+
})(IMBRICATE_DATABASE_EDIT_TYPE || (exports.IMBRICATE_DATABASE_EDIT_TYPE = IMBRICATE_DATABASE_EDIT_TYPE = {}));
|
package/database/interface.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { IImbricateDocument } from "../document/interface";
|
|
7
7
|
import { DocumentProperties } from "../document/property";
|
|
8
|
-
import { ImbricateDocumentQuery } from "./definition";
|
|
8
|
+
import { DatabaseEditRecord, ImbricateDocumentQuery } from "./definition";
|
|
9
9
|
import { ImbricateDatabaseSchema } from "./schema";
|
|
10
10
|
export interface IImbricateDatabase {
|
|
11
11
|
/**
|
|
@@ -20,6 +20,18 @@ export interface IImbricateDatabase {
|
|
|
20
20
|
* Schema of the database
|
|
21
21
|
*/
|
|
22
22
|
readonly schema: ImbricateDatabaseSchema;
|
|
23
|
+
/**
|
|
24
|
+
* Put and replace the schema of the database
|
|
25
|
+
* Existing documents will still be kept, and stays unchanged
|
|
26
|
+
*
|
|
27
|
+
* @param schema schema of the database
|
|
28
|
+
* @param noEditRecord do not add edit record, optional
|
|
29
|
+
*
|
|
30
|
+
* @returns a promise of the updated schema
|
|
31
|
+
* Note: if the origin supports Document Edit Record, the edit record will be added by default
|
|
32
|
+
* If you do not want to add the edit record, set `noEditRecord` to true
|
|
33
|
+
*/
|
|
34
|
+
putSchema(schema: ImbricateDatabaseSchema, noEditRecord?: boolean): PromiseLike<void>;
|
|
23
35
|
/**
|
|
24
36
|
* Create a new document in the database
|
|
25
37
|
* If origin supports Document Edit Record, the edit record will be added by default
|
|
@@ -47,4 +59,22 @@ export interface IImbricateDatabase {
|
|
|
47
59
|
* @returns a promise of the documents in the database
|
|
48
60
|
*/
|
|
49
61
|
queryDocuments(query: ImbricateDocumentQuery): PromiseLike<IImbricateDocument[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Add edit records to the database, optional
|
|
64
|
+
* This method is optional, if not implemented, means the origin
|
|
65
|
+
* 1. The origin does not support edit records
|
|
66
|
+
* 2. The origin force to add edit records when put properties
|
|
67
|
+
*
|
|
68
|
+
* @param records database edit records
|
|
69
|
+
*/
|
|
70
|
+
addEditRecords?(records: DatabaseEditRecord[]): PromiseLike<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Get edit records of the database, optional
|
|
73
|
+
* This method is optional, if not implemented, means the origin
|
|
74
|
+
* 1. The origin does not support edit records
|
|
75
|
+
* 2. The origin force to add edit records when put properties
|
|
76
|
+
*
|
|
77
|
+
* @returns a promise of the edit records of the database
|
|
78
|
+
*/
|
|
79
|
+
getEditRecords?(): PromiseLike<DatabaseEditRecord[]>;
|
|
50
80
|
}
|