@hosterai/types 0.0.28 → 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 (100) 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-renew-request.dto.js +1 -1
  52. package/dist/dtos/product/requests/product-suspend-request.dto.js +1 -1
  53. package/dist/dtos/product/requests/product-unsuspend-request.dto.js +1 -1
  54. package/dist/dtos/product/requests/product-upgradable-request.dto.js +1 -1
  55. package/dist/dtos/product/requests/product-upgrade-request.dto.js +1 -1
  56. package/dist/dtos/product/responses/product-info-response.dto.js +1 -1
  57. package/dist/dtos/responses/validate-attributes-response.dto.d.ts +2 -2
  58. package/dist/dtos/tab.dto.js +2 -2
  59. package/dist/dtos/tax-manager/tax-details-request.dto.d.ts +31 -0
  60. package/dist/dtos/tax-manager/tax-details-request.dto.js +84 -0
  61. package/dist/dtos/unit.dto.js +3 -3
  62. package/dist/enums/country.enum.d.ts +1 -1
  63. package/dist/enums/country.enum.js +312 -78
  64. package/dist/enums/currency.enum.d.ts +43 -0
  65. package/dist/enums/currency.enum.js +47 -0
  66. package/dist/index.d.ts +2 -1
  67. package/dist/index.js +2 -1
  68. package/dist/openapi/schemas/components.schemas.d.ts +0 -30
  69. package/dist/openapi/schemas/components.schemas.js +10 -40
  70. package/dist/validators/action-validator.spec.js +3 -3
  71. package/dist/validators/addon-field-validator.spec.js +10 -3
  72. package/dist/validators/admin-panel-more-actions-validator.spec.js +12 -8
  73. package/dist/validators/admin-panel-more-actions.validator.d.ts +1 -1
  74. package/dist/validators/admin-panel-tabs-validator.spec.js +74 -10
  75. package/dist/validators/admin-panel-tabs.validator.d.ts +1 -1
  76. package/dist/validators/admin-panel-validator.spec.js +164 -32
  77. package/dist/validators/attachment-validator.spec.js +8 -8
  78. package/dist/validators/attribute-field-validator.spec.js +18 -7
  79. package/dist/validators/client-panel-validator.spec.js +57 -9
  80. package/dist/validators/country-validator.spec.js +7 -7
  81. package/dist/validators/field-validator.spec.js +35 -10
  82. package/dist/validators/info-validator.spec.js +10 -10
  83. package/dist/validators/invoice-contact-data-validator.spec.js +18 -10
  84. package/dist/validators/invoice-info-validator.spec.js +14 -10
  85. package/dist/validators/invoice-item-data-validator.spec.js +4 -4
  86. package/dist/validators/item-data-validator.spec.js +17 -9
  87. package/dist/validators/menu-with-submenu-validator.spec.js +13 -11
  88. package/dist/validators/menu-with-url-validator.spec.js +15 -5
  89. package/dist/validators/notification-info-validator.spec.js +23 -15
  90. package/dist/validators/product-info-validator.spec.js +46 -32
  91. package/dist/validators/product-info.validator.d.ts +1 -1
  92. package/dist/validators/product-item-data-validator.spec.js +12 -4
  93. package/dist/validators/sender-sms-validator.spec.js +5 -2
  94. package/dist/validators/settings-with-tabs-validator.spec.js +176 -12
  95. package/dist/validators/settings-with-url-validator.spec.js +89 -11
  96. package/dist/validators/tab-validator.spec.js +7 -7
  97. package/dist/validators/tin-validation-details-validator.spec.js +8 -8
  98. package/dist/validators/transaction-data-validator.spec.js +13 -8
  99. package/dist/validators/unit-validator.spec.js +13 -4
  100. package/package.json +1 -1
@@ -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
  });
@@ -9,21 +9,21 @@ const product_info_validator_1 = require("./product-info.validator");
9
9
  describe('ProductInfoDto Validator', () => {
10
10
  const field = {
11
11
  id: 'field',
12
- label: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: "label" }],
12
+ label: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: 'label' }],
13
13
  value: 'string',
14
14
  type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
15
15
  required: false,
16
16
  disabled: false,
17
17
  hidden: false,
18
- upgradable: false
18
+ upgradable: false,
19
19
  };
20
20
  const invalidField = {
21
21
  id: 'field',
22
- label: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: "label" }],
22
+ label: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: 'label' }],
23
23
  value: 'string',
24
24
  type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
25
25
  disabled: false,
26
- upgradable: false
26
+ upgradable: false,
27
27
  };
28
28
  const testCases = [
29
29
  {
@@ -33,9 +33,9 @@ describe('ProductInfoDto Validator', () => {
33
33
  supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
34
34
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
35
35
  productAttributes: [field],
36
- itemAttributes: [field]
36
+ itemAttributes: [field],
37
37
  },
38
- expectedErrorsLength: 0
38
+ expectedErrorsLength: 0,
39
39
  },
40
40
  {
41
41
  description: 'should return error for invalid required and hidden',
@@ -43,9 +43,9 @@ describe('ProductInfoDto Validator', () => {
43
43
  title: 'Test',
44
44
  supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
45
45
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
46
- itemAttributes: [invalidField]
46
+ itemAttributes: [invalidField],
47
47
  },
48
- expectedErrorsLength: 1
48
+ expectedErrorsLength: 1,
49
49
  },
50
50
  {
51
51
  description: 'should return error for invalid title',
@@ -54,9 +54,9 @@ describe('ProductInfoDto Validator', () => {
54
54
  supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
55
55
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
56
56
  productAttributes: [field],
57
- itemAttributes: [field]
57
+ itemAttributes: [field],
58
58
  },
59
- expectedErrorsLength: 1
59
+ expectedErrorsLength: 1,
60
60
  },
61
61
  {
62
62
  description: 'should return error for unsupported action',
@@ -65,9 +65,9 @@ describe('ProductInfoDto Validator', () => {
65
65
  supportedActions: ['update'],
66
66
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
67
67
  productAttributes: [field],
68
- itemAttributes: [field]
68
+ itemAttributes: [field],
69
69
  },
70
- expectedErrorsLength: 1
70
+ expectedErrorsLength: 1,
71
71
  },
72
72
  {
73
73
  description: 'should return error for unsupported language',
@@ -76,9 +76,9 @@ describe('ProductInfoDto Validator', () => {
76
76
  supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
77
77
  supportedLanguages: [],
78
78
  productAttributes: [field],
79
- itemAttributes: [field]
79
+ itemAttributes: [field],
80
80
  },
81
- expectedErrorsLength: 1
81
+ expectedErrorsLength: 1,
82
82
  },
83
83
  {
84
84
  description: 'should return no errors for valid DTO with adminPanel and clientPanel',
@@ -88,10 +88,16 @@ describe('ProductInfoDto Validator', () => {
88
88
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
89
89
  productAttributes: [field],
90
90
  itemAttributes: [field],
91
- adminPanel: { tabs: { product: [{ label: 'Product', url: 'https://example.com/product' }] } },
92
- clientPanel: { tabs: { item: [{ label: 'Item', url: 'https://example.com/item' }] } }
91
+ adminPanel: {
92
+ tabs: {
93
+ product: [{ label: 'Product', url: 'https://example.com/product' }],
94
+ },
95
+ },
96
+ clientPanel: {
97
+ tabs: { item: [{ label: 'Item', url: 'https://example.com/item' }] },
98
+ },
93
99
  },
94
- expectedErrorsLength: 0
100
+ expectedErrorsLength: 0,
95
101
  },
96
102
  {
97
103
  description: 'should return error for invalid DTO with adminPanel and clientPanel',
@@ -101,10 +107,14 @@ describe('ProductInfoDto Validator', () => {
101
107
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
102
108
  productAttributes: [field],
103
109
  itemAttributes: [field],
104
- adminPanel: { /* invalid admin panel data */},
105
- clientPanel: { /* invalid client panel data */}
110
+ adminPanel: {
111
+ /* invalid admin panel data */
112
+ },
113
+ clientPanel: {
114
+ /* invalid client panel data */
115
+ },
106
116
  },
107
- expectedErrorsLength: 3
117
+ expectedErrorsLength: 3,
108
118
  },
109
119
  {
110
120
  description: 'should return no errors for valid DTO with payPerUseUnits',
@@ -114,9 +124,11 @@ describe('ProductInfoDto Validator', () => {
114
124
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
115
125
  productAttributes: [field],
116
126
  itemAttributes: [field],
117
- payPerUseUnits: [{ id: "ram", unitDescription: "MB", intervalDescription: "month" }]
127
+ payPerUseUnits: [
128
+ { id: 'ram', unitDescription: 'MB', intervalDescription: 'month' },
129
+ ],
118
130
  },
119
- expectedErrorsLength: 0
131
+ expectedErrorsLength: 0,
120
132
  },
121
133
  {
122
134
  description: 'should return error for invalid DTO with payPerUseUnits',
@@ -126,10 +138,12 @@ describe('ProductInfoDto Validator', () => {
126
138
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
127
139
  productAttributes: [field],
128
140
  itemAttributes: [field],
129
- payPerUseUnits: [{ id: "", unitDescription: "", intervalDescription: "" }]
141
+ payPerUseUnits: [
142
+ { id: '', unitDescription: '', intervalDescription: '' },
143
+ ],
130
144
  },
131
- expectedErrorsLength: 1
132
- }
145
+ expectedErrorsLength: 1,
146
+ },
133
147
  ];
134
148
  testCases.forEach(({ description, dto, expectedErrorsLength }) => {
135
149
  it(description, () => {
@@ -144,9 +158,9 @@ describe('ProductInfoDto Validator', () => {
144
158
  supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
145
159
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
146
160
  productAttributes: [field],
147
- itemAttributes: [field]
161
+ itemAttributes: [field],
148
162
  },
149
- expectedErrors: ['title']
163
+ expectedErrors: ['title'],
150
164
  },
151
165
  {
152
166
  description: 'should return ValidationError for unsupported action',
@@ -155,16 +169,16 @@ describe('ProductInfoDto Validator', () => {
155
169
  supportedActions: ['update'],
156
170
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
157
171
  productAttributes: [field],
158
- itemAttributes: [field]
172
+ itemAttributes: [field],
159
173
  },
160
- expectedErrors: ['supportedActions']
161
- }
174
+ expectedErrors: ['supportedActions'],
175
+ },
162
176
  ];
163
177
  validationErrorTestCases.forEach(({ description, dto, expectedErrors }) => {
164
178
  it(description, async () => {
165
179
  const errors = await (0, product_info_validator_1.validateProductInfoDto)(dto);
166
- const errorProperties = errors.map(error => error.property);
167
- expectedErrors.forEach(expectedError => {
180
+ const errorProperties = errors.map((error) => error.property);
181
+ expectedErrors.forEach((expectedError) => {
168
182
  expect(errorProperties).toContain(expectedError);
169
183
  });
170
184
  });
@@ -1,2 +1,2 @@
1
- import { ValidationError } from "class-validator";
1
+ import { ValidationError } from 'class-validator';
2
2
  export declare function validateProductInfoDto(data: object): ValidationError[];
@@ -39,9 +39,17 @@ describe('ProductItemDataDto Validator', () => {
39
39
  describe('Missing inherited required fields', () => {
40
40
  it('should return errors when all fields are missing', () => {
41
41
  const errors = (0, product_item_data_validator_1.validateProductItemDataDto)({});
42
- const requiredProps = ['productId', 'productName', 'resourceName', 'productAttributes', 'itemAttributes', 'startDate', 'endDate'];
42
+ const requiredProps = [
43
+ 'productId',
44
+ 'productName',
45
+ 'resourceName',
46
+ 'productAttributes',
47
+ 'itemAttributes',
48
+ 'startDate',
49
+ 'endDate',
50
+ ];
43
51
  for (const prop of requiredProps) {
44
- expect(errors.some(e => e.property === prop)).toBe(true);
52
+ expect(errors.some((e) => e.property === prop)).toBe(true);
45
53
  }
46
54
  });
47
55
  });
@@ -49,12 +57,12 @@ describe('ProductItemDataDto Validator', () => {
49
57
  it('should return error for invalid action enum', () => {
50
58
  const dto = { ...baseValidDto, action: 'invalid-action' };
51
59
  const errors = (0, product_item_data_validator_1.validateProductItemDataDto)(dto);
52
- expect(errors.some(e => e.property === 'action')).toBe(true);
60
+ expect(errors.some((e) => e.property === 'action')).toBe(true);
53
61
  });
54
62
  it('should return error for non-string action', () => {
55
63
  const dto = { ...baseValidDto, action: 123 };
56
64
  const errors = (0, product_item_data_validator_1.validateProductItemDataDto)(dto);
57
- expect(errors.some(e => e.property === 'action')).toBe(true);
65
+ expect(errors.some((e) => e.property === 'action')).toBe(true);
58
66
  });
59
67
  });
60
68
  });