@haibun/core 3.8.4 → 3.9.3
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/build/currentVersion.d.ts +1 -1
- package/build/currentVersion.js +1 -1
- package/build/steps/finalizer-stepper.d.ts +14 -0
- package/build/steps/finalizer-stepper.d.ts.map +1 -0
- package/build/steps/finalizer-stepper.js +71 -0
- package/build/steps/finalizer-stepper.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const currentVersion = "3.
|
|
1
|
+
export declare const currentVersion = "3.9.3";
|
|
2
2
|
//# sourceMappingURL=currentVersion.d.ts.map
|
package/build/currentVersion.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const currentVersion = '3.
|
|
1
|
+
export const currentVersion = '3.9.3';
|
|
2
2
|
//# sourceMappingURL=currentVersion.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AStepper, IHasCycles, TStepperSteps } from '../lib/astepper.js';
|
|
2
|
+
import { IStepperCycles, TWorld } from '../lib/defs.js';
|
|
3
|
+
import { FlowRunner } from '../lib/core/flow-runner.js';
|
|
4
|
+
export default class FinalizerStepper extends AStepper implements IHasCycles {
|
|
5
|
+
description: string;
|
|
6
|
+
flowRunner: FlowRunner;
|
|
7
|
+
registeredStatementsByFeature: Map<string, string[]>;
|
|
8
|
+
activeFeaturePath?: string;
|
|
9
|
+
private runFinalizersForFeature;
|
|
10
|
+
cycles: IStepperCycles;
|
|
11
|
+
setWorld(world: TWorld, steppers: AStepper[]): Promise<void>;
|
|
12
|
+
steps: TStepperSteps;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=finalizer-stepper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalizer-stepper.d.ts","sourceRoot":"","sources":["../../src/steps/finalizer-stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAgB,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAKxD,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,QAAS,YAAW,UAAU;IAC3E,WAAW,SAA8D;IAEzE,UAAU,EAAE,UAAU,CAAC;IACvB,6BAA6B,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAa;IACjE,iBAAiB,CAAC,EAAE,MAAM,CAAC;YAEb,uBAAuB;IAoBrC,MAAM,EAAE,cAAc,CAuBpB;IAEI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE;IAKlD,KAAK,EAAE,aAAa,CAelB;CACF"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { AStepper } from '../lib/astepper.js';
|
|
2
|
+
import { FlowRunner } from '../lib/core/flow-runner.js';
|
|
3
|
+
import { OK } from '../schema/protocol.js';
|
|
4
|
+
import { DOMAIN_STATEMENT } from '../lib/domain-types.js';
|
|
5
|
+
import { actionNotOK } from '../lib/util/index.js';
|
|
6
|
+
export default class FinalizerStepper extends AStepper {
|
|
7
|
+
description = 'Runs registered finalizer statements at end of execution';
|
|
8
|
+
flowRunner;
|
|
9
|
+
registeredStatementsByFeature = new Map();
|
|
10
|
+
activeFeaturePath;
|
|
11
|
+
async runFinalizersForFeature(featurePath) {
|
|
12
|
+
const statements = this.registeredStatementsByFeature.get(featurePath);
|
|
13
|
+
if (statements && statements.length > 0) {
|
|
14
|
+
for (const [index, statement] of statements.entries()) {
|
|
15
|
+
const result = await this.flowRunner.runStatement(statement, {
|
|
16
|
+
seqPath: [998, index + 1],
|
|
17
|
+
intent: { mode: 'authoritative' },
|
|
18
|
+
});
|
|
19
|
+
if (result.kind !== 'ok') {
|
|
20
|
+
this.getWorld().eventLogger.warn(`finalizer-stepper: statement failed: ${statement} :: ${result.message || 'unknown error'}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
this.registeredStatementsByFeature.delete(featurePath);
|
|
25
|
+
}
|
|
26
|
+
cycles = {
|
|
27
|
+
startExecution: () => {
|
|
28
|
+
this.registeredStatementsByFeature = new Map();
|
|
29
|
+
this.activeFeaturePath = undefined;
|
|
30
|
+
},
|
|
31
|
+
startFeature: ({ resolvedFeature }) => {
|
|
32
|
+
this.activeFeaturePath = resolvedFeature.path;
|
|
33
|
+
if (!this.registeredStatementsByFeature.has(resolvedFeature.path)) {
|
|
34
|
+
this.registeredStatementsByFeature.set(resolvedFeature.path, []);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
endFeature: async () => {
|
|
38
|
+
if (!this.activeFeaturePath) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
await this.runFinalizersForFeature(this.activeFeaturePath);
|
|
42
|
+
this.activeFeaturePath = undefined;
|
|
43
|
+
},
|
|
44
|
+
endExecution: async () => {
|
|
45
|
+
for (const featurePath of this.registeredStatementsByFeature.keys()) {
|
|
46
|
+
await this.runFinalizersForFeature(featurePath);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
async setWorld(world, steppers) {
|
|
51
|
+
await super.setWorld(world, steppers);
|
|
52
|
+
this.flowRunner = new FlowRunner(world, steppers);
|
|
53
|
+
}
|
|
54
|
+
steps = {
|
|
55
|
+
registerFinalizer: {
|
|
56
|
+
gwta: `finalizer {statement:${DOMAIN_STATEMENT}}`,
|
|
57
|
+
action: (_, featureStep) => {
|
|
58
|
+
const statement = featureStep.action?.stepValuesMap?.statement?.term?.trim();
|
|
59
|
+
if (!statement) {
|
|
60
|
+
return actionNotOK('finalizer statement is required');
|
|
61
|
+
}
|
|
62
|
+
const featurePath = this.getWorld().runtime.currentFeaturePath || featureStep.source.path;
|
|
63
|
+
const statements = this.registeredStatementsByFeature.get(featurePath) || [];
|
|
64
|
+
statements.push(statement);
|
|
65
|
+
this.registeredStatementsByFeature.set(featurePath, statements);
|
|
66
|
+
return OK;
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=finalizer-stepper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalizer-stepper.js","sourceRoot":"","sources":["../../src/steps/finalizer-stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA6B,MAAM,oBAAoB,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,QAAQ;IACrD,WAAW,GAAG,0DAA0D,CAAC;IAEzE,UAAU,CAAa;IACvB,6BAA6B,GAA0B,IAAI,GAAG,EAAE,CAAC;IACjE,iBAAiB,CAAU;IAEnB,KAAK,CAAC,uBAAuB,CAAC,WAAmB;QACxD,MAAM,UAAU,GAAG,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACvE,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzC,KAAK,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;gBACvD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,EAAE;oBAC5D,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC;oBACzB,MAAM,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;iBACjC,CAAC,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