@mapcreator/api 0.0.0-saga.1 → 0.0.0-saga.3
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/choropleth.d.ts +3 -3
- package/cjs/api/choropleth.d.ts.map +1 -1
- package/cjs/api/choropleth.js +17 -4
- package/cjs/api/choropleth.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 +49 -0
- package/cjs/api/insetMap.js.map +1 -0
- 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/cjs/index.d.ts +1 -0
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +1 -0
- package/cjs/index.js.map +1 -1
- package/esm/api/choropleth.d.ts +3 -3
- package/esm/api/choropleth.d.ts.map +1 -1
- package/esm/api/choropleth.js +17 -4
- package/esm/api/choropleth.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 +44 -0
- package/esm/api/insetMap.js.map +1 -0
- 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/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/package.json +2 -2
- package/src/api/apiCommon.ts +70 -70
- package/src/api/choropleth.ts +125 -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 +49 -49
- package/src/api/fontFamily.ts +43 -43
- package/src/api/highlight.ts +87 -87
- package/src/api/insetMap.ts +96 -0
- 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 +145 -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 +43 -42
- package/src/oauth.ts +314 -314
- package/src/utils.ts +342 -342
package/src/api/choropleth.ts
CHANGED
|
@@ -1,105 +1,125 @@
|
|
|
1
|
-
import { type ApiError, type ApiSuccess, getSearchParams, request } from '../utils.js';
|
|
2
|
-
import type { Polygon } from 'geojson';
|
|
3
|
-
|
|
4
|
-
export type ApiSearchPoint = {
|
|
5
|
-
lat: number;
|
|
6
|
-
lng: number;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export type ApiSearchBounds = {
|
|
10
|
-
min_lat: number;
|
|
11
|
-
min_lng: number;
|
|
12
|
-
max_lat: number;
|
|
13
|
-
max_lng: number;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type ApiSingleOrGroupedAreaArray =
|
|
17
|
-
| ({ data: ApiSingleOrGroupedArea[] } & Omit<ApiSuccess, 'data'>)
|
|
18
|
-
| ApiError;
|
|
19
|
-
|
|
20
|
-
type ApiSingleOrGroupedArea = {
|
|
21
|
-
id: number;
|
|
22
|
-
title: string;
|
|
23
|
-
subtitle: string;
|
|
24
|
-
svg_preview: string;
|
|
25
|
-
bounding_box: string;
|
|
26
|
-
is_group: boolean;
|
|
27
|
-
vector_source: string | null;
|
|
28
|
-
source_layer: string | null;
|
|
29
|
-
feature_id: number | null;
|
|
30
|
-
properties: Record<string, string> | null;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
type SingleOrGroupedAreaBase = {
|
|
34
|
-
id: number;
|
|
35
|
-
title: string;
|
|
36
|
-
subtitle: string;
|
|
37
|
-
svgPreview: string;
|
|
38
|
-
boundingBox: Polygon;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
1
|
+
import { type ApiError, type ApiSuccess, getSearchParams, request } from '../utils.js';
|
|
2
|
+
import type { Polygon } from 'geojson';
|
|
3
|
+
|
|
4
|
+
export type ApiSearchPoint = {
|
|
5
|
+
lat: number;
|
|
6
|
+
lng: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type ApiSearchBounds = {
|
|
10
|
+
min_lat: number;
|
|
11
|
+
min_lng: number;
|
|
12
|
+
max_lat: number;
|
|
13
|
+
max_lng: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type ApiSingleOrGroupedAreaArray =
|
|
17
|
+
| ({ data: ApiSingleOrGroupedArea[] } & Omit<ApiSuccess, 'data'>)
|
|
18
|
+
| ApiError;
|
|
19
|
+
|
|
20
|
+
type ApiSingleOrGroupedArea = {
|
|
21
|
+
id: number;
|
|
22
|
+
title: string;
|
|
23
|
+
subtitle: string;
|
|
24
|
+
svg_preview: string;
|
|
25
|
+
bounding_box: string;
|
|
26
|
+
is_group: boolean;
|
|
27
|
+
vector_source: string | null;
|
|
28
|
+
source_layer: string | null;
|
|
29
|
+
feature_id: number | null;
|
|
30
|
+
properties: Record<string, string> | null;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type SingleOrGroupedAreaBase = {
|
|
34
|
+
id: number;
|
|
35
|
+
title: string;
|
|
36
|
+
subtitle: string;
|
|
37
|
+
svgPreview: string;
|
|
38
|
+
boundingBox: Polygon;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// TODO don't export this once search on click is out
|
|
42
|
+
export type GroupedArea = SingleOrGroupedAreaBase & {
|
|
43
|
+
isGroup: true;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// TODO don't export this once search on click is out
|
|
47
|
+
export type SingleArea = SingleOrGroupedAreaBase & {
|
|
48
|
+
isGroup: false;
|
|
49
|
+
vectorSource: string;
|
|
50
|
+
sourceLayer: string;
|
|
51
|
+
featureId: number;
|
|
52
|
+
properties: Record<string, string>;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type SingleOrGroupedArea = SingleArea | GroupedArea;
|
|
56
|
+
|
|
57
|
+
export async function searchSingleOrGroupedAreas(
|
|
58
|
+
language: string,
|
|
59
|
+
searchBounds?: ApiSearchBounds,
|
|
60
|
+
query?: string,
|
|
61
|
+
searchPoint?: ApiSearchPoint,
|
|
62
|
+
mode: 'polygon' | 'group' | 'both' = 'both',
|
|
63
|
+
): Promise<SingleOrGroupedArea[]> {
|
|
64
|
+
/**
|
|
65
|
+
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
66
|
+
*/
|
|
67
|
+
return request<ApiSingleOrGroupedAreaArray, SingleOrGroupedArea>(
|
|
68
|
+
`/v1/choropleth/polygons/search?${getSearchParams({
|
|
69
|
+
language,
|
|
70
|
+
...searchBounds,
|
|
71
|
+
...(query && { query }),
|
|
72
|
+
...(searchPoint && { point: searchPoint }),
|
|
73
|
+
mode,
|
|
74
|
+
})}`,
|
|
75
|
+
).then(result => {
|
|
76
|
+
result.forEach(
|
|
77
|
+
elem => {
|
|
78
|
+
elem.boundingBox = JSON.parse(elem.boundingBox as unknown as string) as Polygon;
|
|
79
|
+
if (!elem.isGroup) {
|
|
80
|
+
elem.properties = JSON.parse(elem.properties as unknown as string) as Record<string, string>;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
return result;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type ApiGroupedAreaChildArray =
|
|
90
|
+
| ({
|
|
91
|
+
data: ApiGroupedAreaChild[];
|
|
92
|
+
} & Omit<ApiSuccess, 'data'>)
|
|
93
|
+
| ApiError;
|
|
94
|
+
|
|
95
|
+
type ApiGroupedAreaChild = {
|
|
96
|
+
id: number;
|
|
97
|
+
title: string;
|
|
98
|
+
vector_source: string;
|
|
99
|
+
source_layer: string;
|
|
100
|
+
feature_id: number;
|
|
101
|
+
properties: Record<string, string>;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export type GroupedAreaChild = {
|
|
105
|
+
id: number;
|
|
106
|
+
title: string;
|
|
107
|
+
vectorSource: string;
|
|
108
|
+
sourceLayer: string;
|
|
109
|
+
featureId: number;
|
|
110
|
+
properties: Record<string, string>;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export async function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]> {
|
|
114
|
+
return request<ApiGroupedAreaChildArray, GroupedAreaChild>(
|
|
115
|
+
`/v1/choropleth/groups/${groupId}/children-optimized?${getSearchParams({ language })}`,
|
|
116
|
+
).then(result => {
|
|
117
|
+
result.forEach(
|
|
118
|
+
elem => {
|
|
119
|
+
elem.properties = JSON.parse(elem.properties as unknown as string) as Record<string, string>;
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
return result;
|
|
124
|
+
});
|
|
125
|
+
}
|
package/src/api/color.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
-
|
|
3
|
-
export type Color = {
|
|
4
|
-
id: number;
|
|
5
|
-
hex: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type ApiColor = {
|
|
9
|
-
data: {
|
|
10
|
-
id: number; // The color id (sortable)
|
|
11
|
-
name: string; // The name of the color (searchable, sortable)
|
|
12
|
-
hex: string; // The hex value of the color (searchable, sortable)
|
|
13
|
-
order?: number; // TODO: not present in API specification!
|
|
14
|
-
} & ApiCommonData;
|
|
15
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
16
|
-
|
|
17
|
-
export type ApiColorData = Flatten<Exclude<ApiColor, ApiError>['data']>;
|
|
18
|
-
|
|
19
|
-
export const colorRevivers: Revivers<ApiColor, Color> = {
|
|
20
|
-
name: undefined,
|
|
21
|
-
order: undefined,
|
|
22
|
-
};
|
|
1
|
+
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
export type Color = {
|
|
4
|
+
id: number;
|
|
5
|
+
hex: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type ApiColor = {
|
|
9
|
+
data: {
|
|
10
|
+
id: number; // The color id (sortable)
|
|
11
|
+
name: string; // The name of the color (searchable, sortable)
|
|
12
|
+
hex: string; // The hex value of the color (searchable, sortable)
|
|
13
|
+
order?: number; // TODO: not present in API specification!
|
|
14
|
+
} & ApiCommonData;
|
|
15
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
16
|
+
|
|
17
|
+
export type ApiColorData = Flatten<Exclude<ApiColor, ApiError>['data']>;
|
|
18
|
+
|
|
19
|
+
export const colorRevivers: Revivers<ApiColor, Color> = {
|
|
20
|
+
name: undefined,
|
|
21
|
+
order: undefined,
|
|
22
|
+
};
|
package/src/api/dimension.ts
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
-
|
|
3
|
-
export type OutputUnit =
|
|
4
|
-
| 'millimeter'
|
|
5
|
-
| 'centimeter'
|
|
6
|
-
| 'inch'
|
|
7
|
-
| 'pixel'
|
|
8
|
-
| 'pica';
|
|
9
|
-
|
|
10
|
-
export type Dimension = {
|
|
11
|
-
id: number;
|
|
12
|
-
dimensionSetId: number;
|
|
13
|
-
name: string;
|
|
14
|
-
width: number;
|
|
15
|
-
height: number;
|
|
16
|
-
dpi: number;
|
|
17
|
-
unit: OutputUnit;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type ApiDimension = {
|
|
21
|
-
data: {
|
|
22
|
-
id: number; // The dimension id (sortable)
|
|
23
|
-
dimension_set_id: number; // The id of the dimension set
|
|
24
|
-
name: string; // The name of dimension (searchable, sortable)
|
|
25
|
-
width: number; // The width of the dimension (searchable, sortable)
|
|
26
|
-
height: number; // The height of the dimension (searchable, sortable)
|
|
27
|
-
dpi: number; // The dpi of the dimension
|
|
28
|
-
unit: string; // The unit of this dimension
|
|
29
|
-
} & ApiCommonData;
|
|
30
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
31
|
-
|
|
32
|
-
export type ApiDimensionData = Flatten<Exclude<ApiDimension, ApiError>['data']>;
|
|
33
|
-
|
|
34
|
-
const keyToUnit: { [key: string]: OutputUnit } = {
|
|
35
|
-
MM: 'millimeter',
|
|
36
|
-
CM: 'centimeter',
|
|
37
|
-
IN: 'inch',
|
|
38
|
-
PX: 'pixel',
|
|
39
|
-
PICA: 'pica',
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const dimensionRevivers: Revivers<ApiDimension, Dimension> = {
|
|
43
|
-
unit: (data: ApiDimensionData) => keyToUnit[data.unit],
|
|
44
|
-
};
|
|
1
|
+
import type { ApiCommonData, ApiError, ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
export type OutputUnit =
|
|
4
|
+
| 'millimeter'
|
|
5
|
+
| 'centimeter'
|
|
6
|
+
| 'inch'
|
|
7
|
+
| 'pixel'
|
|
8
|
+
| 'pica';
|
|
9
|
+
|
|
10
|
+
export type Dimension = {
|
|
11
|
+
id: number;
|
|
12
|
+
dimensionSetId: number;
|
|
13
|
+
name: string;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
dpi: number;
|
|
17
|
+
unit: OutputUnit;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type ApiDimension = {
|
|
21
|
+
data: {
|
|
22
|
+
id: number; // The dimension id (sortable)
|
|
23
|
+
dimension_set_id: number; // The id of the dimension set
|
|
24
|
+
name: string; // The name of dimension (searchable, sortable)
|
|
25
|
+
width: number; // The width of the dimension (searchable, sortable)
|
|
26
|
+
height: number; // The height of the dimension (searchable, sortable)
|
|
27
|
+
dpi: number; // The dpi of the dimension
|
|
28
|
+
unit: string; // The unit of this dimension
|
|
29
|
+
} & ApiCommonData;
|
|
30
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
31
|
+
|
|
32
|
+
export type ApiDimensionData = Flatten<Exclude<ApiDimension, ApiError>['data']>;
|
|
33
|
+
|
|
34
|
+
const keyToUnit: { [key: string]: OutputUnit } = {
|
|
35
|
+
MM: 'millimeter',
|
|
36
|
+
CM: 'centimeter',
|
|
37
|
+
IN: 'inch',
|
|
38
|
+
PX: 'pixel',
|
|
39
|
+
PICA: 'pica',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const dimensionRevivers: Revivers<ApiDimension, Dimension> = {
|
|
43
|
+
unit: (data: ApiDimensionData) => keyToUnit[data.unit],
|
|
44
|
+
};
|
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,49 @@
|
|
|
1
|
-
import { type ApiCommonData, type ApiError, type ApiSuccess, type Flatten, type Revivers, getSearchParams, request } from '../utils.js';
|
|
2
|
-
|
|
3
|
-
export type Font = {
|
|
4
|
-
id: number;
|
|
5
|
-
fontFamilyId: number;
|
|
6
|
-
name: string;
|
|
7
|
-
label: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type ApiFont = {
|
|
11
|
-
data: {
|
|
12
|
-
id: number; // The id of the font (sortable)
|
|
13
|
-
font_family_id: number; // The id of the font family
|
|
14
|
-
name: string; // The name of the font (searchable, sortable)
|
|
15
|
-
style: string; // The font style (searchable, sortable)
|
|
16
|
-
stretch: string; // The font stretch (searchable, sortable)
|
|
17
|
-
weight: number; // The font weight (searchable, sortable)
|
|
18
|
-
label: string; // The label of the font (searchable, sortable)
|
|
19
|
-
order?: number; // TODO: not present in API specification!
|
|
20
|
-
} & ApiCommonData;
|
|
21
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
22
|
-
|
|
23
|
-
export type ApiFontData = Flatten<Exclude<ApiFont, ApiError>['data']>;
|
|
24
|
-
|
|
25
|
-
type FontSearchOptions = {
|
|
26
|
-
family?: string;
|
|
27
|
-
style?: string;
|
|
28
|
-
weight?: string;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const fontRevivers: Revivers<ApiFont, Font> = {
|
|
32
|
-
style: undefined,
|
|
33
|
-
stretch: undefined,
|
|
34
|
-
weight: undefined,
|
|
35
|
-
order: undefined,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export async function getFonts(searchOptions: FontSearchOptions): Promise<Font[] | Font> {
|
|
39
|
-
const pathname = `/v1/fonts/search`;
|
|
40
|
-
const query = getSearchParams(searchOptions);
|
|
41
|
-
|
|
42
|
-
const path = `${pathname}?${query}`;
|
|
43
|
-
|
|
44
|
-
type ApiFontArray = {
|
|
45
|
-
data: ApiFontData[];
|
|
46
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
47
|
-
|
|
48
|
-
return request<ApiFontArray, Font>(path);
|
|
49
|
-
}
|
|
1
|
+
import { type ApiCommonData, type ApiError, type ApiSuccess, type Flatten, type Revivers, getSearchParams, request } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
export type Font = {
|
|
4
|
+
id: number;
|
|
5
|
+
fontFamilyId: number;
|
|
6
|
+
name: string;
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type ApiFont = {
|
|
11
|
+
data: {
|
|
12
|
+
id: number; // The id of the font (sortable)
|
|
13
|
+
font_family_id: number; // The id of the font family
|
|
14
|
+
name: string; // The name of the font (searchable, sortable)
|
|
15
|
+
style: string; // The font style (searchable, sortable)
|
|
16
|
+
stretch: string; // The font stretch (searchable, sortable)
|
|
17
|
+
weight: number; // The font weight (searchable, sortable)
|
|
18
|
+
label: string; // The label of the font (searchable, sortable)
|
|
19
|
+
order?: number; // TODO: not present in API specification!
|
|
20
|
+
} & ApiCommonData;
|
|
21
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
22
|
+
|
|
23
|
+
export type ApiFontData = Flatten<Exclude<ApiFont, ApiError>['data']>;
|
|
24
|
+
|
|
25
|
+
type FontSearchOptions = {
|
|
26
|
+
family?: string;
|
|
27
|
+
style?: string;
|
|
28
|
+
weight?: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const fontRevivers: Revivers<ApiFont, Font> = {
|
|
32
|
+
style: undefined,
|
|
33
|
+
stretch: undefined,
|
|
34
|
+
weight: undefined,
|
|
35
|
+
order: undefined,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export async function getFonts(searchOptions: FontSearchOptions): Promise<Font[] | Font> {
|
|
39
|
+
const pathname = `/v1/fonts/search`;
|
|
40
|
+
const query = getSearchParams(searchOptions);
|
|
41
|
+
|
|
42
|
+
const path = `${pathname}?${query}`;
|
|
43
|
+
|
|
44
|
+
type ApiFontArray = {
|
|
45
|
+
data: ApiFontData[];
|
|
46
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
47
|
+
|
|
48
|
+
return request<ApiFontArray, Font>(path);
|
|
49
|
+
}
|
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
|
+
}
|