smocker-concretio
v1.0.18
Published
This SFDX plugin generates relastic data for salesforce using mockaroo API. Easily create customized datasets for any Salesforce object. helping streamline development and testing with accurate, varied data
Downloads
112
Maintainers
Readme
Smocker (v1.0.0)
A Salesforce CLI Plugin to Simplify Synthetic Data Generation
Overview
Smocker is a lightweight yet powerful Salesforce CLI plugin that allows users to generate synthetic data quickly and easily. This tool is specifically designed to streamline the creation of realistic, customizable test data while ensuring compatibility with complex Salesforce schemas and industry-specific requirements.
Key Challenges solved
Smocker addresses critical challenges faced by Saleforce Professionals in managing and generating mock data for their environments. Here are the key pain points Smocker solves:
- Privacy and Compliance: Avoids the use of real customer data, ensuring GDPR and CCPA compliance by generating synthetic, privacy-safe test data.
- Time-Consuming Data Creation: Automates the generation of complex, relationship-driven Salesforce data, saving time and reducing manual effort.
- Salesforce Schema Complexity: Handles Salesforce’s complex schema, including custom objects and relationships, ensuring accurate data generation.
- Customization and Flexibility: Provides advanced customization options for field exclusions, record counts, and language preferences, tailored to specific business needs.
Installation
Prerequisites
- Salesforce CLI
- Node.js (v18.0.0 or later)
- Mockaroo API Key
Commands
- Install:
sf plugins install smocker-concretio
- Update:
sf plugins update
Directory Structure
The following directories are created(if doesn't already exist) on current working directory when using Smocker:
- data_gen
- templates: Stores data templates for test data generation.
- output: Contains generated data and record insertion details.
Environment Variables
Smocker relies on these environment variables:
SALESFORCE_USERNAME="[email protected]"
SALESFORCE_SECURITY_TOKEN="your_security_token"
SALESFORCE_PASSWORD="your_password"
MOCKAROO_API_KEY="your_mockaroo_api_key"
Obtain your Mockaroo API key from Mockaroo.
Template Structure
The sf template init
command generates a data template based on the values provided in the questionnaire.
{
"templateFileName": "default_data_template.json",
"namespaceToExclude": [],
"outputFormat": ["csv"],
"language": "en",
"count": 1,
"sObjects": [
{ "account": {} },
{ "contact": {} },
{
"lead": {
"fieldsToExclude": ["fax", "website"],
"language": "en",
"count": 5
}
}
]
}
Commands
Initialize Template: This command initializes a new data generation template. It sets up the required directory structure, prompts for a valid template file name, and collects configuration details for Salesforce objects (such as fields to exclude and record counts). The configuration is validated against org before it is saved to a JSON file.
sf template init [--default]
Watch this video for more detail.
Upsert Configurations: This command allows users to add or update configuration settings in an existing data template. Users can specify options like the Salesforce object, language, record count, fields to exclude, and other settings. If the object is not already present, the command will prompt users to add it.
sf template upsert -t <templateFileName> [-s <sObject>] [-l <languageCode>] [-c <recordCount>] [-x <namespaceToExclude>] [-f <outputFormat>] [-e <fieldsToExclude>]
Watch this video for more detail.
Remove Configurations: This command allows users to remove specific configurations from an existing data template. It can remove settings like record count, language, namespaces, output format, and fields to exclude.However record count and language cannot be removed globally, and at least one output format is required.
sf template remove -t <templateFileName> [-s <sObject>] [-l <languageCode>] [-c <recordCount>] [-x <namespaceToExclude>] [-f <outputFormat>] [-e <fieldsToExclude>]
Watch this video for more detail.
Validate Template: This command validates a data generation template file, ensuring that it is correctly configured for Salesforce. It checks the template for correctness, connects to Salesforce (using environment variables for credentials), and logs any warnings or errors found in the template's configuration. This step ensures that all objects, fields, and settings are properly defined before use.
sf template validate -t <templateFileName>
Watch this video for more detail.
Generate Data: The generate command reads a Salesforce data generation template and generates data based on the objects and settings defined within it. It also excludes the fields from the data template file that have been specified, ensuring that unwanted fields are omitted from the generated records. This command is designed to facilitate the creation of tailored datasets for Salesforce objects.
sf data generate -t <templateFileName>
Watch this video for more detail.
Print Template: This command retrieves and displays the contents of a specified Salesforce data generation template. It is useful for reviewing the configuration before using it to generate data.
sf template print -t <templateFileName>
Flags
| Flag | Short Hand | Flag Name | Description |
|----------------------|------------|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| --default
| | Default Template | Creates a default template. |
| --templateName
| -t
| Template Name | Specify the name of the data template to be utilized. The template must exist in the data_gen/templates
directory. |
| --count
| -c
| Count | Set the number of records to generate. If --sObject
or -o
is provided, this will only update or remove the count for that object. |
| --namespaceToExclude
| -x
| Namespace to Exclude | Exclude specific namespaces from generating record data for namespace fields. Multiple namespaces can be separated by commas. |
| --language
| -l
| Language | Select the language (en
or jp
). When --sObject
or -o
is specified, this updates or removes the language setting for that object. |
| --outputFormat
| -f
| Output Format | Define the output format(s) for generated data (e.g., CSV, JSON, DI). Multiple formats can be specified, separated by commas. |
| --sObject
| -s
| Specific Object | Target a specific object and override its existing settings. If not found in the template, an "add object" prompt will appear. |
| --fieldsToExclude
| -e
| Fields to Exclude | Exclude specific fields from test data generation for a given object. Applies only at the object level. |
Command Help
To access command help:
sf <template/data> <command> --help