@plitzi/sdk-shared 0.32.3 → 0.32.5

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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @plitzi/sdk-shared
2
2
 
3
+ ## 0.32.5
4
+
5
+ ### Patch Changes
6
+
7
+ - v0.32.4
8
+ - Updated dependencies
9
+ - @plitzi/nexus@0.32.5
10
+
11
+ ## 0.32.4
12
+
13
+ ### Patch Changes
14
+
15
+ - v0.32.4
16
+ - Updated dependencies
17
+ - @plitzi/nexus@0.32.4
18
+
3
19
  ## 0.32.3
4
20
 
5
21
  ### Patch Changes
@@ -4,19 +4,21 @@ import n from "./dateConverter.mjs";
4
4
  import r from "./staticValue.mjs";
5
5
  import i from "./stringToArray.mjs";
6
6
  import a from "./styleSelector.mjs";
7
- import o from "./twigTemplate.mjs";
7
+ import o from "./styleVariant.mjs";
8
+ import s from "./twigTemplate.mjs";
8
9
  //#region src/dataSource/utility/index.ts
9
- var s = {
10
- twigTemplate: o,
10
+ var c = {
11
+ twigTemplate: s,
11
12
  dateConverter: n,
12
13
  staticValue: r,
13
14
  capitalize: t,
14
15
  arrayMap: e,
15
16
  stringToArray: i,
16
- styleSelector: a
17
- }, c = Object.values(s).map(({ title: e, action: t }) => ({
17
+ styleSelector: a,
18
+ styleVariant: o
19
+ }, l = Object.values(c).map(({ title: e, action: t }) => ({
18
20
  label: e,
19
21
  value: t
20
22
  }));
21
23
  //#endregion
22
- export { s as default, c as utilityOptions };
24
+ export { c as default, l as utilityOptions };
@@ -20,7 +20,16 @@ var t = {
20
20
  label: "Selector",
21
21
  defaultValue: "",
22
22
  type: "select",
23
- options: []
23
+ options: (e, t, n) => {
24
+ let r = n?.stylePlatform;
25
+ return r ? Object.keys(r).map((e) => ({
26
+ label: e,
27
+ options: Object.values(r[e]).filter((e) => e.type === "class").map((e) => ({
28
+ label: e.name,
29
+ value: e.name
30
+ }))
31
+ })) : [];
32
+ }
24
33
  }
25
34
  },
26
35
  preview: {
@@ -0,0 +1,3 @@
1
+ import { DataSourceUtility } from '../../types';
2
+ declare const styleVariant: DataSourceUtility<string | string[] | Record<string, string | string[]>, Record<string, string | string[]>, string>;
3
+ export default styleVariant;
@@ -0,0 +1,76 @@
1
+ import { set as e } from "@plitzi/plitzi-ui/helpers/lodash";
2
+ //#region src/dataSource/utility/styleVariant.ts
3
+ var t = (t, n, r, i = {}) => {
4
+ let { key: a, variant: o, append: s } = n;
5
+ if (!a) return i.sourceTo ?? {};
6
+ let c = a || "base", l = o || t;
7
+ return typeof l == "object" && !Array.isArray(l) ? l : e(s ? { ...i.sourceTo } : {}, c, l);
8
+ }, n = (e) => {
9
+ let t = e.reduce((e, { groupLabel: t, option: n }) => (t in e || (e[t] = []), e[t].push(n), e), {});
10
+ return Object.entries(t).map(([e, t]) => ({
11
+ label: e,
12
+ options: t
13
+ }));
14
+ }, r = {
15
+ action: "styleVariant",
16
+ title: "Style Variant",
17
+ type: "utility",
18
+ params: {
19
+ key: {
20
+ label: "Selector Key",
21
+ defaultValue: "",
22
+ type: "select",
23
+ options: (e, t) => {
24
+ let r = t?.definition?.styleSelectors;
25
+ if (!t || !t.definition || !r) return [];
26
+ let i = t.definition.type;
27
+ return n(Object.entries(r).flatMap(([e, t]) => (t ? [i, ...t.split(" ")] : [i]).map((t) => ({
28
+ groupLabel: e,
29
+ option: {
30
+ value: `${t}.${e}`,
31
+ label: `${t} (${e})`
32
+ }
33
+ }))));
34
+ }
35
+ },
36
+ variant: {
37
+ label: "Variant",
38
+ defaultValue: "",
39
+ type: "select",
40
+ options: (e, t, n) => {
41
+ let r = t?.definition?.styleSelectors, i = e.key || "";
42
+ if (!t || !t.definition || !r || !n?.stylePlatform || !i.includes(".")) return [];
43
+ let a = t.definition.type, o = i.split(".").pop() || "", s = r[o];
44
+ if (!s) return [];
45
+ let c = [], l = [a, ...s.split(" ").filter(Boolean)];
46
+ return Object.entries(n.stylePlatform).forEach(([e, t]) => {
47
+ l.forEach((n) => {
48
+ let r = t[n];
49
+ if (!r) return;
50
+ let i = r.attributes[o];
51
+ Object.keys(i.variants || {}).forEach((t) => {
52
+ c.push({
53
+ value: t,
54
+ label: `${e}: ${t}`
55
+ });
56
+ });
57
+ });
58
+ }), c;
59
+ }
60
+ },
61
+ append: {
62
+ label: "Append to Variant",
63
+ description: "Merge with existing variant values instead of replacing",
64
+ defaultValue: !1,
65
+ type: "checkbox"
66
+ }
67
+ },
68
+ preview: {
69
+ key: "",
70
+ variant: "",
71
+ append: ""
72
+ },
73
+ callback: t
74
+ };
75
+ //#endregion
76
+ export { r as default };
@@ -19,7 +19,7 @@ var e = (e) => {
19
19
  if (Object.is(e, t)) return !0;
20
20
  if (e === null || t === null || typeof e != "object" || typeof t != "object" || Array.isArray(e) !== Array.isArray(t)) return !1;
21
21
  let n = Object.keys(e), r = Object.keys(t);
22
- return n.length === r.length ? n.every((n) => Object.is(e[n], t[n])) : !1;
22
+ return n.length === r.length && n.every((n) => Object.is(e[n], t[n]));
23
23
  }, r = (e, r) => {
24
24
  if (!e) return [];
25
25
  let i = [], a = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(r)]);
@@ -1,15 +1,22 @@
1
1
  import { Element } from './SchemaTypes';
2
2
  import { Field, RuleValue } from '@plitzi/plitzi-ui/QueryBuilder';
3
+ export type DataSourceUtilityParamsOption = {
4
+ label: string;
5
+ value: string;
6
+ } | {
7
+ label: string;
8
+ options: {
9
+ label: string;
10
+ value: string;
11
+ }[];
12
+ };
3
13
  export type DataSourceUtilityParams<TParams = string | boolean | number> = Record<string, {
4
14
  type?: DataSourceUtilityParamType | ((params: DataSourceUtilityParamsValue<TParams>) => DataSourceUtilityParamType);
5
15
  label?: string;
6
16
  description?: string;
7
17
  defaultValue?: string | boolean | number;
8
18
  disabled?: boolean | ((params: DataSourceUtilityParamsValue<TParams>) => boolean);
9
- options?: {
10
- label: string;
11
- value: string;
12
- }[];
19
+ options?: DataSourceUtilityParamsOption[] | Promise<DataSourceUtilityParamsOption[]> | ((params: DataSourceUtilityParamsValue<TParams>, element?: Partial<Element>, data?: Record<string, unknown>) => DataSourceUtilityParamsOption[] | Promise<DataSourceUtilityParamsOption[]>);
13
20
  }>;
14
21
  export type DataSourceUtilityParamsValue<T = string | boolean | number> = Record<keyof DataSourceUtility<T>['params'], T>;
15
22
  export type DataSourceUtilityParamType = 'text' | 'select' | 'textarea' | 'checkbox' | 'codemirror-text';
@@ -1,28 +1,6 @@
1
1
  import { AiContext, AiMode, PromptRole } from '../AITypes';
2
- import { StyleVariableCategory, StyleVariableValue } from '../StyleTypes';
3
- import { McpAdapters } from './McpAdapters';
4
2
  import { ToolAnnotations } from '@modelcontextprotocol/sdk/types';
5
3
  import { ZodType } from 'zod';
6
- export * from './McpAdapters';
7
- export type McpPlugin = {
8
- name: string;
9
- version?: string;
10
- description?: string;
11
- };
12
- export type McpStyleVariable = {
13
- category: StyleVariableCategory;
14
- name: string;
15
- value: StyleVariableValue;
16
- };
17
- export type McpSegment = {
18
- id?: string;
19
- identifier: string;
20
- definition: {
21
- name: string;
22
- description: string;
23
- baseElementId: string;
24
- };
25
- };
26
4
  export type ToolOperationType = 'read' | 'write';
27
5
  export type McpPromptHandlerResult = {
28
6
  messages: {
@@ -34,27 +12,18 @@ export type McpPromptHandlerResult = {
34
12
  }[];
35
13
  };
36
14
  export type McpPromptHandler = (args: Record<string, any>, ctx: AiContext) => Promise<McpPromptHandlerResult>;
37
- export type McpPrompt = {
38
- name: string;
39
- definition: {
40
- title: string;
41
- description: string;
42
- argsSchema?: Record<string, any>;
43
- };
44
- handler: McpPromptHandler;
15
+ export type McpTextContent = {
16
+ type: 'text';
17
+ text: string;
45
18
  };
46
- export type McpResource = {
47
- uri: string;
48
- name: string;
49
- description: string;
19
+ export type McpImageContent = {
20
+ type: 'image';
21
+ data: string;
50
22
  mimeType: string;
51
- content: string;
52
23
  };
24
+ export type McpContent = McpTextContent | McpImageContent;
53
25
  export type McpToolHandlerResult = {
54
- content: {
55
- type: 'text';
56
- text: string;
57
- }[];
26
+ content: McpContent[];
58
27
  data?: unknown;
59
28
  structuredContent?: Record<string, unknown>;
60
29
  isError?: true;
@@ -83,14 +52,9 @@ export type McpTool = {
83
52
  definition: {
84
53
  allowedModes: AiMode[];
85
54
  };
86
- adapterName?: keyof McpAdapters;
87
55
  handler?: McpToolHandler;
88
56
  };
89
57
  export type McpServerConfig = {
90
58
  enabled?: boolean;
91
59
  path?: string;
92
- adapters: Partial<McpAdapters>;
93
- tools?: McpTool[];
94
- prompts?: McpPrompt[];
95
- resources?: McpResource[];
96
60
  };
@@ -65,6 +65,9 @@ export type ElementDefinition = {
65
65
  runtime?: ElementRuntime;
66
66
  /** Controls when the element is loaded/rendered. */
67
67
  loadStrategy?: ElementLoadStrategy;
68
+ /** Stable, human-readable reference chosen by an AI agent (mcp-ai). Lets agents address this element
69
+ * without knowing its opaque `id`. Optional and ignored by rendering. */
70
+ aiRef?: string;
68
71
  };
69
72
  export type Element<TAttributes extends Record<string, unknown> = Record<string, unknown>> = {
70
73
  id: string;
@@ -1,6 +1,8 @@
1
1
  import { Environment } from './CommonTypes';
2
2
  import { McpServerConfig } from './McpTypes';
3
+ import { Schema } from './SchemaTypes';
3
4
  import { OfflineDataRaw } from './SdkTypes';
5
+ import { Style } from './StyleTypes';
4
6
  import { IncomingHttpHeaders } from 'node:http';
5
7
  import { FC } from 'react';
6
8
  export type ServerEnvironment = 'development' | 'production' | 'staging' | 'local';
@@ -123,6 +125,24 @@ export type SSRRscData = {
123
125
  export type SSRAdapters = {
124
126
  getOfflineData: (spaceId: number, environment: string, revision?: number) => Promise<OfflineDataRaw | undefined>;
125
127
  getSpaceDeployment: (req: SSRRequest) => Promise<SSRSpaceDeployment>;
128
+ /** Persist a space mutated by the mcp-ai `apply` tool. Implementations must recompute derived caches
129
+ * (notably `style.cache`) before storing. When omitted, mcp-ai runs read/preview/validate only and
130
+ * `apply` reports `persisted: false`. */
131
+ saveOfflineData?: (spaceId: number, environment: string, data: OfflineDataRaw) => Promise<void>;
132
+ /** Resolve the spaceId the MCP request operates on, from the verified `Authorization` bearer. The consumer
133
+ * owns the JWT secret, so it decodes here; the MCP service stays stateless. Returns undefined when the
134
+ * token is missing or invalid. Required for the `mcp` service to serve any request. */
135
+ getSpaceId?: (req: SSRRequest) => Promise<number | undefined>;
136
+ /** Read the element schema for the MCP tools. Separate from `getOfflineData` (which is SSR/RSC shaped and
137
+ * strips `style.platform`); the MCP style resource needs the full documents, so schema and style split. */
138
+ getSchema?: (spaceId: number, environment: Environment) => Promise<Schema | undefined>;
139
+ /** Read the full style document (with `platform`/`mode`, which the MCP definitions resource requires). */
140
+ getStyle?: (spaceId: number, environment: Environment) => Promise<Style | undefined>;
141
+ /** Persist the element schema mutated by the MCP `apply` tool. When omitted, `apply` reports `persisted: false`. */
142
+ saveSchema?: (spaceId: number, environment: Environment, schema: Schema) => Promise<void>;
143
+ /** Persist the style document mutated by the MCP `apply` tool. Implementations must recompute `style.cache`
144
+ * before storing. When omitted, `apply` reports `persisted: false`. */
145
+ saveStyle?: (spaceId: number, environment: Environment, style: Style) => Promise<void>;
126
146
  getUser?: (req: SSRRequest) => Promise<SSRUser | undefined>;
127
147
  onLogin?: (req: SSRRequest, res: SSRResponseHelpers) => Promise<boolean>;
128
148
  onLogout?: (req: SSRRequest, res: SSRResponseHelpers) => Promise<void>;
@@ -176,10 +196,58 @@ export type SSRServerConfig = {
176
196
  rsc?: SSRRscConfig;
177
197
  /** MCP (Model Context Protocol) server configuration — exposes schema tools to Claude. */
178
198
  mcp?: McpServerConfig;
199
+ /** AI-native MCP server — replaces the standard MCP with a zero-hallucination batch protocol.
200
+ * When enabled, requests to the MCP path serve the AI-native server instead. */
201
+ mcpAi?: {
202
+ enabled?: boolean;
203
+ path?: string;
204
+ };
179
205
  adapters: SSRAdapters;
206
+ /** Draft-preview endpoint for the MCP visual-preview tools (the RENDERER side). Off unless `enabled`. */
207
+ preview?: SSRPreviewConfig;
208
+ /** For an MCP server that runs separately from the renderer (the CLIENT side): where to reach the SSR
209
+ * `/preview` endpoint so the visual-preview tools work. The SDK builds an HTTP preview client from this;
210
+ * absent → those tools report PREVIEW_UNAVAILABLE. */
211
+ previewClient?: {
212
+ url: string;
213
+ secret?: string;
214
+ };
215
+ /** Dedicated headless-browser service for plitzi_screenshot (off unless set). `serviceUrl` is the browser
216
+ * service that turns a URL into PNG(s); `renderBaseUrl` is the SSR base the browser navigates to (a page
217
+ * path + the one-shot `__pt` token are appended). When absent, plitzi_screenshot is not registered and only
218
+ * the HTML plitzi_preview is available; when the service is unreachable at call time the tool degrades to
219
+ * returning the HTML preview with a warning. */
220
+ screenshot?: {
221
+ serviceUrl: string;
222
+ renderBaseUrl: string;
223
+ };
224
+ /** Backing store for draft-preview tokens. Defaults to an in-memory store (single replica); inject a shared
225
+ * store (e.g. Redis) for multi-replica correctness. */
226
+ draftStore?: DraftStore;
227
+ /** Which request-handling services this server mounts. Each maps to an internal `create<Name>Server` unit,
228
+ * so new services scale without rewriting the dispatcher. Omitted flags fall back to sensible defaults:
229
+ * ssr on, rsc when `adapters.getRscData` exists, mcp from `mcpAi.enabled`. `ai` is a reserved slot (not
230
+ * wired yet). The per-service presets (createSSRServer / createMCPServer) pin these flags for you. */
231
+ services?: ServerServices;
232
+ /** Liveness/readiness endpoint for standalone servers (k8s probes). A stage always answers `path`
233
+ * (default /health) with 200. The body is the generic identity payload built from `name`/`version`/`role`
234
+ * ({ Server, Version, role }); pass an explicit `payload` to override it entirely. */
235
+ health?: {
236
+ path?: string;
237
+ payload?: Record<string, unknown>;
238
+ name?: string;
239
+ version?: string;
240
+ role?: string;
241
+ };
180
242
  /** Cache-buster appended as ?v=<assetVersion> to all default SDK asset URLs (jsPath, cssPath, react vendor). Compute from file mtime or package version at startup. */
181
243
  assetVersion?: string;
182
244
  };
245
+ export type ServerServices = {
246
+ ssr?: boolean;
247
+ rsc?: boolean;
248
+ mcp?: boolean;
249
+ ai?: boolean;
250
+ };
183
251
  export type PluginRegistry = {
184
252
  register: (name: string, source: PluginSource) => void;
185
253
  invalidate: (name?: string, version?: string) => Promise<void>;
@@ -206,3 +274,23 @@ export type SSRServer = {
206
274
  readonly cache: CacheManager | null;
207
275
  readonly plugins: PluginRegistry;
208
276
  };
277
+ /** A short-TTL, one-shot store for unsaved draft offline-data behind a preview token. The SDK ships an
278
+ * in-memory default (fine for a single replica); a multi-replica deployment injects a shared (e.g. Redis)
279
+ * implementation so a preview URL resolves on whichever replica the browser lands on. `take` consumes the
280
+ * token so a preview URL is not replayable. */
281
+ export type DraftStore = {
282
+ put: (token: string, data: OfflineDataRaw, ttlMs: number) => void | Promise<void>;
283
+ take: (token: string) => (OfflineDataRaw | undefined) | Promise<OfflineDataRaw | undefined>;
284
+ };
285
+ /** Draft-preview config for the MCP visual-preview tools. When enabled, an internal endpoint at `path`
286
+ * (guarded by `secret`) applies unsaved edits to a clone, stashes the resulting offline-data under a
287
+ * one-shot token, and the render path serves it back at `?__pt=<token>`. Off by default. */
288
+ export type SSRPreviewConfig = {
289
+ enabled?: boolean;
290
+ /** Internal endpoint path that mints a preview token. Default '/__preview'. */
291
+ path?: string;
292
+ /** Shared secret required in the `x-preview-secret` header; requests without it are rejected. */
293
+ secret?: string;
294
+ /** Token time-to-live in milliseconds. Default 60000. */
295
+ ttlMs?: number;
296
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-shared",
3
- "version": "0.32.3",
3
+ "version": "0.32.5",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist",
@@ -102,6 +102,10 @@
102
102
  "types": "./dist/dataSource/utility/styleSelector.d.ts",
103
103
  "import": "./dist/dataSource/utility/styleSelector.mjs"
104
104
  },
105
+ "./dataSource/utility/styleVariant": {
106
+ "types": "./dist/dataSource/utility/styleVariant.d.ts",
107
+ "import": "./dist/dataSource/utility/styleVariant.mjs"
108
+ },
105
109
  "./dataSource/utility/twigTemplate": {
106
110
  "types": "./dist/dataSource/utility/twigTemplate.d.ts",
107
111
  "import": "./dist/dataSource/utility/twigTemplate.mjs"
@@ -1006,9 +1010,6 @@
1006
1010
  "./types/InteractionTypes": {
1007
1011
  "types": "./dist/types/InteractionTypes.d.ts"
1008
1012
  },
1009
- "./types/McpTypes/McpAdapters": {
1010
- "types": "./dist/types/McpTypes/McpAdapters.d.ts"
1011
- },
1012
1013
  "./types/McpTypes/index": {
1013
1014
  "types": "./dist/types/McpTypes/index.d.ts"
1014
1015
  },
@@ -1075,12 +1076,12 @@
1075
1076
  },
1076
1077
  "dependencies": {
1077
1078
  "@modelcontextprotocol/sdk": "^1.29.0",
1078
- "@plitzi/nexus": "0.32.3",
1079
+ "@plitzi/nexus": "0.32.5",
1079
1080
  "@plitzi/plitzi-ui": "^1.6.13",
1080
1081
  "date-fns": "^4.4.0",
1081
1082
  "date-fns-tz": "^3.2.0",
1082
1083
  "graphql-tag": "^2.12.7",
1083
- "immer": "^11.1.8",
1084
+ "immer": "^11.1.11",
1084
1085
  "twig": "^3.0.0",
1085
1086
  "zod": "^4.4.3"
1086
1087
  },
@@ -1089,7 +1090,7 @@
1089
1090
  "react-dom": "^19"
1090
1091
  },
1091
1092
  "devDependencies": {
1092
- "@babel/cli": "^8.0.1",
1093
+ "@babel/cli": "^8.0.4",
1093
1094
  "@babel/core": "^8.0.1",
1094
1095
  "@babel/eslint-parser": "^8.0.1",
1095
1096
  "@babel/plugin-syntax-flow": "^8.0.1",
@@ -1104,38 +1105,38 @@
1104
1105
  "@types/react": "^19.2.17",
1105
1106
  "@types/react-dom": "^19.2.3",
1106
1107
  "@types/twig": "^1.12.17",
1107
- "@vitejs/plugin-react": "^6.0.2",
1108
- "@vitest/coverage-v8": "^4.1.9",
1108
+ "@vitejs/plugin-react": "^6.0.3",
1109
+ "@vitest/coverage-v8": "^4.1.10",
1109
1110
  "babel-minify": "^0.5.2",
1110
1111
  "eslint": "^9.39.4",
1111
1112
  "eslint-config-airbnb": "^19.0.4",
1112
1113
  "eslint-config-prettier": "^10.1.8",
1113
- "eslint-config-turbo": "^2.9.18",
1114
+ "eslint-config-turbo": "^2.10.4",
1114
1115
  "eslint-import-resolver-alias": "^1.1.2",
1115
- "eslint-plugin-cypress": "^6.4.1",
1116
+ "eslint-plugin-cypress": "^6.4.2",
1116
1117
  "eslint-plugin-flowtype": "8.0.3",
1117
1118
  "eslint-plugin-import": "^2.32.0",
1118
- "eslint-plugin-jsdoc": "^63.0.7",
1119
+ "eslint-plugin-jsdoc": "^63.0.13",
1119
1120
  "eslint-plugin-jsx-a11y": "^6.10.2",
1120
1121
  "eslint-plugin-prettier": "^5.5.6",
1121
1122
  "eslint-plugin-react": "^7.37.5",
1122
1123
  "eslint-plugin-react-hooks": "^7.1.1",
1123
1124
  "eslint-plugin-react-refresh": "^0.5.3",
1124
- "eslint-plugin-storybook": "^10.4.6",
1125
- "globals": "^17.6.0",
1125
+ "eslint-plugin-storybook": "^10.5.0",
1126
+ "globals": "^17.7.0",
1126
1127
  "jsdom": "^29.1.1",
1127
- "postcss": "^8.5.15",
1128
- "prettier": "^3.8.4",
1128
+ "postcss": "^8.5.17",
1129
+ "prettier": "^3.9.5",
1129
1130
  "react": "^19.2.7",
1130
1131
  "react-dom": "^19.2.7",
1131
- "tailwindcss": "^4.3.1",
1132
- "terser": "^5.48.0",
1132
+ "tailwindcss": "^4.3.2",
1133
+ "terser": "^5.49.0",
1133
1134
  "typescript": "^6.0.3",
1134
- "typescript-eslint": "^8.61.1",
1135
- "vite": "^8.0.16",
1136
- "vite-plugin-dts": "^5.0.2",
1135
+ "typescript-eslint": "^8.63.0",
1136
+ "vite": "^8.1.4",
1137
+ "vite-plugin-dts": "^5.0.3",
1137
1138
  "vite-plugin-react": "^4.0.1",
1138
- "vitest": "^4.1.9",
1139
+ "vitest": "^4.1.10",
1139
1140
  "vitest-fetch-mock": "^0.4.5"
1140
1141
  }
1141
1142
  }
@@ -1,455 +0,0 @@
1
- import { AiContext, DisplayMode, Resource, StyleCategory, StyleItem, StyleVariableCategory, StyleVariableValue, TagType } from '../..';
2
- import { McpPlugin, McpSegment, McpStyleVariable } from '../McpTypes';
3
- import { DropPosition, Element, PageFolder, Schema, SchemaVariable } from '../SchemaTypes';
4
- import { Theme } from '../ThemeTypes';
5
- export type McpAdapter<R = any, T extends Record<string, any> = Record<string, any>> = (args: T, ctx: AiContext) => Promise<{
6
- data: R;
7
- } | {
8
- error: Error | string;
9
- }>;
10
- export type McpAdaptersSchema = {
11
- applyPreview: McpAdapter<{
12
- baseElementId: string;
13
- targetParentId: string;
14
- elementCount: number;
15
- }, {
16
- schema: {
17
- flat: Record<string, Element>;
18
- };
19
- style?: Record<string, unknown>;
20
- baseElementId: string;
21
- targetParentId: string;
22
- dropPosition?: DropPosition;
23
- }>;
24
- };
25
- export type PageElementSummary = {
26
- id: string;
27
- label: string;
28
- type: string;
29
- parentId: string | null;
30
- attributes: Record<string, unknown>;
31
- };
32
- export type McpAdaptersPages = {
33
- getPage: McpAdapter<{
34
- page: Element;
35
- elements: PageElementSummary[];
36
- } | undefined, {
37
- pageId: string;
38
- }>;
39
- getPages: McpAdapter<Element[]>;
40
- getPageBySlug: McpAdapter<Element | undefined, {
41
- slug: string;
42
- }>;
43
- createPage: McpAdapter<Element, {
44
- name: string;
45
- }>;
46
- updatePage: McpAdapter<Element, {
47
- pageId: string;
48
- updates: {
49
- name?: string;
50
- slug?: string;
51
- default?: boolean;
52
- folder?: string;
53
- };
54
- }>;
55
- deletePage: McpAdapter<boolean, {
56
- pageId: string;
57
- }>;
58
- };
59
- export type McpAdaptersPageFolders = {
60
- getPageFolder: McpAdapter<PageFolder | undefined, {
61
- folderId: string;
62
- }>;
63
- getPageFolders: McpAdapter<PageFolder[]>;
64
- createPageFolder: McpAdapter<PageFolder, {
65
- name: string;
66
- parentId?: string;
67
- }>;
68
- updatePageFolder: McpAdapter<PageFolder, {
69
- id: string;
70
- updates: Partial<Pick<PageFolder, 'name' | 'slug' | 'parentId'>>;
71
- }>;
72
- deletePageFolder: McpAdapter<boolean, {
73
- id: string;
74
- }>;
75
- };
76
- export type McpAdaptersElements = {
77
- createElement: McpAdapter<Element | undefined, {
78
- element: Element;
79
- parentId?: string;
80
- position?: number;
81
- }>;
82
- getElement: McpAdapter<Element | undefined, {
83
- elementId: string;
84
- }>;
85
- getElements: McpAdapter<Element[], {
86
- pageId?: string;
87
- type?: string;
88
- parentId?: string;
89
- }>;
90
- listElements: McpAdapter<{
91
- id: string;
92
- label: string;
93
- type: string;
94
- parentId?: string;
95
- items?: string[];
96
- }[], {
97
- rootId?: string;
98
- parentId?: string;
99
- type?: string;
100
- }>;
101
- updateElement: McpAdapter<Element, Element>;
102
- deleteElement: McpAdapter<boolean, {
103
- elementId: string;
104
- }>;
105
- moveElement: McpAdapter<boolean, {
106
- elementId: string;
107
- toParentId: string;
108
- dropPosition?: DropPosition;
109
- }>;
110
- cloneElement: McpAdapter<{
111
- id: string;
112
- label: string;
113
- type: string;
114
- parentId?: string;
115
- items?: string[];
116
- }[], {
117
- elementId: string;
118
- to: string;
119
- dropPosition: DropPosition;
120
- }>;
121
- };
122
- export type McpAdaptersSchemaVariables = {
123
- getVariable: McpAdapter<SchemaVariable | undefined, {
124
- name: string;
125
- }>;
126
- getVariables: McpAdapter<SchemaVariable[]>;
127
- createSchemaVariable: McpAdapter<SchemaVariable, {
128
- variable: Pick<SchemaVariable, 'name' | 'type' | 'value' | 'category'>;
129
- }>;
130
- updateSchemaVariable: McpAdapter<SchemaVariable, {
131
- variable: Partial<SchemaVariable> & {
132
- name: string;
133
- };
134
- }>;
135
- deleteSchemaVariable: McpAdapter<boolean, {
136
- name: string;
137
- }>;
138
- };
139
- export type McpAdaptersStyles = {
140
- getStyleVariables: McpAdapter<Record<string, Record<string, StyleVariableValue>>>;
141
- getStyleVariable: McpAdapter<StyleVariableValue | undefined, {
142
- category: StyleVariableCategory;
143
- name: string;
144
- }>;
145
- getStyleSelectors: McpAdapter<Record<string, string[]>, {
146
- displayMode?: string;
147
- }>;
148
- updateStyle: McpAdapter;
149
- updateStyleSettings: McpAdapter;
150
- };
151
- export type McpAdaptersStylesVariables = {
152
- createStyleVariable: McpAdapter<{
153
- category: StyleVariableCategory;
154
- name: string;
155
- value: StyleVariableValue;
156
- }, McpStyleVariable>;
157
- updateStyleVariable: McpAdapter<McpStyleVariable, {
158
- category: StyleVariableCategory;
159
- name: string;
160
- value: StyleVariableValue;
161
- }>;
162
- deleteStyleVariable: McpAdapter<boolean, {
163
- category: StyleVariableCategory;
164
- name: string;
165
- }>;
166
- };
167
- export type McpAdaptersStylesSelectors = {
168
- createStyleSelector: McpAdapter<StyleItem, {
169
- displayMode: DisplayMode;
170
- selector: string;
171
- type: TagType;
172
- path?: StyleCategory;
173
- style?: StyleItem['attributes'];
174
- params?: Record<string, unknown>;
175
- }>;
176
- updateStyleSelector: McpAdapter<StyleItem, {
177
- displayMode: DisplayMode;
178
- selector: string;
179
- type: TagType;
180
- path?: StyleCategory;
181
- style?: StyleItem['attributes'];
182
- params?: Record<string, unknown>;
183
- }>;
184
- deleteStyleSelector: McpAdapter<boolean, {
185
- displayMode: DisplayMode;
186
- selector: string;
187
- }>;
188
- };
189
- export type McpAdaptersSegments = {
190
- createSegment: McpAdapter<McpSegment, {
191
- name: string;
192
- description: string;
193
- }>;
194
- updateSegment: McpAdapter<McpSegment, {
195
- segmentId: string;
196
- updates: {
197
- name?: string;
198
- description?: string;
199
- };
200
- }>;
201
- deleteSegment: McpAdapter<boolean, {
202
- segmentId: string;
203
- }>;
204
- getSegment: McpAdapter<Record<string, unknown> | undefined, {
205
- segmentId?: string;
206
- identifier?: string;
207
- }>;
208
- getSegments: McpAdapter<Record<string, unknown>[], {
209
- cursor?: string;
210
- limit?: number;
211
- }>;
212
- createSegmentElement: McpAdapter<Element, {
213
- segmentId: string;
214
- element: {
215
- type: string;
216
- label: string;
217
- props?: Record<string, unknown>;
218
- };
219
- parentId: string;
220
- }>;
221
- updateSegmentElement: McpAdapter<Element, {
222
- segmentId: string;
223
- elementId: string;
224
- updates: {
225
- label?: string;
226
- props?: Record<string, unknown>;
227
- };
228
- }>;
229
- moveSegmentElement: McpAdapter<boolean, {
230
- segmentId: string;
231
- elementId: string;
232
- toParentId: string;
233
- dropPosition?: DropPosition;
234
- }>;
235
- deleteSegmentElement: McpAdapter<boolean, {
236
- segmentId: string;
237
- elementId: string;
238
- }>;
239
- cloneSegmentElement: McpAdapter;
240
- createSegmentVariable: McpAdapter<SchemaVariable, {
241
- segmentId: string;
242
- variable: Pick<SchemaVariable, 'name' | 'type' | 'value' | 'category'>;
243
- }>;
244
- updateSegmentVariable: McpAdapter<SchemaVariable, {
245
- segmentId: string;
246
- variable: Partial<SchemaVariable> & {
247
- name: string;
248
- };
249
- }>;
250
- deleteSegmentVariable: McpAdapter<boolean, {
251
- segmentId: string;
252
- name: string;
253
- }>;
254
- createSegmentStyleVariable: McpAdapter<McpStyleVariable, {
255
- segmentId: string;
256
- category: StyleVariableCategory;
257
- name: string;
258
- value: StyleVariableValue;
259
- }>;
260
- updateSegmentStyleVariable: McpAdapter<McpStyleVariable, {
261
- segmentId: string;
262
- category: StyleVariableCategory;
263
- name: string;
264
- value: StyleVariableValue;
265
- }>;
266
- deleteSegmentStyleVariable: McpAdapter<boolean, {
267
- segmentId: string;
268
- category: StyleVariableCategory;
269
- name: string;
270
- }>;
271
- addSegmentStyleSelector: McpAdapter<StyleItem, {
272
- segmentId: string;
273
- displayMode: DisplayMode;
274
- selector: string;
275
- type: TagType;
276
- path?: StyleCategory;
277
- style?: StyleItem['attributes'];
278
- params: Record<string, unknown>;
279
- }>;
280
- updateSegmentStyleSelector: McpAdapter<StyleItem, {
281
- segmentId: string;
282
- displayMode: DisplayMode;
283
- selector: string;
284
- path?: StyleCategory;
285
- style?: StyleItem['attributes'];
286
- params: Record<string, unknown>;
287
- }>;
288
- deleteSegmentStyleSelector: McpAdapter<boolean, {
289
- segmentId: string;
290
- displayMode: DisplayMode;
291
- selector: string;
292
- }>;
293
- addSegmentStyleSelectorVariable: McpAdapter<{
294
- displayMode: DisplayMode;
295
- selector: string;
296
- category: StyleVariableCategory;
297
- name: string;
298
- value: StyleVariableValue;
299
- }, {
300
- segmentId: string;
301
- displayMode: DisplayMode;
302
- selector: string;
303
- category: StyleVariableCategory;
304
- name: string;
305
- value: StyleVariableValue;
306
- }>;
307
- updateSegmentStyleSelectorVariable: McpAdapter<{
308
- displayMode: DisplayMode;
309
- selector: string;
310
- category: StyleVariableCategory;
311
- name: string;
312
- value: StyleVariableValue;
313
- }, {
314
- segmentId: string;
315
- displayMode: DisplayMode;
316
- selector: string;
317
- category: StyleVariableCategory;
318
- name: string;
319
- value: StyleVariableValue;
320
- }>;
321
- removeSegmentStyleSelectorVariable: McpAdapter<boolean, {
322
- segmentId: string;
323
- displayMode: DisplayMode;
324
- selector: string;
325
- category: StyleVariableCategory;
326
- name: string;
327
- }>;
328
- addSegmentSelectorVariable: McpAdapter<{
329
- displayMode: DisplayMode;
330
- selector: string;
331
- category: StyleVariableCategory;
332
- name: string;
333
- value: StyleVariableValue;
334
- }, {
335
- segmentId: string;
336
- displayMode: DisplayMode;
337
- selector: string;
338
- category: StyleVariableCategory;
339
- name: string;
340
- value: StyleVariableValue;
341
- }>;
342
- updateSegmentSelectorVariable: McpAdapter<{
343
- displayMode: DisplayMode;
344
- selector: string;
345
- category: StyleVariableCategory;
346
- name: string;
347
- value: StyleVariableValue;
348
- }, {
349
- segmentId: string;
350
- displayMode: DisplayMode;
351
- selector: string;
352
- category: StyleVariableCategory;
353
- name: string;
354
- value: StyleVariableValue;
355
- }>;
356
- removeSegmentSelectorVariable: McpAdapter<boolean, {
357
- segmentId: string;
358
- displayMode: DisplayMode;
359
- selector: string;
360
- category: StyleVariableCategory;
361
- name: string;
362
- }>;
363
- };
364
- export type McpAdaptersPlugins = {
365
- listPlugins: McpAdapter<McpPlugin[]>;
366
- addPlugin: McpAdapter<{
367
- type: string;
368
- resource: string;
369
- settings: Record<string, unknown>;
370
- }, {
371
- pluginType: string;
372
- resource: string;
373
- override?: boolean;
374
- }>;
375
- updatePlugin: McpAdapter<{
376
- type: string;
377
- resource: string;
378
- settings: Record<string, unknown>;
379
- }, {
380
- pluginType: string;
381
- resource: string;
382
- }>;
383
- removePlugin: McpAdapter<boolean, {
384
- pluginType: string;
385
- }>;
386
- };
387
- export type McpAdaptersCollections = {
388
- getCollections: McpAdapter<Record<string, unknown>[], Record<string, unknown>>;
389
- getCollection: McpAdapter<Record<string, unknown> | undefined, {
390
- collectionId: string;
391
- }>;
392
- createCollection: McpAdapter;
393
- updateCollection: McpAdapter;
394
- deleteCollection: McpAdapter<boolean, any>;
395
- getCollectionRecords: McpAdapter;
396
- getCollectionRecord: McpAdapter;
397
- createCollectionRecord: McpAdapter;
398
- updateCollectionRecord: McpAdapter;
399
- deleteCollectionRecord: McpAdapter<boolean, {
400
- collectionId: string;
401
- recordId: string;
402
- }>;
403
- };
404
- export type McpAdaptersResources = {
405
- getResources: McpAdapter;
406
- getResource: McpAdapter<Resource | undefined, {
407
- identifier: string;
408
- cdnIdentifier: string;
409
- }>;
410
- addResource: McpAdapter<Resource | undefined, {
411
- url: string;
412
- cdnIdentifier: string;
413
- filename?: string;
414
- type?: string;
415
- prefix?: string;
416
- compression?: string;
417
- }>;
418
- moveResource: McpAdapter<Resource | undefined, {
419
- identifier: string;
420
- cdnIdentifier: string;
421
- prefix: string;
422
- }>;
423
- removeResource: McpAdapter<{
424
- id: string;
425
- } | undefined, {
426
- identifier: string;
427
- cdnIdentifier: string;
428
- }>;
429
- };
430
- export type McpAdaptersSpace = {
431
- getSpaceSettings: McpAdapter<Schema['settings'] | undefined>;
432
- updateSpaceSettings: McpAdapter<Schema['settings'], {
433
- path?: string;
434
- value?: string | number | boolean;
435
- }>;
436
- };
437
- export type McpAdapters = {
438
- getBuilderContext: McpAdapter<{
439
- currentPageId?: string;
440
- selectedElementId?: string;
441
- cssVariables: Record<string, {
442
- default: string;
443
- light?: string;
444
- dark?: string;
445
- }> | undefined;
446
- elementDefaults: any;
447
- elements: {
448
- id: string;
449
- label: string;
450
- type: string;
451
- parentId?: string;
452
- }[];
453
- theme?: Exclude<Theme, 'system'>;
454
- } | undefined>;
455
- } & McpAdaptersSchema & McpAdaptersPages & McpAdaptersPageFolders & McpAdaptersElements & McpAdaptersSchemaVariables & McpAdaptersStyles & McpAdaptersStylesVariables & McpAdaptersStylesSelectors & McpAdaptersSegments & McpAdaptersPlugins & McpAdaptersCollections & McpAdaptersResources & McpAdaptersSpace;
File without changes