@@ -20,10 +20,20 @@ export function reflectCustomFieldsAndObjectsAndMetadataRecords(
2020 return parsedFiles . filter ( ( parsedFile ) => parsedFile . type . deploymentStatus === 'Deployed' ) ;
2121 }
2222
23- function filterNonPublic ( parsedFiles : ParsedFile < CustomObjectMetadata > [ ] ) : ParsedFile < CustomObjectMetadata > [ ] {
24- return parsedFiles . filter ( ( parsedFile ) =>
25- visibilitiesToDocument . includes ( parsedFile . type . visibility . toLowerCase ( ) ) ,
26- ) ;
23+ /**
24+ * Returns a tuple of parsed objects to document and the names of the objects that should be actively ignored.
25+ * @param parsedFiles
26+ */
27+ function filter ( parsedFiles : ParsedFile < CustomObjectMetadata > [ ] ) : [ ParsedFile < CustomObjectMetadata > [ ] , string [ ] ] {
28+ function shouldBeDocumented ( parsedFile : ParsedFile < CustomObjectMetadata > ) : boolean {
29+ return visibilitiesToDocument . includes ( parsedFile . type . visibility . toLowerCase ( ) ) ;
30+ }
31+
32+ const objectsToDocument = parsedFiles . filter ( shouldBeDocumented ) ;
33+ const objectsToIgnore = parsedFiles
34+ . filter ( ( parsedFile ) => ! shouldBeDocumented ( parsedFile ) )
35+ . map ( ( parsedFile ) => parsedFile . type . name ) ;
36+ return [ objectsToDocument , objectsToIgnore ] ;
2737 }
2838
2939 const customObjects = objectBundles . filter (
@@ -54,12 +64,12 @@ export function reflectCustomFieldsAndObjectsAndMetadataRecords(
5464 customObjects ,
5565 reflectCustomObjectSources ,
5666 TE . map ( filterNonPublished ) ,
57- TE . map ( filterNonPublic ) ,
58- TE . bindTo ( 'objects ' ) ,
67+ TE . map ( filter ) ,
68+ TE . bindTo ( 'filterResult ' ) ,
5969 TE . bind ( 'fields' , ( ) => generateForFields ( customFields ) ) ,
6070 TE . bind ( 'metadata' , ( ) => generateForMetadata ( customMetadata ) ) ,
61- TE . map ( ( { objects , fields, metadata } ) => {
62- return [ ...mapFieldsAndMetadata ( objects , fields , metadata ) , ...mapExtensionFields ( objects , fields ) ] ;
71+ TE . map ( ( { filterResult , fields, metadata } ) => {
72+ return [ ...mapFieldsAndMetadata ( filterResult [ 0 ] , fields , metadata ) , ...mapExtensionFields ( filterResult , fields ) ] ;
6373 } ) ,
6474 ) ;
6575}
@@ -88,11 +98,16 @@ function mapFieldsAndMetadata(
8898// "Extension" fields are fields that are in the source code without the corresponding object-meta.xml file.
8999// These are fields that either extend a standard Salesforce object, or an object in a different package.
90100function mapExtensionFields (
91- objects : ParsedFile < CustomObjectMetadata > [ ] ,
101+ filterResult : [ ParsedFile < CustomObjectMetadata > [ ] , string [ ] ] ,
92102 fields : ParsedFile < CustomFieldMetadata > [ ] ,
93103) : ParsedFile < CustomObjectMetadata > [ ] {
104+ const objects = filterResult [ 0 ] ;
105+ const ignoredObjectNames = filterResult [ 1 ] ;
106+
94107 const extensionFields = fields . filter (
95- ( field ) => ! objects . some ( ( object ) => object . type . name === field . type . parentName ) ,
108+ ( field ) =>
109+ ! objects . some ( ( object ) => object . type . name . toLowerCase ( ) === field . type . parentName . toLowerCase ( ) ) &&
110+ ! ignoredObjectNames . map ( ( name ) => name . toLowerCase ( ) ) . includes ( field . type . parentName . toLowerCase ( ) ) ,
96111 ) ;
97112 // There might be many objects for the same parent name, so we need to group the fields by parent name
98113 const extensionFieldsByParent = extensionFields . reduce (
0 commit comments