@mapcreator/api 5.0.0-alpha.73 → 5.0.0-alpha.75

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/LICENSE CHANGED
@@ -1,29 +1,29 @@
1
- BSD 3-Clause License
2
-
3
- Copyright (c) 2024, Mapcreator
4
- All rights reserved.
5
-
6
- Redistribution and use in source and binary forms, with or without
7
- modification, are permitted provided that the following conditions are met:
8
-
9
- * Redistributions of source code must retain the above copyright notice, this
10
- list of conditions and the following disclaimer.
11
-
12
- * Redistributions in binary form must reproduce the above copyright notice,
13
- this list of conditions and the following disclaimer in the documentation
14
- and/or other materials provided with the distribution.
15
-
16
- * Neither the name of the copyright holder nor the names of its
17
- contributors may be used to endorse or promote products derived from
18
- this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024, Mapcreator
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,86 +1,86 @@
1
- # Mapcreator Javascript API
2
-
3
- The Mapcreator API is a powerful mapping service built for our front-end applications. This library is released to
4
- provide a painless way of talking to the api using Javascript. See the LICENSE file for licensing information. Api
5
- tokens can be granted through support requests.
6
-
7
- ## Table of contents
8
-
9
- * [Installation](#installation)
10
- * [Quick start](#quick-start)
11
- * [Common usage](#common-usage)
12
- * [Publishing](#publishing)
13
-
14
- ### Installation
15
-
16
- ```bash
17
- npm install @mapcreator/api --save
18
- ```
19
-
20
- ### Quick start
21
-
22
- ```javascript
23
- import { authenticate, initImplicitFlow } from '@mapcreator/api/oauth';
24
-
25
- /**
26
- * You need to initialize the authentication module.
27
- * This is an important step that should be completed as soon as possible after general application init.
28
- *
29
- * @param {string} apiUrl - Full API URL, like 'https://api.mapcreator.io'
30
- * @param {string} clientId - OAuth client id, issued for particular application
31
- * @param {string} [redirectUrl] - Callback URL, typically your application URL
32
- * @param {string[]} [scopes] - A list of required scopes, like ['mapcreator']
33
- */
34
- initImplicitFlow(
35
- import.meta.env.VITE_API_HOST,
36
- import.meta.env.VITE_API_CLIENT_ID,
37
- import.meta.env.VITE_API_REDIRECT_URL,
38
- ['mapcreator'],
39
- );
40
-
41
- // ...
42
-
43
- /**
44
- * The subsequent command should lead to two scenarios.
45
- * If the initialization function was able to obtain the token from the local storage or from the address bar,
46
- * then this command is NO-OP. If the token is not found or has expired, then a redirect will be made to the
47
- * authentication page (the application will unload), but when it redirects back again (see the parameter above),
48
- * this method won't do anything and the application will be able to continue its work.
49
- */
50
- authenticate();
51
- ```
52
-
53
- ### Common usage
54
-
55
- The library exports independent methods for accessing the API. The recommended pattern for importing and using methods
56
- looks like this:
57
-
58
- ```typescript
59
- import { updateJob } from '@mapcreator/api/job';
60
-
61
- await updateJob(someJobId, newJobTitle);
62
- ```
63
-
64
- You can also import methods by specifying only the package name, but this results in the use of a common file with
65
- re-exports and can negatively affect the size of the resulting code if you do not need some parts of the API.
66
-
67
- ```typescript
68
- import { type LayerFaq, listLayerFaqs } from '@mapcreator/api';
69
-
70
- const layerFaqs: LayerFaq = await listLayerFaqs();
71
- ```
72
-
73
- TypeScript types are also exposed, and you can use them whenever needed.
74
-
75
- Please consult the contents of the library. All API access files (they are located in `api` sub-folder and each file
76
- generally describes methods for accessing specific entity) describe both the API type and the data type returned
77
- to the application. We sincerely hope this helps you make your app development easier.
78
-
79
- ## Publishing
80
- ```shell
81
- npm version patch # minor | major
82
- npm publish
83
- ```
84
- Until the contents of the package are stabilized, it is suggested to use the scheme with the **alpha** or **beta**
85
- suffixes. And therefore the call to the first command should be replaced by manual modification of the `package.json`
86
- and `package-lock.json` files (will need to change in three places).
1
+ # Mapcreator Javascript API
2
+
3
+ The Mapcreator API is a powerful mapping service built for our front-end applications. This library is released to
4
+ provide a painless way of talking to the api using Javascript. See the LICENSE file for licensing information. Api
5
+ tokens can be granted through support requests.
6
+
7
+ ## Table of contents
8
+
9
+ * [Installation](#installation)
10
+ * [Quick start](#quick-start)
11
+ * [Common usage](#common-usage)
12
+ * [Publishing](#publishing)
13
+
14
+ ### Installation
15
+
16
+ ```bash
17
+ npm install @mapcreator/api --save
18
+ ```
19
+
20
+ ### Quick start
21
+
22
+ ```javascript
23
+ import { authenticate, initImplicitFlow } from '@mapcreator/api/oauth';
24
+
25
+ /**
26
+ * You need to initialize the authentication module.
27
+ * This is an important step that should be completed as soon as possible after general application init.
28
+ *
29
+ * @param {string} apiUrl - Full API URL, like 'https://api.mapcreator.io'
30
+ * @param {string} clientId - OAuth client id, issued for particular application
31
+ * @param {string} [redirectUrl] - Callback URL, typically your application URL
32
+ * @param {string[]} [scopes] - A list of required scopes, like ['mapcreator']
33
+ */
34
+ initImplicitFlow(
35
+ import.meta.env.VITE_API_HOST,
36
+ import.meta.env.VITE_API_CLIENT_ID,
37
+ import.meta.env.VITE_API_REDIRECT_URL,
38
+ ['mapcreator'],
39
+ );
40
+
41
+ // ...
42
+
43
+ /**
44
+ * The subsequent command should lead to two scenarios.
45
+ * If the initialization function was able to obtain the token from the local storage or from the address bar,
46
+ * then this command is NO-OP. If the token is not found or has expired, then a redirect will be made to the
47
+ * authentication page (the application will unload), but when it redirects back again (see the parameter above),
48
+ * this method won't do anything and the application will be able to continue its work.
49
+ */
50
+ authenticate();
51
+ ```
52
+
53
+ ### Common usage
54
+
55
+ The library exports independent methods for accessing the API. The recommended pattern for importing and using methods
56
+ looks like this:
57
+
58
+ ```typescript
59
+ import { updateJob } from '@mapcreator/api/job';
60
+
61
+ await updateJob(someJobId, newJobTitle);
62
+ ```
63
+
64
+ You can also import methods by specifying only the package name, but this results in the use of a common file with
65
+ re-exports and can negatively affect the size of the resulting code if you do not need some parts of the API.
66
+
67
+ ```typescript
68
+ import { type LayerFaq, listLayerFaqs } from '@mapcreator/api';
69
+
70
+ const layerFaqs: LayerFaq = await listLayerFaqs();
71
+ ```
72
+
73
+ TypeScript types are also exposed, and you can use them whenever needed.
74
+
75
+ Please consult the contents of the library. All API access files (they are located in `api` sub-folder and each file
76
+ generally describes methods for accessing specific entity) describe both the API type and the data type returned
77
+ to the application. We sincerely hope this helps you make your app development easier.
78
+
79
+ ## Publishing
80
+ ```shell
81
+ npm version patch # minor | major
82
+ npm publish
83
+ ```
84
+ Until the contents of the package are stabilized, it is suggested to use the scheme with the **alpha** or **beta**
85
+ suffixes. And therefore the call to the first command should be replaced by manual modification of the `package.json`
86
+ and `package-lock.json` files (will need to change in three places).
@@ -1,5 +1,6 @@
1
+ import { type ApiError, type ApiSuccess, type Flatten, type Revivers } from '../utils.js';
2
+ import type { RequireAtLeastOne } from 'type-fest';
1
3
  import type { Polygon } from 'geojson';
2
- import { RequireAtLeastOne } from 'type-fest';
3
4
  export type ApiSearchPoint = {
4
5
  lat: number;
5
6
  lng: number;
@@ -16,18 +17,35 @@ type SingleOrGroupedAreaBase = {
16
17
  subtitle: string;
17
18
  svgPreview: string;
18
19
  boundingBox: Polygon;
20
+ isGroup: boolean;
21
+ properties: Record<string, string> | null;
19
22
  };
20
- export type GroupedArea = SingleOrGroupedAreaBase & {
21
- isGroup: true;
22
- };
23
+ export type GroupedArea = SingleOrGroupedAreaBase;
23
24
  export type SingleArea = SingleOrGroupedAreaBase & {
24
- isGroup: false;
25
25
  vectorSource: string;
26
26
  sourceLayer: string;
27
27
  featureId: number;
28
- properties: Record<string, string>;
29
28
  };
30
29
  export type SingleOrGroupedArea = SingleArea | GroupedArea;
30
+ export type ApiSingleOrGroupedArea = {
31
+ data: {
32
+ id: number;
33
+ title: string;
34
+ subtitle: string;
35
+ svg_preview: string;
36
+ bounding_box: string;
37
+ is_group: boolean;
38
+ vector_source: string | null;
39
+ source_layer: string | null;
40
+ feature_id: number | null;
41
+ properties: string | null;
42
+ };
43
+ } & Omit<ApiSuccess, 'data'> | ApiError;
44
+ export type ApiSingleOrGroupedAreaData = Flatten<Exclude<ApiSingleOrGroupedArea, ApiError>['data']>;
45
+ export declare const singleOrGroupedAreaRevivers: Revivers<ApiSingleOrGroupedArea, SingleOrGroupedArea>;
46
+ /**
47
+ * TODO When SAGA search on click is implemented, remove mode and make searchBounds required
48
+ */
31
49
  export declare function searchSingleOrGroupedAreas(language: string, search: RequireAtLeastOne<{
32
50
  searchBounds?: ApiSearchBounds;
33
51
  query?: string;
@@ -39,8 +57,63 @@ export type GroupedAreaChild = {
39
57
  vectorSource: string;
40
58
  sourceLayer: string;
41
59
  featureId: number;
60
+ boundingBox: Polygon;
42
61
  properties: Record<string, string>;
43
62
  };
63
+ type ApiGroupedAreaChild = {
64
+ data: {
65
+ id: number;
66
+ title: string;
67
+ vector_source: string;
68
+ source_layer: string;
69
+ feature_id: number;
70
+ bounding_box: string;
71
+ properties: string;
72
+ };
73
+ } & Omit<ApiSuccess, 'data'> | ApiError;
74
+ export type ApiGroupedAreaChildData = Flatten<Exclude<ApiGroupedAreaChild, ApiError>['data']>;
75
+ export declare const groupedAreaChildRevivers: Revivers<ApiGroupedAreaChild, GroupedAreaChild>;
44
76
  export declare function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]>;
77
+ export type MatchedGroup = {
78
+ id: number;
79
+ sml: number;
80
+ childrenCount: number;
81
+ matchField: string;
82
+ property: string;
83
+ name: string;
84
+ };
85
+ export type ApiMatchedGroup = {
86
+ data: {
87
+ id: number;
88
+ sml: number;
89
+ children_count: number;
90
+ match_field: string;
91
+ property: string;
92
+ name: string;
93
+ };
94
+ } & Omit<ApiSuccess, 'data'> | ApiError;
95
+ export type ApiMatchedGroupData = Flatten<Exclude<ApiMatchedGroup, ApiError>['data']>;
96
+ export declare function getGroupsByDataSample(sample: Record<string, string[]>, language: string): Promise<MatchedGroup[]>;
97
+ export type BoundPolygon = {
98
+ index: number;
99
+ id: number;
100
+ sml: number;
101
+ name: string;
102
+ inputName: string;
103
+ boundingBox: Polygon;
104
+ };
105
+ export type ApiBoundPolygon = {
106
+ data: {
107
+ index: number;
108
+ id: number;
109
+ sml: number;
110
+ name: string;
111
+ input_name: string;
112
+ bounding_box: string;
113
+ };
114
+ } & Omit<ApiSuccess, 'data'> | ApiError;
115
+ export type ApiBoundPolygonData = Flatten<Exclude<ApiBoundPolygon, ApiError>['data']>;
116
+ export declare const boundPolygonRevivers: Revivers<ApiBoundPolygon, BoundPolygon>;
117
+ export declare function getBoundPolygons(groupId: number, property: string, data: string[], language: string): Promise<BoundPolygon[]>;
45
118
  export {};
46
119
  //# sourceMappingURL=choropleth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"choropleth.d.ts","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAmBF,KAAK,uBAAuB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM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M,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC;AAExC,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEtF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,eAAe,EAAE,YAAY,CAExE,CAAC;AAEF,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,EAAE,CAAC,CAUzB"}
@@ -1,28 +1,47 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.boundPolygonRevivers = exports.groupedAreaChildRevivers = exports.singleOrGroupedAreaRevivers = void 0;
3
4
  exports.searchSingleOrGroupedAreas = searchSingleOrGroupedAreas;
4
5
  exports.groupedAreaChildren = groupedAreaChildren;
6
+ exports.getGroupsByDataSample = getGroupsByDataSample;
7
+ exports.getBoundPolygons = getBoundPolygons;
5
8
  const utils_js_1 = require("../utils.js");
9
+ exports.singleOrGroupedAreaRevivers = {
10
+ boundingBox: (data) => JSON.parse(data.bounding_box),
11
+ properties: (data) => (data.properties != null ? JSON.parse(data.properties) : null),
12
+ };
13
+ /**
14
+ * TODO When SAGA search on click is implemented, remove mode and make searchBounds required
15
+ */
6
16
  async function searchSingleOrGroupedAreas(language, search, mode = 'both') {
7
- /**
8
- * TODO When SAGA search on click is implemented, remove mode and make searchBounds required
9
- */
10
- return (0, utils_js_1.request)(`/v1/choropleth/polygons/search?${(0, utils_js_1.getSearchParams)(Object.assign(Object.assign(Object.assign(Object.assign({ language }, search.searchBounds), (search.query && { query: search.query })), (search.searchPoint && { point: search.searchPoint })), { mode }))}`).then(result => {
11
- result.forEach(elem => {
12
- elem.boundingBox = JSON.parse(elem.boundingBox);
13
- if (!elem.isGroup) {
14
- elem.properties = JSON.parse(elem.properties);
15
- }
16
- });
17
- return result;
18
- });
17
+ const pathname = '/v1/choropleth/polygons/search';
18
+ const query = (0, utils_js_1.getSearchParams)(Object.assign(Object.assign(Object.assign(Object.assign({ language }, search.searchBounds), (search.query && { query: search.query })), (search.searchPoint && { point: search.searchPoint })), { mode }));
19
+ const path = `${pathname}?${query}`;
20
+ const options = { revivers: exports.singleOrGroupedAreaRevivers };
21
+ return (0, utils_js_1.request)(path, null, null, options);
19
22
  }
23
+ exports.groupedAreaChildRevivers = {
24
+ boundingBox: (data) => JSON.parse(data.bounding_box),
25
+ properties: (data) => JSON.parse(data.properties),
26
+ };
20
27
  async function groupedAreaChildren(groupId, language) {
21
- return (0, utils_js_1.request)(`/v1/choropleth/groups/${groupId}/children-optimized?${(0, utils_js_1.getSearchParams)({ language })}`).then(result => {
22
- result.forEach(elem => {
23
- elem.properties = JSON.parse(elem.properties);
24
- });
25
- return result;
26
- });
28
+ const pathname = `/v1/choropleth/groups/${groupId}/children-optimized`;
29
+ const query = (0, utils_js_1.getSearchParams)({ language });
30
+ const path = `${pathname}?${query}`;
31
+ const options = { revivers: exports.groupedAreaChildRevivers };
32
+ return (0, utils_js_1.request)(path, null, null, options);
33
+ }
34
+ async function getGroupsByDataSample(sample, language) {
35
+ const path = `/v1/choropleth/groups/sample`;
36
+ return (0, utils_js_1.request)(path, { sample, language });
37
+ }
38
+ exports.boundPolygonRevivers = {
39
+ boundingBox: (data) => JSON.parse(data.bounding_box),
40
+ };
41
+ async function getBoundPolygons(groupId, property, data, language) {
42
+ const path = `/v1/choropleth/groups/bind`;
43
+ const body = { group_id: groupId, property, data, language };
44
+ const options = { revivers: exports.boundPolygonRevivers };
45
+ return (0, utils_js_1.request)(path, body, null, options);
27
46
  }
28
47
  //# sourceMappingURL=choropleth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"choropleth.js","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":";;AAyDA,gEAgCC;AAwBD,kDAYC;AA7HD,0CAAuF;AAyDhF,KAAK,UAAU,0BAA0B,CAC9C,QAAgB,EAChB,MAIE,EACF,OAAqC,MAAM;IAE3C;;OAEG;IACH,OAAO,IAAA,kBAAO,EACZ,kCAAkC,IAAA,0BAAe,4DAC/C,QAAQ,IACL,MAAM,CAAC,YAAY,GACnB,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,GACzC,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,KACxD,IAAI,IACJ,EAAE,CACL,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACd,MAAM,CAAC,OAAO,CACZ,IAAI,CAAC,EAAE;YACL,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAgC,CAAY,CAAC;YAChF,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAA+B,CAA2B,CAAC;YAC/F,CAAC;QACH,CAAC,CACF,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CA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C,KAAK,CAAC,IAAI,CAAC,YAAY,CAAY;CACrF,CAAC;AAEK,KAAK,UAAU,gBAAgB,CACpC,OAAe,EACf,QAAgB,EAChB,IAAc,EACd,QAAgB;IAEhB,MAAM,IAAI,GAAG,4BAA4B,CAAC;IAC1C,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC7D,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,4BAAoB,EAAE,CAAC;IAMnD,OAAO,IAAA,kBAAO,EAAqC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAChF,CAAC"}
@@ -1,5 +1,6 @@
1
+ import { type ApiError, type ApiSuccess, type Flatten, type Revivers } from '../utils.js';
2
+ import type { RequireAtLeastOne } from 'type-fest';
1
3
  import type { Polygon } from 'geojson';
2
- import { RequireAtLeastOne } from 'type-fest';
3
4
  export type ApiSearchPoint = {
4
5
  lat: number;
5
6
  lng: number;
@@ -16,18 +17,35 @@ type SingleOrGroupedAreaBase = {
16
17
  subtitle: string;
17
18
  svgPreview: string;
18
19
  boundingBox: Polygon;
20
+ isGroup: boolean;
21
+ properties: Record<string, string> | null;
19
22
  };
20
- export type GroupedArea = SingleOrGroupedAreaBase & {
21
- isGroup: true;
22
- };
23
+ export type GroupedArea = SingleOrGroupedAreaBase;
23
24
  export type SingleArea = SingleOrGroupedAreaBase & {
24
- isGroup: false;
25
25
  vectorSource: string;
26
26
  sourceLayer: string;
27
27
  featureId: number;
28
- properties: Record<string, string>;
29
28
  };
30
29
  export type SingleOrGroupedArea = SingleArea | GroupedArea;
30
+ export type ApiSingleOrGroupedArea = {
31
+ data: {
32
+ id: number;
33
+ title: string;
34
+ subtitle: string;
35
+ svg_preview: string;
36
+ bounding_box: string;
37
+ is_group: boolean;
38
+ vector_source: string | null;
39
+ source_layer: string | null;
40
+ feature_id: number | null;
41
+ properties: string | null;
42
+ };
43
+ } & Omit<ApiSuccess, 'data'> | ApiError;
44
+ export type ApiSingleOrGroupedAreaData = Flatten<Exclude<ApiSingleOrGroupedArea, ApiError>['data']>;
45
+ export declare const singleOrGroupedAreaRevivers: Revivers<ApiSingleOrGroupedArea, SingleOrGroupedArea>;
46
+ /**
47
+ * TODO When SAGA search on click is implemented, remove mode and make searchBounds required
48
+ */
31
49
  export declare function searchSingleOrGroupedAreas(language: string, search: RequireAtLeastOne<{
32
50
  searchBounds?: ApiSearchBounds;
33
51
  query?: string;
@@ -39,8 +57,63 @@ export type GroupedAreaChild = {
39
57
  vectorSource: string;
40
58
  sourceLayer: string;
41
59
  featureId: number;
60
+ boundingBox: Polygon;
42
61
  properties: Record<string, string>;
43
62
  };
63
+ type ApiGroupedAreaChild = {
64
+ data: {
65
+ id: number;
66
+ title: string;
67
+ vector_source: string;
68
+ source_layer: string;
69
+ feature_id: number;
70
+ bounding_box: string;
71
+ properties: string;
72
+ };
73
+ } & Omit<ApiSuccess, 'data'> | ApiError;
74
+ export type ApiGroupedAreaChildData = Flatten<Exclude<ApiGroupedAreaChild, ApiError>['data']>;
75
+ export declare const groupedAreaChildRevivers: Revivers<ApiGroupedAreaChild, GroupedAreaChild>;
44
76
  export declare function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]>;
77
+ export type MatchedGroup = {
78
+ id: number;
79
+ sml: number;
80
+ childrenCount: number;
81
+ matchField: string;
82
+ property: string;
83
+ name: string;
84
+ };
85
+ export type ApiMatchedGroup = {
86
+ data: {
87
+ id: number;
88
+ sml: number;
89
+ children_count: number;
90
+ match_field: string;
91
+ property: string;
92
+ name: string;
93
+ };
94
+ } & Omit<ApiSuccess, 'data'> | ApiError;
95
+ export type ApiMatchedGroupData = Flatten<Exclude<ApiMatchedGroup, ApiError>['data']>;
96
+ export declare function getGroupsByDataSample(sample: Record<string, string[]>, language: string): Promise<MatchedGroup[]>;
97
+ export type BoundPolygon = {
98
+ index: number;
99
+ id: number;
100
+ sml: number;
101
+ name: string;
102
+ inputName: string;
103
+ boundingBox: Polygon;
104
+ };
105
+ export type ApiBoundPolygon = {
106
+ data: {
107
+ index: number;
108
+ id: number;
109
+ sml: number;
110
+ name: string;
111
+ input_name: string;
112
+ bounding_box: string;
113
+ };
114
+ } & Omit<ApiSuccess, 'data'> | ApiError;
115
+ export type ApiBoundPolygonData = Flatten<Exclude<ApiBoundPolygon, ApiError>['data']>;
116
+ export declare const boundPolygonRevivers: Revivers<ApiBoundPolygon, BoundPolygon>;
117
+ export declare function getBoundPolygons(groupId: number, property: string, data: string[], language: string): Promise<BoundPolygon[]>;
45
118
  export {};
46
119
  //# sourceMappingURL=choropleth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"choropleth.d.ts","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAmBF,KAAK,uBAAuB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAGF,MAAM,MAAM,WAAW,GAAG,uBAAuB,GAAG;IAClD,OAAO,EAAE,IAAI,CAAC;CACf,CAAC;AAGF,MAAM,MAAM,UAAU,GAAG,uBAAuB,GAAG;IACjD,OAAO,EAAE,KAAK,CAAC;IACf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F,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC;AAExC,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEtF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,eAAe,EAAE,YAAY,CAExE,CAAC;AAEF,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,EAAE,CAAC,CAUzB"}
@@ -1,24 +1,40 @@
1
1
  import { getSearchParams, request } from '../utils.js';
2
+ export const singleOrGroupedAreaRevivers = {
3
+ boundingBox: (data) => JSON.parse(data.bounding_box),
4
+ properties: (data) => (data.properties != null ? JSON.parse(data.properties) : null),
5
+ };
6
+ /**
7
+ * TODO When SAGA search on click is implemented, remove mode and make searchBounds required
8
+ */
2
9
  export async function searchSingleOrGroupedAreas(language, search, mode = 'both') {
3
- /**
4
- * TODO When SAGA search on click is implemented, remove mode and make searchBounds required
5
- */
6
- return request(`/v1/choropleth/polygons/search?${getSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({ language }, search.searchBounds), (search.query && { query: search.query })), (search.searchPoint && { point: search.searchPoint })), { mode }))}`).then(result => {
7
- result.forEach(elem => {
8
- elem.boundingBox = JSON.parse(elem.boundingBox);
9
- if (!elem.isGroup) {
10
- elem.properties = JSON.parse(elem.properties);
11
- }
12
- });
13
- return result;
14
- });
10
+ const pathname = '/v1/choropleth/polygons/search';
11
+ const query = getSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({ language }, search.searchBounds), (search.query && { query: search.query })), (search.searchPoint && { point: search.searchPoint })), { mode }));
12
+ const path = `${pathname}?${query}`;
13
+ const options = { revivers: singleOrGroupedAreaRevivers };
14
+ return request(path, null, null, options);
15
15
  }
16
+ export const groupedAreaChildRevivers = {
17
+ boundingBox: (data) => JSON.parse(data.bounding_box),
18
+ properties: (data) => JSON.parse(data.properties),
19
+ };
16
20
  export async function groupedAreaChildren(groupId, language) {
17
- return request(`/v1/choropleth/groups/${groupId}/children-optimized?${getSearchParams({ language })}`).then(result => {
18
- result.forEach(elem => {
19
- elem.properties = JSON.parse(elem.properties);
20
- });
21
- return result;
22
- });
21
+ const pathname = `/v1/choropleth/groups/${groupId}/children-optimized`;
22
+ const query = getSearchParams({ language });
23
+ const path = `${pathname}?${query}`;
24
+ const options = { revivers: groupedAreaChildRevivers };
25
+ return request(path, null, null, options);
26
+ }
27
+ export async function getGroupsByDataSample(sample, language) {
28
+ const path = `/v1/choropleth/groups/sample`;
29
+ return request(path, { sample, language });
30
+ }
31
+ export const boundPolygonRevivers = {
32
+ boundingBox: (data) => JSON.parse(data.bounding_box),
33
+ };
34
+ export async function getBoundPolygons(groupId, property, data, language) {
35
+ const path = `/v1/choropleth/groups/bind`;
36
+ const body = { group_id: groupId, property, data, language };
37
+ const options = { revivers: boundPolygonRevivers };
38
+ return request(path, body, null, options);
23
39
  }
24
40
  //# sourceMappingURL=choropleth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"choropleth.js","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,eAAe,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAyDvF,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,QAAgB,EAChB,MAIE,EACF,OAAqC,MAAM;IAE3C;;OAEG;IACH,OAAO,OAAO,CAC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