Skip to content

Commit 302c79c

Browse files
authored
Feature : 2.4.0 -- Feature/standard value sets (#29)
* feat: initial refactoring setup to prepare for code changes in generating picklist values * artifcats: adding standardValueSets in preparation for testing and building expected faker expressions for fields that reference standard value sets * refactor: readding getstandardvalueset method as removing it is out of scope * feat: undoing object name from xmlfielddetail -- introducing valuesetservice * feat: removing objectname property that no longer exists * refactor: clean up to undo objectName property * feat: tests to capture standardValueSet key for snowfakery and fakerjs implementation * build: update for form-data patch version * feat: logic update and associated validation tests to correctly handle scenarios when there are no availablePicklistValues * build: package-lock json update * refactor: removing test files * clean: removing excess spaces showing the only change on the file * build: package.json update * docs: changelog update to 2.4 * docs: changelog update
1 parent b2e6dd5 commit 302c79c

File tree

13 files changed

+1086
-478
lines changed

13 files changed

+1086
-478
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Change Log
22

3+
## [2.4.0] [PR#29](https://github.com/jdschleicher/Salesforce-Data-Treecipe/pull/29) - Feature : 2.4.0
4+
5+
### Standard Value Set Map for avoiding additional TODO's when generating recipes from code base
6+
7+
When generating recipes based on source code, there tends to be references to standardValueSets that require extra efforts to get their associated picklist values in a faker function because the OOTB standard value sets are picklists WITHOUT any necessary xml markup capturing what values make up the picklist.
8+
9+
This feature created a dedicated field api name to picklist values to allow for local management of OOTB standardPicklistValues.
10+
11+
It's not an exhaustive list but is a start and can be easily added on to.
12+
313
## [2.3.0] [PR#27](https://github.com/jdschleicher/Salesforce-Data-Treecipe/pull/27) - Feature : 2.3.0
414

515
Feature: Leverage nickname property from yaml object recipe that can combine with unique "record reference key" to allow for lookup reference replacements.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
***
3+
4+
# Changelog for branch: feature/standardValueSets
5+
6+
Generated on: 2025-08-01
7+
8+
## Summary
9+
- Total commits: 13
10+
- Files added: 2
11+
- Files modified: 9
12+
- Files deleted: 0
13+
- Files renamed: 0
14+
15+
***
16+
17+
## Changes at a glance
18+
## Added Files
19+
| Added File | Commits | History |
20+
|------|---------|---------|
21+
| src/treecipe/src/RecipeService/tests/FakerJSRecipeService.test.ts | 3 | [View Full History](/commits/feature/standardValueSets/src/treecipe/src/RecipeService/tests/FakerJSRecipeService.test.ts) |
22+
| src/treecipe/src/ValueSetService/ValueSetService.ts | 3 | [View Full History](/commits/feature/standardValueSets/src/treecipe/src/ValueSetService/ValueSetService.ts) |
23+
## Modified Files
24+
| Modified File | Commits | History |
25+
|------|---------|---------|
26+
| package-lock.json | 2 | [View Full History](/commits/feature/standardValueSets/package-lock.json) |
27+
| package.json | 1 | [View Full History](/commits/feature/standardValueSets/package.json) |
28+
| src/treecipe/src/FakerRecipeProcessor/SnowfakeryRecipeProcessor/SnowfakeryRecipeProcessor.ts | 1 | [View Full History](/commits/feature/standardValueSets/src/treecipe/src/FakerRecipeProcessor/SnowfakeryRecipeProcessor/SnowfakeryRecipeProcessor.ts) |
29+
| src/treecipe/src/RecipeFakerService.ts/FakerJSRecipeFakerService/FakerJSRecipeFakerService.ts | 3 | [View Full History](/commits/feature/standardValueSets/src/treecipe/src/RecipeFakerService.ts/FakerJSRecipeFakerService/FakerJSRecipeFakerService.ts) |
30+
| src/treecipe/src/RecipeFakerService.ts/FakerJSRecipeFakerService/tests/FakerJSRecipeFakerService.test.ts | 2 | [View Full History](/commits/feature/standardValueSets/src/treecipe/src/RecipeFakerService.ts/FakerJSRecipeFakerService/tests/FakerJSRecipeFakerService.test.ts) |
31+
| src/treecipe/src/RecipeFakerService.ts/SnowfakeryRecipeFakerService/SnowfakeryRecipeFakerService.ts | 4 | [View Full History](/commits/feature/standardValueSets/src/treecipe/src/RecipeFakerService.ts/SnowfakeryRecipeFakerService/SnowfakeryRecipeFakerService.ts) |
32+
| src/treecipe/src/RecipeService/RecipeService.ts | 3 | [View Full History](/commits/feature/standardValueSets/src/treecipe/src/RecipeService/RecipeService.ts) |
33+
| src/treecipe/src/RecipeService/tests/RecipeService.test.ts | 3 | [View Full History](/commits/feature/standardValueSets/src/treecipe/src/RecipeService/tests/RecipeService.test.ts) |
34+
| src/treecipe/src/XMLProcessingService/tests/mocks/XMLMarkupMockService.ts | 4 | [View Full History](/commits/feature/standardValueSets/src/treecipe/src/XMLProcessingService/tests/mocks/XMLMarkupMockService.ts) |
35+
## Deleted Files
36+
| Deleted File | Commits | History |
37+
|------|---------|---------|
38+
## Renamed Files
39+
| Old Path | New Path | Commits | History |
40+
|----------|----------|---------|---------|

package-lock.json

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Salesforce Data Treecipe",
44
"description": "source-fidelity driven development, pairs well with cumulus-ci",
55
"icon": "images/datatreecipe.webp",
6-
"version": "2.3.0",
6+
"version": "2.4.0",
77
"engines": {
88
"vscode": "^1.94.0"
99
},

src/treecipe/src/FakerRecipeProcessor/SnowfakeryRecipeProcessor/SnowfakeryRecipeProcessor.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,13 @@ export class SnowfakeryRecipeProcessor implements IFakerRecipeProcessor {
136136
return referenceTrackingId;
137137

138138
}
139+
140+
getStandardAndGlobalValueSetTODOPlaceholderWithExample():string {
141+
142+
const emptyPicklistXMLDetailRecipePlaceholder = `### TODO: POSSIBLE GLOBAL OR STANDARD VALUE SET USED FOR THIS PICKLIST AS DETAILS ARE NOT IN FIELD XML MARKUP -- FIND ASSOCIATED VALUE SET AND REPALCE COMMA SEPARATED FRUITS WITH VALUE SET OPTIONS: \${{ random_choice('apple', 'orange', 'banana') }}`;
143+
return emptyPicklistXMLDetailRecipePlaceholder;
144+
145+
}
146+
139147

140148
}

src/treecipe/src/RecipeFakerService.ts/FakerJSRecipeFakerService/FakerJSRecipeFakerService.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,22 @@ ${this.generateTabs(5)}${randomChoicesBreakdown}`;
126126

127127
}
128128

129-
buildPicklistRecipeValueByXMLFieldDetail(availablePicklistChoices: string[],
129+
buildPicklistRecipeValueByXMLFieldDetail(availablePicklistChoices: string[],
130130
recordTypeNameByRecordTypeWrapper: Record<string, RecordTypeWrapper>,
131-
associatedFieldApiName): string {
131+
fieldApiName: string): string {
132+
133+
let fakeRecipeValue = '';
134+
135+
if ( !(availablePicklistChoices) || availablePicklistChoices.length === 0 ) {
136+
// indicates no svs or picklistvlaues
137+
return "### TODO: This picklist field needs manually updated with either a standard value set list or global value set";
138+
139+
}
132140

133141
const fakerJoinedChoicesSyntax = this.buildPicklistFakerArraySingleElementSyntaxByPicklistOptions(availablePicklistChoices);
134-
let fakeRecipeValue = `${this.openingRecipeSyntax} ${fakerJoinedChoicesSyntax} ${this.closingRecipeSyntax}`;
142+
fakeRecipeValue = `${this.openingRecipeSyntax} ${fakerJoinedChoicesSyntax} ${this.closingRecipeSyntax}`;
135143

136-
const recordTypeBasedRecipeValues = this.buildRecordTypeBasedPicklistRecipeValue(recordTypeNameByRecordTypeWrapper, associatedFieldApiName);
144+
const recordTypeBasedRecipeValues = this.buildRecordTypeBasedPicklistRecipeValue(recordTypeNameByRecordTypeWrapper, fieldApiName);
137145
if ( recordTypeBasedRecipeValues) {
138146
fakeRecipeValue += `\n${recordTypeBasedRecipeValues}`;
139147
}
@@ -498,7 +506,6 @@ ${this.generateTabs(5)}${randomChoicesBreakdown}`;
498506
const emptyMultiSelectXMLDetailPlaceholder = `### TODO: POSSIBLE GLOBAL OR STANDARD VALUE SET USED FOR THIS MULTIPICKLIST AS DETAILS ARE NOT IN FIELD XML MARKUP -- FIND ASSOCIATED VALUE SET AND REPLACE COMMA SEPARATED FRUITS WITH VALUE SET OPTIONS: \${{ (faker.helpers.arrayElements(['apple', 'orange', 'banana']) ).join(';') }}`;
499507
return emptyMultiSelectXMLDetailPlaceholder;
500508

501-
502509
}
503510

504511
}

src/treecipe/src/RecipeFakerService.ts/FakerJSRecipeFakerService/tests/FakerJSRecipeFakerService.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,19 @@ describe('FakerJSRecipeFakerService Shared Intstance Tests', () => {
224224
expect(actualFakerValue).toBe(expectedRecipeValue);
225225
});
226226

227+
test('given expected list of choices, returns expected picklist faker value', () => {
228+
229+
const possibleChoices: string[] = ['apple', 'orange', 'banana'];
230+
const expectedRecipeValue = `\${{ faker.helpers.arrayElement(['apple','orange','banana']) }}`;
231+
const emptyRecordTypeNameByRecordTypeNameToXRecordTypeWrapperMap: Record<string, RecordTypeWrapper> = {};
232+
const fakeFieldApiName = "Fruit__c";
233+
const actualFakerValue = fakerJSRecipeFakerService.buildPicklistRecipeValueByXMLFieldDetail(possibleChoices,
234+
emptyRecordTypeNameByRecordTypeNameToXRecordTypeWrapperMap,
235+
fakeFieldApiName);
236+
237+
expect(actualFakerValue).toBe(expectedRecipeValue);
238+
});
239+
227240
});
228241

229242
describe('getOOTBExpectedObjectToFakerValueMappings', () => {

src/treecipe/src/RecipeFakerService.ts/SnowfakeryRecipeFakerService/SnowfakeryRecipeFakerService.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,21 @@ ${this.generateTabs(5)}${randomChoicesBreakdown}`;
126126

127127
}
128128

129-
buildPicklistRecipeValueByXMLFieldDetail(availablePicklistChoices: string[],
129+
buildPicklistRecipeValueByXMLFieldDetail(availablePicklistChoices: string[],
130130
recordTypeNameByRecordTypeWrapper: Record<string, RecordTypeWrapper>,
131-
associatedFieldApiName): string {
131+
fieldApiName: string): string {
132+
133+
let fakeRecipeValue = '';
134+
135+
if ( !(availablePicklistChoices) || availablePicklistChoices.length === 0 ) {
136+
// indicates no svs or picklistvlaues
137+
return "### TODO: This picklist field needs manually updated with either a standard value set list or global value set";
138+
}
132139

133140
const commaJoinedPicklistChoices = availablePicklistChoices.join("', '");
134-
let fakeRecipeValue = `${this.openingRecipeSyntax} random_choice('${commaJoinedPicklistChoices}') ${this.closingRecipeSyntax}`;
141+
fakeRecipeValue = `${this.openingRecipeSyntax} random_choice('${commaJoinedPicklistChoices}') ${this.closingRecipeSyntax}`;
135142

136-
const recordTypeBasedRecipeValues = this.buildRecordTypeBasedPicklistRecipeValue(recordTypeNameByRecordTypeWrapper, associatedFieldApiName);
143+
const recordTypeBasedRecipeValues = this.buildRecordTypeBasedPicklistRecipeValue(recordTypeNameByRecordTypeWrapper, fieldApiName);
137144
if ( recordTypeBasedRecipeValues) {
138145
fakeRecipeValue += `\n${recordTypeBasedRecipeValues}`;
139146
}

src/treecipe/src/RecipeService/RecipeService.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ErrorHandlingService } from "../ErrorHandlingService/ErrorHandlingService";
22
import { IRecipeFakerService } from "../RecipeFakerService.ts/IRecipeFakerService";
33
import { RecordTypeWrapper } from "../RecordTypeService/RecordTypesWrapper";
4+
import { ValueSetService } from "../ValueSetService/ValueSetService";
45
import { XMLFieldDetail } from "../XMLProcessingService/XMLFieldDetail";
56

67
export class RecipeService {
@@ -56,16 +57,25 @@ export class RecipeService {
5657
// THIS SCENARIO INDICATES THAT THE PICKLIST FIELD IS DEPENDENT
5758
fakeRecipeValue = this.getDependentPicklistRecipeFakerValue(xmlFieldDetail, recordTypeApiToRecordTypeWrapperMap);
5859
} else {
59-
60+
61+
let availablePicklistValueOptions: string[] = [];
6062
if ( !(xmlFieldDetail.picklistValues) ) {
61-
// THIS SCENARIO INDICATEDS THAT THE PICKLIST FIELD UTILIZED A GLOBAL VALUE SET
62-
const emptyPicklistXMLDetailRecipePlaceholder = this.fakerService.getStandardAndGlobalValueSetTODOPlaceholderWithExample();
63-
return emptyPicklistXMLDetailRecipePlaceholder;
63+
64+
// IF THE FIELD TYPE IS 'picklist' BUT!!! THERE IS NO <picklistValues> XML MARKUP, THEN WE TRY
65+
// TO GET PICKLIST VALUES WITH THE POSSIBILITY THEY ARE A DEFAULT STANDARD VALUE SET (OR GLOBAL VALUE SET IN A FUTURE FEATURE)
66+
const existingOOTBStandardValueSetPicklistValuesByApiName = ValueSetService.getOOTBValueOptionsByStandardValueSetName(xmlFieldDetail.apiName);
67+
if ( existingOOTBStandardValueSetPicklistValuesByApiName ) {
68+
availablePicklistValueOptions = existingOOTBStandardValueSetPicklistValuesByApiName;
69+
}
70+
71+
} else {
72+
73+
availablePicklistValueOptions = xmlFieldDetail.picklistValues.map(picklistOption => picklistOption.picklistOptionApiName);
74+
6475
}
65-
const availablePicklistChoices = xmlFieldDetail.picklistValues.map(picklistOption => picklistOption.picklistOptionApiName);
66-
fakeRecipeValue = this.fakerService.buildPicklistRecipeValueByXMLFieldDetail(availablePicklistChoices,
67-
recordTypeApiToRecordTypeWrapperMap,
68-
xmlFieldDetail.apiName);
76+
77+
fakeRecipeValue = this.fakerService.buildPicklistRecipeValueByXMLFieldDetail(availablePicklistValueOptions, recordTypeApiToRecordTypeWrapperMap, xmlFieldDetail.apiName );
78+
6979
}
7080

7181
return fakeRecipeValue;

0 commit comments

Comments
 (0)