@inweb/client 25.3.17 → 25.3.18
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/dist/client.js +698 -527
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +1 -1
- package/dist/client.module.js +473 -484
- package/dist/client.module.js.map +1 -1
- package/lib/Api/Assembly.d.ts +32 -8
- package/lib/Api/ClashTest.d.ts +1 -1
- package/lib/Api/Client.d.ts +2 -3
- package/lib/Api/Fetch.d.ts +6 -0
- package/lib/Api/{impl/FetchError.d.ts → FetchError.d.ts} +2 -0
- package/lib/Api/File.d.ts +34 -10
- package/lib/Api/HttpClient.d.ts +9 -3
- package/lib/Api/IHttpClient.d.ts +10 -4
- package/lib/Api/Job.d.ts +1 -1
- package/lib/Api/Model.d.ts +33 -9
- package/lib/Api/Project.d.ts +3 -3
- package/lib/Api/User.d.ts +1 -1
- package/lib/Api/Utils.d.ts +11 -0
- package/lib/Api/XMLHttp.d.ts +7 -0
- package/lib/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/Api/Assembly.ts +76 -70
- package/src/Api/ClashTest.ts +10 -19
- package/src/Api/Client.ts +92 -56
- package/src/Api/Fetch.ts +84 -0
- package/src/Api/{impl/http.ts → FetchError.ts} +33 -1
- package/src/Api/File.ts +112 -117
- package/src/Api/HttpClient.ts +107 -20
- package/src/Api/IHttpClient.ts +17 -12
- package/src/Api/Job.ts +7 -5
- package/src/Api/Member.ts +7 -5
- package/src/Api/Model.ts +61 -14
- package/src/Api/Permission.ts +6 -5
- package/src/Api/Project.ts +93 -88
- package/src/Api/Role.ts +6 -5
- package/src/Api/User.ts +28 -17
- package/src/Api/Utils.ts +104 -0
- package/src/Api/XMLHttp.ts +72 -0
- package/src/index.ts +1 -1
- package/lib/Api/impl/Utils.d.ts +0 -32
- package/lib/Api/impl/http.d.ts +0 -66
- package/src/Api/impl/FetchError.ts +0 -48
- package/src/Api/impl/Utils.ts +0 -367
package/dist/client.module.js
CHANGED
|
@@ -75,254 +75,38 @@ class Model {
|
|
|
75
75
|
downloadResource(dataId, onProgress, signal) {
|
|
76
76
|
return this._file.downloadResource(dataId, onProgress, signal);
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
return this._file.
|
|
80
|
-
}
|
|
81
|
-
downloadFileRange(requestId, records, dataId, onProgress, signal) {
|
|
82
|
-
return this._file.downloadFileRange(requestId, records, dataId, onProgress, signal);
|
|
83
|
-
}
|
|
84
|
-
getReferences(signal) {
|
|
85
|
-
return this._file.getReferences(signal);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const STATUS_CODES = {
|
|
90
|
-
100: "Continue",
|
|
91
|
-
101: "Switching Protocols",
|
|
92
|
-
102: "Processing",
|
|
93
|
-
103: "Early Hints",
|
|
94
|
-
200: "OK",
|
|
95
|
-
201: "Created",
|
|
96
|
-
202: "Accepted",
|
|
97
|
-
203: "Non-Authoritative Information",
|
|
98
|
-
204: "No Content",
|
|
99
|
-
205: "Reset Content",
|
|
100
|
-
206: "Partial Content",
|
|
101
|
-
207: "Multi-Status",
|
|
102
|
-
208: "Already Reported",
|
|
103
|
-
226: "IM Used",
|
|
104
|
-
300: "Multiple Choices",
|
|
105
|
-
301: "Moved Permanently",
|
|
106
|
-
302: "Found",
|
|
107
|
-
303: "See Other",
|
|
108
|
-
304: "Not Modified",
|
|
109
|
-
305: "Use Proxy",
|
|
110
|
-
307: "Temporary Redirect",
|
|
111
|
-
308: "Permanent Redirect",
|
|
112
|
-
400: "Bad Request",
|
|
113
|
-
401: "Unauthorized",
|
|
114
|
-
402: "Payment Required",
|
|
115
|
-
403: "Forbidden",
|
|
116
|
-
404: "Not Found",
|
|
117
|
-
405: "Method Not Allowed",
|
|
118
|
-
406: "Not Acceptable",
|
|
119
|
-
407: "Proxy Authentication Required",
|
|
120
|
-
408: "Request Time-out",
|
|
121
|
-
409: "Conflict",
|
|
122
|
-
410: "Gone",
|
|
123
|
-
411: "Length Required",
|
|
124
|
-
412: "Precondition Failed",
|
|
125
|
-
413: "Payload Too Large",
|
|
126
|
-
414: "URI Too Long",
|
|
127
|
-
415: "Unsupported Media Type",
|
|
128
|
-
416: "Range Not Satisfiable",
|
|
129
|
-
417: "Expectation Failed",
|
|
130
|
-
418: "I'm a teapot",
|
|
131
|
-
421: "Misdirected Request",
|
|
132
|
-
422: "Unprocessable Entity",
|
|
133
|
-
423: "Locked",
|
|
134
|
-
424: "Failed Dependency",
|
|
135
|
-
425: "Too Early",
|
|
136
|
-
426: "Upgrade Required",
|
|
137
|
-
428: "Precondition Required",
|
|
138
|
-
429: "Too Many Requests",
|
|
139
|
-
431: "Header Fields Too Large",
|
|
140
|
-
451: "Unavailable For Legal Reasons",
|
|
141
|
-
500: "Internal Server Error",
|
|
142
|
-
501: "Not Implemented",
|
|
143
|
-
502: "Bad Gateway",
|
|
144
|
-
503: "Service Unavailable",
|
|
145
|
-
504: "Gateway Timeout",
|
|
146
|
-
505: "HTTP Version Not Supported",
|
|
147
|
-
506: "Variant Also Negotiates",
|
|
148
|
-
507: "Insufficient Storage",
|
|
149
|
-
508: "Loop Detected",
|
|
150
|
-
509: "Bandwidth Limit Exceeded",
|
|
151
|
-
510: "Not Extended",
|
|
152
|
-
511: "Network Authentication Required"
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
function statusText(status) {
|
|
156
|
-
return STATUS_CODES[status] || `Error ${status}`;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
class FetchError extends Error {
|
|
160
|
-
constructor(status, message) {
|
|
161
|
-
super(message || statusText(status));
|
|
162
|
-
this.status = status;
|
|
163
|
-
this.statusText = statusText(status);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function json(request) {
|
|
168
|
-
return request.then((response => response.json()));
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function text(request) {
|
|
172
|
-
return request.then((response => response.text()));
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function error400(text, _default = "400") {
|
|
176
|
-
try {
|
|
177
|
-
return JSON.parse(text).description;
|
|
178
|
-
} catch {
|
|
179
|
-
return _default;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function handleXMLHttpError(xhr) {
|
|
184
|
-
if (xhr.status === 0) {
|
|
185
|
-
return Promise.reject(new FetchError(0, "Network error"));
|
|
186
|
-
}
|
|
187
|
-
if (xhr.status < 200 || xhr.status > 299) {
|
|
188
|
-
switch (xhr.status) {
|
|
189
|
-
case 400:
|
|
190
|
-
{
|
|
191
|
-
console.error(xhr.responseText);
|
|
192
|
-
return Promise.reject(new FetchError(400, error400(xhr.responseText)));
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
case 500:
|
|
196
|
-
{
|
|
197
|
-
console.error(error400(xhr.responseText, xhr.responseText));
|
|
198
|
-
return Promise.reject(new FetchError(500));
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
default:
|
|
202
|
-
{
|
|
203
|
-
return Promise.reject(new FetchError(xhr.status));
|
|
204
|
-
}
|
|
205
|
-
}
|
|
78
|
+
downloadResourceRange(dataId, ranges, requestId, onProgress, signal) {
|
|
79
|
+
return this._file.downloadResourceRange(dataId, ranges, requestId, onProgress, signal);
|
|
206
80
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
81
|
+
partialDownloadResource(dataId, onProgress, signal) {
|
|
82
|
+
console.warn("Model.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use Model.downloadResource() instead.");
|
|
83
|
+
return this.downloadResource(dataId, onProgress, signal);
|
|
84
|
+
}
|
|
85
|
+
async downloadFileRange(requestId, records, dataId, onProgress, signal) {
|
|
86
|
+
if (!records) return;
|
|
87
|
+
let ranges = [];
|
|
88
|
+
if (records.length) {
|
|
89
|
+
ranges = records.map((record => ({
|
|
90
|
+
begin: Number(record.begin),
|
|
91
|
+
end: Number(record.end),
|
|
92
|
+
requestId: record.reqId
|
|
93
|
+
})));
|
|
94
|
+
} else {
|
|
95
|
+
for (let i = 0; i < records.size(); i++) {
|
|
96
|
+
const record = records.get(i);
|
|
97
|
+
ranges.push({
|
|
98
|
+
begin: Number(record.begin),
|
|
99
|
+
end: Number(record.end),
|
|
100
|
+
requestId: requestId
|
|
101
|
+
});
|
|
102
|
+
record.delete();
|
|
227
103
|
}
|
|
228
|
-
|
|
229
|
-
default:
|
|
230
|
-
return Promise.reject(new FetchError(response.status, statusText(response.status)));
|
|
231
104
|
}
|
|
105
|
+
await this.downloadResourceRange(dataId, ranges, requestId, onProgress, signal);
|
|
232
106
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
function $init(method, headers, body, signal) {
|
|
237
|
-
headers = {
|
|
238
|
-
...headers
|
|
239
|
-
};
|
|
240
|
-
headers["Content-Type"] = "application/json";
|
|
241
|
-
if (method === "POST" || method === "PUT") {
|
|
242
|
-
if (body instanceof FormData) {
|
|
243
|
-
delete headers["Content-Type"];
|
|
244
|
-
} else if (body instanceof File || body instanceof Blob) {
|
|
245
|
-
const formData = new FormData;
|
|
246
|
-
formData.append("file", body);
|
|
247
|
-
return $init(method, headers, formData, signal);
|
|
248
|
-
} else if (body instanceof ArrayBuffer) {
|
|
249
|
-
const blob = new Blob([ body ]);
|
|
250
|
-
return $init(method, headers, blob, signal);
|
|
251
|
-
} else if (body && typeof body === "object") {
|
|
252
|
-
body = JSON.stringify(body);
|
|
253
|
-
} else if (typeof body === "string") {
|
|
254
|
-
headers["Content-Type"] = "text/plain";
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
const result = {
|
|
258
|
-
method: method,
|
|
259
|
-
headers: headers
|
|
260
|
-
};
|
|
261
|
-
if (body && (body instanceof ArrayBuffer || body instanceof Blob || body instanceof globalThis.File || body instanceof FormData || typeof body === "string")) {
|
|
262
|
-
result.body = body;
|
|
263
|
-
}
|
|
264
|
-
if (signal) result.signal = signal;
|
|
265
|
-
return result;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function $fetch(url, init) {
|
|
269
|
-
return fetch(url, init).then((response => handleFetchError(response)));
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function $get(url, headers, signal) {
|
|
273
|
-
return $fetch(url, $init("GET", headers, null, signal));
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
function $put(url, headers, body) {
|
|
277
|
-
return $fetch(url, $init("PUT", headers, body));
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
function $post(url, headers, body) {
|
|
281
|
-
return $fetch(url, $init("POST", headers, body));
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function $delete(url, headers) {
|
|
285
|
-
return $fetch(url, $init("DELETE", headers));
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
function streamProgress(stream, onprogress) {
|
|
289
|
-
const reader = stream.getReader();
|
|
290
|
-
let current = 0;
|
|
291
|
-
function calc(ev) {
|
|
292
|
-
if (!ev.done) {
|
|
293
|
-
reader.read().then(calc).catch(console.error);
|
|
294
|
-
}
|
|
295
|
-
if (ev.value) current += ev.value.length;
|
|
296
|
-
onprogress(current);
|
|
107
|
+
getReferences(signal) {
|
|
108
|
+
return this._file.getReferences(signal);
|
|
297
109
|
}
|
|
298
|
-
reader.read().then(calc).catch(console.error);
|
|
299
|
-
return stream;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
function downloadProgress(response, onprogress) {
|
|
303
|
-
var _a;
|
|
304
|
-
const contentLength = (_a = response.headers.get("Content-Length")) !== null && _a !== void 0 ? _a : "";
|
|
305
|
-
const total = parseInt(contentLength, 10);
|
|
306
|
-
const tee = response.body.tee();
|
|
307
|
-
streamProgress(tee[0], (bytesCount => onprogress && onprogress(bytesCount / total)));
|
|
308
|
-
return new Response(tee[1]);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function $XMLHttp(url, {headers: headers, method: method, body: body, uploadProgress: uploadProgress, downloadProgress: downloadProgress}) {
|
|
312
|
-
return new Promise(((resolve, reject) => {
|
|
313
|
-
const xhr = new XMLHttpRequest;
|
|
314
|
-
xhr.open(method, url, true);
|
|
315
|
-
for (const key in headers) {
|
|
316
|
-
xhr.setRequestHeader(key, headers[key]);
|
|
317
|
-
}
|
|
318
|
-
function calcProgress(event) {
|
|
319
|
-
return event.lengthComputable ? event.loaded / event.total : 1;
|
|
320
|
-
}
|
|
321
|
-
xhr.upload.onprogress = event => uploadProgress && uploadProgress(calcProgress(event));
|
|
322
|
-
xhr.onprogress = event => downloadProgress && downloadProgress(calcProgress(event));
|
|
323
|
-
xhr.onloadend = event => handleXMLHttpError(event.target).then(resolve, reject);
|
|
324
|
-
xhr.send(body);
|
|
325
|
-
}));
|
|
326
110
|
}
|
|
327
111
|
|
|
328
112
|
function delay(ms, signal) {
|
|
@@ -358,69 +142,6 @@ async function waitFor(func, params = {}) {
|
|
|
358
142
|
return Promise.reject(timeoutError);
|
|
359
143
|
}
|
|
360
144
|
|
|
361
|
-
async function downloadPartOfFile(requestId, records, url, defHeaders, onProgress, signal) {
|
|
362
|
-
var _a;
|
|
363
|
-
const headers = {
|
|
364
|
-
...defHeaders
|
|
365
|
-
};
|
|
366
|
-
const isMultipleResourceParts = records && records.length;
|
|
367
|
-
if (records) {
|
|
368
|
-
const ranges = [];
|
|
369
|
-
if (isMultipleResourceParts) {
|
|
370
|
-
for (let i = 0; i < records.length; i++) {
|
|
371
|
-
const record = records[i];
|
|
372
|
-
ranges.push(`${record.begin}-${record.end}`);
|
|
373
|
-
}
|
|
374
|
-
} else {
|
|
375
|
-
for (let i = 0; i < records.size(); i++) {
|
|
376
|
-
const record = records.get(i);
|
|
377
|
-
ranges.push(`${record.begin}-${record.end}`);
|
|
378
|
-
record.delete();
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
headers["Range"] = "bytes=" + ranges.join(",");
|
|
382
|
-
}
|
|
383
|
-
const response = await $fetch(url, $init("GET", headers, null, signal));
|
|
384
|
-
const contentLength = (_a = response.headers.get("content-length")) !== null && _a !== void 0 ? _a : "";
|
|
385
|
-
const total = parseInt(contentLength, 10);
|
|
386
|
-
const reader = response.body.getReader();
|
|
387
|
-
if (isMultipleResourceParts) {
|
|
388
|
-
let curRecordIndex = 0;
|
|
389
|
-
let curRecordPos = 0;
|
|
390
|
-
while (true) {
|
|
391
|
-
const {done: done, value: value} = await reader.read();
|
|
392
|
-
if (done) break;
|
|
393
|
-
let totalLeft = value.byteLength;
|
|
394
|
-
let loadedPos = 0;
|
|
395
|
-
while (totalLeft > 0) {
|
|
396
|
-
const curRecord = records[curRecordIndex];
|
|
397
|
-
const recLeft = curRecord.size - curRecordPos;
|
|
398
|
-
if (totalLeft < recLeft) {
|
|
399
|
-
const buf = value.subarray(loadedPos, loadedPos + totalLeft);
|
|
400
|
-
if (typeof onProgress === "function") onProgress(loadedPos / total, buf, curRecord.reqId);
|
|
401
|
-
curRecordPos += totalLeft;
|
|
402
|
-
totalLeft = 0;
|
|
403
|
-
} else {
|
|
404
|
-
const buf = value.subarray(loadedPos, loadedPos + recLeft);
|
|
405
|
-
if (typeof onProgress === "function") onProgress(loadedPos / total, buf, curRecord.reqId);
|
|
406
|
-
curRecordIndex++;
|
|
407
|
-
curRecordPos = 0;
|
|
408
|
-
loadedPos += recLeft;
|
|
409
|
-
totalLeft -= recLeft;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
} else {
|
|
414
|
-
let loaded = 0;
|
|
415
|
-
while (true) {
|
|
416
|
-
const {done: done, value: value} = await reader.read();
|
|
417
|
-
if (done) break;
|
|
418
|
-
loaded += value.byteLength;
|
|
419
|
-
if (onProgress) onProgress(loaded / total, value, requestId);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
145
|
function parseArgs(args) {
|
|
425
146
|
if (typeof args === "string") {
|
|
426
147
|
const firstArg = args.indexOf("--");
|
|
@@ -510,17 +231,15 @@ class ClashTest {
|
|
|
510
231
|
get tolerance() {
|
|
511
232
|
return this.data.tolerance;
|
|
512
233
|
}
|
|
513
|
-
checkout() {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
}));
|
|
234
|
+
async checkout() {
|
|
235
|
+
const response = await this.internalGet("");
|
|
236
|
+
this.data = await response.json();
|
|
237
|
+
return this;
|
|
518
238
|
}
|
|
519
|
-
update(data) {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
}));
|
|
239
|
+
async update(data) {
|
|
240
|
+
const response = await this.internalPut("", data);
|
|
241
|
+
this.data = await response.json();
|
|
242
|
+
return this;
|
|
524
243
|
}
|
|
525
244
|
delete() {
|
|
526
245
|
return this.internalDelete("").then((response => response.json()));
|
|
@@ -537,6 +256,92 @@ class ClashTest {
|
|
|
537
256
|
}
|
|
538
257
|
}
|
|
539
258
|
|
|
259
|
+
const STATUS_CODES = {
|
|
260
|
+
100: "Continue",
|
|
261
|
+
101: "Switching Protocols",
|
|
262
|
+
102: "Processing",
|
|
263
|
+
103: "Early Hints",
|
|
264
|
+
200: "OK",
|
|
265
|
+
201: "Created",
|
|
266
|
+
202: "Accepted",
|
|
267
|
+
203: "Non-Authoritative Information",
|
|
268
|
+
204: "No Content",
|
|
269
|
+
205: "Reset Content",
|
|
270
|
+
206: "Partial Content",
|
|
271
|
+
207: "Multi-Status",
|
|
272
|
+
208: "Already Reported",
|
|
273
|
+
226: "IM Used",
|
|
274
|
+
300: "Multiple Choices",
|
|
275
|
+
301: "Moved Permanently",
|
|
276
|
+
302: "Found",
|
|
277
|
+
303: "See Other",
|
|
278
|
+
304: "Not Modified",
|
|
279
|
+
305: "Use Proxy",
|
|
280
|
+
307: "Temporary Redirect",
|
|
281
|
+
308: "Permanent Redirect",
|
|
282
|
+
400: "Bad Request",
|
|
283
|
+
401: "Unauthorized",
|
|
284
|
+
402: "Payment Required",
|
|
285
|
+
403: "Forbidden",
|
|
286
|
+
404: "Not Found",
|
|
287
|
+
405: "Method Not Allowed",
|
|
288
|
+
406: "Not Acceptable",
|
|
289
|
+
407: "Proxy Authentication Required",
|
|
290
|
+
408: "Request Time-out",
|
|
291
|
+
409: "Conflict",
|
|
292
|
+
410: "Gone",
|
|
293
|
+
411: "Length Required",
|
|
294
|
+
412: "Precondition Failed",
|
|
295
|
+
413: "Payload Too Large",
|
|
296
|
+
414: "URI Too Long",
|
|
297
|
+
415: "Unsupported Media Type",
|
|
298
|
+
416: "Range Not Satisfiable",
|
|
299
|
+
417: "Expectation Failed",
|
|
300
|
+
418: "I'm a teapot",
|
|
301
|
+
421: "Misdirected Request",
|
|
302
|
+
422: "Unprocessable Entity",
|
|
303
|
+
423: "Locked",
|
|
304
|
+
424: "Failed Dependency",
|
|
305
|
+
425: "Too Early",
|
|
306
|
+
426: "Upgrade Required",
|
|
307
|
+
428: "Precondition Required",
|
|
308
|
+
429: "Too Many Requests",
|
|
309
|
+
431: "Header Fields Too Large",
|
|
310
|
+
451: "Unavailable For Legal Reasons",
|
|
311
|
+
500: "Internal Server Error",
|
|
312
|
+
501: "Not Implemented",
|
|
313
|
+
502: "Bad Gateway",
|
|
314
|
+
503: "Service Unavailable",
|
|
315
|
+
504: "Gateway Timeout",
|
|
316
|
+
505: "HTTP Version Not Supported",
|
|
317
|
+
506: "Variant Also Negotiates",
|
|
318
|
+
507: "Insufficient Storage",
|
|
319
|
+
508: "Loop Detected",
|
|
320
|
+
509: "Bandwidth Limit Exceeded",
|
|
321
|
+
510: "Not Extended",
|
|
322
|
+
511: "Network Authentication Required"
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
function statusText(status) {
|
|
326
|
+
return STATUS_CODES[status] || `Error ${status}`;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function error400(text, _default = "400") {
|
|
330
|
+
try {
|
|
331
|
+
return JSON.parse(text).description;
|
|
332
|
+
} catch {
|
|
333
|
+
return _default;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
class FetchError extends Error {
|
|
338
|
+
constructor(status, message) {
|
|
339
|
+
super(message || statusText(status));
|
|
340
|
+
this.status = status;
|
|
341
|
+
this.statusText = statusText(status);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
540
345
|
class Assembly {
|
|
541
346
|
constructor(data, httpClient) {
|
|
542
347
|
this.path = `/assemblies/${data.id}`;
|
|
@@ -564,30 +369,6 @@ class Assembly {
|
|
|
564
369
|
relativePath = this.appendVersionParam(relativePath);
|
|
565
370
|
return this.httpClient.delete(`${this.path}${relativePath}`);
|
|
566
371
|
}
|
|
567
|
-
async partialDownloadResource(dataId, onProgress, signal) {
|
|
568
|
-
var _a;
|
|
569
|
-
let pathname = `${this.path}/downloads/${dataId}`;
|
|
570
|
-
pathname = this.appendVersionParam(pathname);
|
|
571
|
-
const response = await fetch(`${this.httpClient.serverUrl}${pathname}`, {
|
|
572
|
-
headers: this.httpClient.headers,
|
|
573
|
-
signal: signal
|
|
574
|
-
});
|
|
575
|
-
const contentLength = (_a = response.headers.get("Content-Length")) !== null && _a !== void 0 ? _a : "";
|
|
576
|
-
const total = parseInt(contentLength, 10);
|
|
577
|
-
const reader = response.body.getReader();
|
|
578
|
-
let loaded = 0;
|
|
579
|
-
while (true) {
|
|
580
|
-
const {done: done, value: value} = await reader.read();
|
|
581
|
-
if (done) break;
|
|
582
|
-
loaded += value.byteLength;
|
|
583
|
-
if (typeof onProgress === "function") onProgress(loaded / total, value);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
downloadFileRange(requestId, records, dataId, onProgress, signal) {
|
|
587
|
-
let pathname = `${this.path}/downloads/${dataId}?requestId=${requestId}`;
|
|
588
|
-
pathname = this.appendVersionParam(pathname);
|
|
589
|
-
return downloadPartOfFile(requestId, records, `${this.httpClient.serverUrl}${pathname}`, this.httpClient.headers, onProgress, signal);
|
|
590
|
-
}
|
|
591
372
|
get activeVersion() {
|
|
592
373
|
return this.data.activeVersion;
|
|
593
374
|
}
|
|
@@ -651,15 +432,17 @@ class Assembly {
|
|
|
651
432
|
return this.data.versions;
|
|
652
433
|
}
|
|
653
434
|
async checkout() {
|
|
654
|
-
|
|
435
|
+
const response = await this.internalGet("");
|
|
436
|
+
this.data = await response.json();
|
|
655
437
|
return this;
|
|
656
438
|
}
|
|
657
439
|
async update(data) {
|
|
658
|
-
|
|
440
|
+
const response = await this.internalPut("", data);
|
|
441
|
+
this.data = await response.json();
|
|
659
442
|
return this;
|
|
660
443
|
}
|
|
661
444
|
delete() {
|
|
662
|
-
return
|
|
445
|
+
return this.internalDelete("").then((response => response.json()));
|
|
663
446
|
}
|
|
664
447
|
save() {
|
|
665
448
|
return this.update(this.data);
|
|
@@ -669,7 +452,7 @@ class Assembly {
|
|
|
669
452
|
return Promise.resolve(this);
|
|
670
453
|
}
|
|
671
454
|
getModels() {
|
|
672
|
-
return
|
|
455
|
+
return this.internalGet("/geometry").then((response => response.json())).then((array => array.map((data => new Model(data, this)))));
|
|
673
456
|
}
|
|
674
457
|
getModelTransformMatrix(handle) {
|
|
675
458
|
return this.data.transform[handle];
|
|
@@ -684,13 +467,14 @@ class Assembly {
|
|
|
684
467
|
});
|
|
685
468
|
}
|
|
686
469
|
getProperties(handles) {
|
|
687
|
-
|
|
470
|
+
const relativePath = handles !== undefined ? `/properties?handles=${handles}` : "/properties";
|
|
471
|
+
return this.internalGet(relativePath).then((response => response.json()));
|
|
688
472
|
}
|
|
689
473
|
searchProperties(searchPattern) {
|
|
690
|
-
return
|
|
474
|
+
return this.internalPost("/properties/search", searchPattern).then((response => response.json()));
|
|
691
475
|
}
|
|
692
476
|
getCdaTree() {
|
|
693
|
-
return
|
|
477
|
+
return this.internalGet(`/properties/tree`).then((response => response.json()));
|
|
694
478
|
}
|
|
695
479
|
getViewpoints() {
|
|
696
480
|
console.warn("Assembly does not support viewpoints");
|
|
@@ -713,7 +497,19 @@ class Assembly {
|
|
|
713
497
|
return Promise.resolve("");
|
|
714
498
|
}
|
|
715
499
|
downloadResource(dataId, onProgress, signal) {
|
|
716
|
-
|
|
500
|
+
const relativePath = this.appendVersionParam(`/downloads/${dataId}`);
|
|
501
|
+
return this.httpClient.downloadFile(`${this.path}${relativePath}`, onProgress, signal).then((response => response.arrayBuffer()));
|
|
502
|
+
}
|
|
503
|
+
downloadResourceRange(dataId, ranges, requestId, onProgress, signal) {
|
|
504
|
+
const relativePath = this.appendVersionParam(`/downloads/${dataId}?requestId=${requestId}`);
|
|
505
|
+
return this.httpClient.downloadFileRange(`${this.path}${relativePath}`, ranges, onProgress, signal).then((response => response.arrayBuffer()));
|
|
506
|
+
}
|
|
507
|
+
partialDownloadResource(dataId, onProgress, signal) {
|
|
508
|
+
console.warn("Assembly.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use Assembly.downloadResource() instead.");
|
|
509
|
+
return this.downloadResource(dataId, onProgress, signal);
|
|
510
|
+
}
|
|
511
|
+
async downloadFileRange(requestId, records, dataId, onProgress, signal) {
|
|
512
|
+
await this.downloadResourceRange(dataId, records, requestId, onProgress, signal);
|
|
717
513
|
}
|
|
718
514
|
getReferences(signal) {
|
|
719
515
|
return Promise.resolve({
|
|
@@ -836,32 +632,219 @@ class EventEmitter2 {
|
|
|
836
632
|
}
|
|
837
633
|
}
|
|
838
634
|
|
|
635
|
+
function handleFetchError(response) {
|
|
636
|
+
if (!response.ok) {
|
|
637
|
+
switch (response.status) {
|
|
638
|
+
case 400:
|
|
639
|
+
{
|
|
640
|
+
return response.text().then((text => {
|
|
641
|
+
console.error(text);
|
|
642
|
+
return Promise.reject(new FetchError(400, error400(text)));
|
|
643
|
+
}));
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
case 500:
|
|
647
|
+
{
|
|
648
|
+
return response.text().then((text => {
|
|
649
|
+
console.error(error400(text, text));
|
|
650
|
+
return Promise.reject(new FetchError(500));
|
|
651
|
+
}));
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
default:
|
|
655
|
+
return Promise.reject(new FetchError(response.status, statusText(response.status)));
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return Promise.resolve(response);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
function $fetch(url, params = {
|
|
662
|
+
method: "GET"
|
|
663
|
+
}) {
|
|
664
|
+
const headers = {
|
|
665
|
+
...params.headers
|
|
666
|
+
};
|
|
667
|
+
delete headers["Content-Type"];
|
|
668
|
+
let body;
|
|
669
|
+
if (params.method === "POST" || params.method === "PUT") {
|
|
670
|
+
if (params.body instanceof FormData) {
|
|
671
|
+
body = params.body;
|
|
672
|
+
} else if (params.body instanceof Blob) {
|
|
673
|
+
body = new FormData;
|
|
674
|
+
body.append("file", params.body);
|
|
675
|
+
} else if (params.body instanceof ArrayBuffer) {
|
|
676
|
+
body = new FormData;
|
|
677
|
+
body.append("file", new Blob([ params.body ]));
|
|
678
|
+
} else if (typeof params.body === "object") {
|
|
679
|
+
body = JSON.stringify(params.body);
|
|
680
|
+
headers["Content-Type"] = "application/json";
|
|
681
|
+
} else if (typeof params.body === "string") {
|
|
682
|
+
body = params.body;
|
|
683
|
+
headers["Content-Type"] = "text/plain";
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
const init = {
|
|
687
|
+
method: params.method,
|
|
688
|
+
headers: headers
|
|
689
|
+
};
|
|
690
|
+
if (body) init.body = body;
|
|
691
|
+
if (params.signal) init.signal = params.signal;
|
|
692
|
+
return fetch(url, init).then(handleFetchError);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
function handleXMLHttpError(xhr) {
|
|
696
|
+
if (xhr.status === 0) {
|
|
697
|
+
return Promise.reject(new FetchError(0, "Network error"));
|
|
698
|
+
}
|
|
699
|
+
if (xhr.status < 200 || xhr.status > 299) {
|
|
700
|
+
switch (xhr.status) {
|
|
701
|
+
case 400:
|
|
702
|
+
{
|
|
703
|
+
console.error(xhr.responseText);
|
|
704
|
+
return Promise.reject(new FetchError(400, error400(xhr.responseText)));
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
case 500:
|
|
708
|
+
{
|
|
709
|
+
console.error(error400(xhr.responseText, xhr.responseText));
|
|
710
|
+
return Promise.reject(new FetchError(500));
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
default:
|
|
714
|
+
{
|
|
715
|
+
return Promise.reject(new FetchError(xhr.status));
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return Promise.resolve(xhr);
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
function $xmlhttp(url, params = {
|
|
723
|
+
method: "GET"
|
|
724
|
+
}) {
|
|
725
|
+
return new Promise(((resolve, reject) => {
|
|
726
|
+
const xhr = new XMLHttpRequest;
|
|
727
|
+
xhr.open(params.method, url, true);
|
|
728
|
+
for (const key in params.headers) {
|
|
729
|
+
xhr.setRequestHeader(key, params.headers[key]);
|
|
730
|
+
}
|
|
731
|
+
function calcProgress(event) {
|
|
732
|
+
return event.lengthComputable ? event.loaded / event.total : 1;
|
|
733
|
+
}
|
|
734
|
+
xhr.upload.onprogress = event => params.uploadProgress && params.uploadProgress(calcProgress(event));
|
|
735
|
+
xhr.onprogress = event => params.downloadProgress && params.downloadProgress(calcProgress(event));
|
|
736
|
+
xhr.onloadend = event => handleXMLHttpError(event.target).then(resolve, reject);
|
|
737
|
+
xhr.send(params.body);
|
|
738
|
+
}));
|
|
739
|
+
}
|
|
740
|
+
|
|
839
741
|
class HttpClient {
|
|
840
742
|
constructor(serverUrl) {
|
|
841
743
|
this.serverUrl = serverUrl;
|
|
842
744
|
}
|
|
843
745
|
get(relativePath, signal) {
|
|
844
|
-
return $
|
|
746
|
+
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
747
|
+
method: "GET",
|
|
748
|
+
headers: this.headers,
|
|
749
|
+
signal: signal
|
|
750
|
+
});
|
|
845
751
|
}
|
|
846
752
|
post(relativePath, body) {
|
|
847
|
-
return $
|
|
753
|
+
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
754
|
+
method: "POST",
|
|
755
|
+
headers: this.headers,
|
|
756
|
+
body: body
|
|
757
|
+
});
|
|
848
758
|
}
|
|
849
759
|
put(relativePath, body) {
|
|
850
|
-
return $
|
|
760
|
+
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
761
|
+
method: "PUT",
|
|
762
|
+
headers: this.headers,
|
|
763
|
+
body: body
|
|
764
|
+
});
|
|
851
765
|
}
|
|
852
766
|
delete(relativePath) {
|
|
853
|
-
return $
|
|
767
|
+
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
768
|
+
method: "DELETE",
|
|
769
|
+
headers: this.headers
|
|
770
|
+
});
|
|
854
771
|
}
|
|
855
|
-
|
|
772
|
+
uploadFile(relativePath, file, onProgress) {
|
|
856
773
|
const data = new FormData;
|
|
857
774
|
data.append("file", file);
|
|
858
|
-
return $
|
|
775
|
+
return $xmlhttp(`${this.serverUrl}${relativePath}`, {
|
|
859
776
|
method: "POST",
|
|
860
777
|
headers: this.headers,
|
|
861
778
|
body: data,
|
|
862
779
|
uploadProgress: onProgress
|
|
863
780
|
});
|
|
864
781
|
}
|
|
782
|
+
async downloadFile(relativePath, onProgress, signal) {
|
|
783
|
+
const response = await this.get(relativePath, signal);
|
|
784
|
+
const contentLength = response.headers.get("Content-Length");
|
|
785
|
+
const total = parseInt(contentLength, 10) || 1;
|
|
786
|
+
return new Response(new ReadableStream({
|
|
787
|
+
async start(controller) {
|
|
788
|
+
const reader = response.body.getReader();
|
|
789
|
+
let loaded = 0;
|
|
790
|
+
while (true) {
|
|
791
|
+
const {done: done, value: value} = await reader.read();
|
|
792
|
+
if (done) break;
|
|
793
|
+
controller.enqueue(value);
|
|
794
|
+
loaded += value.length;
|
|
795
|
+
if (onProgress) onProgress(loaded / total, value);
|
|
796
|
+
}
|
|
797
|
+
controller.close();
|
|
798
|
+
}
|
|
799
|
+
}));
|
|
800
|
+
}
|
|
801
|
+
async downloadFileRange(relativePath, ranges, onProgress, signal) {
|
|
802
|
+
const headers = {
|
|
803
|
+
...this.headers
|
|
804
|
+
};
|
|
805
|
+
headers["Range"] = "bytes=" + ranges.map((x => `${x.begin}-${x.end}`)).join(",");
|
|
806
|
+
const response = await $fetch(`${this.serverUrl}${relativePath}`, {
|
|
807
|
+
method: "GET",
|
|
808
|
+
headers: headers,
|
|
809
|
+
signal: signal
|
|
810
|
+
});
|
|
811
|
+
const contentLength = response.headers.get("content-length");
|
|
812
|
+
const total = parseInt(contentLength, 10) || 1;
|
|
813
|
+
return new Response(new ReadableStream({
|
|
814
|
+
async start(controller) {
|
|
815
|
+
const reader = response.body.getReader();
|
|
816
|
+
let loaded = 0;
|
|
817
|
+
let rangedIndex = 0;
|
|
818
|
+
let rangePos = 0;
|
|
819
|
+
while (true) {
|
|
820
|
+
const {done: done, value: value} = await reader.read();
|
|
821
|
+
if (done) break;
|
|
822
|
+
controller.enqueue(value);
|
|
823
|
+
loaded += value.length;
|
|
824
|
+
let chunkLeft = value.length;
|
|
825
|
+
let chunkPos = 0;
|
|
826
|
+
while (chunkLeft > 0) {
|
|
827
|
+
const range = ranges[rangedIndex];
|
|
828
|
+
const rangeLeft = range.end - range.begin - rangePos;
|
|
829
|
+
if (chunkLeft < rangeLeft) {
|
|
830
|
+
const chunk = value.subarray(chunkPos, chunkPos + chunkLeft);
|
|
831
|
+
if (onProgress) onProgress(loaded / total, chunk, range.requestId);
|
|
832
|
+
rangePos += chunkLeft;
|
|
833
|
+
chunkLeft = 0;
|
|
834
|
+
} else {
|
|
835
|
+
const chunk = value.subarray(chunkPos, chunkPos + rangeLeft);
|
|
836
|
+
if (onProgress) onProgress(loaded / total, chunk, range.requestId);
|
|
837
|
+
chunkPos += rangeLeft;
|
|
838
|
+
chunkLeft -= rangeLeft;
|
|
839
|
+
rangedIndex++;
|
|
840
|
+
rangePos = 0;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
controller.close();
|
|
845
|
+
}
|
|
846
|
+
}));
|
|
847
|
+
}
|
|
865
848
|
}
|
|
866
849
|
|
|
867
850
|
class Permission {
|
|
@@ -907,15 +890,17 @@ class Permission {
|
|
|
907
890
|
this.data.public = value;
|
|
908
891
|
}
|
|
909
892
|
async checkout() {
|
|
910
|
-
|
|
893
|
+
const response = await this.internalGet();
|
|
894
|
+
this.data = await response.json();
|
|
911
895
|
return this;
|
|
912
896
|
}
|
|
913
897
|
async update(data) {
|
|
914
|
-
|
|
898
|
+
const response = await this.internalPut(data);
|
|
899
|
+
this.data = await response.json();
|
|
915
900
|
return this;
|
|
916
901
|
}
|
|
917
902
|
delete() {
|
|
918
|
-
return
|
|
903
|
+
return this.internalDelete().then((response => response.json()));
|
|
919
904
|
}
|
|
920
905
|
save() {
|
|
921
906
|
return this.update(this.data);
|
|
@@ -979,15 +964,17 @@ class Job {
|
|
|
979
964
|
return this.data.startedAt;
|
|
980
965
|
}
|
|
981
966
|
async checkout() {
|
|
982
|
-
|
|
967
|
+
const response = await this.internalGet();
|
|
968
|
+
this.data = await response.json();
|
|
983
969
|
return this;
|
|
984
970
|
}
|
|
985
971
|
async update(data) {
|
|
986
|
-
|
|
972
|
+
const response = await this.internalPut(data);
|
|
973
|
+
this.data = await response.json();
|
|
987
974
|
return this;
|
|
988
975
|
}
|
|
989
976
|
delete() {
|
|
990
|
-
return
|
|
977
|
+
return this.internalDelete().then((response => response.json()));
|
|
991
978
|
}
|
|
992
979
|
waitForDone(params) {
|
|
993
980
|
const checkDone = () => this.checkout().then((job => {
|
|
@@ -1000,7 +987,7 @@ class Job {
|
|
|
1000
987
|
}
|
|
1001
988
|
}
|
|
1002
989
|
|
|
1003
|
-
class File
|
|
990
|
+
class File {
|
|
1004
991
|
constructor(data, httpClient) {
|
|
1005
992
|
this.path = `/files/${data.id}`;
|
|
1006
993
|
this.httpClient = httpClient;
|
|
@@ -1027,30 +1014,6 @@ class File$1 {
|
|
|
1027
1014
|
relativePath = this.appendVersionParam(relativePath);
|
|
1028
1015
|
return this.httpClient.delete(`${this.path}${relativePath}`);
|
|
1029
1016
|
}
|
|
1030
|
-
async partialDownloadResource(dataId, onProgress, signal) {
|
|
1031
|
-
var _a;
|
|
1032
|
-
let pathname = `${this.path}/downloads/${dataId}`;
|
|
1033
|
-
pathname = this.appendVersionParam(pathname);
|
|
1034
|
-
const response = await fetch(`${this.httpClient.serverUrl}${pathname}`, {
|
|
1035
|
-
headers: this.httpClient.headers,
|
|
1036
|
-
signal: signal
|
|
1037
|
-
});
|
|
1038
|
-
const contentLength = (_a = response.headers.get("Content-Length")) !== null && _a !== void 0 ? _a : "";
|
|
1039
|
-
const total = parseInt(contentLength, 10);
|
|
1040
|
-
const reader = response.body.getReader();
|
|
1041
|
-
let loaded = 0;
|
|
1042
|
-
while (true) {
|
|
1043
|
-
const {done: done, value: value} = await reader.read();
|
|
1044
|
-
if (done) break;
|
|
1045
|
-
loaded += value.byteLength;
|
|
1046
|
-
if (typeof onProgress === "function") onProgress(loaded / total, value);
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
downloadFileRange(requestId, records, dataId, onProgress, signal) {
|
|
1050
|
-
let pathname = `${this.path}/downloads/${dataId}?requestId=${requestId}`;
|
|
1051
|
-
pathname = this.appendVersionParam(pathname);
|
|
1052
|
-
return downloadPartOfFile(requestId, records, `${this.httpClient.serverUrl}${pathname}`, this.httpClient.headers, onProgress, signal);
|
|
1053
|
-
}
|
|
1054
1017
|
get activeVersion() {
|
|
1055
1018
|
return this.data.activeVersion;
|
|
1056
1019
|
}
|
|
@@ -1145,29 +1108,28 @@ class File$1 {
|
|
|
1145
1108
|
return this.data.versions;
|
|
1146
1109
|
}
|
|
1147
1110
|
async checkout() {
|
|
1148
|
-
|
|
1111
|
+
const response = await this.internalGet("");
|
|
1112
|
+
this.data = await response.json();
|
|
1149
1113
|
return this;
|
|
1150
1114
|
}
|
|
1151
1115
|
async update(data) {
|
|
1152
|
-
|
|
1116
|
+
const response = await this.internalPut("", data);
|
|
1117
|
+
this.data = await response.json();
|
|
1153
1118
|
return this;
|
|
1154
1119
|
}
|
|
1155
1120
|
delete() {
|
|
1156
|
-
return
|
|
1121
|
+
return this.internalDelete("").then((response => response.json()));
|
|
1157
1122
|
}
|
|
1158
1123
|
save() {
|
|
1159
1124
|
return this.update(this.data);
|
|
1160
1125
|
}
|
|
1161
1126
|
async setPreview(image) {
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
} else {
|
|
1165
|
-
this.data = await json(this.internalDelete("/preview"));
|
|
1166
|
-
}
|
|
1127
|
+
const response = await (image ? this.internalPost("/preview", image) : this.internalDelete("/preview"));
|
|
1128
|
+
this.data = await response.json();
|
|
1167
1129
|
return this;
|
|
1168
1130
|
}
|
|
1169
1131
|
getModels() {
|
|
1170
|
-
return
|
|
1132
|
+
return this.internalGet("/geometry").then((response => response.json())).then((array => array.map((data => new Model(data, this)))));
|
|
1171
1133
|
}
|
|
1172
1134
|
getModelTransformMatrix(handle) {
|
|
1173
1135
|
return undefined;
|
|
@@ -1177,44 +1139,58 @@ class File$1 {
|
|
|
1177
1139
|
return Promise.resolve(this);
|
|
1178
1140
|
}
|
|
1179
1141
|
getProperties(handles) {
|
|
1180
|
-
|
|
1142
|
+
const relativePath = handles !== undefined ? `/properties?handles=${handles}` : "/properties";
|
|
1143
|
+
return this.internalGet(relativePath).then((response => response.json()));
|
|
1181
1144
|
}
|
|
1182
1145
|
searchProperties(searchPattern) {
|
|
1183
|
-
return
|
|
1146
|
+
return this.internalPost("/properties/search", searchPattern).then((response => response.json()));
|
|
1184
1147
|
}
|
|
1185
1148
|
getCdaTree() {
|
|
1186
|
-
return
|
|
1149
|
+
return this.internalGet(`/properties/tree`).then((response => response.json()));
|
|
1187
1150
|
}
|
|
1188
1151
|
getViewpoints() {
|
|
1189
|
-
return
|
|
1152
|
+
return this.internalGet("/viewpoints").then((response => response.json())).then((viewpoints => viewpoints.result));
|
|
1190
1153
|
}
|
|
1191
1154
|
saveViewpoint(viewpoint) {
|
|
1192
|
-
return
|
|
1155
|
+
return this.internalPost("/viewpoints", viewpoint).then((response => response.json()));
|
|
1193
1156
|
}
|
|
1194
1157
|
deleteViewpoint(guid) {
|
|
1195
|
-
return
|
|
1158
|
+
return this.internalDelete(`/viewpoints/${guid}`).then((response => response.json()));
|
|
1196
1159
|
}
|
|
1197
1160
|
getSnapshot(guid) {
|
|
1198
|
-
return
|
|
1161
|
+
return this.internalGet(`/viewpoints/${guid}/snapshot`).then((response => response.text()));
|
|
1199
1162
|
}
|
|
1200
1163
|
getSnapshotData(guid, bitmapGuid) {
|
|
1201
|
-
return
|
|
1164
|
+
return this.internalGet(`/viewpoints/${guid}/bitmaps/${bitmapGuid}`).then((response => response.text()));
|
|
1202
1165
|
}
|
|
1203
1166
|
download(onProgress, signal) {
|
|
1204
|
-
|
|
1167
|
+
const relativePath = this.appendVersionParam("/downloads");
|
|
1168
|
+
return this.httpClient.downloadFile(`${this.path}${relativePath}`, onProgress, signal).then((response => response.arrayBuffer()));
|
|
1205
1169
|
}
|
|
1206
1170
|
downloadResource(dataId, onProgress, signal) {
|
|
1207
|
-
|
|
1171
|
+
const relativePath = this.appendVersionParam(`/downloads/${dataId}`);
|
|
1172
|
+
return this.httpClient.downloadFile(`${this.path}${relativePath}`, onProgress, signal).then((response => response.arrayBuffer()));
|
|
1173
|
+
}
|
|
1174
|
+
downloadResourceRange(dataId, ranges, requestId, onProgress, signal) {
|
|
1175
|
+
const relativePath = this.appendVersionParam(`/downloads/${dataId}?requestId=${requestId}`);
|
|
1176
|
+
return this.httpClient.downloadFileRange(`${this.path}${relativePath}`, ranges, onProgress, signal).then((response => response.arrayBuffer()));
|
|
1177
|
+
}
|
|
1178
|
+
partialDownloadResource(dataId, onProgress, signal) {
|
|
1179
|
+
console.warn("File.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use File.downloadResource() instead.");
|
|
1180
|
+
return this.downloadResource(dataId, onProgress, signal);
|
|
1181
|
+
}
|
|
1182
|
+
async downloadFileRange(requestId, records, dataId, onProgress, signal) {
|
|
1183
|
+
await this.downloadResourceRange(dataId, records, requestId, onProgress, signal);
|
|
1208
1184
|
}
|
|
1209
1185
|
getReferences(signal) {
|
|
1210
|
-
return
|
|
1186
|
+
return this.internalGet("/references", signal).then((response => response.json()));
|
|
1211
1187
|
}
|
|
1212
1188
|
setReferences(references) {
|
|
1213
|
-
return
|
|
1189
|
+
return this.internalPut("/references", references).then((response => response.json()));
|
|
1214
1190
|
}
|
|
1215
1191
|
createJob(outputFormat, parameters) {
|
|
1216
|
-
const
|
|
1217
|
-
return this.httpClient.post(
|
|
1192
|
+
const relativePath = this.appendVersionParam("/jobs");
|
|
1193
|
+
return this.httpClient.post(relativePath, {
|
|
1218
1194
|
fileId: this.id,
|
|
1219
1195
|
outputFormat: outputFormat,
|
|
1220
1196
|
parameters: parseArgs(parameters)
|
|
@@ -1245,28 +1221,28 @@ class File$1 {
|
|
|
1245
1221
|
return waitFor(checkDone, params).then((() => this));
|
|
1246
1222
|
}
|
|
1247
1223
|
getPermissions() {
|
|
1248
|
-
return
|
|
1224
|
+
return this.internalGet("/permissions").then((response => response.json())).then((array => array.map((data => new Permission(data, this.id, this.httpClient)))));
|
|
1249
1225
|
}
|
|
1250
1226
|
getPermission(permissionId) {
|
|
1251
|
-
return
|
|
1227
|
+
return this.internalGet(`/permissions/${permissionId}`).then((response => response.json())).then((data => new Permission(data, this.id, this.httpClient)));
|
|
1252
1228
|
}
|
|
1253
1229
|
createPermission(actions, grantedTo, _public) {
|
|
1254
|
-
return
|
|
1255
|
-
actions:
|
|
1230
|
+
return this.internalPost("/permissions", {
|
|
1231
|
+
actions: Array.isArray(actions) ? actions : [ actions ],
|
|
1256
1232
|
grantedTo: grantedTo,
|
|
1257
1233
|
public: _public
|
|
1258
|
-
})).then((data => new Permission(data, this.id, this.httpClient)));
|
|
1234
|
+
}).then((response => response.json())).then((data => new Permission(data, this.id, this.httpClient)));
|
|
1259
1235
|
}
|
|
1260
1236
|
deletePermission(permissionId) {
|
|
1261
|
-
return
|
|
1237
|
+
return this.internalDelete(`/permissions/${permissionId}`).then((response => response.json()));
|
|
1262
1238
|
}
|
|
1263
1239
|
async uploadVersion(file, params = {
|
|
1264
1240
|
waitForDone: false
|
|
1265
1241
|
}) {
|
|
1266
|
-
const result = await this.httpClient.
|
|
1242
|
+
const result = await this.httpClient.uploadFile(`${this.path}/versions`, file, (progress => {
|
|
1267
1243
|
var _a;
|
|
1268
1244
|
return (_a = params.onProgress) === null || _a === void 0 ? void 0 : _a.call(params, progress, file);
|
|
1269
|
-
})).then((xhr => JSON.parse(xhr.responseText))).then((data => new File
|
|
1245
|
+
})).then((xhr => JSON.parse(xhr.responseText))).then((data => new File(data, this.httpClient)));
|
|
1270
1246
|
if (params.geometry === undefined && this.geometryType !== "") params.geometry = true;
|
|
1271
1247
|
if (params.properties === undefined && this.status.properties.state !== "none") params.properties = true;
|
|
1272
1248
|
const jobs = [];
|
|
@@ -1277,16 +1253,16 @@ class File$1 {
|
|
|
1277
1253
|
return result;
|
|
1278
1254
|
}
|
|
1279
1255
|
getVersions() {
|
|
1280
|
-
return this.internalGet("/versions").then((response => response.json())).then((files => files.map((data => new File
|
|
1256
|
+
return this.internalGet("/versions").then((response => response.json())).then((files => files.map((data => new File(data, this.httpClient))))).then((files => files.map((file => file.id == file.originalFileId ? file.useVersion(0) : file))));
|
|
1281
1257
|
}
|
|
1282
1258
|
getVersion(version) {
|
|
1283
|
-
return this.internalGet(`/versions/${version}`).then((response => response.json())).then((data => new File
|
|
1259
|
+
return this.internalGet(`/versions/${version}`).then((response => response.json())).then((data => new File(data, this.httpClient))).then((file => file.id == file.originalFileId ? file.useVersion(0) : file));
|
|
1284
1260
|
}
|
|
1285
1261
|
async deleteVersion(version) {
|
|
1286
1262
|
const response = await this.internalDelete(`/versions/${version}`);
|
|
1287
|
-
const
|
|
1263
|
+
const data = await response.json();
|
|
1288
1264
|
await this.checkout();
|
|
1289
|
-
return
|
|
1265
|
+
return data;
|
|
1290
1266
|
}
|
|
1291
1267
|
setActiveVersion(version) {
|
|
1292
1268
|
return this.update({
|
|
@@ -1339,15 +1315,17 @@ class Role {
|
|
|
1339
1315
|
this.data.permissions = value || {};
|
|
1340
1316
|
}
|
|
1341
1317
|
async checkout() {
|
|
1342
|
-
|
|
1318
|
+
const response = await this.internalGet();
|
|
1319
|
+
this.data = await response.json();
|
|
1343
1320
|
return this;
|
|
1344
1321
|
}
|
|
1345
1322
|
async update(data) {
|
|
1346
|
-
|
|
1323
|
+
const response = await this.internalPut(data);
|
|
1324
|
+
this.data = await response.json();
|
|
1347
1325
|
return this;
|
|
1348
1326
|
}
|
|
1349
1327
|
delete() {
|
|
1350
|
-
return
|
|
1328
|
+
return this.internalDelete().then((response => response.json()));
|
|
1351
1329
|
}
|
|
1352
1330
|
save() {
|
|
1353
1331
|
return this.update(this.data);
|
|
@@ -1394,15 +1372,17 @@ class Member {
|
|
|
1394
1372
|
return this.data.user;
|
|
1395
1373
|
}
|
|
1396
1374
|
async checkout() {
|
|
1397
|
-
|
|
1375
|
+
const response = await this.internalGet();
|
|
1376
|
+
this.data = await response.json();
|
|
1398
1377
|
return this;
|
|
1399
1378
|
}
|
|
1400
1379
|
async update(data) {
|
|
1401
|
-
|
|
1380
|
+
const response = await this.internalPut(data);
|
|
1381
|
+
this.data = await response.json();
|
|
1402
1382
|
return this;
|
|
1403
1383
|
}
|
|
1404
1384
|
delete() {
|
|
1405
|
-
return
|
|
1385
|
+
return this.internalDelete().then((response => response.json()));
|
|
1406
1386
|
}
|
|
1407
1387
|
save() {
|
|
1408
1388
|
return this.update(this.data);
|
|
@@ -1500,15 +1480,17 @@ class Project {
|
|
|
1500
1480
|
return this.data.updatedAt;
|
|
1501
1481
|
}
|
|
1502
1482
|
async checkout() {
|
|
1503
|
-
|
|
1483
|
+
const response = await this.internalGet("");
|
|
1484
|
+
this.data = await response.json();
|
|
1504
1485
|
return this;
|
|
1505
1486
|
}
|
|
1506
1487
|
async update(data) {
|
|
1507
|
-
|
|
1488
|
+
const response = await this.internalPut("", data);
|
|
1489
|
+
this.data = await response.json();
|
|
1508
1490
|
return this;
|
|
1509
1491
|
}
|
|
1510
1492
|
delete() {
|
|
1511
|
-
return
|
|
1493
|
+
return this.internalDelete("").then((response => response.text())).then((text => {
|
|
1512
1494
|
try {
|
|
1513
1495
|
return JSON.parse(text);
|
|
1514
1496
|
} catch {
|
|
@@ -1522,46 +1504,43 @@ class Project {
|
|
|
1522
1504
|
return this.update(this.data);
|
|
1523
1505
|
}
|
|
1524
1506
|
async setPreview(image) {
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
} else {
|
|
1528
|
-
this.data = await json(this.internalDelete("/preview"));
|
|
1529
|
-
}
|
|
1507
|
+
const response = await (image ? this.internalPost("/preview", image) : this.internalDelete("/preview"));
|
|
1508
|
+
this.data = await response.json();
|
|
1530
1509
|
return this;
|
|
1531
1510
|
}
|
|
1532
1511
|
getRoles() {
|
|
1533
|
-
return
|
|
1512
|
+
return this.internalGet("/roles").then((response => response.json())).then((array => array.map((data => new Role(data, this.id, this.httpClient)))));
|
|
1534
1513
|
}
|
|
1535
1514
|
getRole(name) {
|
|
1536
|
-
return
|
|
1515
|
+
return this.internalGet(`/roles/${name}`).then((response => response.json())).then((data => new Role(data, this.id, this.httpClient)));
|
|
1537
1516
|
}
|
|
1538
1517
|
createRole(name, description, permissions) {
|
|
1539
|
-
return
|
|
1518
|
+
return this.internalPost("/roles", {
|
|
1540
1519
|
name: name,
|
|
1541
1520
|
description: description,
|
|
1542
1521
|
permissions: permissions || {}
|
|
1543
|
-
})).then((data => new Role(data, this.id, this.httpClient)));
|
|
1522
|
+
}).then((response => response.json())).then((data => new Role(data, this.id, this.httpClient)));
|
|
1544
1523
|
}
|
|
1545
1524
|
deleteRole(name) {
|
|
1546
|
-
return
|
|
1525
|
+
return this.internalDelete(`/roles/${name}`).then((response => response.json()));
|
|
1547
1526
|
}
|
|
1548
1527
|
getMembers() {
|
|
1549
|
-
return
|
|
1528
|
+
return this.internalGet("/members").then((response => response.json())).then((array => array.map((data => new Member(data, this.id, this.httpClient)))));
|
|
1550
1529
|
}
|
|
1551
1530
|
getMember(memberId) {
|
|
1552
|
-
return
|
|
1531
|
+
return this.internalGet(`/members/${memberId}`).then((response => response.json())).then((data => new Member(data, this.id, this.httpClient)));
|
|
1553
1532
|
}
|
|
1554
1533
|
addMember(userId, role) {
|
|
1555
|
-
return
|
|
1534
|
+
return this.internalPost("/members", {
|
|
1556
1535
|
userId: userId,
|
|
1557
1536
|
role: role
|
|
1558
|
-
})).then((data => new Member(data, this.id, this.httpClient)));
|
|
1537
|
+
}).then((response => response.json())).then((data => new Member(data, this.id, this.httpClient)));
|
|
1559
1538
|
}
|
|
1560
1539
|
removeMember(memberId) {
|
|
1561
|
-
return
|
|
1540
|
+
return this.internalDelete(`/members/${memberId}`).then((response => response.json()));
|
|
1562
1541
|
}
|
|
1563
1542
|
getFilesInformation() {
|
|
1564
|
-
return
|
|
1543
|
+
return this.httpClient.get(`/bcf/3.0/projects/${this.data.id}/files_information`).then((response => response.json())).then((items => {
|
|
1565
1544
|
items.forEach((item => {
|
|
1566
1545
|
const getFieldValue = displayName => (item.display_information.find((x => x.field_display_name === displayName)) || {}).field_value;
|
|
1567
1546
|
const previewUrl = `${this.httpClient.serverUrl}/files/${item.file.reference}/preview`;
|
|
@@ -1697,13 +1676,15 @@ class User {
|
|
|
1697
1676
|
}
|
|
1698
1677
|
async checkout() {
|
|
1699
1678
|
if (this.id === this.httpClient.signInUserId) {
|
|
1700
|
-
const
|
|
1679
|
+
const response = await this.httpClient.get("/user");
|
|
1680
|
+
const data = await response.json();
|
|
1701
1681
|
this.data = {
|
|
1702
1682
|
id: this.id,
|
|
1703
1683
|
...data
|
|
1704
1684
|
};
|
|
1705
1685
|
} else {
|
|
1706
|
-
const
|
|
1686
|
+
const response = await this.httpClient.get(`/users/${this.id}`);
|
|
1687
|
+
const data = await response.json();
|
|
1707
1688
|
this.data = {
|
|
1708
1689
|
id: data.id,
|
|
1709
1690
|
...data.userBrief
|
|
@@ -1713,15 +1694,17 @@ class User {
|
|
|
1713
1694
|
}
|
|
1714
1695
|
async update(data) {
|
|
1715
1696
|
if (this.id === this.httpClient.signInUserId) {
|
|
1716
|
-
const
|
|
1697
|
+
const response = await this.httpClient.put("/user", data);
|
|
1698
|
+
const newData = await response.json();
|
|
1717
1699
|
this.data = {
|
|
1718
1700
|
id: this.id,
|
|
1719
1701
|
...newData
|
|
1720
1702
|
};
|
|
1721
1703
|
} else {
|
|
1722
|
-
const
|
|
1704
|
+
const response = await this.httpClient.put(`/users/${this.id}`, {
|
|
1723
1705
|
userBrief: data
|
|
1724
|
-
})
|
|
1706
|
+
});
|
|
1707
|
+
const newData = await response.json();
|
|
1725
1708
|
this.data = {
|
|
1726
1709
|
id: newData.id,
|
|
1727
1710
|
...newData.userBrief
|
|
@@ -1730,7 +1713,7 @@ class User {
|
|
|
1730
1713
|
return this;
|
|
1731
1714
|
}
|
|
1732
1715
|
delete() {
|
|
1733
|
-
return
|
|
1716
|
+
return this.httpClient.delete(`/users/${this.id}`).then((response => response.json())).then((data => {
|
|
1734
1717
|
if (this.id === this.httpClient.signInUserId) {
|
|
1735
1718
|
this.httpClient.headers = {};
|
|
1736
1719
|
this.httpClient.signInUserId = "";
|
|
@@ -1744,13 +1727,15 @@ class User {
|
|
|
1744
1727
|
async setAvatar(image) {
|
|
1745
1728
|
if (image) {
|
|
1746
1729
|
if (this.id === this.httpClient.signInUserId) {
|
|
1747
|
-
const
|
|
1730
|
+
const response = await this.httpClient.post("/user/avatar", image);
|
|
1731
|
+
const data = await response.json();
|
|
1748
1732
|
this.data = {
|
|
1749
1733
|
id: this.id,
|
|
1750
1734
|
...data
|
|
1751
1735
|
};
|
|
1752
1736
|
} else {
|
|
1753
|
-
const
|
|
1737
|
+
const response = await this.httpClient.post(`/users/${this.id}/avatar`, image);
|
|
1738
|
+
const data = await response.json();
|
|
1754
1739
|
this.data = {
|
|
1755
1740
|
id: data.id,
|
|
1756
1741
|
...data.userBrief
|
|
@@ -1758,13 +1743,15 @@ class User {
|
|
|
1758
1743
|
}
|
|
1759
1744
|
} else {
|
|
1760
1745
|
if (this.id === this.httpClient.signInUserId) {
|
|
1761
|
-
const
|
|
1746
|
+
const response = await this.httpClient.delete("/user/avatar");
|
|
1747
|
+
const data = await response.json();
|
|
1762
1748
|
this.data = {
|
|
1763
1749
|
id: this.id,
|
|
1764
1750
|
...data
|
|
1765
1751
|
};
|
|
1766
1752
|
} else {
|
|
1767
|
-
const
|
|
1753
|
+
const response = await this.httpClient.delete(`/users/${this.id}/avatar`);
|
|
1754
|
+
const data = await response.json();
|
|
1768
1755
|
this.data = {
|
|
1769
1756
|
id: data.id,
|
|
1770
1757
|
...data.userBrief
|
|
@@ -1844,7 +1831,7 @@ class Client extends EventEmitter2 {
|
|
|
1844
1831
|
return this._httpClient.get("/version").then((response => response.json())).then((data => ({
|
|
1845
1832
|
...data,
|
|
1846
1833
|
server: data.version,
|
|
1847
|
-
client: "25.3.
|
|
1834
|
+
client: "25.3.18"
|
|
1848
1835
|
})));
|
|
1849
1836
|
}
|
|
1850
1837
|
registerUser(email, password, userName) {
|
|
@@ -1868,14 +1855,16 @@ class Client extends EventEmitter2 {
|
|
|
1868
1855
|
this._httpClient.headers = {
|
|
1869
1856
|
Authorization: "Basic " + credentials
|
|
1870
1857
|
};
|
|
1871
|
-
const
|
|
1858
|
+
const response = await this._httpClient.get("/token");
|
|
1859
|
+
const data = await response.json();
|
|
1872
1860
|
return this.setCurrentUser(data);
|
|
1873
1861
|
}
|
|
1874
1862
|
async signInWithToken(token) {
|
|
1875
1863
|
this._httpClient.headers = {
|
|
1876
1864
|
Authorization: token
|
|
1877
1865
|
};
|
|
1878
|
-
const
|
|
1866
|
+
const response = await this._httpClient.get("/user");
|
|
1867
|
+
const data = await response.json();
|
|
1879
1868
|
return this.setCurrentUser(data);
|
|
1880
1869
|
}
|
|
1881
1870
|
setCurrentUser(data) {
|
|
@@ -1896,19 +1885,19 @@ class Client extends EventEmitter2 {
|
|
|
1896
1885
|
return this._user;
|
|
1897
1886
|
}
|
|
1898
1887
|
getUsers() {
|
|
1899
|
-
return
|
|
1888
|
+
return this._httpClient.get("/users").then((response => response.json())).then((array => array.map((data => ({
|
|
1900
1889
|
id: data.id,
|
|
1901
1890
|
...data.userBrief
|
|
1902
1891
|
}))))).then((array => array.map((data => new User(data, this._httpClient)))));
|
|
1903
1892
|
}
|
|
1904
1893
|
getUser(userId) {
|
|
1905
1894
|
if (userId === this._httpClient.signInUserId) {
|
|
1906
|
-
return
|
|
1895
|
+
return this._httpClient.get("/user").then((response => response.json())).then((data => ({
|
|
1907
1896
|
id: userId,
|
|
1908
1897
|
...data
|
|
1909
1898
|
}))).then((data => new User(data, this._httpClient)));
|
|
1910
1899
|
} else {
|
|
1911
|
-
return
|
|
1900
|
+
return this._httpClient.get(`/users/${userId}`).then((response => response.json())).then((data => ({
|
|
1912
1901
|
id: data.id,
|
|
1913
1902
|
...data.userBrief
|
|
1914
1903
|
}))).then((data => new User(data, this._httpClient)));
|
|
@@ -1916,7 +1905,7 @@ class Client extends EventEmitter2 {
|
|
|
1916
1905
|
}
|
|
1917
1906
|
createUser(email, password, params = {}) {
|
|
1918
1907
|
const {isAdmin: isAdmin, userName: userName, ...rest} = params;
|
|
1919
|
-
return
|
|
1908
|
+
return this._httpClient.post("/users", {
|
|
1920
1909
|
isAdmin: isAdmin,
|
|
1921
1910
|
userBrief: {
|
|
1922
1911
|
...rest,
|
|
@@ -1924,13 +1913,13 @@ class Client extends EventEmitter2 {
|
|
|
1924
1913
|
userName: userName !== null && userName !== void 0 ? userName : (email + "").split("@").at(0)
|
|
1925
1914
|
},
|
|
1926
1915
|
password: password
|
|
1927
|
-
})).then((data => ({
|
|
1916
|
+
}).then((response => response.json())).then((data => ({
|
|
1928
1917
|
id: data.id,
|
|
1929
1918
|
...data.userBrief
|
|
1930
1919
|
}))).then((data => new User(data, this._httpClient)));
|
|
1931
1920
|
}
|
|
1932
1921
|
deleteUser(userId) {
|
|
1933
|
-
return
|
|
1922
|
+
return this._httpClient.delete(`/users/${userId}`).then((response => response.json())).then((data => {
|
|
1934
1923
|
if (userId === this._httpClient.signInUserId) {
|
|
1935
1924
|
this.clearCurrentUser();
|
|
1936
1925
|
}
|
|
@@ -1955,20 +1944,20 @@ class Client extends EventEmitter2 {
|
|
|
1955
1944
|
if (sortField) searchParams.set("sortField", sortField);
|
|
1956
1945
|
let queryString = searchParams.toString();
|
|
1957
1946
|
if (queryString) queryString = "?" + queryString;
|
|
1958
|
-
return
|
|
1947
|
+
return this._httpClient.get(`/files${queryString}`).then((response => response.json())).then((files => ({
|
|
1959
1948
|
...files,
|
|
1960
|
-
result: files.result.map((data => new File
|
|
1949
|
+
result: files.result.map((data => new File(data, this._httpClient)))
|
|
1961
1950
|
})));
|
|
1962
1951
|
}
|
|
1963
1952
|
getFile(fileId) {
|
|
1964
|
-
return
|
|
1953
|
+
return this._httpClient.get(`/files/${fileId}`).then((response => response.json())).then((data => new File(data, this._httpClient)));
|
|
1965
1954
|
}
|
|
1966
1955
|
async uploadFile(file, params = {
|
|
1967
1956
|
geometry: true,
|
|
1968
1957
|
properties: false,
|
|
1969
1958
|
waitForDone: false
|
|
1970
1959
|
}) {
|
|
1971
|
-
const result = await this._httpClient.
|
|
1960
|
+
const result = await this._httpClient.uploadFile("/files", file, (progress => {
|
|
1972
1961
|
var _a;
|
|
1973
1962
|
this.emitEvent({
|
|
1974
1963
|
type: "uploadprogress",
|
|
@@ -1976,7 +1965,7 @@ class Client extends EventEmitter2 {
|
|
|
1976
1965
|
file: file
|
|
1977
1966
|
});
|
|
1978
1967
|
(_a = params.onProgress) === null || _a === void 0 ? void 0 : _a.call(params, progress, file);
|
|
1979
|
-
})).then((xhr => JSON.parse(xhr.responseText))).then((data => new File
|
|
1968
|
+
})).then((xhr => JSON.parse(xhr.responseText))).then((data => new File(data, this._httpClient)));
|
|
1980
1969
|
const geometryType = typeof params.geometry === "string" ? params.geometry : "vsfx";
|
|
1981
1970
|
const jobs = [];
|
|
1982
1971
|
if (params.geometry) jobs.push((await result.extractGeometry(geometryType)).outputFormat);
|
|
@@ -1985,10 +1974,10 @@ class Client extends EventEmitter2 {
|
|
|
1985
1974
|
return result;
|
|
1986
1975
|
}
|
|
1987
1976
|
deleteFile(fileId) {
|
|
1988
|
-
return
|
|
1977
|
+
return this._httpClient.delete(`/files/${fileId}`).then((response => response.json()));
|
|
1989
1978
|
}
|
|
1990
1979
|
downloadFile(fileId, onProgress, signal) {
|
|
1991
|
-
return this._httpClient.
|
|
1980
|
+
return this._httpClient.downloadFile(`/files/${fileId}/downloads`, onProgress, signal).then((response => response.arrayBuffer()));
|
|
1992
1981
|
}
|
|
1993
1982
|
getJobs(status, limit, start, sortByDesc, sortField) {
|
|
1994
1983
|
const searchParams = new URLSearchParams;
|
|
@@ -2003,13 +1992,13 @@ class Client extends EventEmitter2 {
|
|
|
2003
1992
|
if (sortField) searchParams.set("sortField", sortField);
|
|
2004
1993
|
let queryString = searchParams.toString();
|
|
2005
1994
|
if (queryString) queryString = "?" + queryString;
|
|
2006
|
-
return
|
|
1995
|
+
return this._httpClient.get(`/jobs${queryString}`).then((response => response.json())).then((jobs => ({
|
|
2007
1996
|
...jobs,
|
|
2008
1997
|
result: jobs.result.map((data => new Job(data, this._httpClient)))
|
|
2009
1998
|
})));
|
|
2010
1999
|
}
|
|
2011
2000
|
getJob(jobId) {
|
|
2012
|
-
return
|
|
2001
|
+
return this._httpClient.get(`/jobs/${jobId}`).then((response => response.json())).then((data => new Job(data, this._httpClient)));
|
|
2013
2002
|
}
|
|
2014
2003
|
createJob(fileId, outputFormat, parameters) {
|
|
2015
2004
|
return this._httpClient.post("/jobs", {
|
|
@@ -2019,7 +2008,7 @@ class Client extends EventEmitter2 {
|
|
|
2019
2008
|
}).then((response => response.json())).then((data => new Job(data, this._httpClient)));
|
|
2020
2009
|
}
|
|
2021
2010
|
deleteJob(jobId) {
|
|
2022
|
-
return
|
|
2011
|
+
return this._httpClient.delete(`/jobs/${jobId}`).then((response => response.json()));
|
|
2023
2012
|
}
|
|
2024
2013
|
getAssemblies(start, limit, name, ids, sortByDesc, sortField) {
|
|
2025
2014
|
const searchParams = new URLSearchParams;
|
|
@@ -2035,13 +2024,13 @@ class Client extends EventEmitter2 {
|
|
|
2035
2024
|
if (sortField) searchParams.set("sortField", sortField);
|
|
2036
2025
|
let queryString = searchParams.toString();
|
|
2037
2026
|
if (queryString) queryString = "?" + queryString;
|
|
2038
|
-
return
|
|
2027
|
+
return this._httpClient.get(`/assemblies${queryString}`).then((response => response.json())).then((assemblies => ({
|
|
2039
2028
|
...assemblies,
|
|
2040
2029
|
result: assemblies.result.map((data => new Assembly(data, this._httpClient)))
|
|
2041
2030
|
})));
|
|
2042
2031
|
}
|
|
2043
2032
|
getAssembly(assemblyId) {
|
|
2044
|
-
return
|
|
2033
|
+
return this._httpClient.get(`/assemblies/${assemblyId}`).then((response => response.json())).then((data => new Assembly(data, this._httpClient)));
|
|
2045
2034
|
}
|
|
2046
2035
|
createAssembly(files, name, params) {
|
|
2047
2036
|
const {waitForDone: waitForDone} = params !== null && params !== void 0 ? params : {};
|
|
@@ -2051,7 +2040,7 @@ class Client extends EventEmitter2 {
|
|
|
2051
2040
|
}).then((response => response.json())).then((data => new Assembly(data, this._httpClient))).then((result => waitForDone ? result.waitForDone(params) : result));
|
|
2052
2041
|
}
|
|
2053
2042
|
deleteAssembly(assemblyId) {
|
|
2054
|
-
return
|
|
2043
|
+
return this._httpClient.delete(`/assemblies/${assemblyId}`).then((response => response.json()));
|
|
2055
2044
|
}
|
|
2056
2045
|
getProjects(start, limit, name, ids, sortByDesc) {
|
|
2057
2046
|
const searchParams = new URLSearchParams;
|
|
@@ -2066,7 +2055,7 @@ class Client extends EventEmitter2 {
|
|
|
2066
2055
|
if (sortByDesc !== undefined) searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
|
|
2067
2056
|
let queryString = searchParams.toString();
|
|
2068
2057
|
if (queryString) queryString = "?" + queryString;
|
|
2069
|
-
return
|
|
2058
|
+
return this._httpClient.get(`/projects${queryString}`).then((response => response.json())).then((projects => {
|
|
2070
2059
|
if (Array.isArray(projects)) {
|
|
2071
2060
|
let result = projects;
|
|
2072
2061
|
if (ids) result = result.filter((x => ids.includes(x.id)));
|
|
@@ -2090,19 +2079,19 @@ class Client extends EventEmitter2 {
|
|
|
2090
2079
|
})));
|
|
2091
2080
|
}
|
|
2092
2081
|
getProject(projectId) {
|
|
2093
|
-
return
|
|
2082
|
+
return this._httpClient.get(`/projects/${projectId}`).then((response => response.json())).then((data => new Project(data, this._httpClient)));
|
|
2094
2083
|
}
|
|
2095
2084
|
createProject(name, description, startDate, endDate, avatarUrl) {
|
|
2096
|
-
return
|
|
2085
|
+
return this._httpClient.post("/projects", {
|
|
2097
2086
|
name: name,
|
|
2098
2087
|
description: description,
|
|
2099
2088
|
startDate: startDate instanceof Date ? startDate.toISOString() : startDate,
|
|
2100
2089
|
endDate: endDate instanceof Date ? endDate.toISOString() : endDate,
|
|
2101
2090
|
avatarUrl: avatarUrl
|
|
2102
|
-
})).then((data => new Project(data, this._httpClient)));
|
|
2091
|
+
}).then((response => response.json())).then((data => new Project(data, this._httpClient)));
|
|
2103
2092
|
}
|
|
2104
2093
|
deleteProject(projectId) {
|
|
2105
|
-
return
|
|
2094
|
+
return this._httpClient.delete(`/projects/${projectId}`).then((response => response.text())).then((text => {
|
|
2106
2095
|
try {
|
|
2107
2096
|
return JSON.parse(text);
|
|
2108
2097
|
} catch {
|
|
@@ -2114,7 +2103,7 @@ class Client extends EventEmitter2 {
|
|
|
2114
2103
|
}
|
|
2115
2104
|
}
|
|
2116
2105
|
|
|
2117
|
-
const version = "25.3.
|
|
2106
|
+
const version = "25.3.18";
|
|
2118
2107
|
|
|
2119
|
-
export { Assembly, ClashTest, Client, File
|
|
2108
|
+
export { Assembly, ClashTest, Client, File, Job, Member, Model, Permission, Project, Role, User, parseArgs, userFullName, userInitials, version, waitFor };
|
|
2120
2109
|
//# sourceMappingURL=client.module.js.map
|