@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integry/sdk",
3
- "version": "4.7.38",
3
+ "version": "4.7.39",
4
4
  "description": "Integry SDK",
5
5
  "main": "dist/umd/index.umd.js",
6
6
  "module": "dist/esm/index.csm.js",
@@ -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
- ): StoreType['dynamicFieldData'] {
61
- let result: StoreType['dynamicFieldData'] = {};
59
+ ): Record<string, string[]> {
60
+ let result: Record<string, string[]> = {};
61
+
62
62
  Object.keys(obj).forEach((key) => {
63
- if (key in obj) {
64
- let currentKey = sourceStepKey ? `${sourceStepKey}` : '';
65
- currentKey += parentKey ? `${parentKey}.${key}` : key;
66
- if (
67
- obj[key] &&
68
- typeof obj[key] === 'object' &&
69
- !Array.isArray(obj[key])
70
- ) {
71
- const flattened = JSONToDynamicFieldData(obj[key], currentKey);
72
- if (result) {
73
- try {
74
- result[currentKey] = [JSON.stringify(obj[key])];
75
- } catch (e) {
76
- result[currentKey] = [''];
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