@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.
Files changed (70) hide show
  1. package/cjs/api/insetMap.js +1 -1
  2. package/cjs/api/insetMap.js.map +1 -1
  3. package/cjs/api/job.d.ts +1 -0
  4. package/cjs/api/job.d.ts.map +1 -1
  5. package/cjs/api/job.js.map +1 -1
  6. package/cjs/api/jobResult.d.ts +1 -1
  7. package/cjs/api/jobResult.d.ts.map +1 -1
  8. package/cjs/api/jobResult.js +1 -1
  9. package/cjs/api/jobResult.js.map +1 -1
  10. package/cjs/api/jobRevision.d.ts +2 -2
  11. package/cjs/api/jobRevision.d.ts.map +1 -1
  12. package/cjs/api/jobRevision.js +1 -1
  13. package/cjs/api/jobRevision.js.map +1 -1
  14. package/cjs/api/organisation.d.ts +2 -1
  15. package/cjs/api/organisation.d.ts.map +1 -1
  16. package/cjs/api/organisation.js +1 -2
  17. package/cjs/api/organisation.js.map +1 -1
  18. package/cjs/api/resources.d.ts +1 -1
  19. package/cjs/api/resources.d.ts.map +1 -1
  20. package/cjs/api/resources.js.map +1 -1
  21. package/esm/api/insetMap.js +1 -1
  22. package/esm/api/insetMap.js.map +1 -1
  23. package/esm/api/job.d.ts +1 -0
  24. package/esm/api/job.d.ts.map +1 -1
  25. package/esm/api/job.js.map +1 -1
  26. package/esm/api/jobResult.d.ts +1 -1
  27. package/esm/api/jobResult.d.ts.map +1 -1
  28. package/esm/api/jobResult.js +1 -1
  29. package/esm/api/jobResult.js.map +1 -1
  30. package/esm/api/jobRevision.d.ts +2 -2
  31. package/esm/api/jobRevision.d.ts.map +1 -1
  32. package/esm/api/jobRevision.js +1 -1
  33. package/esm/api/jobRevision.js.map +1 -1
  34. package/esm/api/organisation.d.ts +2 -1
  35. package/esm/api/organisation.d.ts.map +1 -1
  36. package/esm/api/organisation.js +1 -2
  37. package/esm/api/organisation.js.map +1 -1
  38. package/esm/api/resources.d.ts +1 -1
  39. package/esm/api/resources.d.ts.map +1 -1
  40. package/esm/api/resources.js.map +1 -1
  41. package/package.json +1 -1
  42. package/src/api/apiCommon.ts +70 -70
  43. package/src/api/choropleth.ts +359 -359
  44. package/src/api/color.ts +22 -22
  45. package/src/api/dimension.ts +44 -44
  46. package/src/api/dimensionSet.ts +20 -20
  47. package/src/api/feature.ts +22 -22
  48. package/src/api/font.ts +49 -49
  49. package/src/api/fontFamily.ts +43 -43
  50. package/src/api/highlight.ts +87 -87
  51. package/src/api/insetMap.ts +96 -96
  52. package/src/api/job.ts +130 -129
  53. package/src/api/jobResult.ts +95 -95
  54. package/src/api/jobRevision.ts +279 -278
  55. package/src/api/jobShare.ts +35 -35
  56. package/src/api/jobType.ts +26 -26
  57. package/src/api/language.ts +19 -19
  58. package/src/api/layer.ts +38 -38
  59. package/src/api/layerFaq.ts +53 -53
  60. package/src/api/layerGroup.ts +69 -69
  61. package/src/api/mapstyleSet.ts +48 -48
  62. package/src/api/message.ts +80 -80
  63. package/src/api/organisation.ts +95 -95
  64. package/src/api/resources.ts +146 -144
  65. package/src/api/svg.ts +33 -33
  66. package/src/api/svgSet.ts +56 -56
  67. package/src/api/user.ts +327 -327
  68. package/src/index.ts +43 -43
  69. package/src/oauth.ts +314 -314
  70. package/src/utils.ts +342 -342
@@ -1,96 +1,96 @@
1
- import { apiHost, authenticate, 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 = { Accept: 'application/json', ...(token ? { Authorization: token.toString() } : null) };
67
- const response = await fetch(href, { headers }).catch((error: Error) => {
68
- throw new NetworkError(error?.message ?? error);
69
- });
70
-
71
- if (response.ok) {
72
- return response.json().catch(() => {
73
- throw new APIError({
74
- success: false,
75
- error: { type: 'SyntaxError', message: 'Malformed JSON response' },
76
- });
77
- }) as Promise<TopoJSON>;
78
- } else {
79
- // eslint-disable-next-line default-case
80
- switch (response.status) {
81
- case 401:
82
- await authenticate();
83
- break; // NO-OP
84
- case 403:
85
- case 404:
86
- case 406:
87
- case 429:
88
- throw new APIError({
89
- success: false,
90
- error: { type: 'HttpException', message: response.statusText },
91
- });
92
- }
93
-
94
- throw new HTTPError(response);
95
- }
96
- }
1
+ import { apiHost, authenticate, 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 = { Accept: 'application/json', ...(token ? { Authorization: token.toString() } : null) };
67
+ const response = await fetch(href, { headers }).catch((error: Error) => {
68
+ throw new NetworkError(error?.message ?? error);
69
+ });
70
+
71
+ if (response.ok) {
72
+ return response.json().catch(() => {
73
+ throw new APIError({
74
+ success: false,
75
+ error: { type: 'SyntaxError', message: 'Malformed JSON response' },
76
+ });
77
+ }) as Promise<TopoJSON>;
78
+ } else {
79
+ // eslint-disable-next-line default-case
80
+ switch (response.status) {
81
+ case 401:
82
+ await authenticate();
83
+ break; // NO-OP
84
+ case 403:
85
+ case 404:
86
+ case 406:
87
+ case 429:
88
+ throw new APIError({
89
+ success: false,
90
+ error: { type: 'HttpException', message: response.statusText },
91
+ });
92
+ }
93
+
94
+ throw new HTTPError(response);
95
+ }
96
+ }
package/src/api/job.ts CHANGED
@@ -1,129 +1,130 @@
1
- import type { ApiJobShare, JobShare, JobShareVisibility } from './jobShare.js';
2
- import { type JobSearchResult, listJobs } from './apiCommon.js';
3
- import {
4
- type ApiCommon,
5
- type ApiCommonData,
6
- type ApiError,
7
- type ApiSuccess,
8
- type Flatten,
9
- type Revivers,
10
- deletedNoneParam,
11
- request,
12
- } from '../utils.js';
13
-
14
- export type Job = {
15
- id: number;
16
- jobTypeId: number;
17
- title: string;
18
- previewPath: string | undefined;
19
- createdAt: string;
20
- star: boolean;
21
- jobFolderId: number | null;
22
- userEmail: string | undefined;
23
- jobFolderName: string | null;
24
- userId: number;
25
- };
26
-
27
- export type ApiJob = {
28
- data: {
29
- id: number; // The job id (sortable)
30
- job_type_id: number; // The id of the job type (searchable)
31
- user_id: number; // The user id (searchable)
32
- title: string; // The title of the job (searchable, sortable)
33
- description: string | null; // The description of the job (searchable, sortable)
34
- share_token: string | null; // The token used for sharing this job
35
- autosave_preview_path: string | null; // The preview path of the Job
36
- job_folder_id: number | null; // TODO: not present in API specification!
37
- job_folder_name?: string | null; // TODO: not present in API specification!
38
- star: boolean; // TODO: not present in API specification!
39
- } & ApiCommonData;
40
- } & Omit<ApiSuccess, 'data'> | ApiError;
41
-
42
- export type ApiJobData = Flatten<Exclude<ApiJob, ApiError>['data']>;
43
-
44
- export const jobRevivers: Revivers<ApiJob, Job> = {
45
- description: undefined,
46
- share_token: undefined,
47
- autosave_preview_path: undefined,
48
-
49
- jobTypeId: () => 9,
50
- jobFolderName: (data: ApiJobData) => data.job_folder_name ?? null,
51
- createdAt: (data: ApiJobData) => data.created_at as string,
52
- previewPath: (data: ApiJobData) => data.autosave_preview_path ?? undefined,
53
- };
54
-
55
- export async function createJob(title: string): Promise<Job> {
56
- const path = `/v1/jobs`;
57
- const body = { title, job_type_id: 9 };
58
- const options = { revivers: jobRevivers };
59
-
60
- // Technically, the returning `data` will contain only the following fields:
61
- // Pick<ApiJobData, 'id' | 'job_type_id' | 'user_id' | 'title' | 'created_at' | 'updated_at'>
62
-
63
- return request<ApiJob, Job>(path, body, null, options);
64
- }
65
-
66
- export async function getJob(jobId: number): Promise<Job> {
67
- const path = `/v1/jobs/${jobId}`;
68
- const options = { revivers: jobRevivers };
69
-
70
- return request<ApiJob, Job>(path, null, null, options);
71
- }
72
-
73
- export async function deleteJob(jobId: number): Promise<Record<string, never>> {
74
- const path = `/v1/jobs/${jobId}`;
75
-
76
- return request<ApiCommon, Record<string, never>>(path, null, null, { method: 'DELETE' });
77
- }
78
-
79
- export async function updateJob(jobId: number, newTitle: string): Promise<Record<string, never>> {
80
- const path = `/v1/jobs/${jobId}`;
81
- const body = { title: newTitle };
82
-
83
- return request<ApiCommon, Record<string, never>>(path, body, null, { method: 'PATCH' });
84
- }
85
-
86
- export async function updateJobFolder(jobId: number, folderId: number | null): Promise<Record<string, never>> {
87
- const path = `/v1/jobs/${jobId}`;
88
- const body = { job_folder_id: folderId };
89
-
90
- return request<ApiCommon, Record<string, never>>(path, body, null, { method: 'PATCH' });
91
- }
92
-
93
- export async function starJob(jobId: number, star: boolean): Promise<Record<string, never>> {
94
- const path = `/v1/jobs/${jobId}`;
95
- const body = { star };
96
-
97
- return request<ApiCommon, Record<string, never>>(path, body, null, { method: 'PATCH' });
98
- }
99
-
100
- export async function generateJobShare(
101
- jobId: number,
102
- visibility: JobShareVisibility,
103
- ): Promise<JobShare> {
104
- const path = `/v1/jobs/${jobId}/share`;
105
- const body = { visibility };
106
-
107
- return request<ApiJobShare, JobShare>(path, body);
108
- }
109
-
110
- export async function uploadJobPreview(
111
- jobId: number,
112
- preview: Blob,
113
- ): Promise<Record<string, never>> {
114
- const pathname = `/v1/jobs/${jobId}/preview`;
115
- const path = `${pathname}?${deletedNoneParam}`;
116
- const body = new FormData();
117
-
118
- body.append('preview', preview);
119
-
120
- return request<ApiCommon, Record<string, never>>(path, body);
121
- }
122
-
123
- export async function listFeaturedJobs(
124
- title: string,
125
- page: number,
126
- options?: Record<string, unknown>,
127
- ): Promise<JobSearchResult> {
128
- return listJobs(`/v1/jobs/featured`, title, page, options);
129
- }
1
+ import type { ApiJobShare, JobShare, JobShareVisibility } from './jobShare.js';
2
+ import { type JobSearchResult, listJobs } from './apiCommon.js';
3
+ import {
4
+ type ApiCommon,
5
+ type ApiCommonData,
6
+ type ApiError,
7
+ type ApiSuccess,
8
+ type Flatten,
9
+ type Revivers,
10
+ deletedNoneParam,
11
+ request,
12
+ } from '../utils.js';
13
+
14
+ export type Job = {
15
+ id: number;
16
+ jobTypeId: number;
17
+ title: string;
18
+ previewPath: string | undefined;
19
+ createdAt: string;
20
+ star: boolean;
21
+ jobFolderId: number | null;
22
+ userEmail: string | undefined;
23
+ jobFolderName: string | null;
24
+ userId: number;
25
+ orgName: string | undefined;
26
+ };
27
+
28
+ export type ApiJob = {
29
+ data: {
30
+ id: number; // The job id (sortable)
31
+ job_type_id: number; // The id of the job type (searchable)
32
+ user_id: number; // The user id (searchable)
33
+ title: string; // The title of the job (searchable, sortable)
34
+ description: string | null; // The description of the job (searchable, sortable)
35
+ share_token: string | null; // The token used for sharing this job
36
+ autosave_preview_path: string | null; // The preview path of the Job
37
+ job_folder_id: number | null; // TODO: not present in API specification!
38
+ job_folder_name?: string | null; // TODO: not present in API specification!
39
+ star: boolean; // TODO: not present in API specification!
40
+ } & ApiCommonData;
41
+ } & Omit<ApiSuccess, 'data'> | ApiError;
42
+
43
+ export type ApiJobData = Flatten<Exclude<ApiJob, ApiError>['data']>;
44
+
45
+ export const jobRevivers: Revivers<ApiJob, Job> = {
46
+ description: undefined,
47
+ share_token: undefined,
48
+ autosave_preview_path: undefined,
49
+
50
+ jobTypeId: () => 9,
51
+ jobFolderName: (data: ApiJobData) => data.job_folder_name ?? null,
52
+ createdAt: (data: ApiJobData) => data.created_at as string,
53
+ previewPath: (data: ApiJobData) => data.autosave_preview_path ?? undefined,
54
+ };
55
+
56
+ export async function createJob(title: string): Promise<Job> {
57
+ const path = `/v1/jobs`;
58
+ const body = { title, job_type_id: 9 };
59
+ const options = { revivers: jobRevivers };
60
+
61
+ // Technically, the returning `data` will contain only the following fields:
62
+ // Pick<ApiJobData, 'id' | 'job_type_id' | 'user_id' | 'title' | 'created_at' | 'updated_at'>
63
+
64
+ return request<ApiJob, Job>(path, body, null, options);
65
+ }
66
+
67
+ export async function getJob(jobId: number): Promise<Job> {
68
+ const path = `/v1/jobs/${jobId}`;
69
+ const options = { revivers: jobRevivers };
70
+
71
+ return request<ApiJob, Job>(path, null, null, options);
72
+ }
73
+
74
+ export async function deleteJob(jobId: number): Promise<Record<string, never>> {
75
+ const path = `/v1/jobs/${jobId}`;
76
+
77
+ return request<ApiCommon, Record<string, never>>(path, null, null, { method: 'DELETE' });
78
+ }
79
+
80
+ export async function updateJob(jobId: number, newTitle: string): Promise<Record<string, never>> {
81
+ const path = `/v1/jobs/${jobId}`;
82
+ const body = { title: newTitle };
83
+
84
+ return request<ApiCommon, Record<string, never>>(path, body, null, { method: 'PATCH' });
85
+ }
86
+
87
+ export async function updateJobFolder(jobId: number, folderId: number | null): Promise<Record<string, never>> {
88
+ const path = `/v1/jobs/${jobId}`;
89
+ const body = { job_folder_id: folderId };
90
+
91
+ return request<ApiCommon, Record<string, never>>(path, body, null, { method: 'PATCH' });
92
+ }
93
+
94
+ export async function starJob(jobId: number, star: boolean): Promise<Record<string, never>> {
95
+ const path = `/v1/jobs/${jobId}`;
96
+ const body = { star };
97
+
98
+ return request<ApiCommon, Record<string, never>>(path, body, null, { method: 'PATCH' });
99
+ }
100
+
101
+ export async function generateJobShare(
102
+ jobId: number,
103
+ visibility: JobShareVisibility,
104
+ ): Promise<JobShare> {
105
+ const path = `/v1/jobs/${jobId}/share`;
106
+ const body = { visibility };
107
+
108
+ return request<ApiJobShare, JobShare>(path, body);
109
+ }
110
+
111
+ export async function uploadJobPreview(
112
+ jobId: number,
113
+ preview: Blob,
114
+ ): Promise<Record<string, never>> {
115
+ const pathname = `/v1/jobs/${jobId}/preview`;
116
+ const path = `${pathname}?${deletedNoneParam}`;
117
+ const body = new FormData();
118
+
119
+ body.append('preview', preview);
120
+
121
+ return request<ApiCommon, Record<string, never>>(path, body);
122
+ }
123
+
124
+ export async function listFeaturedJobs(
125
+ title: string,
126
+ page: number,
127
+ options?: Record<string, unknown>,
128
+ ): Promise<JobSearchResult> {
129
+ return listJobs(`/v1/jobs/featured`, title, page, options);
130
+ }
@@ -1,95 +1,95 @@
1
- import {
2
- type ApiCommon,
3
- type ApiCommonData,
4
- type ApiError,
5
- type ApiSuccess,
6
- type Flatten,
7
- type Revivers,
8
- deletedNoneParam,
9
- lastJobRevision,
10
- request,
11
- } from '../utils.js';
12
-
13
- export type JobResult = {
14
- jobRevisionId: number;
15
- revision: number;
16
- status: string;
17
- };
18
-
19
- export type ApiJobResult = {
20
- data: {
21
- job_revision_id: number; // The id of the job revision
22
- revision: number; // The revision number of the job revision
23
- mapstyle_id: number; // The id of the map style
24
- interface_version: string; // The version of the interface (searchable, sortable)
25
- fix: string; //
26
- status: string; // The status of the job result (searchable, sortable)
27
- fail_reason: string; // A human-readable reason of why the map failed to process
28
- process_start: string; // The datetime when the job process started (searchable, sortable)
29
- process_end: string; // The datetime when the job process ended (searchable, sortable)
30
- dealt_with: boolean; // Checks if the Support fixed an issue (searchable, sortable)
31
- bought: boolean; // Checks if the result is bought or not (searchable, sortable)
32
- contract_id: number; // The id of the contract that was active when the map was created
33
- callback: string; // URL to another API which can finish a map (searchable, sortable)
34
- last_downloaded: string; // The last time the archive was downloaded (searchable, sortable)
35
- } & ApiCommonData;
36
- } & Omit<ApiSuccess, 'data'> | ApiError;
37
-
38
- export type ApiJobResultData = Flatten<Exclude<ApiJobResult, ApiError>['data']>;
39
-
40
- export const jobResultRevivers: Revivers<ApiJobResult, JobResult> = {
41
- mapstyle_id: undefined,
42
- interface_version: undefined,
43
- fix: undefined,
44
- fail_reason: undefined,
45
- process_start: undefined,
46
- process_end: undefined,
47
- dealt_with: undefined,
48
- bought: undefined,
49
- contract_id: undefined,
50
- callback: undefined,
51
- last_downloaded: undefined,
52
- };
53
-
54
- export async function uploadJobResultPreview(
55
- jobId: number,
56
- blob: Blob,
57
- ): Promise<Record<string, never>> {
58
- const pathname = `/v1/jobs/${jobId}/revisions/${lastJobRevision}/result/preview`;
59
- const path = `${pathname}?${deletedNoneParam}`;
60
- const body = new FormData();
61
-
62
- body.append('preview', blob);
63
-
64
- return request<ApiCommon, Record<string, never>>(path, body);
65
- }
66
-
67
- export type JobResultHostedImage = {
68
- url: string;
69
- message: string;
70
- };
71
-
72
- export type ApiJobResultHostedImage = {
73
- data: {
74
- url: string;
75
- message: string;
76
- } & ApiCommonData;
77
- } & Omit<ApiSuccess, 'data'> | ApiError;
78
-
79
- export type ApiJobResultHostedImageData = Flatten<Exclude<ApiJobResultHostedImage, ApiError>['data']>;
80
-
81
- export async function uploadJobResultHostedImage(
82
- jobId: number,
83
- blob: Blob,
84
- fileName: string,
85
- fileType: 'jpg' | 'png' | 'svg',
86
- ): Promise<JobResultHostedImage> {
87
- const pathname = `/v1/jobs/${jobId}/revisions/${lastJobRevision}/result/hosted-${fileType}`;
88
- const path = `${pathname}?${deletedNoneParam}`;
89
- const body = new FormData();
90
-
91
- body.append(fileType, blob);
92
- body.append('filename', fileName);
93
-
94
- return request<ApiJobResultHostedImage, JobResultHostedImage>(path, body);
95
- }
1
+ import {
2
+ type ApiCommon,
3
+ type ApiCommonData,
4
+ type ApiError,
5
+ type ApiSuccess,
6
+ type Flatten,
7
+ type Revivers,
8
+ deletedNoneParam,
9
+ lastJobRevision,
10
+ request,
11
+ } from '../utils.js';
12
+
13
+ export type JobResult = {
14
+ jobRevisionId: number;
15
+ revision: number;
16
+ status: string;
17
+ };
18
+
19
+ export type ApiJobResult = {
20
+ data: {
21
+ job_revision_id: number; // The id of the job revision
22
+ revision: number; // The revision number of the job revision
23
+ mapstyle_id: number; // The id of the map style
24
+ interface_version: string; // The version of the interface (searchable, sortable)
25
+ fix: string; //
26
+ status: string; // The status of the job result (searchable, sortable)
27
+ fail_reason: string; // A human-readable reason of why the map failed to process
28
+ process_start: string; // The datetime when the job process started (searchable, sortable)
29
+ process_end: string; // The datetime when the job process ended (searchable, sortable)
30
+ dealt_with: boolean; // Checks if the Support fixed an issue (searchable, sortable)
31
+ bought: boolean; // Checks if the result is bought or not (searchable, sortable)
32
+ subscription_id: number; // The id of the subscription that was active when the map was created
33
+ callback: string; // URL to another API which can finish a map (searchable, sortable)
34
+ last_downloaded: string; // The last time the archive was downloaded (searchable, sortable)
35
+ } & ApiCommonData;
36
+ } & Omit<ApiSuccess, 'data'> | ApiError;
37
+
38
+ export type ApiJobResultData = Flatten<Exclude<ApiJobResult, ApiError>['data']>;
39
+
40
+ export const jobResultRevivers: Revivers<ApiJobResult, JobResult> = {
41
+ mapstyle_id: undefined,
42
+ interface_version: undefined,
43
+ fix: undefined,
44
+ fail_reason: undefined,
45
+ process_start: undefined,
46
+ process_end: undefined,
47
+ dealt_with: undefined,
48
+ bought: undefined,
49
+ subscription_id: undefined,
50
+ callback: undefined,
51
+ last_downloaded: undefined,
52
+ };
53
+
54
+ export async function uploadJobResultPreview(
55
+ jobId: number,
56
+ blob: Blob,
57
+ ): Promise<Record<string, never>> {
58
+ const pathname = `/v1/jobs/${jobId}/revisions/${lastJobRevision}/result/preview`;
59
+ const path = `${pathname}?${deletedNoneParam}`;
60
+ const body = new FormData();
61
+
62
+ body.append('preview', blob);
63
+
64
+ return request<ApiCommon, Record<string, never>>(path, body);
65
+ }
66
+
67
+ export type JobResultHostedImage = {
68
+ url: string;
69
+ message: string;
70
+ };
71
+
72
+ export type ApiJobResultHostedImage = {
73
+ data: {
74
+ url: string;
75
+ message: string;
76
+ } & ApiCommonData;
77
+ } & Omit<ApiSuccess, 'data'> | ApiError;
78
+
79
+ export type ApiJobResultHostedImageData = Flatten<Exclude<ApiJobResultHostedImage, ApiError>['data']>;
80
+
81
+ export async function uploadJobResultHostedImage(
82
+ jobId: number,
83
+ blob: Blob,
84
+ fileName: string,
85
+ fileType: 'jpg' | 'png' | 'svg',
86
+ ): Promise<JobResultHostedImage> {
87
+ const pathname = `/v1/jobs/${jobId}/revisions/${lastJobRevision}/result/hosted-${fileType}`;
88
+ const path = `${pathname}?${deletedNoneParam}`;
89
+ const body = new FormData();
90
+
91
+ body.append(fileType, blob);
92
+ body.append('filename', fileName);
93
+
94
+ return request<ApiJobResultHostedImage, JobResultHostedImage>(path, body);
95
+ }