@plitzi/sdk-server 0.32.5 → 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 (168) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/core/services/mcp.js +1 -1
  3. package/dist/helpers/buildServerInfo.js +3 -9
  4. package/dist/index.js +2 -1
  5. package/dist/modules/mcp/catalogs/builtinCallbacks.js +204 -0
  6. package/dist/modules/mcp/catalogs/builtinComponents.js +170 -0
  7. package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +50 -0
  8. package/dist/modules/mcp/catalogs/builtinTransformers.js +148 -0
  9. package/dist/modules/mcp/catalogs/builtinUtilities.js +90 -0
  10. package/dist/modules/mcp/{tools/operations/style → catalogs}/cssCatalog.js +75 -2
  11. package/dist/modules/mcp/catalogs/observed.js +90 -0
  12. package/dist/modules/mcp/catalogs/paramSpec.js +69 -0
  13. package/dist/modules/mcp/catalogs/registry.js +89 -0
  14. package/dist/modules/mcp/handler.js +12 -2
  15. package/dist/modules/mcp/helpers/agentPrompt.js +104 -0
  16. package/dist/modules/mcp/helpers/guide.js +334 -15
  17. package/dist/modules/mcp/helpers/interactions.js +123 -0
  18. package/dist/modules/mcp/helpers/log.js +54 -0
  19. package/dist/modules/mcp/helpers/space.js +158 -33
  20. package/dist/modules/mcp/helpers/uris.js +44 -0
  21. package/dist/modules/mcp/resources/canonical.js +6 -21
  22. package/dist/modules/mcp/resources/core.js +4 -3
  23. package/dist/modules/mcp/resources/primer.js +13 -8
  24. package/dist/modules/mcp/resources/register.js +37 -5
  25. package/dist/modules/mcp/resources/schema.js +30 -20
  26. package/dist/modules/mcp/resources/style.js +18 -11
  27. package/dist/modules/mcp/server.js +21 -7
  28. package/dist/modules/mcp/tools/apply/dispatch.js +38 -18
  29. package/dist/modules/mcp/tools/apply/index.js +19 -4
  30. package/dist/modules/mcp/tools/apply/writeResult.js +2 -1
  31. package/dist/modules/mcp/tools/index.js +1 -1
  32. package/dist/modules/mcp/tools/operations/index.js +13 -2
  33. package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +32 -0
  34. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +36 -0
  35. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +47 -0
  36. package/dist/modules/mcp/tools/operations/schema/{deleteElement.js → elements/deleteElement.js} +10 -6
  37. package/dist/modules/mcp/tools/operations/schema/{moveElement.js → elements/moveElement.js} +8 -6
  38. package/dist/modules/mcp/tools/operations/schema/{patchElement.js → elements/patchElement.js} +19 -7
  39. package/dist/modules/mcp/tools/operations/schema/{upsertElement.js → elements/upsertElement.js} +11 -5
  40. package/dist/modules/mcp/tools/operations/schema/{deleteFolder.js → folders/deleteFolder.js} +4 -4
  41. package/dist/modules/mcp/tools/operations/schema/{upsertFolder.js → folders/upsertFolder.js} +4 -4
  42. package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +52 -0
  43. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +47 -0
  44. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +43 -0
  45. package/dist/modules/mcp/tools/operations/schema/operations.js +25 -11
  46. package/dist/modules/mcp/tools/operations/schema/{deletePage.js → pages/deletePage.js} +8 -5
  47. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +75 -0
  48. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +45 -0
  49. package/dist/modules/mcp/tools/operations/schema/shared.js +94 -2
  50. package/dist/modules/mcp/tools/operations/schema/translator.js +77 -10
  51. package/dist/modules/mcp/tools/operations/schema/{deleteVariable.js → variables/deleteVariable.js} +3 -3
  52. package/dist/modules/mcp/tools/operations/schema/{upsertVariable.js → variables/upsertVariable.js} +4 -4
  53. package/dist/modules/mcp/tools/operations/schema/write.js +78 -13
  54. package/dist/modules/mcp/tools/operations/style/{deleteDefinition.js → definitions/deleteDefinition.js} +4 -3
  55. package/dist/modules/mcp/tools/operations/style/{patchDefinition.js → definitions/patchDefinition.js} +6 -5
  56. package/dist/modules/mcp/tools/operations/style/{upsertDefinition.js → definitions/upsertDefinition.js} +5 -4
  57. package/dist/modules/mcp/tools/operations/style/{deleteGlobalStyle.js → globalStyles/deleteGlobalStyle.js} +4 -3
  58. package/dist/modules/mcp/tools/operations/style/{patchGlobalStyle.js → globalStyles/patchGlobalStyle.js} +6 -5
  59. package/dist/modules/mcp/tools/operations/style/{upsertGlobalStyle.js → globalStyles/upsertGlobalStyle.js} +5 -4
  60. package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +21 -0
  61. package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +28 -0
  62. package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +24 -0
  63. package/dist/modules/mcp/tools/operations/style/operations.js +14 -8
  64. package/dist/modules/mcp/tools/operations/style/translator.js +25 -1
  65. package/dist/modules/mcp/tools/operations/style/{deleteStyleVariable.js → variables/deleteStyleVariable.js} +4 -4
  66. package/dist/modules/mcp/tools/operations/style/{upsertStyleVariable.js → variables/upsertStyleVariable.js} +4 -4
  67. package/dist/modules/mcp/tools/operations/style/write.js +19 -11
  68. package/dist/modules/mcp/tools/read.js +1 -1
  69. package/dist/modules/mcp/tools/search.js +34 -27
  70. package/dist/modules/mcp/tools/shared/validator/audit.js +124 -0
  71. package/dist/modules/mcp/tools/shared/validator/batch.js +30 -0
  72. package/dist/modules/mcp/tools/shared/validator/bindings.js +70 -0
  73. package/dist/modules/mcp/tools/shared/validator/context.js +35 -0
  74. package/dist/modules/mcp/tools/shared/validator/css.js +47 -0
  75. package/dist/modules/mcp/tools/shared/validator/elements.js +55 -0
  76. package/dist/modules/mcp/tools/shared/validator/index.js +226 -0
  77. package/dist/modules/mcp/tools/shared/validator/interactions.js +106 -0
  78. package/dist/modules/mcp/tools/shared/validator/refs.js +28 -0
  79. package/dist/modules/mcp/tools/validate.js +23 -3
  80. package/dist/modules/ssr/preview.js +1 -1
  81. package/dist/modules/ssr/views/template.ejs +2 -0
  82. package/dist/src/index.d.ts +1 -1
  83. package/dist/src/modules/mcp/catalogs/builtinCallbacks.d.ts +23 -0
  84. package/dist/src/modules/mcp/catalogs/builtinComponents.d.ts +4 -0
  85. package/dist/src/modules/mcp/catalogs/builtinElementCallbacks.d.ts +20 -0
  86. package/dist/src/modules/mcp/catalogs/builtinTransformers.d.ts +28 -0
  87. package/dist/src/modules/mcp/catalogs/builtinTransformers.test.d.ts +1 -0
  88. package/dist/src/modules/mcp/catalogs/builtinUtilities.d.ts +18 -0
  89. package/dist/src/modules/mcp/{tools/operations/style → catalogs}/cssCatalog.d.ts +5 -1
  90. package/dist/src/modules/mcp/catalogs/index.d.ts +9 -0
  91. package/dist/src/modules/mcp/catalogs/observed.d.ts +48 -0
  92. package/dist/src/modules/mcp/catalogs/paramSpec.d.ts +42 -0
  93. package/dist/src/modules/mcp/catalogs/registry.d.ts +35 -0
  94. package/dist/src/modules/mcp/handler.d.ts +2 -2
  95. package/dist/src/modules/mcp/helpers/agentPrompt.d.ts +4 -0
  96. package/dist/src/modules/mcp/helpers/guide.d.ts +2 -1
  97. package/dist/src/modules/mcp/helpers/index.d.ts +4 -0
  98. package/dist/src/modules/mcp/helpers/interactions.d.ts +30 -0
  99. package/dist/src/modules/mcp/helpers/log.d.ts +8 -0
  100. package/dist/src/modules/mcp/helpers/log.test.d.ts +1 -0
  101. package/dist/src/modules/mcp/helpers/space.d.ts +67 -11
  102. package/dist/src/modules/mcp/helpers/uris.d.ts +28 -0
  103. package/dist/src/modules/mcp/index.d.ts +1 -1
  104. package/dist/src/modules/mcp/mcp.bench.d.ts +1 -0
  105. package/dist/src/modules/mcp/resources/canonical.d.ts +0 -1
  106. package/dist/src/modules/mcp/resources/index.d.ts +2 -3
  107. package/dist/src/modules/mcp/resources/primer.d.ts +2 -1
  108. package/dist/src/modules/mcp/resources/register.d.ts +2 -2
  109. package/dist/src/modules/mcp/server.d.ts +5 -2
  110. package/dist/src/modules/mcp/tools/apply/index.d.ts +191 -2
  111. package/dist/src/modules/mcp/tools/operations/index.d.ts +383 -4
  112. package/dist/src/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +17 -0
  113. package/dist/src/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +25 -0
  114. package/dist/src/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +27 -0
  115. package/dist/src/modules/mcp/tools/operations/schema/{deleteElement.d.ts → elements/deleteElement.d.ts} +2 -2
  116. package/dist/src/modules/mcp/tools/operations/schema/{moveElement.d.ts → elements/moveElement.d.ts} +2 -2
  117. package/dist/src/modules/mcp/tools/operations/schema/{patchElement.d.ts → elements/patchElement.d.ts} +7 -2
  118. package/dist/src/modules/mcp/tools/operations/schema/{upsertElement.d.ts → elements/upsertElement.d.ts} +3 -3
  119. package/dist/src/modules/mcp/tools/operations/schema/{deleteFolder.d.ts → folders/deleteFolder.d.ts} +2 -2
  120. package/dist/src/modules/mcp/tools/operations/schema/{upsertFolder.d.ts → folders/upsertFolder.d.ts} +2 -2
  121. package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +17 -11
  122. package/dist/src/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +12 -0
  123. package/dist/src/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +18 -0
  124. package/dist/src/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +27 -0
  125. package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +131 -0
  126. package/dist/src/modules/mcp/tools/operations/schema/{deletePage.d.ts → pages/deletePage.d.ts} +2 -2
  127. package/dist/src/modules/mcp/tools/operations/schema/{upsertPage.d.ts → pages/upsertPage.d.ts} +3 -2
  128. package/dist/src/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +34 -0
  129. package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +53 -0
  130. package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +5 -2
  131. package/dist/src/modules/mcp/tools/operations/schema/{deleteVariable.d.ts → variables/deleteVariable.d.ts} +2 -2
  132. package/dist/src/modules/mcp/tools/operations/schema/{upsertVariable.d.ts → variables/upsertVariable.d.ts} +2 -2
  133. package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +38 -8
  134. package/dist/src/modules/mcp/tools/operations/style/{deleteDefinition.d.ts → definitions/deleteDefinition.d.ts} +2 -2
  135. package/dist/src/modules/mcp/tools/operations/style/{patchDefinition.d.ts → definitions/patchDefinition.d.ts} +2 -2
  136. package/dist/src/modules/mcp/tools/operations/style/{upsertDefinition.d.ts → definitions/upsertDefinition.d.ts} +2 -2
  137. package/dist/src/modules/mcp/tools/operations/style/{deleteGlobalStyle.d.ts → globalStyles/deleteGlobalStyle.d.ts} +2 -2
  138. package/dist/src/modules/mcp/tools/operations/style/{patchGlobalStyle.d.ts → globalStyles/patchGlobalStyle.d.ts} +2 -2
  139. package/dist/src/modules/mcp/tools/operations/style/{upsertGlobalStyle.d.ts → globalStyles/upsertGlobalStyle.d.ts} +2 -2
  140. package/dist/src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +9 -0
  141. package/dist/src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +37 -0
  142. package/dist/src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +37 -0
  143. package/dist/src/modules/mcp/tools/operations/style/index.d.ts +11 -9
  144. package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +70 -2
  145. package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +1 -1
  146. package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +4 -1
  147. package/dist/src/modules/mcp/tools/operations/style/{deleteStyleVariable.d.ts → variables/deleteStyleVariable.d.ts} +3 -3
  148. package/dist/src/modules/mcp/tools/operations/style/{upsertStyleVariable.d.ts → variables/upsertStyleVariable.d.ts} +3 -3
  149. package/dist/src/modules/mcp/tools/operations/style/write.d.ts +2 -7
  150. package/dist/src/modules/mcp/tools/preview.d.ts +191 -2
  151. package/dist/src/modules/mcp/tools/screenshot.d.ts +191 -2
  152. package/dist/src/modules/mcp/tools/shared/validator/audit.d.ts +4 -0
  153. package/dist/src/modules/mcp/tools/shared/validator/batch.d.ts +5 -0
  154. package/dist/src/modules/mcp/tools/shared/validator/bindings.d.ts +6 -0
  155. package/dist/src/modules/mcp/tools/shared/validator/context.d.ts +34 -0
  156. package/dist/src/modules/mcp/tools/shared/validator/css.d.ts +4 -0
  157. package/dist/src/modules/mcp/tools/shared/validator/elements.d.ts +6 -0
  158. package/dist/src/modules/mcp/tools/shared/validator/index.d.ts +8 -0
  159. package/dist/src/modules/mcp/tools/shared/validator/interactions.d.ts +3 -0
  160. package/dist/src/modules/mcp/tools/shared/validator/refs.d.ts +4 -0
  161. package/dist/src/modules/mcp/tools/validate.d.ts +191 -2
  162. package/dist/src/modules/mcp/types/aiSchema.d.ts +93 -1
  163. package/package.json +12 -10
  164. package/dist/modules/mcp/tools/operations/schema/registry.js +0 -55
  165. package/dist/modules/mcp/tools/operations/schema/upsertPage.js +0 -64
  166. package/dist/modules/mcp/tools/shared/validator.js +0 -262
  167. package/dist/src/modules/mcp/tools/operations/schema/registry.d.ts +0 -22
  168. package/dist/src/modules/mcp/tools/shared/validator.d.ts +0 -4
@@ -1,8 +1,9 @@
1
- import { empty } from "../../../helpers/opResult.js";
2
- import { defUri, defsUri, guardKind, writeStyleItem } from "./write.js";
3
- import { upsertCssShape } from "./shared.js";
1
+ import { defUri, defsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { guardKind, writeStyleItem } from "../write.js";
4
+ import { upsertCssShape } from "../shared.js";
4
5
  import { z } from "zod";
5
- //#region src/modules/mcp/tools/operations/style/upsertDefinition.ts
6
+ //#region src/modules/mcp/tools/operations/style/definitions/upsertDefinition.ts
6
7
  var upsertDefinitionOp = z.object({
7
8
  type: z.literal("upsertDefinition"),
8
9
  ref: z.string().describe("Class name you choose (kebab-case), or an existing class ref to fully replace"),
@@ -1,7 +1,8 @@
1
- import { empty } from "../../../helpers/opResult.js";
2
- import { MODES, globalUri, globalsUri, guardKind } from "./write.js";
1
+ import { globalUri, globalsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { MODES, guardKind } from "../write.js";
3
4
  import { z } from "zod";
4
- //#region src/modules/mcp/tools/operations/style/deleteGlobalStyle.ts
5
+ //#region src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.ts
5
6
  var deleteGlobalStyleOp = z.object({
6
7
  type: z.literal("deleteGlobalStyle"),
7
8
  componentType: z.string().describe("Element type whose site-wide style to remove")
@@ -1,9 +1,10 @@
1
- import { empty, fail } from "../../../helpers/opResult.js";
2
- import { globalStyleToAI } from "./translator.js";
3
- import { globalUri, globalsUri, guardKind, mergePatch, writeStyleItem } from "./write.js";
4
- import { patchCssShape } from "./shared.js";
1
+ import { globalUri, globalsUri } from "../../../../helpers/uris.js";
2
+ import { empty, fail } from "../../../../helpers/opResult.js";
3
+ import { globalStyleToAI } from "../translator.js";
4
+ import { guardKind, mergePatch, writeStyleItem } from "../write.js";
5
+ import { patchCssShape } from "../shared.js";
5
6
  import { z } from "zod";
6
- //#region src/modules/mcp/tools/operations/style/patchGlobalStyle.ts
7
+ //#region src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.ts
7
8
  var patchGlobalStyleOp = z.object({
8
9
  type: z.literal("patchGlobalStyle"),
9
10
  componentType: z.string().describe("Element type whose global style to merge into; affects ALL of that type"),
@@ -1,8 +1,9 @@
1
- import { empty } from "../../../helpers/opResult.js";
2
- import { globalUri, globalsUri, guardKind, writeStyleItem } from "./write.js";
3
- import { upsertCssShape } from "./shared.js";
1
+ import { globalUri, globalsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { guardKind, writeStyleItem } from "../write.js";
4
+ import { upsertCssShape } from "../shared.js";
4
5
  import { z } from "zod";
5
- //#region src/modules/mcp/tools/operations/style/upsertGlobalStyle.ts
6
+ //#region src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.ts
6
7
  var upsertGlobalStyleOp = z.object({
7
8
  type: z.literal("upsertGlobalStyle"),
8
9
  componentType: z.string().describe("Element type to style site-wide (e.g. \"button\"); affects ALL of that type"),
@@ -0,0 +1,21 @@
1
+ import { idUri, idsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { MODES, guardKind } from "../write.js";
4
+ import { z } from "zod";
5
+ //#region src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.ts
6
+ var deleteIdStyleOp = z.object({
7
+ type: z.literal("deleteIdStyle"),
8
+ targetId: z.string().describe("DOM id whose id rule to remove (without the # prefix)")
9
+ }).describe("Remove the id rule (`#id`) for a single element (the element keeps its own classes).");
10
+ var deleteIdStyle = (space, env, op) => {
11
+ const guard = guardKind(space.style, op.targetId, "id");
12
+ if (guard) return guard;
13
+ for (const mode of MODES) Reflect.deleteProperty(space.style.platform[mode], op.targetId);
14
+ return {
15
+ ...empty(),
16
+ deleted: 1,
17
+ staleResources: [idUri(env, op.targetId), idsUri(env)]
18
+ };
19
+ };
20
+ //#endregion
21
+ export { deleteIdStyle, deleteIdStyleOp };
@@ -0,0 +1,28 @@
1
+ import { idUri, idsUri } from "../../../../helpers/uris.js";
2
+ import { empty, fail } from "../../../../helpers/opResult.js";
3
+ import { idStyleToAI } from "../translator.js";
4
+ import { guardKind, mergePatch, writeStyleItem } from "../write.js";
5
+ import { patchCssShape } from "../shared.js";
6
+ import { z } from "zod";
7
+ //#region src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.ts
8
+ var patchIdStyleOp = z.object({
9
+ type: z.literal("patchIdStyle"),
10
+ targetId: z.string().describe("DOM id whose id rule to merge into (without the # prefix)"),
11
+ ...patchCssShape
12
+ }).describe("Partially update the CSS of an id rule (`#id`): CSS is merged (a null value removes a property). Never creates — use upsertIdStyle for that.");
13
+ var patchIdStyle = (space, env, op) => {
14
+ const guard = guardKind(space.style, op.targetId, "id");
15
+ if (guard) return guard;
16
+ const existing = idStyleToAI(space.style, op.targetId);
17
+ if (!existing) return fail("targetId", `No id rule for "${op.targetId}"`, "patchIdStyle only updates an existing id rule; use upsertIdStyle to create one");
18
+ const { type, targetId, slots: slotsPatch, ...basePatch } = op;
19
+ const { base, slots } = mergePatch(existing, basePatch, slotsPatch);
20
+ writeStyleItem(space.style, targetId, base, slots, "id", void 0);
21
+ return {
22
+ ...empty(),
23
+ updated: 1,
24
+ staleResources: [idUri(env, targetId), idsUri(env)]
25
+ };
26
+ };
27
+ //#endregion
28
+ export { patchIdStyle, patchIdStyleOp };
@@ -0,0 +1,24 @@
1
+ import { idUri, idsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { guardKind, writeStyleItem } from "../write.js";
4
+ import { upsertCssShape } from "../shared.js";
5
+ import { z } from "zod";
6
+ //#region src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.ts
7
+ var upsertIdStyleOp = z.object({
8
+ type: z.literal("upsertIdStyle"),
9
+ targetId: z.string().describe("DOM id of the element to style (without the # prefix); matches its `id` attribute"),
10
+ ...upsertCssShape
11
+ }).describe("Create or fully replace the CSS for a single element addressed by its DOM id (`#id`). The element must carry that `id` attribute. To style by reusable class instead, use upsertDefinition. Use patchIdStyle for a partial change.");
12
+ var upsertIdStyle = (space, env, op) => {
13
+ const { type, targetId, slots, ...base } = op;
14
+ const guard = guardKind(space.style, targetId, "id");
15
+ if (guard) return guard;
16
+ writeStyleItem(space.style, targetId, base, slots, "id", void 0);
17
+ return {
18
+ ...empty(),
19
+ updated: 1,
20
+ staleResources: [idUri(env, targetId), idsUri(env)]
21
+ };
22
+ };
23
+ //#endregion
24
+ export { upsertIdStyle, upsertIdStyleOp };
@@ -1,11 +1,14 @@
1
- import { deleteDefinitionOp } from "./deleteDefinition.js";
2
- import { deleteGlobalStyleOp } from "./deleteGlobalStyle.js";
3
- import { deleteStyleVariableOp } from "./deleteStyleVariable.js";
4
- import { patchDefinitionOp } from "./patchDefinition.js";
5
- import { patchGlobalStyleOp } from "./patchGlobalStyle.js";
6
- import { upsertDefinitionOp } from "./upsertDefinition.js";
7
- import { upsertGlobalStyleOp } from "./upsertGlobalStyle.js";
8
- import { upsertStyleVariableOp } from "./upsertStyleVariable.js";
1
+ import { deleteDefinitionOp } from "./definitions/deleteDefinition.js";
2
+ import { patchDefinitionOp } from "./definitions/patchDefinition.js";
3
+ import { upsertDefinitionOp } from "./definitions/upsertDefinition.js";
4
+ import { deleteGlobalStyleOp } from "./globalStyles/deleteGlobalStyle.js";
5
+ import { patchGlobalStyleOp } from "./globalStyles/patchGlobalStyle.js";
6
+ import { upsertGlobalStyleOp } from "./globalStyles/upsertGlobalStyle.js";
7
+ import { deleteIdStyleOp } from "./idStyles/deleteIdStyle.js";
8
+ import { patchIdStyleOp } from "./idStyles/patchIdStyle.js";
9
+ import { upsertIdStyleOp } from "./idStyles/upsertIdStyle.js";
10
+ import { deleteStyleVariableOp } from "./variables/deleteStyleVariable.js";
11
+ import { upsertStyleVariableOp } from "./variables/upsertStyleVariable.js";
9
12
  //#region src/modules/mcp/tools/operations/style/operations.ts
10
13
  var styleOps = {
11
14
  upsertDefinition: upsertDefinitionOp,
@@ -14,6 +17,9 @@ var styleOps = {
14
17
  upsertGlobalStyle: upsertGlobalStyleOp,
15
18
  patchGlobalStyle: patchGlobalStyleOp,
16
19
  deleteGlobalStyle: deleteGlobalStyleOp,
20
+ upsertIdStyle: upsertIdStyleOp,
21
+ patchIdStyle: patchIdStyleOp,
22
+ deleteIdStyle: deleteIdStyleOp,
17
23
  upsertStyleVariable: upsertStyleVariableOp,
18
24
  deleteStyleVariable: deleteStyleVariableOp
19
25
  };
@@ -38,6 +38,18 @@ var projectItem = (style, ref, accept) => {
38
38
  return found ? def : void 0;
39
39
  };
40
40
  var definitionToAI = (style, ref) => projectItem(style, ref, isClassDefinition);
41
+ var definitionVariantNames = (style, ref) => {
42
+ const def = definitionToAI(style, ref);
43
+ if (!def) return;
44
+ const result = {};
45
+ const baseVariants = Object.keys(def.variants ?? {});
46
+ if (baseVariants.length > 0) result.base = baseVariants.sort();
47
+ for (const [slot, slotDef] of Object.entries(def.slots ?? {})) {
48
+ const variants = Object.keys(slotDef.variants ?? {});
49
+ if (variants.length > 0) result[slot] = variants.sort();
50
+ }
51
+ return Object.keys(result).length > 0 ? result : void 0;
52
+ };
41
53
  var globalStylesForType = (style, componentType) => {
42
54
  const isGlobal = (item) => item.type === "element" && item.componentType === componentType;
43
55
  const refs = /* @__PURE__ */ new Set();
@@ -64,6 +76,18 @@ var globalStyleTypes = (style) => {
64
76
  for (const mode of DISPLAY_MODES) for (const item of Object.values(style.platform[mode])) if (item.type === "element" && item.componentType) types.add(item.componentType);
65
77
  return Array.from(types).sort();
66
78
  };
79
+ var idStyleIds = (style) => {
80
+ const ids = /* @__PURE__ */ new Set();
81
+ for (const mode of DISPLAY_MODES) for (const [name, item] of Object.entries(style.platform[mode])) if (item.type === "id") ids.add(name);
82
+ return Array.from(ids).sort();
83
+ };
84
+ var idStyleToAI = (style, targetId) => {
85
+ const def = projectItem(style, targetId, (item) => item.type === "id");
86
+ return def ? {
87
+ ...def,
88
+ targetId
89
+ } : void 0;
90
+ };
67
91
  var styleVariablesToAI = (style) => {
68
92
  const data = {};
69
93
  for (const [category, group] of Object.entries(style.variables)) data[category] = Object.entries(group).map(([name, value]) => ({
@@ -74,4 +98,4 @@ var styleVariablesToAI = (style) => {
74
98
  return data;
75
99
  };
76
100
  //#endregion
77
- export { definitionRefs, definitionToAI, globalStyleToAI, globalStyleTypes, globalStylesForType, isClassDefinition, styleVariablesToAI };
101
+ export { definitionRefs, definitionToAI, definitionVariantNames, globalStyleToAI, globalStyleTypes, globalStylesForType, idStyleIds, idStyleToAI, isClassDefinition, styleVariablesToAI };
@@ -1,8 +1,8 @@
1
- import { empty } from "../../../helpers/opResult.js";
2
- import { styleVarUri, styleVarsUri } from "./write.js";
3
- import { styleCategory } from "./shared.js";
1
+ import { styleVarUri, styleVarsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { styleCategory } from "../shared.js";
4
4
  import { z } from "zod";
5
- //#region src/modules/mcp/tools/operations/style/deleteStyleVariable.ts
5
+ //#region src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.ts
6
6
  var deleteStyleVariableOp = z.object({
7
7
  type: z.literal("deleteStyleVariable"),
8
8
  category: styleCategory,
@@ -1,8 +1,8 @@
1
- import { empty } from "../../../helpers/opResult.js";
2
- import { styleVarUri, styleVarsUri } from "./write.js";
3
- import { styleCategory, themeValue } from "./shared.js";
1
+ import { styleVarUri, styleVarsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { styleCategory, themeValue } from "../shared.js";
4
4
  import { z } from "zod";
5
- //#region src/modules/mcp/tools/operations/style/upsertStyleVariable.ts
5
+ //#region src/modules/mcp/tools/operations/style/variables/upsertStyleVariable.ts
6
6
  var upsertStyleVariableOp = z.object({
7
7
  type: z.literal("upsertStyleVariable"),
8
8
  category: styleCategory,
@@ -1,5 +1,6 @@
1
+ import { expandShorthand } from "../../../catalogs/cssCatalog.js";
2
+ import { defUri, defsUri, globalUri, globalsUri, idUri, idsUri, styleVarUri, styleVarsUri } from "../../../helpers/uris.js";
1
3
  import { fail } from "../../../helpers/opResult.js";
2
- import { expandShorthand } from "./cssCatalog.js";
3
4
  import processSelector from "@plitzi/sdk-style/helpers/processSelector";
4
5
  //#region src/modules/mcp/tools/operations/style/write.ts
5
6
  var MODES = [
@@ -7,18 +8,25 @@ var MODES = [
7
8
  "tablet",
8
9
  "mobile"
9
10
  ];
10
- var defUri = (env, ref) => `plitzi://definitions/${env}/${ref}`;
11
- var defsUri = (env) => `plitzi://definitions/${env}`;
12
- var globalUri = (env, componentType) => `plitzi://global-styles/${env}/${componentType}`;
13
- var globalsUri = (env) => `plitzi://global-styles/${env}`;
14
- var styleVarUri = (env, category) => `plitzi://style-variables/${env}/${category}`;
15
- var styleVarsUri = (env) => `plitzi://style-variables/${env}`;
16
- var describeKind = (item) => item.type === "element" ? `a global style for every "${item.componentType}" element` : item.type === "class" ? "a reusable class definition" : "an id rule";
11
+ var KIND_LABEL = {
12
+ class: "a reusable class definition",
13
+ element: "a global style for an element type",
14
+ id: "an id rule targeting a single element"
15
+ };
16
+ var KIND_TOOL = {
17
+ class: "upsertDefinition/patchDefinition",
18
+ element: "upsertGlobalStyle/patchGlobalStyle",
19
+ id: "upsertIdStyle/patchIdStyle"
20
+ };
21
+ var KIND_FIELD = {
22
+ class: "ref",
23
+ element: "componentType",
24
+ id: "targetId"
25
+ };
17
26
  var guardKind = (style, ref, want) => {
18
27
  const clash = MODES.map((mode) => style.platform[mode][ref]).find((item) => item !== void 0 && item.type !== want);
19
28
  if (!clash) return null;
20
- const wantIsClass = want === "class";
21
- return fail(wantIsClass ? "ref" : "componentType", `"${ref}" is already ${describeKind(clash)}; it cannot be edited as ${wantIsClass ? "a class definition" : "a global element style"}`, wantIsClass ? "To restyle every element of a type on purpose, use upsertGlobalStyle/patchGlobalStyle with its componentType. Otherwise pick a different class name." : "That name is a class definition — edit it with upsertDefinition/patchDefinition, or choose a different componentType.");
29
+ return fail(KIND_FIELD[want], `"${ref}" is already ${KIND_LABEL[clash.type]}; it cannot be edited as ${KIND_LABEL[want]}`, `Edit it with ${KIND_TOOL[clash.type]}, or choose a different ${KIND_FIELD[want]}.`);
22
30
  };
23
31
  var slotToBlocks = (slot) => {
24
32
  const perMode = {};
@@ -97,4 +105,4 @@ var mergePatch = (existing, basePatch, slotsPatch) => {
97
105
  };
98
106
  };
99
107
  //#endregion
100
- export { MODES, defUri, defsUri, globalUri, globalsUri, guardKind, mergePatch, styleVarUri, styleVarsUri, writeStyleItem };
108
+ export { MODES, defUri, defsUri, globalUri, globalsUri, guardKind, idUri, idsUri, mergePatch, styleVarUri, styleVarsUri, writeStyleItem };
@@ -24,7 +24,7 @@ var read = (input, space, env) => {
24
24
  var readTool = defineTool({
25
25
  name: "plitzi_read",
26
26
  title: "Batch read",
27
- description: "Read MANY resources at once by URI — the batch alternative to opening resources one by one. Pass an array of URIs (pages, elements, definitions, variables), e.g. the ready-made uris from plitzi_search or a write response, and get them all back in a single call instead of one read per URI. Each result is { uri, stateVersion, data } or a teachable error, so one bad URI never fails the batch.",
27
+ description: "Batch-fetch resource content for URIs you ALREADY HOLD (from plitzi_search or a write response) — the tool form of opening MCP resources, for many at once. Pass an array of URIs (pages, elements, definitions, variables) and get them all in one call. NOT for finding things: to locate an element by label/type use plitzi_search; to browse what exists, list the plitzi:// resources. Each result is { uri, stateVersion, data } or a teachable error, so one bad URI never fails the batch. Never hand-build a URI to guess your way to an element — search for it.",
28
28
  inputShape: readShape,
29
29
  access: "read",
30
30
  run: (input, ctx) => read(input, ctx.space, ctx.env)
@@ -1,7 +1,8 @@
1
1
  import { computeVersion } from "../helpers/computeVersion.js";
2
- import { elementRefOf, getPageElements, isPageElement, pageRefOf, pageRefOfElement } from "../helpers/space.js";
2
+ import { elementRefOf, getPageElements, isPageElement, nameOf, pageRefOf, pageRefOfElement } from "../helpers/space.js";
3
+ import { elementUri, pageUri } from "../helpers/uris.js";
3
4
  import { definitionRefs, definitionToAI } from "./operations/style/translator.js";
4
- import { elementDetailToAI, pageSkeletonToAI } from "./operations/schema/translator.js";
5
+ import { elementView, pageSkeletonToAI } from "./operations/schema/translator.js";
5
6
  import { defineTool } from "./shared/tool.js";
6
7
  import { z } from "zod";
7
8
  //#region src/modules/mcp/tools/search.ts
@@ -15,21 +16,20 @@ var searchShape = {
15
16
  limit: z.number().int().min(1).max(100).optional().describe("Max element hits to return (default 50). Response echoes total and, if more remain, nextOffset."),
16
17
  offset: z.number().int().min(0).optional().describe("Element hits to skip (default 0). Page by re-calling with offset = nextOffset until it is absent.")
17
18
  };
18
- var labelOf = (el) => (typeof el.attributes.name === "string" ? el.attributes.name : void 0) ?? el.definition.label;
19
19
  var breadcrumb = (schema, el) => {
20
20
  const chain = [];
21
21
  let current = el;
22
22
  const guard = /* @__PURE__ */ new Set();
23
23
  while (current && !guard.has(current.id)) {
24
24
  guard.add(current.id);
25
- chain.push(labelOf(current));
25
+ chain.push(nameOf(current));
26
26
  current = current.definition.parentId ? schema.flat[current.definition.parentId] : void 0;
27
27
  }
28
28
  return chain.reverse();
29
29
  };
30
30
  var search = (input, space, env) => {
31
31
  const query = input.query.toLowerCase();
32
- const results = [];
32
+ const matched = [];
33
33
  for (const el of Object.values(space.schema.flat)) {
34
34
  if (isPageElement(space.schema, el)) continue;
35
35
  if (input.filters?.type && el.definition.type !== input.filters.type) continue;
@@ -40,22 +40,33 @@ var search = (input, space, env) => {
40
40
  if (el.definition.type.toLowerCase().includes(query)) matches.push(`type: ${el.definition.type}`);
41
41
  for (const [key, value] of Object.entries(el.attributes)) if (String(value).toLowerCase().includes(query)) matches.push(`${key}: ${String(value).slice(0, 100)}`);
42
42
  if (matches.length === 0) continue;
43
- const ref = elementRefOf(el);
44
- const detail = elementDetailToAI(space.schema, el, space.style);
45
- results.push({
43
+ matched.push({
44
+ el,
46
45
  pageRef,
47
- ref,
48
- uri: `plitzi://schema/${env}/elements/${ref}`,
49
- pageUri: `plitzi://schema/${env}/pages/${pageRef}`,
50
- stateVersion: computeVersion(detail),
51
- parentRef: detail.parentRef,
52
- path: breadcrumb(space.schema, el),
53
- label: el.definition.label,
54
- type: el.definition.type,
55
- matches,
56
- detail: input.include === "detail" ? detail : void 0
46
+ ref: elementRefOf(el),
47
+ matches
57
48
  });
58
49
  }
50
+ const offset = input.offset ?? 0;
51
+ const limit = input.limit ?? 50;
52
+ const total = matched.length;
53
+ const nextOffset = offset + limit < total ? offset + limit : void 0;
54
+ const results = matched.slice(offset, offset + limit).map((hit) => {
55
+ const { detail, version } = elementView(space.schema, hit.el, space.style);
56
+ return {
57
+ pageRef: hit.pageRef,
58
+ ref: hit.ref,
59
+ uri: elementUri(env, hit.ref),
60
+ pageUri: pageUri(env, hit.pageRef),
61
+ stateVersion: version,
62
+ parentRef: detail.parentRef,
63
+ path: breadcrumb(space.schema, hit.el),
64
+ label: hit.el.definition.label,
65
+ type: hit.el.definition.type,
66
+ matches: hit.matches,
67
+ detail: input.include === "detail" ? detail : void 0
68
+ };
69
+ });
59
70
  const definitions = [];
60
71
  for (const ref of definitionRefs(space.style)) {
61
72
  if (ref.toLowerCase().includes(query)) {
@@ -66,7 +77,7 @@ var search = (input, space, env) => {
66
77
  }
67
78
  const pages = [];
68
79
  for (const page of getPageElements(space.schema)) {
69
- const label = labelOf(page);
80
+ const label = nameOf(page);
70
81
  const slug = typeof page.attributes.slug === "string" ? page.attributes.slug : "";
71
82
  const matches = [];
72
83
  if (label.toLowerCase().includes(query)) matches.push(`label: ${label}`);
@@ -75,19 +86,15 @@ var search = (input, space, env) => {
75
86
  const ref = pageRefOf(page);
76
87
  pages.push({
77
88
  ref,
78
- uri: `plitzi://schema/${env}/pages/${ref}`,
79
- stateVersion: computeVersion(pageSkeletonToAI(space.schema, page)),
89
+ uri: pageUri(env, ref),
90
+ stateVersion: computeVersion(pageSkeletonToAI(space.schema, page, space.style)),
80
91
  label,
81
92
  slug,
82
93
  matches
83
94
  });
84
95
  }
85
- const offset = input.offset ?? 0;
86
- const limit = input.limit ?? 50;
87
- const total = results.length;
88
- const nextOffset = offset + limit < total ? offset + limit : void 0;
89
96
  return {
90
- results: results.slice(offset, offset + limit),
97
+ results,
91
98
  total,
92
99
  offset,
93
100
  limit,
@@ -99,7 +106,7 @@ var search = (input, space, env) => {
99
106
  var searchTool = defineTool({
100
107
  name: "plitzi_search",
101
108
  title: "Search",
102
- description: "Find elements by label, type or attribute value across all pages. Each hit returns the element uri, its stateVersion (edit with optimistic concurrency, no read needed) and its tree path. Pass include: \"detail\" to inline the full props/style of each hit plus resolvedStyle (the CSS of its classes). Also returns any style definitions matching the query (with full CSS) under `definitions`, and matching pages under `pages`. Element hits are paginated: it returns at most `limit` (default 50) starting at `offset`, plus `total` and — while more remain — `nextOffset` to fetch the next page.",
109
+ description: "FIND elements when you know what you want but not its ref/uri (e.g. \"the hero button\"). Matches label, type or attribute value across all pages. Each hit returns the element uri, its stateVersion (edit with optimistic concurrency, no read needed) and its tree path. Pass include: \"detail\" to inline the full props/style of each hit plus resolvedStyle (the CSS of its classes). Also returns any style definitions matching the query (with full CSS) under `definitions`, and matching pages under `pages`. Element hits are paginated: it returns at most `limit` (default 50) starting at `offset`, plus `total` and — while more remain — `nextOffset` to fetch the next page.",
103
110
  inputShape: searchShape,
104
111
  access: "read",
105
112
  run: (input, ctx) => search(input, ctx.space, ctx.env)
@@ -0,0 +1,124 @@
1
+ import { elementRefOf, findElementByRef } from "../../../helpers/space.js";
2
+ import { definitionToAI, globalStyleToAI, idStyleToAI } from "../../operations/style/translator.js";
3
+ import { checkBindingSourceScope, checkBindingTarget, checkBindingTransformers } from "./bindings.js";
4
+ import { checkSlotCss } from "./css.js";
5
+ import { checkVariantApplication } from "./elements.js";
6
+ import { checkInteractionNode } from "./interactions.js";
7
+ import { buildValidationCtx } from "./index.js";
8
+ //#region src/modules/mcp/tools/shared/validator/audit.ts
9
+ var harvest = (ctx, into, label, run) => {
10
+ const sub = {
11
+ ...ctx,
12
+ errors: [],
13
+ warnings: [],
14
+ warned: /* @__PURE__ */ new Set()
15
+ };
16
+ run(sub);
17
+ for (const e of sub.errors) into.errors.push({
18
+ path: e.path,
19
+ message: `Pre-existing malformation in ${label}: ${e.message}`,
20
+ hint: `${e.hint ? `${e.hint} ` : ""}This issue already exists in the space (NOT caused by your change), but the save is blocked until you fix it too, in this same batch.`,
21
+ ...e.validValues ? { validValues: e.validValues } : {}
22
+ });
23
+ for (const w of sub.warnings) {
24
+ const message = `Pre-existing issue in ${label} (not caused by your change, but worth fixing too): ${w}`;
25
+ if (!into.warnings.includes(message)) into.warnings.push(message);
26
+ }
27
+ };
28
+ var toNode = (id, node) => ({
29
+ id,
30
+ title: node.title,
31
+ nodeType: node.type,
32
+ action: node.action,
33
+ params: node.params,
34
+ enabled: node.enabled,
35
+ when: node.when,
36
+ elementId: node.elementId ?? void 0,
37
+ preview: node.preview
38
+ });
39
+ var auditElement = (space, sub, el) => {
40
+ const hostRef = elementRefOf(el);
41
+ const base = `element "${hostRef}"`;
42
+ for (const [category, list] of Object.entries(el.definition.bindings ?? {})) for (const binding of list) {
43
+ const path = `${base}.bindings.${category}[to=${binding.to}]`;
44
+ checkBindingTransformers(binding.transformers, `${path}.transformers`, sub);
45
+ checkBindingSourceScope(space, sub, hostRef, binding.source, `${path}.source`);
46
+ checkBindingTarget(hostRef, category, binding.to, path, sub);
47
+ }
48
+ for (const [id, node] of Object.entries(el.definition.interactions ?? {})) checkInteractionNode(toNode(id, node), `${base}.interactions.${id}`, sub, hostRef);
49
+ checkVariantApplication(el.definition.initialState, `${base}.initialState`, sub);
50
+ };
51
+ var auditDefinitionCss = (sub, label, def) => {
52
+ const { ref: _ref, slots, ...slot } = def;
53
+ checkSlotCss(slot, label, sub);
54
+ for (const [name, slotDef] of Object.entries(slots ?? {})) checkSlotCss(slotDef, `${label}.slots.${name}`, sub);
55
+ };
56
+ var collectTouched = (ops) => {
57
+ const touched = {
58
+ elementRefs: /* @__PURE__ */ new Set(),
59
+ definitions: /* @__PURE__ */ new Set(),
60
+ globalStyles: /* @__PURE__ */ new Set(),
61
+ idStyles: /* @__PURE__ */ new Set()
62
+ };
63
+ for (const op of ops) switch (op.type) {
64
+ case "upsertElement":
65
+ touched.elementRefs.add(op.element.ref);
66
+ break;
67
+ case "patchElement":
68
+ case "moveElement":
69
+ case "upsertBinding":
70
+ case "patchBinding":
71
+ case "deleteBinding":
72
+ case "upsertInteractionFlow":
73
+ case "patchInteractionNode":
74
+ case "deleteInteraction":
75
+ touched.elementRefs.add(op.ref);
76
+ break;
77
+ case "upsertDefinition":
78
+ case "patchDefinition":
79
+ touched.definitions.add(op.ref);
80
+ break;
81
+ case "upsertGlobalStyle":
82
+ case "patchGlobalStyle":
83
+ touched.globalStyles.add(op.componentType);
84
+ break;
85
+ case "upsertIdStyle":
86
+ case "patchIdStyle":
87
+ touched.idStyles.add(op.targetId);
88
+ break;
89
+ default: break;
90
+ }
91
+ return touched;
92
+ };
93
+ var auditResources = (space, ops) => {
94
+ const ctx = buildValidationCtx(space, ops);
95
+ const result = {
96
+ valid: true,
97
+ errors: [],
98
+ warnings: []
99
+ };
100
+ const touched = collectTouched(ops);
101
+ const seenElements = /* @__PURE__ */ new Set();
102
+ for (const ref of touched.elementRefs) {
103
+ const el = findElementByRef(space.schema, ref);
104
+ if (!el || seenElements.has(el.id)) continue;
105
+ seenElements.add(el.id);
106
+ harvest(ctx, result, `element "${elementRefOf(el)}"`, (sub) => auditElement(space, sub, el));
107
+ }
108
+ for (const ref of touched.definitions) {
109
+ const def = definitionToAI(space.style, ref);
110
+ if (def) harvest(ctx, result, `definition "${ref}"`, (sub) => auditDefinitionCss(sub, `definition "${ref}"`, def));
111
+ }
112
+ for (const componentType of touched.globalStyles) {
113
+ const def = globalStyleToAI(space.style, componentType);
114
+ if (def) harvest(ctx, result, `global style "${componentType}"`, (sub) => auditDefinitionCss(sub, `global style "${componentType}"`, def));
115
+ }
116
+ for (const targetId of touched.idStyles) {
117
+ const def = idStyleToAI(space.style, targetId);
118
+ if (def) harvest(ctx, result, `id style "#${targetId}"`, (sub) => auditDefinitionCss(sub, `id style "#${targetId}"`, def));
119
+ }
120
+ result.valid = result.errors.length === 0;
121
+ return result;
122
+ };
123
+ //#endregion
124
+ export { auditResources };
@@ -0,0 +1,30 @@
1
+ import { slugRouteParams } from "../../../helpers/space.js";
2
+ //#region src/modules/mcp/tools/shared/validator/batch.ts
3
+ var batchDeclaredVars = (ops) => {
4
+ const names = [];
5
+ for (const op of ops) if (op.type === "upsertVariable") names.push(op.name);
6
+ else if (op.type === "upsertPage" && typeof op.slug === "string") names.push(...slugRouteParams(op.slug));
7
+ return names;
8
+ };
9
+ var batchDeclaredPages = (ops) => {
10
+ const refs = /* @__PURE__ */ new Set();
11
+ for (const op of ops) if (op.type === "upsertPage") refs.add(op.ref);
12
+ return refs;
13
+ };
14
+ var batchDeclaredFolders = (ops) => {
15
+ const refs = /* @__PURE__ */ new Set();
16
+ for (const op of ops) if (op.type === "upsertFolder") refs.add(op.ref);
17
+ return refs;
18
+ };
19
+ var batchDeclaredVariants = (ops) => {
20
+ const map = /* @__PURE__ */ new Map();
21
+ for (const op of ops) {
22
+ if (op.type !== "upsertDefinition" && op.type !== "patchDefinition") continue;
23
+ const names = new Set(Object.keys(op.variants ?? {}));
24
+ for (const slot of Object.values(op.slots ?? {})) for (const name of Object.keys(slot.variants ?? {})) names.add(name);
25
+ if (names.size > 0) map.set(op.ref, /* @__PURE__ */ new Set([...map.get(op.ref) ?? [], ...names]));
26
+ }
27
+ return map;
28
+ };
29
+ //#endregion
30
+ export { batchDeclaredFolders, batchDeclaredPages, batchDeclaredVariants, batchDeclaredVars };