mirror of
https://github.com/GabrielVidal1/ask-form.git
synced 2026-12-02 02:07:27 +01:00
`ask-form create form.yaml` takes the whole form in one file: title, description, lang and sections (each a page, keyed by its title), with fields keyed by their key, options by their value and a table's columns by their key, in the order written. A section takes an intro (markdown under its title) and a showIf for the whole page. Plain lists of option texts and the old lists (`key:` fields, `value:` options) are read too, and the flat JSON field array still works byte for byte (--fields-file spec.json). - internal/form/yaml.go: a strict YAML 1.2 subset reader, stdlib only. Ordered mappings (*form.Map), block and flow collections, | and > scalars, quotes, comments; refuses anchors, tags, ? keys, several documents, tab indentation and duplicate keys, with the line. Only true/false are booleans; a number keeps its text (json.Number). - internal/form/doc.go: ParseDoc compiles a form file (YAML, or JSON of the same shape) into the flat field array: section title -> group, intro -> a markdown block, section showIf AND-ed into its fields'. The CLI does it before POST /v1/forms, so server, relay, store and MCP are unchanged and a new CLI works with an older serve. - examples: spec.yaml + spec.fr.yaml replace the JSON specs (converted, each checked to normalise to the same fields); /spec.json still answers with the form compiled to JSON. - SKILL.md, the claude.ai sandbox skill, agent-install, README and CLAUDE.md teach the YAML form file; a test keeps SKILL.md's YAML valid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
110 lines
5.8 KiB
YAML
110 lines
5.8 KiB
YAML
title: 'Commentaires : le modèle de données'
|
||
description: Des commentaires sur des posts, avec réponses et réactions. Voici le schéma et l'API tels que je les construirais. Quelques choix vous reviennent ; mes préférences sont pré-sélectionnées, avec le pourquoi.
|
||
summary: |-
|
||
Revue de conception : le schéma sous forme de diagramme, les endpoints dans un tableau, puis les choix ouverts : fils de réponses, identifiants, suppression, pagination.
|
||
order: 6
|
||
sections:
|
||
Le modèle:
|
||
fields:
|
||
schema:
|
||
type: html
|
||
label: Schéma
|
||
html: |-
|
||
<svg viewBox="0 0 420 250" xmlns="http://www.w3.org/2000/svg" style="display:block;width:100%;max-width:560px;height:auto;margin:0 auto;font:12.5px ui-monospace,SFMono-Regular,Menlo,monospace">
|
||
<g fill="hsl(var(--card))" stroke="hsl(var(--border))"><rect x="6" y="20" width="118" height="86" rx="10"/><rect x="6" y="140" width="118" height="70" rx="10"/></g>
|
||
<rect x="150" y="6" width="134" height="238" rx="10" fill="hsl(var(--primary) / .08)" stroke="hsl(var(--primary))"/>
|
||
<rect x="306" y="40" width="108" height="98" rx="10" fill="hsl(var(--primary) / .08)" stroke="hsl(var(--primary))"/>
|
||
<g font-weight="700" fill="hsl(var(--foreground))" font-family="system-ui,sans-serif" font-size="14"><text x="18" y="42">posts</text><text x="18" y="162">users</text><text x="162" y="28">comments</text><text x="318" y="62">reactions</text></g>
|
||
<g fill="hsl(var(--muted-foreground))">
|
||
<text x="18" y="64">id</text><text x="18" y="82">author_id</text><text x="18" y="100">…</text>
|
||
<text x="18" y="184">id</text><text x="18" y="202">name</text>
|
||
<text x="162" y="52">id</text><text x="162" y="72">post_id</text><text x="162" y="92">parent_id</text><text x="162" y="112">author_id</text><text x="162" y="132">body</text><text x="162" y="152">created_at</text><text x="162" y="172">edited_at</text><text x="162" y="192">deleted_at</text><text x="162" y="212">reply_count</text>
|
||
<text x="318" y="84">comment_id</text><text x="318" y="104">user_id</text><text x="318" y="124">emoji</text></g>
|
||
<g fill="none" stroke="hsl(var(--muted-foreground))" stroke-width="1.4"><path d="M124 60H136V68H150"/><path d="M124 180H136V108H150"/><path d="M284 48H296V80H306"/><path d="M284 88C300 88 300 100 284 100"/></g>
|
||
<text x="210" y="236" fill="hsl(var(--muted-foreground))" font-family="system-ui,sans-serif" font-size="11" text-anchor="middle">parent_id → comments.id (une réponse)</text>
|
||
</svg>
|
||
endpoints:
|
||
type: markdown
|
||
label: Endpoints
|
||
text: |-
|
||
| Route | Rôle |
|
||
|---|---|
|
||
| `GET /posts/:id/comments` | liste, du plus récent au plus ancien, paginée |
|
||
| `POST /posts/:id/comments` | ajoute ; `parent_id` pour une réponse |
|
||
| `PATCH /comments/:id` | modifie, auteur uniquement |
|
||
| `DELETE /comments/:id` | supprime, auteur ou propriétaire du post |
|
||
| `PUT /comments/:id/reactions/:emoji` | active ou retire une réaction |
|
||
threading:
|
||
type: radio
|
||
label: Jusqu'à quelle profondeur vont les réponses ?
|
||
required: true
|
||
default: one-level
|
||
help: Un seul niveau se lit bien sur mobile et garde la liste en une seule requête.
|
||
options:
|
||
one-level:
|
||
label: Un niveau
|
||
description: Des réponses sous un commentaire, pas de réponses aux réponses (comme les fils Slack)
|
||
tree:
|
||
label: Un arbre complet
|
||
description: Profondeur illimitée (comme Reddit) ; demande une requête récursive
|
||
flat: {label: Pas de réponses, description: Supprimer parent_id}
|
||
ids:
|
||
type: radio
|
||
label: Type d'identifiant
|
||
required: true
|
||
default: uuid7
|
||
options:
|
||
uuid7: {label: UUID v7, description: 'Triable par date, sans risque dans les URL'}
|
||
serial:
|
||
label: Entiers auto-incrémentés
|
||
description: Ce qu'utilisent les posts aujourd'hui ; révèle le nombre de commentaires
|
||
ulid: Chaînes ULID
|
||
Comportement:
|
||
fields:
|
||
deletion:
|
||
type: radio
|
||
label: Que se passe-t-il quand quelqu'un supprime un commentaire ?
|
||
required: true
|
||
default: soft
|
||
options:
|
||
soft:
|
||
label: Il affiche « supprimé », les réponses restent
|
||
description: 'Soft delete : la ligne garde deleted_at, le corps est effacé'
|
||
cascade: Il disparaît, avec ses réponses
|
||
orphan: Il disparaît, les réponses remontent
|
||
edit_window:
|
||
type: number
|
||
label: Combien de temps un commentaire reste-t-il modifiable ? (en minutes, 0 = toujours)
|
||
min: 0
|
||
step: 5
|
||
default: 15
|
||
reactions:
|
||
type: multiselect
|
||
label: Quelles réactions ?
|
||
default: [👍, ❤️, 😂, 🎉]
|
||
options: [👍, ❤️, 😂, 🎉, 😮, 👀]
|
||
notify:
|
||
type: checkbox
|
||
label: Prévenir l'auteur du post par e-mail des nouveaux commentaires (regroupés, au plus une fois par heure)
|
||
default: true
|
||
API:
|
||
fields:
|
||
pagination:
|
||
type: radio
|
||
label: Pagination de la liste
|
||
required: true
|
||
default: cursor
|
||
options:
|
||
cursor:
|
||
label: Curseur
|
||
description: '`?after=<id>` : stable pendant que de nouveaux commentaires arrivent'
|
||
offset:
|
||
label: Numéros de page
|
||
description: '`?page=3` : peut répéter ou sauter un commentaire'
|
||
json_case:
|
||
type: radio
|
||
label: Noms des champs dans le JSON
|
||
default: camel
|
||
help: Le reste de votre API utilise camelCase.
|
||
options: {camel: camelCase (createdAt), snake: snake_case (created_at)}
|