@mapcreator/api 0.0.0-saga.1 → 0.0.0-saga.10
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.
Potentially problematic release.
This version of @mapcreator/api might be problematic. Click here for more details.
- package/cjs/api/apiCommon.d.ts.map +1 -1
- package/cjs/api/apiCommon.js +14 -3
- package/cjs/api/apiCommon.js.map +1 -1
- package/cjs/api/choropleth.d.ts +114 -5
- package/cjs/api/choropleth.d.ts.map +1 -1
- package/cjs/api/choropleth.js +58 -6
- package/cjs/api/choropleth.js.map +1 -1
- package/cjs/api/font.d.ts +3 -0
- package/cjs/api/font.d.ts.map +1 -1
- package/cjs/api/font.js +0 -3
- package/cjs/api/font.js.map +1 -1
- package/cjs/api/geocode.d.ts +10 -0
- package/cjs/api/geocode.d.ts.map +1 -0
- package/cjs/api/geocode.js +9 -0
- package/cjs/api/geocode.js.map +1 -0
- package/cjs/api/highlight.js +1 -1
- package/cjs/api/highlight.js.map +1 -1
- package/cjs/api/insetMap.d.ts +37 -0
- package/cjs/api/insetMap.d.ts.map +1 -0
- package/cjs/api/insetMap.js +47 -0
- package/cjs/api/insetMap.js.map +1 -0
- package/cjs/api/job.d.ts +10 -6
- package/cjs/api/job.d.ts.map +1 -1
- package/cjs/api/job.js +10 -5
- package/cjs/api/job.js.map +1 -1
- package/cjs/api/jobResult.d.ts +1 -1
- package/cjs/api/jobResult.d.ts.map +1 -1
- package/cjs/api/jobResult.js +1 -1
- package/cjs/api/jobResult.js.map +1 -1
- package/cjs/api/jobRevision.d.ts +3 -3
- package/cjs/api/jobRevision.d.ts.map +1 -1
- package/cjs/api/jobRevision.js +19 -14
- package/cjs/api/jobRevision.js.map +1 -1
- package/cjs/api/mapstyleSet.d.ts +2 -1
- package/cjs/api/mapstyleSet.d.ts.map +1 -1
- package/cjs/api/mapstyleSet.js +9 -0
- package/cjs/api/mapstyleSet.js.map +1 -1
- package/cjs/api/organisation.d.ts +4 -3
- package/cjs/api/organisation.d.ts.map +1 -1
- package/cjs/api/organisation.js +6 -7
- package/cjs/api/organisation.js.map +1 -1
- package/cjs/api/resources.d.ts +7 -1
- package/cjs/api/resources.d.ts.map +1 -1
- package/cjs/api/resources.js +10 -4
- package/cjs/api/resources.js.map +1 -1
- package/cjs/api/user.d.ts +2 -1
- package/cjs/api/user.d.ts.map +1 -1
- package/cjs/api/user.js +4 -5
- package/cjs/api/user.js.map +1 -1
- package/cjs/index.d.ts +2 -0
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +2 -0
- package/cjs/index.js.map +1 -1
- package/cjs/oauth.d.ts +10 -6
- package/cjs/oauth.d.ts.map +1 -1
- package/cjs/oauth.js +29 -199
- package/cjs/oauth.js.map +1 -1
- package/cjs/utils.d.ts +9 -2
- package/cjs/utils.d.ts.map +1 -1
- package/cjs/utils.js +72 -14
- package/cjs/utils.js.map +1 -1
- package/esm/api/apiCommon.d.ts.map +1 -1
- package/esm/api/apiCommon.js +14 -3
- package/esm/api/apiCommon.js.map +1 -1
- package/esm/api/choropleth.d.ts +114 -5
- package/esm/api/choropleth.d.ts.map +1 -1
- package/esm/api/choropleth.js +53 -5
- package/esm/api/choropleth.js.map +1 -1
- package/esm/api/font.d.ts +3 -0
- package/esm/api/font.d.ts.map +1 -1
- package/esm/api/font.js +1 -4
- package/esm/api/font.js.map +1 -1
- package/esm/api/geocode.d.ts +10 -0
- package/esm/api/geocode.d.ts.map +1 -0
- package/esm/api/geocode.js +6 -0
- package/esm/api/geocode.js.map +1 -0
- package/esm/api/highlight.js +1 -1
- package/esm/api/highlight.js.map +1 -1
- package/esm/api/insetMap.d.ts +37 -0
- package/esm/api/insetMap.d.ts.map +1 -0
- package/esm/api/insetMap.js +42 -0
- package/esm/api/insetMap.js.map +1 -0
- package/esm/api/job.d.ts +10 -6
- package/esm/api/job.d.ts.map +1 -1
- package/esm/api/job.js +9 -5
- package/esm/api/job.js.map +1 -1
- package/esm/api/jobResult.d.ts +1 -1
- package/esm/api/jobResult.d.ts.map +1 -1
- package/esm/api/jobResult.js +1 -1
- package/esm/api/jobResult.js.map +1 -1
- package/esm/api/jobRevision.d.ts +3 -3
- package/esm/api/jobRevision.d.ts.map +1 -1
- package/esm/api/jobRevision.js +19 -14
- package/esm/api/jobRevision.js.map +1 -1
- package/esm/api/mapstyleSet.d.ts +2 -1
- package/esm/api/mapstyleSet.d.ts.map +1 -1
- package/esm/api/mapstyleSet.js +8 -0
- package/esm/api/mapstyleSet.js.map +1 -1
- package/esm/api/organisation.d.ts +4 -3
- package/esm/api/organisation.d.ts.map +1 -1
- package/esm/api/organisation.js +6 -7
- package/esm/api/organisation.js.map +1 -1
- package/esm/api/resources.d.ts +7 -1
- package/esm/api/resources.d.ts.map +1 -1
- package/esm/api/resources.js +10 -4
- package/esm/api/resources.js.map +1 -1
- package/esm/api/user.d.ts +2 -1
- package/esm/api/user.d.ts.map +1 -1
- package/esm/api/user.js +4 -5
- package/esm/api/user.js.map +1 -1
- package/esm/index.d.ts +2 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +2 -0
- package/esm/index.js.map +1 -1
- package/esm/oauth.d.ts +10 -6
- package/esm/oauth.d.ts.map +1 -1
- package/esm/oauth.js +28 -198
- package/esm/oauth.js.map +1 -1
- package/esm/utils.d.ts +9 -2
- package/esm/utils.d.ts.map +1 -1
- package/esm/utils.js +71 -14
- package/esm/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/api/apiCommon.ts +71 -70
- package/src/api/choropleth.ts +256 -105
- package/src/api/color.ts +22 -22
- package/src/api/dimension.ts +44 -44
- package/src/api/dimensionSet.ts +20 -20
- package/src/api/feature.ts +22 -22
- package/src/api/font.ts +57 -49
- package/src/api/fontFamily.ts +43 -43
- package/src/api/geocode.ts +17 -0
- package/src/api/highlight.ts +87 -87
- package/src/api/insetMap.ts +95 -0
- package/src/api/job.ts +139 -129
- package/src/api/jobResult.ts +95 -95
- package/src/api/jobRevision.ts +281 -278
- package/src/api/jobShare.ts +35 -35
- package/src/api/jobType.ts +26 -26
- package/src/api/language.ts +19 -19
- package/src/api/layer.ts +38 -38
- package/src/api/layerFaq.ts +53 -53
- package/src/api/layerGroup.ts +69 -69
- package/src/api/mapstyleSet.ts +70 -48
- package/src/api/message.ts +80 -80
- package/src/api/organisation.ts +96 -95
- package/src/api/resources.ts +153 -143
- package/src/api/svg.ts +33 -33
- package/src/api/svgSet.ts +56 -56
- package/src/api/user.ts +327 -327
- package/src/index.ts +44 -42
- package/src/oauth.ts +90 -314
- package/src/utils.ts +407 -342
package/src/api/apiCommon.ts
CHANGED
|
@@ -1,70 +1,71 @@
|
|
|
1
|
-
import { type ApiJobData, type Job, jobRevivers } from './job.js';
|
|
2
|
-
import {
|
|
3
|
-
APIMeta,
|
|
4
|
-
type ApiError,
|
|
5
|
-
type ApiSuccess,
|
|
6
|
-
type Revivers,
|
|
7
|
-
defaultListHeader,
|
|
8
|
-
getSearchParams,
|
|
9
|
-
request,
|
|
10
|
-
} from '../utils.js';
|
|
11
|
-
|
|
12
|
-
export interface JobSearchResult {
|
|
13
|
-
pageCount: number;
|
|
14
|
-
data: Job[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function listJobs(
|
|
18
|
-
pathname: string,
|
|
19
|
-
title: string,
|
|
20
|
-
page: number,
|
|
21
|
-
searchOptions?: Record<string, unknown>,
|
|
22
|
-
): Promise<JobSearchResult> {
|
|
23
|
-
const defaultSearchOptions = {
|
|
24
|
-
sort: '-updated',
|
|
25
|
-
only_downloaded: false,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const search = { ...defaultSearchOptions, ...searchOptions };
|
|
29
|
-
|
|
30
|
-
const query = getSearchParams({
|
|
31
|
-
only_with_revisions: true,
|
|
32
|
-
search: {
|
|
33
|
-
job_type_id: '9',
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
1
|
+
import { type ApiJobData, type Job, jobRevivers } from './job.js';
|
|
2
|
+
import {
|
|
3
|
+
APIMeta,
|
|
4
|
+
type ApiError,
|
|
5
|
+
type ApiSuccess,
|
|
6
|
+
type Revivers,
|
|
7
|
+
defaultListHeader,
|
|
8
|
+
getSearchParams,
|
|
9
|
+
request,
|
|
10
|
+
} from '../utils.js';
|
|
11
|
+
|
|
12
|
+
export interface JobSearchResult {
|
|
13
|
+
pageCount: number;
|
|
14
|
+
data: Job[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function listJobs(
|
|
18
|
+
pathname: string,
|
|
19
|
+
title: string,
|
|
20
|
+
page: number,
|
|
21
|
+
searchOptions?: Record<string, unknown>,
|
|
22
|
+
): Promise<JobSearchResult> {
|
|
23
|
+
const defaultSearchOptions = {
|
|
24
|
+
sort: '-updated',
|
|
25
|
+
only_downloaded: false,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const search = { ...defaultSearchOptions, ...searchOptions };
|
|
29
|
+
|
|
30
|
+
const query = getSearchParams({
|
|
31
|
+
only_with_revisions: true,
|
|
32
|
+
search: {
|
|
33
|
+
job_type_id: ['9', '6'],
|
|
34
|
+
converted_job_id: '=:',
|
|
35
|
+
...(title.length > 0 && { title: `~:${title}` }),
|
|
36
|
+
},
|
|
37
|
+
...search,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const path = `${pathname}?${query}`;
|
|
41
|
+
|
|
42
|
+
const headers = {
|
|
43
|
+
...defaultListHeader,
|
|
44
|
+
'X-Page': `${page}`,
|
|
45
|
+
};
|
|
46
|
+
const options = {
|
|
47
|
+
revivers: jobRevivers as Revivers<ApiJobArray, Job>,
|
|
48
|
+
withMeta: true,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type ApiJobArray = {
|
|
52
|
+
data: ApiJobData[];
|
|
53
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
54
|
+
|
|
55
|
+
const result = (await request<ApiJobArray, Job>(path, null, headers, options).catch(
|
|
56
|
+
(error: Error) => {
|
|
57
|
+
if (error instanceof APIMeta) {
|
|
58
|
+
const { data, headers, status } = error as APIMeta<ApiJobArray, Job>;
|
|
59
|
+
|
|
60
|
+
return { data, headers, status };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
throw error;
|
|
64
|
+
},
|
|
65
|
+
)) as APIMeta<ApiJobArray, Job>;
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
data: result.data,
|
|
69
|
+
pageCount: Number(result.headers.get('X-Paginate-Pages')),
|
|
70
|
+
};
|
|
71
|
+
}
|
package/src/api/choropleth.ts
CHANGED
|
@@ -1,105 +1,256 @@
|
|
|
1
|
-
import { type ApiError, type ApiSuccess, getSearchParams, request } from '../utils.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
type
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
type
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
type
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
properties:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
1
|
+
import { type ApiError, type ApiSuccess, type Flatten, type Revivers, getSearchParams, request } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
import type { RequireAtLeastOne } from 'type-fest';
|
|
4
|
+
import type { Polygon } from 'geojson';
|
|
5
|
+
|
|
6
|
+
export const boundingBoxRevivers: Revivers<
|
|
7
|
+
{ data: { bounding_box: string } } & Omit<ApiSuccess, 'data'> | ApiError,
|
|
8
|
+
{ boundingBox: Polygon }
|
|
9
|
+
> = {
|
|
10
|
+
boundingBox: (data: { bounding_box: string }) => JSON.parse(data.bounding_box) as Polygon,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type ApiSearchPoint = {
|
|
14
|
+
lat: number;
|
|
15
|
+
lng: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type ApiSearchBounds = {
|
|
19
|
+
min_lat: number;
|
|
20
|
+
min_lng: number;
|
|
21
|
+
max_lat: number;
|
|
22
|
+
max_lng: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type SingleOrGroupedAreaBase = {
|
|
26
|
+
id: number;
|
|
27
|
+
title: string;
|
|
28
|
+
subtitle: string;
|
|
29
|
+
svgPreview: string;
|
|
30
|
+
boundingBox: Polygon;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type GroupedArea = SingleOrGroupedAreaBase & {
|
|
34
|
+
isGroup: true;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type SingleArea = SingleOrGroupedAreaBase & {
|
|
38
|
+
isGroup: false;
|
|
39
|
+
properties: Record<string, string>;
|
|
40
|
+
vectorSource: string;
|
|
41
|
+
sourceLayer: string;
|
|
42
|
+
featureId: number;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type ApiSingleArea = {
|
|
46
|
+
data: {
|
|
47
|
+
id: number;
|
|
48
|
+
title: string;
|
|
49
|
+
subtitle: string;
|
|
50
|
+
svg_preview: string;
|
|
51
|
+
bounding_box: string;
|
|
52
|
+
is_group: false;
|
|
53
|
+
properties: string;
|
|
54
|
+
vector_source: string;
|
|
55
|
+
source_layer: string;
|
|
56
|
+
feature_id: number;
|
|
57
|
+
};
|
|
58
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
59
|
+
|
|
60
|
+
export type ApiSingleAreaData = Flatten<Exclude<ApiSingleArea, ApiError>['data']>;
|
|
61
|
+
|
|
62
|
+
export type ApiSingleAreaArray = {
|
|
63
|
+
data: ApiSingleAreaData[];
|
|
64
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
65
|
+
|
|
66
|
+
type ApiGroupedArea = {
|
|
67
|
+
data: {
|
|
68
|
+
id: number;
|
|
69
|
+
title: string;
|
|
70
|
+
subtitle: string;
|
|
71
|
+
svg_preview: string;
|
|
72
|
+
bounding_box: string;
|
|
73
|
+
is_group: true;
|
|
74
|
+
properties: null;
|
|
75
|
+
vector_source: null;
|
|
76
|
+
source_layer: null;
|
|
77
|
+
feature_id: null;
|
|
78
|
+
};
|
|
79
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
80
|
+
|
|
81
|
+
export type ApiGroupedAreaData = Flatten<Exclude<ApiGroupedArea, ApiError>['data']>;
|
|
82
|
+
|
|
83
|
+
export type ApiGroupedAreaArray = {
|
|
84
|
+
data: ApiGroupedAreaData[];
|
|
85
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
86
|
+
|
|
87
|
+
export const singleAreaRevivers: Revivers<ApiSingleArea, SingleArea> = {
|
|
88
|
+
...boundingBoxRevivers,
|
|
89
|
+
properties: (data: ApiSingleAreaData) =>
|
|
90
|
+
JSON.parse(data.properties) as Record<string, string>,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const groupedAreaRevivers: Revivers<ApiGroupedArea, GroupedArea> = {
|
|
94
|
+
...boundingBoxRevivers,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export async function searchSingleAreas(
|
|
98
|
+
language: string,
|
|
99
|
+
search: RequireAtLeastOne<{
|
|
100
|
+
searchBounds: ApiSearchBounds;
|
|
101
|
+
query?: string;
|
|
102
|
+
searchPoint?: ApiSearchPoint;
|
|
103
|
+
}>,
|
|
104
|
+
): Promise<SingleArea[]> {
|
|
105
|
+
const pathname = '/v1/choropleth/polygons/search';
|
|
106
|
+
const query = getSearchParams({
|
|
107
|
+
language,
|
|
108
|
+
...search.searchBounds,
|
|
109
|
+
...(search.query && { query: search.query }),
|
|
110
|
+
...(search.searchPoint && { point: search.searchPoint }),
|
|
111
|
+
mode: 'polygon',
|
|
112
|
+
});
|
|
113
|
+
const path = `${pathname}?${query}`;
|
|
114
|
+
const options = { revivers: singleAreaRevivers };
|
|
115
|
+
|
|
116
|
+
return request<ApiSingleAreaArray, SingleArea>(path, null, null, options);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export async function searchGroupedAreas(
|
|
120
|
+
language: string,
|
|
121
|
+
search: RequireAtLeastOne<{
|
|
122
|
+
searchBounds: ApiSearchBounds;
|
|
123
|
+
query?: string;
|
|
124
|
+
searchPoint?: ApiSearchPoint;
|
|
125
|
+
}>,
|
|
126
|
+
): Promise<GroupedArea[]> {
|
|
127
|
+
const pathname = '/v1/choropleth/polygons/search';
|
|
128
|
+
const query = getSearchParams({
|
|
129
|
+
language,
|
|
130
|
+
...search.searchBounds,
|
|
131
|
+
...(search.query && { query: search.query }),
|
|
132
|
+
...(search.searchPoint && { point: search.searchPoint }),
|
|
133
|
+
mode: 'group',
|
|
134
|
+
});
|
|
135
|
+
const path = `${pathname}?${query}`;
|
|
136
|
+
const options = { revivers: groupedAreaRevivers };
|
|
137
|
+
|
|
138
|
+
return request<ApiGroupedAreaArray, GroupedArea>(path, null, null, options);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export type GroupedAreaChild = {
|
|
142
|
+
id: number;
|
|
143
|
+
title: string;
|
|
144
|
+
vectorSource: string;
|
|
145
|
+
sourceLayer: string;
|
|
146
|
+
featureId: number;
|
|
147
|
+
boundingBox: Polygon;
|
|
148
|
+
properties: Record<string, string>;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
type ApiGroupedAreaChild = {
|
|
152
|
+
data: {
|
|
153
|
+
id: number;
|
|
154
|
+
title: string;
|
|
155
|
+
vector_source: string;
|
|
156
|
+
source_layer: string;
|
|
157
|
+
feature_id: number;
|
|
158
|
+
bounding_box: string;
|
|
159
|
+
properties: string;
|
|
160
|
+
};
|
|
161
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
162
|
+
|
|
163
|
+
export type ApiGroupedAreaChildData = Flatten<Exclude<ApiGroupedAreaChild, ApiError>['data']>;
|
|
164
|
+
|
|
165
|
+
export const groupedAreaChildRevivers: Revivers<ApiGroupedAreaChild, GroupedAreaChild> = {
|
|
166
|
+
...boundingBoxRevivers,
|
|
167
|
+
properties: (data: ApiGroupedAreaChildData) => JSON.parse(data.properties) as Record<string, string>,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export async function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]> {
|
|
171
|
+
const pathname = `/v1/choropleth/groups/${groupId}/children-optimized`;
|
|
172
|
+
const query = getSearchParams({ language });
|
|
173
|
+
const path = `${pathname}?${query}`;
|
|
174
|
+
const options = { revivers: groupedAreaChildRevivers };
|
|
175
|
+
|
|
176
|
+
type ApiGroupedAreaChildArray = {
|
|
177
|
+
data: ApiGroupedAreaChildData[];
|
|
178
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
179
|
+
|
|
180
|
+
return request<ApiGroupedAreaChildArray, GroupedAreaChild>(path, null, null, options);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export type MatchedGroup = {
|
|
184
|
+
id: number;
|
|
185
|
+
sml: number;
|
|
186
|
+
childrenCount: number;
|
|
187
|
+
matchField: string;
|
|
188
|
+
boundingBox: Polygon;
|
|
189
|
+
property: string;
|
|
190
|
+
name: string;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export type ApiMatchedGroup = {
|
|
194
|
+
data: {
|
|
195
|
+
id: number;
|
|
196
|
+
sml: number;
|
|
197
|
+
children_count: number;
|
|
198
|
+
match_field: string;
|
|
199
|
+
bounding_box: string;
|
|
200
|
+
property: string;
|
|
201
|
+
name: string;
|
|
202
|
+
};
|
|
203
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
204
|
+
|
|
205
|
+
export type ApiMatchedGroupData = Flatten<Exclude<ApiMatchedGroup, ApiError>['data']>;
|
|
206
|
+
|
|
207
|
+
export async function getGroupsByDataSample(
|
|
208
|
+
sample: Record<string, string[]>,
|
|
209
|
+
language: string,
|
|
210
|
+
rowCount: number,
|
|
211
|
+
): Promise<MatchedGroup[]> {
|
|
212
|
+
const path = `/v1/choropleth/groups/sample`;
|
|
213
|
+
const options = { revivers: boundingBoxRevivers };
|
|
214
|
+
|
|
215
|
+
type ApiMatchedGroupArray = {
|
|
216
|
+
data: ApiMatchedGroupData[];
|
|
217
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
218
|
+
|
|
219
|
+
return request<ApiMatchedGroupArray, MatchedGroup>(path, { sample, language, row_count: rowCount }, null, options);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export type BoundPolygon = {
|
|
223
|
+
index: number;
|
|
224
|
+
inputName: string;
|
|
225
|
+
id: number;
|
|
226
|
+
sml: number;
|
|
227
|
+
name: string;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export type ApiBoundPolygon = {
|
|
231
|
+
data: {
|
|
232
|
+
index: number;
|
|
233
|
+
input_name: string;
|
|
234
|
+
id: number;
|
|
235
|
+
sml: number;
|
|
236
|
+
name: string;
|
|
237
|
+
};
|
|
238
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
239
|
+
|
|
240
|
+
export type ApiBoundPolygonData = Flatten<Exclude<ApiBoundPolygon, ApiError>['data']>;
|
|
241
|
+
|
|
242
|
+
export async function getBoundPolygons(
|
|
243
|
+
groupId: number,
|
|
244
|
+
property: string,
|
|
245
|
+
data: string[],
|
|
246
|
+
language: string,
|
|
247
|
+
): Promise<BoundPolygon[]> {
|
|
248
|
+
const path = `/v1/choropleth/groups/bind`;
|
|
249
|
+
const body = { group_id: groupId, property, data, language };
|
|
250
|
+
|
|
251
|
+
type ApiBoundPolygonArray = {
|
|
252
|
+
data: ApiBoundPolygonData[];
|
|
253
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
254
|
+
|
|
255
|
+
return request<ApiBoundPolygonArray, BoundPolygon>(path, body);
|
|
256
|
+
}
|
package/src/api/color.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
-
|
|
3
|
-
export type Color = {
|
|
4
|
-
id: number;
|
|
5
|
-
hex: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type ApiColor = {
|
|
9
|
-
data: {
|
|
10
|
-
id: number; // The color id (sortable)
|
|
11
|
-
name: string; // The name of the color (searchable, sortable)
|
|
12
|
-
hex: string; // The hex value of the color (searchable, sortable)
|
|
13
|
-
order?: number; // TODO: not present in API specification!
|
|
14
|
-
} & ApiCommonData;
|
|
15
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
16
|
-
|
|
17
|
-
export type ApiColorData = Flatten<Exclude<ApiColor, ApiError>['data']>;
|
|
18
|
-
|
|
19
|
-
export const colorRevivers: Revivers<ApiColor, Color> = {
|
|
20
|
-
name: undefined,
|
|
21
|
-
order: undefined,
|
|
22
|
-
};
|
|
1
|
+
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
export type Color = {
|
|
4
|
+
id: number;
|
|
5
|
+
hex: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type ApiColor = {
|
|
9
|
+
data: {
|
|
10
|
+
id: number; // The color id (sortable)
|
|
11
|
+
name: string; // The name of the color (searchable, sortable)
|
|
12
|
+
hex: string; // The hex value of the color (searchable, sortable)
|
|
13
|
+
order?: number; // TODO: not present in API specification!
|
|
14
|
+
} & ApiCommonData;
|
|
15
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
16
|
+
|
|
17
|
+
export type ApiColorData = Flatten<Exclude<ApiColor, ApiError>['data']>;
|
|
18
|
+
|
|
19
|
+
export const colorRevivers: Revivers<ApiColor, Color> = {
|
|
20
|
+
name: undefined,
|
|
21
|
+
order: undefined,
|
|
22
|
+
};
|
package/src/api/dimension.ts
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
-
|
|
3
|
-
export type OutputUnit =
|
|
4
|
-
| 'millimeter'
|
|
5
|
-
| 'centimeter'
|
|
6
|
-
| 'inch'
|
|
7
|
-
| 'pixel'
|
|
8
|
-
| 'pica';
|
|
9
|
-
|
|
10
|
-
export type Dimension = {
|
|
11
|
-
id: number;
|
|
12
|
-
dimensionSetId: number;
|
|
13
|
-
name: string;
|
|
14
|
-
width: number;
|
|
15
|
-
height: number;
|
|
16
|
-
dpi: number;
|
|
17
|
-
unit: OutputUnit;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type ApiDimension = {
|
|
21
|
-
data: {
|
|
22
|
-
id: number; // The dimension id (sortable)
|
|
23
|
-
dimension_set_id: number; // The id of the dimension set
|
|
24
|
-
name: string; // The name of dimension (searchable, sortable)
|
|
25
|
-
width: number; // The width of the dimension (searchable, sortable)
|
|
26
|
-
height: number; // The height of the dimension (searchable, sortable)
|
|
27
|
-
dpi: number; // The dpi of the dimension
|
|
28
|
-
unit: string; // The unit of this dimension
|
|
29
|
-
} & ApiCommonData;
|
|
30
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
31
|
-
|
|
32
|
-
export type ApiDimensionData = Flatten<Exclude<ApiDimension, ApiError>['data']>;
|
|
33
|
-
|
|
34
|
-
const keyToUnit: { [key: string]: OutputUnit } = {
|
|
35
|
-
MM: 'millimeter',
|
|
36
|
-
CM: 'centimeter',
|
|
37
|
-
IN: 'inch',
|
|
38
|
-
PX: 'pixel',
|
|
39
|
-
PICA: 'pica',
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const dimensionRevivers: Revivers<ApiDimension, Dimension> = {
|
|
43
|
-
unit: (data: ApiDimensionData) => keyToUnit[data.unit],
|
|
44
|
-
};
|
|
1
|
+
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
export type OutputUnit =
|
|
4
|
+
| 'millimeter'
|
|
5
|
+
| 'centimeter'
|
|
6
|
+
| 'inch'
|
|
7
|
+
| 'pixel'
|
|
8
|
+
| 'pica';
|
|
9
|
+
|
|
10
|
+
export type Dimension = {
|
|
11
|
+
id: number;
|
|
12
|
+
dimensionSetId: number;
|
|
13
|
+
name: string;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
dpi: number;
|
|
17
|
+
unit: OutputUnit;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type ApiDimension = {
|
|
21
|
+
data: {
|
|
22
|
+
id: number; // The dimension id (sortable)
|
|
23
|
+
dimension_set_id: number; // The id of the dimension set
|
|
24
|
+
name: string; // The name of dimension (searchable, sortable)
|
|
25
|
+
width: number; // The width of the dimension (searchable, sortable)
|
|
26
|
+
height: number; // The height of the dimension (searchable, sortable)
|
|
27
|
+
dpi: number; // The dpi of the dimension
|
|
28
|
+
unit: string; // The unit of this dimension
|
|
29
|
+
} & ApiCommonData;
|
|
30
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
31
|
+
|
|
32
|
+
export type ApiDimensionData = Flatten<Exclude<ApiDimension, ApiError>['data']>;
|
|
33
|
+
|
|
34
|
+
const keyToUnit: { [key: string]: OutputUnit } = {
|
|
35
|
+
MM: 'millimeter',
|
|
36
|
+
CM: 'centimeter',
|
|
37
|
+
IN: 'inch',
|
|
38
|
+
PX: 'pixel',
|
|
39
|
+
PICA: 'pica',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const dimensionRevivers: Revivers<ApiDimension, Dimension> = {
|
|
43
|
+
unit: (data: ApiDimensionData) => keyToUnit[data.unit],
|
|
44
|
+
};
|
package/src/api/dimensionSet.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
-
|
|
3
|
-
export type DimensionSet = {
|
|
4
|
-
id: number;
|
|
5
|
-
name: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type ApiDimensionSet = {
|
|
9
|
-
data: {
|
|
10
|
-
id: number; // The dimension set id (sortable)
|
|
11
|
-
name: string; // The dimension set name (searchable, sortable)
|
|
12
|
-
order?: number; // TODO: not present in API specification!
|
|
13
|
-
} & ApiCommonData;
|
|
14
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
15
|
-
|
|
16
|
-
export type ApiDimensionSetData = Flatten<Exclude<ApiDimensionSet, ApiError>['data']>;
|
|
17
|
-
|
|
18
|
-
export const dimensionSetRevivers: Revivers<ApiDimensionSet, DimensionSet> = {
|
|
19
|
-
order: undefined,
|
|
20
|
-
};
|
|
1
|
+
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
export type DimensionSet = {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type ApiDimensionSet = {
|
|
9
|
+
data: {
|
|
10
|
+
id: number; // The dimension set id (sortable)
|
|
11
|
+
name: string; // The dimension set name (searchable, sortable)
|
|
12
|
+
order?: number; // TODO: not present in API specification!
|
|
13
|
+
} & ApiCommonData;
|
|
14
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
15
|
+
|
|
16
|
+
export type ApiDimensionSetData = Flatten<Exclude<ApiDimensionSet, ApiError>['data']>;
|
|
17
|
+
|
|
18
|
+
export const dimensionSetRevivers: Revivers<ApiDimensionSet, DimensionSet> = {
|
|
19
|
+
order: undefined,
|
|
20
|
+
};
|