@fatehan/tsrp 1.3.31 → 1.3.33

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.
@@ -8,7 +8,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
8
8
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
9
  };
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.FilterScope = exports.FilterConditions = exports.AreaIndexResponse = exports.AreaIndexRequest = exports.MeResponse = exports.MeRequest = exports.DeviceShowResponse = exports.DeviceShowRequest = exports.DeviceResponse = exports.DeviceRequest_QueryFilterEntry = exports.DeviceRequest = exports.UserResponse = exports.UserRequest_QueryFilterEntry = exports.UserRequest = exports.ConfigResponse_AppSecConfig = exports.ConfigResponse_AppDesignConfig = exports.ConfigResponse = exports.ConfigRequest = exports.IoResponse = exports.IoRequest = exports.AuthResponse = exports.AuthRequest = exports.protobufPackage = void 0;
11
+ exports.FilterScope = exports.FilterConditions = exports.AlertAndNotifications = exports.AreaIndexResponse = exports.AreaIndexRequest = exports.MeResponse = exports.MeRequest = exports.DeviceShowResponse = exports.DeviceShowRequest = exports.DeviceResponse = exports.DeviceRequest_QueryFilterEntry = exports.DeviceRequest = exports.UserResponse = exports.UserRequest_QueryFilterEntry = exports.UserRequest = exports.ConfigResponse_AppSecConfig = exports.ConfigResponse_AppDesignConfig = exports.ConfigResponse = exports.ConfigRequest = exports.IoResponse = exports.IoRequest = exports.AuthResponse = exports.AuthRequest = exports.protobufPackage = void 0;
12
12
  /* eslint-disable */
13
13
  const wire_1 = require("@bufbuild/protobuf/wire");
14
14
  const long_1 = __importDefault(require("long"));
@@ -18,6 +18,7 @@ const financial_1 = require("../financial/financial");
18
18
  const authentication_1 = require("../identities/authentication");
19
19
  const identities_1 = require("../identities/identities");
20
20
  const models_1 = require("../models/models");
21
+ const notify_1 = require("../notifies/notify");
21
22
  const repositories_1 = require("./repositories");
22
23
  exports.protobufPackage = "com.fatehan.services";
23
24
  function createBaseAuthRequest() {
@@ -536,6 +537,9 @@ function createBaseConfigResponse_AppDesignConfig() {
536
537
  telegram: "",
537
538
  primaryIconColor: "",
538
539
  secondaryIconColor: "",
540
+ defaultRoleId: "",
541
+ enableRegistration: "",
542
+ defaultRegisterOrganizationId: "",
539
543
  };
540
544
  }
541
545
  exports.ConfigResponse_AppDesignConfig = {
@@ -576,6 +580,15 @@ exports.ConfigResponse_AppDesignConfig = {
576
580
  if (message.secondaryIconColor !== "") {
577
581
  writer.uint32(98).string(message.secondaryIconColor);
578
582
  }
583
+ if (message.defaultRoleId !== "") {
584
+ writer.uint32(106).string(message.defaultRoleId);
585
+ }
586
+ if (message.enableRegistration !== "") {
587
+ writer.uint32(114).string(message.enableRegistration);
588
+ }
589
+ if (message.defaultRegisterOrganizationId !== "") {
590
+ writer.uint32(122).string(message.defaultRegisterOrganizationId);
591
+ }
579
592
  return writer;
580
593
  },
581
594
  decode(input, length) {
@@ -669,6 +682,27 @@ exports.ConfigResponse_AppDesignConfig = {
669
682
  message.secondaryIconColor = reader.string();
670
683
  continue;
671
684
  }
685
+ case 13: {
686
+ if (tag !== 106) {
687
+ break;
688
+ }
689
+ message.defaultRoleId = reader.string();
690
+ continue;
691
+ }
692
+ case 14: {
693
+ if (tag !== 114) {
694
+ break;
695
+ }
696
+ message.enableRegistration = reader.string();
697
+ continue;
698
+ }
699
+ case 15: {
700
+ if (tag !== 122) {
701
+ break;
702
+ }
703
+ message.defaultRegisterOrganizationId = reader.string();
704
+ continue;
705
+ }
672
706
  }
673
707
  if ((tag & 7) === 4 || tag === 0) {
674
708
  break;
@@ -691,6 +725,11 @@ exports.ConfigResponse_AppDesignConfig = {
691
725
  telegram: isSet(object.telegram) ? globalThis.String(object.telegram) : "",
692
726
  primaryIconColor: isSet(object.primaryIconColor) ? globalThis.String(object.primaryIconColor) : "",
693
727
  secondaryIconColor: isSet(object.secondaryIconColor) ? globalThis.String(object.secondaryIconColor) : "",
728
+ defaultRoleId: isSet(object.defaultRoleId) ? globalThis.String(object.defaultRoleId) : "",
729
+ enableRegistration: isSet(object.enableRegistration) ? globalThis.String(object.enableRegistration) : "",
730
+ defaultRegisterOrganizationId: isSet(object.defaultRegisterOrganizationId)
731
+ ? globalThis.String(object.defaultRegisterOrganizationId)
732
+ : "",
694
733
  };
695
734
  },
696
735
  toJSON(message) {
@@ -731,13 +770,22 @@ exports.ConfigResponse_AppDesignConfig = {
731
770
  if (message.secondaryIconColor !== "") {
732
771
  obj.secondaryIconColor = message.secondaryIconColor;
733
772
  }
773
+ if (message.defaultRoleId !== "") {
774
+ obj.defaultRoleId = message.defaultRoleId;
775
+ }
776
+ if (message.enableRegistration !== "") {
777
+ obj.enableRegistration = message.enableRegistration;
778
+ }
779
+ if (message.defaultRegisterOrganizationId !== "") {
780
+ obj.defaultRegisterOrganizationId = message.defaultRegisterOrganizationId;
781
+ }
734
782
  return obj;
735
783
  },
736
784
  create(base) {
737
785
  return exports.ConfigResponse_AppDesignConfig.fromPartial(base !== null && base !== void 0 ? base : {});
738
786
  },
739
787
  fromPartial(object) {
740
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
788
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
741
789
  const message = createBaseConfigResponse_AppDesignConfig();
742
790
  message.appName = (_a = object.appName) !== null && _a !== void 0 ? _a : "";
743
791
  message.logo = (_b = object.logo) !== null && _b !== void 0 ? _b : "";
@@ -751,6 +799,9 @@ exports.ConfigResponse_AppDesignConfig = {
751
799
  message.telegram = (_k = object.telegram) !== null && _k !== void 0 ? _k : "";
752
800
  message.primaryIconColor = (_l = object.primaryIconColor) !== null && _l !== void 0 ? _l : "";
753
801
  message.secondaryIconColor = (_m = object.secondaryIconColor) !== null && _m !== void 0 ? _m : "";
802
+ message.defaultRoleId = (_o = object.defaultRoleId) !== null && _o !== void 0 ? _o : "";
803
+ message.enableRegistration = (_p = object.enableRegistration) !== null && _p !== void 0 ? _p : "";
804
+ message.defaultRegisterOrganizationId = (_q = object.defaultRegisterOrganizationId) !== null && _q !== void 0 ? _q : "";
754
805
  return message;
755
806
  },
756
807
  };
@@ -2408,6 +2459,197 @@ exports.AreaIndexResponse = {
2408
2459
  return message;
2409
2460
  },
2410
2461
  };
2462
+ function createBaseAlertAndNotifications() {
2463
+ return {
2464
+ deviceId: long_1.default.UZERO,
2465
+ page: 0,
2466
+ platform: "",
2467
+ total: 0,
2468
+ lastPage: 0,
2469
+ records: 0,
2470
+ cost: 0,
2471
+ alerts: [],
2472
+ notifications: [],
2473
+ };
2474
+ }
2475
+ exports.AlertAndNotifications = {
2476
+ encode(message, writer = new wire_1.BinaryWriter()) {
2477
+ if (!message.deviceId.equals(long_1.default.UZERO)) {
2478
+ writer.uint32(8).uint64(message.deviceId.toString());
2479
+ }
2480
+ if (message.page !== 0) {
2481
+ writer.uint32(16).uint32(message.page);
2482
+ }
2483
+ if (message.platform !== "") {
2484
+ writer.uint32(26).string(message.platform);
2485
+ }
2486
+ if (message.total !== 0) {
2487
+ writer.uint32(32).uint32(message.total);
2488
+ }
2489
+ if (message.lastPage !== 0) {
2490
+ writer.uint32(40).uint32(message.lastPage);
2491
+ }
2492
+ if (message.records !== 0) {
2493
+ writer.uint32(48).uint32(message.records);
2494
+ }
2495
+ if (message.cost !== 0) {
2496
+ writer.uint32(56).uint32(message.cost);
2497
+ }
2498
+ for (const v of message.alerts) {
2499
+ notify_1.UserDeviceAlert.encode(v, writer.uint32(66).fork()).join();
2500
+ }
2501
+ for (const v of message.notifications) {
2502
+ notify_1.Notification.encode(v, writer.uint32(74).fork()).join();
2503
+ }
2504
+ return writer;
2505
+ },
2506
+ decode(input, length) {
2507
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2508
+ const end = length === undefined ? reader.len : reader.pos + length;
2509
+ const message = createBaseAlertAndNotifications();
2510
+ while (reader.pos < end) {
2511
+ const tag = reader.uint32();
2512
+ switch (tag >>> 3) {
2513
+ case 1: {
2514
+ if (tag !== 8) {
2515
+ break;
2516
+ }
2517
+ message.deviceId = long_1.default.fromString(reader.uint64().toString(), true);
2518
+ continue;
2519
+ }
2520
+ case 2: {
2521
+ if (tag !== 16) {
2522
+ break;
2523
+ }
2524
+ message.page = reader.uint32();
2525
+ continue;
2526
+ }
2527
+ case 3: {
2528
+ if (tag !== 26) {
2529
+ break;
2530
+ }
2531
+ message.platform = reader.string();
2532
+ continue;
2533
+ }
2534
+ case 4: {
2535
+ if (tag !== 32) {
2536
+ break;
2537
+ }
2538
+ message.total = reader.uint32();
2539
+ continue;
2540
+ }
2541
+ case 5: {
2542
+ if (tag !== 40) {
2543
+ break;
2544
+ }
2545
+ message.lastPage = reader.uint32();
2546
+ continue;
2547
+ }
2548
+ case 6: {
2549
+ if (tag !== 48) {
2550
+ break;
2551
+ }
2552
+ message.records = reader.uint32();
2553
+ continue;
2554
+ }
2555
+ case 7: {
2556
+ if (tag !== 56) {
2557
+ break;
2558
+ }
2559
+ message.cost = reader.uint32();
2560
+ continue;
2561
+ }
2562
+ case 8: {
2563
+ if (tag !== 66) {
2564
+ break;
2565
+ }
2566
+ message.alerts.push(notify_1.UserDeviceAlert.decode(reader, reader.uint32()));
2567
+ continue;
2568
+ }
2569
+ case 9: {
2570
+ if (tag !== 74) {
2571
+ break;
2572
+ }
2573
+ message.notifications.push(notify_1.Notification.decode(reader, reader.uint32()));
2574
+ continue;
2575
+ }
2576
+ }
2577
+ if ((tag & 7) === 4 || tag === 0) {
2578
+ break;
2579
+ }
2580
+ reader.skip(tag & 7);
2581
+ }
2582
+ return message;
2583
+ },
2584
+ fromJSON(object) {
2585
+ return {
2586
+ deviceId: isSet(object.device_id) ? long_1.default.fromValue(object.device_id) : long_1.default.UZERO,
2587
+ page: isSet(object.page) ? globalThis.Number(object.page) : 0,
2588
+ platform: isSet(object.platform) ? globalThis.String(object.platform) : "",
2589
+ total: isSet(object.total) ? globalThis.Number(object.total) : 0,
2590
+ lastPage: isSet(object.last_page) ? globalThis.Number(object.last_page) : 0,
2591
+ records: isSet(object.records) ? globalThis.Number(object.records) : 0,
2592
+ cost: isSet(object.cost) ? globalThis.Number(object.cost) : 0,
2593
+ alerts: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.alerts)
2594
+ ? object.alerts.map((e) => notify_1.UserDeviceAlert.fromJSON(e))
2595
+ : [],
2596
+ notifications: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.notifications)
2597
+ ? object.notifications.map((e) => notify_1.Notification.fromJSON(e))
2598
+ : [],
2599
+ };
2600
+ },
2601
+ toJSON(message) {
2602
+ var _a, _b;
2603
+ const obj = {};
2604
+ if (!message.deviceId.equals(long_1.default.UZERO)) {
2605
+ obj.device_id = (message.deviceId || long_1.default.UZERO).toString();
2606
+ }
2607
+ if (message.page !== 0) {
2608
+ obj.page = Math.round(message.page);
2609
+ }
2610
+ if (message.platform !== "") {
2611
+ obj.platform = message.platform;
2612
+ }
2613
+ if (message.total !== 0) {
2614
+ obj.total = Math.round(message.total);
2615
+ }
2616
+ if (message.lastPage !== 0) {
2617
+ obj.last_page = Math.round(message.lastPage);
2618
+ }
2619
+ if (message.records !== 0) {
2620
+ obj.records = Math.round(message.records);
2621
+ }
2622
+ if (message.cost !== 0) {
2623
+ obj.cost = Math.round(message.cost);
2624
+ }
2625
+ if ((_a = message.alerts) === null || _a === void 0 ? void 0 : _a.length) {
2626
+ obj.alerts = message.alerts.map((e) => notify_1.UserDeviceAlert.toJSON(e));
2627
+ }
2628
+ if ((_b = message.notifications) === null || _b === void 0 ? void 0 : _b.length) {
2629
+ obj.notifications = message.notifications.map((e) => notify_1.Notification.toJSON(e));
2630
+ }
2631
+ return obj;
2632
+ },
2633
+ create(base) {
2634
+ return exports.AlertAndNotifications.fromPartial(base !== null && base !== void 0 ? base : {});
2635
+ },
2636
+ fromPartial(object) {
2637
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2638
+ const message = createBaseAlertAndNotifications();
2639
+ message.deviceId = (object.deviceId !== undefined && object.deviceId !== null)
2640
+ ? long_1.default.fromValue(object.deviceId)
2641
+ : long_1.default.UZERO;
2642
+ message.page = (_a = object.page) !== null && _a !== void 0 ? _a : 0;
2643
+ message.platform = (_b = object.platform) !== null && _b !== void 0 ? _b : "";
2644
+ message.total = (_c = object.total) !== null && _c !== void 0 ? _c : 0;
2645
+ message.lastPage = (_d = object.lastPage) !== null && _d !== void 0 ? _d : 0;
2646
+ message.records = (_e = object.records) !== null && _e !== void 0 ? _e : 0;
2647
+ message.cost = (_f = object.cost) !== null && _f !== void 0 ? _f : 0;
2648
+ message.alerts = ((_g = object.alerts) === null || _g === void 0 ? void 0 : _g.map((e) => notify_1.UserDeviceAlert.fromPartial(e))) || [];
2649
+ message.notifications = ((_h = object.notifications) === null || _h === void 0 ? void 0 : _h.map((e) => notify_1.Notification.fromPartial(e))) || [];
2650
+ return message;
2651
+ },
2652
+ };
2411
2653
  function createBaseFilterConditions() {
2412
2654
  return { filterType: "", type: "", filter: "" };
2413
2655
  }
package/dist/report.d.ts CHANGED
@@ -1,21 +1,38 @@
1
1
  import { HeaderProvider } from ".";
2
+ export declare class ApiError extends Error {
3
+ status: number;
4
+ constructor(status: number, message: string);
5
+ }
6
+ export type ServiceResponse<T> = {
7
+ data: T;
8
+ error?: undefined;
9
+ } | {
10
+ data?: undefined;
11
+ error: {
12
+ status: number;
13
+ message: string;
14
+ };
15
+ };
2
16
  export declare class ReportService {
3
17
  private readonly url;
4
18
  private readonly namespace;
5
19
  private readonly getDynamicHeaders;
6
20
  constructor(url: string, headerProvider: HeaderProvider);
7
21
  private _call;
8
- RouteStopReport(request: import("./fatehan/reports/report").RouteStopRequest): Promise<import("./fatehan/reports/report").RouteStopResponse>;
9
- TripPerformanceReport(request: import("./fatehan/reports/report").TripPerformanceRequest): Promise<import("./fatehan/reports/report").TripPerformanceResponse>;
10
- TripReport(request: import("./fatehan/reports/report").TripReportRequest): Promise<import("./fatehan/reports/report").TripReportResponse>;
11
- RouteReviewReport(request: import("./fatehan/reports/report").RouteReviewRequest): Promise<import("./fatehan/reports/report").RouteReviewResponse>;
12
- DashboardIndividual(request: import("./fatehan/reports/report").DashboardIndividualRequest): Promise<import("./fatehan/reports/report").DashboardIndividualResponse>;
13
- LogReport(request: import("./fatehan/reports/report").LogRequest): Promise<import("./fatehan/reports/report").LogResponse>;
14
- DataReport(request: import("./fatehan/reports/report").DeviceDataRequest): Promise<import("./fatehan/reports/report").DeviceDataResponse>;
15
- AreaSummaryReviewReport(request: import("./fatehan/reports/report").AreaSummaryReviewRequest): Promise<import("./fatehan/reports/report").AreaSummaryReviewResponse>;
16
- WorkCycleReport(request: import("./fatehan/reports/report").WorkCycleRequest): Promise<import("./fatehan/reports/report").WorkCycleResponse>;
17
- CommandHistoryReport(request: import("./fatehan/reports/report").CommandHistoryRequest): Promise<import("./fatehan/reports/report").CommandHistoryResponse>;
18
- WorkflowReport(request: import("./fatehan/reports/report").WorkflowRequest): Promise<import("./fatehan/reports/report").WorkflowResponse>;
19
- ChartReport(request: import("./fatehan/reports/report").ChartRequest, responses: (chunk: import("./fatehan/reports/report").ChartResponse) => void): Promise<void>;
22
+ RouteStopReport(request: import("./fatehan/reports/report").RouteStopRequest): Promise<ServiceResponse<import("./fatehan/reports/report").RouteStopResponse>>;
23
+ TripPerformanceReport(request: import("./fatehan/reports/report").TripPerformanceRequest): Promise<ServiceResponse<import("./fatehan/reports/report").TripPerformanceResponse>>;
24
+ TripReport(request: import("./fatehan/reports/report").TripReportRequest): Promise<ServiceResponse<import("./fatehan/reports/report").TripReportResponse>>;
25
+ RouteReviewReport(request: import("./fatehan/reports/report").RouteReviewRequest): Promise<ServiceResponse<import("./fatehan/reports/report").RouteReviewResponse>>;
26
+ DashboardIndividual(request: import("./fatehan/reports/report").DashboardIndividualRequest): Promise<ServiceResponse<import("./fatehan/reports/report").DashboardIndividualResponse>>;
27
+ LogReport(request: import("./fatehan/reports/report").LogRequest): Promise<ServiceResponse<import("./fatehan/reports/report").LogResponse>>;
28
+ DataReport(request: import("./fatehan/reports/report").DeviceDataRequest): Promise<ServiceResponse<import("./fatehan/reports/report").DeviceDataResponse>>;
29
+ AreaSummaryReviewReport(request: import("./fatehan/reports/report").AreaSummaryReviewRequest): Promise<ServiceResponse<import("./fatehan/reports/report").AreaSummaryReviewResponse>>;
30
+ WorkCycleReport(request: import("./fatehan/reports/report").WorkCycleRequest): Promise<ServiceResponse<import("./fatehan/reports/report").WorkCycleResponse>>;
31
+ CommandHistoryReport(request: import("./fatehan/reports/report").CommandHistoryRequest): Promise<ServiceResponse<import("./fatehan/reports/report").CommandHistoryResponse>>;
32
+ WorkflowReport(request: import("./fatehan/reports/report").WorkflowRequest): Promise<ServiceResponse<import("./fatehan/reports/report").WorkflowResponse>>;
33
+ ChartReport(request: import("./fatehan/reports/report").ChartRequest, responses: (chunk: import("./fatehan/reports/report").ChartResponse) => void, onError: (error: {
34
+ status: number;
35
+ message: string;
36
+ }) => void): Promise<void>;
20
37
  }
21
38
  //# sourceMappingURL=report.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,CAAC;AAEnC,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+C;IACzE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAiB;gBAEvC,GAAG,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc;YAKzC,KAAK;IA+BN,eAAe,CAC1B,OAAO,EAAE,OAAO,0BAA0B,EAAE,gBAAgB,GAC3D,OAAO,CAAC,OAAO,0BAA0B,EAAE,iBAAiB,CAAC;IAYnD,qBAAqB,CAChC,OAAO,EAAE,OAAO,0BAA0B,EAAE,sBAAsB,GACjE,OAAO,CAAC,OAAO,0BAA0B,EAAE,uBAAuB,CAAC;IAYzD,UAAU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,GACrE,OAAO,CACR,eAAe,CACb,OAAO,0BAA0B,EAAE,2BAA2B,CAC/D,CACF;IAmBY,SAAS,CACpB,OAAO,EAAE,OAAO,0BAA0B,EAAE,UAAU,GACrD,OAAO,CAAC,eAAe,CAAC,OAAO,0BAA0B,EAAE,WAAW,CAAC,CAAC;IAoB9D,UAAU,CACrB,OAAO,EAAE,OAAO,0BAA0B,EAAE,iBAAiB,GAC5D,OAAO,CACR,eAAe,CAAC,OAAO,0BAA0B,EAAE,kBAAkB,CAAC,CACvE;IAoBY,uBAAuB,CAClC,OAAO,EAAE,OAAO,0BAA0B,EAAE,wBAAwB,GACnE,OAAO,CACR,eAAe,CACb,OAAO,0BAA0B,EAAE,yBAAyB,CAC7D,CACF;IAmBY,eAAe,CAC1B,OAAO,EAAE,OAAO,0BAA0B,EAAE,gBAAgB,GAC3D,OAAO,CACR,eAAe,CAAC,OAAO,0BAA0B,EAAE,iBAAiB,CAAC,CACtE;IAoBY,oBAAoB,CAC/B,OAAO,EAAE,OAAO,0BAA0B,EAAE,qBAAqB,GAChE,OAAO,CACR,eAAe,CAAC,OAAO,0BAA0B,EAAE,sBAAsB,CAAC,CAC3E;IAoBY,cAAc,CACzB,OAAO,EAAE,OAAO,0BAA0B,EAAE,eAAe,GAC1D,OAAO,CACR,eAAe,CAAC,OAAO,0BAA0B,EAAE,gBAAgB,CAAC,CACrE;IAoBY,WAAW,CACtB,OAAO,EAAE,OAAO,0BAA0B,EAAE,YAAY,EACxD,SAAS,EAAE,CACT,KAAK,EAAE,OAAO,0BAA0B,EAAE,aAAa,KACpD,IAAI,EACT,OAAO,EAAE,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI;CA6DhE"}
package/dist/report.js CHANGED
@@ -33,7 +33,14 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ReportService = void 0;
36
+ exports.ReportService = exports.ApiError = void 0;
37
+ class ApiError extends Error {
38
+ constructor(status, message) {
39
+ super(message);
40
+ this.status = status;
41
+ }
42
+ }
43
+ exports.ApiError = ApiError;
37
44
  class ReportService {
38
45
  constructor(url, headerProvider) {
39
46
  this.namespace = "com.fatehan.reports.ReportService";
@@ -58,87 +65,203 @@ class ReportService {
58
65
  }
59
66
  else {
60
67
  const errorText = await response.text();
61
- throw new Error(`API Error (${response.status}): ${errorText}`);
68
+ throw new ApiError(response.status, errorText || response.statusText);
62
69
  }
63
70
  }
64
71
  async RouteStopReport(request) {
65
- const { RouteStopRequest, RouteStopResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
66
- return this._call("RouteStopReport", request, RouteStopRequest, RouteStopResponse);
72
+ try {
73
+ const { RouteStopRequest, RouteStopResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
74
+ const data = await this._call("RouteStopReport", request, RouteStopRequest, RouteStopResponse);
75
+ return { data };
76
+ }
77
+ catch (e) {
78
+ if (e instanceof ApiError) {
79
+ return { error: { status: e.status, message: e.message } };
80
+ }
81
+ return { error: { status: 500, message: "Unknown error" } };
82
+ }
67
83
  }
68
84
  async TripPerformanceReport(request) {
69
- const { TripPerformanceRequest, TripPerformanceResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
70
- return this._call("TripPerformanceReport", request, TripPerformanceRequest, TripPerformanceResponse);
85
+ try {
86
+ const { TripPerformanceRequest, TripPerformanceResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
87
+ const data = await this._call("TripPerformanceReport", request, TripPerformanceRequest, TripPerformanceResponse);
88
+ return { data };
89
+ }
90
+ catch (e) {
91
+ if (e instanceof ApiError) {
92
+ return { error: { status: e.status, message: e.message } };
93
+ }
94
+ return { error: { status: 500, message: "Unknown error" } };
95
+ }
71
96
  }
72
97
  async TripReport(request) {
73
- const { TripReportRequest, TripReportResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
74
- return this._call("TripReport", request, TripReportRequest, TripReportResponse);
98
+ try {
99
+ const { TripReportRequest, TripReportResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
100
+ const data = await this._call("TripReport", request, TripReportRequest, TripReportResponse);
101
+ return { data };
102
+ }
103
+ catch (e) {
104
+ if (e instanceof ApiError) {
105
+ return { error: { status: e.status, message: e.message } };
106
+ }
107
+ return { error: { status: 500, message: "Unknown error" } };
108
+ }
75
109
  }
76
110
  async RouteReviewReport(request) {
77
- const { RouteReviewRequest, RouteReviewResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
78
- return this._call("RouteReviewReport", request, RouteReviewRequest, RouteReviewResponse);
111
+ try {
112
+ const { RouteReviewRequest, RouteReviewResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
113
+ const data = await this._call("RouteReviewReport", request, RouteReviewRequest, RouteReviewResponse);
114
+ return { data };
115
+ }
116
+ catch (e) {
117
+ if (e instanceof ApiError) {
118
+ return { error: { status: e.status, message: e.message } };
119
+ }
120
+ return { error: { status: 500, message: "Unknown error" } };
121
+ }
79
122
  }
80
123
  async DashboardIndividual(request) {
81
- const { DashboardIndividualRequest, DashboardIndividualResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
82
- return this._call("DashboardIndividual", request, DashboardIndividualRequest, DashboardIndividualResponse);
124
+ try {
125
+ const { DashboardIndividualRequest, DashboardIndividualResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
126
+ const data = await this._call("DashboardIndividual", request, DashboardIndividualRequest, DashboardIndividualResponse);
127
+ return { data };
128
+ }
129
+ catch (e) {
130
+ if (e instanceof ApiError) {
131
+ return { error: { status: e.status, message: e.message } };
132
+ }
133
+ return { error: { status: 500, message: "Unknown error" } };
134
+ }
83
135
  }
84
136
  async LogReport(request) {
85
- const { LogRequest, LogResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
86
- return this._call("LogReport", request, LogRequest, LogResponse);
137
+ try {
138
+ const { LogRequest, LogResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
139
+ const data = await this._call("LogReport", request, LogRequest, LogResponse);
140
+ return { data };
141
+ }
142
+ catch (e) {
143
+ if (e instanceof ApiError) {
144
+ return { error: { status: e.status, message: e.message } };
145
+ }
146
+ return { error: { status: 500, message: "Unknown error" } };
147
+ }
87
148
  }
88
149
  async DataReport(request) {
89
- const { DeviceDataRequest, DeviceDataResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
90
- return this._call("DeviceDataReport", request, DeviceDataRequest, DeviceDataResponse);
150
+ try {
151
+ const { DeviceDataRequest, DeviceDataResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
152
+ const data = await this._call("DeviceDataReport", request, DeviceDataRequest, DeviceDataResponse);
153
+ return { data };
154
+ }
155
+ catch (e) {
156
+ if (e instanceof ApiError) {
157
+ return { error: { status: e.status, message: e.message } };
158
+ }
159
+ return { error: { status: 500, message: "Unknown error" } };
160
+ }
91
161
  }
92
162
  async AreaSummaryReviewReport(request) {
93
- const { AreaSummaryReviewRequest, AreaSummaryReviewResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
94
- return this._call("AreaSummaryReviewReport", request, AreaSummaryReviewRequest, AreaSummaryReviewResponse);
163
+ try {
164
+ const { AreaSummaryReviewRequest, AreaSummaryReviewResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
165
+ const data = await this._call("AreaSummaryReviewReport", request, AreaSummaryReviewRequest, AreaSummaryReviewResponse);
166
+ return { data };
167
+ }
168
+ catch (e) {
169
+ if (e instanceof ApiError) {
170
+ return { error: { status: e.status, message: e.message } };
171
+ }
172
+ return { error: { status: 500, message: "Unknown error" } };
173
+ }
95
174
  }
96
175
  async WorkCycleReport(request) {
97
- const { WorkCycleRequest, WorkCycleResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
98
- return this._call("WorkCycleReport", request, WorkCycleRequest, WorkCycleResponse);
176
+ try {
177
+ const { WorkCycleRequest, WorkCycleResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
178
+ const data = await this._call("WorkCycleReport", request, WorkCycleRequest, WorkCycleResponse);
179
+ return { data };
180
+ }
181
+ catch (e) {
182
+ if (e instanceof ApiError) {
183
+ return { error: { status: e.status, message: e.message } };
184
+ }
185
+ return { error: { status: 500, message: "Unknown error" } };
186
+ }
99
187
  }
100
188
  async CommandHistoryReport(request) {
101
- const { CommandHistoryRequest, CommandHistoryResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
102
- return this._call("CommandHistoryReport", request, CommandHistoryRequest, CommandHistoryResponse);
189
+ try {
190
+ const { CommandHistoryRequest, CommandHistoryResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
191
+ const data = await this._call("CommandHistoryReport", request, CommandHistoryRequest, CommandHistoryResponse);
192
+ return { data };
193
+ }
194
+ catch (e) {
195
+ if (e instanceof ApiError) {
196
+ return { error: { status: e.status, message: e.message } };
197
+ }
198
+ return { error: { status: 500, message: "Unknown error" } };
199
+ }
103
200
  }
104
201
  async WorkflowReport(request) {
105
- const { WorkflowRequest, WorkflowResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
106
- return this._call("WorkflowReport", request, WorkflowRequest, WorkflowResponse);
202
+ try {
203
+ const { WorkflowRequest, WorkflowResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
204
+ const data = await this._call("WorkflowReport", request, WorkflowRequest, WorkflowResponse);
205
+ return { data };
206
+ }
207
+ catch (e) {
208
+ if (e instanceof ApiError) {
209
+ return { error: { status: e.status, message: e.message } };
210
+ }
211
+ return { error: { status: 500, message: "Unknown error" } };
212
+ }
107
213
  }
108
- async ChartReport(request, responses) {
109
- const { ChartRequest, ChartResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
110
- const dynamicHeaders = await this.getDynamicHeaders();
111
- const headers = {
112
- "Content-Type": "application/octet-stream",
113
- Accept: "application/octet-stream",
114
- ...dynamicHeaders,
115
- };
116
- const res = await fetch(`${this.url}/${this.namespace}/ChartReport`, {
117
- method: "POST",
118
- headers: headers,
119
- body: new Uint8Array(ChartRequest.encode(request).finish()),
120
- });
121
- if (res.body == null) {
122
- console.error("ChartReport response body is null.");
123
- return;
124
- }
125
- const reader = res.body.getReader();
126
- let buffer = new Uint8Array(0);
127
- while (true) {
128
- const { done, value } = await reader.read();
129
- if (done)
130
- break;
131
- const tmp = new Uint8Array(buffer.length + value.length);
132
- tmp.set(buffer);
133
- tmp.set(value, buffer.length);
134
- buffer = tmp;
135
- while (buffer.length >= 4) {
136
- const msgLen = new DataView(buffer.buffer).getUint32(0);
137
- if (buffer.length < 4 + msgLen)
214
+ async ChartReport(request, responses, onError) {
215
+ try {
216
+ const { ChartRequest, ChartResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
217
+ const dynamicHeaders = await this.getDynamicHeaders();
218
+ const headers = {
219
+ "Content-Type": "application/octet-stream",
220
+ Accept: "application/octet-stream",
221
+ ...dynamicHeaders,
222
+ };
223
+ const res = await fetch(`${this.url}/${this.namespace}/ChartReport`, {
224
+ method: "POST",
225
+ headers: headers,
226
+ body: new Uint8Array(ChartRequest.encode(request).finish()),
227
+ });
228
+ if (!res.ok) {
229
+ const errorText = await res.text();
230
+ onError({ status: res.status, message: errorText || res.statusText });
231
+ return;
232
+ }
233
+ if (res.body == null) {
234
+ console.error("ChartReport response body is null.");
235
+ onError({ status: 500, message: "Response body is null" });
236
+ return;
237
+ }
238
+ const reader = res.body.getReader();
239
+ let buffer = new Uint8Array(0);
240
+ while (true) {
241
+ const { done, value } = await reader.read();
242
+ if (done)
138
243
  break;
139
- const message = buffer.slice(4, 4 + msgLen);
140
- responses(ChartResponse.decode(message));
141
- buffer = buffer.slice(4 + msgLen);
244
+ const tmp = new Uint8Array(buffer.length + value.length);
245
+ tmp.set(buffer);
246
+ tmp.set(value, buffer.length);
247
+ buffer = tmp;
248
+ while (buffer.length >= 4) {
249
+ const msgLen = new DataView(buffer.buffer).getUint32(0);
250
+ if (buffer.length < 4 + msgLen)
251
+ break;
252
+ const message = buffer.slice(4, 4 + msgLen);
253
+ responses(ChartResponse.decode(message));
254
+ buffer = buffer.slice(4 + msgLen);
255
+ }
256
+ }
257
+ }
258
+ catch (e) {
259
+ console.error("ChartReport failed:", e);
260
+ if (e instanceof Error) {
261
+ onError({ status: 500, message: e.message });
262
+ }
263
+ else {
264
+ onError({ status: 500, message: "An unknown error occurred" });
142
265
  }
143
266
  }
144
267
  }