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

@irontitan/doctor

v1.1.5

Published

Tool to operate @irontitan/paradox and help with controling time

Downloads

19

Readme

Doctor

build-status stability-unstable

Simple yet useful library to avoid manually manipulating event sourcing databases and paradox / tardis events and entities.

Installation

The recommended way to install doctor is through npm:

npm i -g @irontitan/doctor

Usage

Configuration file

Doctor works based on a configuration file that defines your applications, with its entities and repositories. Besides that, this file provides all the information doctor needs to connect to your database.

The default filename is doctor.config.js. The CLI will look for this file in the current working directory every time you invoke it, unless you pass the -f or --file flag. See global params

Structure

This is the minimum structure of a valid doctor configuration file:

const Person = require('path/to/your/event-entity/class')
const PersonRepository = require('path/to/your/event-repository/class')

module.exports = {
  mongodb: {
    uri: process.env.DATABASE_MONGODB_URI,
    dbName: process.env.DATABASE_MONGODB_DBNAME
  },
  entities: {
    person: {
      entity: Person,
      collection: 'people',
      repository: (mongodbConnection) => new PersonRepository(mongodbConnection)
    }
  }
}

Breaking it down:

  • mongodb
    • uri:
      • Type: String
      • Description: Mongodb URI (including connection schema)
      • Example: mongodb://localhost:27017
      • Required: true
    • dbName:
      • Tyoe: String
      • Description: Mongodb database name
      • Example: my-app
      • Required: true
  • entities
    • [entity-name] : String
      • entity:
        • Type: EventEntity
        • Description: Constructor of the entity class
        • Required: true
      • collection
        • Type: String
        • Description: Name of the collection for this entity
        • Required: true
      • repository:
        • Type: Function
        • Description: Function that receives a connection to mongodb and returns a specific EventRepository instance that will be used for all operations for this entity
        • example:
        • required: false

Important concepts

During following commands documentation, some concepts will be refered to. They are:

  • Entity: The name of an entity, as described on the config file
  • Entity id: The unique ID of a document of given entity
  • Event: The unique id of an event inside an events array, or an event name
  • Timestamp: A date and, optionally, time, in the format YYYY-MM-DD.HH:mm, as momentjs format tokens

Commands

All following commands are invoked the same way:

doctor <command> [params]

Global params

All commands (except by help) accept the following params:

  • -f, --file: Config file path. Overrides default ./doctor.config.js
  • -f, --verbose: Enables verbose output

help

doctor-help

Prints help about commands

Usage
doctor help [command]
Params

No params supported

reduce

doctor-reduce

Reduces the events of a given entity and returns its resulting state.

Usage
doctor reduce <entity> <entity-id> [--ignore <event>] [--until <timestamp>] [--save]
Params
  • -i, --ignore: Ignores given event. Can be repeated to ignore more than one event.
  • -u, --until: Ignores all events that happened after given timestamp. Takes precedence over --ignore.
  • -s, --save: Saves the result to the database. This will ask for your confirmation before making any changes.

All global params are supported

check

doctor-check

This command goes through you config file an tells you if it's ok and usable by doctor.

Usage
doctor check
Params

All global params are supported

diff

doctor-diff

This command calculates the time difference (in hours) between the first occurence of an event and the last occurence of another event.

Usage
doctor diff <entity> <entity-id> <first-event> <last-event>
Params

All global params are supported

entitites

doctor-entities

This command lists all entities described by the config file

Usage
doctor entities
Params

All global params are supported

rebuild

doctor-rebuild

This command reduces and updates the states of a whole collection

Usage
doctor rebuild <collection>
Params

All global params are supported


TODO

  • [ ] Write tests
  • [X] Add ability to reduce multiple entities and even collections at once
  • [ ] Add ability to use custom script to manipulate entities
  • [ ] Make mongodb connection not required
  • [ ] Improve documentation about custom repositories

Contributing

PRs are, as always, very welcome.

Just follow StandardJS, use pnpm, and make sure you code builds (pnpm run build) before submitting.