sf-ent
v0.5.1
Published
A declarative interface for working with the Salesforce Composite API
Downloads
6
Readme
⛔ This is a beta version that is not suitable for production use.
Intro
The Salesforce Composite API is an invaluable tool for loading complex data sets across orgs. It is also, unfortunately, verbose and time-consuming to implement.
sf-ent
makes harnessing the Composite API fast and intuitive. Use it interactively from the command line or programmatically as a script library. Build requests and load data quickly.
Installation
npm install [--global] sf-ent
Usage
The CLI and script APIs are very similar. Commands and subcommands for each use the same names.
The primary difference is that the CLI will prompt you for required inputs and provides object and field auto-completion based on the schema of an authenticated org. Some CLI commands also support flags. Pass -h
or --help
with any command to learn more.
generate
The following shows an example of using the generate
command to create a composite API request file with a single query
subrequest:
CLI:
$ sfent generate --out ./query.json
$ # prompts will guide you to create the query
Script:
const { ent } = require('sf-ent');
// all commands are chainable and must be terminated by invocation of done(), returning a Promise that resolves to the command output
await ent()
.generate({ out: './query.json' })
.query('select id from recordType where sobjectType = \'Account\' and developerName = \'consumer\'')
.done();
API
Full documentation coming soon.
Notes
TypeInfo in URL Hash
sf-ent
appends the name of the class that constructs each Composite subrequest as a URL hash, a la:
{
// ...
"url": "/services/data/v60.0/query/?q=SELECT id FROM Account limit 1#Query_github.com/kev4ev/sf-ent#urlTypeInfo"
// ...
}
It does this so that the prototype can be inferred when a request is loaded into the CLI for interactive modification. Since hashes are not read by the server it has no effect on the request to Salesforce.
Happy Building!