@plitzi/sdk-shared 0.30.19 → 0.31.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-shared",
3
- "version": "0.30.19",
3
+ "version": "0.31.0",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist",
@@ -50,10 +50,6 @@
50
50
  "types": "./dist/dataSource/index.d.ts",
51
51
  "import": "./dist/dataSource/index.mjs"
52
52
  },
53
- "./dataSource/DataSourceContext": {
54
- "types": "./dist/dataSource/DataSourceContext.d.ts",
55
- "import": "./dist/dataSource/DataSourceContext.mjs"
56
- },
57
53
  "./dataSource/hooks": {
58
54
  "types": "./dist/dataSource/hooks/index.d.ts",
59
55
  "import": "./dist/dataSource/hooks/index.mjs"
@@ -66,6 +62,10 @@
66
62
  "types": "./dist/dataSource/hooks/useDataSource.d.ts",
67
63
  "import": "./dist/dataSource/hooks/useDataSource.mjs"
68
64
  },
65
+ "./dataSource/hooks/useRegisterSource": {
66
+ "types": "./dist/dataSource/hooks/useRegisterSource.d.ts",
67
+ "import": "./dist/dataSource/hooks/useRegisterSource.mjs"
68
+ },
69
69
  "./dataSource/index": {
70
70
  "types": "./dist/dataSource/index.d.ts",
71
71
  "import": "./dist/dataSource/index.mjs"
@@ -901,6 +901,9 @@
901
901
  "types": "./dist/types/index.d.ts",
902
902
  "import": "./dist/types/index.mjs"
903
903
  },
904
+ "./types/AITypes": {
905
+ "types": "./dist/types/AITypes.d.ts"
906
+ },
904
907
  "./types/AuthTypes": {
905
908
  "types": "./dist/types/AuthTypes.d.ts"
906
909
  },
@@ -931,8 +934,11 @@
931
934
  "./types/InteractionTypes": {
932
935
  "types": "./dist/types/InteractionTypes.d.ts"
933
936
  },
934
- "./types/McpTypes": {
935
- "types": "./dist/types/McpTypes.d.ts"
937
+ "./types/McpTypes/McpAdapters": {
938
+ "types": "./dist/types/McpTypes/McpAdapters.d.ts"
939
+ },
940
+ "./types/McpTypes/index": {
941
+ "types": "./dist/types/McpTypes/index.d.ts"
936
942
  },
937
943
  "./types/NavigationTypes": {
938
944
  "types": "./dist/types/NavigationTypes.d.ts"
@@ -943,9 +949,6 @@
943
949
  "./types/ResourceTypes": {
944
950
  "types": "./dist/types/ResourceTypes.d.ts"
945
951
  },
946
- "./types/SchemaTypes": {
947
- "types": "./dist/types/SchemaTypes.d.ts"
948
- },
949
952
  "./types/SdkTypes": {
950
953
  "types": "./dist/types/SdkTypes.d.ts"
951
954
  },
@@ -999,65 +1002,67 @@
999
1002
  "build:prod": "vite build && node ./scripts/generate-exports.mjs"
1000
1003
  },
1001
1004
  "dependencies": {
1002
- "@plitzi/plitzi-ui": "^1.6.2",
1003
- "@plitzi/sdk-store": "0.30.19",
1004
- "date-fns": "^4.1.0",
1005
+ "@modelcontextprotocol/sdk": "^1.29.0",
1006
+ "@plitzi/plitzi-ui": "^1.6.9",
1007
+ "@plitzi/sdk-store": "0.31.0",
1008
+ "date-fns": "^4.3.0",
1005
1009
  "date-fns-tz": "^3.2.0",
1006
1010
  "graphql-tag": "^2.12.6",
1007
- "twig": "^3.0.0"
1011
+ "twig": "^3.0.0",
1012
+ "zod": "^4.4.3"
1008
1013
  },
1009
1014
  "peerDependencies": {
1010
1015
  "react": "^19",
1011
1016
  "react-dom": "^19"
1012
1017
  },
1013
1018
  "devDependencies": {
1014
- "@babel/cli": "^7.28.6",
1015
- "@babel/core": "^7.29.0",
1016
- "@babel/eslint-parser": "^7.28.6",
1017
- "@babel/plugin-syntax-flow": "^7.28.6",
1018
- "@babel/plugin-transform-react-jsx": "^7.28.6",
1019
- "@babel/preset-env": "^7.29.2",
1019
+ "@babel/cli": "^7.29.7",
1020
+ "@babel/core": "^7.29.7",
1021
+ "@babel/eslint-parser": "^7.29.7",
1022
+ "@babel/plugin-syntax-flow": "^7.29.7",
1023
+ "@babel/plugin-transform-react-jsx": "^7.29.7",
1024
+ "@babel/preset-env": "^7.29.7",
1020
1025
  "@eslint/js": "^10.0.1",
1021
1026
  "@tailwindcss/forms": "^0.5.11",
1022
1027
  "@testing-library/dom": "^10.4.1",
1023
1028
  "@testing-library/react": "^16.3.2",
1024
1029
  "@testing-library/react-hooks": "^8.0.1",
1025
1030
  "@testing-library/user-event": "^14.6.1",
1026
- "@types/react": "^19.2.14",
1031
+ "@types/react": "^19.2.15",
1027
1032
  "@types/react-dom": "^19.2.3",
1028
1033
  "@types/twig": "^1.12.17",
1029
- "@vitejs/plugin-react": "^6.0.1",
1030
- "@vitest/coverage-v8": "^4.1.5",
1034
+ "@vitejs/plugin-react": "^6.0.2",
1035
+ "@vitest/coverage-v8": "^4.1.7",
1031
1036
  "babel-minify": "^0.5.2",
1032
1037
  "eslint": "^9.39.4",
1033
1038
  "eslint-config-airbnb": "^19.0.4",
1034
1039
  "eslint-config-prettier": "^10.1.8",
1035
- "eslint-config-turbo": "^2.9.6",
1040
+ "eslint-config-turbo": "^2.9.14",
1036
1041
  "eslint-import-resolver-alias": "^1.1.2",
1037
- "eslint-plugin-cypress": "^6.4.0",
1042
+ "eslint-plugin-cypress": "^6.4.1",
1038
1043
  "eslint-plugin-flowtype": "8.0.3",
1039
1044
  "eslint-plugin-import": "^2.32.0",
1040
- "eslint-plugin-jsdoc": "^62.9.0",
1045
+ "eslint-plugin-jsdoc": "^63.0.0",
1041
1046
  "eslint-plugin-jsx-a11y": "^6.10.2",
1042
1047
  "eslint-plugin-prettier": "^5.5.5",
1043
1048
  "eslint-plugin-react": "^7.37.5",
1044
1049
  "eslint-plugin-react-hooks": "^7.1.1",
1045
1050
  "eslint-plugin-react-refresh": "^0.5.2",
1046
- "eslint-plugin-storybook": "^10.3.6",
1047
- "globals": "^17.5.0",
1051
+ "eslint-plugin-storybook": "^10.4.1",
1052
+ "globals": "^17.6.0",
1048
1053
  "jsdom": "^29.1.1",
1049
- "postcss": "^8.5.12",
1054
+ "postcss": "^8.5.15",
1050
1055
  "prettier": "^3.8.3",
1051
- "react": "^19.2.5",
1052
- "react-dom": "^19.2.5",
1053
- "tailwindcss": "^4.2.4",
1054
- "terser": "^5.46.2",
1056
+ "react": "^19.2.6",
1057
+ "react-dom": "^19.2.6",
1058
+ "tailwindcss": "^4.3.0",
1059
+ "terser": "^5.48.0",
1055
1060
  "typescript": "^6.0.3",
1056
- "typescript-eslint": "^8.59.1",
1057
- "vite": "^8.0.10",
1058
- "vite-plugin-dts": "^5.0.0",
1061
+ "typescript-eslint": "^8.60.0",
1062
+ "vite": "^8.0.14",
1063
+ "vite-plugin-dts": "^5.0.1",
1059
1064
  "vite-plugin-react": "^4.0.1",
1060
- "vitest": "^4.1.5",
1065
+ "vitest": "^4.1.7",
1061
1066
  "vitest-fetch-mock": "^0.4.5"
1062
1067
  }
1063
1068
  }
@@ -1,3 +0,0 @@
1
- import { DataSourceContextValue } from '../types';
2
- declare const DataSourceContext: import('react').Context<DataSourceContextValue>;
3
- export default DataSourceContext;
@@ -1,5 +0,0 @@
1
- import { createContext as e } from "react";
2
- var t = e({});
3
- t.displayName = "DataSourceContext";
4
- //#endregion
5
- export { t as default };
@@ -1,20 +0,0 @@
1
- import { SourceMeta } from '../../types';
2
- import { Context } from 'react';
3
- export type UseDataSourceMode = 'write' | 'read';
4
- export type UseDataSourceFilter = 'soft' | 'hard';
5
- export type UseDataSourceProps<T extends UseDataSourceMode> = {
6
- id?: string;
7
- fields?: SourceMeta['fields'];
8
- mode: T;
9
- sourceFilter?: string[];
10
- filterMode?: UseDataSourceFilter;
11
- } & (T extends 'read' ? {
12
- name?: string;
13
- source?: string;
14
- } : {
15
- name: string;
16
- source: string;
17
- });
18
- declare function useDataSource<T = unknown>(props: UseDataSourceProps<'read'>): Record<string, T>;
19
- declare function useDataSource<T = unknown>(props: UseDataSourceProps<'write'>): [Context<T>, string];
20
- export default useDataSource;
@@ -1,45 +0,0 @@
1
- import { emptyObject as e, makeId as t } from "../../helpers/utils.mjs";
2
- import n from "../DataSourceContext.mjs";
3
- import { use as r, useEffect as i, useMemo as a, useRef as o } from "react";
4
- //#region src/dataSource/hooks/useDataSource.ts
5
- function s({ id: s = "", source: c, name: l, fields: u = [], mode: d = "write", sourceFilter: f = [], filterMode: p = "soft" }) {
6
- let { addSource: m, getSources: h, updateFields: g, removeSource: _ } = r(n), v = o(!1), y = a(() => `${s}_${t(8)}`, [s]), b = o(void 0), x = o({});
7
- if (d === "write" && (!l || !c)) throw Error("Name and Source are required in write mode");
8
- if (d === "write" && !v.current && (v.current = !0, b.current = m(y, {
9
- id: s,
10
- source: c,
11
- name: l,
12
- fields: u
13
- })), i(() => (d === "write" && !v.current && (v.current = !0, b.current = m(y, {
14
- id: s,
15
- source: c,
16
- name: l,
17
- fields: u
18
- })), () => {
19
- v.current = !1, _(y);
20
- }), [y]), i(() => {
21
- d === "write" && g(y, u);
22
- }, [
23
- u,
24
- y,
25
- g,
26
- d
27
- ]), d === "write") return [b.current, y];
28
- if (p === "hard" && !f.length) return e;
29
- let S = Object.values(h());
30
- f.length && (S = S.filter((e) => !f.length || !e.meta.source || f.includes(e.meta.source)));
31
- let C = S.filter((e) => e.meta.source).map((e) => ({
32
- ...e,
33
- value: r(e.context)
34
- })).reduce((e, t) => ({
35
- ...e,
36
- [t.meta.source]: t.value
37
- }), {});
38
- return Object.entries(x.current).filter(([e, t]) => t !== C[e]).length > 0 || Object.keys(C).length !== Object.keys(x.current).length ? x.current = C : (Object.keys(x.current).forEach((e) => {
39
- delete x.current[e];
40
- }), Object.entries(C).forEach(([e, t]) => {
41
- x.current[e] = t;
42
- })), x.current;
43
- }
44
- //#endregion
45
- export { s as default };
@@ -1,164 +0,0 @@
1
- import { PageFolder, SchemaVariable, DropPosition } from './SchemaTypes';
2
- import { DisplayMode, StyleCategory, StyleItem, StyleVariableCategory, StyleVariableValue, TagType } from './StyleTypes';
3
- export type McpSpace = {
4
- id: number;
5
- name: string;
6
- environments?: string[];
7
- };
8
- export type McpElement = {
9
- id: string;
10
- type: string;
11
- label: string;
12
- parentId?: string;
13
- props?: Record<string, unknown>;
14
- styles?: Record<string, unknown>;
15
- runtime?: 'server' | 'client' | 'shared';
16
- children?: string[];
17
- };
18
- export type McpSchema = {
19
- spaceId: number;
20
- environment: string;
21
- revision: number;
22
- elements: Record<string, McpElement>;
23
- };
24
- export type McpPlugin = {
25
- name: string;
26
- version?: string;
27
- description?: string;
28
- };
29
- export type McpPage = {
30
- id: string;
31
- name: string;
32
- isDefault: boolean;
33
- };
34
- export type McpStyleVariable = {
35
- category: StyleVariableCategory;
36
- name: string;
37
- value: StyleVariableValue;
38
- };
39
- export type McpStyleSelector = {
40
- displayMode: DisplayMode;
41
- selector: string;
42
- type: TagType;
43
- path?: StyleCategory;
44
- style?: StyleItem['attributes'];
45
- params: Record<string, unknown>;
46
- };
47
- export type McpSegment = {
48
- id?: string;
49
- identifier: string;
50
- definition: {
51
- name: string;
52
- description: string;
53
- baseElementId: string;
54
- };
55
- };
56
- export type McpAdapters = {
57
- /** Return all spaces the agent may access. */
58
- listSpaces: () => Promise<McpSpace[]>;
59
- /** Return the full element tree for a space + environment. */
60
- getSchema: (spaceId: number, environment: string) => Promise<McpSchema | undefined>;
61
- /** Add a new element to the schema. Returns the created element with its generated ID. */
62
- createElement: (spaceId: number, environment: string, element: {
63
- type: string;
64
- label: string;
65
- props?: Record<string, unknown>;
66
- runtime?: 'server' | 'client' | 'shared';
67
- }, parentId?: string, position?: number) => Promise<McpElement>;
68
- /** Update an existing element's label, props, styles, or runtime. */
69
- updateElement: (spaceId: number, environment: string, elementId: string, updates: {
70
- label?: string;
71
- props?: Record<string, unknown>;
72
- styles?: Record<string, unknown>;
73
- runtime?: 'server' | 'client' | 'shared';
74
- }) => Promise<McpElement>;
75
- /** Remove an element and its descendants from the schema. */
76
- deleteElement: (spaceId: number, environment: string, elementId: string) => Promise<void>;
77
- /** Move an element to a different parent. */
78
- moveElement: (spaceId: number, environment: string, elementId: string, toParentId: string, dropPosition?: DropPosition) => Promise<{
79
- success: boolean;
80
- }>;
81
- /** Publish the current draft as a new revision. Returns the new revision number. */
82
- publishSchema: (spaceId: number, environment: string) => Promise<{
83
- revision: number;
84
- }>;
85
- /** Optional: list plugins registered in the system. */
86
- listPlugins?: () => Promise<McpPlugin[]>;
87
- /** Create a new page. */
88
- createPage: (spaceId: number, environment: string, name: string) => Promise<McpPage>;
89
- /** Delete a page by ID. */
90
- deletePage: (spaceId: number, environment: string, pageId: string) => Promise<void>;
91
- /** Create a new page folder. */
92
- createPageFolder: (spaceId: number, environment: string, name: string, parentId?: string) => Promise<PageFolder>;
93
- /** Update a page folder. */
94
- updatePageFolder: (spaceId: number, environment: string, id: string, updates: Partial<Pick<PageFolder, 'name' | 'slug' | 'parentId'>>) => Promise<PageFolder>;
95
- /** Delete a page folder. */
96
- deletePageFolder: (spaceId: number, environment: string, id: string) => Promise<void>;
97
- /** Create a schema variable. */
98
- createVariable: (spaceId: number, environment: string, variable: Pick<SchemaVariable, 'name' | 'type' | 'value' | 'category'>) => Promise<SchemaVariable>;
99
- /** Update a schema variable. */
100
- updateVariable: (spaceId: number, environment: string, variable: Partial<SchemaVariable> & {
101
- name: string;
102
- }) => Promise<SchemaVariable>;
103
- /** Delete a schema variable. */
104
- deleteVariable: (spaceId: number, environment: string, name: string) => Promise<void>;
105
- /** Create a global style variable. */
106
- createStyleVariable: (spaceId: number, environment: string, category: StyleVariableCategory, name: string, value: StyleVariableValue) => Promise<McpStyleVariable>;
107
- /** Update a global style variable. */
108
- updateStyleVariable: (spaceId: number, environment: string, category: StyleVariableCategory, name: string, value: StyleVariableValue) => Promise<McpStyleVariable>;
109
- /** Delete a global style variable. */
110
- deleteStyleVariable: (spaceId: number, environment: string, category: StyleVariableCategory, name: string) => Promise<void>;
111
- /** Create a global style selector. */
112
- createStyleSelector: (spaceId: number, environment: string, displayMode: DisplayMode, selector: string, type: TagType, path?: StyleCategory, style?: StyleItem['attributes'], params?: Record<string, unknown>) => Promise<McpStyleSelector>;
113
- /** Update a global style selector. */
114
- updateStyleSelector: (spaceId: number, environment: string, displayMode: DisplayMode, selector: string, type: TagType, path?: StyleCategory, style?: StyleItem['attributes'], params?: Record<string, unknown>) => Promise<McpStyleSelector>;
115
- /** Delete a global style selector. */
116
- deleteStyleSelector: (spaceId: number, environment: string, displayMode: DisplayMode, selector: string) => Promise<void>;
117
- /** Create a segment. */
118
- createSegment: (spaceId: number, name: string, description: string) => Promise<McpSegment>;
119
- /** Update a segment. */
120
- updateSegment: (spaceId: number, segmentId: string, updates: {
121
- name?: string;
122
- description?: string;
123
- }) => Promise<McpSegment>;
124
- /** Delete a segment. */
125
- deleteSegment: (spaceId: number, segmentId: string) => Promise<void>;
126
- /** Add an element to a segment. */
127
- createSegmentElement: (spaceId: number, segmentId: string, element: {
128
- type: string;
129
- label: string;
130
- props?: Record<string, unknown>;
131
- }, parentId: string) => Promise<McpElement>;
132
- /** Update an element inside a segment. */
133
- updateSegmentElement: (spaceId: number, segmentId: string, elementId: string, updates: {
134
- label?: string;
135
- props?: Record<string, unknown>;
136
- }) => Promise<McpElement>;
137
- /** Move an element inside a segment. */
138
- moveSegmentElement: (spaceId: number, segmentId: string, elementId: string, toParentId: string, dropPosition?: DropPosition) => Promise<{
139
- success: boolean;
140
- }>;
141
- /** Remove an element from a segment. */
142
- deleteSegmentElement: (spaceId: number, segmentId: string, elementId: string) => Promise<void>;
143
- /** Create a segment schema variable. */
144
- createSegmentVariable: (spaceId: number, segmentId: string, variable: Pick<SchemaVariable, 'name' | 'type' | 'value' | 'category'>) => Promise<SchemaVariable>;
145
- /** Update a segment schema variable. */
146
- updateSegmentVariable: (spaceId: number, segmentId: string, variable: Partial<SchemaVariable> & {
147
- name: string;
148
- }) => Promise<SchemaVariable>;
149
- /** Delete a segment schema variable. */
150
- deleteSegmentVariable: (spaceId: number, segmentId: string, name: string) => Promise<void>;
151
- /** Create a segment style variable. */
152
- createSegmentStyleVariable: (spaceId: number, segmentId: string, category: StyleVariableCategory, name: string, value: StyleVariableValue) => Promise<McpStyleVariable>;
153
- /** Update a segment style variable. */
154
- updateSegmentStyleVariable: (spaceId: number, segmentId: string, category: StyleVariableCategory, name: string, value: StyleVariableValue) => Promise<McpStyleVariable>;
155
- /** Delete a segment style variable. */
156
- deleteSegmentStyleVariable: (spaceId: number, segmentId: string, category: StyleVariableCategory, name: string) => Promise<void>;
157
- };
158
- export type McpServerConfig = {
159
- /** Whether the MCP endpoint is active. Defaults to true. */
160
- enabled?: boolean;
161
- /** URL path for the MCP endpoint. Defaults to '/mcp'. */
162
- path?: string;
163
- adapters: McpAdapters;
164
- };
File without changes