@tldiagram/core-ui 1.87.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.d.ts +1 -0
- package/dist/api/client.d.ts +143 -0
- package/dist/api/transport-vscode.d.ts +8 -0
- package/dist/api/transport.d.ts +1 -0
- package/dist/components/CodePreviewPanel-vscode.d.ts +7 -0
- package/dist/components/CodePreviewPanel.d.ts +9 -0
- package/dist/components/ConfirmDialog.d.ts +12 -0
- package/dist/components/ConnectorPanel.d.ts +21 -0
- package/dist/components/ContextBoundaryElement.d.ts +11 -0
- package/dist/components/ContextNeighborElement.d.ts +29 -0
- package/dist/components/ContextStraightConnector.d.ts +4 -0
- package/dist/components/CrossBranchControls.d.ts +9 -0
- package/dist/components/DependenciesOnboarding.d.ts +5 -0
- package/dist/components/DrawingCanvas.d.ts +39 -0
- package/dist/components/ElementLibrary-vscode.d.ts +7 -0
- package/dist/components/ElementLibrary.d.ts +22 -0
- package/dist/components/ElementNode.d.ts +36 -0
- package/dist/components/ElementPanel.d.ts +25 -0
- package/dist/components/ExploreOnboarding.d.ts +5 -0
- package/dist/components/ExplorePageOnboarding.d.ts +5 -0
- package/dist/components/ExportModal.d.ts +16 -0
- package/dist/components/FloatingEdge.d.ts +9 -0
- package/dist/components/GitSourceLinker.d.ts +8 -0
- package/dist/components/HeaderContext.d.ts +16 -0
- package/dist/components/Icons.d.ts +95 -0
- package/dist/components/ImportModal.d.ts +10 -0
- package/dist/components/InlineElementAdder.d.ts +17 -0
- package/dist/components/LayoutSection.d.ts +7 -0
- package/dist/components/LocalSourceLinker.d.ts +8 -0
- package/dist/components/MiniZoomOnboarding.d.ts +5 -0
- package/dist/components/NavBreadcrumb.d.ts +6 -0
- package/dist/components/NodeBody.d.ts +12 -0
- package/dist/components/NodeContainer.d.ts +8 -0
- package/dist/components/NodeHoverCard.d.ts +10 -0
- package/dist/components/PanelHeader.d.ts +8 -0
- package/dist/components/PanelUI.d.ts +3 -0
- package/dist/components/ProxyConnectorEdge.d.ts +4 -0
- package/dist/components/ProxyConnectorPanel.d.ts +9 -0
- package/dist/components/SafeBackground.d.ts +13 -0
- package/dist/components/ScrollIndicatorWrapper.d.ts +8 -0
- package/dist/components/SetChildModal.d.ts +10 -0
- package/dist/components/SetParentModal.d.ts +10 -0
- package/dist/components/SlidingPanel.d.ts +16 -0
- package/dist/components/TagUpsert.d.ts +8 -0
- package/dist/components/TopMenuBar.d.ts +8 -0
- package/dist/components/ViewBezierConnector.d.ts +4 -0
- package/dist/components/ViewDrawMenu.d.ts +22 -0
- package/dist/components/ViewEditorEdgeLabelLayout.d.ts +16 -0
- package/dist/components/ViewEditorOnboarding.d.ts +5 -0
- package/dist/components/ViewExplorer/TagManager/ColorPicker.d.ts +7 -0
- package/dist/components/ViewExplorer/TagManager/GroupNamingPopover.d.ts +10 -0
- package/dist/components/ViewExplorer/TagManager/LayerItem.d.ts +27 -0
- package/dist/components/ViewExplorer/TagManager/TagItem.d.ts +25 -0
- package/dist/components/ViewExplorer/TagManager/index.d.ts +21 -0
- package/dist/components/ViewExplorer/ViewNavigator.d.ts +11 -0
- package/dist/components/ViewExplorer/ViewSearch.d.ts +8 -0
- package/dist/components/ViewExplorer/ViewTree.d.ts +18 -0
- package/dist/components/ViewExplorer/index.d.ts +31 -0
- package/dist/components/ViewExplorer/types.d.ts +11 -0
- package/dist/components/ViewExplorer/utils.d.ts +6 -0
- package/dist/components/ViewExplorer-vscode.d.ts +6 -0
- package/dist/components/ViewFloatingMenu-vscode.d.ts +27 -0
- package/dist/components/ViewFloatingMenu.d.ts +39 -0
- package/dist/components/ViewGridNode.d.ts +29 -0
- package/dist/components/ViewHeaderButton.d.ts +11 -0
- package/dist/components/ViewPanel.d.ts +18 -0
- package/dist/components/ViewsGridOnboarding.d.ts +5 -0
- package/dist/components/ZUI/ZUICanvas.d.ts +18 -0
- package/dist/components/ZUI/index.d.ts +2 -0
- package/dist/components/ZUI/layout.d.ts +18 -0
- package/dist/components/ZUI/proxy.d.ts +25 -0
- package/dist/components/ZUI/renderer.d.ts +30 -0
- package/dist/components/ZUI/types.d.ts +140 -0
- package/dist/components/ZUI/useZUIInteraction.d.ts +21 -0
- package/dist/config/runtime-vscode.d.ts +22 -0
- package/dist/config/runtime.d.ts +5 -0
- package/dist/constants/colors.d.ts +27 -0
- package/dist/constants/diagramColors.d.ts +1 -0
- package/dist/context/ThemeContext.d.ts +27 -0
- package/dist/crossBranch/graph.d.ts +13 -0
- package/dist/crossBranch/resolve.d.ts +22 -0
- package/dist/crossBranch/settings.d.ts +6 -0
- package/dist/crossBranch/store.d.ts +11 -0
- package/dist/crossBranch/types.d.ts +96 -0
- package/dist/demo/DemoPage.d.ts +9 -0
- package/dist/demo/seed.d.ts +9 -0
- package/dist/demo/store.d.ts +137 -0
- package/dist/demo/viewEditor.d.ts +26 -0
- package/dist/favicon.svg +35 -0
- package/dist/hooks/useSafeFitView.d.ts +16 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +19966 -0
- package/dist/lib/vscodeBridge-vscode.d.ts +13 -0
- package/dist/lib/vscodeBridge.d.ts +5 -0
- package/dist/logo-120.png +0 -0
- package/dist/logo-bw.png +0 -0
- package/dist/logo-bw.svg +15 -0
- package/dist/logo-text.svg +51 -0
- package/dist/logo.svg +35 -0
- package/dist/pages/AppearanceSettings.d.ts +3 -0
- package/dist/pages/Dependencies.d.ts +1 -0
- package/dist/pages/InfiniteZoom.d.ts +7 -0
- package/dist/pages/Settings.d.ts +7 -0
- package/dist/pages/ViewEditor/components/EditorMenus.d.ts +24 -0
- package/dist/pages/ViewEditor/components/EditorOverlays.d.ts +30 -0
- package/dist/pages/ViewEditor/components/EmptyCanvasState.d.ts +7 -0
- package/dist/pages/ViewEditor/context.d.ts +13 -0
- package/dist/pages/ViewEditor/hooks/useCanvasInteractions.d.ts +201 -0
- package/dist/pages/ViewEditor/hooks/useDrawingEngine.d.ts +40 -0
- package/dist/pages/ViewEditor/hooks/useViewContextNeighbours.d.ts +20 -0
- package/dist/pages/ViewEditor/hooks/useViewData.d.ts +74 -0
- package/dist/pages/ViewEditor/index.d.ts +8 -0
- package/dist/pages/ViewEditor/utils.d.ts +14 -0
- package/dist/pages/Views.d.ts +6 -0
- package/dist/pages/ViewsGrid.d.ts +6 -0
- package/dist/pkg/importer/mermaid.d.ts +7 -0
- package/dist/pkg/importer/mermaid.test.d.ts +1 -0
- package/dist/platform/PlatformContext.d.ts +6 -0
- package/dist/platform/context.d.ts +3 -0
- package/dist/platform/local.d.ts +2 -0
- package/dist/platform/types.d.ts +17 -0
- package/dist/slots.d.ts +67 -0
- package/dist/theme.d.ts +2 -0
- package/dist/types/index.d.ts +193 -0
- package/dist/types/vscode-messages.d.ts +60 -0
- package/dist/utils/edgeDistribution.d.ts +34 -0
- package/dist/utils/githubApi.d.ts +4 -0
- package/dist/utils/githubCache.d.ts +17 -0
- package/dist/utils/ids.d.ts +2 -0
- package/dist/utils/technologyCatalog.d.ts +15 -0
- package/dist/utils/toast.d.ts +15 -0
- package/dist/utils/treesitter.d.ts +13 -0
- package/dist/utils/url.d.ts +12 -0
- package/package.json +159 -0
- package/src/App.tsx +141 -0
- package/src/api/client.ts +618 -0
- package/src/api/transport-vscode.ts +28 -0
- package/src/api/transport.ts +7 -0
- package/src/assets/logo-mark.svg +31 -0
- package/src/assets/logo-wordmark.svg +22 -0
- package/src/assets/logo.svg +35 -0
- package/src/components/CodePreviewPanel-vscode.tsx +85 -0
- package/src/components/CodePreviewPanel.tsx +384 -0
- package/src/components/ConfirmDialog.tsx +66 -0
- package/src/components/ConnectorPanel.tsx +403 -0
- package/src/components/ContextBoundaryElement.tsx +35 -0
- package/src/components/ContextNeighborElement.tsx +282 -0
- package/src/components/ContextStraightConnector.tsx +144 -0
- package/src/components/CrossBranchControls.tsx +105 -0
- package/src/components/DependenciesOnboarding.tsx +427 -0
- package/src/components/DrawingCanvas.tsx +391 -0
- package/src/components/ElementLibrary-vscode.tsx +9 -0
- package/src/components/ElementLibrary.tsx +512 -0
- package/src/components/ElementNode.tsx +1033 -0
- package/src/components/ElementPanel.tsx +928 -0
- package/src/components/ExploreOnboarding.tsx +347 -0
- package/src/components/ExplorePageOnboarding.tsx +383 -0
- package/src/components/ExportModal.tsx +132 -0
- package/src/components/FloatingEdge.tsx +115 -0
- package/src/components/GitSourceLinker.tsx +1053 -0
- package/src/components/HeaderContext.tsx +30 -0
- package/src/components/Icons.tsx +245 -0
- package/src/components/ImportModal.tsx +219 -0
- package/src/components/InlineElementAdder.tsx +216 -0
- package/src/components/LayoutSection.tsx +624 -0
- package/src/components/LocalSourceLinker.tsx +330 -0
- package/src/components/MiniZoomOnboarding.tsx +78 -0
- package/src/components/NavBreadcrumb.tsx +24 -0
- package/src/components/NodeBody.tsx +89 -0
- package/src/components/NodeContainer.tsx +58 -0
- package/src/components/NodeHoverCard.tsx +135 -0
- package/src/components/PanelHeader.tsx +36 -0
- package/src/components/PanelUI.tsx +24 -0
- package/src/components/ProxyConnectorEdge.tsx +169 -0
- package/src/components/ProxyConnectorPanel.tsx +130 -0
- package/src/components/SafeBackground.tsx +19 -0
- package/src/components/ScrollIndicatorWrapper.tsx +117 -0
- package/src/components/SetChildModal.tsx +191 -0
- package/src/components/SetParentModal.tsx +187 -0
- package/src/components/SlidingPanel.tsx +114 -0
- package/src/components/TagUpsert.tsx +142 -0
- package/src/components/TopMenuBar.tsx +380 -0
- package/src/components/ViewBezierConnector.tsx +143 -0
- package/src/components/ViewDrawMenu.tsx +270 -0
- package/src/components/ViewEditorEdgeLabelLayout.ts +189 -0
- package/src/components/ViewEditorOnboarding.tsx +445 -0
- package/src/components/ViewExplorer/TagManager/ColorPicker.tsx +49 -0
- package/src/components/ViewExplorer/TagManager/GroupNamingPopover.tsx +96 -0
- package/src/components/ViewExplorer/TagManager/LayerItem.tsx +228 -0
- package/src/components/ViewExplorer/TagManager/TagItem.tsx +242 -0
- package/src/components/ViewExplorer/TagManager/index.tsx +418 -0
- package/src/components/ViewExplorer/ViewNavigator.tsx +121 -0
- package/src/components/ViewExplorer/ViewSearch.tsx +33 -0
- package/src/components/ViewExplorer/ViewTree.tsx +98 -0
- package/src/components/ViewExplorer/index.tsx +384 -0
- package/src/components/ViewExplorer/types.ts +13 -0
- package/src/components/ViewExplorer/utils.ts +56 -0
- package/src/components/ViewExplorer-vscode.tsx +8 -0
- package/src/components/ViewFloatingMenu-vscode.tsx +248 -0
- package/src/components/ViewFloatingMenu.tsx +379 -0
- package/src/components/ViewGridNode.tsx +451 -0
- package/src/components/ViewHeaderButton.tsx +60 -0
- package/src/components/ViewPanel.tsx +162 -0
- package/src/components/ViewsGridOnboarding.tsx +400 -0
- package/src/components/ZUI/ZUICanvas.tsx +853 -0
- package/src/components/ZUI/index.ts +3 -0
- package/src/components/ZUI/layout.ts +323 -0
- package/src/components/ZUI/proxy.ts +278 -0
- package/src/components/ZUI/renderer.ts +1189 -0
- package/src/components/ZUI/types.ts +150 -0
- package/src/components/ZUI/useZUIInteraction.ts +720 -0
- package/src/config/runtime-vscode.ts +46 -0
- package/src/config/runtime.ts +30 -0
- package/src/constants/colors.ts +80 -0
- package/src/constants/diagramColors.ts +9 -0
- package/src/context/ThemeContext.tsx +158 -0
- package/src/crossBranch/graph.ts +207 -0
- package/src/crossBranch/resolve.ts +643 -0
- package/src/crossBranch/settings.ts +59 -0
- package/src/crossBranch/store.ts +71 -0
- package/src/crossBranch/types.ts +102 -0
- package/src/demo/DemoPage.tsx +184 -0
- package/src/demo/seed.ts +67 -0
- package/src/demo/store.ts +536 -0
- package/src/demo/viewEditor.ts +110 -0
- package/src/hooks/useSafeFitView.ts +60 -0
- package/src/index.css +309 -0
- package/src/index.ts +184 -0
- package/src/kafka-ss.png +0 -0
- package/src/lib/vscodeBridge-vscode.ts +27 -0
- package/src/lib/vscodeBridge.ts +7 -0
- package/src/main.tsx +46 -0
- package/src/pages/AppearanceSettings.tsx +135 -0
- package/src/pages/Dependencies.tsx +926 -0
- package/src/pages/InfiniteZoom.tsx +404 -0
- package/src/pages/Settings.tsx +91 -0
- package/src/pages/ViewEditor/EDGE_DISTRIBUTION.md +64 -0
- package/src/pages/ViewEditor/components/EditorMenus.tsx +112 -0
- package/src/pages/ViewEditor/components/EditorOverlays.tsx +172 -0
- package/src/pages/ViewEditor/components/EmptyCanvasState.tsx +42 -0
- package/src/pages/ViewEditor/context.tsx +21 -0
- package/src/pages/ViewEditor/hooks/useCanvasInteractions.ts +1349 -0
- package/src/pages/ViewEditor/hooks/useDrawingEngine.ts +127 -0
- package/src/pages/ViewEditor/hooks/useViewContextNeighbours.ts +501 -0
- package/src/pages/ViewEditor/hooks/useViewData.ts +491 -0
- package/src/pages/ViewEditor/index.tsx +1366 -0
- package/src/pages/ViewEditor/utils.ts +88 -0
- package/src/pages/Views.tsx +171 -0
- package/src/pages/ViewsGrid.tsx +1310 -0
- package/src/pkg/importer/mermaid.test.ts +141 -0
- package/src/pkg/importer/mermaid.ts +76 -0
- package/src/platform/PlatformContext.tsx +17 -0
- package/src/platform/context.ts +9 -0
- package/src/platform/local.tsx +15 -0
- package/src/platform/types.ts +19 -0
- package/src/slots.ts +92 -0
- package/src/styles/editor-panels.css +66 -0
- package/src/styles/theme.css +56 -0
- package/src/theme.ts +336 -0
- package/src/types/index.ts +234 -0
- package/src/types/offline-ambient.d.ts +14 -0
- package/src/types/vscode-messages.ts +32 -0
- package/src/utils/edgeDistribution.ts +103 -0
- package/src/utils/githubApi.ts +121 -0
- package/src/utils/githubCache.ts +108 -0
- package/src/utils/ids.ts +9 -0
- package/src/utils/technologyCatalog.ts +143 -0
- package/src/utils/toast.ts +100 -0
- package/src/utils/treesitter.ts +147 -0
- package/src/utils/url.ts +72 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,618 @@
|
|
|
1
|
+
import { createClient, ConnectError } from '@connectrpc/connect'
|
|
2
|
+
import { toJson } from '@bufbuild/protobuf'
|
|
3
|
+
import type {
|
|
4
|
+
Connector,
|
|
5
|
+
DependencyConnector,
|
|
6
|
+
DependencyElement,
|
|
7
|
+
ElementPlacement,
|
|
8
|
+
ExploreData,
|
|
9
|
+
LibraryElement,
|
|
10
|
+
PlacedElement,
|
|
11
|
+
View,
|
|
12
|
+
ViewConnector,
|
|
13
|
+
ViewLayer,
|
|
14
|
+
ViewPlacement,
|
|
15
|
+
ViewTreeNode,
|
|
16
|
+
} from '../types'
|
|
17
|
+
import {
|
|
18
|
+
WorkspaceService,
|
|
19
|
+
CreateViewResponseSchema,
|
|
20
|
+
UpdateViewResponseSchema,
|
|
21
|
+
ListViewsResponseSchema,
|
|
22
|
+
GetViewResponseSchema,
|
|
23
|
+
GetWorkspaceResponseSchema,
|
|
24
|
+
ListElementsResponseSchema,
|
|
25
|
+
GetElementResponseSchema,
|
|
26
|
+
CreateElementResponseSchema,
|
|
27
|
+
UpdateElementResponseSchema,
|
|
28
|
+
ListElementPlacementsResponseSchema,
|
|
29
|
+
ListPlacementsResponseSchema,
|
|
30
|
+
CreatePlacementResponseSchema,
|
|
31
|
+
ListConnectorsResponseSchema,
|
|
32
|
+
CreateConnectorResponseSchema,
|
|
33
|
+
UpdateConnectorResponseSchema,
|
|
34
|
+
ListElementNavigationsResponseSchema,
|
|
35
|
+
ListViewLayersResponseSchema,
|
|
36
|
+
CreateViewLayerResponseSchema,
|
|
37
|
+
UpdateViewLayerResponseSchema,
|
|
38
|
+
PlanElement,
|
|
39
|
+
PlanConnector,
|
|
40
|
+
} from '@buf/tldiagramcom_diagram.bufbuild_es/diag/v1/workspace_service_pb'
|
|
41
|
+
import {
|
|
42
|
+
DependencyService,
|
|
43
|
+
ListDependenciesResponseSchema,
|
|
44
|
+
} from '@buf/tldiagramcom_diagram.bufbuild_es/diag/v1/dependency_service_pb'
|
|
45
|
+
import {
|
|
46
|
+
ImportService,
|
|
47
|
+
} from '@buf/tldiagramcom_diagram.bufbuild_es/diag/v1/import_service_pb'
|
|
48
|
+
import { transport } from './transport'
|
|
49
|
+
|
|
50
|
+
export interface DependenciesResponse {
|
|
51
|
+
elements: DependencyElement[]
|
|
52
|
+
connectors: DependencyConnector[]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ─── RPC clients ─────────────────────────────────────────────────────────────
|
|
56
|
+
|
|
57
|
+
const workspaceClient = createClient(WorkspaceService, transport)
|
|
58
|
+
const dependencyClient = createClient(DependencyService, transport)
|
|
59
|
+
const importClient = createClient(ImportService, transport)
|
|
60
|
+
|
|
61
|
+
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
62
|
+
|
|
63
|
+
async function rpc<T>(call: () => Promise<T>): Promise<T> {
|
|
64
|
+
try {
|
|
65
|
+
return await call()
|
|
66
|
+
} catch (e) {
|
|
67
|
+
if (e instanceof ConnectError) throw new Error(e.message)
|
|
68
|
+
throw e
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function j<T>(schema: Parameters<typeof toJson>[0], msg: Parameters<typeof toJson>[1]): T {
|
|
73
|
+
return toJson(schema, msg, { useProtoFieldName: true, emitDefaultValues: true }) as unknown as T
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ─── Proto → frontend type mappers ───────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
interface ProtoDiagram {
|
|
79
|
+
id: number
|
|
80
|
+
ownerElementId?: number | null
|
|
81
|
+
owner_element_id?: number | null
|
|
82
|
+
name: string
|
|
83
|
+
description?: string | null
|
|
84
|
+
levelLabel?: string | null
|
|
85
|
+
level_label?: string | null
|
|
86
|
+
level?: number
|
|
87
|
+
depth?: number
|
|
88
|
+
createdAt?: string
|
|
89
|
+
created_at?: string
|
|
90
|
+
updatedAt?: string
|
|
91
|
+
updated_at?: string
|
|
92
|
+
parent_view_id?: number | null
|
|
93
|
+
children?: ProtoDiagram[]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function mapDiagram(d: ProtoDiagram): ViewTreeNode {
|
|
97
|
+
return {
|
|
98
|
+
id: Number(d.id),
|
|
99
|
+
owner_element_id: d.ownerElementId != null || d.owner_element_id != null
|
|
100
|
+
? Number(d.ownerElementId ?? d.owner_element_id)
|
|
101
|
+
: null,
|
|
102
|
+
name: d.name,
|
|
103
|
+
description: d.description ?? null,
|
|
104
|
+
level_label: d.levelLabel ?? d.level_label ?? null,
|
|
105
|
+
level: d.level ?? 0,
|
|
106
|
+
depth: d.depth ?? 0,
|
|
107
|
+
created_at: d.createdAt ?? d.created_at ?? '',
|
|
108
|
+
updated_at: d.updatedAt ?? d.updated_at ?? '',
|
|
109
|
+
parent_view_id: d.parent_view_id ?? null,
|
|
110
|
+
children: (d.children ?? []).map(mapDiagram),
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function diagramToView(d: ProtoDiagram): View {
|
|
115
|
+
return {
|
|
116
|
+
id: Number(d.id),
|
|
117
|
+
owner_element_id: d.ownerElementId != null || d.owner_element_id != null
|
|
118
|
+
? Number(d.ownerElementId ?? d.owner_element_id)
|
|
119
|
+
: null,
|
|
120
|
+
name: d.name,
|
|
121
|
+
label: d.levelLabel ?? d.level_label ?? null,
|
|
122
|
+
is_root: (d.parent_view_id ?? null) === null,
|
|
123
|
+
created_at: d.createdAt ?? d.created_at ?? new Date().toISOString(),
|
|
124
|
+
updated_at: d.updatedAt ?? d.updated_at ?? new Date().toISOString(),
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function protoElementToLibrary(e: Record<string, unknown>): LibraryElement {
|
|
129
|
+
return {
|
|
130
|
+
id: Number(e.id ?? 0),
|
|
131
|
+
name: String(e.name ?? ''),
|
|
132
|
+
kind: (e.kind ?? null) as string | null,
|
|
133
|
+
description: (e.description ?? null) as string | null,
|
|
134
|
+
technology: (e.technology ?? null) as string | null,
|
|
135
|
+
url: (e.url ?? null) as string | null,
|
|
136
|
+
logo_url: (e.logo_url ?? null) as string | null,
|
|
137
|
+
technology_connectors: (e.technology_connectors ?? []) as LibraryElement['technology_connectors'],
|
|
138
|
+
tags: (e.tags ?? []) as string[],
|
|
139
|
+
repo: (e.repo ?? null) as string | null,
|
|
140
|
+
branch: (e.branch ?? null) as string | null,
|
|
141
|
+
file_path: (e.file_path ?? null) as string | null,
|
|
142
|
+
language: (e.language ?? null) as string | null,
|
|
143
|
+
created_at: String(e.created_at ?? new Date().toISOString()),
|
|
144
|
+
updated_at: String(e.updated_at ?? new Date().toISOString()),
|
|
145
|
+
has_view: Boolean(e.has_view ?? false),
|
|
146
|
+
view_label: (e.view_label ?? null) as string | null,
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function protoPlacedElement(p: Record<string, unknown>): PlacedElement {
|
|
151
|
+
return {
|
|
152
|
+
id: Number(p.id ?? 0),
|
|
153
|
+
view_id: Number(p.view_id ?? 0),
|
|
154
|
+
element_id: Number(p.element_id ?? 0),
|
|
155
|
+
position_x: Number(p.position_x ?? 0),
|
|
156
|
+
position_y: Number(p.position_y ?? 0),
|
|
157
|
+
name: String(p.name ?? ''),
|
|
158
|
+
description: (p.description ?? null) as string | null,
|
|
159
|
+
kind: (p.kind ?? null) as string | null,
|
|
160
|
+
technology: (p.technology ?? null) as string | null,
|
|
161
|
+
url: (p.url ?? null) as string | null,
|
|
162
|
+
logo_url: (p.logo_url ?? null) as string | null,
|
|
163
|
+
technology_connectors: (p.technology_connectors ?? []) as PlacedElement['technology_connectors'],
|
|
164
|
+
tags: (p.tags ?? []) as string[],
|
|
165
|
+
repo: (p.repo ?? null) as string | null,
|
|
166
|
+
branch: (p.branch ?? null) as string | null,
|
|
167
|
+
file_path: (p.file_path ?? null) as string | null,
|
|
168
|
+
language: (p.language ?? null) as string | null,
|
|
169
|
+
has_view: Boolean(p.has_view ?? false),
|
|
170
|
+
view_label: (p.view_label ?? null) as string | null,
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function protoConnector(e: Record<string, unknown>): Connector {
|
|
175
|
+
return {
|
|
176
|
+
id: Number(e.id ?? 0),
|
|
177
|
+
view_id: Number(e.view_id ?? 0),
|
|
178
|
+
source_element_id: Number(e.source_element_id ?? 0),
|
|
179
|
+
target_element_id: Number(e.target_element_id ?? 0),
|
|
180
|
+
label: (e.label ?? null) as string | null,
|
|
181
|
+
description: (e.description ?? null) as string | null,
|
|
182
|
+
relationship: (e.relationship ?? null) as string | null,
|
|
183
|
+
direction: String(e.direction ?? 'forward'),
|
|
184
|
+
style: String(e.style ?? 'bezier'),
|
|
185
|
+
url: (e.url ?? null) as string | null,
|
|
186
|
+
source_handle: (e.source_handle ?? null) as string | null,
|
|
187
|
+
target_handle: (e.target_handle ?? null) as string | null,
|
|
188
|
+
created_at: String(e.created_at ?? new Date().toISOString()),
|
|
189
|
+
updated_at: String(e.updated_at ?? new Date().toISOString()),
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function protoNavigation(n: Record<string, unknown>): ViewConnector {
|
|
194
|
+
return {
|
|
195
|
+
id: Number(n.id ?? 0),
|
|
196
|
+
element_id: (n.element_id ?? null) as number | null,
|
|
197
|
+
from_view_id: Number(n.from_view_id ?? 0),
|
|
198
|
+
to_view_id: Number(n.to_view_id ?? 0),
|
|
199
|
+
to_view_name: String(n.to_view_name ?? ''),
|
|
200
|
+
relation_type: String(n.relation_type ?? 'child'),
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function protoDiagramPlacement(p: Record<string, unknown>): ViewPlacement {
|
|
205
|
+
return {
|
|
206
|
+
view_id: Number(p.view_id ?? 0),
|
|
207
|
+
view_name: String(p.view_name ?? ''),
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function protoLayer(l: Record<string, unknown>): ViewLayer {
|
|
212
|
+
return {
|
|
213
|
+
id: Number(l.id ?? 0),
|
|
214
|
+
diagram_id: Number(l.view_id ?? l.diagram_id ?? 0),
|
|
215
|
+
name: String(l.name ?? ''),
|
|
216
|
+
tags: (l.tags ?? []) as string[],
|
|
217
|
+
color: String(l.color ?? ''),
|
|
218
|
+
created_at: String(l.created_at ?? new Date().toISOString()),
|
|
219
|
+
updated_at: String(l.updated_at ?? new Date().toISOString()),
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export const api = {
|
|
224
|
+
system: {
|
|
225
|
+
ready: (): Promise<{ ok: boolean }> =>
|
|
226
|
+
rpc(() => workspaceClient.listViews({}).then(() => ({ ok: true }))),
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
user: {
|
|
230
|
+
getPreferences: (): Promise<{ accent_color: string | null; background_color: string | null; element_color: string | null }> =>
|
|
231
|
+
Promise.resolve({
|
|
232
|
+
accent_color: localStorage.getItem('diag:accent-color'),
|
|
233
|
+
background_color: localStorage.getItem('diag:background-color'),
|
|
234
|
+
element_color: localStorage.getItem('diag:element-color'),
|
|
235
|
+
}),
|
|
236
|
+
updatePreferences: async (prefs: { accent_color?: string; background_color?: string; element_color?: string }): Promise<void> => {
|
|
237
|
+
if (prefs.accent_color) localStorage.setItem('diag:accent-color', prefs.accent_color)
|
|
238
|
+
if (prefs.background_color) localStorage.setItem('diag:background-color', prefs.background_color)
|
|
239
|
+
if (prefs.element_color) localStorage.setItem('diag:element-color', prefs.element_color)
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
elements: {
|
|
244
|
+
list: (params?: { limit?: number; offset?: number; search?: string }): Promise<LibraryElement[]> =>
|
|
245
|
+
rpc(async () => {
|
|
246
|
+
const res = await workspaceClient.listElements({
|
|
247
|
+
limit: params?.limit ?? 0,
|
|
248
|
+
offset: params?.offset ?? 0,
|
|
249
|
+
search: params?.search ?? '',
|
|
250
|
+
})
|
|
251
|
+
const json = j<{ elements: Record<string, unknown>[] }>(ListElementsResponseSchema, res)
|
|
252
|
+
return (json.elements ?? []).map(protoElementToLibrary)
|
|
253
|
+
}),
|
|
254
|
+
|
|
255
|
+
get: (id: number): Promise<LibraryElement> =>
|
|
256
|
+
rpc(async () => {
|
|
257
|
+
const res = await workspaceClient.getElement({ elementId: id })
|
|
258
|
+
const json = j<{ element: Record<string, unknown> }>(GetElementResponseSchema, res)
|
|
259
|
+
return protoElementToLibrary(json.element ?? {})
|
|
260
|
+
}),
|
|
261
|
+
|
|
262
|
+
create: (data: Partial<LibraryElement>): Promise<LibraryElement> =>
|
|
263
|
+
rpc(async () => {
|
|
264
|
+
const res = await workspaceClient.createElement({
|
|
265
|
+
name: data.name ?? '',
|
|
266
|
+
kind: data.kind ?? '',
|
|
267
|
+
description: data.description ?? undefined,
|
|
268
|
+
technology: data.technology ?? undefined,
|
|
269
|
+
url: data.url ?? undefined,
|
|
270
|
+
logoUrl: data.logo_url ?? undefined,
|
|
271
|
+
technologyLinks: (data.technology_connectors ?? []).map(tl => ({
|
|
272
|
+
type: tl.type,
|
|
273
|
+
slug: tl.slug ?? '',
|
|
274
|
+
label: tl.label,
|
|
275
|
+
isPrimaryIcon: tl.is_primary_icon ?? false,
|
|
276
|
+
})),
|
|
277
|
+
tags: data.tags ?? [],
|
|
278
|
+
repo: data.repo ?? undefined,
|
|
279
|
+
branch: data.branch ?? undefined,
|
|
280
|
+
filePath: data.file_path ?? undefined,
|
|
281
|
+
language: data.language ?? undefined,
|
|
282
|
+
})
|
|
283
|
+
const json = j<{ element: Record<string, unknown> }>(CreateElementResponseSchema, res)
|
|
284
|
+
return protoElementToLibrary(json.element ?? {})
|
|
285
|
+
}),
|
|
286
|
+
|
|
287
|
+
update: (id: number, data: Partial<LibraryElement>): Promise<LibraryElement> =>
|
|
288
|
+
rpc(async () => {
|
|
289
|
+
const res = await workspaceClient.updateElement({
|
|
290
|
+
elementId: id,
|
|
291
|
+
name: data.name ?? undefined,
|
|
292
|
+
kind: data.kind ?? undefined,
|
|
293
|
+
description: data.description ?? undefined,
|
|
294
|
+
technology: data.technology ?? undefined,
|
|
295
|
+
url: data.url ?? undefined,
|
|
296
|
+
logoUrl: data.logo_url ?? undefined,
|
|
297
|
+
technologyLinks: (data.technology_connectors ?? []).map(tl => ({
|
|
298
|
+
type: tl.type,
|
|
299
|
+
slug: tl.slug ?? '',
|
|
300
|
+
label: tl.label,
|
|
301
|
+
isPrimaryIcon: tl.is_primary_icon ?? false,
|
|
302
|
+
})),
|
|
303
|
+
tags: data.tags ?? [],
|
|
304
|
+
repo: data.repo ?? undefined,
|
|
305
|
+
branch: data.branch ?? undefined,
|
|
306
|
+
filePath: data.file_path ?? undefined,
|
|
307
|
+
language: data.language ?? undefined,
|
|
308
|
+
})
|
|
309
|
+
const json = j<{ element: Record<string, unknown> }>(UpdateElementResponseSchema, res)
|
|
310
|
+
return protoElementToLibrary(json.element ?? {})
|
|
311
|
+
}),
|
|
312
|
+
|
|
313
|
+
delete: (_orgId: string, id: number): Promise<void> =>
|
|
314
|
+
rpc(async () => { await workspaceClient.deleteElement({ orgId: '', elementId: id }) }),
|
|
315
|
+
|
|
316
|
+
placements: (id: number): Promise<ViewPlacement[]> =>
|
|
317
|
+
rpc(async () => {
|
|
318
|
+
const res = await workspaceClient.listElementPlacements({ elementId: id })
|
|
319
|
+
const json = j<{ placements: Record<string, unknown>[] }>(ListElementPlacementsResponseSchema, res)
|
|
320
|
+
return (json.placements ?? []).map(protoDiagramPlacement)
|
|
321
|
+
}),
|
|
322
|
+
},
|
|
323
|
+
|
|
324
|
+
workspace: {
|
|
325
|
+
elements: {
|
|
326
|
+
list: (params?: { limit?: number; offset?: number; search?: string }): Promise<LibraryElement[]> =>
|
|
327
|
+
api.elements.list(params),
|
|
328
|
+
get: (id: number): Promise<LibraryElement> => api.elements.get(id),
|
|
329
|
+
create: (data: Partial<LibraryElement>): Promise<LibraryElement> => api.elements.create(data),
|
|
330
|
+
update: (id: number, data: Partial<LibraryElement>): Promise<LibraryElement> => api.elements.update(id, data),
|
|
331
|
+
delete: (_orgId: string, id: number): Promise<void> => api.elements.delete('', id),
|
|
332
|
+
placements: (id: number): Promise<ViewPlacement[]> => api.elements.placements(id),
|
|
333
|
+
navigations: {
|
|
334
|
+
list: (elementId: number, fromDiagramId: number): Promise<ViewConnector[]> =>
|
|
335
|
+
rpc(async () => {
|
|
336
|
+
const res = await workspaceClient.listElementNavigations({ elementId, fromViewId: fromDiagramId, toViewId: 0 })
|
|
337
|
+
const json = j<{ navigations: Record<string, unknown>[] }>(ListElementNavigationsResponseSchema, res)
|
|
338
|
+
return (json.navigations ?? []).map(protoNavigation)
|
|
339
|
+
}),
|
|
340
|
+
listParents: (elementId: number, toDiagramId: number): Promise<ViewConnector[]> =>
|
|
341
|
+
rpc(async () => {
|
|
342
|
+
const res = await workspaceClient.listElementNavigations({ elementId, fromViewId: 0, toViewId: toDiagramId })
|
|
343
|
+
const json = j<{ navigations: Record<string, unknown>[] }>(ListElementNavigationsResponseSchema, res)
|
|
344
|
+
return (json.navigations ?? []).map(protoNavigation)
|
|
345
|
+
}),
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
|
|
349
|
+
views: {
|
|
350
|
+
list: (): Promise<View[]> =>
|
|
351
|
+
rpc(async () => {
|
|
352
|
+
const res = await workspaceClient.listViews({})
|
|
353
|
+
const json = j<{ views: Record<string, unknown>[] }>(ListViewsResponseSchema, res)
|
|
354
|
+
return (json.views ?? []).map(v => ({
|
|
355
|
+
id: Number(v.id ?? 0),
|
|
356
|
+
owner_element_id: v.owner_element_id != null ? Number(v.owner_element_id) : null,
|
|
357
|
+
name: String(v.name ?? ''),
|
|
358
|
+
label: (v.label ?? null) as string | null,
|
|
359
|
+
is_root: Boolean(v.is_root ?? false),
|
|
360
|
+
created_at: String(v.created_at ?? new Date().toISOString()),
|
|
361
|
+
updated_at: String(v.updated_at ?? new Date().toISOString()),
|
|
362
|
+
}))
|
|
363
|
+
}),
|
|
364
|
+
|
|
365
|
+
content: (id: number): Promise<{ placements: PlacedElement[]; connectors: Connector[] }> =>
|
|
366
|
+
rpc(async () => {
|
|
367
|
+
const [placementsRes, connectorsRes] = await Promise.all([
|
|
368
|
+
workspaceClient.listPlacements({ viewId: id }),
|
|
369
|
+
workspaceClient.listConnectors({ viewId: id }),
|
|
370
|
+
])
|
|
371
|
+
const placementJson = j<{ placements: Record<string, unknown>[] }>(ListPlacementsResponseSchema, placementsRes)
|
|
372
|
+
const connectorJson = j<{ connectors: Record<string, unknown>[] }>(ListConnectorsResponseSchema, connectorsRes)
|
|
373
|
+
return {
|
|
374
|
+
placements: (placementJson.placements ?? []).map(protoPlacedElement),
|
|
375
|
+
connectors: (connectorJson.connectors ?? []).map(protoConnector),
|
|
376
|
+
}
|
|
377
|
+
}),
|
|
378
|
+
|
|
379
|
+
tree: (): Promise<ViewTreeNode[]> =>
|
|
380
|
+
rpc(async () => {
|
|
381
|
+
const res = await workspaceClient.getWorkspace({ includeContent: false })
|
|
382
|
+
const json = j<{ views: ProtoDiagram[] }>(GetWorkspaceResponseSchema, res)
|
|
383
|
+
return (json.views ?? []).map(mapDiagram)
|
|
384
|
+
}),
|
|
385
|
+
|
|
386
|
+
get: (id: number): Promise<ViewTreeNode> =>
|
|
387
|
+
rpc(async () => {
|
|
388
|
+
const res = await workspaceClient.getView({ viewId: id })
|
|
389
|
+
const json = j<{ view?: ProtoDiagram }>(GetViewResponseSchema, res)
|
|
390
|
+
if (!json.view) throw new Error('View not found')
|
|
391
|
+
return mapDiagram(json.view)
|
|
392
|
+
}),
|
|
393
|
+
|
|
394
|
+
create: (data: { name: string; label?: string; parent_view_id?: number | null }): Promise<View> =>
|
|
395
|
+
rpc(async () => {
|
|
396
|
+
const res = await workspaceClient.createView({
|
|
397
|
+
name: data.name,
|
|
398
|
+
levelLabel: data.label ?? undefined,
|
|
399
|
+
ownerElementId: data.parent_view_id ?? undefined,
|
|
400
|
+
})
|
|
401
|
+
const json = j<{ view: ProtoDiagram }>(CreateViewResponseSchema, res)
|
|
402
|
+
return diagramToView(json.view)
|
|
403
|
+
}),
|
|
404
|
+
|
|
405
|
+
update: (id: number, data: { name: string; label?: string }): Promise<View> =>
|
|
406
|
+
rpc(async () => {
|
|
407
|
+
const res = await workspaceClient.updateView({ viewId: id, name: data.name, levelLabel: data.label ?? undefined })
|
|
408
|
+
const json = j<{ view: ProtoDiagram }>(UpdateViewResponseSchema, res)
|
|
409
|
+
return diagramToView(json.view)
|
|
410
|
+
}),
|
|
411
|
+
|
|
412
|
+
rename: (id: number, name: string): Promise<View> =>
|
|
413
|
+
rpc(async () => {
|
|
414
|
+
const res = await workspaceClient.updateView({ viewId: id, name })
|
|
415
|
+
const json = j<{ view: ProtoDiagram }>(UpdateViewResponseSchema, res)
|
|
416
|
+
return diagramToView(json.view)
|
|
417
|
+
}),
|
|
418
|
+
|
|
419
|
+
setLevel: (id: number, level: number): Promise<void> =>
|
|
420
|
+
rpc(async () => { await workspaceClient.setViewLevel({ viewId: id, level }) }),
|
|
421
|
+
|
|
422
|
+
delete: (_orgId: string, id: number): Promise<void> =>
|
|
423
|
+
rpc(async () => { await workspaceClient.deleteView({ orgId: '', viewId: id }) }),
|
|
424
|
+
|
|
425
|
+
thumbnail: async (_id: number): Promise<string | null> => null,
|
|
426
|
+
|
|
427
|
+
placements: {
|
|
428
|
+
list: (diagramId: number): Promise<ElementPlacement[]> =>
|
|
429
|
+
rpc(async () => {
|
|
430
|
+
const res = await workspaceClient.listPlacements({ viewId: diagramId })
|
|
431
|
+
const json = j<{ placements: Record<string, unknown>[] }>(ListPlacementsResponseSchema, res)
|
|
432
|
+
return (json.placements ?? []).map(protoPlacedElement).map(pe => ({
|
|
433
|
+
id: pe.id,
|
|
434
|
+
view_id: pe.view_id,
|
|
435
|
+
element_id: pe.element_id,
|
|
436
|
+
position_x: pe.position_x,
|
|
437
|
+
position_y: pe.position_y,
|
|
438
|
+
}))
|
|
439
|
+
}),
|
|
440
|
+
|
|
441
|
+
add: (diagramId: number, elementId: number, x = 100, y = 100): Promise<ElementPlacement> =>
|
|
442
|
+
rpc(async () => {
|
|
443
|
+
const res = await workspaceClient.createPlacement({ viewId: diagramId, elementId, positionX: x, positionY: y })
|
|
444
|
+
const json = j<{ placement: Record<string, unknown> }>(CreatePlacementResponseSchema, res)
|
|
445
|
+
const pe = protoPlacedElement(json.placement ?? {})
|
|
446
|
+
return { id: pe.id, view_id: pe.view_id, element_id: pe.element_id, position_x: pe.position_x, position_y: pe.position_y }
|
|
447
|
+
}),
|
|
448
|
+
|
|
449
|
+
updatePosition: (diagramId: number, elementId: number, x: number, y: number): Promise<void> =>
|
|
450
|
+
rpc(async () => { await workspaceClient.updatePlacementPosition({ viewId: diagramId, elementId, positionX: x, positionY: y }) }),
|
|
451
|
+
|
|
452
|
+
remove: (diagramId: number, elementId: number): Promise<void> =>
|
|
453
|
+
rpc(async () => { await workspaceClient.deletePlacement({ viewId: diagramId, elementId }) }),
|
|
454
|
+
},
|
|
455
|
+
|
|
456
|
+
layers: {
|
|
457
|
+
list: (diagramId: number): Promise<ViewLayer[]> =>
|
|
458
|
+
rpc(async () => {
|
|
459
|
+
const res = await workspaceClient.listViewLayers({ viewId: diagramId })
|
|
460
|
+
const json = j<{ layers: Record<string, unknown>[] }>(ListViewLayersResponseSchema, res)
|
|
461
|
+
return (json.layers ?? []).map(protoLayer)
|
|
462
|
+
}),
|
|
463
|
+
|
|
464
|
+
create: (diagramId: number, data: { name: string; tags: string[]; color?: string }): Promise<ViewLayer> =>
|
|
465
|
+
rpc(async () => {
|
|
466
|
+
const res = await workspaceClient.createViewLayer({ viewId: diagramId, name: data.name, tags: data.tags, color: data.color ?? '#888888' })
|
|
467
|
+
const json = j<{ layer: Record<string, unknown> }>(CreateViewLayerResponseSchema, res)
|
|
468
|
+
return protoLayer(json.layer ?? {})
|
|
469
|
+
}),
|
|
470
|
+
|
|
471
|
+
update: (_diagramId: number, layerId: number, data: Partial<ViewLayer>): Promise<ViewLayer> =>
|
|
472
|
+
rpc(async () => {
|
|
473
|
+
const res = await workspaceClient.updateViewLayer({ layerId, name: data.name ?? undefined, tags: data.tags ?? [], color: data.color ?? undefined })
|
|
474
|
+
const json = j<{ layer: Record<string, unknown> }>(UpdateViewLayerResponseSchema, res)
|
|
475
|
+
return protoLayer(json.layer ?? {})
|
|
476
|
+
}),
|
|
477
|
+
|
|
478
|
+
delete: (_diagramId: number, layerId: number): Promise<void> =>
|
|
479
|
+
rpc(async () => { await workspaceClient.deleteViewLayer({ layerId }) }),
|
|
480
|
+
},
|
|
481
|
+
|
|
482
|
+
},
|
|
483
|
+
|
|
484
|
+
connectors: {
|
|
485
|
+
list: (diagramId: number): Promise<Connector[]> =>
|
|
486
|
+
rpc(async () => {
|
|
487
|
+
const res = await workspaceClient.listConnectors({ viewId: diagramId })
|
|
488
|
+
const json = j<{ connectors: Record<string, unknown>[] }>(ListConnectorsResponseSchema, res)
|
|
489
|
+
return (json.connectors ?? []).map(protoConnector)
|
|
490
|
+
}),
|
|
491
|
+
|
|
492
|
+
create: (
|
|
493
|
+
diagramId: number,
|
|
494
|
+
data: {
|
|
495
|
+
source_element_id: number
|
|
496
|
+
target_element_id: number
|
|
497
|
+
label?: string
|
|
498
|
+
description?: string
|
|
499
|
+
relationship?: string
|
|
500
|
+
direction?: string
|
|
501
|
+
style?: string
|
|
502
|
+
url?: string
|
|
503
|
+
source_handle?: string | null
|
|
504
|
+
target_handle?: string | null
|
|
505
|
+
},
|
|
506
|
+
): Promise<Connector> =>
|
|
507
|
+
rpc(async () => {
|
|
508
|
+
const res = await workspaceClient.createConnector({
|
|
509
|
+
viewId: diagramId,
|
|
510
|
+
sourceElementId: data.source_element_id,
|
|
511
|
+
targetElementId: data.target_element_id,
|
|
512
|
+
label: data.label ?? undefined,
|
|
513
|
+
description: data.description ?? undefined,
|
|
514
|
+
relationship: data.relationship ?? undefined,
|
|
515
|
+
direction: data.direction ?? undefined,
|
|
516
|
+
style: data.style ?? undefined,
|
|
517
|
+
url: data.url ?? undefined,
|
|
518
|
+
sourceHandle: data.source_handle ?? undefined,
|
|
519
|
+
targetHandle: data.target_handle ?? undefined,
|
|
520
|
+
})
|
|
521
|
+
const json = j<{ connector: Record<string, unknown> }>(CreateConnectorResponseSchema, res)
|
|
522
|
+
return protoConnector(json.connector ?? {})
|
|
523
|
+
}),
|
|
524
|
+
|
|
525
|
+
update: (
|
|
526
|
+
_diagramId: number,
|
|
527
|
+
connectorId: number,
|
|
528
|
+
data: {
|
|
529
|
+
source_element_id?: number
|
|
530
|
+
target_element_id?: number
|
|
531
|
+
label?: string
|
|
532
|
+
description?: string
|
|
533
|
+
relationship?: string
|
|
534
|
+
direction?: string
|
|
535
|
+
style?: string
|
|
536
|
+
url?: string
|
|
537
|
+
source_handle?: string | null
|
|
538
|
+
target_handle?: string | null
|
|
539
|
+
},
|
|
540
|
+
): Promise<Connector> =>
|
|
541
|
+
rpc(async () => {
|
|
542
|
+
const res = await workspaceClient.updateConnector({
|
|
543
|
+
connectorId,
|
|
544
|
+
sourceElementId: data.source_element_id ?? undefined,
|
|
545
|
+
targetElementId: data.target_element_id ?? undefined,
|
|
546
|
+
label: data.label ?? undefined,
|
|
547
|
+
description: data.description ?? undefined,
|
|
548
|
+
relationship: data.relationship ?? undefined,
|
|
549
|
+
direction: data.direction ?? undefined,
|
|
550
|
+
style: data.style ?? undefined,
|
|
551
|
+
url: data.url ?? undefined,
|
|
552
|
+
sourceHandle: data.source_handle ?? undefined,
|
|
553
|
+
targetHandle: data.target_handle ?? undefined,
|
|
554
|
+
})
|
|
555
|
+
const json = j<{ connector: Record<string, unknown> }>(UpdateConnectorResponseSchema, res)
|
|
556
|
+
return protoConnector(json.connector ?? {})
|
|
557
|
+
}),
|
|
558
|
+
|
|
559
|
+
delete: (_orgId: string, connectorId: number): Promise<void> =>
|
|
560
|
+
rpc(async () => { await workspaceClient.deleteConnector({ orgId: '', connectorId }) }),
|
|
561
|
+
},
|
|
562
|
+
},
|
|
563
|
+
|
|
564
|
+
dependencies: {
|
|
565
|
+
list: (): Promise<DependenciesResponse> =>
|
|
566
|
+
rpc(async () => {
|
|
567
|
+
const res = await dependencyClient.listDependencies({})
|
|
568
|
+
return j<DependenciesResponse>(ListDependenciesResponseSchema, res)
|
|
569
|
+
}),
|
|
570
|
+
},
|
|
571
|
+
|
|
572
|
+
explore: {
|
|
573
|
+
load: (): Promise<ExploreData & { password_required?: boolean }> =>
|
|
574
|
+
rpc(async () => {
|
|
575
|
+
const res = await workspaceClient.getWorkspace({ includeContent: true })
|
|
576
|
+
const json = j<{
|
|
577
|
+
views: ProtoDiagram[]
|
|
578
|
+
content: Record<string, { placements: Record<string, unknown>[]; connectors: Record<string, unknown>[] }>
|
|
579
|
+
navigations: Record<string, unknown>[]
|
|
580
|
+
}>(GetWorkspaceResponseSchema, res)
|
|
581
|
+
return {
|
|
582
|
+
tree: (json.views ?? []).map(mapDiagram),
|
|
583
|
+
views: Object.fromEntries(
|
|
584
|
+
Object.entries(json.content ?? {}).map(([key, value]) => [
|
|
585
|
+
key,
|
|
586
|
+
{
|
|
587
|
+
placements: (value.placements ?? []).map(protoPlacedElement),
|
|
588
|
+
connectors: (value.connectors ?? []).map(protoConnector),
|
|
589
|
+
},
|
|
590
|
+
])
|
|
591
|
+
),
|
|
592
|
+
navigations: (json.navigations ?? []).map(protoNavigation),
|
|
593
|
+
password_required: false,
|
|
594
|
+
}
|
|
595
|
+
}),
|
|
596
|
+
},
|
|
597
|
+
|
|
598
|
+
import: {
|
|
599
|
+
resources: (orgId: string, data: { elements: PlanElement[]; connectors: PlanConnector[] }): Promise<{ view_id: number; view_url: string }> =>
|
|
600
|
+
rpc(async () => {
|
|
601
|
+
const res = await importClient.importResources({
|
|
602
|
+
orgId,
|
|
603
|
+
elements: data.elements,
|
|
604
|
+
connectors: data.connectors,
|
|
605
|
+
})
|
|
606
|
+
return { view_id: res.viewId, view_url: res.viewUrl }
|
|
607
|
+
}),
|
|
608
|
+
parseStructurizr: (code: string): Promise<{ elements: PlanElement[]; connectors: PlanConnector[]; warnings: string[] }> =>
|
|
609
|
+
rpc(async () => {
|
|
610
|
+
const res = await importClient.parseStructurizr({ code })
|
|
611
|
+
return {
|
|
612
|
+
elements: res.elements,
|
|
613
|
+
connectors: res.connectors,
|
|
614
|
+
warnings: res.warnings,
|
|
615
|
+
}
|
|
616
|
+
}),
|
|
617
|
+
},
|
|
618
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VS Code webview transport.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the session-cookie transport with Bearer token auth.
|
|
5
|
+
* The API key and server URL are injected by the extension host
|
|
6
|
+
* via window globals before this script runs.
|
|
7
|
+
*/
|
|
8
|
+
import { createConnectTransport } from '@connectrpc/connect-web'
|
|
9
|
+
|
|
10
|
+
declare global {
|
|
11
|
+
interface Window {
|
|
12
|
+
__TLD_API_KEY__?: string
|
|
13
|
+
__TLD_SERVER_URL__?: string
|
|
14
|
+
__TLD_DIAGRAM_ID__?: number
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const serverUrl = (window.__TLD_SERVER_URL__ ?? 'https://tldiagram.com').replace(/\/$/, '')
|
|
19
|
+
const apiKey = window.__TLD_API_KEY__ ?? ''
|
|
20
|
+
|
|
21
|
+
export const transport = createConnectTransport({
|
|
22
|
+
baseUrl: `${serverUrl}/api`,
|
|
23
|
+
fetch: (input, init) => {
|
|
24
|
+
const headers = new Headers(init?.headers)
|
|
25
|
+
if (apiKey) headers.set('Authorization', `Bearer ${apiKey}`)
|
|
26
|
+
return fetch(input, { ...init, headers })
|
|
27
|
+
},
|
|
28
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80">
|
|
3
|
+
<defs>
|
|
4
|
+
<filter id="glow" x="-40%" y="-40%" width="180%" height="180%">
|
|
5
|
+
<feGaussianBlur in="SourceAlpha" stdDeviation="32" result="blur1" />
|
|
6
|
+
<feFlood flood-color="#63b3ed" flood-opacity="0.3" result="c1" />
|
|
7
|
+
<feComposite in="c1" in2="blur1" operator="in" result="glow1" />
|
|
8
|
+
<feGaussianBlur in="SourceAlpha" stdDeviation="10" result="blur2" />
|
|
9
|
+
<feFlood flood-color="#90cdf4" flood-opacity="0.5" result="c2" />
|
|
10
|
+
<feComposite in="c2" in2="blur2" operator="in" result="glow2" />
|
|
11
|
+
<feMerge>
|
|
12
|
+
<feMergeNode in="glow1" />
|
|
13
|
+
<feMergeNode in="glow2" />
|
|
14
|
+
<feMergeNode in="SourceGraphic" />
|
|
15
|
+
</feMerge>
|
|
16
|
+
</filter>
|
|
17
|
+
<linearGradient id="grad" x1="0" y1="0" x2="0.6" y2="1">
|
|
18
|
+
<stop offset="0" stop-color="#90cdf4" />
|
|
19
|
+
<stop offset="0.45" stop-color="#63b3ed" />
|
|
20
|
+
<stop offset="1" stop-color="#2b6cb0" />
|
|
21
|
+
</linearGradient>
|
|
22
|
+
</defs>
|
|
23
|
+
<!-- Scale 1024→80 (×0.078125), then apply original inner transform -->
|
|
24
|
+
<g transform="scale(0.078125)" fill-rule="evenodd">
|
|
25
|
+
<g filter="url(#glow)" transform="translate(78,118) scale(0.8)">
|
|
26
|
+
<path
|
|
27
|
+
d="M201 18s169-39 340-2c171 38 342 152 342 457S713 902 544 949c-170 48-344 19-344 19l1-566h302V217H201z M455 715c-67 83-122 141-62 48q23-35 33-62h-4a78 78 0 1 1 78-78q0 24-12 44-11 21-33 48"
|
|
28
|
+
fill="url(#grad)" />
|
|
29
|
+
</g>
|
|
30
|
+
</g>
|
|
31
|
+
</svg>
|