@yellowpanther/shared 1.3.2 → 1.3.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yellowpanther/shared",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"./redis/redisClient": "./src/redis/redisClient.js",
|
|
21
21
|
"./queue/compressionQueue": "./src/queue/compressionQueue.js",
|
|
22
22
|
"./queue/newsTranslationQueue": "./src/queue/newsTranslationQueue.js",
|
|
23
|
+
"./queue/addUserPointsQueue": "./src/queue/addUserPointsQueue.js",
|
|
23
24
|
"./queue/newsTranslateQueue": "./src/queue/newsTranslateQueue.js",
|
|
24
25
|
"./queue/newsPublishQueue": "./src/queue/newsPublishQueue.js",
|
|
25
26
|
"./queue/articlePublishQueue": "./src/queue/articlePublishQueue.js",
|
|
@@ -28,13 +29,13 @@
|
|
|
28
29
|
"./queue/imagePublishQueue": "./src/queue/imagePublishQueue.js",
|
|
29
30
|
"./queue/imageAlbumPublishQueue": "./src/queue/imageAlbumPublishQueue.js",
|
|
30
31
|
"./queue/pagePublishQueue": "./src/queue/pagePublishQueue.js",
|
|
31
|
-
"./queue/shopPublishQueue": "./src/queue/shopPublishQueue.js",
|
|
32
32
|
"./queue/productPublishQueue": "./src/queue/productPublishQueue.js",
|
|
33
33
|
"./queue/quizPublishQueue": "./src/queue/quizPublishQueue.js",
|
|
34
34
|
"./queue/predictPublishQueue": "./src/queue/predictPublishQueue.js",
|
|
35
35
|
"./queue/queueRegistry": "./src/queue/queueRegistry.js",
|
|
36
|
-
"./queue/
|
|
36
|
+
"./queue/shopPublishQueue": "./src/queue/shopPublishQueue.js",
|
|
37
37
|
"./lang/translationHelper": "./src/lang/translationHelper.js",
|
|
38
|
+
"./queue/pageTranslationQueue": "./src/queue/pageTranslationQueue.js",
|
|
38
39
|
"./*": "./src/*"
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
},
|
|
44
45
|
"license": "MIT",
|
|
45
46
|
"dependencies": {
|
|
47
|
+
"@yellowpanther/shared": "^1.3.2",
|
|
46
48
|
"dotenv": "^17.2.2",
|
|
47
49
|
"joi": "^18.0.1"
|
|
48
50
|
}
|
package/src/index.js
CHANGED
|
@@ -21,6 +21,8 @@ module.exports = {
|
|
|
21
21
|
.addArticlePublishJob,
|
|
22
22
|
addVideoPublishJob: require("./queue/videoPublishQueue").addVideoPublishJob,
|
|
23
23
|
addImagePublishJob: require("./queue/imagePublishQueue").addImagePublishJob,
|
|
24
|
+
pageTranslateQueue: require('./queue/pageTranslationQueue'),
|
|
25
|
+
addPageTranslationJob: require('./queue/pageTranslationQueue').addPageTranslationJob,
|
|
24
26
|
addPagePublishJob: require("./queue/pagePublishQueue").addPagePublishJob,
|
|
25
27
|
addProductPublishJob: require("./queue/productPublishQueue")
|
|
26
28
|
.addProductPublishJob,
|
|
@@ -30,6 +32,15 @@ module.exports = {
|
|
|
30
32
|
addImageAlbumPublishJob: require("./queue/imageAlbumPublishQueue")
|
|
31
33
|
.addImageAlbumPublishJob,
|
|
32
34
|
addEventPublishJob: require("./queue/eventPublishQueue").addEventPublishJob,
|
|
33
|
-
addShopPublishJob: require("./queue/shopPublishQueue").addShopPublishJob,
|
|
34
35
|
addUserPointsJob: require("./queue/addUserPointsQueue").addUserPointsJob,
|
|
36
|
+
addShopPublishJob: require("./queue/shopPublishQueue").addShopPublishJob,
|
|
37
|
+
|
|
38
|
+
jobTranslationQueue: require("./queue/jobTranslationQueue").jobTranslationQueue,
|
|
39
|
+
addJobTranslationJob: require("./queue/jobTranslationQueue").addJobTranslationJob,
|
|
40
|
+
|
|
41
|
+
shopTranslationQueue: require("./queue/shopTranslationQueue").shopTranslationQueue,
|
|
42
|
+
addShopTranslationJob: require("./queue/shopTranslationQueue").addShopTranslationJob,
|
|
43
|
+
|
|
44
|
+
tournamentTranslationQueue: require("./queue/tournamentTranslationQueue").tournamentTranslationQueue,
|
|
45
|
+
addTournamentTranslationJob: require("./queue/tournamentTranslationQueue").addTournamentTranslationJob
|
|
35
46
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { Queue } = require('bullmq');
|
|
2
|
+
const redisClient = require('../redis/redisClient');
|
|
3
|
+
|
|
4
|
+
const jobTranslationQueue = new Queue('jobTranslationQueue', {
|
|
5
|
+
connection: redisClient,
|
|
6
|
+
defaultJobOptions: {
|
|
7
|
+
removeOnComplete: false,
|
|
8
|
+
removeOnFail: false,
|
|
9
|
+
attempts: 3,
|
|
10
|
+
backoff: {
|
|
11
|
+
type: 'exponential',
|
|
12
|
+
delay: 1000
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Add a job translation job
|
|
19
|
+
* @param {Object} jobData
|
|
20
|
+
* @returns {Promise<void>}
|
|
21
|
+
*/
|
|
22
|
+
async function addJobTranslationJob({ job_id, translation }) {
|
|
23
|
+
await jobTranslationQueue.add('translateJob', { job_id, translation });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
jobTranslationQueue,
|
|
28
|
+
addJobTranslationJob
|
|
29
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { Queue } = require('bullmq');
|
|
2
|
+
const redisClient = require('../redis/redisClient');
|
|
3
|
+
|
|
4
|
+
const pageTranslationQueue = new Queue('pageTranslationQueue', {
|
|
5
|
+
connection: redisClient,
|
|
6
|
+
defaultJobOptions: {
|
|
7
|
+
removeOnComplete: false,
|
|
8
|
+
removeOnFail: false,
|
|
9
|
+
attempts: 3,
|
|
10
|
+
backoff: {
|
|
11
|
+
type: 'exponential',
|
|
12
|
+
delay: 1000
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Add a page translation job
|
|
19
|
+
* @param {Object} jobData
|
|
20
|
+
* @returns {Promise<void>}
|
|
21
|
+
*/
|
|
22
|
+
async function addPageTranslationJob({ page_id, user_id, translation, blocks, heromedia }) {
|
|
23
|
+
await pageTranslationQueue.add('translatePage', { page_id, user_id, translation, blocks, heromedia });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
pageTranslationQueue,
|
|
28
|
+
addPageTranslationJob
|
|
29
|
+
};
|
|
@@ -68,7 +68,7 @@ async function findPendingShopJobs(shop_id) {
|
|
|
68
68
|
const states = ["delayed", "waiting", "waiting-children", "active"];
|
|
69
69
|
const jobs = await shopPublishQueue.getJobs(states);
|
|
70
70
|
return jobs.filter(
|
|
71
|
-
(j) => j?.name === "shop:publish" && j?.data?.shop_id === String(shop_id)
|
|
71
|
+
(j) => j?.name === "shop:publish" && j?.data?.shop_id === String(shop_id)
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -84,7 +84,7 @@ async function purgeExistingForShop(shop_id) {
|
|
|
84
84
|
} catch (e) {
|
|
85
85
|
if (DEBUG)
|
|
86
86
|
console.warn(
|
|
87
|
-
`[shopPublishQueue] failed to remove pending job ${j.id}: ${e.message}
|
|
87
|
+
`[shopPublishQueue] failed to remove pending job ${j.id}: ${e.message}`
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -98,7 +98,7 @@ async function purgeExistingForShop(shop_id) {
|
|
|
98
98
|
} catch (e) {
|
|
99
99
|
if (DEBUG)
|
|
100
100
|
console.warn(
|
|
101
|
-
`[shopPublishQueue] failed to remove stable job ${last.id}: ${e.message}
|
|
101
|
+
`[shopPublishQueue] failed to remove stable job ${last.id}: ${e.message}`
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -154,7 +154,7 @@ async function addShopPublishJob({
|
|
|
154
154
|
const job = await shopPublishQueue.add(
|
|
155
155
|
"shop:publish",
|
|
156
156
|
{ shop_id: String(shop_id), runAtUtc: runAtIso, extra },
|
|
157
|
-
{ jobId, delay: delayMs }
|
|
157
|
+
{ jobId, delay: delayMs }
|
|
158
158
|
);
|
|
159
159
|
|
|
160
160
|
if (DEBUG) {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { Queue } = require('bullmq');
|
|
2
|
+
const redisClient = require('../redis/redisClient');
|
|
3
|
+
|
|
4
|
+
const shopTranslationQueue = new Queue('shopTranslationQueue', {
|
|
5
|
+
connection: redisClient,
|
|
6
|
+
defaultJobOptions: {
|
|
7
|
+
removeOnComplete: false,
|
|
8
|
+
removeOnFail: false,
|
|
9
|
+
attempts: 3,
|
|
10
|
+
backoff: {
|
|
11
|
+
type: 'exponential',
|
|
12
|
+
delay: 1000
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Add a shop translation job
|
|
19
|
+
* @param {Object} jobData
|
|
20
|
+
* @returns {Promise<void>}
|
|
21
|
+
*/
|
|
22
|
+
async function addShopTranslationJob({ shop_id, translation }) {
|
|
23
|
+
await shopTranslationQueue.add('translateShop', { shop_id, translation });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
shopTranslationQueue,
|
|
28
|
+
addShopTranslationJob
|
|
29
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { Queue } = require('bullmq');
|
|
2
|
+
const redisClient = require('../redis/redisClient');
|
|
3
|
+
|
|
4
|
+
const tournamentTranslationQueue = new Queue('tournamentTranslationQueue', {
|
|
5
|
+
connection: redisClient,
|
|
6
|
+
defaultJobOptions: {
|
|
7
|
+
removeOnComplete: false,
|
|
8
|
+
removeOnFail: false,
|
|
9
|
+
attempts: 3,
|
|
10
|
+
backoff: {
|
|
11
|
+
type: 'exponential',
|
|
12
|
+
delay: 1000
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Add a tournament translation job
|
|
19
|
+
* @param {Object} jobData
|
|
20
|
+
* @returns {Promise<void>}
|
|
21
|
+
*/
|
|
22
|
+
async function addTournamentTranslationJob({ tournament_id, translation }) {
|
|
23
|
+
await tournamentTranslationQueue.add('translateTournament', { tournament_id, translation });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
tournamentTranslationQueue,
|
|
28
|
+
addTournamentTranslationJob
|
|
29
|
+
};
|