gauge-ts 0.1.1 → 0.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/RunnerServer.d.ts +50 -0
- package/dist/RunnerServer.js +295 -0
- package/dist/gen/messages_pb.d.ts +0 -143
- package/dist/gen/messages_pb.js +10 -1
- package/dist/gen/services_grpc_pb.d.ts +3 -4
- package/dist/gen/services_pb.js +10 -1
- package/dist/gen/spec_pb.d.ts +0 -153
- package/dist/gen/spec_pb.js +18 -5
- package/dist/helpers/CodeHelper.d.ts +3 -3
- package/dist/helpers/CodeHelper.js +9 -6
- package/dist/index.d.ts +12 -12
- package/dist/index.js +26 -26
- package/dist/loaders/ImplLoader.js +17 -27
- package/dist/loaders/StaticLoader.d.ts +1 -1
- package/dist/loaders/StaticLoader.js +10 -9
- package/dist/models/GlobalRegistry.d.ts +2 -3
- package/dist/models/HookMethod.d.ts +1 -1
- package/dist/models/HookMethod.js +6 -1
- package/dist/models/HookRegistry.d.ts +1 -1
- package/dist/models/HookRegistry.js +16 -8
- package/dist/models/HookType.js +2 -1
- package/dist/models/Position.js +3 -0
- package/dist/models/Range.d.ts +1 -1
- package/dist/models/Range.js +3 -0
- package/dist/models/StepRegistry.d.ts +3 -3
- package/dist/models/StepRegistry.js +18 -15
- package/dist/models/StepRegistryEntry.d.ts +2 -2
- package/dist/models/StepRegistryEntry.js +10 -1
- package/dist/processors/CacheFileProcessor.d.ts +1 -1
- package/dist/processors/CacheFileProcessor.js +3 -1
- package/dist/processors/ExecutionEndingProcessor.d.ts +3 -4
- package/dist/processors/ExecutionEndingProcessor.js +2 -4
- package/dist/processors/ExecutionProcessor.d.ts +2 -2
- package/dist/processors/ExecutionProcessor.js +3 -19
- package/dist/processors/ExecutionStartingProcessor.d.ts +3 -4
- package/dist/processors/ExecutionStartingProcessor.js +8 -8
- package/dist/processors/HookExecutionProcessor.d.ts +4 -4
- package/dist/processors/HookExecutionProcessor.js +29 -42
- package/dist/processors/RefactorProcessor.d.ts +3 -2
- package/dist/processors/RefactorProcessor.js +37 -19
- package/dist/processors/ScenarioExecutionEndingProcessor.d.ts +3 -4
- package/dist/processors/ScenarioExecutionEndingProcessor.js +2 -4
- package/dist/processors/ScenarioExecutionStartingProcessor.d.ts +3 -4
- package/dist/processors/ScenarioExecutionStartingProcessor.js +2 -4
- package/dist/processors/SpecExecutionEndingProcessor.d.ts +3 -4
- package/dist/processors/SpecExecutionEndingProcessor.js +2 -4
- package/dist/processors/SpecExecutionStartingProcessor.d.ts +3 -4
- package/dist/processors/SpecExecutionStartingProcessor.js +2 -4
- package/dist/processors/StepExecutionEndingProcessor.d.ts +3 -4
- package/dist/processors/StepExecutionEndingProcessor.js +2 -4
- package/dist/processors/StepExecutionProcessor.d.ts +1 -1
- package/dist/processors/StepExecutionProcessor.js +44 -55
- package/dist/processors/StepExecutionStartingProcessor.d.ts +3 -4
- package/dist/processors/StepExecutionStartingProcessor.js +2 -4
- package/dist/processors/StepNameProcessor.d.ts +1 -1
- package/dist/processors/StepNameProcessor.js +1 -0
- package/dist/processors/StepPositionsProcessor.d.ts +1 -1
- package/dist/processors/StepPositionsProcessor.js +1 -0
- package/dist/processors/StubImplementationCodeProcessor.d.ts +1 -1
- package/dist/processors/StubImplementationCodeProcessor.js +27 -17
- package/dist/processors/ValidationProcessor.d.ts +1 -1
- package/dist/processors/ValidationProcessor.js +16 -14
- package/dist/public/Gauge.js +4 -13
- package/dist/public/Operator.js +2 -1
- package/dist/public/Table.d.ts +1 -1
- package/dist/public/Table.js +17 -14
- package/dist/public/TableRow.js +4 -2
- package/dist/public/context/ExecutionContext.d.ts +3 -3
- package/dist/public/context/ExecutionContext.js +5 -0
- package/dist/public/context/Scenario.js +4 -0
- package/dist/public/context/Specification.js +5 -0
- package/dist/public/context/StepInfo.js +6 -0
- package/dist/public/decorators.d.ts +2 -6
- package/dist/public/decorators.js +13 -22
- package/dist/screenshot/Screenshot.d.ts +1 -1
- package/dist/screenshot/Screenshot.js +35 -42
- package/dist/stores/DataStore.js +2 -3
- package/dist/stores/DataStoreFactory.js +2 -0
- package/dist/stores/GlobalDataStore.d.ts +1 -2
- package/dist/stores/MessageStore.js +7 -5
- package/dist/stores/ScreenshotStore.js +7 -5
- package/dist/utils/Util.d.ts +9 -8
- package/dist/utils/Util.js +47 -60
- package/package.json +24 -33
- package/LICENSE +0 -21
- package/README.md +0 -51
- package/dist/GaugeRuntime.d.ts +0 -3
- package/dist/GaugeRuntime.js +0 -24
- package/dist/RunnerServiceImpl.d.ts +0 -48
- package/dist/RunnerServiceImpl.js +0 -225
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Server } from "@grpc/grpc-js";
|
|
2
|
+
import type { ServerUnaryCall as SUC, sendUnaryData as sUD } from "@grpc/grpc-js";
|
|
3
|
+
import { Empty, ImplementationFileGlobPatternResponse as IFGPR, ImplementationFileListResponse as IFLR, StepNamesResponse } from "./gen/messages_pb";
|
|
4
|
+
import type { CacheFileRequest, ExecutionStatusResponse as ESR, ExecuteStepRequest, ExecutionEndingRequest, ExecutionStartingRequest, FileDiff, KillProcessRequest, RefactorRequest, RefactorResponse, ScenarioDataStoreInitRequest as SCDSIR, ScenarioExecutionEndingRequest as SCEER, ScenarioExecutionStartingRequest as SCESR, SpecDataStoreInitRequest as SPDSIR, SpecExecutionEndingRequest as SPEER, SpecExecutionStartingRequest as SPESR, StepExecutionEndingRequest as STEER, StepExecutionStartingRequest as STESR, StepNameRequest, StepNameResponse, StepNamesRequest, StepPositionsRequest, StepPositionsResponse, StepValidateRequest, StepValidateResponse, StubImplementationCodeRequest, SuiteDataStoreInitRequest } from "./gen/messages_pb";
|
|
5
|
+
import type { IRunnerServer } from "./gen/services_grpc_pb";
|
|
6
|
+
import StaticLoader from "./loaders/StaticLoader";
|
|
7
|
+
export default class RunnerServer implements IRunnerServer {
|
|
8
|
+
[name: string]: import("@grpc/grpc-js").UntypedHandleCall;
|
|
9
|
+
private static cacheFileProcessor;
|
|
10
|
+
private static executionEndingProcessor;
|
|
11
|
+
private static executionStartingProcessor;
|
|
12
|
+
private static refactorProcessor;
|
|
13
|
+
private static scenarioExecutionEndingProcessor;
|
|
14
|
+
private static scenarioExecutionStartingProcessor;
|
|
15
|
+
private static specExecutionEndingProcessor;
|
|
16
|
+
private static specExecutionStartingProcessor;
|
|
17
|
+
private static stepExecutionEndingProcessor;
|
|
18
|
+
private static stepExecutionProcessor;
|
|
19
|
+
private static stepExecutionStartingProcessor;
|
|
20
|
+
private static stepNameProcessor;
|
|
21
|
+
private static stepPositionsProcessor;
|
|
22
|
+
private static stubImplementationCodeProcessor;
|
|
23
|
+
private static validationProcessor;
|
|
24
|
+
constructor(loader: StaticLoader);
|
|
25
|
+
validateStep(call: SUC<StepValidateRequest, StepValidateResponse>, callback: sUD<StepValidateResponse>): void;
|
|
26
|
+
initializeSuiteDataStore(_call: SUC<SuiteDataStoreInitRequest, ESR>, callback: sUD<ESR>): void;
|
|
27
|
+
startExecution(call: SUC<ExecutionStartingRequest, ESR>, callback: sUD<ESR>): void;
|
|
28
|
+
initializeSpecDataStore(call: SUC<SPDSIR, ESR>, callback: sUD<ESR>): void;
|
|
29
|
+
startSpecExecution(call: SUC<SPESR, ESR>, callback: sUD<ESR>): void;
|
|
30
|
+
initializeScenarioDataStore(call: SUC<SCDSIR, ESR>, callback: sUD<ESR>): void;
|
|
31
|
+
startScenarioExecution(call: SUC<SCESR, ESR>, callback: sUD<ESR>): void;
|
|
32
|
+
startStepExecution(call: SUC<STESR, ESR>, callback: sUD<ESR>): void;
|
|
33
|
+
executeStep(call: SUC<ExecuteStepRequest, ESR>, callback: sUD<ESR>): void;
|
|
34
|
+
finishStepExecution(call: SUC<STEER, ESR>, callback: sUD<ESR>): void;
|
|
35
|
+
finishScenarioExecution(call: SUC<SCEER, ESR>, callback: sUD<ESR>): void;
|
|
36
|
+
finishSpecExecution(call: SUC<SPEER, ESR>, callback: sUD<ESR>): void;
|
|
37
|
+
finishExecution(call: SUC<ExecutionEndingRequest, ESR>, callback: sUD<ESR>): void;
|
|
38
|
+
cacheFile(call: SUC<CacheFileRequest, Empty>, callback: sUD<Empty>): void;
|
|
39
|
+
getStepName(call: SUC<StepNameRequest, StepNameResponse>, callback: sUD<StepNameResponse>): void;
|
|
40
|
+
getGlobPatterns(call: SUC<Empty, IFGPR>, callback: sUD<IFGPR>): void;
|
|
41
|
+
getStepNames(call: SUC<StepNamesRequest, StepNamesResponse>, callback: sUD<StepNamesResponse>): void;
|
|
42
|
+
getStepPositions(call: SUC<StepPositionsRequest, StepPositionsResponse>, callback: sUD<StepPositionsResponse>): void;
|
|
43
|
+
getImplementationFiles(call: SUC<Empty, IFLR>, callback: sUD<IFLR>): void;
|
|
44
|
+
implementStub(call: SUC<StubImplementationCodeRequest, FileDiff>, callback: sUD<FileDiff>): void;
|
|
45
|
+
refactor(call: SUC<RefactorRequest, RefactorResponse>, callback: sUD<RefactorResponse>): void;
|
|
46
|
+
kill(_call: SUC<KillProcessRequest, Empty>, callback: sUD<Empty>): void;
|
|
47
|
+
private getEmptExecutionResponse;
|
|
48
|
+
}
|
|
49
|
+
export declare const start: (host?: string, server?: Server, runnerService?: RunnerServer) => void;
|
|
50
|
+
export declare const stop: (server?: Server | null) => void;
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stop = exports.start = void 0;
|
|
4
|
+
const node_os_1 = require("node:os");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const grpc_js_1 = require("@grpc/grpc-js");
|
|
7
|
+
const services_grpc_pb_1 = require("./gen/services_grpc_pb");
|
|
8
|
+
const constants_1 = require("@grpc/grpc-js/build/src/constants");
|
|
9
|
+
const _1 = require(".");
|
|
10
|
+
const messages_pb_1 = require("./gen/messages_pb");
|
|
11
|
+
const spec_pb_1 = require("./gen/spec_pb");
|
|
12
|
+
const ImplLoader_1 = require("./loaders/ImplLoader");
|
|
13
|
+
const StaticLoader_1 = require("./loaders/StaticLoader");
|
|
14
|
+
const StepRegistry_1 = require("./models/StepRegistry");
|
|
15
|
+
const CacheFileProcessor_1 = require("./processors/CacheFileProcessor");
|
|
16
|
+
const ExecutionEndingProcessor_1 = require("./processors/ExecutionEndingProcessor");
|
|
17
|
+
const ExecutionStartingProcessor_1 = require("./processors/ExecutionStartingProcessor");
|
|
18
|
+
const RefactorProcessor_1 = require("./processors/RefactorProcessor");
|
|
19
|
+
const ScenarioExecutionEndingProcessor_1 = require("./processors/ScenarioExecutionEndingProcessor");
|
|
20
|
+
const ScenarioExecutionStartingProcessor_1 = require("./processors/ScenarioExecutionStartingProcessor");
|
|
21
|
+
const SpecExecutionEndingProcessor_1 = require("./processors/SpecExecutionEndingProcessor");
|
|
22
|
+
const SpecExecutionStartingProcessor_1 = require("./processors/SpecExecutionStartingProcessor");
|
|
23
|
+
const StepExecutionEndingProcessor_1 = require("./processors/StepExecutionEndingProcessor");
|
|
24
|
+
const StepExecutionProcessor_1 = require("./processors/StepExecutionProcessor");
|
|
25
|
+
const StepExecutionStartingProcessor_1 = require("./processors/StepExecutionStartingProcessor");
|
|
26
|
+
const StepNameProcessor_1 = require("./processors/StepNameProcessor");
|
|
27
|
+
const StepPositionsProcessor_1 = require("./processors/StepPositionsProcessor");
|
|
28
|
+
const StubImplementationCodeProcessor_1 = require("./processors/StubImplementationCodeProcessor");
|
|
29
|
+
const ValidationProcessor_1 = require("./processors/ValidationProcessor");
|
|
30
|
+
const Util_1 = require("./utils/Util");
|
|
31
|
+
class RunnerServer {
|
|
32
|
+
static cacheFileProcessor;
|
|
33
|
+
static executionEndingProcessor;
|
|
34
|
+
static executionStartingProcessor;
|
|
35
|
+
static refactorProcessor;
|
|
36
|
+
static scenarioExecutionEndingProcessor;
|
|
37
|
+
static scenarioExecutionStartingProcessor;
|
|
38
|
+
static specExecutionEndingProcessor;
|
|
39
|
+
static specExecutionStartingProcessor;
|
|
40
|
+
static stepExecutionEndingProcessor;
|
|
41
|
+
static stepExecutionProcessor;
|
|
42
|
+
static stepExecutionStartingProcessor;
|
|
43
|
+
static stepNameProcessor;
|
|
44
|
+
static stepPositionsProcessor;
|
|
45
|
+
static stubImplementationCodeProcessor;
|
|
46
|
+
static validationProcessor;
|
|
47
|
+
constructor(loader) {
|
|
48
|
+
loader.loadImplementations();
|
|
49
|
+
RunnerServer.cacheFileProcessor = new CacheFileProcessor_1.CacheFileProcessor(loader);
|
|
50
|
+
RunnerServer.executionEndingProcessor = new ExecutionEndingProcessor_1.ExecutionEndingProcessor();
|
|
51
|
+
RunnerServer.executionStartingProcessor = new ExecutionStartingProcessor_1.ExecutionStartingProcessor();
|
|
52
|
+
RunnerServer.refactorProcessor = new RefactorProcessor_1.RefactorProcessor();
|
|
53
|
+
RunnerServer.scenarioExecutionEndingProcessor =
|
|
54
|
+
new ScenarioExecutionEndingProcessor_1.ScenarioExecutionEndingProcessor();
|
|
55
|
+
RunnerServer.scenarioExecutionStartingProcessor =
|
|
56
|
+
new ScenarioExecutionStartingProcessor_1.ScenarioExecutionStartingProcessor();
|
|
57
|
+
RunnerServer.specExecutionEndingProcessor =
|
|
58
|
+
new SpecExecutionEndingProcessor_1.SpecExecutionEndingProcessor();
|
|
59
|
+
RunnerServer.specExecutionStartingProcessor =
|
|
60
|
+
new SpecExecutionStartingProcessor_1.SpecExecutionStartingProcessor();
|
|
61
|
+
RunnerServer.stepExecutionEndingProcessor =
|
|
62
|
+
new StepExecutionEndingProcessor_1.StepExecutionEndingProcessor();
|
|
63
|
+
RunnerServer.stepExecutionProcessor = new StepExecutionProcessor_1.StepExecutionProcessor();
|
|
64
|
+
RunnerServer.stepExecutionStartingProcessor =
|
|
65
|
+
new StepExecutionStartingProcessor_1.StepExecutionStartingProcessor();
|
|
66
|
+
RunnerServer.stepNameProcessor = new StepNameProcessor_1.StepNameProcessor();
|
|
67
|
+
RunnerServer.stepPositionsProcessor = new StepPositionsProcessor_1.StepPositionsProcessor();
|
|
68
|
+
RunnerServer.stubImplementationCodeProcessor =
|
|
69
|
+
new StubImplementationCodeProcessor_1.StubImplementationCodeProcessor();
|
|
70
|
+
RunnerServer.validationProcessor = new ValidationProcessor_1.ValidationProcessor();
|
|
71
|
+
}
|
|
72
|
+
validateStep(call, callback) {
|
|
73
|
+
try {
|
|
74
|
+
callback(null, RunnerServer.validationProcessor.process(call.request));
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
callback(createRpcError(error), null);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
initializeSuiteDataStore(_call, callback) {
|
|
81
|
+
try {
|
|
82
|
+
_1.DataStoreFactory.getSuiteDataStore().clear();
|
|
83
|
+
const loader = new ImplLoader_1.ImplLoader();
|
|
84
|
+
loader
|
|
85
|
+
.loadImplementations()
|
|
86
|
+
.then(() => callback(null, this.getEmptExecutionResponse()))
|
|
87
|
+
.catch((err) => {
|
|
88
|
+
callback(createRpcError(err), null);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
callback(createRpcError(error), null);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
startExecution(call, callback) {
|
|
96
|
+
RunnerServer.executionStartingProcessor
|
|
97
|
+
.process(call.request)
|
|
98
|
+
.then((res) => callback(null, res))
|
|
99
|
+
.catch((error) => callback(createRpcError(error), null));
|
|
100
|
+
}
|
|
101
|
+
initializeSpecDataStore(call, callback) {
|
|
102
|
+
try {
|
|
103
|
+
_1.DataStoreFactory.getSpecDataStore().clear();
|
|
104
|
+
callback(null, this.getEmptExecutionResponse());
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
callback(createRpcError(error), null);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
startSpecExecution(call, callback) {
|
|
111
|
+
RunnerServer.specExecutionStartingProcessor
|
|
112
|
+
.process(call.request)
|
|
113
|
+
.then((res) => callback(null, res))
|
|
114
|
+
.catch((error) => callback(createRpcError(error), null));
|
|
115
|
+
}
|
|
116
|
+
initializeScenarioDataStore(call, callback) {
|
|
117
|
+
try {
|
|
118
|
+
_1.DataStoreFactory.getScenarioDataStore().clear();
|
|
119
|
+
callback(null, this.getEmptExecutionResponse());
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
callback(createRpcError(error), null);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
startScenarioExecution(call, callback) {
|
|
126
|
+
RunnerServer.scenarioExecutionStartingProcessor
|
|
127
|
+
.process(call.request)
|
|
128
|
+
.then((res) => callback(null, res))
|
|
129
|
+
.catch((error) => callback(createRpcError(error), null));
|
|
130
|
+
}
|
|
131
|
+
startStepExecution(call, callback) {
|
|
132
|
+
RunnerServer.stepExecutionStartingProcessor
|
|
133
|
+
.process(call.request)
|
|
134
|
+
.then((res) => callback(null, res))
|
|
135
|
+
.catch((error) => callback(createRpcError(error), null));
|
|
136
|
+
}
|
|
137
|
+
executeStep(call, callback) {
|
|
138
|
+
RunnerServer.stepExecutionProcessor
|
|
139
|
+
.process(call.request)
|
|
140
|
+
.then((res) => callback(null, res))
|
|
141
|
+
.catch((error) => callback(createRpcError(error), null));
|
|
142
|
+
}
|
|
143
|
+
finishStepExecution(call, callback) {
|
|
144
|
+
RunnerServer.stepExecutionEndingProcessor
|
|
145
|
+
.process(call.request)
|
|
146
|
+
.then((res) => callback(null, res))
|
|
147
|
+
.catch((error) => callback(createRpcError(error), null));
|
|
148
|
+
}
|
|
149
|
+
finishScenarioExecution(call, callback) {
|
|
150
|
+
RunnerServer.scenarioExecutionEndingProcessor
|
|
151
|
+
.process(call.request)
|
|
152
|
+
.then((res) => callback(null, res))
|
|
153
|
+
.catch((error) => callback(createRpcError(error), null));
|
|
154
|
+
}
|
|
155
|
+
finishSpecExecution(call, callback) {
|
|
156
|
+
RunnerServer.specExecutionEndingProcessor
|
|
157
|
+
.process(call.request)
|
|
158
|
+
.then((res) => callback(null, res))
|
|
159
|
+
.catch((error) => callback(createRpcError(error), null));
|
|
160
|
+
}
|
|
161
|
+
finishExecution(call, callback) {
|
|
162
|
+
RunnerServer.executionEndingProcessor
|
|
163
|
+
.process(call.request)
|
|
164
|
+
.then((res) => callback(null, res))
|
|
165
|
+
.catch((error) => callback(createRpcError(error), null));
|
|
166
|
+
}
|
|
167
|
+
cacheFile(call, callback) {
|
|
168
|
+
try {
|
|
169
|
+
RunnerServer.cacheFileProcessor.process(call.request);
|
|
170
|
+
callback(null, new messages_pb_1.Empty());
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
callback(createRpcError(error), null);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
getStepName(call, callback) {
|
|
177
|
+
try {
|
|
178
|
+
callback(null, RunnerServer.stepNameProcessor.process(call.request));
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
callback(createRpcError(error), null);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
getGlobPatterns(call, callback) {
|
|
185
|
+
try {
|
|
186
|
+
const patterns = Util_1.Util.getImplDirs().map((dir) => {
|
|
187
|
+
return dir.split(node_path_1.sep).concat(["**", "*.ts"]).join("/");
|
|
188
|
+
});
|
|
189
|
+
const res = new messages_pb_1.ImplementationFileGlobPatternResponse();
|
|
190
|
+
res.setGlobpatternsList(patterns);
|
|
191
|
+
callback(null, res);
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
callback(createRpcError(error), null);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
getStepNames(call, callback) {
|
|
198
|
+
try {
|
|
199
|
+
const res = new messages_pb_1.StepNamesResponse();
|
|
200
|
+
res.setStepsList(StepRegistry_1.default.getStepTexts());
|
|
201
|
+
callback(null, res);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
callback(createRpcError(error), null);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
getStepPositions(call, callback) {
|
|
208
|
+
try {
|
|
209
|
+
callback(null, RunnerServer.stepPositionsProcessor.process(call.request));
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
callback(createRpcError(error), null);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
getImplementationFiles(call, callback) {
|
|
216
|
+
try {
|
|
217
|
+
const res = new messages_pb_1.ImplementationFileListResponse();
|
|
218
|
+
res.setImplementationfilepathsList(Util_1.Util.getListOfFiles());
|
|
219
|
+
callback(null, res);
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
callback(createRpcError(error), null);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
implementStub(call, callback) {
|
|
226
|
+
try {
|
|
227
|
+
callback(null, RunnerServer.stubImplementationCodeProcessor.process(call.request));
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
callback(createRpcError(error), null);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
refactor(call, callback) {
|
|
234
|
+
try {
|
|
235
|
+
callback(null, RunnerServer.refactorProcessor.process(call.request));
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
callback(createRpcError(error), null);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
kill(_call, callback) {
|
|
242
|
+
callback(null, new messages_pb_1.Empty());
|
|
243
|
+
setTimeout(() => {
|
|
244
|
+
(0, exports.stop)();
|
|
245
|
+
process.exit(0);
|
|
246
|
+
}, 100);
|
|
247
|
+
}
|
|
248
|
+
getEmptExecutionResponse() {
|
|
249
|
+
const res = new messages_pb_1.ExecutionStatusResponse();
|
|
250
|
+
const result = new spec_pb_1.ProtoExecutionResult();
|
|
251
|
+
result.setFailed(false);
|
|
252
|
+
res.setExecutionresult(result);
|
|
253
|
+
return res;
|
|
254
|
+
// eslint-disable-next-line padded-blocks
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
exports.default = RunnerServer;
|
|
258
|
+
function createRpcError(error) {
|
|
259
|
+
return {
|
|
260
|
+
code: constants_1.Status.INTERNAL,
|
|
261
|
+
message: error.message,
|
|
262
|
+
stack: error.stack ?? "",
|
|
263
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
264
|
+
details: `${error.message}${node_os_1.EOL}${error.stack ?? ""}`,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
let serverInstance = null;
|
|
268
|
+
const start = (host = "127.0.0.1:0", server = new grpc_js_1.Server(), runnerService = new RunnerServer(new StaticLoader_1.default())) => {
|
|
269
|
+
serverInstance = server;
|
|
270
|
+
server.addService(services_grpc_pb_1.RunnerService, runnerService);
|
|
271
|
+
let port = null;
|
|
272
|
+
server.bindAsync(host, grpc_js_1.ServerCredentials.createInsecure(), (err, boundPort) => {
|
|
273
|
+
if (err) {
|
|
274
|
+
throw err;
|
|
275
|
+
}
|
|
276
|
+
port = boundPort;
|
|
277
|
+
console.debug(`Listening on port:${port}`);
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
exports.start = start;
|
|
281
|
+
const stop = (server = serverInstance) => {
|
|
282
|
+
if (!serverInstance) {
|
|
283
|
+
console.debug("Server is not running.");
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
server?.tryShutdown((err) => {
|
|
287
|
+
if (err) {
|
|
288
|
+
console.error("Error shutting down the server:", err);
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
serverInstance = null;
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
exports.stop = stop;
|