@moostjs/event-wf 0.7.2 → 0.7.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/dist/index.cjs +9 -40
- package/dist/index.mjs +9 -40
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -102,45 +102,6 @@ function getWfMate() {
|
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
//#endregion
|
|
106
|
-
//#region packages/event-wf/src/run-scope.ts
|
|
107
|
-
/** Marks a `WooksWf` whose runs release their moost DI scope (see {@link releaseRunScopes}). */ const RUN_SCOPES_RELEASED = Symbol.for("moost-wf.run-scopes-released");
|
|
108
|
-
/** Marks the cleanup that releases a run's scope, so a resumed run does not wrap it twice. */ const RUN_SCOPE_CLEANUP = Symbol.for("moost-wf.run-scope-cleanup");
|
|
109
|
-
/** Run options whose `cleanup` also releases the run's moost DI scope (when the run ends). */ function withRunScopeCleanup(opts) {
|
|
110
|
-
const own = opts?.cleanup;
|
|
111
|
-
if (own?.[RUN_SCOPE_CLEANUP]) return opts;
|
|
112
|
-
const cleanup = () => {
|
|
113
|
-
try {
|
|
114
|
-
own?.();
|
|
115
|
-
} finally {
|
|
116
|
-
(0, moost.getMoostInfact)().unregisterScope((0, moost.useScopeId)());
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
cleanup[RUN_SCOPE_CLEANUP] = true;
|
|
120
|
-
return {
|
|
121
|
-
...opts,
|
|
122
|
-
cleanup
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Makes every run of `wfApp` release its moost DI scope when it ends — whoever starts it:
|
|
127
|
-
* `MoostWf.start()`, `getWfApp().start()`, an outlet trigger or `mintWfToken()`. Step handlers
|
|
128
|
-
* keep the run's scope (`FOR_EVENT` instances) alive across steps, so the run end releases it.
|
|
129
|
-
* Replaces the instance's `start`/`resume`: anything that captured them before (e.g. a
|
|
130
|
-
* `createOutletHandler(wooksWf)` made before `new MoostWf(wooksWf)`) bypasses the release.
|
|
131
|
-
*/ function releaseRunScopes(wfApp) {
|
|
132
|
-
const app = wfApp;
|
|
133
|
-
if (app[RUN_SCOPES_RELEASED]) return;
|
|
134
|
-
app[RUN_SCOPES_RELEASED] = true;
|
|
135
|
-
const { start, resume } = app;
|
|
136
|
-
app.start = function(schemaId, context, opts) {
|
|
137
|
-
return start.call(this, schemaId, context, withRunScopeCleanup(opts));
|
|
138
|
-
};
|
|
139
|
-
app.resume = function(state, opts) {
|
|
140
|
-
return resume.call(this, state, withRunScopeCleanup(opts));
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
105
|
//#endregion
|
|
145
106
|
//#region packages/event-wf/src/event-wf.ts
|
|
146
107
|
function _define_property(obj, key, value) {
|
|
@@ -153,6 +114,14 @@ function _define_property(obj, key, value) {
|
|
|
153
114
|
else obj[key] = value;
|
|
154
115
|
return obj;
|
|
155
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Releases the moost DI scope of a workflow run when the run ends (paused, finished or
|
|
119
|
+
* failed): step handlers keep the run's `FOR_EVENT` instances alive across steps. Runs after
|
|
120
|
+
* the run's own `cleanup`, inside the workflow context. Module-level, so attaching it to a
|
|
121
|
+
* `WooksWf` shared by several `MoostWf` instances registers it once.
|
|
122
|
+
*/ function releaseRunScope() {
|
|
123
|
+
(0, moost.getMoostInfact)().unregisterScope((0, moost.useScopeId)());
|
|
124
|
+
}
|
|
156
125
|
const LOGGER_TITLE = "moost-wf";
|
|
157
126
|
/**
|
|
158
127
|
* Moost adapter for workflow events. Wraps `@wooksjs/event-wf` to register
|
|
@@ -333,7 +302,7 @@ const LOGGER_TITLE = "moost-wf";
|
|
|
333
302
|
if (opts && opts instanceof _wooksjs_event_wf.WooksWf) this.wfApp = opts;
|
|
334
303
|
else if (opts) this.wfApp = (0, _wooksjs_event_wf.createWfApp)(opts);
|
|
335
304
|
else this.wfApp = (0, _wooksjs_event_wf.createWfApp)();
|
|
336
|
-
|
|
305
|
+
this.wfApp.attachCleanup(releaseRunScope);
|
|
337
306
|
}
|
|
338
307
|
};
|
|
339
308
|
/** Names this adapter for DI independently of class identity (see `MOOST_ADAPTER_BRAND`). */ _define_property(MoostWf, moost.MOOST_ADAPTER_BRAND, "@moostjs/event-wf/MoostWf");
|
package/dist/index.mjs
CHANGED
|
@@ -101,45 +101,6 @@ function getWfMate() {
|
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
-
//#endregion
|
|
105
|
-
//#region packages/event-wf/src/run-scope.ts
|
|
106
|
-
/** Marks a `WooksWf` whose runs release their moost DI scope (see {@link releaseRunScopes}). */ const RUN_SCOPES_RELEASED = Symbol.for("moost-wf.run-scopes-released");
|
|
107
|
-
/** Marks the cleanup that releases a run's scope, so a resumed run does not wrap it twice. */ const RUN_SCOPE_CLEANUP = Symbol.for("moost-wf.run-scope-cleanup");
|
|
108
|
-
/** Run options whose `cleanup` also releases the run's moost DI scope (when the run ends). */ function withRunScopeCleanup(opts) {
|
|
109
|
-
const own = opts?.cleanup;
|
|
110
|
-
if (own?.[RUN_SCOPE_CLEANUP]) return opts;
|
|
111
|
-
const cleanup = () => {
|
|
112
|
-
try {
|
|
113
|
-
own?.();
|
|
114
|
-
} finally {
|
|
115
|
-
getMoostInfact().unregisterScope(useScopeId());
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
cleanup[RUN_SCOPE_CLEANUP] = true;
|
|
119
|
-
return {
|
|
120
|
-
...opts,
|
|
121
|
-
cleanup
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Makes every run of `wfApp` release its moost DI scope when it ends — whoever starts it:
|
|
126
|
-
* `MoostWf.start()`, `getWfApp().start()`, an outlet trigger or `mintWfToken()`. Step handlers
|
|
127
|
-
* keep the run's scope (`FOR_EVENT` instances) alive across steps, so the run end releases it.
|
|
128
|
-
* Replaces the instance's `start`/`resume`: anything that captured them before (e.g. a
|
|
129
|
-
* `createOutletHandler(wooksWf)` made before `new MoostWf(wooksWf)`) bypasses the release.
|
|
130
|
-
*/ function releaseRunScopes(wfApp) {
|
|
131
|
-
const app = wfApp;
|
|
132
|
-
if (app[RUN_SCOPES_RELEASED]) return;
|
|
133
|
-
app[RUN_SCOPES_RELEASED] = true;
|
|
134
|
-
const { start, resume } = app;
|
|
135
|
-
app.start = function(schemaId, context, opts) {
|
|
136
|
-
return start.call(this, schemaId, context, withRunScopeCleanup(opts));
|
|
137
|
-
};
|
|
138
|
-
app.resume = function(state, opts) {
|
|
139
|
-
return resume.call(this, state, withRunScopeCleanup(opts));
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
104
|
//#endregion
|
|
144
105
|
//#region packages/event-wf/src/event-wf.ts
|
|
145
106
|
function _define_property(obj, key, value) {
|
|
@@ -152,6 +113,14 @@ function _define_property(obj, key, value) {
|
|
|
152
113
|
else obj[key] = value;
|
|
153
114
|
return obj;
|
|
154
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Releases the moost DI scope of a workflow run when the run ends (paused, finished or
|
|
118
|
+
* failed): step handlers keep the run's `FOR_EVENT` instances alive across steps. Runs after
|
|
119
|
+
* the run's own `cleanup`, inside the workflow context. Module-level, so attaching it to a
|
|
120
|
+
* `WooksWf` shared by several `MoostWf` instances registers it once.
|
|
121
|
+
*/ function releaseRunScope() {
|
|
122
|
+
getMoostInfact().unregisterScope(useScopeId());
|
|
123
|
+
}
|
|
155
124
|
const LOGGER_TITLE = "moost-wf";
|
|
156
125
|
/**
|
|
157
126
|
* Moost adapter for workflow events. Wraps `@wooksjs/event-wf` to register
|
|
@@ -332,7 +301,7 @@ const LOGGER_TITLE = "moost-wf";
|
|
|
332
301
|
if (opts && opts instanceof WooksWf) this.wfApp = opts;
|
|
333
302
|
else if (opts) this.wfApp = createWfApp(opts);
|
|
334
303
|
else this.wfApp = createWfApp();
|
|
335
|
-
|
|
304
|
+
this.wfApp.attachCleanup(releaseRunScope);
|
|
336
305
|
}
|
|
337
306
|
};
|
|
338
307
|
/** Names this adapter for DI independently of class identity (see `MOOST_ADAPTER_BRAND`). */ _define_property(MoostWf, MOOST_ADAPTER_BRAND, "@moostjs/event-wf/MoostWf");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moostjs/event-wf",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "@moostjs/event-wf",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"composables",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@prostojs/wf": "^0.3.0",
|
|
42
|
-
"@wooksjs/event-wf": "^0.8.
|
|
42
|
+
"@wooksjs/event-wf": "^0.8.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"vitest": "4.1.12"
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@prostojs/infact": "^0.6.1",
|
|
49
49
|
"@prostojs/mate": "^0.5.1",
|
|
50
|
-
"@wooksjs/event-core": "^0.8.
|
|
51
|
-
"wooks": "^0.8.
|
|
52
|
-
"moost": "^0.7.
|
|
50
|
+
"@wooksjs/event-core": "^0.8.1",
|
|
51
|
+
"wooks": "^0.8.1",
|
|
52
|
+
"moost": "^0.7.3"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"pub": "pnpm publish --access public",
|