mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
feat(core): Implement lifecycle hooks to support streaming responses (no-changelog) (#16391)
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import type {
|
||||
AINodeConnectionType,
|
||||
CallbackManager,
|
||||
ChunkType,
|
||||
CloseFunction,
|
||||
IDataObject,
|
||||
IExecuteData,
|
||||
IExecuteFunctions,
|
||||
IExecuteResponsePromiseData,
|
||||
@@ -13,6 +15,7 @@ import type {
|
||||
IWorkflowExecuteAdditionalData,
|
||||
NodeExecutionHint,
|
||||
Result,
|
||||
StructuredChunk,
|
||||
Workflow,
|
||||
WorkflowExecuteMode,
|
||||
} from 'n8n-workflow';
|
||||
@@ -128,6 +131,23 @@ export class ExecuteContext extends BaseExecuteContext implements IExecuteFuncti
|
||||
)) as IExecuteFunctions['getNodeParameter'];
|
||||
}
|
||||
|
||||
async sendChunk(type: ChunkType, content?: IDataObject | string): Promise<void> {
|
||||
const node = this.getNode();
|
||||
const metadata = {
|
||||
nodeId: node.id,
|
||||
nodeName: node.name,
|
||||
timestamp: Date.now(),
|
||||
};
|
||||
|
||||
const message: StructuredChunk = {
|
||||
type,
|
||||
content: content ? JSON.stringify(content) : undefined,
|
||||
metadata,
|
||||
};
|
||||
|
||||
await this.additionalData.hooks?.runHook('sendChunk', [message]);
|
||||
}
|
||||
|
||||
async startJob<T = unknown, E = unknown>(
|
||||
jobType: string,
|
||||
settings: unknown,
|
||||
|
||||
Reference in New Issue
Block a user