Skip to content

Commit 4ecb28f

Browse files
knethMichael Wilkerson-Barker
authored andcommitted
[bindgen] expose both SyncUser and app::User (#7634)
1 parent 816920b commit 4ecb28f

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

bindgen/spec.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ headers:
1919
- "realm/object-store/sync/app.hpp"
2020
- "realm/object-store/sync/sync_manager.hpp"
2121
- "realm/object-store/sync/sync_session.hpp"
22-
- "realm/object-store/sync/app_user.hpp"
2322
- "realm/object-store/sync/sync_user.hpp"
23+
- "realm/object-store/sync/app_user.hpp"
2424
- "realm/object-store/sync/mongo_collection.hpp"
2525
- "realm/util/bson/bson.hpp"
2626

@@ -739,6 +739,7 @@ classes:
739739
# TODO: Consider making preverify_ok a bool.
740740
make_ssl_verify_callback: '(callback: (server_address: const std::string&, server_port: int, pem_data: std::string_view, preverify_ok: int, depth: int) off_thread -> bool) -> SSLVerifyCallback'
741741
needs_file_format_upgrade: '(config: const RealmConfig&) -> bool'
742+
sync_user_as_app_user: '(sync_user: Nullable<std::shared_ptr<SyncUser>>) -> Nullable<std::shared_ptr<User>>'
742743

743744
LogCategoryRef:
744745
cppName: util::LogCategoryRef
@@ -1205,7 +1206,13 @@ classes:
12051206
cppName: app::User::Token
12061207

12071208
SyncUser:
1209+
cppName: SyncUser
12081210
sharedPtrWrapped: SharedSyncUser
1211+
1212+
User:
1213+
base: SyncUser
1214+
cppName: app::User
1215+
sharedPtrWrapped: SharedUser
12091216
properties:
12101217
is_logged_in: bool
12111218
user_id: std::string
@@ -1214,21 +1221,6 @@ classes:
12141221
access_token: std::string
12151222
refresh_token: std::string
12161223
state: SyncUserState
1217-
sync_manager: SharedSyncManager
1218-
methods:
1219-
access_token_refresh_required: '() -> bool'
1220-
# request_log_out: '(cb: AsyncCallback<(err: std::optional<AppError>)>&&)'
1221-
request_refresh_user: '(cb: AsyncCallback<(err: std::optional<AppError>)>&&)'
1222-
request_refresh_location: '(cb: AsyncCallback<(err: std::optional<AppError>)>&&)'
1223-
request_access_token: '(cb: AsyncCallback<(err: std::optional<AppError>)>&&)'
1224-
track_realm: '(path: std::string_view)'
1225-
create_file_action: '(action: SyncFileAction, original_path: std::string_view, requested_recovery_dir: std::optional<std::string>, partition_value: std::string_view) -> std::string'
1226-
1227-
User:
1228-
base: SyncUser
1229-
cppName: app::User
1230-
sharedPtrWrapped: SharedUser
1231-
properties:
12321224
is_anonymous: bool
12331225
device_id: std::string
12341226
has_device_id: bool
@@ -1242,6 +1234,13 @@ classes:
12421234
subscribe: '(observer: (user: IgnoreArgument<const User&>)) -> UserSubscriptionToken'
12431235
unsubscribe: '(token: UserSubscriptionToken)'
12441236
path_for_realm: '(config: SyncConfig&, custom_file_name: std::optional<std::string>&) -> std::string'
1237+
access_token_refresh_required: '() -> bool'
1238+
# # request_log_out: '(cb: AsyncCallback<(err: std::optional<AppError>)>&&)'
1239+
request_refresh_user: '(cb: AsyncCallback<(err: std::optional<AppError>)>&&)'
1240+
request_refresh_location: '(cb: AsyncCallback<(err: std::optional<AppError>)>&&)'
1241+
request_access_token: '(cb: AsyncCallback<(err: std::optional<AppError>)>&&)'
1242+
track_realm: '(path: std::string_view)'
1243+
create_file_action: '(action: SyncFileAction, original_path: std::string_view, requested_recovery_dir: std::optional<std::string>, partition_value: std::string_view) -> std::string'
12451244

12461245
UserProfile:
12471246
cppName: app::UserProfile
@@ -1361,7 +1360,7 @@ classes:
13611360
reconnect: ()
13621361
wait_for_sessions_to_terminate: ()
13631362
get_existing_active_session: '(path: const std::string&) -> Nullable<SharedSyncSession>'
1364-
get_all_sessions_for: '(user: const SyncUser&) -> std::vector<SharedSyncSession>'
1363+
get_all_sessions_for: '(user: const User&) -> std::vector<SharedSyncSession>'
13651364

13661365
ThreadSafeReference: {}
13671366
AsyncOpenTask:

bindgen/src/realm_helpers.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <realm/object-store/shared_realm.hpp>
3131
#include <realm/object-store/sync/generic_network_transport.hpp>
3232
#include <realm/object-store/util/event_loop_dispatcher.hpp>
33+
#include <realm/object-store/sync/app_user.hpp>
34+
#include <realm/object-store/sync/sync_user.hpp>
3335
#include <realm/util/functional.hpp>
3436
#include <string_view>
3537
#include <system_error>
@@ -283,6 +285,11 @@ struct Helpers {
283285
{
284286
return config.needs_file_format_upgrade();
285287
}
288+
289+
static std::shared_ptr<app::User> sync_user_as_app_user(std::shared_ptr<SyncUser> sync_user)
290+
{
291+
return std::dynamic_pointer_cast<app::User>(sync_user);
292+
}
286293
};
287294

288295
struct ObjectChangeSet {

0 commit comments

Comments
 (0)