@unchainedshop/core-currencies 3.1.13 → 4.0.0-rc.3
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/db/CurrenciesCollection.d.ts +1 -1
- package/lib/db/CurrenciesCollection.d.ts.map +1 -1
- package/lib/db/CurrenciesCollection.js +2 -2
- package/lib/db/CurrenciesCollection.js.map +1 -1
- package/lib/module/configureCurrenciesModule.d.ts +4 -9
- package/lib/module/configureCurrenciesModule.d.ts.map +1 -1
- package/lib/module/configureCurrenciesModule.js +6 -3
- package/lib/module/configureCurrenciesModule.js.map +1 -1
- package/package.json +3 -3
- package/src/db/CurrenciesCollection.ts +8 -3
- package/src/module/configureCurrenciesModule.ts +11 -4
|
@@ -6,7 +6,7 @@ export type Currency = {
|
|
|
6
6
|
contractAddress?: string;
|
|
7
7
|
decimals?: number;
|
|
8
8
|
} & TimestampFields;
|
|
9
|
-
export type CurrencyQuery = {
|
|
9
|
+
export type CurrencyQuery = mongodb.Filter<Currency> & {
|
|
10
10
|
includeInactive?: boolean;
|
|
11
11
|
contractAddress?: string;
|
|
12
12
|
queryString?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrenciesCollection.d.ts","sourceRoot":"","sources":["../../src/db/CurrenciesCollection.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CurrenciesCollection.d.ts","sourceRoot":"","sources":["../../src/db/CurrenciesCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,eAAe,EAEhB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,QAAQ,GAAG;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,eAAe,CAAC;AAEpB,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG;IACrD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,IAAI,OAAO,CAAC,EAAE,0CAuBxD,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { buildDbIndexes } from '@unchainedshop/mongodb';
|
|
1
|
+
import { buildDbIndexes, isDocumentDBCompatModeEnabled, } from '@unchainedshop/mongodb';
|
|
2
2
|
export const CurrenciesCollection = async (db) => {
|
|
3
3
|
const Currencies = db.collection('currencies');
|
|
4
4
|
await buildDbIndexes(Currencies, [
|
|
5
5
|
{ index: { isoCode: 1 }, options: { unique: true } },
|
|
6
|
-
{
|
|
6
|
+
!isDocumentDBCompatModeEnabled() && {
|
|
7
7
|
index: { isoCode: 'text', _id: 'text' },
|
|
8
8
|
options: {
|
|
9
9
|
weights: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrenciesCollection.js","sourceRoot":"","sources":["../../src/db/CurrenciesCollection.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CurrenciesCollection.js","sourceRoot":"","sources":["../../src/db/CurrenciesCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAEd,6BAA6B,GAC9B,MAAM,wBAAwB,CAAC;AAgBhC,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAAE,EAAc,EAAE,EAAE;IAC3D,MAAM,UAAU,GAAG,EAAE,CAAC,UAAU,CAAW,YAAY,CAAC,CAAC;IAEzD,MAAM,cAAc,CAAW,UAAU,EAAE;QACzC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;QACpD,CAAC,6BAA6B,EAAE,IAAI;YAClC,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE;YACvC,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,GAAG,EAAE,CAAC;oBACN,OAAO,EAAE,CAAC;iBACX;gBACD,IAAI,EAAE,4BAA4B;aACnC;SACF;QACD;YACE,KAAK,EAAE;gBACL,OAAO,EAAE,CAAC;aACX;SACF;KACF,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC"}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { ModuleInput } from '@unchainedshop/mongodb';
|
|
1
|
+
import { ModuleInput, mongodb } from '@unchainedshop/mongodb';
|
|
2
2
|
import { SortOption } from '@unchainedshop/utils';
|
|
3
3
|
import { Currency, CurrencyQuery } from '../db/CurrenciesCollection.js';
|
|
4
|
-
export declare const buildFindSelector: ({ includeInactive, contractAddress, queryString, }: CurrencyQuery) =>
|
|
5
|
-
isActive?: true;
|
|
6
|
-
deleted: null;
|
|
7
|
-
contractAddress?: string;
|
|
8
|
-
$text?: any;
|
|
9
|
-
};
|
|
4
|
+
export declare const buildFindSelector: ({ includeInactive, contractAddress, queryString, ...rest }: CurrencyQuery) => mongodb.Filter<Currency>;
|
|
10
5
|
export declare const configureCurrenciesModule: ({ db }: ModuleInput<Record<string, never>>) => Promise<{
|
|
11
6
|
findCurrency: ({ currencyId, isoCode, }: {
|
|
12
7
|
currencyId?: string;
|
|
@@ -15,8 +10,8 @@ export declare const configureCurrenciesModule: ({ db }: ModuleInput<Record<stri
|
|
|
15
10
|
findCurrencies: ({ limit, offset, sort, ...query }: CurrencyQuery & {
|
|
16
11
|
limit?: number;
|
|
17
12
|
offset?: number;
|
|
18
|
-
sort?:
|
|
19
|
-
}) => Promise<
|
|
13
|
+
sort?: SortOption[];
|
|
14
|
+
}) => Promise<Currency[]>;
|
|
20
15
|
count: (query: CurrencyQuery) => Promise<number>;
|
|
21
16
|
currencyExists: ({ currencyId }: {
|
|
22
17
|
currencyId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureCurrenciesModule.d.ts","sourceRoot":"","sources":["../../src/module/configureCurrenciesModule.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,WAAW,
|
|
1
|
+
{"version":3,"file":"configureCurrenciesModule.d.ts","sourceRoot":"","sources":["../../src/module/configureCurrenciesModule.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,WAAW,EAEX,OAAO,EACR,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,GAAI,4DAK/B,aAAa,6BAYf,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAU,QAAQ,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,UAAU,EAAE,CAAC;KACrB,KAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;mBAUF,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"}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { emit, registerEvents } from '@unchainedshop/events';
|
|
2
|
-
import { generateDbFilterById, buildSortOptions, generateDbObjectId, } from '@unchainedshop/mongodb';
|
|
2
|
+
import { generateDbFilterById, buildSortOptions, generateDbObjectId, assertDocumentDBCompatMode, } from '@unchainedshop/mongodb';
|
|
3
3
|
import { SortDirection } from '@unchainedshop/utils';
|
|
4
4
|
import { CurrenciesCollection } from '../db/CurrenciesCollection.js';
|
|
5
5
|
const CURRENCY_EVENTS = ['CURRENCY_CREATE', 'CURRENCY_UPDATE', 'CURRENCY_REMOVE'];
|
|
6
|
-
export const buildFindSelector = ({ includeInactive = false, contractAddress, queryString, }) => {
|
|
6
|
+
export const buildFindSelector = ({ includeInactive = false, contractAddress, queryString, ...rest }) => {
|
|
7
7
|
const selector = {
|
|
8
|
+
...rest,
|
|
8
9
|
deleted: null,
|
|
9
10
|
};
|
|
10
11
|
if (!includeInactive)
|
|
11
12
|
selector.isActive = true;
|
|
12
13
|
if (contractAddress)
|
|
13
14
|
selector.contractAddress = contractAddress;
|
|
14
|
-
if (queryString)
|
|
15
|
+
if (queryString) {
|
|
16
|
+
assertDocumentDBCompatMode();
|
|
15
17
|
selector.$text = { $search: queryString };
|
|
18
|
+
}
|
|
16
19
|
return selector;
|
|
17
20
|
};
|
|
18
21
|
export const configureCurrenciesModule = async ({ db }) => {
|
|
@@ -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,
|
|
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,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AAG,CAAC,OAAO,CAAC,WAAW,EAAE;gBAClC,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC;YACH,MAAM,IAAI,CAAC,iBAAiB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;YAC9C,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,UAAkB,EAAE,GAAsB,EAAE,EAAE;YAC3D,MAAM,UAAU,CAAC,SAAS,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE;gBAC3D,IAAI,EAAE;oBACJ,OAAO,EAAE,IAAI,IAAI,EAAE;oBACnB,GAAG,GAAG;oBACN,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE;iBACnC;aACF,CAAC,CAAC;YACH,MAAM,IAAI,CAAC,iBAAiB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;YAC9C,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,UAAkB,EAAE,EAAE;YACnC,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,MAAM,UAAU,CAAC,SAAS,CAChE,oBAAoB,CAAC,UAAU,CAAC,EAChC;gBACE,IAAI,EAAE;oBACJ,OAAO,EAAE,IAAI,IAAI,EAAE;iBACpB;aACF,CACF,CAAC;YACF,MAAM,IAAI,CAAC,iBAAiB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;YAC9C,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-currencies",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-rc.3",
|
|
4
4
|
"main": "lib/currencies-index.js",
|
|
5
5
|
"types": "lib/currencies-index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@unchainedshop/events": "^
|
|
35
|
-
"@unchainedshop/utils": "^
|
|
34
|
+
"@unchainedshop/events": "^4.0.0-rc.3",
|
|
35
|
+
"@unchainedshop/utils": "^4.0.0-rc.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^24.0.4",
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
mongodb,
|
|
3
|
+
buildDbIndexes,
|
|
4
|
+
TimestampFields,
|
|
5
|
+
isDocumentDBCompatModeEnabled,
|
|
6
|
+
} from '@unchainedshop/mongodb';
|
|
2
7
|
|
|
3
8
|
export type Currency = {
|
|
4
9
|
_id?: string;
|
|
@@ -8,7 +13,7 @@ export type Currency = {
|
|
|
8
13
|
decimals?: number;
|
|
9
14
|
} & TimestampFields;
|
|
10
15
|
|
|
11
|
-
export type CurrencyQuery = {
|
|
16
|
+
export type CurrencyQuery = mongodb.Filter<Currency> & {
|
|
12
17
|
includeInactive?: boolean;
|
|
13
18
|
contractAddress?: string;
|
|
14
19
|
queryString?: string;
|
|
@@ -19,7 +24,7 @@ export const CurrenciesCollection = async (db: mongodb.Db) => {
|
|
|
19
24
|
|
|
20
25
|
await buildDbIndexes<Currency>(Currencies, [
|
|
21
26
|
{ index: { isoCode: 1 }, options: { unique: true } },
|
|
22
|
-
{
|
|
27
|
+
!isDocumentDBCompatModeEnabled() && {
|
|
23
28
|
index: { isoCode: 'text', _id: 'text' },
|
|
24
29
|
options: {
|
|
25
30
|
weights: {
|
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
buildSortOptions,
|
|
5
5
|
generateDbObjectId,
|
|
6
6
|
ModuleInput,
|
|
7
|
+
assertDocumentDBCompatMode,
|
|
8
|
+
mongodb,
|
|
7
9
|
} from '@unchainedshop/mongodb';
|
|
8
10
|
import { SortDirection, SortOption } from '@unchainedshop/utils';
|
|
9
11
|
import { CurrenciesCollection, Currency, CurrencyQuery } from '../db/CurrenciesCollection.js';
|
|
@@ -14,13 +16,18 @@ export const buildFindSelector = ({
|
|
|
14
16
|
includeInactive = false,
|
|
15
17
|
contractAddress,
|
|
16
18
|
queryString,
|
|
19
|
+
...rest
|
|
17
20
|
}: CurrencyQuery) => {
|
|
18
|
-
const selector:
|
|
21
|
+
const selector: mongodb.Filter<Currency> = {
|
|
22
|
+
...rest,
|
|
19
23
|
deleted: null,
|
|
20
24
|
};
|
|
21
25
|
if (!includeInactive) selector.isActive = true;
|
|
22
26
|
if (contractAddress) selector.contractAddress = contractAddress;
|
|
23
|
-
if (queryString)
|
|
27
|
+
if (queryString) {
|
|
28
|
+
assertDocumentDBCompatMode();
|
|
29
|
+
selector.$text = { $search: queryString };
|
|
30
|
+
}
|
|
24
31
|
return selector;
|
|
25
32
|
};
|
|
26
33
|
|
|
@@ -48,8 +55,8 @@ export const configureCurrenciesModule = async ({ db }: ModuleInput<Record<strin
|
|
|
48
55
|
}: CurrencyQuery & {
|
|
49
56
|
limit?: number;
|
|
50
57
|
offset?: number;
|
|
51
|
-
sort?:
|
|
52
|
-
}): Promise<
|
|
58
|
+
sort?: SortOption[];
|
|
59
|
+
}): Promise<Currency[]> => {
|
|
53
60
|
const defaultSort = [{ key: 'created', value: SortDirection.ASC }] as SortOption[];
|
|
54
61
|
const currencies = Currencies.find(buildFindSelector(query), {
|
|
55
62
|
skip: offset,
|