Skip to content

Add global describe and /limits REST endpoints - #18

Merged
razkevich merged 1 commit into
mainfrom
feat/global-describe-and-limits
Jul 25, 2026
Merged

razkevich merged 1 commit into
mainfrom
feat/global-describe-and-limits

Conversation

@razkevich

Copy link
Copy Markdown
Owner

Why

Salesforce clients typically call global describe (/sobjects) before they can offer an object picker or browse schema, and read /limits to show consumption. Neither was emulated, so those code paths 404'd and any tool exercising them couldn't be tested against sf-localstack.

Found while building a terminal UI over the Salesforce APIs: object/field discovery was the first thing that couldn't run locally.

What

Endpoint Behavior
GET /services/data/{apiVersion}/sobjects Global describe. Baseline standard objects (Account, Contact, Lead, Opportunity, User, Organization) plus every object currently in org state. Includes keyPrefix, custom, queryable and the urls block (sobject, describe, rowTemplate) that clients follow to per-object describes.
GET /services/data/{apiVersion}/limits Max/Remaining for the commonly displayed limits. Record count drives DataStorageMB and API consumption so the numbers track org state; Remaining is floored at 0.

Both are read-only, mounted on the existing /services/data and /data prefixes, and reflect the requested apiVersion in generated URLs instead of hardcoding a version.

Tests

5 new controller tests in OrgApiControllerTest: baseline objects with URLs, custom objects appearing after a create, apiVersion reflected in URLs, limits shape, and Remaining staying non-negative as records accumulate.

Full suite green: 194 tests, 0 failures.

Not included

ApexLog and DeployRequest (Tooling) are still unemulated — they need new domain entities and seed data, so they're better as separate changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N7CzVfJLuZjCJeAnVqJ7HJ

Two org-level REST resources were missing, so tools that discover an org's
shape before doing anything else could not work against the emulator:

- GET /services/data/{apiVersion}/sobjects — global describe. Lists the
  baseline standard objects plus every object currently present in org
  state, with keyPrefix, custom flag and the urls block clients follow to
  reach per-object describes. The requested apiVersion is reflected in
  those URLs rather than hardcoded.
- GET /services/data/{apiVersion}/limits — Max/Remaining for the limits
  clients commonly display. Derived from org state (record count drives
  DataStorageMB and API consumption) so it stays consistent with whatever
  the emulator holds, and Remaining never goes negative.

Both are read-only and mounted on the existing /services/data and /data
prefixes. 5 controller tests added; full suite green (194 tests).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
razkevich added a commit to razkevich/sf9s that referenced this pull request Jul 25, 2026
…elect

The new tier runs the TUI against a live sf-localstack instance (a real
Salesforce API emulator) behind a build tag, skipping when unreachable so
'go test ./...' stays hermetic. It immediately earned its keep:

Selecting an org routed through an async message, so keystrokes typed
right after enter were still delivered to the orgs view and silently
dropped — 'SELECT ...' became 'ELECT ...'. Our own mock matched any query
containing 'FROM Account', so it never noticed. Selection is now applied
synchronously, the mock rejects statements a real org would reject, and a
regression test types immediately after selecting.

sf-localstack needed /sobjects (global describe) and /limits to serve this
suite; both are proposed upstream in razkevich/sf-localstack#18.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@razkevich
razkevich merged commit 16d32a3 into main Jul 25, 2026
2 checks passed
@razkevich
razkevich deleted the feat/global-describe-and-limits branch July 25, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant