share / share/sharedb

A specific version of ot-json0 is hardcoded as the basic type

Open
#284 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
6.5k
Forks
456
Avg merge
1d 5h
Merged PRs (30d)
5

Description

There's currently a bunch of experiments going on around adding presence to ot-json0. One of the things I've come across is that ShareDB currently has a hard dependency on the ot-json0 NPM package, meaning that if we want to replace it with another implementation, we need to also fork the ShareDB package, which is unfortunate.

Here's the code that errors out:

      if (types.map[message.type] !== types.defaultType) {
        err = new ShareDBError(4020, 'Invalid default type');
        return this.emit('error', err);

(lib/client/connection.js:198)

We can either remove that (I did, and it worked), or instead of this line in lib/types.js:

exports.defaultType = require('ot-json0').type;

we might think about letting the user (optionally) supply a default type when configuring ShareDB?

Currently I've just been looking at replacing the base ot-json0 implementation with a type that is almost identical, just with added presence. However, I don't actually know enough about the requirements for a defaultType - does there have to be one? Does it just need to "exist" or to implement a certain interface (beyond the general OT interface)? Could I specify "ot-text" as a default type?

Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the defaultType assignment in lib/types.js and the validation at lib/client/connection.js:198. Review how ShareDB types are configured and determine the requirements for a replaceable default type. Done should define and document the supported configuration behavior, including whether a custom implementation such as ot-text is valid, with coverage for the validation path.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.