Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
4.2 kB 128 lines
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129import albedo_sqliteimport gleam/dynamic/decodeimport gleam/option.{type Option}import sqlight
/// Shared return type for queries in this directory:/// src/albedo_ext_webhooks/receipts/sql/lettered.sql/// src/albedo_ext_webhooks/receipts/sql/list_delivered_receipts_after.sql/// src/albedo_ext_webhooks/receipts/sql/list_delivery_receipts_after.sqlpub type ReceiptRow { ReceiptRow( id: String, hook: String, session: String, received_at: String, delivered_at: Option(String), attempts: Int, deferral: Option(String), )}
fn receipt_row_decoder() -> decode.Decoder(ReceiptRow) { use id <- decode.field(0, decode.string) use hook <- decode.field(1, decode.string) use session <- decode.field(2, decode.string) use received_at <- decode.field(3, decode.string) use delivered_at <- decode.field(4, decode.optional(decode.string)) use attempts <- decode.field(5, decode.int) use deferral <- decode.field(6, decode.optional(decode.string)) decode.success(ReceiptRow( id:, hook:, session:, received_at:, delivered_at:, attempts:, deferral:, ))}
/// Generated from src/albedo_ext_webhooks/receipts/sql/lettered.sqlpub fn lettered( db db: sqlight.Connection, ids ids: String,) -> Result(List(ReceiptRow), String) { albedo_sqlite.rows( "SELECT id AS id,hook AS hook,session,received_at,delivered_at,attempts,last_error AS deferral FROM webhook_deliveries WHERE id IN (SELECT value FROM json_each(@ids)) ORDER BY id", on: db, with: [sqlight.text(ids)], expecting: receipt_row_decoder(), )}
/// Generated from src/albedo_ext_webhooks/receipts/sql/list_delivered_receipts_after.sqlpub fn list_delivered_receipts_after( db db: sqlight.Connection, hook hook: String, after after: String, limit limit: Int,) -> Result(List(ReceiptRow), String) { albedo_sqlite.rows( "SELECT id AS id,hook AS hook,session,received_at,delivered_at,attempts,last_error AS deferral FROM webhook_deliveries WHERE hook=@hook AND delivered_at IS NOT NULL AND id>@after ORDER BY id LIMIT @limit", on: db, with: [sqlight.text(hook), sqlight.text(after), sqlight.int(limit)], expecting: receipt_row_decoder(), )}
/// Generated from src/albedo_ext_webhooks/receipts/sql/list_delivery_receipts_after.sqlpub fn list_delivery_receipts_after( db db: sqlight.Connection, hook hook: String, after after: String, limit limit: Int,) -> Result(List(ReceiptRow), String) { albedo_sqlite.rows( "SELECT id AS id,hook AS hook,session,received_at,delivered_at,attempts,last_error AS deferral FROM webhook_deliveries WHERE hook=@hook AND id>@after ORDER BY id LIMIT @limit", on: db, with: [sqlight.text(hook), sqlight.text(after), sqlight.int(limit)], expecting: receipt_row_decoder(), )}
/// Generated from src/albedo_ext_webhooks/receipts/sql/receipt_with_body.sqlpub type ReceiptWithBodyRow { ReceiptWithBodyRow( id: String, hook: String, session: String, received_at: String, delivered_at: Option(String), attempts: Int, deferral: Option(String), body: BitArray, )}
/// Generated from src/albedo_ext_webhooks/receipts/sql/receipt_with_body.sqlpub fn receipt_with_body( db db: sqlight.Connection, id id: String,) -> Result(List(ReceiptWithBodyRow), String) { albedo_sqlite.rows( "SELECT id AS id,hook AS hook,session,received_at,delivered_at,attempts,last_error AS deferral,body FROM webhook_deliveries WHERE id=@id", on: db, with: [sqlight.text(id)], expecting: { use id <- decode.field(0, decode.string) use hook <- decode.field(1, decode.string) use session <- decode.field(2, decode.string) use received_at <- decode.field(3, decode.string) use delivered_at <- decode.field(4, decode.optional(decode.string)) use attempts <- decode.field(5, decode.int) use deferral <- decode.field(6, decode.optional(decode.string)) use body <- decode.field(7, decode.bit_array) decode.success(ReceiptWithBodyRow( id:, hook:, session:, received_at:, delivered_at:, attempts:, deferral:, body:, )) }, )}