Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScriptInterfaceMethods.tpl generating non-matching camel case structure references in method interfaces. #321

Open
tscaff opened this issue Mar 8, 2023 · 10 comments
Assignees
Labels
question Further information is requested

Comments

@tscaff
Copy link

tscaff commented Mar 8, 2023

When generating TypeScript templates in Harmony Core, it looks like the camel casing for the structure names in the methods template are incorrect and do not match the casing of the Structures being generated.

Is there a different token than <PARAMETER_TSTYPE> that will provide the correct casing of the structure name?

Example: Note the casing on the weblibStructures.abaFile reference which does not match the casing of the structure in the Structures.ts generated by the codegen tool.

import * as weblibStructures from './Structures';

// ------------------------------------------------------------------------------
// Operation: ABALookup

export interface ABALookupRequest {
connectionString: string;
abaFileRecord: weblibStructures.abaFile;
lookupType: string;
abaCount: number;
}

Stucture: ABA_FILE
Description: ABA Bank Index File
/
export interface AbaFile {
AbaNumber: number; /
Size: 9, Description: ABA Bank Number /
AbaName: string; /
Size: 36, Description: ABA Bank Name /
AbaShortname: string; /
Size: 18, Description: ABA Bank Shortname /
AbaAddress: string; /
Size: 36, Description: ABA Bank Address /
AbaState: string; /
Size: 2, Description: ABA Bank State /
AbaCity: string; /
Size: 25, Description: ABA Bank City /
AbaZip: number; /
Size: 9, Description: ABA Bank Zip Code /
AbaPhone: number; /
Size: 10, Description: ABA Bank Telephone /
AbaAllowach: string; /
Size: 1, Description: Allow ACH Transactions to this Bank /
AbaWirefunds: string; /
Size: 1, Description: Allow Wires to this Bank /
AbaFiller: string; /
Size: 53, Description: Additional space for future growth */
}

@tscaff tscaff added the question Further information is requested label Mar 8, 2023
@SteveIves
Copy link
Contributor

Hey, Tom. Before I spend too much time on this, can you check something out for me. This is a "delicate" area, as we have had different customers wanting different behaviors, and I want to avoid fixing something specifically for you and in the process breaking it for someone else.

Generally, when processing with the method catalog, names are maintained from exactly how they appear in the method catalog, which has case-sensitive names. There are a couple of CodeGen "tweaks" which allow you to morph these interface, method and parameter names into camelCase or PascalCase, when using the UPPER case replacement tokensm like <INTERFACE_NAME>, <METHOD_NAME> and <PARAMETER_NAME>.

The tweaks are SMC_CAMEL_CASE and SMC_PASCAL_CASE. You would use one of them via the -tweaks <tweak_name> command line option, for example -tweaks SMC_CAMEL_CASE.

Tweaks are documented here: https://codegen.synergex.com/topics/tweaks.htm

Can you try these out and see if one of them addresses your issue?

@tscaff
Copy link
Author

tscaff commented Mar 9, 2023

Hi Steve.

I will test that out. Thank you for the references to the tweaks...I was trying to figure those out from within the HC project and couldn't find how those were handled....I failed to be look inside the CodeGen project...probably why I missed the documentation on it.

So while I was waiting, I actually modified the TyperScript templates to make it do what we wanted. I have attached those for review. I noticed the Non-Tweaked version didn't really match up the casing like I thought it would and it also applied pluralization where I didn't expect it to, causing some undefined references.

The attach file has the template modifications that get's us all the way to the finish in our Angular implementation.

I will test out the Tweak modifications and see how those work and post feedback to this question. Thanks again.
TypeScript.zip

@tscaff
Copy link
Author

tscaff commented Mar 9, 2023

@hippiehunter how would I implement those tweaks in the harmonycore gui? (I only found reference to those in regen.bat when I searched for it.)

@hippiehunter
Copy link
Contributor

I think these typescript files are being generated by your csx script file. I think there is a task coming from InterfaceTaskHelper. CodeGenTask has a ObservableCollection member on it for Tweaks

https://github.com/Synergex/CodeGen/blob/ce3231ac799427458a4f925de7d7fbf50d66bba5/CodeGenEngine/CodeGenTask.dbl#L463

The Tweaks Steve is referencing above can just be added to that Collection on the CodeGenTask being created in your csx file.

@tscaff
Copy link
Author

tscaff commented Mar 10, 2023

Thanks Jeff. I will see about doing a run through on those and see if that address the casing issues I was seeing.

@hippiehunter
Copy link
Contributor

@tscaff did this solve your problem?

@tscaff
Copy link
Author

tscaff commented Mar 17, 2023

@hippiehunter I did a few tests using the tweak options and it doesn't quite hit the mark in the manner I was hoping. It seems to tweak the value opposite of what they should be. I have to use my original template modifications I posted earlier to make it work.

Example: If I set SMC_PASCAL_CASE on both the structures and methods and client code, it seems to camel case the structure names and shows as undefine, such as in this case where abaFile is camel cased, but it's value in structures is pascal cased. When I set SMC_CAMEL_CASE it seems to do the opposite problem. And this is with using the existing templates so I guess I don't see how these could be working for folks.

import * as WeblibStructures from '../interfaces/Structures';

export interface AbalookupRequest {
Connectionstring: string;
Abafilerecord: WeblibStructures.abaFile;
Lookuptype: string;
Abacount: number;
}

*

Stucture: ABA_FILE
Description: ABA Bank Index File
*/
export interface AbaFile {
AbaNumber: number;
AbaName: string;
AbaShortname: string;
AbaAddress: string;
AbaState: string;
AbaCity: string;
AbaZip: number;
AbaPhone: number;
AbaAllowach: string;
AbaWirefunds: string;
AbaFiller: string;
}

Maybe I am doing these wrong? I have attached the templats and files for review.
TypeScript.zip
TraditionalBridgeGenerator.zip

@hippiehunter
Copy link
Contributor

I poked around in the tpl files and checked with steve, the tweaks stuff is only supposed to apply to all caps tokens. As an example from one of the tpl files

public <methodName>(arg: <interfaceName>Methods.<methodName>Request): Observable<<interfaceName>Methods.<methodName>Response>

those tokens will give you camel case and should be ignoring tweaks settings.

public <METHOD_NAME>(arg: <INTERFACE_NAME>Methods.<METHOD_NAME>Request): Observable<<INTERFACE_NAME>Methods.<METHOD_NAME>Response>

These tokens will give you exact case (whatever was specified in the SMC) but will respond to tweaks settings. You can either change the tokens to all caps and set the tweaks or just adjust the casing in the tokens to the type you're looking for.

@hippiehunter
Copy link
Contributor

@tscaff do you have a working solution to this problem?

@tscaff
Copy link
Author

tscaff commented Jun 16, 2023

Hi @hippiehunter I just got back to looking at this. I don't have a solution to this problem yet. I may need some help working this one out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants