-module(dewey). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/dewey.gleam"). -export([new_client/2, default_get_documents_options/0, get_tasks/2, get_one_task/2, cancel_tasks/2, delete_tasks/2, delete_all_tasks/1, get_all_indexes/1, get_one_index/2, create_index/3, update_index/3, delete_index/2, swap_indexes/2, rename_indexes/2, get_documents/4, get_one_document/4, add_or_replace_documents/4, add_or_update_documents/4, delete_all_documents/2, delete_one_document/3, delete_documents_by_filter/3, delete_documents_by_batch/3, search/5]). -export_type([dewey_error/0, client/0, summarized_task/0, task/0, task_status/0, task_type/0, task_details/0, task_error/0, tasks_param/0, index/0, documents_response/1, get_documents_options/0, search_param/0, search_response/1, swap/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -type dewey_error() :: {j_s_o_n_decode_error, gleam@json:decode_error()} | {a_p_i_error, binary(), binary(), binary(), binary()} | unexpected_a_p_i_error. -opaque client() :: {client, binary(), binary()}. -type summarized_task() :: {summarized_task, integer(), gleam@option:option(binary()), task_status(), task_type(), gleam@time@timestamp:timestamp()}. -type task() :: {task, integer(), gleam@option:option(binary()), integer(), task_status(), task_type(), gleam@option:option(integer()), gleam@option:option(task_details()), gleam@option:option(task_error()), gleam@time@timestamp:timestamp(), gleam@option:option(gleam@time@timestamp:timestamp()), gleam@option:option(gleam@time@timestamp:timestamp())}. -type task_status() :: enqueued | processing | succeeded | failed | canceled | unexpected_task_status. -type task_type() :: index_creation | index_update | index_deletion | index_swap | document_addition_or_update | document_deletion | settings_update | dump_creation | task_cancelation | task_deletion | upgrade_database | document_edition | snapshot_creation | unexpected_task_type. -type task_details() :: {document_addition_or_update_details, integer(), gleam@option:option(integer())} | {document_deletion_details, integer(), gleam@option:option(binary()), gleam@option:option(integer())} | {index_creation_or_update_details, gleam@option:option(binary())} | {index_deletion_details, gleam@option:option(integer())} | {index_swap_details, list(swap())} | {settings_update_details, gleam@option:option(list(binary())), gleam@option:option(binary()), gleam@option:option(list(binary())), gleam@option:option(list(binary())), gleam@option:option(list(binary())), gleam@option:option(list(binary()))} | {dump_creation_details, gleam@option:option(binary())} | {task_cancelation_details, integer(), gleam@option:option(integer()), binary()} | {task_deletion_details, integer(), gleam@option:option(integer()), binary()}. -type task_error() :: {task_error, binary(), binary(), binary(), binary()}. -type tasks_param() :: {tasks_by_u_i_ds, list(integer())} | {tasks_by_batch_u_i_ds, list(integer())} | {tasks_by_statuses, list(task_status())} | {tasks_by_types, list(task_type())} | {tasks_by_index_u_i_ds, list(binary())} | {tasks_limit, integer()} | {tasks_from_task_u_i_d, integer()} | {tasks_in_reverse, boolean()} | {tasks_before_enqueued_at, gleam@time@timestamp:timestamp()} | {tasks_after_enqueued_at, gleam@time@timestamp:timestamp()} | {tasks_before_started_at, gleam@time@timestamp:timestamp()} | {tasks_after_started_at, gleam@time@timestamp:timestamp()} | {tasks_before_finished_at, gleam@time@timestamp:timestamp()} | {tasks_after_finished_at, gleam@time@timestamp:timestamp()}. -type index() :: {index, binary(), gleam@time@timestamp:timestamp(), gleam@time@timestamp:timestamp(), binary()}. -type documents_response(FIT) :: {documents_response, list(FIT), integer(), integer(), integer()}. -type get_documents_options() :: {get_documents_options, integer(), integer(), gleam@option:option(list(binary())), gleam@option:option(binary()), boolean(), gleam@option:option(binary()), gleam@option:option(list(binary()))}. -type search_param() :: {search_offset, integer()} | {search_limit, integer()} | {search_hits_per_page, integer()} | {search_page, integer()} | {search_filter, binary()} | {search_distinct_attribute, binary()} | {search_attributes_to_retrieve, list(binary())} | {search_attributes_to_crop, list(binary())} | {search_crop_length, integer()} | {search_crop_marker, binary()} | {search_attributes_to_highlight, list(binary())} | {search_highlight_pre_tag, binary()} | {search_highligh_post_tag, binary()} | {search_show_matches_position, boolean()} | {search_sort_attributes, list(binary())} | {search_matching_strategy, binary()} | {search_show_ranking_score, boolean()} | {search_show_ranking_score_details, boolean()} | {search_ranking_score_threshold, float()} | {search_attributes_to_search_on, list(binary())} | {search_vector, list(float())} | {search_retrieve_vectors, boolean()} | {search_locales, list(binary())}. -type search_response(FIU) :: {search_response, list(FIU), integer(), integer(), gleam@option:option(integer()), gleam@option:option(integer()), gleam@option:option(integer()), gleam@option:option(integer()), integer(), binary(), binary()}. -type swap() :: {swap, {binary(), binary()}, boolean()}. -file("src/dewey.gleam", 36). -spec new_client(binary(), binary()) -> {ok, client()} | {error, nil}. new_client(Url, Api_key) -> {ok, {client, Url, Api_key}}. -file("src/dewey.gleam", 96). -spec string_to_task_status(binary()) -> task_status(). string_to_task_status(Str) -> case Str of <<"enqueued"/utf8>> -> enqueued; <<"processing"/utf8>> -> processing; <<"succeeded"/utf8>> -> succeeded; <<"failed"/utf8>> -> failed; <<"canceled"/utf8>> -> canceled; _ -> unexpected_task_status end. -file("src/dewey.gleam", 107). -spec task_status_to_string(task_status()) -> binary(). task_status_to_string(Status) -> case Status of enqueued -> <<"enqueued"/utf8>>; processing -> <<"processing"/utf8>>; succeeded -> <<"succeeded"/utf8>>; failed -> <<"failed"/utf8>>; canceled -> <<"canceled"/utf8>>; unexpected_task_status -> <<""/utf8>> end. -file("src/dewey.gleam", 139). -spec string_to_task_type(binary()) -> task_type(). string_to_task_type(Str) -> case Str of <<"indexCreation"/utf8>> -> index_creation; <<"indexUpdate"/utf8>> -> index_update; <<"indexDeletion"/utf8>> -> index_deletion; <<"indexSwap"/utf8>> -> index_swap; <<"documentAdditionOrUpdate"/utf8>> -> document_addition_or_update; <<"documentDeletion"/utf8>> -> document_deletion; <<"settingsUpdate"/utf8>> -> settings_update; <<"dumpCreation"/utf8>> -> dump_creation; <<"taskCancelation"/utf8>> -> task_cancelation; <<"taskDeletion"/utf8>> -> task_deletion; <<"upgradeDatabase"/utf8>> -> upgrade_database; <<"documentEdition"/utf8>> -> document_edition; <<"snapshotCreation"/utf8>> -> snapshot_creation; _ -> unexpected_task_type end. -file("src/dewey.gleam", 158). -spec task_type_to_string(task_type()) -> binary(). task_type_to_string(Task_type) -> case Task_type of index_creation -> <<"indexCreation"/utf8>>; index_update -> <<"indexUpdate"/utf8>>; index_deletion -> <<"indexDeletion"/utf8>>; index_swap -> <<"indexSwap"/utf8>>; document_addition_or_update -> <<"documentAdditionOrUpdate"/utf8>>; document_deletion -> <<"documentDeletion"/utf8>>; settings_update -> <<"settingsUpdate"/utf8>>; dump_creation -> <<"dumpCreation"/utf8>>; task_cancelation -> <<"taskCancelation"/utf8>>; task_deletion -> <<"taskDeletion"/utf8>>; upgrade_database -> <<"upgradeDatabase"/utf8>>; document_edition -> <<"documentEdition"/utf8>>; snapshot_creation -> <<"snapshotCreation"/utf8>>; unexpected_task_type -> <<""/utf8>> end. -file("src/dewey.gleam", 237). -spec tasks_param_to_tuple(tasks_param()) -> {binary(), binary()}. tasks_param_to_tuple(Param) -> case Param of {tasks_by_u_i_ds, Uids} -> Uids@1 = gleam@list:map(Uids, fun erlang:integer_to_binary/1), {<<"uids"/utf8>>, gleam@string:join(Uids@1, <<","/utf8>>)}; {tasks_by_batch_u_i_ds, Batch_uids} -> Batch_uids@1 = gleam@list:map( Batch_uids, fun erlang:integer_to_binary/1 ), {<<"batchUids"/utf8>>, gleam@string:join(Batch_uids@1, <<","/utf8>>)}; {tasks_by_statuses, Statuses} -> Statuses@1 = gleam@list:map(Statuses, fun task_status_to_string/1), {<<"statuses"/utf8>>, gleam@string:join(Statuses@1, <<","/utf8>>)}; {tasks_by_types, Types} -> Types@1 = gleam@list:map(Types, fun task_type_to_string/1), {<<"types"/utf8>>, gleam@string:join(Types@1, <<","/utf8>>)}; {tasks_by_index_u_i_ds, Index_uids} -> {<<"indexUids"/utf8>>, gleam@string:join(Index_uids, <<","/utf8>>)}; {tasks_limit, Limit} -> {<<"limit"/utf8>>, erlang:integer_to_binary(Limit)}; {tasks_from_task_u_i_d, From_uid} -> {<<"from"/utf8>>, erlang:integer_to_binary(From_uid)}; {tasks_in_reverse, Reverse} -> {<<"reverse"/utf8>>, string:lowercase(gleam@bool:to_string(Reverse))}; {tasks_before_enqueued_at, Before_enqueued_at} -> {<<"beforeEnqueuedAt"/utf8>>, gleam@time@timestamp:to_rfc3339( Before_enqueued_at, gleam@time@duration:seconds(0) )}; {tasks_after_enqueued_at, After_enqueued_at} -> {<<"afterEnqueuedAt"/utf8>>, gleam@time@timestamp:to_rfc3339( After_enqueued_at, gleam@time@duration:seconds(0) )}; {tasks_before_started_at, Before_started_at} -> {<<"beforeStartedAt"/utf8>>, gleam@time@timestamp:to_rfc3339( Before_started_at, gleam@time@duration:seconds(0) )}; {tasks_after_started_at, After_started_at} -> {<<"afterStartedAt"/utf8>>, gleam@time@timestamp:to_rfc3339( After_started_at, gleam@time@duration:seconds(0) )}; {tasks_before_finished_at, Before_finished_at} -> {<<"beforeFinishedAt"/utf8>>, gleam@time@timestamp:to_rfc3339( Before_finished_at, gleam@time@duration:seconds(0) )}; {tasks_after_finished_at, After_finished_at} -> {<<"afterFinishedAt"/utf8>>, gleam@time@timestamp:to_rfc3339( After_finished_at, gleam@time@duration:seconds(0) )} end. -file("src/dewey.gleam", 587). ?DOC( " A function returning the default set of options for the Get Documents endpoint.\n" " \n" " These options are outlined at: https://www.meilisearch.com/docs/reference/api/documents#body\n" ). -spec default_get_documents_options() -> get_documents_options(). default_get_documents_options() -> {get_documents_options, 0, 20, none, none, false, none, none}. -file("src/dewey.gleam", 842). -spec search_param_to_json_field(search_param()) -> {binary(), gleam@json:json()}. search_param_to_json_field(Param) -> case Param of {search_offset, Offset} -> {<<"offset"/utf8>>, gleam@json:int(Offset)}; {search_limit, Limit} -> {<<"limit"/utf8>>, gleam@json:int(Limit)}; {search_hits_per_page, Hits} -> {<<"hitsPerPage"/utf8>>, gleam@json:int(Hits)}; {search_page, Page_num} -> {<<"page"/utf8>>, gleam@json:int(Page_num)}; {search_filter, Filter} -> {<<"filter"/utf8>>, gleam@json:string(Filter)}; {search_distinct_attribute, Attribute} -> {<<"distinct"/utf8>>, gleam@json:string(Attribute)}; {search_attributes_to_retrieve, Attributes} -> {<<"attributesToRetrieve"/utf8>>, gleam@json:array(Attributes, fun gleam@json:string/1)}; {search_attributes_to_crop, Attributes@1} -> {<<"attributesToCrop"/utf8>>, gleam@json:array(Attributes@1, fun gleam@json:string/1)}; {search_crop_length, Length} -> {<<"cropLength"/utf8>>, gleam@json:int(Length)}; {search_crop_marker, Marker} -> {<<"cropMarker"/utf8>>, gleam@json:string(Marker)}; {search_attributes_to_highlight, Attributes@2} -> {<<"attributesToHighlight"/utf8>>, gleam@json:array(Attributes@2, fun gleam@json:string/1)}; {search_highlight_pre_tag, Pre_tag} -> {<<"highlightPreTag"/utf8>>, gleam@json:string(Pre_tag)}; {search_highligh_post_tag, Post_tag} -> {<<"highlightPostTag"/utf8>>, gleam@json:string(Post_tag)}; {search_show_matches_position, Show_matches_position} -> {<<"showMatchesPosition"/utf8>>, gleam@json:bool(Show_matches_position)}; {search_sort_attributes, Attributes@3} -> {<<"sort"/utf8>>, gleam@json:array(Attributes@3, fun gleam@json:string/1)}; {search_matching_strategy, Strategy} -> {<<"matchingStrategy"/utf8>>, gleam@json:string(Strategy)}; {search_show_ranking_score, Show_ranking_score} -> {<<"showRankingScore"/utf8>>, gleam@json:bool(Show_ranking_score)}; {search_show_ranking_score_details, Show_ranking_score_details} -> {<<"showRankingScoreDetails"/utf8>>, gleam@json:bool(Show_ranking_score_details)}; {search_ranking_score_threshold, Threshold} -> {<<"rankingScoreThreshold"/utf8>>, gleam@json:float(Threshold)}; {search_attributes_to_search_on, Attributes@4} -> {<<"attributesToSearchOn"/utf8>>, gleam@json:array(Attributes@4, fun gleam@json:string/1)}; {search_vector, Vector} -> {<<"vector"/utf8>>, gleam@json:array(Vector, fun gleam@json:float/1)}; {search_retrieve_vectors, Retrieve_vectors} -> {<<"retrieveVectors"/utf8>>, gleam@json:bool(Retrieve_vectors)}; {search_locales, Locales} -> {<<"locales"/utf8>>, gleam@json:array(Locales, fun gleam@json:string/1)} end. -file("src/dewey.gleam", 1005). -spec summarized_task_decoder() -> gleam@dynamic@decode:decoder(summarized_task()). summarized_task_decoder() -> gleam@dynamic@decode:field( <<"taskUid"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Task_uid) -> gleam@dynamic@decode:field( <<"indexUid"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Index_uid) -> gleam@dynamic@decode:field( <<"status"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Status_str) -> gleam@dynamic@decode:field( <<"type"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Type_str) -> gleam@dynamic@decode:field( <<"enqueuedAt"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Enqueued_at_str) -> Status = string_to_task_status( Status_str ), Task_type = string_to_task_type( Type_str ), Enqueued_at = begin _pipe = gleam@time@timestamp:parse_rfc3339( Enqueued_at_str ), gleam@result:unwrap( _pipe, gleam@time@timestamp:from_unix_seconds( 0 ) ) end, gleam@dynamic@decode:success( {summarized_task, Task_uid, Index_uid, Status, Task_type, Enqueued_at} ) end ) end ) end ) end ) end ). -file("src/dewey.gleam", 1030). -spec index_decoder() -> gleam@dynamic@decode:decoder(index()). index_decoder() -> gleam@dynamic@decode:field( <<"uid"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Uid) -> gleam@dynamic@decode:field( <<"createdAt"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Created_at_string) -> gleam@dynamic@decode:field( <<"updatedAt"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Updated_at_string) -> gleam@dynamic@decode:field( <<"primaryKey"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Primary_key) -> Created_at = begin _pipe = gleam@time@timestamp:parse_rfc3339( Created_at_string ), gleam@result:unwrap( _pipe, gleam@time@timestamp:from_unix_seconds( 0 ) ) end, Updated_at = begin _pipe@1 = gleam@time@timestamp:parse_rfc3339( Updated_at_string ), gleam@result:unwrap( _pipe@1, gleam@time@timestamp:from_unix_seconds( 0 ) ) end, gleam@dynamic@decode:success( {index, Uid, Created_at, Updated_at, Primary_key} ) end ) end ) end ) end ). -file("src/dewey.gleam", 1106). -spec task_details_decoder() -> gleam@dynamic@decode:decoder(gleam@option:option(task_details())). task_details_decoder() -> Document_addition_or_update = begin gleam@dynamic@decode:field( <<"receivedDocuments"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Received_documents) -> gleam@dynamic@decode:field( <<"indexedDocuments"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun(Indexed_documents) -> gleam@dynamic@decode:success( {document_addition_or_update_details, Received_documents, Indexed_documents} ) end ) end ) end, Document_deletion = begin gleam@dynamic@decode:field( <<"providedIds"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Provided_ids) -> gleam@dynamic@decode:field( <<"originalFilter"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Original_filter) -> gleam@dynamic@decode:field( <<"deletedDocuments"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun(Deleted_documents) -> gleam@dynamic@decode:success( {document_deletion_details, Provided_ids, Original_filter, Deleted_documents} ) end ) end ) end ) end, Index_creation_or_update = begin gleam@dynamic@decode:field( <<"primaryKey"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Primary_key) -> gleam@dynamic@decode:success( {index_creation_or_update_details, Primary_key} ) end ) end, Index_deletion = begin gleam@dynamic@decode:field( <<"deletedDocuments"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun(Deleted_documents@1) -> gleam@dynamic@decode:success( {index_deletion_details, Deleted_documents@1} ) end ) end, Index_swap = begin Swap_decoder = begin gleam@dynamic@decode:field( <<"indexes"/utf8>>, gleam@dynamic@decode:list( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Indexes) -> gleam@dynamic@decode:field( <<"rename"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_bool/1}, fun(Rename) -> case Indexes of [First_index, Second_index] -> gleam@dynamic@decode:success( {swap, {First_index, Second_index}, Rename} ); _ -> gleam@dynamic@decode:failure( {swap, {<<""/utf8>>, <<""/utf8>>}, false}, <<"Swap"/utf8>> ) end end ) end ) end, gleam@dynamic@decode:field( <<"swaps"/utf8>>, gleam@dynamic@decode:list(Swap_decoder), fun(Swaps) -> gleam@dynamic@decode:success({index_swap_details, Swaps}) end ) end, Optional_string_list = gleam@dynamic@decode:optional( gleam@dynamic@decode:list( {decoder, fun gleam@dynamic@decode:decode_string/1} ) ), Settings_update = begin gleam@dynamic@decode:optional_field( <<"rankingRules"/utf8>>, none, Optional_string_list, fun(Ranking_rules) -> gleam@dynamic@decode:optional_field( <<"distinctAttribute"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Distinct_attribute) -> gleam@dynamic@decode:optional_field( <<"searchableAttributes"/utf8>>, none, Optional_string_list, fun(Searchable_attributes) -> gleam@dynamic@decode:optional_field( <<"displayedAttributes"/utf8>>, none, Optional_string_list, fun(Displayed_attributes) -> gleam@dynamic@decode:optional_field( <<"sortableAttributes"/utf8>>, none, Optional_string_list, fun(Sortable_attributes) -> gleam@dynamic@decode:optional_field( <<"stopWords"/utf8>>, none, Optional_string_list, fun(Stop_words) -> gleam@dynamic@decode:success( {settings_update_details, Ranking_rules, Distinct_attribute, Searchable_attributes, Displayed_attributes, Sortable_attributes, Stop_words} ) end ) end ) end ) end ) end ) end ) end, Dump_creation = begin gleam@dynamic@decode:field( <<"dumpUid"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Dump_uid) -> gleam@dynamic@decode:success({dump_creation_details, Dump_uid}) end ) end, Task_cancelation = begin gleam@dynamic@decode:field( <<"matchedTasks"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Matched_tasks) -> gleam@dynamic@decode:field( <<"canceledTasks"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun(Canceled_tasks) -> gleam@dynamic@decode:field( <<"originalFilter"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Original_filter@1) -> gleam@dynamic@decode:success( {task_cancelation_details, Matched_tasks, Canceled_tasks, Original_filter@1} ) end ) end ) end ) end, Task_deletion = begin gleam@dynamic@decode:field( <<"matchedTasks"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Matched_tasks@1) -> gleam@dynamic@decode:field( <<"deletedTasks"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun(Deleted_tasks) -> gleam@dynamic@decode:field( <<"originalFilter"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Original_filter@2) -> gleam@dynamic@decode:success( {task_deletion_details, Matched_tasks@1, Deleted_tasks, Original_filter@2} ) end ) end ) end ) end, gleam@dynamic@decode:optional( gleam@dynamic@decode:one_of( Settings_update, [Document_deletion, Index_creation_or_update, Index_deletion, Index_swap, Document_addition_or_update, Dump_creation, Task_cancelation, Task_deletion] ) ). -file("src/dewey.gleam", 1269). -spec task_error_decoder() -> gleam@dynamic@decode:decoder(task_error()). task_error_decoder() -> gleam@dynamic@decode:field( <<"message"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Message) -> gleam@dynamic@decode:field( <<"code"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Code) -> gleam@dynamic@decode:field( <<"type"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Error_type) -> gleam@dynamic@decode:field( <<"link"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Link) -> gleam@dynamic@decode:success( {task_error, Message, Code, Error_type, Link} ) end ) end ) end ) end ). -file("src/dewey.gleam", 1047). -spec task_decoder() -> gleam@dynamic@decode:decoder(task()). task_decoder() -> gleam@dynamic@decode:field( <<"uid"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Uid) -> gleam@dynamic@decode:field( <<"batchUid"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Batch_uid) -> gleam@dynamic@decode:field( <<"indexUid"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Index_uid) -> gleam@dynamic@decode:field( <<"status"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Status_string) -> gleam@dynamic@decode:field( <<"type"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Task_type_string) -> gleam@dynamic@decode:field( <<"canceledBy"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun(Canceled_by) -> gleam@dynamic@decode:field( <<"details"/utf8>>, task_details_decoder(), fun(Details) -> gleam@dynamic@decode:field( <<"error"/utf8>>, gleam@dynamic@decode:optional( task_error_decoder( ) ), fun(Error) -> gleam@dynamic@decode:field( <<"enqueuedAt"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun( Enqueued_at_string ) -> gleam@dynamic@decode:field( <<"startedAt"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun( Started_at_string ) -> gleam@dynamic@decode:field( <<"finishedAt"/utf8>>, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun( Finished_at_string ) -> Status = string_to_task_status( Status_string ), Task_type = string_to_task_type( Task_type_string ), Default_time = gleam@time@timestamp:from_unix_seconds( 0 ), Enqueued_at = begin _pipe = gleam@time@timestamp:parse_rfc3339( Enqueued_at_string ), gleam@result:unwrap( _pipe, Default_time ) end, Started_at = gleam@option:map( Started_at_string, fun( Str ) -> _pipe@1 = gleam@time@timestamp:parse_rfc3339( Str ), gleam@result:unwrap( _pipe@1, Default_time ) end ), Finished_at = gleam@option:map( Finished_at_string, fun( Str@1 ) -> _pipe@2 = gleam@time@timestamp:parse_rfc3339( Str@1 ), gleam@result:unwrap( _pipe@2, Default_time ) end ), gleam@dynamic@decode:success( {task, Uid, Index_uid, Batch_uid, Status, Task_type, Canceled_by, Details, Error, Enqueued_at, Started_at, Finished_at} ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ). -file("src/dewey.gleam", 1279). -spec base_request(binary(), binary()) -> gleam@http@request:request(binary()). base_request(Url, Api_key) -> Base_req@1 = case gleam@http@request:to(Url) of {ok, Base_req} -> Base_req; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"dewey"/utf8>>, function => <<"base_request"/utf8>>, line => 1280, value => _assert_fail, start => 38006, 'end' => 38047, pattern_start => 38017, pattern_end => 38029}) end, gleam@http@request:set_header( Base_req@1, <<"Authorization"/utf8>>, <<"Bearer "/utf8, Api_key/binary>> ). -file("src/dewey.gleam", 1287). -spec verify_response(gleam@http@response:response(binary())) -> {ok, binary()} | {error, dewey_error()}. verify_response(Resp) -> case gleam@list:contains([200, 201, 202, 204, 205], erlang:element(2, Resp)) of true -> {ok, erlang:element(4, Resp)}; false -> Decoder = begin gleam@dynamic@decode:field( <<"message"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Message) -> gleam@dynamic@decode:field( <<"code"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Code) -> gleam@dynamic@decode:field( <<"type"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Error_type) -> gleam@dynamic@decode:field( <<"link"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Link) -> gleam@dynamic@decode:success( {a_p_i_error, Message, Code, Error_type, Link} ) end ) end ) end ) end ) end, case gleam@json:parse(erlang:element(4, Resp), Decoder) of {ok, Api_error} -> {error, Api_error}; {error, _} -> {error, unexpected_a_p_i_error} end end. -file("src/dewey.gleam", 55). -spec parse_summarized_task_response(gleam@http@response:response(binary())) -> {ok, summarized_task()} | {error, dewey_error()}. parse_summarized_task_response(Resp) -> gleam@result:'try'( verify_response(Resp), fun(Resp_body) -> _pipe = gleam@json:parse(Resp_body, summarized_task_decoder()), gleam@result:map_error( _pipe, fun(Field@0) -> {j_s_o_n_decode_error, Field@0} end ) end ). -file("src/dewey.gleam", 293). -spec get_tasks(client(), list(tasks_param())) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, list(task())} | {error, dewey_error()})}. get_tasks(Client, Params) -> Url = <<(erlang:element(2, Client))/binary, "/tasks"/utf8>>, Req = begin _pipe = base_request(Url, erlang:element(3, Client)), _pipe@1 = gleam@http@request:set_method(_pipe, get), gleam@http@request:set_query( _pipe@1, gleam@list:map(Params, fun tasks_param_to_tuple/1) ) end, {Req, fun(Resp) -> gleam@result:'try'( verify_response(Resp), fun(Resp_body) -> Decoder = begin gleam@dynamic@decode:field( <<"results"/utf8>>, gleam@dynamic@decode:list(task_decoder()), fun(Results) -> gleam@dynamic@decode:success(Results) end ) end, _pipe@2 = gleam@json:parse(Resp_body, Decoder), gleam@result:map_error( _pipe@2, fun(Field@0) -> {j_s_o_n_decode_error, Field@0} end ) end ) end}. -file("src/dewey.gleam", 318). -spec get_one_task(client(), integer()) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, task()} | {error, dewey_error()})}. get_one_task(Client, Task_uid) -> Url = <<<<(erlang:element(2, Client))/binary, "/tasks/"/utf8>>/binary, (erlang:integer_to_binary(Task_uid))/binary>>, Req = begin _pipe = base_request(Url, erlang:element(3, Client)), gleam@http@request:set_method(_pipe, get) end, {Req, fun(Resp) -> gleam@result:'try'( verify_response(Resp), fun(Resp_body) -> _pipe@1 = gleam@json:parse(Resp_body, task_decoder()), gleam@result:map_error( _pipe@1, fun(Field@0) -> {j_s_o_n_decode_error, Field@0} end ) end ) end}. -file("src/dewey.gleam", 333). -spec cancel_tasks(client(), list(tasks_param())) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, summarized_task()} | {error, dewey_error()})}. cancel_tasks(Client, Params) -> Url = <<(erlang:element(2, Client))/binary, "/tasks/cancel"/utf8>>, Req = begin _pipe = base_request(Url, erlang:element(3, Client)), _pipe@1 = gleam@http@request:set_method(_pipe, post), gleam@http@request:set_query( _pipe@1, gleam@list:map(Params, fun tasks_param_to_tuple/1) ) end, {Req, fun parse_summarized_task_response/1}. -file("src/dewey.gleam", 347). -spec delete_tasks(client(), list(tasks_param())) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, summarized_task()} | {error, dewey_error()})}. delete_tasks(Client, Params) -> Url = <<(erlang:element(2, Client))/binary, "/tasks"/utf8>>, Req = begin _pipe = base_request(Url, erlang:element(3, Client)), _pipe@1 = gleam@http@request:set_method(_pipe, delete), gleam@http@request:set_query( _pipe@1, gleam@list:map(Params, fun tasks_param_to_tuple/1) ) end, {Req, fun parse_summarized_task_response/1}. -file("src/dewey.gleam", 361). -spec delete_all_tasks(client()) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, summarized_task()} | {error, dewey_error()})}. delete_all_tasks(Client) -> Url = <<(erlang:element(2, Client))/binary, "/tasks"/utf8>>, Req = begin _pipe = base_request(Url, erlang:element(3, Client)), _pipe@1 = gleam@http@request:set_method(_pipe, delete), gleam@http@request:set_query( _pipe@1, [{<<"statuses"/utf8>>, <<"failed,canceled,succeeded"/utf8>>}] ) end, {Req, fun parse_summarized_task_response/1}. -file("src/dewey.gleam", 388). ?DOC( " Returns an Operation record for the Get All Indexes endpoint\n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/indexes#list-all-indexes\n" ). -spec get_all_indexes(client()) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, list(index())} | {error, dewey_error()})}. get_all_indexes(Client) -> Url = <<(erlang:element(2, Client))/binary, "/indexes"/utf8>>, Req = begin _pipe = base_request(Url, erlang:element(3, Client)), gleam@http@request:set_method(_pipe, get) end, {Req, fun(Resp) -> gleam@result:'try'( verify_response(Resp), fun(Resp_body) -> Decoder = begin gleam@dynamic@decode:field( <<"results"/utf8>>, gleam@dynamic@decode:list(index_decoder()), fun(Indexes) -> gleam@dynamic@decode:success(Indexes) end ) end, _pipe@1 = gleam@json:parse(Resp_body, Decoder), gleam@result:map_error( _pipe@1, fun(Field@0) -> {j_s_o_n_decode_error, Field@0} end ) end ) end}. -file("src/dewey.gleam", 411). ?DOC( " Returns an Operation record for the Get One Index endpoint\n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/indexes#get-one-index\n" ). -spec get_one_index(client(), binary()) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, index()} | {error, dewey_error()})}. get_one_index(Client, Index_uid) -> Url = <<<<(erlang:element(2, Client))/binary, "/indexes/"/utf8>>/binary, Index_uid/binary>>, Req = begin _pipe = base_request(Url, erlang:element(3, Client)), gleam@http@request:set_method(_pipe, get) end, {Req, fun(Resp) -> gleam@result:'try'( verify_response(Resp), fun(Resp_body) -> _pipe@1 = gleam@json:parse(Resp_body, index_decoder()), gleam@result:map_error( _pipe@1, fun(Field@0) -> {j_s_o_n_decode_error, Field@0} end ) end ) end}. -file("src/dewey.gleam", 429). ?DOC( " Returns an Operation record for the Create Index endpoint\n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/indexes#create-an-index\n" ). -spec create_index(client(), binary(), gleam@option:option(binary())) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, summarized_task()} | {error, dewey_error()})}. create_index(Client, Index_uid, Primary_key) -> Url = <<(erlang:element(2, Client))/binary, "/indexes"/utf8>>, Req_body = begin _pipe = gleam@json:object( [{<<"uid"/utf8>>, gleam@json:string(Index_uid)}, {<<"primaryKey"/utf8>>, gleam@json:nullable(Primary_key, fun gleam@json:string/1)}] ), gleam@json:to_string(_pipe) end, Req = begin _pipe@1 = base_request(Url, erlang:element(3, Client)), _pipe@2 = gleam@http@request:set_method(_pipe@1, post), _pipe@3 = gleam@http@request:set_header( _pipe@2, <<"Content-Type"/utf8>>, <<"application/json"/utf8>> ), gleam@http@request:set_body(_pipe@3, Req_body) end, {Req, fun parse_summarized_task_response/1}. -file("src/dewey.gleam", 455). ?DOC( " Returns an Operation record for the Update Index endpoint\n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/indexes#update-an-index\n" ). -spec update_index(client(), binary(), gleam@option:option(binary())) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, summarized_task()} | {error, dewey_error()})}. update_index(Client, Index_uid, New_primary_key) -> Url = <<<<(erlang:element(2, Client))/binary, "/indexes/"/utf8>>/binary, Index_uid/binary>>, Req_body = begin _pipe = gleam@json:object( [{<<"primaryKey"/utf8>>, gleam@json:nullable( New_primary_key, fun gleam@json:string/1 )}] ), gleam@json:to_string(_pipe) end, Req = begin _pipe@1 = base_request(Url, erlang:element(3, Client)), _pipe@2 = gleam@http@request:set_method(_pipe@1, patch), _pipe@3 = gleam@http@request:set_header( _pipe@2, <<"Content-Type"/utf8>>, <<"application/json"/utf8>> ), gleam@http@request:set_body(_pipe@3, Req_body) end, {Req, fun parse_summarized_task_response/1}. -file("src/dewey.gleam", 478). ?DOC( " Returns an Operation record for the Delete Index endpoint.\n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/indexes#delete-an-index\n" ). -spec delete_index(client(), binary()) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, summarized_task()} | {error, dewey_error()})}. delete_index(Client, Index_uid) -> Url = <<<<(erlang:element(2, Client))/binary, "/indexes/"/utf8>>/binary, Index_uid/binary>>, Req = begin _pipe = base_request(Url, erlang:element(3, Client)), gleam@http@request:set_method(_pipe, delete) end, {Req, fun parse_summarized_task_response/1}. -file("src/dewey.gleam", 498). ?DOC( " Returns an Operation record for the Swap Indexes endpoint\n" " \n" " This function does not include the rename parameter, and therefore does not rename\n" " indexes when the second index does not exist. To rename indexes, use the rename_indexes\n" " function instead. \n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/indexes#swap-indexes\n" ). -spec swap_indexes(client(), list({binary(), binary()})) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, summarized_task()} | {error, dewey_error()})}. swap_indexes(Client, Index_uids_to_swap) -> Url = <<(erlang:element(2, Client))/binary, "/swap-indexes"/utf8>>, Indexes_list = gleam@list:map( Index_uids_to_swap, fun(Tuple) -> [erlang:element(1, Tuple), erlang:element(2, Tuple)] end ), Req_body = begin _pipe = gleam@json:array( Indexes_list, fun(Indexes) -> gleam@json:object( [{<<"indexes"/utf8>>, gleam@json:array(Indexes, fun gleam@json:string/1)}] ) end ), gleam@json:to_string(_pipe) end, Req = begin _pipe@1 = base_request(Url, erlang:element(3, Client)), _pipe@2 = gleam@http@request:set_method(_pipe@1, post), _pipe@3 = gleam@http@request:set_header( _pipe@2, <<"Content-Type"/utf8>>, <<"application/json"/utf8>> ), gleam@http@request:set_body(_pipe@3, Req_body) end, {Req, fun parse_summarized_task_response/1}. -file("src/dewey.gleam", 529). ?DOC( " Returns an Operation record for the Swap Indexes endpoint, utilizing the\n" " rename parameter.\n" " \n" " This function includes the rename parameter within the request body, meaning that\n" " the first index_uid will be renamed to the second index_uid listed (assuming the second uid does not exist).\n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/indexes#swap-indexes\n" ). -spec rename_indexes(client(), list({binary(), binary()})) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, summarized_task()} | {error, dewey_error()})}. rename_indexes(Client, Index_uids_to_swap) -> Url = <<(erlang:element(2, Client))/binary, "/swap-indexes"/utf8>>, Indexes_list = gleam@list:map( Index_uids_to_swap, fun(Tuple) -> [erlang:element(1, Tuple), erlang:element(2, Tuple)] end ), Req_body = begin _pipe = gleam@json:array( Indexes_list, fun(Indexes) -> gleam@json:object( [{<<"indexes"/utf8>>, gleam@json:array(Indexes, fun gleam@json:string/1)}, {<<"rename"/utf8>>, gleam@json:bool(true)}] ) end ), gleam@json:to_string(_pipe) end, Req = begin _pipe@1 = base_request(Url, erlang:element(3, Client)), _pipe@2 = gleam@http@request:set_method(_pipe@1, post), _pipe@3 = gleam@http@request:set_header( _pipe@2, <<"Content-Type"/utf8>>, <<"application/json"/utf8>> ), gleam@http@request:set_body(_pipe@3, Req_body) end, {Req, fun parse_summarized_task_response/1}. -file("src/dewey.gleam", 602). ?DOC( " Returns an Operation record for the Get Documents endpoint.\n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#get-documents-with-post\n" ). -spec get_documents( client(), binary(), get_documents_options(), gleam@dynamic@decode:decoder(FKC) ) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, documents_response(FKC)} | {error, dewey_error()})}. get_documents(Client, Index_uid, Options, Documents_decoder) -> Url = <<<<<<(erlang:element(2, Client))/binary, "/indexes/"/utf8>>/binary, Index_uid/binary>>/binary, "/documents/fetch"/utf8>>, Json_string_array = fun(_capture) -> gleam@json:array(_capture, fun gleam@json:string/1) end, Req_body = begin _pipe = gleam@json:object( [{<<"offset"/utf8>>, gleam@json:int(erlang:element(2, Options))}, {<<"limit"/utf8>>, gleam@json:int(erlang:element(3, Options))}, {<<"fields"/utf8>>, gleam@json:nullable( erlang:element(4, Options), Json_string_array )}, {<<"filter"/utf8>>, gleam@json:nullable( erlang:element(5, Options), fun gleam@json:string/1 )}, {<<"retrieveVectors"/utf8>>, gleam@json:bool(erlang:element(6, Options))}, {<<"sort"/utf8>>, gleam@json:nullable( erlang:element(7, Options), fun gleam@json:string/1 )}, {<<"ids"/utf8>>, gleam@json:nullable( erlang:element(8, Options), Json_string_array )}] ), gleam@json:to_string(_pipe) end, Req = begin _pipe@1 = base_request(Url, erlang:element(3, Client)), _pipe@2 = gleam@http@request:set_method(_pipe@1, post), _pipe@3 = gleam@http@request:set_header( _pipe@2, <<"Content-Type"/utf8>>, <<"application/json"/utf8>> ), gleam@http@request:set_body(_pipe@3, Req_body) end, {Req, fun(Resp) -> gleam@result:'try'( verify_response(Resp), fun(Resp_body) -> Decoder = begin gleam@dynamic@decode:field( <<"results"/utf8>>, gleam@dynamic@decode:list(Documents_decoder), fun(Results) -> gleam@dynamic@decode:field( <<"offset"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Offset) -> gleam@dynamic@decode:field( <<"limit"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Limit) -> gleam@dynamic@decode:field( <<"total"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Total) -> gleam@dynamic@decode:success( {documents_response, Results, Offset, Limit, Total} ) end ) end ) end ) end ) end, _pipe@4 = gleam@json:parse(Resp_body, Decoder), gleam@result:map_error( _pipe@4, fun(Field@0) -> {j_s_o_n_decode_error, Field@0} end ) end ) end}. -file("src/dewey.gleam", 653). ?DOC( " Returns an Operation record for the Get One Document endpoint.\n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#get-one-document\n" ). -spec get_one_document( client(), binary(), binary(), gleam@dynamic@decode:decoder(FKG) ) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, FKG} | {error, dewey_error()})}. get_one_document(Client, Index_uid, Document_id, Document_decoder) -> Url = <<<<<<<<(erlang:element(2, Client))/binary, "/indexes/"/utf8>>/binary, Index_uid/binary>>/binary, "/documents/"/utf8>>/binary, Document_id/binary>>, Req = begin _pipe = base_request(Url, erlang:element(3, Client)), gleam@http@request:set_method(_pipe, get) end, {Req, fun(Resp) -> gleam@result:'try'( verify_response(Resp), fun(Resp_body) -> _pipe@1 = gleam@json:parse(Resp_body, Document_decoder), gleam@result:map_error( _pipe@1, fun(Field@0) -> {j_s_o_n_decode_error, Field@0} end ) end ) end}. -file("src/dewey.gleam", 677). ?DOC( " Returns an Operation record for the Add or Replace Documents endpoint.\n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#add-or-replace-documents\n" ). -spec add_or_replace_documents( client(), binary(), list(FKJ), fun((FKJ) -> gleam@json:json()) ) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, summarized_task()} | {error, dewey_error()})}. add_or_replace_documents(Client, Index_uid, Documents, Document_encoder) -> Url = <<<<<<(erlang:element(2, Client))/binary, "/indexes/"/utf8>>/binary, Index_uid/binary>>/binary, "/documents"/utf8>>, Req_body = begin _pipe = gleam@json:array(Documents, Document_encoder), gleam@json:to_string(_pipe) end, Req = begin _pipe@1 = base_request(Url, erlang:element(3, Client)), _pipe@2 = gleam@http@request:set_method(_pipe@1, post), _pipe@3 = gleam@http@request:set_header( _pipe@2, <<"Content-Type"/utf8>>, <<"application/json"/utf8>> ), gleam@http@request:set_body(_pipe@3, Req_body) end, {Req, fun parse_summarized_task_response/1}. -file("src/dewey.gleam", 701). ?DOC( " Returns an Operation record for the Add or Update Documents endpoint.\n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#add-or-update-documents\n" ). -spec add_or_update_documents( client(), binary(), list(FKM), fun((FKM) -> gleam@json:json()) ) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, summarized_task()} | {error, dewey_error()})}. add_or_update_documents(Client, Index_uid, Documents, Document_encoder) -> Url = <<<<<<(erlang:element(2, Client))/binary, "/indexes/"/utf8>>/binary, Index_uid/binary>>/binary, "/documents"/utf8>>, Req_body = begin _pipe = gleam@json:array(Documents, Document_encoder), gleam@json:to_string(_pipe) end, Req = begin _pipe@1 = base_request(Url, erlang:element(3, Client)), _pipe@2 = gleam@http@request:set_method(_pipe@1, put), _pipe@3 = gleam@http@request:set_header( _pipe@2, <<"Content-Type"/utf8>>, <<"application/json"/utf8>> ), gleam@http@request:set_body(_pipe@3, Req_body) end, {Req, fun parse_summarized_task_response/1}. -file("src/dewey.gleam", 725). ?DOC( " Returns an Operation record for the Delete All Documents endpoint.\n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#delete-all-documents\n" ). -spec delete_all_documents(client(), binary()) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, summarized_task()} | {error, dewey_error()})}. delete_all_documents(Client, Index_uid) -> Url = <<<<<<(erlang:element(2, Client))/binary, "/indexes/"/utf8>>/binary, Index_uid/binary>>/binary, "/documents"/utf8>>, Req = begin _pipe = base_request(Url, erlang:element(3, Client)), gleam@http@request:set_method(_pipe, delete) end, {Req, fun parse_summarized_task_response/1}. -file("src/dewey.gleam", 741). ?DOC( " Returns an Operation record for the Delete One Document endpoint.\n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#delete-one-document\n" ). -spec delete_one_document(client(), binary(), binary()) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, summarized_task()} | {error, dewey_error()})}. delete_one_document(Client, Index_uid, Document_id) -> Url = <<<<<<<<(erlang:element(2, Client))/binary, "/indexes/"/utf8>>/binary, Index_uid/binary>>/binary, "/documents/"/utf8>>/binary, Document_id/binary>>, Req = begin _pipe = base_request(Url, erlang:element(3, Client)), gleam@http@request:set_method(_pipe, delete) end, {Req, fun parse_summarized_task_response/1}. -file("src/dewey.gleam", 759). ?DOC( " Returns an Operation record for the Delete Documents by Filter endpoint.\n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#delete-documents-by-filter\n" ). -spec delete_documents_by_filter(client(), binary(), binary()) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, summarized_task()} | {error, dewey_error()})}. delete_documents_by_filter(Client, Index_uid, Filter) -> Url = <<<<<<(erlang:element(2, Client))/binary, "/indexes/"/utf8>>/binary, Index_uid/binary>>/binary, "/documents/delete"/utf8>>, Req_body = begin _pipe = gleam@json:object( [{<<"filter"/utf8>>, gleam@json:string(Filter)}] ), gleam@json:to_string(_pipe) end, Req = begin _pipe@1 = base_request(Url, erlang:element(3, Client)), _pipe@2 = gleam@http@request:set_method(_pipe@1, post), _pipe@3 = gleam@http@request:set_header( _pipe@2, <<"Content-Type"/utf8>>, <<"application/json"/utf8>> ), gleam@http@request:set_body(_pipe@3, Req_body) end, {Req, fun parse_summarized_task_response/1}. -file("src/dewey.gleam", 782). ?DOC( " Returns an Operation record for the Delete Documents by Batch endpoint.\n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#delete-documents-by-batch\n" ). -spec delete_documents_by_batch(client(), binary(), list(binary())) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, summarized_task()} | {error, dewey_error()})}. delete_documents_by_batch(Client, Index_uid, Batch) -> Url = <<<<<<(erlang:element(2, Client))/binary, "/indexes/"/utf8>>/binary, Index_uid/binary>>/binary, "/documents/delete-batch"/utf8>>, Req_body = begin _pipe = gleam@json:array(Batch, fun gleam@json:string/1), gleam@json:to_string(_pipe) end, Req = begin _pipe@1 = base_request(Url, erlang:element(3, Client)), _pipe@2 = gleam@http@request:set_method(_pipe@1, post), _pipe@3 = gleam@http@request:set_header( _pipe@2, <<"Content-Type"/utf8>>, <<"application/json"/utf8>> ), gleam@http@request:set_body(_pipe@3, Req_body) end, {Req, fun parse_summarized_task_response/1}. -file("src/dewey.gleam", 927). ?DOC( " Returns an Operation record for the Search endpoint\n" " \n" " This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/search#search-in-an-index-with-post\n" ). -spec search( client(), binary(), binary(), gleam@dynamic@decode:decoder(FKU), list(search_param()) ) -> {gleam@http@request:request(binary()), fun((gleam@http@response:response(binary())) -> {ok, search_response(FKU)} | {error, dewey_error()})}. search(Client, Index_uid, Query, Document_decoder, Params) -> Url = <<<<<<(erlang:element(2, Client))/binary, "/indexes/"/utf8>>/binary, Index_uid/binary>>/binary, "/search"/utf8>>, Param_fields = [{<<"q"/utf8>>, gleam@json:string(Query)} | gleam@list:map(Params, fun search_param_to_json_field/1)], Req_body = begin _pipe = gleam@json:object(Param_fields), gleam@json:to_string(_pipe) end, Req = begin _pipe@1 = base_request(Url, erlang:element(3, Client)), _pipe@2 = gleam@http@request:set_method(_pipe@1, post), _pipe@3 = gleam@http@request:set_header( _pipe@2, <<"Content-Type"/utf8>>, <<"application/json"/utf8>> ), gleam@http@request:set_body(_pipe@3, Req_body) end, {Req, fun(Resp) -> gleam@result:'try'( verify_response(Resp), fun(Resp_body) -> Decoder = begin gleam@dynamic@decode:field( <<"hits"/utf8>>, gleam@dynamic@decode:list(Document_decoder), fun(Hits) -> gleam@dynamic@decode:field( <<"offset"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Offset) -> gleam@dynamic@decode:field( <<"limit"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Limit) -> gleam@dynamic@decode:optional_field( <<"estimatedTotalHits"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun(Estimated_total_hits) -> gleam@dynamic@decode:optional_field( <<"totalHits"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun(Total_hits) -> gleam@dynamic@decode:optional_field( <<"totalPages"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun( Total_pages ) -> gleam@dynamic@decode:optional_field( <<"hitsPerPage"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun( Hits_per_page ) -> gleam@dynamic@decode:field( <<"processingTimeMs"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun( Processing_time_ms ) -> gleam@dynamic@decode:field( <<"query"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun( Query@1 ) -> gleam@dynamic@decode:field( <<"requestUid"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun( Request_uid ) -> gleam@dynamic@decode:success( {search_response, Hits, Offset, Limit, Estimated_total_hits, Total_hits, Total_pages, Hits_per_page, Processing_time_ms, Query@1, Request_uid} ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end, _pipe@4 = gleam@json:parse(Resp_body, Decoder), gleam@result:map_error( _pipe@4, fun(Field@0) -> {j_s_o_n_decode_error, Field@0} end ) end ) end}.