@chopkola/common 1.0.124 → 1.0.125

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/build/index.d.ts CHANGED
@@ -11,3 +11,5 @@ export * from './types/apis';
11
11
  export * from './types/file.types';
12
12
  export * from './types/category';
13
13
  export * from './types/vendor';
14
+ export * from './types/menus';
15
+ export * from './types/products';
package/build/index.js CHANGED
@@ -27,3 +27,5 @@ __exportStar(require("./types/apis"), exports);
27
27
  __exportStar(require("./types/file.types"), exports);
28
28
  __exportStar(require("./types/category"), exports);
29
29
  __exportStar(require("./types/vendor"), exports);
30
+ __exportStar(require("./types/menus"), exports);
31
+ __exportStar(require("./types/products"), exports);
@@ -5,6 +5,12 @@ export declare const ACCESS_TOKEN_EXPIRATION_DURATION = "1h";
5
5
  export declare const REFRESH_TOKEN_EXPIRATION_DURATION = "1d";
6
6
  export declare const CART_SESSION_TOKEN_EXPIRATION_DURATION = "30d";
7
7
  export type SystemLogType = "info" | "success" | "warning" | "error";
8
+ export type UUID = string;
9
+ export interface Timestamps {
10
+ created_at: Date;
11
+ updated_at: Date;
12
+ }
13
+ export type DecimalString = string;
8
14
  export interface JwtPayload {
9
15
  first_name: string;
10
16
  last_name: string;
@@ -0,0 +1,83 @@
1
+ import { CategoryI } from "./category";
2
+ import { Timestamps, UUID } from "./global";
3
+ export type DietaryFlag = "vegan" | "vegetarian" | "gluten-free" | "spicy" | "halal" | "kosher" | string;
4
+ export interface AvailabilityScheduleEntry {
5
+ day: "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday";
6
+ from: string;
7
+ to: string;
8
+ }
9
+ export interface MenuItemI extends Timestamps {
10
+ id: UUID;
11
+ vendor_id: UUID;
12
+ category_id: UUID | null;
13
+ name: string;
14
+ description: string | null;
15
+ image_urls: string[] | null;
16
+ base_price: string;
17
+ is_available: boolean;
18
+ is_featured: boolean;
19
+ preparation_time_minutes: number | null;
20
+ dietary_flags: DietaryFlag[] | null;
21
+ nutritional_info?: Record<string, unknown>;
22
+ }
23
+ export interface ModifierGroupI extends Timestamps {
24
+ id: UUID;
25
+ vendor_id: UUID;
26
+ name: string;
27
+ min_selection: number;
28
+ max_selection: number;
29
+ }
30
+ export interface ModifierOptionI extends Timestamps {
31
+ id: UUID;
32
+ modifier_group_id: UUID;
33
+ name: string;
34
+ price_adjustment: string;
35
+ is_available: boolean;
36
+ }
37
+ export interface MenuI extends Timestamps {
38
+ id: UUID;
39
+ vendor_id: UUID;
40
+ name: string;
41
+ description: string | null;
42
+ is_active: boolean;
43
+ availability_schedule: AvailabilityScheduleEntry[] | null;
44
+ }
45
+ export interface MenuItemModifierGroup {
46
+ menu_item_id: UUID;
47
+ modifier_group_id: UUID;
48
+ sort_order: number;
49
+ }
50
+ export interface MenuMenuItem {
51
+ menu_id: UUID;
52
+ menu_item_id: UUID;
53
+ sort_order: number;
54
+ }
55
+ export type CreateMenuItemInput = Omit<MenuItemI, "id" | "created_at" | "updated_at">;
56
+ export type CreateModifierGroupInput = Omit<ModifierGroupI, "id" | "created_at" | "updated_at">;
57
+ export type CreateModifierOptionInput = Omit<ModifierOptionI, "id" | "created_at" | "updated_at">;
58
+ export type CreateMenuInput = Omit<MenuI, "id" | "created_at" | "updated_at">;
59
+ export interface ModifierGroupWithOptionsI extends ModifierGroupI {
60
+ options: ModifierOptionI[];
61
+ sort_order: number;
62
+ }
63
+ export interface MenuItemWithModifiersI extends MenuItemI {
64
+ modifier_groups: ModifierGroupWithOptionsI[];
65
+ }
66
+ export interface MenuWithItemsI extends MenuI {
67
+ items: (MenuItemWithModifiersI & {
68
+ sort_order: number;
69
+ })[];
70
+ }
71
+ export interface SelectedModifierOptionI {
72
+ modifier_group_id: UUID;
73
+ modifier_option_id: UUID;
74
+ }
75
+ export interface CartItem {
76
+ menu_item_id: UUID;
77
+ quantity: number;
78
+ selected_options: SelectedModifierOptionI[];
79
+ }
80
+ export interface VendorMenusManagementData {
81
+ categories: CategoryI[];
82
+ menus: MenuWithItemsI[];
83
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,92 @@
1
+ import { DecimalString, Timestamps, UUID } from "./global";
2
+ export declare enum StockStatus {
3
+ IN_STOCK = "in_stock",
4
+ LOW_STOCK = "low_stock",
5
+ OUT_OF_STOCK = "out_of_stock",
6
+ DISCONTINUED = "discontinued"
7
+ }
8
+ export declare enum StockMovementReason {
9
+ SALE = "sale",
10
+ RETURN = "return",
11
+ SUPPLIER_INTAKE = "supplier_intake",
12
+ RECOUNT_ADJUSTMENT = "recount_adjustment",
13
+ DAMAGE = "damage",
14
+ THEFT = "theft",
15
+ PROMOTION = "promotion",
16
+ TRANSFER_OUT = "transfer_out",
17
+ TRANSFER_IN = "transfer_in",
18
+ INITIAL_STOCK = "initial_stock"
19
+ }
20
+ export interface ProductAttributesI {
21
+ [key: string]: string | number | boolean | string[] | number[] | null;
22
+ }
23
+ export interface VariantOptionsI {
24
+ [optionName: string]: string;
25
+ }
26
+ export interface ProductI extends Timestamps {
27
+ id: UUID;
28
+ vendor_id: UUID;
29
+ name: string;
30
+ slug: string;
31
+ description: string | null;
32
+ brand: string | null;
33
+ images: string[] | null;
34
+ category_id: UUID | null;
35
+ tags: string[] | null;
36
+ attributes: ProductAttributesI | null;
37
+ is_approved: boolean;
38
+ }
39
+ export interface ProductVariantI extends Timestamps {
40
+ id: UUID;
41
+ product_id: UUID;
42
+ name_suffix: string | null;
43
+ options: VariantOptionsI;
44
+ images: string[] | null;
45
+ is_default: boolean;
46
+ }
47
+ export interface InventoryItemI extends Timestamps {
48
+ id: UUID;
49
+ vendor_id: UUID;
50
+ /**
51
+ * One of these must be present (enforced at DB level)
52
+ */
53
+ product_id: UUID | null;
54
+ product_variant_id: UUID | null;
55
+ sku: string;
56
+ price: DecimalString;
57
+ cost_price: DecimalString | null;
58
+ sale_price: DecimalString | null;
59
+ quantity: DecimalString;
60
+ low_stock_threshold: DecimalString | null;
61
+ stock_status: StockStatus;
62
+ is_trackable: boolean;
63
+ is_visible: boolean;
64
+ supplier: string | null;
65
+ storage_location: string | null;
66
+ }
67
+ export interface StockMovementI extends Timestamps {
68
+ id: UUID;
69
+ inventory_item_id: UUID;
70
+ quantity_change: DecimalString;
71
+ quantity_before: DecimalString;
72
+ quantity_after: DecimalString;
73
+ reason: StockMovementReason;
74
+ notes: string | null;
75
+ source_reference_id: UUID | null;
76
+ user_id: UUID | null;
77
+ }
78
+ export type CreateProductVariantInputI = Omit<ProductVariantI, "id" | "created_at" | "updated_at">;
79
+ export type CreateProductInputI = Omit<ProductI, "id" | "created_at" | "updated_at">;
80
+ export type CreateInventoryItemInputI = Omit<InventoryItemI, "id" | "created_at" | "updated_at">;
81
+ export type CreateStockMovementInputI = Omit<StockMovementI, "id" | "created_at" | "updated_at">;
82
+ export interface ProductWithVariantsI extends ProductI {
83
+ variants: ProductVariantI[];
84
+ }
85
+ export interface InventoryItemWithProductI extends InventoryItemI {
86
+ product?: ProductI | null;
87
+ variant?: ProductVariantI | null;
88
+ }
89
+ export interface InventoryLedgerI {
90
+ item: InventoryItemI;
91
+ movements: StockMovementI[];
92
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StockMovementReason = exports.StockStatus = void 0;
4
+ var StockStatus;
5
+ (function (StockStatus) {
6
+ StockStatus["IN_STOCK"] = "in_stock";
7
+ StockStatus["LOW_STOCK"] = "low_stock";
8
+ StockStatus["OUT_OF_STOCK"] = "out_of_stock";
9
+ StockStatus["DISCONTINUED"] = "discontinued";
10
+ })(StockStatus || (exports.StockStatus = StockStatus = {}));
11
+ var StockMovementReason;
12
+ (function (StockMovementReason) {
13
+ StockMovementReason["SALE"] = "sale";
14
+ StockMovementReason["RETURN"] = "return";
15
+ StockMovementReason["SUPPLIER_INTAKE"] = "supplier_intake";
16
+ StockMovementReason["RECOUNT_ADJUSTMENT"] = "recount_adjustment";
17
+ StockMovementReason["DAMAGE"] = "damage";
18
+ StockMovementReason["THEFT"] = "theft";
19
+ StockMovementReason["PROMOTION"] = "promotion";
20
+ StockMovementReason["TRANSFER_OUT"] = "transfer_out";
21
+ StockMovementReason["TRANSFER_IN"] = "transfer_in";
22
+ StockMovementReason["INITIAL_STOCK"] = "initial_stock";
23
+ })(StockMovementReason || (exports.StockMovementReason = StockMovementReason = {}));
24
+ // Either product_id OR product_variant_id
25
+ // But never both.
26
+ // Never neither.
27
+ // if (!input.product_id && !input.product_variant_id) {
28
+ // throw new Error("Inventory item must reference product or variant");
29
+ // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chopkola/common",
3
- "version": "1.0.124",
3
+ "version": "1.0.125",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "akrosoft technology ltd",