1
0
Fork 0
mirror of synced 2024-10-02 18:16:29 +13:00

Quick fix for automation JS scripting, make sure context is passed through correctly.

This commit is contained in:
mike12345567 2024-02-01 16:00:58 +00:00
parent f77acc1f1b
commit 6cad0e758f
2 changed files with 5 additions and 6 deletions

View file

@ -1,12 +1,12 @@
import ScriptRunner from "../../utilities/scriptRunner"
import { BBContext } from "@budibase/types"
import { Ctx } from "@budibase/types"
export async function execute(ctx: BBContext) {
export async function execute(ctx: Ctx) {
const { script, context } = ctx.request.body
const runner = new ScriptRunner(script, context)
ctx.body = runner.execute()
}
export async function save(ctx: BBContext) {
export async function save(ctx: Ctx) {
ctx.throw(501, "Not currently implemented")
}

View file

@ -1,4 +1,4 @@
import ivm, { Context, Script } from "isolated-vm"
import ivm from "isolated-vm"
const JS_TIMEOUT_MS = 1000
@ -9,8 +9,7 @@ class ScriptRunner {
const code = `let fn = () => {\n${script}\n}; results.out = fn();`
this.vm = new IsolatedVM({ memoryLimit: 8 })
this.vm.context = {
data: context.data,
params: context.params,
...context,
results: { out: "" },
}
this.vm.code = code