@decaf-ts/ui-decorators 0.9.0 → 0.11.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 (112) hide show
  1. package/lib/cjs/index.cjs +9 -8
  2. package/lib/cjs/index.cjs.map +1 -0
  3. package/lib/cjs/model/Renderable.cjs +1 -0
  4. package/lib/cjs/model/{Renderable.js.map → Renderable.cjs.map} +1 -1
  5. package/lib/cjs/model/decorators.cjs +9 -8
  6. package/lib/cjs/model/decorators.cjs.map +1 -0
  7. package/lib/cjs/model/index.cjs +1 -0
  8. package/lib/cjs/model/index.cjs.map +1 -0
  9. package/lib/cjs/model/model.cjs +1 -0
  10. package/lib/cjs/model/model.cjs.map +1 -0
  11. package/lib/cjs/model/overrides.cjs +19 -18
  12. package/lib/cjs/model/overrides.cjs.map +1 -0
  13. package/lib/cjs/overrides/ModelBuilderExtensions.cjs +8 -7
  14. package/lib/cjs/overrides/ModelBuilderExtensions.cjs.map +1 -0
  15. package/lib/cjs/overrides/index.cjs +1 -0
  16. package/lib/cjs/overrides/index.cjs.map +1 -0
  17. package/lib/cjs/ui/DecafComponent.cjs +4 -3
  18. package/lib/cjs/ui/DecafComponent.cjs.map +1 -0
  19. package/lib/cjs/ui/DecafEventHandler.cjs +3 -2
  20. package/lib/cjs/ui/DecafEventHandler.cjs.map +1 -0
  21. package/lib/cjs/ui/DecafTranslateService.cjs +1 -0
  22. package/lib/cjs/ui/DecafTranslateService.cjs.map +1 -0
  23. package/lib/cjs/ui/Rendering.cjs +62 -61
  24. package/lib/cjs/ui/Rendering.cjs.map +1 -0
  25. package/lib/cjs/ui/UIValidator.cjs +1 -0
  26. package/lib/cjs/ui/UIValidator.cjs.map +1 -0
  27. package/lib/cjs/ui/constants.cjs +4 -4
  28. package/lib/cjs/ui/constants.cjs.map +1 -0
  29. package/lib/cjs/ui/decorators.cjs +15 -14
  30. package/lib/cjs/ui/decorators.cjs.map +1 -0
  31. package/lib/cjs/ui/errors.cjs +1 -0
  32. package/lib/cjs/ui/errors.cjs.map +1 -0
  33. package/lib/cjs/ui/index.cjs +3 -2
  34. package/lib/cjs/ui/index.cjs.map +1 -0
  35. package/lib/cjs/ui/interfaces.cjs +1 -8
  36. package/lib/cjs/ui/interfaces.cjs.map +1 -0
  37. package/lib/cjs/ui/overrides.cjs +1 -0
  38. package/lib/cjs/ui/overrides.cjs.map +1 -0
  39. package/lib/cjs/ui/types.cjs +3 -2
  40. package/lib/cjs/ui/types.cjs.map +1 -0
  41. package/lib/cjs/ui/utils.cjs +7 -6
  42. package/lib/cjs/ui/utils.cjs.map +1 -0
  43. package/lib/cjs/ui/validator.cjs +1 -0
  44. package/lib/cjs/ui/validator.cjs.map +1 -0
  45. package/lib/esm/index.js +1 -1
  46. package/lib/types/index.d.cts +19 -0
  47. package/lib/types/index.d.mts +19 -0
  48. package/lib/types/index.d.ts +1 -1
  49. package/lib/types/model/Renderable.d.cts +18 -0
  50. package/lib/types/model/Renderable.d.mts +18 -0
  51. package/lib/types/model/decorators.d.cts +318 -0
  52. package/lib/types/model/decorators.d.mts +318 -0
  53. package/lib/types/model/index.d.cts +4 -0
  54. package/lib/types/model/index.d.mts +4 -0
  55. package/lib/types/model/model.d.cts +31 -0
  56. package/lib/types/model/model.d.mts +31 -0
  57. package/lib/types/model/overrides.d.cts +9 -0
  58. package/lib/types/model/overrides.d.mts +9 -0
  59. package/lib/types/overrides/ModelBuilderExtensions.d.cts +16 -0
  60. package/lib/types/overrides/ModelBuilderExtensions.d.mts +16 -0
  61. package/lib/types/overrides/index.d.cts +6 -0
  62. package/lib/types/overrides/index.d.mts +6 -0
  63. package/lib/types/ui/DecafComponent.d.cts +293 -0
  64. package/lib/types/ui/DecafComponent.d.mts +293 -0
  65. package/lib/types/ui/DecafEventHandler.d.cts +43 -0
  66. package/lib/types/ui/DecafEventHandler.d.mts +43 -0
  67. package/lib/types/ui/DecafTranslateService.d.cts +5 -0
  68. package/lib/types/ui/DecafTranslateService.d.mts +5 -0
  69. package/lib/types/ui/Rendering.d.cts +202 -0
  70. package/lib/types/ui/Rendering.d.mts +202 -0
  71. package/lib/types/ui/UIValidator.d.cts +6 -0
  72. package/lib/types/ui/UIValidator.d.mts +6 -0
  73. package/lib/types/ui/constants.d.cts +355 -0
  74. package/lib/types/ui/constants.d.mts +355 -0
  75. package/lib/types/ui/decorators.d.cts +482 -0
  76. package/lib/types/ui/decorators.d.mts +482 -0
  77. package/lib/types/ui/errors.d.cts +32 -0
  78. package/lib/types/ui/errors.d.mts +32 -0
  79. package/lib/types/ui/index.d.cts +11 -0
  80. package/lib/types/ui/index.d.mts +11 -0
  81. package/lib/types/ui/interfaces.d.cts +64 -0
  82. package/lib/types/ui/interfaces.d.mts +64 -0
  83. package/lib/types/ui/overrides.d.cts +1 -0
  84. package/lib/types/ui/overrides.d.mts +1 -0
  85. package/lib/types/ui/types.d.cts +186 -0
  86. package/lib/types/ui/types.d.mts +186 -0
  87. package/lib/types/ui/utils.d.cts +27 -0
  88. package/lib/types/ui/utils.d.mts +27 -0
  89. package/lib/types/ui/validator.d.cts +9 -0
  90. package/lib/types/ui/validator.d.mts +9 -0
  91. package/package.json +4 -4
  92. package/lib/cjs/index.js.map +0 -1
  93. package/lib/cjs/model/decorators.js.map +0 -1
  94. package/lib/cjs/model/index.js.map +0 -1
  95. package/lib/cjs/model/model.js.map +0 -1
  96. package/lib/cjs/model/overrides.js.map +0 -1
  97. package/lib/cjs/overrides/ModelBuilderExtensions.js.map +0 -1
  98. package/lib/cjs/overrides/index.js.map +0 -1
  99. package/lib/cjs/ui/DecafComponent.js.map +0 -1
  100. package/lib/cjs/ui/DecafEventHandler.js.map +0 -1
  101. package/lib/cjs/ui/DecafTranslateService.js.map +0 -1
  102. package/lib/cjs/ui/Rendering.js.map +0 -1
  103. package/lib/cjs/ui/UIValidator.js.map +0 -1
  104. package/lib/cjs/ui/constants.js.map +0 -1
  105. package/lib/cjs/ui/decorators.js.map +0 -1
  106. package/lib/cjs/ui/errors.js.map +0 -1
  107. package/lib/cjs/ui/index.js.map +0 -1
  108. package/lib/cjs/ui/interfaces.js.map +0 -1
  109. package/lib/cjs/ui/overrides.js.map +0 -1
  110. package/lib/cjs/ui/types.js.map +0 -1
  111. package/lib/cjs/ui/utils.js.map +0 -1
  112. package/lib/cjs/ui/validator.js.map +0 -1
@@ -0,0 +1,5 @@
1
+ import { LoggedClass } from "@decaf-ts/logging";
2
+ export declare class DecafTranslateService extends LoggedClass {
3
+ translate(key: string, params?: Record<string, any>): any;
4
+ instant(key: string, params?: Record<string, any>): any;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { LoggedClass } from "@decaf-ts/logging";
2
+ export declare class DecafTranslateService extends LoggedClass {
3
+ translate(key: string, params?: Record<string, any>): any;
4
+ instant(key: string, params?: Record<string, any>): any;
5
+ }
@@ -0,0 +1,202 @@
1
+ import { FieldDefinition } from "./types.cjs";
2
+ import { Model, ValidationMetadata } from "@decaf-ts/decorator-validation";
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
+ /**
17
+ * Represents the base abstraction for decaf rendering engines, handling engine registration,
18
+ * initialization, model-to-field translation, and runtime rendering orchestration.
19
+ * Implementations must provide initialization and rendering logic while leveraging the shared
20
+ * metadata-driven conversion utilities supplied here.
21
+ */
22
+ export declare abstract class RenderingEngine<T = void, R = FieldDefinition<T>> {
23
+ readonly flavour: string;
24
+ /**
25
+ * @description Cache for storing rendering engine instances or constructors.
26
+ * @private
27
+ * @static
28
+ */
29
+ private static cache;
30
+ /**
31
+ * @description The currently active rendering engine.
32
+ * @private
33
+ * @static
34
+ */
35
+ private static current;
36
+ /**
37
+ * Flag indicating whether the rendering engine has been initialized.
38
+ */
39
+ protected initialized: boolean;
40
+ protected constructor(flavour: string);
41
+ /**
42
+ * @description Initializes the rendering engine.
43
+ * @summary Abstract method to be implemented by subclasses for specific initialization logic.
44
+ *
45
+ * @param {...any[]} args - Any additional arguments needed for initialization.
46
+ * @returns {Promise<void>} A promise that resolves when initialization is complete.
47
+ *
48
+ * @abstract
49
+ */
50
+ abstract initialize(...args: any[]): Promise<void>;
51
+ /**
52
+ * @description Translates between model types and HTML input types.
53
+ * @summary Converts model data types to appropriate HTML input types and vice versa.
54
+ *
55
+ * @param {string} key - The key to translate.
56
+ * @param {boolean} [toView=true] - Direction of translation (true for model to view, false for view to model).
57
+ * @returns {string} The translated type.
58
+ */
59
+ translate(key: string, toView?: boolean): string;
60
+ /**
61
+ * @description Retrieves class decorator metadata for a model instance
62
+ * @summary Extracts UI-related class decorators from a model and returns them as an array
63
+ * This method collects metadata from various UI class decorators including @uimodel,
64
+ * @uilistmodel, @uihandlers, and @uilayout applied to the model class.
65
+ *
66
+ * @template M Type extending Model
67
+ * @param {M} model - The model instance to extract metadata from
68
+ * @returns {UIClassMetadata[]} Array of UI class metadata objects
69
+ *
70
+ * @private
71
+ */
72
+ private getClassDecoratorsMetadata;
73
+ private sortChildrenByOrder;
74
+ /**
75
+ * @description Checks if a validation key represents a custom validator (i.e., not a built-in validation or UI key).
76
+ * @summary Determines whether the provided key corresponds to a user-defined validator by excluding all built-in ValidationKeys and UIKeys.
77
+ *
78
+ * @param {string} key - The validation key to check.
79
+ * @returns {boolean} True if the key is a custom validator, false otherwise.
80
+ * @returns {boolean} True if the key is not a built-in validation key or UI key (i.e. is custom), false otherwise.
81
+ */
82
+ protected isCustomValidator(key: string): boolean;
83
+ /**
84
+ * @description Checks if a type is validatable by its nature.
85
+ * @summary Determines if a given UI key represents a type that is inherently validatable.
86
+ *
87
+ * @param {string} key - The UI key to check.
88
+ * @returns {boolean} True if the type is validatable, false otherwise.
89
+ */
90
+ protected isValidatableByType(key: string): boolean;
91
+ /**
92
+ * @description Checks if a type is validatable by attribute.
93
+ * @summary Determines if a given UI key represents a validation that can be applied as an attribute.
94
+ *
95
+ * @param {string} key - The UI key to check.
96
+ * @returns {boolean} True if the type is validatable by attribute, false otherwise.
97
+ */
98
+ protected isValidatableByAttribute(key: string): boolean;
99
+ /**
100
+ * @description Converts validation metadata to an attribute value.
101
+ * @summary Transforms validation metadata into a value suitable for use as an HTML attribute.
102
+ *
103
+ * @param {string} key - The validation key.
104
+ * @param {ValidationMetadata} value - The validation metadata.
105
+ * @returns {string | number | boolean} The converted attribute value.
106
+ * @throws {Error} If the given key is not validatable by attribute.
107
+ */
108
+ protected toAttributeValue(key: string, value: ValidationMetadata): string | number | boolean;
109
+ /**
110
+ * @description Converts a model to a field definition.
111
+ * @summary Processes a model instance, extracting UI-related metadata and validation rules to create a field definition.
112
+ *
113
+ * @template M Type extending Model
114
+ * @template T Type referencing the specific Rendering engine field properties/inputs
115
+ * @param {M} model - The model instance to convert.
116
+ * @param {Record<string, unknown>} [globalProps={}] - Global properties to apply to all child elements.
117
+ * @param {boolean} [generateId=true] - Flag indicating whether to populate the rendererId property.
118
+ * @returns {FieldDefinition<T>} A field definition object representing the UI structure of the model.
119
+ * @throws {RenderingError} If no UI definitions are set for the model or if there are invalid decorators.
120
+ *
121
+ * @mermaid
122
+ * sequenceDiagram
123
+ * participant C as Client
124
+ * participant RE as RenderingEngine
125
+ * participant R as Reflection
126
+ * participant M as Model
127
+ * C->>RE: toFieldDefinition(model, globalProps)
128
+ * RE->>R: getMetadata(UIKeys.UIMODEL, model.constructor)
129
+ * R-->>RE: UIModelMetadata
130
+ * RE->>R: getAllPropertyDecorators(model, UIKeys.REFLECT)
131
+ * R-->>RE: Record<string, DecoratorMetadata[]>
132
+ * RE->>R: getAllPropertyDecorators(model, ValidationKeys.REFLECT)
133
+ * R-->>RE: Record<string, DecoratorMetadata<ValidationMetadata>[]>
134
+ * loop For each property
135
+ * RE->>RE: Process UI decorators
136
+ * RE->>RE: Apply validation rules
137
+ * end
138
+ * RE-->>C: FieldDefinition<T>
139
+ */
140
+ protected toFieldDefinition<M extends Model>(model: M, globalProps?: Record<string, unknown>, generateId?: boolean): FieldDefinition<T>;
141
+ /**
142
+ * @description Renders a model with global properties and additional arguments.
143
+ * @summary Abstract method to be implemented by subclasses to define specific rendering behavior.
144
+ *
145
+ * @template M Type extending Model
146
+ * @template R Rendering engine implementation specific output type
147
+ * @param {M} model - The model to be rendered.
148
+ * @param {Record<string, unknown>} globalProps - Global properties to be applied to all elements during rendering.
149
+ * @param {...any[]} args - Additional arguments that may be required for specific rendering implementations.
150
+ * @returns {R} The rendered result, type depends on the specific implementation.
151
+ *
152
+ * @abstract
153
+ */
154
+ abstract render<M extends Model>(model: M, globalProps: Record<string, unknown>, ...args: any[]): R;
155
+ /**
156
+ * @description Registers a rendering engine instance.
157
+ * @summary Adds a rendering engine to the static cache and sets it as the current engine.
158
+ *
159
+ * @param {RenderingEngine<unknown, unknown>} engine - The rendering engine to register.
160
+ * @throws {InternalError} If an engine with the same flavor already exists.
161
+ *
162
+ * @static
163
+ */
164
+ static register(engine: RenderingEngine<unknown, unknown>): void;
165
+ /**
166
+ * @description Retrieves or initializes a rendering engine.
167
+ * @summary Gets an existing engine instance or creates and initializes a new one if given a constructor.
168
+ *
169
+ * @template O The type of the rendering engine output
170
+ * @param {Constructor<RenderingEngine<O>> | RenderingEngine<O>} obj - The engine instance or constructor.
171
+ * @returns {RenderingEngine<O>} The initialized rendering engine.
172
+ *
173
+ * @private
174
+ * @static
175
+ */
176
+ private static getOrBoot;
177
+ /**
178
+ * @description Retrieves a rendering engine by flavor.
179
+ * @summary Gets the current rendering engine or a specific one by flavor.
180
+ *
181
+ * @template O The type of the rendering engine output
182
+ * @param {string} [flavour] - The flavor of the rendering engine to retrieve.
183
+ * @returns {RenderingEngine<O>} The requested rendering engine.
184
+ * @throws {InternalError} If the requested flavor does not exist.
185
+ *
186
+ * @static
187
+ */
188
+ static get<O>(flavour?: string): RenderingEngine<O>;
189
+ /**
190
+ * @description Renders a model using the appropriate rendering engine.
191
+ * @summary Determines the correct rendering engine for a model and invokes its render method.
192
+ *
193
+ * @template M Type extending Model
194
+ * @param {M} model - The model to render.
195
+ * @param {...any[]} args - Additional arguments to pass to the render method.
196
+ * @returns {any} The result of the rendering process.
197
+ * @throws {InternalError} If no registered model is found.
198
+ *
199
+ * @static
200
+ */
201
+ static render<M extends Model>(model: M, ...args: any[]): any;
202
+ }
@@ -0,0 +1,202 @@
1
+ import { FieldDefinition } from "./types.js";
2
+ import { Model, ValidationMetadata } from "@decaf-ts/decorator-validation";
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
+ /**
17
+ * Represents the base abstraction for decaf rendering engines, handling engine registration,
18
+ * initialization, model-to-field translation, and runtime rendering orchestration.
19
+ * Implementations must provide initialization and rendering logic while leveraging the shared
20
+ * metadata-driven conversion utilities supplied here.
21
+ */
22
+ export declare abstract class RenderingEngine<T = void, R = FieldDefinition<T>> {
23
+ readonly flavour: string;
24
+ /**
25
+ * @description Cache for storing rendering engine instances or constructors.
26
+ * @private
27
+ * @static
28
+ */
29
+ private static cache;
30
+ /**
31
+ * @description The currently active rendering engine.
32
+ * @private
33
+ * @static
34
+ */
35
+ private static current;
36
+ /**
37
+ * Flag indicating whether the rendering engine has been initialized.
38
+ */
39
+ protected initialized: boolean;
40
+ protected constructor(flavour: string);
41
+ /**
42
+ * @description Initializes the rendering engine.
43
+ * @summary Abstract method to be implemented by subclasses for specific initialization logic.
44
+ *
45
+ * @param {...any[]} args - Any additional arguments needed for initialization.
46
+ * @returns {Promise<void>} A promise that resolves when initialization is complete.
47
+ *
48
+ * @abstract
49
+ */
50
+ abstract initialize(...args: any[]): Promise<void>;
51
+ /**
52
+ * @description Translates between model types and HTML input types.
53
+ * @summary Converts model data types to appropriate HTML input types and vice versa.
54
+ *
55
+ * @param {string} key - The key to translate.
56
+ * @param {boolean} [toView=true] - Direction of translation (true for model to view, false for view to model).
57
+ * @returns {string} The translated type.
58
+ */
59
+ translate(key: string, toView?: boolean): string;
60
+ /**
61
+ * @description Retrieves class decorator metadata for a model instance
62
+ * @summary Extracts UI-related class decorators from a model and returns them as an array
63
+ * This method collects metadata from various UI class decorators including @uimodel,
64
+ * @uilistmodel, @uihandlers, and @uilayout applied to the model class.
65
+ *
66
+ * @template M Type extending Model
67
+ * @param {M} model - The model instance to extract metadata from
68
+ * @returns {UIClassMetadata[]} Array of UI class metadata objects
69
+ *
70
+ * @private
71
+ */
72
+ private getClassDecoratorsMetadata;
73
+ private sortChildrenByOrder;
74
+ /**
75
+ * @description Checks if a validation key represents a custom validator (i.e., not a built-in validation or UI key).
76
+ * @summary Determines whether the provided key corresponds to a user-defined validator by excluding all built-in ValidationKeys and UIKeys.
77
+ *
78
+ * @param {string} key - The validation key to check.
79
+ * @returns {boolean} True if the key is a custom validator, false otherwise.
80
+ * @returns {boolean} True if the key is not a built-in validation key or UI key (i.e. is custom), false otherwise.
81
+ */
82
+ protected isCustomValidator(key: string): boolean;
83
+ /**
84
+ * @description Checks if a type is validatable by its nature.
85
+ * @summary Determines if a given UI key represents a type that is inherently validatable.
86
+ *
87
+ * @param {string} key - The UI key to check.
88
+ * @returns {boolean} True if the type is validatable, false otherwise.
89
+ */
90
+ protected isValidatableByType(key: string): boolean;
91
+ /**
92
+ * @description Checks if a type is validatable by attribute.
93
+ * @summary Determines if a given UI key represents a validation that can be applied as an attribute.
94
+ *
95
+ * @param {string} key - The UI key to check.
96
+ * @returns {boolean} True if the type is validatable by attribute, false otherwise.
97
+ */
98
+ protected isValidatableByAttribute(key: string): boolean;
99
+ /**
100
+ * @description Converts validation metadata to an attribute value.
101
+ * @summary Transforms validation metadata into a value suitable for use as an HTML attribute.
102
+ *
103
+ * @param {string} key - The validation key.
104
+ * @param {ValidationMetadata} value - The validation metadata.
105
+ * @returns {string | number | boolean} The converted attribute value.
106
+ * @throws {Error} If the given key is not validatable by attribute.
107
+ */
108
+ protected toAttributeValue(key: string, value: ValidationMetadata): string | number | boolean;
109
+ /**
110
+ * @description Converts a model to a field definition.
111
+ * @summary Processes a model instance, extracting UI-related metadata and validation rules to create a field definition.
112
+ *
113
+ * @template M Type extending Model
114
+ * @template T Type referencing the specific Rendering engine field properties/inputs
115
+ * @param {M} model - The model instance to convert.
116
+ * @param {Record<string, unknown>} [globalProps={}] - Global properties to apply to all child elements.
117
+ * @param {boolean} [generateId=true] - Flag indicating whether to populate the rendererId property.
118
+ * @returns {FieldDefinition<T>} A field definition object representing the UI structure of the model.
119
+ * @throws {RenderingError} If no UI definitions are set for the model or if there are invalid decorators.
120
+ *
121
+ * @mermaid
122
+ * sequenceDiagram
123
+ * participant C as Client
124
+ * participant RE as RenderingEngine
125
+ * participant R as Reflection
126
+ * participant M as Model
127
+ * C->>RE: toFieldDefinition(model, globalProps)
128
+ * RE->>R: getMetadata(UIKeys.UIMODEL, model.constructor)
129
+ * R-->>RE: UIModelMetadata
130
+ * RE->>R: getAllPropertyDecorators(model, UIKeys.REFLECT)
131
+ * R-->>RE: Record<string, DecoratorMetadata[]>
132
+ * RE->>R: getAllPropertyDecorators(model, ValidationKeys.REFLECT)
133
+ * R-->>RE: Record<string, DecoratorMetadata<ValidationMetadata>[]>
134
+ * loop For each property
135
+ * RE->>RE: Process UI decorators
136
+ * RE->>RE: Apply validation rules
137
+ * end
138
+ * RE-->>C: FieldDefinition<T>
139
+ */
140
+ protected toFieldDefinition<M extends Model>(model: M, globalProps?: Record<string, unknown>, generateId?: boolean): FieldDefinition<T>;
141
+ /**
142
+ * @description Renders a model with global properties and additional arguments.
143
+ * @summary Abstract method to be implemented by subclasses to define specific rendering behavior.
144
+ *
145
+ * @template M Type extending Model
146
+ * @template R Rendering engine implementation specific output type
147
+ * @param {M} model - The model to be rendered.
148
+ * @param {Record<string, unknown>} globalProps - Global properties to be applied to all elements during rendering.
149
+ * @param {...any[]} args - Additional arguments that may be required for specific rendering implementations.
150
+ * @returns {R} The rendered result, type depends on the specific implementation.
151
+ *
152
+ * @abstract
153
+ */
154
+ abstract render<M extends Model>(model: M, globalProps: Record<string, unknown>, ...args: any[]): R;
155
+ /**
156
+ * @description Registers a rendering engine instance.
157
+ * @summary Adds a rendering engine to the static cache and sets it as the current engine.
158
+ *
159
+ * @param {RenderingEngine<unknown, unknown>} engine - The rendering engine to register.
160
+ * @throws {InternalError} If an engine with the same flavor already exists.
161
+ *
162
+ * @static
163
+ */
164
+ static register(engine: RenderingEngine<unknown, unknown>): void;
165
+ /**
166
+ * @description Retrieves or initializes a rendering engine.
167
+ * @summary Gets an existing engine instance or creates and initializes a new one if given a constructor.
168
+ *
169
+ * @template O The type of the rendering engine output
170
+ * @param {Constructor<RenderingEngine<O>> | RenderingEngine<O>} obj - The engine instance or constructor.
171
+ * @returns {RenderingEngine<O>} The initialized rendering engine.
172
+ *
173
+ * @private
174
+ * @static
175
+ */
176
+ private static getOrBoot;
177
+ /**
178
+ * @description Retrieves a rendering engine by flavor.
179
+ * @summary Gets the current rendering engine or a specific one by flavor.
180
+ *
181
+ * @template O The type of the rendering engine output
182
+ * @param {string} [flavour] - The flavor of the rendering engine to retrieve.
183
+ * @returns {RenderingEngine<O>} The requested rendering engine.
184
+ * @throws {InternalError} If the requested flavor does not exist.
185
+ *
186
+ * @static
187
+ */
188
+ static get<O>(flavour?: string): RenderingEngine<O>;
189
+ /**
190
+ * @description Renders a model using the appropriate rendering engine.
191
+ * @summary Determines the correct rendering engine for a model and invokes its render method.
192
+ *
193
+ * @template M Type extending Model
194
+ * @param {M} model - The model to render.
195
+ * @param {...any[]} args - Additional arguments to pass to the render method.
196
+ * @returns {any} The result of the rendering process.
197
+ * @throws {InternalError} If no registered model is found.
198
+ *
199
+ * @static
200
+ */
201
+ static render<M extends Model>(model: M, ...args: any[]): any;
202
+ }
@@ -0,0 +1,6 @@
1
+ import { Validator } from "@decaf-ts/decorator-validation";
2
+ import { DecafTranslateService } from "./DecafTranslateService.cjs";
3
+ export declare abstract class UIValidator extends Validator {
4
+ static translateService: DecafTranslateService;
5
+ getMessage(message: string, ...args: any[]): string;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { Validator } from "@decaf-ts/decorator-validation";
2
+ import { DecafTranslateService } from "./DecafTranslateService.js";
3
+ export declare abstract class UIValidator extends Validator {
4
+ static translateService: DecafTranslateService;
5
+ getMessage(message: string, ...args: any[]): string;
6
+ }