@atscript/moost-wf 0.1.157 → 0.1.159
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.mjs +29 -7
- package/package.json +20 -20
package/dist/index.mjs
CHANGED
|
@@ -83,6 +83,33 @@ function serializeFormSchema(type) {
|
|
|
83
83
|
return schema;
|
|
84
84
|
}
|
|
85
85
|
//#endregion
|
|
86
|
+
//#region ../ui/src/form/error-utils.ts
|
|
87
|
+
/**
|
|
88
|
+
* Framework-agnostic helpers for working with form-error maps keyed by
|
|
89
|
+
* dotted path. Used by AsForm to drive error badges and auto-open
|
|
90
|
+
* collapsed sections; safe to share with React (or any other) bindings.
|
|
91
|
+
*
|
|
92
|
+
* Convention:
|
|
93
|
+
* - Keys are dotted paths (`a.b.c`); empty string and `__form` denote
|
|
94
|
+
* the form-level error.
|
|
95
|
+
* - Values may be `string | undefined`; falsy entries are dropped on
|
|
96
|
+
* merge.
|
|
97
|
+
*/
|
|
98
|
+
/** Error-map key of the form-level error. */
|
|
99
|
+
const FORM_ERROR_KEY = "__form";
|
|
100
|
+
/**
|
|
101
|
+
* Turn a validator's error list into an error map keyed by path. A
|
|
102
|
+
* root-level error (empty path) becomes the form-level error
|
|
103
|
+
* ({@link FORM_ERROR_KEY}). The first error per path wins: a failing
|
|
104
|
+
* container rule is reported before the container's own shape / length
|
|
105
|
+
* checks at the same path.
|
|
106
|
+
*/
|
|
107
|
+
function validatorErrorsToMap(errors) {
|
|
108
|
+
const out = {};
|
|
109
|
+
for (const err of errors) out[err.path || "__form"] ??= err.message;
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
86
113
|
//#region src/wf-io/validator-cache.ts
|
|
87
114
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
88
115
|
/**
|
|
@@ -107,11 +134,6 @@ function getCachedValidator(type, opts) {
|
|
|
107
134
|
}
|
|
108
135
|
//#endregion
|
|
109
136
|
//#region src/wf-io/use-atscript-wf.ts
|
|
110
|
-
function flattenValidatorErrors(err) {
|
|
111
|
-
const out = {};
|
|
112
|
-
for (const e of err.errors) out[e.path] = e.message;
|
|
113
|
-
return out;
|
|
114
|
-
}
|
|
115
137
|
function isValidatorError(err) {
|
|
116
138
|
return err !== null && typeof err === "object" && "errors" in err && Array.isArray(err.errors);
|
|
117
139
|
}
|
|
@@ -120,7 +142,7 @@ function useAtscriptWf(type) {
|
|
|
120
142
|
function requireInput({ errors, formMessage } = {}) {
|
|
121
143
|
const passContext = extractPassContext(type, wfState.ctx() ?? {});
|
|
122
144
|
const mergedErrors = errors ? { ...errors } : formMessage ? {} : void 0;
|
|
123
|
-
if (formMessage && mergedErrors) mergedErrors
|
|
145
|
+
if (formMessage && mergedErrors) mergedErrors[FORM_ERROR_KEY] = formMessage;
|
|
124
146
|
const context = mergedErrors ? {
|
|
125
147
|
...passContext,
|
|
126
148
|
errors: mergedErrors
|
|
@@ -136,7 +158,7 @@ function useAtscriptWf(type) {
|
|
|
136
158
|
try {
|
|
137
159
|
validator.validate(input);
|
|
138
160
|
} catch (err) {
|
|
139
|
-
if (isValidatorError(err)) throw requireInput({ errors:
|
|
161
|
+
if (isValidatorError(err)) throw requireInput({ errors: validatorErrorsToMap(err.errors) });
|
|
140
162
|
throw err;
|
|
141
163
|
}
|
|
142
164
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/moost-wf",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.159",
|
|
4
4
|
"description": "Workflow form integration for moost — decorators, interceptors, and serialization driven by atscript type metadata",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -56,30 +56,30 @@
|
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@atscript/core": "^0.1.
|
|
60
|
-
"@atscript/db": "^0.1.
|
|
61
|
-
"@atscript/db-sql-tools": "^0.1.
|
|
62
|
-
"@atscript/db-sqlite": "^0.1.
|
|
63
|
-
"@atscript/typescript": "^0.1.
|
|
64
|
-
"@moostjs/event-wf": "^0.6.
|
|
59
|
+
"@atscript/core": "^0.1.109",
|
|
60
|
+
"@atscript/db": "^0.1.163",
|
|
61
|
+
"@atscript/db-sql-tools": "^0.1.163",
|
|
62
|
+
"@atscript/db-sqlite": "^0.1.163",
|
|
63
|
+
"@atscript/typescript": "^0.1.109",
|
|
64
|
+
"@moostjs/event-wf": "^0.6.53",
|
|
65
65
|
"@prostojs/wf": "^0.2.1",
|
|
66
66
|
"@uniqu/core": "^0.1.15",
|
|
67
|
-
"@wooksjs/event-core": "^0.7.
|
|
68
|
-
"@wooksjs/event-http": "^0.7.
|
|
69
|
-
"@wooksjs/event-wf": "^0.7.
|
|
70
|
-
"@wooksjs/http-body": "^0.7.
|
|
71
|
-
"moost": "^0.6.
|
|
72
|
-
"unplugin-atscript": "^0.1.
|
|
67
|
+
"@wooksjs/event-core": "^0.7.31",
|
|
68
|
+
"@wooksjs/event-http": "^0.7.31",
|
|
69
|
+
"@wooksjs/event-wf": "^0.7.31",
|
|
70
|
+
"@wooksjs/http-body": "^0.7.31",
|
|
71
|
+
"moost": "^0.6.53",
|
|
72
|
+
"unplugin-atscript": "^0.1.109",
|
|
73
73
|
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14",
|
|
74
|
-
"@atscript/ui": "^0.1.
|
|
74
|
+
"@atscript/ui": "^0.1.159"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@atscript/core": "^0.1.
|
|
78
|
-
"@atscript/typescript": "^0.1.
|
|
79
|
-
"@moostjs/event-wf": "^0.6.
|
|
80
|
-
"@wooksjs/event-core": "^0.7.
|
|
81
|
-
"@wooksjs/event-wf": "^0.7.
|
|
82
|
-
"moost": "^0.6.
|
|
77
|
+
"@atscript/core": "^0.1.109",
|
|
78
|
+
"@atscript/typescript": "^0.1.109",
|
|
79
|
+
"@moostjs/event-wf": "^0.6.53",
|
|
80
|
+
"@wooksjs/event-core": "^0.7.31",
|
|
81
|
+
"@wooksjs/event-wf": "^0.7.31",
|
|
82
|
+
"moost": "^0.6.53"
|
|
83
83
|
},
|
|
84
84
|
"scripts": {
|
|
85
85
|
"build": "vp pack",
|