@cpzxrobot/sdk 1.3.89 → 1.3.90

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
@@ -210,12 +210,13 @@ export class DeviceGateway extends Object {
210
210
  * @param factoryId 工厂ID
211
211
  * @returns Promise 包含报警规则列表
212
212
  */
213
- list: async (factoryId: number): Promise<AlarmRuleListResponse> => {
213
+ list: async (factoryId?: number): Promise<AlarmRuleListResponse> => {
214
214
  const axios = await this.context.ready;
215
215
 
216
216
  // 参数验证
217
217
  if (!factoryId) {
218
- throw new Error('工厂ID不能为空');
218
+ let farm = await this.context.user.getSelectedFarm();
219
+ factoryId = farm?.id;
219
220
  }
220
221
 
221
222
  return axios.get(`/api/v2/device/stat/alarms/rule`, {
@@ -259,7 +260,8 @@ export class DeviceGateway extends Object {
259
260
 
260
261
  // 参数验证
261
262
  if (!request.factoryId) {
262
- throw new Error('工厂ID不能为空');
263
+ let farm = await this.context.user.getSelectedFarm();
264
+ request.factoryId = farm?.id;
263
265
  }
264
266
  if (!request.ruleName) {
265
267
  throw new Error('规则名称不能为空');
@@ -158,7 +158,8 @@ class DeviceGateway extends Object {
158
158
  const axios = yield this.context.ready;
159
159
  // 参数验证
160
160
  if (!factoryId) {
161
- throw new Error('工厂ID不能为空');
161
+ let farm = yield this.context.user.getSelectedFarm();
162
+ factoryId = farm === null || farm === void 0 ? void 0 : farm.id;
162
163
  }
163
164
  return axios.get(`/api/v2/device/stat/alarms/rule`, {
164
165
  params: { factoryId }
@@ -196,7 +197,8 @@ class DeviceGateway extends Object {
196
197
  const axios = yield this.context.ready;
197
198
  // 参数验证
198
199
  if (!request.factoryId) {
199
- throw new Error('工厂ID不能为空');
200
+ let farm = yield this.context.user.getSelectedFarm();
201
+ request.factoryId = farm === null || farm === void 0 ? void 0 : farm.id;
200
202
  }
201
203
  if (!request.ruleName) {
202
204
  throw new Error('规则名称不能为空');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.89",
3
+ "version": "1.3.90",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {