@hapl/api-queries 0.1.114 → 0.1.115

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 (28) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api-queries.cjs.development.js +111 -21
  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 +111 -21
  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 +2 -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/index.d.ts +2 -0
  13. package/dist/clients/v1/types/ServiceRequestSellerReport.d.ts +20 -0
  14. package/dist/clients/v1/types/SoldStatistic.d.ts +9 -0
  15. package/dist/clients/v1/types/User.d.ts +1 -0
  16. package/dist/clients/v1/types/index.d.ts +2 -0
  17. package/dist/clients/v2/api/realty/findRealtyById/index.d.ts +1 -0
  18. package/package.json +1 -1
  19. package/src/clients/v1/api/experts/findExperts/index.ts +33 -29
  20. package/src/clients/v1/api/index.ts +3 -0
  21. package/src/clients/v1/api/serviceRequest/findServiceRequestSellerReport/index.ts +62 -0
  22. package/src/clients/v1/api/sold/findSoldStatistic/index.ts +35 -0
  23. package/src/clients/v1/index.ts +14 -0
  24. package/src/clients/v1/types/ServiceRequestSellerReport.ts +20 -0
  25. package/src/clients/v1/types/SoldStatistic.ts +10 -0
  26. package/src/clients/v1/types/User.ts +1 -0
  27. package/src/clients/v1/types/index.ts +2 -0
  28. package/src/clients/v2/api/realty/findRealtyById/index.ts +1 -0
@@ -1,34 +1,39 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
1
2
  import { User } from '../../../types';
3
+ declare type ErrorData = {
4
+ success: false;
5
+ data: {
6
+ error: string;
7
+ };
8
+ };
9
+ declare type ResultData = {
10
+ ids: number[];
11
+ byId: Record<string, Partial<User> & {
12
+ id: number;
13
+ }>;
14
+ meta: {
15
+ total: number;
16
+ };
17
+ };
18
+ declare type ResultError = ErrorData['data']['error'];
2
19
  export declare type FindExpertsParams = {
3
20
  filter?: {
4
21
  id?: number | number[];
5
22
  };
6
23
  limits?: {
7
- page: number;
8
- count: number;
24
+ page?: number;
25
+ count: number | 'all';
9
26
  };
10
27
  sorting?: {
11
28
  direction: 'asc' | 'desc';
12
29
  type: 'id' | 'createdAt';
13
30
  };
14
31
  };
15
- export declare type FindExpertsData = {
16
- data: {
17
- ids: number[];
18
- byId: Record<string, Partial<User> & {
19
- id: number;
20
- }>;
21
- };
22
- meta: {
23
- total: number;
24
- };
25
- };
26
- export declare type FindExpertsError = {
27
- status: number;
28
- data: string;
29
- };
32
+ export declare type FindExpertsData = AxiosResponse<ResultData>;
33
+ export declare type FindExpertsError = AxiosError<ResultError>;
30
34
  export declare type FindExpertsConfig = {
31
35
  baseURL?: string;
32
36
  params: FindExpertsParams;
33
37
  };
34
38
  export declare function findExpertsRequest({ baseURL, params }: FindExpertsConfig): Promise<FindExpertsData>;
39
+ export {};
@@ -43,6 +43,7 @@ export * from './serviceRequest/findServiceRequestActivities';
43
43
  export * from './serviceRequest/findServiceRequestById';
44
44
  export * from './serviceRequest/findServiceRequestDuplicates';
45
45
  export * from './serviceRequest/findServiceRequests';
46
+ export * from './serviceRequest/findServiceRequestSellerReport';
46
47
  export * from './serviceRequest/findServiceRequestShortInfo';
47
48
  export * from './serviceRequest/findServiceRequestShortInfoById';
48
49
  export * from './serviceRequest/findServiceRequestShortInfoByDealId';
@@ -52,6 +53,7 @@ export * from './serviceRequest/returnDeferredServiceRequest';
52
53
  export * from './serviceRequest/sendServiceRequestToModeration';
53
54
  export * from './serviceRequest/startServiceRequestModeration';
54
55
  export * from './serviceRequest/startServiceRequestModerationForOldRealty';
56
+ export * from './sold/findSoldStatistic';
55
57
  export * from './users/createUser';
56
58
  export * from './users/findUsers';
57
59
  export * from './users/findUserById';
@@ -0,0 +1,42 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { ServiceRequestSellerReport } from '../../../types';
3
+ declare type ErrorData = {
4
+ success: false;
5
+ data: {
6
+ error: string;
7
+ };
8
+ };
9
+ declare type ResultData = {
10
+ ids: string[];
11
+ byId: Record<string, ServiceRequestSellerReport>;
12
+ meta: {
13
+ total: number;
14
+ };
15
+ };
16
+ declare type ResultError = ErrorData['data']['error'];
17
+ export declare type FindServiceRequestSellerReportParams = {
18
+ sorting?: {
19
+ type: 'createdAt';
20
+ direction: 'asc' | 'desc';
21
+ };
22
+ limits?: {
23
+ page?: number;
24
+ count?: number | 'all';
25
+ };
26
+ };
27
+ export declare type FindServiceRequestSellerReportUrlParams = {
28
+ id: number;
29
+ };
30
+ export declare type FindServiceRequestSellerReportHeaders = {
31
+ 'x-auth-hc': string;
32
+ };
33
+ export declare type FindServiceRequestSellerReportData = AxiosResponse<ResultData>;
34
+ export declare type FindServiceRequestSellerReportError = AxiosError<ResultError>;
35
+ export declare type FindServiceRequestSellerReportConfig = {
36
+ baseURL?: string;
37
+ urlParams: FindServiceRequestSellerReportUrlParams;
38
+ params: FindServiceRequestSellerReportParams;
39
+ headers?: FindServiceRequestSellerReportHeaders;
40
+ };
41
+ export declare function findServiceRequestSellerReportRequest({ baseURL, urlParams, headers, params, }: FindServiceRequestSellerReportConfig): Promise<FindServiceRequestSellerReportData>;
42
+ export {};
@@ -0,0 +1,25 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { SoldStatistic } from '../../../types';
3
+ declare type SuccessData = {
4
+ success: true;
5
+ data: SoldStatistic[];
6
+ };
7
+ declare type ErrorData = {
8
+ success: false;
9
+ data: {
10
+ error: string;
11
+ };
12
+ };
13
+ declare type ResultData = SuccessData['data'];
14
+ declare type ResultError = ErrorData['data']['error'];
15
+ export declare type FindSoldStatisticHeaders = {
16
+ 'x-auth-hc'?: string;
17
+ };
18
+ export declare type FindSoldStatisticData = AxiosResponse<ResultData>;
19
+ export declare type FindSoldStatisticError = AxiosError<ResultError>;
20
+ export declare type FindSoldStatisticConfig = {
21
+ baseURL?: string;
22
+ headers?: FindSoldStatisticHeaders;
23
+ };
24
+ export declare function findSoldStatisticRequest({ baseURL, headers }: FindSoldStatisticConfig): Promise<FindSoldStatisticData>;
25
+ export {};
@@ -56,6 +56,8 @@ export declare class Api {
56
56
  returnDeferredServiceRequest: (body: api.ReturnDeferredServiceRequestBody, headers: api.ReturnDeferredServiceRequestHeaders) => Promise<api.ReturnDeferredServiceRequestData>;
57
57
  startServiceRequestModeration: (urlParams: api.StartServiceRequestModerationUrlParams, headers: api.StartServiceRequestModerationHeaders) => Promise<api.StartServiceRequestModerationData>;
58
58
  startServiceRequestModerationForOldRealty: (urlParams: api.StartServiceRequestModerationForOldRealtyUrlParams, headers: api.StartServiceRequestModerationForOldRealtyHeaders) => Promise<api.StartServiceRequestModerationForOldRealtyData>;
59
+ findServiceRequestSellerReport: (urlParams: api.FindServiceRequestSellerReportUrlParams, params: api.FindServiceRequestSellerReportParams, headers: api.FindServiceRequestSellerReportHeaders) => Promise<api.FindServiceRequestSellerReportData>;
60
+ findSoldStatistic: (headers?: api.FindSoldStatisticHeaders | undefined) => Promise<api.FindSoldStatisticData>;
59
61
  findTasks: (params: api.FindTasksParams, headers: api.FindTasksHeaders) => Promise<api.FindTasksData>;
60
62
  createUser: (body: api.CreateUserBody, headers: api.CreateUserHeaders) => Promise<api.CreateUserData>;
61
63
  findUsers: (params: api.FindUsersParams, headers: api.FindUsersHeaders) => Promise<api.FindUsersData>;
@@ -0,0 +1,20 @@
1
+ export declare 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,9 @@
1
+ export declare enum SoldStatisticTypes {
2
+ House = "house",
3
+ FlatNew = "flat_new",
4
+ FlatSecondary = "flat_secondary"
5
+ }
6
+ export declare type SoldStatistic = {
7
+ type: SoldStatisticTypes;
8
+ price: number;
9
+ };
@@ -143,4 +143,5 @@ export declare type User = {
143
143
  patronymic?: string;
144
144
  supervisor?: User;
145
145
  updatedAt?: string;
146
+ fullNameTranslit?: string;
146
147
  };
@@ -18,9 +18,11 @@ 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';
@@ -16,6 +16,7 @@ declare type SuccessData = {
16
16
  }>;
17
17
  realtyAccess?: Array<FindRealtyByIdDataMetaRealtyAccess>;
18
18
  updatedAt?: string;
19
+ serviceRequestId?: number;
19
20
  };
20
21
  };
21
22
  included?: Array<Address | AddressBTIParams | Complex | RealtyImage | Image | RealtyHouseHighwayDistance | RealtyMetroDistance>;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.114",
2
+ "version": "0.1.115",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -1,49 +1,53 @@
1
- import axios, { AxiosResponse, AxiosError } from 'axios';
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
2
  import { User } from '../../../types';
3
+ import qs from 'qs';
3
4
 
4
5
  type SuccessData = {
5
6
  success: true;
6
7
  data: Partial<User> & { id: number }[];
7
8
  pageParams: { page: number; length: number };
8
9
  };
9
-
10
10
  type ErrorData = { success: false; data: { error: string } };
11
11
 
12
+ type ResultData = { ids: number[]; byId: Record<string, Partial<User> & { id: number }>; meta: { total: number } };
13
+ type ResultError = ErrorData['data']['error'];
14
+
12
15
  export type FindExpertsParams = {
13
16
  filter?: { id?: number | number[] };
14
- limits?: { page: number; count: number };
17
+ limits?: { page?: number; count: number | 'all' };
15
18
  sorting?: { direction: 'asc' | 'desc'; type: 'id' | 'createdAt' };
16
19
  };
17
20
 
18
- export type FindExpertsData = {
19
- data: { ids: number[]; byId: Record<string, Partial<User> & { id: number }> };
20
- meta: { total: number };
21
- };
22
-
23
- export type FindExpertsError = { status: number; data: string };
24
-
21
+ export type FindExpertsData = AxiosResponse<ResultData>;
22
+ export type FindExpertsError = AxiosError<ResultError>;
25
23
  export type FindExpertsConfig = { baseURL?: string; params: FindExpertsParams };
26
24
 
27
25
  export function findExpertsRequest({ baseURL = 'https://clients.homeapp.ru', params }: FindExpertsConfig) {
28
26
  return axios
29
- .get('/api/experts', { baseURL, params, headers: { Accept: 'application/json' } })
30
- .then(
31
- (res: AxiosResponse<SuccessData>): FindExpertsData => {
32
- const data: FindExpertsData = { data: { byId: {}, ids: [] }, meta: { total: res.data.pageParams.length } };
33
-
34
- res.data.data.forEach(entity => {
35
- data.data.byId[entity.id] = entity;
36
- data.data.ids.push(entity.id);
37
- });
38
-
39
- return data;
40
- }
41
- )
42
- .catch((err: AxiosError<ErrorData>) => {
43
- const error: Error & Partial<FindExpertsError> = new Error(err.message);
44
- error.status = err.response?.status ?? 520;
45
- error.data = err.response?.data.data.error ?? 'Unknown Error';
46
-
47
- throw error;
27
+ .get('/api/experts', {
28
+ baseURL,
29
+ params,
30
+ paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
31
+ headers: { Accept: 'application/json' },
32
+ transformResponse: [
33
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
34
+ (data: SuccessData | ErrorData): ResultData | ResultError => {
35
+ if (!data.success) return data.data.error;
36
+
37
+ const ids: ResultData['ids'] = [];
38
+ const byId: ResultData['byId'] = {};
39
+
40
+ data.data.forEach(entity => {
41
+ byId[entity.id] = entity;
42
+ ids.push(entity.id);
43
+ });
44
+
45
+ return { ids, byId, meta: { total: data.pageParams.length } };
46
+ },
47
+ ],
48
+ })
49
+ .then((res: FindExpertsData) => res)
50
+ .catch((err: FindExpertsError) => {
51
+ throw err;
48
52
  });
49
53
  }
@@ -51,6 +51,7 @@ export * from './serviceRequest/findServiceRequestActivities';
51
51
  export * from './serviceRequest/findServiceRequestById';
52
52
  export * from './serviceRequest/findServiceRequestDuplicates';
53
53
  export * from './serviceRequest/findServiceRequests';
54
+ export * from './serviceRequest/findServiceRequestSellerReport';
54
55
  export * from './serviceRequest/findServiceRequestShortInfo';
55
56
  export * from './serviceRequest/findServiceRequestShortInfoById';
56
57
  export * from './serviceRequest/findServiceRequestShortInfoByDealId';
@@ -61,6 +62,8 @@ export * from './serviceRequest/sendServiceRequestToModeration';
61
62
  export * from './serviceRequest/startServiceRequestModeration';
62
63
  export * from './serviceRequest/startServiceRequestModerationForOldRealty';
63
64
 
65
+ export * from './sold/findSoldStatistic';
66
+
64
67
  export * from './users/createUser';
65
68
  export * from './users/findUsers';
66
69
  export * from './users/findUserById';
@@ -0,0 +1,62 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import { ServiceRequestSellerReport } from '../../../types';
3
+ import qs from 'qs';
4
+
5
+ type SuccessData = { success: true; data: ServiceRequestSellerReport[]; pageParams: { page: number; length: number } };
6
+ type ErrorData = { success: false; data: { error: string } };
7
+
8
+ type ResultData = { ids: string[]; byId: Record<string, ServiceRequestSellerReport>; meta: { total: number } };
9
+ type ResultError = ErrorData['data']['error'];
10
+
11
+ export type FindServiceRequestSellerReportParams = {
12
+ sorting?: {
13
+ type: 'createdAt';
14
+ direction: 'asc' | 'desc';
15
+ };
16
+ limits?: { page?: number; count?: number | 'all' };
17
+ };
18
+ export type FindServiceRequestSellerReportUrlParams = { id: number };
19
+ export type FindServiceRequestSellerReportHeaders = { 'x-auth-hc': string };
20
+ export type FindServiceRequestSellerReportData = AxiosResponse<ResultData>;
21
+ export type FindServiceRequestSellerReportError = AxiosError<ResultError>;
22
+ export type FindServiceRequestSellerReportConfig = {
23
+ baseURL?: string;
24
+ urlParams: FindServiceRequestSellerReportUrlParams;
25
+ params: FindServiceRequestSellerReportParams;
26
+ headers?: FindServiceRequestSellerReportHeaders;
27
+ };
28
+
29
+ export function findServiceRequestSellerReportRequest({
30
+ baseURL = 'https://clients.homeapp.ru',
31
+ urlParams,
32
+ headers,
33
+ params,
34
+ }: FindServiceRequestSellerReportConfig) {
35
+ return axios
36
+ .get(`/api/service-request/${urlParams.id}/report-for-seller`, {
37
+ baseURL,
38
+ params,
39
+ paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
40
+ headers: { Accept: 'application/json', ...headers },
41
+ transformResponse: [
42
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
43
+ (data: SuccessData | ErrorData): ResultData | ResultError => {
44
+ if (!data.success) return data.data.error;
45
+
46
+ const ids: ResultData['ids'] = [];
47
+ const byId: ResultData['byId'] = {};
48
+
49
+ data.data.forEach(entity => {
50
+ byId[entity.id] = entity;
51
+ ids.push(entity.id);
52
+ });
53
+
54
+ return { ids, byId, meta: { total: data.pageParams.length } };
55
+ },
56
+ ],
57
+ })
58
+ .then((res: FindServiceRequestSellerReportData) => res)
59
+ .catch((err: FindServiceRequestSellerReportError) => {
60
+ throw err;
61
+ });
62
+ }
@@ -0,0 +1,35 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import { SoldStatistic } from '../../../types';
3
+
4
+ type SuccessData = {
5
+ success: true;
6
+ data: SoldStatistic[];
7
+ };
8
+ type ErrorData = { success: false; data: { error: string } };
9
+
10
+ type ResultData = SuccessData['data'];
11
+ type ResultError = ErrorData['data']['error'];
12
+
13
+ export type FindSoldStatisticHeaders = { 'x-auth-hc'?: string };
14
+ export type FindSoldStatisticData = AxiosResponse<ResultData>;
15
+ export type FindSoldStatisticError = AxiosError<ResultError>;
16
+ export type FindSoldStatisticConfig = {
17
+ baseURL?: string;
18
+ headers?: FindSoldStatisticHeaders;
19
+ };
20
+
21
+ export function findSoldStatisticRequest({ baseURL = 'https://clients.homeapp.ru', headers }: FindSoldStatisticConfig) {
22
+ return axios
23
+ .get('/api/sold/statistic', {
24
+ baseURL,
25
+ headers: { Accept: 'application/json', ...headers },
26
+ transformResponse: [
27
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
28
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
29
+ ],
30
+ })
31
+ .then((res: FindSoldStatisticData) => res)
32
+ .catch((err: FindSoldStatisticError) => {
33
+ throw err;
34
+ });
35
+ }
@@ -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) => {
@@ -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
  };
@@ -18,9 +18,11 @@ 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';
@@ -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<