@mapcreator/api 2.6.0 → 2.7.0

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.
@@ -20,7 +20,7 @@ function easyAuth() {
20
20
 
21
21
  console.log('You can play around with the api in here, the library is bound to window.mapcreator. Authentication ');
22
22
  console.log('can easily be done by running the command easyAuth(). See the docs for more information here: ');
23
- console.log('https://docs.mapcreator.io/wrapper/manual/example/examples.authentication.html');
23
+ console.log('https://docs.mapcreator.io/wrapper/manual/examples.authentication.html');
24
24
  console.log('Example: easyAuth().then(api => window.api = api);');
25
25
  console.log('window.mapcreator =', window.mapcreator);
26
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapcreator/api",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "Mapcreator JavaScript API",
5
5
  "main": "dist/bundle.js",
6
6
  "repository": "https://gitlab.com/mapcreator/api-wrapper.git",
@@ -56,7 +56,7 @@
56
56
  "scripts": {
57
57
  "build": "APP_ENV=production npx webpack",
58
58
  "watch": "npx webpack --progress --watch",
59
- "docs": "npx esdoc",
59
+ "docs": "npx esdoc && ./scripts/inject_docs_viewport.sh",
60
60
  "lint": "npx eslint --no-color --format checkstyle --output-file build/checkstyle.xml src",
61
61
  "clean": "rm -fr dist docs build || true",
62
62
  "all": "npm run clean && npm run lint && npm run build && npm run test && npm run docs",
package/src/Mapcreator.js CHANGED
@@ -70,6 +70,8 @@ import {
70
70
  User,
71
71
  VectorHighlight,
72
72
  VectorChoropleth,
73
+ ProductTour,
74
+ ProductTourStep,
73
75
  } from './resources';
74
76
  import ResourceBase from './resources/base/ResourceBase';
75
77
  import Injectable from './traits/Injectable';
@@ -81,6 +83,7 @@ import ValidationError from './errors/ValidationError';
81
83
  import ApiError from './errors/ApiError';
82
84
  import { wrapKyPrefixUrl } from './utils/requests';
83
85
  import EventEmitter from 'events';
86
+ import LayerGroup from './resources/LayerGroup';
84
87
 
85
88
  /**
86
89
  * Base API class
@@ -533,6 +536,15 @@ export default class Mapcreator extends mix(EventEmitter, Injectable) {
533
536
  return this.static(Layer);
534
537
  }
535
538
 
539
+ /**
540
+ * Layer group accessor
541
+ * @see {@link LayerGroup}
542
+ * @returns {ResourceProxy} - A proxy for accessing the resource
543
+ */
544
+ get layerGroups () {
545
+ return this.static(LayerGroup);
546
+ }
547
+
536
548
  /**
537
549
  * Mapstyle accessor
538
550
  * @see {@link Mapstyle}
@@ -587,6 +599,14 @@ export default class Mapcreator extends mix(EventEmitter, Injectable) {
587
599
  return this.static(Permission);
588
600
  }
589
601
 
602
+ get productTours () {
603
+ return this.static(ProductTour);
604
+ }
605
+
606
+ get productTourSteps () {
607
+ return this.static(ProductTourStep);
608
+ }
609
+
590
610
  /**
591
611
  * Role accessor
592
612
  * @see {@link Role}
@@ -0,0 +1,57 @@
1
+ /*
2
+ * BSD 3-Clause License
3
+ *
4
+ * Copyright (c) 2020, Mapcreator
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ *
10
+ * Redistributions of source code must retain the above copyright notice, this
11
+ * list of conditions and the following disclaimer.
12
+ *
13
+ * Redistributions in binary form must reproduce the above copyright notice,
14
+ * this list of conditions and the following disclaimer in the documentation
15
+ * and/or other materials provided with the distribution.
16
+ *
17
+ * Neither the name of the copyright holder nor the names of its
18
+ * contributors may be used to endorse or promote products derived from
19
+ * this software without specific prior written permission.
20
+ *
21
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ */
32
+
33
+ import OwnableResource from '../traits/OwnableResource';
34
+ import { mix } from '../utils/reflection';
35
+ import Layer from './Layer';
36
+ import CrudSetBase from './base/CrudSetBase';
37
+ import { OwnedResourceProxy } from '../proxy';
38
+
39
+ /**
40
+ * Layer
41
+ * @extends CrudBase
42
+ * @mixes OwnableResource
43
+ * @mixes HandlesImages
44
+ */
45
+ export default class LayerGroup extends mix(CrudSetBase, OwnableResource) {
46
+ static get resourceName () {
47
+ return 'layer-groups';
48
+ }
49
+
50
+ get items () {
51
+ return new OwnedResourceProxy(this.api, this, this._Child);
52
+ }
53
+
54
+ get _Child () {
55
+ return Layer;
56
+ }
57
+ }
@@ -48,6 +48,7 @@ import Tag from './Tag';
48
48
  import User from './User';
49
49
  import { makeCancelable } from '../utils/helpers';
50
50
  import { encodeQueryString } from '../utils/requests';
51
+ import LayerGroup from './LayerGroup';
51
52
 
52
53
 
53
54
  export default class Organisation extends CrudBase {
@@ -120,6 +121,14 @@ export default class Organisation extends CrudBase {
120
121
  return new OwnedResourceProxy(this.api, this, Layer);
121
122
  }
122
123
 
124
+ /**
125
+ * Get a proxy for layer groups linked to the organisation
126
+ * @returns {OwnedResourceProxy} - A proxy for accessing the resource
127
+ */
128
+ get layerGroups () {
129
+ return new OwnedResourceProxy(this.api, this, LayerGroup);
130
+ }
131
+
123
132
  /**
124
133
  * Get a proxy for jobs linked to the organisation, also known as company maps
125
134
  * @returns {SimpleResourceProxy} - A proxy for accessing the resource
@@ -0,0 +1,53 @@
1
+ /*
2
+ * BSD 3-Clause License
3
+ *
4
+ * Copyright (c) 2020, Mapcreator
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ *
10
+ * Redistributions of source code must retain the above copyright notice, this
11
+ * list of conditions and the following disclaimer.
12
+ *
13
+ * Redistributions in binary form must reproduce the above copyright notice,
14
+ * this list of conditions and the following disclaimer in the documentation
15
+ * and/or other materials provided with the distribution.
16
+ *
17
+ * Neither the name of the copyright holder nor the names of its
18
+ * contributors may be used to endorse or promote products derived from
19
+ * this software without specific prior written permission.
20
+ *
21
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ */
32
+
33
+ import { mix } from '../utils/reflection';
34
+ import CrudSetBase from './base/CrudSetBase';
35
+ import ProductTourStep from './ProductTourStep';
36
+
37
+ /**
38
+ * Mapstyle set
39
+ * @extends CrudSetBase
40
+ */
41
+ export default class ProductTour extends mix(CrudSetBase) {
42
+ static get resourcePath () {
43
+ return '/product-tours/{id}';
44
+ }
45
+
46
+ static get resourceName () {
47
+ return 'product-tours';
48
+ }
49
+
50
+ get _Child () {
51
+ return ProductTourStep;
52
+ }
53
+ }
@@ -0,0 +1,48 @@
1
+ /*
2
+ * BSD 3-Clause License
3
+ *
4
+ * Copyright (c) 2020, Mapcreator
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ *
10
+ * Redistributions of source code must retain the above copyright notice, this
11
+ * list of conditions and the following disclaimer.
12
+ *
13
+ * Redistributions in binary form must reproduce the above copyright notice,
14
+ * this list of conditions and the following disclaimer in the documentation
15
+ * and/or other materials provided with the distribution.
16
+ *
17
+ * Neither the name of the copyright holder nor the names of its
18
+ * contributors may be used to endorse or promote products derived from
19
+ * this software without specific prior written permission.
20
+ *
21
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ */
32
+
33
+ import { mix } from '../utils/reflection';
34
+ import CrudSetItemBase from './base/CrudSetItemBase';
35
+
36
+ /**
37
+ * @extends CrudSetItemBase
38
+ */
39
+ export default class ProductTourStep extends mix(CrudSetItemBase) {
40
+ static get resourceName () {
41
+ return 'product-tours/steps';
42
+ }
43
+
44
+ static get parentKey () {
45
+ return 'product_tour_id';
46
+ }
47
+ }
48
+
@@ -103,11 +103,20 @@ export default class User extends CrudBase {
103
103
  }
104
104
 
105
105
  /**
106
- * Get the list messagse linked to the user
107
- * @returns {SimpleResourceProxy} - A proxy for accessing the resource
106
+ * Get a list of read/unread messages for the user
107
+ * @returns {CancelablePromise<{read: Message[], unread: Message[]}>} - Read and unread messages
108
108
  */
109
- get messages () {
110
- return this._proxyResourceList(Message);
109
+ messages () {
110
+ const url = `${this.url}/messages`;
111
+
112
+ return makeCancelable(async signal => {
113
+ const { data } = await this.api.ky.get(url, { signal }).json();
114
+
115
+ return {
116
+ read: data.read.map(o => new Message(this.api, o)),
117
+ unread: data.unread.map(o => new Message(this.api, o)),
118
+ };
119
+ });
111
120
  }
112
121
 
113
122
  /**
@@ -55,6 +55,8 @@ export Message from './Message';
55
55
  export Notification from './Notification';
56
56
  export Organisation from './Organisation';
57
57
  export Permission from './Permission';
58
+ export ProductTour from './ProductTour';
59
+ export ProductTourStep from './ProductTourStep';
58
60
  export Role from './Role';
59
61
  export Svg from './Svg';
60
62
  export SvgSet from './SvgSet';