index.ts
2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import {
DeviceInfoItemType,
DeviceTypeItem,
PageParams,
QueryItemType,
ScriptTestParams,
} from './model';
import { TBPaginationResult } from '/#/axios';
import { ScriptLanguageEnum } from '/@/enums/scriptEnum';
import { defHttp } from '/@/utils/http/axios';
enum Api {
GET_DEVICE_INFOS = '/tenant/deviceInfos',
GET_DEVICE_TYPE = '/device/types',
QUEUE = '/queues',
TEST_SCRIPT = '/ruleChain/testScript',
}
enum Entity {
DEVICES = '/tenant/devices',
ASSETS = '/tenant/assets',
ENTITY_VIEW = '/tenant/entityViews',
TENANT = '/tenant',
CUSTOMER = '/customers',
DASHBOARD = '/tenant/dashboards',
USER = '/users',
EDGE = '/tenant/edges',
}
export const getDeviceInfos = () => {
return defHttp.get<TBPaginationResult<DeviceInfoItemType>>(
{
url: Api.GET_DEVICE_INFOS,
},
{ joinPrefix: false }
);
};
export const getDeviceTypes = () => {
return defHttp.get<TBPaginationResult<DeviceTypeItem[]>>(
{
url: Api.GET_DEVICE_TYPE,
},
{ joinPrefix: false }
);
};
export const getQueue = (params: Recordable) => {
return defHttp.get<TBPaginationResult<QueryItemType>>(
{
url: Api.QUEUE,
params,
},
{ joinPrefix: false }
);
};
export const getEntityDevice = (params: PageParams) => {
return defHttp.get(
{
url: Entity.DEVICES,
params,
},
{
joinPrefix: false,
}
);
};
export const getEntityAssets = (params: PageParams) => {
return defHttp.get(
{
url: Entity.ASSETS,
params,
},
{
joinPrefix: false,
}
);
};
export const getEntityViews = (params: PageParams) => {
return defHttp.get(
{
url: Entity.ENTITY_VIEW,
params,
},
{
joinPrefix: false,
}
);
};
export const getEntityTenant = (params: Record<'tenantId', string>) => {
return defHttp.get(
{
url: `${Entity.TENANT}/${params.tenantId}`,
params,
},
{
joinPrefix: false,
}
);
};
export const getEntityCustomer = (params: PageParams) => {
return defHttp.get(
{
url: Entity.CUSTOMER,
params,
},
{
joinPrefix: false,
}
);
};
export const getEntityUser = (params: PageParams) => {
return defHttp.get(
{
url: Entity.USER,
params,
},
{
joinPrefix: false,
}
);
};
export const getEntityDashboard = (params: PageParams) => {
return defHttp.get(
{
url: Entity.DASHBOARD,
params,
},
{
joinPrefix: false,
}
);
};
export const getEntityEdge = (params: PageParams) => {
return defHttp.get(
{
url: Entity.EDGE,
params,
},
{
joinPrefix: false,
}
);
};
export const testScript = (
data: ScriptTestParams,
scriptLang: ScriptLanguageEnum = ScriptLanguageEnum.JavaScript
) => {
return defHttp.post<Record<'error' | 'output', string>>(
{
url: `${Api.TEST_SCRIPT}?scriptLang=${scriptLang}`,
data,
},
{ joinPrefix: false }
);
};