mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
fix(core): Fix binary data helpers (like prepareBinaryData) with task runner (#12259)
This commit is contained in:
24
packages/core/src/SerializedBuffer.ts
Normal file
24
packages/core/src/SerializedBuffer.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/** A nodejs Buffer gone through JSON.stringify */
|
||||
export type SerializedBuffer = {
|
||||
type: 'Buffer';
|
||||
data: number[]; // Array like Uint8Array, each item is uint8 (0-255)
|
||||
};
|
||||
|
||||
/** Converts the given SerializedBuffer to nodejs Buffer */
|
||||
export function toBuffer(serializedBuffer: SerializedBuffer): Buffer {
|
||||
return Buffer.from(serializedBuffer.data);
|
||||
}
|
||||
|
||||
function isObjectLiteral(item: unknown): item is { [key: string]: unknown } {
|
||||
return typeof item === 'object' && item !== null && !Array.isArray(item);
|
||||
}
|
||||
|
||||
export function isSerializedBuffer(candidate: unknown): candidate is SerializedBuffer {
|
||||
return (
|
||||
isObjectLiteral(candidate) &&
|
||||
'type' in candidate &&
|
||||
'data' in candidate &&
|
||||
candidate.type === 'Buffer' &&
|
||||
Array.isArray(candidate.data)
|
||||
);
|
||||
}
|
||||
@@ -24,3 +24,4 @@ export * from './ExecutionMetadata';
|
||||
export * from './node-execution-context';
|
||||
export * from './PartialExecutionUtils';
|
||||
export { ErrorReporter } from './error-reporter';
|
||||
export * from './SerializedBuffer';
|
||||
|
||||
Reference in New Issue
Block a user