Add restricted middleware transformation pipelines

This commit is contained in:
2026-11-05 23:07:36 +00:00
parent 163f99be54
commit f7a06f487c
5 changed files with 88 additions and 11 deletions
+2 -1
View File
@@ -26,6 +26,7 @@ The initial landscape contains Website, API, ERP, CRM and Email Platform plus tw
- Place reusable Website, CRM, ERP, Email Platform, Analytics and API presets, selecting only the capabilities needed for each instance.
- Inspect labelled capability ports and fictional action payloads, expand node actions, and save customised systems as private browser-local presets.
- Build reusable custom systems with form-based action, output and endpoint definitions. Actions support button, incoming request/event and simulated schedule triggers; outputs can run in parallel, and endpoints support multiple delayed example responses that may trigger actions.
- Add restricted transformation pipelines to action definitions for middleware-style Receive, Validate, Transform, Route and Send stages. Pipelines support explicit example payloads, copy/rename/fixed/default/type-conversion/object-construction/array-item-mapping rules, reference lookup values, validation-failure paths and playback inspection without executing arbitrary JavaScript. The demo includes Website → Order Middleware → ERP.
- Model direct request/response exchanges separately from onward event transfers. Request and response payloads are both recorded in the data inspector, with compatibility warnings shown without blocking unusual integrations.
- Run, pause, advance and reset scenarios with animated packets and event log output.
- Adjust playback speed and inspect the active payload.
@@ -40,4 +41,4 @@ npm run build
## Limitations
This is intentionally a local simulation prototype. It has no authentication, collaboration, server persistence, external API calls, real payload delivery, or production-grade graph editing. Custom definitions and placed instances are stored in browser local storage; playback state is transient and is not included in saved JSON. LiteGraph supplies canvas rendering and cable interaction; scenario semantics are managed by the Vue application. The minimap is diagnostic rather than a full viewport navigator, and transformation highlighting currently compares top-level JSON fields.
This is intentionally a local simulation prototype. It has no authentication, collaboration, server persistence, external API calls, real payload delivery, or production-grade graph editing. Custom definitions and placed instances are stored in browser local storage; playback state is transient and is not included in saved JSON. LiteGraph supplies canvas rendering and cable interaction; scenario semantics are managed by the Vue application. The minimap is diagnostic rather than a full viewport navigator, and transformation highlighting currently compares top-level JSON fields. Pipeline mappings are deliberately limited to the listed rule operations; arbitrary JavaScript, network lookups and live middleware execution are not supported. The custom builder exposes pipeline definitions as validated JSON so advanced step graphs can be edited without adding another runtime dependency.
+12 -3
View File
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
import { LGraph, LGraphCanvas, LiteGraph } from 'litegraph.js'
import { cloneCapabilities, demoLandscape, SYSTEM_PRESETS, systemFromPreset, type CapabilityModel, type ComponentRole, type ConnectionModel, type DefinitionActionModel, type EndpointModel, type EndpointResponseModel, type EnvironmentContainerModel, type EnvironmentModel, type InfrastructureComponent, type LandscapeModel, type ScenarioModel, type ScenarioStep, type SystemDefinition, type SystemModel, type SystemPreset, uid, validateLandscape } from './model'
import { cloneCapabilities, demoLandscape, executePipeline, SYSTEM_PRESETS, systemFromPreset, type CapabilityModel, type ComponentRole, type ConnectionModel, type DefinitionActionModel, type EndpointModel, type EndpointResponseModel, type EnvironmentContainerModel, type EnvironmentModel, type InfrastructureComponent, type LandscapeModel, type PipelineTrace, type ScenarioModel, type ScenarioStep, type SystemDefinition, type SystemModel, type SystemPreset, uid, validateLandscape } from './model'
const STORAGE_KEY = 'dumas-system-landscape-v1'
const PRESET_STORAGE_KEY = 'dumas-system-presets-v1'
@@ -42,6 +42,7 @@ type TransferKind = 'received' | 'sent' | 'stored'
interface TransferChange { key: string; status: 'added' | 'removed' | 'changed' | 'same'; incoming?: unknown; outgoing?: unknown }
interface TransferRecord { id: string; kind: TransferKind; scenarioName: string; stepNumber: number; stepExplanation: string; senderId: string; destinationId: string; payload: string; incoming: string; outgoing: string; changes: TransferChange[]; timestamp: string }
const transferHistory = ref<TransferRecord[]>([])
const pipelineTrace = ref<PipelineTrace[]>([])
const dataTab = ref<TransferKind>('received')
const selectedContainerId = ref('')
const selectedContainer = computed(() => landscape.value.containers.find((item) => item.id === selectedContainerId.value))
@@ -84,6 +85,8 @@ function saveSelectedAsPreset() { if (!selectedSystem.value) return; saveCustomP
function newCustomAction(): DefinitionActionModel { return { id: uid('action'), name: 'New action', description: 'Describe the simulated action.', trigger: 'button', input: '{}', outputs: [{ id: uid('output'), name: 'Output', payload: '{}', parallel: false }] } }
function newCustomEndpoint(): EndpointModel { return { id: uid('endpoint'), name: 'New endpoint', protocol: 'HTTPS', method: 'POST', path: '/example', request: '{}', responses: [{ id: uid('response'), status: 200, body: '{}', delayMs: 300 }] } }
function newCustomResponse(): EndpointResponseModel { return { id: uid('response'), status: 200, body: '{}', delayMs: 300 } }
function attachPipeline(action: DefinitionActionModel) { action.pipeline ||= { id: uid('pipeline'), name: `${action.name} pipeline`, references: {}, steps: [{ id: uid('step'), type: 'receive', name: 'Receive', description: 'Receive the incoming payload.', mappings: [] }, { id: uid('step'), type: 'validate', name: 'Validate', description: 'Validate the required fields.', mappings: [], condition: '' }, { id: uid('step'), type: 'transform', name: 'Transform', description: 'Apply restricted mapping rules.', mappings: [] }, { id: uid('step'), type: 'route', name: 'Route', description: 'Choose the destination.', mappings: [], condition: '' }, { id: uid('step'), type: 'send', name: 'Send', description: 'Send the resulting payload.', mappings: [] }] } }
function updatePipeline(action: DefinitionActionModel, event: Event) { const value = (event.target as HTMLTextAreaElement).value; try { action.pipeline = JSON.parse(value); importError.value = '' } catch { importError.value = 'Pipeline JSON must be valid before saving.' } }
function openCustomBuilder() { customDraft.value = { name: 'Custom system', description: 'Describe this reusable system.', category: 'service', color: '#6d7cff', definition: { actions: [newCustomAction()], endpoints: [newCustomEndpoint()] } }; customBuilderOpen.value = true }
function saveCustomBuilder() { const draft = structuredClone(customDraft.value); const preset: SystemPreset = { id: `custom-${uid('preset')}`, name: draft.name || 'Custom system', description: draft.description, category: draft.category, color: draft.color, capabilities: definitionCapabilities(draft.definition), definition: draft.definition }; saveCustomPreset(preset); customBuilderOpen.value = false }
function addCustomAction() { customDraft.value.definition.actions.push(newCustomAction()) }
@@ -120,7 +123,7 @@ function addStep() {
}
function deleteStep(index: number) { selectedScenario.value?.steps.splice(index, 1); persist() }
function resetPlayback() { playing.value = false; stepIndex.value = -1; packetProgress.value = 0; eventLog.value = []; transferHistory.value = []; failureState.value = 'none'; retryAttempts.value = {}; pendingDecision.value = null; runtimeConnectionIds.value = []; runtimePayload.value = ''; stopAnimation() }
function resetPlayback() { playing.value = false; stepIndex.value = -1; packetProgress.value = 0; eventLog.value = []; transferHistory.value = []; pipelineTrace.value = []; failureState.value = 'none'; retryAttempts.value = {}; pendingDecision.value = null; runtimeConnectionIds.value = []; runtimePayload.value = ''; stopAnimation() }
function startScenario(systemId?: string) {
if (systemId) {
const candidate = landscape.value.scenarios.find((scenario) => scenario.startSystemId === systemId)
@@ -148,7 +151,11 @@ function recordTransfers(step: ScenarioModel['steps'][number], selectedConnectio
const connection = landscape.value.connections.find((item) => item.id === connectionId)
if (!connection) continue
const incoming = connection.transformation?.incoming || selectedPayload || step.payload || connection.payload
const outgoing = selectedPayload || connection.transformation?.outgoing || incoming
const sourceSystem = landscape.value.systems.find((item) => item.id === connection.sourceId)
const pipelineAction = sourceSystem?.definition?.actions.find((action) => action.pipeline)
const pipelineRun = pipelineAction?.pipeline ? executePipeline(selectedPayload || step.payload || connection.payload, pipelineAction.pipeline) : undefined
if (pipelineRun) pipelineTrace.value = pipelineRun.trace
const outgoing = pipelineRun ? (pipelineRun.ok ? pipelineRun.payload : connection.payload || pipelineRun.payload) : selectedPayload || connection.transformation?.outgoing || incoming
const changes = comparePayloads(incoming, outgoing)
const payload = outgoing
transferHistory.value.push(
@@ -284,5 +291,7 @@ onUnmounted(stopAnimation)
<section class="category-panel panel"><label>Filter by category<select v-model="categoryFilter"><option value="all">All categories</option><option value="application">Application</option><option value="saas-service">SaaS Service</option><option value="cloud-service">Cloud Service</option><option value="development-tool">Development Tool</option><option value="data-store">Data Store</option><option value="service">Service</option><option value="data">Data</option><option value="human">Human</option><option value="external">External</option></select></label><label>Filter connections<select v-model="connectionTypeFilter" @change="rebuildGraph"><option value="all">All relationship types</option><option value="data-flow">Data Flow</option><option value="deployment">Deployment</option><option value="dependency">Dependency</option><option value="source-repository">Source Repository</option></select></label><label v-if="selectedConnection">Selected relationship type<select v-model="selectedConnection.connectionType"><option value="data-flow">Data Flow</option><option value="deployment">Deployment</option><option value="dependency">Dependency</option><option value="source-repository">Source Repository</option></select></label></section>
<section v-if="selectedSystem && (selectedSystem.environments?.length || activeTab === 'systems')" class="environment-panel panel"><div class="environment-header"><div><span class="eyebrow">INFRASTRUCTURE DRILL-DOWN</span><strong>{{ selectedSystem.name }} environments</strong></div><div class="environment-actions"><button class="ghost" @click="addEnvironment">+ Environment</button><button v-if="selectedEnvironment" class="ghost" @click="cloneEnvironment(selectedEnvironment)">Clone environment</button></div></div><div class="environment-tabs"><button v-for="environment in (selectedSystem.environments || [])" :key="environment.id" :class="{active: selectedEnvironment?.id === environment.id}" @click="selectEnvironment(environment.id)">{{ environment.name }}</button><span v-if="!selectedSystem.environments?.length" class="muted">No environments yet. Add Dev, QA, UAT or Prod.</span></div><div v-if="selectedEnvironment" class="environment-detail"><div class="environment-config"><label>Name<input v-model="selectedEnvironment.name" /></label><label>Hosting location<input v-model="selectedEnvironment.configuration.hostingLocation" placeholder="Azure, on-prem, etc." /></label><label>Software/version<input v-model="selectedEnvironment.configuration.softwareVersion" /></label><label>Example configuration<input :value="selectedEnvironment.exampleConfiguration ? 'Yes — fictional values' : 'No'" readonly /></label><label>Properties JSON<textarea :value="JSON.stringify(selectedEnvironment.configuration.properties, null, 2)" @change="(event) => { try { selectedEnvironment.configuration.properties = JSON.parse(event.target.value); persist() } catch { importError = 'Environment properties must be valid JSON.' } }" rows="3" class="code"></textarea></label></div><div class="environment-components"><div class="steps-head"><span>Components and instances</span><button class="icon-button" @click="addComponent">+</button></div><article v-for="component in selectedEnvironment.components" :key="component.id" class="component-card"><div class="component-head"><strong>{{ component.name }}</strong><small>{{ component.role }} · {{ component.instanceName }}</small><button class="text-danger" @click="deleteComponent(component.id)">Remove</button></div><div class="definition-grid"><label>Name<input v-model="component.name" /></label><label>Instance<input v-model="component.instanceName" /></label><label>Role<select v-model="component.role"><option value="web-application">Web Application</option><option value="content-management">Content Management</option><option value="content-delivery">Content Delivery</option><option value="database-server">Database Server</option><option value="database">Database</option><option value="search-service">Search Service</option></select></label><label>Hosting location<input v-model="component.configuration.hostingLocation" /></label><label>Hostname<input v-model="component.configuration.hostname" /></label><label>URL<input v-model="component.configuration.url" /></label><label>Software/version<input v-model="component.configuration.softwareVersion" /></label><label>Properties JSON<textarea :value="JSON.stringify(component.configuration.properties, null, 2)" @change="(event) => { try { component.configuration.properties = JSON.parse(event.target.value); persist() } catch { importError = 'Component properties must be valid JSON.' } }" rows="2" class="code"></textarea></label></div></article></div><div class="environment-topology"><div class="steps-head"><span>Internal topology</span><small>Editable example connections</small></div><div v-for="link in selectedEnvironment.connections" :key="link.id" class="topology-row"><select v-model="link.sourceComponentId"><option v-for="component in selectedEnvironment.components" :key="component.id" :value="component.id">{{ component.name }}</option></select><input v-model="link.label" /><select v-model="link.targetComponentId"><option v-for="component in selectedEnvironment.components" :key="component.id" :value="component.id">{{ component.name }}</option></select></div></div></div></section>
<section v-if="selectedScenario" class="scenario-environment panel"><span class="eyebrow">SCENARIO ENVIRONMENT</span><label>Environment<select v-model="selectedScenario.environmentId"><option value="">Logical system view</option><option v-for="system in landscape.systems" :key="system.id" :value="system.environments?.[0]?.id" :disabled="!system.environments?.length">{{ system.name }} · {{ system.environments?.[0]?.name || 'No environment' }}</option></select></label><label class="checkbox-label"><input v-model="selectedScenario.traceInternal" type="checkbox" /> Trace internal component connections when available</label></section>
<section v-if="pipelineTrace.length" class="pipeline-inspector panel"><div class="steps-head"><span>Middleware pipeline trace</span><small>Simulated restricted mappings</small></div><article v-for="trace in pipelineTrace" :key="trace.stepId" class="pipeline-trace-row"><div><b>{{ trace.name }}</b><small>{{ trace.type.toUpperCase() }} · {{ trace.explanation }}</small></div><div class="json-columns"><pre>{{ trace.input }}</pre><span>→</span><pre>{{ trace.output }}</pre></div><p v-if="trace.changedFields.length" class="changed-fields">Changed: {{ trace.changedFields.join(', ') }}</p></article></section>
<section v-if="customBuilderOpen" class="pipeline-builder-overlay"><div class="pipeline-builder panel"><div class="inspector-header"><div><span class="eyebrow">ACTION PIPELINES</span><h2>Middleware mapping editor</h2><p class="muted">Optional restricted pipelines are saved inside each action definition. No arbitrary JavaScript is executed.</p></div><button class="danger-icon" @click="customBuilderOpen = false">×</button></div><article v-for="action in customDraft.definition.actions" :key="action.id" class="definition-card"><div class="steps-head"><span>{{ action.name }}</span><button v-if="!action.pipeline" class="ghost" @click="attachPipeline(action)">Add pipeline</button></div><p v-if="!action.pipeline" class="muted">Add Receive, Validate, Transform, Route and Send stages to this action.</p><div v-else><label>Pipeline name<input v-model="action.pipeline.name" /></label><label>Pipeline JSON<textarea :value="JSON.stringify(action.pipeline, null, 2)" @change="updatePipeline(action, $event)" rows="14" class="code"></textarea></label><small class="muted">Mapping ops: copy, rename, fixed, default, type-conversion, object-construction and array-item-mapping. Use <code>$ref:key</code> in a fixed value for a reference lookup.</small></div></article><div class="modal-actions"><button class="ghost" @click="customBuilderOpen = false">Continue editing</button><button class="primary" @click="saveCustomBuilder">Save reusable preset</button></div></div></section>
</main>
</template>
+13 -3
View File
@@ -1,11 +1,11 @@
import { describe, expect, it } from 'vitest'
import { definitionFromCapabilities, demoLandscape, getPreset, systemFromPreset, validateLandscape } from './model'
import { definitionFromCapabilities, demoLandscape, executePipeline, getPreset, systemFromPreset, validateLandscape } from './model'
describe('landscape model', () => {
it('provides the editable demo landscape', () => {
const landscape = demoLandscape()
expect(landscape.systems).toHaveLength(9)
expect(landscape.scenarios.map((scenario) => scenario.name)).toEqual(expect.arrayContaining(['Place order', 'Register customer', 'Contact enquiry', 'Sample request', 'Commercial order', 'Order retry and recovery', 'Commit, build and deploy']))
expect(landscape.systems).toHaveLength(10)
expect(landscape.scenarios.map((scenario) => scenario.name)).toEqual(expect.arrayContaining(['Place order', 'Register customer', 'Contact enquiry', 'Sample request', 'Commercial order', 'Order retry and recovery', 'Commit, build and deploy', 'Website → Middleware → ERP order']))
expect(landscape.scenarios[0].steps[2].connectionIds).toHaveLength(2)
expect(getPreset('bitbucket')?.category).toBe('development-tool')
expect(landscape.connections.find((connection) => connection.id === 'azure-devops-website')?.connectionType).toBe('deployment')
@@ -51,4 +51,14 @@ describe('landscape model', () => {
const imported = validateLandscape(JSON.parse(JSON.stringify(landscape)))
expect(imported.containers).toEqual(landscape.containers)
})
it('executes restricted middleware mappings and reports validation failures', () => {
const action = getPreset('middleware')!.definition!.actions[0]
const result = executePipeline('{"customerId":"cus_89","sku":"sample-blue"}', action.pipeline!)
expect(result.ok).toBe(true)
expect(JSON.parse(result.payload)).toMatchObject({ accountCode: 'ERP-0042', channel: 'website' })
expect(result.trace.map((item) => item.type)).toEqual(['receive', 'validate', 'transform', 'route', 'send'])
const failed = executePipeline('{"sku":"sample-blue"}', action.pipeline!)
expect(failed.ok).toBe(false)
expect(failed.failureStepId).toBe('validation-failure')
})
})
+60 -4
View File
@@ -7,7 +7,13 @@ export interface HumanActionModel extends ActionModel { connectionId: string }
export interface HumanDecisionModel { roleSystemId: string; task: string; receivedData: string; editableFields: Record<string, string>; actions: HumanActionModel[] }
export type ActionTrigger = 'button' | 'incoming' | 'schedule'
export interface ActionOutputModel { id: string; name: string; payload: string; condition?: string; parallel?: boolean }
export interface DefinitionActionModel { id: string; name: string; description: string; trigger: ActionTrigger; input?: string; outputs: ActionOutputModel[] }
export type PipelineStepType = 'receive' | 'validate' | 'transform' | 'route' | 'send'
export type MappingRule = { op: 'copy' | 'rename' | 'fixed' | 'default' | 'type-conversion' | 'object-construction' | 'array-item-mapping'; source?: string; target?: string; value?: unknown; type?: 'string' | 'number' | 'boolean'; fields?: Record<string, string>; itemPath?: string; itemTarget?: string }
export interface PipelineStep { id: string; type: PipelineStepType; name: string; description: string; mappings: MappingRule[]; condition?: string; failureStepId?: string }
export interface TransformationPipeline { id: string; name: string; steps: PipelineStep[]; references?: Record<string, string> }
export interface PipelineTrace { stepId: string; name: string; type: PipelineStepType; input: string; output: string; explanation: string; changedFields: string[] }
export interface PipelineExecution { ok: boolean; payload: string; trace: PipelineTrace[]; failureStepId?: string; error?: string }
export interface DefinitionActionModel { id: string; name: string; description: string; trigger: ActionTrigger; input?: string; outputs: ActionOutputModel[]; pipeline?: TransformationPipeline }
export interface EndpointResponseModel { id: string; status: number; body: string; delayMs: number }
export interface EndpointModel { id: string; name: string; protocol: string; method: string; path: string; request: string; responses: EndpointResponseModel[]; triggersActionId?: string }
export interface SystemDefinition { actions: DefinitionActionModel[]; endpoints: EndpointModel[] }
@@ -101,6 +107,43 @@ export const uid = (prefix: string) => `${prefix}-${Math.random().toString(36).s
const port = (id: string, name: string, description: string): PortModel => ({ id, name, description })
const action = (id: string, name: string, description: string, payload: string): ActionModel => ({ id, name, description, payload })
const capability = (id: string, name: string, description: string, inputs: PortModel[], outputs: PortModel[], actions: ActionModel[], payload: string): CapabilityModel => ({ id, name, description, inputs, outputs, actions, payload })
function readPath(value: any, path = ''): any { return path.split('.').filter(Boolean).reduce((current, key) => current == null ? undefined : current[key], value) }
function writePath(value: any, path: string, next: any) { const keys = path.split('.').filter(Boolean); if (!keys.length) return; let current = value; keys.slice(0, -1).forEach((key) => { current[key] ||= {}; current = current[key] }); current[keys[keys.length - 1]] = next }
function applyMapping(input: any, rule: MappingRule, references: Record<string, string>) { const output = structuredClone(input); const source = rule.source ? readPath(input, rule.source) : undefined; const value = rule.op === 'copy' || rule.op === 'rename' ? source : rule.op === 'fixed' ? rule.value : rule.op === 'default' ? (source === undefined ? rule.value : source) : rule.op === 'type-conversion' ? (rule.type === 'number' ? Number(source) : rule.type === 'boolean' ? Boolean(source) : String(source ?? '')) : rule.op === 'object-construction' ? Object.fromEntries(Object.entries(rule.fields || {}).map(([key, path]) => [key, readPath(input, path)])) : rule.op === 'array-item-mapping' ? (readPath(input, rule.itemPath || '') || []).map((item: any) => rule.source ? readPath(item, rule.source) : item) : source; if (rule.op === 'rename' && rule.source) { const parts = rule.source.split('.'); let parent = input; parts.slice(0, -1).forEach((key) => { parent = parent?.[key] }); if (parent) delete parent[parts[parts.length - 1]] } if (rule.target) writePath(output, rule.target, value); if (rule.op === 'fixed' && rule.value && typeof rule.value === 'string' && rule.value.startsWith('$ref:')) writePath(output, rule.target || '', references[rule.value.slice(5)] || ''); return output }
export function executePipeline(inputJson: string, pipeline: TransformationPipeline): PipelineExecution {
let current: any
try { current = JSON.parse(inputJson) } catch { return { ok: false, payload: inputJson, trace: [], error: 'Pipeline input is not valid JSON.' } }
const trace: PipelineTrace[] = []
const failureStepIds = new Set(pipeline.steps.map((step) => step.failureStepId).filter(Boolean))
const addTrace = (step: PipelineStep, before: any, after: any) => {
const input = JSON.stringify(before)
const output = JSON.stringify(after)
trace.push({ stepId: step.id, name: step.name, type: step.type, input, output, explanation: step.description, changedFields: input === output ? [] : Object.keys(after) })
}
const runFailure = (stepId: string | undefined) => {
const step = pipeline.steps.find((candidate) => candidate.id === stepId)
if (!step) return
const before = structuredClone(current)
if (step.type === 'transform') for (const rule of step.mappings) current = applyMapping(current, rule, pipeline.references || {})
addTrace(step, before, current)
}
for (const step of pipeline.steps) {
if (failureStepIds.has(step.id)) continue
const before = structuredClone(current)
if (step.type === 'validate' && step.condition && readPath(current, step.condition) === undefined) {
addTrace(step, before, current)
runFailure(step.failureStepId)
return { ok: false, payload: JSON.stringify(current), trace, failureStepId: step.failureStepId, error: step.description }
}
if (step.type === 'transform') for (const rule of step.mappings) current = applyMapping(current, rule, pipeline.references || {})
if (step.type === 'route' && step.condition && !readPath(current, step.condition)) {
runFailure(step.failureStepId)
return { ok: false, payload: JSON.stringify(current), trace, failureStepId: step.failureStepId, error: step.description }
}
addTrace(step, before, current)
}
return { ok: true, payload: JSON.stringify(current), trace }
}
export const SYSTEM_PRESETS: SystemPreset[] = [
{ id: 'website', name: 'Website', description: 'Customer-facing storefront and account experience.', category: 'application', color: '#6d7cff', capabilities: [
@@ -122,7 +165,8 @@ export const SYSTEM_PRESETS: SystemPreset[] = [
{ id: 'sitecore-ordercloud', name: 'Sitecore OrderCloud', description: 'Simulated headless commerce service.', category: 'saas-service', color: '#f06ca9', capabilities: [capability('commerce-api', 'Commerce API', 'Process fictional commerce requests.', [port('order-request', 'Order request', 'A commerce order.')], [port('order-response', 'Order response', 'A commerce response.')], [action('create-order', 'Create order', 'Simulate order creation.', '{"orderId":"oc_1001","status":"accepted"}')], '{"orderId":"oc_1001"}')]},
{ id: 'azure-functions', name: 'Azure Functions', description: 'Simulated serverless compute.', category: 'cloud-service', color: '#00a4ef', capabilities: [capability('function', 'Function', 'Run a fictional function.', [port('trigger', 'Trigger', 'An event that invokes a function.')], [port('result', 'Result', 'Function result.')], [action('invoke', 'Invoke function', 'Simulate function execution.', '{"invocationId":"inv_9","status":"complete"}')], '{"invocationId":"inv_9"}')]},
{ id: 'service-bus', name: 'Service Bus', description: 'Simulated cloud message broker.', category: 'cloud-service', color: '#5d8ee8', capabilities: [capability('messaging', 'Messaging', 'Publish fictional messages.', [port('message', 'Message', 'A message to publish.')], [port('message-event', 'Message event', 'A published message event.')], [action('publish', 'Publish message', 'Simulate message publication.', '{"messageId":"msg_9","status":"accepted"}')], '{"messageId":"msg_9"}')]},
{ id: 'azure-storage', name: 'Storage', description: 'Simulated object and data storage.', category: 'data-store', color: '#86bc25', capabilities: [capability('blob-storage', 'Blob storage', 'Store fictional data objects.', [port('object', 'Object', 'An object to store.')], [port('stored-object', 'Stored object', 'Storage confirmation.')], [action('store', 'Store object', 'Simulate object storage.', '{"objectKey":"orders/oc_1001.json","status":"stored"}')], '{"objectKey":"orders/oc_1001.json"}')]}
{ id: 'azure-storage', name: 'Storage', description: 'Simulated object and data storage.', category: 'data-store', color: '#86bc25', capabilities: [capability('blob-storage', 'Blob storage', 'Store fictional data objects.', [port('object', 'Object', 'An object to store.')], [port('stored-object', 'Stored object', 'Storage confirmation.')], [action('store', 'Store object', 'Simulate object storage.', '{"objectKey":"orders/oc_1001.json","status":"stored"}')], '{"objectKey":"orders/oc_1001.json"}')]},
{ id: 'middleware', name: 'Order Middleware', description: 'Simulated receive/validate/transform/route/send middleware.', category: 'service', color: '#b48cff', capabilities: [capability('pipeline', 'Order pipeline', 'Transform website orders into ERP account orders.', [port('order-input', 'Order input', 'A website order.')], [port('erp-order', 'ERP order', 'An ERP-ready order.')], [action('process-order', 'Process order', 'Run the order transformation pipeline.', '{"customerId":"cus_89","sku":"sample-blue","quantity":1}')], '{"customerId":"cus_89","sku":"sample-blue","quantity":1}')], definition: { actions: [{ id: 'process-order', name: 'Process order', description: 'Receive, validate, transform, route and send an order.', trigger: 'incoming', input: '{"customerId":"cus_89","sku":"sample-blue","quantity":1}', outputs: [{ id: 'erp-output', name: 'ERP order', payload: '{"accountCode":"ERP-0042","sku":"sample-blue","quantity":1}', condition: 'customerId', parallel: false }], pipeline: { id: 'order-pipeline', name: 'Website → ERP order pipeline', references: { 'customerId:cus_89': 'ERP-0042' }, steps: [{ id: 'receive', type: 'receive', name: 'Receive', description: 'Receive the website order.', mappings: [] }, { id: 'validate', type: 'validate', name: 'Validate', description: 'Reject orders without a customer ID.', mappings: [], condition: 'customerId', failureStepId: 'validation-failure' }, { id: 'transform', type: 'transform', name: 'Transform', description: 'Map the website customer ID through the ERP account lookup.', mappings: [{ op: 'fixed', target: 'accountCode', value: '$ref:customerId:cus_89' }, { op: 'fixed', target: 'channel', value: 'website' }, { op: 'default', source: 'quantity', target: 'quantity', value: 1 }] }, { id: 'route', type: 'route', name: 'Route', description: 'Route valid orders to ERP.', mappings: [], condition: 'accountCode', failureStepId: 'validation-failure' }, { id: 'send', type: 'send', name: 'Send', description: 'Send the resulting payload to ERP.', mappings: [] }, { id: 'validation-failure', type: 'send', name: 'Validation failure', description: 'Send a validation failure notification.', mappings: [{ op: 'fixed', target: 'status', value: 'rejected' }] }] } }], endpoints: [{ id: 'order-webhook', name: 'Order webhook', protocol: 'HTTPS', method: 'POST', path: '/orders', request: '{"customerId":"cus_89"}', responses: [{ id: 'accepted', status: 202, body: '{"accepted":true}', delayMs: 150 }] }] } }
]
export function getPreset(id: string) { return SYSTEM_PRESETS.find((preset) => preset.id === id) }
@@ -160,7 +204,8 @@ export const demoLandscape = (): LandscapeModel => ({
{ id: 'sales-review', name: 'Sales review', description: 'Sales team role that reviews sample requests.', category: 'human', color: '#f06ca9', position: [650, 480], containerId: 'azure-resource-group', tags: ['Production', 'Business Function'], presetId: 'sales-review-role', capabilities: cloneCapabilities(getPreset('sales-review-role')!.capabilities) },
{ id: 'bitbucket', name: 'Bitbucket', description: 'Source repository for application code.', category: 'development-tool', color: '#2684ff', position: [80, 700], tags: ['Test', 'Source Control'], providerMetadata: { provider: 'Atlassian', service: 'Bitbucket' }, presetId: 'bitbucket', capabilities: cloneCapabilities(getPreset('bitbucket')!.capabilities) },
{ id: 'azure-devops', name: 'Azure DevOps', description: 'Build and release orchestration.', category: 'development-tool', color: '#0078d4', position: [360, 700], tags: ['Test', 'Deployment'], providerMetadata: { provider: 'Microsoft', service: 'Azure DevOps' }, presetId: 'azure-devops', capabilities: cloneCapabilities(getPreset('azure-devops')!.capabilities) },
{ id: 'sitecore', name: 'Sitecore', description: 'Logical Sitecore content and commerce platform.', category: 'saas-service', color: '#f06ca9', position: [650, 700], tags: ['Production', 'Customer Data'], providerMetadata: { provider: 'Microsoft', service: 'Azure' }, presetId: 'sitecore-ordercloud', capabilities: cloneCapabilities(getPreset('sitecore-ordercloud')!.capabilities), environments: [sitecoreProdEnvironment()] }
{ id: 'sitecore', name: 'Sitecore', description: 'Logical Sitecore content and commerce platform.', category: 'saas-service', color: '#f06ca9', position: [650, 700], tags: ['Production', 'Customer Data'], providerMetadata: { provider: 'Microsoft', service: 'Azure' }, presetId: 'sitecore-ordercloud', capabilities: cloneCapabilities(getPreset('sitecore-ordercloud')!.capabilities), environments: [sitecoreProdEnvironment()] },
{ id: 'middleware', name: 'Order Middleware', description: 'Simulated order transformation pipeline.', category: 'service', color: '#b48cff', position: [930, 500], tags: ['Production', 'Business Function'], presetId: 'middleware', capabilities: cloneCapabilities(getPreset('middleware')!.capabilities), definition: structuredClone(getPreset('middleware')!.definition) }
],
connections: [
{ id: 'website-api', sourceId: 'website', targetId: 'api', label: 'Order request', description: 'Website submits a new order to the API.', payload: '{"orderId":"ord_1042","total":129.5}' },
@@ -180,7 +225,10 @@ export const demoLandscape = (): LandscapeModel => ({
{ id: 'sales-erp', sourceId: 'sales-review', targetId: 'erp', label: 'Approved sample', description: 'Sales approves the sample for ERP fulfilment.', payload: '{"orderId":"smp_1042","decision":"approved"}', protocol: 'HTTPS', dataType: 'JSON', deliveryMethod: 'manual', showCableLabel: true },
{ id: 'sales-email', sourceId: 'sales-review', targetId: 'email', label: 'Rejected sample notice', description: 'Sales rejection triggers a customer notification.', payload: '{"template":"sample-rejected","orderId":"smp_1042"}', protocol: 'HTTPS', dataType: 'JSON', deliveryMethod: 'manual', showCableLabel: true },
{ id: 'bitbucket-azure-devops', sourceId: 'bitbucket', targetId: 'azure-devops', label: 'Commit triggers build', description: 'A source commit triggers the build pipeline.', payload: '{"commit":"abc123","branch":"main"}', connectionType: 'source-repository', exchangeType: 'event-transfer', protocol: 'Webhook', dataType: 'Event', deliveryMethod: 'immediate', showCableLabel: true },
{ id: 'azure-devops-website', sourceId: 'azure-devops', targetId: 'website', label: 'Deploy website', description: 'A successful build deploys the website.', payload: '{"buildId":"build_42","environment":"Production"}', connectionType: 'deployment', exchangeType: 'event-transfer', protocol: 'HTTPS', dataType: 'Event', deliveryMethod: 'scheduled', showCableLabel: true }
{ id: 'azure-devops-website', sourceId: 'azure-devops', targetId: 'website', label: 'Deploy website', description: 'A successful build deploys the website.', payload: '{"buildId":"build_42","environment":"Production"}', connectionType: 'deployment', exchangeType: 'event-transfer', protocol: 'HTTPS', dataType: 'Event', deliveryMethod: 'scheduled', showCableLabel: true },
{ id: 'website-middleware', sourceId: 'website', targetId: 'middleware', label: 'Order request', description: 'Website sends an order to middleware.', payload: '{"customerId":"cus_89","sku":"sample-blue","quantity":1}', connectionType: 'data-flow', exchangeType: 'request-response', responsePayload: '{"accepted":true}', responseStatus: 202, protocol: 'HTTPS', dataType: 'JSON', deliveryMethod: 'immediate', showCableLabel: true },
{ id: 'middleware-erp', sourceId: 'middleware', targetId: 'erp', label: 'ERP-ready order', description: 'Middleware sends the transformed order to ERP.', payload: '{"accountCode":"ERP-0042","sku":"sample-blue","quantity":1}', connectionType: 'data-flow', exchangeType: 'event-transfer', protocol: 'HTTPS', dataType: 'JSON', deliveryMethod: 'immediate', showCableLabel: true },
{ id: 'middleware-email', sourceId: 'middleware', targetId: 'email', label: 'Validation failure', description: 'Middleware notifies the customer when validation fails.', payload: '{"status":"rejected","reason":"invalid_order"}', connectionType: 'data-flow', exchangeType: 'event-transfer', protocol: 'HTTPS', dataType: 'JSON', deliveryMethod: 'immediate', showCableLabel: true }
],
scenarios: [
{
@@ -242,6 +290,14 @@ export const demoLandscape = (): LandscapeModel => ({
{ id: 'dev-1', connectionIds: ['bitbucket-azure-devops'], explanation: 'A developer pushes a commit to the source repository.', payload: '{"commit":"abc123","branch":"main"}', delayMs: 700, outcome: 'success' },
{ id: 'dev-2', connectionIds: ['azure-devops-website'], explanation: 'Azure DevOps completes the build and deploys the website.', payload: '{"buildId":"build_42","environment":"Production"}', delayMs: 1100, outcome: 'success' }
]
},
{
id: 'website-middleware-order', name: 'Website → Middleware → ERP order', description: 'Transform a website order into an ERP account order, with a validation-failure branch.', startSystemId: 'website', startActionId: 'place-order',
steps: [
{ id: 'middleware-1', connectionIds: ['website-middleware'], explanation: 'Website sends an order into middleware.', payload: '{"customerId":"cus_89","sku":"sample-blue","quantity":1}', delayMs: 700, outcome: 'success' },
{ id: 'middleware-2', connectionIds: ['middleware-erp'], explanation: 'Middleware validates, transforms and routes the order to ERP.', payload: '{"customerId":"cus_89","sku":"sample-blue","quantity":1}', delayMs: 1000, outcome: 'success' },
{ id: 'middleware-failure', connectionIds: ['middleware-email'], explanation: 'Invalid orders follow the configured validation-failure path.', payload: '{"status":"rejected","reason":"missing_customerId"}', delayMs: 700, outcome: 'rejected' }
]
}
]
})
+1
View File
@@ -2,3 +2,4 @@
.container-editor,.tag-panel{padding:16px;margin-top:14px}.container-list{display:flex;gap:8px;flex-wrap:wrap}.container-list .list-item{width:auto;min-width:180px}.container-form{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-top:14px;padding-top:14px;border-top:1px solid #263149}.container-form label,.tag-panel label{color:#8996af;font-size:11px;font-weight:700}.container-form input,.container-form select,.tag-panel select,.tag-panel input{display:block;width:100%;margin-top:5px;background:#0d1320;color:#dce4f4;border:1px solid #303d58;border-radius:4px;padding:8px}.container-move{display:flex;gap:5px;align-items:end;flex-wrap:wrap}.tag-panel{display:flex;gap:14px;align-items:end}.tag-panel label{min-width:220px}.tag-panel label+label{flex:1}@media(max-width:700px){.container-form{grid-template-columns:1fr 1fr}.tag-panel{display:block}.tag-panel label{display:block;margin-bottom:10px}}
.category-panel{display:flex;gap:12px;align-items:end;padding:12px 16px;margin-top:14px}.category-panel label{color:#8996af;font-size:11px;font-weight:700;min-width:190px}.category-panel select{display:block;width:100%;margin-top:5px;background:#0d1320;color:#dce4f4;border:1px solid #303d58;border-radius:4px;padding:8px}@media(max-width:700px){.category-panel{display:block}.category-panel label{display:block;margin-bottom:10px}}
.scenario-environment,.environment-panel{padding:16px;margin-top:14px}.scenario-environment{display:flex;gap:14px;align-items:center}.scenario-environment label{color:#8996af;font-size:11px;font-weight:700}.scenario-environment select{display:block;min-width:240px;margin-top:5px;background:#0d1320;color:#dce4f4;border:1px solid #303d58;border-radius:4px;padding:8px}.environment-header{display:flex;justify-content:space-between;align-items:center;gap:12px}.environment-header strong{display:block;margin-top:4px}.environment-actions{display:flex;gap:7px}.environment-tabs{display:flex;gap:7px;flex-wrap:wrap;border-bottom:1px solid #263149;padding:12px 0}.environment-tabs button{border:1px solid #33405a;background:#151d2d;color:#bdc8dc;border-radius:5px;padding:7px 11px}.environment-tabs button.active{background:#8795ff;color:#08101f}.environment-detail{display:grid;grid-template-columns:260px 1fr;gap:16px;padding-top:14px}.environment-config{display:flex;flex-direction:column;gap:5px}.environment-config label,.component-card label{color:#8996af;font-size:10px;font-weight:700}.environment-config input,.environment-config textarea,.component-card input,.component-card select,.component-card textarea{display:block;width:100%;margin-top:5px;background:#0d1320;color:#dce4f4;border:1px solid #303d58;border-radius:4px;padding:7px}.component-card{border:1px solid #303d58;background:#0d1320;border-radius:6px;padding:10px;margin:8px 0}.component-head{display:flex;gap:10px;align-items:center;margin-bottom:10px}.component-head strong{color:#dce4f4}.component-head small{color:#8996af;flex:1}.environment-topology{grid-column:1/-1;border-top:1px solid #263149;padding-top:12px}.topology-row{display:grid;grid-template-columns:1fr 1fr 1fr;gap:7px;margin:7px 0}.topology-row input,.topology-row select{background:#0d1320;color:#dce4f4;border:1px solid #303d58;border-radius:4px;padding:7px}@media(max-width:800px){.environment-detail{grid-template-columns:1fr}.scenario-environment{display:block}.scenario-environment label{display:block;margin-top:8px}.environment-header{align-items:flex-start;flex-direction:column}}
.pipeline-inspector{padding:16px;margin-top:14px}.pipeline-trace-row{border-top:1px solid #263149;padding:12px 0}.pipeline-trace-row>div:first-child{display:flex;justify-content:space-between;gap:12px}.pipeline-trace-row small{color:#8996af}.pipeline-trace-row pre{max-height:150px;overflow:auto}.changed-fields{color:#f4ca72;font-size:11px}.pipeline-builder-overlay{position:fixed;inset:0;z-index:30;background:rgba(4,8,15,.78);display:grid;place-items:center;padding:24px}.pipeline-builder{width:min(820px,96vw);max-height:90vh;overflow:auto;padding:20px}.pipeline-builder .definition-card{margin:12px 0}.pipeline-builder textarea{width:100%;box-sizing:border-box}.pipeline-builder code{color:#b9c5ff}