Repository navigation
Releases
Releases · Uttsavv/even-simpler-salesforce
v0.6.0
Added
- The docs now have an
llms.txtindex 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 a401, so you can reuse an existing login such as the Salesforce CLI (sf org display --json) or a token from a secrets manager. Concurrent401responses share one call, andAsyncSalesforceruns the function in a worker thread. (#4)- Agent skills ship with the library:
esf-usage,esf-probe,esf-migrate,esf-testingandesf-debug.esf skills list,esf skills show NAMEandesf skills install [NAME ...] [--dir DIR] [--force]copy them into.claude/skills(Claude Code) or.agents/skills(Codex). Runesf skills install --forceagain 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 namescolumns=.
Changed
- The Apex REST guide and the
esf migratehint say that an unknown Apex REST path raisesApexErrorwith status 404, notNotFound, and show how to mapApexError.statusto an HTTP response. esf migraterewritesapexecute()tosf.apex.*, and a newbulkrule names the Bulk API 2.0 call for each Bulk v1 use. TODOs forsession_id,sf_instance,toolingexecuteandmdapinow name the 0.5 replacements.
Fixed
esf migrateno longer rewritessf.bulk.<Obj>.query_all()as a RESTquery_iter()call.
Install: pip install even-simpler-salesforce==0.6.0
v0.5.1
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 thepubsubandmigrateextras, and the docs no longer tell you to install withpip install --pre.
Install: pip install even-simpler-salesforce==0.5.1
v0.5.0
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.ApexActionFailederror (aRecordError) is raised forAPEX_FAILED, the code Salesforce returns when an Apex invocable action throws an uncaught exception. Its hint points to the Apex debug log. Code that catchesesf.RecordErrorkeeps working. - Add
sf.graphql(query, variables)for the Salesforce GraphQL API. It returns thedatamember and raisesesf.GraphQLError(with.datafor partial data) when the response has anerrorsarray, even with200 OK.sf.graphql_iter(query, variables, path=...)yields every node of a connection by followingpageInfo.endCursor, andFakeSalesforce.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}withvalidatedDeployRequestId), andsf.metadata.cancel_deploy(id)(PATCHwithdeployResult.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 newesf.DeployNotCancelable.FakeSalesforce.metadatasupports both. - Add
sf.metadatafor the Metadata API.deploy()takes zip bytes, a zip file or a folder (zipped on the fly, symlinks must stay inside it) and sendsmetadata/deployRequest.deploy_status(id, wait=True)polls until the deployment is done, andDeployResult.raise_for_errors()raisesesf.DeployFailed.retrieve(),list_metadata()anddescribe_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 withesf.MetadataTimeout.FakeSalesforce.metadata,fake.on_deploy()andfake.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 theReportobject with SOQL.FakeSalesforcelists the scripted reports. - Add
sf.reportsfor the Reports and Dashboards REST API: run reports with or without filters, run slow reports asynchronously and wait withinstance(), and read or refresh dashboards.ReportResult.rows()andsummary_rows()turn fact maps into dicts, andFakeSalesforcescripts reports withfake.on_report()and dashboards withfake.on_dashboard(). New errors:ReportRunFailedandReportTimeout. - Added
default_namespace=toAsyncSalesforceandSalesforce. It sendsdefaultNamespace=<ns>inSforce-Call-Options(withclient=whenclient_nameis 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 aWarningresponse header (for example for a deprecated API version), the client warns once per distinct text per client family, and thesf.requestevent has a newsf_warningfield. - Added
update_mru=toAsyncSalesforceandSalesforce.update_mru=FalsesendsSforce-Mru: updateMru=falseonsf.sobject(...)create, get, get-by-external-id, update and upsert, so an integration doesn't fill the user's Recently Viewed list. It needsapi_version60.0 or newer. - Collections
sf.requestevents carryrecords_failed, and thecapture()roll-up hassf_records_failed, so partial failures are visible in logs even whenraise_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
esfCLI, migrating from simple-salesforce, an API reference and ADRs 0002–0011. Every Python example indocs/andREADME.mdruns 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 ahintwith the likely fix: the closest field names for anInvalidField(from the cached describe only, never an extra API call), and hints forINVALID_SESSION_IDafter a refresh,API_DISABLED_FOR_ORG,REQUEST_LIMIT_EXCEEDEDand a query with an unescaped quote. Both are added tostr(error), survive pickling, andesfprints them on their own lines. - Login flows accept an Experience Cloud site URL with a path prefix as
domain=, such ashttps://acme.my.site.com/partners; the client calls the authorize, token, revoke and introspect endpoints under that URL, andJwtBeareruses the site URL as theaudclaim.ClientCredentialsstill 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 anesf.AsyncQueryJob(esf.QueryJob) at once, withid,info,refresh(),wait(),abort(),rows(parallel_downloads=)andpages(locator=, max_records=).pages()yields anesf.AsyncResultPage(esf.ResultPage) withlocator,next_locatorandsize, so a download can resume from a saved locator.sf.bulk.query_job(job_id)andsf.bulk.ingest_job(job_ids)open a job again by its ids, for example in a worker. Newesf.BulkJobNotCompletefor results asked for before a query job isJobComplete.FakeSalesforcesupports all of it. - New
esfcommands: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 throughsf.request; andesf generate models <sObject>... [--out FILE] [--pydantic]writes oneTypedDict(or pydantic model) per sObject from its describe, for use withmodel=. - New
private_key_passphrase=onesf.JwtBearerfor encrypted PEM keys. The client decrypts the key locally when you create the object and never sends, logs or shows the passphrase. - New
sf.bulkfor 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;Nonesets null and a missing key leaves a field unchanged. The returned job haswait(poll=esf.Backoff(...), timeout=...),info,abort(),successful_results(),failed_results()(withesf.ErrorDetail) andunprocessed_records().query()streams the rows of a query job, withinclude_deleted=andparallel_downloads=, andexpand_compound_fields()swaps compound fields for their components. Newesf.BulkJobState,esf.BulkJobInfo,esf.BulkFailure,esf.Backoffandesf.BulkJobTimeout;esf.BulkJobFailedis now raised.FakeSalesforceandAsyncFakeSalesforcesupportbulk. - New
sf.compositefor many REST calls in one round trip:builder()(Composite, up to 25 subrequests withref("id")references andall_or_none),graph()(Composite Graph, each graph atomic),tree()(sObject Tree) andbatch()(up to 25 independent subrequests). Every limit raisesValueErrorbefore anything is sent, and results areesf.CompositeResult,esf.SubrequestResultandesf.GraphResult, whoseraise_for_errors()raises the usual typed error of the subrequest that caused the failure.FakeSalesforceandAsyncFakeSalesforcesupportcomposite. - New
sf.filesfor 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 optionallink_to,share_typeandvisibility.download()is a streaming context manager; alsodownload_bytes(),download_attachment(),link()andlist_for()(returnsesf.FileLink).FakeSalesforceandAsyncFakeSalesforcesupportfiles, plusadd_file()andfile_content(). - New
sf.tooling.describe_global(cached=True)lists every Tooling API object (GET tooling/sobjects), cached likesf.describe_global().FakeSalesforceandAsyncFakeSalesforcesupport it. - New
sf.toolingfor the Tooling API:query(),query_iter()andsobject(name)(thesf.sobjectmethods ontooling/paths;sf.query_more()accepts Tooling cursors),run_tests_async(class_ids)andcompletions(type).execute_anonymous(code, capture_log=False)runs anonymous Apex and returnsesf.AnonymousResult; it is never resent after it may have reached Salesforce. Withcapture_log=Truethe client creates a short-livedTraceFlag, returns the run's debug log inresult.logand always deletes the flag.FakeSalesforceandAsyncFakeSalesforcesupporttooling, pluson_execute_anonymous()andset_completions(). - New
sf.uireads the Salesforce User Interface API:record(),object_info(),picklist_values(),create_defaults(),clone_defaults(),list_views()andlist_records(). Object info and picklist values are served from the describe cache, andFakeSalesforcehas a matchingfake.uiwithset_list_view(). - Org automation:
sf.actions.standard(),flow()andapex()run invocable actions with one input or a list, andlist()anddescribe()read them.sf.apex.get/post/put/patch/delete()call Apex REST classes and raiseApexErrorwith the decoded body.esf generate actionswrites typed stubs (dataclasses, or Pydantic models with--pydantic) that you run withsf.run(). `FakeSalesforce...
v0.1.0rc1
Added
- Collections
sf.requestevents carryrecords_failed, and thecapture()roll-up hassf_records_failed, so partial failures are visible in logs even whenraise_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
esfCLI, migrating from simple-salesforce, an API reference and ADRs 0002–0011. Every Python example indocs/andREADME.mdruns 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)onquery,query_iter,count,query_one,query_firstandexplain, quoted by the same code asesf.soql. Newsf.query_one()(exactly one row:NotFound/MultipleMatches),sf.query_first()(first row orNone),sf.explain()(query plans asQueryPlan, Salesforce Beta) andesf.flatten(row)(dotted lookup keys, flattened child rows) for CSV/DataFrame export; the CLI CSV output uses it. UNSUPPORTED_API_VERSIONmaps toUnsupportedApiVersion. A caller's ownSforce-Call-Optionsheader is merged withclient_nameinstead of replacing it.with_auth(..., instance_url=); the parent's override is no longer inherited.sf.auth.revoke()/introspect()takeauth=for tokens issued by another flow, and aStaticTokenrevoke really revokes.client_name=client option: sendsSforce-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 migratecodemod ([migrate]extra, libcst): rewrites simple-salesforce code (sync andsimple_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 theesf migratedocs page.sf.instance_url: read-only base URL of the org (theinstance_url=override, else the current token's instance;Nonebefore the first call). Replaces simple-salesforce'ssf_instance/base_urlfor 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 falseConflict/NotFound. Passidempotent=Truetosf.request()to opt in. Connect errors, row locks andRetry-Afterresponses 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.
Decimalvalues 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=2attempt events log the path template instead of the URL, so external id values stay out of logs.parameterized_searchevents carrysoql_hash. - Collections: when one chunk's request fails, every other chunk still finishes and the call raises
PartialFailurewith the full orderedBatchResult(failed-chunk rows carryextended["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=Trueerrors 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
floatorDecimal, at any depth) now raiseValueErrorbefore anything is sent, with both the stdlib and orjson backends. Previously orjson turned them intonulland 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_FOUNDon an sObject type raisesInvalidType; SOSLFIND {...}terms are redacted from logs;sf.auth.refreshedis emitted after the refresh lock is released; client-credentials/JWTinvalid_grantis anOAuthError, notReauthorizationRequired;capture()counts only real retries; SOQL floats never use exponent notation; JwtBearer checks for the[jwt]extra at construction. - The
api_versionvalidation errors now quoteDEFAULT_API_VERSIONand 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_grantor 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. TheESF_DEBUGline prints whole thousands as100k.esf migratereview 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 andmatch;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 asnot-a-clientTODOs (upper-case fallback only in modules that use simple-salesforce);SalesforceExpiredSessionis a TODO (not 1:1);describe_layout,headers=/raw_response=and keywordupsert(record_id=)are TODOs; method references rewritten; un-awaited asyncquery_allis a TODO;esfname conflicts handled; stronger report redaction (multi-line strings, more secret names); faster file walk.sf.requestevents reportoutcome="error"when a 2xx body that should be JSON is not; previously the event saidokand 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.requestevents unlessESF_DEBUGis set; the raised exception keeps the full message. WebServerFlownow requirestoken_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