@hosterai/types 0.0.14 → 0.0.15

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.
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Data Transfer Object for field options.
3
+ * This class defines the structure and properties of a field option
4
+ * that can be used in form fields.
5
+ */
6
+ export declare class FieldOptionDto {
7
+ /**
8
+ * Key of the field option
9
+ */
10
+ key: string;
11
+ /**
12
+ * Value of the field option
13
+ */
14
+ value: string;
15
+ /**
16
+ * Indicates if the field option is disabled
17
+ */
18
+ disabled?: boolean;
19
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FieldOptionDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ /**
15
+ * Data Transfer Object for field options.
16
+ * This class defines the structure and properties of a field option
17
+ * that can be used in form fields.
18
+ */
19
+ class FieldOptionDto {
20
+ constructor() {
21
+ /**
22
+ * Indicates if the field option is disabled
23
+ */
24
+ this.disabled = false;
25
+ }
26
+ }
27
+ exports.FieldOptionDto = FieldOptionDto;
28
+ __decorate([
29
+ (0, class_validator_1.IsString)(),
30
+ (0, class_validator_1.IsDefined)(),
31
+ __metadata("design:type", String)
32
+ ], FieldOptionDto.prototype, "key", void 0);
33
+ __decorate([
34
+ (0, class_validator_1.IsString)(),
35
+ (0, class_validator_1.IsDefined)(),
36
+ __metadata("design:type", String)
37
+ ], FieldOptionDto.prototype, "value", void 0);
38
+ __decorate([
39
+ (0, class_validator_1.IsBoolean)(),
40
+ (0, class_validator_1.IsOptional)(),
41
+ __metadata("design:type", Boolean)
42
+ ], FieldOptionDto.prototype, "disabled", void 0);
@@ -1,5 +1,6 @@
1
1
  import { FieldTypeEnum } from '../enums/field-type.enum';
2
2
  import { MultilangTextDto } from './multilang-text.dto';
3
+ import { FieldOptionDto } from './field-option.dto';
3
4
  /**
4
5
  * Data Transfer Object for a form field.
5
6
  * This class defines the structure and properties of a single field
@@ -15,11 +16,16 @@ export declare class FieldDto {
15
16
  */
16
17
  label: MultilangTextDto[];
17
18
  /**
18
- * Value of action field
19
+ * Value of the field.
20
+ *
21
+ * String is when it is input, text area
22
+ * Number is when it is number
23
+ * FieldOptionDto is when it is checkbox
24
+ * FieldOptionDto[] is when it is radioboxes or select
19
25
  */
20
- value: string | number | Record<string, unknown>;
26
+ value: string | number | FieldOptionDto | FieldOptionDto[];
21
27
  /**
22
- * Type of label
28
+ * Type of the field
23
29
  */
24
30
  type: FieldTypeEnum;
25
31
  /**
@@ -43,15 +49,17 @@ export declare class FieldDto {
43
49
  */
44
50
  regexValidationErrorMessage?: MultilangTextDto[];
45
51
  /**
46
- * Indicates if the field has remote validation
52
+ * Indicates if the field triggers remote validation
47
53
  */
48
- remoteValidation?: boolean;
54
+ triggersRemoteValidation?: boolean;
49
55
  /**
50
- * Error message for the field
56
+ * Error message for the field for supported languages
51
57
  */
52
58
  remoteValidationErrorMessage?: MultilangTextDto[];
53
59
  /**
54
60
  * The item attribute is upgradable
61
+ * If the user has the permission to upgrade the item from his panel
62
+ * TODO: Let's see if this approach is the best way for the user to upgrade their item
55
63
  */
56
64
  upgradable: boolean;
57
65
  }
@@ -21,8 +21,14 @@ const multilang_text_dto_1 = require("./multilang-text.dto");
21
21
  */
22
22
  class FieldDto {
23
23
  constructor() {
24
+ /**
25
+ * Indicates if the field triggers remote validation
26
+ */
27
+ this.triggersRemoteValidation = false;
24
28
  /**
25
29
  * The item attribute is upgradable
30
+ * If the user has the permission to upgrade the item from his panel
31
+ * TODO: Let's see if this approach is the best way for the user to upgrade their item
26
32
  */
27
33
  this.upgradable = false;
28
34
  }
@@ -74,7 +80,7 @@ __decorate([
74
80
  (0, class_validator_1.IsBoolean)(),
75
81
  (0, class_validator_1.IsOptional)(),
76
82
  __metadata("design:type", Boolean)
77
- ], FieldDto.prototype, "remoteValidation", void 0);
83
+ ], FieldDto.prototype, "triggersRemoteValidation", void 0);
78
84
  __decorate([
79
85
  (0, class_validator_1.ValidateNested)({ each: true }),
80
86
  (0, class_transformer_1.Type)(() => multilang_text_dto_1.MultilangTextDto),
@@ -1,4 +1,4 @@
1
- import { ActionsEnum } from '../enums/actions.enum';
1
+ import { ProductActionsEnum } from '../enums/actions.enum';
2
2
  import { EventsEnum } from '../enums/events.enum';
3
3
  import { LanguageEnum } from '../enums/language.enum';
4
4
  import { RolesEnum } from '../enums/roles.enum';
@@ -34,7 +34,7 @@ export declare class InfoDto {
34
34
  /**
35
35
  * A list of actions that are supported by this integration.
36
36
  */
37
- supportedActions?: ActionsEnum[];
37
+ supportedActions?: ProductActionsEnum[];
38
38
  /**
39
39
  * A list of events that the integration listens to.
40
40
  * This allows the integration to react to specific events in the system.
@@ -1,4 +1,3 @@
1
- import { Request } from 'express';
2
1
  import { JwtDto } from '../jwt.dto';
3
2
  import { ProductInfoResponseDto } from './responses/product-info-response.dto';
4
3
  import { ErrorResponseDto } from '../error-response.dto';
@@ -23,6 +22,7 @@ import { ProductDeleteRequestDto } from './requests/product-delete-request.dto';
23
22
  import { ProductValidateAttributesRequestDto } from './requests/product-validate-attributes-request.dto';
24
23
  import { ProductValidateAttributesResponseDto } from './responses/product-validate-attributes-response.dto';
25
24
  import { SetupStatusResponseDto } from '../setup-status-response.dto';
25
+ import { CompanyDataDto } from '../company-data.dto';
26
26
  export interface ProductControllerInterface {
27
27
  info(request: Request & JwtDto): ProductInfoResponseDto | ErrorResponseDto;
28
28
  create(requestBody: ProductCreateRequestDto & JwtDto): Promise<ProductCreateResponseDto>;
@@ -32,13 +32,11 @@ export interface ProductControllerInterface {
32
32
  suspend(requestBody: ProductSuspendRequestDto & JwtDto): Promise<ProductSuspendResponseDto>;
33
33
  unsuspend(requestBody: ProductUnsuspendRequestDto & JwtDto): Promise<ProductUnsuspendResponseDto>;
34
34
  upgradable(requestBody: ProductUpgradableRequestDto & JwtDto): Promise<ProductUpgradableResponseDto>;
35
- Downgradable(requestBody: ProductDowngradableRequestDto & JwtDto): Promise<ProductDowngradableResponseDto>;
35
+ downgradeable(requestBody: ProductDowngradableRequestDto & JwtDto): Promise<ProductDowngradableResponseDto>;
36
36
  delete(requestBody: ProductDeleteRequestDto & JwtDto): Promise<ProductDeleteResponseDto>;
37
37
  validateProductAttributes(requestBody: ProductValidateAttributesRequestDto): Promise<ProductValidateAttributesResponseDto | ErrorResponseDto>;
38
38
  validateItemAttributes(requestBody: ProductValidateAttributesRequestDto): Promise<ProductValidateAttributesResponseDto | ErrorResponseDto>;
39
39
  setupStatus(): Promise<SetupStatusResponseDto>;
40
- install(request: Request & JwtDto): Promise<null | ErrorResponseDto>;
41
- uninstall(request: Request & JwtDto, requestBody: {
42
- companyId: string;
43
- }): Promise<null | ErrorResponseDto>;
40
+ install(requestBody: CompanyDataDto & JwtDto): Promise<null | ErrorResponseDto>;
41
+ uninstall(requestBody: JwtDto): Promise<null | ErrorResponseDto>;
44
42
  }
@@ -0,0 +1,23 @@
1
+ import { ProductItemDataDto } from '../product-item-data.dto';
2
+ /**
3
+ * Represents a request to validate item attributes.
4
+ * This DTO is used when a client needs to check the validity of a set of attribute values
5
+ * before proceeding with an action, such as creating or updating an item.
6
+ */
7
+ export declare class ItemValidateAttributesRequestDto {
8
+ /**
9
+ * The product data of the item.
10
+ */
11
+ productData: ProductItemDataDto;
12
+ /**
13
+ * The key of the attribute that triggered the validation.
14
+ * This helps the server understand the context of the validation request,
15
+ * especially in cases where validation rules are interdependent.
16
+ */
17
+ triggeredByKey: string;
18
+ /**
19
+ * A record of attribute values to be validated.
20
+ * The keys are the attribute identifiers, and the values are the data to be checked.
21
+ */
22
+ attributeValues: Record<string, unknown>;
23
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ItemValidateAttributesRequestDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ const product_item_data_dto_1 = require("../product-item-data.dto");
15
+ const class_transformer_1 = require("class-transformer");
16
+ /**
17
+ * Represents a request to validate item attributes.
18
+ * This DTO is used when a client needs to check the validity of a set of attribute values
19
+ * before proceeding with an action, such as creating or updating an item.
20
+ */
21
+ class ItemValidateAttributesRequestDto {
22
+ }
23
+ exports.ItemValidateAttributesRequestDto = ItemValidateAttributesRequestDto;
24
+ __decorate([
25
+ (0, class_validator_1.IsDefined)(),
26
+ (0, class_transformer_1.Type)(() => product_item_data_dto_1.ProductItemDataDto),
27
+ (0, class_validator_1.ValidateNested)(),
28
+ __metadata("design:type", product_item_data_dto_1.ProductItemDataDto)
29
+ ], ItemValidateAttributesRequestDto.prototype, "productData", void 0);
30
+ __decorate([
31
+ (0, class_validator_1.IsDefined)(),
32
+ (0, class_validator_1.IsString)(),
33
+ __metadata("design:type", String)
34
+ ], ItemValidateAttributesRequestDto.prototype, "triggeredByKey", void 0);
35
+ __decorate([
36
+ (0, class_validator_1.IsDefined)(),
37
+ (0, class_validator_1.IsObject)(),
38
+ __metadata("design:type", Object)
39
+ ], ItemValidateAttributesRequestDto.prototype, "attributeValues", void 0);
@@ -14,5 +14,5 @@ export declare class ProductValidateAttributesRequestDto {
14
14
  * A record of attribute values to be validated.
15
15
  * The keys are the attribute identifiers, and the values are the data to be checked.
16
16
  */
17
- values: Record<string, unknown>;
17
+ attributeValues: Record<string, unknown>;
18
18
  }
@@ -28,4 +28,4 @@ __decorate([
28
28
  (0, class_validator_1.IsDefined)(),
29
29
  (0, class_validator_1.IsObject)(),
30
30
  __metadata("design:type", Object)
31
- ], ProductValidateAttributesRequestDto.prototype, "values", void 0);
31
+ ], ProductValidateAttributesRequestDto.prototype, "attributeValues", void 0);
@@ -0,0 +1,13 @@
1
+ import { BaseResponse } from '../../base-response.dto';
2
+ import { FieldDto } from '../../field.dto';
3
+ /**
4
+ * Represents the response from validating item attributes.
5
+ * Contains the list of attributes that have been validated.
6
+ */
7
+ export declare class ItemValidateAttributesResponseDto extends BaseResponse {
8
+ /**
9
+ * An array of field DTOs representing the validated attributes.
10
+ * Each `FieldDto` contains details about a single attribute.
11
+ */
12
+ validatedAttributes: FieldDto[];
13
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ItemValidateAttributesResponseDto = void 0;
4
+ const base_response_dto_1 = require("../../base-response.dto");
5
+ /**
6
+ * Represents the response from validating item attributes.
7
+ * Contains the list of attributes that have been validated.
8
+ */
9
+ class ItemValidateAttributesResponseDto extends base_response_dto_1.BaseResponse {
10
+ }
11
+ exports.ItemValidateAttributesResponseDto = ItemValidateAttributesResponseDto;
@@ -1,9 +1,9 @@
1
- export declare enum ActionsEnum {
2
- CREATE = "CREATE",
3
- RENEW = "RENEW",
4
- UPGRADE = "UPGRADE",
5
- DOWNGRADE = "DOWNGRADE",
6
- SUSPEND = "SUSPEND",
7
- UNSUSPEND = "UNSUSPEND",
8
- DELETE = "DELETE"
1
+ export declare enum ProductActionsEnum {
2
+ CREATE = "create",
3
+ RENEW = "renew",
4
+ UPGRADE = "upgrade",
5
+ DOWNGRADE = "downgrade",
6
+ SUSPEND = "suspend",
7
+ UNSUSPEND = "unsuspend",
8
+ DELETE = "delete"
9
9
  }
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ActionsEnum = void 0;
4
- var ActionsEnum;
5
- (function (ActionsEnum) {
3
+ exports.ProductActionsEnum = void 0;
4
+ var ProductActionsEnum;
5
+ (function (ProductActionsEnum) {
6
6
  // Product Integration
7
- ActionsEnum["CREATE"] = "CREATE";
8
- ActionsEnum["RENEW"] = "RENEW";
9
- ActionsEnum["UPGRADE"] = "UPGRADE";
10
- ActionsEnum["DOWNGRADE"] = "DOWNGRADE";
11
- ActionsEnum["SUSPEND"] = "SUSPEND";
12
- ActionsEnum["UNSUSPEND"] = "UNSUSPEND";
13
- ActionsEnum["DELETE"] = "DELETE";
14
- })(ActionsEnum || (exports.ActionsEnum = ActionsEnum = {}));
7
+ ProductActionsEnum["CREATE"] = "create";
8
+ ProductActionsEnum["RENEW"] = "renew";
9
+ ProductActionsEnum["UPGRADE"] = "upgrade";
10
+ ProductActionsEnum["DOWNGRADE"] = "downgrade";
11
+ ProductActionsEnum["SUSPEND"] = "suspend";
12
+ ProductActionsEnum["UNSUSPEND"] = "unsuspend";
13
+ ProductActionsEnum["DELETE"] = "delete";
14
+ })(ProductActionsEnum || (exports.ProductActionsEnum = ProductActionsEnum = {}));
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from './dtos/client-data.dto';
6
6
  export * from './dtos/company-data.dto';
7
7
  export * from './dtos/error-response.dto';
8
8
  export * from './dtos/field.dto';
9
+ export * from './dtos/field-option.dto';
9
10
  export * from './dtos/info.dto';
10
11
  export * from './dtos/jwt.dto';
11
12
  export * from './dtos/menu.dto';
@@ -37,6 +38,7 @@ export * from './dtos/product/requests/product-unsuspend-request.dto';
37
38
  export * from './dtos/product/requests/product-upgrade-request.dto';
38
39
  export * from './dtos/product/requests/product-upgradable-request.dto';
39
40
  export * from './dtos/product/requests/product-validate-attributes-request.dto';
41
+ export * from './dtos/product/requests/item-validate-attributes-request.dto';
40
42
  export * from './dtos/product/responses/product-create-response.dto';
41
43
  export * from './dtos/product/responses/product-delete-response.dto';
42
44
  export * from './dtos/product/responses/product-downgrade-response.dto';
@@ -48,6 +50,7 @@ export * from './dtos/product/responses/product-unsuspend-response.dto';
48
50
  export * from './dtos/product/responses/product-upgrade-response.dto';
49
51
  export * from './dtos/product/responses/product-upgradable-response.dto';
50
52
  export * from './dtos/product/responses/product-validate-attributes-response.dto';
53
+ export * from './dtos/product/responses/item-validate-attributes-response.dto';
51
54
  export * from './enums/actions.enum';
52
55
  export * from './enums/country.enum';
53
56
  export * from './enums/duration.enum';
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ __exportStar(require("./dtos/client-data.dto"), exports);
23
23
  __exportStar(require("./dtos/company-data.dto"), exports);
24
24
  __exportStar(require("./dtos/error-response.dto"), exports);
25
25
  __exportStar(require("./dtos/field.dto"), exports);
26
+ __exportStar(require("./dtos/field-option.dto"), exports);
26
27
  __exportStar(require("./dtos/info.dto"), exports);
27
28
  __exportStar(require("./dtos/jwt.dto"), exports);
28
29
  __exportStar(require("./dtos/menu.dto"), exports);
@@ -57,6 +58,7 @@ __exportStar(require("./dtos/product/requests/product-unsuspend-request.dto"), e
57
58
  __exportStar(require("./dtos/product/requests/product-upgrade-request.dto"), exports);
58
59
  __exportStar(require("./dtos/product/requests/product-upgradable-request.dto"), exports);
59
60
  __exportStar(require("./dtos/product/requests/product-validate-attributes-request.dto"), exports);
61
+ __exportStar(require("./dtos/product/requests/item-validate-attributes-request.dto"), exports);
60
62
  // Product Responses
61
63
  __exportStar(require("./dtos/product/responses/product-create-response.dto"), exports);
62
64
  __exportStar(require("./dtos/product/responses/product-delete-response.dto"), exports);
@@ -69,6 +71,7 @@ __exportStar(require("./dtos/product/responses/product-unsuspend-response.dto"),
69
71
  __exportStar(require("./dtos/product/responses/product-upgrade-response.dto"), exports);
70
72
  __exportStar(require("./dtos/product/responses/product-upgradable-response.dto"), exports);
71
73
  __exportStar(require("./dtos/product/responses/product-validate-attributes-response.dto"), exports);
74
+ __exportStar(require("./dtos/product/responses/item-validate-attributes-response.dto"), exports);
72
75
  // Enums
73
76
  __exportStar(require("./enums/actions.enum"), exports);
74
77
  __exportStar(require("./enums/country.enum"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hosterai/types",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {