simply-aep-core
Apex Enterprise Patterns (fflib, force-di, AT4DX) binding scan and resolution logic. Full signatures and types are in the API reference.
npm install @simplysf/simply-aep-coreEvery example below assumes an authenticated @salesforce/core-style connection where relevant — see
Get Started.
Scanning local force-app source for AT4DX bindings
Section titled “Scanning local force-app source for AT4DX bindings”scanLocalBindings reads AT4DXBinding__mdt/AT4DXDomainProcessBinding__mdt-style custom metadata
records out of one or more source directories, without deploying anything:
import { scanLocalBindings, resolveBindings, ALL_BINDING_TYPES } from '@simplysf/simply-aep-core';
const scan = scanLocalBindings(['force-app'], ALL_BINDING_TYPES);const bindings = resolveBindings(scan.records);
for (const binding of bindings) { console.log(binding.bindingType, binding.key, '->', binding.to, binding.effective ? '(effective)' : '');}Validating bindings for problems
Section titled “Validating bindings for problems”validateBindings takes a scan result (or raw records + the diagnostics that came with them) and
returns every issue it finds — ambiguous/missing SObject references, sequence collisions, duplicate
DeveloperNames, and more:
import { scanLocalBindings, validateBindings, ALL_BINDING_TYPES } from '@simplysf/simply-aep-core';
const scan = scanLocalBindings(['force-app'], ALL_BINDING_TYPES);const issues = validateBindings(scan);
if (issues.length > 0) { for (const issue of issues) { console.error(`[${issue.severity}] ${issue.rule}: ${issue.message}`); } process.exitCode = 1;}Scanning an org instead of local source
Section titled “Scanning an org instead of local source”Same shape, but reads the metadata that’s actually deployed to an org:
import { scanOrgBindings, ALL_BINDING_TYPES } from '@simplysf/simply-aep-core';
const scan = await scanOrgBindings(connection, ALL_BINDING_TYPES);Building a binding’s metadata XML
Section titled “Building a binding’s metadata XML”Useful for anything that wants to generate or update an AT4DXBinding__mdt record’s .md-meta.xml
without shelling out to a CLI:
import { buildBindingXml } from '@simplysf/simply-aep-core';
const xml = buildBindingXml({ bindingType: 'Service', key: 'MyServiceInterface', to: 'MyServiceImpl',});Simulating platform event distribution
Section titled “Simulating platform event distribution”PlatformEvents_Subscription__mdt records route platform events to consumer classes. Given a scan,
resolvePlatformEventDistribution answers “which consumers would AT4DX invoke for this event, and why
not the others?” without publishing anything.
import { resolvePlatformEventDistribution, scanLocalPlatformEventSubscriptions, validatePlatformEventSubscriptions,} from '@simplysf/simply-aep-core';
const scan = scanLocalPlatformEventSubscriptions(['force-app/main/default']);const issues = validatePlatformEventSubscriptions(scan);
const { matches, misses } = resolvePlatformEventDistribution( { eventBus: 'Order_Event__e', category: 'Fulfillment', eventName: 'OrderShipped' }, scan.records,);