@atscript/moost-wf 0.1.62 → 0.1.64
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/README.md +1 -0
- package/dist/index.d.mts +69 -1
- package/dist/index.mjs +76 -1
- package/package.json +15 -14
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ Part of the [atscript-ui](https://github.com/moostjs/atscript-ui) monorepo.
|
|
|
17
17
|
- Workflow decorators that wrap Moost handlers and expose them as `@atscript/vue-wf`-compatible endpoints
|
|
18
18
|
- Interceptors that serialize / deserialize workflow state across HTTP requests
|
|
19
19
|
- `@AsWfState` storage abstraction with a default `@atscript/db`-backed implementation
|
|
20
|
+
- Unified `WfFinished` envelope + helpers (`finishWfWithData`, `finishWfWithRedirect`, `finishWfWithChoice`, …) for terminal-screen UX. See [Finish Screens](https://ui.atscript.dev/workflows/finish-screens).
|
|
20
21
|
|
|
21
22
|
## Install
|
|
22
23
|
|
package/dist/index.d.mts
CHANGED
|
@@ -174,4 +174,72 @@ declare function createAsHttpOutlet(): WfOutlet;
|
|
|
174
174
|
*/
|
|
175
175
|
declare function handleAsOutletRequest(config: WfOutletTriggerConfig, deps: WfOutletTriggerDeps): Promise<unknown>;
|
|
176
176
|
//#endregion
|
|
177
|
-
|
|
177
|
+
//#region src/wf-finished.d.ts
|
|
178
|
+
interface WfFinished<TData = unknown> {
|
|
179
|
+
finished: true;
|
|
180
|
+
data?: TData;
|
|
181
|
+
message?: WfMessage;
|
|
182
|
+
end?: WfFinishedEnd;
|
|
183
|
+
aborted?: boolean;
|
|
184
|
+
reason?: string;
|
|
185
|
+
}
|
|
186
|
+
interface WfMessage {
|
|
187
|
+
level: "info" | "success" | "warn" | "error";
|
|
188
|
+
text: string;
|
|
189
|
+
}
|
|
190
|
+
type WfFinishedEnd = {
|
|
191
|
+
mode: "immediate";
|
|
192
|
+
action: WfAction;
|
|
193
|
+
} | {
|
|
194
|
+
mode: "auto";
|
|
195
|
+
timeoutMs: number;
|
|
196
|
+
action: WfAction;
|
|
197
|
+
skipButton?: {
|
|
198
|
+
label: string;
|
|
199
|
+
behavior?: "now" | "cancel";
|
|
200
|
+
};
|
|
201
|
+
} | {
|
|
202
|
+
mode: "manual";
|
|
203
|
+
primary?: WfButton;
|
|
204
|
+
options?: WfButton[];
|
|
205
|
+
};
|
|
206
|
+
interface WfButton {
|
|
207
|
+
label: string;
|
|
208
|
+
action: WfAction;
|
|
209
|
+
}
|
|
210
|
+
type WfAction = {
|
|
211
|
+
type: "redirect";
|
|
212
|
+
target: string;
|
|
213
|
+
reason?: string;
|
|
214
|
+
} | {
|
|
215
|
+
type: "reload";
|
|
216
|
+
} | {
|
|
217
|
+
type: "dismiss";
|
|
218
|
+
};
|
|
219
|
+
/** Type-guard for the unified envelope. */
|
|
220
|
+
declare function isWfFinished(v: unknown): v is WfFinished;
|
|
221
|
+
declare function finishWf<T>(payload: WfFinished<T>): void;
|
|
222
|
+
declare function finishWfWithData<T>(data: T, message?: WfMessage): void;
|
|
223
|
+
declare function finishWfWithMessage(level: WfMessage["level"], text: string): void;
|
|
224
|
+
interface RedirectOpts {
|
|
225
|
+
reason?: string;
|
|
226
|
+
message?: WfMessage;
|
|
227
|
+
/** Present → `mode: 'auto'` with countdown; absent → `mode: 'immediate'`. */
|
|
228
|
+
autoMs?: number;
|
|
229
|
+
/** Only honored when `autoMs` is set — adds a "skip / cancel" button. */
|
|
230
|
+
skipLabel?: string;
|
|
231
|
+
}
|
|
232
|
+
declare function finishWfWithRedirect(target: string, opts?: RedirectOpts): void;
|
|
233
|
+
interface ChoiceOpts {
|
|
234
|
+
data?: unknown;
|
|
235
|
+
message?: WfMessage;
|
|
236
|
+
primary?: WfButton;
|
|
237
|
+
options?: WfButton[];
|
|
238
|
+
}
|
|
239
|
+
declare function finishWfWithChoice(opts: ChoiceOpts): void;
|
|
240
|
+
declare function finishWfAborted(reason: string, opts?: {
|
|
241
|
+
message?: WfMessage;
|
|
242
|
+
end?: WfFinishedEnd;
|
|
243
|
+
}): void;
|
|
244
|
+
//#endregion
|
|
245
|
+
export { AltAction, type ChoiceOpts, FormInput, FormInputRequired, type RedirectOpts, type TFormInput, type WfAction, type WfButton, type WfFinished, type WfFinishedEnd, type WfMessage, createAsHttpOutlet, extractPassContext, finishWf, finishWfAborted, finishWfWithChoice, finishWfWithData, finishWfWithMessage, finishWfWithRedirect, formInputInterceptor, getFormActions, handleAsOutletRequest, isWfFinished, serializeFormSchema, useFormInput, useWfAction };
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { createHttpOutlet, handleWfOutletRequest, useWfState } from "@moostjs/ev
|
|
|
2
2
|
import { Intercept, Resolve, TInterceptorPriority, useControllerContext } from "moost";
|
|
3
3
|
import { isAnnotatedType, serializeAnnotatedType } from "@atscript/typescript/utils";
|
|
4
4
|
import { current, key } from "@wooksjs/event-core";
|
|
5
|
+
import { useWfFinished } from "@wooksjs/event-wf";
|
|
5
6
|
//#region src/form-input/context.ts
|
|
6
7
|
const WF_CONTEXT_PASS = "wf.context.pass";
|
|
7
8
|
const UI_FORM_ACTION = "ui.form.action";
|
|
@@ -407,4 +408,78 @@ async function handleAsOutletRequest(config, deps) {
|
|
|
407
408
|
return wrapFinished(await handleWfOutletRequest(config, deps));
|
|
408
409
|
}
|
|
409
410
|
//#endregion
|
|
410
|
-
|
|
411
|
+
//#region src/wf-finished.ts
|
|
412
|
+
/** Type-guard for the unified envelope. */
|
|
413
|
+
function isWfFinished(v) {
|
|
414
|
+
return !!(v && typeof v === "object" && v.finished);
|
|
415
|
+
}
|
|
416
|
+
function setEnvelope(envelope) {
|
|
417
|
+
useWfFinished().set({
|
|
418
|
+
type: "data",
|
|
419
|
+
value: envelope
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
function finishWf(payload) {
|
|
423
|
+
setEnvelope(payload);
|
|
424
|
+
}
|
|
425
|
+
function finishWfWithData(data, message) {
|
|
426
|
+
finishWf({
|
|
427
|
+
finished: true,
|
|
428
|
+
data,
|
|
429
|
+
message
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
function finishWfWithMessage(level, text) {
|
|
433
|
+
finishWf({
|
|
434
|
+
finished: true,
|
|
435
|
+
message: {
|
|
436
|
+
level,
|
|
437
|
+
text
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
function finishWfWithRedirect(target, opts = {}) {
|
|
442
|
+
const action = {
|
|
443
|
+
type: "redirect",
|
|
444
|
+
target,
|
|
445
|
+
reason: opts.reason
|
|
446
|
+
};
|
|
447
|
+
const end = opts.autoMs ? {
|
|
448
|
+
mode: "auto",
|
|
449
|
+
timeoutMs: opts.autoMs,
|
|
450
|
+
action,
|
|
451
|
+
skipButton: opts.skipLabel ? { label: opts.skipLabel } : void 0
|
|
452
|
+
} : {
|
|
453
|
+
mode: "immediate",
|
|
454
|
+
action
|
|
455
|
+
};
|
|
456
|
+
finishWf({
|
|
457
|
+
finished: true,
|
|
458
|
+
message: opts.message,
|
|
459
|
+
end
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
function finishWfWithChoice(opts) {
|
|
463
|
+
if (!opts.primary && (!opts.options || opts.options.length === 0)) throw new Error("finishWfWithChoice() requires at least a primary button or one option.");
|
|
464
|
+
finishWf({
|
|
465
|
+
finished: true,
|
|
466
|
+
data: opts.data,
|
|
467
|
+
message: opts.message,
|
|
468
|
+
end: {
|
|
469
|
+
mode: "manual",
|
|
470
|
+
primary: opts.primary,
|
|
471
|
+
options: opts.options
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
function finishWfAborted(reason, opts = {}) {
|
|
476
|
+
finishWf({
|
|
477
|
+
finished: true,
|
|
478
|
+
aborted: true,
|
|
479
|
+
reason,
|
|
480
|
+
message: opts.message,
|
|
481
|
+
end: opts.end
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
//#endregion
|
|
485
|
+
export { AltAction, FormInput, FormInputRequired, createAsHttpOutlet, extractPassContext, finishWf, finishWfAborted, finishWfWithChoice, finishWfWithData, finishWfWithMessage, finishWfWithRedirect, formInputInterceptor, getFormActions, handleAsOutletRequest, isWfFinished, serializeFormSchema, useFormInput, useWfAction };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/moost-wf",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.64",
|
|
4
4
|
"description": "Workflow form integration for moost — decorators, interceptors, and serialization driven by atscript type metadata",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -51,23 +51,24 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@atscript/core": "^0.1.
|
|
55
|
-
"@atscript/db": "^0.1.
|
|
56
|
-
"@atscript/db-sqlite": "^0.1.
|
|
57
|
-
"@atscript/typescript": "^0.1.
|
|
58
|
-
"@moostjs/event-wf": "^0.6.
|
|
54
|
+
"@atscript/core": "^0.1.56",
|
|
55
|
+
"@atscript/db": "^0.1.79",
|
|
56
|
+
"@atscript/db-sqlite": "^0.1.79",
|
|
57
|
+
"@atscript/typescript": "^0.1.56",
|
|
58
|
+
"@moostjs/event-wf": "^0.6.10",
|
|
59
59
|
"@prostojs/wf": "^0.1.1",
|
|
60
|
-
"@wooksjs/event-core": "^0.7.
|
|
61
|
-
"
|
|
62
|
-
"
|
|
60
|
+
"@wooksjs/event-core": "^0.7.12",
|
|
61
|
+
"@wooksjs/event-wf": "^0.7.12",
|
|
62
|
+
"moost": "^0.6.10",
|
|
63
|
+
"unplugin-atscript": "^0.1.56",
|
|
63
64
|
"vitest": "npm:@voidzero-dev/vite-plus-test@latest",
|
|
64
|
-
"@atscript/ui": "^0.1.
|
|
65
|
+
"@atscript/ui": "^0.1.64"
|
|
65
66
|
},
|
|
66
67
|
"peerDependencies": {
|
|
67
|
-
"@atscript/core": "^0.1.
|
|
68
|
-
"@atscript/typescript": "^0.1.
|
|
69
|
-
"@moostjs/event-wf": "^0.6.
|
|
70
|
-
"moost": "^0.6.
|
|
68
|
+
"@atscript/core": "^0.1.56",
|
|
69
|
+
"@atscript/typescript": "^0.1.56",
|
|
70
|
+
"@moostjs/event-wf": "^0.6.10",
|
|
71
|
+
"moost": "^0.6.10"
|
|
71
72
|
},
|
|
72
73
|
"scripts": {
|
|
73
74
|
"build": "vp pack",
|