@mapcreator/api 0.0.0-wms.0 → 0.0.0-wms.1
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/cjs/api/insetMap.js +1 -1
- package/cjs/api/insetMap.js.map +1 -1
- package/cjs/api/job.d.ts +1 -0
- package/cjs/api/job.d.ts.map +1 -1
- package/cjs/api/job.js.map +1 -1
- package/cjs/api/jobResult.d.ts +1 -1
- package/cjs/api/jobResult.d.ts.map +1 -1
- package/cjs/api/jobResult.js +1 -1
- package/cjs/api/jobResult.js.map +1 -1
- package/cjs/api/jobRevision.d.ts +2 -2
- package/cjs/api/jobRevision.d.ts.map +1 -1
- package/cjs/api/jobRevision.js +1 -1
- package/cjs/api/jobRevision.js.map +1 -1
- package/cjs/api/organisation.d.ts +2 -1
- package/cjs/api/organisation.d.ts.map +1 -1
- package/cjs/api/organisation.js +1 -2
- package/cjs/api/organisation.js.map +1 -1
- package/cjs/api/resources.d.ts +1 -1
- package/cjs/api/resources.d.ts.map +1 -1
- package/cjs/api/resources.js.map +1 -1
- package/esm/api/insetMap.js +1 -1
- package/esm/api/insetMap.js.map +1 -1
- package/esm/api/job.d.ts +1 -0
- package/esm/api/job.d.ts.map +1 -1
- package/esm/api/job.js.map +1 -1
- package/esm/api/jobResult.d.ts +1 -1
- package/esm/api/jobResult.d.ts.map +1 -1
- package/esm/api/jobResult.js +1 -1
- package/esm/api/jobResult.js.map +1 -1
- package/esm/api/jobRevision.d.ts +2 -2
- package/esm/api/jobRevision.d.ts.map +1 -1
- package/esm/api/jobRevision.js +1 -1
- package/esm/api/jobRevision.js.map +1 -1
- package/esm/api/organisation.d.ts +2 -1
- package/esm/api/organisation.d.ts.map +1 -1
- package/esm/api/organisation.js +1 -2
- package/esm/api/organisation.js.map +1 -1
- package/esm/api/resources.d.ts +1 -1
- package/esm/api/resources.d.ts.map +1 -1
- package/esm/api/resources.js.map +1 -1
- package/package.json +1 -1
- package/src/api/apiCommon.ts +70 -70
- package/src/api/choropleth.ts +359 -359
- package/src/api/color.ts +22 -22
- package/src/api/dimension.ts +44 -44
- package/src/api/dimensionSet.ts +20 -20
- package/src/api/feature.ts +22 -22
- package/src/api/font.ts +49 -49
- package/src/api/fontFamily.ts +43 -43
- package/src/api/highlight.ts +87 -87
- package/src/api/insetMap.ts +96 -96
- package/src/api/job.ts +130 -129
- package/src/api/jobResult.ts +95 -95
- package/src/api/jobRevision.ts +279 -278
- package/src/api/jobShare.ts +35 -35
- package/src/api/jobType.ts +26 -26
- package/src/api/language.ts +19 -19
- package/src/api/layer.ts +38 -38
- package/src/api/layerFaq.ts +53 -53
- package/src/api/layerGroup.ts +69 -69
- package/src/api/mapstyleSet.ts +48 -48
- package/src/api/message.ts +80 -80
- package/src/api/organisation.ts +95 -95
- package/src/api/resources.ts +146 -144
- package/src/api/svg.ts +33 -33
- package/src/api/svgSet.ts +56 -56
- package/src/api/user.ts +327 -327
- package/src/index.ts +43 -43
- package/src/oauth.ts +314 -314
- package/src/utils.ts +342 -342
package/src/api/jobType.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
-
|
|
3
|
-
export type JobType = {
|
|
4
|
-
id: number;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export type ApiJobType = {
|
|
8
|
-
data: {
|
|
9
|
-
id: number; // The id of the job type (sortable)
|
|
10
|
-
name: string; // The name of the job type (searchable, sortable)
|
|
11
|
-
preview: string | null; // The preview file name of the job type
|
|
12
|
-
description: string | null; // The description of the job type (searchable, sortable)
|
|
13
|
-
components: string | null; // The components of the job type
|
|
14
|
-
order?: number; // TODO: not present in API specification!
|
|
15
|
-
} & ApiCommonData;
|
|
16
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
17
|
-
|
|
18
|
-
export type ApiJobTypeData = Flatten<Exclude<ApiJobType, ApiError>['data']>;
|
|
19
|
-
|
|
20
|
-
export const jobTypeRevivers: Revivers<ApiJobType, JobType> = {
|
|
21
|
-
name: undefined,
|
|
22
|
-
preview: undefined,
|
|
23
|
-
description: undefined,
|
|
24
|
-
components: undefined,
|
|
25
|
-
order: undefined,
|
|
26
|
-
};
|
|
1
|
+
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
export type JobType = {
|
|
4
|
+
id: number;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type ApiJobType = {
|
|
8
|
+
data: {
|
|
9
|
+
id: number; // The id of the job type (sortable)
|
|
10
|
+
name: string; // The name of the job type (searchable, sortable)
|
|
11
|
+
preview: string | null; // The preview file name of the job type
|
|
12
|
+
description: string | null; // The description of the job type (searchable, sortable)
|
|
13
|
+
components: string | null; // The components of the job type
|
|
14
|
+
order?: number; // TODO: not present in API specification!
|
|
15
|
+
} & ApiCommonData;
|
|
16
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
17
|
+
|
|
18
|
+
export type ApiJobTypeData = Flatten<Exclude<ApiJobType, ApiError>['data']>;
|
|
19
|
+
|
|
20
|
+
export const jobTypeRevivers: Revivers<ApiJobType, JobType> = {
|
|
21
|
+
name: undefined,
|
|
22
|
+
preview: undefined,
|
|
23
|
+
description: undefined,
|
|
24
|
+
components: undefined,
|
|
25
|
+
order: undefined,
|
|
26
|
+
};
|
package/src/api/language.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type { ApiCommonData, ApiError, ApiSuccess, Flatten } from '../utils.js';
|
|
2
|
-
|
|
3
|
-
export type Language = {
|
|
4
|
-
code: string;
|
|
5
|
-
name: string;
|
|
6
|
-
locale: string;
|
|
7
|
-
interface: boolean;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type ApiLanguage = {
|
|
11
|
-
data: {
|
|
12
|
-
code: string; // The language code
|
|
13
|
-
name: string; // The name of the language (searchable, sortable)
|
|
14
|
-
locale: string; // The locale string for the language (searchable, sortable)
|
|
15
|
-
interface: boolean; // If this language can be used for user interfaces
|
|
16
|
-
} & ApiCommonData;
|
|
17
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
18
|
-
|
|
19
|
-
export type ApiLanguageData = Flatten<Exclude<ApiLanguage, ApiError>['data']>;
|
|
1
|
+
import type { ApiCommonData, ApiError, ApiSuccess, Flatten } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
export type Language = {
|
|
4
|
+
code: string;
|
|
5
|
+
name: string;
|
|
6
|
+
locale: string;
|
|
7
|
+
interface: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type ApiLanguage = {
|
|
11
|
+
data: {
|
|
12
|
+
code: string; // The language code
|
|
13
|
+
name: string; // The name of the language (searchable, sortable)
|
|
14
|
+
locale: string; // The locale string for the language (searchable, sortable)
|
|
15
|
+
interface: boolean; // If this language can be used for user interfaces
|
|
16
|
+
} & ApiCommonData;
|
|
17
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
18
|
+
|
|
19
|
+
export type ApiLanguageData = Flatten<Exclude<ApiLanguage, ApiError>['data']>;
|
package/src/api/layer.ts
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
-
|
|
3
|
-
export type Layer = {
|
|
4
|
-
id: number;
|
|
5
|
-
name: string;
|
|
6
|
-
description: string;
|
|
7
|
-
svg: string | null;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type ApiLayer = {
|
|
11
|
-
data: {
|
|
12
|
-
id: number; // The id of the layer (sortable)
|
|
13
|
-
name: string; // The name of the layer (searchable, sortable)
|
|
14
|
-
path: string; // The path to the layer
|
|
15
|
-
description: string; // The description of the layer (searchable, sortable)
|
|
16
|
-
image: string | null; // The image related to a layer
|
|
17
|
-
svg: string | null; // The svg related to a layer
|
|
18
|
-
scale_min: number; // The minimum scale for the layer (searchable, sortable)
|
|
19
|
-
scale_max: number; // The maximum scale for the layer (searchable, sortable)
|
|
20
|
-
pangaea_ready: boolean; // Whether a layer is prepared for Pangaea (searchable, sortable)
|
|
21
|
-
svg_set_id: number | null; // TODO: not present in API specification!
|
|
22
|
-
pivot: unknown; // TODO: not present in API specification!
|
|
23
|
-
order?: number; // TODO: not present in API specification!
|
|
24
|
-
} & ApiCommonData;
|
|
25
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
26
|
-
|
|
27
|
-
export type ApiLayerData = Flatten<Exclude<ApiLayer, ApiError>['data']>;
|
|
28
|
-
|
|
29
|
-
export const layerRevivers: Revivers<ApiLayer, Layer> = {
|
|
30
|
-
path: undefined,
|
|
31
|
-
image: undefined,
|
|
32
|
-
scale_min: undefined,
|
|
33
|
-
scale_max: undefined,
|
|
34
|
-
pangaea_ready: undefined,
|
|
35
|
-
svg_set_id: undefined,
|
|
36
|
-
pivot: undefined,
|
|
37
|
-
order: undefined,
|
|
38
|
-
};
|
|
1
|
+
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
export type Layer = {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
svg: string | null;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type ApiLayer = {
|
|
11
|
+
data: {
|
|
12
|
+
id: number; // The id of the layer (sortable)
|
|
13
|
+
name: string; // The name of the layer (searchable, sortable)
|
|
14
|
+
path: string; // The path to the layer
|
|
15
|
+
description: string; // The description of the layer (searchable, sortable)
|
|
16
|
+
image: string | null; // The image related to a layer
|
|
17
|
+
svg: string | null; // The svg related to a layer
|
|
18
|
+
scale_min: number; // The minimum scale for the layer (searchable, sortable)
|
|
19
|
+
scale_max: number; // The maximum scale for the layer (searchable, sortable)
|
|
20
|
+
pangaea_ready: boolean; // Whether a layer is prepared for Pangaea (searchable, sortable)
|
|
21
|
+
svg_set_id: number | null; // TODO: not present in API specification!
|
|
22
|
+
pivot: unknown; // TODO: not present in API specification!
|
|
23
|
+
order?: number; // TODO: not present in API specification!
|
|
24
|
+
} & ApiCommonData;
|
|
25
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
26
|
+
|
|
27
|
+
export type ApiLayerData = Flatten<Exclude<ApiLayer, ApiError>['data']>;
|
|
28
|
+
|
|
29
|
+
export const layerRevivers: Revivers<ApiLayer, Layer> = {
|
|
30
|
+
path: undefined,
|
|
31
|
+
image: undefined,
|
|
32
|
+
scale_min: undefined,
|
|
33
|
+
scale_max: undefined,
|
|
34
|
+
pangaea_ready: undefined,
|
|
35
|
+
svg_set_id: undefined,
|
|
36
|
+
pivot: undefined,
|
|
37
|
+
order: undefined,
|
|
38
|
+
};
|
package/src/api/layerFaq.ts
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ApiCommonData,
|
|
3
|
-
type ApiError,
|
|
4
|
-
type ApiSuccess,
|
|
5
|
-
type Flatten,
|
|
6
|
-
type Revivers,
|
|
7
|
-
defaultListHeader,
|
|
8
|
-
getSearchParams,
|
|
9
|
-
request,
|
|
10
|
-
} from '../utils.js';
|
|
11
|
-
|
|
12
|
-
export type LayerFaq = {
|
|
13
|
-
id: number;
|
|
14
|
-
name: string;
|
|
15
|
-
description: string;
|
|
16
|
-
mediaUrl: string;
|
|
17
|
-
readMoreUrl: string;
|
|
18
|
-
tags: string[];
|
|
19
|
-
layerId: number;
|
|
20
|
-
order?: number;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type ApiLayerFaq = {
|
|
24
|
-
data: {
|
|
25
|
-
id: number; // The id of the layer faq (sortable)
|
|
26
|
-
name: string; // The name of this layer faq (searchable, sortable)
|
|
27
|
-
description: string; // The description of the layer faq (searchable)
|
|
28
|
-
media_url: string; // The image for the faq (searchable)
|
|
29
|
-
read_more_url: string; // A link to a page with more information (searchable)
|
|
30
|
-
tags: string[]; // A list of tags to search in (searchable)
|
|
31
|
-
layer_id: number; // TODO: not present in API specification!
|
|
32
|
-
order?: number; // TODO: not present in API specification!
|
|
33
|
-
} & ApiCommonData;
|
|
34
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
35
|
-
|
|
36
|
-
export type ApiLayerFaqData = Flatten<Exclude<ApiLayerFaq, ApiError>['data']>;
|
|
37
|
-
|
|
38
|
-
export const layerFaqRevivers: Revivers<ApiLayerFaq, LayerFaq> = {
|
|
39
|
-
order: undefined,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export async function listLayerFaqs(): Promise<LayerFaq[]> {
|
|
43
|
-
const pathname = `/v1/layer-faqs`;
|
|
44
|
-
const query = getSearchParams({ sort: 'order,name' });
|
|
45
|
-
const path = `${pathname}?${query}`;
|
|
46
|
-
const options = { revivers: layerFaqRevivers };
|
|
47
|
-
|
|
48
|
-
type ApiLayerFaqArray = {
|
|
49
|
-
data: ApiLayerFaqData[];
|
|
50
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
51
|
-
|
|
52
|
-
return request<ApiLayerFaqArray, LayerFaq>(path, null, defaultListHeader, options);
|
|
53
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
type ApiCommonData,
|
|
3
|
+
type ApiError,
|
|
4
|
+
type ApiSuccess,
|
|
5
|
+
type Flatten,
|
|
6
|
+
type Revivers,
|
|
7
|
+
defaultListHeader,
|
|
8
|
+
getSearchParams,
|
|
9
|
+
request,
|
|
10
|
+
} from '../utils.js';
|
|
11
|
+
|
|
12
|
+
export type LayerFaq = {
|
|
13
|
+
id: number;
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
mediaUrl: string;
|
|
17
|
+
readMoreUrl: string;
|
|
18
|
+
tags: string[];
|
|
19
|
+
layerId: number;
|
|
20
|
+
order?: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type ApiLayerFaq = {
|
|
24
|
+
data: {
|
|
25
|
+
id: number; // The id of the layer faq (sortable)
|
|
26
|
+
name: string; // The name of this layer faq (searchable, sortable)
|
|
27
|
+
description: string; // The description of the layer faq (searchable)
|
|
28
|
+
media_url: string; // The image for the faq (searchable)
|
|
29
|
+
read_more_url: string; // A link to a page with more information (searchable)
|
|
30
|
+
tags: string[]; // A list of tags to search in (searchable)
|
|
31
|
+
layer_id: number; // TODO: not present in API specification!
|
|
32
|
+
order?: number; // TODO: not present in API specification!
|
|
33
|
+
} & ApiCommonData;
|
|
34
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
35
|
+
|
|
36
|
+
export type ApiLayerFaqData = Flatten<Exclude<ApiLayerFaq, ApiError>['data']>;
|
|
37
|
+
|
|
38
|
+
export const layerFaqRevivers: Revivers<ApiLayerFaq, LayerFaq> = {
|
|
39
|
+
order: undefined,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export async function listLayerFaqs(): Promise<LayerFaq[]> {
|
|
43
|
+
const pathname = `/v1/layer-faqs`;
|
|
44
|
+
const query = getSearchParams({ sort: 'order,name' });
|
|
45
|
+
const path = `${pathname}?${query}`;
|
|
46
|
+
const options = { revivers: layerFaqRevivers };
|
|
47
|
+
|
|
48
|
+
type ApiLayerFaqArray = {
|
|
49
|
+
data: ApiLayerFaqData[];
|
|
50
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
51
|
+
|
|
52
|
+
return request<ApiLayerFaqArray, LayerFaq>(path, null, defaultListHeader, options);
|
|
53
|
+
}
|
package/src/api/layerGroup.ts
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import type { Layer } from './layer.js';
|
|
2
|
-
import {
|
|
3
|
-
type ApiCommonData,
|
|
4
|
-
type ApiError,
|
|
5
|
-
type ApiSuccess,
|
|
6
|
-
type Flatten,
|
|
7
|
-
getSearchParams,
|
|
8
|
-
request,
|
|
9
|
-
} from '../utils.js';
|
|
10
|
-
|
|
11
|
-
export type LayerGroup = {
|
|
12
|
-
id: number;
|
|
13
|
-
name: string;
|
|
14
|
-
layers: Layer[];
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type ApiLayerGroup = {
|
|
18
|
-
data: {
|
|
19
|
-
id: number; // The id of the layer group (sortable)
|
|
20
|
-
name: string; // The name of the layer group (searchable, sortable)
|
|
21
|
-
} & ApiCommonData;
|
|
22
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
23
|
-
|
|
24
|
-
export type ApiLayerGroupData = Flatten<Exclude<ApiLayerGroup, ApiError>['data']>;
|
|
25
|
-
|
|
26
|
-
export async function listLayerGroups(layers: Layer[]): Promise<LayerGroup[]> {
|
|
27
|
-
const pathname = `/v1/layer-groups/for-layer-ids`;
|
|
28
|
-
const query = getSearchParams({ layer_ids: layers.map(layer => layer.id) });
|
|
29
|
-
const path = `${pathname}?${query}`;
|
|
30
|
-
|
|
31
|
-
type ApiLayerGroupArray = {
|
|
32
|
-
data: Array<ApiLayerGroupData & { layers: Array<{ id: number }> }>;
|
|
33
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
34
|
-
|
|
35
|
-
const layerGroups = await request<ApiLayerGroupArray, LayerGroup>(path);
|
|
36
|
-
|
|
37
|
-
// Arrange layers in an object by id for fast lookups
|
|
38
|
-
const layerMap = new Map(layers.map(layer => [layer.id, layer]));
|
|
39
|
-
|
|
40
|
-
// Create a set of all layer ids that belong to a group
|
|
41
|
-
const groupedLayerIds = new Set<number>();
|
|
42
|
-
|
|
43
|
-
for (const layerGroup of layerGroups) {
|
|
44
|
-
// Replace layers from the API response with their full representation
|
|
45
|
-
layerGroup.layers = layerGroup.layers
|
|
46
|
-
.map(groupLayer => layerMap.get(groupLayer.id))
|
|
47
|
-
.filter((layer): layer is Layer => layer !== undefined);
|
|
48
|
-
|
|
49
|
-
// Remember that these layers belong to a group
|
|
50
|
-
for (const layer of layerGroup.layers) {
|
|
51
|
-
groupedLayerIds.add(layer.id);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Get a list of layers that don’t belong to any group
|
|
56
|
-
const miscLayers = layers.filter(layer => !groupedLayerIds.has(layer.id));
|
|
57
|
-
|
|
58
|
-
// Sort it alphabetically
|
|
59
|
-
miscLayers.sort((a, b) => a.name.localeCompare(b.name));
|
|
60
|
-
|
|
61
|
-
// Put them all in a separate group
|
|
62
|
-
const miscLayerGroup: LayerGroup = {
|
|
63
|
-
id: 999,
|
|
64
|
-
layers: miscLayers,
|
|
65
|
-
name: 'Other layers',
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
return [...layerGroups, miscLayerGroup];
|
|
69
|
-
}
|
|
1
|
+
import type { Layer } from './layer.js';
|
|
2
|
+
import {
|
|
3
|
+
type ApiCommonData,
|
|
4
|
+
type ApiError,
|
|
5
|
+
type ApiSuccess,
|
|
6
|
+
type Flatten,
|
|
7
|
+
getSearchParams,
|
|
8
|
+
request,
|
|
9
|
+
} from '../utils.js';
|
|
10
|
+
|
|
11
|
+
export type LayerGroup = {
|
|
12
|
+
id: number;
|
|
13
|
+
name: string;
|
|
14
|
+
layers: Layer[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type ApiLayerGroup = {
|
|
18
|
+
data: {
|
|
19
|
+
id: number; // The id of the layer group (sortable)
|
|
20
|
+
name: string; // The name of the layer group (searchable, sortable)
|
|
21
|
+
} & ApiCommonData;
|
|
22
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
23
|
+
|
|
24
|
+
export type ApiLayerGroupData = Flatten<Exclude<ApiLayerGroup, ApiError>['data']>;
|
|
25
|
+
|
|
26
|
+
export async function listLayerGroups(layers: Layer[]): Promise<LayerGroup[]> {
|
|
27
|
+
const pathname = `/v1/layer-groups/for-layer-ids`;
|
|
28
|
+
const query = getSearchParams({ layer_ids: layers.map(layer => layer.id) });
|
|
29
|
+
const path = `${pathname}?${query}`;
|
|
30
|
+
|
|
31
|
+
type ApiLayerGroupArray = {
|
|
32
|
+
data: Array<ApiLayerGroupData & { layers: Array<{ id: number }> }>;
|
|
33
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
34
|
+
|
|
35
|
+
const layerGroups = await request<ApiLayerGroupArray, LayerGroup>(path);
|
|
36
|
+
|
|
37
|
+
// Arrange layers in an object by id for fast lookups
|
|
38
|
+
const layerMap = new Map(layers.map(layer => [layer.id, layer]));
|
|
39
|
+
|
|
40
|
+
// Create a set of all layer ids that belong to a group
|
|
41
|
+
const groupedLayerIds = new Set<number>();
|
|
42
|
+
|
|
43
|
+
for (const layerGroup of layerGroups) {
|
|
44
|
+
// Replace layers from the API response with their full representation
|
|
45
|
+
layerGroup.layers = layerGroup.layers
|
|
46
|
+
.map(groupLayer => layerMap.get(groupLayer.id))
|
|
47
|
+
.filter((layer): layer is Layer => layer !== undefined);
|
|
48
|
+
|
|
49
|
+
// Remember that these layers belong to a group
|
|
50
|
+
for (const layer of layerGroup.layers) {
|
|
51
|
+
groupedLayerIds.add(layer.id);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Get a list of layers that don’t belong to any group
|
|
56
|
+
const miscLayers = layers.filter(layer => !groupedLayerIds.has(layer.id));
|
|
57
|
+
|
|
58
|
+
// Sort it alphabetically
|
|
59
|
+
miscLayers.sort((a, b) => a.name.localeCompare(b.name));
|
|
60
|
+
|
|
61
|
+
// Put them all in a separate group
|
|
62
|
+
const miscLayerGroup: LayerGroup = {
|
|
63
|
+
id: 999,
|
|
64
|
+
layers: miscLayers,
|
|
65
|
+
name: 'Other layers',
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return [...layerGroups, miscLayerGroup];
|
|
69
|
+
}
|
package/src/api/mapstyleSet.ts
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
-
|
|
3
|
-
export type MapstyleSet = {
|
|
4
|
-
id: number;
|
|
5
|
-
name: string;
|
|
6
|
-
supportsSvg: boolean;
|
|
7
|
-
disableInteractive: boolean;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type ApiMapstyleSet = {
|
|
11
|
-
data: {
|
|
12
|
-
id: number; // The id of the mapstyle set (sortable)
|
|
13
|
-
name: string; // The name of the mapstyle set (searchable, sortable)
|
|
14
|
-
description: string; // The description of the set (searchable, sortable)
|
|
15
|
-
supports_svg: boolean; // If the set supports svg (searchable, sortable)
|
|
16
|
-
disable_interactive: boolean; // If interactive export is disabled
|
|
17
|
-
job_type_id: number; // The id of the job type (searchable)
|
|
18
|
-
preview_lat: number; // The latitude for the preview image
|
|
19
|
-
preview_lon: number; // The longitude for the preview image
|
|
20
|
-
preview_language_code: string; // The language code of the preview
|
|
21
|
-
world_cache: string | null; // The name of the world cache (sortable)
|
|
22
|
-
world_cache_max_zoom: number | null; // The max zoom level of the world cache (sortable)
|
|
23
|
-
css: string | null; // Custom CSS for the MapstyleSet (sortable)
|
|
24
|
-
locator_ready: boolean; // If the set can be used as locator (searchable, sortable)
|
|
25
|
-
show_underlying_elements: boolean; // Shows elements even if behind annotations
|
|
26
|
-
ace_on_osm: boolean; // Use OSM source as data for ACE maps (searchable, sortable)
|
|
27
|
-
order?: number; // TODO: not present in API specification!
|
|
28
|
-
custom_settings?: string | null; // TODO: not present in API specification!
|
|
29
|
-
} & ApiCommonData;
|
|
30
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
31
|
-
|
|
32
|
-
export type ApiMapstyleSetData = Flatten<Exclude<ApiMapstyleSet, ApiError>['data']>;
|
|
33
|
-
|
|
34
|
-
export const mapstyleSetRevivers: Revivers<ApiMapstyleSet, MapstyleSet> = {
|
|
35
|
-
description: undefined,
|
|
36
|
-
job_type_id: undefined,
|
|
37
|
-
preview_lat: undefined,
|
|
38
|
-
preview_lon: undefined,
|
|
39
|
-
preview_language_code: undefined,
|
|
40
|
-
world_cache: undefined,
|
|
41
|
-
world_cache_max_zoom: undefined,
|
|
42
|
-
css: undefined,
|
|
43
|
-
locator_ready: undefined,
|
|
44
|
-
show_underlying_elements: undefined,
|
|
45
|
-
ace_on_osm: undefined,
|
|
46
|
-
order: undefined,
|
|
47
|
-
custom_settings: undefined,
|
|
48
|
-
};
|
|
1
|
+
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
export type MapstyleSet = {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
supportsSvg: boolean;
|
|
7
|
+
disableInteractive: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type ApiMapstyleSet = {
|
|
11
|
+
data: {
|
|
12
|
+
id: number; // The id of the mapstyle set (sortable)
|
|
13
|
+
name: string; // The name of the mapstyle set (searchable, sortable)
|
|
14
|
+
description: string; // The description of the set (searchable, sortable)
|
|
15
|
+
supports_svg: boolean; // If the set supports svg (searchable, sortable)
|
|
16
|
+
disable_interactive: boolean; // If interactive export is disabled
|
|
17
|
+
job_type_id: number; // The id of the job type (searchable)
|
|
18
|
+
preview_lat: number; // The latitude for the preview image
|
|
19
|
+
preview_lon: number; // The longitude for the preview image
|
|
20
|
+
preview_language_code: string; // The language code of the preview
|
|
21
|
+
world_cache: string | null; // The name of the world cache (sortable)
|
|
22
|
+
world_cache_max_zoom: number | null; // The max zoom level of the world cache (sortable)
|
|
23
|
+
css: string | null; // Custom CSS for the MapstyleSet (sortable)
|
|
24
|
+
locator_ready: boolean; // If the set can be used as locator (searchable, sortable)
|
|
25
|
+
show_underlying_elements: boolean; // Shows elements even if behind annotations
|
|
26
|
+
ace_on_osm: boolean; // Use OSM source as data for ACE maps (searchable, sortable)
|
|
27
|
+
order?: number; // TODO: not present in API specification!
|
|
28
|
+
custom_settings?: string | null; // TODO: not present in API specification!
|
|
29
|
+
} & ApiCommonData;
|
|
30
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
31
|
+
|
|
32
|
+
export type ApiMapstyleSetData = Flatten<Exclude<ApiMapstyleSet, ApiError>['data']>;
|
|
33
|
+
|
|
34
|
+
export const mapstyleSetRevivers: Revivers<ApiMapstyleSet, MapstyleSet> = {
|
|
35
|
+
description: undefined,
|
|
36
|
+
job_type_id: undefined,
|
|
37
|
+
preview_lat: undefined,
|
|
38
|
+
preview_lon: undefined,
|
|
39
|
+
preview_language_code: undefined,
|
|
40
|
+
world_cache: undefined,
|
|
41
|
+
world_cache_max_zoom: undefined,
|
|
42
|
+
css: undefined,
|
|
43
|
+
locator_ready: undefined,
|
|
44
|
+
show_underlying_elements: undefined,
|
|
45
|
+
ace_on_osm: undefined,
|
|
46
|
+
order: undefined,
|
|
47
|
+
custom_settings: undefined,
|
|
48
|
+
};
|