OzMcp.Config.Prompt.DSL (OzMcp v0.9.0)

Copy Markdown View Source

Compile-time macros of a prompt module (use OzMcp.Config.Prompt).

use OzMcp.Config.Prompt imports the root macro prompt/2 only. The nested macros are not imported: they work only inside their prompt block. A nested macro at the root of the module gives a compile error (undefined function argument/2).

The macros generate list/0 of the prompt behaviour. The module must define get/2. A module with the DSL cannot define list/0.

The macros

MacroBlockValueWire field
prompt "name"rootnon-empty string, unique in the modulename
titlepromptnon-empty stringtitle
descriptionpromptnon-empty stringdescription
required_scopespromptlist of scope tokensnone (a 403 and a filtered prompts/list)
argument "name"prompt (repeatable)name: non-empty string, unique in the promptone entry of arguments
argument "name", optsprompt (repeatable)title: and description: are non-empty strings, required: is a booleanarguments[].title, .description, .required
iconprompt (repeatable)blockone entry of icons
srciconhttps: URL, http: URL of a loopback host, or data: URIicons[].src
mime_typeiconnon-empty stringicons[].mimeType
sizesiconlist of "any" and "WxH" stringsicons[].sizes
themeicon"light" or "dark"icons[].theme
meta key, valuepromptkey: string or atom, value: a JSON term_meta.<key>

The framework sends required on the wire only when it is true. An option that is not title, description or required raises at compile time. A wrong value, a macro outside its block, or a property declared two times raises at compile time too. With warn?: true (the default), a prompt with no title or no description gives a compiler warning.

The guide Prompts shows an example of the DSL.

Summary

Functions

argument(name, opts \\ [])

(macro)

description(value)

(macro)

icon(list)

(macro)

meta(key, value)

(macro)

mime_type(value)

(macro)

prompt(entity_name, list)

(macro)

required_scopes(value)

(macro)

sizes(value)

(macro)

src(value)

(macro)

theme(value)

(macro)

title(value)

(macro)