@fincity/kirun-js 1.4.9 → 1.4.11

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.
@@ -28,6 +28,7 @@ import { StatementMessageType } from './StatementMessageType';
28
28
  import { isNullValue } from '../util/NullCheck';
29
29
  import { SchemaType } from '../json/schema/type/SchemaType';
30
30
  import { ArraySchemaType } from '../json/schema/array/ArraySchemaType';
31
+ import { ArgumentsTokenValueExtractor } from './tokenextractor/ArgumentsTokenValueExtractor';
31
32
 
32
33
  export class KIRuntime extends AbstractFunction {
33
34
  private static readonly PARAMETER_NEEDS_A_VALUE: string = 'Parameter "$" needs a value';
@@ -89,9 +90,17 @@ export class KIRuntime extends AbstractFunction {
89
90
 
90
91
  if (!inContext.getSteps()) inContext.setSteps(new Map());
91
92
 
93
+ if (inContext.getArguments()) {
94
+ inContext.addTokenValueExtractor(
95
+ new ArgumentsTokenValueExtractor(inContext.getArguments()!),
96
+ );
97
+ }
98
+
92
99
  if (this.debugMode) {
93
- console.log(`Executing: ${this.fd.getNamespace()}.${this.fd.getName()}`);
94
- console.log('Parameters: ', inContext);
100
+ console.log(
101
+ `EID: ${inContext.getExecutionId()} Executing: ${this.fd.getNamespace()}.${this.fd.getName()}`,
102
+ );
103
+ console.log(`EID: ${inContext.getExecutionId()} Parameters: `, inContext);
95
104
  }
96
105
 
97
106
  let eGraph: Tuple2<
@@ -100,14 +109,15 @@ export class KIRuntime extends AbstractFunction {
100
109
  > = await this.getExecutionPlan(inContext);
101
110
 
102
111
  if (this.debugMode) {
103
- console.log(eGraph.getT2()?.toString());
112
+ console.log(`EID: ${inContext.getExecutionId()} ${eGraph.getT2()?.toString()}`);
104
113
  }
105
114
 
106
115
  let unresolvedList: Tuple2<string, string>[] = eGraph.getT1();
107
116
 
108
117
  if (this.debugMode && unresolvedList.length) {
109
- console.log('Unresolved Dependencies: ');
118
+ console.log(`EID: ${inContext.getExecutionId()} Unresolved Dependencies: `);
110
119
  console.log(
120
+ `EID: ${inContext.getExecutionId()} `,
111
121
  unresolvedList.map((e) =>
112
122
  StringFormatter.format('Steps.$.$', e.getT1(), e.getT2()),
113
123
  ),
@@ -274,10 +284,10 @@ export class KIRuntime extends AbstractFunction {
274
284
  if (this.debugMode) {
275
285
  const s = vertex.getData().getStatement();
276
286
  console.log(
277
- `Step : ${s.getStatementName()} => ${s.getNamespace()}.${s.getName()}`,
287
+ `EID: ${inContext.getExecutionId()} Step : ${s.getStatementName()} => ${s.getNamespace()}.${s.getName()}`,
278
288
  );
279
289
  console.log(
280
- `Event : ${nextOutput.getName()} : `,
290
+ `EID: ${inContext.getExecutionId()} Event : ${nextOutput.getName()} : `,
281
291
  inContext.getSteps()!.get(s.getStatementName())!.get(nextOutput.getName()),
282
292
  );
283
293
  }
@@ -325,14 +335,23 @@ export class KIRuntime extends AbstractFunction {
325
335
  );
326
336
 
327
337
  if (this.debugMode) {
328
- console.log(`Step : ${s.getStatementName()} => ${s.getNamespace()}.${s.getName()}`);
329
- console.log('Arguments : ', args);
338
+ console.log(
339
+ `EID: ${inContext.getExecutionId()} Step : ${s.getStatementName()} => ${s.getNamespace()}.${s.getName()}`,
340
+ );
341
+ console.log(`EID: ${inContext.getExecutionId()} Arguments : `, args);
330
342
  }
331
343
 
332
344
  let context: Map<string, ContextElement> = inContext.getContext()!;
345
+ let fep: FunctionExecutionParameters;
333
346
 
334
- let result: FunctionOutput = await fun.execute(
335
- new FunctionExecutionParameters(
347
+ if (fun instanceof KIRuntime) {
348
+ fep = new FunctionExecutionParameters(
349
+ inContext.getFunctionRepository(),
350
+ inContext.getSchemaRepository(),
351
+ `${inContext.getExecutionId()}_${s.getStatementName()}`,
352
+ ).setArguments(args);
353
+ } else {
354
+ fep = new FunctionExecutionParameters(
336
355
  inContext.getFunctionRepository(),
337
356
  inContext.getSchemaRepository(),
338
357
  inContext.getExecutionId(),
@@ -343,8 +362,10 @@ export class KIRuntime extends AbstractFunction {
343
362
  .setEvents(inContext.getEvents()!)
344
363
  .setSteps(inContext.getSteps()!)
345
364
  .setStatementExecution(vertex.getData())
346
- .setCount(inContext.getCount()),
347
- );
365
+ .setCount(inContext.getCount());
366
+ }
367
+
368
+ let result: FunctionOutput = await fun.execute(fep);
348
369
 
349
370
  let er: EventResult | undefined = result.next();
350
371
 
@@ -365,9 +386,11 @@ export class KIRuntime extends AbstractFunction {
365
386
  .set(er.getName(), this.resolveInternalExpressions(er.getResult(), inContext));
366
387
 
367
388
  if (this.debugMode) {
368
- console.log(`Step : ${s.getStatementName()} => ${s.getNamespace()}.${s.getName()}`);
369
389
  console.log(
370
- `Event : ${er.getName()} : `,
390
+ `EID: ${inContext.getExecutionId()} Step : ${s.getStatementName()} => ${s.getNamespace()}.${s.getName()}`,
391
+ );
392
+ console.log(
393
+ `EID: ${inContext.getExecutionId()} Event : ${er.getName()} : `,
371
394
  inContext.getSteps()!.get(s.getStatementName())!.get(er.getName()),
372
395
  );
373
396
  }
@@ -0,0 +1,5 @@
1
+ import { Function } from '../function/Function';
2
+
3
+ export default function mapEntry(fun: Function): [string, Function] {
4
+ return [fun.getSignature().getName(), fun];
5
+ }