import { Action } from '@ngrx/store';

import { RPCClientError } from '@loafer/ng-rpc/protocol';
import { MetaCrawler } from '@overflow/commons-typescript/model/meta';


export enum ActionType {
  ReadAll = '[meta.crawler-readall] ReadAll',
  ReadAllSuccess = '[meta.crawler-readall] ReadAllSuccess',
  ReadAllFailure = '[meta.crawler-readall] ReadAllFailure',
}

export class ReadAll implements Action {
  readonly type = ActionType.ReadAll;

  constructor() {}
}

export class ReadAllSuccess implements Action {
  readonly type = ActionType.ReadAllSuccess;

  constructor(public payload: MetaCrawler[]) {}
}

export class ReadAllFailure implements Action {
  readonly type = ActionType.ReadAllFailure;

  constructor(public payload: RPCClientError) {}
}

export type Actions =
  | ReadAll
  | ReadAllSuccess
  | ReadAllFailure

;
