File: util.nu 1 exported command 17 internal commands

build-session

Internal

Build 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

inputoutput
anyany

build-headers

Internal

Build standard Salesforce REST API headers

Usage

build-headers <session_id>

Parameters

session_id <string>

Input/output types

inputoutput
anyany

sf-call

Internal

Central 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

inputoutput
anyany

sf-error

Internal

Raise a structured Salesforce error based on status code.

Usage

sf-error <status> <url> <content>

Parameters

status <int>
url <string>
content <any>

Input/output types

inputoutput
anyany

b64url

Internal

Encode 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

inputoutput
anystring

host-from-url

Internal

Extract 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

inputoutput
anyany

login-host

Internal

Resolve 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

inputoutput
anyany

oauth-post

Internal

POST 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

inputoutput
anyany

sf-oauth-token

Internal

Request 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

inputoutput
anyany

sf-oauth-error

Internal

Raise 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

inputoutput
anyany

build-jwt-assertion

Internal

Build 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

inputoutput
anyany

validate-soql

Internal

Validate 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

inputoutput
anyany

to-sf-datetime

Internal

Convert an ISO 8601 date string or datetime to Salesforce-compatible format.

Usage

to-sf-datetime <dt>

Parameters

dt <any>

Input/output types

inputoutput
anyany

xml-find-text

Internal

Find 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

inputoutput
anyany

strip-attributes

Internal

Usage

strip-attributes <value>

Parameters

value <any>

Input/output types

inputoutput
anyany

format-query-records

Internal

Usage

format-query-records <records> <include_attributes>

Parameters

records <any>
include_attributes <bool>

Input/output types

inputoutput
anyany

load-env-file

Loads environment variables from a file

Usage

load-env-file <path?>

Parameters

path <path>
(optional, default: '.env')

Input/output types

inputoutput
anyany

from kv

Internal

Parses `KEY=value` text into a record

Usage

from kv

Input/output types

inputoutput
oneof<string, nothing>record