@unchainedshop/core-worker 5.0.0-alpha.1 → 5.0.0-alpha.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.
@@ -1,4 +1,4 @@
1
- import { isDocumentDBCompatModeEnabled } from '@unchainedshop/mongodb';
1
+ import {} from '@unchainedshop/mongodb';
2
2
  import { buildDbIndexes } from '@unchainedshop/mongodb';
3
3
  const ONE_DAY_IN_SECONDS = 86400;
4
4
  export const WorkStatus = {
@@ -10,34 +10,32 @@ export const WorkStatus = {
10
10
  };
11
11
  export const WorkQueueCollection = async (db) => {
12
12
  const WorkQueue = db.collection('work_queue');
13
- if (!isDocumentDBCompatModeEnabled()) {
14
- await buildDbIndexes(WorkQueue, [
15
- {
16
- index: { originalWorkId: 'text', _id: 'text', worker: 'text', input: 'text', type: 'text' },
17
- options: {
18
- weights: {
19
- _id: 8,
20
- originalWorkId: 6,
21
- type: 5,
22
- worker: 4,
23
- input: 2,
24
- },
25
- name: 'workqueue_fulltext_search',
13
+ await buildDbIndexes(WorkQueue, [
14
+ {
15
+ index: { originalWorkId: 'text', _id: 'text', worker: 'text', input: 'text', type: 'text' },
16
+ options: {
17
+ weights: {
18
+ _id: 8,
19
+ originalWorkId: 6,
20
+ type: 5,
21
+ worker: 4,
22
+ input: 2,
26
23
  },
24
+ name: 'workqueue_fulltext_search',
27
25
  },
28
- ]);
29
- }
26
+ },
27
+ ]);
30
28
  await buildDbIndexes(WorkQueue, [
31
29
  {
32
30
  index: { created: -1 },
33
31
  options: { expireAfterSeconds: 30 * ONE_DAY_IN_SECONDS },
34
32
  },
35
- { index: { started: -1 } },
36
- { index: { finished: 1 } },
37
- { index: { scheduled: 1 } },
38
- { index: { priority: -1 } },
33
+ { index: { scheduled: 1, type: 1 } },
39
34
  { index: { type: 1 } },
40
35
  { index: { originalWorkId: 1 } },
36
+ { index: { started: 1 }, options: { sparse: true } },
37
+ { index: { finished: 1 }, options: { sparse: true } },
38
+ { index: { priority: -1 } },
41
39
  ]);
42
40
  return WorkQueue;
43
41
  };
@@ -1,6 +1,6 @@
1
1
  import os from 'node:os';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
- import { generateDbFilterById, buildSortOptions, generateDbObjectId, assertDocumentDBCompatMode, } from '@unchainedshop/mongodb';
3
+ import { generateDbFilterById, buildSortOptions, generateDbObjectId, } from '@unchainedshop/mongodb';
4
4
  import { emit, registerEvents } from '@unchainedshop/events';
5
5
  import { buildObfuscatedFieldsFilter, SortDirection, } from '@unchainedshop/utils';
6
6
  import { WorkQueueCollection, WorkStatus } from "../db/WorkQueueCollection.js";
@@ -58,7 +58,6 @@ export const buildQuerySelector = ({ created, scheduled, types, status, workId,
58
58
  query = generateDbFilterById(workId, query);
59
59
  }
60
60
  if (queryString) {
61
- assertDocumentDBCompatMode();
62
61
  query.$text = { $search: queryString };
63
62
  }
64
63
  return { ...query, ...rest };
@@ -318,7 +317,7 @@ export const configureWorkerModule = async ({ db, options }) => {
318
317
  try {
319
318
  const result = await WorkQueue.findOneAndUpdate(query, {
320
319
  $set: {
321
- input,
320
+ input: input || {},
322
321
  worker: null,
323
322
  updated: created,
324
323
  retries,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unchainedshop/core-worker",
3
3
  "description": "Background job and task queue module for the Unchained Engine",
4
- "version": "5.0.0-alpha.1",
4
+ "version": "5.0.0-alpha.3",
5
5
  "main": "lib/worker-index.js",
6
6
  "types": "lib/worker-index.d.ts",
7
7
  "type": "module",
@@ -35,11 +35,13 @@
35
35
  },
36
36
  "homepage": "https://github.com/unchainedshop/unchained#readme",
37
37
  "dependencies": {
38
+ "@unchainedshop/events": "^5.0.0-alpha.1",
38
39
  "@unchainedshop/logger": "^5.0.0-alpha.1",
40
+ "@unchainedshop/mongodb": "^5.0.0-alpha.1",
39
41
  "@unchainedshop/utils": "^5.0.0-alpha.1"
40
42
  },
41
43
  "devDependencies": {
42
- "@types/node": "^25.0.0",
44
+ "@types/node": "^26.2.0",
43
45
  "typescript": "^5.8.3"
44
46
  }
45
47
  }