nayota-show-sdk 1.3.78 → 1.3.79
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/api/upload.js +2 -78
- package/package.json +1 -1
- package/utils/iot-module-specs.js +26 -1
- package/utils/iot-module-specs.test.js +6 -0
- package/AI_EXECUTABLE_TASKS.md +0 -558
- package/API_LEVEL_V2_IMPLEMENTATION_CHECKLIST.md +0 -886
- package/SDK_MIGRATION_PLAN.md +0 -464
- package/api/upload.test.js +0 -81
package/api/upload.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { requestShow, requestForm, requestIot } from '../utils'
|
|
1
|
+
import { requestShow, requestForm } from '../utils'
|
|
3
2
|
/**
|
|
4
3
|
* @file 文件管理api
|
|
5
4
|
* @module 文件管理接口
|
|
@@ -26,67 +25,6 @@ import { requestShow, requestForm, requestIot } from '../utils'
|
|
|
26
25
|
* }
|
|
27
26
|
*/
|
|
28
27
|
|
|
29
|
-
function getUploadPayload(response) {
|
|
30
|
-
if (response && typeof response === 'object') {
|
|
31
|
-
if (response.code === 0 && response.data) {
|
|
32
|
-
return response.data
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (typeof response.status === 'number' && response.data) {
|
|
36
|
-
return response.data
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return response
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function getUrlOrigin(baseUrl) {
|
|
44
|
-
if (!baseUrl) {
|
|
45
|
-
return typeof window !== 'undefined' && window.location ? window.location.origin : ''
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (/^https?:\/\//i.test(baseUrl)) {
|
|
49
|
-
try {
|
|
50
|
-
return new URL(baseUrl).origin
|
|
51
|
-
} catch (error) {
|
|
52
|
-
return ''
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return typeof window !== 'undefined' && window.location ? window.location.origin : ''
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function toAbsoluteConfigFileUrl(fileUrl) {
|
|
60
|
-
if (!fileUrl || /^https?:\/\//i.test(fileUrl)) {
|
|
61
|
-
return fileUrl
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const origin = getUrlOrigin(urlcfg.getIotUrl())
|
|
65
|
-
if (!origin) {
|
|
66
|
-
return fileUrl
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return `${origin}${fileUrl.startsWith('/') ? '' : '/'}${fileUrl}`
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function normalizeV2UploadResponse(response) {
|
|
73
|
-
const payload = getUploadPayload(response) || {}
|
|
74
|
-
const id = payload.id || payload._id || payload.filename
|
|
75
|
-
const path = toAbsoluteConfigFileUrl(payload.path || payload.url)
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
code: 0,
|
|
79
|
-
success: true,
|
|
80
|
-
data: {
|
|
81
|
-
...payload,
|
|
82
|
-
_id: id,
|
|
83
|
-
id,
|
|
84
|
-
name: payload.name || payload.originalname || payload.filename,
|
|
85
|
-
path
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
28
|
/**
|
|
91
29
|
* 获取文件列表
|
|
92
30
|
* @param {Object} query - 请求对象
|
|
@@ -112,21 +50,6 @@ export function list(query) {
|
|
|
112
50
|
* @returns {string} data - 新增成功的数据,见表结构upload定义
|
|
113
51
|
*/
|
|
114
52
|
export function upload(data) {
|
|
115
|
-
if (urlcfg.isV2()) {
|
|
116
|
-
if (!urlcfg.getIotUrl()) {
|
|
117
|
-
throw new Error('[nayota-show-sdk][v2] iotServer is required for upload module.')
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return requestIot({
|
|
121
|
-
url: '/files/upload',
|
|
122
|
-
method: 'post',
|
|
123
|
-
data,
|
|
124
|
-
headers: {
|
|
125
|
-
'Content-Type': 'multipart/form-data'
|
|
126
|
-
}
|
|
127
|
-
}).then(normalizeV2UploadResponse)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
53
|
return requestForm({
|
|
131
54
|
url: '/uploads',
|
|
132
55
|
method: 'post',
|
|
@@ -194,3 +117,4 @@ export default {
|
|
|
194
117
|
deleteMany,
|
|
195
118
|
getOne
|
|
196
119
|
}
|
|
120
|
+
|
package/package.json
CHANGED
|
@@ -497,6 +497,28 @@ function normalizeLegacyStatus(status, props = []) {
|
|
|
497
497
|
function normalizeLegacyEasyListProp(source = {}, row = {}) {
|
|
498
498
|
const prop = withLegacyId(source.prop || {})
|
|
499
499
|
const propId = source.propId || source.devicePropertyId || prop._id || source._id || source.id
|
|
500
|
+
const thresholdRules = prop.thresholdRules !== undefined
|
|
501
|
+
? prop.thresholdRules
|
|
502
|
+
: source.thresholdRules !== undefined
|
|
503
|
+
? source.thresholdRules
|
|
504
|
+
: getNestedValue(prop, 'typeProperty.thresholdRules') !== undefined
|
|
505
|
+
? getNestedValue(prop, 'typeProperty.thresholdRules')
|
|
506
|
+
: getNestedValue(source, 'typeProperty.thresholdRules') !== undefined
|
|
507
|
+
? getNestedValue(source, 'typeProperty.thresholdRules')
|
|
508
|
+
: getNestedValue(prop, 'metadata.thresholdRules') !== undefined
|
|
509
|
+
? getNestedValue(prop, 'metadata.thresholdRules')
|
|
510
|
+
: getNestedValue(source, 'metadata.thresholdRules')
|
|
511
|
+
const isThresholdEnabled = prop.isThresholdEnabled !== undefined
|
|
512
|
+
? prop.isThresholdEnabled
|
|
513
|
+
: source.isThresholdEnabled !== undefined
|
|
514
|
+
? source.isThresholdEnabled
|
|
515
|
+
: getNestedValue(prop, 'typeProperty.isThresholdEnabled') !== undefined
|
|
516
|
+
? getNestedValue(prop, 'typeProperty.isThresholdEnabled')
|
|
517
|
+
: getNestedValue(source, 'typeProperty.isThresholdEnabled') !== undefined
|
|
518
|
+
? getNestedValue(source, 'typeProperty.isThresholdEnabled')
|
|
519
|
+
: getNestedValue(prop, 'metadata.isThresholdEnabled') !== undefined
|
|
520
|
+
? getNestedValue(prop, 'metadata.isThresholdEnabled')
|
|
521
|
+
: getNestedValue(source, 'metadata.isThresholdEnabled')
|
|
500
522
|
const value = prop.value !== undefined
|
|
501
523
|
? prop.value
|
|
502
524
|
: source.value !== undefined
|
|
@@ -528,7 +550,8 @@ function normalizeLegacyEasyListProp(source = {}, row = {}) {
|
|
|
528
550
|
company: prop.company || source.company,
|
|
529
551
|
valueMap: prop.valueMap !== undefined ? prop.valueMap : source.valueMap,
|
|
530
552
|
interval,
|
|
531
|
-
thresholdRules
|
|
553
|
+
thresholdRules,
|
|
554
|
+
isThresholdEnabled,
|
|
532
555
|
valueAt,
|
|
533
556
|
sort: prop.sort !== undefined ? prop.sort : source.sort,
|
|
534
557
|
parent: prop.parent !== undefined ? prop.parent : source.parent,
|
|
@@ -550,6 +573,8 @@ function normalizeLegacyEasyListProp(source = {}, row = {}) {
|
|
|
550
573
|
value,
|
|
551
574
|
valueStr,
|
|
552
575
|
interval,
|
|
576
|
+
thresholdRules,
|
|
577
|
+
isThresholdEnabled,
|
|
553
578
|
valueAt,
|
|
554
579
|
prop: legacyProp
|
|
555
580
|
})
|
|
@@ -257,6 +257,8 @@ describe('iotModuleSpecs devices easyList legacy compatibility', () => {
|
|
|
257
257
|
line: true,
|
|
258
258
|
value: 0.043,
|
|
259
259
|
company: 'A',
|
|
260
|
+
isThresholdEnabled: true,
|
|
261
|
+
thresholdRules: [{ level: 'warn', min: 0, max: 10 }],
|
|
260
262
|
valueAt: '2026-04-25T06:31:00.000Z',
|
|
261
263
|
prop: {
|
|
262
264
|
id: 'device-prop-electric'
|
|
@@ -322,6 +324,8 @@ describe('iotModuleSpecs devices easyList legacy compatibility', () => {
|
|
|
322
324
|
isImport: true,
|
|
323
325
|
line: true,
|
|
324
326
|
value: 0.043,
|
|
327
|
+
isThresholdEnabled: true,
|
|
328
|
+
thresholdRules: [{ level: 'warn', min: 0, max: 10 }],
|
|
325
329
|
valueAt: '2026-04-25T06:31:00.000Z'
|
|
326
330
|
})
|
|
327
331
|
)
|
|
@@ -330,6 +334,8 @@ describe('iotModuleSpecs devices easyList legacy compatibility', () => {
|
|
|
330
334
|
line: true,
|
|
331
335
|
value: 0.043,
|
|
332
336
|
company: 'A',
|
|
337
|
+
isThresholdEnabled: true,
|
|
338
|
+
thresholdRules: [{ level: 'warn', min: 0, max: 10 }],
|
|
333
339
|
valueAt: '2026-04-25T06:31:00.000Z'
|
|
334
340
|
})
|
|
335
341
|
)
|