@hapl/api-queries 0.1.190 → 0.1.191
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/CHANGELOG.md +13 -0
- package/dist/api-queries.cjs.development.js +51 -0
- package/dist/api-queries.cjs.development.js.map +1 -1
- package/dist/api-queries.cjs.production.min.js +1 -1
- package/dist/api-queries.cjs.production.min.js.map +1 -1
- package/dist/api-queries.esm.js +51 -0
- package/dist/api-queries.esm.js.map +1 -1
- package/dist/clients/v1/api/event/findEvents/index.d.ts +40 -0
- package/dist/clients/v1/api/index.d.ts +1 -0
- package/dist/clients/v1/index.d.ts +1 -0
- package/dist/clients/v1/types/Event.d.ts +1 -0
- package/package.json +1 -1
- package/src/clients/v1/api/event/findEvents/index.ts +59 -0
- package/src/clients/v1/api/index.ts +1 -0
- package/src/clients/v1/index.ts +4 -0
- package/src/clients/v1/types/Event.ts +1 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AxiosResponse, AxiosError } from 'axios';
|
|
2
|
+
import { Event } from '../../../types';
|
|
3
|
+
declare type ResultData = {
|
|
4
|
+
ids: number[];
|
|
5
|
+
byId: Record<string, Event>;
|
|
6
|
+
meta: {
|
|
7
|
+
total: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
declare type ResultError = string;
|
|
11
|
+
export declare type FindEventsHeaders = {
|
|
12
|
+
'x-auth-hc'?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare type FindEventsParams = {
|
|
15
|
+
filter?: {
|
|
16
|
+
name?: string;
|
|
17
|
+
scheduledAt?: {
|
|
18
|
+
from?: string;
|
|
19
|
+
to?: string;
|
|
20
|
+
};
|
|
21
|
+
hasFiles?: boolean;
|
|
22
|
+
};
|
|
23
|
+
limits?: {
|
|
24
|
+
page?: number;
|
|
25
|
+
count?: number | 'all';
|
|
26
|
+
};
|
|
27
|
+
sorting?: {
|
|
28
|
+
type: 'id' | 'scheduledAt';
|
|
29
|
+
direction: 'asc' | 'desc';
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare type FindEventsData = AxiosResponse<ResultData>;
|
|
33
|
+
export declare type FindEventsError = AxiosError<ResultError>;
|
|
34
|
+
export declare type FindEventsConfig = {
|
|
35
|
+
baseURL?: string;
|
|
36
|
+
headers?: FindEventsHeaders;
|
|
37
|
+
params: FindEventsParams;
|
|
38
|
+
};
|
|
39
|
+
export declare function findEventsRequest({ baseURL, headers, params }: FindEventsConfig): Promise<FindEventsData>;
|
|
40
|
+
export {};
|
|
@@ -51,6 +51,7 @@ export * from './deal/setDealSignedState';
|
|
|
51
51
|
export * from './deal/terminateDeal';
|
|
52
52
|
export * from './deal/updateDeal';
|
|
53
53
|
export * from './event/findEventById';
|
|
54
|
+
export * from './event/findEvents';
|
|
54
55
|
export * from './expert/createExpertCase';
|
|
55
56
|
export * from './expert/createExpertReview';
|
|
56
57
|
export * from './expert/findExpertById';
|
|
@@ -55,6 +55,7 @@ export declare class Api {
|
|
|
55
55
|
terminateDeal: (urlParams: api.TerminateDealUrlParams, body: api.TerminateDealBody, headers: api.TerminateDealHeaders) => Promise<api.TerminateDealData>;
|
|
56
56
|
updateDeal: (urlParams: api.UpdateDealUrlParams, body: api.UpdateDealBody, headers: api.UpdateDealHeaders) => Promise<api.UpdateDealData>;
|
|
57
57
|
findEventById: (urlParams: api.FindEventByIdUrlParams, headers?: api.FindEventByIdHeaders | undefined) => Promise<api.FindEventByIdData>;
|
|
58
|
+
findEvents: (params: api.FindEventsParams, headers?: api.FindEventsHeaders | undefined) => Promise<api.FindEventsData>;
|
|
58
59
|
createExpertCase: (body: api.CreateExpertCaseBody, headers?: api.CreateExpertCaseHeaders | undefined) => Promise<api.CreateExpertCaseData>;
|
|
59
60
|
createExpertReview: (urlParams: api.CreateExpertReviewUrlParams, body: api.CreateExpertReviewBody, headers: api.CreateExpertReviewHeaders) => Promise<api.CreateExpertReviewData>;
|
|
60
61
|
findExpertById: (urlParams: api.FindExpertByIdUrlParams, headers: api.FindExpertByIdHeaders) => Promise<api.FindExpertByIdData>;
|
package/package.json
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
|
|
2
|
+
import qs from 'qs';
|
|
3
|
+
import { Event } from '../../../types';
|
|
4
|
+
|
|
5
|
+
type SuccessData = { success: true; data: Event[]; pageParams: { length: number; page: number } };
|
|
6
|
+
type ErrorData = { success: false; data: { error: string } };
|
|
7
|
+
|
|
8
|
+
type ResultData = { ids: number[]; byId: Record<string, Event>; meta: { total: number } };
|
|
9
|
+
type ResultError = string;
|
|
10
|
+
|
|
11
|
+
export type FindEventsHeaders = { 'x-auth-hc'?: string };
|
|
12
|
+
export type FindEventsParams = {
|
|
13
|
+
filter?: {
|
|
14
|
+
name?: string;
|
|
15
|
+
scheduledAt?: { from?: string; to?: string };
|
|
16
|
+
hasFiles?: boolean;
|
|
17
|
+
};
|
|
18
|
+
limits?: { page?: number; count?: number | 'all' };
|
|
19
|
+
sorting?: { type: 'id' | 'scheduledAt'; direction: 'asc' | 'desc' };
|
|
20
|
+
};
|
|
21
|
+
export type FindEventsData = AxiosResponse<ResultData>;
|
|
22
|
+
export type FindEventsError = AxiosError<ResultError>;
|
|
23
|
+
export type FindEventsConfig = {
|
|
24
|
+
baseURL?: string;
|
|
25
|
+
headers?: FindEventsHeaders;
|
|
26
|
+
params: FindEventsParams;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export function findEventsRequest({ baseURL = 'https://clients.homeapp.ru', headers, params }: FindEventsConfig) {
|
|
30
|
+
return axios
|
|
31
|
+
.get('/api/site/event', {
|
|
32
|
+
baseURL,
|
|
33
|
+
params,
|
|
34
|
+
paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
|
|
35
|
+
headers: { Accept: 'application/json', ...headers },
|
|
36
|
+
transformResponse: [
|
|
37
|
+
...(axios.defaults.transformResponse as AxiosTransformer[]),
|
|
38
|
+
(data: SuccessData | ErrorData): ResultData | ResultError => {
|
|
39
|
+
if (data.success) {
|
|
40
|
+
const ids: ResultData['ids'] = [];
|
|
41
|
+
const byId: ResultData['byId'] = {};
|
|
42
|
+
|
|
43
|
+
data.data.forEach(entity => {
|
|
44
|
+
byId[entity.id] = entity;
|
|
45
|
+
ids.push(entity.id);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return { ids, byId, meta: { total: data.pageParams.length } };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return data.data.error;
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
})
|
|
55
|
+
.then((res: FindEventsData) => res)
|
|
56
|
+
.catch((err: FindEventsError) => {
|
|
57
|
+
throw err;
|
|
58
|
+
});
|
|
59
|
+
}
|
package/src/clients/v1/index.ts
CHANGED
|
@@ -319,6 +319,10 @@ export class Api {
|
|
|
319
319
|
return api.findEventByIdRequest({ urlParams, headers, baseURL: this.baseURL });
|
|
320
320
|
};
|
|
321
321
|
|
|
322
|
+
findEvents = (params: api.FindEventsParams, headers?: api.FindEventsHeaders) => {
|
|
323
|
+
return api.findEventsRequest({ params, headers, baseURL: this.baseURL });
|
|
324
|
+
};
|
|
325
|
+
|
|
322
326
|
// expert
|
|
323
327
|
|
|
324
328
|
createExpertCase = (body: api.CreateExpertCaseBody, headers?: api.CreateExpertCaseHeaders) => {
|