@centrali-io/centrali-sdk 2.1.3 → 2.1.5
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/dist/index.js +11 -2
- package/index.ts +11 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -561,8 +561,17 @@ class CentraliSDK {
|
|
|
561
561
|
request(method, path, data, queryParams, config) {
|
|
562
562
|
return __awaiter(this, void 0, void 0, function* () {
|
|
563
563
|
const resp = yield this.axios.request(Object.assign({ method, url: path, data, params: queryParams }, config));
|
|
564
|
-
// 🔧 Normalize
|
|
565
|
-
|
|
564
|
+
// 🔧 Normalize responses to always return { data: T, ... } format
|
|
565
|
+
// Handle primitives (strings, numbers, etc.)
|
|
566
|
+
if (typeof resp.data !== 'object' || resp.data === null) {
|
|
567
|
+
return { data: resp.data };
|
|
568
|
+
}
|
|
569
|
+
// Handle arrays (which are objects but should be wrapped in data property)
|
|
570
|
+
if (Array.isArray(resp.data)) {
|
|
571
|
+
return { data: resp.data };
|
|
572
|
+
}
|
|
573
|
+
// Handle objects that don't have a data property (legacy endpoints)
|
|
574
|
+
if (!('data' in resp.data)) {
|
|
566
575
|
return { data: resp.data };
|
|
567
576
|
}
|
|
568
577
|
return resp.data;
|
package/index.ts
CHANGED
|
@@ -822,8 +822,17 @@ export class CentraliSDK {
|
|
|
822
822
|
...config,
|
|
823
823
|
});
|
|
824
824
|
|
|
825
|
-
// 🔧 Normalize
|
|
826
|
-
|
|
825
|
+
// 🔧 Normalize responses to always return { data: T, ... } format
|
|
826
|
+
// Handle primitives (strings, numbers, etc.)
|
|
827
|
+
if (typeof resp.data !== 'object' || resp.data === null) {
|
|
828
|
+
return { data: resp.data as T };
|
|
829
|
+
}
|
|
830
|
+
// Handle arrays (which are objects but should be wrapped in data property)
|
|
831
|
+
if (Array.isArray(resp.data)) {
|
|
832
|
+
return { data: resp.data as T };
|
|
833
|
+
}
|
|
834
|
+
// Handle objects that don't have a data property (legacy endpoints)
|
|
835
|
+
if (!('data' in resp.data)) {
|
|
827
836
|
return { data: resp.data as T };
|
|
828
837
|
}
|
|
829
838
|
return resp.data;
|