Operation.ts 646 B

123456789101112131415161718192021222324252627282930313233
  1. import {
  2. Describe,
  3. Command,
  4. } from "../internal";
  5. export abstract class Operation<T = unknown> {
  6. protected _command: Command;
  7. abstract apply(resource: T): void;
  8. abstract clone(): Operation;
  9. abstract toJSON(): Operation.Serialize;
  10. public getCommand(): Command {
  11. return this._command;
  12. }
  13. public setCommand(command: Command): void {
  14. this._command = command;
  15. }
  16. public replaceOperations(...operations: Operation[]) {
  17. const command = this._command;
  18. if (command) {
  19. command.replaceOperations(this, operations);
  20. }
  21. }
  22. }
  23. export namespace Operation {
  24. export interface Serialize extends Describe {}
  25. }