remove snowflake-promise lib, update curlconverter to use dynamic import

This commit is contained in:
Martin McKeaveney 2024-11-19 14:53:20 +00:00
parent 7c40ad06b6
commit c563bb64b5
5 changed files with 372 additions and 1854 deletions

@ -1 +1 @@
Subproject commit a2d61705e6f75f74b31154f9ae74e4e3166376ca
Subproject commit a3fb5faa97ebee477e6f3d01116380e6409ab1e8

View File

@ -83,7 +83,7 @@
"google-spreadsheet": "npm:@budibase/google-spreadsheet@4.1.5",
"ioredis": "5.3.2",
"isolated-vm": "^4.7.2",
"jimp": "0.22.12",
"jimp": "1.1.4",
"joi": "17.6.0",
"js-yaml": "4.1.0",
"jsonschema": "1.4.0",
@ -111,7 +111,6 @@
"redis": "4",
"serialize-error": "^7.0.1",
"server-destroy": "1.0.1",
"snowflake-promise": "^4.5.0",
"socket.io": "4.8.1",
"tar": "6.2.1",
"tmp": "0.2.3",

View File

@ -2,9 +2,8 @@ import { ImportSource, ImportInfo } from "./base"
import { Query } from "../../../../../definitions/common"
import { URL } from "url"
const curlconverter = require("curlconverter")
const parseCurl = (data: string): any => {
const parseCurl = async (data: string): any => {
const curlconverter = await import("curlconverter")
const curlJson = curlconverter.toJsonString(data)
return JSON.parse(curlJson)
}
@ -53,7 +52,7 @@ export class Curl extends ImportSource {
isSupported = async (data: string): Promise<boolean> => {
try {
const curl = parseCurl(data)
const curl = await parseCurl(data)
this.curl = curl
} catch (err) {
return false

View File

@ -6,7 +6,8 @@ import {
QueryType,
SqlQuery,
} from "@budibase/types"
import { Snowflake } from "snowflake-promise"
import snowflakeSdk from "snowflake-sdk"
import { promisify } from "util"
interface SnowflakeConfig {
account: string
@ -17,6 +18,7 @@ interface SnowflakeConfig {
schema: string
}
const SCHEMA: Integration = {
docs: "https://developers.snowflake.com/",
description:
@ -71,11 +73,42 @@ const SCHEMA: Integration = {
},
}
class SnowflakeIntegration {
private client: Snowflake
class SnowflakePromise {
config: SnowflakeConfig
client: snowflakeSdk
constructor(config: SnowflakeConfig) {
this.client = new Snowflake(config)
this.config = config
}
async connect() {
if (this.client?.isConnected()) return
this.client = snowflakeSdk.createConnection(this.config)
const connectAsync = promisify(this.client.connect.bind(this.client))
return connectAsync()
}
async execute(sql: string) {
return new Promise((resolve, reject) => {
this.client.execute({
sqlText: sql,
complete: function(err: Error, statementExecuted: string, rows: any) {
if (err) {
return reject(err)
}
resolve(rows)
},
})
})
}
}
class SnowflakeIntegration {
private client: SnowflakePromise
constructor(config: SnowflakeConfig) {
this.client = new SnowflakePromise(config)
}
async testConnection(): Promise<ConnectionInfo> {

2173
yarn.lock

File diff suppressed because it is too large Load Diff