nayota-show-sdk 1.3.109 → 1.3.111
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/README.md +23 -1
- package/api/inspectionCheckItems.js +39 -0
- package/api/inspectionCheckItems.test.js +38 -0
- package/api/inspectionCheckTemplates.js +158 -0
- package/api/inspectionCheckTemplates.test.js +128 -0
- package/api/inspectionCompliance.test.js +38 -0
- package/api/inspectionPoints.js +15 -1
- package/api/inspectionTaskSub.js +19 -0
- package/index.js +4 -0
- package/index.test.js +12 -36
- package/package.json +1 -1
- package/utils/iot-module-specs.js +16 -0
- package/utils/iot-module-specs.test.js +28 -0
package/README.md
CHANGED
|
@@ -23,4 +23,26 @@ import { alarmRecord } from 'nayota-show-sdk'
|
|
|
23
23
|
const { list, updateOne, create, delete } = alarmRecord
|
|
24
24
|
// 正常调用
|
|
25
25
|
list({ page:1, limit:50 })
|
|
26
|
-
```
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 3.2 消防巡检合规接口
|
|
29
|
+
```javascript
|
|
30
|
+
// 检查模板
|
|
31
|
+
NayotaSdk.inspectionCheckTemplates.list({ page: 1, limit: 20 })
|
|
32
|
+
NayotaSdk.inspectionCheckTemplates.options()
|
|
33
|
+
NayotaSdk.inspectionCheckTemplates.create(data)
|
|
34
|
+
NayotaSdk.inspectionCheckTemplates.updateOne({ _id, ...data })
|
|
35
|
+
NayotaSdk.inspectionCheckTemplates.deleteOne(_id)
|
|
36
|
+
NayotaSdk.inspectionCheckTemplates.seedBuiltins()
|
|
37
|
+
|
|
38
|
+
// 检查项
|
|
39
|
+
NayotaSdk.inspectionCheckTemplates.listItems(templateId)
|
|
40
|
+
NayotaSdk.inspectionCheckTemplates.createItem(templateId, data)
|
|
41
|
+
NayotaSdk.inspectionCheckTemplates.sortItems(templateId, sortData)
|
|
42
|
+
NayotaSdk.inspectionCheckItems.updateOne({ _id, ...data })
|
|
43
|
+
NayotaSdk.inspectionCheckItems.deleteOne(_id)
|
|
44
|
+
|
|
45
|
+
// 点位执行配置与巡检提交
|
|
46
|
+
NayotaSdk.inspectionPoints.checkRuntime(pointId)
|
|
47
|
+
NayotaSdk.inspectionTaskSub.submitCompliance(data)
|
|
48
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { requestShow } from '../utils'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file 巡检检查项api
|
|
5
|
+
* @module 巡检检查项接口
|
|
6
|
+
* @category 巡更管理
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 修改检查项
|
|
11
|
+
* @param {Object} data - 检查项数据,需包含 _id 或 id
|
|
12
|
+
* @returns {number} code - 返回码,0表示成功
|
|
13
|
+
* @returns {Object} data - 修改后的检查项
|
|
14
|
+
*/
|
|
15
|
+
export function updateOne(data) {
|
|
16
|
+
const id = data._id || data.id
|
|
17
|
+
return requestShow({
|
|
18
|
+
url: `/inspection-check-items/${id}`,
|
|
19
|
+
method: 'put',
|
|
20
|
+
data
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 删除检查项
|
|
26
|
+
* @param {string} id - 检查项id
|
|
27
|
+
* @returns {number} code - 返回码,0表示成功
|
|
28
|
+
*/
|
|
29
|
+
export function deleteOne(id) {
|
|
30
|
+
return requestShow({
|
|
31
|
+
url: `/inspection-check-items/${id}`,
|
|
32
|
+
method: 'delete'
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default {
|
|
37
|
+
updateOne,
|
|
38
|
+
deleteOne
|
|
39
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
jest.mock('../utils', () => ({
|
|
2
|
+
requestShow: jest.fn()
|
|
3
|
+
}))
|
|
4
|
+
|
|
5
|
+
const { requestShow } = require('../utils')
|
|
6
|
+
const inspectionCheckItems = require('./inspectionCheckItems').default
|
|
7
|
+
const sdk = require('../index').default
|
|
8
|
+
|
|
9
|
+
describe('inspectionCheckItems api', () => {
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
jest.clearAllMocks()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test('updates an inspection check item', () => {
|
|
15
|
+
const data = { _id: 'item-1', itemName: '消防栓外观检查' }
|
|
16
|
+
|
|
17
|
+
inspectionCheckItems.updateOne(data)
|
|
18
|
+
|
|
19
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
20
|
+
url: '/inspection-check-items/item-1',
|
|
21
|
+
method: 'put',
|
|
22
|
+
data
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
test('deletes an inspection check item', () => {
|
|
27
|
+
inspectionCheckItems.deleteOne('item-1')
|
|
28
|
+
|
|
29
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
30
|
+
url: '/inspection-check-items/item-1',
|
|
31
|
+
method: 'delete'
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
test('exports module from sdk root', () => {
|
|
36
|
+
expect(sdk.inspectionCheckItems).toBe(inspectionCheckItems)
|
|
37
|
+
})
|
|
38
|
+
})
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { requestShow } from '../utils'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file 巡检检查模板api
|
|
5
|
+
* @module 巡检检查模板接口
|
|
6
|
+
* @category 巡更管理
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 获取检查模板列表
|
|
11
|
+
* @param {Object} query - 请求对象
|
|
12
|
+
* @returns {number} code - 返回码,0表示成功
|
|
13
|
+
* @returns {Object} data - { total, rows }
|
|
14
|
+
*/
|
|
15
|
+
export function list(query) {
|
|
16
|
+
return requestShow({
|
|
17
|
+
url: '/inspection-check-templates',
|
|
18
|
+
method: 'get',
|
|
19
|
+
params: query
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 获取启用检查模板下拉列表
|
|
25
|
+
* @param {Object} query - 请求对象
|
|
26
|
+
* @returns {number} code - 返回码,0表示成功
|
|
27
|
+
* @returns {Array} data - 模板下拉数组
|
|
28
|
+
*/
|
|
29
|
+
export function options(query) {
|
|
30
|
+
return requestShow({
|
|
31
|
+
url: '/inspection-check-templates/options',
|
|
32
|
+
method: 'get',
|
|
33
|
+
params: query
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 新增检查模板
|
|
39
|
+
* @param {Object} data - 检查模板数据
|
|
40
|
+
* @returns {number} code - 返回码,0表示成功
|
|
41
|
+
* @returns {Object} data - 新增后的检查模板
|
|
42
|
+
*/
|
|
43
|
+
export function create(data) {
|
|
44
|
+
return requestShow({
|
|
45
|
+
url: '/inspection-check-templates',
|
|
46
|
+
method: 'post',
|
|
47
|
+
data
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 获取检查模板详情
|
|
53
|
+
* @param {string} id - 检查模板id
|
|
54
|
+
* @returns {number} code - 返回码,0表示成功
|
|
55
|
+
* @returns {Object} data - 检查模板详情
|
|
56
|
+
*/
|
|
57
|
+
export function getOne(id) {
|
|
58
|
+
return requestShow({
|
|
59
|
+
url: `/inspection-check-templates/${id}`,
|
|
60
|
+
method: 'get'
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 修改检查模板
|
|
66
|
+
* @param {Object} data - 检查模板数据,需包含 _id 或 id
|
|
67
|
+
* @returns {number} code - 返回码,0表示成功
|
|
68
|
+
* @returns {Object} data - 修改后的检查模板
|
|
69
|
+
*/
|
|
70
|
+
export function updateOne(data) {
|
|
71
|
+
const id = data._id || data.id
|
|
72
|
+
return requestShow({
|
|
73
|
+
url: `/inspection-check-templates/${id}`,
|
|
74
|
+
method: 'put',
|
|
75
|
+
data
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 删除检查模板
|
|
81
|
+
* @param {string} id - 检查模板id
|
|
82
|
+
* @returns {number} code - 返回码,0表示成功
|
|
83
|
+
*/
|
|
84
|
+
export function deleteOne(id) {
|
|
85
|
+
return requestShow({
|
|
86
|
+
url: `/inspection-check-templates/${id}`,
|
|
87
|
+
method: 'delete'
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 初始化内置检查模板
|
|
93
|
+
* @returns {number} code - 返回码,0表示成功
|
|
94
|
+
* @returns {Object} data - 初始化结果
|
|
95
|
+
*/
|
|
96
|
+
export function seedBuiltins() {
|
|
97
|
+
return requestShow({
|
|
98
|
+
url: '/inspection-check-templates/seed-builtins',
|
|
99
|
+
method: 'post'
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 获取模板下检查项列表
|
|
105
|
+
* @param {string} templateId - 检查模板id
|
|
106
|
+
* @param {Object} query - 请求对象
|
|
107
|
+
* @returns {number} code - 返回码,0表示成功
|
|
108
|
+
* @returns {Array} data - 检查项列表
|
|
109
|
+
*/
|
|
110
|
+
export function listItems(templateId, query) {
|
|
111
|
+
return requestShow({
|
|
112
|
+
url: `/inspection-check-templates/${templateId}/items`,
|
|
113
|
+
method: 'get',
|
|
114
|
+
params: query
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 新增模板检查项
|
|
120
|
+
* @param {string} templateId - 检查模板id
|
|
121
|
+
* @param {Object} data - 检查项数据
|
|
122
|
+
* @returns {number} code - 返回码,0表示成功
|
|
123
|
+
* @returns {Object} data - 新增后的检查项
|
|
124
|
+
*/
|
|
125
|
+
export function createItem(templateId, data) {
|
|
126
|
+
return requestShow({
|
|
127
|
+
url: `/inspection-check-templates/${templateId}/items`,
|
|
128
|
+
method: 'post',
|
|
129
|
+
data
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* 调整模板检查项排序
|
|
135
|
+
* @param {string} templateId - 检查模板id
|
|
136
|
+
* @param {Object|Array} data - 排序数据
|
|
137
|
+
* @returns {number} code - 返回码,0表示成功
|
|
138
|
+
*/
|
|
139
|
+
export function sortItems(templateId, data) {
|
|
140
|
+
return requestShow({
|
|
141
|
+
url: `/inspection-check-templates/${templateId}/items/sort`,
|
|
142
|
+
method: 'put',
|
|
143
|
+
data
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export default {
|
|
148
|
+
list,
|
|
149
|
+
options,
|
|
150
|
+
create,
|
|
151
|
+
getOne,
|
|
152
|
+
updateOne,
|
|
153
|
+
deleteOne,
|
|
154
|
+
seedBuiltins,
|
|
155
|
+
listItems,
|
|
156
|
+
createItem,
|
|
157
|
+
sortItems
|
|
158
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
jest.mock('../utils', () => ({
|
|
2
|
+
requestShow: jest.fn()
|
|
3
|
+
}))
|
|
4
|
+
|
|
5
|
+
const { requestShow } = require('../utils')
|
|
6
|
+
const inspectionCheckTemplates = require('./inspectionCheckTemplates').default
|
|
7
|
+
const sdk = require('../index').default
|
|
8
|
+
|
|
9
|
+
describe('inspectionCheckTemplates api', () => {
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
jest.clearAllMocks()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test('lists inspection check templates', () => {
|
|
15
|
+
const query = { page: 1, limit: 20, keyword: 'fire' }
|
|
16
|
+
|
|
17
|
+
inspectionCheckTemplates.list(query)
|
|
18
|
+
|
|
19
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
20
|
+
url: '/inspection-check-templates',
|
|
21
|
+
method: 'get',
|
|
22
|
+
params: query
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
test('gets inspection check template options', () => {
|
|
27
|
+
const query = { status: true }
|
|
28
|
+
|
|
29
|
+
inspectionCheckTemplates.options(query)
|
|
30
|
+
|
|
31
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
32
|
+
url: '/inspection-check-templates/options',
|
|
33
|
+
method: 'get',
|
|
34
|
+
params: query
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
test('creates an inspection check template', () => {
|
|
39
|
+
const data = { name: '消防巡检模板' }
|
|
40
|
+
|
|
41
|
+
inspectionCheckTemplates.create(data)
|
|
42
|
+
|
|
43
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
44
|
+
url: '/inspection-check-templates',
|
|
45
|
+
method: 'post',
|
|
46
|
+
data
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
test('gets one inspection check template', () => {
|
|
51
|
+
inspectionCheckTemplates.getOne('template-1')
|
|
52
|
+
|
|
53
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
54
|
+
url: '/inspection-check-templates/template-1',
|
|
55
|
+
method: 'get'
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('updates an inspection check template', () => {
|
|
60
|
+
const data = { _id: 'template-1', name: '更新模板' }
|
|
61
|
+
|
|
62
|
+
inspectionCheckTemplates.updateOne(data)
|
|
63
|
+
|
|
64
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
65
|
+
url: '/inspection-check-templates/template-1',
|
|
66
|
+
method: 'put',
|
|
67
|
+
data
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
test('deletes an inspection check template', () => {
|
|
72
|
+
inspectionCheckTemplates.deleteOne('template-1')
|
|
73
|
+
|
|
74
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
75
|
+
url: '/inspection-check-templates/template-1',
|
|
76
|
+
method: 'delete'
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
test('seeds built-in templates', () => {
|
|
81
|
+
inspectionCheckTemplates.seedBuiltins()
|
|
82
|
+
|
|
83
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
84
|
+
url: '/inspection-check-templates/seed-builtins',
|
|
85
|
+
method: 'post'
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
test('lists template items', () => {
|
|
90
|
+
const query = { status: true }
|
|
91
|
+
|
|
92
|
+
inspectionCheckTemplates.listItems('template-1', query)
|
|
93
|
+
|
|
94
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
95
|
+
url: '/inspection-check-templates/template-1/items',
|
|
96
|
+
method: 'get',
|
|
97
|
+
params: query
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
test('creates a template item', () => {
|
|
102
|
+
const data = { itemName: '灭火器压力检查' }
|
|
103
|
+
|
|
104
|
+
inspectionCheckTemplates.createItem('template-1', data)
|
|
105
|
+
|
|
106
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
107
|
+
url: '/inspection-check-templates/template-1/items',
|
|
108
|
+
method: 'post',
|
|
109
|
+
data
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
test('sorts template items', () => {
|
|
114
|
+
const data = [{ id: 'item-1', sort: 1 }]
|
|
115
|
+
|
|
116
|
+
inspectionCheckTemplates.sortItems('template-1', data)
|
|
117
|
+
|
|
118
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
119
|
+
url: '/inspection-check-templates/template-1/items/sort',
|
|
120
|
+
method: 'put',
|
|
121
|
+
data
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
test('exports module from sdk root', () => {
|
|
126
|
+
expect(sdk.inspectionCheckTemplates).toBe(inspectionCheckTemplates)
|
|
127
|
+
})
|
|
128
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
jest.mock('../utils', () => ({
|
|
2
|
+
requestShow: jest.fn()
|
|
3
|
+
}))
|
|
4
|
+
|
|
5
|
+
const { requestShow } = require('../utils')
|
|
6
|
+
const inspectionPoints = require('./inspectionPoints').default
|
|
7
|
+
const inspectionTaskSub = require('./inspectionTaskSub').default
|
|
8
|
+
|
|
9
|
+
describe('inspection compliance api', () => {
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
jest.clearAllMocks()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test('gets point check runtime', () => {
|
|
15
|
+
inspectionPoints.checkRuntime('point-1')
|
|
16
|
+
|
|
17
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
18
|
+
url: '/inspection-points/point-1/check-runtime',
|
|
19
|
+
method: 'get'
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test('submits compliance result', () => {
|
|
24
|
+
const data = {
|
|
25
|
+
taskId: 'task-1',
|
|
26
|
+
pointId: 'point-1',
|
|
27
|
+
itemResults: [{ itemId: 'item-1', result: 'normal' }]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
inspectionTaskSub.submitCompliance(data)
|
|
31
|
+
|
|
32
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
33
|
+
url: '/inspection-task-subs/submit-compliance',
|
|
34
|
+
method: 'post',
|
|
35
|
+
data
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
})
|
package/api/inspectionPoints.js
CHANGED
|
@@ -88,6 +88,19 @@ export function getOne(id) {
|
|
|
88
88
|
})
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* 获取点位巡检执行配置
|
|
93
|
+
* @param {string} id - 点位id
|
|
94
|
+
* @returns {number} code - 返回码,0表示成功
|
|
95
|
+
* @returns {Object} data - 点位、检查模板、检查项和证据规则
|
|
96
|
+
*/
|
|
97
|
+
export function checkRuntime(id) {
|
|
98
|
+
return requestShow({
|
|
99
|
+
url: `/inspection-points/${id}/check-runtime`,
|
|
100
|
+
method: 'get'
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
|
|
91
104
|
/**
|
|
92
105
|
* 修改点位
|
|
93
106
|
* @param {Object} data - 包含点位的请求体 属性见表结构inspectionPoint定义。
|
|
@@ -134,5 +147,6 @@ export default {
|
|
|
134
147
|
updateOne,
|
|
135
148
|
deleteOne,
|
|
136
149
|
deleteMany,
|
|
137
|
-
getOne
|
|
150
|
+
getOne,
|
|
151
|
+
checkRuntime
|
|
138
152
|
}
|
package/api/inspectionTaskSub.js
CHANGED
|
@@ -96,6 +96,24 @@ export function create(data) {
|
|
|
96
96
|
})
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
/**
|
|
100
|
+
* 提交巡检合规记录
|
|
101
|
+
* @param {Object} data - 巡检提交数据
|
|
102
|
+
* @param {string} data.taskId - 巡检任务id
|
|
103
|
+
* @param {string} data.pointId - 点位id
|
|
104
|
+
* @param {Array} data.itemResults - 检查项结果快照
|
|
105
|
+
* @param {Array} [data.photos] - 现场照片
|
|
106
|
+
* @returns {number} code - 返回码,0表示成功
|
|
107
|
+
* @returns {Object} data - 保存后的巡检子任务/记录
|
|
108
|
+
*/
|
|
109
|
+
export function submitCompliance(data) {
|
|
110
|
+
return requestShow({
|
|
111
|
+
url: '/inspection-task-subs/submit-compliance',
|
|
112
|
+
method: 'post',
|
|
113
|
+
data
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
99
117
|
/**
|
|
100
118
|
* 获取巡查任务子表
|
|
101
119
|
* @param {string} id - 巡查任务子表id
|
|
@@ -182,6 +200,7 @@ export default {
|
|
|
182
200
|
summary,
|
|
183
201
|
offline,
|
|
184
202
|
create,
|
|
203
|
+
submitCompliance,
|
|
185
204
|
updateOne,
|
|
186
205
|
deleteOne,
|
|
187
206
|
deleteMany,
|
package/index.js
CHANGED
|
@@ -25,6 +25,8 @@ import inspectionPoints from "./api/inspectionPoints";
|
|
|
25
25
|
import patrolPoints from "./api/patrolPoints";
|
|
26
26
|
import inspectionTask from "./api/inspectionTask";
|
|
27
27
|
import inspectionTaskSub from "./api/inspectionTaskSub";
|
|
28
|
+
import inspectionCheckTemplates from "./api/inspectionCheckTemplates";
|
|
29
|
+
import inspectionCheckItems from "./api/inspectionCheckItems";
|
|
28
30
|
import inspectionTeams from "./api/inspectionTeams";
|
|
29
31
|
import product from "./api/product";
|
|
30
32
|
import area from "./api/area";
|
|
@@ -68,6 +70,8 @@ const api = {
|
|
|
68
70
|
patrolPoints,
|
|
69
71
|
inspectionTask,
|
|
70
72
|
inspectionTaskSub,
|
|
73
|
+
inspectionCheckTemplates,
|
|
74
|
+
inspectionCheckItems,
|
|
71
75
|
inspectionTeams,
|
|
72
76
|
product,
|
|
73
77
|
area,
|
package/index.test.js
CHANGED
|
@@ -1,38 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
expect(
|
|
12
|
-
expect(
|
|
13
|
-
expect(Object.keys(modules)).toHaveLength(17) // Assuming there is only one module in the littleTool directory
|
|
14
|
-
|
|
15
|
-
// Test the structure of the module
|
|
16
|
-
// const module = modules['api'] // Assuming the module name is 'api'
|
|
17
|
-
// expect(module).toBeDefined()
|
|
18
|
-
// expect(typeof module).toBe('object')
|
|
19
|
-
// expect(Object.keys(module)).toHaveLength(13) // Assuming there are 13 sub-modules in the api directory
|
|
20
|
-
|
|
21
|
-
// // Test the structure of each sub-module
|
|
22
|
-
// expect(module['alarms']).toBeDefined()
|
|
23
|
-
// expect(module['checkReduces']).toBeDefined()
|
|
24
|
-
// expect(module['user']).toBeDefined()
|
|
25
|
-
// expect(module['httpDrives']).toBeDefined()
|
|
26
|
-
// expect(module['hardwares']).toBeDefined()
|
|
27
|
-
// expect(module['checks']).toBeDefined()
|
|
28
|
-
// expect(module['cloudHardwares']).toBeDefined()
|
|
29
|
-
// expect(module['loraSlaves']).toBeDefined()
|
|
30
|
-
// expect(module['lorawanDevices']).toBeDefined()
|
|
31
|
-
// expect(module['nbiotDrives']).toBeDefined()
|
|
32
|
-
// expect(module['nbm2mDevices']).toBeDefined()
|
|
33
|
-
// expect(module['netDrives']).toBeDefined()
|
|
34
|
-
// expect(module['netMqttDevices']).toBeDefined()
|
|
35
|
-
// // 添加alarms list请求的测试
|
|
36
|
-
// expect(module['alarms']['list']).toBeDefined()
|
|
1
|
+
const sdk = require('./index.js').default
|
|
2
|
+
|
|
3
|
+
describe('sdk root export', () => {
|
|
4
|
+
test('exports config, event hook and api modules', () => {
|
|
5
|
+
expect(sdk).toBeDefined()
|
|
6
|
+
expect(typeof sdk).toBe('object')
|
|
7
|
+
expect(typeof sdk.config).toBe('function')
|
|
8
|
+
expect(typeof sdk.on).toBe('function')
|
|
9
|
+
expect(sdk.inspectionPoints).toBeDefined()
|
|
10
|
+
expect(sdk.inspectionTaskSub).toBeDefined()
|
|
11
|
+
expect(sdk.inspectionCheckTemplates).toBeDefined()
|
|
12
|
+
expect(sdk.inspectionCheckItems).toBeDefined()
|
|
37
13
|
})
|
|
38
14
|
})
|
package/package.json
CHANGED
|
@@ -1101,6 +1101,22 @@ function createDeviceClassOperations() {
|
|
|
1101
1101
|
}
|
|
1102
1102
|
}
|
|
1103
1103
|
|
|
1104
|
+
operations.onlineRate = {
|
|
1105
|
+
toRequest(query = {}) {
|
|
1106
|
+
return {
|
|
1107
|
+
url: '/device-classes/online-rate',
|
|
1108
|
+
method: 'get',
|
|
1109
|
+
params: query
|
|
1110
|
+
}
|
|
1111
|
+
},
|
|
1112
|
+
fromResponse(response) {
|
|
1113
|
+
const payload = response && response.data && response.status ? response.data : response
|
|
1114
|
+
return payload && payload.code !== undefined
|
|
1115
|
+
? payload
|
|
1116
|
+
: { code: 0, data: payload?.data !== undefined ? payload.data : payload }
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1104
1120
|
return operations
|
|
1105
1121
|
}
|
|
1106
1122
|
|
|
@@ -51,6 +51,34 @@ describe('iotModuleSpecs deviceClass UI compatibility', () => {
|
|
|
51
51
|
expect(request.data.metadata.bms.deviceUI).toBe('legacy-device-ui-2')
|
|
52
52
|
})
|
|
53
53
|
|
|
54
|
+
test('maps onlineRate to the iot legacy-compatible device-classes endpoint', () => {
|
|
55
|
+
const request = deviceClass.onlineRate.toRequest({ year: 2026, month: 7 })
|
|
56
|
+
|
|
57
|
+
expect(request).toEqual({
|
|
58
|
+
url: '/device-classes/online-rate',
|
|
59
|
+
method: 'get',
|
|
60
|
+
params: { year: 2026, month: 7 }
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
expect(
|
|
64
|
+
deviceClass.onlineRate.fromResponse({
|
|
65
|
+
code: 0,
|
|
66
|
+
data: {
|
|
67
|
+
year: 2026,
|
|
68
|
+
month: 7,
|
|
69
|
+
summary: { onlineRate: 1 }
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
).toEqual({
|
|
73
|
+
code: 0,
|
|
74
|
+
data: {
|
|
75
|
+
year: 2026,
|
|
76
|
+
month: 7,
|
|
77
|
+
summary: { onlineRate: 1 }
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
|
|
54
82
|
test('expands digital twin type ui relation back to legacy uis', () => {
|
|
55
83
|
const response = deviceClass.list.fromResponse({
|
|
56
84
|
code: 0,
|