@hapl/api-queries 0.1.114 → 0.1.117

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 (42) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/api-queries.cjs.development.js +213 -22
  3. package/dist/api-queries.cjs.development.js.map +1 -1
  4. package/dist/api-queries.cjs.production.min.js +1 -1
  5. package/dist/api-queries.cjs.production.min.js.map +1 -1
  6. package/dist/api-queries.esm.js +213 -22
  7. package/dist/api-queries.esm.js.map +1 -1
  8. package/dist/clients/v1/api/experts/findExperts/index.d.ts +22 -17
  9. package/dist/clients/v1/api/index.d.ts +3 -0
  10. package/dist/clients/v1/api/serviceRequest/findServiceRequestSellerReport/index.d.ts +42 -0
  11. package/dist/clients/v1/api/sold/findSoldStatistic/index.d.ts +25 -0
  12. package/dist/clients/v1/api/valuation/findValuationByServiceRequestId/index.d.ts +29 -0
  13. package/dist/clients/v1/dictionaries/Valuation.d.ts +10 -0
  14. package/dist/clients/v1/dictionaries/index.d.ts +1 -0
  15. package/dist/clients/v1/index.d.ts +3 -0
  16. package/dist/clients/v1/types/ServiceRequestSellerReport.d.ts +20 -0
  17. package/dist/clients/v1/types/SoldStatistic.d.ts +9 -0
  18. package/dist/clients/v1/types/User.d.ts +1 -0
  19. package/dist/clients/v1/types/Valuation.d.ts +69 -0
  20. package/dist/clients/v1/types/index.d.ts +3 -0
  21. package/dist/clients/v2/api/index.d.ts +1 -0
  22. package/dist/clients/v2/api/realty/findRealties/index.d.ts +74 -0
  23. package/dist/clients/v2/api/realty/findRealtyById/index.d.ts +1 -0
  24. package/dist/clients/v2/index.d.ts +1 -0
  25. package/package.json +1 -1
  26. package/src/clients/v1/api/experts/findExperts/index.ts +33 -29
  27. package/src/clients/v1/api/index.ts +5 -0
  28. package/src/clients/v1/api/serviceRequest/findServiceRequestSellerReport/index.ts +62 -0
  29. package/src/clients/v1/api/sold/findSoldStatistic/index.ts +35 -0
  30. package/src/clients/v1/api/valuation/findValuationByServiceRequestId/index.ts +42 -0
  31. package/src/clients/v1/dictionaries/Valuation.ts +11 -0
  32. package/src/clients/v1/dictionaries/index.ts +1 -0
  33. package/src/clients/v1/index.ts +23 -0
  34. package/src/clients/v1/types/ServiceRequestSellerReport.ts +20 -0
  35. package/src/clients/v1/types/SoldStatistic.ts +10 -0
  36. package/src/clients/v1/types/User.ts +1 -0
  37. package/src/clients/v1/types/Valuation.ts +57 -0
  38. package/src/clients/v1/types/index.ts +3 -0
  39. package/src/clients/v2/api/index.ts +1 -0
  40. package/src/clients/v2/api/realty/findRealties/index.ts +105 -0
  41. package/src/clients/v2/api/realty/findRealtyById/index.ts +1 -0
  42. package/src/clients/v2/index.ts +4 -0
@@ -0,0 +1,42 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import qs from 'qs';
3
+ import { Valuation } from '../../../types';
4
+
5
+ type SuccessData = { success: true; data: Valuation };
6
+ type ErrorData = { success: false; data: { error: string } };
7
+
8
+ type ResultData = SuccessData['data'];
9
+ type ResultError = ErrorData['data']['error'];
10
+
11
+ export type FindValuationByServiceRequestIdUrlParams = { id: number };
12
+ export type FindValuationByServiceRequestIdParams = { withDrafts?: boolean };
13
+ export type FindValuationByServiceRequestIdData = AxiosResponse<ResultData>;
14
+ export type FindValuationByServiceRequestIdError = AxiosError<ResultError>;
15
+
16
+ export type FindValuationByServiceRequestIdConfig = {
17
+ baseURL?: string;
18
+ urlParams: FindValuationByServiceRequestIdUrlParams;
19
+ params?: FindValuationByServiceRequestIdParams;
20
+ };
21
+
22
+ export function findValuationByServiceRequestIdRequest({
23
+ baseURL = 'https://clients.homeapp.ru',
24
+ urlParams,
25
+ params,
26
+ }: FindValuationByServiceRequestIdConfig) {
27
+ return axios
28
+ .get(`/api/valuation/${urlParams.id}`, {
29
+ baseURL,
30
+ params,
31
+ paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
32
+ headers: { Accept: 'application/json' },
33
+ transformResponse: [
34
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
35
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
36
+ ],
37
+ })
38
+ .then((res: FindValuationByServiceRequestIdData) => res)
39
+ .catch((err: FindValuationByServiceRequestIdError) => {
40
+ throw err;
41
+ });
42
+ }
@@ -0,0 +1,11 @@
1
+ import { ValuationConcurrency } from '../types';
2
+
3
+ export const ValuationDictionary = {
4
+ Concurrency: {
5
+ [ValuationConcurrency.Low]: 'Не высокий',
6
+ [ValuationConcurrency.Medium]: 'Средний',
7
+ [ValuationConcurrency.MediumHigh]: 'Выше среднего',
8
+ [ValuationConcurrency.High]: 'Высокий',
9
+ [ValuationConcurrency.VeryHigh]: 'Очень высокий',
10
+ },
11
+ };
@@ -16,3 +16,4 @@ export * from './ServiceRequestCategorizedFile';
16
16
  export * from './Shape';
17
17
  export * from './Task';
18
18
  export * from './User';
19
+ export * from './Valuation';
@@ -347,6 +347,20 @@ export class Api {
347
347
  return api.startServiceRequestModerationForOldRealtyRequest({ urlParams, headers, baseURL: this.baseURL });
348
348
  };
349
349
 
350
+ findServiceRequestSellerReport = (
351
+ urlParams: api.FindServiceRequestSellerReportUrlParams,
352
+ params: api.FindServiceRequestSellerReportParams,
353
+ headers: api.FindServiceRequestSellerReportHeaders
354
+ ) => {
355
+ return api.findServiceRequestSellerReportRequest({ urlParams, params, headers, baseURL: this.baseURL });
356
+ };
357
+
358
+ // sold
359
+
360
+ findSoldStatistic = (headers?: api.FindSoldStatisticHeaders) => {
361
+ return api.findSoldStatisticRequest({ headers, baseURL: this.baseURL });
362
+ };
363
+
350
364
  // task
351
365
 
352
366
  findTasks = (params: api.FindTasksParams, headers: api.FindTasksHeaders) => {
@@ -382,6 +396,15 @@ export class Api {
382
396
  ) => {
383
397
  return api.assignSubordinateUsersRequest({ urlParams, body, headers, baseURL: this.baseURL });
384
398
  };
399
+
400
+ // valuation
401
+
402
+ findValuationByServiceRequestId = (
403
+ urlParams: api.FindValuationByServiceRequestIdUrlParams,
404
+ params?: api.FindValuationByServiceRequestIdParams
405
+ ) => {
406
+ return api.findValuationByServiceRequestIdRequest({ urlParams, params, baseURL: this.baseURL });
407
+ };
385
408
  }
386
409
 
387
410
  export * from './api';
@@ -0,0 +1,20 @@
1
+ export type ServiceRequestSellerReport = {
2
+ id: string;
3
+ closingReasons: Array<{
4
+ label: string;
5
+ value: number;
6
+ }>;
7
+ comment: string;
8
+ createdAt: string;
9
+ curatorId: number;
10
+ from: string;
11
+ serviceRequestId: number;
12
+ stats: {
13
+ calls: number;
14
+ rejections: number;
15
+ shows: number;
16
+ views: number;
17
+ priceStatus?: string;
18
+ };
19
+ to: string;
20
+ };
@@ -0,0 +1,10 @@
1
+ export enum SoldStatisticTypes {
2
+ House = 'house',
3
+ FlatNew = 'flat_new',
4
+ FlatSecondary = 'flat_secondary',
5
+ }
6
+
7
+ export type SoldStatistic = {
8
+ type: SoldStatisticTypes;
9
+ price: number;
10
+ };
@@ -148,4 +148,5 @@ export type User = {
148
148
  patronymic?: string;
149
149
  supervisor?: User;
150
150
  updatedAt?: string;
151
+ fullNameTranslit?: string;
151
152
  };
@@ -0,0 +1,57 @@
1
+ import { ServiceRequest } from './ServiceRequest';
2
+
3
+ export enum ValuationConcurrency {
4
+ Low = 'low',
5
+ Medium = 'medium',
6
+ MediumHigh = 'medium-high',
7
+ High = 'high',
8
+ VeryHigh = 'very-high',
9
+ }
10
+
11
+ type ValueRange = { max: number; min: number; p10: number; p50: number; p90: number };
12
+
13
+ type Stats = {
14
+ count: number;
15
+ outOfRange: number;
16
+ area?: ValueRange;
17
+ price?: ValueRange;
18
+ realtyIds?: number[];
19
+ };
20
+
21
+ export type Valuation = {
22
+ addresses: number[];
23
+ comments: Array<{ comment: string; realtyId: number }>;
24
+ createdAt: string;
25
+ id: number;
26
+ isDraft: boolean;
27
+ isOnlyInMarketRangeShown: boolean;
28
+ realties: number[];
29
+ realtyParams:
30
+ | any[]
31
+ | {
32
+ address?: string;
33
+ area?: number;
34
+ floor?: number;
35
+ lat?: number;
36
+ lng?: number;
37
+ price?: number;
38
+ roomsNumber?: number;
39
+ };
40
+ serviceRequest: Partial<ServiceRequest> & Required<Pick<ServiceRequest, 'id'>>;
41
+
42
+ calculationData?: {
43
+ active: Stats;
44
+ concurrencyLevel: ValuationConcurrency;
45
+ inventoryPerBuyer: number;
46
+ sold: Stats;
47
+ };
48
+ comment?: string;
49
+ filter?: {
50
+ address?: string;
51
+ area?: { from?: number; to?: number };
52
+ floor?: { from?: number; to?: number };
53
+ floorsNumber?: { from: number; to: number };
54
+ isShortDateRange?: boolean;
55
+ roomsNumber?: number[];
56
+ };
57
+ };
@@ -18,10 +18,13 @@ export * from './Realty';
18
18
  export * from './RealtyOffer';
19
19
  export * from './ServiceRequest';
20
20
  export * from './ServiceRequestActivity';
21
+ export * from './ServiceRequestSellerReport';
21
22
  export * from './ServiceRequestShortInfo';
22
23
  export * from './ServiceRequestCategorizedFile';
23
24
  export * from './Shape';
25
+ export * from './SoldStatistic';
24
26
  export * from './Task';
25
27
  export * from './User';
26
28
  export * from './UserCase';
27
29
  export * from './UserPhone';
30
+ export * from './Valuation';
@@ -13,6 +13,7 @@ export * from './realty/createRealtyHouseHighwayDistance';
13
13
  export * from './realty/createRealtyImage';
14
14
  export * from './realty/createRealtyMetroDistance';
15
15
  export * from './realty/deleteRealtyImage';
16
+ export * from './realty/findRealties';
16
17
  export * from './realty/findRealtyById';
17
18
  export * from './realty/updateRealty';
18
19
  export * from './realty/updateRealtyHouseHighwayDistance';
@@ -0,0 +1,105 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import qs from 'qs';
3
+ import {
4
+ Realty,
5
+ Address,
6
+ AddressBTIParams,
7
+ Complex,
8
+ RealtyImage,
9
+ Image,
10
+ RealtyHouseHighwayDistance,
11
+ RealtyMetroDistance,
12
+ RealtyType,
13
+ } from '../../../types';
14
+
15
+ type SuccessData = {
16
+ data: Realty[];
17
+ included?: Array<
18
+ Address | AddressBTIParams | Complex | RealtyImage | Image | RealtyHouseHighwayDistance | RealtyMetroDistance
19
+ >;
20
+ meta: { page: { offset: number; count: number; total: number } };
21
+ errors: never;
22
+ };
23
+ type ErrorData = {
24
+ data: never;
25
+ included: never;
26
+ meta: never;
27
+ errors: Array<{ source?: { parameter: string }; detail: string; description?: string }>;
28
+ };
29
+
30
+ type ResultData = {
31
+ ids: string[];
32
+ byId: Record<string, Realty>;
33
+ meta: SuccessData['meta'];
34
+ included?: SuccessData['included'];
35
+ };
36
+ type ResultError = ErrorData['errors'];
37
+
38
+ export type FindRealtiesInclude =
39
+ | 'address.bti'
40
+ | 'complex'
41
+ | 'metroDistance.metroStation'
42
+ | 'address.metroDistance.metroStation'
43
+ | 'highwayDistance.highway'
44
+ | 'realtyImage.image';
45
+
46
+ export type FindRealtiesParams = {
47
+ include?: Array<FindRealtiesInclude>;
48
+ filter?: {
49
+ id?: number | number[] | string | string[];
50
+ realtyType?: RealtyType;
51
+ district?: string;
52
+ cityArea?: string;
53
+ isHomeapp?: boolean;
54
+ isSold?: boolean;
55
+ 'address.fullAddress'?: string;
56
+ roomCount?: number;
57
+ floor?: number;
58
+ price?: { from?: number; to?: number };
59
+ coordinates?: {
60
+ 'topLeft.lat'?: number;
61
+ 'topLeft.lng'?: number;
62
+ 'bottomRight.lat'?: number;
63
+ 'bottomRight.lng'?: number;
64
+ };
65
+ };
66
+ page?: { offset?: number; limit?: number };
67
+ };
68
+ export type FindRealtiesHeaders = { 'x-auth-hc'?: string };
69
+ export type FindRealtiesData = AxiosResponse<ResultData>;
70
+ export type FindRealtiesError = AxiosError<ResultError>;
71
+ export type FindRealtiesConfig = {
72
+ baseURL?: string;
73
+ params?: FindRealtiesParams;
74
+ headers?: FindRealtiesHeaders;
75
+ };
76
+
77
+ export function findRealtiesRequest({ baseURL = 'https://clients.homeapp.ru', params, headers }: FindRealtiesConfig) {
78
+ return axios
79
+ .get('/api/v2/realty', {
80
+ baseURL,
81
+ params,
82
+ paramsSerializer: params => qs.stringify(params, { arrayFormat: 'comma', skipNulls: true }),
83
+ headers: { Accept: 'application/vnd.api+json', ...headers },
84
+ transformResponse: [
85
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
86
+ (data: SuccessData | ErrorData): ResultData | ResultError => {
87
+ if (data.errors) return data.errors;
88
+
89
+ const ids: ResultData['ids'] = [];
90
+ const byId: ResultData['byId'] = {};
91
+
92
+ data.data.forEach(entity => {
93
+ byId[entity.id] = entity;
94
+ ids.push(entity.id);
95
+ });
96
+
97
+ return { ids, byId, included: data.included, meta: data.meta };
98
+ },
99
+ ],
100
+ })
101
+ .then((res: FindRealtiesData) => res)
102
+ .catch((err: FindRealtiesError) => {
103
+ throw err;
104
+ });
105
+ }
@@ -25,6 +25,7 @@ type SuccessData = {
25
25
  consistency?: Array<{ message: string; fields: string[] }>;
26
26
  realtyAccess?: Array<FindRealtyByIdDataMetaRealtyAccess>;
27
27
  updatedAt?: string;
28
+ serviceRequestId?: number;
28
29
  };
29
30
  };
30
31
  included?: Array<
@@ -67,6 +67,10 @@ export class Api {
67
67
  return api.deleteRealtyImageRequest({ urlParams, headers, baseURL: this.baseURL });
68
68
  };
69
69
 
70
+ findRealties = (params: api.FindRealtiesParams, headers?: api.FindRealtiesHeaders) => {
71
+ return api.findRealtiesRequest({ params, headers, baseURL: this.baseURL });
72
+ };
73
+
70
74
  findRealtyById = (
71
75
  urlParams: api.FindRealtyByIdUrlParams,
72
76
  params: api.FindRealtyByIdParams,