2024-11-04 19:03:26 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2024, stelar7 <dudedbz@gmail.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2025-03-24 19:34:05 +01:00
|
|
|
#include <AK/Variant.h>
|
2024-11-04 19:03:26 +01:00
|
|
|
#include <LibJS/Runtime/Realm.h>
|
2025-07-09 11:52:44 +02:00
|
|
|
#include <LibWeb/Bindings/IDBCursorPrototype.h>
|
2025-03-24 21:23:58 +01:00
|
|
|
#include <LibWeb/HTML/DOMStringList.h>
|
2025-05-13 22:18:14 +02:00
|
|
|
#include <LibWeb/IndexedDB/IDBKeyRange.h>
|
2024-11-04 19:03:26 +01:00
|
|
|
#include <LibWeb/IndexedDB/IDBRequest.h>
|
2024-11-11 10:49:36 +01:00
|
|
|
#include <LibWeb/IndexedDB/Internal/Key.h>
|
2024-11-04 19:03:26 +01:00
|
|
|
#include <LibWeb/StorageAPI/StorageKey.h>
|
2025-05-08 23:36:18 +02:00
|
|
|
#include <LibWeb/WebIDL/Types.h>
|
2024-11-04 19:03:26 +01:00
|
|
|
|
|
|
|
namespace Web::IndexedDB {
|
|
|
|
|
2025-07-09 11:52:44 +02:00
|
|
|
enum class RecordKind {
|
|
|
|
Key,
|
|
|
|
Value,
|
|
|
|
Record
|
|
|
|
};
|
|
|
|
|
2025-03-24 19:34:05 +01:00
|
|
|
using KeyPath = Variant<String, Vector<String>>;
|
2025-05-13 22:54:08 +02:00
|
|
|
using RecordSource = Variant<GC::Ref<ObjectStore>, GC::Ref<Index>>;
|
2025-03-24 19:34:05 +01:00
|
|
|
|
2025-09-09 20:41:59 +01:00
|
|
|
void open_a_database_connection(JS::Realm&, StorageAPI::StorageKey, String, Optional<u64>, GC::Ref<IDBRequest>, GC::Ref<GC::Function<void(WebIDL::ExceptionOr<GC::Ref<IDBDatabase>>)>>);
|
2024-11-15 04:01:23 +13:00
|
|
|
bool fire_a_version_change_event(JS::Realm&, FlyString const&, GC::Ref<DOM::EventTarget>, u64, Optional<u64>);
|
2025-04-25 17:59:06 +02:00
|
|
|
WebIDL::ExceptionOr<GC::Ref<Key>> convert_a_value_to_a_key(JS::Realm&, JS::Value, Vector<JS::Value> = {});
|
2025-09-13 11:01:25 +01:00
|
|
|
void close_a_database_connection(GC::Ref<IDBDatabase>, GC::Ptr<GC::Function<void()>> on_complete = nullptr, bool forced = false);
|
|
|
|
void upgrade_a_database(JS::Realm&, GC::Ref<IDBDatabase>, u64, GC::Ref<IDBRequest>, GC::Ref<GC::Function<void()>>);
|
2025-09-09 20:41:59 +01:00
|
|
|
void delete_a_database(JS::Realm&, StorageAPI::StorageKey, String, GC::Ref<IDBRequest>, GC::Ref<GC::Function<void(WebIDL::ExceptionOr<u64>)>>);
|
2025-04-02 10:28:34 +02:00
|
|
|
void abort_a_transaction(GC::Ref<IDBTransaction>, GC::Ptr<WebIDL::DOMException>);
|
2025-01-08 23:25:46 +01:00
|
|
|
JS::Value convert_a_key_to_a_value(JS::Realm&, GC::Ref<Key>);
|
2025-03-24 19:34:05 +01:00
|
|
|
bool is_valid_key_path(KeyPath const&);
|
2025-03-24 21:23:58 +01:00
|
|
|
GC::Ref<HTML::DOMStringList> create_a_sorted_name_list(JS::Realm&, Vector<String>);
|
2025-04-09 23:11:12 +02:00
|
|
|
void commit_a_transaction(JS::Realm&, GC::Ref<IDBTransaction>);
|
2025-04-11 10:38:55 +02:00
|
|
|
WebIDL::ExceptionOr<JS::Value> clone_in_realm(JS::Realm&, JS::Value, GC::Ref<IDBTransaction>);
|
2025-04-25 17:59:06 +02:00
|
|
|
WebIDL::ExceptionOr<GC::Ref<Key>> convert_a_value_to_a_multi_entry_key(JS::Realm&, JS::Value);
|
2025-04-11 10:51:03 +02:00
|
|
|
WebIDL::ExceptionOr<ErrorOr<JS::Value>> evaluate_key_path_on_a_value(JS::Realm&, JS::Value, KeyPath const&);
|
2025-04-11 10:47:08 +02:00
|
|
|
WebIDL::ExceptionOr<ErrorOr<GC::Ref<Key>>> extract_a_key_from_a_value_using_a_key_path(JS::Realm&, JS::Value, KeyPath const&, bool = false);
|
2025-04-11 10:54:23 +02:00
|
|
|
bool check_that_a_key_could_be_injected_into_a_value(JS::Realm&, JS::Value, KeyPath const&);
|
2025-04-11 11:09:16 +02:00
|
|
|
void fire_an_error_event(JS::Realm&, GC::Ref<IDBRequest>);
|
2025-04-11 11:10:05 +02:00
|
|
|
void fire_a_success_event(JS::Realm&, GC::Ref<IDBRequest>);
|
2025-04-11 11:22:29 +02:00
|
|
|
GC::Ref<IDBRequest> asynchronously_execute_a_request(JS::Realm&, IDBRequestSource, GC::Ref<GC::Function<WebIDL::ExceptionOr<JS::Value>()>>, GC::Ptr<IDBRequest> = nullptr);
|
2025-04-11 11:25:56 +02:00
|
|
|
ErrorOr<u64> generate_a_key(GC::Ref<ObjectStore>);
|
2025-04-11 11:27:22 +02:00
|
|
|
void possibly_update_the_key_generator(GC::Ref<ObjectStore>, GC::Ref<Key>);
|
2025-04-11 11:28:11 +02:00
|
|
|
void inject_a_key_into_a_value_using_a_key_path(JS::Realm&, JS::Value, GC::Ref<Key>, KeyPath const&);
|
2025-05-08 09:59:13 +02:00
|
|
|
JS::Value delete_records_from_an_object_store(GC::Ref<ObjectStore>, GC::Ref<IDBKeyRange>);
|
2025-04-11 11:38:29 +02:00
|
|
|
WebIDL::ExceptionOr<GC::Ptr<Key>> store_a_record_into_an_object_store(JS::Realm&, GC::Ref<ObjectStore>, JS::Value, GC::Ptr<Key>, bool);
|
2025-04-28 15:49:38 +02:00
|
|
|
WebIDL::ExceptionOr<GC::Ref<IDBKeyRange>> convert_a_value_to_a_key_range(JS::Realm&, Optional<JS::Value>, bool = false);
|
2025-05-13 22:54:08 +02:00
|
|
|
JS::Value count_the_records_in_a_range(RecordSource, GC::Ref<IDBKeyRange>);
|
2025-04-28 15:55:46 +02:00
|
|
|
WebIDL::ExceptionOr<JS::Value> retrieve_a_value_from_an_object_store(JS::Realm&, GC::Ref<ObjectStore>, GC::Ref<IDBKeyRange>);
|
2025-04-29 17:37:16 +02:00
|
|
|
GC::Ptr<IDBCursor> iterate_a_cursor(JS::Realm&, GC::Ref<IDBCursor>, GC::Ptr<Key> = nullptr, GC::Ptr<Key> = nullptr, u64 = 1);
|
2025-05-08 10:04:43 +02:00
|
|
|
JS::Value clear_an_object_store(GC::Ref<ObjectStore>);
|
2025-05-08 15:27:11 +02:00
|
|
|
JS::Value retrieve_a_key_from_an_object_store(JS::Realm&, GC::Ref<ObjectStore>, GC::Ref<IDBKeyRange>);
|
2025-05-08 23:36:18 +02:00
|
|
|
GC::Ref<JS::Array> retrieve_multiple_values_from_an_object_store(JS::Realm&, GC::Ref<ObjectStore>, GC::Ref<IDBKeyRange>, Optional<WebIDL::UnsignedLong>);
|
2025-05-08 23:47:38 +02:00
|
|
|
GC::Ref<JS::Array> retrieve_multiple_keys_from_an_object_store(JS::Realm&, GC::Ref<ObjectStore>, GC::Ref<IDBKeyRange>, Optional<WebIDL::UnsignedLong>);
|
2025-05-13 22:18:14 +02:00
|
|
|
JS::Value retrieve_a_referenced_value_from_an_index(JS::Realm&, GC::Ref<Index>, GC::Ref<IDBKeyRange>);
|
2025-05-13 22:21:57 +02:00
|
|
|
JS::Value retrieve_a_value_from_an_index(JS::Realm&, GC::Ref<Index>, GC::Ref<IDBKeyRange>);
|
2025-05-13 22:41:18 +02:00
|
|
|
GC::Ref<JS::Array> retrieve_multiple_referenced_values_from_an_index(JS::Realm&, GC::Ref<Index>, GC::Ref<IDBKeyRange>, Optional<WebIDL::UnsignedLong>);
|
2025-05-13 22:46:23 +02:00
|
|
|
GC::Ref<JS::Array> retrieve_multiple_values_from_an_index(JS::Realm&, GC::Ref<Index>, GC::Ref<IDBKeyRange>, Optional<WebIDL::UnsignedLong>);
|
2025-05-16 08:26:03 +02:00
|
|
|
void queue_a_database_task(GC::Ref<GC::Function<void()>>);
|
2025-06-16 16:41:29 +02:00
|
|
|
bool cleanup_indexed_database_transactions(GC::Ref<HTML::EventLoop>);
|
2025-07-09 11:19:14 +02:00
|
|
|
bool is_a_potentially_valid_key_range(JS::Realm&, JS::Value);
|
2025-07-09 11:52:44 +02:00
|
|
|
GC::Ref<JS::Array> retrieve_multiple_items_from_an_object_store(JS::Realm&, GC::Ref<ObjectStore>, GC::Ref<IDBKeyRange>, RecordKind, Bindings::IDBCursorDirection, Optional<WebIDL::UnsignedLong>);
|
2025-07-10 09:15:01 +02:00
|
|
|
GC::Ref<JS::Array> retrieve_multiple_items_from_an_index(JS::Realm&, GC::Ref<Index>, GC::Ref<IDBKeyRange>, RecordKind, Bindings::IDBCursorDirection, Optional<WebIDL::UnsignedLong>);
|
2025-07-25 19:51:45 +02:00
|
|
|
WebIDL::ExceptionOr<GC::Ref<IDBRequest>> create_a_request_to_retrieve_multiple_items(JS::Realm&, IDBRequestSource, RecordKind, JS::Value, Optional<WebIDL::UnsignedLong>);
|
2024-11-04 19:03:26 +01:00
|
|
|
|
|
|
|
}
|