@goweekdays/core 2.15.7 → 2.15.9

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @goweekdays/core
2
2
 
3
+ ## 2.15.9
4
+
5
+ ### Patch Changes
6
+
7
+ - fcf8414: Add asset item unique index
8
+
9
+ ## 2.15.8
10
+
11
+ ### Patch Changes
12
+
13
+ - c402102: Update asset item model
14
+
3
15
  ## 2.15.7
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -2230,6 +2230,7 @@ type TAssetItem = {
2230
2230
  _id?: ObjectId;
2231
2231
  orgId: ObjectId | string;
2232
2232
  name: string;
2233
+ normalizedName?: string;
2233
2234
  description?: string;
2234
2235
  assetCategory: TAssetItemCategory;
2235
2236
  assetClass: TAssetItemClass;
@@ -2237,6 +2238,8 @@ type TAssetItem = {
2237
2238
  purpose: TAssetItemPurpose;
2238
2239
  unit: string;
2239
2240
  price?: number;
2241
+ marketplacePrice?: number;
2242
+ isPublic: boolean;
2240
2243
  sku?: string;
2241
2244
  itemRefId?: string | ObjectId;
2242
2245
  remarks?: string;
package/dist/index.js CHANGED
@@ -22633,15 +22633,24 @@ function modelAssetItem(data) {
22633
22633
  "Price must be greater than 0 for items marked as 'for-sale'."
22634
22634
  );
22635
22635
  }
22636
+ if (data.isPublic && (data.marketplacePrice === void 0 || data.marketplacePrice === null)) {
22637
+ throw new import_utils115.BadRequestError(
22638
+ "Marketplace price is required for items marked as public."
22639
+ );
22640
+ }
22641
+ data.normalizedName = data.name.trim().toLowerCase();
22636
22642
  return {
22637
22643
  _id: data._id,
22638
22644
  orgId: data.orgId,
22639
22645
  name: data.name,
22646
+ normalizedName: data.normalizedName,
22640
22647
  description: data.description ?? "",
22641
22648
  assetCategory: data.assetCategory,
22642
22649
  assetClass: data.assetClass,
22643
22650
  unit: data.unit ?? "",
22644
22651
  price: data.price ?? 0,
22652
+ marketplacePrice: data.marketplacePrice ?? 0,
22653
+ isPublic: data.isPublic ?? false,
22645
22654
  sku: data.sku ?? "",
22646
22655
  brand: data.brand ?? "",
22647
22656
  trackingType: data.trackingType,
@@ -22683,7 +22692,16 @@ function useAssetItemRepo() {
22683
22692
  { key: { purpose: 1 } },
22684
22693
  { key: { trackingType: 1 } },
22685
22694
  { key: { status: 1 } },
22686
- { key: { name: "text" } }
22695
+ { key: { name: "text" } },
22696
+ {
22697
+ key: {
22698
+ orgId: 1,
22699
+ normalizedName: 1,
22700
+ purpose: 1,
22701
+ itemRefId: 1
22702
+ },
22703
+ unique: true
22704
+ }
22687
22705
  ]);
22688
22706
  } catch (error) {
22689
22707
  throw new import_utils116.BadRequestError("Failed to create asset item indexes.");