@mapcreator/api 0.0.0-saga.2 → 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/jobRevision.ts
CHANGED
|
@@ -1,278 +1,279 @@
|
|
|
1
|
-
import { type ApiLayerData, type Layer, layerRevivers } from './layer.js';
|
|
2
|
-
import { apiHost, authenticate, token } from '../oauth.js';
|
|
3
|
-
import type { ApiMapstyleSetData } from './mapstyleSet.js';
|
|
4
|
-
import type { ApiLanguageData } from './language.js';
|
|
5
|
-
import {
|
|
6
|
-
APIError,
|
|
7
|
-
type ApiCommon,
|
|
8
|
-
type ApiCommonData,
|
|
9
|
-
type ApiError,
|
|
10
|
-
type ApiSuccess,
|
|
11
|
-
type Flatten,
|
|
12
|
-
HTTPError,
|
|
13
|
-
NetworkError,
|
|
14
|
-
type Revivers,
|
|
15
|
-
defaultListHeader,
|
|
16
|
-
deletedNoneParam,
|
|
17
|
-
lastJobRevision,
|
|
18
|
-
request,
|
|
19
|
-
} from '../utils.js';
|
|
20
|
-
|
|
21
|
-
export type FileFormat =
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
} &
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
} &
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
} &
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const
|
|
162
|
-
const
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
case
|
|
259
|
-
case
|
|
260
|
-
case
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
1
|
+
import { type ApiLayerData, type Layer, layerRevivers } from './layer.js';
|
|
2
|
+
import { apiHost, authenticate, token } from '../oauth.js';
|
|
3
|
+
import type { ApiMapstyleSetData } from './mapstyleSet.js';
|
|
4
|
+
import type { ApiLanguageData } from './language.js';
|
|
5
|
+
import {
|
|
6
|
+
APIError,
|
|
7
|
+
type ApiCommon,
|
|
8
|
+
type ApiCommonData,
|
|
9
|
+
type ApiError,
|
|
10
|
+
type ApiSuccess,
|
|
11
|
+
type Flatten,
|
|
12
|
+
HTTPError,
|
|
13
|
+
NetworkError,
|
|
14
|
+
type Revivers,
|
|
15
|
+
defaultListHeader,
|
|
16
|
+
deletedNoneParam,
|
|
17
|
+
lastJobRevision,
|
|
18
|
+
request,
|
|
19
|
+
} from '../utils.js';
|
|
20
|
+
|
|
21
|
+
export type FileFormat =
|
|
22
|
+
| 'jpg'
|
|
23
|
+
| 'png'
|
|
24
|
+
| 'svg'
|
|
25
|
+
| 'pdf'
|
|
26
|
+
| 'tiff'
|
|
27
|
+
| 'eps'
|
|
28
|
+
| 'eps_log'
|
|
29
|
+
| 'mp4'
|
|
30
|
+
| 'mov'
|
|
31
|
+
| 'mkv'
|
|
32
|
+
| 'mxf'
|
|
33
|
+
| 'webm'
|
|
34
|
+
| 'jpg_sequence'
|
|
35
|
+
| 'png_sequence'
|
|
36
|
+
| 'web'
|
|
37
|
+
| 'web_download';
|
|
38
|
+
|
|
39
|
+
export type JobRevision = {
|
|
40
|
+
id: number;
|
|
41
|
+
jobId: number;
|
|
42
|
+
revision: number;
|
|
43
|
+
languageCode: string;
|
|
44
|
+
mapstyleSetId: number;
|
|
45
|
+
output: FileFormat;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type ApiJobRevision = {
|
|
49
|
+
data: {
|
|
50
|
+
id: number; // The id of the job revision (sortable)
|
|
51
|
+
job_id: number; // The id of the job related to this revision (searchable, sortable)
|
|
52
|
+
revision: number; // The revision number (searchable, sortable)
|
|
53
|
+
language_code: string; // The language code of the revision (searchable, sortable)
|
|
54
|
+
mapstyle_set_id: number; // The id of the mapstyle set
|
|
55
|
+
archived: boolean; // Whether the revision has been generated (searchable, sortable)
|
|
56
|
+
output: FileFormat; // The output file type
|
|
57
|
+
} & ApiCommonData;
|
|
58
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
59
|
+
|
|
60
|
+
export type ApiJobRevisionData = Flatten<Exclude<ApiJobRevision, ApiError>['data']>;
|
|
61
|
+
|
|
62
|
+
export const jobRevisionRevivers: Revivers<ApiJobRevision, JobRevision> = {
|
|
63
|
+
archived: undefined,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export async function createJobRevision(
|
|
67
|
+
jobId: number,
|
|
68
|
+
languageCode: string,
|
|
69
|
+
mapstyleSetId: number,
|
|
70
|
+
layers: number[],
|
|
71
|
+
output: FileFormat,
|
|
72
|
+
jobObject: Record<string, unknown>,
|
|
73
|
+
): Promise<JobRevision> {
|
|
74
|
+
const pathname = `/v1/jobs/${jobId}/revisions`;
|
|
75
|
+
const path = `${pathname}?${deletedNoneParam}`;
|
|
76
|
+
const body = {
|
|
77
|
+
language_code: languageCode,
|
|
78
|
+
mapstyle_set_id: mapstyleSetId,
|
|
79
|
+
object: JSON.stringify(jobObject),
|
|
80
|
+
output,
|
|
81
|
+
layers,
|
|
82
|
+
};
|
|
83
|
+
const options = { revivers: jobRevisionRevivers };
|
|
84
|
+
|
|
85
|
+
return request<ApiJobRevision, JobRevision>(path, body, null, options);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export async function getJobRevision(jobId: number): Promise<JobRevision | undefined> {
|
|
89
|
+
const path = `/v1/jobs/${jobId}/revisions/${lastJobRevision}`;
|
|
90
|
+
const options = { revivers: jobRevisionRevivers };
|
|
91
|
+
|
|
92
|
+
return request<ApiJobRevision, JobRevision>(path, null, null, options).catch(() => undefined);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export async function getJobRevisionObject<JobObject>(jobId: number): Promise<JobObject> {
|
|
96
|
+
const pathname = `/v1/jobs/${jobId}/revisions/${lastJobRevision}/object`;
|
|
97
|
+
const path = `${pathname}?${deletedNoneParam}`;
|
|
98
|
+
|
|
99
|
+
return request<ApiCommon, string>(path).then(JSON.parse) as Promise<JobObject>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export type JobCanBuild = {
|
|
103
|
+
canBuild: boolean;
|
|
104
|
+
paymentSource: string;
|
|
105
|
+
reason: string | null;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export type ApiJobCanBuild = {
|
|
109
|
+
data: {
|
|
110
|
+
can_build: boolean;
|
|
111
|
+
payment_source: string;
|
|
112
|
+
reason: string | null;
|
|
113
|
+
} & ApiCommonData;
|
|
114
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
115
|
+
|
|
116
|
+
// Also known as `canBuild()`
|
|
117
|
+
export async function getJobRevisionBuild(jobId: number): Promise<JobCanBuild> {
|
|
118
|
+
const pathname = `/v1/jobs/${jobId}/revisions/${lastJobRevision}/build`;
|
|
119
|
+
const path = `${pathname}?${deletedNoneParam}`;
|
|
120
|
+
|
|
121
|
+
return request<ApiJobCanBuild, JobCanBuild>(path);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export type JobRevisionBuild = {
|
|
125
|
+
jobRevisionId: number;
|
|
126
|
+
revision: number;
|
|
127
|
+
status: string;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export type ApiJobRevisionBuild = {
|
|
131
|
+
data: {
|
|
132
|
+
job_revision_id: number; // The id of the job revision
|
|
133
|
+
status: string; // The status of the job result (searchable, sortable)
|
|
134
|
+
subscription_id: number; // The id of the subscription that was active when the map was created
|
|
135
|
+
process_start: string; // The datetime when the job process started (searchable, sortable)
|
|
136
|
+
process_end: string; // The datetime when the job process ended (searchable, sortable)
|
|
137
|
+
last_downloaded: string; // The last time the archive was downloaded (searchable, sortable)
|
|
138
|
+
bought: boolean; // Checks if the result is bought or not (searchable, sortable)
|
|
139
|
+
revision: number; // The revision number of the job revision
|
|
140
|
+
job_revision: ApiJobRevisionData;
|
|
141
|
+
} & ApiCommonData;
|
|
142
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
143
|
+
|
|
144
|
+
export type ApiJobRevisionBuildData = Flatten<Exclude<ApiJobRevisionBuild, ApiError>['data']>;
|
|
145
|
+
|
|
146
|
+
export const jobRevisionBuildRevivers: Revivers<ApiJobRevisionBuild, JobRevisionBuild> = {
|
|
147
|
+
subscription_id: undefined,
|
|
148
|
+
process_start: undefined,
|
|
149
|
+
process_end: undefined,
|
|
150
|
+
last_downloaded: undefined,
|
|
151
|
+
bought: undefined,
|
|
152
|
+
job_revision: undefined,
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export async function registerJobRevisionBuild(
|
|
156
|
+
jobId: number,
|
|
157
|
+
status: string,
|
|
158
|
+
start: Date,
|
|
159
|
+
end: Date,
|
|
160
|
+
): Promise<JobRevisionBuild> {
|
|
161
|
+
const pathname = `/v1/jobs/${jobId}/revisions/${lastJobRevision}/build/register`;
|
|
162
|
+
const path = `${pathname}?${deletedNoneParam}`;
|
|
163
|
+
const body = { status, process_start: start, process_end: end };
|
|
164
|
+
const options = { revivers: jobRevisionBuildRevivers };
|
|
165
|
+
|
|
166
|
+
return request<ApiJobRevisionBuild, JobRevisionBuild>(path, body, null, options);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export async function cloneJobRevision(jobId: number, newTitle?: string): Promise<JobRevision> {
|
|
170
|
+
const pathname = `/v1/jobs/${jobId}/revisions/${lastJobRevision}/clone`;
|
|
171
|
+
const path = `${pathname}?${deletedNoneParam}`;
|
|
172
|
+
const body = { title: newTitle ?? null };
|
|
173
|
+
const options = {
|
|
174
|
+
revivers: {
|
|
175
|
+
...jobRevisionRevivers,
|
|
176
|
+
layers: undefined,
|
|
177
|
+
language: undefined,
|
|
178
|
+
mapstyle_set: undefined,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
type ApiJobRevisionWithData = {
|
|
183
|
+
data: ApiJobRevisionData & {
|
|
184
|
+
layers: ApiLayerData[];
|
|
185
|
+
language: ApiLanguageData;
|
|
186
|
+
mapstyle_set: ApiMapstyleSetData;
|
|
187
|
+
};
|
|
188
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
189
|
+
|
|
190
|
+
return request<ApiJobRevisionWithData, JobRevision>(path, body, null, options);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export async function listJobRevisionLayers(jobId: number): Promise<Layer[]> {
|
|
194
|
+
const path = `/v1/jobs/${jobId}/revisions/${lastJobRevision}/layers`;
|
|
195
|
+
const options = { revivers: layerRevivers };
|
|
196
|
+
|
|
197
|
+
type ApiLayerArray = {
|
|
198
|
+
data: ApiLayerData[];
|
|
199
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
200
|
+
|
|
201
|
+
return request<ApiLayerArray, Layer>(path, null, defaultListHeader, options);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export type JobRevisionOutputUrl = { url: string };
|
|
205
|
+
|
|
206
|
+
export type ApiJobRevisionOutputUrl = {
|
|
207
|
+
data: JobRevisionOutputUrl & ApiCommonData;
|
|
208
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
209
|
+
|
|
210
|
+
export async function getJobRevisionOutputUrl(jobId: number): Promise<JobRevisionOutputUrl> {
|
|
211
|
+
await createJobRevisionBuild(jobId);
|
|
212
|
+
|
|
213
|
+
const path = `/v1/jobs/${jobId}/revisions/${lastJobRevision}/result/output-url`;
|
|
214
|
+
|
|
215
|
+
return request<ApiJobRevisionOutputUrl, JobRevisionOutputUrl>(path);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export type JobRevisionOutput = { blob: Blob; filename?: string | undefined };
|
|
219
|
+
|
|
220
|
+
export async function getJobRevisionOutput(jobId: number): Promise<JobRevisionOutput> {
|
|
221
|
+
await createJobRevisionBuild(jobId);
|
|
222
|
+
|
|
223
|
+
const href = `${apiHost}/v1/jobs/${jobId}/revisions/${lastJobRevision}/result/output`;
|
|
224
|
+
const headers = { ...(token ? { Authorization: token.toString() } : null) };
|
|
225
|
+
const response = await fetch(href, { headers }).catch((error: Error) => {
|
|
226
|
+
throw new NetworkError(error?.message ?? error);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
if (response.ok) {
|
|
230
|
+
const blob = await response.blob().catch(() => {
|
|
231
|
+
throw new APIError({ success: false, error: { type: 'TypeError', message: 'Malformed Blob response' } });
|
|
232
|
+
});
|
|
233
|
+
const contentDisposition = response.headers.get('Content-Disposition');
|
|
234
|
+
|
|
235
|
+
if (contentDisposition) {
|
|
236
|
+
const filenameRegex = /filename\*\s*=\s*UTF-8''(.+)/i;
|
|
237
|
+
const filenameMatch = contentDisposition.match(filenameRegex);
|
|
238
|
+
|
|
239
|
+
if (filenameMatch?.[1]) {
|
|
240
|
+
return { blob, filename: filenameMatch[1] };
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const fallbackRegex = /filename\s*=\s*"([^"]+)"/i;
|
|
244
|
+
const fallbackMatch = contentDisposition.match(fallbackRegex);
|
|
245
|
+
|
|
246
|
+
if (fallbackMatch?.[1]) {
|
|
247
|
+
return { blob, filename: fallbackMatch[1] };
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return { blob };
|
|
252
|
+
} else {
|
|
253
|
+
// eslint-disable-next-line default-case
|
|
254
|
+
switch (response.status) {
|
|
255
|
+
case 401:
|
|
256
|
+
await authenticate();
|
|
257
|
+
break; // NO-OP
|
|
258
|
+
case 403:
|
|
259
|
+
case 404:
|
|
260
|
+
case 406:
|
|
261
|
+
case 429:
|
|
262
|
+
throw new APIError(
|
|
263
|
+
(await response.json().catch(() => ({
|
|
264
|
+
success: false,
|
|
265
|
+
error: { type: 'HttpException', message: response.statusText },
|
|
266
|
+
}))) as ApiError,
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
throw new HTTPError(response);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
async function createJobRevisionBuild(jobId: number): Promise<string> {
|
|
275
|
+
const pathname = `/v1/jobs/${jobId}/revisions/${lastJobRevision}/build`;
|
|
276
|
+
const path = `${pathname}?${deletedNoneParam}`;
|
|
277
|
+
|
|
278
|
+
return request<ApiCommon, string>(path, null, null, { method: 'POST' });
|
|
279
|
+
}
|
package/src/api/jobShare.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { type ApiCommon, type ApiCommonData, type ApiError, type ApiSuccess, type Flatten, request } from '../utils.js';
|
|
2
|
-
|
|
3
|
-
export type JobShareVisibility = 'private' | 'organisation' | 'public';
|
|
4
|
-
|
|
5
|
-
export type JobShare = {
|
|
6
|
-
id: number;
|
|
7
|
-
jobId: number;
|
|
8
|
-
visibility: JobShareVisibility;
|
|
9
|
-
hashKey: string;
|
|
10
|
-
apiUrl: string;
|
|
11
|
-
webUrl: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export type ApiJobShare = {
|
|
15
|
-
data: {
|
|
16
|
-
id: number; // The id of the job share (sortable)
|
|
17
|
-
job_id: number; // The id of the job related to this share
|
|
18
|
-
visibility: string; // The visibility of the job share (searchable, sortable)
|
|
19
|
-
hash_key: string; // The hash key of the job share
|
|
20
|
-
apiUrl: string; // TODO: not present in API specification!
|
|
21
|
-
webUrl: string; // TODO: not present in API specification!
|
|
22
|
-
} & ApiCommonData;
|
|
23
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
24
|
-
|
|
25
|
-
export type ApiJobShareData = Flatten<Exclude<ApiJobShare, ApiError>['data']>;
|
|
26
|
-
|
|
27
|
-
export type ApiJobShareArray = {
|
|
28
|
-
data: ApiJobShareData[];
|
|
29
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
30
|
-
|
|
31
|
-
export async function deleteJobShare(jobShareId: number): Promise<Record<string, never>> {
|
|
32
|
-
const path = `/v1/jobs/shares/${jobShareId}`;
|
|
33
|
-
|
|
34
|
-
return request<ApiCommon, Record<string, never>>(path, null, null, { method: 'DELETE' });
|
|
35
|
-
}
|
|
1
|
+
import { type ApiCommon, type ApiCommonData, type ApiError, type ApiSuccess, type Flatten, request } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
export type JobShareVisibility = 'private' | 'organisation' | 'public';
|
|
4
|
+
|
|
5
|
+
export type JobShare = {
|
|
6
|
+
id: number;
|
|
7
|
+
jobId: number;
|
|
8
|
+
visibility: JobShareVisibility;
|
|
9
|
+
hashKey: string;
|
|
10
|
+
apiUrl: string;
|
|
11
|
+
webUrl: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type ApiJobShare = {
|
|
15
|
+
data: {
|
|
16
|
+
id: number; // The id of the job share (sortable)
|
|
17
|
+
job_id: number; // The id of the job related to this share
|
|
18
|
+
visibility: string; // The visibility of the job share (searchable, sortable)
|
|
19
|
+
hash_key: string; // The hash key of the job share
|
|
20
|
+
apiUrl: string; // TODO: not present in API specification!
|
|
21
|
+
webUrl: string; // TODO: not present in API specification!
|
|
22
|
+
} & ApiCommonData;
|
|
23
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
24
|
+
|
|
25
|
+
export type ApiJobShareData = Flatten<Exclude<ApiJobShare, ApiError>['data']>;
|
|
26
|
+
|
|
27
|
+
export type ApiJobShareArray = {
|
|
28
|
+
data: ApiJobShareData[];
|
|
29
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
30
|
+
|
|
31
|
+
export async function deleteJobShare(jobShareId: number): Promise<Record<string, never>> {
|
|
32
|
+
const path = `/v1/jobs/shares/${jobShareId}`;
|
|
33
|
+
|
|
34
|
+
return request<ApiCommon, Record<string, never>>(path, null, null, { method: 'DELETE' });
|
|
35
|
+
}
|