From a0f19a3fdce48c6145d3e1e4ada424b880bd68e1 Mon Sep 17 00:00:00 2001 From: Bram van den Heuvel Date: Mon, 13 Feb 2023 19:09:32 +0100 Subject: [PATCH] Refactor GetEvent API endpoint --- src/Internal/Api/All.elm | 2 +- src/Internal/Api/GetEvent/Api.elm | 12 ++- src/Internal/Api/GetEvent/Main.elm | 28 +++--- .../Api/GetEvent/{V1_2 => V1}/SpecObjects.elm | 4 +- .../GetEvent/{V1_2 => V1}/SpecObjects.yaml | 2 +- src/Internal/Api/GetEvent/V1_2/Api.elm | 17 ---- src/Internal/Api/GetEvent/V1_2/Convert.elm | 27 ------ src/Internal/Api/GetEvent/V1_2/Objects.elm | 97 ------------------- src/Internal/Api/GetEvent/V1_2/Objects.yaml | 40 -------- src/Internal/Api/GetEvent/V1_2/Upcast.elm | 18 ---- src/Internal/Api/GetEvent/V1_3/Api.elm | 18 ---- src/Internal/Api/GetEvent/V1_3/Convert.elm | 27 ------ src/Internal/Api/GetEvent/V1_3/Objects.elm | 97 ------------------- src/Internal/Api/GetEvent/V1_3/Objects.yaml | 40 -------- .../Api/GetEvent/V1_3/SpecObjects.elm | 97 ------------------- .../Api/GetEvent/V1_3/SpecObjects.yaml | 40 -------- src/Internal/Api/GetEvent/V1_3/Upcast.elm | 27 ------ src/Internal/Api/GetEvent/V1_4/Api.elm | 18 ---- src/Internal/Api/GetEvent/V1_4/Convert.elm | 27 ------ src/Internal/Api/GetEvent/V1_4/Objects.elm | 97 ------------------- src/Internal/Api/GetEvent/V1_4/Objects.yaml | 40 -------- .../Api/GetEvent/V1_4/SpecObjects.elm | 97 ------------------- .../Api/GetEvent/V1_4/SpecObjects.yaml | 40 -------- src/Internal/Api/GetEvent/V1_4/Upcast.elm | 27 ------ src/Internal/Api/GetEvent/V1_5/Api.elm | 18 ---- src/Internal/Api/GetEvent/V1_5/Convert.elm | 27 ------ src/Internal/Api/GetEvent/V1_5/Objects.elm | 97 ------------------- src/Internal/Api/GetEvent/V1_5/Objects.yaml | 40 -------- .../Api/GetEvent/V1_5/SpecObjects.elm | 97 ------------------- .../Api/GetEvent/V1_5/SpecObjects.yaml | 40 -------- src/Internal/Api/GetEvent/V1_5/Upcast.elm | 27 ------ 31 files changed, 24 insertions(+), 1261 deletions(-) rename src/Internal/Api/GetEvent/{V1_2 => V1}/SpecObjects.elm (96%) rename src/Internal/Api/GetEvent/{V1_2 => V1}/SpecObjects.yaml (98%) delete mode 100644 src/Internal/Api/GetEvent/V1_2/Api.elm delete mode 100644 src/Internal/Api/GetEvent/V1_2/Convert.elm delete mode 100644 src/Internal/Api/GetEvent/V1_2/Objects.elm delete mode 100644 src/Internal/Api/GetEvent/V1_2/Objects.yaml delete mode 100644 src/Internal/Api/GetEvent/V1_2/Upcast.elm delete mode 100644 src/Internal/Api/GetEvent/V1_3/Api.elm delete mode 100644 src/Internal/Api/GetEvent/V1_3/Convert.elm delete mode 100644 src/Internal/Api/GetEvent/V1_3/Objects.elm delete mode 100644 src/Internal/Api/GetEvent/V1_3/Objects.yaml delete mode 100644 src/Internal/Api/GetEvent/V1_3/SpecObjects.elm delete mode 100644 src/Internal/Api/GetEvent/V1_3/SpecObjects.yaml delete mode 100644 src/Internal/Api/GetEvent/V1_3/Upcast.elm delete mode 100644 src/Internal/Api/GetEvent/V1_4/Api.elm delete mode 100644 src/Internal/Api/GetEvent/V1_4/Convert.elm delete mode 100644 src/Internal/Api/GetEvent/V1_4/Objects.elm delete mode 100644 src/Internal/Api/GetEvent/V1_4/Objects.yaml delete mode 100644 src/Internal/Api/GetEvent/V1_4/SpecObjects.elm delete mode 100644 src/Internal/Api/GetEvent/V1_4/SpecObjects.yaml delete mode 100644 src/Internal/Api/GetEvent/V1_4/Upcast.elm delete mode 100644 src/Internal/Api/GetEvent/V1_5/Api.elm delete mode 100644 src/Internal/Api/GetEvent/V1_5/Convert.elm delete mode 100644 src/Internal/Api/GetEvent/V1_5/Objects.elm delete mode 100644 src/Internal/Api/GetEvent/V1_5/Objects.yaml delete mode 100644 src/Internal/Api/GetEvent/V1_5/SpecObjects.elm delete mode 100644 src/Internal/Api/GetEvent/V1_5/SpecObjects.yaml delete mode 100644 src/Internal/Api/GetEvent/V1_5/Upcast.elm diff --git a/src/Internal/Api/All.elm b/src/Internal/Api/All.elm index bc2f369..a8bb707 100644 --- a/src/Internal/Api/All.elm +++ b/src/Internal/Api/All.elm @@ -10,7 +10,7 @@ import Internal.Api.Versions.Main as Versions {-| Get a specific event from the Matrix API. -} -getEvent : List String -> GetEvent.EventInput -> GetEvent.EventOutput +getEvent : List String -> Maybe (GetEvent.EventInput -> GetEvent.EventOutput) getEvent = GetEvent.getEvent diff --git a/src/Internal/Api/GetEvent/Api.elm b/src/Internal/Api/GetEvent/Api.elm index 171c2e1..785b6be 100644 --- a/src/Internal/Api/GetEvent/Api.elm +++ b/src/Internal/Api/GetEvent/Api.elm @@ -1,8 +1,8 @@ module Internal.Api.GetEvent.Api exposing (..) +import Internal.Api.GetEvent.V1.SpecObjects as SO1 import Internal.Api.Request as R import Internal.Tools.Exceptions as X -import Json.Decode as D import Task exposing (Task) @@ -14,8 +14,12 @@ type alias GetEventInputV1 = } -getEventInputV1 : D.Decoder a -> (a -> b) -> GetEventInputV1 -> Task X.Error b -getEventInputV1 decoder mapping data = +type alias GetEventOutputV1 = + Task X.Error SO1.ClientEvent + + +getEventInputV1 : GetEventInputV1 -> GetEventOutputV1 +getEventInputV1 data = R.rawApiCall { headers = R.WithAccessToken data.accessToken , method = "GET" @@ -28,5 +32,5 @@ getEventInputV1 decoder mapping data = , queryParams = [] , bodyParams = [] , timeout = Nothing - , decoder = \_ -> D.map mapping decoder + , decoder = \_ -> SO1.clientEventDecoder } diff --git a/src/Internal/Api/GetEvent/Main.elm b/src/Internal/Api/GetEvent/Main.elm index 30d2dee..b4e6ea4 100644 --- a/src/Internal/Api/GetEvent/Main.elm +++ b/src/Internal/Api/GetEvent/Main.elm @@ -1,27 +1,23 @@ module Internal.Api.GetEvent.Main exposing (..) import Internal.Api.GetEvent.Api as Api -import Internal.Api.GetEvent.V1_2.Api as V1_2 -import Internal.Api.GetEvent.V1_3.Api as V1_3 -import Internal.Api.GetEvent.V1_4.Api as V1_4 -import Internal.Api.GetEvent.V1_5.Api as V1_5 -import Internal.Api.GetEvent.V1_5.Objects as O -import Internal.Api.VersionControl as V -import Internal.Tools.Exceptions as X -import Task exposing (Task) +import Internal.Tools.VersionControl as VC -getEvent : List String -> EventInput -> EventOutput -getEvent = - V.firstVersion V1_2.packet - |> V.updateWith V1_3.packet - |> V.updateWith V1_4.packet - |> V.updateWith V1_5.packet - |> V.toFunction +getEvent : List String -> Maybe (EventInput -> EventOutput) +getEvent versions = + VC.withBottomLayer + { current = Api.getEventInputV1 + , version = "v1.2" + } + |> VC.sameForVersion "v1.3" + |> VC.sameForVersion "v1.4" + |> VC.sameForVersion "v1.5" + |> VC.mostRecentFromVersionList versions type alias EventOutput = - Task X.Error O.ClientEvent + Api.GetEventOutputV1 type alias EventInput = diff --git a/src/Internal/Api/GetEvent/V1_2/SpecObjects.elm b/src/Internal/Api/GetEvent/V1/SpecObjects.elm similarity index 96% rename from src/Internal/Api/GetEvent/V1_2/SpecObjects.elm rename to src/Internal/Api/GetEvent/V1/SpecObjects.elm index 2975564..fc30d61 100644 --- a/src/Internal/Api/GetEvent/V1_2/SpecObjects.elm +++ b/src/Internal/Api/GetEvent/V1/SpecObjects.elm @@ -1,4 +1,4 @@ -module Internal.Api.GetEvent.V1_2.SpecObjects exposing +module Internal.Api.GetEvent.V1.SpecObjects exposing ( ClientEvent , UnsignedData(..) , clientEventDecoder @@ -9,7 +9,7 @@ module Internal.Api.GetEvent.V1_2.SpecObjects exposing {-| Automatically generated 'SpecObjects' -Last generated at Unix time 1673279712 +Last generated at Unix time 1676311233 -} diff --git a/src/Internal/Api/GetEvent/V1_2/SpecObjects.yaml b/src/Internal/Api/GetEvent/V1/SpecObjects.yaml similarity index 98% rename from src/Internal/Api/GetEvent/V1_2/SpecObjects.yaml rename to src/Internal/Api/GetEvent/V1/SpecObjects.yaml index 8d8bb95..8baed65 100644 --- a/src/Internal/Api/GetEvent/V1_2/SpecObjects.yaml +++ b/src/Internal/Api/GetEvent/V1/SpecObjects.yaml @@ -1,4 +1,4 @@ -version: v1.2 +version: v1 name: SpecObjects objects: ClientEvent: diff --git a/src/Internal/Api/GetEvent/V1_2/Api.elm b/src/Internal/Api/GetEvent/V1_2/Api.elm deleted file mode 100644 index 3b67d65..0000000 --- a/src/Internal/Api/GetEvent/V1_2/Api.elm +++ /dev/null @@ -1,17 +0,0 @@ -module Internal.Api.GetEvent.V1_2.Api exposing (..) - -import Internal.Api.GetEvent.Api as Api -import Internal.Api.GetEvent.V1_2.Convert as C -import Internal.Api.GetEvent.V1_2.Objects as O -import Internal.Api.GetEvent.V1_2.SpecObjects as SO -import Internal.Api.GetEvent.V1_2.Upcast as U -import Internal.Api.VersionControl as V - - -packet : V.SingleVersion () () Api.GetEventInputV1 O.ClientEvent -packet = - { version = "v1.2" - , downcast = \_ -> () - , current = Api.getEventInputV1 SO.clientEventDecoder C.convert - , upcast = U.upcast - } diff --git a/src/Internal/Api/GetEvent/V1_2/Convert.elm b/src/Internal/Api/GetEvent/V1_2/Convert.elm deleted file mode 100644 index 7a99460..0000000 --- a/src/Internal/Api/GetEvent/V1_2/Convert.elm +++ /dev/null @@ -1,27 +0,0 @@ -module Internal.Api.GetEvent.V1_2.Convert exposing (..) - -import Internal.Api.GetEvent.V1_2.Objects as O -import Internal.Api.GetEvent.V1_2.SpecObjects as SO - - -convert : SO.ClientEvent -> O.ClientEvent -convert e = - { content = e.content - , eventId = e.eventId - , originServerTs = e.originServerTs - , roomId = e.roomId - , sender = e.sender - , stateKey = e.stateKey - , contentType = e.contentType - , unsigned = Maybe.map convertUnsigned e.unsigned - } - - -convertUnsigned : SO.UnsignedData -> O.UnsignedData -convertUnsigned (SO.UnsignedData u) = - O.UnsignedData - { age = u.age - , prevContent = u.prevContent - , redactedBecause = Maybe.map convert u.redactedBecause - , transactionId = u.transactionId - } diff --git a/src/Internal/Api/GetEvent/V1_2/Objects.elm b/src/Internal/Api/GetEvent/V1_2/Objects.elm deleted file mode 100644 index bcf112a..0000000 --- a/src/Internal/Api/GetEvent/V1_2/Objects.elm +++ /dev/null @@ -1,97 +0,0 @@ -module Internal.Api.GetEvent.V1_2.Objects exposing - ( ClientEvent - , UnsignedData(..) - , clientEventDecoder - , encodeClientEvent - , encodeUnsignedData - , unsignedDataDecoder - ) - -{-| Automatically generated 'Objects' - -Last generated at Unix time 1673279712 - --} - -import Internal.Tools.DecodeExtra exposing (opField) -import Internal.Tools.EncodeExtra exposing (maybeObject) -import Internal.Tools.Timestamp exposing (Timestamp, encodeTimestamp, timestampDecoder) -import Json.Decode as D -import Json.Encode as E - - -{-| Client Event containing all data on an event. --} -type alias ClientEvent = - { content : E.Value - , eventId : String - , originServerTs : Timestamp - , roomId : String - , sender : String - , stateKey : Maybe String - , contentType : String - , unsigned : Maybe UnsignedData - } - - -encodeClientEvent : ClientEvent -> E.Value -encodeClientEvent data = - maybeObject - [ ( "content", Just <| data.content ) - , ( "event_id", Just <| E.string data.eventId ) - , ( "origin_server_ts", Just <| encodeTimestamp data.originServerTs ) - , ( "room_id", Just <| E.string data.roomId ) - , ( "sender", Just <| E.string data.sender ) - , ( "state_key", Maybe.map E.string data.stateKey ) - , ( "type", Just <| E.string data.contentType ) - , ( "unsigned", Maybe.map encodeUnsignedData data.unsigned ) - ] - - -clientEventDecoder : D.Decoder ClientEvent -clientEventDecoder = - D.map8 - (\a b c d e f g h -> - { content = a, eventId = b, originServerTs = c, roomId = d, sender = e, stateKey = f, contentType = g, unsigned = h } - ) - (D.field "content" D.value) - (D.field "event_id" D.string) - (D.field "origin_server_ts" timestampDecoder) - (D.field "room_id" D.string) - (D.field "sender" D.string) - (opField "state_key" D.string) - (D.field "type" D.string) - (opField "unsigned" (D.lazy (\_ -> unsignedDataDecoder))) - - -{-| Extra information about the event. --} -type UnsignedData - = UnsignedData - { age : Maybe Int - , prevContent : Maybe E.Value - , redactedBecause : Maybe ClientEvent - , transactionId : Maybe String - } - - -encodeUnsignedData : UnsignedData -> E.Value -encodeUnsignedData (UnsignedData data) = - maybeObject - [ ( "age", Maybe.map E.int data.age ) - , ( "prev_content", data.prevContent ) - , ( "redacted_because", Maybe.map encodeClientEvent data.redactedBecause ) - , ( "transaction_id", Maybe.map E.string data.transactionId ) - ] - - -unsignedDataDecoder : D.Decoder UnsignedData -unsignedDataDecoder = - D.map4 - (\a b c d -> - UnsignedData { age = a, prevContent = b, redactedBecause = c, transactionId = d } - ) - (opField "age" D.int) - (opField "prev_content" D.value) - (opField "redacted_because" clientEventDecoder) - (opField "transaction_id" D.string) diff --git a/src/Internal/Api/GetEvent/V1_2/Objects.yaml b/src/Internal/Api/GetEvent/V1_2/Objects.yaml deleted file mode 100644 index eebe4b0..0000000 --- a/src/Internal/Api/GetEvent/V1_2/Objects.yaml +++ /dev/null @@ -1,40 +0,0 @@ -version: v1.2 -name: Objects -objects: - ClientEvent: - description: Client Event containing all data on an event. - fields: - content: - type: value - required: true - event_id: - type: string - required: true - origin_server_ts: - type: timestamp - required: true - room_id: - type: string - required: true - sender: - type: string - required: true - state_key: - type: string - type: - type: string - required: true - unsigned: - type: UnsignedData - UnsignedData: - anti_recursion: true - description: Extra information about the event. - fields: - age: - type: int - prev_content: - type: value - redacted_because: - type: ClientEvent - transaction_id: - type: string diff --git a/src/Internal/Api/GetEvent/V1_2/Upcast.elm b/src/Internal/Api/GetEvent/V1_2/Upcast.elm deleted file mode 100644 index e7db279..0000000 --- a/src/Internal/Api/GetEvent/V1_2/Upcast.elm +++ /dev/null @@ -1,18 +0,0 @@ -module Internal.Api.GetEvent.V1_2.Upcast exposing (..) - -import Internal.Api.GetEvent.V1_2.Objects as O -import Internal.Config.Leaking as L -import Json.Encode as E - - -upcast : () -> O.ClientEvent -upcast _ = - { content = E.object [] - , eventId = L.eventId - , originServerTs = L.originServerTs - , roomId = L.roomId - , sender = L.sender - , stateKey = Nothing - , contentType = L.eventType - , unsigned = Nothing - } diff --git a/src/Internal/Api/GetEvent/V1_3/Api.elm b/src/Internal/Api/GetEvent/V1_3/Api.elm deleted file mode 100644 index cd824e4..0000000 --- a/src/Internal/Api/GetEvent/V1_3/Api.elm +++ /dev/null @@ -1,18 +0,0 @@ -module Internal.Api.GetEvent.V1_3.Api exposing (..) - -import Internal.Api.GetEvent.Api as Api -import Internal.Api.GetEvent.V1_2.Objects as PO -import Internal.Api.GetEvent.V1_3.Convert as C -import Internal.Api.GetEvent.V1_3.Objects as O -import Internal.Api.GetEvent.V1_3.SpecObjects as SO -import Internal.Api.GetEvent.V1_3.Upcast as U -import Internal.Api.VersionControl as V - - -packet : V.SingleVersion Api.GetEventInputV1 PO.ClientEvent Api.GetEventInputV1 O.ClientEvent -packet = - { version = "v1.3" - , downcast = identity - , current = Api.getEventInputV1 SO.clientEventDecoder C.convert - , upcast = U.upcast - } diff --git a/src/Internal/Api/GetEvent/V1_3/Convert.elm b/src/Internal/Api/GetEvent/V1_3/Convert.elm deleted file mode 100644 index 146b6d4..0000000 --- a/src/Internal/Api/GetEvent/V1_3/Convert.elm +++ /dev/null @@ -1,27 +0,0 @@ -module Internal.Api.GetEvent.V1_3.Convert exposing (..) - -import Internal.Api.GetEvent.V1_3.Objects as O -import Internal.Api.GetEvent.V1_3.SpecObjects as SO - - -convert : SO.ClientEvent -> O.ClientEvent -convert e = - { content = e.content - , eventId = e.eventId - , originServerTs = e.originServerTs - , roomId = e.roomId - , sender = e.sender - , stateKey = e.stateKey - , contentType = e.contentType - , unsigned = Maybe.map convertUnsigned e.unsigned - } - - -convertUnsigned : SO.UnsignedData -> O.UnsignedData -convertUnsigned (SO.UnsignedData u) = - O.UnsignedData - { age = u.age - , prevContent = u.prevContent - , redactedBecause = Maybe.map convert u.redactedBecause - , transactionId = u.transactionId - } diff --git a/src/Internal/Api/GetEvent/V1_3/Objects.elm b/src/Internal/Api/GetEvent/V1_3/Objects.elm deleted file mode 100644 index dc61b95..0000000 --- a/src/Internal/Api/GetEvent/V1_3/Objects.elm +++ /dev/null @@ -1,97 +0,0 @@ -module Internal.Api.GetEvent.V1_3.Objects exposing - ( ClientEvent - , UnsignedData(..) - , clientEventDecoder - , encodeClientEvent - , encodeUnsignedData - , unsignedDataDecoder - ) - -{-| Automatically generated 'Objects' - -Last generated at Unix time 1673279712 - --} - -import Internal.Tools.DecodeExtra exposing (opField) -import Internal.Tools.EncodeExtra exposing (maybeObject) -import Internal.Tools.Timestamp exposing (Timestamp, encodeTimestamp, timestampDecoder) -import Json.Decode as D -import Json.Encode as E - - -{-| Client Event containing all data on an event. --} -type alias ClientEvent = - { content : E.Value - , eventId : String - , originServerTs : Timestamp - , roomId : String - , sender : String - , stateKey : Maybe String - , contentType : String - , unsigned : Maybe UnsignedData - } - - -encodeClientEvent : ClientEvent -> E.Value -encodeClientEvent data = - maybeObject - [ ( "content", Just <| data.content ) - , ( "event_id", Just <| E.string data.eventId ) - , ( "origin_server_ts", Just <| encodeTimestamp data.originServerTs ) - , ( "room_id", Just <| E.string data.roomId ) - , ( "sender", Just <| E.string data.sender ) - , ( "state_key", Maybe.map E.string data.stateKey ) - , ( "type", Just <| E.string data.contentType ) - , ( "unsigned", Maybe.map encodeUnsignedData data.unsigned ) - ] - - -clientEventDecoder : D.Decoder ClientEvent -clientEventDecoder = - D.map8 - (\a b c d e f g h -> - { content = a, eventId = b, originServerTs = c, roomId = d, sender = e, stateKey = f, contentType = g, unsigned = h } - ) - (D.field "content" D.value) - (D.field "event_id" D.string) - (D.field "origin_server_ts" timestampDecoder) - (D.field "room_id" D.string) - (D.field "sender" D.string) - (opField "state_key" D.string) - (D.field "type" D.string) - (opField "unsigned" (D.lazy (\_ -> unsignedDataDecoder))) - - -{-| Extra information about the event. --} -type UnsignedData - = UnsignedData - { age : Maybe Int - , prevContent : Maybe E.Value - , redactedBecause : Maybe ClientEvent - , transactionId : Maybe String - } - - -encodeUnsignedData : UnsignedData -> E.Value -encodeUnsignedData (UnsignedData data) = - maybeObject - [ ( "age", Maybe.map E.int data.age ) - , ( "prev_content", data.prevContent ) - , ( "redacted_because", Maybe.map encodeClientEvent data.redactedBecause ) - , ( "transaction_id", Maybe.map E.string data.transactionId ) - ] - - -unsignedDataDecoder : D.Decoder UnsignedData -unsignedDataDecoder = - D.map4 - (\a b c d -> - UnsignedData { age = a, prevContent = b, redactedBecause = c, transactionId = d } - ) - (opField "age" D.int) - (opField "prev_content" D.value) - (opField "redacted_because" clientEventDecoder) - (opField "transaction_id" D.string) diff --git a/src/Internal/Api/GetEvent/V1_3/Objects.yaml b/src/Internal/Api/GetEvent/V1_3/Objects.yaml deleted file mode 100644 index e4a9d82..0000000 --- a/src/Internal/Api/GetEvent/V1_3/Objects.yaml +++ /dev/null @@ -1,40 +0,0 @@ -version: v1.3 -name: Objects -objects: - ClientEvent: - description: Client Event containing all data on an event. - fields: - content: - type: value - required: true - event_id: - type: string - required: true - origin_server_ts: - type: timestamp - required: true - room_id: - type: string - required: true - sender: - type: string - required: true - state_key: - type: string - type: - type: string - required: true - unsigned: - type: UnsignedData - UnsignedData: - anti_recursion: true - description: Extra information about the event. - fields: - age: - type: int - prev_content: - type: value - redacted_because: - type: ClientEvent - transaction_id: - type: string diff --git a/src/Internal/Api/GetEvent/V1_3/SpecObjects.elm b/src/Internal/Api/GetEvent/V1_3/SpecObjects.elm deleted file mode 100644 index 1a873a3..0000000 --- a/src/Internal/Api/GetEvent/V1_3/SpecObjects.elm +++ /dev/null @@ -1,97 +0,0 @@ -module Internal.Api.GetEvent.V1_3.SpecObjects exposing - ( ClientEvent - , UnsignedData(..) - , clientEventDecoder - , encodeClientEvent - , encodeUnsignedData - , unsignedDataDecoder - ) - -{-| Automatically generated 'SpecObjects' - -Last generated at Unix time 1673279712 - --} - -import Internal.Tools.DecodeExtra exposing (opField) -import Internal.Tools.EncodeExtra exposing (maybeObject) -import Internal.Tools.Timestamp exposing (Timestamp, encodeTimestamp, timestampDecoder) -import Json.Decode as D -import Json.Encode as E - - -{-| Client Event containing all data on an event. --} -type alias ClientEvent = - { content : E.Value - , eventId : String - , originServerTs : Timestamp - , roomId : String - , sender : String - , stateKey : Maybe String - , contentType : String - , unsigned : Maybe UnsignedData - } - - -encodeClientEvent : ClientEvent -> E.Value -encodeClientEvent data = - maybeObject - [ ( "content", Just <| data.content ) - , ( "event_id", Just <| E.string data.eventId ) - , ( "origin_server_ts", Just <| encodeTimestamp data.originServerTs ) - , ( "room_id", Just <| E.string data.roomId ) - , ( "sender", Just <| E.string data.sender ) - , ( "state_key", Maybe.map E.string data.stateKey ) - , ( "type", Just <| E.string data.contentType ) - , ( "unsigned", Maybe.map encodeUnsignedData data.unsigned ) - ] - - -clientEventDecoder : D.Decoder ClientEvent -clientEventDecoder = - D.map8 - (\a b c d e f g h -> - { content = a, eventId = b, originServerTs = c, roomId = d, sender = e, stateKey = f, contentType = g, unsigned = h } - ) - (D.field "content" D.value) - (D.field "event_id" D.string) - (D.field "origin_server_ts" timestampDecoder) - (D.field "room_id" D.string) - (D.field "sender" D.string) - (opField "state_key" D.string) - (D.field "type" D.string) - (opField "unsigned" (D.lazy (\_ -> unsignedDataDecoder))) - - -{-| Extra information about the event. --} -type UnsignedData - = UnsignedData - { age : Maybe Int - , prevContent : Maybe E.Value - , redactedBecause : Maybe ClientEvent - , transactionId : Maybe String - } - - -encodeUnsignedData : UnsignedData -> E.Value -encodeUnsignedData (UnsignedData data) = - maybeObject - [ ( "age", Maybe.map E.int data.age ) - , ( "prev_content", data.prevContent ) - , ( "redacted_because", Maybe.map encodeClientEvent data.redactedBecause ) - , ( "transaction_id", Maybe.map E.string data.transactionId ) - ] - - -unsignedDataDecoder : D.Decoder UnsignedData -unsignedDataDecoder = - D.map4 - (\a b c d -> - UnsignedData { age = a, prevContent = b, redactedBecause = c, transactionId = d } - ) - (opField "age" D.int) - (opField "prev_content" D.value) - (opField "redacted_because" clientEventDecoder) - (opField "transaction_id" D.string) diff --git a/src/Internal/Api/GetEvent/V1_3/SpecObjects.yaml b/src/Internal/Api/GetEvent/V1_3/SpecObjects.yaml deleted file mode 100644 index aa903c7..0000000 --- a/src/Internal/Api/GetEvent/V1_3/SpecObjects.yaml +++ /dev/null @@ -1,40 +0,0 @@ -version: v1.3 -name: SpecObjects -objects: - ClientEvent: - description: Client Event containing all data on an event. - fields: - content: - type: value - required: true - event_id: - type: string - required: true - origin_server_ts: - type: timestamp - required: true - room_id: - type: string - required: true - sender: - type: string - required: true - state_key: - type: string - type: - type: string - required: true - unsigned: - type: UnsignedData - UnsignedData: - anti_recursion: true - description: Extra information about the event. - fields: - age: - type: int - prev_content: - type: value - redacted_because: - type: ClientEvent - transaction_id: - type: string diff --git a/src/Internal/Api/GetEvent/V1_3/Upcast.elm b/src/Internal/Api/GetEvent/V1_3/Upcast.elm deleted file mode 100644 index ebf6159..0000000 --- a/src/Internal/Api/GetEvent/V1_3/Upcast.elm +++ /dev/null @@ -1,27 +0,0 @@ -module Internal.Api.GetEvent.V1_3.Upcast exposing (..) - -import Internal.Api.GetEvent.V1_2.Objects as PO -import Internal.Api.GetEvent.V1_3.Objects as O - - -upcast : PO.ClientEvent -> O.ClientEvent -upcast e = - { content = e.content - , eventId = e.eventId - , originServerTs = e.originServerTs - , roomId = e.roomId - , sender = e.sender - , stateKey = e.stateKey - , contentType = e.contentType - , unsigned = Maybe.map upcastUnsigned e.unsigned - } - - -upcastUnsigned : PO.UnsignedData -> O.UnsignedData -upcastUnsigned (PO.UnsignedData u) = - O.UnsignedData - { age = u.age - , prevContent = u.prevContent - , redactedBecause = Maybe.map upcast u.redactedBecause - , transactionId = u.transactionId - } diff --git a/src/Internal/Api/GetEvent/V1_4/Api.elm b/src/Internal/Api/GetEvent/V1_4/Api.elm deleted file mode 100644 index 1c6a043..0000000 --- a/src/Internal/Api/GetEvent/V1_4/Api.elm +++ /dev/null @@ -1,18 +0,0 @@ -module Internal.Api.GetEvent.V1_4.Api exposing (..) - -import Internal.Api.GetEvent.Api as Api -import Internal.Api.GetEvent.V1_3.Objects as PO -import Internal.Api.GetEvent.V1_4.Convert as C -import Internal.Api.GetEvent.V1_4.Objects as O -import Internal.Api.GetEvent.V1_4.SpecObjects as SO -import Internal.Api.GetEvent.V1_4.Upcast as U -import Internal.Api.VersionControl as V - - -packet : V.SingleVersion Api.GetEventInputV1 PO.ClientEvent Api.GetEventInputV1 O.ClientEvent -packet = - { version = "v1.4" - , downcast = identity - , current = Api.getEventInputV1 SO.clientEventDecoder C.convert - , upcast = U.upcast - } diff --git a/src/Internal/Api/GetEvent/V1_4/Convert.elm b/src/Internal/Api/GetEvent/V1_4/Convert.elm deleted file mode 100644 index 8c65a32..0000000 --- a/src/Internal/Api/GetEvent/V1_4/Convert.elm +++ /dev/null @@ -1,27 +0,0 @@ -module Internal.Api.GetEvent.V1_4.Convert exposing (..) - -import Internal.Api.GetEvent.V1_4.Objects as O -import Internal.Api.GetEvent.V1_4.SpecObjects as SO - - -convert : SO.ClientEvent -> O.ClientEvent -convert e = - { content = e.content - , eventId = e.eventId - , originServerTs = e.originServerTs - , roomId = e.roomId - , sender = e.sender - , stateKey = e.stateKey - , contentType = e.contentType - , unsigned = Maybe.map convertUnsigned e.unsigned - } - - -convertUnsigned : SO.UnsignedData -> O.UnsignedData -convertUnsigned (SO.UnsignedData u) = - O.UnsignedData - { age = u.age - , prevContent = u.prevContent - , redactedBecause = Maybe.map convert u.redactedBecause - , transactionId = u.transactionId - } diff --git a/src/Internal/Api/GetEvent/V1_4/Objects.elm b/src/Internal/Api/GetEvent/V1_4/Objects.elm deleted file mode 100644 index 3c9f675..0000000 --- a/src/Internal/Api/GetEvent/V1_4/Objects.elm +++ /dev/null @@ -1,97 +0,0 @@ -module Internal.Api.GetEvent.V1_4.Objects exposing - ( ClientEvent - , UnsignedData(..) - , clientEventDecoder - , encodeClientEvent - , encodeUnsignedData - , unsignedDataDecoder - ) - -{-| Automatically generated 'Objects' - -Last generated at Unix time 1673279712 - --} - -import Internal.Tools.DecodeExtra exposing (opField) -import Internal.Tools.EncodeExtra exposing (maybeObject) -import Internal.Tools.Timestamp exposing (Timestamp, encodeTimestamp, timestampDecoder) -import Json.Decode as D -import Json.Encode as E - - -{-| Client Event containing all data on an event. --} -type alias ClientEvent = - { content : E.Value - , eventId : String - , originServerTs : Timestamp - , roomId : String - , sender : String - , stateKey : Maybe String - , contentType : String - , unsigned : Maybe UnsignedData - } - - -encodeClientEvent : ClientEvent -> E.Value -encodeClientEvent data = - maybeObject - [ ( "content", Just <| data.content ) - , ( "event_id", Just <| E.string data.eventId ) - , ( "origin_server_ts", Just <| encodeTimestamp data.originServerTs ) - , ( "room_id", Just <| E.string data.roomId ) - , ( "sender", Just <| E.string data.sender ) - , ( "state_key", Maybe.map E.string data.stateKey ) - , ( "type", Just <| E.string data.contentType ) - , ( "unsigned", Maybe.map encodeUnsignedData data.unsigned ) - ] - - -clientEventDecoder : D.Decoder ClientEvent -clientEventDecoder = - D.map8 - (\a b c d e f g h -> - { content = a, eventId = b, originServerTs = c, roomId = d, sender = e, stateKey = f, contentType = g, unsigned = h } - ) - (D.field "content" D.value) - (D.field "event_id" D.string) - (D.field "origin_server_ts" timestampDecoder) - (D.field "room_id" D.string) - (D.field "sender" D.string) - (opField "state_key" D.string) - (D.field "type" D.string) - (opField "unsigned" (D.lazy (\_ -> unsignedDataDecoder))) - - -{-| Extra information about the event. --} -type UnsignedData - = UnsignedData - { age : Maybe Int - , prevContent : Maybe E.Value - , redactedBecause : Maybe ClientEvent - , transactionId : Maybe String - } - - -encodeUnsignedData : UnsignedData -> E.Value -encodeUnsignedData (UnsignedData data) = - maybeObject - [ ( "age", Maybe.map E.int data.age ) - , ( "prev_content", data.prevContent ) - , ( "redacted_because", Maybe.map encodeClientEvent data.redactedBecause ) - , ( "transaction_id", Maybe.map E.string data.transactionId ) - ] - - -unsignedDataDecoder : D.Decoder UnsignedData -unsignedDataDecoder = - D.map4 - (\a b c d -> - UnsignedData { age = a, prevContent = b, redactedBecause = c, transactionId = d } - ) - (opField "age" D.int) - (opField "prev_content" D.value) - (opField "redacted_because" clientEventDecoder) - (opField "transaction_id" D.string) diff --git a/src/Internal/Api/GetEvent/V1_4/Objects.yaml b/src/Internal/Api/GetEvent/V1_4/Objects.yaml deleted file mode 100644 index 9c4f25c..0000000 --- a/src/Internal/Api/GetEvent/V1_4/Objects.yaml +++ /dev/null @@ -1,40 +0,0 @@ -version: v1.4 -name: Objects -objects: - ClientEvent: - description: Client Event containing all data on an event. - fields: - content: - type: value - required: true - event_id: - type: string - required: true - origin_server_ts: - type: timestamp - required: true - room_id: - type: string - required: true - sender: - type: string - required: true - state_key: - type: string - type: - type: string - required: true - unsigned: - type: UnsignedData - UnsignedData: - anti_recursion: true - description: Extra information about the event. - fields: - age: - type: int - prev_content: - type: value - redacted_because: - type: ClientEvent - transaction_id: - type: string diff --git a/src/Internal/Api/GetEvent/V1_4/SpecObjects.elm b/src/Internal/Api/GetEvent/V1_4/SpecObjects.elm deleted file mode 100644 index bc83a03..0000000 --- a/src/Internal/Api/GetEvent/V1_4/SpecObjects.elm +++ /dev/null @@ -1,97 +0,0 @@ -module Internal.Api.GetEvent.V1_4.SpecObjects exposing - ( ClientEvent - , UnsignedData(..) - , clientEventDecoder - , encodeClientEvent - , encodeUnsignedData - , unsignedDataDecoder - ) - -{-| Automatically generated 'SpecObjects' - -Last generated at Unix time 1673279712 - --} - -import Internal.Tools.DecodeExtra exposing (opField) -import Internal.Tools.EncodeExtra exposing (maybeObject) -import Internal.Tools.Timestamp exposing (Timestamp, encodeTimestamp, timestampDecoder) -import Json.Decode as D -import Json.Encode as E - - -{-| Client Event containing all data on an event. --} -type alias ClientEvent = - { content : E.Value - , eventId : String - , originServerTs : Timestamp - , roomId : String - , sender : String - , stateKey : Maybe String - , contentType : String - , unsigned : Maybe UnsignedData - } - - -encodeClientEvent : ClientEvent -> E.Value -encodeClientEvent data = - maybeObject - [ ( "content", Just <| data.content ) - , ( "event_id", Just <| E.string data.eventId ) - , ( "origin_server_ts", Just <| encodeTimestamp data.originServerTs ) - , ( "room_id", Just <| E.string data.roomId ) - , ( "sender", Just <| E.string data.sender ) - , ( "state_key", Maybe.map E.string data.stateKey ) - , ( "type", Just <| E.string data.contentType ) - , ( "unsigned", Maybe.map encodeUnsignedData data.unsigned ) - ] - - -clientEventDecoder : D.Decoder ClientEvent -clientEventDecoder = - D.map8 - (\a b c d e f g h -> - { content = a, eventId = b, originServerTs = c, roomId = d, sender = e, stateKey = f, contentType = g, unsigned = h } - ) - (D.field "content" D.value) - (D.field "event_id" D.string) - (D.field "origin_server_ts" timestampDecoder) - (D.field "room_id" D.string) - (D.field "sender" D.string) - (opField "state_key" D.string) - (D.field "type" D.string) - (opField "unsigned" (D.lazy (\_ -> unsignedDataDecoder))) - - -{-| Extra information about the event. --} -type UnsignedData - = UnsignedData - { age : Maybe Int - , prevContent : Maybe E.Value - , redactedBecause : Maybe ClientEvent - , transactionId : Maybe String - } - - -encodeUnsignedData : UnsignedData -> E.Value -encodeUnsignedData (UnsignedData data) = - maybeObject - [ ( "age", Maybe.map E.int data.age ) - , ( "prev_content", data.prevContent ) - , ( "redacted_because", Maybe.map encodeClientEvent data.redactedBecause ) - , ( "transaction_id", Maybe.map E.string data.transactionId ) - ] - - -unsignedDataDecoder : D.Decoder UnsignedData -unsignedDataDecoder = - D.map4 - (\a b c d -> - UnsignedData { age = a, prevContent = b, redactedBecause = c, transactionId = d } - ) - (opField "age" D.int) - (opField "prev_content" D.value) - (opField "redacted_because" clientEventDecoder) - (opField "transaction_id" D.string) diff --git a/src/Internal/Api/GetEvent/V1_4/SpecObjects.yaml b/src/Internal/Api/GetEvent/V1_4/SpecObjects.yaml deleted file mode 100644 index 77270ef..0000000 --- a/src/Internal/Api/GetEvent/V1_4/SpecObjects.yaml +++ /dev/null @@ -1,40 +0,0 @@ -version: v1.4 -name: SpecObjects -objects: - ClientEvent: - description: Client Event containing all data on an event. - fields: - content: - type: value - required: true - event_id: - type: string - required: true - origin_server_ts: - type: timestamp - required: true - room_id: - type: string - required: true - sender: - type: string - required: true - state_key: - type: string - type: - type: string - required: true - unsigned: - type: UnsignedData - UnsignedData: - anti_recursion: true - description: Extra information about the event. - fields: - age: - type: int - prev_content: - type: value - redacted_because: - type: ClientEvent - transaction_id: - type: string diff --git a/src/Internal/Api/GetEvent/V1_4/Upcast.elm b/src/Internal/Api/GetEvent/V1_4/Upcast.elm deleted file mode 100644 index ac901d9..0000000 --- a/src/Internal/Api/GetEvent/V1_4/Upcast.elm +++ /dev/null @@ -1,27 +0,0 @@ -module Internal.Api.GetEvent.V1_4.Upcast exposing (..) - -import Internal.Api.GetEvent.V1_3.Objects as PO -import Internal.Api.GetEvent.V1_4.Objects as O - - -upcast : PO.ClientEvent -> O.ClientEvent -upcast e = - { content = e.content - , eventId = e.eventId - , originServerTs = e.originServerTs - , roomId = e.roomId - , sender = e.sender - , stateKey = e.stateKey - , contentType = e.contentType - , unsigned = Maybe.map upcastUnsigned e.unsigned - } - - -upcastUnsigned : PO.UnsignedData -> O.UnsignedData -upcastUnsigned (PO.UnsignedData u) = - O.UnsignedData - { age = u.age - , prevContent = u.prevContent - , redactedBecause = Maybe.map upcast u.redactedBecause - , transactionId = u.transactionId - } diff --git a/src/Internal/Api/GetEvent/V1_5/Api.elm b/src/Internal/Api/GetEvent/V1_5/Api.elm deleted file mode 100644 index f139e90..0000000 --- a/src/Internal/Api/GetEvent/V1_5/Api.elm +++ /dev/null @@ -1,18 +0,0 @@ -module Internal.Api.GetEvent.V1_5.Api exposing (..) - -import Internal.Api.GetEvent.Api as Api -import Internal.Api.GetEvent.V1_4.Objects as PO -import Internal.Api.GetEvent.V1_5.Convert as C -import Internal.Api.GetEvent.V1_5.Objects as O -import Internal.Api.GetEvent.V1_5.SpecObjects as SO -import Internal.Api.GetEvent.V1_5.Upcast as U -import Internal.Api.VersionControl as V - - -packet : V.SingleVersion Api.GetEventInputV1 PO.ClientEvent Api.GetEventInputV1 O.ClientEvent -packet = - { version = "v1.5" - , downcast = identity - , current = Api.getEventInputV1 SO.clientEventDecoder C.convert - , upcast = U.upcast - } diff --git a/src/Internal/Api/GetEvent/V1_5/Convert.elm b/src/Internal/Api/GetEvent/V1_5/Convert.elm deleted file mode 100644 index de1f972..0000000 --- a/src/Internal/Api/GetEvent/V1_5/Convert.elm +++ /dev/null @@ -1,27 +0,0 @@ -module Internal.Api.GetEvent.V1_5.Convert exposing (..) - -import Internal.Api.GetEvent.V1_5.Objects as O -import Internal.Api.GetEvent.V1_5.SpecObjects as SO - - -convert : SO.ClientEvent -> O.ClientEvent -convert e = - { content = e.content - , eventId = e.eventId - , originServerTs = e.originServerTs - , roomId = e.roomId - , sender = e.sender - , stateKey = e.stateKey - , contentType = e.contentType - , unsigned = Maybe.map convertUnsigned e.unsigned - } - - -convertUnsigned : SO.UnsignedData -> O.UnsignedData -convertUnsigned (SO.UnsignedData u) = - O.UnsignedData - { age = u.age - , prevContent = u.prevContent - , redactedBecause = Maybe.map convert u.redactedBecause - , transactionId = u.transactionId - } diff --git a/src/Internal/Api/GetEvent/V1_5/Objects.elm b/src/Internal/Api/GetEvent/V1_5/Objects.elm deleted file mode 100644 index 3044dba..0000000 --- a/src/Internal/Api/GetEvent/V1_5/Objects.elm +++ /dev/null @@ -1,97 +0,0 @@ -module Internal.Api.GetEvent.V1_5.Objects exposing - ( ClientEvent - , UnsignedData(..) - , clientEventDecoder - , encodeClientEvent - , encodeUnsignedData - , unsignedDataDecoder - ) - -{-| Automatically generated 'Objects' - -Last generated at Unix time 1673279712 - --} - -import Internal.Tools.DecodeExtra exposing (opField) -import Internal.Tools.EncodeExtra exposing (maybeObject) -import Internal.Tools.Timestamp exposing (Timestamp, encodeTimestamp, timestampDecoder) -import Json.Decode as D -import Json.Encode as E - - -{-| Client Event containing all data on an event. --} -type alias ClientEvent = - { content : E.Value - , eventId : String - , originServerTs : Timestamp - , roomId : String - , sender : String - , stateKey : Maybe String - , contentType : String - , unsigned : Maybe UnsignedData - } - - -encodeClientEvent : ClientEvent -> E.Value -encodeClientEvent data = - maybeObject - [ ( "content", Just <| data.content ) - , ( "event_id", Just <| E.string data.eventId ) - , ( "origin_server_ts", Just <| encodeTimestamp data.originServerTs ) - , ( "room_id", Just <| E.string data.roomId ) - , ( "sender", Just <| E.string data.sender ) - , ( "state_key", Maybe.map E.string data.stateKey ) - , ( "type", Just <| E.string data.contentType ) - , ( "unsigned", Maybe.map encodeUnsignedData data.unsigned ) - ] - - -clientEventDecoder : D.Decoder ClientEvent -clientEventDecoder = - D.map8 - (\a b c d e f g h -> - { content = a, eventId = b, originServerTs = c, roomId = d, sender = e, stateKey = f, contentType = g, unsigned = h } - ) - (D.field "content" D.value) - (D.field "event_id" D.string) - (D.field "origin_server_ts" timestampDecoder) - (D.field "room_id" D.string) - (D.field "sender" D.string) - (opField "state_key" D.string) - (D.field "type" D.string) - (opField "unsigned" (D.lazy (\_ -> unsignedDataDecoder))) - - -{-| Extra information about the event. --} -type UnsignedData - = UnsignedData - { age : Maybe Int - , prevContent : Maybe E.Value - , redactedBecause : Maybe ClientEvent - , transactionId : Maybe String - } - - -encodeUnsignedData : UnsignedData -> E.Value -encodeUnsignedData (UnsignedData data) = - maybeObject - [ ( "age", Maybe.map E.int data.age ) - , ( "prev_content", data.prevContent ) - , ( "redacted_because", Maybe.map encodeClientEvent data.redactedBecause ) - , ( "transaction_id", Maybe.map E.string data.transactionId ) - ] - - -unsignedDataDecoder : D.Decoder UnsignedData -unsignedDataDecoder = - D.map4 - (\a b c d -> - UnsignedData { age = a, prevContent = b, redactedBecause = c, transactionId = d } - ) - (opField "age" D.int) - (opField "prev_content" D.value) - (opField "redacted_because" clientEventDecoder) - (opField "transaction_id" D.string) diff --git a/src/Internal/Api/GetEvent/V1_5/Objects.yaml b/src/Internal/Api/GetEvent/V1_5/Objects.yaml deleted file mode 100644 index 7fdb81f..0000000 --- a/src/Internal/Api/GetEvent/V1_5/Objects.yaml +++ /dev/null @@ -1,40 +0,0 @@ -version: v1.5 -name: Objects -objects: - ClientEvent: - description: Client Event containing all data on an event. - fields: - content: - type: value - required: true - event_id: - type: string - required: true - origin_server_ts: - type: timestamp - required: true - room_id: - type: string - required: true - sender: - type: string - required: true - state_key: - type: string - type: - type: string - required: true - unsigned: - type: UnsignedData - UnsignedData: - anti_recursion: true - description: Extra information about the event. - fields: - age: - type: int - prev_content: - type: value - redacted_because: - type: ClientEvent - transaction_id: - type: string diff --git a/src/Internal/Api/GetEvent/V1_5/SpecObjects.elm b/src/Internal/Api/GetEvent/V1_5/SpecObjects.elm deleted file mode 100644 index 924c4ae..0000000 --- a/src/Internal/Api/GetEvent/V1_5/SpecObjects.elm +++ /dev/null @@ -1,97 +0,0 @@ -module Internal.Api.GetEvent.V1_5.SpecObjects exposing - ( ClientEvent - , UnsignedData(..) - , clientEventDecoder - , encodeClientEvent - , encodeUnsignedData - , unsignedDataDecoder - ) - -{-| Automatically generated 'SpecObjects' - -Last generated at Unix time 1673279712 - --} - -import Internal.Tools.DecodeExtra exposing (opField) -import Internal.Tools.EncodeExtra exposing (maybeObject) -import Internal.Tools.Timestamp exposing (Timestamp, encodeTimestamp, timestampDecoder) -import Json.Decode as D -import Json.Encode as E - - -{-| Client Event containing all data on an event. --} -type alias ClientEvent = - { content : E.Value - , eventId : String - , originServerTs : Timestamp - , roomId : String - , sender : String - , stateKey : Maybe String - , contentType : String - , unsigned : Maybe UnsignedData - } - - -encodeClientEvent : ClientEvent -> E.Value -encodeClientEvent data = - maybeObject - [ ( "content", Just <| data.content ) - , ( "event_id", Just <| E.string data.eventId ) - , ( "origin_server_ts", Just <| encodeTimestamp data.originServerTs ) - , ( "room_id", Just <| E.string data.roomId ) - , ( "sender", Just <| E.string data.sender ) - , ( "state_key", Maybe.map E.string data.stateKey ) - , ( "type", Just <| E.string data.contentType ) - , ( "unsigned", Maybe.map encodeUnsignedData data.unsigned ) - ] - - -clientEventDecoder : D.Decoder ClientEvent -clientEventDecoder = - D.map8 - (\a b c d e f g h -> - { content = a, eventId = b, originServerTs = c, roomId = d, sender = e, stateKey = f, contentType = g, unsigned = h } - ) - (D.field "content" D.value) - (D.field "event_id" D.string) - (D.field "origin_server_ts" timestampDecoder) - (D.field "room_id" D.string) - (D.field "sender" D.string) - (opField "state_key" D.string) - (D.field "type" D.string) - (opField "unsigned" (D.lazy (\_ -> unsignedDataDecoder))) - - -{-| Extra information about the event. --} -type UnsignedData - = UnsignedData - { age : Maybe Int - , prevContent : Maybe E.Value - , redactedBecause : Maybe ClientEvent - , transactionId : Maybe String - } - - -encodeUnsignedData : UnsignedData -> E.Value -encodeUnsignedData (UnsignedData data) = - maybeObject - [ ( "age", Maybe.map E.int data.age ) - , ( "prev_content", data.prevContent ) - , ( "redacted_because", Maybe.map encodeClientEvent data.redactedBecause ) - , ( "transaction_id", Maybe.map E.string data.transactionId ) - ] - - -unsignedDataDecoder : D.Decoder UnsignedData -unsignedDataDecoder = - D.map4 - (\a b c d -> - UnsignedData { age = a, prevContent = b, redactedBecause = c, transactionId = d } - ) - (opField "age" D.int) - (opField "prev_content" D.value) - (opField "redacted_because" clientEventDecoder) - (opField "transaction_id" D.string) diff --git a/src/Internal/Api/GetEvent/V1_5/SpecObjects.yaml b/src/Internal/Api/GetEvent/V1_5/SpecObjects.yaml deleted file mode 100644 index 11145ee..0000000 --- a/src/Internal/Api/GetEvent/V1_5/SpecObjects.yaml +++ /dev/null @@ -1,40 +0,0 @@ -version: v1.5 -name: SpecObjects -objects: - ClientEvent: - description: Client Event containing all data on an event. - fields: - content: - type: value - required: true - event_id: - type: string - required: true - origin_server_ts: - type: timestamp - required: true - room_id: - type: string - required: true - sender: - type: string - required: true - state_key: - type: string - type: - type: string - required: true - unsigned: - type: UnsignedData - UnsignedData: - anti_recursion: true - description: Extra information about the event. - fields: - age: - type: int - prev_content: - type: value - redacted_because: - type: ClientEvent - transaction_id: - type: string diff --git a/src/Internal/Api/GetEvent/V1_5/Upcast.elm b/src/Internal/Api/GetEvent/V1_5/Upcast.elm deleted file mode 100644 index 22db576..0000000 --- a/src/Internal/Api/GetEvent/V1_5/Upcast.elm +++ /dev/null @@ -1,27 +0,0 @@ -module Internal.Api.GetEvent.V1_5.Upcast exposing (..) - -import Internal.Api.GetEvent.V1_4.Objects as PO -import Internal.Api.GetEvent.V1_5.Objects as O - - -upcast : PO.ClientEvent -> O.ClientEvent -upcast e = - { content = e.content - , eventId = e.eventId - , originServerTs = e.originServerTs - , roomId = e.roomId - , sender = e.sender - , stateKey = e.stateKey - , contentType = e.contentType - , unsigned = Maybe.map upcastUnsigned e.unsigned - } - - -upcastUnsigned : PO.UnsignedData -> O.UnsignedData -upcastUnsigned (PO.UnsignedData u) = - O.UnsignedData - { age = u.age - , prevContent = u.prevContent - , redactedBecause = Maybe.map upcast u.redactedBecause - , transactionId = u.transactionId - }