@hapl/api-queries 0.1.147 → 0.1.148

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.
@@ -0,0 +1,96 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { ContractStatus, Deal, DealStatus, RealtyType } 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, Deal>;
12
+ meta: {
13
+ total: number;
14
+ plannedCommissionSum: number;
15
+ receivedCommissionSum: number;
16
+ };
17
+ };
18
+ declare type ResultError = ErrorData['data']['error'];
19
+ export declare type FindDealsParams = {
20
+ filter?: {
21
+ actSignedAt?: {
22
+ from?: string;
23
+ to?: string;
24
+ };
25
+ address?: string;
26
+ 'contract.serviceRequest.curator.office'?: string;
27
+ 'contract.serviceRequest.id'?: number;
28
+ 'contract.serviceRequest.investBuyoutDeal.id'?: 'notnull' | number;
29
+ 'contract.serviceRequest.realtyType'?: RealtyType;
30
+ 'contract.signedAt'?: {
31
+ from?: string;
32
+ to?: string;
33
+ };
34
+ 'contract.status'?: ContractStatus;
35
+ commonId?: string;
36
+ createdAt?: {
37
+ from?: string;
38
+ to?: string;
39
+ };
40
+ dealDoneAt?: {
41
+ from?: string;
42
+ to?: string;
43
+ };
44
+ dealSignedAt?: {
45
+ from?: string;
46
+ to?: string;
47
+ };
48
+ 'expert.id'?: number;
49
+ 'expert.supervisor.id'?: number;
50
+ hasPassedDate?: boolean;
51
+ hasPrepayment?: boolean;
52
+ id?: number | number[];
53
+ isInvestBuyout?: boolean;
54
+ isLawyerRequired?: boolean;
55
+ 'lawyer.id'?: number;
56
+ lawyerNotRequiredReason?: string;
57
+ prepaidAt?: {
58
+ from?: string;
59
+ to?: string;
60
+ };
61
+ prepaymentPlannedAt?: {
62
+ from?: string;
63
+ to?: string;
64
+ };
65
+ registeredAt?: {
66
+ from?: string;
67
+ to?: string;
68
+ };
69
+ status?: DealStatus;
70
+ terminatedAt?: {
71
+ from?: string;
72
+ to?: string;
73
+ };
74
+ withTerminated?: boolean;
75
+ };
76
+ limits?: {
77
+ page?: number;
78
+ count: number | 'all';
79
+ };
80
+ sorting?: {
81
+ direction: 'asc' | 'desc';
82
+ type: 'commissionAt' | 'commissionPlannedAt' | 'createdAt' | 'dealDoneAt' | 'dealSignPlannedAt' | 'dealSignedAt' | 'prepaidAt' | 'prepaymentPlannedAt' | 'registerPlannedAt' | 'registeredAt' | 'terminationRequestedAt';
83
+ };
84
+ };
85
+ export declare type FindDealsHeaders = {
86
+ 'x-auth-hc': string;
87
+ };
88
+ export declare type FindDealsData = AxiosResponse<ResultData>;
89
+ export declare type FindDealsError = AxiosError<ResultError>;
90
+ export declare type FindDealsConfig = {
91
+ baseURL?: string;
92
+ headers: FindDealsHeaders;
93
+ params: FindDealsParams;
94
+ };
95
+ export declare function findDealsRequest({ baseURL, headers, params }: FindDealsConfig): Promise<FindDealsData>;
96
+ export {};
@@ -36,6 +36,7 @@ export * from './deal/createDealCategorizedFile';
36
36
  export * from './deal/createDealInvestPrepayment';
37
37
  export * from './deal/deleteDealCategorizedFile';
38
38
  export * from './deal/findDealCategorizedFiles';
39
+ export * from './deal/findDeals';
39
40
  export * from './deal/setDealDoneState';
40
41
  export * from './deal/setDealPrepaymentState';
41
42
  export * from './deal/setDealRegisteredState';
@@ -39,6 +39,7 @@ export declare class Api {
39
39
  createDealCategorizedFile: (urlParams: api.CreateDealCategorizedFileUrlParams, body: api.CreateDealCategorizedFileBody, headers: api.CreateDealCategorizedFileHeaders) => Promise<api.CreateDealCategorizedFileData>;
40
40
  createDealInvestPrepayment: (urlParams: api.CreateDealInvestPrepaymentUrlParams, body: api.CreateDealInvestPrepaymentBody, headers: api.CreateDealInvestPrepaymentHeaders) => Promise<api.CreateDealInvestPrepaymentData>;
41
41
  findDealCategorizedFiles: (urlParams: api.FindDealCategorizedFilesUrlParams, params: api.FindDealCategorizedFilesParams, headers: api.FindDealCategorizedFilesHeaders) => Promise<api.FindDealCategorizedFilesData>;
42
+ findDeals: (params: api.FindDealsParams, headers: api.FindDealsHeaders) => Promise<api.FindDealsData>;
42
43
  deleteDealCategorizedFile: (urlParams: api.DeleteDealCategorizedFileUrlParams, headers: api.DeleteDealCategorizedFileHeaders) => Promise<api.DeleteDealCategorizedFileData>;
43
44
  setDealDoneState: (urlParams: api.SetDealDoneStateUrlParams, headers: api.SetDealDoneStateHeaders) => Promise<api.SetDealDoneStateData>;
44
45
  setDealPrepaymentState: (urlParams: api.SetDealPrepaymentStateUrlParams, body: api.SetDealPrepaymentStateBody, headers: api.SetDealPrepaymentStateHeaders) => Promise<api.SetDealPrepaymentStateData>;
@@ -23,35 +23,32 @@ export declare enum DealStatus {
23
23
  Terminated = "terminated"
24
24
  }
25
25
  export declare type Deal = {
26
- id: number;
27
- createdAt: string;
28
- status: DealStatus;
26
+ buyer: Partial<Buyer> & Required<Pick<Buyer, 'id'>>;
29
27
  canBeDealDone?: boolean;
30
- finalPrice: number;
31
28
  contract?: Partial<Contract> & Required<Pick<Contract, 'id'>>;
32
- hasPrepayment: boolean;
33
- plannedCommission: number;
29
+ createdAt: string;
34
30
  developerCommission: number;
35
- partnerCommission: number;
36
- receivedCommission: number;
37
- buyer: Partial<Buyer> & Required<Pick<Buyer, 'id'>>;
31
+ finalPrice: number;
32
+ hasPrepayment: boolean;
33
+ id: number;
38
34
  incomes: Array<Partial<Income> & Required<Pick<Income, 'id'>>>;
39
35
  participants: Array<Partial<DealParticipant> & Required<Pick<DealParticipant, 'id'>>>;
36
+ partnerCommission: number;
37
+ plannedCommission: number;
38
+ receivedCommission: number;
39
+ status: DealStatus;
40
+ actSignedAt?: string;
40
41
  comment?: string;
41
- lawyer?: Partial<User> & Required<Pick<User, 'id'>>;
42
+ commissionAt?: string;
43
+ commissionPlannedAt?: string;
44
+ dealDoneAt?: string;
45
+ dealSingedAt?: string;
46
+ dealSignPlannedAt?: string;
47
+ dealSignedAt?: string;
42
48
  files?: Array<Partial<File> & Required<Pick<File, 'id'>>>;
43
49
  filesInDeal?: {
44
50
  id: number;
45
51
  };
46
- updatedAt?: string;
47
- dealSignPlannedAt?: string;
48
- commissionPlannedAt?: string;
49
- registerPlannedAt?: string;
50
- prepaidAt?: string;
51
- registeredAt?: string;
52
- dealSingedAt?: string;
53
- dealDoneAt?: string;
54
- terminatedAt?: string;
55
52
  invest?: {
56
53
  isInvestBuyout?: boolean;
57
54
  investBuyoutPrepaymentSum?: number;
@@ -60,4 +57,14 @@ export declare type Deal = {
60
57
  id: number;
61
58
  };
62
59
  };
60
+ isLawyerRequired?: string;
61
+ lawyer?: Partial<User> & Required<Pick<User, 'id'>>;
62
+ lawyerNotRequiredReason?: DealNoLawyerReason;
63
+ prepaidAt?: string;
64
+ prepaymentPlannedAt?: string;
65
+ registerPlannedAt?: string;
66
+ registeredAt?: string;
67
+ terminatedAt?: string;
68
+ terminationRequestedAt?: string;
69
+ updatedAt?: string;
63
70
  };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.147",
2
+ "version": "0.1.148",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -0,0 +1,105 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import qs from 'qs';
3
+ import { ContractStatus, Deal, DealStatus, RealtyType } from '../../../types';
4
+
5
+ type SuccessData = {
6
+ success: true;
7
+ data: Deal[];
8
+ meta: { plannedCommissionSum: number; receivedCommissionSum: number };
9
+ pageParams: { page: number; length: number };
10
+ };
11
+ type ErrorData = { success: false; data: { error: string } };
12
+
13
+ type ResultData = {
14
+ ids: number[];
15
+ byId: Record<string, Deal>;
16
+ meta: { total: number; plannedCommissionSum: number; receivedCommissionSum: number };
17
+ };
18
+ type ResultError = ErrorData['data']['error'];
19
+
20
+ export type FindDealsParams = {
21
+ filter?: {
22
+ actSignedAt?: { from?: string; to?: string };
23
+ address?: string;
24
+ 'contract.serviceRequest.curator.office'?: string;
25
+ 'contract.serviceRequest.id'?: number;
26
+ 'contract.serviceRequest.investBuyoutDeal.id'?: 'notnull' | number;
27
+ 'contract.serviceRequest.realtyType'?: RealtyType;
28
+ 'contract.signedAt'?: { from?: string; to?: string };
29
+ 'contract.status'?: ContractStatus;
30
+ commonId?: string;
31
+ createdAt?: { from?: string; to?: string };
32
+ dealDoneAt?: { from?: string; to?: string };
33
+ dealSignedAt?: { from?: string; to?: string };
34
+ 'expert.id'?: number;
35
+ 'expert.supervisor.id'?: number;
36
+ hasPassedDate?: boolean;
37
+ hasPrepayment?: boolean;
38
+ id?: number | number[];
39
+ isInvestBuyout?: boolean;
40
+ isLawyerRequired?: boolean;
41
+ 'lawyer.id'?: number;
42
+ lawyerNotRequiredReason?: string;
43
+ prepaidAt?: { from?: string; to?: string };
44
+ prepaymentPlannedAt?: { from?: string; to?: string };
45
+ registeredAt?: { from?: string; to?: string };
46
+ status?: DealStatus;
47
+ terminatedAt?: { from?: string; to?: string };
48
+ withTerminated?: boolean;
49
+ };
50
+ limits?: { page?: number; count: number | 'all' };
51
+ sorting?: {
52
+ direction: 'asc' | 'desc';
53
+ type:
54
+ | 'commissionAt'
55
+ | 'commissionPlannedAt'
56
+ | 'createdAt'
57
+ | 'dealDoneAt'
58
+ | 'dealSignPlannedAt'
59
+ | 'dealSignedAt'
60
+ | 'prepaidAt'
61
+ | 'prepaymentPlannedAt'
62
+ | 'registerPlannedAt'
63
+ | 'registeredAt'
64
+ | 'terminationRequestedAt';
65
+ };
66
+ };
67
+
68
+ export type FindDealsHeaders = { 'x-auth-hc': string };
69
+ export type FindDealsData = AxiosResponse<ResultData>;
70
+ export type FindDealsError = AxiosError<ResultError>;
71
+ export type FindDealsConfig = {
72
+ baseURL?: string;
73
+ headers: FindDealsHeaders;
74
+ params: FindDealsParams;
75
+ };
76
+
77
+ export function findDealsRequest({ baseURL = 'https://clients.homeapp.ru', headers, params }: FindDealsConfig) {
78
+ return axios
79
+ .get('/api/deal', {
80
+ baseURL,
81
+ params,
82
+ paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
83
+ headers: { Accept: 'application/json', ...headers },
84
+ transformResponse: [
85
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
86
+ (data: SuccessData | ErrorData): ResultData | ResultError => {
87
+ if (!data.success) return data.data.error;
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, meta: { ...data.meta, total: data.pageParams.length } };
98
+ },
99
+ ],
100
+ })
101
+ .then((res: FindDealsData) => res)
102
+ .catch((err: FindDealsError) => {
103
+ throw err;
104
+ });
105
+ }
@@ -44,6 +44,7 @@ export * from './deal/createDealCategorizedFile';
44
44
  export * from './deal/createDealInvestPrepayment';
45
45
  export * from './deal/deleteDealCategorizedFile';
46
46
  export * from './deal/findDealCategorizedFiles';
47
+ export * from './deal/findDeals';
47
48
  export * from './deal/setDealDoneState';
48
49
  export * from './deal/setDealPrepaymentState';
49
50
  export * from './deal/setDealRegisteredState';
@@ -218,6 +218,10 @@ export class Api {
218
218
  return api.findDealCategorizedFilesRequest({ urlParams, params, headers, baseURL: this.baseURL });
219
219
  };
220
220
 
221
+ findDeals = (params: api.FindDealsParams, headers: api.FindDealsHeaders) => {
222
+ return api.findDealsRequest({ params, headers, baseURL: this.baseURL });
223
+ };
224
+
221
225
  deleteDealCategorizedFile = (
222
226
  urlParams: api.DeleteDealCategorizedFileUrlParams,
223
227
  headers: api.DeleteDealCategorizedFileHeaders
@@ -27,37 +27,44 @@ export enum DealStatus {
27
27
  }
28
28
 
29
29
  export type Deal = {
30
- id: number;
31
- createdAt: string;
32
- status: DealStatus;
30
+ buyer: Partial<Buyer> & Required<Pick<Buyer, 'id'>>;
33
31
  canBeDealDone?: boolean;
34
- finalPrice: number;
35
32
  contract?: Partial<Contract> & Required<Pick<Contract, 'id'>>;
36
- hasPrepayment: boolean;
37
- plannedCommission: number;
33
+ createdAt: string;
38
34
  developerCommission: number;
39
- partnerCommission: number;
40
- receivedCommission: number;
41
- buyer: Partial<Buyer> & Required<Pick<Buyer, 'id'>>;
35
+ finalPrice: number;
36
+ hasPrepayment: boolean;
37
+ id: number;
42
38
  incomes: Array<Partial<Income> & Required<Pick<Income, 'id'>>>;
43
39
  participants: Array<Partial<DealParticipant> & Required<Pick<DealParticipant, 'id'>>>;
40
+ partnerCommission: number;
41
+ plannedCommission: number;
42
+ receivedCommission: number;
43
+ status: DealStatus;
44
+ actSignedAt?: string;
44
45
  comment?: string;
45
- lawyer?: Partial<User> & Required<Pick<User, 'id'>>;
46
- files?: Array<Partial<File> & Required<Pick<File, 'id'>>>;
47
- filesInDeal?: { id: number };
48
- updatedAt?: string;
49
- dealSignPlannedAt?: string;
46
+ commissionAt?: string;
50
47
  commissionPlannedAt?: string;
51
- registerPlannedAt?: string;
52
- prepaidAt?: string;
53
- registeredAt?: string;
54
- dealSingedAt?: string;
55
48
  dealDoneAt?: string;
56
- terminatedAt?: string;
49
+ dealSingedAt?: string;
50
+ dealSignPlannedAt?: string;
51
+ dealSignedAt?: string;
52
+ files?: Array<Partial<File> & Required<Pick<File, 'id'>>>;
53
+ filesInDeal?: { id: number };
57
54
  invest?: {
58
55
  isInvestBuyout?: boolean;
59
56
  investBuyoutPrepaymentSum?: number;
60
57
  investBuyoutPrepaymentAt?: string;
61
58
  investSellServiceRequest?: { id: number };
62
59
  };
60
+ isLawyerRequired?: string;
61
+ lawyer?: Partial<User> & Required<Pick<User, 'id'>>;
62
+ lawyerNotRequiredReason?: DealNoLawyerReason;
63
+ prepaidAt?: string;
64
+ prepaymentPlannedAt?: string;
65
+ registerPlannedAt?: string;
66
+ registeredAt?: string;
67
+ terminatedAt?: string;
68
+ terminationRequestedAt?: string;
69
+ updatedAt?: string;
63
70
  };