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

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,5 @@
1
+ import type { RequireAtLeastOne } from 'type-fest';
1
2
  import type { Polygon } from 'geojson';
2
- import { RequireAtLeastOne } from 'type-fest';
3
3
  export type ApiSearchPoint = {
4
4
  lat: number;
5
5
  lng: number;
@@ -42,5 +42,37 @@ export type GroupedAreaChild = {
42
42
  properties: Record<string, string>;
43
43
  };
44
44
  export declare function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]>;
45
+ export type MatchedGroup = {
46
+ id: number;
47
+ sml: number;
48
+ childrenCount: number;
49
+ matchField: string;
50
+ property: string;
51
+ name: string;
52
+ };
53
+ export type ApiMatchedGroup = {
54
+ id: number;
55
+ sml: number;
56
+ children_count: number;
57
+ match_field: string;
58
+ property: string;
59
+ name: string;
60
+ };
61
+ export declare function getGroupsByDataSample(sample: Array<Record<string, string[]>>, language: string): Promise<MatchedGroup[]>;
62
+ export type BoundPolygon = {
63
+ index: number;
64
+ id: number;
65
+ sml: number;
66
+ name: string;
67
+ inputName: string;
68
+ };
69
+ export type ApiBoundPolygon = {
70
+ index: number;
71
+ id: number;
72
+ sml: number;
73
+ name: string;
74
+ input_name: string;
75
+ };
76
+ export declare function getBoundPolygons(groupId: number, property: string, data: string[], language: string): Promise<BoundPolygon[]>;
45
77
  export {};
46
78
  //# 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,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,mBA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,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,EACvC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,EAAE,CAAC,CAQzB;AAED,MAAM,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;CACnB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,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,CASzB"}
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.searchSingleOrGroupedAreas = searchSingleOrGroupedAreas;
4
4
  exports.groupedAreaChildren = groupedAreaChildren;
5
+ exports.getGroupsByDataSample = getGroupsByDataSample;
6
+ exports.getBoundPolygons = getBoundPolygons;
5
7
  const utils_js_1 = require("../utils.js");
6
8
  async function searchSingleOrGroupedAreas(language, search, mode = 'both') {
7
9
  /**
@@ -25,4 +27,13 @@ async function groupedAreaChildren(groupId, language) {
25
27
  return result;
26
28
  });
27
29
  }
30
+ async function getGroupsByDataSample(sample, language) {
31
+ const path = `/v1/choropleth/groups/sample`;
32
+ return (0, utils_js_1.request)(path, { sample, language });
33
+ }
34
+ async function getBoundPolygons(groupId, property, data, language) {
35
+ const path = `/v1/choropleth/groups/bind`;
36
+ const postBody = { group_id: groupId, property, data, language };
37
+ return (0, utils_js_1.request)(path, postBody);
38
+ }
28
39
  //# 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,IA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geojson';
2
- import { RequireAtLeastOne } from 'type-fest';
3
3
  export type ApiSearchPoint = {
4
4
  lat: number;
5
5
  lng: number;
@@ -42,5 +42,37 @@ export type GroupedAreaChild = {
42
42
  properties: Record<string, string>;
43
43
  };
44
44
  export declare function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]>;
45
+ export type MatchedGroup = {
46
+ id: number;
47
+ sml: number;
48
+ childrenCount: number;
49
+ matchField: string;
50
+ property: string;
51
+ name: string;
52
+ };
53
+ export type ApiMatchedGroup = {
54
+ id: number;
55
+ sml: number;
56
+ children_count: number;
57
+ match_field: string;
58
+ property: string;
59
+ name: string;
60
+ };
61
+ export declare function getGroupsByDataSample(sample: Array<Record<string, string[]>>, language: string): Promise<MatchedGroup[]>;
62
+ export type BoundPolygon = {
63
+ index: number;
64
+ id: number;
65
+ sml: number;
66
+ name: string;
67
+ inputName: string;
68
+ };
69
+ export type ApiBoundPolygon = {
70
+ index: number;
71
+ id: number;
72
+ sml: number;
73
+ name: string;
74
+ input_name: string;
75
+ };
76
+ export declare function getBoundPolygons(groupId: number, property: string, data: string[], language: string): Promise<BoundPolygon[]>;
45
77
  export {};
46
78
  //# 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,uBAA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,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,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,CASzB"}
@@ -21,4 +21,13 @@ export async function groupedAreaChildren(groupId, language) {
21
21
  return result;
22
22
  });
23
23
  }
24
+ export async function getGroupsByDataSample(sample, language) {
25
+ const path = `/v1/choropleth/groups/sample`;
26
+ return request(path, { sample, language });
27
+ }
28
+ export async function getBoundPolygons(groupId, property, data, language) {
29
+ const path = `/v1/choropleth/groups/bind`;
30
+ const postBody = { group_id: groupId, property, data, language };
31
+ return request(path, postBody);
32
+ }
24
33
  //# 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,CACZ,kCAAkC,eAAe,2DAC/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,CAA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Q,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAMjE,OAAO,OAAO,CAAqC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACrE,CAAC"}
package/package.json CHANGED
@@ -1,80 +1,80 @@
1
- {
2
- "name": "@mapcreator/api",
3
- "version": "5.0.0-alpha.73",
4
- "description": "Mapcreator JavaScript API",
5
- "license": "BSD-3-Clause",
6
- "main": "./cjs/index.js",
7
- "types": "./cjs/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./esm/index.d.ts",
11
- "import": "./esm/index.js",
12
- "require": "./cjs/index.js"
13
- },
14
- "./oauth": {
15
- "types": "./esm/oauth.d.ts",
16
- "import": "./esm/oauth.js",
17
- "require": "./cjs/oauth.js"
18
- },
19
- "./oauth.js": {
20
- "types": "./esm/oauth.d.ts",
21
- "import": "./esm/oauth.js",
22
- "require": "./cjs/oauth.js"
23
- },
24
- "./utils": {
25
- "types": "./esm/utils.d.ts",
26
- "import": "./esm/utils.js",
27
- "require": "./cjs/utils.js"
28
- },
29
- "./utils.js": {
30
- "types": "./esm/utils.d.ts",
31
- "import": "./esm/utils.js",
32
- "require": "./cjs/utils.js"
33
- },
34
- "./package.json": "./package.json",
35
- "./*": {
36
- "types": "./esm/api/*.d.ts",
37
- "import": "./esm/api/*.js",
38
- "require": "./cjs/api/*.js"
39
- },
40
- "./*.js": {
41
- "types": "./esm/api/*.d.ts",
42
- "import": "./esm/api/*.js",
43
- "require": "./cjs/api/*.js"
44
- }
45
- },
46
- "scripts": {
47
- "build": "tsc --outDir esm && tsc -m commonjs --outDir cjs",
48
- "clean": "npx rimraf esm/ cjs/",
49
- "lint": "eslint --ext .ts src",
50
- "prepublishOnly": "npm run lint && npm run clean && npm run build",
51
- "test": "echo \"Error: no test specified\" && exit 1"
52
- },
53
- "repository": {
54
- "type": "git",
55
- "url": "git+https://gitlab.com/mapcreator/api-wrapper.git"
56
- },
57
- "publishConfig": {
58
- "registry": "https://registry.npmjs.org/"
59
- },
60
- "files": [
61
- "cjs",
62
- "esm",
63
- "src"
64
- ],
65
- "bugs": {
66
- "url": "https://gitlab.com/mapcreator/api-wrapper/issues"
67
- },
68
- "homepage": "https://gitlab.com/mapcreator/api-wrapper#readme",
69
- "dependencies": {
70
- "@types/geojson": "^7946.0.14",
71
- "type-fest": "^4.10"
72
- },
73
- "devDependencies": {
74
- "@stylistic/eslint-plugin": "~1.5",
75
- "@typescript-eslint/eslint-plugin": "~6.15",
76
- "@typescript-eslint/parser": "~6.15",
77
- "eslint": "~8.57",
78
- "typescript": "~5.8.3"
79
- }
80
- }
1
+ {
2
+ "name": "@mapcreator/api",
3
+ "version": "5.0.0-alpha.74",
4
+ "description": "Mapcreator JavaScript API",
5
+ "license": "BSD-3-Clause",
6
+ "main": "./cjs/index.js",
7
+ "types": "./cjs/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./esm/index.d.ts",
11
+ "import": "./esm/index.js",
12
+ "require": "./cjs/index.js"
13
+ },
14
+ "./oauth": {
15
+ "types": "./esm/oauth.d.ts",
16
+ "import": "./esm/oauth.js",
17
+ "require": "./cjs/oauth.js"
18
+ },
19
+ "./oauth.js": {
20
+ "types": "./esm/oauth.d.ts",
21
+ "import": "./esm/oauth.js",
22
+ "require": "./cjs/oauth.js"
23
+ },
24
+ "./utils": {
25
+ "types": "./esm/utils.d.ts",
26
+ "import": "./esm/utils.js",
27
+ "require": "./cjs/utils.js"
28
+ },
29
+ "./utils.js": {
30
+ "types": "./esm/utils.d.ts",
31
+ "import": "./esm/utils.js",
32
+ "require": "./cjs/utils.js"
33
+ },
34
+ "./package.json": "./package.json",
35
+ "./*": {
36
+ "types": "./esm/api/*.d.ts",
37
+ "import": "./esm/api/*.js",
38
+ "require": "./cjs/api/*.js"
39
+ },
40
+ "./*.js": {
41
+ "types": "./esm/api/*.d.ts",
42
+ "import": "./esm/api/*.js",
43
+ "require": "./cjs/api/*.js"
44
+ }
45
+ },
46
+ "scripts": {
47
+ "build": "tsc --outDir esm && tsc -m commonjs --outDir cjs",
48
+ "clean": "npx rimraf esm/ cjs/",
49
+ "lint": "eslint --ext .ts src",
50
+ "prepublishOnly": "npm run lint && npm run clean && npm run build",
51
+ "test": "echo \"Error: no test specified\" && exit 1"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://gitlab.com/mapcreator/api-wrapper.git"
56
+ },
57
+ "publishConfig": {
58
+ "registry": "https://registry.npmjs.org/"
59
+ },
60
+ "files": [
61
+ "cjs",
62
+ "esm",
63
+ "src"
64
+ ],
65
+ "bugs": {
66
+ "url": "https://gitlab.com/mapcreator/api-wrapper/issues"
67
+ },
68
+ "homepage": "https://gitlab.com/mapcreator/api-wrapper#readme",
69
+ "dependencies": {
70
+ "@types/geojson": "^7946.0.14",
71
+ "type-fest": "^4.10"
72
+ },
73
+ "devDependencies": {
74
+ "@stylistic/eslint-plugin": "~1.5",
75
+ "@typescript-eslint/eslint-plugin": "~6.15",
76
+ "@typescript-eslint/parser": "~6.15",
77
+ "eslint": "~8.57",
78
+ "typescript": "~5.8.3"
79
+ }
80
+ }
package/src/README.md CHANGED
@@ -1,126 +1,126 @@
1
- ### Used type system
2
-
3
- We use type declarations for both the data coming over the wire and the data used by the application. In general, these types differ only in the presence of additional fields in the data arriving over the network (like `created_at`), and used naming convention. Data over the network uses the so-called snake case.
4
-
5
- All in all, we can use TypeScript's native mechanisms to convert one type to another and fully define just one type:
6
-
7
- ```typescript
8
- import type { CamelCasedProperties } from 'type-fest';
9
-
10
- type ApiType =
11
- | ({
12
- data: {
13
- prop: unknown;
14
- } & ApiCommonData;
15
- } & Omit<ApiSuccess, 'data'>)
16
- | ApiError;
17
-
18
- type AppType = CamelCasedProperties<Omit<Exclude<ApiType, ApiError>['data'], keyof ApiCommonData>>;
19
- ```
20
-
21
- or in reverse order:
22
-
23
- ```typescript
24
- import type { SnakeCasedProperties } from 'type-fest';
25
-
26
- type AppType = {
27
- prop: unknown;
28
- };
29
-
30
- type ApiType =
31
- | ({
32
- data: SnakeCasedProperties<AppType> & ApiCommonData;
33
- } & Omit<ApiSuccess, 'data'>)
34
- | ApiError;
35
- ```
36
-
37
- But the decision was made not to do this, since it may be more difficult for the developer to make the conversion in their head than to see it in front of their eyes.
38
-
39
- ### Using a `request()`
40
-
41
- The function has the following signature:
42
-
43
- ```typescript
44
- async function request<I extends ApiCommon, O extends Record<string, unknown> | string>(
45
- path: string,
46
- body?: XMLHttpRequestBodyInit | Record<string | number, unknown> | null,
47
- extraHeaders?: Record<string, string> | null,
48
- extraOptions?: ExtraOptions<I, O>,
49
- ): Promise<O | O[]> { /* ... */ }
50
- ```
51
-
52
- Let's take it step by step.
53
-
54
- `I extends ApiCommon` - represents the type of data we receive over the network.
55
-
56
- `O extends Record<string, unknown> | string` - represents the data type that will be used in the application.
57
-
58
- Ideally you should describe and convey both types. This will help to check the data types in the arguments passed.
59
- See current data types for an example.
60
-
61
- `path: string` - the path to the resource, must include the API version, but must not include the schema or authority.
62
- Example: `/v1/jobs/12345`
63
-
64
- `body?: XMLHttpRequestBodyInit | Record<string | number, unknown> | null` - any meaningful body type. In general,
65
- the presence of an JSON object is assumed (or the absence of one for methods that only request data), but you can
66
- also pass `Blob`, `FormData`, `URLSearchParams` or just `ArrayBuffer`. The required content type will be added to
67
- the headers automatically.
68
-
69
- `extraHeaders?: Record<string, string> | null` - the object with additional headers.
70
-
71
- `extraOptions?: ExtraOptions<I, O>` - where `ExtraOptions<I, O>` is defined like this:
72
-
73
- ```typescript
74
- interface ExtraOptions<I extends ApiCommon, O extends Record<string, unknown> | string> {
75
- method?: 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
76
- revivers?: O extends Record<string, unknown> ? Revivers<I, O> : never;
77
- sendNull?: boolean;
78
- withMeta?: boolean;
79
- }
80
- ```
81
-
82
- Most fields are self-explanatory.
83
-
84
- `sendNull` can be used if you really want to pass `null` as body content.
85
-
86
- `revivers` is used to specify an object that can modify the behavior of the internal handler of data coming over
87
- the network. Let's take a closer look at this moment.
88
-
89
- #### Revivers
90
-
91
- By default, the `request()` function does the following things with data coming over the network:
92
-
93
- - It removes `created_at`, `updated_at`, `deleted_at` fields from the output objects.
94
- - It preserves all the remaining fields but converts their names into camelCase.
95
-
96
- When passing an object with revivers you can a couple of things:
97
-
98
- - You can list the fields that you want **to exclude** from the result object. To do this, the field must be assigned an
99
- `undefined` value.
100
- - You can **add** new fields or **modify** the type of existing ones. To do this, you need to pass a function as a field
101
- value, which will receive the original object as input.
102
-
103
- Example:
104
-
105
- ```typescript
106
- const jobRevivers: Revivers<ApiJob, Job> = {
107
- user_id: undefined,
108
- description: undefined,
109
- share_token: undefined,
110
- autosave_preview_path: undefined,
111
- job_folder_id: undefined,
112
-
113
- jobTypeId: () => 9,
114
- createdAt: (data: ApiJobData) => data.created_at as string,
115
- previewPath: (data: ApiJobData) => data.autosave_preview_path ?? undefined,
116
- };
117
- ```
118
-
119
- `user_id`, `description`, `share_token`, `autosave_preview_path`, `job_folder_id` fields will be excluded from the
120
- result object.
121
-
122
- `jobTypeId` will be always **9**.
123
-
124
- `createdAt` will be returned (please note that that field is excluded by default)
125
-
126
- `previewPath` - some actions will be performed with the source data.
1
+ ### Used type system
2
+
3
+ We use type declarations for both the data coming over the wire and the data used by the application. In general, these types differ only in the presence of additional fields in the data arriving over the network (like `created_at`), and used naming convention. Data over the network uses the so-called snake case.
4
+
5
+ All in all, we can use TypeScript's native mechanisms to convert one type to another and fully define just one type:
6
+
7
+ ```typescript
8
+ import type { CamelCasedProperties } from 'type-fest';
9
+
10
+ type ApiType =
11
+ | ({
12
+ data: {
13
+ prop: unknown;
14
+ } & ApiCommonData;
15
+ } & Omit<ApiSuccess, 'data'>)
16
+ | ApiError;
17
+
18
+ type AppType = CamelCasedProperties<Omit<Exclude<ApiType, ApiError>['data'], keyof ApiCommonData>>;
19
+ ```
20
+
21
+ or in reverse order:
22
+
23
+ ```typescript
24
+ import type { SnakeCasedProperties } from 'type-fest';
25
+
26
+ type AppType = {
27
+ prop: unknown;
28
+ };
29
+
30
+ type ApiType =
31
+ | ({
32
+ data: SnakeCasedProperties<AppType> & ApiCommonData;
33
+ } & Omit<ApiSuccess, 'data'>)
34
+ | ApiError;
35
+ ```
36
+
37
+ But the decision was made not to do this, since it may be more difficult for the developer to make the conversion in their head than to see it in front of their eyes.
38
+
39
+ ### Using a `request()`
40
+
41
+ The function has the following signature:
42
+
43
+ ```typescript
44
+ async function request<I extends ApiCommon, O extends Record<string, unknown> | string>(
45
+ path: string,
46
+ body?: XMLHttpRequestBodyInit | Record<string | number, unknown> | null,
47
+ extraHeaders?: Record<string, string> | null,
48
+ extraOptions?: ExtraOptions<I, O>,
49
+ ): Promise<O | O[]> { /* ... */ }
50
+ ```
51
+
52
+ Let's take it step by step.
53
+
54
+ `I extends ApiCommon` - represents the type of data we receive over the network.
55
+
56
+ `O extends Record<string, unknown> | string` - represents the data type that will be used in the application.
57
+
58
+ Ideally you should describe and convey both types. This will help to check the data types in the arguments passed.
59
+ See current data types for an example.
60
+
61
+ `path: string` - the path to the resource, must include the API version, but must not include the schema or authority.
62
+ Example: `/v1/jobs/12345`
63
+
64
+ `body?: XMLHttpRequestBodyInit | Record<string | number, unknown> | null` - any meaningful body type. In general,
65
+ the presence of an JSON object is assumed (or the absence of one for methods that only request data), but you can
66
+ also pass `Blob`, `FormData`, `URLSearchParams` or just `ArrayBuffer`. The required content type will be added to
67
+ the headers automatically.
68
+
69
+ `extraHeaders?: Record<string, string> | null` - the object with additional headers.
70
+
71
+ `extraOptions?: ExtraOptions<I, O>` - where `ExtraOptions<I, O>` is defined like this:
72
+
73
+ ```typescript
74
+ interface ExtraOptions<I extends ApiCommon, O extends Record<string, unknown> | string> {
75
+ method?: 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
76
+ revivers?: O extends Record<string, unknown> ? Revivers<I, O> : never;
77
+ sendNull?: boolean;
78
+ withMeta?: boolean;
79
+ }
80
+ ```
81
+
82
+ Most fields are self-explanatory.
83
+
84
+ `sendNull` can be used if you really want to pass `null` as body content.
85
+
86
+ `revivers` is used to specify an object that can modify the behavior of the internal handler of data coming over
87
+ the network. Let's take a closer look at this moment.
88
+
89
+ #### Revivers
90
+
91
+ By default, the `request()` function does the following things with data coming over the network:
92
+
93
+ - It removes `created_at`, `updated_at`, `deleted_at` fields from the output objects.
94
+ - It preserves all the remaining fields but converts their names into camelCase.
95
+
96
+ When passing an object with revivers you can a couple of things:
97
+
98
+ - You can list the fields that you want **to exclude** from the result object. To do this, the field must be assigned an
99
+ `undefined` value.
100
+ - You can **add** new fields or **modify** the type of existing ones. To do this, you need to pass a function as a field
101
+ value, which will receive the original object as input.
102
+
103
+ Example:
104
+
105
+ ```typescript
106
+ const jobRevivers: Revivers<ApiJob, Job> = {
107
+ user_id: undefined,
108
+ description: undefined,
109
+ share_token: undefined,
110
+ autosave_preview_path: undefined,
111
+ job_folder_id: undefined,
112
+
113
+ jobTypeId: () => 9,
114
+ createdAt: (data: ApiJobData) => data.created_at as string,
115
+ previewPath: (data: ApiJobData) => data.autosave_preview_path ?? undefined,
116
+ };
117
+ ```
118
+
119
+ `user_id`, `description`, `share_token`, `autosave_preview_path`, `job_folder_id` fields will be excluded from the
120
+ result object.
121
+
122
+ `jobTypeId` will be always **9**.
123
+
124
+ `createdAt` will be returned (please note that that field is excluded by default)
125
+
126
+ `previewPath` - some actions will be performed with the source data.
@@ -1,6 +1,7 @@
1
1
  import { type ApiError, type ApiSuccess, getSearchParams, request } from '../utils.js';
2
+
3
+ import type { RequireAtLeastOne } from 'type-fest';
2
4
  import type { Polygon } from 'geojson';
3
- import { RequireAtLeastOne } from 'type-fest';
4
5
 
5
6
  export type ApiSearchPoint = {
6
7
  lat: number;
@@ -124,3 +125,66 @@ export async function groupedAreaChildren(groupId: number, language: string): Pr
124
125
  return result;
125
126
  });
126
127
  }
128
+
129
+ export type MatchedGroup = {
130
+ id: number;
131
+ sml: number;
132
+ childrenCount: number;
133
+ matchField: string;
134
+ property: string;
135
+ name: string;
136
+ };
137
+
138
+ export type ApiMatchedGroup = {
139
+ id: number;
140
+ sml: number;
141
+ children_count: number;
142
+ match_field: string;
143
+ property: string;
144
+ name: string;
145
+ };
146
+
147
+ export async function getGroupsByDataSample(
148
+ sample: Array<Record<string, string[]>>,
149
+ language: string,
150
+ ): Promise<MatchedGroup[]> {
151
+ const path = `/v1/choropleth/groups/sample`;
152
+
153
+ type ApiMatchedGroupArray = {
154
+ data: ApiMatchedGroup[];
155
+ } & Omit<ApiSuccess, 'data'> | ApiError;
156
+
157
+ return request<ApiMatchedGroupArray, MatchedGroup>(path, { sample, language });
158
+ }
159
+
160
+ export type BoundPolygon = {
161
+ index: number;
162
+ id: number;
163
+ sml: number;
164
+ name: string;
165
+ inputName: string;
166
+ };
167
+
168
+ export type ApiBoundPolygon = {
169
+ index: number;
170
+ id: number;
171
+ sml: number;
172
+ name: string;
173
+ input_name: string;
174
+ };
175
+
176
+ export async function getBoundPolygons(
177
+ groupId: number,
178
+ property: string,
179
+ data: string[],
180
+ language: string,
181
+ ): Promise<BoundPolygon[]> {
182
+ const path = `/v1/choropleth/groups/bind`;
183
+ const postBody = { group_id: groupId, property, data, language };
184
+
185
+ type ApiBoundPolygonArray = {
186
+ data: ApiBoundPolygon[];
187
+ } & Omit<ApiSuccess, 'data'> | ApiError;
188
+
189
+ return request<ApiBoundPolygonArray, BoundPolygon>(path, postBody);
190
+ }