Firebase Bolt Compiler

raw JSON →
1.2.9 verified Fri May 01 auth: no javascript maintenance

Compiles Firebase Bolt schema definitions (from firebase-bolt) into TypeScript interfaces, Flow types, and other code artifacts. Current stable version is 1.2.9, last released in September 2017. This package is a TypeScript rewrite of firebase-bolt-transpiler, using the same AST types as the original firebase-bolt package. It is primarily a CLI tool that reads .bolt files and outputs TypeScript or Flow type definitions. Key differentiators: generates path helper functions (since v1.2.0), handles null explicitly, and provides stricter typing compared to the original transpiler. No active development since 2017.

error TypeError: compile is not a function
cause Using default import when the package only exports named exports.
fix
Use named import: import { compile } from 'firebase-bolt-compiler';
error Cannot find module 'firebase-bolt'
cause Missing peer dependency firebase-bolt.
fix
Install firebase-bolt: npm install firebase-bolt
error firebase-bolt-compiler: command not found
cause Global installation missing or not in PATH.
fix
Install globally: npm install -g firebase-bolt-compiler, or use npx: npx firebase-bolt-compiler
error Error: Could not parse bolt file: Unexpected token
cause Invalid Bolt syntax in input file.
fix
Validate the .bolt file using firebase-bolt's validator or check the Bolt language specification.
deprecated Package has not been updated since 2017 and may not work with newer Firebase products (Firestore, etc.).
fix Consider migrating to Firebase's official Security Rules tools or use firebase-bolt directly.
gotcha The compile function expects the full Bolt source, not just a file path. It does not handle file I/O; the CLI does that.
fix Read the file contents separately before passing to compile().
breaking Before v1.2.0, TypeScript generation did not include path helper functions. Code relying on path helpers may break if upgrading from <1.2.0.
fix Upgrade to v1.2.0+ and update generated type imports to include path functions.
gotcha The CLI output goes to stdout; there is no --output flag. Redirect to file manually.
fix Use shell redirection: firebase-bolt-compiler < input.bolt > output.ts
npm install firebase-bolt-compiler
yarn add firebase-bolt-compiler
pnpm add firebase-bolt-compiler

Compiles a Bolt schema string to TypeScript interfaces using the programmatic API.

// install: yarn add firebase-bolt-compiler firebase-bolt
import { readFileSync } from 'fs';
import { compile, generateTypeScript } from 'firebase-bolt-compiler';

const boltContent = `
path /users/{uid} is Users {
  read() { true }
  write() { isCurrentUser(uid) }
}
type Users extends User[] {}
type User {
  firstName: String;
  lastName: String;
}
`;

const ast = compile(boltContent);
const tsOutput = generateTypeScript(ast);
console.log(tsOutput);
// Outputs:
// type Users = { [key: string]: User };
// export interface User {
//     firstName: string;
//     lastName: string;
// }