@kogeet/scapin-core-agent 0.1.8 → 0.2.0
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/bin/core/runsteps.d.ts +2 -2
- package/bin/core/runsteps.d.ts.map +1 -1
- package/bin/core/runsteps.js +14 -6
- package/bin/core/step.context.js +1 -1
- package/bin/core/wsocket.io.d.ts +5 -2
- package/bin/core/wsocket.io.d.ts.map +1 -1
- package/bin/core/wsocket.io.js +30 -11
- package/package.json +1 -1
package/bin/core/runsteps.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export declare class RunSteps {
|
|
|
4
4
|
private runStep;
|
|
5
5
|
private stepCtx;
|
|
6
6
|
stop: boolean;
|
|
7
|
-
constructor(
|
|
8
|
-
run(pos
|
|
7
|
+
constructor(data: RunDataStepModel[] | RunDataStepModel | undefined, rVars: Variable[]);
|
|
8
|
+
run(pos?: number, end?: number): Promise<void>;
|
|
9
9
|
size(): number;
|
|
10
10
|
close(): void;
|
|
11
11
|
private runAStep;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runsteps.d.ts","sourceRoot":"","sources":["../../src/core/runsteps.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runsteps.d.ts","sourceRoot":"","sources":["../../src/core/runsteps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAKtE,qBAAa,QAAQ;IACnB,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,OAAO,CAA2B;IACnC,IAAI,EAAE,OAAO,CAAQ;gBAET,IAAI,EAAE,gBAAgB,EAAE,GAAG,gBAAgB,GAAG,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE;IAShF,GAAG,CAAC,GAAG,GAAE,MAAU,EAAE,GAAG,GAAE,MAA4B;IAkB5D,IAAI;IAIJ,KAAK;YAKE,QAAQ;CAwBvB"}
|
package/bin/core/runsteps.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import wSocketIo from './wsocket.io.js';
|
|
2
1
|
import { context, report } from "../index.js";
|
|
3
|
-
import StepContext from './step.context.js';
|
|
4
2
|
import RunStep from './runstep.js';
|
|
3
|
+
import StepContext from './step.context.js';
|
|
4
|
+
import wSocketIo from './wsocket.io.js';
|
|
5
5
|
export class RunSteps {
|
|
6
6
|
runData;
|
|
7
7
|
runStep = new RunStep();
|
|
8
8
|
stepCtx = null;
|
|
9
9
|
stop = false;
|
|
10
|
-
constructor(
|
|
11
|
-
|
|
10
|
+
constructor(data, rVars) {
|
|
11
|
+
if (data) {
|
|
12
|
+
this.runData = !Array.isArray(data) ? [data] : data;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
this.runData = [];
|
|
16
|
+
}
|
|
12
17
|
context.resetVariables(rVars);
|
|
13
18
|
}
|
|
14
|
-
async run(pos, end) {
|
|
19
|
+
async run(pos = 0, end = this.runData.length) {
|
|
20
|
+
console.log(`run pos=${pos}, end=${end} runData:`, this.runData);
|
|
15
21
|
if (this.runData.length != 0) {
|
|
16
22
|
for (let i = pos; i < end; i++) {
|
|
17
23
|
if (i < this.runData.length) {
|
|
@@ -28,7 +34,9 @@ export class RunSteps {
|
|
|
28
34
|
wSocketIo.end();
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
|
-
size() {
|
|
37
|
+
size() {
|
|
38
|
+
return this.runData.length;
|
|
39
|
+
}
|
|
32
40
|
close() {
|
|
33
41
|
this.runData = [];
|
|
34
42
|
context.resetVariables();
|
package/bin/core/step.context.js
CHANGED
|
@@ -49,7 +49,7 @@ export default class StepContext {
|
|
|
49
49
|
// console.log('variables: ', [...ctxVars.map<string>(v => `${v.name}=${v.value}`)])
|
|
50
50
|
this.params.map((param) => {
|
|
51
51
|
// console.log('Parameter ', {...param})
|
|
52
|
-
if (param.value[0] === "=" && param.type) {
|
|
52
|
+
if (param.value && param.value[0] === "=" && param.type) {
|
|
53
53
|
let input = param.value;
|
|
54
54
|
if (input[0] === '=')
|
|
55
55
|
input = input.slice(1);
|
package/bin/core/wsocket.io.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ declare class WsocketIo {
|
|
|
4
4
|
private runSteps;
|
|
5
5
|
private connected;
|
|
6
6
|
private termId;
|
|
7
|
+
private modeJobRun;
|
|
7
8
|
start(): void;
|
|
8
9
|
report(message: string, stepStatus: number): void;
|
|
9
10
|
/**
|
|
@@ -11,10 +12,12 @@ declare class WsocketIo {
|
|
|
11
12
|
*/
|
|
12
13
|
end(): void;
|
|
13
14
|
private onError;
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
private onRundataOldVersion;
|
|
16
|
+
/** Réception des données d'exécution **/
|
|
17
|
+
private onData;
|
|
16
18
|
/** Ordre d'exécution en mode Debug**/
|
|
17
19
|
private onDebugRun;
|
|
20
|
+
private onRun;
|
|
18
21
|
private onDebugStop;
|
|
19
22
|
/** Ordre d'exécution en mode Job **/
|
|
20
23
|
private onRundata;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsocket.io.d.ts","sourceRoot":"","sources":["../../src/core/wsocket.io.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAW5C,cAAM,SAAS;IACN,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAO;IACrC,OAAO,CAAC,QAAQ,CAAwB;IACxC,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,MAAM,CAAa;
|
|
1
|
+
{"version":3,"file":"wsocket.io.d.ts","sourceRoot":"","sources":["../../src/core/wsocket.io.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAW5C,cAAM,SAAS;IACN,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAO;IACrC,OAAO,CAAC,QAAQ,CAAwB;IACxC,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,UAAU,CAAQ;IAEnB,KAAK;IAoDL,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAQjD;;OAEG;IACI,GAAG;IASV,OAAO,CAAC,OAAO,CAUd;IAED,OAAO,CAAC,mBAAmB,CAU1B;IAED,yCAAyC;IACzC,OAAO,CAAC,MAAM,CAGb;IAED,sCAAsC;IACtC,OAAO,CAAC,UAAU,CAGjB;YAEa,KAAK;IAanB,OAAO,CAAC,WAAW,CAGlB;IAED,qCAAqC;IACrC,OAAO,CAAC,SAAS,CAIhB;IAED,OAAO,CAAC,QAAQ,CAIf;IAED,OAAO,CAAC,MAAM,CAGb;IAED,OAAO,CAAC,SAAS,CAOhB;CAEF;AAED,QAAA,MAAM,SAAS,WAAkB,CAAA;AACjC,eAAe,SAAS,CAAA"}
|
package/bin/core/wsocket.io.js
CHANGED
|
@@ -8,6 +8,7 @@ class WsocketIo {
|
|
|
8
8
|
runSteps = null;
|
|
9
9
|
connected = true;
|
|
10
10
|
termId = '';
|
|
11
|
+
modeJobRun = false;
|
|
11
12
|
start() {
|
|
12
13
|
console.log(`Start websocket url = ${url}, activation key = ${scapinAgentId}`);
|
|
13
14
|
const t = scapinAgentId ? scapinAgentId.split('/') : '__';
|
|
@@ -37,10 +38,12 @@ class WsocketIo {
|
|
|
37
38
|
console.log(`Terminal ${scapinAgentId} is now connected to automation server!`);
|
|
38
39
|
}));
|
|
39
40
|
this.ioClient.on('connect_error', this.onError);
|
|
40
|
-
this.ioClient.on('data', this.
|
|
41
|
-
this.ioClient.on('
|
|
42
|
-
this.ioClient.on('
|
|
43
|
-
this.ioClient.on('run
|
|
41
|
+
this.ioClient.on('data', this.onRundataOldVersion);
|
|
42
|
+
this.ioClient.on('rundata', this.onRundataOldVersion);
|
|
43
|
+
this.ioClient.on('debug-data', this.onData);
|
|
44
|
+
this.ioClient.on('debug-run', this.onDebugRun);
|
|
45
|
+
this.ioClient.on('debug-stop', this.onDebugStop);
|
|
46
|
+
this.ioClient.on('job-run-data', this.onRundata);
|
|
44
47
|
this.ioClient.on('status', this.onStatus);
|
|
45
48
|
this.ioClient.on('status-ping', this.onPing);
|
|
46
49
|
this.ioClient.on('stop-run', this.onStopRun);
|
|
@@ -83,17 +86,32 @@ class WsocketIo {
|
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
};
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
onRundataOldVersion = async (stepsdata) => {
|
|
90
|
+
console.log(`Réception event 'data' :`, stepsdata);
|
|
91
|
+
this.runSteps = new RunSteps(stepsdata, []);
|
|
92
|
+
try {
|
|
93
|
+
await this.runSteps.run();
|
|
94
|
+
wSocketIo.end();
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
console.log('Unexpected error : ' + e.message);
|
|
98
|
+
wSocketIo.end();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
/** Réception des données d'exécution **/
|
|
102
|
+
onData = (stepsData, runVar) => {
|
|
88
103
|
console.log(`Data of the run are: ${stepsData?.length || 0} steps and ${runVar?.length || 0} variables`);
|
|
89
104
|
this.runSteps = stepsData && runVar ? new RunSteps(stepsData, runVar) : null;
|
|
90
105
|
};
|
|
91
106
|
/** Ordre d'exécution en mode Debug**/
|
|
92
107
|
onDebugRun = async (pos, end) => {
|
|
93
108
|
console.log(`Running in Debug mode from ${pos} to ${end}`);
|
|
94
|
-
|
|
109
|
+
await this.onRun(pos, end);
|
|
110
|
+
};
|
|
111
|
+
async onRun(start, end) {
|
|
112
|
+
if (this.runSteps && typeof start === 'number' && typeof end === 'number') {
|
|
95
113
|
try {
|
|
96
|
-
await this.runSteps.run(
|
|
114
|
+
await this.runSteps.run(start, end);
|
|
97
115
|
}
|
|
98
116
|
catch (e) {
|
|
99
117
|
console.log('Unexpected error : ' + e.message);
|
|
@@ -103,15 +121,16 @@ class WsocketIo {
|
|
|
103
121
|
else {
|
|
104
122
|
console.log("Invalid executive data");
|
|
105
123
|
}
|
|
106
|
-
}
|
|
124
|
+
}
|
|
107
125
|
onDebugStop = () => {
|
|
108
126
|
console.log("Arrêt du mode debug");
|
|
109
127
|
wSocketIo.end();
|
|
110
128
|
};
|
|
111
129
|
/** Ordre d'exécution en mode Job **/
|
|
112
130
|
onRundata = async (stepsData, runVars) => {
|
|
113
|
-
this.
|
|
114
|
-
await this.
|
|
131
|
+
this.onData(stepsData, runVars);
|
|
132
|
+
await this.onRun(0, this.runSteps?.size() || 0);
|
|
133
|
+
wSocketIo.end();
|
|
115
134
|
};
|
|
116
135
|
onStatus = () => {
|
|
117
136
|
if (this.ioClient) {
|