@cpzxrobot/sdk 1.0.10 → 1.0.11

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/camera_gateway.ts CHANGED
@@ -8,8 +8,8 @@ export class CameraGateway extends Object {
8
8
  }
9
9
  //搜索摄像头
10
10
  async search(data: Unit): Promise<any> {
11
- await this.context.ready;
12
- const response = await this.context.axios.post("/api/v1/camera/search", {
11
+ var axios = await this.context.ready;
12
+ const response = await axios.post("/api/v1/camera/search", {
13
13
  unit_id: data.id,
14
14
  });
15
15
  return response.data;
@@ -17,16 +17,16 @@ export class CameraGateway extends Object {
17
17
 
18
18
  //获得摄像头的播放地址
19
19
  async getUrl(data: Camera): Promise<any> {
20
- await this.context.ready;
21
- const response = await this.context.axios.get(
20
+ var axios = await this.context.ready;
21
+ const response = await axios.get(
22
22
  `/api/v1/camera/${data.id}/url/wss`
23
23
  );
24
24
  return response.data;
25
25
  }
26
26
  //获取工厂天气
27
27
  async weather(id: number): Promise<any> {
28
- await this.context.ready;
29
- const response = await this.context.axios.get(`/api/v1/weather?code=${id}`);
28
+ var axios = await this.context.ready;
29
+ const response = await axios.get(`/api/v1/weather?code=${id}`);
30
30
  return response.data;
31
31
  }
32
32
  }
@@ -2,29 +2,29 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CameraGateway = void 0;
4
4
  class CameraGateway extends Object {
5
- constructor(context) {
6
- super();
7
- this.context = context;
8
- }
9
- //搜索摄像头
10
- async search(data) {
11
- await this.context.ready;
12
- const response = await this.context.axios.post("/api/v1/camera/search", {
13
- unit_id: data.id,
14
- });
15
- return response.data;
16
- }
17
- //获得摄像头的播放地址
18
- async getUrl(data) {
19
- await this.context.ready;
20
- const response = await this.context.axios.get(`/api/v1/camera/${data.id}/url/wss`);
21
- return response.data;
22
- }
23
- //获取工厂天气
24
- async weather(id) {
25
- await this.context.ready;
26
- const response = await this.context.axios.get(`/api/v1/weather?code=${id}`);
27
- return response.data;
28
- }
5
+ constructor(context) {
6
+ super();
7
+ this.context = context;
8
+ }
9
+ //搜索摄像头
10
+ async search(data) {
11
+ var axios = await this.context.ready;
12
+ const response = axios.post("/api/v1/camera/search", {
13
+ unit_id: data.id,
14
+ });
15
+ return response.data;
16
+ }
17
+ //获得摄像头的播放地址
18
+ async getUrl(data) {
19
+ var axios = await this.context.ready;
20
+ const response = axios.get(`/api/v1/camera/${data.id}/url/wss`);
21
+ return response.data;
22
+ }
23
+ //获取工厂天气
24
+ async weather(id) {
25
+ var axios = await this.context.ready;
26
+ const response = axios.get(`/api/v1/weather?code=${id}`);
27
+ return response.data;
28
+ }
29
29
  }
30
30
  exports.CameraGateway = CameraGateway;
@@ -94,6 +94,10 @@ class DeviceFilter {
94
94
  sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
95
95
  args.start = this.formateDateToYYYYMMDD(sevenDaysAgo);
96
96
  }
97
+ if (!args.type) {
98
+ throw new Error("没有提交数据类型,请检查type参数");
99
+ }
100
+
97
101
  return this.context.ready
98
102
  .then(() => {
99
103
  const p1 = this.context.axios.get(`/api/v1/device/${id}/data/${args.type}`, {
@@ -47,8 +47,8 @@ export class FactoryGateway extends Object {
47
47
  }
48
48
 
49
49
  async company(data: Factory): Promise<any> {
50
- await this.context.ready;
51
- const response = await this.context.axios.get(`/api/v1/factory/${data.id}/organizaion`, data);
50
+ var axios = await this.context.ready;
51
+ const response = await axios.get(`/api/v1/factory/${data.id}/organizaion`, data);
52
52
  return response.data;
53
53
  }
54
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/types.d.ts CHANGED
@@ -2,6 +2,7 @@ import { DeviceGateway } from "@cpzxrobot/sdk/device_gateway";
2
2
  import { FactoryGateway } from "@cpzxrobot/sdk/factory_gateway";
3
3
  import { TransportGateway } from "@cpzxrobot/sdk/transport_gateway";
4
4
  import { UserGateway } from "@cpzxrobot/sdk/user_gateway";
5
+ import { CameraGateway } from "@cpzxrobot/sdk/camera_gateway";
5
6
 
6
7
  type Device = {
7
8
  id: number;
@@ -130,6 +131,7 @@ export class Cpzxrobot {
130
131
  device: DeviceGateway;
131
132
  mode: string;
132
133
  axios: MyAxiosInstance;
134
+ camera: CameraGateway;
133
135
  _getSelectedFarmFromMiniApp: () => Promise<Factory>;
134
136
  _getSelectedUnitFromMiniApp: () => Promise<Unit>;
135
137
  setTitle: (title: string) => void;