2022-01-07 08:14:59 -08:00
|
|
|
import { INodeTypes } from 'n8n-workflow';
|
2022-11-09 06:25:00 -08:00
|
|
|
import { InternalHooksClass } from '@/InternalHooks';
|
|
|
|
import { Telemetry } from '@/telemetry';
|
2021-10-18 20:57:49 -07:00
|
|
|
|
|
|
|
export class InternalHooksManager {
|
|
|
|
private static internalHooksInstance: InternalHooksClass;
|
|
|
|
|
|
|
|
static getInstance(): InternalHooksClass {
|
|
|
|
if (this.internalHooksInstance) {
|
|
|
|
return this.internalHooksInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('InternalHooks not initialized');
|
|
|
|
}
|
|
|
|
|
2023-01-04 02:38:48 -08:00
|
|
|
static async init(instanceId: string, nodeTypes: INodeTypes): Promise<InternalHooksClass> {
|
2021-10-18 20:57:49 -07:00
|
|
|
if (!this.internalHooksInstance) {
|
2023-01-04 02:38:48 -08:00
|
|
|
const telemetry = new Telemetry(instanceId);
|
2023-01-02 03:14:39 -08:00
|
|
|
await telemetry.init();
|
2023-01-04 02:38:48 -08:00
|
|
|
this.internalHooksInstance = new InternalHooksClass(telemetry, instanceId, nodeTypes);
|
2021-10-18 20:57:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return this.internalHooksInstance;
|
|
|
|
}
|
|
|
|
}
|