@rtsdk/topia 0.0.20 → 0.0.21
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/index.js +4 -4
- package/dist/src/__mocks__/assets.js +4 -4
- package/dist/src/controllers/Asset.js +2 -4
- package/dist/src/controllers/DroppedAsset.js +29 -31
- package/dist/src/controllers/SDKController.js +28 -0
- package/dist/src/controllers/User.js +7 -9
- package/dist/src/controllers/Visitor.js +4 -6
- package/dist/src/controllers/World.js +13 -13
- package/dist/src/controllers/__tests__/droppedAsset.test.js +1 -1
- package/dist/src/factories/DroppedAssetFactory.js +5 -6
- package/dist/src/index.js +12 -1
- package/dist/src/utils/index.js +0 -1
- package/package.json +1 -1
|
@@ -54,7 +54,7 @@ export const droppedAssets = [
|
|
|
54
54
|
assetBroadcastAll: false,
|
|
55
55
|
assetBroadcast: false,
|
|
56
56
|
audioRadius: null,
|
|
57
|
-
|
|
57
|
+
audioSliderVolume: null,
|
|
58
58
|
isPrivateZone: false,
|
|
59
59
|
isPrivateZoneChatDisabled: false,
|
|
60
60
|
privateZoneUserCap: null,
|
|
@@ -104,7 +104,7 @@ export const droppedAssets = [
|
|
|
104
104
|
assetBroadcastAll: false,
|
|
105
105
|
assetBroadcast: false,
|
|
106
106
|
audioRadius: null,
|
|
107
|
-
|
|
107
|
+
audioSliderVolume: null,
|
|
108
108
|
isPrivateZone: false,
|
|
109
109
|
isPrivateZoneChatDisabled: false,
|
|
110
110
|
privateZoneUserCap: null,
|
|
@@ -154,7 +154,7 @@ export const droppedAssets = [
|
|
|
154
154
|
assetBroadcastAll: false,
|
|
155
155
|
assetBroadcast: false,
|
|
156
156
|
audioRadius: null,
|
|
157
|
-
|
|
157
|
+
audioSliderVolume: null,
|
|
158
158
|
isPrivateZone: false,
|
|
159
159
|
isPrivateZoneChatDisabled: false,
|
|
160
160
|
privateZoneUserCap: null,
|
|
@@ -204,7 +204,7 @@ export const droppedAssets = [
|
|
|
204
204
|
assetBroadcastAll: false,
|
|
205
205
|
assetBroadcast: false,
|
|
206
206
|
audioRadius: null,
|
|
207
|
-
|
|
207
|
+
audioSliderVolume: null,
|
|
208
208
|
isPrivateZone: false,
|
|
209
209
|
isPrivateZoneChatDisabled: false,
|
|
210
210
|
privateZoneUserCap: null,
|
|
@@ -9,8 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
// controllers
|
|
11
11
|
import { SDKController } from "controllers/SDKController";
|
|
12
|
-
// utils
|
|
13
|
-
import { getErrorResponse } from "utils";
|
|
14
12
|
/**
|
|
15
13
|
* @summary
|
|
16
14
|
* Create an instance of Asset class with a given asset id and optional attributes and session credentials.
|
|
@@ -29,11 +27,11 @@ export class Asset extends SDKController {
|
|
|
29
27
|
fetchPlatformAssets() {
|
|
30
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
29
|
try {
|
|
32
|
-
const response = yield this.
|
|
30
|
+
const response = yield this.topiaPublicApi().get("/assets/topia-assets", this.requestOptions);
|
|
33
31
|
return response.data;
|
|
34
32
|
}
|
|
35
33
|
catch (error) {
|
|
36
|
-
throw
|
|
34
|
+
throw this.errorHandler({ error });
|
|
37
35
|
}
|
|
38
36
|
});
|
|
39
37
|
}
|
|
@@ -15,8 +15,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
15
15
|
var _DroppedAsset_updateDroppedAsset;
|
|
16
16
|
// controllers
|
|
17
17
|
import { Asset } from "controllers/Asset";
|
|
18
|
-
// utils
|
|
19
|
-
import { getErrorResponse } from "utils";
|
|
20
18
|
/**
|
|
21
19
|
* @summary
|
|
22
20
|
* Create an instance of Dropped Asset class with a given dropped asset id, url slug, and optional attributes and session credentials.
|
|
@@ -33,10 +31,10 @@ export class DroppedAsset extends Asset {
|
|
|
33
31
|
// update dropped assets
|
|
34
32
|
_DroppedAsset_updateDroppedAsset.set(this, (payload, updateType) => __awaiter(this, void 0, void 0, function* () {
|
|
35
33
|
try {
|
|
36
|
-
yield this.
|
|
34
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/${updateType}`, Object.assign({}, payload), this.requestOptions);
|
|
37
35
|
}
|
|
38
36
|
catch (error) {
|
|
39
|
-
throw
|
|
37
|
+
throw this.errorHandler({ error });
|
|
40
38
|
}
|
|
41
39
|
}));
|
|
42
40
|
this.id = id;
|
|
@@ -57,11 +55,11 @@ export class DroppedAsset extends Asset {
|
|
|
57
55
|
fetchDroppedAssetById() {
|
|
58
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
57
|
try {
|
|
60
|
-
const response = yield this.
|
|
58
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/assets/${this.id}`, this.requestOptions);
|
|
61
59
|
Object.assign(this, response.data);
|
|
62
60
|
}
|
|
63
61
|
catch (error) {
|
|
64
|
-
throw
|
|
62
|
+
throw this.errorHandler({ error });
|
|
65
63
|
}
|
|
66
64
|
});
|
|
67
65
|
}
|
|
@@ -69,10 +67,10 @@ export class DroppedAsset extends Asset {
|
|
|
69
67
|
deleteDroppedAsset() {
|
|
70
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
69
|
try {
|
|
72
|
-
yield this.
|
|
70
|
+
yield this.topiaPublicApi().delete(`/world/${this.urlSlug}/assets/${this.id}`, this.requestOptions);
|
|
73
71
|
}
|
|
74
72
|
catch (error) {
|
|
75
|
-
throw
|
|
73
|
+
throw this.errorHandler({ error });
|
|
76
74
|
}
|
|
77
75
|
});
|
|
78
76
|
}
|
|
@@ -90,11 +88,11 @@ export class DroppedAsset extends Asset {
|
|
|
90
88
|
fetchDroppedAssetDataObject() {
|
|
91
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
90
|
try {
|
|
93
|
-
const response = yield this.
|
|
91
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/assets/${this.id}/data-object`, this.requestOptions);
|
|
94
92
|
this.dataObject = response.data;
|
|
95
93
|
}
|
|
96
94
|
catch (error) {
|
|
97
|
-
throw
|
|
95
|
+
throw this.errorHandler({ error });
|
|
98
96
|
}
|
|
99
97
|
});
|
|
100
98
|
}
|
|
@@ -117,11 +115,11 @@ export class DroppedAsset extends Asset {
|
|
|
117
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
116
|
try {
|
|
119
117
|
const { lock = {} } = options;
|
|
120
|
-
yield this.
|
|
118
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/set-data-object`, { dataObject, lock }, this.requestOptions);
|
|
121
119
|
this.dataObject = dataObject;
|
|
122
120
|
}
|
|
123
121
|
catch (error) {
|
|
124
|
-
throw
|
|
122
|
+
throw this.errorHandler({ error });
|
|
125
123
|
}
|
|
126
124
|
});
|
|
127
125
|
}
|
|
@@ -144,11 +142,11 @@ export class DroppedAsset extends Asset {
|
|
|
144
142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
145
143
|
try {
|
|
146
144
|
const { lock = {} } = options;
|
|
147
|
-
yield this.
|
|
145
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/update-data-object`, { dataObject, lock }, this.requestOptions);
|
|
148
146
|
this.dataObject = dataObject;
|
|
149
147
|
}
|
|
150
148
|
catch (error) {
|
|
151
|
-
throw
|
|
149
|
+
throw this.errorHandler({ error });
|
|
152
150
|
}
|
|
153
151
|
});
|
|
154
152
|
}
|
|
@@ -170,7 +168,7 @@ export class DroppedAsset extends Asset {
|
|
|
170
168
|
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { assetBroadcast, assetBroadcastAll, broadcasterEmail }, "set-asset-broadcast");
|
|
171
169
|
}
|
|
172
170
|
catch (error) {
|
|
173
|
-
throw
|
|
171
|
+
throw this.errorHandler({ error });
|
|
174
172
|
}
|
|
175
173
|
}
|
|
176
174
|
/**
|
|
@@ -206,7 +204,7 @@ export class DroppedAsset extends Asset {
|
|
|
206
204
|
}, "change-click-type");
|
|
207
205
|
}
|
|
208
206
|
catch (error) {
|
|
209
|
-
throw
|
|
207
|
+
throw this.errorHandler({ error });
|
|
210
208
|
}
|
|
211
209
|
}
|
|
212
210
|
/**
|
|
@@ -230,7 +228,7 @@ export class DroppedAsset extends Asset {
|
|
|
230
228
|
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { style, text }, "set-custom-text");
|
|
231
229
|
}
|
|
232
230
|
catch (error) {
|
|
233
|
-
throw
|
|
231
|
+
throw this.errorHandler({ error });
|
|
234
232
|
}
|
|
235
233
|
}
|
|
236
234
|
/**
|
|
@@ -244,19 +242,19 @@ export class DroppedAsset extends Asset {
|
|
|
244
242
|
* "mediaLink": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
|
|
245
243
|
* "isVideo": true,
|
|
246
244
|
* "syncUserMedia": true,
|
|
247
|
-
* "
|
|
245
|
+
* "audioSliderVolume: 30"
|
|
248
246
|
* "portalName": "community",
|
|
249
247
|
* "audioRadius": 0,
|
|
250
248
|
* "mediaName": "string"
|
|
251
249
|
* });
|
|
252
250
|
* ```
|
|
253
251
|
*/
|
|
254
|
-
updateMediaType({ audioRadius,
|
|
252
|
+
updateMediaType({ audioRadius, audioSliderVolume, isVideo, mediaLink, mediaName, mediaType, portalName, syncUserMedia, }) {
|
|
255
253
|
try {
|
|
256
|
-
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { audioRadius,
|
|
254
|
+
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { audioRadius, audioSliderVolume, isVideo, mediaLink, mediaName, mediaType, portalName, syncUserMedia }, "change-media-type");
|
|
257
255
|
}
|
|
258
256
|
catch (error) {
|
|
259
|
-
throw
|
|
257
|
+
throw this.errorHandler({ error });
|
|
260
258
|
}
|
|
261
259
|
}
|
|
262
260
|
/**
|
|
@@ -273,7 +271,7 @@ export class DroppedAsset extends Asset {
|
|
|
273
271
|
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { isMutezone }, "set-mute-zone");
|
|
274
272
|
}
|
|
275
273
|
catch (error) {
|
|
276
|
-
throw
|
|
274
|
+
throw this.errorHandler({ error });
|
|
277
275
|
}
|
|
278
276
|
}
|
|
279
277
|
/**
|
|
@@ -290,7 +288,7 @@ export class DroppedAsset extends Asset {
|
|
|
290
288
|
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { x, y }, "set-position");
|
|
291
289
|
}
|
|
292
290
|
catch (error) {
|
|
293
|
-
throw
|
|
291
|
+
throw this.errorHandler({ error });
|
|
294
292
|
}
|
|
295
293
|
}
|
|
296
294
|
/**
|
|
@@ -311,7 +309,7 @@ export class DroppedAsset extends Asset {
|
|
|
311
309
|
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { isPrivateZone, isPrivateZoneChatDisabled, privateZoneUserCap }, "set-private-zone");
|
|
312
310
|
}
|
|
313
311
|
catch (error) {
|
|
314
|
-
throw
|
|
312
|
+
throw this.errorHandler({ error });
|
|
315
313
|
}
|
|
316
314
|
}
|
|
317
315
|
/**
|
|
@@ -328,7 +326,7 @@ export class DroppedAsset extends Asset {
|
|
|
328
326
|
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { assetScale }, "change-scale");
|
|
329
327
|
}
|
|
330
328
|
catch (error) {
|
|
331
|
-
throw
|
|
329
|
+
throw this.errorHandler({ error });
|
|
332
330
|
}
|
|
333
331
|
}
|
|
334
332
|
/**
|
|
@@ -345,7 +343,7 @@ export class DroppedAsset extends Asset {
|
|
|
345
343
|
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { mediaId }, "change-uploaded-media-selected");
|
|
346
344
|
}
|
|
347
345
|
catch (error) {
|
|
348
|
-
throw
|
|
346
|
+
throw this.errorHandler({ error });
|
|
349
347
|
}
|
|
350
348
|
}
|
|
351
349
|
/**
|
|
@@ -362,7 +360,7 @@ export class DroppedAsset extends Asset {
|
|
|
362
360
|
return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { bottom, top }, "set-webimage-layers");
|
|
363
361
|
}
|
|
364
362
|
catch (error) {
|
|
365
|
-
throw
|
|
363
|
+
throw this.errorHandler({ error });
|
|
366
364
|
}
|
|
367
365
|
}
|
|
368
366
|
/**
|
|
@@ -387,7 +385,7 @@ export class DroppedAsset extends Asset {
|
|
|
387
385
|
addWebhook({ dataObject, description, isUniqueOnly, title, type, url, }) {
|
|
388
386
|
return __awaiter(this, void 0, void 0, function* () {
|
|
389
387
|
try {
|
|
390
|
-
yield this.
|
|
388
|
+
yield this.topiaPublicApi().post(`/world/${this.urlSlug}/webhooks`, {
|
|
391
389
|
active: true,
|
|
392
390
|
assetId: this.id,
|
|
393
391
|
dataObject,
|
|
@@ -401,7 +399,7 @@ export class DroppedAsset extends Asset {
|
|
|
401
399
|
}, this.requestOptions);
|
|
402
400
|
}
|
|
403
401
|
catch (error) {
|
|
404
|
-
throw
|
|
402
|
+
throw this.errorHandler({ error });
|
|
405
403
|
}
|
|
406
404
|
});
|
|
407
405
|
}
|
|
@@ -420,7 +418,7 @@ export class DroppedAsset extends Asset {
|
|
|
420
418
|
setInteractiveSettings({ isInteractive = false, interactivePublicKey = "", }) {
|
|
421
419
|
return __awaiter(this, void 0, void 0, function* () {
|
|
422
420
|
try {
|
|
423
|
-
yield this.
|
|
421
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/set-asset-interactive-settings`, {
|
|
424
422
|
interactivePublicKey,
|
|
425
423
|
isInteractive,
|
|
426
424
|
}, this.requestOptions);
|
|
@@ -428,7 +426,7 @@ export class DroppedAsset extends Asset {
|
|
|
428
426
|
this.interactivePublicKey = interactivePublicKey;
|
|
429
427
|
}
|
|
430
428
|
catch (error) {
|
|
431
|
-
throw
|
|
429
|
+
throw this.errorHandler({ error });
|
|
432
430
|
}
|
|
433
431
|
});
|
|
434
432
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// utils
|
|
2
2
|
import jwt from "jsonwebtoken";
|
|
3
|
+
import { AxiosError } from "axios";
|
|
3
4
|
/**
|
|
4
5
|
* @summary
|
|
5
6
|
* Create an instance of SDKController class with credentials.
|
|
@@ -44,5 +45,32 @@ export class SDKController {
|
|
|
44
45
|
}
|
|
45
46
|
this.requestOptions = { headers };
|
|
46
47
|
}
|
|
48
|
+
topiaPublicApi() {
|
|
49
|
+
this.stackTrace = new Error("Thrown here:");
|
|
50
|
+
return this.topia.axios;
|
|
51
|
+
}
|
|
52
|
+
errorHandler({ error, message = "Something went wrong. Please try again or contact support.", }) {
|
|
53
|
+
var _a, _b, _c, _d;
|
|
54
|
+
let data = {}, errorMessage = message, status = 500, url = "unknown", method = "unknown", stack = "empty";
|
|
55
|
+
if (error instanceof AxiosError) {
|
|
56
|
+
errorMessage = (error === null || error === void 0 ? void 0 : error.message) || message;
|
|
57
|
+
if (error.response) {
|
|
58
|
+
status = error.response.status;
|
|
59
|
+
data = error.response.data;
|
|
60
|
+
}
|
|
61
|
+
if ((_a = error === null || error === void 0 ? void 0 : error.config) === null || _a === void 0 ? void 0 : _a.url)
|
|
62
|
+
url = error.config.url;
|
|
63
|
+
if ((_b = error === null || error === void 0 ? void 0 : error.config) === null || _b === void 0 ? void 0 : _b.method)
|
|
64
|
+
method = error.config.method;
|
|
65
|
+
if ((_c = this.stackTrace) === null || _c === void 0 ? void 0 : _c.stack)
|
|
66
|
+
stack = `${error.stack}\n${this.stackTrace.stack}`;
|
|
67
|
+
}
|
|
68
|
+
else if (error instanceof Error) {
|
|
69
|
+
errorMessage = (error === null || error === void 0 ? void 0 : error.message) || message;
|
|
70
|
+
if ((_d = this.stackTrace) === null || _d === void 0 ? void 0 : _d.stack)
|
|
71
|
+
stack = `${error.stack}\n${this.stackTrace.stack}`;
|
|
72
|
+
}
|
|
73
|
+
return { success: false, status, url, method, message: errorMessage, data, stack };
|
|
74
|
+
}
|
|
47
75
|
}
|
|
48
76
|
export default SDKController;
|
|
@@ -22,8 +22,6 @@ var _User_worldsMap;
|
|
|
22
22
|
// controllers
|
|
23
23
|
import { SDKController } from "controllers/SDKController";
|
|
24
24
|
import { World } from "controllers/World";
|
|
25
|
-
// utils
|
|
26
|
-
import { getErrorResponse } from "utils";
|
|
27
25
|
/**
|
|
28
26
|
* @summary
|
|
29
27
|
* Create an instance of User class with email and optional session credentials.
|
|
@@ -50,11 +48,11 @@ export class User extends SDKController {
|
|
|
50
48
|
fetchAssetsByEmail(ownerEmail) {
|
|
51
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
50
|
try {
|
|
53
|
-
const response = yield this.
|
|
51
|
+
const response = yield this.topiaPublicApi().get(`/assets/my-assets?email=${ownerEmail}`, this.requestOptions);
|
|
54
52
|
return response.data;
|
|
55
53
|
}
|
|
56
54
|
catch (error) {
|
|
57
|
-
throw
|
|
55
|
+
throw this.errorHandler({ error });
|
|
58
56
|
}
|
|
59
57
|
});
|
|
60
58
|
}
|
|
@@ -66,12 +64,12 @@ export class User extends SDKController {
|
|
|
66
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
65
|
try {
|
|
68
66
|
if (!this.email)
|
|
69
|
-
throw
|
|
70
|
-
const response = yield this.
|
|
67
|
+
throw this.errorHandler({ error: new Error("There is no email associated with this user.") }); // throw a new Error so the stack trace goes to errorHandler
|
|
68
|
+
const response = yield this.topiaPublicApi().get(`/scenes/my-scenes?email=${this.email}`, this.requestOptions);
|
|
71
69
|
return response.data;
|
|
72
70
|
}
|
|
73
71
|
catch (error) {
|
|
74
|
-
throw
|
|
72
|
+
throw this.errorHandler({ error });
|
|
75
73
|
}
|
|
76
74
|
});
|
|
77
75
|
}
|
|
@@ -95,7 +93,7 @@ export class User extends SDKController {
|
|
|
95
93
|
fetchWorldsByKey() {
|
|
96
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
97
95
|
try {
|
|
98
|
-
const response = yield this.
|
|
96
|
+
const response = yield this.topiaPublicApi().get("/user/worlds", this.requestOptions);
|
|
99
97
|
const tempWorldsMap = {};
|
|
100
98
|
for (const i in response.data) {
|
|
101
99
|
const worldDetails = response.data[i];
|
|
@@ -106,7 +104,7 @@ export class User extends SDKController {
|
|
|
106
104
|
__classPrivateFieldSet(this, _User_worldsMap, tempWorldsMap, "f");
|
|
107
105
|
}
|
|
108
106
|
catch (error) {
|
|
109
|
-
throw
|
|
107
|
+
throw this.errorHandler({ error });
|
|
110
108
|
}
|
|
111
109
|
});
|
|
112
110
|
}
|
|
@@ -9,8 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
// controllers
|
|
11
11
|
import { SDKController } from "controllers/SDKController";
|
|
12
|
-
// utils
|
|
13
|
-
import { getErrorResponse } from "utils";
|
|
14
12
|
/**
|
|
15
13
|
* @summary
|
|
16
14
|
* Create an instance of Visitor class with a given id and optional attributes and session credentials.
|
|
@@ -42,7 +40,7 @@ export class Visitor extends SDKController {
|
|
|
42
40
|
fetchVisitor() {
|
|
43
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
42
|
try {
|
|
45
|
-
const response = yield this.
|
|
43
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors/${this.id}`, this.requestOptions);
|
|
46
44
|
if (response.data.success) {
|
|
47
45
|
Object.assign(this, response.data).players[0];
|
|
48
46
|
}
|
|
@@ -51,7 +49,7 @@ export class Visitor extends SDKController {
|
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
51
|
catch (error) {
|
|
54
|
-
throw
|
|
52
|
+
throw this.errorHandler({ error });
|
|
55
53
|
}
|
|
56
54
|
});
|
|
57
55
|
}
|
|
@@ -74,7 +72,7 @@ export class Visitor extends SDKController {
|
|
|
74
72
|
moveVisitor({ shouldTeleportVisitor, x, y }) {
|
|
75
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
74
|
try {
|
|
77
|
-
yield this.
|
|
75
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/move`, {
|
|
78
76
|
moveTo: {
|
|
79
77
|
x,
|
|
80
78
|
y,
|
|
@@ -83,7 +81,7 @@ export class Visitor extends SDKController {
|
|
|
83
81
|
}, this.requestOptions);
|
|
84
82
|
}
|
|
85
83
|
catch (error) {
|
|
86
|
-
throw
|
|
84
|
+
throw this.errorHandler({ error });
|
|
87
85
|
}
|
|
88
86
|
});
|
|
89
87
|
}
|
|
@@ -24,7 +24,7 @@ import { DroppedAsset } from "controllers/DroppedAsset";
|
|
|
24
24
|
import { SDKController } from "controllers/SDKController";
|
|
25
25
|
import { Visitor } from "controllers/Visitor";
|
|
26
26
|
// utils
|
|
27
|
-
import {
|
|
27
|
+
import { removeUndefined, scatterVisitors } from "utils";
|
|
28
28
|
/**
|
|
29
29
|
* @summary
|
|
30
30
|
* Create an instance of World class with a given url slug and optional attributes and session credentials.
|
|
@@ -64,11 +64,11 @@ export class World extends SDKController {
|
|
|
64
64
|
fetchDetails() {
|
|
65
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
66
|
try {
|
|
67
|
-
const response = yield this.
|
|
67
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/world-details`, this.requestOptions);
|
|
68
68
|
Object.assign(this, response.data);
|
|
69
69
|
}
|
|
70
70
|
catch (error) {
|
|
71
|
-
throw
|
|
71
|
+
throw this.errorHandler({ error });
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
}
|
|
@@ -106,12 +106,12 @@ export class World extends SDKController {
|
|
|
106
106
|
width,
|
|
107
107
|
};
|
|
108
108
|
try {
|
|
109
|
-
yield this.
|
|
109
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/world-details`, payload, this.requestOptions);
|
|
110
110
|
const cleanPayload = removeUndefined(payload);
|
|
111
111
|
Object.assign(this, cleanPayload);
|
|
112
112
|
}
|
|
113
113
|
catch (error) {
|
|
114
|
-
throw
|
|
114
|
+
throw this.errorHandler({ error });
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
117
|
}
|
|
@@ -119,7 +119,7 @@ export class World extends SDKController {
|
|
|
119
119
|
fetchVisitors() {
|
|
120
120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
121
121
|
try {
|
|
122
|
-
const response = yield this.
|
|
122
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors`, this.requestOptions);
|
|
123
123
|
// create temp map and then update private property only once
|
|
124
124
|
const tempVisitorsMap = {};
|
|
125
125
|
for (const id in response.data) {
|
|
@@ -130,7 +130,7 @@ export class World extends SDKController {
|
|
|
130
130
|
__classPrivateFieldSet(this, _World_visitorsMap, tempVisitorsMap, "f");
|
|
131
131
|
}
|
|
132
132
|
catch (error) {
|
|
133
|
-
throw
|
|
133
|
+
throw this.errorHandler({ error });
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
136
|
}
|
|
@@ -240,7 +240,7 @@ export class World extends SDKController {
|
|
|
240
240
|
fetchDroppedAssets() {
|
|
241
241
|
return __awaiter(this, void 0, void 0, function* () {
|
|
242
242
|
try {
|
|
243
|
-
const response = yield this.
|
|
243
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/assets`, this.requestOptions);
|
|
244
244
|
// create temp map and then update private property only once
|
|
245
245
|
const tempDroppedAssetsMap = {};
|
|
246
246
|
for (const index in response.data) {
|
|
@@ -252,7 +252,7 @@ export class World extends SDKController {
|
|
|
252
252
|
__classPrivateFieldSet(this, _World_droppedAssetsMap, tempDroppedAssetsMap, "f");
|
|
253
253
|
}
|
|
254
254
|
catch (error) {
|
|
255
|
-
throw
|
|
255
|
+
throw this.errorHandler({ error });
|
|
256
256
|
}
|
|
257
257
|
});
|
|
258
258
|
}
|
|
@@ -307,10 +307,10 @@ export class World extends SDKController {
|
|
|
307
307
|
replaceScene(sceneId) {
|
|
308
308
|
return __awaiter(this, void 0, void 0, function* () {
|
|
309
309
|
try {
|
|
310
|
-
yield this.
|
|
310
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/change-scene`, { sceneId }, this.requestOptions);
|
|
311
311
|
}
|
|
312
312
|
catch (error) {
|
|
313
|
-
throw
|
|
313
|
+
throw this.errorHandler({ error });
|
|
314
314
|
}
|
|
315
315
|
});
|
|
316
316
|
}
|
|
@@ -328,7 +328,7 @@ export class World extends SDKController {
|
|
|
328
328
|
fetchDroppedAssetsWithUniqueName({ uniqueName, isPartial = false, isReversed = false, }) {
|
|
329
329
|
return __awaiter(this, void 0, void 0, function* () {
|
|
330
330
|
try {
|
|
331
|
-
const response = yield this.
|
|
331
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/assets-with-unique-name/${uniqueName}?${isPartial ? `partial=${isPartial}&` : ""}${isReversed ? `reversed=${isReversed}` : ""}`, this.requestOptions);
|
|
332
332
|
// create temp map and then update private property only once
|
|
333
333
|
const droppedAssets = [];
|
|
334
334
|
for (const asset of response.data.assets) {
|
|
@@ -339,7 +339,7 @@ export class World extends SDKController {
|
|
|
339
339
|
return droppedAssets;
|
|
340
340
|
}
|
|
341
341
|
catch (error) {
|
|
342
|
-
throw
|
|
342
|
+
throw this.errorHandler({ error });
|
|
343
343
|
}
|
|
344
344
|
});
|
|
345
345
|
}
|
|
@@ -59,7 +59,7 @@ describe("DroppedAsset Class", () => {
|
|
|
59
59
|
}));
|
|
60
60
|
it("should update dropped asset media type", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
61
|
mock.onPut(`${BASE_URL}/change-media-type`).reply(200);
|
|
62
|
-
const mediaTypeArgs = Object.assign(Object.assign({}, attributes), { audioRadius: 0,
|
|
62
|
+
const mediaTypeArgs = Object.assign(Object.assign({}, attributes), { audioRadius: 0, audioSliderVolume: 30, isVideo: true, mediaLink: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", mediaName: "string", mediaType: DroppedAssetMediaType.LINK, portalName: "community", syncUserMedia: true });
|
|
63
63
|
yield testDroppedAsset.updateMediaType(mediaTypeArgs);
|
|
64
64
|
expect(mock.history.put.length).toBe(1);
|
|
65
65
|
}));
|
|
@@ -7,11 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { DroppedAsset } from "controllers";
|
|
11
|
-
|
|
12
|
-
export class DroppedAssetFactory {
|
|
10
|
+
import { DroppedAsset, SDKController } from "controllers";
|
|
11
|
+
export class DroppedAssetFactory extends SDKController {
|
|
13
12
|
constructor(topia) {
|
|
14
|
-
|
|
13
|
+
super(topia);
|
|
15
14
|
}
|
|
16
15
|
create(id, urlSlug, options) {
|
|
17
16
|
return new DroppedAsset(this.topia, id, urlSlug, options);
|
|
@@ -26,7 +25,7 @@ export class DroppedAssetFactory {
|
|
|
26
25
|
drop(asset, { position: { x, y }, uniqueName, urlSlug, }) {
|
|
27
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
27
|
try {
|
|
29
|
-
const response = yield this.
|
|
28
|
+
const response = yield this.topiaPublicApi().post(`/world/${urlSlug}/assets`, {
|
|
30
29
|
assetId: asset.id,
|
|
31
30
|
position: { x, y },
|
|
32
31
|
uniqueName,
|
|
@@ -35,7 +34,7 @@ export class DroppedAssetFactory {
|
|
|
35
34
|
return new DroppedAsset(this.topia, id, urlSlug, { credentials: asset.credentials });
|
|
36
35
|
}
|
|
37
36
|
catch (error) {
|
|
38
|
-
throw
|
|
37
|
+
throw this.errorHandler({ error });
|
|
39
38
|
}
|
|
40
39
|
});
|
|
41
40
|
}
|
package/dist/src/index.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
export { Topia } from "controllers";
|
|
2
2
|
export { AssetFactory, DroppedAssetFactory, UserFactory, VisitorFactory, WorldFactory } from "factories";
|
|
3
|
+
Error.stackTraceLimit = 20;
|
|
3
4
|
process.on("unhandledRejection", (reason) => {
|
|
5
|
+
if (reason.data) {
|
|
6
|
+
const { errors } = reason.data;
|
|
7
|
+
if (Array.isArray(errors)) {
|
|
8
|
+
for (const error of errors) {
|
|
9
|
+
console.error(error);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
console.error((reason === null || reason === void 0 ? void 0 : reason.stack) || "no stack");
|
|
14
|
+
delete reason.stack;
|
|
4
15
|
console.error(reason);
|
|
5
|
-
console.
|
|
16
|
+
console.error(`Please surround your use of the RTSDK with a try/catch block.`);
|
|
6
17
|
process.exit(1);
|
|
7
18
|
});
|
|
8
19
|
process.on("uncaughtException", function (err) {
|
package/dist/src/utils/index.js
CHANGED
package/package.json
CHANGED