1.0.18 • Published 8 months ago

smocker-concretio v1.0.18

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

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

  1. Install:
    sf plugins install smocker-concretio
  2. 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="username@domain.com"
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

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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

FlagShort HandFlag NameDescription
--defaultDefault TemplateCreates a default template.
--templateName-tTemplate NameSpecify the name of the data template to be utilized. The template must exist in the data_gen/templates directory.
--count-cCountSet the number of records to generate. If --sObject or -o is provided, this will only update or remove the count for that object.
--namespaceToExclude-xNamespace to ExcludeExclude specific namespaces from generating record data for namespace fields. Multiple namespaces can be separated by commas.
--language-lLanguageSelect the language (en or jp). When --sObject or -o is specified, this updates or removes the language setting for that object.
--outputFormat-fOutput FormatDefine the output format(s) for generated data (e.g., CSV, JSON, DI). Multiple formats can be specified, separated by commas.
--sObject-sSpecific ObjectTarget a specific object and override its existing settings. If not found in the template, an "add object" prompt will appear.
--fieldsToExclude-eFields to ExcludeExclude 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

References

1.0.18

8 months ago

1.0.17

8 months ago

1.0.16

8 months ago

1.0.15

8 months ago

1.0.14

8 months ago

1.0.13

8 months ago

1.0.12

8 months ago

1.0.11

8 months ago

1.0.10

8 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago