feat: optimize datalink metadata display, fix field mapping schema, bill timeout and cli options
This commit is contained in:
1 parent
fbdb38bfb2
commit
a5f685045e
13 files changed
+254
-40
No files matched your search
@@ -164,6 +164,27 @@ describe("workflow-script - 本地静态语法校验与沙箱仿真引擎", () =
|
||||
expect(res.durationMs).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
|
||||
it("supports accessing variables through inputs namespace as well as top-level globals", async () => {
|
||||
const code = `
|
||||
return {
|
||||
direct: foo,
|
||||
viaNamespace: inputs.foo,
|
||||
nested: inputs.nested.value
|
||||
};
|
||||
`;
|
||||
const inputs = {
|
||||
foo: "bar",
|
||||
nested: { value: 42 }
|
||||
};
|
||||
const res = await executeJavaScriptSandbox(code, inputs);
|
||||
expect(res.success).toBe(true);
|
||||
expect(res.returnValue).toEqual({
|
||||
direct: "bar",
|
||||
viaNamespace: "bar",
|
||||
nested: 42
|
||||
});
|
||||
});
|
||||
|
||||
it("catches runtime errors and reports line number", async () => {
|
||||
const code = `
|
||||
const a = 10;
|
||||
|
||||
@@ -51,6 +51,11 @@ export async function executeJavaScriptSandbox(
|
||||
const value = vm.getProp(parsed.value, key);
|
||||
try { vm.setProp(vm.global, key, value); } finally { value.dispose(); }
|
||||
}
|
||||
// 同时挂载 inputs 命名空间,支持脚本直接通过 inputs.xxx 访问输入对象
|
||||
if (!Object.hasOwn(inputs, "inputs")) {
|
||||
const dup = parsed.value.dup();
|
||||
try { vm.setProp(vm.global, "inputs", dup); } finally { dup.dispose(); }
|
||||
}
|
||||
} finally { parsed.value.dispose(); }
|
||||
|
||||
const recordLog = (args: Parameters<typeof vm.dump>) => {
|
||||
|
||||
Reference in new issue
Block a user