@hosterai/types 0.0.27 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/decorators/all-or-none-validator.spec.js +9 -3
- package/dist/decorators/at-least-one-non-empty-validator.spec.js +1 -1
- package/dist/decorators/at-least-one-non-empty.validator.js +2 -2
- package/dist/decorators/is-of-allowed-types-validator.spec.js +10 -8
- package/dist/decorators/is-of-allowed-types.validator.js +4 -2
- package/dist/decorators/is-one-of.validator.d.ts +2 -2
- package/dist/decorators/is-one-of.validator.js +1 -1
- package/dist/decorators/is-plain-object.validator.d.ts +1 -1
- package/dist/decorators/is-plain-object.validator.js +3 -1
- package/dist/decorators/is-property-forbidden-validator.spec.js +12 -4
- package/dist/decorators/is-property-forbidden.validator.d.ts +1 -1
- package/dist/decorators/is-regex.validator.d.ts +1 -1
- package/dist/decorators/min-less-or-equal-validator.spec.js +6 -2
- package/dist/dtos/action.dto.js +5 -5
- package/dist/dtos/addon-field.dto.d.ts +1 -1
- package/dist/dtos/admin-panel.dto.js +16 -18
- package/dist/dtos/attribute-field.dto.d.ts +1 -1
- package/dist/dtos/client-panel.dto.d.ts +3 -3
- package/dist/dtos/client-panel.dto.js +11 -10
- package/dist/dtos/company-data.dto.d.ts +4 -0
- package/dist/dtos/company-data.dto.js +19 -8
- package/dist/dtos/error-response.dto.js +1 -4
- package/dist/dtos/field-option.dto.js +3 -3
- package/dist/dtos/info.dto.js +10 -10
- package/dist/dtos/invoice/invoice-info.dto.d.ts +3 -3
- package/dist/dtos/invoice/invoice-info.dto.js +1 -1
- package/dist/dtos/invoice/invoice-item-data.dto.d.ts +2 -2
- package/dist/dtos/invoice/requests/base-invoice-request.dto.d.ts +30 -0
- package/dist/dtos/invoice/requests/base-invoice-request.dto.js +108 -0
- package/dist/dtos/invoice/requests/credit-note-request.dto.d.ts +2 -2
- package/dist/dtos/invoice/requests/credit-note-request.dto.js +2 -2
- package/dist/dtos/invoice/requests/invoice-request.dto.d.ts +2 -2
- package/dist/dtos/invoice/requests/invoice-request.dto.js +2 -2
- package/dist/dtos/invoice/requests/proforma-invoice-request.dto.d.ts +2 -19
- package/dist/dtos/invoice/requests/proforma-invoice-request.dto.js +2 -95
- package/dist/dtos/invoice/responses/credit-note-response.dto.d.ts +1 -1
- package/dist/dtos/invoice/responses/invoice-response.dto.d.ts +1 -1
- package/dist/dtos/invoice/responses/tax-details-response.dto.js +1 -1
- package/dist/dtos/invoice-contact-data.dto.d.ts +2 -2
- package/dist/dtos/invoice-contact-data.dto.js +5 -5
- package/dist/dtos/menu.dto.js +8 -4
- package/dist/dtos/notification/responses/notification-send-response.dto.d.ts +1 -1
- package/dist/dtos/notification/sender/sender-sms.dto.js +1 -1
- package/dist/dtos/product/product-info.dto.js +11 -5
- package/dist/dtos/product/product-item-data.dto.d.ts +2 -2
- package/dist/dtos/product/requests/product-create-request.dto.js +1 -1
- package/dist/dtos/product/requests/product-delete-request.dto.js +3 -3
- package/dist/dtos/product/requests/product-downgradable-request.dto.js +1 -1
- package/dist/dtos/product/requests/product-downgrade-request.dto.js +1 -1
- package/dist/dtos/product/requests/product-downgradeable-request.dto.d.ts +18 -0
- package/dist/dtos/product/requests/product-downgradeable-request.dto.js +37 -0
- package/dist/dtos/product/requests/product-renew-request.dto.js +1 -1
- package/dist/dtos/product/requests/product-suspend-request.dto.js +1 -1
- package/dist/dtos/product/requests/product-unsuspend-request.dto.js +1 -1
- package/dist/dtos/product/requests/product-upgradable-request.dto.js +1 -1
- package/dist/dtos/product/requests/product-upgrade-request.dto.js +1 -1
- package/dist/dtos/product/requests/product-upgradeable-request.dto.d.ts +18 -0
- package/dist/dtos/product/requests/product-upgradeable-request.dto.js +37 -0
- package/dist/dtos/product/responses/product-downgradeable-response.dto.d.ts +22 -0
- package/dist/dtos/product/responses/product-downgradeable-response.dto.js +11 -0
- package/dist/dtos/product/responses/product-info-response.dto.js +1 -1
- package/dist/dtos/product/responses/product-upgradeable-response.dto.d.ts +22 -0
- package/dist/dtos/product/responses/product-upgradeable-response.dto.js +11 -0
- package/dist/dtos/responses/validate-attributes-response.dto.d.ts +2 -2
- package/dist/dtos/tab.dto.js +2 -2
- package/dist/dtos/tax-manager/tax-details-request.dto.d.ts +31 -0
- package/dist/dtos/tax-manager/tax-details-request.dto.js +84 -0
- package/dist/dtos/unit.dto.js +3 -3
- package/dist/enums/country.enum.d.ts +1 -1
- package/dist/enums/country.enum.js +312 -78
- package/dist/enums/currency.enum.d.ts +43 -0
- package/dist/enums/currency.enum.js +47 -0
- package/dist/enums/events.enum.d.ts +3 -0
- package/dist/enums/events.enum.js +3 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/openapi/schemas/components.schemas.d.ts +3 -33
- package/dist/openapi/schemas/components.schemas.js +19 -40
- package/dist/validators/action-validator.spec.js +3 -3
- package/dist/validators/addon-field-validator.spec.js +10 -3
- package/dist/validators/admin-panel-more-actions-validator.spec.js +12 -8
- package/dist/validators/admin-panel-more-actions.validator.d.ts +1 -1
- package/dist/validators/admin-panel-tabs-validator.spec.js +74 -10
- package/dist/validators/admin-panel-tabs.validator.d.ts +1 -1
- package/dist/validators/admin-panel-validator.spec.js +164 -32
- package/dist/validators/attachment-validator.spec.js +8 -8
- package/dist/validators/attribute-field-validator.spec.js +18 -7
- package/dist/validators/client-panel-validator.spec.js +57 -9
- package/dist/validators/country-validator.spec.js +7 -7
- package/dist/validators/field-validator.spec.js +35 -10
- package/dist/validators/info-validator.spec.js +10 -10
- package/dist/validators/invoice-contact-data-validator.spec.js +18 -10
- package/dist/validators/invoice-info-validator.spec.js +14 -10
- package/dist/validators/invoice-item-data-validator.spec.js +4 -4
- package/dist/validators/item-data-validator.spec.js +17 -9
- package/dist/validators/menu-with-submenu-validator.spec.js +13 -11
- package/dist/validators/menu-with-url-validator.spec.js +15 -5
- package/dist/validators/notification-info-validator.spec.js +23 -15
- package/dist/validators/product-downgradeable-request-validator.d.ts +8 -0
- package/dist/validators/product-downgradeable-request-validator.js +17 -0
- package/dist/validators/product-info-validator.spec.js +46 -32
- package/dist/validators/product-info.validator.d.ts +1 -1
- package/dist/validators/product-item-data-validator.spec.js +12 -4
- package/dist/validators/product-upgradeable-request-validator.d.ts +8 -0
- package/dist/validators/product-upgradeable-request-validator.js +17 -0
- package/dist/validators/sender-sms-validator.spec.js +5 -2
- package/dist/validators/settings-with-tabs-validator.spec.js +176 -12
- package/dist/validators/settings-with-url-validator.spec.js +89 -11
- package/dist/validators/tab-validator.spec.js +7 -7
- package/dist/validators/tin-validation-details-validator.spec.js +8 -8
- package/dist/validators/transaction-data-validator.spec.js +13 -8
- package/dist/validators/unit-validator.spec.js +13 -4
- package/package.json +1 -1
- package/dist/dtos/info/info-notification.dto.d.ts +0 -5
- package/dist/dtos/info/info-notification.dto.js +0 -7
- package/dist/dtos/info/info.dto.d.ts +0 -196
- package/dist/dtos/info/info.dto.js +0 -278
- package/dist/dtos/notification/notification-request.dto.d.ts +0 -20
- package/dist/dtos/notification/notification-request.dto.js +0 -31
- package/dist/dtos/receiver/receiver-email.dto.d.ts +0 -20
- package/dist/dtos/receiver/receiver-email.dto.js +0 -39
- package/dist/dtos/receiver/receiver-push.dto.d.ts +0 -15
- package/dist/dtos/receiver/receiver-push.dto.js +0 -31
- package/dist/dtos/receiver/receiver-sms.dto.d.ts +0 -11
- package/dist/dtos/receiver/receiver-sms.dto.js +0 -26
- package/dist/dtos/request.dto.d.ts +0 -20
- package/dist/dtos/request.dto.js +0 -31
- package/dist/dtos/sender/sender-email.dto.d.ts +0 -25
- package/dist/dtos/sender/sender-email.dto.js +0 -46
- package/dist/dtos/sender/sender-push.dto.d.ts +0 -31
- package/dist/dtos/sender/sender-push.dto.js +0 -50
- package/dist/dtos/sender/sender-sms.dto.d.ts +0 -15
- package/dist/dtos/sender/sender-sms.dto.js +0 -30
- package/dist/enums/message-type.enum.d.ts +0 -5
- package/dist/enums/message-type.enum.js +0 -9
|
@@ -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:
|
|
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:
|
|
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: {
|
|
92
|
-
|
|
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: {
|
|
105
|
-
|
|
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: [
|
|
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: [
|
|
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
|
|
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 = [
|
|
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
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ValidationError } from 'class-validator';
|
|
2
|
+
/**
|
|
3
|
+
* Validates a product upgradeable request object.
|
|
4
|
+
*
|
|
5
|
+
* @param {Record<string, unknown>} plainObject - The plain object to validate.
|
|
6
|
+
* @returns {Promise<ValidationError[]>} - A promise that resolves with an array of validation errors.
|
|
7
|
+
*/
|
|
8
|
+
export declare const validateProductUpgradeableRequestDto: (plainObject: Record<string, unknown>) => Promise<ValidationError[]>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateProductUpgradeableRequestDto = void 0;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
const class_transformer_1 = require("class-transformer");
|
|
6
|
+
const product_upgradeable_request_dto_1 = require("../dtos/product/requests/product-upgradeable-request.dto");
|
|
7
|
+
/**
|
|
8
|
+
* Validates a product upgradeable request object.
|
|
9
|
+
*
|
|
10
|
+
* @param {Record<string, unknown>} plainObject - The plain object to validate.
|
|
11
|
+
* @returns {Promise<ValidationError[]>} - A promise that resolves with an array of validation errors.
|
|
12
|
+
*/
|
|
13
|
+
const validateProductUpgradeableRequestDto = async (plainObject) => {
|
|
14
|
+
const request = (0, class_transformer_1.plainToInstance)(product_upgradeable_request_dto_1.ProductUpgradeableRequestDto, plainObject);
|
|
15
|
+
return await (0, class_validator_1.validate)(request);
|
|
16
|
+
};
|
|
17
|
+
exports.validateProductUpgradeableRequestDto = validateProductUpgradeableRequestDto;
|
|
@@ -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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
11
|
-
|
|
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
|
-
[
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
[
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
11
|
-
|
|
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
|
-
[
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
[
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
});
|
|
@@ -15,35 +15,35 @@ describe('TabDto Validator', () => {
|
|
|
15
15
|
describe('Missing required fields', () => {
|
|
16
16
|
it('should return errors when all fields are missing', () => {
|
|
17
17
|
const errors = (0, tab_validator_1.validateTabDto)({});
|
|
18
|
-
expect(errors.some(e => e.property === 'label')).toBe(true);
|
|
19
|
-
expect(errors.some(e => e.property === 'url')).toBe(true);
|
|
18
|
+
expect(errors.some((e) => e.property === 'label')).toBe(true);
|
|
19
|
+
expect(errors.some((e) => e.property === 'url')).toBe(true);
|
|
20
20
|
});
|
|
21
21
|
it('should return error when label is missing', () => {
|
|
22
22
|
const dto = { url: 'https://example.com/settings' };
|
|
23
23
|
const errors = (0, tab_validator_1.validateTabDto)(dto);
|
|
24
|
-
expect(errors.some(e => e.property === 'label')).toBe(true);
|
|
24
|
+
expect(errors.some((e) => e.property === 'label')).toBe(true);
|
|
25
25
|
});
|
|
26
26
|
it('should return error when url is missing', () => {
|
|
27
27
|
const dto = { label: 'Settings' };
|
|
28
28
|
const errors = (0, tab_validator_1.validateTabDto)(dto);
|
|
29
|
-
expect(errors.some(e => e.property === 'url')).toBe(true);
|
|
29
|
+
expect(errors.some((e) => e.property === 'url')).toBe(true);
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
describe('Invalid field values', () => {
|
|
33
33
|
it('should return error for empty label', () => {
|
|
34
34
|
const dto = { ...baseValidDto, label: '' };
|
|
35
35
|
const errors = (0, tab_validator_1.validateTabDto)(dto);
|
|
36
|
-
expect(errors.some(e => e.property === 'label')).toBe(true);
|
|
36
|
+
expect(errors.some((e) => e.property === 'label')).toBe(true);
|
|
37
37
|
});
|
|
38
38
|
it('should return error for non-https URL', () => {
|
|
39
39
|
const dto = { ...baseValidDto, url: 'http://example.com/settings' };
|
|
40
40
|
const errors = (0, tab_validator_1.validateTabDto)(dto);
|
|
41
|
-
expect(errors.some(e => e.property === 'url')).toBe(true);
|
|
41
|
+
expect(errors.some((e) => e.property === 'url')).toBe(true);
|
|
42
42
|
});
|
|
43
43
|
it('should return error for invalid URL', () => {
|
|
44
44
|
const dto = { ...baseValidDto, url: 'not-a-url' };
|
|
45
45
|
const errors = (0, tab_validator_1.validateTabDto)(dto);
|
|
46
|
-
expect(errors.some(e => e.property === 'url')).toBe(true);
|
|
46
|
+
expect(errors.some((e) => e.property === 'url')).toBe(true);
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
});
|