Documentation
¶
Overview ¶
Package snippets embeds the files of the reference app (examples/notes) that show how the common tasks are done: an owned resource, auth routes, a page on the generated client, a handler test, a browser test, an MCP tool. `lidza mcp` serves them as lidza_snippet and `lidza snippet` prints them, so an agent copies code that compiles and passes its tests instead of guessing. `go generate ./pkg/snippets` refreshes the copies in _files (the underscore keeps the go tool from building them as packages).
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Index = []Snippet{
{"schema", "schema.lidza", "Models, API types with rules, optional fields, and the types the auth routes reply with."},
{"routes", "app/routes.go", "Public routes; a group behind auth.Optional() for a page that serves visitors too; groups behind auth.Require(); a resource mounted on a group."},
{"auth-handlers", "handlers/auth.go", "Register, login, logout, email verification and password reset, and the session route read from the database: password hashing, HttpOnly cookies plus a bearer token (the auth pack renews them), normalized emails, links through mail.Link, 409 on a taken email, 401 on a wrong password."},
{"start", "app/start.go", "The app's start hook (onStart, wired in app/app.go): where job handlers are registered with jobs.FromServices(s).Handle and services are provided."},
{"resource-handlers", "handlers/note.go", "The handlers `lidza gen resource` writes, scoped to the signed-in user: list, get, create, patch, delete with 404 for another user's rows."},
{"queries", "db/queries/note.sql", "sqlc queries for an owned resource: owner checks on every statement, COALESCE with sqlc.narg for a partial update, :execrows for delete."},
{"handler-test", "tests/routes_test.go", "A Go test with lidzatest.Start: cookies carried across calls, a bearer token, mail read from the outbox with WaitFor and srv.Context(), and the expected 401, 409, 422 and 404 replies."},
{"mcp-tool", "app/tools.go", "An app MCP tool (lidza.ToolFunc) that queries the database through the db pack."},
{"mail-template", "mail/verify.txt.tmpl", "A mail template (Go text/template over the Data of mail.Message); the html variant sits next to it. handlers/auth.go sends it through the mail pack."},
{"storage-handler", "handlers/attachment.go", "Upload (a typed route taking router.File, api.uploadAttachment in the client) and raw download through the storage pack: the body stored under a key derived from the row, the same access check as the row, streaming back through the app, the object deleted with the row."},
{"admin-page", "handlers/admin.go", "An app page in the admin pages (admin.Page): its data from sqlc queries across accounts, a delete action returning the message the page shows, mounted in routes.go with its template embedded."},
{"admin-page-template", "app/admin/notes.html", "The admin page's template: it defines \"content\" inside the admin frame, with Tabler's card and table classes, since and icon, an empty state through admin-empty, and a form posting to the page's action with a confirmation."},
{"llm-handler", "handlers/tags.go", "A route that asks the language model for a schema type through the llm pack: llm.Generate over the note the user may read, the prompt in the handler, the reply validated by the type's rules."},
{"pack-capability", "packs/stats/rust/src/lib.rs", "A Rust pack capability (lidza_export!) over types from schema.lidza: one CPU pass over user text, no I/O; the handler noteStats in resource-handlers calls it through the generated wrapper."},
{"pack-manifest", "packs/stats/pack.lidza.json", "The pack manifest: capability names with their input and output types, the pool size, memory cap, timeout, and uninterruptible for input-bounded loops."},
{"ui", "src/ui.tsx", "The app's components (react template): Page, Section, Stack, Row, Notice, Empty, Button, Field, TextInput, TextArea, SearchInput, Select (a combobox over a listbox with the keyboard), Dialog and Drawer on the <dialog> element; every page is built from them, and lidza check L026 flags the browser's own controls once an app has this file: `lidza snippet ui > src/ui.tsx`."},
{"page", "src/pages/Home.tsx", "A React page on @lidza/client only, built from the app's components (src/ui.tsx): useQuery and useMutation with api.*, validators.* before a request, Field and Button for the form, sign in and sign out, Select for a display choice (the list's order) kept with usePreferences."},
{"preferences", "src/preferences.ts", "usePreferences (react template): an account's display choices from the auth pack's preference routes, read once into the query cache, changed optimistically, sent in order, rolled back when refused, flushed before sign-out; for an app created before it existed, `lidza snippet preferences > src/preferences.ts`."},
{"navigation", "src/navigation.tsx", "Browser navigation (react template): BackLink (back through history when the previous entry is the app's, else to the parent it names, as a real <a href>), useTitle (the document title follows the route), and the search-parameter parsers for a route's validateSearch; for an app created before it existed, `lidza snippet navigation > src/navigation.tsx`, set appName, and add scrollRestoration: true to createRouter."},
{"preference-handlers", "handlers/preferences.go", "The auth pack's preference routes in an app with its own sign-in routes: two handlers over auth.From(ctx).Preferences and PatchPreferences, with the pack's types, behind auth.Require()."},
{"browser-test", "e2e/notes.spec.ts", "A Playwright test: register, add a note, reload, sign out, and no console or window errors."},
}
Index lists the snippets in reading order.
Functions ¶
Types ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
_files
|
|
|
handlers
One attachment per note through the storage pack.
|
One attachment per note through the storage pack. |
|
internal
|
|
|
sync
command
Command sync copies the reference app's files listed in the snippet index into pkg/snippets/_files, for embedding.
|
Command sync copies the reference app's files listed in the snippet index into pkg/snippets/_files, for embedding. |
Click to show internal directories.
Click to hide internal directories.