@deallony/shared 1.2.8 → 1.2.9

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 (109) hide show
  1. package/dist/cjs/dto/events/Event.d.ts +2 -0
  2. package/dist/cjs/dto/events/Event.js +5 -0
  3. package/dist/cjs/dto/events/EventTemplate.d.ts +14 -0
  4. package/dist/cjs/dto/events/EventTemplate.dto.d.ts +18 -0
  5. package/dist/cjs/dto/events/EventTemplate.dto.js +11 -0
  6. package/dist/cjs/dto/events/EventTemplate.js +14 -0
  7. package/dist/cjs/dto/events/EventType.d.ts +2 -0
  8. package/dist/cjs/dto/events/EventType.dto.d.ts +16 -0
  9. package/dist/cjs/dto/events/EventType.dto.js +10 -0
  10. package/dist/cjs/dto/events/EventType.js +5 -0
  11. package/dist/cjs/dto/events/EventWedding.d.ts +11 -0
  12. package/dist/cjs/dto/events/EventWedding.js +9 -0
  13. package/dist/cjs/dto/events/common.d.ts +5 -0
  14. package/dist/cjs/dto/events/common.js +8 -0
  15. package/dist/cjs/types/attributes/CarBody.d.ts +5 -0
  16. package/dist/cjs/types/attributes/CarBody.js +2 -0
  17. package/dist/cjs/types/attributes/Facility.d.ts +6 -0
  18. package/dist/cjs/types/attributes/Facility.js +2 -0
  19. package/dist/cjs/types/attributes/Feature.d.ts +7 -0
  20. package/dist/cjs/types/attributes/Feature.js +2 -0
  21. package/dist/cjs/types/attributes/FuelType.d.ts +5 -0
  22. package/dist/cjs/types/attributes/FuelType.js +2 -0
  23. package/dist/cjs/types/attributes/LicenseType.d.ts +5 -0
  24. package/dist/cjs/types/attributes/LicenseType.js +2 -0
  25. package/dist/cjs/types/attributes/OfferType.d.ts +5 -0
  26. package/dist/cjs/types/attributes/OfferType.js +2 -0
  27. package/dist/cjs/types/attributes/PriceType.d.ts +7 -0
  28. package/dist/cjs/types/attributes/PriceType.js +2 -0
  29. package/dist/cjs/types/attributes/PropertyStatus.d.ts +5 -0
  30. package/dist/cjs/types/attributes/PropertyStatus.js +2 -0
  31. package/dist/cjs/types/attributes/PublisherType.d.ts +5 -0
  32. package/dist/cjs/types/attributes/PublisherType.js +2 -0
  33. package/dist/cjs/types/attributes/RegionalSpec.d.ts +5 -0
  34. package/dist/cjs/types/attributes/RegionalSpec.js +2 -0
  35. package/dist/cjs/types/attributes/Transmission.d.ts +5 -0
  36. package/dist/cjs/types/attributes/Transmission.js +2 -0
  37. package/dist/cjs/types/attributes/Unit.d.ts +5 -0
  38. package/dist/cjs/types/attributes/Unit.js +2 -0
  39. package/dist/cjs/types/attributes/UsedProductAge.d.ts +7 -0
  40. package/dist/cjs/types/attributes/UsedProductAge.js +2 -0
  41. package/dist/cjs/types/attributes/UsedProductCondition.d.ts +7 -0
  42. package/dist/cjs/types/attributes/UsedProductCondition.js +2 -0
  43. package/dist/cjs/types/attributes/WorkType.d.ts +6 -0
  44. package/dist/cjs/types/attributes/WorkType.js +2 -0
  45. package/dist/cjs/types/common/AccessType.d.ts +5 -0
  46. package/dist/cjs/types/common/AccessType.js +2 -0
  47. package/dist/cjs/types/events/EventTemplate.d.ts +14 -0
  48. package/dist/cjs/types/events/EventTemplate.js +14 -0
  49. package/dist/cjs/types/events/EventType.d.ts +10 -0
  50. package/dist/cjs/types/events/EventType.js +11 -0
  51. package/dist/cjs/types/listings/Ad.d.ts +93 -0
  52. package/dist/cjs/types/listings/Ad.js +25 -0
  53. package/dist/cjs/types/listings/AdLocation.d.ts +5 -0
  54. package/dist/cjs/types/listings/AdLocation.js +2 -0
  55. package/dist/cjs/types/listings/AdPromotion.d.ts +12 -0
  56. package/dist/cjs/types/listings/AdPromotion.js +2 -0
  57. package/dist/cjs/types/listings/Motor.d.ts +24 -0
  58. package/dist/cjs/types/listings/Motor.js +17 -0
  59. package/dist/cjs/types/listings/MotorTrim.d.ts +6 -0
  60. package/dist/cjs/types/listings/MotorTrim.js +2 -0
  61. package/dist/cjs/types/listings/Property.d.ts +37 -0
  62. package/dist/cjs/types/listings/Property.js +14 -0
  63. package/dist/cjs/types/listings/PropertySubType.d.ts +6 -0
  64. package/dist/cjs/types/listings/PropertySubType.js +2 -0
  65. package/dist/cjs/types/listings/Service.d.ts +14 -0
  66. package/dist/cjs/types/listings/Service.js +9 -0
  67. package/dist/cjs/types/listings/UsedProduct.d.ts +8 -0
  68. package/dist/cjs/types/listings/UsedProduct.js +7 -0
  69. package/dist/cjs/types/listings/index.d.ts +5 -0
  70. package/dist/cjs/types/listings/index.js +21 -0
  71. package/dist/cjs/validation/ad/save-ad.d.ts +45 -0
  72. package/dist/cjs/validation/ad/save-ad.js +55 -0
  73. package/dist/esm/dto/events/Event.js +1 -0
  74. package/dist/esm/dto/events/EventTemplate.dto.js +8 -0
  75. package/dist/esm/dto/events/EventTemplate.js +11 -0
  76. package/dist/esm/dto/events/EventType.dto.js +7 -0
  77. package/dist/esm/dto/events/EventType.js +1 -0
  78. package/dist/esm/dto/events/EventWedding.js +6 -0
  79. package/dist/esm/dto/events/common.js +5 -0
  80. package/dist/esm/types/attributes/CarBody.js +1 -0
  81. package/dist/esm/types/attributes/Facility.js +1 -0
  82. package/dist/esm/types/attributes/Feature.js +1 -0
  83. package/dist/esm/types/attributes/FuelType.js +1 -0
  84. package/dist/esm/types/attributes/LicenseType.js +1 -0
  85. package/dist/esm/types/attributes/OfferType.js +1 -0
  86. package/dist/esm/types/attributes/PriceType.js +1 -0
  87. package/dist/esm/types/attributes/PropertyStatus.js +1 -0
  88. package/dist/esm/types/attributes/PublisherType.js +1 -0
  89. package/dist/esm/types/attributes/RegionalSpec.js +1 -0
  90. package/dist/esm/types/attributes/Transmission.js +1 -0
  91. package/dist/esm/types/attributes/Unit.js +1 -0
  92. package/dist/esm/types/attributes/UsedProductAge.js +1 -0
  93. package/dist/esm/types/attributes/UsedProductCondition.js +1 -0
  94. package/dist/esm/types/attributes/WorkType.js +1 -0
  95. package/dist/esm/types/common/AccessType.js +1 -0
  96. package/dist/esm/types/events/EventTemplate.js +11 -0
  97. package/dist/esm/types/events/EventType.js +8 -0
  98. package/dist/esm/types/listings/Ad.js +22 -0
  99. package/dist/esm/types/listings/AdLocation.js +1 -0
  100. package/dist/esm/types/listings/AdPromotion.js +1 -0
  101. package/dist/esm/types/listings/Motor.js +14 -0
  102. package/dist/esm/types/listings/MotorTrim.js +1 -0
  103. package/dist/esm/types/listings/Property.js +11 -0
  104. package/dist/esm/types/listings/PropertySubType.js +1 -0
  105. package/dist/esm/types/listings/Service.js +6 -0
  106. package/dist/esm/types/listings/UsedProduct.js +4 -0
  107. package/dist/esm/types/listings/index.js +5 -0
  108. package/dist/esm/validation/ad/save-ad.js +52 -0
  109. package/package.json +1 -1
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emptyProperty = void 0;
4
+ exports.emptyProperty = {
5
+ id: 0,
6
+ offer_type_id: 0,
7
+ price_type_id: 0,
8
+ size_m2: 0,
9
+ bedrooms: 0,
10
+ created_at: "",
11
+ updated_at: "",
12
+ property_facilities: [],
13
+ feature_ids: [],
14
+ };
@@ -0,0 +1,6 @@
1
+ import { LocalizedName } from "../common/LocalizedName";
2
+ export type IPropertyType = {
3
+ id?: number;
4
+ name: LocalizedName;
5
+ category_id: number;
6
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ export type IServiceLocation = {
2
+ id?: number;
3
+ service_id?: number;
4
+ district_id?: number;
5
+ city_id: number;
6
+ };
7
+ export type IService = {
8
+ id?: number;
9
+ unit_id: number | null;
10
+ access_type_id: number | null;
11
+ work_type_id: number | null;
12
+ locations: IServiceLocation[];
13
+ };
14
+ export declare const emptyService: IService;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emptyService = void 0;
4
+ exports.emptyService = {
5
+ unit_id: null,
6
+ access_type_id: null,
7
+ work_type_id: null,
8
+ locations: [],
9
+ };
@@ -0,0 +1,8 @@
1
+ export type IUsedProduct = {
2
+ id?: number;
3
+ condition_id?: number;
4
+ age_id?: number;
5
+ isDeliveryAvailable: undefined;
6
+ product_type_id: undefined;
7
+ };
8
+ export declare const emptyUsedProduct: IUsedProduct;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emptyUsedProduct = void 0;
4
+ exports.emptyUsedProduct = {
5
+ isDeliveryAvailable: undefined,
6
+ product_type_id: undefined,
7
+ };
@@ -0,0 +1,5 @@
1
+ export * from "../ad";
2
+ export * from "../motor";
3
+ export * from "../property";
4
+ export * from "../service";
5
+ export * from "../used-product";
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("../ad"), exports);
18
+ __exportStar(require("../motor"), exports);
19
+ __exportStar(require("../property"), exports);
20
+ __exportStar(require("../service"), exports);
21
+ __exportStar(require("../used-product"), exports);
@@ -0,0 +1,45 @@
1
+ import { z } from 'zod';
2
+ export declare const createAdSchema: z.ZodObject<{
3
+ title: z.ZodOptional<z.ZodString>;
4
+ status_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
5
+ description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
6
+ category_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
7
+ price: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
8
+ currency_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
9
+ negotiable: z.ZodNullable<z.ZodOptional<z.ZodCoercedBoolean<unknown>>>;
10
+ city_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
11
+ latitude: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
12
+ longitude: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
13
+ media: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodAny>>>;
14
+ base_price: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
15
+ contact_methods: z.ZodNullable<z.ZodOptional<z.ZodObject<{
16
+ by_message: z.ZodOptional<z.ZodBoolean>;
17
+ by_whatsapp: z.ZodOptional<z.ZodBoolean>;
18
+ by_call: z.ZodOptional<z.ZodBoolean>;
19
+ }, z.core.$strip>>>;
20
+ selected_phone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
21
+ user_id: z.ZodCoercedNumber<unknown>;
22
+ id: z.ZodOptional<z.ZodNever>;
23
+ }, z.core.$strip>;
24
+ export declare const updateAdSchema: z.ZodObject<{
25
+ id: z.ZodCoercedNumber<unknown>;
26
+ title: z.ZodOptional<z.ZodString>;
27
+ status_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
28
+ description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
29
+ category_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
30
+ price: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
31
+ currency_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
32
+ negotiable: z.ZodNullable<z.ZodOptional<z.ZodCoercedBoolean<unknown>>>;
33
+ city_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
34
+ latitude: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
35
+ longitude: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
36
+ media: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodAny>>>;
37
+ base_price: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
38
+ contact_methods: z.ZodNullable<z.ZodOptional<z.ZodObject<{
39
+ by_message: z.ZodOptional<z.ZodBoolean>;
40
+ by_whatsapp: z.ZodOptional<z.ZodBoolean>;
41
+ by_call: z.ZodOptional<z.ZodBoolean>;
42
+ }, z.core.$strip>>>;
43
+ selected_phone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
44
+ user_id: z.ZodCoercedNumber<unknown>;
45
+ }, z.core.$strip>;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateAdSchema = exports.createAdSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const baseAdCommon = zod_1.z.object({
6
+ title: zod_1.z.string().trim().optional(),
7
+ status_id: zod_1.z.coerce.number().int().positive().optional(),
8
+ description: zod_1.z.string().trim().optional().nullable(),
9
+ category_id: zod_1.z.coerce.number().int().positive().optional().nullable(),
10
+ price: zod_1.z.coerce.number().min(0).optional().nullable(),
11
+ currency_id: zod_1.z.coerce.number().int().positive().optional().nullable(),
12
+ negotiable: zod_1.z.coerce.boolean().optional().nullable(),
13
+ city_id: zod_1.z.coerce.number().int().positive().optional().nullable(),
14
+ latitude: zod_1.z.coerce.number().optional().nullable(),
15
+ longitude: zod_1.z.coerce.number().optional().nullable(),
16
+ media: zod_1.z.array(zod_1.z.any()).optional().nullable(),
17
+ // subject_type: SubjectTypeSchema.optional(),
18
+ base_price: zod_1.z.coerce.number().optional().nullable(),
19
+ contact_methods: zod_1.z.object({
20
+ by_message: zod_1.z.boolean().optional(),
21
+ by_whatsapp: zod_1.z.boolean().optional(),
22
+ by_call: zod_1.z.boolean().optional(),
23
+ }).optional().nullable(),
24
+ selected_phone: zod_1.z.string().trim().optional().nullable(),
25
+ });
26
+ exports.createAdSchema = zod_1.z.object({
27
+ user_id: zod_1.z.coerce.number().int().positive(),
28
+ id: zod_1.z.never().optional(), // disallow id on create
29
+ ...baseAdCommon.shape,
30
+ // motor: createMotorSchema
31
+ // .extend({ ad_id: z.coerce.number().optional() })
32
+ // .optional()
33
+ // .nullable(),
34
+ // // Make nested ad_id optional/nullable without changing original schemas
35
+ // property: createPropertySchema
36
+ // .extend({ ad_id: z.coerce.number().optional() })
37
+ // .optional()
38
+ // .nullable(),
39
+ // product: createUsedProductSchema
40
+ // .extend({ ad_id: z.coerce.number().optional() })
41
+ // .optional()
42
+ // .nullable(),
43
+ // service: createServiceSchema
44
+ // .extend({ ad_id: z.coerce.number().optional() })
45
+ // .optional()
46
+ // .nullable(),
47
+ });
48
+ exports.updateAdSchema = zod_1.z.object({
49
+ ...exports.createAdSchema.shape,
50
+ id: zod_1.z.coerce.number().int().positive(),
51
+ // motor: updateMotorSchema.optional().nullable(),
52
+ // property: updatePropertySchema.optional().nullable(),
53
+ // product: updateUsedProductSchema.optional().nullable(),
54
+ // service: updateServiceSchema.optional().nullable(),
55
+ });
@@ -0,0 +1 @@
1
+ export { emptyEvent } from './Event.dto.js';
@@ -0,0 +1,8 @@
1
+ export const EventTemplate = {
2
+ WEDDING: { value: 'wedding-1', name: { en: 'Wedding', ar: 'زفاف' }, event_types: ['wedding'] },
3
+ };
4
+ export const EventTemplateOptions = Object.values(EventTemplate).map((type) => ({
5
+ value: type.value,
6
+ name: type.name,
7
+ event_types: type.event_types,
8
+ }));
@@ -0,0 +1,11 @@
1
+ import { createEmptyLocalizedName } from '../../types/common/LocalizedName.js';
2
+ export const emptyEventTemplate = {
3
+ id: 0,
4
+ code: '',
5
+ name: createEmptyLocalizedName(),
6
+ active: true,
7
+ religion: null,
8
+ event_type_id: 0,
9
+ eventType: undefined,
10
+ weddings: [],
11
+ };
@@ -0,0 +1,7 @@
1
+ export const EventTypes = {
2
+ WEDDING: { value: 'wedding', name: { en: 'Wedding', ar: 'زفاف' } },
3
+ };
4
+ export const EventTypeOptions = Object.values(EventTypes).map((type) => ({
5
+ value: type.value,
6
+ name: type.name,
7
+ }));
@@ -0,0 +1 @@
1
+ export { emptyEventType } from './EventType.dto.js';
@@ -0,0 +1,6 @@
1
+ export const emptyEventWedding = {
2
+ id: 0,
3
+ event_id: 0,
4
+ event_template_id: 0,
5
+ cover: null,
6
+ };
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ export const localizedNameSchema = z.object({
3
+ en: z.string().trim().min(1),
4
+ ar: z.string().trim().min(1),
5
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { createEmptyLocalizedName } from '../common/LocalizedName.js';
2
+ export const emptyEventTemplate = {
3
+ id: 0,
4
+ code: '',
5
+ name: createEmptyLocalizedName(),
6
+ active: true,
7
+ religion: null,
8
+ event_type_id: 0,
9
+ eventType: undefined,
10
+ weddings: [],
11
+ };
@@ -0,0 +1,8 @@
1
+ import { createEmptyLocalizedName } from '../common/LocalizedName.js';
2
+ export const emptyEventType = {
3
+ id: 0,
4
+ code: '',
5
+ name: createEmptyLocalizedName(),
6
+ active: true,
7
+ templates: [],
8
+ };
@@ -0,0 +1,22 @@
1
+ import { emptyMotor } from "./Motor.js";
2
+ import { emptyProperty } from "./Property.js";
3
+ import { emptyService } from "./Service.js";
4
+ import { emptyUsedProduct } from "./UsedProduct.js";
5
+ export const emptyAd = {
6
+ id: 0,
7
+ user_id: 0,
8
+ status_id: 0,
9
+ title: "",
10
+ description: "",
11
+ negotiable: false,
12
+ latitude: 0,
13
+ longitude: 0,
14
+ baseAdminBoundaryId: 0,
15
+ contact_methods: null,
16
+ selected_phone: null,
17
+ media: [],
18
+ property: emptyProperty,
19
+ motor: emptyMotor,
20
+ service: emptyService,
21
+ product: emptyUsedProduct,
22
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ export const emptyMotor = {
2
+ id: 0,
3
+ body_type_id: 0,
4
+ regional_spec_id: 0,
5
+ transmission_id: 0,
6
+ fuel_type_id: 0,
7
+ interior_color_id: null,
8
+ mileage: 0,
9
+ offer_type_id: 0,
10
+ year: null,
11
+ created_at: "",
12
+ updated_at: "",
13
+ seats_count: null,
14
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ export const emptyProperty = {
2
+ id: 0,
3
+ offer_type_id: 0,
4
+ price_type_id: 0,
5
+ size_m2: 0,
6
+ bedrooms: 0,
7
+ created_at: "",
8
+ updated_at: "",
9
+ property_facilities: [],
10
+ feature_ids: [],
11
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export const emptyService = {
2
+ unit_id: null,
3
+ access_type_id: null,
4
+ work_type_id: null,
5
+ locations: [],
6
+ };
@@ -0,0 +1,4 @@
1
+ export const emptyUsedProduct = {
2
+ isDeliveryAvailable: undefined,
3
+ product_type_id: undefined,
4
+ };
@@ -0,0 +1,5 @@
1
+ export * from "../ad/index.js";
2
+ export * from "../motor/index.js";
3
+ export * from "../property/index.js";
4
+ export * from "../service/index.js";
5
+ export * from "../used-product/index.js";
@@ -0,0 +1,52 @@
1
+ import { z } from 'zod';
2
+ const baseAdCommon = z.object({
3
+ title: z.string().trim().optional(),
4
+ status_id: z.coerce.number().int().positive().optional(),
5
+ description: z.string().trim().optional().nullable(),
6
+ category_id: z.coerce.number().int().positive().optional().nullable(),
7
+ price: z.coerce.number().min(0).optional().nullable(),
8
+ currency_id: z.coerce.number().int().positive().optional().nullable(),
9
+ negotiable: z.coerce.boolean().optional().nullable(),
10
+ city_id: z.coerce.number().int().positive().optional().nullable(),
11
+ latitude: z.coerce.number().optional().nullable(),
12
+ longitude: z.coerce.number().optional().nullable(),
13
+ media: z.array(z.any()).optional().nullable(),
14
+ // subject_type: SubjectTypeSchema.optional(),
15
+ base_price: z.coerce.number().optional().nullable(),
16
+ contact_methods: z.object({
17
+ by_message: z.boolean().optional(),
18
+ by_whatsapp: z.boolean().optional(),
19
+ by_call: z.boolean().optional(),
20
+ }).optional().nullable(),
21
+ selected_phone: z.string().trim().optional().nullable(),
22
+ });
23
+ export const createAdSchema = z.object({
24
+ user_id: z.coerce.number().int().positive(),
25
+ id: z.never().optional(), // disallow id on create
26
+ ...baseAdCommon.shape,
27
+ // motor: createMotorSchema
28
+ // .extend({ ad_id: z.coerce.number().optional() })
29
+ // .optional()
30
+ // .nullable(),
31
+ // // Make nested ad_id optional/nullable without changing original schemas
32
+ // property: createPropertySchema
33
+ // .extend({ ad_id: z.coerce.number().optional() })
34
+ // .optional()
35
+ // .nullable(),
36
+ // product: createUsedProductSchema
37
+ // .extend({ ad_id: z.coerce.number().optional() })
38
+ // .optional()
39
+ // .nullable(),
40
+ // service: createServiceSchema
41
+ // .extend({ ad_id: z.coerce.number().optional() })
42
+ // .optional()
43
+ // .nullable(),
44
+ });
45
+ export const updateAdSchema = z.object({
46
+ ...createAdSchema.shape,
47
+ id: z.coerce.number().int().positive(),
48
+ // motor: updateMotorSchema.optional().nullable(),
49
+ // property: updatePropertySchema.optional().nullable(),
50
+ // product: updateUsedProductSchema.optional().nullable(),
51
+ // service: updateServiceSchema.optional().nullable(),
52
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deallony/shared",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "private": false,
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",