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

import { RPCClientError } from '@loafer/ng-rpc';
import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth';
import { MetaSensorItemKey, MetaCrawler } from '@overflow/commons-typescript/model/meta';

export enum ActionType {
  ReadAllByCrawler = '[meta.meta-sensor-item-key] ReadAllByCrawler',
  ReadAllByCrawlerSuccess = '[meta.meta-sensor-item-key] ReadAllByCrawlerSuccess',
  ReadAllByCrawlerFailure = '[meta.meta-sensor-item-key] ReadAllByCrawlerFailure',

  ReadAllMapByCrawler = '[meta.meta-sensor-item-key] ReadAllMapByCrawler',
  ReadAllMapByCrawlerSuccess = '[meta.meta-sensor-item-key] ReadAllMapByCrawlerSuccess',
  ReadAllMapByCrawlerFailure = '[meta.meta-sensor-item-key] ReadAllMapByCrawlerFailure',
}

export class ReadAllByCrawler implements Action {
  readonly type = ActionType.ReadAllByCrawler;
  constructor(public payload: MetaCrawler) {}
}

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

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

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

  constructor(public payload: RPCClientError) {}
}

export class ReadAllMapByCrawler implements Action {
  readonly type = ActionType.ReadAllMapByCrawler;
  constructor(public payload: MetaCrawler) {}
}

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

  constructor(public payload: Map<number, MetaSensorItemKey>) {}
}

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

  constructor(public payload: RPCClientError) {}
}

export type Actions =
| ReadAllByCrawler
| ReadAllByCrawlerSuccess
| ReadAllByCrawlerFailure

| ReadAllMapByCrawler
| ReadAllMapByCrawlerSuccess
| ReadAllMapByCrawlerFailure
;
