@orkestrel/form 0.0.1

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 Orkestrel
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,80 @@
1
+ # @orkestrel/form
2
+
3
+ The environment-agnostic form document for the `@orkestrel` line — a schema of twelve field
4
+ controls, the answers given against it, declarative validation carried as data, and a submit that
5
+ settles exactly once. A terminal prompt and a browser form ask the same thing in different places,
6
+ so this package ships what they share and neither renders nor reads input itself. Its `answer`
7
+ promise is the parking seam a server needs: hand the document out, wait, receive the answers back.
8
+ A live form can take a field out and put it back with `disable` and `enable`, and nine exported
9
+ budgets bound what one schema and its answers may retain, so a document that arrives from a wire
10
+ costs a known maximum before anything decides to trust it.
11
+ Built on `@orkestrel/contract` and `@orkestrel/emitter`.
12
+
13
+ ## Install
14
+
15
+ ```sh
16
+ npm install @orkestrel/form
17
+ ```
18
+
19
+ ## Requirements
20
+
21
+ - Node.js >= 22.12
22
+ - Host-independent: no `node:*`, no DOM. Ships dual ESM+CJS builds.
23
+
24
+ ## Usage
25
+
26
+ Declare what is asked, answer it, and settle it once:
27
+
28
+ ```ts
29
+ import { createForm } from '@orkestrel/form'
30
+
31
+ const form = createForm({
32
+ label: 'Sign up',
33
+ fields: [
34
+ { control: 'text', name: 'email', label: 'Email', rule: { required: true, email: true } },
35
+ {
36
+ control: 'password',
37
+ name: 'secret',
38
+ label: 'Password',
39
+ rule: { required: true, minimum: 12 },
40
+ },
41
+ { control: 'confirm', name: 'terms', label: 'I accept the terms', rule: { required: true } },
42
+ ],
43
+ })
44
+
45
+ // A task somewhere else parks on the answer.
46
+ const parked = form.answer
47
+
48
+ form.fill({ email: 'ada@example.com', secret: 'correct horse battery' })
49
+ form.errors // [{ field: 'terms', message: 'This field is required', rule: 'required' }]
50
+
51
+ form.fill('terms', true)
52
+ const result = form.submit()
53
+ result.success // true
54
+
55
+ await parked // { email: 'ada@example.com', secret: 'correct horse battery', terms: true }
56
+ ```
57
+
58
+ ## Guide
59
+
60
+ See [guides/form.md](./guides/form.md) for the documented surface — the twelve controls and their
61
+ value shapes, the rule table and the custom cross-field seam, the presence model behind `required`,
62
+ the lifecycle and its seven events, taking a field out of a live form with `disable` and `enable`,
63
+ the budgets that bound what a schema and its answers may retain, the serialize/parse wire boundary,
64
+ and the concept inventory of what this package leaves to the layer above.
65
+
66
+ ## Package
67
+
68
+ Published as one entry point per the `exports` field in `package.json`: `.`, the host-independent
69
+ core. It ships dual ESM+CJS builds with declarations for both.
70
+
71
+ ## Development
72
+
73
+ ```sh
74
+ npm install
75
+ npm test
76
+ ```
77
+
78
+ ## License
79
+
80
+ MIT © [Orkestrel](https://github.com/orkestrel) — see [LICENSE](./LICENSE).