maca/postgrest-admin-preview/3.0.0

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 23156f6951ea of https://github.com/maca/postgrest-admin-preview (zip prefix maca-postgrest-admin-preview-23156f6/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 f0e3c4fc5d53b826aceb272f752d36a1cf48e278.

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/3.0.0/

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
, params : Params
, expect : Result Error (List 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 () -> 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
, resolver : Resolver Error body
, timeout : Maybe Float
}
-> Task Error body

Task to perform a request to a PostgREST instance resource.

The path can identify a plural resource such as /posts in which case an upsert operation will be performed, or a singular resource such as '/posts?id=eq.1'.

fetch : (Result Error Value -> msg) -> Task Error Value -> Cmd msg

Perform a task converting the result to a message.

resolveWhatever : Resolver Error Value

Use this in combination with task when you don't expect PostgREST response to have a body, as when performing a request with POST or PATCH.

type alias Error =
Error

Request error.

errorToString : Error -> String

Transform Error to an error explanation.

Authentication

isAuthenticated : Client -> Bool

Does the client has a valid JWT?

toJwtString : Client -> Maybe String

Obtain the JWT as a string.