@deallony/shared 1.2.39 → 1.2.42
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/dist/cjs/constants/used-product/UsedProduct.js +1 -1
- package/dist/cjs/schema/ad/save-ad.schema.d.ts +9 -13
- package/dist/cjs/schema/ad/save-ad.schema.js +17 -8
- package/dist/cjs/types/used-product/UsedProduct.d.ts +1 -1
- package/dist/cjs/types/used-product/UsedProduct.js +1 -1
- package/dist/cjs/utils/routes.d.ts +8 -0
- package/dist/cjs/utils/routes.js +10 -1
- package/dist/esm/constants/used-product/UsedProduct.js +1 -1
- package/dist/esm/schema/ad/save-ad.schema.js +18 -9
- package/dist/esm/types/used-product/UsedProduct.js +1 -1
- package/dist/esm/utils/routes.js +8 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
export declare const subjectTypeSchema: z.ZodEnum<{
|
|
3
3
|
properties: "properties";
|
|
4
4
|
services: "services";
|
|
@@ -32,7 +32,6 @@ export declare const createAdSchema: z.ZodObject<{
|
|
|
32
32
|
size_m2: z.ZodCoercedNumber<unknown>;
|
|
33
33
|
bedrooms: z.ZodCoercedNumber<unknown>;
|
|
34
34
|
offer_type_id: z.ZodCoercedNumber<unknown>;
|
|
35
|
-
district_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
36
35
|
property_type_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
37
36
|
price_type_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
38
37
|
publisher_type_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
@@ -51,8 +50,8 @@ export declare const createAdSchema: z.ZodObject<{
|
|
|
51
50
|
}, z.core.$strip>>>;
|
|
52
51
|
product: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
53
52
|
ad_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
54
|
-
condition_id: z.ZodCoercedNumber<unknown
|
|
55
|
-
age_id: z.ZodCoercedNumber<unknown
|
|
53
|
+
condition_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
54
|
+
age_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
56
55
|
isFree: z.ZodNullable<z.ZodOptional<z.ZodCoercedBoolean<unknown>>>;
|
|
57
56
|
isDeliveryAvailable: z.ZodNullable<z.ZodOptional<z.ZodCoercedBoolean<unknown>>>;
|
|
58
57
|
product_type_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
@@ -129,7 +128,6 @@ export declare const updateAdSchema: z.ZodObject<{
|
|
|
129
128
|
size_m2: z.ZodCoercedNumber<unknown>;
|
|
130
129
|
bedrooms: z.ZodCoercedNumber<unknown>;
|
|
131
130
|
offer_type_id: z.ZodCoercedNumber<unknown>;
|
|
132
|
-
district_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
133
131
|
property_type_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
134
132
|
price_type_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
135
133
|
publisher_type_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
@@ -149,8 +147,8 @@ export declare const updateAdSchema: z.ZodObject<{
|
|
|
149
147
|
}, z.core.$strip>>>;
|
|
150
148
|
product: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
151
149
|
id: z.ZodCoercedNumber<unknown>;
|
|
152
|
-
condition_id: z.ZodCoercedNumber<unknown
|
|
153
|
-
age_id: z.ZodCoercedNumber<unknown
|
|
150
|
+
condition_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
151
|
+
age_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
154
152
|
isFree: z.ZodNullable<z.ZodOptional<z.ZodCoercedBoolean<unknown>>>;
|
|
155
153
|
isDeliveryAvailable: z.ZodNullable<z.ZodOptional<z.ZodCoercedBoolean<unknown>>>;
|
|
156
154
|
product_type_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
@@ -222,7 +220,6 @@ export declare const saveAdSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
222
220
|
size_m2: z.ZodCoercedNumber<unknown>;
|
|
223
221
|
bedrooms: z.ZodCoercedNumber<unknown>;
|
|
224
222
|
offer_type_id: z.ZodCoercedNumber<unknown>;
|
|
225
|
-
district_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
226
223
|
property_type_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
227
224
|
price_type_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
228
225
|
publisher_type_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
@@ -241,8 +238,8 @@ export declare const saveAdSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
241
238
|
}, z.core.$strip>>>;
|
|
242
239
|
product: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
243
240
|
ad_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
244
|
-
condition_id: z.ZodCoercedNumber<unknown
|
|
245
|
-
age_id: z.ZodCoercedNumber<unknown
|
|
241
|
+
condition_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
242
|
+
age_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
246
243
|
isFree: z.ZodNullable<z.ZodOptional<z.ZodCoercedBoolean<unknown>>>;
|
|
247
244
|
isDeliveryAvailable: z.ZodNullable<z.ZodOptional<z.ZodCoercedBoolean<unknown>>>;
|
|
248
245
|
product_type_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
@@ -318,7 +315,6 @@ export declare const saveAdSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
318
315
|
size_m2: z.ZodCoercedNumber<unknown>;
|
|
319
316
|
bedrooms: z.ZodCoercedNumber<unknown>;
|
|
320
317
|
offer_type_id: z.ZodCoercedNumber<unknown>;
|
|
321
|
-
district_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
322
318
|
property_type_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
323
319
|
price_type_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
324
320
|
publisher_type_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
@@ -338,8 +334,8 @@ export declare const saveAdSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
338
334
|
}, z.core.$strip>>>;
|
|
339
335
|
product: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
340
336
|
id: z.ZodCoercedNumber<unknown>;
|
|
341
|
-
condition_id: z.ZodCoercedNumber<unknown
|
|
342
|
-
age_id: z.ZodCoercedNumber<unknown
|
|
337
|
+
condition_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
338
|
+
age_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
343
339
|
isFree: z.ZodNullable<z.ZodOptional<z.ZodCoercedBoolean<unknown>>>;
|
|
344
340
|
isDeliveryAvailable: z.ZodNullable<z.ZodOptional<z.ZodCoercedBoolean<unknown>>>;
|
|
345
341
|
product_type_id: z.ZodNullable<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.saveAdSchema = exports.updateAdSchema = exports.createAdSchema = exports.subjectTypeSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
exports.subjectTypeSchema = zod_1.z.enum([
|
|
5
|
+
exports.subjectTypeSchema = zod_1.z.enum([
|
|
6
|
+
"properties",
|
|
7
|
+
"services",
|
|
8
|
+
"motors",
|
|
9
|
+
"used_products",
|
|
10
|
+
]);
|
|
6
11
|
const adLocationSchema = zod_1.z.object({
|
|
7
12
|
ad_id: zod_1.z.coerce.number().int().positive().optional(),
|
|
8
13
|
admin_boundary_id: zod_1.z.coerce.number().int().positive(),
|
|
@@ -31,7 +36,10 @@ const createMotorSchema = zod_1.z.object({
|
|
|
31
36
|
seats_count: zod_1.z.coerce.number().nullable().optional(),
|
|
32
37
|
engine_capacity_cc: zod_1.z.coerce.number().nullable().optional(),
|
|
33
38
|
cylinders_count: zod_1.z.coerce.number().nullable().optional(),
|
|
34
|
-
feature_ids: zod_1.z
|
|
39
|
+
feature_ids: zod_1.z
|
|
40
|
+
.array(zod_1.z.coerce.number().int().positive())
|
|
41
|
+
.nullable()
|
|
42
|
+
.optional(),
|
|
35
43
|
});
|
|
36
44
|
const updateMotorSchema = createMotorSchema.extend({
|
|
37
45
|
id: zod_1.z.coerce.number().int().positive(),
|
|
@@ -41,7 +49,6 @@ const createPropertySchema = zod_1.z.object({
|
|
|
41
49
|
size_m2: zod_1.z.coerce.number().min(0),
|
|
42
50
|
bedrooms: zod_1.z.coerce.number().int().min(0),
|
|
43
51
|
offer_type_id: zod_1.z.coerce.number().int().positive(),
|
|
44
|
-
district_id: zod_1.z.coerce.number().int().positive().optional(),
|
|
45
52
|
property_type_id: zod_1.z.coerce.number().int().positive().optional(),
|
|
46
53
|
price_type_id: zod_1.z.coerce.number().int().optional(),
|
|
47
54
|
publisher_type_id: zod_1.z.coerce.number().int().positive().optional(),
|
|
@@ -60,7 +67,9 @@ const createPropertySchema = zod_1.z.object({
|
|
|
60
67
|
.map((item) => ({
|
|
61
68
|
...item,
|
|
62
69
|
// If property_id is null, undefined, or <= 0, convert it to undefined so Zod drops it
|
|
63
|
-
property_id: item.property_id === null ||
|
|
70
|
+
property_id: item.property_id === null ||
|
|
71
|
+
item.property_id === undefined ||
|
|
72
|
+
Number(item.property_id) <= 0
|
|
64
73
|
? undefined
|
|
65
74
|
: item.property_id,
|
|
66
75
|
}));
|
|
@@ -75,16 +84,16 @@ const updatePropertySchema = createPropertySchema.extend({
|
|
|
75
84
|
});
|
|
76
85
|
const createUsedProductSchema = zod_1.z.object({
|
|
77
86
|
ad_id: zod_1.z.coerce.number().int().positive().optional(),
|
|
78
|
-
condition_id: zod_1.z.coerce.number().int().positive(),
|
|
79
|
-
age_id: zod_1.z.coerce.number().int().positive(),
|
|
87
|
+
condition_id: zod_1.z.coerce.number().int().positive().optional().nullable(),
|
|
88
|
+
age_id: zod_1.z.coerce.number().int().positive().optional().nullable(),
|
|
80
89
|
isFree: zod_1.z.coerce.boolean().optional().nullable(),
|
|
81
90
|
isDeliveryAvailable: zod_1.z.coerce.boolean().optional().nullable(),
|
|
82
91
|
product_type_id: zod_1.z.coerce.number().optional().nullable(),
|
|
83
92
|
});
|
|
84
93
|
const updateUsedProductSchema = zod_1.z.object({
|
|
85
94
|
id: zod_1.z.coerce.number().int().positive(),
|
|
86
|
-
condition_id: zod_1.z.coerce.number().int().positive(),
|
|
87
|
-
age_id: zod_1.z.coerce.number().int().positive(),
|
|
95
|
+
condition_id: zod_1.z.coerce.number().int().positive().optional().nullable(),
|
|
96
|
+
age_id: zod_1.z.coerce.number().int().positive().optional().nullable(),
|
|
88
97
|
isFree: zod_1.z.coerce.boolean().optional().nullable(),
|
|
89
98
|
isDeliveryAvailable: zod_1.z.coerce.boolean().optional().nullable(),
|
|
90
99
|
product_type_id: zod_1.z.coerce.number().optional().nullable(),
|
|
@@ -5,7 +5,15 @@ export type RouteLike = {
|
|
|
5
5
|
params?: Record<string, RouteParamValue>;
|
|
6
6
|
};
|
|
7
7
|
export declare const routeToString: (route: RouteLike) => string;
|
|
8
|
+
export declare const buildHttpRouter: ({ domin, route, }: {
|
|
9
|
+
domin: string;
|
|
10
|
+
route: RouteLike;
|
|
11
|
+
}) => string;
|
|
8
12
|
export declare const RoutesUtils: {
|
|
9
13
|
routeToString: (route: RouteLike) => string;
|
|
14
|
+
buildHttpRouter: ({ domin, route, }: {
|
|
15
|
+
domin: string;
|
|
16
|
+
route: RouteLike;
|
|
17
|
+
}) => string;
|
|
10
18
|
};
|
|
11
19
|
export {};
|
package/dist/cjs/utils/routes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RoutesUtils = exports.routeToString = void 0;
|
|
3
|
+
exports.RoutesUtils = exports.buildHttpRouter = exports.routeToString = void 0;
|
|
4
4
|
const isNil = (value) => value == null;
|
|
5
5
|
const encodeParam = (value) => encodeURIComponent(String(value));
|
|
6
6
|
const stringifyQueryValue = (value) => {
|
|
@@ -36,6 +36,15 @@ const routeToString = (route) => {
|
|
|
36
36
|
return query ? `${pathname}?${query}` : pathname;
|
|
37
37
|
};
|
|
38
38
|
exports.routeToString = routeToString;
|
|
39
|
+
const buildHttpRouter = ({ domin, route, }) => {
|
|
40
|
+
const normalizedDomain = domin.replace(/\/+$/, "");
|
|
41
|
+
const normalizedRoute = (0, exports.routeToString)(route).replace(/^\/+/, "");
|
|
42
|
+
return normalizedRoute
|
|
43
|
+
? `${normalizedDomain}/${normalizedRoute}`
|
|
44
|
+
: `${normalizedDomain}/`;
|
|
45
|
+
};
|
|
46
|
+
exports.buildHttpRouter = buildHttpRouter;
|
|
39
47
|
exports.RoutesUtils = {
|
|
40
48
|
routeToString: exports.routeToString,
|
|
49
|
+
buildHttpRouter: exports.buildHttpRouter
|
|
41
50
|
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
export const subjectTypeSchema = z.enum([
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const subjectTypeSchema = z.enum([
|
|
3
|
+
"properties",
|
|
4
|
+
"services",
|
|
5
|
+
"motors",
|
|
6
|
+
"used_products",
|
|
7
|
+
]);
|
|
3
8
|
const adLocationSchema = z.object({
|
|
4
9
|
ad_id: z.coerce.number().int().positive().optional(),
|
|
5
10
|
admin_boundary_id: z.coerce.number().int().positive(),
|
|
@@ -28,7 +33,10 @@ const createMotorSchema = z.object({
|
|
|
28
33
|
seats_count: z.coerce.number().nullable().optional(),
|
|
29
34
|
engine_capacity_cc: z.coerce.number().nullable().optional(),
|
|
30
35
|
cylinders_count: z.coerce.number().nullable().optional(),
|
|
31
|
-
feature_ids: z
|
|
36
|
+
feature_ids: z
|
|
37
|
+
.array(z.coerce.number().int().positive())
|
|
38
|
+
.nullable()
|
|
39
|
+
.optional(),
|
|
32
40
|
});
|
|
33
41
|
const updateMotorSchema = createMotorSchema.extend({
|
|
34
42
|
id: z.coerce.number().int().positive(),
|
|
@@ -38,7 +46,6 @@ const createPropertySchema = z.object({
|
|
|
38
46
|
size_m2: z.coerce.number().min(0),
|
|
39
47
|
bedrooms: z.coerce.number().int().min(0),
|
|
40
48
|
offer_type_id: z.coerce.number().int().positive(),
|
|
41
|
-
district_id: z.coerce.number().int().positive().optional(),
|
|
42
49
|
property_type_id: z.coerce.number().int().positive().optional(),
|
|
43
50
|
price_type_id: z.coerce.number().int().optional(),
|
|
44
51
|
publisher_type_id: z.coerce.number().int().positive().optional(),
|
|
@@ -57,7 +64,9 @@ const createPropertySchema = z.object({
|
|
|
57
64
|
.map((item) => ({
|
|
58
65
|
...item,
|
|
59
66
|
// If property_id is null, undefined, or <= 0, convert it to undefined so Zod drops it
|
|
60
|
-
property_id: item.property_id === null ||
|
|
67
|
+
property_id: item.property_id === null ||
|
|
68
|
+
item.property_id === undefined ||
|
|
69
|
+
Number(item.property_id) <= 0
|
|
61
70
|
? undefined
|
|
62
71
|
: item.property_id,
|
|
63
72
|
}));
|
|
@@ -72,16 +81,16 @@ const updatePropertySchema = createPropertySchema.extend({
|
|
|
72
81
|
});
|
|
73
82
|
const createUsedProductSchema = z.object({
|
|
74
83
|
ad_id: z.coerce.number().int().positive().optional(),
|
|
75
|
-
condition_id: z.coerce.number().int().positive(),
|
|
76
|
-
age_id: z.coerce.number().int().positive(),
|
|
84
|
+
condition_id: z.coerce.number().int().positive().optional().nullable(),
|
|
85
|
+
age_id: z.coerce.number().int().positive().optional().nullable(),
|
|
77
86
|
isFree: z.coerce.boolean().optional().nullable(),
|
|
78
87
|
isDeliveryAvailable: z.coerce.boolean().optional().nullable(),
|
|
79
88
|
product_type_id: z.coerce.number().optional().nullable(),
|
|
80
89
|
});
|
|
81
90
|
const updateUsedProductSchema = z.object({
|
|
82
91
|
id: z.coerce.number().int().positive(),
|
|
83
|
-
condition_id: z.coerce.number().int().positive(),
|
|
84
|
-
age_id: z.coerce.number().int().positive(),
|
|
92
|
+
condition_id: z.coerce.number().int().positive().optional().nullable(),
|
|
93
|
+
age_id: z.coerce.number().int().positive().optional().nullable(),
|
|
85
94
|
isFree: z.coerce.boolean().optional().nullable(),
|
|
86
95
|
isDeliveryAvailable: z.coerce.boolean().optional().nullable(),
|
|
87
96
|
product_type_id: z.coerce.number().optional().nullable(),
|
package/dist/esm/utils/routes.js
CHANGED
|
@@ -32,6 +32,14 @@ export const routeToString = (route) => {
|
|
|
32
32
|
const query = queryEntries.join("&");
|
|
33
33
|
return query ? `${pathname}?${query}` : pathname;
|
|
34
34
|
};
|
|
35
|
+
export const buildHttpRouter = ({ domin, route, }) => {
|
|
36
|
+
const normalizedDomain = domin.replace(/\/+$/, "");
|
|
37
|
+
const normalizedRoute = routeToString(route).replace(/^\/+/, "");
|
|
38
|
+
return normalizedRoute
|
|
39
|
+
? `${normalizedDomain}/${normalizedRoute}`
|
|
40
|
+
: `${normalizedDomain}/`;
|
|
41
|
+
};
|
|
35
42
|
export const RoutesUtils = {
|
|
36
43
|
routeToString,
|
|
44
|
+
buildHttpRouter
|
|
37
45
|
};
|