Update for Gleam 0.30

This commit is contained in:
Mikko Ahlroth 2023-07-22 11:20:05 +03:00
parent 0d1f5324f7
commit 4f0071c6c8
7 changed files with 58 additions and 53 deletions

View file

@ -1,3 +1,3 @@
gleam 0.29.0
gleam 0.30.2
erlang 25.2.2
elixir 1.14.3-otp-25

View file

@ -1,3 +1,8 @@
4.0.0
-----
* Updated for Gleam 0.30.
3.0.0
-----

View file

@ -1,6 +1,7 @@
name = "finch_gleam"
version = "3.0.0"
version = "4.0.0"
target = "erlang"
gleam = ">= 0.30.0"
# Fill out these fields if you intend to generate HTML documentation or publish
# your project to the Hex package manager.

View file

@ -2,27 +2,27 @@
# You typically do not need to edit this file
packages = [
{ name = "castore", version = "1.0.1", build_tools = ["mix"], requirements = [], otp_app = "castore", source = "hex", outer_checksum = "B4951DE93C224D44FAC71614BEABD88B71932D0B1DEA80D2F80FB9044E01BBB3" },
{ name = "finch", version = "0.16.0", build_tools = ["mix"], requirements = ["nimble_options", "nimble_pool", "mint", "castore", "mime", "telemetry"], otp_app = "finch", source = "hex", outer_checksum = "F660174C4D519E5FEC629016054D60EDD822CDFE2B7270836739AC2F97735EC5" },
{ name = "gleam_erlang", version = "0.18.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "C69F59D086AD50B80DE294FB0963550630971C9DC04E92B1F7AEEDD2C0BE226C" },
{ name = "castore", version = "1.0.3", build_tools = ["mix"], requirements = [], otp_app = "castore", source = "hex", outer_checksum = "680AB01EF5D15B161ED6A95449FAC5C6B8F60055677A8E79ACF01B27BAA4390B" },
{ name = "finch", version = "0.16.0", build_tools = ["mix"], requirements = ["mint", "castore", "telemetry", "nimble_pool", "mime", "nimble_options"], otp_app = "finch", source = "hex", outer_checksum = "F660174C4D519E5FEC629016054D60EDD822CDFE2B7270836739AC2F97735EC5" },
{ name = "gleam_erlang", version = "0.19.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "720D1E0A0CEBBD51C4AA88501D1D4FBFEF4AA7B3332C994691ED944767A52582" },
{ name = "gleam_http", version = "3.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "D034F5CE0639CD142CBA210B7D5D14236C284B0C5772A043D2E22128594573AE" },
{ name = "gleam_otp", version = "0.5.3", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "6E705B69464237353E0380AC8143BDB29A3F0BF6168755D5F2D6E55A34A8B077" },
{ name = "gleam_stdlib", version = "0.28.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "73F0A89FADE5022CBEF6D6C3551F9ADCE7054AFCE0CB1DC4C6D5AB4CA62D0111" },
{ name = "gleam_otp", version = "0.5.3", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_erlang"], otp_app = "gleam_otp", source = "hex", outer_checksum = "6E705B69464237353E0380AC8143BDB29A3F0BF6168755D5F2D6E55A34A8B077" },
{ name = "gleam_stdlib", version = "0.30.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "03710B3DA047A3683117591707FCA19D32B980229DD8CE8B0603EB5B5144F6C3" },
{ name = "gleeunit", version = "0.10.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "ECEA2DE4BE6528D36AFE74F42A21CDF99966EC36D7F25DEB34D47DD0F7977BAF" },
{ name = "glisten", version = "0.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_erlang", "gleam_otp"], otp_app = "glisten", source = "hex", outer_checksum = "52B530FF25370590843998D1B6C4EC6169DB1300D5E4407A5CDA1575374B7AEC" },
{ name = "glisten", version = "0.7.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib"], otp_app = "glisten", source = "hex", outer_checksum = "52B530FF25370590843998D1B6C4EC6169DB1300D5E4407A5CDA1575374B7AEC" },
{ name = "hpax", version = "0.1.2", build_tools = ["mix"], requirements = [], otp_app = "hpax", source = "hex", outer_checksum = "2C87843D5A23F5F16748EBE77969880E29809580EFDACCD615CD3BED628A8C13" },
{ name = "mime", version = "2.0.3", build_tools = ["mix"], requirements = [], otp_app = "mime", source = "hex", outer_checksum = "27A30BF0DB44D25EECBA73755ACF4068CBFE26A4372F9EB3E4EA3A45956BFF6B" },
{ name = "mint", version = "1.5.1", build_tools = ["mix"], requirements = ["castore", "hpax"], otp_app = "mint", source = "hex", outer_checksum = "4A63E1E76A7C3956ABD2C72F370A0D0AECDDC3976DEA5C27ECCBECFA5E7D5B1E" },
{ name = "mist", version = "0.11.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_erlang", "gleam_http", "gleam_otp", "glisten"], otp_app = "mist", source = "hex", outer_checksum = "B990DB49BC7EA68B2BAFCE2C5A6A2F8469EEDEB29A406B182DC6389E14FFA10B" },
{ name = "mime", version = "2.0.5", build_tools = ["mix"], requirements = [], otp_app = "mime", source = "hex", outer_checksum = "DA0D64A365C45BC9935CC5C8A7FC5E49A0E0F9932A761C55D6C52B142780A05C" },
{ name = "mint", version = "1.5.1", build_tools = ["mix"], requirements = ["hpax", "castore"], otp_app = "mint", source = "hex", outer_checksum = "4A63E1E76A7C3956ABD2C72F370A0D0AECDDC3976DEA5C27ECCBECFA5E7D5B1E" },
{ name = "mist", version = "0.12.0", build_tools = ["gleam"], requirements = ["gleam_otp", "gleam_erlang", "gleam_stdlib", "glisten", "gleam_http"], otp_app = "mist", source = "hex", outer_checksum = "6FD3D24B0E79CA90AE07A695C2ADA2049E16A384BEF960B122E841DE88B6CA67" },
{ name = "nimble_options", version = "1.0.2", build_tools = ["mix"], requirements = [], otp_app = "nimble_options", source = "hex", outer_checksum = "FD12A8DB2021036CE12A309F26F564EC367373265B53E25403F0EE697380F1B8" },
{ name = "nimble_pool", version = "1.0.0", build_tools = ["mix"], requirements = [], otp_app = "nimble_pool", source = "hex", outer_checksum = "80BE3B882D2D351882256087078E1B1952A28BF98D0A287BE87E4A24A710B67A" },
{ name = "telemetry", version = "1.2.1", build_tools = ["rebar3"], requirements = [], otp_app = "telemetry", source = "hex", outer_checksum = "DAD9CE9D8EFFC621708F99EAC538EF1CBE05D6A874DD741DE2E689C47FEAFED5" },
]
[requirements]
finch = "~> 0.16"
gleam_erlang = "~> 0.18"
gleam_http = "~> 3.1"
gleam_stdlib = "~> 0.28"
gleeunit = "~> 0.10"
mist = "~> 0.11"
finch = { version = "~> 0.16" }
gleam_erlang = { version = "~> 0.18" }
gleam_http = { version = "~> 3.1" }
gleam_stdlib = { version = "~> 0.28" }
gleeunit = { version = "~> 0.10" }
mist = { version = "~> 0.11" }

View file

@ -4,7 +4,6 @@
//// information about the functions.
import gleam/result
import gleam
import gleam/uri
import gleam/erlang/atom.{Atom}
@ -35,12 +34,12 @@ pub type RequestOptions =
List(RequestOption)
/// Finch request, use `build/2` to create one from a Gleam request.
pub external type Request
pub type Request
external type Response
type Response
/// Exception returned by Finch in case of request errors.
pub external type Exception
pub type Exception
/// Build a Finch request that can be run with `request/2` or `stream/5`.
///
@ -64,14 +63,14 @@ pub fn build(
)
}
external fn build_ext(
method: Method,
url: String,
headers: Headers,
body: String,
opts: RequestOptions,
) -> Request =
"Elixir.Finch" "build"
@external(erlang, "Elixir.Finch", "build")
fn build_ext(
method method: Method,
url url: String,
headers headers: Headers,
body body: String,
opts opts: RequestOptions,
) -> Request
/// Send a request using the Finch instance with the given name.
pub fn request(
@ -87,22 +86,22 @@ pub fn request(
))
}
external fn do_request(req: Request, name: Atom) -> Result(Response, Exception) =
"Elixir.Finch" "request"
@external(erlang, "Elixir.Finch", "request")
fn do_request(req req: Request, name name: Atom) -> Result(Response, Exception)
/// Stream a request using the Finch instance with the given name.
pub external fn stream(
req: Request,
name: Atom,
acc: a,
fun: StreamFun(a),
opts: RequestOptions,
) -> Result(a, Exception) =
"Elixir.Finch" "stream"
@external(erlang, "Elixir.Finch", "stream")
pub fn stream(
req req: Request,
name name: Atom,
acc acc: a,
fun fun: StreamFun(a),
opts opts: RequestOptions,
) -> Result(a, Exception)
/// Start a new Finch instance with the given options.
pub external fn start_link(opts: InstanceOptions) -> OnStart =
"Elixir.Finch" "start_link"
@external(erlang, "Elixir.Finch", "start_link")
pub fn start_link(opts opts: InstanceOptions) -> OnStart
fn response_body(resp: Response) -> String {
get_response_body(resp, Body)
@ -141,14 +140,14 @@ type ResponseStatusKey {
Status
}
external fn get_response_body(resp: Response, key: ResponseBodyKey) -> String =
"Elixir.Map" "fetch!"
@external(erlang, "Elixir.Map", "fetch!")
fn get_response_body(resp resp: Response, key key: ResponseBodyKey) -> String
external fn get_response_status(resp: Response, key: ResponseStatusKey) -> Int =
"Elixir.Map" "fetch!"
@external(erlang, "Elixir.Map", "fetch!")
fn get_response_status(resp resp: Response, key key: ResponseStatusKey) -> Int
external fn get_response_headers(
resp: Response,
key: ResponseHeadersKey,
) -> Headers =
"Elixir.Map" "fetch!"
@external(erlang, "Elixir.Map", "fetch!")
fn get_response_headers(
resp resp: Response,
key key: ResponseHeadersKey,
) -> Headers

View file

@ -6,7 +6,7 @@
import gleam/dynamic
/// A timeout value, either infinite or a specified amount of milliseconds.
pub external type Timeout
pub type Timeout
/// Create an infinite timeout.
pub fn infinity() -> Timeout {

View file

@ -163,5 +163,5 @@ type LoggerOption {
type LoggerOptions =
List(LoggerOption)
external fn configure_logger(LoggerOptions) -> Nil =
"Elixir.Logger" "configure"
@external(erlang, "Elixir.Logger", "configure")
fn configure_logger(a: LoggerOptions) -> Nil