@unchainedshop/core-products 5.0.0-alpha.3 → 5.0.0-alpha.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.
@@ -41,11 +41,13 @@ export const ProductsCollection = async (db) => {
41
41
  },
42
42
  ]);
43
43
  await buildDbIndexes(Products, [
44
- { index: { deleted: 1, status: 1, sequence: 1 } },
44
+ { index: { status: 1, sequence: 1, published: -1 } },
45
45
  { index: { slugs: 1 } },
46
46
  { index: { tags: 1 } },
47
47
  { index: { 'warehousing.sku': 1 }, options: { sparse: true } },
48
- ]);
48
+ { index: { 'bundleItems.productId': 1 }, options: { sparse: true } },
49
+ { index: { 'proxy.assignments.productId': 1 }, options: { sparse: true } },
50
+ ], { rebuild: false });
49
51
  await buildDbIndexes(ProductTexts, [
50
52
  { index: { productId: 1 } },
51
53
  { index: { slug: 1 } },
@@ -54,7 +54,7 @@ export const configureProductMediaModule = async ({ db }) => {
54
54
  const mediaList = ProductMedias.find(selector, {
55
55
  skip: offset,
56
56
  limit,
57
- sort: { sortKey: 1 },
57
+ sort: { sortKey: 1, _id: 1 },
58
58
  ...options,
59
59
  });
60
60
  return mediaList.toArray();
@@ -64,7 +64,7 @@ export const configureProductMediaModule = async ({ db }) => {
64
64
  const lastProductMedia = (await ProductMedias.findOne({
65
65
  productId: doc.productId,
66
66
  }, {
67
- sort: { sortKey: -1 },
67
+ sort: { sortKey: -1, _id: -1 },
68
68
  })) || { sortKey: 0 };
69
69
  sortKey = lastProductMedia.sortKey + 1;
70
70
  }
@@ -123,7 +123,7 @@ export const configureProductMediaModule = async ({ db }) => {
123
123
  }));
124
124
  const productMedias = await ProductMedias.find({
125
125
  _id: { $in: changedProductMediaIds },
126
- }, { sort: { sortKey: 1 } }).toArray();
126
+ }, { sort: { sortKey: 1, _id: 1 } }).toArray();
127
127
  await emit('PRODUCT_REORDER_MEDIA', { productMedias });
128
128
  return productMedias;
129
129
  },
@@ -108,7 +108,7 @@ export const configureProductPricesModule = ({ proxyProducts, db, }) => {
108
108
  ],
109
109
  timestamp: { $lte: referenceDate },
110
110
  expiresAt: { $gte: referenceDate },
111
- }, { sort: { timestamp: -1 } });
111
+ }, { sort: { timestamp: -1, _id: -1 } });
112
112
  if (!mostRecentCurrencyRate)
113
113
  return null;
114
114
  const rate = normalizeRate(baseCurrency, quoteCurrency, mostRecentCurrencyRate);
@@ -149,7 +149,7 @@ export const configureProductsModule = async (moduleInput) => {
149
149
  return {
150
150
  findProduct: async (params) => {
151
151
  if ('sku' in params) {
152
- return Products.findOne({ 'warehousing.sku': params.sku }, { sort: { sequence: 1 } });
152
+ return Products.findOne({ 'warehousing.sku': params.sku }, { sort: { sequence: 1, _id: 1 } });
153
153
  }
154
154
  if ('slug' in params && params.slug != null) {
155
155
  return Products.findOne({ slugs: params.slug }, {});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unchainedshop/core-products",
3
3
  "description": "Product catalog management module for the Unchained Engine",
4
- "version": "5.0.0-alpha.3",
4
+ "version": "5.0.0-alpha.4",
5
5
  "main": "lib/products-index.js",
6
6
  "types": "lib/products-index.d.ts",
7
7
  "type": "module",
@@ -42,6 +42,6 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "^26.2.0",
45
- "typescript": "^5.8.3"
45
+ "typescript": "^6.0.3"
46
46
  }
47
47
  }