nayota-show-sdk 1.3.111 → 1.3.113

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nayota-show-sdk",
3
- "version": "1.3.111",
3
+ "version": "1.3.113",
4
4
  "description": "nayota-show-server rest-api",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1111,9 +1111,25 @@ function createDeviceClassOperations() {
1111
1111
  },
1112
1112
  fromResponse(response) {
1113
1113
  const payload = response && response.data && response.status ? response.data : response
1114
- return payload && payload.code !== undefined
1115
- ? payload
1116
- : { code: 0, data: payload?.data !== undefined ? payload.data : payload }
1114
+ const data = payload?.data?.data !== undefined
1115
+ ? payload.data.data
1116
+ : payload?.data !== undefined
1117
+ ? payload.data
1118
+ : payload
1119
+ const normalizedData = {
1120
+ ...(data && typeof data === 'object' && !Array.isArray(data) ? data : {}),
1121
+ items: Array.isArray(data?.items)
1122
+ ? data.items.map(item => ({
1123
+ ...item,
1124
+ deviceClassName: item?.deviceClassName || item?.deviceName || item?.name || '未分类设备'
1125
+ }))
1126
+ : []
1127
+ }
1128
+
1129
+ return {
1130
+ code: Number(payload?.code ?? 0),
1131
+ data: normalizedData
1132
+ }
1117
1133
  }
1118
1134
  }
1119
1135
 
@@ -62,11 +62,12 @@ describe('iotModuleSpecs deviceClass UI compatibility', () => {
62
62
 
63
63
  expect(
64
64
  deviceClass.onlineRate.fromResponse({
65
- code: 0,
65
+ success: true,
66
66
  data: {
67
67
  year: 2026,
68
68
  month: 7,
69
- summary: { onlineRate: 1 }
69
+ summary: { onlineRate: 1 },
70
+ items: [{ deviceName: '摄像头', summary: { onlineRatePercent: 99 } }]
70
71
  }
71
72
  })
72
73
  ).toEqual({
@@ -74,7 +75,8 @@ describe('iotModuleSpecs deviceClass UI compatibility', () => {
74
75
  data: {
75
76
  year: 2026,
76
77
  month: 7,
77
- summary: { onlineRate: 1 }
78
+ summary: { onlineRate: 1 },
79
+ items: [{ deviceName: '摄像头', deviceClassName: '摄像头', summary: { onlineRatePercent: 99 } }]
78
80
  }
79
81
  })
80
82
  })