@hosterai/types 0.0.17 → 0.0.19
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 +12 -9
- package/dist/decorators/all-or-none-validator.spec.d.ts +1 -0
- package/dist/decorators/all-or-none-validator.spec.js +91 -0
- package/dist/decorators/all-or-none.validator.d.ts +2 -0
- package/dist/decorators/all-or-none.validator.js +71 -0
- package/dist/decorators/at-least-one-non-empty-validator.spec.d.ts +1 -0
- package/dist/decorators/at-least-one-non-empty-validator.spec.js +79 -0
- package/dist/decorators/at-least-one-non-empty.validator.d.ts +2 -0
- package/dist/decorators/at-least-one-non-empty.validator.js +43 -0
- package/dist/decorators/is-of-allowed-types-validator.spec.d.ts +1 -0
- package/dist/decorators/is-of-allowed-types-validator.spec.js +188 -0
- package/dist/decorators/is-of-allowed-types.validator.d.ts +16 -0
- package/dist/decorators/is-of-allowed-types.validator.js +105 -0
- package/dist/decorators/is-one-of-validator.spec.d.ts +1 -0
- package/dist/decorators/is-one-of-validator.spec.js +51 -0
- package/dist/decorators/is-one-of.validator.d.ts +2 -0
- package/dist/decorators/is-one-of.validator.js +19 -0
- package/dist/decorators/is-plain-object-validator.spec.d.ts +1 -0
- package/dist/decorators/is-plain-object-validator.spec.js +46 -0
- package/dist/decorators/is-plain-object.validator.d.ts +2 -0
- package/dist/decorators/is-plain-object.validator.js +30 -0
- package/dist/decorators/is-property-forbidden-validator.spec.d.ts +1 -0
- package/dist/decorators/is-property-forbidden-validator.spec.js +62 -0
- package/dist/decorators/is-property-forbidden.validator.d.ts +2 -0
- package/dist/decorators/is-property-forbidden.validator.js +22 -0
- package/dist/decorators/is-regex-validator.spec.d.ts +1 -0
- package/dist/decorators/is-regex-validator.spec.js +46 -0
- package/dist/decorators/is-regex.validator.d.ts +2 -0
- package/dist/decorators/is-regex.validator.js +32 -0
- package/dist/decorators/min-less-or-equal-validator.spec.d.ts +1 -0
- package/dist/decorators/min-less-or-equal-validator.spec.js +60 -0
- package/dist/decorators/min-less-or-equal.validator.d.ts +2 -0
- package/dist/decorators/min-less-or-equal.validator.js +58 -0
- package/dist/decorators/unique-field-in-array-validator.spec.d.ts +1 -0
- package/dist/decorators/unique-field-in-array-validator.spec.js +39 -0
- package/dist/decorators/unique-field-in-array.validator.d.ts +6 -0
- package/dist/decorators/unique-field-in-array.validator.js +47 -0
- package/dist/dtos/action.dto.js +25 -1
- package/dist/dtos/admin-panel.dto.d.ts +38 -0
- package/dist/dtos/admin-panel.dto.js +241 -0
- package/dist/dtos/client-panel.dto.d.ts +24 -0
- package/dist/dtos/client-panel.dto.js +105 -0
- package/dist/dtos/company-data.dto.js +1 -1
- package/dist/dtos/field-option.dto.js +16 -0
- package/dist/dtos/field.dto.d.ts +2 -0
- package/dist/dtos/field.dto.js +112 -2
- package/dist/dtos/info.dto.d.ts +4 -79
- package/dist/dtos/info.dto.js +141 -0
- package/dist/dtos/menu.dto.d.ts +5 -6
- package/dist/dtos/menu.dto.js +108 -0
- package/dist/dtos/multilang-text.dto.js +1 -1
- package/dist/dtos/notification/notification-info.dto.js +42 -0
- package/dist/dtos/product/product-info.dto.js +73 -0
- 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-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-upgradeable-response.dto.d.ts +22 -0
- package/dist/dtos/product/responses/product-upgradeable-response.dto.js +11 -0
- package/dist/dtos/settings.dto.d.ts +14 -0
- package/dist/dtos/settings.dto.js +81 -0
- package/dist/dtos/tab.dto.js +32 -0
- package/dist/dtos/unit.dto.js +47 -0
- package/dist/index.d.ts +23 -7
- package/dist/index.js +26 -7
- package/dist/openapi/schemas/components.schemas.d.ts +991 -0
- package/dist/openapi/schemas/components.schemas.js +2552 -0
- package/dist/transformers/menu.transformer.d.ts +2 -0
- package/dist/transformers/menu.transformer.js +16 -0
- package/dist/transformers/settings.transformer.d.ts +1 -0
- package/dist/transformers/settings.transformer.js +15 -0
- package/dist/validators/action-validator.spec.d.ts +1 -0
- package/dist/validators/action-validator.spec.js +67 -0
- package/dist/validators/admin-panel-more-actions-validator.spec.d.ts +1 -0
- package/dist/validators/admin-panel-more-actions-validator.spec.js +129 -0
- package/dist/validators/admin-panel-more-actions.validator.d.ts +2 -0
- package/dist/validators/admin-panel-more-actions.validator.js +11 -0
- package/dist/validators/admin-panel-tabs-validator.spec.d.ts +1 -0
- package/dist/validators/admin-panel-tabs-validator.spec.js +39 -0
- package/dist/validators/admin-panel-tabs.validator.d.ts +2 -0
- package/dist/validators/admin-panel-tabs.validator.js +11 -0
- package/dist/validators/admin-panel-validator.spec.d.ts +1 -0
- package/dist/validators/admin-panel-validator.spec.js +112 -0
- package/dist/validators/admin-panel.validator.d.ts +2 -0
- package/dist/validators/admin-panel.validator.js +14 -0
- package/dist/validators/client-data-validator.spec.d.ts +1 -0
- package/dist/validators/client-data-validator.spec.js +35 -0
- package/dist/validators/client-panel-validator.spec.d.ts +1 -0
- package/dist/validators/client-panel-validator.spec.js +51 -0
- package/dist/validators/client-panel.validator.d.ts +2 -0
- package/dist/validators/client-panel.validator.js +14 -0
- package/dist/validators/company-data-validator.spec.d.ts +1 -0
- package/dist/validators/company-data-validator.spec.js +73 -0
- package/dist/validators/field-option-validator.spec.d.ts +1 -0
- package/dist/validators/field-option-validator.spec.js +28 -0
- package/dist/validators/field-option.validator.d.ts +2 -0
- package/dist/validators/field-option.validator.js +11 -0
- package/dist/validators/field-validator.spec.d.ts +1 -0
- package/dist/validators/field-validator.spec.js +102 -0
- package/dist/validators/jwt-validator.spec.d.ts +2 -0
- package/dist/validators/jwt-validator.spec.js +43 -0
- package/dist/validators/menu-with-submenu-validator.spec.d.ts +1 -0
- package/dist/validators/menu-with-submenu-validator.spec.js +52 -0
- package/dist/validators/menu-with-submenu.validator.d.ts +2 -0
- package/dist/validators/menu-with-submenu.validator.js +11 -0
- package/dist/validators/menu-with-url-validator.spec.d.ts +1 -0
- package/dist/validators/menu-with-url-validator.spec.js +70 -0
- package/dist/validators/menu-with-url.validator.d.ts +2 -0
- package/dist/validators/menu-with-url.validator.js +11 -0
- package/dist/validators/multilang-text-validator.spec.d.ts +1 -0
- package/dist/validators/multilang-text-validator.spec.js +33 -0
- package/dist/validators/notification-info-validator.spec.d.ts +1 -0
- package/dist/validators/notification-info-validator.spec.js +82 -0
- package/dist/validators/notification-info.validator.d.ts +7 -0
- package/dist/validators/notification-info.validator.js +16 -0
- package/dist/validators/notification-request-validator.spec.d.ts +1 -0
- package/dist/validators/notification-request-validator.spec.js +115 -0
- package/dist/validators/product-create-request-validator.spec.d.ts +2 -0
- package/dist/validators/product-create-request-validator.spec.js +44 -0
- package/dist/validators/product-delete-request-validator.spec.d.ts +1 -0
- package/dist/validators/product-delete-request-validator.spec.js +40 -0
- package/dist/validators/product-downgradable-request-validator.spec.d.ts +1 -0
- package/dist/validators/product-downgradable-request-validator.spec.js +40 -0
- package/dist/validators/product-downgrade-request-validator.spec.d.ts +1 -0
- package/dist/validators/product-downgrade-request-validator.spec.js +46 -0
- 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.d.ts +1 -0
- package/dist/validators/product-info-validator.spec.js +259 -0
- package/dist/validators/product-info.validator.d.ts +2 -0
- package/dist/validators/product-info.validator.js +11 -0
- package/dist/validators/product-renew-request-validator.spec.d.ts +1 -0
- package/dist/validators/product-renew-request-validator.spec.js +40 -0
- package/dist/validators/product-suspend-request-validator.spec.d.ts +1 -0
- package/dist/validators/product-suspend-request-validator.spec.js +40 -0
- package/dist/validators/product-unsuspend-request-validator.spec.d.ts +1 -0
- package/dist/validators/product-unsuspend-request-validator.spec.js +40 -0
- package/dist/validators/product-upgradable-request-validator.spec.d.ts +1 -0
- package/dist/validators/product-upgradable-request-validator.spec.js +40 -0
- package/dist/validators/product-upgrade-request-validator.spec.d.ts +1 -0
- package/dist/validators/product-upgrade-request-validator.spec.js +46 -0
- package/dist/validators/product-upgradeable-request-validator.d.ts +8 -0
- package/dist/validators/product-upgradeable-request-validator.js +17 -0
- package/dist/validators/product-validate-attributes-request-validator.spec.d.ts +1 -0
- package/dist/validators/product-validate-attributes-request-validator.spec.js +27 -0
- package/dist/validators/receiver-email-validator.spec.d.ts +1 -0
- package/dist/validators/receiver-email-validator.spec.js +32 -0
- package/dist/validators/receiver-push-validator.spec.d.ts +1 -0
- package/dist/validators/receiver-push-validator.spec.js +31 -0
- package/dist/validators/receiver-sms-validator.spec.d.ts +1 -0
- package/dist/validators/receiver-sms-validator.spec.js +29 -0
- package/dist/validators/sender-email-validator.spec.d.ts +2 -0
- package/dist/validators/sender-email-validator.spec.js +62 -0
- package/dist/validators/sender-push-validator.spec.d.ts +1 -0
- package/dist/validators/sender-push-validator.spec.js +38 -0
- package/dist/validators/sender-sms-validator.spec.d.ts +1 -0
- package/dist/validators/sender-sms-validator.spec.js +22 -0
- package/dist/validators/settings-with-tabs-validator.spec.d.ts +1 -0
- package/dist/validators/settings-with-tabs-validator.spec.js +29 -0
- package/dist/validators/settings-with-tabs.validator.d.ts +2 -0
- package/dist/validators/settings-with-tabs.validator.js +11 -0
- package/dist/validators/settings-with-url-validator.spec.d.ts +1 -0
- package/dist/validators/settings-with-url-validator.spec.js +29 -0
- package/dist/validators/settings-with-url.validator.d.ts +2 -0
- package/dist/validators/settings-with-url.validator.js +11 -0
- package/dist/validators/unit-validator.spec.d.ts +1 -0
- package/dist/validators/unit-validator.spec.js +27 -0
- package/dist/validators/unit.validator.d.ts +2 -0
- package/dist/validators/unit.validator.js +11 -0
- package/package.json +4 -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
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const product_create_request_validator_1 = require("./product-create-request-validator");
|
|
6
|
+
const country_enum_1 = require("../enums/country.enum");
|
|
7
|
+
const duration_enum_1 = require("../enums/duration.enum");
|
|
8
|
+
describe('validateProductCreateRequestDto', () => {
|
|
9
|
+
it('should return no errors for a valid request', async () => {
|
|
10
|
+
const validRequest = {
|
|
11
|
+
clientData: {
|
|
12
|
+
email: 'test@example.com',
|
|
13
|
+
firstName: 'John',
|
|
14
|
+
lastName: 'Doe',
|
|
15
|
+
telephone: '+14155552671',
|
|
16
|
+
address1: '123 Main St',
|
|
17
|
+
postcode: '12345',
|
|
18
|
+
city: 'Anytown',
|
|
19
|
+
country: country_enum_1.CountryEnum.UNITED_STATES,
|
|
20
|
+
},
|
|
21
|
+
itemData: {
|
|
22
|
+
productAttributes: { key: 'value' },
|
|
23
|
+
itemAttributes: { key: 'value' },
|
|
24
|
+
duration: duration_enum_1.DurationEnum.ONE_MONTH,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const errors = await (0, product_create_request_validator_1.validateProductCreateRequestDto)(validRequest);
|
|
28
|
+
expect(errors.length).toBe(0);
|
|
29
|
+
});
|
|
30
|
+
it('should return errors for an invalid request', async () => {
|
|
31
|
+
const invalidRequest = {
|
|
32
|
+
clientData: {
|
|
33
|
+
email: 'not-an-email',
|
|
34
|
+
},
|
|
35
|
+
itemData: {
|
|
36
|
+
productAttributes: {},
|
|
37
|
+
itemAttributes: {},
|
|
38
|
+
duration: 'invalid-duration',
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
const errors = await (0, product_create_request_validator_1.validateProductCreateRequestDto)(invalidRequest);
|
|
42
|
+
expect(errors.length).toBeGreaterThan(0);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
const product_delete_request_validator_1 = require("./product-delete-request-validator");
|
|
5
|
+
const country_enum_1 = require("../enums/country.enum");
|
|
6
|
+
const duration_enum_1 = require("../enums/duration.enum");
|
|
7
|
+
describe('validateProductDeleteRequestDto', () => {
|
|
8
|
+
it('should return no errors for a valid request', async () => {
|
|
9
|
+
const validRequest = {
|
|
10
|
+
clientData: {
|
|
11
|
+
email: 'test@example.com',
|
|
12
|
+
firstName: 'John',
|
|
13
|
+
lastName: 'Doe',
|
|
14
|
+
telephone: '+14155552671',
|
|
15
|
+
address1: '123 Main St',
|
|
16
|
+
postcode: '12345',
|
|
17
|
+
city: 'Anytown',
|
|
18
|
+
country: country_enum_1.CountryEnum.UNITED_STATES,
|
|
19
|
+
},
|
|
20
|
+
itemData: {
|
|
21
|
+
itemId: 'item-123',
|
|
22
|
+
productAttributes: { key: 'value' },
|
|
23
|
+
itemAttributes: { key: 'value' },
|
|
24
|
+
duration: duration_enum_1.DurationEnum.ONE_MONTH,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const errors = await (0, product_delete_request_validator_1.validateProductDeleteRequestDto)(validRequest);
|
|
28
|
+
expect(errors.length).toBe(0);
|
|
29
|
+
});
|
|
30
|
+
it('should return errors for an invalid request', async () => {
|
|
31
|
+
const invalidRequest = {
|
|
32
|
+
clientData: {
|
|
33
|
+
email: 'not-an-email',
|
|
34
|
+
},
|
|
35
|
+
itemData: {},
|
|
36
|
+
};
|
|
37
|
+
const errors = await (0, product_delete_request_validator_1.validateProductDeleteRequestDto)(invalidRequest);
|
|
38
|
+
expect(errors.length).toBeGreaterThan(0);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
const product_downgradable_request_validator_1 = require("./product-downgradable-request-validator");
|
|
5
|
+
const country_enum_1 = require("../enums/country.enum");
|
|
6
|
+
const duration_enum_1 = require("../enums/duration.enum");
|
|
7
|
+
describe('validateProductDowngradableRequestDto', () => {
|
|
8
|
+
it('should return no errors for a valid request', async () => {
|
|
9
|
+
const validRequest = {
|
|
10
|
+
clientData: {
|
|
11
|
+
email: 'test@example.com',
|
|
12
|
+
firstName: 'John',
|
|
13
|
+
lastName: 'Doe',
|
|
14
|
+
telephone: '+14155552671',
|
|
15
|
+
address1: '123 Main St',
|
|
16
|
+
postcode: '12345',
|
|
17
|
+
city: 'Anytown',
|
|
18
|
+
country: country_enum_1.CountryEnum.UNITED_STATES,
|
|
19
|
+
},
|
|
20
|
+
itemData: {
|
|
21
|
+
itemId: 'item-123',
|
|
22
|
+
productAttributes: { key: 'value' },
|
|
23
|
+
itemAttributes: { key: 'value' },
|
|
24
|
+
duration: duration_enum_1.DurationEnum.ONE_MONTH,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const errors = await (0, product_downgradable_request_validator_1.validateProductDowngradableRequestDto)(validRequest);
|
|
28
|
+
expect(errors.length).toBe(0);
|
|
29
|
+
});
|
|
30
|
+
it('should return errors for an invalid request', async () => {
|
|
31
|
+
const invalidRequest = {
|
|
32
|
+
clientData: {
|
|
33
|
+
email: 'not-an-email',
|
|
34
|
+
},
|
|
35
|
+
itemData: {},
|
|
36
|
+
};
|
|
37
|
+
const errors = await (0, product_downgradable_request_validator_1.validateProductDowngradableRequestDto)(invalidRequest);
|
|
38
|
+
expect(errors.length).toBeGreaterThan(0);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
const product_downgrade_request_validator_1 = require("./product-downgrade-request-validator");
|
|
5
|
+
const country_enum_1 = require("../enums/country.enum");
|
|
6
|
+
const duration_enum_1 = require("../enums/duration.enum");
|
|
7
|
+
describe('validateProductDowngradeRequestDto', () => {
|
|
8
|
+
it('should return no errors for a valid request', async () => {
|
|
9
|
+
const validRequest = {
|
|
10
|
+
clientData: {
|
|
11
|
+
email: 'test@example.com',
|
|
12
|
+
firstName: 'John',
|
|
13
|
+
lastName: 'Doe',
|
|
14
|
+
telephone: '+14155552671',
|
|
15
|
+
address1: '123 Main St',
|
|
16
|
+
postcode: '12345',
|
|
17
|
+
city: 'Anytown',
|
|
18
|
+
country: country_enum_1.CountryEnum.UNITED_STATES,
|
|
19
|
+
},
|
|
20
|
+
itemData: {
|
|
21
|
+
itemId: 'item-123',
|
|
22
|
+
productAttributes: { key: 'value' },
|
|
23
|
+
itemAttributes: { key: 'value' },
|
|
24
|
+
duration: duration_enum_1.DurationEnum.ONE_MONTH,
|
|
25
|
+
},
|
|
26
|
+
previousItemData: {
|
|
27
|
+
itemId: 'item-123',
|
|
28
|
+
productAttributes: { key: 'value' },
|
|
29
|
+
itemAttributes: { key: 'value' },
|
|
30
|
+
duration: duration_enum_1.DurationEnum.ONE_MONTH,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
const errors = await (0, product_downgrade_request_validator_1.validateProductDowngradeRequestDto)(validRequest);
|
|
34
|
+
expect(errors.length).toBe(0);
|
|
35
|
+
});
|
|
36
|
+
it('should return errors for an invalid request', async () => {
|
|
37
|
+
const invalidRequest = {
|
|
38
|
+
clientData: {
|
|
39
|
+
email: 'not-an-email',
|
|
40
|
+
},
|
|
41
|
+
itemData: {},
|
|
42
|
+
};
|
|
43
|
+
const errors = await (0, product_downgrade_request_validator_1.validateProductDowngradeRequestDto)(invalidRequest);
|
|
44
|
+
expect(errors.length).toBeGreaterThan(0);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ValidationError } from 'class-validator';
|
|
2
|
+
/**
|
|
3
|
+
* Validates a product downgradable request object.
|
|
4
|
+
*
|
|
5
|
+
* @param {Record<string, unknown>} plainObject - The plain object to validate.
|
|
6
|
+
* @returns {Promise<ValidationError[]>} - A promise that resolves with an array of validation errors.
|
|
7
|
+
*/
|
|
8
|
+
export declare const validateProductDowngradableRequestDto: (plainObject: Record<string, unknown>) => Promise<ValidationError[]>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateProductDowngradableRequestDto = void 0;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
const class_transformer_1 = require("class-transformer");
|
|
6
|
+
const product_downgradable_request_dto_1 = require("../dtos/product/requests/product-downgradable-request.dto");
|
|
7
|
+
/**
|
|
8
|
+
* Validates a product downgradable request object.
|
|
9
|
+
*
|
|
10
|
+
* @param {Record<string, unknown>} plainObject - The plain object to validate.
|
|
11
|
+
* @returns {Promise<ValidationError[]>} - A promise that resolves with an array of validation errors.
|
|
12
|
+
*/
|
|
13
|
+
const validateProductDowngradableRequestDto = async (plainObject) => {
|
|
14
|
+
const request = (0, class_transformer_1.plainToInstance)(product_downgradable_request_dto_1.ProductDowngradableRequestDto, plainObject);
|
|
15
|
+
return await (0, class_validator_1.validate)(request);
|
|
16
|
+
};
|
|
17
|
+
exports.validateProductDowngradableRequestDto = validateProductDowngradableRequestDto;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
// import { ProductInfoDto } from '../dtos/product/product-info.dto';
|
|
5
|
+
const actions_enum_1 = require("../enums/actions.enum");
|
|
6
|
+
const language_enum_1 = require("../enums/language.enum");
|
|
7
|
+
const field_type_enum_1 = require("../enums/field-type.enum");
|
|
8
|
+
const product_info_validator_1 = require("./product-info.validator");
|
|
9
|
+
describe('ProductInfoDto Validator', () => {
|
|
10
|
+
const field = {
|
|
11
|
+
id: 'field',
|
|
12
|
+
label: [{ language: language_enum_1.LanguageEnum.EN, text: "label" }],
|
|
13
|
+
value: 'string',
|
|
14
|
+
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
15
|
+
required: false,
|
|
16
|
+
disabled: false,
|
|
17
|
+
hidden: false,
|
|
18
|
+
upgradable: false
|
|
19
|
+
};
|
|
20
|
+
const invalidField = {
|
|
21
|
+
id: 'field',
|
|
22
|
+
label: [{ language: language_enum_1.LanguageEnum.EN, text: "label" }],
|
|
23
|
+
value: 'string',
|
|
24
|
+
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
25
|
+
disabled: false,
|
|
26
|
+
upgradable: false
|
|
27
|
+
};
|
|
28
|
+
const testCases = [
|
|
29
|
+
{
|
|
30
|
+
description: 'should return no errors for valid DTO',
|
|
31
|
+
dto: {
|
|
32
|
+
title: 'Test',
|
|
33
|
+
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
34
|
+
supportedLanguages: [language_enum_1.LanguageEnum.EN],
|
|
35
|
+
productAttributes: [field],
|
|
36
|
+
itemAttributes: [field]
|
|
37
|
+
},
|
|
38
|
+
expectedErrorsLength: 0
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
description: 'should return error for invalid required and hidden',
|
|
42
|
+
dto: {
|
|
43
|
+
title: 'Test',
|
|
44
|
+
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
45
|
+
supportedLanguages: [language_enum_1.LanguageEnum.EN],
|
|
46
|
+
itemAttributes: [invalidField]
|
|
47
|
+
},
|
|
48
|
+
expectedErrorsLength: 1
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
description: 'should return error for invalid title',
|
|
52
|
+
dto: {
|
|
53
|
+
title: '',
|
|
54
|
+
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
55
|
+
supportedLanguages: [language_enum_1.LanguageEnum.EN],
|
|
56
|
+
productAttributes: [field],
|
|
57
|
+
itemAttributes: [field]
|
|
58
|
+
},
|
|
59
|
+
expectedErrorsLength: 1
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
description: 'should return error for unsupported action',
|
|
63
|
+
dto: {
|
|
64
|
+
title: 'Test',
|
|
65
|
+
supportedActions: ['update'],
|
|
66
|
+
supportedLanguages: [language_enum_1.LanguageEnum.EN],
|
|
67
|
+
productAttributes: [field],
|
|
68
|
+
itemAttributes: [field]
|
|
69
|
+
},
|
|
70
|
+
expectedErrorsLength: 1
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
description: 'should return error for unsupported language',
|
|
74
|
+
dto: {
|
|
75
|
+
title: 'Test',
|
|
76
|
+
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
77
|
+
supportedLanguages: [],
|
|
78
|
+
productAttributes: [field],
|
|
79
|
+
itemAttributes: [field]
|
|
80
|
+
},
|
|
81
|
+
expectedErrorsLength: 1
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
description: 'should return no errors for valid DTO with adminPanel and clientPanel',
|
|
85
|
+
dto: {
|
|
86
|
+
title: 'Test',
|
|
87
|
+
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
88
|
+
supportedLanguages: [language_enum_1.LanguageEnum.EN],
|
|
89
|
+
productAttributes: [field],
|
|
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' }] } }
|
|
93
|
+
},
|
|
94
|
+
expectedErrorsLength: 0
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
description: 'should return error for invalid DTO with adminPanel and clientPanel',
|
|
98
|
+
dto: {
|
|
99
|
+
title: '',
|
|
100
|
+
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
101
|
+
supportedLanguages: [language_enum_1.LanguageEnum.EN],
|
|
102
|
+
productAttributes: [field],
|
|
103
|
+
itemAttributes: [field],
|
|
104
|
+
adminPanel: { /* invalid admin panel data */},
|
|
105
|
+
clientPanel: { /* invalid client panel data */}
|
|
106
|
+
},
|
|
107
|
+
expectedErrorsLength: 3
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
description: 'should return no errors for valid DTO with payPerUseUnits',
|
|
111
|
+
dto: {
|
|
112
|
+
title: 'Test',
|
|
113
|
+
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
114
|
+
supportedLanguages: [language_enum_1.LanguageEnum.EN],
|
|
115
|
+
productAttributes: [field],
|
|
116
|
+
itemAttributes: [field],
|
|
117
|
+
payPerUseUnits: [{ id: "ram", unitDescription: "MB", intervalDescription: "month" }]
|
|
118
|
+
},
|
|
119
|
+
expectedErrorsLength: 0
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
description: 'should return error for invalid DTO with payPerUseUnits',
|
|
123
|
+
dto: {
|
|
124
|
+
title: 'Test',
|
|
125
|
+
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
126
|
+
supportedLanguages: [language_enum_1.LanguageEnum.EN],
|
|
127
|
+
productAttributes: [field],
|
|
128
|
+
itemAttributes: [field],
|
|
129
|
+
payPerUseUnits: [{ id: "", unitDescription: "", intervalDescription: "" }]
|
|
130
|
+
},
|
|
131
|
+
expectedErrorsLength: 1
|
|
132
|
+
}
|
|
133
|
+
];
|
|
134
|
+
testCases.forEach(({ description, dto, expectedErrorsLength }) => {
|
|
135
|
+
it(description, () => {
|
|
136
|
+
const errors = (0, product_info_validator_1.validateProductInfoDto)(dto);
|
|
137
|
+
expect(errors.length).toBe(expectedErrorsLength);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
const validationErrorTestCases = [
|
|
141
|
+
{
|
|
142
|
+
description: 'should return ValidationError for missing title',
|
|
143
|
+
dto: {
|
|
144
|
+
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
145
|
+
supportedLanguages: [language_enum_1.LanguageEnum.EN],
|
|
146
|
+
productAttributes: [field],
|
|
147
|
+
itemAttributes: [field]
|
|
148
|
+
},
|
|
149
|
+
expectedErrors: ['title']
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
description: 'should return ValidationError for unsupported action',
|
|
153
|
+
dto: {
|
|
154
|
+
title: 'Test',
|
|
155
|
+
supportedActions: ['update'],
|
|
156
|
+
supportedLanguages: [language_enum_1.LanguageEnum.EN],
|
|
157
|
+
productAttributes: [field],
|
|
158
|
+
itemAttributes: [field]
|
|
159
|
+
},
|
|
160
|
+
expectedErrors: ['supportedActions']
|
|
161
|
+
}
|
|
162
|
+
];
|
|
163
|
+
validationErrorTestCases.forEach(({ description, dto, expectedErrors }) => {
|
|
164
|
+
it(description, async () => {
|
|
165
|
+
const errors = await (0, product_info_validator_1.validateProductInfoDto)(dto);
|
|
166
|
+
const errorProperties = errors.map(error => error.property);
|
|
167
|
+
expectedErrors.forEach(expectedError => {
|
|
168
|
+
expect(errorProperties).toContain(expectedError);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
describe('FieldDto class-level constraints inside ProductInfoDto', () => {
|
|
173
|
+
it('fails when a FieldDto has only reapetableMin (AllOrNone)', () => {
|
|
174
|
+
const fieldWithOnlyMin = {
|
|
175
|
+
id: 'f1',
|
|
176
|
+
label: [{ language: language_enum_1.LanguageEnum.EN, text: 'label' }],
|
|
177
|
+
value: 'v',
|
|
178
|
+
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
179
|
+
required: false,
|
|
180
|
+
disabled: false,
|
|
181
|
+
hidden: false,
|
|
182
|
+
upgradable: false,
|
|
183
|
+
reapetableMin: 1,
|
|
184
|
+
};
|
|
185
|
+
const dto = {
|
|
186
|
+
title: 'Test',
|
|
187
|
+
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
188
|
+
supportedLanguages: [language_enum_1.LanguageEnum.EN],
|
|
189
|
+
productAttributes: [fieldWithOnlyMin],
|
|
190
|
+
};
|
|
191
|
+
const errors = (0, product_info_validator_1.validateProductInfoDto)(dto);
|
|
192
|
+
expect(errors.length).toBeGreaterThan(0);
|
|
193
|
+
});
|
|
194
|
+
it('fails when a FieldDto has only reapetableMax (AllOrNone)', () => {
|
|
195
|
+
const fieldWithOnlyMax = {
|
|
196
|
+
id: 'f2',
|
|
197
|
+
label: [{ language: language_enum_1.LanguageEnum.EN, text: 'label' }],
|
|
198
|
+
value: 'v',
|
|
199
|
+
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
200
|
+
required: false,
|
|
201
|
+
disabled: false,
|
|
202
|
+
hidden: false,
|
|
203
|
+
upgradable: false,
|
|
204
|
+
reapetableMax: 2,
|
|
205
|
+
};
|
|
206
|
+
const dto = {
|
|
207
|
+
title: 'Test',
|
|
208
|
+
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
209
|
+
supportedLanguages: [language_enum_1.LanguageEnum.EN],
|
|
210
|
+
itemAttributes: [fieldWithOnlyMax],
|
|
211
|
+
};
|
|
212
|
+
const errors = (0, product_info_validator_1.validateProductInfoDto)(dto);
|
|
213
|
+
expect(errors.length).toBeGreaterThan(0);
|
|
214
|
+
});
|
|
215
|
+
it('passes when a FieldDto has both min and max with min <= max', () => {
|
|
216
|
+
const fieldOk = {
|
|
217
|
+
id: 'f3',
|
|
218
|
+
label: [{ language: language_enum_1.LanguageEnum.EN, text: 'label' }],
|
|
219
|
+
value: 'v',
|
|
220
|
+
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
221
|
+
required: false,
|
|
222
|
+
disabled: false,
|
|
223
|
+
hidden: false,
|
|
224
|
+
upgradable: false,
|
|
225
|
+
reapetableMin: 1,
|
|
226
|
+
reapetableMax: 2,
|
|
227
|
+
};
|
|
228
|
+
const dto = {
|
|
229
|
+
title: 'Test',
|
|
230
|
+
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
231
|
+
supportedLanguages: [language_enum_1.LanguageEnum.EN],
|
|
232
|
+
productAttributes: [fieldOk],
|
|
233
|
+
};
|
|
234
|
+
expect((0, product_info_validator_1.validateProductInfoDto)(dto)).toHaveLength(0);
|
|
235
|
+
});
|
|
236
|
+
it('fails when a FieldDto has both min and max with min > max (Min<=Max)', () => {
|
|
237
|
+
const fieldBad = {
|
|
238
|
+
id: 'f4',
|
|
239
|
+
label: [{ language: language_enum_1.LanguageEnum.EN, text: 'label' }],
|
|
240
|
+
value: 'v',
|
|
241
|
+
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
242
|
+
required: false,
|
|
243
|
+
disabled: false,
|
|
244
|
+
hidden: false,
|
|
245
|
+
upgradable: false,
|
|
246
|
+
reapetableMin: 5,
|
|
247
|
+
reapetableMax: 2,
|
|
248
|
+
};
|
|
249
|
+
const dto = {
|
|
250
|
+
title: 'Test',
|
|
251
|
+
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
252
|
+
supportedLanguages: [language_enum_1.LanguageEnum.EN],
|
|
253
|
+
itemAttributes: [fieldBad],
|
|
254
|
+
};
|
|
255
|
+
const errors = (0, product_info_validator_1.validateProductInfoDto)(dto);
|
|
256
|
+
expect(errors.length).toBeGreaterThan(0);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateProductInfoDto = validateProductInfoDto;
|
|
4
|
+
const class_transformer_1 = require("class-transformer");
|
|
5
|
+
const class_validator_1 = require("class-validator");
|
|
6
|
+
const product_info_dto_1 = require("../dtos/product/product-info.dto");
|
|
7
|
+
function validateProductInfoDto(data) {
|
|
8
|
+
const dto = (0, class_transformer_1.plainToInstance)(product_info_dto_1.ProductInfoDto, data);
|
|
9
|
+
const errors = (0, class_validator_1.validateSync)(dto);
|
|
10
|
+
return errors;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
const product_renew_request_validator_1 = require("./product-renew-request-validator");
|
|
5
|
+
const country_enum_1 = require("../enums/country.enum");
|
|
6
|
+
const duration_enum_1 = require("../enums/duration.enum");
|
|
7
|
+
describe('validateProductRenewRequestDto', () => {
|
|
8
|
+
it('should return no errors for a valid request', async () => {
|
|
9
|
+
const validRequest = {
|
|
10
|
+
clientData: {
|
|
11
|
+
email: 'test@example.com',
|
|
12
|
+
firstName: 'John',
|
|
13
|
+
lastName: 'Doe',
|
|
14
|
+
telephone: '+14155552671',
|
|
15
|
+
address1: '123 Main St',
|
|
16
|
+
postcode: '12345',
|
|
17
|
+
city: 'Anytown',
|
|
18
|
+
country: country_enum_1.CountryEnum.UNITED_STATES,
|
|
19
|
+
},
|
|
20
|
+
itemData: {
|
|
21
|
+
itemId: 'item-123',
|
|
22
|
+
productAttributes: { key: 'value' },
|
|
23
|
+
itemAttributes: { key: 'value' },
|
|
24
|
+
duration: duration_enum_1.DurationEnum.ONE_MONTH,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const errors = await (0, product_renew_request_validator_1.validateProductRenewRequestDto)(validRequest);
|
|
28
|
+
expect(errors.length).toBe(0);
|
|
29
|
+
});
|
|
30
|
+
it('should return errors for an invalid request', async () => {
|
|
31
|
+
const invalidRequest = {
|
|
32
|
+
clientData: {
|
|
33
|
+
email: 'not-an-email',
|
|
34
|
+
},
|
|
35
|
+
itemData: {},
|
|
36
|
+
};
|
|
37
|
+
const errors = await (0, product_renew_request_validator_1.validateProductRenewRequestDto)(invalidRequest);
|
|
38
|
+
expect(errors.length).toBeGreaterThan(0);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
const product_suspend_request_validator_1 = require("./product-suspend-request-validator");
|
|
5
|
+
const country_enum_1 = require("../enums/country.enum");
|
|
6
|
+
const duration_enum_1 = require("../enums/duration.enum");
|
|
7
|
+
describe('validateProductSuspendRequestDto', () => {
|
|
8
|
+
it('should return no errors for a valid request', async () => {
|
|
9
|
+
const validRequest = {
|
|
10
|
+
clientData: {
|
|
11
|
+
email: 'test@example.com',
|
|
12
|
+
firstName: 'John',
|
|
13
|
+
lastName: 'Doe',
|
|
14
|
+
telephone: '+14155552671',
|
|
15
|
+
address1: '123 Main St',
|
|
16
|
+
postcode: '12345',
|
|
17
|
+
city: 'Anytown',
|
|
18
|
+
country: country_enum_1.CountryEnum.UNITED_STATES,
|
|
19
|
+
},
|
|
20
|
+
itemData: {
|
|
21
|
+
itemId: 'item-123',
|
|
22
|
+
productAttributes: { key: 'value' },
|
|
23
|
+
itemAttributes: { key: 'value' },
|
|
24
|
+
duration: duration_enum_1.DurationEnum.ONE_MONTH,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const errors = await (0, product_suspend_request_validator_1.validateProductSuspendRequestDto)(validRequest);
|
|
28
|
+
expect(errors.length).toBe(0);
|
|
29
|
+
});
|
|
30
|
+
it('should return errors for an invalid request', async () => {
|
|
31
|
+
const invalidRequest = {
|
|
32
|
+
clientData: {
|
|
33
|
+
email: 'not-an-email',
|
|
34
|
+
},
|
|
35
|
+
itemData: {},
|
|
36
|
+
};
|
|
37
|
+
const errors = await (0, product_suspend_request_validator_1.validateProductSuspendRequestDto)(invalidRequest);
|
|
38
|
+
expect(errors.length).toBeGreaterThan(0);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
const product_unsuspend_request_validator_1 = require("./product-unsuspend-request-validator");
|
|
5
|
+
const country_enum_1 = require("../enums/country.enum");
|
|
6
|
+
const duration_enum_1 = require("../enums/duration.enum");
|
|
7
|
+
describe('validateProductUnsuspendRequestDto', () => {
|
|
8
|
+
it('should return no errors for a valid request', async () => {
|
|
9
|
+
const validRequest = {
|
|
10
|
+
clientData: {
|
|
11
|
+
email: 'test@example.com',
|
|
12
|
+
firstName: 'John',
|
|
13
|
+
lastName: 'Doe',
|
|
14
|
+
telephone: '+14155552671',
|
|
15
|
+
address1: '123 Main St',
|
|
16
|
+
postcode: '12345',
|
|
17
|
+
city: 'Anytown',
|
|
18
|
+
country: country_enum_1.CountryEnum.UNITED_STATES,
|
|
19
|
+
},
|
|
20
|
+
itemData: {
|
|
21
|
+
itemId: 'item-123',
|
|
22
|
+
productAttributes: { key: 'value' },
|
|
23
|
+
itemAttributes: { key: 'value' },
|
|
24
|
+
duration: duration_enum_1.DurationEnum.ONE_MONTH,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const errors = await (0, product_unsuspend_request_validator_1.validateProductUnsuspendRequestDto)(validRequest);
|
|
28
|
+
expect(errors.length).toBe(0);
|
|
29
|
+
});
|
|
30
|
+
it('should return errors for an invalid request', async () => {
|
|
31
|
+
const invalidRequest = {
|
|
32
|
+
clientData: {
|
|
33
|
+
email: 'not-an-email',
|
|
34
|
+
},
|
|
35
|
+
itemData: {},
|
|
36
|
+
};
|
|
37
|
+
const errors = await (0, product_unsuspend_request_validator_1.validateProductUnsuspendRequestDto)(invalidRequest);
|
|
38
|
+
expect(errors.length).toBeGreaterThan(0);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
const product_upgradable_request_validator_1 = require("./product-upgradable-request-validator");
|
|
5
|
+
const country_enum_1 = require("../enums/country.enum");
|
|
6
|
+
const duration_enum_1 = require("../enums/duration.enum");
|
|
7
|
+
describe('validateProductUpgradableRequestDto', () => {
|
|
8
|
+
it('should return no errors for a valid request', async () => {
|
|
9
|
+
const validRequest = {
|
|
10
|
+
clientData: {
|
|
11
|
+
email: 'test@example.com',
|
|
12
|
+
firstName: 'John',
|
|
13
|
+
lastName: 'Doe',
|
|
14
|
+
telephone: '+14155552671',
|
|
15
|
+
address1: '123 Main St',
|
|
16
|
+
postcode: '12345',
|
|
17
|
+
city: 'Anytown',
|
|
18
|
+
country: country_enum_1.CountryEnum.UNITED_STATES,
|
|
19
|
+
},
|
|
20
|
+
itemData: {
|
|
21
|
+
itemId: 'item-123',
|
|
22
|
+
productAttributes: { key: 'value' },
|
|
23
|
+
itemAttributes: { key: 'value' },
|
|
24
|
+
duration: duration_enum_1.DurationEnum.ONE_MONTH,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const errors = await (0, product_upgradable_request_validator_1.validateProductUpgradableRequestDto)(validRequest);
|
|
28
|
+
expect(errors.length).toBe(0);
|
|
29
|
+
});
|
|
30
|
+
it('should return errors for an invalid request', async () => {
|
|
31
|
+
const invalidRequest = {
|
|
32
|
+
clientData: {
|
|
33
|
+
email: 'not-an-email',
|
|
34
|
+
},
|
|
35
|
+
itemData: {},
|
|
36
|
+
};
|
|
37
|
+
const errors = await (0, product_upgradable_request_validator_1.validateProductUpgradableRequestDto)(invalidRequest);
|
|
38
|
+
expect(errors.length).toBeGreaterThan(0);
|
|
39
|
+
});
|
|
40
|
+
});
|