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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@suman-kundu-wd/plugin-apex-enterprise-scaffold

v0.0.8

Published

This plugin helps to scaffold the apex enterprise pattern for an object with minimal structure of domain, selector, service classes.

Downloads

42

Readme

Salesforce Apex Enterprise Pattern Generator

Building apex trigger on SObject following FFLib enterprise pattern needs couple of classes like domain, selector, service, trigger and few interfaces. This plugin helps to scaffold those classes for an object with minimal code (without any logical part). When we have many objects' triggers to follow the enterprise pattern, it becomes a overhead to create the same structure for every object, and this plugin helps make that process efficient.

Install

$ sf plugins install @suman-kundu-wd/[email protected]

Command Syntax

sf apex-enterprise generate -o <value> -p <value> [--json] [-s y|n] [-e <value>] [-i <value>] [-t <value>] [-w <value>] [-f] [--json]

Flags

| Flag Name | Short Char | Required? | Details | | -------------------- | ---------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --object | -o | Yes | Please provide the object API name for which it will create the enterprise pattern structure. | | --plural | -p | Yes | Please provide the object plural form name which will be used in class’s naming format. Please don't use any space for multi-word name, instead use camel case. | | --save | -s | No | By default, it deploys the generated classes to org. To avoid deploying directly, you may choose 'n'. Valid options 'y' and 'n'. | | --api-version | -i | No | Please provide API Version like 57.0. Default takes the current version. | | --exclude | -e | No | If a user wants to skip component(s) from the structure, he/she may choose to use the component type under the exclude flag. Valid options 'trigger', 'service', 'implementation', 'selector', 'domain' & 'object'. If choosing multiple, use comma ',' as separator and don't use any space in between. | | --team-name | -t | No | If class naming convention should maintain team name in prefix/suffix, please provide team name here. Don't add underscore ('_') here. | | --team-name-position | -w | No | If class naming convention should maintain team name in prefix/suffix, please provide team name position here. Valid values are prefix and suffix. | | --overwrite | -f | No | When generated class or trigger name is already present in project drive, by default system doesn't overwrite. But if we choose overwrite option it will overwrite the existing content. | | --code-path | | No | If the default code content needs to be changed, prepare code md file downloading the original, and then pass the path of the file in this flag. Please don't change the key names in the md file. | | --json | | No | Standard SFDX flag to get response in JSON format. | | --help | -h | No | Standard SFDX flag to get the command details. |

Examples

  • Suppose we have a fresh new sobject or an existing sobject but doesn’t yet have any trigger, and we want to create a trigger following the enterprise pattern.:
$ sf apex-enterprise generate -o Custom_Price__c -p CustomPrices -i 55.0
  • Suppose we have an existing sobject which has a trigger already with non-enterprise structure, and we want to create a trigger following the enterprise pattern.:
$ sf apex-enterprise generate -o Opportunity -p Opportunities -s n -e trigger
  • Suppose we have a fresh new sobject and we want to create a trigger following the enterprise pattern. As there are multiple teams working on same Salesforce org, team uses team's naming convention for easy identification.:
$ sf apex-enterprise generate -o Custom_Price__c -p CustomPrices -t CLOSE -w suffix
  • Suppose we have an existing sobject having trigger and classes with old pattern. Now while executing this command, it may generate the same file name. By default, it doesn't overwrite, instead fails. To forcefully overwrite use below command with overwrite (-f) flag.:
$ sf apex-enterprise generate -o Custom_Price__c -p CustomPrices -f
  • Suppose the provided default codes do not match your expectation completely and need some change, then download the code.components.md file, update the content but don't change the keys and then provide the file path in the code-path flag.:
$ sf apex-enterprise generate -o Custom_Price__c -p CustomPrices --code-path /Users/suman.kundu/Desktop/code.components.md

Components Table

| Component Name | Type | Purpose | | -------------------------------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [Plural Input].trigger | Trigger | It calls the FFLIB SObject Domain class to initiate the trigger process. | | [Plural Input]TriggerHandler.cls | Apex Class | This is the domain class handles trigger events, validation, defaulting etc. | | [Plural Input].cls | Apex Class | This class helps to define methods or actions specific to the SObject. | | I[Plural Input].cls | Apex Class (Interface) | This is an interface, helps to maintain an object's methods or actions contract. | | [Plural Input]ServiceImpl.cls | Apex Class | This class holds all the core services provided on this object and their implementation logic. | | I[Plural Input]Service.cls | Apex Class (Interface) | This is an interface, helps to maintain an object's service implementation contract. | | [Plural Input]Service.cls | Apex Class | It can be considered as an API of object’s provided services to the external components like controller, other object services etc. | | [Plural Input]Selector.cls | Apex Class | This class maintains all the different queries of this object, so that it becomes better maintainable (as it’s centralized), makes it efficient (as in single transaction we can control to not get invoked multiple times). | | I[Plural Input]Selector.cls | Apex Class (Interface) | This is an interface, helps to maintain an object's selector methods’ contract. |

  • [Plural Input]: This is the same value that is provided in the plural (-p) flag in command.
  • In case of prefix team name provided, component name starts with '[Team-Name Input]_' like: [Team-Name Input]_[ComponentName].[extention].
  • In case of suffix team name provided, component name ends with '_[Team-Name Input]' like: [ComponentName]_[Team-Name Input].[extention]

Prerequisites

  • SFDX must be installed in the developer’s laptop with updated version.
  • FFLIB Apex Enterprise Library must be installed in the present organization before executing or deploying these generated enterprise classes.
  • Node is installed in the developer’s laptop.

Tooling