@pipelex/mthds-form 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pipelex
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # @pipelex/mthds-form
2
+
3
+ The input form for MTHDS methods, as a library: a headless kernel that turns a method's declared input contract into a renderable descriptor and gates what may be run, plus a themeable React control set that renders that descriptor.
4
+
5
+ It exists because "the form" is one problem that keeps being solved separately. A method declares its inputs; something has to decide what widget each input deserves, whether the Run button may light up, what shape the values take on the wire, and what a validation failure says to a person. That logic belongs in one place with tests around it, not copied into each surface that happens to need a form.
6
+
7
+ ## Two entry points
8
+
9
+ ```ts
10
+ import { buildRunFields, computeReadiness } from '@pipelex/mthds-form'; // headless
11
+ import { FieldRenderer } from '@pipelex/mthds-form/react'; // the controls
12
+ ```
13
+
14
+ `.` is the kernel: no React, no design system, no framework. Its only runtime dependency is `ajv`, which the gate validates through. It runs in a browser, in Node, in a worker.
15
+
16
+ `./react` is the control set — one control per field kind behind a single dispatch point, styled with Tailwind classes over standard shadcn/ui tokens. `react` and `react-dom` are optional peer dependencies, so a consumer that only wants the kernel never installs them.
17
+
18
+ ## The shape of a form
19
+
20
+ ```tsx
21
+ import { buildRunFields, computeReadiness, getPipeIOContract } from '@pipelex/mthds-form';
22
+ import { FieldRenderer } from '@pipelex/mthds-form/react';
23
+
24
+ const contract = getPipeIOContract(method.pipe_io_contracts, pipeCode, method.domain);
25
+ const fields = buildRunFields(contract.inputs);
26
+ const { canRun } = computeReadiness(fields, values);
27
+
28
+ return fields.map((field) => (
29
+ <FieldRenderer
30
+ key={field.name}
31
+ field={field}
32
+ id={field.name}
33
+ value={values[field.name]}
34
+ onChange={(next) => setValue(field.name, next)}
35
+ />
36
+ ));
37
+ ```
38
+
39
+ `buildRunFields` is the only function that reads JSON Schema. Everything downstream — rendering, readiness, validation messaging — reads the `RunField` descriptor it returns. That is the load-bearing rule of the package, and [docs/architecture.md](docs/architecture.md) explains what it buys.
40
+
41
+ Submitting goes through the gate: `buildRunInputsSchema` → `prepareRunInputs` → `validateRunInputs` → `apiInputsFromSchemaData`. The verdict is structured (`RunInputError[]`), and `describeValidationError` renders it for a person.
42
+
43
+ ## Theming
44
+
45
+ The controls carry Tailwind classes over the standard shadcn/ui semantic tokens (`--background`, `--input`, `--border`, `--primary`, …). A host that already defines those tokens gets controls that match its product with no configuration. A host with no Tailwind build loads the prebuilt `@pipelex/mthds-form/styles.css`. Both paths, and the exact token list, are in [docs/theming.md](docs/theming.md).
46
+
47
+ ## Documentation
48
+
49
+ | | |
50
+ | --- | --- |
51
+ | [docs/architecture.md](docs/architecture.md) | the descriptor currency, the one-function seam, the module map |
52
+ | [docs/dependency-budget.md](docs/dependency-budget.md) | what each layer may depend on, and how that is enforced |
53
+ | [docs/theming.md](docs/theming.md) | the token contract and host setup |
54
+ | [docs/derivation-swap.md](docs/derivation-swap.md) | how the descriptor moves server-side without touching consumers |
55
+
56
+ ## Development
57
+
58
+ ```bash
59
+ make install
60
+ make check # lint + format + typecheck
61
+ make test
62
+ make build # both entry points, plus the prebuilt stylesheet
63
+ ```
64
+
65
+ MIT licensed.