@karmaniverous/jsonmap 0.2.3 → 0.2.4
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.
|
@@ -114,13 +114,13 @@ class JsonMap {
|
|
|
114
114
|
} = this.#resolvePath(transformation.method, results);
|
|
115
115
|
|
|
116
116
|
// Resolves the parameter paths for the transformation
|
|
117
|
-
const params =
|
|
117
|
+
const params = (0, _lodash.default)(transformation.params).map(param => {
|
|
118
118
|
const {
|
|
119
119
|
obj: paramObj,
|
|
120
120
|
path: paramPath
|
|
121
121
|
} = this.#resolvePath(param, results);
|
|
122
122
|
return paramObj ? paramPath ? (0, _lodash3.default)(paramObj, paramPath) : paramObj : paramPath;
|
|
123
|
-
})
|
|
123
|
+
});
|
|
124
124
|
|
|
125
125
|
// Calls the specified method on the resolved object with the resolved parameters
|
|
126
126
|
const result = await (0, _lodash4.default)(methodObj, methodPath, ...params);
|
|
@@ -177,7 +177,9 @@ class JsonMap {
|
|
|
177
177
|
#resolvePath(path, results) {
|
|
178
178
|
// If the path is not a string, return it as is
|
|
179
179
|
if (!(0, _lodash9.default)(path)) {
|
|
180
|
-
return
|
|
180
|
+
return {
|
|
181
|
+
path
|
|
182
|
+
};
|
|
181
183
|
}
|
|
182
184
|
|
|
183
185
|
// Defines special patterns and their corresponding resolution functions
|
package/lib/JsonMap/JsonMap.js
CHANGED
|
@@ -117,19 +117,17 @@ class JsonMap {
|
|
|
117
117
|
);
|
|
118
118
|
|
|
119
119
|
// Resolves the parameter paths for the transformation
|
|
120
|
-
const params =
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
? paramPath
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
})
|
|
132
|
-
);
|
|
120
|
+
const params = castArray(transformation.params).map((param) => {
|
|
121
|
+
const { obj: paramObj, path: paramPath } = this.#resolvePath(
|
|
122
|
+
param,
|
|
123
|
+
results
|
|
124
|
+
);
|
|
125
|
+
return paramObj
|
|
126
|
+
? paramPath
|
|
127
|
+
? get(paramObj, paramPath)
|
|
128
|
+
: paramObj
|
|
129
|
+
: paramPath;
|
|
130
|
+
});
|
|
133
131
|
|
|
134
132
|
// Calls the specified method on the resolved object with the resolved parameters
|
|
135
133
|
const result = await invoke(methodObj, methodPath, ...params);
|
|
@@ -191,7 +189,7 @@ class JsonMap {
|
|
|
191
189
|
#resolvePath(path, results) {
|
|
192
190
|
// If the path is not a string, return it as is
|
|
193
191
|
if (!isString(path)) {
|
|
194
|
-
return path;
|
|
192
|
+
return { path };
|
|
195
193
|
}
|
|
196
194
|
|
|
197
195
|
// Defines special patterns and their corresponding resolution functions
|