@hapl/api-queries 0.1.163 → 0.1.164
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 +12 -0
- package/dist/api-queries.cjs.development.js +60 -10
- 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 +60 -10
- package/dist/api-queries.esm.js.map +1 -1
- package/dist/registry/v1/api/image/uploadImages/index.d.ts +20 -0
- package/dist/registry/v1/api/index.d.ts +1 -0
- package/dist/registry/v1/index.d.ts +2 -1
- package/dist/registry/v1/types/Image.d.ts +6 -1
- package/package.json +1 -1
- package/src/registry/v1/api/image/uploadImages/index.ts +57 -0
- package/src/registry/v1/api/index.ts +2 -0
- package/src/registry/v1/index.ts +13 -7
- package/src/registry/v1/types/Image.ts +6 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AxiosResponse, AxiosError } from 'axios';
|
|
2
|
+
import { Image } from '../../../types';
|
|
3
|
+
declare type ResultData = {
|
|
4
|
+
ids: number[];
|
|
5
|
+
byId: Record<string, Image>;
|
|
6
|
+
};
|
|
7
|
+
declare type ResultError = string;
|
|
8
|
+
export declare type UploadImagesHeaders = {
|
|
9
|
+
'x-auth-hc': string;
|
|
10
|
+
};
|
|
11
|
+
export declare type UploadImagesBody = Blob[];
|
|
12
|
+
export declare type UploadImagesData = AxiosResponse<ResultData>;
|
|
13
|
+
export declare type UploadImagesError = AxiosError<ResultError>;
|
|
14
|
+
export declare type UploadImagesConfig = {
|
|
15
|
+
baseURL?: string;
|
|
16
|
+
headers: UploadImagesHeaders;
|
|
17
|
+
body: UploadImagesBody;
|
|
18
|
+
};
|
|
19
|
+
export declare function uploadImagesRequest({ baseURL, body, headers }: UploadImagesConfig): Promise<UploadImagesData>;
|
|
20
|
+
export {};
|
|
@@ -2,5 +2,6 @@ export * from './address/createAddress';
|
|
|
2
2
|
export * from './address/findAddressById';
|
|
3
3
|
export * from './address/findAddressesByRealtyParams';
|
|
4
4
|
export * from './complex/findComplexIds';
|
|
5
|
+
export * from './image/uploadImages';
|
|
5
6
|
export * from './realty/findRealties';
|
|
6
7
|
export * from './valuation/calculateValuation';
|
|
@@ -2,9 +2,10 @@ import * as api from './api';
|
|
|
2
2
|
export declare class Api {
|
|
3
3
|
private baseURL;
|
|
4
4
|
constructor(baseURL: string | undefined);
|
|
5
|
-
findComplexIds: (params: api.FindComplexIdsParams) => Promise<api.FindComplexIdsData>;
|
|
6
5
|
createAddress: (body: api.CreateAddressBody, headers: api.CreateAddressHeaders) => Promise<api.CreateAddressData>;
|
|
7
6
|
findAddressById: (urlParams: api.FindAddressByIdUrlParams, headers: api.FindAddressByIdHeaders) => Promise<api.FindAddressByIdData>;
|
|
7
|
+
findComplexIds: (params: api.FindComplexIdsParams) => Promise<api.FindComplexIdsData>;
|
|
8
|
+
uploadImages: (body: api.UploadImagesBody, headers: api.UploadImagesHeaders) => Promise<api.UploadImagesData>;
|
|
8
9
|
findRealties: (params: api.FindRealtiesParams, headers?: api.FindRealtiesHeaders | undefined) => Promise<api.FindRealtiesData>;
|
|
9
10
|
findAddressesByRealtyParams: (params: api.FindAddressesByRealtyParams, headers?: api.FindAddressesByRealtyParamsHeaders | undefined) => Promise<api.FindAddressesByRealtyParamsData>;
|
|
10
11
|
calculateValuation: (body: api.CalculateValuationBody, headers: api.CalculateValuationHeaders) => Promise<api.CalculateValuationData>;
|
|
@@ -8,8 +8,13 @@ export declare type Image = {
|
|
|
8
8
|
properties: {
|
|
9
9
|
oldId?: number;
|
|
10
10
|
maxSize?: string;
|
|
11
|
+
system?: {
|
|
12
|
+
type?: string;
|
|
13
|
+
mime?: string;
|
|
14
|
+
size?: number;
|
|
15
|
+
};
|
|
11
16
|
};
|
|
12
17
|
storagePath: string;
|
|
13
18
|
thumbnailPath: string;
|
|
14
|
-
type
|
|
19
|
+
type?: string | ImageType;
|
|
15
20
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
|
|
2
|
+
import { Image } from '../../../types';
|
|
3
|
+
|
|
4
|
+
type SuccessData = { success: true; data: Image[]; pageParams: { page: number; length: number } };
|
|
5
|
+
type ErrorData = { success: false; data: Record<'error' | 'message', string> };
|
|
6
|
+
|
|
7
|
+
type ResultData = { ids: number[]; byId: Record<string, Image> };
|
|
8
|
+
type ResultError = string;
|
|
9
|
+
|
|
10
|
+
export type UploadImagesHeaders = { 'x-auth-hc': string };
|
|
11
|
+
export type UploadImagesBody = Blob[];
|
|
12
|
+
|
|
13
|
+
export type UploadImagesData = AxiosResponse<ResultData>;
|
|
14
|
+
export type UploadImagesError = AxiosError<ResultError>;
|
|
15
|
+
export type UploadImagesConfig = {
|
|
16
|
+
baseURL?: string;
|
|
17
|
+
headers: UploadImagesHeaders;
|
|
18
|
+
body: UploadImagesBody;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function uploadImagesRequest({ baseURL = 'https://registry.homeapp.ru', body, headers }: UploadImagesConfig) {
|
|
22
|
+
const formData = new FormData();
|
|
23
|
+
|
|
24
|
+
if (body.length === 0) {
|
|
25
|
+
throw new Error('Список изображений пуст');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
body.forEach((file, index) => {
|
|
29
|
+
formData.append(`file${index}`, file);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return axios
|
|
33
|
+
.post('/api/image/upload', formData, {
|
|
34
|
+
baseURL,
|
|
35
|
+
headers: { Accept: 'application/json', 'Content-Type': 'multipart/form-data', ...headers },
|
|
36
|
+
transformResponse: [
|
|
37
|
+
...(axios.defaults.transformResponse as AxiosTransformer[]),
|
|
38
|
+
(data: SuccessData | ErrorData): ResultData | ResultError => {
|
|
39
|
+
if (!data.success) return data.data.error || data.data.message;
|
|
40
|
+
|
|
41
|
+
const ids: ResultData['ids'] = [];
|
|
42
|
+
const byId: ResultData['byId'] = {};
|
|
43
|
+
|
|
44
|
+
data.data.forEach(entity => {
|
|
45
|
+
byId[entity.id] = entity;
|
|
46
|
+
ids.push(entity.id);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return { ids, byId };
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
})
|
|
53
|
+
.then((res: UploadImagesData) => res)
|
|
54
|
+
.catch((err: UploadImagesError) => {
|
|
55
|
+
throw err;
|
|
56
|
+
});
|
|
57
|
+
}
|
package/src/registry/v1/index.ts
CHANGED
|
@@ -3,12 +3,6 @@ import * as api from './api';
|
|
|
3
3
|
export class Api {
|
|
4
4
|
constructor(private baseURL: string | undefined) {}
|
|
5
5
|
|
|
6
|
-
// complex
|
|
7
|
-
|
|
8
|
-
findComplexIds = (params: api.FindComplexIdsParams) => {
|
|
9
|
-
return api.findComplexIdsRequest({ params, baseURL: this.baseURL });
|
|
10
|
-
};
|
|
11
|
-
|
|
12
6
|
// address
|
|
13
7
|
|
|
14
8
|
createAddress = (body: api.CreateAddressBody, headers: api.CreateAddressHeaders) => {
|
|
@@ -19,6 +13,18 @@ export class Api {
|
|
|
19
13
|
return api.findAddressByIdRequest({ urlParams, headers, baseURL: this.baseURL });
|
|
20
14
|
};
|
|
21
15
|
|
|
16
|
+
// complex
|
|
17
|
+
|
|
18
|
+
findComplexIds = (params: api.FindComplexIdsParams) => {
|
|
19
|
+
return api.findComplexIdsRequest({ params, baseURL: this.baseURL });
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// image
|
|
23
|
+
|
|
24
|
+
uploadImages = (body: api.UploadImagesBody, headers: api.UploadImagesHeaders) => {
|
|
25
|
+
return api.uploadImagesRequest({ body, headers, baseURL: this.baseURL });
|
|
26
|
+
};
|
|
27
|
+
|
|
22
28
|
// realty
|
|
23
29
|
|
|
24
30
|
findRealties = (params: api.FindRealtiesParams, headers?: api.FindRealtiesHeaders) => {
|
|
@@ -32,7 +38,7 @@ export class Api {
|
|
|
32
38
|
return api.findAddressesByRealtyParamsRequest({ params, headers, baseURL: this.baseURL });
|
|
33
39
|
};
|
|
34
40
|
|
|
35
|
-
//
|
|
41
|
+
// valuation
|
|
36
42
|
|
|
37
43
|
calculateValuation = (body: api.CalculateValuationBody, headers: api.CalculateValuationHeaders) => {
|
|
38
44
|
return api.calculateValuationRequest({ body, headers, baseURL: this.baseURL });
|
|
@@ -6,8 +6,12 @@ export enum ImageType {
|
|
|
6
6
|
|
|
7
7
|
export type Image = {
|
|
8
8
|
id: number;
|
|
9
|
-
properties: {
|
|
9
|
+
properties: {
|
|
10
|
+
oldId?: number;
|
|
11
|
+
maxSize?: string;
|
|
12
|
+
system?: { type?: string; mime?: string; size?: number };
|
|
13
|
+
};
|
|
10
14
|
storagePath: string;
|
|
11
15
|
thumbnailPath: string;
|
|
12
|
-
type
|
|
16
|
+
type?: string | ImageType;
|
|
13
17
|
};
|