Add Elm Timeline to elm.json
parent
1940b1d51f
commit
421e1f6ce7
1
elm.json
1
elm.json
|
@ -23,6 +23,7 @@
|
|||
"Internal.Values.Event",
|
||||
"Internal.Values.Settings",
|
||||
"Internal.Values.StateManager",
|
||||
"Internal.Values.Timeline",
|
||||
"Internal.Values.Vault",
|
||||
"Matrix",
|
||||
"Matrix.Event",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module Internal.Config.Text exposing
|
||||
( docs, failures, fields
|
||||
( docs, failures, fields, mappings
|
||||
, accessTokenFoundLocally, accessTokenExpired, accessTokenInvalid
|
||||
, versionsFoundLocally, versionsReceived, versionsFailedToDecode
|
||||
, unsupportedVersionForEndpoint
|
||||
|
@ -27,7 +27,7 @@ You should only do this if you know what you're doing.
|
|||
|
||||
## Type documentation
|
||||
|
||||
@docs docs, failures, fields
|
||||
@docs docs, failures, fields, mappings
|
||||
|
||||
|
||||
## API Authentication
|
||||
|
@ -347,6 +347,19 @@ leakingValueFound leaking_value =
|
|||
"Found leaking value : " ++ leaking_value
|
||||
|
||||
|
||||
{-| Function descriptions
|
||||
-}
|
||||
mappings : { itokenPTR : TypeDocs }
|
||||
mappings =
|
||||
{ itokenPTR =
|
||||
{ name = "ITokenPTR init"
|
||||
, description =
|
||||
[ "Converts an optional string to an Itoken pointer."
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{-| The Matrix homeserver can specify how it wishes to communicate, and the Elm
|
||||
SDK aims to communicate accordingly. This may fail in some scenarios, however,
|
||||
in which case it will throw this error.
|
||||
|
|
|
@ -3,7 +3,7 @@ module Internal.Tools.Json exposing
|
|||
, Encoder, encode, Decoder, decode, Value
|
||||
, succeed, fail, andThen, lazy, map
|
||||
, Docs(..), RequiredField(..), toDocs
|
||||
, list, slowDict, fastDict, maybe
|
||||
, list, slowDict, fastDict, set, maybe
|
||||
, Field, field
|
||||
, object2, object3, object4, object5, object6, object7, object8, object9, object10, object11
|
||||
)
|
||||
|
@ -49,7 +49,7 @@ module to build its encoders and decoders.
|
|||
|
||||
## Data types
|
||||
|
||||
@docs list, slowDict, fastDict, maybe
|
||||
@docs list, slowDict, fastDict, set, maybe
|
||||
|
||||
|
||||
## Objects
|
||||
|
@ -73,6 +73,7 @@ import Internal.Tools.DecodeExtra as D
|
|||
import Internal.Tools.EncodeExtra as E
|
||||
import Json.Decode as D
|
||||
import Json.Encode as E
|
||||
import Set exposing (Set)
|
||||
|
||||
|
||||
{-| A field of type `a` as a subtype of an object `object`.
|
||||
|
@ -155,6 +156,7 @@ type Docs
|
|||
)
|
||||
| DocsOptional Docs
|
||||
| DocsRiskyMap (Descriptive { content : Docs, failure : List String })
|
||||
| DocsSet Docs
|
||||
| DocsString
|
||||
| DocsValue
|
||||
|
||||
|
@ -1079,6 +1081,27 @@ object11 { name, description, init } fa fb fc fd fe ff fg fh fi fj fk =
|
|||
}
|
||||
|
||||
|
||||
{-| Define a set.
|
||||
-}
|
||||
set : Coder comparable -> Coder (Set comparable)
|
||||
set (Coder data) =
|
||||
Coder
|
||||
{ encoder = E.set data.encoder
|
||||
, decoder =
|
||||
data.decoder
|
||||
|> D.list
|
||||
|> D.map
|
||||
(\items ->
|
||||
( items
|
||||
|> List.map Tuple.first
|
||||
|> Set.fromList
|
||||
, items
|
||||
|> List.concatMap Tuple.second
|
||||
)
|
||||
)
|
||||
, docs = DocsSet data.docs
|
||||
}
|
||||
|
||||
{-| Define a slow dict from the `elm/core` library.
|
||||
-}
|
||||
slowDict : Coder value -> Coder (SlowDict.Dict String value)
|
||||
|
|
|
@ -61,7 +61,7 @@ events!
|
|||
|
||||
## JSON coder
|
||||
|
||||
@docs encode, decoder
|
||||
@docs coder, encode, decoder
|
||||
|
||||
-}
|
||||
|
||||
|
@ -70,6 +70,7 @@ import Internal.Filter.Timeline as Filter exposing (Filter)
|
|||
import Internal.Tools.Hashdict as Hashdict exposing (Hashdict)
|
||||
import Internal.Tools.Iddict as Iddict exposing (Iddict)
|
||||
import Internal.Tools.Json as Json
|
||||
import Internal.Config.Text as Text
|
||||
import Json.Decode as D
|
||||
import Json.Encode as E
|
||||
import Recursion
|
||||
|
@ -79,6 +80,9 @@ import Set exposing (Set)
|
|||
|
||||
{-| A batch is a batch of events that is placed onto the Timeline. Functions
|
||||
that require an insertion, generally require this data type.
|
||||
|
||||
If the `start` value is `Nothing`, it is either the start of the timeline or the
|
||||
start of the timeline part that the user is allowed to view.
|
||||
-}
|
||||
type alias Batch =
|
||||
{ events : List String
|
||||
|
@ -164,6 +168,83 @@ type Timeline
|
|||
type alias TokenValue =
|
||||
String
|
||||
|
||||
coderIBatchPTR : Json.Coder IBatchPTR
|
||||
coderIBatchPTR =
|
||||
Json.map
|
||||
{ name = Debug.todo "Add name"
|
||||
, description = Debug.todo "Add description"
|
||||
, back = IBatchPTR
|
||||
, forth = (\(IBatchPTR value) -> value)
|
||||
}
|
||||
coderIBatchPTRValue
|
||||
|
||||
coderIBatchPTRValue : Json.Coder IBatchPTRValue
|
||||
coderIBatchPTRValue = Json.int
|
||||
|
||||
coderIToken : Json.Coder IToken
|
||||
coderIToken =
|
||||
Json.object5
|
||||
{ name = "IToken"
|
||||
, description = Debug.todo "TODO: Add description"
|
||||
, init = IToken
|
||||
}
|
||||
( Json.field.required
|
||||
{ fieldName = "name"
|
||||
, toField = .name
|
||||
, description = Debug.todo "TODO: Add description"
|
||||
, coder = coderTokenValue
|
||||
}
|
||||
)
|
||||
( Json.field.optional.withDefault
|
||||
{ fieldName = "starts"
|
||||
, toField = .starts
|
||||
, description = Debug.todo "TODO: Add description"
|
||||
, coder = Json.set coderIBatchPTRValue
|
||||
, default = ( Set.empty, [] )
|
||||
, defaultToString = always "[]"
|
||||
}
|
||||
)
|
||||
( Json.field.optional.withDefault
|
||||
{ fieldName = "ends"
|
||||
, toField = .ends
|
||||
, description = Debug.todo "TODO: Add description"
|
||||
, coder = Json.set coderIBatchPTRValue
|
||||
, default = ( Set.empty, [] )
|
||||
, defaultToString = always "[]"
|
||||
}
|
||||
)
|
||||
|
||||
coderITokenPTR : Json.Coder ITokenPTR
|
||||
coderITokenPTR =
|
||||
Json.maybe coderITokenPTRValue
|
||||
|> Json.map
|
||||
{ name = Text.mappings.itokenPTR.name
|
||||
, description = Text.mappings.itokenPTR.description
|
||||
, back =
|
||||
(\itokenptr ->
|
||||
case itokenptr of
|
||||
ITokenPTR name ->
|
||||
Just name
|
||||
|
||||
StartOfTimeline ->
|
||||
Nothing
|
||||
)
|
||||
, forth =
|
||||
(\value ->
|
||||
case value of
|
||||
Just name ->
|
||||
ITokenPTR name
|
||||
|
||||
Nothing ->
|
||||
StartOfTimeline
|
||||
)
|
||||
}
|
||||
|
||||
coderITokenPTRValue : Json.Coder ITokenPTRValue
|
||||
coderITokenPTRValue = Json.string
|
||||
|
||||
coderTokenValue : Json.Coder TokenValue
|
||||
coderTokenValue = Json.string
|
||||
|
||||
{-| Append a token at the end of a batch.
|
||||
-}
|
||||
|
|
|
@ -170,7 +170,7 @@ suite =
|
|||
]
|
||||
, describe "Gaps"
|
||||
[ fuzz TestFilter.fuzzer
|
||||
"Gap leaves behind old events"
|
||||
"Gaps leave behind old events"
|
||||
(\filter ->
|
||||
Timeline.empty
|
||||
|> Timeline.insert
|
||||
|
@ -189,7 +189,7 @@ suite =
|
|||
|> Expect.equal [ [ "d", "e", "f" ] ]
|
||||
)
|
||||
, fuzz TestFilter.fuzzer
|
||||
"Gap can be bridged"
|
||||
"Gaps can be bridged"
|
||||
(\filter ->
|
||||
Timeline.empty
|
||||
|> Timeline.insert
|
||||
|
|
Loading…
Reference in New Issue