util.nu
1 exported command
17 internal commandsbuild-session
InternalBuild the session record that gets stored in $env.SALESFORCE
Usage
build-session <session_id> <instance> --version <string> --domain <string> --auth-type <string> --refresh-token <any> --issued-at <any>
Parameters
session_id <string>instance <string>
Flags
--version <string>- (default: '64.0')
--domain <string>- (default: 'login')
--auth-type <string>- (default: 'direct')
--refresh-token <any>- OAuth refresh token, if the flow returned one
--issued-at <any>- Token issue time (epoch millis string), if known
Input/output types
| input | output |
|---|---|
| any | any |
build-headers
InternalBuild standard Salesforce REST API headers
Usage
build-headers <session_id>
Parameters
session_id <string>
Input/output types
| input | output |
|---|---|
| any | any |
sf-call
InternalCentral HTTP helper for making Salesforce API calls. Returns the parsed response body (usually a record or table). Automatically handles error responses.
Usage
sf-call <method> <url> --data <any> --params <record>
Parameters
method <string>url <string>
Flags
--data <any>- Body for POST/PATCH/PUT requests
--params <record>- Query parameters for GET requests
Input/output types
| input | output |
|---|---|
| any | any |
sf-error
InternalRaise a structured Salesforce error based on status code.
Usage
sf-error <status> <url> <content>
Parameters
status <int>url <string>content <any>
Input/output types
| input | output |
|---|---|
| any | any |
b64url
InternalEncode a string or binary value as URL-safe, unpadded Base64 (RFC 7515) — the encoding required for JSON Web Token segments.
Usage
b64url
Input/output types
| input | output |
|---|---|
| any | string |
host-from-url
InternalExtract the instance host (e.g. mydomain.my.salesforce.com) from a URL such as an OAuth `instance_url` or a SOAP serverUrl.
Usage
host-from-url <url>
Parameters
url <string>
Input/output types
| input | output |
|---|---|
| any | any |
login-host
InternalResolve the OAuth login host used for the JWT `aud` claim and as the token endpoint host for the JWT and Device flows.
- If an explicit instance (My Domain) is given, use it.
- Otherwise fall back to test/login.salesforce.com based on the domain.
Usage
login-host <domain> <instance?>
Parameters
domain <string>instance <string>- (optional)
Input/output types
| input | output |
|---|---|
| any | any |
oauth-post
InternalPOST form-urlencoded parameters to a Salesforce OAuth token endpoint. Returns the full response as { status, body } without raising on errors, so callers (e.g. Device flow polling) can inspect expected error codes. `http post` form-encodes the record itself when given this content type.
Usage
oauth-post <token_url> <params>
Parameters
token_url <string>params <record>
Input/output types
| input | output |
|---|---|
| any | any |
sf-oauth-token
InternalRequest an OAuth access token, raising a structured error on failure. Used by the Client Credentials and JWT Bearer flows.
Usage
sf-oauth-token <token_url> <params>
Parameters
token_url <string>params <record>
Input/output types
| input | output |
|---|---|
| any | any |
sf-oauth-error
InternalRaise a structured error from a Salesforce OAuth token error response. The body is JSON like { error, error_description }, which `http post` may already have parsed into a record.
Usage
sf-oauth-error <status> <url> <content>
Parameters
status <int>url <string>content <any>
Input/output types
| input | output |
|---|---|
| any | any |
build-jwt-assertion
InternalBuild and RS256-sign a JWT assertion for the OAuth 2.0 JWT Bearer flow. iss = consumer key (client id), sub = username to impersonate, aud = login host URL, exp = now + 3 minutes. Signs `header.claims` with the RSA private key at key_path via openssl.
Usage
build-jwt-assertion <client_id> <username> <audience> <key_path>
Parameters
client_id <string>username <string>audience <string>key_path <path>
Input/output types
| input | output |
|---|---|
| any | any |
validate-soql
InternalValidate a SOQL query string for common structural issues. Raises a descriptive error if problems are found. Call this before sending a SOQL query to the Salesforce API.
Usage
validate-soql <soql>
Parameters
soql <string>
Input/output types
| input | output |
|---|---|
| any | any |
to-sf-datetime
InternalConvert an ISO 8601 date string or datetime to Salesforce-compatible format.
Usage
to-sf-datetime <dt>
Parameters
dt <any>
Input/output types
| input | output |
|---|---|
| any | any |
xml-find-text
InternalFind a specific XML element by tag name in a parsed XML tree. The XML tree is in Nushell's `from xml` format: { tag: "name", attributes: {...}, content: [...] } Returns the first matching element's text content, or null if not found.
Usage
xml-find-text <xml> <tag_name>
Parameters
xml <record>tag_name <string>
Input/output types
| input | output |
|---|---|
| any | any |
strip-attributes
InternalUsage
strip-attributes <value>
Parameters
value <any>
Input/output types
| input | output |
|---|---|
| any | any |
format-query-records
InternalUsage
format-query-records <records> <include_attributes>
Parameters
records <any>include_attributes <bool>
Input/output types
| input | output |
|---|---|
| any | any |
load-env-file
Loads environment variables from a file
Usage
load-env-file <path?>
Parameters
path <path>- (optional, default: '.env')
Input/output types
| input | output |
|---|---|
| any | any |
from kv
InternalParses `KEY=value` text into a record
Usage
from kv
Input/output types
| input | output |
|---|---|
| oneof<string, nothing> | record |