Skip to content

Conversation

@jdschleicher
Copy link
Owner

@jdschleicher jdschleicher commented Feb 7, 2025

Motivation and Context

DO NOT EVER USE IN PRODUCTION ORG -- TEST DATA ONLY

New Command and associated refactoring and setup logic:

Open the Command Palette and type:

"Insert Data Set by Directory"

This command requires AND WILL ASK YOU FOR:

  • existing directory to choose from found in "FakeDataSets" directory. ( this directory is generated from functionality introduced : Feature/snowfakery integration #9 )

  • a previously Salesforce CLI/Extension pack authenticated alias or username -- this means a NON-PRODUCTION, Salesforce org alias name

  • ALL OR NONE - If any failure in any object insert attempt , rollback inserts

  • special scenarios it will handle

    • Take all listings of "ObjectApiName.RecordTypeDeveloperName" and replace with actual record Id retrieved from target insert org
    • Will handle lookups of previously inserted records ( this functionality will not work as expected all the time as there is no method to automatically order the inserts such as ensuring Accounts are inserted before Contacts. However, we can look at the dataset files we want to insert and adjust the json structure based on the expected hierarchical relationships

This update also includes refactoring based on the creation of a dedicated "RecordTypeWrapper" object that can manage different picklist scenarios as well as be extended based on associated field markup found in record type files

What does this PR do?

  • Takes expected artifacts already in Collections API format, generates "proof" artifacts, attempts insert of pre-structured files, and adds insert success/failure results in same timestamped directory as "proof" artifacts.
  • significant refactoring needed to properly setup proof files and introduce new "RecordTypeWrapper" object that incorporates a map of "RecordType.DeveloperName" to unique Record Type Id based on the targeted Salesforce org we are attempting to insert data against
  • brief description of each file change below

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Other (please describe):

How Has This Been Tested?

  • Tested on Windows
  • Tested on macOS
  • Tested on Linux
  • Added new unit tests
  • Updated existing tests

Test Details

[Describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration]

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

Full list of new files and changed files along with brief detail of changes found in each file:

  • jest.config.json
  • setting "restoreMocks" to true so each test resets and avoids having to maintain beforeAll/AfterAll on file by file basis
  • package-lock.json
    • associated updates with newly added modules
  • package.json
    • addint new extension command for inserting data by chosen directory
  • src/extension.ts
    • intiation logic for new extension command "Insert Data Set by Directory"
  • src/nodeDevelopmentSuppport/collectionsCall.ts
    • development file for testing out js-force and typescript to successfully make crud calls using previously authenticated alias
  • src/treecipe/src/CollectionsApiService/CollectionsApiService.ts
    • manages logic associated with new "Insert Data Set by Directory" command including rest callouts for Collections API
  • src/treecipe/src/CollectionsApiService/tests/CollectionsApiService.test.ts
    • new set of tests
  • src/treecipe/src/CollectionsApiService/tests/mocks/MockCollectionsApiService.ts
    • new set of mocks
  • src/treecipe/src/ConfigurationService/ConfigurationService.ts
    • new expected/fixed directory names
  • src/treecipe/src/ConfigurationService/tests/ConfigurationService.test.ts
    • new tests for expected directory names
  • src/treecipe/src/DirectoryProcessingService/DirectoryProcessor.ts
    • object model refactoring and associated syntax adjustments(lower case properties to uppercase)
  • src/treecipe/src/DirectoryProcessingService/tests/MockObjectsDirectory/MockDirectoryService.ts
    • json structure to represent directories that have path name of expected "dataset" structure and path names without expected dataset to ensure only dataset directories are captured from treecipe directory
  • src/treecipe/src/DirectoryProcessingService/tests/MockObjectsDirectory/objects/Example_Everything__c/fields/RichTextAreaHtml__c.field-meta.xml
    • test field
  • src/treecipe/src/DirectoryProcessingService/tests/MockObjectsDirectory/objects/Example_Everything__c/fields/TextAreaRich__c.field-meta.xml
    • test field
  • src/treecipe/src/DirectoryProcessingService/tests/MockObjectsDirectory/objects/Example_Everything__c/recordTypes/OneRecType.recordType-meta.xml
    • adjustments to record type for correct picklist options based on available values
  • src/treecipe/src/DirectoryProcessingService/tests/MockObjectsDirectory/objects/Example_Everything__c/recordTypes/TwoRecType.recordType-meta.xml
    • adjustments to record type for correct picklist options based on available values
  • src/treecipe/src/ErrorHandlingService/tests/ErrorHandlingService.test.ts
    • removing trailing comma
  • src/treecipe/src/ExtensionCommandService/ExtensionCommandService.ts
    • introducing new command handler for inserting dataset to org
    • refactoring to create new timestamped directories to capture dataset generated artificacts
  • src/treecipe/src/FakerService/IFakerService.ts
    • adjustments due to new object off of objectinfowrapper
  • src/treecipe/src/FakerService/NPMFakerService/NPMFakerService.ts
    • adjustments for interface change
  • src/treecipe/src/FakerService/NPMFakerService/tests/NPMFakerService.test.ts
    • adjustments for interface change
  • src/treecipe/src/FakerService/SnowfakeryFakerService/SnowfakeryFakerService.ts
    • refactoring with adjustments for recordtypewrapper
  • src/treecipe/src/FakerService/SnowfakeryFakerService/tests/SnowfakeryFakerService.test.ts
    • adjustments for refactoring with recordtypewrapper
  • src/treecipe/src/ObjectInfoWrapper/ObjectInfo.ts
    • case syntax refactoring and adjustments for RecordTypeWrapper
  • src/treecipe/src/ObjectInfoWrapper/ObjectInfoWrapper.ts
    • case syntax refactoring
  • src/treecipe/src/ObjectInfoWrapper/tests/ObjectInfoWrapper.test.ts
    • case syntax refactoring
  • src/treecipe/src/RecipeService/RecipeService.ts
    • recordtypewrapper refactoring
  • src/treecipe/src/RecipeService/tests/RecipeService.test.ts
    • adjustments of unit tests for recordtypewrapper refactoring
  • src/treecipe/src/RecordTypeService/RecordTypeService.ts
    • refactoring from RecordTypeWrapper
  • src/treecipe/src/RecordTypeService/RecordTypesWrapper.ts
    • new recordtypeswrapper object to hold different metadata configurations based on Record Type markup
  • src/treecipe/src/RecordTypeService/tests/MockRecordTypeService.ts
    • adding mock json templates and fake data to mimic record type queryies for unit tests
  • src/treecipe/src/RecordTypeService/tests/RecordTypeService.test.ts
    • adjustment and new unit tests from refactoring
  • src/treecipe/src/SnowfakeryIntegrationService/SnowfakeryIntegrationService.ts
    • refactoring
  • src/treecipe/src/SnowfakeryIntegrationService/tests/SnowfakeryIntegrationService.test.ts
  • src/treecipe/src/VSCodeWorkspace/VSCodeWorkspaceService.ts
    • refactoring
  • src/treecipe/src/VSCodeWorkspace/tests/VSCodeWorkspaceService.test.ts
    • refactoring to promote generic directory traversing
    • refactoring to support generic vscode quick item creation
  • src/treecipe/src/XMLProcessingService/tests/XmlFileProcessor.test.ts
    • verbiage/recipe adjustements to add correct field type for html
  • src/treecipe/src/XMLProcessingService/tests/mocks/XMLMarkupMockService.ts
    • verbiage/recipe adjustements to add correct field type for html
  • tsconfig.json
    • adjustment to latest ES version to compile

Reviewers

@mention-team-members-or-specific-reviewers

@jdschleicher jdschleicher marked this pull request as ready for review February 15, 2025 22:10
@jdschleicher jdschleicher merged commit 8eb3552 into main Feb 16, 2025
2 checks passed
@jdschleicher jdschleicher deleted the feature/collectionsApiService branch February 16, 2025 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant