@plitzi/sdk-mcp 0.39.0 → 0.39.2
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 +29 -0
- package/README.md +5 -1
- package/dist/createServer.d.ts +3 -2
- package/dist/createServer.js +3 -13
- package/dist/index.js +8 -8
- package/dist/modules/mcp/accessibilityOutline.js +1 -2
- package/dist/modules/mcp/apps/index.js +3 -4
- package/dist/modules/mcp/apps/render/index.js +3 -7
- package/dist/modules/mcp/apps/render/styles.js +2 -3
- package/dist/modules/mcp/apps/shared/assets.d.ts +6 -0
- package/dist/modules/mcp/apps/shared/assets.js +15 -4
- package/dist/modules/mcp/apps/shared/bundle.js +3 -4
- package/dist/modules/mcp/apps/shared/index.d.ts +1 -1
- package/dist/modules/mcp/apps/shared/page.js +3 -5
- package/dist/modules/mcp/apps/shared/registerApp.js +1 -2
- package/dist/modules/mcp/apps/shared/resolve.js +1 -2
- package/dist/modules/mcp/apps/shared/zodEnglishOnly.js +1 -2
- package/dist/modules/mcp/catalogs/observed.js +1 -2
- package/dist/modules/mcp/catalogs/pluginCatalog.d.ts +1 -1
- package/dist/modules/mcp/catalogs/pluginCatalog.js +1 -2
- package/dist/modules/mcp/catalogs/registry.d.ts +2 -1
- package/dist/modules/mcp/catalogs/registry.js +1 -2
- package/dist/modules/mcp/handler.d.ts +1 -1
- package/dist/modules/mcp/handler.js +1 -2
- package/dist/modules/mcp/helpers/callToolResult.js +1 -2
- package/dist/modules/mcp/helpers/components.js +1 -2
- package/dist/modules/mcp/helpers/computeVersion.js +1 -2
- package/dist/modules/mcp/helpers/guide/index.js +1 -2
- package/dist/modules/mcp/helpers/guide/instructions.js +1 -2
- package/dist/modules/mcp/helpers/guide/logic.js +1 -2
- package/dist/modules/mcp/helpers/guide/practice.js +5 -5
- package/dist/modules/mcp/helpers/guide/reference.d.ts +1 -1
- package/dist/modules/mcp/helpers/guide/reference.js +3 -3
- package/dist/modules/mcp/helpers/guide/server.d.ts +1 -1
- package/dist/modules/mcp/helpers/guide/server.js +3 -4
- package/dist/modules/mcp/helpers/guide/structure.d.ts +1 -1
- package/dist/modules/mcp/helpers/guide/structure.js +3 -2
- package/dist/modules/mcp/helpers/guide/styling.js +1 -2
- package/dist/modules/mcp/helpers/guide/values.js +1 -2
- package/dist/modules/mcp/helpers/interactions.js +1 -2
- package/dist/modules/mcp/helpers/log.d.ts +1 -1
- package/dist/modules/mcp/helpers/log.js +2 -3
- package/dist/modules/mcp/helpers/opResult.js +1 -2
- package/dist/modules/mcp/helpers/space.d.ts +2 -1
- package/dist/modules/mcp/helpers/space.js +1 -2
- package/dist/modules/mcp/helpers/uris.js +1 -2
- package/dist/modules/mcp/localScreenshotClient.js +9 -6
- package/dist/modules/mcp/previewClient.js +1 -2
- package/dist/modules/mcp/proxy/config.d.ts +1 -1
- package/dist/modules/mcp/proxy/config.js +2 -3
- package/dist/modules/mcp/proxy/fetch.js +1 -2
- package/dist/modules/mcp/proxy/grant.js +1 -2
- package/dist/modules/mcp/proxy/guard.js +2 -3
- package/dist/modules/mcp/proxy/handler.d.ts +1 -1
- package/dist/modules/mcp/proxy/handler.js +2 -3
- package/dist/modules/mcp/proxy/payload.js +1 -2
- package/dist/modules/mcp/proxy/rewrite.js +1 -2
- package/dist/modules/mcp/proxy/sign.js +1 -2
- package/dist/modules/mcp/proxy/types.js +1 -2
- package/dist/modules/mcp/resources/actions.js +2 -3
- package/dist/modules/mcp/resources/canonical.js +1 -2
- package/dist/modules/mcp/resources/connectors.js +2 -3
- package/dist/modules/mcp/resources/core.js +4 -5
- package/dist/modules/mcp/resources/data.js +1 -2
- package/dist/modules/mcp/resources/envelope.js +1 -2
- package/dist/modules/mcp/resources/explain.js +1 -2
- package/dist/modules/mcp/resources/functions.js +1 -2
- package/dist/modules/mcp/resources/primer.js +7 -8
- package/dist/modules/mcp/resources/register.d.ts +1 -1
- package/dist/modules/mcp/resources/register.js +6 -7
- package/dist/modules/mcp/resources/renderGuide.js +2 -3
- package/dist/modules/mcp/resources/router.js +3 -4
- package/dist/modules/mcp/resources/schema.js +3 -4
- package/dist/modules/mcp/resources/style.js +2 -3
- package/dist/modules/mcp/screenshotClient.js +6 -5
- package/dist/modules/mcp/server.d.ts +1 -1
- package/dist/modules/mcp/server.js +4 -5
- package/dist/modules/mcp/tools/activity.js +1 -2
- package/dist/modules/mcp/tools/apply/dispatch.js +4 -5
- package/dist/modules/mcp/tools/apply/index.d.ts +5 -0
- package/dist/modules/mcp/tools/apply/index.js +3 -4
- package/dist/modules/mcp/tools/apply/writeResult.js +1 -2
- package/dist/modules/mcp/tools/describeOperation.js +2 -3
- package/dist/modules/mcp/tools/index.js +1 -2
- package/dist/modules/mcp/tools/intents.js +3 -4
- package/dist/modules/mcp/tools/look.js +2 -3
- package/dist/modules/mcp/tools/operations/actions/deleteAction.js +2 -3
- package/dist/modules/mcp/tools/operations/actions/document.d.ts +2 -0
- package/dist/modules/mcp/tools/operations/actions/document.js +4 -3
- package/dist/modules/mcp/tools/operations/actions/index.d.ts +4 -0
- package/dist/modules/mcp/tools/operations/actions/index.js +1 -2
- package/dist/modules/mcp/tools/operations/actions/patchAction.d.ts +2 -0
- package/dist/modules/mcp/tools/operations/actions/patchAction.js +3 -4
- package/dist/modules/mcp/tools/operations/actions/upsertAction.d.ts +2 -0
- package/dist/modules/mcp/tools/operations/actions/upsertAction.js +3 -4
- package/dist/modules/mcp/tools/operations/closed.js +1 -2
- package/dist/modules/mcp/tools/operations/connectors/deleteConnector.js +2 -3
- package/dist/modules/mcp/tools/operations/connectors/index.js +1 -2
- package/dist/modules/mcp/tools/operations/connectors/manifest.js +1 -2
- package/dist/modules/mcp/tools/operations/connectors/patchConnector.js +3 -4
- package/dist/modules/mcp/tools/operations/connectors/upsertConnector.js +3 -4
- package/dist/modules/mcp/tools/operations/data/index.js +1 -2
- package/dist/modules/mcp/tools/operations/functions/index.js +2 -3
- package/dist/modules/mcp/tools/operations/index.d.ts +12 -0
- package/dist/modules/mcp/tools/operations/index.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/components/deleteComponent.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/components/upsertComponent.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +3 -4
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +3 -4
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +3 -4
- package/dist/modules/mcp/tools/operations/schema/flags/deleteFlag.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/flags/upsertFlag.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/operations.d.ts +1 -0
- package/dist/modules/mcp/tools/operations/schema/operations.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/pages/deleteLayout.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/pages/upsertLayout.js +3 -4
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +3 -4
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +1 -0
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +3 -3
- package/dist/modules/mcp/tools/operations/schema/shared.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/translator.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/write.js +3 -4
- package/dist/modules/mcp/tools/operations/schemaIds.js +1 -2
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +1 -2
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +2 -3
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +1 -2
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +1 -2
- package/dist/modules/mcp/tools/operations/style/fonts/deleteFont.js +2 -3
- package/dist/modules/mcp/tools/operations/style/fonts/upsertFont.js +2 -3
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +1 -2
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +2 -3
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +1 -2
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +1 -2
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +2 -3
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +1 -2
- package/dist/modules/mcp/tools/operations/style/operations.js +1 -2
- package/dist/modules/mcp/tools/operations/style/shared.js +1 -2
- package/dist/modules/mcp/tools/operations/style/translator.js +1 -2
- package/dist/modules/mcp/tools/operations/style/validate.js +1 -2
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +2 -3
- package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +2 -3
- package/dist/modules/mcp/tools/operations/style/write.js +2 -3
- package/dist/modules/mcp/tools/read.js +2 -3
- package/dist/modules/mcp/tools/render.d.ts +1 -0
- package/dist/modules/mcp/tools/render.js +3 -4
- package/dist/modules/mcp/tools/renderWidget.d.ts +1 -0
- package/dist/modules/mcp/tools/renderWidget.js +2 -3
- package/dist/modules/mcp/tools/search.js +2 -3
- package/dist/modules/mcp/tools/shared/draftBatch.js +2 -3
- package/dist/modules/mcp/tools/shared/effects.js +1 -2
- package/dist/modules/mcp/tools/shared/expandOperations.js +1 -2
- package/dist/modules/mcp/tools/shared/interactionReport.js +1 -2
- package/dist/modules/mcp/tools/shared/lintDraft.js +1 -2
- package/dist/modules/mcp/tools/shared/look.js +1 -2
- package/dist/modules/mcp/tools/shared/newSuggestions.js +1 -2
- package/dist/modules/mcp/tools/shared/normalizeOperations.js +1 -2
- package/dist/modules/mcp/tools/shared/repeats.js +1 -2
- package/dist/modules/mcp/tools/shared/tool.js +1 -2
- package/dist/modules/mcp/tools/shared/validator/batch.js +1 -2
- package/dist/modules/mcp/tools/shared/validator/bindings.js +1 -2
- package/dist/modules/mcp/tools/shared/validator/connectors.js +2 -3
- package/dist/modules/mcp/tools/shared/validator/context.js +1 -2
- package/dist/modules/mcp/tools/shared/validator/css.js +2 -3
- package/dist/modules/mcp/tools/shared/validator/elements.js +2 -3
- package/dist/modules/mcp/tools/shared/validator/index.js +20 -10
- package/dist/modules/mcp/tools/shared/validator/interactions.js +2 -3
- package/dist/modules/mcp/tools/shared/validator/refs.js +1 -2
- package/dist/modules/mcp/tools/test.js +1 -2
- package/dist/modules/mcp/tools/tryFunction.js +1 -2
- package/dist/modules/mcp/types/aiSchema.d.ts +2 -0
- package/dist/modules/mcp/types/screenshotTypes.d.ts +8 -0
- package/dist/options.d.ts +1 -1
- package/dist/pipeline.d.ts +2 -1
- package/dist/pipeline.js +4 -3
- package/dist/preview/createPreview.d.ts +1 -1
- package/dist/preview/createPreview.js +1 -2
- package/dist/preview.d.ts +7 -0
- package/dist/preview.js +1 -0
- package/dist/render.js +1 -1
- package/dist/server.js +3 -3
- package/dist/stages/mcp.d.ts +1 -1
- package/dist/stages/mcp.js +2 -3
- package/dist/stages/preview.d.ts +2 -1
- package/dist/stages/preview.js +3 -4
- package/dist/stages/proxy.d.ts +1 -1
- package/dist/stages/proxy.js +2 -3
- package/package.json +23 -16
|
@@ -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_BATCH`) \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 (`PREVIEW_UNAVAILABLE` 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_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.\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- `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_BATCH`) \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 (`PREVIEW_UNAVAILABLE` 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_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- `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";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/modules/mcp/helpers/guide/reference.ts
|
|
2
2
|
/** The guide's start: what to read, the tools, and how an element is addressed, made, moved and deleted. */
|
|
3
3
|
var referenceGuide = `# Plitzi AI MCP — usage guide
|
|
4
4
|
|
|
@@ -162,7 +162,8 @@ space already had is not repeated on every batch — and none of them blocks any
|
|
|
162
162
|
- \`repeated-shape\` — one structure written again with other words: a **component** with props
|
|
163
163
|
(\`upsertComponent { fromRef }\` turns one copy into it), or, for sibling rows of data, one \`repeatElement\`/\`list\`.
|
|
164
164
|
A few cards a person rewords by hand can stay cards; siblings that bind different data, keep different state, fill
|
|
165
|
-
from a template of their own or render on the server are controls written alike, and are not offered.
|
|
165
|
+
from a template of their own or render on the server are controls written alike, and are not offered. Copies apart
|
|
166
|
+
that read different sources are one component still: each instance binds its own to a \`json\` prop.
|
|
166
167
|
- \`content-attribute\` — a \`button\` or \`link\` whose children are only a \`text\` and/or a \`fontAwesome\`: its words
|
|
167
168
|
are its own \`content\` and the icon its \`icon\`. What the text's class adds (\`white-space: nowrap\`) moves to the
|
|
168
169
|
box's class — never the class itself; the icon's class goes in the \`icon\` slot.
|
|
@@ -245,5 +246,4 @@ You do not have to rewrite them.
|
|
|
245
246
|
(\`aria-selected\`), never \`active\` (the press): \`plitzi://explain/<type>\` says what each element writes on its node.
|
|
246
247
|
|
|
247
248
|
`;
|
|
248
|
-
//#endregion
|
|
249
249
|
export { referenceGuide };
|
|
@@ -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-server/functions`. 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-server/functions`): 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- **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";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/modules/mcp/helpers/guide/server.ts
|
|
2
2
|
/** The space's server side: connectors, server actions, functions, data, realtime channels and feature flags. */
|
|
3
3
|
var serverGuide = `## Connectors — CMS and API integrations
|
|
4
4
|
A **connector** is how a space reads real content from Strapi, WordPress, Contentful, Directus or any REST service.
|
|
@@ -150,7 +150,7 @@ any other (\`<namespace>.<action>\`), listed in \`plitzi://actions/{env}/tasks\`
|
|
|
150
150
|
- **Write** files with \`upsertFunctionFile { path, content }\` (whole files; \`deleteFunctionFile { path }\` removes
|
|
151
151
|
one). \`index.ts\` default-exports the definition:
|
|
152
152
|
\`export default defineFunctions({ allow: { hosts: ["api.example.com"] }, tasks: [{ namespace, action, title, params, run: async (params, ctx) => … }] })\`,
|
|
153
|
-
\`defineFunctions\` from \`@plitzi/sdk-
|
|
153
|
+
\`defineFunctions\` from \`@plitzi/sdk-runtime\`. Files import each other by relative path — no package,
|
|
154
154
|
no Node built-in.
|
|
155
155
|
- **\`ctx\` is all a function reaches:** \`ctx.kv\` (the space's store), \`ctx.fetch(url, init)\` to the hosts
|
|
156
156
|
\`allow.hosts\` names (\`*.example.com\` for subdomains), \`ctx.publish/grant/revoke\` (channels),
|
|
@@ -158,7 +158,7 @@ any other (\`<namespace>.<action>\`), listed in \`plitzi://actions/{env}/tasks\`
|
|
|
158
158
|
asked, never their session). A secret is NAMED, never read: \`ctx.fetch(url, { credential: "stripe",
|
|
159
159
|
headers: { authorization: "Bearer {{ credential.apiKey }}" } })\`. \`signal\` in the init cuts a slow request short
|
|
160
160
|
(\`AbortSignal.timeout(12000)\`).
|
|
161
|
-
- **Refuse with \`ActionRefusal\`** (from \`@plitzi/sdk-
|
|
161
|
+
- **Refuse with \`ActionRefusal\`** (from \`@plitzi/sdk-runtime\`): its message is written for whoever asked and
|
|
162
162
|
reaches them (\`{{ step.error }}\`, a route's \`400 { error }\`); anything else thrown stays in the run's record.
|
|
163
163
|
\`new ActionRefusal(message, { code })\` names it for code that catches it — compare \`error.code\`, never the message.
|
|
164
164
|
- **An API on behalf of a visitor** (their calendar, their music) is an OAuth connection declared as data:
|
|
@@ -248,5 +248,4 @@ builder's *Publish flags* sends only them, and a rollback keeps them. Above the
|
|
|
248
248
|
may each override a flag; you only ever write the space's own.
|
|
249
249
|
|
|
250
250
|
`;
|
|
251
|
-
//#endregion
|
|
252
251
|
export { serverGuide };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** How a space is put together: shared layouts, components, pages and folders, and its settings. */
|
|
2
|
-
export declare const structureGuide = "## Shared layouts \u2014 the chrome a page does NOT contain\nA page's tree is usually **not the whole page**. The header, the sidebar and the footer normally live in a **layout\ncontainer**: a shell several pages are rendered inside, so the navigation is authored once instead of once per page.\n\nIt is a **root of its own** \u2014 a `layoutContainer` element that no page owns and that is not in the page list \u2014 and\na page points at it with two attributes:\n- `layout` \u2014 the shell's ref. This is the whole of \"which chrome do I render inside\".\n- `layoutContainer` \u2014 the **slot**: the ref of a container INSIDE that shell where this page's own body is placed.\n\nSo a page with `layout: \"main-layout\"` renders `main-layout`'s whole tree, with its own elements dropped into the\none container it named. Two pages naming the same shell share every element of it \u2014 **editing the shell changes\nevery page that uses it**, which is the point and also the thing to say out loud before you touch one.\n\n**Reading them.**\n- `plitzi://schema/{env}/layouts` lists the shells: `ref`, `label`, `usedBy` (the pages), `slots`, `elementCount`.\n- Every page in `plitzi://schema/{env}/pages` carries `layout` and `layoutSlot` when it has them.\n- Read a shell exactly like a page: `plitzi://schema/{env}/pages/{layoutRef}` for its skeleton,\n `.../pages/{layoutRef}/styles` for its classes. `plitzi_search` reports a layout's elements with the layout as\n their `pageRef`.\n\n**Writing them.** Every element/binding/interaction op takes the shell's ref as its `pageRef` \u2014 there is no separate\nvocabulary:\n```json\n{ \"type\": \"upsertElement\", \"pageRef\": \"main-layout\", \"parentRef\": \"sidebar\",\n \"element\": { \"ref\": \"upgrade-card\", \"type\": \"container\", \"children\": [ \u2026 ] } }\n```\n- `upsertLayout` creates a shell (`ref`, `label`, `subType`). Put the chrome in it with `upsertElement`, including\n an empty container to serve as the slot.\n- `upsertPage { layout, layoutContainer }` attaches a page to it; `layout: null` detaches. A `layoutContainer` that\n is not an element of that shell is refused \u2014 stored, it would render the page's body where nobody sees it.\n- `deleteLayout` removes a shell and everything in it, and is **refused while any page still renders inside it**\n (the refusal names them). Destructive: what it deletes is on every page that uses it, so confirm first.\n\n**Only some pages?** A block that only some of a layout's pages carry (a newsletter band on two of ten) is not\nchrome: make it a **component** and place it on those pages.\n\n**Where does this element belong?** If the user asks for something \"on every page\" \u2014 a nav item, a banner, a footer\nlink, an upgrade prompt in the sidebar \u2014 it belongs in the LAYOUT, not in the page you happen to have open. Check\nthe page's `layout` first; if the element you are looking for is not in the page's own tree, it is in the shell.\n\n## Components \u2014 a subtree written once, placed anywhere\nA **component** is a reusable subtree: a product card, a pricing tier, a testimonial \u2014 written once and placed on\nany page as an **instance**. It is part of the space, so it is published, versioned and copied with it. Its tree is\nnot inside any page: it is a root of its own, like a layout, and **editing it changes every instance** \u2014 say so\nbefore you touch one.\n\nIt is not a **snippet**. The builder's *Save as snippet* keeps a copy of a block as a file people drop onto pages, and\neach drop is the page's own from then on. No operation here writes one: when someone wants a block that stays the same\neverywhere, that is a component.\n\nIt is **closed**. Inside, a binding or a template reads **`props`** \u2014 what each instance hands in \u2014 and the globals\n(`state`, `auth`, `navigation`, `theme`, `variables`, `computed`), never the page an instance sits on. A\ncomponent that needs a list row's record gets it as a prop: the INSTANCE binds it (`item: \"{{ list_rows.item }}\"`),\nthe component reads `{{ props.item.name }}`.\n\n**Reading them.** `plitzi://schema/{env}/components` lists them: `ref`, `label`, `props`, `slots`, `rootRef`,\n`instances`. Read one like a page: `plitzi://schema/{env}/pages/{componentRef}` (and `/styles`).\n\n**Writing them.**\n- `upsertComponent { ref, label?, props?, slots? }` declares one \u2014 with nothing in it but its root, `{ref}-root`, a\n container \u2014 or updates the declaration of one that exists (`props` is REPLACED whole). Fill it with every\n element/binding/interaction op you already know, with **`pageRef: \"<componentRef>\"`**:\n ```json\n { \"type\": \"upsertElement\", \"pageRef\": \"product-card\", \"parentRef\": \"product-card-root\",\n \"element\": { \"ref\": \"product-card-title\", \"type\": \"heading\" } }\n ```\n- `upsertComponent { ref, fromRef, instanceRef }` makes a component OF an element that already exists: the element\n and everything inside it become the component, and an instance named `instanceRef` takes its place, so the page\n renders what it did. The way to turn a repeated block into one.\n- A **prop** is `{ type, description, required?, default?, options? }`, `type` one of `text`, `textarea`,\n `number`, `boolean`, `select` (with `options`), `scalar`, `json`. Its name is read as `{{ props.<name> }}`, so\n letters, digits and `_` \u2014 and never one an instance already has (`referenceId`, `referenceType`, `slot`\u2026).\n- A **slot** is an element of the component's tree (usually an empty container) an instance fills with children.\n- `deleteComponent { ref }` removes one nothing places; while instances remain it is refused, naming them.\n\n**Placing one** is an element: a `reference` whose props say which component and hand in its props, one attribute each:\n```json\n{ \"type\": \"upsertElement\", \"pageRef\": \"shop\", \"parentRef\": \"grid\",\n \"element\": { \"ref\": \"lamp-card\", \"type\": \"reference\",\n \"props\": { \"referenceType\": \"component\", \"referenceId\": \"product-card\", \"title\": \"Lamp\" },\n \"children\": [ { \"ref\": \"lamp-buy\", \"type\": \"button\", \"props\": { \"content\": \"Buy\", \"slot\": \"product-card-actions\" } } ] } }\n```\nA required prop left out, a prop the component does not declare, a value of the wrong kind or a child naming a slot\nthe component does not have is reported by `plitzi_apply`'s `dryRun` \u2014 fix it before applying.\n\n## Pages & folders\n- **A page behind a feature flag**: `upsertPage { flag: \"labs\" }` answers 404 while the flag is off (see **Feature\n flags**); `flag: null` removes it.\n- **Always set a `slug` when creating a page** (`upsertPage`) \u2014 it is the page's URL path and good practice for a\n clean, stable route (e.g. `\"pricing\"` or `\"posts/:postId\"`). Omit it and the page ref is used as the slug,\n and `plitzi_apply` warns so you remember to set a meaningful one.\n- **A page slug is RELATIVE \u2014 do NOT start it with `/`.** The runtime prepends the leading slash (and any folder\n path) itself, so a leading slash doubles it. Write `\"pricing\"`, not `\"/pricing\"`. (upsertPage strips a leading\n slash for you, but write it relative.)\n- **Dynamic pages \u2014 route params.** A slug segment written `:name` (e.g. `\"posts/:postId\"`) is a **route param**,\n exactly like React Router. On that page it is readable **two ways**: as `{{name}}` inside a prop, and as the\n data-binding source **`navigation.routeParams.name`** (the `navigation` module source, global \u2014 bindable\n anywhere). So a blog is a `\"posts\"` list page plus a `\"posts/:postId\"` detail page whose `apiContainer` query\n binds `navigation.routeParams.postId` to fetch that one post. (`navigation.queryParams.<name>` exposes `?query=`\n string params the same way.)\n- **Navigate with the `Link` element, not an interaction.** `link` is a **container** \u2014 it wraps any children and\n navigates on click, so it is the default way to move between pages. Its `mode`: `\"page\"` links to another space\n page (set `href` to the target page, folder path resolved for you); `\"internal\"` takes a path inside the space and\n resolves `{{token}}` templates in it, so a row's \"view\" link is `mode:\"internal\", href:\"posts/{{postId}}\"`;\n `\"external\"` is a full URL. `target` is `self`/`blank`/`parent`/`top`. Reach for the `navigate` globalCallback\n only when navigation must be **one step inside a larger interaction flow** (e.g. save, then go) \u2014 for a plain link,\n use `link`.\n- **A link's words are its `content`, and an icon beside them its `icon`** \u2014 `{ \"type\": \"link\", \"props\": { \"mode\":\n \"page\", \"href\": \"pricing\", \"content\": \"Pricing\", \"icon\": \"fa-solid fa-arrow-right\", \"iconPlacement\": \"after\" } }`\n (a `button` takes the same two). The icon's class goes in the element's `icon` slot (`style.slots.icon`). With\n children too, `contentPlacement` puts the words `before` or `after` them. A `text` or `fontAwesome` inside is\n one element more, and a text keeps a colour of its own instead of the link's (and its hover).\n- **The link to the page being shown marks itself**: it carries `aria-current=\"page\"`, and its class's `current`\n state says how it looks \u2014 `{ \"type\": \"patchDefinition\", \"ref\": \"nav-link\", \"states\": { \"current\": { \"desktop\": {\n \"color\": \"var(--primary)\" } } } }`. So a header written once in a layout lights the right item on every page; never\n copy the header per page to style one item. A link for a section \u2014 a journal and its articles \u2014 takes\n `\"current\": \"section\"` in its props: current on every page under its path too (`aria-current=\"true\"`), the same\n state dressing it. The same state dresses any chosen one of a set: a pressed toggle (`aria-pressed` \u2014 a theme\n toggle's option slot) and a selected tab.\n- **A section of a page** is an element with an `anchor` (its `id` in the DOM: lowercase, digits, `-`; one per\n page, layouts included; not inside a list row or a component). A link lands on it with `hash`:\n `{ \"mode\": \"page\", \"href\": \"home\", \"hash\": \"plans\" }` goes to `/#plans` and scrolls there, from any page.\n\nPages can be grouped into **folders** (the sidebar tree). A folder is `{ ref, name, slug, parentId? }`; its `ref`\n**is its id**, and that id is what a page and a nested folder reference.\n- **Folder slugs PREPEND to the page URL \u2014 this is how nested URLs are built.** The full path is each ancestor\n folder's slug plus the page slug, joined by `/`: a page at slug `\"1-1-1\"` inside `folder-1` > `folder-1-1`\n resolves to `/folder-1/folder-1-1/1-1-1`. So a folder slug is part of the route; keep folder slugs relative too.\n- Create/rename/move a folder with `upsertFolder` (the `ref` you pass on create becomes its id \u2014 pick a stable one\n like `\"blog\"`). Nest it under another with `parentId` (a folder ref); `parentId: null` moves it back to the root.\n- Put a page in a folder with `upsertPage`'s `folder` (a folder ref). A page's `folder` is always either **empty\n (root)** or an **existing folder id**: `folder: null` or `folder: \"\"` moves it to the root, and any other value\n must resolve to a folder that already exists or is created earlier in the same batch \u2014 an unknown folder is\n rejected, never stored.\n- `deleteFolder` removes a folder and **promotes its contents up one level** \u2014 its child folders and its pages move\n to its parent (or the root). A folder cannot be nested under itself or one of its descendants.\n- **Disable a page** with `upsertPage`'s `enabled: false`; `enabled: true` re-enables it (defaults to enabled, and\n a page read reports its current `enabled`). Disabling only affects the **published SDK runtime** \u2014 the page stops\n being routable/accessible to end users. It stays fully **editable here**: you can still read it and apply any op to\n a disabled page. This does not delete it \u2014 `deletePage` does.\n- **A page that fills the window** (a dashboard, a board) takes `upsertPage`'s `documentScroll: \"locked\"`: the\n document holds still and only parts with `overflow: auto` scroll, so a finger on a tablet no longer drags and\n bounces the page. `\"noBounce\"` keeps the scroll without the rubber band; `null` undoes either. Never an\n `html, body` rule in `customCss`: that holds every page, and the site the space is a widget on.\n\n## Settings\nSpace-level configuration lives in `plitzi://settings/{env}` and is edited with a single **`patchSettings`** op\n(merge \u2014 only the fields you pass change):\n- `customCss` \u2014 **raw global CSS** injected for the whole space. Use it only for genuinely site-wide rules\n (`@keyframes`, `@font-face`, resets). To style an element, write a **definition** and attach it \u2014 never customCss.\n- `notifications` \u2014 how the toasts an `addNotification` step shows look: colours (`background`, `text`,\n `success`, `danger`, `warning`, `info`), shape (`radius`, `font`, `fontSize`, `fontWeight`, `lineHeight`,\n `minHeight`, `border`, `shadow`, `padding`) and the parts inside (`iconSize`, `iconGap`, `closeColor`,\n `closeOpacity`, `progressHeight`), one CSS value each \u2014 a token follows the theme: `{ \"type\": \"patchSettings\",\n \"notifications\": { \"background\": \"var(--card)\", \"iconSize\": \"18px\" } }`. Merged field by field, `null` removes one.\n It is stored as rules inside `customCss` but reads and changes apart from it: never write a `.Toastify__*` rule\n yourself.\n- `keepState` / `stateStorage` \u2014 keep the runtime state (`state.<key>`, what `setState` writes) across reloads,\n in `localStorage`/`sessionStorage`, filed under whoever is signed in. It is the space's setting \u2014 pages do not\n take one. `transientState` lists the top-level keys never kept (a filter, a demo, a panel left open) \u2014 or\n `keptState` the only ones kept, when few are (a dismissed notice); one of the two. Do not\n reset kept state from `onPageLoad` instead \u2014 it is restored later than that and undoes half of the reset.\n `paintedState` lists the kept keys the FIRST PAINT shows (the tool a toolbar shows, a name in an avatar): they go\n in a cookie too, so the server draws with them instead of the page swapping them in after load. Small values only.\n- **User provider / auth**: `userProvider` \u2014 `basic` for any HTTP+JSON backend, the name of a provider registered\n in the page, or `\"\"` for none \u2014 plus `tokenStorage`, the `loginUrl`/`userUrl`/`refreshUrl`/`logoutUrl`\n endpoints and the `detailsPath`/`tokenPath`/`refreshTokenPath`/`expirationTimePath` mapping that says where the\n values sit in their responses. `sessionHintCookie` is worth setting whenever the backend can: it names a readable\n cookie carrying only expiries, which is what lets a page answer \"nobody is signed in\" without a request.\n A space served by a self-hosted `createServer({ auth })` declares none of these: that server tells its pages where\n they sign in, and only what the space declares overrides it.\n On the Plitzi platform, `userProvider: \"server\"` signs visitors in with their Plitzi account on the space's own\n host: a `link` with `mode: \"external\"` to `/auth/sign-in?return=/` starts it, `authLogout` ends it.\n- `visitorRoles` \u2014 what each visitor role gives, `{ \"author\": [\"postPublish\"] }`: the permissions an action's\n `access: { mode: \"role\" }` and a page's `can()` ask for. A visitor holds ONLY the permissions of their roles here,\n never their account's. Who holds a role is given by email in the builder's Settings \u2192 Visitors \u2014 never in the\n space's `settings`.\n- `channels` \u2014 the realtime channels, by topic pattern (see **Realtime channels**). Merged pattern by pattern;\n `null` removes one.\n Example \u2014 inject a keyframe globally:\n `{ \"type\": \"patchSettings\", \"customCss\": \"@keyframes spin { to { transform: rotate(360deg); } }\" }`.\n\n";
|
|
2
|
+
export declare const structureGuide = "## Shared layouts \u2014 the chrome a page does NOT contain\nA page's tree is usually **not the whole page**. The header, the sidebar and the footer normally live in a **layout\ncontainer**: a shell several pages are rendered inside, so the navigation is authored once instead of once per page.\n\nIt is a **root of its own** \u2014 a `layoutContainer` element that no page owns and that is not in the page list \u2014 and\na page points at it with two attributes:\n- `layout` \u2014 the shell's ref. This is the whole of \"which chrome do I render inside\".\n- `layoutContainer` \u2014 the **slot**: the ref of a container INSIDE that shell where this page's own body is placed.\n\nSo a page with `layout: \"main-layout\"` renders `main-layout`'s whole tree, with its own elements dropped into the\none container it named. Two pages naming the same shell share every element of it \u2014 **editing the shell changes\nevery page that uses it**, which is the point and also the thing to say out loud before you touch one.\n\n**Reading them.**\n- `plitzi://schema/{env}/layouts` lists the shells: `ref`, `label`, `usedBy` (the pages), `slots`, `elementCount`.\n- Every page in `plitzi://schema/{env}/pages` carries `layout` and `layoutSlot` when it has them.\n- Read a shell exactly like a page: `plitzi://schema/{env}/pages/{layoutRef}` for its skeleton,\n `.../pages/{layoutRef}/styles` for its classes. `plitzi_search` reports a layout's elements with the layout as\n their `pageRef`.\n\n**Writing them.** Every element/binding/interaction op takes the shell's ref as its `pageRef` \u2014 there is no separate\nvocabulary:\n```json\n{ \"type\": \"upsertElement\", \"pageRef\": \"main-layout\", \"parentRef\": \"sidebar\",\n \"element\": { \"ref\": \"upgrade-card\", \"type\": \"container\", \"children\": [ \u2026 ] } }\n```\n- `upsertLayout` creates a shell (`ref`, `label`, `subType`). Put the chrome in it with `upsertElement`, including\n an empty container to serve as the slot.\n- `upsertPage { layout, layoutContainer }` attaches a page to it; `layout: null` detaches. A `layoutContainer` that\n is not an element of that shell is refused \u2014 stored, it would render the page's body where nobody sees it.\n- `deleteLayout` removes a shell and everything in it, and is **refused while any page still renders inside it**\n (the refusal names them). Destructive: what it deletes is on every page that uses it, so confirm first.\n\n**Only some pages?** A block that only some of a layout's pages carry (a newsletter band on two of ten) is not\nchrome: make it a **component** and place it on those pages.\n\n**Where does this element belong?** If the user asks for something \"on every page\" \u2014 a nav item, a banner, a footer\nlink, an upgrade prompt in the sidebar \u2014 it belongs in the LAYOUT, not in the page you happen to have open. Check\nthe page's `layout` first; if the element you are looking for is not in the page's own tree, it is in the shell.\n\n## Components \u2014 a subtree written once, placed anywhere\nA **component** is a reusable subtree: a product card, a pricing tier, a testimonial \u2014 written once and placed on\nany page as an **instance**. It is part of the space, so it is published, versioned and copied with it. Its tree is\nnot inside any page: it is a root of its own, like a layout, and **editing it changes every instance** \u2014 say so\nbefore you touch one.\n\nIt is not a **snippet**. The builder's *Save as snippet* keeps a copy of a block as a file people drop onto pages, and\neach drop is the page's own from then on. No operation here writes one: when someone wants a block that stays the same\neverywhere, that is a component.\n\nIt is **closed**. Inside, a binding or a template reads **`props`** \u2014 what each instance hands in \u2014 and the globals\n(`state`, `auth`, `navigation`, `theme`, `variables`, `computed`), never the page an instance sits on. A\ncomponent that needs a list row's record gets it as a prop: the INSTANCE binds it (`item: \"{{ list_rows.item }}\"`),\nthe component reads `{{ props.item.name }}`.\n\n**Reading them.** `plitzi://schema/{env}/components` lists them: `ref`, `label`, `props`, `slots`, `rootRef`,\n`instances`. Read one like a page: `plitzi://schema/{env}/pages/{componentRef}` (and `/styles`).\n\n**Writing them.**\n- `upsertComponent { ref, label?, props?, slots? }` declares one \u2014 with nothing in it but its root, `{ref}-root`, a\n container \u2014 or updates the declaration of one that exists (`props` is REPLACED whole). Fill it with every\n element/binding/interaction op you already know, with **`pageRef: \"<componentRef>\"`**:\n ```json\n { \"type\": \"upsertElement\", \"pageRef\": \"product-card\", \"parentRef\": \"product-card-root\",\n \"element\": { \"ref\": \"product-card-title\", \"type\": \"heading\" } }\n ```\n- `upsertComponent { ref, fromRef, instanceRef }` makes a component OF an element that already exists: the element\n and everything inside it become the component, and an instance named `instanceRef` takes its place, so the page\n renders what it did. The way to turn a repeated block into one.\n- A **prop** is `{ type, description, required?, default?, options? }`, `type` one of `text`, `textarea`,\n `number`, `boolean`, `select` (with `options`), `scalar`, `json`. Its name is read as `{{ props.<name> }}`, so\n letters, digits and `_` \u2014 and never one an instance already has (`referenceId`, `referenceType`, `slot`\u2026).\n- A **slot** is an element of the component's tree (usually an empty container) an instance fills with children.\n- `deleteComponent { ref }` removes one nothing places; while instances remain it is refused, naming them.\n\n**Placing one** is an element: a `reference` whose props say which component and hand in its props, one attribute each:\n```json\n{ \"type\": \"upsertElement\", \"pageRef\": \"shop\", \"parentRef\": \"grid\",\n \"element\": { \"ref\": \"lamp-card\", \"type\": \"reference\",\n \"props\": { \"referenceType\": \"component\", \"referenceId\": \"product-card\", \"title\": \"Lamp\" },\n \"children\": [ { \"ref\": \"lamp-buy\", \"type\": \"button\", \"props\": { \"content\": \"Buy\", \"slot\": \"product-card-actions\" } } ] } }\n```\nA required prop left out, a prop the component does not declare, a value of the wrong kind or a child naming a slot\nthe component does not have is reported by `plitzi_apply`'s `dryRun` \u2014 fix it before applying.\n\n## Pages & folders\n- **A page behind a feature flag**: `upsertPage { flag: \"labs\" }` answers 404 while the flag is off (see **Feature\n flags**); `flag: null` removes it.\n- **Always set a `slug` when creating a page** (`upsertPage`) \u2014 it is the page's URL path and good practice for a\n clean, stable route (e.g. `\"pricing\"` or `\"posts/:postId\"`). Omit it and the page ref is used as the slug,\n and `plitzi_apply` warns so you remember to set a meaningful one.\n- **A page slug is RELATIVE \u2014 do NOT start it with `/`.** The runtime prepends the leading slash (and any folder\n path) itself, so a leading slash doubles it. Write `\"pricing\"`, not `\"/pricing\"`. (upsertPage strips a leading\n slash for you, but write it relative.)\n- **Dynamic pages \u2014 route params.** A slug segment written `:name` (e.g. `\"posts/:postId\"`) is a **route param**,\n exactly like React Router. On that page it is readable **two ways**: as `{{name}}` inside a prop, and as the\n data-binding source **`navigation.routeParams.name`** (the `navigation` module source, global \u2014 bindable\n anywhere). So a blog is a `\"posts\"` list page plus a `\"posts/:postId\"` detail page whose `apiContainer` query\n binds `navigation.routeParams.postId` to fetch that one post. (`navigation.queryParams.<name>` exposes `?query=`\n string params the same way.)\n- **Navigate with the `Link` element, not an interaction.** `link` is a **container** \u2014 it wraps any children and\n navigates on click, so it is the default way to move between pages. Its `mode`: `\"page\"` links to another space\n page (set `href` to the target page, folder path resolved for you); `\"internal\"` takes a path inside the space and\n resolves `{{token}}` templates in it, so a row's \"view\" link is `mode:\"internal\", href:\"posts/{{postId}}\"`;\n `\"external\"` is a full URL. `target` is `self`/`blank`/`parent`/`top`. Reach for the `navigate` globalCallback\n only when navigation must be **one step inside a larger interaction flow** (e.g. save, then go) \u2014 for a plain link,\n use `link`.\n- **A link's words are its `content`, and an icon beside them its `icon`** \u2014 `{ \"type\": \"link\", \"props\": { \"mode\":\n \"page\", \"href\": \"pricing\", \"content\": \"Pricing\", \"icon\": \"fa-solid fa-arrow-right\", \"iconPlacement\": \"after\" } }`\n (a `button` takes the same two). The icon's class goes in the element's `icon` slot (`style.slots.icon`). With\n children too, `contentPlacement` puts the words `before` or `after` them. A `text` or `fontAwesome` inside is\n one element more, and a text keeps a colour of its own instead of the link's (and its hover).\n- **The link to the page being shown marks itself**: it carries `aria-current=\"page\"`, and its class's `current`\n state says how it looks \u2014 `{ \"type\": \"patchDefinition\", \"ref\": \"nav-link\", \"states\": { \"current\": { \"desktop\": {\n \"color\": \"var(--primary)\" } } } }`. So a header written once in a layout lights the right item on every page; never\n copy the header per page to style one item. A link for a section \u2014 a journal and its articles \u2014 takes\n `\"current\": \"section\"` in its props: current on every page under its path too (`aria-current=\"true\"`), the same\n state dressing it. The same state dresses any chosen one of a set: a pressed toggle (`aria-pressed` \u2014 a theme\n toggle's option slot) and a selected tab.\n- **A section of a page** is an element with an `anchor` (its `id` in the DOM: lowercase, digits, `-`; one per\n page, layouts included; not inside a list row or a component). A link lands on it with `hash`:\n `{ \"mode\": \"page\", \"href\": \"home\", \"hash\": \"plans\" }` goes to `/#plans` and scrolls there, from any page.\n\nPages can be grouped into **folders** (the sidebar tree). A folder is `{ ref, name, slug, parentId? }`; its `ref`\n**is its id**, and that id is what a page and a nested folder reference.\n- **Folder slugs PREPEND to the page URL \u2014 this is how nested URLs are built.** The full path is each ancestor\n folder's slug plus the page slug, joined by `/`: a page at slug `\"1-1-1\"` inside `folder-1` > `folder-1-1`\n resolves to `/folder-1/folder-1-1/1-1-1`. So a folder slug is part of the route; keep folder slugs relative too.\n- Create/rename/move a folder with `upsertFolder` (the `ref` you pass on create becomes its id \u2014 pick a stable one\n like `\"blog\"`). Nest it under another with `parentId` (a folder ref); `parentId: null` moves it back to the root.\n- Put a page in a folder with `upsertPage`'s `folder` (a folder ref). A page's `folder` is always either **empty\n (root)** or an **existing folder id**: `folder: null` or `folder: \"\"` moves it to the root, and any other value\n must resolve to a folder that already exists or is created earlier in the same batch \u2014 an unknown folder is\n rejected, never stored.\n- `deleteFolder` removes a folder and **promotes its contents up one level** \u2014 its child folders and its pages move\n to its parent (or the root). A folder cannot be nested under itself or one of its descendants.\n- **Disable a page** with `upsertPage`'s `enabled: false`; `enabled: true` re-enables it (defaults to enabled, and\n a page read reports its current `enabled`). Disabling only affects the **published SDK runtime** \u2014 the page stops\n being routable/accessible to end users. It stays fully **editable here**: you can still read it and apply any op to\n a disabled page. This does not delete it \u2014 `deletePage` does.\n- **A page that fills the window** (a dashboard, a board) takes `upsertPage`'s `documentScroll: \"locked\"`: the\n document holds still and only parts with `overflow: auto` scroll, so a finger on a tablet no longer drags and\n bounces the page. `\"noBounce\"` keeps the scroll without the rubber band; `null` undoes either. Never an\n `html, body` rule in `customCss`: that holds every page, and the site the space is a widget on.\n\n## Settings\nSpace-level configuration lives in `plitzi://settings/{env}` and is edited with a single **`patchSettings`** op\n(merge \u2014 only the fields you pass change):\n- `customCss` \u2014 **raw global CSS** injected for the whole space. Use it only for genuinely site-wide rules\n (`@keyframes`, `@font-face`, resets). To style an element, write a **definition** and attach it \u2014 never customCss.\n- `notifications` \u2014 how the toasts an `addNotification` step shows look: colours (`background`, `text`,\n `success`, `danger`, `warning`, `info`), shape (`radius`, `font`, `fontSize`, `fontWeight`, `lineHeight`,\n `minHeight`, `border`, `shadow`, `padding`) and the parts inside (`iconSize`, `iconGap`, `closeColor`,\n `closeOpacity`, `progressHeight`), one CSS value each \u2014 a token follows the theme: `{ \"type\": \"patchSettings\",\n \"notifications\": { \"background\": \"var(--card)\", \"iconSize\": \"18px\" } }`. Merged field by field, `null` removes one.\n It is stored as rules inside `customCss` but reads and changes apart from it: never write a `.Toastify__*` rule\n yourself.\n- `keepState` / `stateStorage` \u2014 keep the runtime state (`state.<key>`, what `setState` writes) across reloads,\n in `localStorage`/`sessionStorage`, filed under whoever is signed in. It is the space's setting \u2014 pages do not\n take one. `transientState` lists the top-level keys never kept (a filter, a demo, a panel left open) \u2014 or\n `keptState` the only ones kept, when few are (a dismissed notice); one of the two. Do not\n reset kept state from `onPageLoad` instead \u2014 it is restored later than that and undoes half of the reset.\n `paintedState` lists the kept keys the FIRST PAINT shows (the tool a toolbar shows, a name in an avatar): they go\n in a cookie too, so the server draws with them instead of the page swapping them in after load. Small values only.\n `browserState` lists the kept keys that are the BROWSER's, not the account's (the cookie consent): signing in, out\n or as somebody else forgets the rest, never these. Never what belongs to an account.\n- **User provider / auth**: `userProvider` \u2014 `basic` for any HTTP+JSON backend, the name of a provider registered\n in the page, or `\"\"` for none \u2014 plus `tokenStorage`, the `loginUrl`/`userUrl`/`refreshUrl`/`logoutUrl`\n endpoints and the `detailsPath`/`tokenPath`/`refreshTokenPath`/`expirationTimePath` mapping that says where the\n values sit in their responses. `sessionHintCookie` is worth setting whenever the backend can: it names a readable\n cookie carrying only expiries, which is what lets a page answer \"nobody is signed in\" without a request.\n A space served by a self-hosted `createServer({ auth })` declares none of these: that server tells its pages where\n they sign in, and only what the space declares overrides it.\n On the Plitzi platform, `userProvider: \"server\"` signs visitors in with their Plitzi account on the space's own\n host: a `link` with `mode: \"external\"` to `/auth/sign-in?return=/` starts it, `authLogout` ends it.\n- `visitorRoles` \u2014 what each visitor role gives, `{ \"author\": [\"postPublish\"] }`: the permissions an action's\n `access: { mode: \"role\" }` and a page's `can()` ask for. A visitor holds ONLY the permissions of their roles here,\n never their account's. Who holds a role is given by email in the builder's Settings \u2192 Visitors \u2014 never in the\n space's `settings`.\n- `channels` \u2014 the realtime channels, by topic pattern (see **Realtime channels**). Merged pattern by pattern;\n `null` removes one.\n Example \u2014 inject a keyframe globally:\n `{ \"type\": \"patchSettings\", \"customCss\": \"@keyframes spin { to { transform: rotate(360deg); } }\" }`.\n\n";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/modules/mcp/helpers/guide/structure.ts
|
|
2
2
|
/** How a space is put together: shared layouts, components, pages and folders, and its settings. */
|
|
3
3
|
var structureGuide = `## Shared layouts — the chrome a page does NOT contain
|
|
4
4
|
A page's tree is usually **not the whole page**. The header, the sidebar and the footer normally live in a **layout
|
|
@@ -164,6 +164,8 @@ Space-level configuration lives in \`plitzi://settings/{env}\` and is edited wit
|
|
|
164
164
|
reset kept state from \`onPageLoad\` instead — it is restored later than that and undoes half of the reset.
|
|
165
165
|
\`paintedState\` lists the kept keys the FIRST PAINT shows (the tool a toolbar shows, a name in an avatar): they go
|
|
166
166
|
in a cookie too, so the server draws with them instead of the page swapping them in after load. Small values only.
|
|
167
|
+
\`browserState\` lists the kept keys that are the BROWSER's, not the account's (the cookie consent): signing in, out
|
|
168
|
+
or as somebody else forgets the rest, never these. Never what belongs to an account.
|
|
167
169
|
- **User provider / auth**: \`userProvider\` — \`basic\` for any HTTP+JSON backend, the name of a provider registered
|
|
168
170
|
in the page, or \`""\` for none — plus \`tokenStorage\`, the \`loginUrl\`/\`userUrl\`/\`refreshUrl\`/\`logoutUrl\`
|
|
169
171
|
endpoints and the \`detailsPath\`/\`tokenPath\`/\`refreshTokenPath\`/\`expirationTimePath\` mapping that says where the
|
|
@@ -183,5 +185,4 @@ Space-level configuration lives in \`plitzi://settings/{env}\` and is edited wit
|
|
|
183
185
|
\`{ "type": "patchSettings", "customCss": "@keyframes spin { to { transform: rotate(360deg); } }" }\`.
|
|
184
186
|
|
|
185
187
|
`;
|
|
186
|
-
//#endregion
|
|
187
188
|
export { structureGuide };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/modules/mcp/helpers/guide/styling.ts
|
|
2
2
|
/** Styling: classes and selectors, variants and state, variables, tokens and fonts. */
|
|
3
3
|
var stylingGuide = `## Styling (crosses both schemas)
|
|
4
4
|
- **Mind the type's intrinsic default style.** A type renders with a base CSS *before* any class is attached — read
|
|
@@ -114,5 +114,4 @@ Any ancestor counts, not only the parent; the class's own states and variants wi
|
|
|
114
114
|
in their fallback.
|
|
115
115
|
|
|
116
116
|
`;
|
|
117
|
-
//#endregion
|
|
118
117
|
export { stylingGuide };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BUILTIN_TRANSFORMERS, GLOBAL_SOURCES } from "@plitzi/sdk-authoring";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/helpers/guide/values.ts
|
|
3
3
|
var GLOBALS = GLOBAL_SOURCES.map((source) => `\`${source}\``).join(", ");
|
|
4
4
|
var OTHER_TRANSFORMERS = Object.keys(BUILTIN_TRANSFORMERS).filter((action) => action !== "twigTemplate").map((action) => `\`${action}\``).join(", ");
|
|
5
|
-
//#endregion
|
|
6
5
|
export { GLOBALS, OTHER_TRANSFORMERS };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { applyBuiltinCallback, applyElementCallback, applyUtility } from "../catalogs/index.js";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/helpers/interactions.ts
|
|
3
3
|
var BINDING_CATEGORIES = [
|
|
4
4
|
"attributes",
|
|
5
5
|
"style",
|
|
@@ -130,5 +130,4 @@ var bindingsToAI = (bindings) => {
|
|
|
130
130
|
}
|
|
131
131
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
132
132
|
};
|
|
133
|
-
//#endregion
|
|
134
133
|
export { BINDING_CATEGORIES, NULLISH_ELEMENT_IDS, bindingToAI, bindingsToAI, flowsFromInteractions, materializeFlow, newNodeId };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ServerLogger } from '@plitzi/sdk-
|
|
1
|
+
import { ServerLogger } from '@plitzi/sdk-kernel/types';
|
|
2
2
|
export interface McpLog {
|
|
3
3
|
toolCall(name: string, args: unknown, ms: number, error?: unknown): void;
|
|
4
4
|
resourceRead(uri: string, ms: number, error?: unknown): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { renderLogEvent } from "@plitzi/sdk-
|
|
2
|
-
|
|
1
|
+
import { renderLogEvent } from "@plitzi/sdk-kernel/log";
|
|
2
|
+
// src/modules/mcp/helpers/log.ts
|
|
3
3
|
var MCP_DEBUG = process.env.MCP_DEBUG === "1";
|
|
4
4
|
var MCP_LOG_ARGS = process.env.MCP_LOG_ARGS === "1";
|
|
5
5
|
var shapeOf = (value, depth = 0) => {
|
|
@@ -60,5 +60,4 @@ var createMcpLog = (logger) => {
|
|
|
60
60
|
})
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
|
-
//#endregion
|
|
64
63
|
export { createMcpLog };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/modules/mcp/helpers/opResult.ts
|
|
2
2
|
var empty = () => ({
|
|
3
3
|
created: 0,
|
|
4
4
|
updated: 0,
|
|
@@ -14,5 +14,4 @@ var fail = (path, message, hint, validValues) => ({
|
|
|
14
14
|
validValues
|
|
15
15
|
}]
|
|
16
16
|
});
|
|
17
|
-
//#endregion
|
|
18
17
|
export { empty, fail };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AIElementDetail } from '../types';
|
|
2
|
-
import {
|
|
2
|
+
import { ComponentCatalog } from '@plitzi/sdk-kernel/types';
|
|
3
|
+
import { ActionEntry, ActionTaskDescriptor, ConnectorEntry, DataDraft, Element, FunctionsDraft, PageFolder, Schema, Style } from '@plitzi/sdk-shared';
|
|
3
4
|
import { TSpaceEntitlements } from '@plitzi/sdk-shared/network';
|
|
4
5
|
/** The working view the tools read and mutate: the two Plitzi schemas (elements + style), which the platform
|
|
5
6
|
* stores and persists as separate documents (Space model / Style model), plus the space's `connectors` — a third
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { descendants } from "@plitzi/sdk-schema";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/helpers/space.ts
|
|
3
3
|
var cloneSpace = (space) => ({
|
|
4
4
|
schema: structuredClone(space.schema),
|
|
5
5
|
style: structuredClone(space.style),
|
|
@@ -300,5 +300,4 @@ var ReadOnlyGrantError = class extends Error {
|
|
|
300
300
|
this.name = "ReadOnlyGrantError";
|
|
301
301
|
}
|
|
302
302
|
};
|
|
303
|
-
//#endregion
|
|
304
303
|
export { NoSpaceError, ReadOnlyGrantError, cloneSpace, descendantCount, elementById, emptySpace, emptySpaceMessage, findActionEntry, findConnectorEntry, findElementByRef, findFolderByRef, findLayoutByRef, findPageByRef, findRootByRef, folderAncestorIds, getLayoutElements, getPageElements, indexAddElement, indexAddLayout, indexAddPage, indexInvalidateDetails, indexRemoveElements, indexRemoveLayout, indexRemovePage, invalidateIndex, isPageElement, nameOf, noSpaceErrorCode, orderedChildren, pageFoldersOf, pageRefOfElement, pagesUsingLayout, readOnlyGrantErrorCode, readOnlyGrantMessage, resolveRef, routeParamNames, slugRouteParams, slugify, sortFolders, spaceIndex, strOr, unauthorizedSpaceMessage };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/modules/mcp/helpers/uris.ts
|
|
2
2
|
var guideUri = "plitzi://guide";
|
|
3
3
|
var typesUri = "plitzi://types";
|
|
4
4
|
var cssPropertiesUri = "plitzi://css-properties";
|
|
@@ -63,5 +63,4 @@ var itemTemplates = (env) => [
|
|
|
63
63
|
/** The remainder of `uri` after `prefix`, or undefined when it does not start with it — so a resolver matches a
|
|
64
64
|
* family and extracts its ref in one step, without repeating the prefix string for both the startsWith and slice. */
|
|
65
65
|
var afterPrefix = (uri, prefix) => uri.startsWith(prefix) ? uri.slice(prefix.length) : void 0;
|
|
66
|
-
//#endregion
|
|
67
66
|
export { actionTasksUri, actionUri, actionsUri, afterPrefix, aliasedRoots, changesUri, componentsUri, connectorPresetsUri, connectorUri, connectorsUri, cssPropertiesUri, dataFileUri, dataSourcesUri, dataUri, defUri, defsUri, elementUri, flagsUri, folderUri, foldersUri, fontUri, fontsUri, functionFileUri, functionsUri, globalUri, globalsUri, guideUri, idUri, idsUri, interactionsUri, itemTemplates, layoutsUri, pageUri, pagesUri, primerUri, schemaVarsUri, settingsUri, styleVarUri, styleVarsUri, typesUri };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { outlineOfSnapshot, outlineOfTree } from "./accessibilityOutline.js";
|
|
2
|
-
import { PREVIEW_TOKEN_PARAM } from "@plitzi/sdk-
|
|
3
|
-
|
|
2
|
+
import { PREVIEW_TOKEN_PARAM } from "@plitzi/sdk-kernel/identity";
|
|
3
|
+
// src/modules/mcp/localScreenshotClient.ts
|
|
4
4
|
/**
|
|
5
5
|
* Grow the window to whatever actually scrolls before shooting.
|
|
6
6
|
*
|
|
@@ -72,7 +72,7 @@ var emulateCaptureMedia = async (page, colorScheme) => {
|
|
|
72
72
|
var createLocalScreenshotClient = async ({ renderBaseUrl, ignoreHttpsErrors = true }) => {
|
|
73
73
|
const driver = await resolveLocalBrowser();
|
|
74
74
|
if (!driver) return;
|
|
75
|
-
return { async capture({ pagePath, token, viewports, fullPage = true, colorScheme, views = ["image"] }) {
|
|
75
|
+
return { async capture({ pagePath, token, viewports, fullPage = true, colorScheme, views = ["image"], format = "png", quality = 80 }) {
|
|
76
76
|
const url = new URL(pagePath, renderBaseUrl);
|
|
77
77
|
if (token) url.searchParams.set(PREVIEW_TOKEN_PARAM, token);
|
|
78
78
|
/**
|
|
@@ -109,13 +109,17 @@ var createLocalScreenshotClient = async ({ renderBaseUrl, ignoreHttpsErrors = tr
|
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
if (views.includes("image")) {
|
|
112
|
-
const shot = await page.screenshot({
|
|
112
|
+
const shot = await page.screenshot(format === "webp" ? {
|
|
113
|
+
type: "webp",
|
|
114
|
+
quality,
|
|
115
|
+
fullPage
|
|
116
|
+
} : {
|
|
113
117
|
type: "png",
|
|
114
118
|
fullPage
|
|
115
119
|
});
|
|
116
120
|
images.push({
|
|
117
121
|
label: viewport.label,
|
|
118
|
-
mimeType: "image/png",
|
|
122
|
+
mimeType: format === "webp" ? "image/webp" : "image/png",
|
|
119
123
|
data: Buffer.from(shot).toString("base64")
|
|
120
124
|
});
|
|
121
125
|
}
|
|
@@ -141,5 +145,4 @@ var createLocalScreenshotClient = async ({ renderBaseUrl, ignoreHttpsErrors = tr
|
|
|
141
145
|
}
|
|
142
146
|
} };
|
|
143
147
|
};
|
|
144
|
-
//#endregion
|
|
145
148
|
export { createLocalScreenshotClient, resolveLocalBrowser };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/modules/mcp/previewClient.ts
|
|
2
2
|
/** Default `PreviewClient`: POSTs the preview request to the SSR `/preview` endpoint over HTTP. Used when the
|
|
3
3
|
* MCP server is a separate process from the SSR renderer (the common case). A network/HTTP failure surfaces as
|
|
4
4
|
* an `ok:false` result rather than throwing, so the calling tool can degrade gracefully. */
|
|
@@ -27,5 +27,4 @@ var createHttpPreviewClient = ({ url, secret, fetchImpl = fetch }) => ({ async r
|
|
|
27
27
|
};
|
|
28
28
|
return await res.json();
|
|
29
29
|
} });
|
|
30
|
-
//#endregion
|
|
31
30
|
export { createHttpPreviewClient };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResourceProxy, ResourceProxySettings } from './types';
|
|
2
2
|
import { McpProxyOptions } from '../../../options';
|
|
3
|
-
import { SSRRequest } from '@plitzi/sdk-
|
|
3
|
+
import { SSRRequest } from '@plitzi/sdk-kernel/types';
|
|
4
4
|
export declare const PROXY_PATH = "/__proxy";
|
|
5
5
|
/** What this deployment serves at its widget endpoint, or undefined when it serves none. A secret is what turns it
|
|
6
6
|
* on: without one the endpoint could not tell its own widgets' URLs from anyone else's, and an unsigned fetcher
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { connectionId } from "./sign.js";
|
|
2
2
|
import { DEFAULT_PROXY_TOOLS } from "./types.js";
|
|
3
|
-
import { requestOrigin } from "@plitzi/sdk-
|
|
4
|
-
|
|
3
|
+
import { requestOrigin } from "@plitzi/sdk-kernel/http";
|
|
4
|
+
// src/modules/mcp/proxy/config.ts
|
|
5
5
|
var PROXY_PATH = "/__proxy";
|
|
6
6
|
var MAX_BYTES = 8388608;
|
|
7
7
|
var TTL_SECONDS = 604800;
|
|
@@ -58,5 +58,4 @@ var grantingProxy = (settings, req, identity) => {
|
|
|
58
58
|
* and lasts as long as the widget does; a tool that WRITES a space (plitzi_apply) would persist those URLs into
|
|
59
59
|
* content the user owns, which is why it is not on the list unless a deployment puts it there deliberately. */
|
|
60
60
|
var proxyForTool = (proxy, tool) => proxy?.tools.includes(tool) ? proxy : void 0;
|
|
61
|
-
//#endregion
|
|
62
61
|
export { PROXY_PATH, grantingProxy, proxyForTool, proxySettings, requestProxy };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isPublicHost } from "./guard.js";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/proxy/fetch.ts
|
|
3
3
|
var TIMEOUT_MS = 1e4;
|
|
4
4
|
var MAX_REDIRECTS = 4;
|
|
5
5
|
var ALLOWED_TYPES = {
|
|
@@ -87,5 +87,4 @@ var fetchResource = async (target, kind, maxBytes) => {
|
|
|
87
87
|
clearTimeout(timer);
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
|
-
//#endregion
|
|
91
90
|
export { fetchResource };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sign, verify } from "./sign.js";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/proxy/grant.ts
|
|
3
3
|
/** The single query parameter a proxied URL carries: `<signature>.<kind>.<expiry>.<connection>.<target>`. One
|
|
4
4
|
* parameter rather than several so the URL holds no `&` — these end up inside HTML attributes and markdown
|
|
5
5
|
* links, where an unescaped ampersand is the kind of detail that silently truncates a URL. */
|
|
@@ -63,5 +63,4 @@ var readGrant = (param, secret) => {
|
|
|
63
63
|
* `data:`/`blob:` carry their own bytes, and a relative URL has no origin to reach in the first place. */
|
|
64
64
|
var isRemote = (url) => /^https?:\/\//i.test(url);
|
|
65
65
|
var isGranted = (url, proxy) => url.startsWith(`${proxy.endpoint}?`);
|
|
66
|
-
//#endregion
|
|
67
66
|
export { grantUrl, isGranted, isRemote, readGrant };
|