nayota-show-sdk 1.3.83 → 1.3.85

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.83",
3
+ "version": "1.3.85",
4
4
  "description": "nayota-show-server rest-api",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -74,11 +74,18 @@ function normalizeAreaCenterCoordinate(item = {}) {
74
74
 
75
75
  function mapAreaToIotQuery(query = {}) {
76
76
  const next = removeUndefinedFields({
77
- ...omitKeys(query, ['_id', 'depart', 'visible', 'areaClass', 'sort']),
77
+ ...omitKeys(query, ['_id', 'depart', 'visible', 'areaClass', 'sort', 'select', 'fields']),
78
78
  ids: Array.isArray(query.ids) ? query.ids.join(',') : (query.ids || query._id || undefined),
79
79
  hierarchyId: query.hierarchyId || query.depart,
80
80
  isVisible: query.isVisible != null ? query.isVisible : query.visible,
81
81
  areaClassId: query.areaClassId || query.areaClass,
82
+ fields: mapLegacyFieldsParam(query.fields || query.select, {
83
+ _id: 'id',
84
+ depart: 'hierarchyId',
85
+ visible: 'isVisible',
86
+ areaSize: 'area',
87
+ areaClass: 'areaClassId'
88
+ }),
82
89
  ...parseLegacySort(query.sort, {
83
90
  areaSize: 'area',
84
91
  visible: 'isVisible',
@@ -119,6 +126,28 @@ function mapLegacySelectFields(select, fieldMap = {}) {
119
126
  return [...new Set(fields.map(field => fieldMap[field] || field))].join(' ')
120
127
  }
121
128
 
129
+ function mapLegacyFieldsParam(select, fieldMap = {}) {
130
+ const fields = mapLegacySelectFields(select, fieldMap)
131
+ return typeof fields === 'string' ? fields.replace(/\s+/g, ',') : fields
132
+ }
133
+
134
+ function resolveAreaClassIdForWrite(data = {}, options = {}) {
135
+ const hasPrimary = hasOwn(data, 'areaClassId')
136
+ const hasLegacy = hasOwn(data, 'areaClass')
137
+
138
+ if (!hasPrimary && !hasLegacy) {
139
+ return undefined
140
+ }
141
+
142
+ const value = hasPrimary ? data.areaClassId : data.areaClass
143
+
144
+ if (options.partial === true && hasOwn(data, 'statisticsJson') && (value == null || value === '')) {
145
+ return undefined
146
+ }
147
+
148
+ return resolveLegacyReference(value)
149
+ }
150
+
122
151
  function mapAreaToIotBody(data = {}, options = {}) {
123
152
  const isPartial = options.partial === true
124
153
  const metadata = mergeMetadata(data.metadata, {
@@ -143,7 +172,7 @@ function mapAreaToIotBody(data = {}, options = {}) {
143
172
  hierarchyId: data.hierarchyId || data.depart,
144
173
  isVisible: data.isVisible != null ? data.isVisible : data.visible,
145
174
  area: data.area != null ? data.area : data.areaSize,
146
- areaClassId: resolveOptionalLegacyReference(data, 'areaClassId', 'areaClass'),
175
+ areaClassId: resolveAreaClassIdForWrite(data, options),
147
176
  targetHierarchyId: resolveOptionalLegacyReference(data, 'targetHierarchyId', 'targetDepartId'),
148
177
  centerPoint: normalizeAreaCenterPoint(data),
149
178
  floorPlan: normalizeAreaFloorPlan(data),
@@ -177,9 +206,9 @@ function mapIotAreaToLegacy(item = {}) {
177
206
 
178
207
  function mapAreaClassToIotQuery(query = {}) {
179
208
  return removeUndefinedFields({
180
- ...omitKeys(query, ['_id', 'sort']),
209
+ ...omitKeys(query, ['_id', 'sort', 'select', 'fields']),
181
210
  ids: Array.isArray(query.ids) ? query.ids.join(',') : (query.ids || query._id || undefined),
182
- select: mapLegacySelectFields(query.select, {
211
+ fields: mapLegacyFieldsParam(query.fields || query.select, {
183
212
  _id: 'id'
184
213
  }),
185
214
  ...parseLegacySort(query.sort)
@@ -694,10 +723,10 @@ function getDigitalTwinTypeUiId(data = {}) {
694
723
 
695
724
  function mapDeviceClassToIotQuery(query = {}) {
696
725
  return removeUndefinedFields({
697
- ...omitKeys(query, ['_id', 'code', 'sort']),
726
+ ...omitKeys(query, ['_id', 'code', 'sort', 'select', 'fields']),
698
727
  id: query.id || query._id,
699
728
  typeCode: query.typeCode || query.code,
700
- select: mapLegacySelectFields(query.select, {
729
+ fields: mapLegacyFieldsParam(query.fields || query.select, {
701
730
  _id: 'id',
702
731
  code: 'typeCode'
703
732
  }),
@@ -254,6 +254,17 @@ describe('iotModuleSpecs area space compatibility', () => {
254
254
  expect(request.data.spaceType).toBeUndefined()
255
255
  })
256
256
 
257
+ test('does not clear areaClassId when vuetify emits an empty type during statistics sync', () => {
258
+ const request = area.updateOne.toRequest({
259
+ _id: '4f168184-9ef0-4068-b494-2ee861db0c08',
260
+ areaClass: null,
261
+ statisticsJson: []
262
+ })
263
+
264
+ expect(request.data.areaClassId).toBeUndefined()
265
+ expect(request.data.statisticsJson).toEqual([])
266
+ })
267
+
257
268
  test('keeps explicit areaClass clear on area updates', () => {
258
269
  const request = area.updateOne.toRequest({
259
270
  _id: '4f168184-9ef0-4068-b494-2ee861db0c08',
@@ -268,7 +279,8 @@ describe('iotModuleSpecs area space compatibility', () => {
268
279
  select: '_id name'
269
280
  })
270
281
 
271
- expect(request.params.select).toBe('id name')
282
+ expect(request.params.fields).toBe('id,name')
283
+ expect(request.params.select).toBeUndefined()
272
284
 
273
285
  const response = areaClass.list.fromResponse({
274
286
  code: 0,