cap-mock-generator
Parses the .cds schema and fills db/data with relationally consistent CSV — through an LLM layer where one is configured, or a local engine where none is.
Relational consistency is the claim that separates it from row-count generators: foreign keys line up, so the generated set is navigable rather than merely present. An interactive wizard walks the configuration.
Facts
Where it sits
Who is behind it
In the atlas: maintains 1, contributes to 1@xbergunmaintainer
What it declares
Every artifact
- Type
- Generator
- Origin
- Independently maintained
- Runtime
- build time
As a generator
- Generates
- does not say
- Run with
- Its own command
- Distributed through
- npm
Connections
CSV seed data generated from @Mockdata annotations with Faker
Getting realistic data into a service for development and demos
Download
Install
npm add cap-mock-generatorDerived from the package name. No recipe recorded; the README has the configuration.
README
quoted from xbergun/cap-mock-generator under MIT, readCAP Mock Generator
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 manyandComposition of manyvirtual 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.
History
Others providing
Compare all 6 on the Seed data page →- cap-js-mockdatacap-js-mockdataA cds add command that generates CSV seed files into db/data from @Mockdata annotations on your entities, filling each column with values from the Faker module the annotation names.independent, capCSV seed data generated from @Mockdata annotations with Faker
- @animb1996/cds-data-drift@animb1996/cds-data-driftCompares the CSV files under a CAP project's db/data with the rows in the database bound as its db service, and reports where the two have diverged without writing to either.independent, capCompares a CAP project's CSV data with its database rowsfrom CAP
- cap-js-mockdatacap-js-mockdataA cds add command that generates CSV seed files into db/data from @Mockdata annotations on your entities, filling each column with values from the Faker module the annotation names.independent, capCSV seed data generated from @Mockdata annotations with Fakerfrom CAP
- @sap/cds-common-content@sap/cds-common-contentISO-standard content for CAP's common definitions — countries, languages, currencies and timezones — so a project does not seed those tables itself.sap official, capISO content for CAP's countries, languages, currencies and timezonesfrom CAP
- @sap/cds@sap/cdsThe CAP Node.js runtime, which compiles the CDS model, serves the services declared in it, answers generic requests before any handler runs, and loads every cds-plugin.sap official, capCAP Node.js runtimefrom CAP
- abapFakerabapFakerGenerates fake data in ABAP, for bootstrapping a database, creating XML documents, stress-testing a persistence layer or anonymising data taken from a production service.independent, abapFake data generator for ABAPfrom ABAP
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
History in the atlas
- First seen.
For your agent
- Ref
artifact:xbergun-cap-mock-generator- JSON
- /artifacts/xbergun-cap-mock-generator.json
- MCP
- Connecting an agent