Add connection protocol and delivery properties

This commit is contained in:
2026-11-05 22:24:38 +00:00
parent eed4d300fa
commit 281c166834
4 changed files with 16 additions and 2 deletions
+10 -2
View File
@@ -47,7 +47,7 @@ const isRunning = computed(() => playing.value || stepIndex.value >= 0)
function persist() { localStorage.setItem(STORAGE_KEY, JSON.stringify(landscape.value)) }
function persistPresets() { localStorage.setItem(PRESET_STORAGE_KEY, JSON.stringify(customPresets.value)) }
function selectSystem(id: string) { selectedSystemId.value = id; selectedConnectionId.value = '' }
function selectConnection(id: string) { selectedConnectionId.value = id; selectedSystemId.value = ''; const connection = landscape.value.connections.find((item) => item.id === id); if (connection && !connection.transformation) connection.transformation = { incoming: connection.payload, outgoing: connection.payload, note: '' } }
function selectConnection(id: string) { selectedConnectionId.value = id; selectedSystemId.value = ''; const connection = landscape.value.connections.find((item) => item.id === id); if (connection) { connection.transformation ||= { incoming: connection.payload, outgoing: connection.payload, note: '' }; connection.protocol ||= 'HTTPS'; connection.dataType ||= 'JSON'; connection.deliveryMethod ||= 'immediate'; connection.showCableLabel ??= true } }
function addSystem() {
const id = uid('system'); landscape.value.systems.push({ id, name: 'New system', description: 'Describe this system.', category: 'service', color: '#6d7cff', position: [160, 160], capabilities: [] }); selectSystem(id); persist(); rebuildGraph()
}
@@ -62,7 +62,7 @@ function deleteSystem(id: string) {
}
function addConnection() {
if (landscape.value.systems.length < 2) return
const connection: ConnectionModel = { id: uid('connection'), sourceId: landscape.value.systems[0].id, targetId: landscape.value.systems[1].id, label: 'New connection', description: '', payload: '{}', transformation: { incoming: '{}', outgoing: '{}', note: '' } }
const connection: ConnectionModel = { id: uid('connection'), sourceId: landscape.value.systems[0].id, targetId: landscape.value.systems[1].id, label: 'New connection', description: '', payload: '{}', transformation: { incoming: '{}', outgoing: '{}', note: '' }, protocol: 'HTTPS', dataType: 'JSON', deliveryMethod: 'immediate', showCableLabel: true }
landscape.value.connections.push(connection); selectConnection(connection.id); persist(); rebuildGraph()
}
function deleteConnection(id: string) {
@@ -145,6 +145,7 @@ function buildNode(system: SystemModel) {
node.onDrawForeground = function(ctx: CanvasRenderingContext2D) { ctx.fillStyle = '#8d9bb8'; ctx.font = '11px Inter, sans-serif'; ctx.fillText(system.category.toUpperCase(), 12, 76); if (node.showActions) { ctx.fillStyle = '#c9d3e8'; ctx.font = '10px Inter, sans-serif'; system.capabilities.forEach((capability: CapabilityModel, index: number) => ctx.fillText(`${capability.name}: ${capability.actions.map((item) => item.name).join(', ')}`, 12, 92 + index * 13)) } }
graph.add(node); return node
}
function connectionLabel(connection: ConnectionModel) { return connection.showCableLabel === false ? '' : `${connection.label} · ${connection.protocol || 'HTTPS'} · ${connection.dataType || 'JSON'} · ${connection.deliveryMethod || 'immediate'}` }
function rebuildGraph() {
graph.clear(); landscape.value.systems.forEach(buildNode)
for (const connection of landscape.value.connections) {
@@ -161,6 +162,12 @@ function drawPackets() {
graphCanvas.onDrawForeground = original
if (!currentConnections.value.length || stepIndex.value < 0) return
const ctx = graphCanvas.ctx as CanvasRenderingContext2D
for (const connection of landscape.value.connections) {
if (!connection.showCableLabel) continue
const from = graph.getNodeById(connection.sourceId); const to = graph.getNodeById(connection.targetId)
if (!from || !to) continue
ctx.save(); ctx.fillStyle = '#7887a2'; ctx.font = '10px Inter, sans-serif'; ctx.fillText(connectionLabel(connection), (from.pos[0] + to.pos[0]) / 2, (from.pos[1] + to.pos[1]) / 2 - 8); ctx.restore()
}
for (const connection of currentConnections.value) {
const from = graph.getNodeById(connection.sourceId); const to = graph.getNodeById(connection.targetId)
if (!from || !to) continue
@@ -208,5 +215,6 @@ onUnmounted(stopAnimation)
<section v-if="selectedConnection" class="transformation-panel panel"><div><span class="eyebrow">SIMULATED TRANSFORMATION</span><strong>{{ selectedConnection.label }}</strong><p class="muted">Configure the data change explicitly; playback never calls a real service.</p></div><label>Incoming JSON<textarea v-model="selectedConnection.transformation!.incoming" rows="4" class="code" @focus="enableTransformation"></textarea></label><label>Outgoing JSON<textarea v-model="selectedConnection.transformation!.outgoing" rows="4" class="code" @focus="enableTransformation"></textarea></label><label>Explanation<input v-model="selectedConnection.transformation!.note" placeholder="What changed?" @focus="enableTransformation" /></label></section><section v-if="latestSelectedRecord" class="transformation-view panel"><span class="eyebrow">LAST RECEIVED PAYLOAD</span><div class="json-columns"><div><b>Incoming</b><pre>{{ latestSelectedRecord.incoming }}</pre></div><div><b>Outgoing</b><pre>{{ latestSelectedRecord.outgoing }}</pre></div></div><div class="change-list"><span v-for="change in latestSelectedRecord.changes" :key="change.key" :class="`change-${change.status}`"><b>{{ change.status }}</b> {{ change.key }}: {{ change.incoming }} → {{ change.outgoing }}</span></div></section>
<section v-if="currentStep" class="guided-card panel"><span class="eyebrow">GUIDED STEP {{ stepIndex + 1 }}</span><strong>{{ currentStep.explanation }}</strong><p>{{ selectedScenario?.description }}</p></section><button class="presentation-toggle ghost" @click="presentationMode = !presentationMode">{{ presentationMode ? 'Exit presentation' : 'Presentation mode' }}</button>
<section v-if="selectedScenario" class="failure-config panel"><div><span class="eyebrow">STEP OUTCOMES</span><strong>Failure and recovery routing</strong><p class="muted">Choose how a simulated step behaves. Retry is limited to one automatic attempt per reset.</p></div><div v-for="(step, index) in selectedScenario.steps" :key="step.id" class="failure-row"><b>{{ index + 1 }}. {{ step.explanation }}</b><select v-model="step.outcome"><option value="success">Success</option><option value="rejected">Reject data</option><option value="timeout">Time out</option></select><select v-model="step.retryStepId"><option value="">No retry</option><option v-for="candidate in selectedScenario.steps" :key="candidate.id" :value="candidate.id" :disabled="candidate.id === step.id">Retry step {{ selectedScenario.steps.indexOf(candidate) + 1 }}</option></select><select v-model="step.recoveryStepId"><option value="">No recovery step</option><option v-for="candidate in selectedScenario.steps" :key="candidate.id" :value="candidate.id" :disabled="candidate.id === step.id">Recover at step {{ selectedScenario.steps.indexOf(candidate) + 1 }}</option></select></div></section>
<section v-if="selectedConnection" class="connection-properties panel"><span class="eyebrow">CONNECTION PROPERTIES</span><div class="property-grid"><label>Protocol<select v-model="selectedConnection.protocol"><option>HTTPS</option><option>HTTP</option><option>GraphQL</option><option>SMTP</option><option>Webhook</option><option>Message queue</option></select></label><label>Data type<select v-model="selectedConnection.dataType"><option>JSON</option><option>Form data</option><option>CSV</option><option>Event</option><option>Binary</option></select></label><label>Delivery<select v-model="selectedConnection.deliveryMethod"><option value="immediate">Immediate</option><option value="scheduled">Scheduled</option><option value="manual">Manual</option></select></label><label class="checkbox-label"><input v-model="selectedConnection.showCableLabel" type="checkbox" /> Show cable label</label></div></section>
</main>
</template>
+1
View File
@@ -0,0 +1 @@
.connection-properties{padding:13px 16px}.property-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-top:9px}.property-grid label{color:#8996af;font-size:10px;font-weight:700}.property-grid select{display:block;width:100%;margin-top:5px;background:#0d1320;color:#dce4f4;border:1px solid #303d58;border-radius:4px;padding:7px;font-size:11px}.property-grid .checkbox-label{display:flex;align-items:center;gap:7px;padding-top:22px}.property-grid .checkbox-label input{width:auto}@media(max-width:800px){.property-grid{grid-template-columns:1fr 1fr}}
+1
View File
@@ -5,6 +5,7 @@ import './inspector.css'
import './transformation.css'
import './presentation.css'
import './failure.css'
import './connection.css'
import './style.css'
createApp(App).mount('#app')
+4
View File
@@ -24,6 +24,10 @@ export interface ConnectionModel {
description: string
payload: string
transformation?: { incoming: string; outgoing: string; note: string }
protocol?: string
dataType?: string
deliveryMethod?: 'immediate' | 'scheduled' | 'manual'
showCableLabel?: boolean
}
export interface ScenarioStep {