@centrali-io/centrali-sdk 2.1.2 → 2.1.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.
Files changed (3) hide show
  1. package/dist/index.js +11 -2
  2. package/index.ts +11 -2
  3. 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 non-object responses
565
- if (typeof resp.data !== 'object') {
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 non-object responses
826
- if (typeof resp.data !== 'object') {
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centrali-io/centrali-sdk",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "Centrali Node SDK",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",