Currently, I am working on a Spring Boot backend application and incorporating the Facebook marketing SDK. For the frontend, I am utilizing Angular 10. Whenever I create a new page or campaign, my goal is to send the corresponding object back to the frontend application with all the required properties of the campaign.
I attempted to use the typescript-generator tool from Habarta, but encountered challenges due to the complexity of the Facebook Java classes, resulting in conflicting outcomes during the generation process. An example of this issue is:
When parsing 'com.facebook.ads.sdk.ProductFeedRuleSuggestion' for 'APIRequestGetSuggestedRules.lastResponse'
Warning: Several classes are associated with 'APIRequestGetActivities'. Conflicting classes: [class com.facebook.ads.sdk.AdAccount$APIRequestGetActivities, class com.facebook.ads.sdk.AdSet$APIRequestGetActivities]
...
[ERROR] The execution of goal cz.habarta.typescript-generator:typescript-generator-maven-plugin:2.25.695:generate (default-cli) failed while processing 'simplephy' project: The default-cli execution of cz.habarta.typescript-generator:typescript-generator-maven-plugin:2.25.695:generate was unsuccessful due to having multiple classes mapped with the same name. To resolve conflicts or exclude unintended classes, consider using 'customTypeNaming' or 'customTypeNamingFunction' settings.
Here is how my plugin is set up:
<plugin>
<groupId>cz.habarta.typescript-generator</groupId>
<artifactId>typescript-generator-maven-plugin</artifactId>
<version>2.25.695</version>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
<configuration>
<jsonLibrary>jackson2</jsonLibrary>
<mapClasses>asClasses</mapClasses>
<classes>
<class>com.facebook.ads.sdk.Campaign</class>
</classes>
<excludeClasses>
<excludeClass>com.facebook.ads.sdk.APINode</excludeClass>
</excludeClasses>
<outputKind>module</outputKind>
<outputFileType>implementationFile</outputFileType>
</configuration>
</plugin>
What would be the most effective approach to generating the essential TypeScript classes based on the Facebook Java objects? Alternatively, are there better methods for transferring these Facebook objects between the backend and frontend applications?