@cpzxrobot/sdk 1.3.92 → 1.3.94
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/ai_gateway.ts +10 -0
- package/device_gateway.ts +15 -2
- package/device_type_gateway.ts +8 -4
- package/dist/ai_gateway.js +3 -0
- package/dist/device_gateway.js +13 -0
- package/dist/device_type_gateway.js +19 -4
- package/dist/mobile_platform.js +3 -0
- package/dist/web_platform.js +3 -0
- package/dist/windows_platform.js +5 -0
- package/mobile_platform.ts +5 -1
- package/package.json +1 -1
- package/platform_interface.ts +2 -1
- package/types.d.ts +9 -1
- package/web_platform.ts +5 -1
- package/windows_platform.ts +6 -1
package/ai_gateway.ts
CHANGED
|
@@ -15,5 +15,15 @@ export class AiGateway extends Object {
|
|
|
15
15
|
return axios.post(" /api/chatai/deviceMatch", args);
|
|
16
16
|
})
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
assist(args:{
|
|
20
|
+
prompt: string;
|
|
21
|
+
output: {
|
|
22
|
+
type: string;
|
|
18
23
|
|
|
24
|
+
},
|
|
25
|
+
callback: (data: any) => void;
|
|
26
|
+
}){
|
|
27
|
+
this.context.platform.aiAssist(args);
|
|
28
|
+
}
|
|
19
29
|
}
|
package/device_gateway.ts
CHANGED
|
@@ -216,7 +216,7 @@ export class DeviceGateway extends Object {
|
|
|
216
216
|
// 参数验证
|
|
217
217
|
if (!factoryId) {
|
|
218
218
|
let farm = await this.context.user.getSelectedFarm();
|
|
219
|
-
factoryId = farm?.id || 0;
|
|
219
|
+
factoryId = farm?.id || 0;
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
return axios.get(`/api/v2/device/stat/alarms/rule`, {
|
|
@@ -280,6 +280,19 @@ export class DeviceGateway extends Object {
|
|
|
280
280
|
return res.data;
|
|
281
281
|
});
|
|
282
282
|
},
|
|
283
|
+
/**
|
|
284
|
+
* 删除报警规则
|
|
285
|
+
* @param id - 报警规则ID
|
|
286
|
+
*/
|
|
287
|
+
delete: async (id: number): Promise<any> => {
|
|
288
|
+
const axios = await this.context.ready;
|
|
289
|
+
return axios.delete(`/api/v2/device/stat/alarms/rule/${id}`).then((res) => {
|
|
290
|
+
if (res.data.code !== 200) {
|
|
291
|
+
throw new Error(res.data.message || '删除报警规则失败');
|
|
292
|
+
}
|
|
293
|
+
return res.data;
|
|
294
|
+
});
|
|
295
|
+
},
|
|
283
296
|
};
|
|
284
297
|
}
|
|
285
298
|
|
|
@@ -1264,7 +1277,7 @@ export class DeviceGateway extends Object {
|
|
|
1264
1277
|
params.duration = args.duration;
|
|
1265
1278
|
}
|
|
1266
1279
|
if (args.hourMode !== undefined) {
|
|
1267
|
-
params.perHour = args.hourMode;
|
|
1280
|
+
params.perHour = args.hourMode;
|
|
1268
1281
|
}
|
|
1269
1282
|
|
|
1270
1283
|
return axios.get(`/api/v2/device/stat/alarms/trend`, {
|
package/device_type_gateway.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cpzxrobot, type Unit,type
|
|
1
|
+
import { Cpzxrobot, type Unit, type DeviceType } from "."
|
|
2
2
|
|
|
3
3
|
//缓存设备类型数据
|
|
4
4
|
export class DeviceTypeGateway {
|
|
@@ -11,11 +11,15 @@ export class DeviceTypeGateway {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
//需要返回.data
|
|
14
|
-
list(): Promise<DeviceType[]> {
|
|
14
|
+
async list(): Promise<DeviceType[]> {
|
|
15
15
|
if (this.deviceTypes) {
|
|
16
16
|
return Promise.resolve(this.deviceTypes)
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
var axios = await this.context.ready;
|
|
19
|
+
return axios.get('/api/v1/device/type').then((res) => {
|
|
20
|
+
this.deviceTypes = res.data
|
|
21
|
+
return res.data
|
|
22
|
+
})
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
alarmConfigForUnit(unit: Unit): Promise<any> {
|
|
@@ -27,5 +31,5 @@ export class DeviceTypeGateway {
|
|
|
27
31
|
})
|
|
28
32
|
});
|
|
29
33
|
}
|
|
30
|
-
|
|
34
|
+
|
|
31
35
|
}
|
package/dist/ai_gateway.js
CHANGED
package/dist/device_gateway.js
CHANGED
|
@@ -212,6 +212,19 @@ class DeviceGateway extends Object {
|
|
|
212
212
|
return res.data;
|
|
213
213
|
});
|
|
214
214
|
}),
|
|
215
|
+
/**
|
|
216
|
+
* 删除报警规则
|
|
217
|
+
* @param id - 报警规则ID
|
|
218
|
+
*/
|
|
219
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
220
|
+
const axios = yield this.context.ready;
|
|
221
|
+
return axios.delete(`/api/v2/device/stat/alarms/rule/${id}`).then((res) => {
|
|
222
|
+
if (res.data.code !== 200) {
|
|
223
|
+
throw new Error(res.data.message || '删除报警规则失败');
|
|
224
|
+
}
|
|
225
|
+
return res.data;
|
|
226
|
+
});
|
|
227
|
+
}),
|
|
215
228
|
};
|
|
216
229
|
}
|
|
217
230
|
constructor(context) {
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.DeviceTypeGateway = void 0;
|
|
4
13
|
//缓存设备类型数据
|
|
@@ -8,10 +17,16 @@ class DeviceTypeGateway {
|
|
|
8
17
|
}
|
|
9
18
|
//需要返回.data
|
|
10
19
|
list() {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
if (this.deviceTypes) {
|
|
22
|
+
return Promise.resolve(this.deviceTypes);
|
|
23
|
+
}
|
|
24
|
+
var axios = yield this.context.ready;
|
|
25
|
+
return axios.get('/api/v1/device/type').then((res) => {
|
|
26
|
+
this.deviceTypes = res.data;
|
|
27
|
+
return res.data;
|
|
28
|
+
});
|
|
29
|
+
});
|
|
15
30
|
}
|
|
16
31
|
alarmConfigForUnit(unit) {
|
|
17
32
|
return this.context.ready.then((axios) => {
|
package/dist/mobile_platform.js
CHANGED
package/dist/web_platform.js
CHANGED
package/dist/windows_platform.js
CHANGED
|
@@ -135,5 +135,10 @@ class WindwosMiniAppPlatform {
|
|
|
135
135
|
// @ts-ignore
|
|
136
136
|
(_a = window.miniapp) === null || _a === void 0 ? void 0 : _a.setProgress(precentage);
|
|
137
137
|
}
|
|
138
|
+
aiAssist(args) {
|
|
139
|
+
var _a;
|
|
140
|
+
// @ts-ignore
|
|
141
|
+
(_a = window.miniapp) === null || _a === void 0 ? void 0 : _a.aiAssist(args);
|
|
142
|
+
}
|
|
138
143
|
}
|
|
139
144
|
exports.WindwosMiniAppPlatform = WindwosMiniAppPlatform;
|
package/mobile_platform.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PlatformInterface } from "./platform_interface";
|
|
2
|
-
import { Factory, MyAxiosInstance, Unit } from "./types";
|
|
2
|
+
import { AiAssistRequest, Factory, MyAxiosInstance, Unit } from "./types";
|
|
3
3
|
|
|
4
4
|
export class MobilePlatform implements PlatformInterface {
|
|
5
5
|
private platform: {
|
|
@@ -187,4 +187,8 @@ export class MobilePlatform implements PlatformInterface {
|
|
|
187
187
|
setProgress(precentage: number): void {
|
|
188
188
|
this.platform.callHandler("app.setProgress", precentage);
|
|
189
189
|
}
|
|
190
|
+
|
|
191
|
+
aiAssist(args: AiAssistRequest): void {
|
|
192
|
+
this.platform.callHandler("app.aiAssist", args);
|
|
193
|
+
}
|
|
190
194
|
}
|
package/package.json
CHANGED
package/platform_interface.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Factory, type MyAxiosInstance, type Unit } from "./types";
|
|
1
|
+
import { AiAssistRequest, type Factory, type MyAxiosInstance, type Unit } from "./types";
|
|
2
2
|
|
|
3
3
|
export abstract class PlatformInterface {
|
|
4
4
|
appCode: string;
|
|
@@ -33,4 +33,5 @@ export abstract class PlatformInterface {
|
|
|
33
33
|
abstract setSelectedFarm(farm: Factory | String | Number): void;
|
|
34
34
|
//change factory
|
|
35
35
|
abstract openFactorySelector():void;
|
|
36
|
+
abstract aiAssist(args:AiAssistRequest):void;
|
|
36
37
|
}
|
package/types.d.ts
CHANGED
|
@@ -608,7 +608,7 @@ interface CreateAlarmRuleResponse {
|
|
|
608
608
|
*/
|
|
609
609
|
interface AlarmRuleDetail {
|
|
610
610
|
/** 规则id */
|
|
611
|
-
|
|
611
|
+
id: number;
|
|
612
612
|
/** 工厂id */
|
|
613
613
|
factoryId: number;
|
|
614
614
|
/** 规则名称 */
|
|
@@ -645,6 +645,14 @@ interface AlarmRuleListResponse {
|
|
|
645
645
|
message: string;
|
|
646
646
|
}
|
|
647
647
|
|
|
648
|
+
interface AiAssistRequest {
|
|
649
|
+
prompt: string;
|
|
650
|
+
output: {
|
|
651
|
+
type: string;
|
|
652
|
+
};
|
|
653
|
+
callback: (data: any) => void;
|
|
654
|
+
}
|
|
655
|
+
|
|
648
656
|
/**
|
|
649
657
|
* 报警规则详情响应接口
|
|
650
658
|
*/
|
package/web_platform.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PlatformInterface } from "./platform_interface";
|
|
2
|
-
import { Cpzxrobot, Factory, MyAxiosInstance, Unit } from "./types";
|
|
2
|
+
import { AiAssistRequest, Cpzxrobot, Factory, MyAxiosInstance, Unit } from "./types";
|
|
3
3
|
|
|
4
4
|
export class WebPlatform implements PlatformInterface {
|
|
5
5
|
token: string = "";
|
|
@@ -480,4 +480,8 @@ export class WebPlatform implements PlatformInterface {
|
|
|
480
480
|
setProgress(_precentage: number): void {
|
|
481
481
|
// No implementation in web platform
|
|
482
482
|
}
|
|
483
|
+
|
|
484
|
+
aiAssist(_args: AiAssistRequest): void {
|
|
485
|
+
// No implementation in web platform
|
|
486
|
+
}
|
|
483
487
|
}
|
package/windows_platform.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PlatformInterface } from "./platform_interface";
|
|
2
|
-
import { Factory, MyAxiosInstance, Unit } from "./types";
|
|
2
|
+
import { AiAssistRequest, Factory, MyAxiosInstance, Unit } from "./types";
|
|
3
3
|
|
|
4
4
|
export class WindwosMiniAppPlatform implements PlatformInterface {
|
|
5
5
|
// private messagePort?: MessagePort;
|
|
@@ -128,4 +128,9 @@ export class WindwosMiniAppPlatform implements PlatformInterface {
|
|
|
128
128
|
// @ts-ignore
|
|
129
129
|
window.miniapp?.setProgress(precentage);
|
|
130
130
|
}
|
|
131
|
+
|
|
132
|
+
aiAssist(args: AiAssistRequest): void {
|
|
133
|
+
// @ts-ignore
|
|
134
|
+
window.miniapp?.aiAssist(args);
|
|
135
|
+
}
|
|
131
136
|
}
|