@hosterai/types 0.0.29 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/README.md +6 -1
  2. package/dist/decorators/is-e164-validator.spec.d.ts +1 -0
  3. package/dist/decorators/is-e164-validator.spec.js +64 -0
  4. package/dist/decorators/is-e164.validator.d.ts +2 -0
  5. package/dist/decorators/is-e164.validator.js +30 -0
  6. package/dist/decorators/unique-field-in-array-validator.spec.js +14 -0
  7. package/dist/decorators/unique-field-in-array.validator.js +18 -4
  8. package/dist/dtos/addon-field.dto.d.ts +6 -2
  9. package/dist/dtos/addon-field.dto.js +25 -2
  10. package/dist/dtos/attribute-field.dto.d.ts +18 -6
  11. package/dist/dtos/attribute-field.dto.js +18 -2
  12. package/dist/dtos/base-field.dto.d.ts +45 -0
  13. package/dist/dtos/base-field.dto.js +133 -0
  14. package/dist/dtos/field.dto.d.ts +5 -64
  15. package/dist/dtos/field.dto.js +0 -186
  16. package/dist/dtos/fields/any-field.dto.d.ts +38 -0
  17. package/dist/dtos/fields/any-field.dto.js +36 -0
  18. package/dist/dtos/fields/boolean-field.dto.d.ts +14 -0
  19. package/dist/dtos/fields/boolean-field.dto.js +48 -0
  20. package/dist/dtos/fields/countries-field.dto.d.ts +14 -0
  21. package/dist/dtos/fields/countries-field.dto.js +51 -0
  22. package/dist/dtos/fields/currency-field.dto.d.ts +14 -0
  23. package/dist/dtos/fields/currency-field.dto.js +50 -0
  24. package/dist/dtos/fields/date-field.dto.d.ts +14 -0
  25. package/dist/dtos/fields/date-field.dto.js +49 -0
  26. package/dist/dtos/fields/email-field.dto.d.ts +14 -0
  27. package/dist/dtos/fields/email-field.dto.js +49 -0
  28. package/dist/dtos/fields/multi-select-field.dto.d.ts +15 -0
  29. package/dist/dtos/fields/multi-select-field.dto.js +53 -0
  30. package/dist/dtos/fields/number-field.dto.d.ts +26 -0
  31. package/dist/dtos/fields/number-field.dto.js +82 -0
  32. package/dist/dtos/fields/password-field.dto.d.ts +21 -0
  33. package/dist/dtos/fields/password-field.dto.js +64 -0
  34. package/dist/dtos/fields/phone-field.dto.d.ts +14 -0
  35. package/dist/dtos/fields/phone-field.dto.js +50 -0
  36. package/dist/dtos/fields/select-field.dto.d.ts +15 -0
  37. package/dist/dtos/fields/select-field.dto.js +51 -0
  38. package/dist/dtos/fields/text-field.dto.d.ts +31 -0
  39. package/dist/dtos/fields/text-field.dto.js +102 -0
  40. package/dist/dtos/fields/textarea-field.dto.d.ts +31 -0
  41. package/dist/dtos/fields/textarea-field.dto.js +102 -0
  42. package/dist/dtos/fields/url-field.dto.d.ts +14 -0
  43. package/dist/dtos/fields/url-field.dto.js +49 -0
  44. package/dist/dtos/info/info-notification.dto.d.ts +5 -0
  45. package/dist/dtos/info/info-notification.dto.js +7 -0
  46. package/dist/dtos/info/info.dto.d.ts +196 -0
  47. package/dist/dtos/info/info.dto.js +278 -0
  48. package/dist/dtos/info.dto.d.ts +2 -2
  49. package/dist/dtos/info.dto.js +2 -5
  50. package/dist/dtos/invoice/requests/base-invoice-request.dto.d.ts +1 -1
  51. package/dist/dtos/invoice/requests/base-invoice-request.dto.js +1 -1
  52. package/dist/dtos/notification/notification-request.dto.d.ts +20 -0
  53. package/dist/dtos/notification/notification-request.dto.js +31 -0
  54. package/dist/dtos/product/product-info.dto.d.ts +2 -2
  55. package/dist/dtos/product/product-info.dto.js +4 -4
  56. package/dist/dtos/product/product-item-data.dto.d.ts +2 -2
  57. package/dist/dtos/product/product-item-data.dto.js +2 -2
  58. package/dist/dtos/receiver/receiver-email.dto.d.ts +20 -0
  59. package/dist/dtos/receiver/receiver-email.dto.js +39 -0
  60. package/dist/dtos/receiver/receiver-push.dto.d.ts +15 -0
  61. package/dist/dtos/receiver/receiver-push.dto.js +31 -0
  62. package/dist/dtos/receiver/receiver-sms.dto.d.ts +11 -0
  63. package/dist/dtos/receiver/receiver-sms.dto.js +26 -0
  64. package/dist/dtos/request.dto.d.ts +20 -0
  65. package/dist/dtos/request.dto.js +31 -0
  66. package/dist/dtos/responses/validate-attributes-response.dto.d.ts +4 -4
  67. package/dist/dtos/responses/validate-attributes-response.dto.js +2 -6
  68. package/dist/dtos/sender/sender-email.dto.d.ts +25 -0
  69. package/dist/dtos/sender/sender-email.dto.js +46 -0
  70. package/dist/dtos/sender/sender-push.dto.d.ts +31 -0
  71. package/dist/dtos/sender/sender-push.dto.js +50 -0
  72. package/dist/dtos/sender/sender-sms.dto.d.ts +15 -0
  73. package/dist/dtos/sender/sender-sms.dto.js +30 -0
  74. package/dist/enums/field-type.enum.d.ts +20 -7
  75. package/dist/enums/field-type.enum.js +19 -7
  76. package/dist/enums/item-actions.enum.d.ts +10 -10
  77. package/dist/enums/item-actions.enum.js +13 -14
  78. package/dist/enums/message-type.enum.d.ts +5 -0
  79. package/dist/enums/message-type.enum.js +9 -0
  80. package/dist/index.d.ts +29 -0
  81. package/dist/index.js +29 -0
  82. package/dist/openapi/schemas/components.schemas.d.ts +1169 -236
  83. package/dist/openapi/schemas/components.schemas.js +1878 -567
  84. package/dist/validators/addon-field-validator.d.ts +4 -1
  85. package/dist/validators/addon-field-validator.js +22 -3
  86. package/dist/validators/addon-field-validator.spec.js +15 -21
  87. package/dist/validators/any-field-validator.d.ts +10 -0
  88. package/dist/validators/any-field-validator.js +28 -0
  89. package/dist/validators/any-field-validator.spec.d.ts +1 -0
  90. package/dist/validators/any-field-validator.spec.js +37 -0
  91. package/dist/validators/attribute-field-validator.d.ts +4 -0
  92. package/dist/validators/attribute-field-validator.js +16 -0
  93. package/dist/validators/attribute-field-validator.spec.js +30 -20
  94. package/dist/validators/field-validator.d.ts +2 -4
  95. package/dist/validators/field-validator.js +4 -10
  96. package/dist/validators/field-validator.spec.js +16 -79
  97. package/dist/validators/fields/boolean-field-validator.d.ts +8 -0
  98. package/dist/validators/fields/boolean-field-validator.js +15 -0
  99. package/dist/validators/fields/boolean-field-validator.spec.d.ts +1 -0
  100. package/dist/validators/fields/boolean-field-validator.spec.js +43 -0
  101. package/dist/validators/fields/countries-field-validator.d.ts +8 -0
  102. package/dist/validators/fields/countries-field-validator.js +15 -0
  103. package/dist/validators/fields/countries-field-validator.spec.d.ts +1 -0
  104. package/dist/validators/fields/countries-field-validator.spec.js +44 -0
  105. package/dist/validators/fields/currency-field-validator.d.ts +8 -0
  106. package/dist/validators/fields/currency-field-validator.js +15 -0
  107. package/dist/validators/fields/currency-field-validator.spec.d.ts +1 -0
  108. package/dist/validators/fields/currency-field-validator.spec.js +41 -0
  109. package/dist/validators/fields/date-field-validator.d.ts +8 -0
  110. package/dist/validators/fields/date-field-validator.js +15 -0
  111. package/dist/validators/fields/date-field-validator.spec.d.ts +1 -0
  112. package/dist/validators/fields/date-field-validator.spec.js +43 -0
  113. package/dist/validators/fields/email-field-validator.d.ts +8 -0
  114. package/dist/validators/fields/email-field-validator.js +15 -0
  115. package/dist/validators/fields/email-field-validator.spec.d.ts +1 -0
  116. package/dist/validators/fields/email-field-validator.spec.js +43 -0
  117. package/dist/validators/fields/multi-select-field-validator.d.ts +8 -0
  118. package/dist/validators/fields/multi-select-field-validator.js +15 -0
  119. package/dist/validators/fields/multi-select-field-validator.spec.d.ts +1 -0
  120. package/dist/validators/fields/multi-select-field-validator.spec.js +52 -0
  121. package/dist/validators/fields/number-field-validator.d.ts +8 -0
  122. package/dist/validators/fields/number-field-validator.js +15 -0
  123. package/dist/validators/fields/number-field-validator.spec.d.ts +1 -0
  124. package/dist/validators/fields/number-field-validator.spec.js +59 -0
  125. package/dist/validators/fields/password-field-validator.d.ts +8 -0
  126. package/dist/validators/fields/password-field-validator.js +15 -0
  127. package/dist/validators/fields/password-field-validator.spec.d.ts +1 -0
  128. package/dist/validators/fields/password-field-validator.spec.js +44 -0
  129. package/dist/validators/fields/phone-field-validator.d.ts +8 -0
  130. package/dist/validators/fields/phone-field-validator.js +15 -0
  131. package/dist/validators/fields/phone-field-validator.spec.d.ts +1 -0
  132. package/dist/validators/fields/phone-field-validator.spec.js +41 -0
  133. package/dist/validators/fields/select-field-validator.d.ts +8 -0
  134. package/dist/validators/fields/select-field-validator.js +15 -0
  135. package/dist/validators/fields/select-field-validator.spec.d.ts +1 -0
  136. package/dist/validators/fields/select-field-validator.spec.js +46 -0
  137. package/dist/validators/fields/text-field-validator.d.ts +8 -0
  138. package/dist/validators/fields/text-field-validator.js +15 -0
  139. package/dist/validators/fields/text-field-validator.spec.d.ts +1 -0
  140. package/dist/validators/fields/text-field-validator.spec.js +60 -0
  141. package/dist/validators/fields/textarea-field-validator.d.ts +8 -0
  142. package/dist/validators/fields/textarea-field-validator.js +15 -0
  143. package/dist/validators/fields/textarea-field-validator.spec.d.ts +1 -0
  144. package/dist/validators/fields/textarea-field-validator.spec.js +52 -0
  145. package/dist/validators/fields/url-field-validator.d.ts +8 -0
  146. package/dist/validators/fields/url-field-validator.js +15 -0
  147. package/dist/validators/fields/url-field-validator.spec.d.ts +1 -0
  148. package/dist/validators/fields/url-field-validator.spec.js +43 -0
  149. package/dist/validators/notification-info-validator.spec.js +5 -5
  150. package/dist/validators/product-info-validator.spec.js +54 -120
  151. package/dist/validators/product-item-data-validator.spec.js +3 -3
  152. package/package.json +1 -1
  153. package/dist/dtos/product/requests/product-downgradeable-request.dto.d.ts +0 -18
  154. package/dist/dtos/product/requests/product-downgradeable-request.dto.js +0 -37
  155. package/dist/dtos/product/requests/product-upgradeable-request.dto.d.ts +0 -18
  156. package/dist/dtos/product/requests/product-upgradeable-request.dto.js +0 -37
  157. package/dist/dtos/product/responses/product-downgradeable-response.dto.d.ts +0 -22
  158. package/dist/dtos/product/responses/product-downgradeable-response.dto.js +0 -11
  159. package/dist/dtos/product/responses/product-upgradeable-response.dto.d.ts +0 -22
  160. package/dist/dtos/product/responses/product-upgradeable-response.dto.js +0 -11
  161. package/dist/validators/product-downgradeable-request-validator.d.ts +0 -8
  162. package/dist/validators/product-downgradeable-request-validator.js +0 -17
  163. package/dist/validators/product-upgradeable-request-validator.d.ts +0 -8
  164. package/dist/validators/product-upgradeable-request-validator.js +0 -17
package/README.md CHANGED
@@ -165,6 +165,7 @@ This package includes validation functions that leverage `class-validator` to en
165
165
  **Available Validators:**
166
166
 
167
167
  **Core Validators:**
168
+
168
169
  - `validateActionDto`: Validates UI actions.
169
170
  - `validateClientDataDto`: Validates client data.
170
171
  - `validateCompanyDataDto`: Validates company data.
@@ -183,24 +184,28 @@ This package includes validation functions that leverage `class-validator` to en
183
184
  - `validateInfoDto`: Validates integration info.
184
185
 
185
186
  **Panel Validators:**
187
+
186
188
  - `validateAdminPanelDto`: Validates admin panel configuration.
187
189
  - `validateAdminPanelTabsDto`: Validates admin panel tabs.
188
190
  - `validateAdminPanelMoreActionsDto`: Validates admin panel additional actions.
189
191
  - `validateClientPanelDto`: Validates client panel configuration.
190
192
 
191
193
  **Menu & Settings Validators:**
194
+
192
195
  - `validateMenuWithUrlDto`: Validates menu items with direct URLs.
193
196
  - `validateMenuWithSubmenuDto`: Validates menu items with submenus.
194
197
  - `validateSettingsWithUrlDto`: Validates settings with URL configuration.
195
198
  - `validateSettingsWithTabsDto`: Validates settings with tabs configuration.
196
199
 
197
200
  **Notification Validators:**
201
+
198
202
  - `validateNotificationRequestDto`: Validates the main notification request.
199
203
  - `validateNotificationInfoDto`: Validates notification information.
200
204
  - `validateEmailReceiverDto`, `validateSmsReceiverDto`, `validatePushReceiverDto`: Validators for notification receivers.
201
205
  - `validateEmailSenderDto`, `validateSmsSenderDto`, `validatePushSenderDto`: Validators for notification senders.
202
206
 
203
207
  **Invoice Validators:**
208
+
204
209
  - `validateInvoiceInfoDto`: Validates invoice integration info.
205
210
  - `validateInvoiceContactDataDto`: Validates invoice contact data.
206
211
  - `validateInvoiceItemDataDto`: Validates invoice item data.
@@ -208,6 +213,7 @@ This package includes validation functions that leverage `class-validator` to en
208
213
  - `validateTransactionDataDto`: Validates transaction data.
209
214
 
210
215
  **Product Validators:**
216
+
211
217
  - `validateProductInfoDto`: Validates product information.
212
218
  - `validateProductCreateRequestDto`: Validates product creation requests.
213
219
  - `validateProductDeleteRequestDto`: Validates product deletion requests.
@@ -220,7 +226,6 @@ This package includes validation functions that leverage `class-validator` to en
220
226
  - `validateProductDowngradableRequestDto`: Validates product downgradability checks.
221
227
  - `validateValidateAttributesRequestDto`: Validates attribute validation requests.
222
228
 
223
-
224
229
  ### Custom Decorators
225
230
 
226
231
  The package includes custom `class-validator` decorators for advanced validation scenarios:
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const class_validator_1 = require("class-validator");
13
+ const is_e164_validator_1 = require("./is-e164.validator");
14
+ class TestDto {
15
+ }
16
+ __decorate([
17
+ (0, is_e164_validator_1.IsE164)(),
18
+ __metadata("design:type", String)
19
+ ], TestDto.prototype, "phone", void 0);
20
+ describe('IsE164', () => {
21
+ it('should validate canonical E.164 numbers', () => {
22
+ const dto = new TestDto();
23
+ dto.phone = '+14155552671';
24
+ const errors = (0, class_validator_1.validateSync)(dto);
25
+ expect(errors.length).toBe(0);
26
+ });
27
+ it('should validate another canonical E.164 number', () => {
28
+ const dto = new TestDto();
29
+ dto.phone = '+306912345678';
30
+ const errors = (0, class_validator_1.validateSync)(dto);
31
+ expect(errors.length).toBe(0);
32
+ });
33
+ it('should invalidate numbers without leading +', () => {
34
+ const dto = new TestDto();
35
+ dto.phone = '14155552671';
36
+ const errors = (0, class_validator_1.validateSync)(dto);
37
+ expect(errors.length).toBeGreaterThan(0);
38
+ });
39
+ it('should invalidate numbers with spaces or formatting', () => {
40
+ const dto = new TestDto();
41
+ dto.phone = '+1 415 555 2671';
42
+ const errors = (0, class_validator_1.validateSync)(dto);
43
+ expect(errors.length).toBeGreaterThan(0);
44
+ });
45
+ it('should invalidate clearly invalid strings', () => {
46
+ const dto = new TestDto();
47
+ dto.phone = 'not-a-phone';
48
+ const errors = (0, class_validator_1.validateSync)(dto);
49
+ expect(errors.length).toBeGreaterThan(0);
50
+ });
51
+ it('should invalidate non-string values', () => {
52
+ const dto = new TestDto();
53
+ // @ts-expect-error -- intentionally wrong type for negative test
54
+ dto.phone = 14155552671;
55
+ const errors = (0, class_validator_1.validateSync)(dto);
56
+ expect(errors.length).toBeGreaterThan(0);
57
+ });
58
+ it('should invalidate empty strings', () => {
59
+ const dto = new TestDto();
60
+ dto.phone = '';
61
+ const errors = (0, class_validator_1.validateSync)(dto);
62
+ expect(errors.length).toBeGreaterThan(0);
63
+ });
64
+ });
@@ -0,0 +1,2 @@
1
+ import { ValidationOptions } from 'class-validator';
2
+ export declare function IsE164(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsE164 = IsE164;
4
+ const class_validator_1 = require("class-validator");
5
+ const libphonenumber_js_1 = require("libphonenumber-js");
6
+ function IsE164(validationOptions) {
7
+ return function (object, propertyName) {
8
+ (0, class_validator_1.registerDecorator)({
9
+ name: 'isE164',
10
+ target: object.constructor,
11
+ propertyName: propertyName,
12
+ options: validationOptions,
13
+ validator: {
14
+ validate(value) {
15
+ if (typeof value !== 'string')
16
+ return false;
17
+ if (value.trim().length === 0)
18
+ return false;
19
+ const parsed = (0, libphonenumber_js_1.parsePhoneNumberFromString)(value);
20
+ if (!parsed)
21
+ return false;
22
+ return parsed.format('E.164') === value;
23
+ },
24
+ defaultMessage() {
25
+ return '$property must be a valid E.164 phone number (e.g. +14155552671)';
26
+ },
27
+ },
28
+ });
29
+ };
30
+ }
@@ -36,4 +36,18 @@ describe('UniqueFieldInArray', () => {
36
36
  const errors = (0, class_validator_1.validateSync)(dto);
37
37
  expect(errors.length).toBe(0);
38
38
  });
39
+ it('should support dotted paths for nested fields', () => {
40
+ class NestedDto {
41
+ }
42
+ __decorate([
43
+ (0, unique_field_in_array_validator_1.UniqueFieldInArray)('nested.id'),
44
+ __metadata("design:type", Array)
45
+ ], NestedDto.prototype, "items", void 0);
46
+ const ok = new NestedDto();
47
+ ok.items = [{ nested: { id: 1 } }, { nested: { id: 2 } }];
48
+ expect((0, class_validator_1.validateSync)(ok).length).toBe(0);
49
+ const bad = new NestedDto();
50
+ bad.items = [{ nested: { id: 1 } }, { nested: { id: 1 } }];
51
+ expect((0, class_validator_1.validateSync)(bad).length).toBeGreaterThan(0);
52
+ });
39
53
  });
@@ -9,18 +9,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.UniqueFieldInArrayConstraint = void 0;
10
10
  exports.UniqueFieldInArray = UniqueFieldInArray;
11
11
  const class_validator_1 = require("class-validator");
12
+ /**
13
+ * Walk a dotted path (`'a.b.c'`) into an object. Returns undefined if any segment is missing
14
+ * or if a non-object is encountered before the leaf.
15
+ */
16
+ function readPath(obj, path) {
17
+ let current = obj;
18
+ for (const segment of path.split('.')) {
19
+ if (current === null || typeof current !== 'object')
20
+ return undefined;
21
+ current = current[segment];
22
+ }
23
+ return current;
24
+ }
12
25
  let UniqueFieldInArrayConstraint = class UniqueFieldInArrayConstraint {
13
26
  validate(value, args) {
14
27
  if (!Array.isArray(value))
15
28
  return true; // Let @IsArray handle wrong type
16
- const field = args.constraints[0];
29
+ const path = args.constraints[0];
17
30
  const seen = new Set();
18
31
  for (const obj of value) {
19
- if (obj && typeof obj === 'object' && obj[field] !== undefined) {
20
- if (seen.has(obj[field])) {
32
+ const fieldValue = readPath(obj, path);
33
+ if (fieldValue !== undefined) {
34
+ if (seen.has(fieldValue)) {
21
35
  return false;
22
36
  }
23
- seen.add(obj[field]);
37
+ seen.add(fieldValue);
24
38
  }
25
39
  }
26
40
  return true;
@@ -1,7 +1,11 @@
1
- import { FieldDto } from './field.dto';
1
+ import { AnyFieldDto } from './fields/any-field.dto';
2
2
  /**
3
3
  * Fields defined by the seller for a product, requested during checkout setup.
4
4
  * These fields contain information relevant only to the seller, not to the integration.
5
+ *
6
+ * Wraps a concrete field DTO under the nested `field` property — validate the
7
+ * union separately (see `validateAddonFieldDto`).
5
8
  */
6
- export declare class AddonFieldDto extends FieldDto {
9
+ export declare class AddonFieldDto {
10
+ field: AnyFieldDto;
7
11
  }
@@ -1,11 +1,34 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.AddonFieldDto = void 0;
4
- const field_dto_1 = require("./field.dto");
13
+ const class_validator_1 = require("class-validator");
14
+ const class_validator_jsonschema_1 = require("class-validator-jsonschema");
5
15
  /**
6
16
  * Fields defined by the seller for a product, requested during checkout setup.
7
17
  * These fields contain information relevant only to the seller, not to the integration.
18
+ *
19
+ * Wraps a concrete field DTO under the nested `field` property — validate the
20
+ * union separately (see `validateAddonFieldDto`).
8
21
  */
9
- class AddonFieldDto extends field_dto_1.FieldDto {
22
+ class AddonFieldDto {
10
23
  }
11
24
  exports.AddonFieldDto = AddonFieldDto;
25
+ __decorate([
26
+ (0, class_validator_1.IsObject)(),
27
+ (0, class_validator_1.IsDefined)(),
28
+ (0, class_validator_jsonschema_1.JSONSchema)({
29
+ title: 'Field',
30
+ description: 'The concrete field DTO (discriminated by its `type` literal).',
31
+ $ref: '#/components/schemas/AnyFieldDto',
32
+ }),
33
+ __metadata("design:type", Object)
34
+ ], AddonFieldDto.prototype, "field", void 0);
@@ -1,19 +1,31 @@
1
- import { FieldDto } from './field.dto';
2
- export declare class AttributeFieldDto extends FieldDto {
1
+ import { AnyFieldDto } from './fields/any-field.dto';
2
+ /**
3
+ * Wraps a concrete field DTO with product-attribute-specific options.
4
+ *
5
+ * The underlying field lives under the nested `field` property — its concrete
6
+ * class is discriminated by `field.type` and must be validated separately
7
+ * (see `validateAttributeFieldDto`).
8
+ */
9
+ export declare class AttributeFieldDto {
3
10
  /**
4
- * Indicates if the field is visible in orders
11
+ * The concrete field DTO (one of `AnyFieldDto`). Validated separately by
12
+ * the dispatcher in `validateAttributeFieldDto` since it is a discriminated union.
13
+ */
14
+ field: AnyFieldDto;
15
+ /**
16
+ * Indicates if the field is visible in orders.
5
17
  */
6
18
  visibleInOrder?: boolean;
7
19
  /**
8
- * Indicates if the field is visible in client panel
20
+ * Indicates if the field is visible in client panel.
9
21
  */
10
22
  visibleInClientPanel?: boolean;
11
23
  /**
12
- * Minimum repeats for repeatable fields
24
+ * Minimum repeats for repeatable fields.
13
25
  */
14
26
  repeatableMin?: number;
15
27
  /**
16
- * Maximum repeats for repeatable fields
28
+ * Maximum repeats for repeatable fields.
17
29
  */
18
30
  repeatableMax?: number;
19
31
  }
@@ -12,12 +12,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AttributeFieldDto = void 0;
13
13
  const class_validator_1 = require("class-validator");
14
14
  const class_validator_jsonschema_1 = require("class-validator-jsonschema");
15
- const field_dto_1 = require("./field.dto");
16
15
  const all_or_none_validator_1 = require("../decorators/all-or-none.validator");
17
16
  const min_less_or_equal_validator_1 = require("../decorators/min-less-or-equal.validator");
18
- let AttributeFieldDto = class AttributeFieldDto extends field_dto_1.FieldDto {
17
+ /**
18
+ * Wraps a concrete field DTO with product-attribute-specific options.
19
+ *
20
+ * The underlying field lives under the nested `field` property — its concrete
21
+ * class is discriminated by `field.type` and must be validated separately
22
+ * (see `validateAttributeFieldDto`).
23
+ */
24
+ let AttributeFieldDto = class AttributeFieldDto {
19
25
  };
20
26
  exports.AttributeFieldDto = AttributeFieldDto;
27
+ __decorate([
28
+ (0, class_validator_1.IsObject)(),
29
+ (0, class_validator_1.IsDefined)(),
30
+ (0, class_validator_jsonschema_1.JSONSchema)({
31
+ title: 'Field',
32
+ description: 'The concrete field DTO (discriminated by its `type` literal).',
33
+ $ref: '#/components/schemas/AnyFieldDto',
34
+ }),
35
+ __metadata("design:type", Object)
36
+ ], AttributeFieldDto.prototype, "field", void 0);
21
37
  __decorate([
22
38
  (0, class_validator_1.IsBoolean)(),
23
39
  (0, class_validator_1.IsOptional)(),
@@ -0,0 +1,45 @@
1
+ import { MultilangTextDto } from './multilang-text.dto';
2
+ /**
3
+ * Abstract base shared by every concrete field DTO (TextFieldDto, NumberFieldDto, ...).
4
+ *
5
+ * Concrete classes add a string-literal `type` discriminator and a typed `value` plus any
6
+ * type-specific options (min/max, regex validation for text, etc.).
7
+ */
8
+ export declare abstract class BaseFieldDto {
9
+ /**
10
+ * Unique identifier for the field.
11
+ */
12
+ id: string;
13
+ /**
14
+ * Multilingual label for the field.
15
+ */
16
+ label: MultilangTextDto[];
17
+ /**
18
+ * Whether the field is required.
19
+ */
20
+ required?: boolean;
21
+ /**
22
+ * Whether the field is disabled.
23
+ */
24
+ disabled?: boolean;
25
+ /**
26
+ * Whether the field is hidden.
27
+ */
28
+ hidden?: boolean;
29
+ /**
30
+ * Whether remote validation should be triggered.
31
+ */
32
+ triggersRemoteValidation?: boolean;
33
+ /**
34
+ * Localized error message shown when remote validation fails.
35
+ */
36
+ remoteValidationErrorMessage?: MultilangTextDto[];
37
+ /**
38
+ * Whether the item attribute is upgradable by the user.
39
+ */
40
+ upgradable?: boolean;
41
+ /**
42
+ * Whether the item attribute is downgradable by the user.
43
+ */
44
+ downgradable?: boolean;
45
+ }
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BaseFieldDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ const class_transformer_1 = require("class-transformer");
15
+ const class_validator_jsonschema_1 = require("class-validator-jsonschema");
16
+ const multilang_text_dto_1 = require("./multilang-text.dto");
17
+ /**
18
+ * Abstract base shared by every concrete field DTO (TextFieldDto, NumberFieldDto, ...).
19
+ *
20
+ * Concrete classes add a string-literal `type` discriminator and a typed `value` plus any
21
+ * type-specific options (min/max, regex validation for text, etc.).
22
+ */
23
+ class BaseFieldDto {
24
+ constructor() {
25
+ /**
26
+ * Whether the item attribute is upgradable by the user.
27
+ */
28
+ this.upgradable = false;
29
+ /**
30
+ * Whether the item attribute is downgradable by the user.
31
+ */
32
+ this.downgradable = false;
33
+ }
34
+ }
35
+ exports.BaseFieldDto = BaseFieldDto;
36
+ __decorate([
37
+ (0, class_validator_1.IsString)(),
38
+ (0, class_validator_1.IsDefined)(),
39
+ (0, class_validator_jsonschema_1.JSONSchema)({
40
+ title: 'ID',
41
+ description: 'Unique identifier for the field.',
42
+ type: 'string',
43
+ }),
44
+ __metadata("design:type", String)
45
+ ], BaseFieldDto.prototype, "id", void 0);
46
+ __decorate([
47
+ (0, class_validator_1.ValidateNested)({ each: true }),
48
+ (0, class_transformer_1.Type)(() => multilang_text_dto_1.MultilangTextDto),
49
+ (0, class_validator_1.IsArray)(),
50
+ (0, class_validator_1.ArrayMinSize)(1),
51
+ (0, class_validator_jsonschema_1.JSONSchema)({
52
+ title: 'Label',
53
+ description: 'Multilingual label for the field.',
54
+ type: 'array',
55
+ items: { $ref: '#/components/schemas/MultilangTextDto' },
56
+ }),
57
+ __metadata("design:type", Array)
58
+ ], BaseFieldDto.prototype, "label", void 0);
59
+ __decorate([
60
+ (0, class_validator_1.IsBoolean)(),
61
+ (0, class_validator_1.IsDefined)(),
62
+ (0, class_validator_jsonschema_1.JSONSchema)({
63
+ title: 'Required',
64
+ description: 'Whether the field is required.',
65
+ type: 'boolean',
66
+ }),
67
+ __metadata("design:type", Boolean)
68
+ ], BaseFieldDto.prototype, "required", void 0);
69
+ __decorate([
70
+ (0, class_validator_1.IsBoolean)(),
71
+ (0, class_validator_1.IsDefined)(),
72
+ (0, class_validator_jsonschema_1.JSONSchema)({
73
+ title: 'Disabled',
74
+ description: 'Whether the field is disabled.',
75
+ type: 'boolean',
76
+ }),
77
+ __metadata("design:type", Boolean)
78
+ ], BaseFieldDto.prototype, "disabled", void 0);
79
+ __decorate([
80
+ (0, class_validator_1.IsBoolean)(),
81
+ (0, class_validator_1.IsOptional)(),
82
+ (0, class_validator_jsonschema_1.JSONSchema)({
83
+ title: 'Hidden',
84
+ description: 'Whether the field is hidden.',
85
+ type: 'boolean',
86
+ }),
87
+ __metadata("design:type", Boolean)
88
+ ], BaseFieldDto.prototype, "hidden", void 0);
89
+ __decorate([
90
+ (0, class_validator_1.IsBoolean)(),
91
+ (0, class_validator_1.IsOptional)(),
92
+ (0, class_validator_jsonschema_1.JSONSchema)({
93
+ title: 'Triggers Remote Validation',
94
+ description: 'Whether remote validation should be triggered for this field.',
95
+ type: 'boolean',
96
+ }),
97
+ __metadata("design:type", Boolean)
98
+ ], BaseFieldDto.prototype, "triggersRemoteValidation", void 0);
99
+ __decorate([
100
+ (0, class_validator_1.ValidateIf)((o) => !!o.triggersRemoteValidation),
101
+ (0, class_validator_1.ValidateNested)({ each: true }),
102
+ (0, class_transformer_1.Type)(() => multilang_text_dto_1.MultilangTextDto),
103
+ (0, class_validator_1.IsArray)(),
104
+ (0, class_validator_1.ArrayMinSize)(1),
105
+ (0, class_validator_1.IsOptional)(),
106
+ (0, class_validator_jsonschema_1.JSONSchema)({
107
+ title: 'Remote Validation Error Message',
108
+ description: 'Localized error message shown when remote validation fails.',
109
+ type: 'array',
110
+ items: { $ref: '#/components/schemas/MultilangTextDto' },
111
+ }),
112
+ __metadata("design:type", Array)
113
+ ], BaseFieldDto.prototype, "remoteValidationErrorMessage", void 0);
114
+ __decorate([
115
+ (0, class_validator_1.IsBoolean)(),
116
+ (0, class_validator_1.IsOptional)(),
117
+ (0, class_validator_jsonschema_1.JSONSchema)({
118
+ title: 'Upgradable',
119
+ description: 'Whether the item attribute is upgradable by the user.',
120
+ type: 'boolean',
121
+ }),
122
+ __metadata("design:type", Boolean)
123
+ ], BaseFieldDto.prototype, "upgradable", void 0);
124
+ __decorate([
125
+ (0, class_validator_1.IsBoolean)(),
126
+ (0, class_validator_1.IsOptional)(),
127
+ (0, class_validator_jsonschema_1.JSONSchema)({
128
+ title: 'Downgradable',
129
+ description: 'Whether the item attribute is downgradable by the user.',
130
+ type: 'boolean',
131
+ }),
132
+ __metadata("design:type", Boolean)
133
+ ], BaseFieldDto.prototype, "downgradable", void 0);
@@ -1,66 +1,7 @@
1
- import { FieldTypeEnum } from '../enums/field-type.enum';
2
- import { MultilangTextDto } from './multilang-text.dto';
3
- import { FieldOptionDto } from './field-option.dto';
1
+ import { AnyFieldDto } from './fields/any-field.dto';
4
2
  /**
5
- * Data Transfer Object for a form field.
6
- * This class defines the structure and properties of a single field
7
- * that can be used in a user interface form.
3
+ * @deprecated Use a concrete field DTO (`TextFieldDto`, `NumberFieldDto`, ...)
4
+ * or the `AnyFieldDto` union directly. This alias is kept for one release while
5
+ * downstream consumers migrate (hoster-ai/api issue #449).
8
6
  */
9
- export declare class FieldDto {
10
- /**
11
- * ID of action field
12
- */
13
- id: string;
14
- /**
15
- * Label of action field
16
- */
17
- label: MultilangTextDto[];
18
- /**
19
- * Value of the field.
20
- *
21
- * String is when it is input, text area
22
- * Number is when it is number
23
- * FieldOptionDto is when it is checkbox
24
- * FieldOptionDto[] is when it is radioboxes or select
25
- */
26
- value: string | number | FieldOptionDto | FieldOptionDto[];
27
- /**
28
- * Type of the field
29
- */
30
- type: FieldTypeEnum;
31
- /**
32
- * Indicates if the field is required
33
- */
34
- required?: boolean;
35
- /**
36
- * Indicates if the field is disabled
37
- */
38
- disabled?: boolean;
39
- /**
40
- * Indicates if the field is hidden
41
- */
42
- hidden?: boolean;
43
- /**
44
- * Regex validation pattern for the field
45
- */
46
- regexValidation?: string;
47
- /**
48
- * Error message for the field for supported languages
49
- */
50
- regexValidationErrorMessage?: MultilangTextDto[];
51
- /**
52
- * Whether remote validation should be triggered
53
- */
54
- triggersRemoteValidation?: boolean;
55
- /**
56
- * Remote validation error message for supported languages
57
- */
58
- remoteValidationErrorMessage?: MultilangTextDto[];
59
- /**
60
- * The item attribute is upgradable
61
- * If the user has the permission to upgrade the item from his panel
62
- * TODO: Let's see if this approach is the best way for the user to upgrade their item
63
- */
64
- upgradable?: boolean;
65
- downgradable?: boolean;
66
- }
7
+ export type FieldDto = AnyFieldDto;