mirror of
https://github.com/BrianHicks/elm-duet.git
synced 2024-11-22 12:13:14 +03:00
update with latest tinyping schema
This commit is contained in:
parent
095154a32f
commit
f2b058d474
@ -1,106 +1,15 @@
|
||||
definitions:
|
||||
notificationPermission:
|
||||
metadata:
|
||||
name: NotificationPermission
|
||||
enum:
|
||||
- default
|
||||
- denied
|
||||
- granted
|
||||
|
||||
# name/prefix policy: all versioned objects have a `versioned` constructor
|
||||
# prefix to avoid conflicts. Current versions of types don't have a version
|
||||
# suffix, but previous versions do.
|
||||
|
||||
doc:
|
||||
notification:
|
||||
metadata:
|
||||
constructorPrefix: versioned
|
||||
discriminator: version
|
||||
mapping:
|
||||
v1:
|
||||
metadata:
|
||||
name: Doc
|
||||
properties:
|
||||
pings:
|
||||
elements:
|
||||
ref: ping
|
||||
settings:
|
||||
ref: settings
|
||||
|
||||
settings:
|
||||
metadata:
|
||||
name: DocumentSettings
|
||||
constructorPrefix: versioned
|
||||
discriminator: version
|
||||
mapping:
|
||||
v1:
|
||||
metadata:
|
||||
name: Settings
|
||||
properties:
|
||||
minutesPerPing:
|
||||
type: int32
|
||||
|
||||
ping:
|
||||
metadata:
|
||||
constructorPrefix: versioned
|
||||
discriminator: version
|
||||
mapping:
|
||||
v1:
|
||||
metadata:
|
||||
name: Ping
|
||||
properties:
|
||||
time:
|
||||
type: int32
|
||||
tag:
|
||||
type: string
|
||||
nullable: true
|
||||
custom:
|
||||
values:
|
||||
type: string
|
||||
|
||||
modules:
|
||||
Main:
|
||||
flags:
|
||||
properties:
|
||||
currentTimeMillis:
|
||||
type: float64
|
||||
notificationPermission:
|
||||
ref: notificationPermission
|
||||
ports:
|
||||
docFromAutomerge:
|
||||
metadata:
|
||||
direction: JsToElm
|
||||
ref: doc
|
||||
changeDocument:
|
||||
metadata:
|
||||
direction: ElmToJs
|
||||
elements:
|
||||
discriminator: tag
|
||||
mapping:
|
||||
SetMinutesPerPing:
|
||||
properties:
|
||||
value:
|
||||
type: float64
|
||||
AddNewPingAt:
|
||||
properties:
|
||||
value:
|
||||
type: float64
|
||||
SetTagForPing:
|
||||
properties:
|
||||
index:
|
||||
type: float64
|
||||
value:
|
||||
type: string
|
||||
nullable: true
|
||||
|
||||
# notifications
|
||||
requestNotificationsPermission:
|
||||
metadata:
|
||||
direction: ElmToJs
|
||||
gotNewNotificationsPermission:
|
||||
metadata:
|
||||
direction: JsToElm
|
||||
ref: notificationPermission
|
||||
notify:
|
||||
metadata:
|
||||
direction: ElmToJs
|
||||
name: Notification
|
||||
properties:
|
||||
title:
|
||||
type: string
|
||||
@ -120,3 +29,99 @@ modules:
|
||||
type: boolean
|
||||
tag:
|
||||
type: string
|
||||
|
||||
# name/prefix policy: all versioned objects have a `versioned` constructor
|
||||
# prefix to avoid conflicts.
|
||||
|
||||
doc:
|
||||
metadata:
|
||||
constructorPrefix: versioned
|
||||
discriminator: version
|
||||
mapping:
|
||||
v1:
|
||||
metadata:
|
||||
name: DocV1
|
||||
properties:
|
||||
pings:
|
||||
elements:
|
||||
ref: ping
|
||||
settings:
|
||||
ref: settings
|
||||
|
||||
settings:
|
||||
metadata:
|
||||
constructorPrefix: versioned
|
||||
discriminator: version
|
||||
mapping:
|
||||
v1:
|
||||
metadata:
|
||||
name: SettingsV1
|
||||
properties:
|
||||
minutesPerPing:
|
||||
type: int32
|
||||
|
||||
ping:
|
||||
metadata:
|
||||
constructorPrefix: versioned
|
||||
discriminator: version
|
||||
mapping:
|
||||
v1:
|
||||
metadata:
|
||||
name: PingV1
|
||||
properties:
|
||||
time:
|
||||
type: int32
|
||||
tag:
|
||||
type: string
|
||||
nullable: true
|
||||
custom:
|
||||
values:
|
||||
type: string
|
||||
|
||||
modules:
|
||||
Main:
|
||||
flags:
|
||||
properties:
|
||||
currentTimeMillis:
|
||||
type: int32
|
||||
notificationPermission:
|
||||
ref: notificationPermission
|
||||
ports:
|
||||
docFromAutomerge:
|
||||
metadata:
|
||||
direction: JsToElm
|
||||
ref: doc
|
||||
changeDocument:
|
||||
metadata:
|
||||
direction: ElmToJs
|
||||
elements:
|
||||
discriminator: tag
|
||||
mapping:
|
||||
SetMinutesPerPing:
|
||||
properties:
|
||||
value:
|
||||
type: uint32
|
||||
AddNewPingAt:
|
||||
properties:
|
||||
value:
|
||||
type: uint32
|
||||
SetTagForPing:
|
||||
properties:
|
||||
index:
|
||||
type: uint32
|
||||
value:
|
||||
type: string
|
||||
nullable: true
|
||||
|
||||
# notifications
|
||||
requestNotificationsPermission:
|
||||
metadata:
|
||||
direction: ElmToJs
|
||||
gotNewNotificationsPermission:
|
||||
metadata:
|
||||
direction: JsToElm
|
||||
ref: notificationPermission
|
||||
notify:
|
||||
metadata:
|
||||
direction: ElmToJs
|
||||
ref: notification
|
||||
|
@ -49,7 +49,7 @@ encodeNotificationPermission notificationPermission_ =
|
||||
|
||||
|
||||
type alias Flags =
|
||||
{ currentTimeMillis : Float
|
||||
{ currentTimeMillis : Int
|
||||
, notificationPermission : NotificationPermission
|
||||
}
|
||||
|
||||
@ -57,13 +57,13 @@ type alias Flags =
|
||||
flagsDecoder : Json.Decode.Decoder Flags
|
||||
flagsDecoder =
|
||||
Json.Decode.succeed Flags
|
||||
|> Json.Decode.Pipeline.required "currentTimeMillis" Json.Decode.float
|
||||
|> Json.Decode.Pipeline.required "currentTimeMillis" Json.Decode.int
|
||||
|> Json.Decode.Pipeline.required "notificationPermission" notificationPermissionDecoder
|
||||
|
||||
|
||||
encodeFlags : Flags -> Json.Encode.Value
|
||||
encodeFlags flags_ =
|
||||
Json.Encode.object
|
||||
[ ( "currentTimeMillis", Json.Encode.float flags_.currentTimeMillis )
|
||||
[ ( "currentTimeMillis", Json.Encode.int flags_.currentTimeMillis )
|
||||
, ( "notificationPermission", encodeNotificationPermission flags_.notificationPermission )
|
||||
]
|
||||
|
@ -10,45 +10,45 @@ import Json.Encode
|
||||
|
||||
|
||||
type alias AddNewPingAt =
|
||||
{ value : Float
|
||||
{ value : Int
|
||||
}
|
||||
|
||||
|
||||
addNewPingAtDecoder : Json.Decode.Decoder AddNewPingAt
|
||||
addNewPingAtDecoder =
|
||||
Json.Decode.succeed AddNewPingAt
|
||||
|> Json.Decode.Pipeline.required "value" Json.Decode.float
|
||||
|> Json.Decode.Pipeline.required "value" Json.Decode.int
|
||||
|
||||
|
||||
encodeAddNewPingAt : AddNewPingAt -> Json.Encode.Value
|
||||
encodeAddNewPingAt addNewPingAt_ =
|
||||
Json.Encode.object
|
||||
[ ( "value", Json.Encode.float addNewPingAt_.value )
|
||||
[ ( "value", Json.Encode.int addNewPingAt_.value )
|
||||
, ( "tag", Json.Encode.string "AddNewPingAt" )
|
||||
]
|
||||
|
||||
|
||||
type alias SetMinutesPerPing =
|
||||
{ value : Float
|
||||
{ value : Int
|
||||
}
|
||||
|
||||
|
||||
setMinutesPerPingDecoder : Json.Decode.Decoder SetMinutesPerPing
|
||||
setMinutesPerPingDecoder =
|
||||
Json.Decode.succeed SetMinutesPerPing
|
||||
|> Json.Decode.Pipeline.required "value" Json.Decode.float
|
||||
|> Json.Decode.Pipeline.required "value" Json.Decode.int
|
||||
|
||||
|
||||
encodeSetMinutesPerPing : SetMinutesPerPing -> Json.Encode.Value
|
||||
encodeSetMinutesPerPing setMinutesPerPing_ =
|
||||
Json.Encode.object
|
||||
[ ( "value", Json.Encode.float setMinutesPerPing_.value )
|
||||
[ ( "value", Json.Encode.int setMinutesPerPing_.value )
|
||||
, ( "tag", Json.Encode.string "SetMinutesPerPing" )
|
||||
]
|
||||
|
||||
|
||||
type alias SetTagForPing =
|
||||
{ index : Float
|
||||
{ index : Int
|
||||
, value : Maybe String
|
||||
}
|
||||
|
||||
@ -56,14 +56,14 @@ type alias SetTagForPing =
|
||||
setTagForPingDecoder : Json.Decode.Decoder SetTagForPing
|
||||
setTagForPingDecoder =
|
||||
Json.Decode.succeed SetTagForPing
|
||||
|> Json.Decode.Pipeline.required "index" Json.Decode.float
|
||||
|> Json.Decode.Pipeline.required "index" Json.Decode.int
|
||||
|> Json.Decode.Pipeline.required "value" (Json.Decode.nullable Json.Decode.string)
|
||||
|
||||
|
||||
encodeSetTagForPing : SetTagForPing -> Json.Encode.Value
|
||||
encodeSetTagForPing setTagForPing_ =
|
||||
Json.Encode.object
|
||||
[ ( "index", Json.Encode.float setTagForPing_.index )
|
||||
[ ( "index", Json.Encode.int setTagForPing_.index )
|
||||
, ( "value"
|
||||
, case setTagForPing_.value of
|
||||
Just value ->
|
||||
@ -129,40 +129,40 @@ encodeChangeDocument changeDocument_ =
|
||||
Json.Encode.list (/value -> encodeChangeDocumentElements value) changeDocument_
|
||||
|
||||
|
||||
type alias Ping =
|
||||
type alias PingV1 =
|
||||
{ custom : Dict String String
|
||||
, tag : Maybe String
|
||||
, time : Int
|
||||
}
|
||||
|
||||
|
||||
pingDecoder : Json.Decode.Decoder Ping
|
||||
pingDecoder =
|
||||
Json.Decode.succeed Ping
|
||||
pingV1Decoder : Json.Decode.Decoder PingV1
|
||||
pingV1Decoder =
|
||||
Json.Decode.succeed PingV1
|
||||
|> Json.Decode.Pipeline.required "custom" (Json.Decode.dict Json.Decode.string)
|
||||
|> Json.Decode.Pipeline.required "tag" (Json.Decode.nullable Json.Decode.string)
|
||||
|> Json.Decode.Pipeline.required "time" Json.Decode.int
|
||||
|
||||
|
||||
encodePing : Ping -> Json.Encode.Value
|
||||
encodePing ping_ =
|
||||
encodePingV1 : PingV1 -> Json.Encode.Value
|
||||
encodePingV1 pingV1_ =
|
||||
Json.Encode.object
|
||||
[ ( "custom", Json.Encode.dict identity (/value -> Json.Encode.string value) ping_.custom )
|
||||
[ ( "custom", Json.Encode.dict identity (/value -> Json.Encode.string value) pingV1_.custom )
|
||||
, ( "tag"
|
||||
, case ping_.tag of
|
||||
, case pingV1_.tag of
|
||||
Just value ->
|
||||
Json.Encode.string value
|
||||
|
||||
Nothing ->
|
||||
Json.Encode.null
|
||||
)
|
||||
, ( "time", Json.Encode.int ping_.time )
|
||||
, ( "time", Json.Encode.int pingV1_.time )
|
||||
, ( "version", Json.Encode.string "v1" )
|
||||
]
|
||||
|
||||
|
||||
type PingsElements
|
||||
= VersionedPingsElementsV1 Ping
|
||||
= VersionedPingsElementsV1 PingV1
|
||||
|
||||
|
||||
pingsElementsDecoder : Json.Decode.Decoder PingsElements
|
||||
@ -171,7 +171,7 @@ pingsElementsDecoder =
|
||||
(/tag ->
|
||||
case tag of
|
||||
"v1" ->
|
||||
Json.Decode.map VersionedPingsElementsV1 pingDecoder
|
||||
Json.Decode.map VersionedPingsElementsV1 pingV1Decoder
|
||||
|
||||
unknown ->
|
||||
Json.Decode.fail ("Unknown value `" ++ unknown ++ "`")
|
||||
@ -183,39 +183,39 @@ encodePingsElements : PingsElements -> Json.Encode.Value
|
||||
encodePingsElements pingsElements_ =
|
||||
case pingsElements_ of
|
||||
VersionedPingsElementsV1 versionedPingsElementsV1 ->
|
||||
encodePing versionedPingsElementsV1
|
||||
encodePingV1 versionedPingsElementsV1
|
||||
|
||||
|
||||
type alias Settings =
|
||||
type alias SettingsV1 =
|
||||
{ minutesPerPing : Int
|
||||
}
|
||||
|
||||
|
||||
settingsDecoder : Json.Decode.Decoder Settings
|
||||
settingsDecoder =
|
||||
Json.Decode.succeed Settings
|
||||
settingsV1Decoder : Json.Decode.Decoder SettingsV1
|
||||
settingsV1Decoder =
|
||||
Json.Decode.succeed SettingsV1
|
||||
|> Json.Decode.Pipeline.required "minutesPerPing" Json.Decode.int
|
||||
|
||||
|
||||
encodeSettings : Settings -> Json.Encode.Value
|
||||
encodeSettings settings_ =
|
||||
encodeSettingsV1 : SettingsV1 -> Json.Encode.Value
|
||||
encodeSettingsV1 settingsV1_ =
|
||||
Json.Encode.object
|
||||
[ ( "minutesPerPing", Json.Encode.int settings_.minutesPerPing )
|
||||
[ ( "minutesPerPing", Json.Encode.int settingsV1_.minutesPerPing )
|
||||
, ( "version", Json.Encode.string "v1" )
|
||||
]
|
||||
|
||||
|
||||
type DocumentSettings
|
||||
= VersionedDocumentSettingsV1 Settings
|
||||
type Settings
|
||||
= VersionedSettingsV1 SettingsV1
|
||||
|
||||
|
||||
documentSettingsDecoder : Json.Decode.Decoder DocumentSettings
|
||||
documentSettingsDecoder =
|
||||
settingsDecoder : Json.Decode.Decoder Settings
|
||||
settingsDecoder =
|
||||
Json.Decode.andThen
|
||||
(/tag ->
|
||||
case tag of
|
||||
"v1" ->
|
||||
Json.Decode.map VersionedDocumentSettingsV1 settingsDecoder
|
||||
Json.Decode.map VersionedSettingsV1 settingsV1Decoder
|
||||
|
||||
unknown ->
|
||||
Json.Decode.fail ("Unknown value `" ++ unknown ++ "`")
|
||||
@ -223,37 +223,37 @@ documentSettingsDecoder =
|
||||
(Json.Decode.field "version" Json.Decode.string)
|
||||
|
||||
|
||||
encodeDocumentSettings : DocumentSettings -> Json.Encode.Value
|
||||
encodeDocumentSettings documentSettings_ =
|
||||
case documentSettings_ of
|
||||
VersionedDocumentSettingsV1 versionedDocumentSettingsV1 ->
|
||||
encodeSettings versionedDocumentSettingsV1
|
||||
encodeSettings : Settings -> Json.Encode.Value
|
||||
encodeSettings settings_ =
|
||||
case settings_ of
|
||||
VersionedSettingsV1 versionedSettingsV1 ->
|
||||
encodeSettingsV1 versionedSettingsV1
|
||||
|
||||
|
||||
type alias Doc =
|
||||
type alias DocV1 =
|
||||
{ pings : List PingsElements
|
||||
, settings : DocumentSettings
|
||||
, settings : Settings
|
||||
}
|
||||
|
||||
|
||||
docDecoder : Json.Decode.Decoder Doc
|
||||
docDecoder =
|
||||
Json.Decode.succeed Doc
|
||||
docV1Decoder : Json.Decode.Decoder DocV1
|
||||
docV1Decoder =
|
||||
Json.Decode.succeed DocV1
|
||||
|> Json.Decode.Pipeline.required "pings" (Json.Decode.list pingsElementsDecoder)
|
||||
|> Json.Decode.Pipeline.required "settings" documentSettingsDecoder
|
||||
|> Json.Decode.Pipeline.required "settings" settingsDecoder
|
||||
|
||||
|
||||
encodeDoc : Doc -> Json.Encode.Value
|
||||
encodeDoc doc_ =
|
||||
encodeDocV1 : DocV1 -> Json.Encode.Value
|
||||
encodeDocV1 docV1_ =
|
||||
Json.Encode.object
|
||||
[ ( "pings", Json.Encode.list (/value -> encodePingsElements value) doc_.pings )
|
||||
, ( "settings", encodeDocumentSettings doc_.settings )
|
||||
[ ( "pings", Json.Encode.list (/value -> encodePingsElements value) docV1_.pings )
|
||||
, ( "settings", encodeSettings docV1_.settings )
|
||||
, ( "version", Json.Encode.string "v1" )
|
||||
]
|
||||
|
||||
|
||||
type DocFromAutomerge
|
||||
= VersionedDocFromAutomergeV1 Doc
|
||||
= VersionedDocFromAutomergeV1 DocV1
|
||||
|
||||
|
||||
docFromAutomergeDecoder : Json.Decode.Decoder DocFromAutomerge
|
||||
@ -262,7 +262,7 @@ docFromAutomergeDecoder =
|
||||
(/tag ->
|
||||
case tag of
|
||||
"v1" ->
|
||||
Json.Decode.map VersionedDocFromAutomergeV1 docDecoder
|
||||
Json.Decode.map VersionedDocFromAutomergeV1 docV1Decoder
|
||||
|
||||
unknown ->
|
||||
Json.Decode.fail ("Unknown value `" ++ unknown ++ "`")
|
||||
@ -274,28 +274,28 @@ encodeDocFromAutomerge : DocFromAutomerge -> Json.Encode.Value
|
||||
encodeDocFromAutomerge docFromAutomerge_ =
|
||||
case docFromAutomerge_ of
|
||||
VersionedDocFromAutomergeV1 versionedDocFromAutomergeV1 ->
|
||||
encodeDoc versionedDocFromAutomergeV1
|
||||
encodeDocV1 versionedDocFromAutomergeV1
|
||||
|
||||
|
||||
type GotNewNotificationsPermission
|
||||
= GotNewNotificationsPermissionDefault
|
||||
| GotNewNotificationsPermissionDenied
|
||||
| GotNewNotificationsPermissionGranted
|
||||
type NotificationPermission
|
||||
= NotificationPermissionDefault
|
||||
| NotificationPermissionDenied
|
||||
| NotificationPermissionGranted
|
||||
|
||||
|
||||
gotNewNotificationsPermissionDecoder : Json.Decode.Decoder GotNewNotificationsPermission
|
||||
gotNewNotificationsPermissionDecoder =
|
||||
notificationPermissionDecoder : Json.Decode.Decoder NotificationPermission
|
||||
notificationPermissionDecoder =
|
||||
Json.Decode.andThen
|
||||
(/tag ->
|
||||
case tag of
|
||||
"default" ->
|
||||
Json.Decode.succeed GotNewNotificationsPermissionDefault
|
||||
Json.Decode.succeed NotificationPermissionDefault
|
||||
|
||||
"denied" ->
|
||||
Json.Decode.succeed GotNewNotificationsPermissionDenied
|
||||
Json.Decode.succeed NotificationPermissionDenied
|
||||
|
||||
"granted" ->
|
||||
Json.Decode.succeed GotNewNotificationsPermissionGranted
|
||||
Json.Decode.succeed NotificationPermissionGranted
|
||||
|
||||
unknown ->
|
||||
Json.Decode.fail ("Unknown value `" ++ unknown ++ "`")
|
||||
@ -303,16 +303,16 @@ gotNewNotificationsPermissionDecoder =
|
||||
Json.Decode.string
|
||||
|
||||
|
||||
encodeGotNewNotificationsPermission : GotNewNotificationsPermission -> Json.Encode.Value
|
||||
encodeGotNewNotificationsPermission gotNewNotificationsPermission_ =
|
||||
case gotNewNotificationsPermission_ of
|
||||
GotNewNotificationsPermissionDefault ->
|
||||
encodeNotificationPermission : NotificationPermission -> Json.Encode.Value
|
||||
encodeNotificationPermission notificationPermission_ =
|
||||
case notificationPermission_ of
|
||||
NotificationPermissionDefault ->
|
||||
Json.Encode.string "default"
|
||||
|
||||
GotNewNotificationsPermissionDenied ->
|
||||
NotificationPermissionDenied ->
|
||||
Json.Encode.string "denied"
|
||||
|
||||
GotNewNotificationsPermissionGranted ->
|
||||
NotificationPermissionGranted ->
|
||||
Json.Encode.string "granted"
|
||||
|
||||
|
||||
@ -353,24 +353,24 @@ encodeOptions options_ =
|
||||
|> Json.Encode.object
|
||||
|
||||
|
||||
type alias Notify =
|
||||
type alias Notification =
|
||||
{ options : Options
|
||||
, title : String
|
||||
}
|
||||
|
||||
|
||||
notifyDecoder : Json.Decode.Decoder Notify
|
||||
notifyDecoder =
|
||||
Json.Decode.succeed Notify
|
||||
notificationDecoder : Json.Decode.Decoder Notification
|
||||
notificationDecoder =
|
||||
Json.Decode.succeed Notification
|
||||
|> Json.Decode.Pipeline.required "options" optionsDecoder
|
||||
|> Json.Decode.Pipeline.required "title" Json.Decode.string
|
||||
|
||||
|
||||
encodeNotify : Notify -> Json.Encode.Value
|
||||
encodeNotify notify_ =
|
||||
encodeNotification : Notification -> Json.Encode.Value
|
||||
encodeNotification notification_ =
|
||||
Json.Encode.object
|
||||
[ ( "options", encodeOptions notify_.options )
|
||||
, ( "title", Json.Encode.string notify_.title )
|
||||
[ ( "options", encodeOptions notification_.options )
|
||||
, ( "title", Json.Encode.string notification_.title )
|
||||
]
|
||||
|
||||
|
||||
@ -407,17 +407,17 @@ subscribeToDocFromAutomerge toMsg =
|
||||
port gotNewNotificationsPermission : (Json.Decode.Value -> msg) -> Sub msg
|
||||
|
||||
|
||||
subscribeToGotNewNotificationsPermission : (Result Json.Decode.Error GotNewNotificationsPermission -> msg) -> Sub msg
|
||||
subscribeToGotNewNotificationsPermission : (Result Json.Decode.Error NotificationPermission -> msg) -> Sub msg
|
||||
subscribeToGotNewNotificationsPermission toMsg =
|
||||
gotNewNotificationsPermission (Json.Decode.decodeValue gotNewNotificationsPermissionDecoder >> toMsg)
|
||||
gotNewNotificationsPermission (Json.Decode.decodeValue notificationPermissionDecoder >> toMsg)
|
||||
|
||||
|
||||
port notify : Json.Decode.Value -> Cmd msg
|
||||
|
||||
|
||||
sendNotify : Notify -> Cmd msg
|
||||
sendNotify : Notification -> Cmd msg
|
||||
sendNotify =
|
||||
encodeNotify >> notify
|
||||
encodeNotification >> notify
|
||||
|
||||
|
||||
port requestNotificationsPermission : Json.Decode.Value -> Cmd msg
|
||||
|
Loading…
Reference in New Issue
Block a user