@atscript/moost-wf 0.1.59 → 0.1.61
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.d.mts +26 -1
- package/dist/index.mjs +78 -2
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WfOutlet, WfOutletTriggerConfig, WfOutletTriggerDeps } from "@moostjs/event-wf";
|
|
1
2
|
import { TInterceptorDef } from "moost";
|
|
2
3
|
import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
3
4
|
|
|
@@ -149,4 +150,28 @@ declare function useWfAction(): {
|
|
|
149
150
|
setAction: (action: string | undefined) => void;
|
|
150
151
|
};
|
|
151
152
|
//#endregion
|
|
152
|
-
|
|
153
|
+
//#region src/outlet.d.ts
|
|
154
|
+
/**
|
|
155
|
+
* `createHttpOutlet` pre-configured for `<AsWfForm>` consumers.
|
|
156
|
+
*
|
|
157
|
+
* Wraps generic form payloads in `{ inputRequired: { payload, transport: 'http', context } }`
|
|
158
|
+
* so step handlers can `return outletHttp(serializeFormSchema(Form), extractPassContext(Form, ctx))`
|
|
159
|
+
* without shaping the response by hand.
|
|
160
|
+
*
|
|
161
|
+
* Signal pass-through: payloads already carrying a root-level routing key
|
|
162
|
+
* (`finished`/`sent`/`outlet`/`error`) — e.g. `outletHttp({ outlet: 'awaiting-payment' })`
|
|
163
|
+
* for a webhook pause — flow through at the response root (merged with `context`
|
|
164
|
+
* if provided), so the client routes on the signal as expected.
|
|
165
|
+
*/
|
|
166
|
+
declare function createAsHttpOutlet(): WfOutlet;
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/handle.d.ts
|
|
169
|
+
/**
|
|
170
|
+
* Drop-in wrapper around `handleWfOutletRequest` that compensates for
|
|
171
|
+
* `@wooksjs/event-wf`'s unwrap of `useWfFinished().set({ value })` (wooks index.mjs:198).
|
|
172
|
+
* Steps return their domain data via `value` and the wrapper supplies the `finished: true`
|
|
173
|
+
* marker so `<AsWfForm>` fires `@finished` instead of falling into "Unexpected response format".
|
|
174
|
+
*/
|
|
175
|
+
declare function handleAsOutletRequest(config: WfOutletTriggerConfig, deps: WfOutletTriggerDeps): Promise<unknown>;
|
|
176
|
+
//#endregion
|
|
177
|
+
export { AltAction, FormInput, FormInputRequired, type TFormInput, createAsHttpOutlet, extractPassContext, formInputInterceptor, getFormActions, handleAsOutletRequest, serializeFormSchema, useFormInput, useWfAction };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useWfState } from "@moostjs/event-wf";
|
|
1
|
+
import { createHttpOutlet, handleWfOutletRequest, useWfState } from "@moostjs/event-wf";
|
|
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";
|
|
@@ -331,4 +331,80 @@ function formInputInterceptor() {
|
|
|
331
331
|
};
|
|
332
332
|
}
|
|
333
333
|
//#endregion
|
|
334
|
-
|
|
334
|
+
//#region src/outlet.ts
|
|
335
|
+
/**
|
|
336
|
+
* Top-level keys `<AsWfForm>` routes on (`packages/vue-wf/src/use-wf-form.ts:128-167`):
|
|
337
|
+
* `finished` → @finished, `sent`/`outlet` → outlet pause, `error` → error branch.
|
|
338
|
+
* Payloads that already carry one of these must reach the response root intact —
|
|
339
|
+
* wrapping in `inputRequired` would mis-route to the form branch.
|
|
340
|
+
*/
|
|
341
|
+
const SIGNAL_KEYS = [
|
|
342
|
+
"finished",
|
|
343
|
+
"sent",
|
|
344
|
+
"outlet",
|
|
345
|
+
"error"
|
|
346
|
+
];
|
|
347
|
+
/**
|
|
348
|
+
* `createHttpOutlet` pre-configured for `<AsWfForm>` consumers.
|
|
349
|
+
*
|
|
350
|
+
* Wraps generic form payloads in `{ inputRequired: { payload, transport: 'http', context } }`
|
|
351
|
+
* so step handlers can `return outletHttp(serializeFormSchema(Form), extractPassContext(Form, ctx))`
|
|
352
|
+
* without shaping the response by hand.
|
|
353
|
+
*
|
|
354
|
+
* Signal pass-through: payloads already carrying a root-level routing key
|
|
355
|
+
* (`finished`/`sent`/`outlet`/`error`) — e.g. `outletHttp({ outlet: 'awaiting-payment' })`
|
|
356
|
+
* for a webhook pause — flow through at the response root (merged with `context`
|
|
357
|
+
* if provided), so the client routes on the signal as expected.
|
|
358
|
+
*/
|
|
359
|
+
function createAsHttpOutlet() {
|
|
360
|
+
return createHttpOutlet({ transform: (payload, context) => {
|
|
361
|
+
if (payload !== null && typeof payload === "object") {
|
|
362
|
+
for (const key of SIGNAL_KEYS) if (key in payload) return context && typeof context === "object" ? {
|
|
363
|
+
...payload,
|
|
364
|
+
...context
|
|
365
|
+
} : payload;
|
|
366
|
+
}
|
|
367
|
+
return { inputRequired: {
|
|
368
|
+
payload,
|
|
369
|
+
transport: "http",
|
|
370
|
+
context: context ?? {}
|
|
371
|
+
} };
|
|
372
|
+
} });
|
|
373
|
+
}
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region src/handle.ts
|
|
376
|
+
/**
|
|
377
|
+
* Top-level keys `<AsWfForm>` routes on (`packages/vue-wf/src/use-wf-form.ts:128-167`)
|
|
378
|
+
* plus `inputRequired` (form-pause envelope). Anything carrying one of these reaches
|
|
379
|
+
* the client root intact; only "bare" finished payloads need a `finished: true` marker.
|
|
380
|
+
*/
|
|
381
|
+
const MARKER_KEYS = [
|
|
382
|
+
"inputRequired",
|
|
383
|
+
"finished",
|
|
384
|
+
"error",
|
|
385
|
+
"sent",
|
|
386
|
+
"outlet"
|
|
387
|
+
];
|
|
388
|
+
/**
|
|
389
|
+
* Wrap an unmarked plain-object result in `{ finished: true, ...result }` — the marker
|
|
390
|
+
* `<AsWfForm>` reads to fire `@finished`. Pass-through for `null`/`undefined`, arrays,
|
|
391
|
+
* primitives (incl. redirect's empty-string body), and already-marked envelopes.
|
|
392
|
+
*/
|
|
393
|
+
function wrapFinished(result) {
|
|
394
|
+
if (result !== null && typeof result === "object" && !Array.isArray(result) && !MARKER_KEYS.some((k) => k in result)) return {
|
|
395
|
+
finished: true,
|
|
396
|
+
...result
|
|
397
|
+
};
|
|
398
|
+
return result;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Drop-in wrapper around `handleWfOutletRequest` that compensates for
|
|
402
|
+
* `@wooksjs/event-wf`'s unwrap of `useWfFinished().set({ value })` (wooks index.mjs:198).
|
|
403
|
+
* Steps return their domain data via `value` and the wrapper supplies the `finished: true`
|
|
404
|
+
* marker so `<AsWfForm>` fires `@finished` instead of falling into "Unexpected response format".
|
|
405
|
+
*/
|
|
406
|
+
async function handleAsOutletRequest(config, deps) {
|
|
407
|
+
return wrapFinished(await handleWfOutletRequest(config, deps));
|
|
408
|
+
}
|
|
409
|
+
//#endregion
|
|
410
|
+
export { AltAction, FormInput, FormInputRequired, createAsHttpOutlet, extractPassContext, formInputInterceptor, getFormActions, handleAsOutletRequest, 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.61",
|
|
4
4
|
"description": "Workflow form integration for moost — decorators, interceptors, and serialization driven by atscript type metadata",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"moost": "^0.6.9",
|
|
62
62
|
"unplugin-atscript": "^0.1.54",
|
|
63
63
|
"vitest": "npm:@voidzero-dev/vite-plus-test@latest",
|
|
64
|
-
"@atscript/ui": "^0.1.
|
|
64
|
+
"@atscript/ui": "^0.1.61"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"@atscript/core": "^0.1.54",
|