diff --git a/src/Data/Event.purs b/src/Data/Event.purs index b62a004..f03ff39 100644 --- a/src/Data/Event.purs +++ b/src/Data/Event.purs @@ -1,6 +1,5 @@ module Data.Event ( Event(..) - , EventType(..) , SourceID , SessionID , DestinationID @@ -9,6 +8,7 @@ module Data.Event , FeatureID , InstanceID , module Data.Event.Class + , module Data.Event.EventType , eventTypes , foreignEvent ) where @@ -25,7 +25,7 @@ import FFI.UUID (UUID) import Data.Event.Class (class EventCategory, class EventID, eventCategories, eventIDs) -data EventType = Success | Failure +import Data.Event.EventType (EventType(..)) type SourceID = UUID type SessionID = UUID @@ -52,20 +52,43 @@ data Event a b = Event (EventCategory a => EventID b => , endTime :: Date }) -instance showEventType :: Show EventType where - show Success = "SUCCESS" - show Failure = "FAILURE" +{-- todo: see https://github.com/markfarrell/3iter/issues/5 --} + +type Feature a b = (EventCategory a => EventID b => + { eventCategory :: a + , eventType :: EventType + , eventID :: b + }) + +type Identifier = + { sourceID :: SourceID + , sessionID :: SessionID + , destinationID :: DestinationID + , logID :: LogID + , schemaID :: SchemaID + } + +type Checksum = + { featureID :: FeatureID + , instanceID :: InstanceID + } + +type Period = + { startTime :: Date + , duration :: Int + , endTime :: Date + } instance showEvent :: (EventCategory a, EventID b) => Show (Event a b) where show = JSON.stringify <<< foreignEvent -derive instance eqEventType :: Eq EventType - derive instance eqEvent :: (EventCategory a, EventID b) => Eq (Event a b) eventTypes :: Array EventType eventTypes = [ Success, Failure ] +{-- todo: see https://github.com/markfarrell/3tier/issues/27 --} + foreignEvent :: forall a b. EventCategory a => EventID b => Event a b -> Foreign foreignEvent (Event x) = unsafeCoerce $ { eventCategory : show x.eventCategory diff --git a/src/Data/Event/EventType.purs b/src/Data/Event/EventType.purs new file mode 100644 index 0000000..31efaba --- /dev/null +++ b/src/Data/Event/EventType.purs @@ -0,0 +1,15 @@ +module Data.Event.EventType + ( EventType (..) + ) where + +import Prelude + +{-- todo: see https://github.com/markfarrell/3tier/issues/5 --} + +data EventType = Success | Failure + +instance showEventType :: Show EventType where + show Success = "SUCCESS" + show Failure = "FAILURE" + +derive instance eqEventType :: Eq EventType diff --git a/src/Data/Forward.purs b/src/Data/Forward.purs index 12cddfd..8778cd9 100644 --- a/src/Data/Forward.purs +++ b/src/Data/Forward.purs @@ -11,10 +11,10 @@ import Data.Linux as Linux import Data.Windows as Windows data Event = - Alert Alert.Event - | Audit Audit.Event + Alert Alert.Event + | Audit Audit.Event | Traffic Traffic.Event - | Linux Linux.Event + | Linux Linux.Event | Windows Windows.Event instance showEventForward :: Show Event where