@fatehan/tsrp 1.1.15 → 1.3.1
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 +5 -10
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +48 -15
- package/dist/api.old.d.ts +19 -0
- package/dist/api.old.d.ts.map +1 -0
- package/dist/api.old.js +52 -0
- package/dist/api.test.js +39 -16
- package/dist/auth.d.ts +11 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +73 -0
- package/dist/fatehan/identities/authentication.d.ts +44 -2
- package/dist/fatehan/identities/authentication.d.ts.map +1 -1
- package/dist/fatehan/identities/authentication.js +727 -14
- package/dist/report.d.ts +15 -33
- package/dist/report.d.ts.map +1 -1
- package/dist/report.js +72 -46
- package/dist/report.old.d.ts +39 -0
- package/dist/report.old.d.ts.map +1 -0
- package/dist/report.old.js +148 -0
- package/dist/report.test.js +103 -362
- package/package.json +1 -1
package/dist/report.d.ts
CHANGED
|
@@ -1,43 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Data } from "./fatehan/packets/dataModel";
|
|
1
|
+
import type { ShownIo, SystemIo } from "./fatehan/devices/devices";
|
|
2
|
+
import type { Data } from "./fatehan/packets/dataModel";
|
|
4
3
|
export type HeaderProvider = () => Promise<HeadersInit> | HeadersInit;
|
|
5
|
-
/**
|
|
6
|
-
* A service for fetching reports from the com.fatehan.reports.ReportService backend.
|
|
7
|
-
* Implements a dynamic header provider to act as an interceptor for authentication.
|
|
8
|
-
*/
|
|
9
4
|
export declare class ReportService {
|
|
10
5
|
private readonly url;
|
|
11
6
|
private readonly namespace;
|
|
12
7
|
private readonly getDynamicHeaders;
|
|
13
|
-
/**
|
|
14
|
-
* @param url The base URL of the API server.
|
|
15
|
-
* @param headerProvider A function that returns headers to be added to each request.
|
|
16
|
-
*/
|
|
17
8
|
constructor(url: string, headerProvider: HeaderProvider);
|
|
18
9
|
private _call;
|
|
19
|
-
RouteStopReport(request: RouteStopRequest): Promise<RouteStopResponse>;
|
|
20
|
-
TripPerformanceReport(request: TripPerformanceRequest): Promise<TripPerformanceResponse>;
|
|
21
|
-
TripReport(request: TripReportRequest): Promise<TripReportResponse>;
|
|
22
|
-
RouteReviewReport(request: RouteReviewRequest): Promise<RouteReviewResponse>;
|
|
23
|
-
DashboardIndividual(request: DashboardIndividualRequest): Promise<DashboardIndividualResponse>;
|
|
24
|
-
LogReport(request: LogRequest): Promise<LogResponse>;
|
|
25
|
-
DataReport(request: DeviceDataRequest): Promise<DeviceDataResponse>;
|
|
26
|
-
AreaSummaryReviewReport(request: AreaSummaryReviewRequest): Promise<AreaSummaryReviewResponse>;
|
|
27
|
-
WorkCycleReport(request: WorkCycleRequest): Promise<WorkCycleResponse>;
|
|
28
|
-
CommandHistoryReport(request: CommandHistoryRequest): Promise<CommandHistoryResponse>;
|
|
29
|
-
WorkflowReport(request: WorkflowRequest): Promise<WorkflowResponse>;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*/
|
|
33
|
-
ChartReport(request: ChartRequest, responses: (chunk: ChartResponse) => void): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Fetches System IO data, using a cache first.
|
|
36
|
-
*/
|
|
37
|
-
SystemIoReport(request: SystemIoRequest): Promise<SystemIoResponse>;
|
|
38
|
-
/**
|
|
39
|
-
* A helper that uses SystemIoReport internally if needed.
|
|
40
|
-
*/
|
|
10
|
+
RouteStopReport(request: import("./fatehan/reports/report").RouteStopRequest): Promise<import("./fatehan/reports/report").RouteStopResponse>;
|
|
11
|
+
TripPerformanceReport(request: import("./fatehan/reports/report").TripPerformanceRequest): Promise<import("./fatehan/reports/report").TripPerformanceResponse>;
|
|
12
|
+
TripReport(request: import("./fatehan/reports/report").TripReportRequest): Promise<import("./fatehan/reports/report").TripReportResponse>;
|
|
13
|
+
RouteReviewReport(request: import("./fatehan/reports/report").RouteReviewRequest): Promise<import("./fatehan/reports/report").RouteReviewResponse>;
|
|
14
|
+
DashboardIndividual(request: import("./fatehan/reports/report").DashboardIndividualRequest): Promise<import("./fatehan/reports/report").DashboardIndividualResponse>;
|
|
15
|
+
LogReport(request: import("./fatehan/reports/report").LogRequest): Promise<import("./fatehan/reports/report").LogResponse>;
|
|
16
|
+
DataReport(request: import("./fatehan/reports/report").DeviceDataRequest): Promise<import("./fatehan/reports/report").DeviceDataResponse>;
|
|
17
|
+
AreaSummaryReviewReport(request: import("./fatehan/reports/report").AreaSummaryReviewRequest): Promise<import("./fatehan/reports/report").AreaSummaryReviewResponse>;
|
|
18
|
+
WorkCycleReport(request: import("./fatehan/reports/report").WorkCycleRequest): Promise<import("./fatehan/reports/report").WorkCycleResponse>;
|
|
19
|
+
CommandHistoryReport(request: import("./fatehan/reports/report").CommandHistoryRequest): Promise<import("./fatehan/reports/report").CommandHistoryResponse>;
|
|
20
|
+
WorkflowReport(request: import("./fatehan/reports/report").WorkflowRequest): Promise<import("./fatehan/reports/report").WorkflowResponse>;
|
|
21
|
+
ChartReport(request: import("./fatehan/reports/report").ChartRequest, responses: (chunk: import("./fatehan/reports/report").ChartResponse) => void): Promise<void>;
|
|
22
|
+
SystemIoReport(request: import("./fatehan/reports/report").SystemIoRequest): Promise<import("./fatehan/reports/report").SystemIoResponse>;
|
|
41
23
|
SystemIoCast(systemIo: SystemIo[] | null, deviceIo: SystemIo[], data: Data): Promise<ShownIo[]>;
|
|
42
24
|
}
|
|
43
25
|
//# sourceMappingURL=report.d.ts.map
|
package/dist/report.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,KAAK,EAAE,I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yB,CAAC;IAKpK,eAAe,CAAC,OAAO,EAAE,OAAO,0BAA0B,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,0BAA0B,EAAE,iBAAiB,CAAC;IAK5I,oBAAoB,CAAC,OAAO,EAAE,OAAO,0BAA0B,EAAE,qBAAqB,GAAG,OAAO,CAAC,OAAO,0BAA0B,EAAE,sBAAsB,CAAC;IAK3J,cAAc,CAAC,OAAO,EAAE,OAAO,0BAA0B,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,0BAA0B,EAAE,gBAAgB,CAAC;IAKzI,WAAW,CAAC,OAAO,EAAE,OAAO,0BAA0B,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,0BAA0B,EAAE,aAAa,KAAK,IAAI;IA2ClJ,cAAc,CAAC,OAAO,EAAE,OAAO,0BAA0B,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,0BAA0B,EAAE,gBAAgB,CAAC;IAazI,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAc/G"}
|
package/dist/report.js
CHANGED
|
@@ -1,21 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
5
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
39
|
exports.ReportService = void 0;
|
|
7
|
-
const report_1 = require("./fatehan/reports/report");
|
|
8
40
|
const system_io_1 = require("./store/system.io");
|
|
9
41
|
const system_io_2 = __importDefault(require("./system.io"));
|
|
10
|
-
/**
|
|
11
|
-
* A service for fetching reports from the com.fatehan.reports.ReportService backend.
|
|
12
|
-
* Implements a dynamic header provider to act as an interceptor for authentication.
|
|
13
|
-
*/
|
|
14
42
|
class ReportService {
|
|
15
|
-
/**
|
|
16
|
-
* @param url The base URL of the API server.
|
|
17
|
-
* @param headerProvider A function that returns headers to be added to each request.
|
|
18
|
-
*/
|
|
19
43
|
constructor(url, headerProvider) {
|
|
20
44
|
this.namespace = "com.fatehan.reports.ReportService";
|
|
21
45
|
this.url = url;
|
|
@@ -42,45 +66,52 @@ class ReportService {
|
|
|
42
66
|
throw new Error(`API Error (${response.status}): ${errorText}`);
|
|
43
67
|
}
|
|
44
68
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return this._call("RouteStopReport", request,
|
|
69
|
+
async RouteStopReport(request) {
|
|
70
|
+
const { RouteStopRequest, RouteStopResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
|
|
71
|
+
return this._call("RouteStopReport", request, RouteStopRequest, RouteStopResponse);
|
|
48
72
|
}
|
|
49
|
-
TripPerformanceReport(request) {
|
|
50
|
-
|
|
73
|
+
async TripPerformanceReport(request) {
|
|
74
|
+
const { TripPerformanceRequest, TripPerformanceResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
|
|
75
|
+
return this._call("TripPerformanceReport", request, TripPerformanceRequest, TripPerformanceResponse);
|
|
51
76
|
}
|
|
52
|
-
TripReport(request) {
|
|
53
|
-
|
|
77
|
+
async TripReport(request) {
|
|
78
|
+
const { TripReportRequest, TripReportResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
|
|
79
|
+
return this._call("TripReport", request, TripReportRequest, TripReportResponse);
|
|
54
80
|
}
|
|
55
|
-
RouteReviewReport(request) {
|
|
56
|
-
|
|
81
|
+
async RouteReviewReport(request) {
|
|
82
|
+
const { RouteReviewRequest, RouteReviewResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
|
|
83
|
+
return this._call("RouteReviewReport", request, RouteReviewRequest, RouteReviewResponse);
|
|
57
84
|
}
|
|
58
|
-
DashboardIndividual(request) {
|
|
59
|
-
|
|
85
|
+
async DashboardIndividual(request) {
|
|
86
|
+
const { DashboardIndividualRequest, DashboardIndividualResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
|
|
87
|
+
return this._call("DashboardIndividual", request, DashboardIndividualRequest, DashboardIndividualResponse);
|
|
60
88
|
}
|
|
61
|
-
LogReport(request) {
|
|
62
|
-
|
|
89
|
+
async LogReport(request) {
|
|
90
|
+
const { LogRequest, LogResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
|
|
91
|
+
return this._call("LogReport", request, LogRequest, LogResponse);
|
|
63
92
|
}
|
|
64
|
-
DataReport(request) {
|
|
65
|
-
|
|
93
|
+
async DataReport(request) {
|
|
94
|
+
const { DeviceDataRequest, DeviceDataResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
|
|
95
|
+
return this._call("DeviceDataReport", request, DeviceDataRequest, DeviceDataResponse);
|
|
66
96
|
}
|
|
67
|
-
AreaSummaryReviewReport(request) {
|
|
68
|
-
|
|
97
|
+
async AreaSummaryReviewReport(request) {
|
|
98
|
+
const { AreaSummaryReviewRequest, AreaSummaryReviewResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
|
|
99
|
+
return this._call("AreaSummaryReviewReport", request, AreaSummaryReviewRequest, AreaSummaryReviewResponse);
|
|
69
100
|
}
|
|
70
|
-
WorkCycleReport(request) {
|
|
71
|
-
|
|
101
|
+
async WorkCycleReport(request) {
|
|
102
|
+
const { WorkCycleRequest, WorkCycleResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
|
|
103
|
+
return this._call("WorkCycleReport", request, WorkCycleRequest, WorkCycleResponse);
|
|
72
104
|
}
|
|
73
|
-
CommandHistoryReport(request) {
|
|
74
|
-
|
|
105
|
+
async CommandHistoryReport(request) {
|
|
106
|
+
const { CommandHistoryRequest, CommandHistoryResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
|
|
107
|
+
return this._call("CommandHistoryReport", request, CommandHistoryRequest, CommandHistoryResponse);
|
|
75
108
|
}
|
|
76
|
-
WorkflowReport(request) {
|
|
77
|
-
|
|
109
|
+
async WorkflowReport(request) {
|
|
110
|
+
const { WorkflowRequest, WorkflowResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
|
|
111
|
+
return this._call("WorkflowReport", request, WorkflowRequest, WorkflowResponse);
|
|
78
112
|
}
|
|
79
|
-
// --- Special Case Methods ---
|
|
80
|
-
/**
|
|
81
|
-
* Handles a streaming RPC for chart data.
|
|
82
|
-
*/
|
|
83
113
|
async ChartReport(request, responses) {
|
|
114
|
+
const { ChartRequest, ChartResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
|
|
84
115
|
const dynamicHeaders = await this.getDynamicHeaders();
|
|
85
116
|
const headers = {
|
|
86
117
|
"Content-Type": "application/octet-stream",
|
|
@@ -90,7 +121,7 @@ class ReportService {
|
|
|
90
121
|
const res = await fetch(`${this.url}/${this.namespace}/ChartReport`, {
|
|
91
122
|
method: "POST",
|
|
92
123
|
headers: headers,
|
|
93
|
-
body: new Uint8Array(
|
|
124
|
+
body: new Uint8Array(ChartRequest.encode(request).finish()),
|
|
94
125
|
});
|
|
95
126
|
if (res.body == null) {
|
|
96
127
|
console.error("ChartReport response body is null.");
|
|
@@ -111,32 +142,27 @@ class ReportService {
|
|
|
111
142
|
if (buffer.length < 4 + msgLen)
|
|
112
143
|
break;
|
|
113
144
|
const message = buffer.slice(4, 4 + msgLen);
|
|
114
|
-
responses(
|
|
145
|
+
responses(ChartResponse.decode(message));
|
|
115
146
|
buffer = buffer.slice(4 + msgLen);
|
|
116
147
|
}
|
|
117
148
|
}
|
|
118
149
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Fetches System IO data, using a cache first.
|
|
121
|
-
*/
|
|
122
150
|
async SystemIoReport(request) {
|
|
123
151
|
const cachedIo = (0, system_io_1.getSystemIoCache)();
|
|
124
152
|
if (cachedIo != null) {
|
|
125
153
|
return { cost: 0, ios: cachedIo, records: cachedIo.length };
|
|
126
154
|
}
|
|
127
|
-
const
|
|
155
|
+
const { SystemIoRequest, SystemIoResponse } = await Promise.resolve().then(() => __importStar(require("./fatehan/reports/report")));
|
|
156
|
+
const response = await this._call("SystemIoReport", request, SystemIoRequest, SystemIoResponse);
|
|
128
157
|
(0, system_io_1.setSystemIoCache)(response.ios);
|
|
129
158
|
return response;
|
|
130
159
|
}
|
|
131
|
-
/**
|
|
132
|
-
* A helper that uses SystemIoReport internally if needed.
|
|
133
|
-
*/
|
|
134
160
|
async SystemIoCast(systemIo, deviceIo, data) {
|
|
135
161
|
var _a;
|
|
136
162
|
let ioData = systemIo;
|
|
137
163
|
if (ioData == null) {
|
|
138
164
|
try {
|
|
139
|
-
const result = await this.SystemIoReport({});
|
|
165
|
+
const result = await this.SystemIoReport({});
|
|
140
166
|
if (!((_a = result === null || result === void 0 ? void 0 : result.ios) === null || _a === void 0 ? void 0 : _a.length))
|
|
141
167
|
return [];
|
|
142
168
|
ioData = result.ios;
|
|
@@ -0,0 +1,39 @@
|
|
|
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, WorkflowRequest, WorkflowResponse } from "./fatehan/reports/report";
|
|
2
|
+
import { ShownIo, SystemIo } from "./fatehan/devices/devices";
|
|
3
|
+
import { Data } from "./fatehan/packets/dataModel";
|
|
4
|
+
export type HeaderProvider = () => Promise<HeadersInit> | HeadersInit;
|
|
5
|
+
export declare class ReportService {
|
|
6
|
+
private readonly url;
|
|
7
|
+
private readonly namespace;
|
|
8
|
+
private readonly getDynamicHeaders;
|
|
9
|
+
/**
|
|
10
|
+
* @param url The base URL of the API server.
|
|
11
|
+
* @param headerProvider A function that returns headers to be added to each request.
|
|
12
|
+
*/
|
|
13
|
+
constructor(url: string, headerProvider: HeaderProvider);
|
|
14
|
+
private _call;
|
|
15
|
+
RouteStopReport(request: RouteStopRequest): Promise<RouteStopResponse>;
|
|
16
|
+
TripPerformanceReport(request: TripPerformanceRequest): Promise<TripPerformanceResponse>;
|
|
17
|
+
TripReport(request: TripReportRequest): Promise<TripReportResponse>;
|
|
18
|
+
RouteReviewReport(request: RouteReviewRequest): Promise<RouteReviewResponse>;
|
|
19
|
+
DashboardIndividual(request: DashboardIndividualRequest): Promise<DashboardIndividualResponse>;
|
|
20
|
+
LogReport(request: LogRequest): Promise<LogResponse>;
|
|
21
|
+
DataReport(request: DeviceDataRequest): Promise<DeviceDataResponse>;
|
|
22
|
+
AreaSummaryReviewReport(request: AreaSummaryReviewRequest): Promise<AreaSummaryReviewResponse>;
|
|
23
|
+
WorkCycleReport(request: WorkCycleRequest): Promise<WorkCycleResponse>;
|
|
24
|
+
CommandHistoryReport(request: CommandHistoryRequest): Promise<CommandHistoryResponse>;
|
|
25
|
+
WorkflowReport(request: WorkflowRequest): Promise<WorkflowResponse>;
|
|
26
|
+
/**
|
|
27
|
+
* Handles a streaming RPC for chart data.
|
|
28
|
+
*/
|
|
29
|
+
ChartReport(request: ChartRequest, responses: (chunk: ChartResponse) => void): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Fetches System IO data, using a cache first.
|
|
32
|
+
*/
|
|
33
|
+
SystemIoReport(request: SystemIoRequest): Promise<SystemIoResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* A helper that uses SystemIoReport internally if needed.
|
|
36
|
+
*/
|
|
37
|
+
SystemIoCast(systemIo: SystemIo[] | null, deviceIo: SystemIo[], data: Data): Promise<ShownIo[]>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=report.old.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.old.d.ts","sourceRoot":"","sources":["../src/report.old.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,wBAAwB,EACxB,yBAAyB,EACzB,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,0BA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E,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAI9F,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAItE,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAIrF,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAM1E;;OAEG;IACU,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI;IA0CzF;;OAEG;IACU,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAWhF;;OAEG;IACU,YAAY,CACrB,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,EAC3B,QAAQ,EAAE,QAAQ,EAAE,EACpB,IAAI,EAAE,IAAI,GACX,OAAO,CAAC,OAAO,EAAE,CAAC;CAcxB"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ReportService = void 0;
|
|
7
|
+
const report_1 = require("./fatehan/reports/report");
|
|
8
|
+
const system_io_1 = require("./store/system.io");
|
|
9
|
+
const system_io_2 = __importDefault(require("./system.io"));
|
|
10
|
+
class ReportService {
|
|
11
|
+
/**
|
|
12
|
+
* @param url The base URL of the API server.
|
|
13
|
+
* @param headerProvider A function that returns headers to be added to each request.
|
|
14
|
+
*/
|
|
15
|
+
constructor(url, headerProvider) {
|
|
16
|
+
this.namespace = "com.fatehan.reports.ReportService";
|
|
17
|
+
this.url = url;
|
|
18
|
+
this.getDynamicHeaders = headerProvider;
|
|
19
|
+
}
|
|
20
|
+
async _call(methodName, request, encoder, decoder) {
|
|
21
|
+
const dynamicHeaders = await this.getDynamicHeaders();
|
|
22
|
+
const headers = {
|
|
23
|
+
"Content-Type": "application/octet-stream",
|
|
24
|
+
Accept: "application/octet-stream",
|
|
25
|
+
...dynamicHeaders,
|
|
26
|
+
};
|
|
27
|
+
const response = await fetch(`${this.url}/${this.namespace}/${methodName}`, {
|
|
28
|
+
method: "POST",
|
|
29
|
+
headers: headers,
|
|
30
|
+
body: new Uint8Array(encoder.encode(request).finish()),
|
|
31
|
+
});
|
|
32
|
+
if (response.ok) {
|
|
33
|
+
const buffer = await response.arrayBuffer();
|
|
34
|
+
return decoder.decode(new Uint8Array(buffer));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const errorText = await response.text();
|
|
38
|
+
throw new Error(`API Error (${response.status}): ${errorText}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// --- Public Unary API Methods ---
|
|
42
|
+
RouteStopReport(request) {
|
|
43
|
+
return this._call("RouteStopReport", request, report_1.RouteStopRequest, report_1.RouteStopResponse);
|
|
44
|
+
}
|
|
45
|
+
TripPerformanceReport(request) {
|
|
46
|
+
return this._call("TripPerformanceReport", request, report_1.TripPerformanceRequest, report_1.TripPerformanceResponse);
|
|
47
|
+
}
|
|
48
|
+
TripReport(request) {
|
|
49
|
+
return this._call("TripReport", request, report_1.TripReportRequest, report_1.TripReportResponse);
|
|
50
|
+
}
|
|
51
|
+
RouteReviewReport(request) {
|
|
52
|
+
return this._call("RouteReviewReport", request, report_1.RouteReviewRequest, report_1.RouteReviewResponse);
|
|
53
|
+
}
|
|
54
|
+
DashboardIndividual(request) {
|
|
55
|
+
return this._call("DashboardIndividual", request, report_1.DashboardIndividualRequest, report_1.DashboardIndividualResponse);
|
|
56
|
+
}
|
|
57
|
+
LogReport(request) {
|
|
58
|
+
return this._call("LogReport", request, report_1.LogRequest, report_1.LogResponse);
|
|
59
|
+
}
|
|
60
|
+
DataReport(request) {
|
|
61
|
+
return this._call("DeviceDataReport", request, report_1.DeviceDataRequest, report_1.DeviceDataResponse);
|
|
62
|
+
}
|
|
63
|
+
AreaSummaryReviewReport(request) {
|
|
64
|
+
return this._call("AreaSummaryReviewReport", request, report_1.AreaSummaryReviewRequest, report_1.AreaSummaryReviewResponse);
|
|
65
|
+
}
|
|
66
|
+
WorkCycleReport(request) {
|
|
67
|
+
return this._call("WorkCycleReport", request, report_1.WorkCycleRequest, report_1.WorkCycleResponse);
|
|
68
|
+
}
|
|
69
|
+
CommandHistoryReport(request) {
|
|
70
|
+
return this._call("CommandHistoryReport", request, report_1.CommandHistoryRequest, report_1.CommandHistoryResponse);
|
|
71
|
+
}
|
|
72
|
+
WorkflowReport(request) {
|
|
73
|
+
return this._call("WorkflowReport", request, report_1.WorkflowRequest, report_1.WorkflowResponse);
|
|
74
|
+
}
|
|
75
|
+
// --- Special Case Methods ---
|
|
76
|
+
/**
|
|
77
|
+
* Handles a streaming RPC for chart data.
|
|
78
|
+
*/
|
|
79
|
+
async ChartReport(request, responses) {
|
|
80
|
+
const dynamicHeaders = await this.getDynamicHeaders();
|
|
81
|
+
const headers = {
|
|
82
|
+
"Content-Type": "application/octet-stream",
|
|
83
|
+
Accept: "application/octet-stream",
|
|
84
|
+
...dynamicHeaders,
|
|
85
|
+
};
|
|
86
|
+
const res = await fetch(`${this.url}/${this.namespace}/ChartReport`, {
|
|
87
|
+
method: "POST",
|
|
88
|
+
headers: headers,
|
|
89
|
+
body: new Uint8Array(report_1.ChartRequest.encode(request).finish()),
|
|
90
|
+
});
|
|
91
|
+
if (res.body == null) {
|
|
92
|
+
console.error("ChartReport response body is null.");
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const reader = res.body.getReader();
|
|
96
|
+
let buffer = new Uint8Array(0);
|
|
97
|
+
while (true) {
|
|
98
|
+
const { done, value } = await reader.read();
|
|
99
|
+
if (done)
|
|
100
|
+
break;
|
|
101
|
+
const tmp = new Uint8Array(buffer.length + value.length);
|
|
102
|
+
tmp.set(buffer);
|
|
103
|
+
tmp.set(value, buffer.length);
|
|
104
|
+
buffer = tmp;
|
|
105
|
+
while (buffer.length >= 4) {
|
|
106
|
+
const msgLen = new DataView(buffer.buffer).getUint32(0);
|
|
107
|
+
if (buffer.length < 4 + msgLen)
|
|
108
|
+
break;
|
|
109
|
+
const message = buffer.slice(4, 4 + msgLen);
|
|
110
|
+
responses(report_1.ChartResponse.decode(message));
|
|
111
|
+
buffer = buffer.slice(4 + msgLen);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Fetches System IO data, using a cache first.
|
|
117
|
+
*/
|
|
118
|
+
async SystemIoReport(request) {
|
|
119
|
+
const cachedIo = (0, system_io_1.getSystemIoCache)();
|
|
120
|
+
if (cachedIo != null) {
|
|
121
|
+
return { cost: 0, ios: cachedIo, records: cachedIo.length };
|
|
122
|
+
}
|
|
123
|
+
const response = await this._call("SystemIoReport", request, report_1.SystemIoRequest, report_1.SystemIoResponse);
|
|
124
|
+
(0, system_io_1.setSystemIoCache)(response.ios);
|
|
125
|
+
return response;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* A helper that uses SystemIoReport internally if needed.
|
|
129
|
+
*/
|
|
130
|
+
async SystemIoCast(systemIo, deviceIo, data) {
|
|
131
|
+
var _a;
|
|
132
|
+
let ioData = systemIo;
|
|
133
|
+
if (ioData == null) {
|
|
134
|
+
try {
|
|
135
|
+
const result = await this.SystemIoReport({}); // This call is now authenticated
|
|
136
|
+
if (!((_a = result === null || result === void 0 ? void 0 : result.ios) === null || _a === void 0 ? void 0 : _a.length))
|
|
137
|
+
return [];
|
|
138
|
+
ioData = result.ios;
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
console.error("Failed to fetch SystemIoReport in SystemIoCast:", error);
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return (0, system_io_2.default)(ioData, deviceIo, data);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.ReportService = ReportService;
|