@hapl/api-queries 0.1.121 → 0.1.122
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 +24 -21
- 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 +24 -21
- package/dist/api-queries.esm.js.map +1 -1
- package/dist/publisher/v1/api/findPlannedEventsRow/index.d.ts +17 -13
- package/package.json +1 -1
- package/src/publisher/v1/api/findPlannedEventsRow/index.ts +28 -32
|
@@ -1,32 +1,36 @@
|
|
|
1
|
+
import { AxiosResponse, AxiosError } from 'axios';
|
|
1
2
|
import { PlannedEventsRow } from '../../types';
|
|
3
|
+
declare type ResultData = {
|
|
4
|
+
ids: number[];
|
|
5
|
+
byId: Record<string, PlannedEventsRow>;
|
|
6
|
+
meta: {
|
|
7
|
+
total: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
declare type ResultError = string;
|
|
2
11
|
export declare type FindPlannedEventsRowHeaders = {
|
|
3
12
|
'x-auth-hc': string;
|
|
4
13
|
};
|
|
5
14
|
export declare type FindPlannedEventsRowParams = {
|
|
6
15
|
filter?: {
|
|
7
16
|
id?: number;
|
|
17
|
+
'realty.id'?: number;
|
|
18
|
+
createdAt?: {
|
|
19
|
+
from?: string;
|
|
20
|
+
to?: string;
|
|
21
|
+
};
|
|
8
22
|
};
|
|
9
23
|
limits?: {
|
|
10
24
|
page: number;
|
|
11
25
|
count: number;
|
|
12
26
|
};
|
|
13
27
|
};
|
|
14
|
-
export declare type FindPlannedEventsRowData =
|
|
15
|
-
|
|
16
|
-
ids: number[];
|
|
17
|
-
byId: Record<string, PlannedEventsRow>;
|
|
18
|
-
};
|
|
19
|
-
meta: {
|
|
20
|
-
total: number;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
export declare type FindPlannedEventsRowError = {
|
|
24
|
-
status: number;
|
|
25
|
-
data: string;
|
|
26
|
-
};
|
|
28
|
+
export declare type FindPlannedEventsRowData = AxiosResponse<ResultData>;
|
|
29
|
+
export declare type FindPlannedEventsRowError = AxiosError<ResultError>;
|
|
27
30
|
export declare type FindPlannedEventsRowConfig = {
|
|
28
31
|
baseURL?: string;
|
|
29
32
|
headers: FindPlannedEventsRowHeaders;
|
|
30
33
|
params: FindPlannedEventsRowParams;
|
|
31
34
|
};
|
|
32
35
|
export declare function findPlannedEventsRowRequest({ baseURL, headers, params, }: FindPlannedEventsRowConfig): Promise<FindPlannedEventsRowData>;
|
|
36
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
1
|
+
import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
|
|
2
2
|
import qs from 'qs';
|
|
3
3
|
import { PlannedEventsRow } from '../../types';
|
|
4
4
|
|
|
5
5
|
type SuccessData = { success: true; data: PlannedEventsRow[]; pageParams: { page: number; length: number } };
|
|
6
|
-
|
|
7
6
|
type ErrorData = { success?: false; data?: { error: string }; message?: string };
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
type ResultData = { ids: number[]; byId: Record<string, PlannedEventsRow>; meta: { total: number } };
|
|
9
|
+
type ResultError = string;
|
|
10
10
|
|
|
11
|
+
export type FindPlannedEventsRowHeaders = { 'x-auth-hc': string };
|
|
11
12
|
export type FindPlannedEventsRowParams = {
|
|
12
|
-
filter?: { id?: number };
|
|
13
|
+
filter?: { id?: number; 'realty.id'?: number; createdAt?: { from?: string; to?: string } };
|
|
13
14
|
limits?: { page: number; count: number };
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
-
export type
|
|
17
|
-
data: { ids: number[]; byId: Record<string, PlannedEventsRow> };
|
|
18
|
-
meta: { total: number };
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type FindPlannedEventsRowError = { status: number; data: string };
|
|
16
|
+
export type FindPlannedEventsRowData = AxiosResponse<ResultData>;
|
|
17
|
+
export type FindPlannedEventsRowError = AxiosError<ResultError>;
|
|
22
18
|
|
|
23
19
|
export type FindPlannedEventsRowConfig = {
|
|
24
20
|
baseURL?: string;
|
|
@@ -37,27 +33,27 @@ export function findPlannedEventsRowRequest({
|
|
|
37
33
|
params,
|
|
38
34
|
paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
|
|
39
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 ?? data.message ?? 'Unknown Error';
|
|
52
|
+
},
|
|
53
|
+
],
|
|
40
54
|
})
|
|
41
|
-
.then(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
data: { byId: {}, ids: [] },
|
|
45
|
-
meta: { total: res.data.pageParams.length },
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
res.data.data.forEach(entity => {
|
|
49
|
-
data.data.byId[entity.id] = entity;
|
|
50
|
-
data.data.ids.push(entity.id);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
return data;
|
|
54
|
-
}
|
|
55
|
-
)
|
|
56
|
-
.catch((err: AxiosError<ErrorData>) => {
|
|
57
|
-
const error: Error & Partial<FindPlannedEventsRowError> = new Error(err.message);
|
|
58
|
-
error.status = err.response?.status ?? 520;
|
|
59
|
-
error.data = err.response?.data.message ?? err.response?.data.data?.error ?? 'Unknown Error';
|
|
60
|
-
|
|
61
|
-
throw error;
|
|
55
|
+
.then((res: FindPlannedEventsRowData) => res)
|
|
56
|
+
.catch((err: FindPlannedEventsRowError) => {
|
|
57
|
+
throw err;
|
|
62
58
|
});
|
|
63
59
|
}
|