@unchainedshop/core-currencies 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/configureCurrenciesModule.d.ts +15 -15
- package/lib/module/configureCurrenciesModule.d.ts.map +1 -1
- package/lib/module/configureCurrenciesModule.js +2 -2
- package/lib/module/configureCurrenciesModule.js.map +1 -1
- package/package.json +5 -5
- package/src/module/configureCurrenciesModule.ts +23 -24
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { ModuleInput } from '@unchainedshop/mongodb';
|
|
2
2
|
import { SortOption } from '@unchainedshop/utils';
|
|
3
3
|
import { Currency, CurrencyQuery } from '../db/CurrenciesCollection.js';
|
|
4
|
-
export
|
|
5
|
-
|
|
4
|
+
export declare const buildFindSelector: ({ includeInactive, contractAddress, queryString, }: CurrencyQuery) => {
|
|
5
|
+
isActive?: true;
|
|
6
|
+
deleted: null;
|
|
7
|
+
contractAddress?: string;
|
|
8
|
+
$text?: any;
|
|
9
|
+
};
|
|
10
|
+
export declare const configureCurrenciesModule: ({ db }: ModuleInput<Record<string, never>>) => Promise<{
|
|
11
|
+
findCurrency: ({ currencyId, isoCode, }: {
|
|
6
12
|
currencyId?: string;
|
|
7
13
|
isoCode?: string;
|
|
8
14
|
}) => Promise<Currency>;
|
|
9
|
-
findCurrencies: (
|
|
15
|
+
findCurrencies: ({ limit, offset, sort, ...query }: CurrencyQuery & {
|
|
10
16
|
limit?: number;
|
|
11
17
|
offset?: number;
|
|
12
18
|
sort?: Array<SortOption>;
|
|
13
19
|
}) => Promise<Array<Currency>>;
|
|
14
20
|
count: (query: CurrencyQuery) => Promise<number>;
|
|
15
|
-
currencyExists: (
|
|
21
|
+
currencyExists: ({ currencyId }: {
|
|
16
22
|
currencyId: string;
|
|
17
23
|
}) => Promise<boolean>;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
export
|
|
23
|
-
isActive?: true;
|
|
24
|
-
deleted: null;
|
|
25
|
-
contractAddress?: string;
|
|
26
|
-
$text?: any;
|
|
27
|
-
};
|
|
28
|
-
export declare const configureCurrenciesModule: ({ db, }: ModuleInput<Record<string, never>>) => Promise<CurrenciesModule>;
|
|
24
|
+
create: (doc: Currency) => Promise<string>;
|
|
25
|
+
update: (currencyId: string, doc: Partial<Currency>) => Promise<string>;
|
|
26
|
+
delete: (currencyId: string) => Promise<number>;
|
|
27
|
+
}>;
|
|
28
|
+
export type CurrenciesModule = Awaited<ReturnType<typeof configureCurrenciesModule>>;
|
|
29
29
|
//# sourceMappingURL=configureCurrenciesModule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureCurrenciesModule.d.ts","sourceRoot":"","sources":["../../src/module/configureCurrenciesModule.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAiB,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAwB,QAAQ,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAI9F,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"configureCurrenciesModule.d.ts","sourceRoot":"","sources":["../../src/module/configureCurrenciesModule.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAiB,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAwB,QAAQ,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAI9F,eAAO,MAAM,iBAAiB,uDAI3B,aAAa;eACe,IAAI;aAAW,IAAI;sBAAoB,MAAM;YAAU,GAAG;CAOxF,CAAC;AAEF,eAAO,MAAM,yBAAyB,WAAkB,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;6CASnF;QACD,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,KAAG,OAAO,CAAC,QAAQ,CAAC;wDASlB,aAAa,GAAG;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;KAC1B,KAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;mBAUP,aAAa;qCAKK;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE;kBAUzC,QAAQ;yBAaD,MAAM,OAAO,OAAO,CAAC,QAAQ,CAAC;yBAY9B,MAAM;EAapC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC"}
|
|
@@ -15,11 +15,11 @@ export const buildFindSelector = ({ includeInactive = false, contractAddress, qu
|
|
|
15
15
|
selector.$text = { $search: queryString };
|
|
16
16
|
return selector;
|
|
17
17
|
};
|
|
18
|
-
export const configureCurrenciesModule = async ({ db
|
|
18
|
+
export const configureCurrenciesModule = async ({ db }) => {
|
|
19
19
|
registerEvents(CURRENCY_EVENTS);
|
|
20
20
|
const Currencies = await CurrenciesCollection(db);
|
|
21
21
|
return {
|
|
22
|
-
findCurrency: async ({ currencyId, isoCode }) => {
|
|
22
|
+
findCurrency: async ({ currencyId, isoCode, }) => {
|
|
23
23
|
return Currencies.findOne(currencyId ? generateDbFilterById(currencyId) : { isoCode });
|
|
24
24
|
},
|
|
25
25
|
findCurrencies: async ({ limit, offset, sort, ...query }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureCurrenciesModule.js","sourceRoot":"","sources":["../../src/module/configureCurrenciesModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,GAEnB,MAAM,wBAAwB,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CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-currencies",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"main": "lib/currencies-index.js",
|
|
5
5
|
"types": "lib/currencies-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
|
}
|
|
@@ -10,22 +10,6 @@ import { CurrenciesCollection, Currency, CurrencyQuery } from '../db/CurrenciesC
|
|
|
10
10
|
|
|
11
11
|
const CURRENCY_EVENTS: string[] = ['CURRENCY_CREATE', 'CURRENCY_UPDATE', 'CURRENCY_REMOVE'];
|
|
12
12
|
|
|
13
|
-
export type CurrenciesModule = {
|
|
14
|
-
findCurrency: (params: { currencyId?: string; isoCode?: string }) => Promise<Currency>;
|
|
15
|
-
findCurrencies: (
|
|
16
|
-
params: CurrencyQuery & {
|
|
17
|
-
limit?: number;
|
|
18
|
-
offset?: number;
|
|
19
|
-
sort?: Array<SortOption>;
|
|
20
|
-
},
|
|
21
|
-
) => Promise<Array<Currency>>;
|
|
22
|
-
count: (query: CurrencyQuery) => Promise<number>;
|
|
23
|
-
currencyExists: (params: { currencyId: string }) => Promise<boolean>;
|
|
24
|
-
update: (_id: string, doc: Currency) => Promise<string>;
|
|
25
|
-
delete: (_id: string) => Promise<number>;
|
|
26
|
-
create: (doc: Currency) => Promise<string | null>;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
13
|
export const buildFindSelector = ({
|
|
30
14
|
includeInactive = false,
|
|
31
15
|
contractAddress,
|
|
@@ -40,19 +24,32 @@ export const buildFindSelector = ({
|
|
|
40
24
|
return selector;
|
|
41
25
|
};
|
|
42
26
|
|
|
43
|
-
export const configureCurrenciesModule = async ({
|
|
44
|
-
db,
|
|
45
|
-
}: ModuleInput<Record<string, never>>): Promise<CurrenciesModule> => {
|
|
27
|
+
export const configureCurrenciesModule = async ({ db }: ModuleInput<Record<string, never>>) => {
|
|
46
28
|
registerEvents(CURRENCY_EVENTS);
|
|
47
29
|
|
|
48
30
|
const Currencies = await CurrenciesCollection(db);
|
|
49
31
|
|
|
50
32
|
return {
|
|
51
|
-
findCurrency: async ({
|
|
33
|
+
findCurrency: async ({
|
|
34
|
+
currencyId,
|
|
35
|
+
isoCode,
|
|
36
|
+
}: {
|
|
37
|
+
currencyId?: string;
|
|
38
|
+
isoCode?: string;
|
|
39
|
+
}): Promise<Currency> => {
|
|
52
40
|
return Currencies.findOne(currencyId ? generateDbFilterById(currencyId) : { isoCode });
|
|
53
41
|
},
|
|
54
42
|
|
|
55
|
-
findCurrencies: async ({
|
|
43
|
+
findCurrencies: async ({
|
|
44
|
+
limit,
|
|
45
|
+
offset,
|
|
46
|
+
sort,
|
|
47
|
+
...query
|
|
48
|
+
}: CurrencyQuery & {
|
|
49
|
+
limit?: number;
|
|
50
|
+
offset?: number;
|
|
51
|
+
sort?: Array<SortOption>;
|
|
52
|
+
}): Promise<Array<Currency>> => {
|
|
56
53
|
const defaultSort = [{ key: 'created', value: SortDirection.ASC }] as SortOption[];
|
|
57
54
|
const currencies = Currencies.find(buildFindSelector(query), {
|
|
58
55
|
skip: offset,
|
|
@@ -62,12 +59,12 @@ export const configureCurrenciesModule = async ({
|
|
|
62
59
|
return currencies.toArray();
|
|
63
60
|
},
|
|
64
61
|
|
|
65
|
-
count: async (query) => {
|
|
62
|
+
count: async (query: CurrencyQuery) => {
|
|
66
63
|
const count = await Currencies.countDocuments(buildFindSelector(query));
|
|
67
64
|
return count;
|
|
68
65
|
},
|
|
69
66
|
|
|
70
|
-
currencyExists: async ({ currencyId }) => {
|
|
67
|
+
currencyExists: async ({ currencyId }: { currencyId: string }) => {
|
|
71
68
|
const currencyCount = await Currencies.countDocuments(
|
|
72
69
|
generateDbFilterById(currencyId, { deleted: null }),
|
|
73
70
|
{
|
|
@@ -102,7 +99,7 @@ export const configureCurrenciesModule = async ({
|
|
|
102
99
|
return currencyId;
|
|
103
100
|
},
|
|
104
101
|
|
|
105
|
-
delete: async (currencyId) => {
|
|
102
|
+
delete: async (currencyId: string) => {
|
|
106
103
|
const { modifiedCount: deletedCount } = await Currencies.updateOne(
|
|
107
104
|
generateDbFilterById(currencyId),
|
|
108
105
|
{
|
|
@@ -116,3 +113,5 @@ export const configureCurrenciesModule = async ({
|
|
|
116
113
|
},
|
|
117
114
|
};
|
|
118
115
|
};
|
|
116
|
+
|
|
117
|
+
export type CurrenciesModule = Awaited<ReturnType<typeof configureCurrenciesModule>>;
|