@hosterai/types 0.0.11 → 0.0.12

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 (2) hide show
  1. package/README.md +53 -39
  2. package/package.json +3 -1
package/README.md CHANGED
@@ -29,28 +29,29 @@ DTOs define the shape of data that is exchanged between different parts of the s
29
29
 
30
30
  **Available DTOs:**
31
31
 
32
- - `action.dto.ts`: Defines the structure for an action, including icon, label, URL, and how it opens.
32
+ - `action.dto.ts`: Defines the structure for a UI action.
33
33
  - `attachment.dto.ts`: Represents a file attachment.
34
34
  - `base-response.dto.ts`: A base structure for API responses.
35
+ - `client-data.dto.ts`: Defines the data structure for a client.
35
36
  - `company-data.dto.ts`: Holds all the relevant data for a company.
36
- - `error-response.dto.ts`: Defines the structure for error responses from the API.
37
- - `field.dto.ts`: Represents a generic field, likely for forms or dynamic data display.
38
- - `info.dto.ts`: Contains all the necessary information for a service integration.
39
- - `jwt.dto.ts`: DTOs related to JSON Web Tokens (authentication).
37
+ - `error-response.dto.ts`: Defines the structure for error responses.
38
+ - `field.dto.ts`: Represents a generic field for forms or dynamic data.
39
+ - `info.dto.ts`: Contains all necessary information for a service integration.
40
+ - `jwt.dto.ts`: DTOs related to JSON Web Tokens.
40
41
  - `menu.dto.ts`: Defines the structure for menu items.
41
42
  - `multilang-text.dto.ts`: A DTO for handling text in multiple languages.
42
43
  - `response-data.dto.ts`: A generic wrapper for response data.
43
44
  - `setup-status-response.dto.ts`: DTO for returning the setup status.
44
45
  - `success-response.dto.ts`: Defines the structure for successful API responses.
45
46
  - `tab.dto.ts`: Represents a tab in a user interface.
46
- - `submenu.dto.ts`: Represents a submenu item, extending the `TabDto`.
47
+ - `submenu.dto.ts`: Represents a submenu item.
47
48
  - `task-response.dto.ts`: DTO for responses related to background tasks.
48
49
  - `unit.dto.ts`: Represents a unit for pay-per-use billing.
49
50
 
50
51
  **Notification DTOs:**
51
52
 
52
53
  - `notification/notification-info.dto.ts`: Contains detailed information about a notification.
53
- - `notification/notification-request.dto.ts`: The primary DTO for requesting a new notification.
54
+ - `notification/notification-send-request.dto.ts`: The primary DTO for requesting a new notification.
54
55
  - `notification/receiver/receiver-email.dto.ts`: Defines the receiver for an email notification.
55
56
  - `notification/receiver/receiver-push.dto.ts`: Defines the receiver for a push notification.
56
57
  - `notification/receiver/receiver-sms.dto.ts`: Defines the receiver for an SMS notification.
@@ -58,25 +59,38 @@ DTOs define the shape of data that is exchanged between different parts of the s
58
59
  - `notification/sender/sender-push.dto.ts`: Defines the sender for a push notification.
59
60
  - `notification/sender/sender-sms.dto.ts`: Defines the sender for an SMS notification.
60
61
 
62
+ **Product DTOs:**
63
+
64
+ - `product/product-info.dto.ts`: Contains detailed information about a product.
65
+ - `product/product-item-data.dto.ts`: Represents the data of a specific product item.
66
+ - `product/requests/*`: DTOs for product-related requests (create, delete, upgrade, etc.).
67
+ - `product/responses/*`: DTOs for product-related responses.
68
+
61
69
  ### Enums
62
70
 
63
- Enums provide a set of named constants for common types, such as roles, languages, or notification types, preventing common errors with magic strings.
71
+ Enums provide a set of named constants for common types, preventing errors with magic strings.
64
72
 
65
73
  **Key Enums:**
66
74
 
67
- - `ActionsEnum`: Defines the possible actions that can be performed.
75
+ - `ActionsEnum`: Defines possible actions.
68
76
  - `CountryEnum`: A list of all countries.
69
- - `EventsEnum`: Defines the events that can be triggered.
70
- - `FieldTypeEnum`: Defines the types of fields that can be used.
77
+ - `DurationEnum`: Defines billing durations (e.g., `MONTHLY`, `YEARLY`).
78
+ - `EventsEnum`: Defines triggerable events.
79
+ - `FieldTypeEnum`: Defines types of fields.
71
80
  - `LanguageEnum`: A list of supported languages.
72
- - `NotificationMessageTypeEnum`: Defines the type of notification (e.g., `EMAIL`, `SMS`, `PUSH`).
81
+ - `NotificationMessageTypeEnum`: Defines the type of notification (e.g., `EMAIL`, `SMS`).
73
82
  - `OpenMethodEnum`: Defines how an action's URL should be opened.
74
- - `RolesEnum`: Defines user roles within the system.
83
+ - `ResponseStatusEnum`: Defines the status of a response (e.g., `COMPLETED`, `FAILED`).
84
+ - `RolesEnum`: Defines user roles.
75
85
  - `SetupStatusEnum`: Defines the status of a setup process.
76
86
 
87
+ ### Interfaces
88
+
89
+ - `product/product.interface.ts`: Defines the contract for a product module.
90
+
77
91
  ### Validators
78
92
 
79
- This package includes validation functions that leverage `class-validator` and `class-transformer` to ensure that incoming data conforms to the DTO definitions. To use the validators, you must have `reflect-metadata` imported in your project's entry file.
93
+ This package includes validation functions that leverage `class-validator` to ensure that incoming data conforms to the DTO definitions.
80
94
 
81
95
  **Available Validators:**
82
96
 
@@ -91,45 +105,45 @@ This package includes validation functions that leverage `class-validator` and `
91
105
 
92
106
  ## Usage Example
93
107
 
94
- Here is an example of how to use the `NotificationRequestDto` and its validator.
108
+ Here is an example of how to use a DTO and its validator.
95
109
 
96
110
  First, import the necessary DTO, Enum, and validator function:
97
111
 
98
112
  ```typescript
99
113
  import {
100
- NotificationRequestDto,
101
- NotificationMessageTypeEnum,
102
- validateNotificationRequestDto,
114
+ ProductCreateRequestDto,
115
+ ClientDataDto,
116
+ ProductItemDataDto,
117
+ DurationEnum,
118
+ validateProductCreateRequestDto, // Assuming a validator exists
103
119
  } from '@hosterai/types';
104
120
 
105
- // 1. Create a notification request object
106
- const notification: NotificationRequestDto = {
107
- notificationId: 'user-welcome-email-01',
108
- messageType: NotificationMessageTypeEnum.EMAIL,
109
- sender: {
110
- email: 'no-reply@hoster.ai',
111
- name: 'HosterAI Team',
112
- },
113
- receiver: {
114
- email: 'new-user@example.com',
121
+ // 1. Create a request object
122
+ const request: ProductCreateRequestDto = {
123
+ clientData: {
124
+ // ... client data
115
125
  },
116
- // Optional template data
117
- templateData: {
118
- username: 'JohnDoe',
119
- welcome_url: 'https://app.hoster.ai/welcome',
126
+ itemData: {
127
+ itemId: 'item-123',
128
+ productAttributes: {
129
+ // ... product attributes
130
+ },
131
+ itemAttributes: {
132
+ // ... item attributes
133
+ },
134
+ duration: DurationEnum.MONTHLY,
120
135
  },
121
136
  };
122
137
 
123
138
  // 2. Validate the object
124
- const errors = validateNotificationRequestDto(notification);
139
+ // const errors = validateProductCreateRequestDto(request);
125
140
 
126
141
  // 3. Check for errors
127
- if (errors.length > 0) {
128
- console.error('Validation failed:', errors);
129
- } else {
130
- console.log('Validation successful! Ready to send.');
131
- // Proceed to send the notification...
132
- }
142
+ // if (errors.length > 0) {
143
+ // console.error('Validation failed:', errors);
144
+ // } else {
145
+ // console.log('Validation successful!');
146
+ // }
133
147
  ```
134
148
 
135
149
  ## Building from Source
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hosterai/types",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -15,6 +15,7 @@
15
15
  "license": "MIT",
16
16
  "description": "",
17
17
  "devDependencies": {
18
+ "@types/express": "^5.0.3",
18
19
  "@types/fs-extra": "^11.0.4",
19
20
  "@types/jest": "^30.0.0",
20
21
  "@typescript-eslint/eslint-plugin": "^8.35.0",
@@ -35,6 +36,7 @@
35
36
  "peerDependencies": {
36
37
  "class-transformer": "^0.5.1",
37
38
  "class-validator": "^0.14.2",
39
+ "express": "^5.1.0",
38
40
  "reflect-metadata": "^0.2.2"
39
41
  },
40
42
  "files": [