@integry/sdk 4.7.38 → 4.7.39
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
CHANGED
|
@@ -53,35 +53,48 @@ export function JSONToActivityOutputData(
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export function JSONToDynamicFieldData(
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
56
|
obj: any,
|
|
58
57
|
parentKey = '',
|
|
59
58
|
sourceStepKey = '',
|
|
60
|
-
):
|
|
61
|
-
let result:
|
|
59
|
+
): Record<string, string[]> {
|
|
60
|
+
let result: Record<string, string[]> = {};
|
|
61
|
+
|
|
62
62
|
Object.keys(obj).forEach((key) => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
let currentKey = sourceStepKey ? `${sourceStepKey}` : '';
|
|
64
|
+
currentKey += parentKey ? `${parentKey}.${key}` : key;
|
|
65
|
+
|
|
66
|
+
const value = obj[key];
|
|
67
|
+
|
|
68
|
+
if (value === null || value === undefined) {
|
|
69
|
+
result[currentKey] = [''];
|
|
70
|
+
} else if (typeof value === 'object') {
|
|
71
|
+
if (Array.isArray(value)) {
|
|
72
|
+
// Handle array elements individually
|
|
73
|
+
value.forEach((item, index) => {
|
|
74
|
+
const indexedKey = `${currentKey}.${index}`;
|
|
75
|
+
if (typeof item === 'object' && item !== null) {
|
|
76
|
+
// Recursively flatten array item
|
|
77
|
+
const flattened = JSONToDynamicFieldData(item, indexedKey);
|
|
78
|
+
result = { ...result, ...flattened };
|
|
79
|
+
} else {
|
|
80
|
+
result[indexedKey] = [item];
|
|
77
81
|
}
|
|
82
|
+
});
|
|
83
|
+
} else {
|
|
84
|
+
// Regular nested object
|
|
85
|
+
try {
|
|
86
|
+
result[currentKey] = [JSON.stringify(value)];
|
|
87
|
+
} catch {
|
|
88
|
+
result[currentKey] = [''];
|
|
78
89
|
}
|
|
90
|
+
const flattened = JSONToDynamicFieldData(value, currentKey);
|
|
79
91
|
result = { ...result, ...flattened };
|
|
80
|
-
} else if (result) {
|
|
81
|
-
result[currentKey] = [obj[key]];
|
|
82
92
|
}
|
|
93
|
+
} else {
|
|
94
|
+
result[currentKey] = [value];
|
|
83
95
|
}
|
|
84
96
|
});
|
|
97
|
+
|
|
85
98
|
return result;
|
|
86
99
|
}
|
|
87
100
|
|