@plitzi/sdk-mcp 0.39.10 → 0.39.12
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 +30 -0
- package/dist/createServer.js +6 -0
- package/dist/modules/mcp/helpers/guide/instructions.js +6 -1
- package/dist/modules/mcp/helpers/guide/reference.d.ts +1 -1
- package/dist/modules/mcp/helpers/guide/reference.js +1 -1
- package/dist/modules/mcp/helpers/guide/server.d.ts +1 -1
- package/dist/modules/mcp/helpers/guide/server.js +3 -0
- package/dist/modules/mcp/server.js +1 -1
- package/dist/modules/mcp/tools/apply/index.d.ts +4 -0
- package/dist/modules/mcp/tools/operations/index.d.ts +16 -0
- package/dist/modules/mcp/tools/operations/schema/flags/upsertFlag.d.ts +4 -0
- package/dist/modules/mcp/tools/operations/schema/flags/upsertFlag.js +7 -2
- package/dist/modules/mcp/tools/operations/schema/operations.d.ts +4 -0
- package/dist/modules/mcp/tools/render.d.ts +4 -0
- package/dist/modules/mcp/tools/renderWidget.d.ts +4 -0
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @plitzi/sdk-mcp
|
|
2
2
|
|
|
3
|
+
## 0.39.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2f5b44d: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
8
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
9
|
+
- Updated dependencies [2f5b44d]
|
|
10
|
+
- @plitzi/plitzi-sdk@0.39.12
|
|
11
|
+
- @plitzi/sdk-server@0.39.12
|
|
12
|
+
- @plitzi/sdk-authoring@0.39.12
|
|
13
|
+
- @plitzi/sdk-kernel@0.39.12
|
|
14
|
+
- @plitzi/sdk-schema@0.39.12
|
|
15
|
+
- @plitzi/sdk-shared@0.39.12
|
|
16
|
+
- @plitzi/sdk-style@0.39.12
|
|
17
|
+
|
|
18
|
+
## 0.39.11
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- d0b5be6: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
23
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
24
|
+
- Updated dependencies [d0b5be6]
|
|
25
|
+
- @plitzi/plitzi-sdk@0.39.11
|
|
26
|
+
- @plitzi/sdk-server@0.39.11
|
|
27
|
+
- @plitzi/sdk-authoring@0.39.11
|
|
28
|
+
- @plitzi/sdk-kernel@0.39.11
|
|
29
|
+
- @plitzi/sdk-schema@0.39.11
|
|
30
|
+
- @plitzi/sdk-shared@0.39.11
|
|
31
|
+
- @plitzi/sdk-style@0.39.11
|
|
32
|
+
|
|
3
33
|
## 0.39.10
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/dist/createServer.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { buildMCPPipeline } from "./pipeline.js";
|
|
2
2
|
import { createHttpServer, makeHandler } from "@plitzi/sdk-kernel/http";
|
|
3
|
+
import { configureServerLog, defaultLogLevel } from "@plitzi/sdk-kernel/log";
|
|
3
4
|
// src/createServer.ts
|
|
4
5
|
/** The server this package makes: the lean MCP pipeline over the bare context — no render template, caches
|
|
5
6
|
* or plugin manager. `config` is the HTTP server's (port, TLS, health, logger, adapters); `options` is what MCP
|
|
@@ -10,6 +11,11 @@ import { createHttpServer, makeHandler } from "@plitzi/sdk-kernel/http";
|
|
|
10
11
|
* It owns its whole sub-domain, answering JSON-RPC on every path rather than under /mcp. To serve MCP alongside
|
|
11
12
|
* pages on one port instead, hand `mcpExtensions(options)` to createServer from `@plitzi/sdk-server`. */
|
|
12
13
|
var createServer = (config, options = {}) => {
|
|
14
|
+
configureServerLog({
|
|
15
|
+
level: config.logLevel ?? defaultLogLevel(config.devMode),
|
|
16
|
+
...config.logger ? { logger: config.logger } : {},
|
|
17
|
+
...config.slowRunMs === void 0 ? {} : { slowRunMs: config.slowRunMs }
|
|
18
|
+
});
|
|
13
19
|
const stages = buildMCPPipeline(options);
|
|
14
20
|
const makeHandlerForPort = (port) => {
|
|
15
21
|
const buildContext = (raw, rawRes, req, res) => ({
|
|
@@ -80,7 +80,12 @@ element** (\`mode\` "page"/"internal"/"external"; its words are its \`content\`,
|
|
|
80
80
|
a \`navigate\` interaction.
|
|
81
81
|
|
|
82
82
|
**Feature flags:** what a person switches on (a beta, a rollout) is \`upsertFlag\` plus \`flag: "x"\` / \`"!x"\` on the
|
|
83
|
-
element or page — not \`visible\`. Read anywhere as \`{{ flags.x }}\`.
|
|
83
|
+
element or page — not \`visible\`. Read anywhere as \`{{ flags.x }}\`. A \`variants\` shows each visitor one of its
|
|
84
|
+
\`variantItem\`s: by chance (an A/B test, 2–5 variants, each \`weight\` its share; each visitor keeps theirs, read as
|
|
85
|
+
\`{{ experiments.<experiment> }}\` — \`'a'\`, \`'b'\`…, its id when unnamed; a \`reachGoal\` step counts a conversion) or, with
|
|
86
|
+
\`chooseBy: 'rules'\`, the first whose \`when\` (a flag's rule fields, plus \`visitor.returning\`/\`language\`/\`device\`)
|
|
87
|
+
matches; end those with one without \`when\`. A \`timeWindow\` shows its children only between \`startsAt\` and \`endsAt\`
|
|
88
|
+
(ISO 8601 with the offset).
|
|
84
89
|
|
|
85
90
|
**Accessible by default:** screen readers and browser agents (Claude in Chrome) read the accessibility tree, so every
|
|
86
91
|
button/link needs words (an icon-only button a \`title\`), every field a \`label\` (\`hideLabel: true\` hides it), every
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The guide's start: what to read, the tools, and how an element is addressed, made, moved and deleted. */
|
|
2
|
-
export declare const referenceGuide = "# Plitzi AI MCP \u2014 usage guide\n\nA Plitzi space is **two separate schemas** you edit together:\n- **Element schema** \u2014 the tree of pages and elements (their type, label, props, and which style classes they use).\n- **Style schema** \u2014 reusable **definitions** (CSS classes), design tokens (variables), theme.\n\nThey are stored and persisted independently, but a single `plitzi_apply` batch may touch **both atomically**.\nTo style a specific element you do two things in one batch: write a **definition** (style schema) and **attach**\nit via the element's `style.base` (element schema). Example \u2014 \"rename button X to PEPE and make it red\":\n```json\n{ \"operations\": [\n { \"type\": \"upsertDefinition\", \"ref\": \"btn-x\", \"desktop\": { \"color\": \"red\" } },\n { \"type\": \"upsertElement\", \"pageRef\": \"home\",\n \"element\": { \"ref\": \"X\", \"type\": \"button\", \"label\": \"PEPE\", \"style\": { \"base\": [\"btn-x\"] } } }\n] }\n```\n\nReads are cheap by design \u2014 treat them like a filesystem: **list** to navigate, **read one item** for detail.\nNever download a whole tree you do not need.\n\n## Resources (read)\n- `plitzi://primer/{env}` \u2014 **cold-start bundle**: guide + types + css-properties + page/definition/variable\n **summaries** in one read. Fetch this first instead of the individual resources below. Summaries only \u2014 open a\n page skeleton or element for its tree/detail.\n- `plitzi://guide` \u2014 this guide.\n- `plitzi://types` \u2014 element types **observed in this space** (ground truth): props, slots, subTypes, plus each\n type's `label`, `description` (what it is FOR) and `category`, and a `source` (`builtin` | `plugin` | `unknown`).\n Read the descriptions to pick the right type \u2014 e.g. `apiContainer` fetches backend data into the frontend,\n `link` navigates between pages, `list` repeats a template over a data array. `plugin` types are the elements\n of the plugins the space installed: added by their type, like a built-in.\n- `plitzi://css-properties` \u2014 valid kebab-case CSS property keys.\n- `plitzi://explain/{name}` \u2014 what a name means: an element type's attributes, triggers, callbacks and what it writes\n on its node; a step's params and what it publishes; what a trigger hands its flow; a style state; a problem code's\n fix. `plitzi://explain/steps` (or elements, triggers, codes, transformers, states) lists every one of a kind.\n- `plitzi://schema/{env}/pages` \u2014 page **summaries** (ref, label, elementCount, folder). No element trees.\n- `plitzi://schema/{env}/layouts` \u2014 the shared **layout shells** (header/sidebar/footer) and the pages rendered\n inside each. Read one like a page. See *Shared layouts* below.\n- `plitzi://schema/{env}/components` \u2014 the space's **components** (reusable subtrees): their props, slots, root and\n how many places render each. Read one like a page. See *Components* below.\n- `plitzi://folders/{env}` \u2014 page **folders** (the sidebar tree): ref, name, slug, parentId. `/{ref}` for one.\n- `plitzi://schema/{env}/pages/{ref}` \u2014 one page as a **skeleton tree**: each node is `ref/type/label` **plus the\n style classes it attaches** (`base`, and `slots` for non-base slots) \u2014 names only, no CSS. So you can map every\n element to its class in a single page read, without opening each element just to learn which class it uses.\n- `plitzi://schema/{env}/pages/{ref}/styles` \u2014 **every style the page uses in one read**: the class definitions its\n elements attach (deduplicated, **with full CSS**) plus the global styles affecting any element type on the page.\n Reach for this to recolor/restyle a whole page \u2014 it needs no shared class-name prefix and no per-element reads.\n- `plitzi://schema/{env}/elements/{ref}` \u2014 one element in **full detail** (props, style, parentRef, childRefs).\n Its `resolvedStyle` inlines the **CSS of every definition** the element attaches (keyed by class ref), so you\n can see and edit its style without a separate definition read. Its `globalStyles` lists the **global element\n selectors** that also affect it (the CSS equivalent of `button { \u2026 }`, keyed by the type they target) \u2014 every\n element of that type inherits them. Edit a global only through the global-style tools (never per element). If the\n element carries a DOM `id` that an id rule matches, its `idStyle` (`#id`) is inlined too.\n- `plitzi://definitions/{env}` \u2014 the **names** of every style definition.\n- `plitzi://definitions/{env}/{ref}` \u2014 one definition's CSS.\n- `plitzi://global-styles/{env}` \u2014 element **types** that have a site-wide global style. `/{componentType}` for one.\n- `plitzi://id-styles/{env}` \u2014 DOM **ids** that have an id rule (`#id`) targeting a single element. `/{targetId}` for one.\n- `plitzi://style-variables/{env}` \u2014 design tokens by category. `/{category}` for one.\n- `plitzi://fonts/{env}` \u2014 the font **families the space loads**, with their source and fallback. `/{family}` for one.\n- `plitzi://schema-variables/{env}` \u2014 space-level values referenced in props as `{{name}}`.\n- `plitzi://flags/{env}` \u2014 the space's **feature flags**, each a default and its rules (see **Feature flags**).\n- `plitzi://settings/{env}` \u2014 space-level settings: the global `customCss` and the state/auth (user-provider) config.\n- `plitzi://interactions/{env}` \u2014 interaction **actions** observed in this space (grouped by node type): the\n vocabulary for interaction flows.\n- `plitzi://data-sources/{env}` \u2014 data-source **paths** and binding targets observed in this space: the\n vocabulary for data bindings.\n- `plitzi://connector-presets` \u2014 working starting **manifests** (Strapi, WordPress, Directus, Contentful, plain\n REST) with the credential keys each provider needs, plus every **template token** the connector engine binds.\n Space-independent. Read it before writing a connector by hand.\n- `plitzi://connectors/{env}` \u2014 the **connectors this space has**: for each, its read/write endpoint names, its\n filter operators and its published fields. `/{ref}` opens one manifest in full. See *Connectors* below.\n- `plitzi://actions/{env}` \u2014 the **server actions this space has**: what starts each one, who may run it, and the\n input/output contract a caller is held to. `/{ref}` opens one flow in full. See *Server actions* below.\n- `plitzi://actions/{env}/tasks` \u2014 the **server tasks this deployment can run**, each with its params: the steps an\n action may be built from.\n- `plitzi://functions/{env}` \u2014 the space's **functions**, its own server code: which files, and the tasks, routes and\n hosts they declare. `plitzi://functions/{env}/{+path}` reads one file whole. See *Functions* below.\n- `plitzi://data/{env}` \u2014 the space's **data**: JSON files its server providers read, never served.\n `plitzi://data/{env}/{+path}` reads one, parsed. See *Data* below.\n- `plitzi://changes/{env}` \u2014 the space's **change history**, read-only and newest first: who made each change (a\n person in the builder, an agent, the autofix), when, and every element, class, token or font it touched, whole, before\n and after. `/{id}` for the history of one of them \u2014 how you find what changed an element you are asked about, or\n review what you or another agent just did.\n- `plitzi://render/guide`, `plitzi://render/types` \u2014 the manual and the type table for `plitzi_render` (offline\n widgets, not this space).\n\nThe style resources also answer under the `plitzi://schema/{env}/\u2026` root as aliases \u2014 `plitzi://schema/{env}/definitions/{ref}`, `plitzi://schema/{env}/style-variables/{category}`, `plitzi://schema/{env}/schema-variables` \u2014 but prefer the ready-made `uri` from search / a write response over hand-building either form.\n\nData resources return `{ stateVersion, data }`. Keep `stateVersion` for optimistic concurrency.\n\n**Reuse what you already know \u2014 don't re-scan an unchanged page.** A page read (`plitzi://schema/{env}/pages/{ref}`)\nreturns a `stateVersion` that is an **aggregate of the whole page**: it changes if and only if some element on the\npage changed. Its skeleton `tree` also carries a `stateVersion` **per node**, identical to the one a direct element\nread or search hit returns for that element. So when you come back to a page you already inspected:\n1. Re-read just the page skeleton and compare its top-level `stateVersion` to the one you held. **Same \u2192 nothing\n changed since your read; skip re-reading and re-searching the tree** and act on what you already know.\n2. If it differs, diff the per-node `stateVersion`s against the ones you cached and `plitzi_read` **only the nodes\n that changed** \u2014 never re-search or re-read the whole tree.\n\nThis is a **read-time** shortcut, not a safety guarantee. **Other agents/sub-agents may edit the same space\nconcurrently**, so a version you cached can go stale between your read and your write. Never skip the write-time\ncheck below on the strength of a cached hash \u2014 the guarantee that no concurrent edit is lost comes only from\n`expectedResourceVersions` on `plitzi_apply`, which re-validates against the live data at write time.\n\n## Navigating (files analogy)\nPages and containers are folders; elements are files. **Prefer `plitzi_search` (especially with `include: \"detail\"`)\nover reading elements one by one** \u2014 it jumps straight to elements by label/type/attribute and each hit already\ncarries the element's `uri`, `stateVersion`, `pageUri`, `parentRef` and tree `path`, so you can edit it (with\noptimistic concurrency) **without a follow-up read**. `include: \"detail\"` additionally inlines each hit's props/style\n**and** its `resolvedStyle` (the CSS behind its classes) \u2014 so a search-then-edit is the efficient path and a manual\nelement read is the exception. Search also matches **pages** by name/slug (returned under `pages`, each with its uri +\nstateVersion) and returns any **style definitions** whose name matches the query, with full CSS, under `definitions`.\nWhen you do hold several refs to open (e.g. from a skeleton), read them together with `plitzi_read` rather than one at a time.\n\n## Tools\n- `plitzi_apply` \u2014 validate \u2192 apply \u2192 persist atomically. Rejects the whole batch on any error or conflict, and\n reports **pre-existing malformations** in any resource the batch touches (see below) and `suggestions` (see\n *Suggestions*). Pass `dryRun: true` to check and apply in memory only \u2014 the same answer, nothing persisted \u2014 and\n `look` (`\"html\"`, `\"image\"`, `\"accessibility\"` or `\"both\"`, with `pageRef` and `viewport`) to see the page\n as the batch leaves it in the same call. Check and look with `dryRun`, then send the same operations without it.\n `effects` is what the batch did, read off the space before and after it \u2014 every element, attribute, class and\n setting it changed, one line each: read it, not your batch, for what is now so. `Nothing changed` and `NOT saved`\n lead the warnings when they are so.\n- **By intention**, a few parameters and the element named by its ref alone \u2014 the page is found, the operations\n written, the batch checked and saved as `plitzi_apply` saves it, and the answer its `effects`, whether it was\n `saved`, and what was already so:\n `plitzi_set_attributes { ref, set, unset }`, `plitzi_set_classes { ref, add, remove }` (the classes it wears and\n you do not name stay), `plitzi_bind_attribute { ref, to, source }`, `plitzi_place_component { component, ref, into,\n props }`, `plitzi_add_page { ref, slug, layout }`. One of them when it says the whole change; anything else is one\n batch of `plitzi_apply`.\n- `plitzi_describe_operation` \u2014 one operation's schema by its `type` (every field, which are required); without a\n type, every operation type there is. Ask for the one you are writing instead of guessing a field: a field an\n operation does not have is refused naming the one meant (`\"prop\" (did you mean \"props\"?)`), and a type spelt with\n other capitals is read as the catalog spells it and said in `warnings`. The same batch refused twice is not run a\n third time (`repeated`) \u2014 change what the errors name, or ask the person.\n- `plitzi_search` \u2014 find elements (and pages/definitions) across the space.\n- `plitzi_read` \u2014 read many resource **uris in one batch** (pages, elements, definitions, variables). Pass the\n ready-made uris from search / a write response; each result is `{ uri, stateVersion, data }` or a teachable error,\n so one bad uri never fails the batch. Use it instead of N single reads whenever you already hold several refs.\n- `plitzi_look { pageRef, view, viewport }` \u2014 see a saved page. `view`: `\"accessibility\"` (default) reads it as a\n screen reader and a browser agent (Claude in Chrome) do \u2014 an outline of roles and names, every control and picture\n with no name listed in `unnamed`, as text and far cheaper than an image; `\"html\"` its markup; `\"image\"` a PNG,\n the way to SEE overflow and misalignment (desktop, mobile or `both`); `\"both\"` image and outline. A change not\n saved yet is seen with `plitzi_apply`'s `dryRun` and `look`, the same views. It needs the SSR render service\n (refused `not-allowed` without it); without a browser, an image or an outline falls back to the HTML, said.\n- `plitzi_activity { after, wait }` \u2014 what happened on the space since you last looked: the draft changed (a person\n in the builder, another agent, the autofix \u2014 `seq` is its place in `plitzi://changes/{env}`), a version went\n out, a server action failed or was refused. The first call, without `after`, answers the latest and a `cursor`;\n pass it back as `after` and the call waits up to `wait` seconds (45, at most 50) until something happens. Your own\n writes are left out and counted (`skippedMine`; `mine: true` keeps them). On a space people edit too, call it\n before a write that rests on what you read earlier.\n- `plitzi_releases { domain? }`, `plitzi_publish { domain, environment, revision?, deploy? }`, `plitzi_rollback { domain, to? }`\n \u2014 the space's releases: what each domain serves, where its site is (`where`: Plitzi, or a copy on a\n provider) and what it asks (`asks`), and what a rollback would put back, one domain's history,\n pointing a domain at a revision (its environment's latest unless named; `main` serves the draft), and putting back\n what it served right before its latest release. A publish is live at once for that domain's visitors: publish only\n what the person asked for. Held to who may publish, the plan and the revision's tests, a refusal answered as\n `{ done: false, reason }`; a rollback is never refused by plan. Feature flags and the space's data stay as they are.\n On a domain whose site a provider holds, a publish that needs a deploy is refused with why unless `deploy: true`;\n the answer's `deployId` is the deploy it queued.\n- `plitzi_render` \u2014 a different job: show the user a self-contained widget built offline. It never touches the space.\n\n## Suggestions \u2014 the same page with fewer elements\n`plitzi_apply` (with or without `dryRun`) answers with `suggestions`: lines like `[content-attribute] \u2026 (saves 4\nelements)`, each naming a shorter way to what the batch just wrote. Only what THIS batch opened up is said \u2014 what the\nspace already had is not repeated on every batch \u2014 and none of them blocks anything: the page renders as written.\n- `repeated-on-pages` \u2014 the same block at the edge of several pages: put it in a **layout** once (a block only some\n pages of a layout carry is a **component** instead). Copies differing only in one link's class are the nav item of the\n page being shown: the `current` state marks it (see *Pages & folders*).\n- `repeated-shape` \u2014 one structure written again with other words: a **component** with props\n (`upsertComponent { fromRef }` turns one copy into it), or, for sibling rows of data, one `repeatElement`/`list`.\n A few cards a person rewords by hand can stay cards; siblings that bind different data, keep different state, fill\n from a template of their own or render on the server are controls written alike, and are not offered. Copies apart\n that read different sources are one component still: each instance binds its own to a `json` prop.\n- `content-attribute` \u2014 a `button` or `link` whose children are only a `text` and/or a `fontAwesome`: its words\n are its own `content` and the icon its `icon`. What the text's class adds (`white-space: nowrap`) moves to the\n box's class \u2014 never the class itself; the icon's class goes in the `icon` slot.\n- `custom-css-class`, `custom-css-sdk-default`, `custom-css-notifications` \u2014 `customCss` that a class's\n `states`/`ancestors`, the SDK (reduced motion, the theme toggle's icons) or the space's notification look says.\n- `heavy-animation` \u2014 keyframes that animate a size, a position, a blur, a shadow, or a colour in a loop: they stutter\n while the page loads. Lighter, not shorter \u2014 see **Motion \u2014 good practices**.\n- `unused-class`, `unused-token`, `unused-component` \u2014 declared and read by nothing: remove it\n (`deleteDefinition`, `deleteStyleVariable`, `deleteComponent`), or use it where it was meant to go. Said\n when a batch leaves one behind.\n- `element-color-inherited` \u2014 the space's `elements` giving a type `color: inherit` or the page's own colour,\n which every element \u2014 a link's words included \u2014 takes by itself: remove it, and name the colour once on the page.\n- `literal-colour` \u2014 a class painted from the palette typing out a token's light value: `var(--token)` when it\n should follow the scheme; a token of one value when it must stay the same in both.\n`plitzi://explain/<code>` explains each. Take one unless the copies are about to diverge; one left on purpose is\nquieted on an element it names \u2014 `quiet: [\"repeated-shape\"]` on `upsertElement`/`patchElement` (`null` removes it)\n\u2014 and is not offered again, here, in the builder or in authoring. Suggestions' codes only.\n\n## Readers: resources vs plitzi_search vs plitzi_read (do not confuse them)\nThree ways to read, each for a different moment \u2014 pick by what you have in hand:\n- **MCP resources** (the `plitzi://\u2026` catalog above) \u2014 the **browsable index**. List them to discover what exists, or\n open one by URI when you are exploring. This is the passive catalog, not a tool.\n- **`plitzi_search`** \u2014 you know *what* you want but not its **ref/uri** (\"the hero button\"). Search finds it by\n label/type/attribute and hands back the uri + stateVersion (and, with `include:\"detail\"`, the full element).\n- **`plitzi_read`** \u2014 you **already hold one or more uris** (from search or a write response) and want their\n content in one batch. It is the tool form of opening resources, for when you have the addresses.\nRule of thumb: **discover \u2192 resources**, **find a name \u2192 plitzi_search**, **fetch known uris \u2192 plitzi_read**. Never\nhand-build a URI to guess your way to an element \u2014 search for it instead.\n\nWrite tools return what **changed** (`{ uri, stateVersion }`) plus counts, and the **full detail of every element\nthey created or updated** \u2014 each with its own `uri` and `stateVersion` (`elements: [...]`) so a follow-up edit of\nthe same element needs **no intermediate read**. Other resources (pages, definitions, variables) still report only\nuri+stateVersion \u2014 re-read them if you need their new content. The operation shapes are in each tool's input\nschema (discriminated by `type`).\n\n## Addressing\nEvery element and page has **one name, and that name is its id**. You choose it, you address it by it, and the\nruntime wires by it \u2014 there is no second key and nothing to translate. Creating an element with\n`\"ref\": \"products-api\"` stores it under exactly that.\n\nThat name is the **wiring key**: a provider registers its data source as `<type>_<name>`, so a `source` you write\nagainst a name resolves to that element at runtime. Rules for a **new** name (both enforced; a violation fails the\nbatch):\n- Charset `[A-Za-z0-9_-]`, **starting with a letter** and not ending in `-` (e.g. `\"products-api\"`, `\"food_item\"`). A `.` would split\n the `<type>_<name>.<field>` source path and the interaction target lookup, so **no dots**. An **underscore is\n allowed**: the FIRST `_` separates `<type>` from the name and element types are camelCase with none, so\n underscores inside a name are unambiguous (`list_food_item` \u2192 type `list`, name `food_item`).\n- **Unique across the space**; a name that is taken is rejected (address the existing element instead).\n\n**Never invent a name for something that already exists** \u2014 read it. Every read hands you the name back\n(`plitzi_search`, a page skeleton, a write response), and that is the string every op takes.\n\n**Where an element renders** is its `runtime`, settable on `upsertElement`/`patchElement`: `\"shared\"` (the\ndefault, both sides), `\"client\"` (browser only) or `\"server\"` (SSR only). It matters for one thing above all \u2014 an\n`apiContainer` reads through a **connector** only when it is `\"server\"` (see *Connectors*). An element read\nreports it only when it is set. The page server resolves `\"server\"` elements of a page and its layouts only, never\ninside a component \u2014 one there is refused; put the provider on the page and hand the component its rows as a prop.\n\n**Renaming** (`patchElement` with `rename`) moves the one key: the parent's child list, every binding source and\nevery interaction target across the space that named the old one is repointed with it, so nothing comes unwired.\nYou do not have to rewrite them.\n\n## Elements \u2014 create, move, delete\n- `upsertElement` creates an element (or replaces one by name) under `parentRef` \u2014 the page root when omitted \u2014 and\n builds a whole subtree in one op through nested `children`. `patchElement` changes an existing one in place.\n- `addSpec { pageRef, parentRef, spec, classes }` adds a tree written as the authoring skill writes one \u2014 what\n `container({ \u2026 })` returns, as JSON, and the `styles(name, { \u2026 })` it names \u2014 checked by authoring itself: the\n same words in a project and here. Every `id` in it must be new to the space. With `replaces: ref` instead of\n `parentRef` it takes that element's place, and that element and all under it go: the spec may name their ids\n again, so an element is rewritten in the same words it was written in.\n- `moveElement { pageRef, ref, toParentRef, position }` moves or reorders one: `position` `\"inside\"` (the default)\n nests it in `toParentRef`; `\"before\"`/`\"after\"` make it that element's sibling. Its subtree moves with it.\n- `deleteElement { pageRef, ref }` removes an element **and everything under it**. A binding or an interaction\n elsewhere that named one of them is left pointing at nothing, and the save reports it \u2014 delete them in the same\n batch. Destructive: confirm first.\n- `flag` on `upsertElement` / `patchElement` gates an element on a feature flag (`\"newCheckout\"` or\n `\"!newCheckout\"`) \u2014 not a visibility: gated off it is not rendered at all. See **Feature flags**.\n- **A compound element is written with its parts**, as `children` of the same `upsertElement`: a `carousel` holds a\n `carouselTrack` (the slides go in it), a `tabContainer` a `tabContainerHeader` and a `tabContainerBody`, a\n `dropdown` a `dropdownPopup`. Without its part it shows nothing (`part-missing`); a part anywhere else breaks the\n page (`outside-ancestor`).\n- **A dropdown places its popup**: the popup's class is its look, never its place (`popup-position-set`) \u2014\n `popupPlacement`, the offsets and `popupWidth: \"trigger\"` are the dropdown's; the `openDropdown`,\n `closeDropdown` and `toggleDropdown` steps open and close it. The open tab is a class's `current` state\n (`aria-selected`), never `active` (the press): `plitzi://explain/<type>` says what each element writes on its node.\n\n";
|
|
2
|
+
export declare const referenceGuide = "# Plitzi AI MCP \u2014 usage guide\n\nA Plitzi space is **two separate schemas** you edit together:\n- **Element schema** \u2014 the tree of pages and elements (their type, label, props, and which style classes they use).\n- **Style schema** \u2014 reusable **definitions** (CSS classes), design tokens (variables), theme.\n\nThey are stored and persisted independently, but a single `plitzi_apply` batch may touch **both atomically**.\nTo style a specific element you do two things in one batch: write a **definition** (style schema) and **attach**\nit via the element's `style.base` (element schema). Example \u2014 \"rename button X to PEPE and make it red\":\n```json\n{ \"operations\": [\n { \"type\": \"upsertDefinition\", \"ref\": \"btn-x\", \"desktop\": { \"color\": \"red\" } },\n { \"type\": \"upsertElement\", \"pageRef\": \"home\",\n \"element\": { \"ref\": \"X\", \"type\": \"button\", \"label\": \"PEPE\", \"style\": { \"base\": [\"btn-x\"] } } }\n] }\n```\n\nReads are cheap by design \u2014 treat them like a filesystem: **list** to navigate, **read one item** for detail.\nNever download a whole tree you do not need.\n\n## Resources (read)\n- `plitzi://primer/{env}` \u2014 **cold-start bundle**: guide + types + css-properties + page/definition/variable\n **summaries** in one read. Fetch this first instead of the individual resources below. Summaries only \u2014 open a\n page skeleton or element for its tree/detail.\n- `plitzi://guide` \u2014 this guide.\n- `plitzi://types` \u2014 element types **observed in this space** (ground truth): props, slots, subTypes, plus each\n type's `label`, `description` (what it is FOR) and `category`, and a `source` (`builtin` | `plugin` | `unknown`).\n Read the descriptions to pick the right type \u2014 e.g. `apiContainer` fetches backend data into the frontend,\n `link` navigates between pages, `list` repeats a template over a data array. `plugin` types are the elements\n of the plugins the space installed: added by their type, like a built-in.\n- `plitzi://css-properties` \u2014 valid kebab-case CSS property keys.\n- `plitzi://explain/{name}` \u2014 what a name means: an element type's attributes, triggers, callbacks and what it writes\n on its node; a step's params and what it publishes; what a trigger hands its flow; a style state; a problem code's\n fix. `plitzi://explain/steps` (or elements, triggers, codes, transformers, states) lists every one of a kind.\n- `plitzi://schema/{env}/pages` \u2014 page **summaries** (ref, label, elementCount, folder). No element trees.\n- `plitzi://schema/{env}/layouts` \u2014 the shared **layout shells** (header/sidebar/footer) and the pages rendered\n inside each. Read one like a page. See *Shared layouts* below.\n- `plitzi://schema/{env}/components` \u2014 the space's **components** (reusable subtrees): their props, slots, root and\n how many places render each. Read one like a page. See *Components* below.\n- `plitzi://folders/{env}` \u2014 page **folders** (the sidebar tree): ref, name, slug, parentId. `/{ref}` for one.\n- `plitzi://schema/{env}/pages/{ref}` \u2014 one page as a **skeleton tree**: each node is `ref/type/label` **plus the\n style classes it attaches** (`base`, and `slots` for non-base slots) \u2014 names only, no CSS. So you can map every\n element to its class in a single page read, without opening each element just to learn which class it uses.\n- `plitzi://schema/{env}/pages/{ref}/styles` \u2014 **every style the page uses in one read**: the class definitions its\n elements attach (deduplicated, **with full CSS**) plus the global styles affecting any element type on the page.\n Reach for this to recolor/restyle a whole page \u2014 it needs no shared class-name prefix and no per-element reads.\n- `plitzi://schema/{env}/elements/{ref}` \u2014 one element in **full detail** (props, style, parentRef, childRefs).\n Its `resolvedStyle` inlines the **CSS of every definition** the element attaches (keyed by class ref), so you\n can see and edit its style without a separate definition read. Its `globalStyles` lists the **global element\n selectors** that also affect it (the CSS equivalent of `button { \u2026 }`, keyed by the type they target) \u2014 every\n element of that type inherits them. Edit a global only through the global-style tools (never per element). If the\n element carries a DOM `id` that an id rule matches, its `idStyle` (`#id`) is inlined too.\n- `plitzi://definitions/{env}` \u2014 the **names** of every style definition.\n- `plitzi://definitions/{env}/{ref}` \u2014 one definition's CSS.\n- `plitzi://global-styles/{env}` \u2014 element **types** that have a site-wide global style. `/{componentType}` for one.\n- `plitzi://id-styles/{env}` \u2014 DOM **ids** that have an id rule (`#id`) targeting a single element. `/{targetId}` for one.\n- `plitzi://style-variables/{env}` \u2014 design tokens by category. `/{category}` for one.\n- `plitzi://fonts/{env}` \u2014 the font **families the space loads**, with their source and fallback. `/{family}` for one.\n- `plitzi://schema-variables/{env}` \u2014 space-level values referenced in props as `{{name}}`.\n- `plitzi://flags/{env}` \u2014 the space's **feature flags**, each a default and its rules (see **Feature flags**).\n- `plitzi://settings/{env}` \u2014 space-level settings: the global `customCss` and the state/auth (user-provider) config.\n- `plitzi://interactions/{env}` \u2014 interaction **actions** observed in this space (grouped by node type): the\n vocabulary for interaction flows.\n- `plitzi://data-sources/{env}` \u2014 data-source **paths** and binding targets observed in this space: the\n vocabulary for data bindings.\n- `plitzi://connector-presets` \u2014 working starting **manifests** (Strapi, WordPress, Directus, Contentful, plain\n REST) with the credential keys each provider needs, plus every **template token** the connector engine binds.\n Space-independent. Read it before writing a connector by hand.\n- `plitzi://connectors/{env}` \u2014 the **connectors this space has**: for each, its read/write endpoint names, its\n filter operators and its published fields. `/{ref}` opens one manifest in full. See *Connectors* below.\n- `plitzi://actions/{env}` \u2014 the **server actions this space has**: what starts each one, who may run it, and the\n input/output contract a caller is held to. `/{ref}` opens one flow in full. See *Server actions* below.\n- `plitzi://actions/{env}/tasks` \u2014 the **server tasks this deployment can run**, each with its params: the steps an\n action may be built from.\n- `plitzi://functions/{env}` \u2014 the space's **functions**, its own server code: which files, and the tasks, routes and\n hosts they declare. `plitzi://functions/{env}/{+path}` reads one file whole. See *Functions* below.\n- `plitzi://data/{env}` \u2014 the space's **data**: JSON files its server providers read, never served.\n `plitzi://data/{env}/{+path}` reads one, parsed. See *Data* below.\n- `plitzi://changes/{env}` \u2014 the space's **change history**, read-only and newest first: who made each change (a\n person in the builder, an agent, the autofix), when, and every element, class, token or font it touched, whole, before\n and after. `/{id}` for the history of one of them \u2014 how you find what changed an element you are asked about, or\n review what you or another agent just did.\n- `plitzi://render/guide`, `plitzi://render/types` \u2014 the manual and the type table for `plitzi_render` (offline\n widgets, not this space).\n\nThe style resources also answer under the `plitzi://schema/{env}/\u2026` root as aliases \u2014 `plitzi://schema/{env}/definitions/{ref}`, `plitzi://schema/{env}/style-variables/{category}`, `plitzi://schema/{env}/schema-variables` \u2014 but prefer the ready-made `uri` from search / a write response over hand-building either form.\n\nData resources return `{ stateVersion, data }`. Keep `stateVersion` for optimistic concurrency.\n\n**Reuse what you already know \u2014 don't re-scan an unchanged page.** A page read (`plitzi://schema/{env}/pages/{ref}`)\nreturns a `stateVersion` that is an **aggregate of the whole page**: it changes if and only if some element on the\npage changed. Its skeleton `tree` also carries a `stateVersion` **per node**, identical to the one a direct element\nread or search hit returns for that element. So when you come back to a page you already inspected:\n1. Re-read just the page skeleton and compare its top-level `stateVersion` to the one you held. **Same \u2192 nothing\n changed since your read; skip re-reading and re-searching the tree** and act on what you already know.\n2. If it differs, diff the per-node `stateVersion`s against the ones you cached and `plitzi_read` **only the nodes\n that changed** \u2014 never re-search or re-read the whole tree.\n\nThis is a **read-time** shortcut, not a safety guarantee. **Other agents/sub-agents may edit the same space\nconcurrently**, so a version you cached can go stale between your read and your write. Never skip the write-time\ncheck below on the strength of a cached hash \u2014 the guarantee that no concurrent edit is lost comes only from\n`expectedResourceVersions` on `plitzi_apply`, which re-validates against the live data at write time.\n\n## Navigating (files analogy)\nPages and containers are folders; elements are files. **Prefer `plitzi_search` (especially with `include: \"detail\"`)\nover reading elements one by one** \u2014 it jumps straight to elements by label/type/attribute and each hit already\ncarries the element's `uri`, `stateVersion`, `pageUri`, `parentRef` and tree `path`, so you can edit it (with\noptimistic concurrency) **without a follow-up read**. `include: \"detail\"` additionally inlines each hit's props/style\n**and** its `resolvedStyle` (the CSS behind its classes) \u2014 so a search-then-edit is the efficient path and a manual\nelement read is the exception. Search also matches **pages** by name/slug (returned under `pages`, each with its uri +\nstateVersion) and returns any **style definitions** whose name matches the query, with full CSS, under `definitions`.\nWhen you do hold several refs to open (e.g. from a skeleton), read them together with `plitzi_read` rather than one at a time.\n\n## Tools\n- `plitzi_apply` \u2014 validate \u2192 apply \u2192 persist atomically. Rejects the whole batch on any error or conflict, and\n reports **pre-existing malformations** in any resource the batch touches (see below) and `suggestions` (see\n *Suggestions*). Pass `dryRun: true` to check and apply in memory only \u2014 the same answer, nothing persisted \u2014 and\n `look` (`\"html\"`, `\"image\"`, `\"accessibility\"` or `\"both\"`, with `pageRef` and `viewport`) to see the page\n as the batch leaves it in the same call. Check and look with `dryRun`, then send the same operations without it.\n `effects` is what the batch did, read off the space before and after it \u2014 every element, attribute, class and\n setting it changed, one line each: read it, not your batch, for what is now so. `Nothing changed` and `NOT saved`\n lead the warnings when they are so.\n- **By intention**, a few parameters and the element named by its ref alone \u2014 the page is found, the operations\n written, the batch checked and saved as `plitzi_apply` saves it, and the answer its `effects`, whether it was\n `saved`, and what was already so:\n `plitzi_set_attributes { ref, set, unset }`, `plitzi_set_classes { ref, add, remove }` (the classes it wears and\n you do not name stay), `plitzi_bind_attribute { ref, to, source }`, `plitzi_place_component { component, ref, into,\n props }`, `plitzi_add_page { ref, slug, layout }`. One of them when it says the whole change; anything else is one\n batch of `plitzi_apply`.\n- `plitzi_describe_operation` \u2014 one operation's schema by its `type` (every field, which are required); without a\n type, every operation type there is. Ask for the one you are writing instead of guessing a field: a field an\n operation does not have is refused naming the one meant (`\"prop\" (did you mean \"props\"?)`), and a type spelt with\n other capitals is read as the catalog spells it and said in `warnings`. The same batch refused twice is not run a\n third time (`repeated`) \u2014 change what the errors name, or ask the person.\n- `plitzi_search` \u2014 find elements (and pages/definitions) across the space.\n- `plitzi_read` \u2014 read many resource **uris in one batch** (pages, elements, definitions, variables). Pass the\n ready-made uris from search / a write response; each result is `{ uri, stateVersion, data }` or a teachable error,\n so one bad uri never fails the batch. Use it instead of N single reads whenever you already hold several refs.\n- `plitzi_look { pageRef, view, viewport }` \u2014 see a saved page. `view`: `\"accessibility\"` (default) reads it as a\n screen reader and a browser agent (Claude in Chrome) do \u2014 an outline of roles and names, every control and picture\n with no name listed in `unnamed`, as text and far cheaper than an image; `\"html\"` its markup; `\"image\"` a PNG,\n the way to SEE overflow and misalignment (desktop, mobile or `both`); `\"both\"` image and outline. A change not\n saved yet is seen with `plitzi_apply`'s `dryRun` and `look`, the same views. It needs the SSR render service\n (refused `not-allowed` without it); without a browser, an image or an outline falls back to the HTML, said.\n- `plitzi_activity { after, wait }` \u2014 what happened on the space since you last looked: the draft changed (a person\n in the builder, another agent, the autofix \u2014 `seq` is its place in `plitzi://changes/{env}`), a version went\n out, a server action failed or was refused. The first call, without `after`, answers the latest and a `cursor`;\n pass it back as `after` and the call waits up to `wait` seconds (45, at most 50) until something happens. Your own\n writes are left out and counted (`skippedMine`; `mine: true` keeps them). On a space people edit too, call it\n before a write that rests on what you read earlier.\n- `plitzi_releases { domain? }`, `plitzi_publish { domain, environment, revision?, deploy? }`, `plitzi_rollback { domain, to? }`\n \u2014 the space's releases: what each domain serves, where its site is (`where`: Plitzi, or a copy on a\n provider) and what it asks (`asks`), and what a rollback would put back, one domain's history,\n pointing a domain at a revision (its environment's latest unless named; `main` serves the draft), and putting back\n what it served right before its latest release. A publish is live at once for that domain's visitors: publish only\n what the person asked for. Held to who may publish, the plan and the revision's tests, a refusal answered as\n `{ done: false, reason }`; a rollback is never refused by plan. Feature flags and the space's data stay as they are.\n On a domain whose site a provider holds, a publish that needs a deploy is refused with why unless `deploy: true`;\n the answer's `deployId` is the deploy it queued.\n- `plitzi_render` \u2014 a different job: show the user a self-contained widget built offline. It never touches the space.\n\n## Suggestions \u2014 the same page with fewer elements\n`plitzi_apply` (with or without `dryRun`) answers with `suggestions`: lines like `[content-attribute] \u2026 (saves 4\nelements)`, each naming a shorter way to what the batch just wrote. Only what THIS batch opened up is said \u2014 what the\nspace already had is not repeated on every batch \u2014 and none of them blocks anything: the page renders as written.\n- `repeated-on-pages` \u2014 the same block at the edge of several pages: put it in a **layout** once (a block only some\n pages of a layout carry is a **component** instead). Copies differing only in one link's class are the nav item of the\n page being shown: the `current` state marks it (see *Pages & folders*).\n- `repeated-shape` \u2014 one structure written again with other words: a **component** with props\n (`upsertComponent { fromRef }` turns one copy into it), or, for sibling rows of data, one `repeatElement`/`list`.\n A few cards a person rewords by hand can stay cards; siblings that bind different data, keep different state, fill\n from a template of their own or render on the server are controls written alike, and are not offered. Copies apart\n that read different sources are one component still: each instance binds its own to a `json` prop.\n- `content-attribute` \u2014 a `button` or `link` whose children are only a `text` and/or a `fontAwesome`: its words\n are its own `content` and the icon its `icon`. What the text's class adds (`white-space: nowrap`) moves to the\n box's class \u2014 never the class itself; the icon's class goes in the `icon` slot.\n- `custom-css-class`, `custom-css-sdk-default`, `custom-css-notifications` \u2014 `customCss` that a class's\n `states`/`ancestors`, the SDK (reduced motion, the theme toggle's icons) or the space's notification look says.\n- `heavy-animation` \u2014 keyframes that animate a size, a position, a blur, a shadow, or a colour in a loop: they stutter\n while the page loads. Lighter, not shorter \u2014 see **Motion \u2014 good practices**.\n- `unused-class`, `unused-token`, `unused-component` \u2014 declared and read by nothing: remove it\n (`deleteDefinition`, `deleteStyleVariable`, `deleteComponent`), or use it where it was meant to go. Said\n when a batch leaves one behind.\n- `element-color-inherited` \u2014 the space's `elements` giving a type `color: inherit` or the page's own colour,\n which every element \u2014 a link's words included \u2014 takes by itself: remove it, and name the colour once on the page.\n- `literal-colour` \u2014 a class painted from the palette typing out a token's light value: `var(--token)` when it\n should follow the scheme; a token of one value when it must stay the same in both.\n`plitzi://explain/<code>` explains each. Take one unless the copies are about to diverge; one left on purpose is\nquieted on an element it names \u2014 `quiet: [\"repeated-shape\"]` on `upsertElement`/`patchElement` (`null` removes it)\n\u2014 and is not offered again, here, in the builder or in authoring. Suggestions' codes only.\n\n## Readers: resources vs plitzi_search vs plitzi_read (do not confuse them)\nThree ways to read, each for a different moment \u2014 pick by what you have in hand:\n- **MCP resources** (the `plitzi://\u2026` catalog above) \u2014 the **browsable index**. List them to discover what exists, or\n open one by URI when you are exploring. This is the passive catalog, not a tool.\n- **`plitzi_search`** \u2014 you know *what* you want but not its **ref/uri** (\"the hero button\"). Search finds it by\n label/type/attribute and hands back the uri + stateVersion (and, with `include:\"detail\"`, the full element).\n- **`plitzi_read`** \u2014 you **already hold one or more uris** (from search or a write response) and want their\n content in one batch. It is the tool form of opening resources, for when you have the addresses.\nRule of thumb: **discover \u2192 resources**, **find a name \u2192 plitzi_search**, **fetch known uris \u2192 plitzi_read**. Never\nhand-build a URI to guess your way to an element \u2014 search for it instead.\n\nWrite tools return what **changed** (`{ uri, stateVersion }`) plus counts, and the **full detail of every element\nthey created or updated** \u2014 each with its own `uri` and `stateVersion` (`elements: [...]`) so a follow-up edit of\nthe same element needs **no intermediate read**. Other resources (pages, definitions, variables) still report only\nuri+stateVersion \u2014 re-read them if you need their new content. The operation shapes are in each tool's input\nschema (discriminated by `type`).\n\n## Addressing\nEvery element and page has **one name, and that name is its id**. You choose it, you address it by it, and the\nruntime wires by it \u2014 there is no second key and nothing to translate. Creating an element with\n`\"ref\": \"products-api\"` stores it under exactly that.\n\nThat name is the **wiring key**: a provider registers its data source as `<type>_<name>`, so a `source` you write\nagainst a name resolves to that element at runtime. Rules for a **new** name (both enforced; a violation fails the\nbatch):\n- Charset `[A-Za-z0-9_-]`, **starting with a letter** and not ending in `-` (e.g. `\"products-api\"`, `\"food_item\"`). A `.` would split\n the `<type>_<name>.<field>` source path and the interaction target lookup, so **no dots**. An **underscore is\n allowed**: the FIRST `_` separates `<type>` from the name and element types are camelCase with none, so\n underscores inside a name are unambiguous (`list_food_item` \u2192 type `list`, name `food_item`).\n- **Unique across the space**; a name that is taken is rejected (address the existing element instead).\n\n**Never invent a name for something that already exists** \u2014 read it. Every read hands you the name back\n(`plitzi_search`, a page skeleton, a write response), and that is the string every op takes.\n\n**Where an element renders** is its `runtime`, settable on `upsertElement`/`patchElement`: `\"shared\"` (the\ndefault, both sides), `\"client\"` (browser only) or `\"server\"` (SSR only). It matters for one thing above all \u2014 an\n`apiContainer` reads through a **connector** only when it is `\"server\"` (see *Connectors*). An element read\nreports it only when it is set. The page server resolves `\"server\"` elements of a page and its layouts only, never\ninside a component \u2014 one there is refused; put the provider on the page and hand the component its rows as a prop.\n\n**Renaming** (`patchElement` with `rename`) moves the one key: the parent's child list, every binding source and\nevery interaction target across the space that named the old one is repointed with it, so nothing comes unwired.\nYou do not have to rewrite them.\n\n## Elements \u2014 create, move, delete\n- `upsertElement` creates an element (or replaces one by name) under `parentRef` \u2014 the page root when omitted \u2014 and\n builds a whole subtree in one op through nested `children`. `patchElement` changes an existing one in place.\n- `addSpec { pageRef, parentRef, spec, classes }` adds a tree written as the authoring skill writes one \u2014 what\n `container({ \u2026 })` returns, as JSON, and the `styles(name, { \u2026 })` it names \u2014 checked by authoring itself: the\n same words in a project and here. Every `id` in it must be new to the space. With `replaces: ref` instead of\n `parentRef` it takes that element's place, and that element and all under it go: the spec may name their ids\n again, so an element is rewritten in the same words it was written in.\n- `moveElement { pageRef, ref, toParentRef, position }` moves or reorders one: `position` `\"inside\"` (the default)\n nests it in `toParentRef`; `\"before\"`/`\"after\"` make it that element's sibling. Its subtree moves with it.\n- `deleteElement { pageRef, ref }` removes an element **and everything under it**. A binding or an interaction\n elsewhere that named one of them is left pointing at nothing, and the save reports it \u2014 delete them in the same\n batch. Destructive: confirm first.\n- `flag` on `upsertElement` / `patchElement` gates an element on a feature flag (`\"newCheckout\"` or\n `\"!newCheckout\"`) \u2014 not a visibility: gated off it is not rendered at all. See **Feature flags**.\n- **A compound element is written with its parts**, as `children` of the same `upsertElement`: a `carousel` holds a\n `carouselTrack` (the slides go in it), a `tabContainer` a `tabContainerHeader` and a `tabContainerBody`, a\n `dropdown` a `dropdownPopup`, a `variants` its `variantItem`s. Without its part it shows nothing (`part-missing`); a part anywhere else breaks the\n page (`outside-ancestor`).\n- **A dropdown places its popup**: the popup's class is its look, never its place (`popup-position-set`) \u2014\n `popupPlacement`, the offsets and `popupWidth: \"trigger\"` are the dropdown's; the `openDropdown`,\n `closeDropdown` and `toggleDropdown` steps open and close it. The open tab is a class's `current` state\n (`aria-selected`), never `active` (the press): `plitzi://explain/<type>` says what each element writes on its node.\n\n";
|
|
@@ -252,7 +252,7 @@ You do not have to rewrite them.
|
|
|
252
252
|
\`"!newCheckout"\`) — not a visibility: gated off it is not rendered at all. See **Feature flags**.
|
|
253
253
|
- **A compound element is written with its parts**, as \`children\` of the same \`upsertElement\`: a \`carousel\` holds a
|
|
254
254
|
\`carouselTrack\` (the slides go in it), a \`tabContainer\` a \`tabContainerHeader\` and a \`tabContainerBody\`, a
|
|
255
|
-
\`dropdown\` a \`dropdownPopup
|
|
255
|
+
\`dropdown\` a \`dropdownPopup\`, a \`variants\` its \`variantItem\`s. Without its part it shows nothing (\`part-missing\`); a part anywhere else breaks the
|
|
256
256
|
page (\`outside-ancestor\`).
|
|
257
257
|
- **A dropdown places its popup**: the popup's class is its look, never its place (\`popup-position-set\`) —
|
|
258
258
|
\`popupPlacement\`, the offsets and \`popupWidth: "trigger"\` are the dropdown's; the \`openDropdown\`,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The space's server side: connectors, server actions, functions, data, realtime channels and feature flags. */
|
|
2
|
-
export declare const serverGuide = "## Connectors \u2014 CMS and API integrations\nA **connector** is how a space reads real content from Strapi, WordPress, Contentful, Directus or any REST service.\nIt is **a manifest, not code**: you declare the base URL, the endpoints, the auth template and the filter operators,\nand the **server** executes it during the render. Integrating a new CMS never means shipping an adapter \u2014 it means\nwriting one document, which you can do here with `upsertConnector`.\n\nWhy the server and not the browser: the request (and the token behind it) never reaches the visitor, and the content\nis in the HTML search engines see. That is also the one hard rule below \u2014 a provider element that is not\nserver-rendered ignores its connector entirely.\n\n**Read these two first:**\n- `plitzi://connector-presets` \u2014 **working manifests** for Strapi v5, WordPress, Directus, Contentful and a plain\n REST API, each with the `credentialKeys` that provider needs, **plus every template token** the engine binds.\n Start from the preset for the user's provider and edit it; do not invent a shape from memory.\n- `plitzi://connectors/{env}` \u2014 the connectors **this space already has**, each with its read/write endpoint names,\n its filter operators and its published fields. `plitzi://connectors/{env}/{ref}` opens one manifest in full.\n\n### Credentials are NOT yours to write\nYou never create, see or transmit a secret. Author the manifest with the token in place\n(`\"value\": \"Bearer {{credential.token}}\"`) and **leave `connection.credential` unset** unless the user hands you an\nidentifier. The connector **saves fine that way** \u2014 validation reports it as a *warning*, not an error \u2014 and its\nrequests go unauthenticated until the space owner creates the credential in the builder and attaches it. Say that to\nthe user as the last step of any integration you build, naming the keys the preset lists (e.g. Strapi needs `token`).\n\n### The manifest\nEvery string is a template the server renders per request. `{{resource}}` is the collection the element asked for;\n`{{limit}}`/`{{offset}}`/`{{page}}`/`{{cursor}}` the window; `{{routeParams.x}}`/`{{queryParams.x}}` the\nvisitor's URL; `{{credential.x}}` the secret; `{{field}}`/`{{value}}` inside an operator; `{{id}}`/`{{values}}`\ninside a write. The op splits it in two, exactly as the engine does:\n- **`connection`** \u2014 what applies to every call: `credential`, `auth`, `headers`, `pagination`, `operators`,\n `mediaBaseUrl`, `fields`, `projection`.\n- **`endpoints`** \u2014 the individual calls: `read` (named; **`list` is the one an element addresses when it names\n none**) and `write` (named; **omit for read-only** \u2014 an undeclared write can never be executed).\n\nA read endpoint says where things live in *that* provider's response: `itemsPath` (the array), `totalPath` (the\ncount), `idPath` (the record's id), `valuesPath` (its fields). Strapi's `data` + `meta.pagination.total` and\nContentful's `items` + `fields` are the same manifest with different paths.\n\nTwo traps the validator will catch for you, both silent at runtime otherwise:\n- An **operator template must render a whole `key=value` entry** (`\"eq\": \"filters[{{field}}][$eq]={{value}}\"`). A\n filter naming an operator the manifest does not declare is **dropped** \u2014 the query then returns *unfiltered*\n records, not none.\n- **Paging must appear in the request.** Declaring `pagination: \"page\"` without `{{page}}` in the query makes every\n page resolve to the first one.\n\nExample \u2014 Strapi, from the preset:\n```json\n{ \"type\": \"upsertConnector\", \"ref\": \"strapi-blog\", \"name\": \"Blog CMS\",\n \"baseUrl\": \"https://cms.example.com\",\n \"connection\": {\n \"auth\": { \"in\": \"header\", \"name\": \"Authorization\", \"value\": \"Bearer {{credential.token}}\" },\n \"pagination\": \"offset\",\n \"operators\": { \"eq\": \"filters[{{field}}][$eq]={{value}}\", \"contains\": \"filters[{{field}}][$containsi]={{value}}\" },\n \"mediaBaseUrl\": \"https://cms.example.com\" },\n \"endpoints\": { \"read\": { \"list\": {\n \"path\": \"/api/{{resource}}\",\n \"query\": { \"pagination[start]\": \"{{offset}}\", \"pagination[limit]\": \"{{limit}}\", \"populate\": \"*\" },\n \"itemsPath\": \"data\", \"totalPath\": \"meta.pagination.total\", \"idPath\": \"documentId\" } } } }\n```\n`patchConnector` changes part of one (endpoints merge **by name**; `null` removes one) \u2014 that is how you add a\n`detail` read to a large manifest without resending it. `deleteConnector` is destructive: every element pointing\nat it stops resolving, so confirm first.\n\n### Using a connector on a page\nThe provider element is `apiContainer`, and it needs **both halves**:\n1. `runtime: \"server\"` \u2014 set it on `upsertElement`/`patchElement`. **Without it the connector is ignored** and the\n element falls back to fetching its own `query` URL from the browser. This is the single most common mistake; the\n validator warns when it sees one half without the other.\n2. props: `connector` (the ref), `resource` (the collection \u2192 `{{resource}}`), and optionally `endpoint` (a read\n other than `list`), `filters`, `limit`, `singleRecord`, `pagination`, `pageParam`.\n\nIt then publishes one source **to its descendants only** (like any provider \u2014 bind *inside* its subtree):\n`apiContainer_<name>.records` (an array of `{ id, values }` \u2014 a record's fields are under `values`, so a row\nreads `list_<name>.item.values.<field>`), `.pageInfo` (`page`, `pageCount`, `total`, `hasNextPage`\u2026),\n`.isEmpty`, `.hasError`, `.errorMessage`, `.isLoading`. With `singleRecord: true` it publishes `.record`\ninstead of `.records` \u2014 that is what a **detail page** uses. Bind an empty-state block's visibility to `.isEmpty`\nand an error block's to `.hasError`; they are ordinary bindings, no special mechanism.\n\n**A list page** \u2014 provider, then a `list` inside it bound to the records, then the row template reading the item\n(a `list` is a `<ul>`, or `<ol>` by `subType`; its row a `listItem`, an `<li>` \u2014 any other row is warned\n`list-row-not-li`):\n```json\n{ \"operations\": [\n { \"type\": \"upsertElement\", \"pageRef\": \"blog\", \"element\": {\n \"ref\": \"posts-api\", \"type\": \"apiContainer\", \"runtime\": \"server\",\n \"props\": { \"connector\": \"strapi-blog\", \"resource\": \"articles\", \"limit\": \"9\", \"pagination\": \"url\" },\n \"children\": [ { \"ref\": \"posts\", \"type\": \"list\", \"children\": [\n { \"ref\": \"post-row\", \"type\": \"listItem\", \"children\": [\n { \"ref\": \"post-title\", \"type\": \"text\" } ] } ] } ] } },\n { \"type\": \"upsertBinding\", \"pageRef\": \"blog\", \"ref\": \"posts\", \"category\": \"attributes\",\n \"binding\": { \"to\": \"items\", \"source\": \"apiContainer_posts-api.records\" } },\n { \"type\": \"upsertBinding\", \"pageRef\": \"blog\", \"ref\": \"post-title\", \"category\": \"attributes\",\n \"binding\": { \"to\": \"content\", \"source\": \"list_posts.item.values.title\" } } ] }\n```\n\n**A detail page** is the same provider with `singleRecord` and a filter resolved from the URL. Create the page with a\nroute param (`\"slug\": \"blog/:postSlug\"`), then filter on it \u2014 the filter `value` is a template the server resolves:\n```json\n{ \"type\": \"upsertElement\", \"pageRef\": \"post-detail\", \"element\": {\n \"ref\": \"post-api\", \"type\": \"apiContainer\", \"runtime\": \"server\",\n \"props\": { \"connector\": \"strapi-blog\", \"resource\": \"articles\", \"singleRecord\": true,\n \"filters\": [ { \"field\": \"slug\", \"operator\": \"eq\", \"value\": \"{{routeParams.postSlug}}\" } ] } } }\n```\nIts children then bind to `apiContainer_post-api.record.values.<field>`. A filter whose template resolves to nothing\nreturns **no records** rather than the whole collection \u2014 a URL that addressed one post never renders a different one.\n\n**Paging** is the `pagination` prop: `\"none\"`, `\"url\"` (the page number rides the query string, so pages are\nshareable and indexable \u2014 prefer it) or `\"append\"` (a \"load more\" list). Give each list on a page its own\n`pageParam` so two lists page independently. The provider also offers the `loadMore` and `goToPage` callbacks to\ninteraction flows, `performQuery` to refetch, and `cancelQuery` to drop a request in flight (a STOP).\n\n**Writing back** (a form, a \"delete\" button): declare the endpoint under `endpoints.write`, then call the provider's\n**`writeRecord`** callback from an interaction flow \u2014 nodeType `callback`, `elementId` the apiContainer's ref,\nparams `action` (the write endpoint's name) and `recordId`. The write goes through the server, which owns the\ncredential and refuses any action the manifest does not declare. Writes exist **only** on a server-rendered provider.\n\n**Connectors need a server.** A space published without server rendering has nowhere to resolve one: it works in the\nbuilder and renders empty when published. If the user has no SSR deployment, say so rather than leaving them to\ndiscover it \u2014 the alternative is a browser-side `query`, which cannot keep a secret.\n\n## Server actions\nWork a page cannot do in the browser \u2014 charge a card, send mail, read a system only the server reaches. An action\nis a stored flow the SERVER runs; a page names it and never learns what it does. Write one with\n`upsertAction` / `patchAction`, then call it from a page flow with the `runServerAction` step (mode\n`await` to use the result, `detached` to fire and carry on).\n\nFour rules worth knowing before you write:\n\n- **Steps are server tasks.** `plitzi://actions/{env}/tasks` lists what this deployment can run \u2014 a browser step\n (`setState`, `navigate`) has nothing to act on here, and the reverse is true too: a task cannot run in a page\n flow.\n- **The contracts.** `input` is coerced and anything undeclared is DROPPED. The OUTPUT is whatever the final\n `flow.output` step names \u2014 there is no separate list to keep in step with it \u2014 and that step must be LAST,\n since only the last one that runs is answered. Everything else a step produced stays on the server.\n- **Whether it runs lives on its TRIGGERS.** Each trigger step carries `enabled`, and the action is on when any\n way into it is \u2014 there is no switch beside the flow. So \"pause this action\" means disabling its trigger step(s),\n never deleting them.\n- **A step names the credential it uses**, and sees no other. `credentials` on the document says which ones the\n action may ask for at all; the secret itself is never yours to see, exactly as with a connector.\n\n`deleteAction { ref }` removes one; every `runServerAction` step that names it stops resolving, so confirm first.\n\n## Functions\nWhen no server task does what a flow needs \u2014 parse a feed, call an API with its own shape, compute something \u2014 the\nspace can have its own: **functions**, TypeScript the platform builds and runs in a sandbox. Their tasks are steps like\nany other (`<namespace>.<action>`), listed in `plitzi://actions/{env}/tasks` once saved.\n\n- **Write** files with `upsertFunctionFile { path, content }` (whole files; `deleteFunctionFile { path }` removes\n one). `index.ts` default-exports the definition:\n `export default defineFunctions({ allow: { hosts: [\"api.example.com\"] }, tasks: [{ namespace, action, title, params, run: async (params, ctx) => \u2026 }] })`,\n `defineFunctions` from `@plitzi/sdk-runtime`. Files import each other by relative path \u2014 no package,\n no Node built-in.\n- **`ctx` is all a function reaches:** `ctx.kv` (the space's store), `ctx.fetch(url, init)` to the hosts\n `allow.hosts` names (`*.example.com` for subdomains), `ctx.publish/grant/revoke` (channels),\n `ctx.data(\"products.json\")` (one file of the space's data, parsed \u2014 never imported), `ctx.log`, `ctx.user` (who\n asked, never their session). A secret is NAMED, never read: `ctx.fetch(url, { credential: \"stripe\",\n headers: { authorization: \"Bearer {{ credential.apiKey }}\" } })`. `signal` in the init cuts a slow request short\n (`AbortSignal.timeout(12000)`).\n- **Refuse with `ActionRefusal`** (from `@plitzi/sdk-runtime`): its message is written for whoever asked and\n reaches them (`{{ step.error }}`, a route's `400 { error }`); anything else thrown stays in the run's record.\n `new ActionRefusal(message, { code })` names it for code that catches it \u2014 compare `error.code`, never the message.\n- **An API on behalf of a visitor** (their calendar, their music) is an OAuth connection declared as data:\n `defineFunctions({ oauth: { calendar: { issuer, credential, scopes } } })` \u2014 `issuer` for OpenID, or\n `authorizeUrl`/`tokenUrl`; the credential holds the app's `clientId`/`clientSecret`. A route redirects to\n `(await ctx.oauth.connect(\"calendar\", { returnTo: \"/settings\" })).url` (`authorizeParams` adds to that one consent:\n `{ prompt: \"select_account\" }`), and `ctx.oauth.fetch(\"calendar\", url)` calls the API with the token written in;\n `status`, `disconnect` beside them. The platform keeps the token sealed and renews it \u2014 never put one in `kv`. The\n user registers `/fn/oauth/callback` on the space's host with the provider (`ctx.oauth.callbackUrl()` says the\n exact address, for a page that shows it). Not connected yet is a refusal with\n `code: \"oauth-not-connected\"`. `token` hands the access token only to a connection declaring `exposeToken: true`.\n- **Stateless:** nothing a function keeps in memory outlives the call \u2014 a module-level cache or counter starts empty\n every time, on whichever instance runs it. What must last goes in `ctx.kv`. A call gets 100 ms of CPU and 10 s;\n a task that needs more says so \u2014 `limits: { cpuMs: 1000, wallMs: 20000 }`, or `defineFunctions({ limits })` for\n all \u2014 up to the plan's ceiling. Asking above it is refused at save, never quietly cut.\n- **Routes** answer HTTP on the space's own host under `/fn/`: `routes: { \"GET /boards/:board\": (request, ctx) =>\n Response.json(\u2026) }` answers `/fn/boards/kanban` (`ctx.params.board`). No page may live under `/fn`.\n- **Saving builds and checks** the files: the batch is refused with each problem where it is (file and line). A\n namespace the platform uses (`kv`, `http`, `flow`\u2026) is refused.\n- **Try it** with `plitzi_try_function { task, params }` before a page relies on it: the value, the logs, the error.\n The live site runs what the space was last published with, never the draft. Running functions is part of the paid\n plans: on another plan they save, and a run answers why it did not start \u2014 tell the user rather than work around it.\n\n## Data\nJSON the space's pages read on the server and never serve \u2014 a catalog, prices, a menu: what a page needs whole and\nnobody edits element by element.\n\n- **Read** it as a provider does: `apiContainer` with `runtime: \"server\"` and `query: \"/data/products.json\"` reads\n `products.json` of `plitzi://data/{env}`, and the page arrives with it. A browser provider reading `/data/\u2026` is\n refused \u2014 the data is the server's.\n- **Write** it with `upsertDataFile { path, content }` (the whole file, as JSON text; `deleteDataFile { path }`\n removes one): a path of plain segments ending in `.json`. Saved whole, with the batch: a newer copy (somebody saved\n since you read it) refuses it \u2014 read it again.\n- **What a provider reads is in the page it renders**: data a page must not carry belongs in a server action, which\n answers only what is shown. The live site reads what the space was last published with, never the draft.\n\n## Realtime channels\nPages that see each other \u2014 cursors, presence, a shared board, a game. Three parts, all needed:\n\n1. **Declare** the topic pattern with `patchSettings { channels: { \"board:{id}\": { access: { mode: \"public\" }, publish: \"server\" } } }`.\n `publish: \"server\"` is for what must be validated and saved first; `\"clients\"` (the default) for what pages send\n directly \u2014 add `presence: true` for who-is-here.\n2. **Subscribe** with a `channel` element whose `topic` a pattern matches (`board:{{ id }}`, a route param).\n Its descendants bind `channel_<id>`: `connected`, `members`, `messages`, `last`, `retained`; flows use its `onMessage`,\n `onJoin`, `onLeave` triggers (`from`, `user` and the `state` the member announced \u2014 `onJoin` only for who\n came after this page) and its `publish` / `setPresence` callbacks.\n3. **Announce from the server**: an action whose last step is the `realtime.publish` task \u2014 validate, save, then say so.\n\nA topic no pattern matches is refused by the server and reported by the linter (`channel-topic`).\n\n**Private topics** (a room behind a password, a customer's order): declare the pattern `grant: true`. The action that\ndecides the visitor may be there ends with `realtime.grant { topic }` and answers its `grant`; the `channel`\nelement binds `grant` to it. Without one the topic is refused however well its name is known (`channel-grant`).\n`realtime.revoke { topic, grant }` takes one back \u2014 or all, naming none \u2014 and lets go whoever is on it with it.\n\n**State every screen shares** (a dashboard's lists, a board's settings): declare the pattern `retain: true` with\n`publish: \"server\"`. The server keeps the latest message of each type it says (`realtime.publish`) and hands them to\nevery page that joins \u2014 and to its `onMessage` flows, as if just said; the page binds `desk.retained.lists`, with no\nread of its own and no copy in `state`. `data: null` forgets a type; a topic keeps at most 64 types and 512 KB.\n\n**Two writers at once**: read-change-write with `kv.setIf` (written only if the value is still the one read \u2014 empty\n`expected` = only if nothing is there yet), ordered lists with `list.put` / `list.range`, and put\n`flow.rateLimit` first in any public action that writes.\n\n## Feature flags\nA flag turns a part of the space on or off without anyone editing it: a feature still being built, a version for\nbeta users, the old checkout kept until the new one ships. **Not a visibility** \u2014 visibility hides an element that is\nstill rendered; a flag decides whether it exists at all.\n\n- **Declare** with `upsertFlag { name, description?, value, rules? }`. `value` is its answer when no rule matches;\n `rules` are `[{ when, value }]` read top to bottom, the first match deciding. A rule's `when` is a rule group over\n `environment` (`main`, `development`, `staging`, `production`), `hostname`, `routeParams.<name>`,\n `queryParams.<name>` and the visitor: `user.authenticated`, `user.email`, `user.username`, `user.roles` (with\n `contains`). A group with no rules is skipped, never read as \"always\". `deleteFlag { name }` removes one.\n- **Gate** an element with `flag` on `upsertElement` / `patchElement`: `\"newCheckout\"` exists only while the flag is\n on, `\"!newCheckout\"` only while it is off \u2014 put both side by side for a rollout. On `upsertPage` a gated-off page\n answers 404. `null` on a patch removes the gate. Gated off, it is not rendered and its server data is not\n resolved \u2014 but the space's document, gated elements included, still reaches the browser: a flag is not a secret.\n- **Read** it anywhere a source is read: `{{ flags.newCheckout }}` in a binding, a `when` of a flow step, a computed\n value \u2014 and in a server action's steps, where it is resolved on the server.\n\nA gate or a read naming a flag the space does not declare is an error (`flag-undeclared`, `flag-unknown`): an\nundeclared flag is off. A declared flag nothing reads is a warning (`flag-unused`) \u2014 remove it once the feature\nships. The draft applies flags at once. Flags are not part of a snapshot: each environment has one set, shared by every\nsnapshot it serves \u2014 publishing a snapshot sends the draft's with it (and the snapshot keeps a copy, as a fallback), the\nbuilder'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\nmay each override a flag; you only ever write the space's own.\n\n";
|
|
2
|
+
export declare const serverGuide = "## Connectors \u2014 CMS and API integrations\nA **connector** is how a space reads real content from Strapi, WordPress, Contentful, Directus or any REST service.\nIt is **a manifest, not code**: you declare the base URL, the endpoints, the auth template and the filter operators,\nand the **server** executes it during the render. Integrating a new CMS never means shipping an adapter \u2014 it means\nwriting one document, which you can do here with `upsertConnector`.\n\nWhy the server and not the browser: the request (and the token behind it) never reaches the visitor, and the content\nis in the HTML search engines see. That is also the one hard rule below \u2014 a provider element that is not\nserver-rendered ignores its connector entirely.\n\n**Read these two first:**\n- `plitzi://connector-presets` \u2014 **working manifests** for Strapi v5, WordPress, Directus, Contentful and a plain\n REST API, each with the `credentialKeys` that provider needs, **plus every template token** the engine binds.\n Start from the preset for the user's provider and edit it; do not invent a shape from memory.\n- `plitzi://connectors/{env}` \u2014 the connectors **this space already has**, each with its read/write endpoint names,\n its filter operators and its published fields. `plitzi://connectors/{env}/{ref}` opens one manifest in full.\n\n### Credentials are NOT yours to write\nYou never create, see or transmit a secret. Author the manifest with the token in place\n(`\"value\": \"Bearer {{credential.token}}\"`) and **leave `connection.credential` unset** unless the user hands you an\nidentifier. The connector **saves fine that way** \u2014 validation reports it as a *warning*, not an error \u2014 and its\nrequests go unauthenticated until the space owner creates the credential in the builder and attaches it. Say that to\nthe user as the last step of any integration you build, naming the keys the preset lists (e.g. Strapi needs `token`).\n\n### The manifest\nEvery string is a template the server renders per request. `{{resource}}` is the collection the element asked for;\n`{{limit}}`/`{{offset}}`/`{{page}}`/`{{cursor}}` the window; `{{routeParams.x}}`/`{{queryParams.x}}` the\nvisitor's URL; `{{credential.x}}` the secret; `{{field}}`/`{{value}}` inside an operator; `{{id}}`/`{{values}}`\ninside a write. The op splits it in two, exactly as the engine does:\n- **`connection`** \u2014 what applies to every call: `credential`, `auth`, `headers`, `pagination`, `operators`,\n `mediaBaseUrl`, `fields`, `projection`.\n- **`endpoints`** \u2014 the individual calls: `read` (named; **`list` is the one an element addresses when it names\n none**) and `write` (named; **omit for read-only** \u2014 an undeclared write can never be executed).\n\nA read endpoint says where things live in *that* provider's response: `itemsPath` (the array), `totalPath` (the\ncount), `idPath` (the record's id), `valuesPath` (its fields). Strapi's `data` + `meta.pagination.total` and\nContentful's `items` + `fields` are the same manifest with different paths.\n\nTwo traps the validator will catch for you, both silent at runtime otherwise:\n- An **operator template must render a whole `key=value` entry** (`\"eq\": \"filters[{{field}}][$eq]={{value}}\"`). A\n filter naming an operator the manifest does not declare is **dropped** \u2014 the query then returns *unfiltered*\n records, not none.\n- **Paging must appear in the request.** Declaring `pagination: \"page\"` without `{{page}}` in the query makes every\n page resolve to the first one.\n\nExample \u2014 Strapi, from the preset:\n```json\n{ \"type\": \"upsertConnector\", \"ref\": \"strapi-blog\", \"name\": \"Blog CMS\",\n \"baseUrl\": \"https://cms.example.com\",\n \"connection\": {\n \"auth\": { \"in\": \"header\", \"name\": \"Authorization\", \"value\": \"Bearer {{credential.token}}\" },\n \"pagination\": \"offset\",\n \"operators\": { \"eq\": \"filters[{{field}}][$eq]={{value}}\", \"contains\": \"filters[{{field}}][$containsi]={{value}}\" },\n \"mediaBaseUrl\": \"https://cms.example.com\" },\n \"endpoints\": { \"read\": { \"list\": {\n \"path\": \"/api/{{resource}}\",\n \"query\": { \"pagination[start]\": \"{{offset}}\", \"pagination[limit]\": \"{{limit}}\", \"populate\": \"*\" },\n \"itemsPath\": \"data\", \"totalPath\": \"meta.pagination.total\", \"idPath\": \"documentId\" } } } }\n```\n`patchConnector` changes part of one (endpoints merge **by name**; `null` removes one) \u2014 that is how you add a\n`detail` read to a large manifest without resending it. `deleteConnector` is destructive: every element pointing\nat it stops resolving, so confirm first.\n\n### Using a connector on a page\nThe provider element is `apiContainer`, and it needs **both halves**:\n1. `runtime: \"server\"` \u2014 set it on `upsertElement`/`patchElement`. **Without it the connector is ignored** and the\n element falls back to fetching its own `query` URL from the browser. This is the single most common mistake; the\n validator warns when it sees one half without the other.\n2. props: `connector` (the ref), `resource` (the collection \u2192 `{{resource}}`), and optionally `endpoint` (a read\n other than `list`), `filters`, `limit`, `singleRecord`, `pagination`, `pageParam`.\n\nIt then publishes one source **to its descendants only** (like any provider \u2014 bind *inside* its subtree):\n`apiContainer_<name>.records` (an array of `{ id, values }` \u2014 a record's fields are under `values`, so a row\nreads `list_<name>.item.values.<field>`), `.pageInfo` (`page`, `pageCount`, `total`, `hasNextPage`\u2026),\n`.isEmpty`, `.hasError`, `.errorMessage`, `.isLoading`. With `singleRecord: true` it publishes `.record`\ninstead of `.records` \u2014 that is what a **detail page** uses. Bind an empty-state block's visibility to `.isEmpty`\nand an error block's to `.hasError`; they are ordinary bindings, no special mechanism.\n\n**A list page** \u2014 provider, then a `list` inside it bound to the records, then the row template reading the item\n(a `list` is a `<ul>`, or `<ol>` by `subType`; its row a `listItem`, an `<li>` \u2014 any other row is warned\n`list-row-not-li`):\n```json\n{ \"operations\": [\n { \"type\": \"upsertElement\", \"pageRef\": \"blog\", \"element\": {\n \"ref\": \"posts-api\", \"type\": \"apiContainer\", \"runtime\": \"server\",\n \"props\": { \"connector\": \"strapi-blog\", \"resource\": \"articles\", \"limit\": \"9\", \"pagination\": \"url\" },\n \"children\": [ { \"ref\": \"posts\", \"type\": \"list\", \"children\": [\n { \"ref\": \"post-row\", \"type\": \"listItem\", \"children\": [\n { \"ref\": \"post-title\", \"type\": \"text\" } ] } ] } ] } },\n { \"type\": \"upsertBinding\", \"pageRef\": \"blog\", \"ref\": \"posts\", \"category\": \"attributes\",\n \"binding\": { \"to\": \"items\", \"source\": \"apiContainer_posts-api.records\" } },\n { \"type\": \"upsertBinding\", \"pageRef\": \"blog\", \"ref\": \"post-title\", \"category\": \"attributes\",\n \"binding\": { \"to\": \"content\", \"source\": \"list_posts.item.values.title\" } } ] }\n```\n\n**A detail page** is the same provider with `singleRecord` and a filter resolved from the URL. Create the page with a\nroute param (`\"slug\": \"blog/:postSlug\"`), then filter on it \u2014 the filter `value` is a template the server resolves:\n```json\n{ \"type\": \"upsertElement\", \"pageRef\": \"post-detail\", \"element\": {\n \"ref\": \"post-api\", \"type\": \"apiContainer\", \"runtime\": \"server\",\n \"props\": { \"connector\": \"strapi-blog\", \"resource\": \"articles\", \"singleRecord\": true,\n \"filters\": [ { \"field\": \"slug\", \"operator\": \"eq\", \"value\": \"{{routeParams.postSlug}}\" } ] } } }\n```\nIts children then bind to `apiContainer_post-api.record.values.<field>`. A filter whose template resolves to nothing\nreturns **no records** rather than the whole collection \u2014 a URL that addressed one post never renders a different one.\n\n**Paging** is the `pagination` prop: `\"none\"`, `\"url\"` (the page number rides the query string, so pages are\nshareable and indexable \u2014 prefer it) or `\"append\"` (a \"load more\" list). Give each list on a page its own\n`pageParam` so two lists page independently. The provider also offers the `loadMore` and `goToPage` callbacks to\ninteraction flows, `performQuery` to refetch, and `cancelQuery` to drop a request in flight (a STOP).\n\n**Writing back** (a form, a \"delete\" button): declare the endpoint under `endpoints.write`, then call the provider's\n**`writeRecord`** callback from an interaction flow \u2014 nodeType `callback`, `elementId` the apiContainer's ref,\nparams `action` (the write endpoint's name) and `recordId`. The write goes through the server, which owns the\ncredential and refuses any action the manifest does not declare. Writes exist **only** on a server-rendered provider.\n\n**Connectors need a server.** A space published without server rendering has nowhere to resolve one: it works in the\nbuilder and renders empty when published. If the user has no SSR deployment, say so rather than leaving them to\ndiscover it \u2014 the alternative is a browser-side `query`, which cannot keep a secret.\n\n## Server actions\nWork a page cannot do in the browser \u2014 charge a card, send mail, read a system only the server reaches. An action\nis a stored flow the SERVER runs; a page names it and never learns what it does. Write one with\n`upsertAction` / `patchAction`, then call it from a page flow with the `runServerAction` step (mode\n`await` to use the result, `detached` to fire and carry on).\n\nFour rules worth knowing before you write:\n\n- **Steps are server tasks.** `plitzi://actions/{env}/tasks` lists what this deployment can run \u2014 a browser step\n (`setState`, `navigate`) has nothing to act on here, and the reverse is true too: a task cannot run in a page\n flow.\n- **The contracts.** `input` is coerced and anything undeclared is DROPPED. The OUTPUT is whatever the final\n `flow.output` step names \u2014 there is no separate list to keep in step with it \u2014 and that step must be LAST,\n since only the last one that runs is answered. Everything else a step produced stays on the server.\n- **Whether it runs lives on its TRIGGERS.** Each trigger step carries `enabled`, and the action is on when any\n way into it is \u2014 there is no switch beside the flow. So \"pause this action\" means disabling its trigger step(s),\n never deleting them.\n- **A step names the credential it uses**, and sees no other. `credentials` on the document says which ones the\n action may ask for at all; the secret itself is never yours to see, exactly as with a connector.\n\n`deleteAction { ref }` removes one; every `runServerAction` step that names it stops resolving, so confirm first.\n\n## Functions\nWhen no server task does what a flow needs \u2014 parse a feed, call an API with its own shape, compute something \u2014 the\nspace can have its own: **functions**, TypeScript the platform builds and runs in a sandbox. Their tasks are steps like\nany other (`<namespace>.<action>`), listed in `plitzi://actions/{env}/tasks` once saved.\n\n- **Write** files with `upsertFunctionFile { path, content }` (whole files; `deleteFunctionFile { path }` removes\n one). `index.ts` default-exports the definition:\n `export default defineFunctions({ allow: { hosts: [\"api.example.com\"] }, tasks: [{ namespace, action, title, params, run: async (params, ctx) => \u2026 }] })`,\n `defineFunctions` from `@plitzi/sdk-runtime`. Files import each other by relative path \u2014 no package,\n no Node built-in.\n- **`ctx` is all a function reaches:** `ctx.kv` (the space's store), `ctx.fetch(url, init)` to the hosts\n `allow.hosts` names (`*.example.com` for subdomains), `ctx.publish/grant/revoke` (channels),\n `ctx.data(\"products.json\")` (one file of the space's data, parsed \u2014 never imported), `ctx.log`, `ctx.user` (who\n asked, never their session). A secret is NAMED, never read: `ctx.fetch(url, { credential: \"stripe\",\n headers: { authorization: \"Bearer {{ credential.apiKey }}\" } })`. `signal` in the init cuts a slow request short\n (`AbortSignal.timeout(12000)`).\n- **Refuse with `ActionRefusal`** (from `@plitzi/sdk-runtime`): its message is written for whoever asked and\n reaches them (`{{ step.error }}`, a route's `400 { error }`); anything else thrown stays in the run's record.\n `new ActionRefusal(message, { code })` names it for code that catches it \u2014 compare `error.code`, never the message.\n- **An API on behalf of a visitor** (their calendar, their music) is an OAuth connection declared as data:\n `defineFunctions({ oauth: { calendar: { issuer, credential, scopes } } })` \u2014 `issuer` for OpenID, or\n `authorizeUrl`/`tokenUrl`; the credential holds the app's `clientId`/`clientSecret`. A route redirects to\n `(await ctx.oauth.connect(\"calendar\", { returnTo: \"/settings\" })).url` (`authorizeParams` adds to that one consent:\n `{ prompt: \"select_account\" }`), and `ctx.oauth.fetch(\"calendar\", url)` calls the API with the token written in;\n `status`, `disconnect` beside them. The platform keeps the token sealed and renews it \u2014 never put one in `kv`. The\n user registers `/fn/oauth/callback` on the space's host with the provider (`ctx.oauth.callbackUrl()` says the\n exact address, for a page that shows it). Not connected yet is a refusal with\n `code: \"oauth-not-connected\"`. `token` hands the access token only to a connection declaring `exposeToken: true`.\n- **Stateless:** nothing a function keeps in memory outlives the call \u2014 a module-level cache or counter starts empty\n every time, on whichever instance runs it. What must last goes in `ctx.kv`. A call gets 100 ms of CPU and 10 s;\n a task that needs more says so \u2014 `limits: { cpuMs: 1000, wallMs: 20000 }`, or `defineFunctions({ limits })` for\n all \u2014 up to the plan's ceiling. Asking above it is refused at save, never quietly cut.\n- **Routes** answer HTTP on the space's own host under `/fn/`: `routes: { \"GET /boards/:board\": (request, ctx) =>\n Response.json(\u2026) }` answers `/fn/boards/kanban` (`ctx.params.board`). No page may live under `/fn`.\n- **Saving builds and checks** the files: the batch is refused with each problem where it is (file and line). A\n namespace the platform uses (`kv`, `http`, `flow`\u2026) is refused.\n- **Try it** with `plitzi_try_function { task, params }` before a page relies on it: the value, the logs, the error.\n The live site runs what the space was last published with, never the draft. Running functions is part of the paid\n plans: on another plan they save, and a run answers why it did not start \u2014 tell the user rather than work around it.\n\n## Data\nJSON the space's pages read on the server and never serve \u2014 a catalog, prices, a menu: what a page needs whole and\nnobody edits element by element.\n\n- **Read** it as a provider does: `apiContainer` with `runtime: \"server\"` and `query: \"/data/products.json\"` reads\n `products.json` of `plitzi://data/{env}`, and the page arrives with it. A browser provider reading `/data/\u2026` is\n refused \u2014 the data is the server's.\n- **Write** it with `upsertDataFile { path, content }` (the whole file, as JSON text; `deleteDataFile { path }`\n removes one): a path of plain segments ending in `.json`. Saved whole, with the batch: a newer copy (somebody saved\n since you read it) refuses it \u2014 read it again.\n- **What a provider reads is in the page it renders**: data a page must not carry belongs in a server action, which\n answers only what is shown. The live site reads what the space was last published with, never the draft.\n\n## Realtime channels\nPages that see each other \u2014 cursors, presence, a shared board, a game. Three parts, all needed:\n\n1. **Declare** the topic pattern with `patchSettings { channels: { \"board:{id}\": { access: { mode: \"public\" }, publish: \"server\" } } }`.\n `publish: \"server\"` is for what must be validated and saved first; `\"clients\"` (the default) for what pages send\n directly \u2014 add `presence: true` for who-is-here.\n2. **Subscribe** with a `channel` element whose `topic` a pattern matches (`board:{{ id }}`, a route param).\n Its descendants bind `channel_<id>`: `connected`, `members`, `messages`, `last`, `retained`; flows use its `onMessage`,\n `onJoin`, `onLeave` triggers (`from`, `user` and the `state` the member announced \u2014 `onJoin` only for who\n came after this page) and its `publish` / `setPresence` callbacks.\n3. **Announce from the server**: an action whose last step is the `realtime.publish` task \u2014 validate, save, then say so.\n\nA topic no pattern matches is refused by the server and reported by the linter (`channel-topic`).\n\n**Private topics** (a room behind a password, a customer's order): declare the pattern `grant: true`. The action that\ndecides the visitor may be there ends with `realtime.grant { topic }` and answers its `grant`; the `channel`\nelement binds `grant` to it. Without one the topic is refused however well its name is known (`channel-grant`).\n`realtime.revoke { topic, grant }` takes one back \u2014 or all, naming none \u2014 and lets go whoever is on it with it.\n\n**State every screen shares** (a dashboard's lists, a board's settings): declare the pattern `retain: true` with\n`publish: \"server\"`. The server keeps the latest message of each type it says (`realtime.publish`) and hands them to\nevery page that joins \u2014 and to its `onMessage` flows, as if just said; the page binds `desk.retained.lists`, with no\nread of its own and no copy in `state`. `data: null` forgets a type; a topic keeps at most 64 types and 512 KB.\n\n**Two writers at once**: read-change-write with `kv.setIf` (written only if the value is still the one read \u2014 empty\n`expected` = only if nothing is there yet), ordered lists with `list.put` / `list.range`, and put\n`flow.rateLimit` first in any public action that writes.\n\n## Feature flags\nA flag turns a part of the space on or off without anyone editing it: a feature still being built, a version for\nbeta users, the old checkout kept until the new one ships. **Not a visibility** \u2014 visibility hides an element that is\nstill rendered; a flag decides whether it exists at all.\n\n- **Declare** with `upsertFlag { name, description?, value, rules? }`. `value` is its answer when no rule matches;\n `rules` are `[{ when, value }]` read top to bottom, the first match deciding. A rule's `when` is a rule group over\n `environment` (`main`, `development`, `staging`, `production`), `hostname`, `routeParams.<name>`,\n `queryParams.<name>` and the visitor: `user.authenticated`, `user.email`, `user.username`, `user.roles` (with\n `contains`). A group with no rules is skipped, never read as \"always\". `deleteFlag { name }` removes one.\n- **Roll out gradually** with `rollout: { percent, value }` on `upsertFlag`: when no rule matches, `percent` of the\n visitors get `value`, the rest the flag's `value`. Each visitor keeps their place (a cookie), so raising the percent\n keeps everyone who was in. Not access control: a visitor's place is theirs to change.\n- **Gate** an element with `flag` on `upsertElement` / `patchElement`: `\"newCheckout\"` exists only while the flag is\n on, `\"!newCheckout\"` only while it is off \u2014 put both side by side for a rollout. On `upsertPage` a gated-off page\n answers 404. `null` on a patch removes the gate. Gated off, it is not rendered and its server data is not\n resolved \u2014 but the space's document, gated elements included, still reaches the browser: a flag is not a secret.\n- **Read** it anywhere a source is read: `{{ flags.newCheckout }}` in a binding, a `when` of a flow step, a computed\n value \u2014 and in a server action's steps, where it is resolved on the server.\n\nA gate or a read naming a flag the space does not declare is an error (`flag-undeclared`, `flag-unknown`): an\nundeclared flag is off. A declared flag nothing reads is a warning (`flag-unused`) \u2014 remove it once the feature\nships. The draft applies flags at once. Flags are not part of a snapshot: each environment has one set, shared by every\nsnapshot it serves \u2014 publishing a snapshot sends the draft's with it (and the snapshot keeps a copy, as a fallback), the\nbuilder'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\nmay each override a flag; you only ever write the space's own.\n\n";
|
|
@@ -233,6 +233,9 @@ still rendered; a flag decides whether it exists at all.
|
|
|
233
233
|
\`environment\` (\`main\`, \`development\`, \`staging\`, \`production\`), \`hostname\`, \`routeParams.<name>\`,
|
|
234
234
|
\`queryParams.<name>\` and the visitor: \`user.authenticated\`, \`user.email\`, \`user.username\`, \`user.roles\` (with
|
|
235
235
|
\`contains\`). A group with no rules is skipped, never read as "always". \`deleteFlag { name }\` removes one.
|
|
236
|
+
- **Roll out gradually** with \`rollout: { percent, value }\` on \`upsertFlag\`: when no rule matches, \`percent\` of the
|
|
237
|
+
visitors get \`value\`, the rest the flag's \`value\`. Each visitor keeps their place (a cookie), so raising the percent
|
|
238
|
+
keeps everyone who was in. Not access control: a visitor's place is theirs to change.
|
|
236
239
|
- **Gate** an element with \`flag\` on \`upsertElement\` / \`patchElement\`: \`"newCheckout"\` exists only while the flag is
|
|
237
240
|
on, \`"!newCheckout"\` only while it is off — put both side by side for a rollout. On \`upsertPage\` a gated-off page
|
|
238
241
|
answers 404. \`null\` on a patch removes the gate. Gated off, it is not rendered and its server data is not
|
|
@@ -81,7 +81,7 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
|
|
|
81
81
|
const getSpace = () => spacePromise ??= loadSpace();
|
|
82
82
|
const server = new McpServer({
|
|
83
83
|
name: "plitzi-mcp",
|
|
84
|
-
version: "0.39.
|
|
84
|
+
version: "0.39.12"
|
|
85
85
|
}, { instructions: hasSpace ? serverInstructions : widgetsOnlyInstructions });
|
|
86
86
|
const { getChanges } = adapters;
|
|
87
87
|
registerResources(server, getSpace, MCP_ENV, log, hasSpace, getChanges ? (query) => getChanges(requireSpaceId(), MCP_ENV, query) : void 0);
|
|
@@ -156,6 +156,10 @@ export declare const applyShape: {
|
|
|
156
156
|
when: z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>;
|
|
157
157
|
value: z.ZodBoolean;
|
|
158
158
|
}, z.core.$strip>>>;
|
|
159
|
+
rollout: z.ZodOptional<z.ZodObject<{
|
|
160
|
+
percent: z.ZodNumber;
|
|
161
|
+
value: z.ZodBoolean;
|
|
162
|
+
}, z.core.$strip>>;
|
|
159
163
|
}, z.core.$strict>, z.ZodObject<{
|
|
160
164
|
type: z.ZodLiteral<"deleteFlag">;
|
|
161
165
|
name: z.ZodString;
|
|
@@ -152,6 +152,10 @@ export declare const documentOperation: z.ZodDiscriminatedUnion<readonly [z.ZodO
|
|
|
152
152
|
when: z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>;
|
|
153
153
|
value: z.ZodBoolean;
|
|
154
154
|
}, z.core.$strip>>>;
|
|
155
|
+
rollout: z.ZodOptional<z.ZodObject<{
|
|
156
|
+
percent: z.ZodNumber;
|
|
157
|
+
value: z.ZodBoolean;
|
|
158
|
+
}, z.core.$strip>>;
|
|
155
159
|
}, z.core.$strict>, z.ZodObject<{
|
|
156
160
|
type: z.ZodLiteral<"deleteFlag">;
|
|
157
161
|
name: z.ZodString;
|
|
@@ -1615,6 +1619,10 @@ export declare const operation: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1615
1619
|
when: z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>;
|
|
1616
1620
|
value: z.ZodBoolean;
|
|
1617
1621
|
}, z.core.$strip>>>;
|
|
1622
|
+
rollout: z.ZodOptional<z.ZodObject<{
|
|
1623
|
+
percent: z.ZodNumber;
|
|
1624
|
+
value: z.ZodBoolean;
|
|
1625
|
+
}, z.core.$strip>>;
|
|
1618
1626
|
}, z.core.$strict>, z.ZodObject<{
|
|
1619
1627
|
type: z.ZodLiteral<"deleteFlag">;
|
|
1620
1628
|
name: z.ZodString;
|
|
@@ -3367,6 +3375,10 @@ export declare const operations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
3367
3375
|
when: z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>;
|
|
3368
3376
|
value: z.ZodBoolean;
|
|
3369
3377
|
}, z.core.$strip>>>;
|
|
3378
|
+
rollout: z.ZodOptional<z.ZodObject<{
|
|
3379
|
+
percent: z.ZodNumber;
|
|
3380
|
+
value: z.ZodBoolean;
|
|
3381
|
+
}, z.core.$strip>>;
|
|
3370
3382
|
}, z.core.$strict>, z.ZodObject<{
|
|
3371
3383
|
type: z.ZodLiteral<"deleteFlag">;
|
|
3372
3384
|
name: z.ZodString;
|
|
@@ -5114,6 +5126,10 @@ export declare const documentOperations: z.ZodArray<z.ZodDiscriminatedUnion<read
|
|
|
5114
5126
|
when: z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>;
|
|
5115
5127
|
value: z.ZodBoolean;
|
|
5116
5128
|
}, z.core.$strip>>>;
|
|
5129
|
+
rollout: z.ZodOptional<z.ZodObject<{
|
|
5130
|
+
percent: z.ZodNumber;
|
|
5131
|
+
value: z.ZodBoolean;
|
|
5132
|
+
}, z.core.$strip>>;
|
|
5117
5133
|
}, z.core.$strict>, z.ZodObject<{
|
|
5118
5134
|
type: z.ZodLiteral<"deleteFlag">;
|
|
5119
5135
|
name: z.ZodString;
|
|
@@ -10,6 +10,10 @@ export declare const upsertFlagOp: z.ZodObject<{
|
|
|
10
10
|
when: z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>;
|
|
11
11
|
value: z.ZodBoolean;
|
|
12
12
|
}, z.core.$strip>>>;
|
|
13
|
+
rollout: z.ZodOptional<z.ZodObject<{
|
|
14
|
+
percent: z.ZodNumber;
|
|
15
|
+
value: z.ZodBoolean;
|
|
16
|
+
}, z.core.$strip>>;
|
|
13
17
|
}, z.core.$strip>;
|
|
14
18
|
export type UpsertFlag = z.infer<typeof upsertFlagOp>;
|
|
15
19
|
export declare const upsertFlag: (space: Space, env: Env, op: UpsertFlag) => OpResult;
|
|
@@ -13,14 +13,19 @@ var upsertFlagOp = z.object({
|
|
|
13
13
|
name: z.string(),
|
|
14
14
|
description: z.string().optional(),
|
|
15
15
|
value: z.boolean().describe("When no rule matches"),
|
|
16
|
-
rules: z.array(ruleInput).optional()
|
|
16
|
+
rules: z.array(ruleInput).optional(),
|
|
17
|
+
rollout: z.object({
|
|
18
|
+
percent: z.number().int().min(0).max(100),
|
|
19
|
+
value: z.boolean()
|
|
20
|
+
}).optional()
|
|
17
21
|
}).describe("Declare or replace a feature flag (guide: Feature flags).");
|
|
18
22
|
var upsertFlag = (space, env, op) => {
|
|
19
23
|
if (!isFlagName(op.name)) return fail("bad-value", "name", `"${op.name}" is not a flag name`, "Letters, digits and \"_\", starting with a letter or \"_\"");
|
|
20
24
|
const flag = {
|
|
21
25
|
...op.description ? { description: op.description } : {},
|
|
22
26
|
value: op.value,
|
|
23
|
-
rules: op.rules ?? []
|
|
27
|
+
rules: op.rules ?? [],
|
|
28
|
+
...op.rollout ? { rollout: op.rollout } : {}
|
|
24
29
|
};
|
|
25
30
|
if (!isSchemaFlag(flag)) return fail("bad-value", "rules", "A rule is { when: { combinator, rules: [...] }, value: true | false }", "Fix the rule groups");
|
|
26
31
|
const existed = Object.hasOwn(space.schema.flags ?? {}, op.name);
|
|
@@ -164,6 +164,10 @@ export declare const elementOps: {
|
|
|
164
164
|
when: import('zod').ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, import('zod/v4/core').$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>;
|
|
165
165
|
value: import('zod').ZodBoolean;
|
|
166
166
|
}, import('zod/v4/core').$strip>>>;
|
|
167
|
+
rollout: import('zod').ZodOptional<import('zod').ZodObject<{
|
|
168
|
+
percent: import('zod').ZodNumber;
|
|
169
|
+
value: import('zod').ZodBoolean;
|
|
170
|
+
}, import('zod/v4/core').$strip>>;
|
|
167
171
|
}, import('zod/v4/core').$strip>;
|
|
168
172
|
deleteFlag: import('zod').ZodObject<{
|
|
169
173
|
type: import('zod').ZodLiteral<"deleteFlag">;
|
|
@@ -154,6 +154,10 @@ export declare const renderShape: {
|
|
|
154
154
|
when: z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>;
|
|
155
155
|
value: z.ZodBoolean;
|
|
156
156
|
}, z.core.$strip>>>;
|
|
157
|
+
rollout: z.ZodOptional<z.ZodObject<{
|
|
158
|
+
percent: z.ZodNumber;
|
|
159
|
+
value: z.ZodBoolean;
|
|
160
|
+
}, z.core.$strip>>;
|
|
157
161
|
}, z.core.$strict>, z.ZodObject<{
|
|
158
162
|
type: z.ZodLiteral<"deleteFlag">;
|
|
159
163
|
name: z.ZodString;
|
|
@@ -159,6 +159,10 @@ export declare const renderWidgetShape: {
|
|
|
159
159
|
when: import('zod').ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, import('zod/v4/core').$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>;
|
|
160
160
|
value: import('zod').ZodBoolean;
|
|
161
161
|
}, import('zod/v4/core').$strip>>>;
|
|
162
|
+
rollout: import('zod').ZodOptional<import('zod').ZodObject<{
|
|
163
|
+
percent: import('zod').ZodNumber;
|
|
164
|
+
value: import('zod').ZodBoolean;
|
|
165
|
+
}, import('zod/v4/core').$strip>>;
|
|
162
166
|
}, import('zod/v4/core').$strict>, import('zod').ZodObject<{
|
|
163
167
|
type: import('zod').ZodLiteral<"deleteFlag">;
|
|
164
168
|
name: import('zod').ZodString;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-mcp",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.12",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@modelcontextprotocol/ext-apps": "^1.7.5",
|
|
49
49
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
50
|
-
"@plitzi/plitzi-sdk": "0.39.
|
|
51
|
-
"@plitzi/sdk-authoring": "0.39.
|
|
52
|
-
"@plitzi/sdk-kernel": "0.39.
|
|
53
|
-
"@plitzi/sdk-schema": "0.39.
|
|
54
|
-
"@plitzi/sdk-server": "0.39.
|
|
55
|
-
"@plitzi/sdk-shared": "0.39.
|
|
56
|
-
"@plitzi/sdk-style": "0.39.
|
|
50
|
+
"@plitzi/plitzi-sdk": "0.39.12",
|
|
51
|
+
"@plitzi/sdk-authoring": "0.39.12",
|
|
52
|
+
"@plitzi/sdk-kernel": "0.39.12",
|
|
53
|
+
"@plitzi/sdk-schema": "0.39.12",
|
|
54
|
+
"@plitzi/sdk-server": "0.39.12",
|
|
55
|
+
"@plitzi/sdk-shared": "0.39.12",
|
|
56
|
+
"@plitzi/sdk-style": "0.39.12",
|
|
57
57
|
"ejs": "^7.0.2",
|
|
58
58
|
"esbuild": "^0.28.2",
|
|
59
59
|
"zod": "^4.6.7"
|