@unchainedshop/plugins 4.4.0 → 4.5.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/filters/local-search.js +8 -17
- package/lib/payment/stripe/stripe.js +1 -1
- package/lib/worker/error-notifications.js +2 -3
- package/lib/worker/update-coinbase-rates.js +2 -3
- package/lib/worker/update-ecb-rates.js +2 -3
- package/lib/worker/update-token-ownership.js +4 -5
- package/lib/worker/zombie-killer.js +2 -2
- package/package.json +13 -19
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { mongodb } from '@unchainedshop/mongodb';
|
|
2
|
-
import {} from '@unchainedshop/core-products';
|
|
3
|
-
import {} from '@unchainedshop/core-assortments';
|
|
4
1
|
import { FilterDirector, FilterAdapter } from '@unchainedshop/core';
|
|
5
2
|
import { createLogger } from '@unchainedshop/logger';
|
|
6
3
|
import { isDocumentDBCompatModeEnabled } from '@unchainedshop/mongodb';
|
|
@@ -18,13 +15,10 @@ const LocalSearch = {
|
|
|
18
15
|
const { queryString } = params.searchQuery;
|
|
19
16
|
if (!queryString)
|
|
20
17
|
return productIds;
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
selector.productId = { $in: [...new Set(productIds)] };
|
|
26
|
-
}
|
|
27
|
-
const products = await params.modules.products.texts.findTexts(selector, {
|
|
18
|
+
const products = await params.modules.products.texts.findTexts({
|
|
19
|
+
queryString,
|
|
20
|
+
productIds: productIds ? [...new Set(productIds)] : undefined,
|
|
21
|
+
}, {
|
|
28
22
|
projection: {
|
|
29
23
|
productId: 1,
|
|
30
24
|
},
|
|
@@ -36,13 +30,10 @@ const LocalSearch = {
|
|
|
36
30
|
if (!queryString) {
|
|
37
31
|
return assortmentIds;
|
|
38
32
|
}
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
selector.assortmentId = { $in: assortmentIds };
|
|
44
|
-
}
|
|
45
|
-
const assortments = await params.modules.assortments.texts.findTexts(selector, {
|
|
33
|
+
const assortments = await params.modules.assortments.texts.findTexts({
|
|
34
|
+
queryString,
|
|
35
|
+
assortmentIds,
|
|
36
|
+
}, {
|
|
46
37
|
projection: {
|
|
47
38
|
assortmentId: 1,
|
|
48
39
|
},
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { WorkStatus } from '@unchainedshop/core-worker';
|
|
2
|
-
import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core';
|
|
3
|
-
|
|
4
|
-
const everyDayAtFourInTheNight = later.parse.cron('0 3 * * *');
|
|
2
|
+
import { WorkerDirector, WorkerAdapter, schedule } from '@unchainedshop/core';
|
|
3
|
+
const everyDayAtFourInTheNight = schedule.parse.cron('0 3 * * *');
|
|
5
4
|
export const ErrorNotifications = {
|
|
6
5
|
...WorkerAdapter,
|
|
7
6
|
key: 'shop.unchained.worker.error-notifications',
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { WorkerAdapter, WorkerDirector } from '@unchainedshop/core';
|
|
2
|
-
import later from '@breejs/later';
|
|
1
|
+
import { WorkerAdapter, WorkerDirector, schedule } from '@unchainedshop/core';
|
|
3
2
|
import { resolveBestCurrency } from '@unchainedshop/utils';
|
|
4
3
|
const getExchangeRates = async (base) => {
|
|
5
4
|
return fetch(`https://api.coinbase.com/v2/exchange-rates?currency=${base}`, {
|
|
@@ -8,7 +7,7 @@ const getExchangeRates = async (base) => {
|
|
|
8
7
|
.then((res) => res.json())
|
|
9
8
|
.then((r) => r?.data);
|
|
10
9
|
};
|
|
11
|
-
const everyMinute =
|
|
10
|
+
const everyMinute = schedule.parse.cron('* * * * *');
|
|
12
11
|
const UpdateCoinbaseRates = {
|
|
13
12
|
...WorkerAdapter,
|
|
14
13
|
key: 'shop.unchained.worker.update-coinbase-rates',
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { WorkerAdapter, WorkerDirector } from '@unchainedshop/core';
|
|
2
|
-
import later from '@breejs/later';
|
|
1
|
+
import { WorkerAdapter, WorkerDirector, schedule } from '@unchainedshop/core';
|
|
3
2
|
import { createLogger } from '@unchainedshop/logger';
|
|
4
3
|
const logger = createLogger('unchained:worker:update-ecb-rates');
|
|
5
4
|
let xml2json;
|
|
@@ -20,7 +19,7 @@ const getExchangeRates = async () => {
|
|
|
20
19
|
.filter((e) => e.name.toLowerCase() === 'cube')[0]
|
|
21
20
|
?.elements[0]?.elements.map((element) => element.attributes));
|
|
22
21
|
};
|
|
23
|
-
const everyDayAtFour =
|
|
22
|
+
const everyDayAtFour = schedule.parse.cron('0 15 * * *');
|
|
24
23
|
const baseCurrency = 'EUR';
|
|
25
24
|
const UpdateECBRates = {
|
|
26
25
|
...WorkerAdapter,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { WorkerAdapter, WorkerDirector } from '@unchainedshop/core';
|
|
2
|
-
|
|
3
|
-
const everyMinute = later.parse.cron('* * * * *');
|
|
1
|
+
import { WorkerAdapter, WorkerDirector, schedule } from '@unchainedshop/core';
|
|
2
|
+
const everyMinute = schedule.parse.cron('* * * * *');
|
|
4
3
|
export const UpdateTokenOwnership = {
|
|
5
4
|
...WorkerAdapter,
|
|
6
5
|
key: 'shop.unchained.worker-plugin.update-token-ownership',
|
|
@@ -21,8 +20,8 @@ export const RefreshTokens = {
|
|
|
21
20
|
external: false,
|
|
22
21
|
async doWork(input, unchainedAPI) {
|
|
23
22
|
const { modules } = unchainedAPI;
|
|
24
|
-
const tokens = await modules.warehousing.findTokens({
|
|
25
|
-
const users = await modules.users.findUsers({ includeGuests: true,
|
|
23
|
+
const tokens = await modules.warehousing.findTokens({ walletAddressExists: true });
|
|
24
|
+
const users = await modules.users.findUsers({ includeGuests: true, web3Verified: true });
|
|
26
25
|
const accounts = users.flatMap((user) => {
|
|
27
26
|
return user?.services?.web3?.flatMap((service) => {
|
|
28
27
|
if (service.verified)
|
|
@@ -38,13 +38,13 @@ export const ZombieKillerWorker = {
|
|
|
38
38
|
const productMedia = await modules.products.media.findProductMedias({}, { projection: { mediaId: 1 } });
|
|
39
39
|
const assortmentMedia = await modules.assortments.media.findAssortmentMedias({}, { projection: { mediaId: 1 } });
|
|
40
40
|
const allFileIdsLinked = [...productMedia, ...assortmentMedia].map((l) => l?.mediaId);
|
|
41
|
-
const allFileIdsRelevant = (await modules.files.findFiles({
|
|
41
|
+
const allFileIdsRelevant = (await modules.files.findFiles({ paths: ['product-media', 'assortment-media'] }, { projection: { _id: 1 } })).map((a) => a._id);
|
|
42
42
|
const fileIdsToRemove = allFileIdsRelevant.filter((fileId) => {
|
|
43
43
|
return !allFileIdsLinked.includes(fileId);
|
|
44
44
|
}) || [];
|
|
45
45
|
const bulkImportMedia = await await modules.files.findFiles({
|
|
46
46
|
path: 'bulk-import-streams',
|
|
47
|
-
|
|
47
|
+
createdBefore: new Date(Date.now() - 1000 * 60 * 60 * 24 * bulkImportMaxAgeInDays),
|
|
48
48
|
});
|
|
49
49
|
bulkImportMedia.forEach(async (media) => {
|
|
50
50
|
fileIdsToRemove.push(media._id);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/plugins",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"main": "lib/plugins-index.js",
|
|
5
5
|
"types": "lib/plugins-index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -36,22 +36,21 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@unchainedshop/api": "^4.
|
|
40
|
-
"@unchainedshop/core-delivery": "^4.
|
|
41
|
-
"@unchainedshop/core-enrollments": "^4.
|
|
42
|
-
"@unchainedshop/core-orders": "^4.
|
|
43
|
-
"@unchainedshop/core-payment": "^4.
|
|
44
|
-
"@unchainedshop/core-products": "^4.
|
|
45
|
-
"@unchainedshop/core-warehousing": "^4.
|
|
46
|
-
"@unchainedshop/core-worker": "^4.
|
|
47
|
-
"@unchainedshop/events": "^4.
|
|
48
|
-
"@unchainedshop/file-upload": "^4.
|
|
49
|
-
"@unchainedshop/logger": "^4.
|
|
50
|
-
"@unchainedshop/utils": "^4.
|
|
39
|
+
"@unchainedshop/api": "^4.5.0",
|
|
40
|
+
"@unchainedshop/core-delivery": "^4.5.0",
|
|
41
|
+
"@unchainedshop/core-enrollments": "^4.5.0",
|
|
42
|
+
"@unchainedshop/core-orders": "^4.5.0",
|
|
43
|
+
"@unchainedshop/core-payment": "^4.5.0",
|
|
44
|
+
"@unchainedshop/core-products": "^4.5.0",
|
|
45
|
+
"@unchainedshop/core-warehousing": "^4.5.0",
|
|
46
|
+
"@unchainedshop/core-worker": "^4.5.0",
|
|
47
|
+
"@unchainedshop/events": "^4.5.0",
|
|
48
|
+
"@unchainedshop/file-upload": "^4.5.0",
|
|
49
|
+
"@unchainedshop/logger": "^4.5.0",
|
|
50
|
+
"@unchainedshop/utils": "^4.5.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@aws-sdk/client-eventbridge": ">= 3.714 < 4",
|
|
54
|
-
"@breejs/later": "^4.2.0",
|
|
55
54
|
"@paypal/checkout-server-sdk": "1.x",
|
|
56
55
|
"@redis/client": ">= 1 < 6",
|
|
57
56
|
"@scure/bip32": ">= 2",
|
|
@@ -68,9 +67,6 @@
|
|
|
68
67
|
"xml-js": ">= 1.6 < 2"
|
|
69
68
|
},
|
|
70
69
|
"peerDependenciesMeta": {
|
|
71
|
-
"@breejs/later": {
|
|
72
|
-
"optional": true
|
|
73
|
-
},
|
|
74
70
|
"@aws-sdk/client-eventbridge": {
|
|
75
71
|
"optional": true
|
|
76
72
|
},
|
|
@@ -115,12 +111,10 @@
|
|
|
115
111
|
}
|
|
116
112
|
},
|
|
117
113
|
"devDependencies": {
|
|
118
|
-
"@breejs/later": "^4.2.0",
|
|
119
114
|
"@paypal/checkout-server-sdk": "^1.0.3",
|
|
120
115
|
"@redis/client": "^5.6.0",
|
|
121
116
|
"@scure/bip32": "^2.0.0",
|
|
122
117
|
"@scure/btc-signer": "^2.0.0",
|
|
123
|
-
"@types/breejs__later": "^4.1.5",
|
|
124
118
|
"@types/express": "^5.0.3",
|
|
125
119
|
"@types/node": "^25.0.0",
|
|
126
120
|
"expiry-map": "^2.0.0",
|