nayota-show-sdk 1.3.82 → 1.3.84
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
|
@@ -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',
|
|
@@ -102,6 +109,45 @@ function resolveOptionalLegacyReference(data, primaryKey, legacyKey) {
|
|
|
102
109
|
return undefined
|
|
103
110
|
}
|
|
104
111
|
|
|
112
|
+
function mapLegacySelectFields(select, fieldMap = {}) {
|
|
113
|
+
if (typeof select !== 'string') {
|
|
114
|
+
return select
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const fields = select
|
|
118
|
+
.split(/[\s,]+/)
|
|
119
|
+
.map(field => field.trim())
|
|
120
|
+
.filter(Boolean)
|
|
121
|
+
|
|
122
|
+
if (!fields.length) {
|
|
123
|
+
return select
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return [...new Set(fields.map(field => fieldMap[field] || field))].join(' ')
|
|
127
|
+
}
|
|
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
|
+
|
|
105
151
|
function mapAreaToIotBody(data = {}, options = {}) {
|
|
106
152
|
const isPartial = options.partial === true
|
|
107
153
|
const metadata = mergeMetadata(data.metadata, {
|
|
@@ -126,7 +172,7 @@ function mapAreaToIotBody(data = {}, options = {}) {
|
|
|
126
172
|
hierarchyId: data.hierarchyId || data.depart,
|
|
127
173
|
isVisible: data.isVisible != null ? data.isVisible : data.visible,
|
|
128
174
|
area: data.area != null ? data.area : data.areaSize,
|
|
129
|
-
areaClassId:
|
|
175
|
+
areaClassId: resolveAreaClassIdForWrite(data, options),
|
|
130
176
|
targetHierarchyId: resolveOptionalLegacyReference(data, 'targetHierarchyId', 'targetDepartId'),
|
|
131
177
|
centerPoint: normalizeAreaCenterPoint(data),
|
|
132
178
|
floorPlan: normalizeAreaFloorPlan(data),
|
|
@@ -160,8 +206,11 @@ function mapIotAreaToLegacy(item = {}) {
|
|
|
160
206
|
|
|
161
207
|
function mapAreaClassToIotQuery(query = {}) {
|
|
162
208
|
return removeUndefinedFields({
|
|
163
|
-
...omitKeys(query, ['_id', 'sort']),
|
|
209
|
+
...omitKeys(query, ['_id', 'sort', 'select', 'fields']),
|
|
164
210
|
ids: Array.isArray(query.ids) ? query.ids.join(',') : (query.ids || query._id || undefined),
|
|
211
|
+
fields: mapLegacyFieldsParam(query.fields || query.select, {
|
|
212
|
+
_id: 'id'
|
|
213
|
+
}),
|
|
165
214
|
...parseLegacySort(query.sort)
|
|
166
215
|
})
|
|
167
216
|
}
|
|
@@ -674,9 +723,13 @@ function getDigitalTwinTypeUiId(data = {}) {
|
|
|
674
723
|
|
|
675
724
|
function mapDeviceClassToIotQuery(query = {}) {
|
|
676
725
|
return removeUndefinedFields({
|
|
677
|
-
...omitKeys(query, ['_id', 'code', 'sort']),
|
|
726
|
+
...omitKeys(query, ['_id', 'code', 'sort', 'select', 'fields']),
|
|
678
727
|
id: query.id || query._id,
|
|
679
728
|
typeCode: query.typeCode || query.code,
|
|
729
|
+
fields: mapLegacyFieldsParam(query.fields || query.select, {
|
|
730
|
+
_id: 'id',
|
|
731
|
+
code: 'typeCode'
|
|
732
|
+
}),
|
|
680
733
|
...parseLegacySort(query.sort, {
|
|
681
734
|
code: 'typeCode'
|
|
682
735
|
})
|
|
@@ -202,6 +202,7 @@ describe('iotModuleSpecs departs hierarchy compatibility', () => {
|
|
|
202
202
|
|
|
203
203
|
describe('iotModuleSpecs area space compatibility', () => {
|
|
204
204
|
const area = iotModuleSpecs.area.operations
|
|
205
|
+
const areaClass = iotModuleSpecs.areaClass.operations
|
|
205
206
|
|
|
206
207
|
test('maps legacy centerCoordinate to space centerPoint when creating areas', () => {
|
|
207
208
|
const request = area.create.toRequest({
|
|
@@ -253,6 +254,17 @@ describe('iotModuleSpecs area space compatibility', () => {
|
|
|
253
254
|
expect(request.data.spaceType).toBeUndefined()
|
|
254
255
|
})
|
|
255
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
|
+
|
|
256
268
|
test('keeps explicit areaClass clear on area updates', () => {
|
|
257
269
|
const request = area.updateOne.toRequest({
|
|
258
270
|
_id: '4f168184-9ef0-4068-b494-2ee861db0c08',
|
|
@@ -261,6 +273,34 @@ describe('iotModuleSpecs area space compatibility', () => {
|
|
|
261
273
|
|
|
262
274
|
expect(request.data.areaClassId).toBeNull()
|
|
263
275
|
})
|
|
276
|
+
|
|
277
|
+
test('maps legacy areaClass select _id to v2 id and returns legacy _id', () => {
|
|
278
|
+
const request = areaClass.list.toRequest({
|
|
279
|
+
select: '_id name'
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
expect(request.params.fields).toBe('id,name')
|
|
283
|
+
expect(request.params.select).toBeUndefined()
|
|
284
|
+
|
|
285
|
+
const response = areaClass.list.fromResponse({
|
|
286
|
+
code: 0,
|
|
287
|
+
data: {
|
|
288
|
+
total: 1,
|
|
289
|
+
items: [
|
|
290
|
+
{
|
|
291
|
+
id: 'space-class-1',
|
|
292
|
+
name: '会议室'
|
|
293
|
+
}
|
|
294
|
+
]
|
|
295
|
+
}
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
expect(response.data.rows[0]).toMatchObject({
|
|
299
|
+
_id: 'space-class-1',
|
|
300
|
+
id: 'space-class-1',
|
|
301
|
+
name: '会议室'
|
|
302
|
+
})
|
|
303
|
+
})
|
|
264
304
|
})
|
|
265
305
|
|
|
266
306
|
describe('iotModuleSpecs devices write compatibility', () => {
|