@flowdrop/flowdrop 1.4.0 → 1.5.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/README.md +68 -24
- package/dist/adapters/WorkflowAdapter.js +2 -22
- package/dist/adapters/agentspec/autoLayout.d.ts +51 -5
- package/dist/adapters/agentspec/autoLayout.js +120 -23
- package/dist/chat/commandClassifier.d.ts +19 -0
- package/dist/chat/commandClassifier.js +30 -0
- package/dist/chat/index.d.ts +27 -0
- package/dist/chat/index.js +32 -0
- package/dist/chat/responseParser.d.ts +21 -0
- package/dist/chat/responseParser.js +87 -0
- package/dist/commands/batch.d.ts +18 -0
- package/dist/commands/batch.js +56 -0
- package/dist/commands/executor.d.ts +37 -0
- package/dist/commands/executor.js +1044 -0
- package/dist/commands/index.d.ts +14 -0
- package/dist/commands/index.js +17 -0
- package/dist/commands/parser.d.ts +16 -0
- package/dist/commands/parser.js +278 -0
- package/dist/commands/positioner.d.ts +19 -0
- package/dist/commands/positioner.js +33 -0
- package/dist/commands/storeIntegration.svelte.d.ts +16 -0
- package/dist/commands/storeIntegration.svelte.js +67 -0
- package/dist/commands/types.d.ts +343 -0
- package/dist/commands/types.js +45 -0
- package/dist/components/App.svelte +351 -12
- package/dist/components/App.svelte.d.ts +3 -0
- package/dist/components/CanvasController.svelte +38 -0
- package/dist/components/CanvasController.svelte.d.ts +32 -0
- package/dist/components/ConfigMappingRow.svelte +130 -0
- package/dist/components/ConfigMappingRow.svelte.d.ts +8 -0
- package/dist/components/ConfigPanel.svelte +56 -7
- package/dist/components/ConfigPanel.svelte.d.ts +2 -0
- package/dist/components/FlowDropEdge.svelte +2 -10
- package/dist/components/LogsSidebar.svelte +5 -5
- package/dist/components/NodeSidebar.svelte +15 -49
- package/dist/components/NodeSwapPicker.svelte +537 -0
- package/dist/components/NodeSwapPicker.svelte.d.ts +16 -0
- package/dist/components/PortMappingRow.svelte +209 -0
- package/dist/components/PortMappingRow.svelte.d.ts +12 -0
- package/dist/components/SwapMappingEditor.svelte +550 -0
- package/dist/components/SwapMappingEditor.svelte.d.ts +12 -0
- package/dist/components/WorkflowEditor.svelte +99 -4
- package/dist/components/WorkflowEditor.svelte.d.ts +8 -0
- package/dist/components/chat/AIChatPanel.svelte +658 -0
- package/dist/components/chat/AIChatPanel.svelte.d.ts +13 -0
- package/dist/components/chat/CommandPreview.svelte +184 -0
- package/dist/components/chat/CommandPreview.svelte.d.ts +9 -0
- package/dist/components/console/CommandConsole.stories.svelte +93 -0
- package/dist/components/console/CommandConsole.stories.svelte.d.ts +27 -0
- package/dist/components/console/CommandConsole.svelte +259 -0
- package/dist/components/console/CommandConsole.svelte.d.ts +11 -0
- package/dist/components/console/ConsoleAutocomplete.svelte +139 -0
- package/dist/components/console/ConsoleAutocomplete.svelte.d.ts +21 -0
- package/dist/components/console/ConsoleInput.svelte +712 -0
- package/dist/components/console/ConsoleInput.svelte.d.ts +16 -0
- package/dist/components/console/ConsoleOutput.svelte +121 -0
- package/dist/components/console/ConsoleOutput.svelte.d.ts +11 -0
- package/dist/components/console/formatters.d.ts +26 -0
- package/dist/components/console/formatters.js +118 -0
- package/dist/components/interrupt/index.d.ts +1 -0
- package/dist/components/interrupt/index.js +1 -0
- package/dist/config/endpoints.d.ts +8 -0
- package/dist/config/endpoints.js +5 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.js +9 -0
- package/dist/editor/index.d.ts +3 -1
- package/dist/editor/index.js +4 -2
- package/dist/helpers/proximityConnect.js +8 -1
- package/dist/helpers/workflowEditorHelper.d.ts +3 -53
- package/dist/helpers/workflowEditorHelper.js +13 -228
- package/dist/playground/index.d.ts +1 -1
- package/dist/playground/index.js +1 -1
- package/dist/schemas/v1/workflow.schema.json +107 -22
- package/dist/services/chatService.d.ts +65 -0
- package/dist/services/chatService.js +131 -0
- package/dist/services/historyService.d.ts +6 -4
- package/dist/services/historyService.js +21 -6
- package/dist/stores/interruptStore.svelte.js +6 -1
- package/dist/stores/playgroundStore.svelte.d.ts +1 -1
- package/dist/stores/playgroundStore.svelte.js +11 -2
- package/dist/stores/portCoordinateStore.svelte.d.ts +4 -0
- package/dist/stores/portCoordinateStore.svelte.js +20 -26
- package/dist/stores/workflowStore.svelte.d.ts +31 -2
- package/dist/stores/workflowStore.svelte.js +84 -64
- package/dist/types/chat.d.ts +63 -0
- package/dist/types/chat.js +9 -0
- package/dist/types/events.d.ts +28 -2
- package/dist/types/events.js +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/settings.d.ts +6 -0
- package/dist/types/settings.js +3 -0
- package/dist/utils/edgeStyling.d.ts +42 -0
- package/dist/utils/edgeStyling.js +176 -0
- package/dist/utils/nodeIds.d.ts +31 -0
- package/dist/utils/nodeIds.js +42 -0
- package/dist/utils/nodeSwap.d.ts +221 -0
- package/dist/utils/nodeSwap.js +686 -0
- package/package.json +6 -1
- package/dist/helpers/nodeLayoutHelper.d.ts +0 -14
- package/dist/helpers/nodeLayoutHelper.js +0 -19
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command DSL Type System
|
|
3
|
+
*
|
|
4
|
+
* Defines all command types, result types, context interfaces, and utilities
|
|
5
|
+
* for the FlowDrop Workflow Command DSL. Zero runtime code except buildTypeMap().
|
|
6
|
+
*
|
|
7
|
+
* @module commands/types
|
|
8
|
+
*/
|
|
9
|
+
import type { NodeMetadata, Workflow, WorkflowNode, WorkflowEdge } from "../types/index.js";
|
|
10
|
+
export interface AddNodeCommand {
|
|
11
|
+
type: "add_node";
|
|
12
|
+
nodeTypeId: string;
|
|
13
|
+
position?: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface DeleteNodeCommand {
|
|
19
|
+
type: "delete_node";
|
|
20
|
+
nodeId: string;
|
|
21
|
+
}
|
|
22
|
+
export interface RenameNodeCommand {
|
|
23
|
+
type: "rename_node";
|
|
24
|
+
nodeId: string;
|
|
25
|
+
label: string;
|
|
26
|
+
}
|
|
27
|
+
export interface SetConfigCommand {
|
|
28
|
+
type: "set_config";
|
|
29
|
+
nodeId: string;
|
|
30
|
+
key: string;
|
|
31
|
+
value: string;
|
|
32
|
+
/** When true, validation errors reject the command instead of warning */
|
|
33
|
+
strict?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface GetConfigCommand {
|
|
36
|
+
type: "get_config";
|
|
37
|
+
nodeId: string;
|
|
38
|
+
key: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ConnectCommand {
|
|
41
|
+
type: "connect";
|
|
42
|
+
sourceNodeId: string;
|
|
43
|
+
sourcePort: string;
|
|
44
|
+
targetNodeId: string;
|
|
45
|
+
targetPort: string;
|
|
46
|
+
}
|
|
47
|
+
export interface DisconnectPortsCommand {
|
|
48
|
+
type: "disconnect_ports";
|
|
49
|
+
sourceNodeId: string;
|
|
50
|
+
sourcePort: string;
|
|
51
|
+
targetNodeId: string;
|
|
52
|
+
targetPort: string;
|
|
53
|
+
}
|
|
54
|
+
export interface DisconnectNodeCommand {
|
|
55
|
+
type: "disconnect_node";
|
|
56
|
+
nodeId: string;
|
|
57
|
+
}
|
|
58
|
+
export interface ListNodesCommand {
|
|
59
|
+
type: "list_nodes";
|
|
60
|
+
}
|
|
61
|
+
export interface ListEdgesCommand {
|
|
62
|
+
type: "list_edges";
|
|
63
|
+
}
|
|
64
|
+
export interface ListTypesCommand {
|
|
65
|
+
type: "list_types";
|
|
66
|
+
}
|
|
67
|
+
export interface InfoCommand {
|
|
68
|
+
type: "info";
|
|
69
|
+
nodeId: string;
|
|
70
|
+
}
|
|
71
|
+
export interface UndoCommand {
|
|
72
|
+
type: "undo";
|
|
73
|
+
}
|
|
74
|
+
export interface RedoCommand {
|
|
75
|
+
type: "redo";
|
|
76
|
+
}
|
|
77
|
+
export interface ConfigOpenCommand {
|
|
78
|
+
type: "config_open";
|
|
79
|
+
nodeId: string;
|
|
80
|
+
}
|
|
81
|
+
export interface SelectNodeCommand {
|
|
82
|
+
type: "select_node";
|
|
83
|
+
nodeId: string;
|
|
84
|
+
}
|
|
85
|
+
export interface HelpCommand {
|
|
86
|
+
type: "help";
|
|
87
|
+
command?: string;
|
|
88
|
+
}
|
|
89
|
+
export interface ClearCommand {
|
|
90
|
+
type: "clear";
|
|
91
|
+
}
|
|
92
|
+
/** Phase 2 commands */
|
|
93
|
+
export interface SwapNodeCommand {
|
|
94
|
+
type: "swap_node";
|
|
95
|
+
nodeId: string;
|
|
96
|
+
newTypeId: string;
|
|
97
|
+
}
|
|
98
|
+
export interface MoveNodeCommand {
|
|
99
|
+
type: "move_node";
|
|
100
|
+
nodeId: string;
|
|
101
|
+
position: {
|
|
102
|
+
x: number;
|
|
103
|
+
y: number;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export interface AutoLayoutCommand {
|
|
107
|
+
type: "auto_layout";
|
|
108
|
+
direction?: "horizontal" | "vertical";
|
|
109
|
+
}
|
|
110
|
+
export interface BeautifyLayoutCommand {
|
|
111
|
+
type: "beautify_layout";
|
|
112
|
+
}
|
|
113
|
+
/** Canvas viewport commands */
|
|
114
|
+
export interface CanvasFitViewCommand {
|
|
115
|
+
type: "canvas_fit_view";
|
|
116
|
+
}
|
|
117
|
+
export interface CanvasZoomInCommand {
|
|
118
|
+
type: "canvas_zoom_in";
|
|
119
|
+
}
|
|
120
|
+
export interface CanvasZoomOutCommand {
|
|
121
|
+
type: "canvas_zoom_out";
|
|
122
|
+
}
|
|
123
|
+
export interface CanvasZoomToCommand {
|
|
124
|
+
type: "canvas_zoom_to";
|
|
125
|
+
level: number;
|
|
126
|
+
}
|
|
127
|
+
export interface CanvasPanToCommand {
|
|
128
|
+
type: "canvas_pan_to";
|
|
129
|
+
position: {
|
|
130
|
+
x: number;
|
|
131
|
+
y: number;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export interface CanvasResetViewCommand {
|
|
135
|
+
type: "canvas_reset_view";
|
|
136
|
+
}
|
|
137
|
+
/** Discriminated union of all commands */
|
|
138
|
+
export type Command = AddNodeCommand | DeleteNodeCommand | RenameNodeCommand | SetConfigCommand | GetConfigCommand | ConnectCommand | DisconnectPortsCommand | DisconnectNodeCommand | ListNodesCommand | ListEdgesCommand | ListTypesCommand | InfoCommand | UndoCommand | RedoCommand | ConfigOpenCommand | SelectNodeCommand | HelpCommand | ClearCommand | SwapNodeCommand | MoveNodeCommand | AutoLayoutCommand | BeautifyLayoutCommand | CanvasFitViewCommand | CanvasZoomInCommand | CanvasZoomOutCommand | CanvasZoomToCommand | CanvasPanToCommand | CanvasResetViewCommand;
|
|
139
|
+
export type ParseResult = {
|
|
140
|
+
ok: true;
|
|
141
|
+
command: Command;
|
|
142
|
+
} | {
|
|
143
|
+
ok: false;
|
|
144
|
+
error: string;
|
|
145
|
+
input: string;
|
|
146
|
+
};
|
|
147
|
+
export type CommandErrorCode = "NODE_NOT_FOUND" | "NODE_TYPE_NOT_FOUND" | "PORT_NOT_FOUND" | "EDGE_NOT_FOUND" | "INVALID_CONNECTION" | "CYCLE_DETECTED" | "NO_WORKFLOW" | "PARSE_ERROR" | "UNKNOWN_COMMAND" | "CONFIG_KEY_NOT_FOUND" | "CONFIG_VALIDATION_ERROR" | "UNDO_UNAVAILABLE" | "REDO_UNAVAILABLE";
|
|
148
|
+
/** Result data for add_node — nodeId is DSL-format short ID (e.g. "llm_node.1") */
|
|
149
|
+
export interface AddNodeResultData {
|
|
150
|
+
nodeId: string;
|
|
151
|
+
type: string;
|
|
152
|
+
label: string;
|
|
153
|
+
position: {
|
|
154
|
+
x: number;
|
|
155
|
+
y: number;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/** Result data for list_nodes — all IDs are DSL-format short IDs */
|
|
159
|
+
export interface ListNodesResultData {
|
|
160
|
+
nodes: Array<{
|
|
161
|
+
nodeId: string;
|
|
162
|
+
label: string;
|
|
163
|
+
type: string;
|
|
164
|
+
}>;
|
|
165
|
+
}
|
|
166
|
+
/** Result data for list_edges — all IDs are DSL-format short IDs */
|
|
167
|
+
export interface ListEdgesResultData {
|
|
168
|
+
edges: Array<{
|
|
169
|
+
edgeId: string;
|
|
170
|
+
sourceNodeId: string;
|
|
171
|
+
sourcePort: string;
|
|
172
|
+
targetNodeId: string;
|
|
173
|
+
targetPort: string;
|
|
174
|
+
}>;
|
|
175
|
+
}
|
|
176
|
+
/** Result data for list_types — type IDs are short names usable with add command */
|
|
177
|
+
export interface ListTypesResultData {
|
|
178
|
+
types: Array<{
|
|
179
|
+
typeId: string;
|
|
180
|
+
name: string;
|
|
181
|
+
category: string;
|
|
182
|
+
}>;
|
|
183
|
+
}
|
|
184
|
+
/** Result data for info command — all IDs are DSL-format short IDs */
|
|
185
|
+
export interface InfoResultData {
|
|
186
|
+
nodeId: string;
|
|
187
|
+
label: string;
|
|
188
|
+
type: string;
|
|
189
|
+
position: {
|
|
190
|
+
x: number;
|
|
191
|
+
y: number;
|
|
192
|
+
};
|
|
193
|
+
config: Record<string, unknown>;
|
|
194
|
+
inputs: Array<{
|
|
195
|
+
portId: string;
|
|
196
|
+
name: string;
|
|
197
|
+
dataType: string;
|
|
198
|
+
}>;
|
|
199
|
+
outputs: Array<{
|
|
200
|
+
portId: string;
|
|
201
|
+
name: string;
|
|
202
|
+
dataType: string;
|
|
203
|
+
}>;
|
|
204
|
+
connectedEdges: Array<{
|
|
205
|
+
edgeId: string;
|
|
206
|
+
direction: "incoming" | "outgoing";
|
|
207
|
+
remoteNodeId: string;
|
|
208
|
+
remotePort: string;
|
|
209
|
+
localPort: string;
|
|
210
|
+
}>;
|
|
211
|
+
}
|
|
212
|
+
/** Result data for get_config command */
|
|
213
|
+
export interface GetConfigResultData {
|
|
214
|
+
nodeId: string;
|
|
215
|
+
key: string;
|
|
216
|
+
value: unknown;
|
|
217
|
+
}
|
|
218
|
+
/** Result data for help command */
|
|
219
|
+
export interface HelpResultData {
|
|
220
|
+
commands: Array<{
|
|
221
|
+
name: string;
|
|
222
|
+
syntax: string;
|
|
223
|
+
description: string;
|
|
224
|
+
}>;
|
|
225
|
+
}
|
|
226
|
+
/** Result data for set_config command — includes validation warnings */
|
|
227
|
+
export interface SetConfigResultData {
|
|
228
|
+
nodeId: string;
|
|
229
|
+
key: string;
|
|
230
|
+
value: unknown;
|
|
231
|
+
/** Validation warnings (non-blocking unless strict mode) */
|
|
232
|
+
warnings?: Array<{
|
|
233
|
+
type: "enum" | "type_mismatch";
|
|
234
|
+
message: string;
|
|
235
|
+
allowedValues?: unknown[];
|
|
236
|
+
expectedType?: string;
|
|
237
|
+
actualType?: string;
|
|
238
|
+
}>;
|
|
239
|
+
}
|
|
240
|
+
/** Result data for swap_node command */
|
|
241
|
+
export interface SwapNodeResultData {
|
|
242
|
+
oldNodeId: string;
|
|
243
|
+
newNodeId: string;
|
|
244
|
+
newType: string;
|
|
245
|
+
keptEdges: number;
|
|
246
|
+
droppedEdges: number;
|
|
247
|
+
hasDataLoss: boolean;
|
|
248
|
+
configCarriedOver: string[];
|
|
249
|
+
configReset: string[];
|
|
250
|
+
}
|
|
251
|
+
/** Result data types union for typed access */
|
|
252
|
+
export type CommandResultData = AddNodeResultData | ListNodesResultData | ListEdgesResultData | ListTypesResultData | InfoResultData | GetConfigResultData | SetConfigResultData | HelpResultData | SwapNodeResultData;
|
|
253
|
+
/** Successful command result */
|
|
254
|
+
export interface CommandResultOk {
|
|
255
|
+
ok: true;
|
|
256
|
+
message: string;
|
|
257
|
+
data?: CommandResultData;
|
|
258
|
+
/** Set when a UI action was requested but emitUIAction was not provided */
|
|
259
|
+
uiActionPending?: boolean;
|
|
260
|
+
}
|
|
261
|
+
/** Failed command result */
|
|
262
|
+
export interface CommandResultError {
|
|
263
|
+
ok: false;
|
|
264
|
+
error: string;
|
|
265
|
+
code: CommandErrorCode;
|
|
266
|
+
}
|
|
267
|
+
/** Result of executing a command */
|
|
268
|
+
export type CommandResult = CommandResultOk | CommandResultError;
|
|
269
|
+
export interface BatchResult {
|
|
270
|
+
ok: boolean;
|
|
271
|
+
results: CommandResult[];
|
|
272
|
+
completedCount: number;
|
|
273
|
+
totalCount: number;
|
|
274
|
+
error?: string;
|
|
275
|
+
}
|
|
276
|
+
export type UIAction = {
|
|
277
|
+
type: "open_config";
|
|
278
|
+
nodeId: string;
|
|
279
|
+
} | {
|
|
280
|
+
type: "select_node";
|
|
281
|
+
nodeId: string;
|
|
282
|
+
} | {
|
|
283
|
+
type: "canvas_fit_view";
|
|
284
|
+
} | {
|
|
285
|
+
type: "canvas_zoom_in";
|
|
286
|
+
} | {
|
|
287
|
+
type: "canvas_zoom_out";
|
|
288
|
+
} | {
|
|
289
|
+
type: "canvas_zoom_to";
|
|
290
|
+
level: number;
|
|
291
|
+
} | {
|
|
292
|
+
type: "canvas_pan_to";
|
|
293
|
+
position: {
|
|
294
|
+
x: number;
|
|
295
|
+
y: number;
|
|
296
|
+
};
|
|
297
|
+
} | {
|
|
298
|
+
type: "canvas_reset_view";
|
|
299
|
+
};
|
|
300
|
+
export interface CommandDispatch {
|
|
301
|
+
addNode(node: WorkflowNode): void;
|
|
302
|
+
removeNode(nodeId: string): void;
|
|
303
|
+
updateNode(nodeId: string, updates: Partial<Pick<WorkflowNode, "data" | "position">>): void;
|
|
304
|
+
addEdge(edge: WorkflowEdge): void;
|
|
305
|
+
removeEdge(edgeId: string): void;
|
|
306
|
+
batchUpdate(updates: {
|
|
307
|
+
nodes?: WorkflowNode[];
|
|
308
|
+
edges?: WorkflowEdge[];
|
|
309
|
+
}): void;
|
|
310
|
+
undo(): boolean;
|
|
311
|
+
redo(): boolean;
|
|
312
|
+
startTransaction(description: string): void;
|
|
313
|
+
commitTransaction(): void;
|
|
314
|
+
cancelTransaction(): void;
|
|
315
|
+
/** Optional callback for UI-side actions (open config panel, select node) */
|
|
316
|
+
emitUIAction?: (action: UIAction) => void;
|
|
317
|
+
/** Optional swap operation for swap command */
|
|
318
|
+
swapNode?: (updates: {
|
|
319
|
+
nodes: WorkflowNode[];
|
|
320
|
+
edges: WorkflowEdge[];
|
|
321
|
+
}) => void;
|
|
322
|
+
}
|
|
323
|
+
export interface CommandContext {
|
|
324
|
+
/** Returns the current workflow state (live, not snapshot) */
|
|
325
|
+
getWorkflow(): Workflow | null;
|
|
326
|
+
/** Available node type definitions */
|
|
327
|
+
nodeTypes: NodeMetadata[];
|
|
328
|
+
/** Map from short type ID (e.g. "llm_node") to full NodeMetadata */
|
|
329
|
+
typeMap: Map<string, NodeMetadata>;
|
|
330
|
+
/** Dispatch interface for mutating workflow state */
|
|
331
|
+
dispatch: CommandDispatch;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Build a lookup map from short type IDs to NodeMetadata.
|
|
335
|
+
*
|
|
336
|
+
* For namespaced IDs like "agentspec.llm_node", creates entries for both:
|
|
337
|
+
* - The full ID: "agentspec.llm_node"
|
|
338
|
+
* - The short suffix: "llm_node"
|
|
339
|
+
*
|
|
340
|
+
* Short IDs take precedence only if unique. If multiple namespaces define
|
|
341
|
+
* the same short ID, only the full namespaced ID is usable.
|
|
342
|
+
*/
|
|
343
|
+
export declare function buildTypeMap(nodeTypes: NodeMetadata[]): Map<string, NodeMetadata>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command DSL Type System
|
|
3
|
+
*
|
|
4
|
+
* Defines all command types, result types, context interfaces, and utilities
|
|
5
|
+
* for the FlowDrop Workflow Command DSL. Zero runtime code except buildTypeMap().
|
|
6
|
+
*
|
|
7
|
+
* @module commands/types
|
|
8
|
+
*/
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Type Map Builder
|
|
11
|
+
// ============================================================================
|
|
12
|
+
/**
|
|
13
|
+
* Build a lookup map from short type IDs to NodeMetadata.
|
|
14
|
+
*
|
|
15
|
+
* For namespaced IDs like "agentspec.llm_node", creates entries for both:
|
|
16
|
+
* - The full ID: "agentspec.llm_node"
|
|
17
|
+
* - The short suffix: "llm_node"
|
|
18
|
+
*
|
|
19
|
+
* Short IDs take precedence only if unique. If multiple namespaces define
|
|
20
|
+
* the same short ID, only the full namespaced ID is usable.
|
|
21
|
+
*/
|
|
22
|
+
export function buildTypeMap(nodeTypes) {
|
|
23
|
+
const map = new Map();
|
|
24
|
+
const shortIdCounts = new Map();
|
|
25
|
+
// First pass: register full IDs and count short ID occurrences
|
|
26
|
+
for (const metadata of nodeTypes) {
|
|
27
|
+
map.set(metadata.id, metadata);
|
|
28
|
+
const dotIndex = metadata.id.indexOf(".");
|
|
29
|
+
if (dotIndex !== -1) {
|
|
30
|
+
const shortId = metadata.id.substring(dotIndex + 1);
|
|
31
|
+
shortIdCounts.set(shortId, (shortIdCounts.get(shortId) ?? 0) + 1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Second pass: register unique short IDs
|
|
35
|
+
for (const metadata of nodeTypes) {
|
|
36
|
+
const dotIndex = metadata.id.indexOf(".");
|
|
37
|
+
if (dotIndex !== -1) {
|
|
38
|
+
const shortId = metadata.id.substring(dotIndex + 1);
|
|
39
|
+
if (shortIdCounts.get(shortId) === 1) {
|
|
40
|
+
map.set(shortId, metadata);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return map;
|
|
45
|
+
}
|