qeai-sdk 2.0.4 → 2.0.5

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.
@@ -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);
@@ -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);
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qeai-sdk",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "In this version we have added the interfaces for the qhay sdk",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {