The generated classes use "experimentalDecorators".
Install ts-force
These two packages should always be on the same version!
Configure code generation
Next we need to create the configuration file which will tell the code generator what to do:
You should now see a ts-force-config.json in the folder where you ran the command. It's contents should look something like this:
For now, just update the auth.username property to a connected sfdx-cli username.
Alternate authentication methods are supported. To see a full list of options, see
"ts-force-config" api section
Run Code Generation
After this completes, you should see that generated classes have been added to src/generated for the sObjects listed in our config.
Using ts-force
We will again use the sfdx-cli obtain a Salesforce access token. To do so from node, we'll need an additional dependency:
In a production environment, you would likely obtain the access token via oAuth or other means. See the "Connecting with Salesforce" section for more details.
Create a new file src/index.ts and add the following code
This code does the following:
Creates a Rest instance from via a sfdx-cli org connection
Inserts an Account
Inserts 2 Contacts related to the Account
Queries Contacts where Account.Industry = 'manufacturing'