-module(admin@products). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/admin/products.gleam"). -export([product_to_json/1, product_edge_to_json/1, get_products_query_to_json/1, get_products_admin_client_response_to_json/1, product_decoder/0, product_edge_decoder/0, get_products_admin_client_response_decoder/0, get_products/6]). -export_type([get_products_query/0, product_connection/0, product/0, product_option/0, money/0, product_price_range/0, product_compare_at_price_range/0, product_variant_connection/0, product_variant_edge/0, product_variant/0, selected_option/0, media_connection/0, media_edge/0, media/0, preview/0, image/0, seo/0, variants_count/0]). -type get_products_query() :: {get_products_query, product_connection()}. -type product_connection() :: {product_connection, list(admin@types:edge(product())), admin@types:pagination()}. -type product() :: {product, binary(), binary(), binary(), gleam@option:option(integer()), gleam@option:option(binary()), gleam@option:option(binary()), binary(), list(product_option()), product_price_range(), gleam@option:option(product_compare_at_price_range()), product_variant_connection(), gleam@option:option(media()), media_connection(), gleam@option:option(seo()), list(binary()), binary(), binary(), gleam@option:option(binary()), variants_count()}. -type product_option() :: {product_option, binary(), binary(), list(binary())}. -type money() :: {money, binary(), binary()}. -type product_price_range() :: {product_price_range, money(), money()}. -type product_compare_at_price_range() :: {product_compare_at_price_range, gleam@option:option(money()), gleam@option:option(money())}. -type product_variant_connection() :: {product_variant_connection, list(product_variant_edge())}. -type product_variant_edge() :: {product_variant_edge, product_variant()}. -type product_variant() :: {product_variant, binary(), binary(), boolean(), list(selected_option()), binary()}. -type selected_option() :: {selected_option, binary(), binary()}. -type media_connection() :: {media_connection, list(media_edge())}. -type media_edge() :: {media_edge, media()}. -type media() :: {media, binary(), binary(), gleam@option:option(binary()), gleam@option:option(preview())}. -type preview() :: {preview, gleam@option:option(image()), binary()}. -type image() :: {image, binary(), binary(), gleam@option:option(binary()), gleam@option:option(integer()), gleam@option:option(integer()), gleam@option:option(binary())}. -type seo() :: {seo, gleam@option:option(binary()), gleam@option:option(binary())}. -type variants_count() :: {variants_count, integer(), binary()}. -file("src/admin/products.gleam", 393). -spec product_option_to_json(product_option()) -> gleam@json:json(). product_option_to_json(Product_option) -> {product_option, Id, Name, Values} = Product_option, gleam@json:object( [{<<"id"/utf8>>, gleam@json:string(Id)}, {<<"name"/utf8>>, gleam@json:string(Name)}, {<<"values"/utf8>>, gleam@json:array(Values, fun gleam@json:string/1)}] ). -file("src/admin/products.gleam", 402). -spec product_option_decoder() -> gleam@dynamic@decode:decoder(product_option()). product_option_decoder() -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:field( <<"name"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Name) -> gleam@dynamic@decode:field( <<"values"/utf8>>, gleam@dynamic@decode:list( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Values) -> gleam@dynamic@decode:success( {product_option, Id, Name, Values} ) end ) end ) end ). -file("src/admin/products.gleam", 413). -spec money_to_json(money()) -> gleam@json:json(). money_to_json(Money) -> {money, Amount, Currency_code} = Money, gleam@json:object( [{<<"amount"/utf8>>, gleam@json:string(Amount)}, {<<"currencyCode"/utf8>>, gleam@json:string(Currency_code)}] ). -file("src/admin/products.gleam", 421). -spec money_decoder() -> gleam@dynamic@decode:decoder(money()). money_decoder() -> gleam@dynamic@decode:field( <<"amount"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Amount) -> gleam@dynamic@decode:field( <<"currencyCode"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Currency_code) -> gleam@dynamic@decode:success({money, Amount, Currency_code}) end ) end ). -file("src/admin/products.gleam", 431). -spec product_price_range_to_json(product_price_range()) -> gleam@json:json(). product_price_range_to_json(Product_price_range) -> {product_price_range, Max_variant_price, Min_variant_price} = Product_price_range, gleam@json:object( [{<<"maxVariantPrice"/utf8>>, money_to_json(Max_variant_price)}, {<<"minVariantPrice"/utf8>>, money_to_json(Min_variant_price)}] ). -file("src/admin/products.gleam", 442). -spec product_price_range_decoder() -> gleam@dynamic@decode:decoder(product_price_range()). product_price_range_decoder() -> gleam@dynamic@decode:field( <<"maxVariantPrice"/utf8>>, money_decoder(), fun(Max_variant_price) -> gleam@dynamic@decode:field( <<"minVariantPrice"/utf8>>, money_decoder(), fun(Min_variant_price) -> gleam@dynamic@decode:success( {product_price_range, Max_variant_price, Min_variant_price} ) end ) end ). -file("src/admin/products.gleam", 455). -spec product_compare_at_price_range_to_json(product_compare_at_price_range()) -> gleam@json:json(). product_compare_at_price_range_to_json(Product_compare_at_price_range) -> {product_compare_at_price_range, Max_variant_compare_at_price, Min_variant_compare_at_price} = Product_compare_at_price_range, gleam@json:object( [{<<"maxVariantCompareAtPrice"/utf8>>, case Max_variant_compare_at_price of none -> gleam@json:null(); {some, Value} -> money_to_json(Value) end}, {<<"minVariantCompareAtPrice"/utf8>>, case Min_variant_compare_at_price of none -> gleam@json:null(); {some, Value@1} -> money_to_json(Value@1) end}] ). -file("src/admin/products.gleam", 474). -spec product_compare_at_price_range_decoder() -> gleam@dynamic@decode:decoder(product_compare_at_price_range()). product_compare_at_price_range_decoder() -> gleam@dynamic@decode:field( <<"maxVariantCompareAtPrice"/utf8>>, gleam@dynamic@decode:optional(money_decoder()), fun(Max_variant_compare_at_price) -> gleam@dynamic@decode:field( <<"minVariantCompareAtPrice"/utf8>>, gleam@dynamic@decode:optional(money_decoder()), fun(Min_variant_compare_at_price) -> gleam@dynamic@decode:success( {product_compare_at_price_range, Max_variant_compare_at_price, Min_variant_compare_at_price} ) end ) end ). -file("src/admin/products.gleam", 581). -spec selected_option_to_json(selected_option()) -> gleam@json:json(). selected_option_to_json(Selected_option) -> {selected_option, Name, Value} = Selected_option, gleam@json:object( [{<<"name"/utf8>>, gleam@json:string(Name)}, {<<"value"/utf8>>, gleam@json:string(Value)}] ). -file("src/admin/products.gleam", 542). -spec product_variant_to_json(product_variant()) -> gleam@json:json(). product_variant_to_json(Product_variant) -> {product_variant, Id, Title, Available_for_sale, Selected_options, Price} = Product_variant, gleam@json:object( [{<<"id"/utf8>>, gleam@json:string(Id)}, {<<"title"/utf8>>, gleam@json:string(Title)}, {<<"availableForSale"/utf8>>, gleam@json:bool(Available_for_sale)}, {<<"selectedOptions"/utf8>>, gleam@json:array( Selected_options, fun selected_option_to_json/1 )}, {<<"price"/utf8>>, gleam@json:string(Price)}] ). -file("src/admin/products.gleam", 518). -spec product_variant_edge_to_json(product_variant_edge()) -> gleam@json:json(). product_variant_edge_to_json(Product_variant_edge) -> {product_variant_edge, Node} = Product_variant_edge, gleam@json:object([{<<"node"/utf8>>, product_variant_to_json(Node)}]). -file("src/admin/products.gleam", 495). -spec product_variant_connection_to_json(product_variant_connection()) -> gleam@json:json(). product_variant_connection_to_json(Product_variant_connection) -> {product_variant_connection, Edges} = Product_variant_connection, gleam@json:object( [{<<"edges"/utf8>>, gleam@json:array(Edges, fun product_variant_edge_to_json/1)}] ). -file("src/admin/products.gleam", 589). -spec selected_option_decoder() -> gleam@dynamic@decode:decoder(selected_option()). selected_option_decoder() -> gleam@dynamic@decode:field( <<"name"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Name) -> gleam@dynamic@decode:field( <<"value"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value) -> gleam@dynamic@decode:success({selected_option, Name, Value}) end ) end ). -file("src/admin/products.gleam", 559). -spec product_variant_decoder() -> gleam@dynamic@decode:decoder(product_variant()). product_variant_decoder() -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:field( <<"title"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Title) -> gleam@dynamic@decode:field( <<"availableForSale"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_bool/1}, fun(Available_for_sale) -> gleam@dynamic@decode:field( <<"selectedOptions"/utf8>>, gleam@dynamic@decode:list( selected_option_decoder() ), fun(Selected_options) -> gleam@dynamic@decode:field( <<"price"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Price) -> gleam@dynamic@decode:success( {product_variant, Id, Title, Available_for_sale, Selected_options, Price} ) end ) end ) end ) end ) end ). -file("src/admin/products.gleam", 527). -spec product_variant_edge_decoder() -> gleam@dynamic@decode:decoder(product_variant_edge()). product_variant_edge_decoder() -> gleam@dynamic@decode:field( <<"node"/utf8>>, product_variant_decoder(), fun(Node) -> gleam@dynamic@decode:success({product_variant_edge, Node}) end ). -file("src/admin/products.gleam", 504). -spec product_variant_connection_decoder() -> gleam@dynamic@decode:decoder(product_variant_connection()). product_variant_connection_decoder() -> gleam@dynamic@decode:field( <<"edges"/utf8>>, gleam@dynamic@decode:list(product_variant_edge_decoder()), fun(Edges) -> gleam@dynamic@decode:success({product_variant_connection, Edges}) end ). -file("src/admin/products.gleam", 692). -spec image_to_json(image()) -> gleam@json:json(). image_to_json(Image) -> {image, Url, Id, Alt_text, Width, Height, Thumbhash} = Image, gleam@json:object( [{<<"url"/utf8>>, gleam@json:string(Url)}, {<<"id"/utf8>>, gleam@json:string(Id)}, {<<"altText"/utf8>>, case Alt_text of none -> gleam@json:null(); {some, Value} -> gleam@json:string(Value) end}, {<<"width"/utf8>>, case Width of none -> gleam@json:null(); {some, Value@1} -> gleam@json:int(Value@1) end}, {<<"height"/utf8>>, case Height of none -> gleam@json:null(); {some, Value@2} -> gleam@json:int(Value@2) end}, {<<"thumbhash"/utf8>>, case Thumbhash of none -> gleam@json:null(); {some, Value@3} -> gleam@json:string(Value@3) end}] ). -file("src/admin/products.gleam", 664). -spec preview_to_json(preview()) -> gleam@json:json(). preview_to_json(Preview) -> {preview, Image, Status} = Preview, gleam@json:object([{<<"image"/utf8>>, case Image of none -> gleam@json:null(); {some, Value} -> image_to_json(Value) end}, {<<"status"/utf8>>, gleam@json:string(Status)}]). -file("src/admin/products.gleam", 636). -spec media_to_json(media()) -> gleam@json:json(). media_to_json(Media) -> {media, Id, Media_content_type, Alt, Preview} = Media, gleam@json:object( [{<<"id"/utf8>>, gleam@json:string(Id)}, {<<"mediaContentType"/utf8>>, gleam@json:string(Media_content_type)}, {<<"alt"/utf8>>, case Alt of none -> gleam@json:null(); {some, Value} -> gleam@json:string(Value) end}, {<<"preview"/utf8>>, case Preview of none -> gleam@json:null(); {some, Value@1} -> preview_to_json(Value@1) end}] ). -file("src/admin/products.gleam", 615). -spec media_edge_to_json(media_edge()) -> gleam@json:json(). media_edge_to_json(Media_edge) -> {media_edge, Node} = Media_edge, gleam@json:object([{<<"node"/utf8>>, media_to_json(Node)}]). -file("src/admin/products.gleam", 599). -spec media_connection_to_json(media_connection()) -> gleam@json:json(). media_connection_to_json(Media_connection) -> {media_connection, Edges} = Media_connection, gleam@json:object( [{<<"edges"/utf8>>, gleam@json:array(Edges, fun media_edge_to_json/1)}] ). -file("src/admin/products.gleam", 716). -spec image_decoder() -> gleam@dynamic@decode:decoder(image()). image_decoder() -> gleam@dynamic@decode:field( <<"url"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Url) -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:field( <<"altText"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Alt_text) -> gleam@dynamic@decode:field( <<"width"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun(Width) -> gleam@dynamic@decode:field( <<"height"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun(Height) -> gleam@dynamic@decode:field( <<"thumbhash"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Thumbhash) -> gleam@dynamic@decode:success( {image, Url, Id, Alt_text, Width, Height, Thumbhash} ) end ) end ) end ) end ) end ) end ). -file("src/admin/products.gleam", 675). -spec preview_decoder() -> gleam@dynamic@decode:decoder(preview()). preview_decoder() -> gleam@dynamic@decode:field( <<"image"/utf8>>, gleam@dynamic@decode:optional(image_decoder()), fun(Image) -> gleam@dynamic@decode:field( <<"status"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Status) -> gleam@dynamic@decode:success({preview, Image, Status}) end ) end ). -file("src/admin/products.gleam", 652). -spec media_decoder() -> gleam@dynamic@decode:decoder(media()). media_decoder() -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:field( <<"mediaContentType"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Media_content_type) -> gleam@dynamic@decode:field( <<"alt"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Alt) -> gleam@dynamic@decode:field( <<"preview"/utf8>>, gleam@dynamic@decode:optional(preview_decoder()), fun(Preview) -> gleam@dynamic@decode:success( {media, Id, Media_content_type, Alt, Preview} ) end ) end ) end ) end ). -file("src/admin/products.gleam", 622). -spec media_edge_decoder() -> gleam@dynamic@decode:decoder(media_edge()). media_edge_decoder() -> gleam@dynamic@decode:field( <<"node"/utf8>>, media_decoder(), fun(Node) -> gleam@dynamic@decode:success({media_edge, Node}) end ). -file("src/admin/products.gleam", 606). -spec media_connection_decoder() -> gleam@dynamic@decode:decoder(media_connection()). media_connection_decoder() -> gleam@dynamic@decode:field( <<"edges"/utf8>>, gleam@dynamic@decode:list(media_edge_decoder()), fun(Edges) -> gleam@dynamic@decode:success({media_connection, Edges}) end ). -file("src/admin/products.gleam", 730). -spec seo_to_json(seo()) -> gleam@json:json(). seo_to_json(Seo) -> {seo, Description, Title} = Seo, gleam@json:object([{<<"description"/utf8>>, case Description of none -> gleam@json:null(); {some, Value} -> gleam@json:string(Value) end}, {<<"title"/utf8>>, case Title of none -> gleam@json:null(); {some, Value@1} -> gleam@json:string(Value@1) end}]). -file("src/admin/products.gleam", 744). -spec seo_decoder() -> gleam@dynamic@decode:decoder(seo()). seo_decoder() -> gleam@dynamic@decode:field( <<"description"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Description) -> gleam@dynamic@decode:field( <<"title"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Title) -> gleam@dynamic@decode:success({seo, Description, Title}) end ) end ). -file("src/admin/products.gleam", 754). -spec variants_count_to_json(variants_count()) -> gleam@json:json(). variants_count_to_json(Variants_count) -> {variants_count, Count, Precision} = Variants_count, gleam@json:object( [{<<"count"/utf8>>, gleam@json:int(Count)}, {<<"precision"/utf8>>, gleam@json:string(Precision)}] ). -file("src/admin/products.gleam", 262). -spec product_to_json(product()) -> gleam@json:json(). product_to_json(Product) -> {product, Id, Handle, Title, Total_inventory, Description, Description_html, Vendor, Options, Price_range_v2, Compare_at_price_range, Variants, Featured_media, Media, Seo, Tags, Updated_at, Created_at, Published_at, Variants_count} = Product, gleam@json:object( [{<<"id"/utf8>>, gleam@json:string(Id)}, {<<"handle"/utf8>>, gleam@json:string(Handle)}, {<<"title"/utf8>>, gleam@json:string(Title)}, {<<"totalInventory"/utf8>>, case Total_inventory of none -> gleam@json:null(); {some, Value} -> gleam@json:int(Value) end}, {<<"description"/utf8>>, case Description of none -> gleam@json:null(); {some, Value@1} -> gleam@json:string(Value@1) end}, {<<"descriptionHtml"/utf8>>, case Description_html of none -> gleam@json:null(); {some, Value@2} -> gleam@json:string(Value@2) end}, {<<"vendor"/utf8>>, gleam@json:string(Vendor)}, {<<"options"/utf8>>, gleam@json:array(Options, fun product_option_to_json/1)}, {<<"priceRangeV2"/utf8>>, product_price_range_to_json(Price_range_v2)}, {<<"compareAtPriceRange"/utf8>>, case Compare_at_price_range of none -> gleam@json:null(); {some, Value@3} -> product_compare_at_price_range_to_json(Value@3) end}, {<<"variants"/utf8>>, product_variant_connection_to_json(Variants)}, {<<"featuredMedia"/utf8>>, case Featured_media of none -> gleam@json:null(); {some, Value@4} -> media_to_json(Value@4) end}, {<<"media"/utf8>>, media_connection_to_json(Media)}, {<<"seo"/utf8>>, case Seo of none -> gleam@json:null(); {some, Value@5} -> seo_to_json(Value@5) end}, {<<"tags"/utf8>>, gleam@json:array(Tags, fun gleam@json:string/1)}, {<<"updatedAt"/utf8>>, gleam@json:string(Updated_at)}, {<<"createdAt"/utf8>>, gleam@json:string(Created_at)}, {<<"publishedAt"/utf8>>, case Published_at of none -> gleam@json:null(); {some, Value@6} -> gleam@json:string(Value@6) end}, {<<"variantsCount"/utf8>>, variants_count_to_json(Variants_count)}] ). -file("src/admin/products.gleam", 231). -spec product_edge_to_json(admin@types:edge(product())) -> gleam@json:json(). product_edge_to_json(Edge) -> {edge, Node} = Edge, gleam@json:object([{<<"node"/utf8>>, product_to_json(Node)}]). -file("src/admin/products.gleam", 212). -spec product_connection_to_json(product_connection()) -> gleam@json:json(). product_connection_to_json(Product_connection) -> {product_connection, Edges, Pagination} = Product_connection, gleam@json:object( [{<<"edges"/utf8>>, gleam@json:array(Edges, fun product_edge_to_json/1)}, {<<"pageInfo"/utf8>>, admin@types:pagination_to_json(Pagination)}] ). -file("src/admin/products.gleam", 196). -spec get_products_query_to_json(get_products_query()) -> gleam@json:json(). get_products_query_to_json(Get_products_query) -> {get_products_query, Products} = Get_products_query, gleam@json:object( [{<<"products"/utf8>>, product_connection_to_json(Products)}] ). -file("src/admin/products.gleam", 180). -spec get_products_admin_client_response_to_json( pify:admin_client_response(get_products_query()) ) -> gleam@json:json(). get_products_admin_client_response_to_json(Admin_client_response) -> {admin_client_response, Data} = Admin_client_response, gleam@json:object([{<<"data"/utf8>>, case Data of none -> gleam@json:null(); {some, Value} -> get_products_query_to_json(Value) end}]). -file("src/admin/products.gleam", 762). -spec variants_count_decoder() -> gleam@dynamic@decode:decoder(variants_count()). variants_count_decoder() -> gleam@dynamic@decode:field( <<"count"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Count) -> gleam@dynamic@decode:field( <<"precision"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Precision) -> gleam@dynamic@decode:success( {variants_count, Count, Precision} ) end ) end ). -file("src/admin/products.gleam", 328). -spec product_decoder() -> gleam@dynamic@decode:decoder(product()). product_decoder() -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:field( <<"handle"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Handle) -> gleam@dynamic@decode:field( <<"title"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Title) -> gleam@dynamic@decode:field( <<"totalInventory"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun(Total_inventory) -> gleam@dynamic@decode:field( <<"description"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Description) -> gleam@dynamic@decode:field( <<"descriptionHtml"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Description_html) -> gleam@dynamic@decode:field( <<"vendor"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Vendor) -> gleam@dynamic@decode:field( <<"options"/utf8>>, gleam@dynamic@decode:list( product_option_decoder( ) ), fun(Options) -> gleam@dynamic@decode:field( <<"priceRangeV2"/utf8>>, product_price_range_decoder( ), fun( Price_range_v2 ) -> gleam@dynamic@decode:field( <<"compareAtPriceRange"/utf8>>, gleam@dynamic@decode:optional( product_compare_at_price_range_decoder( ) ), fun( Compare_at_price_range ) -> gleam@dynamic@decode:field( <<"variants"/utf8>>, product_variant_connection_decoder( ), fun( Variants ) -> gleam@dynamic@decode:field( <<"featuredMedia"/utf8>>, gleam@dynamic@decode:optional( media_decoder( ) ), fun( Featured_media ) -> gleam@dynamic@decode:field( <<"media"/utf8>>, media_connection_decoder( ), fun( Media ) -> gleam@dynamic@decode:field( <<"seo"/utf8>>, gleam@dynamic@decode:optional( seo_decoder( ) ), fun( Seo ) -> gleam@dynamic@decode:field( <<"tags"/utf8>>, gleam@dynamic@decode:list( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun( Tags ) -> gleam@dynamic@decode:field( <<"updatedAt"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun( Updated_at ) -> gleam@dynamic@decode:field( <<"createdAt"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun( Created_at ) -> gleam@dynamic@decode:field( <<"publishedAt"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun( Published_at ) -> gleam@dynamic@decode:field( <<"variantsCount"/utf8>>, variants_count_decoder( ), fun( Variants_count ) -> gleam@dynamic@decode:success( {product, Id, Handle, Title, Total_inventory, Description, Description_html, Vendor, Options, Price_range_v2, Compare_at_price_range, Variants, Featured_media, Media, Seo, Tags, Updated_at, Created_at, Published_at, Variants_count} ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ). -file("src/admin/products.gleam", 226). -spec product_edge_decoder() -> gleam@dynamic@decode:decoder(admin@types:edge(product())). product_edge_decoder() -> gleam@dynamic@decode:field( <<"node"/utf8>>, product_decoder(), fun(Node) -> gleam@dynamic@decode:success({edge, Node}) end ). -file("src/admin/products.gleam", 220). -spec product_connection_decoder() -> gleam@dynamic@decode:decoder(product_connection()). product_connection_decoder() -> gleam@dynamic@decode:field( <<"edges"/utf8>>, gleam@dynamic@decode:list(product_edge_decoder()), fun(Edges) -> gleam@dynamic@decode:field( <<"pageInfo"/utf8>>, admin@types:pagination_decoder(), fun(Pagination) -> gleam@dynamic@decode:success( {product_connection, Edges, Pagination} ) end ) end ). -file("src/admin/products.gleam", 203). -spec get_products_query_decoder() -> gleam@dynamic@decode:decoder(get_products_query()). get_products_query_decoder() -> gleam@dynamic@decode:field( <<"products"/utf8>>, product_connection_decoder(), fun(Products) -> gleam@dynamic@decode:success({get_products_query, Products}) end ). -file("src/admin/products.gleam", 169). -spec get_products_admin_client_response_decoder() -> gleam@dynamic@decode:decoder(pify:admin_client_response(get_products_query())). get_products_admin_client_response_decoder() -> gleam@dynamic@decode:field( <<"data"/utf8>>, gleam@dynamic@decode:optional(get_products_query_decoder()), fun(Data) -> gleam@dynamic@decode:success({admin_client_response, Data}) end ). -file("src/admin/products.gleam", 132). -spec get_products( pify:admin_api_client_config(), gleam@option:option(binary()), gleam@option:option(boolean()), gleam@option:option(admin@types:sort_key()), integer(), gleam@option:option(binary()) ) -> midas@task:effect(get_products_query(), pify:admin_response_errors()). get_products(Config, Query, Reverse, Sort_key, Num_products, Cursor) -> Validade_int = case Num_products =< 0 of true -> 1; _ -> Num_products end, Handler = pify:admin_handler(Config), Variables = gleam@json:object( [{<<"query"/utf8>>, gleam@json:nullable(Query, fun gleam@json:string/1)}, {<<"reverse"/utf8>>, gleam@json:nullable(Reverse, fun gleam@json:bool/1)}, {<<"sortKey"/utf8>>, gleam@json:nullable( Sort_key, fun admin@types:sort_key_to_json/1 )}, {<<"numProducts"/utf8>>, gleam@json:int(Validade_int)}, {<<"cursor"/utf8>>, gleam@json:nullable(Cursor, fun gleam@json:string/1)}] ), midas@task:do( (erlang:element(3, Handler))( <<" query getProducts($numProducts: Int!, $cursor: String, $sortKey: ProductSortKeys, $reverse: Boolean, $query: String) { products( first: $numProducts after: $cursor sortKey: $sortKey reverse: $reverse query: $query ) { edges { node { id handle title totalInventory description descriptionHtml vendor options { id name values } priceRangeV2 { maxVariantPrice { amount currencyCode } minVariantPrice { amount currencyCode } } compareAtPriceRange { maxVariantCompareAtPrice { amount currencyCode } minVariantCompareAtPrice { amount currencyCode } } variants(first: 20) { edges { node { id title availableForSale selectedOptions { name value } price } } } featuredMedia { id mediaContentType alt preview { image { url id altText width height thumbhash } status } } media(first: 20) { edges { node { id mediaContentType alt preview { image { url id altText width height thumbhash } status } } } } seo { description title } tags updatedAt createdAt publishedAt variantsCount { count precision } } } pageInfo { hasNextPage hasPreviousPage startCursor endCursor } } } "/utf8>>, {some, Variables}, get_products_admin_client_response_decoder() ), fun(Decoded_response) -> Products = erlang:element(2, Decoded_response), case Products of none -> {abort, snag:new(<<"No product to be fetched"/utf8>>)}; {some, Value} -> {done, Value} end end ).