@imbricate/core 3.8.0 → 3.8.2

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.
Files changed (84) hide show
  1. package/{src/author/definition.ts → author/definition.d.ts} +0 -4
  2. package/author/definition.js +7 -0
  3. package/{src/database/definition.ts → database/definition.d.ts} +15 -51
  4. package/database/definition.js +31 -0
  5. package/{src/database/interface.ts → database/interface.d.ts} +27 -69
  6. package/database/interface.js +7 -0
  7. package/{src/database/manager.ts → database/manager.d.ts} +9 -24
  8. package/database/manager.js +7 -0
  9. package/database/schema.d.ts +70 -0
  10. package/database/schema.js +78 -0
  11. package/database/validate.d.ts +15 -0
  12. package/database/validate.js +73 -0
  13. package/{src/document/definition.ts → document/definition.d.ts} +3 -31
  14. package/document/definition.js +17 -0
  15. package/{src/document/interface.ts → document/interface.d.ts} +15 -44
  16. package/document/interface.js +7 -0
  17. package/document/property/default-value.d.ts +7 -0
  18. package/document/property/default-value.js +25 -0
  19. package/{src/document/property/definition.ts → document/property/definition.d.ts} +1 -6
  20. package/document/property/definition.js +7 -0
  21. package/document/property/primary.d.ts +8 -0
  22. package/document/property/primary.js +20 -0
  23. package/document/property/triage-base.d.ts +31 -0
  24. package/document/property/triage-base.js +85 -0
  25. package/document/property/triage-manager.d.ts +30 -0
  26. package/document/property/triage-manager.js +50 -0
  27. package/document/property/triage.d.ts +8 -0
  28. package/document/property/triage.js +13 -0
  29. package/{src/document/property.ts → document/property.d.ts} +4 -23
  30. package/document/property.js +54 -0
  31. package/document/validate.d.ts +18 -0
  32. package/{src/document/validate.ts → document/validate.js} +21 -33
  33. package/{src/index.ts → index.d.ts} +0 -2
  34. package/index.js +47 -0
  35. package/{src/loader/definition.ts → loader/definition.d.ts} +1 -5
  36. package/loader/definition.js +7 -0
  37. package/loader/origin-loader.d.ts +29 -0
  38. package/loader/origin-loader.js +104 -0
  39. package/{src/loader/persistence.ts → loader/persistence.d.ts} +3 -12
  40. package/loader/persistence.js +19 -0
  41. package/{src/origin/definition.ts → origin/definition.d.ts} +0 -1
  42. package/origin/definition.js +7 -0
  43. package/{src/origin/interface.ts → origin/interface.d.ts} +7 -18
  44. package/origin/interface.js +7 -0
  45. package/{src/origin/search.ts → origin/search.d.ts} +13 -29
  46. package/origin/search.js +14 -0
  47. package/package.json +3 -27
  48. package/{src/static/definition.ts → static/definition.d.ts} +0 -3
  49. package/static/definition.js +7 -0
  50. package/{src/static/interface.ts → static/interface.d.ts} +1 -6
  51. package/static/interface.js +7 -0
  52. package/{src/static/manager.ts → static/manager.d.ts} +4 -11
  53. package/static/manager.js +7 -0
  54. package/{src/text/definition.ts → text/definition.d.ts} +0 -3
  55. package/text/definition.js +7 -0
  56. package/{src/text/interface.ts → text/interface.d.ts} +1 -6
  57. package/text/interface.js +7 -0
  58. package/{src/text/manager.ts → text/manager.d.ts} +4 -11
  59. package/text/manager.js +7 -0
  60. package/.editorconfig +0 -10
  61. package/.gitattributes +0 -4
  62. package/.github/dependabot.yml +0 -8
  63. package/.github/workflows/ci.yml +0 -48
  64. package/.vscode/settings.json +0 -8
  65. package/.yarn/releases/yarn-4.4.0.cjs +0 -925
  66. package/.yarnrc.yml +0 -3
  67. package/babel.config.js +0 -14
  68. package/docs/README.md +0 -70
  69. package/eslint.config.mjs +0 -64
  70. package/jest.config.ts +0 -14
  71. package/src/database/schema.ts +0 -165
  72. package/src/database/validate.ts +0 -77
  73. package/src/document/property/default-value.ts +0 -26
  74. package/src/document/property/primary.ts +0 -29
  75. package/src/document/property/triage-base.ts +0 -138
  76. package/src/document/property/triage-manager.ts +0 -68
  77. package/src/document/property/triage.ts +0 -15
  78. package/src/loader/origin-loader.ts +0 -88
  79. package/test/unit/database/schema.test.ts +0 -95
  80. package/test/unit/document/property/primary.test.ts +0 -87
  81. package/test/unit/document/property/triage.test.ts +0 -64
  82. package/test/unit/document/validate.test.ts +0 -138
  83. package/test/unit/loader/definition.test.ts +0 -55
  84. package/typescript/tsconfig.build.json +0 -23
@@ -1,88 +0,0 @@
1
- /**
2
- * @author WMXPY
3
- * @namespace Loader
4
- * @description Origin Loader
5
- */
6
-
7
- import { IImbricateOrigin } from "../origin/interface";
8
- import { IMBRICATE_ORIGIN_LOAD_TYPE, ImbricateOriginPersistence, ImbricateOriginPersistenceOrigin } from "./persistence";
9
-
10
- /**
11
- * Load imbricate origin from persistence origin
12
- * This function will load the origin from the persistence origin
13
- * and initialize the origin with the payloads
14
- *
15
- * @param origin origin to persistence to load
16
- *
17
- * @returns a promise of the loaded origin
18
- * if the origin is not found, return null
19
- */
20
- export const loadImbricateOriginFromPersistenceOrigin = async (
21
- origin: ImbricateOriginPersistenceOrigin,
22
- ): Promise<IImbricateOrigin | null> => {
23
-
24
- switch (origin.originLoadType) {
25
-
26
- case IMBRICATE_ORIGIN_LOAD_TYPE.NPM_PACKAGE: {
27
-
28
- const originPackage = await import(origin.originLoadValue);
29
-
30
- if (typeof originPackage.default === "function") {
31
-
32
- const initialized = originPackage.default.call(
33
- null,
34
- origin.originPayloads,
35
- );
36
-
37
- return initialized;
38
- }
39
- break;
40
- }
41
-
42
- case IMBRICATE_ORIGIN_LOAD_TYPE.FILE_SYSTEM: {
43
-
44
- const originPackage = await import(origin.originLoadValue);
45
-
46
- if (typeof originPackage.default === "function") {
47
-
48
- const initialized = originPackage.default.call(
49
- null,
50
- origin.originPayloads,
51
- );
52
-
53
- return initialized;
54
- }
55
- break;
56
- }
57
- }
58
-
59
- return null;
60
- };
61
-
62
- /**
63
- * Load imbricate origins from persistence
64
- * This function will load all origins from the persistence
65
- * and initialize the origins with the payloads
66
- * If the origin is not found, it will be ignored
67
- *
68
- * @param persistence persistence to load origins
69
- *
70
- * @returns a promise of the loaded origins, if the origin is not found, return empty array
71
- */
72
- export const loadImbricateOriginsFromPersistence = async (
73
- persistence: ImbricateOriginPersistence,
74
- ): Promise<IImbricateOrigin[]> => {
75
-
76
- const origins: IImbricateOrigin[] = [];
77
-
78
- for (const origin of persistence.origins) {
79
-
80
- const originInstance: IImbricateOrigin | null = await loadImbricateOriginFromPersistenceOrigin(origin);
81
-
82
- if (originInstance) {
83
- origins.push(originInstance);
84
- }
85
- }
86
-
87
- return origins;
88
- };
@@ -1,95 +0,0 @@
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
- });
@@ -1,87 +0,0 @@
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
- });
@@ -1,64 +0,0 @@
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
- });
@@ -1,138 +0,0 @@
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
- });
@@ -1,55 +0,0 @@
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
- });
@@ -1,23 +0,0 @@
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
- }