@cpzxrobot/sdk 1.3.93 → 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_type_gateway.ts +8 -4
- package/dist/ai_gateway.js +3 -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_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
|
@@ -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
|
}
|