Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Refactor: The Great Refactor #414

Open
21 tasks
carsonfarmer opened this issue Jul 22, 2020 · 0 comments
Open
21 tasks

Refactor: The Great Refactor #414

carsonfarmer opened this issue Jul 22, 2020 · 0 comments
Assignees
Labels
dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation enhancement New feature or request Epic
Milestone

Comments

@carsonfarmer
Copy link
Member

carsonfarmer commented Jul 22, 2020

The Great Refactor

This is essentially a new Epic that describes a merging of Database, Store, and Client into a single, unified JS ThreadDB API.

Overview

The primary plan is to “shift” support for threads-database in favor of threads-client. This limits our API flexibility in some respects, but what we lose in control, we gain in accessibility and a more streamlined development focus. Additionally, we will deprecate threads-network-client and threads-network, which are low-level Threads protocol libraries. These were never really designed to be publicly consumed modules, so this isn’t likely to be a controversial move. Finally, threads-encoding will be moved to its own repo and maintained for demos and examples that want to build on Threads more directly. The primary change will be to marry threads-database and threads-store on top of threads-client, to provide an offline-first database with fast MongoDB style APIs and queries, and a Realm/MongoDB like local/remote sync interface.

Goals/Outcomes

The goals/outcomes of this refactor are to be able to provide a PouchDB + CouchDB style experience for developers that syncs data to remote peers that can then serve said data over decentralized protocols. Something like, “the dynamic database that syncs to IPFS”. Another analogy would be MongoDB + Realm, where you have a free, mobile/browser database that syncs with a remote MongoDB service. The resultant library be familiar to anyone who has built an application using something like Realm, Pouch, or Mongo. The difference here is everything is available over decentralized protocols such as PubSub/GossipPub, IPFS, IPNS, HTTP gateways, and more.

Roadmap

  • Migration
    • Drop threads-network-client and threads-network
    • Move threads-encoding to its own repo (which already exists)
    • Consolidate and combine threads-database with threads-store
    • Import threads-client into threads-database as the primary networking/DB layer
    • Deprecate threads-client in favor of the new threads-database (which is now a nicely wrapped threads-client)
    • Update local (within repo/APIs) documentation to reflect these migrations
  • Local-first
    • Upgrade local-first behavior to support threads-client updates
    • Implement required remote sync API(s) in go-threads to support faster local caching
    • Update local (within repo/APIs) documentation to reflect these new features
  • P2P
    • Expose Pubsub updates at the database level
    • Expose APIs for accessing database collections and entities directly from the JS clients
    • Return IPFS CIDs for all database updates (rather than Instance IDs alone)
    • Update local (within repo/APIs) documentation to reflect these new features
  • DX
    • Refocus primary developer entry-point to js-hub (this is mostly already done)
    • Move from current low level auth access to higher-level, token-based, browser-first implementation. For NodeJS applications, the low-level APIs will remain, or they can utilize a compatibility layer for cookie/header management.
    • Update local (within repo/APIs) documentation to reflect these changes
  • Documentation - All of the above will require major documentation updates
    • Update README of js-threads to clearly state primary goals/functionality of the updated library
    • Additional information on Threads inner-workings should be directed to high-level white paper overview or Go Threads
    • Re-working of primary auth flow (now more "browser native") examples and demos
    • Port all existing Database demos to the new Database design (this is likely only the Chat demo)
    • Refocus primary JS client focus to Buckets where appropriate
@carsonfarmer carsonfarmer added documentation Improvements or additions to documentation enhancement New feature or request Epic dependencies Pull requests that update a dependency file labels Jul 22, 2020
@carsonfarmer carsonfarmer self-assigned this Jul 22, 2020
@carsonfarmer carsonfarmer added this to the Sprint 44 milestone Jul 23, 2020
@carsonfarmer carsonfarmer changed the title Refactor: Merge Database, Store, and Client to create a single Database API Refactor: The Great Refactor Jul 27, 2020
andrewxhill added a commit to textileio/js-textile that referenced this issue Aug 6, 2020
Changelog
========

* Major release includes public Key based inboxing!!!
* Improved API authentication, authorization, scoping methods.
* Migrates from default identity Typescript types to more robust interfaces with encrypt and decrypt methods.
* Improved API response types, docs, organization.

Users
=========

Entirely new API client that consolidates User APIs and includes newly released inboxing methods. 
Use these new APIs to send encrypted direct messages between your app users based only on ed2559 public key.

* `listThreads` and `getThreads` moved to Users API class
* `setupMailbox`, `sendMessage`, `listInboxMessages`, `listSentboxMessages`, `deleteInboxMessage`, etc.
* subscription methods for inbox and sentbox
* Read more here:

Buckets
===========

Updated API client class methods with improved response types.

* Replaces all `AsObject` response types with named response types.
* Adds `copyAuth` method for sharing authentication setup between Buckets and Users API client classes
* Updates `listPath` method to walk tree.
* Adds `listPathFlat` method to return a flat list of files & directories in a Bucket.
* Read more here:


Threads
==================

* Updated `listen` response format includes action type and id.
* Deprecates `listThreads` and `getThread` from the Threads Client class, now available in `Users` and to be removed from `Client` at a future date.
* Removes `Database` class from `@textile/hub` as per textileio/js-threads#414

Crypto Library
==============

Provides a new set of crypto functions available through `@textile/hub`. Projects can now migrate from Libp2pcrypto identities to TweetNacl with backward compatibility.

* Better `encrypt` and `decrypt` support based on PrivateKey and PublicKey identities.
* Read more here:


Docs
====

* Improved and added many more examples
* Added new Users class & crypto methods.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation enhancement New feature or request Epic
Projects
None yet
Development

No branches or pull requests

1 participant