@unchainedshop/core-countries 2.0.0-beta8 → 2.0.0-rc.1
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/jest.config.js +9 -0
- package/lib/db/CountriesSchema.js +0 -1
- package/lib/db/CountriesSchema.js.map +1 -1
- package/lib/module/configureCountriesModule.d.ts +6 -1
- package/lib/module/configureCountriesModule.js +10 -8
- package/lib/module/configureCountriesModule.js.map +1 -1
- package/package.json +9 -8
- package/src/db/CountriesSchema.js +0 -1
- package/src/module/configureCountriesModule.ts +15 -16
- package/tests/countries-index.test.ts +8 -44
package/jest.config.js
CHANGED
|
@@ -3,7 +3,6 @@ import SimpleSchema from 'simpl-schema';
|
|
|
3
3
|
export const CountriesSchema = new SimpleSchema({
|
|
4
4
|
isoCode: { type: String, required: true },
|
|
5
5
|
isActive: Boolean,
|
|
6
|
-
authorId: { type: String, required: true },
|
|
7
6
|
defaultCurrencyId: String,
|
|
8
7
|
...Schemas.timestampFields,
|
|
9
8
|
}, { requiredByDefault: false });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CountriesSchema.js","sourceRoot":"","sources":["../../src/db/CountriesSchema.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,YAAY,CAC7C;IACE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACzC,QAAQ,EAAE,OAAO;IACjB,
|
|
1
|
+
{"version":3,"file":"CountriesSchema.js","sourceRoot":"","sources":["../../src/db/CountriesSchema.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,YAAY,CAC7C;IACE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACzC,QAAQ,EAAE,OAAO;IACjB,iBAAiB,EAAE,MAAM;IACzB,GAAG,OAAO,CAAC,eAAe;CAC3B,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { ModuleInput } from '@unchainedshop/types/core';
|
|
2
|
-
import { CountriesModule } from '@unchainedshop/types/countries';
|
|
2
|
+
import { CountriesModule, CountryQuery } from '@unchainedshop/types/countries';
|
|
3
|
+
export declare const buildFindSelector: ({ includeInactive, queryString }: CountryQuery) => {
|
|
4
|
+
isActive?: true;
|
|
5
|
+
$text?: any;
|
|
6
|
+
deleted?: Date;
|
|
7
|
+
};
|
|
3
8
|
export declare const configureCountriesModule: ({ db, }: ModuleInput<Record<string, never>>) => Promise<CountriesModule>;
|
|
@@ -2,10 +2,11 @@ import countryFlags from 'emoji-flags';
|
|
|
2
2
|
import countryI18n from 'i18n-iso-countries';
|
|
3
3
|
import { emit, registerEvents } from '@unchainedshop/events';
|
|
4
4
|
import { generateDbFilterById, generateDbMutations, systemLocale, buildSortOptions, } from '@unchainedshop/utils';
|
|
5
|
+
import { SortDirection } from '@unchainedshop/types/api';
|
|
5
6
|
import { CountriesCollection } from '../db/CountriesCollection';
|
|
6
7
|
import { CountriesSchema } from '../db/CountriesSchema';
|
|
7
8
|
const COUNTRY_EVENTS = ['COUNTRY_CREATE', 'COUNTRY_UPDATE', 'COUNTRY_REMOVE'];
|
|
8
|
-
const buildFindSelector = ({ includeInactive = false, queryString = '' }) => {
|
|
9
|
+
export const buildFindSelector = ({ includeInactive = false, queryString = '' }) => {
|
|
9
10
|
const selector = { deleted: null };
|
|
10
11
|
if (!includeInactive)
|
|
11
12
|
selector.isActive = true;
|
|
@@ -26,10 +27,11 @@ export const configureCountriesModule = async ({ db, }) => {
|
|
|
26
27
|
return Countries.findOne(countryId ? generateDbFilterById(countryId) : { isoCode });
|
|
27
28
|
},
|
|
28
29
|
findCountries: async ({ limit, offset, sort, includeInactive, queryString }, options) => {
|
|
30
|
+
const defaultSort = [{ key: 'created', value: SortDirection.ASC }];
|
|
29
31
|
const countries = Countries.find(buildFindSelector({ includeInactive, queryString }), {
|
|
30
32
|
skip: offset,
|
|
31
33
|
limit,
|
|
32
|
-
sort: buildSortOptions(sort),
|
|
34
|
+
sort: buildSortOptions(sort || defaultSort),
|
|
33
35
|
...options,
|
|
34
36
|
});
|
|
35
37
|
return countries.toArray();
|
|
@@ -49,23 +51,23 @@ export const configureCountriesModule = async ({ db, }) => {
|
|
|
49
51
|
isBase(country) {
|
|
50
52
|
return country.isoCode === systemLocale.country;
|
|
51
53
|
},
|
|
52
|
-
create: async (doc
|
|
54
|
+
create: async (doc) => {
|
|
53
55
|
await Countries.deleteOne({ isoCode: doc.isoCode.toUpperCase(), deleted: { $ne: null } });
|
|
54
56
|
const countryId = await mutations.create({
|
|
55
57
|
...doc,
|
|
56
58
|
isoCode: doc.isoCode.toUpperCase(),
|
|
57
59
|
isActive: true,
|
|
58
|
-
}
|
|
60
|
+
});
|
|
59
61
|
await emit('COUNTRY_CREATE', { countryId });
|
|
60
62
|
return countryId;
|
|
61
63
|
},
|
|
62
|
-
update: async (_id, doc
|
|
63
|
-
const countryId = await mutations.update(_id, { $set: doc }
|
|
64
|
+
update: async (_id, doc) => {
|
|
65
|
+
const countryId = await mutations.update(_id, { $set: doc });
|
|
64
66
|
await emit('COUNTRY_UPDATE', { countryId });
|
|
65
67
|
return countryId;
|
|
66
68
|
},
|
|
67
|
-
delete: async (countryId
|
|
68
|
-
const deletedCount = await mutations.delete(countryId
|
|
69
|
+
delete: async (countryId) => {
|
|
70
|
+
const deletedCount = await mutations.delete(countryId);
|
|
69
71
|
await emit('COUNTRY_REMOVE', { countryId });
|
|
70
72
|
return deletedCount;
|
|
71
73
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureCountriesModule.js","sourceRoot":"","sources":["../../src/module/configureCountriesModule.ts"],"names":[],"mappings":"AAEA,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,cAAc,GAAa,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;AAExF,MAAM,iBAAiB,GAAG,CAAC,EAAE,eAAe,GAAG,KAAK,EAAE,WAAW,GAAG,EAAE,EAAgB,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"configureCountriesModule.js","sourceRoot":"","sources":["../../src/module/configureCountriesModule.ts"],"names":[],"mappings":"AAEA,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAc,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,cAAc,GAAa,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;AAExF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAAE,eAAe,GAAG,KAAK,EAAE,W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IAAI;aACf,CAAC,CAAC;YACH,MAAM,IAAI,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;YAC5C,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,GAAW,EAAE,GAAqB,EAAE,EAAE;YACnD,MAAM,SAAS,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;YAC7D,MAAM,IAAI,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;YAC5C,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;YAC1B,MAAM,YAAY,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACvD,MAAM,IAAI,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;YAC5C,OAAO,YAAY,CAAC;QACtB,CAAC;QAED,iBAAiB,EAAE,SAAS,CAAC,iBAAiB;KAC/C,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-countries",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc.1",
|
|
4
4
|
"main": "lib/countries-index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/countries-index.js",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"clean": "rm -rf lib",
|
|
13
13
|
"build": "npm run clean && tsc",
|
|
14
14
|
"watch": "tsc -w",
|
|
15
|
-
"test": "jest --
|
|
15
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --detectOpenHandles --forceExit",
|
|
16
|
+
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --detectOpenHandles --forceExit"
|
|
16
17
|
},
|
|
17
18
|
"repository": {
|
|
18
19
|
"type": "git",
|
|
@@ -30,19 +31,19 @@
|
|
|
30
31
|
},
|
|
31
32
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@unchainedshop/events": "^2.0.0-
|
|
34
|
-
"@unchainedshop/utils": "^2.0.0-
|
|
34
|
+
"@unchainedshop/events": "^2.0.0-rc.1",
|
|
35
|
+
"@unchainedshop/utils": "^2.0.0-rc.1",
|
|
35
36
|
"emoji-flags": "^1.3.0",
|
|
36
37
|
"i18n-iso-countries": "^7.5.0",
|
|
37
38
|
"lru-cache": "^7.14.1",
|
|
38
|
-
"simpl-schema": "^3.0
|
|
39
|
+
"simpl-schema": "^3.2.0"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@types/node": "^18.11.
|
|
42
|
-
"@unchainedshop/types": "^2.0.0-
|
|
42
|
+
"@types/node": "^18.11.17",
|
|
43
|
+
"@unchainedshop/types": "^2.0.0-rc.1",
|
|
43
44
|
"cross-env": "^7.0.3",
|
|
44
45
|
"jest": "^29.3.1",
|
|
45
46
|
"ts-jest": "^29.0.3",
|
|
46
|
-
"typescript": "^4.9.
|
|
47
|
+
"typescript": "^4.9.4"
|
|
47
48
|
}
|
|
48
49
|
}
|
|
@@ -9,12 +9,13 @@ import {
|
|
|
9
9
|
systemLocale,
|
|
10
10
|
buildSortOptions,
|
|
11
11
|
} from '@unchainedshop/utils';
|
|
12
|
+
import { SortDirection, SortOption } from '@unchainedshop/types/api';
|
|
12
13
|
import { CountriesCollection } from '../db/CountriesCollection';
|
|
13
14
|
import { CountriesSchema } from '../db/CountriesSchema';
|
|
14
15
|
|
|
15
16
|
const COUNTRY_EVENTS: string[] = ['COUNTRY_CREATE', 'COUNTRY_UPDATE', 'COUNTRY_REMOVE'];
|
|
16
17
|
|
|
17
|
-
const buildFindSelector = ({ includeInactive = false, queryString = '' }: CountryQuery) => {
|
|
18
|
+
export const buildFindSelector = ({ includeInactive = false, queryString = '' }: CountryQuery) => {
|
|
18
19
|
const selector: { isActive?: true; $text?: any; deleted?: Date } = { deleted: null };
|
|
19
20
|
if (!includeInactive) selector.isActive = true;
|
|
20
21
|
if (queryString) selector.$text = { $search: queryString };
|
|
@@ -41,10 +42,11 @@ export const configureCountriesModule = async ({
|
|
|
41
42
|
},
|
|
42
43
|
|
|
43
44
|
findCountries: async ({ limit, offset, sort, includeInactive, queryString }, options) => {
|
|
45
|
+
const defaultSort = [{ key: 'created', value: SortDirection.ASC }] as SortOption[];
|
|
44
46
|
const countries = Countries.find(buildFindSelector({ includeInactive, queryString }), {
|
|
45
47
|
skip: offset,
|
|
46
48
|
limit,
|
|
47
|
-
sort: buildSortOptions(sort),
|
|
49
|
+
sort: buildSortOptions(sort || defaultSort),
|
|
48
50
|
...options,
|
|
49
51
|
});
|
|
50
52
|
return countries.toArray();
|
|
@@ -66,30 +68,27 @@ export const configureCountriesModule = async ({
|
|
|
66
68
|
flagEmoji(country) {
|
|
67
69
|
return countryFlags.countryCode(country.isoCode).emoji || '❌';
|
|
68
70
|
},
|
|
71
|
+
|
|
69
72
|
isBase(country) {
|
|
70
73
|
return country.isoCode === systemLocale.country;
|
|
71
74
|
},
|
|
72
|
-
|
|
73
|
-
create: async (doc: Country, userId: string) => {
|
|
75
|
+
create: async (doc: Country) => {
|
|
74
76
|
await Countries.deleteOne({ isoCode: doc.isoCode.toUpperCase(), deleted: { $ne: null } });
|
|
75
|
-
const countryId = await mutations.create(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
userId,
|
|
82
|
-
);
|
|
77
|
+
const countryId = await mutations.create({
|
|
78
|
+
...doc,
|
|
79
|
+
isoCode: doc.isoCode.toUpperCase(),
|
|
80
|
+
isActive: true,
|
|
81
|
+
});
|
|
83
82
|
await emit('COUNTRY_CREATE', { countryId });
|
|
84
83
|
return countryId;
|
|
85
84
|
},
|
|
86
|
-
update: async (_id: string, doc: Partial<Country
|
|
87
|
-
const countryId = await mutations.update(_id, { $set: doc }
|
|
85
|
+
update: async (_id: string, doc: Partial<Country>) => {
|
|
86
|
+
const countryId = await mutations.update(_id, { $set: doc });
|
|
88
87
|
await emit('COUNTRY_UPDATE', { countryId });
|
|
89
88
|
return countryId;
|
|
90
89
|
},
|
|
91
|
-
delete: async (countryId
|
|
92
|
-
const deletedCount = await mutations.delete(countryId
|
|
90
|
+
delete: async (countryId) => {
|
|
91
|
+
const deletedCount = await mutations.delete(countryId);
|
|
93
92
|
await emit('COUNTRY_REMOVE', { countryId });
|
|
94
93
|
return deletedCount;
|
|
95
94
|
},
|
|
@@ -1,47 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const db = await initDb();
|
|
10
|
-
module = await configureCountriesModule({ db });
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('Check Country module', async () => {
|
|
14
|
-
assert.ok(module);
|
|
15
|
-
assert.isFunction(module.findCountry);
|
|
16
|
-
assert.isFunction(module.findCountries);
|
|
17
|
-
assert.isFunction(module.countryExists);
|
|
18
|
-
assert.isFunction(module.create);
|
|
19
|
-
assert.isFunction(module.update);
|
|
20
|
-
assert.isFunction(module.delete);
|
|
1
|
+
import {buildFindSelector} from '../src/module/configureCountriesModule'
|
|
2
|
+
describe('Country', () => {
|
|
3
|
+
|
|
4
|
+
it('buildFindSelector should return correct filter object', async () => {
|
|
5
|
+
|
|
6
|
+
expect(buildFindSelector({includeInactive: true, queryString: 'hello world'})).toEqual({ deleted: null, '$text': { '$search': 'hello world' } })
|
|
7
|
+
expect(buildFindSelector({includeInactive: true})).toEqual({ deleted: null })
|
|
8
|
+
expect(buildFindSelector({queryString: 'hello world'})).toEqual({ deleted: null, '$text': { '$search': 'hello world' }, isActive: true })
|
|
21
9
|
});
|
|
22
10
|
|
|
23
|
-
it('Mutate country', async () => {
|
|
24
|
-
const countryId = await module.create(
|
|
25
|
-
{
|
|
26
|
-
authorId: 'Test-User-1',
|
|
27
|
-
isoCode: 'CHF',
|
|
28
|
-
},
|
|
29
|
-
'Test-User-1'
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
assert.ok(countryId);
|
|
33
|
-
const country = await module.findCountry(countryId);
|
|
34
|
-
|
|
35
|
-
assert.ok(country);
|
|
36
|
-
assert.equal(country._id, countryId);
|
|
37
|
-
assert.equal(country.isoCode, 'CHF');
|
|
38
|
-
assert.equal(country.userId, 'Test-User-1');
|
|
39
|
-
assert.isDefined(country.created);
|
|
40
|
-
assert.isUndefined(country.updated);
|
|
41
|
-
assert.isUndefined(country.updatedBy);
|
|
42
|
-
assert.equal(country.createdBy, 'Test-User-1');
|
|
43
|
-
|
|
44
|
-
const deletedCount = await module.delete(countryId);
|
|
45
|
-
assert.equal(deletedCount, 1);
|
|
46
|
-
});
|
|
47
11
|
});
|