@kyuda/n8n-nodes-databricks 1.0.2
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.
Potentially problematic release.
This version of @kyuda/n8n-nodes-databricks might be problematic. Click here for more details.
- package/LICENSE.md +19 -0
- package/README.md +478 -0
- package/dist/credentials/Databricks.credentials.d.ts +10 -0
- package/dist/credentials/Databricks.credentials.js +51 -0
- package/dist/credentials/Databricks.credentials.js.map +1 -0
- package/dist/credentials/databricks.svg +19 -0
- package/dist/nodes/Databricks/Databricks.node.d.ts +16 -0
- package/dist/nodes/Databricks/Databricks.node.js +1719 -0
- package/dist/nodes/Databricks/Databricks.node.js.map +1 -0
- package/dist/nodes/Databricks/databricks.dark.svg +19 -0
- package/dist/nodes/Databricks/databricks.svg +19 -0
- package/dist/nodes/Databricks/resources/databricksSql/operations.d.ts +2 -0
- package/dist/nodes/Databricks/resources/databricksSql/operations.js +24 -0
- package/dist/nodes/Databricks/resources/databricksSql/operations.js.map +1 -0
- package/dist/nodes/Databricks/resources/databricksSql/parameters.d.ts +2 -0
- package/dist/nodes/Databricks/resources/databricksSql/parameters.js +94 -0
- package/dist/nodes/Databricks/resources/databricksSql/parameters.js.map +1 -0
- package/dist/nodes/Databricks/resources/databricksSql.d.ts +3 -0
- package/dist/nodes/Databricks/resources/databricksSql.js +130 -0
- package/dist/nodes/Databricks/resources/databricksSql.js.map +1 -0
- package/dist/nodes/Databricks/resources/files/operations.d.ts +2 -0
- package/dist/nodes/Databricks/resources/files/operations.js +71 -0
- package/dist/nodes/Databricks/resources/files/operations.js.map +1 -0
- package/dist/nodes/Databricks/resources/files/parameters.d.ts +2 -0
- package/dist/nodes/Databricks/resources/files/parameters.js +124 -0
- package/dist/nodes/Databricks/resources/files/parameters.js.map +1 -0
- package/dist/nodes/Databricks/resources/files.d.ts +3 -0
- package/dist/nodes/Databricks/resources/files.js +183 -0
- package/dist/nodes/Databricks/resources/files.js.map +1 -0
- package/dist/nodes/Databricks/resources/genie/operations.d.ts +2 -0
- package/dist/nodes/Databricks/resources/genie/operations.js +96 -0
- package/dist/nodes/Databricks/resources/genie/operations.js.map +1 -0
- package/dist/nodes/Databricks/resources/genie/parameters.d.ts +2 -0
- package/dist/nodes/Databricks/resources/genie/parameters.js +96 -0
- package/dist/nodes/Databricks/resources/genie/parameters.js.map +1 -0
- package/dist/nodes/Databricks/resources/index.d.ts +12 -0
- package/dist/nodes/Databricks/resources/index.js +29 -0
- package/dist/nodes/Databricks/resources/index.js.map +1 -0
- package/dist/nodes/Databricks/resources/modelServing/operations.d.ts +2 -0
- package/dist/nodes/Databricks/resources/modelServing/operations.js +24 -0
- package/dist/nodes/Databricks/resources/modelServing/operations.js.map +1 -0
- package/dist/nodes/Databricks/resources/modelServing/parameters.d.ts +2 -0
- package/dist/nodes/Databricks/resources/modelServing/parameters.js +76 -0
- package/dist/nodes/Databricks/resources/modelServing/parameters.js.map +1 -0
- package/dist/nodes/Databricks/resources/modelServing.d.ts +3 -0
- package/dist/nodes/Databricks/resources/modelServing.js +176 -0
- package/dist/nodes/Databricks/resources/modelServing.js.map +1 -0
- package/dist/nodes/Databricks/resources/unityCatalog/operations.d.ts +2 -0
- package/dist/nodes/Databricks/resources/unityCatalog/operations.js +233 -0
- package/dist/nodes/Databricks/resources/unityCatalog/operations.js.map +1 -0
- package/dist/nodes/Databricks/resources/unityCatalog/parameters.d.ts +2 -0
- package/dist/nodes/Databricks/resources/unityCatalog/parameters.js +371 -0
- package/dist/nodes/Databricks/resources/unityCatalog/parameters.js.map +1 -0
- package/dist/nodes/Databricks/resources/unityCatalog.d.ts +3 -0
- package/dist/nodes/Databricks/resources/unityCatalog.js +239 -0
- package/dist/nodes/Databricks/resources/unityCatalog.js.map +1 -0
- package/dist/nodes/Databricks/resources/vectorSearch/operations.d.ts +2 -0
- package/dist/nodes/Databricks/resources/vectorSearch/operations.js +48 -0
- package/dist/nodes/Databricks/resources/vectorSearch/operations.js.map +1 -0
- package/dist/nodes/Databricks/resources/vectorSearch/parameters.d.ts +2 -0
- package/dist/nodes/Databricks/resources/vectorSearch/parameters.js +224 -0
- package/dist/nodes/Databricks/resources/vectorSearch/parameters.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/CallbackHandler.d.ts +66 -0
- package/dist/nodes/agents/DatabricksAiAgent/CallbackHandler.js +531 -0
- package/dist/nodes/agents/DatabricksAiAgent/CallbackHandler.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/DatabricksAiAgent.node.d.ts +5 -0
- package/dist/nodes/agents/DatabricksAiAgent/DatabricksAiAgent.node.js +133 -0
- package/dist/nodes/agents/DatabricksAiAgent/DatabricksAiAgent.node.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/DatabricksAiAgentDark.icon.svg +9 -0
- package/dist/nodes/agents/DatabricksAiAgent/DatabricksAiAgentLight.icon.svg +9 -0
- package/dist/nodes/agents/DatabricksAiAgent/description.d.ts +4 -0
- package/dist/nodes/agents/DatabricksAiAgent/description.js +28 -0
- package/dist/nodes/agents/DatabricksAiAgent/description.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/execute.d.ts +2 -0
- package/dist/nodes/agents/DatabricksAiAgent/execute.js +418 -0
- package/dist/nodes/agents/DatabricksAiAgent/execute.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/constants.d.ts +82 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/constants.js +105 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/constants.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/types/types.d.ts +6 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/types/types.js +3 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/types/types.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/N8nOutputParser.d.ts +5 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/N8nOutputParser.js +13 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/N8nOutputParser.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/N8nTool.d.ts +10 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/N8nTool.js +88 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/N8nTool.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/common.d.ts +28 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/common.js +207 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/common.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/descriptions.d.ts +17 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/descriptions.js +135 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/descriptions.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/helpers.d.ts +24 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/helpers.js +221 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/helpers.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/options.d.ts +2 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/options.js +38 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/options.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/output_parsers/N8nStructuredOutputParser.d.ts +12 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/output_parsers/N8nStructuredOutputParser.js +106 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/output_parsers/N8nStructuredOutputParser.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/prompt.d.ts +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/prompt.js +5 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/prompt.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/retry.d.ts +16 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/retry.js +132 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/retry.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/security.d.ts +18 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/security.js +150 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/security.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/sharedFields.d.ts +7 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/sharedFields.js +150 -0
- package/dist/nodes/agents/DatabricksAiAgent/src/utils/sharedFields.js.map +1 -0
- package/dist/nodes/agents/DatabricksAiAgent/utils.d.ts +2 -0
- package/dist/nodes/agents/DatabricksAiAgent/utils.js +52 -0
- package/dist/nodes/agents/DatabricksAiAgent/utils.js.map +1 -0
- package/dist/nodes/embeddings/EmbeddingsDatabricks/EmbeddingsDatabricks.node.d.ts +5 -0
- package/dist/nodes/embeddings/EmbeddingsDatabricks/EmbeddingsDatabricks.node.js +155 -0
- package/dist/nodes/embeddings/EmbeddingsDatabricks/EmbeddingsDatabricks.node.js.map +1 -0
- package/dist/nodes/embeddings/EmbeddingsDatabricks/databricks.dark.svg +19 -0
- package/dist/nodes/embeddings/EmbeddingsDatabricks/databricks.svg +19 -0
- package/dist/nodes/llms/LmChatDatabricks/LmChatDatabricks.node.d.ts +10 -0
- package/dist/nodes/llms/LmChatDatabricks/LmChatDatabricks.node.js +265 -0
- package/dist/nodes/llms/LmChatDatabricks/LmChatDatabricks.node.js.map +1 -0
- package/dist/nodes/llms/LmChatDatabricks/databricks.dark.svg +19 -0
- package/dist/nodes/llms/LmChatDatabricks/databricks.svg +19 -0
- package/dist/nodes/llms/N8nLlmTracing.d.ts +44 -0
- package/dist/nodes/llms/N8nLlmTracing.js +140 -0
- package/dist/nodes/llms/N8nLlmTracing.js.map +1 -0
- package/dist/nodes/llms/n8nDefaultFailedAttemptHandler.d.ts +1 -0
- package/dist/nodes/llms/n8nDefaultFailedAttemptHandler.js +31 -0
- package/dist/nodes/llms/n8nDefaultFailedAttemptHandler.js.map +1 -0
- package/dist/nodes/llms/n8nDefaultFailedAttemptHandler.test.d.ts +1 -0
- package/dist/nodes/llms/n8nDefaultFailedAttemptHandler.test.js +53 -0
- package/dist/nodes/llms/n8nDefaultFailedAttemptHandler.test.js.map +1 -0
- package/dist/nodes/llms/n8nLlmFailedAttemptHandler.d.ts +3 -0
- package/dist/nodes/llms/n8nLlmFailedAttemptHandler.js +28 -0
- package/dist/nodes/llms/n8nLlmFailedAttemptHandler.js.map +1 -0
- package/dist/nodes/llms/n8nLlmFailedAttemptHandler.test.d.ts +1 -0
- package/dist/nodes/llms/n8nLlmFailedAttemptHandler.test.js +50 -0
- package/dist/nodes/llms/n8nLlmFailedAttemptHandler.test.js.map +1 -0
- package/dist/nodes/vector_store/VectorStoreDatabricks/VectorStoreDatabricks.node.d.ts +15 -0
- package/dist/nodes/vector_store/VectorStoreDatabricks/VectorStoreDatabricks.node.js +98 -0
- package/dist/nodes/vector_store/VectorStoreDatabricks/VectorStoreDatabricks.node.js.map +1 -0
- package/dist/nodes/vector_store/VectorStoreDatabricks/databricks.dark.svg +19 -0
- package/dist/nodes/vector_store/VectorStoreDatabricks/databricks.svg +19 -0
- package/dist/nodes/vector_store/shared/MemoryManager/MemoryCalculator.d.ts +7 -0
- package/dist/nodes/vector_store/shared/MemoryManager/MemoryCalculator.js +50 -0
- package/dist/nodes/vector_store/shared/MemoryManager/MemoryCalculator.js.map +1 -0
- package/dist/nodes/vector_store/shared/MemoryManager/MemoryVectorStoreManager.d.ts +32 -0
- package/dist/nodes/vector_store/shared/MemoryManager/MemoryVectorStoreManager.js +175 -0
- package/dist/nodes/vector_store/shared/MemoryManager/MemoryVectorStoreManager.js.map +1 -0
- package/dist/nodes/vector_store/shared/MemoryManager/StoreCleanupService.d.ts +16 -0
- package/dist/nodes/vector_store/shared/MemoryManager/StoreCleanupService.js +95 -0
- package/dist/nodes/vector_store/shared/MemoryManager/StoreCleanupService.js.map +1 -0
- package/dist/nodes/vector_store/shared/MemoryManager/config.d.ts +4 -0
- package/dist/nodes/vector_store/shared/MemoryManager/config.js +38 -0
- package/dist/nodes/vector_store/shared/MemoryManager/config.js.map +1 -0
- package/dist/nodes/vector_store/shared/MemoryManager/test/MemoryCalculator.test.d.ts +1 -0
- package/dist/nodes/vector_store/shared/MemoryManager/test/MemoryCalculator.test.js +158 -0
- package/dist/nodes/vector_store/shared/MemoryManager/test/MemoryCalculator.test.js.map +1 -0
- package/dist/nodes/vector_store/shared/MemoryManager/test/MemoryVectorStoreManager.test.d.ts +1 -0
- package/dist/nodes/vector_store/shared/MemoryManager/test/MemoryVectorStoreManager.test.js +204 -0
- package/dist/nodes/vector_store/shared/MemoryManager/test/MemoryVectorStoreManager.test.js.map +1 -0
- package/dist/nodes/vector_store/shared/MemoryManager/test/StoreCleanupService.test.d.ts +1 -0
- package/dist/nodes/vector_store/shared/MemoryManager/test/StoreCleanupService.test.js +138 -0
- package/dist/nodes/vector_store/shared/MemoryManager/test/StoreCleanupService.test.js.map +1 -0
- package/dist/nodes/vector_store/shared/MemoryManager/test/config.test.d.ts +1 -0
- package/dist/nodes/vector_store/shared/MemoryManager/test/config.test.js +57 -0
- package/dist/nodes/vector_store/shared/MemoryManager/test/config.test.js.map +1 -0
- package/dist/nodes/vector_store/shared/MemoryManager/types.d.ts +39 -0
- package/dist/nodes/vector_store/shared/MemoryManager/types.js +3 -0
- package/dist/nodes/vector_store/shared/MemoryManager/types.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/__tests__/utils.test.d.ts +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/__tests__/utils.test.js +156 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/__tests__/utils.test.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/constants.d.ts +4 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/constants.js +45 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/constants.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.d.ts +15 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js +227 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.test.d.ts +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.test.js +131 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.test.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/methods/listSearch.d.ts +7 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/methods/listSearch.js +32 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/methods/listSearch.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/insertOperation.test.d.ts +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/insertOperation.test.js +190 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/insertOperation.test.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/loadOperation.test.d.ts +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/loadOperation.test.js +101 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/loadOperation.test.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/operationHandlers.test.d.ts +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/operationHandlers.test.js +93 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/operationHandlers.test.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/retrieveAsToolOperation.test.d.ts +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/retrieveAsToolOperation.test.js +109 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/retrieveAsToolOperation.test.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/retrieveOperation.test.d.ts +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/retrieveOperation.test.js +60 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/retrieveOperation.test.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/updateOperation.test.d.ts +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/updateOperation.test.js +108 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/__tests__/updateOperation.test.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/index.d.ts +5 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/index.js +22 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/index.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/insertOperation.d.ts +5 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/insertOperation.js +36 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/insertOperation.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/loadOperation.d.ts +5 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/loadOperation.js +34 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/loadOperation.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.d.ts +5 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.js +43 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.d.ts +5 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.js +17 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/updateOperation.d.ts +5 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/updateOperation.js +40 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/updateOperation.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/test-helpers.d.ts +0 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/test-helpers.js +2 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/test-helpers.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/types.d.ts +31 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/types.js +3 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/types.js.map +1 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/utils.d.ts +6 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/utils.js +22 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/utils.js.map +1 -0
- package/dist/nodes/vector_store/shared/descriptions.d.ts +4 -0
- package/dist/nodes/vector_store/shared/descriptions.js +70 -0
- package/dist/nodes/vector_store/shared/descriptions.js.map +1 -0
- package/dist/nodes/vector_store/shared/processDocuments.d.ts +25 -0
- package/dist/nodes/vector_store/shared/processDocuments.js +42 -0
- package/dist/nodes/vector_store/shared/processDocuments.js.map +1 -0
- package/dist/package.json +93 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/DatabricksVectorStoreLangChain.d.ts +26 -0
- package/dist/utils/DatabricksVectorStoreLangChain.js +114 -0
- package/dist/utils/DatabricksVectorStoreLangChain.js.map +1 -0
- package/dist/utils/N8nBinaryLoader.d.ts +18 -0
- package/dist/utils/N8nBinaryLoader.js +159 -0
- package/dist/utils/N8nBinaryLoader.js.map +1 -0
- package/dist/utils/N8nJsonLoader.d.ts +11 -0
- package/dist/utils/N8nJsonLoader.js +67 -0
- package/dist/utils/N8nJsonLoader.js.map +1 -0
- package/dist/utils/N8nTool.d.ts +10 -0
- package/dist/utils/N8nTool.js +88 -0
- package/dist/utils/N8nTool.js.map +1 -0
- package/dist/utils/descriptions.d.ts +13 -0
- package/dist/utils/descriptions.js +112 -0
- package/dist/utils/descriptions.js.map +1 -0
- package/dist/utils/helpers.d.ts +23 -0
- package/dist/utils/helpers.js +172 -0
- package/dist/utils/helpers.js.map +1 -0
- package/dist/utils/logWrapper.d.ts +27 -0
- package/dist/utils/logWrapper.js +297 -0
- package/dist/utils/logWrapper.js.map +1 -0
- package/dist/utils/output_parsers/N8nItemListOutputParser.d.ts +13 -0
- package/dist/utils/output_parsers/N8nItemListOutputParser.js +43 -0
- package/dist/utils/output_parsers/N8nItemListOutputParser.js.map +1 -0
- package/dist/utils/output_parsers/N8nOutputFixingParser.d.ts +18 -0
- package/dist/utils/output_parsers/N8nOutputFixingParser.js +68 -0
- package/dist/utils/output_parsers/N8nOutputFixingParser.js.map +1 -0
- package/dist/utils/output_parsers/N8nOutputParser.d.ts +7 -0
- package/dist/utils/output_parsers/N8nOutputParser.js +19 -0
- package/dist/utils/output_parsers/N8nOutputParser.js.map +1 -0
- package/dist/utils/output_parsers/N8nStructuredOutputParser.d.ts +12 -0
- package/dist/utils/output_parsers/N8nStructuredOutputParser.js +84 -0
- package/dist/utils/output_parsers/N8nStructuredOutputParser.js.map +1 -0
- package/dist/utils/output_parsers/prompt.d.ts +3 -0
- package/dist/utils/output_parsers/prompt.js +22 -0
- package/dist/utils/output_parsers/prompt.js.map +1 -0
- package/dist/utils/schemaParsing.d.ts +6 -0
- package/dist/utils/schemaParsing.js +23 -0
- package/dist/utils/schemaParsing.js.map +1 -0
- package/dist/utils/sharedFields.d.ts +6 -0
- package/dist/utils/sharedFields.js +122 -0
- package/dist/utils/sharedFields.js.map +1 -0
- package/dist/utils/tracing.d.ts +7 -0
- package/dist/utils/tracing.js +20 -0
- package/dist/utils/tracing.js.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,1719 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Databricks = void 0;
|
|
7
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
8
|
+
const resources_1 = require("./resources");
|
|
9
|
+
const mime_types_1 = __importDefault(require("mime-types"));
|
|
10
|
+
const endpointCache = new Map();
|
|
11
|
+
const warehouseCache = new Map();
|
|
12
|
+
const catalogCache = new Map();
|
|
13
|
+
const schemaCache = new Map();
|
|
14
|
+
const volumeCache = new Map();
|
|
15
|
+
const tableCache = new Map();
|
|
16
|
+
const functionCache = new Map();
|
|
17
|
+
const CACHE_TTL = 1 * 60 * 1000;
|
|
18
|
+
function getCacheKey(host, type) {
|
|
19
|
+
return `${host}:${type}`;
|
|
20
|
+
}
|
|
21
|
+
function isCacheValid(entry) {
|
|
22
|
+
if (!entry)
|
|
23
|
+
return false;
|
|
24
|
+
return Date.now() - entry.timestamp < CACHE_TTL;
|
|
25
|
+
}
|
|
26
|
+
function detectInputFormat(openApiSchema) {
|
|
27
|
+
var _a, _b, _c, _d, _e, _f;
|
|
28
|
+
const invocationUrl = (_b = (_a = openApiSchema.servers) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.url;
|
|
29
|
+
if (!invocationUrl) {
|
|
30
|
+
throw new Error('No server URL found in OpenAPI schema');
|
|
31
|
+
}
|
|
32
|
+
const pathKeys = Object.keys(openApiSchema.paths);
|
|
33
|
+
if (!pathKeys.length) {
|
|
34
|
+
throw new Error('No paths found in OpenAPI schema');
|
|
35
|
+
}
|
|
36
|
+
const invocationPath = pathKeys[0];
|
|
37
|
+
const postOperation = (_c = openApiSchema.paths[invocationPath]) === null || _c === void 0 ? void 0 : _c.post;
|
|
38
|
+
if (!((_f = (_e = (_d = postOperation === null || postOperation === void 0 ? void 0 : postOperation.requestBody) === null || _d === void 0 ? void 0 : _d.content) === null || _e === void 0 ? void 0 : _e['application/json']) === null || _f === void 0 ? void 0 : _f.schema)) {
|
|
39
|
+
throw new Error('No request schema found');
|
|
40
|
+
}
|
|
41
|
+
const schema = postOperation.requestBody.content['application/json'].schema;
|
|
42
|
+
if (schema.oneOf && schema.oneOf.length > 0) {
|
|
43
|
+
for (const option of schema.oneOf) {
|
|
44
|
+
const properties = option.properties || {};
|
|
45
|
+
if (properties.messages) {
|
|
46
|
+
return { format: 'chat', schema: properties.messages, requiredFields: ['messages'], invocationUrl };
|
|
47
|
+
}
|
|
48
|
+
if (properties.prompt) {
|
|
49
|
+
return { format: 'completions', schema: properties.prompt, requiredFields: ['prompt'], invocationUrl };
|
|
50
|
+
}
|
|
51
|
+
if (properties.input && !properties.dataframe_records && !properties.dataframe_split) {
|
|
52
|
+
return { format: 'embeddings', schema: properties.input, requiredFields: ['input'], invocationUrl };
|
|
53
|
+
}
|
|
54
|
+
if (properties.dataframe_split) {
|
|
55
|
+
return {
|
|
56
|
+
format: 'dataframe_split',
|
|
57
|
+
schema: properties.dataframe_split,
|
|
58
|
+
requiredFields: ['dataframe_split'],
|
|
59
|
+
invocationUrl,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (properties.dataframe_records) {
|
|
63
|
+
return { format: 'dataframe_records', schema: properties.dataframe_records, requiredFields: ['dataframe_records'], invocationUrl };
|
|
64
|
+
}
|
|
65
|
+
if (properties.inputs) {
|
|
66
|
+
return { format: 'inputs', schema: properties.inputs, requiredFields: ['inputs'], invocationUrl };
|
|
67
|
+
}
|
|
68
|
+
if (properties.instances) {
|
|
69
|
+
return { format: 'instances', schema: properties.instances, requiredFields: ['instances'], invocationUrl };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const properties = schema.properties || {};
|
|
74
|
+
if (properties.messages)
|
|
75
|
+
return { format: 'chat', schema: properties.messages, requiredFields: ['messages'], invocationUrl };
|
|
76
|
+
if (properties.prompt)
|
|
77
|
+
return { format: 'completions', schema: properties.prompt, requiredFields: ['prompt'], invocationUrl };
|
|
78
|
+
if (properties.input)
|
|
79
|
+
return { format: 'embeddings', schema: properties.input, requiredFields: ['input'], invocationUrl };
|
|
80
|
+
if (properties.dataframe_records)
|
|
81
|
+
return { format: 'dataframe_records', schema: properties.dataframe_records, requiredFields: ['dataframe_records'], invocationUrl };
|
|
82
|
+
if (properties.dataframe_split)
|
|
83
|
+
return { format: 'dataframe_split', schema: properties.dataframe_split, requiredFields: ['dataframe_split'], invocationUrl };
|
|
84
|
+
if (properties.inputs)
|
|
85
|
+
return { format: 'inputs', schema: properties.inputs, requiredFields: ['inputs'], invocationUrl };
|
|
86
|
+
if (properties.instances)
|
|
87
|
+
return { format: 'instances', schema: properties.instances, requiredFields: ['instances'], invocationUrl };
|
|
88
|
+
return { format: 'generic', schema: schema, requiredFields: [], invocationUrl };
|
|
89
|
+
}
|
|
90
|
+
function generateExampleFromSchema(schema, format) {
|
|
91
|
+
if (schema && schema.properties) {
|
|
92
|
+
try {
|
|
93
|
+
const exampleObj = {};
|
|
94
|
+
for (const [key, propValue] of Object.entries(schema.properties)) {
|
|
95
|
+
const prop = propValue;
|
|
96
|
+
const propType = prop.type;
|
|
97
|
+
if (key === 'messages' && propType === 'array') {
|
|
98
|
+
exampleObj.messages = [
|
|
99
|
+
{ role: 'user', content: 'Hello! How can you help me today?' }
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
else if (key === 'prompt' && propType === 'string') {
|
|
103
|
+
exampleObj.prompt = 'What is Databricks?';
|
|
104
|
+
}
|
|
105
|
+
else if (key === 'input' && propType === 'array') {
|
|
106
|
+
exampleObj.input = ['Text to embed'];
|
|
107
|
+
}
|
|
108
|
+
else if (key === 'max_tokens' && propType === 'integer') {
|
|
109
|
+
exampleObj.max_tokens = 256;
|
|
110
|
+
}
|
|
111
|
+
else if (key === 'temperature' && propType === 'number') {
|
|
112
|
+
exampleObj.temperature = 0.7;
|
|
113
|
+
}
|
|
114
|
+
else if (key === 'top_p' && propType === 'number') {
|
|
115
|
+
exampleObj.top_p = 0.9;
|
|
116
|
+
}
|
|
117
|
+
else if (key === 'top_k' && propType === 'integer') {
|
|
118
|
+
exampleObj.top_k = 40;
|
|
119
|
+
}
|
|
120
|
+
else if (key === 'stream' && propType === 'boolean') {
|
|
121
|
+
exampleObj.stream = false;
|
|
122
|
+
}
|
|
123
|
+
else if (key === 'n' && propType === 'integer') {
|
|
124
|
+
exampleObj.n = 1;
|
|
125
|
+
}
|
|
126
|
+
else if (key === 'stop' && prop.oneOf) {
|
|
127
|
+
exampleObj.stop = ['\\n'];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (Object.keys(exampleObj).length > 0) {
|
|
131
|
+
return JSON.stringify(exampleObj, null, 2);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (e) {
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const examples = {
|
|
138
|
+
chat: `{
|
|
139
|
+
"messages": [
|
|
140
|
+
{
|
|
141
|
+
"role": "user",
|
|
142
|
+
"content": "Hello! How are you?"
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
"max_tokens": 256,
|
|
146
|
+
"temperature": 0.7
|
|
147
|
+
}`,
|
|
148
|
+
completions: `{
|
|
149
|
+
"prompt": "What is machine learning?",
|
|
150
|
+
"max_tokens": 256,
|
|
151
|
+
"temperature": 0.7,
|
|
152
|
+
"top_p": 0.9
|
|
153
|
+
}`,
|
|
154
|
+
embeddings: `{
|
|
155
|
+
"input": [
|
|
156
|
+
"Example text to embed"
|
|
157
|
+
]
|
|
158
|
+
}`,
|
|
159
|
+
dataframe_split: `{
|
|
160
|
+
"dataframe_split": {
|
|
161
|
+
"columns": ["feature1", "feature2"],
|
|
162
|
+
"data": [[1.0, 2.0], [3.0, 4.0]]
|
|
163
|
+
}
|
|
164
|
+
}`,
|
|
165
|
+
dataframe_records: `{
|
|
166
|
+
"dataframe_records": [
|
|
167
|
+
{"feature1": 1.0, "feature2": 2.0}
|
|
168
|
+
]
|
|
169
|
+
}`,
|
|
170
|
+
inputs: `{
|
|
171
|
+
"inputs": {
|
|
172
|
+
"tensor1": [1, 2, 3]
|
|
173
|
+
}
|
|
174
|
+
}`,
|
|
175
|
+
instances: `{
|
|
176
|
+
"instances": [
|
|
177
|
+
{"tensor1": 1}
|
|
178
|
+
]
|
|
179
|
+
}`,
|
|
180
|
+
};
|
|
181
|
+
return examples[format] || '{}';
|
|
182
|
+
}
|
|
183
|
+
function validateRequestBody(requestBody, detectedFormat) {
|
|
184
|
+
switch (detectedFormat) {
|
|
185
|
+
case 'chat':
|
|
186
|
+
if (!requestBody.messages || !Array.isArray(requestBody.messages)) {
|
|
187
|
+
throw new Error('Invalid chat format: "messages" array is required');
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
case 'completions':
|
|
191
|
+
if (!requestBody.prompt) {
|
|
192
|
+
throw new Error('Invalid completions format: "prompt" is required');
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
case 'embeddings':
|
|
196
|
+
if (!requestBody.input) {
|
|
197
|
+
throw new Error('Invalid embeddings format: "input" is required');
|
|
198
|
+
}
|
|
199
|
+
break;
|
|
200
|
+
case 'dataframe_split':
|
|
201
|
+
if (!requestBody.dataframe_split || !requestBody.dataframe_split.data) {
|
|
202
|
+
throw new Error('Invalid dataframe_split format: "dataframe_split.data" is required');
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
case 'dataframe_records':
|
|
206
|
+
if (!requestBody.dataframe_records || !Array.isArray(requestBody.dataframe_records)) {
|
|
207
|
+
throw new Error('Invalid dataframe_records format: "dataframe_records" array is required');
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
case 'inputs':
|
|
211
|
+
if (!requestBody.inputs) {
|
|
212
|
+
throw new Error('Invalid inputs format: "inputs" is required');
|
|
213
|
+
}
|
|
214
|
+
break;
|
|
215
|
+
case 'instances':
|
|
216
|
+
if (!requestBody.instances || !Array.isArray(requestBody.instances)) {
|
|
217
|
+
throw new Error('Invalid instances format: "instances" array is required');
|
|
218
|
+
}
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
class Databricks {
|
|
223
|
+
constructor() {
|
|
224
|
+
this.description = {
|
|
225
|
+
displayName: 'Databricks',
|
|
226
|
+
name: 'databricks',
|
|
227
|
+
icon: 'file:databricks.svg',
|
|
228
|
+
group: ['transform'],
|
|
229
|
+
version: 1,
|
|
230
|
+
usableAsTool: true,
|
|
231
|
+
subtitle: '',
|
|
232
|
+
description: 'Interact with Databricks API',
|
|
233
|
+
documentationUrl: 'https://docs.databricks.com/aws/en',
|
|
234
|
+
defaults: {
|
|
235
|
+
name: 'Databricks',
|
|
236
|
+
},
|
|
237
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
238
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
239
|
+
credentials: [
|
|
240
|
+
{
|
|
241
|
+
name: 'databricks',
|
|
242
|
+
required: true,
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
requestDefaults: {
|
|
246
|
+
baseURL: '={{$credentials.host}}',
|
|
247
|
+
headers: {
|
|
248
|
+
Authorization: '=Bearer {{$credentials.token}}',
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
properties: [
|
|
252
|
+
{
|
|
253
|
+
displayName: 'Resource',
|
|
254
|
+
name: 'resource',
|
|
255
|
+
type: 'options',
|
|
256
|
+
noDataExpression: true,
|
|
257
|
+
options: [
|
|
258
|
+
{
|
|
259
|
+
name: 'Genie',
|
|
260
|
+
value: 'genie',
|
|
261
|
+
description: 'AI-powered data assistant. <a href="https://docs.databricks.com/genie/index.html" target="_blank">Learn more</a>',
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: 'Databricks SQL',
|
|
265
|
+
value: 'databricksSql',
|
|
266
|
+
description: 'Execute SQL queries on data warehouses. <a href="https://docs.databricks.com/sql/index.html" target="_blank">Learn more</a>',
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: 'Unity Catalog',
|
|
270
|
+
value: 'unityCatalog',
|
|
271
|
+
description: 'Unified governance for data and AI. <a href="https://docs.databricks.com/data-governance/unity-catalog/index.html" target="_blank">Learn more</a>',
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
name: 'Model Serving',
|
|
275
|
+
value: 'modelServing',
|
|
276
|
+
description: 'Deploy and query ML models. <a href="https://docs.databricks.com/machine-learning/model-serving/index.html" target="_blank">Learn more</a>',
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: 'Files',
|
|
280
|
+
value: 'files',
|
|
281
|
+
description: 'Manage files in Unity Catalog volumes. <a href="https://docs.databricks.com/api/workspace/files" target="_blank">Learn more</a>',
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
name: 'Vector Search',
|
|
285
|
+
value: 'vectorSearch',
|
|
286
|
+
description: 'Semantic search with vector embeddings. <a href="https://docs.databricks.com/generative-ai/vector-search.html" target="_blank">Learn more</a>',
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
default: 'databricksSql',
|
|
290
|
+
},
|
|
291
|
+
resources_1.filesOperations,
|
|
292
|
+
resources_1.genieOperations,
|
|
293
|
+
resources_1.unityCatalogOperations,
|
|
294
|
+
resources_1.databricksSqlOperations,
|
|
295
|
+
resources_1.modelServingOperations,
|
|
296
|
+
resources_1.vectorSearchOperations,
|
|
297
|
+
...resources_1.filesParameters,
|
|
298
|
+
...resources_1.genieParameters,
|
|
299
|
+
...resources_1.unityCatalogParameters,
|
|
300
|
+
...resources_1.databricksSqlParameters,
|
|
301
|
+
...resources_1.modelServingParameters,
|
|
302
|
+
...resources_1.vectorSearchParameters,
|
|
303
|
+
],
|
|
304
|
+
};
|
|
305
|
+
this.methods = {
|
|
306
|
+
listSearch: {
|
|
307
|
+
async getWarehouses(filter) {
|
|
308
|
+
var _a;
|
|
309
|
+
const credentials = await this.getCredentials('databricks');
|
|
310
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
311
|
+
const cacheKey = getCacheKey(host, 'warehouses');
|
|
312
|
+
let warehouses = [];
|
|
313
|
+
const cachedEntry = warehouseCache.get(cacheKey);
|
|
314
|
+
if (isCacheValid(cachedEntry)) {
|
|
315
|
+
warehouses = cachedEntry.data;
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
const response = await this.helpers.httpRequest({
|
|
319
|
+
method: 'GET',
|
|
320
|
+
url: `${host}/api/2.0/sql/warehouses`,
|
|
321
|
+
headers: {
|
|
322
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
323
|
+
'Accept': 'application/json',
|
|
324
|
+
},
|
|
325
|
+
json: true,
|
|
326
|
+
});
|
|
327
|
+
warehouses = (_a = response.warehouses) !== null && _a !== void 0 ? _a : [];
|
|
328
|
+
warehouseCache.set(cacheKey, {
|
|
329
|
+
data: warehouses,
|
|
330
|
+
timestamp: Date.now(),
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
const allResults = warehouses.map((warehouse) => ({
|
|
334
|
+
name: warehouse.name,
|
|
335
|
+
value: warehouse.id,
|
|
336
|
+
url: `${host}/sql/warehouses/${warehouse.id}`,
|
|
337
|
+
}));
|
|
338
|
+
if (filter) {
|
|
339
|
+
const filterLower = filter.toLowerCase();
|
|
340
|
+
const filteredResults = allResults.filter((result) => result.name.toLowerCase().includes(filterLower));
|
|
341
|
+
return { results: filteredResults };
|
|
342
|
+
}
|
|
343
|
+
return { results: allResults };
|
|
344
|
+
},
|
|
345
|
+
async getEndpoints(filter) {
|
|
346
|
+
var _a;
|
|
347
|
+
const credentials = await this.getCredentials('databricks');
|
|
348
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
349
|
+
const cacheKey = getCacheKey(host, 'endpoints');
|
|
350
|
+
let endpoints = [];
|
|
351
|
+
const cachedEntry = endpointCache.get(cacheKey);
|
|
352
|
+
if (isCacheValid(cachedEntry)) {
|
|
353
|
+
endpoints = cachedEntry.data;
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
const response = await this.helpers.httpRequest({
|
|
357
|
+
method: 'GET',
|
|
358
|
+
url: `${host}/api/2.0/serving-endpoints`,
|
|
359
|
+
headers: {
|
|
360
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
361
|
+
'Accept': 'application/json',
|
|
362
|
+
},
|
|
363
|
+
json: true,
|
|
364
|
+
});
|
|
365
|
+
endpoints = (_a = response.endpoints) !== null && _a !== void 0 ? _a : [];
|
|
366
|
+
endpointCache.set(cacheKey, {
|
|
367
|
+
data: endpoints,
|
|
368
|
+
timestamp: Date.now(),
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
const allResults = endpoints.map((endpoint) => {
|
|
372
|
+
var _a;
|
|
373
|
+
const modelNames = (((_a = endpoint.config) === null || _a === void 0 ? void 0 : _a.served_entities) || [])
|
|
374
|
+
.map((entity) => { var _a, _b; return ((_a = entity.external_model) === null || _a === void 0 ? void 0 : _a.name) || ((_b = entity.foundation_model) === null || _b === void 0 ? void 0 : _b.name); })
|
|
375
|
+
.filter(Boolean)
|
|
376
|
+
.join(', ');
|
|
377
|
+
return {
|
|
378
|
+
name: endpoint.name,
|
|
379
|
+
value: endpoint.name,
|
|
380
|
+
url: `${host}/ml/endpoints/${endpoint.name}`,
|
|
381
|
+
description: modelNames || 'Model serving endpoint',
|
|
382
|
+
};
|
|
383
|
+
});
|
|
384
|
+
if (filter) {
|
|
385
|
+
const filterLower = filter.toLowerCase();
|
|
386
|
+
const filteredResults = allResults.filter((result) => {
|
|
387
|
+
return (result.name.toLowerCase().includes(filterLower) ||
|
|
388
|
+
(result.description && result.description.toLowerCase().includes(filterLower)));
|
|
389
|
+
});
|
|
390
|
+
return { results: filteredResults };
|
|
391
|
+
}
|
|
392
|
+
return { results: allResults };
|
|
393
|
+
},
|
|
394
|
+
async getCatalogs(filter) {
|
|
395
|
+
var _a;
|
|
396
|
+
const credentials = await this.getCredentials('databricks');
|
|
397
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
398
|
+
const cacheKey = getCacheKey(host, 'catalogs');
|
|
399
|
+
let catalogs = [];
|
|
400
|
+
const cachedEntry = catalogCache.get(cacheKey);
|
|
401
|
+
if (isCacheValid(cachedEntry)) {
|
|
402
|
+
catalogs = cachedEntry.data;
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
const response = await this.helpers.httpRequest({
|
|
406
|
+
method: 'GET',
|
|
407
|
+
url: `${host}/api/2.1/unity-catalog/catalogs`,
|
|
408
|
+
headers: {
|
|
409
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
410
|
+
'Accept': 'application/json',
|
|
411
|
+
},
|
|
412
|
+
json: true,
|
|
413
|
+
});
|
|
414
|
+
catalogs = (_a = response.catalogs) !== null && _a !== void 0 ? _a : [];
|
|
415
|
+
catalogCache.set(cacheKey, {
|
|
416
|
+
data: catalogs,
|
|
417
|
+
timestamp: Date.now(),
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
const allResults = catalogs.map((catalog) => ({
|
|
421
|
+
name: catalog.name,
|
|
422
|
+
value: catalog.name,
|
|
423
|
+
url: `${host}/explore/data/${catalog.name}`,
|
|
424
|
+
}));
|
|
425
|
+
if (filter) {
|
|
426
|
+
const filterLower = filter.toLowerCase();
|
|
427
|
+
const filteredResults = allResults.filter((result) => result.name.toLowerCase().includes(filterLower));
|
|
428
|
+
return { results: filteredResults };
|
|
429
|
+
}
|
|
430
|
+
return { results: allResults };
|
|
431
|
+
},
|
|
432
|
+
async getSchemas(filter) {
|
|
433
|
+
var _a;
|
|
434
|
+
const credentials = await this.getCredentials('databricks');
|
|
435
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
436
|
+
let selectedCatalog;
|
|
437
|
+
try {
|
|
438
|
+
const catalogParam = this.getCurrentNodeParameter('catalogName');
|
|
439
|
+
selectedCatalog = typeof catalogParam === 'object' ? catalogParam.value : catalogParam;
|
|
440
|
+
if (selectedCatalog) {
|
|
441
|
+
selectedCatalog = selectedCatalog.trim();
|
|
442
|
+
if (selectedCatalog === '') {
|
|
443
|
+
selectedCatalog = undefined;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
catch (e) {
|
|
448
|
+
selectedCatalog = undefined;
|
|
449
|
+
}
|
|
450
|
+
let allSchemas = [];
|
|
451
|
+
if (selectedCatalog) {
|
|
452
|
+
const cacheKey = `${getCacheKey(host, 'schemas')}:${selectedCatalog}`;
|
|
453
|
+
const cachedEntry = schemaCache.get(cacheKey);
|
|
454
|
+
if (isCacheValid(cachedEntry)) {
|
|
455
|
+
allSchemas = cachedEntry.data;
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
try {
|
|
459
|
+
const schemasResponse = await this.helpers.httpRequest({
|
|
460
|
+
method: 'GET',
|
|
461
|
+
url: `${host}/api/2.1/unity-catalog/schemas?catalog_name=${selectedCatalog}`,
|
|
462
|
+
headers: {
|
|
463
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
464
|
+
'Accept': 'application/json',
|
|
465
|
+
},
|
|
466
|
+
json: true,
|
|
467
|
+
});
|
|
468
|
+
const schemas = (_a = schemasResponse.schemas) !== null && _a !== void 0 ? _a : [];
|
|
469
|
+
schemas.forEach((schema) => {
|
|
470
|
+
allSchemas.push({
|
|
471
|
+
name: schema.name,
|
|
472
|
+
value: schema.name,
|
|
473
|
+
url: `${host}/explore/data/${selectedCatalog}/${schema.name}`,
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
schemaCache.set(cacheKey, {
|
|
477
|
+
data: allSchemas,
|
|
478
|
+
timestamp: Date.now(),
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
catch (e) {
|
|
482
|
+
return {
|
|
483
|
+
results: [{
|
|
484
|
+
name: `Error loading schemas for catalog: ${selectedCatalog}`,
|
|
485
|
+
value: '',
|
|
486
|
+
}]
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
return {
|
|
493
|
+
results: [{
|
|
494
|
+
name: 'Please select a catalog first',
|
|
495
|
+
value: '',
|
|
496
|
+
}]
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
if (filter) {
|
|
500
|
+
const filterLower = filter.toLowerCase();
|
|
501
|
+
const filteredResults = allSchemas.filter((result) => result.name.toLowerCase().includes(filterLower));
|
|
502
|
+
return { results: filteredResults };
|
|
503
|
+
}
|
|
504
|
+
return { results: allSchemas };
|
|
505
|
+
},
|
|
506
|
+
async getVolumes(filter) {
|
|
507
|
+
var _a, _b, _c;
|
|
508
|
+
const credentials = await this.getCredentials('databricks');
|
|
509
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
510
|
+
const cacheKey = getCacheKey(host, 'volumes');
|
|
511
|
+
let allVolumes = [];
|
|
512
|
+
const cachedEntry = volumeCache.get(cacheKey);
|
|
513
|
+
if (isCacheValid(cachedEntry)) {
|
|
514
|
+
allVolumes = cachedEntry.data;
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
const catalogsResponse = await this.helpers.httpRequest({
|
|
518
|
+
method: 'GET',
|
|
519
|
+
url: `${host}/api/2.1/unity-catalog/catalogs`,
|
|
520
|
+
headers: {
|
|
521
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
522
|
+
'Accept': 'application/json',
|
|
523
|
+
},
|
|
524
|
+
json: true,
|
|
525
|
+
});
|
|
526
|
+
const catalogs = (_a = catalogsResponse.catalogs) !== null && _a !== void 0 ? _a : [];
|
|
527
|
+
for (const catalog of catalogs) {
|
|
528
|
+
try {
|
|
529
|
+
const schemasResponse = await this.helpers.httpRequest({
|
|
530
|
+
method: 'GET',
|
|
531
|
+
url: `${host}/api/2.1/unity-catalog/schemas?catalog_name=${catalog.name}`,
|
|
532
|
+
headers: {
|
|
533
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
534
|
+
'Accept': 'application/json',
|
|
535
|
+
},
|
|
536
|
+
json: true,
|
|
537
|
+
});
|
|
538
|
+
const schemas = (_b = schemasResponse.schemas) !== null && _b !== void 0 ? _b : [];
|
|
539
|
+
for (const schema of schemas) {
|
|
540
|
+
try {
|
|
541
|
+
const volumesResponse = await this.helpers.httpRequest({
|
|
542
|
+
method: 'GET',
|
|
543
|
+
url: `${host}/api/2.1/unity-catalog/volumes?catalog_name=${catalog.name}&schema_name=${schema.name}`,
|
|
544
|
+
headers: {
|
|
545
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
546
|
+
'Accept': 'application/json',
|
|
547
|
+
},
|
|
548
|
+
json: true,
|
|
549
|
+
});
|
|
550
|
+
const volumes = (_c = volumesResponse.volumes) !== null && _c !== void 0 ? _c : [];
|
|
551
|
+
volumes.forEach((volume) => {
|
|
552
|
+
const fullPath = `${catalog.name}.${schema.name}.${volume.name}`;
|
|
553
|
+
allVolumes.push({
|
|
554
|
+
name: fullPath,
|
|
555
|
+
value: fullPath,
|
|
556
|
+
description: `${catalog.name} / ${schema.name}${volume.volume_type ? ` (${volume.volume_type})` : ''}`,
|
|
557
|
+
url: `${host}/explore/data/${catalog.name}/${schema.name}/${volume.name}`,
|
|
558
|
+
});
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
catch (e) {
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
catch (e) {
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
volumeCache.set(cacheKey, {
|
|
569
|
+
data: allVolumes,
|
|
570
|
+
timestamp: Date.now(),
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
if (filter) {
|
|
574
|
+
const filterLower = filter.toLowerCase();
|
|
575
|
+
const filteredResults = allVolumes.filter((result) => result.name.toLowerCase().includes(filterLower) ||
|
|
576
|
+
result.description.toLowerCase().includes(filterLower));
|
|
577
|
+
return { results: filteredResults };
|
|
578
|
+
}
|
|
579
|
+
return { results: allVolumes };
|
|
580
|
+
},
|
|
581
|
+
async getTables(filter) {
|
|
582
|
+
var _a, _b, _c;
|
|
583
|
+
const credentials = await this.getCredentials('databricks');
|
|
584
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
585
|
+
const cacheKey = getCacheKey(host, 'tables');
|
|
586
|
+
let allTables = [];
|
|
587
|
+
const cachedEntry = tableCache.get(cacheKey);
|
|
588
|
+
if (isCacheValid(cachedEntry)) {
|
|
589
|
+
allTables = cachedEntry.data;
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
const catalogsResponse = await this.helpers.httpRequest({
|
|
593
|
+
method: 'GET',
|
|
594
|
+
url: `${host}/api/2.1/unity-catalog/catalogs`,
|
|
595
|
+
headers: {
|
|
596
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
597
|
+
'Accept': 'application/json',
|
|
598
|
+
},
|
|
599
|
+
json: true,
|
|
600
|
+
});
|
|
601
|
+
const catalogs = (_a = catalogsResponse.catalogs) !== null && _a !== void 0 ? _a : [];
|
|
602
|
+
for (const catalog of catalogs) {
|
|
603
|
+
try {
|
|
604
|
+
const schemasResponse = await this.helpers.httpRequest({
|
|
605
|
+
method: 'GET',
|
|
606
|
+
url: `${host}/api/2.1/unity-catalog/schemas?catalog_name=${catalog.name}`,
|
|
607
|
+
headers: {
|
|
608
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
609
|
+
'Accept': 'application/json',
|
|
610
|
+
},
|
|
611
|
+
json: true,
|
|
612
|
+
});
|
|
613
|
+
const schemas = (_b = schemasResponse.schemas) !== null && _b !== void 0 ? _b : [];
|
|
614
|
+
for (const schema of schemas) {
|
|
615
|
+
try {
|
|
616
|
+
const tablesResponse = await this.helpers.httpRequest({
|
|
617
|
+
method: 'GET',
|
|
618
|
+
url: `${host}/api/2.1/unity-catalog/tables?catalog_name=${catalog.name}&schema_name=${schema.name}`,
|
|
619
|
+
headers: {
|
|
620
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
621
|
+
'Accept': 'application/json',
|
|
622
|
+
},
|
|
623
|
+
json: true,
|
|
624
|
+
});
|
|
625
|
+
const tables = (_c = tablesResponse.tables) !== null && _c !== void 0 ? _c : [];
|
|
626
|
+
tables.forEach((table) => {
|
|
627
|
+
const fullPath = `${catalog.name}.${schema.name}.${table.name}`;
|
|
628
|
+
allTables.push({
|
|
629
|
+
name: fullPath,
|
|
630
|
+
value: fullPath,
|
|
631
|
+
description: `${catalog.name} / ${schema.name}${table.table_type ? ` (${table.table_type})` : ''}`,
|
|
632
|
+
url: `${host}/explore/data/${catalog.name}/${schema.name}/${table.name}`,
|
|
633
|
+
});
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
catch (e) {
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
catch (e) {
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
tableCache.set(cacheKey, {
|
|
644
|
+
data: allTables,
|
|
645
|
+
timestamp: Date.now(),
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
if (filter) {
|
|
649
|
+
const filterLower = filter.toLowerCase();
|
|
650
|
+
const filteredResults = allTables.filter((result) => result.name.toLowerCase().includes(filterLower) ||
|
|
651
|
+
result.description.toLowerCase().includes(filterLower));
|
|
652
|
+
return { results: filteredResults };
|
|
653
|
+
}
|
|
654
|
+
return { results: allTables };
|
|
655
|
+
},
|
|
656
|
+
async getFunctions(filter) {
|
|
657
|
+
var _a, _b, _c;
|
|
658
|
+
const credentials = await this.getCredentials('databricks');
|
|
659
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
660
|
+
const cacheKey = getCacheKey(host, 'functions');
|
|
661
|
+
let allFunctions = [];
|
|
662
|
+
const cachedEntry = functionCache.get(cacheKey);
|
|
663
|
+
if (isCacheValid(cachedEntry)) {
|
|
664
|
+
allFunctions = cachedEntry.data;
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
const catalogsResponse = await this.helpers.httpRequest({
|
|
668
|
+
method: 'GET',
|
|
669
|
+
url: `${host}/api/2.1/unity-catalog/catalogs`,
|
|
670
|
+
headers: {
|
|
671
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
672
|
+
'Accept': 'application/json',
|
|
673
|
+
},
|
|
674
|
+
json: true,
|
|
675
|
+
});
|
|
676
|
+
const catalogs = (_a = catalogsResponse.catalogs) !== null && _a !== void 0 ? _a : [];
|
|
677
|
+
for (const catalog of catalogs) {
|
|
678
|
+
try {
|
|
679
|
+
const schemasResponse = await this.helpers.httpRequest({
|
|
680
|
+
method: 'GET',
|
|
681
|
+
url: `${host}/api/2.1/unity-catalog/schemas?catalog_name=${catalog.name}`,
|
|
682
|
+
headers: {
|
|
683
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
684
|
+
'Accept': 'application/json',
|
|
685
|
+
},
|
|
686
|
+
json: true,
|
|
687
|
+
});
|
|
688
|
+
const schemas = (_b = schemasResponse.schemas) !== null && _b !== void 0 ? _b : [];
|
|
689
|
+
for (const schema of schemas) {
|
|
690
|
+
try {
|
|
691
|
+
const functionsResponse = await this.helpers.httpRequest({
|
|
692
|
+
method: 'GET',
|
|
693
|
+
url: `${host}/api/2.1/unity-catalog/functions?catalog_name=${catalog.name}&schema_name=${schema.name}`,
|
|
694
|
+
headers: {
|
|
695
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
696
|
+
'Accept': 'application/json',
|
|
697
|
+
},
|
|
698
|
+
json: true,
|
|
699
|
+
});
|
|
700
|
+
const functions = (_c = functionsResponse.functions) !== null && _c !== void 0 ? _c : [];
|
|
701
|
+
functions.forEach((func) => {
|
|
702
|
+
const fullPath = `${catalog.name}.${schema.name}.${func.name}`;
|
|
703
|
+
allFunctions.push({
|
|
704
|
+
name: fullPath,
|
|
705
|
+
value: fullPath,
|
|
706
|
+
description: `${catalog.name} / ${schema.name}${func.data_type ? ` → ${func.data_type}` : ''}`,
|
|
707
|
+
url: `${host}/explore/data/${catalog.name}/${schema.name}/${func.name}`,
|
|
708
|
+
});
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
catch (e) {
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
catch (e) {
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
functionCache.set(cacheKey, {
|
|
719
|
+
data: allFunctions,
|
|
720
|
+
timestamp: Date.now(),
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
if (filter) {
|
|
724
|
+
const filterLower = filter.toLowerCase();
|
|
725
|
+
const filteredResults = allFunctions.filter((result) => result.name.toLowerCase().includes(filterLower) ||
|
|
726
|
+
result.description.toLowerCase().includes(filterLower));
|
|
727
|
+
return { results: filteredResults };
|
|
728
|
+
}
|
|
729
|
+
return { results: allFunctions };
|
|
730
|
+
},
|
|
731
|
+
},
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
async execute() {
|
|
735
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
736
|
+
const items = this.getInputData();
|
|
737
|
+
const returnData = [];
|
|
738
|
+
this.logger.debug(`Starting execution with ${items.length} items`);
|
|
739
|
+
for (let i = 0; i < items.length; i++) {
|
|
740
|
+
try {
|
|
741
|
+
this.logger.debug(`Processing item ${i + 1}/${items.length}`);
|
|
742
|
+
const resource = this.getNodeParameter('resource', i);
|
|
743
|
+
const operation = this.getNodeParameter('operation', i);
|
|
744
|
+
this.logger.debug('Node parameters', {
|
|
745
|
+
resource,
|
|
746
|
+
operation,
|
|
747
|
+
itemIndex: i
|
|
748
|
+
});
|
|
749
|
+
if (resource === 'files' && operation === 'uploadFile') {
|
|
750
|
+
const dataFieldName = this.getNodeParameter('dataFieldName', i);
|
|
751
|
+
const volumePath = this.getNodeParameter('volumePath', i);
|
|
752
|
+
const filePath = this.getNodeParameter('filePath', i);
|
|
753
|
+
const parts = volumePath.split('.');
|
|
754
|
+
if (parts.length !== 3) {
|
|
755
|
+
throw new Error('Volume path must be in format: catalog.schema.volume (e.g., main.default.my_volume)');
|
|
756
|
+
}
|
|
757
|
+
const [catalog, schema, volume] = parts;
|
|
758
|
+
this.logger.debug('File upload parameters', {
|
|
759
|
+
dataFieldName,
|
|
760
|
+
volumePath,
|
|
761
|
+
catalog,
|
|
762
|
+
schema,
|
|
763
|
+
volume,
|
|
764
|
+
filePath
|
|
765
|
+
});
|
|
766
|
+
const credentials = (await this.getCredentials('databricks'));
|
|
767
|
+
const host = credentials.host;
|
|
768
|
+
const binaryData = await this.helpers.getBinaryDataBuffer(i, dataFieldName);
|
|
769
|
+
this.logger.debug('Starting file upload', {
|
|
770
|
+
host,
|
|
771
|
+
filePath,
|
|
772
|
+
dataSize: binaryData.length
|
|
773
|
+
});
|
|
774
|
+
await this.helpers.httpRequest({
|
|
775
|
+
method: 'PUT',
|
|
776
|
+
url: `${host}/api/2.0/fs/files/Volumes/${catalog}/${schema}/${volume}/${filePath}`,
|
|
777
|
+
body: binaryData,
|
|
778
|
+
headers: {
|
|
779
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
780
|
+
'Content-Type': ((_b = (_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[dataFieldName]) === null || _b === void 0 ? void 0 : _b.mimeType) || 'application/octet-stream',
|
|
781
|
+
},
|
|
782
|
+
encoding: 'arraybuffer',
|
|
783
|
+
});
|
|
784
|
+
this.logger.debug('File upload successful', { filePath });
|
|
785
|
+
returnData.push({
|
|
786
|
+
json: {
|
|
787
|
+
success: true,
|
|
788
|
+
message: `File uploaded successfully to ${filePath}`,
|
|
789
|
+
},
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
else if (resource === 'files' && operation === 'downloadFile') {
|
|
793
|
+
const credentials = (await this.getCredentials('databricks'));
|
|
794
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
795
|
+
const volumePath = this.getNodeParameter('volumePath', i);
|
|
796
|
+
const filePath = this.getNodeParameter('filePath', i);
|
|
797
|
+
const parts = volumePath.split('.');
|
|
798
|
+
if (parts.length !== 3) {
|
|
799
|
+
throw new Error('Volume path must be in format: catalog.schema.volume (e.g., main.default.my_volume)');
|
|
800
|
+
}
|
|
801
|
+
const [catalog, schema, volume] = parts;
|
|
802
|
+
this.logger.debug('Downloading file', {
|
|
803
|
+
volumePath,
|
|
804
|
+
catalog,
|
|
805
|
+
schema,
|
|
806
|
+
volume,
|
|
807
|
+
filePath,
|
|
808
|
+
});
|
|
809
|
+
const downloadUrl = `${host}/api/2.0/fs/files/Volumes/${catalog}/${schema}/${volume}/${filePath}`;
|
|
810
|
+
try {
|
|
811
|
+
const response = await this.helpers.httpRequest({
|
|
812
|
+
method: 'GET',
|
|
813
|
+
url: downloadUrl,
|
|
814
|
+
headers: {
|
|
815
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
816
|
+
},
|
|
817
|
+
encoding: 'arraybuffer',
|
|
818
|
+
returnFullResponse: true,
|
|
819
|
+
});
|
|
820
|
+
const fileName = filePath.split('/').pop() || 'downloaded-file';
|
|
821
|
+
let contentType = response.headers['content-type'];
|
|
822
|
+
if (!contentType || contentType === 'application/octet-stream') {
|
|
823
|
+
const detectedType = mime_types_1.default.lookup(fileName);
|
|
824
|
+
contentType = detectedType || 'application/octet-stream';
|
|
825
|
+
}
|
|
826
|
+
const buffer = Buffer.from(response.body);
|
|
827
|
+
this.logger.debug('File downloaded successfully', {
|
|
828
|
+
fileName,
|
|
829
|
+
size: buffer.length,
|
|
830
|
+
contentType,
|
|
831
|
+
});
|
|
832
|
+
returnData.push({
|
|
833
|
+
json: {
|
|
834
|
+
fileName,
|
|
835
|
+
size: buffer.length,
|
|
836
|
+
contentType,
|
|
837
|
+
catalog,
|
|
838
|
+
schema,
|
|
839
|
+
volume,
|
|
840
|
+
filePath,
|
|
841
|
+
},
|
|
842
|
+
binary: {
|
|
843
|
+
data: {
|
|
844
|
+
data: buffer.toString('base64'),
|
|
845
|
+
mimeType: contentType,
|
|
846
|
+
fileName,
|
|
847
|
+
},
|
|
848
|
+
},
|
|
849
|
+
pairedItem: { item: i },
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
catch (error) {
|
|
853
|
+
if (this.continueOnFail()) {
|
|
854
|
+
returnData.push({
|
|
855
|
+
json: {
|
|
856
|
+
error: error.message,
|
|
857
|
+
catalog,
|
|
858
|
+
schema,
|
|
859
|
+
volume,
|
|
860
|
+
filePath,
|
|
861
|
+
},
|
|
862
|
+
pairedItem: { item: i },
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
else {
|
|
866
|
+
throw error;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
else if (resource === 'files' && operation === 'deleteFile') {
|
|
871
|
+
const credentials = (await this.getCredentials('databricks'));
|
|
872
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
873
|
+
const volumePath = this.getNodeParameter('volumePath', i);
|
|
874
|
+
const filePath = this.getNodeParameter('filePath', i);
|
|
875
|
+
const parts = volumePath.split('.');
|
|
876
|
+
if (parts.length !== 3) {
|
|
877
|
+
throw new Error('Volume path must be in format: catalog.schema.volume (e.g., main.default.my_volume)');
|
|
878
|
+
}
|
|
879
|
+
const [catalog, schema, volume] = parts;
|
|
880
|
+
await this.helpers.httpRequest({
|
|
881
|
+
method: 'DELETE',
|
|
882
|
+
url: `${host}/api/2.0/fs/files/Volumes/${catalog}/${schema}/${volume}/${filePath}`,
|
|
883
|
+
headers: {
|
|
884
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
885
|
+
},
|
|
886
|
+
json: true,
|
|
887
|
+
});
|
|
888
|
+
returnData.push({
|
|
889
|
+
json: {
|
|
890
|
+
success: true,
|
|
891
|
+
message: `File deleted successfully: ${filePath}`,
|
|
892
|
+
volumePath,
|
|
893
|
+
filePath,
|
|
894
|
+
},
|
|
895
|
+
pairedItem: { item: i },
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
else if (resource === 'files' && operation === 'getFileInfo') {
|
|
899
|
+
const credentials = (await this.getCredentials('databricks'));
|
|
900
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
901
|
+
const volumePath = this.getNodeParameter('volumePath', i);
|
|
902
|
+
const filePath = this.getNodeParameter('filePath', i);
|
|
903
|
+
const parts = volumePath.split('.');
|
|
904
|
+
if (parts.length !== 3) {
|
|
905
|
+
throw new Error('Volume path must be in format: catalog.schema.volume (e.g., main.default.my_volume)');
|
|
906
|
+
}
|
|
907
|
+
const [catalog, schema, volume] = parts;
|
|
908
|
+
const response = await this.helpers.httpRequest({
|
|
909
|
+
method: 'HEAD',
|
|
910
|
+
url: `${host}/api/2.0/fs/files/Volumes/${catalog}/${schema}/${volume}/${filePath}`,
|
|
911
|
+
headers: {
|
|
912
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
913
|
+
},
|
|
914
|
+
returnFullResponse: true,
|
|
915
|
+
});
|
|
916
|
+
returnData.push({
|
|
917
|
+
json: {
|
|
918
|
+
volumePath,
|
|
919
|
+
filePath,
|
|
920
|
+
headers: response.headers,
|
|
921
|
+
contentLength: response.headers['content-length'],
|
|
922
|
+
contentType: response.headers['content-type'],
|
|
923
|
+
lastModified: response.headers['last-modified'],
|
|
924
|
+
},
|
|
925
|
+
pairedItem: { item: i },
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
else if (resource === 'files' && operation === 'listDirectory') {
|
|
929
|
+
const credentials = (await this.getCredentials('databricks'));
|
|
930
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
931
|
+
const volumePath = this.getNodeParameter('volumePath', i);
|
|
932
|
+
const directoryPath = this.getNodeParameter('directoryPath', i);
|
|
933
|
+
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
934
|
+
const parts = volumePath.split('.');
|
|
935
|
+
if (parts.length !== 3) {
|
|
936
|
+
throw new Error('Volume path must be in format: catalog.schema.volume (e.g., main.default.my_volume)');
|
|
937
|
+
}
|
|
938
|
+
const [catalog, schema, volume] = parts;
|
|
939
|
+
const queryParams = {};
|
|
940
|
+
if (additionalFields.pageSize) {
|
|
941
|
+
queryParams.page_size = additionalFields.pageSize;
|
|
942
|
+
}
|
|
943
|
+
if (additionalFields.pageToken) {
|
|
944
|
+
queryParams.page_token = additionalFields.pageToken;
|
|
945
|
+
}
|
|
946
|
+
const response = await this.helpers.httpRequest({
|
|
947
|
+
method: 'GET',
|
|
948
|
+
url: `${host}/api/2.0/fs/directories/Volumes/${catalog}/${schema}/${volume}/${directoryPath}`,
|
|
949
|
+
headers: {
|
|
950
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
951
|
+
},
|
|
952
|
+
qs: queryParams,
|
|
953
|
+
json: true,
|
|
954
|
+
});
|
|
955
|
+
returnData.push({
|
|
956
|
+
json: response,
|
|
957
|
+
pairedItem: { item: i },
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
else if (resource === 'files' && operation === 'createDirectory') {
|
|
961
|
+
const credentials = (await this.getCredentials('databricks'));
|
|
962
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
963
|
+
const volumePath = this.getNodeParameter('volumePath', i);
|
|
964
|
+
const directoryPath = this.getNodeParameter('directoryPath', i);
|
|
965
|
+
const parts = volumePath.split('.');
|
|
966
|
+
if (parts.length !== 3) {
|
|
967
|
+
throw new Error('Volume path must be in format: catalog.schema.volume (e.g., main.default.my_volume)');
|
|
968
|
+
}
|
|
969
|
+
const [catalog, schema, volume] = parts;
|
|
970
|
+
await this.helpers.httpRequest({
|
|
971
|
+
method: 'PUT',
|
|
972
|
+
url: `${host}/api/2.0/fs/directories/Volumes/${catalog}/${schema}/${volume}/${directoryPath}`,
|
|
973
|
+
headers: {
|
|
974
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
975
|
+
},
|
|
976
|
+
json: true,
|
|
977
|
+
});
|
|
978
|
+
returnData.push({
|
|
979
|
+
json: {
|
|
980
|
+
success: true,
|
|
981
|
+
message: `Directory created successfully: ${directoryPath}`,
|
|
982
|
+
volumePath,
|
|
983
|
+
directoryPath,
|
|
984
|
+
},
|
|
985
|
+
pairedItem: { item: i },
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
else if (resource === 'files' && operation === 'deleteDirectory') {
|
|
989
|
+
const credentials = (await this.getCredentials('databricks'));
|
|
990
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
991
|
+
const volumePath = this.getNodeParameter('volumePath', i);
|
|
992
|
+
const directoryPath = this.getNodeParameter('directoryPath', i);
|
|
993
|
+
const parts = volumePath.split('.');
|
|
994
|
+
if (parts.length !== 3) {
|
|
995
|
+
throw new Error('Volume path must be in format: catalog.schema.volume (e.g., main.default.my_volume)');
|
|
996
|
+
}
|
|
997
|
+
const [catalog, schema, volume] = parts;
|
|
998
|
+
await this.helpers.httpRequest({
|
|
999
|
+
method: 'DELETE',
|
|
1000
|
+
url: `${host}/api/2.0/fs/directories/Volumes/${catalog}/${schema}/${volume}/${directoryPath}`,
|
|
1001
|
+
headers: {
|
|
1002
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1003
|
+
},
|
|
1004
|
+
json: true,
|
|
1005
|
+
});
|
|
1006
|
+
returnData.push({
|
|
1007
|
+
json: {
|
|
1008
|
+
success: true,
|
|
1009
|
+
message: `Directory deleted successfully: ${directoryPath}`,
|
|
1010
|
+
volumePath,
|
|
1011
|
+
directoryPath,
|
|
1012
|
+
},
|
|
1013
|
+
pairedItem: { item: i },
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
else if (resource === 'genie') {
|
|
1017
|
+
const credentials = (await this.getCredentials('databricks'));
|
|
1018
|
+
const host = credentials.host;
|
|
1019
|
+
let url;
|
|
1020
|
+
let method;
|
|
1021
|
+
let body;
|
|
1022
|
+
switch (operation) {
|
|
1023
|
+
case 'createMessage':
|
|
1024
|
+
url = `${host}/api/2.0/genie/spaces/${this.getNodeParameter('spaceId', i)}/conversations/${this.getNodeParameter('conversationId', i)}/messages`;
|
|
1025
|
+
method = 'POST';
|
|
1026
|
+
body = {
|
|
1027
|
+
content: this.getNodeParameter('message', i),
|
|
1028
|
+
};
|
|
1029
|
+
break;
|
|
1030
|
+
case 'getMessage':
|
|
1031
|
+
url = `${host}/api/2.0/genie/spaces/${this.getNodeParameter('spaceId', i)}/conversations/${this.getNodeParameter('conversationId', i)}/messages/${this.getNodeParameter('messageId', i)}`;
|
|
1032
|
+
method = 'GET';
|
|
1033
|
+
break;
|
|
1034
|
+
case 'getQueryResults':
|
|
1035
|
+
url = `${host}/api/2.0/genie/spaces/${this.getNodeParameter('spaceId', i)}/conversations/${this.getNodeParameter('conversationId', i)}/messages/${this.getNodeParameter('messageId', i)}/attachments/${this.getNodeParameter('attachmentId', i)}/query-result`;
|
|
1036
|
+
method = 'GET';
|
|
1037
|
+
break;
|
|
1038
|
+
case 'executeMessageQuery':
|
|
1039
|
+
url = `${host}/api/2.0/genie/spaces/${this.getNodeParameter('spaceId', i)}/conversations/${this.getNodeParameter('conversationId', i)}/messages/${this.getNodeParameter('messageId', i)}/attachments/${this.getNodeParameter('attachmentId', i)}/execute-query`;
|
|
1040
|
+
method = 'POST';
|
|
1041
|
+
break;
|
|
1042
|
+
case 'getSpace':
|
|
1043
|
+
url = `${host}/api/2.0/genie/spaces/${this.getNodeParameter('spaceId', i)}`;
|
|
1044
|
+
method = 'GET';
|
|
1045
|
+
break;
|
|
1046
|
+
case 'startConversation':
|
|
1047
|
+
const spaceId = this.getNodeParameter('spaceId', i);
|
|
1048
|
+
url = `${host}/api/2.0/genie/spaces/${spaceId}/start-conversation`;
|
|
1049
|
+
method = 'POST';
|
|
1050
|
+
body = {
|
|
1051
|
+
content: this.getNodeParameter('initialMessage', i),
|
|
1052
|
+
};
|
|
1053
|
+
break;
|
|
1054
|
+
default:
|
|
1055
|
+
throw new Error(`Unsupported Genie operation: ${operation}`);
|
|
1056
|
+
}
|
|
1057
|
+
this.logger.debug('Making Genie API request', {
|
|
1058
|
+
url,
|
|
1059
|
+
method,
|
|
1060
|
+
body: JSON.stringify(body, null, 2)
|
|
1061
|
+
});
|
|
1062
|
+
const response = await this.helpers.httpRequest({
|
|
1063
|
+
method,
|
|
1064
|
+
url,
|
|
1065
|
+
body,
|
|
1066
|
+
headers: {
|
|
1067
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1068
|
+
'Content-Type': 'application/json',
|
|
1069
|
+
},
|
|
1070
|
+
json: true,
|
|
1071
|
+
});
|
|
1072
|
+
this.logger.debug('Genie API response received', {
|
|
1073
|
+
statusCode: response.statusCode,
|
|
1074
|
+
response: JSON.stringify(response, null, 2)
|
|
1075
|
+
});
|
|
1076
|
+
returnData.push({ json: response });
|
|
1077
|
+
}
|
|
1078
|
+
else if (resource === 'databricksSql' && operation === 'executeQuery') {
|
|
1079
|
+
const credentials = (await this.getCredentials('databricks'));
|
|
1080
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
1081
|
+
const warehouseId = this.getNodeParameter('warehouseId', i);
|
|
1082
|
+
const query = this.getNodeParameter('query', i);
|
|
1083
|
+
this.logger.debug('Executing SQL query', {
|
|
1084
|
+
warehouseId: warehouseId.value,
|
|
1085
|
+
query: query.substring(0, 100),
|
|
1086
|
+
});
|
|
1087
|
+
const executeResponse = await this.helpers.httpRequest({
|
|
1088
|
+
method: 'POST',
|
|
1089
|
+
url: `${host}/api/2.0/sql/statements`,
|
|
1090
|
+
body: {
|
|
1091
|
+
warehouse_id: warehouseId.value,
|
|
1092
|
+
statement: query,
|
|
1093
|
+
},
|
|
1094
|
+
headers: {
|
|
1095
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1096
|
+
'Content-Type': 'application/json',
|
|
1097
|
+
},
|
|
1098
|
+
json: true,
|
|
1099
|
+
});
|
|
1100
|
+
const statementId = executeResponse.statement_id;
|
|
1101
|
+
this.logger.debug('Query submitted', { statementId });
|
|
1102
|
+
let status = executeResponse.status.state;
|
|
1103
|
+
let queryResult = executeResponse;
|
|
1104
|
+
const maxRetries = 60;
|
|
1105
|
+
let retries = 0;
|
|
1106
|
+
while (status !== 'SUCCEEDED' && status !== 'FAILED' && status !== 'CANCELED' && retries < maxRetries) {
|
|
1107
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
1108
|
+
queryResult = await this.helpers.httpRequest({
|
|
1109
|
+
method: 'GET',
|
|
1110
|
+
url: `${host}/api/2.0/sql/statements/${statementId}`,
|
|
1111
|
+
headers: {
|
|
1112
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1113
|
+
'Accept': 'application/json',
|
|
1114
|
+
},
|
|
1115
|
+
json: true,
|
|
1116
|
+
});
|
|
1117
|
+
status = queryResult.status.state;
|
|
1118
|
+
retries++;
|
|
1119
|
+
this.logger.debug('Polling query status', {
|
|
1120
|
+
statementId,
|
|
1121
|
+
status,
|
|
1122
|
+
attempt: retries,
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
if (status === 'FAILED' || status === 'CANCELED') {
|
|
1126
|
+
throw new Error(`Query ${status.toLowerCase()}: ${JSON.stringify(queryResult.status)}`);
|
|
1127
|
+
}
|
|
1128
|
+
if (retries >= maxRetries) {
|
|
1129
|
+
throw new Error('Query execution timeout - exceeded maximum wait time');
|
|
1130
|
+
}
|
|
1131
|
+
const allRows = [];
|
|
1132
|
+
let chunkIndex = 0;
|
|
1133
|
+
const totalChunks = ((_c = queryResult.manifest) === null || _c === void 0 ? void 0 : _c.total_chunk_count) || 0;
|
|
1134
|
+
this.logger.debug('Starting chunk collection', {
|
|
1135
|
+
statementId,
|
|
1136
|
+
totalChunks,
|
|
1137
|
+
});
|
|
1138
|
+
if ((_d = queryResult.result) === null || _d === void 0 ? void 0 : _d.data_array) {
|
|
1139
|
+
allRows.push(...queryResult.result.data_array);
|
|
1140
|
+
chunkIndex = 1;
|
|
1141
|
+
}
|
|
1142
|
+
while (chunkIndex < totalChunks) {
|
|
1143
|
+
const chunkResponse = await this.helpers.httpRequest({
|
|
1144
|
+
method: 'GET',
|
|
1145
|
+
url: `${host}/api/2.0/sql/statements/${statementId}/result/chunks/${chunkIndex}`,
|
|
1146
|
+
headers: {
|
|
1147
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1148
|
+
'Accept': 'application/json',
|
|
1149
|
+
},
|
|
1150
|
+
json: true,
|
|
1151
|
+
});
|
|
1152
|
+
if (chunkResponse.data_array) {
|
|
1153
|
+
allRows.push(...chunkResponse.data_array);
|
|
1154
|
+
}
|
|
1155
|
+
chunkIndex++;
|
|
1156
|
+
this.logger.debug('Fetched chunk', {
|
|
1157
|
+
statementId,
|
|
1158
|
+
chunkIndex,
|
|
1159
|
+
totalChunks,
|
|
1160
|
+
rowsCollected: allRows.length,
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
const columns = ((_f = (_e = queryResult.manifest) === null || _e === void 0 ? void 0 : _e.schema) === null || _f === void 0 ? void 0 : _f.columns) || [];
|
|
1164
|
+
const formattedResults = allRows.map(row => {
|
|
1165
|
+
const obj = {};
|
|
1166
|
+
columns.forEach((col, idx) => {
|
|
1167
|
+
obj[col.name] = row[idx];
|
|
1168
|
+
});
|
|
1169
|
+
return obj;
|
|
1170
|
+
});
|
|
1171
|
+
this.logger.debug('Query execution complete', {
|
|
1172
|
+
statementId,
|
|
1173
|
+
totalRows: formattedResults.length,
|
|
1174
|
+
totalChunks,
|
|
1175
|
+
});
|
|
1176
|
+
formattedResults.forEach(row => {
|
|
1177
|
+
returnData.push({
|
|
1178
|
+
json: row,
|
|
1179
|
+
pairedItem: { item: i },
|
|
1180
|
+
});
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
else if (resource === 'modelServing' && operation === 'queryEndpoint') {
|
|
1184
|
+
const credentials = (await this.getCredentials('databricks'));
|
|
1185
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
1186
|
+
const endpointName = this.getNodeParameter('endpointName', i, '', { extractValue: true });
|
|
1187
|
+
const requestBody = this.getNodeParameter('requestBody', i);
|
|
1188
|
+
this.logger.debug('Fetching endpoint schema for auto-detection', { endpointName });
|
|
1189
|
+
let detectedFormat = 'generic';
|
|
1190
|
+
let invocationUrl = `${host}/serving-endpoints/${endpointName}/invocations`;
|
|
1191
|
+
let exampleRequestBody = '';
|
|
1192
|
+
try {
|
|
1193
|
+
const openApiResponse = await this.helpers.httpRequest({
|
|
1194
|
+
method: 'GET',
|
|
1195
|
+
url: `${host}/api/2.0/serving-endpoints/${endpointName}/openapi`,
|
|
1196
|
+
headers: {
|
|
1197
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1198
|
+
'Accept': 'application/json',
|
|
1199
|
+
},
|
|
1200
|
+
json: true,
|
|
1201
|
+
});
|
|
1202
|
+
if (openApiResponse && openApiResponse.length > 0) {
|
|
1203
|
+
const schemaInfo = detectInputFormat(openApiResponse[0]);
|
|
1204
|
+
detectedFormat = schemaInfo.format;
|
|
1205
|
+
invocationUrl = schemaInfo.invocationUrl;
|
|
1206
|
+
exampleRequestBody = generateExampleFromSchema(schemaInfo.schema, detectedFormat);
|
|
1207
|
+
this.logger.debug('Auto-detected input format and URL', {
|
|
1208
|
+
endpointName,
|
|
1209
|
+
format: detectedFormat,
|
|
1210
|
+
requiredFields: schemaInfo.requiredFields,
|
|
1211
|
+
invocationUrl,
|
|
1212
|
+
exampleRequestBody,
|
|
1213
|
+
});
|
|
1214
|
+
try {
|
|
1215
|
+
validateRequestBody(requestBody, detectedFormat);
|
|
1216
|
+
}
|
|
1217
|
+
catch (validationError) {
|
|
1218
|
+
throw new Error(`${validationError.message}\n\n` +
|
|
1219
|
+
`Detected format: ${detectedFormat}\n\n` +
|
|
1220
|
+
`Example request body:\n${exampleRequestBody}\n\n` +
|
|
1221
|
+
`Your request body:\n${JSON.stringify(requestBody, null, 2)}`);
|
|
1222
|
+
}
|
|
1223
|
+
this.logger.debug('Request body validated successfully', {
|
|
1224
|
+
endpointName,
|
|
1225
|
+
format: detectedFormat,
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
catch (error) {
|
|
1230
|
+
if (error.message && error.message.includes('Detected format:')) {
|
|
1231
|
+
throw error;
|
|
1232
|
+
}
|
|
1233
|
+
this.logger.warn('Could not fetch or parse endpoint schema, using default URL', {
|
|
1234
|
+
endpointName,
|
|
1235
|
+
error: error.message,
|
|
1236
|
+
defaultUrl: invocationUrl,
|
|
1237
|
+
});
|
|
1238
|
+
if (!exampleRequestBody) {
|
|
1239
|
+
exampleRequestBody = generateExampleFromSchema(null, detectedFormat);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
this.logger.debug('Querying model serving endpoint', {
|
|
1243
|
+
endpointName,
|
|
1244
|
+
detectedFormat,
|
|
1245
|
+
invocationUrl,
|
|
1246
|
+
requestBody: JSON.stringify(requestBody, null, 2),
|
|
1247
|
+
});
|
|
1248
|
+
try {
|
|
1249
|
+
const response = await this.helpers.httpRequest({
|
|
1250
|
+
method: 'POST',
|
|
1251
|
+
url: invocationUrl,
|
|
1252
|
+
body: requestBody,
|
|
1253
|
+
headers: {
|
|
1254
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1255
|
+
'Content-Type': 'application/json',
|
|
1256
|
+
},
|
|
1257
|
+
json: true,
|
|
1258
|
+
});
|
|
1259
|
+
this.logger.debug('Model serving response received', {
|
|
1260
|
+
endpointName,
|
|
1261
|
+
detectedFormat,
|
|
1262
|
+
invocationUrl,
|
|
1263
|
+
});
|
|
1264
|
+
returnData.push({
|
|
1265
|
+
json: {
|
|
1266
|
+
...response,
|
|
1267
|
+
_metadata: {
|
|
1268
|
+
endpoint: endpointName,
|
|
1269
|
+
detectedFormat,
|
|
1270
|
+
invocationUrl,
|
|
1271
|
+
}
|
|
1272
|
+
},
|
|
1273
|
+
pairedItem: { item: i }
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
catch (apiError) {
|
|
1277
|
+
if (apiError.statusCode === 400) {
|
|
1278
|
+
if (!exampleRequestBody) {
|
|
1279
|
+
exampleRequestBody = generateExampleFromSchema(null, detectedFormat);
|
|
1280
|
+
}
|
|
1281
|
+
const errorDetails = ((_g = apiError.response) === null || _g === void 0 ? void 0 : _g.body) || apiError.message || 'Bad Request';
|
|
1282
|
+
throw new Error(`API Error: 400 Bad Request\n\n` +
|
|
1283
|
+
`The endpoint rejected your request. This usually means the request body format is incorrect.\n\n` +
|
|
1284
|
+
`Error details: ${JSON.stringify(errorDetails, null, 2)}\n\n` +
|
|
1285
|
+
`Detected format: ${detectedFormat}\n\n` +
|
|
1286
|
+
`Expected request body format:\n${exampleRequestBody}\n\n` +
|
|
1287
|
+
`Your request body:\n${JSON.stringify(requestBody, null, 2)}`);
|
|
1288
|
+
}
|
|
1289
|
+
throw apiError;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
else if (resource === 'unityCatalog') {
|
|
1293
|
+
const credentials = (await this.getCredentials('databricks'));
|
|
1294
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
1295
|
+
const extractValue = (param) => {
|
|
1296
|
+
if (typeof param === 'object' && param !== null) {
|
|
1297
|
+
return param.value || '';
|
|
1298
|
+
}
|
|
1299
|
+
return param || '';
|
|
1300
|
+
};
|
|
1301
|
+
let response;
|
|
1302
|
+
if (operation === 'createVolume') {
|
|
1303
|
+
const catalogName = extractValue(this.getNodeParameter('catalogName', i));
|
|
1304
|
+
const schemaName = extractValue(this.getNodeParameter('schemaName', i));
|
|
1305
|
+
const volumeName = this.getNodeParameter('volumeName', i);
|
|
1306
|
+
const volumeType = this.getNodeParameter('volumeType', i);
|
|
1307
|
+
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
1308
|
+
const body = {
|
|
1309
|
+
catalog_name: catalogName,
|
|
1310
|
+
schema_name: schemaName,
|
|
1311
|
+
name: volumeName,
|
|
1312
|
+
volume_type: volumeType,
|
|
1313
|
+
};
|
|
1314
|
+
if (additionalFields.comment) {
|
|
1315
|
+
body.comment = additionalFields.comment;
|
|
1316
|
+
}
|
|
1317
|
+
if (additionalFields.storage_location) {
|
|
1318
|
+
body.storage_location = additionalFields.storage_location;
|
|
1319
|
+
}
|
|
1320
|
+
response = await this.helpers.httpRequest({
|
|
1321
|
+
method: 'POST',
|
|
1322
|
+
url: `${host}/api/2.1/unity-catalog/volumes`,
|
|
1323
|
+
body,
|
|
1324
|
+
headers: {
|
|
1325
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1326
|
+
'Content-Type': 'application/json',
|
|
1327
|
+
},
|
|
1328
|
+
json: true,
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
else if (operation === 'deleteVolume') {
|
|
1332
|
+
const catalogName = extractValue(this.getNodeParameter('catalogName', i));
|
|
1333
|
+
const schemaName = extractValue(this.getNodeParameter('schemaName', i));
|
|
1334
|
+
const volumeName = this.getNodeParameter('volumeName', i);
|
|
1335
|
+
const fullName = `${catalogName}.${schemaName}.${volumeName}`;
|
|
1336
|
+
await this.helpers.httpRequest({
|
|
1337
|
+
method: 'DELETE',
|
|
1338
|
+
url: `${host}/api/2.1/unity-catalog/volumes/${fullName}`,
|
|
1339
|
+
headers: {
|
|
1340
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1341
|
+
},
|
|
1342
|
+
json: true,
|
|
1343
|
+
});
|
|
1344
|
+
response = {
|
|
1345
|
+
success: true,
|
|
1346
|
+
message: 'Volume deleted successfully',
|
|
1347
|
+
volumeName: fullName,
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
else if (operation === 'getVolume') {
|
|
1351
|
+
const catalogName = extractValue(this.getNodeParameter('catalogName', i));
|
|
1352
|
+
const schemaName = extractValue(this.getNodeParameter('schemaName', i));
|
|
1353
|
+
const volumeName = this.getNodeParameter('volumeName', i);
|
|
1354
|
+
const fullName = `${catalogName}.${schemaName}.${volumeName}`;
|
|
1355
|
+
response = await this.helpers.httpRequest({
|
|
1356
|
+
method: 'GET',
|
|
1357
|
+
url: `${host}/api/2.1/unity-catalog/volumes/${fullName}`,
|
|
1358
|
+
headers: {
|
|
1359
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1360
|
+
},
|
|
1361
|
+
json: true,
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
else if (operation === 'listVolumes') {
|
|
1365
|
+
const catalogName = extractValue(this.getNodeParameter('catalogName', i, ''));
|
|
1366
|
+
const schemaName = extractValue(this.getNodeParameter('schemaName', i, ''));
|
|
1367
|
+
const qs = {};
|
|
1368
|
+
if (catalogName)
|
|
1369
|
+
qs.catalog_name = catalogName;
|
|
1370
|
+
if (schemaName)
|
|
1371
|
+
qs.schema_name = schemaName;
|
|
1372
|
+
response = await this.helpers.httpRequest({
|
|
1373
|
+
method: 'GET',
|
|
1374
|
+
url: `${host}/api/2.1/unity-catalog/volumes`,
|
|
1375
|
+
qs,
|
|
1376
|
+
headers: {
|
|
1377
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1378
|
+
},
|
|
1379
|
+
json: true,
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
else if (operation === 'getTable') {
|
|
1383
|
+
const fullName = extractValue(this.getNodeParameter('fullName', i));
|
|
1384
|
+
response = await this.helpers.httpRequest({
|
|
1385
|
+
method: 'GET',
|
|
1386
|
+
url: `${host}/api/2.1/unity-catalog/tables/${fullName}`,
|
|
1387
|
+
headers: {
|
|
1388
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1389
|
+
},
|
|
1390
|
+
json: true,
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
else if (operation === 'listTables') {
|
|
1394
|
+
const catalogName = extractValue(this.getNodeParameter('catalogName', i, ''));
|
|
1395
|
+
const schemaName = extractValue(this.getNodeParameter('schemaName', i, ''));
|
|
1396
|
+
const qs = {};
|
|
1397
|
+
if (catalogName)
|
|
1398
|
+
qs.catalog_name = catalogName;
|
|
1399
|
+
if (schemaName)
|
|
1400
|
+
qs.schema_name = schemaName;
|
|
1401
|
+
response = await this.helpers.httpRequest({
|
|
1402
|
+
method: 'GET',
|
|
1403
|
+
url: `${host}/api/2.1/unity-catalog/tables`,
|
|
1404
|
+
qs,
|
|
1405
|
+
headers: {
|
|
1406
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1407
|
+
},
|
|
1408
|
+
json: true,
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
else if (operation === 'createFunction') {
|
|
1412
|
+
const catalogName = extractValue(this.getNodeParameter('catalogName', i));
|
|
1413
|
+
const schemaName = extractValue(this.getNodeParameter('schemaName', i));
|
|
1414
|
+
const functionName = this.getNodeParameter('functionName', i);
|
|
1415
|
+
const inputParams = this.getNodeParameter('inputParams', i);
|
|
1416
|
+
const returnType = this.getNodeParameter('returnType', i);
|
|
1417
|
+
const routineBody = this.getNodeParameter('routineBody', i);
|
|
1418
|
+
response = await this.helpers.httpRequest({
|
|
1419
|
+
method: 'POST',
|
|
1420
|
+
url: `${host}/api/2.1/unity-catalog/functions`,
|
|
1421
|
+
body: {
|
|
1422
|
+
name: functionName,
|
|
1423
|
+
catalog_name: catalogName,
|
|
1424
|
+
schema_name: schemaName,
|
|
1425
|
+
input_params: inputParams,
|
|
1426
|
+
data_type: returnType,
|
|
1427
|
+
routine_body: routineBody,
|
|
1428
|
+
},
|
|
1429
|
+
headers: {
|
|
1430
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1431
|
+
'Content-Type': 'application/json',
|
|
1432
|
+
},
|
|
1433
|
+
json: true,
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
else if (operation === 'deleteFunction') {
|
|
1437
|
+
const fullName = extractValue(this.getNodeParameter('fullName', i));
|
|
1438
|
+
await this.helpers.httpRequest({
|
|
1439
|
+
method: 'DELETE',
|
|
1440
|
+
url: `${host}/api/2.1/unity-catalog/functions/${fullName}`,
|
|
1441
|
+
headers: {
|
|
1442
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1443
|
+
},
|
|
1444
|
+
json: true,
|
|
1445
|
+
});
|
|
1446
|
+
response = {
|
|
1447
|
+
success: true,
|
|
1448
|
+
message: 'Function deleted successfully',
|
|
1449
|
+
functionName: fullName,
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
else if (operation === 'getFunction') {
|
|
1453
|
+
const fullName = extractValue(this.getNodeParameter('fullName', i));
|
|
1454
|
+
response = await this.helpers.httpRequest({
|
|
1455
|
+
method: 'GET',
|
|
1456
|
+
url: `${host}/api/2.1/unity-catalog/functions/${fullName}`,
|
|
1457
|
+
headers: {
|
|
1458
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1459
|
+
},
|
|
1460
|
+
json: true,
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
else if (operation === 'listFunctions') {
|
|
1464
|
+
const catalogName = extractValue(this.getNodeParameter('catalogName', i, ''));
|
|
1465
|
+
const schemaName = extractValue(this.getNodeParameter('schemaName', i, ''));
|
|
1466
|
+
const qs = {};
|
|
1467
|
+
if (catalogName)
|
|
1468
|
+
qs.catalog_name = catalogName;
|
|
1469
|
+
if (schemaName)
|
|
1470
|
+
qs.schema_name = schemaName;
|
|
1471
|
+
response = await this.helpers.httpRequest({
|
|
1472
|
+
method: 'GET',
|
|
1473
|
+
url: `${host}/api/2.1/unity-catalog/functions`,
|
|
1474
|
+
qs,
|
|
1475
|
+
headers: {
|
|
1476
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1477
|
+
},
|
|
1478
|
+
json: true,
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
else if (operation === 'createCatalog') {
|
|
1482
|
+
const catalogName = extractValue(this.getNodeParameter('catalogName', i));
|
|
1483
|
+
const comment = this.getNodeParameter('comment', i, '');
|
|
1484
|
+
const body = {
|
|
1485
|
+
name: catalogName,
|
|
1486
|
+
};
|
|
1487
|
+
if (comment) {
|
|
1488
|
+
body.comment = comment;
|
|
1489
|
+
}
|
|
1490
|
+
response = await this.helpers.httpRequest({
|
|
1491
|
+
method: 'POST',
|
|
1492
|
+
url: `${host}/api/2.1/unity-catalog/catalogs`,
|
|
1493
|
+
body,
|
|
1494
|
+
headers: {
|
|
1495
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1496
|
+
'Content-Type': 'application/json',
|
|
1497
|
+
},
|
|
1498
|
+
json: true,
|
|
1499
|
+
});
|
|
1500
|
+
}
|
|
1501
|
+
else if (operation === 'getCatalog') {
|
|
1502
|
+
const catalogName = extractValue(this.getNodeParameter('catalogName', i));
|
|
1503
|
+
response = await this.helpers.httpRequest({
|
|
1504
|
+
method: 'GET',
|
|
1505
|
+
url: `${host}/api/2.1/unity-catalog/catalogs/${catalogName}`,
|
|
1506
|
+
headers: {
|
|
1507
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1508
|
+
},
|
|
1509
|
+
json: true,
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
else if (operation === 'updateCatalog') {
|
|
1513
|
+
const catalogName = extractValue(this.getNodeParameter('catalogName', i));
|
|
1514
|
+
const comment = this.getNodeParameter('comment', i, '');
|
|
1515
|
+
response = await this.helpers.httpRequest({
|
|
1516
|
+
method: 'PATCH',
|
|
1517
|
+
url: `${host}/api/2.1/unity-catalog/catalogs/${catalogName}`,
|
|
1518
|
+
body: {
|
|
1519
|
+
comment,
|
|
1520
|
+
},
|
|
1521
|
+
headers: {
|
|
1522
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1523
|
+
'Content-Type': 'application/json',
|
|
1524
|
+
},
|
|
1525
|
+
json: true,
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
else if (operation === 'deleteCatalog') {
|
|
1529
|
+
const catalogName = extractValue(this.getNodeParameter('catalogName', i));
|
|
1530
|
+
await this.helpers.httpRequest({
|
|
1531
|
+
method: 'DELETE',
|
|
1532
|
+
url: `${host}/api/2.1/unity-catalog/catalogs/${catalogName}`,
|
|
1533
|
+
headers: {
|
|
1534
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1535
|
+
},
|
|
1536
|
+
json: true,
|
|
1537
|
+
});
|
|
1538
|
+
response = {
|
|
1539
|
+
success: true,
|
|
1540
|
+
message: 'Catalog deleted successfully',
|
|
1541
|
+
catalogName: catalogName,
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
else if (operation === 'listCatalogs') {
|
|
1545
|
+
response = await this.helpers.httpRequest({
|
|
1546
|
+
method: 'GET',
|
|
1547
|
+
url: `${host}/api/2.1/unity-catalog/catalogs`,
|
|
1548
|
+
headers: {
|
|
1549
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1550
|
+
},
|
|
1551
|
+
json: true,
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
returnData.push({
|
|
1555
|
+
json: response || {},
|
|
1556
|
+
pairedItem: { item: i },
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
else if (resource === 'vectorSearch' && operation === 'queryIndex') {
|
|
1560
|
+
const credentials = (await this.getCredentials('databricks'));
|
|
1561
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
1562
|
+
const indexName = this.getNodeParameter('indexName', i);
|
|
1563
|
+
const queryType = this.getNodeParameter('queryType', i);
|
|
1564
|
+
const searchMode = this.getNodeParameter('searchMode', i, 'HYBRID');
|
|
1565
|
+
const numResults = this.getNodeParameter('numResults', i, 10);
|
|
1566
|
+
const columnsStr = this.getNodeParameter('columns', i, '');
|
|
1567
|
+
const options = this.getNodeParameter('options', i, {});
|
|
1568
|
+
const enableReranking = this.getNodeParameter('enableReranking', i, false);
|
|
1569
|
+
const rerankerModel = enableReranking ? this.getNodeParameter('rerankerModel', i) : undefined;
|
|
1570
|
+
const columnsToRerank = enableReranking ? this.getNodeParameter('columnsToRerank', i) : undefined;
|
|
1571
|
+
const body = {
|
|
1572
|
+
num_results: numResults,
|
|
1573
|
+
query_type: searchMode,
|
|
1574
|
+
};
|
|
1575
|
+
if (queryType === 'text') {
|
|
1576
|
+
body.query_text = this.getNodeParameter('queryText', i);
|
|
1577
|
+
}
|
|
1578
|
+
else {
|
|
1579
|
+
body.query_vector = this.getNodeParameter('queryVector', i);
|
|
1580
|
+
}
|
|
1581
|
+
body.columns = columnsStr.split(',').map(col => col.trim()).filter(Boolean);
|
|
1582
|
+
if (options.filterExpression) {
|
|
1583
|
+
body.filters_json = options.filterExpression;
|
|
1584
|
+
}
|
|
1585
|
+
if (options.scoreThreshold) {
|
|
1586
|
+
body.score_threshold = options.scoreThreshold;
|
|
1587
|
+
}
|
|
1588
|
+
if (enableReranking) {
|
|
1589
|
+
body.reranker = {
|
|
1590
|
+
model: rerankerModel || 'databricks_reranker',
|
|
1591
|
+
parameters: {
|
|
1592
|
+
columns_to_rerank: columnsToRerank.split(',').map((col) => col.trim()).filter(Boolean),
|
|
1593
|
+
},
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
this.logger.debug('Querying vector search index', {
|
|
1597
|
+
indexName,
|
|
1598
|
+
queryType,
|
|
1599
|
+
searchMode,
|
|
1600
|
+
body: JSON.stringify(body, null, 2),
|
|
1601
|
+
});
|
|
1602
|
+
const response = await this.helpers.httpRequest({
|
|
1603
|
+
method: 'POST',
|
|
1604
|
+
url: `${host}/api/2.0/vector-search/indexes/${indexName}/query`,
|
|
1605
|
+
body,
|
|
1606
|
+
headers: {
|
|
1607
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1608
|
+
'Content-Type': 'application/json',
|
|
1609
|
+
},
|
|
1610
|
+
json: true,
|
|
1611
|
+
});
|
|
1612
|
+
returnData.push({
|
|
1613
|
+
json: response,
|
|
1614
|
+
pairedItem: { item: i },
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1617
|
+
else if (resource === 'vectorSearch' && operation === 'getIndex') {
|
|
1618
|
+
const credentials = (await this.getCredentials('databricks'));
|
|
1619
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
1620
|
+
const indexName = this.getNodeParameter('indexName', i);
|
|
1621
|
+
const response = await this.helpers.httpRequest({
|
|
1622
|
+
method: 'GET',
|
|
1623
|
+
url: `${host}/api/2.0/vector-search/indexes/${indexName}`,
|
|
1624
|
+
headers: {
|
|
1625
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1626
|
+
},
|
|
1627
|
+
json: true,
|
|
1628
|
+
});
|
|
1629
|
+
returnData.push({
|
|
1630
|
+
json: response,
|
|
1631
|
+
pairedItem: { item: i },
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
else if (resource === 'vectorSearch' && operation === 'listIndexes') {
|
|
1635
|
+
const credentials = (await this.getCredentials('databricks'));
|
|
1636
|
+
const host = credentials.host.replace(/\/$/, '');
|
|
1637
|
+
const endpointName = this.getNodeParameter('endpointName', i);
|
|
1638
|
+
const response = await this.helpers.httpRequest({
|
|
1639
|
+
method: 'GET',
|
|
1640
|
+
url: `${host}/api/2.0/vector-search/indexes`,
|
|
1641
|
+
qs: {
|
|
1642
|
+
endpoint_name: endpointName,
|
|
1643
|
+
},
|
|
1644
|
+
headers: {
|
|
1645
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
1646
|
+
},
|
|
1647
|
+
json: true,
|
|
1648
|
+
});
|
|
1649
|
+
returnData.push({
|
|
1650
|
+
json: response,
|
|
1651
|
+
pairedItem: { item: i },
|
|
1652
|
+
});
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
catch (error) {
|
|
1656
|
+
const currentResource = this.getNodeParameter('resource', i);
|
|
1657
|
+
const currentOperation = this.getNodeParameter('operation', i);
|
|
1658
|
+
this.logger.error(`Error processing item ${i + 1}`, {
|
|
1659
|
+
error: error.message,
|
|
1660
|
+
stack: error.stack,
|
|
1661
|
+
itemIndex: i,
|
|
1662
|
+
resource: currentResource,
|
|
1663
|
+
operation: currentOperation
|
|
1664
|
+
});
|
|
1665
|
+
if (error.response) {
|
|
1666
|
+
this.logger.error('API Error', {
|
|
1667
|
+
status: error.response.status,
|
|
1668
|
+
statusText: error.response.statusText,
|
|
1669
|
+
data: error.response.data
|
|
1670
|
+
});
|
|
1671
|
+
if (this.continueOnFail()) {
|
|
1672
|
+
returnData.push({
|
|
1673
|
+
json: {
|
|
1674
|
+
error: `API Error: ${error.response.status} ${error.response.statusText}`,
|
|
1675
|
+
details: error.response.data
|
|
1676
|
+
}
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1679
|
+
else {
|
|
1680
|
+
throw new Error(`API Error: ${error.response.status} ${error.response.statusText}`);
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
else if (error.request) {
|
|
1684
|
+
this.logger.error('Network Error', {
|
|
1685
|
+
request: error.request
|
|
1686
|
+
});
|
|
1687
|
+
if (this.continueOnFail()) {
|
|
1688
|
+
returnData.push({
|
|
1689
|
+
json: {
|
|
1690
|
+
error: 'Network Error: No response received from server',
|
|
1691
|
+
details: error.message
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1695
|
+
else {
|
|
1696
|
+
throw new Error('Network Error: No response received from server');
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
else {
|
|
1700
|
+
if (this.continueOnFail()) {
|
|
1701
|
+
returnData.push({
|
|
1702
|
+
json: {
|
|
1703
|
+
error: error.message,
|
|
1704
|
+
details: error.stack
|
|
1705
|
+
}
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
else {
|
|
1709
|
+
throw error;
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
this.logger.debug('Execution completed successfully');
|
|
1715
|
+
return [returnData];
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
exports.Databricks = Databricks;
|
|
1719
|
+
//# sourceMappingURL=Databricks.node.js.map
|