@plitzi/sdk-mcp 0.38.24 → 0.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +170 -1
- package/dist/createServer.js +1 -0
- package/dist/modules/mcp/catalogs/index.d.ts +1 -1
- package/dist/modules/mcp/catalogs/index.js +2 -2
- package/dist/modules/mcp/catalogs/pluginCatalog.js +5 -1
- package/dist/modules/mcp/handler.d.ts +3 -1
- package/dist/modules/mcp/handler.js +32 -2
- package/dist/modules/mcp/helpers/guide/index.d.ts +3 -0
- package/dist/modules/mcp/helpers/guide/index.js +19 -0
- package/dist/modules/mcp/helpers/{guide.d.ts → guide/instructions.d.ts} +0 -1
- package/dist/modules/mcp/helpers/guide/instructions.js +106 -0
- package/dist/modules/mcp/helpers/guide/logic.d.ts +2 -0
- package/dist/modules/mcp/helpers/guide/logic.js +166 -0
- package/dist/modules/mcp/helpers/guide/practice.d.ts +2 -0
- package/dist/modules/mcp/helpers/guide/practice.js +123 -0
- package/dist/modules/mcp/helpers/guide/reference.d.ts +2 -0
- package/dist/modules/mcp/helpers/guide/reference.js +250 -0
- package/dist/modules/mcp/helpers/guide/server.d.ts +2 -0
- package/dist/modules/mcp/helpers/guide/server.js +252 -0
- package/dist/modules/mcp/helpers/guide/structure.d.ts +2 -0
- package/dist/modules/mcp/helpers/guide/structure.js +189 -0
- package/dist/modules/mcp/helpers/guide/styling.d.ts +2 -0
- package/dist/modules/mcp/helpers/guide/styling.js +118 -0
- package/dist/modules/mcp/helpers/guide/values.d.ts +2 -0
- package/dist/modules/mcp/helpers/guide/values.js +6 -0
- package/dist/modules/mcp/helpers/space.d.ts +5 -2
- package/dist/modules/mcp/helpers/space.js +5 -4
- package/dist/modules/mcp/resources/core.js +1 -1
- package/dist/modules/mcp/resources/index.d.ts +1 -1
- package/dist/modules/mcp/resources/primer.d.ts +0 -11
- package/dist/modules/mcp/resources/primer.js +46 -1
- package/dist/modules/mcp/resources/register.js +1 -1
- package/dist/modules/mcp/server.js +17 -8
- package/dist/modules/mcp/tools/apply/index.d.ts +20 -0
- package/dist/modules/mcp/tools/index.js +2 -0
- package/dist/modules/mcp/tools/operations/actions/document.d.ts +3 -0
- package/dist/modules/mcp/tools/operations/actions/document.js +5 -2
- package/dist/modules/mcp/tools/operations/actions/index.d.ts +6 -0
- package/dist/modules/mcp/tools/operations/actions/patchAction.d.ts +3 -0
- package/dist/modules/mcp/tools/operations/actions/upsertAction.d.ts +3 -0
- package/dist/modules/mcp/tools/operations/index.d.ts +68 -0
- package/dist/modules/mcp/tools/operations/schema/operations.d.ts +14 -0
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +14 -0
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +26 -1
- package/dist/modules/mcp/tools/render.d.ts +14 -0
- package/dist/modules/mcp/tools/renderWidget.d.ts +14 -0
- package/dist/modules/mcp/tools/shared/lintDraft.js +5 -0
- package/dist/modules/mcp/tools/shared/tool.d.ts +6 -0
- package/dist/modules/mcp/tools/shared/validator/connectors.js +0 -1
- package/dist/modules/mcp/tools/shared/validator/css.js +6 -1
- package/dist/modules/mcp/tools/shared/validator/index.js +12 -1
- package/dist/modules/mcp/tools/test.d.ts +23 -0
- package/dist/modules/mcp/tools/test.js +85 -0
- package/dist/modules/mcp/types/aiSchema.d.ts +4 -0
- package/dist/modules/mcp/types/previewTypes.d.ts +3 -2
- package/dist/modules/mcp/types/toolTypes.d.ts +5 -0
- package/dist/preview/createPreview.js +4 -2
- package/package.json +8 -8
- package/dist/modules/mcp/helpers/guide.js +0 -1139
|
@@ -1,1139 +0,0 @@
|
|
|
1
|
-
import { BUILTIN_TRANSFORMERS, GLOBAL_SOURCES, MOTION_ENTERS, MOTION_LOOPS } from "@plitzi/sdk-authoring";
|
|
2
|
-
//#region src/modules/mcp/helpers/guide.ts
|
|
3
|
-
var GLOBALS = GLOBAL_SOURCES.map((source) => `\`${source}\``).join(", ");
|
|
4
|
-
var OTHER_TRANSFORMERS = Object.keys(BUILTIN_TRANSFORMERS).filter((action) => action !== "twigTemplate").map((action) => `\`${action}\``).join(", ");
|
|
5
|
-
var serverInstructions = "Plitzi AI server: read-then-write editing of a Plitzi space. Reads follow a filesystem model — list cheap, read one item in detail on demand; never fetch a whole tree you do not need. Workflow: (1) read plitzi://primer/{env} once — it bundles a quickstart of the guide, types, css-properties and page/definition/variable summaries in a single call; (2) plitzi_search with include:\"detail\" to jump to elements — each hit then carries its uri, stateVersion AND full style/resolvedStyle, so an edit needs no per-element read; open a page skeleton or element only when you need its tree/detail (the skeleton already lists the style classes of each node, and plitzi_read fetches many uris at once); (3) plitzi_apply with dryRun to preview a batch; (4) plitzi_apply to persist, passing expectedResourceVersions to guard against concurrent edits — apply and search both hand back the versions you need for the next edit. Use patchElement / patchDefinition to change only some props / CSS (the upsert variants replace them all). An element read (and search include:\"detail\") inlines the CSS of the definitions it attaches under resolvedStyle, so you rarely need a separate definition read. Every element has ONE name and it IS its id ([A-Za-z0-9_-] starting with a letter, unique, chosen by you) — the same name is the runtime wiring key, so a provider source is `<type>_<name>.<field>`, visible to the provider’s DESCENDANTS only (bind inside its subtree). CSS is plain kebab-case — write shorthands freely (`border: 1px solid red`, `padding: 8px 16px`, `font: bold 16px/1.5 Arial`), they are expanded to longhands for you and STORED that way, so read-back shows the longhands; style vars are var(--name), schema vars are {{name}}. READERS — do not confuse them: MCP *resources* are the browsable catalog (list them, or open one by URI); plitzi_search FINDS elements by label/type/attribute and hands you the name to write ops against; plitzi_read BATCH-fetches URIs you already hold. Reach for search/read to work; browse resources to discover. CMS / API integrations (Strapi, WordPress, Contentful, any REST service) go through a CONNECTOR: a manifest you author declaring the base URL, endpoints and auth template, which the SERVER executes — read plitzi://connector-presets for working ones and plitzi://connectors/{env} for this space’s. You never see or create the credential; the space owner attaches it, and the connector saves without one. An apiContainer reads through it only with runtime:\"server\". Elements also carry applied style variants + visibility (initialState), data bindings and interaction flows: edit them with patchElement (initialState), upsertBinding/patchBinding/deleteBinding, and upsertInteractionFlow/patchInteractionNode/deleteInteraction. An element read shows all three plus availableVariants (which variant each of its classes offers). Build pages people can use without sight: screen readers and browser agents (Claude in Chrome) work a page through its accessibility tree, so every control needs words and clicks go on buttons and links — see Accessibility in plitzi://guide, and plitzi_look (its accessibility outline, the default view) to check. On a space people edit too, plitzi_activity says — and waits for — what they changed since you last looked. Separately, to SHOW the user a small self-contained widget (offline, no space or backend) instead of editing the space — a card, hero, pricing table, a visual answer — use plitzi_render; read plitzi://render/guide for it.";
|
|
6
|
-
var widgetsOnlyInstructions = "Plitzi widget server (widgets-only connection). This connection carries NO Plitzi space: nothing can be read or edited in one, and the space tools are not offered here — do not look for them. What it does do is build self-contained UI widgets fully offline, with no backend, account or setup: call plitzi_render to SHOW the user a real rendered layout (card, hero, pricing table, checklist, form, gallery) instead of describing one. Read plitzi://render/guide first — the element/prop table, the style model and a worked example; plitzi://render/types lists every element type you can author (plitzi_read fetches both). To change a widget you already rendered, call plitzi_render again with patch:true and its renderId. If the user wants to edit their real Plitzi space from here, that is a reconnection they make: the integration must be re-authorized and granted a space (the consent screen lists theirs) — you cannot do it from this connection, and no retry will change it.";
|
|
7
|
-
var guideQuickstart = `# Plitzi AI MCP — quickstart
|
|
8
|
-
This is the condensed guide; read \`plitzi://guide\` for the full reference (every resource, op and example).
|
|
9
|
-
|
|
10
|
-
A space is **two schemas you edit together in one atomic \`plitzi_apply\` batch**: the **element schema** (tree of
|
|
11
|
-
pages/elements) and the **style schema** (definitions = CSS classes, tokens, theme). To style an element: write a
|
|
12
|
-
**definition** and attach it via the element's \`style.base\` in the same batch.
|
|
13
|
-
|
|
14
|
-
**Big spaces:** a primer section may arrive as \`{elided:true, bytes, entries, read}\` instead of its contents —
|
|
15
|
-
the space outgrew what one cold-start read can carry. \`read\` is the resource that serves that exact section whole
|
|
16
|
-
(\`plitzi://definitions/{env}\`, \`plitzi://interactions/{env}\`, …). Read the ones your task needs; nothing is
|
|
17
|
-
missing, it is one round-trip away.
|
|
18
|
-
|
|
19
|
-
**Workflow:** (1) you already have this primer (guide + types + css + page/style summaries). (2) \`plitzi_search\`
|
|
20
|
-
with \`include:"detail"\` to find elements — each hit carries its \`uri\`, \`stateVersion\` and full style, so no
|
|
21
|
-
per-element read. (3) \`plitzi_apply\` with \`dryRun:true\` to preview. (4) \`plitzi_apply\` to persist, passing
|
|
22
|
-
\`expectedResourceVersions\` (uri → the stateVersion you read) for every resource you change — omitting it lets a
|
|
23
|
-
concurrent edit be lost. Use \`patchElement\`/\`patchDefinition\` to change only some props/CSS (upsert replaces all).
|
|
24
|
-
|
|
25
|
-
**Names & wiring:** an element has ONE name and it is its id (letters, numbers, hyphens and underscores,
|
|
26
|
-
**starting with a letter — no dots**). It is also the runtime wiring key: a provider's source is
|
|
27
|
-
\`<type>_<name>\`, and interactions target by it. A dot would split that path; an **underscore is fine** — the first
|
|
28
|
-
\`_\` separates the type from the name (element types have none), so \`list_food_item\` reads unambiguously as type
|
|
29
|
-
\`list\`, name \`food_item\`.
|
|
30
|
-
|
|
31
|
-
**Styling:** CSS keys are **kebab-case** (\`background-color\`); \`var(--token)\` for style vars, \`{{name}}\` for schema
|
|
32
|
-
vars. **Write plain CSS** — shorthands (\`border\`, \`padding\`, \`margin\`, \`gap\`, \`overflow\`, \`flex\`, \`background\`,
|
|
33
|
-
\`font\`, \`transition\`, \`animation\`, \`grid\`, \`grid-row\`/\`grid-column\`, \`place-*\`, \`outline\`, \`columns\`,
|
|
34
|
-
\`list-style\`, \`text-decoration\`) are expanded to their longhands for you, so \`border: 1px solid red\` is stored as
|
|
35
|
-
\`border-top-color\`/\`border-top-width\`/\`border-top-style\`/… That is also how you read them back. Flex layout is
|
|
36
|
-
still \`display: flex\` + \`flex-direction\`/\`align-items\`/…, not a \`flex\` value. Mind a type's \`defaultStyle\`
|
|
37
|
-
(\`text\` is \`display: inline\`). Global styles (\`button {…}\`) and id styles (\`#id\`) have their own ops.
|
|
38
|
-
|
|
39
|
-
**Motion:** animate only \`opacity\` and \`transform\` — they stay smooth while the page loads; an animated blur,
|
|
40
|
-
shadow, size, \`top\`/\`left\` or \`background-position\` stutters on every visitor's machine. Good practices in
|
|
41
|
-
\`plitzi://guide\` (Motion).
|
|
42
|
-
|
|
43
|
-
**Data bindings** (\`upsertBinding\`, category attributes|style|initialState): connect a \`source\` to a \`to\` field.
|
|
44
|
-
A source \`<type>_<name>\` is scoped to the provider's **DESCENDANTS only** — bind inside the provider's subtree
|
|
45
|
-
(the global sources ${GLOBALS} are bindable anywhere). \`apiContainer.mockData\` is builder-only; set a
|
|
46
|
-
real \`query\` for production. \`transformers: [{action, params}]\` post-process the value — use exact action names
|
|
47
|
-
from \`plitzi://data-sources\`; \`twigTemplate\` formats it (the value is \`{{source}}\`, not \`{{value}}\`). \`when\` is
|
|
48
|
-
a QueryBuilder RuleGroup gating the binding.
|
|
49
|
-
|
|
50
|
-
**Fewer elements, same page:** a \`link\` or \`button\` says its words itself — \`content\`, with an icon beside them
|
|
51
|
-
as \`icon\` (\`iconPlacement\` before/after, its class on the \`icon\` slot) — never a \`text\` or \`fontAwesome\` child;
|
|
52
|
-
a text child also ignores the box's colour and hover. Chrome on several pages is a **layout**; the nav item of the page being shown is marked by the
|
|
53
|
-
\`current\` state of its class, not by a copy of the header per page. Sibling rows of data are one \`repeatElement\`; a
|
|
54
|
-
block repeated with other words is a **component** (\`upsertComponent { fromRef }\`). \`plitzi_apply\` (with or
|
|
55
|
-
without \`dryRun\`) answers with **\`suggestions\`** for what the batch could have written shorter, each with the elements
|
|
56
|
-
it saves — never blocking; take them unless the copies are about to diverge.
|
|
57
|
-
|
|
58
|
-
**Interactions** (\`upsertInteractionFlow\`): a \`trigger\` node first, then callbacks/utilities **in order** (links
|
|
59
|
-
computed for you). Node types: \`callback\` (an element's own callback — \`elementId\` is that element), \`globalCallback\`
|
|
60
|
-
(a source module — omit \`elementId\`, the MCP sets it), \`utility\` (no element). Element \`setState\`
|
|
61
|
-
(category/key/value/revertOnFinish) ≠ global \`setState\` (source \`state\`, key/type/value). To turn a step off use
|
|
62
|
-
\`patchInteractionNode {enabled:false}\` — \`deleteInteraction\` removes it (destructive; confirm first). Any param
|
|
63
|
-
**value** can be a binding token \`{{ source }}\` (e.g. notification \`content: "{{ list_<name>.item.name }}"\`).
|
|
64
|
-
Steps read the page as it is when they run; a refiring trigger is ignored unless \`whileRunning: "queue"\` (or
|
|
65
|
-
\`"latest"\`: the newest firing stops the running one); keyboard
|
|
66
|
-
shortcuts are the \`onKey\` trigger (\`keys: "shift+f, escape"\`).
|
|
67
|
-
|
|
68
|
-
**CMS / API integrations** (\`upsertConnector\`): a **connector** is a manifest declaring a provider's base URL,
|
|
69
|
-
endpoints, auth template and filter operators, executed by the **server** — so integrating Strapi, WordPress,
|
|
70
|
-
Contentful or any REST API is configuration, not code. Read \`plitzi://connector-presets\` (working manifests + every
|
|
71
|
-
template token) and \`plitzi://connectors/{env}\` (this space's). **You never create or see credentials** — write the
|
|
72
|
-
manifest with \`{{credential.token}}\` and no \`connection.credential\`; it saves, and the space owner attaches the
|
|
73
|
-
secret in the builder. To consume one, an \`apiContainer\` needs **\`runtime: "server"\`** plus \`connector\`,
|
|
74
|
-
\`resource\`, optional \`endpoint\`/\`filters\`/\`limit\`/\`singleRecord\`/\`pagination\`; it then publishes
|
|
75
|
-
\`apiContainer_<name>.records\` (or \`.record\`) \`.pageInfo .isEmpty .hasError\` to its **descendants**. Full worked
|
|
76
|
-
flow — list page, detail page, paging, writes — in \`plitzi://guide\`.
|
|
77
|
-
|
|
78
|
-
**Pages & navigation:** \`upsertPage\` — always set a **relative** \`slug\` (no leading \`/\`; the runtime and folder
|
|
79
|
-
slugs prepend the path). A \`:name\` segment (\`"posts/:postId"\`) is a route param, readable as \`{{name}}\` and as the
|
|
80
|
-
source \`navigation.routeParams.name\` → build dynamic pages this way. To move between pages **prefer the \`Link\`
|
|
81
|
-
element** (\`mode\` "page"/"internal"/"external"; its words are its \`content\`, and it can wrap any children too) over
|
|
82
|
-
a \`navigate\` interaction.
|
|
83
|
-
|
|
84
|
-
**Feature flags:** what a person switches on (a beta, a rollout) is \`upsertFlag\` plus \`flag: "x"\` / \`"!x"\` on the
|
|
85
|
-
element or page — not \`visible\`. Read anywhere as \`{{ flags.x }}\`.
|
|
86
|
-
|
|
87
|
-
**Accessible by default:** screen readers and browser agents (Claude in Chrome) read the accessibility tree, so every
|
|
88
|
-
button/link needs words (an icon-only button a \`title\`), every field a \`label\` (\`hideLabel: true\` hides it), every
|
|
89
|
-
image an \`alt\` or \`decorative: true\`; clicks go on a \`button\`/\`link\`, never a container; headings step down one
|
|
90
|
-
level at a time. \`plitzi_look\` shows the tree and what has no name.
|
|
91
|
-
|
|
92
|
-
**Everything the space holds is public.** Its pages, variables, attributes, flow params and mock data ship to every
|
|
93
|
-
visitor's browser, and a file on a public bucket of its CDN is served to anyone who has its address. A key, a token or
|
|
94
|
-
data only some visitors may read never goes in any of them: a secret is a credential the owner attaches (a connector, an
|
|
95
|
-
action or a function names it, never carries it), and data for some visitors only comes from a \`runtime: "server"\`
|
|
96
|
-
provider or an action that checks who is asking.
|
|
97
|
-
|
|
98
|
-
**Touched elements must be malformation-free.** Editing an element also checks its CURRENT stored content and BLOCKS
|
|
99
|
-
the save on any \`Pre-existing malformation in element …\` error (a broken transformer, a malformed step, an attribute
|
|
100
|
-
it never reads) — even parts you did not touch. These are NOT from your change (the message says so); fix them in the
|
|
101
|
-
SAME batch and re-apply (the check runs on the result, so the fix unblocks it). \`Pre-existing issue\` warnings advise
|
|
102
|
-
but do not block. A broken tree your batch leaves ANYWHERE (an element orphaned by a delete) blocks it too. Each
|
|
103
|
-
problem leads with its \`[code]\`, and its hint says what to write instead.
|
|
104
|
-
|
|
105
|
-
Read \`plitzi://guide\` before anything above is unclear.
|
|
106
|
-
`;
|
|
107
|
-
var guideText = `# Plitzi AI MCP — usage guide
|
|
108
|
-
|
|
109
|
-
A Plitzi space is **two separate schemas** you edit together:
|
|
110
|
-
- **Element schema** — the tree of pages and elements (their type, label, props, and which style classes they use).
|
|
111
|
-
- **Style schema** — reusable **definitions** (CSS classes), design tokens (variables), theme.
|
|
112
|
-
|
|
113
|
-
They are stored and persisted independently, but a single \`plitzi_apply\` batch may touch **both atomically**.
|
|
114
|
-
To style a specific element you do two things in one batch: write a **definition** (style schema) and **attach**
|
|
115
|
-
it via the element's \`style.base\` (element schema). Example — "rename button X to PEPE and make it red":
|
|
116
|
-
\`\`\`json
|
|
117
|
-
{ "operations": [
|
|
118
|
-
{ "type": "upsertDefinition", "ref": "btn-x", "desktop": { "color": "red" } },
|
|
119
|
-
{ "type": "upsertElement", "pageRef": "home",
|
|
120
|
-
"element": { "ref": "X", "type": "button", "label": "PEPE", "style": { "base": ["btn-x"] } } }
|
|
121
|
-
] }
|
|
122
|
-
\`\`\`
|
|
123
|
-
|
|
124
|
-
Reads are cheap by design — treat them like a filesystem: **list** to navigate, **read one item** for detail.
|
|
125
|
-
Never download a whole tree you do not need.
|
|
126
|
-
|
|
127
|
-
## Resources (read)
|
|
128
|
-
- \`plitzi://primer/{env}\` — **cold-start bundle**: guide + types + css-properties + page/definition/variable
|
|
129
|
-
**summaries** in one read. Fetch this first instead of the individual resources below. Summaries only — open a
|
|
130
|
-
page skeleton or element for its tree/detail.
|
|
131
|
-
- \`plitzi://guide\` — this guide.
|
|
132
|
-
- \`plitzi://types\` — element types **observed in this space** (ground truth): props, slots, subTypes, plus each
|
|
133
|
-
type's \`label\`, \`description\` (what it is FOR) and \`category\`, and a \`source\` (\`builtin\` | \`plugin\` | \`unknown\`).
|
|
134
|
-
Read the descriptions to pick the right type — e.g. \`apiContainer\` fetches backend data into the frontend,
|
|
135
|
-
\`link\` navigates between pages, \`list\` repeats a template over a data array. \`plugin\` types are the elements
|
|
136
|
-
of the plugins the space installed: added by their type, like a built-in.
|
|
137
|
-
- \`plitzi://css-properties\` — valid kebab-case CSS property keys.
|
|
138
|
-
- \`plitzi://explain/{name}\` — what a name means: an element type's attributes, triggers and callbacks; a step's
|
|
139
|
-
params and what it publishes; what a trigger hands its flow; a problem code's fix. \`plitzi://explain/steps\` (or
|
|
140
|
-
elements, triggers, codes, transformers) lists every one of a kind.
|
|
141
|
-
- \`plitzi://schema/{env}/pages\` — page **summaries** (ref, label, elementCount, folder). No element trees.
|
|
142
|
-
- \`plitzi://schema/{env}/layouts\` — the shared **layout shells** (header/sidebar/footer) and the pages rendered
|
|
143
|
-
inside each. Read one like a page. See *Shared layouts* below.
|
|
144
|
-
- \`plitzi://schema/{env}/components\` — the space's **components** (reusable subtrees): their props, slots, root and
|
|
145
|
-
how many places render each. Read one like a page. See *Components* below.
|
|
146
|
-
- \`plitzi://folders/{env}\` — page **folders** (the sidebar tree): ref, name, slug, parentId. \`/{ref}\` for one.
|
|
147
|
-
- \`plitzi://schema/{env}/pages/{ref}\` — one page as a **skeleton tree**: each node is \`ref/type/label\` **plus the
|
|
148
|
-
style classes it attaches** (\`base\`, and \`slots\` for non-base slots) — names only, no CSS. So you can map every
|
|
149
|
-
element to its class in a single page read, without opening each element just to learn which class it uses.
|
|
150
|
-
- \`plitzi://schema/{env}/pages/{ref}/styles\` — **every style the page uses in one read**: the class definitions its
|
|
151
|
-
elements attach (deduplicated, **with full CSS**) plus the global styles affecting any element type on the page.
|
|
152
|
-
Reach for this to recolor/restyle a whole page — it needs no shared class-name prefix and no per-element reads.
|
|
153
|
-
- \`plitzi://schema/{env}/elements/{ref}\` — one element in **full detail** (props, style, parentRef, childRefs).
|
|
154
|
-
Its \`resolvedStyle\` inlines the **CSS of every definition** the element attaches (keyed by class ref), so you
|
|
155
|
-
can see and edit its style without a separate definition read. Its \`globalStyles\` lists the **global element
|
|
156
|
-
selectors** that also affect it (the CSS equivalent of \`button { … }\`, keyed by the type they target) — every
|
|
157
|
-
element of that type inherits them. Edit a global only through the global-style tools (never per element). If the
|
|
158
|
-
element carries a DOM \`id\` that an id rule matches, its \`idStyle\` (\`#id\`) is inlined too.
|
|
159
|
-
- \`plitzi://definitions/{env}\` — the **names** of every style definition.
|
|
160
|
-
- \`plitzi://definitions/{env}/{ref}\` — one definition's CSS.
|
|
161
|
-
- \`plitzi://global-styles/{env}\` — element **types** that have a site-wide global style. \`/{componentType}\` for one.
|
|
162
|
-
- \`plitzi://id-styles/{env}\` — DOM **ids** that have an id rule (\`#id\`) targeting a single element. \`/{targetId}\` for one.
|
|
163
|
-
- \`plitzi://style-variables/{env}\` — design tokens by category. \`/{category}\` for one.
|
|
164
|
-
- \`plitzi://fonts/{env}\` — the font **families the space loads**, with their source and fallback. \`/{family}\` for one.
|
|
165
|
-
- \`plitzi://schema-variables/{env}\` — space-level values referenced in props as \`{{name}}\`.
|
|
166
|
-
- \`plitzi://flags/{env}\` — the space's **feature flags**, each a default and its rules (see **Feature flags**).
|
|
167
|
-
- \`plitzi://settings/{env}\` — space-level settings: the global \`customCss\` and the state/auth (user-provider) config.
|
|
168
|
-
- \`plitzi://interactions/{env}\` — interaction **actions** observed in this space (grouped by node type): the
|
|
169
|
-
vocabulary for interaction flows.
|
|
170
|
-
- \`plitzi://data-sources/{env}\` — data-source **paths** and binding targets observed in this space: the
|
|
171
|
-
vocabulary for data bindings.
|
|
172
|
-
- \`plitzi://connector-presets\` — working starting **manifests** (Strapi, WordPress, Directus, Contentful, plain
|
|
173
|
-
REST) with the credential keys each provider needs, plus every **template token** the connector engine binds.
|
|
174
|
-
Space-independent. Read it before writing a connector by hand.
|
|
175
|
-
- \`plitzi://connectors/{env}\` — the **connectors this space has**: for each, its read/write endpoint names, its
|
|
176
|
-
filter operators and its published fields. \`/{ref}\` opens one manifest in full. See *Connectors* below.
|
|
177
|
-
- \`plitzi://actions/{env}\` — the **server actions this space has**: what starts each one, who may run it, and the
|
|
178
|
-
input/output contract a caller is held to. \`/{ref}\` opens one flow in full. See *Server actions* below.
|
|
179
|
-
- \`plitzi://actions/{env}/tasks\` — the **server tasks this deployment can run**, each with its params: the steps an
|
|
180
|
-
action may be built from.
|
|
181
|
-
- \`plitzi://functions/{env}\` — the space's **functions**, its own server code: which files, and the tasks, routes and
|
|
182
|
-
hosts they declare. \`plitzi://functions/{env}/{+path}\` reads one file whole. See *Functions* below.
|
|
183
|
-
- \`plitzi://data/{env}\` — the space's **data**: JSON files its server providers read, never served.
|
|
184
|
-
\`plitzi://data/{env}/{+path}\` reads one, parsed. See *Data* below.
|
|
185
|
-
- \`plitzi://changes/{env}\` — the space's **change history**, read-only and newest first: who made each change (a
|
|
186
|
-
person in the builder, an agent, the autofix), when, and every element, class, token or font it touched, whole, before
|
|
187
|
-
and after. \`/{id}\` for the history of one of them — how you find what changed an element you are asked about, or
|
|
188
|
-
review what you or another agent just did.
|
|
189
|
-
- \`plitzi://render/guide\`, \`plitzi://render/types\` — the manual and the type table for \`plitzi_render\` (offline
|
|
190
|
-
widgets, not this space).
|
|
191
|
-
|
|
192
|
-
The style resources also answer under the \`plitzi://schema/{env}/…\` root as aliases — \`plitzi://schema/{env}/definitions/{ref}\`, \`plitzi://schema/{env}/style-variables/{category}\`, \`plitzi://schema/{env}/schema-variables\` — but prefer the ready-made \`uri\` from search / a write response over hand-building either form.
|
|
193
|
-
|
|
194
|
-
Data resources return \`{ stateVersion, data }\`. Keep \`stateVersion\` for optimistic concurrency.
|
|
195
|
-
|
|
196
|
-
**Reuse what you already know — don't re-scan an unchanged page.** A page read (\`plitzi://schema/{env}/pages/{ref}\`)
|
|
197
|
-
returns a \`stateVersion\` that is an **aggregate of the whole page**: it changes if and only if some element on the
|
|
198
|
-
page changed. Its skeleton \`tree\` also carries a \`stateVersion\` **per node**, identical to the one a direct element
|
|
199
|
-
read or search hit returns for that element. So when you come back to a page you already inspected:
|
|
200
|
-
1. Re-read just the page skeleton and compare its top-level \`stateVersion\` to the one you held. **Same → nothing
|
|
201
|
-
changed since your read; skip re-reading and re-searching the tree** and act on what you already know.
|
|
202
|
-
2. If it differs, diff the per-node \`stateVersion\`s against the ones you cached and \`plitzi_read\` **only the nodes
|
|
203
|
-
that changed** — never re-search or re-read the whole tree.
|
|
204
|
-
|
|
205
|
-
This is a **read-time** shortcut, not a safety guarantee. **Other agents/sub-agents may edit the same space
|
|
206
|
-
concurrently**, so a version you cached can go stale between your read and your write. Never skip the write-time
|
|
207
|
-
check below on the strength of a cached hash — the guarantee that no concurrent edit is lost comes only from
|
|
208
|
-
\`expectedResourceVersions\` on \`plitzi_apply\`, which re-validates against the live data at write time.
|
|
209
|
-
|
|
210
|
-
## Navigating (files analogy)
|
|
211
|
-
Pages and containers are folders; elements are files. **Prefer \`plitzi_search\` (especially with \`include: "detail"\`)
|
|
212
|
-
over reading elements one by one** — it jumps straight to elements by label/type/attribute and each hit already
|
|
213
|
-
carries the element's \`uri\`, \`stateVersion\`, \`pageUri\`, \`parentRef\` and tree \`path\`, so you can edit it (with
|
|
214
|
-
optimistic concurrency) **without a follow-up read**. \`include: "detail"\` additionally inlines each hit's props/style
|
|
215
|
-
**and** its \`resolvedStyle\` (the CSS behind its classes) — so a search-then-edit is the efficient path and a manual
|
|
216
|
-
element read is the exception. Search also matches **pages** by name/slug (returned under \`pages\`, each with its uri +
|
|
217
|
-
stateVersion) and returns any **style definitions** whose name matches the query, with full CSS, under \`definitions\`.
|
|
218
|
-
When you do hold several refs to open (e.g. from a skeleton), read them together with \`plitzi_read\` rather than one at a time.
|
|
219
|
-
|
|
220
|
-
## Tools
|
|
221
|
-
- \`plitzi_apply\` — validate → apply → persist atomically. Rejects the whole batch on any error or conflict, and
|
|
222
|
-
reports **pre-existing malformations** in any resource the batch touches (see below) and \`suggestions\` (see
|
|
223
|
-
*Suggestions*). Pass \`dryRun: true\` to check and apply in memory only — the same answer, nothing persisted — and
|
|
224
|
-
\`look\` (\`"html"\`, \`"image"\`, \`"accessibility"\` or \`"both"\`, with \`pageRef\` and \`viewport\`) to see the page
|
|
225
|
-
as the batch leaves it in the same call. Check and look with \`dryRun\`, then send the same operations without it.
|
|
226
|
-
\`effects\` is what the batch did, read off the space before and after it — every element, attribute, class and
|
|
227
|
-
setting it changed, one line each: read it, not your batch, for what is now so. \`Nothing changed\` and \`NOT saved\`
|
|
228
|
-
lead the warnings when they are so.
|
|
229
|
-
- **By intention**, a few parameters and the element named by its ref alone — the page is found, the operations
|
|
230
|
-
written, the batch checked and saved as \`plitzi_apply\` saves it, and the answer its \`effects\`, whether it was
|
|
231
|
-
\`saved\`, and what was already so:
|
|
232
|
-
\`plitzi_set_attributes { ref, set, unset }\`, \`plitzi_set_classes { ref, add, remove }\` (the classes it wears and
|
|
233
|
-
you do not name stay), \`plitzi_bind_attribute { ref, to, source }\`, \`plitzi_place_component { component, ref, into,
|
|
234
|
-
props }\`, \`plitzi_add_page { ref, slug, layout }\`. One of them when it says the whole change; anything else is one
|
|
235
|
-
batch of \`plitzi_apply\`.
|
|
236
|
-
- \`plitzi_describe_operation\` — one operation's schema by its \`type\` (every field, which are required); without a
|
|
237
|
-
type, every operation type there is. Ask for the one you are writing instead of guessing a field: a field an
|
|
238
|
-
operation does not have is refused naming the one meant (\`"prop" (did you mean "props"?)\`), and a type spelt with
|
|
239
|
-
other capitals is read as the catalog spells it and said in \`warnings\`. The same batch refused twice is not run a
|
|
240
|
-
third time (\`REPEATED_BATCH\`) — change what the errors name, or ask the person.
|
|
241
|
-
- \`plitzi_search\` — find elements (and pages/definitions) across the space.
|
|
242
|
-
- \`plitzi_read\` — read many resource **uris in one batch** (pages, elements, definitions, variables). Pass the
|
|
243
|
-
ready-made uris from search / a write response; each result is \`{ uri, stateVersion, data }\` or a teachable error,
|
|
244
|
-
so one bad uri never fails the batch. Use it instead of N single reads whenever you already hold several refs.
|
|
245
|
-
- \`plitzi_look { pageRef, view, viewport }\` — see a saved page. \`view\`: \`"accessibility"\` (default) reads it as a
|
|
246
|
-
screen reader and a browser agent (Claude in Chrome) do — an outline of roles and names, every control and picture
|
|
247
|
-
with no name listed in \`unnamed\`, as text and far cheaper than an image; \`"html"\` its markup; \`"image"\` a PNG,
|
|
248
|
-
the way to SEE overflow and misalignment (desktop, mobile or \`both\`); \`"both"\` image and outline. A change not
|
|
249
|
-
saved yet is seen with \`plitzi_apply\`'s \`dryRun\` and \`look\`, the same views. It needs the SSR render service
|
|
250
|
-
(\`PREVIEW_UNAVAILABLE\` without it); without a browser, an image or an outline falls back to the HTML, said.
|
|
251
|
-
- \`plitzi_activity { after, wait }\` — what happened on the space since you last looked: the draft changed (a person
|
|
252
|
-
in the builder, another agent, the autofix — \`seq\` is its place in \`plitzi://changes/{env}\`), a version went
|
|
253
|
-
out, a server action failed or was refused. The first call, without \`after\`, answers the latest and a \`cursor\`;
|
|
254
|
-
pass it back as \`after\` and the call waits up to \`wait\` seconds (45, at most 50) until something happens. Your own
|
|
255
|
-
writes are left out and counted (\`skippedMine\`; \`mine: true\` keeps them). On a space people edit too, call it
|
|
256
|
-
before a write that rests on what you read earlier.
|
|
257
|
-
- \`plitzi_render\` — a different job: show the user a self-contained widget built offline. It never touches the space.
|
|
258
|
-
|
|
259
|
-
## Suggestions — the same page with fewer elements
|
|
260
|
-
\`plitzi_apply\` (with or without \`dryRun\`) answers with \`suggestions\`: lines like \`[content-attribute] … (saves 4
|
|
261
|
-
elements)\`, each naming a shorter way to what the batch just wrote. Only what THIS batch opened up is said — what the
|
|
262
|
-
space already had is not repeated on every batch — and none of them blocks anything: the page renders as written.
|
|
263
|
-
- \`repeated-on-pages\` — the same block at the edge of several pages: put it in a **layout** once (a block only some
|
|
264
|
-
pages of a layout carry is a **component** instead). Copies differing only in one link's class are the nav item of the
|
|
265
|
-
page being shown: the \`current\` state marks it (see *Pages & folders*).
|
|
266
|
-
- \`repeated-shape\` — one structure written again with other words: a **component** with props
|
|
267
|
-
(\`upsertComponent { fromRef }\` turns one copy into it), or, for sibling rows of data, one \`repeatElement\`/\`list\`.
|
|
268
|
-
A few cards a person rewords by hand can stay cards; siblings that bind different data, keep different state, fill
|
|
269
|
-
from a template of their own or render on the server are controls written alike, and are not offered.
|
|
270
|
-
- \`content-attribute\` — a \`button\` or \`link\` whose children are only a \`text\` and/or a \`fontAwesome\`: its words
|
|
271
|
-
are its own \`content\` and the icon its \`icon\`. What the text's class adds (\`white-space: nowrap\`) moves to the
|
|
272
|
-
box's class — never the class itself; the icon's class goes in the \`icon\` slot.
|
|
273
|
-
- \`custom-css-class\`, \`custom-css-sdk-default\`, \`custom-css-notifications\` — \`customCss\` that a class's
|
|
274
|
-
\`states\`/\`ancestors\`, the SDK (reduced motion, the theme toggle's icons) or the space's notification look says.
|
|
275
|
-
- \`heavy-animation\` — keyframes that animate a size, a position, a blur, a shadow, or a colour in a loop: they stutter
|
|
276
|
-
while the page loads. Lighter, not shorter — see **Motion — good practices**.
|
|
277
|
-
- \`unused-class\`, \`unused-token\`, \`unused-component\` — declared and read by nothing: remove it
|
|
278
|
-
(\`deleteDefinition\`, \`deleteStyleVariable\`, \`deleteComponent\`), or use it where it was meant to go. Said
|
|
279
|
-
when a batch leaves one behind.
|
|
280
|
-
- \`element-color-inherited\` — the space's \`elements\` giving a type \`color: inherit\` or the page's own colour,
|
|
281
|
-
which every element — a link's words included — takes by itself: remove it, and name the colour once on the page.
|
|
282
|
-
- \`literal-colour\` — a class painted from the palette typing out a token's light value: \`var(--token)\` when it
|
|
283
|
-
should follow the scheme; a token of one value when it must stay the same in both.
|
|
284
|
-
\`plitzi://explain/<code>\` explains each. Take one unless the copies are about to diverge; one left on purpose is
|
|
285
|
-
quieted on an element it names — \`quiet: ["repeated-shape"]\` on \`upsertElement\`/\`patchElement\` (\`null\` removes it)
|
|
286
|
-
— and is not offered again, here, in the builder or in authoring. Suggestions' codes only.
|
|
287
|
-
|
|
288
|
-
## Readers: resources vs plitzi_search vs plitzi_read (do not confuse them)
|
|
289
|
-
Three ways to read, each for a different moment — pick by what you have in hand:
|
|
290
|
-
- **MCP resources** (the \`plitzi://…\` catalog above) — the **browsable index**. List them to discover what exists, or
|
|
291
|
-
open one by URI when you are exploring. This is the passive catalog, not a tool.
|
|
292
|
-
- **\`plitzi_search\`** — you know *what* you want but not its **ref/uri** ("the hero button"). Search finds it by
|
|
293
|
-
label/type/attribute and hands back the uri + stateVersion (and, with \`include:"detail"\`, the full element).
|
|
294
|
-
- **\`plitzi_read\`** — you **already hold one or more uris** (from search or a write response) and want their
|
|
295
|
-
content in one batch. It is the tool form of opening resources, for when you have the addresses.
|
|
296
|
-
Rule of thumb: **discover → resources**, **find a name → plitzi_search**, **fetch known uris → plitzi_read**. Never
|
|
297
|
-
hand-build a URI to guess your way to an element — search for it instead.
|
|
298
|
-
|
|
299
|
-
Write tools return what **changed** (\`{ uri, stateVersion }\`) plus counts, and the **full detail of every element
|
|
300
|
-
they created or updated** — each with its own \`uri\` and \`stateVersion\` (\`elements: [...]\`) so a follow-up edit of
|
|
301
|
-
the same element needs **no intermediate read**. Other resources (pages, definitions, variables) still report only
|
|
302
|
-
uri+stateVersion — re-read them if you need their new content. The operation shapes are in each tool's input
|
|
303
|
-
schema (discriminated by \`type\`).
|
|
304
|
-
|
|
305
|
-
## Addressing
|
|
306
|
-
Every element and page has **one name, and that name is its id**. You choose it, you address it by it, and the
|
|
307
|
-
runtime wires by it — there is no second key and nothing to translate. Creating an element with
|
|
308
|
-
\`"ref": "products-api"\` stores it under exactly that.
|
|
309
|
-
|
|
310
|
-
That name is the **wiring key**: a provider registers its data source as \`<type>_<name>\`, so a \`source\` you write
|
|
311
|
-
against a name resolves to that element at runtime. Rules for a **new** name (both enforced; a violation fails the
|
|
312
|
-
batch):
|
|
313
|
-
- Charset \`[A-Za-z0-9_-]\`, **starting with a letter** and not ending in \`-\` (e.g. \`"products-api"\`, \`"food_item"\`). A \`.\` would split
|
|
314
|
-
the \`<type>_<name>.<field>\` source path and the interaction target lookup, so **no dots**. An **underscore is
|
|
315
|
-
allowed**: the FIRST \`_\` separates \`<type>\` from the name and element types are camelCase with none, so
|
|
316
|
-
underscores inside a name are unambiguous (\`list_food_item\` → type \`list\`, name \`food_item\`).
|
|
317
|
-
- **Unique across the space**; a name that is taken is rejected (address the existing element instead).
|
|
318
|
-
|
|
319
|
-
**Never invent a name for something that already exists** — read it. Every read hands you the name back
|
|
320
|
-
(\`plitzi_search\`, a page skeleton, a write response), and that is the string every op takes.
|
|
321
|
-
|
|
322
|
-
**Where an element renders** is its \`runtime\`, settable on \`upsertElement\`/\`patchElement\`: \`"shared"\` (the
|
|
323
|
-
default, both sides), \`"client"\` (browser only) or \`"server"\` (SSR only). It matters for one thing above all — an
|
|
324
|
-
\`apiContainer\` reads through a **connector** only when it is \`"server"\` (see *Connectors*). An element read
|
|
325
|
-
reports it only when it is set. The page server resolves \`"server"\` elements of a page and its layouts only, never
|
|
326
|
-
inside a component — one there is refused; put the provider on the page and hand the component its rows as a prop.
|
|
327
|
-
|
|
328
|
-
**Renaming** (\`patchElement\` with \`rename\`) moves the one key: the parent's child list, every binding source and
|
|
329
|
-
every interaction target across the space that named the old one is repointed with it, so nothing comes unwired.
|
|
330
|
-
You do not have to rewrite them.
|
|
331
|
-
|
|
332
|
-
## Elements — create, move, delete
|
|
333
|
-
- \`upsertElement\` creates an element (or replaces one by name) under \`parentRef\` — the page root when omitted — and
|
|
334
|
-
builds a whole subtree in one op through nested \`children\`. \`patchElement\` changes an existing one in place.
|
|
335
|
-
- \`moveElement { pageRef, ref, toParentRef, position }\` moves or reorders one: \`position\` \`"inside"\` (the default)
|
|
336
|
-
nests it in \`toParentRef\`; \`"before"\`/\`"after"\` make it that element's sibling. Its subtree moves with it.
|
|
337
|
-
- \`deleteElement { pageRef, ref }\` removes an element **and everything under it**. A binding or an interaction
|
|
338
|
-
elsewhere that named one of them is left pointing at nothing, and the save reports it — delete them in the same
|
|
339
|
-
batch. Destructive: confirm first.
|
|
340
|
-
- \`flag\` on \`upsertElement\` / \`patchElement\` gates an element on a feature flag (\`"newCheckout"\` or
|
|
341
|
-
\`"!newCheckout"\`) — not a visibility: gated off it is not rendered at all. See **Feature flags**.
|
|
342
|
-
- **A compound element is written with its parts**, as \`children\` of the same \`upsertElement\`: a \`carousel\` holds a
|
|
343
|
-
\`carouselTrack\` (the slides go in it), a \`tabContainer\` a \`tabContainerHeader\` and a \`tabContainerBody\`, a
|
|
344
|
-
\`dropdown\` a \`dropdownPopup\`. Without its part it shows nothing (\`part-missing\`); a part anywhere else breaks the
|
|
345
|
-
page (\`outside-ancestor\`).
|
|
346
|
-
|
|
347
|
-
## Styling (crosses both schemas)
|
|
348
|
-
- **Mind the type's intrinsic default style.** A type renders with a base CSS *before* any class is attached — read
|
|
349
|
-
it from \`defaultStyle\` on the type in \`plitzi://types\` (the primer includes it). Do not assume \`display: block\`:
|
|
350
|
-
\`text\`, for one, defaults to \`display: inline\`, so margins/width/vertical padding behave differently. If you need
|
|
351
|
-
block/flex layout on such an element, set \`display\` explicitly in your definition rather than relying on a default.
|
|
352
|
-
- **Images: preserve aspect ratio.** Setting only \`width\` and \`height\` (or forcing both) distorts an image. Change
|
|
353
|
-
one dimension and let the other be \`auto\`, or set \`aspect-ratio\` with \`object-fit: cover\`/\`contain\`, so the
|
|
354
|
-
image scales without stretching.
|
|
355
|
-
- **Font size and line height move together.** When you change \`font-size\`, set \`line-height\` in the same edit
|
|
356
|
-
(prefer a unitless ratio like \`1.5\`, which tracks the font size). Changing one without the other leaves cramped or
|
|
357
|
-
loosely-spaced text — they are a joint change, not two separate ones.
|
|
358
|
-
- A definition lives in the **style schema**; an element's \`style.base\` (element schema) is the link that applies
|
|
359
|
-
it. Styling an element = upsertDefinitions + upsertElement with that ref in \`style.base\`, in one batch.
|
|
360
|
-
- **Repeating siblings**: when a set of siblings shares a shape and differs only in data (a list, cards, rows,
|
|
361
|
-
steps), use \`repeatElement\` — the template once with \`{{item.field}}\` placeholders plus \`items\`, which
|
|
362
|
-
creates the wrapper and numbers each row's refs (\`step-1\`, \`step-2\`…). A list inside each row is the same op:
|
|
363
|
-
the wrapping node carries \`repeat: { items: "{{item.<list>}}", template: … }\` and its refs number both levels
|
|
364
|
-
(\`blk-2-3\`). Copy-pasting the subtree N times costs N times the tokens and drifts.
|
|
365
|
-
- CSS keys are **kebab-case** (\`background-color\`). camelCase is rejected — read \`plitzi://css-properties\`.
|
|
366
|
-
- **Write normal CSS — shorthands are accepted and expanded for you.** \`border\`, \`border-{side}\`,
|
|
367
|
-
\`border-width\`/\`-color\`/\`-style\`, \`border-radius\`, \`padding\`, \`margin\`, \`inset\`, \`gap\`, \`overflow\`,
|
|
368
|
-
\`flex\`, \`flex-flow\`, \`background\`, \`font\`, \`transition\`, \`animation\`, \`grid\`, \`grid-template\`,
|
|
369
|
-
\`grid-area\`, \`grid-row\`, \`grid-column\`, \`place-content\`, \`place-items\`, \`place-self\`, \`outline\`,
|
|
370
|
-
\`columns\`, \`list-style\`, \`text-decoration\` — the full list is in \`plitzi://css-properties\` under
|
|
371
|
-
\`shorthands\`. They **persist as longhand keys** (that is what a read gives back), so a breakpoint/state/variant
|
|
372
|
-
can still override one property at a time.
|
|
373
|
-
- \`border: 1px solid red\` → \`border-top-width: 1px\`, \`border-top-style: solid\`, \`border-top-color: red\`, …
|
|
374
|
-
for all four sides. A shorthand also RESETS what it omits, so \`border: none\` clears a width a previous
|
|
375
|
-
definition set.
|
|
376
|
-
- Comma-separated layers are kept per longhand: \`transition: opacity 200ms, transform 300ms\` →
|
|
377
|
-
\`transition-property: opacity, transform\` + \`transition-duration: 200ms, 300ms\`.
|
|
378
|
-
- In a **patch**, a shorthand replaces the longhands it controls (\`padding: 8px\` overwrites a previous
|
|
379
|
-
\`padding-left\`), and \`"border": null\` removes all twelve border longhands.
|
|
380
|
-
- **Flex layout is not a \`flex\` value**: set \`display: flex\` **plus** \`flex-direction\`, \`align-items\`,
|
|
381
|
-
\`justify-content\` as separate properties.
|
|
382
|
-
- CSS is grouped by breakpoint: \`desktop\`, \`tablet\`, \`mobile\`.
|
|
383
|
-
- Reference a style variable in CSS as \`var(--name)\`; a schema variable in a prop as \`{{name}}\`.
|
|
384
|
-
- \`element.style.base\` is a **list** of definition refs; other slots go under \`element.style.slots\` — the slots
|
|
385
|
-
\`plitzi://explain/{type}\` lists, never custom CSS on the SDK's own class names. A \`markdown\` or a \`richText\`
|
|
386
|
-
has a slot per part of the document it writes (\`heading\`, \`heading2\`, \`paragraph\`, \`link\`, \`code\`,
|
|
387
|
-
\`codeBlockFrame\`…); a \`formControl\` its \`input\` box, the \`field\` inside it, \`label\`, \`requiredMark\`, \`error\`;
|
|
388
|
-
a \`pagination\` its \`previous\`, \`page\`, \`next\` (the page shown is the class's \`current\` state).
|
|
389
|
-
- **An element can attach SEVERAL classes at once, and they all apply.** \`style.base\` holds a list, and each
|
|
390
|
-
non-base slot holds its own — every attached definition contributes CSS, and they **cascade** (a later class, then a
|
|
391
|
-
global/id rule, overrides an earlier one on the same property). So when a style looks wrong, the culprit may be
|
|
392
|
-
ANY attached class, not the one you just edited: read the element's \`resolvedStyle\` (it inlines the CSS of every
|
|
393
|
-
class it attaches, keyed by ref) together with its \`globalStyles\`/\`idStyle\` and the type's \`defaultStyle\`, and
|
|
394
|
-
fix the class that actually sets the property — do not just pile another class on top.
|
|
395
|
-
- **Three kinds of style live in the style schema — do not confuse them:**
|
|
396
|
-
- **Definitions** = reusable CSS **classes** (\`upsertDefinition\`/\`patchDefinition\`/\`deleteDefinition\`, keyed by a
|
|
397
|
-
class \`ref\`). Attach one to an element via \`style.base\` to style **that** element (and anything else that opts in).
|
|
398
|
-
This is the **default** way to style one element. Declaring MORE than one class in a batch? Use
|
|
399
|
-
\`upsertDefinitions\` — one op carrying \`{ "<class>": { desktop: … }, … }\`, same result as the run of
|
|
400
|
-
\`upsertDefinition\` it replaces, without repeating the envelope once per class.
|
|
401
|
-
- **Global styles** = the CSS equivalent of a bare element selector like \`button { … }\`
|
|
402
|
-
(\`upsertGlobalStyle\`/\`patchGlobalStyle\`/\`deleteGlobalStyle\`, keyed by \`componentType\`). They style **every**
|
|
403
|
-
element of that type at once. Use these for site-wide intent — e.g. "all buttons rounded":
|
|
404
|
-
\`{ "type": "upsertGlobalStyle", "componentType": "button", "desktop": { "border-radius": "9999px" } }\`.
|
|
405
|
-
- **Id styles** = the CSS equivalent of an id selector like \`#hero { … }\`
|
|
406
|
-
(\`upsertIdStyle\`/\`patchIdStyle\`/\`deleteIdStyle\`, keyed by \`targetId\`). They style the **single** element whose
|
|
407
|
-
DOM \`id\` attribute equals \`targetId\` — so the element must carry that \`id\` (set it in its props). Prefer a
|
|
408
|
-
**definition** for one element; reach for an id style only when a specific, uniquely-identified node must be
|
|
409
|
-
targeted by id: \`{ "type": "upsertIdStyle", "targetId": "hero", "desktop": { "min-height": "100vh" } }\`.
|
|
410
|
-
- The three share one name space, so an op refuses a name held by another kind (guards against a typo silently
|
|
411
|
-
rewriting every element of a type, or converting a class into an id rule). If refused, you targeted the wrong
|
|
412
|
-
kind — switch tools or rename.
|
|
413
|
-
|
|
414
|
-
## Style variants & element state
|
|
415
|
-
A **variant** is a named CSS override on a definition (e.g. a button class with a \`primary\` variant). It takes two
|
|
416
|
-
steps across the two schemas:
|
|
417
|
-
- **Declare** the variant CSS on the class (style schema): \`upsertDefinition\`/\`patchDefinition\` with
|
|
418
|
-
\`variants: { "primary": { "desktop": { "background-color": "#111" } } }\` (per slot under \`slots.<slot>.variants\`).
|
|
419
|
-
- **Apply** it to an element (element schema): \`initialState.styleVariant\` =
|
|
420
|
-
\`{ "<class-ref>": { "base": "primary" } }\` — a slot name instead of \`base\` targets that slot; an array applies
|
|
421
|
-
several. Set it via \`upsertElement\`/\`patchElement\`.
|
|
422
|
-
An element read reports \`availableVariants\` (which variant each attached class offers) and the element's current
|
|
423
|
-
\`initialState\`, so you can see a button **has** a \`primary\` variant and whether it uses it. If the user asks for a
|
|
424
|
-
variant that does not exist yet, **create it (upsertDefinition variants) and apply it in the same batch**.
|
|
425
|
-
- \`initialState.visibility\` (boolean) sets whether the element starts shown or hidden.
|
|
426
|
-
- The \`hidden\` state of a class is how it looks while hidden — where it goes and where it comes from. With a
|
|
427
|
-
\`transition\` that includes \`display 200ms allow-discrete\`, it fades or slides in and out instead of blinking.
|
|
428
|
-
|
|
429
|
-
**Ancestor conditions** — a class that changes inside an ANCESTOR (\`.toolbar .icon\`), or while that ancestor is
|
|
430
|
-
hovered or in a variant (\`.card:hover .icon\`, a collapsed sidebar hiding its labels) is \`ancestors\` on that class,
|
|
431
|
-
keyed by a class the ancestor wears: \`ancestors: { "toolbar": { "desktop": { … } }, "card": { "states": { "hover":
|
|
432
|
-
{ "desktop": { … } } } }, "sidebar": { "variants": { "collapsed": … } } }\`.
|
|
433
|
-
Any ancestor counts, not only the parent; the class's own states and variants win over these. Never customCss for it.
|
|
434
|
-
\`">"\` keys the parent, whatever it wears — a component's part reacting to what it sits in.
|
|
435
|
-
|
|
436
|
-
**Pseudo-elements and conditions** sit beside \`states\` in a definition and in each of its variants:
|
|
437
|
-
\`pseudos: { "after": { "desktop": { "content": "\\"→\\"" }, "states": { "hover": { "desktop": { … } } } } }\`
|
|
438
|
-
(\`before\`/\`after\` are drawn only with a quoted \`content\`; also \`selection\`, \`marker\`, \`placeholder\`,
|
|
439
|
-
\`first-letter\`, \`first-line\`), and \`conditions: { "motion-reduce": { "desktop": { … } }, "container (max-width:
|
|
440
|
-
30rem)": { … } }\` (the nearest ancestor whose class sets \`container-type\`). A patch keeps the ones it does not name;
|
|
441
|
-
\`null\` removes one. A state beyond \`hover\`/\`focus-visible\`/\`current\`: \`expanded\` (an open trigger), \`first\`,
|
|
442
|
-
\`last\`, \`odd\`, \`even\`.
|
|
443
|
-
|
|
444
|
-
## Variables, design tokens and fonts
|
|
445
|
-
- **Schema variables** are space-wide values a prop reads as \`{{name}}\`: \`upsertVariable { name, variableType,
|
|
446
|
-
value, category?, subValues? }\` (\`variableType\` is the runtime type — \`text\`, \`number\`, … — not the op's
|
|
447
|
-
\`type\`), \`deleteVariable { name }\`.
|
|
448
|
-
- **Design tokens** are CSS values a definition reads as \`var(--name)\`: \`upsertStyleVariable { category, name,
|
|
449
|
-
value }\` with \`category\` one of \`color\`, \`spacing\`, \`shadow\`, \`custom\` and \`name\` without the \`--\`. A
|
|
450
|
-
\`value\` may be one string or \`{ light, dark }\`, so a colour follows the theme. \`deleteStyleVariable\` removes one.
|
|
451
|
-
Reach for a token whenever a value repeats across classes — a hardcoded colour is a colour the theme cannot change.
|
|
452
|
-
- **Fonts**: a \`font-family\` only renders in its face when the space loads that family. \`upsertFont { family,
|
|
453
|
-
source, fallback, weights? }\` declares one — \`source\` \`google\` needs nothing else, \`remote\` a \`stylesheet\` or
|
|
454
|
-
\`files\` URL, \`system\` loads nothing. \`deleteFont { family }\` stops loading it; rules that still name it render
|
|
455
|
-
in their fallback.
|
|
456
|
-
|
|
457
|
-
## Data bindings
|
|
458
|
-
Connect a data **source** to an element field. A binding is \`{ to, source, transformers?, when?, enabled? }\` grouped
|
|
459
|
-
by **category**: \`attributes\` (a prop), \`style\` (a style value), \`initialState\` (an initial-state key).
|
|
460
|
-
- \`upsertBinding\` adds one, or replaces the binding already feeding the same \`to\` (or \`id\`).
|
|
461
|
-
- \`patchBinding\` edits an existing one (matched by \`to\`/\`id\`); \`deleteBinding\` removes it.
|
|
462
|
-
Discover valid source paths **and the transformer catalog** in \`plitzi://data-sources/{env}\`. Example — feed a
|
|
463
|
-
provider's records into a list element:
|
|
464
|
-
\`{ "type": "upsertBinding", "pageRef": "home", "ref": "myList", "category": "attributes",
|
|
465
|
-
"binding": { "to": "items", "source": "apiContainer_products.records" } }\`.
|
|
466
|
-
|
|
467
|
-
**What an \`apiContainer\` publishes** depends on where it reads. Through a connector (\`runtime: "server"\`) it is the
|
|
468
|
-
fixed shape under *Connectors* — \`.records\` or \`.record\`, \`.pageInfo\`, … With a browser \`query\` it is the
|
|
469
|
-
response: \`.data\` (the parsed body — an API answering \`{ "items": [...] }\` is read as
|
|
470
|
-
\`apiContainer_<name>.data.items\`) and \`.status\` (the HTTP status) — and a \`"server"\` provider with only a
|
|
471
|
-
\`query\` (a JSON file the deployment serves) answers in that same shape, so moving it to the server changes no
|
|
472
|
-
binding. Fed by a server **action**, it is the action's output at the root (\`apiContainer_<name>.items\`, never
|
|
473
|
-
\`.data.items\`). All add \`.isLoading\` (true while asked again too), \`.isEmpty\`,
|
|
474
|
-
\`.hasError\` and \`.errorMessage\`.
|
|
475
|
-
|
|
476
|
-
**Source scope — a source is visible to the provider's DESCENDANTS only.** An element source named
|
|
477
|
-
\`<type>_<name>\` (e.g. \`apiContainer_products\`, \`list_food-list\`) is published by that element into the scope of
|
|
478
|
-
its **subtree**, so **only elements INSIDE the provider can bind to it**. Binding a sibling or an unrelated element
|
|
479
|
-
to it resolves to nothing at runtime. So to consume \`apiContainer_products.records\`, the bound element must live under
|
|
480
|
-
that apiContainer; inside a \`list\`, the repeated \`listItem\` and its children read the per-row source
|
|
481
|
-
(\`list_<name>.item.<field>\`). The global sources — ${GLOBALS} — have no \`<type>_<name>\` head and are
|
|
482
|
-
bindable anywhere. Binding an element to an element source outside its
|
|
483
|
-
provider's subtree is schema-valid but **broken at runtime** (the source is not in scope), so
|
|
484
|
-
\`plitzi_apply\` treats it as an **error and rejects the batch** — move the element under the
|
|
485
|
-
provider, or bind a source that is in scope.
|
|
486
|
-
|
|
487
|
-
**mockData is builder-only.** An \`apiContainer\`'s \`mockData\` prop feeds sample data **while editing in the
|
|
488
|
-
builder**; the published runtime fetches real data instead. Never rely on mockData as the production source — give
|
|
489
|
-
the provider a real source: a **connector** with \`runtime: "server"\` (see *Connectors*, the right answer whenever
|
|
490
|
-
the API needs a token or the content should be in the HTML), or a browser-side \`query\`/\`method\` for a public URL.
|
|
491
|
-
|
|
492
|
-
**\`transformers\` — post-process the value before it reaches the field** (\`source → t₁ → t₂ → field\`). An array of
|
|
493
|
-
\`{ action, params }\`; the runtime runs them in order and resolves each by its \`action\` alone, so an **unknown
|
|
494
|
-
action is silently skipped** and the raw value passes through. Use the **exact** action names from
|
|
495
|
-
\`plitzi://data-sources\` (\`transformers\`). The most common is **\`twigTemplate\`** to format a value — the incoming
|
|
496
|
-
value is the **\`{{source}}\`** token (NOT \`{{value}}\`) — undefined until the source has a value, so \`{{ source|default('…') }}\` covers the wait; \`{{sourceTo}}\` is the field's previous value. Example —
|
|
497
|
-
show a number with units:
|
|
498
|
-
\`{ "type": "upsertBinding", "pageRef": "home", "ref": "food-item-time", "category": "attributes",
|
|
499
|
-
"binding": { "to": "content", "source": "list_food-list.item.cookTimeMinutes",
|
|
500
|
-
"transformers": [ { "action": "twigTemplate", "params": { "template": "{{source}} min de cocción" } } ] } }\`.
|
|
501
|
-
The others: ${OTHER_TRANSFORMERS} — each one's purpose and params are in \`plitzi://data-sources/{env}\`.
|
|
502
|
-
Transformer \`params\` values are strings. Each transformer also takes an optional \`enabled\` flag: set \`"enabled": false\` to keep it in the chain but
|
|
503
|
-
skip it at runtime (defaults to true) — the value passes through untouched, and a disabled transformer is not
|
|
504
|
-
validated.
|
|
505
|
-
|
|
506
|
-
**\`when\` — gate the binding** with a QueryBuilder RuleGroup: the binding only applies when the guard passes against
|
|
507
|
-
the data source. Shape: \`{ "combinator": "and", "rules": [ { "field": "<path>", "operator": "=", "value": "x" } ] }\`
|
|
508
|
-
(operators: \`=\`, \`!=\`, \`<\`, \`>\`, \`contains\`, \`beginsWith\`, \`empty\`, \`in\`, \`between\`, …; nest RuleGroups for
|
|
509
|
-
and/or). The guard is validated structurally. Example — only bind when a flag is set:
|
|
510
|
-
\`"when": { "combinator": "and", "rules": [ { "field": "status", "operator": "=", "value": "published" } ] }\`.
|
|
511
|
-
|
|
512
|
-
## Interactions
|
|
513
|
-
An interaction **flow** is a **trigger** (an event like \`onClick\`, \`onPageLoad\`) followed by the callbacks/utilities
|
|
514
|
-
it runs, in order. You pass the steps **in order** and the stored beforeNode/afterNode/flowId links are computed for
|
|
515
|
-
you — never wire them by hand. Each step also has an \`enabled\` flag (see disable vs delete below).
|
|
516
|
-
|
|
517
|
-
**Each step reads the page as it is when it runs**: a \`when\` or a \`{{ state.x }}\` after a \`setState\` sees the new
|
|
518
|
-
value, and one after a \`delay\` sees what changed meanwhile. To act on the value from BEFORE a write, put the reading
|
|
519
|
-
step first. A step's \`when\` asks an earlier step only for what it publishes (\`plitzi://explain/<action>\` lists it):
|
|
520
|
-
a run's \`<step>.status\` (\`runServerAction\` only), a sign-in's \`<step>.ok\` — any other key is refused
|
|
521
|
-
(\`condition-field-unpublished\`). **A trigger fired again while its flow runs is ignored** (no double submit); set
|
|
522
|
-
\`"whileRunning": "queue"\` on the trigger node for a stream of events that must each run in order (\`"parallel"\` runs
|
|
523
|
-
them at once, \`"latest"\` stops the running flow — its server action or request too — for a search as you type).
|
|
524
|
-
**Keyboard shortcuts** are a trigger every element has: \`onKey\` with param \`keys\` — \`"f"\`, \`"shift+f"\`,
|
|
525
|
-
\`"mod+k"\` (⌘ on a Mac, Ctrl elsewhere), \`"plus, ="\`, \`"escape"\`. Heard on the whole page while the element is
|
|
526
|
-
mounted, ignored while someone types in a field; the flow reads the key pressed as \`{{ <trigger id>.key }}\`.
|
|
527
|
-
|
|
528
|
-
**Node types & \`elementId\`** — a step names which element (or module) provides the callback it runs. Picking the
|
|
529
|
-
**wrong node type for an action** makes the runtime resolve it against nothing, so the step **silently does nothing**:
|
|
530
|
-
- \`trigger\` — the event; belongs to the host element. \`elementId\` defaults to the host.
|
|
531
|
-
- \`callback\` — a callback provided by a **specific element**. \`elementId\` is that element's name (the flow host by
|
|
532
|
-
default, or another element to act on). Every element
|
|
533
|
-
registers a built-in **\`setState\`** callback that changes **its own attribute or state**: params
|
|
534
|
-
\`category\` (\`"attribute"\` — set a prop like \`content\`/\`disabled\` — or \`"state"\` — \`visibility\` or a style
|
|
535
|
-
selector), \`key\`, \`value\` (a **scalar** whose type follows the target attribute — a real boolean \`true\`/\`false\`
|
|
536
|
-
for a boolean attribute, a number for a numeric one, otherwise a string), and **\`revertOnFinish\`**. Set
|
|
537
|
-
\`revertOnFinish: true\` for a **temporary** change (a "loading…" label, disabling a button while it works): it is
|
|
538
|
-
**undone automatically when the flow finishes**, so you do **NOT** add manual restore steps at the end. This element
|
|
539
|
-
\`setState\` has **no** \`type\` param (that belongs to the global one below). Beside it every element registers
|
|
540
|
-
**\`toggleState\`** — the same write with **no \`value\`**: it stores the OPPOSITE of what is there
|
|
541
|
-
(\`category\`, \`key\`, \`revertOnFinish\`). That is how expand/collapse is authored — **one step on one trigger**,
|
|
542
|
-
never two \`setState\` branches under complementary \`when\` conditions: every step reads the page as it is when it
|
|
543
|
-
runs, so the second sees what the first wrote and flips it back. An element type may also register its own extra
|
|
544
|
-
callbacks.
|
|
545
|
-
- \`globalCallback\` — a callback provided by a **source module**, NOT by any element: \`addNotification\` (source
|
|
546
|
-
\`space\`), \`setState\`/\`toggleState\`/\`clearState\` (\`state\`), \`navigate\` (\`navigation\`), \`login\`/\`logout\`/
|
|
547
|
-
\`refreshDetails\` (\`auth\`), \`runServerAction\`/\`cancelServerAction\` (\`actions\`). Its \`elementId\` is the
|
|
548
|
-
**source module id**, never the host element — a node that stored the host element's name here would resolve to
|
|
549
|
-
nothing at runtime. **Omit \`elementId\`**: the MCP sets the correct source and fills the
|
|
550
|
-
builder's **param defaults** (e.g. \`addNotification\` gets \`autoDismiss:true\`, \`autoDismissTimeout:5000\`,
|
|
551
|
-
\`placement:"top-right"\`, \`appearance:"success"\`) for any params you leave out. Use **only** the params each
|
|
552
|
-
callback declares (exact spelling) — for \`addNotification\` the visible text goes in \`content\`; there is **no**
|
|
553
|
-
\`title\`/\`message\`/\`type\` param, and any unknown key is dropped. See the full param schema for each callback under
|
|
554
|
-
\`globalCallbacks\` in \`plitzi://interactions/{env}\`.
|
|
555
|
-
- **Two \`setState\`s (and two \`toggleState\`s) — do not mix them:** the **element** \`setState\` (nodeType
|
|
556
|
-
\`callback\`, on an element, category/key/value/revertOnFinish) changes THAT element's attribute/state and is what
|
|
557
|
-
you want to change a button's label or disabled flag. The **global** \`setState\` (nodeType \`globalCallback\`,
|
|
558
|
-
source \`state\`, key/type/value) writes \`runtime.state.<key>\`. They share a name but have different node types
|
|
559
|
-
AND different params, and \`toggleState\` splits the same way: on an element (category/key/revertOnFinish) it flips
|
|
560
|
-
that element's own field; on source \`state\` (key) it flips \`runtime.state.<key>\`. Pick the element one when
|
|
561
|
-
nothing outside the element needs to know it is open; pick the state one when something else binds to it.
|
|
562
|
-
- \`utility\` — a built-in utility action (no element/source module); nodeType \`utility\`. Use the **exact** param
|
|
563
|
-
names: \`delayTime\` waits \`time\` milliseconds (**not** \`delay\`), \`twigTemplate\` (\`returnMode\`, \`template\`),
|
|
564
|
-
\`webHook\` (\`url\`, \`method\`, …), \`copyToClipboard\` (\`text\`). See \`utilities\` in
|
|
565
|
-
\`plitzi://interactions/{env}\`.
|
|
566
|
-
|
|
567
|
-
**A param value can be a data binding.** Any interaction param may hold a \`{{ source }}\` token instead of a literal —
|
|
568
|
-
it resolves at runtime exactly like a prop binding, using the same source grammar (\`<type>_<name>.<path>\`, or a
|
|
569
|
-
module source like \`navigation\`/\`state\`). This is how a step reacts to *the data in context*: inside a \`listItem\`,
|
|
570
|
-
a click on a row can show \`addNotification\` with \`content: "{{ list_<name>.item.name }}"\` — the clicked row's field.
|
|
571
|
-
The value follows the source's type, so a token is valid even where a param expects a boolean/number. Copy/paste of an
|
|
572
|
-
element repoints these tokens to the copies' names automatically, along with the element's bindings.
|
|
573
|
-
|
|
574
|
-
**Navigating between pages — prefer the \`Link\` element over an interaction.** For a plain "go to page X" the right
|
|
575
|
-
tool is a \`link\` element (a container, see *Pages & folders*), not a \`navigate\` interaction step. Use the
|
|
576
|
-
\`navigate\` globalCallback only when the navigation is one step of a larger flow (e.g. submit a form, then go).
|
|
577
|
-
|
|
578
|
-
Tools:
|
|
579
|
-
- \`upsertInteractionFlow\` — create or replace one flow. The FIRST node must be a \`trigger\`. Pass \`flowId\` (the
|
|
580
|
-
trigger's node id) to replace an existing flow. Example (elementId omitted — the MCP wires it to \`space\` and fills
|
|
581
|
-
the notification defaults):
|
|
582
|
-
\`{ "type": "upsertInteractionFlow", "pageRef": "home", "ref": "cta", "nodes": [
|
|
583
|
-
{ "nodeType": "trigger", "action": "onClick", "title": "Click" },
|
|
584
|
-
{ "nodeType": "globalCallback", "action": "addNotification", "title": "Notify",
|
|
585
|
-
"params": { "content": "Saved!" } } ] }\`.
|
|
586
|
-
- \`patchInteractionNode\` — change one step in place (by \`nodeId\`); \`params\` merge onto the node.
|
|
587
|
-
|
|
588
|
-
**Disable vs delete a step — do not confuse them (three different intents):**
|
|
589
|
-
- **Disable / deactivate / turn off a step** (keep it in the flow, just stop it running): \`patchInteractionNode\`
|
|
590
|
-
with \`{ "enabled": false }\`. Re-enable with \`{ "enabled": true }\`. This is NOT a deletion — the step stays.
|
|
591
|
-
- **Remove one step** from a flow: \`deleteInteraction\` with \`nodeId\` (its neighbors are re-linked).
|
|
592
|
-
- **Remove the whole flow**: \`deleteInteraction\` with \`flowId\` (the trigger node id).
|
|
593
|
-
|
|
594
|
-
So "deactivate the addNotification step" means \`patchInteractionNode { enabled: false }\` — never delete the step, and
|
|
595
|
-
never delete the flow. \`deleteInteraction\` is **destructive and not undoable**: only use it when the user asked to
|
|
596
|
-
*remove* something, and **confirm with the user before deleting** a step or a flow.
|
|
597
|
-
|
|
598
|
-
Discover valid actions in \`plitzi://interactions/{env}\`: \`actions\` = observed, \`globalCallbacks\` /
|
|
599
|
-
\`elementCallbacks\` / \`utilities\` = the built-in vocabularies with their full param schema, so you know the exact
|
|
600
|
-
node type and valid params per action. An element read lists its flows as ordered nodes (each with its \`id\` and
|
|
601
|
-
\`enabled\`), so a follow-up patch/delete needs no extra read.
|
|
602
|
-
|
|
603
|
-
## What is public — and where a secret goes
|
|
604
|
-
A space is served to anyone who opens it, and everything it is made of goes with it:
|
|
605
|
-
|
|
606
|
-
- **The documents.** Every page, layout and component, every schema and style variable, every attribute, binding,
|
|
607
|
-
flow param and \`mockData\` reaches the visitor's browser with the page. Hiding an element (\`visible: false\`, a
|
|
608
|
-
flag, a condition) does not remove it from what is sent.
|
|
609
|
-
- **The files.** A file on one of the space's public buckets is on the internet at its address, signed in or not —
|
|
610
|
-
for pictures, fonts and data every visitor may see.
|
|
611
|
-
|
|
612
|
-
So a secret — an API key, a token, a password — never goes in a document or a public file. It is a **credential**,
|
|
613
|
-
created by the space owner in the builder, which a connector, an action or a function **names** and never carries.
|
|
614
|
-
Data only some visitors may read comes from a \`runtime: "server"\` provider or a server action whose \`access\` checks
|
|
615
|
-
who is asking — never from a public file or a document the page filters on the client.
|
|
616
|
-
|
|
617
|
-
## Connectors — CMS and API integrations
|
|
618
|
-
A **connector** is how a space reads real content from Strapi, WordPress, Contentful, Directus or any REST service.
|
|
619
|
-
It is **a manifest, not code**: you declare the base URL, the endpoints, the auth template and the filter operators,
|
|
620
|
-
and the **server** executes it during the render. Integrating a new CMS never means shipping an adapter — it means
|
|
621
|
-
writing one document, which you can do here with \`upsertConnector\`.
|
|
622
|
-
|
|
623
|
-
Why the server and not the browser: the request (and the token behind it) never reaches the visitor, and the content
|
|
624
|
-
is in the HTML search engines see. That is also the one hard rule below — a provider element that is not
|
|
625
|
-
server-rendered ignores its connector entirely.
|
|
626
|
-
|
|
627
|
-
**Read these two first:**
|
|
628
|
-
- \`plitzi://connector-presets\` — **working manifests** for Strapi v5, WordPress, Directus, Contentful and a plain
|
|
629
|
-
REST API, each with the \`credentialKeys\` that provider needs, **plus every template token** the engine binds.
|
|
630
|
-
Start from the preset for the user's provider and edit it; do not invent a shape from memory.
|
|
631
|
-
- \`plitzi://connectors/{env}\` — the connectors **this space already has**, each with its read/write endpoint names,
|
|
632
|
-
its filter operators and its published fields. \`plitzi://connectors/{env}/{ref}\` opens one manifest in full.
|
|
633
|
-
|
|
634
|
-
### Credentials are NOT yours to write
|
|
635
|
-
You never create, see or transmit a secret. Author the manifest with the token in place
|
|
636
|
-
(\`"value": "Bearer {{credential.token}}"\`) and **leave \`connection.credential\` unset** unless the user hands you an
|
|
637
|
-
identifier. The connector **saves fine that way** — validation reports it as a *warning*, not an error — and its
|
|
638
|
-
requests go unauthenticated until the space owner creates the credential in the builder and attaches it. Say that to
|
|
639
|
-
the user as the last step of any integration you build, naming the keys the preset lists (e.g. Strapi needs \`token\`).
|
|
640
|
-
|
|
641
|
-
### The manifest
|
|
642
|
-
Every string is a template the server renders per request. \`{{resource}}\` is the collection the element asked for;
|
|
643
|
-
\`{{limit}}\`/\`{{offset}}\`/\`{{page}}\`/\`{{cursor}}\` the window; \`{{routeParams.x}}\`/\`{{queryParams.x}}\` the
|
|
644
|
-
visitor's URL; \`{{credential.x}}\` the secret; \`{{field}}\`/\`{{value}}\` inside an operator; \`{{id}}\`/\`{{values}}\`
|
|
645
|
-
inside a write. The op splits it in two, exactly as the engine does:
|
|
646
|
-
- **\`connection\`** — what applies to every call: \`credential\`, \`auth\`, \`headers\`, \`pagination\`, \`operators\`,
|
|
647
|
-
\`mediaBaseUrl\`, \`fields\`, \`projection\`.
|
|
648
|
-
- **\`endpoints\`** — the individual calls: \`read\` (named; **\`list\` is the one an element addresses when it names
|
|
649
|
-
none**) and \`write\` (named; **omit for read-only** — an undeclared write can never be executed).
|
|
650
|
-
|
|
651
|
-
A read endpoint says where things live in *that* provider's response: \`itemsPath\` (the array), \`totalPath\` (the
|
|
652
|
-
count), \`idPath\` (the record's id), \`valuesPath\` (its fields). Strapi's \`data\` + \`meta.pagination.total\` and
|
|
653
|
-
Contentful's \`items\` + \`fields\` are the same manifest with different paths.
|
|
654
|
-
|
|
655
|
-
Two traps the validator will catch for you, both silent at runtime otherwise:
|
|
656
|
-
- An **operator template must render a whole \`key=value\` entry** (\`"eq": "filters[{{field}}][$eq]={{value}}"\`). A
|
|
657
|
-
filter naming an operator the manifest does not declare is **dropped** — the query then returns *unfiltered*
|
|
658
|
-
records, not none.
|
|
659
|
-
- **Paging must appear in the request.** Declaring \`pagination: "page"\` without \`{{page}}\` in the query makes every
|
|
660
|
-
page resolve to the first one.
|
|
661
|
-
|
|
662
|
-
Example — Strapi, from the preset:
|
|
663
|
-
\`\`\`json
|
|
664
|
-
{ "type": "upsertConnector", "ref": "strapi-blog", "name": "Blog CMS",
|
|
665
|
-
"baseUrl": "https://cms.example.com",
|
|
666
|
-
"connection": {
|
|
667
|
-
"auth": { "in": "header", "name": "Authorization", "value": "Bearer {{credential.token}}" },
|
|
668
|
-
"pagination": "offset",
|
|
669
|
-
"operators": { "eq": "filters[{{field}}][$eq]={{value}}", "contains": "filters[{{field}}][$containsi]={{value}}" },
|
|
670
|
-
"mediaBaseUrl": "https://cms.example.com" },
|
|
671
|
-
"endpoints": { "read": { "list": {
|
|
672
|
-
"path": "/api/{{resource}}",
|
|
673
|
-
"query": { "pagination[start]": "{{offset}}", "pagination[limit]": "{{limit}}", "populate": "*" },
|
|
674
|
-
"itemsPath": "data", "totalPath": "meta.pagination.total", "idPath": "documentId" } } } }
|
|
675
|
-
\`\`\`
|
|
676
|
-
\`patchConnector\` changes part of one (endpoints merge **by name**; \`null\` removes one) — that is how you add a
|
|
677
|
-
\`detail\` read to a large manifest without resending it. \`deleteConnector\` is destructive: every element pointing
|
|
678
|
-
at it stops resolving, so confirm first.
|
|
679
|
-
|
|
680
|
-
### Using a connector on a page
|
|
681
|
-
The provider element is \`apiContainer\`, and it needs **both halves**:
|
|
682
|
-
1. \`runtime: "server"\` — set it on \`upsertElement\`/\`patchElement\`. **Without it the connector is ignored** and the
|
|
683
|
-
element falls back to fetching its own \`query\` URL from the browser. This is the single most common mistake; the
|
|
684
|
-
validator warns when it sees one half without the other.
|
|
685
|
-
2. props: \`connector\` (the ref), \`resource\` (the collection → \`{{resource}}\`), and optionally \`endpoint\` (a read
|
|
686
|
-
other than \`list\`), \`filters\`, \`limit\`, \`singleRecord\`, \`pagination\`, \`pageParam\`.
|
|
687
|
-
|
|
688
|
-
It then publishes one source **to its descendants only** (like any provider — bind *inside* its subtree):
|
|
689
|
-
\`apiContainer_<name>.records\` (an array of \`{ id, values }\` — a record's fields are under \`values\`, so a row
|
|
690
|
-
reads \`list_<name>.item.values.<field>\`), \`.pageInfo\` (\`page\`, \`pageCount\`, \`total\`, \`hasNextPage\`…),
|
|
691
|
-
\`.isEmpty\`, \`.hasError\`, \`.errorMessage\`, \`.isLoading\`. With \`singleRecord: true\` it publishes \`.record\`
|
|
692
|
-
instead of \`.records\` — that is what a **detail page** uses. Bind an empty-state block's visibility to \`.isEmpty\`
|
|
693
|
-
and an error block's to \`.hasError\`; they are ordinary bindings, no special mechanism.
|
|
694
|
-
|
|
695
|
-
**A list page** — provider, then a \`list\` inside it bound to the records, then the row template reading the item
|
|
696
|
-
(a \`list\` is a \`<ul>\`, or \`<ol>\` by \`subType\`; its row a \`listItem\`, an \`<li>\` — any other row is warned
|
|
697
|
-
\`list-row-not-li\`):
|
|
698
|
-
\`\`\`json
|
|
699
|
-
{ "operations": [
|
|
700
|
-
{ "type": "upsertElement", "pageRef": "blog", "element": {
|
|
701
|
-
"ref": "posts-api", "type": "apiContainer", "runtime": "server",
|
|
702
|
-
"props": { "connector": "strapi-blog", "resource": "articles", "limit": "9", "pagination": "url" },
|
|
703
|
-
"children": [ { "ref": "posts", "type": "list", "children": [
|
|
704
|
-
{ "ref": "post-row", "type": "listItem", "children": [
|
|
705
|
-
{ "ref": "post-title", "type": "text" } ] } ] } ] } },
|
|
706
|
-
{ "type": "upsertBinding", "pageRef": "blog", "ref": "posts", "category": "attributes",
|
|
707
|
-
"binding": { "to": "items", "source": "apiContainer_posts-api.records" } },
|
|
708
|
-
{ "type": "upsertBinding", "pageRef": "blog", "ref": "post-title", "category": "attributes",
|
|
709
|
-
"binding": { "to": "content", "source": "list_posts.item.values.title" } } ] }
|
|
710
|
-
\`\`\`
|
|
711
|
-
|
|
712
|
-
**A detail page** is the same provider with \`singleRecord\` and a filter resolved from the URL. Create the page with a
|
|
713
|
-
route param (\`"slug": "blog/:postSlug"\`), then filter on it — the filter \`value\` is a template the server resolves:
|
|
714
|
-
\`\`\`json
|
|
715
|
-
{ "type": "upsertElement", "pageRef": "post-detail", "element": {
|
|
716
|
-
"ref": "post-api", "type": "apiContainer", "runtime": "server",
|
|
717
|
-
"props": { "connector": "strapi-blog", "resource": "articles", "singleRecord": true,
|
|
718
|
-
"filters": [ { "field": "slug", "operator": "eq", "value": "{{routeParams.postSlug}}" } ] } } }
|
|
719
|
-
\`\`\`
|
|
720
|
-
Its children then bind to \`apiContainer_post-api.record.values.<field>\`. A filter whose template resolves to nothing
|
|
721
|
-
returns **no records** rather than the whole collection — a URL that addressed one post never renders a different one.
|
|
722
|
-
|
|
723
|
-
**Paging** is the \`pagination\` prop: \`"none"\`, \`"url"\` (the page number rides the query string, so pages are
|
|
724
|
-
shareable and indexable — prefer it) or \`"append"\` (a "load more" list). Give each list on a page its own
|
|
725
|
-
\`pageParam\` so two lists page independently. The provider also offers the \`loadMore\` and \`goToPage\` callbacks to
|
|
726
|
-
interaction flows, \`performQuery\` to refetch, and \`cancelQuery\` to drop a request in flight (a STOP).
|
|
727
|
-
|
|
728
|
-
**Writing back** (a form, a "delete" button): declare the endpoint under \`endpoints.write\`, then call the provider's
|
|
729
|
-
**\`writeRecord\`** callback from an interaction flow — nodeType \`callback\`, \`elementId\` the apiContainer's ref,
|
|
730
|
-
params \`action\` (the write endpoint's name) and \`recordId\`. The write goes through the server, which owns the
|
|
731
|
-
credential and refuses any action the manifest does not declare. Writes exist **only** on a server-rendered provider.
|
|
732
|
-
|
|
733
|
-
**Connectors need a server.** A space published without server rendering has nowhere to resolve one: it works in the
|
|
734
|
-
builder and renders empty when published. If the user has no SSR deployment, say so rather than leaving them to
|
|
735
|
-
discover it — the alternative is a browser-side \`query\`, which cannot keep a secret.
|
|
736
|
-
|
|
737
|
-
## Server actions
|
|
738
|
-
Work a page cannot do in the browser — charge a card, send mail, read a system only the server reaches. An action
|
|
739
|
-
is a stored flow the SERVER runs; a page names it and never learns what it does. Write one with
|
|
740
|
-
\`upsertAction\` / \`patchAction\`, then call it from a page flow with the \`runServerAction\` step (mode
|
|
741
|
-
\`await\` to use the result, \`detached\` to fire and carry on).
|
|
742
|
-
|
|
743
|
-
Four rules worth knowing before you write:
|
|
744
|
-
|
|
745
|
-
- **Steps are server tasks.** \`plitzi://actions/{env}/tasks\` lists what this deployment can run — a browser step
|
|
746
|
-
(\`setState\`, \`navigate\`) has nothing to act on here, and the reverse is true too: a task cannot run in a page
|
|
747
|
-
flow.
|
|
748
|
-
- **The contracts.** \`input\` is coerced and anything undeclared is DROPPED. The OUTPUT is whatever the final
|
|
749
|
-
\`flow.output\` step names — there is no separate list to keep in step with it — and that step must be LAST,
|
|
750
|
-
since only the last one that runs is answered. Everything else a step produced stays on the server.
|
|
751
|
-
- **Whether it runs lives on its TRIGGERS.** Each trigger step carries \`enabled\`, and the action is on when any
|
|
752
|
-
way into it is — there is no switch beside the flow. So "pause this action" means disabling its trigger step(s),
|
|
753
|
-
never deleting them.
|
|
754
|
-
- **A step names the credential it uses**, and sees no other. \`credentials\` on the document says which ones the
|
|
755
|
-
action may ask for at all; the secret itself is never yours to see, exactly as with a connector.
|
|
756
|
-
|
|
757
|
-
\`deleteAction { ref }\` removes one; every \`runServerAction\` step that names it stops resolving, so confirm first.
|
|
758
|
-
|
|
759
|
-
## Functions
|
|
760
|
-
When no server task does what a flow needs — parse a feed, call an API with its own shape, compute something — the
|
|
761
|
-
space can have its own: **functions**, TypeScript the platform builds and runs in a sandbox. Their tasks are steps like
|
|
762
|
-
any other (\`<namespace>.<action>\`), listed in \`plitzi://actions/{env}/tasks\` once saved.
|
|
763
|
-
|
|
764
|
-
- **Write** files with \`upsertFunctionFile { path, content }\` (whole files; \`deleteFunctionFile { path }\` removes
|
|
765
|
-
one). \`index.ts\` default-exports the definition:
|
|
766
|
-
\`export default defineFunctions({ allow: { hosts: ["api.example.com"] }, tasks: [{ namespace, action, title, params, run: async (params, ctx) => … }] })\`,
|
|
767
|
-
\`defineFunctions\` from \`@plitzi/sdk-server/functions\`. Files import each other by relative path — no package,
|
|
768
|
-
no Node built-in.
|
|
769
|
-
- **\`ctx\` is all a function reaches:** \`ctx.kv\` (the space's store), \`ctx.fetch(url, init)\` to the hosts
|
|
770
|
-
\`allow.hosts\` names (\`*.example.com\` for subdomains), \`ctx.publish/grant/revoke\` (channels),
|
|
771
|
-
\`ctx.data("products.json")\` (one file of the space's data, parsed — never imported), \`ctx.log\`, \`ctx.user\` (who
|
|
772
|
-
asked, never their session). A secret is NAMED, never read: \`ctx.fetch(url, { credential: "stripe",
|
|
773
|
-
headers: { authorization: "Bearer {{ credential.apiKey }}" } })\`. \`signal\` in the init cuts a slow request short
|
|
774
|
-
(\`AbortSignal.timeout(12000)\`).
|
|
775
|
-
- **Refuse with \`ActionRefusal\`** (from \`@plitzi/sdk-server/functions\`): its message is written for whoever asked and
|
|
776
|
-
reaches them (\`{{ step.error }}\`, a route's \`400 { error }\`); anything else thrown stays in the run's record.
|
|
777
|
-
\`new ActionRefusal(message, { code })\` names it for code that catches it — compare \`error.code\`, never the message.
|
|
778
|
-
- **An API on behalf of a visitor** (their calendar, their music) is an OAuth connection declared as data:
|
|
779
|
-
\`defineFunctions({ oauth: { calendar: { issuer, credential, scopes } } })\` — \`issuer\` for OpenID, or
|
|
780
|
-
\`authorizeUrl\`/\`tokenUrl\`; the credential holds the app's \`clientId\`/\`clientSecret\`. A route redirects to
|
|
781
|
-
\`(await ctx.oauth.connect("calendar", { returnTo: "/settings" })).url\` (\`authorizeParams\` adds to that one consent:
|
|
782
|
-
\`{ prompt: "select_account" }\`), and \`ctx.oauth.fetch("calendar", url)\` calls the API with the token written in;
|
|
783
|
-
\`status\`, \`disconnect\` beside them. The platform keeps the token sealed and renews it — never put one in \`kv\`. The
|
|
784
|
-
user registers \`/fn/oauth/callback\` on the space's host with the provider (\`ctx.oauth.callbackUrl()\` says the
|
|
785
|
-
exact address, for a page that shows it). Not connected yet is a refusal with
|
|
786
|
-
\`code: "oauth-not-connected"\`. \`token\` hands the access token only to a connection declaring \`exposeToken: true\`.
|
|
787
|
-
- **Stateless:** nothing a function keeps in memory outlives the call — a module-level cache or counter starts empty
|
|
788
|
-
every time, on whichever instance runs it. What must last goes in \`ctx.kv\`. A call gets 100 ms of CPU and 10 s;
|
|
789
|
-
a task that needs more says so — \`limits: { cpuMs: 1000, wallMs: 20000 }\`, or \`defineFunctions({ limits })\` for
|
|
790
|
-
all — up to the plan's ceiling. Asking above it is refused at save, never quietly cut.
|
|
791
|
-
- **Routes** answer HTTP on the space's own host under \`/fn/\`: \`routes: { "GET /boards/:board": (request, ctx) =>
|
|
792
|
-
Response.json(…) }\` answers \`/fn/boards/kanban\` (\`ctx.params.board\`). No page may live under \`/fn\`.
|
|
793
|
-
- **Saving builds and checks** the files: the batch is refused with each problem where it is (file and line). A
|
|
794
|
-
namespace the platform uses (\`kv\`, \`http\`, \`flow\`…) is refused.
|
|
795
|
-
- **Try it** with \`plitzi_try_function { task, params }\` before a page relies on it: the value, the logs, the error.
|
|
796
|
-
The live site runs what the space was last published with, never the draft. Running functions is part of the paid
|
|
797
|
-
plans: on another plan they save, and a run answers why it did not start — tell the user rather than work around it.
|
|
798
|
-
|
|
799
|
-
## Data
|
|
800
|
-
JSON the space's pages read on the server and never serve — a catalog, prices, a menu: what a page needs whole and
|
|
801
|
-
nobody edits element by element.
|
|
802
|
-
|
|
803
|
-
- **Read** it as a provider does: \`apiContainer\` with \`runtime: "server"\` and \`query: "/data/products.json"\` reads
|
|
804
|
-
\`products.json\` of \`plitzi://data/{env}\`, and the page arrives with it. A browser provider reading \`/data/…\` is
|
|
805
|
-
refused — the data is the server's.
|
|
806
|
-
- **Write** it with \`upsertDataFile { path, content }\` (the whole file, as JSON text; \`deleteDataFile { path }\`
|
|
807
|
-
removes one): a path of plain segments ending in \`.json\`. Saved whole, with the batch: a newer copy (somebody saved
|
|
808
|
-
since you read it) refuses it — read it again.
|
|
809
|
-
- **What a provider reads is in the page it renders**: data a page must not carry belongs in a server action, which
|
|
810
|
-
answers only what is shown. The live site reads what the space was last published with, never the draft.
|
|
811
|
-
|
|
812
|
-
## Realtime channels
|
|
813
|
-
Pages that see each other — cursors, presence, a shared board, a game. Three parts, all needed:
|
|
814
|
-
|
|
815
|
-
1. **Declare** the topic pattern with \`patchSettings { channels: { "board:{id}": { access: { mode: "public" }, publish: "server" } } }\`.
|
|
816
|
-
\`publish: "server"\` is for what must be validated and saved first; \`"clients"\` (the default) for what pages send
|
|
817
|
-
directly — add \`presence: true\` for who-is-here.
|
|
818
|
-
2. **Subscribe** with a \`channel\` element whose \`topic\` a pattern matches (\`board:{{ id }}\`, a route param).
|
|
819
|
-
Its descendants bind \`channel_<id>\`: \`connected\`, \`members\`, \`messages\`, \`last\`, \`retained\`; flows use its \`onMessage\`,
|
|
820
|
-
\`onJoin\`, \`onLeave\` triggers (\`from\`, \`user\` and the \`state\` the member announced — \`onJoin\` only for who
|
|
821
|
-
came after this page) and its \`publish\` / \`setPresence\` callbacks.
|
|
822
|
-
3. **Announce from the server**: an action whose last step is the \`realtime.publish\` task — validate, save, then say so.
|
|
823
|
-
|
|
824
|
-
A topic no pattern matches is refused by the server and reported by the linter (\`channel-topic\`).
|
|
825
|
-
|
|
826
|
-
**Private topics** (a room behind a password, a customer's order): declare the pattern \`grant: true\`. The action that
|
|
827
|
-
decides the visitor may be there ends with \`realtime.grant { topic }\` and answers its \`grant\`; the \`channel\`
|
|
828
|
-
element binds \`grant\` to it. Without one the topic is refused however well its name is known (\`channel-grant\`).
|
|
829
|
-
\`realtime.revoke { topic, grant }\` takes one back — or all, naming none — and lets go whoever is on it with it.
|
|
830
|
-
|
|
831
|
-
**State every screen shares** (a dashboard's lists, a board's settings): declare the pattern \`retain: true\` with
|
|
832
|
-
\`publish: "server"\`. The server keeps the latest message of each type it says (\`realtime.publish\`) and hands them to
|
|
833
|
-
every page that joins — and to its \`onMessage\` flows, as if just said; the page binds \`desk.retained.lists\`, with no
|
|
834
|
-
read of its own and no copy in \`state\`. \`data: null\` forgets a type; a topic keeps at most 64 types and 512 KB.
|
|
835
|
-
|
|
836
|
-
**Two writers at once**: read-change-write with \`kv.setIf\` (written only if the value is still the one read — empty
|
|
837
|
-
\`expected\` = only if nothing is there yet), ordered lists with \`list.put\` / \`list.range\`, and put
|
|
838
|
-
\`flow.rateLimit\` first in any public action that writes.
|
|
839
|
-
|
|
840
|
-
## Feature flags
|
|
841
|
-
A flag turns a part of the space on or off without anyone editing it: a feature still being built, a version for
|
|
842
|
-
beta users, the old checkout kept until the new one ships. **Not a visibility** — visibility hides an element that is
|
|
843
|
-
still rendered; a flag decides whether it exists at all.
|
|
844
|
-
|
|
845
|
-
- **Declare** with \`upsertFlag { name, description?, value, rules? }\`. \`value\` is its answer when no rule matches;
|
|
846
|
-
\`rules\` are \`[{ when, value }]\` read top to bottom, the first match deciding. A rule's \`when\` is a rule group over
|
|
847
|
-
\`environment\` (\`main\`, \`development\`, \`staging\`, \`production\`), \`hostname\`, \`routeParams.<name>\`,
|
|
848
|
-
\`queryParams.<name>\` and the visitor: \`user.authenticated\`, \`user.email\`, \`user.username\`, \`user.roles\` (with
|
|
849
|
-
\`contains\`). A group with no rules is skipped, never read as "always". \`deleteFlag { name }\` removes one.
|
|
850
|
-
- **Gate** an element with \`flag\` on \`upsertElement\` / \`patchElement\`: \`"newCheckout"\` exists only while the flag is
|
|
851
|
-
on, \`"!newCheckout"\` only while it is off — put both side by side for a rollout. On \`upsertPage\` a gated-off page
|
|
852
|
-
answers 404. \`null\` on a patch removes the gate. Gated off, it is not rendered and its server data is not
|
|
853
|
-
resolved — but the space's document, gated elements included, still reaches the browser: a flag is not a secret.
|
|
854
|
-
- **Read** it anywhere a source is read: \`{{ flags.newCheckout }}\` in a binding, a \`when\` of a flow step, a computed
|
|
855
|
-
value — and in a server action's steps, where it is resolved on the server.
|
|
856
|
-
|
|
857
|
-
A gate or a read naming a flag the space does not declare is an error (\`flag-undeclared\`, \`flag-unknown\`): an
|
|
858
|
-
undeclared flag is off. A declared flag nothing reads is a warning (\`flag-unused\`) — remove it once the feature
|
|
859
|
-
ships. The draft applies flags at once. Flags are not part of a snapshot: each environment has one set, shared by every
|
|
860
|
-
snapshot it serves — publishing a snapshot sends the draft's with it (and the snapshot keeps a copy, as a fallback), the
|
|
861
|
-
builder's *Publish flags* sends only them, and a rollback keeps them. Above the space, the server rendering it, the SDK embedding it and a tester with the dev tools
|
|
862
|
-
may each override a flag; you only ever write the space's own.
|
|
863
|
-
|
|
864
|
-
## Shared layouts — the chrome a page does NOT contain
|
|
865
|
-
A page's tree is usually **not the whole page**. The header, the sidebar and the footer normally live in a **layout
|
|
866
|
-
container**: a shell several pages are rendered inside, so the navigation is authored once instead of once per page.
|
|
867
|
-
|
|
868
|
-
It is a **root of its own** — a \`layoutContainer\` element that no page owns and that is not in the page list — and
|
|
869
|
-
a page points at it with two attributes:
|
|
870
|
-
- \`layout\` — the shell's ref. This is the whole of "which chrome do I render inside".
|
|
871
|
-
- \`layoutContainer\` — the **slot**: the ref of a container INSIDE that shell where this page's own body is placed.
|
|
872
|
-
|
|
873
|
-
So a page with \`layout: "main-layout"\` renders \`main-layout\`'s whole tree, with its own elements dropped into the
|
|
874
|
-
one container it named. Two pages naming the same shell share every element of it — **editing the shell changes
|
|
875
|
-
every page that uses it**, which is the point and also the thing to say out loud before you touch one.
|
|
876
|
-
|
|
877
|
-
**Reading them.**
|
|
878
|
-
- \`plitzi://schema/{env}/layouts\` lists the shells: \`ref\`, \`label\`, \`usedBy\` (the pages), \`slots\`, \`elementCount\`.
|
|
879
|
-
- Every page in \`plitzi://schema/{env}/pages\` carries \`layout\` and \`layoutSlot\` when it has them.
|
|
880
|
-
- Read a shell exactly like a page: \`plitzi://schema/{env}/pages/{layoutRef}\` for its skeleton,
|
|
881
|
-
\`.../pages/{layoutRef}/styles\` for its classes. \`plitzi_search\` reports a layout's elements with the layout as
|
|
882
|
-
their \`pageRef\`.
|
|
883
|
-
|
|
884
|
-
**Writing them.** Every element/binding/interaction op takes the shell's ref as its \`pageRef\` — there is no separate
|
|
885
|
-
vocabulary:
|
|
886
|
-
\`\`\`json
|
|
887
|
-
{ "type": "upsertElement", "pageRef": "main-layout", "parentRef": "sidebar",
|
|
888
|
-
"element": { "ref": "upgrade-card", "type": "container", "children": [ … ] } }
|
|
889
|
-
\`\`\`
|
|
890
|
-
- \`upsertLayout\` creates a shell (\`ref\`, \`label\`, \`subType\`). Put the chrome in it with \`upsertElement\`, including
|
|
891
|
-
an empty container to serve as the slot.
|
|
892
|
-
- \`upsertPage { layout, layoutContainer }\` attaches a page to it; \`layout: null\` detaches. A \`layoutContainer\` that
|
|
893
|
-
is not an element of that shell is refused — stored, it would render the page's body where nobody sees it.
|
|
894
|
-
- \`deleteLayout\` removes a shell and everything in it, and is **refused while any page still renders inside it**
|
|
895
|
-
(the refusal names them). Destructive: what it deletes is on every page that uses it, so confirm first.
|
|
896
|
-
|
|
897
|
-
**Only some pages?** A block that only some of a layout's pages carry (a newsletter band on two of ten) is not
|
|
898
|
-
chrome: make it a **component** and place it on those pages.
|
|
899
|
-
|
|
900
|
-
**Where does this element belong?** If the user asks for something "on every page" — a nav item, a banner, a footer
|
|
901
|
-
link, an upgrade prompt in the sidebar — it belongs in the LAYOUT, not in the page you happen to have open. Check
|
|
902
|
-
the page's \`layout\` first; if the element you are looking for is not in the page's own tree, it is in the shell.
|
|
903
|
-
|
|
904
|
-
## Components — a subtree written once, placed anywhere
|
|
905
|
-
A **component** is a reusable subtree: a product card, a pricing tier, a testimonial — written once and placed on
|
|
906
|
-
any page as an **instance**. It is part of the space, so it is published, versioned and copied with it. Its tree is
|
|
907
|
-
not inside any page: it is a root of its own, like a layout, and **editing it changes every instance** — say so
|
|
908
|
-
before you touch one.
|
|
909
|
-
|
|
910
|
-
It is not a **snippet**. The builder's *Save as snippet* keeps a copy of a block as a file people drop onto pages, and
|
|
911
|
-
each drop is the page's own from then on. No operation here writes one: when someone wants a block that stays the same
|
|
912
|
-
everywhere, that is a component.
|
|
913
|
-
|
|
914
|
-
It is **closed**. Inside, a binding or a template reads **\`props\`** — what each instance hands in — and the globals
|
|
915
|
-
(\`state\`, \`auth\`, \`navigation\`, \`theme\`, \`variables\`, \`computed\`), never the page an instance sits on. A
|
|
916
|
-
component that needs a list row's record gets it as a prop: the INSTANCE binds it (\`item: "{{ list_rows.item }}"\`),
|
|
917
|
-
the component reads \`{{ props.item.name }}\`.
|
|
918
|
-
|
|
919
|
-
**Reading them.** \`plitzi://schema/{env}/components\` lists them: \`ref\`, \`label\`, \`props\`, \`slots\`, \`rootRef\`,
|
|
920
|
-
\`instances\`. Read one like a page: \`plitzi://schema/{env}/pages/{componentRef}\` (and \`/styles\`).
|
|
921
|
-
|
|
922
|
-
**Writing them.**
|
|
923
|
-
- \`upsertComponent { ref, label?, props?, slots? }\` declares one — with nothing in it but its root, \`{ref}-root\`, a
|
|
924
|
-
container — or updates the declaration of one that exists (\`props\` is REPLACED whole). Fill it with every
|
|
925
|
-
element/binding/interaction op you already know, with **\`pageRef: "<componentRef>"\`**:
|
|
926
|
-
\`\`\`json
|
|
927
|
-
{ "type": "upsertElement", "pageRef": "product-card", "parentRef": "product-card-root",
|
|
928
|
-
"element": { "ref": "product-card-title", "type": "heading" } }
|
|
929
|
-
\`\`\`
|
|
930
|
-
- \`upsertComponent { ref, fromRef, instanceRef }\` makes a component OF an element that already exists: the element
|
|
931
|
-
and everything inside it become the component, and an instance named \`instanceRef\` takes its place, so the page
|
|
932
|
-
renders what it did. The way to turn a repeated block into one.
|
|
933
|
-
- A **prop** is \`{ type, description, required?, default?, options? }\`, \`type\` one of \`text\`, \`textarea\`,
|
|
934
|
-
\`number\`, \`boolean\`, \`select\` (with \`options\`), \`scalar\`, \`json\`. Its name is read as \`{{ props.<name> }}\`, so
|
|
935
|
-
letters, digits and \`_\` — and never one an instance already has (\`referenceId\`, \`referenceType\`, \`slot\`…).
|
|
936
|
-
- A **slot** is an element of the component's tree (usually an empty container) an instance fills with children.
|
|
937
|
-
- \`deleteComponent { ref }\` removes one nothing places; while instances remain it is refused, naming them.
|
|
938
|
-
|
|
939
|
-
**Placing one** is an element: a \`reference\` whose props say which component and hand in its props, one attribute each:
|
|
940
|
-
\`\`\`json
|
|
941
|
-
{ "type": "upsertElement", "pageRef": "shop", "parentRef": "grid",
|
|
942
|
-
"element": { "ref": "lamp-card", "type": "reference",
|
|
943
|
-
"props": { "referenceType": "component", "referenceId": "product-card", "title": "Lamp" },
|
|
944
|
-
"children": [ { "ref": "lamp-buy", "type": "button", "props": { "content": "Buy", "slot": "product-card-actions" } } ] } }
|
|
945
|
-
\`\`\`
|
|
946
|
-
A required prop left out, a prop the component does not declare, a value of the wrong kind or a child naming a slot
|
|
947
|
-
the component does not have is reported by \`plitzi_apply\`'s \`dryRun\` — fix it before applying.
|
|
948
|
-
|
|
949
|
-
## Pages & folders
|
|
950
|
-
- **A page behind a feature flag**: \`upsertPage { flag: "labs" }\` answers 404 while the flag is off (see **Feature
|
|
951
|
-
flags**); \`flag: null\` removes it.
|
|
952
|
-
- **Always set a \`slug\` when creating a page** (\`upsertPage\`) — it is the page's URL path and good practice for a
|
|
953
|
-
clean, stable route (e.g. \`"pricing"\` or \`"posts/:postId"\`). Omit it and the page ref is used as the slug,
|
|
954
|
-
and \`plitzi_apply\` warns so you remember to set a meaningful one.
|
|
955
|
-
- **A page slug is RELATIVE — do NOT start it with \`/\`.** The runtime prepends the leading slash (and any folder
|
|
956
|
-
path) itself, so a leading slash doubles it. Write \`"pricing"\`, not \`"/pricing"\`. (upsertPage strips a leading
|
|
957
|
-
slash for you, but write it relative.)
|
|
958
|
-
- **Dynamic pages — route params.** A slug segment written \`:name\` (e.g. \`"posts/:postId"\`) is a **route param**,
|
|
959
|
-
exactly like React Router. On that page it is readable **two ways**: as \`{{name}}\` inside a prop, and as the
|
|
960
|
-
data-binding source **\`navigation.routeParams.name\`** (the \`navigation\` module source, global — bindable
|
|
961
|
-
anywhere). So a blog is a \`"posts"\` list page plus a \`"posts/:postId"\` detail page whose \`apiContainer\` query
|
|
962
|
-
binds \`navigation.routeParams.postId\` to fetch that one post. (\`navigation.queryParams.<name>\` exposes \`?query=\`
|
|
963
|
-
string params the same way.)
|
|
964
|
-
- **Navigate with the \`Link\` element, not an interaction.** \`link\` is a **container** — it wraps any children and
|
|
965
|
-
navigates on click, so it is the default way to move between pages. Its \`mode\`: \`"page"\` links to another space
|
|
966
|
-
page (set \`href\` to the target page, folder path resolved for you); \`"internal"\` takes a path inside the space and
|
|
967
|
-
resolves \`{{token}}\` templates in it, so a row's "view" link is \`mode:"internal", href:"posts/{{postId}}"\`;
|
|
968
|
-
\`"external"\` is a full URL. \`target\` is \`self\`/\`blank\`/\`parent\`/\`top\`. Reach for the \`navigate\` globalCallback
|
|
969
|
-
only when navigation must be **one step inside a larger interaction flow** (e.g. save, then go) — for a plain link,
|
|
970
|
-
use \`link\`.
|
|
971
|
-
- **A link's words are its \`content\`, and an icon beside them its \`icon\`** — \`{ "type": "link", "props": { "mode":
|
|
972
|
-
"page", "href": "pricing", "content": "Pricing", "icon": "fa-solid fa-arrow-right", "iconPlacement": "after" } }\`
|
|
973
|
-
(a \`button\` takes the same two). The icon's class goes in the element's \`icon\` slot (\`style.slots.icon\`). With
|
|
974
|
-
children too, \`contentPlacement\` puts the words \`before\` or \`after\` them. A \`text\` or \`fontAwesome\` inside is
|
|
975
|
-
one element more, and a text keeps a colour of its own instead of the link's (and its hover).
|
|
976
|
-
- **The link to the page being shown marks itself**: it carries \`aria-current="page"\`, and its class's \`current\`
|
|
977
|
-
state says how it looks — \`{ "type": "patchDefinition", "ref": "nav-link", "states": { "current": { "desktop": {
|
|
978
|
-
"color": "var(--primary)" } } } }\`. So a header written once in a layout lights the right item on every page; never
|
|
979
|
-
copy the header per page to style one item. A link for a section — a journal and its articles — takes
|
|
980
|
-
\`"current": "section"\` in its props: current on every page under its path too (\`aria-current="true"\`), the same
|
|
981
|
-
state dressing it. The same state dresses any chosen one of a set: a pressed toggle (\`aria-pressed\` — a theme
|
|
982
|
-
toggle's option slot) and a selected tab.
|
|
983
|
-
- **A section of a page** is an element with an \`anchor\` (its \`id\` in the DOM: lowercase, digits, \`-\`; one per
|
|
984
|
-
page, layouts included; not inside a list row or a component). A link lands on it with \`hash\`:
|
|
985
|
-
\`{ "mode": "page", "href": "home", "hash": "plans" }\` goes to \`/#plans\` and scrolls there, from any page.
|
|
986
|
-
|
|
987
|
-
Pages can be grouped into **folders** (the sidebar tree). A folder is \`{ ref, name, slug, parentId? }\`; its \`ref\`
|
|
988
|
-
**is its id**, and that id is what a page and a nested folder reference.
|
|
989
|
-
- **Folder slugs PREPEND to the page URL — this is how nested URLs are built.** The full path is each ancestor
|
|
990
|
-
folder's slug plus the page slug, joined by \`/\`: a page at slug \`"1-1-1"\` inside \`folder-1\` > \`folder-1-1\`
|
|
991
|
-
resolves to \`/folder-1/folder-1-1/1-1-1\`. So a folder slug is part of the route; keep folder slugs relative too.
|
|
992
|
-
- Create/rename/move a folder with \`upsertFolder\` (the \`ref\` you pass on create becomes its id — pick a stable one
|
|
993
|
-
like \`"blog"\`). Nest it under another with \`parentId\` (a folder ref); \`parentId: null\` moves it back to the root.
|
|
994
|
-
- Put a page in a folder with \`upsertPage\`'s \`folder\` (a folder ref). A page's \`folder\` is always either **empty
|
|
995
|
-
(root)** or an **existing folder id**: \`folder: null\` or \`folder: ""\` moves it to the root, and any other value
|
|
996
|
-
must resolve to a folder that already exists or is created earlier in the same batch — an unknown folder is
|
|
997
|
-
rejected, never stored.
|
|
998
|
-
- \`deleteFolder\` removes a folder and **promotes its contents up one level** — its child folders and its pages move
|
|
999
|
-
to its parent (or the root). A folder cannot be nested under itself or one of its descendants.
|
|
1000
|
-
- **Disable a page** with \`upsertPage\`'s \`enabled: false\`; \`enabled: true\` re-enables it (defaults to enabled, and
|
|
1001
|
-
a page read reports its current \`enabled\`). Disabling only affects the **published SDK runtime** — the page stops
|
|
1002
|
-
being routable/accessible to end users. It stays fully **editable here**: you can still read it and apply any op to
|
|
1003
|
-
a disabled page. This does not delete it — \`deletePage\` does.
|
|
1004
|
-
- **A page that fills the window** (a dashboard, a board) takes \`upsertPage\`'s \`documentScroll: "locked"\`: the
|
|
1005
|
-
document holds still and only parts with \`overflow: auto\` scroll, so a finger on a tablet no longer drags and
|
|
1006
|
-
bounces the page. \`"noBounce"\` keeps the scroll without the rubber band; \`null\` undoes either. Never an
|
|
1007
|
-
\`html, body\` rule in \`customCss\`: that holds every page, and the site the space is a widget on.
|
|
1008
|
-
|
|
1009
|
-
## Settings
|
|
1010
|
-
Space-level configuration lives in \`plitzi://settings/{env}\` and is edited with a single **\`patchSettings\`** op
|
|
1011
|
-
(merge — only the fields you pass change):
|
|
1012
|
-
- \`customCss\` — **raw global CSS** injected for the whole space. Use it only for genuinely site-wide rules
|
|
1013
|
-
(\`@keyframes\`, \`@font-face\`, resets). To style an element, write a **definition** and attach it — never customCss.
|
|
1014
|
-
- \`notifications\` — how the toasts an \`addNotification\` step shows look: colours (\`background\`, \`text\`,
|
|
1015
|
-
\`success\`, \`danger\`, \`warning\`, \`info\`), shape (\`radius\`, \`font\`, \`fontSize\`, \`fontWeight\`, \`lineHeight\`,
|
|
1016
|
-
\`minHeight\`, \`border\`, \`shadow\`, \`padding\`) and the parts inside (\`iconSize\`, \`iconGap\`, \`closeColor\`,
|
|
1017
|
-
\`closeOpacity\`, \`progressHeight\`), one CSS value each — a token follows the theme: \`{ "type": "patchSettings",
|
|
1018
|
-
"notifications": { "background": "var(--card)", "iconSize": "18px" } }\`. Merged field by field, \`null\` removes one.
|
|
1019
|
-
It is stored as rules inside \`customCss\` but reads and changes apart from it: never write a \`.Toastify__*\` rule
|
|
1020
|
-
yourself.
|
|
1021
|
-
- \`keepState\` / \`stateStorage\` — keep the runtime state (\`state.<key>\`, what \`setState\` writes) across reloads,
|
|
1022
|
-
in \`localStorage\`/\`sessionStorage\`, filed under whoever is signed in. It is the space's setting — pages do not
|
|
1023
|
-
take one. \`transientState\` lists the top-level keys never kept (a filter, a demo, a panel left open); do not
|
|
1024
|
-
reset kept state from \`onPageLoad\` instead — it is restored later than that and undoes half of the reset.
|
|
1025
|
-
\`paintedState\` lists the kept keys the FIRST PAINT shows (the tool a toolbar shows, a name in an avatar): they go
|
|
1026
|
-
in a cookie too, so the server draws with them instead of the page swapping them in after load. Small values only.
|
|
1027
|
-
- **User provider / auth**: \`userProvider\` — \`basic\` for any HTTP+JSON backend, the name of a provider registered
|
|
1028
|
-
in the page, or \`""\` for none — plus \`tokenStorage\`, the \`loginUrl\`/\`userUrl\`/\`refreshUrl\`/\`logoutUrl\`
|
|
1029
|
-
endpoints and the \`detailsPath\`/\`tokenPath\`/\`refreshTokenPath\`/\`expirationTimePath\` mapping that says where the
|
|
1030
|
-
values sit in their responses. \`sessionHintCookie\` is worth setting whenever the backend can: it names a readable
|
|
1031
|
-
cookie carrying only expiries, which is what lets a page answer "nobody is signed in" without a request.
|
|
1032
|
-
A space served by a self-hosted \`createServer({ auth })\` declares none of these: that server tells its pages where
|
|
1033
|
-
they sign in, and only what the space declares overrides it.
|
|
1034
|
-
On the Plitzi platform, \`userProvider: "server"\` signs visitors in with their Plitzi account on the space's own
|
|
1035
|
-
host: a \`link\` with \`mode: "external"\` to \`/auth/sign-in?return=/\` starts it, \`authLogout\` ends it.
|
|
1036
|
-
- \`visitorRoles\` — what each visitor role gives, \`{ "author": ["postPublish"] }\`: the permissions an action's
|
|
1037
|
-
\`access: { mode: "role" }\` and a page's \`can()\` ask for. A visitor holds ONLY the permissions of their roles here,
|
|
1038
|
-
never their account's. Who holds a role is given by email in the builder's Settings → Visitors — never in the
|
|
1039
|
-
space's \`settings\`.
|
|
1040
|
-
- \`channels\` — the realtime channels, by topic pattern (see **Realtime channels**). Merged pattern by pattern;
|
|
1041
|
-
\`null\` removes one.
|
|
1042
|
-
Example — inject a keyframe globally:
|
|
1043
|
-
\`{ "type": "patchSettings", "customCss": "@keyframes spin { to { transform: rotate(360deg); } }" }\`.
|
|
1044
|
-
|
|
1045
|
-
## Motion — good practices
|
|
1046
|
-
A preset first: an element's \`motion\` field (\`upsertElement\`/\`patchElement\`) —
|
|
1047
|
-
\`{ "enter": "fade-up", "on": "view" }\`, \`"stagger": 60\` for its children one by one, \`"loop": "float"\` — is
|
|
1048
|
-
played by the SDK, cheap and stilled for reduced motion. \`on\`: \`load\` (default), \`view\` (once, the first time it
|
|
1049
|
-
comes into view, then it stays) or \`scroll\` (follows the scroll both ways — it fades back out as the reader scrolls
|
|
1050
|
-
up past it; only for an effect that is about the scroll itself). Enters: ${MOTION_ENTERS.join(", ")}; loops:
|
|
1051
|
-
${MOTION_LOOPS.join(", ")}. Beyond them, keyframes go in \`customCss\` (\`patchSettings\`), a
|
|
1052
|
-
definition names them (\`animation\`). Only \`opacity\` and
|
|
1053
|
-
\`transform\` (\`translate\`, \`scale\`, \`rotate\`) animate off the main thread: they stay smooth while the page
|
|
1054
|
-
hydrates and on a slow phone. Anything else repaints or lays the page out again on every frame, and freezes while the
|
|
1055
|
-
page's scripts run.
|
|
1056
|
-
- Slide, grow, fade with \`transform\` and \`opacity\` — never \`left\`, \`top\`, \`width\`, \`height\` or
|
|
1057
|
-
\`margin\`. Something travelling across a box is \`transform: translate(%)\` on an element as large as the box.
|
|
1058
|
-
- No animated blur: no \`filter: blur()\` in an entrance or a loop, no \`backdrop-filter\` over moving content. A soft
|
|
1059
|
-
shape is a \`radial-gradient\` fading to transparent.
|
|
1060
|
-
- Fake the expensive ones: a growing shadow is a second shadow on a pseudo-element whose \`opacity\` changes; a
|
|
1061
|
-
pulsing glow is a static gradient whose \`opacity\` or \`scale\` changes.
|
|
1062
|
-
- Decoration that must animate something else (a custom property, \`background-position\`) starts paused and runs
|
|
1063
|
-
once the page is hydrated: \`.glow { animation: glow 8s linear infinite paused; } [data-hydrated] .glow {
|
|
1064
|
-
animation-play-state: running; }\` in \`customCss\`. That is for loops: an entrance of its own that plays once
|
|
1065
|
-
(\`transform\`/\`opacity\` only) plays from the first paint with \`backwards\`, never gated on \`[data-hydrated]\`.
|
|
1066
|
-
- Entrances: \`opacity\` + a small \`translateY\`, under ~600ms, staggered by tens of ms.
|
|
1067
|
-
- One slow ambient loop per screen at most — not one per card: \`infinite\` runs on every visitor's battery.
|
|
1068
|
-
- Name what transitions (\`transition: transform 200ms, opacity 200ms\`), never \`all\`; \`will-change\` only on the
|
|
1069
|
-
few elements about to move.
|
|
1070
|
-
- Reduced motion is the SDK's: it cuts every animation to an instant for whoever asks — never write that reset.
|
|
1071
|
-
|
|
1072
|
-
## Accessibility — pages people, screen readers and browser agents can all use
|
|
1073
|
-
A page is read three ways: seen, heard through a screen reader, and worked by a **browser agent** (Claude in Chrome)
|
|
1074
|
-
— which finds the controls it can press in the same **accessibility tree** a screen reader walks. A control that
|
|
1075
|
-
tree names nothing is invisible to both, however it looks. So build every page to be operable without sight:
|
|
1076
|
-
- **Every control has words.** A \`button\` is named by its \`content\` and the words inside it; an icon-only one needs a
|
|
1077
|
-
\`title\` (also its tooltip), and one whose words do not say what it does (a key hint, a count) a \`label\`. A \`link\` is named by what it holds, or \`label\` (set it on a link wrapping a whole card).
|
|
1078
|
-
A \`formControl\` is named by its \`label\` — keep it and set \`hideLabel: true\` when the design shows what the field
|
|
1079
|
-
is (a swatch, a search box); a \`placeholder\` names only a field typed into, and only until something is typed.
|
|
1080
|
-
- **Every picture says what it shows** (\`alt\`), or is marked \`decorative: true\` when the words beside it already say
|
|
1081
|
-
it. A \`fontAwesome\` icon is decoration (hidden) unless its \`label\` gives it a meaning of its own.
|
|
1082
|
-
- **Only controls are clicked.** A click flow belongs on a \`button\` (it holds children — a whole card can be one) or
|
|
1083
|
-
a \`link\` when it goes somewhere — never on a \`container\`, \`text\` or \`image\`: a keyboard cannot reach those and
|
|
1084
|
-
no agent finds them. An empty backdrop that closes a panel is the exception (the panel's close button and Escape
|
|
1085
|
-
are the ways everyone has).
|
|
1086
|
-
- **State is said, not only styled.** A toggle sets \`ariaPressed\`, a button that opens a panel \`ariaExpanded\`
|
|
1087
|
-
(bind them like any attribute) — an "active" class alone is invisible to both readers. A button that shows and
|
|
1088
|
-
hides a panel names it in \`controls\` (\`aria-controls\`, the panel's anchor), and words that change while a
|
|
1089
|
-
visitor reads them — a count, a total, a status — sit in a \`container\` with \`live: "polite"\` (\`aria-live\`).
|
|
1090
|
-
- **A dropdown opens from a \`button\`** among its children, outside the popup (an avatar, a "⋯": the button holds it and
|
|
1091
|
-
has a \`title\`). The dropdown marks it and moves the focus in and out; a box or an icon alone opens nothing from a
|
|
1092
|
-
keyboard.
|
|
1093
|
-
- **An illustration** built from elements (a mock of a page, art) is a \`container\` with \`decorative: true\`: both
|
|
1094
|
-
readers skip it. Keep controls out of it.
|
|
1095
|
-
- **The page has an outline.** Headings go down one level at a time (h1 → h2 → h3; size them with their class, not
|
|
1096
|
-
their level). Landmarks are containers with a tag — \`header\`, \`nav\`, \`main\`, \`aside\`, \`footer\` — and a
|
|
1097
|
-
\`label\` when a page has two of one kind; a \`section\` with a \`label\` is a region an assistant can jump to.
|
|
1098
|
-
- **What comes built in:** modals and dialogs are \`dialog\`s named by their title, take the focus, keep Tab inside
|
|
1099
|
-
and close on Escape; tabs are a tab list worked with the arrow keys; a field that breaks a rule is marked invalid and
|
|
1100
|
-
described by its message; the pager marks the current page. Nothing to add for those.
|
|
1101
|
-
- **A canvas is a picture** to both readers. A plugin that draws (a chart, a board, a map) also renders what it shows
|
|
1102
|
-
as real elements — a list, a table — with a button for every action; one hidden until focused cannot be clicked by an
|
|
1103
|
-
agent that clicks by position, so offer a visible "list view".
|
|
1104
|
-
The linter warns about these (\`control-without-name\`, \`image-without-alt\`, \`click-on-static-element\`,
|
|
1105
|
-
\`dropdown-without-control\`, \`heading-level-skipped\`, \`label-ignored\`, \`control-in-decorative\`) on every element
|
|
1106
|
-
you touch; fix them in the same batch. Then look:
|
|
1107
|
-
\`plitzi_look\` shows the page as those readers get it, and lists what has no name.
|
|
1108
|
-
|
|
1109
|
-
## Semantics
|
|
1110
|
-
- **props are fully replaced** on \`upsertElement\`: send every prop you want to keep. To change only some props,
|
|
1111
|
-
use **\`patchElement\`** — it merges \`props\`/\`style\` onto the existing element (listed keys change, \`null\` unsets
|
|
1112
|
-
a key, everything else is preserved) and never creates. Combined with \`plitzi_search\` (which returns the ref +
|
|
1113
|
-
stateVersion), a targeted edit is two calls with no read.
|
|
1114
|
-
- **definition CSS is fully replaced** on \`upsertDefinition\`: send every property you want to keep. To change only
|
|
1115
|
-
some declarations, use **\`patchDefinition\`** — it merges CSS per breakpoint/state/variant/slot onto the existing
|
|
1116
|
-
definition (listed keys change, \`null\` removes a property, everything else is preserved) and never creates.
|
|
1117
|
-
Example — recolor one definition without resending it: \`{ "type": "patchDefinition", "ref": "btn-x",
|
|
1118
|
-
"desktop": { "background-color": "#111" } }\`.
|
|
1119
|
-
- **Atomic batches**: if any operation fails, \`plitzi_apply\` persists nothing.
|
|
1120
|
-
- **Every element you touch must be malformation-free — pre-existing errors block the save.** When your batch edits
|
|
1121
|
-
an element, the result is read by the same linter every writer of a space is held to, and the element's **current
|
|
1122
|
-
stored content** with it — a broken transformer action, a malformed step, an attribute it never reads — even in
|
|
1123
|
-
parts your edit does not touch. Such a finding is reported as a \`Pre-existing malformation in element …\` **error**, and
|
|
1124
|
-
\`plitzi_apply\` rejects the batch until it is fixed. These are **not caused by your change** (the message says so)
|
|
1125
|
-
— do not be confused; fix them **in the same batch** and re-apply. Because the check runs on the resulting state,
|
|
1126
|
-
including the fix in your batch is exactly what unblocks the save. (Advisory issues — an unobserved source/action
|
|
1127
|
-
name that may still be a valid plugin, a binding target a plugin manifest does not list — come back as
|
|
1128
|
-
\`Pre-existing issue …\` **warnings** and do not block.) Elements you do not touch are not held against you — except
|
|
1129
|
-
that a broken tree your batch leaves anywhere (an element orphaned by a delete) is refused.
|
|
1130
|
-
- **Optimistic concurrency — read before you write, and prove your read is current.** Editing a resource means you
|
|
1131
|
-
read it first, so you hold its \`stateVersion\`. **Always pass \`expectedResourceVersions\`** (URI → the stateVersion
|
|
1132
|
-
you read) for every resource your batch changes. If another agent edited it in the meantime, the live version no
|
|
1133
|
-
longer matches and apply is **rejected with a conflict** — nothing persists. Then re-read the reported resources
|
|
1134
|
-
(their new content + version) and retry on top of the fresh state. This is exactly how a file editor forces a
|
|
1135
|
-
re-read after a stale write: it is what keeps concurrent agents from silently overwriting each other's changes, so
|
|
1136
|
-
never omit it "to save a call".
|
|
1137
|
-
`;
|
|
1138
|
-
//#endregion
|
|
1139
|
-
export { guideQuickstart, guideText, serverInstructions, widgetsOnlyInstructions };
|