fix: update internal deno runtime to 0.262.0 (#3240)

* feat: scim token and saml metadata setting in UI directly

* chore(main): release 1.271.0 (#3237)

* chore(main): release 1.271.0

* Apply automatic changes

---------

Co-authored-by: rubenfiszel <rubenfiszel@users.noreply.github.com>

* fix test

* all

* update all

* fix frontend

---------

Co-authored-by: rubenfiszel <rubenfiszel@users.noreply.github.com>
This commit is contained in:
Ruben Fiszel
2024-02-18 13:19:35 +01:00
committed by GitHub
parent 639c80220f
commit a61936f66f
9 changed files with 463 additions and 427 deletions
+348 -351
View File
File diff suppressed because it is too large Load Diff
+13 -12
View File
@@ -69,6 +69,7 @@ uuid.workspace = true
gethostname.workspace = true
serde_json.workspace = true
serde.workspace = true
deno_core.workspace = true
pg-embed = {git = "https://github.com/faokunega/pg-embed", optional = true, default-features = false, features = ['rt_tokio']}
[dev-dependencies]
@@ -141,19 +142,19 @@ tokio-util = { version = "^0", features = ["io"] }
json-pointer = "^0"
itertools = "^0"
regex = "^1"
deno_fetch = "0.139.0"
deno_tls = "0.102.0"
deno_console = "0.115.0"
deno_url = "0.115.0"
deno_webidl = "0.115.0"
deno_web = "0.146.0"
deno_core = "0.200.0"
deno_ast = { version = "0.28.0", features = ["transpiling"] }
deno_fetch = "0.162.0"
deno_tls = "0.125.0"
deno_console = "0.138.0"
deno_url = "0.138.0"
deno_webidl = "0.138.0"
deno_web = "0.169.0"
deno_core = "0.262.0"
deno_ast = { version = "0.33.3", features = ["transpiling"] }
async-recursion = "^1"
swc_common = "0.31.21"
swc_ecma_parser = "0.137.15"
swc_ecma_ast = "0.107.7"
swc_ecma_visit = "0.93.7"
swc_common = "=0.33.17"
swc_ecma_parser = "=0.143.3"
swc_ecma_ast = "=0.112.2"
swc_ecma_visit = "=0.98.2"
base64 = "0.21.0"
hmac = "0.12.1"
sha2 = "0.10.6"
+28 -2
View File
@@ -62,8 +62,34 @@ mod monitor;
#[cfg(feature = "pg_embed")]
mod pg_embed;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
#[inline(always)]
fn create_and_run_current_thread_inner<F, R>(future: F) -> R
where
F: std::future::Future<Output = R> + 'static,
R: Send + 'static,
{
let rt = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.worker_threads(32)
.build()
.unwrap();
// Since this is the main future, we want to box it in debug mode because it tends to be fairly
// large and the compiler won't optimize repeated copies. We also make this runtime factory
// function #[inline(always)] to avoid holding the unboxed, unused future on the stack.
#[cfg(debug_assertions)]
// SAFETY: this this is guaranteed to be running on a current-thread executor
let future = Box::pin(future);
rt.block_on(future)
}
pub fn main() -> anyhow::Result<()> {
deno_core::JsRuntime::init_platform(None);
create_and_run_current_thread_inner(windmill_main())
}
async fn windmill_main() -> anyhow::Result<()> {
dotenv::dotenv().ok();
if std::env::var("RUST_LOG").is_err() {
+5 -5
View File
@@ -1,4 +1,3 @@
use deno_core::OpState;
use deno_fetch::FetchPermissions;
use deno_web::{BlobStore, TimersPermission};
use std::env;
@@ -8,6 +7,7 @@ use std::sync::Arc;
pub struct PermissionsContainer;
impl FetchPermissions for PermissionsContainer {
#[inline(always)]
fn check_net_url(
&mut self,
_url: &deno_core::url::Url,
@@ -16,6 +16,7 @@ impl FetchPermissions for PermissionsContainer {
Ok(())
}
#[inline(always)]
fn check_read(
&mut self,
_p: &std::path::Path,
@@ -26,13 +27,10 @@ impl FetchPermissions for PermissionsContainer {
}
impl TimersPermission for PermissionsContainer {
#[inline(always)]
fn allow_hrtime(&mut self) -> bool {
true
}
fn check_unstable(&self, _state: &OpState, _api_name: &'static str) {
()
}
}
deno_core::extension!(
@@ -70,6 +68,8 @@ fn main() {
extensions: exts,
compression_cb: None,
with_runtime_cb: None,
skip_op_registration: false,
},
None,
);
}
+50 -49
View File
@@ -10,10 +10,7 @@ use std::{cell::RefCell, collections::HashMap, rc::Rc, sync::Arc, env, io::{BufR
use deno_ast::{ParseParams, SourceTextInfo};
use deno_core::{
op, serde_v8,
v8::IsolateHandle,
v8::{self},
Extension, JsRuntime, Op, OpState, RuntimeOptions, Snapshot, error::AnyError,
error::AnyError, op2, serde_v8, url, v8::{self, IsolateHandle}, Extension, JsRuntime, Op, OpState, PollEventLoopOptions, RuntimeOptions, Snapshot
};
use deno_fetch::FetchPermissions;
use deno_tls::{rustls::RootCertStore, rustls_pemfile};
@@ -69,6 +66,7 @@ impl deno_tls::RootCertStoreProvider for ContainerRootCertStoreProvider {
pub struct PermissionsContainer;
impl FetchPermissions for PermissionsContainer {
#[inline(always)]
fn check_net_url(
&mut self,
_url: &deno_core::url::Url,
@@ -77,6 +75,7 @@ impl FetchPermissions for PermissionsContainer {
Ok(())
}
#[inline(always)]
fn check_read(
&mut self,
_p: &std::path::Path,
@@ -87,13 +86,10 @@ impl FetchPermissions for PermissionsContainer {
}
impl TimersPermission for PermissionsContainer {
#[inline(always)]
fn allow_hrtime(&mut self) -> bool {
true
}
fn check_unstable(&self, _state: &OpState, _api_name: &'static str) {
()
}
}
pub struct OptAuthedClient(Option<AuthedClient>);
@@ -322,12 +318,12 @@ async function result_by_id(node_id) {{
}}
}} else {{
let flow_job_id = "{}";
return JSON.parse(await Deno.core.opAsync("op_get_id", [flow_job_id, node_id]));
return JSON.parse(await Deno.core.ops.op_get_id(flow_job_id, node_id));
}}
}}
async function get_result(id) {{
return JSON.parse(await Deno.core.opAsync("op_get_result", [id]));
return JSON.parse(await Deno.core.ops.op_get_result(id));
}}
const results = new Proxy({{}}, {{
get: function(target, name, receiver) {{
@@ -359,10 +355,10 @@ const results = new Proxy({{}}, {{
let api_code = format!(
r#"
async function variable(path) {{
return await Deno.core.opAsync("op_variable", [path]);
return await Deno.core.ops.op_variable(path);
}}
async function resource(path) {{
return await Deno.core.opAsync("op_resource", [path]);
return await Deno.core.ops.op_resource(path);
}}
"#,
);
@@ -379,7 +375,7 @@ async function resource(path) {{
let code = format!(
r#"
function get_from_env(name) {{
return JSON.parse(Deno.core.ops.op_get_context([name]));
return JSON.parse(Deno.core.ops.op_get_context(name));
}}
{api_code}
{}
@@ -401,8 +397,9 @@ function get_from_env(name) {{
);
let global = context.execute_script("<anon>", code.into())?;
let global = context.resolve_value(global).await?;
let script = context.execute_script("<anon>", code.into())?;
let fut = context.resolve(script);
let global = context.with_event_loop_promise(fut, PollEventLoopOptions::default()).await?;
let scope = &mut context.handle_scope();
let local = v8::Local::new(scope, global);
@@ -423,30 +420,30 @@ function get_from_env(name) {{
// }
// TODO: Can we a) share the api configuration here somehow or b) just implement this natively in deno, via the deno client?
#[op]
#[op2(async)]
#[string]
async fn op_variable(
op_state: Rc<RefCell<OpState>>,
args: Vec<String>,
#[string] path: String,
) -> Result<String, anyhow::Error> {
let path = &args[0];
let client = op_state.borrow().borrow::<OptAuthedClient>().0.clone();
if let Some(client) = client {
Ok(client.get_variable_value(path).await?)
Ok(client.get_variable_value(&path).await?)
} else {
anyhow::bail!("No client found in op state");
}
}
#[op]
#[op2(async)]
#[string]
async fn op_get_result(
op_state: Rc<RefCell<OpState>>,
args: Vec<String>,
#[string] id: String,
) -> Result<String, anyhow::Error> {
let id = &args[0];
let client = op_state.borrow().borrow::<OptAuthedClient>().0.clone();
if let Some(client) = client {
let result = client
.get_completed_job_result::<Box<RawValue>>(id, None)
.get_completed_job_result::<Box<RawValue>>(&id, None)
.await?
.clone();
Ok(result.get().to_string())
@@ -455,18 +452,18 @@ async fn op_get_result(
}
}
#[op]
#[op2(async)]
#[string]
async fn op_get_id(
op_state: Rc<RefCell<OpState>>,
args: Vec<String>,
#[string] flow_job_id: String,
#[string] node_id: String,
) -> Result<Option<String>, anyhow::Error> {
let flow_job_id = &args[0];
let node_id = &args[1];
let client = op_state.borrow().borrow::<OptAuthedClient>().0.clone();
if let Some(client) = client {
let result = client
.get_result_by_id::<Option<Box<RawValue>>>(flow_job_id, node_id, None)
.get_result_by_id::<Option<Box<RawValue>>>(&flow_job_id, &node_id, None)
.await.ok();
if let Some(result) = result {
Ok(result.map(|x| x.get().to_string()))
@@ -478,16 +475,15 @@ async fn op_get_id(
}
}
#[op]
#[op2(async)]
#[serde]
async fn op_resource(
op_state: Rc<RefCell<OpState>>,
args: Vec<String>,
#[string] path:String,
) -> Result<serde_json::Value, anyhow::Error> {
let path = &args[0];
let client = op_state.borrow().borrow::<OptAuthedClient>().0.clone();
if let Some(client) = client {
client.get_resource_value_interpolated(path, None).await
client.get_resource_value_interpolated(&path, None).await
} else {
anyhow::bail!("No client found in op state");
}
@@ -498,28 +494,29 @@ pub struct TransformContext {
pub flow_input: Option<Arc<HashMap<String, Box<RawValue>>>>,
}
#[op]
fn op_get_context(op_state: Rc<RefCell<OpState>>, args: Vec<String>) -> String {
let id = &args[0];
#[op2]
#[string]
fn op_get_context(op_state: Rc<RefCell<OpState>>, #[string] id: &str) -> String {
let ops = op_state.borrow();
let client = ops.borrow::<TransformContext>();
if id == "flow_input" {
return client
client
.flow_input
.as_ref()
.and_then(|x| serde_json::to_string(&x).ok())
.unwrap_or_else(|| "null".to_string());
}
return client
.unwrap_or_else(|| "null".to_string())
} else {
client
.envs
.get(id)
.and_then(|x| serde_json::to_string(x).ok())
.unwrap_or_else(String::new);
.unwrap_or_else(String::new)
}
}
pub fn transpile_ts(expr: String) -> anyhow::Result<String> {
let parsed = deno_ast::parse_module(ParseParams {
specifier: "eval.ts".to_string(),
specifier: url::Url::parse("file:///eval.ts")?,
text_info: SourceTextInfo::from_string(expr),
capture_tokens: false,
scope_analysis: false,
@@ -668,7 +665,7 @@ async fn eval_fetch(js_runtime: &mut JsRuntime, expr: &str) -> anyhow::Result<Bo
)
.await?;
let global = js_runtime.execute_script(
let script = js_runtime.execute_script(
"<anon>",
r#"
let args = Deno.core.ops.op_get_static_args().map(JSON.parse)
@@ -677,7 +674,10 @@ import("file:///eval.ts").then((module) => module.main(...args)).then(JSON.strin
.to_string()
.into(),
)?;
let global = js_runtime.resolve_value(global).await?;
let fut = js_runtime.resolve(script);
let global = js_runtime.with_event_loop_promise(fut, PollEventLoopOptions::default()).await?;
let scope = &mut js_runtime.handle_scope();
let local = v8::Local::new(scope, global);
@@ -687,18 +687,19 @@ import("file:///eval.ts").then((module) => module.main(...args)).then(JSON.strin
Ok(unsafe_raw(r.unwrap_or_else(|| "null".to_string())))
}
#[op]
#[op2]
#[serde]
fn op_get_static_args(op_state: Rc<RefCell<OpState>>) -> Vec<Option<String>> {
return op_state.borrow().borrow::<MainArgs>().args.iter().map(|x| x.as_ref().map(|y| y.get().to_string())).collect_vec();
op_state.borrow().borrow::<MainArgs>().args.iter().map(|x| x.as_ref().map(|y| y.get().to_string())).collect_vec()
}
#[op]
fn op_log(op_state: Rc<RefCell<OpState>>, args: Vec<String>) {
#[op2(fast)]
fn op_log(op_state: Rc<RefCell<OpState>>, #[string] log: &str) {
op_state
.borrow_mut()
.borrow_mut::<LogString>()
.s
.push_str(args.get(0).unwrap());
.push_str(log);
}
#[cfg(test)]
+2 -1
View File
@@ -1,7 +1,6 @@
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
import * as base64 from "ext:deno_web/05_base64.js";
import * as console from "ext:deno_console/01_console.js";
import DOMException from "ext:deno_web/01_dom_exception.js";
import * as encoding from "ext:deno_web/08_text_encoding.js";
import * as event from "ext:deno_web/02_event.js";
import * as fetch from "ext:deno_fetch/26_fetch.js";
@@ -21,6 +20,8 @@ import "ext:deno_web/04_global_interfaces.js";
import "ext:deno_web/13_message_port.js";
import "ext:deno_web/14_compression.js";
import "ext:deno_web/15_performance.js";
import "ext:deno_web/16_image_data.js";
import "ext:deno_fetch/27_eventsource.js";
globalThis.atob = base64.atob;
globalThis.btoa = base64.btoa;
@@ -84,13 +84,16 @@ export async function createInlineScriptModule(
return [flowModule, await loadFlowModuleState(flowModule)]
}
export async function createLoop(id: string): Promise<[FlowModule, FlowModuleState]> {
export async function createLoop(
id: string,
enabledAi: boolean
): Promise<[FlowModule, FlowModuleState]> {
const loopFlowModule: FlowModule = {
id,
value: {
type: 'forloopflow',
modules: [],
iterator: { type: 'javascript', expr: '' },
iterator: { type: 'javascript', expr: enabledAi ? '' : "['dynamic or static array']" },
skip_failures: true
}
}
@@ -23,7 +23,7 @@
import { getDependentComponents } from '../flowExplorer'
import type { FlowCopilotContext } from '$lib/components/copilot/flow'
import { fade } from 'svelte/transition'
import { tutorialsToDo } from '$lib/stores'
import { copilotInfo, tutorialsToDo } from '$lib/stores'
import FlowTutorials from '$lib/components/FlowTutorials.svelte'
import { ignoredTutorials } from '$lib/components/tutorials/ignoredTutorials'
@@ -61,7 +61,10 @@
if (wsScript) {
;[module, state] = await pickScript(wsScript.path, wsScript.summary, module.id, wsScript.hash)
} else if (kind == 'forloop') {
;[module, state] = await createLoop(module.id)
;[module, state] = await createLoop(
module.id,
!disableAi && $copilotInfo.exists_openai_resource_path
)
} else if (kind == 'branchone') {
;[module, state] = await createBranches(module.id)
} else if (kind == 'branchall') {
@@ -161,9 +161,13 @@
return true
}
})
.map(({ rowData }) => Object.values(rowData)
.map((field) => /[\",\n]/.test(field) ? "\"" + field.replace(/"/g, "\"\"") + "\"" : row)
.join(','))
.map(({ rowData }) =>
Object.values(rowData)
.map((field) =>
/[\",\n]/.test(field) ? '"' + field.replace(/"/g, '""') + '"' : field
)
.join(',')
)
].join('\n')
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' })