npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

entropic-bond

v1.53.9

Published

Tidy up your messy components

Downloads

109

Readme

Entropic Bond

Tidy up your messy components

Entropic Bond helps your TypeScript software development, both in the frontend and the backend. It is composed by several abstractions that make your code fully decoupled from the database, authorization service or cloud storage provider yet easy to use. In addition, it offers an observer based architecture to intercommunicate your business logic entities efficiently.

Who needs to focus on a unique backend provider

Entropic Bond is designed with the serverless and NoSQL models in mind. This doesn't mean you cannot use it in such scenarios. Moreover, it is an excellent tool to develop Functions as a Service (FaaS). With Entropic Bond, you just forget about those implementation details. You only need to focus on developing your domain model.

Who needs a global state

Entropic Bond removes the need to maintain a global state. The underlying architecture is designed in a way that the state is maintained at entity level and the relationship between the entities is provided by a notification infrastructure.

How to use

Typically, you will derive all your business logic entities from the EntropicComponent class. This class provides two main functionalities; persistence and observability.

API

You can find the API documentation here.

Persistence

The persistence mechanism allows defining which entities and which properties of those entities should be stored in the database. To make an entity persistent, it should derive from the EntropicComponent class or the Persistent class.

In order to allow the persistence mechanism to automatically instantiate entities from the database, you should use the @registerPersistentClass decorator passing the class name as a parameter.

The properties or attributes that you want to be streamed should be preceded by the @persistent decorator in the attribute declaration. The property name must be private and prefixed with an underscore (_). Access to the public attributes should be done by the use of accessors.

@registerPersistentClass( 'MyEntity' )
class MyEntity extends EntropicBond {
	@persistent private _persistentProp1: string
	@persistent private _persistentProp2: boolean
	@persistent private _persistentProp3: AnotherPersistentObject
	@persistent private _persistentProp4: number[]

	private _nonPersistentProp: unknown
	
	// accessors go here ...
}

Storing and querying the persistent entities

The database abstraction is provided by the Store object. To learn how to set up a concrete database, see below.

The Store.getModel method will return an object with methods to access the database.

let foundEntity: MyEntity
const myEntity = new MyEntity()
const entityModel = Store.getModel<MyEntity>( 'MyEntity' )

// fill myEntity object with data here ...

await entityModel.save( myEntity )		// saves myEntity in the database

foundEntity = await entityModel.findById( '0340d-349ab' ) // retrieves from database

foundEntity = await entityModel.find().
									.where( 'persistentProp1', '==', 'foo' )
									.where( 'persistentProp2', '==', true )
									.limit( 10 )
									.orderBy( 'persistentProp1', 'desc' )
									.get()														// retrieves from database

entityModel.delete( '0340d-349ab' )									// deletes from database

Set up the database access

The database access is encapsulated in a DataSource object. A concrete implementation of a JSON DataSource is provided as JsonDataSource. You can use this implementation for testing purposes.

Currently, there is an official plugin to connect to a Firebase Firestore database. To install the plugin, run:

npm i entropic-bond-firebase

You can develop new plugins following the plugin developer's section.

You should instantiate the concrete implementation of the DataSource and pass it to the useDataSource method of the Store object.

Store.useDataSource( new JsonDataSource() )

Observability

Auth