@chopkola/common 1.0.138 → 1.0.140

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.
@@ -92,17 +92,43 @@ export interface StockMovementI extends Timestamps {
92
92
  source_reference_id: UUID | null;
93
93
  user_id: UUID | null;
94
94
  }
95
- export interface ProductWithVariantsI extends ProductI {
96
- variants: ProductVariantI[];
95
+ export interface InventoryWithMovementsI extends InventoryItemI {
96
+ movements: StockMovementI[];
97
97
  }
98
- export interface InventoryItemWithProductI extends InventoryItemI {
99
- product?: ProductWithVariantsI | null;
100
- movements?: StockMovementI[];
98
+ export interface ProductVariantAggregateI extends ProductVariantI {
99
+ inventory: InventoryWithMovementsI | null;
101
100
  }
101
+ /**
102
+ * Product WITHOUT variants
103
+ */
104
+ export interface ProductSimpleAggregateI extends ProductI {
105
+ type: "simple";
106
+ inventory: InventoryWithMovementsI | null;
107
+ variants: [];
108
+ }
109
+ /**
110
+ * Product WITH variants
111
+ */
112
+ export interface ProductWithVariantsAggregateI extends ProductI {
113
+ type: "variant";
114
+ inventory: null;
115
+ variants: ProductVariantAggregateI[];
116
+ }
117
+ /**
118
+ * FINAL PRODUCT TYPE
119
+ */
120
+ export type ProductAggregateI = ProductSimpleAggregateI | ProductWithVariantsAggregateI;
102
121
  export type CreateProductInput = Omit<ProductI, "id" | "created_at" | "updated_at">;
122
+ export type UpdateProductInput = Partial<CreateProductInput>;
103
123
  export type CreateProductVariantInput = Omit<ProductVariantI, "id" | "created_at" | "updated_at">;
124
+ export type UpdateProductVariantInput = Partial<CreateProductVariantInput>;
104
125
  export type CreateInventoryItemInput = Omit<InventoryItemI, "id" | "created_at" | "updated_at" | "stock_status">;
126
+ export type UpdateInventoryItemInput = Partial<CreateInventoryItemInput>;
105
127
  export type CreateStockMovementInput = Omit<StockMovementI, "id" | "created_at" | "updated_at">;
128
+ /**
129
+ * Enforces DB constraint:
130
+ * Either product OR variant — never both
131
+ */
106
132
  export type InventoryLink = {
107
133
  product_id: UUID;
108
134
  product_variant_id: null;
@@ -111,10 +137,10 @@ export type InventoryLink = {
111
137
  product_variant_id: UUID;
112
138
  };
113
139
  export interface VendorProductsManagementData {
114
- inventoriesWithProducts: InventoryItemWithProductI[];
140
+ products: ProductAggregateI[];
115
141
  stats: VendorProductsStats;
116
142
  }
117
143
  export interface VendorCreateOrEditProductPageData {
118
144
  categories: CategoryI[];
119
- product?: InventoryItemWithProductI;
145
+ product?: ProductAggregateI;
120
146
  }
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VendorProductsStatisticsIconEnum = exports.StockMovementReasonEnum = exports.StockStatusEnum = void 0;
4
+ /* -------------------------------------------------------------------------- */
5
+ /* ENUMS */
6
+ /* -------------------------------------------------------------------------- */
4
7
  var StockStatusEnum;
5
8
  (function (StockStatusEnum) {
6
9
  StockStatusEnum["IN_STOCK"] = "in_stock";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chopkola/common",
3
- "version": "1.0.138",
3
+ "version": "1.0.140",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "akrosoft technology ltd",