@siliconst/metaui 1.0.0 → 1.2.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.
- package/README.md +134 -123
- package/package.json +22 -34
- package/src/nz/co/siliconst/ui5/metaui/.library +7 -7
- package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost-dbg.js +300 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.d.ts +130 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.ts +292 -162
- package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine-dbg.js +52 -0
- package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.d.ts +29 -0
- package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.ts +49 -40
- package/src/nz/co/siliconst/ui5/metaui/core/Engine-dbg.js +82 -0
- package/src/nz/co/siliconst/ui5/metaui/core/Engine-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/Engine.d.ts +17 -0
- package/src/nz/co/siliconst/ui5/metaui/core/Engine.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/Engine.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/core/Engine.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/Engine.ts +82 -56
- package/src/nz/co/siliconst/ui5/metaui/core/EventBus-dbg.js +66 -0
- package/src/nz/co/siliconst/ui5/metaui/core/EventBus-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/EventBus.d.ts +40 -0
- package/src/nz/co/siliconst/ui5/metaui/core/EventBus.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/EventBus.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/core/EventBus.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/EventBus.ts +60 -45
- package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry-dbg.js +73 -0
- package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.d.ts +39 -0
- package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.ts +71 -56
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer-dbg.js +146 -0
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.d.ts +25 -0
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.ts +157 -31
- package/src/nz/co/siliconst/ui5/metaui/core/StateManager-dbg.js +56 -0
- package/src/nz/co/siliconst/ui5/metaui/core/StateManager-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/StateManager.d.ts +37 -0
- package/src/nz/co/siliconst/ui5/metaui/core/StateManager.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/StateManager.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/core/StateManager.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/StateManager.ts +56 -56
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus-dbg.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus.d.ts +29 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus.ts +29 -29
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager-dbg.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager.d.ts +20 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager.ts +21 -26
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin-dbg.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin.d.ts +15 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin.ts +14 -33
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema-dbg.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.d.ts +58 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.ts +70 -70
- package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout-dbg.js +24 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.d.ts +15 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.ts +22 -34
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout-dbg.js +99 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.d.ts +20 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.ts +97 -60
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout-dbg.js +103 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.d.ts +16 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.ts +119 -102
- package/src/nz/co/siliconst/ui5/metaui/library-dbg.js +44 -0
- package/src/nz/co/siliconst/ui5/metaui/library-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/library-preload.js +39 -0
- package/src/nz/co/siliconst/ui5/metaui/library-preload.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/library.d.ts +10 -0
- package/src/nz/co/siliconst/ui5/metaui/library.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/library.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/library.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/library.ts +55 -43
- package/src/nz/co/siliconst/ui5/metaui/manifest.json +35 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin-dbg.js +68 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.d.ts +15 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.ts +71 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin-dbg.js +55 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.d.ts +24 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.ts +56 -58
- package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin-dbg.js +42 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.d.ts +18 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.ts +41 -42
- package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin-dbg.js +69 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.d.ts +18 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.ts +69 -63
- package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin-dbg.js +68 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.d.ts +18 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.ts +68 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin-dbg.js +67 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.d.ts +18 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.ts +65 -65
- package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin-dbg.js +56 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.d.ts +18 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.ts +56 -55
- package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin-dbg.js +57 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.d.ts +18 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.ts +58 -55
- package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin-dbg.js +43 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.d.ts +18 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.ts +42 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin-dbg.js +58 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.d.ts +18 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.ts +58 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin-dbg.js +74 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.d.ts +18 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.ts +71 -0
- package/ui5.yaml +4 -12
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
sap.ui.define([], function () {
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file PluginRegistry.ts
|
|
6
|
+
* @description Centralized hub for mapping UI5 controls to SAP schema data types.
|
|
7
|
+
* Enforces the Registry Pattern to decouple the core engine from specific UI5 control implementations.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Singleton registry that manages the lifecycle and lookup of UI5 plugin constructors.
|
|
12
|
+
*/
|
|
13
|
+
class PluginRegistry {
|
|
14
|
+
/** Internal map linking string types to their respective constructor functions. */
|
|
15
|
+
plugins = new Map();
|
|
16
|
+
constructor() {
|
|
17
|
+
// Enforce singleton
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the singular instance of the PluginRegistry.
|
|
22
|
+
* @returns The PluginRegistry singleton.
|
|
23
|
+
*/
|
|
24
|
+
static getInstance() {
|
|
25
|
+
if (!PluginRegistry.instance) {
|
|
26
|
+
PluginRegistry.instance = new PluginRegistry();
|
|
27
|
+
}
|
|
28
|
+
return PluginRegistry.instance;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Registers a new UI control plugin against a specific schema primitive type (and optional widget).
|
|
33
|
+
* @param type The primitive FieldType (e.g., 'string', 'date').
|
|
34
|
+
* @param pluginConstructor The class constructor for the plugin.
|
|
35
|
+
* @param widgetName Optional widget specific override (e.g., 'textArea').
|
|
36
|
+
*/
|
|
37
|
+
register(type, pluginConstructor, widgetName) {
|
|
38
|
+
const key = widgetName ? `${type}:${widgetName}` : type;
|
|
39
|
+
this.plugins.set(key, pluginConstructor);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Instantiates and returns a new plugin based on the requested primitive type and widget.
|
|
44
|
+
* @param type The primitive FieldType to look up.
|
|
45
|
+
* @param widgetName Optional widget specific override.
|
|
46
|
+
* @throws Error if no plugin has been registered for the provided type.
|
|
47
|
+
* @returns A newly instantiated plugin ready for rendering.
|
|
48
|
+
*/
|
|
49
|
+
getPlugin(type, widgetName) {
|
|
50
|
+
let PluginClass;
|
|
51
|
+
|
|
52
|
+
// 1. Attempt specific widget lookup
|
|
53
|
+
if (widgetName) {
|
|
54
|
+
PluginClass = this.plugins.get(`${type}:${widgetName}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 2. Fallback to primitive type
|
|
58
|
+
if (!PluginClass) {
|
|
59
|
+
PluginClass = this.plugins.get(type);
|
|
60
|
+
}
|
|
61
|
+
if (!PluginClass) {
|
|
62
|
+
throw new Error(`[MetaUI] No plugin registered for FieldType: ${type}`);
|
|
63
|
+
}
|
|
64
|
+
return new PluginClass();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
var __exports = {
|
|
68
|
+
__esModule: true
|
|
69
|
+
};
|
|
70
|
+
__exports.PluginRegistry = PluginRegistry;
|
|
71
|
+
return __exports;
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=PluginRegistry-dbg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginRegistry-dbg.js","names":["PluginRegistry","plugins","Map","constructor","getInstance","instance","register","type","pluginConstructor","widgetName","key","set","getPlugin","PluginClass","get","Error","__exports","__esModule"],"sources":["PluginRegistry.ts"],"sourcesContent":["/**\n * @file PluginRegistry.ts\n * @description Centralized hub for mapping UI5 controls to SAP schema data types.\n * Enforces the Registry Pattern to decouple the core engine from specific UI5 control implementations.\n */\n\nimport { IPlugin } from \"../interfaces/IPlugin\";\nimport { FieldType } from \"../interfaces/ISchema\";\n\n/**\n * Singleton registry that manages the lifecycle and lookup of UI5 plugin constructors.\n */\nexport class PluginRegistry {\n private static instance: PluginRegistry;\n \n /** Internal map linking string types to their respective constructor functions. */\n private plugins: Map<string, new () => IPlugin> = new Map();\n\n private constructor() {\n // Enforce singleton\n }\n\n /**\n * Retrieves the singular instance of the PluginRegistry.\n * @returns The PluginRegistry singleton.\n */\n public static getInstance(): PluginRegistry {\n if (!PluginRegistry.instance) {\n PluginRegistry.instance = new PluginRegistry();\n }\n return PluginRegistry.instance;\n }\n\n /**\n * Registers a new UI control plugin against a specific schema primitive type (and optional widget).\n * @param type The primitive FieldType (e.g., 'string', 'date').\n * @param pluginConstructor The class constructor for the plugin.\n * @param widgetName Optional widget specific override (e.g., 'textArea').\n */\n public register(type: FieldType, pluginConstructor: new () => IPlugin, widgetName?: string): void {\n const key = widgetName ? `${type}:${widgetName}` : type;\n this.plugins.set(key, pluginConstructor);\n }\n\n /**\n * Instantiates and returns a new plugin based on the requested primitive type and widget.\n * @param type The primitive FieldType to look up.\n * @param widgetName Optional widget specific override.\n * @throws Error if no plugin has been registered for the provided type.\n * @returns A newly instantiated plugin ready for rendering.\n */\n public getPlugin(type: FieldType, widgetName?: string): IPlugin {\n let PluginClass;\n \n // 1. Attempt specific widget lookup\n if (widgetName) {\n PluginClass = this.plugins.get(`${type}:${widgetName}`);\n }\n \n // 2. Fallback to primitive type\n if (!PluginClass) {\n PluginClass = this.plugins.get(type);\n }\n\n if (!PluginClass) {\n throw new Error(`[MetaUI] No plugin registered for FieldType: ${type}`);\n }\n \n return new PluginClass();\n }\n}\n"],"mappings":";;;EAAA;AACA;AACA;AACA;AACA;;EAKA;AACA;AACA;EACO,MAAMA,cAAc,CAAC;IAGxB;IACQC,OAAO,GAAmC,IAAIC,GAAG,CAAC,CAAC;IAEnDC,WAAWA,CAAA,EAAG;MAClB;IAAA;;IAGJ;AACJ;AACA;AACA;IACI,OAAcC,WAAWA,CAAA,EAAmB;MACxC,IAAI,CAACJ,cAAc,CAACK,QAAQ,EAAE;QAC1BL,cAAc,CAACK,QAAQ,GAAG,IAAIL,cAAc,CAAC,CAAC;MAClD;MACA,OAAOA,cAAc,CAACK,QAAQ;IAClC;;IAEA;AACJ;AACA;AACA;AACA;AACA;IACWC,QAAQA,CAACC,IAAe,EAAEC,iBAAoC,EAAEC,UAAmB,EAAQ;MAC9F,MAAMC,GAAG,GAAGD,UAAU,GAAG,GAAGF,IAAI,IAAIE,UAAU,EAAE,GAAGF,IAAI;MACvD,IAAI,CAACN,OAAO,CAACU,GAAG,CAACD,GAAG,EAAEF,iBAAiB,CAAC;IAC5C;;IAEA;AACJ;AACA;AACA;AACA;AACA;AACA;IACWI,SAASA,CAACL,IAAe,EAAEE,UAAmB,EAAW;MAC5D,IAAII,WAAW;;MAEf;MACA,IAAIJ,UAAU,EAAE;QACZI,WAAW,GAAG,IAAI,CAACZ,OAAO,CAACa,GAAG,CAAC,GAAGP,IAAI,IAAIE,UAAU,EAAE,CAAC;MAC3D;;MAEA;MACA,IAAI,CAACI,WAAW,EAAE;QACdA,WAAW,GAAG,IAAI,CAACZ,OAAO,CAACa,GAAG,CAACP,IAAI,CAAC;MACxC;MAEA,IAAI,CAACM,WAAW,EAAE;QACd,MAAM,IAAIE,KAAK,CAAC,gDAAgDR,IAAI,EAAE,CAAC;MAC3E;MAEA,OAAO,IAAIM,WAAW,CAAC,CAAC;IAC5B;EACJ;EAAC,IAAAG,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAAhB,cAAA,GAAAA,cAAA;EAAA,OAAAgB,SAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
declare module "nz/co/siliconst/ui5/metaui/core/PluginRegistry" {
|
|
2
|
+
/**
|
|
3
|
+
* @file PluginRegistry.ts
|
|
4
|
+
* @description Centralized hub for mapping UI5 controls to SAP schema data types.
|
|
5
|
+
* Enforces the Registry Pattern to decouple the core engine from specific UI5 control implementations.
|
|
6
|
+
*/
|
|
7
|
+
import { IPlugin } from "nz/co/siliconst/ui5/metaui/interfaces/IPlugin";
|
|
8
|
+
import { FieldType } from "nz/co/siliconst/ui5/metaui/interfaces/ISchema";
|
|
9
|
+
/**
|
|
10
|
+
* Singleton registry that manages the lifecycle and lookup of UI5 plugin constructors.
|
|
11
|
+
*/
|
|
12
|
+
export class PluginRegistry {
|
|
13
|
+
private static instance;
|
|
14
|
+
/** Internal map linking string types to their respective constructor functions. */
|
|
15
|
+
private plugins;
|
|
16
|
+
private constructor();
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves the singular instance of the PluginRegistry.
|
|
19
|
+
* @returns The PluginRegistry singleton.
|
|
20
|
+
*/
|
|
21
|
+
static getInstance(): PluginRegistry;
|
|
22
|
+
/**
|
|
23
|
+
* Registers a new UI control plugin against a specific schema primitive type (and optional widget).
|
|
24
|
+
* @param type The primitive FieldType (e.g., 'string', 'date').
|
|
25
|
+
* @param pluginConstructor The class constructor for the plugin.
|
|
26
|
+
* @param widgetName Optional widget specific override (e.g., 'textArea').
|
|
27
|
+
*/
|
|
28
|
+
register(type: FieldType, pluginConstructor: new () => IPlugin, widgetName?: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Instantiates and returns a new plugin based on the requested primitive type and widget.
|
|
31
|
+
* @param type The primitive FieldType to look up.
|
|
32
|
+
* @param widgetName Optional widget specific override.
|
|
33
|
+
* @throws Error if no plugin has been registered for the provided type.
|
|
34
|
+
* @returns A newly instantiated plugin ready for rendering.
|
|
35
|
+
*/
|
|
36
|
+
getPlugin(type: FieldType, widgetName?: string): IPlugin;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=PluginRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginRegistry.d.ts","sourceRoot":"../../../../../../../..","sources":["src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,gDAAgD,CAAC;IAChE;;;;OAIG;IAEH,OAAO,EAAE,OAAO,EAAE,MAAM,+CAA+C,CAAC;IACxE,OAAO,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;IAE1E;;OAEG;IACH,MAAa,cAAc;QACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiB;QAExC,mFAAmF;QACnF,OAAO,CAAC,OAAO,CAA6C;QAE5D,OAAO;QAIP;;;WAGG;eACW,WAAW,IAAI,cAAc;QAO3C;;;;;WAKG;QACI,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;QAKjG;;;;;;WAMG;QACI,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO;KAmBlE;CAEA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
sap.ui.define([],function(){"use strict";class e{plugins=new Map;constructor(){}static getInstance(){if(!e.instance){e.instance=new e}return e.instance}register(e,t,n){const i=n?`${e}:${n}`:e;this.plugins.set(i,t)}getPlugin(e,t){let n;if(t){n=this.plugins.get(`${e}:${t}`)}if(!n){n=this.plugins.get(e)}if(!n){throw new Error(`[MetaUI] No plugin registered for FieldType: ${e}`)}return new n}}var t={__esModule:true};t.PluginRegistry=e;return t});
|
|
2
|
+
//# sourceMappingURL=PluginRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginRegistry.js","names":["PluginRegistry","plugins","Map","constructor","getInstance","instance","register","type","pluginConstructor","widgetName","key","this","set","getPlugin","PluginClass","get","Error","__exports","__esModule"],"sources":["PluginRegistry.ts"],"sourcesContent":["/**\n * @file PluginRegistry.ts\n * @description Centralized hub for mapping UI5 controls to SAP schema data types.\n * Enforces the Registry Pattern to decouple the core engine from specific UI5 control implementations.\n */\n\nimport { IPlugin } from \"../interfaces/IPlugin\";\nimport { FieldType } from \"../interfaces/ISchema\";\n\n/**\n * Singleton registry that manages the lifecycle and lookup of UI5 plugin constructors.\n */\nexport class PluginRegistry {\n private static instance: PluginRegistry;\n \n /** Internal map linking string types to their respective constructor functions. */\n private plugins: Map<string, new () => IPlugin> = new Map();\n\n private constructor() {\n // Enforce singleton\n }\n\n /**\n * Retrieves the singular instance of the PluginRegistry.\n * @returns The PluginRegistry singleton.\n */\n public static getInstance(): PluginRegistry {\n if (!PluginRegistry.instance) {\n PluginRegistry.instance = new PluginRegistry();\n }\n return PluginRegistry.instance;\n }\n\n /**\n * Registers a new UI control plugin against a specific schema primitive type (and optional widget).\n * @param type The primitive FieldType (e.g., 'string', 'date').\n * @param pluginConstructor The class constructor for the plugin.\n * @param widgetName Optional widget specific override (e.g., 'textArea').\n */\n public register(type: FieldType, pluginConstructor: new () => IPlugin, widgetName?: string): void {\n const key = widgetName ? `${type}:${widgetName}` : type;\n this.plugins.set(key, pluginConstructor);\n }\n\n /**\n * Instantiates and returns a new plugin based on the requested primitive type and widget.\n * @param type The primitive FieldType to look up.\n * @param widgetName Optional widget specific override.\n * @throws Error if no plugin has been registered for the provided type.\n * @returns A newly instantiated plugin ready for rendering.\n */\n public getPlugin(type: FieldType, widgetName?: string): IPlugin {\n let PluginClass;\n \n // 1. Attempt specific widget lookup\n if (widgetName) {\n PluginClass = this.plugins.get(`${type}:${widgetName}`);\n }\n \n // 2. Fallback to primitive type\n if (!PluginClass) {\n PluginClass = this.plugins.get(type);\n }\n\n if (!PluginClass) {\n throw new Error(`[MetaUI] No plugin registered for FieldType: ${type}`);\n }\n \n return new PluginClass();\n }\n}\n"],"mappings":"yCAYO,MAAMA,EAIDC,QAA0C,IAAIC,IAE9CC,cACJ,CAOJ,kBAAcC,GACV,IAAKJ,EAAeK,SAAU,CAC1BL,EAAeK,SAAW,IAAIL,CAClC,CACA,OAAOA,EAAeK,QAC1B,CAQOC,SAASC,EAAiBC,EAAsCC,GACnE,MAAMC,EAAMD,EAAa,GAAGF,KAAQE,IAAeF,EACnDI,KAAKV,QAAQW,IAAIF,EAAKF,EAC1B,CASOK,UAAUN,EAAiBE,GAC9B,IAAIK,EAGJ,GAAIL,EAAY,CACZK,EAAcH,KAAKV,QAAQc,IAAI,GAAGR,KAAQE,IAC9C,CAGA,IAAKK,EAAa,CACdA,EAAcH,KAAKV,QAAQc,IAAIR,EACnC,CAEA,IAAKO,EAAa,CACd,MAAM,IAAIE,MAAM,gDAAgDT,IACpE,CAEA,OAAO,IAAIO,CACf,EACH,IAAAG,EAAA,CAAAC,WAAA,MAAAD,EAAAjB,iBAAA,OAAAiB,CAAA","ignoreList":[]}
|
|
@@ -1,56 +1,71 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file PluginRegistry.ts
|
|
3
|
-
* @description Centralized hub for mapping UI5 controls to SAP schema data types.
|
|
4
|
-
* Enforces the Registry Pattern to decouple the core engine from specific UI5 control implementations.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { IPlugin } from "../interfaces/IPlugin";
|
|
8
|
-
import { FieldType } from "../interfaces/ISchema";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Singleton registry that manages the lifecycle and lookup of UI5 plugin constructors.
|
|
12
|
-
*/
|
|
13
|
-
export class PluginRegistry {
|
|
14
|
-
private static instance: PluginRegistry;
|
|
15
|
-
|
|
16
|
-
/** Internal map linking string types to their respective constructor functions. */
|
|
17
|
-
private plugins: Map<
|
|
18
|
-
|
|
19
|
-
private constructor() {
|
|
20
|
-
// Enforce singleton
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Retrieves the singular instance of the PluginRegistry.
|
|
25
|
-
* @returns The PluginRegistry singleton.
|
|
26
|
-
*/
|
|
27
|
-
public static getInstance(): PluginRegistry {
|
|
28
|
-
if (!PluginRegistry.instance) {
|
|
29
|
-
PluginRegistry.instance = new PluginRegistry();
|
|
30
|
-
}
|
|
31
|
-
return PluginRegistry.instance;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Registers a new UI control plugin against a specific schema primitive type.
|
|
36
|
-
* @param type The primitive FieldType (e.g., 'string', 'date').
|
|
37
|
-
* @param pluginConstructor The class constructor for the plugin.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*
|
|
47
|
-
* @
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file PluginRegistry.ts
|
|
3
|
+
* @description Centralized hub for mapping UI5 controls to SAP schema data types.
|
|
4
|
+
* Enforces the Registry Pattern to decouple the core engine from specific UI5 control implementations.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { IPlugin } from "../interfaces/IPlugin";
|
|
8
|
+
import { FieldType } from "../interfaces/ISchema";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Singleton registry that manages the lifecycle and lookup of UI5 plugin constructors.
|
|
12
|
+
*/
|
|
13
|
+
export class PluginRegistry {
|
|
14
|
+
private static instance: PluginRegistry;
|
|
15
|
+
|
|
16
|
+
/** Internal map linking string types to their respective constructor functions. */
|
|
17
|
+
private plugins: Map<string, new () => IPlugin> = new Map();
|
|
18
|
+
|
|
19
|
+
private constructor() {
|
|
20
|
+
// Enforce singleton
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves the singular instance of the PluginRegistry.
|
|
25
|
+
* @returns The PluginRegistry singleton.
|
|
26
|
+
*/
|
|
27
|
+
public static getInstance(): PluginRegistry {
|
|
28
|
+
if (!PluginRegistry.instance) {
|
|
29
|
+
PluginRegistry.instance = new PluginRegistry();
|
|
30
|
+
}
|
|
31
|
+
return PluginRegistry.instance;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Registers a new UI control plugin against a specific schema primitive type (and optional widget).
|
|
36
|
+
* @param type The primitive FieldType (e.g., 'string', 'date').
|
|
37
|
+
* @param pluginConstructor The class constructor for the plugin.
|
|
38
|
+
* @param widgetName Optional widget specific override (e.g., 'textArea').
|
|
39
|
+
*/
|
|
40
|
+
public register(type: FieldType, pluginConstructor: new () => IPlugin, widgetName?: string): void {
|
|
41
|
+
const key = widgetName ? `${type}:${widgetName}` : type;
|
|
42
|
+
this.plugins.set(key, pluginConstructor);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Instantiates and returns a new plugin based on the requested primitive type and widget.
|
|
47
|
+
* @param type The primitive FieldType to look up.
|
|
48
|
+
* @param widgetName Optional widget specific override.
|
|
49
|
+
* @throws Error if no plugin has been registered for the provided type.
|
|
50
|
+
* @returns A newly instantiated plugin ready for rendering.
|
|
51
|
+
*/
|
|
52
|
+
public getPlugin(type: FieldType, widgetName?: string): IPlugin {
|
|
53
|
+
let PluginClass;
|
|
54
|
+
|
|
55
|
+
// 1. Attempt specific widget lookup
|
|
56
|
+
if (widgetName) {
|
|
57
|
+
PluginClass = this.plugins.get(`${type}:${widgetName}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 2. Fallback to primitive type
|
|
61
|
+
if (!PluginClass) {
|
|
62
|
+
PluginClass = this.plugins.get(type);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!PluginClass) {
|
|
66
|
+
throw new Error(`[MetaUI] No plugin registered for FieldType: ${type}`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return new PluginClass();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
sap.ui.define([], function () {
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file SchemaNormalizer.ts
|
|
6
|
+
* @description Transforms and validates incoming JSON payloads into the strict v2 ISchema dictionary matrix.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
class SchemaNormalizer {
|
|
10
|
+
/**
|
|
11
|
+
* Validates that the provided raw payload conforms to the required ISchema structures.
|
|
12
|
+
*/
|
|
13
|
+
static normalize(rawSchema, data) {
|
|
14
|
+
let schemaObj = rawSchema;
|
|
15
|
+
if (typeof schemaObj === "string") {
|
|
16
|
+
try {
|
|
17
|
+
schemaObj = JSON.parse(schemaObj);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.warn("[MetaUI] Failed to parse schema string, falling back to inference.", e);
|
|
20
|
+
schemaObj = null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (!schemaObj || typeof schemaObj !== 'object' || Array.isArray(schemaObj)) {
|
|
24
|
+
return this.inferSchemaFromData(data);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// It is an object. Ensure it conforms to v2 structure.
|
|
28
|
+
const normalized = {
|
|
29
|
+
title: schemaObj.title || "MetaUI Generated Form",
|
|
30
|
+
type: schemaObj.type || (schemaObj.items ? "array" : "object")
|
|
31
|
+
};
|
|
32
|
+
if (normalized.type === "object") {
|
|
33
|
+
normalized.properties = this.normalizeProperties(schemaObj.properties || {});
|
|
34
|
+
} else if (normalized.type === "array") {
|
|
35
|
+
normalized.items = this.normalizePropertyMetadata(schemaObj.items || {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {}
|
|
38
|
+
}, "items");
|
|
39
|
+
}
|
|
40
|
+
return normalized;
|
|
41
|
+
}
|
|
42
|
+
static normalizeProperties(properties) {
|
|
43
|
+
const normalizedProps = {};
|
|
44
|
+
for (const key of Object.keys(properties)) {
|
|
45
|
+
normalizedProps[key] = this.normalizePropertyMetadata(properties[key], key);
|
|
46
|
+
}
|
|
47
|
+
return normalizedProps;
|
|
48
|
+
}
|
|
49
|
+
static normalizePropertyMetadata(prop, keyName) {
|
|
50
|
+
const normalized = {
|
|
51
|
+
type: prop.type || "string",
|
|
52
|
+
ui: {
|
|
53
|
+
label: prop.ui?.label || this.generateLabel(keyName),
|
|
54
|
+
isKey: !!prop.ui?.isKey,
|
|
55
|
+
readOnly: !!prop.ui?.readOnly,
|
|
56
|
+
widget: prop.ui?.widget,
|
|
57
|
+
group: prop.ui?.group,
|
|
58
|
+
visibleOn: prop.ui?.visibleOn,
|
|
59
|
+
enabledOn: prop.ui?.enabledOn,
|
|
60
|
+
format: prop.ui?.format
|
|
61
|
+
},
|
|
62
|
+
required: !!prop.required,
|
|
63
|
+
maxLength: prop.maxLength,
|
|
64
|
+
minimum: prop.minimum,
|
|
65
|
+
maximum: prop.maximum,
|
|
66
|
+
pattern: prop.pattern,
|
|
67
|
+
precision: prop.precision,
|
|
68
|
+
scale: prop.scale,
|
|
69
|
+
valueHelp: prop.valueHelp
|
|
70
|
+
};
|
|
71
|
+
if (normalized.type === "object" && prop.properties) {
|
|
72
|
+
normalized.properties = this.normalizeProperties(prop.properties);
|
|
73
|
+
} else if (normalized.type === "array" && prop.items) {
|
|
74
|
+
normalized.items = this.normalizePropertyMetadata(prop.items, "items");
|
|
75
|
+
}
|
|
76
|
+
return normalized;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Generates a Title Case label from camelCase or snake_case technical names.
|
|
81
|
+
*/
|
|
82
|
+
static generateLabel(name) {
|
|
83
|
+
if (!name) return "";
|
|
84
|
+
let spaced = name.replace(/([A-Z])/g, " $1").replace(/_/g, " ");
|
|
85
|
+
return spaced.split(' ').filter(w => w.length > 0).map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(' ').trim();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Infers a v2 ISchema structure dynamically from a plain data payload.
|
|
90
|
+
*/
|
|
91
|
+
static inferSchemaFromData(data) {
|
|
92
|
+
const schema = {
|
|
93
|
+
type: "object",
|
|
94
|
+
properties: {}
|
|
95
|
+
};
|
|
96
|
+
if (!data || typeof data !== "object") {
|
|
97
|
+
return schema;
|
|
98
|
+
}
|
|
99
|
+
if (Array.isArray(data)) {
|
|
100
|
+
schema.type = "array";
|
|
101
|
+
schema.items = {
|
|
102
|
+
type: "object",
|
|
103
|
+
properties: data.length > 0 ? this.inferPropertiesFromObject(data[0]) : {}
|
|
104
|
+
};
|
|
105
|
+
} else {
|
|
106
|
+
schema.type = "object";
|
|
107
|
+
schema.properties = this.inferPropertiesFromObject(data);
|
|
108
|
+
}
|
|
109
|
+
return schema;
|
|
110
|
+
}
|
|
111
|
+
static inferPropertiesFromObject(obj) {
|
|
112
|
+
const properties = {};
|
|
113
|
+
if (!obj || typeof obj !== "object") return properties;
|
|
114
|
+
for (const key of Object.keys(obj)) {
|
|
115
|
+
const val = obj[key];
|
|
116
|
+
if (val === null || val === undefined) continue;
|
|
117
|
+
if (typeof val === "object" && !Array.isArray(val)) continue;
|
|
118
|
+
let type = "string";
|
|
119
|
+
let items;
|
|
120
|
+
if (typeof val === "number") type = "number";else if (typeof val === "boolean") type = "boolean";else if (Array.isArray(val)) {
|
|
121
|
+
type = "array";
|
|
122
|
+
items = {
|
|
123
|
+
type: "object",
|
|
124
|
+
properties: val.length > 0 ? this.inferPropertiesFromObject(val[0]) : {}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
properties[key] = {
|
|
128
|
+
type,
|
|
129
|
+
items,
|
|
130
|
+
ui: {
|
|
131
|
+
label: this.generateLabel(key),
|
|
132
|
+
isKey: false,
|
|
133
|
+
readOnly: false
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return properties;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
var __exports = {
|
|
141
|
+
__esModule: true
|
|
142
|
+
};
|
|
143
|
+
__exports.SchemaNormalizer = SchemaNormalizer;
|
|
144
|
+
return __exports;
|
|
145
|
+
});
|
|
146
|
+
//# sourceMappingURL=SchemaNormalizer-dbg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaNormalizer-dbg.js","names":["SchemaNormalizer","normalize","rawSchema","data","schemaObj","JSON","parse","e","console","warn","Array","isArray","inferSchemaFromData","normalized","title","type","items","properties","normalizeProperties","normalizePropertyMetadata","normalizedProps","key","Object","keys","prop","keyName","ui","label","generateLabel","isKey","readOnly","widget","group","visibleOn","enabledOn","format","required","maxLength","minimum","maximum","pattern","precision","scale","valueHelp","name","spaced","replace","split","filter","w","length","map","word","charAt","toUpperCase","slice","toLowerCase","join","trim","schema","inferPropertiesFromObject","obj","val","undefined","__exports","__esModule"],"sources":["SchemaNormalizer.ts"],"sourcesContent":["/**\n * @file SchemaNormalizer.ts\n * @description Transforms and validates incoming JSON payloads into the strict v2 ISchema dictionary matrix.\n */\n\nimport { ISchema, IPropertyMetadata, FieldType } from \"../interfaces/ISchema\";\n\nexport class SchemaNormalizer {\n \n /**\n * Validates that the provided raw payload conforms to the required ISchema structures.\n */\n public static normalize(rawSchema?: any, data?: any): ISchema {\n let schemaObj = rawSchema;\n\n if (typeof schemaObj === \"string\") {\n try {\n schemaObj = JSON.parse(schemaObj);\n } catch (e) {\n console.warn(\"[MetaUI] Failed to parse schema string, falling back to inference.\", e);\n schemaObj = null;\n }\n }\n\n if (!schemaObj || typeof schemaObj !== 'object' || Array.isArray(schemaObj)) {\n return this.inferSchemaFromData(data);\n }\n\n // It is an object. Ensure it conforms to v2 structure.\n const normalized: ISchema = {\n title: schemaObj.title || \"MetaUI Generated Form\",\n type: schemaObj.type || (schemaObj.items ? \"array\" : \"object\"),\n };\n\n if (normalized.type === \"object\") {\n normalized.properties = this.normalizeProperties(schemaObj.properties || {});\n } else if (normalized.type === \"array\") {\n normalized.items = this.normalizePropertyMetadata(schemaObj.items || { type: \"object\", properties: {} }, \"items\");\n }\n\n return normalized;\n }\n\n private static normalizeProperties(properties: any): Record<string, IPropertyMetadata> {\n const normalizedProps: Record<string, IPropertyMetadata> = {};\n for (const key of Object.keys(properties)) {\n normalizedProps[key] = this.normalizePropertyMetadata(properties[key], key);\n }\n return normalizedProps;\n }\n\n private static normalizePropertyMetadata(prop: any, keyName: string): IPropertyMetadata {\n const normalized: IPropertyMetadata = {\n type: prop.type || \"string\",\n ui: {\n label: prop.ui?.label || this.generateLabel(keyName),\n isKey: !!prop.ui?.isKey,\n readOnly: !!prop.ui?.readOnly,\n widget: prop.ui?.widget,\n group: prop.ui?.group,\n visibleOn: prop.ui?.visibleOn,\n enabledOn: prop.ui?.enabledOn,\n format: prop.ui?.format\n },\n required: !!prop.required,\n maxLength: prop.maxLength,\n minimum: prop.minimum,\n maximum: prop.maximum,\n pattern: prop.pattern,\n precision: prop.precision,\n scale: prop.scale,\n valueHelp: prop.valueHelp\n };\n\n if (normalized.type === \"object\" && prop.properties) {\n normalized.properties = this.normalizeProperties(prop.properties);\n } else if (normalized.type === \"array\" && prop.items) {\n normalized.items = this.normalizePropertyMetadata(prop.items, \"items\");\n }\n\n return normalized;\n }\n\n /**\n * Generates a Title Case label from camelCase or snake_case technical names.\n */\n private static generateLabel(name: string): string {\n if (!name) return \"\";\n let spaced = name.replace(/([A-Z])/g, \" $1\").replace(/_/g, \" \");\n return spaced.split(' ')\n .filter(w => w.length > 0)\n .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(' ')\n .trim();\n }\n\n /**\n * Infers a v2 ISchema structure dynamically from a plain data payload.\n */\n private static inferSchemaFromData(data: any): ISchema {\n const schema: ISchema = { type: \"object\", properties: {} };\n \n if (!data || typeof data !== \"object\") {\n return schema;\n }\n\n if (Array.isArray(data)) {\n schema.type = \"array\";\n schema.items = {\n type: \"object\",\n properties: data.length > 0 ? this.inferPropertiesFromObject(data[0]) : {}\n };\n } else {\n schema.type = \"object\";\n schema.properties = this.inferPropertiesFromObject(data);\n }\n\n return schema;\n }\n\n private static inferPropertiesFromObject(obj: any): Record<string, IPropertyMetadata> {\n const properties: Record<string, IPropertyMetadata> = {};\n if (!obj || typeof obj !== \"object\") return properties;\n\n for (const key of Object.keys(obj)) {\n const val = obj[key];\n if (val === null || val === undefined) continue;\n \n if (typeof val === \"object\" && !Array.isArray(val)) continue;\n\n let type: FieldType = \"string\";\n let items: IPropertyMetadata | undefined;\n\n if (typeof val === \"number\") type = \"number\";\n else if (typeof val === \"boolean\") type = \"boolean\";\n else if (Array.isArray(val)) {\n type = \"array\";\n items = {\n type: \"object\",\n properties: val.length > 0 ? this.inferPropertiesFromObject(val[0]) : {}\n };\n }\n \n properties[key] = {\n type,\n items,\n ui: {\n label: this.generateLabel(key),\n isKey: false,\n readOnly: false\n }\n };\n }\n\n return properties;\n }\n}\n"],"mappings":";;;EAAA;AACA;AACA;AACA;;EAIO,MAAMA,gBAAgB,CAAC;IAE1B;AACJ;AACA;IACI,OAAcC,SAASA,CAACC,SAAe,EAAEC,IAAU,EAAW;MAC1D,IAAIC,SAAS,GAAGF,SAAS;MAEzB,IAAI,OAAOE,SAAS,KAAK,QAAQ,EAAE;QAC/B,IAAI;UACAA,SAAS,GAAGC,IAAI,CAACC,KAAK,CAACF,SAAS,CAAC;QACrC,CAAC,CAAC,OAAOG,CAAC,EAAE;UACRC,OAAO,CAACC,IAAI,CAAC,oEAAoE,EAAEF,CAAC,CAAC;UACrFH,SAAS,GAAG,IAAI;QACpB;MACJ;MAEA,IAAI,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAIM,KAAK,CAACC,OAAO,CAACP,SAAS,CAAC,EAAE;QACzE,OAAO,IAAI,CAACQ,mBAAmB,CAACT,IAAI,CAAC;MACzC;;MAEA;MACA,MAAMU,UAAmB,GAAG;QACxBC,KAAK,EAAEV,SAAS,CAACU,KAAK,IAAI,uBAAuB;QACjDC,IAAI,EAAEX,SAAS,CAACW,IAAI,KAAKX,SAAS,CAACY,KAAK,GAAG,OAAO,GAAG,QAAQ;MACjE,CAAC;MAED,IAAIH,UAAU,CAACE,IAAI,KAAK,QAAQ,EAAE;QAC9BF,UAAU,CAACI,UAAU,GAAG,IAAI,CAACC,mBAAmB,CAACd,SAAS,CAACa,UAAU,IAAI,CAAC,CAAC,CAAC;MAChF,CAAC,MAAM,IAAIJ,UAAU,CAACE,IAAI,KAAK,OAAO,EAAE;QACpCF,UAAU,CAACG,KAAK,GAAG,IAAI,CAACG,yBAAyB,CAACf,SAAS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C,KAC/C,IAAIL,KAAK,CAACC,OAAO,CAACmD,GAAG,CAAC,EAAE;UACzB/C,IAAI,GAAG,OAAO;UACdC,KAAK,GAAG;YACJD,IAAI,EAAE,QAAQ;YACdE,UAAU,EAAE6C,GAAG,CAACZ,MAAM,GAAG,CAAC,GAAG,IAAI,CAACU,yBAAyB,CAACE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;UAC3E,CAAC;QACL;QAEA7C,UAAU,CAACI,GAAG,CAAC,GAAG;UACdN,IAAI;UACJC,KAAK;UACLU,EAAE,EAAE;YACAC,KAAK,EAAE,IAAI,CAACC,aAAa,CAACP,GAAG,CAAC;YAC9BQ,KAAK,EAAE,KAAK;YACZC,QAAQ,EAAE;UACd;QACJ,CAAC;MACL;MAEA,OAAOb,UAAU;IACrB;EACJ;EAAC,IAAA+C,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAAhE,gBAAA,GAAAA,gBAAA;EAAA,OAAAgE,SAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare module "nz/co/siliconst/ui5/metaui/core/SchemaNormalizer" {
|
|
2
|
+
/**
|
|
3
|
+
* @file SchemaNormalizer.ts
|
|
4
|
+
* @description Transforms and validates incoming JSON payloads into the strict v2 ISchema dictionary matrix.
|
|
5
|
+
*/
|
|
6
|
+
import { ISchema } from "nz/co/siliconst/ui5/metaui/interfaces/ISchema";
|
|
7
|
+
export class SchemaNormalizer {
|
|
8
|
+
/**
|
|
9
|
+
* Validates that the provided raw payload conforms to the required ISchema structures.
|
|
10
|
+
*/
|
|
11
|
+
static normalize(rawSchema?: any, data?: any): ISchema;
|
|
12
|
+
private static normalizeProperties;
|
|
13
|
+
private static normalizePropertyMetadata;
|
|
14
|
+
/**
|
|
15
|
+
* Generates a Title Case label from camelCase or snake_case technical names.
|
|
16
|
+
*/
|
|
17
|
+
private static generateLabel;
|
|
18
|
+
/**
|
|
19
|
+
* Infers a v2 ISchema structure dynamically from a plain data payload.
|
|
20
|
+
*/
|
|
21
|
+
private static inferSchemaFromData;
|
|
22
|
+
private static inferPropertiesFromObject;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=SchemaNormalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaNormalizer.d.ts","sourceRoot":"../../../../../../../..","sources":["src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,kDAAkD,CAAC;IAClE;;;OAGG;IAEH,OAAO,EAAE,OAAO,EAAgC,MAAM,+CAA+C,CAAC;IAEtG,MAAa,gBAAgB;QAEzB;;WAEG;eACW,SAAS,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO;QA+B7D,OAAO,CAAC,MAAM,CAAC,mBAAmB;QAQlC,OAAO,CAAC,MAAM,CAAC,yBAAyB;QAgCxC;;WAEG;QACH,OAAO,CAAC,MAAM,CAAC,aAAa;QAU5B;;WAEG;QACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;QAqBlC,OAAO,CAAC,MAAM,CAAC,yBAAyB;KAoC3C;CAEA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
sap.ui.define([],function(){"use strict";class e{static normalize(e,t){let r=e;if(typeof r==="string"){try{r=JSON.parse(r)}catch(e){console.warn("[MetaUI] Failed to parse schema string, falling back to inference.",e);r=null}}if(!r||typeof r!=="object"||Array.isArray(r)){return this.inferSchemaFromData(t)}const i={title:r.title||"MetaUI Generated Form",type:r.type||(r.items?"array":"object")};if(i.type==="object"){i.properties=this.normalizeProperties(r.properties||{})}else if(i.type==="array"){i.items=this.normalizePropertyMetadata(r.items||{type:"object",properties:{}},"items")}return i}static normalizeProperties(e){const t={};for(const r of Object.keys(e)){t[r]=this.normalizePropertyMetadata(e[r],r)}return t}static normalizePropertyMetadata(e,t){const r={type:e.type||"string",ui:{label:e.ui?.label||this.generateLabel(t),isKey:!!e.ui?.isKey,readOnly:!!e.ui?.readOnly,widget:e.ui?.widget,group:e.ui?.group,visibleOn:e.ui?.visibleOn,enabledOn:e.ui?.enabledOn,format:e.ui?.format},required:!!e.required,maxLength:e.maxLength,minimum:e.minimum,maximum:e.maximum,pattern:e.pattern,precision:e.precision,scale:e.scale,valueHelp:e.valueHelp};if(r.type==="object"&&e.properties){r.properties=this.normalizeProperties(e.properties)}else if(r.type==="array"&&e.items){r.items=this.normalizePropertyMetadata(e.items,"items")}return r}static generateLabel(e){if(!e)return"";let t=e.replace(/([A-Z])/g," $1").replace(/_/g," ");return t.split(" ").filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ").trim()}static inferSchemaFromData(e){const t={type:"object",properties:{}};if(!e||typeof e!=="object"){return t}if(Array.isArray(e)){t.type="array";t.items={type:"object",properties:e.length>0?this.inferPropertiesFromObject(e[0]):{}}}else{t.type="object";t.properties=this.inferPropertiesFromObject(e)}return t}static inferPropertiesFromObject(e){const t={};if(!e||typeof e!=="object")return t;for(const r of Object.keys(e)){const i=e[r];if(i===null||i===undefined)continue;if(typeof i==="object"&&!Array.isArray(i))continue;let a="string";let s;if(typeof i==="number")a="number";else if(typeof i==="boolean")a="boolean";else if(Array.isArray(i)){a="array";s={type:"object",properties:i.length>0?this.inferPropertiesFromObject(i[0]):{}}}t[r]={type:a,items:s,ui:{label:this.generateLabel(r),isKey:false,readOnly:false}}}return t}}var t={__esModule:true};t.SchemaNormalizer=e;return t});
|
|
2
|
+
//# sourceMappingURL=SchemaNormalizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaNormalizer.js","names":["SchemaNormalizer","normalize","rawSchema","data","schemaObj","JSON","parse","e","console","warn","Array","isArray","this","inferSchemaFromData","normalized","title","type","items","properties","normalizeProperties","normalizePropertyMetadata","normalizedProps","key","Object","keys","prop","keyName","ui","label","generateLabel","isKey","readOnly","widget","group","visibleOn","enabledOn","format","required","maxLength","minimum","maximum","pattern","precision","scale","valueHelp","name","spaced","replace","split","filter","w","length","map","word","charAt","toUpperCase","slice","toLowerCase","join","trim","schema","inferPropertiesFromObject","obj","val","undefined","__exports","__esModule"],"sources":["SchemaNormalizer.ts"],"sourcesContent":["/**\n * @file SchemaNormalizer.ts\n * @description Transforms and validates incoming JSON payloads into the strict v2 ISchema dictionary matrix.\n */\n\nimport { ISchema, IPropertyMetadata, FieldType } from \"../interfaces/ISchema\";\n\nexport class SchemaNormalizer {\n \n /**\n * Validates that the provided raw payload conforms to the required ISchema structures.\n */\n public static normalize(rawSchema?: any, data?: any): ISchema {\n let schemaObj = rawSchema;\n\n if (typeof schemaObj === \"string\") {\n try {\n schemaObj = JSON.parse(schemaObj);\n } catch (e) {\n console.warn(\"[MetaUI] Failed to parse schema string, falling back to inference.\", e);\n schemaObj = null;\n }\n }\n\n if (!schemaObj || typeof schemaObj !== 'object' || Array.isArray(schemaObj)) {\n return this.inferSchemaFromData(data);\n }\n\n // It is an object. Ensure it conforms to v2 structure.\n const normalized: ISchema = {\n title: schemaObj.title || \"MetaUI Generated Form\",\n type: schemaObj.type || (schemaObj.items ? \"array\" : \"object\"),\n };\n\n if (normalized.type === \"object\") {\n normalized.properties = this.normalizeProperties(schemaObj.properties || {});\n } else if (normalized.type === \"array\") {\n normalized.items = this.normalizePropertyMetadata(schemaObj.items || { type: \"object\", properties: {} }, \"items\");\n }\n\n return normalized;\n }\n\n private static normalizeProperties(properties: any): Record<string, IPropertyMetadata> {\n const normalizedProps: Record<string, IPropertyMetadata> = {};\n for (const key of Object.keys(properties)) {\n normalizedProps[key] = this.normalizePropertyMetadata(properties[key], key);\n }\n return normalizedProps;\n }\n\n private static normalizePropertyMetadata(prop: any, keyName: string): IPropertyMetadata {\n const normalized: IPropertyMetadata = {\n type: prop.type || \"string\",\n ui: {\n label: prop.ui?.label || this.generateLabel(keyName),\n isKey: !!prop.ui?.isKey,\n readOnly: !!prop.ui?.readOnly,\n widget: prop.ui?.widget,\n group: prop.ui?.group,\n visibleOn: prop.ui?.visibleOn,\n enabledOn: prop.ui?.enabledOn,\n format: prop.ui?.format\n },\n required: !!prop.required,\n maxLength: prop.maxLength,\n minimum: prop.minimum,\n maximum: prop.maximum,\n pattern: prop.pattern,\n precision: prop.precision,\n scale: prop.scale,\n valueHelp: prop.valueHelp\n };\n\n if (normalized.type === \"object\" && prop.properties) {\n normalized.properties = this.normalizeProperties(prop.properties);\n } else if (normalized.type === \"array\" && prop.items) {\n normalized.items = this.normalizePropertyMetadata(prop.items, \"items\");\n }\n\n return normalized;\n }\n\n /**\n * Generates a Title Case label from camelCase or snake_case technical names.\n */\n private static generateLabel(name: string): string {\n if (!name) return \"\";\n let spaced = name.replace(/([A-Z])/g, \" $1\").replace(/_/g, \" \");\n return spaced.split(' ')\n .filter(w => w.length > 0)\n .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(' ')\n .trim();\n }\n\n /**\n * Infers a v2 ISchema structure dynamically from a plain data payload.\n */\n private static inferSchemaFromData(data: any): ISchema {\n const schema: ISchema = { type: \"object\", properties: {} };\n \n if (!data || typeof data !== \"object\") {\n return schema;\n }\n\n if (Array.isArray(data)) {\n schema.type = \"array\";\n schema.items = {\n type: \"object\",\n properties: data.length > 0 ? this.inferPropertiesFromObject(data[0]) : {}\n };\n } else {\n schema.type = \"object\";\n schema.properties = this.inferPropertiesFromObject(data);\n }\n\n return schema;\n }\n\n private static inferPropertiesFromObject(obj: any): Record<string, IPropertyMetadata> {\n const properties: Record<string, IPropertyMetadata> = {};\n if (!obj || typeof obj !== \"object\") return properties;\n\n for (const key of Object.keys(obj)) {\n const val = obj[key];\n if (val === null || val === undefined) continue;\n \n if (typeof val === \"object\" && !Array.isArray(val)) continue;\n\n let type: FieldType = \"string\";\n let items: IPropertyMetadata | undefined;\n\n if (typeof val === \"number\") type = \"number\";\n else if (typeof val === \"boolean\") type = \"boolean\";\n else if (Array.isArray(val)) {\n type = \"array\";\n items = {\n type: \"object\",\n properties: val.length > 0 ? this.inferPropertiesFromObject(val[0]) : {}\n };\n }\n \n properties[key] = {\n type,\n items,\n ui: {\n label: this.generateLabel(key),\n isKey: false,\n readOnly: false\n }\n };\n }\n\n return properties;\n }\n}\n"],"mappings":"yCAOO,MAAMA,EAKT,gBAAcC,CAAUC,EAAiBC,GACrC,IAAIC,EAAYF,EAEhB,UAAWE,IAAc,SAAU,CAC/B,IACIA,EAAYC,KAAKC,MAAMF,EAC3B,CAAE,MAAOG,GACLC,QAAQC,KAAK,qEAAsEF,GACnFH,EAAY,IAChB,CACJ,CAEA,IAAKA,UAAoBA,IAAc,UAAYM,MAAMC,QAAQP,GAAY,CACzE,OAAOQ,KAAKC,oBAAoBV,EACpC,CAGA,MAAMW,EAAsB,CACxBC,MAAOX,EAAUW,OAAS,wBAC1BC,KAAMZ,EAAUY,OAASZ,EAAUa,MAAQ,QAAU,WAGzD,GAAIH,EAAWE,OAAS,SAAU,CAC9BF,EAAWI,WAAaN,KAAKO,oBAAoBf,EAAUc,YAAc,CAAC,EAC9E,MAAO,GAAIJ,EAAWE,OAAS,QAAS,CACpCF,EAAWG,MAAQL,KAAKQ,0BAA0BhB,EAAUa,OAAS,CAAED,KAAM,SAAUE,WAAY,CAAC,GAAK,QAC7G,CAEA,OAAOJ,CACX,CAEA,0BAAeK,CAAoBD,GAC/B,MAAMG,EAAqD,CAAC,EAC5D,IAAK,MAAMC,KAAOC,OAAOC,KAAKN,GAAa,CACvCG,EAAgBC,GAAOV,KAAKQ,0BAA0BF,EAAWI,GAAMA,EAC3E,CACA,OAAOD,CACX,CAEA,gCAAeD,CAA0BK,EAAWC,GAChD,MAAMZ,EAAgC,CAClCE,KAAMS,EAAKT,MAAQ,SACnBW,GAAI,CACAC,MAAOH,EAAKE,IAAIC,OAAShB,KAAKiB,cAAcH,GAC5CI,QAASL,EAAKE,IAAIG,MAClBC,WAAYN,EAAKE,IAAII,SACrB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