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 🙏

© 2026 – Pkg Stats / Ryan Hefner

firebase-rules-describe

v1.0.1

Published

Describe your Firebase rules in your native language and split the definitions in multiple files.

Downloads

14

Readme

firebase-rules-describe

Generate complex database.rules.json files with ease. With this package you can describe your Firebase rules in your native language and split the definitions in multiple files.

Basic usage

Install globally with npm install firebase-rules-describe -g

Create a file containing the definitions of your rules: database.definitions.json

{
  "rules": {
    "example": {
      ".read": "{Authenticated User}",
      ".write": "{User is Admin}",
      ".validate": "{Hello World}"
    }
  }
}

Create a file containing the specs for the definitions: database.specs.json

{
  "Authenticated User": "auth !== null",
  "User is Admin": "root.child('admins/' + auth.uid).val() === true",
  "Hello World": "newData.val() === 'Hello World'"
}

Run the following command to process these files into an output file:

firebase-rules-describe process database.definitions.json database.specs.json database.rules.json

These filenames are the defaults, so you can ommit them:

firebase-rules-describe process

Output will be a file: database.rules.json

{
  "rules": {
    "example": {
      ".read": "auth !== null",
      ".write": "root.child('admins/' + auth.uid).val() === true",
      ".validate": "newData.val() === 'Hello World'"
    }
  }
}

Features

Comments

Both in the definitions and spec files, you can include comments. These will not be included in the rules output file.

Definitions within Specs

You can create more complex Specs by including definitions in the Specs. For example consider the following Spec file:

{
  // Authentication
  "Admin": "root.child('admins/' + auth.uid).val() === true",
  
  // Posts
  "Post creator": "root.child('posts/' + $post_id + '/creator').val() === auth.uid",
  "Global editor": "auth.uid === 'global-editor'",
  "Post editor": "{Admin} || {Post creator} || {Global editor}"
}

This allows you to specify in your rules definitions, that any {Post editor} can write to a post. This includes the post creator, the admin and a global editor. Note that the $post_id wildcard variable is used in the spec in order to determine the post creator.

{
  "rules": {
    "posts": {
      // Rules for every Post
      "$post_id": {
        ".write": "{Post editor}"
      }
    }
  }
}

Split files

Your rules definitions file can be split in different files. Use [filename.json] to include a file at that location. Use the key at that location as the root key in the new file.

database.definitions.json

{
  "rules": {
    "posts": "[posts.json]",
    "users": "[users.json]"
  }
}

posts.json

{
  "posts": {
    "$post_id": {
      // Post rules
    }
  }
}

users.json

{
  "users": {
    "$user_id": {
      // User rules
    }
  }
}