@chopkola/common 1.0.139 → 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,22 +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
  }
102
- export interface InventoryItemWithProductAndVariantI extends InventoryItemI {
103
- product?: ProductI | null;
104
- variant?: ProductVariantI | null;
105
- movements?: StockMovementI[];
101
+ /**
102
+ * Product WITHOUT variants
103
+ */
104
+ export interface ProductSimpleAggregateI extends ProductI {
105
+ type: "simple";
106
+ inventory: InventoryWithMovementsI | null;
107
+ variants: [];
106
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;
107
121
  export type CreateProductInput = Omit<ProductI, "id" | "created_at" | "updated_at">;
122
+ export type UpdateProductInput = Partial<CreateProductInput>;
108
123
  export type CreateProductVariantInput = Omit<ProductVariantI, "id" | "created_at" | "updated_at">;
124
+ export type UpdateProductVariantInput = Partial<CreateProductVariantInput>;
109
125
  export type CreateInventoryItemInput = Omit<InventoryItemI, "id" | "created_at" | "updated_at" | "stock_status">;
126
+ export type UpdateInventoryItemInput = Partial<CreateInventoryItemInput>;
110
127
  export type CreateStockMovementInput = Omit<StockMovementI, "id" | "created_at" | "updated_at">;
128
+ /**
129
+ * Enforces DB constraint:
130
+ * Either product OR variant — never both
131
+ */
111
132
  export type InventoryLink = {
112
133
  product_id: UUID;
113
134
  product_variant_id: null;
@@ -116,10 +137,10 @@ export type InventoryLink = {
116
137
  product_variant_id: UUID;
117
138
  };
118
139
  export interface VendorProductsManagementData {
119
- inventories: InventoryItemWithProductAndVariantI[];
140
+ products: ProductAggregateI[];
120
141
  stats: VendorProductsStats;
121
142
  }
122
143
  export interface VendorCreateOrEditProductPageData {
123
144
  categories: CategoryI[];
124
- product?: InventoryItemWithProductI;
145
+ product?: ProductAggregateI;
125
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.139",
3
+ "version": "1.0.140",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "akrosoft technology ltd",