Skip to content

forcedotcom/sf-skills / plugins/builder/integration/skills/integration-connectivity-generate

integration-connectivity-generate

Verified

Salesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use integration-connectivity-connected-app-configure), Apex-only logic (use platform-apex-generate), data import/export (use platform-data-manage), or CDC channel-membership metadata such as PlatformEventChannel, PlatformEventChannelMember, or EnrichedField (use integration-eventing-cdc-configure).

FileKindSize
README.mdmarkdown3.5 KB
SKILL.mdskill md8.8 KB
assets/callouts/callout-retry-handler.clsother6.0 KB
assets/callouts/http-response-handler.clsother8.5 KB
assets/callouts/rest-queueable-callout.clsother8.8 KB
assets/callouts/rest-sync-callout.clsother7.4 KB
assets/cdc/cdc-handler.clsother8.4 KB
assets/cdc/cdc-subscriber-trigger.triggerother5.3 KB
assets/endpoint-security/example.cspTrustedSite-meta.xmlconfig1.8 KB
assets/endpoint-security/example.remoteSite-meta.xmlconfig1.3 KB
assets/external-credentials/jwt-external-credential.externalCredential-meta.xmlconfig3.2 KB
assets/external-credentials/oauth-external-credential.externalCredential-meta.xmlconfig3.0 KB
assets/external-services/external-service-operations.mdmarkdown5.5 KB
assets/external-services/openapi-registration.externalServiceRegistration-meta.xmlconfig4.8 KB
assets/named-credentials/certificate-auth.namedCredential-meta.xmlconfig2.2 KB
assets/named-credentials/custom-auth.namedCredential-meta.xmlconfig2.2 KB
assets/named-credentials/oauth-client-credentials.namedCredential-meta.xmlconfig1.8 KB
assets/named-credentials/oauth-jwt-bearer.namedCredential-meta.xmlconfig2.2 KB
assets/platform-events/event-publisher.clsother6.4 KB
assets/platform-events/event-subscriber-action.clsother9.5 KB
assets/platform-events/event-subscriber-trigger.triggerother3.9 KB
assets/platform-events/platform-event-definition.object-meta.xmlconfig3.7 KB
assets/soap/soap-callout-service.clsother6.4 KB
assets/soap/wsdl2apex-guide.mdmarkdown6.2 KB
references/callout-patterns.mdmarkdown21.8 KB
references/cdc-guide.mdmarkdown8.2 KB
references/cli-reference.mdmarkdown2.9 KB
references/event-driven-architecture-guide.mdmarkdown10.1 KB
references/event-patterns.mdmarkdown27.2 KB
references/external-services-guide.mdmarkdown8.4 KB
references/messaging-api-v2.mdmarkdown17.9 KB
references/named-credentials-automation.mdmarkdown6.2 KB
references/named-credentials-guide.mdmarkdown7.1 KB
references/platform-events-guide.mdmarkdown6.6 KB
references/rest-callout-patterns.mdmarkdown8.8 KB
references/scoring-rubric.mdmarkdown2.4 KB
references/security-best-practices.mdmarkdown5.9 KB
scripts/README.mdmarkdown2.9 KB
scripts/configure-named-credential.shexecutablescript9.2 KB
scripts/set-api-credential.shexecutablescript4.9 KB
scripts/suggest_credential_setup.pyscript9.3 KB
scripts/templates/setup-credentials-with-csp.shexecutablescript5.9 KB
scripts/validate_integration.pyscript13.4 KB

assets/platform-events/event-subscriber-action.cls

View on GitHub
/**
 * @description Platform Event Handler/Action Class for {{EventName}}__e
 *
 * Use Case: Business logic for processing Platform Events
 * - Separated from trigger for testability
 * - TAF-compatible action pattern
 * - Bulkified processing
 *
 * This class is called by the {{EventName}}Subscriber trigger
 * and contains all business logic for event processing.
 *
 * @author {{Author}}
 * @date {{Date}}
 */
public with sharing class {{EventName}}Handler {

    /**
     * @description Handle CREATE operation events
     * @param event The platform event
     */
    public static void handleCreate({{EventName}}__e event) {
        Map<String, Object> payload = parsePayload(event.Payload__c);

        // Example: Create a record based on event data
        /*
        {{TargetObject}}__c newRecord = new {{TargetObject}}__c();
        newRecord.Name = (String) payload.get('name');
        newRecord.External_Id__c = event.Record_Id__c;
        newRecord.Source_System__c = 'Platform Event';
        insert newRecord;
        */

        System.debug(LoggingLevel.DEBUG,
            'Processed CREATE event: ' + event.Correlation_Id__c);
    }

    /**
     * @description Handle UPDATE operation events
     * @param event The platform event
     */
    public static void handleUpdate({{EventName}}__e event) {
        Map<String, Object> payload = parsePayload(event.Payload__c);
        String recordId = event.Record_Id__c;

        // Example: Update existing record
        /*
        List<{{TargetObject}}__c> records = [
            SELECT Id, Name
            FROM {{TargetObject}}__c
            WHERE External_Id__c = :recordId
            WITH USER_MODE
            LIMIT 1
        ];

        if (!records.isEmpty()) {
            {{TargetObject}}__c record = records[0];
            record.Name = (String) payload.get('name');
            record.Last_Sync__c = Datetime.now();
            update record;
        }
        */

        System.debug(LoggingLevel.DEBUG,
            'Processed UPDATE event: ' + event.Correlation_Id__c);
    }

    /**
     * @description Handle DELETE operation events
     * @param event The platform event
     */
    public static void handleDelete({{EventName}}__e event) {
        String recordId = event.Record_Id__c;

        // Example: Delete or archive record
        /*
        List<{{TargetObject}}__c> records = [
            SELECT Id
            FROM {{TargetObject}}__c
            WHERE External_Id__c = :recordId
            WITH USER_MODE
            LIMIT 1
        ];

        if (!records.isEmpty()) {
            delete records;
        }
        */

        System.debug(LoggingLevel.DEBUG,
            'Processed DELETE event: ' + event.Correlation_Id__c);
    }

    /**
     * @description Handle bulk events (for optimized processing)
     *              Call this from trigger instead of individual handlers
     *              when processing high volumes
     * @param events List of events to process
     */
    public static void handleBulk(List<{{EventName}}__e> events) {
        // Separate events by operation
        List<{{EventName}}__e> createEvents = new List<{{EventName}}__e>();
        List<{{EventName}}__e> updateEvents = new List<{{EventName}}__e>();
        List<{{EventName}}__e> deleteEvents = new List<{{EventName}}__e>();

        for ({{EventName}}__e event : events) {
            switch on event.Operation__c {
                when 'CREATE' {
                    createEvents.add(event);
                }
                when 'UPDATE' {
                    updateEvents.add(event);
                }
                when 'DELETE' {
                    deleteEvents.add(event);
                }
            }
        }

        // Process each operation type in bulk
        if (!createEvents.isEmpty()) {
            handleBulkCreate(createEvents);
        }
        if (!updateEvents.isEmpty()) {
            handleBulkUpdate(updateEvents);
        }
        if (!deleteEvents.isEmpty()) {
            handleBulkDelete(deleteEvents);
        }
    }

    /**
     * @description Bulk create handler
     * @param events CREATE events
     */
    private static void handleBulkCreate(List<{{EventName}}__e> events) {
        List<{{TargetObject}}__c> newRecords = new List<{{TargetObject}}__c>();

        for ({{EventName}}__e event : events) {
            Map<String, Object> payload = parsePayload(event.Payload__c);

            {{TargetObject}}__c record = new {{TargetObject}}__c();
            // Map fields from payload
            // record.Name = (String) payload.get('name');
            // record.External_Id__c = event.Record_Id__c;

            newRecords.add(record);
        }

        if (!newRecords.isEmpty()) {
            // Use Database.insert for partial success handling
            Database.SaveResult[] results = Database.insert(newRecords, false);
            logDmlResults(results, 'CREATE');
        }
    }

    /**
     * @description Bulk update handler
     * @param events UPDATE events
     */
    private static void handleBulkUpdate(List<{{EventName}}__e> events) {
        // Collect external IDs to query
        Set<String> externalIds = new Set<String>();
        Map<String, {{EventName}}__e> eventsByExternalId = new Map<String, {{EventName}}__e>();

        for ({{EventName}}__e event : events) {
            externalIds.add(event.Record_Id__c);
            eventsByExternalId.put(event.Record_Id__c, event);
        }

        // Query existing records
        /*
        Map<String, {{TargetObject}}__c> recordsByExternalId = new Map<String, {{TargetObject}}__c>();
        for ({{TargetObject}}__c record : [
            SELECT Id, External_Id__c, Name
            FROM {{TargetObject}}__c
            WHERE External_Id__c IN :externalIds
            WITH USER_MODE
        ]) {
            recordsByExternalId.put(record.External_Id__c, record);
        }

        // Update records
        List<{{TargetObject}}__c> toUpdate = new List<{{TargetObject}}__c>();
        for (String extId : externalIds) {
            if (recordsByExternalId.containsKey(extId)) {
                {{TargetObject}}__c record = recordsByExternalId.get(extId);
                {{EventName}}__e event = eventsByExternalId.get(extId);
                Map<String, Object> payload = parsePayload(event.Payload__c);

                // Update fields
                // record.Name = (String) payload.get('name');
                toUpdate.add(record);
            }
        }

        if (!toUpdate.isEmpty()) {
            Database.SaveResult[] results = Database.update(toUpdate, false);
            logDmlResults(results, 'UPDATE');
        }
        */
    }

    /**
     * @description Bulk delete handler
     * @param events DELETE events
     */
    private static void handleBulkDelete(List<{{EventName}}__e> events) {
        Set<String> externalIds = new Set<String>();
        for ({{EventName}}__e event : events) {
            externalIds.add(event.Record_Id__c);
        }

        /*
        List<{{TargetObject}}__c> toDelete = [
            SELECT Id
            FROM {{TargetObject}}__c
            WHERE External_Id__c IN :externalIds
            WITH USER_MODE
        ];

        if (!toDelete.isEmpty()) {
            Database.DeleteResult[] results = Database.delete(toDelete, false);
            logDeleteResults(results, 'DELETE');
        }
        */
    }

    /**
     * @description Parse JSON payload to Map
     * @param payloadJson JSON string
     * @return Parsed Map
     */
    private static Map<String, Object> parsePayload(String payloadJson) {
        if (String.isBlank(payloadJson)) {
            return new Map<String, Object>();
        }

        try {
            return (Map<String, Object>) JSON.deserializeUntyped(payloadJson);
        } catch (JSONException e) {
            System.debug(LoggingLevel.ERROR, 'Failed to parse payload: ' + e.getMessage());
            return new Map<String, Object>();
        }
    }

    /**
     * @description Log DML results for monitoring
     * @param results Database.SaveResult array
     * @param operation Operation name
     */
    private static void logDmlResults(Database.SaveResult[] results, String operation) {
        Integer successCount = 0;
        Integer failCount = 0;

        for (Database.SaveResult sr : results) {
            if (sr.isSuccess()) {
                successCount++;
            } else {
                failCount++;
                for (Database.Error err : sr.getErrors()) {
                    System.debug(LoggingLevel.ERROR,
                        operation + ' failed: ' + err.getStatusCode() + ' - ' + err.getMessage());
                }
            }
        }

        System.debug(LoggingLevel.INFO,
            operation + ' results - Success: ' + successCount + ', Failed: ' + failCount);
    }

    /**
     * @description Log delete results for monitoring
     * @param results Database.DeleteResult array
     * @param operation Operation name
     */
    private static void logDeleteResults(Database.DeleteResult[] results, String operation) {
        Integer successCount = 0;
        Integer failCount = 0;

        for (Database.DeleteResult dr : results) {
            if (dr.isSuccess()) {
                successCount++;
            } else {
                failCount++;
                for (Database.Error err : dr.getErrors()) {
                    System.debug(LoggingLevel.ERROR,
                        operation + ' failed: ' + err.getStatusCode() + ' - ' + err.getMessage());
                }
            }
        }

        System.debug(LoggingLevel.INFO,
            operation + ' results - Success: ' + successCount + ', Failed: ' + failCount);
    }
}
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall