
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
yjs-normalized
Advanced tools
Yjs extension that offers generic maintainer and observer classes for normalized semi-structured data
This yjs extension offers generic maintainer and observer classes for normalized semi-structured data.
When dealing with nested or relational data in yjs applications, using a normalized state shape can be beneficial. This approach involves storing data in a flat structure similar to a database, which offers several benefits:
The concept is based on the section: normalizing state shape in the redux documentation.
Example structure:
{
"cells":{
"byId":{
"abc":{
"id":"abc"
},
},
"allIds":["abc"]
}
}
This library comes with 2 features: Maintainer and Observer
This class provides methods to add, delete, update, and manipulate objects within a Yjs Y.Map, ensuring that all changes are made within a transaction to maintain consistency.
Define a maintainer for a certain normalized table:
export default class CellsMaintainer extends Maintainer<ICell> {
}
Initialize the maintainer:
const cellsMaintainer = new CellsMaintainer(
ydoc.getMap('cells'),
ydoc.transact
);
Usage:
const cell: ICell = {...};
cellsMaintainer.changeObject(cell);
In general, observers facilitate the observation of semi-structured, normalized data within a Yjs Y.Map, track changes to the data and dispatch events accordingly.
The RootObserver class is an abstract class that primarily functions as a root data observer and secondarily acts as a registry for sub-observers that track more granular changes within the data.
The class defines several abstract dispatcher methods (rootDispatcher, addDispatcher, deleteDispatcher, updatePropertyDispatcher, and allIdsDispatcher) that subclasses must implement to handle various types of data updates. These methods enable dispatching events accordingly.
Sub-Observers are managed by the library itself. Following sub-observers are created / deleted and listened to during runtime:
allIds Y.ArraybyId Y.MapbyId Y.MapUsers can integrate this class with their preferred state management library (e.g., Redux, MobX).
export class CellsObserver extends RootObserver<ICell> {
protected rootDispatcher: (payload: RootDispatch<ICell>) => void = (payload) => {
//store.dispatch(setCells(payload))
}
protected addDispatcher: (payload: AddDispatch<ICell>) => void = (payload) => {
//store.dispatch(addCell(payload))
};
protected deleteDispatcher: (payload: DeleteDispatch) => void = (payload) => {
//store.dispatch(deleteCell(payload))
};
protected updatePropertyDispatcher: (payload: UpdatePropertyDispatch) => void = (payload) =>{
//store.dispatch(updateCellProperty(payload))
};
protected allIdsDispatcher: (payload: AllIdsDispatch) => void = (payload) => {
//store.dispatch(updateCellsAllIds(payload))
};
}
FAQs
Yjs extension that offers generic maintainer and observer classes for normalized semi-structured data
We found that yjs-normalized demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.