@unchainedshop/core-countries 4.8.29 → 5.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +11 -58
  2. package/package.json +8 -5
package/README.md CHANGED
@@ -13,72 +13,25 @@ npm install @unchainedshop/core-countries
13
13
 
14
14
  ## Usage
15
15
 
16
- ```typescript
17
- import { configureCountriesModule } from '@unchainedshop/core-countries';
16
+ The platform initializes this module as `platform.unchainedAPI.modules.countries`.
18
17
 
19
- const countriesModule = await configureCountriesModule({ db });
18
+ ```typescript
19
+ const { countries } = platform.unchainedAPI.modules;
20
20
 
21
- // Create a country
22
- const countryId = await countriesModule.create({
21
+ const countryId = await countries.create({
23
22
  isoCode: 'CH',
24
23
  defaultCurrencyCode: 'CHF',
24
+ isActive: true,
25
25
  });
26
-
27
- // Find countries
28
- const countries = await countriesModule.findCountries({ includeInactive: false });
29
-
30
- // Get localized country name
31
- const name = countriesModule.name(country, new Intl.Locale('en'));
26
+ const country = await countries.findCountry({ countryId });
27
+ if (country) {
28
+ const name = countries.name(country, new Intl.Locale('en'));
29
+ }
32
30
  ```
33
31
 
34
- ## API Overview
35
-
36
- ### Module Configuration
37
-
38
- | Export | Description |
39
- |--------|-------------|
40
- | `configureCountriesModule` | Configure and return the countries module |
41
-
42
- ### Queries
43
-
44
- | Method | Description |
45
- |--------|-------------|
46
- | `findCountry` | Find country by ID or ISO code |
47
- | `findCountries` | Find countries with filtering, sorting, and pagination |
48
- | `count` | Count countries matching query |
49
- | `countryExists` | Check if a country exists |
50
-
51
- ### Mutations
52
-
53
- | Method | Description |
54
- |--------|-------------|
55
- | `create` | Create a new country |
56
- | `update` | Update an existing country |
57
- | `delete` | Soft delete a country |
58
-
59
- ### Helper Methods
60
-
61
- | Method | Description |
62
- |--------|-------------|
63
- | `name` | Get localized country name using Intl.DisplayNames |
64
- | `flagEmoji` | Get flag emoji for a country |
65
- | `isBase` | Check if country is the base/system country |
66
-
67
- ### Types
68
-
69
- | Export | Description |
70
- |--------|-------------|
71
- | `Country` | Country document type |
72
- | `CountryQuery` | Query parameters type |
73
- | `CountriesModule` | Module interface type |
74
-
75
- ## Events
32
+ `create` returns a country ID. Configure currencies separately before assigning them to countries.
76
33
 
77
- | Event | Description |
78
- |-------|-------------|
79
- | `COUNTRY_CREATE` | Emitted when a country is created |
80
- | `COUNTRY_UPDATE` | Emitted when a country is updated |
81
- | `COUNTRY_REMOVE` | Emitted when a country is removed |
34
+ See the [module guide](https://docs.unchained.shop/platform-configuration/modules/countries), [public exports](src/countries-index.ts), and [module implementation](src/module/configureCountriesModule.ts) for queries, helpers, and events.
82
35
 
83
36
  ## License
84
37
 
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@unchainedshop/core-countries",
3
3
  "description": "Country management module for the Unchained Engine",
4
- "version": "4.8.29",
4
+ "version": "5.0.0-alpha.10",
5
+ "files": [
6
+ "lib"
7
+ ],
5
8
  "main": "lib/countries-index.js",
6
9
  "types": "lib/countries-index.d.ts",
7
10
  "type": "module",
@@ -35,12 +38,12 @@
35
38
  },
36
39
  "homepage": "https://github.com/unchainedshop/unchained#readme",
37
40
  "dependencies": {
38
- "@unchainedshop/events": "^4.8.27",
39
- "@unchainedshop/mongodb": "^4.8.27",
40
- "@unchainedshop/utils": "^4.8.27"
41
+ "@unchainedshop/events": "^5.0.0-alpha.10",
42
+ "@unchainedshop/mongodb": "^5.0.0-alpha.10",
43
+ "@unchainedshop/utils": "^5.0.0-alpha.10"
41
44
  },
42
45
  "devDependencies": {
43
46
  "@types/node": "^26.2.0",
44
- "typescript": "^5.8.3"
47
+ "typescript": "^6.0.3"
45
48
  }
46
49
  }