@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
@@ -9,54 +9,54 @@ 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
  {
30
30
  description: 'should return no errors for valid DTO',
31
31
  dto: {
32
32
  title: 'Test',
33
- supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
33
+ supportedActions: [item_actions_enum_1.ProductActionsEnum.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',
42
42
  dto: {
43
43
  title: 'Test',
44
- supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
44
+ supportedActions: [item_actions_enum_1.ProductActionsEnum.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',
52
52
  dto: {
53
53
  title: '',
54
- supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
54
+ supportedActions: [item_actions_enum_1.ProductActionsEnum.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,71 +65,85 @@ 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',
74
74
  dto: {
75
75
  title: 'Test',
76
- supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
76
+ supportedActions: [item_actions_enum_1.ProductActionsEnum.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',
85
85
  dto: {
86
86
  title: 'Test',
87
- supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
87
+ supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
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',
98
104
  dto: {
99
105
  title: '',
100
- supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
106
+ supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
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',
111
121
  dto: {
112
122
  title: 'Test',
113
- supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
123
+ supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
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',
123
135
  dto: {
124
136
  title: 'Test',
125
- supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
137
+ supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
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, () => {
@@ -141,12 +155,12 @@ describe('ProductInfoDto Validator', () => {
141
155
  {
142
156
  description: 'should return ValidationError for missing title',
143
157
  dto: {
144
- supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
158
+ supportedActions: [item_actions_enum_1.ProductActionsEnum.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
  });
@@ -184,7 +198,7 @@ describe('ProductInfoDto Validator', () => {
184
198
  };
185
199
  const dto = {
186
200
  title: 'Test',
187
- supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
201
+ supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
188
202
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
189
203
  productAttributes: [fieldWithOnlyMin],
190
204
  };
@@ -205,7 +219,7 @@ describe('ProductInfoDto Validator', () => {
205
219
  };
206
220
  const dto = {
207
221
  title: 'Test',
208
- supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
222
+ supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
209
223
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
210
224
  itemAttributes: [fieldWithOnlyMax],
211
225
  };
@@ -224,7 +238,7 @@ describe('ProductInfoDto Validator', () => {
224
238
  };
225
239
  const dto = {
226
240
  title: 'Test',
227
- supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
241
+ supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
228
242
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
229
243
  productAttributes: [fieldOk],
230
244
  };
@@ -245,7 +259,7 @@ describe('ProductInfoDto Validator', () => {
245
259
  };
246
260
  const dto = {
247
261
  title: 'Test',
248
- supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
262
+ supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
249
263
  supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
250
264
  itemAttributes: [fieldBad],
251
265
  };
@@ -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[];
@@ -18,10 +18,10 @@ describe('ProductItemDataDto Validator', () => {
18
18
  expect((0, product_item_data_validator_1.validateProductItemDataDto)(baseValidDto)).toHaveLength(0);
19
19
  });
20
20
  it('should return no errors with a valid action', () => {
21
- const dto = { ...baseValidDto, action: item_actions_enum_1.ProductItemActionsEnum.CREATE };
21
+ const dto = { ...baseValidDto, action: item_actions_enum_1.ProductActionsEnum.CREATE };
22
22
  expect((0, product_item_data_validator_1.validateProductItemDataDto)(dto)).toHaveLength(0);
23
23
  });
24
- it.each(Object.values(item_actions_enum_1.ProductItemActionsEnum))('should accept action %s', (action) => {
24
+ it.each(Object.values(item_actions_enum_1.ProductActionsEnum))('should accept action %s', (action) => {
25
25
  const dto = { ...baseValidDto, action };
26
26
  expect((0, product_item_data_validator_1.validateProductItemDataDto)(dto)).toHaveLength(0);
27
27
  });
@@ -31,7 +31,7 @@ describe('ProductItemDataDto Validator', () => {
31
31
  itemId: 'item-456',
32
32
  price: 9.99,
33
33
  discountPrice: 7.99,
34
- action: item_actions_enum_1.ProductItemActionsEnum.RENEW,
34
+ action: item_actions_enum_1.ProductActionsEnum.RENEW,
35
35
  };
36
36
  expect((0, product_item_data_validator_1.validateProductItemDataDto)(dto)).toHaveLength(0);
37
37
  });
@@ -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
  });
@@ -11,12 +11,15 @@ describe('SmsSenderDto Validator', () => {
11
11
  expect((0, sender_sms_validator_1.validateSmsSenderDto)(validDto)).toHaveLength(0);
12
12
  });
13
13
  it.each([
14
- [{ senderPhone: 'not-a-phone-number', message: 'Test Message' }, 'senderPhone'],
14
+ [
15
+ { senderPhone: 'not-a-phone-number', message: 'Test Message' },
16
+ 'senderPhone',
17
+ ],
15
18
  [{ senderPhone: '+11234567890' }, 'message'],
16
19
  [{ message: 'Test Message' }, 'senderPhone'],
17
20
  ])('should return error for invalid %s', (dto, expectedProp) => {
18
21
  const errors = (0, sender_sms_validator_1.validateSmsSenderDto)(dto);
19
22
  expect(errors.length).toBeGreaterThan(0);
20
- expect(errors.some(e => e.property === expectedProp)).toBe(true);
23
+ expect(errors.some((e) => e.property === expectedProp)).toBe(true);
21
24
  });
22
25
  });
@@ -5,24 +5,188 @@ const settings_with_tabs_validator_1 = require("./settings-with-tabs.validator")
5
5
  describe('SettingsWithTabsDto', () => {
6
6
  it.each([
7
7
  // valid
8
- [{ tabs: [{ label: 'Tab 1', icon: 'https://icon.com', description: 'Test', url: 'https://valid.com' }], label: 'Test', icon: 'https://icon.com', description: 'Test' }, 0],
8
+ [
9
+ {
10
+ tabs: [
11
+ {
12
+ label: 'Tab 1',
13
+ icon: 'https://icon.com',
14
+ description: 'Test',
15
+ url: 'https://valid.com',
16
+ },
17
+ ],
18
+ label: 'Test',
19
+ icon: 'https://icon.com',
20
+ description: 'Test',
21
+ },
22
+ 0,
23
+ ],
9
24
  // invalid URL
10
- [{ tabs: [{ label: 'Tab 1', icon: 'https://icon.com', description: 'Test', url: 'not-a-url' }], label: 'Test', icon: 'https://icon.com', description: 'Test' }, 1],
11
- [{ tabs: [{ label: 'Tab 1', icon: 'https://icon.com', description: 'Test', url: 'ftp://wrongprotocol.com' }], label: 'Test', icon: 'https://icon.com', description: 'Test' }, 1],
25
+ [
26
+ {
27
+ tabs: [
28
+ {
29
+ label: 'Tab 1',
30
+ icon: 'https://icon.com',
31
+ description: 'Test',
32
+ url: 'not-a-url',
33
+ },
34
+ ],
35
+ label: 'Test',
36
+ icon: 'https://icon.com',
37
+ description: 'Test',
38
+ },
39
+ 1,
40
+ ],
41
+ [
42
+ {
43
+ tabs: [
44
+ {
45
+ label: 'Tab 1',
46
+ icon: 'https://icon.com',
47
+ description: 'Test',
48
+ url: 'ftp://wrongprotocol.com',
49
+ },
50
+ ],
51
+ label: 'Test',
52
+ icon: 'https://icon.com',
53
+ description: 'Test',
54
+ },
55
+ 1,
56
+ ],
12
57
  // missing URL
13
- [{ tabs: [{ label: 'Tab 1', icon: 'https://icon.com', description: 'Test' }], label: 'Missing URL', icon: 'https://icon.com', description: 'Test' }, 1],
14
- [{ tabs: [{ label: 'Tab 1', icon: 'https://icon.com', description: 'Test' }], label: 'Empty URL', icon: 'https://icon.com', description: 'Test' }, 1],
15
- [{ tabs: [{ label: 'Tab 1', icon: 'https://icon.com', description: 'Test' }], label: 'Null URL', icon: 'https://icon.com', description: 'Test' }, 1],
58
+ [
59
+ {
60
+ tabs: [
61
+ { label: 'Tab 1', icon: 'https://icon.com', description: 'Test' },
62
+ ],
63
+ label: 'Missing URL',
64
+ icon: 'https://icon.com',
65
+ description: 'Test',
66
+ },
67
+ 1,
68
+ ],
69
+ [
70
+ {
71
+ tabs: [
72
+ { label: 'Tab 1', icon: 'https://icon.com', description: 'Test' },
73
+ ],
74
+ label: 'Empty URL',
75
+ icon: 'https://icon.com',
76
+ description: 'Test',
77
+ },
78
+ 1,
79
+ ],
80
+ [
81
+ {
82
+ tabs: [
83
+ { label: 'Tab 1', icon: 'https://icon.com', description: 'Test' },
84
+ ],
85
+ label: 'Null URL',
86
+ icon: 'https://icon.com',
87
+ description: 'Test',
88
+ },
89
+ 1,
90
+ ],
16
91
  // missing Name
17
- [{ tabs: [{ label: 'Tab 1', icon: 'https://icon.com', description: 'Test', url: 'https://valid.com' }], icon: 'https://icon.com', description: 'Test' }, 1],
18
- [{ tabs: [{ label: 'Tab 1', icon: 'https://icon.com', description: 'Test', url: 'https://valid.com' }], label: '', icon: 'https://icon.com', description: 'Test' }, 1],
19
- [{ tabs: [{ label: 'Tab 1', icon: 'https://icon.com', description: 'Test', url: 'https://valid.com' }], label: null, icon: 'https://icon.com', description: 'Test' }, 1],
92
+ [
93
+ {
94
+ tabs: [
95
+ {
96
+ label: 'Tab 1',
97
+ icon: 'https://icon.com',
98
+ description: 'Test',
99
+ url: 'https://valid.com',
100
+ },
101
+ ],
102
+ icon: 'https://icon.com',
103
+ description: 'Test',
104
+ },
105
+ 1,
106
+ ],
107
+ [
108
+ {
109
+ tabs: [
110
+ {
111
+ label: 'Tab 1',
112
+ icon: 'https://icon.com',
113
+ description: 'Test',
114
+ url: 'https://valid.com',
115
+ },
116
+ ],
117
+ label: '',
118
+ icon: 'https://icon.com',
119
+ description: 'Test',
120
+ },
121
+ 1,
122
+ ],
123
+ [
124
+ {
125
+ tabs: [
126
+ {
127
+ label: 'Tab 1',
128
+ icon: 'https://icon.com',
129
+ description: 'Test',
130
+ url: 'https://valid.com',
131
+ },
132
+ ],
133
+ label: null,
134
+ icon: 'https://icon.com',
135
+ description: 'Test',
136
+ },
137
+ 1,
138
+ ],
20
139
  // missing both link and icon
21
- [{ tabs: [{ label: 'Tab 1', icon: 'https://icon.com', description: 'Test', url: 'https://valid.com' }], label: 'Missing URL', description: 'Test' }, 1],
140
+ [
141
+ {
142
+ tabs: [
143
+ {
144
+ label: 'Tab 1',
145
+ icon: 'https://icon.com',
146
+ description: 'Test',
147
+ url: 'https://valid.com',
148
+ },
149
+ ],
150
+ label: 'Missing URL',
151
+ description: 'Test',
152
+ },
153
+ 1,
154
+ ],
22
155
  // null both
23
- [{ tabs: [{ label: 'Tab 1', icon: 'https://icon.com', description: 'Test', url: 'https://valid.com' }], label: null, icon: null, description: 'Test' }, 2],
156
+ [
157
+ {
158
+ tabs: [
159
+ {
160
+ label: 'Tab 1',
161
+ icon: 'https://icon.com',
162
+ description: 'Test',
163
+ url: 'https://valid.com',
164
+ },
165
+ ],
166
+ label: null,
167
+ icon: null,
168
+ description: 'Test',
169
+ },
170
+ 2,
171
+ ],
24
172
  // extra unexpected field should still pass base validation?
25
- [{ tabs: [{ label: 'Tab 1', icon: 'https://icon.com', description: 'Test', url: 'https://valid.com' }], label: 'Test', icon: 'https://icon.com', description: 'Test', extra: 'field' }, 0],
173
+ [
174
+ {
175
+ tabs: [
176
+ {
177
+ label: 'Tab 1',
178
+ icon: 'https://icon.com',
179
+ description: 'Test',
180
+ url: 'https://valid.com',
181
+ },
182
+ ],
183
+ label: 'Test',
184
+ icon: 'https://icon.com',
185
+ description: 'Test',
186
+ extra: 'field',
187
+ },
188
+ 0,
189
+ ],
26
190
  ])('validates %# -> %s errors', (input, expectedCount) => {
27
191
  expect((0, settings_with_tabs_validator_1.validateSettingsWithTabsDto)(input)).toHaveLength(expectedCount);
28
192
  });
@@ -5,24 +5,102 @@ const settings_with_url_validator_1 = require("./settings-with-url.validator");
5
5
  describe('SettingsWithUrlDto', () => {
6
6
  it.each([
7
7
  // valid
8
- [{ url: 'https://valid.com', label: 'Test', icon: 'https://icon.com', description: 'Test' }, 0],
8
+ [
9
+ {
10
+ url: 'https://valid.com',
11
+ label: 'Test',
12
+ icon: 'https://icon.com',
13
+ description: 'Test',
14
+ },
15
+ 0,
16
+ ],
9
17
  // invalid URL
10
- [{ url: 'not-a-url', label: 'Test', icon: 'https://icon.com', description: 'Test' }, 1],
11
- [{ url: 'ftp://wrongprotocol.com', label: 'Test', icon: 'https://icon.com', description: 'Test' }, 1],
18
+ [
19
+ {
20
+ url: 'not-a-url',
21
+ label: 'Test',
22
+ icon: 'https://icon.com',
23
+ description: 'Test',
24
+ },
25
+ 1,
26
+ ],
27
+ [
28
+ {
29
+ url: 'ftp://wrongprotocol.com',
30
+ label: 'Test',
31
+ icon: 'https://icon.com',
32
+ description: 'Test',
33
+ },
34
+ 1,
35
+ ],
12
36
  // missing URL
13
- [{ label: 'Missing URL', icon: 'https://icon.com', description: 'Test' }, 1],
14
- [{ url: '', label: 'Empty URL', icon: 'https://icon.com', description: 'Test' }, 1],
15
- [{ url: null, label: 'Null URL', icon: 'https://icon.com', description: 'Test' }, 1],
37
+ [
38
+ { label: 'Missing URL', icon: 'https://icon.com', description: 'Test' },
39
+ 1,
40
+ ],
41
+ [
42
+ {
43
+ url: '',
44
+ label: 'Empty URL',
45
+ icon: 'https://icon.com',
46
+ description: 'Test',
47
+ },
48
+ 1,
49
+ ],
50
+ [
51
+ {
52
+ url: null,
53
+ label: 'Null URL',
54
+ icon: 'https://icon.com',
55
+ description: 'Test',
56
+ },
57
+ 1,
58
+ ],
16
59
  // missing Name
17
- [{ url: 'https://valid.com', icon: 'https://icon.com', description: 'Test' }, 1],
18
- [{ url: 'https://valid.com', label: '', icon: 'https://icon.com', description: 'Test' }, 1],
19
- [{ url: 'https://valid.com', label: null, icon: 'https://icon.com', description: 'Test' }, 1],
60
+ [
61
+ {
62
+ url: 'https://valid.com',
63
+ icon: 'https://icon.com',
64
+ description: 'Test',
65
+ },
66
+ 1,
67
+ ],
68
+ [
69
+ {
70
+ url: 'https://valid.com',
71
+ label: '',
72
+ icon: 'https://icon.com',
73
+ description: 'Test',
74
+ },
75
+ 1,
76
+ ],
77
+ [
78
+ {
79
+ url: 'https://valid.com',
80
+ label: null,
81
+ icon: 'https://icon.com',
82
+ description: 'Test',
83
+ },
84
+ 1,
85
+ ],
20
86
  // missing both link and icon
21
87
  [{ label: 'Missing URL', description: 'Test' }, 2],
22
88
  // null both
23
- [{ url: null, label: null, icon: 'https://icon.com', description: 'Test' }, 2],
89
+ [
90
+ { url: null, label: null, icon: 'https://icon.com', description: 'Test' },
91
+ 2,
92
+ ],
24
93
  // extra unexpected field should still pass base validation?
25
- [{ url: 'https://valid.com', label: 'Test', icon: 'https://icon.com', description: 'Test', extra: 'field' }, 0],
94
+ [
95
+ {
96
+ url: 'https://valid.com',
97
+ label: 'Test',
98
+ icon: 'https://icon.com',
99
+ description: 'Test',
100
+ extra: 'field',
101
+ },
102
+ 0,
103
+ ],
26
104
  ])('validates %# -> %s errors', (input, expectedCount) => {
27
105
  expect((0, settings_with_url_validator_1.validateSettingsWithUrlDto)(input)).toHaveLength(expectedCount);
28
106
  });