@bolttech/form-engine-core 0.0.1-beta.42 → 0.0.1-beta.43
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/index.esm.js +21 -35
- package/package.json +1 -1
- package/src/helpers/helpers.d.ts +1 -1
package/index.esm.js
CHANGED
|
@@ -140,45 +140,31 @@ function extractFieldKeys(expression) {
|
|
|
140
140
|
* // expressions will contain an array of objects with origin expressions, field keys, and destination paths.
|
|
141
141
|
* ```
|
|
142
142
|
*/
|
|
143
|
-
function traverseObject(
|
|
143
|
+
function traverseObject(element, path) {
|
|
144
144
|
const result = [];
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (String(item).includes('${')) {
|
|
154
|
-
// const extractedPath = item.replace(/\$|{|}/g, '').split('.');
|
|
155
|
-
const extractedOriginPath = `${path ? `${path}.` : ``}${key}`.split('.');
|
|
156
|
-
result.push(Object.assign(Object.assign({
|
|
157
|
-
originExpression: item
|
|
158
|
-
}, extractFieldKeys(item)), {
|
|
159
|
-
destinationKey: extractedOriginPath[0],
|
|
160
|
-
destinationProperty: extractedOriginPath[1],
|
|
161
|
-
destinationPath: extractedOriginPath.slice(2)
|
|
162
|
-
}));
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
} else if (typeof value === 'object') {
|
|
145
|
+
if (Array.isArray(element)) {
|
|
146
|
+
element.forEach((item, index) => {
|
|
147
|
+
result.push(...traverseObject(item, `${path ? `${path}.` : ``}${index}`));
|
|
148
|
+
});
|
|
149
|
+
} else if (typeof element === 'object') {
|
|
150
|
+
for (const key in element) {
|
|
151
|
+
if (Object.prototype.hasOwnProperty.call(element, key)) {
|
|
152
|
+
const value = element[key];
|
|
167
153
|
result.push(...traverseObject(value, `${path ? `${path}.` : ``}${key}`));
|
|
168
|
-
} else if (typeof value === 'string') {
|
|
169
|
-
if (value.includes('${')) {
|
|
170
|
-
// const extractedPath = value.replace(/\$|{|}/g, '').split('.');
|
|
171
|
-
const destinationPath = `${path ? `${path}.` : ``}${key}`.split('.');
|
|
172
|
-
result.push(Object.assign(Object.assign({
|
|
173
|
-
originExpression: value
|
|
174
|
-
}, extractFieldKeys(value)), {
|
|
175
|
-
destinationKey: destinationPath[0],
|
|
176
|
-
destinationProperty: destinationPath[1],
|
|
177
|
-
destinationPath: destinationPath.slice(2)
|
|
178
|
-
}));
|
|
179
|
-
}
|
|
180
154
|
}
|
|
181
155
|
}
|
|
156
|
+
} else if (typeof element === 'string') {
|
|
157
|
+
if (element.includes('${')) {
|
|
158
|
+
// const extractedPath = value.replace(/\$|{|}/g, '').split('.');
|
|
159
|
+
const destinationPath = (path ? path : '').split('.');
|
|
160
|
+
result.push(Object.assign(Object.assign({
|
|
161
|
+
originExpression: element
|
|
162
|
+
}, extractFieldKeys(element)), {
|
|
163
|
+
destinationKey: destinationPath[0],
|
|
164
|
+
destinationProperty: destinationPath[1],
|
|
165
|
+
destinationPath: destinationPath.slice(2)
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
182
168
|
}
|
|
183
169
|
return result;
|
|
184
170
|
}
|
package/package.json
CHANGED
package/src/helpers/helpers.d.ts
CHANGED
|
@@ -60,5 +60,5 @@ declare function extractFieldKeys(expression: string): {
|
|
|
60
60
|
* // expressions will contain an array of objects with origin expressions, field keys, and destination paths.
|
|
61
61
|
* ```
|
|
62
62
|
*/
|
|
63
|
-
declare function traverseObject(
|
|
63
|
+
declare function traverseObject(element: any, path?: string): TSubscribedTemplates[];
|
|
64
64
|
export { makeRequest, traverseObject, extractFieldKeys };
|