@mapcreator/api 0.0.0-saga.1 → 0.0.0-saga.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @mapcreator/api might be problematic. Click here for more details.
- package/cjs/api/apiCommon.d.ts.map +1 -1
- package/cjs/api/apiCommon.js +14 -3
- package/cjs/api/apiCommon.js.map +1 -1
- package/cjs/api/choropleth.d.ts +116 -6
- package/cjs/api/choropleth.d.ts.map +1 -1
- package/cjs/api/choropleth.js +58 -6
- package/cjs/api/choropleth.js.map +1 -1
- package/cjs/api/font.d.ts +3 -0
- package/cjs/api/font.d.ts.map +1 -1
- package/cjs/api/font.js +0 -3
- package/cjs/api/font.js.map +1 -1
- package/cjs/api/geocode.d.ts +10 -0
- package/cjs/api/geocode.d.ts.map +1 -0
- package/cjs/api/geocode.js +9 -0
- package/cjs/api/geocode.js.map +1 -0
- package/cjs/api/highlight.js +1 -1
- package/cjs/api/highlight.js.map +1 -1
- package/cjs/api/insetMap.d.ts +37 -0
- package/cjs/api/insetMap.d.ts.map +1 -0
- package/cjs/api/insetMap.js +47 -0
- package/cjs/api/insetMap.js.map +1 -0
- package/cjs/api/job.d.ts +10 -6
- package/cjs/api/job.d.ts.map +1 -1
- package/cjs/api/job.js +10 -5
- 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 +3 -3
- package/cjs/api/jobRevision.d.ts.map +1 -1
- package/cjs/api/jobRevision.js +19 -14
- package/cjs/api/jobRevision.js.map +1 -1
- package/cjs/api/mapstyleSet.d.ts +2 -1
- package/cjs/api/mapstyleSet.d.ts.map +1 -1
- package/cjs/api/mapstyleSet.js +9 -0
- package/cjs/api/mapstyleSet.js.map +1 -1
- package/cjs/api/organisation.d.ts +4 -3
- package/cjs/api/organisation.d.ts.map +1 -1
- package/cjs/api/organisation.js +6 -7
- package/cjs/api/organisation.js.map +1 -1
- package/cjs/api/resources.d.ts +7 -1
- package/cjs/api/resources.d.ts.map +1 -1
- package/cjs/api/resources.js +10 -4
- package/cjs/api/resources.js.map +1 -1
- package/cjs/api/user.d.ts +2 -1
- package/cjs/api/user.d.ts.map +1 -1
- package/cjs/api/user.js +4 -5
- package/cjs/api/user.js.map +1 -1
- package/cjs/index.d.ts +2 -0
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +2 -0
- package/cjs/index.js.map +1 -1
- package/cjs/oauth.d.ts +10 -6
- package/cjs/oauth.d.ts.map +1 -1
- package/cjs/oauth.js +29 -199
- package/cjs/oauth.js.map +1 -1
- package/cjs/utils.d.ts +9 -2
- package/cjs/utils.d.ts.map +1 -1
- package/cjs/utils.js +72 -14
- package/cjs/utils.js.map +1 -1
- package/esm/api/apiCommon.d.ts.map +1 -1
- package/esm/api/apiCommon.js +14 -3
- package/esm/api/apiCommon.js.map +1 -1
- package/esm/api/choropleth.d.ts +116 -6
- package/esm/api/choropleth.d.ts.map +1 -1
- package/esm/api/choropleth.js +53 -5
- package/esm/api/choropleth.js.map +1 -1
- package/esm/api/font.d.ts +3 -0
- package/esm/api/font.d.ts.map +1 -1
- package/esm/api/font.js +1 -4
- package/esm/api/font.js.map +1 -1
- package/esm/api/geocode.d.ts +10 -0
- package/esm/api/geocode.d.ts.map +1 -0
- package/esm/api/geocode.js +6 -0
- package/esm/api/geocode.js.map +1 -0
- package/esm/api/highlight.js +1 -1
- package/esm/api/highlight.js.map +1 -1
- package/esm/api/insetMap.d.ts +37 -0
- package/esm/api/insetMap.d.ts.map +1 -0
- package/esm/api/insetMap.js +42 -0
- package/esm/api/insetMap.js.map +1 -0
- package/esm/api/job.d.ts +10 -6
- package/esm/api/job.d.ts.map +1 -1
- package/esm/api/job.js +9 -5
- 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 +3 -3
- package/esm/api/jobRevision.d.ts.map +1 -1
- package/esm/api/jobRevision.js +19 -14
- package/esm/api/jobRevision.js.map +1 -1
- package/esm/api/mapstyleSet.d.ts +2 -1
- package/esm/api/mapstyleSet.d.ts.map +1 -1
- package/esm/api/mapstyleSet.js +8 -0
- package/esm/api/mapstyleSet.js.map +1 -1
- package/esm/api/organisation.d.ts +4 -3
- package/esm/api/organisation.d.ts.map +1 -1
- package/esm/api/organisation.js +6 -7
- package/esm/api/organisation.js.map +1 -1
- package/esm/api/resources.d.ts +7 -1
- package/esm/api/resources.d.ts.map +1 -1
- package/esm/api/resources.js +10 -4
- package/esm/api/resources.js.map +1 -1
- package/esm/api/user.d.ts +2 -1
- package/esm/api/user.d.ts.map +1 -1
- package/esm/api/user.js +4 -5
- package/esm/api/user.js.map +1 -1
- package/esm/index.d.ts +2 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +2 -0
- package/esm/index.js.map +1 -1
- package/esm/oauth.d.ts +10 -6
- package/esm/oauth.d.ts.map +1 -1
- package/esm/oauth.js +28 -198
- package/esm/oauth.js.map +1 -1
- package/esm/utils.d.ts +9 -2
- package/esm/utils.d.ts.map +1 -1
- package/esm/utils.js +71 -14
- package/esm/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/api/apiCommon.ts +71 -70
- package/src/api/choropleth.ts +258 -105
- 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 +57 -49
- package/src/api/fontFamily.ts +43 -43
- package/src/api/geocode.ts +17 -0
- package/src/api/highlight.ts +87 -87
- package/src/api/insetMap.ts +95 -0
- package/src/api/job.ts +139 -129
- package/src/api/jobResult.ts +95 -95
- package/src/api/jobRevision.ts +281 -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 +70 -48
- package/src/api/message.ts +80 -80
- package/src/api/organisation.ts +96 -95
- package/src/api/resources.ts +153 -143
- 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 +44 -42
- package/src/oauth.ts +90 -314
- package/src/utils.ts +407 -342
package/src/api/dimensionSet.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
-
|
|
3
|
-
export type DimensionSet = {
|
|
4
|
-
id: number;
|
|
5
|
-
name: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type ApiDimensionSet = {
|
|
9
|
-
data: {
|
|
10
|
-
id: number; // The dimension set id (sortable)
|
|
11
|
-
name: string; // The dimension set name (searchable, sortable)
|
|
12
|
-
order?: number; // TODO: not present in API specification!
|
|
13
|
-
} & ApiCommonData;
|
|
14
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
15
|
-
|
|
16
|
-
export type ApiDimensionSetData = Flatten<Exclude<ApiDimensionSet, ApiError>['data']>;
|
|
17
|
-
|
|
18
|
-
export const dimensionSetRevivers: Revivers<ApiDimensionSet, DimensionSet> = {
|
|
19
|
-
order: undefined,
|
|
20
|
-
};
|
|
1
|
+
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
export type DimensionSet = {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type ApiDimensionSet = {
|
|
9
|
+
data: {
|
|
10
|
+
id: number; // The dimension set id (sortable)
|
|
11
|
+
name: string; // The dimension set name (searchable, sortable)
|
|
12
|
+
order?: number; // TODO: not present in API specification!
|
|
13
|
+
} & ApiCommonData;
|
|
14
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
15
|
+
|
|
16
|
+
export type ApiDimensionSetData = Flatten<Exclude<ApiDimensionSet, ApiError>['data']>;
|
|
17
|
+
|
|
18
|
+
export const dimensionSetRevivers: Revivers<ApiDimensionSet, DimensionSet> = {
|
|
19
|
+
order: undefined,
|
|
20
|
+
};
|
package/src/api/feature.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
-
|
|
3
|
-
export type Feature = {
|
|
4
|
-
id: number;
|
|
5
|
-
name: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type ApiFeature = {
|
|
9
|
-
data: {
|
|
10
|
-
id: number; // The feature id
|
|
11
|
-
name: string; // The feature name (searchable, sortable)
|
|
12
|
-
description: string; // The description of the feature (searchable, sortable)
|
|
13
|
-
order?: number; // TODO: not present in API specification!
|
|
14
|
-
} & ApiCommonData;
|
|
15
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
16
|
-
|
|
17
|
-
export type ApiFeatureData = Flatten<Exclude<ApiFeature, ApiError>['data']>;
|
|
18
|
-
|
|
19
|
-
export const featureRevivers: Revivers<ApiFeature, Feature> = {
|
|
20
|
-
description: undefined,
|
|
21
|
-
order: undefined,
|
|
22
|
-
};
|
|
1
|
+
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
export type Feature = {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type ApiFeature = {
|
|
9
|
+
data: {
|
|
10
|
+
id: number; // The feature id
|
|
11
|
+
name: string; // The feature name (searchable, sortable)
|
|
12
|
+
description: string; // The description of the feature (searchable, sortable)
|
|
13
|
+
order?: number; // TODO: not present in API specification!
|
|
14
|
+
} & ApiCommonData;
|
|
15
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
16
|
+
|
|
17
|
+
export type ApiFeatureData = Flatten<Exclude<ApiFeature, ApiError>['data']>;
|
|
18
|
+
|
|
19
|
+
export const featureRevivers: Revivers<ApiFeature, Feature> = {
|
|
20
|
+
description: undefined,
|
|
21
|
+
order: undefined,
|
|
22
|
+
};
|
package/src/api/font.ts
CHANGED
|
@@ -1,49 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
import {
|
|
2
|
+
type ApiCommonData,
|
|
3
|
+
type ApiError,
|
|
4
|
+
type ApiSuccess,
|
|
5
|
+
type Flatten,
|
|
6
|
+
type Revivers,
|
|
7
|
+
getSearchParams,
|
|
8
|
+
request,
|
|
9
|
+
} from '../utils.js';
|
|
10
|
+
|
|
11
|
+
export type Font = {
|
|
12
|
+
id: number;
|
|
13
|
+
fontFamilyId: number;
|
|
14
|
+
name: string;
|
|
15
|
+
label: string;
|
|
16
|
+
weight: number;
|
|
17
|
+
style: string;
|
|
18
|
+
stretch: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type ApiFont = {
|
|
22
|
+
data: {
|
|
23
|
+
id: number; // The id of the font (sortable)
|
|
24
|
+
font_family_id: number; // The id of the font family
|
|
25
|
+
name: string; // The name of the font (searchable, sortable)
|
|
26
|
+
style: string; // The font style (searchable, sortable)
|
|
27
|
+
stretch: string; // The font stretch (searchable, sortable)
|
|
28
|
+
weight: number; // The font weight (searchable, sortable)
|
|
29
|
+
label: string; // The label of the font (searchable, sortable)
|
|
30
|
+
order?: number; // TODO: not present in API specification!
|
|
31
|
+
} & ApiCommonData;
|
|
32
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
33
|
+
|
|
34
|
+
export type ApiFontData = Flatten<Exclude<ApiFont, ApiError>['data']>;
|
|
35
|
+
|
|
36
|
+
type FontSearchOptions = {
|
|
37
|
+
family?: string;
|
|
38
|
+
style?: string;
|
|
39
|
+
weight?: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const fontRevivers: Revivers<ApiFont, Font> = {
|
|
43
|
+
order: undefined,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export async function getFonts(searchOptions: FontSearchOptions): Promise<Font[] | Font> {
|
|
47
|
+
const pathname = `/v1/fonts/search`;
|
|
48
|
+
const query = getSearchParams(searchOptions);
|
|
49
|
+
|
|
50
|
+
const path = `${pathname}?${query}`;
|
|
51
|
+
|
|
52
|
+
type ApiFontArray = {
|
|
53
|
+
data: ApiFontData[];
|
|
54
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
55
|
+
|
|
56
|
+
return request<ApiFontArray, Font>(path);
|
|
57
|
+
}
|
package/src/api/fontFamily.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { type ApiFontData, type Font, fontRevivers } from './font.js';
|
|
2
|
-
import {
|
|
3
|
-
type ApiCommonData,
|
|
4
|
-
type ApiError,
|
|
5
|
-
type ApiSuccess,
|
|
6
|
-
type Flatten,
|
|
7
|
-
type Revivers,
|
|
8
|
-
defaultListHeader,
|
|
9
|
-
getSearchParams,
|
|
10
|
-
request,
|
|
11
|
-
} from '../utils.js';
|
|
12
|
-
|
|
13
|
-
export type FontFamily = {
|
|
14
|
-
id: number;
|
|
15
|
-
name: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type ApiFontFamily = {
|
|
19
|
-
data: {
|
|
20
|
-
id: number; // The id of the font family (sortable)
|
|
21
|
-
name: string; // The name of the font family (searchable, sortable)
|
|
22
|
-
order?: number; // TODO: not present in API specification!
|
|
23
|
-
} & ApiCommonData;
|
|
24
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
25
|
-
|
|
26
|
-
export type ApiFontFamilyData = Flatten<Exclude<ApiFontFamily, ApiError>['data']>;
|
|
27
|
-
|
|
28
|
-
export const fontFamilyRevivers: Revivers<ApiFontFamily, FontFamily> = {
|
|
29
|
-
order: undefined,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export async function listFontFamilyFonts(fontFamilyId: number): Promise<Font[]> {
|
|
33
|
-
const pathname = `/v1/fonts/families/${fontFamilyId}/items`;
|
|
34
|
-
const query = getSearchParams({ sort: 'order' });
|
|
35
|
-
const path = `${pathname}?${query}`;
|
|
36
|
-
const options = { revivers: fontRevivers };
|
|
37
|
-
|
|
38
|
-
type ApiFontArray = {
|
|
39
|
-
data: ApiFontData[];
|
|
40
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
41
|
-
|
|
42
|
-
return request<ApiFontArray, Font>(path, null, defaultListHeader, options);
|
|
43
|
-
}
|
|
1
|
+
import { type ApiFontData, type Font, fontRevivers } from './font.js';
|
|
2
|
+
import {
|
|
3
|
+
type ApiCommonData,
|
|
4
|
+
type ApiError,
|
|
5
|
+
type ApiSuccess,
|
|
6
|
+
type Flatten,
|
|
7
|
+
type Revivers,
|
|
8
|
+
defaultListHeader,
|
|
9
|
+
getSearchParams,
|
|
10
|
+
request,
|
|
11
|
+
} from '../utils.js';
|
|
12
|
+
|
|
13
|
+
export type FontFamily = {
|
|
14
|
+
id: number;
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type ApiFontFamily = {
|
|
19
|
+
data: {
|
|
20
|
+
id: number; // The id of the font family (sortable)
|
|
21
|
+
name: string; // The name of the font family (searchable, sortable)
|
|
22
|
+
order?: number; // TODO: not present in API specification!
|
|
23
|
+
} & ApiCommonData;
|
|
24
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
25
|
+
|
|
26
|
+
export type ApiFontFamilyData = Flatten<Exclude<ApiFontFamily, ApiError>['data']>;
|
|
27
|
+
|
|
28
|
+
export const fontFamilyRevivers: Revivers<ApiFontFamily, FontFamily> = {
|
|
29
|
+
order: undefined,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export async function listFontFamilyFonts(fontFamilyId: number): Promise<Font[]> {
|
|
33
|
+
const pathname = `/v1/fonts/families/${fontFamilyId}/items`;
|
|
34
|
+
const query = getSearchParams({ sort: 'order' });
|
|
35
|
+
const path = `${pathname}?${query}`;
|
|
36
|
+
const options = { revivers: fontRevivers };
|
|
37
|
+
|
|
38
|
+
type ApiFontArray = {
|
|
39
|
+
data: ApiFontData[];
|
|
40
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
41
|
+
|
|
42
|
+
return request<ApiFontArray, Font>(path, null, defaultListHeader, options);
|
|
43
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ApiError, type ApiSuccess, request } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
export type GeocodeResult = {
|
|
4
|
+
index: number;
|
|
5
|
+
lat: number | undefined;
|
|
6
|
+
lng: number | undefined;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export async function bulkGeocode(addresses: Array<{ index: number; address: string }>): Promise<GeocodeResult[]> {
|
|
10
|
+
const pathname = `/v1/geocode`;
|
|
11
|
+
|
|
12
|
+
type GeocodeResultArray = {
|
|
13
|
+
data: GeocodeResult[];
|
|
14
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
15
|
+
|
|
16
|
+
return request<GeocodeResultArray, GeocodeResult>(pathname, { items: addresses });
|
|
17
|
+
}
|
package/src/api/highlight.ts
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import type { FeatureCollection } from 'geojson';
|
|
2
|
-
import type { SnakeCase } from 'type-fest';
|
|
3
|
-
import {
|
|
4
|
-
APIMeta,
|
|
5
|
-
type ApiCommonData,
|
|
6
|
-
type ApiError,
|
|
7
|
-
type ApiSuccess,
|
|
8
|
-
type Flatten,
|
|
9
|
-
defaultListHeader,
|
|
10
|
-
getSearchParams,
|
|
11
|
-
request,
|
|
12
|
-
} from '../utils.js';
|
|
13
|
-
|
|
14
|
-
type FieldName = 'id' | 'name' | 'description' | 'previewPath' | 'previewJson';
|
|
15
|
-
|
|
16
|
-
export type PartialVectorHighlight = Pick<VectorHighlight, FieldName>;
|
|
17
|
-
|
|
18
|
-
export type VectorHighlight = {
|
|
19
|
-
id: number;
|
|
20
|
-
name: string;
|
|
21
|
-
description: string;
|
|
22
|
-
previewPath: string | null;
|
|
23
|
-
previewJson: FeatureCollection | null;
|
|
24
|
-
|
|
25
|
-
vectorSetUrl: string;
|
|
26
|
-
sourceLayerName: string;
|
|
27
|
-
|
|
28
|
-
lngMin: number;
|
|
29
|
-
lngMax: number;
|
|
30
|
-
latMin: number;
|
|
31
|
-
latMax: number;
|
|
32
|
-
|
|
33
|
-
keys: string[];
|
|
34
|
-
properties: Record<string, unknown>;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export type ApiVectorHighlight = {
|
|
38
|
-
data: {
|
|
39
|
-
id: number;
|
|
40
|
-
name: string;
|
|
41
|
-
description: string;
|
|
42
|
-
preview_path: string | null;
|
|
43
|
-
preview_json: FeatureCollection | null;
|
|
44
|
-
|
|
45
|
-
vector_set_url: string;
|
|
46
|
-
source_layer_name: string;
|
|
47
|
-
|
|
48
|
-
lng_min: number;
|
|
49
|
-
lng_max: number;
|
|
50
|
-
lat_min: number;
|
|
51
|
-
lat_max: number;
|
|
52
|
-
|
|
53
|
-
keys: string[];
|
|
54
|
-
properties: Record<string, unknown>;
|
|
55
|
-
} & ApiCommonData;
|
|
56
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
57
|
-
|
|
58
|
-
export type ApiVectorHighlightData = Flatten<Exclude<ApiVectorHighlight, ApiError>['data']>;
|
|
59
|
-
|
|
60
|
-
export async function listVectorHighlights(name: string): Promise<PartialVectorHighlight[]> {
|
|
61
|
-
const pathname = `/v1/highlights/vector`;
|
|
62
|
-
const query = getSearchParams({ search: { name } });
|
|
63
|
-
const path = `${pathname}?${query}`;
|
|
64
|
-
|
|
65
|
-
// Only request first 50 results
|
|
66
|
-
const headers = { ...defaultListHeader };
|
|
67
|
-
const options = { withMeta: true };
|
|
68
|
-
|
|
69
|
-
type ApiVectorHighlightArray = {
|
|
70
|
-
data: Array<Pick<ApiVectorHighlightData, SnakeCase<FieldName>>>;
|
|
71
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
72
|
-
|
|
73
|
-
return request<ApiVectorHighlightArray, PartialVectorHighlight>(path, null, headers, options)
|
|
74
|
-
.catch((error: Error) => {
|
|
75
|
-
if (error instanceof APIMeta) {
|
|
76
|
-
return (error as APIMeta<ApiVectorHighlightArray, PartialVectorHighlight>).data;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
throw error;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export async function getVectorHighlight(highlightId: number): Promise<VectorHighlight> {
|
|
84
|
-
const path = `/v1/highlights/vector/${highlightId}`;
|
|
85
|
-
|
|
86
|
-
return request<ApiVectorHighlight, VectorHighlight>(path);
|
|
87
|
-
}
|
|
1
|
+
import type { FeatureCollection } from 'geojson';
|
|
2
|
+
import type { SnakeCase } from 'type-fest';
|
|
3
|
+
import {
|
|
4
|
+
APIMeta,
|
|
5
|
+
type ApiCommonData,
|
|
6
|
+
type ApiError,
|
|
7
|
+
type ApiSuccess,
|
|
8
|
+
type Flatten,
|
|
9
|
+
defaultListHeader,
|
|
10
|
+
getSearchParams,
|
|
11
|
+
request,
|
|
12
|
+
} from '../utils.js';
|
|
13
|
+
|
|
14
|
+
type FieldName = 'id' | 'name' | 'description' | 'previewPath' | 'previewJson';
|
|
15
|
+
|
|
16
|
+
export type PartialVectorHighlight = Pick<VectorHighlight, FieldName>;
|
|
17
|
+
|
|
18
|
+
export type VectorHighlight = {
|
|
19
|
+
id: number;
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
previewPath: string | null;
|
|
23
|
+
previewJson: FeatureCollection | null;
|
|
24
|
+
|
|
25
|
+
vectorSetUrl: string;
|
|
26
|
+
sourceLayerName: string;
|
|
27
|
+
|
|
28
|
+
lngMin: number;
|
|
29
|
+
lngMax: number;
|
|
30
|
+
latMin: number;
|
|
31
|
+
latMax: number;
|
|
32
|
+
|
|
33
|
+
keys: string[];
|
|
34
|
+
properties: Record<string, unknown>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type ApiVectorHighlight = {
|
|
38
|
+
data: {
|
|
39
|
+
id: number;
|
|
40
|
+
name: string;
|
|
41
|
+
description: string;
|
|
42
|
+
preview_path: string | null;
|
|
43
|
+
preview_json: FeatureCollection | null;
|
|
44
|
+
|
|
45
|
+
vector_set_url: string;
|
|
46
|
+
source_layer_name: string;
|
|
47
|
+
|
|
48
|
+
lng_min: number;
|
|
49
|
+
lng_max: number;
|
|
50
|
+
lat_min: number;
|
|
51
|
+
lat_max: number;
|
|
52
|
+
|
|
53
|
+
keys: string[];
|
|
54
|
+
properties: Record<string, unknown>;
|
|
55
|
+
} & ApiCommonData;
|
|
56
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
57
|
+
|
|
58
|
+
export type ApiVectorHighlightData = Flatten<Exclude<ApiVectorHighlight, ApiError>['data']>;
|
|
59
|
+
|
|
60
|
+
export async function listVectorHighlights(name: string): Promise<PartialVectorHighlight[]> {
|
|
61
|
+
const pathname = `/v1/highlights/vector`;
|
|
62
|
+
const query = getSearchParams({ search: { name } });
|
|
63
|
+
const path = `${pathname}?${query}`;
|
|
64
|
+
|
|
65
|
+
// Only request first 50 results
|
|
66
|
+
const headers = { ...defaultListHeader };
|
|
67
|
+
const options = { withMeta: true };
|
|
68
|
+
|
|
69
|
+
type ApiVectorHighlightArray = {
|
|
70
|
+
data: Array<Pick<ApiVectorHighlightData, SnakeCase<FieldName>>>;
|
|
71
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
72
|
+
|
|
73
|
+
return request<ApiVectorHighlightArray, PartialVectorHighlight>(path, null, headers, options)
|
|
74
|
+
.catch((error: Error) => {
|
|
75
|
+
if (error instanceof APIMeta) {
|
|
76
|
+
return (error as APIMeta<ApiVectorHighlightArray, PartialVectorHighlight>).data;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
throw error;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export async function getVectorHighlight(highlightId: number): Promise<VectorHighlight> {
|
|
84
|
+
const path = `/v1/highlights/vector/${highlightId}`;
|
|
85
|
+
|
|
86
|
+
return request<ApiVectorHighlight, VectorHighlight>(path);
|
|
87
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { apiHost, authenticate, getAuthorizationHeaders, token } from '../oauth.js';
|
|
2
|
+
import {
|
|
3
|
+
APIError,
|
|
4
|
+
type ApiCommonData,
|
|
5
|
+
type ApiError,
|
|
6
|
+
type ApiSuccess,
|
|
7
|
+
type Flatten,
|
|
8
|
+
HTTPError,
|
|
9
|
+
NetworkError,
|
|
10
|
+
request,
|
|
11
|
+
} from '../utils.js';
|
|
12
|
+
|
|
13
|
+
export type InsetMap = {
|
|
14
|
+
id: number;
|
|
15
|
+
description: string;
|
|
16
|
+
jsonFilename: string;
|
|
17
|
+
latMin: number;
|
|
18
|
+
lngMin: number;
|
|
19
|
+
latMax: number;
|
|
20
|
+
lngMax: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type ApiInsetMap = {
|
|
24
|
+
data: {
|
|
25
|
+
id: number;
|
|
26
|
+
description: string;
|
|
27
|
+
json_filename: string;
|
|
28
|
+
lat_min: number;
|
|
29
|
+
lng_min: number;
|
|
30
|
+
lat_max: number;
|
|
31
|
+
lng_max: number;
|
|
32
|
+
} & ApiCommonData;
|
|
33
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
34
|
+
|
|
35
|
+
export type ApiInsetMapData = Flatten<Exclude<ApiInsetMap, ApiError>['data']>;
|
|
36
|
+
|
|
37
|
+
type Boundary = {
|
|
38
|
+
topLeft: {
|
|
39
|
+
lat: number;
|
|
40
|
+
lng: number;
|
|
41
|
+
};
|
|
42
|
+
bottomRight: {
|
|
43
|
+
lat: number;
|
|
44
|
+
lng: number;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export async function listInsetMaps(boundary: Boundary): Promise<InsetMap[]> {
|
|
49
|
+
const path = `/v1/inset-maps/for-boundary`;
|
|
50
|
+
|
|
51
|
+
type ApiInsetMapArray = {
|
|
52
|
+
data: ApiInsetMapData[];
|
|
53
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
54
|
+
|
|
55
|
+
return request<ApiInsetMapArray, InsetMap>(path, { boundary });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function getInsetMap(insetMapId: number): Promise<InsetMap> {
|
|
59
|
+
const path = `/v1/inset-maps/${insetMapId}`;
|
|
60
|
+
|
|
61
|
+
return request<ApiInsetMap, InsetMap>(path);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function getInsetMapTopoJson<TopoJSON>(insetMapId: number): Promise<TopoJSON> {
|
|
65
|
+
const href = `${apiHost}/v1/inset-maps/${insetMapId}/json`;
|
|
66
|
+
const headers = getAuthorizationHeaders('GET');
|
|
67
|
+
const response = await fetch(href, { headers, ...!token && { credentials: 'include' } })
|
|
68
|
+
.catch((error: Error) => { throw new NetworkError(error?.message ?? error) });
|
|
69
|
+
|
|
70
|
+
if (response.ok) {
|
|
71
|
+
return response.json().catch(() => {
|
|
72
|
+
throw new APIError({
|
|
73
|
+
success: false,
|
|
74
|
+
error: { type: 'SyntaxError', message: 'Malformed JSON response' },
|
|
75
|
+
});
|
|
76
|
+
}) as Promise<TopoJSON>;
|
|
77
|
+
} else {
|
|
78
|
+
// eslint-disable-next-line default-case
|
|
79
|
+
switch (response.status) {
|
|
80
|
+
case 401:
|
|
81
|
+
await authenticate();
|
|
82
|
+
break; // NO-OP
|
|
83
|
+
case 403:
|
|
84
|
+
case 404:
|
|
85
|
+
case 406:
|
|
86
|
+
case 429:
|
|
87
|
+
throw new APIError({
|
|
88
|
+
success: false,
|
|
89
|
+
error: { type: 'HttpException', message: response.statusText },
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
throw new HTTPError(response);
|
|
94
|
+
}
|
|
95
|
+
}
|