@valerypopoff/rivet2-core 2.0.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/LICENSE +7 -0
- package/README.md +15 -0
- package/dist/cjs/bundle.cjs +28772 -0
- package/dist/cjs/bundle.cjs.map +7 -0
- package/dist/esm/api/createProcessor.js +116 -0
- package/dist/esm/api/looseDataValue.js +16 -0
- package/dist/esm/api/processSettings.js +16 -0
- package/dist/esm/api/streaming.js +116 -0
- package/dist/esm/exports.js +48 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/integrations/AudioProvider.js +1 -0
- package/dist/esm/integrations/CodeRunner.js +44 -0
- package/dist/esm/integrations/DatasetProvider.js +92 -0
- package/dist/esm/integrations/EmbeddingGenerator.js +1 -0
- package/dist/esm/integrations/GptTokenizerTokenizer.js +67 -0
- package/dist/esm/integrations/LLMProvider.js +1 -0
- package/dist/esm/integrations/Tokenizer.js +1 -0
- package/dist/esm/integrations/VectorDatabase.js +1 -0
- package/dist/esm/integrations/enableIntegrations.js +3 -0
- package/dist/esm/integrations/integrations.js +19 -0
- package/dist/esm/integrations/mcp/MCPBase.js +87 -0
- package/dist/esm/integrations/mcp/MCPProvider.js +23 -0
- package/dist/esm/integrations/mcp/MCPUtils.js +33 -0
- package/dist/esm/integrations/openai/OpenAIEmbeddingGenerator.js +23 -0
- package/dist/esm/model/CycleDetector.js +43 -0
- package/dist/esm/model/DataValue.js +188 -0
- package/dist/esm/model/Dataset.js +1 -0
- package/dist/esm/model/EditorDefinition.js +1 -0
- package/dist/esm/model/ExecutorProtocol.js +1 -0
- package/dist/esm/model/GraphPreprocessor.js +97 -0
- package/dist/esm/model/GraphProcessor.js +1136 -0
- package/dist/esm/model/NodeBase.js +11 -0
- package/dist/esm/model/NodeBodySpec.js +1 -0
- package/dist/esm/model/NodeDefinition.js +12 -0
- package/dist/esm/model/NodeExecutionPlanner.js +82 -0
- package/dist/esm/model/NodeGraph.js +14 -0
- package/dist/esm/model/NodeImpl.js +57 -0
- package/dist/esm/model/NodeRegistration.js +146 -0
- package/dist/esm/model/Nodes.js +279 -0
- package/dist/esm/model/PluginLoadSpec.js +1 -0
- package/dist/esm/model/ProcessContext.js +1 -0
- package/dist/esm/model/ProcessContextBuilder.js +33 -0
- package/dist/esm/model/Project.js +2 -0
- package/dist/esm/model/ProjectReferenceLoader.js +1 -0
- package/dist/esm/model/RecordingPlayer.js +262 -0
- package/dist/esm/model/RegistryAssembly.js +53 -0
- package/dist/esm/model/RivetPlugin.js +1 -0
- package/dist/esm/model/RivetUIContext.js +1 -0
- package/dist/esm/model/Settings.js +1 -0
- package/dist/esm/model/SplitRunProcessor.js +98 -0
- package/dist/esm/model/SubprocessorBridge.js +82 -0
- package/dist/esm/model/chat/aiSdkMessages.js +105 -0
- package/dist/esm/model/chat/aiSdkStreaming.js +38 -0
- package/dist/esm/model/chat/aiSdkTools.js +10 -0
- package/dist/esm/model/chat/chatCost.js +33 -0
- package/dist/esm/model/chat/chatMessages.js +47 -0
- package/dist/esm/model/chat/openAIChatRequest.js +110 -0
- package/dist/esm/model/chat/openAIChatRuntime.js +220 -0
- package/dist/esm/model/chat/streamChatResponse.js +97 -0
- package/dist/esm/model/chat/tokenBudget.js +16 -0
- package/dist/esm/model/chat-v2/aiSdkBridge.js +88 -0
- package/dist/esm/model/chat-v2/chatV2EditorCache.js +107 -0
- package/dist/esm/model/chat-v2/chatV2Errors.js +255 -0
- package/dist/esm/model/chat-v2/chatV2FeatureCompatibility.js +16 -0
- package/dist/esm/model/chat-v2/chatV2Pipeline.js +387 -0
- package/dist/esm/model/chat-v2/chatV2ResponseFormat.js +57 -0
- package/dist/esm/model/chat-v2/chatV2Retry.js +41 -0
- package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +242 -0
- package/dist/esm/model/chat-v2/chatV2Shared.js +285 -0
- package/dist/esm/model/chat-v2/chatV2Types.js +1 -0
- package/dist/esm/model/chat-v2/index.js +10 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeData.js +56 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +475 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +90 -0
- package/dist/esm/model/chat-v2/messageConverter.js +173 -0
- package/dist/esm/model/chat-v2/modelRegistry.js +23 -0
- package/dist/esm/model/chat-v2/providerOptions.js +202 -0
- package/dist/esm/model/chat-v2/toolContinuation.js +108 -0
- package/dist/esm/model/chat-v2/toolConverter.js +4 -0
- package/dist/esm/model/interpolationInputDefinition.js +36 -0
- package/dist/esm/model/loopControllerBreak.js +4 -0
- package/dist/esm/model/nodes/AbortGraphNode.js +100 -0
- package/dist/esm/model/nodes/AppendToDatasetNode.js +115 -0
- package/dist/esm/model/nodes/ArrayNode.js +144 -0
- package/dist/esm/model/nodes/AssembleMessageNode.js +209 -0
- package/dist/esm/model/nodes/AssemblePromptNode.js +151 -0
- package/dist/esm/model/nodes/AudioNode.js +101 -0
- package/dist/esm/model/nodes/BooleanNode.js +74 -0
- package/dist/esm/model/nodes/CallGraphNode.js +135 -0
- package/dist/esm/model/nodes/ChatLoopNode.js +150 -0
- package/dist/esm/model/nodes/ChatNode.js +56 -0
- package/dist/esm/model/nodes/ChatNodeBase.js +912 -0
- package/dist/esm/model/nodes/ChunkNode.js +166 -0
- package/dist/esm/model/nodes/CoalesceNode.js +104 -0
- package/dist/esm/model/nodes/CodeNode.js +197 -0
- package/dist/esm/model/nodes/CommentNode.js +71 -0
- package/dist/esm/model/nodes/CompareNode.js +144 -0
- package/dist/esm/model/nodes/ContextNode.js +99 -0
- package/dist/esm/model/nodes/CreateDatasetNode.js +71 -0
- package/dist/esm/model/nodes/CronNode.js +248 -0
- package/dist/esm/model/nodes/DatasetNearestNeigborsNode.js +97 -0
- package/dist/esm/model/nodes/DelayNode.js +105 -0
- package/dist/esm/model/nodes/DelegateFunctionCallNode.js +175 -0
- package/dist/esm/model/nodes/DestructureNode.js +110 -0
- package/dist/esm/model/nodes/DocumentNode.js +183 -0
- package/dist/esm/model/nodes/EvaluateNode.js +141 -0
- package/dist/esm/model/nodes/ExpressionNode.js +143 -0
- package/dist/esm/model/nodes/ExternalCallNode.js +162 -0
- package/dist/esm/model/nodes/ExtractJsonNode.js +122 -0
- package/dist/esm/model/nodes/ExtractMarkdownCodeBlocksNode.js +100 -0
- package/dist/esm/model/nodes/ExtractObjectPathNode.js +159 -0
- package/dist/esm/model/nodes/ExtractRegexNode.js +200 -0
- package/dist/esm/model/nodes/ExtractYamlNode.js +214 -0
- package/dist/esm/model/nodes/FilterNode.js +73 -0
- package/dist/esm/model/nodes/GetAllDatasetsNode.js +53 -0
- package/dist/esm/model/nodes/GetDatasetRowNode.js +99 -0
- package/dist/esm/model/nodes/GetEmbeddingNode.js +130 -0
- package/dist/esm/model/nodes/GetGlobalNode.js +139 -0
- package/dist/esm/model/nodes/GraphInputNode.js +132 -0
- package/dist/esm/model/nodes/GraphOutputNode.js +104 -0
- package/dist/esm/model/nodes/GraphReferenceNode.js +128 -0
- package/dist/esm/model/nodes/HashNode.js +97 -0
- package/dist/esm/model/nodes/HttpCallNode.js +592 -0
- package/dist/esm/model/nodes/IfElseNode.js +138 -0
- package/dist/esm/model/nodes/IfNode.js +129 -0
- package/dist/esm/model/nodes/ImageNode.js +107 -0
- package/dist/esm/model/nodes/JSFilterNode.js +69 -0
- package/dist/esm/model/nodes/JSMapNode.js +69 -0
- package/dist/esm/model/nodes/JoinNode.js +135 -0
- package/dist/esm/model/nodes/LLMChatV2Node.js +234 -0
- package/dist/esm/model/nodes/ListGraphsNode.js +61 -0
- package/dist/esm/model/nodes/LoadDatasetNode.js +83 -0
- package/dist/esm/model/nodes/LoopControllerNode.js +206 -0
- package/dist/esm/model/nodes/LoopUntilNode.js +214 -0
- package/dist/esm/model/nodes/MCPDiscoveryNode.js +214 -0
- package/dist/esm/model/nodes/MCPGetPromptNode.js +234 -0
- package/dist/esm/model/nodes/MCPToolCallNode.js +262 -0
- package/dist/esm/model/nodes/MatchNode.js +160 -0
- package/dist/esm/model/nodes/NumberNode.js +86 -0
- package/dist/esm/model/nodes/ObjectNode.js +152 -0
- package/dist/esm/model/nodes/PassthroughNode.js +78 -0
- package/dist/esm/model/nodes/PlayAudioNode.js +61 -0
- package/dist/esm/model/nodes/PopNode.js +89 -0
- package/dist/esm/model/nodes/PromptNode.js +248 -0
- package/dist/esm/model/nodes/RaceInputsNode.js +85 -0
- package/dist/esm/model/nodes/RaiseEventNode.js +84 -0
- package/dist/esm/model/nodes/RandomNumberNode.js +117 -0
- package/dist/esm/model/nodes/ReadAllFilesNode.js +210 -0
- package/dist/esm/model/nodes/ReadDirectoryNode.js +171 -0
- package/dist/esm/model/nodes/ReadFileNode.js +114 -0
- package/dist/esm/model/nodes/ReferencedGraphAliasNode.js +199 -0
- package/dist/esm/model/nodes/ReplaceDatasetNode.js +118 -0
- package/dist/esm/model/nodes/SetGlobalNode.js +124 -0
- package/dist/esm/model/nodes/ShuffleNode.js +64 -0
- package/dist/esm/model/nodes/SliceNode.js +99 -0
- package/dist/esm/model/nodes/SplitNode.js +101 -0
- package/dist/esm/model/nodes/SubGraphNode.js +180 -0
- package/dist/esm/model/nodes/TextNode.js +125 -0
- package/dist/esm/model/nodes/ToJsonNode.js +78 -0
- package/dist/esm/model/nodes/ToMarkdownTableNode.js +119 -0
- package/dist/esm/model/nodes/ToTreeNode.js +133 -0
- package/dist/esm/model/nodes/ToYamlNode.js +68 -0
- package/dist/esm/model/nodes/ToolNode.js +172 -0
- package/dist/esm/model/nodes/TrimChatMessagesNode.js +120 -0
- package/dist/esm/model/nodes/URLReferenceNode.js +79 -0
- package/dist/esm/model/nodes/UserInputNode.js +109 -0
- package/dist/esm/model/nodes/VectorNearestNeighborsNode.js +127 -0
- package/dist/esm/model/nodes/VectorStoreNode.js +124 -0
- package/dist/esm/model/nodes/WaitForEventNode.js +88 -0
- package/dist/esm/model/nodes/codeNodeErrorDiagnostics.js +104 -0
- package/dist/esm/model/nodes/jsListCallbackHelpers.js +196 -0
- package/dist/esm/model/nodes/jsValueInterpolation.js +163 -0
- package/dist/esm/model/nodes/toolCallDelegation.js +159 -0
- package/dist/esm/native/BaseDir.js +32 -0
- package/dist/esm/native/BrowserNativeApi.js +19 -0
- package/dist/esm/native/NativeApi.js +1 -0
- package/dist/esm/plugins/anthropic/anthropic.js +208 -0
- package/dist/esm/plugins/anthropic/fetchEventSource.js +107 -0
- package/dist/esm/plugins/anthropic/index.js +2 -0
- package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +767 -0
- package/dist/esm/plugins/anthropic/plugin.js +26 -0
- package/dist/esm/plugins/assemblyAi/LemurActionItemsNode.js +75 -0
- package/dist/esm/plugins/assemblyAi/LemurQaNode.js +155 -0
- package/dist/esm/plugins/assemblyAi/LemurSummaryNode.js +79 -0
- package/dist/esm/plugins/assemblyAi/LemurTaskNode.js +82 -0
- package/dist/esm/plugins/assemblyAi/TranscribeAudioNode.js +126 -0
- package/dist/esm/plugins/assemblyAi/index.js +2 -0
- package/dist/esm/plugins/assemblyAi/lemurHelpers.js +114 -0
- package/dist/esm/plugins/assemblyAi/plugin.js +32 -0
- package/dist/esm/plugins/autoevals/AutoEvalsNode.js +223 -0
- package/dist/esm/plugins/autoevals/index.js +2 -0
- package/dist/esm/plugins/autoevals/plugin.js +8 -0
- package/dist/esm/plugins/gentrace/index.js +3 -0
- package/dist/esm/plugins/gentrace/plugin.js +195 -0
- package/dist/esm/plugins/google/google.js +165 -0
- package/dist/esm/plugins/google/index.js +2 -0
- package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +584 -0
- package/dist/esm/plugins/google/plugin.js +39 -0
- package/dist/esm/plugins/huggingface/index.js +2 -0
- package/dist/esm/plugins/huggingface/nodes/ChatHuggingFace.js +243 -0
- package/dist/esm/plugins/huggingface/nodes/TextToImageHuggingFace.js +189 -0
- package/dist/esm/plugins/huggingface/plugin.js +26 -0
- package/dist/esm/plugins/openai/handleOpenaiError.js +17 -0
- package/dist/esm/plugins/openai/index.js +2 -0
- package/dist/esm/plugins/openai/nodes/AttachAssistantFileNode.js +123 -0
- package/dist/esm/plugins/openai/nodes/CreateAssistantNode.js +289 -0
- package/dist/esm/plugins/openai/nodes/CreateThreadMessageNode.js +176 -0
- package/dist/esm/plugins/openai/nodes/CreateThreadNode.js +157 -0
- package/dist/esm/plugins/openai/nodes/DeleteAssistantNode.js +104 -0
- package/dist/esm/plugins/openai/nodes/DeleteThreadNode.js +97 -0
- package/dist/esm/plugins/openai/nodes/GetAssistantNode.js +118 -0
- package/dist/esm/plugins/openai/nodes/GetOpenAIFileNode.js +100 -0
- package/dist/esm/plugins/openai/nodes/GetThreadNode.js +108 -0
- package/dist/esm/plugins/openai/nodes/ListAssistantsNode.js +202 -0
- package/dist/esm/plugins/openai/nodes/ListOpenAIFilesNode.js +94 -0
- package/dist/esm/plugins/openai/nodes/ListThreadMessagesNode.js +224 -0
- package/dist/esm/plugins/openai/nodes/RunThreadNode.js +630 -0
- package/dist/esm/plugins/openai/nodes/ThreadMessageNode.js +143 -0
- package/dist/esm/plugins/openai/nodes/UploadFileNode.js +121 -0
- package/dist/esm/plugins/openai/plugin.js +44 -0
- package/dist/esm/plugins/pinecone/PineconeVectorDatabase.js +88 -0
- package/dist/esm/plugins/pinecone/index.js +2 -0
- package/dist/esm/plugins/pinecone/plugin.js +19 -0
- package/dist/esm/plugins.js +29 -0
- package/dist/esm/recording/ExecutionRecorder.js +273 -0
- package/dist/esm/recording/RecordedEvents.js +1 -0
- package/dist/esm/utils/assertNever.js +3 -0
- package/dist/esm/utils/base64.js +38 -0
- package/dist/esm/utils/chatMessageToOpenAIChatCompletionMessage.js +73 -0
- package/dist/esm/utils/coerceType.js +326 -0
- package/dist/esm/utils/compatibility.js +27 -0
- package/dist/esm/utils/copyToClipboard.js +10 -0
- package/dist/esm/utils/defaults.js +2 -0
- package/dist/esm/utils/emitDetached.js +12 -0
- package/dist/esm/utils/errors.js +7 -0
- package/dist/esm/utils/expectType.js +34 -0
- package/dist/esm/utils/fetchEventSource.js +120 -0
- package/dist/esm/utils/genericUtilFunctions.js +25 -0
- package/dist/esm/utils/getPluginConfig.js +23 -0
- package/dist/esm/utils/handleEscapeCharacters.js +11 -0
- package/dist/esm/utils/index.js +17 -0
- package/dist/esm/utils/inputs.js +16 -0
- package/dist/esm/utils/interpolation.js +286 -0
- package/dist/esm/utils/misc.js +1 -0
- package/dist/esm/utils/newId.js +4 -0
- package/dist/esm/utils/openai.js +206 -0
- package/dist/esm/utils/orderedStringPortIds.js +27 -0
- package/dist/esm/utils/outputs.js +14 -0
- package/dist/esm/utils/pQueueCompat.js +12 -0
- package/dist/esm/utils/paths.js +80 -0
- package/dist/esm/utils/providerStreamParsing.js +14 -0
- package/dist/esm/utils/runtimeLogging.js +121 -0
- package/dist/esm/utils/serialization/serialization.js +77 -0
- package/dist/esm/utils/serialization/serializationHelpers.js +63 -0
- package/dist/esm/utils/serialization/serializationUtils.js +112 -0
- package/dist/esm/utils/serialization/serialization_v1.js +19 -0
- package/dist/esm/utils/serialization/serialization_v2.js +24 -0
- package/dist/esm/utils/serialization/serialization_v3.js +100 -0
- package/dist/esm/utils/serialization/serialization_v4.js +156 -0
- package/dist/esm/utils/symbols.js +2 -0
- package/dist/esm/utils/time.js +14 -0
- package/dist/esm/utils/typeSafety.js +42 -0
- package/dist/esm/vendor/fnv1a.js +80 -0
- package/dist/types/api/createProcessor.d.ts +56 -0
- package/dist/types/api/looseDataValue.d.ts +4 -0
- package/dist/types/api/processSettings.d.ts +4 -0
- package/dist/types/api/streaming.d.ts +56 -0
- package/dist/types/exports.d.ts +49 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/integrations/AudioProvider.d.ts +4 -0
- package/dist/types/integrations/CodeRunner.d.ts +19 -0
- package/dist/types/integrations/DatasetProvider.d.ts +33 -0
- package/dist/types/integrations/EmbeddingGenerator.d.ts +3 -0
- package/dist/types/integrations/GptTokenizerTokenizer.d.ts +20 -0
- package/dist/types/integrations/LLMProvider.d.ts +7 -0
- package/dist/types/integrations/Tokenizer.d.ts +11 -0
- package/dist/types/integrations/VectorDatabase.d.ts +7 -0
- package/dist/types/integrations/enableIntegrations.d.ts +1 -0
- package/dist/types/integrations/integrations.d.ts +12 -0
- package/dist/types/integrations/mcp/MCPBase.d.ts +18 -0
- package/dist/types/integrations/mcp/MCPProvider.d.ts +153 -0
- package/dist/types/integrations/mcp/MCPUtils.d.ts +9 -0
- package/dist/types/integrations/openai/OpenAIEmbeddingGenerator.d.ts +10 -0
- package/dist/types/model/CycleDetector.d.ts +2 -0
- package/dist/types/model/DataValue.d.ts +160 -0
- package/dist/types/model/Dataset.d.ts +19 -0
- package/dist/types/model/EditorDefinition.d.ts +176 -0
- package/dist/types/model/ExecutorProtocol.d.ts +216 -0
- package/dist/types/model/GraphPreprocessor.d.ts +24 -0
- package/dist/types/model/GraphProcessor.d.ts +210 -0
- package/dist/types/model/NodeBase.d.ts +116 -0
- package/dist/types/model/NodeBodySpec.d.ts +19 -0
- package/dist/types/model/NodeDefinition.d.ts +13 -0
- package/dist/types/model/NodeExecutionPlanner.d.ts +28 -0
- package/dist/types/model/NodeGraph.d.ts +15 -0
- package/dist/types/model/NodeImpl.d.ts +56 -0
- package/dist/types/model/NodeRegistration.d.ts +29 -0
- package/dist/types/model/Nodes.d.ts +112 -0
- package/dist/types/model/PluginLoadSpec.d.ts +17 -0
- package/dist/types/model/ProcessContext.d.ts +110 -0
- package/dist/types/model/ProcessContextBuilder.d.ts +41 -0
- package/dist/types/model/Project.d.ts +31 -0
- package/dist/types/model/ProjectReferenceLoader.d.ts +5 -0
- package/dist/types/model/RecordingPlayer.d.ts +27 -0
- package/dist/types/model/RegistryAssembly.d.ts +42 -0
- package/dist/types/model/RivetPlugin.d.ts +51 -0
- package/dist/types/model/RivetUIContext.d.ts +27 -0
- package/dist/types/model/Settings.d.ts +20 -0
- package/dist/types/model/SplitRunProcessor.d.ts +31 -0
- package/dist/types/model/SubprocessorBridge.d.ts +13 -0
- package/dist/types/model/chat/aiSdkMessages.d.ts +3 -0
- package/dist/types/model/chat/aiSdkStreaming.d.ts +9 -0
- package/dist/types/model/chat/aiSdkTools.d.ts +3 -0
- package/dist/types/model/chat/chatCost.d.ts +30 -0
- package/dist/types/model/chat/chatMessages.d.ts +5 -0
- package/dist/types/model/chat/openAIChatRequest.d.ts +39 -0
- package/dist/types/model/chat/openAIChatRuntime.d.ts +61 -0
- package/dist/types/model/chat/streamChatResponse.d.ts +27 -0
- package/dist/types/model/chat/tokenBudget.d.ts +3 -0
- package/dist/types/model/chat-v2/aiSdkBridge.d.ts +2 -0
- package/dist/types/model/chat-v2/chatV2EditorCache.d.ts +25 -0
- package/dist/types/model/chat-v2/chatV2Errors.d.ts +23 -0
- package/dist/types/model/chat-v2/chatV2FeatureCompatibility.d.ts +12 -0
- package/dist/types/model/chat-v2/chatV2Pipeline.d.ts +2 -0
- package/dist/types/model/chat-v2/chatV2ResponseFormat.d.ts +24 -0
- package/dist/types/model/chat-v2/chatV2Retry.d.ts +5 -0
- package/dist/types/model/chat-v2/chatV2RuntimeOptions.d.ts +12 -0
- package/dist/types/model/chat-v2/chatV2Shared.d.ts +56 -0
- package/dist/types/model/chat-v2/chatV2Types.d.ts +110 -0
- package/dist/types/model/chat-v2/index.d.ts +10 -0
- package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +73 -0
- package/dist/types/model/chat-v2/llmChatV2NodeEditors.d.ts +4 -0
- package/dist/types/model/chat-v2/llmChatV2NodeRuntime.d.ts +23 -0
- package/dist/types/model/chat-v2/messageConverter.d.ts +8 -0
- package/dist/types/model/chat-v2/modelRegistry.d.ts +296 -0
- package/dist/types/model/chat-v2/providerOptions.d.ts +59 -0
- package/dist/types/model/chat-v2/toolContinuation.d.ts +15 -0
- package/dist/types/model/chat-v2/toolConverter.d.ts +3 -0
- package/dist/types/model/interpolationInputDefinition.d.ts +16 -0
- package/dist/types/model/loopControllerBreak.d.ts +3 -0
- package/dist/types/model/nodes/AbortGraphNode.d.ts +22 -0
- package/dist/types/model/nodes/AppendToDatasetNode.d.ts +21 -0
- package/dist/types/model/nodes/ArrayNode.d.ts +20 -0
- package/dist/types/model/nodes/AssembleMessageNode.d.ts +23 -0
- package/dist/types/model/nodes/AssemblePromptNode.d.ts +23 -0
- package/dist/types/model/nodes/AudioNode.d.ts +20 -0
- package/dist/types/model/nodes/BooleanNode.d.ts +19 -0
- package/dist/types/model/nodes/CallGraphNode.d.ts +16 -0
- package/dist/types/model/nodes/ChatLoopNode.d.ts +21 -0
- package/dist/types/model/nodes/ChatNode.d.ts +17 -0
- package/dist/types/model/nodes/ChatNodeBase.d.ts +85 -0
- package/dist/types/model/nodes/ChunkNode.d.ts +22 -0
- package/dist/types/model/nodes/CoalesceNode.d.ts +14 -0
- package/dist/types/model/nodes/CodeNode.d.ts +27 -0
- package/dist/types/model/nodes/CommentNode.d.ts +20 -0
- package/dist/types/model/nodes/CompareNode.d.ts +19 -0
- package/dist/types/model/nodes/ContextNode.d.ts +24 -0
- package/dist/types/model/nodes/CreateDatasetNode.d.ts +13 -0
- package/dist/types/model/nodes/CronNode.d.ts +34 -0
- package/dist/types/model/nodes/DatasetNearestNeigborsNode.d.ts +19 -0
- package/dist/types/model/nodes/DelayNode.d.ts +20 -0
- package/dist/types/model/nodes/DelegateFunctionCallNode.d.ts +28 -0
- package/dist/types/model/nodes/DestructureNode.d.ts +19 -0
- package/dist/types/model/nodes/DocumentNode.d.ts +28 -0
- package/dist/types/model/nodes/EvaluateNode.d.ts +19 -0
- package/dist/types/model/nodes/ExpressionNode.d.ts +21 -0
- package/dist/types/model/nodes/ExternalCallNode.d.ts +22 -0
- package/dist/types/model/nodes/ExtractJsonNode.d.ts +13 -0
- package/dist/types/model/nodes/ExtractMarkdownCodeBlocksNode.d.ts +12 -0
- package/dist/types/model/nodes/ExtractObjectPathNode.d.ts +22 -0
- package/dist/types/model/nodes/ExtractRegexNode.d.ts +22 -0
- package/dist/types/model/nodes/ExtractYamlNode.d.ts +21 -0
- package/dist/types/model/nodes/FilterNode.d.ts +13 -0
- package/dist/types/model/nodes/GetAllDatasetsNode.d.ts +14 -0
- package/dist/types/model/nodes/GetDatasetRowNode.d.ts +19 -0
- package/dist/types/model/nodes/GetEmbeddingNode.d.ts +24 -0
- package/dist/types/model/nodes/GetGlobalNode.d.ts +29 -0
- package/dist/types/model/nodes/GraphInputNode.d.ts +24 -0
- package/dist/types/model/nodes/GraphOutputNode.d.ts +22 -0
- package/dist/types/model/nodes/GraphReferenceNode.d.ts +22 -0
- package/dist/types/model/nodes/HashNode.d.ts +17 -0
- package/dist/types/model/nodes/HttpCallNode.d.ts +32 -0
- package/dist/types/model/nodes/IfElseNode.d.ts +18 -0
- package/dist/types/model/nodes/IfNode.d.ts +17 -0
- package/dist/types/model/nodes/ImageNode.d.ts +20 -0
- package/dist/types/model/nodes/JSFilterNode.d.ts +19 -0
- package/dist/types/model/nodes/JSMapNode.d.ts +19 -0
- package/dist/types/model/nodes/JoinNode.d.ts +21 -0
- package/dist/types/model/nodes/LLMChatV2Node.d.ts +20 -0
- package/dist/types/model/nodes/ListGraphsNode.d.ts +14 -0
- package/dist/types/model/nodes/LoadDatasetNode.d.ts +17 -0
- package/dist/types/model/nodes/LoopControllerNode.d.ts +20 -0
- package/dist/types/model/nodes/LoopUntilNode.d.ts +32 -0
- package/dist/types/model/nodes/MCPDiscoveryNode.d.ts +9 -0
- package/dist/types/model/nodes/MCPGetPromptNode.d.ts +23 -0
- package/dist/types/model/nodes/MCPToolCallNode.d.ts +26 -0
- package/dist/types/model/nodes/MatchNode.d.ts +20 -0
- package/dist/types/model/nodes/NumberNode.d.ts +21 -0
- package/dist/types/model/nodes/ObjectNode.d.ts +19 -0
- package/dist/types/model/nodes/PassthroughNode.d.ts +14 -0
- package/dist/types/model/nodes/PlayAudioNode.d.ts +15 -0
- package/dist/types/model/nodes/PopNode.d.ts +19 -0
- package/dist/types/model/nodes/PromptNode.d.ts +25 -0
- package/dist/types/model/nodes/RaceInputsNode.d.ts +16 -0
- package/dist/types/model/nodes/RaiseEventNode.d.ts +22 -0
- package/dist/types/model/nodes/RandomNumberNode.d.ts +23 -0
- package/dist/types/model/nodes/ReadAllFilesNode.d.ts +30 -0
- package/dist/types/model/nodes/ReadDirectoryNode.d.ts +30 -0
- package/dist/types/model/nodes/ReadFileNode.d.ts +23 -0
- package/dist/types/model/nodes/ReferencedGraphAliasNode.d.ts +31 -0
- package/dist/types/model/nodes/ReplaceDatasetNode.d.ts +21 -0
- package/dist/types/model/nodes/SetGlobalNode.d.ts +23 -0
- package/dist/types/model/nodes/ShuffleNode.d.ts +12 -0
- package/dist/types/model/nodes/SliceNode.d.ts +22 -0
- package/dist/types/model/nodes/SplitNode.d.ts +19 -0
- package/dist/types/model/nodes/SubGraphNode.d.ts +29 -0
- package/dist/types/model/nodes/TextNode.d.ts +19 -0
- package/dist/types/model/nodes/ToJsonNode.d.ts +18 -0
- package/dist/types/model/nodes/ToMarkdownTableNode.d.ts +19 -0
- package/dist/types/model/nodes/ToTreeNode.d.ts +21 -0
- package/dist/types/model/nodes/ToYamlNode.d.ts +13 -0
- package/dist/types/model/nodes/ToolNode.d.ts +25 -0
- package/dist/types/model/nodes/TrimChatMessagesNode.d.ts +20 -0
- package/dist/types/model/nodes/URLReferenceNode.d.ts +19 -0
- package/dist/types/model/nodes/UserInputNode.d.ts +20 -0
- package/dist/types/model/nodes/VectorNearestNeighborsNode.d.ts +24 -0
- package/dist/types/model/nodes/VectorStoreNode.d.ts +22 -0
- package/dist/types/model/nodes/WaitForEventNode.d.ts +21 -0
- package/dist/types/model/nodes/codeNodeErrorDiagnostics.d.ts +9 -0
- package/dist/types/model/nodes/jsListCallbackHelpers.d.ts +23 -0
- package/dist/types/model/nodes/jsValueInterpolation.d.ts +11 -0
- package/dist/types/model/nodes/toolCallDelegation.d.ts +29 -0
- package/dist/types/native/BaseDir.d.ts +29 -0
- package/dist/types/native/BrowserNativeApi.d.ts +9 -0
- package/dist/types/native/NativeApi.d.ts +17 -0
- package/dist/types/plugins/anthropic/anthropic.d.ts +315 -0
- package/dist/types/plugins/anthropic/fetchEventSource.d.ts +11 -0
- package/dist/types/plugins/anthropic/index.d.ts +2 -0
- package/dist/types/plugins/anthropic/nodes/ChatAnthropicNode.d.ts +40 -0
- package/dist/types/plugins/anthropic/plugin.d.ts +2 -0
- package/dist/types/plugins/assemblyAi/LemurActionItemsNode.d.ts +6 -0
- package/dist/types/plugins/assemblyAi/LemurQaNode.d.ts +22 -0
- package/dist/types/plugins/assemblyAi/LemurSummaryNode.d.ts +8 -0
- package/dist/types/plugins/assemblyAi/LemurTaskNode.d.ts +8 -0
- package/dist/types/plugins/assemblyAi/TranscribeAudioNode.d.ts +7 -0
- package/dist/types/plugins/assemblyAi/index.d.ts +2 -0
- package/dist/types/plugins/assemblyAi/lemurHelpers.d.ts +67 -0
- package/dist/types/plugins/assemblyAi/plugin.d.ts +2 -0
- package/dist/types/plugins/autoevals/AutoEvalsNode.d.ts +8 -0
- package/dist/types/plugins/autoevals/index.d.ts +2 -0
- package/dist/types/plugins/autoevals/plugin.d.ts +2 -0
- package/dist/types/plugins/gentrace/index.d.ts +2 -0
- package/dist/types/plugins/gentrace/plugin.d.ts +10 -0
- package/dist/types/plugins/google/google.d.ts +129 -0
- package/dist/types/plugins/google/index.d.ts +2 -0
- package/dist/types/plugins/google/nodes/ChatGoogleNode.d.ts +35 -0
- package/dist/types/plugins/google/plugin.d.ts +2 -0
- package/dist/types/plugins/huggingface/index.d.ts +2 -0
- package/dist/types/plugins/huggingface/nodes/ChatHuggingFace.d.ts +24 -0
- package/dist/types/plugins/huggingface/nodes/TextToImageHuggingFace.d.ts +20 -0
- package/dist/types/plugins/huggingface/plugin.d.ts +2 -0
- package/dist/types/plugins/openai/handleOpenaiError.d.ts +1 -0
- package/dist/types/plugins/openai/index.d.ts +2 -0
- package/dist/types/plugins/openai/nodes/AttachAssistantFileNode.d.ts +10 -0
- package/dist/types/plugins/openai/nodes/CreateAssistantNode.d.ts +26 -0
- package/dist/types/plugins/openai/nodes/CreateThreadMessageNode.d.ts +15 -0
- package/dist/types/plugins/openai/nodes/CreateThreadNode.d.ts +13 -0
- package/dist/types/plugins/openai/nodes/DeleteAssistantNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/DeleteThreadNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/GetAssistantNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/GetOpenAIFileNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/GetThreadNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/ListAssistantsNode.d.ts +14 -0
- package/dist/types/plugins/openai/nodes/ListOpenAIFilesNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/ListThreadMessagesNode.d.ts +16 -0
- package/dist/types/plugins/openai/nodes/RunThreadNode.d.ts +28 -0
- package/dist/types/plugins/openai/nodes/ThreadMessageNode.d.ts +14 -0
- package/dist/types/plugins/openai/nodes/UploadFileNode.d.ts +7 -0
- package/dist/types/plugins/openai/plugin.d.ts +2 -0
- package/dist/types/plugins/pinecone/PineconeVectorDatabase.d.ts +9 -0
- package/dist/types/plugins/pinecone/index.d.ts +2 -0
- package/dist/types/plugins/pinecone/plugin.d.ts +2 -0
- package/dist/types/plugins.d.ts +22 -0
- package/dist/types/recording/ExecutionRecorder.d.ts +27 -0
- package/dist/types/recording/RecordedEvents.d.ts +114 -0
- package/dist/types/utils/assertNever.d.ts +1 -0
- package/dist/types/utils/base64.d.ts +3 -0
- package/dist/types/utils/chatMessageToOpenAIChatCompletionMessage.d.ts +5 -0
- package/dist/types/utils/coerceType.d.ts +6 -0
- package/dist/types/utils/compatibility.d.ts +3 -0
- package/dist/types/utils/copyToClipboard.d.ts +1 -0
- package/dist/types/utils/defaults.d.ts +2 -0
- package/dist/types/utils/emitDetached.d.ts +11 -0
- package/dist/types/utils/errors.d.ts +2 -0
- package/dist/types/utils/expectType.d.ts +3 -0
- package/dist/types/utils/fetchEventSource.d.ts +12 -0
- package/dist/types/utils/genericUtilFunctions.d.ts +21 -0
- package/dist/types/utils/getPluginConfig.d.ts +2 -0
- package/dist/types/utils/handleEscapeCharacters.d.ts +2 -0
- package/dist/types/utils/index.d.ts +17 -0
- package/dist/types/utils/inputs.d.ts +3 -0
- package/dist/types/utils/interpolation.d.ts +26 -0
- package/dist/types/utils/misc.d.ts +1 -0
- package/dist/types/utils/newId.d.ts +1 -0
- package/dist/types/utils/openai.d.ts +784 -0
- package/dist/types/utils/orderedStringPortIds.d.ts +10 -0
- package/dist/types/utils/outputs.d.ts +3 -0
- package/dist/types/utils/pQueueCompat.d.ts +10 -0
- package/dist/types/utils/paths.d.ts +8 -0
- package/dist/types/utils/providerStreamParsing.d.ts +1 -0
- package/dist/types/utils/runtimeLogging.d.ts +10 -0
- package/dist/types/utils/serialization/serialization.d.ts +12 -0
- package/dist/types/utils/serialization/serializationHelpers.d.ts +27 -0
- package/dist/types/utils/serialization/serializationUtils.d.ts +16 -0
- package/dist/types/utils/serialization/serialization_v1.d.ts +3 -0
- package/dist/types/utils/serialization/serialization_v2.d.ts +3 -0
- package/dist/types/utils/serialization/serialization_v3.d.ts +19 -0
- package/dist/types/utils/serialization/serialization_v4.d.ts +9 -0
- package/dist/types/utils/symbols.d.ts +3 -0
- package/dist/types/utils/time.d.ts +22 -0
- package/dist/types/utils/typeSafety.d.ts +37 -0
- package/dist/types/vendor/fnv1a.d.ts +9 -0
- package/package.json +77 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const MAX_ERROR_MESSAGE_LENGTH = 500;
|
|
2
|
+
export function isRuntimeDebugLoggingEnabled() {
|
|
3
|
+
const processEnv = globalThis.process?.env;
|
|
4
|
+
if (processEnv?.RIVET_DEBUG_RUNTIME_LOGS === 'true') {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
try {
|
|
8
|
+
return globalThis.localStorage?.getItem('rivet.debugRuntimeLogs') === 'true';
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function summarizePortMapForLog(values) {
|
|
15
|
+
if (!values) {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
return Object.fromEntries(Object.entries(values).map(([key, value]) => [key, summarizeDataValueForLog(value)]));
|
|
19
|
+
}
|
|
20
|
+
export function summarizeDataValueForLog(value) {
|
|
21
|
+
if (!value) {
|
|
22
|
+
return { type: 'undefined' };
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
type: value.type,
|
|
26
|
+
value: summarizeUnknownForLog(value.value),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function summarizeUnknownForLog(value) {
|
|
30
|
+
if (value == null) {
|
|
31
|
+
return { kind: String(value) };
|
|
32
|
+
}
|
|
33
|
+
if (typeof value === 'string') {
|
|
34
|
+
return { kind: 'string', length: value.length };
|
|
35
|
+
}
|
|
36
|
+
if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {
|
|
37
|
+
return { kind: typeof value };
|
|
38
|
+
}
|
|
39
|
+
if (Array.isArray(value)) {
|
|
40
|
+
return { kind: 'array', length: value.length };
|
|
41
|
+
}
|
|
42
|
+
if (ArrayBuffer.isView(value)) {
|
|
43
|
+
return { kind: 'array-buffer-view', byteLength: value.byteLength };
|
|
44
|
+
}
|
|
45
|
+
if (value instanceof ArrayBuffer) {
|
|
46
|
+
return { kind: 'array-buffer', byteLength: value.byteLength };
|
|
47
|
+
}
|
|
48
|
+
if (typeof SharedArrayBuffer !== 'undefined' && value instanceof SharedArrayBuffer) {
|
|
49
|
+
return { kind: 'shared-array-buffer', byteLength: value.byteLength };
|
|
50
|
+
}
|
|
51
|
+
if (typeof Blob !== 'undefined' && value instanceof Blob) {
|
|
52
|
+
return { kind: 'blob', size: value.size, type: value.type };
|
|
53
|
+
}
|
|
54
|
+
if (value instanceof Date) {
|
|
55
|
+
return { kind: 'date' };
|
|
56
|
+
}
|
|
57
|
+
if (typeof value === 'object') {
|
|
58
|
+
return { kind: 'object', keyCount: getObjectKeyCountForLog(value) };
|
|
59
|
+
}
|
|
60
|
+
return { kind: typeof value };
|
|
61
|
+
}
|
|
62
|
+
export function summarizeErrorForLog(error) {
|
|
63
|
+
if (error instanceof Error) {
|
|
64
|
+
return {
|
|
65
|
+
name: error.name,
|
|
66
|
+
message: truncateForLog(error.message),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (typeof error === 'string') {
|
|
70
|
+
return {
|
|
71
|
+
name: 'Error',
|
|
72
|
+
message: truncateForLog(error),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
name: 'UnknownError',
|
|
77
|
+
value: summarizeUnknownForLog(error),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function logRuntimeInfo(message, metadata) {
|
|
81
|
+
if (metadata) {
|
|
82
|
+
console.log(message, metadata);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
console.log(message);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export function logRuntimeWarn(message, metadata) {
|
|
89
|
+
if (metadata) {
|
|
90
|
+
console.warn(message, metadata);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
console.warn(message);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export function logRuntimeError(message, error, metadata) {
|
|
97
|
+
console.error(message, {
|
|
98
|
+
...metadata,
|
|
99
|
+
error: summarizeErrorForLog(error),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
export function logRuntimeDebug(message, metadata) {
|
|
103
|
+
if (!isRuntimeDebugLoggingEnabled()) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
logRuntimeInfo(message, metadata);
|
|
107
|
+
}
|
|
108
|
+
function truncateForLog(value) {
|
|
109
|
+
if (value.length <= MAX_ERROR_MESSAGE_LENGTH) {
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
return `${value.slice(0, MAX_ERROR_MESSAGE_LENGTH)}...`;
|
|
113
|
+
}
|
|
114
|
+
function getObjectKeyCountForLog(value) {
|
|
115
|
+
try {
|
|
116
|
+
return Object.keys(value).length;
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return 'unknown';
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import * as yaml from 'yaml';
|
|
3
|
+
import { graphV3Deserializer, projectV3Deserializer } from './serialization_v3.js';
|
|
4
|
+
import { getError } from '../errors.js';
|
|
5
|
+
import { detectSerializationVersion, yamlProblem } from './serializationUtils.js';
|
|
6
|
+
import { datasetV4Deserializer, datasetV4Serializer, graphV4Deserializer, graphV4Serializer, projectV4Deserializer, projectV4Serializer, } from './serialization_v4.js';
|
|
7
|
+
import { graphV2Deserializer, projectV2Deserializer } from './serialization_v2.js';
|
|
8
|
+
import { graphV1Deserializer, projectV1Deserializer } from './serialization_v1.js';
|
|
9
|
+
export function serializeProject(project, attachedData) {
|
|
10
|
+
return projectV4Serializer(project, attachedData);
|
|
11
|
+
}
|
|
12
|
+
const errMessage = (err) => `${getError(err).message}\n${getError(err).stack}`;
|
|
13
|
+
export function deserializeProject(serializedProject, path = null) {
|
|
14
|
+
const version = detectSerializationVersion(serializedProject);
|
|
15
|
+
try {
|
|
16
|
+
const result = deserializeProjectByVersion(serializedProject, version);
|
|
17
|
+
if (path !== null) {
|
|
18
|
+
result[0].metadata.path = path;
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
if (err instanceof yaml.YAMLError) {
|
|
24
|
+
yamlProblem(err);
|
|
25
|
+
}
|
|
26
|
+
console.warn(`Failed to deserialize project v${version}: ${errMessage(err)}`);
|
|
27
|
+
throw new Error('Could not deserialize project');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function serializeGraph(graph) {
|
|
31
|
+
return graphV4Serializer(graph);
|
|
32
|
+
}
|
|
33
|
+
export function deserializeGraph(serializedGraph) {
|
|
34
|
+
const version = detectSerializationVersion(serializedGraph);
|
|
35
|
+
try {
|
|
36
|
+
return deserializeGraphByVersion(serializedGraph, version);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
if (err instanceof yaml.YAMLError) {
|
|
40
|
+
yamlProblem(err);
|
|
41
|
+
}
|
|
42
|
+
console.warn(`Failed to deserialize graph v${version}: ${errMessage(err)}`);
|
|
43
|
+
throw new Error('Could not deserialize graph');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function deserializeProjectByVersion(serializedProject, version) {
|
|
47
|
+
switch (version) {
|
|
48
|
+
case 4:
|
|
49
|
+
return projectV4Deserializer(serializedProject);
|
|
50
|
+
case 3:
|
|
51
|
+
return [projectV3Deserializer(serializedProject), {}];
|
|
52
|
+
case 2:
|
|
53
|
+
return [projectV2Deserializer(serializedProject), {}];
|
|
54
|
+
case 1:
|
|
55
|
+
default:
|
|
56
|
+
return [projectV1Deserializer(serializedProject), {}];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function deserializeGraphByVersion(serializedGraph, version) {
|
|
60
|
+
switch (version) {
|
|
61
|
+
case 4:
|
|
62
|
+
return graphV4Deserializer(serializedGraph);
|
|
63
|
+
case 3:
|
|
64
|
+
return graphV3Deserializer(serializedGraph);
|
|
65
|
+
case 2:
|
|
66
|
+
return graphV2Deserializer(serializedGraph);
|
|
67
|
+
case 1:
|
|
68
|
+
default:
|
|
69
|
+
return graphV1Deserializer(serializedGraph);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export function serializeDatasets(datasets) {
|
|
73
|
+
return datasetV4Serializer(datasets);
|
|
74
|
+
}
|
|
75
|
+
export function deserializeDatasets(serializedDatasets) {
|
|
76
|
+
return datasetV4Deserializer(serializedDatasets);
|
|
77
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared serialization helpers used by V3 and V4 serializers.
|
|
3
|
+
* Connection format, visual data encoding, and YAML envelope logic.
|
|
4
|
+
*/
|
|
5
|
+
import stableStringify from 'safe-stable-stringify';
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import * as yaml from 'yaml';
|
|
8
|
+
export function serializeConnection(connection, allNodes) {
|
|
9
|
+
const targetTitle = allNodes.find((node) => node.id === connection.inputNodeId)?.title ?? '';
|
|
10
|
+
return `${connection.outputId}->"${targetTitle}" ${connection.inputNodeId}/${connection.inputId}`;
|
|
11
|
+
}
|
|
12
|
+
export function deserializeConnection(connection, sourceNodeId) {
|
|
13
|
+
const match = connection.match(/(.+)->"(.*)"\s+(.+)\/(.+)/);
|
|
14
|
+
if (!match) {
|
|
15
|
+
throw new Error(`Invalid connection: ${connection}`);
|
|
16
|
+
}
|
|
17
|
+
const [, outputId, , inputNodeId, inputId] = match;
|
|
18
|
+
return {
|
|
19
|
+
outputId: outputId,
|
|
20
|
+
outputNodeId: sourceNodeId,
|
|
21
|
+
inputId: inputId,
|
|
22
|
+
inputNodeId: inputNodeId,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function parseOptionalFloat(val) {
|
|
26
|
+
return val === 'null' || val === undefined || val === '' ? undefined : parseFloat(val);
|
|
27
|
+
}
|
|
28
|
+
/** Parse `x/y/width/zIndex` or `x/y/width/zIndex/borderColor/bgColor` */
|
|
29
|
+
export function parseVisualData(packed) {
|
|
30
|
+
const parts = packed.split('/');
|
|
31
|
+
const [x, y, width, zIndex, borderColor, bgColor] = parts;
|
|
32
|
+
return {
|
|
33
|
+
x: parseFloat(x),
|
|
34
|
+
y: parseFloat(y),
|
|
35
|
+
width: parseOptionalFloat(width),
|
|
36
|
+
zIndex: parseOptionalFloat(zIndex),
|
|
37
|
+
borderColor: borderColor || undefined,
|
|
38
|
+
bgColor: bgColor || undefined,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Encode visual data as `x/y/width/zIndex` (V3) */
|
|
42
|
+
export function packVisualDataV3(node) {
|
|
43
|
+
return `${node.visualData.x}/${node.visualData.y}/${node.visualData.width ?? 'null'}/${node.visualData.zIndex ?? 'null'}`;
|
|
44
|
+
}
|
|
45
|
+
/** Encode visual data as `x/y/width/zIndex/borderColor/bgColor` (V4) */
|
|
46
|
+
export function packVisualDataV4(node) {
|
|
47
|
+
return `${node.visualData.x}/${node.visualData.y}/${node.visualData.width ?? 'null'}/${node.visualData.zIndex ?? 'null'}/${node.visualData.color?.border ?? ''}/${node.visualData.color?.bg ?? ''}`;
|
|
48
|
+
}
|
|
49
|
+
// ---- YAML envelope ----
|
|
50
|
+
export function wrapInYamlEnvelope(version, data) {
|
|
51
|
+
const stabilized = JSON.parse(stableStringify(data) ?? '{}');
|
|
52
|
+
return yaml.stringify({ version, data: stabilized }, null, { indent: 2 });
|
|
53
|
+
}
|
|
54
|
+
export function unwrapYamlEnvelope(raw, expectedVersion, label) {
|
|
55
|
+
if (typeof raw !== 'string') {
|
|
56
|
+
throw new Error(`${label} deserializer requires a string`);
|
|
57
|
+
}
|
|
58
|
+
const parsed = yaml.parse(raw);
|
|
59
|
+
if (parsed.version !== expectedVersion) {
|
|
60
|
+
throw new Error(`${label} deserializer requires a version ${expectedVersion} ${label.toLowerCase()}`);
|
|
61
|
+
}
|
|
62
|
+
return parsed.data;
|
|
63
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as YAML from 'yaml';
|
|
2
|
+
/** Validates a deserialized project structure. Returns errors for structural problems. */
|
|
3
|
+
export function validateProject(project) {
|
|
4
|
+
const errors = [];
|
|
5
|
+
const warnings = [];
|
|
6
|
+
if (!project || typeof project !== 'object') {
|
|
7
|
+
return { valid: false, errors: ['Project is not an object'], warnings };
|
|
8
|
+
}
|
|
9
|
+
const p = project;
|
|
10
|
+
// Metadata checks
|
|
11
|
+
if (!p.metadata || typeof p.metadata !== 'object') {
|
|
12
|
+
errors.push('Missing project metadata');
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
const meta = p.metadata;
|
|
16
|
+
if (!meta.id)
|
|
17
|
+
errors.push('Missing project metadata.id');
|
|
18
|
+
if (!meta.title)
|
|
19
|
+
errors.push('Missing project metadata.title');
|
|
20
|
+
}
|
|
21
|
+
// Graphs checks
|
|
22
|
+
if (!p.graphs || typeof p.graphs !== 'object') {
|
|
23
|
+
errors.push('Missing or invalid project graphs');
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const graphs = p.graphs;
|
|
27
|
+
for (const [graphId, graph] of Object.entries(graphs)) {
|
|
28
|
+
if (!graph || typeof graph !== 'object') {
|
|
29
|
+
errors.push(`Graph "${graphId}": not an object`);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const g = graph;
|
|
33
|
+
if (!Array.isArray(g.nodes)) {
|
|
34
|
+
errors.push(`Graph "${graphId}": nodes is not an array`);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
for (let i = 0; i < g.nodes.length; i++) {
|
|
38
|
+
const node = g.nodes[i];
|
|
39
|
+
if (!node || typeof node !== 'object') {
|
|
40
|
+
errors.push(`Graph "${graphId}": node at index ${i} is not an object`);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (!node.id)
|
|
44
|
+
errors.push(`Graph "${graphId}": node at index ${i} missing id`);
|
|
45
|
+
if (!node.type)
|
|
46
|
+
errors.push(`Graph "${graphId}": node "${node.id ?? i}" missing type`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (!Array.isArray(g.connections)) {
|
|
50
|
+
errors.push(`Graph "${graphId}": connections is not an array`);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
for (let i = 0; i < g.connections.length; i++) {
|
|
54
|
+
const conn = g.connections[i];
|
|
55
|
+
if (!conn || typeof conn !== 'object') {
|
|
56
|
+
errors.push(`Graph "${graphId}": connection at index ${i} is not an object`);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (!conn.inputNodeId || !conn.outputNodeId) {
|
|
60
|
+
warnings.push(`Graph "${graphId}": connection at index ${i} missing node reference`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { valid: errors.length === 0, errors, warnings };
|
|
67
|
+
}
|
|
68
|
+
/** Quick structural check - throws on invalid project. */
|
|
69
|
+
export function doubleCheckProject(project) {
|
|
70
|
+
const result = validateProject(project);
|
|
71
|
+
if (!result.valid) {
|
|
72
|
+
throw new Error(`Invalid project file: ${result.errors.join('; ')}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export function yamlProblem(err) {
|
|
76
|
+
const { code, message, pos, linePos } = err;
|
|
77
|
+
throw new Error(`YAML error: ${code} ${message} at ${pos} ${linePos}`);
|
|
78
|
+
}
|
|
79
|
+
export function detectSerializationVersion(data) {
|
|
80
|
+
if (typeof data !== 'string') {
|
|
81
|
+
return 1;
|
|
82
|
+
}
|
|
83
|
+
const trimmed = data.trim();
|
|
84
|
+
if (!trimmed) {
|
|
85
|
+
return 1;
|
|
86
|
+
}
|
|
87
|
+
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
|
|
88
|
+
try {
|
|
89
|
+
const parsed = JSON.parse(trimmed);
|
|
90
|
+
if (typeof parsed === 'object' &&
|
|
91
|
+
parsed != null &&
|
|
92
|
+
typeof parsed.version === 'number' &&
|
|
93
|
+
parsed.version >= 2 &&
|
|
94
|
+
parsed.version <= 4) {
|
|
95
|
+
return parsed.version;
|
|
96
|
+
}
|
|
97
|
+
return 1;
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return 1;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const parsed = YAML.parse(trimmed);
|
|
104
|
+
if (parsed &&
|
|
105
|
+
typeof parsed === 'object' &&
|
|
106
|
+
typeof parsed.version === 'number' &&
|
|
107
|
+
parsed.version >= 2 &&
|
|
108
|
+
parsed.version <= 4) {
|
|
109
|
+
return parsed.version;
|
|
110
|
+
}
|
|
111
|
+
return 1;
|
|
112
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { doubleCheckProject } from './serializationUtils.js';
|
|
2
|
+
export function projectV1Deserializer(data) {
|
|
3
|
+
if (typeof data !== 'string') {
|
|
4
|
+
throw new Error('Project v1 deserializer requires a string');
|
|
5
|
+
}
|
|
6
|
+
const project = JSON.parse(data);
|
|
7
|
+
doubleCheckProject(project);
|
|
8
|
+
return project;
|
|
9
|
+
}
|
|
10
|
+
export function graphV1Deserializer(data) {
|
|
11
|
+
if (typeof data !== 'string') {
|
|
12
|
+
throw new Error('Graph v1 deserializer requires a string');
|
|
13
|
+
}
|
|
14
|
+
const graph = JSON.parse(data);
|
|
15
|
+
if (!graph.nodes || !graph.connections) {
|
|
16
|
+
throw new Error('Invalid graph file');
|
|
17
|
+
}
|
|
18
|
+
return graph;
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { doubleCheckProject } from './serializationUtils.js';
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
import * as yaml from 'yaml';
|
|
4
|
+
export function projectV2Deserializer(data) {
|
|
5
|
+
if (typeof data !== 'string') {
|
|
6
|
+
throw new Error('Project v2 deserializer requires a string');
|
|
7
|
+
}
|
|
8
|
+
const project = yaml.parse(data);
|
|
9
|
+
if (project.version !== 2) {
|
|
10
|
+
throw new Error('Project v2 deserializer requires a version 2 project');
|
|
11
|
+
}
|
|
12
|
+
doubleCheckProject(project.data);
|
|
13
|
+
return project.data;
|
|
14
|
+
}
|
|
15
|
+
export function graphV2Deserializer(data) {
|
|
16
|
+
if (typeof data !== 'string') {
|
|
17
|
+
throw new Error('Graph v2 deserializer requires a string');
|
|
18
|
+
}
|
|
19
|
+
const graph = yaml.parse(data);
|
|
20
|
+
if (graph.version !== 2) {
|
|
21
|
+
throw new Error('Graph v2 deserializer requires a version 2 graph');
|
|
22
|
+
}
|
|
23
|
+
return graph.data;
|
|
24
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { mapValues } from 'lodash-es';
|
|
2
|
+
import { doubleCheckProject } from './serializationUtils.js';
|
|
3
|
+
import { serializeConnection, deserializeConnection, parseVisualData, packVisualDataV3, wrapInYamlEnvelope, unwrapYamlEnvelope, } from './serializationHelpers.js';
|
|
4
|
+
export function projectV3Deserializer(data) {
|
|
5
|
+
const serializedProject = unwrapYamlEnvelope(data, 3, 'Project v3');
|
|
6
|
+
const project = fromSerializedProject(serializedProject);
|
|
7
|
+
doubleCheckProject(project);
|
|
8
|
+
return project;
|
|
9
|
+
}
|
|
10
|
+
export function graphV3Deserializer(data) {
|
|
11
|
+
const serializedGraph = unwrapYamlEnvelope(data, 3, 'Graph v3');
|
|
12
|
+
return fromSerializedGraph(serializedGraph);
|
|
13
|
+
}
|
|
14
|
+
export function projectV3Serializer(project) {
|
|
15
|
+
return wrapInYamlEnvelope(3, toSerializedProject(project));
|
|
16
|
+
}
|
|
17
|
+
export function graphV3Serializer(graph) {
|
|
18
|
+
return wrapInYamlEnvelope(3, toSerializedGraph(graph));
|
|
19
|
+
}
|
|
20
|
+
function toSerializedProject(project) {
|
|
21
|
+
return {
|
|
22
|
+
metadata: project.metadata,
|
|
23
|
+
graphs: mapValues(project.graphs, (graph) => toSerializedGraph(graph)),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function fromSerializedProject(serializedProject) {
|
|
27
|
+
return {
|
|
28
|
+
metadata: serializedProject.metadata,
|
|
29
|
+
graphs: mapValues(serializedProject.graphs, (graph) => fromSerializedGraph(graph)),
|
|
30
|
+
plugins: [],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function toSerializedGraph(graph) {
|
|
34
|
+
return {
|
|
35
|
+
metadata: {
|
|
36
|
+
id: graph.metadata.id,
|
|
37
|
+
name: graph.metadata.name,
|
|
38
|
+
description: graph.metadata.description,
|
|
39
|
+
},
|
|
40
|
+
nodes: graph.nodes.reduce((acc, node) => ({
|
|
41
|
+
...acc,
|
|
42
|
+
[node.id]: toSerializedNode(node, graph.nodes, graph.connections),
|
|
43
|
+
}), {}),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function fromSerializedGraph(serializedGraph) {
|
|
47
|
+
const allConnections = [];
|
|
48
|
+
const allNodes = [];
|
|
49
|
+
for (const node of Object.values(serializedGraph.nodes)) {
|
|
50
|
+
const [chartNode, connections] = fromSerializedNode(node);
|
|
51
|
+
allNodes.push(chartNode);
|
|
52
|
+
allConnections.push(...connections);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
metadata: {
|
|
56
|
+
id: serializedGraph.metadata.id,
|
|
57
|
+
name: serializedGraph.metadata.name,
|
|
58
|
+
description: serializedGraph.metadata.description,
|
|
59
|
+
},
|
|
60
|
+
nodes: allNodes,
|
|
61
|
+
connections: allConnections,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function toSerializedNode(node, allNodes, allConnections) {
|
|
65
|
+
return {
|
|
66
|
+
id: node.id,
|
|
67
|
+
title: node.title,
|
|
68
|
+
description: node.description,
|
|
69
|
+
type: node.type,
|
|
70
|
+
visualData: packVisualDataV3(node),
|
|
71
|
+
isSplitRun: node.isSplitRun,
|
|
72
|
+
splitRunMax: node.splitRunMax,
|
|
73
|
+
splitRunConcurrency: node.splitRunConcurrency,
|
|
74
|
+
data: node.data,
|
|
75
|
+
outgoingConnections: allConnections
|
|
76
|
+
.filter((connection) => connection.outputNodeId === node.id)
|
|
77
|
+
.map((connection) => serializeConnection(connection, allNodes))
|
|
78
|
+
.sort(),
|
|
79
|
+
variants: (node.variants?.length ?? 0) > 0 ? node.variants : undefined,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function fromSerializedNode(serializedNode) {
|
|
83
|
+
const { x, y, width, zIndex } = parseVisualData(serializedNode.visualData);
|
|
84
|
+
const connections = serializedNode.outgoingConnections.map((conn) => deserializeConnection(conn, serializedNode.id));
|
|
85
|
+
return [
|
|
86
|
+
{
|
|
87
|
+
id: serializedNode.id,
|
|
88
|
+
title: serializedNode.title,
|
|
89
|
+
description: serializedNode.description,
|
|
90
|
+
type: serializedNode.type,
|
|
91
|
+
isSplitRun: serializedNode.isSplitRun,
|
|
92
|
+
splitRunMax: serializedNode.splitRunMax,
|
|
93
|
+
splitRunConcurrency: serializedNode.splitRunConcurrency,
|
|
94
|
+
visualData: { x, y, width, zIndex },
|
|
95
|
+
data: serializedNode.data,
|
|
96
|
+
variants: serializedNode.variants,
|
|
97
|
+
},
|
|
98
|
+
connections,
|
|
99
|
+
];
|
|
100
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { mapValues } from 'lodash-es';
|
|
2
|
+
import { doubleCheckProject } from './serializationUtils.js';
|
|
3
|
+
import { entries } from '../typeSafety.js';
|
|
4
|
+
import {} from '../../model/Project.js';
|
|
5
|
+
import { serializeConnection, deserializeConnection, parseVisualData, packVisualDataV4, wrapInYamlEnvelope, unwrapYamlEnvelope, } from './serializationHelpers.js';
|
|
6
|
+
export function projectV4Deserializer(data) {
|
|
7
|
+
const serializedProject = unwrapYamlEnvelope(data, 4, 'Project v4');
|
|
8
|
+
const [project, attachedData] = fromSerializedProject(serializedProject);
|
|
9
|
+
doubleCheckProject(project);
|
|
10
|
+
return [project, attachedData];
|
|
11
|
+
}
|
|
12
|
+
export function graphV4Deserializer(data) {
|
|
13
|
+
const serializedGraph = unwrapYamlEnvelope(data, 4, 'Graph v4');
|
|
14
|
+
return fromSerializedGraph(serializedGraph);
|
|
15
|
+
}
|
|
16
|
+
export function projectV4Serializer(project, attachedData) {
|
|
17
|
+
const filteredProject = {
|
|
18
|
+
...project,
|
|
19
|
+
metadata: {
|
|
20
|
+
...project.metadata,
|
|
21
|
+
path: undefined,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
return wrapInYamlEnvelope(4, toSerializedProject(filteredProject, attachedData));
|
|
25
|
+
}
|
|
26
|
+
export function graphV4Serializer(graph) {
|
|
27
|
+
return wrapInYamlEnvelope(4, toSerializedGraph(graph));
|
|
28
|
+
}
|
|
29
|
+
function toSerializedProject(project, attachedData) {
|
|
30
|
+
return {
|
|
31
|
+
metadata: project.metadata,
|
|
32
|
+
graphs: mapValues(project.graphs, (graph) => toSerializedGraph(graph)),
|
|
33
|
+
attachedData,
|
|
34
|
+
plugins: project.plugins ?? [],
|
|
35
|
+
references: project.references ?? [],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function fromSerializedProject(serializedProject) {
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
metadata: serializedProject.metadata,
|
|
42
|
+
graphs: mapValues(serializedProject.graphs, (graph) => fromSerializedGraph(graph)),
|
|
43
|
+
plugins: serializedProject.plugins ?? [],
|
|
44
|
+
references: serializedProject.references ?? [],
|
|
45
|
+
},
|
|
46
|
+
serializedProject.attachedData ?? {},
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
function toSerializedGraph(graph) {
|
|
50
|
+
const graphMetadata = {
|
|
51
|
+
id: graph.metadata.id,
|
|
52
|
+
name: graph.metadata.name,
|
|
53
|
+
description: graph.metadata.description,
|
|
54
|
+
};
|
|
55
|
+
if (graph.metadata.attachedData) {
|
|
56
|
+
graphMetadata.attachedData = graph.metadata.attachedData;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
metadata: graphMetadata,
|
|
60
|
+
nodes: graph.nodes.reduce((acc, node) => ({
|
|
61
|
+
...acc,
|
|
62
|
+
[getGraphNodeKey(node)]: toSerializedNode(node, graph.nodes, graph.connections),
|
|
63
|
+
}), {}),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function getGraphNodeKey(node) {
|
|
67
|
+
return `[${node.id}]:${node.type} "${node.title}"`;
|
|
68
|
+
}
|
|
69
|
+
function deserializeGraphNodeKey(key) {
|
|
70
|
+
const { nodeId, type, title } = key.match(/^\[(?<nodeId>[^\]]+)\]:(?<type>[^\s]+) "(?<title>.*)"$/)?.groups ?? {};
|
|
71
|
+
if (!nodeId || !type || title == null) {
|
|
72
|
+
throw new Error(`Invalid graph node key: ${key}`);
|
|
73
|
+
}
|
|
74
|
+
return [nodeId, type, title];
|
|
75
|
+
}
|
|
76
|
+
function fromSerializedGraph(serializedGraph) {
|
|
77
|
+
const allConnections = [];
|
|
78
|
+
const allNodes = [];
|
|
79
|
+
for (const [serializedNodeInfo, node] of entries(serializedGraph.nodes)) {
|
|
80
|
+
const [chartNode, connections] = fromSerializedNode(node, serializedNodeInfo);
|
|
81
|
+
allNodes.push(chartNode);
|
|
82
|
+
allConnections.push(...connections);
|
|
83
|
+
}
|
|
84
|
+
const metadata = {
|
|
85
|
+
id: serializedGraph.metadata.id,
|
|
86
|
+
name: serializedGraph.metadata.name,
|
|
87
|
+
description: serializedGraph.metadata.description,
|
|
88
|
+
};
|
|
89
|
+
if (serializedGraph.metadata.attachedData) {
|
|
90
|
+
metadata.attachedData = serializedGraph.metadata.attachedData;
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
metadata,
|
|
94
|
+
nodes: allNodes,
|
|
95
|
+
connections: allConnections,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function toSerializedNode(node, allNodes, allConnections) {
|
|
99
|
+
const outgoingConnections = allConnections
|
|
100
|
+
.filter((connection) => connection.outputNodeId === node.id)
|
|
101
|
+
.map((connection) => serializeConnection(connection, allNodes))
|
|
102
|
+
.sort();
|
|
103
|
+
return {
|
|
104
|
+
description: node.description?.trim() ? node.description : undefined,
|
|
105
|
+
visualData: packVisualDataV4(node),
|
|
106
|
+
isSplitRun: node.isSplitRun ? true : undefined,
|
|
107
|
+
splitRunMax: node.isSplitRun ? node.splitRunMax : undefined,
|
|
108
|
+
splitRunConcurrency: node.isSplitRun ? node.splitRunConcurrency : undefined,
|
|
109
|
+
isSplitSequential: node.isSplitSequential ? true : undefined,
|
|
110
|
+
data: Object.keys(node.data ?? {}).length > 0 ? node.data : undefined,
|
|
111
|
+
outgoingConnections: outgoingConnections.length > 0 ? outgoingConnections : undefined,
|
|
112
|
+
variants: (node.variants?.length ?? 0) > 0 ? node.variants : undefined,
|
|
113
|
+
disabled: node.disabled ? true : undefined,
|
|
114
|
+
isConditional: node.isConditional,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function fromSerializedNode(serializedNode, serializedNodeInfo) {
|
|
118
|
+
const [nodeId, type, title] = deserializeGraphNodeKey(serializedNodeInfo);
|
|
119
|
+
const { x, y, width, zIndex, borderColor, bgColor } = parseVisualData(serializedNode.visualData);
|
|
120
|
+
const connections = serializedNode.outgoingConnections?.map((conn) => deserializeConnection(conn, nodeId)) ?? [];
|
|
121
|
+
const color = borderColor || bgColor ? { border: borderColor, bg: bgColor } : undefined;
|
|
122
|
+
return [
|
|
123
|
+
{
|
|
124
|
+
id: nodeId,
|
|
125
|
+
type,
|
|
126
|
+
title,
|
|
127
|
+
description: serializedNode.description,
|
|
128
|
+
isSplitRun: serializedNode.isSplitRun ?? false,
|
|
129
|
+
splitRunMax: serializedNode.splitRunMax ?? 10,
|
|
130
|
+
splitRunConcurrency: serializedNode.splitRunConcurrency,
|
|
131
|
+
isSplitSequential: serializedNode.isSplitSequential ?? false,
|
|
132
|
+
visualData: {
|
|
133
|
+
x,
|
|
134
|
+
y,
|
|
135
|
+
width,
|
|
136
|
+
zIndex,
|
|
137
|
+
color,
|
|
138
|
+
},
|
|
139
|
+
data: serializedNode.data ?? {},
|
|
140
|
+
variants: serializedNode.variants ?? [],
|
|
141
|
+
disabled: serializedNode.disabled,
|
|
142
|
+
isConditional: serializedNode.isConditional,
|
|
143
|
+
},
|
|
144
|
+
connections,
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
export function datasetV4Serializer(datasets) {
|
|
148
|
+
return JSON.stringify({ datasets });
|
|
149
|
+
}
|
|
150
|
+
export function datasetV4Deserializer(serializedDatasets) {
|
|
151
|
+
const dataContainer = JSON.parse(serializedDatasets);
|
|
152
|
+
if (!dataContainer.datasets) {
|
|
153
|
+
throw new Error('Invalid dataset data');
|
|
154
|
+
}
|
|
155
|
+
return dataContainer.datasets;
|
|
156
|
+
}
|