feat: [dasc] Form v2#441
Open
kozmaadrian wants to merge 26 commits into
Open
Conversation
added 21 commits
May 13, 2026 19:20
|
Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
|
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test url: https://da.live/form?nx=form-v2#/kozmaadrian/da-sc/forms/demo-v2
Form Block: v2 Review Guide
This guide covers the scope and motivation behind the change, and walks through the architecture and design decisions of the new implementation.
Part 1: v1 vs v2
The problems in v1
1. Schema spec was weak. v1 accepted almost any JSON Schema and tried its best to render it. No rules, no docs about what's allowed, no warning when a schema used something the editor didn't actually support. There was no spec authors could rely on. Business impact: a schema chosen early in a project can turn out to be unworkable in production. Rewriting it means touching every document built on top, which risks blocking launches and eroding trust whenever a "valid" schema produces a broken form.
2. Not testable. There was no way to test one piece on its own. Checking schema compilation, validation, or a single mutation required building the whole model (full document, full schema, full path) every time. The only real feedback loop was opening the browser. Business impact: bugs can slip through to users instead of being caught earlier. The team risks growing cautious about touching anything important. Bug fixes take longer because reproducing an issue means recreating the session by hand.
3. Not reusable. Nothing ran outside the browser. If another tool (DA import, MCP, an AI agent, a migration script) needed to read or validate the same data, it had to re-implement validation, schema resolution, and serialization from scratch. Copies drift. Business impact: every new integration pays the full cost again. AI, MCP, automation: none of it is practical without rewriting the same logic per channel, and the copies risk producing inconsistent data.
4. Mixed layers. Data handling, UI, and network calls were all tangled together. A new feature can touch any of them, and a change in one place can break something far away. Business impact: simple features risk taking weeks. New engineers have to learn everything at once. "Safe" edits can produce regressions that only surface in production.
Part 2: Overview of v2
Why it is built the way it is
v2 splits the code into three layers, and each layer has one job. Nothing leaks across a boundary.
core/is the most important layer. It runs anywhere JavaScript runs: no DOM, nofetch, no globals. It loads in Node.js, in an MCP server, in a CLI, or in a test runner. Theui/layer knows the DOM but knows nothing about schemas or validation.app/is the thin glue between them. The boundary lives in the imports. There's no build tool enforcing it, so it's worth checking in review.File structure
This isn't just a rename. The three folders make the rule real:
ui/can import fromcore/, butcore/never imports fromui/,app/, or anything browser-related. That's what makes the core headless and testable.Part 3: What this PR really solves
Each of the four v1 pains has a direct answer in v2. This is the short version of what a reviewer is approving.
Schema authors know what works. schema-spec.md lists exactly which JSON Schema features the form supports. The compiler (schema-builder.md) checks every schema and reports anything outside that list as a schema issue, so the author sees it in the editor right away, not after building a form on top of it. No more rewriting a schema because a feature you used silently fails.
Anything can be unit-tested. Schema compilation, model building, mutations, validation, type coercion: each one has its own tests that run without a browser. Bugs get caught before they reach users.
One source of truth, reused everywhere.
createCore()gives the same API to the editor, an MCP server, an AI agent, a migration script, or a CLI. No second copy to keep in sync. The next thing we build on top of forms (AI assist, bulk migration, anything) just callscreateCore(). headless-consumer.md shows how.Three layers, no cross-talk.
core/,app/,ui/are real folders. Imports only go one direction. New engineers learn one layer at a time. A bug stays in the layer where it was made. Schema work won't break the renderer, and the other way around.Bonus: every file in
core/and the load path is documented in docs/compileSchemaresolves refs, flags unsupported features, and produces the definition treebuildModelmerges a definition with a document for rendering and validationcreateCoreoutside the browserPart 4: Same UX
The editor looks and behaves identically to v1. This is a full internal rewrite — no visible change was the goal. Fields, validation feedback, array controls, the sidebar, and the preview panel all work as before.
Part 5: Scores