@punica/form-mcp 0.6.0 → 0.6.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.2.
|
|
1
|
+
{"version":"0.2.1"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FormController } from '@punica/form';
|
|
2
|
-
import { type JsonFormItem, type JsonFormValues, type RuleDefinition } from '@punica/form-json';
|
|
2
|
+
import { type JsonFormItem, type Rule, type JsonFormValues, type RuleDefinition } from '@punica/form-json';
|
|
3
3
|
/**
|
|
4
4
|
* A form you draw yourself (your own markup, @punica/components or native
|
|
5
5
|
* controls) whose values, rules and submit are Punica Form's: the engine
|
|
@@ -37,10 +37,29 @@ export interface BindFormOptions {
|
|
|
37
37
|
fields: Record<string, BoundControl>;
|
|
38
38
|
/** Rules of the engine beyond what each control says itself: `{ rule, value?, message? }`. */
|
|
39
39
|
rules?: Record<string, RuleDefinition[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Rules of your own, by the names `rules` uses them with, beside the built-in ones (`required`, `min`,
|
|
42
|
+
* `pattern`, …): `{ vatNumber: (value) => (valid(value) ? undefined : 'Not a VAT number.') }`.
|
|
43
|
+
*/
|
|
44
|
+
customRules?: Record<string, Rule>;
|
|
40
45
|
/** Called with the values when every rule and every control holds. What it throws is said in `alert` (or `failed`). */
|
|
41
46
|
onSubmit: (values: Record<string, unknown>) => unknown;
|
|
42
|
-
/**
|
|
43
|
-
|
|
47
|
+
/**
|
|
48
|
+
* The fields a failed `onSubmit` names, read from what it threw (a server that refused some fields):
|
|
49
|
+
* `{ email: 'Already registered.' }`. They are shown on their fields, the first one takes the focus, and
|
|
50
|
+
* `alert` says only what named no field of the form. Nothing named: `undefined` or `{}`.
|
|
51
|
+
*/
|
|
52
|
+
refusal?: (err: unknown) => Record<string, string | string[]> | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* The words for a control that is wrong and has no message of its own (a control without
|
|
55
|
+
* `validationMessage`): `required` for a missing value, `invalid` for any other.
|
|
56
|
+
*/
|
|
57
|
+
problemMessage?: (problem: 'required' | 'invalid') => string;
|
|
58
|
+
/**
|
|
59
|
+
* Called when a submit failed, instead of saying it in `alert`: with what was thrown and how many fields
|
|
60
|
+
* of the form `refusal` marked.
|
|
61
|
+
*/
|
|
62
|
+
failed?: (err: unknown, named: number) => void;
|
|
44
63
|
/** Where a failure is said. */
|
|
45
64
|
alert?: HTMLElement;
|
|
46
65
|
/** After a submit that went through, put every field back to where the form started. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.
|
|
1
|
+
{"version":"0.6.1"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@punica/form-mcp",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "MCP server for Punica Form: look up the exact API of its packages, read the rules and check code that uses them.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
39
|
-
"@punica/form-json": "^0.2.
|
|
39
|
+
"@punica/form-json": "^0.2.1",
|
|
40
40
|
"zod": "^4.6.7"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@punica/form": "^2.3.0",
|
|
44
44
|
"@punica/form-service": "^2.3.0",
|
|
45
45
|
"@punica/form-react": "^0.2.0",
|
|
46
|
-
"@punica/form-kit": "^0.
|
|
46
|
+
"@punica/form-kit": "^0.6.1",
|
|
47
47
|
"@punica/form-schema": "^0.1.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
package/src/guide.md
CHANGED
|
@@ -118,6 +118,10 @@ const form = bindForm(document.querySelector('form')!, {
|
|
|
118
118
|
call `form.submit()` from each button.
|
|
119
119
|
- `form.set(name, value)` writes into the engine and the control;
|
|
120
120
|
`form.dispose()` before the form is drawn again.
|
|
121
|
+
- `refusal: (err) => ({ field: 'message' })` reads the fields a failed
|
|
122
|
+
`onSubmit` names (a server's refusal) and shows them on those fields;
|
|
123
|
+
`customRules` adds named rules of your own; `problemMessage` gives the
|
|
124
|
+
words for a control without a message of its own.
|
|
121
125
|
|
|
122
126
|
## Lifecycle
|
|
123
127
|
|