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

cap-mock-generator

v1.0.11

Published

An interactive mock data generation engine for SAP CAP applications, leveraging the official @sap/cds-compiler by SAP for schema parsing.

Readme

CAP Mock Generator

npm version License: MIT

An advanced, interactive, and intelligent mock dataset generation engine built specifically for SAP Business Technology Platform (BTP) Cloud Application Programming Model (CAP) applications.

cap-mock-generator parses your native .cds schemas and populates your db/data/ folder with highly realistic, relationally consistent .csv mock files in seconds, using either a cutting-edge AI Smart Layer or a high-speed Local Fallback Engine.


Features

  • Interactive Onboarding Wizard: Powered by modern @inquirer/prompts, walking you seamlessly through configuration step-by-step.
  • Relational Data Integrity (Foreign Key Management): Automatically analyzes dependencies. It ensures child tables (e.g., entity relationships ending with ID) match valid, existing primary keys generated from parent tables.
  • Automatic Virtual Column Stripping: Cleanly filters out Association to many and Composition of many virtual elements so they never mess up your physical CSV deployment files.
  • Multi-Provider AI Data Layer: High-fidelity business mock data using either Google Gemini Pro (gemini-2.5-flash) or OpenAI (gpt-4o-mini) structured JSON responses.
  • Resilient Fallback Core: If your AI API tokens hit limit caps or encounter network spikes (503 Service Unavailable), the engine gracefully falls back to a lightning-fast local Faker.js cluster without crashing.
  • Clean Architectural Foundations: Designed around the Command-Service pattern for maximum scalability and maintainability.

Installation

You can install cap-mock-generator globally, locally as a development dependency, or invoke it instantly on-demand using npx.

1. Global Installation

Quickest access across any project workspace:

npm install -g cap-mock-generator

2. Local Installation

Recommended for engineering team standardization.

Install it directly as a development dependency inside your specific SAP CAP project root directory:

npm install cap-mock-generator --save-dev

Usage

Once installed, open your terminal, ensure you are in the root directory of your SAP CAP application where your package.json and db/ folder reside, and trigger the wizard using one of the strategies below.

Option A: On-The-Fly Execution

No installation required.

If you prefer to run the module directly without explicitly downloading it to your machine, use npx:

npx cap-mock-generator start

Option B: Global Command Line Execution

If you selected the global installation strategy earlier, simply ignite the interface by typing:

cap-mock-generator start

Option C: Configured Local Project Scripts

If you installed the generator locally, open your native package.json and map a clean entry shortcut helper to your internal scripts block:

{
  "scripts": {
    "mock:gen": "cap-mock-generator start"
  }
}

Now, any team member working on the repository can securely refresh testing data vectors by executing:

npm run mock:gen

Interactive Onboarding Flow

When you ignite the CLI wizard, it will guide you through the following prompts:

🌟 --- CAP Mock Generator Onboarding Wizard ---

? Enter your CDS schema filename inside the "db" directory: (schema.cds)
? How many mock records should be generated per Entity? (5)
? Do you want to enable the AI smart data layer engine? (Yes/No)
? Select your preferred AI Provider target: (Gemini (Google) / OpenAI (GPT))
? Provide your secret authorization API Key: ***********************

⚙️ Processing schema and initializing execution...
🔍 Analyzing model artifacts...

📦 Processing Entity: [sap.btp.assetmanagement.Plants]
🤖 Generating smart context data via Gemini...
✅ CSV successfully exported to: .../db/data/sap.btp.assetmanagement.Plants.csv

📦 Processing Entity: [sap.btp.assetmanagement.Assets]
🤖 Generating smart context data via Gemini...
✅ CSV successfully exported to: .../db/data/sap.btp.assetmanagement.Assets.csv

✨ Execution successfully completed! Check your db/data directory. 😎

Security & Environment Compliance

Your secret API credentials, such as GEMINI_API_KEY or OPENAI_API_KEY, are processed strictly inside your immediate shell execution context memory through process.env.

They are never saved to disk, logged to the console, or transported outside the official provider endpoint requests.


Relational Schema Topology

The generator intelligently tracks schema hierarchy. Take this complex manufacturing scenario:

entity Plants {
    key ID   : UUID;
    name     : String(100);
}

entity Assets {
    key ID      : UUID;
    plantID     : UUID; // Foreign Key referencing Plants
    name        : String(100);
}

License and Usage Notice

This library leverages the official @sap/cds-compiler package provided by SAP to parse CDS schema definitions for SAP CAP applications. It does not modify, bundle, or redistribute SAP source code beyond declaring @sap/cds-compiler as an npm dependency.

The @sap/cds-compiler package is provided under SAP's own license terms. Users of cap-mock-generator are responsible for reviewing and complying with the applicable SAP license terms when using this package in projects that depend on SAP CAP tooling.

Careful attention should be paid to licensing restrictions when integrating cap-mock-generator into commercial, enterprise, or redistributed software that includes SAP CAP dependencies.

cap-mock-generator itself is licensed under the MIT License. See the LICENSE file for details.