@hosterai/types 0.0.24 → 0.0.25
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 +2 -1
- package/dist/dtos/info.dto.js +1 -1
- package/dist/enums/language.enum.d.ts +184 -184
- package/dist/enums/language.enum.js +184 -367
- package/dist/helpers/country.helper.d.ts +1 -1
- package/dist/helpers/country.helper.js +1 -3
- package/dist/openapi/schemas/components.schemas.d.ts +7 -7
- package/dist/openapi/schemas/components.schemas.js +739 -739
- package/dist/validators/company-data-validator.spec.js +6 -6
- package/dist/validators/field-validator.spec.js +3 -3
- package/dist/validators/multilang-text-validator.spec.js +2 -2
- package/dist/validators/notification-info-validator.spec.js +5 -5
- package/dist/validators/product-info-validator.spec.js +20 -20
- package/package.json +1 -1
|
@@ -12,8 +12,8 @@ describe('CompanyDataDto Validator', () => {
|
|
|
12
12
|
emails: ['test@example.com'],
|
|
13
13
|
invoiceEmail: 'invoice@example.com',
|
|
14
14
|
privacyPolicyUrl: 'https://example.com/privacy',
|
|
15
|
-
defaultLanguage: language_enum_1.LanguageEnum.
|
|
16
|
-
languages: [language_enum_1.LanguageEnum.
|
|
15
|
+
defaultLanguage: language_enum_1.LanguageEnum.ENGLISH,
|
|
16
|
+
languages: [language_enum_1.LanguageEnum.ENGLISH, language_enum_1.LanguageEnum.FRENCH],
|
|
17
17
|
telephone: '+12133734253',
|
|
18
18
|
address1: '123 Main St',
|
|
19
19
|
postcode: '12345',
|
|
@@ -39,8 +39,8 @@ describe('CompanyDataDto Validator', () => {
|
|
|
39
39
|
emails: ['not-an-email'],
|
|
40
40
|
invoiceEmail: 'invoice@example.com',
|
|
41
41
|
privacyPolicyUrl: 'http://example.com/privacy',
|
|
42
|
-
defaultLanguage: language_enum_1.LanguageEnum.
|
|
43
|
-
languages: [language_enum_1.LanguageEnum.
|
|
42
|
+
defaultLanguage: language_enum_1.LanguageEnum.ENGLISH,
|
|
43
|
+
languages: [language_enum_1.LanguageEnum.ENGLISH, language_enum_1.LanguageEnum.FRENCH],
|
|
44
44
|
telephone: '+12133734253',
|
|
45
45
|
address1: '123 Main St',
|
|
46
46
|
postcode: '12345',
|
|
@@ -58,8 +58,8 @@ describe('CompanyDataDto Validator', () => {
|
|
|
58
58
|
emails: ['test@example.com'],
|
|
59
59
|
invoiceEmail: 'invoice@example.com',
|
|
60
60
|
privacyPolicyUrl: 'not-a-url',
|
|
61
|
-
defaultLanguage: language_enum_1.LanguageEnum.
|
|
62
|
-
languages: [language_enum_1.LanguageEnum.
|
|
61
|
+
defaultLanguage: language_enum_1.LanguageEnum.ENGLISH,
|
|
62
|
+
languages: [language_enum_1.LanguageEnum.ENGLISH, language_enum_1.LanguageEnum.FRENCH],
|
|
63
63
|
telephone: '+12133734253',
|
|
64
64
|
address1: '123 Main St',
|
|
65
65
|
postcode: '12345',
|
|
@@ -6,7 +6,7 @@ const field_type_enum_1 = require("../enums/field-type.enum");
|
|
|
6
6
|
const language_enum_1 = require("../enums/language.enum");
|
|
7
7
|
const baseValidDto = {
|
|
8
8
|
id: 'test-id',
|
|
9
|
-
label: [{ language: language_enum_1.LanguageEnum.
|
|
9
|
+
label: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: 'Test Label' }],
|
|
10
10
|
value: 'test-value',
|
|
11
11
|
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
12
12
|
required: true,
|
|
@@ -23,8 +23,8 @@ describe('FieldDto Validator', () => {
|
|
|
23
23
|
it('should return no errors for a valid DTO with optional error messages', () => {
|
|
24
24
|
const dto = {
|
|
25
25
|
...baseValidDto,
|
|
26
|
-
regexValidationErrorMessage: [{ language: language_enum_1.LanguageEnum.
|
|
27
|
-
remoteValidationErrorMessage: [{ language: language_enum_1.LanguageEnum.
|
|
26
|
+
regexValidationErrorMessage: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: 'Invalid format' }],
|
|
27
|
+
remoteValidationErrorMessage: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: 'Invalid value' }],
|
|
28
28
|
};
|
|
29
29
|
expect((0, field_validator_1.validateFieldDto)(dto)).toHaveLength(0);
|
|
30
30
|
});
|
|
@@ -6,7 +6,7 @@ const language_enum_1 = require("../enums/language.enum");
|
|
|
6
6
|
describe('MultilangTextDto Validator', () => {
|
|
7
7
|
it('should return no errors for valid DTO', () => {
|
|
8
8
|
const validDto = {
|
|
9
|
-
language: language_enum_1.LanguageEnum.
|
|
9
|
+
language: language_enum_1.LanguageEnum.ENGLISH,
|
|
10
10
|
text: 'Hello World',
|
|
11
11
|
};
|
|
12
12
|
const errors = (0, multilang_text_validator_1.validateMultilangTextDto)(validDto);
|
|
@@ -23,7 +23,7 @@ describe('MultilangTextDto Validator', () => {
|
|
|
23
23
|
});
|
|
24
24
|
it('should return error for missing text', () => {
|
|
25
25
|
const invalidDto = {
|
|
26
|
-
language: language_enum_1.LanguageEnum.
|
|
26
|
+
language: language_enum_1.LanguageEnum.ENGLISH,
|
|
27
27
|
// Missing text
|
|
28
28
|
};
|
|
29
29
|
const errors = (0, multilang_text_validator_1.validateMultilangTextDto)(invalidDto);
|
|
@@ -14,7 +14,7 @@ describe('NotificationInfoDto Validator', () => {
|
|
|
14
14
|
type: notification_message_type_enum_1.NotificationMessageTypeEnum.EMAIL,
|
|
15
15
|
title: 'Valid Title',
|
|
16
16
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
17
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
17
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
18
18
|
payPerUseUnits: [validUnit]
|
|
19
19
|
},
|
|
20
20
|
expectedErrorsLength: 0
|
|
@@ -24,7 +24,7 @@ describe('NotificationInfoDto Validator', () => {
|
|
|
24
24
|
dto: {
|
|
25
25
|
title: 'Valid Title',
|
|
26
26
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
27
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
27
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
28
28
|
payPerUseUnits: [validUnit]
|
|
29
29
|
},
|
|
30
30
|
expectedErrorsLength: 1
|
|
@@ -35,7 +35,7 @@ describe('NotificationInfoDto Validator', () => {
|
|
|
35
35
|
type: notification_message_type_enum_1.NotificationMessageTypeEnum.EMAIL,
|
|
36
36
|
title: 'Valid Title',
|
|
37
37
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
38
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
38
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
39
39
|
payPerUseUnits: [{ id: "", unitDescription: "", intervalDescription: "" }] // Invalid unit
|
|
40
40
|
},
|
|
41
41
|
expectedErrorsLength: 1
|
|
@@ -53,7 +53,7 @@ describe('NotificationInfoDto Validator', () => {
|
|
|
53
53
|
dto: {
|
|
54
54
|
type: notification_message_type_enum_1.NotificationMessageTypeEnum.EMAIL,
|
|
55
55
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
56
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
56
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
57
57
|
payPerUseUnits: [validUnit]
|
|
58
58
|
},
|
|
59
59
|
expectedErrors: ['title']
|
|
@@ -64,7 +64,7 @@ describe('NotificationInfoDto Validator', () => {
|
|
|
64
64
|
type: notification_message_type_enum_1.NotificationMessageTypeEnum.EMAIL,
|
|
65
65
|
title: 'Valid Title',
|
|
66
66
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
67
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
67
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
68
68
|
payPerUseUnits: [{ id: "", unitDescription: "", intervalDescription: "" }]
|
|
69
69
|
},
|
|
70
70
|
expectedErrors: ['payPerUseUnits']
|
|
@@ -9,7 +9,7 @@ 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.
|
|
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,
|
|
@@ -20,7 +20,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
20
20
|
};
|
|
21
21
|
const invalidField = {
|
|
22
22
|
id: 'field',
|
|
23
|
-
label: [{ language: language_enum_1.LanguageEnum.
|
|
23
|
+
label: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: "label" }],
|
|
24
24
|
value: 'string',
|
|
25
25
|
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
26
26
|
disabled: false,
|
|
@@ -32,7 +32,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
32
32
|
dto: {
|
|
33
33
|
title: 'Test',
|
|
34
34
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
35
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
35
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
36
36
|
productAttributes: [field],
|
|
37
37
|
itemAttributes: [field]
|
|
38
38
|
},
|
|
@@ -43,7 +43,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
43
43
|
dto: {
|
|
44
44
|
title: 'Test',
|
|
45
45
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
46
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
46
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
47
47
|
itemAttributes: [invalidField]
|
|
48
48
|
},
|
|
49
49
|
expectedErrorsLength: 1
|
|
@@ -53,7 +53,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
53
53
|
dto: {
|
|
54
54
|
title: '',
|
|
55
55
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
56
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
56
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
57
57
|
productAttributes: [field],
|
|
58
58
|
itemAttributes: [field]
|
|
59
59
|
},
|
|
@@ -64,7 +64,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
64
64
|
dto: {
|
|
65
65
|
title: 'Test',
|
|
66
66
|
supportedActions: ['update'],
|
|
67
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
67
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
68
68
|
productAttributes: [field],
|
|
69
69
|
itemAttributes: [field]
|
|
70
70
|
},
|
|
@@ -86,7 +86,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
86
86
|
dto: {
|
|
87
87
|
title: 'Test',
|
|
88
88
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
89
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
89
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
90
90
|
productAttributes: [field],
|
|
91
91
|
itemAttributes: [field],
|
|
92
92
|
adminPanel: { tabs: { product: [{ label: 'Product', url: 'https://example.com/product' }] } },
|
|
@@ -99,7 +99,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
99
99
|
dto: {
|
|
100
100
|
title: '',
|
|
101
101
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
102
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
102
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
103
103
|
productAttributes: [field],
|
|
104
104
|
itemAttributes: [field],
|
|
105
105
|
adminPanel: { /* invalid admin panel data */},
|
|
@@ -112,7 +112,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
112
112
|
dto: {
|
|
113
113
|
title: 'Test',
|
|
114
114
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
115
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
115
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
116
116
|
productAttributes: [field],
|
|
117
117
|
itemAttributes: [field],
|
|
118
118
|
payPerUseUnits: [{ id: "ram", unitDescription: "MB", intervalDescription: "month" }]
|
|
@@ -124,7 +124,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
124
124
|
dto: {
|
|
125
125
|
title: 'Test',
|
|
126
126
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
127
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
127
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
128
128
|
productAttributes: [field],
|
|
129
129
|
itemAttributes: [field],
|
|
130
130
|
payPerUseUnits: [{ id: "", unitDescription: "", intervalDescription: "" }]
|
|
@@ -143,7 +143,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
143
143
|
description: 'should return ValidationError for missing title',
|
|
144
144
|
dto: {
|
|
145
145
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
146
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
146
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
147
147
|
productAttributes: [field],
|
|
148
148
|
itemAttributes: [field]
|
|
149
149
|
},
|
|
@@ -154,7 +154,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
154
154
|
dto: {
|
|
155
155
|
title: 'Test',
|
|
156
156
|
supportedActions: ['update'],
|
|
157
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
157
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
158
158
|
productAttributes: [field],
|
|
159
159
|
itemAttributes: [field]
|
|
160
160
|
},
|
|
@@ -174,7 +174,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
174
174
|
it('fails when a FieldDto has only repeatableMin (AllOrNone)', () => {
|
|
175
175
|
const fieldWithOnlyMin = {
|
|
176
176
|
id: 'f1',
|
|
177
|
-
label: [{ language: language_enum_1.LanguageEnum.
|
|
177
|
+
label: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: 'label' }],
|
|
178
178
|
value: 'v',
|
|
179
179
|
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
180
180
|
required: false,
|
|
@@ -187,7 +187,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
187
187
|
const dto = {
|
|
188
188
|
title: 'Test',
|
|
189
189
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
190
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
190
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
191
191
|
productAttributes: [fieldWithOnlyMin],
|
|
192
192
|
};
|
|
193
193
|
const errors = (0, product_info_validator_1.validateProductInfoDto)(dto);
|
|
@@ -196,7 +196,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
196
196
|
it('fails when a FieldDto has only repeatableMax (AllOrNone)', () => {
|
|
197
197
|
const fieldWithOnlyMax = {
|
|
198
198
|
id: 'f2',
|
|
199
|
-
label: [{ language: language_enum_1.LanguageEnum.
|
|
199
|
+
label: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: 'label' }],
|
|
200
200
|
value: 'v',
|
|
201
201
|
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
202
202
|
required: false,
|
|
@@ -209,7 +209,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
209
209
|
const dto = {
|
|
210
210
|
title: 'Test',
|
|
211
211
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
212
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
212
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
213
213
|
itemAttributes: [fieldWithOnlyMax],
|
|
214
214
|
};
|
|
215
215
|
const errors = (0, product_info_validator_1.validateProductInfoDto)(dto);
|
|
@@ -218,7 +218,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
218
218
|
it('passes when a FieldDto has both min and max with min <= max', () => {
|
|
219
219
|
const fieldOk = {
|
|
220
220
|
id: 'f3',
|
|
221
|
-
label: [{ language: language_enum_1.LanguageEnum.
|
|
221
|
+
label: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: 'label' }],
|
|
222
222
|
value: 'v',
|
|
223
223
|
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
224
224
|
required: false,
|
|
@@ -232,7 +232,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
232
232
|
const dto = {
|
|
233
233
|
title: 'Test',
|
|
234
234
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
235
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
235
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
236
236
|
productAttributes: [fieldOk],
|
|
237
237
|
};
|
|
238
238
|
expect((0, product_info_validator_1.validateProductInfoDto)(dto)).toHaveLength(0);
|
|
@@ -240,7 +240,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
240
240
|
it('fails when a FieldDto has both min and max with min > max (Min<=Max)', () => {
|
|
241
241
|
const fieldBad = {
|
|
242
242
|
id: 'f4',
|
|
243
|
-
label: [{ language: language_enum_1.LanguageEnum.
|
|
243
|
+
label: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: 'label' }],
|
|
244
244
|
value: 'v',
|
|
245
245
|
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
246
246
|
required: false,
|
|
@@ -254,7 +254,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
254
254
|
const dto = {
|
|
255
255
|
title: 'Test',
|
|
256
256
|
supportedActions: [actions_enum_1.ActionsEnum.CREATE],
|
|
257
|
-
supportedLanguages: [language_enum_1.LanguageEnum.
|
|
257
|
+
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
258
258
|
itemAttributes: [fieldBad],
|
|
259
259
|
};
|
|
260
260
|
const errors = (0, product_info_validator_1.validateProductInfoDto)(dto);
|