@plitzi/sdk-shared 0.32.4 → 0.32.6

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.
Files changed (131) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/dataSource/getBindingsDetails.mjs +17 -23
  3. package/dist/dataSource/helpers/getSourceName.d.ts +4 -0
  4. package/dist/dataSource/helpers/getSourceName.mjs +4 -0
  5. package/dist/dataSource/helpers/index.d.ts +2 -0
  6. package/dist/dataSource/helpers/index.mjs +2 -0
  7. package/dist/dataSource/hooks/useRegisterSource.mjs +20 -18
  8. package/dist/dataSource/index.d.ts +1 -0
  9. package/dist/dataSource/index.mjs +5 -4
  10. package/dist/dataSource/utility/twigTemplate.mjs +3 -2
  11. package/dist/helpers/index.mjs +7 -5
  12. package/dist/helpers/twigWrapper/AST.d.ts +116 -0
  13. package/dist/helpers/twigWrapper/Evaluator/Evaluator.d.ts +7 -0
  14. package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +220 -0
  15. package/dist/helpers/twigWrapper/Evaluator/helpers.d.ts +4 -0
  16. package/dist/helpers/twigWrapper/Evaluator/helpers.mjs +4 -0
  17. package/dist/helpers/twigWrapper/Evaluator/index.d.ts +2 -0
  18. package/dist/helpers/twigWrapper/Evaluator/index.mjs +2 -0
  19. package/dist/helpers/twigWrapper/Lexer/Lexer.d.ts +2 -0
  20. package/dist/helpers/twigWrapper/Lexer/Lexer.mjs +53 -0
  21. package/dist/helpers/twigWrapper/Lexer/index.d.ts +3 -0
  22. package/dist/helpers/twigWrapper/Lexer/index.mjs +3 -0
  23. package/dist/helpers/twigWrapper/Lexer/types.d.ts +17 -0
  24. package/dist/helpers/twigWrapper/Lexer/types.mjs +10 -0
  25. package/dist/helpers/twigWrapper/Parser/Cursor.d.ts +14 -0
  26. package/dist/helpers/twigWrapper/Parser/Cursor.mjs +63 -0
  27. package/dist/helpers/twigWrapper/Parser/ExpressionParser.d.ts +3 -0
  28. package/dist/helpers/twigWrapper/Parser/ExpressionParser.mjs +296 -0
  29. package/dist/helpers/twigWrapper/Parser/Parser.d.ts +3 -0
  30. package/dist/helpers/twigWrapper/Parser/Parser.mjs +237 -0
  31. package/dist/helpers/twigWrapper/Parser/helpers.d.ts +2 -0
  32. package/dist/helpers/twigWrapper/Parser/helpers.mjs +18 -0
  33. package/dist/helpers/twigWrapper/Parser/index.d.ts +2 -0
  34. package/dist/helpers/twigWrapper/Parser/index.mjs +2 -0
  35. package/dist/helpers/twigWrapper/Parser/types.d.ts +5 -0
  36. package/dist/helpers/twigWrapper/TemplateCache/TemplateCache.d.ts +17 -0
  37. package/dist/helpers/twigWrapper/TemplateCache/TemplateCache.mjs +64 -0
  38. package/dist/helpers/twigWrapper/TemplateCache/index.d.ts +1 -0
  39. package/dist/helpers/twigWrapper/TemplateCache/index.mjs +2 -0
  40. package/dist/helpers/twigWrapper/bench.bench.d.ts +1 -0
  41. package/dist/helpers/twigWrapper/charClass.d.ts +44 -0
  42. package/dist/helpers/twigWrapper/charClass.mjs +59 -0
  43. package/dist/helpers/twigWrapper/filters/filters.d.ts +14 -0
  44. package/dist/helpers/twigWrapper/filters/filters.mjs +372 -0
  45. package/dist/helpers/twigWrapper/filters/index.d.ts +1 -0
  46. package/dist/helpers/twigWrapper/filters/index.mjs +2 -0
  47. package/dist/helpers/twigWrapper/index.d.ts +5 -0
  48. package/dist/helpers/twigWrapper/index.mjs +4 -0
  49. package/dist/helpers/twigWrapper/processTwig/helpers.d.ts +7 -0
  50. package/dist/helpers/twigWrapper/processTwig/helpers.mjs +34 -0
  51. package/dist/helpers/twigWrapper/processTwig/index.d.ts +1 -0
  52. package/dist/helpers/twigWrapper/processTwig/index.mjs +2 -0
  53. package/dist/helpers/twigWrapper/processTwig/processTwig.d.ts +1 -0
  54. package/dist/helpers/twigWrapper/processTwig/processTwig.mjs +24 -0
  55. package/dist/helpers/twigWrapper/tokens/hasValidToken.d.ts +1 -0
  56. package/dist/helpers/twigWrapper/tokens/hasValidToken.mjs +9 -0
  57. package/dist/helpers/twigWrapper/tokens/tokenPatterns.d.ts +2 -0
  58. package/dist/helpers/twigWrapper/tokens/tokenPatterns.mjs +4 -0
  59. package/dist/hooks/useNetwork.mjs +1 -1
  60. package/dist/index.mjs +37 -34
  61. package/dist/network/graphql/builder/Mutations/Segment/SegmentAddMutation.mjs +1 -0
  62. package/dist/network/graphql/builder/Mutations/Segment/SegmentAddTemplateMutation.mjs +1 -0
  63. package/dist/network/graphql/builder/Mutations/Segment/SegmentUpdateMutation.mjs +1 -0
  64. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentAddElementMutation.mjs +1 -0
  65. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentCloneElementMutation.mjs +1 -0
  66. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentMoveElementMutation.mjs +1 -0
  67. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRemoveElementMutation.mjs +1 -0
  68. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementMutation.mjs +1 -0
  69. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementsMutation.d.ts +2 -0
  70. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementsMutation.mjs +24 -0
  71. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorsMutation.d.ts +2 -0
  72. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorsMutation.mjs +12 -0
  73. package/dist/network/graphql/builder/Mutations/Space/SpaceAddElementMutation.mjs +1 -0
  74. package/dist/network/graphql/builder/Mutations/Space/SpaceAddTemplateMutation.mjs +1 -0
  75. package/dist/network/graphql/builder/Mutations/Space/SpaceCloneElementMutation.mjs +1 -0
  76. package/dist/network/graphql/builder/Mutations/Space/SpaceMoveElementMutation.mjs +1 -0
  77. package/dist/network/graphql/builder/Mutations/Space/SpaceRemoveElementMutation.mjs +1 -0
  78. package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementMutation.mjs +1 -0
  79. package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementsMutation.d.ts +2 -0
  80. package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementsMutation.mjs +24 -0
  81. package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateMutation.mjs +1 -0
  82. package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSchemaMutation.mjs +1 -0
  83. package/dist/network/graphql/builder/Mutations/Space/pages/SpaceAddPageMutation.mjs +9 -2
  84. package/dist/network/graphql/builder/Mutations/Space/pages/SpaceUpdatePageMutation.mjs +1 -0
  85. package/dist/network/graphql/builder/Mutations/Style/selectors/StyleRemoveSelectorsMutation.d.ts +2 -0
  86. package/dist/network/graphql/builder/Mutations/Style/selectors/StyleRemoveSelectorsMutation.mjs +12 -0
  87. package/dist/network/graphql/builder/Mutations/index.d.ts +8 -0
  88. package/dist/network/graphql/builder/Mutations/index.mjs +124 -116
  89. package/dist/network/graphql/builder/Queries/InitQuery.mjs +2 -0
  90. package/dist/network/graphql/builder/Queries/Segment/SegmentQuery.mjs +1 -0
  91. package/dist/network/graphql/builder/Queries/Segment/SegmentsQuery.mjs +1 -0
  92. package/dist/network/graphql/builder/Subscriptions/Segment/SegmentAddTemplateSubscription.mjs +1 -0
  93. package/dist/network/graphql/builder/Subscriptions/Segment/space/elements/SegmentAddElementSubscription.mjs +1 -0
  94. package/dist/network/graphql/builder/Subscriptions/Segment/space/elements/SegmentCloneElementSubscription.mjs +1 -0
  95. package/dist/network/graphql/builder/Subscriptions/Segment/space/elements/SegmentUpdateElementSubscription.mjs +1 -0
  96. package/dist/network/graphql/builder/Subscriptions/Segment/space/elements/SegmentUpdateElementsSubscription.d.ts +7 -0
  97. package/dist/network/graphql/builder/Subscriptions/Segment/space/elements/SegmentUpdateElementsSubscription.mjs +27 -0
  98. package/dist/network/graphql/builder/Subscriptions/Segment/style/selectors/SegmentStyleRemoveSelectorsSubscription.d.ts +8 -0
  99. package/dist/network/graphql/builder/Subscriptions/Segment/style/selectors/SegmentStyleRemoveSelectorsSubscription.mjs +13 -0
  100. package/dist/network/graphql/builder/Subscriptions/Space/SpaceAddTemplateSubscription.mjs +1 -0
  101. package/dist/network/graphql/builder/Subscriptions/Space/SpaceUpdatedSubscription.mjs +1 -0
  102. package/dist/network/graphql/builder/Subscriptions/Space/elements/SpaceAddElementSubscription.mjs +1 -0
  103. package/dist/network/graphql/builder/Subscriptions/Space/elements/SpaceCloneElementSubscription.mjs +1 -0
  104. package/dist/network/graphql/builder/Subscriptions/Space/elements/SpaceUpdateElementSubscription.mjs +1 -0
  105. package/dist/network/graphql/builder/Subscriptions/Space/elements/SpaceUpdateElementsSubscription.d.ts +6 -0
  106. package/dist/network/graphql/builder/Subscriptions/Space/elements/SpaceUpdateElementsSubscription.mjs +26 -0
  107. package/dist/network/graphql/builder/Subscriptions/Space/pages/SpaceAddPageSubscription.mjs +1 -0
  108. package/dist/network/graphql/builder/Subscriptions/Space/pages/SpaceHomePageSubscription.mjs +1 -0
  109. package/dist/network/graphql/builder/Subscriptions/Space/pages/SpaceUpdatePageSubscription.mjs +1 -0
  110. package/dist/network/graphql/builder/Subscriptions/Style/selector/StyleRemoveSelectorsSubscription.d.ts +7 -0
  111. package/dist/network/graphql/builder/Subscriptions/Style/selector/StyleRemoveSelectorsSubscription.mjs +12 -0
  112. package/dist/network/graphql/builder/Subscriptions/index.d.ts +12 -0
  113. package/dist/network/graphql/builder/Subscriptions/index.mjs +94 -86
  114. package/dist/network/graphql/sdk/Queries/InitQuery.mjs +2 -0
  115. package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.mjs +1 -0
  116. package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.mjs +1 -0
  117. package/dist/store/index.d.ts +33 -33
  118. package/dist/store/tracing/preview.mjs +1 -1
  119. package/dist/style/styleConstants.mjs +12 -8
  120. package/dist/types/CommonTypes.d.ts +1 -3
  121. package/dist/types/EventBridgeTypes.d.ts +1 -1
  122. package/dist/types/InteractionTypes.d.ts +2 -1
  123. package/dist/types/McpTypes/index.d.ts +8 -44
  124. package/dist/types/SchemaTypes.d.ts +6 -8
  125. package/dist/types/ServerTypes.d.ts +147 -0
  126. package/dist/types/StyleTypes.d.ts +1 -0
  127. package/package.json +182 -30
  128. package/dist/helpers/twigWrapper.d.ts +0 -4
  129. package/dist/helpers/twigWrapper.mjs +0 -33
  130. package/dist/types/McpTypes/McpAdapters.d.ts +0 -455
  131. package/dist/types/McpTypes/McpAdapters.mjs +0 -0
@@ -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)]);
@@ -108,21 +108,25 @@ var e = {
108
108
  TEXT_OVERFLOW: "text-overflow",
109
109
  TEXT_SHADOW: "text-shadow"
110
110
  }, n = [
111
- t.TEXT_DECORATION,
112
- t.LINE_HEIGHT,
113
- t.LETTER_SPACING,
114
- t.COLOR,
115
- t.DIRECTION,
116
111
  t.FONT_FAMILY,
117
- t.FONT_WEIGHT,
118
112
  t.FONT_SIZE,
113
+ t.FONT_STYLE,
114
+ t.FONT_WEIGHT,
115
+ t.COLOR,
116
+ t.LINE_HEIGHT,
117
+ t.LETTER_SPACING,
119
118
  t.TEXT_ALIGN,
119
+ t.TEXT_DECORATION,
120
120
  t.TEXT_INDENT,
121
121
  t.TEXT_SHADOW,
122
122
  t.TEXT_TRANSFORM,
123
- t.WHITE_SPACE,
124
123
  t.TEXT_WRAP,
125
- t.TEXT_OVERFLOW
124
+ t.TEXT_OVERFLOW,
125
+ t.WHITE_SPACE,
126
+ t.DIRECTION,
127
+ t.CURSOR,
128
+ t.LIST_STYLE,
129
+ t.LIST_STYLE_TYPE
126
130
  ], r = Object.values(t).map((e) => ({
127
131
  path: e,
128
132
  label: e
@@ -8,9 +8,7 @@ export type Server<T extends Record<string, unknown> = Record<string, unknown>>
8
8
  host?: string;
9
9
  domain?: string;
10
10
  requestUrl?: string;
11
- nodeServer: string;
12
- aiServer: string;
13
- graphqlServer: string;
11
+ serverUrl: string;
14
12
  websocketServer: string;
15
13
  subscriptionServer: string;
16
14
  location?: Location;
@@ -2,4 +2,4 @@ export type EventBridgeContextValue<T = any> = {
2
2
  eventBridge: T;
3
3
  };
4
4
  export type EventBridgeModule = 'main' | 'builder' | 'segment' | 'template' | 'interaction' | 'element';
5
- export type EventBridgeEvent = 'schemaAddPage' | 'schemaHomePage' | 'schemaUpdatePage' | 'schemaRemovePage' | 'schemaAddPageFolder' | 'schemaUpdatePageFolder' | 'schemaRemovePageFolder' | 'schemaUpdateSettings' | 'schemaUpdate' | 'schemaAddElement' | 'schemaUpdateElement' | 'schemaRemoveElement' | 'schemaMoveElement' | 'schemaCloneElement' | 'schemaAddVariable' | 'schemaUpdateVariable' | 'schemaRemoveVariable' | 'schemaAddTemplate' | 'styleUpdate' | 'styleAddSelector' | 'styleUpdateSelector' | 'styleRemoveSelector' | 'styleAddSelectorVariable' | 'styleUpdateSelectorVariable' | 'styleRemoveSelectorVariable' | 'styleAddVariable' | 'styleUpdateVariable' | 'styleRemoveVariable' | 'styleAddTemplate' | 'styleUpdateSettings' | 'builderSetBaseContext' | 'builderSetSelected' | 'builderSetHovered';
5
+ export type EventBridgeEvent = 'schemaAddPage' | 'schemaHomePage' | 'schemaUpdatePage' | 'schemaRemovePage' | 'schemaAddPageFolder' | 'schemaUpdatePageFolder' | 'schemaRemovePageFolder' | 'schemaUpdateSettings' | 'schemaUpdate' | 'schemaAddElement' | 'schemaUpdateElement' | 'schemaUpdateElements' | 'schemaRemoveElement' | 'schemaMoveElement' | 'schemaCloneElement' | 'schemaAddVariable' | 'schemaUpdateVariable' | 'schemaRemoveVariable' | 'schemaAddTemplate' | 'styleUpdate' | 'styleAddSelector' | 'styleUpdateSelector' | 'styleRemoveSelector' | 'styleRemoveSelectors' | 'styleAddSelectorVariable' | 'styleUpdateSelectorVariable' | 'styleRemoveSelectorVariable' | 'styleAddVariable' | 'styleUpdateVariable' | 'styleRemoveVariable' | 'styleAddTemplate' | 'styleUpdateSettings' | 'builderSetBaseContext' | 'builderSetSelected' | 'builderSetHovered';
@@ -68,6 +68,7 @@ export type InteractionCallback<T extends Record<string, unknown> = Record<strin
68
68
  title: string;
69
69
  type: InteractionCallbackType;
70
70
  enabled?: boolean;
71
+ unreferenced?: boolean;
71
72
  params: Record<keyof T, InteractionCallbackParam<T>> | ((params: InteractionCallbackParamValues<T>) => Record<keyof T, InteractionCallbackParam<T>>);
72
73
  callback?: (params: InteractionCallbackParamValues<T>) => unknown;
73
74
  postCallback?: InteractionPostCallback<T>;
@@ -92,7 +93,7 @@ export type Subscriptor<T extends Record<string, unknown> = Record<string, unkno
92
93
  export type InteractionsContextValue<TManager = any> = {
93
94
  interactionsManager: TManager;
94
95
  useInteractions: <T extends Record<string, unknown> = Record<string, unknown>>(props: {
95
- id: string;
96
+ id?: string;
96
97
  interactions?: Record<string, ElementInteraction>;
97
98
  triggers?: Record<string, InteractionCallback<T>>;
98
99
  callbacks?: Record<string, InteractionCallback<T>>;
@@ -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
  };
@@ -13,21 +13,17 @@ export type SchemaRsc = {
13
13
  export type DropPosition = 'top' | 'bottom' | 'left' | 'right' | 'inside' | 'custom';
14
14
  export type BindingCategory = 'attributes' | 'style' | 'initialState';
15
15
  export type BindingTransformer = {
16
- type: 'utility' | 'unknown';
17
16
  action: string;
18
- params: {
19
- valueType: string;
20
- value: string;
21
- };
17
+ params: Record<string, string>;
18
+ enabled?: boolean;
22
19
  };
23
20
  export type ElementBinding = {
24
21
  id: string;
25
22
  source: string;
26
- fromPath?: string;
27
23
  transformers?: BindingTransformer[];
28
24
  when?: RuleGroup;
29
25
  enabled?: boolean;
30
- toPath: string;
26
+ to: string;
31
27
  };
32
28
  export type ElementInteraction<T extends Record<keyof InteractionCallback['params'], unknown> = Record<string, unknown>> = {
33
29
  id: string;
@@ -36,7 +32,7 @@ export type ElementInteraction<T extends Record<keyof InteractionCallback['param
36
32
  action: string;
37
33
  params: InteractionCallbackParamValues<T>;
38
34
  preview: Record<string, unknown>;
39
- elementId: Element['id'];
35
+ elementId: Element['id'] | null;
40
36
  beforeNode: string;
41
37
  afterNode: string;
42
38
  flowId: string;
@@ -68,6 +64,7 @@ export type ElementDefinition = {
68
64
  };
69
65
  export type Element<TAttributes extends Record<string, unknown> = Record<string, unknown>> = {
70
66
  id: string;
67
+ idRef?: string;
71
68
  attributes: TAttributes & {
72
69
  subType?: string;
73
70
  };
@@ -125,6 +122,7 @@ export type SchemaContextValue = {
125
122
  schemaUpdate?: (newSchema: SchemaRaw, fromSubscriptions?: boolean) => void;
126
123
  schemaAddElement?: (to: string, data: Element, dropPosition?: DropPosition, initialItems?: Record<string, Element>, variables?: SchemaVariable[], fromSubscriptions?: boolean) => void;
127
124
  schemaUpdateElement?: (element: Element, fromSubscriptions?: boolean) => void;
125
+ schemaUpdateElements?: (elements: Element[], fromSubscriptions?: boolean) => void;
128
126
  schemaMoveElement?: (from: string, to: string, elementId: string, dropPosition?: DropPosition, fromSubscriptions?: boolean) => void;
129
127
  schemaCloneElement?: (elementId: string, targetId?: string, fromSubscriptions?: boolean) => void;
130
128
  schemaRemoveElement?: (elementId: string, fromSubscriptions?: boolean) => void;
@@ -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';
@@ -120,9 +122,61 @@ export type SSRRscData = {
120
122
  /** Per-element server data keyed by schema element ID. Each element reads its own slice via its id prop. */
121
123
  serverData?: Record<string, unknown>;
122
124
  };
125
+ /** Semantic + machine-readable metadata for one element type, so the MCP can tell an agent what the type DOES
126
+ * (not just that it exists) AND validate against it. `category` groups it (e.g. provider, structure, media);
127
+ * `custom` marks a plugin-provided type. The MCP keys strict-vs-lenient validation off `custom`: a `custom:false`
128
+ * (default sdk-elements) type is authoritative — an unknown attribute/setState key on it is an error — while a
129
+ * `custom:true` (plugin) type is best-effort (warnings only), since its metadata is a manifest snapshot. */
130
+ export type ComponentCatalogEntry = {
131
+ label?: string;
132
+ description?: string;
133
+ category?: string;
134
+ custom?: boolean;
135
+ /** The type's attribute/prop keys — the authoritative set for a default type (setState `key` when
136
+ * category="attribute", and type-prop validation). Absent when unknown (e.g. a plugin with no manifest). */
137
+ attributes?: string[];
138
+ /** The type's `definition.styleSelectors` keys (slots) — setState `key` when category="state" is
139
+ * `visibility` or `styleSelectors.<selector>`. */
140
+ styleSelectors?: string[];
141
+ /** The type's intrinsic base default CSS (its `defaultStyle.style.base.default`) — the declarations the element
142
+ * renders with before any class is attached, e.g. `text` defaults to `{ display: 'inline' }`. The MCP surfaces
143
+ * it so an agent styles against the real starting point instead of assuming `display: block`. */
144
+ defaultStyle?: Record<string, string>;
145
+ /** Binding targets the type exposes, from the plugin manifest's `defaultStyle.bindingsAllowed`. */
146
+ bindingsAllowed?: {
147
+ attributes?: string[];
148
+ initialState?: string[];
149
+ };
150
+ };
151
+ /** Element type → its semantic metadata, keyed by the `type` string used in the schema. Covers BOTH the default
152
+ * sdk-elements types (custom:false, authoritative) and the plugin (custom:true) element types installed on a
153
+ * space, so the MCP can validate types/attributes dynamically per space instead of against a hand-mirror. */
154
+ export type ComponentCatalog = Record<string, ComponentCatalogEntry>;
123
155
  export type SSRAdapters = {
124
156
  getOfflineData: (spaceId: number, environment: string, revision?: number) => Promise<OfflineDataRaw | undefined>;
125
157
  getSpaceDeployment: (req: SSRRequest) => Promise<SSRSpaceDeployment>;
158
+ /** Persist a space mutated by the mcp-ai `apply` tool. Implementations must recompute derived caches
159
+ * (notably `style.cache`) before storing. When omitted, mcp-ai runs read/preview/validate only and
160
+ * `apply` reports `persisted: false`. */
161
+ saveOfflineData?: (spaceId: number, environment: string, data: OfflineDataRaw) => Promise<void>;
162
+ /** Resolve the spaceId the MCP request operates on, from the verified `Authorization` bearer. The consumer
163
+ * owns the JWT secret, so it decodes here; the MCP service stays stateless. Returns undefined when the
164
+ * token is missing or invalid. Required for the `mcp` service to serve any request. */
165
+ getSpaceId?: (req: SSRRequest) => Promise<number | undefined>;
166
+ /** Read the element schema for the MCP tools. Separate from `getOfflineData` (which is SSR/RSC shaped and
167
+ * strips `style.platform`); the MCP style resource needs the full documents, so schema and style split. */
168
+ getSchema?: (spaceId: number, environment: Environment) => Promise<Schema | undefined>;
169
+ /** Read the full style document (with `platform`/`mode`, which the MCP definitions resource requires). */
170
+ getStyle?: (spaceId: number, environment: Environment) => Promise<Style | undefined>;
171
+ /** Read the semantic catalog of the space's PLUGIN (custom) element types — label/description/category from
172
+ * each installed plugin's manifest — so the MCP `plitzi://types` resource can explain what custom elements do.
173
+ * The MCP already knows the built-in types. When omitted, custom types surface with their observed label only. */
174
+ getComponentCatalog?: (spaceId: number, environment: Environment) => Promise<ComponentCatalog | undefined>;
175
+ /** Persist the element schema mutated by the MCP `apply` tool. When omitted, `apply` reports `persisted: false`. */
176
+ saveSchema?: (spaceId: number, environment: Environment, schema: Schema) => Promise<void>;
177
+ /** Persist the style document mutated by the MCP `apply` tool. Implementations must recompute `style.cache`
178
+ * before storing. When omitted, `apply` reports `persisted: false`. */
179
+ saveStyle?: (spaceId: number, environment: Environment, style: Style) => Promise<void>;
126
180
  getUser?: (req: SSRRequest) => Promise<SSRUser | undefined>;
127
181
  onLogin?: (req: SSRRequest, res: SSRResponseHelpers) => Promise<boolean>;
128
182
  onLogout?: (req: SSRRequest, res: SSRResponseHelpers) => Promise<void>;
@@ -139,6 +193,27 @@ export type SSRRscConfig = {
139
193
  /** Server-side cache TTL for RSC responses in milliseconds. Defaults to 30 000. Set to 0 to disable. */
140
194
  cacheTtlMs?: number;
141
195
  };
196
+ /** A structured log event the MCP server emits for each tool call and resource read, so a CONSUMER can render its
197
+ * own request log (dev tooling, a dashboard, structured logging). Wire a sink via `SSRServerConfig.mcpLogger`;
198
+ * without one the server prints to the console only when `MCP_DEBUG=1`. */
199
+ export type McpLogEvent = {
200
+ /** 'tool' for a plitzi_* tool call, 'resource' for a plitzi:// resource read. */
201
+ kind: 'tool' | 'resource';
202
+ /** The tool name (e.g. 'plitzi_apply') or the resource URI that was read. */
203
+ name: string;
204
+ /** Wall-clock duration of the handler, in milliseconds. */
205
+ durationMs: number;
206
+ /** Whether the handler completed without throwing. */
207
+ ok: boolean;
208
+ /** The error message when `ok` is false. */
209
+ error?: string;
210
+ /** A compact, truncated JSON summary of the tool arguments (tool events only). */
211
+ argsSummary?: string;
212
+ /** ISO-8601 timestamp of when the event was emitted. */
213
+ timestamp: string;
214
+ };
215
+ /** A sink the consumer provides to receive every MCP {@link McpLogEvent} (see `SSRServerConfig.mcpLogger`). */
216
+ export type McpLogger = (event: McpLogEvent) => void;
142
217
  export type SSRServerConfig = {
143
218
  port?: number;
144
219
  host?: string;
@@ -176,10 +251,62 @@ export type SSRServerConfig = {
176
251
  rsc?: SSRRscConfig;
177
252
  /** MCP (Model Context Protocol) server configuration — exposes schema tools to Claude. */
178
253
  mcp?: McpServerConfig;
254
+ /** AI-native MCP server — replaces the standard MCP with a zero-hallucination batch protocol.
255
+ * When enabled, requests to the MCP path serve the AI-native server instead. */
256
+ mcpAi?: {
257
+ enabled?: boolean;
258
+ path?: string;
259
+ };
260
+ /** Receives a structured {@link McpLogEvent} for every MCP tool call and resource read, so the consumer can
261
+ * render its own request log (e.g. in dev mode). Without it, the MCP server logs to the console only when
262
+ * `MCP_DEBUG=1`. */
263
+ mcpLogger?: McpLogger;
179
264
  adapters: SSRAdapters;
265
+ /** Draft-preview endpoint for the MCP visual-preview tools (the RENDERER side). Off unless `enabled`. */
266
+ preview?: SSRPreviewConfig;
267
+ /** For an MCP server that runs separately from the renderer (the CLIENT side): where to reach the SSR
268
+ * `/preview` endpoint so the visual-preview tools work. The SDK builds an HTTP preview client from this;
269
+ * absent → those tools report PREVIEW_UNAVAILABLE. */
270
+ previewClient?: {
271
+ url: string;
272
+ secret?: string;
273
+ };
274
+ /** Dedicated headless-browser service for plitzi_screenshot (off unless set). `serviceUrl` is the browser
275
+ * service that turns a URL into PNG(s); `renderBaseUrl` is the SSR base the browser navigates to (a page
276
+ * path + the one-shot `__pt` token are appended). When absent, plitzi_screenshot is not registered and only
277
+ * the HTML plitzi_preview is available; when the service is unreachable at call time the tool degrades to
278
+ * returning the HTML preview with a warning. */
279
+ screenshot?: {
280
+ serviceUrl: string;
281
+ renderBaseUrl: string;
282
+ };
283
+ /** Backing store for draft-preview tokens. Defaults to an in-memory store (single replica); inject a shared
284
+ * store (e.g. Redis) for multi-replica correctness. */
285
+ draftStore?: DraftStore;
286
+ /** Which request-handling services this server mounts. Each maps to an internal `create<Name>Server` unit,
287
+ * so new services scale without rewriting the dispatcher. Omitted flags fall back to sensible defaults:
288
+ * ssr on, rsc when `adapters.getRscData` exists, mcp from `mcpAi.enabled`. `ai` is a reserved slot (not
289
+ * wired yet). The per-service presets (createSSRServer / createMCPServer) pin these flags for you. */
290
+ services?: ServerServices;
291
+ /** Liveness/readiness endpoint for standalone servers (k8s probes). A stage always answers `path`
292
+ * (default /health) with 200. The body is the generic identity payload built from `name`/`version`/`role`
293
+ * ({ Server, Version, role }); pass an explicit `payload` to override it entirely. */
294
+ health?: {
295
+ path?: string;
296
+ payload?: Record<string, unknown>;
297
+ name?: string;
298
+ version?: string;
299
+ role?: string;
300
+ };
180
301
  /** 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
302
  assetVersion?: string;
182
303
  };
304
+ export type ServerServices = {
305
+ ssr?: boolean;
306
+ rsc?: boolean;
307
+ mcp?: boolean;
308
+ ai?: boolean;
309
+ };
183
310
  export type PluginRegistry = {
184
311
  register: (name: string, source: PluginSource) => void;
185
312
  invalidate: (name?: string, version?: string) => Promise<void>;
@@ -206,3 +333,23 @@ export type SSRServer = {
206
333
  readonly cache: CacheManager | null;
207
334
  readonly plugins: PluginRegistry;
208
335
  };
336
+ /** A short-TTL, one-shot store for unsaved draft offline-data behind a preview token. The SDK ships an
337
+ * in-memory default (fine for a single replica); a multi-replica deployment injects a shared (e.g. Redis)
338
+ * implementation so a preview URL resolves on whichever replica the browser lands on. `take` consumes the
339
+ * token so a preview URL is not replayable. */
340
+ export type DraftStore = {
341
+ put: (token: string, data: OfflineDataRaw, ttlMs: number) => void | Promise<void>;
342
+ take: (token: string) => (OfflineDataRaw | undefined) | Promise<OfflineDataRaw | undefined>;
343
+ };
344
+ /** Draft-preview config for the MCP visual-preview tools. When enabled, an internal endpoint at `path`
345
+ * (guarded by `secret`) applies unsaved edits to a clone, stashes the resulting offline-data under a
346
+ * one-shot token, and the render path serves it back at `?__pt=<token>`. Off by default. */
347
+ export type SSRPreviewConfig = {
348
+ enabled?: boolean;
349
+ /** Internal endpoint path that mints a preview token. Default '/__preview'. */
350
+ path?: string;
351
+ /** Shared secret required in the `x-preview-secret` header; requests without it are rejected. */
352
+ secret?: string;
353
+ /** Token time-to-live in milliseconds. Default 60000. */
354
+ ttlMs?: number;
355
+ };
@@ -48,6 +48,7 @@ export type StyleContextValue = {
48
48
  styleAddSelector?: unknown;
49
49
  styleUpdateSelector?: unknown;
50
50
  styleRemoveSelector?: unknown;
51
+ styleRemoveSelectors?: unknown;
51
52
  styleAddSelectorVariable?: unknown;
52
53
  styleUpdateSelectorVariable?: unknown;
53
54
  styleRemoveSelectorVariable?: unknown;