@fatehan/tsrp 1.0.28 → 1.0.31

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AreaSummaryReviewRequest, AreaSummaryReviewResponse, ChartRequest, ChartResponse, CommandHistoryRequest, CommandHistoryResponse, DashboardIndividualRequest, DashboardIndividualResponse, DeviceDataRequest, DeviceDataResponse, LogRequest, LogResponse, RouteReviewRequest, RouteReviewResponse, RouteStopRequest, RouteStopResponse, TripPerformanceRequest, TripPerformanceResponse, TripReportRequest, TripReportResponse, WorkCycleRequest, WorkCycleResponse } from "./fatehan/reports/report";
1
+ import { AreaSummaryReviewRequest, AreaSummaryReviewResponse, ChartRequest, ChartResponse, CommandHistoryRequest, CommandHistoryResponse, DashboardIndividualRequest, DashboardIndividualResponse, DeviceDataRequest, DeviceDataResponse, LogRequest, LogResponse, RouteReviewRequest, RouteReviewResponse, RouteStopRequest, RouteStopResponse, SystemIoRequest, SystemIoResponse, TripPerformanceRequest, TripPerformanceResponse, TripReportRequest, TripReportResponse, WorkCycleRequest, WorkCycleResponse } from "./fatehan/reports/report";
2
2
  export declare class ReportService {
3
3
  private readonly url;
4
4
  private readonly namespace;
@@ -15,5 +15,6 @@ export declare class ReportService {
15
15
  WorkCycleReport(request: WorkCycleRequest): Promise<WorkCycleResponse>;
16
16
  CommandHistoryReport(request: CommandHistoryRequest): Promise<CommandHistoryResponse>;
17
17
  ChartReport(request: ChartRequest, responses: (chunk: ChartResponse) => void): Promise<void>;
18
+ SystemIoReport(request: SystemIoRequest): Promise<SystemIoResponse>;
18
19
  }
19
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,sBAAs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pD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAyBnE,uBAAuB,CAC5B,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,yBAAyB,CAAC;IAwB9B,eAAe,CACpB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,iBAAiB,CAAC;IAwBtB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAmB/E,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI;IAiClF,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CA4B3E"}
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ReportService = void 0;
4
4
  const report_1 = require("./fatehan/reports/report");
5
+ const system_io_1 = require("./store/system.io");
5
6
  class ReportService {
6
7
  constructor(url, authorization, organizationId) {
7
8
  this.namespace = "com.fatehan.reports.ReportService";
@@ -197,5 +198,31 @@ class ReportService {
197
198
  }
198
199
  }
199
200
  ;
201
+ SystemIoReport(request) {
202
+ return new Promise(async (resolve, reject) => {
203
+ let systemIo = (0, system_io_1.getSystemIoCache)();
204
+ if (systemIo != null) {
205
+ resolve({
206
+ cost: 0,
207
+ ios: systemIo,
208
+ records: systemIo.length,
209
+ });
210
+ return;
211
+ }
212
+ const response = await fetch(`${this.url}/${this.namespace}/SystemIoReport`, {
213
+ method: "POST",
214
+ headers: this.headers,
215
+ body: report_1.SystemIoRequest.encode(request).finish(),
216
+ });
217
+ if (response.ok) {
218
+ let systemIo = report_1.SystemIoResponse.decode(new Uint8Array(await response.arrayBuffer()));
219
+ (0, system_io_1.setSystemIoCache)(systemIo.ios);
220
+ resolve(systemIo);
221
+ }
222
+ else {
223
+ reject(await response.text());
224
+ }
225
+ });
226
+ }
200
227
  }
201
228
  exports.ReportService = ReportService;
@@ -7,10 +7,12 @@ const vitest_1 = require("vitest");
7
7
  const index_1 = require("./index");
8
8
  const report_1 = require("./fatehan/reports/report");
9
9
  const long_1 = __importDefault(require("long"));
10
+ const models_1 = require("./fatehan/models/models");
11
+ const system_io_1 = __importDefault(require("./system.io"));
10
12
  (0, vitest_1.describe)("ReportService", () => {
11
13
  let url = "http://report.myavl.ir:1272";
12
- let token = "1000028|oOCcnfZrHsjscQbnJcF8yvzSVRQPgzuH2nC1gat186e7a9f6";
13
- let organization = "1000000";
14
+ let token = "5|gvRWOzVBVN3a6Q7iajws2uV9TEVELEK81H3RCpzO85369b27";
15
+ let organization = "1000001";
14
16
  let c = new index_1.ReportService(url, token, organization);
15
17
  (0, vitest_1.it)("TripPerformanceReport", async () => {
16
18
  let res = await c.TripPerformanceReport({
@@ -33,7 +35,7 @@ const long_1 = __importDefault(require("long"));
33
35
  });
34
36
  (0, vitest_1.it)("RouteReviewReport", async () => {
35
37
  let res = await c.RouteReviewReport({
36
- deviceId: long_1.default.fromInt(124251414),
38
+ deviceId: long_1.default.fromInt(7744),
37
39
  startedAt: new Date("2025-04-01 00:00:00"),
38
40
  finishedAt: new Date("2025-04-22 00:00:00"),
39
41
  includeTrip: true,
@@ -73,6 +75,10 @@ const long_1 = __importDefault(require("long"));
73
75
  });
74
76
  console.log("AreaSummaryReviewReport", res);
75
77
  });
78
+ (0, vitest_1.it)("SystemIoReport", async () => {
79
+ let res = await c.SystemIoReport({});
80
+ console.log("SystemIoReport", res);
81
+ });
76
82
  (0, vitest_1.it)("WorkCycleReport", async () => {
77
83
  let res = await c.WorkCycleReport({
78
84
  areaStopSeconds: 10,
@@ -93,4 +99,282 @@ const long_1 = __importDefault(require("long"));
93
99
  console.log(report_1.ChartResponse.toJSON(chunk));
94
100
  });
95
101
  });
102
+ (0, vitest_1.it)("Io", async () => {
103
+ let devIo = {
104
+ formula: "($speed / 3.6)",
105
+ name: "سرعت",
106
+ type: models_1.SystemIoType.FLOAT,
107
+ activeStyle: {
108
+ color: "#3a3a3a",
109
+ name: "سرعت"
110
+ },
111
+ inactiveStyle: {
112
+ color: '#a3a3a3',
113
+ name: "سرعت"
114
+ },
115
+ description: "سرعت خودرو",
116
+ unit: "m/h",
117
+ deviceId: long_1.default.fromNumber(7744),
118
+ organizationId: long_1.default.fromNumber(7744),
119
+ id: long_1.default.fromNumber(1),
120
+ };
121
+ let systemIos = await c.SystemIoReport({});
122
+ let result = (0, system_io_1.default)(systemIos.ios, [devIo], {
123
+ deviceId: long_1.default.fromNumber(7744),
124
+ gpsTime: new Date("2025-04-21T09:06:06.000Z"),
125
+ latitude: 32.61252975463867,
126
+ longitude: 51.60394287109375,
127
+ altitude: 1634,
128
+ angle: 319,
129
+ speed: 38,
130
+ satellite: 20,
131
+ ignition: true,
132
+ mileage: long_1.default.fromNumber(64438820),
133
+ compact: {
134
+ ioElement: {
135
+ gsm: 100,
136
+ sleepMode: 0,
137
+ gnss: 1,
138
+ pdop: undefined,
139
+ hdop: 6,
140
+ externalVoltage: 13837,
141
+ cellId: 27760,
142
+ areaCode: 12540,
143
+ batteryVoltage: 4097,
144
+ batteryCurrent: long_1.default.fromNumber(0),
145
+ batteryPercent: 97,
146
+ operatorCode: 43235,
147
+ tripOdometer: 10,
148
+ ai1: 0,
149
+ ai2: undefined,
150
+ ai3: undefined,
151
+ ai4: undefined,
152
+ di1: true,
153
+ di2: undefined,
154
+ di3: undefined,
155
+ di4: undefined,
156
+ do1: false,
157
+ do2: undefined,
158
+ do3: undefined,
159
+ do4: undefined,
160
+ fuelRateGps: 787,
161
+ fuelUsedGps: 2181327,
162
+ axisX: -192,
163
+ axisY: 317,
164
+ axisZ: -60,
165
+ iccId: long_1.default.fromNumber(408497408),
166
+ sdStatus: undefined,
167
+ iButton: undefined,
168
+ dallas: undefined,
169
+ lls: undefined,
170
+ eye: undefined,
171
+ ble: undefined,
172
+ driver: undefined,
173
+ msp500: undefined,
174
+ rfid: undefined,
175
+ ecoScore: undefined,
176
+ networkType: undefined,
177
+ pulseCounterDin1: undefined,
178
+ pulseCounterDin2: undefined,
179
+ btStatus: undefined,
180
+ barcodeId: undefined,
181
+ instantMovement: undefined,
182
+ ul20202SensorFuelLevel: undefined,
183
+ ul20202SensorStatus: undefined,
184
+ groundSense: undefined,
185
+ iso6709Coordinates: undefined,
186
+ umtsLteCellId: undefined,
187
+ ainSpeed: undefined,
188
+ wakeReason: undefined,
189
+ axlCalibrationStatus: undefined,
190
+ frequencyDin1: undefined,
191
+ frequencyDin2: undefined,
192
+ ignition: undefined,
193
+ idling: false,
194
+ towing: false,
195
+ unplug: false,
196
+ jamming: false,
197
+ movement: true,
198
+ dataMode: 1,
199
+ speed: 38,
200
+ temperature: undefined,
201
+ slopeX: undefined,
202
+ slopeY: undefined,
203
+ slopeZ: undefined,
204
+ humidity: undefined,
205
+ fuelFlow: undefined,
206
+ doorCar: undefined,
207
+ realtime: undefined,
208
+ positioning: undefined,
209
+ adminPhoneNumber: undefined,
210
+ fuelCounter: undefined,
211
+ impulseFrequency1: undefined,
212
+ impulseCounter1: undefined,
213
+ impulseRpm1: undefined,
214
+ impulseFrequency2: undefined,
215
+ impulseCounter2: undefined,
216
+ impulseRpm2: undefined,
217
+ impulseFrequency3: undefined,
218
+ impulseCounter3: undefined,
219
+ impulseRpm3: undefined,
220
+ impulseFrequency4: undefined,
221
+ impulseCounter4: undefined,
222
+ impulseRpm4: undefined,
223
+ numberOfData: undefined,
224
+ rfidCom2: undefined,
225
+ imsi: undefined,
226
+ ultrasonicFuelLevel1: undefined,
227
+ ultrasonicFuelLevel2: undefined,
228
+ ultrasonicSoftwareStatus1: undefined,
229
+ ultrasonicSoftwareStatus2: undefined,
230
+ oneWireHumidity1: undefined,
231
+ oneWireHumidity2: undefined,
232
+ oneWireHumidity3: undefined,
233
+ oneWireHumidity4: undefined,
234
+ oneWireHumidity5: undefined,
235
+ oneWireHumidity6: undefined,
236
+ imei: undefined,
237
+ noSimCounter: undefined,
238
+ connectivityQuality: undefined,
239
+ },
240
+ eventualIoElements: {
241
+ geoFenceZone01: undefined,
242
+ geoFenceZone02: undefined,
243
+ geoFenceZone03: undefined,
244
+ geoFenceZone04: undefined,
245
+ geoFenceZone05: undefined,
246
+ geoFenceZone06: undefined,
247
+ geoFenceZone07: undefined,
248
+ geoFenceZone08: undefined,
249
+ geoFenceZone09: undefined,
250
+ geoFenceZone10: undefined,
251
+ geoFenceZone11: undefined,
252
+ geoFenceZone12: undefined,
253
+ geoFenceZone13: undefined,
254
+ geoFenceZone14: undefined,
255
+ geoFenceZone15: undefined,
256
+ geoFenceZone16: undefined,
257
+ geoFenceZone17: undefined,
258
+ geoFenceZone18: undefined,
259
+ geoFenceZone19: undefined,
260
+ geoFenceZone20: undefined,
261
+ geoFenceZone21: undefined,
262
+ geoFenceZone22: undefined,
263
+ geoFenceZone23: undefined,
264
+ geoFenceZone24: undefined,
265
+ geoFenceZone25: undefined,
266
+ geoFenceZone26: undefined,
267
+ geoFenceZone27: undefined,
268
+ geoFenceZone28: undefined,
269
+ geoFenceZone29: undefined,
270
+ geoFenceZone30: undefined,
271
+ geoFenceZone31: undefined,
272
+ geoFenceZone32: undefined,
273
+ geoFenceZone33: undefined,
274
+ geoFenceZone34: undefined,
275
+ geoFenceZone35: undefined,
276
+ geoFenceZone36: undefined,
277
+ geoFenceZone37: undefined,
278
+ geoFenceZone38: undefined,
279
+ geoFenceZone39: undefined,
280
+ geoFenceZone40: undefined,
281
+ geoFenceZone41: undefined,
282
+ geoFenceZone42: undefined,
283
+ geoFenceZone43: undefined,
284
+ geoFenceZone44: undefined,
285
+ geoFenceZone45: undefined,
286
+ geoFenceZone46: undefined,
287
+ geoFenceZone47: undefined,
288
+ geoFenceZone48: undefined,
289
+ geoFenceZone49: undefined,
290
+ geoFenceZone50: undefined,
291
+ greenDrivingType: undefined,
292
+ greenDrivingValue: undefined,
293
+ crashDetection: undefined,
294
+ immobilizer: undefined,
295
+ iccId2: long_1.default.fromNumber(1871890036),
296
+ greenDrivingEventDuration: undefined,
297
+ alarm: undefined,
298
+ ecoMaximum: undefined,
299
+ ecoAverage: undefined,
300
+ ecoDuration: undefined,
301
+ drivingState: undefined,
302
+ drivingRecords: undefined,
303
+ crashEventCounter: undefined,
304
+ gnssJamming: undefined,
305
+ privateMode: undefined,
306
+ ignitionOnCounter: undefined,
307
+ motorcycleFallDetection: undefined,
308
+ trip: undefined,
309
+ overSpeeding: undefined,
310
+ crashTraceData: undefined,
311
+ bloodAlcoholContent: undefined,
312
+ autoGeoFence: undefined,
313
+ iccId3: undefined,
314
+ geoFenceZone51: undefined,
315
+ geoFenceZone52: undefined,
316
+ geoFenceZone53: undefined,
317
+ geoFenceZone54: undefined,
318
+ geoFenceZone55: undefined,
319
+ geoFenceZone56: undefined,
320
+ geoFenceZone57: undefined,
321
+ geoFenceZone58: undefined,
322
+ geoFenceZone59: undefined,
323
+ geoFenceZone60: undefined,
324
+ geoFenceZone61: undefined,
325
+ geoFenceZone62: undefined,
326
+ geoFenceZone63: undefined,
327
+ geoFenceZone64: undefined,
328
+ geoFenceZone65: undefined,
329
+ geoFenceZone66: undefined,
330
+ geoFenceZone67: undefined,
331
+ geoFenceZone68: undefined,
332
+ geoFenceZone69: undefined,
333
+ geoFenceZone70: undefined,
334
+ geoFenceZone71: undefined,
335
+ geoFenceZone72: undefined,
336
+ geoFenceZone73: undefined,
337
+ geoFenceZone74: undefined,
338
+ geoFenceZone75: undefined,
339
+ geoFenceZone76: undefined,
340
+ geoFenceZone77: undefined,
341
+ geoFenceZone78: undefined,
342
+ geoFenceZone79: undefined,
343
+ geoFenceZone80: undefined,
344
+ geoFenceZone81: undefined,
345
+ geoFenceZone82: undefined,
346
+ geoFenceZone83: undefined,
347
+ geoFenceZone84: undefined,
348
+ geoFenceZone85: undefined,
349
+ geoFenceZone86: undefined,
350
+ geoFenceZone87: undefined,
351
+ geoFenceZone88: undefined,
352
+ geoFenceZone89: undefined,
353
+ geoFenceZone90: undefined,
354
+ geoFenceZone91: undefined,
355
+ geoFenceZone92: undefined,
356
+ geoFenceZone93: undefined,
357
+ geoFenceZone94: undefined,
358
+ geoFenceZone95: undefined,
359
+ geoFenceZone96: undefined,
360
+ geoFenceZone97: undefined,
361
+ geoFenceZone98: undefined,
362
+ geoFenceZone99: undefined,
363
+ geoFenceZone100: undefined,
364
+ },
365
+ obdElements: undefined,
366
+ obdOemElements: undefined,
367
+ bleSensorsIoElements: undefined,
368
+ canAdaptersElements: undefined,
369
+ alerts: [
370
+ 0,
371
+ ],
372
+ alertValues: {},
373
+ adas: undefined,
374
+ fms: undefined,
375
+ unknownIos: {},
376
+ },
377
+ });
378
+ console.log(result);
379
+ });
96
380
  });
@@ -0,0 +1,4 @@
1
+ import { SystemIo } from "../fatehan/models/models";
2
+ export declare function setSystemIoCache(data: SystemIo[]): void;
3
+ export declare function getSystemIoCache(): SystemIo[];
4
+ //# sourceMappingURL=system.io.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.io.d.ts","sourceRoot":"","sources":["../../src/store/system.io.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAIpD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAEhD;AAED,wBAAgB,gBAAgB,IAAI,QAAQ,EAAE,CAE7C"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setSystemIoCache = setSystemIoCache;
4
+ exports.getSystemIoCache = getSystemIoCache;
5
+ let ios;
6
+ function setSystemIoCache(data) {
7
+ ios = data;
8
+ }
9
+ function getSystemIoCache() {
10
+ return ios;
11
+ }
@@ -0,0 +1,5 @@
1
+ import { DeviceIo, ShownIo, SystemIo } from "./fatehan/models/models";
2
+ import { Data } from "./fatehan/packets/dataModel";
3
+ declare const SystemIoCast: (systemIo: SystemIo[], deviceIo: DeviceIo[], data: Data) => ShownIo[];
4
+ export default SystemIoCast;
5
+ //# sourceMappingURL=system.io.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.io.d.ts","sourceRoot":"","sources":["../src/system.io.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAElD,QAAA,MAAM,YAAY,GACd,UAAU,QAAQ,EAAE,EACpB,UAAU,QAAQ,EAAE,EACpB,MAAM,IAAI,KACX,OAAO,EA4CT,CAAA;AAuBD,eAAe,YAAY,CAAA"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const SystemIoCast = (systemIo, deviceIo, data) => {
4
+ let list = [];
5
+ for (let i = 0; i < systemIo.length; i++) {
6
+ const value = getNestedPropertyValue(data, systemIo[i].key);
7
+ if (value != null) {
8
+ list.push({
9
+ value: value,
10
+ name: systemIo[i].name,
11
+ unit: systemIo[i].unit,
12
+ style: systemIo[i].activeStyle,
13
+ description: systemIo[i].description,
14
+ });
15
+ }
16
+ }
17
+ for (let i = 0; i < deviceIo.length; i++) {
18
+ let items = extractVariables(deviceIo[i].formula);
19
+ let formula = deviceIo[i].formula;
20
+ let hasIos = true;
21
+ for (let i = 0; i < items.length; i++) {
22
+ const value = getNestedPropertyValue(data, items[i]);
23
+ if (value == null) {
24
+ hasIos = false;
25
+ break;
26
+ }
27
+ formula = formula.replace(new RegExp("\\$" + items[i], 'g'), value);
28
+ }
29
+ if (!hasIos) {
30
+ continue;
31
+ }
32
+ list.push({
33
+ value: eval(formula),
34
+ name: deviceIo[i].name,
35
+ unit: deviceIo[i].unit,
36
+ style: deviceIo[i].activeStyle,
37
+ description: deviceIo[i].description,
38
+ });
39
+ }
40
+ return list;
41
+ };
42
+ function extractVariables(str) {
43
+ const matches = str.match(/\$(\w+(?:\.\w+)*)/g);
44
+ if (!matches)
45
+ return [];
46
+ return matches.map(match => match.substring(1));
47
+ }
48
+ function getNestedPropertyValue(obj, propertyPath) {
49
+ const properties = propertyPath.split('.');
50
+ let currentObj = obj;
51
+ for (const property of properties) {
52
+ if (!Object.prototype.hasOwnProperty.call(currentObj, property)) {
53
+ return null;
54
+ }
55
+ currentObj = currentObj[property];
56
+ if (currentObj === null || currentObj === undefined) {
57
+ return null;
58
+ }
59
+ }
60
+ return String(currentObj);
61
+ }
62
+ exports.default = SystemIoCast;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fatehan/tsrp",
3
- "version": "1.0.28",
3
+ "version": "1.0.31",
4
4
  "description": "fatehan main models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/readme.md CHANGED
@@ -14,15 +14,15 @@ protoc \
14
14
 
15
15
  ## GRPC Including
16
16
 
17
- ```cmd
17
+ <!-- ```cmd
18
18
  protoc \
19
19
  --plugin=protoc-gen-ts_proto=/usr/bin/protoc-gen-ts_proto \
20
20
  -I ./src/fatehan \
21
21
  -I ../protocols \
22
22
  --ts_proto_out=./src/fatehan \
23
- --ts_proto_opt=outputServices=grpc-web,outputClientImpl=grpc-web,esModuleInterop=true,outputEncodeMethods=true,outputJsonMethods=true \
23
+ --ts_proto_opt=outputServices=none,outputClientImpl=false,esModuleInterop=true,outputEncodeMethods=true,outputJsonMethods=true,useOptionals=messages,forceLong=long \
24
24
  ../protocols/**/*.proto
25
- ```
25
+ ``` -->
26
26
 
27
27
  ### Build
28
28