Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional validation for operations + shallow copies when applying operations #19

Closed
wants to merge 10 commits into from

Conversation

ryanwe
Copy link

@ryanwe ryanwe commented Jul 12, 2016

This library is awesome and has been super helpful! In the course of using it, we found it helpful to add some validation to ensure that the operations being submitted are valid and fail fast. This means validating that the ld or od object is actually the expected object being deleted, range checks for l* operations, and that oi operations include od when they are overwriting/deleting an existing object.

This PR also includes a change to clone the entire operation instead of rebuilding it from scratch. We found places where attaching additional properties to an operation was helpful, and we want to maintain those properties after transforming the operations.

We use webpack (and sometimes browserify) to include this library on the client side and are able to require('assert') but if that doesn't work, I can add a custom assert.deepEqual() function to the code.

If this is considered a breaking change (due to the new errors and assertions), I can bump the version number too.

Like I said, this library has been great to work with and I'm happy to contribute back. Let me know if these changes look good or if they require additional modification.

Thanks!

Ryan Weingast added 9 commits February 1, 2016 10:17
By default, splice does no bounds checking and leads to null entries and undesired data. Adding additional validation here also helps detect divergence and sync errors before the local operations have been applied and sent to the server.
There are times when it is convenient and useful to attach "metadata" like properties
to operation components. The validity of this data is independent of transformation so
we would like to maintain that data regardless of transformation.
validate proper 'od' and 'ld' when replacing or deleting to ensure nothing is inadvertently lost.
- This is similar to the ImmutableJS pattern and makes json0.appy more React-friendly
- No noticeable performance changes
- allows for better object reference equality checks
@ryanwe ryanwe force-pushed the master branch 3 times, most recently from 0d7b3e4 to abd235a Compare January 10, 2017 13:01
@ryanwe
Copy link
Author

ryanwe commented Jan 10, 2017

Cool. Tests are passing which also means better node and browser compatibility. 👍

@ryanwe ryanwe changed the title Additional validation for operations Additional validation for operations + shallow copies when applying operations Jan 10, 2017
@alecgibson
Copy link
Contributor

alecgibson commented Jul 12, 2018

@josephg what's happening with this PR? I think these checks are hugely valuable.

@josephg
Copy link
Member

josephg commented Jul 14, 2018

Wow; there is a lot of great stuff here. I wish I merged a lot of this ages ago - my focus has been on newer, green-fields stuff. For what its worth, I agree that require('assert') is probably fine these days since just about everyone uses browserify / webpack / rollup / etc.

I'm not going to take this PR for two reasons:

  • Its too big (there's too many changes here)
  • None of the changes are tested by the test suite.

I'd love to merge most of this. But I'm going to close this issue as-is. Feel free to re-open individual PRs with the changes and we can talk about them. I know its a pain. I'm sorry. But I don't want to blindly take responsibility for this code as-is.

Going forward it'd be nice to get some more committers direct access to this repo. Once I merge a few commits I'll be happy to just give you commit access and you can do the rest yourself

@josephg josephg closed this Jul 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants