2024-10-30 15:55:25 +00:00
|
|
|
import { UpdateProcess } from '../processes';
|
|
|
|
import { DefaultExecutor } from './default.executor';
|
|
|
|
|
|
|
|
// @TODO: This executor should be able to extend from ReadExecutor and CreateExecutor
|
|
|
|
export class UpdateExecutor extends DefaultExecutor {
|
2024-11-02 02:41:20 +00:00
|
|
|
constructor(
|
|
|
|
process: UpdateProcess,
|
|
|
|
identityData,
|
|
|
|
data,
|
|
|
|
identityKey: string = 'id',
|
|
|
|
) {
|
2024-10-30 15:55:25 +00:00
|
|
|
super(process);
|
|
|
|
// Set the id and data to process
|
2024-11-02 02:41:20 +00:00
|
|
|
process.identityData = identityData;
|
2024-11-01 17:51:57 +00:00
|
|
|
process.payload = data;
|
2024-11-02 02:41:20 +00:00
|
|
|
process.identityKey = identityKey;
|
2024-10-30 15:55:25 +00:00
|
|
|
}
|
|
|
|
|
2024-11-02 02:41:20 +00:00
|
|
|
static async bootstrap(
|
|
|
|
process: UpdateProcess,
|
|
|
|
identityData,
|
|
|
|
data,
|
|
|
|
identityKey: string = 'id',
|
|
|
|
) {
|
|
|
|
const executor = new UpdateExecutor(
|
|
|
|
process,
|
|
|
|
identityData,
|
|
|
|
data,
|
|
|
|
identityKey,
|
|
|
|
);
|
2024-10-30 15:55:25 +00:00
|
|
|
await executor.execute();
|
|
|
|
return executor.getOutput();
|
|
|
|
}
|
|
|
|
}
|