nayota-show-sdk 1.3.62 → 1.3.63

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.
@@ -0,0 +1,29 @@
1
+ import { buildLegacyListResponse } from './utils/iot-adapter-helpers'
2
+
3
+ describe('iot adapter helpers', () => {
4
+ test('wraps list responses as code + data.total/data.rows', () => {
5
+ const result = buildLegacyListResponse({
6
+ total: 1,
7
+ items: [
8
+ {
9
+ id: 'type-1',
10
+ name: '风速仪'
11
+ }
12
+ ]
13
+ })
14
+
15
+ expect(result).toEqual({
16
+ code: 0,
17
+ data: {
18
+ total: 1,
19
+ rows: [
20
+ {
21
+ id: 'type-1',
22
+ _id: 'type-1',
23
+ name: '风速仪'
24
+ }
25
+ ]
26
+ }
27
+ })
28
+ })
29
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nayota-show-sdk",
3
- "version": "1.3.62",
3
+ "version": "1.3.63",
4
4
  "description": "nayota-show-server rest-api",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -209,8 +209,10 @@ export function buildLegacyListResponse(response, mapItem) {
209
209
 
210
210
  return {
211
211
  code: 0,
212
- total: Number(payload?.total ?? items.length ?? 0),
213
- rows: items.map(item => (mapItem ? mapItem(item) : withLegacyId(item)))
212
+ data: {
213
+ total: Number(payload?.total ?? items.length ?? 0),
214
+ rows: items.map(item => (mapItem ? mapItem(item) : withLegacyId(item)))
215
+ }
214
216
  }
215
217
  }
216
218
 
@@ -505,8 +505,10 @@ export const iotModuleSpecs = {
505
505
  const payload = response && response.data && response.status ? response.data : response
506
506
  return {
507
507
  code: 0,
508
- total: Number(payload?.total || 0),
509
- rows: Array.isArray(payload?.rows) ? payload.rows.map(item => withLegacyId(item)) : []
508
+ data: {
509
+ total: Number(payload?.total || 0),
510
+ rows: Array.isArray(payload?.rows) ? payload.rows.map(item => withLegacyId(item)) : []
511
+ }
510
512
  }
511
513
  }
512
514
  }