@unchainedshop/core-countries 3.0.0-rc9 → 3.0.0
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.
- package/lib/module/configureCountriesModule.d.ts +18 -18
- package/lib/module/configureCountriesModule.d.ts.map +1 -1
- package/lib/module/configureCountriesModule.js +2 -2
- package/lib/module/configureCountriesModule.js.map +1 -1
- package/package.json +5 -5
- package/src/module/configureCountriesModule.ts +32 -32
|
@@ -10,31 +10,31 @@ export type CountryQuery = {
|
|
|
10
10
|
includeInactive?: boolean;
|
|
11
11
|
queryString?: string;
|
|
12
12
|
};
|
|
13
|
-
export
|
|
14
|
-
|
|
13
|
+
export declare const buildFindSelector: ({ includeInactive, queryString }: CountryQuery) => {
|
|
14
|
+
isActive?: true;
|
|
15
|
+
$text?: any;
|
|
16
|
+
deleted?: Date;
|
|
17
|
+
};
|
|
18
|
+
export declare const configureCountriesModule: ({ db, migrationRepository, }: ModuleInput<Record<string, never>>) => Promise<{
|
|
19
|
+
count: (query: CountryQuery) => Promise<number>;
|
|
20
|
+
findCountry: ({ countryId, isoCode, }: {
|
|
15
21
|
countryId?: string;
|
|
16
22
|
isoCode?: string;
|
|
17
23
|
}) => Promise<Country>;
|
|
18
|
-
findCountries: (
|
|
24
|
+
findCountries: ({ limit, offset, sort, includeInactive, queryString, }: CountryQuery & {
|
|
19
25
|
limit?: number;
|
|
20
26
|
offset?: number;
|
|
21
27
|
sort?: Array<SortOption>;
|
|
22
28
|
}, options?: mongodb.FindOptions) => Promise<Array<Country>>;
|
|
23
|
-
|
|
24
|
-
countryExists: (params: {
|
|
29
|
+
countryExists: ({ countryId }: {
|
|
25
30
|
countryId: string;
|
|
26
31
|
}) => Promise<boolean>;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
export
|
|
35
|
-
isActive?: true;
|
|
36
|
-
$text?: any;
|
|
37
|
-
deleted?: Date;
|
|
38
|
-
};
|
|
39
|
-
export declare const configureCountriesModule: ({ db, migrationRepository, }: ModuleInput<Record<string, never>>) => Promise<CountriesModule>;
|
|
32
|
+
name(country: Country, language: string): string;
|
|
33
|
+
flagEmoji(country: Country): string;
|
|
34
|
+
isBase(country: Country): boolean;
|
|
35
|
+
create: (doc: Country) => Promise<string>;
|
|
36
|
+
update: (countryId: string, doc: Country) => Promise<string>;
|
|
37
|
+
delete: (countryId: string) => Promise<number>;
|
|
38
|
+
}>;
|
|
39
|
+
export type CountriesModule = Awaited<ReturnType<typeof configureCountriesModule>>;
|
|
40
40
|
//# sourceMappingURL=configureCountriesModule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureCountriesModule.d.ts","sourceRoot":"","sources":["../../src/module/configureCountriesModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG/E,OAAO,EAAiB,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAKjE,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,GAAG,eAAe,CAAC;AAEpB,MAAM,MAAM,YAAY,GAAG;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;
|
|
1
|
+
{"version":3,"file":"configureCountriesModule.d.ts","sourceRoot":"","sources":["../../src/module/configureCountriesModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG/E,OAAO,EAAiB,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAKjE,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,GAAG,eAAe,CAAC;AAEpB,MAAM,MAAM,YAAY,GAAG;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAIF,eAAO,MAAM,iBAAiB,qCAAmD,YAAY;eAC9D,IAAI;YAAU,GAAG;cAAY,IAAI;CAI/D,CAAC;AAEF,eAAO,MAAM,wBAAwB,iCAGlC,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;mBASZ,YAAY,KAAG,OAAO,CAAC,MAAM,CAAC;2CAQhD;QACD,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,KAAG,OAAO,CAAC,OAAO,CAAC;4EAWf,YAAY,GAAG;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;KAC1B,YACS,OAAO,CAAC,WAAW,KAC5B,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;mCAWW;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO,CAAC,OAAO,CAAC;kBAU/D,OAAO,YAAY,MAAM;uBAIpB,OAAO;oBAOV,OAAO;kBAIH,OAAO;wBAaD,MAAM,OAAO,OAAO;wBAWpB,MAAM;EAanC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC"}
|
|
@@ -23,10 +23,10 @@ export const configureCountriesModule = async ({ db, migrationRepository, }) =>
|
|
|
23
23
|
const countryCount = await Countries.countDocuments(buildFindSelector(query));
|
|
24
24
|
return countryCount;
|
|
25
25
|
},
|
|
26
|
-
findCountry: async ({ countryId, isoCode }) => {
|
|
26
|
+
findCountry: async ({ countryId, isoCode, }) => {
|
|
27
27
|
return Countries.findOne(countryId ? generateDbFilterById(countryId) : { isoCode });
|
|
28
28
|
},
|
|
29
|
-
findCountries: async ({ limit, offset, sort, includeInactive, queryString }, options) => {
|
|
29
|
+
findCountries: async ({ limit, offset, sort, includeInactive, queryString, }, options) => {
|
|
30
30
|
const defaultSort = [{ key: 'created', value: SortDirection.ASC }];
|
|
31
31
|
const countries = Countries.find(buildFindSelector({ includeInactive, queryString }), {
|
|
32
32
|
skip: offset,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureCountriesModule.js","sourceRoot":"","sources":["../../src/module/configureCountriesModule.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACpG,OAAO,EAAE,aAAa,EAAc,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,aAAa,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"configureCountriesModule.js","sourceRoot":"","sources":["../../src/module/configureCountriesModule.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACpG,OAAO,EAAE,aAAa,EAAc,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8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SAAS,CAAC,EAC/B;gBACE,IAAI,EAAE;oBACJ,OAAO,EAAE,IAAI,IAAI,EAAE;iBACpB;aACF,CACF,CAAC;YACF,MAAM,IAAI,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;YAC5C,OAAO,YAAY,CAAC;QACtB,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-countries",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"main": "lib/countries-index.js",
|
|
5
5
|
"types": "lib/countries-index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@unchainedshop/events": "^3.0.0
|
|
35
|
-
"@unchainedshop/utils": "^3.0.0
|
|
34
|
+
"@unchainedshop/events": "^3.0.0",
|
|
35
|
+
"@unchainedshop/utils": "^3.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/node": "^22.10.
|
|
38
|
+
"@types/node": "^22.10.5",
|
|
39
39
|
"jest": "^29.7.0",
|
|
40
40
|
"ts-jest": "^29.2.5",
|
|
41
|
-
"typescript": "^5.7.
|
|
41
|
+
"typescript": "^5.7.3"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -17,27 +17,6 @@ export type CountryQuery = {
|
|
|
17
17
|
includeInactive?: boolean;
|
|
18
18
|
queryString?: string;
|
|
19
19
|
};
|
|
20
|
-
export type CountriesModule = {
|
|
21
|
-
findCountry: (params: { countryId?: string; isoCode?: string }) => Promise<Country>;
|
|
22
|
-
findCountries: (
|
|
23
|
-
params: CountryQuery & {
|
|
24
|
-
limit?: number;
|
|
25
|
-
offset?: number;
|
|
26
|
-
sort?: Array<SortOption>;
|
|
27
|
-
},
|
|
28
|
-
options?: mongodb.FindOptions,
|
|
29
|
-
) => Promise<Array<Country>>;
|
|
30
|
-
count: (query: CountryQuery) => Promise<number>;
|
|
31
|
-
countryExists: (params: { countryId: string }) => Promise<boolean>;
|
|
32
|
-
|
|
33
|
-
flagEmoji: (country: Country) => string;
|
|
34
|
-
isBase: (country: Country) => boolean;
|
|
35
|
-
name: (country: Country, language: string) => string;
|
|
36
|
-
|
|
37
|
-
update: (_id: string, doc: Country) => Promise<string>;
|
|
38
|
-
delete: (_id: string) => Promise<number>;
|
|
39
|
-
create: (doc: Country) => Promise<string | null>;
|
|
40
|
-
};
|
|
41
20
|
|
|
42
21
|
const COUNTRY_EVENTS: string[] = ['COUNTRY_CREATE', 'COUNTRY_UPDATE', 'COUNTRY_REMOVE'];
|
|
43
22
|
|
|
@@ -51,7 +30,7 @@ export const buildFindSelector = ({ includeInactive = false, queryString = '' }:
|
|
|
51
30
|
export const configureCountriesModule = async ({
|
|
52
31
|
db,
|
|
53
32
|
migrationRepository,
|
|
54
|
-
}: ModuleInput<Record<string, never>>)
|
|
33
|
+
}: ModuleInput<Record<string, never>>) => {
|
|
55
34
|
registerEvents(COUNTRY_EVENTS);
|
|
56
35
|
|
|
57
36
|
// Migration
|
|
@@ -60,16 +39,35 @@ export const configureCountriesModule = async ({
|
|
|
60
39
|
const Countries = await CountriesCollection(db);
|
|
61
40
|
|
|
62
41
|
return {
|
|
63
|
-
count: async (query) => {
|
|
42
|
+
count: async (query: CountryQuery): Promise<number> => {
|
|
64
43
|
const countryCount = await Countries.countDocuments(buildFindSelector(query));
|
|
65
44
|
return countryCount;
|
|
66
45
|
},
|
|
67
46
|
|
|
68
|
-
findCountry: async ({
|
|
47
|
+
findCountry: async ({
|
|
48
|
+
countryId,
|
|
49
|
+
isoCode,
|
|
50
|
+
}: {
|
|
51
|
+
countryId?: string;
|
|
52
|
+
isoCode?: string;
|
|
53
|
+
}): Promise<Country> => {
|
|
69
54
|
return Countries.findOne(countryId ? generateDbFilterById(countryId) : { isoCode });
|
|
70
55
|
},
|
|
71
56
|
|
|
72
|
-
findCountries: async (
|
|
57
|
+
findCountries: async (
|
|
58
|
+
{
|
|
59
|
+
limit,
|
|
60
|
+
offset,
|
|
61
|
+
sort,
|
|
62
|
+
includeInactive,
|
|
63
|
+
queryString,
|
|
64
|
+
}: CountryQuery & {
|
|
65
|
+
limit?: number;
|
|
66
|
+
offset?: number;
|
|
67
|
+
sort?: Array<SortOption>;
|
|
68
|
+
},
|
|
69
|
+
options?: mongodb.FindOptions,
|
|
70
|
+
): Promise<Array<Country>> => {
|
|
73
71
|
const defaultSort = [{ key: 'created', value: SortDirection.ASC }] as SortOption[];
|
|
74
72
|
const countries = Countries.find(buildFindSelector({ includeInactive, queryString }), {
|
|
75
73
|
skip: offset,
|
|
@@ -80,7 +78,7 @@ export const configureCountriesModule = async ({
|
|
|
80
78
|
return countries.toArray();
|
|
81
79
|
},
|
|
82
80
|
|
|
83
|
-
countryExists: async ({ countryId }) => {
|
|
81
|
+
countryExists: async ({ countryId }: { countryId: string }): Promise<boolean> => {
|
|
84
82
|
const countryCount = await Countries.countDocuments(
|
|
85
83
|
generateDbFilterById(countryId, { deleted: null }),
|
|
86
84
|
{
|
|
@@ -90,22 +88,22 @@ export const configureCountriesModule = async ({
|
|
|
90
88
|
return !!countryCount;
|
|
91
89
|
},
|
|
92
90
|
|
|
93
|
-
name(country, language) {
|
|
91
|
+
name(country: Country, language: string) {
|
|
94
92
|
return new Intl.DisplayNames([language], { type: 'region', fallback: 'code' }).of(country.isoCode);
|
|
95
93
|
},
|
|
96
94
|
|
|
97
|
-
flagEmoji(country) {
|
|
95
|
+
flagEmoji(country: Country) {
|
|
98
96
|
const letterToLetterEmoji = (letter: string): string => {
|
|
99
97
|
return String.fromCodePoint(letter.toLowerCase().charCodeAt(0) + 127365);
|
|
100
98
|
};
|
|
101
99
|
return Array.from(country.isoCode.toUpperCase()).map(letterToLetterEmoji).join('');
|
|
102
100
|
},
|
|
103
101
|
|
|
104
|
-
isBase(country) {
|
|
102
|
+
isBase(country: Country) {
|
|
105
103
|
return country.isoCode === systemLocale.region;
|
|
106
104
|
},
|
|
107
105
|
|
|
108
|
-
create: async (doc) => {
|
|
106
|
+
create: async (doc: Country) => {
|
|
109
107
|
await Countries.deleteOne({ isoCode: doc.isoCode.toUpperCase(), deleted: { $ne: null } });
|
|
110
108
|
const { insertedId: countryId } = await Countries.insertOne({
|
|
111
109
|
_id: generateDbObjectId(),
|
|
@@ -118,7 +116,7 @@ export const configureCountriesModule = async ({
|
|
|
118
116
|
return countryId;
|
|
119
117
|
},
|
|
120
118
|
|
|
121
|
-
update: async (countryId, doc) => {
|
|
119
|
+
update: async (countryId: string, doc: Country) => {
|
|
122
120
|
await Countries.updateOne(generateDbFilterById(countryId), {
|
|
123
121
|
$set: {
|
|
124
122
|
updated: new Date(),
|
|
@@ -129,7 +127,7 @@ export const configureCountriesModule = async ({
|
|
|
129
127
|
return countryId;
|
|
130
128
|
},
|
|
131
129
|
|
|
132
|
-
delete: async (countryId) => {
|
|
130
|
+
delete: async (countryId: string) => {
|
|
133
131
|
const { modifiedCount: deletedCount } = await Countries.updateOne(
|
|
134
132
|
generateDbFilterById(countryId),
|
|
135
133
|
{
|
|
@@ -143,3 +141,5 @@ export const configureCountriesModule = async ({
|
|
|
143
141
|
},
|
|
144
142
|
};
|
|
145
143
|
};
|
|
144
|
+
|
|
145
|
+
export type CountriesModule = Awaited<ReturnType<typeof configureCountriesModule>>;
|