@onlineapps/conn-orch-api-mapper 1.0.24 → 1.0.26
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 +2 -2
- package/src/ApiMapper.js +17 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/conn-orch-api-mapper",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"description": "API mapping connector for OA Drive - maps cookbook operations to HTTP endpoints",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"axios": "^1.4.0",
|
|
24
|
-
"@onlineapps/content-resolver": "1.1.
|
|
24
|
+
"@onlineapps/content-resolver": "1.1.14"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"jest": "^29.5.0",
|
package/src/ApiMapper.js
CHANGED
|
@@ -469,6 +469,23 @@ class ApiMapper {
|
|
|
469
469
|
const isDescriptor = value && typeof value === 'object' &&
|
|
470
470
|
(value._descriptor === true || value.ref || value.storage_ref);
|
|
471
471
|
|
|
472
|
+
// Some upstream steps may serialize arrays into array-like objects: { "0": ..., "1": ... }.
|
|
473
|
+
// If schema expects an array, normalize such objects back into arrays so item schemas are applied correctly.
|
|
474
|
+
// Without this, nested descriptors (e.g. attachments[].value) may lose their schema.type='file' and get resolved
|
|
475
|
+
// into strings, dropping filename/content_type metadata.
|
|
476
|
+
if (!Array.isArray(value) && value && typeof value === 'object' && schema?.type === 'array') {
|
|
477
|
+
const keys = Object.keys(value);
|
|
478
|
+
const isNumericKeyed =
|
|
479
|
+
keys.length > 0 &&
|
|
480
|
+
keys.every((k) => /^[0-9]+$/.test(k));
|
|
481
|
+
if (isNumericKeyed) {
|
|
482
|
+
const asArray = keys
|
|
483
|
+
.sort((a, b) => Number(a) - Number(b))
|
|
484
|
+
.map((k) => value[k]);
|
|
485
|
+
return resolveValue(asArray, schema, keyPath);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
472
489
|
if (isDescriptor) {
|
|
473
490
|
const fieldType = schema?.type;
|
|
474
491
|
const storageRef = value.ref || value.storage_ref || value;
|