@onlineapps/conn-orch-api-mapper 1.0.23 → 1.0.25
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 +1 -1
- package/src/ApiMapper.js +17 -7
package/package.json
CHANGED
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;
|
|
@@ -730,13 +747,6 @@ class ApiMapper {
|
|
|
730
747
|
request.headers['account-id'] = String(accountId);
|
|
731
748
|
}
|
|
732
749
|
|
|
733
|
-
// Tester mode: for workflows initiated from "frontend tester", we explicitly disable side-effects
|
|
734
|
-
// in services that support it (e.g. emailer). This is controlled via cookbook._system.labels (set by Gateway).
|
|
735
|
-
// NOTE: This is NOT validation; validation uses per-operation headers in conn-orch-validator.
|
|
736
|
-
if (sys && Array.isArray(sys.labels) && sys.labels.includes('tester')) {
|
|
737
|
-
request.headers['x-tester-request'] = 'true';
|
|
738
|
-
}
|
|
739
|
-
|
|
740
750
|
return request;
|
|
741
751
|
}
|
|
742
752
|
|