@imbricate/core 3.7.2 → 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.
Files changed (82) hide show
  1. package/.editorconfig +10 -0
  2. package/.gitattributes +4 -0
  3. package/.github/dependabot.yml +8 -0
  4. package/.github/workflows/ci.yml +48 -0
  5. package/.vscode/settings.json +8 -0
  6. package/.yarn/releases/yarn-4.4.0.cjs +925 -0
  7. package/.yarnrc.yml +3 -0
  8. package/babel.config.js +14 -0
  9. package/docs/README.md +70 -0
  10. package/eslint.config.mjs +64 -0
  11. package/jest.config.ts +14 -0
  12. package/package.json +27 -3
  13. package/{author/definition.d.ts → src/author/definition.ts} +4 -0
  14. package/{database/definition.d.ts → src/database/definition.ts} +67 -4
  15. package/{database/interface.d.ts → src/database/interface.ts} +69 -27
  16. package/{database/manager.d.ts → src/database/manager.ts} +24 -9
  17. package/src/database/schema.ts +165 -0
  18. package/src/database/validate.ts +77 -0
  19. package/{document/definition.d.ts → src/document/definition.ts} +31 -3
  20. package/{document/interface.d.ts → src/document/interface.ts} +44 -15
  21. package/src/document/property/default-value.ts +26 -0
  22. package/{document/property/definition.d.ts → src/document/property/definition.ts} +6 -1
  23. package/src/document/property/primary.ts +29 -0
  24. package/src/document/property/triage-base.ts +138 -0
  25. package/src/document/property/triage-manager.ts +68 -0
  26. package/src/document/property/triage.ts +15 -0
  27. package/{document/property.d.ts → src/document/property.ts} +23 -4
  28. package/{document/validate.js → src/document/validate.ts} +33 -21
  29. package/{index.d.ts → src/index.ts} +3 -0
  30. package/{loader/definition.d.ts → src/loader/definition.ts} +5 -1
  31. package/src/loader/origin-loader.ts +88 -0
  32. package/{loader/persistence.d.ts → src/loader/persistence.ts} +12 -3
  33. package/{origin/definition.d.ts → src/origin/definition.ts} +1 -0
  34. package/{origin/interface.d.ts → src/origin/interface.ts} +18 -7
  35. package/{origin/search.d.ts → src/origin/search.ts} +29 -13
  36. package/{static/definition.d.ts → src/static/definition.ts} +3 -0
  37. package/{static/interface.d.ts → src/static/interface.ts} +6 -1
  38. package/{static/manager.d.ts → src/static/manager.ts} +11 -4
  39. package/{text/definition.d.ts → src/text/definition.ts} +3 -0
  40. package/{text/interface.d.ts → src/text/interface.ts} +6 -1
  41. package/{text/manager.d.ts → src/text/manager.ts} +11 -4
  42. package/test/unit/database/schema.test.ts +95 -0
  43. package/test/unit/document/property/primary.test.ts +87 -0
  44. package/test/unit/document/property/triage.test.ts +64 -0
  45. package/test/unit/document/validate.test.ts +138 -0
  46. package/test/unit/loader/definition.test.ts +55 -0
  47. package/typescript/tsconfig.build.json +23 -0
  48. package/author/definition.js +0 -7
  49. package/database/definition.js +0 -17
  50. package/database/interface.js +0 -7
  51. package/database/manager.js +0 -7
  52. package/database/schema.d.ts +0 -69
  53. package/database/schema.js +0 -78
  54. package/document/definition.js +0 -17
  55. package/document/interface.js +0 -7
  56. package/document/property/default-value.d.ts +0 -7
  57. package/document/property/default-value.js +0 -25
  58. package/document/property/definition.js +0 -7
  59. package/document/property/primary.d.ts +0 -8
  60. package/document/property/primary.js +0 -20
  61. package/document/property/triage-base.d.ts +0 -31
  62. package/document/property/triage-base.js +0 -85
  63. package/document/property/triage-manager.d.ts +0 -30
  64. package/document/property/triage-manager.js +0 -50
  65. package/document/property/triage.d.ts +0 -8
  66. package/document/property/triage.js +0 -13
  67. package/document/property.js +0 -54
  68. package/document/validate.d.ts +0 -18
  69. package/index.js +0 -46
  70. package/loader/definition.js +0 -7
  71. package/loader/origin-loader.d.ts +0 -29
  72. package/loader/origin-loader.js +0 -104
  73. package/loader/persistence.js +0 -19
  74. package/origin/definition.js +0 -7
  75. package/origin/interface.js +0 -7
  76. package/origin/search.js +0 -14
  77. package/static/definition.js +0 -7
  78. package/static/interface.js +0 -7
  79. package/static/manager.js +0 -7
  80. package/text/definition.js +0 -7
  81. package/text/interface.js +0 -7
  82. package/text/manager.js +0 -7
@@ -1,78 +0,0 @@
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
- switch (property.propertyType) {
29
- case property_1.IMBRICATE_PROPERTY_TYPE.REFERENCE: {
30
- if (typeof property.propertyOptions !== "object") {
31
- return "Property options must be an object";
32
- }
33
- if (typeof property.propertyOptions.allowMultiple !== "boolean") {
34
- return "Property options allowMultiple must be a boolean";
35
- }
36
- if (!Array.isArray(property.propertyOptions.databases)) {
37
- return "Property options databases must be an array";
38
- }
39
- for (const database of property.propertyOptions.databases) {
40
- if (typeof database.originUniqueIdentifier !== "string") {
41
- return "Database originUniqueIdentifier must be a string";
42
- }
43
- if (typeof database.databaseUniqueIdentifier !== "string") {
44
- return "Database databaseUniqueIdentifier must be a string";
45
- }
46
- }
47
- break;
48
- }
49
- }
50
- return null;
51
- };
52
- exports.validateImbricateSchemaProperty = validateImbricateSchemaProperty;
53
- /**
54
- * Validate a schema
55
- *
56
- * @param schema database schema to validate
57
- *
58
- * @returns a string error message if validation failed
59
- * null if validation passed
60
- */
61
- const validateImbricateSchema = (schema) => {
62
- if (!Array.isArray(schema.properties)) {
63
- return "Properties must be an array";
64
- }
65
- const propertyNames = new Set();
66
- for (const property of schema.properties) {
67
- const propertyValidationResult = (0, exports.validateImbricateSchemaProperty)(property);
68
- if (typeof propertyValidationResult === "string") {
69
- return `Invalid property ${property.propertyName}, ${propertyValidationResult}`;
70
- }
71
- if (propertyNames.has(property.propertyName)) {
72
- return `Duplicated property name ${property.propertyName}`;
73
- }
74
- propertyNames.add(property.propertyName);
75
- }
76
- return null;
77
- };
78
- exports.validateImbricateSchema = validateImbricateSchema;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Document
5
- * @description Definition
6
- */
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 = {}));
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Document
5
- * @description Interface
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +0,0 @@
1
- /**
2
- * @author WMXPY
3
- * @namespace Document_Property
4
- * @description Default Value
5
- */
6
- import { DocumentPropertyValueObject, IMBRICATE_PROPERTY_TYPE } from "../property";
7
- export declare const getImbricateDefaultValueOfProperty: (type: IMBRICATE_PROPERTY_TYPE) => DocumentPropertyValueObject<IMBRICATE_PROPERTY_TYPE>;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Document_Property
5
- * @description Default Value
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.getImbricateDefaultValueOfProperty = void 0;
9
- const property_1 = require("../property");
10
- // IMBRICATE_PROPERTY_TYPE SWITCH
11
- const getImbricateDefaultValueOfProperty = (type) => {
12
- switch (type) {
13
- case property_1.IMBRICATE_PROPERTY_TYPE.BOOLEAN: return false;
14
- case property_1.IMBRICATE_PROPERTY_TYPE.STRING: return "";
15
- case property_1.IMBRICATE_PROPERTY_TYPE.NUMBER: return 0;
16
- case property_1.IMBRICATE_PROPERTY_TYPE.MARKDOWN: return "";
17
- case property_1.IMBRICATE_PROPERTY_TYPE.JSON: return "";
18
- case property_1.IMBRICATE_PROPERTY_TYPE.IMBRISCRIPT: return "";
19
- case property_1.IMBRICATE_PROPERTY_TYPE.DATE: return new Date().toISOString();
20
- case property_1.IMBRICATE_PROPERTY_TYPE.LABEL: return [];
21
- case property_1.IMBRICATE_PROPERTY_TYPE.REFERENCE: return [];
22
- }
23
- return null;
24
- };
25
- exports.getImbricateDefaultValueOfProperty = getImbricateDefaultValueOfProperty;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Document_Property
5
- * @description Definition
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +0,0 @@
1
- /**
2
- * @author WMXPY
3
- * @namespace Document_Property
4
- * @description Primary
5
- */
6
- import { ImbricateDatabaseSchema } from "../../database/schema";
7
- import { DocumentProperties, DocumentPropertyValue, IMBRICATE_PROPERTY_TYPE } from "../property";
8
- export declare const findPrimaryProperty: (schema: ImbricateDatabaseSchema, properties: DocumentProperties) => DocumentPropertyValue<IMBRICATE_PROPERTY_TYPE> | null;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Document_Property
5
- * @description Primary
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.findPrimaryProperty = void 0;
9
- const findPrimaryProperty = (schema, properties) => {
10
- for (const property of schema.properties) {
11
- if (property.isPrimaryKey) {
12
- const value = properties[property.propertyIdentifier];
13
- if (value) {
14
- return value;
15
- }
16
- }
17
- }
18
- return null;
19
- };
20
- exports.findPrimaryProperty = findPrimaryProperty;
@@ -1,31 +0,0 @@
1
- /**
2
- * @author WMXPY
3
- * @namespace Document_Property
4
- * @description Triage Base
5
- */
6
- import { DocumentProperties, DocumentPropertyKey, IMBRICATE_PROPERTY_TYPE } from "../property";
7
- import { DocumentPropertyTriageFunction } from "./definition";
8
- export declare class ImbricateDocumentPropertyTriageBase<Result> {
9
- private readonly _triageFunctionsByKey;
10
- private readonly _triageFunctionsByType;
11
- protected constructor();
12
- /**
13
- * Set triage function for property key,
14
- * This action will override document value based triage functions
15
- *
16
- * @param propertyKey property key
17
- * @param triageFunction triage function
18
- * @returns triage manager
19
- */
20
- forPropertyKey<T extends IMBRICATE_PROPERTY_TYPE>(propertyKey: DocumentPropertyKey, triageFunction: DocumentPropertyTriageFunction<T, Result>): this;
21
- forBoolean(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.BOOLEAN, Result>): this;
22
- forString(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.STRING, Result>): this;
23
- forNumber(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.NUMBER, Result>): this;
24
- forMarkdown(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.MARKDOWN, Result>): this;
25
- forJson(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.JSON, Result>): this;
26
- forImbriscript(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.IMBRISCRIPT, Result>): this;
27
- forDate(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.DATE, Result>): this;
28
- forLabel(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.LABEL, Result>): this;
29
- forReference(triageFunction: DocumentPropertyTriageFunction<IMBRICATE_PROPERTY_TYPE.REFERENCE, Result>): this;
30
- protected _collect(properties: DocumentProperties): Map<DocumentPropertyKey, Result>;
31
- }
@@ -1,85 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Document_Property
5
- * @description Triage Base
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.ImbricateDocumentPropertyTriageBase = void 0;
9
- const property_1 = require("../property");
10
- // IMBRICATE_PROPERTY_TYPE SWITCH
11
- class ImbricateDocumentPropertyTriageBase {
12
- constructor() {
13
- this._triageFunctionsByKey = new Map();
14
- this._triageFunctionsByType = new Map();
15
- }
16
- /**
17
- * Set triage function for property key,
18
- * This action will override document value based triage functions
19
- *
20
- * @param propertyKey property key
21
- * @param triageFunction triage function
22
- * @returns triage manager
23
- */
24
- forPropertyKey(propertyKey, triageFunction) {
25
- this._triageFunctionsByKey.set(propertyKey, triageFunction);
26
- return this;
27
- }
28
- forBoolean(triageFunction) {
29
- this._triageFunctionsByType.set(property_1.IMBRICATE_PROPERTY_TYPE.BOOLEAN, triageFunction);
30
- return this;
31
- }
32
- forString(triageFunction) {
33
- this._triageFunctionsByType.set(property_1.IMBRICATE_PROPERTY_TYPE.STRING, triageFunction);
34
- return this;
35
- }
36
- forNumber(triageFunction) {
37
- this._triageFunctionsByType.set(property_1.IMBRICATE_PROPERTY_TYPE.NUMBER, triageFunction);
38
- return this;
39
- }
40
- forMarkdown(triageFunction) {
41
- this._triageFunctionsByType.set(property_1.IMBRICATE_PROPERTY_TYPE.MARKDOWN, triageFunction);
42
- return this;
43
- }
44
- forJson(triageFunction) {
45
- this._triageFunctionsByType.set(property_1.IMBRICATE_PROPERTY_TYPE.JSON, triageFunction);
46
- return this;
47
- }
48
- forImbriscript(triageFunction) {
49
- this._triageFunctionsByType.set(property_1.IMBRICATE_PROPERTY_TYPE.IMBRISCRIPT, triageFunction);
50
- return this;
51
- }
52
- forDate(triageFunction) {
53
- this._triageFunctionsByType.set(property_1.IMBRICATE_PROPERTY_TYPE.DATE, triageFunction);
54
- return this;
55
- }
56
- forLabel(triageFunction) {
57
- this._triageFunctionsByType.set(property_1.IMBRICATE_PROPERTY_TYPE.LABEL, triageFunction);
58
- return this;
59
- }
60
- forReference(triageFunction) {
61
- this._triageFunctionsByType.set(property_1.IMBRICATE_PROPERTY_TYPE.REFERENCE, triageFunction);
62
- return this;
63
- }
64
- _collect(properties) {
65
- const keys = Object.keys(properties);
66
- const result = new Map();
67
- for (const key of keys) {
68
- const property = properties[key];
69
- const triageFunction = this._triageFunctionsByKey.get(key);
70
- if (typeof triageFunction === "function") {
71
- const value = triageFunction(key, property);
72
- result.set(key, value);
73
- continue;
74
- }
75
- const typeFunction = this._triageFunctionsByType.get(property.type);
76
- if (typeof typeFunction === "function") {
77
- const value = typeFunction(key, property);
78
- result.set(key, value);
79
- continue;
80
- }
81
- }
82
- return result;
83
- }
84
- }
85
- exports.ImbricateDocumentPropertyTriageBase = ImbricateDocumentPropertyTriageBase;
@@ -1,30 +0,0 @@
1
- /**
2
- * @author WMXPY
3
- * @namespace Document_Property
4
- * @description Triage Manager
5
- */
6
- import { DocumentProperties, DocumentPropertyKey } from "../property";
7
- import { ImbricateDocumentPropertyTriageBase } from "./triage-base";
8
- export declare class ImbricateDocumentPropertyTriageManager<Result> extends ImbricateDocumentPropertyTriageBase<Result> {
9
- static create<Result>(properties: DocumentProperties): ImbricateDocumentPropertyTriageManager<Result>;
10
- private readonly _properties;
11
- private constructor();
12
- /**
13
- * Collect the result as array
14
- *
15
- * @returns collected result as array
16
- */
17
- collectAsArray(): Result[];
18
- /**
19
- * Collect the result as map
20
- *
21
- * @returns collected result as map
22
- */
23
- collectAsMap(): Map<DocumentPropertyKey, Result>;
24
- /**
25
- * Collect the result as object
26
- *
27
- * @returns collected result as object
28
- */
29
- collectAsObject(): Record<DocumentPropertyKey, Result>;
30
- }
@@ -1,50 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Document_Property
5
- * @description Triage Manager
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.ImbricateDocumentPropertyTriageManager = void 0;
9
- const triage_base_1 = require("./triage-base");
10
- class ImbricateDocumentPropertyTriageManager extends triage_base_1.ImbricateDocumentPropertyTriageBase {
11
- static create(properties) {
12
- return new ImbricateDocumentPropertyTriageManager(properties);
13
- }
14
- constructor(properties) {
15
- super();
16
- this._properties = properties;
17
- }
18
- /**
19
- * Collect the result as array
20
- *
21
- * @returns collected result as array
22
- */
23
- collectAsArray() {
24
- const result = super._collect(this._properties);
25
- return Array.from(result.values());
26
- }
27
- /**
28
- * Collect the result as map
29
- *
30
- * @returns collected result as map
31
- */
32
- collectAsMap() {
33
- return super._collect(this._properties);
34
- }
35
- /**
36
- * Collect the result as object
37
- *
38
- * @returns collected result as object
39
- */
40
- collectAsObject() {
41
- const result = super._collect(this._properties);
42
- const keys = Array.from(result.keys());
43
- const object = {};
44
- for (const key of keys) {
45
- object[key] = result.get(key);
46
- }
47
- return object;
48
- }
49
- }
50
- exports.ImbricateDocumentPropertyTriageManager = ImbricateDocumentPropertyTriageManager;
@@ -1,8 +0,0 @@
1
- /**
2
- * @author WMXPY
3
- * @namespace Document_Property
4
- * @description Triage
5
- */
6
- import { DocumentProperties } from "../property";
7
- import { ImbricateDocumentPropertyTriageManager } from "./triage-manager";
8
- export declare const triageImbricateDocumentProperties: <Result>(properties: DocumentProperties) => ImbricateDocumentPropertyTriageManager<Result>;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Document_Property
5
- * @description Triage
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.triageImbricateDocumentProperties = void 0;
9
- const triage_manager_1 = require("./triage-manager");
10
- const triageImbricateDocumentProperties = (properties) => {
11
- return triage_manager_1.ImbricateDocumentPropertyTriageManager.create(properties);
12
- };
13
- exports.triageImbricateDocumentProperties = triageImbricateDocumentProperties;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Document
5
- * @description Property
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.IMBRICATE_PROPERTY_TYPE = void 0;
9
- /**
10
- * Document properties
11
- */
12
- var IMBRICATE_PROPERTY_TYPE;
13
- (function (IMBRICATE_PROPERTY_TYPE) {
14
- /**
15
- * BOOLEAN - boolean, store as boolean
16
- */
17
- IMBRICATE_PROPERTY_TYPE["BOOLEAN"] = "BOOLEAN";
18
- /**
19
- * STRING - string, store as plain text
20
- */
21
- IMBRICATE_PROPERTY_TYPE["STRING"] = "STRING";
22
- /**
23
- * NUMBER - number, store as number
24
- */
25
- IMBRICATE_PROPERTY_TYPE["NUMBER"] = "NUMBER";
26
- /**
27
- * MARKDOWN - markdown, store as text object unique identifier. Display as markdown
28
- */
29
- IMBRICATE_PROPERTY_TYPE["MARKDOWN"] = "MARKDOWN";
30
- /**
31
- * JSON - json, store as text object unique identifier. Display as JSON
32
- */
33
- IMBRICATE_PROPERTY_TYPE["JSON"] = "JSON";
34
- /**
35
- * IMBRISCRIPT - imbricate script, store as text object unique identifier. Display as imbricate script
36
- * The script is executed in a sandbox environment, using customized javascript engine
37
- */
38
- IMBRICATE_PROPERTY_TYPE["IMBRISCRIPT"] = "IMBRISCRIPT";
39
- /**
40
- * DATE - date, store as string in ISO format
41
- * For example - 2000-01-01T00:00:00.000Z
42
- */
43
- IMBRICATE_PROPERTY_TYPE["DATE"] = "DATE";
44
- /**
45
- * LABEL - label, store as a list of label id
46
- * Note: Label is always stored as an array, even if it is a single label
47
- */
48
- IMBRICATE_PROPERTY_TYPE["LABEL"] = "LABEL";
49
- /**
50
- * REFERENCE - reference, store as a list of other document unique identifier
51
- * Note: Reference is always stored as an array, even if it is a single reference
52
- */
53
- IMBRICATE_PROPERTY_TYPE["REFERENCE"] = "REFERENCE";
54
- })(IMBRICATE_PROPERTY_TYPE || (exports.IMBRICATE_PROPERTY_TYPE = IMBRICATE_PROPERTY_TYPE = {}));
@@ -1,18 +0,0 @@
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
- * @param allowExtraProperties allow extra properties, optional with default false
14
- *
15
- * @returns a string error message if validation failed
16
- * null if validation passed
17
- */
18
- export declare const validateImbricateProperties: (properties: DocumentProperties, schema: ImbricateDatabaseSchema, allowExtraProperties?: boolean) => string | null;
package/index.js DELETED
@@ -1,46 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @description Index
5
- */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- var desc = Object.getOwnPropertyDescriptor(m, k);
9
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
- desc = { enumerable: true, get: function() { return m[k]; } };
11
- }
12
- Object.defineProperty(o, k2, desc);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- __exportStar(require("./author/definition"), 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/property/default-value"), exports);
30
- __exportStar(require("./document/property/definition"), exports);
31
- __exportStar(require("./document/property/primary"), exports);
32
- __exportStar(require("./document/property/triage"), exports);
33
- __exportStar(require("./document/property/triage-manager"), exports);
34
- __exportStar(require("./document/validate"), exports);
35
- __exportStar(require("./loader/definition"), exports);
36
- __exportStar(require("./loader/origin-loader"), exports);
37
- __exportStar(require("./loader/persistence"), exports);
38
- __exportStar(require("./origin/definition"), exports);
39
- __exportStar(require("./origin/interface"), exports);
40
- __exportStar(require("./origin/search"), exports);
41
- __exportStar(require("./static/definition"), exports);
42
- __exportStar(require("./static/interface"), exports);
43
- __exportStar(require("./static/manager"), exports);
44
- __exportStar(require("./text/definition"), exports);
45
- __exportStar(require("./text/interface"), exports);
46
- __exportStar(require("./text/manager"), exports);
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Loader
5
- * @description Definition
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,29 +0,0 @@
1
- /**
2
- * @author WMXPY
3
- * @namespace Loader
4
- * @description Origin Loader
5
- */
6
- import { IImbricateOrigin } from "../origin/interface";
7
- import { ImbricateOriginPersistence, ImbricateOriginPersistenceOrigin } from "./persistence";
8
- /**
9
- * Load imbricate origin from persistence origin
10
- * This function will load the origin from the persistence origin
11
- * and initialize the origin with the payloads
12
- *
13
- * @param origin origin to persistence to load
14
- *
15
- * @returns a promise of the loaded origin
16
- * if the origin is not found, return null
17
- */
18
- export declare const loadImbricateOriginFromPersistenceOrigin: (origin: ImbricateOriginPersistenceOrigin) => Promise<IImbricateOrigin | null>;
19
- /**
20
- * Load imbricate origins from persistence
21
- * This function will load all origins from the persistence
22
- * and initialize the origins with the payloads
23
- * If the origin is not found, it will be ignored
24
- *
25
- * @param persistence persistence to load origins
26
- *
27
- * @returns a promise of the loaded origins, if the origin is not found, return empty array
28
- */
29
- export declare const loadImbricateOriginsFromPersistence: (persistence: ImbricateOriginPersistence) => Promise<IImbricateOrigin[]>;
@@ -1,104 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Loader
5
- * @description Origin Loader
6
- */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
- Object.defineProperty(o, "default", { enumerable: true, value: v });
20
- }) : function(o, v) {
21
- o["default"] = v;
22
- });
23
- var __importStar = (this && this.__importStar) || (function () {
24
- var ownKeys = function(o) {
25
- ownKeys = Object.getOwnPropertyNames || function (o) {
26
- var ar = [];
27
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
- return ar;
29
- };
30
- return ownKeys(o);
31
- };
32
- return function (mod) {
33
- if (mod && mod.__esModule) return mod;
34
- var result = {};
35
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
- __setModuleDefault(result, mod);
37
- return result;
38
- };
39
- })();
40
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
41
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
42
- return new (P || (P = Promise))(function (resolve, reject) {
43
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
44
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
45
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
46
- step((generator = generator.apply(thisArg, _arguments || [])).next());
47
- });
48
- };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.loadImbricateOriginsFromPersistence = exports.loadImbricateOriginFromPersistenceOrigin = void 0;
51
- const persistence_1 = require("./persistence");
52
- /**
53
- * Load imbricate origin from persistence origin
54
- * This function will load the origin from the persistence origin
55
- * and initialize the origin with the payloads
56
- *
57
- * @param origin origin to persistence to load
58
- *
59
- * @returns a promise of the loaded origin
60
- * if the origin is not found, return null
61
- */
62
- const loadImbricateOriginFromPersistenceOrigin = (origin) => __awaiter(void 0, void 0, void 0, function* () {
63
- switch (origin.originLoadType) {
64
- case persistence_1.IMBRICATE_ORIGIN_LOAD_TYPE.NPM_PACKAGE: {
65
- const originPackage = yield Promise.resolve(`${origin.originLoadValue}`).then(s => __importStar(require(s)));
66
- if (typeof originPackage.default === "function") {
67
- const initialized = originPackage.default.call(null, origin.originPayloads);
68
- return initialized;
69
- }
70
- break;
71
- }
72
- case persistence_1.IMBRICATE_ORIGIN_LOAD_TYPE.FILE_SYSTEM: {
73
- const originPackage = yield Promise.resolve(`${origin.originLoadValue}`).then(s => __importStar(require(s)));
74
- if (typeof originPackage.default === "function") {
75
- const initialized = originPackage.default.call(null, origin.originPayloads);
76
- return initialized;
77
- }
78
- break;
79
- }
80
- }
81
- return null;
82
- });
83
- exports.loadImbricateOriginFromPersistenceOrigin = loadImbricateOriginFromPersistenceOrigin;
84
- /**
85
- * Load imbricate origins from persistence
86
- * This function will load all origins from the persistence
87
- * and initialize the origins with the payloads
88
- * If the origin is not found, it will be ignored
89
- *
90
- * @param persistence persistence to load origins
91
- *
92
- * @returns a promise of the loaded origins, if the origin is not found, return empty array
93
- */
94
- const loadImbricateOriginsFromPersistence = (persistence) => __awaiter(void 0, void 0, void 0, function* () {
95
- const origins = [];
96
- for (const origin of persistence.origins) {
97
- const originInstance = yield (0, exports.loadImbricateOriginFromPersistenceOrigin)(origin);
98
- if (originInstance) {
99
- origins.push(originInstance);
100
- }
101
- }
102
- return origins;
103
- });
104
- exports.loadImbricateOriginsFromPersistence = loadImbricateOriginsFromPersistence;