Add a pseudo local data-store implementation for development mode so local runtimes do not fail when DynamoDB-backed MRT data store is unavailable.
This behavior should be activated through the existing package export condition:
@salesforce/mrt-utilities/data-store+--conditions development
The pseudo local implementation must read default entry values from environment variables (as implied by the provided prototype):
SFNEXT_DATA_STORE_DEFAULTS(JSON object map of key -> value object)SFNEXT_DATA_STORE_WARN_ON_MISSING("false"disables warnings; default is warning enabled)
./data-storealready has adevelopmentexport condition inpackage.json, but it currently points tosrc.- Desired update: point
developmentto a builtdistpseudo-local data-store output. - Current
DataStoreimplementation is DynamoDB-based and throwsDataStoreUnavailableErrorwhen required MRT environment variables are missing. - Existing tests primarily validate production/DynamoDB behavior.
Create two implementation modules:
- Production implementation (existing behavior)
- DynamoDB-backed
- Preserves existing errors:
DataStoreUnavailableErrorDataStoreNotFoundErrorDataStoreServiceError
- Development implementation (new behavior)
- No AWS dependency
- Uses local defaults from env var JSON
- Warns once per missing key (configurable)
- Uses strict parity with production semantics by default for missing keys (throws not-found)
- Optional lenient mode can be introduced as explicit opt-in for
{}fallback during local experimentation
Keep consumer import surface unchanged:
DataStore.getDataStore()DataStore#isDataStoreAvailable()DataStore#getEntry(key)- Existing error classes remain exported
This allows existing projects to adopt dev behavior without refactoring imports.
Use conditional exports to load the development implementation for local dev from built artifacts:
development-> built dev pseudo-local data-store module indistimport/require-> production built outputs indist
- Parse as JSON object.
- Expected shape:
{ "<entry-key>": { ...objectValue } }
- On invalid JSON:
- fall back to empty defaults
- warn once with clear message
- If unset: warnings enabled
- If set to
"false"(case-insensitive): disable missing-key warnings - Any other value: warnings enabled
- If key exists in parsed defaults and value is object: return that value.
- If key missing or invalid value type:
- by default, throw
DataStoreNotFoundError(production parity) - optionally warn once for that key before throwing
- optional future opt-in lenient mode may return
{}instead (must be off by default)
- by default, throw
Add/adjust tests to cover both modes:
- Production tests
- Keep current behavior assertions unchanged.
- Development tests
- Reads defaults from
SFNEXT_DATA_STORE_DEFAULTS - Throws
DataStoreNotFoundErrorwhen key is absent (default behavior) - Warns once per missing key when warnings enabled
- Does not warn when
SFNEXT_DATA_STORE_WARN_ON_MISSING=false - Handles invalid JSON safely
- (If lenient mode is added) returns
{}only when explicitly enabled
- Reads defaults from
Update packages/mrt-utilities/README.md (or docs page if preferred) with:
- How to enable dev behavior (
node --conditions development) - Env var configuration examples for default data-store values
- Differences between dev and production data-store semantics
- Add a new dev data-store module in
src/data-store/. - Move/keep current DynamoDB implementation as production module.
- Ensure build output emits both implementations to
dist(esm/cjs + types). - Update
package.jsonexports sodevelopmentresolves to the built dev pseudo-local module indist(notsrc), whileimport/requirecontinue resolving to production built outputs. - Add development-focused tests.
- Run validation:
pnpm --filter @salesforce/mrt-utilities run test:agentpnpm --filter @salesforce/mrt-utilities run lint:agentpnpm --filter @salesforce/mrt-utilities run typecheck:agent
- Add a changeset for
@salesforce/mrt-utilitiesif this is considered user-facing behavior.
- Strict production parity in dev is the default to avoid masking missing-key issues.
- Any lenient
{}fallback behavior must be explicit opt-in and clearly documented. - Existing export stripping behavior is already understood and is not changed by this plan.
- Local development using
--conditions developmentno longer fails due to missing DynamoDB/MRT runtime vars. - Dev data-store entries are sourced from
SFNEXT_DATA_STORE_DEFAULTS. - Missing-key behavior is predictable and configurable via
SFNEXT_DATA_STORE_WARN_ON_MISSING. - Production behavior and API remain backward-compatible.
- No breaking public interface changes: existing import paths, exported symbols, and type surface for
@salesforce/mrt-utilitiesand@salesforce/mrt-utilities/data-storeremain intact (except correcting thedevelopmentexport target to builtdistoutput). - Default dev missing-key semantics match production (
DataStoreNotFoundError), with no implicit{}fallback.