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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@basemachina/bm-sql-inspector

v0.1.2

Published

A CLI tool to extract and filter MySQL and PostgreSQL actions from action_settings.json

Readme

bm-sql-inspector

SQL Action Inspector - A CLI tool to extract and analyze MySQL and PostgreSQL actions from action_settings.json

Overview

bm-sql-inspector is a TypeScript-based CLI tool that extracts MySQL and PostgreSQL actions from action_settings.json files and analyzes their SQL queries and parameters.

The action_settings.json file may contain multiple action types (mysql, postgresql, restapi, awss3, etc.), but this tool focuses exclusively on SQL-based actions (class="mysql" or class="postgresql"), simply skipping other action types.

Features

  • ✅ Extract MySQL and PostgreSQL actions
  • ✅ Extract parameter references from SQL statements ({{ parameter_name }} pattern)
  • ✅ Automatically extract table names and column names from SQL queries
  • ✅ Filter by multiple conditions (AND logic)
  • ✅ JSON output format

Installation

No Installation Required - Use with npx:

# Run directly without installing (once published to npm)
npx @basemachina/bm-sql-inspector --help
npx @basemachina/bm-sql-inspector --action-settings-file=action_settings.json

For Development:

# Clone the repository
git clone <repository-url>
cd bm-sql-inspector

# Install dependencies
npm install

# Build the project
npm run build

# Link globally for local testing
npm link

# Now you can test the command
bm-sql-inspector --help

Usage

Basic Usage

# Extract all SQL actions (default)
npx @basemachina/bm-sql-inspector

# Specify a file
npx @basemachina/bm-sql-inspector --action-settings-file=action_settings.json

Filtering

Filter by Datasource Type

# MySQL actions only
npx @basemachina/bm-sql-inspector --datasource-type=mysql

# PostgreSQL actions only
npx @basemachina/bm-sql-inspector --datasource-type=postgresql

Filter by Data Source Name

npx @basemachina/bm-sql-inspector --data-source-name=service-db

Filter by Table Name

npx @basemachina/bm-sql-inspector --table-name=users

Filter by Column Name

npx @basemachina/bm-sql-inspector --column-name=id

Multiple Filters (AND Condition)

npx @basemachina/bm-sql-inspector \
  --datasource-type=mysql \
  --table-name=products \
  --column-name=category

Display Help

npx @basemachina/bm-sql-inspector --help
# or
npx @basemachina/bm-sql-inspector -h

Options

| Option | Description | Default | |--------|-------------|---------| | --action-settings-file <path> | Path to action_settings.json file | ./action_settings.json | | --datasource-type <type> | Filter by datasource type (mysql or postgresql) | - | | --data-source-name <name> | Filter by data source name (resourceID) | - | | --table-name <name> | Filter by table name | - | | --column-name <name> | Filter by column name | - | | --help, -h | Display help message | - |

Output Format

Results are output in JSON format to stdout.

{
  "totalActions": 4,
  "totalSkipped": 1,
  "actions": [
    {
      "id": "test-mysql-001",
      "name": "Product Search",
      "class": "mysql",
      "resourceID": "resource-001",
      "statements": [
        {
          "statement": "SELECT * FROM products WHERE category = {{ category }} AND price >= {{ min_price }}",
          "method": "QUERY",
          "parametersUsed": ["category", "min_price"]
        }
      ],
      "parameters": [
        {"name": "category", "inputType": "TEXT"},
        {"name": "min_price", "inputType": "NUMBER"}
      ],
      "tablesUsed": ["products"],
      "columnsUsed": ["category", "price"]
    }
  ]
}

Development

Prerequisites

  • Node.js 18 or later
  • npm

Setup

# Install dependencies
npm install

# Link globally for development (no build required!)
npm link

# Now you can run the command directly
bm-sql-inspector --action-settings-file=test/fixtures/sample_actions.json

# Or use npm run dev
npm run dev -- --action-settings-file=test/fixtures/sample_actions.json

# Run tests
npm test

# Build TypeScript (optional, for distribution)
npm run build

Testing

This project is developed using Test-Driven Development (TDD) with Vitest.

# Run all tests
npm test

# Run specific test file
npm test -- types.test.ts

# Generate coverage report
npm test -- --coverage

Test Coverage:

  • Unit tests: 49 tests
  • Integration tests: 12 tests
  • E2E tests: 13 tests
  • Total: 74 tests

Project Structure

bm-sql-inspector/
├── src/
│   ├── types.ts              # Type definitions
│   ├── fileLoader.ts         # File loading
│   ├── sqlActionExtractor.ts # SQL extraction & filtering
│   ├── outputFormatter.ts    # Output formatting
│   ├── cli.ts                # CLI interface
│   ├── index.ts              # Entry point
│   ├── *.test.ts             # Unit tests
│   ├── integration.test.ts   # Integration tests
│   └── e2e.test.ts           # E2E tests
├── test/
│   └── fixtures/
│       └── sample_actions.json
├── dist/                     # Build output
├── package.json
├── tsconfig.json
└── vitest.config.ts

Publishing to npm

To make this package available via npx, publish it to npm:

# 1. Login to npm (first time only)
npm login

# 2. Update version in package.json
npm version patch  # or minor, or major

# 3. Publish to npm (runs build and tests automatically)
npm publish

After publishing, anyone can use it with:

npx @basemachina/bm-sql-inspector --action-settings-file=action_settings.json

License

MIT

Author

BaseMachina