/* eslint-disable @typescript-eslint/no-explicit-any */
import { Observable, Subject } from 'rxjs';
import { FHIR } from './event-catalogue';
import { NAPEventType } from './event-catalogue/event-type';


export interface NAPEvent {
  type: NAPEventType;
  context?: FHIR.Context[];
}

/**
 *  External interface of the events that goes forth and back
 *  over the bridge
 *  @category Public API
 */
export interface NAPMessage {
  date: string;
  id: string;
  event: NAPEvent;
}

/**
 *  External interface of the subscriber of the events from
 *  the host
 *  @category Public API
 */
export type NAPHostSubscriber = (callback: NAPMessage) => void;

/*
 *  External interfaces towards the applications or upstream SDKs
 *  consuming this SDK
 *  @category Public API
 */
export interface NAP {
  fromHost$: Observable<NAPMessage>;
  toHost$: Subject<NAPMessage>;
  errors$: Observable<NAPError>;
  subscribe: (subscriber: NAPHostSubscriber) => void;
  unsubscribe: (subscriber: NAPHostSubscriber) => void;
  send: (message: NAPMessage) => void;
}

/**
 * External interface describing errors on the NAP SDK
 * @category Public API
 */
export interface NAPError {
  id: number;
  message: string;
  isFatal: boolean;
}
