feat: add nu-lang support (#5217)

* feat: add nu (nushell) support

* add worker tests

* deactivate tables and non-any types below top-level

full support will come in V1
for V0 it's better to keep things minimal and simple

* add syntax highlighting

used python's grammar, since nushell isn't supported by monaco nor svelte-highlights

for V1 nu will get it`s own grammar

* add logo

* partially implement plugin support

* change logo + ability to deploy + nsjail draft

* static variables + get_resource + get_variable

* lsp/dev.nu + initial nu lsp (not working yet)

* make it work with nsjail

* nullguard

* Much more flexible signature parsing and better error-messages

* add init script

* rename nulsp to nu

* install nu to dockerfile

* fix merge

* implement Default for MainArgSignature

* stage NU_CACHE_DIR

* improve dockerfiles

* dev.nu for parser-wasm + flake.nix

* update code for windows

* add nushell to flake

* upload Cargo.lock

* make build.sh work on nixos

* build wasm cli parsers

* add docs to README_DEV.md

* add helper script docker/dev.nu

* improve docker/dev.nu

* fix windows

* commit frontend/package(lock).json

* update cargo.lock

* correctly update cargo.lock

* remove lsp

* update flake.nix to include svelte server and nushell

* Revert base.sql to main

* remove PLUGIN_USE_RE

* make CARGO_PATH private

* add nu to cli

* Change flags to build wasm-nu-parser

* remove flake.nix from parser-wasm

* update wasm-build target

* remove unused import

* add cli support for nu

* update github workflows

* wasm-build 0.17 -> 0.19

* update build script

* update cargo.lock

* Fix typographical error

* update Cargo.lock

* update ENV_SETTINGS

* use published nu parser

* update package.lock

* rewrite parser in tree-sitter

* implement parser from scratch

* polishing

* change init script to match new parser

* fix imports

* fix cli build

* fix cli build

* merge

* update wasm

* use MiniPulledJob

* update cli

* change cli wasm schema

* change cli

* update deno.json

* make wasm modules load lazily

* regenerate parsers

* remove leftover

* update cargo.lock

* clean up dnt.ts

* add docs to cli/test.nu

* add schema validation option

* add Nu to try_validate_schema

* reference frontend to new parser version
This commit is contained in:
pyranota
2025-03-20 16:45:21 +01:00
committed by GitHub
parent 18e5057464
commit a3faea16e7
120 changed files with 7107 additions and 4125 deletions
+9 -2
View File
@@ -27,31 +27,38 @@ RUN wget https://golang.org/dl/go1.21.5.linux-amd64.tar.gz && tar -C /usr/local
ENV PATH="${PATH}:/usr/local/go/bin"
ENV GO_PATH=/usr/local/go/bin/go
# Install UV
# UV
RUN curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.4.18/uv-installer.sh | sh && mv /usr/local/cargo/bin/uv /usr/local/bin/uv
ENV TZ=Etc/UTC
ENV PYTHON_VERSION 3.11.4
# Python
RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz \
&& tar -xf Python-${PYTHON_VERSION}.tgz && cd Python-${PYTHON_VERSION}/ && ./configure --enable-optimizations \
&& make -j 4 && make install
RUN /usr/local/bin/python3 -m pip install pip-tools
# Bun
COPY --from=oven/bun:1.2.4 /usr/local/bin/bun /usr/bin/bun
ARG TARGETPLATFORM
# Deno
RUN curl -Lsf https://github.com/denoland/deno/releases/download/v2.0.2/deno-x86_64-unknown-linux-gnu.zip -o deno.zip
# RUN [ "$TARGETPLATFORM" == "linux/arm64" ] && curl -Lsf https://github.com/denoland/deno/releases/download/v2.0.0/deno-aarch64-unknown-linux-gnu.zip -o deno.zip || true
RUN unzip deno.zip && rm deno.zip && mv deno /usr/bin/deno
RUN apt-get update \
&& apt-get install -y postgresql-client --allow-unauthenticated
RUN rustup component add rustfmt
# C#
COPY --from=bitnami/dotnet-sdk:9.0.101-debian-12-r0 /opt/bitnami/dotnet-sdk /opt/dotnet-sdk
RUN ln -s /opt/dotnet-sdk/bin/dotnet /usr/bin/dotnet
# Nushell
COPY --from=ghcr.io/nushell/nushell:0.101.0-bookworm /usr/bin/nu /usr/bin/nu
+2 -2
View File
@@ -64,7 +64,7 @@ jobs:
platforms: linux/amd64
push: true
build-args: |
features=enterprise,enterprise_saml,stripe,embedding,parquet,prometheus,openidconnect,cloud,jemalloc,deno_core,license,otel,http_trigger,zip,oauth2,kafka,sqs_trigger,nats,php,mysql,mssql,bigquery,oracledb,postgres_trigger,mqtt_trigger,websocket,python,smtp,csharp,static_frontend,rust
features=enterprise,enterprise_saml,stripe,embedding,parquet,prometheus,openidconnect,cloud,jemalloc,deno_core,license,otel,http_trigger,zip,oauth2,kafka,sqs_trigger,nats,php,mysql,mssql,bigquery,oracledb,postgres_trigger,mqtt_trigger,websocket,python,smtp,csharp,static_frontend,rust,nu
secrets: |
rh_username=${{ secrets.RH_USERNAME }}
rh_password=${{ secrets.RH_PASSWORD }}
@@ -81,7 +81,7 @@ jobs:
platforms: linux/arm64
push: true
build-args: |
features=enterprise,enterprise_saml,stripe,embedding,parquet,prometheus,openidconnect,cloud,jemalloc,deno_core,license,otel,http_trigger,zip,oauth2,kafka,sqs_trigger,nats,php,mysql,mssql,bigquery,oracledb,postgres_trigger,mqtt_trigger,websocket,python,smtp,csharp,static_frontend,rust
features=enterprise,enterprise_saml,stripe,embedding,parquet,prometheus,openidconnect,cloud,jemalloc,deno_core,license,otel,http_trigger,zip,oauth2,kafka,sqs_trigger,nats,php,mysql,mssql,bigquery,oracledb,postgres_trigger,mqtt_trigger,websocket,python,smtp,csharp,static_frontend,rust,nu
secrets: |
rh_username=${{ secrets.RH_USERNAME }}
rh_password=${{ secrets.RH_PASSWORD }}
+1 -1
View File
@@ -51,7 +51,7 @@ jobs:
$env:OPENSSL_DIR="${Env:VCPKG_INSTALLATION_ROOT}\installed\x64-windows-static"
mkdir frontend/build && cd backend
New-Item -Path . -Name "windmill-api/openapi-deref.yaml" -ItemType "File" -Force
cargo build --release --features=enterprise,stripe,embedding,parquet,prometheus,openidconnect,cloud,jemalloc,tantivy,deno_core,license,http_trigger,zip,oauth2,kafka,nats,sqs_trigger,php,mysql,mssql,bigquery,oracledb,postgres_trigger,mqtt_trigger,websocket,python,smtp,csharp,static_frontend,rust
cargo build --release --features=enterprise,stripe,embedding,parquet,prometheus,openidconnect,cloud,jemalloc,tantivy,deno_core,license,http_trigger,zip,oauth2,kafka,nats,sqs_trigger,php,mysql,mssql,bigquery,oracledb,postgres_trigger,mqtt_trigger,websocket,python,smtp,csharp,static_frontend,rust,nu
- name: Rename binary with corresponding architecture
run: |
+1 -1
View File
@@ -67,7 +67,7 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
build-args: |
features=embedding,parquet,openidconnect,deno_core,license,http_trigger,zip,oauth2,php,mysql,mssql,bigquery,oracledb,postgres_trigger,mqtt_trigger,websocket,python,smtp,csharp,static_frontend,rust
features=embedding,parquet,openidconnect,deno_core,license,http_trigger,zip,oauth2,php,mysql,mssql,bigquery,oracledb,postgres_trigger,mqtt_trigger,websocket,python,smtp,csharp,static_frontend,rust,nu
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev
${{ steps.meta-public.outputs.tags }}
+2 -2
View File
@@ -95,7 +95,7 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
build-args: |
features=embedding,parquet,openidconnect,jemalloc,deno_core,license,http_trigger,zip,oauth2,dind,php,mysql,mssql,bigquery,oracledb,postgres_trigger,mqtt_trigger,websocket,python,smtp,csharp,static_frontend,rust
features=embedding,parquet,openidconnect,jemalloc,deno_core,license,http_trigger,zip,oauth2,dind,php,mysql,mssql,bigquery,oracledb,postgres_trigger,mqtt_trigger,websocket,python,smtp,csharp,static_frontend,rust,nu
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DEV_SHA }}
${{ steps.meta-public.outputs.tags }}
@@ -157,7 +157,7 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
build-args: |
features=enterprise,enterprise_saml,stripe,embedding,parquet,prometheus,openidconnect,cloud,jemalloc,tantivy,deno_core,license,http_trigger,zip,oauth2,kafka,sqs_trigger,nats,otel,dind,php,mysql,mssql,bigquery,oracledb,postgres_trigger,mqtt_trigger,websocket,python,smtp,csharp,static_frontend,rust
features=enterprise,enterprise_saml,stripe,embedding,parquet,prometheus,openidconnect,cloud,jemalloc,tantivy,deno_core,license,http_trigger,zip,oauth2,kafka,sqs_trigger,nats,otel,dind,php,mysql,mssql,bigquery,oracledb,postgres_trigger,mqtt_trigger,websocket,python,smtp,csharp,static_frontend,rust,nu
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-ee:${{ env.DEV_SHA }}
${{ steps.meta-ee-public.outputs.tags }}
+1 -1
View File
@@ -53,7 +53,7 @@ jobs:
$env:OPENSSL_DIR="${Env:VCPKG_INSTALLATION_ROOT}\installed\x64-windows-static"
mkdir frontend/build && cd backend
New-Item -Path . -Name "windmill-api/openapi-deref.yaml" -ItemType "File" -Force
cargo build --release --features=enterprise,stripe,embedding,parquet,prometheus,openidconnect,cloud,jemalloc,tantivy,deno_core,license,http_trigger,zip,oauth2,kafka,sqs_trigger,nats,php,mysql,mssql,bigquery,oracledb,postgres_trigger,mqtt_trigger,websocket,python,smtp,csharp,static_frontend,rust
cargo build --release --features=enterprise,stripe,embedding,parquet,prometheus,openidconnect,cloud,jemalloc,tantivy,deno_core,license,http_trigger,zip,oauth2,kafka,sqs_trigger,nats,php,mysql,mssql,bigquery,oracledb,postgres_trigger,mqtt_trigger,websocket,python,smtp,csharp,static_frontend,rust,nu
- name: Rename binary with corresponding architecture
run: |
+1
View File
@@ -8,3 +8,4 @@ CaddyfileRemoteMalo
**/.idea/
.direnv
.vscode
.dev-docker-wrapper*
+2
View File
@@ -41,6 +41,8 @@ COPY /typescript-client/docs/ /frontend/static/tsdocs/
RUN npm run generate-backend-client
ENV NODE_OPTIONS "--max-old-space-size=8192"
ARG VITE_BASE_URL ""
# Read more about macro in docker/dev.nu
# -- MACRO-SPREAD-WASM-PARSER-DEV-ONLY -- #
RUN npm run build
+609 -16
View File
@@ -1358,7 +1358,16 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
dependencies = [
"bit-vec",
"bit-vec 0.6.3",
]
[[package]]
name = "bit-set"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
dependencies = [
"bit-vec 0.8.0",
]
[[package]]
@@ -1367,6 +1376,12 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
[[package]]
name = "bit-vec"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
[[package]]
name = "bitflags"
version = "1.3.2"
@@ -1622,6 +1637,17 @@ dependencies = [
"allocator-api2",
]
[[package]]
name = "byte-unit"
version = "5.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1cd29c3c585209b0cbc7309bfe3ed7efd8c84c21b7af29c8bfae908f8777174"
dependencies = [
"rust_decimal",
"serde",
"utf8-width",
]
[[package]]
name = "bytecheck"
version = "0.6.12"
@@ -1689,6 +1715,12 @@ dependencies = [
"either",
]
[[package]]
name = "bytesize"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d2c12f985c78475a6b8d629afd0c360260ef34cfef52efccdcfd31972f81c2e"
[[package]]
name = "bzip2"
version = "0.4.4"
@@ -1885,11 +1917,21 @@ dependencies = [
"iana-time-zone",
"js-sys",
"num-traits",
"pure-rust-locales",
"serde",
"wasm-bindgen",
"windows-targets 0.52.6",
]
[[package]]
name = "chrono-humanize"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "799627e6b4d27827a814e837b9d8a504832086081806d45b1afa34dc982b023b"
dependencies = [
"chrono",
]
[[package]]
name = "chrono-tz"
version = "0.9.0"
@@ -2352,6 +2394,15 @@ version = "0.8.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
[[package]]
name = "crossterm_winapi"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
dependencies = [
"winapi",
]
[[package]]
name = "crunchy"
version = "0.2.3"
@@ -3058,8 +3109,8 @@ dependencies = [
"anyhow",
"az",
"bincode",
"bit-set",
"bit-vec",
"bit-set 0.5.3",
"bit-vec 0.6.3",
"bytes",
"capacity_builder 0.1.3",
"cooked-waker",
@@ -3254,7 +3305,7 @@ dependencies = [
"filetime",
"junction",
"libc",
"nix",
"nix 0.27.1",
"rand 0.8.5",
"rayon",
"serde",
@@ -3659,7 +3710,7 @@ dependencies = [
"libc",
"log",
"memchr",
"nix",
"nix 0.27.1",
"pin-project-lite",
"rand 0.8.5",
"serde",
@@ -3752,7 +3803,7 @@ dependencies = [
"hyper-util",
"libc",
"log",
"nix",
"nix 0.27.1",
"node_resolver",
"notify",
"ntapi",
@@ -4542,6 +4593,16 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "erased-serde"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e004d887f51fcb9fef17317a2f3525c887d8aa3f4f50fed920816a688284a5b7"
dependencies = [
"serde",
"typeid",
]
[[package]]
name = "errno"
version = "0.3.10"
@@ -4619,6 +4680,17 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
[[package]]
name = "fancy-regex"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e24cb5a94bcae1e5408b0effca5cd7172ea3c5755049c5f3af4cd283a165298"
dependencies = [
"bit-set 0.8.0",
"regex-automata 0.4.9",
"regex-syntax 0.8.5",
]
[[package]]
name = "fastdivide"
version = "0.4.2"
@@ -6326,6 +6398,15 @@ version = "3.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02"
[[package]]
name = "inventory"
version = "0.3.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab08d7cd2c5897f2c949e5383ea7c7db03fb19130ffcfbf7eda795137ae3cb83"
dependencies = [
"rustversion",
]
[[package]]
name = "ipconfig"
version = "0.3.2"
@@ -6365,6 +6446,12 @@ dependencies = [
"syn 2.0.100",
]
[[package]]
name = "is_ci"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45"
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
@@ -6741,6 +6828,17 @@ version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
[[package]]
name = "libproc"
version = "0.14.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78a09b56be5adbcad5aa1197371688dc6bb249a26da3bca2011ee2fb987ebfb"
dependencies = [
"bindgen 0.70.1",
"errno",
"libc",
]
[[package]]
name = "libredox"
version = "0.1.3"
@@ -6864,6 +6962,15 @@ dependencies = [
"hashbrown 0.15.2",
]
[[package]]
name = "lscolors"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53304fff6ab1e597661eee37e42ea8c47a146fca280af902bb76bff8a896e523"
dependencies = [
"nu-ansi-term 0.50.1",
]
[[package]]
name = "lz4_flex"
version = "0.11.3"
@@ -6884,6 +6991,15 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "mach2"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709"
dependencies = [
"libc",
]
[[package]]
name = "macro_rules_attribute"
version = "0.2.0"
@@ -7143,6 +7259,35 @@ dependencies = [
"paste",
]
[[package]]
name = "miette"
version = "7.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a955165f87b37fd1862df2a59547ac542c77ef6d17c666f619d1ad22dd89484"
dependencies = [
"cfg-if",
"miette-derive",
"owo-colors",
"supports-color",
"supports-hyperlinks",
"supports-unicode",
"terminal_size",
"textwrap",
"thiserror 1.0.69",
"unicode-width 0.1.14",
]
[[package]]
name = "miette-derive"
version = "7.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf45bf44ab49be92fd1227a3be6fc6f617f1a337c06af54981048574d8783147"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.100",
]
[[package]]
name = "mime"
version = "0.3.17"
@@ -7381,7 +7526,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e536ae46fcab0876853bd4a632ede5df4b1c2527a58f6c5a4150fe86be858231"
dependencies = [
"arrayvec",
"bit-set",
"bit-set 0.5.3",
"bitflags 2.9.0",
"codespan-reporting",
"hexf-parse",
@@ -7470,6 +7615,18 @@ dependencies = [
"libc",
]
[[package]]
name = "nix"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
dependencies = [
"bitflags 2.9.0",
"cfg-if",
"cfg_aliases 0.2.1",
"libc",
]
[[package]]
name = "nkeys"
version = "0.4.4"
@@ -7569,6 +7726,145 @@ dependencies = [
"winapi",
]
[[package]]
name = "nu-ansi-term"
version = "0.50.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "nu-derive-value"
version = "0.101.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71f7c8ed6ba88a567ec6f7c4cad4a7a8465ab93b8cdaf89d3dc72347a83c2d1f"
dependencies = [
"heck 0.5.0",
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.100",
]
[[package]]
name = "nu-engine"
version = "0.101.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c6619583ed281060a9ea0a3f4532eea918370c94e703b903065f35e5aa49b14"
dependencies = [
"log",
"nu-glob",
"nu-path",
"nu-protocol",
"nu-utils",
"terminal_size",
]
[[package]]
name = "nu-glob"
version = "0.101.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acd0a9fe69412acdc8501f5ef19031f9cac119d93823cb957b14ddfe1cb97660"
[[package]]
name = "nu-parser"
version = "0.101.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2adc2876bd7bc83be15786cedf2cb08a81a9d70fa4b8df569b3f1cbec1e0b58d"
dependencies = [
"bytesize",
"chrono",
"itertools 0.13.0",
"log",
"nu-engine",
"nu-path",
"nu-protocol",
"nu-utils",
"serde_json",
]
[[package]]
name = "nu-path"
version = "0.101.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ccd1bbaf370d79118bd1a807abb07d8d1386751d0ae9266baafa91bd0b5523f"
dependencies = [
"dirs 5.0.1",
"omnipath",
"pwd",
]
[[package]]
name = "nu-protocol"
version = "0.101.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72f49a395b632530d7f46fd24183c7f42423677f70afb3cb4726e3abfe92273b"
dependencies = [
"byte-unit",
"bytes",
"chrono",
"chrono-humanize",
"dirs 5.0.1",
"dirs-sys 0.4.1",
"fancy-regex",
"heck 0.5.0",
"indexmap 2.8.0",
"log",
"lru",
"miette",
"nix 0.29.0",
"nu-derive-value",
"nu-path",
"nu-system",
"nu-utils",
"num-format",
"serde",
"serde_json",
"thiserror 2.0.12",
"typetag",
"windows-sys 0.48.0",
]
[[package]]
name = "nu-system"
version = "0.101.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81182f7e64bd5dd16ab844d8e40f78e389d06d95f5a0c419f4701fb8fc163077"
dependencies = [
"chrono",
"itertools 0.13.0",
"libc",
"libproc",
"log",
"mach2",
"nix 0.29.0",
"ntapi",
"procfs",
"sysinfo",
"windows 0.56.0",
]
[[package]]
name = "nu-utils"
version = "0.101.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d1468fa8e6e12d9d53c90b44f3d11a37d87502d7a30d145f122341c5b33745"
dependencies = [
"crossterm_winapi",
"fancy-regex",
"log",
"lscolors",
"nix 0.29.0",
"num-format",
"serde",
"serde_json",
"strip-ansi-escapes",
"sys-locale",
"unicase",
]
[[package]]
name = "nuid"
version = "0.5.0"
@@ -7638,6 +7934,16 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
[[package]]
name = "num-format"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3"
dependencies = [
"arrayvec",
"itoa",
]
[[package]]
name = "num-integer"
version = "0.1.46"
@@ -7802,6 +8108,12 @@ dependencies = [
"asn1-rs",
]
[[package]]
name = "omnipath"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80adb31078122c880307e9cdfd4e3361e6545c319f9b9dcafcb03acd3b51a575"
[[package]]
name = "once_cell"
version = "1.21.1"
@@ -8117,6 +8429,12 @@ dependencies = [
"stable_deref_trait",
]
[[package]]
name = "owo-colors"
version = "4.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1036865bb9422d3300cf723f657c2851d0e9ab12567854b1f4eba3d77decf564"
[[package]]
name = "p224"
version = "0.13.2"
@@ -8589,7 +8907,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613283563cd90e1dfc3518d548caee47e0e725455ed619881f5cf21f36de4b48"
dependencies = [
"array-init",
"bit-vec",
"bit-vec 0.6.3",
"bytes",
"chrono",
"fallible-iterator 0.2.0",
@@ -8736,6 +9054,31 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "procfs"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc5b72d8145275d844d4b5f6d4e1eef00c8cd889edb6035c21675d1bb1f45c9f"
dependencies = [
"bitflags 2.9.0",
"chrono",
"flate2",
"hex",
"procfs-core",
"rustix 0.38.44",
]
[[package]]
name = "procfs-core"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "239df02d8349b06fc07398a3a1697b06418223b1c7725085e801e7c0fc6a12ec"
dependencies = [
"bitflags 2.9.0",
"chrono",
"hex",
]
[[package]]
name = "profiling"
version = "1.0.16"
@@ -8939,6 +9282,22 @@ dependencies = [
"reborrow",
]
[[package]]
name = "pure-rust-locales"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1190fd18ae6ce9e137184f207593877e70f39b015040156b1e05081cdfe3733a"
[[package]]
name = "pwd"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72c71c0c79b9701efe4e1e4b563b2016dd4ee789eb99badcb09d61ac4b92e4a2"
dependencies = [
"libc",
"thiserror 1.0.69",
]
[[package]]
name = "quick-xml"
version = "0.30.0"
@@ -10008,7 +10367,7 @@ dependencies = [
"libc",
"log",
"memchr",
"nix",
"nix 0.27.1",
"radix_trie",
"unicode-segmentation",
"unicode-width 0.1.14",
@@ -11169,6 +11528,15 @@ dependencies = [
"unicode-properties",
]
[[package]]
name = "strip-ansi-escapes"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a8f8038e7e7969abb3f1b7c2a811225e9296da208539e0f79c5251d6cac0025"
dependencies = [
"vte",
]
[[package]]
name = "strsim"
version = "0.10.0"
@@ -11241,6 +11609,27 @@ version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "supports-color"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c64fc7232dd8d2e4ac5ce4ef302b1d81e0b80d055b9d77c7c4f51f6aa4c867d6"
dependencies = [
"is_ci",
]
[[package]]
name = "supports-hyperlinks"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "804f44ed3c63152de6a9f90acbea1a110441de43006ea51bcce8f436196a288b"
[[package]]
name = "supports-unicode"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2"
[[package]]
name = "swc_allocator"
version = "0.1.10"
@@ -11668,6 +12057,15 @@ dependencies = [
"syn 2.0.100",
]
[[package]]
name = "sys-locale"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8eab9a99a024a169fe8a903cf9d4a3b3601109bcc13bd9e3c6fff259138626c4"
dependencies = [
"libc",
]
[[package]]
name = "sys_traits"
version = "0.1.7"
@@ -11692,6 +12090,20 @@ dependencies = [
"walkdir",
]
[[package]]
name = "sysinfo"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c33cd241af0f2e9e3b5c32163b873b29956890b5342e6745b917ce9d490f4af"
dependencies = [
"core-foundation-sys",
"libc",
"memchr",
"ntapi",
"rayon",
"windows 0.57.0",
]
[[package]]
name = "system-configuration"
version = "0.5.1"
@@ -11920,6 +12332,16 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "terminal_size"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45c6481c4829e4cc63825e62c49186a34538b7b2750b73b266581ffb612fb5ed"
dependencies = [
"rustix 1.0.3",
"windows-sys 0.59.0",
]
[[package]]
name = "text_lines"
version = "0.6.0"
@@ -11929,6 +12351,16 @@ dependencies = [
"serde",
]
[[package]]
name = "textwrap"
version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057"
dependencies = [
"unicode-linebreak",
"unicode-width 0.2.0",
]
[[package]]
name = "thiserror"
version = "1.0.69"
@@ -12721,7 +13153,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
dependencies = [
"matchers",
"nu-ansi-term",
"nu-ansi-term 0.46.0",
"once_cell",
"regex",
"serde",
@@ -12832,12 +13264,42 @@ version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
[[package]]
name = "typeid"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c"
[[package]]
name = "typenum"
version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f"
[[package]]
name = "typetag"
version = "0.2.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73f22b40dd7bfe8c14230cf9702081366421890435b2d625fa92b4acc4c3de6f"
dependencies = [
"erased-serde",
"inventory",
"once_cell",
"serde",
"typetag-impl",
]
[[package]]
name = "typetag-impl"
version = "0.2.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35f5380909ffc31b4de4f4bdf96b877175a016aa2ca98cee39fcfd8c4d53d952"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.100",
]
[[package]]
name = "typify"
version = "0.0.12"
@@ -12987,6 +13449,12 @@ version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]]
name = "unicode-linebreak"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f"
[[package]]
name = "unicode-normalization"
version = "0.1.24"
@@ -13158,6 +13626,12 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcfc827f90e53a02eaef5e535ee14266c1d569214c6aa70133a624d8a3164ba"
[[package]]
name = "utf8-width"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3"
[[package]]
name = "utf8_iter"
version = "1.0.4"
@@ -13257,6 +13731,15 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64"
[[package]]
name = "vte"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "231fdcd7ef3037e8330d8e17e61011a2c244126acc0a982f4040ac3f9f0bc077"
dependencies = [
"memchr",
]
[[package]]
name = "waker-fn"
version = "1.2.0"
@@ -13481,7 +13964,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d50819ab545b867d8a454d1d756b90cd5f15da1f2943334ca314af10583c9d39"
dependencies = [
"arrayvec",
"bit-vec",
"bit-vec 0.6.3",
"bitflags 2.9.0",
"cfg_aliases 0.1.1",
"codespan-reporting",
@@ -13512,7 +13995,7 @@ dependencies = [
"android_system_properties",
"arrayvec",
"ash",
"bit-set",
"bit-set 0.5.3",
"bitflags 2.9.0",
"block",
"cfg_aliases 0.1.1",
@@ -13983,6 +14466,17 @@ dependencies = [
"windmill-parser",
]
[[package]]
name = "windmill-parser-nu"
version = "1.478.1"
dependencies = [
"anyhow",
"nu-parser",
"serde_json",
"wasm-bindgen",
"windmill-parser",
]
[[package]]
name = "windmill-parser-php"
version = "1.478.1"
@@ -14086,6 +14580,7 @@ dependencies = [
"windmill-parser-csharp",
"windmill-parser-go",
"windmill-parser-graphql",
"windmill-parser-nu",
"windmill-parser-php",
"windmill-parser-py",
"windmill-parser-rust",
@@ -14155,7 +14650,7 @@ dependencies = [
"async-recursion",
"backon",
"base64 0.22.1",
"bit-vec",
"bit-vec 0.6.3",
"bollard",
"bytes",
"chrono",
@@ -14187,7 +14682,7 @@ dependencies = [
"mappable-rc",
"mysql_async",
"native-tls",
"nix",
"nix 0.27.1",
"object_store",
"once_cell",
"opentelemetry",
@@ -14219,6 +14714,7 @@ dependencies = [
"windmill-parser-csharp",
"windmill-parser-go",
"windmill-parser-graphql",
"windmill-parser-nu",
"windmill-parser-php",
"windmill-parser-py",
"windmill-parser-py-imports",
@@ -14240,6 +14736,26 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows"
version = "0.56.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132"
dependencies = [
"windows-core 0.56.0",
"windows-targets 0.52.6",
]
[[package]]
name = "windows"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143"
dependencies = [
"windows-core 0.57.0",
"windows-targets 0.52.6",
]
[[package]]
name = "windows"
version = "0.58.0"
@@ -14259,19 +14775,65 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-core"
version = "0.56.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4698e52ed2d08f8658ab0c39512a7c00ee5fe2688c65f8c0a4f06750d729f2a6"
dependencies = [
"windows-implement 0.56.0",
"windows-interface 0.56.0",
"windows-result 0.1.2",
"windows-targets 0.52.6",
]
[[package]]
name = "windows-core"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d"
dependencies = [
"windows-implement 0.57.0",
"windows-interface 0.57.0",
"windows-result 0.1.2",
"windows-targets 0.52.6",
]
[[package]]
name = "windows-core"
version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
dependencies = [
"windows-implement",
"windows-interface",
"windows-implement 0.58.0",
"windows-interface 0.58.0",
"windows-result 0.2.0",
"windows-strings 0.1.0",
"windows-targets 0.52.6",
]
[[package]]
name = "windows-implement"
version = "0.56.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.100",
]
[[package]]
name = "windows-implement"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.100",
]
[[package]]
name = "windows-implement"
version = "0.58.0"
@@ -14283,6 +14845,28 @@ dependencies = [
"syn 2.0.100",
]
[[package]]
name = "windows-interface"
version = "0.56.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.100",
]
[[package]]
name = "windows-interface"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.100",
]
[[package]]
name = "windows-interface"
version = "0.58.0"
@@ -14311,6 +14895,15 @@ dependencies = [
"windows-targets 0.53.0",
]
[[package]]
name = "windows-result"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-result"
version = "0.2.0"
+6 -2
View File
@@ -22,11 +22,12 @@ members = [
"./parsers/windmill-parser-go",
"./parsers/windmill-parser-rust",
"./parsers/windmill-parser-csharp",
"./parsers/windmill-parser-nu",
"./parsers/windmill-parser-bash",
"./parsers/windmill-parser-py",
"./parsers/windmill-parser-py-imports",
"./parsers/windmill-sql-datatype-parser-wasm",
"./parsers/windmill-parser-yaml", "windmill-macros",
"./parsers/windmill-parser-yaml", "windmill-macros", "parsers/windmill-parser-nu",
]
[workspace.package]
@@ -79,6 +80,7 @@ sqs_trigger = ["windmill-api/sqs_trigger"]
python = ["windmill-worker/python"]
smtp = ["windmill-api/smtp", "windmill-common/smtp"]
csharp = ["windmill-worker/csharp"]
nu = ["windmill-worker/nu"]
license = ["windmill-api/license"]
oauth2 = ["windmill-api/oauth2"]
http_trigger = ["windmill-api/http_trigger"]
@@ -155,6 +157,7 @@ windmill-parser-go = { path = "./parsers/windmill-parser-go" }
windmill-parser-rust = { path = "./parsers/windmill-parser-rust" }
windmill-parser-yaml = { path = "./parsers/windmill-parser-yaml" }
windmill-parser-csharp = { path = "./parsers/windmill-parser-csharp" }
windmill-parser-nu = { path = "./parsers/windmill-parser-nu" }
windmill-parser-bash = { path = "./parsers/windmill-parser-bash" }
windmill-parser-sql = { path = "./parsers/windmill-parser-sql" }
windmill-parser-graphql = { path = "./parsers/windmill-parser-graphql" }
@@ -310,6 +313,7 @@ rdkafka = { version = "0.36.2", features = ["cmake-build", "ssl-vendored"] }
pg_escape = "0.1.1"
async-nats = "0.38.0"
nkeys = "0.4.4"
nu-parser = { version = "0.101.0", default-features = false }
datafusion = "39.0.0"
object_store = { version = "0.10.0", features = ["aws", "azure"] }
@@ -355,7 +359,7 @@ quote = "1.0.36"
regex-lite = "0.1.6"
yaml-rust = "0.4.5"
tokio-tungstenite = { version = "0.24.0", features = ["native-tls"] }
tree-sitter = {version = "0.23.0", features = []}
tree-sitter = { version = "0.23.0", features = [] }
tree-sitter-c-sharp = "0.23.0"
oracle = { version = "0.6.3", features = ["chrono"] }
rumqttc = { version = "0.24.0", features = ["use-native-tls"]}
@@ -0,0 +1 @@
-- Add down migration script here
@@ -0,0 +1,2 @@
ALTER TYPE SCRIPT_LANG ADD VALUE IF NOT EXISTS 'nu';
UPDATE config set config = jsonb_set(config, '{worker_tags}', config->'worker_tags' || '["nu"]'::jsonb) where name = 'worker__default' and config @> '{"worker_tags": ["deno", "python3", "go", "bash", "powershell", "dependency", "flow", "hub", "other", "bun", "php", "rust", "ansible", "csharp"]}'::jsonb AND NOT config->'worker_tags' @> '"nu"'::jsonb;
@@ -0,0 +1,16 @@
[package]
name = "windmill-parser-nu"
version.workspace = true
authors.workspace = true
edition.workspace = true
[lib]
name = "windmill_parser_nu"
path = "./src/lib.rs"
[dependencies]
windmill-parser.workspace = true
anyhow.workspace = true
nu-parser.workspace = true
wasm-bindgen.workspace = true
serde_json.workspace = true
@@ -0,0 +1,261 @@
#![cfg_attr(target_arch = "wasm32", feature(c_variadic))]
use anyhow::{anyhow, bail};
use nu_parser::lex;
use serde_json::{json, Value};
use windmill_parser::{Arg, MainArgSignature, Typ};
pub fn parse_nu_signature(code: &str) -> anyhow::Result<MainArgSignature> {
let (tokens, ..) = lex(code.as_bytes(), 0, &[], &[], true);
let src = code.to_owned();
#[derive(Debug)]
enum LastToken {
None,
Def,
Main,
Args(String),
}
let mut last_token = LastToken::None;
for token in tokens {
let s = token.span;
let cont = src.get(s.start..s.end).ok_or(anyhow!("Parsing error"))?;
last_token = match last_token {
LastToken::None if cont == "def" => LastToken::Def,
LastToken::Def if cont == "main" => LastToken::Main,
LastToken::Main => {
LastToken::Args(cont.get(1..(cont.len() - 1)).unwrap_or("Error").to_owned())
}
LastToken::Args(_) => break,
_ => LastToken::None,
};
}
let LastToken::Args(args) = last_token else {
bail!("Cannot find main function.");
};
let mut sig = MainArgSignature::default();
sig.no_main_func = Some(false);
let batches = args
.lines()
.filter_map(|el| {
if el.trim_start().starts_with('#') {
None
} else {
Some(
el.split(',')
.map(|el| el.trim())
.filter(|el| el != &"")
.collect::<Vec<&str>>(),
)
}
})
.flatten()
.collect::<Vec<&str>>();
let mut compensate_lookahead = 0;
for (i, batch) in batches.iter().enumerate() {
// parse_default can lookahead and if it does we need to compensate
// otherwise we would try to parse data already parsed but not yielded by parse_default
if compensate_lookahead > 0 {
compensate_lookahead -= 1;
continue;
}
let type_start = batch.find(":");
let default_start = batch.find("=");
let (name, typ, default) = match (type_start, default_start) {
(None, None) => (batch.trim(), None, None),
(None, Some(d)) => (
batch
.get(0..d)
.ok_or(anyhow!("Cannot parse argument ident"))?
.trim(),
None,
Some(parse_default(
&batch
.get(d..)
.ok_or(anyhow!("Cannot parse default value for argument"))?,
&batches,
i,
&mut compensate_lookahead,
)?),
),
(Some(t), None) => (
batch
.get(0..t)
.ok_or(anyhow!("Cannot parse argument ident"))?
.trim(),
Some(parse_type(
&batch
.get(t..)
.ok_or(anyhow!("Cannot parse type of argument"))?,
)?),
None,
),
(Some(t), Some(d)) => {
if t < d {
(
batch
.get(0..t)
.ok_or(anyhow!("Cannot parse argument ident"))?
.trim(),
Some(parse_type(
&batch
.get(t..d)
.ok_or(anyhow!("Cannot parse type of argument"))?,
)?),
Some(parse_default(
&batch
.get(d..)
.ok_or(anyhow!("Cannot parse default value of argument"))?,
&batches,
i,
&mut compensate_lookahead,
)?),
)
} else {
bail!("Parsing error `:` should be before `=`\nit likely means you are trying to set default value to record or table which is not supported at the moment.")
}
}
};
// Check if it is optional
let optional = {
let Some(element) = name.chars().last() else {
bail!("Internal error, cannot check if argument is optional")
};
element == '?'
};
// Rest parameters are not supported
if matches!(name.get(0..3), Some("...")) {
bail!("Rest (...) parameters are not supported")
}
// Flags are not supported
if matches!(name.get(0..2), Some("--")) {
bail!("Flags are not supported")
}
sig.args.push(Arg {
name: if optional {
name.get(..name.len() - 1).unwrap_or("Error").to_owned()
} else {
name.to_owned()
},
typ: typ.unwrap_or(Typ::Unknown),
otyp: None,
has_default: default.is_some() || optional,
default: default.or_else(|| if optional { Some(json!(null)) } else { None }),
oidx: None,
});
}
fn parse_type(content: &str) -> anyhow::Result<Typ> {
let c = content.replace(":", "").trim().to_owned();
let typ = match c.as_str() {
"string" => Typ::Str(None),
"int" => Typ::Int,
"float" => Typ::Float,
"number" => Typ::Float,
"record" => Typ::Object(vec![]),
"table" => Typ::List(Box::new(Typ::Object(vec![]))),
"nothing" => Typ::Unknown,
// TODO: needs additional work on literal parsing
// "binary" => Typ::Bytes,
"datetime" => Typ::Datetime,
"any" => Typ::Unknown,
"bool" => Typ::Bool,
// Lists
"list" | "list<any>" | "list<nothing>" => Typ::List(Box::new(Typ::Unknown)),
"list<number>" => Typ::List(Box::new(Typ::Float)),
"list<bool>" => Typ::List(Box::new(Typ::Bool)),
"list<string>" => Typ::List(Box::new(Typ::Str(None))),
// list<float/int> is not supported
// Records and Tables
// TODO: Support in V1?
s if s.contains("record<") => {
bail!("typed records are not supported, use `ident: record`")
}
s if s.contains("table<") => {
bail!("typed tables are not supported, use `ident: table`")
}
s => bail!("{s} is not supported"),
};
Ok(typ)
}
fn parse_default(
content: &str,
ctx: &[&str],
i: usize,
skip: &mut usize,
) -> anyhow::Result<Value> {
let mut c = content.replace("=", "").trim().to_owned();
fn parse_object_literal(
(open, close): (char, char),
mut c_2: String,
ctx: &[&str],
i: usize,
skip: &mut usize,
) -> anyhow::Result<String> {
// It is list
// if c.contains("[") {
let mut closed = false;
if c_2 != open.to_string() {
// [a ~ , ~ ...
// Add ^
c_2 += ",";
}
// else {
// [
// a < Do not add ","
// ...
// }
let remainder = &ctx
.iter()
.skip(i + 1)
.map_while(|el| {
let el = el.trim();
if closed {
None
} else {
if el.chars().last() == Some(close) {
closed = true;
}
*skip += 1;
Some(el)
}
})
.collect::<Vec<&str>>()
.join(",");
if remainder.contains(&['{', '[']) {
bail!("Nesting is not supported")
}
Ok((c_2 + remainder)
// Remove trailing comma if there is any
.replace(&format!(",{close}"), &close.to_string()))
}
// It is list
if c.contains("[") {
if c.chars().last() != Some(']') {
c = parse_object_literal(('[', ']'), c.clone(), ctx, i, skip)?;
}
}
// It is record
if c.contains("{") {
if c.chars().last() != Some('}') {
c = parse_object_literal(('{', '}'), c.clone(), ctx, i, skip)?;
}
}
Ok(serde_json::from_str(&c)?)
}
Ok(sig)
}
@@ -0,0 +1,690 @@
#[cfg(test)]
mod test {
use serde_json::json;
use windmill_parser::{Arg, MainArgSignature, Typ};
use windmill_parser_nu::parse_nu_signature;
#[test]
fn test_nu_no_main_sig() {
assert!(parse_nu_signature("").is_err());
}
#[test]
fn test_nu_any_sig() {
let sig = parse_nu_signature(
r#"
def main [ a, b , c, d] {}
"#,
)
.unwrap();
assert_eq!(
MainArgSignature {
star_args: false,
star_kwargs: false,
args: vec![
Arg {
name: "a".into(),
otyp: None,
typ: Typ::Unknown,
default: None,
has_default: false,
oidx: None
},
Arg {
name: "b".into(),
otyp: None,
typ: Typ::Unknown,
default: None,
has_default: false,
oidx: None
},
Arg {
name: "c".into(),
otyp: None,
typ: Typ::Unknown,
default: None,
has_default: false,
oidx: None
},
Arg {
name: "d".into(),
otyp: None,
typ: Typ::Unknown,
default: None,
has_default: false,
oidx: None
}
],
no_main_func: Some(false),
has_preprocessor: None,
},
sig
);
}
#[test]
fn test_nu_optional_sig() {
let sig = parse_nu_signature(
r#"
def main [foo?] {}
"#,
)
.unwrap();
assert_eq!(
MainArgSignature {
star_args: false,
star_kwargs: false,
args: vec![Arg {
name: "foo".into(),
otyp: None,
typ: Typ::Unknown,
default: Some(serde_json::Value::Null),
has_default: true,
oidx: None
},],
no_main_func: Some(false),
has_preprocessor: None,
},
sig
);
}
#[test]
fn test_nu_simple_typed_sig() {
let sig = parse_nu_signature(
r#"
def main [ foo: string, bar: int] {}
"#,
)
.unwrap();
assert_eq!(
MainArgSignature {
star_args: false,
star_kwargs: false,
args: vec![
Arg {
name: "foo".into(),
otyp: None,
typ: Typ::Str(None),
default: None,
has_default: false,
oidx: None
},
Arg {
name: "bar".into(),
otyp: None,
typ: Typ::Int,
default: None,
has_default: false,
oidx: None
},
],
no_main_func: Some(false),
has_preprocessor: None,
},
sig
);
}
#[test]
fn test_nu_complete_typed_sig() {
let sig = parse_nu_signature(
r#"
def main [
a1: any,
a2: bool,
a3: int,
a4: float,
a5: datetime,
a6: string,
a7: record,
a8: list,
a9: table,
a10: nothing,
] {}
"#,
)
.unwrap();
assert_eq!(
MainArgSignature {
star_args: false,
star_kwargs: false,
args: vec![
Arg {
name: "a1".into(),
otyp: None,
typ: Typ::Unknown,
default: None,
has_default: false,
oidx: None
},
Arg {
name: "a2".into(),
otyp: None,
typ: Typ::Bool,
default: None,
has_default: false,
oidx: None
},
Arg {
name: "a3".into(),
otyp: None,
typ: Typ::Int,
default: None,
has_default: false,
oidx: None
},
Arg {
name: "a4".into(),
otyp: None,
typ: Typ::Float,
default: None,
has_default: false,
oidx: None
},
Arg {
name: "a5".into(),
otyp: None,
typ: Typ::Datetime,
default: None,
has_default: false,
oidx: None
},
Arg {
name: "a6".into(),
otyp: None,
typ: Typ::Str(None),
default: None,
has_default: false,
oidx: None
},
Arg {
name: "a7".into(),
otyp: None,
typ: Typ::Object(vec![]),
default: None,
has_default: false,
oidx: None
},
Arg {
name: "a8".into(),
otyp: None,
typ: Typ::List(Box::new(Typ::Unknown)),
default: None,
has_default: false,
oidx: None
},
Arg {
name: "a9".into(),
otyp: None,
typ: Typ::List(Box::new(Typ::Object(vec![]))),
default: None,
has_default: false,
oidx: None
},
Arg {
name: "a10".into(),
otyp: None,
typ: Typ::Unknown,
default: None,
has_default: false,
oidx: None
},
],
no_main_func: Some(false),
has_preprocessor: None,
},
sig
);
}
#[test]
fn test_nu_default_sig() {
let sig = parse_nu_signature(
r#"
def main [ foo = "Foo", bar: string = "Bar", bazz = 3 ] {}
"#,
)
.unwrap();
println!("{}", serde_json::to_string_pretty(&sig).unwrap());
assert_eq!(
MainArgSignature {
star_args: false,
star_kwargs: false,
args: vec![
Arg {
name: "foo".into(),
otyp: None,
typ: Typ::Unknown,
default: Some(json!("Foo")),
has_default: true,
oidx: None
},
Arg {
name: "bar".into(),
otyp: None,
typ: Typ::Str(None),
default: Some(json!("Bar")),
has_default: true,
oidx: None
},
Arg {
name: "bazz".into(),
otyp: None,
typ: Typ::Unknown,
default: Some(json!(3)),
has_default: true,
oidx: None
},
],
no_main_func: Some(false),
has_preprocessor: None,
},
sig
);
}
#[test]
fn test_nu_preprocessor_sig() {}
#[test]
fn test_nu_flags_sig() {
assert!(parse_nu_signature(
r#"
def main [--flag] {}
"#,
)
.is_err());
}
#[test]
fn test_nu_rest_sig() {
assert!(parse_nu_signature(
r#"
def main [...foo: string] {}
"#,
)
.is_err())
}
// #[test]
// fn test_nu_dynamically_sized_sig() {
// parse_nu_signature(
// r#"
// def main [] {
// }
// "#,
// );
// }
// #[test]
// fn test_nu_record_sig() {
// let sig = parse_nu_signature(
// r#"
// def main [ foo: record<a: string, b, c: number, d> ] { }
// "#,
// )
// .unwrap();
// assert_eq!(
// MainArgSignature {
// star_args: false,
// star_kwargs: false,
// args: vec![Arg {
// name: "foo".into(),
// otyp: None,
// typ: Typ::Object(vec![
// ObjectProperty { key: "a".into(), typ: Box::new(Typ::Str(None)) },
// ObjectProperty { key: "b".into(), typ: Box::new(Typ::Unknown) },
// ObjectProperty { key: "c".into(), typ: Box::new(Typ::Float) },
// ObjectProperty { key: "d".into(), typ: Box::new(Typ::Unknown) },
// ]),
// default: None,
// has_default: false,
// oidx: None
// },],
// no_main_func: Some(false),
// has_preprocessor: None,
// },
// sig
// );
// }
#[test]
fn test_nu_list_sig() {
let sig = parse_nu_signature(
r#"
def main [ foo: list<number> ] { }
"#,
)
.unwrap();
println!("{}", serde_json::to_string_pretty(&sig).unwrap());
assert_eq!(
MainArgSignature {
star_args: false,
star_kwargs: false,
args: vec![Arg {
name: "foo".into(),
otyp: None,
typ: Typ::List(Box::new(Typ::Float)),
default: None,
has_default: false,
oidx: None
},],
no_main_func: Some(false),
has_preprocessor: None,
},
sig
);
}
#[test]
fn test_nu_list_full_sig() {
let sig = parse_nu_signature(
r#"
def main [ a, foo: list<number> = [ 2, 3, 4 ], b ] { }
"#,
)
.unwrap();
println!("{}", serde_json::to_string_pretty(&sig).unwrap());
assert_eq!(
MainArgSignature {
star_args: false,
star_kwargs: false,
args: vec![
Arg {
name: "a".into(),
otyp: None,
typ: Typ::Unknown,
default: None,
has_default: false,
oidx: None
},
Arg {
name: "foo".into(),
otyp: None,
typ: Typ::List(Box::new(Typ::Float)),
default: Some(json!([2, 3, 4])),
has_default: true,
oidx: None
},
Arg {
name: "b".into(),
otyp: None,
typ: Typ::Unknown,
default: None,
has_default: false,
oidx: None
},
],
no_main_func: Some(false),
has_preprocessor: None,
},
sig
);
}
#[test]
fn test_nu_datetime_sig() {
let sig = parse_nu_signature(
r#"
def main [ foo: datetime ] { }
"#,
)
.unwrap();
assert_eq!(
MainArgSignature {
star_args: false,
star_kwargs: false,
args: vec![Arg {
name: "foo".into(),
otyp: None,
typ: Typ::Datetime,
default: None,
has_default: false,
oidx: None
},],
no_main_func: Some(false),
has_preprocessor: None,
},
sig
);
}
// TODO: Re-enable for V1
// #[test]
// fn test_nu_table_sig() {
// let sig = parse_nu_signature(
// r#"
// def main [ foo: table<a, b: number, c: string>] { }
// "#,
// )
// .unwrap();
// assert_eq!(
// MainArgSignature {
// star_args: false,
// star_kwargs: false,
// args: vec![Arg {
// name: "foo".into(),
// otyp: None,
// typ: Typ::List(Box::new(Typ::Object(vec![
// ObjectProperty { key: "a".into(), typ: Box::new(Typ::Unknown) },
// ObjectProperty { key: "b".into(), typ: Box::new(Typ::Float) },
// ObjectProperty { key: "c".into(), typ: Box::new(Typ::Str(None)) },
// ]))),
// default: None,
// has_default: false,
// oidx: None
// },],
// no_main_func: Some(false),
// has_preprocessor: None,
// },
// sig
// );
// }
#[test]
fn test_nu_wrapup_sig() {
let sig = parse_nu_signature(
r#"
def main [a ,b :int,c? , d: string = "foo", bi?: any] {}
"#,
)
.unwrap();
assert_eq!(
MainArgSignature {
star_args: false,
star_kwargs: false,
args: vec![
Arg {
name: "a".into(),
otyp: None,
typ: Typ::Unknown,
default: None,
has_default: false,
oidx: None
},
Arg {
name: "b".into(),
otyp: None,
typ: Typ::Int,
default: None,
has_default: false,
oidx: None
},
Arg {
name: "c".into(),
otyp: None,
typ: Typ::Unknown,
default: Some(serde_json::Value::Null),
has_default: true,
oidx: None
},
Arg {
name: "d".into(),
otyp: None,
typ: Typ::Str(None),
default: Some(json!("foo")),
has_default: true,
oidx: None
},
Arg {
name: "bi".into(),
otyp: None,
typ: Typ::Unknown,
default: Some(serde_json::Value::Null),
has_default: true,
oidx: None
}
],
no_main_func: Some(false),
has_preprocessor: None,
},
sig
);
}
// #[test]
// fn test_nu_wrapup_nested_sig() {
// let sig = parse_nu_signature(
// r#"
// def main [
// baz: string,
// foo: record<a: string,
// b,
// c: list<number>,
// d: record<a1, b1, c1>>
// =
// {
// a: "a",
// b: 3,
// c: [ 2, 3, 4 ],
// d: {
// a: true,
// b: false,
// c: true
// }
// }
// ] { }
// "#,
// )
// .unwrap();
// println!("{}", serde_json::to_string_pretty(&sig).unwrap());
// assert_eq!(
// MainArgSignature {
// star_args: false,
// star_kwargs: false,
// args: vec![
// Arg {
// name: "baz".into(),
// otyp: None,
// typ: Typ::Str(None),
// default: None,
// has_default: false,
// oidx: None
// },
// Arg {
// name: "foo".into(),
// otyp: None,
// typ: Typ::Object(vec![
// ObjectProperty { key: "a".into(), typ: Box::new(Typ::Str(None)) },
// ObjectProperty { key: "b".into(), typ: Box::new(Typ::Unknown) },
// ObjectProperty {
// key: "c".into(),
// typ: Box::new(Typ::List(Box::new(Typ::Float)))
// },
// ObjectProperty {
// key: "d".into(),
// typ: Box::new(Typ::Object(vec![
// ObjectProperty {
// key: "a1".into(),
// typ: Box::new(Typ::Unknown)
// },
// ObjectProperty {
// key: "b1".into(),
// typ: Box::new(Typ::Unknown)
// },
// ObjectProperty {
// key: "c1".into(),
// typ: Box::new(Typ::Unknown)
// }
// ]))
// },
// ]),
// default: Some(json!({
// "a": "a",
// "b": 3,
// "c": [
// 2,
// 3,
// 4
// ],
// "d": {
// "a": true,
// "b": false,
// "c": true
// }
// })),
// has_default: true,
// oidx: None
// },
// ],
// no_main_func: Some(false),
// has_preprocessor: None,
// },
// sig
// );
// }
#[test]
fn test_nu_nested_extra_types() {
assert_eq!(
parse_nu_signature(
r#"
def main [a: list<int>] {}
"#,
)
.is_err(),
true
);
assert_eq!(
parse_nu_signature(
r#"
def main [a: list<float>] {}
"#,
)
.is_err(),
true
);
assert_eq!(
parse_nu_signature(
r#"
def main [a: list<datetime>] {}
"#,
)
.is_err(),
true
);
assert_eq!(
parse_nu_signature(
r#"
def main [a: list<binary>] {}
"#,
)
.is_err(),
true
);
assert_eq!(
parse_nu_signature(
r#"
def main [a: list<list<int>>] {}
"#,
)
.is_err(),
true
);
}
}
@@ -2580,4 +2580,4 @@ import innerdifffolder
'{}',
'',
'',
'f/foobar/bar', -28028598712388159, 'python3', '');
'f/foobar/bar', -28028598712388159, 'python3', '');
@@ -0,0 +1 @@
use flake ../../#wasm
@@ -27,6 +27,7 @@ rust-parser = [ "dep:windmill-parser-rust"]
graphql-parser = [ "dep:windmill-parser-graphql"]
ansible-parser = [ "dep:windmill-parser-yaml"]
csharp-parser = [ "dep:windmill-parser-csharp"]
nu-parser = [ "dep:windmill-parser-nu"]
[dependencies]
anyhow.workspace = true
@@ -41,6 +42,7 @@ windmill-parser-graphql = { workspace = true, optional = true }
windmill-parser-rust = { workspace = true, optional = true }
windmill-parser-yaml = { workspace = true, optional = true }
windmill-parser-csharp = { workspace = true, optional = true }
windmill-parser-nu = { workspace = true, optional = true }
wasm-bindgen.workspace = true
serde_json.workspace = true
getrandom = { workspace = true, features = ["js"] }
@@ -1,3 +1,4 @@
### Windmill parser wasm
How to build
@@ -14,7 +15,20 @@ Install wasm-pack
cargo install wasm-pack
```
#### To use it on a dev environment
Or enter nix devshell
```
nix develop ../../#wasm
```
#### Dev locally
```
./dev.nu <language>
```
#### Or how to use it on a dev environment manually
Go to frontend and run:
@@ -23,3 +37,15 @@ npm install ../backend/parsers/windmill-parser-wasm/pkg
```
Make sure to not reset the package.json before commiting
#### Testing with docker
Go to the root
```
sudo docker/dev.nu up --features "<feature1>,<feature2>" --wasm-pkg <language>
```
For example to test `nu`:
```
sudo docker/dev.nu up --features "static_frontend,nu" --wasm-pkg nu
```
+75
View File
@@ -0,0 +1,75 @@
#!/usr/bin/env bash
set -eou pipefail
#-# bun and deno
OUT_DIR="../../../cli/wasm/ts"
mkdir -p $OUT_DIR
wasm-pack build --release --target deno --out-dir $OUT_DIR --features "ts-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-ts"/' $OUT_DIR/package.json
rm $OUT_DIR/.gitignore
#-# sql languages, graphql and bash/powershell, since they all use regex
OUT_DIR="../../../cli/wasm/regex"
mkdir -p $OUT_DIR
wasm-pack build --release --target deno --out-dir $OUT_DIR \
--features "sql-parser,graphql-parser,bash-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-regex"/' $OUT_DIR/package.json
rm $OUT_DIR/.gitignore
#-# python
OUT_DIR="../../../cli/wasm/python"
mkdir -p $OUT_DIR
wasm-pack build --release --target deno --out-dir $OUT_DIR --features "py-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-py"/' $OUT_DIR/package.json
rm $OUT_DIR/.gitignore
#-# go
OUT_DIR="../../../cli/wasm/go"
mkdir -p $OUT_DIR
wasm-pack build --release --target deno --out-dir $OUT_DIR --features "go-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-go"/' $OUT_DIR/package.json
rm $OUT_DIR/.gitignore
#-# php
OUT_DIR="../../../cli/wasm/php"
mkdir -p $OUT_DIR
wasm-pack build --release --target deno --out-dir $OUT_DIR --features "php-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-php"/' $OUT_DIR/package.json
rm $OUT_DIR/.gitignore
#-# rust
OUT_DIR="../../../cli/wasm/rust"
mkdir -p $OUT_DIR
wasm-pack build --release --target deno --out-dir $OUT_DIR --features "rust-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-rust"/' $OUT_DIR/package.json
rm $OUT_DIR/.gitignore
#-# ansible
OUT_DIR="../../../cli/wasm/yaml"
mkdir -p $OUT_DIR
wasm-pack build --release --target deno --out-dir $OUT_DIR --features "ansible-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-yaml"/' $OUT_DIR/package.json
rm $OUT_DIR/.gitignore
#-# C# (needs some more stuff to compile C tree sitter into wasm)
OUT_DIR="../../../cli/wasm/csharp"
mkdir -p $OUT_DIR
CFLAGS_wasm32_unknown_unknown="-I$(pwd)/wasm-sysroot -Wbad-function-cast -Wcast-function-type -fno-builtin" RUSTFLAGS="-Zwasm-c-abi=spec" wasm-pack build --release --target deno --out-dir $OUT_DIR --features "csharp-parser"
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-csharp"/' $OUT_DIR/package.json
rm $OUT_DIR/.gitignore
#-# Nu
OUT_DIR="../../../cli/wasm/nu"
mkdir -p $OUT_DIR
wasm-pack build --release --target deno --out-dir $OUT_DIR --features "nu-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-nu"/' $OUT_DIR/package.json
rm $OUT_DIR/.gitignore
@@ -1,56 +1,63 @@
#!/bin/bash
set -eou pipefail
# full pkg
#-# full pkg
OUT_DIR="pkg"
wasm-pack build --release --target web --out-dir $OUT_DIR --all-features \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
# bun and deno
#-# bun and deno
OUT_DIR="pkg-ts"
wasm-pack build --release --target web --out-dir $OUT_DIR --features "ts-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-ts"/' $OUT_DIR/package.json
# sql languages, graphql and bash/powershell, since they all use regex
#-# sql languages, graphql and bash/powershell, since they all use regex
OUT_DIR="pkg-regex"
wasm-pack build --release --target web --out-dir $OUT_DIR \
--features "sql-parser,graphql-parser,bash-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-regex"/' $OUT_DIR/package.json
# python
#-# python
OUT_DIR="pkg-py"
wasm-pack build --release --target web --out-dir $OUT_DIR --features "py-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-py"/' $OUT_DIR/package.json
# go
#-# go
OUT_DIR="pkg-go"
wasm-pack build --release --target web --out-dir $OUT_DIR --features "go-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-go"/' $OUT_DIR/package.json
# php
#-# php
OUT_DIR="pkg-php"
wasm-pack build --release --target web --out-dir $OUT_DIR --features "php-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-php"/' $OUT_DIR/package.json
# rust
#-# rust
OUT_DIR="pkg-rust"
wasm-pack build --release --target web --out-dir $OUT_DIR --features "rust-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-rust"/' $OUT_DIR/package.json
# ansible
#-# ansible
OUT_DIR="pkg-yaml"
wasm-pack build --release --target web --out-dir $OUT_DIR --features "ansible-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-yaml"/' $OUT_DIR/package.json
# C# (needs some more stuff to compile C tree sitter into wasm)
#-# C# (needs some more stuff to compile C tree sitter into wasm)
# TODO: hasn't been tested on mac, might need fixing
OUT_DIR="pkg-csharp"
CFLAGS_wasm32_unknown_unknown="-I$(pwd)/wasm-sysroot -Wbad-function-cast -Wcast-function-type -fno-builtin" RUSTFLAGS="-Zwasm-c-abi=spec" wasm-pack build --release --target web --out-dir $OUT_DIR --features "csharp-parser"
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-csharp"/' $OUT_DIR/package.json
#-# nu
# TODO: hasn't been tested on mac, might need fixing
OUT_DIR="pkg-nu"
wasm-pack build --release --target web --out-dir $OUT_DIR --features "nu-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-nu"/' $OUT_DIR/package.json
@@ -1,55 +1,62 @@
#!/bin/bash
#!/usr/bin/env bash
set -eou pipefail
# full pkg
#-# full pkg
OUT_DIR="pkg"
wasm-pack build --release --target web --out-dir $OUT_DIR --all-features \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
# bun and deno
#-# bun and deno
OUT_DIR="pkg-ts"
wasm-pack build --release --target web --out-dir $OUT_DIR --features "ts-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-ts"/' $OUT_DIR/package.json
# sql languages, graphql and bash/powershell, since they all use regex
#-# sql languages, graphql and bash/powershell, since they all use regex
OUT_DIR="pkg-regex"
wasm-pack build --release --target web --out-dir $OUT_DIR \
--features "sql-parser,graphql-parser,bash-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-regex"/' $OUT_DIR/package.json
# python
#-# python
OUT_DIR="pkg-py"
wasm-pack build --release --target web --out-dir $OUT_DIR --features "py-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-py"/' $OUT_DIR/package.json
# go
#-# go
OUT_DIR="pkg-go"
wasm-pack build --release --target web --out-dir $OUT_DIR --features "go-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-go"/' $OUT_DIR/package.json
# php
#-# php
OUT_DIR="pkg-php"
wasm-pack build --release --target web --out-dir $OUT_DIR --features "php-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-php"/' $OUT_DIR/package.json
# rust
#-# rust
OUT_DIR="pkg-rust"
wasm-pack build --release --target web --out-dir $OUT_DIR --features "rust-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-rust"/' $OUT_DIR/package.json
# ansible
#-# ansible
OUT_DIR="pkg-yaml"
wasm-pack build --release --target web --out-dir $OUT_DIR --features "ansible-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-yaml"/' $OUT_DIR/package.json
# C# (needs some more stuff to compile C tree sitter into wasm)
#-# C# (needs some more stuff to compile C tree sitter into wasm)
OUT_DIR="pkg-csharp"
CFLAGS_wasm32_unknown_unknown="-I$(pwd)/wasm-sysroot -Wbad-function-cast -Wcast-function-type -fno-builtin" RUSTFLAGS="-Zwasm-c-abi=spec" wasm-pack build --release --target web --out-dir $OUT_DIR --features "csharp-parser"
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-csharp"/' $OUT_DIR/package.json
#-# Nu
OUT_DIR="pkg-nu"
wasm-pack build --release --target web --out-dir $OUT_DIR --features "nu-parser" \
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-nu"/' $OUT_DIR/package.json
@@ -1,4 +1,8 @@
#!/bin/bash
#!/usr/bin/env bash
set -eou pipefail
deno task wasmbuild --out ../../../cli/wasm/ -p windmill-parser-wasm --all-features
# Flags are needed to build correctly with C#
# NOTE: Currently does not work with nix nor nixos
CFLAGS_wasm32_unknown_unknown="-I$(pwd)/wasm-sysroot -Wbad-function-cast -Wcast-function-type -fno-builtin" RUSTFLAGS="-Zwasm-c-abi=spec" deno task wasmbuild --inline --out ../../../cli/wasm/ -p windmill-parser-wasm --all-features
@@ -1,5 +1,5 @@
{
"tasks": {
"wasmbuild": "deno run -A jsr:@deno/wasmbuild@0.17.2"
"wasmbuild": "deno run -A jsr:@deno/wasmbuild@0.19.0"
}
}
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env nu
# Build in debug mode specified lang parser to wasm
# and perform installation to frontend
def "main" [
lang: string # Example: nu
--release(-r)
] {
let out_dir = $'pkg-($lang)'
if $release {
open build-pkgs.sh
| split row '#-'
| find $out_dir
| bash -c $"RUST_LOG=trace ($in.0)"
} else {
open build-pkgs.sh
| split row '#-'
| find $out_dir
| str replace "--release" "--no-opt"
| bash -c $"WASM_OPT=-Oz ($in.0)"
}
(
cd ../../../frontend; npm install ../backend/parsers/windmill-parser-wasm/($out_dir)
)
}
-95
View File
@@ -1,95 +0,0 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1737885589,
"narHash": "sha256-Zf0hSrtzaM1DEz8//+Xs51k/wdSajticVrATqDrfQjg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "852ff1d9e153d8875a83602e03fdef8a63f0ecf8",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1736320768,
"narHash": "sha256-nIYdTAiKIGnFNugbomgBJR+Xv5F1ZQU+HfaBqJKroC0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4bc9c909d9ac828a039f288cf872d16d38185db8",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1738117527,
"narHash": "sha256-GFviGfaezjGLFUlxdv3zyC7rSZvTXqwcG/YsF6MDkOw=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "6a3dc6ce4132bd57359214d986db376f2333c14d",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
@@ -1,37 +0,0 @@
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = {
nixpkgs,
flake-utils,
rust-overlay,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [(import rust-overlay)];
};
rust = pkgs.rust-bin.nightly.latest.default.override {
extensions = [
"rust-src"
];
targets = ["wasm32-unknown-unknown"];
};
in {
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
rust
nodejs
wasm-pack
sccache
];
RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
CARGO_PATH = "${rust}/bin/cargo";
};
});
}
@@ -27,3 +27,6 @@ popd
pushd "pkg-csharp" && npm publish ${args}
popd
pushd "pkg-nu" && npm publish ${args}
popd
@@ -149,3 +149,9 @@ pub fn parse_ansible(code: &str) -> String {
pub fn parse_csharp(code: &str) -> String {
wrap_sig(windmill_parser_csharp::parse_csharp_signature(code))
}
#[cfg(feature = "nu-parser")]
#[wasm_bindgen]
pub fn parse_nu(code: &str) -> String {
wrap_sig(windmill_parser_nu::parse_nu_signature(code))
}
+1 -1
View File
@@ -10,7 +10,7 @@ use convert_case::{Boundary, Case, Casing};
use serde::Serialize;
use serde_json::Value;
#[derive(Serialize, Debug, PartialEq)]
#[derive(Serialize, Debug, PartialEq, Default)]
pub struct MainArgSignature {
pub star_args: bool,
pub star_kwargs: bool,
+3 -2
View File
@@ -66,8 +66,8 @@ use windmill_common::global_settings::OBJECT_STORE_CACHE_CONFIG_SETTING;
use windmill_worker::{
get_hub_script_content_and_requirements, BUN_BUNDLE_CACHE_DIR, BUN_CACHE_DIR, CSHARP_CACHE_DIR,
DENO_CACHE_DIR, DENO_CACHE_DIR_DEPS, DENO_CACHE_DIR_NPM, GO_BIN_CACHE_DIR, GO_CACHE_DIR,
POWERSHELL_CACHE_DIR, PY310_CACHE_DIR, PY311_CACHE_DIR, PY312_CACHE_DIR, PY313_CACHE_DIR,
RUST_CACHE_DIR, TAR_PY310_CACHE_DIR, TAR_PY311_CACHE_DIR, TAR_PY312_CACHE_DIR,
NU_CACHE_DIR, POWERSHELL_CACHE_DIR, PY310_CACHE_DIR, PY311_CACHE_DIR, PY312_CACHE_DIR,
PY313_CACHE_DIR, RUST_CACHE_DIR, TAR_PY310_CACHE_DIR, TAR_PY311_CACHE_DIR, TAR_PY312_CACHE_DIR,
TAR_PY313_CACHE_DIR, UV_CACHE_DIR,
};
@@ -1080,6 +1080,7 @@ pub async fn run_workers(
GO_BIN_CACHE_DIR,
RUST_CACHE_DIR,
CSHARP_CACHE_DIR,
NU_CACHE_DIR,
HUB_CACHE_DIR,
POWERSHELL_CACHE_DIR,
] {
+103
View File
@@ -1886,6 +1886,109 @@ echo "hello $msg"
assert_eq!(job.json_result(), Some(json!("hello world")));
}
#[cfg(feature = "nu")]
#[sqlx::test(fixtures("base"))]
async fn test_nu_job(db: Pool<Postgres>) {
initialize_tracing().await;
let server = ApiServer::start(db.clone()).await;
let port = server.addr.port();
let content = r#"
def main [ msg: string ] {
"hello " + $msg
}
"#
.to_owned();
let job = RunJob::from(JobPayload::Code(RawCode {
hash: None,
content,
path: None,
lock: None,
language: ScriptLang::Nu,
custom_concurrency_key: None,
concurrent_limit: None,
concurrency_time_window_s: None,
cache_ttl: None,
dedicated_worker: None,
}))
.arg("msg", json!("world"))
.run_until_complete(&db, port)
.await;
assert_eq!(job.json_result(), Some(json!("hello world")));
}
#[cfg(feature = "nu")]
#[sqlx::test(fixtures("base"))]
async fn test_nu_job_full(db: Pool<Postgres>) {
initialize_tracing().await;
let server = ApiServer::start(db.clone()).await;
let port = server.addr.port();
let content = r#"
def main [
# Required
## Primitive
a
b: any
c: bool
d: float
e: datetime
f: string
j: nothing
## Nesting
g: record
h: list<string>
i: table
# Optional
m?
n = "foo"
o: any = "foo"
p?: any
# TODO: ...x
] {
0
}
"#
.to_owned();
let result = RunJob::from(JobPayload::Code(RawCode {
hash: None,
content,
path: None,
lock: None,
language: ScriptLang::Nu,
custom_concurrency_key: None,
concurrent_limit: None,
concurrency_time_window_s: None,
cache_ttl: None,
dedicated_worker: None,
}))
.arg("a", json!("3"))
.arg("b", json!("null"))
.arg("c", json!(true))
.arg("d", json!(3.0))
.arg("e", json!("2024-09-24T10:00:00.000Z"))
.arg("f", json!("str"))
.arg("j", json!(null))
.arg("g", json!({"a": 32}))
.arg("h", json!(["foo"]))
.arg(
"i",
json!([
{"a": 1, "b": "foo", "c": true},
{"a": 2, "b": "baz", "c": false}
]),
)
.arg("n", json!("baz"))
.run_until_complete(&db, port)
.await
.json_result()
.unwrap();
assert_eq!(result, serde_json::json!(0));
}
#[sqlx::test(fixtures("base"))]
async fn test_python_job(db: Pool<Postgres>) {
initialize_tracing().await;
+2 -1
View File
@@ -13380,7 +13380,8 @@ components:
php,
rust,
ansible,
csharp
csharp,
nu
]
Preview:
+1
View File
@@ -610,6 +610,7 @@ async fn create_script_internal<'c>(
|| ns.language == ScriptLang::Rust
|| ns.language == ScriptLang::Ansible
|| ns.language == ScriptLang::CSharp
|| ns.language == ScriptLang::Nu
|| ns.language == ScriptLang::Php)
{
Some(String::new())
@@ -376,6 +376,7 @@ pub(crate) async fn tarball_workspace(
ScriptLang::Rust => "rs",
ScriptLang::Ansible => "playbook.yml",
ScriptLang::CSharp => "cs",
ScriptLang::Nu => "nu",
ScriptLang::OracleDB => "odb.sql",
};
archive
@@ -40,7 +40,7 @@ pub const JWT_SECRET_SETTING: &str = "jwt_secret";
pub const EMAIL_DOMAIN_SETTING: &str = "email_domain";
pub const OTEL_SETTING: &str = "otel";
pub const ENV_SETTINGS: [&str; 58] = [
pub const ENV_SETTINGS: &[&str] = &[
"DISABLE_NSJAIL",
"MODE",
"NUM_WORKERS",
@@ -58,6 +58,7 @@ pub const ENV_SETTINGS: [&str; 58] = [
"S3_CACHE_BUCKET",
"COOKIE_DOMAIN",
"PYTHON_PATH",
"NU_PATH",
"DENO_PATH",
"GO_PATH",
"GOPRIVATE",
+1 -1
View File
@@ -364,6 +364,7 @@ pub fn should_validate_schema(code: &str, lang: &ScriptLang) -> bool {
ScriptLang::Rust => find_annotation("//!", annotation, code),
ScriptLang::Ansible => find_annotation("#", annotation, code),
ScriptLang::CSharp => find_annotation("//", annotation, code),
ScriptLang::Nu => find_annotation("#", annotation, code),
}
}
@@ -650,4 +651,3 @@ mod tests {
.expect("Validation should work for this");
}
}
+2
View File
@@ -50,6 +50,7 @@ pub enum ScriptLang {
Rust,
Ansible,
CSharp,
Nu,
}
impl ScriptLang {
@@ -74,6 +75,7 @@ impl ScriptLang {
ScriptLang::Rust => "rust",
ScriptLang::Ansible => "ansible",
ScriptLang::CSharp => "csharp",
ScriptLang::Nu => "nu",
}
}
}
+1
View File
@@ -50,6 +50,7 @@ lazy_static::lazy_static! {
"rust".to_string(),
"ansible".to_string(),
"csharp".to_string(),
"nu".to_string(),
"dependency".to_string(),
"flow".to_string(),
"other".to_string()
+2
View File
@@ -29,6 +29,7 @@ oracledb = ["dep:oracle"]
python = ["dep:windmill-parser-py", "dep:windmill-parser-py-imports"]
csharp = ["dep:windmill-parser-csharp"]
rust = ["dep:windmill-parser-rust"]
nu = ["dep:windmill-parser-nu"]
[dependencies]
windmill-queue.workspace = true
@@ -39,6 +40,7 @@ windmill-parser-ts.workspace = true
windmill-parser-go.workspace = true
windmill-parser-rust = { workspace = true, optional = true }
windmill-parser-csharp = { workspace = true, optional = true }
windmill-parser-nu = { workspace = true, optional = true }
windmill-parser-py = { workspace = true, optional = true }
windmill-parser-yaml.workspace = true
windmill-parser-py-imports = { workspace = true, optional = true }
@@ -0,0 +1,106 @@
name: "nu run script"
mode: ONCE
hostname: "nu"
log_level: ERROR
disable_rl: true
cwd: "/tmp"
clone_newnet: false
clone_newuser: {CLONE_NEWUSER}
keep_caps: false
keep_env: true
mount_proc: true
mount {
src: "/bin"
dst: "/bin"
is_bind: true
}
mount {
src: "/lib"
dst: "/lib"
is_bind: true
}
mount {
src: "/lib64"
dst: "/lib64"
is_bind: true
mandatory: false
}
mount {
src: "/usr"
dst: "/usr"
is_bind: true
}
mount {
src: "/dev/null"
dst: "/dev/null"
is_bind: true
rw: true
}
mount {
dst: "/tmp"
fstype: "tmpfs"
rw: true
options: "size=800000000"
}
mount {
src: "{NU_PATH}"
dst: "{NU_PATH}"
is_bind: true
}
mount {
src: "{JOB_DIR}/main.nu"
dst: "/tmp/main.nu"
is_bind: true
}
mount {
src: "{JOB_DIR}/result.json"
dst: "/tmp/result.json"
rw: true
is_bind: true
}
mount {
src: "{JOB_DIR}/args.json"
dst: "/tmp/args.json"
rw: true
is_bind: true
}
mount {
src: "/etc"
dst: "/etc"
is_bind: true
}
mount {
src: "/dev/random"
dst: "/dev/random"
is_bind: true
}
mount {
src: "/dev/urandom"
dst: "/dev/urandom"
is_bind: true
}
iface_no_lo: true
{SHARED_MOUNT}
envar: "HOME=/tmp"
+2
View File
@@ -9,6 +9,8 @@ mod snowflake_executor;
mod ansible_executor;
mod bash_executor;
#[cfg(feature = "nu")]
mod nu_executor;
#[cfg(feature = "benchmark")]
pub mod bench;
mod bun_executor;
+356
View File
@@ -0,0 +1,356 @@
use std::{collections::HashMap, process::Stdio};
use itertools::Itertools;
use serde_json::value::RawValue;
use tokio::{fs::File, io::AsyncWriteExt, process::Command};
use windmill_common::{error::Error, worker::write_file};
use windmill_parser::Arg;
use windmill_parser_nu::parse_nu_signature;
use windmill_queue::{append_logs, CanceledBy, MiniPulledJob};
use crate::{
common::{
create_args_and_out_file, get_reserved_variables, read_result, start_child_process,
OccupancyMetrics,
},
handle_child, AuthedClientBackgroundTask, DISABLE_NSJAIL, DISABLE_NUSER, NSJAIL_PATH, PATH_ENV,
PROXY_ENVS,
};
const NSJAIL_CONFIG_RUN_NU_CONTENT: &str = include_str!("../nsjail/run.nu.config.proto");
lazy_static::lazy_static! {
static ref NU_PATH: String = std::env::var("NU_PATH").unwrap_or_else(|_| "/usr/bin/nu".to_string());
// TODO(v1):
// static ref PLUGIN_USE_RE: Regex = Regex::new(r#"(?:plugin use )(?<plugin>.*)"#).unwrap();
}
// TODO: Can be generalized and used for other handlers
#[allow(dead_code)]
pub(crate) struct JobHandlerInput<'a> {
pub base_internal_url: &'a str,
pub canceled_by: &'a mut Option<CanceledBy>,
pub client: &'a AuthedClientBackgroundTask,
pub db: &'a sqlx::Pool<sqlx::Postgres>,
pub envs: HashMap<String, String>,
pub inner_content: &'a str,
pub job: &'a MiniPulledJob,
pub job_dir: &'a str,
pub mem_peak: &'a mut i32,
pub occupancy_metrics: &'a mut OccupancyMetrics,
pub requirements_o: Option<&'a String>,
pub shared_mount: &'a str,
pub worker_name: &'a str,
}
pub async fn handle_nu_job<'a>(mut args: JobHandlerInput<'a>) -> Result<Box<RawValue>, Error> {
// TODO(v1):
// --- Handle plugins ---
// let plugins = get_plugins(&mut args).await?;
// TODO(v1):
// --- Handle imports ---
// TODO(v1):
// --- Handle relative ---
// --- Wrap and write to fs ---
{
create_args_and_out_file(&args.client, args.job, args.job_dir, args.db).await?;
File::create(format!("{}/main.nu", args.job_dir))
.await?
.write_all(&wrap(args.inner_content)?.into_bytes())
.await?;
}
// --- Execute ---
{
run(&mut args).await?;
}
// --- Retrieve results ---
{
read_result(&args.job_dir).await
}
}
// async fn get_plugins<'a>(
// JobHandlerInput {
// occupancy_metrics,
// mem_peak,
// canceled_by,
// worker_name,
// job,
// db,
// inner_content,
// ..
// }: &mut JobHandlerInput<'a>,
// ) -> Result<Vec<&'a str>, Error> {
// let plugins_dir = concatcp!(NU_CACHE_DIR, "/plugins");
// let nu_version = from_utf8_mut(
// Command::new(NU_PATH.as_str())
// .arg("--version")
// .output()
// .await?
// .stdout
// .as_mut_slice(),
// )
// .map_err(|e| windmill_common::error::Error::ExecutionErr(e.to_string()))?
// .to_owned();
// let plugins = parse_plugin_use(inner_content);
// for plugin in &plugins {
// let mut run_cmd = Command::new(CARGO_PATH.as_str());
// // cargo install nu_plugin_query --version (nu --version); plugin add ~/.cargo/bin/nu_plugin_query
// run_cmd
// // TODO: make it work with env_clear
// // .env_clear()
// .args(&[
// "install",
// "--root",
// plugins_dir,
// "--locked",
// &format!("nu_plugin_{plugin}"),
// "--version",
// &nu_version,
// ])
// .stdout(Stdio::piped())
// .stderr(Stdio::piped());
// #[cfg(windows)]
// nsjail_cmd.env("SystemRoot", SYSTEM_ROOT.as_str());
// let child = start_child_process(run_cmd, "cargo").await?;
// // handle_child::handle_child(
// // &job.id,
// // db,
// // mem_peak,
// // canceled_by,
// // child,
// // !*DISABLE_NSJAIL,
// // worker_name,
// // &job.workspace_id,
// // "cargo",
// // job.timeout,
// // false,
// // &mut Some(occupancy_metrics),
// // )
// // .await?;
// }
// Ok(plugins)
// }
// fn parse_plugin_use(inner_content: &str) -> Vec<&str> {
// let mut plugins = vec![];
// // TODO: Ignore plugins with # in the beginning
// for cap in PLUGIN_USE_RE.captures_iter(inner_content).into_iter() {
// if let Some(mat) = cap.name("plugin") {
// plugins.push(mat.as_str());
// }
// }
// plugins
// }
/// Wraps content script
/// that upon execution reads args.json (which are piped and transformed from previous flow step or top level inputs)
/// Also wrapper takes output of program and serializes to result.json (Which windmill will know how to use later)
fn wrap(inner_content: &str) -> Result<String, Error> {
let sig = parse_nu_signature(inner_content)?;
let spread = sig
.args
.clone()
.into_iter()
.map(|Arg { name, typ, has_default, .. }| {
// Apply additional input transformation
let transformation = format!(
"| if $in != null {{ {} }} else {{ $in }}",
match typ {
// JSON converts X.0 to X and nu can't coerce type automatically
windmill_parser::Typ::Datetime => "into datetime",
windmill_parser::Typ::Bytes => "into binary",
windmill_parser::Typ::Float => "into float",
// Ident
_ => "$in",
}
);
let nullguard = if has_default || matches!(typ, windmill_parser::Typ::Unknown) {
"".to_owned()
} else {
format!("| nullguard {name}")
};
format!("\n\t\t\t($parsed_args.{name}? {nullguard} {transformation}) ",)
})
.collect_vec()
.join(" ");
Ok(
r#"
$env.config.table.mode = 'basic'
def nullguard [ name: string ] {
if ($in == null) {
panic $"argument `($name)` of main function can't be null"
}
$in
}
# TODO: Probably needs rework in order for LSP to work
def get_variable [ pat ] {
let addr = $"($env.BASE_INTERNAL_URL)/api/w/($env.WM_WORKSPACE)/variables/get_value/($pat)" ;
http get -H ["Authorization", $"Bearer ($env.WM_TOKEN)"] $addr | return $in
}
def get_resource [ pat ] {
let addr = $"($env.BASE_INTERNAL_URL)/api/w/($env.WM_WORKSPACE)/resources/get_value_interpolated/($pat)" ;
http get -H ["Authorization", $"Bearer ($env.WM_TOKEN)"] $addr | return $in
}
def 'main --wrapped' [] {
let parsed_args = open args.json
(main SPREAD
) | to json | save -f result.json
}
INNER_CONTENT
"#
.replace("INNER_CONTENT", inner_content)
.replace("SPREAD", &spread), // .replace("TRANSFORM", transform)
)
}
async fn run<'a>(
JobHandlerInput {
occupancy_metrics,
mem_peak,
canceled_by,
worker_name,
job,
db,
job_dir,
shared_mount,
client,
envs,
base_internal_url,
..
}: &mut JobHandlerInput<'a>,
// plugins: Vec<&'a str>,
) -> Result<(), Error> {
let client = &client.get_authed().await;
let reserved_variables = get_reserved_variables(job, &client.token, db).await?;
let child = if !cfg!(windows) && !*DISABLE_NSJAIL {
append_logs(
&job.id,
&job.workspace_id,
format!("\n\n--- ISOLATED NU CODE EXECUTION ---\n"),
db.clone(),
)
.await;
write_file(
job_dir,
"run.config.proto",
&NSJAIL_CONFIG_RUN_NU_CONTENT
.replace("{JOB_DIR}", job_dir)
.replace("{NU_PATH}", &NU_PATH)
.replace("{SHARED_MOUNT}", &shared_mount)
.replace("{CLONE_NEWUSER}", &(!*DISABLE_NUSER).to_string()),
)?;
let mut nsjail_cmd = Command::new(NSJAIL_PATH.as_str());
nsjail_cmd
.env_clear()
.current_dir(job_dir)
.env("PATH", PATH_ENV.as_str())
.env("BASE_INTERNAL_URL", base_internal_url)
.envs(envs)
.envs(reserved_variables)
.envs(PROXY_ENVS.clone())
.args(vec![
"--config",
"run.config.proto",
"--",
NU_PATH.as_str(),
"/tmp/main.nu",
"--wrapped",
])
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str()).await?
} else {
append_logs(
&job.id,
&job.workspace_id,
format!("\n\n--- NU CODE EXECUTION ---\n"),
db.clone(),
)
.await;
// let plugin_registry = format!("{job_dir}/plugin-registry");
// File::create(&plugin_registry).await?;
//
let mut cmd = Command::new(if cfg!(windows) {
"nu"
} else {
NU_PATH.as_str()
});
cmd.env_clear()
.current_dir(job_dir.to_owned())
.env("PATH", PATH_ENV.as_str())
.env("BASE_INTERNAL_URL", base_internal_url)
.envs(envs)
.envs(reserved_variables)
.envs(PROXY_ENVS.clone())
.args(&[
"main.nu",
"--wrapped",
// TODO(v1):
// "--plugins",
// &format!(
// "[{}]",
// plugins
// .into_iter()
// .map(|pl| format!("{NU_CACHE_DIR}/plugins/bin/nu_plugin_{pl}"))
// .collect_vec()
// .join(",")
// ),
])
.stdout(Stdio::piped())
.stderr(Stdio::piped());
#[cfg(windows)]
{
cmd.env("SystemRoot", crate::SYSTEM_ROOT.as_str())
.env("USERPROFILE", crate::USERPROFILE_ENV.as_str())
.env(
"TMP",
std::env::var("TMP").unwrap_or_else(|_| String::from("/tmp")),
);
}
start_child_process(cmd, "nu").await?
};
handle_child::handle_child(
&job.id,
db,
mem_peak,
canceled_by,
child,
!*DISABLE_NSJAIL,
worker_name,
&job.workspace_id,
"nu",
job.timeout,
false,
&mut Some(occupancy_metrics),
)
.await
}
// #[cfg(test)]
// mod test {
// use super::parse_plugin_use;
// #[test]
// fn test_nu_plugin_use() {
// let content = r#"
// plugin use foo
// plugin use bar
// plugin use baz
// plugin use meh
// "#;
// assert_eq!(
// vec!["foo", "bar", "baz", "meh"], //
// parse_plugin_use(content)
// );
// }
// }
+32
View File
@@ -122,6 +122,9 @@ use crate::{
#[cfg(feature = "rust")]
use crate::rust_executor::handle_rust_job;
#[cfg(feature = "nu")]
use crate::nu_executor::{handle_nu_job, JobHandlerInput};
#[cfg(feature = "php")]
use crate::php_executor::handle_php_job;
@@ -275,6 +278,7 @@ pub const DENO_CACHE_DIR_NPM: &str = concatcp!(ROOT_CACHE_DIR, "deno/npm");
pub const GO_CACHE_DIR: &str = concatcp!(ROOT_CACHE_DIR, "go");
pub const RUST_CACHE_DIR: &str = concatcp!(ROOT_CACHE_DIR, "rust");
pub const NU_CACHE_DIR: &str = concatcp!(ROOT_CACHE_DIR, "nu");
pub const CSHARP_CACHE_DIR: &str = concatcp!(ROOT_CACHE_DIR, "csharp");
pub const BUN_CACHE_DIR: &str = concatcp!(ROOT_CACHE_NOMOUNT_DIR, "bun");
pub const BUN_BUNDLE_CACHE_DIR: &str = concatcp!(ROOT_CACHE_DIR, "bun");
@@ -3026,6 +3030,30 @@ mount {{
)
.await
}
Some(ScriptLang::Nu) => {
#[cfg(not(feature = "nu"))]
return Err(
anyhow::anyhow!("Nu is not available because the feature is not enabled").into(),
);
#[cfg(feature = "nu")]
handle_nu_job(JobHandlerInput {
mem_peak,
canceled_by,
job,
db,
client,
inner_content: &code,
job_dir,
requirements_o: lock.as_ref(),
shared_mount: &shared_mount,
base_internal_url,
worker_name,
envs,
occupancy_metrics,
})
.await
}
_ => panic!("unreachable, language is not supported: {language:#?}"),
};
tracing::info!(
@@ -3089,6 +3117,10 @@ fn parse_sig_of_lang(
ScriptLang::CSharp => Some(windmill_parser_csharp::parse_csharp_signature(code)?),
#[cfg(not(feature = "csharp"))]
ScriptLang::CSharp => None,
#[cfg(feature = "nu")]
ScriptLang::Nu => Some(windmill_parser_nu::parse_nu_signature(code)?),
#[cfg(not(feature = "nu"))]
ScriptLang::Nu => None,
}
} else {
None
@@ -2050,6 +2050,7 @@ async fn capture_dependency_job(
ScriptLang::Graphql => Ok("".to_owned()),
ScriptLang::OracleDB => Ok("".to_owned()),
ScriptLang::Bash => Ok("".to_owned()),
ScriptLang::Nu => Ok("".to_owned()),
ScriptLang::Powershell => Ok("".to_owned()),
ScriptLang::Nativets => Ok("".to_owned()),
}
+5
View File
@@ -94,6 +94,11 @@ function main() {
}
}
`,
nu: `
def main [] {
print "Hello World"
}
`,
rust: `fn main() -> Result<(), String> {
println!("Hello World");
+1 -1
View File
@@ -15,4 +15,4 @@
"@std/yaml": "jsr:@std/yaml@^1.0.5",
"@types/diff": "npm:@types/diff@^5.2.2"
}
}
}
Generated
+2183 -2307
View File
File diff suppressed because it is too large Load Diff
+27 -5
View File
@@ -13,9 +13,18 @@ await build({
},
],
outDir: "./npm",
shims: {
shims: {
// see JS docs for overview and more options
deno: true,
// shims to only use in the tests
customDev: [{
// this is what `timers: "dev"` does internally
package: {
name: "@deno/shim-timers",
version: "~0.1.0",
},
globalNames: ["setTimeout", "setInterval"],
}],
},
scriptModule: false,
filterDiagnostic(diagnostic) {
@@ -50,12 +59,25 @@ await build({
postBuild() {
// steps to run after building and before running the tests
// add shebang to npm/esm/main.js
const dirs = [
"nu",
"ts",
"regex",
"python",
"go",
"php",
"rust",
"yaml",
"csharp",
];
for (const l of dirs) {
Deno.copyFileSync(
"wasm/" + l + "/windmill_parser_wasm_bg.wasm",
"npm/esm/wasm/" + l + "/windmill_parser_wasm_bg.wasm"
);
}
Deno.copyFileSync("../LICENSE", "npm/LICENSE");
Deno.copyFileSync("README.md", "npm/README.md");
Deno.copyFileSync(
"wasm/windmill_parser_wasm_bg.wasm",
"npm/esm/wasm/windmill_parser_wasm_bg.wasm"
);
},
});
+1 -1
View File
@@ -54,7 +54,7 @@ export const OpenAPI: OpenAPIConfig = {
PASSWORD: undefined,
TOKEN: getEnv("WM_TOKEN"),
USERNAME: undefined,
VERSION: '1.476.0',
VERSION: '1.477.1',
WITH_CREDENTIALS: true,
interceptors: {
request: new Interceptors(),
File diff suppressed because one or more lines are too long
+53 -2
View File
@@ -169,6 +169,7 @@ export type QueuedJob = {
aggregate_wait_time_ms?: number;
suspend?: number;
preprocessed?: boolean;
worker?: string;
};
export type job_kind = 'script' | 'preview' | 'dependencies' | 'flowdependencies' | 'appdependencies' | 'flow' | 'flowpreview' | 'script_hub' | 'identity' | 'deploymentcallback' | 'singlescriptflow' | 'flowscript' | 'flownode' | 'appscript';
@@ -214,6 +215,7 @@ export type CompletedJob = {
self_wait_time_ms?: number;
aggregate_wait_time_ms?: number;
preprocessed?: boolean;
worker?: string;
};
export type ObscuredJob = {
@@ -374,7 +376,7 @@ export type MainArgSignature = {
export type type2 = 'Valid' | 'Invalid';
export type ScriptLang = 'python3' | 'deno' | 'go' | 'bash' | 'powershell' | 'postgresql' | 'mysql' | 'bigquery' | 'snowflake' | 'mssql' | 'oracledb' | 'graphql' | 'nativets' | 'bun' | 'php' | 'rust' | 'ansible' | 'csharp';
export type ScriptLang = 'python3' | 'deno' | 'go' | 'bash' | 'powershell' | 'postgresql' | 'mysql' | 'bigquery' | 'snowflake' | 'mssql' | 'oracledb' | 'graphql' | 'nativets' | 'bun' | 'php' | 'rust' | 'ansible' | 'csharp' | 'nu';
export type Preview = {
content?: string;
@@ -578,7 +580,9 @@ export type HttpTrigger = TriggerExtraProperty & {
is_async: boolean;
requires_auth: boolean;
is_static_website: boolean;
workspaced_route?: boolean;
workspaced_route: boolean;
wrap_body: boolean;
raw_string: boolean;
};
export type http_method = 'get' | 'post' | 'put' | 'delete' | 'patch';
@@ -598,6 +602,8 @@ export type NewHttpTrigger = {
is_async: boolean;
requires_auth: boolean;
is_static_website: boolean;
wrap_body?: boolean;
raw_string?: boolean;
};
export type EditHttpTrigger = {
@@ -615,6 +621,8 @@ export type EditHttpTrigger = {
is_async: boolean;
requires_auth: boolean;
is_static_website: boolean;
wrap_body?: boolean;
raw_string?: boolean;
};
export type TriggersCount = {
@@ -1720,6 +1728,11 @@ export type ParameterCreatedBy = string;
*/
export type ParameterLabel = string;
/**
* worker this job was ran on
*/
export type ParameterWorker = string;
/**
* The parent job that is at the origin and responsible for the execution of this script if any
*/
@@ -3773,6 +3786,10 @@ export type DeleteScriptByHashData = {
export type DeleteScriptByHashResponse = (Script);
export type DeleteScriptByPathData = {
/**
* keep captures
*/
keepCaptures?: boolean;
path: string;
workspace: string;
};
@@ -4312,6 +4329,10 @@ export type ArchiveFlowByPathData = {
export type ArchiveFlowByPathResponse = (string);
export type DeleteFlowByPathData = {
/**
* keep captures
*/
keepCaptures?: boolean;
path: string;
workspace: string;
};
@@ -4961,6 +4982,10 @@ export type ListQueueData = {
* filter on jobs with a given tag/worker group
*/
tag?: string;
/**
* worker this job was ran on
*/
worker?: string;
workspace: string;
};
@@ -5183,6 +5208,10 @@ export type ListCompletedJobsData = {
* filter on jobs with a given tag/worker group
*/
tag?: string;
/**
* worker this job was ran on
*/
worker?: string;
workspace: string;
};
@@ -5305,6 +5334,10 @@ export type ListJobsData = {
* filter on jobs with a given tag/worker group
*/
tag?: string;
/**
* worker this job was ran on
*/
worker?: string;
workspace: string;
};
@@ -6878,6 +6911,20 @@ export type ListCapturesData = {
export type ListCapturesResponse = (Array<Capture>);
export type MoveCapturesAndConfigsData = {
path: string;
/**
* move captures and configs to a new path
*/
requestBody: {
new_path?: string;
};
runnableKind: 'script' | 'flow';
workspace: string;
};
export type MoveCapturesAndConfigsResponse = (string);
export type GetCaptureData = {
id: number;
workspace: string;
@@ -6913,6 +6960,10 @@ export type UnstarData = {
export type UnstarResponse = (unknown);
export type GetInputHistoryData = {
/**
* filter on jobs containing those args as a json subset (@> in postgres)
*/
args?: string;
includePreview?: boolean;
/**
* which page to return (start at 1, default 1)
+29 -24
View File
@@ -12,25 +12,8 @@ import {
ScriptMetadata,
defaultScriptMetadata,
} from "./bootstrap/script_bootstrap.ts";
import {
instantiate as instantiateWasm,
parse_ansible,
parse_bash,
parse_bigquery,
parse_deno,
parse_go,
parse_graphql,
parse_mssql,
parse_mysql,
parse_php,
parse_powershell,
parse_python,
parse_rust,
parse_csharp,
parse_snowflake,
parse_sql,
parse_oracledb,
} from "./wasm/windmill_parser_wasm.generated.js";
import { Workspace } from "./workspace.ts";
import { SchemaProperty } from "./bootstrap/common.ts";
import { ScriptLanguage } from "./script_common.ts";
@@ -312,8 +295,7 @@ export async function updateScriptSchema(
path: string
): Promise<void> {
// infer schema from script content and update it inplace
await instantiateWasm();
const result = inferSchema(
const result = await inferSchema(
language,
scriptContent,
metadataContent.schema,
@@ -471,80 +453,102 @@ export async function updateFlow(
////////////////////////////////////////////////////////////////////////////////////////////
// below functions copied from Windmill's FE inferArgs function. TODO: refactor //
////////////////////////////////////////////////////////////////////////////////////////////
export function inferSchema(
export async function inferSchema(
language: ScriptLanguage,
content: string,
currentSchema: any,
path: string
): {
): Promise<{
schema: any;
has_preprocessor: boolean | undefined;
no_main_func: boolean | undefined;
} {
}> {
let inferedSchema: any;
if (language === "python3") {
const { parse_python } = await import('./wasm/python/windmill_parser_wasm.js')
inferedSchema = JSON.parse(parse_python(content));
} else if (language === "nativets") {
const { parse_deno } = await import('./wasm/ts/windmill_parser_wasm.js')
inferedSchema = JSON.parse(parse_deno(content));
} else if (language === "bun") {
const { parse_deno } = await import('./wasm/ts/windmill_parser_wasm.js')
inferedSchema = JSON.parse(parse_deno(content));
} else if (language === "deno") {
const { parse_deno } = await import('./wasm/ts/windmill_parser_wasm.js')
inferedSchema = JSON.parse(parse_deno(content));
} else if (language === "go") {
const { parse_go } = await import("./wasm/go/windmill_parser_wasm.js");
inferedSchema = JSON.parse(parse_go(content));
} else if (language === "mysql") {
const { parse_mysql } = await import("./wasm/regex/windmill_parser_wasm.js");
inferedSchema = JSON.parse(parse_mysql(content));
inferedSchema.args = [
{ name: "database", typ: { resource: "mysql" } },
...inferedSchema.args,
];
} else if (language === "bigquery") {
const { parse_bigquery } = await import("./wasm/regex/windmill_parser_wasm.js");
inferedSchema = JSON.parse(parse_bigquery(content));
inferedSchema.args = [
{ name: "database", typ: { resource: "bigquery" } },
...inferedSchema.args,
];
} else if (language === "oracledb") {
const { parse_oracledb } = await import("./wasm/regex/windmill_parser_wasm.js");
inferedSchema = JSON.parse(parse_oracledb(content));
inferedSchema.args = [
{ name: "database", typ: { resource: "oracledb" } },
...inferedSchema.args,
];
} else if (language === "snowflake") {
const { parse_snowflake } = await import("./wasm/regex/windmill_parser_wasm.js");
inferedSchema = JSON.parse(parse_snowflake(content));
inferedSchema.args = [
{ name: "database", typ: { resource: "snowflake" } },
...inferedSchema.args,
];
} else if (language === "mssql") {
const { parse_mssql } = await import("./wasm/regex/windmill_parser_wasm.js");
inferedSchema = JSON.parse(parse_mssql(content));
inferedSchema.args = [
{ name: "database", typ: { resource: "ms_sql_server" } },
...inferedSchema.args,
];
} else if (language === "postgresql") {
const { parse_sql } = await import("./wasm/regex/windmill_parser_wasm.js");
inferedSchema = JSON.parse(parse_sql(content));
inferedSchema.args = [
{ name: "database", typ: { resource: "postgresql" } },
...inferedSchema.args,
];
} else if (language === "graphql") {
const { parse_graphql } = await import("./wasm/regex/windmill_parser_wasm.js");
inferedSchema = JSON.parse(parse_graphql(content));
inferedSchema.args = [
{ name: "api", typ: { resource: "graphql" } },
...inferedSchema.args,
];
} else if (language === "bash") {
const { parse_bash } = await import("./wasm/regex/windmill_parser_wasm.js");
inferedSchema = JSON.parse(parse_bash(content));
} else if (language === "powershell") {
const { parse_powershell } = await import("./wasm/regex/windmill_parser_wasm.js");
inferedSchema = JSON.parse(parse_powershell(content));
} else if (language === "php") {
const { parse_php } = await import("./wasm/php/windmill_parser_wasm.js");
inferedSchema = JSON.parse(parse_php(content));
} else if (language === "rust") {
const { parse_rust } = await import("./wasm/rust/windmill_parser_wasm.js");
inferedSchema = JSON.parse(parse_rust(content));
} else if (language === "csharp") {
const { parse_csharp } = await import("./wasm/csharp/windmill_parser_wasm.js");
inferedSchema = JSON.parse(parse_csharp(content));
} else if (language === "nu") {
const { parse_nu } = await import("./wasm/nu/windmill_parser_wasm.js");
inferedSchema = JSON.parse(parse_nu(content));
} else if (language === "ansible") {
const { parse_ansible } = await import("./wasm/yaml/windmill_parser_wasm.js");
inferedSchema = JSON.parse(parse_ansible(content));
} else {
throw new Error("Invalid language: " + language);
@@ -588,6 +592,7 @@ export function inferSchema(
}
}
return {
schema: currentSchema,
has_preprocessor: inferedSchema.has_preprocessor,
+3
View File
@@ -567,6 +567,8 @@ export function filePathExtensionFromContentType(
return ".playbook.yml";
} else if (language === "csharp") {
return ".cs";
} else if (language === "nu") {
return ".nu";
} else {
throw new Error("Invalid language: " + language);
}
@@ -592,6 +594,7 @@ export const exts = [
".php",
".rs",
".cs",
".nu",
".playbook.yml",
];
+3
View File
@@ -16,6 +16,7 @@ export type ScriptLanguage =
| "php"
| "rust"
| "csharp"
| "nu"
| "ansible";
export function inferContentTypeFromFilePath(
@@ -60,6 +61,8 @@ export function inferContentTypeFromFilePath(
return "csharp";
} else if (contentPath.endsWith(".playbook.yml")) {
return "ansible";
} else if (contentPath.endsWith(".nu")) {
return "nu";
} else {
throw new Error(
"Invalid language: " + contentPath.substring(contentPath.lastIndexOf("."))
+2
View File
@@ -340,6 +340,7 @@ export function newPathAssigner(defaultTs: "bun" | "deno"): PathAssigner {
else if (language == "php") ext = "php";
else if (language == "rust") ext = "rs";
else if (language == "csharp") ext = "cs";
else if (language == "nu") ext = "nu";
else if (language == "ansible") ext = "playbook.yml";
else ext = "no_ext";
@@ -687,6 +688,7 @@ export async function elementsToMap(
"rs",
"cs",
"yml",
"nu",
].includes(path.split(".").pop() ?? "") &&
!isFileResource(path)
)
Executable
+88
View File
@@ -0,0 +1,88 @@
#!/usr/bin/env nu
# NOTE: Not polished yet
# This script supposed to test wasm parsers in cli
# Currently you would need to create local dir in repo root (it is ignored by git)
# In there init windmill workspace
#
# Start instance with languages features on
# Invoke this script from local: ../cli/test.nu test deno
const languages = [
"python3",
"nativets",
"bun",
"deno",
"go",
"mysql",
"bigquery",
"oracledb",
"snowflake",
"mssql",
"postgresql",
"graphql",
"bash",
"powershell",
# "php",
"rust",
"csharp",
"nu",
"ansible",
];
def main [] {
main test deno;
main build;
main test node;
}
def 'main test deno' [] {
main clean;
$languages | each { |l|
print $"+ ($l)"
deno run -A ../cli/main.ts script bootstrap $"f/tests/(random uuid)" $l
}
deno run -A ../cli/main.ts script generate-metadata
}
def 'main test node' [] {
# TODO: Use node
main clean;
$languages | each { |l|
print $"+ ($l)"
node ../cli/npm/esm/main.js script bootstrap $"f/tests/(random uuid)" $l
}
node ../cli/npm/esm/main.js script generate-metadata
}
def 'main clean' [] {
rm -rf f/tests/*
}
def 'main build' [] {
../cli/build.sh
}
# def main [] {
# main clean;
# $languages | each { |l|
# print $"+ ($l)"
# # deno run -A ../cli/main.ts script bootstrap $"f/tests/(random uuid)" $l
# #
# let cmd = r#'
# import { inferSchema } from '../cli/metadata.ts';
# await inferSchema("LANG", "", undefined, "f/tests/NAME)")
# '#
# | str replace "LANG" $l
# | str replace "NAME" (random uuid);
# deno eval $cmd
# }
# # deno run -A ../cli/main.ts script generate-metadata
# }
# def 'main clean' [] {
# rm -rf f/tests/*
# }
+1
View File
@@ -226,6 +226,7 @@ export function getTypeStrFromPath(
parsed.ext == ".php" ||
parsed.ext == ".rs" ||
parsed.ext == ".cs" ||
parsed.ext == ".nu" ||
(parsed.ext == ".yml" && parsed.name.split(".").pop() == "playbook")
) {
return "script";
+3
View File
@@ -0,0 +1,3 @@
/* tslint:disable */
/* eslint-disable */
export function parse_csharp(code: string): string;
+121
View File
@@ -0,0 +1,121 @@
let WASM_VECTOR_LEN = 0;
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
const encodeString = function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
};
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8ArrayMemory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_csharp(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_csharp(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
const imports = {
__wbindgen_placeholder__: {
__wbindgen_init_externref_table: function() {
const table = wasm.__wbindgen_export_0;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
},
},
};
const wasm_url = new URL('windmill_parser_wasm_bg.wasm', import.meta.url);
let wasmCode = '';
switch (wasm_url.protocol) {
case 'file:':
wasmCode = await Deno.readFile(wasm_url);
break
case 'https:':
case 'http:':
wasmCode = await (await fetch(wasm_url)).arrayBuffer();
break
default:
throw new Error(`Unsupported protocol: ${wasm_url.protocol}`);
}
const wasmInstance = (await WebAssembly.instantiate(wasmCode, imports)).instance;
const wasm = wasmInstance.exports;
export const __wasm = wasm;
wasm.__wbindgen_start();
Binary file not shown.
+29
View File
@@ -0,0 +1,29 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export const parse_csharp: (a: number, b: number) => [number, number];
export const abort: () => void;
export const malloc: (a: number) => number;
export const calloc: (a: number, b: number) => number;
export const realloc: (a: number, b: number) => number;
export const free: (a: number) => void;
export const strncmp: (a: number, b: number, c: number) => number;
export const iswspace: (a: number) => number;
export const iswalnum: (a: number) => number;
export const clock: () => bigint;
export const isprint: (a: number) => number;
export const fprintf: (a: number, b: number, c: number) => number;
export const fputs: (a: number, b: number) => number;
export const fputc: (a: number, b: number) => number;
export const fdopen: (a: number, b: number) => number;
export const fclose: (a: number) => number;
export const fwrite: (a: number, b: number, c: number, d: number) => number;
export const vsnprintf: (a: number, b: number, c: number, d: number) => number;
export const clock_gettime: (a: number, b: number) => void;
export const snprintf: () => void;
export const __assert_fail: (a: number, b: number, c: number, d: number) => void;
export const __wbindgen_export_0: WebAssembly.Table;
export const __wbindgen_malloc: (a: number, b: number) => number;
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
export const __wbindgen_free: (a: number, b: number, c: number) => void;
export const __wbindgen_start: () => void;
+3
View File
@@ -0,0 +1,3 @@
/* tslint:disable */
/* eslint-disable */
export function parse_go(code: string): string;
+121
View File
@@ -0,0 +1,121 @@
let WASM_VECTOR_LEN = 0;
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
const encodeString = function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
};
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8ArrayMemory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_go(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_go(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
const imports = {
__wbindgen_placeholder__: {
__wbindgen_init_externref_table: function() {
const table = wasm.__wbindgen_export_0;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
},
},
};
const wasm_url = new URL('windmill_parser_wasm_bg.wasm', import.meta.url);
let wasmCode = '';
switch (wasm_url.protocol) {
case 'file:':
wasmCode = await Deno.readFile(wasm_url);
break
case 'https:':
case 'http:':
wasmCode = await (await fetch(wasm_url)).arrayBuffer();
break
default:
throw new Error(`Unsupported protocol: ${wasm_url.protocol}`);
}
const wasmInstance = (await WebAssembly.instantiate(wasmCode, imports)).instance;
const wasm = wasmInstance.exports;
export const __wasm = wasm;
wasm.__wbindgen_start();
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export const parse_go: (a: number, b: number) => [number, number];
export const __wbindgen_export_0: WebAssembly.Table;
export const __wbindgen_malloc: (a: number, b: number) => number;
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
export const __wbindgen_free: (a: number, b: number, c: number) => void;
export const __wbindgen_start: () => void;
+3
View File
@@ -0,0 +1,3 @@
/* tslint:disable */
/* eslint-disable */
export function parse_nu(code: string): string;
+121
View File
@@ -0,0 +1,121 @@
let WASM_VECTOR_LEN = 0;
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
const encodeString = function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
};
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8ArrayMemory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_nu(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_nu(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
const imports = {
__wbindgen_placeholder__: {
__wbindgen_init_externref_table: function() {
const table = wasm.__wbindgen_export_0;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
},
},
};
const wasm_url = new URL('windmill_parser_wasm_bg.wasm', import.meta.url);
let wasmCode = '';
switch (wasm_url.protocol) {
case 'file:':
wasmCode = await Deno.readFile(wasm_url);
break
case 'https:':
case 'http:':
wasmCode = await (await fetch(wasm_url)).arrayBuffer();
break
default:
throw new Error(`Unsupported protocol: ${wasm_url.protocol}`);
}
const wasmInstance = (await WebAssembly.instantiate(wasmCode, imports)).instance;
const wasm = wasmInstance.exports;
export const __wasm = wasm;
wasm.__wbindgen_start();
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export const parse_nu: (a: number, b: number) => [number, number];
export const __wbindgen_export_0: WebAssembly.Table;
export const __wbindgen_malloc: (a: number, b: number) => number;
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
export const __wbindgen_free: (a: number, b: number, c: number) => void;
export const __wbindgen_start: () => void;
+3
View File
@@ -0,0 +1,3 @@
/* tslint:disable */
/* eslint-disable */
export function parse_php(code: string): string;
+121
View File
@@ -0,0 +1,121 @@
let WASM_VECTOR_LEN = 0;
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
const encodeString = function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
};
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8ArrayMemory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_php(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_php(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
const imports = {
__wbindgen_placeholder__: {
__wbindgen_init_externref_table: function() {
const table = wasm.__wbindgen_export_0;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
},
},
};
const wasm_url = new URL('windmill_parser_wasm_bg.wasm', import.meta.url);
let wasmCode = '';
switch (wasm_url.protocol) {
case 'file:':
wasmCode = await Deno.readFile(wasm_url);
break
case 'https:':
case 'http:':
wasmCode = await (await fetch(wasm_url)).arrayBuffer();
break
default:
throw new Error(`Unsupported protocol: ${wasm_url.protocol}`);
}
const wasmInstance = (await WebAssembly.instantiate(wasmCode, imports)).instance;
const wasm = wasmInstance.exports;
export const __wasm = wasm;
wasm.__wbindgen_start();
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export const parse_php: (a: number, b: number) => [number, number];
export const __wbindgen_export_0: WebAssembly.Table;
export const __wbindgen_malloc: (a: number, b: number) => number;
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
export const __wbindgen_free: (a: number, b: number, c: number) => void;
export const __wbindgen_start: () => void;
+3
View File
@@ -0,0 +1,3 @@
/* tslint:disable */
/* eslint-disable */
export function parse_python(code: string, main_override?: string | null): string;
+128
View File
@@ -0,0 +1,128 @@
let WASM_VECTOR_LEN = 0;
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
const encodeString = function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
};
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8ArrayMemory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
function isLikeNone(x) {
return x === undefined || x === null;
}
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
/**
* @param {string} code
* @param {string | null} [main_override]
* @returns {string}
*/
export function parse_python(code, main_override) {
let deferred3_0;
let deferred3_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
var ptr1 = isLikeNone(main_override) ? 0 : passStringToWasm0(main_override, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
const ret = wasm.parse_python(ptr0, len0, ptr1, len1);
deferred3_0 = ret[0];
deferred3_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
}
}
const imports = {
__wbindgen_placeholder__: {
__wbindgen_init_externref_table: function() {
const table = wasm.__wbindgen_export_0;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
},
},
};
const wasm_url = new URL('windmill_parser_wasm_bg.wasm', import.meta.url);
let wasmCode = '';
switch (wasm_url.protocol) {
case 'file:':
wasmCode = await Deno.readFile(wasm_url);
break
case 'https:':
case 'http:':
wasmCode = await (await fetch(wasm_url)).arrayBuffer();
break
default:
throw new Error(`Unsupported protocol: ${wasm_url.protocol}`);
}
const wasmInstance = (await WebAssembly.instantiate(wasmCode, imports)).instance;
const wasm = wasmInstance.exports;
export const __wasm = wasm;
wasm.__wbindgen_start();
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export const parse_python: (a: number, b: number, c: number, d: number) => [number, number];
export const __wbindgen_export_0: WebAssembly.Table;
export const __wbindgen_malloc: (a: number, b: number) => number;
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
export const __wbindgen_free: (a: number, b: number, c: number) => void;
export const __wbindgen_start: () => void;
+12
View File
@@ -0,0 +1,12 @@
/* tslint:disable */
/* eslint-disable */
export function parse_bash(code: string): string;
export function parse_powershell(code: string): string;
export function parse_sql(code: string): string;
export function parse_mysql(code: string): string;
export function parse_oracledb(code: string): string;
export function parse_bigquery(code: string): string;
export function parse_snowflake(code: string): string;
export function parse_mssql(code: string): string;
export function parse_db_resource(code: string): string | undefined;
export function parse_graphql(code: string): string;
+289
View File
@@ -0,0 +1,289 @@
let WASM_VECTOR_LEN = 0;
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
const encodeString = function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
};
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8ArrayMemory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_bash(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_bash(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_powershell(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_powershell(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_sql(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_sql(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_mysql(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_mysql(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_oracledb(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_oracledb(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_bigquery(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_bigquery(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_snowflake(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_snowflake(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_mssql(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_mssql(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @param {string} code
* @returns {string | undefined}
*/
export function parse_db_resource(code) {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_db_resource(ptr0, len0);
let v2;
if (ret[0] !== 0) {
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
}
return v2;
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_graphql(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_graphql(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
const imports = {
__wbindgen_placeholder__: {
__wbindgen_init_externref_table: function() {
const table = wasm.__wbindgen_export_0;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
},
},
};
const wasm_url = new URL('windmill_parser_wasm_bg.wasm', import.meta.url);
let wasmCode = '';
switch (wasm_url.protocol) {
case 'file:':
wasmCode = await Deno.readFile(wasm_url);
break
case 'https:':
case 'http:':
wasmCode = await (await fetch(wasm_url)).arrayBuffer();
break
default:
throw new Error(`Unsupported protocol: ${wasm_url.protocol}`);
}
const wasmInstance = (await WebAssembly.instantiate(wasmCode, imports)).instance;
const wasm = wasmInstance.exports;
export const __wasm = wasm;
wasm.__wbindgen_start();
Binary file not shown.
+18
View File
@@ -0,0 +1,18 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export const parse_bash: (a: number, b: number) => [number, number];
export const parse_powershell: (a: number, b: number) => [number, number];
export const parse_sql: (a: number, b: number) => [number, number];
export const parse_mysql: (a: number, b: number) => [number, number];
export const parse_oracledb: (a: number, b: number) => [number, number];
export const parse_bigquery: (a: number, b: number) => [number, number];
export const parse_snowflake: (a: number, b: number) => [number, number];
export const parse_mssql: (a: number, b: number) => [number, number];
export const parse_db_resource: (a: number, b: number) => [number, number];
export const parse_graphql: (a: number, b: number) => [number, number];
export const __wbindgen_export_0: WebAssembly.Table;
export const __wbindgen_malloc: (a: number, b: number) => number;
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
export const __wbindgen_free: (a: number, b: number, c: number) => void;
export const __wbindgen_start: () => void;
+3
View File
@@ -0,0 +1,3 @@
/* tslint:disable */
/* eslint-disable */
export function parse_rust(code: string): string;
+121
View File
@@ -0,0 +1,121 @@
let WASM_VECTOR_LEN = 0;
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
const encodeString = function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
};
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8ArrayMemory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_rust(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_rust(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
const imports = {
__wbindgen_placeholder__: {
__wbindgen_init_externref_table: function() {
const table = wasm.__wbindgen_export_0;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
},
},
};
const wasm_url = new URL('windmill_parser_wasm_bg.wasm', import.meta.url);
let wasmCode = '';
switch (wasm_url.protocol) {
case 'file:':
wasmCode = await Deno.readFile(wasm_url);
break
case 'https:':
case 'http:':
wasmCode = await (await fetch(wasm_url)).arrayBuffer();
break
default:
throw new Error(`Unsupported protocol: ${wasm_url.protocol}`);
}
const wasmInstance = (await WebAssembly.instantiate(wasmCode, imports)).instance;
const wasm = wasmInstance.exports;
export const __wasm = wasm;
wasm.__wbindgen_start();
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export const parse_rust: (a: number, b: number) => [number, number];
export const __wbindgen_export_0: WebAssembly.Table;
export const __wbindgen_malloc: (a: number, b: number) => number;
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
export const __wbindgen_free: (a: number, b: number, c: number) => void;
export const __wbindgen_start: () => void;
+5
View File
@@ -0,0 +1,5 @@
/* tslint:disable */
/* eslint-disable */
export function parse_deno(code: string, main_override?: string | null, skip_params?: boolean | null): string;
export function parse_outputs(code: string): string;
export function parse_ts_imports(code: string): string;
+429
View File
@@ -0,0 +1,429 @@
function addToExternrefTable0(obj) {
const idx = wasm.__externref_table_alloc();
wasm.__wbindgen_export_2.set(idx, obj);
return idx;
}
function handleError(f, args) {
try {
return f.apply(this, args);
} catch (e) {
const idx = addToExternrefTable0(e);
wasm.__wbindgen_exn_store(idx);
}
}
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
function isLikeNone(x) {
return x === undefined || x === null;
}
let cachedDataViewMemory0 = null;
function getDataViewMemory0() {
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
}
return cachedDataViewMemory0;
}
function debugString(val) {
// primitive types
const type = typeof val;
if (type == 'number' || type == 'boolean' || val == null) {
return `${val}`;
}
if (type == 'string') {
return `"${val}"`;
}
if (type == 'symbol') {
const description = val.description;
if (description == null) {
return 'Symbol';
} else {
return `Symbol(${description})`;
}
}
if (type == 'function') {
const name = val.name;
if (typeof name == 'string' && name.length > 0) {
return `Function(${name})`;
} else {
return 'Function';
}
}
// objects
if (Array.isArray(val)) {
const length = val.length;
let debug = '[';
if (length > 0) {
debug += debugString(val[0]);
}
for(let i = 1; i < length; i++) {
debug += ', ' + debugString(val[i]);
}
debug += ']';
return debug;
}
// Test for built-in
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
let className;
if (builtInMatches && builtInMatches.length > 1) {
className = builtInMatches[1];
} else {
// Failed to match the standard '[object ClassName]'
return toString.call(val);
}
if (className == 'Object') {
// we're a user defined class or Object
// JSON.stringify avoids problems with cycles, and is generally much
// easier than looping through ownProperties of `val`.
try {
return 'Object(' + JSON.stringify(val) + ')';
} catch (_) {
return 'Object';
}
}
// errors
if (val instanceof Error) {
return `${val.name}: ${val.message}\n${val.stack}`;
}
// TODO we could test for more things here, like `Set`s and `Map`s.
return className;
}
let WASM_VECTOR_LEN = 0;
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
const encodeString = function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
};
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8ArrayMemory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
/**
* @param {string} code
* @param {string | null} [main_override]
* @param {boolean | null} [skip_params]
* @returns {string}
*/
export function parse_deno(code, main_override, skip_params) {
let deferred3_0;
let deferred3_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
var ptr1 = isLikeNone(main_override) ? 0 : passStringToWasm0(main_override, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
const ret = wasm.parse_deno(ptr0, len0, ptr1, len1, isLikeNone(skip_params) ? 0xFFFFFF : skip_params ? 1 : 0);
deferred3_0 = ret[0];
deferred3_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
}
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_outputs(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_outputs(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_ts_imports(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_ts_imports(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
const imports = {
__wbindgen_placeholder__: {
__wbg_buffer_609cc3eee51ed158: function(arg0) {
const ret = arg0.buffer;
return ret;
},
__wbg_call_672a4d21634d4a24: function() { return handleError(function (arg0, arg1) {
const ret = arg0.call(arg1);
return ret;
}, arguments) },
__wbg_done_769e5ede4b31c67b: function(arg0) {
const ret = arg0.done;
return ret;
},
__wbg_entries_3265d4158b33e5dc: function(arg0) {
const ret = Object.entries(arg0);
return ret;
},
__wbg_eval_58d0b9f11db87ad1: function(arg0, arg1) {
const ret = eval(getStringFromWasm0(arg0, arg1));
return ret;
},
__wbg_get_67b2ba62fc30de12: function() { return handleError(function (arg0, arg1) {
const ret = Reflect.get(arg0, arg1);
return ret;
}, arguments) },
__wbg_get_b9b93047fe3cf45b: function(arg0, arg1) {
const ret = arg0[arg1 >>> 0];
return ret;
},
__wbg_instanceof_ArrayBuffer_e14585432e3737fc: function(arg0) {
let result;
try {
result = arg0 instanceof ArrayBuffer;
} catch (_) {
result = false;
}
const ret = result;
return ret;
},
__wbg_instanceof_Map_f3469ce2244d2430: function(arg0) {
let result;
try {
result = arg0 instanceof Map;
} catch (_) {
result = false;
}
const ret = result;
return ret;
},
__wbg_instanceof_Uint8Array_17156bcf118086a9: function(arg0) {
let result;
try {
result = arg0 instanceof Uint8Array;
} catch (_) {
result = false;
}
const ret = result;
return ret;
},
__wbg_isArray_a1eab7e0d067391b: function(arg0) {
const ret = Array.isArray(arg0);
return ret;
},
__wbg_isSafeInteger_343e2beeeece1bb0: function(arg0) {
const ret = Number.isSafeInteger(arg0);
return ret;
},
__wbg_iterator_9a24c88df860dc65: function() {
const ret = Symbol.iterator;
return ret;
},
__wbg_length_a446193dc22c12f8: function(arg0) {
const ret = arg0.length;
return ret;
},
__wbg_length_e2d2a49132c1b256: function(arg0) {
const ret = arg0.length;
return ret;
},
__wbg_new_a12002a7f91c75be: function(arg0) {
const ret = new Uint8Array(arg0);
return ret;
},
__wbg_next_25feadfc0913fea9: function(arg0) {
const ret = arg0.next;
return ret;
},
__wbg_next_6574e1a8a62d1055: function() { return handleError(function (arg0) {
const ret = arg0.next();
return ret;
}, arguments) },
__wbg_set_65595bdd868b3009: function(arg0, arg1, arg2) {
arg0.set(arg1, arg2 >>> 0);
},
__wbg_value_cd1ffa7b1ab794f1: function(arg0) {
const ret = arg0.value;
return ret;
},
__wbindgen_bigint_from_i64: function(arg0) {
const ret = arg0;
return ret;
},
__wbindgen_bigint_from_u64: function(arg0) {
const ret = BigInt.asUintN(64, arg0);
return ret;
},
__wbindgen_bigint_get_as_i64: function(arg0, arg1) {
const v = arg1;
const ret = typeof(v) === 'bigint' ? v : undefined;
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
},
__wbindgen_boolean_get: function(arg0) {
const v = arg0;
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
return ret;
},
__wbindgen_debug_string: function(arg0, arg1) {
const ret = debugString(arg1);
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len1 = WASM_VECTOR_LEN;
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
},
__wbindgen_error_new: function(arg0, arg1) {
const ret = new Error(getStringFromWasm0(arg0, arg1));
return ret;
},
__wbindgen_in: function(arg0, arg1) {
const ret = arg0 in arg1;
return ret;
},
__wbindgen_init_externref_table: function() {
const table = wasm.__wbindgen_export_2;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
},
__wbindgen_is_bigint: function(arg0) {
const ret = typeof(arg0) === 'bigint';
return ret;
},
__wbindgen_is_function: function(arg0) {
const ret = typeof(arg0) === 'function';
return ret;
},
__wbindgen_is_object: function(arg0) {
const val = arg0;
const ret = typeof(val) === 'object' && val !== null;
return ret;
},
__wbindgen_jsval_eq: function(arg0, arg1) {
const ret = arg0 === arg1;
return ret;
},
__wbindgen_jsval_loose_eq: function(arg0, arg1) {
const ret = arg0 == arg1;
return ret;
},
__wbindgen_memory: function() {
const ret = wasm.memory;
return ret;
},
__wbindgen_number_get: function(arg0, arg1) {
const obj = arg1;
const ret = typeof(obj) === 'number' ? obj : undefined;
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
},
__wbindgen_string_get: function(arg0, arg1) {
const obj = arg1;
const ret = typeof(obj) === 'string' ? obj : undefined;
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
},
__wbindgen_throw: function(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
},
},
};
const wasm_url = new URL('windmill_parser_wasm_bg.wasm', import.meta.url);
let wasmCode = '';
switch (wasm_url.protocol) {
case 'file:':
wasmCode = await Deno.readFile(wasm_url);
break
case 'https:':
case 'http:':
wasmCode = await (await fetch(wasm_url)).arrayBuffer();
break
default:
throw new Error(`Unsupported protocol: ${wasm_url.protocol}`);
}
const wasmInstance = (await WebAssembly.instantiate(wasmCode, imports)).instance;
const wasm = wasmInstance.exports;
export const __wasm = wasm;
wasm.__wbindgen_start();
Binary file not shown.
+13
View File
@@ -0,0 +1,13 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export const parse_deno: (a: number, b: number, c: number, d: number, e: number) => [number, number];
export const parse_outputs: (a: number, b: number) => [number, number];
export const parse_ts_imports: (a: number, b: number) => [number, number];
export const __wbindgen_exn_store: (a: number) => void;
export const __externref_table_alloc: () => number;
export const __wbindgen_export_2: WebAssembly.Table;
export const __wbindgen_malloc: (a: number, b: number) => number;
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
export const __wbindgen_free: (a: number, b: number, c: number) => void;
export const __wbindgen_start: () => void;
-146
View File
@@ -1,146 +0,0 @@
// deno-lint-ignore-file
// deno-fmt-ignore-file
export interface InstantiateResult {
instance: WebAssembly.Instance;
exports: {
parse_deno: typeof parse_deno;
parse_outputs: typeof parse_outputs;
parse_ts_imports: typeof parse_ts_imports;
parse_bash: typeof parse_bash;
parse_powershell: typeof parse_powershell;
parse_go: typeof parse_go;
parse_python: typeof parse_python;
parse_sql: typeof parse_sql;
parse_mysql: typeof parse_mysql;
parse_oracledb: typeof parse_oracledb;
parse_bigquery: typeof parse_bigquery;
parse_snowflake: typeof parse_snowflake;
parse_mssql: typeof parse_mssql;
parse_db_resource: typeof parse_db_resource;
parse_graphql: typeof parse_graphql;
parse_php: typeof parse_php;
parse_rust: typeof parse_rust;
parse_ansible: typeof parse_ansible;
parse_csharp: typeof parse_csharp
};
}
/** Gets if the Wasm module has been instantiated. */
export function isInstantiated(): boolean;
/** Options for instantiating a Wasm instance. */
export interface InstantiateOptions {
/** Optional url to the Wasm file to instantiate. */
url?: URL;
/** Callback to decompress the raw Wasm file bytes before instantiating. */
decompress?: (bytes: Uint8Array) => Uint8Array;
}
/** Instantiates an instance of the Wasm module returning its functions.
* @remarks It is safe to call this multiple times and once successfully
* loaded it will always return a reference to the same object. */
export function instantiate(opts?: InstantiateOptions): Promise<InstantiateResult["exports"]>;
/** Instantiates an instance of the Wasm module along with its exports.
* @remarks It is safe to call this multiple times and once successfully
* loaded it will always return a reference to the same object. */
export function instantiateWithInstance(opts?: InstantiateOptions): Promise<InstantiateResult>;
/**
* @param {string} code
* @param {string | undefined} [main_override]
* @returns {string}
*/
export function parse_deno(code: string, main_override?: string): string;
/**
* @param {string} code
* @returns {string}
*/
export function parse_outputs(code: string): string;
/**
* @param {string} code
* @returns {string}
*/
export function parse_ts_imports(code: string): string;
/**
* @param {string} code
* @returns {string}
*/
export function parse_bash(code: string): string;
/**
* @param {string} code
* @returns {string}
*/
export function parse_powershell(code: string): string;
/**
* @param {string} code
* @returns {string}
*/
export function parse_go(code: string): string;
/**
* @param {string} code
* @param {string | undefined} [main_override]
* @returns {string}
*/
export function parse_python(code: string, main_override?: string): string;
/**
* @param {string} code
* @returns {string}
*/
export function parse_sql(code: string): string;
/**
* @param {string} code
* @returns {string}
*/
export function parse_mysql(code: string): string;
/**
* @param {string} code
* @returns {string}
*/
export function parse_oracledb(code: string): string;
/**
* @param {string} code
* @returns {string}
*/
export function parse_bigquery(code: string): string;
/**
* @param {string} code
* @returns {string}
*/
export function parse_snowflake(code: string): string;
/**
* @param {string} code
* @returns {string}
*/
export function parse_mssql(code: string): string;
/**
* @param {string} code
* @returns {string | undefined}
*/
export function parse_db_resource(code: string): string | undefined;
/**
* @param {string} code
* @returns {string}
*/
export function parse_graphql(code: string): string;
/**
* @param {string} code
* @returns {string}
*/
export function parse_php(code: string): string;
/**
* @param {string} code
* @returns {string}
*/
export function parse_rust(code: string): string;
/**
* @param {string} code
* @returns {string}
*/
export function parse_ansible(code: string): string;
/**
* @param {string} code
* @returns {string}
*/
export function parse_csharp(code: string): string;
File diff suppressed because it is too large Load Diff
Binary file not shown.
+3
View File
@@ -0,0 +1,3 @@
/* tslint:disable */
/* eslint-disable */
export function parse_ansible(code: string): string;
+121
View File
@@ -0,0 +1,121 @@
let WASM_VECTOR_LEN = 0;
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
const encodeString = function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
};
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8ArrayMemory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
/**
* @param {string} code
* @returns {string}
*/
export function parse_ansible(code) {
let deferred2_0;
let deferred2_1;
try {
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.parse_ansible(ptr0, len0);
deferred2_0 = ret[0];
deferred2_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
const imports = {
__wbindgen_placeholder__: {
__wbindgen_init_externref_table: function() {
const table = wasm.__wbindgen_export_0;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
},
},
};
const wasm_url = new URL('windmill_parser_wasm_bg.wasm', import.meta.url);
let wasmCode = '';
switch (wasm_url.protocol) {
case 'file:':
wasmCode = await Deno.readFile(wasm_url);
break
case 'https:':
case 'http:':
wasmCode = await (await fetch(wasm_url)).arrayBuffer();
break
default:
throw new Error(`Unsupported protocol: ${wasm_url.protocol}`);
}
const wasmInstance = (await WebAssembly.instantiate(wasmCode, imports)).instance;
const wasm = wasmInstance.exports;
export const __wasm = wasm;
wasm.__wbindgen_start();
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export const parse_ansible: (a: number, b: number) => [number, number];
export const __wbindgen_export_0: WebAssembly.Table;
export const __wbindgen_malloc: (a: number, b: number) => number;
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
export const __wbindgen_free: (a: number, b: number, c: number) => void;
export const __wbindgen_start: () => void;
+6
View File
@@ -1,10 +1,16 @@
FROM ghcr.io/windmill-labs/windmill:dev
# Rust
COPY --from=rust:1.81.0 /usr/local/cargo /usr/local/cargo
COPY --from=rust:1.81.0 /usr/local/rustup /usr/local/rustup
# Ansible
RUN uv tool install ansible && [ -d "$(uv tool dir)/ansible/bin/" ] && find "$(uv tool dir)/ansible/bin/" -mindepth 1 -maxdepth 1 -type f -executable -regextype posix-extended -regex '^((.+/)?)[^.]+' -print0 | xargs -0 ln -s -t "$UV_TOOL_BIN_DIR/" || true
# C#
COPY --from=bitnami/dotnet-sdk:9.0.101-debian-12-r0 /opt/bitnami/dotnet-sdk /opt/dotnet-sdk
RUN ln -s /opt/dotnet-sdk/bin/dotnet /usr/bin/dotnet
ENV DOTNET_ROOT="/opt/dotnet-sdk/bin"
# Nushell
COPY --from=ghcr.io/nushell/nushell:0.101.0-bookworm /usr/bin/nu /usr/bin/nu
+5
View File
@@ -19,9 +19,11 @@ RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
FROM ghcr.io/windmill-labs/windmill-ee:dev
# Rust
COPY --from=rust:1.81.0 /usr/local/cargo /usr/local/cargo
COPY --from=rust:1.81.0 /usr/local/rustup /usr/local/rustup
# Ansible
RUN uv tool install ansible && [ -d "$(uv tool dir)/ansible/bin/" ] && find "$(uv tool dir)/ansible/bin/" -mindepth 1 -maxdepth 1 -type f -executable -regextype posix-extended -regex '^((.+/)?)[^.]+' -print0 | xargs -0 ln -s -t "$UV_TOOL_BIN_DIR/" || true
# dotnet SDK
COPY --from=bitnami/dotnet-sdk:9.0.101-debian-12-r0 /opt/bitnami/dotnet-sdk /opt/dotnet-sdk
@@ -32,3 +34,6 @@ ENV DOTNET_ROOT="/opt/dotnet-sdk/bin"
COPY --from=oracledb-client /opt/oracle/23/lib /opt/oracle/23/lib
RUN apt-get -y update && apt-get install -y libaio1
RUN echo /opt/oracle/23/lib > /etc/ld.so.conf.d/oracle-instantclient.conf && ldconfig
# Nushell
COPY --from=ghcr.io/nushell/nushell:0.101.0-bookworm /usr/bin/nu /usr/bin/nu
+5
View File
@@ -42,9 +42,11 @@ FROM ghcr.io/windmill-labs/windmill-ee:dev
RUN apt-get update && apt-get install -y libprotobuf-dev libnl-route-3-dev
# Rust
COPY --from=rust:1.80.1 /usr/local/cargo /usr/local/cargo
COPY --from=rust:1.80.1 /usr/local/rustup /usr/local/rustup
# Ansible
RUN uv tool install ansible && [ -d "$(uv tool dir)/ansible/bin/" ] && find "$(uv tool dir)/ansible/bin/" -mindepth 1 -maxdepth 1 -type f -executable -regextype posix-extended -regex '^((.+/)?)[^.]+' -print0 | xargs -0 ln -s -t "$UV_TOOL_BIN_DIR/" || true
# dotnet SDK
@@ -57,4 +59,7 @@ COPY --from=oracledb-client /opt/oracle/23/lib /opt/oracle/23/lib
RUN apt-get -y update && apt-get install -y libaio1
RUN echo /opt/oracle/23/lib > /etc/ld.so.conf.d/oracle-instantclient.conf && ldconfig
# Nushell
COPY --from=ghcr.io/nushell/nushell:0.101.0-bookworm /usr/bin/nu /usr/bin/nu
COPY --from=nsjail /nsjail/nsjail /bin/nsjail

Some files were not shown because too many files have changed in this diff Show More