BREAKING: Fix bug breaking Elm compiler

4-compiler-bug
Bram 2024-05-26 18:12:37 +02:00
parent e6257d8e38
commit 4349a14a87
2 changed files with 332 additions and 324 deletions

View File

@ -159,333 +159,340 @@ type alias PhantomV1 a =
loginWithUsernameAndPasswordV1 : LoginWithUsernameAndPasswordInputV1 i -> A.TaskChain (PhantomV1 a) (PhantomV1 { a | accessToken : () }) loginWithUsernameAndPasswordV1 : LoginWithUsernameAndPasswordInputV1 i -> A.TaskChain (PhantomV1 a) (PhantomV1 { a | accessToken : () })
loginWithUsernameAndPasswordV1 { username, password } context = loginWithUsernameAndPasswordV1 { username, password } =
A.request \context ->
{ attributes = A.request
[ R.bodyString "password" password { attributes =
, R.bodyString "type" "m.login.password" [ R.bodyString "password" password
, R.bodyString "user" username , R.bodyString "type" "m.login.password"
, R.onStatusCode 400 "M_UNKNOWN" , R.bodyString "user" username
, R.onStatusCode 403 "M_FORBIDDEN" , R.onStatusCode 400 "M_UNKNOWN"
] , R.onStatusCode 403 "M_FORBIDDEN"
, coder = coderV1 ]
, method = "POST" , coder = coderV1
, path = [ "_matrix", "client", "r0", "login" ] , method = "POST"
, contextChange = , path = [ "_matrix", "client", "r0", "login" ]
\out -> Context.setAccessToken out.accessToken , contextChange =
, toUpdate = \out -> Context.setAccessToken out.accessToken
\out -> , toUpdate =
( E.More \out ->
[ E.SetAccessToken ( E.More
{ created = Context.getNow context [ E.SetAccessToken
, expiryMs = Nothing { created = Context.getNow context
, lastUsed = Context.getNow context , expiryMs = Nothing
, refresh = out.refreshToken , lastUsed = Context.getNow context
, value = out.accessToken , refresh = out.refreshToken
} , value = out.accessToken
, out.user }
|> Maybe.map (V.SetUser >> E.ContentUpdate) , out.user
|> E.Optional |> Maybe.map (V.SetUser >> E.ContentUpdate)
] |> E.Optional
, [] ]
) , []
} )
context }
context
loginWithUsernameAndPasswordV2 : LoginWithUsernameAndPasswordInputV2 i -> A.TaskChain (PhantomV1 a) (PhantomV1 { a | accessToken : () }) loginWithUsernameAndPasswordV2 : LoginWithUsernameAndPasswordInputV2 i -> A.TaskChain (PhantomV1 a) (PhantomV1 { a | accessToken : () })
loginWithUsernameAndPasswordV2 { deviceId, initialDeviceDisplayName, username, password } context = loginWithUsernameAndPasswordV2 { deviceId, initialDeviceDisplayName, username, password } =
A.request \context ->
{ attributes = A.request
[ R.bodyOpString "device_id" deviceId { attributes =
, R.bodyOpString "initial_device_display_name" initialDeviceDisplayName [ R.bodyOpString "device_id" deviceId
, R.bodyString "password" password , R.bodyOpString "initial_device_display_name" initialDeviceDisplayName
, R.bodyString "type" "m.login.password" , R.bodyString "password" password
, R.bodyString "user" username , R.bodyString "type" "m.login.password"
, R.onStatusCode 400 "M_UNKNOWN" , R.bodyString "user" username
, R.onStatusCode 403 "M_FORBIDDEN" , R.onStatusCode 400 "M_UNKNOWN"
, R.onStatusCode 429 "string" -- Yup. That's what it says. , R.onStatusCode 403 "M_FORBIDDEN"
] , R.onStatusCode 429 "string" -- Yup. That's what it says.
, coder = coderV2 ]
, method = "POST" , coder = coderV2
, path = [ "_matrix", "client", "r0", "login" ] , method = "POST"
, contextChange = , path = [ "_matrix", "client", "r0", "login" ]
\out -> Context.setAccessToken out.accessToken , contextChange =
, toUpdate = \out -> Context.setAccessToken out.accessToken
\out -> , toUpdate =
( E.More \out ->
[ E.SetAccessToken ( E.More
{ created = Context.getNow context [ E.SetAccessToken
, expiryMs = Nothing { created = Context.getNow context
, lastUsed = Context.getNow context , expiryMs = Nothing
, refresh = Nothing , lastUsed = Context.getNow context
, value = out.accessToken , refresh = Nothing
} , value = out.accessToken
, out.user }
|> Maybe.map (V.SetUser >> E.ContentUpdate) , out.user
|> E.Optional |> Maybe.map (V.SetUser >> E.ContentUpdate)
, out.deviceId |> E.Optional
|> Maybe.map E.SetDeviceId , out.deviceId
|> E.Optional |> Maybe.map E.SetDeviceId
] |> E.Optional
, [] ]
) , []
} )
context }
context
loginWithUsernameAndPasswordV3 : LoginWithUsernameAndPasswordInputV2 i -> A.TaskChain (PhantomV1 a) (PhantomV1 { a | accessToken : () }) loginWithUsernameAndPasswordV3 : LoginWithUsernameAndPasswordInputV2 i -> A.TaskChain (PhantomV1 a) (PhantomV1 { a | accessToken : () })
loginWithUsernameAndPasswordV3 { deviceId, initialDeviceDisplayName, username, password } context = loginWithUsernameAndPasswordV3 { deviceId, initialDeviceDisplayName, username, password } =
A.request \context ->
{ attributes = A.request
[ R.bodyOpString "address" Nothing { attributes =
, R.bodyOpString "device_id" deviceId [ R.bodyOpString "address" Nothing
, R.bodyValue "identifier" , R.bodyOpString "device_id" deviceId
(E.object , R.bodyValue "identifier"
[ ( "type", E.string "m.id.user" ) (E.object
, ( "user", E.string username ) [ ( "type", E.string "m.id.user" )
] , ( "user", E.string username )
) ]
, R.bodyOpString "initial_device_display_name" initialDeviceDisplayName )
, R.bodyString "password" password , R.bodyOpString "initial_device_display_name" initialDeviceDisplayName
, R.bodyString "type" "m.login.password" , R.bodyString "password" password
, R.bodyString "user" username , R.bodyString "type" "m.login.password"
, R.onStatusCode 400 "M_UNKNOWN" , R.bodyString "user" username
, R.onStatusCode 403 "M_FORBIDDEN" , R.onStatusCode 400 "M_UNKNOWN"
, R.onStatusCode 429 "M_LIMIT_EXCEEDED" , R.onStatusCode 403 "M_FORBIDDEN"
] , R.onStatusCode 429 "M_LIMIT_EXCEEDED"
, coder = coderV3 ]
, method = "POST" , coder = coderV3
, path = [ "_matrix", "client", "r0", "login" ] , method = "POST"
, contextChange = , path = [ "_matrix", "client", "r0", "login" ]
\out -> Context.setAccessToken out.accessToken , contextChange =
, toUpdate = \out -> Context.setAccessToken out.accessToken
\out -> , toUpdate =
( E.More \out ->
[ E.SetAccessToken ( E.More
{ created = Context.getNow context [ E.SetAccessToken
, expiryMs = Nothing { created = Context.getNow context
, lastUsed = Context.getNow context , expiryMs = Nothing
, refresh = Nothing , lastUsed = Context.getNow context
, value = out.accessToken , refresh = Nothing
} , value = out.accessToken
, out.user }
|> Maybe.map (V.SetUser >> E.ContentUpdate) , out.user
|> E.Optional |> Maybe.map (V.SetUser >> E.ContentUpdate)
, out.deviceId |> E.Optional
|> Maybe.map E.SetDeviceId , out.deviceId
|> E.Optional |> Maybe.map E.SetDeviceId
] |> E.Optional
, [] ]
) , []
} )
context }
context
loginWithUsernameAndPasswordV4 : LoginWithUsernameAndPasswordInputV2 i -> A.TaskChain (PhantomV1 a) (PhantomV1 { a | accessToken : () }) loginWithUsernameAndPasswordV4 : LoginWithUsernameAndPasswordInputV2 i -> A.TaskChain (PhantomV1 a) (PhantomV1 { a | accessToken : () })
loginWithUsernameAndPasswordV4 { deviceId, initialDeviceDisplayName, username, password } context = loginWithUsernameAndPasswordV4 { deviceId, initialDeviceDisplayName, username, password } =
A.request \context ->
{ attributes = A.request
[ R.bodyOpString "address" Nothing { attributes =
, R.bodyOpString "device_id" deviceId [ R.bodyOpString "address" Nothing
, R.bodyValue "identifier" , R.bodyOpString "device_id" deviceId
(E.object , R.bodyValue "identifier"
[ ( "type", E.string "m.id.user" ) (E.object
, ( "user", E.string username ) [ ( "type", E.string "m.id.user" )
] , ( "user", E.string username )
) ]
, R.bodyOpString "initial_device_display_name" initialDeviceDisplayName )
, R.bodyString "password" password , R.bodyOpString "initial_device_display_name" initialDeviceDisplayName
, R.bodyString "type" "m.login.password" , R.bodyString "password" password
, R.bodyString "user" username , R.bodyString "type" "m.login.password"
, R.onStatusCode 400 "M_UNKNOWN" , R.bodyString "user" username
, R.onStatusCode 403 "M_FORBIDDEN" , R.onStatusCode 400 "M_UNKNOWN"
, R.onStatusCode 429 "M_LIMIT_EXCEEDED" , R.onStatusCode 403 "M_FORBIDDEN"
] , R.onStatusCode 429 "M_LIMIT_EXCEEDED"
, coder = coderV4 ]
, method = "POST" , coder = coderV4
, path = [ "_matrix", "client", "r0", "login" ] , method = "POST"
, contextChange = , path = [ "_matrix", "client", "r0", "login" ]
\out -> Context.setAccessToken out.accessToken , contextChange =
, toUpdate = \out -> Context.setAccessToken out.accessToken
\out -> , toUpdate =
( E.More \out ->
[ E.SetAccessToken ( E.More
{ created = Context.getNow context [ E.SetAccessToken
, expiryMs = Nothing { created = Context.getNow context
, lastUsed = Context.getNow context , expiryMs = Nothing
, refresh = Nothing , lastUsed = Context.getNow context
, value = out.accessToken , refresh = Nothing
} , value = out.accessToken
, out.user }
|> Maybe.map (V.SetUser >> E.ContentUpdate) , out.user
|> E.Optional |> Maybe.map (V.SetUser >> E.ContentUpdate)
, out.wellKnown |> E.Optional
|> Maybe.map (.homeserver >> .baseUrl) , out.wellKnown
|> Maybe.map E.SetBaseUrl |> Maybe.map (.homeserver >> .baseUrl)
|> E.Optional |> Maybe.map E.SetBaseUrl
, out.deviceId |> E.Optional
|> Maybe.map E.SetDeviceId , out.deviceId
|> E.Optional |> Maybe.map E.SetDeviceId
] |> E.Optional
, [] ]
) , []
} )
context }
context
loginWithUsernameAndPasswordV5 : LoginWithUsernameAndPasswordInputV2 i -> A.TaskChain (PhantomV1 a) (PhantomV1 { a | accessToken : () }) loginWithUsernameAndPasswordV5 : LoginWithUsernameAndPasswordInputV2 i -> A.TaskChain (PhantomV1 a) (PhantomV1 { a | accessToken : () })
loginWithUsernameAndPasswordV5 { deviceId, initialDeviceDisplayName, username, password } context = loginWithUsernameAndPasswordV5 { deviceId, initialDeviceDisplayName, username, password } =
A.request \context ->
{ attributes = A.request
[ R.bodyOpString "address" Nothing { attributes =
, R.bodyOpString "device_id" deviceId [ R.bodyOpString "address" Nothing
, R.bodyValue "identifier" , R.bodyOpString "device_id" deviceId
(E.object , R.bodyValue "identifier"
[ ( "type", E.string "m.id.user" ) (E.object
, ( "user", E.string username ) [ ( "type", E.string "m.id.user" )
] , ( "user", E.string username )
) ]
, R.bodyOpString "initial_device_display_name" initialDeviceDisplayName )
, R.bodyString "password" password , R.bodyOpString "initial_device_display_name" initialDeviceDisplayName
, R.bodyString "type" "m.login.password" , R.bodyString "password" password
, R.bodyString "user" username , R.bodyString "type" "m.login.password"
, R.onStatusCode 400 "M_UNKNOWN" , R.bodyString "user" username
, R.onStatusCode 403 "M_FORBIDDEN" , R.onStatusCode 400 "M_UNKNOWN"
, R.onStatusCode 429 "M_LIMIT_EXCEEDED" , R.onStatusCode 403 "M_FORBIDDEN"
] , R.onStatusCode 429 "M_LIMIT_EXCEEDED"
, coder = coderV4 ]
, method = "POST" , coder = coderV4
, path = [ "_matrix", "client", "v3", "login" ] , method = "POST"
, contextChange = , path = [ "_matrix", "client", "v3", "login" ]
\out -> Context.setAccessToken out.accessToken , contextChange =
, toUpdate = \out -> Context.setAccessToken out.accessToken
\out -> , toUpdate =
( E.More \out ->
[ E.SetAccessToken ( E.More
{ created = Context.getNow context [ E.SetAccessToken
, expiryMs = Nothing { created = Context.getNow context
, lastUsed = Context.getNow context , expiryMs = Nothing
, refresh = Nothing , lastUsed = Context.getNow context
, value = out.accessToken , refresh = Nothing
} , value = out.accessToken
, out.user }
|> Maybe.map (V.SetUser >> E.ContentUpdate) , out.user
|> E.Optional |> Maybe.map (V.SetUser >> E.ContentUpdate)
, out.wellKnown |> E.Optional
|> Maybe.map (.homeserver >> .baseUrl) , out.wellKnown
|> Maybe.map E.SetBaseUrl |> Maybe.map (.homeserver >> .baseUrl)
|> E.Optional |> Maybe.map E.SetBaseUrl
, out.deviceId |> E.Optional
|> Maybe.map E.SetDeviceId , out.deviceId
|> E.Optional |> Maybe.map E.SetDeviceId
] |> E.Optional
, [] ]
) , []
} )
context }
context
loginWithUsernameAndPasswordV6 : LoginWithUsernameAndPasswordInputV3 i -> A.TaskChain (PhantomV1 a) (PhantomV1 { a | accessToken : () }) loginWithUsernameAndPasswordV6 : LoginWithUsernameAndPasswordInputV3 i -> A.TaskChain (PhantomV1 a) (PhantomV1 { a | accessToken : () })
loginWithUsernameAndPasswordV6 { deviceId, enableRefreshToken, initialDeviceDisplayName, username, password } context = loginWithUsernameAndPasswordV6 { deviceId, enableRefreshToken, initialDeviceDisplayName, username, password } =
A.request \context ->
{ attributes = A.request
[ R.bodyOpString "address" Nothing { attributes =
, R.bodyOpString "device_id" deviceId [ R.bodyOpString "address" Nothing
, R.bodyValue "identifier" , R.bodyOpString "device_id" deviceId
(E.object , R.bodyValue "identifier"
[ ( "type", E.string "m.id.user" ) (E.object
, ( "user", E.string username ) [ ( "type", E.string "m.id.user" )
] , ( "user", E.string username )
) ]
, R.bodyOpString "initial_device_display_name" initialDeviceDisplayName )
, R.bodyString "password" password , R.bodyOpString "initial_device_display_name" initialDeviceDisplayName
, R.bodyOpBool "refresh_token" enableRefreshToken , R.bodyString "password" password
, R.bodyString "type" "m.login.password" , R.bodyOpBool "refresh_token" enableRefreshToken
, R.bodyString "user" username , R.bodyString "type" "m.login.password"
, R.onStatusCode 400 "M_UNKNOWN" , R.bodyString "user" username
, R.onStatusCode 403 "M_FORBIDDEN" , R.onStatusCode 400 "M_UNKNOWN"
, R.onStatusCode 429 "M_LIMIT_EXCEEDED" , R.onStatusCode 403 "M_FORBIDDEN"
] , R.onStatusCode 429 "M_LIMIT_EXCEEDED"
, coder = coderV5 ]
, method = "POST" , coder = coderV5
, path = [ "_matrix", "client", "v3", "login" ] , method = "POST"
, contextChange = , path = [ "_matrix", "client", "v3", "login" ]
\out -> Context.setAccessToken out.accessToken , contextChange =
, toUpdate = \out -> Context.setAccessToken out.accessToken
\out -> , toUpdate =
( E.More \out ->
[ E.SetAccessToken ( E.More
{ created = Context.getNow context [ E.SetAccessToken
, expiryMs = out.expiresInMs { created = Context.getNow context
, lastUsed = Context.getNow context , expiryMs = out.expiresInMs
, refresh = out.refreshToken , lastUsed = Context.getNow context
, value = out.accessToken , refresh = out.refreshToken
} , value = out.accessToken
, out.user }
|> Maybe.map (V.SetUser >> E.ContentUpdate) , out.user
|> E.Optional |> Maybe.map (V.SetUser >> E.ContentUpdate)
, out.wellKnown |> E.Optional
|> Maybe.map (.homeserver >> .baseUrl) , out.wellKnown
|> Maybe.map E.SetBaseUrl |> Maybe.map (.homeserver >> .baseUrl)
|> E.Optional |> Maybe.map E.SetBaseUrl
, out.deviceId |> E.Optional
|> Maybe.map E.SetDeviceId , out.deviceId
|> E.Optional |> Maybe.map E.SetDeviceId
] |> E.Optional
, [] ]
) , []
} )
context }
context
loginWithUsernameAndPasswordV7 : LoginWithUsernameAndPasswordInputV3 i -> A.TaskChain (PhantomV1 a) (PhantomV1 { a | accessToken : () }) loginWithUsernameAndPasswordV7 : LoginWithUsernameAndPasswordInputV3 i -> A.TaskChain (PhantomV1 a) (PhantomV1 { a | accessToken : () })
loginWithUsernameAndPasswordV7 { deviceId, enableRefreshToken, initialDeviceDisplayName, username, password } context = loginWithUsernameAndPasswordV7 { deviceId, enableRefreshToken, initialDeviceDisplayName, username, password } =
A.request \context ->
{ attributes = A.request
[ R.bodyOpString "address" Nothing { attributes =
, R.bodyOpString "device_id" deviceId [ R.bodyOpString "address" Nothing
, R.bodyValue "identifier" , R.bodyOpString "device_id" deviceId
(E.object , R.bodyValue "identifier"
[ ( "type", E.string "m.id.user" ) (E.object
, ( "user", E.string username ) [ ( "type", E.string "m.id.user" )
] , ( "user", E.string username )
) ]
, R.bodyOpString "initial_device_display_name" initialDeviceDisplayName )
, R.bodyString "password" password , R.bodyOpString "initial_device_display_name" initialDeviceDisplayName
, R.bodyOpBool "refresh_token" enableRefreshToken , R.bodyString "password" password
, R.bodyString "type" "m.login.password" , R.bodyOpBool "refresh_token" enableRefreshToken
, R.bodyString "user" username , R.bodyString "type" "m.login.password"
, R.onStatusCode 400 "M_UNKNOWN" , R.bodyString "user" username
, R.onStatusCode 403 "M_FORBIDDEN" , R.onStatusCode 400 "M_UNKNOWN"
, R.onStatusCode 429 "M_LIMIT_EXCEEDED" , R.onStatusCode 403 "M_FORBIDDEN"
] , R.onStatusCode 429 "M_LIMIT_EXCEEDED"
, coder = coderV6 ]
, method = "POST" , coder = coderV6
, path = [ "_matrix", "client", "v3", "login" ] , method = "POST"
, contextChange = , path = [ "_matrix", "client", "v3", "login" ]
\out -> Context.setAccessToken out.accessToken , contextChange =
, toUpdate = \out -> Context.setAccessToken out.accessToken
\out -> , toUpdate =
( E.More \out ->
[ E.SetAccessToken ( E.More
{ created = Context.getNow context [ E.SetAccessToken
, expiryMs = out.expiresInMs { created = Context.getNow context
, lastUsed = Context.getNow context , expiryMs = out.expiresInMs
, refresh = out.refreshToken , lastUsed = Context.getNow context
, value = out.accessToken , refresh = out.refreshToken
} , value = out.accessToken
, E.ContentUpdate (V.SetUser out.user) }
, out.wellKnown , E.ContentUpdate (V.SetUser out.user)
|> Maybe.map (.homeserver >> .baseUrl) , out.wellKnown
|> Maybe.map E.SetBaseUrl |> Maybe.map (.homeserver >> .baseUrl)
|> E.Optional |> Maybe.map E.SetBaseUrl
, E.SetDeviceId out.deviceId |> E.Optional
] , E.SetDeviceId out.deviceId
, [] ]
) , []
} )
context }
context
coderV1 : Json.Coder LoginWithUsernameAndPasswordOutputV1 coderV1 : Json.Coder LoginWithUsernameAndPasswordOutputV1

View File

@ -20,18 +20,19 @@ import Time
getNow : A.TaskChain a { a | now : () } getNow : A.TaskChain a { a | now : () }
getNow _ = getNow =
Task.map \_ ->
(\now -> Task.map
{ messages = [ E.SetNow now ] (\now ->
, logs = { messages = [ E.SetNow now ]
[ "Identified current time at Unix time " , logs =
, now |> Time.posixToMillis |> String.fromInt [ "Identified current time at Unix time "
] , now |> Time.posixToMillis |> String.fromInt
|> String.concat ]
|> log.debug |> String.concat
|> List.singleton |> log.debug
, contextChange = Context.setNow now |> List.singleton
} , contextChange = Context.setNow now
) }
Time.now )
Time.now