@cplace/test-mcp-server 1.1.6 → 1.2.1

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 (66) hide show
  1. package/README.md +4 -18
  2. package/dist/api.d.ts +1 -0
  3. package/dist/api.d.ts.map +1 -1
  4. package/dist/api.js +50 -0
  5. package/dist/api.js.map +1 -1
  6. package/dist/conditional-registration.d.ts.map +1 -1
  7. package/dist/conditional-registration.js +5 -3
  8. package/dist/conditional-registration.js.map +1 -1
  9. package/dist/index.js +7 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/profiles.js +3 -3
  12. package/dist/profiles.js.map +1 -1
  13. package/dist/searchConversion.d.ts.map +1 -1
  14. package/dist/searchConversion.js +98 -0
  15. package/dist/searchConversion.js.map +1 -1
  16. package/dist/searchSchema.d.ts +1320 -0
  17. package/dist/searchSchema.d.ts.map +1 -1
  18. package/dist/searchSchema.js +86 -0
  19. package/dist/searchSchema.js.map +1 -1
  20. package/dist/tool-metadata.js +3 -3
  21. package/dist/tool-metadata.js.map +1 -1
  22. package/dist/tools/board-widget.js +1 -1
  23. package/dist/tools/board-widget.js.map +1 -1
  24. package/dist/tools/common-schemas.d.ts +0 -227
  25. package/dist/tools/common-schemas.d.ts.map +1 -1
  26. package/dist/tools/common-schemas.js +0 -67
  27. package/dist/tools/common-schemas.js.map +1 -1
  28. package/dist/tools/csv-export.d.ts +1320 -0
  29. package/dist/tools/csv-export.d.ts.map +1 -1
  30. package/dist/tools/layout-script.d.ts +166 -0
  31. package/dist/tools/layout-script.d.ts.map +1 -0
  32. package/dist/tools/layout-script.js +474 -0
  33. package/dist/tools/layout-script.js.map +1 -0
  34. package/dist/tools/search.d.ts +1322 -0
  35. package/dist/tools/search.d.ts.map +1 -1
  36. package/dist/tools/search.js +48 -2
  37. package/dist/tools/search.js.map +1 -1
  38. package/dist/tools/type-layouts.d.ts +0 -11
  39. package/dist/tools/type-layouts.d.ts.map +1 -1
  40. package/dist/tools/type-layouts.js +0 -31
  41. package/dist/tools/type-layouts.js.map +1 -1
  42. package/dist/tools/type-management.d.ts +9 -3
  43. package/dist/tools/type-management.d.ts.map +1 -1
  44. package/dist/tools/type-management.js +12 -8
  45. package/dist/tools/type-management.js.map +1 -1
  46. package/dist/tools/url-resolution.d.ts +16 -0
  47. package/dist/tools/url-resolution.d.ts.map +1 -0
  48. package/dist/tools/url-resolution.js +35 -0
  49. package/dist/tools/url-resolution.js.map +1 -0
  50. package/dist/tools/widgets.d.ts +0 -161
  51. package/dist/tools/widgets.d.ts.map +1 -1
  52. package/dist/tools/widgets.js +0 -275
  53. package/dist/tools/widgets.js.map +1 -1
  54. package/dist/tools/workspace-admin.d.ts.map +1 -1
  55. package/dist/tools/workspace-admin.js +7 -11
  56. package/dist/tools/workspace-admin.js.map +1 -1
  57. package/dist/widget-specifications/cf.cplace.cboard.main.board/_implementation.md +1 -1
  58. package/dist/widget-specifications/cf.cplace.platform.attributesGroup/layout.md +1 -6
  59. package/dist/widget-specifications/cf.cplace.platform.connectedAttributesGroup/cf.cplace.platform.attributesGroup.layout.md +1 -6
  60. package/dist/widget-specifications/cf.cplace.visualizations.scriptingHighcharts/tableWidgetId.md +1 -1
  61. package/dist/widget-specifications/cf.platform.embeddedSearchAsTable/search.md +13 -0
  62. package/package.json +1 -1
  63. package/dist/tools/generic-layouts.d.ts +0 -332
  64. package/dist/tools/generic-layouts.d.ts.map +0 -1
  65. package/dist/tools/generic-layouts.js +0 -512
  66. package/dist/tools/generic-layouts.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"csv-export.d.ts","sourceRoot":"","sources":["../../src/tools/csv-export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAU5C,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAa9B,CAAC;AAEX,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,QAgEhF"}
@@ -0,0 +1,166 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { z } from "zod";
3
+ import { CplaceApiClient } from '../api.js';
4
+ export declare const LayoutContextSchema: z.ZodUnion<[z.ZodObject<{
5
+ type: z.ZodLiteral<"page">;
6
+ pageUID: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ type: "page";
9
+ pageUID: string;
10
+ }, {
11
+ type: "page";
12
+ pageUID: string;
13
+ }>, z.ZodObject<{
14
+ type: z.ZodLiteral<"type">;
15
+ workspaceId: z.ZodString;
16
+ typeInternalName: z.ZodString;
17
+ alternativeLayoutName: z.ZodOptional<z.ZodString>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ type: "type";
20
+ workspaceId: string;
21
+ typeInternalName: string;
22
+ alternativeLayoutName?: string | undefined;
23
+ }, {
24
+ type: "type";
25
+ workspaceId: string;
26
+ typeInternalName: string;
27
+ alternativeLayoutName?: string | undefined;
28
+ }>]>;
29
+ export declare const LAYOUT_SCRIPT_TOOL_DEFINITIONS: {
30
+ readonly cplace_layout_script: {
31
+ readonly description: "Execute a JavaScript layout script to define a complete page or type layout atomically using layout.define().\n\nWHEN TO USE:\n- Use this tool when you know the full layout structure upfront\n- Replaces the entire layout in a single atomic operation (no partial updates)\n- More efficient than sequential add-row/add-widget calls for complete layouts\n\nKEY BEHAVIORS:\n- The script must call layout.define() exactly once\n- The entire layout is atomically replaced — previous layout is fully overwritten\n- Script timeout: 30 seconds\n- Widget IDs: auto-generated if omitted; if provided without '_' prefix, '_' is prepended automatically\n\nRESPONSE OUTCOMES:\n- VALID_COMPLETE: Layout saved, all widgets fully configured\n- VALID_INCOMPLETE: Layout saved, but some widgets have missing optional configuration (warnings returned)\n- Validation errors: Layout NOT saved — structural or widget errors returned with details\n- Generic errors: Entity not found, permission denied, script errors\n\nVALIDATION FEEDBACK:\n- Structural errors: invalid column proportions (must be 3-12 each, sum to 12 per row)\n- Widget errors: unknown widget types, invalid configurations\n- Warnings: widgets saved but missing optional configuration (e.g., search filter not set)\n\nTIP: After a VALID_INCOMPLETE response, re-run layout.define() with corrected widget configuration to resolve warnings.";
32
+ readonly inputSchema: {
33
+ readonly context: z.ZodUnion<[z.ZodObject<{
34
+ type: z.ZodLiteral<"page">;
35
+ pageUID: z.ZodString;
36
+ }, "strip", z.ZodTypeAny, {
37
+ type: "page";
38
+ pageUID: string;
39
+ }, {
40
+ type: "page";
41
+ pageUID: string;
42
+ }>, z.ZodObject<{
43
+ type: z.ZodLiteral<"type">;
44
+ workspaceId: z.ZodString;
45
+ typeInternalName: z.ZodString;
46
+ alternativeLayoutName: z.ZodOptional<z.ZodString>;
47
+ }, "strip", z.ZodTypeAny, {
48
+ type: "type";
49
+ workspaceId: string;
50
+ typeInternalName: string;
51
+ alternativeLayoutName?: string | undefined;
52
+ }, {
53
+ type: "type";
54
+ workspaceId: string;
55
+ typeInternalName: string;
56
+ alternativeLayoutName?: string | undefined;
57
+ }>]>;
58
+ readonly script: z.ZodString;
59
+ };
60
+ readonly annotations: {
61
+ readonly title: "Execute Layout Script";
62
+ };
63
+ };
64
+ readonly cplace_layout_get_overview: {
65
+ readonly description: "Get layout structure for page or type. Provides an overview of the layout grid including rows, columns, and widget summaries for both page and type layouts.";
66
+ readonly inputSchema: {
67
+ readonly context: z.ZodUnion<[z.ZodObject<{
68
+ type: z.ZodLiteral<"page">;
69
+ pageUID: z.ZodString;
70
+ }, "strip", z.ZodTypeAny, {
71
+ type: "page";
72
+ pageUID: string;
73
+ }, {
74
+ type: "page";
75
+ pageUID: string;
76
+ }>, z.ZodObject<{
77
+ type: z.ZodLiteral<"type">;
78
+ workspaceId: z.ZodString;
79
+ typeInternalName: z.ZodString;
80
+ alternativeLayoutName: z.ZodOptional<z.ZodString>;
81
+ }, "strip", z.ZodTypeAny, {
82
+ type: "type";
83
+ workspaceId: string;
84
+ typeInternalName: string;
85
+ alternativeLayoutName?: string | undefined;
86
+ }, {
87
+ type: "type";
88
+ workspaceId: string;
89
+ typeInternalName: string;
90
+ alternativeLayoutName?: string | undefined;
91
+ }>]>;
92
+ };
93
+ readonly annotations: {
94
+ readonly title: "Get Layout Overview";
95
+ };
96
+ };
97
+ readonly cplace_layout_get_widget_details: {
98
+ readonly description: "Get detailed widget configuration from page or type layout. Extracts specific widget information from the layout structure.";
99
+ readonly inputSchema: {
100
+ readonly context: z.ZodUnion<[z.ZodObject<{
101
+ type: z.ZodLiteral<"page">;
102
+ pageUID: z.ZodString;
103
+ }, "strip", z.ZodTypeAny, {
104
+ type: "page";
105
+ pageUID: string;
106
+ }, {
107
+ type: "page";
108
+ pageUID: string;
109
+ }>, z.ZodObject<{
110
+ type: z.ZodLiteral<"type">;
111
+ workspaceId: z.ZodString;
112
+ typeInternalName: z.ZodString;
113
+ alternativeLayoutName: z.ZodOptional<z.ZodString>;
114
+ }, "strip", z.ZodTypeAny, {
115
+ type: "type";
116
+ workspaceId: string;
117
+ typeInternalName: string;
118
+ alternativeLayoutName?: string | undefined;
119
+ }, {
120
+ type: "type";
121
+ workspaceId: string;
122
+ typeInternalName: string;
123
+ alternativeLayoutName?: string | undefined;
124
+ }>]>;
125
+ readonly widgetId: z.ZodString;
126
+ };
127
+ readonly annotations: {
128
+ readonly title: "Get Widget Details from Layout";
129
+ };
130
+ };
131
+ readonly cplace_layout_get_script: {
132
+ readonly description: "Get the current layout as a layout.define() JavaScript script for a page or type layout.\n\nWHEN TO USE:\n- To read the current layout before modifying it (read-edit-write workflow)\n- To inspect the full layout definition including widget configurations and embedded layouts\n- To copy a layout from one page/type to another\n\nRETURNS:\n- The layout as a layout.define({...}) script string, ready to be modified and posted back via cplace_layout_script\n- Widget config values are in the INPUT format accepted by cplace_layout_script (references as UID strings, rich strings as markup strings, localized strings as {locale: value} maps)\n\nROUND-TRIP WORKFLOW:\n1. GET: Use this tool to retrieve the current layout script\n2. EDIT: Modify the script as needed\n3. POST: Use cplace_layout_script to apply the modified script";
133
+ readonly inputSchema: {
134
+ readonly context: z.ZodUnion<[z.ZodObject<{
135
+ type: z.ZodLiteral<"page">;
136
+ pageUID: z.ZodString;
137
+ }, "strip", z.ZodTypeAny, {
138
+ type: "page";
139
+ pageUID: string;
140
+ }, {
141
+ type: "page";
142
+ pageUID: string;
143
+ }>, z.ZodObject<{
144
+ type: z.ZodLiteral<"type">;
145
+ workspaceId: z.ZodString;
146
+ typeInternalName: z.ZodString;
147
+ alternativeLayoutName: z.ZodOptional<z.ZodString>;
148
+ }, "strip", z.ZodTypeAny, {
149
+ type: "type";
150
+ workspaceId: string;
151
+ typeInternalName: string;
152
+ alternativeLayoutName?: string | undefined;
153
+ }, {
154
+ type: "type";
155
+ workspaceId: string;
156
+ typeInternalName: string;
157
+ alternativeLayoutName?: string | undefined;
158
+ }>]>;
159
+ };
160
+ readonly annotations: {
161
+ readonly title: "Get Layout Script";
162
+ };
163
+ };
164
+ };
165
+ export declare function registerLayoutScriptTools(server: McpServer, client: CplaceApiClient): void;
166
+ //# sourceMappingURL=layout-script.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-script.d.ts","sourceRoot":"","sources":["../../src/tools/layout-script.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAK5C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;IAW+C,CAAC;AAYhF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyMjC,CAAC;AAkCX,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,QA2RnF"}
@@ -0,0 +1,474 @@
1
+ import { z } from "zod";
2
+ import { debugLogWithTag } from "../logger.js";
3
+ import { checkResponseSize } from "../utils.js";
4
+ export const LayoutContextSchema = z.union([
5
+ z.object({
6
+ type: z.literal("page"),
7
+ pageUID: z.string().describe("Page UID (e.g., 'page/abc123')")
8
+ }),
9
+ z.object({
10
+ type: z.literal("type"),
11
+ workspaceId: z.string().describe("Workspace ID (e.g., 'workspace123')"),
12
+ typeInternalName: z.string().describe("Type internal name (e.g., 'cf.example.myType')"),
13
+ alternativeLayoutName: z.string().optional().describe("Alternative layout name (optional)")
14
+ })
15
+ ]).describe("Layout target - specify whether operating on page or type layout");
16
+ const TOOL_LAYOUT_SCRIPT = 'cplace_layout_script';
17
+ const TOOL_LAYOUT_GET_OVERVIEW = 'cplace_layout_get_overview';
18
+ const TOOL_LAYOUT_GET_WIDGET_DETAILS = 'cplace_layout_get_widget_details';
19
+ const TOOL_LAYOUT_GET_SCRIPT = 'cplace_layout_get_script';
20
+ export const LAYOUT_SCRIPT_TOOL_DEFINITIONS = {
21
+ [TOOL_LAYOUT_SCRIPT]: {
22
+ description: `Execute a JavaScript layout script to define a complete page or type layout atomically using layout.define().
23
+
24
+ WHEN TO USE:
25
+ - Use this tool when you know the full layout structure upfront
26
+ - Replaces the entire layout in a single atomic operation (no partial updates)
27
+ - More efficient than sequential add-row/add-widget calls for complete layouts
28
+
29
+ KEY BEHAVIORS:
30
+ - The script must call layout.define() exactly once
31
+ - The entire layout is atomically replaced — previous layout is fully overwritten
32
+ - Script timeout: 30 seconds
33
+ - Widget IDs: auto-generated if omitted; if provided without '_' prefix, '_' is prepended automatically
34
+
35
+ RESPONSE OUTCOMES:
36
+ - VALID_COMPLETE: Layout saved, all widgets fully configured
37
+ - VALID_INCOMPLETE: Layout saved, but some widgets have missing optional configuration (warnings returned)
38
+ - Validation errors: Layout NOT saved — structural or widget errors returned with details
39
+ - Generic errors: Entity not found, permission denied, script errors
40
+
41
+ VALIDATION FEEDBACK:
42
+ - Structural errors: invalid column proportions (must be 3-12 each, sum to 12 per row)
43
+ - Widget errors: unknown widget types, invalid configurations
44
+ - Warnings: widgets saved but missing optional configuration (e.g., search filter not set)
45
+
46
+ TIP: After a VALID_INCOMPLETE response, re-run layout.define() with corrected widget configuration to resolve warnings.`,
47
+ inputSchema: {
48
+ context: LayoutContextSchema,
49
+ script: z.string().describe(`JavaScript code that calls layout.define() exactly once to declare the complete layout structure.
50
+
51
+ LAYOUT SPECIFICATION FORMAT:
52
+ layout.define({
53
+ rows: [
54
+ {
55
+ columns: [
56
+ {
57
+ proportion: 6, // Column width: integer 3-12, all columns in a row must sum to 12
58
+ widgets: [
59
+ {
60
+ id: "myWidget", // Optional: explicit widget ID (auto-prefixed with '_' if missing prefix)
61
+ type: "cf.platform.wiki", // Required: widget type identifier
62
+ config: { // Optional: widget configuration key-value pairs
63
+ title: "My Wiki"
64
+ },
65
+ embeddedLayouts: { // Optional: nested layouts for container widgets
66
+ "widgetsLayout": { // key is the name of the layout attribute
67
+ rows: [ /* same recursive structure */ ]
68
+ }
69
+ }
70
+ }
71
+ ]
72
+ }
73
+ ]
74
+ }
75
+ ]
76
+ });
77
+
78
+ COLUMN PROPORTION RULES:
79
+ - Each column proportion must be between 3 and 12
80
+ - All column proportions in a row must sum to exactly 12
81
+ - Common patterns: [12] (full width), [6,6] (two equal), [4,4,4] (three equal), [8,4] (main + sidebar), [3,9] (sidebar + main)
82
+
83
+ WIDGET FIELDS:
84
+ - id (optional): Explicit widget ID. Auto-prefixed with '_' if it doesn't start with '_'. Auto-generated if omitted.
85
+ - type (required): Widget type identifier (e.g., 'cf.platform.wiki', 'cf.platform.embeddedSearchAsTable', 'cf.platform.comments', 'cf.platform.files')
86
+ - config (optional): Key-value object of widget configuration. Keys are attribute names, values are strings, numbers, or booleans.
87
+ - embeddedLayouts (optional): Object mapping layout attribute names to nested layout specs. Used for container widgets (tab groups, attributes groups).
88
+
89
+ ADDITIONAL APIS:
90
+ Scripts have access to cplace low-code JavaScript APIs for dynamic layout generation:
91
+ - new Search() / Filters.* — Search for pages to build dynamic layouts
92
+ - cplace.utils() — Platform utilities
93
+ - Standard JavaScript (JSON, Array, etc.)
94
+
95
+ EXAMPLES:
96
+
97
+ Simple single-column layout:
98
+ layout.define({
99
+ rows: [
100
+ { columns: [{ proportion: 12, widgets: [{ type: "cf.platform.wiki" }] }] }
101
+ ]
102
+ });
103
+
104
+ Two-column layout with configured widgets:
105
+ layout.define({
106
+ rows: [
107
+ {
108
+ columns: [
109
+ {
110
+ proportion: 8,
111
+ widgets: [
112
+ { type: "cf.platform.wiki" },
113
+ { type: "cf.platform.embeddedSearchAsTable", config: { height: 600, search: '{"filters":[{"typeNames":["cf.project.Task"]}]}' } }
114
+ ]
115
+ },
116
+ {
117
+ proportion: 4,
118
+ widgets: [
119
+ { type: "cf.platform.comments" },
120
+ { type: "cf.platform.files" }
121
+ ]
122
+ }
123
+ ]
124
+ }
125
+ ]
126
+ });
127
+
128
+ Multi-row layout with explicit widget IDs:
129
+ layout.define({
130
+ rows: [
131
+ { columns: [{ proportion: 12, widgets: [{ id: "header", type: "cf.platform.wiki", config: { title: "Project Overview" } }] }] },
132
+ {
133
+ columns: [
134
+ { proportion: 6, widgets: [{ id: "tasks", type: "cf.platform.embeddedSearchAsTable", config: { height: 400, search: '{"filters":[{"typeNames":["cf.project.Task"]}]}' } }] },
135
+ { proportion: 6, widgets: [{ id: "milestones", type: "cf.platform.embeddedSearchAsTable", config: { height: 400, search: '{"filters":[{"typeNames":["cf.project.Milestone"]}]}' } }] }
136
+ ]
137
+ },
138
+ { columns: [{ proportion: 12, widgets: [{ id: "comments", type: "cf.platform.comments" }] }] }
139
+ ]
140
+ });
141
+
142
+ Widget with embedded layout (container widget):
143
+ layout.define({
144
+ rows: [
145
+ {
146
+ columns: [
147
+ {
148
+ proportion: 12,
149
+ widgets: [
150
+ {
151
+ type: "cf.platform.attributesGroup",
152
+ config: { title: "Details Section" },
153
+ embeddedLayouts: {
154
+ "widgetsLayout": {
155
+ rows: [
156
+ {
157
+ columns: [
158
+ { proportion: 6, widgets: [{ type: "cf.platform.wiki" }] },
159
+ { proportion: 6, widgets: [{ type: "cf.platform.files" }] }
160
+ ]
161
+ }
162
+ ]
163
+ }
164
+ }
165
+ }
166
+ ]
167
+ }
168
+ ]
169
+ }
170
+ ]
171
+ });
172
+
173
+ Dynamic layout using search APIs:
174
+ var search = new Search();
175
+ search.add(Filters.type("cf.project.Dashboard"));
176
+ var count = search.getResultCount();
177
+ var widgets = [{ type: "cf.platform.wiki", config: { title: "Summary (" + count + " dashboards)" } }];
178
+ if (count > 0) {
179
+ widgets.push({ type: "cf.platform.embeddedSearchAsTable", config: { height: 400, search: '{"filters":[{"typeNames":["cf.project.Dashboard"]}]}' } });
180
+ }
181
+ layout.define({ rows: [{ columns: [{ proportion: 12, widgets: widgets }] }] });`)
182
+ },
183
+ annotations: { title: "Execute Layout Script" }
184
+ },
185
+ [TOOL_LAYOUT_GET_OVERVIEW]: {
186
+ description: "Get layout structure for page or type. Provides an overview of the layout grid including rows, columns, and widget summaries for both page and type layouts.",
187
+ inputSchema: {
188
+ context: LayoutContextSchema
189
+ },
190
+ annotations: { title: "Get Layout Overview" }
191
+ },
192
+ [TOOL_LAYOUT_GET_WIDGET_DETAILS]: {
193
+ description: "Get detailed widget configuration from page or type layout. Extracts specific widget information from the layout structure.",
194
+ inputSchema: {
195
+ context: LayoutContextSchema,
196
+ widgetId: z.string().describe("The unique widget identifier to get details for")
197
+ },
198
+ annotations: { title: "Get Widget Details from Layout" }
199
+ },
200
+ [TOOL_LAYOUT_GET_SCRIPT]: {
201
+ description: `Get the current layout as a layout.define() JavaScript script for a page or type layout.
202
+
203
+ WHEN TO USE:
204
+ - To read the current layout before modifying it (read-edit-write workflow)
205
+ - To inspect the full layout definition including widget configurations and embedded layouts
206
+ - To copy a layout from one page/type to another
207
+
208
+ RETURNS:
209
+ - The layout as a layout.define({...}) script string, ready to be modified and posted back via cplace_layout_script
210
+ - Widget config values are in the INPUT format accepted by cplace_layout_script (references as UID strings, rich strings as markup strings, localized strings as {locale: value} maps)
211
+
212
+ ROUND-TRIP WORKFLOW:
213
+ 1. GET: Use this tool to retrieve the current layout script
214
+ 2. EDIT: Modify the script as needed
215
+ 3. POST: Use cplace_layout_script to apply the modified script`,
216
+ inputSchema: {
217
+ context: LayoutContextSchema
218
+ },
219
+ annotations: { title: "Get Layout Script" }
220
+ }
221
+ };
222
+ function determineApiEndpoint(context) {
223
+ return context.type === "page" ? "json/pageLayout" : "json/typeLayout";
224
+ }
225
+ function buildRequestParams(context) {
226
+ if (context.type === "page") {
227
+ return { pageUID: context.pageUID };
228
+ }
229
+ else {
230
+ return {
231
+ workspaceId: context.workspaceId,
232
+ typeInternalName: context.typeInternalName,
233
+ ...(context.alternativeLayoutName && { alternativeLayoutName: context.alternativeLayoutName })
234
+ };
235
+ }
236
+ }
237
+ async function getLayoutOverview(client, context) {
238
+ const endpoint = determineApiEndpoint(context);
239
+ const requestParams = buildRequestParams(context);
240
+ debugLogWithTag('LAYOUT', `getOverview operation on ${context.type} layout via ${endpoint}`);
241
+ return await client.makeApiRequest(endpoint, 'GET', requestParams);
242
+ }
243
+ export function registerLayoutScriptTools(server, client) {
244
+ server.registerTool(TOOL_LAYOUT_SCRIPT, LAYOUT_SCRIPT_TOOL_DEFINITIONS[TOOL_LAYOUT_SCRIPT], async ({ context, script }) => {
245
+ debugLogWithTag('LAYOUT_SCRIPT', `Executing layout script for ${context.type} layout (${script.length} chars)`);
246
+ try {
247
+ const endpoint = context.type === "page"
248
+ ? "json/page/layoutScript"
249
+ : "json/type/layoutScript";
250
+ let requestBody;
251
+ if (context.type === "page") {
252
+ requestBody = {
253
+ pageUID: context.pageUID,
254
+ script
255
+ };
256
+ }
257
+ else {
258
+ requestBody = {
259
+ workspaceId: context.workspaceId,
260
+ typeInternalName: context.typeInternalName,
261
+ ...(context.alternativeLayoutName && { alternativeLayoutName: context.alternativeLayoutName }),
262
+ script
263
+ };
264
+ }
265
+ const rawResponse = await client.makeRawApiRequest(endpoint, 'POST', undefined, requestBody);
266
+ debugLogWithTag('LAYOUT_SCRIPT', `Raw response success: ${rawResponse.success}, status: ${rawResponse.status || 'N/A'}`);
267
+ let response;
268
+ if (rawResponse.success === true) {
269
+ response = {
270
+ operation: "LAYOUT_SCRIPT",
271
+ success: true,
272
+ status: rawResponse.status,
273
+ context,
274
+ result: rawResponse.result,
275
+ ...(rawResponse.validationWarnings && { validationWarnings: rawResponse.validationWarnings })
276
+ };
277
+ }
278
+ else if (rawResponse.errors) {
279
+ response = {
280
+ operation: "LAYOUT_SCRIPT",
281
+ success: false,
282
+ status: "VALIDATION_ERROR",
283
+ context,
284
+ errors: rawResponse.errors
285
+ };
286
+ }
287
+ else {
288
+ response = {
289
+ operation: "LAYOUT_SCRIPT",
290
+ success: false,
291
+ status: "ERROR",
292
+ context,
293
+ errorMessage: rawResponse.errorMessage || "Unknown error"
294
+ };
295
+ }
296
+ const sizeCheck = checkResponseSize(response);
297
+ if (sizeCheck.tooLarge) {
298
+ if (response.result) {
299
+ delete response.result;
300
+ response.resultNote = "Layout was persisted successfully. Result omitted due to size. Use cplace_layout_get_overview to inspect.";
301
+ const sizeCheck2 = checkResponseSize(response);
302
+ if (sizeCheck2.tooLarge) {
303
+ debugLogWithTag('LAYOUT_SCRIPT', `Response still too large after stripping result: ${sizeCheck2.actualSize} chars`);
304
+ return {
305
+ content: [{
306
+ type: "text",
307
+ text: `Layout script response too large (${sizeCheck2.actualSize} characters) even after stripping result. Use cplace_layout_get_overview to inspect the layout.`
308
+ }],
309
+ isError: true
310
+ };
311
+ }
312
+ }
313
+ else {
314
+ debugLogWithTag('LAYOUT_SCRIPT', `Error response too large: ${sizeCheck.actualSize} chars`);
315
+ return {
316
+ content: [{
317
+ type: "text",
318
+ text: `Layout script response too large (${sizeCheck.actualSize} characters). Use cplace_layout_get_overview to inspect the layout.`
319
+ }],
320
+ isError: true
321
+ };
322
+ }
323
+ }
324
+ debugLogWithTag('LAYOUT_SCRIPT', `Returning response with success=${response.success}, status=${response.status}`);
325
+ return {
326
+ content: [{ type: "text", text: JSON.stringify(response, null, 2) }],
327
+ ...(!response.success ? { isError: true } : {})
328
+ };
329
+ }
330
+ catch (error) {
331
+ debugLogWithTag('LAYOUT_SCRIPT', `Error: ${error instanceof Error ? error.message : String(error)}`);
332
+ return {
333
+ content: [{
334
+ type: "text",
335
+ text: `Error executing layout script: ${error instanceof Error ? error.message : String(error)}`
336
+ }],
337
+ isError: true
338
+ };
339
+ }
340
+ });
341
+ server.registerTool(TOOL_LAYOUT_GET_OVERVIEW, LAYOUT_SCRIPT_TOOL_DEFINITIONS[TOOL_LAYOUT_GET_OVERVIEW], async ({ context }) => {
342
+ debugLogWithTag('LAYOUT', `Starting layout overview request for ${context.type} layout`);
343
+ try {
344
+ const result = await getLayoutOverview(client, context);
345
+ const overview = {
346
+ context,
347
+ rows: result.rows?.map((row, rowIndex) => ({
348
+ rowIndex,
349
+ columns: row.columns?.map((column, colIndex) => ({
350
+ columnIndex: colIndex,
351
+ proportion: column.proportion,
352
+ widgets: column.widgets?.map((widget) => ({
353
+ id: widget.id,
354
+ widgetType: widget.widgetType,
355
+ configurationCount: widget.configuration?.length || 0,
356
+ validationStatus: widget.validationStatus || null
357
+ })) || []
358
+ })) || []
359
+ })) || []
360
+ };
361
+ debugLogWithTag('LAYOUT', `Retrieved ${context.type} layout overview successfully`);
362
+ return {
363
+ content: [{ type: "text", text: JSON.stringify(overview, null, 2) }]
364
+ };
365
+ }
366
+ catch (error) {
367
+ debugLogWithTag('LAYOUT', `Error getting layout overview: ${error instanceof Error ? error.message : String(error)}`);
368
+ return {
369
+ content: [{
370
+ type: "text",
371
+ text: `Error getting ${context.type} layout overview: ${error instanceof Error ? error.message : String(error)}`
372
+ }],
373
+ isError: true
374
+ };
375
+ }
376
+ });
377
+ server.registerTool(TOOL_LAYOUT_GET_WIDGET_DETAILS, LAYOUT_SCRIPT_TOOL_DEFINITIONS[TOOL_LAYOUT_GET_WIDGET_DETAILS], async ({ context, widgetId }) => {
378
+ debugLogWithTag('LAYOUT', `Getting widget details for ${widgetId} from ${context.type} layout`);
379
+ try {
380
+ const layoutResult = await getLayoutOverview(client, context);
381
+ let foundWidget = null;
382
+ const findWidget = (rows) => {
383
+ for (const row of rows || []) {
384
+ for (const column of row.columns || []) {
385
+ for (const widget of column.widgets || []) {
386
+ if (widget.id === widgetId) {
387
+ return widget;
388
+ }
389
+ if (widget.widgetsLayout?.rows) {
390
+ const nestedWidget = findWidget(widget.widgetsLayout.rows);
391
+ if (nestedWidget)
392
+ return nestedWidget;
393
+ }
394
+ }
395
+ }
396
+ }
397
+ return null;
398
+ };
399
+ foundWidget = findWidget(layoutResult.rows);
400
+ if (!foundWidget) {
401
+ return {
402
+ content: [{ type: "text", text: `Widget with ID ${widgetId} not found in ${context.type} layout` }]
403
+ };
404
+ }
405
+ debugLogWithTag('LAYOUT', `Retrieved widget details for: ${widgetId} from ${context.type} layout`);
406
+ const response = {
407
+ context,
408
+ widgetId,
409
+ widget: foundWidget,
410
+ validationStatus: foundWidget.validationStatus || null
411
+ };
412
+ return {
413
+ content: [{ type: "text", text: JSON.stringify(response, null, 2) }]
414
+ };
415
+ }
416
+ catch (error) {
417
+ debugLogWithTag('LAYOUT', `Error getting widget details: ${error instanceof Error ? error.message : String(error)}`);
418
+ return {
419
+ content: [{
420
+ type: "text",
421
+ text: `Error getting widget details from ${context.type} layout: ${error instanceof Error ? error.message : String(error)}`
422
+ }],
423
+ isError: true
424
+ };
425
+ }
426
+ });
427
+ server.registerTool(TOOL_LAYOUT_GET_SCRIPT, LAYOUT_SCRIPT_TOOL_DEFINITIONS[TOOL_LAYOUT_GET_SCRIPT], async ({ context }) => {
428
+ debugLogWithTag('LAYOUT', `Getting layout script for ${context.type} layout`);
429
+ try {
430
+ const endpoint = context.type === "page"
431
+ ? "json/page/layoutScript"
432
+ : "json/type/layoutScript";
433
+ const params = buildRequestParams(context);
434
+ const rawResponse = await client.makeRawApiRequest(endpoint, 'GET', params);
435
+ if (rawResponse.success !== true) {
436
+ return {
437
+ content: [{
438
+ type: "text",
439
+ text: `Error getting ${context.type} layout script: ${rawResponse.errorMessage || "Unknown error"}`
440
+ }],
441
+ isError: true
442
+ };
443
+ }
444
+ const response = {
445
+ context,
446
+ script: rawResponse.script
447
+ };
448
+ const sizeCheck = checkResponseSize(response);
449
+ if (sizeCheck.tooLarge) {
450
+ return {
451
+ content: [{
452
+ type: "text",
453
+ text: `Layout script response too large (${sizeCheck.actualSize} characters). Use cplace_layout_get_overview to inspect the layout structure instead.`
454
+ }],
455
+ isError: true
456
+ };
457
+ }
458
+ return {
459
+ content: [{ type: "text", text: JSON.stringify(response, null, 2) }]
460
+ };
461
+ }
462
+ catch (error) {
463
+ debugLogWithTag('LAYOUT', `Error getting layout script: ${error instanceof Error ? error.message : String(error)}`);
464
+ return {
465
+ content: [{
466
+ type: "text",
467
+ text: `Error getting ${context.type} layout script: ${error instanceof Error ? error.message : String(error)}`
468
+ }],
469
+ isError: true
470
+ };
471
+ }
472
+ });
473
+ }
474
+ //# sourceMappingURL=layout-script.js.map