@imbricate/core 2.6.2 → 3.0.1
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/author/definition.d.ts +1 -4
- package/database/definition.d.ts +15 -0
- package/{definition/promise.js → database/definition.js} +2 -2
- package/database/interface.d.ts +41 -0
- package/{function → database}/interface.js +1 -1
- package/database/manager.d.ts +34 -0
- package/database/manager.js +7 -0
- package/database/schema.d.ts +37 -0
- package/database/schema.js +56 -0
- package/document/definition.d.ts +18 -0
- package/{definition/listable.js → document/definition.js} +2 -2
- package/document/interface.d.ts +50 -0
- package/{trash → document}/interface.js +1 -1
- package/document/property.d.ts +18 -0
- package/document/property.js +17 -0
- package/document/validate.d.ts +17 -0
- package/document/validate.js +55 -0
- package/index.d.ts +15 -53
- package/index.js +15 -53
- package/loader/definition.d.ts +8 -0
- package/{query → loader}/definition.js +1 -1
- package/loader/origin-loader.d.ts +9 -0
- package/loader/origin-loader.js +74 -0
- package/loader/persistance.d.ts +19 -0
- package/loader/persistance.js +13 -0
- package/origin/definition.d.ts +1 -19
- package/origin/definition.js +0 -24
- package/origin/interface.d.ts +18 -43
- package/package.json +1 -1
- package/static/interface.d.ts +17 -0
- package/{script → static}/interface.js +1 -1
- package/static/manager.d.ts +26 -0
- package/{query/script.js → static/manager.js} +2 -2
- package/text/interface.d.ts +17 -0
- package/{page → text}/interface.js +1 -1
- package/text/manager.d.ts +26 -0
- package/{query/page.js → text/manager.js} +2 -2
- package/binary-storage/base.d.ts +0 -18
- package/binary-storage/base.js +0 -30
- package/binary-storage/definition.d.ts +0 -11
- package/binary-storage/definition.js +0 -15
- package/binary-storage/interface.d.ts +0 -26
- package/binary-storage/interface.js +0 -7
- package/capability/builder.d.ts +0 -15
- package/capability/builder.js +0 -37
- package/capability/create.d.ts +0 -7
- package/capability/create.js +0 -16
- package/capability/definition.d.ts +0 -16
- package/capability/definition.js +0 -25
- package/capability/validate.d.ts +0 -19
- package/capability/validate.js +0 -36
- package/collection/base.d.ts +0 -36
- package/collection/base.js +0 -60
- package/collection/definition.d.ts +0 -18
- package/collection/definition.js +0 -29
- package/collection/interface.d.ts +0 -43
- package/collection/interface.js +0 -7
- package/collection/least-common-identifier.d.ts +0 -10
- package/collection/least-common-identifier.js +0 -54
- package/collection-manager/base.d.ts +0 -26
- package/collection-manager/base.js +0 -59
- package/collection-manager/definition.d.ts +0 -15
- package/collection-manager/definition.js +0 -23
- package/collection-manager/interface.d.ts +0 -38
- package/collection-manager/interface.js +0 -7
- package/collection-operation-manager/base.d.ts +0 -18
- package/collection-operation-manager/base.js +0 -43
- package/collection-operation-manager/definition.d.ts +0 -12
- package/collection-operation-manager/definition.js +0 -17
- package/collection-operation-manager/interface.d.ts +0 -34
- package/collection-operation-manager/interface.js +0 -7
- package/definition/listable.d.ts +0 -6
- package/definition/promise.d.ts +0 -6
- package/error/imbricate-error.d.ts +0 -15
- package/error/imbricate-error.js +0 -30
- package/error/not-implemented.d.ts +0 -10
- package/error/not-implemented.js +0 -19
- package/executable-manager/base.d.ts +0 -21
- package/executable-manager/base.js +0 -44
- package/executable-manager/definition.d.ts +0 -12
- package/executable-manager/definition.js +0 -17
- package/executable-manager/interface.d.ts +0 -44
- package/executable-manager/interface.js +0 -7
- package/execute/definition.d.ts +0 -17
- package/execute/definition.js +0 -16
- package/function/base.d.ts +0 -19
- package/function/base.js +0 -30
- package/function/definition.d.ts +0 -18
- package/function/definition.js +0 -15
- package/function/interface.d.ts +0 -26
- package/operation/definition.d.ts +0 -28
- package/operation/definition.js +0 -14
- package/origin/base.d.ts +0 -29
- package/origin/base.js +0 -39
- package/origin-operation-manager/base.d.ts +0 -18
- package/origin-operation-manager/base.js +0 -43
- package/origin-operation-manager/definition.d.ts +0 -12
- package/origin-operation-manager/definition.js +0 -17
- package/origin-operation-manager/interface.d.ts +0 -34
- package/origin-operation-manager/interface.js +0 -7
- package/page/base.d.ts +0 -35
- package/page/base.js +0 -48
- package/page/definition.d.ts +0 -41
- package/page/definition.js +0 -25
- package/page/interface.d.ts +0 -55
- package/page-variant/definition.d.ts +0 -16
- package/page-variant/definition.js +0 -33
- package/page-variant/extension.d.ts +0 -7
- package/page-variant/extension.js +0 -24
- package/query/definition.d.ts +0 -14
- package/query/page.d.ts +0 -21
- package/query/script.d.ts +0 -21
- package/script/base.d.ts +0 -34
- package/script/base.js +0 -48
- package/script/definition.d.ts +0 -41
- package/script/definition.js +0 -27
- package/script/interface.d.ts +0 -54
- package/script-manager/base.d.ts +0 -31
- package/script-manager/base.js +0 -54
- package/script-manager/definition.d.ts +0 -18
- package/script-manager/definition.js +0 -29
- package/script-manager/interface.d.ts +0 -47
- package/script-manager/interface.js +0 -7
- package/script-variant/definition.d.ts +0 -22
- package/script-variant/definition.js +0 -39
- package/script-variant/extension.d.ts +0 -7
- package/script-variant/extension.js +0 -23
- package/search/prefix.d.ts +0 -7
- package/search/prefix.js +0 -37
- package/search/snippet.d.ts +0 -38
- package/search/snippet.js +0 -23
- package/trash/base.d.ts +0 -20
- package/trash/base.js +0 -36
- package/trash/definition.d.ts +0 -25
- package/trash/definition.js +0 -21
- package/trash/interface.d.ts +0 -17
package/author/definition.d.ts
CHANGED
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
* @namespace Author
|
|
4
4
|
* @description Definition
|
|
5
5
|
*/
|
|
6
|
-
export type ImbricateAuthorAttributes = Record<string, string>;
|
|
7
6
|
export type ImbricateAuthor = {
|
|
8
|
-
readonly
|
|
9
|
-
readonly displayName?: string;
|
|
7
|
+
readonly category: string;
|
|
10
8
|
readonly identifier: string;
|
|
11
|
-
readonly attributes: ImbricateAuthorAttributes;
|
|
12
9
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Database
|
|
4
|
+
* @description Definition
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Query of the document
|
|
8
|
+
*
|
|
9
|
+
* @param limit limit of the query
|
|
10
|
+
* @param skip skip of the query
|
|
11
|
+
*/
|
|
12
|
+
export type ImbricateDocumentQuery = {
|
|
13
|
+
readonly limit?: number;
|
|
14
|
+
readonly skip?: number;
|
|
15
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Database
|
|
4
|
+
* @description Interface
|
|
5
|
+
*/
|
|
6
|
+
import { IImbricateDocument } from "../document/interface";
|
|
7
|
+
import { DocumentProperties } from "../document/property";
|
|
8
|
+
import { ImbricateDocumentQuery } from "./definition";
|
|
9
|
+
import { ImbricateDatabaseSchema } from "./schema";
|
|
10
|
+
export interface IImbricateDatabase {
|
|
11
|
+
/**
|
|
12
|
+
* Unique identifier of the database
|
|
13
|
+
*/
|
|
14
|
+
readonly uniqueIdentifier: string;
|
|
15
|
+
readonly databaseName: string;
|
|
16
|
+
readonly schema: ImbricateDatabaseSchema;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new document in the database
|
|
19
|
+
*
|
|
20
|
+
* @param properties properties of the document
|
|
21
|
+
* @param uniqueIdentifier unique identifier of the document, optional
|
|
22
|
+
* if not provided, a unique identifier will be generated
|
|
23
|
+
*
|
|
24
|
+
* @returns a promise of the created document
|
|
25
|
+
*/
|
|
26
|
+
createDocument(properties: DocumentProperties, uniqueIdentifier?: string): PromiseLike<IImbricateDocument>;
|
|
27
|
+
/**
|
|
28
|
+
* Get one document from the database
|
|
29
|
+
*
|
|
30
|
+
* @returns a promise of the documents in the database, null if not found
|
|
31
|
+
*/
|
|
32
|
+
getDocument(uniqueIdentifier: string): PromiseLike<IImbricateDocument | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Query documents from the database
|
|
35
|
+
*
|
|
36
|
+
* @param query query of the documents
|
|
37
|
+
*
|
|
38
|
+
* @returns a promise of the documents in the database
|
|
39
|
+
*/
|
|
40
|
+
queryDocuments(query: ImbricateDocumentQuery): PromiseLike<IImbricateDocument[]>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Database
|
|
4
|
+
* @description Manager
|
|
5
|
+
*/
|
|
6
|
+
import { IImbricateDatabase } from "./interface";
|
|
7
|
+
import { ImbricateDatabaseSchemaForCreation } from "./schema";
|
|
8
|
+
export interface IImbricateDatabaseManager {
|
|
9
|
+
/**
|
|
10
|
+
* List all databases in the origin
|
|
11
|
+
*
|
|
12
|
+
* @returns a promise of the databases in the origin
|
|
13
|
+
*/
|
|
14
|
+
listDatabases(): PromiseLike<IImbricateDatabase[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Get one database from the origin
|
|
17
|
+
*
|
|
18
|
+
* @param uniqueIdentifier unique identifier of the database
|
|
19
|
+
*
|
|
20
|
+
* @returns a promise of the database, null if not found
|
|
21
|
+
*/
|
|
22
|
+
getDatabase(uniqueIdentifier: string): PromiseLike<IImbricateDatabase | null>;
|
|
23
|
+
/**
|
|
24
|
+
* Create a new database
|
|
25
|
+
*
|
|
26
|
+
* @param databaseName name of the database
|
|
27
|
+
* @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
|
|
30
|
+
*
|
|
31
|
+
* @returns a promise of the created database
|
|
32
|
+
*/
|
|
33
|
+
createDatabase(databaseName: string, schema: ImbricateDatabaseSchemaForCreation, uniqueIdentifier?: string): PromiseLike<IImbricateDatabase>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Database
|
|
4
|
+
* @description Schema
|
|
5
|
+
*/
|
|
6
|
+
import { IMBRICATE_PROPERTY_TYPE } from "../document/property";
|
|
7
|
+
export type ImbricateDatabaseSchemaProperty = {
|
|
8
|
+
readonly propertyIdentifier: string;
|
|
9
|
+
} & ImbricateDatabaseSchemaPropertyForCreation;
|
|
10
|
+
export type ImbricateDatabaseSchemaPropertyForCreation = {
|
|
11
|
+
readonly propertyName: string;
|
|
12
|
+
readonly propertyType: IMBRICATE_PROPERTY_TYPE;
|
|
13
|
+
};
|
|
14
|
+
export type ImbricateDatabaseSchema = {
|
|
15
|
+
readonly properties: ImbricateDatabaseSchemaProperty[];
|
|
16
|
+
};
|
|
17
|
+
export type ImbricateDatabaseSchemaForCreation = {
|
|
18
|
+
readonly properties: ImbricateDatabaseSchemaPropertyForCreation[];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Validate a schema property
|
|
22
|
+
*
|
|
23
|
+
* @param property property to validate
|
|
24
|
+
*
|
|
25
|
+
* @returns a string error message if validation failed
|
|
26
|
+
* null if validation passed
|
|
27
|
+
*/
|
|
28
|
+
export declare const validateImbricateSchemaProperty: (property: ImbricateDatabaseSchemaProperty) => string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Validate a schema
|
|
31
|
+
*
|
|
32
|
+
* @param schema database schema to validate
|
|
33
|
+
*
|
|
34
|
+
* @returns a string error message if validation failed
|
|
35
|
+
* null if validation passed
|
|
36
|
+
*/
|
|
37
|
+
export declare const validateImbricateSchema: (schema: ImbricateDatabaseSchema) => string | null;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @author WMXPY
|
|
4
|
+
* @namespace Database
|
|
5
|
+
* @description Schema
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.validateImbricateSchema = exports.validateImbricateSchemaProperty = void 0;
|
|
9
|
+
const property_1 = require("../document/property");
|
|
10
|
+
/**
|
|
11
|
+
* Validate a schema property
|
|
12
|
+
*
|
|
13
|
+
* @param property property to validate
|
|
14
|
+
*
|
|
15
|
+
* @returns a string error message if validation failed
|
|
16
|
+
* null if validation passed
|
|
17
|
+
*/
|
|
18
|
+
const validateImbricateSchemaProperty = (property) => {
|
|
19
|
+
if (typeof property.propertyIdentifier !== "string") {
|
|
20
|
+
return "Property identifier must be a string";
|
|
21
|
+
}
|
|
22
|
+
if (typeof property.propertyName !== "string") {
|
|
23
|
+
return "Property name must be a string";
|
|
24
|
+
}
|
|
25
|
+
if (!Object.values(property_1.IMBRICATE_PROPERTY_TYPE).includes(property.propertyType)) {
|
|
26
|
+
return "Property type must be a valid type";
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
exports.validateImbricateSchemaProperty = validateImbricateSchemaProperty;
|
|
31
|
+
/**
|
|
32
|
+
* Validate a schema
|
|
33
|
+
*
|
|
34
|
+
* @param schema database schema to validate
|
|
35
|
+
*
|
|
36
|
+
* @returns a string error message if validation failed
|
|
37
|
+
* null if validation passed
|
|
38
|
+
*/
|
|
39
|
+
const validateImbricateSchema = (schema) => {
|
|
40
|
+
if (!Array.isArray(schema.properties)) {
|
|
41
|
+
return "Properties must be an array";
|
|
42
|
+
}
|
|
43
|
+
const propertyNames = new Set();
|
|
44
|
+
for (const property of schema.properties) {
|
|
45
|
+
const propertyValidationResult = (0, exports.validateImbricateSchemaProperty)(property);
|
|
46
|
+
if (typeof propertyValidationResult === "string") {
|
|
47
|
+
return `Invalid property ${property.propertyName}, ${propertyValidationResult}`;
|
|
48
|
+
}
|
|
49
|
+
if (propertyNames.has(property.propertyName)) {
|
|
50
|
+
return `Duplicated property name ${property.propertyName}`;
|
|
51
|
+
}
|
|
52
|
+
propertyNames.add(property.propertyName);
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
56
|
+
exports.validateImbricateSchema = validateImbricateSchema;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Document
|
|
4
|
+
* @description Definition
|
|
5
|
+
*/
|
|
6
|
+
import { ImbricateAuthor } from "../author/definition";
|
|
7
|
+
import { DocumentPropertyKey, DocumentPropertyValue, IMBRICATE_DOCUMENT_EDIT_TYPE } from "./property";
|
|
8
|
+
export type DocumentEditOperation = {
|
|
9
|
+
readonly key: DocumentPropertyKey;
|
|
10
|
+
readonly action: IMBRICATE_DOCUMENT_EDIT_TYPE;
|
|
11
|
+
readonly value: DocumentPropertyValue;
|
|
12
|
+
};
|
|
13
|
+
export type DocumentEditRecord = {
|
|
14
|
+
readonly uniqueIdentifier: string;
|
|
15
|
+
readonly editAt: Date;
|
|
16
|
+
readonly author: ImbricateAuthor;
|
|
17
|
+
readonly operations: DocumentEditOperation[];
|
|
18
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Document
|
|
4
|
+
* @description Interface
|
|
5
|
+
*/
|
|
6
|
+
import { DocumentEditRecord } from "./definition";
|
|
7
|
+
import { DocumentProperties, DocumentPropertyKey, DocumentPropertyValue } from "./property";
|
|
8
|
+
export interface IImbricateDocument {
|
|
9
|
+
/**
|
|
10
|
+
* Unique identifier of the database
|
|
11
|
+
*/
|
|
12
|
+
readonly uniqueIdentifier: string;
|
|
13
|
+
/**
|
|
14
|
+
* Update a property from the document
|
|
15
|
+
*
|
|
16
|
+
* @param key key of the property
|
|
17
|
+
* @param value value of the property
|
|
18
|
+
*
|
|
19
|
+
* @returns a promise of the edit records of the document
|
|
20
|
+
* Note: the edit records will not be added to the document, the best practice is to call addEditRecords to add the edit records.
|
|
21
|
+
*/
|
|
22
|
+
putProperty(key: DocumentPropertyKey, value: DocumentPropertyValue): PromiseLike<DocumentEditRecord[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Put and replace all properties of the document
|
|
25
|
+
*
|
|
26
|
+
* @param properties properties of the document
|
|
27
|
+
*
|
|
28
|
+
* @returns a promise of the edit records of the document
|
|
29
|
+
* Note: the edit records will not be added to the document, the best practice is to call addEditRecords to add the edit records.
|
|
30
|
+
*/
|
|
31
|
+
putProperties(properties: DocumentProperties): PromiseLike<DocumentEditRecord[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Get properties from the document
|
|
34
|
+
*
|
|
35
|
+
* @returns a promise of the properties of the document
|
|
36
|
+
*/
|
|
37
|
+
getProperties(): PromiseLike<DocumentProperties>;
|
|
38
|
+
/**
|
|
39
|
+
* Add edit records to the document
|
|
40
|
+
*
|
|
41
|
+
* @param records document edit records
|
|
42
|
+
*/
|
|
43
|
+
addEditRecords(records: DocumentEditRecord[]): PromiseLike<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Get edit records of the document
|
|
46
|
+
*
|
|
47
|
+
* @returns a promise of the edit records of the document
|
|
48
|
+
*/
|
|
49
|
+
getEditRecords(): PromiseLike<DocumentEditRecord[]>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Document
|
|
4
|
+
* @description Property
|
|
5
|
+
*/
|
|
6
|
+
export declare enum IMBRICATE_PROPERTY_TYPE {
|
|
7
|
+
STRING = "STRING",
|
|
8
|
+
MARKDOWN = "MARKDOWN"
|
|
9
|
+
}
|
|
10
|
+
export type DocumentProperties = Record<DocumentPropertyKey, DocumentPropertyValue>;
|
|
11
|
+
export type DocumentPropertyKey = string;
|
|
12
|
+
export type DocumentPropertyValue = {
|
|
13
|
+
readonly type: IMBRICATE_PROPERTY_TYPE;
|
|
14
|
+
readonly value: any;
|
|
15
|
+
};
|
|
16
|
+
export declare enum IMBRICATE_DOCUMENT_EDIT_TYPE {
|
|
17
|
+
PUT = "PUT"
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @author WMXPY
|
|
4
|
+
* @namespace Document
|
|
5
|
+
* @description Property
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.IMBRICATE_DOCUMENT_EDIT_TYPE = exports.IMBRICATE_PROPERTY_TYPE = void 0;
|
|
9
|
+
var IMBRICATE_PROPERTY_TYPE;
|
|
10
|
+
(function (IMBRICATE_PROPERTY_TYPE) {
|
|
11
|
+
IMBRICATE_PROPERTY_TYPE["STRING"] = "STRING";
|
|
12
|
+
IMBRICATE_PROPERTY_TYPE["MARKDOWN"] = "MARKDOWN";
|
|
13
|
+
})(IMBRICATE_PROPERTY_TYPE || (exports.IMBRICATE_PROPERTY_TYPE = IMBRICATE_PROPERTY_TYPE = {}));
|
|
14
|
+
var IMBRICATE_DOCUMENT_EDIT_TYPE;
|
|
15
|
+
(function (IMBRICATE_DOCUMENT_EDIT_TYPE) {
|
|
16
|
+
IMBRICATE_DOCUMENT_EDIT_TYPE["PUT"] = "PUT";
|
|
17
|
+
})(IMBRICATE_DOCUMENT_EDIT_TYPE || (exports.IMBRICATE_DOCUMENT_EDIT_TYPE = IMBRICATE_DOCUMENT_EDIT_TYPE = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Document
|
|
4
|
+
* @description Validate
|
|
5
|
+
*/
|
|
6
|
+
import { ImbricateDatabaseSchema } from "../database/schema";
|
|
7
|
+
import { DocumentProperties } from "./property";
|
|
8
|
+
/**
|
|
9
|
+
* Validate properties with schema
|
|
10
|
+
*
|
|
11
|
+
* @param properties properties to validate
|
|
12
|
+
* @param schema database schema to validate
|
|
13
|
+
*
|
|
14
|
+
* @returns a string error message if validation failed
|
|
15
|
+
* null if validation passed
|
|
16
|
+
*/
|
|
17
|
+
export declare const validateImbricateProperties: (properties: DocumentProperties, schema: ImbricateDatabaseSchema) => string | null;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @author WMXPY
|
|
4
|
+
* @namespace Document
|
|
5
|
+
* @description Validate
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.validateImbricateProperties = void 0;
|
|
9
|
+
const property_1 = require("./property");
|
|
10
|
+
/**
|
|
11
|
+
* Validate properties with schema
|
|
12
|
+
*
|
|
13
|
+
* @param properties properties to validate
|
|
14
|
+
* @param schema database schema to validate
|
|
15
|
+
*
|
|
16
|
+
* @returns a string error message if validation failed
|
|
17
|
+
* null if validation passed
|
|
18
|
+
*/
|
|
19
|
+
const validateImbricateProperties = (properties, schema) => {
|
|
20
|
+
if (typeof properties !== "object") {
|
|
21
|
+
return "Properties must be an object";
|
|
22
|
+
}
|
|
23
|
+
const keys = Object.keys(properties);
|
|
24
|
+
for (const key of keys) {
|
|
25
|
+
const property = schema.properties.find((each) => {
|
|
26
|
+
return each.propertyName === key;
|
|
27
|
+
});
|
|
28
|
+
if (!property) {
|
|
29
|
+
return `Property ${key} not found in schema`;
|
|
30
|
+
}
|
|
31
|
+
const value = properties[key];
|
|
32
|
+
if (typeof value.type !== "string") {
|
|
33
|
+
return `Property ${key} type must be a string`;
|
|
34
|
+
}
|
|
35
|
+
if (value.type !== property.propertyType) {
|
|
36
|
+
return `Property ${key} type must be ${property.propertyType}, but got ${value.type}`;
|
|
37
|
+
}
|
|
38
|
+
switch (value.type) {
|
|
39
|
+
case property_1.IMBRICATE_PROPERTY_TYPE.STRING: {
|
|
40
|
+
if (typeof value.value !== "string") {
|
|
41
|
+
return `Property ${key} value must be a string`;
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case property_1.IMBRICATE_PROPERTY_TYPE.MARKDOWN: {
|
|
46
|
+
if (typeof value.value !== "string") {
|
|
47
|
+
return `Property ${key} value must be a string of text object reference`;
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
};
|
|
55
|
+
exports.validateImbricateProperties = validateImbricateProperties;
|
package/index.d.ts
CHANGED
|
@@ -3,58 +3,20 @@
|
|
|
3
3
|
* @description Index
|
|
4
4
|
*/
|
|
5
5
|
export * from "./author/definition";
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./
|
|
14
|
-
export * from "./
|
|
15
|
-
export * from "./
|
|
16
|
-
export * from "./
|
|
17
|
-
export * from "./collection-operation-manager/definition";
|
|
18
|
-
export * from "./collection-operation-manager/interface";
|
|
19
|
-
export * from "./collection/base";
|
|
20
|
-
export * from "./collection/definition";
|
|
21
|
-
export * from "./collection/interface";
|
|
22
|
-
export * from "./collection/least-common-identifier";
|
|
23
|
-
export * from "./definition/listable";
|
|
24
|
-
export * from "./definition/promise";
|
|
25
|
-
export * from "./error/imbricate-error";
|
|
26
|
-
export * from "./error/not-implemented";
|
|
27
|
-
export * from "./executable-manager/base";
|
|
28
|
-
export * from "./executable-manager/definition";
|
|
29
|
-
export * from "./executable-manager/interface";
|
|
30
|
-
export * from "./execute/definition";
|
|
31
|
-
export * from "./function/base";
|
|
32
|
-
export * from "./function/definition";
|
|
33
|
-
export * from "./function/interface";
|
|
34
|
-
export * from "./operation/definition";
|
|
35
|
-
export * from "./origin-operation-manager/base";
|
|
36
|
-
export * from "./origin-operation-manager/definition";
|
|
37
|
-
export * from "./origin-operation-manager/interface";
|
|
38
|
-
export * from "./origin/base";
|
|
6
|
+
export * from "./database/definition";
|
|
7
|
+
export * from "./database/interface";
|
|
8
|
+
export * from "./database/manager";
|
|
9
|
+
export * from "./database/schema";
|
|
10
|
+
export * from "./document/definition";
|
|
11
|
+
export * from "./document/interface";
|
|
12
|
+
export * from "./document/property";
|
|
13
|
+
export * from "./document/validate";
|
|
14
|
+
export * from "./loader/definition";
|
|
15
|
+
export * from "./loader/origin-loader";
|
|
16
|
+
export * from "./loader/persistance";
|
|
39
17
|
export * from "./origin/definition";
|
|
40
18
|
export * from "./origin/interface";
|
|
41
|
-
export * from "./
|
|
42
|
-
export * from "./
|
|
43
|
-
export * from "./
|
|
44
|
-
export * from "./
|
|
45
|
-
export * from "./page/interface";
|
|
46
|
-
export * from "./query/definition";
|
|
47
|
-
export * from "./query/page";
|
|
48
|
-
export * from "./query/script";
|
|
49
|
-
export * from "./script-manager/base";
|
|
50
|
-
export * from "./script-manager/definition";
|
|
51
|
-
export * from "./script-manager/interface";
|
|
52
|
-
export * from "./script-variant/definition";
|
|
53
|
-
export * from "./script/base";
|
|
54
|
-
export * from "./script/definition";
|
|
55
|
-
export * from "./script/interface";
|
|
56
|
-
export * from "./search/prefix";
|
|
57
|
-
export * from "./search/snippet";
|
|
58
|
-
export * from "./trash/base";
|
|
59
|
-
export * from "./trash/definition";
|
|
60
|
-
export * from "./trash/interface";
|
|
19
|
+
export * from "./static/interface";
|
|
20
|
+
export * from "./static/manager";
|
|
21
|
+
export * from "./text/interface";
|
|
22
|
+
export * from "./text/manager";
|
package/index.js
CHANGED
|
@@ -19,58 +19,20 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
__exportStar(require("./author/definition"), exports);
|
|
22
|
-
__exportStar(require("./
|
|
23
|
-
__exportStar(require("./
|
|
24
|
-
__exportStar(require("./
|
|
25
|
-
__exportStar(require("./
|
|
26
|
-
__exportStar(require("./
|
|
27
|
-
__exportStar(require("./
|
|
28
|
-
__exportStar(require("./
|
|
29
|
-
__exportStar(require("./
|
|
30
|
-
__exportStar(require("./
|
|
31
|
-
__exportStar(require("./
|
|
32
|
-
__exportStar(require("./
|
|
33
|
-
__exportStar(require("./collection-operation-manager/definition"), exports);
|
|
34
|
-
__exportStar(require("./collection-operation-manager/interface"), exports);
|
|
35
|
-
__exportStar(require("./collection/base"), exports);
|
|
36
|
-
__exportStar(require("./collection/definition"), exports);
|
|
37
|
-
__exportStar(require("./collection/interface"), exports);
|
|
38
|
-
__exportStar(require("./collection/least-common-identifier"), exports);
|
|
39
|
-
__exportStar(require("./definition/listable"), exports);
|
|
40
|
-
__exportStar(require("./definition/promise"), exports);
|
|
41
|
-
__exportStar(require("./error/imbricate-error"), exports);
|
|
42
|
-
__exportStar(require("./error/not-implemented"), exports);
|
|
43
|
-
__exportStar(require("./executable-manager/base"), exports);
|
|
44
|
-
__exportStar(require("./executable-manager/definition"), exports);
|
|
45
|
-
__exportStar(require("./executable-manager/interface"), exports);
|
|
46
|
-
__exportStar(require("./execute/definition"), exports);
|
|
47
|
-
__exportStar(require("./function/base"), exports);
|
|
48
|
-
__exportStar(require("./function/definition"), exports);
|
|
49
|
-
__exportStar(require("./function/interface"), exports);
|
|
50
|
-
__exportStar(require("./operation/definition"), exports);
|
|
51
|
-
__exportStar(require("./origin-operation-manager/base"), exports);
|
|
52
|
-
__exportStar(require("./origin-operation-manager/definition"), exports);
|
|
53
|
-
__exportStar(require("./origin-operation-manager/interface"), exports);
|
|
54
|
-
__exportStar(require("./origin/base"), exports);
|
|
22
|
+
__exportStar(require("./database/definition"), exports);
|
|
23
|
+
__exportStar(require("./database/interface"), exports);
|
|
24
|
+
__exportStar(require("./database/manager"), exports);
|
|
25
|
+
__exportStar(require("./database/schema"), exports);
|
|
26
|
+
__exportStar(require("./document/definition"), exports);
|
|
27
|
+
__exportStar(require("./document/interface"), exports);
|
|
28
|
+
__exportStar(require("./document/property"), exports);
|
|
29
|
+
__exportStar(require("./document/validate"), exports);
|
|
30
|
+
__exportStar(require("./loader/definition"), exports);
|
|
31
|
+
__exportStar(require("./loader/origin-loader"), exports);
|
|
32
|
+
__exportStar(require("./loader/persistance"), exports);
|
|
55
33
|
__exportStar(require("./origin/definition"), exports);
|
|
56
34
|
__exportStar(require("./origin/interface"), exports);
|
|
57
|
-
__exportStar(require("./
|
|
58
|
-
__exportStar(require("./
|
|
59
|
-
__exportStar(require("./
|
|
60
|
-
__exportStar(require("./
|
|
61
|
-
__exportStar(require("./page/interface"), exports);
|
|
62
|
-
__exportStar(require("./query/definition"), exports);
|
|
63
|
-
__exportStar(require("./query/page"), exports);
|
|
64
|
-
__exportStar(require("./query/script"), exports);
|
|
65
|
-
__exportStar(require("./script-manager/base"), exports);
|
|
66
|
-
__exportStar(require("./script-manager/definition"), exports);
|
|
67
|
-
__exportStar(require("./script-manager/interface"), exports);
|
|
68
|
-
__exportStar(require("./script-variant/definition"), exports);
|
|
69
|
-
__exportStar(require("./script/base"), exports);
|
|
70
|
-
__exportStar(require("./script/definition"), exports);
|
|
71
|
-
__exportStar(require("./script/interface"), exports);
|
|
72
|
-
__exportStar(require("./search/prefix"), exports);
|
|
73
|
-
__exportStar(require("./search/snippet"), exports);
|
|
74
|
-
__exportStar(require("./trash/base"), exports);
|
|
75
|
-
__exportStar(require("./trash/definition"), exports);
|
|
76
|
-
__exportStar(require("./trash/interface"), exports);
|
|
35
|
+
__exportStar(require("./static/interface"), exports);
|
|
36
|
+
__exportStar(require("./static/manager"), exports);
|
|
37
|
+
__exportStar(require("./text/interface"), exports);
|
|
38
|
+
__exportStar(require("./text/manager"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Loader
|
|
4
|
+
* @description Definition
|
|
5
|
+
*/
|
|
6
|
+
import { OriginPayload } from "../origin/definition";
|
|
7
|
+
import { IImbricateOrigin } from "../origin/interface";
|
|
8
|
+
export type ImbricateOriginLoader = (payload: OriginPayload) => IImbricateOrigin;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Loader
|
|
4
|
+
* @description Origin Loader
|
|
5
|
+
*/
|
|
6
|
+
import { IImbricateOrigin } from "../origin/interface";
|
|
7
|
+
import { ImbricateOriginPersistance, ImbricateOriginPersistanceOrigin } from "./persistance";
|
|
8
|
+
export declare const loadImbricateOriginFromPersistanceOrigin: (origin: ImbricateOriginPersistanceOrigin) => Promise<IImbricateOrigin | null>;
|
|
9
|
+
export declare const loadImbricateOriginsFromPersistance: (persistance: ImbricateOriginPersistance) => Promise<IImbricateOrigin[]>;
|