@unchainedshop/core-countries
v4.6.2
Published
Country management module for the Unchained Engine
Readme
@unchainedshop/core-countries
Country management module for the Unchained Engine. Manages supported countries with ISO codes, currencies, and activation status.
Installation
npm install @unchainedshop/core-countriesUsage
import { configureCountriesModule } from '@unchainedshop/core-countries';
const countriesModule = await configureCountriesModule({ db });
// Create a country
const countryId = await countriesModule.create({
isoCode: 'CH',
defaultCurrencyCode: 'CHF',
});
// Find countries
const countries = await countriesModule.findCountries({ includeInactive: false });
// Get localized country name
const name = countriesModule.name(country, new Intl.Locale('en'));API Overview
Module Configuration
| Export | Description |
|--------|-------------|
| configureCountriesModule | Configure and return the countries module |
Queries
| Method | Description |
|--------|-------------|
| findCountry | Find country by ID or ISO code |
| findCountries | Find countries with filtering, sorting, and pagination |
| count | Count countries matching query |
| countryExists | Check if a country exists |
Mutations
| Method | Description |
|--------|-------------|
| create | Create a new country |
| update | Update an existing country |
| delete | Soft delete a country |
Helper Methods
| Method | Description |
|--------|-------------|
| name | Get localized country name using Intl.DisplayNames |
| flagEmoji | Get flag emoji for a country |
| isBase | Check if country is the base/system country |
Types
| Export | Description |
|--------|-------------|
| Country | Country document type |
| CountryQuery | Query parameters type |
| CountriesModule | Module interface type |
Events
| Event | Description |
|-------|-------------|
| COUNTRY_CREATE | Emitted when a country is created |
| COUNTRY_UPDATE | Emitted when a country is updated |
| COUNTRY_REMOVE | Emitted when a country is removed |
License
EUPL-1.2
