Skip to content

Commit

Permalink
Use SyncUser internally
Browse files Browse the repository at this point in the history
  • Loading branch information
kneth committed Apr 29, 2024
1 parent 286f341 commit 26cca78
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 23 deletions.
2 changes: 0 additions & 2 deletions integration-tests/tests/src/tests/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1052,11 +1052,9 @@ describe("Queries", () => {
expect(aged14Or15.length).to.equal(2);

const aged17 = persons.filtered("age IN $0", [17]);
console.log({ aged17 });
expect(aged17.length).to.equal(1);

const dennis = persons.filtered("name in {'Dennis'}");
console.log({ dennis });
expect(dennis.length).to.equal(0);

const bobs = persons.filtered("name in $0", ["Bob"]);
Expand Down
38 changes: 26 additions & 12 deletions packages/realm/bindgen/js_opt_in_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ classes:
- feed_buffer
- make_ssl_verify_callback
- needs_file_format_upgrade
- sync_user_as_app_user

LogCategoryRef:
methods:
Expand Down Expand Up @@ -445,7 +446,31 @@ classes:
- api_key

SyncUser:
methods: []
# - is_logged_in
# - user_id
# - app_id
# - legacy_identities
# - access_token
# - refresh_token
# - state
# - access_token_refresh_required
# - request_refresh_user
# - request_refresh_location
# - request_access_token
# - track_realm

User:
methods:
- has_device_id
- device_id
- user_profile
- identities
- custom_data
- subscribe
- unsubscribe
- path_for_realm
- app
- is_logged_in
- user_id
- app_id
Expand All @@ -459,18 +484,6 @@ classes:
- request_access_token
- track_realm

User:
methods:
- has_device_id
- device_id
- user_profile
- identities
- custom_data
- subscribe
- unsubscribe
- path_for_realm
- app

UserProfile:
methods:
- data
Expand Down Expand Up @@ -563,6 +576,7 @@ classes:
- revive_if_needed
- force_close
- handle_reconnect
- user
# JS-specific
- DOLLAR_resetSharedPtr

Expand Down
2 changes: 1 addition & 1 deletion packages/realm/bindgen/vendor/realm-core
Submodule realm-core updated 141 files
7 changes: 1 addition & 6 deletions packages/realm/src/app-services/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,6 @@ export class App<
assert.function(fetch, "fetch");
}

const syncClientConfig: binding.SyncClientConfig_Relaxed = {
multiplexSessions,
userAgentBindingInfo: App.userAgent,
};

fs.ensureDirectoryForFile(fs.joinPaths(baseFilePath || fs.getDefaultDirectoryPath(), "mongodb-realm"));
// TODO: This used getSharedApp in the legacy SDK, but it's failing AppTests
this.internal = binding.App.getApp(binding.AppCacheMode.Disabled, {
Expand All @@ -298,7 +293,7 @@ export class App<
syncClientConfig: {
multiplexSessions,
userAgentBindingInfo: App.userAgent,
}
},
});
}

Expand Down
4 changes: 2 additions & 2 deletions packages/realm/src/app-services/SyncSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export class SyncSession {
*/
get config(): SyncConfiguration {
return this.withInternal((internal) => {
const user = new User(internal.config.user, mockApp);
const user = new User(binding.Helpers.syncUserAsAppUser(internal.user), mockApp);
const { partitionValue, flxSyncRequested, customHttpHeaders, clientValidateSsl, sslTrustCertificatePath } =
internal.config;
if (flxSyncRequested) {
Expand Down Expand Up @@ -349,7 +349,7 @@ export class SyncSession {
* Gets the User that this session was created with.
*/
get user() {
return User.get(this.withInternal((internal) => internal.config.user));
return User.get(this.withInternal((internal) => binding.Helpers.syncUserAsAppUser(internal.user)));
}

/**
Expand Down

0 comments on commit 26cca78

Please sign in to comment.