| 39 | static args = Command.args |
| 40 | |
| 41 | private async plugins({ |
| 42 | storage: { isRunning, engine }, |
| 43 | flags, |
| 44 | providerData, |
| 45 | }: { |
| 46 | storage: { |
| 47 | isRunning: boolean |
| 48 | engine: StorageEngine |
| 49 | } |
| 50 | flags: { |
| 51 | [flag: string]: any |
| 52 | } |
| 53 | providerData: ProviderData |
| 54 | }): Promise<void> { |
| 55 | const config = this.getCGConfig('cloudGraph') |
| 56 | const { plugins = {} } = config |
| 57 | for (const pluginType in plugins) { |
| 58 | if (pluginType) { |
| 59 | try { |
| 60 | // Get Plugin Interface |
| 61 | const Plugin = pluginMap[pluginType] |
| 62 | |
| 63 | // Execute Plugins by Provider |
| 64 | for (const provider in this.providers) { |
| 65 | if (provider) { |
| 66 | const { schemasMap, serviceKey } = this.providers[provider] |
| 67 | |
| 68 | // Initialize |
| 69 | const PluginInstance = new Plugin({ |
| 70 | config, |
| 71 | provider: { |
| 72 | name: provider, |
| 73 | schemasMap, |
| 74 | serviceKey, |
| 75 | }, |
| 76 | flags: flags as { [flag: string]: any }, |
| 77 | logger: this.logger, |
| 78 | }) |
| 79 | |
| 80 | // Get the Plugin Manager |
| 81 | const pluginManager = await this.getPluginManager( |
| 82 | pluginType as PluginType |
| 83 | ) |
| 84 | |
| 85 | // Configure |
| 86 | await PluginInstance.configure(pluginManager, plugins[pluginType]) |
| 87 | |
| 88 | // Execute plugins |
| 89 | await PluginInstance.execute({ |
| 90 | storageRunning: isRunning, |
| 91 | storageEngine: engine, |
| 92 | providerData, |
| 93 | processConnectionsBetweenEntities, |
| 94 | }) |
| 95 | } |
| 96 | } |
| 97 | } catch (error) { |
| 98 | this.logger.warn('Plugin not supported by CG') |