snow-flow 3.0.9 → 3.0.13
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/claude-flow.bat +0 -0
- package/claude-flow.ps1 +0 -0
- package/dist/mcp/intelligent-reporting-mcp.d.ts +7 -0
- package/dist/mcp/intelligent-reporting-mcp.js +379 -0
- package/dist/mcp/servicenow-automation-mcp.js +0 -0
- package/dist/mcp/servicenow-deployment-mcp.js +0 -0
- package/dist/mcp/servicenow-integration-mcp.js +0 -0
- package/dist/mcp/servicenow-mcp-server.js +0 -0
- package/dist/mcp/servicenow-operations-mcp.js +0 -0
- package/dist/mcp/servicenow-platform-development-mcp.js +0 -0
- package/dist/mcp/servicenow-progressive-indexer.js +0 -0
- package/dist/mcp/servicenow-reporting-analytics-mcp.js +280 -29
- package/dist/mcp/servicenow-security-compliance-mcp.js +0 -0
- package/dist/mcp/servicenow-update-set-mcp.js +0 -0
- package/dist/mcp/start-all-mcp-servers.js +0 -0
- package/dist/mcp/start-servicenow-mcp.js +0 -0
- package/dist/services/widget-deployment-service.d.ts +2 -1
- package/dist/services/widget-deployment-service.js +17 -16
- package/dist/utils/anti-mock-data-validator.d.ts +66 -0
- package/dist/utils/anti-mock-data-validator.js +316 -0
- package/dist/utils/servicenow-eventual-consistency.d.ts +120 -0
- package/dist/utils/servicenow-eventual-consistency.js +220 -0
- package/memory/agents/README.md +1 -1
- package/memory/claude-flow-data.json +1 -1
- package/memory/sessions/README.md +1 -1
- package/package.json +4 -3
- package/.mcp.json +0 -22
- package/claude-flow.config.json +0 -20
- package/dist/agents/app-creator.agent.d.ts +0 -55
- package/dist/agents/app-creator.agent.js +0 -1292
- package/dist/agents/base/base-snow-agent.d.ts +0 -75
- package/dist/agents/base/base-snow-agent.js +0 -169
- package/dist/agents/base-snow-agent.d.ts +0 -63
- package/dist/agents/base-snow-agent.js +0 -296
- package/dist/agents/coordinator.d.ts +0 -200
- package/dist/agents/coordinator.js +0 -777
- package/dist/agents/flow-builder-agent.d.ts +0 -18
- package/dist/agents/flow-builder-agent.js +0 -197
- package/dist/agents/queen-403-handler.d.ts +0 -47
- package/dist/agents/queen-403-handler.js +0 -175
- package/dist/agents/queen-agent-example.d.ts +0 -23
- package/dist/agents/queen-agent-example.js +0 -240
- package/dist/agents/queen-agent.test.d.ts +0 -6
- package/dist/agents/script-generator.agent.d.ts +0 -32
- package/dist/agents/script-generator.agent.js +0 -772
- package/dist/agents/script-writer-agent.d.ts +0 -22
- package/dist/agents/script-writer-agent.js +0 -695
- package/dist/agents/security-agent.d.ts +0 -23
- package/dist/agents/security-agent.js +0 -619
- package/dist/agents/specialists/automation-specialist.agent.d.ts +0 -44
- package/dist/agents/specialists/automation-specialist.agent.js +0 -204
- package/dist/agents/specialists/data-specialist.agent.d.ts +0 -165
- package/dist/agents/specialists/data-specialist.agent.js +0 -484
- package/dist/agents/specialists/integration-specialist.agent.d.ts +0 -227
- package/dist/agents/specialists/integration-specialist.agent.js +0 -725
- package/dist/agents/specialists/reporting-specialist.agent.d.ts +0 -54
- package/dist/agents/specialists/reporting-specialist.agent.js +0 -193
- package/dist/agents/specialists/security-specialist.agent.d.ts +0 -85
- package/dist/agents/specialists/security-specialist.agent.js +0 -309
- package/dist/agents/teams/adaptive/adaptive-coordinator.agent.d.ts +0 -111
- package/dist/agents/teams/adaptive/adaptive-coordinator.agent.js +0 -383
- package/dist/agents/teams/base-team.d.ts +0 -72
- package/dist/agents/teams/base-team.js +0 -253
- package/dist/agents/teams/team-types.d.ts +0 -265
- package/dist/agents/teams/team-types.js +0 -3
- package/dist/agents/teams/widget/widget-architect.agent.d.ts +0 -61
- package/dist/agents/teams/widget/widget-architect.agent.js +0 -436
- package/dist/agents/teams/widget/widget-backend.agent.d.ts +0 -74
- package/dist/agents/teams/widget/widget-backend.agent.js +0 -1531
- package/dist/agents/teams/widget/widget-frontend.agent.d.ts +0 -67
- package/dist/agents/teams/widget/widget-frontend.agent.js +0 -1014
- package/dist/agents/teams/widget/widget-platform.agent.d.ts +0 -90
- package/dist/agents/teams/widget/widget-platform.agent.js +0 -1190
- package/dist/agents/teams/widget/widget-uiux.agent.d.ts +0 -107
- package/dist/agents/teams/widget/widget-uiux.agent.js +0 -1033
- package/dist/agents/test-agent.d.ts +0 -26
- package/dist/agents/test-agent.js +0 -734
- package/dist/agents/test-agents.d.ts +0 -7
- package/dist/agents/test-agents.js +0 -64
- package/dist/agents/ui-builder.agent.d.ts +0 -50
- package/dist/agents/ui-builder.agent.js +0 -1539
- package/dist/agents/widget-builder.agent.d.ts +0 -32
- package/dist/agents/widget-builder.agent.js +0 -439
- package/dist/agents/widget-creator-agent.d.ts +0 -18
- package/dist/agents/widget-creator-agent.js +0 -498
- package/dist/agents/workflow-designer.agent.d.ts +0 -31
- package/dist/agents/workflow-designer.agent.js +0 -583
- package/dist/api/error-handling.d.ts +0 -325
- package/dist/api/error-handling.js +0 -1488
- package/dist/api/flow-designer-api.d.ts +0 -167
- package/dist/api/flow-designer-api.js +0 -554
- package/dist/api/natural-language-mapper.d.ts +0 -124
- package/dist/api/natural-language-mapper.js +0 -501
- package/dist/api/performance-optimizer.d.ts +0 -240
- package/dist/api/performance-optimizer.js +0 -706
- package/dist/api/transaction-manager.d.ts +0 -189
- package/dist/api/transaction-manager.js +0 -576
- package/dist/assembly/team-assembler.d.ts +0 -140
- package/dist/assembly/team-assembler.js +0 -502
- package/dist/benchmark-performance.d.ts +0 -41
- package/dist/benchmark-performance.js +0 -230
- package/dist/cli/snow-flow-cli-integration.d.ts +0 -30
- package/dist/cli/snow-flow-cli-integration.js +0 -396
- package/dist/coordination/coordination-engine.d.ts +0 -41
- package/dist/coordination/coordination-engine.js +0 -324
- package/dist/coordination/coordination.test.d.ts +0 -6
- package/dist/coordination/example.d.ts +0 -31
- package/dist/coordination/example.js +0 -394
- package/dist/coordination/execution-patterns.d.ts +0 -43
- package/dist/coordination/execution-patterns.js +0 -507
- package/dist/coordination/factory.d.ts +0 -94
- package/dist/coordination/factory.js +0 -433
- package/dist/coordination/index.d.ts +0 -71
- package/dist/coordination/index.js +0 -135
- package/dist/coordination/progress-monitor.d.ts +0 -71
- package/dist/coordination/progress-monitor.js +0 -505
- package/dist/coordination/quality-gates.d.ts +0 -124
- package/dist/coordination/quality-gates.js +0 -577
- package/dist/coordination/shared-memory.d.ts +0 -39
- package/dist/coordination/shared-memory.js +0 -289
- package/dist/coordination/task-dependencies.d.ts +0 -50
- package/dist/coordination/task-dependencies.js +0 -407
- package/dist/coordination/team-coordinator.d.ts +0 -59
- package/dist/coordination/team-coordinator.js +0 -550
- package/dist/coordination/types.d.ts +0 -152
- package/dist/coordination/types.js +0 -3
- package/dist/mcp/mcp-wrapper.d.ts +0 -8
- package/dist/mcp/mcp-wrapper.js +0 -77
- package/dist/mcp/servicenow-flow-composer-enhanced.js +0 -396
- package/dist/mcp/servicenow-flow-composer-mcp.d.ts +0 -7
- package/dist/mcp/servicenow-flow-composer-mcp.js +0 -3103
- package/dist/mcp/servicenow-graph-memory-mcp.d.ts +0 -7
- package/dist/mcp/servicenow-intelligent-mcp.d.ts +0 -143
- package/dist/mcp/servicenow-intelligent-mcp.js +0 -4156
- package/dist/mcp/servicenow-xml-flow-mcp.d.ts +0 -53
- package/dist/mcp/servicenow-xml-flow-mcp.js +0 -1704
- package/dist/mcp/singleton-check.js +0 -31
- package/dist/mcp/test-simple-mcp.d.ts +0 -6
- package/dist/mcp/test-simple-mcp.js +0 -63
- package/dist/memory/hierarchical-memory-system.d.ts +0 -90
- package/dist/memory/hierarchical-memory-system.js +0 -400
- package/dist/memory/index.d.ts +0 -9
- package/dist/memory/index.js +0 -20
- package/dist/memory/mcp-integration-example.d.ts +0 -6
- package/dist/memory/mcp-integration-example.js +0 -281
- package/dist/memory/memory-client.d.ts +0 -199
- package/dist/memory/memory-client.js +0 -364
- package/dist/memory/memory-manager.d.ts +0 -29
- package/dist/memory/memory-manager.js +0 -280
- package/dist/memory/memory-operations.d.ts +0 -179
- package/dist/memory/memory-operations.js +0 -691
- package/dist/memory/memory-system.d.ts +0 -153
- package/dist/memory/memory-system.js +0 -651
- package/dist/memory/memory-test.d.ts +0 -6
- package/dist/memory/memory-test.js +0 -161
- package/dist/memory/snow-flow-memory-patterns.d.ts +0 -213
- package/dist/memory/snow-flow-memory-patterns.js +0 -200
- package/dist/memory/snow-memory.d.ts +0 -54
- package/dist/memory/snow-memory.js +0 -301
- package/dist/memory/swarm-memory.d.ts +0 -135
- package/dist/memory/swarm-memory.js +0 -378
- package/dist/optimization/flow-performance-optimizer.js +0 -723
- package/dist/orchestration/discovery/service-discovery.d.ts +0 -81
- package/dist/orchestration/discovery/service-discovery.js +0 -808
- package/dist/orchestration/distributed-orchestrator.d.ts +0 -131
- package/dist/orchestration/distributed-orchestrator.js +0 -712
- package/dist/orchestration/distribution/task-distribution-engine.d.ts +0 -53
- package/dist/orchestration/distribution/task-distribution-engine.js +0 -586
- package/dist/orchestration/flow-update-orchestrator.js +0 -648
- package/dist/orchestration/interfaces/distributed-orchestration.interface.d.ts +0 -606
- package/dist/orchestration/interfaces/distributed-orchestration.interface.js +0 -65
- package/dist/orchestration/protocols/mcpx-protocol.d.ts +0 -71
- package/dist/orchestration/protocols/mcpx-protocol.js +0 -668
- package/dist/orchestration/state/distributed-state-manager.d.ts +0 -89
- package/dist/orchestration/state/distributed-state-manager.js +0 -716
- package/dist/orchestrator/flow-composer.d.ts +0 -105
- package/dist/orchestrator/flow-composer.js +0 -404
- package/dist/orchestrator/flow-pattern-templates.d.ts +0 -260
- package/dist/orchestrator/flow-pattern-templates.js +0 -908
- package/dist/orchestrator/flow-subflow-decision-engine.d.ts +0 -202
- package/dist/orchestrator/flow-subflow-decision-engine.js +0 -769
- package/dist/orchestrator/flow-validation-engine.d.ts +0 -169
- package/dist/orchestrator/flow-validation-engine.js +0 -913
- package/dist/orchestrator/snow-orchestrator.d.ts +0 -49
- package/dist/orchestrator/snow-orchestrator.js +0 -235
- package/dist/orchestrator/subflow-creation-handler.d.ts +0 -230
- package/dist/orchestrator/subflow-creation-handler.js +0 -791
- package/dist/patterns/adaptive-patterns.d.ts +0 -140
- package/dist/patterns/adaptive-patterns.js +0 -549
- package/dist/queen/advanced-integration-test.d.ts +0 -48
- package/dist/queen/advanced-integration-test.js +0 -473
- package/dist/queen/integration-example.d.ts +0 -82
- package/dist/queen/integration-example.js +0 -219
- package/dist/queen/integration-test.d.ts +0 -72
- package/dist/queen/integration-test.js +0 -563
- package/dist/queen/mock-mcp-client.d.ts +0 -71
- package/dist/queen/mock-mcp-client.js +0 -317
- package/dist/queen/run-integration-tests.d.ts +0 -9
- package/dist/queen/run-integration-tests.js +0 -27
- package/dist/sparc/coordinators/adaptive-coordinator.d.ts +0 -54
- package/dist/sparc/coordinators/adaptive-coordinator.js +0 -367
- package/dist/sparc/coordinators/team-coordinator.d.ts +0 -66
- package/dist/sparc/coordinators/team-coordinator.js +0 -402
- package/dist/sparc/modes/team-modes.d.ts +0 -33
- package/dist/sparc/modes/team-modes.js +0 -399
- package/dist/sparc/teams/application-team.d.ts +0 -73
- package/dist/sparc/teams/application-team.js +0 -463
- package/dist/sparc/teams/flow-team.d.ts +0 -67
- package/dist/sparc/teams/flow-team.js +0 -373
- package/dist/sparc/teams/widget-team.d.ts +0 -61
- package/dist/sparc/teams/widget-team.js +0 -280
- package/dist/specialists/app-specialists.d.ts +0 -93
- package/dist/specialists/app-specialists.js +0 -1639
- package/dist/specialists/base-specialist.d.ts +0 -19
- package/dist/specialists/base-specialist.js +0 -54
- package/dist/specialists/flow-specialists.d.ts +0 -113
- package/dist/specialists/flow-specialists.js +0 -1787
- package/dist/specialists/individual-specialists.d.ts +0 -67
- package/dist/specialists/individual-specialists.js +0 -632
- package/dist/specialists/widget-specialists.d.ts +0 -70
- package/dist/specialists/widget-specialists.js +0 -1264
- package/dist/src/utils/agent-detector.js +0 -655
- package/dist/teams/adaptive-team.d.ts +0 -81
- package/dist/teams/adaptive-team.js +0 -1153
- package/dist/teams/application-team.d.ts +0 -30
- package/dist/teams/application-team.js +0 -547
- package/dist/teams/base-team.d.ts +0 -55
- package/dist/teams/base-team.js +0 -243
- package/dist/teams/flow-team.d.ts +0 -28
- package/dist/teams/flow-team.js +0 -525
- package/dist/teams/widget-team.d.ts +0 -26
- package/dist/teams/widget-team.js +0 -459
- package/dist/templates/flow-template-system.js +0 -625
- package/dist/test-fetch-incidents.d.ts +0 -2
- package/dist/test-fetch-incidents.js +0 -84
- package/dist/test-incident-access.d.ts +0 -2
- package/dist/test-incident-access.js +0 -72
- package/dist/test-iphone-flow.js +0 -189
- package/dist/test-limit-problem.d.ts +0 -2
- package/dist/test-limit-problem.js +0 -60
- package/dist/test-ml-batch-fix.d.ts +0 -2
- package/dist/test-ml-batch-fix.js +0 -104
- package/dist/test-ml-batch.d.ts +0 -2
- package/dist/test-ml-batch.js +0 -87
- package/dist/test-ml-query.d.ts +0 -2
- package/dist/test-ml-query.js +0 -100
- package/dist/test-ml-training-fix.d.ts +0 -12
- package/dist/test-ml-training-fix.js +0 -113
- package/dist/test-ml-training.d.ts +0 -2
- package/dist/test-ml-training.js +0 -32
- package/dist/test-operations-query.d.ts +0 -2
- package/dist/test-operations-query.js +0 -84
- package/dist/test-performance-query.d.ts +0 -2
- package/dist/test-performance-query.js +0 -52
- package/dist/test-singleton-protection.d.ts +0 -8
- package/dist/test-singleton-protection.js +0 -110
- package/dist/test-smart-limits.d.ts +0 -13
- package/dist/test-smart-limits.js +0 -100
- package/dist/test-snow-query-incidents.d.ts +0 -2
- package/dist/test-snow-query-incidents.js +0 -66
- package/dist/test-universal-query.d.ts +0 -2
- package/dist/test-universal-query.js +0 -106
- package/dist/testing/flow-testing-automation.js +0 -641
- package/dist/utils/complete-flow-xml-generator.js +0 -1285
- package/dist/utils/file-storage-fallback.d.ts +0 -62
- package/dist/utils/file-storage-fallback.js +0 -289
- package/dist/utils/flow-api-discovery.d.ts +0 -151
- package/dist/utils/flow-api-discovery.js +0 -439
- package/dist/utils/flow-examples.js +0 -720
- package/dist/utils/flow-structure-builder.js +0 -677
- package/dist/utils/flow-xml-generator.d.ts +0 -41
- package/dist/utils/flow-xml-generator.js +0 -258
- package/dist/utils/improved-flow-xml-generator.js +0 -820
- package/dist/utils/mcp-process-manager.backup.d.ts +0 -58
- package/dist/utils/mcp-process-manager.backup.js +0 -220
- package/dist/utils/mcp-singleton-enforcer.d.ts +0 -36
- package/dist/utils/mcp-singleton-enforcer.js +0 -201
- package/dist/utils/mcp-timeout-fix.d.ts +0 -53
- package/dist/utils/mcp-timeout-fix.js +0 -221
- package/dist/utils/migrate-claude-flow.d.ts +0 -22
- package/dist/utils/migrate-claude-flow.js +0 -120
- package/dist/utils/scope-utils.d.ts +0 -72
- package/dist/utils/scope-utils.js +0 -386
- package/dist/utils/snow-oauth-old.d.ts +0 -65
- package/dist/utils/snow-oauth-old.js +0 -345
- package/dist/utils/xml-first-flow-generator.js +0 -513
- package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +0 -30
- package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +0 -36
- package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +0 -30
- package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +0 -30
- package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +0 -55
- package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +0 -55
- package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +0 -9
- package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +0 -9
- package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +0 -8
- package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +0 -9
- package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +0 -9
- package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +0 -9
- package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +0 -58
- package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +0 -9
- package/reports/swarm-auto-centralized-1752649029776.json +0 -13
- package/src/memory/README.md +0 -240
|
@@ -1,1539 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* UI Builder Agent for UI Pages and UI Actions
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.UIBuilderAgent = void 0;
|
|
7
|
-
const base_agent_js_1 = require("../core/base-agent.js");
|
|
8
|
-
class UIBuilderAgent extends base_agent_js_1.BaseServiceNowAgent {
|
|
9
|
-
constructor(config) {
|
|
10
|
-
super('ui-builder', servicenow_types_js_1.AgentType.UI_BUILDER, [
|
|
11
|
-
'create_ui_page',
|
|
12
|
-
'create_ui_action',
|
|
13
|
-
'generate_form_layout',
|
|
14
|
-
'create_ui_macro',
|
|
15
|
-
'generate_responsive_ui',
|
|
16
|
-
'create_ui_components',
|
|
17
|
-
'validate_ui_code'
|
|
18
|
-
], config);
|
|
19
|
-
}
|
|
20
|
-
async execute(task) {
|
|
21
|
-
this.logger.info(`Executing UI building task: ${task.description}`);
|
|
22
|
-
try {
|
|
23
|
-
switch (task.type) {
|
|
24
|
-
case 'create_ui_page':
|
|
25
|
-
return await this.createUIPage(task);
|
|
26
|
-
case 'create_ui_action':
|
|
27
|
-
return await this.createUIAction(task);
|
|
28
|
-
case 'generate_ui_from_spec':
|
|
29
|
-
return await this.generateUIFromSpec(task);
|
|
30
|
-
case 'create_form_layout':
|
|
31
|
-
return await this.createFormLayout(task);
|
|
32
|
-
case 'create_ui_components':
|
|
33
|
-
return await this.createUIComponents(task);
|
|
34
|
-
default:
|
|
35
|
-
throw new Error(`Unknown task type: ${task.type}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
this.logger.error(`UI building task failed: ${error.message}`);
|
|
40
|
-
return {
|
|
41
|
-
taskId: task.id,
|
|
42
|
-
success: false,
|
|
43
|
-
error: error.message
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async createUIPage(task) {
|
|
48
|
-
const { name, description, layout, components, directAccess } = task.payload;
|
|
49
|
-
const uiPage = {
|
|
50
|
-
name,
|
|
51
|
-
html: this.generateUIPageHTML(name, layout, components),
|
|
52
|
-
processingScript: this.generateProcessingScript(components),
|
|
53
|
-
clientScript: this.generateUIPageClientScript(components),
|
|
54
|
-
directAccess: directAccess ?? false
|
|
55
|
-
};
|
|
56
|
-
// Generate CSS file
|
|
57
|
-
const css = this.generateUIPageCSS(name, layout);
|
|
58
|
-
// Generate orchestration commands
|
|
59
|
-
const commands = [
|
|
60
|
-
this.generateCommand('Bash', 'create', {
|
|
61
|
-
command: `mkdir -p /Users/nielsvanderwerf/Projects/servicenow_multiagent/output/ui_pages/${this.sanitizeName(name)}`,
|
|
62
|
-
description: `Create UI Page directory for ${name}`
|
|
63
|
-
}, 'Create directory'),
|
|
64
|
-
this.generateCommand('Write', 'create', {
|
|
65
|
-
file_path: `/Users/nielsvanderwerf/Projects/servicenow_multiagent/output/ui_pages/${this.sanitizeName(name)}/page.html`,
|
|
66
|
-
content: uiPage.html
|
|
67
|
-
}, `Create UI Page HTML: ${name}`),
|
|
68
|
-
this.generateCommand('Write', 'create', {
|
|
69
|
-
file_path: `/Users/nielsvanderwerf/Projects/servicenow_multiagent/output/ui_pages/${this.sanitizeName(name)}/processing.js`,
|
|
70
|
-
content: uiPage.processingScript || '// No processing script required'
|
|
71
|
-
}, 'Create processing script'),
|
|
72
|
-
this.generateCommand('Write', 'create', {
|
|
73
|
-
file_path: `/Users/nielsvanderwerf/Projects/servicenow_multiagent/output/ui_pages/${this.sanitizeName(name)}/client.js`,
|
|
74
|
-
content: uiPage.clientScript || '// No client script required'
|
|
75
|
-
}, 'Create client script'),
|
|
76
|
-
this.generateCommand('Write', 'create', {
|
|
77
|
-
file_path: `/Users/nielsvanderwerf/Projects/servicenow_multiagent/output/ui_pages/${this.sanitizeName(name)}/styles.css`,
|
|
78
|
-
content: css
|
|
79
|
-
}, 'Create CSS styles'),
|
|
80
|
-
this.generateCommand('Write', 'create', {
|
|
81
|
-
file_path: `/Users/nielsvanderwerf/Projects/servicenow_multiagent/output/ui_pages/${this.sanitizeName(name)}/config.json`,
|
|
82
|
-
content: JSON.stringify({
|
|
83
|
-
name,
|
|
84
|
-
description: description || `UI Page: ${name}`,
|
|
85
|
-
directAccess,
|
|
86
|
-
created: new Date().toISOString()
|
|
87
|
-
}, null, 2)
|
|
88
|
-
}, 'Create UI Page configuration')
|
|
89
|
-
];
|
|
90
|
-
// Store in memory
|
|
91
|
-
await this.storeInMemory(`ui_pages:${this.sanitizeName(name)}`, uiPage);
|
|
92
|
-
return {
|
|
93
|
-
taskId: task.id,
|
|
94
|
-
success: true,
|
|
95
|
-
output: uiPage,
|
|
96
|
-
artifacts: [
|
|
97
|
-
this.createArtifact('ui_page', name, uiPage, {
|
|
98
|
-
hasProcessingScript: !!uiPage.processingScript,
|
|
99
|
-
hasClientScript: !!uiPage.clientScript,
|
|
100
|
-
directAccess
|
|
101
|
-
})
|
|
102
|
-
],
|
|
103
|
-
commands
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
async createUIAction(task) {
|
|
107
|
-
const { name, table, label, formButton, listButton, conditions, action } = task.payload;
|
|
108
|
-
const uiAction = {
|
|
109
|
-
name,
|
|
110
|
-
table,
|
|
111
|
-
formButton: formButton ?? true,
|
|
112
|
-
listButton: listButton ?? false,
|
|
113
|
-
conditions: conditions || '',
|
|
114
|
-
clientScript: action.clientSide ? this.generateUIActionClientScript(action) : undefined,
|
|
115
|
-
serverScript: action.serverSide ? this.generateUIActionServerScript(action) : undefined
|
|
116
|
-
};
|
|
117
|
-
const commands = [
|
|
118
|
-
this.generateCommand('Bash', 'create', {
|
|
119
|
-
command: `mkdir -p /Users/nielsvanderwerf/Projects/servicenow_multiagent/output/ui_actions/${table}`,
|
|
120
|
-
description: `Create UI Actions directory for ${table}`
|
|
121
|
-
}, 'Create directory'),
|
|
122
|
-
this.generateCommand('Write', 'create', {
|
|
123
|
-
file_path: `/Users/nielsvanderwerf/Projects/servicenow_multiagent/output/ui_actions/${table}/${this.sanitizeName(name)}.js`,
|
|
124
|
-
content: this.combineUIActionScripts(uiAction)
|
|
125
|
-
}, `Create UI Action: ${name}`),
|
|
126
|
-
this.generateCommand('Write', 'create', {
|
|
127
|
-
file_path: `/Users/nielsvanderwerf/Projects/servicenow_multiagent/output/ui_actions/${table}/${this.sanitizeName(name)}.json`,
|
|
128
|
-
content: JSON.stringify({
|
|
129
|
-
...uiAction,
|
|
130
|
-
label: label || name,
|
|
131
|
-
order: action.order || 100,
|
|
132
|
-
active: true
|
|
133
|
-
}, null, 2)
|
|
134
|
-
}, 'Create UI Action metadata')
|
|
135
|
-
];
|
|
136
|
-
await this.storeInMemory(`ui_actions:${table}:${this.sanitizeName(name)}`, uiAction);
|
|
137
|
-
return {
|
|
138
|
-
taskId: task.id,
|
|
139
|
-
success: true,
|
|
140
|
-
output: uiAction,
|
|
141
|
-
artifacts: [
|
|
142
|
-
this.createArtifact('ui_action', name, uiAction, {
|
|
143
|
-
table,
|
|
144
|
-
type: action.clientSide ? 'client' : 'server'
|
|
145
|
-
})
|
|
146
|
-
],
|
|
147
|
-
commands
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
async generateUIFromSpec(task) {
|
|
151
|
-
const { spec, type } = task.payload;
|
|
152
|
-
let result;
|
|
153
|
-
switch (type) {
|
|
154
|
-
case 'dashboard':
|
|
155
|
-
result = await this.generateDashboard(spec);
|
|
156
|
-
break;
|
|
157
|
-
case 'form':
|
|
158
|
-
result = await this.generateForm(spec);
|
|
159
|
-
break;
|
|
160
|
-
case 'report':
|
|
161
|
-
result = await this.generateReport(spec);
|
|
162
|
-
break;
|
|
163
|
-
case 'wizard':
|
|
164
|
-
result = await this.generateWizard(spec);
|
|
165
|
-
break;
|
|
166
|
-
default:
|
|
167
|
-
result = await this.generateGenericUI(spec);
|
|
168
|
-
}
|
|
169
|
-
return {
|
|
170
|
-
...result,
|
|
171
|
-
taskId: task.id
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
async createFormLayout(task) {
|
|
175
|
-
const { formName, sections, fields, responsive } = task.payload;
|
|
176
|
-
const formHTML = this.generateFormHTML(sections, fields, responsive);
|
|
177
|
-
const formCSS = this.generateFormCSS(formName, responsive);
|
|
178
|
-
const formJS = this.generateFormJavaScript(fields);
|
|
179
|
-
const commands = [
|
|
180
|
-
this.generateCommand('Bash', 'create', {
|
|
181
|
-
command: `mkdir -p /Users/nielsvanderwerf/Projects/servicenow_multiagent/output/forms/${this.sanitizeName(formName)}`,
|
|
182
|
-
description: `Create form directory for ${formName}`
|
|
183
|
-
}, 'Create directory'),
|
|
184
|
-
this.generateCommand('Write', 'create', {
|
|
185
|
-
file_path: `/Users/nielsvanderwerf/Projects/servicenow_multiagent/output/forms/${this.sanitizeName(formName)}/form.html`,
|
|
186
|
-
content: formHTML
|
|
187
|
-
}, 'Create form HTML'),
|
|
188
|
-
this.generateCommand('Write', 'create', {
|
|
189
|
-
file_path: `/Users/nielsvanderwerf/Projects/servicenow_multiagent/output/forms/${this.sanitizeName(formName)}/styles.css`,
|
|
190
|
-
content: formCSS
|
|
191
|
-
}, 'Create form CSS'),
|
|
192
|
-
this.generateCommand('Write', 'create', {
|
|
193
|
-
file_path: `/Users/nielsvanderwerf/Projects/servicenow_multiagent/output/forms/${this.sanitizeName(formName)}/script.js`,
|
|
194
|
-
content: formJS
|
|
195
|
-
}, 'Create form JavaScript')
|
|
196
|
-
];
|
|
197
|
-
return {
|
|
198
|
-
taskId: task.id,
|
|
199
|
-
success: true,
|
|
200
|
-
output: {
|
|
201
|
-
html: formHTML,
|
|
202
|
-
css: formCSS,
|
|
203
|
-
javascript: formJS
|
|
204
|
-
},
|
|
205
|
-
artifacts: [
|
|
206
|
-
this.createArtifact('form_layout', formName, {
|
|
207
|
-
sections: sections.length,
|
|
208
|
-
fields: fields.length,
|
|
209
|
-
responsive
|
|
210
|
-
})
|
|
211
|
-
],
|
|
212
|
-
commands
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
async createUIComponents(task) {
|
|
216
|
-
const { components, theme } = task.payload;
|
|
217
|
-
const generatedComponents = components.map((comp) => ({
|
|
218
|
-
name: comp.name,
|
|
219
|
-
type: comp.type,
|
|
220
|
-
html: this.generateComponentHTML(comp),
|
|
221
|
-
css: this.generateComponentCSS(comp, theme),
|
|
222
|
-
javascript: this.generateComponentJS(comp)
|
|
223
|
-
}));
|
|
224
|
-
const commands = [];
|
|
225
|
-
generatedComponents.forEach((comp) => {
|
|
226
|
-
const compDir = `/Users/nielsvanderwerf/Projects/servicenow_multiagent/output/components/${this.sanitizeName(comp.name)}`;
|
|
227
|
-
commands.push(this.generateCommand('Bash', 'create', {
|
|
228
|
-
command: `mkdir -p ${compDir}`,
|
|
229
|
-
description: `Create component directory for ${comp.name}`
|
|
230
|
-
}, 'Create directory'), this.generateCommand('Write', 'create', {
|
|
231
|
-
file_path: `${compDir}/component.html`,
|
|
232
|
-
content: comp.html
|
|
233
|
-
}, `Create ${comp.name} HTML`), this.generateCommand('Write', 'create', {
|
|
234
|
-
file_path: `${compDir}/component.css`,
|
|
235
|
-
content: comp.css
|
|
236
|
-
}, `Create ${comp.name} CSS`), this.generateCommand('Write', 'create', {
|
|
237
|
-
file_path: `${compDir}/component.js`,
|
|
238
|
-
content: comp.javascript
|
|
239
|
-
}, `Create ${comp.name} JavaScript`));
|
|
240
|
-
});
|
|
241
|
-
return {
|
|
242
|
-
taskId: task.id,
|
|
243
|
-
success: true,
|
|
244
|
-
output: generatedComponents,
|
|
245
|
-
artifacts: generatedComponents.map((comp) => this.createArtifact('ui_component', comp.name, comp)),
|
|
246
|
-
commands
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
// Helper methods
|
|
250
|
-
generateUIPageHTML(name, layout, components) {
|
|
251
|
-
const layoutClass = layout?.type || 'standard';
|
|
252
|
-
return `<?xml version="1.0" encoding="utf-8" ?>
|
|
253
|
-
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
|
|
254
|
-
<g:requires name="styles/${this.sanitizeName(name)}.css" />
|
|
255
|
-
|
|
256
|
-
<div class="ui-page-container ${layoutClass}-layout">
|
|
257
|
-
<header class="ui-page-header">
|
|
258
|
-
<h1>${name}</h1>
|
|
259
|
-
</header>
|
|
260
|
-
|
|
261
|
-
<main class="ui-page-content">
|
|
262
|
-
${this.generateLayoutHTML(layout, components)}
|
|
263
|
-
</main>
|
|
264
|
-
|
|
265
|
-
<footer class="ui-page-footer">
|
|
266
|
-
<p>Generated by ServiceNow UI Builder</p>
|
|
267
|
-
</footer>
|
|
268
|
-
</div>
|
|
269
|
-
|
|
270
|
-
<script>
|
|
271
|
-
${this.generateUIPageClientScript(components)}
|
|
272
|
-
</script>
|
|
273
|
-
</j:jelly>`;
|
|
274
|
-
}
|
|
275
|
-
generateLayoutHTML(layout, components) {
|
|
276
|
-
if (!layout || !components) {
|
|
277
|
-
return '<div class="placeholder">Add your content here</div>';
|
|
278
|
-
}
|
|
279
|
-
switch (layout.type) {
|
|
280
|
-
case 'grid':
|
|
281
|
-
return this.generateGridLayout(layout, components);
|
|
282
|
-
case 'flex':
|
|
283
|
-
return this.generateFlexLayout(layout, components);
|
|
284
|
-
case 'tabs':
|
|
285
|
-
return this.generateTabsLayout(layout, components);
|
|
286
|
-
default:
|
|
287
|
-
return this.generateStandardLayout(components);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
generateGridLayout(layout, components) {
|
|
291
|
-
const columns = layout.columns || 3;
|
|
292
|
-
return `<div class="grid-container" style="grid-template-columns: repeat(${columns}, 1fr);">
|
|
293
|
-
${components.map((comp, index) => `
|
|
294
|
-
<div class="grid-item" data-component="${comp.type}">
|
|
295
|
-
${this.generateComponentHTML(comp)}
|
|
296
|
-
</div>
|
|
297
|
-
`).join('')}
|
|
298
|
-
</div>`;
|
|
299
|
-
}
|
|
300
|
-
generateFlexLayout(layout, components) {
|
|
301
|
-
return `<div class="flex-container" style="flex-direction: ${layout.direction || 'row'};">
|
|
302
|
-
${components.map(comp => `
|
|
303
|
-
<div class="flex-item" data-component="${comp.type}">
|
|
304
|
-
${this.generateComponentHTML(comp)}
|
|
305
|
-
</div>
|
|
306
|
-
`).join('')}
|
|
307
|
-
</div>`;
|
|
308
|
-
}
|
|
309
|
-
generateTabsLayout(layout, components) {
|
|
310
|
-
return `<div class="tabs-container">
|
|
311
|
-
<ul class="tab-headers">
|
|
312
|
-
${components.map((comp, index) => `
|
|
313
|
-
<li class="tab-header ${index === 0 ? 'active' : ''}" data-tab="${index}">
|
|
314
|
-
${comp.label || comp.name}
|
|
315
|
-
</li>
|
|
316
|
-
`).join('')}
|
|
317
|
-
</ul>
|
|
318
|
-
<div class="tab-contents">
|
|
319
|
-
${components.map((comp, index) => `
|
|
320
|
-
<div class="tab-content ${index === 0 ? 'active' : ''}" data-tab="${index}">
|
|
321
|
-
${this.generateComponentHTML(comp)}
|
|
322
|
-
</div>
|
|
323
|
-
`).join('')}
|
|
324
|
-
</div>
|
|
325
|
-
</div>`;
|
|
326
|
-
}
|
|
327
|
-
generateStandardLayout(components) {
|
|
328
|
-
return components.map(comp => `
|
|
329
|
-
<section class="ui-section">
|
|
330
|
-
${this.generateComponentHTML(comp)}
|
|
331
|
-
</section>
|
|
332
|
-
`).join('');
|
|
333
|
-
}
|
|
334
|
-
generateComponentHTML(component) {
|
|
335
|
-
switch (component.type) {
|
|
336
|
-
case 'chart':
|
|
337
|
-
return `<div class="chart-container" id="${component.id || 'chart'}">
|
|
338
|
-
<canvas id="${component.id}-canvas"></canvas>
|
|
339
|
-
</div>`;
|
|
340
|
-
case 'table':
|
|
341
|
-
return `<div class="table-container">
|
|
342
|
-
<table class="data-table" id="${component.id || 'table'}">
|
|
343
|
-
<thead>
|
|
344
|
-
<tr>${(component.columns || []).map((col) => `<th>${col.label}</th>`).join('')}</tr>
|
|
345
|
-
</thead>
|
|
346
|
-
<tbody>
|
|
347
|
-
<!-- Data will be loaded dynamically -->
|
|
348
|
-
</tbody>
|
|
349
|
-
</table>
|
|
350
|
-
</div>`;
|
|
351
|
-
case 'form':
|
|
352
|
-
return this.generateFormHTML(component.sections || [], component.fields || [], false);
|
|
353
|
-
case 'metric':
|
|
354
|
-
return `<div class="metric-widget">
|
|
355
|
-
<h3>${component.label}</h3>
|
|
356
|
-
<div class="metric-value" id="${component.id}-value">--</div>
|
|
357
|
-
<div class="metric-trend" id="${component.id}-trend"></div>
|
|
358
|
-
</div>`;
|
|
359
|
-
default:
|
|
360
|
-
return `<div class="custom-component" id="${component.id}">
|
|
361
|
-
${component.content || '<!-- Custom component -->'}
|
|
362
|
-
</div>`;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
generateProcessingScript(components) {
|
|
366
|
-
return `<%
|
|
367
|
-
// Server-side processing script
|
|
368
|
-
|
|
369
|
-
// Initialize response object
|
|
370
|
-
var response = {
|
|
371
|
-
success: true,
|
|
372
|
-
data: {}
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
try {
|
|
376
|
-
${components?.map(comp => this.generateComponentDataFetch(comp)).join('\n ') || '// Add data fetching logic'}
|
|
377
|
-
|
|
378
|
-
// Set response data
|
|
379
|
-
g_response.setContentType('application/json');
|
|
380
|
-
g_response.getWriter().write(JSON.stringify(response));
|
|
381
|
-
} catch (e) {
|
|
382
|
-
response.success = false;
|
|
383
|
-
response.error = e.message;
|
|
384
|
-
g_response.getWriter().write(JSON.stringify(response));
|
|
385
|
-
}
|
|
386
|
-
%>`;
|
|
387
|
-
}
|
|
388
|
-
generateComponentDataFetch(component) {
|
|
389
|
-
switch (component.type) {
|
|
390
|
-
case 'table':
|
|
391
|
-
return `// Fetch data for table: ${component.id}
|
|
392
|
-
var gr = new GlideRecord('${component.table || 'incident'}');
|
|
393
|
-
gr.setLimit(${component.limit || 100});
|
|
394
|
-
gr.query();
|
|
395
|
-
response.data.${component.id} = [];
|
|
396
|
-
while (gr.next()) {
|
|
397
|
-
response.data.${component.id}.push({
|
|
398
|
-
sys_id: gr.getUniqueValue(),
|
|
399
|
-
display_value: gr.getDisplayValue()
|
|
400
|
-
});
|
|
401
|
-
}`;
|
|
402
|
-
case 'metric':
|
|
403
|
-
return `// Calculate metric: ${component.id}
|
|
404
|
-
var count = new GlideAggregate('${component.table || 'incident'}');
|
|
405
|
-
count.addAggregate('COUNT');
|
|
406
|
-
count.query();
|
|
407
|
-
if (count.next()) {
|
|
408
|
-
response.data.${component.id} = count.getAggregate('COUNT');
|
|
409
|
-
}`;
|
|
410
|
-
default:
|
|
411
|
-
return `// Custom data fetch for ${component.id}`;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
generateUIPageClientScript(components) {
|
|
415
|
-
return `(function() {
|
|
416
|
-
// UI Page client-side script
|
|
417
|
-
|
|
418
|
-
document.addEventListener('DOMContentLoaded', function() {
|
|
419
|
-
initializePage();
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
function initializePage() {
|
|
423
|
-
${components?.map(comp => this.generateComponentInitialization(comp)).join('\n ') || '// Add initialization logic'}
|
|
424
|
-
|
|
425
|
-
// Setup event handlers
|
|
426
|
-
setupEventHandlers();
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
function setupEventHandlers() {
|
|
430
|
-
// Tab navigation
|
|
431
|
-
var tabHeaders = document.querySelectorAll('.tab-header');
|
|
432
|
-
tabHeaders.forEach(function(header) {
|
|
433
|
-
header.addEventListener('click', function() {
|
|
434
|
-
switchTab(this.getAttribute('data-tab'));
|
|
435
|
-
});
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
function switchTab(tabIndex) {
|
|
440
|
-
// Hide all tabs
|
|
441
|
-
document.querySelectorAll('.tab-content').forEach(function(content) {
|
|
442
|
-
content.classList.remove('active');
|
|
443
|
-
});
|
|
444
|
-
document.querySelectorAll('.tab-header').forEach(function(header) {
|
|
445
|
-
header.classList.remove('active');
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
// Show selected tab
|
|
449
|
-
document.querySelector('.tab-content[data-tab="' + tabIndex + '"]').classList.add('active');
|
|
450
|
-
document.querySelector('.tab-header[data-tab="' + tabIndex + '"]').classList.add('active');
|
|
451
|
-
}
|
|
452
|
-
})();`;
|
|
453
|
-
}
|
|
454
|
-
generateComponentInitialization(component) {
|
|
455
|
-
switch (component.type) {
|
|
456
|
-
case 'chart':
|
|
457
|
-
return `// Initialize chart: ${component.id}
|
|
458
|
-
initializeChart('${component.id}-canvas', ${JSON.stringify(component.config || {})});`;
|
|
459
|
-
case 'table':
|
|
460
|
-
return `// Initialize table: ${component.id}
|
|
461
|
-
loadTableData('${component.id}');`;
|
|
462
|
-
default:
|
|
463
|
-
return `// Initialize component: ${component.id}`;
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
generateUIPageCSS(name, layout) {
|
|
467
|
-
return `.ui-page-container {
|
|
468
|
-
max-width: 1200px;
|
|
469
|
-
margin: 0 auto;
|
|
470
|
-
padding: 20px;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
.ui-page-header {
|
|
474
|
-
margin-bottom: 30px;
|
|
475
|
-
padding-bottom: 20px;
|
|
476
|
-
border-bottom: 2px solid #e0e0e0;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
.ui-page-header h1 {
|
|
480
|
-
margin: 0;
|
|
481
|
-
color: #333;
|
|
482
|
-
font-size: 28px;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
.ui-page-content {
|
|
486
|
-
min-height: 400px;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
/* Grid Layout */
|
|
490
|
-
.grid-container {
|
|
491
|
-
display: grid;
|
|
492
|
-
gap: 20px;
|
|
493
|
-
margin-bottom: 20px;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
.grid-item {
|
|
497
|
-
background: #f9f9f9;
|
|
498
|
-
padding: 20px;
|
|
499
|
-
border-radius: 4px;
|
|
500
|
-
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
/* Flex Layout */
|
|
504
|
-
.flex-container {
|
|
505
|
-
display: flex;
|
|
506
|
-
gap: 20px;
|
|
507
|
-
flex-wrap: wrap;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
.flex-item {
|
|
511
|
-
flex: 1;
|
|
512
|
-
min-width: 300px;
|
|
513
|
-
background: #f9f9f9;
|
|
514
|
-
padding: 20px;
|
|
515
|
-
border-radius: 4px;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
/* Tabs Layout */
|
|
519
|
-
.tab-headers {
|
|
520
|
-
list-style: none;
|
|
521
|
-
padding: 0;
|
|
522
|
-
margin: 0;
|
|
523
|
-
display: flex;
|
|
524
|
-
border-bottom: 2px solid #ddd;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
.tab-header {
|
|
528
|
-
padding: 10px 20px;
|
|
529
|
-
cursor: pointer;
|
|
530
|
-
border-bottom: 2px solid transparent;
|
|
531
|
-
transition: all 0.3s;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
.tab-header:hover {
|
|
535
|
-
background: #f0f0f0;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
.tab-header.active {
|
|
539
|
-
border-bottom-color: #0078d4;
|
|
540
|
-
color: #0078d4;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
.tab-content {
|
|
544
|
-
display: none;
|
|
545
|
-
padding: 20px 0;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
.tab-content.active {
|
|
549
|
-
display: block;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
/* Components */
|
|
553
|
-
.chart-container {
|
|
554
|
-
position: relative;
|
|
555
|
-
height: 400px;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
.data-table {
|
|
559
|
-
width: 100%;
|
|
560
|
-
border-collapse: collapse;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
.data-table th,
|
|
564
|
-
.data-table td {
|
|
565
|
-
padding: 10px;
|
|
566
|
-
text-align: left;
|
|
567
|
-
border-bottom: 1px solid #ddd;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
.data-table th {
|
|
571
|
-
background: #f5f5f5;
|
|
572
|
-
font-weight: bold;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
.metric-widget {
|
|
576
|
-
text-align: center;
|
|
577
|
-
padding: 20px;
|
|
578
|
-
background: #fff;
|
|
579
|
-
border-radius: 8px;
|
|
580
|
-
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
.metric-value {
|
|
584
|
-
font-size: 48px;
|
|
585
|
-
font-weight: bold;
|
|
586
|
-
color: #0078d4;
|
|
587
|
-
margin: 20px 0;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
.ui-page-footer {
|
|
591
|
-
margin-top: 40px;
|
|
592
|
-
padding-top: 20px;
|
|
593
|
-
border-top: 1px solid #e0e0e0;
|
|
594
|
-
text-align: center;
|
|
595
|
-
color: #666;
|
|
596
|
-
}`;
|
|
597
|
-
}
|
|
598
|
-
generateUIActionClientScript(action) {
|
|
599
|
-
const confirmMessage = action.confirmMessage || 'Are you sure you want to perform this action?';
|
|
600
|
-
return `function ${this.sanitizeName(action.name)}() {
|
|
601
|
-
// Client-side UI Action
|
|
602
|
-
|
|
603
|
-
if (!confirm('${confirmMessage}')) {
|
|
604
|
-
return false;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
// Show loading indicator
|
|
608
|
-
g_form.showLoadingMessage('Processing...');
|
|
609
|
-
|
|
610
|
-
// Prepare data
|
|
611
|
-
var data = {
|
|
612
|
-
sys_id: g_form.getUniqueValue(),
|
|
613
|
-
table: '${action.table || 'current'}',
|
|
614
|
-
${action.parameters?.map((p) => `${p.name}: g_form.getValue('${p.field}')`).join(',\n ') || ''}
|
|
615
|
-
};
|
|
616
|
-
|
|
617
|
-
// Make AJAX call to server
|
|
618
|
-
var ga = new GlideAjax('${action.ajaxProcessor || 'UIActionProcessor'}');
|
|
619
|
-
ga.addParam('sysparm_name', '${action.name}');
|
|
620
|
-
ga.addParam('sysparm_data', JSON.stringify(data));
|
|
621
|
-
|
|
622
|
-
ga.getXMLAnswer(function(response) {
|
|
623
|
-
g_form.hideLoadingMessage();
|
|
624
|
-
|
|
625
|
-
try {
|
|
626
|
-
var result = JSON.parse(response);
|
|
627
|
-
if (result.success) {
|
|
628
|
-
g_form.addInfoMessage(result.message || 'Action completed successfully');
|
|
629
|
-
${action.refresh ? 'g_form.reload();' : ''}
|
|
630
|
-
} else {
|
|
631
|
-
g_form.addErrorMessage(result.error || 'Action failed');
|
|
632
|
-
}
|
|
633
|
-
} catch (e) {
|
|
634
|
-
g_form.addErrorMessage('Error processing response');
|
|
635
|
-
}
|
|
636
|
-
});
|
|
637
|
-
|
|
638
|
-
return false; // Prevent default form submission
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
// Execute the action
|
|
642
|
-
${this.sanitizeName(action.name)}();`;
|
|
643
|
-
}
|
|
644
|
-
generateUIActionServerScript(action) {
|
|
645
|
-
return `// Server-side UI Action
|
|
646
|
-
(function() {
|
|
647
|
-
try {
|
|
648
|
-
${this.generateServerActionLogic(action)}
|
|
649
|
-
|
|
650
|
-
// Set success message
|
|
651
|
-
gs.addInfoMessage('${action.successMessage || 'Action completed successfully'}');
|
|
652
|
-
|
|
653
|
-
// Redirect if specified
|
|
654
|
-
${action.redirect ? `action.setRedirectURL('${action.redirect}');` : '// No redirect'}
|
|
655
|
-
|
|
656
|
-
} catch (e) {
|
|
657
|
-
gs.addErrorMessage('Error: ' + e.message);
|
|
658
|
-
action.setRedirectURL(current);
|
|
659
|
-
}
|
|
660
|
-
})();`;
|
|
661
|
-
}
|
|
662
|
-
generateServerActionLogic(action) {
|
|
663
|
-
switch (action.type) {
|
|
664
|
-
case 'create_related':
|
|
665
|
-
return `// Create related record
|
|
666
|
-
var gr = new GlideRecord('${action.targetTable}');
|
|
667
|
-
gr.initialize();
|
|
668
|
-
${action.fieldMappings?.map((m) => `gr.${m.target} = current.${m.source};`).join('\n ') || ''}
|
|
669
|
-
gr.insert();`;
|
|
670
|
-
case 'update_field':
|
|
671
|
-
return `// Update field
|
|
672
|
-
current.${action.field} = '${action.value}';
|
|
673
|
-
current.update();`;
|
|
674
|
-
case 'execute_flow':
|
|
675
|
-
return `// Execute flow
|
|
676
|
-
sn_fd.FlowAPI.startFlow('${action.flowId}', {
|
|
677
|
-
table: current.getTableName(),
|
|
678
|
-
sys_id: current.getUniqueValue()
|
|
679
|
-
});`;
|
|
680
|
-
default:
|
|
681
|
-
return '// Custom action logic\n ' + (action.customCode || '// Add implementation');
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
combineUIActionScripts(uiAction) {
|
|
685
|
-
let combined = '// UI Action: ' + uiAction.name + '\n\n';
|
|
686
|
-
if (uiAction.clientScript) {
|
|
687
|
-
combined += '// CLIENT SCRIPT\n' + uiAction.clientScript + '\n\n';
|
|
688
|
-
}
|
|
689
|
-
if (uiAction.serverScript) {
|
|
690
|
-
combined += '// SERVER SCRIPT\n' + uiAction.serverScript;
|
|
691
|
-
}
|
|
692
|
-
return combined;
|
|
693
|
-
}
|
|
694
|
-
generateFormHTML(sections, fields, responsive) {
|
|
695
|
-
const formClass = responsive ? 'responsive-form' : 'standard-form';
|
|
696
|
-
return `<form class="${formClass}" id="custom-form">
|
|
697
|
-
${sections.map(section => `
|
|
698
|
-
<fieldset class="form-section">
|
|
699
|
-
<legend>${section.title}</legend>
|
|
700
|
-
<div class="form-fields">
|
|
701
|
-
${fields
|
|
702
|
-
.filter(field => field.section === section.id)
|
|
703
|
-
.map(field => this.generateFieldHTML(field))
|
|
704
|
-
.join('')}
|
|
705
|
-
</div>
|
|
706
|
-
</fieldset>
|
|
707
|
-
`).join('')}
|
|
708
|
-
|
|
709
|
-
<div class="form-actions">
|
|
710
|
-
<button type="submit" class="btn btn-primary">Submit</button>
|
|
711
|
-
<button type="button" class="btn btn-secondary" onclick="resetForm()">Reset</button>
|
|
712
|
-
</div>
|
|
713
|
-
</form>`;
|
|
714
|
-
}
|
|
715
|
-
generateFieldHTML(field) {
|
|
716
|
-
const required = field.required ? 'required' : '';
|
|
717
|
-
switch (field.type) {
|
|
718
|
-
case 'text':
|
|
719
|
-
case 'email':
|
|
720
|
-
case 'number':
|
|
721
|
-
return `<div class="form-field">
|
|
722
|
-
<label for="${field.id}">${field.label}</label>
|
|
723
|
-
<input type="${field.type}" id="${field.id}" name="${field.name}" ${required} />
|
|
724
|
-
</div>`;
|
|
725
|
-
case 'textarea':
|
|
726
|
-
return `<div class="form-field">
|
|
727
|
-
<label for="${field.id}">${field.label}</label>
|
|
728
|
-
<textarea id="${field.id}" name="${field.name}" rows="4" ${required}></textarea>
|
|
729
|
-
</div>`;
|
|
730
|
-
case 'select':
|
|
731
|
-
return `<div class="form-field">
|
|
732
|
-
<label for="${field.id}">${field.label}</label>
|
|
733
|
-
<select id="${field.id}" name="${field.name}" ${required}>
|
|
734
|
-
<option value="">-- Select --</option>
|
|
735
|
-
${field.options?.map((opt) => `<option value="${opt.value}">${opt.label}</option>`).join('')}
|
|
736
|
-
</select>
|
|
737
|
-
</div>`;
|
|
738
|
-
case 'checkbox':
|
|
739
|
-
return `<div class="form-field checkbox-field">
|
|
740
|
-
<input type="checkbox" id="${field.id}" name="${field.name}" />
|
|
741
|
-
<label for="${field.id}">${field.label}</label>
|
|
742
|
-
</div>`;
|
|
743
|
-
case 'reference':
|
|
744
|
-
return `<div class="form-field">
|
|
745
|
-
<label for="${field.id}">${field.label}</label>
|
|
746
|
-
<input type="text" id="${field.id}" name="${field.name}"
|
|
747
|
-
data-reference="${field.reference}" ${required} />
|
|
748
|
-
<button type="button" class="reference-lookup" onclick="lookupReference('${field.id}')">
|
|
749
|
-
🔍
|
|
750
|
-
</button>
|
|
751
|
-
</div>`;
|
|
752
|
-
default:
|
|
753
|
-
return `<div class="form-field">
|
|
754
|
-
<label for="${field.id}">${field.label}</label>
|
|
755
|
-
<input type="text" id="${field.id}" name="${field.name}" ${required} />
|
|
756
|
-
</div>`;
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
generateFormCSS(formName, responsive) {
|
|
760
|
-
return `.${responsive ? 'responsive-form' : 'standard-form'} {
|
|
761
|
-
max-width: ${responsive ? '100%' : '800px'};
|
|
762
|
-
margin: 0 auto;
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
.form-section {
|
|
766
|
-
margin-bottom: 30px;
|
|
767
|
-
padding: 20px;
|
|
768
|
-
border: 1px solid #e0e0e0;
|
|
769
|
-
border-radius: 4px;
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
.form-section legend {
|
|
773
|
-
font-weight: bold;
|
|
774
|
-
color: #333;
|
|
775
|
-
padding: 0 10px;
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
.form-fields {
|
|
779
|
-
display: ${responsive ? 'grid' : 'block'};
|
|
780
|
-
${responsive ? 'grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));' : ''}
|
|
781
|
-
gap: 20px;
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
.form-field {
|
|
785
|
-
margin-bottom: 20px;
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
.form-field label {
|
|
789
|
-
display: block;
|
|
790
|
-
margin-bottom: 5px;
|
|
791
|
-
font-weight: 600;
|
|
792
|
-
color: #555;
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
.form-field input,
|
|
796
|
-
.form-field textarea,
|
|
797
|
-
.form-field select {
|
|
798
|
-
width: 100%;
|
|
799
|
-
padding: 8px 12px;
|
|
800
|
-
border: 1px solid #ddd;
|
|
801
|
-
border-radius: 4px;
|
|
802
|
-
font-size: 14px;
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
.form-field input:focus,
|
|
806
|
-
.form-field textarea:focus,
|
|
807
|
-
.form-field select:focus {
|
|
808
|
-
outline: none;
|
|
809
|
-
border-color: #0078d4;
|
|
810
|
-
box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.2);
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
.checkbox-field {
|
|
814
|
-
display: flex;
|
|
815
|
-
align-items: center;
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
.checkbox-field input {
|
|
819
|
-
width: auto;
|
|
820
|
-
margin-right: 8px;
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
.reference-lookup {
|
|
824
|
-
display: inline-block;
|
|
825
|
-
margin-left: 8px;
|
|
826
|
-
padding: 6px 10px;
|
|
827
|
-
border: 1px solid #ddd;
|
|
828
|
-
background: #f5f5f5;
|
|
829
|
-
cursor: pointer;
|
|
830
|
-
border-radius: 4px;
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
.form-actions {
|
|
834
|
-
margin-top: 30px;
|
|
835
|
-
text-align: center;
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
.btn {
|
|
839
|
-
padding: 10px 20px;
|
|
840
|
-
margin: 0 5px;
|
|
841
|
-
border: none;
|
|
842
|
-
border-radius: 4px;
|
|
843
|
-
font-size: 16px;
|
|
844
|
-
cursor: pointer;
|
|
845
|
-
transition: background-color 0.3s;
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
.btn-primary {
|
|
849
|
-
background: #0078d4;
|
|
850
|
-
color: white;
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
.btn-primary:hover {
|
|
854
|
-
background: #005a9e;
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
.btn-secondary {
|
|
858
|
-
background: #e0e0e0;
|
|
859
|
-
color: #333;
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
.btn-secondary:hover {
|
|
863
|
-
background: #d0d0d0;
|
|
864
|
-
}`;
|
|
865
|
-
}
|
|
866
|
-
generateFormJavaScript(fields) {
|
|
867
|
-
return `// Form JavaScript
|
|
868
|
-
document.addEventListener('DOMContentLoaded', function() {
|
|
869
|
-
initializeForm();
|
|
870
|
-
});
|
|
871
|
-
|
|
872
|
-
function initializeForm() {
|
|
873
|
-
// Setup form validation
|
|
874
|
-
var form = document.getElementById('custom-form');
|
|
875
|
-
form.addEventListener('submit', handleSubmit);
|
|
876
|
-
|
|
877
|
-
// Initialize reference fields
|
|
878
|
-
${fields.filter(f => f.type === 'reference').map(field => `
|
|
879
|
-
initializeReferenceField('${field.id}', '${field.reference}');`).join('')}
|
|
880
|
-
|
|
881
|
-
// Setup field dependencies
|
|
882
|
-
setupFieldDependencies();
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
function handleSubmit(event) {
|
|
886
|
-
event.preventDefault();
|
|
887
|
-
|
|
888
|
-
if (!validateForm()) {
|
|
889
|
-
return false;
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
// Collect form data
|
|
893
|
-
var formData = new FormData(event.target);
|
|
894
|
-
var data = {};
|
|
895
|
-
|
|
896
|
-
for (var [key, value] of formData.entries()) {
|
|
897
|
-
data[key] = value;
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
// Submit form via AJAX
|
|
901
|
-
submitForm(data);
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
function validateForm() {
|
|
905
|
-
var isValid = true;
|
|
906
|
-
var errors = [];
|
|
907
|
-
|
|
908
|
-
// Validate required fields
|
|
909
|
-
document.querySelectorAll('[required]').forEach(function(field) {
|
|
910
|
-
if (!field.value.trim()) {
|
|
911
|
-
errors.push(field.previousElementSibling.textContent + ' is required');
|
|
912
|
-
isValid = false;
|
|
913
|
-
}
|
|
914
|
-
});
|
|
915
|
-
|
|
916
|
-
// Custom validations
|
|
917
|
-
${fields.filter(f => f.validation).map(field => `
|
|
918
|
-
if (!validate${field.name}()) {
|
|
919
|
-
errors.push('${field.validationMessage || 'Invalid ' + field.label}');
|
|
920
|
-
isValid = false;
|
|
921
|
-
}`).join('')}
|
|
922
|
-
|
|
923
|
-
if (!isValid) {
|
|
924
|
-
showErrors(errors);
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
return isValid;
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
function submitForm(data) {
|
|
931
|
-
// Show loading
|
|
932
|
-
showLoading();
|
|
933
|
-
|
|
934
|
-
// Make AJAX request
|
|
935
|
-
var xhr = new XMLHttpRequest();
|
|
936
|
-
xhr.open('POST', '/api/form/submit', true);
|
|
937
|
-
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
938
|
-
|
|
939
|
-
xhr.onload = function() {
|
|
940
|
-
hideLoading();
|
|
941
|
-
|
|
942
|
-
if (xhr.status === 200) {
|
|
943
|
-
var response = JSON.parse(xhr.responseText);
|
|
944
|
-
if (response.success) {
|
|
945
|
-
showSuccess('Form submitted successfully');
|
|
946
|
-
resetForm();
|
|
947
|
-
} else {
|
|
948
|
-
showError(response.error || 'Submission failed');
|
|
949
|
-
}
|
|
950
|
-
} else {
|
|
951
|
-
showError('Server error occurred');
|
|
952
|
-
}
|
|
953
|
-
};
|
|
954
|
-
|
|
955
|
-
xhr.send(JSON.stringify(data));
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
function resetForm() {
|
|
959
|
-
document.getElementById('custom-form').reset();
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
function lookupReference(fieldId) {
|
|
963
|
-
// Open reference lookup dialog
|
|
964
|
-
var field = document.getElementById(fieldId);
|
|
965
|
-
var table = field.getAttribute('data-reference');
|
|
966
|
-
|
|
967
|
-
// Implement reference lookup logic
|
|
968
|
-
console.log('Opening reference lookup for', table);
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
function initializeReferenceField(fieldId, table) {
|
|
972
|
-
// Setup autocomplete for reference field
|
|
973
|
-
var field = document.getElementById(fieldId);
|
|
974
|
-
|
|
975
|
-
// Add autocomplete functionality
|
|
976
|
-
// This would integrate with ServiceNow's reference field behavior
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
function setupFieldDependencies() {
|
|
980
|
-
// Setup any field dependencies or conditional display logic
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
function showLoading() {
|
|
984
|
-
// Show loading indicator
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
function hideLoading() {
|
|
988
|
-
// Hide loading indicator
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
function showSuccess(message) {
|
|
992
|
-
alert('Success: ' + message);
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
function showError(message) {
|
|
996
|
-
alert('Error: ' + message);
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
function showErrors(errors) {
|
|
1000
|
-
alert('Please fix the following errors:\\n\\n' + errors.join('\\n'));
|
|
1001
|
-
}`;
|
|
1002
|
-
}
|
|
1003
|
-
generateComponentCSS(component, theme) {
|
|
1004
|
-
const primaryColor = theme?.primaryColor || '#0078d4';
|
|
1005
|
-
const secondaryColor = theme?.secondaryColor || '#e0e0e0';
|
|
1006
|
-
return `.component-${this.sanitizeName(component.name)} {
|
|
1007
|
-
padding: 20px;
|
|
1008
|
-
background: ${theme?.background || '#fff'};
|
|
1009
|
-
border: 1px solid ${secondaryColor};
|
|
1010
|
-
border-radius: 4px;
|
|
1011
|
-
margin-bottom: 20px;
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
.component-${this.sanitizeName(component.name)} h3 {
|
|
1015
|
-
color: ${primaryColor};
|
|
1016
|
-
margin-bottom: 15px;
|
|
1017
|
-
}`;
|
|
1018
|
-
}
|
|
1019
|
-
generateComponentJS(component) {
|
|
1020
|
-
return `// Component: ${component.name}
|
|
1021
|
-
(function() {
|
|
1022
|
-
var component = {
|
|
1023
|
-
init: function() {
|
|
1024
|
-
console.log('Initializing ${component.name}');
|
|
1025
|
-
${component.initialization || '// Add initialization code'}
|
|
1026
|
-
},
|
|
1027
|
-
|
|
1028
|
-
refresh: function() {
|
|
1029
|
-
${component.refreshCode || '// Add refresh logic'}
|
|
1030
|
-
},
|
|
1031
|
-
|
|
1032
|
-
destroy: function() {
|
|
1033
|
-
${component.cleanupCode || '// Add cleanup code'}
|
|
1034
|
-
}
|
|
1035
|
-
};
|
|
1036
|
-
|
|
1037
|
-
// Auto-initialize if DOM is ready
|
|
1038
|
-
if (document.readyState === 'loading') {
|
|
1039
|
-
document.addEventListener('DOMContentLoaded', component.init);
|
|
1040
|
-
} else {
|
|
1041
|
-
component.init();
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
// Export for external use
|
|
1045
|
-
window['${this.sanitizeName(component.name)}Component'] = component;
|
|
1046
|
-
})();`;
|
|
1047
|
-
}
|
|
1048
|
-
async generateDashboard(spec) {
|
|
1049
|
-
// Generate dashboard UI
|
|
1050
|
-
const dashboardHTML = this.generateDashboardHTML(spec);
|
|
1051
|
-
const dashboardCSS = this.generateDashboardCSS(spec);
|
|
1052
|
-
const dashboardJS = this.generateDashboardJS(spec);
|
|
1053
|
-
return {
|
|
1054
|
-
taskId: '',
|
|
1055
|
-
success: true,
|
|
1056
|
-
output: {
|
|
1057
|
-
html: dashboardHTML,
|
|
1058
|
-
css: dashboardCSS,
|
|
1059
|
-
javascript: dashboardJS
|
|
1060
|
-
},
|
|
1061
|
-
artifacts: [
|
|
1062
|
-
this.createArtifact('dashboard', spec.name, {
|
|
1063
|
-
html: dashboardHTML,
|
|
1064
|
-
css: dashboardCSS,
|
|
1065
|
-
javascript: dashboardJS
|
|
1066
|
-
})
|
|
1067
|
-
]
|
|
1068
|
-
};
|
|
1069
|
-
}
|
|
1070
|
-
generateDashboardHTML(spec) {
|
|
1071
|
-
return `<div class="dashboard-container">
|
|
1072
|
-
<header class="dashboard-header">
|
|
1073
|
-
<h1>${spec.title || 'Dashboard'}</h1>
|
|
1074
|
-
<div class="dashboard-controls">
|
|
1075
|
-
<button onclick="refreshDashboard()">Refresh</button>
|
|
1076
|
-
</div>
|
|
1077
|
-
</header>
|
|
1078
|
-
|
|
1079
|
-
<div class="dashboard-grid">
|
|
1080
|
-
${spec.widgets?.map((widget) => `
|
|
1081
|
-
<div class="dashboard-widget ${widget.size || 'medium'}" id="widget-${widget.id}">
|
|
1082
|
-
${this.generateWidgetHTML(widget)}
|
|
1083
|
-
</div>
|
|
1084
|
-
`).join('') || ''}
|
|
1085
|
-
</div>
|
|
1086
|
-
</div>`;
|
|
1087
|
-
}
|
|
1088
|
-
generateWidgetHTML(widget) {
|
|
1089
|
-
switch (widget.type) {
|
|
1090
|
-
case 'metric':
|
|
1091
|
-
return `<div class="metric-widget">
|
|
1092
|
-
<h3>${widget.title}</h3>
|
|
1093
|
-
<div class="metric-value">${widget.value || '--'}</div>
|
|
1094
|
-
<div class="metric-change">${widget.change || ''}</div>
|
|
1095
|
-
</div>`;
|
|
1096
|
-
case 'chart':
|
|
1097
|
-
return `<div class="chart-widget">
|
|
1098
|
-
<h3>${widget.title}</h3>
|
|
1099
|
-
<canvas id="chart-${widget.id}"></canvas>
|
|
1100
|
-
</div>`;
|
|
1101
|
-
case 'list':
|
|
1102
|
-
return `<div class="list-widget">
|
|
1103
|
-
<h3>${widget.title}</h3>
|
|
1104
|
-
<ul class="widget-list">
|
|
1105
|
-
<!-- Items will be loaded dynamically -->
|
|
1106
|
-
</ul>
|
|
1107
|
-
</div>`;
|
|
1108
|
-
default:
|
|
1109
|
-
return `<div class="custom-widget">
|
|
1110
|
-
<h3>${widget.title}</h3>
|
|
1111
|
-
<div class="widget-content">
|
|
1112
|
-
<!-- Custom content -->
|
|
1113
|
-
</div>
|
|
1114
|
-
</div>`;
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
generateDashboardCSS(spec) {
|
|
1118
|
-
return `.dashboard-container {
|
|
1119
|
-
padding: 20px;
|
|
1120
|
-
background: #f5f5f5;
|
|
1121
|
-
min-height: 100vh;
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
.dashboard-header {
|
|
1125
|
-
display: flex;
|
|
1126
|
-
justify-content: space-between;
|
|
1127
|
-
align-items: center;
|
|
1128
|
-
margin-bottom: 30px;
|
|
1129
|
-
padding: 20px;
|
|
1130
|
-
background: white;
|
|
1131
|
-
border-radius: 8px;
|
|
1132
|
-
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
.dashboard-grid {
|
|
1136
|
-
display: grid;
|
|
1137
|
-
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
|
1138
|
-
gap: 20px;
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
.dashboard-widget {
|
|
1142
|
-
background: white;
|
|
1143
|
-
padding: 20px;
|
|
1144
|
-
border-radius: 8px;
|
|
1145
|
-
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
.dashboard-widget.small {
|
|
1149
|
-
grid-column: span 1;
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
.dashboard-widget.medium {
|
|
1153
|
-
grid-column: span 2;
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
.dashboard-widget.large {
|
|
1157
|
-
grid-column: span 3;
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
.metric-widget {
|
|
1161
|
-
text-align: center;
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
.metric-value {
|
|
1165
|
-
font-size: 48px;
|
|
1166
|
-
font-weight: bold;
|
|
1167
|
-
color: #0078d4;
|
|
1168
|
-
margin: 20px 0;
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
.metric-change {
|
|
1172
|
-
color: #666;
|
|
1173
|
-
font-size: 14px;
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
.chart-widget canvas {
|
|
1177
|
-
max-width: 100%;
|
|
1178
|
-
height: 300px;
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
.list-widget .widget-list {
|
|
1182
|
-
list-style: none;
|
|
1183
|
-
padding: 0;
|
|
1184
|
-
margin: 0;
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
.list-widget .widget-list li {
|
|
1188
|
-
padding: 10px;
|
|
1189
|
-
border-bottom: 1px solid #e0e0e0;
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
.list-widget .widget-list li:last-child {
|
|
1193
|
-
border-bottom: none;
|
|
1194
|
-
}`;
|
|
1195
|
-
}
|
|
1196
|
-
generateDashboardJS(spec) {
|
|
1197
|
-
return `// Dashboard JavaScript
|
|
1198
|
-
var dashboard = {
|
|
1199
|
-
widgets: {},
|
|
1200
|
-
refreshInterval: ${spec.refreshInterval || 30000},
|
|
1201
|
-
|
|
1202
|
-
init: function() {
|
|
1203
|
-
console.log('Initializing dashboard');
|
|
1204
|
-
this.loadWidgets();
|
|
1205
|
-
this.startAutoRefresh();
|
|
1206
|
-
},
|
|
1207
|
-
|
|
1208
|
-
loadWidgets: function() {
|
|
1209
|
-
${spec.widgets?.map((widget) => `
|
|
1210
|
-
this.loadWidget('${widget.id}', ${JSON.stringify(widget)});`).join('')}
|
|
1211
|
-
},
|
|
1212
|
-
|
|
1213
|
-
loadWidget: function(widgetId, config) {
|
|
1214
|
-
console.log('Loading widget:', widgetId);
|
|
1215
|
-
|
|
1216
|
-
switch (config.type) {
|
|
1217
|
-
case 'metric':
|
|
1218
|
-
this.loadMetricWidget(widgetId, config);
|
|
1219
|
-
break;
|
|
1220
|
-
case 'chart':
|
|
1221
|
-
this.loadChartWidget(widgetId, config);
|
|
1222
|
-
break;
|
|
1223
|
-
case 'list':
|
|
1224
|
-
this.loadListWidget(widgetId, config);
|
|
1225
|
-
break;
|
|
1226
|
-
}
|
|
1227
|
-
},
|
|
1228
|
-
|
|
1229
|
-
loadMetricWidget: function(widgetId, config) {
|
|
1230
|
-
// Fetch metric data
|
|
1231
|
-
fetch('/api/metrics/' + config.metric)
|
|
1232
|
-
.then(response => response.json())
|
|
1233
|
-
.then(data => {
|
|
1234
|
-
var widget = document.getElementById('widget-' + widgetId);
|
|
1235
|
-
widget.querySelector('.metric-value').textContent = data.value;
|
|
1236
|
-
widget.querySelector('.metric-change').textContent = data.change;
|
|
1237
|
-
});
|
|
1238
|
-
},
|
|
1239
|
-
|
|
1240
|
-
loadChartWidget: function(widgetId, config) {
|
|
1241
|
-
// Initialize chart
|
|
1242
|
-
var ctx = document.getElementById('chart-' + widgetId).getContext('2d');
|
|
1243
|
-
// Chart.js initialization would go here
|
|
1244
|
-
},
|
|
1245
|
-
|
|
1246
|
-
loadListWidget: function(widgetId, config) {
|
|
1247
|
-
// Fetch list data
|
|
1248
|
-
fetch('/api/list/' + config.source)
|
|
1249
|
-
.then(response => response.json())
|
|
1250
|
-
.then(data => {
|
|
1251
|
-
var list = document.querySelector('#widget-' + widgetId + ' .widget-list');
|
|
1252
|
-
list.innerHTML = data.items.map(item =>
|
|
1253
|
-
'<li>' + item.display_value + '</li>'
|
|
1254
|
-
).join('');
|
|
1255
|
-
});
|
|
1256
|
-
},
|
|
1257
|
-
|
|
1258
|
-
refresh: function() {
|
|
1259
|
-
console.log('Refreshing dashboard');
|
|
1260
|
-
this.loadWidgets();
|
|
1261
|
-
},
|
|
1262
|
-
|
|
1263
|
-
startAutoRefresh: function() {
|
|
1264
|
-
var self = this;
|
|
1265
|
-
setInterval(function() {
|
|
1266
|
-
self.refresh();
|
|
1267
|
-
}, this.refreshInterval);
|
|
1268
|
-
}
|
|
1269
|
-
};
|
|
1270
|
-
|
|
1271
|
-
// Initialize on load
|
|
1272
|
-
document.addEventListener('DOMContentLoaded', function() {
|
|
1273
|
-
dashboard.init();
|
|
1274
|
-
});
|
|
1275
|
-
|
|
1276
|
-
function refreshDashboard() {
|
|
1277
|
-
dashboard.refresh();
|
|
1278
|
-
}`;
|
|
1279
|
-
}
|
|
1280
|
-
async generateForm(spec) {
|
|
1281
|
-
return this.createFormLayout({
|
|
1282
|
-
id: '',
|
|
1283
|
-
type: 'create_form_layout',
|
|
1284
|
-
description: 'Generate form from spec',
|
|
1285
|
-
payload: {
|
|
1286
|
-
formName: spec.name,
|
|
1287
|
-
sections: spec.sections || [{ id: 'main', title: 'Main Section' }],
|
|
1288
|
-
fields: spec.fields || [],
|
|
1289
|
-
responsive: spec.responsive !== false
|
|
1290
|
-
},
|
|
1291
|
-
priority: 'medium'
|
|
1292
|
-
});
|
|
1293
|
-
}
|
|
1294
|
-
async generateReport(spec) {
|
|
1295
|
-
// Generate report UI
|
|
1296
|
-
const reportHTML = `<div class="report-container">
|
|
1297
|
-
<h1>${spec.title}</h1>
|
|
1298
|
-
<div class="report-filters">
|
|
1299
|
-
<!-- Filters will be added here -->
|
|
1300
|
-
</div>
|
|
1301
|
-
<div class="report-content">
|
|
1302
|
-
<!-- Report content will be loaded here -->
|
|
1303
|
-
</div>
|
|
1304
|
-
</div>`;
|
|
1305
|
-
return {
|
|
1306
|
-
taskId: '',
|
|
1307
|
-
success: true,
|
|
1308
|
-
output: { html: reportHTML },
|
|
1309
|
-
artifacts: [
|
|
1310
|
-
this.createArtifact('report', spec.name, { html: reportHTML })
|
|
1311
|
-
]
|
|
1312
|
-
};
|
|
1313
|
-
}
|
|
1314
|
-
async generateWizard(spec) {
|
|
1315
|
-
// Generate wizard UI
|
|
1316
|
-
const wizardHTML = this.generateWizardHTML(spec);
|
|
1317
|
-
const wizardCSS = this.generateWizardCSS();
|
|
1318
|
-
const wizardJS = this.generateWizardJS(spec);
|
|
1319
|
-
return {
|
|
1320
|
-
taskId: '',
|
|
1321
|
-
success: true,
|
|
1322
|
-
output: {
|
|
1323
|
-
html: wizardHTML,
|
|
1324
|
-
css: wizardCSS,
|
|
1325
|
-
javascript: wizardJS
|
|
1326
|
-
},
|
|
1327
|
-
artifacts: [
|
|
1328
|
-
this.createArtifact('wizard', spec.name, {
|
|
1329
|
-
html: wizardHTML,
|
|
1330
|
-
css: wizardCSS,
|
|
1331
|
-
javascript: wizardJS
|
|
1332
|
-
})
|
|
1333
|
-
]
|
|
1334
|
-
};
|
|
1335
|
-
}
|
|
1336
|
-
generateWizardHTML(spec) {
|
|
1337
|
-
return `<div class="wizard-container">
|
|
1338
|
-
<div class="wizard-progress">
|
|
1339
|
-
${spec.steps?.map((step, index) => `
|
|
1340
|
-
<div class="wizard-step ${index === 0 ? 'active' : ''}" data-step="${index}">
|
|
1341
|
-
<div class="step-number">${index + 1}</div>
|
|
1342
|
-
<div class="step-title">${step.title}</div>
|
|
1343
|
-
</div>
|
|
1344
|
-
`).join('') || ''}
|
|
1345
|
-
</div>
|
|
1346
|
-
|
|
1347
|
-
<div class="wizard-content">
|
|
1348
|
-
${spec.steps?.map((step, index) => `
|
|
1349
|
-
<div class="wizard-panel ${index === 0 ? 'active' : ''}" data-step="${index}">
|
|
1350
|
-
<h2>${step.title}</h2>
|
|
1351
|
-
${step.content || '<!-- Step content -->'}
|
|
1352
|
-
</div>
|
|
1353
|
-
`).join('') || ''}
|
|
1354
|
-
</div>
|
|
1355
|
-
|
|
1356
|
-
<div class="wizard-actions">
|
|
1357
|
-
<button class="btn btn-secondary" onclick="previousStep()" id="prevBtn" disabled>Previous</button>
|
|
1358
|
-
<button class="btn btn-primary" onclick="nextStep()" id="nextBtn">Next</button>
|
|
1359
|
-
<button class="btn btn-success" onclick="finishWizard()" id="finishBtn" style="display:none;">Finish</button>
|
|
1360
|
-
</div>
|
|
1361
|
-
</div>`;
|
|
1362
|
-
}
|
|
1363
|
-
generateWizardCSS() {
|
|
1364
|
-
return `.wizard-container {
|
|
1365
|
-
max-width: 800px;
|
|
1366
|
-
margin: 0 auto;
|
|
1367
|
-
padding: 20px;
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
.wizard-progress {
|
|
1371
|
-
display: flex;
|
|
1372
|
-
justify-content: space-between;
|
|
1373
|
-
margin-bottom: 40px;
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
.wizard-step {
|
|
1377
|
-
text-align: center;
|
|
1378
|
-
flex: 1;
|
|
1379
|
-
position: relative;
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
.wizard-step:not(:last-child)::after {
|
|
1383
|
-
content: '';
|
|
1384
|
-
position: absolute;
|
|
1385
|
-
top: 20px;
|
|
1386
|
-
left: 50%;
|
|
1387
|
-
width: 100%;
|
|
1388
|
-
height: 2px;
|
|
1389
|
-
background: #e0e0e0;
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
|
-
.wizard-step.active::after,
|
|
1393
|
-
.wizard-step.completed::after {
|
|
1394
|
-
background: #0078d4;
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
.step-number {
|
|
1398
|
-
width: 40px;
|
|
1399
|
-
height: 40px;
|
|
1400
|
-
border-radius: 50%;
|
|
1401
|
-
background: #e0e0e0;
|
|
1402
|
-
color: #666;
|
|
1403
|
-
display: flex;
|
|
1404
|
-
align-items: center;
|
|
1405
|
-
justify-content: center;
|
|
1406
|
-
margin: 0 auto 10px;
|
|
1407
|
-
position: relative;
|
|
1408
|
-
z-index: 1;
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
|
-
.wizard-step.active .step-number,
|
|
1412
|
-
.wizard-step.completed .step-number {
|
|
1413
|
-
background: #0078d4;
|
|
1414
|
-
color: white;
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
.wizard-panel {
|
|
1418
|
-
display: none;
|
|
1419
|
-
min-height: 300px;
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
.wizard-panel.active {
|
|
1423
|
-
display: block;
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
.wizard-actions {
|
|
1427
|
-
margin-top: 40px;
|
|
1428
|
-
text-align: center;
|
|
1429
|
-
}`;
|
|
1430
|
-
}
|
|
1431
|
-
generateWizardJS(spec) {
|
|
1432
|
-
return `// Wizard JavaScript
|
|
1433
|
-
var wizard = {
|
|
1434
|
-
currentStep: 0,
|
|
1435
|
-
totalSteps: ${spec.steps?.length || 0},
|
|
1436
|
-
|
|
1437
|
-
init: function() {
|
|
1438
|
-
this.updateButtons();
|
|
1439
|
-
},
|
|
1440
|
-
|
|
1441
|
-
nextStep: function() {
|
|
1442
|
-
if (this.validateStep(this.currentStep)) {
|
|
1443
|
-
this.currentStep++;
|
|
1444
|
-
this.showStep(this.currentStep);
|
|
1445
|
-
}
|
|
1446
|
-
},
|
|
1447
|
-
|
|
1448
|
-
previousStep: function() {
|
|
1449
|
-
this.currentStep--;
|
|
1450
|
-
this.showStep(this.currentStep);
|
|
1451
|
-
},
|
|
1452
|
-
|
|
1453
|
-
showStep: function(step) {
|
|
1454
|
-
// Hide all panels
|
|
1455
|
-
document.querySelectorAll('.wizard-panel').forEach(function(panel) {
|
|
1456
|
-
panel.classList.remove('active');
|
|
1457
|
-
});
|
|
1458
|
-
document.querySelectorAll('.wizard-step').forEach(function(stepEl) {
|
|
1459
|
-
stepEl.classList.remove('active');
|
|
1460
|
-
});
|
|
1461
|
-
|
|
1462
|
-
// Show current panel
|
|
1463
|
-
document.querySelector('.wizard-panel[data-step="' + step + '"]').classList.add('active');
|
|
1464
|
-
document.querySelector('.wizard-step[data-step="' + step + '"]').classList.add('active');
|
|
1465
|
-
|
|
1466
|
-
// Mark completed steps
|
|
1467
|
-
for (var i = 0; i < step; i++) {
|
|
1468
|
-
document.querySelector('.wizard-step[data-step="' + i + '"]').classList.add('completed');
|
|
1469
|
-
}
|
|
1470
|
-
|
|
1471
|
-
this.updateButtons();
|
|
1472
|
-
},
|
|
1473
|
-
|
|
1474
|
-
updateButtons: function() {
|
|
1475
|
-
var prevBtn = document.getElementById('prevBtn');
|
|
1476
|
-
var nextBtn = document.getElementById('nextBtn');
|
|
1477
|
-
var finishBtn = document.getElementById('finishBtn');
|
|
1478
|
-
|
|
1479
|
-
prevBtn.disabled = this.currentStep === 0;
|
|
1480
|
-
|
|
1481
|
-
if (this.currentStep === this.totalSteps - 1) {
|
|
1482
|
-
nextBtn.style.display = 'none';
|
|
1483
|
-
finishBtn.style.display = 'inline-block';
|
|
1484
|
-
} else {
|
|
1485
|
-
nextBtn.style.display = 'inline-block';
|
|
1486
|
-
finishBtn.style.display = 'none';
|
|
1487
|
-
}
|
|
1488
|
-
},
|
|
1489
|
-
|
|
1490
|
-
validateStep: function(step) {
|
|
1491
|
-
// Add validation logic for each step
|
|
1492
|
-
return true;
|
|
1493
|
-
},
|
|
1494
|
-
|
|
1495
|
-
finish: function() {
|
|
1496
|
-
if (this.validateStep(this.currentStep)) {
|
|
1497
|
-
// Collect all data and submit
|
|
1498
|
-
console.log('Wizard completed');
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
};
|
|
1502
|
-
|
|
1503
|
-
// Global functions
|
|
1504
|
-
function nextStep() {
|
|
1505
|
-
wizard.nextStep();
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
function previousStep() {
|
|
1509
|
-
wizard.previousStep();
|
|
1510
|
-
}
|
|
1511
|
-
|
|
1512
|
-
function finishWizard() {
|
|
1513
|
-
wizard.finish();
|
|
1514
|
-
}
|
|
1515
|
-
|
|
1516
|
-
// Initialize
|
|
1517
|
-
document.addEventListener('DOMContentLoaded', function() {
|
|
1518
|
-
wizard.init();
|
|
1519
|
-
});`;
|
|
1520
|
-
}
|
|
1521
|
-
async generateGenericUI(spec) {
|
|
1522
|
-
// Generate generic UI based on spec
|
|
1523
|
-
return {
|
|
1524
|
-
taskId: '',
|
|
1525
|
-
success: true,
|
|
1526
|
-
output: {
|
|
1527
|
-
html: '<div>Generic UI Component</div>'
|
|
1528
|
-
},
|
|
1529
|
-
artifacts: [
|
|
1530
|
-
this.createArtifact('ui_component', spec.name, spec)
|
|
1531
|
-
]
|
|
1532
|
-
};
|
|
1533
|
-
}
|
|
1534
|
-
sanitizeName(name) {
|
|
1535
|
-
return name.toLowerCase().replace(/[^a-z0-9]/g, '_');
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
exports.UIBuilderAgent = UIBuilderAgent;
|
|
1539
|
-
//# sourceMappingURL=ui-builder.agent.js.map
|