@kogeet/scapin-core-agent 0.1.8 → 0.2.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.
@@ -4,8 +4,8 @@ export declare class RunSteps {
4
4
  private runStep;
5
5
  private stepCtx;
6
6
  stop: boolean;
7
- constructor(rData: RunDataStepModel[], rVars: Variable[]);
8
- run(pos: number, end: number): Promise<void>;
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":"AAIA,OAAO,KAAK,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAEtE,qBAAa,QAAQ;IACnB,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,OAAO,CAAgB;IAC/B,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;IAkBlC,IAAI;IAEJ,KAAK;YAKE,QAAQ;CAwBvB"}
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,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"}
@@ -7,11 +7,16 @@ export class RunSteps {
7
7
  runStep = new RunStep();
8
8
  stepCtx = null;
9
9
  stop = false;
10
- constructor(rData, rVars) {
11
- this.runData = rData;
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) {
15
20
  if (this.runData.length != 0) {
16
21
  for (let i = pos; i < end; i++) {
17
22
  if (i < this.runData.length) {
@@ -28,7 +33,9 @@ export class RunSteps {
28
33
  wSocketIo.end();
29
34
  }
30
35
  }
31
- size() { return this.runData.length; }
36
+ size() {
37
+ return this.runData.length;
38
+ }
32
39
  close() {
33
40
  this.runData = [];
34
41
  context.resetVariables();
@@ -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);
@@ -11,10 +11,12 @@ 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;
14
+ private onRundataOldVersion;
15
+ /** Réception des données d'exécution **/
16
+ private onData;
16
17
  /** Ordre d'exécution en mode Debug**/
17
18
  private onDebugRun;
19
+ private onRun;
18
20
  private onDebugStop;
19
21
  /** Ordre d'exécution en mode Job **/
20
22
  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;IAEpB,KAAK;IAkDL,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAQjD;;OAEG;IACI,GAAG;IASV,OAAO,CAAC,OAAO,CAUd;IAED,uDAAuD;IACvD,OAAO,CAAC,WAAW,CAGlB;IAED,sCAAsC;IACtC,OAAO,CAAC,UAAU,CAYjB;IAED,OAAO,CAAC,WAAW,CAGlB;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"}
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;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"}
@@ -37,10 +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.onDebugData);
41
- this.ioClient.on('run', this.onDebugRun);
42
- this.ioClient.on('stop-debugger', this.onDebugStop);
43
- this.ioClient.on('run-data', this.onRundata);
40
+ this.ioClient.on('data', this.onRundataOldVersion);
41
+ this.ioClient.on('rundata', this.onRundataOldVersion);
42
+ this.ioClient.on('debug-data', this.onData);
43
+ this.ioClient.on('debug-run', this.onDebugRun);
44
+ this.ioClient.on('debug-stop', this.onDebugStop);
45
+ this.ioClient.on('job-run-data', this.onRundata);
44
46
  this.ioClient.on('status', this.onStatus);
45
47
  this.ioClient.on('status-ping', this.onPing);
46
48
  this.ioClient.on('stop-run', this.onStopRun);
@@ -83,17 +85,32 @@ class WsocketIo {
83
85
  }
84
86
  }
85
87
  };
86
- /** Réception des données d'exécution en mode Debug **/
87
- onDebugData = (stepsData, runVar) => {
88
+ onRundataOldVersion = async (stepsdata) => {
89
+ // console.log(`Réception event 'data' :`, stepsdata)
90
+ this.runSteps = new RunSteps(stepsdata, []);
91
+ try {
92
+ await this.runSteps.run();
93
+ wSocketIo.end();
94
+ }
95
+ catch (e) {
96
+ console.log('Unexpected error : ' + e.message);
97
+ wSocketIo.end();
98
+ }
99
+ };
100
+ /** Réception des données d'exécution **/
101
+ onData = (stepsData, runVar) => {
88
102
  console.log(`Data of the run are: ${stepsData?.length || 0} steps and ${runVar?.length || 0} variables`);
89
103
  this.runSteps = stepsData && runVar ? new RunSteps(stepsData, runVar) : null;
90
104
  };
91
105
  /** Ordre d'exécution en mode Debug**/
92
106
  onDebugRun = async (pos, end) => {
93
107
  console.log(`Running in Debug mode from ${pos} to ${end}`);
94
- if (this.runSteps && typeof pos === 'number' && typeof end === 'number') {
108
+ await this.onRun(pos, end);
109
+ };
110
+ async onRun(start, end) {
111
+ if (this.runSteps && typeof start === 'number' && typeof end === 'number') {
95
112
  try {
96
- await this.runSteps.run(pos, end);
113
+ await this.runSteps.run(start, end);
97
114
  }
98
115
  catch (e) {
99
116
  console.log('Unexpected error : ' + e.message);
@@ -103,15 +120,16 @@ class WsocketIo {
103
120
  else {
104
121
  console.log("Invalid executive data");
105
122
  }
106
- };
123
+ }
107
124
  onDebugStop = () => {
108
125
  console.log("Arrêt du mode debug");
109
126
  wSocketIo.end();
110
127
  };
111
128
  /** Ordre d'exécution en mode Job **/
112
129
  onRundata = async (stepsData, runVars) => {
113
- this.onDebugData(stepsData, runVars);
114
- await this.onDebugRun(0, this.runSteps?.size() || 0);
130
+ this.onData(stepsData, runVars);
131
+ await this.onRun(0, this.runSteps?.size() || 0);
132
+ wSocketIo.end();
115
133
  };
116
134
  onStatus = () => {
117
135
  if (this.ioClient) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kogeet/scapin-core-agent",
3
- "version": "0.1.8",
3
+ "version": "0.2.1",
4
4
  "description": "Scapin Core Agent",
5
5
  "author": "Loïc Griveau",
6
6
  "license": "MIT",