@unimart/firebase-config
v0.2.0
Published
Shared TypeScript definitions and validators for Unimart Firebase Remote Config values.
Maintainers
Readme
Firebase Remote Config Tracker
This repository serves as a centralized source of truth for Firebase Remote Config values used across our applications. It provides version control, change history, and documentation for all remote configuration parameters.
Purpose
Firebase Remote Config is a powerful tool for dynamically updating application behavior without requiring app updates. However, its built-in version tracking has limitations. This repository addresses those limitations by:
- Version Control: Tracking all config changes with proper Git history
- Documentation: Providing context and documentation for each parameter
- Cross-Platform Consistency: Ensuring consistent configuration across mobile, web, and other platforms
- Change Review: Enabling proper review of configuration changes through pull requests
- Rollback Capability: Making it easy to revert to previous configurations
Repository Structure
├── remote_config/
│ ├── unimartAppSettings/
│ ├── unimartAppModals/
│ ├── storefrontGlobalSettings/
│ ├── deliveryAppSettings/
│ └── appMinimumVersion/
├── src/
│ ├── types/ # Source of truth for published TypeScript definitions
│ ├── validators.ts # Runtime validation helpers
│ └── generated/schemas/ # Generated JSON Schemas
├── scripts/
└── README.mdConfiguration Groups
Each folder represents a logical grouping of configuration parameters, for example:
- unimartAppSettings: Contains settings for the Unimart applications across different markets
default.json: Costa Rica (CR) market configurationHydrogenGT.json: Guatemala (GT) market configuration
- unimartAppModals: Payment, shipping, and installment modal/banner content
- storefrontGlobalSettings: Storefront-wide product spec settings
- deliveryAppSettings: Settings consumed by the delivery app
Workflow
- Exporting: When changes are made in Firebase Console, manually copy the updated JSON to this repository
- Changing: Make changes to the JSON files in this repository
- Validating: Run
pnpm testto verify JSON values still match the TypeScript definitions - Reviewing: Create pull requests for changes to be reviewed
- Importing: After approval, manually update Firebase Remote Config with the approved changes
Validation
Install dependencies once:
pnpm installValidate all JSON-backed Remote Config groups:
pnpm testThis runs:
pnpm run generate:schemasto generate JSON Schemas from the TypeScript definitions insrc/types.node scripts/validate-remote-config.mjsto validate everyremote_config/<group>/*.jsonfile against the matching schema.node scripts/check-negative-validation.mjsto confirm a known bad fixture is rejected.
If a config shape changes intentionally, update the TypeScript definition and the JSON value in the same pull request. Validation fails on missing required fields, wrong value types, invalid string unions, and unexpected properties.
Shared Package
This repo publishes shared definitions and runtime validators as:
@unimart/firebase-configBuild the package locally:
pnpm run buildConsume it from another app:
import {
type UnimartAppSettings,
validateUnimartAppSettings
} from '@unimart/firebase-config';
const result = validateUnimartAppSettings(JSON.parse(remoteConfigValue));
if (!result.valid) {
console.error(result.errors);
}For dynamic config keys, use the generic validator:
import { validateRemoteConfigValue } from '@unimart/firebase-config';
const result = validateRemoteConfigValue('unimartAppSettings', value);Runtime validators are exported for consumers that need to validate parsed Remote Config values. The generated schemas are packaged as internal validator assets, but they are not part of the public export map.
Releasing
Versioning is manual semver, starting at 0.1.0.
- Patch: documentation, schema comments, or backwards-compatible validator/package fixes
- Minor: new config groups, new optional fields, or backwards-compatible type additions
- Major: required field changes, removed fields, renamed config keys, or stricter validation that can break consumers
Publishing is guarded by the prepublishOnly branch check and the GitHub release workflow. Releases should be created from main, matching the workflow used by the existing @unimart/unimart-locations-react package.
This package is public to avoid private npm package billing. Published output is intentionally minimal: only build artifacts are packed, emitted comments are stripped, and raw JSON Schemas are not exposed as public package exports. Type names and config field names remain visible because consumers need them for TypeScript type safety.
Best Practices
- Document the purpose of each parameter in comments or documentation files
- Use semantic versioning for major configuration changes
- Include testing instructions for significant changes
- Tag important releases for easy reference
- Keep configuration structure consistent across different environments
