qeai-sdk 2.0.4 → 2.0.6

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.
Files changed (28) hide show
  1. package/dist/constants/index.d.ts +15 -14
  2. package/dist/constants/index.js +16 -14
  3. package/dist/constants/inventory-commands.constant.d.ts +31 -0
  4. package/dist/constants/inventory-commands.constant.js +31 -0
  5. package/dist/dtos/categories/create-category.dto.js +2 -2
  6. package/dist/dtos/ingredients/create-ingredient.dto.d.ts +4 -3
  7. package/dist/dtos/ingredients/create-ingredient.dto.js +14 -9
  8. package/dist/dtos/ingredients/update-ingredient.dto.d.ts +5 -4
  9. package/dist/dtos/ingredients/update-ingredient.dto.js +13 -8
  10. package/dist/dtos/inventory/adjust-ingredient-inventory.dto.d.ts +50 -0
  11. package/dist/dtos/inventory/adjust-ingredient-inventory.dto.js +86 -0
  12. package/dist/dtos/inventory/set-ingredient-inventory.dto.d.ts +40 -0
  13. package/dist/dtos/inventory/set-ingredient-inventory.dto.js +72 -0
  14. package/dist/interfaces/ingredients/ingredient.interface.d.ts +2 -1
  15. package/dist/interfaces/inventory/index.d.ts +11 -0
  16. package/dist/interfaces/inventory/index.js +11 -0
  17. package/dist/interfaces/inventory/ingredient-inventory-response.interface.d.ts +16 -0
  18. package/dist/interfaces/inventory/ingredient-inventory-response.interface.js +1 -0
  19. package/dist/interfaces/inventory/ingredient-inventory.interface.d.ts +35 -0
  20. package/dist/interfaces/inventory/ingredient-inventory.interface.js +1 -0
  21. package/dist/interfaces/inventory/ingredients-inventory-list-response.interface.d.ts +17 -0
  22. package/dist/interfaces/inventory/ingredients-inventory-list-response.interface.js +1 -0
  23. package/dist/interfaces/products/product-recipe.interface.d.ts +3 -2
  24. package/dist/types/index.d.ts +3 -2
  25. package/dist/types/index.js +3 -2
  26. package/dist/types/ingredient-unit.type.d.ts +26 -0
  27. package/dist/types/ingredient-unit.type.js +30 -0
  28. package/package.json +1 -1
@@ -15,17 +15,18 @@
15
15
  *
16
16
  * @since 2.0.0
17
17
  */
18
- export * from './auth-commands.constant.js';
19
- export * from './category-commands.constant.js';
20
- export * from './chain-commands.constant.js';
21
- export * from './ingredient-commands.constant.js';
22
- export * from './order-commands.constant.js';
23
- export * from './payment-commands.constant.js';
24
- export * from './payment-events.constant.js';
25
- export * from './product-commands.constant.js';
26
- export * from './product-events.constant.js';
27
- export * from './question-commands.constant.js';
28
- export * from './restaurant-commands.constant.js';
29
- export * from './tag-commands.constant.js';
30
- export * from './translation-commands.constant.js';
31
- export * from './services-config.constant.js';
18
+ export * from "./auth-commands.constant.js";
19
+ export * from "./category-commands.constant.js";
20
+ export * from "./chain-commands.constant.js";
21
+ export * from "./ingredient-commands.constant.js";
22
+ export * from "./order-commands.constant.js";
23
+ export * from "./payment-commands.constant.js";
24
+ export * from "./payment-events.constant.js";
25
+ export * from "./product-commands.constant.js";
26
+ export * from "./product-events.constant.js";
27
+ export * from "./question-commands.constant.js";
28
+ export * from "./restaurant-commands.constant.js";
29
+ export * from "./tag-commands.constant.js";
30
+ export * from "./translation-commands.constant.js";
31
+ export * from "./services-config.constant.js";
32
+ export * from "./inventory-commands.constant.js";
@@ -16,28 +16,30 @@
16
16
  * @since 2.0.0
17
17
  */
18
18
  // Auth commands
19
- export * from './auth-commands.constant.js';
19
+ export * from "./auth-commands.constant.js";
20
20
  // Category commands
21
- export * from './category-commands.constant.js';
21
+ export * from "./category-commands.constant.js";
22
22
  // Chain commands
23
- export * from './chain-commands.constant.js';
23
+ export * from "./chain-commands.constant.js";
24
24
  // Ingredient commands
25
- export * from './ingredient-commands.constant.js';
25
+ export * from "./ingredient-commands.constant.js";
26
26
  // Order commands
27
- export * from './order-commands.constant.js';
27
+ export * from "./order-commands.constant.js";
28
28
  // Payment commands and events
29
- export * from './payment-commands.constant.js';
30
- export * from './payment-events.constant.js';
29
+ export * from "./payment-commands.constant.js";
30
+ export * from "./payment-events.constant.js";
31
31
  // Product commands and events
32
- export * from './product-commands.constant.js';
33
- export * from './product-events.constant.js';
32
+ export * from "./product-commands.constant.js";
33
+ export * from "./product-events.constant.js";
34
34
  // Question commands
35
- export * from './question-commands.constant.js';
35
+ export * from "./question-commands.constant.js";
36
36
  // Restaurant commands
37
- export * from './restaurant-commands.constant.js';
37
+ export * from "./restaurant-commands.constant.js";
38
38
  // Tag commands
39
- export * from './tag-commands.constant.js';
39
+ export * from "./tag-commands.constant.js";
40
40
  // Translation commands
41
- export * from './translation-commands.constant.js';
41
+ export * from "./translation-commands.constant.js";
42
42
  // Services config
43
- export * from './services-config.constant.js';
43
+ export * from "./services-config.constant.js";
44
+ // Inventory commands
45
+ export * from "./inventory-commands.constant.js";
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Inventory service command subjects.
3
+ *
4
+ * Centralized constant with all subject/message keys
5
+ * for commands between client(s) and the Inventory microservice.
6
+ * Each key corresponds to a MessagePattern handled by the microservice.
7
+ *
8
+ * Naming conventions:
9
+ * - Keys use SCREAMING_SNAKE_CASE.
10
+ * - Subject values use kebab-case between dots, matching the inventory domain.
11
+ *
12
+ * Usage examples:
13
+ * - INVENTORY_COMMANDS.SET_INGREDIENT_INVENTORY: Subject to set inventory for an ingredient.
14
+ * - INVENTORY_COMMANDS.ADJUST_INGREDIENT_INVENTORY: Subject to adjust inventory for an ingredient.
15
+ * - INVENTORY_COMMANDS.GET_INGREDIENT_INVENTORY: Subject to retrieve ingredient inventory for a restaurant.
16
+ *
17
+ * Centralizing these values ensures consistency, discoverability,
18
+ * and maintainability across the codebase.
19
+ *
20
+ * @since 2.0.0
21
+ */
22
+ export declare const INVENTORY_COMMANDS: {
23
+ /** Set the inventory value of an ingredient for a restaurant */
24
+ readonly SET_INGREDIENT_INVENTORY: "inventory.set-ingredient-inventory";
25
+ /** Adjust (increment or decrement) the inventory for a restaurant's ingredient */
26
+ readonly ADJUST_INGREDIENT_INVENTORY: "inventory.adjust-ingredient-inventory";
27
+ /** Retrieve the current inventory of a specific ingredient for a restaurant */
28
+ readonly GET_INGREDIENT_INVENTORY: "inventory.get-ingredient-inventory";
29
+ /** Retrieve all ingredients' inventories for a restaurant (with optional pagination) */
30
+ readonly GET_ALL_INGREDIENT_INVENTORIES: "inventory.get-all-ingredient-inventories";
31
+ };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Inventory service command subjects.
3
+ *
4
+ * Centralized constant with all subject/message keys
5
+ * for commands between client(s) and the Inventory microservice.
6
+ * Each key corresponds to a MessagePattern handled by the microservice.
7
+ *
8
+ * Naming conventions:
9
+ * - Keys use SCREAMING_SNAKE_CASE.
10
+ * - Subject values use kebab-case between dots, matching the inventory domain.
11
+ *
12
+ * Usage examples:
13
+ * - INVENTORY_COMMANDS.SET_INGREDIENT_INVENTORY: Subject to set inventory for an ingredient.
14
+ * - INVENTORY_COMMANDS.ADJUST_INGREDIENT_INVENTORY: Subject to adjust inventory for an ingredient.
15
+ * - INVENTORY_COMMANDS.GET_INGREDIENT_INVENTORY: Subject to retrieve ingredient inventory for a restaurant.
16
+ *
17
+ * Centralizing these values ensures consistency, discoverability,
18
+ * and maintainability across the codebase.
19
+ *
20
+ * @since 2.0.0
21
+ */
22
+ export const INVENTORY_COMMANDS = {
23
+ /** Set the inventory value of an ingredient for a restaurant */
24
+ SET_INGREDIENT_INVENTORY: "inventory.set-ingredient-inventory",
25
+ /** Adjust (increment or decrement) the inventory for a restaurant's ingredient */
26
+ ADJUST_INGREDIENT_INVENTORY: "inventory.adjust-ingredient-inventory",
27
+ /** Retrieve the current inventory of a specific ingredient for a restaurant */
28
+ GET_INGREDIENT_INVENTORY: "inventory.get-ingredient-inventory",
29
+ /** Retrieve all ingredients' inventories for a restaurant (with optional pagination) */
30
+ GET_ALL_INGREDIENT_INVENTORIES: "inventory.get-all-ingredient-inventories",
31
+ };
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { IsString, IsOptional, IsBoolean, IsNotEmpty, MinLength, MaxLength, IsUUID } from 'class-validator';
10
+ import { IsString, IsOptional, IsBoolean, IsMongoId, IsNotEmpty, MinLength, MaxLength } from 'class-validator';
11
11
  /**
12
12
  * DTO for creating a new category.
13
13
  *
@@ -66,7 +66,7 @@ __decorate([
66
66
  ], CreateCategoryDto.prototype, "status", void 0);
67
67
  __decorate([
68
68
  IsString(),
69
- IsUUID(),
69
+ IsMongoId(),
70
70
  IsNotEmpty(),
71
71
  __metadata("design:type", String)
72
72
  ], CreateCategoryDto.prototype, "createdBy", void 0);
@@ -1,3 +1,4 @@
1
+ import { type IngredientUnit } from "../../types/ingredient-unit.type";
1
2
  /**
2
3
  * DTO for creating a new ingredient.
3
4
  *
@@ -16,11 +17,11 @@ export declare class CreateIngredientDto {
16
17
  name: string;
17
18
  /**
18
19
  * Unit of measurement for the ingredient.
19
- * Must not be empty and must have a maximum length of 12 characters.
20
+ * Must be one of the allowed units defined in INGREDIENT_UNITS.
20
21
  *
21
- * @example "kg"
22
+ * @example "GRAM"
22
23
  */
23
- unit: string;
24
+ unit: IngredientUnit;
24
25
  /**
25
26
  * User ID of the user who created the ingredient.
26
27
  * Must be a valid MongoDB ObjectId.
@@ -7,7 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { IsString, IsNotEmpty, MaxLength, IsMongoId } from 'class-validator';
10
+ import { IsString, IsNotEmpty, MaxLength, IsMongoId, IsIn, } from "class-validator";
11
+ import { INGREDIENT_UNITS, } from "../../types/ingredient-unit.type";
11
12
  /**
12
13
  * DTO for creating a new ingredient.
13
14
  *
@@ -26,9 +27,9 @@ export class CreateIngredientDto {
26
27
  name;
27
28
  /**
28
29
  * Unit of measurement for the ingredient.
29
- * Must not be empty and must have a maximum length of 12 characters.
30
+ * Must be one of the allowed units defined in INGREDIENT_UNITS.
30
31
  *
31
- * @example "kg"
32
+ * @example "GRAM"
32
33
  */
33
34
  unit;
34
35
  /**
@@ -41,19 +42,23 @@ export class CreateIngredientDto {
41
42
  }
42
43
  __decorate([
43
44
  IsString(),
44
- IsNotEmpty({ message: 'Ingredient name is required' }),
45
- MaxLength(25, { message: 'Ingredient name must be at most 25 characters' }),
45
+ IsNotEmpty({ message: "Ingredient name is required" }),
46
+ MaxLength(25, { message: "Ingredient name must be at most 25 characters" }),
46
47
  __metadata("design:type", String)
47
48
  ], CreateIngredientDto.prototype, "name", void 0);
48
49
  __decorate([
49
50
  IsString(),
50
- IsNotEmpty({ message: 'Unit is required' }),
51
- MaxLength(12, { message: 'Unit must be at most 12 characters' }),
51
+ IsNotEmpty({ message: "Unit is required" }),
52
+ IsIn(INGREDIENT_UNITS, {
53
+ message: `Unit must be one of: ${INGREDIENT_UNITS.join(", ")}`,
54
+ }),
52
55
  __metadata("design:type", String)
53
56
  ], CreateIngredientDto.prototype, "unit", void 0);
54
57
  __decorate([
55
58
  IsString(),
56
- IsMongoId({ message: 'createdBy must be a valid MongoDB ObjectId' }),
57
- IsNotEmpty({ message: 'createdBy is required and must be a valid MongoDB ObjectId' }),
59
+ IsMongoId({ message: "createdBy must be a valid MongoDB ObjectId" }),
60
+ IsNotEmpty({
61
+ message: "createdBy is required and must be a valid MongoDB ObjectId",
62
+ }),
58
63
  __metadata("design:type", String)
59
64
  ], CreateIngredientDto.prototype, "createdBy", void 0);
@@ -1,3 +1,4 @@
1
+ import { type IngredientUnit } from "../../types/ingredient-unit.type";
1
2
  /**
2
3
  * DTO for updating an existing ingredient.
3
4
  *
@@ -11,7 +12,7 @@
11
12
  * {
12
13
  * "ingredientId": "550e8400-e29b-41d4-a716-446655440000",
13
14
  * "name": "Tomato",
14
- * "unit": "kg",
15
+ * "unit": "GRAM",
15
16
  * "updatedBy": "507f1f77bcf86cd799439011"
16
17
  * }
17
18
  */
@@ -25,11 +26,11 @@ export declare class UpdateIngredientDto {
25
26
  name?: string;
26
27
  /**
27
28
  * Unit of measurement for the ingredient.
28
- * Optional. If provided, must be a string with a maximum length of 12 characters.
29
+ * Optional. If provided, must be one of the allowed units defined in INGREDIENT_UNITS.
29
30
  *
30
- * @example "kg"
31
+ * @example "GRAM"
31
32
  */
32
- unit?: string;
33
+ unit?: IngredientUnit;
33
34
  /**
34
35
  * Unique identifier of the ingredient to update.
35
36
  * Required. Must be a valid UUID string.
@@ -7,7 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { IsString, IsOptional, IsMongoId, IsUUID, MaxLength, IsNotEmpty, } from "class-validator";
10
+ import { IsString, IsOptional, IsMongoId, IsUUID, MaxLength, IsNotEmpty, IsIn, } from "class-validator";
11
+ import { INGREDIENT_UNITS, } from "../../types/ingredient-unit.type";
11
12
  /**
12
13
  * DTO for updating an existing ingredient.
13
14
  *
@@ -21,7 +22,7 @@ import { IsString, IsOptional, IsMongoId, IsUUID, MaxLength, IsNotEmpty, } from
21
22
  * {
22
23
  * "ingredientId": "550e8400-e29b-41d4-a716-446655440000",
23
24
  * "name": "Tomato",
24
- * "unit": "kg",
25
+ * "unit": "GRAM",
25
26
  * "updatedBy": "507f1f77bcf86cd799439011"
26
27
  * }
27
28
  */
@@ -35,9 +36,9 @@ export class UpdateIngredientDto {
35
36
  name;
36
37
  /**
37
38
  * Unit of measurement for the ingredient.
38
- * Optional. If provided, must be a string with a maximum length of 12 characters.
39
+ * Optional. If provided, must be one of the allowed units defined in INGREDIENT_UNITS.
39
40
  *
40
- * @example "kg"
41
+ * @example "GRAM"
41
42
  */
42
43
  unit;
43
44
  /**
@@ -64,18 +65,22 @@ __decorate([
64
65
  __decorate([
65
66
  IsOptional(),
66
67
  IsString(),
67
- MaxLength(12, { message: "Unit must be at most 12 characters" }),
68
+ IsIn(INGREDIENT_UNITS, {
69
+ message: `Unit must be one of: ${INGREDIENT_UNITS.join(", ")}`,
70
+ }),
68
71
  __metadata("design:type", String)
69
72
  ], UpdateIngredientDto.prototype, "unit", void 0);
70
73
  __decorate([
71
74
  IsString(),
72
75
  IsUUID(),
73
- IsNotEmpty({ message: 'ingredientId is required and must be a valid UUID.' }),
76
+ IsNotEmpty({ message: "ingredientId is required and must be a valid UUID." }),
74
77
  __metadata("design:type", String)
75
78
  ], UpdateIngredientDto.prototype, "ingredientId", void 0);
76
79
  __decorate([
77
80
  IsString(),
78
- IsMongoId({ message: 'updatedBy must be a valid MongoDB ObjectId.' }),
79
- IsNotEmpty({ message: 'updatedBy is required and must be a valid MongoDB ObjectId.' }),
81
+ IsMongoId({ message: "updatedBy must be a valid MongoDB ObjectId." }),
82
+ IsNotEmpty({
83
+ message: "updatedBy is required and must be a valid MongoDB ObjectId.",
84
+ }),
80
85
  __metadata("design:type", String)
81
86
  ], UpdateIngredientDto.prototype, "updatedBy", void 0);
@@ -0,0 +1,50 @@
1
+ /**
2
+ * DTO for adjusting the inventory level of an ingredient by a delta value.
3
+ *
4
+ * This DTO is used when incrementing or decrementing the quantity of a specific
5
+ * ingredient in a restaurant's inventory (e.g., by usage, restock, waste, etc.).
6
+ *
7
+ * @property restaurantId - The restaurant's unique identifier (UUID v4).
8
+ * @property ingredientId - The ingredient's unique identifier (UUID v4).
9
+ * @property delta - The quantity change to apply (positive or negative, can be fractional).
10
+ * @property reason - The reason for this inventory adjustment (required, e.g., "usage", "restock").
11
+ * @property actor - The actor performing the adjustment; must match
12
+ * "user:<uuid>", "ms:<serviceName>", or "job:<jobName>".
13
+ *
14
+ * @example
15
+ * {
16
+ * restaurantId: "a1c7c3da-abcd-4312-b843-0fe7c44253a5",
17
+ * ingredientId: "b8e3ffcb-3029-4ed6-8c0d-43edf8fc542d",
18
+ * delta: -200.5,
19
+ * reason: "usage",
20
+ * actor: "user:aaaabbbb-cccc-dddd-eeee-ffffffffffff"
21
+ * }
22
+ *
23
+ * @since 2.0.0
24
+ */
25
+ export declare class AdjustIngredientInventoryDto {
26
+ /**
27
+ * The restaurant's unique identifier (UUID v4).
28
+ */
29
+ restaurantId: string;
30
+ /**
31
+ * The ingredient's unique identifier (UUID v4).
32
+ */
33
+ ingredientId: string;
34
+ /**
35
+ * The quantity change to apply (positive for additions, negative for deductions).
36
+ * Can be negative or positive, nonzero. Zero deltas are ignored by business logic.
37
+ */
38
+ delta: number;
39
+ /**
40
+ * The reason for this inventory adjustment (usage, restock, correction, waste, etc.).
41
+ */
42
+ reason: string;
43
+ /**
44
+ * The actor performing the adjustment; must match:
45
+ * - user:<uuid>
46
+ * - ms:<serviceName>
47
+ * - job:<jobName>
48
+ */
49
+ actor: string;
50
+ }
@@ -0,0 +1,86 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { IsString, IsUUID, IsNumber, IsNotEmpty, Matches, } from "class-validator";
11
+ /**
12
+ * DTO for adjusting the inventory level of an ingredient by a delta value.
13
+ *
14
+ * This DTO is used when incrementing or decrementing the quantity of a specific
15
+ * ingredient in a restaurant's inventory (e.g., by usage, restock, waste, etc.).
16
+ *
17
+ * @property restaurantId - The restaurant's unique identifier (UUID v4).
18
+ * @property ingredientId - The ingredient's unique identifier (UUID v4).
19
+ * @property delta - The quantity change to apply (positive or negative, can be fractional).
20
+ * @property reason - The reason for this inventory adjustment (required, e.g., "usage", "restock").
21
+ * @property actor - The actor performing the adjustment; must match
22
+ * "user:<uuid>", "ms:<serviceName>", or "job:<jobName>".
23
+ *
24
+ * @example
25
+ * {
26
+ * restaurantId: "a1c7c3da-abcd-4312-b843-0fe7c44253a5",
27
+ * ingredientId: "b8e3ffcb-3029-4ed6-8c0d-43edf8fc542d",
28
+ * delta: -200.5,
29
+ * reason: "usage",
30
+ * actor: "user:aaaabbbb-cccc-dddd-eeee-ffffffffffff"
31
+ * }
32
+ *
33
+ * @since 2.0.0
34
+ */
35
+ export class AdjustIngredientInventoryDto {
36
+ /**
37
+ * The restaurant's unique identifier (UUID v4).
38
+ */
39
+ restaurantId;
40
+ /**
41
+ * The ingredient's unique identifier (UUID v4).
42
+ */
43
+ ingredientId;
44
+ /**
45
+ * The quantity change to apply (positive for additions, negative for deductions).
46
+ * Can be negative or positive, nonzero. Zero deltas are ignored by business logic.
47
+ */
48
+ delta;
49
+ /**
50
+ * The reason for this inventory adjustment (usage, restock, correction, waste, etc.).
51
+ */
52
+ reason;
53
+ /**
54
+ * The actor performing the adjustment; must match:
55
+ * - user:<uuid>
56
+ * - ms:<serviceName>
57
+ * - job:<jobName>
58
+ */
59
+ actor;
60
+ }
61
+ __decorate([
62
+ IsString(),
63
+ IsUUID("4", { message: "restaurantId must be a valid UUID v4" }),
64
+ __metadata("design:type", String)
65
+ ], AdjustIngredientInventoryDto.prototype, "restaurantId", void 0);
66
+ __decorate([
67
+ IsString(),
68
+ IsUUID("4", { message: "ingredientId must be a valid UUID v4" }),
69
+ __metadata("design:type", String)
70
+ ], AdjustIngredientInventoryDto.prototype, "ingredientId", void 0);
71
+ __decorate([
72
+ IsNumber({}, { message: "delta must be a number" }),
73
+ __metadata("design:type", Number)
74
+ ], AdjustIngredientInventoryDto.prototype, "delta", void 0);
75
+ __decorate([
76
+ IsString(),
77
+ IsNotEmpty({ message: "reason must be specified" }),
78
+ __metadata("design:type", String)
79
+ ], AdjustIngredientInventoryDto.prototype, "reason", void 0);
80
+ __decorate([
81
+ IsString(),
82
+ Matches(/^(user:[0-9a-fA-F\-]{36}|ms:[a-zA-Z0-9_\-]+|job:[a-zA-Z0-9_\-]+)$/, {
83
+ message: 'actor must be in the format "user:<uuid>", "ms:<serviceName>" or "job:<jobName>"',
84
+ }),
85
+ __metadata("design:type", String)
86
+ ], AdjustIngredientInventoryDto.prototype, "actor", void 0);
@@ -0,0 +1,40 @@
1
+ /**
2
+ * DTO for updating an ingredient's inventory for a specific restaurant.
3
+ *
4
+ * @property restaurantId - The unique identifier of the restaurant (UUID).
5
+ * @property ingredientId - The unique identifier of the ingredient (UUID).
6
+ * @property quantity - The new quantity to set in the inventory (must be positive and greater than 0).
7
+ * @property actor - The actor performing the update; must match "user:<uuid>", "ms:<serviceName>", or "job:<jobName>".
8
+ *
9
+ * @example
10
+ * {
11
+ * restaurantId: "f354c5cd-31a7-4e9d-aef6-7b1c8e393d57",
12
+ * ingredientId: "dbb6bafd-8d22-45b9-9efb-af3fa0cfe245",
13
+ * quantity: 10.5,
14
+ * actor: "user:7cf5d452-0838-46c0-bbb2-94d22e9f2a79"
15
+ * }
16
+ *
17
+ * @since 2.0.0
18
+ */
19
+ export declare class SetIngredientInventoryDto {
20
+ /**
21
+ * The unique identifier for the restaurant (UUID).
22
+ */
23
+ restaurantId: string;
24
+ /**
25
+ * The unique identifier for the ingredient (UUID).
26
+ */
27
+ ingredientId: string;
28
+ /**
29
+ * The quantity to update in the inventory (must be positive and greater than 0).
30
+ */
31
+ quantity: number;
32
+ /**
33
+ * The actor performing the update.
34
+ * Accepted formats:
35
+ * - user:<uuid>
36
+ * - ms:<serviceName>
37
+ * - job:<jobName>
38
+ */
39
+ actor: string;
40
+ }
@@ -0,0 +1,72 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { IsString, IsUUID, IsNumber, Min, Matches } from "class-validator";
11
+ /**
12
+ * DTO for updating an ingredient's inventory for a specific restaurant.
13
+ *
14
+ * @property restaurantId - The unique identifier of the restaurant (UUID).
15
+ * @property ingredientId - The unique identifier of the ingredient (UUID).
16
+ * @property quantity - The new quantity to set in the inventory (must be positive and greater than 0).
17
+ * @property actor - The actor performing the update; must match "user:<uuid>", "ms:<serviceName>", or "job:<jobName>".
18
+ *
19
+ * @example
20
+ * {
21
+ * restaurantId: "f354c5cd-31a7-4e9d-aef6-7b1c8e393d57",
22
+ * ingredientId: "dbb6bafd-8d22-45b9-9efb-af3fa0cfe245",
23
+ * quantity: 10.5,
24
+ * actor: "user:7cf5d452-0838-46c0-bbb2-94d22e9f2a79"
25
+ * }
26
+ *
27
+ * @since 2.0.0
28
+ */
29
+ export class SetIngredientInventoryDto {
30
+ /**
31
+ * The unique identifier for the restaurant (UUID).
32
+ */
33
+ restaurantId;
34
+ /**
35
+ * The unique identifier for the ingredient (UUID).
36
+ */
37
+ ingredientId;
38
+ /**
39
+ * The quantity to update in the inventory (must be positive and greater than 0).
40
+ */
41
+ quantity;
42
+ /**
43
+ * The actor performing the update.
44
+ * Accepted formats:
45
+ * - user:<uuid>
46
+ * - ms:<serviceName>
47
+ * - job:<jobName>
48
+ */
49
+ actor;
50
+ }
51
+ __decorate([
52
+ IsString(),
53
+ IsUUID("4", { message: "restaurantId must be a valid UUID v4" }),
54
+ __metadata("design:type", String)
55
+ ], SetIngredientInventoryDto.prototype, "restaurantId", void 0);
56
+ __decorate([
57
+ IsString(),
58
+ IsUUID("4", { message: "ingredientId must be a valid UUID v4" }),
59
+ __metadata("design:type", String)
60
+ ], SetIngredientInventoryDto.prototype, "ingredientId", void 0);
61
+ __decorate([
62
+ IsNumber(),
63
+ Min(1, { message: "quantity must be a number greater than 0" }),
64
+ __metadata("design:type", Number)
65
+ ], SetIngredientInventoryDto.prototype, "quantity", void 0);
66
+ __decorate([
67
+ IsString(),
68
+ Matches(/^(user:[0-9a-fA-F\-]{36}|ms:[a-zA-Z0-9_\-]+|job:[a-zA-Z0-9_\-]+)$/, {
69
+ message: 'actor must be in the format "user:<uuid>", "ms:<serviceName>" or "job:<jobName>"',
70
+ }),
71
+ __metadata("design:type", String)
72
+ ], SetIngredientInventoryDto.prototype, "actor", void 0);
@@ -1,3 +1,4 @@
1
+ import { IngredientUnit } from "../../types";
1
2
  /**
2
3
  * Ingredient interface.
3
4
  *
@@ -31,7 +32,7 @@ export interface Ingredient {
31
32
  * @example "ml"
32
33
  * @example "pieces"
33
34
  */
34
- unit: string;
35
+ unit: IngredientUnit;
35
36
  /**
36
37
  * Whether the ingredient is active/available.
37
38
  * Determines if the ingredient can be used in recipes.
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Ingredient interfaces.
3
+ *
4
+ * This module exports interfaces used for ingredient management
5
+ * in the Products microservice.
6
+ *
7
+ * @since 2.0.0
8
+ */
9
+ export * from "./ingredient-inventory.interface.js";
10
+ export * from "./ingredient-inventory-response.interface.js";
11
+ export * from "./ingredients-inventory-list-response.interface.js";
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Ingredient interfaces.
3
+ *
4
+ * This module exports interfaces used for ingredient management
5
+ * in the Products microservice.
6
+ *
7
+ * @since 2.0.0
8
+ */
9
+ export * from "./ingredient-inventory.interface.js";
10
+ export * from "./ingredient-inventory-response.interface.js";
11
+ export * from "./ingredients-inventory-list-response.interface.js";
@@ -0,0 +1,16 @@
1
+ import { ApiResponse } from "../common/index.js";
2
+ import { IngredientInventory } from "./ingredient-inventory.interface.js";
3
+ /**
4
+ * Ingredient inventory response interface.
5
+ *
6
+ * Represents the response structure for retrieving a single ingredient inventory resource.
7
+ * Extends from the generic ApiResponse, encapsulating the ingredient inventory data.
8
+ *
9
+ * @since 2.0.0
10
+ */
11
+ export interface IngredientInventoryResponse extends ApiResponse {
12
+ /**
13
+ * Ingredient inventory data payload.
14
+ */
15
+ data: IngredientInventory;
16
+ }
@@ -0,0 +1,35 @@
1
+ import { Ingredient } from "../ingredients";
2
+ import { Restaurant } from "../restaurants";
3
+ /**
4
+ * IngredientInventory represents the inventory of a specific ingredient in a restaurant,
5
+ * including current quantity and optional low stock limit.
6
+ *
7
+ * This interface maps to the IngredientInventory model in Prisma schema.
8
+ *
9
+ * @property id - Unique identifier for the inventory record (UUID).
10
+ * @property restaurantId - Identifier of the restaurant to which the inventory belongs (UUID).
11
+ * @property ingredientId - Identifier of the ingredient (UUID).
12
+ * @property quantity - Current available quantity in the ingredient's base unit.
13
+ * @property lowStockLimit - (Optional) Threshold that indicates when stock is considered low.
14
+ * @property createdAt - Date and time when the inventory record was created.
15
+ * @property updatedAt - Date and time when the inventory record was last updated.
16
+ * @property createdBy - (Optional) User/service/job that created the record.
17
+ * @property updatedBy - (Optional) User/service/job that last updated the record.
18
+ */
19
+ export interface IngredientInventory {
20
+ id: string;
21
+ restaurantId: string;
22
+ ingredientId: string;
23
+ quantity: number;
24
+ lowStockLimit?: number;
25
+ createdAt: Date;
26
+ updatedAt: Date;
27
+ createdBy?: string;
28
+ updatedBy?: string;
29
+ }
30
+ export interface IngredientInventoryExpandRestaurant extends IngredientInventory {
31
+ restaurant: Restaurant;
32
+ }
33
+ export interface IngredientInventoryExpandIngredient extends IngredientInventory {
34
+ ingredient: Ingredient;
35
+ }
@@ -0,0 +1,17 @@
1
+ import { ApiResponse } from "../common/index.js";
2
+ import { PaginationResponse } from "../common/api-pagination-response.interface.js";
3
+ import { IngredientInventory } from "./ingredient-inventory.interface.js";
4
+ /**
5
+ * Ingredients inventory list response interface.
6
+ *
7
+ * Represents the response structure for retrieving a paginated list of ingredients inventory.
8
+ * Extends from the generic ApiResponse and encapsulates a paginated list of ingredients inventory.
9
+ *
10
+ * @since 2.0.0
11
+ */
12
+ export interface IngredientsInventoryListResponse extends ApiResponse {
13
+ /**
14
+ * Paginated data containing ingredients.
15
+ */
16
+ data: PaginationResponse<IngredientInventory>;
17
+ }
@@ -1,4 +1,5 @@
1
- import { Ingredient } from '../ingredients/ingredient.interface.js';
1
+ import { IngredientUnit } from "../../types/ingredient-unit.type.js";
2
+ import { Ingredient } from "../ingredients/ingredient.interface.js";
2
3
  /**
3
4
  * Product recipe interface.
4
5
  *
@@ -46,5 +47,5 @@ export interface ProductRecipe {
46
47
  * @example "ml"
47
48
  * @example "pieces"
48
49
  */
49
- unit: string;
50
+ unit: IngredientUnit;
50
51
  }
@@ -1,4 +1,5 @@
1
- export * from './order-mode.type.js';
2
- export * from './order-status.type.js';
1
+ export * from "./order-mode.type.js";
2
+ export * from "./order-status.type.js";
3
3
  export * from "./currency.type.js";
4
4
  export * from "./product-status.type.js";
5
+ export * from "./ingredient-unit.type.js";
@@ -1,4 +1,5 @@
1
- export * from './order-mode.type.js';
2
- export * from './order-status.type.js';
1
+ export * from "./order-mode.type.js";
2
+ export * from "./order-status.type.js";
3
3
  export * from "./currency.type.js";
4
4
  export * from "./product-status.type.js";
5
+ export * from "./ingredient-unit.type.js";
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Ingredient unit constants for the QeHay platform.
3
+ *
4
+ * This array defines all possible measurement units supported for ingredients in recipes, inventory,
5
+ * and menu composition. It acts as the single source of truth for unit values across all modules
6
+ * (client, waiter, kitchen, admin).
7
+ *
8
+ * - GRAM: Gramo
9
+ * - KILOGRAM: Kilogramo
10
+ * - MILLILITER: Mililitro
11
+ * - LITER: Litro
12
+ * - UNIT: Unidad (pieza/entero)
13
+ * - TABLESPOON: Cucharada
14
+ * - TEASPOON: Cucharadita
15
+ *
16
+ * @since 2.0.0
17
+ */
18
+ export declare const INGREDIENT_UNITS: readonly ["GRAM", "KILOGRAM", "MILLILITER", "LITER", "PIECE", "UNIT", "TEASPOON", "TABLESPOON", "CUP", "OUNCE", "POUND"];
19
+ /**
20
+ * Type representing all supported ingredient units within the QeHay platform.
21
+ * @see INGREDIENT_UNITS
22
+ *
23
+ * @example IngredientUnit.GRAM
24
+ * @example IngredientUnit.LITER
25
+ */
26
+ export type IngredientUnit = (typeof INGREDIENT_UNITS)[number];
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Ingredient unit constants for the QeHay platform.
3
+ *
4
+ * This array defines all possible measurement units supported for ingredients in recipes, inventory,
5
+ * and menu composition. It acts as the single source of truth for unit values across all modules
6
+ * (client, waiter, kitchen, admin).
7
+ *
8
+ * - GRAM: Gramo
9
+ * - KILOGRAM: Kilogramo
10
+ * - MILLILITER: Mililitro
11
+ * - LITER: Litro
12
+ * - UNIT: Unidad (pieza/entero)
13
+ * - TABLESPOON: Cucharada
14
+ * - TEASPOON: Cucharadita
15
+ *
16
+ * @since 2.0.0
17
+ */
18
+ export const INGREDIENT_UNITS = [
19
+ "GRAM",
20
+ "KILOGRAM",
21
+ "MILLILITER",
22
+ "LITER",
23
+ "PIECE",
24
+ "UNIT",
25
+ "TEASPOON",
26
+ "TABLESPOON",
27
+ "CUP",
28
+ "OUNCE",
29
+ "POUND",
30
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qeai-sdk",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "In this version we have added the interfaces for the qhay sdk",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {