@cpzxrobot/sdk 1.3.42 → 1.3.43

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/device_gateway.ts CHANGED
@@ -211,11 +211,17 @@ export class DeviceGateway extends Object {
211
211
  }
212
212
 
213
213
  async watch(
214
- id: number,
214
+ ids: number|number[],
215
215
  fn: any,
216
216
  ) {
217
217
  var axios = await this.context.ready;
218
- return axios.getAsSse(`/api/v1/device/watch/${id}`, fn)
218
+ var idQuery = "";
219
+ if (Array.isArray(ids)) {
220
+ idQuery = ids.map(x => `ids=${x}`).join("&");
221
+ }else{
222
+ idQuery = `ids=${ids}`;
223
+ }
224
+ return axios.getAsSse(`/api/v1/device/watch?`+idQuery, fn)
219
225
  }
220
226
 
221
227
  private getFilter<T extends { id: number }>(
@@ -168,9 +168,16 @@ class DeviceGateway extends Object {
168
168
  show(id, type = "datapoint") {
169
169
  this.context.platform.showInDeviceManager(id, type);
170
170
  }
171
- async watch(id, fn) {
171
+ async watch(ids, fn) {
172
172
  var axios = await this.context.ready;
173
- return axios.getAsSse(`/api/v1/device/watch/${id}`, fn);
173
+ var idQuery = "";
174
+ if (Array.isArray(ids)) {
175
+ idQuery = ids.map(x => `ids=${x}`).join("&");
176
+ }
177
+ else {
178
+ idQuery = `ids=${ids}`;
179
+ }
180
+ return axios.getAsSse(`/api/v1/device/watch?` + idQuery, fn);
174
181
  }
175
182
  getFilter(type, cls) {
176
183
  // 如果filters中已经有对应type的过滤器,则直接返回该过滤器
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.42",
3
+ "version": "1.3.43",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/types.d.ts CHANGED
@@ -33,7 +33,7 @@ type Device = {
33
33
  currentAmount: number;
34
34
  location: string;
35
35
  supplier?: string;
36
- data?: number[];
36
+ data?: any;
37
37
  typeCode: string;
38
38
  unitId: number;
39
39
  };
@@ -87,9 +87,9 @@ type Assistant = {
87
87
  id: Number;
88
88
  };
89
89
  type Factory = {
90
- code: string;
90
+ code?: string;
91
91
  name?: string;
92
- company_code: string;
92
+ company_code?: string;
93
93
  id?: number;
94
94
  type?: string;
95
95
  kind?: string;