@3dverse/api 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.esm.js CHANGED
@@ -1,764 +1,764 @@
1
1
  import axios from 'axios';
2
2
 
3
- /**
4
- * 3dverse v1.0
5
- * # 3dverse API
6
- *
7
- * Welcome to the 3dverse API. The 3dverse API scopes to an API key. Each development environment of an application requires a separate API key.
8
- * Through the API key, you can manage ownership, access, and permissions for each environment.
9
- * Each environment has its own set of users, groups, folders, and assets.
10
- *
11
- *
12
- * Contact: 3dverse Support (support@3dverse.com)
13
- *
14
- * NOTE: This file is auto generated by library-generator (https://gitlab.com/3dverse/libs/library-generator).
15
- * Do not edit this file class manually.
16
- */
17
- //--------------------------------------------------------------------------
18
- const axiosInstance = axios.create({
19
- baseURL: "https://api.3dverse.com/app/v1",
20
- operationId: "3dverse"
21
- });
22
- //------------------------------------------------------------------------------
23
- function setBaseURL(baseURL) {
24
- axiosInstance.defaults.baseURL = baseURL;
25
- }
26
- function listUsers({ offset = 0, limit = 10 }) {
27
- return axiosInstance({
28
- operationId: "listUsers",
29
- method: "get",
30
- url: "/users",
31
- params: {
32
- offset: offset,
33
- limit: limit
34
- }
35
- });
36
- }
37
- function registerUser({ username }) {
38
- return axiosInstance({
39
- operationId: "registerUser",
40
- method: "post",
41
- url: "/users",
42
- data: {
43
- username: username
44
- }
45
- });
46
- }
47
- function getUser({ user_id }) {
48
- return axiosInstance({
49
- operationId: "getUser",
50
- method: "get",
51
- url: "/users/" + user_id + ""
52
- });
53
- }
54
- //--------------------------------------------------------------------------
55
- // Updates the details of the target user.
56
- function updateUser({ user_id, username }) {
57
- return axiosInstance({
58
- operationId: "updateUser",
59
- method: "patch",
60
- url: "/users/" + user_id + "",
61
- data: {
62
- username: username
63
- }
64
- });
65
- }
66
- function deleteUser({ user_id }) {
67
- return axiosInstance({
68
- operationId: "deleteUser",
69
- method: "delete",
70
- url: "/users/" + user_id + ""
71
- });
72
- }
73
- function generateUserToken({ user_id, scope, ttl = '1h' }) {
74
- return axiosInstance({
75
- operationId: "generateUserToken",
76
- method: "post",
77
- url: "/users/" + user_id + "/tokens",
78
- data: {
79
- scope: scope,
80
- ttl: ttl
81
- }
82
- });
83
- }
84
- function getUserGroups({ user_id }) {
85
- return axiosInstance({
86
- operationId: "getUserGroups",
87
- method: "get",
88
- url: "/users/" + user_id + "/groups"
89
- });
90
- }
91
- function getUserUploadTasks({ user_id, offset = 0, limit = 10 }) {
92
- return axiosInstance({
93
- operationId: "getUserUploadTasks",
94
- method: "get",
95
- url: "/users/" + user_id + "/upload-tasks",
96
- params: {
97
- offset: offset,
98
- limit: limit
99
- }
100
- });
101
- }
102
- function createGroup({ group_name, group_description, members }) {
103
- return axiosInstance({
104
- operationId: "createGroup",
105
- method: "post",
106
- url: "/groups",
107
- data: {
108
- group_name: group_name,
109
- group_description: group_description,
110
- members: members
111
- }
112
- });
113
- }
114
- function getGroup({ group_id }) {
115
- return axiosInstance({
116
- operationId: "getGroup",
117
- method: "get",
118
- url: "/groups/" + group_id + ""
119
- });
120
- }
121
- //--------------------------------------------------------------------------
122
- // Updates a group details.
123
- function updateGroupDescription({ group_id, group_name, group_description }) {
124
- return axiosInstance({
125
- operationId: "updateGroupDescription",
126
- method: "patch",
127
- url: "/groups/" + group_id + "",
128
- data: {
129
- group_name: group_name,
130
- group_description: group_description
131
- }
132
- });
133
- }
134
- //--------------------------------------------------------------------------
135
- // Deletes a group and all its access rights.
136
- function deleteGroup({ group_id }) {
137
- return axiosInstance({
138
- operationId: "deleteGroup",
139
- method: "delete",
140
- url: "/groups/" + group_id + ""
141
- });
142
- }
143
- //--------------------------------------------------------------------------
144
- // Grants member access to the group.
145
- function grantMemberAccessToGroup({ group_id, member_type, member_id, group_access, folder_access }) {
146
- return axiosInstance({
147
- operationId: "grantMemberAccessToGroup",
148
- method: "put",
149
- url: "/groups/" + group_id + "/members/" + member_type + "/" + member_id + "",
150
- data: {
151
- group_access: group_access,
152
- folder_access: folder_access
153
- }
154
- });
155
- }
156
- //--------------------------------------------------------------------------
157
- // Revoke requested user access to group.
158
- function revokeMemberAccessToGroup({ group_id, member_type, member_id }) {
159
- return axiosInstance({
160
- operationId: "revokeMemberAccessToGroup",
161
- method: "delete",
162
- url: "/groups/" + group_id + "/members/" + member_type + "/" + member_id + ""
163
- });
164
- }
165
- function listFolders({ offset = 0, limit = 10 }) {
166
- return axiosInstance({
167
- operationId: "listFolders",
168
- method: "get",
169
- url: "/folders",
170
- params: {
171
- offset: offset,
172
- limit: limit
173
- }
174
- });
175
- }
176
- function createFolder({ folder_name, subfolders }) {
177
- return axiosInstance({
178
- operationId: "createFolder",
179
- method: "post",
180
- url: "/folders",
181
- data: {
182
- folder_name: folder_name,
183
- subfolders: subfolders
184
- }
185
- });
186
- }
187
- function getFolderInfo({ folder_id }) {
188
- return axiosInstance({
189
- operationId: "getFolderInfo",
190
- method: "get",
191
- url: "/folders/" + folder_id + ""
192
- });
193
- }
194
- //--------------------------------------------------------------------------
195
- // Move folders inside the specified folder.
196
- function moveFolders({ folder_id, folderIds }) {
197
- return axiosInstance({
198
- operationId: "moveFolders",
199
- method: "put",
200
- url: "/folders/" + folder_id + "",
201
- data: folderIds
202
- });
203
- }
204
- //--------------------------------------------------------------------------
205
- // Updates the folder details.
206
- function updateFolder({ folder_id, folder_name }) {
207
- return axiosInstance({
208
- operationId: "updateFolder",
209
- method: "patch",
210
- url: "/folders/" + folder_id + "",
211
- data: {
212
- folder_name: folder_name
213
- }
214
- });
215
- }
216
- //--------------------------------------------------------------------------
217
- // Deletes the requested folder. The target folder must be empty.
218
- function deleteFolder({ folder_id }) {
219
- return axiosInstance({
220
- operationId: "deleteFolder",
221
- method: "delete",
222
- url: "/folders/" + folder_id + ""
223
- });
224
- }
225
- function listFolderAccesses({ folder_id }) {
226
- return axiosInstance({
227
- operationId: "listFolderAccesses",
228
- method: "get",
229
- url: "/folders/" + folder_id + "/access"
230
- });
231
- }
232
- //--------------------------------------------------------------------------
233
- // Grants member access to the targeted folder.
234
- function grantMemberAccessToFolder({ folder_id, member_type, member_id, access }) {
235
- return axiosInstance({
236
- operationId: "grantMemberAccessToFolder",
237
- method: "put",
238
- url: "/folders/" + folder_id + "/access/" + member_type + "/" + member_id + "",
239
- data: {
240
- access: access
241
- }
242
- });
243
- }
244
- //--------------------------------------------------------------------------
245
- // Revokes member access to a target folder.
246
- function revokeMemberAccessToFolder({ folder_id, member_type, member_id }) {
247
- return axiosInstance({
248
- operationId: "revokeMemberAccessToFolder",
249
- method: "delete",
250
- url: "/folders/" + folder_id + "/access/" + member_type + "/" + member_id + ""
251
- });
252
- }
253
- function createSubfolder({ folder_id, folder_name, subfolders }) {
254
- return axiosInstance({
255
- operationId: "createSubfolder",
256
- method: "post",
257
- url: "/folders/" + folder_id + "/folders",
258
- data: {
259
- folder_name: folder_name,
260
- subfolders: subfolders
261
- }
262
- });
263
- }
264
- function listFolderSubFolders({ folder_id, depth = 0 }) {
265
- return axiosInstance({
266
- operationId: "listFolderSubFolders",
267
- method: "get",
268
- url: "/folders/" + folder_id + "/folders",
269
- params: {
270
- depth: depth
271
- }
272
- });
273
- }
274
- function uploadSourceFiles({ folder_id, body }) {
275
- return axiosInstance({
276
- operationId: "uploadSourceFiles",
277
- method: "post",
278
- url: "/folders/" + folder_id + "/source-files",
279
- headers: {
280
- "Content-Type": "multipart/form-data"
281
- },
282
- data: body
283
- });
284
- }
285
- function getSourceFilesInFolder({ folder_id, offset = 0, limit = 10 }) {
286
- return axiosInstance({
287
- operationId: "getSourceFilesInFolder",
288
- method: "get",
289
- url: "/folders/" + folder_id + "/source-files",
290
- params: {
291
- offset: offset,
292
- limit: limit
293
- }
294
- });
295
- }
296
- //--------------------------------------------------------------------------
297
- // Move source files inside the specified folder.
298
- function moveSourceFiles({ folder_id, sourceFileIds }) {
299
- return axiosInstance({
300
- operationId: "moveSourceFiles",
301
- method: "put",
302
- url: "/folders/" + folder_id + "/source-files",
303
- data: sourceFileIds
304
- });
305
- }
306
- function getUploadTasksInFolder({ folder_id, offset = 0, limit = 10 }) {
307
- return axiosInstance({
308
- operationId: "getUploadTasksInFolder",
309
- method: "get",
310
- url: "/folders/" + folder_id + "/upload-tasks",
311
- params: {
312
- offset: offset,
313
- limit: limit
314
- }
315
- });
316
- }
317
- function getFolderAssets({ folder_id, offset = 0, limit = 10 }) {
318
- return axiosInstance({
319
- operationId: "getFolderAssets",
320
- method: "get",
321
- url: "/folders/" + folder_id + "/assets",
322
- params: {
323
- offset: offset,
324
- limit: limit
325
- }
326
- });
327
- }
328
- //--------------------------------------------------------------------------
329
- // Move assets inside the specified folder.
330
- function moveAssets({ folder_id, assetIds }) {
331
- return axiosInstance({
332
- operationId: "moveAssets",
333
- method: "put",
334
- url: "/folders/" + folder_id + "/assets",
335
- data: assetIds
336
- });
337
- }
338
- function createAsset({ folder_id, asset_container_creatable, assetCreationOptions }) {
339
- return axiosInstance({
340
- operationId: "createAsset",
341
- method: "post",
342
- url: "/folders/" + folder_id + "/assets/" + asset_container_creatable + "",
343
- data: assetCreationOptions
344
- });
345
- }
346
- function getSessionsInFolder({ folder_id }) {
347
- return axiosInstance({
348
- operationId: "getSessionsInFolder",
349
- method: "get",
350
- url: "/folders/" + folder_id + "/sessions"
351
- });
352
- }
353
- function listSourceFiles({ offset = 0, limit = 10 }) {
354
- return axiosInstance({
355
- operationId: "listSourceFiles",
356
- method: "get",
357
- url: "/source-files",
358
- params: {
359
- offset: offset,
360
- limit: limit
361
- }
362
- });
363
- }
364
- //--------------------------------------------------------------------------
365
- // Deletes the target source files. Deleting a source file is permanent.
366
- function deleteSourceFiles({ sourceFileIds }) {
367
- return axiosInstance({
368
- operationId: "deleteSourceFiles",
369
- method: "delete",
370
- url: "/source-files",
371
- data: sourceFileIds
372
- });
373
- }
374
- //--------------------------------------------------------------------------
375
- // Downloads the target source file.
376
- function downloadSourceFile({ source_file_id }) {
377
- return axiosInstance({
378
- operationId: "downloadSourceFile",
379
- method: "get",
380
- url: "/source-files/" + source_file_id + "",
381
- responseType: "arraybuffer"
382
- });
383
- }
384
- function getSourceFileDetails({ source_file_id }) {
385
- return axiosInstance({
386
- operationId: "getSourceFileDetails",
387
- method: "get",
388
- url: "/source-files/" + source_file_id + "/details"
389
- });
390
- }
391
- //--------------------------------------------------------------------------
392
- // Updates details for a specific source file.
393
- function updateSourceFileDetails({ source_file_id, source_file_name }) {
394
- return axiosInstance({
395
- operationId: "updateSourceFileDetails",
396
- method: "patch",
397
- url: "/source-files/" + source_file_id + "/details",
398
- data: {
399
- source_file_name: source_file_name
400
- }
401
- });
402
- }
403
- function getSourceFileAssets({ source_file_id }) {
404
- return axiosInstance({
405
- operationId: "getSourceFileAssets",
406
- method: "get",
407
- url: "/source-files/" + source_file_id + "/assets"
408
- });
409
- }
410
- function getUploadTask({ upload_task_id }) {
411
- return axiosInstance({
412
- operationId: "getUploadTask",
413
- method: "get",
414
- url: "/upload-tasks/" + upload_task_id + ""
415
- });
416
- }
417
- function listAssets({ offset = 0, limit = 10 }) {
418
- return axiosInstance({
419
- operationId: "listAssets",
420
- method: "get",
421
- url: "/assets",
422
- params: {
423
- offset: offset,
424
- limit: limit
425
- }
426
- });
427
- }
428
- //--------------------------------------------------------------------------
429
- // Batch delete assets. You **MUST NOT** reference assets.
430
- function deleteAssets({ assetIds }) {
431
- return axiosInstance({
432
- operationId: "deleteAssets",
433
- method: "delete",
434
- url: "/assets",
435
- data: assetIds
436
- });
437
- }
438
- //--------------------------------------------------------------------------
439
- // Deletes the asset.
440
- function deleteAsset({ asset_container, asset_id }) {
441
- return axiosInstance({
442
- operationId: "deleteAsset",
443
- method: "delete",
444
- url: "/assets/" + asset_container + "/" + asset_id + ""
445
- });
446
- }
447
- function getAssetSourceFile({ asset_container, asset_id }) {
448
- return axiosInstance({
449
- operationId: "getAssetSourceFile",
450
- method: "get",
451
- url: "/assets/" + asset_container + "/" + asset_id + "/source-file"
452
- });
453
- }
454
- function getAssetDetails({ asset_container, asset_id }) {
455
- return axiosInstance({
456
- operationId: "getAssetDetails",
457
- method: "get",
458
- url: "/assets/" + asset_container + "/" + asset_id + "/details"
459
- });
460
- }
461
- function getAssetFolder({ asset_container, asset_id }) {
462
- return axiosInstance({
463
- operationId: "getAssetFolder",
464
- method: "get",
465
- url: "/assets/" + asset_container + "/" + asset_id + "/folder"
466
- });
467
- }
468
- function getAssetDependencies({ asset_container, asset_id, format = 'flat', depth = 'all', filter }) {
469
- return axiosInstance({
470
- operationId: "getAssetDependencies",
471
- method: "get",
472
- url: "/assets/" + asset_container + "/" + asset_id + "/dependencies",
473
- params: {
474
- format: format,
475
- depth: depth,
476
- filter: filter
477
- }
478
- });
479
- }
480
- function getAssetReferences({ asset_container, asset_id }) {
481
- return axiosInstance({
482
- operationId: "getAssetReferences",
483
- method: "get",
484
- url: "/assets/" + asset_container + "/" + asset_id + "/references"
485
- });
486
- }
487
- function getAssetDescription({ asset_container, asset_id }) {
488
- return axiosInstance({
489
- operationId: "getAssetDescription",
490
- method: "get",
491
- url: "/assets/" + asset_container + "/" + asset_id + "/description"
492
- });
493
- }
494
- function updateAssetDescription({ asset_container, asset_id, assetDescription }) {
495
- return axiosInstance({
496
- operationId: "updateAssetDescription",
497
- method: "patch",
498
- url: "/assets/" + asset_container + "/" + asset_id + "/description",
499
- data: assetDescription
500
- });
501
- }
502
- //--------------------------------------------------------------------------
503
- // Gets the asset payload from the specified asset.
504
- function getAssetPayload({ asset_container_with_payload, asset_id }) {
505
- return axiosInstance({
506
- operationId: "getAssetPayload",
507
- method: "get",
508
- url: "/assets/" + asset_container_with_payload + "/" + asset_id + "/payload",
509
- responseType: "arraybuffer"
510
- });
511
- }
512
- function getAssetHistory({ asset_container, asset_id }) {
513
- return axiosInstance({
514
- operationId: "getAssetHistory",
515
- method: "get",
516
- url: "/assets/" + asset_container + "/" + asset_id + "/history"
517
- });
518
- }
519
- function getAssetMeta({ asset_container, asset_id }) {
520
- return axiosInstance({
521
- operationId: "getAssetMeta",
522
- method: "get",
523
- url: "/assets/" + asset_container + "/" + asset_id + "/meta"
524
- });
525
- }
526
- //--------------------------------------------------------------------------
527
- // Gets the code of the specified asset.
528
- function getAssetCode({ asset_container_with_code, asset_id }) {
529
- return axiosInstance({
530
- operationId: "getAssetCode",
531
- method: "get",
532
- url: "/assets/" + asset_container_with_code + "/" + asset_id + "/code"
533
- });
534
- }
535
- //--------------------------------------------------------------------------
536
- // Gets the asset thumbnail from the specified asset.
537
- function getAssetThumbnail({ asset_container, asset_id, size, default_url }) {
538
- return axiosInstance({
539
- operationId: "getAssetThumbnail",
540
- method: "get",
541
- url: "/assets/" + asset_container + "/" + asset_id + "/thumbnail",
542
- params: {
543
- size: size,
544
- default_url: default_url
545
- }
546
- });
547
- }
548
- //--------------------------------------------------------------------------
549
- // Assigns a thumbnail to the specified asset.
550
- function setAssetThumbnail({ asset_container, asset_id, body }, contentType) {
551
- return axiosInstance({
552
- operationId: "setAssetThumbnail",
553
- method: "put",
554
- url: "/assets/" + asset_container + "/" + asset_id + "/thumbnail",
555
- headers: {
556
- "Content-Type": contentType
557
- },
558
- data: body
559
- });
560
- }
561
- function getAssetCustomTypes({ asset_container_with_custom_types, asset_id }) {
562
- return axiosInstance({
563
- operationId: "getAssetCustomTypes",
564
- method: "get",
565
- url: "/assets/" + asset_container_with_custom_types + "/" + asset_id + "/custom-types"
566
- });
567
- }
568
- //--------------------------------------------------------------------------
569
- // Packages and downloads the target asset.
570
- function packageAsset({ asset_container, asset_id }) {
571
- return axiosInstance({
572
- operationId: "packageAsset",
573
- method: "get",
574
- url: "/assets/" + asset_container + "/" + asset_id + "/package",
575
- responseType: "arraybuffer"
576
- });
577
- }
578
- //--------------------------------------------------------------------------
579
- // Downloads an asset payload in a given format. Only mesh is supported for the moment. This endpoint requires special export permission.
580
- function exportAsset({ asset_container_exportable, asset_id, format, scale = 1 }) {
581
- return axiosInstance({
582
- operationId: "exportAsset",
583
- method: "get",
584
- url: "/assets/" + asset_container_exportable + "/" + asset_id + "/exports/" + format + "",
585
- responseType: "arraybuffer",
586
- params: {
587
- scale: scale
588
- }
589
- });
590
- }
591
- function getSceneSessions({ scene_id }) {
592
- return axiosInstance({
593
- operationId: "getSceneSessions",
594
- method: "get",
595
- url: "/assets/scenes/" + scene_id + "/sessions"
596
- });
597
- }
598
- function getSceneAABB({ scene_id }) {
599
- return axiosInstance({
600
- operationId: "getSceneAABB",
601
- method: "get",
602
- url: "/assets/scenes/" + scene_id + "/aabb"
603
- });
604
- }
605
- function getEntity({ scene_id, entity_id, compute_global_transform = false }) {
606
- return axiosInstance({
607
- operationId: "getEntity",
608
- method: "get",
609
- url: "/assets/scenes/" + scene_id + "/entities/" + entity_id + "",
610
- params: {
611
- compute_global_transform: compute_global_transform
612
- }
613
- });
614
- }
615
- function updateEntity({ scene_id, entity_id, entity }) {
616
- return axiosInstance({
617
- operationId: "updateEntity",
618
- method: "patch",
619
- url: "/assets/scenes/" + scene_id + "/entities/" + entity_id + "",
620
- data: entity
621
- });
622
- }
623
- //--------------------------------------------------------------------------
624
- // Delete a specific entity from a scene
625
- function deleteEntity({ scene_id, entity_id }) {
626
- return axiosInstance({
627
- operationId: "deleteEntity",
628
- method: "delete",
629
- url: "/assets/scenes/" + scene_id + "/entities/" + entity_id + ""
630
- });
631
- }
632
- function createSession({ scene_id }) {
633
- return axiosInstance({
634
- operationId: "createSession",
635
- method: "post",
636
- url: "/sessions",
637
- data: {
638
- scene_id: scene_id
639
- }
640
- });
641
- }
642
- function getSession({ session_id }) {
643
- return axiosInstance({
644
- operationId: "getSession",
645
- method: "get",
646
- url: "/sessions/" + session_id + ""
647
- });
648
- }
649
- //--------------------------------------------------------------------------
650
- // Forcefully terminates a session.
651
- function killSession({ session_id }) {
652
- return axiosInstance({
653
- operationId: "killSession",
654
- method: "delete",
655
- url: "/sessions/" + session_id + ""
656
- });
657
- }
658
- function joinSession({ session_id }) {
659
- return axiosInstance({
660
- operationId: "joinSession",
661
- method: "post",
662
- url: "/sessions/" + session_id + "/clients"
663
- });
664
- }
665
- //--------------------------------------------------------------------------
666
- // Kick a client from a running session.
667
- function kickClientFromSession({ session_id, client_id }) {
668
- return axiosInstance({
669
- operationId: "kickClientFromSession",
670
- method: "delete",
671
- url: "/sessions/" + session_id + "/clients/" + client_id + ""
672
- });
673
- }
674
- function joinSessionAsGuest() {
675
- return axiosInstance({
676
- operationId: "joinSessionAsGuest",
677
- method: "post",
678
- url: "/sessions/guests"
679
- });
680
- }
681
- function generateGuestToken({ session_id }) {
682
- return axiosInstance({
683
- operationId: "generateGuestToken",
684
- method: "post",
685
- url: "/sessions/" + session_id + "/guests"
686
- });
3
+ /**
4
+ * 3dverse v1.0
5
+ * # 3dverse API
6
+ *
7
+ * Welcome to the 3dverse API. The 3dverse API scopes to an API key. Each development environment of an application requires a separate API key.
8
+ * Through the API key, you can manage ownership, access, and permissions for each environment.
9
+ * Each environment has its own set of users, groups, folders, and assets.
10
+ *
11
+ *
12
+ * Contact: 3dverse Support (support@3dverse.com)
13
+ *
14
+ * NOTE: This file is auto generated by library-generator (https://gitlab.com/3dverse/libs/library-generator).
15
+ * Do not edit this file class manually.
16
+ */
17
+ //--------------------------------------------------------------------------
18
+ const axiosInstance = axios.create({
19
+ baseURL: "https://api.3dverse.com/app/v1",
20
+ operationId: "3dverse"
21
+ });
22
+ //------------------------------------------------------------------------------
23
+ function setBaseURL(baseURL) {
24
+ axiosInstance.defaults.baseURL = baseURL;
25
+ }
26
+ function listUsers({ offset = 0, limit = 10 }) {
27
+ return axiosInstance({
28
+ operationId: "listUsers",
29
+ method: "get",
30
+ url: "/users",
31
+ params: {
32
+ offset: offset,
33
+ limit: limit
34
+ }
35
+ });
36
+ }
37
+ function registerUser({ username }) {
38
+ return axiosInstance({
39
+ operationId: "registerUser",
40
+ method: "post",
41
+ url: "/users",
42
+ data: {
43
+ username: username
44
+ }
45
+ });
46
+ }
47
+ function getUser({ user_id }) {
48
+ return axiosInstance({
49
+ operationId: "getUser",
50
+ method: "get",
51
+ url: "/users/" + user_id + ""
52
+ });
53
+ }
54
+ //--------------------------------------------------------------------------
55
+ // Updates the details of the target user.
56
+ function updateUser({ user_id, username }) {
57
+ return axiosInstance({
58
+ operationId: "updateUser",
59
+ method: "patch",
60
+ url: "/users/" + user_id + "",
61
+ data: {
62
+ username: username
63
+ }
64
+ });
65
+ }
66
+ function deleteUser({ user_id }) {
67
+ return axiosInstance({
68
+ operationId: "deleteUser",
69
+ method: "delete",
70
+ url: "/users/" + user_id + ""
71
+ });
72
+ }
73
+ function generateUserToken({ user_id, scope, ttl = '1h' }) {
74
+ return axiosInstance({
75
+ operationId: "generateUserToken",
76
+ method: "post",
77
+ url: "/users/" + user_id + "/tokens",
78
+ data: {
79
+ scope: scope,
80
+ ttl: ttl
81
+ }
82
+ });
83
+ }
84
+ function getUserGroups({ user_id }) {
85
+ return axiosInstance({
86
+ operationId: "getUserGroups",
87
+ method: "get",
88
+ url: "/users/" + user_id + "/groups"
89
+ });
90
+ }
91
+ function getUserUploadTasks({ user_id, offset = 0, limit = 10 }) {
92
+ return axiosInstance({
93
+ operationId: "getUserUploadTasks",
94
+ method: "get",
95
+ url: "/users/" + user_id + "/upload-tasks",
96
+ params: {
97
+ offset: offset,
98
+ limit: limit
99
+ }
100
+ });
101
+ }
102
+ function createGroup({ group_name, group_description, members }) {
103
+ return axiosInstance({
104
+ operationId: "createGroup",
105
+ method: "post",
106
+ url: "/groups",
107
+ data: {
108
+ group_name: group_name,
109
+ group_description: group_description,
110
+ members: members
111
+ }
112
+ });
113
+ }
114
+ function getGroup({ group_id }) {
115
+ return axiosInstance({
116
+ operationId: "getGroup",
117
+ method: "get",
118
+ url: "/groups/" + group_id + ""
119
+ });
120
+ }
121
+ //--------------------------------------------------------------------------
122
+ // Updates a group details.
123
+ function updateGroupDescription({ group_id, group_name, group_description }) {
124
+ return axiosInstance({
125
+ operationId: "updateGroupDescription",
126
+ method: "patch",
127
+ url: "/groups/" + group_id + "",
128
+ data: {
129
+ group_name: group_name,
130
+ group_description: group_description
131
+ }
132
+ });
133
+ }
134
+ //--------------------------------------------------------------------------
135
+ // Deletes a group and all its access rights.
136
+ function deleteGroup({ group_id }) {
137
+ return axiosInstance({
138
+ operationId: "deleteGroup",
139
+ method: "delete",
140
+ url: "/groups/" + group_id + ""
141
+ });
142
+ }
143
+ //--------------------------------------------------------------------------
144
+ // Grants member access to the group.
145
+ function grantMemberAccessToGroup({ group_id, member_type, member_id, group_access, folder_access }) {
146
+ return axiosInstance({
147
+ operationId: "grantMemberAccessToGroup",
148
+ method: "put",
149
+ url: "/groups/" + group_id + "/members/" + member_type + "/" + member_id + "",
150
+ data: {
151
+ group_access: group_access,
152
+ folder_access: folder_access
153
+ }
154
+ });
155
+ }
156
+ //--------------------------------------------------------------------------
157
+ // Revoke requested user access to group.
158
+ function revokeMemberAccessToGroup({ group_id, member_type, member_id }) {
159
+ return axiosInstance({
160
+ operationId: "revokeMemberAccessToGroup",
161
+ method: "delete",
162
+ url: "/groups/" + group_id + "/members/" + member_type + "/" + member_id + ""
163
+ });
164
+ }
165
+ function listFolders({ offset = 0, limit = 10 }) {
166
+ return axiosInstance({
167
+ operationId: "listFolders",
168
+ method: "get",
169
+ url: "/folders",
170
+ params: {
171
+ offset: offset,
172
+ limit: limit
173
+ }
174
+ });
175
+ }
176
+ function createFolder({ folder_name, subfolders }) {
177
+ return axiosInstance({
178
+ operationId: "createFolder",
179
+ method: "post",
180
+ url: "/folders",
181
+ data: {
182
+ folder_name: folder_name,
183
+ subfolders: subfolders
184
+ }
185
+ });
186
+ }
187
+ function getFolderInfo({ folder_id }) {
188
+ return axiosInstance({
189
+ operationId: "getFolderInfo",
190
+ method: "get",
191
+ url: "/folders/" + folder_id + ""
192
+ });
193
+ }
194
+ //--------------------------------------------------------------------------
195
+ // Move folders inside the specified folder.
196
+ function moveFolders({ folder_id, folderIds }) {
197
+ return axiosInstance({
198
+ operationId: "moveFolders",
199
+ method: "put",
200
+ url: "/folders/" + folder_id + "",
201
+ data: folderIds
202
+ });
203
+ }
204
+ //--------------------------------------------------------------------------
205
+ // Updates the folder details.
206
+ function updateFolder({ folder_id, folder_name }) {
207
+ return axiosInstance({
208
+ operationId: "updateFolder",
209
+ method: "patch",
210
+ url: "/folders/" + folder_id + "",
211
+ data: {
212
+ folder_name: folder_name
213
+ }
214
+ });
215
+ }
216
+ //--------------------------------------------------------------------------
217
+ // Deletes the requested folder. The target folder must be empty.
218
+ function deleteFolder({ folder_id }) {
219
+ return axiosInstance({
220
+ operationId: "deleteFolder",
221
+ method: "delete",
222
+ url: "/folders/" + folder_id + ""
223
+ });
224
+ }
225
+ function listFolderAccesses({ folder_id }) {
226
+ return axiosInstance({
227
+ operationId: "listFolderAccesses",
228
+ method: "get",
229
+ url: "/folders/" + folder_id + "/access"
230
+ });
231
+ }
232
+ //--------------------------------------------------------------------------
233
+ // Grants member access to the targeted folder.
234
+ function grantMemberAccessToFolder({ folder_id, member_type, member_id, access }) {
235
+ return axiosInstance({
236
+ operationId: "grantMemberAccessToFolder",
237
+ method: "put",
238
+ url: "/folders/" + folder_id + "/access/" + member_type + "/" + member_id + "",
239
+ data: {
240
+ access: access
241
+ }
242
+ });
243
+ }
244
+ //--------------------------------------------------------------------------
245
+ // Revokes member access to a target folder.
246
+ function revokeMemberAccessToFolder({ folder_id, member_type, member_id }) {
247
+ return axiosInstance({
248
+ operationId: "revokeMemberAccessToFolder",
249
+ method: "delete",
250
+ url: "/folders/" + folder_id + "/access/" + member_type + "/" + member_id + ""
251
+ });
252
+ }
253
+ function createSubfolder({ folder_id, folder_name, subfolders }) {
254
+ return axiosInstance({
255
+ operationId: "createSubfolder",
256
+ method: "post",
257
+ url: "/folders/" + folder_id + "/folders",
258
+ data: {
259
+ folder_name: folder_name,
260
+ subfolders: subfolders
261
+ }
262
+ });
263
+ }
264
+ function listFolderSubFolders({ folder_id, depth = 0 }) {
265
+ return axiosInstance({
266
+ operationId: "listFolderSubFolders",
267
+ method: "get",
268
+ url: "/folders/" + folder_id + "/folders",
269
+ params: {
270
+ depth: depth
271
+ }
272
+ });
273
+ }
274
+ function uploadSourceFiles({ folder_id, body }) {
275
+ return axiosInstance({
276
+ operationId: "uploadSourceFiles",
277
+ method: "post",
278
+ url: "/folders/" + folder_id + "/source-files",
279
+ headers: {
280
+ "Content-Type": "multipart/form-data"
281
+ },
282
+ data: body
283
+ });
284
+ }
285
+ function getSourceFilesInFolder({ folder_id, offset = 0, limit = 10 }) {
286
+ return axiosInstance({
287
+ operationId: "getSourceFilesInFolder",
288
+ method: "get",
289
+ url: "/folders/" + folder_id + "/source-files",
290
+ params: {
291
+ offset: offset,
292
+ limit: limit
293
+ }
294
+ });
295
+ }
296
+ //--------------------------------------------------------------------------
297
+ // Move source files inside the specified folder.
298
+ function moveSourceFiles({ folder_id, sourceFileIds }) {
299
+ return axiosInstance({
300
+ operationId: "moveSourceFiles",
301
+ method: "put",
302
+ url: "/folders/" + folder_id + "/source-files",
303
+ data: sourceFileIds
304
+ });
305
+ }
306
+ function getUploadTasksInFolder({ folder_id, offset = 0, limit = 10 }) {
307
+ return axiosInstance({
308
+ operationId: "getUploadTasksInFolder",
309
+ method: "get",
310
+ url: "/folders/" + folder_id + "/upload-tasks",
311
+ params: {
312
+ offset: offset,
313
+ limit: limit
314
+ }
315
+ });
316
+ }
317
+ function getFolderAssets({ folder_id, offset = 0, limit = 10 }) {
318
+ return axiosInstance({
319
+ operationId: "getFolderAssets",
320
+ method: "get",
321
+ url: "/folders/" + folder_id + "/assets",
322
+ params: {
323
+ offset: offset,
324
+ limit: limit
325
+ }
326
+ });
327
+ }
328
+ //--------------------------------------------------------------------------
329
+ // Move assets inside the specified folder.
330
+ function moveAssets({ folder_id, assetIds }) {
331
+ return axiosInstance({
332
+ operationId: "moveAssets",
333
+ method: "put",
334
+ url: "/folders/" + folder_id + "/assets",
335
+ data: assetIds
336
+ });
337
+ }
338
+ function createAsset({ folder_id, asset_container_creatable, assetCreationOptions }) {
339
+ return axiosInstance({
340
+ operationId: "createAsset",
341
+ method: "post",
342
+ url: "/folders/" + folder_id + "/assets/" + asset_container_creatable + "",
343
+ data: assetCreationOptions
344
+ });
345
+ }
346
+ function getSessionsInFolder({ folder_id }) {
347
+ return axiosInstance({
348
+ operationId: "getSessionsInFolder",
349
+ method: "get",
350
+ url: "/folders/" + folder_id + "/sessions"
351
+ });
352
+ }
353
+ function listSourceFiles({ offset = 0, limit = 10 }) {
354
+ return axiosInstance({
355
+ operationId: "listSourceFiles",
356
+ method: "get",
357
+ url: "/source-files",
358
+ params: {
359
+ offset: offset,
360
+ limit: limit
361
+ }
362
+ });
363
+ }
364
+ //--------------------------------------------------------------------------
365
+ // Deletes the target source files. Deleting a source file is permanent.
366
+ function deleteSourceFiles({ sourceFileIds }) {
367
+ return axiosInstance({
368
+ operationId: "deleteSourceFiles",
369
+ method: "delete",
370
+ url: "/source-files",
371
+ data: sourceFileIds
372
+ });
373
+ }
374
+ //--------------------------------------------------------------------------
375
+ // Downloads the target source file.
376
+ function downloadSourceFile({ source_file_id }) {
377
+ return axiosInstance({
378
+ operationId: "downloadSourceFile",
379
+ method: "get",
380
+ url: "/source-files/" + source_file_id + "",
381
+ responseType: "arraybuffer"
382
+ });
383
+ }
384
+ function getSourceFileDetails({ source_file_id }) {
385
+ return axiosInstance({
386
+ operationId: "getSourceFileDetails",
387
+ method: "get",
388
+ url: "/source-files/" + source_file_id + "/details"
389
+ });
390
+ }
391
+ //--------------------------------------------------------------------------
392
+ // Updates details for a specific source file.
393
+ function updateSourceFileDetails({ source_file_id, source_file_name }) {
394
+ return axiosInstance({
395
+ operationId: "updateSourceFileDetails",
396
+ method: "patch",
397
+ url: "/source-files/" + source_file_id + "/details",
398
+ data: {
399
+ source_file_name: source_file_name
400
+ }
401
+ });
402
+ }
403
+ function getSourceFileAssets({ source_file_id }) {
404
+ return axiosInstance({
405
+ operationId: "getSourceFileAssets",
406
+ method: "get",
407
+ url: "/source-files/" + source_file_id + "/assets"
408
+ });
409
+ }
410
+ function getUploadTask({ upload_task_id }) {
411
+ return axiosInstance({
412
+ operationId: "getUploadTask",
413
+ method: "get",
414
+ url: "/upload-tasks/" + upload_task_id + ""
415
+ });
416
+ }
417
+ function listAssets({ offset = 0, limit = 10 }) {
418
+ return axiosInstance({
419
+ operationId: "listAssets",
420
+ method: "get",
421
+ url: "/assets",
422
+ params: {
423
+ offset: offset,
424
+ limit: limit
425
+ }
426
+ });
427
+ }
428
+ //--------------------------------------------------------------------------
429
+ // Batch delete assets. You **MUST NOT** reference assets.
430
+ function deleteAssets({ assetIds }) {
431
+ return axiosInstance({
432
+ operationId: "deleteAssets",
433
+ method: "delete",
434
+ url: "/assets",
435
+ data: assetIds
436
+ });
437
+ }
438
+ //--------------------------------------------------------------------------
439
+ // Deletes the asset.
440
+ function deleteAsset({ asset_container, asset_id }) {
441
+ return axiosInstance({
442
+ operationId: "deleteAsset",
443
+ method: "delete",
444
+ url: "/assets/" + asset_container + "/" + asset_id + ""
445
+ });
446
+ }
447
+ function getAssetSourceFile({ asset_container, asset_id }) {
448
+ return axiosInstance({
449
+ operationId: "getAssetSourceFile",
450
+ method: "get",
451
+ url: "/assets/" + asset_container + "/" + asset_id + "/source-file"
452
+ });
453
+ }
454
+ function getAssetDetails({ asset_container, asset_id }) {
455
+ return axiosInstance({
456
+ operationId: "getAssetDetails",
457
+ method: "get",
458
+ url: "/assets/" + asset_container + "/" + asset_id + "/details"
459
+ });
460
+ }
461
+ function getAssetFolder({ asset_container, asset_id }) {
462
+ return axiosInstance({
463
+ operationId: "getAssetFolder",
464
+ method: "get",
465
+ url: "/assets/" + asset_container + "/" + asset_id + "/folder"
466
+ });
467
+ }
468
+ function getAssetDependencies({ asset_container, asset_id, format = 'flat', depth = 'all', filter }) {
469
+ return axiosInstance({
470
+ operationId: "getAssetDependencies",
471
+ method: "get",
472
+ url: "/assets/" + asset_container + "/" + asset_id + "/dependencies",
473
+ params: {
474
+ format: format,
475
+ depth: depth,
476
+ filter: filter
477
+ }
478
+ });
479
+ }
480
+ function getAssetReferences({ asset_container, asset_id }) {
481
+ return axiosInstance({
482
+ operationId: "getAssetReferences",
483
+ method: "get",
484
+ url: "/assets/" + asset_container + "/" + asset_id + "/references"
485
+ });
486
+ }
487
+ function getAssetDescription({ asset_container, asset_id }) {
488
+ return axiosInstance({
489
+ operationId: "getAssetDescription",
490
+ method: "get",
491
+ url: "/assets/" + asset_container + "/" + asset_id + "/description"
492
+ });
493
+ }
494
+ function updateAssetDescription({ asset_container, asset_id, assetDescription }) {
495
+ return axiosInstance({
496
+ operationId: "updateAssetDescription",
497
+ method: "patch",
498
+ url: "/assets/" + asset_container + "/" + asset_id + "/description",
499
+ data: assetDescription
500
+ });
501
+ }
502
+ //--------------------------------------------------------------------------
503
+ // Gets the asset payload from the specified asset.
504
+ function getAssetPayload({ asset_container_with_payload, asset_id }) {
505
+ return axiosInstance({
506
+ operationId: "getAssetPayload",
507
+ method: "get",
508
+ url: "/assets/" + asset_container_with_payload + "/" + asset_id + "/payload",
509
+ responseType: "arraybuffer"
510
+ });
511
+ }
512
+ function getAssetHistory({ asset_container, asset_id }) {
513
+ return axiosInstance({
514
+ operationId: "getAssetHistory",
515
+ method: "get",
516
+ url: "/assets/" + asset_container + "/" + asset_id + "/history"
517
+ });
518
+ }
519
+ function getAssetMeta({ asset_container, asset_id }) {
520
+ return axiosInstance({
521
+ operationId: "getAssetMeta",
522
+ method: "get",
523
+ url: "/assets/" + asset_container + "/" + asset_id + "/meta"
524
+ });
525
+ }
526
+ //--------------------------------------------------------------------------
527
+ // Gets the code of the specified asset.
528
+ function getAssetCode({ asset_container_with_code, asset_id }) {
529
+ return axiosInstance({
530
+ operationId: "getAssetCode",
531
+ method: "get",
532
+ url: "/assets/" + asset_container_with_code + "/" + asset_id + "/code"
533
+ });
534
+ }
535
+ //--------------------------------------------------------------------------
536
+ // Gets the asset thumbnail from the specified asset.
537
+ function getAssetThumbnail({ asset_container, asset_id, size, default_url }) {
538
+ return axiosInstance({
539
+ operationId: "getAssetThumbnail",
540
+ method: "get",
541
+ url: "/assets/" + asset_container + "/" + asset_id + "/thumbnail",
542
+ params: {
543
+ size: size,
544
+ default_url: default_url
545
+ }
546
+ });
547
+ }
548
+ //--------------------------------------------------------------------------
549
+ // Assigns a thumbnail to the specified asset.
550
+ function setAssetThumbnail({ asset_container, asset_id, body }, contentType) {
551
+ return axiosInstance({
552
+ operationId: "setAssetThumbnail",
553
+ method: "put",
554
+ url: "/assets/" + asset_container + "/" + asset_id + "/thumbnail",
555
+ headers: {
556
+ "Content-Type": contentType
557
+ },
558
+ data: body
559
+ });
560
+ }
561
+ function getAssetCustomTypes({ asset_container_with_custom_types, asset_id }) {
562
+ return axiosInstance({
563
+ operationId: "getAssetCustomTypes",
564
+ method: "get",
565
+ url: "/assets/" + asset_container_with_custom_types + "/" + asset_id + "/custom-types"
566
+ });
567
+ }
568
+ //--------------------------------------------------------------------------
569
+ // Packages and downloads the target asset.
570
+ function packageAsset({ asset_container, asset_id }) {
571
+ return axiosInstance({
572
+ operationId: "packageAsset",
573
+ method: "get",
574
+ url: "/assets/" + asset_container + "/" + asset_id + "/package",
575
+ responseType: "arraybuffer"
576
+ });
577
+ }
578
+ //--------------------------------------------------------------------------
579
+ // Downloads an asset payload in a given format. Only mesh is supported for the moment. This endpoint requires special export permission.
580
+ function exportAsset({ asset_container_exportable, asset_id, format, scale = 1 }) {
581
+ return axiosInstance({
582
+ operationId: "exportAsset",
583
+ method: "get",
584
+ url: "/assets/" + asset_container_exportable + "/" + asset_id + "/exports/" + format + "",
585
+ responseType: "arraybuffer",
586
+ params: {
587
+ scale: scale
588
+ }
589
+ });
590
+ }
591
+ function getSceneSessions({ scene_id }) {
592
+ return axiosInstance({
593
+ operationId: "getSceneSessions",
594
+ method: "get",
595
+ url: "/assets/scenes/" + scene_id + "/sessions"
596
+ });
597
+ }
598
+ function getSceneAABB({ scene_id }) {
599
+ return axiosInstance({
600
+ operationId: "getSceneAABB",
601
+ method: "get",
602
+ url: "/assets/scenes/" + scene_id + "/aabb"
603
+ });
604
+ }
605
+ function getEntity({ scene_id, entity_id, compute_global_transform = false }) {
606
+ return axiosInstance({
607
+ operationId: "getEntity",
608
+ method: "get",
609
+ url: "/assets/scenes/" + scene_id + "/entities/" + entity_id + "",
610
+ params: {
611
+ compute_global_transform: compute_global_transform
612
+ }
613
+ });
614
+ }
615
+ function updateEntity({ scene_id, entity_id, entity }) {
616
+ return axiosInstance({
617
+ operationId: "updateEntity",
618
+ method: "patch",
619
+ url: "/assets/scenes/" + scene_id + "/entities/" + entity_id + "",
620
+ data: entity
621
+ });
622
+ }
623
+ //--------------------------------------------------------------------------
624
+ // Delete a specific entity from a scene
625
+ function deleteEntity({ scene_id, entity_id }) {
626
+ return axiosInstance({
627
+ operationId: "deleteEntity",
628
+ method: "delete",
629
+ url: "/assets/scenes/" + scene_id + "/entities/" + entity_id + ""
630
+ });
631
+ }
632
+ function createSession({ scene_id }) {
633
+ return axiosInstance({
634
+ operationId: "createSession",
635
+ method: "post",
636
+ url: "/sessions",
637
+ data: {
638
+ scene_id: scene_id
639
+ }
640
+ });
641
+ }
642
+ function getSession({ session_id }) {
643
+ return axiosInstance({
644
+ operationId: "getSession",
645
+ method: "get",
646
+ url: "/sessions/" + session_id + ""
647
+ });
648
+ }
649
+ //--------------------------------------------------------------------------
650
+ // Forcefully terminates a session.
651
+ function killSession({ session_id }) {
652
+ return axiosInstance({
653
+ operationId: "killSession",
654
+ method: "delete",
655
+ url: "/sessions/" + session_id + ""
656
+ });
657
+ }
658
+ function joinSession({ session_id }) {
659
+ return axiosInstance({
660
+ operationId: "joinSession",
661
+ method: "post",
662
+ url: "/sessions/" + session_id + "/clients"
663
+ });
664
+ }
665
+ //--------------------------------------------------------------------------
666
+ // Kick a client from a running session.
667
+ function kickClientFromSession({ session_id, client_id }) {
668
+ return axiosInstance({
669
+ operationId: "kickClientFromSession",
670
+ method: "delete",
671
+ url: "/sessions/" + session_id + "/clients/" + client_id + ""
672
+ });
673
+ }
674
+ function joinSessionAsGuest() {
675
+ return axiosInstance({
676
+ operationId: "joinSessionAsGuest",
677
+ method: "post",
678
+ url: "/sessions/guests"
679
+ });
680
+ }
681
+ function generateGuestToken({ session_id }) {
682
+ return axiosInstance({
683
+ operationId: "generateGuestToken",
684
+ method: "post",
685
+ url: "/sessions/" + session_id + "/guests"
686
+ });
687
687
  }
688
688
 
689
- //------------------------------------------------------------------------------
690
- function setApiKey(apiKey) {
691
- axiosInstance.defaults.headers.common['api_key'] = apiKey;
692
- delete axiosInstance.defaults.headers.common['user_token'];
693
- }
694
- //------------------------------------------------------------------------------
695
- function setUserToken(userToken) {
696
- axiosInstance.defaults.headers.common['user_token'] = userToken;
697
- delete axiosInstance.defaults.headers.common['api_key'];
698
- }
699
- //------------------------------------------------------------------------------
700
- function setBaseUrl(url) {
701
- axiosInstance.defaults.baseURL = url;
702
- }
703
- //------------------------------------------------------------------------------
704
- class ServiceError extends Error {
705
- errorCode;
706
- httpCode;
707
- message;
708
- //--------------------------------------------------------------------------
709
- constructor(errorCode, httpCode, message) {
710
- super();
711
- this.errorCode = errorCode;
712
- this.httpCode = httpCode;
713
- this.message = message;
714
- }
715
- }
716
- //------------------------------------------------------------------------------
717
- class ApiError extends ServiceError {
718
- serviceError;
719
- constructor(errorCode, status, message, serviceError) {
720
- super(errorCode, status, message);
721
- this.serviceError = serviceError;
722
- }
723
- }
724
- //------------------------------------------------------------------------------
725
- class UnexpectedServiceError extends ServiceError {
726
- unexpectedError;
727
- constructor(status, unexpectedError) {
728
- super(0, status, 'Unexpected service error error');
729
- this.unexpectedError = unexpectedError;
730
- }
731
- }
732
- //------------------------------------------------------------------------------
733
- function installInterceptors() {
734
- const CLIENT_ERROR = 400;
735
- const INTERNAL_SERVER_ERROR = 500;
736
- axiosInstance.interceptors.response.use(successFulResponse => {
737
- if (successFulResponse.config.responseType === 'stream') {
738
- successFulResponse.data.pause();
739
- }
740
- return successFulResponse;
741
- }, error => {
742
- if (!error.response) {
743
- return Promise.reject(error);
744
- }
745
- const axiosError = error;
746
- const status = axiosError.response?.status || INTERNAL_SERVER_ERROR;
747
- const errorData = axiosError.response?.data;
748
- if (!errorData &&
749
- axiosError.request.method === 'HEAD' &&
750
- status >= CLIENT_ERROR &&
751
- status < INTERNAL_SERVER_ERROR) {
752
- return axiosError.response;
753
- }
754
- if (!errorData || !('error' in errorData)) {
755
- return Promise.reject(new UnexpectedServiceError(status, errorData));
756
- }
757
- const serviceError = errorData.error;
758
- return Promise.reject(new ApiError(serviceError.errorCode, status, serviceError.message, serviceError));
759
- });
760
- }
761
- //------------------------------------------------------------------------------
689
+ //------------------------------------------------------------------------------
690
+ function setApiKey(apiKey) {
691
+ axiosInstance.defaults.headers.common['api_key'] = apiKey;
692
+ delete axiosInstance.defaults.headers.common['user_token'];
693
+ }
694
+ //------------------------------------------------------------------------------
695
+ function setUserToken(userToken) {
696
+ axiosInstance.defaults.headers.common['user_token'] = userToken;
697
+ delete axiosInstance.defaults.headers.common['api_key'];
698
+ }
699
+ //------------------------------------------------------------------------------
700
+ function setBaseUrl(url) {
701
+ axiosInstance.defaults.baseURL = url;
702
+ }
703
+ //------------------------------------------------------------------------------
704
+ class ServiceError extends Error {
705
+ errorCode;
706
+ httpCode;
707
+ message;
708
+ //--------------------------------------------------------------------------
709
+ constructor(errorCode, httpCode, message) {
710
+ super();
711
+ this.errorCode = errorCode;
712
+ this.httpCode = httpCode;
713
+ this.message = message;
714
+ }
715
+ }
716
+ //------------------------------------------------------------------------------
717
+ class ApiError extends ServiceError {
718
+ serviceError;
719
+ constructor(errorCode, status, message, serviceError) {
720
+ super(errorCode, status, message);
721
+ this.serviceError = serviceError;
722
+ }
723
+ }
724
+ //------------------------------------------------------------------------------
725
+ class UnexpectedServiceError extends ServiceError {
726
+ unexpectedError;
727
+ constructor(status, unexpectedError) {
728
+ super(0, status, 'Unexpected service error error');
729
+ this.unexpectedError = unexpectedError;
730
+ }
731
+ }
732
+ //------------------------------------------------------------------------------
733
+ function installInterceptors() {
734
+ const CLIENT_ERROR = 400;
735
+ const INTERNAL_SERVER_ERROR = 500;
736
+ axiosInstance.interceptors.response.use(successFulResponse => {
737
+ if (successFulResponse.config.responseType === 'stream') {
738
+ successFulResponse.data.pause();
739
+ }
740
+ return successFulResponse;
741
+ }, error => {
742
+ if (!error.response) {
743
+ return Promise.reject(error);
744
+ }
745
+ const axiosError = error;
746
+ const status = axiosError.response?.status || INTERNAL_SERVER_ERROR;
747
+ const errorData = axiosError.response?.data;
748
+ if (!errorData &&
749
+ axiosError.request.method === 'HEAD' &&
750
+ status >= CLIENT_ERROR &&
751
+ status < INTERNAL_SERVER_ERROR) {
752
+ return axiosError.response;
753
+ }
754
+ if (!errorData || !('error' in errorData)) {
755
+ return Promise.reject(new UnexpectedServiceError(status, errorData));
756
+ }
757
+ const serviceError = errorData.error;
758
+ return Promise.reject(new ApiError(serviceError.errorCode, status, serviceError.message, serviceError));
759
+ });
760
+ }
761
+ //------------------------------------------------------------------------------
762
762
  installInterceptors();
763
763
 
764
764
  export { ApiError, UnexpectedServiceError, axiosInstance, createAsset, createFolder, createGroup, createSession, createSubfolder, deleteAsset, deleteAssets, deleteEntity, deleteFolder, deleteGroup, deleteSourceFiles, deleteUser, downloadSourceFile, exportAsset, generateGuestToken, generateUserToken, getAssetCode, getAssetCustomTypes, getAssetDependencies, getAssetDescription, getAssetDetails, getAssetFolder, getAssetHistory, getAssetMeta, getAssetPayload, getAssetReferences, getAssetSourceFile, getAssetThumbnail, getEntity, getFolderAssets, getFolderInfo, getGroup, getSceneAABB, getSceneSessions, getSession, getSessionsInFolder, getSourceFileAssets, getSourceFileDetails, getSourceFilesInFolder, getUploadTask, getUploadTasksInFolder, getUser, getUserGroups, getUserUploadTasks, grantMemberAccessToFolder, grantMemberAccessToGroup, joinSession, joinSessionAsGuest, kickClientFromSession, killSession, listAssets, listFolderAccesses, listFolderSubFolders, listFolders, listSourceFiles, listUsers, moveAssets, moveFolders, moveSourceFiles, packageAsset, registerUser, revokeMemberAccessToFolder, revokeMemberAccessToGroup, setApiKey, setAssetThumbnail, setBaseURL, setBaseUrl, setUserToken, updateAssetDescription, updateEntity, updateFolder, updateGroupDescription, updateSourceFileDetails, updateUser, uploadSourceFiles };