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