@imbricate/core 3.7.3 → 3.8.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/.editorconfig +10 -0
- package/.gitattributes +4 -0
- package/.github/dependabot.yml +8 -0
- package/.github/workflows/ci.yml +48 -0
- package/.vscode/settings.json +8 -0
- package/.yarn/releases/yarn-4.4.0.cjs +925 -0
- package/.yarnrc.yml +3 -0
- package/babel.config.js +14 -0
- package/docs/README.md +70 -0
- package/eslint.config.mjs +64 -0
- package/jest.config.ts +14 -0
- package/package.json +27 -3
- package/{author/definition.d.ts → src/author/definition.ts} +4 -0
- package/{database/definition.d.ts → src/database/definition.ts} +67 -4
- package/{database/interface.d.ts → src/database/interface.ts} +69 -27
- package/{database/manager.d.ts → src/database/manager.ts} +24 -9
- package/src/database/schema.ts +165 -0
- package/src/database/validate.ts +77 -0
- package/{document/definition.d.ts → src/document/definition.ts} +31 -3
- package/{document/interface.d.ts → src/document/interface.ts} +44 -15
- package/src/document/property/default-value.ts +26 -0
- package/{document/property/definition.d.ts → src/document/property/definition.ts} +6 -1
- package/src/document/property/primary.ts +29 -0
- package/src/document/property/triage-base.ts +138 -0
- package/src/document/property/triage-manager.ts +68 -0
- package/src/document/property/triage.ts +15 -0
- package/{document/property.d.ts → src/document/property.ts} +23 -4
- package/{document/validate.js → src/document/validate.ts} +33 -21
- package/{index.d.ts → src/index.ts} +3 -0
- package/{loader/definition.d.ts → src/loader/definition.ts} +5 -1
- package/src/loader/origin-loader.ts +88 -0
- package/{loader/persistence.d.ts → src/loader/persistence.ts} +12 -3
- package/{origin/definition.d.ts → src/origin/definition.ts} +1 -0
- package/{origin/interface.d.ts → src/origin/interface.ts} +18 -7
- package/{origin/search.d.ts → src/origin/search.ts} +29 -13
- package/{static/definition.d.ts → src/static/definition.ts} +3 -0
- package/{static/interface.d.ts → src/static/interface.ts} +6 -1
- package/{static/manager.d.ts → src/static/manager.ts} +11 -4
- package/{text/definition.d.ts → src/text/definition.ts} +3 -0
- package/{text/interface.d.ts → src/text/interface.ts} +6 -1
- package/{text/manager.d.ts → src/text/manager.ts} +11 -4
- package/test/unit/database/schema.test.ts +95 -0
- package/test/unit/document/property/primary.test.ts +87 -0
- package/test/unit/document/property/triage.test.ts +64 -0
- package/test/unit/document/validate.test.ts +138 -0
- package/test/unit/loader/definition.test.ts +55 -0
- package/typescript/tsconfig.build.json +23 -0
- package/author/definition.js +0 -7
- package/database/definition.js +0 -17
- package/database/interface.js +0 -7
- package/database/manager.js +0 -7
- package/database/schema.d.ts +0 -70
- package/database/schema.js +0 -78
- package/document/definition.js +0 -17
- package/document/interface.js +0 -7
- package/document/property/default-value.d.ts +0 -7
- package/document/property/default-value.js +0 -25
- package/document/property/definition.js +0 -7
- package/document/property/primary.d.ts +0 -8
- package/document/property/primary.js +0 -20
- package/document/property/triage-base.d.ts +0 -31
- package/document/property/triage-base.js +0 -85
- package/document/property/triage-manager.d.ts +0 -30
- package/document/property/triage-manager.js +0 -50
- package/document/property/triage.d.ts +0 -8
- package/document/property/triage.js +0 -13
- package/document/property.js +0 -54
- package/document/validate.d.ts +0 -18
- package/index.js +0 -46
- package/loader/definition.js +0 -7
- package/loader/origin-loader.d.ts +0 -29
- package/loader/origin-loader.js +0 -104
- package/loader/persistence.js +0 -19
- package/origin/definition.js +0 -7
- package/origin/interface.js +0 -7
- package/origin/search.js +0 -14
- package/static/definition.js +0 -7
- package/static/interface.js +0 -7
- package/static/manager.js +0 -7
- package/text/definition.js +0 -7
- package/text/interface.js +0 -7
- package/text/manager.js +0 -7
|
@@ -3,19 +3,24 @@
|
|
|
3
3
|
* @namespace Text
|
|
4
4
|
* @description Interface
|
|
5
5
|
*/
|
|
6
|
+
|
|
6
7
|
import { ImbricateAuthor } from "../author/definition";
|
|
8
|
+
|
|
7
9
|
export interface IImbricateText {
|
|
10
|
+
|
|
8
11
|
/**
|
|
9
12
|
* Unique identifier of the text object
|
|
10
13
|
*/
|
|
11
14
|
readonly uniqueIdentifier: string;
|
|
15
|
+
|
|
12
16
|
/**
|
|
13
17
|
* Author of the text object
|
|
14
18
|
*/
|
|
15
19
|
readonly author?: ImbricateAuthor;
|
|
20
|
+
|
|
16
21
|
/**
|
|
17
22
|
* Get the content of the text object
|
|
18
|
-
*
|
|
23
|
+
*
|
|
19
24
|
* @returns a promise of the content of the text object
|
|
20
25
|
*/
|
|
21
26
|
getContent(): PromiseLike<string>;
|
|
@@ -3,24 +3,31 @@
|
|
|
3
3
|
* @namespace Text
|
|
4
4
|
* @description Manager
|
|
5
5
|
*/
|
|
6
|
+
|
|
6
7
|
import { ImbricateTextAuditOptions } from "./definition";
|
|
7
8
|
import { IImbricateText } from "./interface";
|
|
9
|
+
|
|
8
10
|
export interface IImbricateTextManager {
|
|
11
|
+
|
|
9
12
|
/**
|
|
10
13
|
* Get the text object from the origin
|
|
11
|
-
*
|
|
14
|
+
*
|
|
12
15
|
* @returns a promise of the text object, null if not found
|
|
13
16
|
*/
|
|
14
17
|
getText(uniqueIdentifier: string): PromiseLike<IImbricateText | null>;
|
|
18
|
+
|
|
15
19
|
/**
|
|
16
20
|
* Create a new text object in the origin
|
|
17
21
|
* Text object is immutable, once created, it cannot be changed
|
|
18
22
|
* Patch a new text object if you want to change the content
|
|
19
|
-
*
|
|
23
|
+
*
|
|
20
24
|
* @param content content of the text
|
|
21
25
|
* @param auditOptions audit options of the text
|
|
22
|
-
*
|
|
26
|
+
*
|
|
23
27
|
* @returns a promise of the text object
|
|
24
28
|
*/
|
|
25
|
-
createText(
|
|
29
|
+
createText(
|
|
30
|
+
content: string,
|
|
31
|
+
auditOptions?: ImbricateTextAuditOptions,
|
|
32
|
+
): PromiseLike<IImbricateText>;
|
|
26
33
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Database
|
|
4
|
+
* @description Schema
|
|
5
|
+
* @override Unit Test
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { validateImbricateSchema } from "../../../src/database/schema";
|
|
9
|
+
import { IMBRICATE_PROPERTY_TYPE } from "../../../src/document/property";
|
|
10
|
+
|
|
11
|
+
describe("Given [Database Schema] methods", (): void => {
|
|
12
|
+
|
|
13
|
+
test("should be able to validate schema", (): void => {
|
|
14
|
+
|
|
15
|
+
const testSchema: any = {
|
|
16
|
+
properties: [
|
|
17
|
+
{
|
|
18
|
+
propertyIdentifier: "test",
|
|
19
|
+
propertyName: "test",
|
|
20
|
+
propertyType: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const result: string | null = validateImbricateSchema(testSchema);
|
|
26
|
+
|
|
27
|
+
expect(result).toBeNull();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("should be able to invalidate schema - properties not array", (): void => {
|
|
31
|
+
|
|
32
|
+
const testSchema: any = {
|
|
33
|
+
properties: "test",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const result: string | null = validateImbricateSchema(testSchema);
|
|
37
|
+
|
|
38
|
+
expect(typeof result).toStrictEqual("string");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("should be able to invalidate schema - invalid property", (): void => {
|
|
42
|
+
|
|
43
|
+
const testSchema: any = {
|
|
44
|
+
properties: [
|
|
45
|
+
{
|
|
46
|
+
propertyIdentifier: "test",
|
|
47
|
+
propertyName: "test",
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const result: string | null = validateImbricateSchema(testSchema);
|
|
53
|
+
|
|
54
|
+
expect(typeof result).toStrictEqual("string");
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("should be able to invalidate schema - invalid property type", (): void => {
|
|
58
|
+
|
|
59
|
+
const testSchema: any = {
|
|
60
|
+
properties: [
|
|
61
|
+
{
|
|
62
|
+
propertyIdentifier: "test",
|
|
63
|
+
propertyName: "test",
|
|
64
|
+
propertyType: "INVALID",
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const result: string | null = validateImbricateSchema(testSchema);
|
|
70
|
+
|
|
71
|
+
expect(typeof result).toStrictEqual("string");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test("should be able to invalidate schema - duplicate property name", (): void => {
|
|
75
|
+
|
|
76
|
+
const testSchema: any = {
|
|
77
|
+
properties: [
|
|
78
|
+
{
|
|
79
|
+
propertyIdentifier: "test",
|
|
80
|
+
propertyName: "test",
|
|
81
|
+
propertyType: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
propertyIdentifier: "test",
|
|
85
|
+
propertyName: "test",
|
|
86
|
+
propertyType: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const result: string | null = validateImbricateSchema(testSchema);
|
|
92
|
+
|
|
93
|
+
expect(typeof result).toStrictEqual("string");
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Document_Property
|
|
4
|
+
* @description Primary
|
|
5
|
+
* @override Unit Test
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { DocumentProperties, IMBRICATE_PROPERTY_TYPE, ImbricateDatabaseSchema, findPrimaryProperty } from "../../../../src";
|
|
9
|
+
|
|
10
|
+
describe("Given [Document-Property-Primary] helper methods", (): void => {
|
|
11
|
+
|
|
12
|
+
it("should be able to find primary property", (): void => {
|
|
13
|
+
|
|
14
|
+
const schema: ImbricateDatabaseSchema = {
|
|
15
|
+
properties: [
|
|
16
|
+
{
|
|
17
|
+
propertyIdentifier: "test",
|
|
18
|
+
propertyName: "test",
|
|
19
|
+
propertyType: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
20
|
+
propertyOptions: {},
|
|
21
|
+
isPrimaryKey: true,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const properties: DocumentProperties = {
|
|
27
|
+
test: {
|
|
28
|
+
type: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
29
|
+
value: "test",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const result = findPrimaryProperty(schema, properties);
|
|
34
|
+
|
|
35
|
+
expect(result).toStrictEqual({
|
|
36
|
+
type: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
37
|
+
value: "test",
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should be able to find primary property - null", (): void => {
|
|
42
|
+
|
|
43
|
+
const schema: ImbricateDatabaseSchema = {
|
|
44
|
+
properties: [
|
|
45
|
+
{
|
|
46
|
+
propertyIdentifier: "test",
|
|
47
|
+
propertyName: "test",
|
|
48
|
+
propertyType: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
49
|
+
propertyOptions: {},
|
|
50
|
+
isPrimaryKey: true,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const properties: DocumentProperties = {};
|
|
56
|
+
|
|
57
|
+
const result = findPrimaryProperty(schema, properties);
|
|
58
|
+
|
|
59
|
+
expect(result).toBeNull();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("should be able to find primary property - not primary", (): void => {
|
|
63
|
+
|
|
64
|
+
const schema: ImbricateDatabaseSchema = {
|
|
65
|
+
properties: [
|
|
66
|
+
{
|
|
67
|
+
propertyIdentifier: "test",
|
|
68
|
+
propertyName: "test",
|
|
69
|
+
propertyType: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
70
|
+
propertyOptions: {},
|
|
71
|
+
isPrimaryKey: false,
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const properties: DocumentProperties = {
|
|
77
|
+
test: {
|
|
78
|
+
type: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
79
|
+
value: "test",
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const result = findPrimaryProperty(schema, properties);
|
|
84
|
+
|
|
85
|
+
expect(result).toBeNull();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Document_Property
|
|
4
|
+
* @description Triage
|
|
5
|
+
* @override Unit Test
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { DocumentProperties, IMBRICATE_PROPERTY_TYPE, triageImbricateDocumentProperties } from "../../../../src";
|
|
9
|
+
|
|
10
|
+
describe("Given [Document-Property-Triage] helper methods", (): void => {
|
|
11
|
+
|
|
12
|
+
it("should be able to triage single property", (): void => {
|
|
13
|
+
|
|
14
|
+
const properties: DocumentProperties = {
|
|
15
|
+
test: {
|
|
16
|
+
type: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
17
|
+
value: "test",
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const result = triageImbricateDocumentProperties(properties)
|
|
22
|
+
.forString(() => "string")
|
|
23
|
+
.collectAsArray();
|
|
24
|
+
|
|
25
|
+
expect(result).toStrictEqual(["string"]);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should be able to triage single property - not match", (): void => {
|
|
29
|
+
|
|
30
|
+
const properties: DocumentProperties = {
|
|
31
|
+
test: {
|
|
32
|
+
type: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
33
|
+
value: "test",
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const result = triageImbricateDocumentProperties(properties)
|
|
38
|
+
.forNumber(() => "number")
|
|
39
|
+
.collectAsArray();
|
|
40
|
+
|
|
41
|
+
expect(result).toStrictEqual([]);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("should be able to triage multiple property", (): void => {
|
|
45
|
+
|
|
46
|
+
const properties: DocumentProperties = {
|
|
47
|
+
test: {
|
|
48
|
+
type: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
49
|
+
value: "test",
|
|
50
|
+
},
|
|
51
|
+
number: {
|
|
52
|
+
type: IMBRICATE_PROPERTY_TYPE.NUMBER,
|
|
53
|
+
value: 1,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const result = triageImbricateDocumentProperties(properties)
|
|
58
|
+
.forString(() => "string")
|
|
59
|
+
.forNumber(() => "number")
|
|
60
|
+
.collectAsArray();
|
|
61
|
+
|
|
62
|
+
expect(result).toStrictEqual(["string", "number"]);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Document
|
|
4
|
+
* @description Validate
|
|
5
|
+
* @override Unit Test
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { IMBRICATE_PROPERTY_TYPE, validateImbricateProperties } from "../../../src";
|
|
9
|
+
|
|
10
|
+
describe("Given [Document Validate] methods", (): void => {
|
|
11
|
+
|
|
12
|
+
test("should be able to validate property", (): void => {
|
|
13
|
+
|
|
14
|
+
const testSchema: any = {
|
|
15
|
+
properties: [
|
|
16
|
+
{
|
|
17
|
+
propertyIdentifier: "test",
|
|
18
|
+
propertyName: "test",
|
|
19
|
+
propertyType: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const result: string | null = validateImbricateProperties({
|
|
25
|
+
test: {
|
|
26
|
+
type: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
27
|
+
value: "test",
|
|
28
|
+
},
|
|
29
|
+
}, testSchema as any);
|
|
30
|
+
|
|
31
|
+
expect(result).toBeNull();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("should be able to invalidate property - not object", (): void => {
|
|
35
|
+
|
|
36
|
+
const testSchema: any = {
|
|
37
|
+
properties: [
|
|
38
|
+
{
|
|
39
|
+
propertyIdentifier: "test",
|
|
40
|
+
propertyName: "test",
|
|
41
|
+
propertyType: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const result: string | null = validateImbricateProperties("test" as any, testSchema as any);
|
|
47
|
+
|
|
48
|
+
expect(typeof result).toStrictEqual("string");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("should be able to invalidate property - invalid property", (): void => {
|
|
52
|
+
|
|
53
|
+
const testSchema: any = {
|
|
54
|
+
properties: [
|
|
55
|
+
{
|
|
56
|
+
propertyIdentifier: "test",
|
|
57
|
+
propertyName: "test",
|
|
58
|
+
propertyType: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const result: string | null = validateImbricateProperties({
|
|
64
|
+
notExist: {
|
|
65
|
+
type: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
66
|
+
value: "test",
|
|
67
|
+
},
|
|
68
|
+
}, testSchema as any);
|
|
69
|
+
|
|
70
|
+
expect(typeof result).toStrictEqual("string");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("should be able to invalidate property - invalid property type", (): void => {
|
|
74
|
+
|
|
75
|
+
const testSchema: any = {
|
|
76
|
+
properties: [
|
|
77
|
+
{
|
|
78
|
+
propertyIdentifier: "test",
|
|
79
|
+
propertyName: "test",
|
|
80
|
+
propertyType: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const result: string | null = validateImbricateProperties({
|
|
86
|
+
test: {
|
|
87
|
+
type: "INVALID" as any,
|
|
88
|
+
value: "test",
|
|
89
|
+
},
|
|
90
|
+
}, testSchema as any);
|
|
91
|
+
|
|
92
|
+
expect(typeof result).toStrictEqual("string");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("should be able to invalidate property - invalid property value", (): void => {
|
|
96
|
+
|
|
97
|
+
const testSchema: any = {
|
|
98
|
+
properties: [
|
|
99
|
+
{
|
|
100
|
+
propertyIdentifier: "test",
|
|
101
|
+
propertyName: "test",
|
|
102
|
+
propertyType: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const result: string | null = validateImbricateProperties({
|
|
108
|
+
test: {
|
|
109
|
+
type: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
110
|
+
value: 123 as any,
|
|
111
|
+
},
|
|
112
|
+
}, testSchema as any);
|
|
113
|
+
|
|
114
|
+
expect(typeof result).toStrictEqual("string");
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test("should be able to invalidate property - invalid property value type", (): void => {
|
|
118
|
+
|
|
119
|
+
const testSchema: any = {
|
|
120
|
+
properties: [
|
|
121
|
+
{
|
|
122
|
+
propertyIdentifier: "test",
|
|
123
|
+
propertyName: "test",
|
|
124
|
+
propertyType: IMBRICATE_PROPERTY_TYPE.MARKDOWN,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const result: string | null = validateImbricateProperties({
|
|
130
|
+
test: {
|
|
131
|
+
type: IMBRICATE_PROPERTY_TYPE.STRING,
|
|
132
|
+
value: 123 as any,
|
|
133
|
+
},
|
|
134
|
+
}, testSchema as any);
|
|
135
|
+
|
|
136
|
+
expect(typeof result).toStrictEqual("string");
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Loader
|
|
4
|
+
* @description Definition
|
|
5
|
+
* @override Unit Test
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { IMBRICATE_ORIGIN_LOAD_TYPE, loadImbricateOriginsFromPersistence } from "../../../src";
|
|
9
|
+
import { ImbricateOriginLoader } from "../../../src/loader/definition";
|
|
10
|
+
|
|
11
|
+
describe("Given [Origin Loader] methods", (): void => {
|
|
12
|
+
|
|
13
|
+
test("should be able to initialize npm package", async (): Promise<void> => {
|
|
14
|
+
|
|
15
|
+
let mockPayload: any;
|
|
16
|
+
|
|
17
|
+
jest.mock("mock-origin", () => {
|
|
18
|
+
|
|
19
|
+
const loader: ImbricateOriginLoader = (payload: any) => {
|
|
20
|
+
|
|
21
|
+
mockPayload = payload;
|
|
22
|
+
return {
|
|
23
|
+
name: "Mock",
|
|
24
|
+
} as any;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return loader;
|
|
28
|
+
}, {
|
|
29
|
+
virtual: true,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const origins = await loadImbricateOriginsFromPersistence({
|
|
33
|
+
origins: [
|
|
34
|
+
{
|
|
35
|
+
originLoadType: IMBRICATE_ORIGIN_LOAD_TYPE.NPM_PACKAGE,
|
|
36
|
+
originLoadValue: "mock-origin",
|
|
37
|
+
|
|
38
|
+
originName: "Mock",
|
|
39
|
+
originPayloads: {
|
|
40
|
+
hello: "world",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
expect(origins).toHaveLength(1);
|
|
47
|
+
expect(mockPayload).toEqual({
|
|
48
|
+
hello: "world",
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
afterEach(() => {
|
|
53
|
+
jest.clearAllMocks();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES6",
|
|
4
|
+
"lib": [
|
|
5
|
+
"esnext"
|
|
6
|
+
],
|
|
7
|
+
"outDir": "../app",
|
|
8
|
+
"downlevelIteration": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"module": "CommonJS",
|
|
14
|
+
"moduleResolution": "node",
|
|
15
|
+
"isolatedModules": true
|
|
16
|
+
},
|
|
17
|
+
"include": [
|
|
18
|
+
"../src/**/*.ts",
|
|
19
|
+
],
|
|
20
|
+
"exclude": [
|
|
21
|
+
"node_modules"
|
|
22
|
+
]
|
|
23
|
+
}
|
package/author/definition.js
DELETED
package/database/definition.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @author WMXPY
|
|
4
|
-
* @namespace Database
|
|
5
|
-
* @description Definition
|
|
6
|
-
*/
|
|
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["PUT_ANNOTATION"] = "PUT_ANNOTATION";
|
|
16
|
-
IMBRICATE_DATABASE_EDIT_TYPE["DELETE_ANNOTATION"] = "DELETE_ANNOTATION";
|
|
17
|
-
})(IMBRICATE_DATABASE_EDIT_TYPE || (exports.IMBRICATE_DATABASE_EDIT_TYPE = IMBRICATE_DATABASE_EDIT_TYPE = {}));
|
package/database/interface.js
DELETED
package/database/manager.js
DELETED
package/database/schema.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author WMXPY
|
|
3
|
-
* @namespace Database
|
|
4
|
-
* @description Schema
|
|
5
|
-
*/
|
|
6
|
-
import { IMBRICATE_PROPERTY_TYPE } from "../document/property";
|
|
7
|
-
export type ImbricateDatabaseSchemaProperty<T extends IMBRICATE_PROPERTY_TYPE> = {
|
|
8
|
-
readonly propertyIdentifier: string;
|
|
9
|
-
} & ImbricateDatabaseSchemaPropertyForCreation<T>;
|
|
10
|
-
export type ImbricateDatabaseSchemaPropertyOptionsReferenceDatabase = {
|
|
11
|
-
readonly originUniqueIdentifier: string;
|
|
12
|
-
readonly databaseUniqueIdentifier: string;
|
|
13
|
-
};
|
|
14
|
-
export type ImbricateDatabaseSchemaPropertyOptionsLabelOption = {
|
|
15
|
-
readonly labelIdentifier: string;
|
|
16
|
-
readonly labelName: string;
|
|
17
|
-
readonly labelColor: string;
|
|
18
|
-
};
|
|
19
|
-
export type ImbricateDatabaseSchemaPropertyOptionsLabel = {
|
|
20
|
-
/**
|
|
21
|
-
* Allow multiple labels
|
|
22
|
-
*/
|
|
23
|
-
readonly allowMultiple: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Label Options
|
|
26
|
-
*/
|
|
27
|
-
readonly labelOptions: ImbricateDatabaseSchemaPropertyOptionsLabelOption[];
|
|
28
|
-
};
|
|
29
|
-
export type ImbricateDatabaseSchemaPropertyOptionsReference = {
|
|
30
|
-
/**
|
|
31
|
-
* Allow multiple references
|
|
32
|
-
*/
|
|
33
|
-
readonly allowMultiple: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Allow references from these databases
|
|
36
|
-
* If empty, allow references from all databases
|
|
37
|
-
*/
|
|
38
|
-
readonly databases: ImbricateDatabaseSchemaPropertyOptionsReferenceDatabase[];
|
|
39
|
-
};
|
|
40
|
-
export type ImbricateDatabaseSchemaPropertyOptions<T extends IMBRICATE_PROPERTY_TYPE> = T extends IMBRICATE_PROPERTY_TYPE.BOOLEAN ? {} : T extends IMBRICATE_PROPERTY_TYPE.STRING ? {} : T extends IMBRICATE_PROPERTY_TYPE.NUMBER ? {} : T extends IMBRICATE_PROPERTY_TYPE.MARKDOWN ? {} : T extends IMBRICATE_PROPERTY_TYPE.JSON ? {} : T extends IMBRICATE_PROPERTY_TYPE.IMBRISCRIPT ? {} : T extends IMBRICATE_PROPERTY_TYPE.DATE ? {} : T extends IMBRICATE_PROPERTY_TYPE.LABEL ? ImbricateDatabaseSchemaPropertyOptionsLabel : T extends IMBRICATE_PROPERTY_TYPE.REFERENCE ? ImbricateDatabaseSchemaPropertyOptionsReference : never;
|
|
41
|
-
export type ImbricateDatabaseSchemaPropertyForCreation<T extends IMBRICATE_PROPERTY_TYPE> = {
|
|
42
|
-
readonly propertyName: string;
|
|
43
|
-
readonly propertyType: T;
|
|
44
|
-
readonly propertyOptions: ImbricateDatabaseSchemaPropertyOptions<T>;
|
|
45
|
-
readonly isPrimaryKey?: boolean;
|
|
46
|
-
};
|
|
47
|
-
export type ImbricateDatabaseSchema = {
|
|
48
|
-
readonly properties: Array<ImbricateDatabaseSchemaProperty<IMBRICATE_PROPERTY_TYPE>>;
|
|
49
|
-
};
|
|
50
|
-
export type ImbricateDatabaseSchemaForCreation = {
|
|
51
|
-
readonly properties: Array<ImbricateDatabaseSchemaPropertyForCreation<IMBRICATE_PROPERTY_TYPE>>;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Validate a schema property
|
|
55
|
-
*
|
|
56
|
-
* @param property property to validate
|
|
57
|
-
*
|
|
58
|
-
* @returns a string error message if validation failed
|
|
59
|
-
* null if validation passed
|
|
60
|
-
*/
|
|
61
|
-
export declare const validateImbricateSchemaProperty: (property: ImbricateDatabaseSchemaProperty<IMBRICATE_PROPERTY_TYPE>) => string | null;
|
|
62
|
-
/**
|
|
63
|
-
* Validate a schema
|
|
64
|
-
*
|
|
65
|
-
* @param schema database schema to validate
|
|
66
|
-
*
|
|
67
|
-
* @returns a string error message if validation failed
|
|
68
|
-
* null if validation passed
|
|
69
|
-
*/
|
|
70
|
-
export declare const validateImbricateSchema: (schema: ImbricateDatabaseSchema) => string | null;
|