# @angstone/cement-truth

> Store Level Zero Of Cement Framework: an EventStore

Latest version **1.0.1** (published 2019-08-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @angstone/cement-truth
pnpm add @angstone/cement-truth
yarn add @angstone/cement-truth
bun add @angstone/cement-truth
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-08-14 |
| First published | 2019-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 39 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ssribeiro |
| Maintainers | ssribeiro |
| Keywords | cement, backend, eventstore, events, node |

## Links

- npm: https://www.npmjs.com/package/@angstone/cement-truth
- npm.io page: https://npm.io/package/@angstone/cement-truth

## Dependencies (6)

- [path](https://npm.io/package/path.md) ^0.12.7
- [level](https://npm.io/package/level.md) ^5.0.1
- [events](https://npm.io/package/events.md) ^3.0.0
- [rimraf](https://npm.io/package/rimraf.md) ^2.6.3
- [lexicographic-integer](https://npm.io/package/lexicographic-integer.md) ^1.1.0
- [@angstone/cement-basic](https://npm.io/package/@angstone/cement-basic.md) ^1.0.1

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-08-14
- 1.0.0 — 2019-08-13

## README

# The Cement Truth Module

Store Level Zero Of Cement Framework: an EventStore

## what is that?

It is an EventStore, called LEVEL ZERO store of the framework.

This is where, in last instance, the "truth" about the data is stored.

All other store levels can be built based on a safe backup of this.
They all are considered just an "image" of the data.

## install

```
npm install @angstone/cement-truth
```

## usage

```
import { signature } from '@angstone/cement-basic'
signature()

import { error, logger } from '@angstone/cement-basic'
import {
  AGENTS /*, ITruthModule, LeveldbTruthModule */,
  IEvent,
  IEventTrusted,
  ITruthObserver,
  TruthModule as truth,
} from '@angstone/cement-truth'

// you can use your own implementation
// but it already works with own implementation
// using leveldb

// truth.useTruthModule(YourOwnTruthModule) // YourOwnTruthModule must implements ITruthModule
// truth.useTruthModule(LeveldbTruthModule) // optional already set

// you can set the default path for leveldb folder storage
/*
truth.config({
    levelDbPath: './your/db'
})
*/

// indeed you can just use it like this:
const event: IEvent = {
  type: 'user signed up', // required
  agent: AGENTS.SYSTEM_DEVELOPER, // the user, the system, you, the developer REQUIRED
  payload: {
    // payload is optional
    username: 'john',
    password: '1234',
  },
}

// note on agent: You can define your own interface
// it is stored as json object. the provided IAgent
// only contains "name" field

truth.registerEvent(event).then(eventNumber => {
  logger.note(eventNumber)
})
// or inside async
// const eventNumber = await truth.registerEvent(event)

// so you retrieve this way:
const someAsyncFunc = async (eventNumber: number) => {
  const event: IEventTrusted = await truth.retrieveEvent(eventNumber)
}

// and of course, there is no static truth in this world so..
// the MAIN FUNCTION:

truth.retrieveAllEvents().then((truthObserver: ITruthObserver) => {
  truthObserver.eventStream$.on('event', (event: IEventTrusted) => {
    // do amazing stuff with the past events with the ones that are about to come
  })
  truthObserver.eventStream$.once('live', () => {
    // now you know that all past was read and the next ones are new in live!
  })
})
```

---
_Source: https://npm.io/package/@angstone/cement-truth · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
