fix: modify snake case numbers resource types (#2029)

This commit is contained in:
HugoCasa
2023-08-11 10:16:23 +02:00
committed by GitHub
parent 76a1dd888d
commit ca5534d9f7
8 changed files with 43 additions and 32 deletions

1
backend/Cargo.lock generated
View File

@@ -7320,6 +7320,7 @@ version = "1.144.4"
dependencies = [
"anyhow",
"convert_case 0.6.0",
"regex",
"serde-wasm-bindgen",
"serde_json",
"swc_common",

View File

@@ -20,4 +20,5 @@ swc_ecma_parser.workspace = true
swc_ecma_ast.workspace = true
serde_json.workspace = true
anyhow.workspace = true
convert_case.workspace = true
convert_case.workspace = true
regex.workspace = true

View File

@@ -1,4 +1,5 @@
use convert_case::{Case, Casing};
use regex::Regex;
/*
* Author: Ruben Fiszel
* Copyright: Windmill Labs, Inc 2022
@@ -151,6 +152,14 @@ fn binding_ident_to_arg(BindingIdent { id, type_ann }: &BindingIdent) -> (String
(id.sym.to_string(), typ, nullable)
}
fn to_snake_case(s: &str) -> String {
let r = s.to_case(Case::Snake);
// s_3 => s3
let re = Regex::new(r"_(\d)").unwrap();
re.replace_all(&r, "$1").to_string()
}
fn tstype_to_typ(ts_type: &TsType) -> (Typ, bool) {
// log(&format!("{:?}", ts_type));
match ts_type {
@@ -262,7 +271,7 @@ fn tstype_to_typ(ts_type: &TsType) -> (Typ, bool) {
"Base64" => (Typ::Bytes, false),
"Email" => (Typ::Email, false),
"Sql" => (Typ::Sql, false),
x @ _ => (Typ::Resource(x.to_case(Case::Snake)), false),
x @ _ => (Typ::Resource(to_snake_case(x)), false),
}
}
_ => (Typ::Unknown, false),

View File

@@ -3,7 +3,7 @@
"collaborators": [
"Ruben Fiszel <ruben@windmill.dev>"
],
"version": "1.143.0",
"version": "1.144.4",
"files": [
"windmill_parser_wasm_bg.wasm",
"windmill_parser_wasm.js",

View File

@@ -6,20 +6,6 @@ heap.push(undefined, null, true, false);
function getObject(idx) { return heap[idx]; }
let heap_next = heap.length;
function dropObject(idx) {
if (idx < 132) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
let WASM_VECTOR_LEN = 0;
let cachedUint8Memory0 = null;
@@ -97,6 +83,20 @@ function getInt32Memory0() {
return cachedInt32Memory0;
}
let heap_next = heap.length;
function dropObject(idx) {
if (idx < 132) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
@@ -469,13 +469,6 @@ async function __wbg_load(module, imports) {
function __wbg_get_imports() {
const imports = {};
imports.wbg = {};
imports.wbg.__wbg_eval_44bde4e76596166e = function(arg0, arg1) {
const ret = eval(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
const obj = getObject(arg1);
const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -484,6 +477,13 @@ function __wbg_get_imports() {
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
imports.wbg.__wbg_eval_fc6855b8339aec25 = function(arg0, arg1) {
const ret = eval(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
imports.wbg.__wbindgen_boolean_get = function(arg0) {
const v = getObject(arg0);
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;

View File

@@ -43,7 +43,7 @@
"svelte-timezone-picker": "^2.0.3",
"tailwind-merge": "^1.13.2",
"vscode-ws-jsonrpc": "3.0.0",
"windmill-parser-wasm": "^1.143.0",
"windmill-parser-wasm": "^1.144.4",
"y-monaco": "^0.1.4",
"y-websocket": "^1.5.0",
"yjs": "^13.6.7"
@@ -9811,9 +9811,9 @@
}
},
"node_modules/windmill-parser-wasm": {
"version": "1.143.0",
"resolved": "https://registry.npmjs.org/windmill-parser-wasm/-/windmill-parser-wasm-1.143.0.tgz",
"integrity": "sha512-sxkolDrUX/ywrE3tZpA3f9B4BONpW7PaHq+5qJBreCBHVkGnAx8iyXgyEvZhIpcTmuNhCy/osumoK/CjxGWWDw=="
"version": "1.144.4",
"resolved": "https://registry.npmjs.org/windmill-parser-wasm/-/windmill-parser-wasm-1.144.4.tgz",
"integrity": "sha512-8Lx7kcZIEsnlXUr/vzkWJfjXP8MrJIocNVUwwDCATyRx1A9kZ3fSj2K1S+ObhAvc5YyE7v0kgS65h+ybm4eRoA=="
},
"node_modules/wordwrap": {
"version": "1.0.0",
@@ -16782,9 +16782,9 @@
}
},
"windmill-parser-wasm": {
"version": "1.143.0",
"resolved": "https://registry.npmjs.org/windmill-parser-wasm/-/windmill-parser-wasm-1.143.0.tgz",
"integrity": "sha512-sxkolDrUX/ywrE3tZpA3f9B4BONpW7PaHq+5qJBreCBHVkGnAx8iyXgyEvZhIpcTmuNhCy/osumoK/CjxGWWDw=="
"version": "1.144.4",
"resolved": "https://registry.npmjs.org/windmill-parser-wasm/-/windmill-parser-wasm-1.144.4.tgz",
"integrity": "sha512-8Lx7kcZIEsnlXUr/vzkWJfjXP8MrJIocNVUwwDCATyRx1A9kZ3fSj2K1S+ObhAvc5YyE7v0kgS65h+ybm4eRoA=="
},
"wordwrap": {
"version": "1.0.0",

View File

@@ -107,7 +107,7 @@
"svelte-timezone-picker": "^2.0.3",
"tailwind-merge": "^1.13.2",
"vscode-ws-jsonrpc": "3.0.0",
"windmill-parser-wasm": "^1.143.0",
"windmill-parser-wasm": "^1.144.4",
"y-monaco": "^0.1.4",
"y-websocket": "^1.5.0",
"yjs": "^13.6.7"