Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ RUN npm install -q

# copy source code
ADD . .
ADD config-docker.ls config.ls

# build
RUN npm run build
Expand Down
28 changes: 14 additions & 14 deletions query-types/curl.ls
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@ export get-context = ->
# execute :: (CancellablePromise cp) => OpsManager -> QueryStore -> DataSource -> String -> String -> Parameters -> cp result
export execute = (, , data-source, query, transpilation-language, parameters) -->
{shell-command, parse} = require \./shell-command-parser
result = parse shell-command, query
result = parse shell-command, (query.replace /\s/g, '')

# parsing error
if !!result.0.1
return (new-promise (, rej) -> rej new Error "Parsing Error #{result.0.1}")

result := result.0.0.args
result := result.0.0.args
|> concat-map id

url = result
|> find (-> !!it.opt)
url = result
|> find (-> !!it.opt)
|> (.opt)

options = result
|> filter (-> !!it.name)
|> map ({name, value}) ->
options = result
|> filter (-> !!it.name)
|> map ({name, value}) ->
(if name.length > 1 then "--" else "-") + name + if !!value then " #value" else ""
|> Str.join " "

[err, url] = compile-and-execute-sync do
[err, url] = compile-and-execute-sync do
url
transpilation-language
parameters |> Obj.map -> it ? ""

if !!err
return (new-promise (, rej) -> rej new Error "Url foramtting failed\n#err")
return (new-promise (, rej) -> rej new Error "Url foramtting failed\n#err")

# escape characters
url .= replace \{, '\\{'
Expand All @@ -55,14 +55,14 @@ export execute = (, , data-source, query, transpilation-language, parameters) --
return rej Error "Error in curl #code #output", null if code != 0
res output

with-cancel-and-dispose do
with-cancel-and-dispose do
execute-curl
->
->
curl-process.kill! if !!curl-process
returnP \killed

# default-document :: DataSourceCue -> String -> Document
export default-document = (data-source-cue, transpilation-language) ->
export default-document = (data-source-cue, transpilation-language) ->
query: """curl "https://api.github.com/emojis" """
transformation: "JSON.parse"
presentation: "json"
Expand Down
17 changes: 9 additions & 8 deletions query-types/mysql.ls
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ execute-sql = (data-source, query) -->
..connect!
..query query, (err, rows) -> if !!err then rej err else res rows

with-cancel-and-dispose do
with-cancel-and-dispose do
execute-sql-promise
-> returnP \killed
-> if !!connection then connection.end!

# connections :: (CancellablePromise cp) => a -> cp b
export connections = ->
returnP do
connections: (config?.connections?.mysql or {})
returnP do
connections: (config?.connections?.mysql or {})
|> obj-to-pairs
|> map ([name, value]) ->
label: (value?.label or name)
Expand All @@ -29,7 +29,7 @@ export connections = ->

# keywords :: (CancellablePromise cp) => [DataSource, String] -> cp [String]
export keywords = ([data-source, transpilation-language]) ->
results <- bindP (execute-sql data-source, "select table_schema, table_name, column_name from information_schema.columns")
results <- bindP (execute-sql data-source, "select table_schema, table_name, column_name from information_schema.columns")
tables = results |> (group-by (-> "#{it.table_schema}.#{it.table_name}")) >> (Obj.map map (.column_name))
returnP {
keywords: <[SELECT GROUP BY TOP ORDER WITH DISTINCT INNER OUTER JOIN]>
Expand All @@ -44,14 +44,15 @@ export get-context = ->
# execute :: (CancellablePromise cp) => OpsManager -> QueryStore -> DataSource -> String -> CompiledQueryParameters -> cp result
export execute = (, , data-source, query, transpilation, parameters) -->
(Obj.keys parameters) |> each (key) ->
query := query.replace "$#{key}$", parameters[key]
pattern = new RegExp "\\$#{key}\\$", \g
query := query.replace pattern, parameters[key]
execute-sql data-source, query

# default-document :: DataSourceCue -> String -> Document
export default-document = (data-source-cue, transpilation-language) ->
export default-document = (data-source-cue, transpilation-language) ->
query: """
select *
from
select *
from
limit 10
"""
transformation: "id"
Expand Down