Commit Graph

238 Commits

Author SHA1 Message Date
Ari Lazier e4d4cbbdf3 proper fix/hack removal, partially working sync for rn 2016-11-11 17:53:58 -08:00
Ari Lazier 8ce8f52105 add test for login 2016-11-08 14:07:04 -08:00
Ari Lazier b2e71a5fb6 test fixes 2016-11-08 09:21:27 -08:00
Ari Lazier fde1c5d00d start implementing sync tests 2016-11-08 08:59:30 -08:00
Ari Lazier 5a49dbc325 make sync work with RealmJS tests 2016-10-27 13:49:41 -07:00
Ari Lazier 60d9da1b44 remove unneded server argument for adminUser, update care and sync dependencies 2016-10-26 17:20:34 -07:00
Ari Lazier 92adb669d5 hook up new object store apis 2016-10-26 17:00:46 -07:00
Ari Lazier 0d74c05366 add sync cleanup method 2016-10-25 15:04:58 -07:00
Yavor Georgiev 622482029a Pass AuthError in Realm.Sync.User methods callbacks (#619)
* Pass AuthError in Realm.Sync.User methods callbacks

The new Realm.Sync.AuthError class exposes properties common to the Problem family of classes in the Realm Object Server

* extract AuthError in a separate file

* whitespace
2016-10-25 00:12:12 +02:00
Yavor Georgiev 3dc968cfe2 rename wireup 2016-10-11 00:45:01 +02:00
Yavor Georgiev 74d385141a refactor Realm constructor wireup 2016-10-10 16:17:05 +02:00
Yavor Georgiev 0ff7357cc3 Build for node without sync 2016-10-10 14:20:33 +02:00
Ari Lazier 9d0df0de3d Sync and fine grained notifications 2016-10-04 15:07:14 -07:00
Yavor Georgiev 33eb3fe06f Make Collection prototype methods configurable and writable (#592)
* Make Collection prototype methods configurable and writable

* Make `Realm.Types` re-definable
2016-09-09 01:33:42 +03:00
Yavor Georgiev fb7911e3fa add support for the jest runner’s node environment 2016-08-10 15:50:37 +02:00
Marius Rackwitz 48b106e610 Check if there is a global console to silent eslint 2016-08-04 10:12:16 -07:00
Marius Rackwitz 7755e7030b Warn when Realm.Types is still used 2016-08-04 10:10:28 -07:00
Scott Kyle 717d6781a1 Add support for debugging in Visual Studio Code
Since Code runs in Node, rather than Chrome, we need to require the `sync-request` module. The global `__debug__` object was exposed by the vscode-react-native plugin v0.1.5 for us to be able to do that.

Resolves #374
2016-06-29 16:02:50 -07:00
Scott Kyle 5b9fbbb0ac Remove unnecessary cross-Realm check in rpc
This was causing the new failure in Chrome debug mode in the `testLinkTypesPropertySetters` test.
2016-06-14 16:58:05 -07:00
Scott Kyle 3307bf0a26 Fix for changed error message 2016-06-14 16:57:39 -07:00
Scott Kyle cdcb99a502 Improvements from PR feedback 2016-06-09 13:07:05 -07:00
Scott Kyle cd0bb079b7 Implement objectForPrimaryKey() method
Resolves #328
2016-06-03 16:51:32 -07:00
Ari Lazier 9c7292acff chrome debug and and react native fixes 2016-05-19 13:27:36 -07:00
Ari Lazier e7b341dfdb merge latest from master 2016-05-13 15:05:19 -07:00
Ari Lazier 9c1b923797 fixes for test app 2016-05-13 13:05:39 -07:00
Scott Kyle d4b7a6bed3 Update RPC layer for changing constructors
This is very important for hot module reloading.
2016-05-06 15:42:17 -07:00
Scott Kyle e8cd20d7bb Use RPC callback mechanism for writes and listeners
The callbacks are stored by their id in the RPCServer so they are properly uniqued. This prevents the same callback from being added multiple times as a change listener.
2016-05-02 12:41:53 -07:00
Scott Kyle 32a8a2ed72 Make migration tests work in Chrome debug mode
All realm operations for the RPC are now done in their own thread so it can be allowed to block on waiting for callback results. The recursive and multi-threaded nature of this makes it pretty tricky, but it works!
2016-04-29 13:55:49 -07:00
Scott Kyle 950b75fd2f Fix broken testResultsInvalidation test on Chrome
We needed more actions to actually get sent over the RPC.
2016-04-29 11:16:21 -07:00
Scott Kyle 85919dc66f Fix realm.schema property in Chrome debug mode 2016-04-29 11:16:10 -07:00
Ari Lazier 2b35360117 add readOnly property 2016-04-28 15:50:43 -07:00
Scott Kyle df14c7760d Fix Realm.Object in Chrome debug mode 2016-04-26 17:33:33 -07:00
Ari Lazier 785e57eb47 another fix for chrome debug mode 2016-04-26 17:08:00 -07:00
Ari Lazier 591dce8051 one fix for chrome debug mode 2016-04-26 16:53:50 -07:00
Ari Lazier b59784670b create RealmObject class and make isValid a member 2016-04-26 16:30:04 -07:00
Ari Lazier 3509caedd5 bugfix for empty results, fix for realm.isValid 2016-04-19 17:29:34 -07:00
Scott Kyle 275334fa7e Remove definition of Realm.Types from browser shim
It's added in the top-level index.js file
2016-04-19 03:24:15 -07:00
Scott Kyle a05f7e2261 Fix some eslint errors 2016-04-19 01:38:46 -07:00
Scott Kyle 73cfca7d81 Fix for failing React Native test on iOS 2016-04-18 16:06:59 -07:00
Scott Kyle 133289ad85 All tests now pass on Node 2016-04-15 16:06:44 -07:00
Scott Kyle 0e74362e4c Merge pull request #340 from realm/sk-collection
Make List and Results inherit from Collection
2016-03-21 15:27:18 -07:00
Scott Kyle 83e09268ea Rename array-methods.js to collection-methods.js 2016-03-21 15:00:00 -07:00
Ari Lazier 836cfc1c6b add chrome debugging, use -1 for not versioned 2016-03-21 13:34:12 -07:00
Scott Kyle 8c66bab8aa Make collection iterators actually iterable
The ES6 spec calls for this so these iterators are usable in for-of loops, with spread operators, etc.
2016-03-20 11:51:16 -07:00
Scott Kyle b5ce02c0ce Make List and Results inherit from Collection
This will allow for easier type checking, documentation, etc.
2016-03-20 11:51:16 -07:00
Scott Kyle 27073a9e66 Properly configure ESLint for syntax checking
Added a test case to run on CI as well.
2016-03-16 13:01:38 -07:00
Scott Kyle 1e652d9f2a Merge pull request #292 from realm/sk-debug-on-device
Use device IP addresses to connect to RPC host
2016-03-16 12:51:24 -07:00
Scott Kyle 8d73a8e985 Simplify setting up Chrome debugging sessionHost 2016-03-16 09:28:18 -07:00
Ari Lazier aa08d25ed0 Merge pull request #305 from realm/al-object-store
Latest object store changes and core
2016-03-10 16:03:12 -08:00
Scott Kyle d39d437bfe Fix for failing test with Chrome debugging
A new error popped up ("LinkView is not attached") which required a more generalized check.
2016-03-09 15:23:58 -08:00
Scott Kyle 1a127b425b Merge pull request #289 from realm/sk-accept-constructor
Accept constructor in create() and objects() methods
2016-03-07 12:23:26 -08:00
Scott Kyle 37b2c35169 Add Symbol.iterator method to List and Results
Resolves #235
2016-03-02 23:00:53 -08:00
Scott Kyle 1cba02c34d Fix broken iterator methods on Android
Turns out the JSC included with React Native on Android includes a buggy implementation of ArrayIterator that is missing an exposed next() method, so we implement it ourselves instead.
2016-03-02 22:57:36 -08:00
Scott Kyle 00b19d95b8 Use device IP addresses to connect to RPC host
It still only tries localhost for the simulator, but for devices, we now get a list of possible IP addresses to attempt to connect to before throw a more helpful exception.

Resolves #284 and fixes #276
2016-03-01 00:56:45 -08:00
Scott Kyle 4a81b091cb Accept constructor in create() and objects() methods
This will help the linter prevent spelling mistakes and make some code more easily readable.

Resolves #233
2016-03-01 00:46:03 -08:00
Scott Kyle ad24673776 Rename util.createList to createCollection
Sounds more generic this way.
2016-02-29 12:34:29 -08:00
Scott Kyle 4ea2e729b4 Support many Array methods on List and Results
Resolves #18
2016-02-29 03:24:58 -08:00
Scott Kyle 236d0a5eed Ensure List and Results constructors throw exception
This was already done from native code, but needed to happen for the browser shim and be tested.
2016-02-29 03:24:58 -08:00
Scott Kyle b1f656a252 Convert browser module to use ES6 modules 2016-02-29 03:24:58 -08:00
Scott Kyle 44a29d8dd4 Expose List and Results constructors into JS 2016-02-29 03:24:58 -08:00
Scott Kyle 97e6166597 Move browser JS shim under its own directory 2016-02-29 03:24:58 -08:00
Tim Anglade 7cc2f69736 Merge pull request #264 from realm/km-js-fixlicense
License update
2016-02-21 18:56:59 -08:00
Scott Kyle 2e3a3b5db8 Merge pull request #257 from realm/sk-schema-prop
The schema property should be directly on constructor
2016-02-18 16:27:47 -08:00
Karson Miller 5e9333b699 no message 2016-02-18 15:30:44 -08:00
Scott Kyle 5332131c14 Add sorted() method to List 2016-02-18 13:41:11 -08:00
Scott Kyle 05d84b23a2 Change sortedBy API as discussed
If provided an array, then each member can optionally be an array of [propName, reverse]
2016-02-18 12:47:18 -08:00
Scott Kyle 249bcd8f3f Change sortByProperty to return new Results
The method name changed to sortedBy to reflect that it returns a new Results object and to be more succinct. Also, the second optional argument instead reflects descending (or rather, reverse) since it's an anti-pattern to have an optional argument default to true in JS, and this also follows precedences set by other JS libraries and by Python's sorted function.
2016-02-18 11:58:39 -08:00
Scott Kyle b34e52b290 The schema property should be directly on constructor
The constructor is now also called with `this` set as the constructed object.

Fixes #232
2016-02-18 11:10:02 -08:00
Ari Lazier 6374a04ed4 chrome support for filtered 2016-02-17 20:27:10 -08:00
Scott Kyle 3e1889d342 Merge branch 'master' into sk-listview-merge
* master: (207 commits)
  Convert to using new React Native MainActivity template
  Create RealmReactPackage for our Android plugin
  Fix doc for Android
  NPM ignore react-native/android folder
  Skip building Android module under Xcode
  Skip building Android module for iOS tests
  gitignore Android downloads folder
  Update README with instructions to run on Android
  Use un-patched RN for Android by installing hook into JSC
  cleanup build system
  Use Realm in node_modules for ReactTests on Android
  Change Demo => ReactTests
  adding a 'publishAndroid' task to generate the AAR with prebuilt .so files
  Adjust POM_NAME
  Use consistent package naming
  Remove old Demo files
  Add copyright to JNI file
  Cleanup platform.hpp
  Make our Android module buildable as a dependency
  Add `npm test` command
  ...
2016-02-15 14:49:31 -08:00
Scott Kyle a6715d210d Ignore more things when publishing with NPM
Unfortunately some kind of NPM bug is making it ignore a top-level .npmignore file.
2016-01-22 16:43:53 -08:00
Scott Kyle eb4ac0000b Efficient React ListView for Realm collections
This component is fully backwards compatible with the original React ListView, but is compatible with Realm Results and List objects to use their snapshot functionality along with more efficiently checking if each row should update.
2016-01-21 11:41:38 -08:00
Scott Kyle bc77077b13 Merge branch 'sk-schema-api'
* sk-schema-api:
  Improve clarity of schema parsing and serialization
  Add test that checks schema validation
  Update README with new Schema API
  Cleanup some code and comments to make it consistent
  Convert tests to create objects with property objects
  Update example apps with new schema API
  Remove confusion between propTypes and objectTypes
  Simplify object schema info returned from RPC
  RPC now keeps object keys in the same order
  Change schema API to take properties as an object
  Add method to clear mutation listeners in RPC client
  Plug small leak from not releasing a JSStringRef
  Make RJSStringForValue use consistent exception style
  Improve error messages inside RJSUtil
2016-01-14 15:13:33 -08:00
Scott Kyle 7202994482 Add comments to explain checking for userAgent 2016-01-08 15:54:30 -08:00
Scott Kyle 334e646d7b Error message when RealmReact framework is missing
Fixes #190
2016-01-07 15:18:27 -08:00
Scott Kyle 15052985f1 Remove confusion between propTypes and objectTypes
The RPC layer now only speaks in objectTypes, since they don't always equate to propTypes. We were overloading the use of propTypes for no good purpose.
2016-01-05 13:53:54 -08:00
Scott Kyle 36ffc6c77c Simplify object schema info returned from RPC
Only the property names are needed.
2016-01-05 13:40:57 -08:00
Scott Kyle c928ab716e RPC now keeps object keys in the same order
Maintaining insertion order when passing objects through the RPC is essential to make the new schema API work.
2016-01-05 13:40:57 -08:00
Scott Kyle 358e5dacf3 Add method to clear mutation listeners in RPC client 2016-01-05 13:40:53 -08:00
Scott Kyle 381dbbe7ba Merge branch 'sk-npm'
* sk-npm:
  Add ability to publish NPM module to git
  Move RealmJS.mm to correct location
2016-01-05 13:25:20 -08:00
Scott Kyle 632f9d737e Add methods to create snapshot of List and Results
The Results class was updated to match the style of List and include a flag (m_live) that determines if it should sync updates. If an object in the static Results is deleted, then it will return null.
2015-12-30 16:53:26 -08:00
Scott Kyle 3da6b54df6 Add ability to publish NPM module to git
The top-level package.json explicitly includes the directories it needs (vendor/.npmignore cuts down the cruft). The publish-beta.sh script essentially uses `npm pack` to package up the NPM module and then push it into an orphaned `beta` branch.
2015-12-28 22:01:17 -08:00
Scott Kyle 4109c86343 Make Realm object properties enumerable 2015-12-08 03:26:57 -08:00
Scott Kyle be0c2a91ea Fix RPC client error after deleting objects
Specifically for objects with lists, since the mutation listener would fire on a list that no longer is attached. If during the mutation listener that error is thrown, then the listener will be removed and the error will not be propagated.
2015-12-01 14:05:33 -08:00
Ari Lazier 55851f6d99 fix for rpc constants and other pr feedback 2015-11-18 17:55:30 -08:00
Scott Kyle 7b115a934b ArrayBufferView objects now fully supported
Previously we were not accounting for the byte offsets and misunderstood how the Uint8Array constructor worked. The tests now confirm everything works as expected with multiple different typed arrays and slices of the data.
2015-11-17 13:32:32 -08:00
Scott Kyle 616f78ea07 Add support for data properties in RPC layer
The data is base64 encoded before being sent via the RPC.
2015-11-17 13:32:31 -08:00
Scott Kyle 336ef55c1f Remove uses of for-of loops in RPC modules
The React Native packager does not transform for-of loops, and minification step uses UglifyJS, which does not yet support ES6 syntax.

Fixes #120
2015-11-05 16:10:52 -08:00
Scott Kyle 7df2997ee7 Use a Set to store listener callbacks in JS 2015-11-03 02:41:52 -08:00
Scott Kyle 0b35564830 Merge pull request #107 from realm/sk-live-update-fixes
Ensure Lists and Results live-update in Chrome
2015-10-28 10:46:43 -07:00
Scott Kyle 46bee3c867 Add beta licenses to Chrome JS modules 2015-10-28 10:37:17 -07:00
Scott Kyle 0eb3b49970 Ensure Lists and Results live-update in Chrome
Results needed to live-update during a transaction (not just as the end), and Lists needed to update on deletions as well.
2015-10-28 10:21:32 -07:00
Ari Lazier ec87281cc1 don't convert undefined to null in rpc requests 2015-10-27 12:13:57 -07:00
Ari Lazier a1c4cd5702 pr fixes 2015-10-27 07:48:11 -07:00
Ari Lazier 6f41c3cf68 take notification name 2015-10-26 19:18:24 -07:00
Ari Lazier bb68e45250 support notifications in chrome 2015-10-26 16:49:46 -07:00
Scott Kyle d55d42da8d Add ESLint config for JS test files
This helps the editor catch simple syntax issues before finding out about them when running a test.
2015-10-21 15:20:44 -07:00
Scott Kyle 2e592bc101 Sprinkle some const inside ES6 JS code
React Native 0.13.0 fixes the bug we experienced by using const.
2015-10-21 13:57:34 -07:00
Scott Kyle 725e9855fe Update RPC JS to use originalXMLHttpRequest
React Native now leaves the original object accessible when it "polyfills" objects. So we check for that, but still have the previous logic in place in case they change their minds.
2015-10-21 13:57:34 -07:00
Scott Kyle 0055d0510c Make List objects work with Object.keys in Chrome
Rather than using Object.preventExtensions to throw exceptions when setting any out-of-bounds index, we must instead compromise by only throwing for the common cases, which are -1 and list.length. Having Object.keys() support is essential for List to work with React Native ListViewDataSource.

Resolves #80
2015-10-21 13:11:41 -07:00
Scott Kyle 34b84759c8 Fix crash when reloading app during Chrome debugging
Added a session ID, that actually tracks the Realm constructor in our RPC server's JS context. This conveniently let us remove the special casing for defaultPath as well as letting us call the Realm constructor with JSObjectCallAsConstructor.

Fixes #68
2015-10-20 15:10:52 -07:00
Scott Kyle 01dc3a85d9 Add comment about usage of preventExtensions 2015-10-20 00:52:38 -07:00
Scott Kyle f2c4e7882a Make RPC lists non-extensible
Assigning to non-existent index will throw an exception and all tests pass in Chrome!
2015-10-19 17:43:51 -07:00
Scott Kyle 85e2a26b42 Make RPC Results objects auto-resize 2015-10-19 17:28:20 -07:00
Scott Kyle 3439b4c455 Add getter/setter for defaultPath to RPC 2015-10-19 16:59:04 -07:00
Scott Kyle 03751c35b4 Handle passing dates through RPC 2015-10-19 16:46:56 -07:00
Scott Kyle b07aa72a55 Move all constants into a single JS file 2015-10-19 16:19:43 -07:00
Scott Kyle 57778ce878 Improve calling object methods through RPC 2015-10-19 16:15:38 -07:00
Scott Kyle d172b43535 Add path and schemaVersion getters to realm object 2015-10-19 15:46:28 -07:00
Scott Kyle 1b7653206a Generalize getting/setting properties through RPC 2015-10-19 15:46:00 -07:00
Scott Kyle 4c0cc578d5 Generalize calling methods through the RPC 2015-10-19 12:46:31 -07:00
Scott Kyle d482ea82e7 Error messages deserve good grammar 2015-10-19 12:18:16 -07:00
Scott Kyle 5f52d07154 Add support for Results methods in Chrome
Which only consists of sortByProperty
2015-10-19 12:18:09 -07:00
Scott Kyle 78ec67cd6c Hacky support for adding notifications in Chrome
Since notifications are called synchronously after a write, we fake it by calling them manually for now. The future plan will be more involved, so some of that is stubbed out.
2015-10-19 12:09:14 -07:00
Scott Kyle b985e1f0a6 Add realm.close() method to JS shim
That was easy!
2015-10-19 12:07:50 -07:00
Scott Kyle 44eea1e036 Minor syntax improvements to JS shim 2015-10-19 12:07:50 -07:00
Ari Lazier 5ccc03eeb7 rename some methods for clarity - try to cleanup js objects 2015-10-15 18:48:13 -07:00
Ari Lazier eb598a2408 fix for in chrome 2015-10-15 17:07:10 -07:00
Scott Kyle 7a79ac8803 Make Xcode tests run in React environment
The deleteTestFiles() function is now added to the Realm object, so that it's easy for the RPC module to handle this as well. We can only do this in testing environments in the future.
2015-10-15 03:26:56 -07:00
Scott Kyle 94521b73bb Properly serialize args to create Realm through RPC
An exception was thrown when parsing the JSON when only a string was passed. This is better and no longer uses the Objective-C API for converting the dictionary to a JSValue.
2015-10-15 03:00:13 -07:00
Scott Kyle 22076933ad Fix "const" search and replace 2015-10-08 15:52:23 -07:00
Ari Lazier d9618a0e06 remove const, link test app with libRealmReact 2015-10-08 15:51:46 -07:00
Scott Kyle a997ec5be9 Some cleanup of JS 2015-10-08 15:32:14 -07:00
Scott Kyle 310e3d7a03 Don't store transient arrays returned by RPC 2015-10-08 15:31:29 -07:00
Ari Lazier 417f0a0c72 don't add Results to property types 2015-10-08 11:22:52 -06:00
Ari Lazier afa974ccc6 serialize Results like other types, use common method rpc call for objects() 2015-10-08 11:04:50 -06:00
Ari Lazier ed3cf01432 consolidate realm methods, code cleanup/remove some duplication 2015-10-08 10:43:38 -06:00
Scott Kyle 3c9fb1a323 Fix for setting properties through RPC 2015-10-08 02:00:10 -07:00
Scott Kyle ebb400ed41 Support delete and deleteAll from RPC 2015-10-08 01:53:22 -07:00
Scott Kyle 31fc14d602 Support (de)serialization of objects in RPC
Everything is a dictionary with either a `value` key or an `id` key. If it's a value, then it will recursively be (de)serialized.
2015-10-08 01:53:01 -07:00
Scott Kyle a9cac20f79 Rework lists to each have their own getters
This was necessary for them to each have their own enumerable properties. The React Native ListViewDataSource uses Object.keys() to the indexes.
2015-10-07 21:20:14 -07:00
Scott Kyle 141ce2cb6d Pass realmId for all calls to convert() in rpc.js 2015-10-07 18:40:09 -07:00
Scott Kyle 41ba3b62b8 JS implementation for Results from RPC 2015-10-07 17:08:31 -07:00
Scott Kyle f35d83a07d Account for overridden XMLHttpRequest in rpc module 2015-10-07 17:08:31 -07:00
Scott Kyle cb4fea97d4 Fix "const" search and replace 2015-10-07 17:08:31 -07:00
Ari Lazier 131123ff9a first end to end rpc call 2015-10-06 14:52:49 -06:00
Ari Lazier 476b3623bb partial rpc server implemenation 2015-10-06 13:36:56 -06:00
Scott Kyle bf1ecfbb07 Initial concept of JS for Chrome debugging
The idea is that we will have an NPM module that should always be required to use the Realm JS API. It will handle the underlying implementation details depending on which environment it is being run in (i.e. JavaScriptCore, Chrome, Node).

The focus here was on stubbing out the machinery required to get React Native Chrome debugging working with the Realm API by leveraging synchronous requests. The app itself will need to run a web server that responds to these requests.
2015-10-01 22:56:47 -07:00