Skip to content

Releases

v0.6.0

Choose a tag to compare

@github-actions github-actions released this 17 Nov 15:29

Added

  • The docs now have an llms.txt index for coding agents. It lists every page with a summary and a link to its Markdown source, and the docs site serves it at /llms.txt. (#2)
  • esf.TokenProvider(get_token) is a login flow that calls your function for a token. The client calls it for the first request and once more after a 401, so you can reuse an existing login such as the Salesforce CLI (sf org display --json) or a token from a secrets manager. Concurrent 401 responses share one call, and AsyncSalesforce runs the function in a worker thread. (#4)
  • Agent skills ship with the library: esf-usage, esf-probe, esf-migrate, esf-testing and esf-debug. esf skills list, esf skills show NAME and esf skills install [NAME ...] [--dir DIR] [--force] copy them into .claude/skills (Claude Code) or .agents/skills (Codex). Run esf skills install --force again after you upgrade. See Coding agents.
  • sf.bulk.ingest(rows=..., columns=[...]) sets the CSV columns for dict rows that set different fields. Without it, the error for an extra field now names columns=.

Changed

  • The Apex REST guide and the esf migrate hint say that an unknown Apex REST path raises ApexError with status 404, not NotFound, and show how to map ApexError.status to an HTTP response.
  • esf migrate rewrites apexecute() to sf.apex.*, and a new bulk rule names the Bulk API 2.0 call for each Bulk v1 use. TODOs for session_id, sf_instance, toolingexecute and mdapi now name the 0.5 replacements.

Fixed

  • esf migrate no longer rewrites sf.bulk.<Obj>.query_all() as a REST query_iter() call.

Install: pip install even-simpler-salesforce==0.6.0

v0.5.1

Choose a tag to compare

@github-actions github-actions released this 17 Nov 10:44

Fixed

  • The PyPI page now renders the README correctly: the project-status note no longer shows a stray [!NOTE] marker, and links to the changelog, contributing guide and licence work. The README also lists the pubsub and migrate extras, and the docs no longer tell you to install with pip install --pre.

Install: pip install even-simpler-salesforce==0.5.1

v0.5.0

Choose a tag to compare

@github-actions github-actions released this 16 Nov 13:32

Added

  • A tutorial in the docs: build a small leads API with FastAPI in about 25 minutes, from the first call to tests with the fake. (#34)
  • A new esf.ApexActionFailed error (a RecordError) is raised for APEX_FAILED, the code Salesforce returns when an Apex invocable action throws an uncaught exception. Its hint points to the Apex debug log. Code that catches esf.RecordError keeps working.
  • Add sf.graphql(query, variables) for the Salesforce GraphQL API. It returns the data member and raises esf.GraphQLError (with .data for partial data) when the response has an errors array, even with 200 OK. sf.graphql_iter(query, variables, path=...) yields every node of a connection by following pageInfo.endCursor, and FakeSalesforce.on_graphql() scripts answers in tests.
  • Add sf.metadata.quick_deploy(validated_id), which deploys a succeeded validation without running its tests again (POST metadata/deployRequest/{id} with validatedDeployRequestId), and sf.metadata.cancel_deploy(id) (PATCH with deployResult.status=Canceling). Neither is resent once it may have reached Salesforce. Canceling a deployment that is already finalizing (API 65.0 and later) raises the new esf.DeployNotCancelable. FakeSalesforce.metadata supports both.
  • Add sf.metadata for the Metadata API. deploy() takes zip bytes, a zip file or a folder (zipped on the fly, symlinks must stay inside it) and sends metadata/deployRequest. deploy_status(id, wait=True) polls until the deployment is done, and DeployResult.raise_for_errors() raises esf.DeployFailed. retrieve(), list_metadata() and describe_metadata() use the SOAP Metadata API with the OAuth token; retrieve(extract_to=...) refuses zip entries that would escape the folder. Deploy and retrieve are never resent once they may have reached Salesforce, and waits end with esf.MetadataTimeout. FakeSalesforce.metadata, fake.on_deploy() and fake.add_metadata() support tests.
  • Add sf.reports.recent(): the reports the user viewed most recently (GET analytics/reports, at most 200). To find any report, query the Report object with SOQL. FakeSalesforce lists the scripted reports.
  • Add sf.reports for the Reports and Dashboards REST API: run reports with or without filters, run slow reports asynchronously and wait with instance(), and read or refresh dashboards. ReportResult.rows() and summary_rows() turn fact maps into dicts, and FakeSalesforce scripts reports with fake.on_report() and dashboards with fake.on_dashboard(). New errors: ReportRunFailed and ReportTimeout.
  • Added default_namespace= to AsyncSalesforce and Salesforce. It sends defaultNamespace=<ns> in Sforce-Call-Options (with client= when client_name is set), so code can name a managed package's fields without the prefix. Salesforce also leaves the prefix out of the field names it returns, so dict keys change.
  • Added esf.SalesforceWarning. When Salesforce sends a Warning response header (for example for a deprecated API version), the client warns once per distinct text per client family, and the sf.request event has a new sf_warning field.
  • Added update_mru= to AsyncSalesforce and Salesforce. update_mru=False sends Sforce-Mru: updateMru=false on sf.sobject(...) create, get, get-by-external-id, update and upsert, so an integration doesn't fill the user's Recently Viewed list. It needs api_version 60.0 or newer.
  • Collections sf.request events carry records_failed, and the capture() roll-up has sf_records_failed, so partial failures are visible in logs even when raise_for_errors() is never called.
  • Core layer for 0.1: typed exception hierarchy, client configuration objects, result models, and pure (no-I/O) helpers for SOQL quoting, query cursors, limit-header parsing, error classification and retry decisions.
  • Documentation for 0.1: a rewritten README and a documentation site covering getting started, Salesforce setup (External Client Apps), each login flow, token stores (with the durable-store contract and SQLite, SQLAlchemy and Redis example stores), records, query and search, Collections, raw requests, errors, usage and budgets, logging, performance, testing, the esf CLI, migrating from simple-salesforce, an API reference and ADRs 0002–0011. Every Python example in docs/ and README.md runs in CI (tests/docs), and the docs build is strict about broken links. Public members that had no docstring now have one.
  • Every error has docs_url, a link to its entry on the new Troubleshooting section of the Errors page, and some have a hint with the likely fix: the closest field names for an InvalidField (from the cached describe only, never an extra API call), and hints for INVALID_SESSION_ID after a refresh, API_DISABLED_FOR_ORG, REQUEST_LIMIT_EXCEEDED and a query with an unescaped quote. Both are added to str(error), survive pickling, and esf prints them on their own lines.
  • Login flows accept an Experience Cloud site URL with a path prefix as domain=, such as https://acme.my.site.com/partners; the client calls the authorize, token, revoke and introspect endpoints under that URL, and JwtBearer uses the site URL as the aud claim. ClientCredentials still needs the My Domain URL.
  • New Bulk API 2.0 job handles for long-running work. sf.bulk.start_query() creates a query job and returns an esf.AsyncQueryJob (esf.QueryJob) at once, with id, info, refresh(), wait(), abort(), rows(parallel_downloads=) and pages(locator=, max_records=). pages() yields an esf.AsyncResultPage (esf.ResultPage) with locator, next_locator and size, so a download can resume from a saved locator. sf.bulk.query_job(job_id) and sf.bulk.ingest_job(job_ids) open a job again by its ids, for example in a worker. New esf.BulkJobNotComplete for results asked for before a query job is JobComplete. FakeSalesforce supports all of it.
  • New esf commands: esf describe <sObject> prints each field's type, length, whether it is required and its picklist values; esf request <METHOD> <path> [--json BODY] [--param KEY=VALUE] calls any REST resource through sf.request; and esf generate models <sObject>... [--out FILE] [--pydantic] writes one TypedDict (or pydantic model) per sObject from its describe, for use with model=.
  • New private_key_passphrase= on esf.JwtBearer for encrypted PEM keys. The client decrypts the key locally when you create the object and never sends, logs or shows the passphrase.
  • New sf.bulk for Bulk API 2.0. ingest() loads rows given as dicts, a CSV path or CSV bytes, streamed and split into jobs of at most 100 MB; None sets null and a missing key leaves a field unchanged. The returned job has wait(poll=esf.Backoff(...), timeout=...), info, abort(), successful_results(), failed_results() (with esf.ErrorDetail) and unprocessed_records(). query() streams the rows of a query job, with include_deleted= and parallel_downloads=, and expand_compound_fields() swaps compound fields for their components. New esf.BulkJobState, esf.BulkJobInfo, esf.BulkFailure, esf.Backoff and esf.BulkJobTimeout; esf.BulkJobFailed is now raised. FakeSalesforce and AsyncFakeSalesforce support bulk.
  • New sf.composite for many REST calls in one round trip: builder() (Composite, up to 25 subrequests with ref("id") references and all_or_none), graph() (Composite Graph, each graph atomic), tree() (sObject Tree) and batch() (up to 25 independent subrequests). Every limit raises ValueError before anything is sent, and results are esf.CompositeResult, esf.SubrequestResult and esf.GraphResult, whose raise_for_errors() raises the usual typed error of the subrequest that caused the failure. FakeSalesforce and AsyncFakeSalesforce support composite.
  • New sf.files for Salesforce Files: upload() streams a path, bytes, a file object or an iterator as a multipart ContentVersion (up to 2 GB, never held in memory), with optional link_to, share_type and visibility. download() is a streaming context manager; also download_bytes(), download_attachment(), link() and list_for() (returns esf.FileLink). FakeSalesforce and AsyncFakeSalesforce support files, plus add_file() and file_content().
  • New sf.tooling.describe_global(cached=True) lists every Tooling API object (GET tooling/sobjects), cached like sf.describe_global(). FakeSalesforce and AsyncFakeSalesforce support it.
  • New sf.tooling for the Tooling API: query(), query_iter() and sobject(name) (the sf.sobject methods on tooling/ paths; sf.query_more() accepts Tooling cursors), run_tests_async(class_ids) and completions(type). execute_anonymous(code, capture_log=False) runs anonymous Apex and returns esf.AnonymousResult; it is never resent after it may have reached Salesforce. With capture_log=True the client creates a short-lived TraceFlag, returns the run's debug log in result.log and always deletes the flag. FakeSalesforce and AsyncFakeSalesforce support tooling, plus on_execute_anonymous() and set_completions().
  • New sf.ui reads the Salesforce User Interface API: record(), object_info(), picklist_values(), create_defaults(), clone_defaults(), list_views() and list_records(). Object info and picklist values are served from the describe cache, and FakeSalesforce has a matching fake.ui with set_list_view().
  • Org automation: sf.actions.standard(), flow() and apex() run invocable actions with one input or a list, and list() and describe() read them. sf.apex.get/post/put/patch/delete() call Apex REST classes and raise ApexError with the decoded body. esf generate actions writes typed stubs (dataclasses, or Pydantic models with --pydantic) that you run with sf.run(). `FakeSalesforce...
Read more

v0.1.0rc1

v0.1.0rc1 Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 09 Nov 15:56
12dc8fb

Added

  • Collections sf.request events carry records_failed, and the capture() roll-up has sf_records_failed, so partial failures are visible in logs even when raise_for_errors() is never called.
  • Core layer for 0.1: typed exception hierarchy, client configuration objects, result models, and pure (no-I/O) helpers for SOQL quoting, query cursors, limit-header parsing, error classification and retry decisions.
  • Documentation for 0.1: a rewritten README and a documentation site covering getting started, Salesforce setup (External Client Apps), each login flow, token stores (with the durable-store contract and SQLite, SQLAlchemy and Redis example stores), records, query and search, Collections, raw requests, errors, usage and budgets, logging, performance, testing, the esf CLI, migrating from simple-salesforce, an API reference and ADRs 0002–0011. Every Python example in docs/ and README.md runs in CI (tests/docs), and the docs build is strict about broken links. Public members that had no docstring now have one.
  • SOQL methods take values directly: sf.query("SELECT Id FROM Lead WHERE Email = {}", email) on query, query_iter, count, query_one, query_first and explain, quoted by the same code as esf.soql. New sf.query_one() (exactly one row: NotFound / MultipleMatches), sf.query_first() (first row or None), sf.explain() (query plans as QueryPlan, Salesforce Beta) and esf.flatten(row) (dotted lookup keys, flattened child rows) for CSV/DataFrame export; the CLI CSV output uses it.
  • UNSUPPORTED_API_VERSION maps to UnsupportedApiVersion. A caller's own Sforce-Call-Options header is merged with client_name instead of replacing it. with_auth(..., instance_url=); the parent's override is no longer inherited. sf.auth.revoke()/introspect() take auth= for tokens issued by another flow, and a StaticToken revoke really revokes.
  • client_name= client option: sends Sforce-Call-Options: client=<name> on every API call so admins can attribute API usage to the integration. sf.request() refuses a body on GET/HEAD.
  • esf migrate codemod ([migrate] extra, libcst): rewrites simple-salesforce code (sync and simple_salesforce.aio) to even-simpler-salesforce, marks what it can't with # esf-migrate: TODO|REVIEW[rule] comments, writes a JSON report (--report), and has a CI mode (--check). See the esf migrate docs page.
  • sf.instance_url: read-only base URL of the org (the instance_url= override, else the current token's instance; None before the first call). Replaces simple-salesforce's sf_instance / base_url for building links.

Changed

  • Documentation site restyled: a shadcn-inspired theme and a landing home page with a step-by-step quickstart example. (#13)
  • Retry safety (breaking): only reads are resent after a request may have reached Salesforce. update, delete, upsert (single and Collections) and code-running GETs (Apex REST, executeAnonymous) are no longer resent after a timeout, reset or 5xx, so triggers and flows never run twice and you never get a false Conflict/NotFound. Pass idempotent=True to sf.request() to opt in. Connect errors, row locks and Retry-After responses are still retried. See ADR 0001.
  • Docs landing page: FastAPI (async) and Flask (sync) examples side by side in an always-dark hero with readable code colours; the project status moved to Getting started. README: links to the docs, PyPI and changelog, badges, and a new tagline.
  • Docs: dark mode by default with a working light-mode toggle (the landing hero now follows it), JetBrains Mono for code, the theme's own header, and more readable body text.
  • Decimal values are encoded as exact JSON numbers instead of strings, with both JSON backends.

Fixed

  • Collections chunks that fail with an HTML 5xx (proxy/maintenance page) are marked outcome="unknown" (the request may have reached Salesforce). ESF_DEBUG=2 attempt events log the path template instead of the URL, so external id values stay out of logs. parameterized_search events carry soql_hash.
  • Collections: when one chunk's request fails, every other chunk still finishes and the call raises PartialFailure with the full ordered BatchResult (failed-chunk rows carry extended["outcome"] = "unknown" or "rejected"). Previously the async client raised immediately and left the other chunks writing in the background, and the results of committed chunks were lost. all_or_none=True errors now report the real HTTP method.
  • Concurrent callers whose requests were in flight when a token refresh failed now reliably share that failure (the refresh generation is captured before each request is sent).
  • JSON request bodies containing NaN or ±Infinity (as float or Decimal, at any depth) now raise ValueError before anything is sent, with both the stdlib and orjson backends. Previously orjson turned them into null and would have blanked the field in Salesforce.
  • Review fixes: cursors/ids/identifiers with a trailing newline are rejected (fullmatch); calls after close raise TransportError; InMemoryTokenStore.lock() is a real per-key lock; the limits poller lives on the client family and stops with the root client; NOT_FOUND on an sObject type raises InvalidType; SOSL FIND {...} terms are redacted from logs; sf.auth.refreshed is emitted after the refresh lock is released; client-credentials/JWT invalid_grant is an OAuthError, not ReauthorizationRequired; capture() counts only real retries; SOQL floats never use exponent notation; JwtBearer checks for the [jwt] extra at construction.
  • The api_version validation errors now quote DEFAULT_API_VERSION and the minimum supported version from their constants instead of hard-coded numbers that would go stale on the next version bump.
  • When many concurrent calls hit an expired session and the token refresh fails (for example invalid_client, invalid_grant or a 401 from the token endpoint), the callers that were already waiting for that refresh now all get the same typed error instead of each posting to the token endpoint again. Bad credentials no longer cause a burst of token requests that can trip Salesforce login rate limits. A call made after the failure still makes a fresh attempt.
  • RetryPolicy(respect_retry_after=False) now retries rate-limited calls with normal backoff instead of failing immediately. The ESF_DEBUG line prints whole thousands as 100k.
  • esf migrate review fixes: f-string-safe quoting (valid on Python 3.10/3.11) plus a compile() safety net; imports pruned only when unused (ignore[...] can no longer cause a NameError); markers for decorators, default args, class headers and match; ignore[rule] honoured for every sub-rule; write-mode report lines mapped with a line diff; leftover simple-salesforce imports marked; unconfirmed sObject-looking calls reported as not-a-client TODOs (upper-case fallback only in modules that use simple-salesforce); SalesforceExpiredSession is a TODO (not 1:1); describe_layout, headers=/raw_response= and keyword upsert(record_id=) are TODOs; method references rewritten; un-awaited async query_all is a TODO; esf name conflicts handled; stronger report redaction (multi-line strings, more secret names); faster file walk.
  • sf.request events report outcome="error" when a 2xx body that should be JSON is not; previously the event said ok and the error was raised afterwards.

Security

  • JwtBearer infers the sandbox audience from the parsed hostname (*.sandbox.my.salesforce.com), not a substring match, so a look-alike domain can't select the sandbox audience.
  • Salesforce error messages (which can quote record values) are no longer added to sf.request events unless ESF_DEBUG is set; the raised exception keeps the full message.
  • WebServerFlow now requires token_key= (one key per Salesforce identity). Without it every user of a multi-user app shared one token record.

Install: pip install even-simpler-salesforce==0.1.0rc1