@vendure/job-queue-plugin 2.3.3 → 2.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/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Vendure Job Queue Plugin
2
-
3
- This plugin includes alternate JobQueueStrategy implementations built on different technologies.
4
-
5
- Implemented:
6
-
7
- * The `PubSubPlugin` uses Google Cloud Pub/Sub to power the Vendure job queue.
8
- * The `BullMQJobQueuePlugin` uses Redis via BullMQ.
1
+ # Vendure Job Queue Plugin
2
+
3
+ This plugin includes alternate JobQueueStrategy implementations built on different technologies.
4
+
5
+ Implemented:
6
+
7
+ * The `PubSubPlugin` uses Google Cloud Pub/Sub to power the Vendure job queue.
8
+ * The `BullMQJobQueuePlugin` uses Redis via BullMQ.
@@ -1,110 +1,110 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getJobsByType = void 0;
4
- const script = `--[[
5
- Get job ids per provided states and filter by name
6
- Input:
7
- KEYS[1] 'prefix'
8
- ARGV[1] start
9
- ARGV[2] end
10
- ARGV[3] filterName
11
- ARGV[4...] types
12
- ]]
13
- local rcall = redis.call
14
- local prefix = KEYS[1]
15
- local rangeStart = tonumber(ARGV[1])
16
- local rangeEnd = tonumber(ARGV[2])
17
- local filterName = ARGV[3]
18
- local results = {}
19
-
20
- local targetSets = {}
21
-
22
- -- Initialize an empty array to hold the sets to unionize. The "completed" and "failed" lists
23
- -- are sorted sets
24
- local setsToUnionize = {}
25
- local typesInUnion = {}
26
-
27
- -- Initialize an empty array to hold lists to include. The "active" and "wait" lists are
28
- -- regular lists
29
- local listsToInclude = {}
30
-
31
-
32
- -- Iterate through ARGV starting from the first element (ARGV[1]) up to the end
33
- for i = 4, #ARGV do
34
- local setKey = prefix .. ARGV[i]
35
-
36
- -- Check if the setKey is valid (e.g., it exists and is a sorted set)
37
- local targetExists = redis.call('EXISTS', setKey)
38
- local listType = redis.call('TYPE', setKey).ok
39
-
40
- if targetExists == 1 and listType == 'zset' then
41
- -- Add the valid set to the array
42
- table.insert(setsToUnionize, setKey)
43
- table.insert(typesInUnion, ARGV[i])
44
- end
45
- if targetExists == 1 and listType == 'list' then
46
- -- Add the valid set to the array
47
- table.insert(listsToInclude, setKey)
48
- table.insert(typesInUnion, ARGV[i])
49
- end
50
- end
51
-
52
- -- Define the destination key for the concatenated sorted set
53
- local tempSortedSetUnionKey = prefix .. 'union:' .. table.concat(typesInUnion, ':');
54
-
55
- if #listsToInclude == 0 and #setsToUnionize == 0 then
56
- return {0, {}}
57
- end
58
-
59
- -- Check if there are valid sets to unionize
60
- if #setsToUnionize > 0 then
61
- -- Use ZUNIONSTORE to concatenate the valid sorted sets into the destination key
62
- local numSets = #setsToUnionize
63
- redis.call('ZUNIONSTORE', tempSortedSetUnionKey, numSets, unpack(setsToUnionize))
64
- end
65
-
66
- local originalResults = rcall("ZREVRANGE", tempSortedSetUnionKey, 0, -1)
67
-
68
-
69
- if #listsToInclude > 0 then
70
- for _, listKey in ipairs(listsToInclude) do
71
- local list = rcall("LRANGE", listKey, 0, -1)
72
- for _, jobId in ipairs(list) do
73
- table.insert(originalResults, jobId)
74
- end
75
- end
76
- end
77
-
78
-
79
- -- Define a custom comparison function for sorting in descending order
80
- local function compareDescending(a, b)
81
- return tonumber(a) > tonumber(b)
82
- end
83
-
84
- -- Sort the table in descending order
85
- table.sort(originalResults, compareDescending)
86
-
87
- local filteredResults = {}
88
- local totalResults = 0
89
-
90
- for _, job in ipairs(originalResults) do
91
- local jobName = rcall("HGET", prefix .. job, "name");
92
- if filterName ~= "" and jobName == filterName then
93
- if rangeStart <= totalResults and #filteredResults < rangeEnd then
94
- table.insert(filteredResults, job)
95
- end
96
- totalResults = totalResults + 1
97
- elseif filterName == "" then
98
- if rangeStart <= totalResults and #filteredResults < rangeEnd then
99
- table.insert(filteredResults, job)
100
- end
101
- totalResults = totalResults + 1
102
- end
103
- end
104
-
105
- rcall("DEL", tempSortedSetUnionKey)
106
-
107
- return {totalResults, filteredResults}
4
+ const script = `--[[
5
+ Get job ids per provided states and filter by name
6
+ Input:
7
+ KEYS[1] 'prefix'
8
+ ARGV[1] start
9
+ ARGV[2] end
10
+ ARGV[3] filterName
11
+ ARGV[4...] types
12
+ ]]
13
+ local rcall = redis.call
14
+ local prefix = KEYS[1]
15
+ local rangeStart = tonumber(ARGV[1])
16
+ local rangeEnd = tonumber(ARGV[2])
17
+ local filterName = ARGV[3]
18
+ local results = {}
19
+
20
+ local targetSets = {}
21
+
22
+ -- Initialize an empty array to hold the sets to unionize. The "completed" and "failed" lists
23
+ -- are sorted sets
24
+ local setsToUnionize = {}
25
+ local typesInUnion = {}
26
+
27
+ -- Initialize an empty array to hold lists to include. The "active" and "wait" lists are
28
+ -- regular lists
29
+ local listsToInclude = {}
30
+
31
+
32
+ -- Iterate through ARGV starting from the first element (ARGV[1]) up to the end
33
+ for i = 4, #ARGV do
34
+ local setKey = prefix .. ARGV[i]
35
+
36
+ -- Check if the setKey is valid (e.g., it exists and is a sorted set)
37
+ local targetExists = redis.call('EXISTS', setKey)
38
+ local listType = redis.call('TYPE', setKey).ok
39
+
40
+ if targetExists == 1 and listType == 'zset' then
41
+ -- Add the valid set to the array
42
+ table.insert(setsToUnionize, setKey)
43
+ table.insert(typesInUnion, ARGV[i])
44
+ end
45
+ if targetExists == 1 and listType == 'list' then
46
+ -- Add the valid set to the array
47
+ table.insert(listsToInclude, setKey)
48
+ table.insert(typesInUnion, ARGV[i])
49
+ end
50
+ end
51
+
52
+ -- Define the destination key for the concatenated sorted set
53
+ local tempSortedSetUnionKey = prefix .. 'union:' .. table.concat(typesInUnion, ':');
54
+
55
+ if #listsToInclude == 0 and #setsToUnionize == 0 then
56
+ return {0, {}}
57
+ end
58
+
59
+ -- Check if there are valid sets to unionize
60
+ if #setsToUnionize > 0 then
61
+ -- Use ZUNIONSTORE to concatenate the valid sorted sets into the destination key
62
+ local numSets = #setsToUnionize
63
+ redis.call('ZUNIONSTORE', tempSortedSetUnionKey, numSets, unpack(setsToUnionize))
64
+ end
65
+
66
+ local originalResults = rcall("ZREVRANGE", tempSortedSetUnionKey, 0, -1)
67
+
68
+
69
+ if #listsToInclude > 0 then
70
+ for _, listKey in ipairs(listsToInclude) do
71
+ local list = rcall("LRANGE", listKey, 0, -1)
72
+ for _, jobId in ipairs(list) do
73
+ table.insert(originalResults, jobId)
74
+ end
75
+ end
76
+ end
77
+
78
+
79
+ -- Define a custom comparison function for sorting in descending order
80
+ local function compareDescending(a, b)
81
+ return tonumber(a) > tonumber(b)
82
+ end
83
+
84
+ -- Sort the table in descending order
85
+ table.sort(originalResults, compareDescending)
86
+
87
+ local filteredResults = {}
88
+ local totalResults = 0
89
+
90
+ for _, job in ipairs(originalResults) do
91
+ local jobName = rcall("HGET", prefix .. job, "name");
92
+ if filterName ~= "" and jobName == filterName then
93
+ if rangeStart <= totalResults and #filteredResults < rangeEnd then
94
+ table.insert(filteredResults, job)
95
+ end
96
+ totalResults = totalResults + 1
97
+ elseif filterName == "" then
98
+ if rangeStart <= totalResults and #filteredResults < rangeEnd then
99
+ table.insert(filteredResults, job)
100
+ end
101
+ totalResults = totalResults + 1
102
+ end
103
+ end
104
+
105
+ rcall("DEL", tempSortedSetUnionKey)
106
+
107
+ return {totalResults, filteredResults}
108
108
  `;
109
109
  exports.getJobsByType = {
110
110
  script,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendure/job-queue-plugin",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
4
4
  "license": "MIT",
5
5
  "main": "package/index.js",
6
6
  "types": "package/index.d.ts",
@@ -23,12 +23,12 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "@google-cloud/pubsub": "^2.8.0",
26
- "@vendure/common": "^2.3.3",
27
- "@vendure/core": "^2.3.3",
26
+ "@vendure/common": "^2.3.4",
27
+ "@vendure/core": "^2.3.4",
28
28
  "bullmq": "^5.4.2",
29
29
  "ioredis": "^5.3.2",
30
30
  "rimraf": "^5.0.5",
31
31
  "typescript": "5.3.3"
32
32
  },
33
- "gitHead": "483dca6a13f4708ae9fc60f5ca8239aafcab0edb"
33
+ "gitHead": "4f4c3ae5f5505fc475c22baebcd774c1fc5a4713"
34
34
  }
package/LICENSE DELETED
@@ -1,9 +0,0 @@
1
- The MIT License
2
-
3
- Copyright (c) 2018 Michael Bromley
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.