* A convenience method for plugins that implement their own `executeMethodMap`. * Pass through to the driver's execute method if the plugin does not handle the script.
(
next: NextPluginCallback,
driver: Driver<C>,
script: string,
protoArgs: readonly [StringRecord<unknown>] | readonly unknown[],
)
| 41 | * Pass through to the driver's execute method if the plugin does not handle the script. |
| 42 | */ |
| 43 | async executeMethod<C extends Constraints>( |
| 44 | next: NextPluginCallback, |
| 45 | driver: Driver<C>, |
| 46 | script: string, |
| 47 | protoArgs: readonly [StringRecord<unknown>] | readonly unknown[], |
| 48 | ): Promise<unknown> { |
| 49 | const PluginClass = this.constructor as typeof BasePlugin; |
| 50 | const commandMetadata = {...PluginClass.executeMethodMap?.[script]}; |
| 51 | |
| 52 | if (!commandMetadata.command || !(commandMetadata.command in this)) { |
| 53 | this.log.info(`Plugin did not know how to handle method '${script}'. Passing control to next`); |
| 54 | return await next(); |
| 55 | } |
| 56 | |
| 57 | const command = this[commandMetadata.command as keyof this] as PluginCommand<ExternalDriver<C>>; |
| 58 | const args = validateExecuteMethodParams(protoArgs as unknown[], commandMetadata.params); |
| 59 | return await command.call(this, next, driver, ...args); |
| 60 | } |
| 61 | } |
nothing calls this directly
no test coverage detected