nayota-show-sdk 1.3.69 → 1.3.70

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.69",
3
+ "version": "1.3.70",
4
4
  "description": "nayota-show-server rest-api",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -160,6 +160,13 @@ function normalizeHierarchyFloorPlan(data = {}) {
160
160
  }
161
161
 
162
162
  function mapDepartsToIotBody(data = {}) {
163
+ const hasParentId = Object.prototype.hasOwnProperty.call(data, 'parentId')
164
+ const hasFather = Object.prototype.hasOwnProperty.call(data, 'father')
165
+ const parentId = hasParentId
166
+ ? data.parentId
167
+ : hasFather
168
+ ? resolveLegacyReference(data.father)
169
+ : undefined
163
170
  const metadata = mergeMetadata(data.metadata, {
164
171
  mapCenter: data.mapCenter,
165
172
  latlng: data.latlng,
@@ -183,7 +190,7 @@ function mapDepartsToIotBody(data = {}) {
183
190
  'departNo'
184
191
  ]),
185
192
  code: data.code || data.departNo || undefined,
186
- parentId: data.parentId != null ? data.parentId : resolveLegacyReference(data.father),
193
+ parentId,
187
194
  sortOrder: data.sortOrder != null ? data.sortOrder : data.sort,
188
195
  isActive: data.isActive != null ? data.isActive : data.status,
189
196
  floorPlan: normalizeHierarchyFloorPlan(data),
@@ -337,7 +344,7 @@ function normalizeLegacyUiRelation(relation = {}, fallbackType = 'ba_card') {
337
344
  })
338
345
  }
339
346
 
340
- function resolveDigitalTwinTypeUiRelation(data = {}) {
347
+ function resolveDigitalTwinTypeUiRelation(data = {}) {
341
348
  if (hasOwn(data, 'uiId')) {
342
349
  return data.uiId == null ? null : normalizeLegacyUiRelation({ uiId: data.uiId, ui: data.ui })
343
350
  }
@@ -93,3 +93,36 @@ describe('iotModuleSpecs deviceClass UI compatibility', () => {
93
93
  ])
94
94
  })
95
95
  })
96
+
97
+ describe('iotModuleSpecs departs hierarchy compatibility', () => {
98
+ const departs = iotModuleSpecs.departs.operations
99
+
100
+ test('does not send parentId for partial relationInfo updates', () => {
101
+ const request = departs.updateOne.toRequest({
102
+ _id: 'e245a3f6-d2c7-4ce1-9e02-ba9bbb347ed7',
103
+ relationInfo: {
104
+ image: {
105
+ imagePath: 'upload/2026/4/25/upload.svg'
106
+ }
107
+ }
108
+ })
109
+
110
+ expect(request.url).toBe('/hierarchies/e245a3f6-d2c7-4ce1-9e02-ba9bbb347ed7')
111
+ expect(request.method).toBe('patch')
112
+ expect(request.data.parentId).toBeUndefined()
113
+ expect(request.data.relationInfo).toEqual({
114
+ image: {
115
+ imagePath: 'upload/2026/4/25/upload.svg'
116
+ }
117
+ })
118
+ })
119
+
120
+ test('keeps explicit legacy father null as root move', () => {
121
+ const request = departs.updateOne.toRequest({
122
+ _id: 'e245a3f6-d2c7-4ce1-9e02-ba9bbb347ed7',
123
+ father: null
124
+ })
125
+
126
+ expect(request.data.parentId).toBeNull()
127
+ })
128
+ })