@rtsdk/topia 0.0.19 → 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.
@@ -54,7 +54,7 @@ export const droppedAssets = [
54
54
  assetBroadcastAll: false,
55
55
  assetBroadcast: false,
56
56
  audioRadius: null,
57
- audioVolume: null,
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
- audioVolume: null,
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
- audioVolume: null,
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
- audioVolume: null,
207
+ audioSliderVolume: null,
208
208
  isPrivateZone: false,
209
209
  isPrivateZoneChatDisabled: false,
210
210
  privateZoneUserCap: null,
@@ -9,11 +9,11 @@ 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
  /**
13
+ * @summary
15
14
  * Create an instance of Asset class with a given asset id and optional attributes and session credentials.
16
15
  *
16
+ * @usage
17
17
  * ```ts
18
18
  * await new Asset(topia, "assetId", { attributes: { assetName: "My Asset", isPublic: false } });
19
19
  * ```
@@ -27,11 +27,11 @@ export class Asset extends SDKController {
27
27
  fetchPlatformAssets() {
28
28
  return __awaiter(this, void 0, void 0, function* () {
29
29
  try {
30
- const response = yield this.topia.axios.get("/assets/topia-assets", this.requestOptions);
30
+ const response = yield this.topiaPublicApi().get("/assets/topia-assets", this.requestOptions);
31
31
  return response.data;
32
32
  }
33
33
  catch (error) {
34
- throw getErrorResponse({ error });
34
+ throw this.errorHandler({ error });
35
35
  }
36
36
  });
37
37
  }
@@ -15,11 +15,11 @@ 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
  /**
19
+ * @summary
21
20
  * Create an instance of Dropped Asset class with a given dropped asset id, url slug, and optional attributes and session credentials.
22
21
  *
22
+ * @usage
23
23
  * ```ts
24
24
  * await new DroppedAsset(topia, "1giFZb0sQ3X27L7uGyQX", "example", { attributes: { text: "" }, credentials: { assetId: "1giFZb0sQ3X27L7uGyQX" } } });
25
25
  * ```
@@ -31,10 +31,10 @@ export class DroppedAsset extends Asset {
31
31
  // update dropped assets
32
32
  _DroppedAsset_updateDroppedAsset.set(this, (payload, updateType) => __awaiter(this, void 0, void 0, function* () {
33
33
  try {
34
- yield this.topia.axios.put(`/world/${this.urlSlug}/assets/${this.id}/${updateType}`, Object.assign({}, payload), this.requestOptions);
34
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/${updateType}`, Object.assign({}, payload), this.requestOptions);
35
35
  }
36
36
  catch (error) {
37
- throw getErrorResponse({ error });
37
+ throw this.errorHandler({ error });
38
38
  }
39
39
  }));
40
40
  this.id = id;
@@ -55,11 +55,11 @@ export class DroppedAsset extends Asset {
55
55
  fetchDroppedAssetById() {
56
56
  return __awaiter(this, void 0, void 0, function* () {
57
57
  try {
58
- const response = yield this.topia.axios.get(`/world/${this.urlSlug}/assets/${this.id}`, this.requestOptions);
58
+ const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/assets/${this.id}`, this.requestOptions);
59
59
  Object.assign(this, response.data);
60
60
  }
61
61
  catch (error) {
62
- throw getErrorResponse({ error });
62
+ throw this.errorHandler({ error });
63
63
  }
64
64
  });
65
65
  }
@@ -67,10 +67,10 @@ export class DroppedAsset extends Asset {
67
67
  deleteDroppedAsset() {
68
68
  return __awaiter(this, void 0, void 0, function* () {
69
69
  try {
70
- yield this.topia.axios.delete(`/world/${this.urlSlug}/assets/${this.id}`, this.requestOptions);
70
+ yield this.topiaPublicApi().delete(`/world/${this.urlSlug}/assets/${this.id}`, this.requestOptions);
71
71
  }
72
72
  catch (error) {
73
- throw getErrorResponse({ error });
73
+ throw this.errorHandler({ error });
74
74
  }
75
75
  });
76
76
  }
@@ -88,11 +88,11 @@ export class DroppedAsset extends Asset {
88
88
  fetchDroppedAssetDataObject() {
89
89
  return __awaiter(this, void 0, void 0, function* () {
90
90
  try {
91
- const response = yield this.topia.axios.get(`/world/${this.urlSlug}/assets/${this.id}/data-object`, this.requestOptions);
91
+ const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/assets/${this.id}/data-object`, this.requestOptions);
92
92
  this.dataObject = response.data;
93
93
  }
94
94
  catch (error) {
95
- throw getErrorResponse({ error });
95
+ throw this.errorHandler({ error });
96
96
  }
97
97
  });
98
98
  }
@@ -115,11 +115,11 @@ export class DroppedAsset extends Asset {
115
115
  return __awaiter(this, void 0, void 0, function* () {
116
116
  try {
117
117
  const { lock = {} } = options;
118
- yield this.topia.axios.put(`/world/${this.urlSlug}/assets/${this.id}/set-data-object`, { dataObject, lock }, this.requestOptions);
118
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/set-data-object`, { dataObject, lock }, this.requestOptions);
119
119
  this.dataObject = dataObject;
120
120
  }
121
121
  catch (error) {
122
- throw getErrorResponse({ error });
122
+ throw this.errorHandler({ error });
123
123
  }
124
124
  });
125
125
  }
@@ -142,11 +142,11 @@ export class DroppedAsset extends Asset {
142
142
  return __awaiter(this, void 0, void 0, function* () {
143
143
  try {
144
144
  const { lock = {} } = options;
145
- yield this.topia.axios.put(`/world/${this.urlSlug}/assets/${this.id}/update-data-object`, { dataObject, lock }, this.requestOptions);
145
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/update-data-object`, { dataObject, lock }, this.requestOptions);
146
146
  this.dataObject = dataObject;
147
147
  }
148
148
  catch (error) {
149
- throw getErrorResponse({ error });
149
+ throw this.errorHandler({ error });
150
150
  }
151
151
  });
152
152
  }
@@ -168,7 +168,7 @@ export class DroppedAsset extends Asset {
168
168
  return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { assetBroadcast, assetBroadcastAll, broadcasterEmail }, "set-asset-broadcast");
169
169
  }
170
170
  catch (error) {
171
- throw getErrorResponse({ error });
171
+ throw this.errorHandler({ error });
172
172
  }
173
173
  }
174
174
  /**
@@ -204,7 +204,7 @@ export class DroppedAsset extends Asset {
204
204
  }, "change-click-type");
205
205
  }
206
206
  catch (error) {
207
- throw getErrorResponse({ error });
207
+ throw this.errorHandler({ error });
208
208
  }
209
209
  }
210
210
  /**
@@ -228,7 +228,7 @@ export class DroppedAsset extends Asset {
228
228
  return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { style, text }, "set-custom-text");
229
229
  }
230
230
  catch (error) {
231
- throw getErrorResponse({ error });
231
+ throw this.errorHandler({ error });
232
232
  }
233
233
  }
234
234
  /**
@@ -242,19 +242,19 @@ export class DroppedAsset extends Asset {
242
242
  * "mediaLink": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
243
243
  * "isVideo": true,
244
244
  * "syncUserMedia": true,
245
- * "audioVolume": -1,
245
+ * "audioSliderVolume: 30"
246
246
  * "portalName": "community",
247
247
  * "audioRadius": 0,
248
248
  * "mediaName": "string"
249
249
  * });
250
250
  * ```
251
251
  */
252
- updateMediaType({ audioRadius, audioVolume, isVideo, mediaLink, mediaName, mediaType, portalName, syncUserMedia, }) {
252
+ updateMediaType({ audioRadius, audioSliderVolume, isVideo, mediaLink, mediaName, mediaType, portalName, syncUserMedia, }) {
253
253
  try {
254
- return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { audioRadius, audioVolume, isVideo, mediaLink, mediaName, mediaType, portalName, syncUserMedia }, "change-media-type");
254
+ return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { audioRadius, audioSliderVolume, isVideo, mediaLink, mediaName, mediaType, portalName, syncUserMedia }, "change-media-type");
255
255
  }
256
256
  catch (error) {
257
- throw getErrorResponse({ error });
257
+ throw this.errorHandler({ error });
258
258
  }
259
259
  }
260
260
  /**
@@ -271,7 +271,7 @@ export class DroppedAsset extends Asset {
271
271
  return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { isMutezone }, "set-mute-zone");
272
272
  }
273
273
  catch (error) {
274
- throw getErrorResponse({ error });
274
+ throw this.errorHandler({ error });
275
275
  }
276
276
  }
277
277
  /**
@@ -288,7 +288,7 @@ export class DroppedAsset extends Asset {
288
288
  return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { x, y }, "set-position");
289
289
  }
290
290
  catch (error) {
291
- throw getErrorResponse({ error });
291
+ throw this.errorHandler({ error });
292
292
  }
293
293
  }
294
294
  /**
@@ -309,7 +309,7 @@ export class DroppedAsset extends Asset {
309
309
  return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { isPrivateZone, isPrivateZoneChatDisabled, privateZoneUserCap }, "set-private-zone");
310
310
  }
311
311
  catch (error) {
312
- throw getErrorResponse({ error });
312
+ throw this.errorHandler({ error });
313
313
  }
314
314
  }
315
315
  /**
@@ -326,7 +326,7 @@ export class DroppedAsset extends Asset {
326
326
  return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { assetScale }, "change-scale");
327
327
  }
328
328
  catch (error) {
329
- throw getErrorResponse({ error });
329
+ throw this.errorHandler({ error });
330
330
  }
331
331
  }
332
332
  /**
@@ -343,7 +343,7 @@ export class DroppedAsset extends Asset {
343
343
  return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { mediaId }, "change-uploaded-media-selected");
344
344
  }
345
345
  catch (error) {
346
- throw getErrorResponse({ error });
346
+ throw this.errorHandler({ error });
347
347
  }
348
348
  }
349
349
  /**
@@ -360,7 +360,7 @@ export class DroppedAsset extends Asset {
360
360
  return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { bottom, top }, "set-webimage-layers");
361
361
  }
362
362
  catch (error) {
363
- throw getErrorResponse({ error });
363
+ throw this.errorHandler({ error });
364
364
  }
365
365
  }
366
366
  /**
@@ -385,7 +385,7 @@ export class DroppedAsset extends Asset {
385
385
  addWebhook({ dataObject, description, isUniqueOnly, title, type, url, }) {
386
386
  return __awaiter(this, void 0, void 0, function* () {
387
387
  try {
388
- yield this.topia.axios.post(`/world/${this.urlSlug}/webhooks`, {
388
+ yield this.topiaPublicApi().post(`/world/${this.urlSlug}/webhooks`, {
389
389
  active: true,
390
390
  assetId: this.id,
391
391
  dataObject,
@@ -399,7 +399,7 @@ export class DroppedAsset extends Asset {
399
399
  }, this.requestOptions);
400
400
  }
401
401
  catch (error) {
402
- throw getErrorResponse({ error });
402
+ throw this.errorHandler({ error });
403
403
  }
404
404
  });
405
405
  }
@@ -418,7 +418,7 @@ export class DroppedAsset extends Asset {
418
418
  setInteractiveSettings({ isInteractive = false, interactivePublicKey = "", }) {
419
419
  return __awaiter(this, void 0, void 0, function* () {
420
420
  try {
421
- yield this.topia.axios.put(`/world/${this.urlSlug}/assets/${this.id}/set-asset-interactive-settings`, {
421
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/set-asset-interactive-settings`, {
422
422
  interactivePublicKey,
423
423
  isInteractive,
424
424
  }, this.requestOptions);
@@ -426,7 +426,7 @@ export class DroppedAsset extends Asset {
426
426
  this.interactivePublicKey = interactivePublicKey;
427
427
  }
428
428
  catch (error) {
429
- throw getErrorResponse({ error });
429
+ throw this.errorHandler({ error });
430
430
  }
431
431
  });
432
432
  }
@@ -1,8 +1,11 @@
1
1
  // utils
2
2
  import jwt from "jsonwebtoken";
3
+ import { AxiosError } from "axios";
3
4
  /**
5
+ * @summary
4
6
  * Create an instance of SDKController class with credentials.
5
7
  *
8
+ * @usage
6
9
  * ```ts
7
10
  * const credentials = {
8
11
  * assetId: "exampleAsset",
@@ -42,5 +45,32 @@ export class SDKController {
42
45
  }
43
46
  this.requestOptions = { headers };
44
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
+ }
45
75
  }
46
76
  export default SDKController;
@@ -2,8 +2,10 @@ import axios from "axios";
2
2
  // utils
3
3
  import { getBrowserWarning } from "utils";
4
4
  /**
5
+ * @summary
5
6
  * Create a single instance of Topia axios used for all calls to the public API in all classes
6
7
  *
8
+ * @usage
7
9
  * ```ts
8
10
  * const topia = await new Topia({
9
11
  * apiDomain: "api.topia.io",
@@ -22,11 +22,11 @@ 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
  /**
26
+ * @summary
28
27
  * Create an instance of User class with email and optional session credentials.
29
28
  *
29
+ * @usage
30
30
  * ```ts
31
31
  * await new User(topia, "example@email.io", { interactiveNonce: "exampleNonce", interactivePublicKey: "examplePublicKey", playerId: 1 });
32
32
  * ```
@@ -48,11 +48,11 @@ export class User extends SDKController {
48
48
  fetchAssetsByEmail(ownerEmail) {
49
49
  return __awaiter(this, void 0, void 0, function* () {
50
50
  try {
51
- const response = yield this.topia.axios.get(`/assets/my-assets?email=${ownerEmail}`, this.requestOptions);
51
+ const response = yield this.topiaPublicApi().get(`/assets/my-assets?email=${ownerEmail}`, this.requestOptions);
52
52
  return response.data;
53
53
  }
54
54
  catch (error) {
55
- throw getErrorResponse({ error });
55
+ throw this.errorHandler({ error });
56
56
  }
57
57
  });
58
58
  }
@@ -64,12 +64,12 @@ export class User extends SDKController {
64
64
  return __awaiter(this, void 0, void 0, function* () {
65
65
  try {
66
66
  if (!this.email)
67
- throw getErrorResponse({ message: "There is no email associated with this user." });
68
- const response = yield this.topia.axios.get(`/scenes/my-scenes?email=${this.email}`, this.requestOptions);
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);
69
69
  return response.data;
70
70
  }
71
71
  catch (error) {
72
- throw getErrorResponse({ error });
72
+ throw this.errorHandler({ error });
73
73
  }
74
74
  });
75
75
  }
@@ -93,7 +93,7 @@ export class User extends SDKController {
93
93
  fetchWorldsByKey() {
94
94
  return __awaiter(this, void 0, void 0, function* () {
95
95
  try {
96
- const response = yield this.topia.axios.get("/user/worlds", this.requestOptions);
96
+ const response = yield this.topiaPublicApi().get("/user/worlds", this.requestOptions);
97
97
  const tempWorldsMap = {};
98
98
  for (const i in response.data) {
99
99
  const worldDetails = response.data[i];
@@ -104,7 +104,7 @@ export class User extends SDKController {
104
104
  __classPrivateFieldSet(this, _User_worldsMap, tempWorldsMap, "f");
105
105
  }
106
106
  catch (error) {
107
- throw getErrorResponse({ error });
107
+ throw this.errorHandler({ error });
108
108
  }
109
109
  });
110
110
  }
@@ -9,11 +9,11 @@ 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
  /**
13
+ * @summary
15
14
  * Create an instance of Visitor class with a given id and optional attributes and session credentials.
16
15
  *
16
+ * @usage
17
17
  * ```ts
18
18
  * await new Visitor(topia, id, urlSlug, { attributes: { moveTo: { x: 0, y: 0 } } });
19
19
  * ```
@@ -40,7 +40,7 @@ export class Visitor extends SDKController {
40
40
  fetchVisitor() {
41
41
  return __awaiter(this, void 0, void 0, function* () {
42
42
  try {
43
- const response = yield this.topia.axios.get(`/world/${this.urlSlug}/visitors/${this.id}`, this.requestOptions);
43
+ const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors/${this.id}`, this.requestOptions);
44
44
  if (response.data.success) {
45
45
  Object.assign(this, response.data).players[0];
46
46
  }
@@ -49,7 +49,7 @@ export class Visitor extends SDKController {
49
49
  }
50
50
  }
51
51
  catch (error) {
52
- throw getErrorResponse({ error });
52
+ throw this.errorHandler({ error });
53
53
  }
54
54
  });
55
55
  }
@@ -72,7 +72,7 @@ export class Visitor extends SDKController {
72
72
  moveVisitor({ shouldTeleportVisitor, x, y }) {
73
73
  return __awaiter(this, void 0, void 0, function* () {
74
74
  try {
75
- yield this.topia.axios.put(`/world/${this.urlSlug}/visitors/${this.id}/move`, {
75
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/move`, {
76
76
  moveTo: {
77
77
  x,
78
78
  y,
@@ -81,7 +81,7 @@ export class Visitor extends SDKController {
81
81
  }, this.requestOptions);
82
82
  }
83
83
  catch (error) {
84
- throw getErrorResponse({ error });
84
+ throw this.errorHandler({ error });
85
85
  }
86
86
  });
87
87
  }
@@ -24,10 +24,12 @@ import { DroppedAsset } from "controllers/DroppedAsset";
24
24
  import { SDKController } from "controllers/SDKController";
25
25
  import { Visitor } from "controllers/Visitor";
26
26
  // utils
27
- import { getErrorResponse, removeUndefined, scatterVisitors } from "utils";
27
+ import { removeUndefined, scatterVisitors } from "utils";
28
28
  /**
29
+ * @summary
29
30
  * Create an instance of World class with a given url slug and optional attributes and session credentials.
30
31
  *
32
+ * @usage
31
33
  * ```ts
32
34
  * await new World(topia, "exampleWorld", { attributes: { name: "Example World" } });
33
35
  * ```
@@ -62,11 +64,11 @@ export class World extends SDKController {
62
64
  fetchDetails() {
63
65
  return __awaiter(this, void 0, void 0, function* () {
64
66
  try {
65
- const response = yield this.topia.axios.get(`/world/${this.urlSlug}/world-details`, this.requestOptions);
67
+ const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/world-details`, this.requestOptions);
66
68
  Object.assign(this, response.data);
67
69
  }
68
70
  catch (error) {
69
- throw getErrorResponse({ error });
71
+ throw this.errorHandler({ error });
70
72
  }
71
73
  });
72
74
  }
@@ -104,12 +106,12 @@ export class World extends SDKController {
104
106
  width,
105
107
  };
106
108
  try {
107
- yield this.topia.axios.put(`/world/${this.urlSlug}/world-details`, payload, this.requestOptions);
109
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/world-details`, payload, this.requestOptions);
108
110
  const cleanPayload = removeUndefined(payload);
109
111
  Object.assign(this, cleanPayload);
110
112
  }
111
113
  catch (error) {
112
- throw getErrorResponse({ error });
114
+ throw this.errorHandler({ error });
113
115
  }
114
116
  });
115
117
  }
@@ -117,7 +119,7 @@ export class World extends SDKController {
117
119
  fetchVisitors() {
118
120
  return __awaiter(this, void 0, void 0, function* () {
119
121
  try {
120
- const response = yield this.topia.axios.get(`/world/${this.urlSlug}/visitors`, this.requestOptions);
122
+ const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors`, this.requestOptions);
121
123
  // create temp map and then update private property only once
122
124
  const tempVisitorsMap = {};
123
125
  for (const id in response.data) {
@@ -128,7 +130,7 @@ export class World extends SDKController {
128
130
  __classPrivateFieldSet(this, _World_visitorsMap, tempVisitorsMap, "f");
129
131
  }
130
132
  catch (error) {
131
- throw getErrorResponse({ error });
133
+ throw this.errorHandler({ error });
132
134
  }
133
135
  });
134
136
  }
@@ -238,7 +240,7 @@ export class World extends SDKController {
238
240
  fetchDroppedAssets() {
239
241
  return __awaiter(this, void 0, void 0, function* () {
240
242
  try {
241
- const response = yield this.topia.axios.get(`/world/${this.urlSlug}/assets`, this.requestOptions);
243
+ const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/assets`, this.requestOptions);
242
244
  // create temp map and then update private property only once
243
245
  const tempDroppedAssetsMap = {};
244
246
  for (const index in response.data) {
@@ -250,7 +252,7 @@ export class World extends SDKController {
250
252
  __classPrivateFieldSet(this, _World_droppedAssetsMap, tempDroppedAssetsMap, "f");
251
253
  }
252
254
  catch (error) {
253
- throw getErrorResponse({ error });
255
+ throw this.errorHandler({ error });
254
256
  }
255
257
  });
256
258
  }
@@ -305,10 +307,10 @@ export class World extends SDKController {
305
307
  replaceScene(sceneId) {
306
308
  return __awaiter(this, void 0, void 0, function* () {
307
309
  try {
308
- yield this.topia.axios.put(`/world/${this.urlSlug}/change-scene`, { sceneId }, this.requestOptions);
310
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/change-scene`, { sceneId }, this.requestOptions);
309
311
  }
310
312
  catch (error) {
311
- throw getErrorResponse({ error });
313
+ throw this.errorHandler({ error });
312
314
  }
313
315
  });
314
316
  }
@@ -326,7 +328,7 @@ export class World extends SDKController {
326
328
  fetchDroppedAssetsWithUniqueName({ uniqueName, isPartial = false, isReversed = false, }) {
327
329
  return __awaiter(this, void 0, void 0, function* () {
328
330
  try {
329
- const response = yield this.topia.axios.get(`/world/${this.urlSlug}/assets-with-unique-name/${uniqueName}?${isPartial ? `partial=${isPartial}&` : ""}${isReversed ? `reversed=${isReversed}` : ""}`, this.requestOptions);
331
+ const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/assets-with-unique-name/${uniqueName}?${isPartial ? `partial=${isPartial}&` : ""}${isReversed ? `reversed=${isReversed}` : ""}`, this.requestOptions);
330
332
  // create temp map and then update private property only once
331
333
  const droppedAssets = [];
332
334
  for (const asset of response.data.assets) {
@@ -337,7 +339,7 @@ export class World extends SDKController {
337
339
  return droppedAssets;
338
340
  }
339
341
  catch (error) {
340
- throw getErrorResponse({ error });
342
+ throw this.errorHandler({ error });
341
343
  }
342
344
  });
343
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, audioVolume: -1, isVideo: true, mediaLink: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", mediaName: "string", mediaType: DroppedAssetMediaType.LINK, portalName: "community", syncUserMedia: true });
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
- import { getErrorResponse } from "utils";
12
- export class DroppedAssetFactory {
10
+ import { DroppedAsset, SDKController } from "controllers";
11
+ export class DroppedAssetFactory extends SDKController {
13
12
  constructor(topia) {
14
- this.topia = topia;
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.topia.axios.post(`/world/${urlSlug}/assets`, {
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 getErrorResponse({ error });
37
+ throw this.errorHandler({ error });
39
38
  }
40
39
  });
41
40
  }
package/dist/src/index.js CHANGED
@@ -1,2 +1,23 @@
1
1
  export { Topia } from "controllers";
2
2
  export { AssetFactory, DroppedAssetFactory, UserFactory, VisitorFactory, WorldFactory } from "factories";
3
+ Error.stackTraceLimit = 20;
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;
15
+ console.error(reason);
16
+ console.error(`Please surround your use of the RTSDK with a try/catch block.`);
17
+ process.exit(1);
18
+ });
19
+ process.on("uncaughtException", function (err) {
20
+ // Handle the error safely
21
+ console.trace(err);
22
+ process.exit(1);
23
+ });