@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.

Files changed (153) hide show
  1. package/cjs/api/apiCommon.d.ts.map +1 -1
  2. package/cjs/api/apiCommon.js +14 -3
  3. package/cjs/api/apiCommon.js.map +1 -1
  4. package/cjs/api/choropleth.d.ts +114 -5
  5. package/cjs/api/choropleth.d.ts.map +1 -1
  6. package/cjs/api/choropleth.js +58 -6
  7. package/cjs/api/choropleth.js.map +1 -1
  8. package/cjs/api/font.d.ts +3 -0
  9. package/cjs/api/font.d.ts.map +1 -1
  10. package/cjs/api/font.js +0 -3
  11. package/cjs/api/font.js.map +1 -1
  12. package/cjs/api/geocode.d.ts +10 -0
  13. package/cjs/api/geocode.d.ts.map +1 -0
  14. package/cjs/api/geocode.js +9 -0
  15. package/cjs/api/geocode.js.map +1 -0
  16. package/cjs/api/highlight.js +1 -1
  17. package/cjs/api/highlight.js.map +1 -1
  18. package/cjs/api/insetMap.d.ts +37 -0
  19. package/cjs/api/insetMap.d.ts.map +1 -0
  20. package/cjs/api/insetMap.js +47 -0
  21. package/cjs/api/insetMap.js.map +1 -0
  22. package/cjs/api/job.d.ts +10 -6
  23. package/cjs/api/job.d.ts.map +1 -1
  24. package/cjs/api/job.js +10 -5
  25. package/cjs/api/job.js.map +1 -1
  26. package/cjs/api/jobResult.d.ts +1 -1
  27. package/cjs/api/jobResult.d.ts.map +1 -1
  28. package/cjs/api/jobResult.js +1 -1
  29. package/cjs/api/jobResult.js.map +1 -1
  30. package/cjs/api/jobRevision.d.ts +3 -3
  31. package/cjs/api/jobRevision.d.ts.map +1 -1
  32. package/cjs/api/jobRevision.js +19 -14
  33. package/cjs/api/jobRevision.js.map +1 -1
  34. package/cjs/api/mapstyleSet.d.ts +2 -1
  35. package/cjs/api/mapstyleSet.d.ts.map +1 -1
  36. package/cjs/api/mapstyleSet.js +9 -0
  37. package/cjs/api/mapstyleSet.js.map +1 -1
  38. package/cjs/api/organisation.d.ts +4 -3
  39. package/cjs/api/organisation.d.ts.map +1 -1
  40. package/cjs/api/organisation.js +6 -7
  41. package/cjs/api/organisation.js.map +1 -1
  42. package/cjs/api/resources.d.ts +7 -1
  43. package/cjs/api/resources.d.ts.map +1 -1
  44. package/cjs/api/resources.js +10 -4
  45. package/cjs/api/resources.js.map +1 -1
  46. package/cjs/api/user.d.ts +2 -1
  47. package/cjs/api/user.d.ts.map +1 -1
  48. package/cjs/api/user.js +4 -5
  49. package/cjs/api/user.js.map +1 -1
  50. package/cjs/index.d.ts +2 -0
  51. package/cjs/index.d.ts.map +1 -1
  52. package/cjs/index.js +2 -0
  53. package/cjs/index.js.map +1 -1
  54. package/cjs/oauth.d.ts +10 -6
  55. package/cjs/oauth.d.ts.map +1 -1
  56. package/cjs/oauth.js +29 -199
  57. package/cjs/oauth.js.map +1 -1
  58. package/cjs/utils.d.ts +9 -2
  59. package/cjs/utils.d.ts.map +1 -1
  60. package/cjs/utils.js +72 -14
  61. package/cjs/utils.js.map +1 -1
  62. package/esm/api/apiCommon.d.ts.map +1 -1
  63. package/esm/api/apiCommon.js +14 -3
  64. package/esm/api/apiCommon.js.map +1 -1
  65. package/esm/api/choropleth.d.ts +114 -5
  66. package/esm/api/choropleth.d.ts.map +1 -1
  67. package/esm/api/choropleth.js +53 -5
  68. package/esm/api/choropleth.js.map +1 -1
  69. package/esm/api/font.d.ts +3 -0
  70. package/esm/api/font.d.ts.map +1 -1
  71. package/esm/api/font.js +1 -4
  72. package/esm/api/font.js.map +1 -1
  73. package/esm/api/geocode.d.ts +10 -0
  74. package/esm/api/geocode.d.ts.map +1 -0
  75. package/esm/api/geocode.js +6 -0
  76. package/esm/api/geocode.js.map +1 -0
  77. package/esm/api/highlight.js +1 -1
  78. package/esm/api/highlight.js.map +1 -1
  79. package/esm/api/insetMap.d.ts +37 -0
  80. package/esm/api/insetMap.d.ts.map +1 -0
  81. package/esm/api/insetMap.js +42 -0
  82. package/esm/api/insetMap.js.map +1 -0
  83. package/esm/api/job.d.ts +10 -6
  84. package/esm/api/job.d.ts.map +1 -1
  85. package/esm/api/job.js +9 -5
  86. package/esm/api/job.js.map +1 -1
  87. package/esm/api/jobResult.d.ts +1 -1
  88. package/esm/api/jobResult.d.ts.map +1 -1
  89. package/esm/api/jobResult.js +1 -1
  90. package/esm/api/jobResult.js.map +1 -1
  91. package/esm/api/jobRevision.d.ts +3 -3
  92. package/esm/api/jobRevision.d.ts.map +1 -1
  93. package/esm/api/jobRevision.js +19 -14
  94. package/esm/api/jobRevision.js.map +1 -1
  95. package/esm/api/mapstyleSet.d.ts +2 -1
  96. package/esm/api/mapstyleSet.d.ts.map +1 -1
  97. package/esm/api/mapstyleSet.js +8 -0
  98. package/esm/api/mapstyleSet.js.map +1 -1
  99. package/esm/api/organisation.d.ts +4 -3
  100. package/esm/api/organisation.d.ts.map +1 -1
  101. package/esm/api/organisation.js +6 -7
  102. package/esm/api/organisation.js.map +1 -1
  103. package/esm/api/resources.d.ts +7 -1
  104. package/esm/api/resources.d.ts.map +1 -1
  105. package/esm/api/resources.js +10 -4
  106. package/esm/api/resources.js.map +1 -1
  107. package/esm/api/user.d.ts +2 -1
  108. package/esm/api/user.d.ts.map +1 -1
  109. package/esm/api/user.js +4 -5
  110. package/esm/api/user.js.map +1 -1
  111. package/esm/index.d.ts +2 -0
  112. package/esm/index.d.ts.map +1 -1
  113. package/esm/index.js +2 -0
  114. package/esm/index.js.map +1 -1
  115. package/esm/oauth.d.ts +10 -6
  116. package/esm/oauth.d.ts.map +1 -1
  117. package/esm/oauth.js +28 -198
  118. package/esm/oauth.js.map +1 -1
  119. package/esm/utils.d.ts +9 -2
  120. package/esm/utils.d.ts.map +1 -1
  121. package/esm/utils.js +71 -14
  122. package/esm/utils.js.map +1 -1
  123. package/package.json +3 -3
  124. package/src/api/apiCommon.ts +71 -70
  125. package/src/api/choropleth.ts +256 -105
  126. package/src/api/color.ts +22 -22
  127. package/src/api/dimension.ts +44 -44
  128. package/src/api/dimensionSet.ts +20 -20
  129. package/src/api/feature.ts +22 -22
  130. package/src/api/font.ts +57 -49
  131. package/src/api/fontFamily.ts +43 -43
  132. package/src/api/geocode.ts +17 -0
  133. package/src/api/highlight.ts +87 -87
  134. package/src/api/insetMap.ts +95 -0
  135. package/src/api/job.ts +139 -129
  136. package/src/api/jobResult.ts +95 -95
  137. package/src/api/jobRevision.ts +281 -278
  138. package/src/api/jobShare.ts +35 -35
  139. package/src/api/jobType.ts +26 -26
  140. package/src/api/language.ts +19 -19
  141. package/src/api/layer.ts +38 -38
  142. package/src/api/layerFaq.ts +53 -53
  143. package/src/api/layerGroup.ts +69 -69
  144. package/src/api/mapstyleSet.ts +70 -48
  145. package/src/api/message.ts +80 -80
  146. package/src/api/organisation.ts +96 -95
  147. package/src/api/resources.ts +153 -143
  148. package/src/api/svg.ts +33 -33
  149. package/src/api/svgSet.ts +56 -56
  150. package/src/api/user.ts +327 -327
  151. package/src/index.ts +44 -42
  152. package/src/oauth.ts +90 -314
  153. package/src/utils.ts +407 -342
@@ -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
- ...(title.length > 0 && { title: `~:${title}` }),
35
- },
36
- ...search,
37
- });
38
-
39
- const path = `${pathname}?${query}`;
40
-
41
- const headers = {
42
- ...defaultListHeader,
43
- 'X-Page': `${page}`,
44
- };
45
- const options = {
46
- revivers: jobRevivers as Revivers<ApiJobArray, Job>,
47
- withMeta: true,
48
- };
49
-
50
- type ApiJobArray = {
51
- data: ApiJobData[];
52
- } & Omit<ApiSuccess, 'data'> | ApiError;
53
-
54
- const result = (await request<ApiJobArray, Job>(path, null, headers, options).catch(
55
- (error: Error) => {
56
- if (error instanceof APIMeta) {
57
- const { data, headers, status } = error as APIMeta<ApiJobArray, Job>;
58
-
59
- return { data, headers, status };
60
- }
61
-
62
- throw error;
63
- },
64
- )) as APIMeta<ApiJobArray, Job>;
65
-
66
- return {
67
- data: result.data,
68
- pageCount: Number(result.headers.get('X-Paginate-Pages')),
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
+ }
@@ -1,105 +1,256 @@
1
- import { type ApiError, type ApiSuccess, getSearchParams, request } from '../utils.js';
2
- import type { Polygon } from 'geojson';
3
-
4
- export type ApiSearchPoint = {
5
- lat: number;
6
- lng: number;
7
- };
8
-
9
- export type ApiSearchBounds = {
10
- min_lat: number;
11
- min_lng: number;
12
- max_lat: number;
13
- max_lng: number;
14
- };
15
-
16
- type ApiSingleOrGroupedAreaArray =
17
- | ({ data: ApiSingleOrGroupedArea[] } & Omit<ApiSuccess, 'data'>)
18
- | ApiError;
19
-
20
- type ApiSingleOrGroupedArea = {
21
- id: number;
22
- title: string;
23
- subtitle: string;
24
- svg_preview: string;
25
- bounding_box: string;
26
- is_group: boolean;
27
- vector_source: string | null;
28
- source_layer: string | null;
29
- feature_id: number | null;
30
- properties: Record<string, string> | null;
31
- };
32
-
33
- type SingleOrGroupedAreaBase = {
34
- id: number;
35
- title: string;
36
- subtitle: string;
37
- svgPreview: string;
38
- boundingBox: Polygon;
39
- };
40
-
41
- type GroupedArea = SingleOrGroupedAreaBase & {
42
- isGroup: true;
43
- };
44
-
45
- type SingleArea = SingleOrGroupedAreaBase & {
46
- isGroup: false;
47
- vectorSource: string;
48
- sourceLayer: string;
49
- featureId: number;
50
- properties: Record<string, string>;
51
- };
52
-
53
- export type SingleOrGroupedArea = SingleArea | GroupedArea;
54
-
55
- export async function searchSingleOrGroupedAreas(
56
- language: string,
57
- searchBounds: ApiSearchBounds,
58
- query?: string,
59
- searchPoint?: ApiSearchPoint,
60
- ): Promise<SingleOrGroupedArea[]> {
61
- return request<ApiSingleOrGroupedAreaArray, SingleOrGroupedArea>(
62
- `/v1/choropleth/polygons/search?${getSearchParams({
63
- language,
64
- ...searchBounds,
65
- ...(query !== '' && { query }),
66
- ...(searchPoint && { point: searchPoint }),
67
- })}`,
68
- ).then(result => {
69
- result.forEach(
70
- elem => (elem.boundingBox = JSON.parse(elem.boundingBox as unknown as string) as Polygon),
71
- );
72
-
73
- return result;
74
- });
75
- }
76
-
77
- type ApiGroupedAreaChildArray =
78
- | ({
79
- data: ApiGroupedAreaChild[];
80
- } & Omit<ApiSuccess, 'data'>)
81
- | ApiError;
82
-
83
- type ApiGroupedAreaChild = {
84
- id: number;
85
- title: string;
86
- vector_source: string;
87
- source_layer: string;
88
- feature_id: number;
89
- properties: Record<string, string>;
90
- };
91
-
92
- export type GroupedAreaChild = {
93
- id: number;
94
- title: string;
95
- vectorSource: string;
96
- sourceLayer: string;
97
- featureId: number;
98
- properties: Record<string, string>;
99
- };
100
-
101
- export async function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]> {
102
- return request<ApiGroupedAreaChildArray, GroupedAreaChild>(
103
- `/v1/choropleth/groups/${groupId}/children-optimized?${getSearchParams({ language })}`,
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
+ };
@@ -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
+ };
@@ -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
+ };