@memberjunction/core-actions 2.107.0 → 2.109.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/custom/ai/find-best-action.action.d.ts +53 -0
- package/dist/custom/ai/find-best-action.action.d.ts.map +1 -0
- package/dist/custom/ai/find-best-action.action.js +211 -0
- package/dist/custom/ai/find-best-action.action.js.map +1 -0
- package/dist/custom/ai/find-best-agent.action.d.ts +53 -0
- package/dist/custom/ai/find-best-agent.action.d.ts.map +1 -0
- package/dist/custom/ai/find-best-agent.action.js +194 -0
- package/dist/custom/ai/find-best-agent.action.js.map +1 -0
- package/dist/custom/ai/summarize-content.action.d.ts +3 -3
- package/dist/custom/ai/summarize-content.action.d.ts.map +1 -1
- package/dist/custom/ai/summarize-content.action.js +51 -143
- package/dist/custom/ai/summarize-content.action.js.map +1 -1
- package/dist/custom/code-execution/execute-code.action.d.ts +61 -0
- package/dist/custom/code-execution/execute-code.action.d.ts.map +1 -0
- package/dist/custom/code-execution/execute-code.action.js +172 -0
- package/dist/custom/code-execution/execute-code.action.js.map +1 -0
- package/dist/custom/data/csv-parser.action.js +1 -1
- package/dist/custom/data/csv-parser.action.js.map +1 -1
- package/dist/custom/data/execute-research-query.action.d.ts +36 -18
- package/dist/custom/data/execute-research-query.action.d.ts.map +1 -1
- package/dist/custom/data/execute-research-query.action.js +221 -114
- package/dist/custom/data/execute-research-query.action.js.map +1 -1
- package/dist/custom/data/explore-database-schema.action.d.ts +4 -0
- package/dist/custom/data/explore-database-schema.action.d.ts.map +1 -1
- package/dist/custom/data/explore-database-schema.action.js +101 -8
- package/dist/custom/data/explore-database-schema.action.js.map +1 -1
- package/dist/custom/data/get-entity-details.action.d.ts +63 -0
- package/dist/custom/data/get-entity-details.action.d.ts.map +1 -0
- package/dist/custom/data/get-entity-details.action.js +284 -0
- package/dist/custom/data/get-entity-details.action.js.map +1 -0
- package/dist/custom/data/get-entity-list.action.d.ts +57 -0
- package/dist/custom/data/get-entity-list.action.d.ts.map +1 -0
- package/dist/custom/data/get-entity-list.action.js +177 -0
- package/dist/custom/data/get-entity-list.action.js.map +1 -0
- package/dist/custom/visualization/create-svg-chart.action.d.ts +97 -0
- package/dist/custom/visualization/create-svg-chart.action.d.ts.map +1 -0
- package/dist/custom/visualization/create-svg-chart.action.js +326 -0
- package/dist/custom/visualization/create-svg-chart.action.js.map +1 -0
- package/dist/custom/visualization/create-svg-diagram.action.d.ts +151 -0
- package/dist/custom/visualization/create-svg-diagram.action.d.ts.map +1 -0
- package/dist/custom/visualization/create-svg-diagram.action.js +764 -0
- package/dist/custom/visualization/create-svg-diagram.action.js.map +1 -0
- package/dist/custom/visualization/create-svg-infographic.action.d.ts +72 -0
- package/dist/custom/visualization/create-svg-infographic.action.d.ts.map +1 -0
- package/dist/custom/visualization/create-svg-infographic.action.js +343 -0
- package/dist/custom/visualization/create-svg-infographic.action.js.map +1 -0
- package/dist/custom/visualization/create-svg-network.action.d.ts +106 -0
- package/dist/custom/visualization/create-svg-network.action.d.ts.map +1 -0
- package/dist/custom/visualization/create-svg-network.action.js +687 -0
- package/dist/custom/visualization/create-svg-network.action.js.map +1 -0
- package/dist/custom/visualization/create-svg-sketch-diagram.action.d.ts +97 -0
- package/dist/custom/visualization/create-svg-sketch-diagram.action.d.ts.map +1 -0
- package/dist/custom/visualization/create-svg-sketch-diagram.action.js +730 -0
- package/dist/custom/visualization/create-svg-sketch-diagram.action.js.map +1 -0
- package/dist/custom/visualization/create-svg-word-cloud.action.d.ts +94 -0
- package/dist/custom/visualization/create-svg-word-cloud.action.d.ts.map +1 -0
- package/dist/custom/visualization/create-svg-word-cloud.action.js +497 -0
- package/dist/custom/visualization/create-svg-word-cloud.action.js.map +1 -0
- package/dist/custom/visualization/shared/svg-theming.d.ts +91 -0
- package/dist/custom/visualization/shared/svg-theming.d.ts.map +1 -0
- package/dist/custom/visualization/shared/svg-theming.js +235 -0
- package/dist/custom/visualization/shared/svg-theming.js.map +1 -0
- package/dist/custom/visualization/shared/svg-types.d.ts +354 -0
- package/dist/custom/visualization/shared/svg-types.d.ts.map +1 -0
- package/dist/custom/visualization/shared/svg-types.js +11 -0
- package/dist/custom/visualization/shared/svg-types.js.map +1 -0
- package/dist/custom/visualization/shared/svg-utils.d.ts +166 -0
- package/dist/custom/visualization/shared/svg-utils.d.ts.map +1 -0
- package/dist/custom/visualization/shared/svg-utils.js +555 -0
- package/dist/custom/visualization/shared/svg-utils.js.map +1 -0
- package/dist/custom/web/google-custom-search.action.d.ts +6 -1
- package/dist/custom/web/google-custom-search.action.d.ts.map +1 -1
- package/dist/custom/web/google-custom-search.action.js +78 -10
- package/dist/custom/web/google-custom-search.action.js.map +1 -1
- package/dist/custom/web/web-page-content.action.d.ts +24 -0
- package/dist/custom/web/web-page-content.action.d.ts.map +1 -1
- package/dist/custom/web/web-page-content.action.js +90 -9
- package/dist/custom/web/web-page-content.action.js.map +1 -1
- package/dist/generated/action_subclasses.d.ts +4 -4
- package/dist/generated/action_subclasses.js +13 -13
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -1
- package/package.json +30 -12
|
@@ -0,0 +1,730 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.LoadCreateSVGSketchDiagramAction = exports.CreateSVGSketchDiagramAction = void 0;
|
|
36
|
+
const actions_1 = require("@memberjunction/actions");
|
|
37
|
+
const global_1 = require("@memberjunction/global");
|
|
38
|
+
const jsdom_1 = require("jsdom");
|
|
39
|
+
const roughjs_1 = __importDefault(require("roughjs"));
|
|
40
|
+
const dagre = __importStar(require("@dagrejs/dagre"));
|
|
41
|
+
const d3Hierarchy = __importStar(require("d3-hierarchy"));
|
|
42
|
+
const svg_utils_1 = require("./shared/svg-utils");
|
|
43
|
+
const svg_theming_1 = require("./shared/svg-theming");
|
|
44
|
+
/**
|
|
45
|
+
* Action that generates hand-drawn/sketch-style SVG diagrams using Rough.js.
|
|
46
|
+
* Provides informal, whiteboard-style visualizations for brainstorming and presentations.
|
|
47
|
+
*
|
|
48
|
+
* This action supports the same diagram types as Create SVG Diagram but renders them
|
|
49
|
+
* with a sketchy, hand-drawn aesthetic using Rough.js.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* // Sketch flowchart
|
|
54
|
+
* await runAction({
|
|
55
|
+
* ActionName: 'Create SVG Sketch Diagram',
|
|
56
|
+
* Params: [
|
|
57
|
+
* { Name: 'DiagramType', Value: 'flow' },
|
|
58
|
+
* { Name: 'Nodes', Value: JSON.stringify([
|
|
59
|
+
* { id: '1', kind: 'start', label: 'Start' },
|
|
60
|
+
* { id: '2', kind: 'process', label: 'Process' },
|
|
61
|
+
* { id: '3', kind: 'end', label: 'End' }
|
|
62
|
+
* ]) },
|
|
63
|
+
* { Name: 'Edges', Value: JSON.stringify([
|
|
64
|
+
* { from: '1', to: '2' },
|
|
65
|
+
* { from: '2', to: '3' }
|
|
66
|
+
* ]) },
|
|
67
|
+
* { Name: 'Roughness', Value: '1.5' },
|
|
68
|
+
* { Name: 'FillStyle', Value: 'cross-hatch' }
|
|
69
|
+
* ]
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
let CreateSVGSketchDiagramAction = class CreateSVGSketchDiagramAction extends actions_1.BaseAction {
|
|
74
|
+
/**
|
|
75
|
+
* Generates a hand-drawn style SVG diagram from the provided data and configuration
|
|
76
|
+
*
|
|
77
|
+
* @param params - The action parameters containing:
|
|
78
|
+
* - DiagramType: Type of diagram ('flow' | 'org' | 'er')
|
|
79
|
+
* - Nodes: JSON array or object of nodes
|
|
80
|
+
* - Edges: JSON array of edges (for flow and ER diagrams)
|
|
81
|
+
* - Roughness: Hand-drawn wobble intensity (0.5-3.0, default: 1.5)
|
|
82
|
+
* - FillStyle: Fill pattern ('solid' | 'hachure' | 'cross-hatch' | 'dots', default: 'hachure')
|
|
83
|
+
* - Bowing: Curve intensity for lines (0-5, default: 1)
|
|
84
|
+
* - Direction: Layout direction ('TB' | 'LR' | 'RL' | 'BT') for flow diagrams
|
|
85
|
+
* - Width: Diagram width in pixels (optional, default: 800)
|
|
86
|
+
* - Height: Diagram height in pixels (optional, default: 600)
|
|
87
|
+
* - Title: Diagram title (optional)
|
|
88
|
+
* - Palette: Color palette name (optional)
|
|
89
|
+
* - EnableTooltips: Enable interactive tooltips (optional)
|
|
90
|
+
* - EnablePanZoom: Enable pan and zoom (optional)
|
|
91
|
+
* - WrapWithContainer: Wrap in scrollable container (optional)
|
|
92
|
+
*
|
|
93
|
+
* @returns A promise resolving to an SVGActionResult
|
|
94
|
+
*/
|
|
95
|
+
async InternalRunAction(params) {
|
|
96
|
+
try {
|
|
97
|
+
const diagramTypeParam = this.getParamValue(params, 'DiagramType');
|
|
98
|
+
if (!diagramTypeParam) {
|
|
99
|
+
return {
|
|
100
|
+
Success: false,
|
|
101
|
+
Message: 'DiagramType parameter is required (flow, org, or er)',
|
|
102
|
+
ResultCode: 'MISSING_PARAMETERS',
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const diagramType = this.ensureString(diagramTypeParam, 'DiagramType').toLowerCase();
|
|
106
|
+
// Parse common parameters
|
|
107
|
+
const width = parseInt(this.ensureString(this.getParamValue(params, 'Width') || '800', 'Width'));
|
|
108
|
+
const height = parseInt(this.ensureString(this.getParamValue(params, 'Height') || '600', 'Height'));
|
|
109
|
+
const title = this.ensureString(this.getParamValue(params, 'Title') || '', 'Title');
|
|
110
|
+
const paletteName = this.ensureString(this.getParamValue(params, 'Palette') || 'mjDefault', 'Palette');
|
|
111
|
+
// Parse Rough.js parameters
|
|
112
|
+
const roughness = parseFloat(this.ensureString(this.getParamValue(params, 'Roughness') || '1.5', 'Roughness'));
|
|
113
|
+
const fillStyle = this.ensureString(this.getParamValue(params, 'FillStyle') || 'hachure', 'FillStyle');
|
|
114
|
+
const bowing = parseFloat(this.ensureString(this.getParamValue(params, 'Bowing') || '1', 'Bowing'));
|
|
115
|
+
// Parse interactivity parameters
|
|
116
|
+
const enableTooltipsParam = this.getParamValue(params, 'EnableTooltips');
|
|
117
|
+
const enableTooltips = enableTooltipsParam ? this.ensureString(enableTooltipsParam, 'EnableTooltips').toLowerCase() === 'true' : false;
|
|
118
|
+
const enablePanZoomParam = this.getParamValue(params, 'EnablePanZoom');
|
|
119
|
+
const enablePanZoom = enablePanZoomParam ? this.ensureString(enablePanZoomParam, 'EnablePanZoom').toLowerCase() === 'true' : false;
|
|
120
|
+
const showZoomControlsParam = this.getParamValue(params, 'ShowZoomControls');
|
|
121
|
+
const showZoomControls = showZoomControlsParam ? this.ensureString(showZoomControlsParam, 'ShowZoomControls').toLowerCase() === 'true' : false;
|
|
122
|
+
const wrapWithContainerParam = this.getParamValue(params, 'WrapWithContainer');
|
|
123
|
+
const wrapWithContainer = wrapWithContainerParam ? this.ensureString(wrapWithContainerParam, 'WrapWithContainer').toLowerCase() === 'true' : false;
|
|
124
|
+
const maxContainerWidth = parseInt(this.ensureString(this.getParamValue(params, 'MaxContainerWidth') || '1200', 'MaxContainerWidth'));
|
|
125
|
+
const maxContainerHeight = parseInt(this.ensureString(this.getParamValue(params, 'MaxContainerHeight') || '800', 'MaxContainerHeight'));
|
|
126
|
+
// Create branding configuration
|
|
127
|
+
const branding = {
|
|
128
|
+
palette: { type: 'named', name: paletteName },
|
|
129
|
+
};
|
|
130
|
+
// Create viewBox configuration
|
|
131
|
+
const viewBox = {
|
|
132
|
+
width,
|
|
133
|
+
height,
|
|
134
|
+
padding: 40,
|
|
135
|
+
};
|
|
136
|
+
// Rough.js options
|
|
137
|
+
const roughOptions = {
|
|
138
|
+
roughness,
|
|
139
|
+
bowing,
|
|
140
|
+
fillStyle: fillStyle,
|
|
141
|
+
strokeWidth: 2,
|
|
142
|
+
fillWeight: 0.5,
|
|
143
|
+
};
|
|
144
|
+
// Generate diagram based on type
|
|
145
|
+
let svg;
|
|
146
|
+
switch (diagramType) {
|
|
147
|
+
case 'flow':
|
|
148
|
+
svg = await this.renderSketchFlow(params, viewBox, branding, title, roughOptions, enableTooltips, enablePanZoom, showZoomControls);
|
|
149
|
+
break;
|
|
150
|
+
case 'org':
|
|
151
|
+
svg = await this.renderSketchOrg(params, viewBox, branding, title, roughOptions, enableTooltips, enablePanZoom, showZoomControls);
|
|
152
|
+
break;
|
|
153
|
+
case 'er':
|
|
154
|
+
svg = await this.renderSketchER(params, viewBox, branding, title, roughOptions, enableTooltips, enablePanZoom, showZoomControls);
|
|
155
|
+
break;
|
|
156
|
+
default:
|
|
157
|
+
return {
|
|
158
|
+
Success: false,
|
|
159
|
+
Message: `Unsupported diagram type: ${diagramType}. Supported types: flow, org, er`,
|
|
160
|
+
ResultCode: 'INVALID_DIAGRAM_TYPE',
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
// Apply scroll container wrapping if requested
|
|
164
|
+
if (wrapWithContainer) {
|
|
165
|
+
svg = svg_utils_1.SVGUtils.wrapWithScrollContainer(svg, maxContainerWidth, maxContainerHeight);
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
Success: true,
|
|
169
|
+
ResultCode: 'SUCCESS',
|
|
170
|
+
Message: svg,
|
|
171
|
+
svg,
|
|
172
|
+
width,
|
|
173
|
+
height,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
return {
|
|
178
|
+
Success: false,
|
|
179
|
+
Message: `Failed to generate sketch diagram: ${error instanceof Error ? error.message : String(error)}`,
|
|
180
|
+
ResultCode: 'DIAGRAM_GENERATION_FAILED',
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Renders a sketch-style flowchart
|
|
186
|
+
*/
|
|
187
|
+
async renderSketchFlow(params, viewBox, branding, title, roughOptions, enableTooltips, enablePanZoom, showZoomControls) {
|
|
188
|
+
// Parse nodes and edges
|
|
189
|
+
const nodesParam = this.getParamValue(params, 'Nodes');
|
|
190
|
+
const edgesParam = this.getParamValue(params, 'Edges');
|
|
191
|
+
if (!nodesParam) {
|
|
192
|
+
throw new Error('Nodes parameter is required for flow diagrams');
|
|
193
|
+
}
|
|
194
|
+
const nodes = this.parseJSON(nodesParam, 'Nodes');
|
|
195
|
+
const edges = edgesParam ? this.parseJSON(edgesParam, 'Edges') : [];
|
|
196
|
+
const directionParam = this.getParamValue(params, 'Direction');
|
|
197
|
+
const direction = (directionParam ? this.ensureString(directionParam, 'Direction') : 'TB');
|
|
198
|
+
// Create dagre graph for layout
|
|
199
|
+
const g = new dagre.graphlib.Graph();
|
|
200
|
+
g.setGraph({
|
|
201
|
+
rankdir: direction,
|
|
202
|
+
nodesep: 50,
|
|
203
|
+
ranksep: 80,
|
|
204
|
+
marginx: 40,
|
|
205
|
+
marginy: 40,
|
|
206
|
+
});
|
|
207
|
+
g.setDefaultEdgeLabel(() => ({}));
|
|
208
|
+
// Add nodes with dimensions
|
|
209
|
+
for (const node of nodes) {
|
|
210
|
+
const dims = this.getNodeDimensions(node);
|
|
211
|
+
g.setNode(node.id, {
|
|
212
|
+
...node,
|
|
213
|
+
width: node.width || dims.width,
|
|
214
|
+
height: node.height || dims.height,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
// Add edges
|
|
218
|
+
for (const edge of edges) {
|
|
219
|
+
g.setEdge(edge.from, edge.to, edge);
|
|
220
|
+
}
|
|
221
|
+
// Run layout
|
|
222
|
+
dagre.layout(g);
|
|
223
|
+
// Create SVG with JSDOM
|
|
224
|
+
const vb = svg_utils_1.SVGUtils.calculateViewBox(viewBox);
|
|
225
|
+
const dom = new jsdom_1.JSDOM(`<svg xmlns="http://www.w3.org/2000/svg" width="${viewBox.width}" height="${viewBox.height}" viewBox="0 0 ${viewBox.width} ${viewBox.height}"></svg>`);
|
|
226
|
+
const doc = dom.window.document;
|
|
227
|
+
const svg = doc.querySelector('svg');
|
|
228
|
+
// Initialize Rough.js with SVG
|
|
229
|
+
const rc = roughjs_1.default.svg(svg);
|
|
230
|
+
// Add accessibility
|
|
231
|
+
if (title) {
|
|
232
|
+
svg_utils_1.SVGUtils.addA11y(svg, {
|
|
233
|
+
title,
|
|
234
|
+
ariaRole: 'img',
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
// Add styles
|
|
238
|
+
const css = (0, svg_theming_1.generateCSS)(branding);
|
|
239
|
+
svg_utils_1.SVGUtils.addStyles(svg, css);
|
|
240
|
+
// Get palette
|
|
241
|
+
const palette = (0, svg_theming_1.getPalette)(branding.palette);
|
|
242
|
+
const ns = svg.namespaceURI;
|
|
243
|
+
// Create container
|
|
244
|
+
const contentContainer = doc.createElementNS(ns, 'g');
|
|
245
|
+
contentContainer.setAttribute('id', enablePanZoom ? 'pan-zoom-container' : 'content-container');
|
|
246
|
+
svg.appendChild(contentContainer);
|
|
247
|
+
// Render edges first (so they appear behind nodes)
|
|
248
|
+
for (const edgeObj of g.edges()) {
|
|
249
|
+
const edge = g.edge(edgeObj);
|
|
250
|
+
// Draw rough line through points
|
|
251
|
+
if (edge.points && edge.points.length >= 2) {
|
|
252
|
+
const pathPoints = edge.points.map(p => [p.x, p.y]);
|
|
253
|
+
const roughLine = rc.linearPath(pathPoints, {
|
|
254
|
+
...roughOptions,
|
|
255
|
+
stroke: palette.foreground,
|
|
256
|
+
fill: 'none',
|
|
257
|
+
strokeWidth: edge.dashed ? 1.5 : 2,
|
|
258
|
+
});
|
|
259
|
+
contentContainer.appendChild(roughLine);
|
|
260
|
+
// Add edge label if present
|
|
261
|
+
if (edge.label) {
|
|
262
|
+
const midPoint = edge.points[Math.floor(edge.points.length / 2)];
|
|
263
|
+
const text = doc.createElementNS(ns, 'text');
|
|
264
|
+
text.setAttribute('x', String(midPoint.x));
|
|
265
|
+
text.setAttribute('y', String(midPoint.y - 5));
|
|
266
|
+
text.setAttribute('class', 'edge-label');
|
|
267
|
+
text.setAttribute('text-anchor', 'middle');
|
|
268
|
+
text.setAttribute('font-size', '11');
|
|
269
|
+
text.textContent = edge.label;
|
|
270
|
+
contentContainer.appendChild(text);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
// Render nodes
|
|
275
|
+
for (const nodeId of g.nodes()) {
|
|
276
|
+
const node = g.node(nodeId);
|
|
277
|
+
const g_elem = doc.createElementNS(ns, 'g');
|
|
278
|
+
g_elem.setAttribute('data-node-id', node.id);
|
|
279
|
+
if (enableTooltips) {
|
|
280
|
+
g_elem.setAttribute('data-tooltip', node.label);
|
|
281
|
+
}
|
|
282
|
+
const colorIndex = this.getNodeColorIndex(node.kind);
|
|
283
|
+
const fillColor = palette.categorical[colorIndex % palette.categorical.length];
|
|
284
|
+
// Draw shape based on kind
|
|
285
|
+
switch (node.kind) {
|
|
286
|
+
case 'start':
|
|
287
|
+
case 'end':
|
|
288
|
+
// Ellipse
|
|
289
|
+
const ellipse = rc.ellipse(node.x, node.y, node.width, node.height, {
|
|
290
|
+
...roughOptions,
|
|
291
|
+
fill: fillColor,
|
|
292
|
+
stroke: '#333',
|
|
293
|
+
});
|
|
294
|
+
g_elem.appendChild(ellipse);
|
|
295
|
+
break;
|
|
296
|
+
case 'decision':
|
|
297
|
+
// Diamond
|
|
298
|
+
const w = node.width / 2;
|
|
299
|
+
const h = node.height / 2;
|
|
300
|
+
const diamond = rc.polygon([
|
|
301
|
+
[node.x, node.y - h],
|
|
302
|
+
[node.x + w, node.y],
|
|
303
|
+
[node.x, node.y + h],
|
|
304
|
+
[node.x - w, node.y]
|
|
305
|
+
], {
|
|
306
|
+
...roughOptions,
|
|
307
|
+
fill: fillColor,
|
|
308
|
+
stroke: '#333',
|
|
309
|
+
});
|
|
310
|
+
g_elem.appendChild(diamond);
|
|
311
|
+
break;
|
|
312
|
+
default:
|
|
313
|
+
// Rectangle
|
|
314
|
+
const rect = rc.rectangle(node.x - node.width / 2, node.y - node.height / 2, node.width, node.height, {
|
|
315
|
+
...roughOptions,
|
|
316
|
+
fill: fillColor,
|
|
317
|
+
stroke: '#333',
|
|
318
|
+
});
|
|
319
|
+
g_elem.appendChild(rect);
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
// Add label
|
|
323
|
+
const text = doc.createElementNS(ns, 'text');
|
|
324
|
+
text.setAttribute('x', String(node.x));
|
|
325
|
+
text.setAttribute('y', String(node.y));
|
|
326
|
+
text.setAttribute('text-anchor', 'middle');
|
|
327
|
+
text.setAttribute('dominant-baseline', 'middle');
|
|
328
|
+
text.setAttribute('font-size', '12');
|
|
329
|
+
text.setAttribute('font-weight', 'bold');
|
|
330
|
+
text.textContent = node.label;
|
|
331
|
+
g_elem.appendChild(text);
|
|
332
|
+
contentContainer.appendChild(g_elem);
|
|
333
|
+
}
|
|
334
|
+
// Add title
|
|
335
|
+
if (title) {
|
|
336
|
+
this.addTitle(doc, svg, title, vb.width, (0, svg_theming_1.getFontSpec)(branding.font));
|
|
337
|
+
}
|
|
338
|
+
// Add interactivity
|
|
339
|
+
if (enableTooltips) {
|
|
340
|
+
svg_utils_1.SVGUtils.addTooltipSupport(svg, doc);
|
|
341
|
+
}
|
|
342
|
+
if (enablePanZoom) {
|
|
343
|
+
const panZoomScript = doc.createElementNS(ns, 'script');
|
|
344
|
+
panZoomScript.setAttribute('type', 'text/javascript');
|
|
345
|
+
panZoomScript.textContent = svg_utils_1.SVGUtils.generatePanZoomScript('pan-zoom-container', 0.5, 3, showZoomControls).replace(/<script[^>]*>|<\/script>/gi, '');
|
|
346
|
+
svg.appendChild(panZoomScript);
|
|
347
|
+
}
|
|
348
|
+
return svg_utils_1.SVGUtils.sanitizeSVG(svg.outerHTML);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Renders a sketch-style org chart
|
|
352
|
+
*/
|
|
353
|
+
async renderSketchOrg(params, viewBox, branding, title, roughOptions, enableTooltips, enablePanZoom, showZoomControls) {
|
|
354
|
+
// Parse org tree
|
|
355
|
+
const nodesParam = this.getParamValue(params, 'Nodes');
|
|
356
|
+
if (!nodesParam) {
|
|
357
|
+
throw new Error('Nodes parameter is required for org charts');
|
|
358
|
+
}
|
|
359
|
+
const rootNode = this.parseJSON(nodesParam, 'Nodes');
|
|
360
|
+
// Create hierarchy
|
|
361
|
+
const hierarchy = d3Hierarchy.hierarchy(rootNode);
|
|
362
|
+
// Create tree layout
|
|
363
|
+
const vb = svg_utils_1.SVGUtils.calculateViewBox(viewBox);
|
|
364
|
+
const treeLayout = d3Hierarchy.tree().size([vb.contentWidth, vb.contentHeight]);
|
|
365
|
+
// Calculate layout
|
|
366
|
+
const treeData = treeLayout(hierarchy);
|
|
367
|
+
// Create SVG
|
|
368
|
+
const dom = new jsdom_1.JSDOM(`<svg xmlns="http://www.w3.org/2000/svg" width="${viewBox.width}" height="${viewBox.height}" viewBox="0 0 ${viewBox.width} ${viewBox.height}"></svg>`);
|
|
369
|
+
const doc = dom.window.document;
|
|
370
|
+
const svg = doc.querySelector('svg');
|
|
371
|
+
// Initialize Rough.js
|
|
372
|
+
const rc = roughjs_1.default.svg(svg);
|
|
373
|
+
// Add accessibility
|
|
374
|
+
if (title) {
|
|
375
|
+
svg_utils_1.SVGUtils.addA11y(svg, {
|
|
376
|
+
title,
|
|
377
|
+
ariaRole: 'img',
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
// Add styles
|
|
381
|
+
const css = (0, svg_theming_1.generateCSS)(branding);
|
|
382
|
+
svg_utils_1.SVGUtils.addStyles(svg, css);
|
|
383
|
+
// Get palette
|
|
384
|
+
const palette = (0, svg_theming_1.getPalette)(branding.palette);
|
|
385
|
+
const ns = svg.namespaceURI;
|
|
386
|
+
// Create container
|
|
387
|
+
const contentContainer = doc.createElementNS(ns, 'g');
|
|
388
|
+
contentContainer.setAttribute('id', enablePanZoom ? 'pan-zoom-container' : 'content-container');
|
|
389
|
+
contentContainer.setAttribute('transform', `translate(${vb.x}, ${vb.y})`);
|
|
390
|
+
svg.appendChild(contentContainer);
|
|
391
|
+
// Render links
|
|
392
|
+
treeData.links().forEach((link) => {
|
|
393
|
+
const points = [
|
|
394
|
+
[link.source.x, link.source.y + 35],
|
|
395
|
+
[link.source.x, (link.source.y + link.target.y) / 2],
|
|
396
|
+
[link.target.x, (link.source.y + link.target.y) / 2],
|
|
397
|
+
[link.target.x, link.target.y - 35],
|
|
398
|
+
];
|
|
399
|
+
const roughPath = rc.linearPath(points, {
|
|
400
|
+
...roughOptions,
|
|
401
|
+
stroke: palette.foreground,
|
|
402
|
+
fill: 'none',
|
|
403
|
+
strokeWidth: 2,
|
|
404
|
+
});
|
|
405
|
+
contentContainer.appendChild(roughPath);
|
|
406
|
+
});
|
|
407
|
+
// Render nodes
|
|
408
|
+
const boxWidth = 180;
|
|
409
|
+
const boxHeight = 70;
|
|
410
|
+
treeData.descendants().forEach((node) => {
|
|
411
|
+
const g_elem = doc.createElementNS(ns, 'g');
|
|
412
|
+
g_elem.setAttribute('data-node-id', node.data.id);
|
|
413
|
+
if (enableTooltips) {
|
|
414
|
+
g_elem.setAttribute('data-tooltip', `${node.data.label}${node.data.role ? ' - ' + node.data.role : ''}`);
|
|
415
|
+
}
|
|
416
|
+
const colorIndex = node.depth % palette.categorical.length;
|
|
417
|
+
const fillColor = palette.categorical[colorIndex];
|
|
418
|
+
// Draw sketchy box
|
|
419
|
+
const box = rc.rectangle(node.x - boxWidth / 2, node.y - boxHeight / 2, boxWidth, boxHeight, {
|
|
420
|
+
...roughOptions,
|
|
421
|
+
fill: fillColor,
|
|
422
|
+
stroke: node.data.highlight ? '#FFD700' : '#333',
|
|
423
|
+
strokeWidth: node.data.highlight ? 3 : 2,
|
|
424
|
+
});
|
|
425
|
+
g_elem.appendChild(box);
|
|
426
|
+
// Add name
|
|
427
|
+
const nameText = doc.createElementNS(ns, 'text');
|
|
428
|
+
nameText.setAttribute('x', String(node.x));
|
|
429
|
+
nameText.setAttribute('y', String(node.y - (node.data.role ? 8 : 0)));
|
|
430
|
+
nameText.setAttribute('text-anchor', 'middle');
|
|
431
|
+
nameText.setAttribute('font-weight', 'bold');
|
|
432
|
+
nameText.setAttribute('font-size', '14');
|
|
433
|
+
nameText.setAttribute('fill', '#FFF');
|
|
434
|
+
nameText.textContent = node.data.label;
|
|
435
|
+
g_elem.appendChild(nameText);
|
|
436
|
+
// Add role
|
|
437
|
+
if (node.data.role) {
|
|
438
|
+
const roleText = doc.createElementNS(ns, 'text');
|
|
439
|
+
roleText.setAttribute('x', String(node.x));
|
|
440
|
+
roleText.setAttribute('y', String(node.y + 8));
|
|
441
|
+
roleText.setAttribute('text-anchor', 'middle');
|
|
442
|
+
roleText.setAttribute('font-size', '12');
|
|
443
|
+
roleText.setAttribute('fill', '#FFF');
|
|
444
|
+
roleText.setAttribute('opacity', '0.9');
|
|
445
|
+
roleText.textContent = node.data.role;
|
|
446
|
+
g_elem.appendChild(roleText);
|
|
447
|
+
}
|
|
448
|
+
contentContainer.appendChild(g_elem);
|
|
449
|
+
});
|
|
450
|
+
// Add title
|
|
451
|
+
if (title) {
|
|
452
|
+
this.addTitle(doc, svg, title, vb.width, (0, svg_theming_1.getFontSpec)(branding.font));
|
|
453
|
+
}
|
|
454
|
+
// Add interactivity
|
|
455
|
+
if (enableTooltips) {
|
|
456
|
+
svg_utils_1.SVGUtils.addTooltipSupport(svg, doc);
|
|
457
|
+
}
|
|
458
|
+
if (enablePanZoom) {
|
|
459
|
+
const panZoomScript = doc.createElementNS(ns, 'script');
|
|
460
|
+
panZoomScript.setAttribute('type', 'text/javascript');
|
|
461
|
+
panZoomScript.textContent = svg_utils_1.SVGUtils.generatePanZoomScript('pan-zoom-container', 0.5, 3, showZoomControls).replace(/<script[^>]*>|<\/script>/gi, '');
|
|
462
|
+
svg.appendChild(panZoomScript);
|
|
463
|
+
}
|
|
464
|
+
return svg_utils_1.SVGUtils.sanitizeSVG(svg.outerHTML);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Renders a sketch-style ER diagram
|
|
468
|
+
*/
|
|
469
|
+
async renderSketchER(params, viewBox, branding, title, roughOptions, enableTooltips, enablePanZoom, showZoomControls) {
|
|
470
|
+
// Parse tables and relations
|
|
471
|
+
const nodesParam = this.getParamValue(params, 'Nodes');
|
|
472
|
+
const edgesParam = this.getParamValue(params, 'Edges');
|
|
473
|
+
if (!nodesParam) {
|
|
474
|
+
throw new Error('Nodes parameter is required for ER diagrams');
|
|
475
|
+
}
|
|
476
|
+
const tables = this.parseJSON(nodesParam, 'Nodes');
|
|
477
|
+
const relations = edgesParam ? this.parseJSON(edgesParam, 'Edges') : [];
|
|
478
|
+
// Create dagre graph for layout
|
|
479
|
+
const g = new dagre.graphlib.Graph();
|
|
480
|
+
g.setGraph({
|
|
481
|
+
rankdir: 'TB',
|
|
482
|
+
nodesep: 60,
|
|
483
|
+
ranksep: 80,
|
|
484
|
+
marginx: 40,
|
|
485
|
+
marginy: 40,
|
|
486
|
+
});
|
|
487
|
+
g.setDefaultEdgeLabel(() => ({}));
|
|
488
|
+
// Add tables as nodes
|
|
489
|
+
for (const table of tables) {
|
|
490
|
+
const height = 40 + table.attrs.length * 25;
|
|
491
|
+
const maxAttrWidth = Math.max(...table.attrs.map((a) => svg_utils_1.SVGUtils.estimateTextWidth(`${a.name}: ${a.type || ''}`, 12)));
|
|
492
|
+
const width = Math.max(200, maxAttrWidth + 80);
|
|
493
|
+
g.setNode(table.id, {
|
|
494
|
+
...table,
|
|
495
|
+
width,
|
|
496
|
+
height,
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
// Add relations as edges
|
|
500
|
+
for (const rel of relations) {
|
|
501
|
+
g.setEdge(rel.from, rel.to, rel);
|
|
502
|
+
}
|
|
503
|
+
// Run layout
|
|
504
|
+
dagre.layout(g);
|
|
505
|
+
// Create SVG
|
|
506
|
+
const vb = svg_utils_1.SVGUtils.calculateViewBox(viewBox);
|
|
507
|
+
const dom = new jsdom_1.JSDOM(`<svg xmlns="http://www.w3.org/2000/svg" width="${viewBox.width}" height="${viewBox.height}" viewBox="0 0 ${viewBox.width} ${viewBox.height}"></svg>`);
|
|
508
|
+
const doc = dom.window.document;
|
|
509
|
+
const svg = doc.querySelector('svg');
|
|
510
|
+
// Initialize Rough.js
|
|
511
|
+
const rc = roughjs_1.default.svg(svg);
|
|
512
|
+
// Add accessibility
|
|
513
|
+
if (title) {
|
|
514
|
+
svg_utils_1.SVGUtils.addA11y(svg, {
|
|
515
|
+
title,
|
|
516
|
+
ariaRole: 'img',
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
// Add styles
|
|
520
|
+
const css = (0, svg_theming_1.generateCSS)(branding);
|
|
521
|
+
svg_utils_1.SVGUtils.addStyles(svg, css);
|
|
522
|
+
// Get palette
|
|
523
|
+
const palette = (0, svg_theming_1.getPalette)(branding.palette);
|
|
524
|
+
const ns = svg.namespaceURI;
|
|
525
|
+
// Create container
|
|
526
|
+
const contentContainer = doc.createElementNS(ns, 'g');
|
|
527
|
+
contentContainer.setAttribute('id', enablePanZoom ? 'pan-zoom-container' : 'content-container');
|
|
528
|
+
svg.appendChild(contentContainer);
|
|
529
|
+
// Render relations
|
|
530
|
+
for (const edgeObj of g.edges()) {
|
|
531
|
+
const rel = g.edge(edgeObj);
|
|
532
|
+
if (rel.points && rel.points.length >= 2) {
|
|
533
|
+
const pathPoints = rel.points.map(p => [p.x, p.y]);
|
|
534
|
+
const roughLine = rc.linearPath(pathPoints, {
|
|
535
|
+
...roughOptions,
|
|
536
|
+
stroke: palette.foreground,
|
|
537
|
+
fill: 'none',
|
|
538
|
+
strokeLineDash: [5, 5],
|
|
539
|
+
});
|
|
540
|
+
contentContainer.appendChild(roughLine);
|
|
541
|
+
// Add label
|
|
542
|
+
if (rel.label) {
|
|
543
|
+
const midPoint = rel.points[Math.floor(rel.points.length / 2)];
|
|
544
|
+
const text = doc.createElementNS(ns, 'text');
|
|
545
|
+
text.setAttribute('x', String(midPoint.x));
|
|
546
|
+
text.setAttribute('y', String(midPoint.y - 5));
|
|
547
|
+
text.setAttribute('text-anchor', 'middle');
|
|
548
|
+
text.setAttribute('font-size', '11');
|
|
549
|
+
text.textContent = rel.label;
|
|
550
|
+
contentContainer.appendChild(text);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
// Render tables
|
|
555
|
+
for (const tableId of g.nodes()) {
|
|
556
|
+
const table = g.node(tableId);
|
|
557
|
+
const g_elem = doc.createElementNS(ns, 'g');
|
|
558
|
+
g_elem.setAttribute('data-node-id', table.id);
|
|
559
|
+
if (enableTooltips) {
|
|
560
|
+
g_elem.setAttribute('data-tooltip', `${table.name} (${table.attrs.length} attributes)`);
|
|
561
|
+
}
|
|
562
|
+
// Draw outer box
|
|
563
|
+
const outerBox = rc.rectangle(table.x - table.width / 2, table.y - table.height / 2, table.width, table.height, {
|
|
564
|
+
...roughOptions,
|
|
565
|
+
fill: palette.background,
|
|
566
|
+
stroke: palette.foreground,
|
|
567
|
+
});
|
|
568
|
+
g_elem.appendChild(outerBox);
|
|
569
|
+
// Draw header box
|
|
570
|
+
const headerBox = rc.rectangle(table.x - table.width / 2, table.y - table.height / 2, table.width, 40, {
|
|
571
|
+
...roughOptions,
|
|
572
|
+
fill: palette.categorical[0],
|
|
573
|
+
stroke: palette.foreground,
|
|
574
|
+
});
|
|
575
|
+
g_elem.appendChild(headerBox);
|
|
576
|
+
// Add table name
|
|
577
|
+
const nameText = doc.createElementNS(ns, 'text');
|
|
578
|
+
nameText.setAttribute('x', String(table.x));
|
|
579
|
+
nameText.setAttribute('y', String(table.y - table.height / 2 + 25));
|
|
580
|
+
nameText.setAttribute('text-anchor', 'middle');
|
|
581
|
+
nameText.setAttribute('font-weight', 'bold');
|
|
582
|
+
nameText.setAttribute('font-size', '14');
|
|
583
|
+
nameText.setAttribute('fill', '#FFF');
|
|
584
|
+
nameText.textContent = table.name;
|
|
585
|
+
g_elem.appendChild(nameText);
|
|
586
|
+
// Add attributes
|
|
587
|
+
let yOffset = table.y - table.height / 2 + 40;
|
|
588
|
+
for (const attr of table.attrs) {
|
|
589
|
+
const attrText = doc.createElementNS(ns, 'text');
|
|
590
|
+
attrText.setAttribute('x', String(table.x - table.width / 2 + 10));
|
|
591
|
+
attrText.setAttribute('y', String(yOffset + 17));
|
|
592
|
+
attrText.setAttribute('font-size', '12');
|
|
593
|
+
attrText.setAttribute('fill', palette.foreground);
|
|
594
|
+
let label = attr.name;
|
|
595
|
+
if (attr.pk)
|
|
596
|
+
label = '🔑 ' + label;
|
|
597
|
+
else if (attr.fk)
|
|
598
|
+
label = '🔗 ' + label;
|
|
599
|
+
if (attr.type)
|
|
600
|
+
label += `: ${attr.type}`;
|
|
601
|
+
attrText.textContent = label;
|
|
602
|
+
g_elem.appendChild(attrText);
|
|
603
|
+
yOffset += 25;
|
|
604
|
+
}
|
|
605
|
+
contentContainer.appendChild(g_elem);
|
|
606
|
+
}
|
|
607
|
+
// Add title
|
|
608
|
+
if (title) {
|
|
609
|
+
this.addTitle(doc, svg, title, vb.width, (0, svg_theming_1.getFontSpec)(branding.font));
|
|
610
|
+
}
|
|
611
|
+
// Add interactivity
|
|
612
|
+
if (enableTooltips) {
|
|
613
|
+
svg_utils_1.SVGUtils.addTooltipSupport(svg, doc);
|
|
614
|
+
}
|
|
615
|
+
if (enablePanZoom) {
|
|
616
|
+
const panZoomScript = doc.createElementNS(ns, 'script');
|
|
617
|
+
panZoomScript.setAttribute('type', 'text/javascript');
|
|
618
|
+
panZoomScript.textContent = svg_utils_1.SVGUtils.generatePanZoomScript('pan-zoom-container', 0.5, 3, showZoomControls).replace(/<script[^>]*>|<\/script>/gi, '');
|
|
619
|
+
svg.appendChild(panZoomScript);
|
|
620
|
+
}
|
|
621
|
+
return svg_utils_1.SVGUtils.sanitizeSVG(svg.outerHTML);
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Gets dimensions for flow node based on kind
|
|
625
|
+
*/
|
|
626
|
+
getNodeDimensions(node) {
|
|
627
|
+
const labelWidth = svg_utils_1.SVGUtils.estimateTextWidth(node.label, 14);
|
|
628
|
+
switch (node.kind) {
|
|
629
|
+
case 'start':
|
|
630
|
+
case 'end':
|
|
631
|
+
return { width: 120, height: 60 };
|
|
632
|
+
case 'decision':
|
|
633
|
+
return { width: Math.max(160, labelWidth + 40), height: 100 };
|
|
634
|
+
case 'process':
|
|
635
|
+
case 'input':
|
|
636
|
+
case 'output':
|
|
637
|
+
case 'subprocess':
|
|
638
|
+
return { width: Math.max(140, labelWidth + 40), height: 70 };
|
|
639
|
+
default:
|
|
640
|
+
return { width: 140, height: 70 };
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Gets color index for node kind
|
|
645
|
+
*/
|
|
646
|
+
getNodeColorIndex(kind) {
|
|
647
|
+
const kindMap = {
|
|
648
|
+
start: 0,
|
|
649
|
+
end: 1,
|
|
650
|
+
process: 2,
|
|
651
|
+
decision: 3,
|
|
652
|
+
input: 4,
|
|
653
|
+
output: 5,
|
|
654
|
+
subprocess: 6,
|
|
655
|
+
};
|
|
656
|
+
return kindMap[kind] || 2;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Adds a title to the SVG
|
|
660
|
+
*/
|
|
661
|
+
addTitle(doc, svg, title, width, font) {
|
|
662
|
+
const ns = svg.namespaceURI;
|
|
663
|
+
const text = doc.createElementNS(ns, 'text');
|
|
664
|
+
text.setAttribute('x', String(width / 2));
|
|
665
|
+
text.setAttribute('y', '25');
|
|
666
|
+
text.setAttribute('text-anchor', 'middle');
|
|
667
|
+
text.setAttribute('font-family', font.family);
|
|
668
|
+
text.setAttribute('font-size', String(font.size + 4));
|
|
669
|
+
text.setAttribute('font-weight', 'bold');
|
|
670
|
+
text.textContent = title;
|
|
671
|
+
svg.appendChild(text);
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Helper to safely parse JSON
|
|
675
|
+
*/
|
|
676
|
+
parseJSON(value, paramName) {
|
|
677
|
+
if (typeof value === 'object' && value !== null) {
|
|
678
|
+
return value;
|
|
679
|
+
}
|
|
680
|
+
if (typeof value === 'string') {
|
|
681
|
+
try {
|
|
682
|
+
return JSON.parse(value);
|
|
683
|
+
}
|
|
684
|
+
catch (error) {
|
|
685
|
+
throw new Error(`Parameter '${paramName}' contains invalid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
throw new Error(`Parameter '${paramName}' must be a JSON string or object. Received ${typeof value}.`);
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Helper to ensure string type
|
|
692
|
+
*/
|
|
693
|
+
ensureString(value, paramName) {
|
|
694
|
+
if (value == null) {
|
|
695
|
+
return '';
|
|
696
|
+
}
|
|
697
|
+
if (typeof value === 'string') {
|
|
698
|
+
return value;
|
|
699
|
+
}
|
|
700
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
701
|
+
return String(value);
|
|
702
|
+
}
|
|
703
|
+
throw new Error(`Parameter '${paramName}' must be a string, number, or boolean. ` +
|
|
704
|
+
`Received ${typeof value}.`);
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Helper to get parameter value by name
|
|
708
|
+
*/
|
|
709
|
+
getParamValue(params, paramName) {
|
|
710
|
+
const param = params.Params.find((p) => p.Name.trim().toLowerCase() === paramName.toLowerCase());
|
|
711
|
+
if (param?.Value && typeof param.Value === 'string') {
|
|
712
|
+
return param?.Value?.trim() || null;
|
|
713
|
+
}
|
|
714
|
+
else {
|
|
715
|
+
return param?.Value || null;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
exports.CreateSVGSketchDiagramAction = CreateSVGSketchDiagramAction;
|
|
720
|
+
exports.CreateSVGSketchDiagramAction = CreateSVGSketchDiagramAction = __decorate([
|
|
721
|
+
(0, global_1.RegisterClass)(actions_1.BaseAction, '__CreateSVGSketchDiagram')
|
|
722
|
+
], CreateSVGSketchDiagramAction);
|
|
723
|
+
/**
|
|
724
|
+
* Loader function to ensure the CreateSVGSketchDiagramAction class is included in the bundle.
|
|
725
|
+
*/
|
|
726
|
+
function LoadCreateSVGSketchDiagramAction() {
|
|
727
|
+
// Stub function to prevent tree-shaking
|
|
728
|
+
}
|
|
729
|
+
exports.LoadCreateSVGSketchDiagramAction = LoadCreateSVGSketchDiagramAction;
|
|
730
|
+
//# sourceMappingURL=create-svg-sketch-diagram.action.js.map
|