remove snowflake-promise lib, update curlconverter to use dynamic import
This commit is contained in:
parent
7c40ad06b6
commit
c563bb64b5
|
@ -1 +1 @@
|
||||||
Subproject commit a2d61705e6f75f74b31154f9ae74e4e3166376ca
|
Subproject commit a3fb5faa97ebee477e6f3d01116380e6409ab1e8
|
|
@ -83,7 +83,7 @@
|
||||||
"google-spreadsheet": "npm:@budibase/google-spreadsheet@4.1.5",
|
"google-spreadsheet": "npm:@budibase/google-spreadsheet@4.1.5",
|
||||||
"ioredis": "5.3.2",
|
"ioredis": "5.3.2",
|
||||||
"isolated-vm": "^4.7.2",
|
"isolated-vm": "^4.7.2",
|
||||||
"jimp": "0.22.12",
|
"jimp": "1.1.4",
|
||||||
"joi": "17.6.0",
|
"joi": "17.6.0",
|
||||||
"js-yaml": "4.1.0",
|
"js-yaml": "4.1.0",
|
||||||
"jsonschema": "1.4.0",
|
"jsonschema": "1.4.0",
|
||||||
|
@ -111,7 +111,6 @@
|
||||||
"redis": "4",
|
"redis": "4",
|
||||||
"serialize-error": "^7.0.1",
|
"serialize-error": "^7.0.1",
|
||||||
"server-destroy": "1.0.1",
|
"server-destroy": "1.0.1",
|
||||||
"snowflake-promise": "^4.5.0",
|
|
||||||
"socket.io": "4.8.1",
|
"socket.io": "4.8.1",
|
||||||
"tar": "6.2.1",
|
"tar": "6.2.1",
|
||||||
"tmp": "0.2.3",
|
"tmp": "0.2.3",
|
||||||
|
|
|
@ -2,9 +2,8 @@ import { ImportSource, ImportInfo } from "./base"
|
||||||
import { Query } from "../../../../../definitions/common"
|
import { Query } from "../../../../../definitions/common"
|
||||||
import { URL } from "url"
|
import { URL } from "url"
|
||||||
|
|
||||||
const curlconverter = require("curlconverter")
|
const parseCurl = async (data: string): any => {
|
||||||
|
const curlconverter = await import("curlconverter")
|
||||||
const parseCurl = (data: string): any => {
|
|
||||||
const curlJson = curlconverter.toJsonString(data)
|
const curlJson = curlconverter.toJsonString(data)
|
||||||
return JSON.parse(curlJson)
|
return JSON.parse(curlJson)
|
||||||
}
|
}
|
||||||
|
@ -53,7 +52,7 @@ export class Curl extends ImportSource {
|
||||||
|
|
||||||
isSupported = async (data: string): Promise<boolean> => {
|
isSupported = async (data: string): Promise<boolean> => {
|
||||||
try {
|
try {
|
||||||
const curl = parseCurl(data)
|
const curl = await parseCurl(data)
|
||||||
this.curl = curl
|
this.curl = curl
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -6,7 +6,8 @@ import {
|
||||||
QueryType,
|
QueryType,
|
||||||
SqlQuery,
|
SqlQuery,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { Snowflake } from "snowflake-promise"
|
import snowflakeSdk from "snowflake-sdk"
|
||||||
|
import { promisify } from "util"
|
||||||
|
|
||||||
interface SnowflakeConfig {
|
interface SnowflakeConfig {
|
||||||
account: string
|
account: string
|
||||||
|
@ -17,6 +18,7 @@ interface SnowflakeConfig {
|
||||||
schema: string
|
schema: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const SCHEMA: Integration = {
|
const SCHEMA: Integration = {
|
||||||
docs: "https://developers.snowflake.com/",
|
docs: "https://developers.snowflake.com/",
|
||||||
description:
|
description:
|
||||||
|
@ -71,11 +73,42 @@ const SCHEMA: Integration = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
class SnowflakeIntegration {
|
class SnowflakePromise {
|
||||||
private client: Snowflake
|
config: SnowflakeConfig
|
||||||
|
client: snowflakeSdk
|
||||||
|
|
||||||
constructor(config: SnowflakeConfig) {
|
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> {
|
async testConnection(): Promise<ConnectionInfo> {
|
||||||
|
|
Loading…
Reference in New Issue