@imbricate/core 3.19.0 → 3.20.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 (51) hide show
  1. package/common/action.d.ts +4 -2
  2. package/database/base-class/essential-readonly.d.ts +2 -2
  3. package/database/base-class/full-feature-readonly.d.ts +2 -2
  4. package/database/base-class/full-feature-with-action.d.ts +2 -2
  5. package/database/base-class/full-feature.d.ts +2 -2
  6. package/database/interface.d.ts +2 -2
  7. package/database/schema.d.ts +1 -1
  8. package/database/schema.js +3 -3
  9. package/document/base-class/essential-readonly.d.ts +3 -3
  10. package/document/base-class/full-feature-readonly.d.ts +3 -3
  11. package/document/base-class/full-feature-with-action.d.ts +7 -5
  12. package/document/base-class/full-feature.d.ts +1 -10
  13. package/document/definition.d.ts +5 -3
  14. package/document/export.d.ts +0 -2
  15. package/document/export.js +0 -2
  16. package/document/interface.d.ts +17 -8
  17. package/document/outcome.d.ts +18 -0
  18. package/document/outcome.js +15 -1
  19. package/document/property/default-value.d.ts +2 -2
  20. package/document/property/default-value.js +10 -10
  21. package/document/property/definition.d.ts +4 -2
  22. package/document/property/primary.d.ts +4 -2
  23. package/document/property/triage-base.d.ts +15 -13
  24. package/document/property/triage-base.js +11 -11
  25. package/document/property/triage-manager.d.ts +5 -4
  26. package/document/property/triage.d.ts +2 -2
  27. package/error/property/feature-not-supported.d.ts +12 -0
  28. package/error/property/feature-not-supported.js +20 -0
  29. package/error/property/property-error.d.ts +9 -0
  30. package/error/property/property-error.js +16 -0
  31. package/index.d.ts +1 -0
  32. package/index.js +1 -0
  33. package/package.json +1 -1
  34. package/property/base-class/full-feature-with-action.d.ts +18 -0
  35. package/property/base-class/full-feature-with-action.js +18 -0
  36. package/property/base-class/full-feature.d.ts +15 -0
  37. package/property/base-class/full-feature.js +24 -0
  38. package/property/definition.d.ts +9 -0
  39. package/property/definition.js +7 -0
  40. package/property/export.d.ts +13 -0
  41. package/property/export.js +29 -0
  42. package/property/feature.d.ts +10 -0
  43. package/property/feature.js +17 -0
  44. package/property/interface.d.ts +45 -0
  45. package/property/interface.js +7 -0
  46. package/property/map.d.ts +9 -0
  47. package/property/map.js +7 -0
  48. package/{document/property.d.ts → property/type.d.ts} +5 -20
  49. package/{document/property.js → property/type.js} +3 -3
  50. package/{document → property}/validate.d.ts +3 -3
  51. package/{document → property}/validate.js +33 -30
@@ -3,6 +3,6 @@
3
3
  * @namespace Document_Property
4
4
  * @description Triage
5
5
  */
6
- import { DocumentProperties } from "../property";
6
+ import { ImbricatePropertyRecord } from "../../property/map";
7
7
  import { ImbricateDocumentPropertyTriageManager } from "./triage-manager";
8
- export declare const triageImbricateDocumentProperties: <Result>(properties: DocumentProperties) => ImbricateDocumentPropertyTriageManager<Result>;
8
+ export declare const triageImbricateDocumentProperties: <Result>(properties: ImbricatePropertyRecord) => ImbricateDocumentPropertyTriageManager<Result>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @namespace Error
4
+ * @description Property Feature Not Supported
5
+ */
6
+ import { IMBRICATE_PROPERTY_FEATURE } from "../../property/feature";
7
+ import { PropertyError } from "./property-error";
8
+ export declare class PropertyFeatureNotSupportedError extends PropertyError {
9
+ static withFeature(feature: IMBRICATE_PROPERTY_FEATURE): PropertyFeatureNotSupportedError;
10
+ static readonly TYPE: string;
11
+ protected constructor(message: string, reason?: any);
12
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /**
3
+ * @author WMXPY
4
+ * @namespace Error
5
+ * @description Property Feature Not Supported
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.PropertyFeatureNotSupportedError = void 0;
9
+ const property_error_1 = require("./property-error");
10
+ class PropertyFeatureNotSupportedError extends property_error_1.PropertyError {
11
+ static withFeature(feature) {
12
+ return new PropertyFeatureNotSupportedError(`Feature ${feature} is not supported`, feature);
13
+ }
14
+ constructor(message, reason) {
15
+ super(message, PropertyFeatureNotSupportedError.TYPE, reason);
16
+ Object.setPrototypeOf(this, PropertyFeatureNotSupportedError.prototype);
17
+ }
18
+ }
19
+ exports.PropertyFeatureNotSupportedError = PropertyFeatureNotSupportedError;
20
+ PropertyFeatureNotSupportedError.TYPE = "IMBRICATE_PROPERTY_FEATURE_NOT_SUPPORTED";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @namespace Error
4
+ * @description Property Error
5
+ */
6
+ import { ImbricateError } from "../imbricate-error";
7
+ export declare class PropertyError extends ImbricateError {
8
+ protected constructor(message: string, type: string, reason?: any);
9
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /**
3
+ * @author WMXPY
4
+ * @namespace Error
5
+ * @description Property Error
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.PropertyError = void 0;
9
+ const imbricate_error_1 = require("../imbricate-error");
10
+ class PropertyError extends imbricate_error_1.ImbricateError {
11
+ constructor(message, type, reason) {
12
+ super(message, type, reason);
13
+ Object.setPrototypeOf(this, PropertyError.prototype);
14
+ }
15
+ }
16
+ exports.PropertyError = PropertyError;
package/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export * from "./document/export";
10
10
  export * from "./error/export";
11
11
  export * from "./loader/export";
12
12
  export * from "./origin/export";
13
+ export * from "./property/export";
13
14
  export * from "./static-manager/export";
14
15
  export * from "./static/export";
15
16
  export * from "./text-manager/export";
package/index.js CHANGED
@@ -26,6 +26,7 @@ __exportStar(require("./document/export"), exports);
26
26
  __exportStar(require("./error/export"), exports);
27
27
  __exportStar(require("./loader/export"), exports);
28
28
  __exportStar(require("./origin/export"), exports);
29
+ __exportStar(require("./property/export"), exports);
29
30
  __exportStar(require("./static-manager/export"), exports);
30
31
  __exportStar(require("./static/export"), exports);
31
32
  __exportStar(require("./text-manager/export"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imbricate/core",
3
3
  "main": "index.js",
4
- "version": "3.19.0",
4
+ "version": "3.20.0",
5
5
  "description": "Imbricate Core, Notebook for Engineers",
6
6
  "repository": {
7
7
  "type": "git",
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @namespace Property
4
+ * @description Full Feature
5
+ */
6
+ import { ImbricateCommonQueryOriginActionsOutcome, ImbricateCommonQueryOriginActionsQuery, ImbricateOriginActionInput, ImbricateOriginActionOutcome } from "../../common/action";
7
+ import { ImbricatePropertyKey } from "../definition";
8
+ import { IMBRICATE_PROPERTY_FEATURE } from "../feature";
9
+ import { IImbricateProperty } from "../interface";
10
+ import { IMBRICATE_PROPERTY_TYPE, ImbricatePropertyValueObject } from "../type";
11
+ export declare abstract class ImbricatePropertyFullFeatureWithActionBase<T extends IMBRICATE_PROPERTY_TYPE> implements IImbricateProperty<T> {
12
+ abstract readonly propertyKey: ImbricatePropertyKey;
13
+ abstract readonly propertyType: T;
14
+ abstract readonly propertyValue: ImbricatePropertyValueObject<T>;
15
+ readonly supportedFeatures: IMBRICATE_PROPERTY_FEATURE[];
16
+ abstract queryOriginActions(query: ImbricateCommonQueryOriginActionsQuery): PromiseLike<ImbricateCommonQueryOriginActionsOutcome>;
17
+ abstract executeOriginAction(input: ImbricateOriginActionInput): PromiseLike<ImbricateOriginActionOutcome>;
18
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /**
3
+ * @author WMXPY
4
+ * @namespace Property
5
+ * @description Full Feature
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ImbricatePropertyFullFeatureWithActionBase = void 0;
9
+ const feature_1 = require("../feature");
10
+ class ImbricatePropertyFullFeatureWithActionBase {
11
+ constructor() {
12
+ this.supportedFeatures = [
13
+ feature_1.IMBRICATE_PROPERTY_FEATURE.PROPERTY_GET_ORIGIN_ACTIONS,
14
+ feature_1.IMBRICATE_PROPERTY_FEATURE.PROPERTY_EXECUTE_ORIGIN_ACTION,
15
+ ];
16
+ }
17
+ }
18
+ exports.ImbricatePropertyFullFeatureWithActionBase = ImbricatePropertyFullFeatureWithActionBase;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @namespace Property
4
+ * @description Full Feature
5
+ */
6
+ import { ImbricateCommonQueryOriginActionsOutcome, ImbricateCommonQueryOriginActionsQuery, ImbricateOriginActionInput, ImbricateOriginActionOutcome } from "../../common/action";
7
+ import { IMBRICATE_PROPERTY_FEATURE } from "../feature";
8
+ import { IImbricateProperty } from "../interface";
9
+ import { IMBRICATE_PROPERTY_TYPE } from "../type";
10
+ import { ImbricatePropertyFullFeatureWithActionBase } from "./full-feature-with-action";
11
+ export declare abstract class ImbricatePropertyFullFeatureBase<T extends IMBRICATE_PROPERTY_TYPE> extends ImbricatePropertyFullFeatureWithActionBase<T> implements IImbricateProperty<T> {
12
+ readonly supportedFeatures: IMBRICATE_PROPERTY_FEATURE[];
13
+ queryOriginActions(_query: ImbricateCommonQueryOriginActionsQuery): PromiseLike<ImbricateCommonQueryOriginActionsOutcome>;
14
+ executeOriginAction(_input: ImbricateOriginActionInput): PromiseLike<ImbricateOriginActionOutcome>;
15
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /**
3
+ * @author WMXPY
4
+ * @namespace Property
5
+ * @description Full Feature
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ImbricatePropertyFullFeatureBase = void 0;
9
+ const feature_not_supported_1 = require("../../error/property/feature-not-supported");
10
+ const feature_1 = require("../feature");
11
+ const full_feature_with_action_1 = require("./full-feature-with-action");
12
+ class ImbricatePropertyFullFeatureBase extends full_feature_with_action_1.ImbricatePropertyFullFeatureWithActionBase {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.supportedFeatures = [];
16
+ }
17
+ queryOriginActions(_query) {
18
+ throw feature_not_supported_1.PropertyFeatureNotSupportedError.withFeature(feature_1.IMBRICATE_PROPERTY_FEATURE.PROPERTY_GET_ORIGIN_ACTIONS);
19
+ }
20
+ executeOriginAction(_input) {
21
+ throw feature_not_supported_1.PropertyFeatureNotSupportedError.withFeature(feature_1.IMBRICATE_PROPERTY_FEATURE.PROPERTY_EXECUTE_ORIGIN_ACTION);
22
+ }
23
+ }
24
+ exports.ImbricatePropertyFullFeatureBase = ImbricatePropertyFullFeatureBase;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @namespace Property
4
+ * @description Definition
5
+ */
6
+ /**
7
+ * Imbricate property key, which should match schema properties unique identifier
8
+ */
9
+ export type ImbricatePropertyKey = string;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * @author WMXPY
4
+ * @namespace Property
5
+ * @description Definition
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @namespace Property
4
+ * @description Export
5
+ */
6
+ export * from "./base-class/full-feature";
7
+ export * from "./base-class/full-feature-with-action";
8
+ export * from "./definition";
9
+ export * from "./feature";
10
+ export * from "./interface";
11
+ export * from "./map";
12
+ export * from "./type";
13
+ export * from "./validate";
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /**
3
+ * @author WMXPY
4
+ * @namespace Property
5
+ * @description Export
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ __exportStar(require("./base-class/full-feature"), exports);
23
+ __exportStar(require("./base-class/full-feature-with-action"), exports);
24
+ __exportStar(require("./definition"), exports);
25
+ __exportStar(require("./feature"), exports);
26
+ __exportStar(require("./interface"), exports);
27
+ __exportStar(require("./map"), exports);
28
+ __exportStar(require("./type"), exports);
29
+ __exportStar(require("./validate"), exports);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @namespace Property
4
+ * @description Feature
5
+ */
6
+ export declare enum IMBRICATE_PROPERTY_FEATURE {
7
+ PROPERTY_GET_ORIGIN_ACTIONS = "PROPERTY_GET_ORIGIN_ACTIONS",
8
+ PROPERTY_EXECUTE_ORIGIN_ACTION = "PROPERTY_EXECUTE_ORIGIN_ACTION"
9
+ }
10
+ export declare const checkImbricatePropertyFeatureSupported: (features: IMBRICATE_PROPERTY_FEATURE[], feature: IMBRICATE_PROPERTY_FEATURE) => boolean;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * @author WMXPY
4
+ * @namespace Property
5
+ * @description Feature
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.checkImbricatePropertyFeatureSupported = exports.IMBRICATE_PROPERTY_FEATURE = void 0;
9
+ var IMBRICATE_PROPERTY_FEATURE;
10
+ (function (IMBRICATE_PROPERTY_FEATURE) {
11
+ IMBRICATE_PROPERTY_FEATURE["PROPERTY_GET_ORIGIN_ACTIONS"] = "PROPERTY_GET_ORIGIN_ACTIONS";
12
+ IMBRICATE_PROPERTY_FEATURE["PROPERTY_EXECUTE_ORIGIN_ACTION"] = "PROPERTY_EXECUTE_ORIGIN_ACTION";
13
+ })(IMBRICATE_PROPERTY_FEATURE || (exports.IMBRICATE_PROPERTY_FEATURE = IMBRICATE_PROPERTY_FEATURE = {}));
14
+ const checkImbricatePropertyFeatureSupported = (features, feature) => {
15
+ return features.includes(feature);
16
+ };
17
+ exports.checkImbricatePropertyFeatureSupported = checkImbricatePropertyFeatureSupported;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @namespace Property
4
+ * @description Interface
5
+ */
6
+ import { ImbricateCommonQueryOriginActionsOutcome, ImbricateCommonQueryOriginActionsQuery, ImbricateOriginActionInput, ImbricateOriginActionOutcome } from "../common/action";
7
+ import { ImbricatePropertyKey } from "./definition";
8
+ import { IMBRICATE_PROPERTY_FEATURE } from "./feature";
9
+ import { IMBRICATE_PROPERTY_TYPE, ImbricatePropertyValueObject } from "./type";
10
+ export interface IImbricateProperty<T extends IMBRICATE_PROPERTY_TYPE> {
11
+ /**
12
+ * Property key, reference to the property key from documents
13
+ */
14
+ readonly propertyKey: ImbricatePropertyKey;
15
+ /**
16
+ * Property type
17
+ */
18
+ readonly propertyType: T;
19
+ /**
20
+ * Property value
21
+ */
22
+ readonly propertyValue: ImbricatePropertyValueObject<T>;
23
+ /**
24
+ * Supported features of the property
25
+ */
26
+ readonly supportedFeatures: IMBRICATE_PROPERTY_FEATURE[];
27
+ /**
28
+ * Query the property actions
29
+ *
30
+ * @param query the query of the property actions
31
+ *
32
+ * @returns the property actions
33
+ * Symbol: S_Common_QueryOriginActions_Stale - if the property actions are stale
34
+ * Symbol: S_Common_QueryOriginActions_Unknown - if the property actions are unknown
35
+ */
36
+ queryOriginActions(query: ImbricateCommonQueryOriginActionsQuery): PromiseLike<ImbricateCommonQueryOriginActionsOutcome>;
37
+ /**
38
+ * Execute the property action
39
+ *
40
+ * @param input the input of the action
41
+ *
42
+ * @returns the result of the action
43
+ */
44
+ executeOriginAction(input: ImbricateOriginActionInput): PromiseLike<ImbricateOriginActionOutcome>;
45
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * @author WMXPY
4
+ * @namespace Property
5
+ * @description Interface
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @namespace Property
4
+ * @description Map
5
+ */
6
+ import { ImbricatePropertyKey } from "./definition";
7
+ import { IImbricateProperty } from "./interface";
8
+ import { IMBRICATE_PROPERTY_TYPE } from "./type";
9
+ export type ImbricatePropertyRecord = Record<ImbricatePropertyKey, IImbricateProperty<IMBRICATE_PROPERTY_TYPE>>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * @author WMXPY
4
+ * @namespace Property
5
+ * @description Map
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @author WMXPY
3
- * @namespace Document
4
- * @description Property
3
+ * @namespace Property
4
+ * @description Type
5
5
  */
6
6
  /**
7
- * Document properties
7
+ * Property type
8
8
  */
9
9
  export declare enum IMBRICATE_PROPERTY_TYPE {
10
10
  /**
@@ -48,24 +48,9 @@ export declare enum IMBRICATE_PROPERTY_TYPE {
48
48
  */
49
49
  REFERENCE = "REFERENCE"
50
50
  }
51
- /**
52
- * Document properties
53
- *
54
- * Key - Property key, which should match schema properties unique identifier
55
- * Value - Property value, which should match schema properties type
56
- */
57
- export type DocumentProperties = Record<DocumentPropertyKey, DocumentPropertyValue<IMBRICATE_PROPERTY_TYPE>>;
58
- /**
59
- * Document property key, which should match schema properties unique identifier
60
- */
61
- export type DocumentPropertyKey = string;
62
- export type DocumentPropertyValue<T extends IMBRICATE_PROPERTY_TYPE> = {
63
- readonly type: T;
64
- readonly value: DocumentPropertyValueObject<T>;
65
- };
66
- export type DocumentPropertyValueObjectReference = {
51
+ export type ImbricatePropertyValueObjectReference = {
67
52
  readonly originUniqueIdentifier: string;
68
53
  readonly databaseUniqueIdentifier: string;
69
54
  readonly documentUniqueIdentifier: string;
70
55
  };
71
- export type DocumentPropertyValueObject<T extends IMBRICATE_PROPERTY_TYPE> = T extends IMBRICATE_PROPERTY_TYPE.BOOLEAN ? boolean : T extends IMBRICATE_PROPERTY_TYPE.STRING ? string : T extends IMBRICATE_PROPERTY_TYPE.NUMBER ? number : T extends IMBRICATE_PROPERTY_TYPE.MARKDOWN ? string : T extends IMBRICATE_PROPERTY_TYPE.JSON ? string : T extends IMBRICATE_PROPERTY_TYPE.IMBRISCRIPT ? string : T extends IMBRICATE_PROPERTY_TYPE.DATE ? string : T extends IMBRICATE_PROPERTY_TYPE.LABEL ? string[] : T extends IMBRICATE_PROPERTY_TYPE.REFERENCE ? DocumentPropertyValueObjectReference[] : never;
56
+ export type ImbricatePropertyValueObject<T extends IMBRICATE_PROPERTY_TYPE> = T extends IMBRICATE_PROPERTY_TYPE.BOOLEAN ? boolean : T extends IMBRICATE_PROPERTY_TYPE.STRING ? string : T extends IMBRICATE_PROPERTY_TYPE.NUMBER ? number : T extends IMBRICATE_PROPERTY_TYPE.MARKDOWN ? string : T extends IMBRICATE_PROPERTY_TYPE.JSON ? string : T extends IMBRICATE_PROPERTY_TYPE.IMBRISCRIPT ? string : T extends IMBRICATE_PROPERTY_TYPE.DATE ? string : T extends IMBRICATE_PROPERTY_TYPE.LABEL ? string[] : T extends IMBRICATE_PROPERTY_TYPE.REFERENCE ? ImbricatePropertyValueObjectReference[] : never;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  /**
3
3
  * @author WMXPY
4
- * @namespace Document
5
- * @description Property
4
+ * @namespace Property
5
+ * @description Type
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.IMBRICATE_PROPERTY_TYPE = void 0;
9
9
  /**
10
- * Document properties
10
+ * Property type
11
11
  */
12
12
  var IMBRICATE_PROPERTY_TYPE;
13
13
  (function (IMBRICATE_PROPERTY_TYPE) {
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @author WMXPY
3
- * @namespace Document
3
+ * @namespace Property
4
4
  * @description Validate
5
5
  */
6
6
  import { ImbricateDatabaseSchema } from "../database/schema";
7
- import { DocumentProperties } from "./property";
7
+ import { ImbricatePropertyRecord } from "./map";
8
8
  /**
9
9
  * Validate properties with schema
10
10
  *
@@ -15,4 +15,4 @@ import { DocumentProperties } from "./property";
15
15
  * @returns a string error message if validation failed
16
16
  * null if validation passed
17
17
  */
18
- export declare const validateImbricateProperties: (properties: DocumentProperties, schema: ImbricateDatabaseSchema, allowExtraProperties?: boolean) => string | null;
18
+ export declare const validateImbricateProperties: (properties: ImbricatePropertyRecord, schema: ImbricateDatabaseSchema, allowExtraProperties?: boolean) => string | null;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  /**
3
3
  * @author WMXPY
4
- * @namespace Document
4
+ * @namespace Property
5
5
  * @description Validate
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.validateImbricateProperties = void 0;
9
- const property_1 = require("./property");
9
+ const type_1 = require("./type");
10
10
  /**
11
11
  * Validate properties with schema
12
12
  *
@@ -23,86 +23,86 @@ const validateImbricateProperties = (properties, schema, allowExtraProperties =
23
23
  }
24
24
  const keys = Object.keys(properties);
25
25
  for (const key of keys) {
26
- const property = schema.properties.find((each) => {
26
+ const schemaProperty = schema.properties.find((each) => {
27
27
  return each.propertyIdentifier === key;
28
28
  });
29
- if (!property) {
29
+ if (!schemaProperty) {
30
30
  if (allowExtraProperties) {
31
31
  continue;
32
32
  }
33
33
  return `Property ${key} not found in schema`;
34
34
  }
35
- const value = properties[key];
36
- if (typeof value.type !== "string") {
35
+ const property = properties[key];
36
+ if (typeof property.propertyType !== "string") {
37
37
  return `Property ${key} type must be a string`;
38
38
  }
39
- if (value.type !== property.propertyType) {
40
- return `Property ${key} type must be ${property.propertyType}, but got ${value.type}`;
39
+ if (property.propertyType !== property.propertyType) {
40
+ return `Property ${key} type must be ${property.propertyType}, but got ${property.propertyType}`;
41
41
  }
42
42
  // IMBRICATE_PROPERTY_TYPE SWITCH
43
- switch (value.type) {
44
- case property_1.IMBRICATE_PROPERTY_TYPE.BOOLEAN: {
45
- if (typeof value.value !== "boolean") {
43
+ switch (property.propertyType) {
44
+ case type_1.IMBRICATE_PROPERTY_TYPE.BOOLEAN: {
45
+ if (typeof property.propertyValue !== "boolean") {
46
46
  return `Property ${key} value must be a boolean`;
47
47
  }
48
48
  break;
49
49
  }
50
- case property_1.IMBRICATE_PROPERTY_TYPE.STRING: {
51
- if (typeof value.value !== "string") {
50
+ case type_1.IMBRICATE_PROPERTY_TYPE.STRING: {
51
+ if (typeof property.propertyValue !== "string") {
52
52
  return `Property ${key} value must be a string`;
53
53
  }
54
54
  break;
55
55
  }
56
- case property_1.IMBRICATE_PROPERTY_TYPE.NUMBER: {
57
- if (typeof value.value !== "number") {
56
+ case type_1.IMBRICATE_PROPERTY_TYPE.NUMBER: {
57
+ if (typeof property.propertyValue !== "number") {
58
58
  return `Property ${key} value must be a number`;
59
59
  }
60
60
  break;
61
61
  }
62
- case property_1.IMBRICATE_PROPERTY_TYPE.MARKDOWN: {
63
- if (typeof value.value !== "string") {
62
+ case type_1.IMBRICATE_PROPERTY_TYPE.MARKDOWN: {
63
+ if (typeof property.propertyValue !== "string") {
64
64
  return `Property ${key} value must be a string`;
65
65
  }
66
66
  break;
67
67
  }
68
- case property_1.IMBRICATE_PROPERTY_TYPE.JSON: {
69
- if (typeof value.value !== "string") {
68
+ case type_1.IMBRICATE_PROPERTY_TYPE.JSON: {
69
+ if (typeof property.propertyValue !== "string") {
70
70
  return `Property ${key} value must be a string`;
71
71
  }
72
72
  break;
73
73
  }
74
- case property_1.IMBRICATE_PROPERTY_TYPE.IMBRISCRIPT: {
75
- if (typeof value.value !== "string") {
74
+ case type_1.IMBRICATE_PROPERTY_TYPE.IMBRISCRIPT: {
75
+ if (typeof property.propertyValue !== "string") {
76
76
  return `Property ${key} value must be a string`;
77
77
  }
78
78
  break;
79
79
  }
80
- case property_1.IMBRICATE_PROPERTY_TYPE.DATE: {
81
- if (typeof value.value !== "string") {
80
+ case type_1.IMBRICATE_PROPERTY_TYPE.DATE: {
81
+ if (typeof property.propertyValue !== "string") {
82
82
  return `Property ${key} value must be a string of date in ISO format`;
83
83
  }
84
- const date = new Date(value.value);
84
+ const date = new Date(property.propertyValue);
85
85
  if (isNaN(date.getTime())) {
86
86
  return `Property ${key} value must be a string of date in ISO format`;
87
87
  }
88
88
  break;
89
89
  }
90
- case property_1.IMBRICATE_PROPERTY_TYPE.LABEL: {
91
- if (!Array.isArray(value.value)) {
90
+ case type_1.IMBRICATE_PROPERTY_TYPE.LABEL: {
91
+ if (!Array.isArray(property.propertyValue)) {
92
92
  return `Property ${key} value must be an array of string`;
93
93
  }
94
- for (const label of value.value) {
94
+ for (const label of property.propertyValue) {
95
95
  if (typeof label !== "string") {
96
96
  return `Property ${key} label must be a string`;
97
97
  }
98
98
  }
99
99
  break;
100
100
  }
101
- case property_1.IMBRICATE_PROPERTY_TYPE.REFERENCE: {
102
- if (!Array.isArray(value.value)) {
101
+ case type_1.IMBRICATE_PROPERTY_TYPE.REFERENCE: {
102
+ if (!Array.isArray(property.propertyValue)) {
103
103
  return `Property ${key} value must be an array of string`;
104
104
  }
105
- for (const reference of value.value) {
105
+ for (const reference of property.propertyValue) {
106
106
  if (typeof reference !== "object") {
107
107
  return `Property ${key} reference must be an object`;
108
108
  }
@@ -118,6 +118,9 @@ const validateImbricateProperties = (properties, schema, allowExtraProperties =
118
118
  }
119
119
  break;
120
120
  }
121
+ default: {
122
+ return `Property ${key} type ${property.propertyType} is not supported`;
123
+ }
121
124
  }
122
125
  }
123
126
  return null;