@siliconst/metaui 1.4.4 → 1.4.5
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/package.json +1 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost-dbg.js +40 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost.d.ts +6 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost.ts +44 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ODataDelegate-dbg.js +122 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ODataDelegate-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ODataDelegate.d.ts +49 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ODataDelegate.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ODataDelegate.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ODataDelegate.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ODataDelegate.ts +118 -0
- package/src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator-dbg.js +24 -8
- package/src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator.d.ts +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator.ts +26 -9
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer-dbg.js +45 -1
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.d.ts +10 -1
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.ts +45 -2
- package/src/nz/co/siliconst/ui5/metaui/layouts/CompactLayout-dbg.js +10 -6
- package/src/nz/co/siliconst/ui5/metaui/layouts/CompactLayout-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/CompactLayout.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/CompactLayout.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/CompactLayout.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/CompactLayout.ts +5 -5
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout-dbg.js +10 -6
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.ts +5 -5
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout-dbg.js +22 -29
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.ts +18 -29
- package/src/nz/co/siliconst/ui5/metaui/layouts/WizardLayout-dbg.js +8 -4
- package/src/nz/co/siliconst/ui5/metaui/layouts/WizardLayout-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/WizardLayout.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/WizardLayout.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/WizardLayout.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/WizardLayout.ts +3 -3
- package/src/nz/co/siliconst/ui5/metaui/library-preload.js +8 -7
- package/src/nz/co/siliconst/ui5/metaui/library-preload.js.map +1 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { DynamicHost } from "../DynamicHost";
|
|
2
|
+
import Context from "sap/ui/model/Context";
|
|
3
|
+
import { Logger } from "../../../utils/Logger";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Universal OData Delegate.
|
|
7
|
+
* Natively detects and manages two-way synchronization for both OData V2 and V4 contexts
|
|
8
|
+
* without requiring controller-level mappings.
|
|
9
|
+
*/
|
|
10
|
+
export class ODataDelegate {
|
|
11
|
+
private host: DynamicHost;
|
|
12
|
+
private context: Context;
|
|
13
|
+
private odataType: "V2" | "V4" | null = null;
|
|
14
|
+
private isSyncing: boolean = false;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Initializes a new instance of the ODataDelegate.
|
|
18
|
+
*
|
|
19
|
+
* @param {DynamicHost} host The parent MetaUI DynamicHost instance managing the UI generation.
|
|
20
|
+
* @param {Context} context The active UI5 Model Context bound to the host.
|
|
21
|
+
*/
|
|
22
|
+
constructor(host: DynamicHost, context: Context) {
|
|
23
|
+
this.host = host;
|
|
24
|
+
this.context = context;
|
|
25
|
+
this.detectODataType();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Evaluates the underlying UI5 Model bound to the context to determine if it is an
|
|
30
|
+
* OData V2 or OData V4 model. This determination drives the synchronization strategy.
|
|
31
|
+
*
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
private detectODataType(): void {
|
|
35
|
+
const model = this.context.getModel();
|
|
36
|
+
// sap.ui.model.odata.v4.ODataModel
|
|
37
|
+
// sap.ui.model.odata.v2.ODataModel
|
|
38
|
+
const sClassName = model.getMetadata().getName();
|
|
39
|
+
if (sClassName.indexOf("v4") > -1) {
|
|
40
|
+
this.odataType = "V4";
|
|
41
|
+
} else if (sClassName.indexOf("v2") > -1 || sClassName.indexOf("ODataModel") > -1) {
|
|
42
|
+
this.odataType = "V2";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Extracts the full entity payload from the bound OData context and pushes it to the Engine.
|
|
48
|
+
* V4 uses an asynchronous requestObject(), while V2 retrieves it synchronously.
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
public syncToEngine(): void {
|
|
53
|
+
if (!this.odataType) return;
|
|
54
|
+
|
|
55
|
+
if (this.odataType === "V4") {
|
|
56
|
+
// V4 uses async requestObject()
|
|
57
|
+
if (typeof (this.context as any).requestObject === "function") {
|
|
58
|
+
(this.context as any).requestObject().then((oData: any) => {
|
|
59
|
+
this.pushPayload(oData);
|
|
60
|
+
}).catch((err: Error) => {
|
|
61
|
+
Logger.error("[MetaUI]", "Failed to extract V4 Context payload: " + err.message, "ODataDelegate");
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
} else if (this.odataType === "V2") {
|
|
65
|
+
// V2 uses sync getObject()
|
|
66
|
+
const oData = this.context.getObject();
|
|
67
|
+
if (oData) {
|
|
68
|
+
this.pushPayload(oData);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Cleans the raw OData payload by stripping framework metadata properties (keys starting with '@' or '__')
|
|
75
|
+
* and pushes the sanitized business data into the MetaUI DynamicHost state manager.
|
|
76
|
+
*
|
|
77
|
+
* @param {any} oData The raw JSON object extracted from the OData model context.
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
private pushPayload(oData: any): void {
|
|
81
|
+
if (!oData) return;
|
|
82
|
+
|
|
83
|
+
// Remove OData metadata properties before pushing to MetaUI
|
|
84
|
+
const cleanData = { ...oData };
|
|
85
|
+
for (const key of Object.keys(cleanData)) {
|
|
86
|
+
if (key.startsWith("@") || key.startsWith("__")) {
|
|
87
|
+
delete cleanData[key];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this.isSyncing = true;
|
|
92
|
+
this.host.setProperty("data", cleanData);
|
|
93
|
+
this.isSyncing = false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Intercepts a field change from the MetaUI Engine and translates it into an OData PATCH.
|
|
98
|
+
*/
|
|
99
|
+
public handleFieldChange(fieldPath: string, value: any): void {
|
|
100
|
+
if (this.isSyncing || !this.odataType) return;
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
if (this.odataType === "V4") {
|
|
104
|
+
// V4 sets property directly on context
|
|
105
|
+
this.context.setProperty(fieldPath, value);
|
|
106
|
+
} else if (this.odataType === "V2") {
|
|
107
|
+
// V2 sets property on model, specifying the context path
|
|
108
|
+
const model = this.context.getModel();
|
|
109
|
+
model.setProperty(fieldPath, value, this.context);
|
|
110
|
+
}
|
|
111
|
+
if (this.host.getProperty("debugMode")) {
|
|
112
|
+
Logger.debug("[MetaUI]", `ODataDelegate Patched ${fieldPath} = ${value} via ${this.odataType}`, "ODataDelegate");
|
|
113
|
+
}
|
|
114
|
+
} catch (e) {
|
|
115
|
+
Logger.error("[MetaUI]", `Failed to patch OData context: ${(e as Error).message}`, "ODataDelegate");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -32,16 +32,12 @@ sap.ui.define([], function () {
|
|
|
32
32
|
if (!props || Object.keys(props).length === 0) {
|
|
33
33
|
return false; // Nothing to map
|
|
34
34
|
}
|
|
35
|
-
const elements =
|
|
36
|
-
for (const key of Object.keys(props)) {
|
|
37
|
-
elements.push({
|
|
38
|
-
type: "Control",
|
|
39
|
-
scope: `#/properties/${key}`
|
|
40
|
-
});
|
|
41
|
-
}
|
|
35
|
+
const elements = this.generateElementsFromProperties(props, "#/properties");
|
|
42
36
|
if (isArray) {
|
|
43
37
|
// Table layouts expect an array of flat Controls at the root uiLayout
|
|
44
|
-
|
|
38
|
+
// For tables, we flatten the deep elements or just render the root level
|
|
39
|
+
// To keep it safe, we'll just use the flat elements for tables
|
|
40
|
+
schema.uiLayout = elements.filter(e => e.type === "Control");
|
|
45
41
|
} else {
|
|
46
42
|
// Form layouts expect a grouped structure
|
|
47
43
|
schema.uiLayout = [{
|
|
@@ -52,6 +48,26 @@ sap.ui.define([], function () {
|
|
|
52
48
|
}
|
|
53
49
|
return true;
|
|
54
50
|
}
|
|
51
|
+
static generateElementsFromProperties(props, basePath) {
|
|
52
|
+
const elements = [];
|
|
53
|
+
for (const key of Object.keys(props)) {
|
|
54
|
+
const prop = props[key];
|
|
55
|
+
const currentPath = `${basePath}/${key}`;
|
|
56
|
+
if (prop.type === "object" && prop.properties) {
|
|
57
|
+
elements.push({
|
|
58
|
+
type: "Group",
|
|
59
|
+
label: prop.ui?.label || key,
|
|
60
|
+
elements: this.generateElementsFromProperties(prop.properties, `${currentPath}/properties`)
|
|
61
|
+
});
|
|
62
|
+
} else {
|
|
63
|
+
elements.push({
|
|
64
|
+
type: "Control",
|
|
65
|
+
scope: currentPath
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return elements;
|
|
70
|
+
}
|
|
55
71
|
}
|
|
56
72
|
var __exports = {
|
|
57
73
|
__esModule: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultLayoutGenerator-dbg.js","names":["DefaultLayoutGenerator","ensureLayout","schema","uiLayout","Array","isArray","length","type","props","items","properties","Object","keys","elements","
|
|
1
|
+
{"version":3,"file":"DefaultLayoutGenerator-dbg.js","names":["DefaultLayoutGenerator","ensureLayout","schema","uiLayout","Array","isArray","length","type","props","items","properties","Object","keys","elements","generateElementsFromProperties","filter","e","label","title","basePath","key","prop","currentPath","push","ui","scope","__exports","__esModule"],"sources":["DefaultLayoutGenerator.ts"],"sourcesContent":["/**\n * @file DefaultLayoutGenerator.ts\n * @description Automatically synthesizes a default UI layout for schemas that lack an explicit mapping.\n */\n\nimport { ISchema, ILayoutElement } from \"../interfaces/ISchema\";\n\n/**\n * Encapsulates the logic to dynamically build a safe, default layout orchestration\n * when the developer or backend fails to provide an explicit `uiLayout`.\n * \n * By elevating this into a dedicated utility, we avoid polluting layout engines\n * (like FormLayout or TableLayout) with structural inference responsibilities.\n * \n * @namespace nz.co.siliconst.ui5.metaui.core\n * @public\n */\nexport class DefaultLayoutGenerator {\n /**\n * Inspects a schema. If it has properties but no `uiLayout`, it synthesizes a default.\n * @param schema The ISchema dictionary.\n * @returns boolean True if a layout was synthesized, false if it already existed or was empty.\n */\n public static ensureLayout(schema: ISchema): boolean {\n // If it already has a valid array, do nothing\n if (schema.uiLayout && Array.isArray(schema.uiLayout) && schema.uiLayout.length > 0) {\n return false;\n }\n\n const isArray = schema.type === \"array\";\n const props = isArray ? schema.items?.properties : schema.properties;\n\n if (!props || Object.keys(props).length === 0) {\n return false; // Nothing to map\n }\n\n const elements = this.generateElementsFromProperties(props, \"#/properties\");\n\n if (isArray) {\n // Table layouts expect an array of flat Controls at the root uiLayout\n // For tables, we flatten the deep elements or just render the root level\n // To keep it safe, we'll just use the flat elements for tables\n schema.uiLayout = elements.filter(e => e.type === \"Control\");\n } else {\n // Form layouts expect a grouped structure\n schema.uiLayout = [\n {\n type: \"Group\",\n label: schema.title,\n elements: elements\n }\n ];\n }\n\n return true;\n }\n\n private static generateElementsFromProperties(props: any, basePath: string): ILayoutElement[] {\n const elements: ILayoutElement[] = [];\n for (const key of Object.keys(props)) {\n const prop = props[key];\n const currentPath = `${basePath}/${key}`;\n\n if (prop.type === \"object\" && prop.properties) {\n elements.push({\n type: \"Group\",\n label: prop.ui?.label || key,\n elements: this.generateElementsFromProperties(prop.properties, `${currentPath}/properties`)\n });\n } else {\n elements.push({\n type: \"Control\",\n scope: currentPath\n });\n }\n }\n return elements;\n }\n}\n"],"mappings":";;;EAAA;AACA;AACA;AACA;;EAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACO,MAAMA,sBAAsB,CAAC;IAChC;AACJ;AACA;AACA;AACA;IACI,OAAcC,YAAYA,CAACC,MAAe,EAAW;MACjD;MACA,IAAIA,MAAM,CAACC,QAAQ,IAAIC,KAAK,CAACC,OAAO,CAACH,MAAM,CAACC,QAAQ,CAAC,IAAID,MAAM,CAACC,QAAQ,CAACG,MAAM,GAAG,CAAC,EAAE;QACjF,OAAO,KAAK;MAChB;MAEA,MAAMD,OAAO,GAAGH,MAAM,CAACK,IAAI,KAAK,OAAO;MACvC,MAAMC,KAAK,GAAGH,OAAO,GAAGH,MAAM,CAACO,KAAK,EAAEC,UAAU,GAAGR,MAAM,CAACQ,UAAU;MAEpE,IAAI,CAACF,KAAK,IAAIG,MAAM,CAACC,IAAI,CAACJ,KAAK,CAAC,CAACF,MAAM,KAAK,CAAC,EAAE;QAC3C,OAAO,KAAK,CAAC,CAAC;MAClB;MAEA,MAAMO,QAAQ,GAAG,IAAI,CAACC,8BAA8B,CAACN,KAAK,EAAE,cAAc,CAAC;MAE3E,IAAIH,OAAO,EAAE;QACT;QACA;QACA;QACAH,MAAM,CAACC,QAAQ,GAAGU,QAAQ,CAACE,MAAM,CAACC,CAAC,IAAIA,CAAC,CAACT,IAAI,KAAK,SAAS,CAAC;MAChE,CAAC,MAAM;QACH;QACAL,MAAM,CAACC,QAAQ,GAAG,CACd;UACII,IAAI,EAAE,OAAO;UACbU,KAAK,EAAEf,MAAM,CAACgB,KAAK;UACnBL,QAAQ,EAAEA;QACd,CAAC,CACJ;MACL;MAEA,OAAO,IAAI;IACf;IAEA,OAAeC,8BAA8BA,CAACN,KAAU,EAAEW,QAAgB,EAAoB;MAC1F,MAAMN,QAA0B,GAAG,EAAE;MACrC,KAAK,MAAMO,GAAG,IAAIT,MAAM,CAACC,IAAI,CAACJ,KAAK,CAAC,EAAE;QAClC,MAAMa,IAAI,GAAGb,KAAK,CAACY,GAAG,CAAC;QACvB,MAAME,WAAW,GAAG,GAAGH,QAAQ,IAAIC,GAAG,EAAE;QAExC,IAAIC,IAAI,CAACd,IAAI,KAAK,QAAQ,IAAIc,IAAI,CAACX,UAAU,EAAE;UAC3CG,QAAQ,CAACU,IAAI,CAAC;YACVhB,IAAI,EAAE,OAAO;YACbU,KAAK,EAAEI,IAAI,CAACG,EAAE,EAAEP,KAAK,IAAIG,GAAG;YAC5BP,QAAQ,EAAE,IAAI,CAACC,8BAA8B,CAACO,IAAI,CAACX,UAAU,EAAE,GAAGY,WAAW,aAAa;UAC9F,CAAC,CAAC;QACN,CAAC,MAAM;UACHT,QAAQ,CAACU,IAAI,CAAC;YACVhB,IAAI,EAAE,SAAS;YACfkB,KAAK,EAAEH;UACX,CAAC,CAAC;QACN;MACJ;MACA,OAAOT,QAAQ;IACnB;EACJ;EAAC,IAAAa,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAA1B,sBAAA,GAAAA,sBAAA;EAAA,OAAA0B,SAAA;AAAA","ignoreList":[]}
|
|
@@ -21,6 +21,7 @@ declare module "nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator" {
|
|
|
21
21
|
* @returns boolean True if a layout was synthesized, false if it already existed or was empty.
|
|
22
22
|
*/
|
|
23
23
|
static ensureLayout(schema: ISchema): boolean;
|
|
24
|
+
private static generateElementsFromProperties;
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
//# sourceMappingURL=DefaultLayoutGenerator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultLayoutGenerator.d.ts","sourceRoot":"../../../../../../../..","sources":["src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,wDAAwD,CAAC;IACxE;;;OAGG;IAEH,OAAO,EAAE,OAAO,EAAkB,MAAM,+CAA+C,CAAC;IAExF;;;;;;;;;OASG;IACH,MAAa,sBAAsB;QAC/B;;;;WAIG;eACW,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO;
|
|
1
|
+
{"version":3,"file":"DefaultLayoutGenerator.d.ts","sourceRoot":"../../../../../../../..","sources":["src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,wDAAwD,CAAC;IACxE;;;OAGG;IAEH,OAAO,EAAE,OAAO,EAAkB,MAAM,+CAA+C,CAAC;IAExF;;;;;;;;;OASG;IACH,MAAa,sBAAsB;QAC/B;;;;WAIG;eACW,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO;QAkCpD,OAAO,CAAC,MAAM,CAAC,8BAA8B;KAqBhD;CAEA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
sap.ui.define([],function(){"use strict";class e{static ensureLayout(e){if(e.uiLayout&&Array.isArray(e.uiLayout)&&e.uiLayout.length>0){return false}const t=e.type==="array";const r=t?e.items?.properties:e.properties;if(!r||Object.keys(r).length===0){return false}const
|
|
1
|
+
sap.ui.define([],function(){"use strict";class e{static ensureLayout(e){if(e.uiLayout&&Array.isArray(e.uiLayout)&&e.uiLayout.length>0){return false}const t=e.type==="array";const r=t?e.items?.properties:e.properties;if(!r||Object.keys(r).length===0){return false}const s=this.generateElementsFromProperties(r,"#/properties");if(t){e.uiLayout=s.filter(e=>e.type==="Control")}else{e.uiLayout=[{type:"Group",label:e.title,elements:s}]}return true}static generateElementsFromProperties(e,t){const r=[];for(const s of Object.keys(e)){const o=e[s];const i=`${t}/${s}`;if(o.type==="object"&&o.properties){r.push({type:"Group",label:o.ui?.label||s,elements:this.generateElementsFromProperties(o.properties,`${i}/properties`)})}else{r.push({type:"Control",scope:i})}}return r}}var t={__esModule:true};t.DefaultLayoutGenerator=e;return t});
|
|
2
2
|
//# sourceMappingURL=DefaultLayoutGenerator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultLayoutGenerator.js","names":["DefaultLayoutGenerator","ensureLayout","schema","uiLayout","Array","isArray","length","type","props","items","properties","Object","keys","elements","
|
|
1
|
+
{"version":3,"file":"DefaultLayoutGenerator.js","names":["DefaultLayoutGenerator","ensureLayout","schema","uiLayout","Array","isArray","length","type","props","items","properties","Object","keys","elements","this","generateElementsFromProperties","filter","e","label","title","basePath","key","prop","currentPath","push","ui","scope","__exports","__esModule"],"sources":["DefaultLayoutGenerator.ts"],"sourcesContent":["/**\n * @file DefaultLayoutGenerator.ts\n * @description Automatically synthesizes a default UI layout for schemas that lack an explicit mapping.\n */\n\nimport { ISchema, ILayoutElement } from \"../interfaces/ISchema\";\n\n/**\n * Encapsulates the logic to dynamically build a safe, default layout orchestration\n * when the developer or backend fails to provide an explicit `uiLayout`.\n * \n * By elevating this into a dedicated utility, we avoid polluting layout engines\n * (like FormLayout or TableLayout) with structural inference responsibilities.\n * \n * @namespace nz.co.siliconst.ui5.metaui.core\n * @public\n */\nexport class DefaultLayoutGenerator {\n /**\n * Inspects a schema. If it has properties but no `uiLayout`, it synthesizes a default.\n * @param schema The ISchema dictionary.\n * @returns boolean True if a layout was synthesized, false if it already existed or was empty.\n */\n public static ensureLayout(schema: ISchema): boolean {\n // If it already has a valid array, do nothing\n if (schema.uiLayout && Array.isArray(schema.uiLayout) && schema.uiLayout.length > 0) {\n return false;\n }\n\n const isArray = schema.type === \"array\";\n const props = isArray ? schema.items?.properties : schema.properties;\n\n if (!props || Object.keys(props).length === 0) {\n return false; // Nothing to map\n }\n\n const elements = this.generateElementsFromProperties(props, \"#/properties\");\n\n if (isArray) {\n // Table layouts expect an array of flat Controls at the root uiLayout\n // For tables, we flatten the deep elements or just render the root level\n // To keep it safe, we'll just use the flat elements for tables\n schema.uiLayout = elements.filter(e => e.type === \"Control\");\n } else {\n // Form layouts expect a grouped structure\n schema.uiLayout = [\n {\n type: \"Group\",\n label: schema.title,\n elements: elements\n }\n ];\n }\n\n return true;\n }\n\n private static generateElementsFromProperties(props: any, basePath: string): ILayoutElement[] {\n const elements: ILayoutElement[] = [];\n for (const key of Object.keys(props)) {\n const prop = props[key];\n const currentPath = `${basePath}/${key}`;\n\n if (prop.type === \"object\" && prop.properties) {\n elements.push({\n type: \"Group\",\n label: prop.ui?.label || key,\n elements: this.generateElementsFromProperties(prop.properties, `${currentPath}/properties`)\n });\n } else {\n elements.push({\n type: \"Control\",\n scope: currentPath\n });\n }\n }\n return elements;\n }\n}\n"],"mappings":"yCAiBO,MAAMA,EAMT,mBAAcC,CAAaC,GAEvB,GAAIA,EAAOC,UAAYC,MAAMC,QAAQH,EAAOC,WAAaD,EAAOC,SAASG,OAAS,EAAG,CACjF,OAAO,KACX,CAEA,MAAMD,EAAUH,EAAOK,OAAS,QAChC,MAAMC,EAAQH,EAAUH,EAAOO,OAAOC,WAAaR,EAAOQ,WAE1D,IAAKF,GAASG,OAAOC,KAAKJ,GAAOF,SAAW,EAAG,CAC3C,OAAO,KACX,CAEA,MAAMO,EAAWC,KAAKC,+BAA+BP,EAAO,gBAE5D,GAAIH,EAAS,CAITH,EAAOC,SAAWU,EAASG,OAAOC,GAAKA,EAAEV,OAAS,UACtD,KAAO,CAEHL,EAAOC,SAAW,CACd,CACII,KAAM,QACNW,MAAOhB,EAAOiB,MACdN,SAAUA,GAGtB,CAEA,OAAO,IACX,CAEA,qCAAeE,CAA+BP,EAAYY,GACtD,MAAMP,EAA6B,GACnC,IAAK,MAAMQ,KAAOV,OAAOC,KAAKJ,GAAQ,CAClC,MAAMc,EAAOd,EAAMa,GACnB,MAAME,EAAc,GAAGH,KAAYC,IAEnC,GAAIC,EAAKf,OAAS,UAAYe,EAAKZ,WAAY,CAC3CG,EAASW,KAAK,CACVjB,KAAM,QACNW,MAAOI,EAAKG,IAAIP,OAASG,EACzBR,SAAUC,KAAKC,+BAA+BO,EAAKZ,WAAY,GAAGa,iBAE1E,KAAO,CACHV,EAASW,KAAK,CACVjB,KAAM,UACNmB,MAAOH,GAEf,CACJ,CACA,OAAOV,CACX,EACH,IAAAc,EAAA,CAAAC,WAAA,MAAAD,EAAA3B,yBAAA,OAAA2B,CAAA","ignoreList":[]}
|
|
@@ -34,18 +34,13 @@ export class DefaultLayoutGenerator {
|
|
|
34
34
|
return false; // Nothing to map
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const elements
|
|
38
|
-
|
|
39
|
-
for (const key of Object.keys(props)) {
|
|
40
|
-
elements.push({
|
|
41
|
-
type: "Control",
|
|
42
|
-
scope: `#/properties/${key}`
|
|
43
|
-
});
|
|
44
|
-
}
|
|
37
|
+
const elements = this.generateElementsFromProperties(props, "#/properties");
|
|
45
38
|
|
|
46
39
|
if (isArray) {
|
|
47
40
|
// Table layouts expect an array of flat Controls at the root uiLayout
|
|
48
|
-
|
|
41
|
+
// For tables, we flatten the deep elements or just render the root level
|
|
42
|
+
// To keep it safe, we'll just use the flat elements for tables
|
|
43
|
+
schema.uiLayout = elements.filter(e => e.type === "Control");
|
|
49
44
|
} else {
|
|
50
45
|
// Form layouts expect a grouped structure
|
|
51
46
|
schema.uiLayout = [
|
|
@@ -59,4 +54,26 @@ export class DefaultLayoutGenerator {
|
|
|
59
54
|
|
|
60
55
|
return true;
|
|
61
56
|
}
|
|
57
|
+
|
|
58
|
+
private static generateElementsFromProperties(props: any, basePath: string): ILayoutElement[] {
|
|
59
|
+
const elements: ILayoutElement[] = [];
|
|
60
|
+
for (const key of Object.keys(props)) {
|
|
61
|
+
const prop = props[key];
|
|
62
|
+
const currentPath = `${basePath}/${key}`;
|
|
63
|
+
|
|
64
|
+
if (prop.type === "object" && prop.properties) {
|
|
65
|
+
elements.push({
|
|
66
|
+
type: "Group",
|
|
67
|
+
label: prop.ui?.label || key,
|
|
68
|
+
elements: this.generateElementsFromProperties(prop.properties, `${currentPath}/properties`)
|
|
69
|
+
});
|
|
70
|
+
} else {
|
|
71
|
+
elements.push({
|
|
72
|
+
type: "Control",
|
|
73
|
+
scope: currentPath
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return elements;
|
|
78
|
+
}
|
|
62
79
|
}
|
|
@@ -165,19 +165,23 @@ sap.ui.define(["../utils/Logger"], function (___utils_Logger) {
|
|
|
165
165
|
for (const key of Object.keys(obj)) {
|
|
166
166
|
const val = obj[key];
|
|
167
167
|
if (val === null || val === undefined) continue;
|
|
168
|
-
if (typeof val === "object" && !Array.isArray(val)) continue;
|
|
169
168
|
let type = "string";
|
|
170
169
|
let items;
|
|
170
|
+
let nestedProps;
|
|
171
171
|
if (typeof val === "number") type = "number";else if (typeof val === "boolean") type = "boolean";else if (Array.isArray(val)) {
|
|
172
172
|
type = "array";
|
|
173
173
|
items = {
|
|
174
174
|
type: "object",
|
|
175
175
|
properties: val.length > 0 ? this.inferPropertiesFromObject(val[0]) : {}
|
|
176
176
|
};
|
|
177
|
+
} else if (typeof val === "object") {
|
|
178
|
+
type = "object";
|
|
179
|
+
nestedProps = this.inferPropertiesFromObject(val);
|
|
177
180
|
}
|
|
178
181
|
properties[key] = {
|
|
179
182
|
type,
|
|
180
183
|
items,
|
|
184
|
+
properties: nestedProps,
|
|
181
185
|
ui: {
|
|
182
186
|
label: this.generateLabel(key),
|
|
183
187
|
isKey: false,
|
|
@@ -187,6 +191,46 @@ sap.ui.define(["../utils/Logger"], function (___utils_Logger) {
|
|
|
187
191
|
}
|
|
188
192
|
return properties;
|
|
189
193
|
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Resolves a JSON Schema scope (e.g. '#/properties/header/properties/id')
|
|
197
|
+
* against the ISchema, returning the PropertyMetadata and the UI5 binding path.
|
|
198
|
+
*/
|
|
199
|
+
static resolveScope(schema, scope) {
|
|
200
|
+
if (!scope || !scope.startsWith("#/properties/")) {
|
|
201
|
+
return {
|
|
202
|
+
meta: undefined,
|
|
203
|
+
bindingPath: scope || "",
|
|
204
|
+
propKey: scope || ""
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
const pathSegments = scope.replace("#/properties/", "").split("/properties/");
|
|
208
|
+
let current = schema.properties;
|
|
209
|
+
let meta;
|
|
210
|
+
Logger.debug("[MetaUI SchemaNormalizer]", `Resolving scope '${scope}' with segments: ${JSON.stringify(pathSegments)}`, "SchemaNormalizer");
|
|
211
|
+
Logger.debug("[MetaUI SchemaNormalizer]", `Root schema keys: ${Object.keys(schema.properties || {})}`, "SchemaNormalizer");
|
|
212
|
+
for (let i = 0; i < pathSegments.length; i++) {
|
|
213
|
+
const segment = pathSegments[i];
|
|
214
|
+
if (!current) {
|
|
215
|
+
Logger.debug("[MetaUI SchemaNormalizer]", `current is undefined at segment '${segment}'`, "SchemaNormalizer");
|
|
216
|
+
meta = undefined;
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
meta = current[segment];
|
|
220
|
+
Logger.debug("[MetaUI SchemaNormalizer]", `Segment '${segment}' resolved to meta: ${!!meta}. Available keys in current: ${Object.keys(current)}`, "SchemaNormalizer");
|
|
221
|
+
if (i < pathSegments.length - 1) {
|
|
222
|
+
current = meta?.properties;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const bindingPath = pathSegments.join("/");
|
|
226
|
+
const propKey = scope.replace("#/properties/", ""); // The original raw string for logging
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
meta,
|
|
230
|
+
bindingPath,
|
|
231
|
+
propKey
|
|
232
|
+
};
|
|
233
|
+
}
|
|
190
234
|
}
|
|
191
235
|
var __exports = {
|
|
192
236
|
__esModule: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaNormalizer-dbg.js","names":["Logger","___utils_Logger","SchemaNormalizer","normalize","rawSchema","data","schemaObj","JSON","parse","e","msg","message","error","showErrorPopup","Array","isArray","inferSchemaFromData","normalized","title","type","items","layoutStrategy","uiLayout","additionalProperties","targetProperties","properties","inferred","deepMergeProperties","normalizeProperties","normalizePropertyMetadata","base","override","merged","key","Object","keys","overrideVal","baseVal","normalizedProps","prop","keyName","ui","label","generateLabel","isKey","readOnly","widget","valueHelp","enum","undefined","visibleOn","enabledOn","format","validators","formatter","args","rows","fullWidth","required","maxLength","minimum","maximum","pattern","precision","scale","name","spaced","replace","split","filter","w","length","map","word","charAt","toUpperCase","slice","toLowerCase","join","trim","schema","inferPropertiesFromObject","obj","val","__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\";\nimport { Logger } from \"../utils/Logger\";\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 const msg = (e as Error).message;\n Logger.error(\"[MetaUI SchemaNormalizer] Failed to parse schema string.\", msg);\n Logger.showErrorPopup(`Failed to parse the provided JSON schema.\\n\\nDetails: ${msg}`);\n schemaObj = null;\n }\n }\n\n if (!schemaObj || typeof schemaObj !== 'object' || Array.isArray(schemaObj)) {\n return this.inferSchemaFromData(data);\n }\n\n try {\n // It is an object. Ensure it conforms to v2 structure.\n const normalized: ISchema = {\n title: schemaObj.title,\n type: schemaObj.type || (schemaObj.items ? \"array\" : \"object\"),\n layoutStrategy: schemaObj.layoutStrategy,\n uiLayout: schemaObj.uiLayout,\n additionalProperties: schemaObj.additionalProperties\n };\n\n let targetProperties = schemaObj.properties || {};\n\n if (schemaObj.additionalProperties === true && data) {\n const inferred = this.inferSchemaFromData(data);\n if (inferred.type === \"object\" && inferred.properties) {\n targetProperties = this.deepMergeProperties(inferred.properties, targetProperties);\n } else if (inferred.type === \"array\" && inferred.items && inferred.items.properties) {\n // Array schema merging could be added here if we want full support.\n }\n }\n\n if (normalized.type === \"object\") {\n normalized.properties = this.normalizeProperties(targetProperties);\n } else if (normalized.type === \"array\") {\n // Future expansion: array deep merge\n normalized.items = this.normalizePropertyMetadata(schemaObj.items || { type: \"object\", properties: {} }, \"items\");\n }\n\n return normalized;\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(\"[MetaUI SchemaNormalizer] Critical error normalizing schema object.\", msg);\n Logger.showErrorPopup(`Schema Normalization failed.\\n\\nDetails: ${msg}`);\n // Fallback to empty object to prevent hard crash downstream\n return { type: \"object\", properties: {} };\n }\n }\n\n private static deepMergeProperties(base: any, override: any): any {\n const merged = { ...base };\n for (const key of Object.keys(override)) {\n const overrideVal = override[key];\n const baseVal = merged[key];\n\n if (baseVal && typeof baseVal === \"object\" && !Array.isArray(baseVal) &&\n overrideVal && typeof overrideVal === \"object\" && !Array.isArray(overrideVal)) {\n merged[key] = this.deepMergeProperties(baseVal, overrideVal);\n } else {\n merged[key] = overrideVal;\n }\n }\n return merged;\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 || (prop.valueHelp || prop.enum ? \"select\" : undefined),\n visibleOn: prop.ui?.visibleOn,\n enabledOn: prop.ui?.enabledOn,\n format: prop.ui?.format,\n validators: prop.ui?.validators,\n formatter: prop.ui?.formatter,\n args: prop.ui?.args,\n rows: prop.ui?.rows,\n fullWidth: prop.ui?.fullWidth\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 enum: prop.enum\n };\n\n if (normalized.type === \"object\" && prop.properties) {\n normalized.properties = this.normalizeProperties(prop.properties);\n normalized.uiLayout = prop.uiLayout;\n } else if (normalized.type === \"array\" && prop.items) {\n normalized.items = this.normalizePropertyMetadata(prop.items, \"items\");\n normalized.uiLayout = prop.uiLayout;\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: {}, layoutStrategy: \"compact\", title: \"\" };\n\n if (!data || typeof data !== \"object\") {\n return schema;\n }\n\n if (Array.isArray(data)) {\n schema.type = \"array\";\n schema.layoutStrategy = \"table\";\n schema.items = {\n type: \"object\",\n layoutStrategy: \"compact\",\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;EAHA,MAMSA,MAAM,GAAAC,eAAA;EAER,MAAMC,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;UACR,MAAMC,GAAG,GAAID,CAAC,CAAWE,OAAO;UAChCX,MAAM,CAACY,KAAK,CAAC,0DAA0D,EAAEF,GAAG,CAAC;UAC7EV,MAAM,CAACa,cAAc,CAAC,yDAAyDH,GAAG,EAAE,CAAC;UACrFJ,SAAS,GAAG,IAAI;QACpB;MACJ;MAEA,IAAI,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAIQ,KAAK,CAACC,OAAO,CAACT,SAAS,CAAC,EAAE;QACzE,OAAO,IAAI,CAACU,mBAAmB,CAACX,IAAI,CAAC;MACzC;MAEA,IAAI;QACA;QACA,MAAMY,UAAmB,GAAG;UACxBC,KAA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AG,KAAK,QAAQ,EAAEhE,IAAI,GAAG,QAAQ,CAAC,KACxC,IAAI,OAAOgE,GAAG,KAAK,SAAS,EAAEhE,IAAI,GAAG,SAAS,CAAC,KAC/C,IAAIL,KAAK,CAACC,OAAO,CAACoE,GAAG,CAAC,EAAE;UACzBhE,IAAI,GAAG,OAAO;UACdC,KAAK,GAAG;YACJD,IAAI,EAAE,QAAQ;YACdM,UAAU,EAAE0D,GAAG,CAACZ,MAAM,GAAG,CAAC,GAAG,IAAI,CAACU,yBAAyB,CAACE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;UAC3E,CAAC;QACL;QAEA1D,UAAU,CAACQ,GAAG,CAAC,GAAG;UACdd,IAAI;UACJC,KAAK;UACLqB,EAAE,EAAE;YACAC,KAAK,EAAE,IAAI,CAACC,aAAa,CAACV,GAAG,CAAC;YAC9BW,KAAK,EAAE,KAAK;YACZC,QAAQ,EAAE;UACd;QACJ,CAAC;MACL;MAEA,OAAOpB,UAAU;IACrB;EACJ;EAAC,IAAA2D,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAAlF,gBAAA,GAAAA,gBAAA;EAAA,OAAAkF,SAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"SchemaNormalizer-dbg.js","names":["Logger","___utils_Logger","SchemaNormalizer","normalize","rawSchema","data","schemaObj","JSON","parse","e","msg","message","error","showErrorPopup","Array","isArray","inferSchemaFromData","normalized","title","type","items","layoutStrategy","uiLayout","additionalProperties","targetProperties","properties","inferred","deepMergeProperties","normalizeProperties","normalizePropertyMetadata","base","override","merged","key","Object","keys","overrideVal","baseVal","normalizedProps","prop","keyName","ui","label","generateLabel","isKey","readOnly","widget","valueHelp","enum","undefined","visibleOn","enabledOn","format","validators","formatter","args","rows","fullWidth","required","maxLength","minimum","maximum","pattern","precision","scale","name","spaced","replace","split","filter","w","length","map","word","charAt","toUpperCase","slice","toLowerCase","join","trim","schema","inferPropertiesFromObject","obj","val","nestedProps","resolveScope","scope","startsWith","meta","bindingPath","propKey","pathSegments","current","debug","stringify","i","segment","__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\";\nimport { Logger } from \"../utils/Logger\";\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 const msg = (e as Error).message;\n Logger.error(\"[MetaUI SchemaNormalizer] Failed to parse schema string.\", msg);\n Logger.showErrorPopup(`Failed to parse the provided JSON schema.\\n\\nDetails: ${msg}`);\n schemaObj = null;\n }\n }\n\n if (!schemaObj || typeof schemaObj !== 'object' || Array.isArray(schemaObj)) {\n return this.inferSchemaFromData(data);\n }\n\n try {\n // It is an object. Ensure it conforms to v2 structure.\n const normalized: ISchema = {\n title: schemaObj.title,\n type: schemaObj.type || (schemaObj.items ? \"array\" : \"object\"),\n layoutStrategy: schemaObj.layoutStrategy,\n uiLayout: schemaObj.uiLayout,\n additionalProperties: schemaObj.additionalProperties\n };\n\n let targetProperties = schemaObj.properties || {};\n\n if (schemaObj.additionalProperties === true && data) {\n const inferred = this.inferSchemaFromData(data);\n if (inferred.type === \"object\" && inferred.properties) {\n targetProperties = this.deepMergeProperties(inferred.properties, targetProperties);\n } else if (inferred.type === \"array\" && inferred.items && inferred.items.properties) {\n // Array schema merging could be added here if we want full support.\n }\n }\n\n if (normalized.type === \"object\") {\n normalized.properties = this.normalizeProperties(targetProperties);\n } else if (normalized.type === \"array\") {\n // Future expansion: array deep merge\n normalized.items = this.normalizePropertyMetadata(schemaObj.items || { type: \"object\", properties: {} }, \"items\");\n }\n\n return normalized;\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(\"[MetaUI SchemaNormalizer] Critical error normalizing schema object.\", msg);\n Logger.showErrorPopup(`Schema Normalization failed.\\n\\nDetails: ${msg}`);\n // Fallback to empty object to prevent hard crash downstream\n return { type: \"object\", properties: {} };\n }\n }\n\n private static deepMergeProperties(base: any, override: any): any {\n const merged = { ...base };\n for (const key of Object.keys(override)) {\n const overrideVal = override[key];\n const baseVal = merged[key];\n\n if (baseVal && typeof baseVal === \"object\" && !Array.isArray(baseVal) &&\n overrideVal && typeof overrideVal === \"object\" && !Array.isArray(overrideVal)) {\n merged[key] = this.deepMergeProperties(baseVal, overrideVal);\n } else {\n merged[key] = overrideVal;\n }\n }\n return merged;\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 || (prop.valueHelp || prop.enum ? \"select\" : undefined),\n visibleOn: prop.ui?.visibleOn,\n enabledOn: prop.ui?.enabledOn,\n format: prop.ui?.format,\n validators: prop.ui?.validators,\n formatter: prop.ui?.formatter,\n args: prop.ui?.args,\n rows: prop.ui?.rows,\n fullWidth: prop.ui?.fullWidth\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 enum: prop.enum\n };\n\n if (normalized.type === \"object\" && prop.properties) {\n normalized.properties = this.normalizeProperties(prop.properties);\n normalized.uiLayout = prop.uiLayout;\n } else if (normalized.type === \"array\" && prop.items) {\n normalized.items = this.normalizePropertyMetadata(prop.items, \"items\");\n normalized.uiLayout = prop.uiLayout;\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: {}, layoutStrategy: \"compact\", title: \"\" };\n\n if (!data || typeof data !== \"object\") {\n return schema;\n }\n\n if (Array.isArray(data)) {\n schema.type = \"array\";\n schema.layoutStrategy = \"table\";\n schema.items = {\n type: \"object\",\n layoutStrategy: \"compact\",\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 let type: FieldType = \"string\";\n let items: IPropertyMetadata | undefined;\n let nestedProps: Record<string, 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 } else if (typeof val === \"object\") {\n type = \"object\";\n nestedProps = this.inferPropertiesFromObject(val);\n }\n\n properties[key] = {\n type,\n items,\n properties: nestedProps,\n ui: {\n label: this.generateLabel(key),\n isKey: false,\n readOnly: false\n }\n };\n }\n\n return properties;\n }\n\n /**\n * Resolves a JSON Schema scope (e.g. '#/properties/header/properties/id')\n * against the ISchema, returning the PropertyMetadata and the UI5 binding path.\n */\n public static resolveScope(schema: ISchema, scope: string): { meta: IPropertyMetadata | undefined, bindingPath: string, propKey: string } {\n if (!scope || !scope.startsWith(\"#/properties/\")) {\n return { meta: undefined, bindingPath: scope || \"\", propKey: scope || \"\" };\n }\n \n const pathSegments = scope.replace(\"#/properties/\", \"\").split(\"/properties/\");\n let current: any = schema.properties;\n let meta: IPropertyMetadata | undefined;\n \n Logger.debug(\"[MetaUI SchemaNormalizer]\", `Resolving scope '${scope}' with segments: ${JSON.stringify(pathSegments)}`, \"SchemaNormalizer\");\n Logger.debug(\"[MetaUI SchemaNormalizer]\", `Root schema keys: ${Object.keys(schema.properties || {})}`, \"SchemaNormalizer\");\n\n for (let i = 0; i < pathSegments.length; i++) {\n const segment = pathSegments[i];\n if (!current) {\n Logger.debug(\"[MetaUI SchemaNormalizer]\", `current is undefined at segment '${segment}'`, \"SchemaNormalizer\");\n meta = undefined;\n break;\n }\n meta = current[segment];\n Logger.debug(\"[MetaUI SchemaNormalizer]\", `Segment '${segment}' resolved to meta: ${!!meta}. Available keys in current: ${Object.keys(current)}`, \"SchemaNormalizer\");\n if (i < pathSegments.length - 1) {\n current = meta?.properties;\n }\n }\n \n const bindingPath = pathSegments.join(\"/\");\n const propKey = scope.replace(\"#/properties/\", \"\"); // The original raw string for logging\n \n return {\n meta,\n bindingPath,\n propKey\n };\n }\n}\n"],"mappings":";;;EAAA;AACA;AACA;AACA;EAHA,MAMSA,MAAM,GAAAC,eAAA;EAER,MAAMC,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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BAAkB,CAAC;QACrK,IAAIG,CAAC,GAAGJ,YAAY,CAACpB,MAAM,GAAG,CAAC,EAAE;UAC7BqB,OAAO,GAAGJ,IAAI,EAAE/D,UAAU;QAC9B;MACJ;MAEA,MAAMgE,WAAW,GAAGE,YAAY,CAACb,IAAI,CAAC,GAAG,CAAC;MAC1C,MAAMY,OAAO,GAAGJ,KAAK,CAACnB,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC;;MAEpD,OAAO;QACHqB,IAAI;QACJC,WAAW;QACXC;MACJ,CAAC;IACL;EACJ;EAAC,IAAAO,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAA/F,gBAAA,GAAAA,gBAAA;EAAA,OAAA+F,SAAA;AAAA","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@ declare module "nz/co/siliconst/ui5/metaui/core/SchemaNormalizer" {
|
|
|
3
3
|
* @file SchemaNormalizer.ts
|
|
4
4
|
* @description Transforms and validates incoming JSON payloads into the strict v2 ISchema dictionary matrix.
|
|
5
5
|
*/
|
|
6
|
-
import { ISchema } from "nz/co/siliconst/ui5/metaui/interfaces/ISchema";
|
|
6
|
+
import { ISchema, IPropertyMetadata } from "nz/co/siliconst/ui5/metaui/interfaces/ISchema";
|
|
7
7
|
export class SchemaNormalizer {
|
|
8
8
|
/**
|
|
9
9
|
* Validates that the provided raw payload conforms to the required ISchema structures.
|
|
@@ -21,6 +21,15 @@ declare module "nz/co/siliconst/ui5/metaui/core/SchemaNormalizer" {
|
|
|
21
21
|
*/
|
|
22
22
|
private static inferSchemaFromData;
|
|
23
23
|
private static inferPropertiesFromObject;
|
|
24
|
+
/**
|
|
25
|
+
* Resolves a JSON Schema scope (e.g. '#/properties/header/properties/id')
|
|
26
|
+
* against the ISchema, returning the PropertyMetadata and the UI5 binding path.
|
|
27
|
+
*/
|
|
28
|
+
static resolveScope(schema: ISchema, scope: string): {
|
|
29
|
+
meta: IPropertyMetadata | undefined;
|
|
30
|
+
bindingPath: string;
|
|
31
|
+
propKey: string;
|
|
32
|
+
};
|
|
24
33
|
}
|
|
25
34
|
}
|
|
26
35
|
//# sourceMappingURL=SchemaNormalizer.d.ts.map
|
|
@@ -1 +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,
|
|
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,EAAE,iBAAiB,EAAa,MAAM,+CAA+C,CAAC;IAGtG,MAAa,gBAAgB;QAEzB;;WAEG;eACW,SAAS,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO;QAwD7D,OAAO,CAAC,MAAM,CAAC,mBAAmB;QAgBlC,OAAO,CAAC,MAAM,CAAC,mBAAmB;QAQlC,OAAO,CAAC,MAAM,CAAC,yBAAyB;QAuCxC;;WAEG;QACH,OAAO,CAAC,MAAM,CAAC,aAAa;QAU5B;;WAEG;QACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;QAuBlC,OAAO,CAAC,MAAM,CAAC,yBAAyB;QAwCxC;;;WAGG;eACW,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG;YAAE,IAAI,EAAE,iBAAiB,GAAG,SAAS,CAAC;YAAC,WAAW,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE;KAmC5I;CAEA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
sap.ui.define(["../utils/Logger"],function(e){"use strict";const t=e["Logger"];class r{static normalize(e,r){let i=e;if(typeof i==="string"){try{i=JSON.parse(i)}catch(e){const r=e.message;t.error("[MetaUI SchemaNormalizer] Failed to parse schema string.",r);t.showErrorPopup(`Failed to parse the provided JSON schema.\n\nDetails: ${r}`);i=null}}if(!i||typeof i!=="object"||Array.isArray(i)){return this.inferSchemaFromData(r)}try{const e={title:i.title,type:i.type||(i.items?"array":"object"),layoutStrategy:i.layoutStrategy,uiLayout:i.uiLayout,additionalProperties:i.additionalProperties};let t=i.properties||{};if(i.additionalProperties===true&&r){const e=this.inferSchemaFromData(r);if(e.type==="object"&&e.properties){t=this.deepMergeProperties(e.properties,t)}else if(e.type==="array"&&e.items&&e.items.properties){}}if(e.type==="object"){e.properties=this.normalizeProperties(t)}else if(e.type==="array"){e.items=this.normalizePropertyMetadata(i.items||{type:"object",properties:{}},"items")}return e}catch(e){const r=e.message;t.error("[MetaUI SchemaNormalizer] Critical error normalizing schema object.",r);t.showErrorPopup(`Schema Normalization failed.\n\nDetails: ${r}`);return{type:"object",properties:{}}}}static deepMergeProperties(e,t){const r={...e};for(const e of Object.keys(t)){const i=t[e];const a=r[e];if(a&&typeof a==="object"&&!Array.isArray(a)&&i&&typeof i==="object"&&!Array.isArray(i)){r[e]=this.deepMergeProperties(a,i)}else{r[e]=i}}return r}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||(e.valueHelp||e.enum?"select":undefined),visibleOn:e.ui?.visibleOn,enabledOn:e.ui?.enabledOn,format:e.ui?.format,validators:e.ui?.validators,formatter:e.ui?.formatter,args:e.ui?.args,rows:e.ui?.rows,fullWidth:e.ui?.fullWidth},required:!!e.required,maxLength:e.maxLength,minimum:e.minimum,maximum:e.maximum,pattern:e.pattern,precision:e.precision,scale:e.scale,valueHelp:e.valueHelp,enum:e.enum};if(r.type==="object"&&e.properties){r.properties=this.normalizeProperties(e.properties);r.uiLayout=e.uiLayout}else if(r.type==="array"&&e.items){r.items=this.normalizePropertyMetadata(e.items,"items");r.uiLayout=e.uiLayout}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:{},layoutStrategy:"compact",title:""};if(!e||typeof e!=="object"){return t}if(Array.isArray(e)){t.type="array";t.layoutStrategy="table";t.items={type:"object",layoutStrategy:"compact",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;
|
|
1
|
+
sap.ui.define(["../utils/Logger"],function(e){"use strict";const t=e["Logger"];class r{static normalize(e,r){let i=e;if(typeof i==="string"){try{i=JSON.parse(i)}catch(e){const r=e.message;t.error("[MetaUI SchemaNormalizer] Failed to parse schema string.",r);t.showErrorPopup(`Failed to parse the provided JSON schema.\n\nDetails: ${r}`);i=null}}if(!i||typeof i!=="object"||Array.isArray(i)){return this.inferSchemaFromData(r)}try{const e={title:i.title,type:i.type||(i.items?"array":"object"),layoutStrategy:i.layoutStrategy,uiLayout:i.uiLayout,additionalProperties:i.additionalProperties};let t=i.properties||{};if(i.additionalProperties===true&&r){const e=this.inferSchemaFromData(r);if(e.type==="object"&&e.properties){t=this.deepMergeProperties(e.properties,t)}else if(e.type==="array"&&e.items&&e.items.properties){}}if(e.type==="object"){e.properties=this.normalizeProperties(t)}else if(e.type==="array"){e.items=this.normalizePropertyMetadata(i.items||{type:"object",properties:{}},"items")}return e}catch(e){const r=e.message;t.error("[MetaUI SchemaNormalizer] Critical error normalizing schema object.",r);t.showErrorPopup(`Schema Normalization failed.\n\nDetails: ${r}`);return{type:"object",properties:{}}}}static deepMergeProperties(e,t){const r={...e};for(const e of Object.keys(t)){const i=t[e];const a=r[e];if(a&&typeof a==="object"&&!Array.isArray(a)&&i&&typeof i==="object"&&!Array.isArray(i)){r[e]=this.deepMergeProperties(a,i)}else{r[e]=i}}return r}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||(e.valueHelp||e.enum?"select":undefined),visibleOn:e.ui?.visibleOn,enabledOn:e.ui?.enabledOn,format:e.ui?.format,validators:e.ui?.validators,formatter:e.ui?.formatter,args:e.ui?.args,rows:e.ui?.rows,fullWidth:e.ui?.fullWidth},required:!!e.required,maxLength:e.maxLength,minimum:e.minimum,maximum:e.maximum,pattern:e.pattern,precision:e.precision,scale:e.scale,valueHelp:e.valueHelp,enum:e.enum};if(r.type==="object"&&e.properties){r.properties=this.normalizeProperties(e.properties);r.uiLayout=e.uiLayout}else if(r.type==="array"&&e.items){r.items=this.normalizePropertyMetadata(e.items,"items");r.uiLayout=e.uiLayout}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:{},layoutStrategy:"compact",title:""};if(!e||typeof e!=="object"){return t}if(Array.isArray(e)){t.type="array";t.layoutStrategy="table";t.items={type:"object",layoutStrategy:"compact",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;let a="string";let o;let s;if(typeof i==="number")a="number";else if(typeof i==="boolean")a="boolean";else if(Array.isArray(i)){a="array";o={type:"object",properties:i.length>0?this.inferPropertiesFromObject(i[0]):{}}}else if(typeof i==="object"){a="object";s=this.inferPropertiesFromObject(i)}t[r]={type:a,items:o,properties:s,ui:{label:this.generateLabel(r),isKey:false,readOnly:false}}}return t}static resolveScope(e,r){if(!r||!r.startsWith("#/properties/")){return{meta:undefined,bindingPath:r||"",propKey:r||""}}const i=r.replace("#/properties/","").split("/properties/");let a=e.properties;let o;t.debug("[MetaUI SchemaNormalizer]",`Resolving scope '${r}' with segments: ${JSON.stringify(i)}`,"SchemaNormalizer");t.debug("[MetaUI SchemaNormalizer]",`Root schema keys: ${Object.keys(e.properties||{})}`,"SchemaNormalizer");for(let e=0;e<i.length;e++){const r=i[e];if(!a){t.debug("[MetaUI SchemaNormalizer]",`current is undefined at segment '${r}'`,"SchemaNormalizer");o=undefined;break}o=a[r];t.debug("[MetaUI SchemaNormalizer]",`Segment '${r}' resolved to meta: ${!!o}. Available keys in current: ${Object.keys(a)}`,"SchemaNormalizer");if(e<i.length-1){a=o?.properties}}const s=i.join("/");const n=r.replace("#/properties/","");return{meta:o,bindingPath:s,propKey:n}}}var i={__esModule:true};i.SchemaNormalizer=r;return i});
|
|
2
2
|
//# sourceMappingURL=SchemaNormalizer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaNormalizer.js","names":["Logger","___utils_Logger","SchemaNormalizer","normalize","rawSchema","data","schemaObj","JSON","parse","e","msg","message","error","showErrorPopup","Array","isArray","this","inferSchemaFromData","normalized","title","type","items","layoutStrategy","uiLayout","additionalProperties","targetProperties","properties","inferred","deepMergeProperties","normalizeProperties","normalizePropertyMetadata","base","override","merged","key","Object","keys","overrideVal","baseVal","normalizedProps","prop","keyName","ui","label","generateLabel","isKey","readOnly","widget","valueHelp","enum","undefined","visibleOn","enabledOn","format","validators","formatter","args","rows","fullWidth","required","maxLength","minimum","maximum","pattern","precision","scale","name","spaced","replace","split","filter","w","length","map","word","charAt","toUpperCase","slice","toLowerCase","join","trim","schema","inferPropertiesFromObject","obj","val","__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\";\nimport { Logger } from \"../utils/Logger\";\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 const msg = (e as Error).message;\n Logger.error(\"[MetaUI SchemaNormalizer] Failed to parse schema string.\", msg);\n Logger.showErrorPopup(`Failed to parse the provided JSON schema.\\n\\nDetails: ${msg}`);\n schemaObj = null;\n }\n }\n\n if (!schemaObj || typeof schemaObj !== 'object' || Array.isArray(schemaObj)) {\n return this.inferSchemaFromData(data);\n }\n\n try {\n // It is an object. Ensure it conforms to v2 structure.\n const normalized: ISchema = {\n title: schemaObj.title,\n type: schemaObj.type || (schemaObj.items ? \"array\" : \"object\"),\n layoutStrategy: schemaObj.layoutStrategy,\n uiLayout: schemaObj.uiLayout,\n additionalProperties: schemaObj.additionalProperties\n };\n\n let targetProperties = schemaObj.properties || {};\n\n if (schemaObj.additionalProperties === true && data) {\n const inferred = this.inferSchemaFromData(data);\n if (inferred.type === \"object\" && inferred.properties) {\n targetProperties = this.deepMergeProperties(inferred.properties, targetProperties);\n } else if (inferred.type === \"array\" && inferred.items && inferred.items.properties) {\n // Array schema merging could be added here if we want full support.\n }\n }\n\n if (normalized.type === \"object\") {\n normalized.properties = this.normalizeProperties(targetProperties);\n } else if (normalized.type === \"array\") {\n // Future expansion: array deep merge\n normalized.items = this.normalizePropertyMetadata(schemaObj.items || { type: \"object\", properties: {} }, \"items\");\n }\n\n return normalized;\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(\"[MetaUI SchemaNormalizer] Critical error normalizing schema object.\", msg);\n Logger.showErrorPopup(`Schema Normalization failed.\\n\\nDetails: ${msg}`);\n // Fallback to empty object to prevent hard crash downstream\n return { type: \"object\", properties: {} };\n }\n }\n\n private static deepMergeProperties(base: any, override: any): any {\n const merged = { ...base };\n for (const key of Object.keys(override)) {\n const overrideVal = override[key];\n const baseVal = merged[key];\n\n if (baseVal && typeof baseVal === \"object\" && !Array.isArray(baseVal) &&\n overrideVal && typeof overrideVal === \"object\" && !Array.isArray(overrideVal)) {\n merged[key] = this.deepMergeProperties(baseVal, overrideVal);\n } else {\n merged[key] = overrideVal;\n }\n }\n return merged;\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 || (prop.valueHelp || prop.enum ? \"select\" : undefined),\n visibleOn: prop.ui?.visibleOn,\n enabledOn: prop.ui?.enabledOn,\n format: prop.ui?.format,\n validators: prop.ui?.validators,\n formatter: prop.ui?.formatter,\n args: prop.ui?.args,\n rows: prop.ui?.rows,\n fullWidth: prop.ui?.fullWidth\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 enum: prop.enum\n };\n\n if (normalized.type === \"object\" && prop.properties) {\n normalized.properties = this.normalizeProperties(prop.properties);\n normalized.uiLayout = prop.uiLayout;\n } else if (normalized.type === \"array\" && prop.items) {\n normalized.items = this.normalizePropertyMetadata(prop.items, \"items\");\n normalized.uiLayout = prop.uiLayout;\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: {}, layoutStrategy: \"compact\", title: \"\" };\n\n if (!data || typeof data !== \"object\") {\n return schema;\n }\n\n if (Array.isArray(data)) {\n schema.type = \"array\";\n schema.layoutStrategy = \"table\";\n schema.items = {\n type: \"object\",\n layoutStrategy: \"compact\",\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 }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,KAAOC,OAAOC,KAAK+C,GAAM,CAChC,MAAMC,EAAMD,EAAIjD,GAChB,GAAIkD,IAAQ,MAAQA,IAAQlC,UAAW,SAEvC,UAAWkC,IAAQ,WAAatE,MAAMC,QAAQqE,GAAM,SAEpD,IAAIhE,EAAkB,SACtB,IAAIC,EAEJ,UAAW+D,IAAQ,SAAUhE,EAAO,cAC/B,UAAWgE,IAAQ,UAAWhE,EAAO,eACrC,GAAIN,MAAMC,QAAQqE,GAAM,CACzBhE,EAAO,QACPC,EAAQ,CACJD,KAAM,SACNM,WAAY0D,EAAIZ,OAAS,EAAIxD,KAAKkE,0BAA0BE,EAAI,IAAM,CAAC,EAE/E,CAEA1D,EAAWQ,GAAO,CACdd,OACAC,QACAqB,GAAI,CACAC,MAAO3B,KAAK4B,cAAcV,GAC1BW,MAAO,MACPC,SAAU,OAGtB,CAEA,OAAOpB,CACX,EACH,IAAA2D,EAAA,CAAAC,WAAA,MAAAD,EAAAnF,mBAAA,OAAAmF,CAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"SchemaNormalizer.js","names":["Logger","___utils_Logger","SchemaNormalizer","normalize","rawSchema","data","schemaObj","JSON","parse","e","msg","message","error","showErrorPopup","Array","isArray","this","inferSchemaFromData","normalized","title","type","items","layoutStrategy","uiLayout","additionalProperties","targetProperties","properties","inferred","deepMergeProperties","normalizeProperties","normalizePropertyMetadata","base","override","merged","key","Object","keys","overrideVal","baseVal","normalizedProps","prop","keyName","ui","label","generateLabel","isKey","readOnly","widget","valueHelp","enum","undefined","visibleOn","enabledOn","format","validators","formatter","args","rows","fullWidth","required","maxLength","minimum","maximum","pattern","precision","scale","name","spaced","replace","split","filter","w","length","map","word","charAt","toUpperCase","slice","toLowerCase","join","trim","schema","inferPropertiesFromObject","obj","val","nestedProps","resolveScope","scope","startsWith","meta","bindingPath","propKey","pathSegments","current","debug","stringify","i","segment","__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\";\nimport { Logger } from \"../utils/Logger\";\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 const msg = (e as Error).message;\n Logger.error(\"[MetaUI SchemaNormalizer] Failed to parse schema string.\", msg);\n Logger.showErrorPopup(`Failed to parse the provided JSON schema.\\n\\nDetails: ${msg}`);\n schemaObj = null;\n }\n }\n\n if (!schemaObj || typeof schemaObj !== 'object' || Array.isArray(schemaObj)) {\n return this.inferSchemaFromData(data);\n }\n\n try {\n // It is an object. Ensure it conforms to v2 structure.\n const normalized: ISchema = {\n title: schemaObj.title,\n type: schemaObj.type || (schemaObj.items ? \"array\" : \"object\"),\n layoutStrategy: schemaObj.layoutStrategy,\n uiLayout: schemaObj.uiLayout,\n additionalProperties: schemaObj.additionalProperties\n };\n\n let targetProperties = schemaObj.properties || {};\n\n if (schemaObj.additionalProperties === true && data) {\n const inferred = this.inferSchemaFromData(data);\n if (inferred.type === \"object\" && inferred.properties) {\n targetProperties = this.deepMergeProperties(inferred.properties, targetProperties);\n } else if (inferred.type === \"array\" && inferred.items && inferred.items.properties) {\n // Array schema merging could be added here if we want full support.\n }\n }\n\n if (normalized.type === \"object\") {\n normalized.properties = this.normalizeProperties(targetProperties);\n } else if (normalized.type === \"array\") {\n // Future expansion: array deep merge\n normalized.items = this.normalizePropertyMetadata(schemaObj.items || { type: \"object\", properties: {} }, \"items\");\n }\n\n return normalized;\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(\"[MetaUI SchemaNormalizer] Critical error normalizing schema object.\", msg);\n Logger.showErrorPopup(`Schema Normalization failed.\\n\\nDetails: ${msg}`);\n // Fallback to empty object to prevent hard crash downstream\n return { type: \"object\", properties: {} };\n }\n }\n\n private static deepMergeProperties(base: any, override: any): any {\n const merged = { ...base };\n for (const key of Object.keys(override)) {\n const overrideVal = override[key];\n const baseVal = merged[key];\n\n if (baseVal && typeof baseVal === \"object\" && !Array.isArray(baseVal) &&\n overrideVal && typeof overrideVal === \"object\" && !Array.isArray(overrideVal)) {\n merged[key] = this.deepMergeProperties(baseVal, overrideVal);\n } else {\n merged[key] = overrideVal;\n }\n }\n return merged;\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 || (prop.valueHelp || prop.enum ? \"select\" : undefined),\n visibleOn: prop.ui?.visibleOn,\n enabledOn: prop.ui?.enabledOn,\n format: prop.ui?.format,\n validators: prop.ui?.validators,\n formatter: prop.ui?.formatter,\n args: prop.ui?.args,\n rows: prop.ui?.rows,\n fullWidth: prop.ui?.fullWidth\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 enum: prop.enum\n };\n\n if (normalized.type === \"object\" && prop.properties) {\n normalized.properties = this.normalizeProperties(prop.properties);\n normalized.uiLayout = prop.uiLayout;\n } else if (normalized.type === \"array\" && prop.items) {\n normalized.items = this.normalizePropertyMetadata(prop.items, \"items\");\n normalized.uiLayout = prop.uiLayout;\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: {}, layoutStrategy: \"compact\", title: \"\" };\n\n if (!data || typeof data !== \"object\") {\n return schema;\n }\n\n if (Array.isArray(data)) {\n schema.type = \"array\";\n schema.layoutStrategy = \"table\";\n schema.items = {\n type: \"object\",\n layoutStrategy: \"compact\",\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 let type: FieldType = \"string\";\n let items: IPropertyMetadata | undefined;\n let nestedProps: Record<string, 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 } else if (typeof val === \"object\") {\n type = \"object\";\n nestedProps = this.inferPropertiesFromObject(val);\n }\n\n properties[key] = {\n type,\n items,\n properties: nestedProps,\n ui: {\n label: this.generateLabel(key),\n isKey: false,\n readOnly: false\n }\n };\n }\n\n return properties;\n }\n\n /**\n * Resolves a JSON Schema scope (e.g. '#/properties/header/properties/id')\n * against the ISchema, returning the PropertyMetadata and the UI5 binding path.\n */\n public static resolveScope(schema: ISchema, scope: string): { meta: IPropertyMetadata | undefined, bindingPath: string, propKey: string } {\n if (!scope || !scope.startsWith(\"#/properties/\")) {\n return { meta: undefined, bindingPath: scope || \"\", propKey: scope || \"\" };\n }\n \n const pathSegments = scope.replace(\"#/properties/\", \"\").split(\"/properties/\");\n let current: any = schema.properties;\n let meta: IPropertyMetadata | undefined;\n \n Logger.debug(\"[MetaUI SchemaNormalizer]\", `Resolving scope '${scope}' with segments: ${JSON.stringify(pathSegments)}`, \"SchemaNormalizer\");\n Logger.debug(\"[MetaUI SchemaNormalizer]\", `Root schema keys: ${Object.keys(schema.properties || {})}`, \"SchemaNormalizer\");\n\n for (let i = 0; i < pathSegments.length; i++) {\n const segment = pathSegments[i];\n if (!current) {\n Logger.debug(\"[MetaUI SchemaNormalizer]\", `current is undefined at segment '${segment}'`, \"SchemaNormalizer\");\n meta = undefined;\n break;\n }\n meta = current[segment];\n Logger.debug(\"[MetaUI SchemaNormalizer]\", `Segment '${segment}' resolved to meta: ${!!meta}. Available keys in current: ${Object.keys(current)}`, \"SchemaNormalizer\");\n if (i < pathSegments.length - 1) {\n current = meta?.properties;\n }\n }\n \n const bindingPath = pathSegments.join(\"/\");\n const propKey = scope.replace(\"#/properties/\", \"\"); // The original raw string for logging\n \n return {\n meta,\n bindingPath,\n propKey\n };\n }\n}\n"],"mappings":"2DAAA,MAMSA,EAAMC,EAAA,UAER,MAAMC,EAKT,gBAAcC,CAAUC,EAAiBC,GACrC,IAAIC,EAAYF,EAEhB,UAAWE,IAAc,SAAU,CAC/B,IACIA,EAAYC,KAAKC,MAAMF,EAC3B,CAAE,MAAOG,GACL,MAAMC,EAAOD,EAAYE,QACzBX,EAAOY,MAAM,2DAA4DF,GACzEV,EAAOa,eAAe,yDAAyDH,KAC/EJ,EAAY,IAChB,CACJ,CAEA,IAAKA,UAAoBA,IAAc,UAAYQ,MAAMC,QAAQT,GAAY,CACzE,OAAOU,KAAKC,oBAAoBZ,EACpC,CAEA,IAEI,MAAMa,EAAs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