@hosterai/types 0.0.27 → 0.0.29

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 (136) hide show
  1. package/README.md +5 -1
  2. package/dist/decorators/all-or-none-validator.spec.js +9 -3
  3. package/dist/decorators/at-least-one-non-empty-validator.spec.js +1 -1
  4. package/dist/decorators/at-least-one-non-empty.validator.js +2 -2
  5. package/dist/decorators/is-of-allowed-types-validator.spec.js +10 -8
  6. package/dist/decorators/is-of-allowed-types.validator.js +4 -2
  7. package/dist/decorators/is-one-of.validator.d.ts +2 -2
  8. package/dist/decorators/is-one-of.validator.js +1 -1
  9. package/dist/decorators/is-plain-object.validator.d.ts +1 -1
  10. package/dist/decorators/is-plain-object.validator.js +3 -1
  11. package/dist/decorators/is-property-forbidden-validator.spec.js +12 -4
  12. package/dist/decorators/is-property-forbidden.validator.d.ts +1 -1
  13. package/dist/decorators/is-regex.validator.d.ts +1 -1
  14. package/dist/decorators/min-less-or-equal-validator.spec.js +6 -2
  15. package/dist/dtos/action.dto.js +5 -5
  16. package/dist/dtos/addon-field.dto.d.ts +1 -1
  17. package/dist/dtos/admin-panel.dto.js +16 -18
  18. package/dist/dtos/attribute-field.dto.d.ts +1 -1
  19. package/dist/dtos/client-panel.dto.d.ts +3 -3
  20. package/dist/dtos/client-panel.dto.js +11 -10
  21. package/dist/dtos/company-data.dto.d.ts +4 -0
  22. package/dist/dtos/company-data.dto.js +19 -8
  23. package/dist/dtos/error-response.dto.js +1 -4
  24. package/dist/dtos/field-option.dto.js +3 -3
  25. package/dist/dtos/info.dto.js +10 -10
  26. package/dist/dtos/invoice/invoice-info.dto.d.ts +3 -3
  27. package/dist/dtos/invoice/invoice-info.dto.js +1 -1
  28. package/dist/dtos/invoice/invoice-item-data.dto.d.ts +2 -2
  29. package/dist/dtos/invoice/requests/base-invoice-request.dto.d.ts +30 -0
  30. package/dist/dtos/invoice/requests/base-invoice-request.dto.js +108 -0
  31. package/dist/dtos/invoice/requests/credit-note-request.dto.d.ts +2 -2
  32. package/dist/dtos/invoice/requests/credit-note-request.dto.js +2 -2
  33. package/dist/dtos/invoice/requests/invoice-request.dto.d.ts +2 -2
  34. package/dist/dtos/invoice/requests/invoice-request.dto.js +2 -2
  35. package/dist/dtos/invoice/requests/proforma-invoice-request.dto.d.ts +2 -19
  36. package/dist/dtos/invoice/requests/proforma-invoice-request.dto.js +2 -95
  37. package/dist/dtos/invoice/responses/credit-note-response.dto.d.ts +1 -1
  38. package/dist/dtos/invoice/responses/invoice-response.dto.d.ts +1 -1
  39. package/dist/dtos/invoice/responses/tax-details-response.dto.js +1 -1
  40. package/dist/dtos/invoice-contact-data.dto.d.ts +2 -2
  41. package/dist/dtos/invoice-contact-data.dto.js +5 -5
  42. package/dist/dtos/menu.dto.js +8 -4
  43. package/dist/dtos/notification/responses/notification-send-response.dto.d.ts +1 -1
  44. package/dist/dtos/notification/sender/sender-sms.dto.js +1 -1
  45. package/dist/dtos/product/product-info.dto.js +11 -5
  46. package/dist/dtos/product/product-item-data.dto.d.ts +2 -2
  47. package/dist/dtos/product/requests/product-create-request.dto.js +1 -1
  48. package/dist/dtos/product/requests/product-delete-request.dto.js +3 -3
  49. package/dist/dtos/product/requests/product-downgradable-request.dto.js +1 -1
  50. package/dist/dtos/product/requests/product-downgrade-request.dto.js +1 -1
  51. package/dist/dtos/product/requests/product-downgradeable-request.dto.d.ts +18 -0
  52. package/dist/dtos/product/requests/product-downgradeable-request.dto.js +37 -0
  53. package/dist/dtos/product/requests/product-renew-request.dto.js +1 -1
  54. package/dist/dtos/product/requests/product-suspend-request.dto.js +1 -1
  55. package/dist/dtos/product/requests/product-unsuspend-request.dto.js +1 -1
  56. package/dist/dtos/product/requests/product-upgradable-request.dto.js +1 -1
  57. package/dist/dtos/product/requests/product-upgrade-request.dto.js +1 -1
  58. package/dist/dtos/product/requests/product-upgradeable-request.dto.d.ts +18 -0
  59. package/dist/dtos/product/requests/product-upgradeable-request.dto.js +37 -0
  60. package/dist/dtos/product/responses/product-downgradeable-response.dto.d.ts +22 -0
  61. package/dist/dtos/product/responses/product-downgradeable-response.dto.js +11 -0
  62. package/dist/dtos/product/responses/product-info-response.dto.js +1 -1
  63. package/dist/dtos/product/responses/product-upgradeable-response.dto.d.ts +22 -0
  64. package/dist/dtos/product/responses/product-upgradeable-response.dto.js +11 -0
  65. package/dist/dtos/responses/validate-attributes-response.dto.d.ts +2 -2
  66. package/dist/dtos/tab.dto.js +2 -2
  67. package/dist/dtos/tax-manager/tax-details-request.dto.d.ts +31 -0
  68. package/dist/dtos/tax-manager/tax-details-request.dto.js +84 -0
  69. package/dist/dtos/unit.dto.js +3 -3
  70. package/dist/enums/country.enum.d.ts +1 -1
  71. package/dist/enums/country.enum.js +312 -78
  72. package/dist/enums/currency.enum.d.ts +43 -0
  73. package/dist/enums/currency.enum.js +47 -0
  74. package/dist/enums/events.enum.d.ts +3 -0
  75. package/dist/enums/events.enum.js +3 -0
  76. package/dist/index.d.ts +2 -1
  77. package/dist/index.js +2 -1
  78. package/dist/openapi/schemas/components.schemas.d.ts +3 -33
  79. package/dist/openapi/schemas/components.schemas.js +19 -40
  80. package/dist/validators/action-validator.spec.js +3 -3
  81. package/dist/validators/addon-field-validator.spec.js +10 -3
  82. package/dist/validators/admin-panel-more-actions-validator.spec.js +12 -8
  83. package/dist/validators/admin-panel-more-actions.validator.d.ts +1 -1
  84. package/dist/validators/admin-panel-tabs-validator.spec.js +74 -10
  85. package/dist/validators/admin-panel-tabs.validator.d.ts +1 -1
  86. package/dist/validators/admin-panel-validator.spec.js +164 -32
  87. package/dist/validators/attachment-validator.spec.js +8 -8
  88. package/dist/validators/attribute-field-validator.spec.js +18 -7
  89. package/dist/validators/client-panel-validator.spec.js +57 -9
  90. package/dist/validators/country-validator.spec.js +7 -7
  91. package/dist/validators/field-validator.spec.js +35 -10
  92. package/dist/validators/info-validator.spec.js +10 -10
  93. package/dist/validators/invoice-contact-data-validator.spec.js +18 -10
  94. package/dist/validators/invoice-info-validator.spec.js +14 -10
  95. package/dist/validators/invoice-item-data-validator.spec.js +4 -4
  96. package/dist/validators/item-data-validator.spec.js +17 -9
  97. package/dist/validators/menu-with-submenu-validator.spec.js +13 -11
  98. package/dist/validators/menu-with-url-validator.spec.js +15 -5
  99. package/dist/validators/notification-info-validator.spec.js +23 -15
  100. package/dist/validators/product-downgradeable-request-validator.d.ts +8 -0
  101. package/dist/validators/product-downgradeable-request-validator.js +17 -0
  102. package/dist/validators/product-info-validator.spec.js +46 -32
  103. package/dist/validators/product-info.validator.d.ts +1 -1
  104. package/dist/validators/product-item-data-validator.spec.js +12 -4
  105. package/dist/validators/product-upgradeable-request-validator.d.ts +8 -0
  106. package/dist/validators/product-upgradeable-request-validator.js +17 -0
  107. package/dist/validators/sender-sms-validator.spec.js +5 -2
  108. package/dist/validators/settings-with-tabs-validator.spec.js +176 -12
  109. package/dist/validators/settings-with-url-validator.spec.js +89 -11
  110. package/dist/validators/tab-validator.spec.js +7 -7
  111. package/dist/validators/tin-validation-details-validator.spec.js +8 -8
  112. package/dist/validators/transaction-data-validator.spec.js +13 -8
  113. package/dist/validators/unit-validator.spec.js +13 -4
  114. package/package.json +1 -1
  115. package/dist/dtos/info/info-notification.dto.d.ts +0 -5
  116. package/dist/dtos/info/info-notification.dto.js +0 -7
  117. package/dist/dtos/info/info.dto.d.ts +0 -196
  118. package/dist/dtos/info/info.dto.js +0 -278
  119. package/dist/dtos/notification/notification-request.dto.d.ts +0 -20
  120. package/dist/dtos/notification/notification-request.dto.js +0 -31
  121. package/dist/dtos/receiver/receiver-email.dto.d.ts +0 -20
  122. package/dist/dtos/receiver/receiver-email.dto.js +0 -39
  123. package/dist/dtos/receiver/receiver-push.dto.d.ts +0 -15
  124. package/dist/dtos/receiver/receiver-push.dto.js +0 -31
  125. package/dist/dtos/receiver/receiver-sms.dto.d.ts +0 -11
  126. package/dist/dtos/receiver/receiver-sms.dto.js +0 -26
  127. package/dist/dtos/request.dto.d.ts +0 -20
  128. package/dist/dtos/request.dto.js +0 -31
  129. package/dist/dtos/sender/sender-email.dto.d.ts +0 -25
  130. package/dist/dtos/sender/sender-email.dto.js +0 -46
  131. package/dist/dtos/sender/sender-push.dto.d.ts +0 -31
  132. package/dist/dtos/sender/sender-push.dto.js +0 -50
  133. package/dist/dtos/sender/sender-sms.dto.d.ts +0 -15
  134. package/dist/dtos/sender/sender-sms.dto.js +0 -30
  135. package/dist/enums/message-type.enum.d.ts +0 -5
  136. package/dist/enums/message-type.enum.js +0 -9
@@ -21,8 +21,12 @@ describe('FieldDto Validator', () => {
21
21
  it('should return no errors for a valid DTO with optional error messages', () => {
22
22
  const dto = {
23
23
  ...baseValidDto,
24
- regexValidationErrorMessage: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: 'Invalid format' }],
25
- remoteValidationErrorMessage: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: 'Invalid value' }],
24
+ regexValidationErrorMessage: [
25
+ { language: language_enum_1.LanguageEnum.ENGLISH, text: 'Invalid format' },
26
+ ],
27
+ remoteValidationErrorMessage: [
28
+ { language: language_enum_1.LanguageEnum.ENGLISH, text: 'Invalid value' },
29
+ ],
26
30
  };
27
31
  expect((0, field_validator_1.validateFieldDto)(dto)).toHaveLength(0);
28
32
  });
@@ -30,28 +34,49 @@ describe('FieldDto Validator', () => {
30
34
  describe('Missing required fields', () => {
31
35
  it('should return errors for all missing required fields (except upgradable)', () => {
32
36
  const errors = (0, field_validator_1.validateFieldDto)({});
33
- const requiredProps = ['id', 'label', 'value', 'type', 'required', 'disabled'];
37
+ const requiredProps = [
38
+ 'id',
39
+ 'label',
40
+ 'value',
41
+ 'type',
42
+ 'required',
43
+ 'disabled',
44
+ ];
34
45
  for (const prop of requiredProps) {
35
- expect(errors.some(e => e.property === prop)).toBe(true);
46
+ expect(errors.some((e) => e.property === prop)).toBe(true);
36
47
  }
37
48
  });
38
49
  it('should return error if value is missing', () => {
39
50
  const dto = { ...baseValidDto };
40
51
  delete dto.value;
41
52
  const errors = (0, field_validator_1.validateFieldDto)(dto);
42
- expect(errors.some(e => e.property === 'value')).toBe(true);
53
+ expect(errors.some((e) => e.property === 'value')).toBe(true);
43
54
  });
44
55
  });
45
56
  describe('Invalid field values', () => {
46
57
  it.each([
47
58
  [{ ...baseValidDto, type: 'not-a-valid-type' }, 'type'],
48
59
  [{}, 'id'],
49
- [{ ...baseValidDto, regexValidation: 'regex', regexValidationErrorMessage: 'not-an-array' }, 'regexValidationErrorMessage'],
50
- [{ ...baseValidDto, triggersRemoteValidation: true, remoteValidationErrorMessage: 'not-an-array' }, 'remoteValidationErrorMessage'],
60
+ [
61
+ {
62
+ ...baseValidDto,
63
+ regexValidation: 'regex',
64
+ regexValidationErrorMessage: 'not-an-array',
65
+ },
66
+ 'regexValidationErrorMessage',
67
+ ],
68
+ [
69
+ {
70
+ ...baseValidDto,
71
+ triggersRemoteValidation: true,
72
+ remoteValidationErrorMessage: 'not-an-array',
73
+ },
74
+ 'remoteValidationErrorMessage',
75
+ ],
51
76
  ])('should return error for invalid %s', (dto, expectedProp) => {
52
77
  const errors = (0, field_validator_1.validateFieldDto)(dto);
53
78
  expect(errors.length).toBeGreaterThan(0);
54
- expect(errors.some(e => e.property === expectedProp)).toBe(true);
79
+ expect(errors.some((e) => e.property === expectedProp)).toBe(true);
55
80
  });
56
81
  });
57
82
  describe('Invalid `value` field', () => {
@@ -64,12 +89,12 @@ describe('FieldDto Validator', () => {
64
89
  ])('should return error if value is invalid type (%s)', (invalidValue, _label) => {
65
90
  const dto = { ...baseValidDto, value: invalidValue };
66
91
  const errors = (0, field_validator_1.validateFieldDto)(dto);
67
- expect(errors.some(e => e.property === 'value')).toBe(true);
92
+ expect(errors.some((e) => e.property === 'value')).toBe(true);
68
93
  });
69
94
  it('should return error if value is empty string when required', () => {
70
95
  const dto = { ...baseValidDto, value: '' };
71
96
  const errors = (0, field_validator_1.validateFieldDto)(dto);
72
- expect(errors.some(e => e.property === 'value')).toBe(true);
97
+ expect(errors.some((e) => e.property === 'value')).toBe(true);
73
98
  });
74
99
  });
75
100
  });
@@ -36,50 +36,50 @@ describe('InfoDto Validator', () => {
36
36
  describe('Missing required fields', () => {
37
37
  it('should return errors when all fields are missing', () => {
38
38
  const errors = (0, info_validator_1.validateInfoDto)({});
39
- expect(errors.some(e => e.property === 'title')).toBe(true);
40
- expect(errors.some(e => e.property === 'supportedLanguages')).toBe(true);
39
+ expect(errors.some((e) => e.property === 'title')).toBe(true);
40
+ expect(errors.some((e) => e.property === 'supportedLanguages')).toBe(true);
41
41
  });
42
42
  it('should return error when title is missing', () => {
43
43
  const { title, ...dto } = baseValidDto;
44
44
  const errors = (0, info_validator_1.validateInfoDto)(dto);
45
- expect(errors.some(e => e.property === 'title')).toBe(true);
45
+ expect(errors.some((e) => e.property === 'title')).toBe(true);
46
46
  });
47
47
  it('should return error when supportedLanguages is missing', () => {
48
48
  const { supportedLanguages, ...dto } = baseValidDto;
49
49
  const errors = (0, info_validator_1.validateInfoDto)(dto);
50
- expect(errors.some(e => e.property === 'supportedLanguages')).toBe(true);
50
+ expect(errors.some((e) => e.property === 'supportedLanguages')).toBe(true);
51
51
  });
52
52
  });
53
53
  describe('Invalid field values', () => {
54
54
  it('should return error for empty title', () => {
55
55
  const dto = { ...baseValidDto, title: '' };
56
56
  const errors = (0, info_validator_1.validateInfoDto)(dto);
57
- expect(errors.some(e => e.property === 'title')).toBe(true);
57
+ expect(errors.some((e) => e.property === 'title')).toBe(true);
58
58
  });
59
59
  it('should return error for empty supportedLanguages array', () => {
60
60
  const dto = { ...baseValidDto, supportedLanguages: [] };
61
61
  const errors = (0, info_validator_1.validateInfoDto)(dto);
62
- expect(errors.some(e => e.property === 'supportedLanguages')).toBe(true);
62
+ expect(errors.some((e) => e.property === 'supportedLanguages')).toBe(true);
63
63
  });
64
64
  it('should return error for invalid language enum', () => {
65
65
  const dto = { ...baseValidDto, supportedLanguages: ['INVALID'] };
66
66
  const errors = (0, info_validator_1.validateInfoDto)(dto);
67
- expect(errors.some(e => e.property === 'supportedLanguages')).toBe(true);
67
+ expect(errors.some((e) => e.property === 'supportedLanguages')).toBe(true);
68
68
  });
69
69
  it('should return error for invalid logo URL (not https)', () => {
70
70
  const dto = { ...baseValidDto, logo: 'http://example.com/logo.png' };
71
71
  const errors = (0, info_validator_1.validateInfoDto)(dto);
72
- expect(errors.some(e => e.property === 'logo')).toBe(true);
72
+ expect(errors.some((e) => e.property === 'logo')).toBe(true);
73
73
  });
74
74
  it('should return error for invalid logo URL (not a URL)', () => {
75
75
  const dto = { ...baseValidDto, logo: 'not-a-url' };
76
76
  const errors = (0, info_validator_1.validateInfoDto)(dto);
77
- expect(errors.some(e => e.property === 'logo')).toBe(true);
77
+ expect(errors.some((e) => e.property === 'logo')).toBe(true);
78
78
  });
79
79
  it('should return error for invalid onboardingUrl', () => {
80
80
  const dto = { ...baseValidDto, onboardingUrl: 'not-a-url' };
81
81
  const errors = (0, info_validator_1.validateInfoDto)(dto);
82
- expect(errors.some(e => e.property === 'onboardingUrl')).toBe(true);
82
+ expect(errors.some((e) => e.property === 'onboardingUrl')).toBe(true);
83
83
  });
84
84
  });
85
85
  });
@@ -40,49 +40,57 @@ describe('InvoiceContactData Validator', () => {
40
40
  it('should return errors when all fields are missing', () => {
41
41
  const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)({});
42
42
  const requiredProps = [
43
- 'invoiceContactId', 'isBusinessContact', 'firstName', 'lastName',
44
- 'email', 'telephone', 'address1', 'postcode', 'city', 'country',
43
+ 'invoiceContactId',
44
+ 'isBusinessContact',
45
+ 'firstName',
46
+ 'lastName',
47
+ 'email',
48
+ 'telephone',
49
+ 'address1',
50
+ 'postcode',
51
+ 'city',
52
+ 'country',
45
53
  ];
46
54
  for (const prop of requiredProps) {
47
- expect(errors.some(e => e.property === prop)).toBe(true);
55
+ expect(errors.some((e) => e.property === prop)).toBe(true);
48
56
  }
49
57
  });
50
58
  it('should return error when invoiceContactId is missing', () => {
51
59
  const { invoiceContactId, ...dto } = baseValidDto;
52
60
  const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)(dto);
53
- expect(errors.some(e => e.property === 'invoiceContactId')).toBe(true);
61
+ expect(errors.some((e) => e.property === 'invoiceContactId')).toBe(true);
54
62
  });
55
63
  });
56
64
  describe('Invalid field values', () => {
57
65
  it('should return error for invalid email', () => {
58
66
  const dto = { ...baseValidDto, email: 'not-an-email' };
59
67
  const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)(dto);
60
- expect(errors.some(e => e.property === 'email')).toBe(true);
68
+ expect(errors.some((e) => e.property === 'email')).toBe(true);
61
69
  });
62
70
  it('should return error for invalid telephone', () => {
63
71
  const dto = { ...baseValidDto, telephone: '123' };
64
72
  const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)(dto);
65
- expect(errors.some(e => e.property === 'telephone')).toBe(true);
73
+ expect(errors.some((e) => e.property === 'telephone')).toBe(true);
66
74
  });
67
75
  it('should return error for invalid country code', () => {
68
76
  const dto = { ...baseValidDto, country: 'INVALID' };
69
77
  const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)(dto);
70
- expect(errors.some(e => e.property === 'country')).toBe(true);
78
+ expect(errors.some((e) => e.property === 'country')).toBe(true);
71
79
  });
72
80
  it('should return error for address1 exceeding max length', () => {
73
81
  const dto = { ...baseValidDto, address1: 'a'.repeat(251) };
74
82
  const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)(dto);
75
- expect(errors.some(e => e.property === 'address1')).toBe(true);
83
+ expect(errors.some((e) => e.property === 'address1')).toBe(true);
76
84
  });
77
85
  it('should return error for postcode exceeding max length', () => {
78
86
  const dto = { ...baseValidDto, postcode: '1'.repeat(17) };
79
87
  const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)(dto);
80
- expect(errors.some(e => e.property === 'postcode')).toBe(true);
88
+ expect(errors.some((e) => e.property === 'postcode')).toBe(true);
81
89
  });
82
90
  it('should return error for invalid mobile phone', () => {
83
91
  const dto = { ...baseValidDto, mobile: 'not-a-phone' };
84
92
  const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)(dto);
85
- expect(errors.some(e => e.property === 'mobile')).toBe(true);
93
+ expect(errors.some((e) => e.property === 'mobile')).toBe(true);
86
94
  });
87
95
  });
88
96
  });
@@ -20,7 +20,11 @@ describe('InvoiceInfoDto Validator', () => {
20
20
  it('should return no errors with all supported types', () => {
21
21
  const dto = {
22
22
  ...baseValidDto,
23
- supportedTypes: [invoice_types_enum_1.InvoiceTypesEnum.INVOICE, invoice_types_enum_1.InvoiceTypesEnum.CREDIT_NOTE, invoice_types_enum_1.InvoiceTypesEnum.PROFORMA],
23
+ supportedTypes: [
24
+ invoice_types_enum_1.InvoiceTypesEnum.INVOICE,
25
+ invoice_types_enum_1.InvoiceTypesEnum.CREDIT_NOTE,
26
+ invoice_types_enum_1.InvoiceTypesEnum.PROFORMA,
27
+ ],
24
28
  };
25
29
  expect((0, invoice_info_validator_1.validateInvoiceInfoDto)(dto)).toHaveLength(0);
26
30
  });
@@ -37,45 +41,45 @@ describe('InvoiceInfoDto Validator', () => {
37
41
  describe('Missing required fields', () => {
38
42
  it('should return errors when all fields are missing', () => {
39
43
  const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)({});
40
- expect(errors.some(e => e.property === 'title')).toBe(true);
41
- expect(errors.some(e => e.property === 'supportedLanguages')).toBe(true);
44
+ expect(errors.some((e) => e.property === 'title')).toBe(true);
45
+ expect(errors.some((e) => e.property === 'supportedLanguages')).toBe(true);
42
46
  });
43
47
  it('should return error when title is missing', () => {
44
48
  const { title, ...dto } = baseValidDto;
45
49
  const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)(dto);
46
- expect(errors.some(e => e.property === 'title')).toBe(true);
50
+ expect(errors.some((e) => e.property === 'title')).toBe(true);
47
51
  });
48
52
  it('should return error when supportedLanguages is missing', () => {
49
53
  const { supportedLanguages, ...dto } = baseValidDto;
50
54
  const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)(dto);
51
- expect(errors.some(e => e.property === 'supportedLanguages')).toBe(true);
55
+ expect(errors.some((e) => e.property === 'supportedLanguages')).toBe(true);
52
56
  });
53
57
  });
54
58
  describe('Invalid field values', () => {
55
59
  it('should return error for invalid supportedTypes enum', () => {
56
60
  const dto = { ...baseValidDto, supportedTypes: ['invalid-type'] };
57
61
  const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)(dto);
58
- expect(errors.some(e => e.property === 'supportedTypes')).toBe(true);
62
+ expect(errors.some((e) => e.property === 'supportedTypes')).toBe(true);
59
63
  });
60
64
  it('should return error for empty title', () => {
61
65
  const dto = { ...baseValidDto, title: '' };
62
66
  const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)(dto);
63
- expect(errors.some(e => e.property === 'title')).toBe(true);
67
+ expect(errors.some((e) => e.property === 'title')).toBe(true);
64
68
  });
65
69
  it('should return error for empty supportedLanguages array', () => {
66
70
  const dto = { ...baseValidDto, supportedLanguages: [] };
67
71
  const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)(dto);
68
- expect(errors.some(e => e.property === 'supportedLanguages')).toBe(true);
72
+ expect(errors.some((e) => e.property === 'supportedLanguages')).toBe(true);
69
73
  });
70
74
  it('should return error for invalid language enum', () => {
71
75
  const dto = { ...baseValidDto, supportedLanguages: ['INVALID'] };
72
76
  const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)(dto);
73
- expect(errors.some(e => e.property === 'supportedLanguages')).toBe(true);
77
+ expect(errors.some((e) => e.property === 'supportedLanguages')).toBe(true);
74
78
  });
75
79
  it('should return error for invalid logo URL', () => {
76
80
  const dto = { ...baseValidDto, logo: 'not-a-url' };
77
81
  const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)(dto);
78
- expect(errors.some(e => e.property === 'logo')).toBe(true);
82
+ expect(errors.some((e) => e.property === 'logo')).toBe(true);
79
83
  });
80
84
  });
81
85
  });
@@ -27,19 +27,19 @@ describe('InvoiceItemDataDto Validator', () => {
27
27
  it('should return error when action is missing', () => {
28
28
  const { action, ...dto } = baseValidDto;
29
29
  const errors = (0, invoice_item_data_validator_1.validateInvoiceItemDataDto)(dto);
30
- expect(errors.some(e => e.property === 'action')).toBe(true);
30
+ expect(errors.some((e) => e.property === 'action')).toBe(true);
31
31
  });
32
32
  it('should return errors for inherited required fields when missing', () => {
33
33
  const errors = (0, invoice_item_data_validator_1.validateInvoiceItemDataDto)({});
34
- expect(errors.some(e => e.property === 'action')).toBe(true);
35
- expect(errors.some(e => e.property === 'productId')).toBe(true);
34
+ expect(errors.some((e) => e.property === 'action')).toBe(true);
35
+ expect(errors.some((e) => e.property === 'productId')).toBe(true);
36
36
  });
37
37
  });
38
38
  describe('Invalid field values', () => {
39
39
  it('should return error for invalid action enum', () => {
40
40
  const dto = { ...baseValidDto, action: 'invalid-action' };
41
41
  const errors = (0, invoice_item_data_validator_1.validateInvoiceItemDataDto)(dto);
42
- expect(errors.some(e => e.property === 'action')).toBe(true);
42
+ expect(errors.some((e) => e.property === 'action')).toBe(true);
43
43
  });
44
44
  });
45
45
  });
@@ -33,47 +33,55 @@ describe('ItemDataDto Validator', () => {
33
33
  describe('Missing required fields', () => {
34
34
  it('should return errors when all fields are missing', () => {
35
35
  const errors = (0, item_data_validator_1.validateItemDataDto)({});
36
- const requiredProps = ['productId', 'productName', 'resourceName', 'productAttributes', 'itemAttributes', 'startDate', 'endDate'];
36
+ const requiredProps = [
37
+ 'productId',
38
+ 'productName',
39
+ 'resourceName',
40
+ 'productAttributes',
41
+ 'itemAttributes',
42
+ 'startDate',
43
+ 'endDate',
44
+ ];
37
45
  for (const prop of requiredProps) {
38
- expect(errors.some(e => e.property === prop)).toBe(true);
46
+ expect(errors.some((e) => e.property === prop)).toBe(true);
39
47
  }
40
48
  });
41
49
  it('should return error when productId is missing', () => {
42
50
  const { productId, ...dto } = baseValidDto;
43
51
  const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
44
- expect(errors.some(e => e.property === 'productId')).toBe(true);
52
+ expect(errors.some((e) => e.property === 'productId')).toBe(true);
45
53
  });
46
54
  it('should return error when productAttributes is missing', () => {
47
55
  const { productAttributes, ...dto } = baseValidDto;
48
56
  const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
49
- expect(errors.some(e => e.property === 'productAttributes')).toBe(true);
57
+ expect(errors.some((e) => e.property === 'productAttributes')).toBe(true);
50
58
  });
51
59
  it('should return error when itemAttributes is missing', () => {
52
60
  const { itemAttributes, ...dto } = baseValidDto;
53
61
  const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
54
- expect(errors.some(e => e.property === 'itemAttributes')).toBe(true);
62
+ expect(errors.some((e) => e.property === 'itemAttributes')).toBe(true);
55
63
  });
56
64
  });
57
65
  describe('Invalid field values', () => {
58
66
  it('should return error for empty productId', () => {
59
67
  const dto = { ...baseValidDto, productId: '' };
60
68
  const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
61
- expect(errors.some(e => e.property === 'productId')).toBe(true);
69
+ expect(errors.some((e) => e.property === 'productId')).toBe(true);
62
70
  });
63
71
  it('should return error for empty startDate', () => {
64
72
  const dto = { ...baseValidDto, startDate: '' };
65
73
  const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
66
- expect(errors.some(e => e.property === 'startDate')).toBe(true);
74
+ expect(errors.some((e) => e.property === 'startDate')).toBe(true);
67
75
  });
68
76
  it('should return error for non-number price', () => {
69
77
  const dto = { ...baseValidDto, price: 'free' };
70
78
  const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
71
- expect(errors.some(e => e.property === 'price')).toBe(true);
79
+ expect(errors.some((e) => e.property === 'price')).toBe(true);
72
80
  });
73
81
  it('should return error for non-number discountPrice', () => {
74
82
  const dto = { ...baseValidDto, discountPrice: 'half-off' };
75
83
  const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
76
- expect(errors.some(e => e.property === 'discountPrice')).toBe(true);
84
+ expect(errors.some((e) => e.property === 'discountPrice')).toBe(true);
77
85
  });
78
86
  });
79
87
  });
@@ -4,41 +4,43 @@ require("reflect-metadata");
4
4
  const menu_with_submenu_validator_1 = require("./menu-with-submenu.validator");
5
5
  describe('validateMenuDto', () => {
6
6
  test.each([
7
- ['valid data with submenu',
7
+ [
8
+ 'valid data with submenu',
8
9
  {
9
10
  type: 'with-submenu',
10
11
  icon: 'https://example.com/icon.png',
11
12
  label: 'Menu Label',
12
- submenu: [
13
- { label: 'Submenu 1', url: 'https://example.com/sub1' }
14
- ],
13
+ submenu: [{ label: 'Submenu 1', url: 'https://example.com/sub1' }],
15
14
  },
16
- true
15
+ true,
17
16
  ],
18
- ['missing required icon',
17
+ [
18
+ 'missing required icon',
19
19
  {
20
20
  type: 'with-submenu',
21
21
  label: 'Menu Label',
22
22
  submenu: [{ label: 'Submenu 1', url: 'https://example.com/sub1' }],
23
23
  },
24
- false
24
+ false,
25
25
  ],
26
- ['missing submenu',
26
+ [
27
+ 'missing submenu',
27
28
  {
28
29
  type: 'with-submenu',
29
30
  icon: 'https://example.com/icon.png',
30
31
  label: 'Menu Label',
31
32
  },
32
- false
33
+ false,
33
34
  ],
34
- ['submenu with missing label',
35
+ [
36
+ 'submenu with missing label',
35
37
  {
36
38
  type: 'with-submenu',
37
39
  icon: 'https://example.com/icon.png',
38
40
  label: 'Menu Label',
39
41
  submenu: [{ url: 'https://example.com/sub1' }],
40
42
  },
41
- false
43
+ false,
42
44
  ],
43
45
  ])('%s', (_, input, expectedValid) => {
44
46
  const errors = (0, menu_with_submenu_validator_1.validateMenuWithSubmenuDto)(input);
@@ -22,7 +22,7 @@ describe('validateMenuWithUrlDto', () => {
22
22
  };
23
23
  const errors = (0, menu_with_url_validator_1.validateMenuWithUrlDto)(data);
24
24
  expect(errors.length).toBeGreaterThan(0);
25
- expect(errors.some(e => { var _a; return (_a = e.constraints) === null || _a === void 0 ? void 0 : _a.isIn; })).toBe(true);
25
+ expect(errors.some((e) => { var _a; return (_a = e.constraints) === null || _a === void 0 ? void 0 : _a.isIn; })).toBe(true);
26
26
  });
27
27
  it('fails if icon is not a string', () => {
28
28
  const data = {
@@ -33,7 +33,7 @@ describe('validateMenuWithUrlDto', () => {
33
33
  };
34
34
  const errors = (0, menu_with_url_validator_1.validateMenuWithUrlDto)(data);
35
35
  expect(errors.length).toBeGreaterThan(0);
36
- expect(errors.some(e => { var _a; return (_a = e.constraints) === null || _a === void 0 ? void 0 : _a.isString; })).toBe(true);
36
+ expect(errors.some((e) => { var _a; return (_a = e.constraints) === null || _a === void 0 ? void 0 : _a.isString; })).toBe(true);
37
37
  });
38
38
  it('fails if label is missing', () => {
39
39
  const data = {
@@ -43,17 +43,27 @@ describe('validateMenuWithUrlDto', () => {
43
43
  };
44
44
  const errors = (0, menu_with_url_validator_1.validateMenuWithUrlDto)(data);
45
45
  expect(errors.length).toBeGreaterThan(0);
46
- expect(errors.some(e => { var _a; return (_a = e.constraints) === null || _a === void 0 ? void 0 : _a.isNotEmpty; })).toBe(true);
46
+ expect(errors.some((e) => { var _a; return (_a = e.constraints) === null || _a === void 0 ? void 0 : _a.isNotEmpty; })).toBe(true);
47
47
  });
48
48
  it('fails if url is missing or invalid', () => {
49
49
  const invalids = [
50
50
  { type: 'only-url', icon: 12345, label: 'Dashboard' }, // icon not a string
51
- { type: 'only-url', icon: 'https://example.com/icon.png', label: 'Dashboard', url: 'invalid-url' },
51
+ {
52
+ type: 'only-url',
53
+ icon: 'https://example.com/icon.png',
54
+ label: 'Dashboard',
55
+ url: 'invalid-url',
56
+ },
52
57
  ];
53
58
  for (const data of invalids) {
54
59
  const errors = (0, menu_with_url_validator_1.validateMenuWithUrlDto)(data);
55
60
  expect(errors.length).toBeGreaterThan(0);
56
- expect(errors.some(e => { var _a, _b, _c; return ((_a = e.constraints) === null || _a === void 0 ? void 0 : _a.isUrl) || ((_b = e.constraints) === null || _b === void 0 ? void 0 : _b.isString) || ((_c = e.constraints) === null || _c === void 0 ? void 0 : _c.isDefined); })).toBe(true);
61
+ expect(errors.some((e) => {
62
+ var _a, _b, _c;
63
+ return ((_a = e.constraints) === null || _a === void 0 ? void 0 : _a.isUrl) ||
64
+ ((_b = e.constraints) === null || _b === void 0 ? void 0 : _b.isString) ||
65
+ ((_c = e.constraints) === null || _c === void 0 ? void 0 : _c.isDefined);
66
+ })).toBe(true);
57
67
  }
58
68
  });
59
69
  it('fails if submenu is present', () => {
@@ -6,7 +6,11 @@ const notification_message_type_enum_1 = require("../enums/notification/notifica
6
6
  const item_actions_enum_1 = require("../enums/item-actions.enum");
7
7
  const language_enum_1 = require("../enums/language.enum");
8
8
  describe('NotificationInfoDto Validator', () => {
9
- const validUnit = { id: "ram", unitDescription: "MB", intervalDescription: "month" };
9
+ const validUnit = {
10
+ id: 'ram',
11
+ unitDescription: 'MB',
12
+ intervalDescription: 'month',
13
+ };
10
14
  const testCases = [
11
15
  {
12
16
  description: 'should return no errors for valid DTO',
@@ -15,9 +19,9 @@ describe('NotificationInfoDto Validator', () => {
15
19
  title: 'Valid Title',
16
20
  supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
17
21
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
18
- payPerUseUnits: [validUnit]
22
+ payPerUseUnits: [validUnit],
19
23
  },
20
- expectedErrorsLength: 0
24
+ expectedErrorsLength: 0,
21
25
  },
22
26
  {
23
27
  description: 'should return error for missing type',
@@ -25,9 +29,9 @@ describe('NotificationInfoDto Validator', () => {
25
29
  title: 'Valid Title',
26
30
  supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
27
31
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
28
- payPerUseUnits: [validUnit]
32
+ payPerUseUnits: [validUnit],
29
33
  },
30
- expectedErrorsLength: 1
34
+ expectedErrorsLength: 1,
31
35
  },
32
36
  {
33
37
  description: 'should return error for invalid payPerUseUnits',
@@ -36,10 +40,12 @@ describe('NotificationInfoDto Validator', () => {
36
40
  title: 'Valid Title',
37
41
  supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
38
42
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
39
- payPerUseUnits: [{ id: "", unitDescription: "", intervalDescription: "" }] // Invalid unit
43
+ payPerUseUnits: [
44
+ { id: '', unitDescription: '', intervalDescription: '' },
45
+ ], // Invalid unit
40
46
  },
41
- expectedErrorsLength: 1
42
- }
47
+ expectedErrorsLength: 1,
48
+ },
43
49
  ];
44
50
  testCases.forEach(({ description, dto, expectedErrorsLength }) => {
45
51
  it(description, async () => {
@@ -54,9 +60,9 @@ describe('NotificationInfoDto Validator', () => {
54
60
  type: notification_message_type_enum_1.NotificationMessageTypeEnum.EMAIL,
55
61
  supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
56
62
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
57
- payPerUseUnits: [validUnit]
63
+ payPerUseUnits: [validUnit],
58
64
  },
59
- expectedErrors: ['title']
65
+ expectedErrors: ['title'],
60
66
  },
61
67
  {
62
68
  description: 'should return ValidationError for invalid payPerUseUnits',
@@ -65,16 +71,18 @@ describe('NotificationInfoDto Validator', () => {
65
71
  title: 'Valid Title',
66
72
  supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
67
73
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
68
- payPerUseUnits: [{ id: "", unitDescription: "", intervalDescription: "" }]
74
+ payPerUseUnits: [
75
+ { id: '', unitDescription: '', intervalDescription: '' },
76
+ ],
69
77
  },
70
- expectedErrors: ['payPerUseUnits']
71
- }
78
+ expectedErrors: ['payPerUseUnits'],
79
+ },
72
80
  ];
73
81
  validationErrorTestCases.forEach(({ description, dto, expectedErrors }) => {
74
82
  it(description, async () => {
75
83
  const errors = await (0, notification_info_validator_1.validateNotificationInfoDto)(dto);
76
- const errorProperties = errors.map(error => error.property);
77
- expectedErrors.forEach(expectedError => {
84
+ const errorProperties = errors.map((error) => error.property);
85
+ expectedErrors.forEach((expectedError) => {
78
86
  expect(errorProperties).toContain(expectedError);
79
87
  });
80
88
  });
@@ -0,0 +1,8 @@
1
+ import { ValidationError } from 'class-validator';
2
+ /**
3
+ * Validates a product downgradable request object.
4
+ *
5
+ * @param {Record<string, unknown>} plainObject - The plain object to validate.
6
+ * @returns {Promise<ValidationError[]>} - A promise that resolves with an array of validation errors.
7
+ */
8
+ export declare const validateProductDowngradableRequestDto: (plainObject: Record<string, unknown>) => Promise<ValidationError[]>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateProductDowngradableRequestDto = void 0;
4
+ const class_validator_1 = require("class-validator");
5
+ const class_transformer_1 = require("class-transformer");
6
+ const product_downgradable_request_dto_1 = require("../dtos/product/requests/product-downgradable-request.dto");
7
+ /**
8
+ * Validates a product downgradable request object.
9
+ *
10
+ * @param {Record<string, unknown>} plainObject - The plain object to validate.
11
+ * @returns {Promise<ValidationError[]>} - A promise that resolves with an array of validation errors.
12
+ */
13
+ const validateProductDowngradableRequestDto = async (plainObject) => {
14
+ const request = (0, class_transformer_1.plainToInstance)(product_downgradable_request_dto_1.ProductDowngradableRequestDto, plainObject);
15
+ return await (0, class_validator_1.validate)(request);
16
+ };
17
+ exports.validateProductDowngradableRequestDto = validateProductDowngradableRequestDto;