@hosterai/types 0.0.28 → 0.0.30

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 (104) 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.d.ts +2 -2
  46. package/dist/dtos/product/product-info.dto.js +12 -6
  47. package/dist/dtos/product/product-item-data.dto.d.ts +3 -3
  48. package/dist/dtos/product/product-item-data.dto.js +2 -2
  49. package/dist/dtos/product/requests/product-create-request.dto.js +1 -1
  50. package/dist/dtos/product/requests/product-delete-request.dto.js +3 -3
  51. package/dist/dtos/product/requests/product-downgradable-request.dto.js +1 -1
  52. package/dist/dtos/product/requests/product-downgrade-request.dto.js +1 -1
  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/responses/product-info-response.dto.js +1 -1
  59. package/dist/dtos/responses/validate-attributes-response.dto.d.ts +2 -2
  60. package/dist/dtos/tab.dto.js +2 -2
  61. package/dist/dtos/tax-manager/tax-details-request.dto.d.ts +31 -0
  62. package/dist/dtos/tax-manager/tax-details-request.dto.js +84 -0
  63. package/dist/dtos/unit.dto.js +3 -3
  64. package/dist/enums/country.enum.d.ts +1 -1
  65. package/dist/enums/country.enum.js +312 -78
  66. package/dist/enums/currency.enum.d.ts +43 -0
  67. package/dist/enums/currency.enum.js +47 -0
  68. package/dist/enums/item-actions.enum.d.ts +10 -10
  69. package/dist/enums/item-actions.enum.js +13 -14
  70. package/dist/index.d.ts +2 -1
  71. package/dist/index.js +2 -1
  72. package/dist/openapi/schemas/components.schemas.d.ts +1 -31
  73. package/dist/openapi/schemas/components.schemas.js +19 -49
  74. package/dist/validators/action-validator.spec.js +3 -3
  75. package/dist/validators/addon-field-validator.spec.js +10 -3
  76. package/dist/validators/admin-panel-more-actions-validator.spec.js +12 -8
  77. package/dist/validators/admin-panel-more-actions.validator.d.ts +1 -1
  78. package/dist/validators/admin-panel-tabs-validator.spec.js +74 -10
  79. package/dist/validators/admin-panel-tabs.validator.d.ts +1 -1
  80. package/dist/validators/admin-panel-validator.spec.js +164 -32
  81. package/dist/validators/attachment-validator.spec.js +8 -8
  82. package/dist/validators/attribute-field-validator.spec.js +18 -7
  83. package/dist/validators/client-panel-validator.spec.js +57 -9
  84. package/dist/validators/country-validator.spec.js +7 -7
  85. package/dist/validators/field-validator.spec.js +35 -10
  86. package/dist/validators/info-validator.spec.js +10 -10
  87. package/dist/validators/invoice-contact-data-validator.spec.js +18 -10
  88. package/dist/validators/invoice-info-validator.spec.js +14 -10
  89. package/dist/validators/invoice-item-data-validator.spec.js +4 -4
  90. package/dist/validators/item-data-validator.spec.js +17 -9
  91. package/dist/validators/menu-with-submenu-validator.spec.js +13 -11
  92. package/dist/validators/menu-with-url-validator.spec.js +15 -5
  93. package/dist/validators/notification-info-validator.spec.js +28 -20
  94. package/dist/validators/product-info-validator.spec.js +59 -45
  95. package/dist/validators/product-info.validator.d.ts +1 -1
  96. package/dist/validators/product-item-data-validator.spec.js +15 -7
  97. package/dist/validators/sender-sms-validator.spec.js +5 -2
  98. package/dist/validators/settings-with-tabs-validator.spec.js +176 -12
  99. package/dist/validators/settings-with-url-validator.spec.js +89 -11
  100. package/dist/validators/tab-validator.spec.js +7 -7
  101. package/dist/validators/tin-validation-details-validator.spec.js +8 -8
  102. package/dist/validators/transaction-data-validator.spec.js +13 -8
  103. package/dist/validators/unit-validator.spec.js +13 -4
  104. package/package.json +1 -1
@@ -2,7 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("reflect-metadata");
4
4
  const admin_panel_validator_1 = require("./admin-panel.validator");
5
- const validAction = { icon: 'add', openMethod: 'ajax_call', url: 'https://example.com/action' };
5
+ const validAction = {
6
+ icon: 'add',
7
+ openMethod: 'ajax_call',
8
+ url: 'https://example.com/action',
9
+ };
6
10
  const minimalValidMenuDtoWithUrl = {
7
11
  type: 'only-url',
8
12
  icon: 'https://example.com/icon.png',
@@ -40,17 +44,39 @@ describe('AdminPanelDto full validation', () => {
40
44
  // Empty object is invalid
41
45
  ['valid minimal empty object', {}, false],
42
46
  // Tabs tests
43
- ['invalid all empty tabs and empty moreActions', {
47
+ [
48
+ 'invalid all empty tabs and empty moreActions',
49
+ {
44
50
  tabs: { product: [], item: [], client: [], user: [], order: [] },
45
51
  moreActions: {},
46
- }, false],
47
- ['valid with one non-empty tab', {
48
- tabs: { product: [{ label: 'Product', url: 'https://example.com/product' }] },
49
- }, true],
50
- ['invalid with one non-empty tab', {
51
- tabs: { product: [{ label: 'Product', url: 'https://example.com/product' }], item: [], client: [], user: [], order: [] },
52
- }, false],
53
- ['invalid with multiple non-empty tabs', {
52
+ },
53
+ false,
54
+ ],
55
+ [
56
+ 'valid with one non-empty tab',
57
+ {
58
+ tabs: {
59
+ product: [{ label: 'Product', url: 'https://example.com/product' }],
60
+ },
61
+ },
62
+ true,
63
+ ],
64
+ [
65
+ 'invalid with one non-empty tab',
66
+ {
67
+ tabs: {
68
+ product: [{ label: 'Product', url: 'https://example.com/product' }],
69
+ item: [],
70
+ client: [],
71
+ user: [],
72
+ order: [],
73
+ },
74
+ },
75
+ false,
76
+ ],
77
+ [
78
+ 'invalid with multiple non-empty tabs',
79
+ {
54
80
  tabs: {
55
81
  product: [{ label: 'Product', url: 'https://example.com/product' }],
56
82
  item: [{ label: 'Item', url: 'https://example.com/item' }],
@@ -58,40 +84,144 @@ describe('AdminPanelDto full validation', () => {
58
84
  user: [],
59
85
  order: [],
60
86
  },
61
- }, false],
62
- ['valid with multiple non-empty tabs', {
87
+ },
88
+ false,
89
+ ],
90
+ [
91
+ 'valid with multiple non-empty tabs',
92
+ {
63
93
  tabs: {
64
94
  product: [{ label: 'Product', url: 'https://example.com/product' }],
65
95
  item: [{ label: 'Item', url: 'https://example.com/item' }],
66
96
  },
67
- }, true],
97
+ },
98
+ true,
99
+ ],
68
100
  // MoreActions tests
69
- ['valid with moreActions.client', { moreActions: { client: [validAction] } }, true],
70
- ['valid with moreActions.item', { moreActions: { item: [validAction] } }, true],
71
- ['valid with moreActions.invoice', { moreActions: { invoice: [validAction] } }, true],
72
- ['valid with moreActions.order', { moreActions: { order: [validAction] } }, true],
73
- ['valid with moreActions.user', { moreActions: { user: [validAction] } }, true],
74
- ['invalid moreActions.client with bad openMethod', { moreActions: { client: [{ icon: 'add', openMethod: 'bad_method', url: 'https://example.com/action' }] } }, false],
101
+ [
102
+ 'valid with moreActions.client',
103
+ { moreActions: { client: [validAction] } },
104
+ true,
105
+ ],
106
+ [
107
+ 'valid with moreActions.item',
108
+ { moreActions: { item: [validAction] } },
109
+ true,
110
+ ],
111
+ [
112
+ 'valid with moreActions.invoice',
113
+ { moreActions: { invoice: [validAction] } },
114
+ true,
115
+ ],
116
+ [
117
+ 'valid with moreActions.order',
118
+ { moreActions: { order: [validAction] } },
119
+ true,
120
+ ],
121
+ [
122
+ 'valid with moreActions.user',
123
+ { moreActions: { user: [validAction] } },
124
+ true,
125
+ ],
126
+ [
127
+ 'invalid moreActions.client with bad openMethod',
128
+ {
129
+ moreActions: {
130
+ client: [
131
+ {
132
+ icon: 'add',
133
+ openMethod: 'bad_method',
134
+ url: 'https://example.com/action',
135
+ },
136
+ ],
137
+ },
138
+ },
139
+ false,
140
+ ],
75
141
  // Menu and Settings valid combos
76
142
  ['valid menu with URL type', { menu: minimalValidMenuDtoWithUrl }, true],
77
- ['valid menu with submenu type', { menu: minimalValidMenuDtoWithSubmenu }, true],
78
- ['valid menu and settings URL', { menu: minimalValidMenuDtoWithUrl, settings: minimalValidSettingsWithUrlDto }, true],
79
- ['valid menu and settings tabs', { menu: minimalValidMenuDtoWithSubmenu, settings: minimalValidSettingsWithTabsDto }, true],
143
+ [
144
+ 'valid menu with submenu type',
145
+ { menu: minimalValidMenuDtoWithSubmenu },
146
+ true,
147
+ ],
148
+ [
149
+ 'valid menu and settings URL',
150
+ {
151
+ menu: minimalValidMenuDtoWithUrl,
152
+ settings: minimalValidSettingsWithUrlDto,
153
+ },
154
+ true,
155
+ ],
156
+ [
157
+ 'valid menu and settings tabs',
158
+ {
159
+ menu: minimalValidMenuDtoWithSubmenu,
160
+ settings: minimalValidSettingsWithTabsDto,
161
+ },
162
+ true,
163
+ ],
80
164
  // Invalid menu cases
81
- ['invalid menu missing required fields', { menu: { type: 'only-url' } }, false],
82
- ['invalid menu unknown type', { menu: { type: 'unknown', icon: 'https://icon.png', label: 'Label', url: 'https://example.com' } }, false],
83
- ['invalid menu with extra property', { menu: { ...minimalValidMenuDtoWithUrl, extra: 'not allowed' } }, false],
84
- ['invalid menu with submenu on URL menu', { menu: { ...minimalValidMenuDtoWithUrl, submenu: [{ url: 'https://example.com', label: 'Sub' }] } }, false],
165
+ [
166
+ 'invalid menu missing required fields',
167
+ { menu: { type: 'only-url' } },
168
+ false,
169
+ ],
170
+ [
171
+ 'invalid menu unknown type',
172
+ {
173
+ menu: {
174
+ type: 'unknown',
175
+ icon: 'https://icon.png',
176
+ label: 'Label',
177
+ url: 'https://example.com',
178
+ },
179
+ },
180
+ false,
181
+ ],
182
+ [
183
+ 'invalid menu with extra property',
184
+ { menu: { ...minimalValidMenuDtoWithUrl, extra: 'not allowed' } },
185
+ false,
186
+ ],
187
+ [
188
+ 'invalid menu with submenu on URL menu',
189
+ {
190
+ menu: {
191
+ ...minimalValidMenuDtoWithUrl,
192
+ submenu: [{ url: 'https://example.com', label: 'Sub' }],
193
+ },
194
+ },
195
+ false,
196
+ ],
85
197
  // Invalid tabs type
86
198
  ['invalid tabs not an object', { tabs: 'not-an-object' }, false],
87
199
  // Invalid extra property on root DTO
88
200
  ['invalid extra property on root', { extra: 'not allowed' }, false],
89
201
  // Settings validation edge cases
90
- ['valid settings with SettingsWithUrlDto', { settings: minimalValidSettingsWithUrlDto }, true],
91
- ['valid settings with SettingsWithTabsDto', { settings: minimalValidSettingsWithTabsDto }, true],
92
- ['invalid settings missing required fields', { settings: { label: 'Missing url and tabs' } }, false],
93
- ['invalid settings with extra property', { settings: { ...minimalValidSettingsWithUrlDto, extra: 'not allowed' } }, false],
94
- ['invalid settings with both url and tabs', {
202
+ [
203
+ 'valid settings with SettingsWithUrlDto',
204
+ { settings: minimalValidSettingsWithUrlDto },
205
+ true,
206
+ ],
207
+ [
208
+ 'valid settings with SettingsWithTabsDto',
209
+ { settings: minimalValidSettingsWithTabsDto },
210
+ true,
211
+ ],
212
+ [
213
+ 'invalid settings missing required fields',
214
+ { settings: { label: 'Missing url and tabs' } },
215
+ false,
216
+ ],
217
+ [
218
+ 'invalid settings with extra property',
219
+ { settings: { ...minimalValidSettingsWithUrlDto, extra: 'not allowed' } },
220
+ false,
221
+ ],
222
+ [
223
+ 'invalid settings with both url and tabs',
224
+ {
95
225
  settings: {
96
226
  url: 'https://example.com',
97
227
  tabs: [{ label: 'Tab 1', url: 'https://example.com/tab1' }],
@@ -99,7 +229,9 @@ describe('AdminPanelDto full validation', () => {
99
229
  icon: 'https://example.com/icon.png',
100
230
  description: 'Should fail because both url and tabs are present',
101
231
  },
102
- }, false],
232
+ },
233
+ false,
234
+ ],
103
235
  ])('%s', async (_desc, input, expectedValid) => {
104
236
  const errors = await (0, admin_panel_validator_1.validateAdminPanelDto)(input);
105
237
  if (expectedValid) {
@@ -19,40 +19,40 @@ describe('AttachmentDto Validator', () => {
19
19
  describe('Missing required fields', () => {
20
20
  it('should return errors when all fields are missing', () => {
21
21
  const errors = (0, attachment_validator_1.validateAttachmentDto)({});
22
- expect(errors.some(e => e.property === 'filename')).toBe(true);
23
- expect(errors.some(e => e.property === 'content')).toBe(true);
22
+ expect(errors.some((e) => e.property === 'filename')).toBe(true);
23
+ expect(errors.some((e) => e.property === 'content')).toBe(true);
24
24
  });
25
25
  it('should return error when filename is missing', () => {
26
26
  const dto = { content: 'SGVsbG8=' };
27
27
  const errors = (0, attachment_validator_1.validateAttachmentDto)(dto);
28
- expect(errors.some(e => e.property === 'filename')).toBe(true);
28
+ expect(errors.some((e) => e.property === 'filename')).toBe(true);
29
29
  });
30
30
  it('should return error when content is missing', () => {
31
31
  const dto = { filename: 'test.pdf' };
32
32
  const errors = (0, attachment_validator_1.validateAttachmentDto)(dto);
33
- expect(errors.some(e => e.property === 'content')).toBe(true);
33
+ expect(errors.some((e) => e.property === 'content')).toBe(true);
34
34
  });
35
35
  });
36
36
  describe('Invalid field values', () => {
37
37
  it('should return error for empty filename', () => {
38
38
  const dto = { ...baseValidDto, filename: '' };
39
39
  const errors = (0, attachment_validator_1.validateAttachmentDto)(dto);
40
- expect(errors.some(e => e.property === 'filename')).toBe(true);
40
+ expect(errors.some((e) => e.property === 'filename')).toBe(true);
41
41
  });
42
42
  it('should return error for empty content', () => {
43
43
  const dto = { ...baseValidDto, content: '' };
44
44
  const errors = (0, attachment_validator_1.validateAttachmentDto)(dto);
45
- expect(errors.some(e => e.property === 'content')).toBe(true);
45
+ expect(errors.some((e) => e.property === 'content')).toBe(true);
46
46
  });
47
47
  it('should return error for non-base64 content', () => {
48
48
  const dto = { ...baseValidDto, content: 'not-valid-base64!!!' };
49
49
  const errors = (0, attachment_validator_1.validateAttachmentDto)(dto);
50
- expect(errors.some(e => e.property === 'content')).toBe(true);
50
+ expect(errors.some((e) => e.property === 'content')).toBe(true);
51
51
  });
52
52
  it('should return error for non-string contentType', () => {
53
53
  const dto = { ...baseValidDto, contentType: 123 };
54
54
  const errors = (0, attachment_validator_1.validateAttachmentDto)(dto);
55
- expect(errors.some(e => e.property === 'contentType')).toBe(true);
55
+ expect(errors.some((e) => e.property === 'contentType')).toBe(true);
56
56
  });
57
57
  });
58
58
  });
@@ -19,7 +19,11 @@ describe('AttributeFieldDto Validator', () => {
19
19
  expect((0, attribute_field_validator_1.validateAttributeFieldDto)(baseValidDto)).toHaveLength(0);
20
20
  });
21
21
  it('should return no errors with optional visibleInOrder and visibleInClientPanel', () => {
22
- const dto = { ...baseValidDto, visibleInOrder: true, visibleInClientPanel: false };
22
+ const dto = {
23
+ ...baseValidDto,
24
+ visibleInOrder: true,
25
+ visibleInClientPanel: false,
26
+ };
23
27
  expect((0, attribute_field_validator_1.validateAttributeFieldDto)(dto)).toHaveLength(0);
24
28
  });
25
29
  it('should return no errors with both repeatableMin and repeatableMax', () => {
@@ -54,30 +58,37 @@ describe('AttributeFieldDto Validator', () => {
54
58
  it('should return error for non-boolean visibleInOrder', () => {
55
59
  const dto = { ...baseValidDto, visibleInOrder: 'yes' };
56
60
  const errors = (0, attribute_field_validator_1.validateAttributeFieldDto)(dto);
57
- expect(errors.some(e => e.property === 'visibleInOrder')).toBe(true);
61
+ expect(errors.some((e) => e.property === 'visibleInOrder')).toBe(true);
58
62
  });
59
63
  it('should return error for non-boolean visibleInClientPanel', () => {
60
64
  const dto = { ...baseValidDto, visibleInClientPanel: 1 };
61
65
  const errors = (0, attribute_field_validator_1.validateAttributeFieldDto)(dto);
62
- expect(errors.some(e => e.property === 'visibleInClientPanel')).toBe(true);
66
+ expect(errors.some((e) => e.property === 'visibleInClientPanel')).toBe(true);
63
67
  });
64
68
  it('should return error for non-number repeatableMin', () => {
65
69
  const dto = { ...baseValidDto, repeatableMin: 'one', repeatableMax: 5 };
66
70
  const errors = (0, attribute_field_validator_1.validateAttributeFieldDto)(dto);
67
- expect(errors.some(e => e.property === 'repeatableMin')).toBe(true);
71
+ expect(errors.some((e) => e.property === 'repeatableMin')).toBe(true);
68
72
  });
69
73
  it('should return error for non-number repeatableMax', () => {
70
74
  const dto = { ...baseValidDto, repeatableMin: 1, repeatableMax: 'five' };
71
75
  const errors = (0, attribute_field_validator_1.validateAttributeFieldDto)(dto);
72
- expect(errors.some(e => e.property === 'repeatableMax')).toBe(true);
76
+ expect(errors.some((e) => e.property === 'repeatableMax')).toBe(true);
73
77
  });
74
78
  });
75
79
  describe('Inherited FieldDto validation', () => {
76
80
  it('should return errors when inherited required fields are missing', () => {
77
81
  const errors = (0, attribute_field_validator_1.validateAttributeFieldDto)({});
78
- const requiredProps = ['id', 'label', 'value', 'type', 'required', 'disabled'];
82
+ const requiredProps = [
83
+ 'id',
84
+ 'label',
85
+ 'value',
86
+ 'type',
87
+ 'required',
88
+ 'disabled',
89
+ ];
79
90
  for (const prop of requiredProps) {
80
- expect(errors.some(e => e.property === prop)).toBe(true);
91
+ expect(errors.some((e) => e.property === prop)).toBe(true);
81
92
  }
82
93
  });
83
94
  });
@@ -2,7 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("reflect-metadata");
4
4
  const client_panel_validator_1 = require("./client-panel.validator"); // your validation function
5
- const validAction = { icon: 'add', openMethod: 'ajax_call', url: 'https://example.com/action' };
5
+ const validAction = {
6
+ icon: 'add',
7
+ openMethod: 'ajax_call',
8
+ url: 'https://example.com/action',
9
+ };
6
10
  const minimalValidMenuDtoWithUrl = {
7
11
  type: 'only-url',
8
12
  icon: 'https://example.com/icon.png',
@@ -25,18 +29,62 @@ describe('ClientPanelDto full validation', () => {
25
29
  // Tabs tests
26
30
  ['invalid empty tabs object', { tabs: {} }, false],
27
31
  ['invalid tabs with empty item array', { tabs: { item: [] } }, false],
28
- ['valid tabs with one item', { tabs: { item: [{ label: 'Tab 1', url: 'https://example.com/tab1' }] } }, true],
32
+ [
33
+ 'valid tabs with one item',
34
+ { tabs: { item: [{ label: 'Tab 1', url: 'https://example.com/tab1' }] } },
35
+ true,
36
+ ],
29
37
  // MoreActions tests
30
38
  ['invalid empty moreActions object', { moreActions: {} }, false],
31
- ['invalid moreActions with empty item array', { moreActions: { item: [] } }, false],
32
- ['valid moreActions with one item', { moreActions: { item: [validAction] } }, true],
39
+ [
40
+ 'invalid moreActions with empty item array',
41
+ { moreActions: { item: [] } },
42
+ false,
43
+ ],
44
+ [
45
+ 'valid moreActions with one item',
46
+ { moreActions: { item: [validAction] } },
47
+ true,
48
+ ],
33
49
  // Menu tests
34
50
  ['valid menu with URL type', { menu: minimalValidMenuDtoWithUrl }, true],
35
- ['valid menu with submenu type', { menu: minimalValidMenuDtoWithSubmenu }, true],
36
- ['invalid menu missing required fields', { menu: { type: 'only-url' } }, false],
37
- ['invalid menu unknown type', { menu: { type: 'unknown', icon: 'https://icon.png', label: 'Label', url: 'https://example.com' } }, false],
38
- ['invalid menu with extra property', { menu: { ...minimalValidMenuDtoWithUrl, extra: 'not allowed' } }, false],
39
- ['invalid menu with submenu on URL menu', { menu: { ...minimalValidMenuDtoWithUrl, submenu: [{ url: 'https://example.com', label: 'Sub' }] } }, false],
51
+ [
52
+ 'valid menu with submenu type',
53
+ { menu: minimalValidMenuDtoWithSubmenu },
54
+ true,
55
+ ],
56
+ [
57
+ 'invalid menu missing required fields',
58
+ { menu: { type: 'only-url' } },
59
+ false,
60
+ ],
61
+ [
62
+ 'invalid menu unknown type',
63
+ {
64
+ menu: {
65
+ type: 'unknown',
66
+ icon: 'https://icon.png',
67
+ label: 'Label',
68
+ url: 'https://example.com',
69
+ },
70
+ },
71
+ false,
72
+ ],
73
+ [
74
+ 'invalid menu with extra property',
75
+ { menu: { ...minimalValidMenuDtoWithUrl, extra: 'not allowed' } },
76
+ false,
77
+ ],
78
+ [
79
+ 'invalid menu with submenu on URL menu',
80
+ {
81
+ menu: {
82
+ ...minimalValidMenuDtoWithUrl,
83
+ submenu: [{ url: 'https://example.com', label: 'Sub' }],
84
+ },
85
+ },
86
+ false,
87
+ ],
40
88
  // Invalid extra property on root DTO
41
89
  ['invalid extra property on root', { extra: 'not allowed' }, false],
42
90
  ])('%s', async (_desc, input, expectedValid) => {
@@ -24,35 +24,35 @@ describe('CountryDto Validator', () => {
24
24
  describe('Missing required fields', () => {
25
25
  it('should return errors when all fields are missing', () => {
26
26
  const errors = (0, country_validator_1.validateCountryDto)({});
27
- expect(errors.some(e => e.property === 'name')).toBe(true);
28
- expect(errors.some(e => e.property === 'code')).toBe(true);
27
+ expect(errors.some((e) => e.property === 'name')).toBe(true);
28
+ expect(errors.some((e) => e.property === 'code')).toBe(true);
29
29
  });
30
30
  it('should return error when name is missing', () => {
31
31
  const dto = { code: country_enum_1.CountryEnum.GREECE };
32
32
  const errors = (0, country_validator_1.validateCountryDto)(dto);
33
- expect(errors.some(e => e.property === 'name')).toBe(true);
33
+ expect(errors.some((e) => e.property === 'name')).toBe(true);
34
34
  });
35
35
  it('should return error when code is missing', () => {
36
36
  const dto = { name: 'Greece' };
37
37
  const errors = (0, country_validator_1.validateCountryDto)(dto);
38
- expect(errors.some(e => e.property === 'code')).toBe(true);
38
+ expect(errors.some((e) => e.property === 'code')).toBe(true);
39
39
  });
40
40
  });
41
41
  describe('Invalid field values', () => {
42
42
  it('should return error for empty name', () => {
43
43
  const dto = { ...baseValidDto, name: '' };
44
44
  const errors = (0, country_validator_1.validateCountryDto)(dto);
45
- expect(errors.some(e => e.property === 'name')).toBe(true);
45
+ expect(errors.some((e) => e.property === 'name')).toBe(true);
46
46
  });
47
47
  it('should return error for invalid country code', () => {
48
48
  const dto = { ...baseValidDto, code: 'INVALID' };
49
49
  const errors = (0, country_validator_1.validateCountryDto)(dto);
50
- expect(errors.some(e => e.property === 'code')).toBe(true);
50
+ expect(errors.some((e) => e.property === 'code')).toBe(true);
51
51
  });
52
52
  it('should return error for non-boolean isEurope', () => {
53
53
  const dto = { ...baseValidDto, isEurope: 'yes' };
54
54
  const errors = (0, country_validator_1.validateCountryDto)(dto);
55
- expect(errors.some(e => e.property === 'isEurope')).toBe(true);
55
+ expect(errors.some((e) => e.property === 'isEurope')).toBe(true);
56
56
  });
57
57
  });
58
58
  });
@@ -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
  });