@fatehan/tsrp 1.3.10 → 1.3.12

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/dist/api.d.ts CHANGED
@@ -14,6 +14,6 @@ export declare class ApiService {
14
14
  ConfigIndex(request: import("./fatehan/services/api").ConfigRequest): Promise<import("./fatehan/services/api").ConfigResponse>;
15
15
  UserIndex(request: import("./fatehan/services/api").UserRequest): Promise<import("./fatehan/services/api").UserResponse>;
16
16
  IoIndex(request: import("./fatehan/services/api").IoRequest): Promise<import("./fatehan/services/api").IoResponse>;
17
- SystemIoCast(data: Data): Promise<ShownIo[]>;
17
+ IoCast(data: Data): Promise<ShownIo[]>;
18
18
  }
19
19
  //# sourceMappingURL=api.d.ts.map
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAUnD,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6C;IACvE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAiB;gBAEvC,GAAG,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc;YAKzC,KAAK;IAgCN,OAAO,CAClB,OAAO,EAAE,OAAO,wBAAwB,EAAE,SAAS,GAClD,OAAO,CAAC,OAAO,wBAAwB,EAAE,UAAU,CAAC;IAK1C,WAAW,CACtB,OAAO,EAAE,OAAO,wBAAwB,EAAE,aAAa,GACtD,OAAO,CAAC,OAAO,wBAAwB,EAAE,cAAc,CAAC;IAO9C,UAAU,CACrB,OAAO,EAAE,OAAO,wBAAwB,EAAE,iBAAiB,GAC1D,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,CACrB,OAAO,EAAE,OAAO,wBAAwB,EAAE,iBAAiB,GAC1D,OAAO,CAAC,OAAO,wBAAwB,EAAE,kBAAkB,CAAC;IAYlD,SAAS,CACpB,OAAO,EAAE,OAAO,wBAAwB,EAAE,gBAAgB,GACzD,OAAO,CAAC,OAAO,wBAAwB,EAAE,iBAAiB,CAAC;IAYjD,WAAW,CACtB,OAAO,EAAE,OAAO,wBAAwB,EAAE,aAAa,GACtD,OAAO,CAAC,OAAO,wBAAwB,EAAE,cAAc,CAAC;IAO9C,SAAS,CACpB,OAAO,EAAE,OAAO,wBAAwB,EAAE,WAAW,GACpD,OAAO,CAAC,OAAO,wBAAwB,EAAE,YAAY,CAAC;IAO5C,OAAO,CAClB,OAAO,EAAE,OAAO,wBAAwB,EAAE,SAAS,GAClD,OAAO,CAAC,OAAO,wBAAwB,EAAE,UAAU,CAAC;IAwC1C,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAgBpD"}
package/dist/api.js CHANGED
@@ -93,64 +93,46 @@ class ApiService {
93
93
  }
94
94
  async IoIndex(request) {
95
95
  if (request.deviceId != null) {
96
- try {
97
- const cachedIo = (0, system_io_1.getDeviceIoCache)(request.deviceId.toString());
98
- if (cachedIo != null && cachedIo != undefined) {
99
- return { cost: 0, ios: cachedIo, records: cachedIo.length };
100
- }
101
- const { IoRequest, IoResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/services/api")));
102
- const response = await this._call("IoIndex", request, IoRequest, IoResponse);
103
- if (response.records > 0) {
104
- (0, system_io_1.setDeviceIoCache)(request.deviceId.toString(), response.ios);
105
- }
106
- return response;
96
+ // trying to fetch from cache
97
+ const cachedIo = (0, system_io_1.getDeviceIoCache)(request.deviceId.toString());
98
+ if (cachedIo != null && cachedIo != undefined) {
99
+ return { cost: 0, ios: cachedIo, records: cachedIo.length };
107
100
  }
108
- catch (ex) {
109
- console.error("device io exception", ex);
110
- return api_1.IoResponse.create({ ios: [] });
101
+ // trying to fetch from server
102
+ const { IoRequest, IoResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/services/api")));
103
+ const response = await this._call("IoIndex", request, IoRequest, IoResponse);
104
+ if (response.records > 0) {
105
+ (0, system_io_1.setDeviceIoCache)(request.deviceId.toString(), response.ios);
111
106
  }
107
+ return response;
112
108
  }
113
109
  else {
114
- try {
115
- const cachedIo = (0, system_io_1.getSystemIoCache)();
116
- if (cachedIo != null && cachedIo != undefined) {
117
- return { cost: 0, ios: cachedIo, records: cachedIo.length };
118
- }
119
- const { IoRequest, IoResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/services/api")));
120
- const response = await this._call("IoIndex", request, IoRequest, IoResponse);
121
- (0, system_io_1.setSystemIoCache)(response.ios);
122
- return response;
110
+ // trying to fetch from cache
111
+ const cachedIo = (0, system_io_1.getSystemIoCache)();
112
+ if (cachedIo != null && cachedIo != undefined) {
113
+ return { cost: 0, ios: cachedIo, records: cachedIo.length };
123
114
  }
124
- catch (ex) {
125
- console.error("device io exception", ex);
126
- return api_1.IoResponse.create({ ios: [] });
115
+ // trying to fetch from server
116
+ const { IoRequest, IoResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/services/api")));
117
+ const response = await this._call("IoIndex", request, IoRequest, IoResponse);
118
+ if (response.records > 0) {
119
+ (0, system_io_1.setSystemIoCache)(response.ios);
127
120
  }
121
+ return response;
128
122
  }
129
123
  }
130
- async SystemIoCast(data) {
131
- var _a, _b;
132
- var ioData, deviceIo;
133
- try {
134
- const result = await this.IoIndex({});
135
- if (!((_a = result === null || result === void 0 ? void 0 : result.ios) === null || _a === void 0 ? void 0 : _a.length))
136
- return [];
137
- ioData = result.ios;
138
- }
139
- catch (error) {
140
- console.error("Failed to fetch SystemIoReport in SystemIoCast:", error);
141
- return [];
142
- }
143
- try {
144
- const result = await this.IoIndex({ deviceId: data.deviceId });
145
- if (!((_b = result === null || result === void 0 ? void 0 : result.ios) === null || _b === void 0 ? void 0 : _b.length))
146
- return [];
147
- deviceIo = result.ios;
124
+ async IoCast(data) {
125
+ var ioData = api_1.IoResponse.create({ ios: [] });
126
+ var deviceIo = api_1.IoResponse.create({ ios: [] });
127
+ const systemIoResult = await this.IoIndex({});
128
+ if (systemIoResult != undefined && systemIoResult != null) {
129
+ ioData = systemIoResult;
148
130
  }
149
- catch (error) {
150
- console.error("Failed to fetch DeviceIoReport in SystemIoCast:", error);
151
- return [];
131
+ const deviceIoResult = await this.IoIndex({ deviceId: data.deviceId });
132
+ if (deviceIoResult != undefined && deviceIoResult != null) {
133
+ deviceIo = deviceIoResult;
152
134
  }
153
- return (0, system_io_2.default)(ioData, deviceIo, data);
135
+ return (0, system_io_2.default)(ioData.ios, deviceIo.ios, data);
154
136
  }
155
137
  }
156
138
  exports.ApiService = ApiService;
@@ -1 +1 @@
1
- {"version":3,"file":"system.io.d.ts","sourceRoot":"","sources":["../src/system.io.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,QAAQ,EAET,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAEnD,QAAA,MAAM,YAAY,GAChB,UAAU,QAAQ,EAAE,EACpB,UAAU,QAAQ,EAAE,EACpB,MAAM,IAAI,KACT,OAAO,EA6DT,CAAC;AAuBF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"system.io.d.ts","sourceRoot":"","sources":["../src/system.io.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,QAAQ,EAET,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAEnD,QAAA,MAAM,YAAY,GAChB,UAAU,QAAQ,EAAE,EACpB,UAAU,QAAQ,EAAE,EACpB,MAAM,IAAI,KACT,OAAO,EAqET,CAAC;AAuBF,eAAe,YAAY,CAAC"}
package/dist/system.io.js CHANGED
@@ -3,6 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const devices_1 = require("./fatehan/devices/devices");
4
4
  const SystemIoCast = (systemIo, deviceIo, data) => {
5
5
  let list = [];
6
+ if (systemIo == undefined || systemIo == null) {
7
+ systemIo = [];
8
+ }
9
+ if (deviceIo == undefined || deviceIo == null) {
10
+ deviceIo = [];
11
+ }
6
12
  const tempSystemIo = [...systemIo, ...deviceIo].sort((a, b) => a.sord - b.sord);
7
13
  tempSystemIo.forEach((io) => {
8
14
  let items = extractVariables(io.formula);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fatehan/tsrp",
3
- "version": "1.3.10",
3
+ "version": "1.3.12",
4
4
  "description": "fatehan main models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",