@chopkola/common 1.0.139 → 1.0.141

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.
@@ -43,6 +43,10 @@ export type VendorProductsStats = {
43
43
  out_of_stock: BackendVendorProductStatistics;
44
44
  top_category: BackendVendorProductStatistics;
45
45
  };
46
+ export declare enum ProductTypeEnum {
47
+ SIMPLE = "simple",
48
+ VARIANT = "variant"
49
+ }
46
50
  export interface ProductI extends Timestamps {
47
51
  id: UUID;
48
52
  vendor_id: UUID;
@@ -92,22 +96,43 @@ export interface StockMovementI extends Timestamps {
92
96
  source_reference_id: UUID | null;
93
97
  user_id: UUID | null;
94
98
  }
95
- export interface ProductWithVariantsI extends ProductI {
96
- variants: ProductVariantI[];
99
+ export interface InventoryWithMovementsI extends InventoryItemI {
100
+ movements: StockMovementI[];
101
+ }
102
+ export interface ProductVariantAggregateI extends ProductVariantI {
103
+ inventory: InventoryWithMovementsI | null;
97
104
  }
98
- export interface InventoryItemWithProductI extends InventoryItemI {
99
- product?: ProductWithVariantsI | null;
100
- movements?: StockMovementI[];
105
+ /**
106
+ * Product WITHOUT variants
107
+ */
108
+ export interface ProductSimpleAggregateI extends ProductI {
109
+ type: "simple";
110
+ inventory: InventoryWithMovementsI | null;
111
+ variants: [];
101
112
  }
102
- export interface InventoryItemWithProductAndVariantI extends InventoryItemI {
103
- product?: ProductI | null;
104
- variant?: ProductVariantI | null;
105
- movements?: StockMovementI[];
113
+ /**
114
+ * Product WITH variants
115
+ */
116
+ export interface ProductWithVariantsAggregateI extends ProductI {
117
+ type: "variant";
118
+ inventory: null;
119
+ variants: ProductVariantAggregateI[];
106
120
  }
121
+ /**
122
+ * FINAL PRODUCT TYPE
123
+ */
124
+ export type ProductAggregateI = ProductSimpleAggregateI | ProductWithVariantsAggregateI;
107
125
  export type CreateProductInput = Omit<ProductI, "id" | "created_at" | "updated_at">;
126
+ export type UpdateProductInput = Partial<CreateProductInput>;
108
127
  export type CreateProductVariantInput = Omit<ProductVariantI, "id" | "created_at" | "updated_at">;
128
+ export type UpdateProductVariantInput = Partial<CreateProductVariantInput>;
109
129
  export type CreateInventoryItemInput = Omit<InventoryItemI, "id" | "created_at" | "updated_at" | "stock_status">;
130
+ export type UpdateInventoryItemInput = Partial<CreateInventoryItemInput>;
110
131
  export type CreateStockMovementInput = Omit<StockMovementI, "id" | "created_at" | "updated_at">;
132
+ /**
133
+ * Enforces DB constraint:
134
+ * Either product OR variant — never both
135
+ */
111
136
  export type InventoryLink = {
112
137
  product_id: UUID;
113
138
  product_variant_id: null;
@@ -116,10 +141,10 @@ export type InventoryLink = {
116
141
  product_variant_id: UUID;
117
142
  };
118
143
  export interface VendorProductsManagementData {
119
- inventories: InventoryItemWithProductAndVariantI[];
144
+ products: ProductAggregateI[];
120
145
  stats: VendorProductsStats;
121
146
  }
122
147
  export interface VendorCreateOrEditProductPageData {
123
148
  categories: CategoryI[];
124
- product?: InventoryItemWithProductI;
149
+ product?: ProductAggregateI;
125
150
  }
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VendorProductsStatisticsIconEnum = exports.StockMovementReasonEnum = exports.StockStatusEnum = void 0;
3
+ exports.ProductTypeEnum = 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";
@@ -28,3 +31,11 @@ var VendorProductsStatisticsIconEnum;
28
31
  VendorProductsStatisticsIconEnum["TRASH_2"] = "trash_2";
29
32
  VendorProductsStatisticsIconEnum["FILTER"] = "filter";
30
33
  })(VendorProductsStatisticsIconEnum || (exports.VendorProductsStatisticsIconEnum = VendorProductsStatisticsIconEnum = {}));
34
+ /* -------------------------------------------------------------------------- */
35
+ /* CORE ENTITIES */
36
+ /* -------------------------------------------------------------------------- */
37
+ var ProductTypeEnum;
38
+ (function (ProductTypeEnum) {
39
+ ProductTypeEnum["SIMPLE"] = "simple";
40
+ ProductTypeEnum["VARIANT"] = "variant";
41
+ })(ProductTypeEnum || (exports.ProductTypeEnum = ProductTypeEnum = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chopkola/common",
3
- "version": "1.0.139",
3
+ "version": "1.0.141",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "akrosoft technology ltd",