@alpic80/rivet-core 1.19.1-aidon.1
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 +176 -0
- package/dist/cjs/bundle.cjs +18915 -0
- package/dist/cjs/bundle.cjs.map +7 -0
- package/dist/esm/api/createProcessor.js +131 -0
- package/dist/esm/api/streaming.js +116 -0
- package/dist/esm/exports.js +32 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/integrations/AudioProvider.js +1 -0
- package/dist/esm/integrations/DatasetProvider.js +92 -0
- package/dist/esm/integrations/EmbeddingGenerator.js +1 -0
- package/dist/esm/integrations/GptTokenizerTokenizer.js +65 -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/openai/OpenAIEmbeddingGenerator.js +23 -0
- package/dist/esm/model/DataValue.js +176 -0
- package/dist/esm/model/Dataset.js +1 -0
- package/dist/esm/model/EditorDefinition.js +1 -0
- package/dist/esm/model/GraphProcessor.js +1198 -0
- package/dist/esm/model/NodeBase.js +1 -0
- package/dist/esm/model/NodeBodySpec.js +1 -0
- package/dist/esm/model/NodeDefinition.js +12 -0
- package/dist/esm/model/NodeGraph.js +14 -0
- package/dist/esm/model/NodeImpl.js +49 -0
- package/dist/esm/model/NodeRegistration.js +144 -0
- package/dist/esm/model/Nodes.js +227 -0
- package/dist/esm/model/PluginLoadSpec.js +1 -0
- package/dist/esm/model/ProcessContext.js +1 -0
- package/dist/esm/model/Project.js +2 -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/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 +199 -0
- package/dist/esm/model/nodes/AssemblePromptNode.js +129 -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 +136 -0
- package/dist/esm/model/nodes/ChatNode.js +964 -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 +136 -0
- package/dist/esm/model/nodes/CommentNode.js +69 -0
- package/dist/esm/model/nodes/CompareNode.js +138 -0
- package/dist/esm/model/nodes/ContextNode.js +99 -0
- package/dist/esm/model/nodes/CreateDatasetNode.js +71 -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 +136 -0
- package/dist/esm/model/nodes/DestructureNode.js +86 -0
- package/dist/esm/model/nodes/EvaluateNode.js +141 -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 +128 -0
- package/dist/esm/model/nodes/ExtractRegexNode.js +201 -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/GptFunctionNode.js +169 -0
- package/dist/esm/model/nodes/GraphInputNode.js +130 -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 +257 -0
- package/dist/esm/model/nodes/IfElseNode.js +138 -0
- package/dist/esm/model/nodes/IfNode.js +124 -0
- package/dist/esm/model/nodes/ImageNode.js +107 -0
- package/dist/esm/model/nodes/JoinNode.js +135 -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/MatchNode.js +137 -0
- package/dist/esm/model/nodes/NumberNode.js +86 -0
- package/dist/esm/model/nodes/ObjectNode.js +121 -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 +227 -0
- package/dist/esm/model/nodes/RaceInputsNode.js +86 -0
- package/dist/esm/model/nodes/RaiseEventNode.js +84 -0
- package/dist/esm/model/nodes/RandomNumberNode.js +106 -0
- package/dist/esm/model/nodes/ReadDirectoryNode.js +165 -0
- package/dist/esm/model/nodes/ReadFileNode.js +114 -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 +100 -0
- package/dist/esm/model/nodes/SplitNode.js +101 -0
- package/dist/esm/model/nodes/SubGraphNode.js +181 -0
- package/dist/esm/model/nodes/TextNode.js +97 -0
- package/dist/esm/model/nodes/ToJsonNode.js +78 -0
- package/dist/esm/model/nodes/ToYamlNode.js +68 -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 +111 -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/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/aidon/index.js +2 -0
- package/dist/esm/plugins/aidon/nodes/ChatAidonNode.js +215 -0
- package/dist/esm/plugins/aidon/plugin.js +9 -0
- package/dist/esm/plugins/anthropic/anthropic.js +187 -0
- package/dist/esm/plugins/anthropic/fetchEventSource.js +106 -0
- package/dist/esm/plugins/anthropic/index.js +2 -0
- package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +652 -0
- package/dist/esm/plugins/anthropic/plugin.js +18 -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 +125 -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 +2 -0
- package/dist/esm/plugins/gentrace/plugin.js +192 -0
- package/dist/esm/plugins/google/google.js +60 -0
- package/dist/esm/plugins/google/index.js +2 -0
- package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +364 -0
- package/dist/esm/plugins/google/plugin.js +32 -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 +145 -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 +21 -0
- package/dist/esm/recording/ExecutionRecorder.js +177 -0
- package/dist/esm/recording/RecordedEvents.js +1 -0
- package/dist/esm/utils/assertNever.js +3 -0
- package/dist/esm/utils/base64.js +25 -0
- package/dist/esm/utils/chatMessageToOpenAIChatCompletionMessage.js +60 -0
- package/dist/esm/utils/coerceType.js +322 -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/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 +14 -0
- package/dist/esm/utils/inputs.js +16 -0
- package/dist/esm/utils/interpolation.js +6 -0
- package/dist/esm/utils/misc.js +1 -0
- package/dist/esm/utils/newId.js +4 -0
- package/dist/esm/utils/openai.js +219 -0
- package/dist/esm/utils/outputs.js +14 -0
- package/dist/esm/utils/serialization/serialization.js +86 -0
- package/dist/esm/utils/serialization/serializationUtils.js +13 -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 +145 -0
- package/dist/esm/utils/serialization/serialization_v4.js +200 -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/types/api/createProcessor.d.ts +37 -0
- package/dist/types/api/streaming.d.ts +56 -0
- package/dist/types/exports.d.ts +33 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/integrations/AudioProvider.d.ts +4 -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/openai/OpenAIEmbeddingGenerator.d.ts +10 -0
- package/dist/types/model/DataValue.d.ts +138 -0
- package/dist/types/model/Dataset.d.ts +19 -0
- package/dist/types/model/EditorDefinition.d.ts +142 -0
- package/dist/types/model/GraphProcessor.d.ts +192 -0
- package/dist/types/model/NodeBase.d.ts +110 -0
- package/dist/types/model/NodeBodySpec.d.ts +19 -0
- package/dist/types/model/NodeDefinition.d.ts +13 -0
- package/dist/types/model/NodeGraph.d.ts +15 -0
- package/dist/types/model/NodeImpl.d.ts +55 -0
- package/dist/types/model/NodeRegistration.d.ts +24 -0
- package/dist/types/model/Nodes.d.ts +84 -0
- package/dist/types/model/PluginLoadSpec.d.ts +17 -0
- package/dist/types/model/ProcessContext.d.ts +69 -0
- package/dist/types/model/Project.d.ts +17 -0
- package/dist/types/model/RivetPlugin.d.ts +45 -0
- package/dist/types/model/RivetUIContext.d.ts +18 -0
- package/dist/types/model/Settings.d.ts +15 -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 +20 -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/ChatNode.d.ts +77 -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 +21 -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/DatasetNearestNeigborsNode.d.ts +19 -0
- package/dist/types/model/nodes/DelayNode.d.ts +20 -0
- package/dist/types/model/nodes/DelegateFunctionCallNode.d.ts +25 -0
- package/dist/types/model/nodes/DestructureNode.d.ts +18 -0
- package/dist/types/model/nodes/EvaluateNode.d.ts +19 -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 +19 -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/GptFunctionNode.d.ts +25 -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 +27 -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/JoinNode.d.ts +21 -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/MatchNode.d.ts +19 -0
- package/dist/types/model/nodes/NumberNode.d.ts +21 -0
- package/dist/types/model/nodes/ObjectNode.d.ts +18 -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 +23 -0
- package/dist/types/model/nodes/RaceInputsNode.d.ts +17 -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/ReadDirectoryNode.d.ts +30 -0
- package/dist/types/model/nodes/ReadFileNode.d.ts +23 -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 +18 -0
- package/dist/types/model/nodes/ToJsonNode.d.ts +18 -0
- package/dist/types/model/nodes/ToYamlNode.d.ts +13 -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 +21 -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/native/BaseDir.d.ts +29 -0
- package/dist/types/native/BrowserNativeApi.d.ts +11 -0
- package/dist/types/native/NativeApi.d.ts +17 -0
- package/dist/types/plugins/aidon/index.d.ts +2 -0
- package/dist/types/plugins/aidon/nodes/ChatAidonNode.d.ts +3 -0
- package/dist/types/plugins/aidon/plugin.d.ts +2 -0
- package/dist/types/plugins/anthropic/anthropic.d.ts +216 -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 +30 -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 +5 -0
- package/dist/types/plugins/google/google.d.ts +60 -0
- package/dist/types/plugins/google/index.d.ts +2 -0
- package/dist/types/plugins/google/nodes/ChatGoogleNode.d.ts +27 -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 +20 -0
- package/dist/types/recording/ExecutionRecorder.d.ts +25 -0
- package/dist/types/recording/RecordedEvents.d.ts +100 -0
- package/dist/types/utils/assertNever.d.ts +1 -0
- package/dist/types/utils/base64.d.ts +2 -0
- package/dist/types/utils/chatMessageToOpenAIChatCompletionMessage.d.ts +3 -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/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 +14 -0
- package/dist/types/utils/inputs.d.ts +3 -0
- package/dist/types/utils/interpolation.d.ts +1 -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 +739 -0
- package/dist/types/utils/outputs.d.ts +3 -0
- package/dist/types/utils/serialization/serialization.d.ts +12 -0
- package/dist/types/utils/serialization/serializationUtils.d.ts +6 -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/package.json +97 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { dedent } from 'ts-dedent';
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { orderBy } from 'lodash-es';
|
|
2
|
+
import { DEFAULT_CHAT_NODE_TIMEOUT } from './defaults.js';
|
|
3
|
+
import fetchEventSource from './fetchEventSource.js';
|
|
4
|
+
export const openaiModels = {
|
|
5
|
+
'gpt-4': {
|
|
6
|
+
maxTokens: 8192,
|
|
7
|
+
cost: {
|
|
8
|
+
prompt: 0.03,
|
|
9
|
+
completion: 0.06,
|
|
10
|
+
},
|
|
11
|
+
displayName: 'GPT-4',
|
|
12
|
+
},
|
|
13
|
+
'gpt-4-32k': {
|
|
14
|
+
maxTokens: 32768,
|
|
15
|
+
cost: {
|
|
16
|
+
prompt: 0.06,
|
|
17
|
+
completion: 0.12,
|
|
18
|
+
},
|
|
19
|
+
displayName: 'GPT-4 32k',
|
|
20
|
+
},
|
|
21
|
+
'gpt-4-0613': {
|
|
22
|
+
maxTokens: 8192,
|
|
23
|
+
cost: {
|
|
24
|
+
prompt: 0.03,
|
|
25
|
+
completion: 0.06,
|
|
26
|
+
},
|
|
27
|
+
displayName: 'GPT-4 (v0613)',
|
|
28
|
+
},
|
|
29
|
+
'gpt-4-32k-0613': {
|
|
30
|
+
maxTokens: 32768,
|
|
31
|
+
cost: {
|
|
32
|
+
prompt: 0.06,
|
|
33
|
+
completion: 0.12,
|
|
34
|
+
},
|
|
35
|
+
displayName: 'GPT-4 32k (v0613)',
|
|
36
|
+
},
|
|
37
|
+
'gpt-3.5-turbo': {
|
|
38
|
+
maxTokens: 4096,
|
|
39
|
+
cost: {
|
|
40
|
+
prompt: 0.002,
|
|
41
|
+
completion: 0.002,
|
|
42
|
+
},
|
|
43
|
+
displayName: 'GPT-3.5 Turbo',
|
|
44
|
+
},
|
|
45
|
+
'gpt-3.5-turbo-16k': {
|
|
46
|
+
maxTokens: 16384,
|
|
47
|
+
cost: {
|
|
48
|
+
prompt: 0.001,
|
|
49
|
+
completion: 0.002,
|
|
50
|
+
},
|
|
51
|
+
displayName: 'GPT-3.5 16k',
|
|
52
|
+
},
|
|
53
|
+
'gpt-3.5-turbo-0613': {
|
|
54
|
+
maxTokens: 16384,
|
|
55
|
+
cost: {
|
|
56
|
+
prompt: 0.002,
|
|
57
|
+
completion: 0.002,
|
|
58
|
+
},
|
|
59
|
+
displayName: 'GPT-3.5 (v0613)',
|
|
60
|
+
},
|
|
61
|
+
'gpt-3.5-turbo-1106': {
|
|
62
|
+
maxTokens: 16385,
|
|
63
|
+
cost: {
|
|
64
|
+
prompt: 0.001,
|
|
65
|
+
completion: 0.002,
|
|
66
|
+
},
|
|
67
|
+
displayName: 'GPT-3.5 (v1106)',
|
|
68
|
+
},
|
|
69
|
+
'gpt-3.5-turbo-16k-0613': {
|
|
70
|
+
maxTokens: 16384,
|
|
71
|
+
cost: {
|
|
72
|
+
prompt: 0.001,
|
|
73
|
+
completion: 0.002,
|
|
74
|
+
},
|
|
75
|
+
displayName: 'GPT-3.5 16k (v0613)',
|
|
76
|
+
},
|
|
77
|
+
'gpt-3.5-turbo-0301': {
|
|
78
|
+
maxTokens: 16384,
|
|
79
|
+
cost: {
|
|
80
|
+
prompt: 0.002,
|
|
81
|
+
completion: 0.002,
|
|
82
|
+
},
|
|
83
|
+
displayName: 'GPT-3.5 (v0301)',
|
|
84
|
+
},
|
|
85
|
+
'gpt-4-0314': {
|
|
86
|
+
maxTokens: 8192,
|
|
87
|
+
cost: {
|
|
88
|
+
prompt: 0.03,
|
|
89
|
+
completion: 0.06,
|
|
90
|
+
},
|
|
91
|
+
displayName: 'GPT-4 (v0314)',
|
|
92
|
+
},
|
|
93
|
+
'gpt-4-32k-0314': {
|
|
94
|
+
maxTokens: 32768,
|
|
95
|
+
cost: {
|
|
96
|
+
prompt: 0.06,
|
|
97
|
+
completion: 0.12,
|
|
98
|
+
},
|
|
99
|
+
displayName: 'GPT-4 32k (v0314)',
|
|
100
|
+
},
|
|
101
|
+
'gpt-4-1106-preview': {
|
|
102
|
+
maxTokens: 128000,
|
|
103
|
+
cost: {
|
|
104
|
+
prompt: 0.01,
|
|
105
|
+
completion: 0.03,
|
|
106
|
+
},
|
|
107
|
+
displayName: 'GPT-4 Turbo 128K (1106 Preview)',
|
|
108
|
+
},
|
|
109
|
+
'gpt-4-turbo': {
|
|
110
|
+
maxTokens: 128000,
|
|
111
|
+
cost: {
|
|
112
|
+
prompt: 0.01,
|
|
113
|
+
completion: 0.03,
|
|
114
|
+
},
|
|
115
|
+
displayName: 'GPT-4 Turbo 128K with Vision',
|
|
116
|
+
},
|
|
117
|
+
'gpt-4-vision-preview': {
|
|
118
|
+
maxTokens: 128000,
|
|
119
|
+
cost: {
|
|
120
|
+
prompt: 0.01,
|
|
121
|
+
completion: 0.03,
|
|
122
|
+
},
|
|
123
|
+
displayName: 'GPT-4 Vision (Preview)',
|
|
124
|
+
},
|
|
125
|
+
'gpt-4o': {
|
|
126
|
+
maxTokens: 128000,
|
|
127
|
+
cost: {
|
|
128
|
+
prompt: 0.005,
|
|
129
|
+
completion: 0.015,
|
|
130
|
+
},
|
|
131
|
+
displayName: 'GPT-4o',
|
|
132
|
+
},
|
|
133
|
+
'gpt-4o-mini': {
|
|
134
|
+
maxTokens: 128000,
|
|
135
|
+
cost: {
|
|
136
|
+
prompt: 0.00015,
|
|
137
|
+
completion: 0.00075,
|
|
138
|
+
},
|
|
139
|
+
displayName: 'GPT-4o mini',
|
|
140
|
+
},
|
|
141
|
+
'gpt-4o-mini-2024-07-18': {
|
|
142
|
+
maxTokens: 128000,
|
|
143
|
+
cost: {
|
|
144
|
+
prompt: 0.00015,
|
|
145
|
+
completion: 0.00075,
|
|
146
|
+
},
|
|
147
|
+
displayName: 'GPT-4o mini (2024-07-18)',
|
|
148
|
+
},
|
|
149
|
+
'local-model': {
|
|
150
|
+
maxTokens: Number.MAX_SAFE_INTEGER,
|
|
151
|
+
cost: {
|
|
152
|
+
prompt: 0,
|
|
153
|
+
completion: 0,
|
|
154
|
+
},
|
|
155
|
+
displayName: 'Local Model',
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
export const openAiModelOptions = orderBy(Object.entries(openaiModels).map(([id, { displayName }]) => ({
|
|
159
|
+
value: id,
|
|
160
|
+
label: displayName,
|
|
161
|
+
})), 'label');
|
|
162
|
+
export class OpenAIError extends Error {
|
|
163
|
+
status;
|
|
164
|
+
responseJson;
|
|
165
|
+
constructor(status, responseJson) {
|
|
166
|
+
super(`OpenAIError: ${status} ${JSON.stringify(responseJson)}`);
|
|
167
|
+
this.status = status;
|
|
168
|
+
this.responseJson = responseJson;
|
|
169
|
+
this.name = 'OpenAIError';
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
export async function* streamChatCompletions({ endpoint, auth, signal, headers, timeout, ...rest }) {
|
|
173
|
+
const abortSignal = signal ?? new AbortController().signal;
|
|
174
|
+
const response = await fetchEventSource(endpoint, {
|
|
175
|
+
method: 'POST',
|
|
176
|
+
headers: {
|
|
177
|
+
'Content-Type': 'application/json',
|
|
178
|
+
Authorization: `Bearer ${auth.apiKey}`,
|
|
179
|
+
...(auth.organization ? { 'OpenAI-Organization': auth.organization } : {}),
|
|
180
|
+
...headers,
|
|
181
|
+
},
|
|
182
|
+
body: JSON.stringify({
|
|
183
|
+
...rest,
|
|
184
|
+
stream: true,
|
|
185
|
+
}),
|
|
186
|
+
signal: abortSignal,
|
|
187
|
+
}, timeout ?? DEFAULT_CHAT_NODE_TIMEOUT);
|
|
188
|
+
let hadChunks = false;
|
|
189
|
+
for await (const chunk of response.events()) {
|
|
190
|
+
hadChunks = true;
|
|
191
|
+
if (chunk === '[DONE]' || abortSignal?.aborted) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
let data;
|
|
195
|
+
try {
|
|
196
|
+
data = JSON.parse(chunk);
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
console.error('JSON parse failed on chunk: ', chunk);
|
|
200
|
+
throw err;
|
|
201
|
+
}
|
|
202
|
+
yield data;
|
|
203
|
+
}
|
|
204
|
+
if (!hadChunks) {
|
|
205
|
+
const responseJson = await response.json();
|
|
206
|
+
throw new OpenAIError(response.status, responseJson);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
export const openAIFilePurposeOptions = [
|
|
210
|
+
{ value: 'fine-tune', label: 'Fine-tuning' },
|
|
211
|
+
{ value: 'fine-tune-results', label: 'Fine-tuning Results' },
|
|
212
|
+
{ value: 'assistants', label: 'Assistants' },
|
|
213
|
+
{ value: 'assistants_output', label: 'Assistants Output' },
|
|
214
|
+
];
|
|
215
|
+
export const openAIFileUploadPurposeOptions = [
|
|
216
|
+
{ value: 'fine-tune', label: 'Fine-tuning' },
|
|
217
|
+
{ value: 'assistants', label: 'Assistants' },
|
|
218
|
+
{ value: 'assistants_output', label: 'Assistants Output' },
|
|
219
|
+
];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { expectType } from './expectType.js';
|
|
2
|
+
import { WarningsPort } from './symbols.js';
|
|
3
|
+
export function addWarning(outputs, warning) {
|
|
4
|
+
if (!outputs[WarningsPort]) {
|
|
5
|
+
outputs[WarningsPort] = { type: 'string[]', value: [] };
|
|
6
|
+
}
|
|
7
|
+
outputs[WarningsPort].value.push(warning);
|
|
8
|
+
}
|
|
9
|
+
export function getWarnings(outputs) {
|
|
10
|
+
if (!outputs?.[WarningsPort]) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
return expectType(outputs[WarningsPort], 'string[]');
|
|
14
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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 { 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
|
+
try {
|
|
15
|
+
const result = projectV4Deserializer(serializedProject);
|
|
16
|
+
if (path !== null)
|
|
17
|
+
result[0].metadata.path = path;
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
if (err instanceof yaml.YAMLError) {
|
|
22
|
+
yamlProblem(err);
|
|
23
|
+
}
|
|
24
|
+
console.warn(`Failed to deserialize project v4: ${errMessage(err)}`);
|
|
25
|
+
try {
|
|
26
|
+
const project = projectV3Deserializer(serializedProject);
|
|
27
|
+
return [project, {}];
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
if (err instanceof yaml.YAMLError) {
|
|
31
|
+
yamlProblem(err);
|
|
32
|
+
}
|
|
33
|
+
console.warn(`Failed to deserialize project v3: ${errMessage(err)}`);
|
|
34
|
+
try {
|
|
35
|
+
const project = projectV2Deserializer(serializedProject);
|
|
36
|
+
return [project, {}];
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
if (err instanceof yaml.YAMLError) {
|
|
40
|
+
yamlProblem(err);
|
|
41
|
+
}
|
|
42
|
+
console.warn(`Failed to deserialize project v2: ${errMessage(err)}`);
|
|
43
|
+
try {
|
|
44
|
+
const project = projectV1Deserializer(serializedProject);
|
|
45
|
+
return [project, {}];
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
console.warn(`Failed to deserialize project v1: ${errMessage(err)}`);
|
|
49
|
+
throw new Error('Could not deserialize project');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function serializeGraph(graph) {
|
|
56
|
+
return graphV4Serializer(graph);
|
|
57
|
+
}
|
|
58
|
+
export function deserializeGraph(serializedGraph) {
|
|
59
|
+
try {
|
|
60
|
+
return graphV4Deserializer(serializedGraph);
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
try {
|
|
64
|
+
return graphV3Deserializer(serializedGraph);
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
try {
|
|
68
|
+
return graphV2Deserializer(serializedGraph);
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
try {
|
|
72
|
+
return graphV1Deserializer(serializedGraph);
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
throw new Error('Could not deserialize graph');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export function serializeDatasets(datasets) {
|
|
82
|
+
return datasetV4Serializer(datasets);
|
|
83
|
+
}
|
|
84
|
+
export function deserializeDatasets(serializedDatasets) {
|
|
85
|
+
return datasetV4Deserializer(serializedDatasets);
|
|
86
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function doubleCheckProject(project) {
|
|
2
|
+
if (!project.metadata ||
|
|
3
|
+
!project.metadata.id ||
|
|
4
|
+
!project.metadata.title ||
|
|
5
|
+
!project.graphs ||
|
|
6
|
+
typeof project.graphs !== 'object') {
|
|
7
|
+
throw new Error('Invalid project file');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function yamlProblem(err) {
|
|
11
|
+
const { code, message, pos, linePos } = err;
|
|
12
|
+
throw new Error(`YAML error: ${code} ${message} at ${pos} ${linePos}`);
|
|
13
|
+
}
|
|
@@ -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,145 @@
|
|
|
1
|
+
import { mapValues } from 'lodash-es';
|
|
2
|
+
import stableStringify from 'safe-stable-stringify';
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import * as yaml from 'yaml';
|
|
5
|
+
import { doubleCheckProject } from './serializationUtils.js';
|
|
6
|
+
export function projectV3Deserializer(data) {
|
|
7
|
+
if (typeof data !== 'string') {
|
|
8
|
+
throw new Error('Project v3 deserializer requires a string');
|
|
9
|
+
}
|
|
10
|
+
const serializedProject = yaml.parse(data);
|
|
11
|
+
if (serializedProject.version !== 3) {
|
|
12
|
+
throw new Error('Project v3 deserializer requires a version 3 project');
|
|
13
|
+
}
|
|
14
|
+
const project = fromSerializedProject(serializedProject.data);
|
|
15
|
+
doubleCheckProject(project);
|
|
16
|
+
return project;
|
|
17
|
+
}
|
|
18
|
+
export function graphV3Deserializer(data) {
|
|
19
|
+
if (typeof data !== 'string') {
|
|
20
|
+
throw new Error('Graph v3 deserializer requires a string');
|
|
21
|
+
}
|
|
22
|
+
const serializedGraph = yaml.parse(data);
|
|
23
|
+
if (serializedGraph.version !== 3) {
|
|
24
|
+
throw new Error('Graph v3 deserializer requires a version 3 graph');
|
|
25
|
+
}
|
|
26
|
+
return fromSerializedGraph(serializedGraph.data);
|
|
27
|
+
}
|
|
28
|
+
export function projectV3Serializer(project) {
|
|
29
|
+
// Make sure all data is ordered deterministically first
|
|
30
|
+
const stabilized = JSON.parse(stableStringify(toSerializedProject(project)));
|
|
31
|
+
const serialized = yaml.stringify({
|
|
32
|
+
version: 3,
|
|
33
|
+
data: stabilized,
|
|
34
|
+
}, null, {
|
|
35
|
+
indent: 2,
|
|
36
|
+
});
|
|
37
|
+
return serialized;
|
|
38
|
+
}
|
|
39
|
+
export function graphV3Serializer(graph) {
|
|
40
|
+
// Make sure all data is ordered deterministically first
|
|
41
|
+
const stabilized = JSON.parse(stableStringify(toSerializedGraph(graph)));
|
|
42
|
+
const serialized = yaml.stringify({
|
|
43
|
+
version: 4,
|
|
44
|
+
data: stabilized,
|
|
45
|
+
}, null, {
|
|
46
|
+
indent: 2,
|
|
47
|
+
});
|
|
48
|
+
return serialized;
|
|
49
|
+
}
|
|
50
|
+
function toSerializedProject(project) {
|
|
51
|
+
return {
|
|
52
|
+
metadata: project.metadata,
|
|
53
|
+
graphs: mapValues(project.graphs, (graph) => toSerializedGraph(graph)),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function fromSerializedProject(serializedProject) {
|
|
57
|
+
return {
|
|
58
|
+
metadata: serializedProject.metadata,
|
|
59
|
+
graphs: mapValues(serializedProject.graphs, (graph) => fromSerializedGraph(graph)),
|
|
60
|
+
plugins: [],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function toSerializedGraph(graph) {
|
|
64
|
+
return {
|
|
65
|
+
metadata: {
|
|
66
|
+
id: graph.metadata.id,
|
|
67
|
+
name: graph.metadata.name,
|
|
68
|
+
description: graph.metadata.description,
|
|
69
|
+
},
|
|
70
|
+
nodes: graph.nodes.reduce((acc, node) => ({
|
|
71
|
+
...acc,
|
|
72
|
+
[node.id]: toSerializedNode(node, graph.nodes, graph.connections),
|
|
73
|
+
}), {}),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function fromSerializedGraph(serializedGraph) {
|
|
77
|
+
const allConnections = [];
|
|
78
|
+
const allNodes = [];
|
|
79
|
+
for (const node of Object.values(serializedGraph.nodes)) {
|
|
80
|
+
const [chartNode, connections] = fromSerializedNode(node);
|
|
81
|
+
allNodes.push(chartNode);
|
|
82
|
+
allConnections.push(...connections);
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
metadata: {
|
|
86
|
+
id: serializedGraph.metadata.id,
|
|
87
|
+
name: serializedGraph.metadata.name,
|
|
88
|
+
description: serializedGraph.metadata.description,
|
|
89
|
+
},
|
|
90
|
+
nodes: allNodes,
|
|
91
|
+
connections: allConnections,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function toSerializedNode(node, allNodes, allConnections) {
|
|
95
|
+
return {
|
|
96
|
+
id: node.id,
|
|
97
|
+
title: node.title,
|
|
98
|
+
description: node.description,
|
|
99
|
+
type: node.type,
|
|
100
|
+
visualData: `${node.visualData.x}/${node.visualData.y}/${node.visualData.width ?? 'null'}/${node.visualData.zIndex ?? 'null'}`,
|
|
101
|
+
isSplitRun: node.isSplitRun,
|
|
102
|
+
splitRunMax: node.splitRunMax,
|
|
103
|
+
data: node.data,
|
|
104
|
+
outgoingConnections: allConnections
|
|
105
|
+
.filter((connection) => connection.outputNodeId === node.id)
|
|
106
|
+
.map((connection) => toSerializedConnection(connection, allNodes))
|
|
107
|
+
.sort(),
|
|
108
|
+
variants: (node.variants?.length ?? 0) > 0 ? node.variants : undefined,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function fromSerializedNode(serializedNode) {
|
|
112
|
+
const [x, y, width, zIndex] = serializedNode.visualData.split('/');
|
|
113
|
+
const connections = serializedNode.outgoingConnections.map((serializedConnection) => fromSerializedConnection(serializedConnection, serializedNode));
|
|
114
|
+
return [
|
|
115
|
+
{
|
|
116
|
+
id: serializedNode.id,
|
|
117
|
+
title: serializedNode.title,
|
|
118
|
+
description: serializedNode.description,
|
|
119
|
+
type: serializedNode.type,
|
|
120
|
+
isSplitRun: serializedNode.isSplitRun,
|
|
121
|
+
splitRunMax: serializedNode.splitRunMax,
|
|
122
|
+
visualData: {
|
|
123
|
+
x: parseFloat(x),
|
|
124
|
+
y: parseFloat(y),
|
|
125
|
+
width: width === 'null' ? undefined : parseFloat(width),
|
|
126
|
+
zIndex: zIndex === 'null' ? undefined : parseFloat(zIndex),
|
|
127
|
+
},
|
|
128
|
+
data: serializedNode.data,
|
|
129
|
+
variants: serializedNode.variants,
|
|
130
|
+
},
|
|
131
|
+
connections,
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
function toSerializedConnection(connection, allNodes) {
|
|
135
|
+
return `${connection.outputId}->"${allNodes.find((node) => node.id === connection.inputNodeId)?.title}" ${connection.inputNodeId}/${connection.inputId}`;
|
|
136
|
+
}
|
|
137
|
+
function fromSerializedConnection(connection, outgoingNode) {
|
|
138
|
+
const [, outputId, , inputNodeId, inputId] = connection.match(/(.+)->"(.+)" (.+)\/(.+)/);
|
|
139
|
+
return {
|
|
140
|
+
outputId: outputId,
|
|
141
|
+
outputNodeId: outgoingNode.id,
|
|
142
|
+
inputId: inputId,
|
|
143
|
+
inputNodeId: inputNodeId,
|
|
144
|
+
};
|
|
145
|
+
}
|