@@ -17,7 +17,8 @@ type ModificationTypes =
1717 | 'NewProperty'
1818 | 'RemovedProperty'
1919 | 'NewField'
20- | 'RemovedField' ;
20+ | 'RemovedField'
21+ | 'LabelChanged' ;
2122
2223export type MemberModificationType = {
2324 __typename : ModificationTypes ;
@@ -35,6 +36,7 @@ export type Changelog = {
3536 newOrModifiedApexMembers : NewOrModifiedMember [ ] ;
3637 newCustomObjects : string [ ] ;
3738 removedCustomObjects : string [ ] ;
39+ customObjectModifications : NewOrModifiedMember [ ] ;
3840} ;
3941
4042export function hasChanges ( changelog : Changelog ) : boolean {
@@ -52,6 +54,7 @@ export function processChangelog(oldVersion: VersionManifest, newVersion: Versio
5254 newOrModifiedApexMembers : getNewOrModifiedApexMembers ( oldVersion , newVersion ) ,
5355 newCustomObjects : getNewCustomObjects ( oldVersion , newVersion ) ,
5456 removedCustomObjects : getRemovedCustomObjects ( oldVersion , newVersion ) ,
57+ customObjectModifications : getModifiedCustomObjectLabels ( oldVersion , newVersion ) ,
5558 } ;
5659}
5760
@@ -95,7 +98,21 @@ function getNewOrModifiedApexMembers(oldVersion: VersionManifest, newVersion: Ve
9598 ) ;
9699}
97100
98- function getNewOrModifiedEnumValues ( typesInBoth : TypeInBoth [ ] ) : NewOrModifiedMember [ ] {
101+ function getModifiedCustomObjectLabels (
102+ oldVersion : VersionManifest ,
103+ newVersion : VersionManifest ,
104+ ) : NewOrModifiedMember [ ] {
105+ return pipe ( getCustomObjectsInBothVersions ( oldVersion , newVersion ) , ( customObjectsInBoth ) =>
106+ customObjectsInBoth
107+ . filter ( ( { oldType, newType } ) => oldType . label . toLowerCase ( ) !== newType . label . toLowerCase ( ) )
108+ . map ( ( { newType } ) => ( {
109+ typeName : newType . name ,
110+ modifications : [ { __typename : 'LabelChanged' , name : newType . label } ] ,
111+ } ) ) ,
112+ ) ;
113+ }
114+
115+ function getNewOrModifiedEnumValues ( typesInBoth : TypeInBoth < Type > [ ] ) : NewOrModifiedMember [ ] {
99116 return pipe (
100117 typesInBoth . filter ( ( typeInBoth ) => typeInBoth . oldType . type_name === 'enum' ) ,
101118 ( enumsInBoth ) =>
@@ -113,7 +130,7 @@ function getNewOrModifiedEnumValues(typesInBoth: TypeInBoth[]): NewOrModifiedMem
113130 ) ;
114131}
115132
116- function getNewOrModifiedMethods ( typesInBoth : TypeInBoth [ ] ) : NewOrModifiedMember [ ] {
133+ function getNewOrModifiedMethods ( typesInBoth : TypeInBoth < Type > [ ] ) : NewOrModifiedMember [ ] {
117134 return pipe (
118135 typesInBoth . filter (
119136 ( typeInBoth ) => typeInBoth . oldType . type_name === 'class' || typeInBoth . oldType . type_name === 'interface' ,
@@ -146,7 +163,7 @@ function getNewOrModifiedMethods(typesInBoth: TypeInBoth[]): NewOrModifiedMember
146163 ) ;
147164}
148165
149- function getNewOrModifiedClassMembers ( typesInBoth : TypeInBoth [ ] ) : NewOrModifiedMember [ ] {
166+ function getNewOrModifiedClassMembers ( typesInBoth : TypeInBoth < Type > [ ] ) : NewOrModifiedMember [ ] {
150167 return pipe (
151168 typesInBoth . filter ( ( typeInBoth ) => typeInBoth . oldType . type_name === 'class' ) ,
152169 ( classesInBoth ) =>
@@ -173,26 +190,40 @@ function getNewOrModifiedClassMembers(typesInBoth: TypeInBoth[]): NewOrModifiedM
173190 ) ;
174191}
175192
176- type TypeInBoth = {
177- oldType : Type ;
178- newType : Type ;
193+ type TypeInBoth < T extends Type | CustomObjectMetadata > = {
194+ oldType : T ;
195+ newType : T ;
179196} ;
180197
181- function getApexTypesInBothVersions ( oldVersion : VersionManifest , newVersion : VersionManifest ) : TypeInBoth [ ] {
198+ function getApexTypesInBothVersions ( oldVersion : VersionManifest , newVersion : VersionManifest ) : TypeInBoth < Type > [ ] {
182199 return oldVersion . types
183200 . filter ( ( newType ) : newType is Type => newType . type_name !== 'customobject' )
184201 . map ( ( oldType ) => ( {
185202 oldType,
186203 newType : newVersion . types . find ( ( newType ) => newType . name . toLowerCase ( ) === oldType . name . toLowerCase ( ) ) ,
187204 } ) )
188- . filter ( ( type ) => type . newType !== undefined ) as TypeInBoth [ ] ;
205+ . filter ( ( type ) : type is TypeInBoth < Type > => type . newType !== undefined ) ;
206+ }
207+
208+ function getCustomObjectsInBothVersions (
209+ oldVersion : VersionManifest ,
210+ newVersion : VersionManifest ,
211+ ) : TypeInBoth < CustomObjectMetadata > [ ] {
212+ return oldVersion . types
213+ . filter ( ( newType ) : newType is CustomObjectMetadata => newType . type_name === 'customobject' )
214+ . map ( ( oldType ) => ( {
215+ oldType,
216+ newType : newVersion . types . find ( ( newType ) => newType . name . toLowerCase ( ) === oldType . name . toLowerCase ( ) ) ,
217+ } ) )
218+ . filter ( ( type ) : type is TypeInBoth < CustomObjectMetadata > => type . newType !== undefined ) ;
189219}
190220
191221type NameAware = {
192222 name : string ;
193223} ;
194224
195225type AreEqualFn < T > = ( oldValue : T , newValue : T ) => boolean ;
226+
196227function areEqualByName < T extends NameAware > ( oldValue : T , newValue : T ) : boolean {
197228 return oldValue . name . toLowerCase ( ) === newValue . name . toLowerCase ( ) ;
198229}
0 commit comments