qeai-sdk 2.0.5 → 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.
@@ -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
+ };
@@ -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);
@@ -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.
@@ -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.5",
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": {