@decaf-ts/ui-decorators 0.4.5 → 0.4.6

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 (61) hide show
  1. package/dist/esm/ui-decorators.bundle.min.esm.js +2 -0
  2. package/dist/esm/ui-decorators.bundle.min.esm.js.LICENSE.txt +14 -0
  3. package/dist/ui-decorators.bundle.min.js +2 -0
  4. package/dist/ui-decorators.bundle.min.js.LICENSE.txt +14 -0
  5. package/lib/esm/index.d.ts +12 -0
  6. package/lib/esm/index.js +14 -0
  7. package/lib/esm/model/Renderable.d.ts +3 -0
  8. package/lib/esm/model/Renderable.js +3 -0
  9. package/lib/esm/model/decorators.d.ts +25 -0
  10. package/lib/esm/model/decorators.js +41 -0
  11. package/lib/esm/model/index.d.ts +8 -0
  12. package/lib/esm/model/index.js +10 -0
  13. package/lib/esm/model/model.d.ts +115 -0
  14. package/lib/esm/model/model.js +3 -0
  15. package/lib/esm/model/overrides.d.ts +1 -0
  16. package/lib/esm/model/overrides.js +7 -0
  17. package/lib/esm/ui/Rendering.d.ts +183 -0
  18. package/lib/esm/ui/Rendering.js +298 -0
  19. package/lib/esm/ui/constants.d.ts +64 -0
  20. package/lib/esm/ui/constants.js +88 -0
  21. package/lib/esm/ui/decorators.d.ts +34 -0
  22. package/lib/esm/ui/decorators.js +62 -0
  23. package/lib/esm/ui/errors.d.ts +4 -0
  24. package/lib/esm/ui/errors.js +8 -0
  25. package/lib/esm/ui/index.d.ts +11 -0
  26. package/lib/esm/ui/index.js +13 -0
  27. package/lib/esm/ui/interfaces.d.ts +5 -0
  28. package/lib/esm/ui/interfaces.js +3 -0
  29. package/lib/esm/ui/types.d.ts +46 -0
  30. package/lib/esm/ui/types.js +3 -0
  31. package/lib/esm/ui/utils.d.ts +13 -0
  32. package/lib/esm/ui/utils.js +88 -0
  33. package/lib/index.cjs +29 -0
  34. package/lib/index.d.ts +12 -0
  35. package/lib/model/Renderable.cjs +2 -0
  36. package/lib/model/Renderable.d.ts +3 -0
  37. package/lib/model/decorators.cjs +43 -0
  38. package/lib/model/decorators.d.ts +25 -0
  39. package/lib/model/index.cjs +24 -0
  40. package/lib/model/index.d.ts +8 -0
  41. package/lib/model/model.cjs +2 -0
  42. package/lib/model/model.d.ts +115 -0
  43. package/lib/model/overrides.cjs +7 -0
  44. package/lib/model/overrides.d.ts +1 -0
  45. package/lib/ui/Rendering.cjs +300 -0
  46. package/lib/ui/Rendering.d.ts +183 -0
  47. package/lib/ui/constants.cjs +89 -0
  48. package/lib/ui/constants.d.ts +64 -0
  49. package/lib/ui/decorators.cjs +66 -0
  50. package/lib/ui/decorators.d.ts +34 -0
  51. package/lib/ui/errors.cjs +10 -0
  52. package/lib/ui/errors.d.ts +4 -0
  53. package/lib/ui/index.cjs +27 -0
  54. package/lib/ui/index.d.ts +11 -0
  55. package/lib/ui/interfaces.cjs +2 -0
  56. package/lib/ui/interfaces.d.ts +5 -0
  57. package/lib/ui/types.cjs +2 -0
  58. package/lib/ui/types.d.ts +46 -0
  59. package/lib/ui/utils.cjs +94 -0
  60. package/lib/ui/utils.d.ts +13 -0
  61. package/package.json +1 -1
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Tags the model as a uimodel, giving it the 'render' method
3
+ *
4
+ * @param {string} [tag] optional param. will render the provided elment wrapping the attribute uielements
5
+ * @param {{}} [props] optional param. Attributes to be passed to the tag element
6
+ * @param {function(any): void} [instanceCallback] optional callback returning the instance after creation for additional logic
7
+ *
8
+ * @decorator uimodel
9
+ *
10
+ * @mermaid
11
+ * sequenceDiagram
12
+ * participant System
13
+ * participant uimodel
14
+ * participant constructor
15
+ * participant instance
16
+ * System->>uimodel:do(constructor)
17
+ * uimodel->>constructor: Executes the constructor
18
+ * constructor->>uimodel: returns instance
19
+ * uimodel->>instance: adds the render method
20
+ * uimodel->>System: returns UIModel instance
21
+ *
22
+ * @category Decorators
23
+ */
24
+ export declare function uimodel(tag?: string, props?: Record<string, any>): (original: any, propertyKey?: any) => void;
25
+ export declare function renderedBy(engine: string): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor) => void;
@@ -0,0 +1,41 @@
1
+ import { UIKeys } from "../ui/constants";
2
+ import { apply, metadata } from "@decaf-ts/reflection";
3
+ import { RenderingEngine } from "../ui/Rendering";
4
+ /**
5
+ * Tags the model as a uimodel, giving it the 'render' method
6
+ *
7
+ * @param {string} [tag] optional param. will render the provided elment wrapping the attribute uielements
8
+ * @param {{}} [props] optional param. Attributes to be passed to the tag element
9
+ * @param {function(any): void} [instanceCallback] optional callback returning the instance after creation for additional logic
10
+ *
11
+ * @decorator uimodel
12
+ *
13
+ * @mermaid
14
+ * sequenceDiagram
15
+ * participant System
16
+ * participant uimodel
17
+ * participant constructor
18
+ * participant instance
19
+ * System->>uimodel:do(constructor)
20
+ * uimodel->>constructor: Executes the constructor
21
+ * constructor->>uimodel: returns instance
22
+ * uimodel->>instance: adds the render method
23
+ * uimodel->>System: returns UIModel instance
24
+ *
25
+ * @category Decorators
26
+ */
27
+ export function uimodel(tag, props) {
28
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
+ return (original, propertyKey) => {
30
+ const meta = {
31
+ tag: tag || original.name,
32
+ props: props,
33
+ };
34
+ return metadata(RenderingEngine.key(UIKeys.UIMODEL), meta)(original);
35
+ };
36
+ }
37
+ export function renderedBy(engine) {
38
+ return apply(metadata(RenderingEngine.key(UIKeys.RENDERED_BY), engine));
39
+ }
40
+
41
+ //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9tb2RlbC9kZWNvcmF0b3JzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUN6QyxPQUFPLEVBQUUsS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBQ3ZELE9B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kgRGVjb3JhdG9yc1xuICovXG5leHBvcnQgZnVuY3Rpb24gdWltb2RlbCh0YWc/OiBzdHJpbmcsIHByb3BzPzogUmVjb3JkPHN0cmluZywgYW55Pikge1xuICAvLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgQHR5cGVzY3JpcHQtZXNsaW50L25vLXVudXNlZC12YXJzXG4gIHJldHVybiAob3JpZ2luYWw6IGFueSwgcHJvcGVydHlLZXk/OiBhbnkpID0+IHtcbiAgICBjb25zdCBtZXRhOiBVSU1vZGVsTWV0YWRhdGEgPSB7XG4gICAgICB0YWc6IHRhZyB8fCBvcmlnaW5hbC5uYW1lLFxuICAgICAgcHJvcHM6IHByb3BzLFxuICAgIH07XG4gICAgcmV0dXJuIG1ldGFkYXRhKFJlbmRlcmluZ0VuZ2luZS5rZXkoVUlLZXlzLlVJTU9ERUwpLCBtZXRhKShvcmlnaW5hbCk7XG4gIH07XG59XG5cbmV4cG9ydCBmdW5jdGlvbiByZW5kZXJlZEJ5KGVuZ2luZTogc3RyaW5nKSB7XG4gIHJldHVybiBhcHBseShtZXRhZGF0YShSZW5kZXJpbmdFbmdpbmUua2V5KFVJS2V5cy5SRU5ERVJFRF9CWSksIGVuZ2luZSkpO1xufVxuIl19
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @namespace model
3
+ * @memberOf ui-decorators
4
+ */
5
+ import "./model";
6
+ export * from "./decorators";
7
+ export * from "./overrides";
8
+ export * from "./Renderable";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @namespace model
3
+ * @memberOf ui-decorators
4
+ */
5
+ import "./model";
6
+ export * from "./decorators";
7
+ export * from "./overrides";
8
+ export * from "./Renderable";
9
+
10
+ //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9tb2RlbC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7O0dBR0c7QUFFSCxPQUFPLFNBQVMsQ0FBQztBQUVqQixjQUFjLGNBQWMsQ0FBQztBQUM3QixjQUFjLGFBQWEsQ0FBQztBQUM1QixjQUFjLGNBQWMsQ0FBQyIsImZpbGUiOiJtb2RlbC9pbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQG5hbWVzcGFjZSBtb2RlbFxuICogQG1lbWJlck9mIHVpLWRlY29yYXRvcnNcbiAqL1xuXG5pbXBvcnQgXCIuL21vZGVsXCI7XG5cbmV4cG9ydCAqIGZyb20gXCIuL2RlY29yYXRvcnNcIjtcbmV4cG9ydCAqIGZyb20gXCIuL292ZXJyaWRlc1wiO1xuZXhwb3J0ICogZnJvbSBcIi4vUmVuZGVyYWJsZVwiO1xuIl19
@@ -0,0 +1,115 @@
1
+ import { ModelErrorDefinition } from "@decaf-ts/decorator-validation";
2
+ import { BuilderRegistry, Comparable, Constructor, Hashable, ModelArg, ModelBuilderFunction, ModelConstructor, Serializable, Validatable } from "@decaf-ts/decorator-validation";
3
+ import { Renderable } from "./Renderable";
4
+ declare module "@decaf-ts/decorator-validation" {
5
+ abstract class Model implements Validatable, Serializable, Hashable, Comparable<Model>, Renderable {
6
+ protected constructor(arg?: ModelArg<Model>);
7
+ hasErrors(...exclusions: any[]): ModelErrorDefinition | undefined;
8
+ hasErrors(previousVersion?: Model | any, ...exclusions: any[]): ModelErrorDefinition | undefined;
9
+ /**
10
+ * @summary Compare object equality recursively
11
+ * @param {any} obj object to compare to
12
+ * @param {string} [exceptions] property names to be excluded from the comparison
13
+ */
14
+ equals(obj: any, ...exceptions: string[]): boolean;
15
+ /**
16
+ * @summary Returns the serialized model according to the currently defined {@link Serializer}
17
+ */
18
+ serialize(): string;
19
+ /**
20
+ * @summary Override the implementation for js's 'toString()' which sucks...
21
+ * @override
22
+ */
23
+ toString(): string;
24
+ /**
25
+ * @summary Defines a default implementation for object hash. Relies on a very basic implementation based on Java's string hash;
26
+ */
27
+ hash(): string;
28
+ /**
29
+ * @summary Deserializes a Model
30
+ * @param {string} str
31
+ *
32
+ * @param args
33
+ * @throws {Error} If it fails to parse the string, or if it fails to build the model
34
+ */
35
+ static deserialize(str: string): any;
36
+ /**
37
+ * @summary Repopulates the Object properties with the ones from the new object
38
+ * @description Iterates all common properties of obj (if existing) and self, and copies them onto self
39
+ *
40
+ * @param {T} self
41
+ * @param {T | Record<string, any>} [obj]
42
+ *
43
+ */
44
+ static fromObject<T extends Model>(self: T, obj?: T | Record<string, any>): T;
45
+ /**
46
+ * @summary Repopulates the instance with the ones from the new Model Object
47
+ * @description Iterates all common properties of obj (if existing) and self, and copies them onto self.
48
+ * Is aware of nested Model Objects and rebuilds them also.
49
+ * When List properties are decorated with {@link list}, they list items will also be rebuilt
50
+ *
51
+ * @param {T} self
52
+ * @param {T | Record<string, any>} [obj]
53
+ *
54
+ */
55
+ static fromModel<T extends Model>(self: T, obj?: T | Record<string, any>): T;
56
+ /**
57
+ * @summary Sets the Global {@link ModelBuilderFunction}
58
+ * @param {ModelBuilderFunction} [builder]
59
+ */
60
+ static setBuilder(builder?: ModelBuilderFunction): void;
61
+ /**
62
+ * @summary Retrieves the current global {@link ModelBuilderFunction}
63
+ */
64
+ static getBuilder(): ModelBuilderFunction | undefined;
65
+ /**
66
+ * Returns the current {@link ModelRegistryManager}
67
+ *
68
+ * @return ModelRegistry, defaults to {@link ModelRegistryManager}
69
+ */
70
+ private static getRegistry;
71
+ /**
72
+ * Returns the current actingModelRegistry
73
+ *
74
+ * @param {BuilderRegistry} modelRegistry the new implementation of Registry
75
+ */
76
+ static setRegistry(modelRegistry: BuilderRegistry<any>): void;
77
+ /**
78
+ * @summary register new Models
79
+ * @param {any} constructor
80
+ * @param {string} [name] when not defined, the name of the constructor will be used
81
+ *
82
+ * @see ModelRegistry
83
+ */
84
+ static register<T extends Model>(constructor: ModelConstructor<T>, name?: string): void;
85
+ /**
86
+ * @summary Gets a registered Model {@link ModelConstructor}
87
+ * @param {string} name
88
+ *
89
+ * @see ModelRegistry
90
+ */
91
+ static get<T extends Model>(name: string): ModelConstructor<T> | undefined;
92
+ /**
93
+ * @param {Record<string, any>} obj
94
+ * @param {string} [clazz] when provided, it will attempt to find the matching constructor
95
+ *
96
+ * @throws Error If clazz is not found, or obj is not a {@link Model} meaning it has no {@link ModelKeys.ANCHOR} property
97
+ *
98
+ * @see ModelRegistry
99
+ */
100
+ static build<T extends Model>(obj?: Record<string, any>, clazz?: string): T;
101
+ static getMetadata<V extends Model>(model: V): any;
102
+ static getAttributes<V extends Model>(model: Constructor<V> | V): string[];
103
+ static equals<V extends Model>(obj1: V, obj2: V, ...exceptions: any[]): boolean;
104
+ static hasErrors<V extends Model>(model: V, ...exceptions: any[]): ModelErrorDefinition | undefined;
105
+ static serialize<V extends Model>(model: V): any;
106
+ static hash<V extends Model>(model: V): any;
107
+ /**
108
+ * @summary Builds the key to store as Metadata under Reflections
109
+ * @description concatenates {@link ModelKeys#REFLECT} with the provided key
110
+ * @param {string} str
111
+ */
112
+ static key(str: string): string;
113
+ render<R>(...args: any[]): R;
114
+ }
115
+ }
@@ -0,0 +1,3 @@
1
+ export {};
2
+
3
+ //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9tb2RlbC9tb2RlbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwiZmlsZSI6Im1vZGVsL21vZGVsLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgTW9kZWxFcnJvckRlZmluaXRpb24gfSBmcm9tIFwiQGRlY2FmLXRzL2RlY29yYXRvci12YWxpZGF0aW9uXCI7XG5pbXBvcnQge1xuICBCdWlsZGVyUmVnaXN0cnksXG4gIENvbXBhcmFibGUsXG4gIENvbnN0cnVjdG9yLFxuICBIYXNoYWJsZSxcbiAgTW9kZWxBcmcsXG4gIE1vZGVsQnVpbGRlckZ1bmN0aW9uLFxuICBNb2RlbENvbnN0cnVjdG9yLFxuICBTZXJpYWxpemFibGUs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FRkxFQ1R9IHdpdGggdGhlIHByb3ZpZGVkIGtleVxuICAgICAqIEBwYXJhbSB7c3RyaW5nfSBzdHJcbiAgICAgKi9cbiAgICBzdGF0aWMga2V5KHN0cjogc3RyaW5nKTogc3RyaW5nO1xuICAgIHJlbmRlcjxSPiguLi5hcmdzOiBhbnlbXSk6IFI7XG4gIH1cbn1cbiJdfQ==
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import { Model } from "@decaf-ts/decorator-validation";
2
+ import { RenderingEngine } from "../ui/Rendering";
3
+ Model.prototype.render = function (...args) {
4
+ return RenderingEngine.render(this, ...args);
5
+ };
6
+
7
+ //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9tb2RlbC9vdmVycmlkZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3ZELE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUVsRCxLQUFLLENBQUMsU0FBUyxDQUFDLE1BQU0sR0FBRyxVQUFvQyxHQUFHLElBQVc7SUFDekUsT0FBTyxlQUFlLENBQUMsTUFBTSxDQUFDLElBQUksRUFBRSxHQUFHLElBQUksQ0FBQyxDQUFDO0FBQy9DLENBQUMsQ0FBQyIsImZpbGUiOiJtb2RlbC9vdmVycmlkZXMuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBNb2RlbCB9IGZyb20gXCJAZGVjYWYtdHMvZGVjb3JhdG9yLXZhbGlkYXRpb25cIjtcbmltcG9ydCB7IFJlbmRlcmluZ0VuZ2luZSB9IGZyb20gXCIuLi91aS9SZW5kZXJpbmdcIjtcblxuTW9kZWwucHJvdG90eXBlLnJlbmRlciA9IGZ1bmN0aW9uIDxNIGV4dGVuZHMgTW9kZWw+KHRoaXM6IE0sIC4uLmFyZ3M6IGFueVtdKSB7XG4gIHJldHVybiBSZW5kZXJpbmdFbmdpbmUucmVuZGVyKHRoaXMsIC4uLmFyZ3MpO1xufTtcbiJdfQ==
@@ -0,0 +1,183 @@
1
+ import { Model, ValidationMetadata } from "@decaf-ts/decorator-validation";
2
+ import { FieldDefinition } from "./types";
3
+ /**
4
+ * @description Abstract class for rendering UI components based on model metadata.
5
+ * @summary The RenderingEngine class provides a framework for converting model metadata into UI field definitions.
6
+ * It handles the translation of model properties to UI elements, applies validation rules, and manages different rendering flavors.
7
+ * This class is designed to be extended by specific rendering implementations.
8
+ *
9
+ * @template T The type of the rendering result, defaults to void
10
+ * @template R The type of the field definition, defaults to FieldDefinition<T>
11
+ *
12
+ * @param {string} flavour - The flavor of the rendering engine.
13
+ *
14
+ * @class RenderingEngine
15
+ */
16
+ export declare abstract class RenderingEngine<T = void, R = FieldDefinition<T>> {
17
+ readonly flavour: string;
18
+ /**
19
+ * @description Cache for storing rendering engine instances or constructors.
20
+ * @private
21
+ * @static
22
+ */
23
+ private static cache;
24
+ /**
25
+ * @description The currently active rendering engine.
26
+ * @private
27
+ * @static
28
+ */
29
+ private static current;
30
+ /**
31
+ * Flag indicating whether the rendering engine has been initialized.
32
+ */
33
+ protected initialized: boolean;
34
+ protected constructor(flavour: string);
35
+ /**
36
+ * @description Initializes the rendering engine.
37
+ * @summary Abstract method to be implemented by subclasses for specific initialization logic.
38
+ *
39
+ * @param {...any[]} args - Any additional arguments needed for initialization.
40
+ * @returns {Promise<void>} A promise that resolves when initialization is complete.
41
+ *
42
+ * @abstract
43
+ */
44
+ abstract initialize(...args: any[]): Promise<void>;
45
+ /**
46
+ * @description Translates between model types and HTML input types.
47
+ * @summary Converts model data types to appropriate HTML input types and vice versa.
48
+ *
49
+ * @param {string} key - The key to translate.
50
+ * @param {boolean} [toView=true] - Direction of translation (true for model to view, false for view to model).
51
+ * @returns {string} The translated type.
52
+ */
53
+ translate(key: string, toView?: boolean): string;
54
+ /**
55
+ * @description Checks if a type is validatable by its nature.
56
+ * @summary Determines if a given UI key represents a type that is inherently validatable.
57
+ *
58
+ * @param {string} key - The UI key to check.
59
+ * @returns {boolean} True if the type is validatable, false otherwise.
60
+ */
61
+ protected isValidatableByType(key: string): boolean;
62
+ /**
63
+ * @description Checks if a type is validatable by attribute.
64
+ * @summary Determines if a given UI key represents a validation that can be applied as an attribute.
65
+ *
66
+ * @param {string} key - The UI key to check.
67
+ * @returns {boolean} True if the type is validatable by attribute, false otherwise.
68
+ */
69
+ protected isValidatableByAttribute(key: string): boolean;
70
+ /**
71
+ * @description Converts validation metadata to an attribute value.
72
+ * @summary Transforms validation metadata into a value suitable for use as an HTML attribute.
73
+ *
74
+ * @param {string} key - The validation key.
75
+ * @param {ValidationMetadata} value - The validation metadata.
76
+ * @returns {string | number | boolean} The converted attribute value.
77
+ * @throws {Error} If the given key is not validatable by attribute.
78
+ */
79
+ protected toAttributeValue(key: string, value: ValidationMetadata): string | number | boolean;
80
+ /**
81
+ * @description Converts a model to a field definition.
82
+ * @summary Processes a model instance, extracting UI-related metadata and validation rules to create a field definition.
83
+ *
84
+ * @template M Type extending Model
85
+ * @template T Type referencing the specific Rendering engine field properties/inputs
86
+ * @param {M} model - The model instance to convert.
87
+ * @param {Record<string, unknown>} [globalProps={}] - Global properties to apply to all child elements.
88
+ * @param {boolean} [generateId=true] - Flag indicating whether to populate the rendererId property.
89
+ * @returns {FieldDefinition<T>} A field definition object representing the UI structure of the model.
90
+ * @throws {RenderingError} If no UI definitions are set for the model or if there are invalid decorators.
91
+ *
92
+ * @mermaid
93
+ * sequenceDiagram
94
+ * participant C as Client
95
+ * participant RE as RenderingEngine
96
+ * participant R as Reflection
97
+ * participant M as Model
98
+ * C->>RE: toFieldDefinition(model, globalProps)
99
+ * RE->>R: getMetadata(UIKeys.UIMODEL, model.constructor)
100
+ * R-->>RE: UIModelMetadata
101
+ * RE->>R: getAllPropertyDecorators(model, UIKeys.REFLECT)
102
+ * R-->>RE: Record<string, DecoratorMetadata[]>
103
+ * RE->>R: getAllPropertyDecorators(model, ValidationKeys.REFLECT)
104
+ * R-->>RE: Record<string, DecoratorMetadata<ValidationMetadata>[]>
105
+ * loop For each property
106
+ * RE->>RE: Process UI decorators
107
+ * RE->>RE: Apply validation rules
108
+ * end
109
+ * RE-->>C: FieldDefinition<T>
110
+ */
111
+ protected toFieldDefinition<M extends Model>(model: M, globalProps?: Record<string, unknown>, generateId?: boolean): FieldDefinition<T>;
112
+ /**
113
+ * @description Renders a model with global properties and additional arguments.
114
+ * @summary Abstract method to be implemented by subclasses to define specific rendering behavior.
115
+ *
116
+ * @template M Type extending Model
117
+ * @template R Rendering engine implementation specific output type
118
+ * @param {M} model - The model to be rendered.
119
+ * @param {Record<string, unknown>} globalProps - Global properties to be applied to all elements during rendering.
120
+ * @param {...any[]} args - Additional arguments that may be required for specific rendering implementations.
121
+ * @returns {R} The rendered result, type depends on the specific implementation.
122
+ *
123
+ * @abstract
124
+ */
125
+ abstract render<M extends Model>(model: M, globalProps: Record<string, unknown>, ...args: any[]): R;
126
+ /**
127
+ * @description Registers a rendering engine instance.
128
+ * @summary Adds a rendering engine to the static cache and sets it as the current engine.
129
+ *
130
+ * @param {RenderingEngine<unknown, unknown>} engine - The rendering engine to register.
131
+ * @throws {InternalError} If an engine with the same flavor already exists.
132
+ *
133
+ * @static
134
+ */
135
+ static register(engine: RenderingEngine<unknown, unknown>): void;
136
+ /**
137
+ * @description Retrieves or initializes a rendering engine.
138
+ * @summary Gets an existing engine instance or creates and initializes a new one if given a constructor.
139
+ *
140
+ * @template O The type of the rendering engine output
141
+ * @param {Constructor<RenderingEngine<O>> | RenderingEngine<O>} obj - The engine instance or constructor.
142
+ * @returns {RenderingEngine<O>} The initialized rendering engine.
143
+ *
144
+ * @private
145
+ * @static
146
+ */
147
+ private static getOrBoot;
148
+ /**
149
+ * @description Retrieves a rendering engine by flavor.
150
+ * @summary Gets the current rendering engine or a specific one by flavor.
151
+ *
152
+ * @template O The type of the rendering engine output
153
+ * @param {string} [flavour] - The flavor of the rendering engine to retrieve.
154
+ * @returns {RenderingEngine<O>} The requested rendering engine.
155
+ * @throws {InternalError} If the requested flavor does not exist.
156
+ *
157
+ * @static
158
+ */
159
+ static get<O>(flavour?: string): RenderingEngine<O>;
160
+ /**
161
+ * @description Renders a model using the appropriate rendering engine.
162
+ * @summary Determines the correct rendering engine for a model and invokes its render method.
163
+ *
164
+ * @template M Type extending Model
165
+ * @param {M} model - The model to render.
166
+ * @param {...any[]} args - Additional arguments to pass to the render method.
167
+ * @returns {any} The result of the rendering process.
168
+ * @throws {InternalError} If no registered model is found.
169
+ *
170
+ * @static
171
+ */
172
+ static render<M extends Model>(model: M, ...args: any[]): any;
173
+ /**
174
+ * @description Generates a metadata key for UI-related properties.
175
+ * @summary Prefixes a given key with the UI reflection prefix.
176
+ *
177
+ * @param {string} key - The key to prefix.
178
+ * @returns {string} The prefixed key.
179
+ *
180
+ * @static
181
+ */
182
+ static key(key: string): string;
183
+ }