Generating Typings for Business Entities

The SmartComponents CLI tool features a declarations file generator for your business entities. These are useful because they provide type safety, code completion and any other advantages associated with strongly typed languages while manipulating database records.

Here are the steps needed to generate declaration files for your business entities:

  1. Install the SCL CLI tool if you have not done so already: npm install -g @consultingwerk/smartcomponents-cli
  2. Change directory to the root of your Angular project
  3. Run the type generation tool:

    No arguments (provide information at run-time)
    scl generate static-types
    Specific Business Entity
    scl generate static-types <fully_qualified_business_entity_name>
    Namespace
    scl generate static-types <name_space_followed_by_*>
  4. Follow the instructions and provide necessary information
  5. The typings should take effect straight away, without taking further actions. If for any reason they do not, then either try recompiling your project or restarting your IDE.

As shown above, the typings generator can be executed in three ways. If no business entity name or namespace is provided, then the generator will prompt you for this information at run-time. If a specific business entity name is passed as an argument, then the generator will generate typings for that business entity only. Finally, if a namespace is provided (e.g. Consultingwerk.SmartComponentsDemo.OERA.*), then the generator will prompt you to choose from the business entities under that namespace (any number of business entities may be selected).

The generator will also prompt you for your service URI, user name and password. You may choose to save this information for later use (your password will not be saved).

When prompted for the output directory, you may choose to use the default value (current working directory). If you would like to use a different path, then you may use both absolute and relative (to the current working directory) paths.

 

After your typings have been successfully generated, you may use them in two ways:

Import
import eCustomer /** this can be any variable name */ = Consultingwerk.SmartComponentsDemo.OERA.Sports2000.CustomerBusinessEntity.eCustomer;
 
...
 
let customerRecord: eCustomer = { ... };
 
myDataSource.selectionChanged.subscribe((event: SelectionChangedEventArgs) => {
	let selectedRecord: eCustomer = event.newSelection;
    ...
});
Inline
let customerRecord: Consultingwerk.SmartComponentsDemo.OERA.Sports2000.CustomerBusinessEntity.eCustomer = { ... }