@atscript/vue-wf 0.1.162 → 0.1.164
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/{as-wf-form-IIT8rtRM.mjs → as-wf-form-CGWH0Hsb.mjs} +19 -2
- package/dist/as-wf-form.d.mts +1 -1
- package/dist/as-wf-form.mjs +1 -1
- package/dist/{as-wf-form.vue-But1dqz0.d.mts → as-wf-form.vue-DzuRHbNd.d.mts} +24 -14
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +9 -9
|
@@ -27,6 +27,20 @@ function friendlyMessageForStatus(status) {
|
|
|
27
27
|
if (status >= 400) return "Something went wrong with that request. Please try again.";
|
|
28
28
|
return "Unexpected response from the server.";
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* A `{ error }` answer as a `WfFormError`: a string is the message; an
|
|
32
|
+
* object keeps its `message` / `status` / `code` and is the `body`.
|
|
33
|
+
*/
|
|
34
|
+
function bodyError(raw) {
|
|
35
|
+
if (typeof raw === "string") return { message: raw };
|
|
36
|
+
const body = typeof raw === "object" && raw !== null ? raw : void 0;
|
|
37
|
+
const status = typeof body?.status === "number" ? body.status : void 0;
|
|
38
|
+
const failed = { message: typeof body?.message === "string" ? body.message : status !== void 0 ? friendlyMessageForStatus(status) : "Something went wrong with that request. Please try again." };
|
|
39
|
+
if (status !== void 0) failed.status = status;
|
|
40
|
+
if (typeof body?.code === "string") failed.code = body.code;
|
|
41
|
+
if (body) failed.body = body;
|
|
42
|
+
return failed;
|
|
43
|
+
}
|
|
30
44
|
function useWfForm(options) {
|
|
31
45
|
const tokenName = options.tokenName ?? "wfs";
|
|
32
46
|
const wfidName = options.wfidName ?? "wfid";
|
|
@@ -89,7 +103,7 @@ function useWfForm(options) {
|
|
|
89
103
|
return;
|
|
90
104
|
}
|
|
91
105
|
if (data.error) {
|
|
92
|
-
error.value = data.error;
|
|
106
|
+
error.value = bodyError(data.error);
|
|
93
107
|
return;
|
|
94
108
|
}
|
|
95
109
|
const ir = data.inputRequired;
|
|
@@ -128,10 +142,13 @@ function useWfForm(options) {
|
|
|
128
142
|
if (data && typeof data === "object" && !Array.isArray(data)) extractToken(data);
|
|
129
143
|
if (!res.ok) {
|
|
130
144
|
const errData = data;
|
|
131
|
-
|
|
145
|
+
const failed = {
|
|
132
146
|
message: errData?.message ?? errData?.error ?? friendlyMessageForStatus(res.status),
|
|
133
147
|
status: res.status
|
|
134
148
|
};
|
|
149
|
+
if (typeof errData?.code === "string") failed.code = errData.code;
|
|
150
|
+
if (data !== null) failed.body = data;
|
|
151
|
+
error.value = failed;
|
|
135
152
|
return;
|
|
136
153
|
}
|
|
137
154
|
if (!data) {
|
package/dist/as-wf-form.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as _default } from "./as-wf-form.vue-
|
|
1
|
+
import { t as _default } from "./as-wf-form.vue-DzuRHbNd.mjs";
|
|
2
2
|
export { _default as default };
|
package/dist/as-wf-form.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as as_wf_form_default } from "./as-wf-form-
|
|
1
|
+
import { t as as_wf_form_default } from "./as-wf-form-CGWH0Hsb.mjs";
|
|
2
2
|
export { as_wf_form_default as default };
|
|
@@ -11,7 +11,12 @@ interface UseWfFormOptions {
|
|
|
11
11
|
path: string;
|
|
12
12
|
/** Workflow ID to start (e.g., 'auth/login') */
|
|
13
13
|
name: string;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Initial form data for the start request. Sent as the first request's
|
|
16
|
+
* `input.formData` (the workflow protocol envelope), so the start step
|
|
17
|
+
* reads it with `useWfState().input().formData` — or validated, with
|
|
18
|
+
* unknown keys stripped, via `useAtscriptWf(Form).resolveInput()`.
|
|
19
|
+
*/
|
|
15
20
|
input?: Record<string, unknown>;
|
|
16
21
|
/**
|
|
17
22
|
* How to transport the workflow state token.
|
|
@@ -43,6 +48,17 @@ interface UseWfFormOptions {
|
|
|
43
48
|
*/
|
|
44
49
|
initialToken?: string;
|
|
45
50
|
}
|
|
51
|
+
/** A failed round-trip, as `error` holds it (and `AsWfForm` emits it). */
|
|
52
|
+
interface WfFormError {
|
|
53
|
+
/** Text to show: the answer's `message` (or `error`), else a friendly text for the status. */
|
|
54
|
+
message: string;
|
|
55
|
+
/** HTTP status of a refused request (absent for a network error). */
|
|
56
|
+
status?: number;
|
|
57
|
+
/** The answer's machine-readable `code`, when it has one (e.g. a step's own refusal code). */
|
|
58
|
+
code?: string;
|
|
59
|
+
/** The parsed JSON body of a refused request (`code`, `params`, …), when it has one. */
|
|
60
|
+
body?: unknown;
|
|
61
|
+
}
|
|
46
62
|
interface UseWfFormReturn {
|
|
47
63
|
formDef: ShallowRef<FormDef | null>;
|
|
48
64
|
formData: ShallowRef<Record<string, unknown> | null>;
|
|
@@ -327,26 +343,20 @@ declare const __VLS_base: vue.DefineComponent<AsWfFormProps, {
|
|
|
327
343
|
action: typeof onAction;
|
|
328
344
|
supportsAction: typeof supportsAction;
|
|
329
345
|
}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {} & {
|
|
330
|
-
dismiss: () => any;
|
|
331
|
-
action: (action: WfActionRequest) => any;
|
|
332
|
-
error: (error: {
|
|
333
|
-
message: string;
|
|
334
|
-
status?: number;
|
|
335
|
-
}) => any;
|
|
336
346
|
finished: (response: unknown) => any;
|
|
347
|
+
error: (error: WfFormError) => any;
|
|
337
348
|
submit: (data: unknown) => any;
|
|
338
349
|
loading: (isLoading: boolean) => any;
|
|
350
|
+
dismiss: () => any;
|
|
351
|
+
action: (action: WfActionRequest) => any;
|
|
339
352
|
form: (def: FormDef, context?: Record<string, unknown> | undefined) => any;
|
|
340
353
|
}, string, vue.PublicProps, Readonly<AsWfFormProps> & Readonly<{
|
|
341
|
-
onDismiss?: (() => any) | undefined;
|
|
342
|
-
onAction?: ((action: WfActionRequest) => any) | undefined;
|
|
343
|
-
onError?: ((error: {
|
|
344
|
-
message: string;
|
|
345
|
-
status?: number;
|
|
346
|
-
}) => any) | undefined;
|
|
347
354
|
onFinished?: ((response: unknown) => any) | undefined;
|
|
355
|
+
onError?: ((error: WfFormError) => any) | undefined;
|
|
348
356
|
onSubmit?: ((data: unknown) => any) | undefined;
|
|
349
357
|
onLoading?: ((isLoading: boolean) => any) | undefined;
|
|
358
|
+
onDismiss?: (() => any) | undefined;
|
|
359
|
+
onAction?: ((action: WfActionRequest) => any) | undefined;
|
|
350
360
|
onForm?: ((def: FormDef, context?: Record<string, unknown> | undefined) => any) | undefined;
|
|
351
361
|
}>, {
|
|
352
362
|
tokenTransport: "body" | "cookie" | "query";
|
|
@@ -362,4 +372,4 @@ type __VLS_WithSlots<T, S> = T & {
|
|
|
362
372
|
};
|
|
363
373
|
};
|
|
364
374
|
//#endregion
|
|
365
|
-
export { useWfForm as i, UseWfFormOptions as n, UseWfFormReturn as r, _default as t };
|
|
375
|
+
export { useWfForm as a, WfFormError as i, UseWfFormOptions as n, UseWfFormReturn as r, _default as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as WfNext, i as WfMessage, n as WfButton, r as WfFinished, t as WfActionRequest } from "./index-C5MmoWFB.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { a as useWfForm, i as WfFormError, n as UseWfFormOptions, r as UseWfFormReturn, t as _default$1 } from "./as-wf-form.vue-DzuRHbNd.mjs";
|
|
3
3
|
import { t as _default } from "./as-wf-finish.vue-BhXMooP3.mjs";
|
|
4
|
-
export { _default as AsWfFinish, _default$1 as AsWfForm, type UseWfFormOptions, type UseWfFormReturn, type WfActionRequest, type WfButton, type WfFinished, type WfMessage, type WfNext, useWfForm };
|
|
4
|
+
export { _default as AsWfFinish, _default$1 as AsWfForm, type UseWfFormOptions, type UseWfFormReturn, type WfActionRequest, type WfButton, type WfFinished, type WfFormError, type WfMessage, type WfNext, useWfForm };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as useWfForm, t as as_wf_form_default } from "./as-wf-form-
|
|
1
|
+
import { n as useWfForm, t as as_wf_form_default } from "./as-wf-form-CGWH0Hsb.mjs";
|
|
2
2
|
import { t as as_wf_finish_default } from "./as-wf-finish-CfbsKJhX.mjs";
|
|
3
3
|
export { as_wf_finish_default as AsWfFinish, as_wf_form_default as AsWfForm, useWfForm };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/vue-wf",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.164",
|
|
4
4
|
"description": "Workflow form integration for Vue 3 — HTTP round-trip loop driven by atscript type metadata",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -51,25 +51,25 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@atscript/ui": "^0.1.
|
|
54
|
+
"@atscript/ui": "^0.1.164"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@atscript/core": "^0.2.
|
|
58
|
-
"@atscript/typescript": "^0.2.
|
|
57
|
+
"@atscript/core": "^0.2.4",
|
|
58
|
+
"@atscript/typescript": "^0.2.4",
|
|
59
59
|
"@vitejs/plugin-vue": "^6",
|
|
60
60
|
"@vue/test-utils": "^2",
|
|
61
61
|
"happy-dom": "^18",
|
|
62
|
-
"unplugin-atscript": "^0.2.
|
|
62
|
+
"unplugin-atscript": "^0.2.4",
|
|
63
63
|
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14",
|
|
64
64
|
"vue": "^3",
|
|
65
65
|
"vue-tsc": "~3.2.9",
|
|
66
|
-
"@atscript/moost-wf": "^0.1.
|
|
67
|
-
"@atscript/vue-form": "^0.1.
|
|
66
|
+
"@atscript/moost-wf": "^0.1.164",
|
|
67
|
+
"@atscript/vue-form": "^0.1.164"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"@atscript/typescript": "^0.2.
|
|
70
|
+
"@atscript/typescript": "^0.2.4",
|
|
71
71
|
"vue": "^3",
|
|
72
|
-
"@atscript/vue-form": "^0.1.
|
|
72
|
+
"@atscript/vue-form": "^0.1.164"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
75
|
"build": "node ../../scripts/gen-exports.mjs && vp pack",
|