All checks were successful
Build + deploy releases / build-and-deploy (push) Successful in 8s
Schema-driven form renderer plus zddc-server endpoints that turn any
<name>.form.yaml into a working data-collection form at <path>/<name>.form.html.
Submissions land in <path>/<name>/<YYYY-MM-DD>-<email-sanitized>.yaml,
ACL-gated by the existing .zddc cascade. The form posts back to its own URL;
the server strips ".html" and routes by what's underneath, so create and
update use the same client-side code path.
Form spec dialect: JSON Schema 2020-12 + RJSF-style ui:* hints, written in
YAML. Chosen for LLM authorability — it's the canonical structured-output
target for OpenAI/Anthropic, and the ui:* convention is the most-trained UI
hint vocabulary. Supported subset for v0: type (string/number/integer/boolean/
array/object), enum, min/max, minLength/maxLength, required, additionalProperties:
false, properties, items, format (date, email). Round-trip mode is form-as-truth:
submission YAML is regenerated each save, comments are not preserved (the v1
file-as-truth mode for hand-edited files like .zddc itself is deferred).
New components:
* form/ — sixth single-file HTML tool, vanilla JS renderer (~760 LoC)
* zddc/internal/jsonschema/ — focused JSON Schema validator covering only
the v0 keyword subset. Match-implementation-cost-to-surface-used: a full
library brings 70%+ surface we don't use; revisit when v1 adds $ref +
oneOf + if/then/else.
* zddc/internal/handler/formhandler.go — RecognizeFormRequest / ServeForm,
capability-URL re-edit, atomic submission writes via the new
zddc.WriteAtomic helper extracted from writer.go.
* dispatch() in zddc-server/main.go now intercepts *.form.html and
*.yaml.html before the static-file path; spec existence is the trigger.
Build pipeline: form joins ZDDC_RELEASE_TOOLS in lockstep, gets its own
embedded copy in handler/form.html (separate from the apps cascade —
the form renderer is fixed, not subject to per-folder version overrides).
Tests: 5 new Playwright specs (form-safety) + 14 new Go tests across the
validator and handler. All 172 Playwright tests + 10 Go packages green.
End-to-end manual verification: GET empty → POST 201 + capability URL →
GET re-edit (pre-filled) → POST update → 200, raw YAML browsable, ACL
deny → 403.
Docs: form/ section added to AGENTS.md and ARCHITECTURE.md. AGENTS.md
also documents the implementation-vs-dependency policy. CLAUDE.md repo-shape
list extended.
Deferred (v1+): .zddc editor migration onto this system, file-as-truth
lossless YAML round-trip, ui:show-when conditional visibility, oneOf/anyOf,
apps-cascade preview hook, cascade-fetched form definitions.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
(function (app) {
|
|
'use strict';
|
|
|
|
const u = app.modules.util;
|
|
|
|
function findByPath(root, path) {
|
|
if (!path || path === '') {
|
|
return root;
|
|
}
|
|
const segs = u.ptrParse(path);
|
|
let cur = root;
|
|
for (let i = 0; i < segs.length; i++) {
|
|
if (!cur || typeof cur.child !== 'function') {
|
|
return null;
|
|
}
|
|
cur = cur.child(segs[i]);
|
|
}
|
|
return cur || null;
|
|
}
|
|
|
|
function apply(errors) {
|
|
if (!errors || !errors.length || !app.rootWidget) {
|
|
return;
|
|
}
|
|
for (let i = 0; i < errors.length; i++) {
|
|
const err = errors[i];
|
|
const widget = findByPath(app.rootWidget, err.path || '');
|
|
if (widget && typeof widget.setError === 'function') {
|
|
widget.setError(err.message || 'Invalid value');
|
|
}
|
|
}
|
|
}
|
|
|
|
function clear() {
|
|
if (app.rootWidget) {
|
|
app.rootWidget.clearErrors();
|
|
}
|
|
}
|
|
|
|
app.modules.errors = { apply: apply, clear: clear };
|
|
})(window.formApp);
|