mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
feat: Add once for each item support for JS task runner (no-changelog) (#11109)
This commit is contained in:
@@ -262,7 +262,7 @@ export class InformationExtractor implements INodeType {
|
||||
}
|
||||
|
||||
const zodSchemaSandbox = getSandboxWithZod(this, jsonSchema, 0);
|
||||
const zodSchema = (await zodSchemaSandbox.runCode()) as z.ZodSchema<object>;
|
||||
const zodSchema = await zodSchemaSandbox.runCode<z.ZodSchema<object>>();
|
||||
|
||||
parser = OutputFixingParser.fromLLM(llm, StructuredOutputParser.fromZodSchema(zodSchema));
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ function getSandbox(
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
|
||||
const sandbox = new JavaScriptSandbox(context, code, itemIndex, this.helpers, {
|
||||
const sandbox = new JavaScriptSandbox(context, code, this.helpers, {
|
||||
resolver: vmResolver,
|
||||
});
|
||||
|
||||
@@ -368,7 +368,7 @@ export class Code implements INodeType {
|
||||
}
|
||||
|
||||
const sandbox = getSandbox.call(this, code.supplyData.code, { itemIndex });
|
||||
const response = (await sandbox.runCode()) as Tool;
|
||||
const response = await sandbox.runCode<Tool>();
|
||||
|
||||
return {
|
||||
response: logWrapper(response, this),
|
||||
|
||||
@@ -48,7 +48,7 @@ export class N8nStructuredOutputParser<T extends z.ZodTypeAny> extends Structure
|
||||
sandboxedSchema: JavaScriptSandbox,
|
||||
nodeVersion: number,
|
||||
): Promise<StructuredOutputParser<z.ZodType<object, z.ZodTypeDef, object>>> {
|
||||
const zodSchema = (await sandboxedSchema.runCode()) as z.ZodSchema<object>;
|
||||
const zodSchema = await sandboxedSchema.runCode<z.ZodSchema<object>>();
|
||||
|
||||
let returnSchema: z.ZodSchema<object>;
|
||||
if (nodeVersion === 1) {
|
||||
|
||||
@@ -199,9 +199,9 @@ export class ToolCode implements INodeType {
|
||||
|
||||
let sandbox: Sandbox;
|
||||
if (language === 'javaScript') {
|
||||
sandbox = new JavaScriptSandbox(context, code, index, this.helpers);
|
||||
sandbox = new JavaScriptSandbox(context, code, this.helpers);
|
||||
} else {
|
||||
sandbox = new PythonSandbox(context, code, index, this.helpers);
|
||||
sandbox = new PythonSandbox(context, code, this.helpers);
|
||||
}
|
||||
|
||||
sandbox.on(
|
||||
@@ -216,7 +216,7 @@ export class ToolCode implements INodeType {
|
||||
|
||||
const runFunction = async (query: string | IDataObject): Promise<string> => {
|
||||
const sandbox = getSandbox(query, itemIndex);
|
||||
return await (sandbox.runCode() as Promise<string>);
|
||||
return await sandbox.runCode<string>();
|
||||
};
|
||||
|
||||
const toolHandler = async (query: string | IDataObject): Promise<string> => {
|
||||
@@ -274,7 +274,7 @@ export class ToolCode implements INodeType {
|
||||
: jsonParse<JSONSchema7>(inputSchema);
|
||||
|
||||
const zodSchemaSandbox = getSandboxWithZod(this, jsonSchema, 0);
|
||||
const zodSchema = (await zodSchemaSandbox.runCode()) as DynamicZodObject;
|
||||
const zodSchema = await zodSchemaSandbox.runCode<DynamicZodObject>();
|
||||
|
||||
tool = new DynamicStructuredTool<typeof zodSchema>({
|
||||
schema: zodSchema,
|
||||
|
||||
@@ -530,7 +530,7 @@ export class ToolWorkflow implements INodeType {
|
||||
: jsonParse<JSONSchema7>(inputSchema);
|
||||
|
||||
const zodSchemaSandbox = getSandboxWithZod(this, jsonSchema, 0);
|
||||
const zodSchema = (await zodSchemaSandbox.runCode()) as DynamicZodObject;
|
||||
const zodSchema = await zodSchemaSandbox.runCode<DynamicZodObject>();
|
||||
|
||||
tool = new DynamicStructuredTool<typeof zodSchema>({
|
||||
schema: zodSchema,
|
||||
|
||||
Reference in New Issue
Block a user