From 3963ffa3db0af81687ad60314f41b80f0937f935 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Thu, 23 Nov 2017 17:21:03 +0100 Subject: [PATCH 01/15] Updating to Realm Sync 2.1.7. --- CHANGELOG.md | 15 +++++++++++++++ dependencies.list | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffb20964..4ff9176d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +X.Y.X Release notes +============================================================= +### Breaking changes +* None. + +### Enchancements +* None + +### Bug fixes +* [Object Server] Fixed a bug where deleted-then-recreated objects with identical primary keys to become empty. +* [Object Server] Fixed a bug in outward partial sync is changed to ensure convergence of partial sync in the case where the client creates a primary key object, that is already present on the server, and subscribes to it in the same transaction. + +### Internal +* Updated to Realm Sync 2.1.7 (see under "Bug fixes"). + 2.0.10 Release notes (2017-11-21) ============================================================= ### Breaking changes diff --git a/dependencies.list b/dependencies.list index d02ad1c6..b318904f 100644 --- a/dependencies.list +++ b/dependencies.list @@ -1,5 +1,5 @@ PACKAGE_NAME=realm-js VERSION=2.0.10 REALM_CORE_VERSION=4.0.2 -REALM_SYNC_VERSION=2.1.6 +REALM_SYNC_VERSION=2.1.7 REALM_OBJECT_SERVER_VERSION=2.0.21 From fc6d62c68e171a17b1d28ce9f86dd2107733088e Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Thu, 23 Nov 2017 17:54:11 +0100 Subject: [PATCH 02/15] [2.0.11] Bump version --- CHANGELOG.md | 2 +- dependencies.list | 2 +- package.json | 2 +- src/RealmJS.xcodeproj/project.pbxproj | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ff9176d..566d66f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -X.Y.X Release notes +2.0.11 Release notes (2017-11-23) ============================================================= ### Breaking changes * None. diff --git a/dependencies.list b/dependencies.list index b318904f..89b7125b 100644 --- a/dependencies.list +++ b/dependencies.list @@ -1,5 +1,5 @@ PACKAGE_NAME=realm-js -VERSION=2.0.10 +VERSION=2.0.11 REALM_CORE_VERSION=4.0.2 REALM_SYNC_VERSION=2.1.7 REALM_OBJECT_SERVER_VERSION=2.0.21 diff --git a/package.json b/package.json index f024f896..19b18735 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "realm", "description": "Realm is a mobile database: an alternative to SQLite and key-value stores", - "version": "2.0.10", + "version": "2.0.11", "license": "Apache-2.0", "homepage": "https://realm.io", "keywords": [ diff --git a/src/RealmJS.xcodeproj/project.pbxproj b/src/RealmJS.xcodeproj/project.pbxproj index 95b39927..a3f59f3f 100644 --- a/src/RealmJS.xcodeproj/project.pbxproj +++ b/src/RealmJS.xcodeproj/project.pbxproj @@ -999,7 +999,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 2.0.10; + CURRENT_PROJECT_VERSION = 2.0.11; CXX = "$(SRCROOT)/../scripts/ccache-clang++.sh"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -1063,7 +1063,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 2.0.10; + CURRENT_PROJECT_VERSION = 2.0.11; CXX = "$(SRCROOT)/../scripts/ccache-clang++.sh"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; From 93f93de4489709285971c0a9505653b00bda2ef1 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Fri, 24 Nov 2017 15:06:53 +0100 Subject: [PATCH 03/15] localeconv() doesn't exist on Android API < 21. --- CHANGELOG.md | 14 ++++++++++++++ vendor/json.hpp | 14 +++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 566d66f2..1d691aef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +X.Y.Z Release notes +============================================================= +### Breaking changes +* None. + +### Enchancements +* None + +### Bug fixes +* Fixed a bug in 3rd party JSON parser: `localeconv()` does not exist on Android API < 21 and should not be called. + +### Internal +* None. + 2.0.11 Release notes (2017-11-23) ============================================================= ### Breaking changes diff --git a/vendor/json.hpp b/vendor/json.hpp index b20cc48d..a3e2d380 100644 --- a/vendor/json.hpp +++ b/vendor/json.hpp @@ -8333,15 +8333,15 @@ class basic_json // check if buffer was large enough assert(static_cast(written_bytes) < m_buf.size()); + #if defined(ANDROID) + // Android NDK doesn't have access to locale info yet; API < 21 doesn't have localeconv() + const char thousands_sep = ','; + const char decimal_point = '.'; + #else // read information from locale const auto loc = localeconv(); assert(loc != nullptr); - #if defined(ANDROID) - // Android NDK doesn't have access to locale info yet - const char thousands_sep = ','; - const char decimal_point = '.'; - #else const char thousands_sep = !loc->thousands_sep ? '\0' : loc->thousands_sep[0]; @@ -11176,11 +11176,11 @@ basic_json_parser_74: // since dealing with strtod family of functions, we're // getting the decimal point char from the C locale facilities // instead of C++'s numpunct facet of the current std::locale - const auto loc = localeconv(); - assert(loc != nullptr); #if defined(ANDROID) const char decimal_point_char = '.'; #else + const auto loc = localeconv(); + assert(loc != nullptr); const char decimal_point_char = (loc->decimal_point == nullptr) ? '.' : loc->decimal_point[0]; #endif From d127a228ea74113040919ade8ad1e7150a15b42a Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 28 Nov 2017 08:31:40 -0800 Subject: [PATCH 04/15] Fix generating an Xcode project via gyp (#1536) Putting the libraries in direct_dependent_settings rather than link_settings happens to work for command-line builds, but resulted in gyp crashing when trying to generate an Xcode project because it would try to add the linker flags to the aggregate targets. --- realm.gypi | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/realm.gypi b/realm.gypi index cc67c761..4146d085 100644 --- a/realm.gypi +++ b/realm.gypi @@ -115,13 +115,15 @@ "target_name": "realm-core", "type": "none", "direct_dependent_settings": { - "libraries": [ "-lrealm<(debug_library_suffix)" ], "conditions": [ ["use_realm_debug", { "defines": [ "REALM_DEBUG=1" ] }] ] }, + "link_settings": { + "libraries": [ "-lrealm<(debug_library_suffix)" ], + }, "variables": { "prefix": " Date: Wed, 29 Nov 2017 17:21:45 -0800 Subject: [PATCH 05/15] Add the header files and scripts to the gyp file (#1540) * Add the header files and scripts to the gyp file This makes the generated project much more useful. * Also add the tests --- binding.gyp | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++- realm.gypi | 62 ++++++++++++++++++++++++++ 2 files changed, 186 insertions(+), 2 deletions(-) diff --git a/binding.gyp b/binding.gyp index bac961b6..19b604bb 100644 --- a/binding.gyp +++ b/binding.gyp @@ -10,9 +10,37 @@ "object-store" ], "sources": [ - "src/node/platform.cpp", "src/js_realm.cpp", - "src/node/node_init.cpp" + "src/node/node_init.cpp", + "src/node/platform.cpp", + + "src/concurrent_deque.hpp", + "src/event_loop_dispatcher.hpp", + "src/js_class.hpp", + "src/js_collection.hpp", + "src/js_list.hpp", + "src/js_object_accessor.hpp", + "src/js_observable.hpp", + "src/js_realm.hpp", + "src/js_realm_object.hpp", + "src/js_results.hpp", + "src/js_schema.hpp", + "src/js_sync.hpp", + "src/js_types.hpp", + "src/js_util.hpp", + "src/node/node_class.hpp", + "src/node/node_context.hpp", + "src/node/node_exception.hpp", + "src/node/node_function.hpp", + "src/node/node_init.hpp", + "src/node/node_object.hpp", + "src/node/node_protected.hpp", + "src/node/node_return_value.hpp", + "src/node/node_string.hpp", + "src/node/node_types.hpp", + "src/node/node_value.hpp", + "src/platform.hpp", + "src/rpc.hpp", ], "include_dirs": [ "src" @@ -28,6 +56,100 @@ "destination": "<(module_path)" } ] + }, + { + "target_name": "scripts", + "type": "none", + "sources": [ + "CHANGELOG.md", + "README.md", + "binding.gyp", + "dependencies.list", + "package.json", + "realm.gypi", + "target_defaults.gypi", + + "lib/collection-methods.js", + "lib/errors.js", + "lib/extensions.js", + "lib/index.d.ts", + "lib/index.js", + "lib/management-schema.js", + "lib/permission-api.js", + "lib/submit-analytics.js", + "lib/user-methods.js", + + "lib/browser/base64.js", + "lib/browser/collections.js", + "lib/browser/constants.js", + "lib/browser/index.js", + "lib/browser/lists.js", + "lib/browser/objects.js", + "lib/browser/results.js", + "lib/browser/rpc.js", + "lib/browser/session.js", + "lib/browser/user.js", + "lib/browser/util.js" + + "scripts/build-node-pre-gyp.ps1", + "scripts/build-node-pre-gyp.sh", + "scripts/ccache-clang++.sh", + "scripts/ccache-clang.sh", + "scripts/changelog-header.sh", + "scripts/check-environment.js", + "scripts/docker-android-wrapper.sh", + "scripts/docker-wrapper.sh", + "scripts/docker_build_wrapper.sh", + "scripts/download-object-server.sh", + "scripts/download-realm.js", + "scripts/download_and_start_server.sh", + "scripts/find-ios-device.rb", + "scripts/git-win-symlink-aliases", + "scripts/handle-license-check.js", + "scripts/prepublish.js", + "scripts/publish.sh", + "scripts/react-tests-android.js", + "scripts/set-version.sh", + "scripts/test.sh", + + "tests/.eslintrc.json", + "tests/index.js", + "tests/js/admin-user-helper.js", + "tests/js/asserts.js", + "tests/js/async-tests.js", + "tests/js/download-api-helper.js", + "tests/js/encryption-tests.js", + "tests/js/garbage-collection.js", + "tests/js/index.js", + "tests/js/linkingobjects-tests.js", + "tests/js/list-tests.js", + "tests/js/migration-tests.js", + "tests/js/object-id-tests.js", + "tests/js/object-tests.js", + "tests/js/package.json", + "tests/js/permission-tests.js", + "tests/js/query-tests.js", + "tests/js/query-tests.json", + "tests/js/realm-tests.js", + "tests/js/results-tests.js", + "tests/js/schemas.js", + "tests/js/session-tests.js", + "tests/js/user-tests.js", + "tests/js/worker-tests-script.js", + "tests/js/worker.js", + "tests/package.json", + "tests/spec/helpers/mock_realm.js", + "tests/spec/helpers/reporters.js", + "tests/spec/helpers/setup-module-path.js", + "tests/spec/support/jasmine.json", + "tests/spec/unit_tests.js", + "tests/test-runners/ava/package.json", + "tests/test-runners/ava/test.js", + "tests/test-runners/jest/package.json", + "tests/test-runners/jest/test.js", + "tests/test-runners/mocha/package.json", + "tests/test-runners/mocha/test.js", + ] } ] } diff --git a/realm.gypi b/realm.gypi index 4146d085..eeb33271 100644 --- a/realm.gypi +++ b/realm.gypi @@ -63,6 +63,68 @@ "src/object-store/src/parser/query_builder.cpp", "src/object-store/src/util/format.cpp", "src/object-store/src/util/uuid.cpp", + + "src/object-store/src/binding_callback_thread_observer.hpp", + "src/object-store/src/binding_context.hpp", + "src/object-store/src/collection_notifications.hpp", + "src/object-store/src/descriptor_ordering.hpp", + "src/object-store/src/execution_context_id.hpp", + "src/object-store/src/feature_checks.hpp", + "src/object-store/src/impl/apple/external_commit_helper.hpp", + "src/object-store/src/impl/apple/keychain_helper.hpp", + "src/object-store/src/impl/collection_change_builder.hpp", + "src/object-store/src/impl/collection_notifier.hpp", + "src/object-store/src/impl/epoll/external_commit_helper.hpp", + "src/object-store/src/impl/external_commit_helper.hpp", + "src/object-store/src/impl/generic/external_commit_helper.hpp", + "src/object-store/src/impl/list_notifier.hpp", + "src/object-store/src/impl/notification_wrapper.hpp", + "src/object-store/src/impl/object_accessor_impl.hpp", + "src/object-store/src/impl/object_notifier.hpp", + "src/object-store/src/impl/primitive_list_notifier.hpp", + "src/object-store/src/impl/realm_coordinator.hpp", + "src/object-store/src/impl/results_notifier.hpp", + "src/object-store/src/impl/transact_log_handler.hpp", + "src/object-store/src/impl/weak_realm_notifier.hpp", + "src/object-store/src/impl/windows/external_commit_helper.hpp", + "src/object-store/src/index_set.hpp", + "src/object-store/src/list.hpp", + "src/object-store/src/object.hpp", + "src/object-store/src/object_accessor.hpp", + "src/object-store/src/object_schema.hpp", + "src/object-store/src/object_store.hpp", + "src/object-store/src/parser/parser.hpp", + "src/object-store/src/parser/query_builder.hpp", + "src/object-store/src/property.hpp", + "src/object-store/src/results.hpp", + "src/object-store/src/schema.hpp", + "src/object-store/src/shared_realm.hpp", + "src/object-store/src/sync/impl/apple/network_reachability_observer.hpp", + "src/object-store/src/sync/impl/apple/system_configuration.hpp", + "src/object-store/src/sync/impl/network_reachability.hpp", + "src/object-store/src/sync/impl/sync_client.hpp", + "src/object-store/src/sync/impl/sync_file.hpp", + "src/object-store/src/sync/impl/sync_metadata.hpp", + "src/object-store/src/sync/partial_sync.hpp", + "src/object-store/src/sync/sync_config.hpp", + "src/object-store/src/sync/sync_manager.hpp", + "src/object-store/src/sync/sync_permission.hpp", + "src/object-store/src/sync/sync_session.hpp", + "src/object-store/src/sync/sync_user.hpp", + "src/object-store/src/thread_safe_reference.hpp", + "src/object-store/src/util/aligned_union.hpp", + "src/object-store/src/util/android/event_loop_signal.hpp", + "src/object-store/src/util/any.hpp", + "src/object-store/src/util/apple/event_loop_signal.hpp", + "src/object-store/src/util/atomic_shared_ptr.hpp", + "src/object-store/src/util/compiler.hpp", + "src/object-store/src/util/event_loop_signal.hpp", + "src/object-store/src/util/format.hpp", + "src/object-store/src/util/generic/event_loop_signal.hpp", + "src/object-store/src/util/tagged_bool.hpp", + "src/object-store/src/util/time.hpp", + "src/object-store/src/util/uuid.hpp", + "src/object-store/src/util/uv/event_loop_signal.hpp", ], "conditions": [ ["OS=='win'", { From 5dac78a97ab135a2510b059db7f3726247f1494f Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Thu, 30 Nov 2017 14:51:17 +0100 Subject: [PATCH 06/15] Upgrading to Realm Sync v2.1.8 --- CHANGELOG.md | 2 +- dependencies.list | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d691aef..eb7a3688 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ X.Y.Z Release notes * Fixed a bug in 3rd party JSON parser: `localeconv()` does not exist on Android API < 21 and should not be called. ### Internal -* None. +* Upgraded to Realm Sync 2.1.8. 2.0.11 Release notes (2017-11-23) ============================================================= diff --git a/dependencies.list b/dependencies.list index 89b7125b..b09bcb5c 100644 --- a/dependencies.list +++ b/dependencies.list @@ -1,5 +1,5 @@ PACKAGE_NAME=realm-js VERSION=2.0.11 REALM_CORE_VERSION=4.0.2 -REALM_SYNC_VERSION=2.1.7 +REALM_SYNC_VERSION=2.1.8 REALM_OBJECT_SERVER_VERSION=2.0.21 From fada575aafcfe74568bf6bed497ff221fe49be4b Mon Sep 17 00:00:00 2001 From: Brian Munkholm Date: Thu, 30 Nov 2017 22:38:57 +0100 Subject: [PATCH 07/15] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb7a3688..af019c88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -X.Y.Z Release notes +2.0.12 Release notes ============================================================= ### Breaking changes * None. @@ -10,7 +10,7 @@ X.Y.Z Release notes * Fixed a bug in 3rd party JSON parser: `localeconv()` does not exist on Android API < 21 and should not be called. ### Internal -* Upgraded to Realm Sync 2.1.8. +* Upgraded to Realm Sync 2.1.8 (no external effects). 2.0.11 Release notes (2017-11-23) ============================================================= From 9d5ed20919cf3ee59a53f673ebc4f1e9e4bed809 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Fri, 1 Dec 2017 10:15:56 +0100 Subject: [PATCH 08/15] Fix typo in docs --- docs/sync.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sync.js b/docs/sync.js index 711d0046..d14a747d 100644 --- a/docs/sync.js +++ b/docs/sync.js @@ -408,7 +408,7 @@ class Adapter { * @param {string} local_path - the local path where realm files are stored * @param {string} server_url - the sync server to listen to * @param {SyncUser} admin_user - an admin user obtained by calling `new Realm.Sync.User.adminUser` - * @param {string} regex - a regular expression used to determine which cahnged Realms should be monitored - + * @param {string} regex - a regular expression used to determine which changed Realms should be monitored - * use `.*` to match all all Realms * @param {function(realm_path)} change_callback - called when a new transaction is available * to process for the given realm_path From 28f9e027b5ae435f6b03e144f9f6e488b259f3b3 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Fri, 1 Dec 2017 13:00:02 +0100 Subject: [PATCH 09/15] Fixing unit tests (discovered on Android). (#1523) * Fixing unit tests (discovered on Android). --- CHANGELOG.md | 1 + tests/js/list-tests.js | 1 - tests/js/results-tests.js | 41 +++++++++++++++++++-------------------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af019c88..273cb1e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * Fixed a bug in 3rd party JSON parser: `localeconv()` does not exist on Android API < 21 and should not be called. ### Internal +* Fixed issues in unit tests (`addListener` hangs on Android). * Upgraded to Realm Sync 2.1.8 (no external effects). 2.0.11 Release notes (2017-11-23) diff --git a/tests/js/list-tests.js b/tests/js/list-tests.js index 145bc9ed..2b171112 100644 --- a/tests/js/list-tests.js +++ b/tests/js/list-tests.js @@ -41,7 +41,6 @@ module.exports = { TestCase.assertThrowsContaining(() => new Realm.List(), 'constructor'); - TestCase.assertType(Realm.List, 'function'); TestCase.assertInstanceOf(Realm.List, Function); }, diff --git a/tests/js/results-tests.js b/tests/js/results-tests.js index 9c238622..ec4a6f2a 100644 --- a/tests/js/results-tests.js +++ b/tests/js/results-tests.js @@ -423,7 +423,7 @@ module.exports = { testAddListener: function() { if (typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent)) { // eslint-disable-line no-undef // FIXME: async callbacks do not work correctly in Chrome debugging mode - return; + return Promise.resolve(); } const realm = new Realm({ schema: [schemas.TestObject] }); @@ -433,29 +433,28 @@ module.exports = { realm.create('TestObject', { doubleCol: 3 }); }); - let resolve, first = true; + let resolve = () => {}; + let first = true; + + realm.objects('TestObject').addListener((testObjects, changes) => { + if (first) { + TestCase.assertEqual(testObjects.length, 3); + TestCase.assertEqual(changes.insertions.length, 0); + } + else { + TestCase.assertEqual(testObjects.length, 4); + TestCase.assertEqual(changes.insertions.length, 1); + } + first = false; + resolve(); + }); + return new Promise((r, _reject) => { resolve = r; - realm.objects('TestObject').addListener((testObjects, changes) => { - if (first) { - TestCase.assertEqual(testObjects.length, 3); - TestCase.assertEqual(changes.insertions.length, 0); - } - else { - TestCase.assertEqual(testObjects.length, 4); - TestCase.assertEqual(changes.insertions.length, 1); - } - first = false; - resolve(); + realm.write(() => { + realm.create('TestObject', { doubleCol: 1 }); }); - }).then(() => { - return new Promise((r, _reject) => { - realm.write(() => { - realm.create('TestObject', { doubleCol: 1 }); - }); - resolve = r; - }); - }) + }); }, testResultsAggregateFunctions: function() { From 7d6817971d17bf5d6e08c39433c053669e4850ed Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Fri, 1 Dec 2017 13:03:22 +0100 Subject: [PATCH 10/15] [2.0.12] Bump version --- CHANGELOG.md | 2 +- dependencies.list | 2 +- package.json | 2 +- src/RealmJS.xcodeproj/project.pbxproj | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 273cb1e1..28b4f08c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -2.0.12 Release notes +2.0.12 Release notes (2017-12-1) ============================================================= ### Breaking changes * None. diff --git a/dependencies.list b/dependencies.list index b09bcb5c..9735512c 100644 --- a/dependencies.list +++ b/dependencies.list @@ -1,5 +1,5 @@ PACKAGE_NAME=realm-js -VERSION=2.0.11 +VERSION=2.0.12 REALM_CORE_VERSION=4.0.2 REALM_SYNC_VERSION=2.1.8 REALM_OBJECT_SERVER_VERSION=2.0.21 diff --git a/package.json b/package.json index 19b18735..283816a1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "realm", "description": "Realm is a mobile database: an alternative to SQLite and key-value stores", - "version": "2.0.11", + "version": "2.0.12", "license": "Apache-2.0", "homepage": "https://realm.io", "keywords": [ diff --git a/src/RealmJS.xcodeproj/project.pbxproj b/src/RealmJS.xcodeproj/project.pbxproj index a3f59f3f..6024cd49 100644 --- a/src/RealmJS.xcodeproj/project.pbxproj +++ b/src/RealmJS.xcodeproj/project.pbxproj @@ -999,7 +999,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 2.0.11; + CURRENT_PROJECT_VERSION = 2.0.12; CXX = "$(SRCROOT)/../scripts/ccache-clang++.sh"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -1063,7 +1063,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 2.0.11; + CURRENT_PROJECT_VERSION = 2.0.12; CXX = "$(SRCROOT)/../scripts/ccache-clang++.sh"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; From f3bbc604dcdfb78335af894fff863515a3a7723a Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Tue, 5 Dec 2017 09:37:35 +0000 Subject: [PATCH 11/15] update JSDOC to work with Node 8 (avoid EISDIR error) --- package-lock.json | 24 ++++++++++++------------ package.json | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index e209caf5..2368e85c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "realm", - "version": "2.0.0-rc11", + "version": "2.0.12", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -270,9 +270,9 @@ } }, "bluebird": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz", - "integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw=", + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==", "dev": true }, "boom": { @@ -1537,18 +1537,18 @@ "optional": true }, "jsdoc": { - "version": "3.5.4", - "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.5.4.tgz", - "integrity": "sha1-zu73xLrEM1yxD/QeOg9Yk5pTRCg=", + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.5.5.tgz", + "integrity": "sha512-6PxB65TAU4WO0Wzyr/4/YhlGovXl0EVYfpKbpSroSj0qBxT4/xod/l40Opkm38dRHRdQgdeY836M0uVnJQG7kg==", "dev": true, "requires": { "babylon": "7.0.0-beta.19", - "bluebird": "3.5.0", + "bluebird": "3.5.1", "catharsis": "0.8.9", "escape-string-regexp": "1.0.5", "js2xmlparser": "3.0.0", "klaw": "2.0.0", - "marked": "0.3.6", + "marked": "0.3.7", "mkdirp": "0.5.1", "requizzle": "0.2.1", "strip-json-comments": "2.0.1", @@ -2497,9 +2497,9 @@ } }, "marked": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.6.tgz", - "integrity": "sha1-ssbGGPzOzk74bE/Gy4p8v1rtqNc=", + "version": "0.3.7", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.7.tgz", + "integrity": "sha512-zBEP4qO1YQp5aXHt8S5wTiOv9i2X74V/LQL0zhUNvVaklt6Ywa6lChxIvS+ibYlCGgADwKwZFhjC3+XfpsvQvQ==", "dev": true }, "mime-db": { diff --git a/package.json b/package.json index 283816a1..1d33f3de 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "eslint": "^3.2.2", "eslint-plugin-jasmine": "^2.1.0", "eslint-plugin-react": "^6.7.0", - "jsdoc": "^3.4.0", + "jsdoc": "^3.5.5", "license-checker": "^8.0.3", "mockery": "^2.0.0", "rimraf": "^2.6.1", From 70004b93046fd39ab261db73cfe834e4c6c20d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Thu, 7 Dec 2017 10:36:24 +0100 Subject: [PATCH 12/15] Checking the content-type of authentication responses (#1556) * Checking the content-type of authentication responses * Adding a changelog entry * Fixing changelog typos and line endings --- CHANGELOG.md | 32 +++++++++++++++++++++++--------- lib/user-methods.js | 10 +++++++++- tests/js/user-tests.js | 15 ++++++++++++++- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28b4f08c..3e12a3c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,23 @@ +x.y.z Release notes +============================================================= +### Breaking changes +* None + +### Enhancements +* None + +### Bug fixes +* When authentication fails due to a misbehaving server, a proper error is thrown. + +### Internal +* None + 2.0.12 Release notes (2017-12-1) ============================================================= ### Breaking changes * None. -### Enchancements +### Enhancements * None ### Bug fixes @@ -18,12 +32,12 @@ ### Breaking changes * None. -### Enchancements +### Enhancements * None ### Bug fixes * [Object Server] Fixed a bug where deleted-then-recreated objects with identical primary keys to become empty. -* [Object Server] Fixed a bug in outward partial sync is changed to ensure convergence of partial sync in the case where the client creates a primary key object, that is already present on the server, and subscribes to it in the same transaction. +* [Object Server] Fixed a bug in outward partial sync is changed to ensure convergence of partial sync in the case where the client creates a primary key object, that is already present on the server, and subscribes to it in the same transaction. ### Internal * Updated to Realm Sync 2.1.7 (see under "Bug fixes"). @@ -33,7 +47,7 @@ ### Breaking changes * None. -### Enchancements +### Enhancements * None ### Bug fixes @@ -47,7 +61,7 @@ ### Breaking changes * None. -### Enchancements +### Enhancements * None ### Bug fixes @@ -61,7 +75,7 @@ ### Breaking changes * None. -### Enchancements +### Enhancements * [Object Server] Improving performance of processing large changesets. ### Bug fixes @@ -76,7 +90,7 @@ ### Breaking changes * None -### Enchancements +### Enhancements * None ### Bug fixes @@ -91,7 +105,7 @@ ### Breaking changes * None. -### Enchancements +### Enhancements * Improved notification performance for objects with no object or list properties. ### Bug fixes @@ -107,7 +121,7 @@ ### Breaking changes * None. -### Enchancements +### Enhancements * None. ### Bug fixes diff --git a/lib/user-methods.js b/lib/user-methods.js index 3ec76eba..b0f4210c 100644 --- a/lib/user-methods.js +++ b/lib/user-methods.js @@ -154,7 +154,15 @@ function _authenticate(userConstructor, server, json, callback) { const promise = performFetch(url, options) .then((response) => { - if (response.status !== 200) { + const contentType = response.headers.get('Content-Type'); + if (contentType.indexOf('application/json') === -1) { + return response.text().then((body) => { + throw new AuthError({ + title: `Could not authenticate: Realm Object Server didn't respond with valid JSON`, + body, + }); + }); + } else if (!response.ok) { return response.json().then((body) => Promise.reject(new AuthError(body))); } else { return response.json().then(function (body) { diff --git a/tests/js/user-tests.js b/tests/js/user-tests.js index b1c02b3a..404ba1fa 100644 --- a/tests/js/user-tests.js +++ b/tests/js/user-tests.js @@ -160,6 +160,20 @@ module.exports = { .catch((e) => assertIsError(e)); }, + testLoginTowardsMisbehavingServer() { + const username = uuid(); + + // Try authenticating towards a server thats clearly not ROS + return Realm.Sync.User.register('https://github.com/realm/realm-js', username, 'user') + .catch((e) => { + assertIsError(e); + TestCase.assertEqual( + e.message, + "Could not authenticate: Realm Object Server didn't respond with valid JSON" + ); + }); + }, + testAll() { const all = Realm.Sync.User.all; TestCase.assertArrayLength(Object.keys(all), 0); @@ -324,4 +338,3 @@ module.exports = { }, */ }; - From 23f965060e3528e4a859814b5d2d315ad7c100a6 Mon Sep 17 00:00:00 2001 From: Yavor Georgiev Date: Thu, 7 Dec 2017 13:47:20 +0100 Subject: [PATCH 13/15] Implement implicit property conversion for date and binary (#1557) * Implement implicit property conversion for date and binary Closes #1542 Closes #1551 * fix include * changelog --- CHANGELOG.md | 3 ++- src/js_object_accessor.hpp | 31 +++++++++++++++++++++++++++++-- src/js_types.hpp | 4 ++-- src/jsc/jsc_value.hpp | 9 +++++++++ src/node/node_init.hpp | 2 +- src/node/node_value.hpp | 17 +++++++++++------ tests/js/object-tests.js | 14 +++++++++++++- tests/js/package.json | 1 + 8 files changed, 68 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e12a3c0..4e614626 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ x.y.z Release notes * When authentication fails due to a misbehaving server, a proper error is thrown. ### Internal -* None +* Strings can now be assigned to Date columns. When that happens the JavaScript Date constructor will be invoked to parse the string. +* Base64 strings can now be assigned to Data columns. 2.0.12 Release notes (2017-12-1) ============================================================= diff --git a/src/js_object_accessor.hpp b/src/js_object_accessor.hpp index 4fc116e5..c2f8f4b6 100644 --- a/src/js_object_accessor.hpp +++ b/src/js_object_accessor.hpp @@ -22,6 +22,10 @@ #include "js_realm_object.hpp" #include "js_schema.hpp" +#if REALM_ENABLE_SYNC +#include +#endif + namespace realm { class List; class Object; @@ -239,7 +243,23 @@ struct Unbox { if (ctx->is_null(value)) { return BinaryData(); } - ctx->m_owned_binary_data = js::Value::validated_to_binary(ctx->m_ctx, value, "Property"); +#if REALM_ENABLE_SYNC + // realm-sync holds the base64-decoding routine + if (js::Value::is_string(ctx->m_ctx, value)) { + // the incoming value might be a base64 string, so let's try to parse it + std::string str = js::Value::to_string(ctx->m_ctx, value); + size_t max_size = util::base64_decoded_size(str.size()); + std::unique_ptr data(new char[max_size]); + if (auto size = util::base64_decode(str, data.get(), max_size)) { + ctx->m_owned_binary_data = OwnedBinaryData(std::move(data), *size); + return ctx->m_owned_binary_data.get(); + } else { + throw std::runtime_error("Attempting to populate BinaryData from string that is not valid base64"); + } + } +#endif + + ctx->m_owned_binary_data = js::Value::validated_to_binary(ctx->m_ctx, value); return ctx->m_owned_binary_data.get(); } }; @@ -257,7 +277,14 @@ struct Unbox { if (ctx->is_null(value)) { return Timestamp(); } - auto date = js::Value::validated_to_date(ctx->m_ctx, value, "Property"); + typename JSEngine::Value date; + if (js::Value::is_string(ctx->m_ctx, value)) { + // the incoming value might be a date string, so let the Date constructor have at it + date = js::Value::to_date(ctx->m_ctx, value); + } else { + date = js::Value::validated_to_date(ctx->m_ctx, value); + } + double milliseconds = js::Value::to_number(ctx->m_ctx, date); int64_t seconds = milliseconds / 1000; int32_t nanoseconds = ((int64_t)milliseconds % 1000) * 1000000; diff --git a/src/js_types.hpp b/src/js_types.hpp index 64f78096..0c7e5309 100644 --- a/src/js_types.hpp +++ b/src/js_types.hpp @@ -389,9 +389,9 @@ inline bool Value::is_valid_for_property_type(ContextType context, const Valu case PropertyType::String: return is_string(context, value); case PropertyType::Data: - return is_binary(context, value); + return is_binary(context, value) || is_string(context, value); case PropertyType::Date: - return is_date(context, value); + return is_date(context, value) || is_string(context, value); case PropertyType::Object: return true; case PropertyType::Any: diff --git a/src/jsc/jsc_value.hpp b/src/jsc/jsc_value.hpp index 4d4cab89..5c113e56 100644 --- a/src/jsc/jsc_value.hpp +++ b/src/jsc/jsc_value.hpp @@ -203,6 +203,15 @@ inline JSObjectRef jsc::Value::to_constructor(JSContextRef ctx, const JSValueRef template<> inline JSObjectRef jsc::Value::to_date(JSContextRef ctx, const JSValueRef &value) { + if (JSValueIsString(ctx, value)) { + JSValueRef error; + std::array args { value }; + if (JSObjectRef result = JSObjectMakeDate(ctx, args.size(), args.data(), &error)) { + return result; + } else { + throw jsc::Exception(ctx, error); + } + } return to_object(ctx, value); } diff --git a/src/node/node_init.hpp b/src/node/node_init.hpp index f2a9cbca..dfc795b6 100644 --- a/src/node/node_init.hpp +++ b/src/node/node_init.hpp @@ -21,9 +21,9 @@ #include "node_string.hpp" #include "node_protected.hpp" #include "node_context.hpp" -#include "node_value.hpp" #include "node_object.hpp" #include "node_function.hpp" +#include "node_value.hpp" #include "node_exception.hpp" #include "node_return_value.hpp" #include "node_class.hpp" diff --git a/src/node/node_value.hpp b/src/node/node_value.hpp index 20dc7d8e..1339028f 100644 --- a/src/node/node_value.hpp +++ b/src/node/node_value.hpp @@ -204,11 +204,6 @@ inline v8::Local node::Value::to_array(v8::Isolate* isolate, const v return to_object(isolate, value); } -template<> -inline v8::Local node::Value::to_date(v8::Isolate* isolate, const v8::Local &value) { - return to_object(isolate, value); -} - template<> inline v8::Local node::Value::to_function(v8::Isolate* isolate, const v8::Local &value) { return value->IsFunction() ? v8::Local::Cast(value) : v8::Local(); @@ -218,6 +213,16 @@ template<> inline v8::Local node::Value::to_constructor(v8::Isolate* isolate, const v8::Local &value) { return to_function(isolate, value); } - + +template<> +inline v8::Local node::Value::to_date(v8::Isolate* isolate, const v8::Local &value) { + if (value->IsString()) { + v8::Local date_constructor = to_constructor(isolate, node::Object::get_property(isolate, isolate->GetCurrentContext()->Global(), "Date")); + std::array, 1> args { {value} }; + return node::Function::construct(isolate, date_constructor, args.size(), args.data()); + } + return to_object(isolate, value); +} + } // js } // realm diff --git a/tests/js/object-tests.js b/tests/js/object-tests.js index 0b19e20e..88792067 100644 --- a/tests/js/object-tests.js +++ b/tests/js/object-tests.js @@ -297,6 +297,15 @@ module.exports = { }); TestCase.assertArraysEqual(new Uint8Array(object.dataCol), RANDOM_DATA); + if (Realm.Sync) { + // The base64 decoder comes from realm-sync + // Should be able to also set a data property to base64-encoded string. + realm.write(function() { + object.dataCol = require('buffer/').Buffer.from(RANDOM_DATA).toString('base64'); + }); + TestCase.assertArraysEqual(new Uint8Array(object.dataCol), RANDOM_DATA); + } + // Should be to set a data property to a DataView. realm.write(function() { object.dataCol = new DataView(RANDOM_DATA.buffer); @@ -348,7 +357,7 @@ module.exports = { object.dataCol = 1; }); TestCase.assertThrows(function() { - object.dataCol = 'data'; + object.dataCol = 'some binary data'; }); TestCase.assertThrows(function() { object.dataCol = [1]; @@ -431,15 +440,18 @@ module.exports = { // test different dates var realm = new Realm({schema: [schemas.DateObject]}); + const stringifiedDate = new Date(); realm.write(function() { realm.create('Date', { currentDate: new Date(10000) }); realm.create('Date', { currentDate: new Date(-10000) }); realm.create('Date', { currentDate: new Date(1000000000000) }); realm.create('Date', { currentDate: new Date(-1000000000000) }); + realm.create('Date', { currentDate: stringifiedDate.toString() }); }); TestCase.assertEqual(realm.objects('Date')[0].currentDate.getTime(), 10000); TestCase.assertEqual(realm.objects('Date')[1].currentDate.getTime(), -10000); TestCase.assertEqual(realm.objects('Date')[2].currentDate.getTime(), 1000000000000); TestCase.assertEqual(realm.objects('Date')[3].currentDate.getTime(), -1000000000000); + TestCase.assertEqual(realm.objects('Date')[4].currentDate.toString(), stringifiedDate.toString()); } }; diff --git a/tests/js/package.json b/tests/js/package.json index c7afa5d5..4a67b4e0 100644 --- a/tests/js/package.json +++ b/tests/js/package.json @@ -3,6 +3,7 @@ "version": "0.0.1", "private": true, "dependencies": { + "buffer": "^5.0.8", "es6-promise": "^3.2.1" } } From 517c165c12f44a4347b13eb2fdcea88a206bfdad Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Fri, 8 Dec 2017 10:57:55 +0100 Subject: [PATCH 14/15] [2.0.13] Bump version --- CHANGELOG.md | 14 +++++++------- dependencies.list | 2 +- package.json | 2 +- src/RealmJS.xcodeproj/project.pbxproj | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e614626..423f41f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +1,17 @@ -x.y.z Release notes +2.0.13 Release notes (2017-12-8) ============================================================= ### Breaking changes -* None +* None. ### Enhancements -* None +* None. ### Bug fixes -* When authentication fails due to a misbehaving server, a proper error is thrown. +* [Object Server] When authentication fails due to a misbehaving server, a proper error is thrown. ### Internal -* Strings can now be assigned to Date columns. When that happens the JavaScript Date constructor will be invoked to parse the string. -* Base64 strings can now be assigned to Data columns. +* [Object Server] Strings can now be assigned to Date columns. When that happens the JavaScript Date constructor will be invoked to parse the string. +* [Object Server] Base64 strings can now be assigned to Data columns. 2.0.12 Release notes (2017-12-1) ============================================================= @@ -19,7 +19,7 @@ x.y.z Release notes * None. ### Enhancements -* None +* None. ### Bug fixes * Fixed a bug in 3rd party JSON parser: `localeconv()` does not exist on Android API < 21 and should not be called. diff --git a/dependencies.list b/dependencies.list index 9735512c..3e987eb2 100644 --- a/dependencies.list +++ b/dependencies.list @@ -1,5 +1,5 @@ PACKAGE_NAME=realm-js -VERSION=2.0.12 +VERSION=2.0.13 REALM_CORE_VERSION=4.0.2 REALM_SYNC_VERSION=2.1.8 REALM_OBJECT_SERVER_VERSION=2.0.21 diff --git a/package.json b/package.json index 1d33f3de..7993d538 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "realm", "description": "Realm is a mobile database: an alternative to SQLite and key-value stores", - "version": "2.0.12", + "version": "2.0.13", "license": "Apache-2.0", "homepage": "https://realm.io", "keywords": [ diff --git a/src/RealmJS.xcodeproj/project.pbxproj b/src/RealmJS.xcodeproj/project.pbxproj index 6024cd49..d3685cd9 100644 --- a/src/RealmJS.xcodeproj/project.pbxproj +++ b/src/RealmJS.xcodeproj/project.pbxproj @@ -999,7 +999,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 2.0.12; + CURRENT_PROJECT_VERSION = 2.0.13; CXX = "$(SRCROOT)/../scripts/ccache-clang++.sh"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -1063,7 +1063,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 2.0.12; + CURRENT_PROJECT_VERSION = 2.0.13; CXX = "$(SRCROOT)/../scripts/ccache-clang++.sh"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; From aed1ea104bdd710366283921363423c75f4b5f50 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Wed, 13 Dec 2017 10:09:26 +0100 Subject: [PATCH 15/15] Adding property Realm.isClosed. (#1560) * Adding property Realm.isClosed. --- CHANGELOG.md | 15 +++++++++++++++ docs/realm.js | 8 ++++++++ lib/browser/index.js | 1 + lib/index.d.ts | 1 + src/js_realm.hpp | 9 ++++++++- tests/js/realm-tests.js | 7 +++++++ 6 files changed, 40 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 423f41f7..1107f19c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ + +X.Y.Z Release notes +============================================================= +### Breaking changes +* None. + +### Enhancements +* Added property `Realm.isClosed` which indicates if a Realm instance is closed or not. + +### Bug fixes +* None. + +### Internal +* None. + 2.0.13 Release notes (2017-12-8) ============================================================= ### Breaking changes diff --git a/docs/realm.js b/docs/realm.js index 5ae17650..a6cf1a22 100644 --- a/docs/realm.js +++ b/docs/realm.js @@ -72,6 +72,14 @@ class Realm { */ get isInTransaction() {} + /** + * Indicates if this Realm has been closed. + * @type {boolean} + * @readonly + * @since 2.1.0 + */ + get isClosed() {} + /** * Gets the sync session if this is a synced Realm * @type {Session} diff --git a/lib/browser/index.js b/lib/browser/index.js index 607af4af..17c16a45 100644 --- a/lib/browser/index.js +++ b/lib/browser/index.js @@ -60,6 +60,7 @@ function setupRealm(realm, realmId) { 'schemaVersion', 'syncSession', 'isInTransaction', + 'isClosed', 'subscribeToObjects', ].forEach((name) => { Object.defineProperty(realm, name, {get: util.getterForProperty(name)}); diff --git a/lib/index.d.ts b/lib/index.d.ts index ca94aae4..d7243ce9 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -458,6 +458,7 @@ declare class Realm { readonly schema: Realm.ObjectSchema[]; readonly schemaVersion: number; readonly isInTransaction: boolean; + readonly isClosed: boolean; readonly syncSession: Realm.Sync.Session | null; diff --git a/src/js_realm.hpp b/src/js_realm.hpp index aa00e8bc..2672721b 100644 --- a/src/js_realm.hpp +++ b/src/js_realm.hpp @@ -198,6 +198,7 @@ public: static void get_in_memory(ContextType, ObjectType, ReturnValue &); static void get_read_only(ContextType, ObjectType, ReturnValue &); static void get_is_in_transaction(ContextType, ObjectType, ReturnValue &); + static void get_is_closed(ContextType, ObjectType, ReturnValue &); #if REALM_ENABLE_SYNC static void get_sync_session(ContextType, ObjectType, ReturnValue &); #endif @@ -259,6 +260,7 @@ public: {"inMemory", {wrap, nullptr}}, {"readOnly", {wrap, nullptr}}, {"isInTransaction", {wrap, nullptr}}, + {"isClosed", {wrap, nullptr}}, #if REALM_ENABLE_SYNC {"syncSession", {wrap, nullptr}}, #endif @@ -694,6 +696,11 @@ void RealmClass::get_is_in_transaction(ContextType ctx, ObjectType object, Re return_value.set(get_internal>(object)->get()->is_in_transaction()); } +template +void RealmClass::get_is_closed(ContextType ctx, ObjectType object, ReturnValue &return_value) { + return_value.set(get_internal>(object)->get()->is_closed()); +} + #if REALM_ENABLE_SYNC template void RealmClass::get_sync_session(ContextType ctx, ObjectType object, ReturnValue &return_value) { @@ -738,7 +745,7 @@ void RealmClass::wait_for_download_completion(ContextType ctx, ObjectType thi ValueType callback_arguments[1]; callback_arguments[0] = object; - + Function::callback(protected_ctx, protected_callback, typename T::Object(), 1, callback_arguments); } diff --git a/tests/js/realm-tests.js b/tests/js/realm-tests.js index 665cbc9b..74538114 100644 --- a/tests/js/realm-tests.js +++ b/tests/js/realm-tests.js @@ -57,6 +57,13 @@ module.exports = { TestCase.assertEqual(realm2.path, defaultDir + testPath2); }, + testRealmIsClosed: function() { + const realm = new Realm({schema: []}); + TestCase.assertFalse(realm.isClosed); + realm.close(); + TestCase.assertTrue(realm.isClosed); + }, + testRealmConstructorSchemaVersion: function() { const defaultRealm = new Realm({schema: []}); TestCase.assertEqual(defaultRealm.schemaVersion, 0);