maca/postgrest-admin-preview/14.0.1

NOTE: the latest version is 15.0.0

Rerouted (regenerated, verified). Same repository and tag, but GitHub now builds the zip with different bytes, so it no longer matches the SHA-1 package.elm-lang.org recorded. The Lamdera package server serves a copy recovered from https://github.com/maca/postgrest-admin-preview.

What we checked: Rebuilt with git archive from commit 39194ab3e5d0 of https://github.com/maca/postgrest-admin-preview (zip prefix maca-postgrest-admin-preview-39194ab/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 ddf0c95c259d4a60b0d92f4faaae7a5dd1dfc667.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/maca/postgrest-admin-preview/zipball/14.0.1/

PostgRestAdmin.Client

Client

type alias Client =
Client

Represents a client for a PostgREST instance, including authentication params.

See Config and Config.FormAuth for authentication configuration options.

toHostUrl : Client -> Url

Obtain the PostgREST instance url.

Table

type alias Table =
Table

Represents a PostgREST table.

getTable : String -> Client -> Maybe Table

Obtain a table from the table name.

tableName : Table -> String

Obtain the name of a table

Requests

Note that the request functions do not produce a vanilla Elm Cmd but a PostgRestAdmin.Cmd.

{ client : Client
, table : Table
, id : String
, expect : Result Error Record -> msg
}
-> Cmd msg

Fetches a record for a given table. expect param requires a function that returns a Msg.

import PostgRestAdmin.Cmd as AppCmd


fetchOne : (Result Error Record -> msg) -> String -> Client -> AppCmd.Cmd Msg
fetchOne tagger tableName client =
    case getTable tableName client of
        Just table ->
            fetchRecord
                { client = client
                , table = table
                , params = []
                , expect = tagger
                }


        Nothing ->
            AppCmd.none
{ client : Client
, table : Table
, queryString : String
, expect : Result Error (Collection Record) -> msg
}
-> Cmd msg

Fetches a list of records for a given table. expect param requires a function that returns a Msg.

import PostgRestAdmin.Cmd as AppCmd


fetchList : (Result Error (List Record) -> Msg) -> String -> Client -> AppCmd.Cmd Msg
fetchList tagger tableName client =
    case getTable tableName client of
        Just table ->
            fetchRecordList
                { client = client
                , table = table
                , params = []
                , expect = tagger
                }


        Nothing ->
            AppCmd.none
{ client : Client
, record : Record
, id : Maybe String
, expect : Result Error Record -> msg
}
-> Cmd msg

Saves a record. expect param requires a function that returns a Msg.

You can use expectRecord to interpret the result as a Record.

import PostgRestAdmin.Cmd as AppCmd


save : (Result Error () -> Msg) -> Record -> Maybe String -> Client -> AppCmd.Cmd Msg
save tagger record id client =
    saveRecord
        { client = client
        , record = record
        , id = id
        , expect = tagger
        }
{ record : Record
, expect : Result Error () -> msg
}
-> Client
-> Cmd msg

Deletes a record. expect param requires a function that returns a Msg.

import PostgRestAdmin.Cmd as AppCmd


delete : (Result Error Record -> Msg) -> Record -> Client -> AppCmd.Cmd Msg
delete tagger record client =
    deleteRecord
        { client = client
        , record = record
        , expect = tagger
        }
{ client : Client
, method : String
, headers : List Header
, path : String
, body : Body
, decoder : Decoder a
, expect : Result Error a -> msg
}
-> Cmd msg

Perform a request

{ client : Client
, method : String
, headers : List Header
, path : String
, body : Body
, decoder : Decoder a
, expect : Result Error (Collection a) -> msg
}
-> Cmd msg
type alias Collection a =
{ from : Int
, to : Int
, total : Int
, records : List a
}
type alias Error =
Error

Request error.

errorToString : Error -> String

Transform Error to an error explanation.

oneResolver : Resolver Error Response
manyResolver : Resolver Error Response
noneResolver : Resolver Error Response
{ client : Client
, method : String
, headers : List Header
, path : String
, body : Body
, resolver : Resolver Error body
, timeout : Maybe Float
}
-> Task Error body

Task to perform a request to a PostgREST instance resource.

attempt : (Result Error Response -> msg) -> Task Error Response -> Cmd msg
decodeOne : Decoder a -> Result Error Response -> Result Error a
decodeMany : Decoder a -> Result Error Response -> Result Error (Collection a)

Authentication

isAuthenticated : Client -> Bool

Does the client has a valid JWT?

toJwtString : Client -> Maybe String

Obtain the JWT as a string.

authHeader : Client -> Maybe Header

Generate an authorization header.