@kogeet/scapin-core-agent 0.1.6 → 0.1.7
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/context.d.ts +5 -2
- package/bin/core/context.d.ts.map +1 -1
- package/bin/core/context.js +4 -1
- package/bin/core/runsteps.d.ts +5 -2
- package/bin/core/runsteps.d.ts.map +1 -1
- package/bin/core/runsteps.js +12 -9
- package/bin/core/wsocket.io.d.ts +6 -1
- package/bin/core/wsocket.io.d.ts.map +1 -1
- package/bin/core/wsocket.io.js +32 -17
- package/bin/models/run.model.d.ts +4 -0
- package/bin/models/run.model.d.ts.map +1 -1
- package/bin/models/run.model.js +12 -6
- package/package.json +7 -7
package/bin/core/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RunParamModel } from '../models/run.model.js';
|
|
2
1
|
import { type varType } from '../models/parameter.model.js';
|
|
2
|
+
import type { RunParamModel } from '../models/run.model.js';
|
|
3
3
|
/**
|
|
4
4
|
* La classe **Context** stocke les variables utilisées lors du test
|
|
5
5
|
*/
|
|
@@ -11,7 +11,10 @@ export declare class Context {
|
|
|
11
11
|
loadVariable(params: RunParamModel[]): void;
|
|
12
12
|
valorize(param: RunParamModel): void;
|
|
13
13
|
dump(): [string, varType][];
|
|
14
|
-
resetVariables(
|
|
14
|
+
resetVariables(rVars?: {
|
|
15
|
+
name: string;
|
|
16
|
+
value: varType;
|
|
17
|
+
}[]): void;
|
|
15
18
|
}
|
|
16
19
|
export declare const context: Context;
|
|
17
20
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/core/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/core/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,OAAO,EAAC,MAAM,8BAA8B,CAAA;AACxE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAC;AAE1D;;GAEG;AACH,qBAAa,OAAO;IACX,OAAO,EAAE,MAAM,CAAM;IAE5B,OAAO,CAAC,SAAS,CAA6B;IAEvC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAIrC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;IAM3C,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE;IAgBpC,QAAQ,CAAC,KAAK,EAAE,aAAa;IAiB7B,IAAI;IAIJ,cAAc,CAAC,KAAK,GAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,EAAO;CAMrE;AAED,eAAO,MAAM,OAAO,SAAgB,CAAA"}
|
package/bin/core/context.js
CHANGED
|
@@ -47,8 +47,11 @@ export class Context {
|
|
|
47
47
|
dump() {
|
|
48
48
|
return [...this.variables.entries()];
|
|
49
49
|
}
|
|
50
|
-
resetVariables() {
|
|
50
|
+
resetVariables(rVars = []) {
|
|
51
51
|
this.variables.clear();
|
|
52
|
+
rVars.forEach((v) => {
|
|
53
|
+
this.setVariable(v.name, v.value);
|
|
54
|
+
});
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
export const context = new Context();
|
package/bin/core/runsteps.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { RunDataStepModel } from '../models/run.model.js';
|
|
1
|
+
import type { RunDataStepModel, Variable } from '../models/run.model.js';
|
|
2
2
|
export declare class RunSteps {
|
|
3
|
+
private runData;
|
|
3
4
|
private runstep;
|
|
4
5
|
private stepCtx;
|
|
5
6
|
stop: boolean;
|
|
6
|
-
|
|
7
|
+
constructor(rData: RunDataStepModel[], rVars: Variable[]);
|
|
8
|
+
run(pos: number, end: number): Promise<void>;
|
|
9
|
+
size(): number;
|
|
7
10
|
private runAStep;
|
|
8
11
|
}
|
|
9
12
|
//# sourceMappingURL=runsteps.d.ts.map
|
|
@@ -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":"AAIA,OAAO,KAAK,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAEtE,qBAAa,QAAQ;IACnB,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,OAAO,CAA2B;IACnC,IAAI,EAAE,OAAO,CAAQ;gBAET,KAAK,EAAE,gBAAgB,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE;IAKlD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAgBlC,IAAI;YAEG,QAAQ;CAwBvB"}
|
package/bin/core/runsteps.js
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import RunStep from './runstep.js';
|
|
2
|
-
import StepContext from './step.context.js';
|
|
3
1
|
import wSocketIo from './wsocket.io.js';
|
|
4
2
|
import { context, report } from "../index.js";
|
|
3
|
+
import StepContext from './step.context.js';
|
|
4
|
+
import RunStep from './runstep.js';
|
|
5
5
|
export class RunSteps {
|
|
6
|
+
runData;
|
|
6
7
|
runstep;
|
|
7
8
|
stepCtx = null;
|
|
8
9
|
stop = false;
|
|
9
|
-
|
|
10
|
-
this.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
constructor(rData, rVars) {
|
|
11
|
+
this.runData = rData;
|
|
12
|
+
context.resetVariables(rVars);
|
|
13
|
+
}
|
|
14
|
+
async run(pos, end) {
|
|
15
|
+
if (this.runData.length != 0 && pos != end) {
|
|
16
|
+
for (let i = pos; i < end; i++) {
|
|
17
|
+
const step = this.runData[i];
|
|
15
18
|
await this.runAStep(step);
|
|
16
19
|
if (this.stop) {
|
|
17
20
|
break;
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
|
-
wSocketIo.end();
|
|
21
23
|
}
|
|
22
24
|
else {
|
|
23
25
|
report.error('No steps data found');
|
|
24
26
|
wSocketIo.end();
|
|
25
27
|
}
|
|
26
28
|
}
|
|
29
|
+
size() { return this.runData.length; }
|
|
27
30
|
async runAStep(step) {
|
|
28
31
|
let stepResult;
|
|
29
32
|
report.stepStart(step.pos);
|
package/bin/core/wsocket.io.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Socket } from "socket.io-client";
|
|
2
2
|
declare class WsocketIo {
|
|
3
3
|
ioClient: Socket | null;
|
|
4
|
-
private
|
|
4
|
+
private runSteps;
|
|
5
5
|
private connected;
|
|
6
6
|
private termId;
|
|
7
7
|
start(): void;
|
|
@@ -11,6 +11,11 @@ declare class WsocketIo {
|
|
|
11
11
|
*/
|
|
12
12
|
end(): void;
|
|
13
13
|
private onError;
|
|
14
|
+
/** Réception des données d'exécution en mode Debug **/
|
|
15
|
+
private onDebugData;
|
|
16
|
+
/** Ordre d'exécution en mode Debug**/
|
|
17
|
+
private onDebugRun;
|
|
18
|
+
/** Ordre d'exécution en mode Job **/
|
|
14
19
|
private onRundata;
|
|
15
20
|
private onStatus;
|
|
16
21
|
private onPing;
|
|
@@ -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;IAEpB,KAAK;
|
|
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;IAEpB,KAAK;IAiDL,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAQjD;;OAEG;IACI,GAAG;IAQV,OAAO,CAAC,OAAO,CAUd;IAED,uDAAuD;IACvD,OAAO,CAAC,WAAW,CAGlB;IAED,sCAAsC;IACtC,OAAO,CAAC,UAAU,CAWjB;IAED,qCAAqC;IACrC,OAAO,CAAC,SAAS,CAGhB;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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { io, Socket } from "socket.io-client";
|
|
2
|
-
import { RunSteps } from './runsteps.js';
|
|
3
2
|
import { report } from "../index.js";
|
|
3
|
+
import { RunSteps } from './runsteps.js';
|
|
4
4
|
const url = process.env.ScapinServerURL || 'https://scapin.loicg.com';
|
|
5
5
|
const scapinAgentId = process.env.ScapinAgentId;
|
|
6
6
|
class WsocketIo {
|
|
7
7
|
ioClient = null;
|
|
8
|
-
|
|
8
|
+
runSteps = null;
|
|
9
9
|
connected = true;
|
|
10
10
|
termId = '';
|
|
11
11
|
start() {
|
|
@@ -37,11 +37,12 @@ class WsocketIo {
|
|
|
37
37
|
console.log(`Terminal ${scapinAgentId} is now connected to automation server!`);
|
|
38
38
|
}));
|
|
39
39
|
this.ioClient.on('connect_error', this.onError);
|
|
40
|
-
this.ioClient.on('data', this.
|
|
41
|
-
this.ioClient.on('
|
|
40
|
+
this.ioClient.on('data', this.onDebugData);
|
|
41
|
+
this.ioClient.on('run', this.onDebugRun);
|
|
42
|
+
this.ioClient.on('run-data', this.onRundata);
|
|
42
43
|
this.ioClient.on('status', this.onStatus);
|
|
43
44
|
this.ioClient.on('status-ping', this.onPing);
|
|
44
|
-
this.ioClient.on('
|
|
45
|
+
this.ioClient.on('stop-run', this.onStopRun);
|
|
45
46
|
// this.ioClient.on('reconnect_attempt', (n: number) => { console.log(`${n} tentative de reconnexion`)})
|
|
46
47
|
this.ioClient.on('reconnect', (n) => {
|
|
47
48
|
console.log(`${n} reconnexion réussies`);
|
|
@@ -65,7 +66,7 @@ class WsocketIo {
|
|
|
65
66
|
if (this.ioClient) {
|
|
66
67
|
this.ioClient.emit('end');
|
|
67
68
|
}
|
|
68
|
-
this.
|
|
69
|
+
this.runSteps = null;
|
|
69
70
|
report.clearStepLog();
|
|
70
71
|
}
|
|
71
72
|
onError = (err) => {
|
|
@@ -80,19 +81,33 @@ class WsocketIo {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
/** Réception des données d'exécution en mode Debug **/
|
|
85
|
+
onDebugData = (stepsData, runVar) => {
|
|
86
|
+
this.runSteps = stepsData && runVar ? new RunSteps(stepsData, runVar) : null;
|
|
87
|
+
};
|
|
88
|
+
/** Ordre d'exécution en mode Debug**/
|
|
89
|
+
onDebugRun = async (pos, end) => {
|
|
90
|
+
if (this.runSteps && pos && end) {
|
|
91
|
+
try {
|
|
92
|
+
await this.runSteps.run(pos, end);
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
console.log('Unexpected error : ' + e.message);
|
|
96
|
+
wSocketIo.end();
|
|
97
|
+
}
|
|
87
98
|
}
|
|
88
|
-
|
|
89
|
-
console.log(
|
|
90
|
-
wSocketIo.end();
|
|
99
|
+
else {
|
|
100
|
+
console.log("Invalid executive data");
|
|
91
101
|
}
|
|
92
102
|
};
|
|
103
|
+
/** Ordre d'exécution en mode Job **/
|
|
104
|
+
onRundata = async (stepsData, runVars) => {
|
|
105
|
+
this.onDebugData(stepsData, runVars);
|
|
106
|
+
await this.onDebugRun(0, this.runSteps?.size() || 0);
|
|
107
|
+
};
|
|
93
108
|
onStatus = () => {
|
|
94
109
|
if (this.ioClient) {
|
|
95
|
-
this.ioClient.emit('status', this.
|
|
110
|
+
this.ioClient.emit('status', this.runSteps ? 'busy' : 'available');
|
|
96
111
|
}
|
|
97
112
|
};
|
|
98
113
|
onPing = (ack) => {
|
|
@@ -101,10 +116,10 @@ class WsocketIo {
|
|
|
101
116
|
};
|
|
102
117
|
onStopRun = () => {
|
|
103
118
|
console.log('onStopRun');
|
|
104
|
-
if (this.
|
|
105
|
-
this.
|
|
119
|
+
if (this.runSteps) {
|
|
120
|
+
this.runSteps.stop = true;
|
|
106
121
|
}
|
|
107
|
-
this.
|
|
122
|
+
this.runSteps = null;
|
|
108
123
|
report.clearStepLog();
|
|
109
124
|
};
|
|
110
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.model.d.ts","sourceRoot":"","sources":["../../src/models/run.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,KAAK,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAEjE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,aAAa,CAAA;IACnB,GAAG,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACxB,MAAM,EAAE,aAAa,EAAE,CAAA;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,aAAa,EAAE,CAAC;IAG5B,MAAM,EAAE,aAAa,EAAE,C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E,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,eAAO,MAAM,UAAU;;;;gBAIT,MAAM,GAAG,SAAS;EAW9B,CAAA;AAEF,eAAO,MAAM,QAAQ;;;;gBAIP,MAAM,GAAG,SAAS;EAW9B,CAAA;AAEF,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAA;CACd"}
|
package/bin/models/run.model.js
CHANGED
|
@@ -5,9 +5,12 @@ export const stepStatus = Object.freeze({
|
|
|
5
5
|
fail: 2,
|
|
6
6
|
toString(n) {
|
|
7
7
|
switch (n) {
|
|
8
|
-
case 0:
|
|
9
|
-
|
|
10
|
-
case
|
|
8
|
+
case 0:
|
|
9
|
+
return 'cancel';
|
|
10
|
+
case 1:
|
|
11
|
+
return 'pass';
|
|
12
|
+
case 2:
|
|
13
|
+
return 'fail';
|
|
11
14
|
}
|
|
12
15
|
return '';
|
|
13
16
|
},
|
|
@@ -18,9 +21,12 @@ export const logLevel = Object.freeze({
|
|
|
18
21
|
error: 2,
|
|
19
22
|
toString(n) {
|
|
20
23
|
switch (n) {
|
|
21
|
-
case 0:
|
|
22
|
-
|
|
23
|
-
case
|
|
24
|
+
case 0:
|
|
25
|
+
return 'info';
|
|
26
|
+
case 1:
|
|
27
|
+
return 'warning';
|
|
28
|
+
case 2:
|
|
29
|
+
return 'error';
|
|
24
30
|
}
|
|
25
31
|
return '';
|
|
26
32
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kogeet/scapin-core-agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Scapin Core Agent",
|
|
5
5
|
"author": "Loïc Griveau",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"np": "np --no-tests --message=core-agent-%s"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@types/node": "^
|
|
21
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
22
|
-
"@typescript-eslint/parser": "^
|
|
23
|
-
"eslint": "^
|
|
24
|
-
"typescript": "^5.
|
|
20
|
+
"@types/node": "^25.3.3",
|
|
21
|
+
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
22
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
23
|
+
"eslint": "^9.39.3",
|
|
24
|
+
"typescript": "^5.9.3"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"jison": "^0.4.18",
|
|
28
|
-
"socket.io-client": "^4.
|
|
28
|
+
"socket.io-client": "^4.8.3"
|
|
29
29
|
},
|
|
30
30
|
"type": "module"
|
|
31
31
|
}
|