@rtsdk/topia 0.0.31 → 0.1.0

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.cjs CHANGED
@@ -39772,31 +39772,40 @@ class SDKController {
39772
39772
  this.requestOptions = { headers };
39773
39773
  }
39774
39774
  topiaPublicApi() {
39775
- this.stackTrace = new Error("Thrown here:");
39776
39775
  return this.topia.axios;
39777
39776
  }
39778
39777
  errorHandler({ error, message = "Something went wrong. Please try again or contact support.", }) {
39779
- var _a, _b, _c, _d;
39780
- let data = {}, errorMessage = message, status = 500, url = "unknown", method = "unknown", stack = "empty";
39778
+ var _a, _b;
39779
+ const stackTrace = new Error("Thrown here:");
39780
+ let data = {}, errorMessage = message, method = "unknown", stack = "empty", status = 500, url = "unknown";
39781
39781
  if (error instanceof AxiosError) {
39782
39782
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || message;
39783
39783
  if (error.response) {
39784
39784
  status = error.response.status;
39785
39785
  data = error.response.data;
39786
+ if (error.response.data.errors)
39787
+ errorMessage = error.response.data.errors[0].message;
39786
39788
  }
39787
39789
  if ((_a = error === null || error === void 0 ? void 0 : error.config) === null || _a === void 0 ? void 0 : _a.url)
39788
39790
  url = error.config.url;
39789
39791
  if ((_b = error === null || error === void 0 ? void 0 : error.config) === null || _b === void 0 ? void 0 : _b.method)
39790
39792
  method = error.config.method;
39791
- if ((_c = this.stackTrace) === null || _c === void 0 ? void 0 : _c.stack)
39792
- stack = `${error.stack}\n${this.stackTrace.stack}`;
39793
+ stack = `${error.stack}\n${stackTrace.stack}`;
39793
39794
  }
39794
39795
  else if (error instanceof Error) {
39795
39796
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || message;
39796
- if ((_d = this.stackTrace) === null || _d === void 0 ? void 0 : _d.stack)
39797
- stack = `${error.stack}\n${this.stackTrace.stack}`;
39797
+ stack = `${error.stack}\n${stackTrace.stack}`;
39798
39798
  }
39799
- return { success: false, status, url, method, message: errorMessage, data, stack };
39799
+ return {
39800
+ data,
39801
+ message: errorMessage,
39802
+ method,
39803
+ stack,
39804
+ stackTrace,
39805
+ status,
39806
+ success: false,
39807
+ url,
39808
+ };
39800
39809
  }
39801
39810
  }
39802
39811
 
@@ -40096,6 +40105,23 @@ class DroppedAsset extends Asset {
40096
40105
  throw this.errorHandler({ error });
40097
40106
  }
40098
40107
  }
40108
+ /**
40109
+ * @summary
40110
+ * Updates webhook zone options for a dropped asset.
40111
+ *
40112
+ * @usage
40113
+ * ```ts
40114
+ * await droppedAsset.updateWebhookZone(true);
40115
+ * ```
40116
+ */
40117
+ updateWebhookZone(isWebhookZoneEnabled) {
40118
+ try {
40119
+ return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { isWebhookZoneEnabled }, "set-webhook-zone");
40120
+ }
40121
+ catch (error) {
40122
+ throw this.errorHandler({ error });
40123
+ }
40124
+ }
40099
40125
  /**
40100
40126
  * @summary
40101
40127
  * Moves a dropped asset to specified coordinates.
@@ -40119,7 +40145,7 @@ class DroppedAsset extends Asset {
40119
40145
  *
40120
40146
  * @usage
40121
40147
  * ```ts
40122
- * await droppedAsset.updateMuteZone({
40148
+ * await droppedAsset.updatePrivateZone({
40123
40149
  * "isPrivateZone": false,
40124
40150
  * "isPrivateZoneChatDisabled": true,
40125
40151
  * "privateZoneUserCap": 10
@@ -40207,7 +40233,7 @@ class DroppedAsset extends Asset {
40207
40233
  addWebhook({ dataObject, description, isUniqueOnly, title, type, url, }) {
40208
40234
  return __awaiter(this, void 0, void 0, function* () {
40209
40235
  try {
40210
- yield this.topiaPublicApi().post(`/world/${this.urlSlug}/webhooks`, {
40236
+ const response = yield this.topiaPublicApi().post(`/world/${this.urlSlug}/webhooks`, {
40211
40237
  active: true,
40212
40238
  assetId: this.id,
40213
40239
  dataObject,
@@ -40219,6 +40245,7 @@ class DroppedAsset extends Asset {
40219
40245
  url,
40220
40246
  urlSlug: this.urlSlug,
40221
40247
  }, this.requestOptions);
40248
+ return response.data.webhookId;
40222
40249
  }
40223
40250
  catch (error) {
40224
40251
  throw this.errorHandler({ error });
@@ -40414,7 +40441,6 @@ class World extends SDKController {
40414
40441
  // create temp map and then update private property only once
40415
40442
  const tempDroppedAssetsMap = {};
40416
40443
  for (const index in response.data) {
40417
- // tempDroppedAssetsMap[id] = createDroppedAsset(this.apiKey, response.data[id], this.urlSlug);
40418
40444
  tempDroppedAssetsMap[index] = new DroppedAsset(this.topia, response.data[index].id, this.urlSlug, {
40419
40445
  attributes: response.data[index],
40420
40446
  credentials: this.credentials,
@@ -41013,9 +41039,22 @@ class WorldFactory {
41013
41039
  }
41014
41040
  }
41015
41041
 
41042
+ exports.DroppedAssetClickType = void 0;
41043
+ (function (DroppedAssetClickType) {
41044
+ DroppedAssetClickType["NONE"] = "none";
41045
+ DroppedAssetClickType["LINK"] = "link";
41046
+ DroppedAssetClickType["PORTAL"] = "portal";
41047
+ DroppedAssetClickType["TELEPORT"] = "teleport";
41048
+ })(exports.DroppedAssetClickType || (exports.DroppedAssetClickType = {}));
41049
+ exports.DroppedAssetMediaType = void 0;
41050
+ (function (DroppedAssetMediaType) {
41051
+ DroppedAssetMediaType["NONE"] = "none";
41052
+ DroppedAssetMediaType["LINK"] = "link";
41053
+ })(exports.DroppedAssetMediaType || (exports.DroppedAssetMediaType = {}));
41054
+
41016
41055
  Error.stackTraceLimit = 20;
41017
41056
  process.on("unhandledRejection", (reason) => {
41018
- if (reason.data) {
41057
+ if (reason && reason.data) {
41019
41058
  const { errors } = reason.data;
41020
41059
  if (Array.isArray(errors)) {
41021
41060
  for (const error of errors) {
@@ -41023,8 +41062,12 @@ process.on("unhandledRejection", (reason) => {
41023
41062
  }
41024
41063
  }
41025
41064
  }
41065
+ else {
41066
+ console.error("Unhandled rejection failed with no defined reason.");
41067
+ }
41026
41068
  console.error((reason === null || reason === void 0 ? void 0 : reason.stack) || "no stack");
41027
- delete reason.stack;
41069
+ if (reason && reason.stack)
41070
+ delete reason.stack;
41028
41071
  console.error(reason);
41029
41072
  console.error(`Please surround your use of the RTSDK with a try/catch block.`);
41030
41073
  process.exit(1);
package/dist/index.js CHANGED
@@ -39770,31 +39770,40 @@ class SDKController {
39770
39770
  this.requestOptions = { headers };
39771
39771
  }
39772
39772
  topiaPublicApi() {
39773
- this.stackTrace = new Error("Thrown here:");
39774
39773
  return this.topia.axios;
39775
39774
  }
39776
39775
  errorHandler({ error, message = "Something went wrong. Please try again or contact support.", }) {
39777
- var _a, _b, _c, _d;
39778
- let data = {}, errorMessage = message, status = 500, url = "unknown", method = "unknown", stack = "empty";
39776
+ var _a, _b;
39777
+ const stackTrace = new Error("Thrown here:");
39778
+ let data = {}, errorMessage = message, method = "unknown", stack = "empty", status = 500, url = "unknown";
39779
39779
  if (error instanceof AxiosError) {
39780
39780
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || message;
39781
39781
  if (error.response) {
39782
39782
  status = error.response.status;
39783
39783
  data = error.response.data;
39784
+ if (error.response.data.errors)
39785
+ errorMessage = error.response.data.errors[0].message;
39784
39786
  }
39785
39787
  if ((_a = error === null || error === void 0 ? void 0 : error.config) === null || _a === void 0 ? void 0 : _a.url)
39786
39788
  url = error.config.url;
39787
39789
  if ((_b = error === null || error === void 0 ? void 0 : error.config) === null || _b === void 0 ? void 0 : _b.method)
39788
39790
  method = error.config.method;
39789
- if ((_c = this.stackTrace) === null || _c === void 0 ? void 0 : _c.stack)
39790
- stack = `${error.stack}\n${this.stackTrace.stack}`;
39791
+ stack = `${error.stack}\n${stackTrace.stack}`;
39791
39792
  }
39792
39793
  else if (error instanceof Error) {
39793
39794
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || message;
39794
- if ((_d = this.stackTrace) === null || _d === void 0 ? void 0 : _d.stack)
39795
- stack = `${error.stack}\n${this.stackTrace.stack}`;
39795
+ stack = `${error.stack}\n${stackTrace.stack}`;
39796
39796
  }
39797
- return { success: false, status, url, method, message: errorMessage, data, stack };
39797
+ return {
39798
+ data,
39799
+ message: errorMessage,
39800
+ method,
39801
+ stack,
39802
+ stackTrace,
39803
+ status,
39804
+ success: false,
39805
+ url,
39806
+ };
39798
39807
  }
39799
39808
  }
39800
39809
 
@@ -40094,6 +40103,23 @@ class DroppedAsset extends Asset {
40094
40103
  throw this.errorHandler({ error });
40095
40104
  }
40096
40105
  }
40106
+ /**
40107
+ * @summary
40108
+ * Updates webhook zone options for a dropped asset.
40109
+ *
40110
+ * @usage
40111
+ * ```ts
40112
+ * await droppedAsset.updateWebhookZone(true);
40113
+ * ```
40114
+ */
40115
+ updateWebhookZone(isWebhookZoneEnabled) {
40116
+ try {
40117
+ return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { isWebhookZoneEnabled }, "set-webhook-zone");
40118
+ }
40119
+ catch (error) {
40120
+ throw this.errorHandler({ error });
40121
+ }
40122
+ }
40097
40123
  /**
40098
40124
  * @summary
40099
40125
  * Moves a dropped asset to specified coordinates.
@@ -40117,7 +40143,7 @@ class DroppedAsset extends Asset {
40117
40143
  *
40118
40144
  * @usage
40119
40145
  * ```ts
40120
- * await droppedAsset.updateMuteZone({
40146
+ * await droppedAsset.updatePrivateZone({
40121
40147
  * "isPrivateZone": false,
40122
40148
  * "isPrivateZoneChatDisabled": true,
40123
40149
  * "privateZoneUserCap": 10
@@ -40205,7 +40231,7 @@ class DroppedAsset extends Asset {
40205
40231
  addWebhook({ dataObject, description, isUniqueOnly, title, type, url, }) {
40206
40232
  return __awaiter(this, void 0, void 0, function* () {
40207
40233
  try {
40208
- yield this.topiaPublicApi().post(`/world/${this.urlSlug}/webhooks`, {
40234
+ const response = yield this.topiaPublicApi().post(`/world/${this.urlSlug}/webhooks`, {
40209
40235
  active: true,
40210
40236
  assetId: this.id,
40211
40237
  dataObject,
@@ -40217,6 +40243,7 @@ class DroppedAsset extends Asset {
40217
40243
  url,
40218
40244
  urlSlug: this.urlSlug,
40219
40245
  }, this.requestOptions);
40246
+ return response.data.webhookId;
40220
40247
  }
40221
40248
  catch (error) {
40222
40249
  throw this.errorHandler({ error });
@@ -40412,7 +40439,6 @@ class World extends SDKController {
40412
40439
  // create temp map and then update private property only once
40413
40440
  const tempDroppedAssetsMap = {};
40414
40441
  for (const index in response.data) {
40415
- // tempDroppedAssetsMap[id] = createDroppedAsset(this.apiKey, response.data[id], this.urlSlug);
40416
40442
  tempDroppedAssetsMap[index] = new DroppedAsset(this.topia, response.data[index].id, this.urlSlug, {
40417
40443
  attributes: response.data[index],
40418
40444
  credentials: this.credentials,
@@ -41011,9 +41037,22 @@ class WorldFactory {
41011
41037
  }
41012
41038
  }
41013
41039
 
41040
+ var DroppedAssetClickType;
41041
+ (function (DroppedAssetClickType) {
41042
+ DroppedAssetClickType["NONE"] = "none";
41043
+ DroppedAssetClickType["LINK"] = "link";
41044
+ DroppedAssetClickType["PORTAL"] = "portal";
41045
+ DroppedAssetClickType["TELEPORT"] = "teleport";
41046
+ })(DroppedAssetClickType || (DroppedAssetClickType = {}));
41047
+ var DroppedAssetMediaType;
41048
+ (function (DroppedAssetMediaType) {
41049
+ DroppedAssetMediaType["NONE"] = "none";
41050
+ DroppedAssetMediaType["LINK"] = "link";
41051
+ })(DroppedAssetMediaType || (DroppedAssetMediaType = {}));
41052
+
41014
41053
  Error.stackTraceLimit = 20;
41015
41054
  process.on("unhandledRejection", (reason) => {
41016
- if (reason.data) {
41055
+ if (reason && reason.data) {
41017
41056
  const { errors } = reason.data;
41018
41057
  if (Array.isArray(errors)) {
41019
41058
  for (const error of errors) {
@@ -41021,8 +41060,12 @@ process.on("unhandledRejection", (reason) => {
41021
41060
  }
41022
41061
  }
41023
41062
  }
41063
+ else {
41064
+ console.error("Unhandled rejection failed with no defined reason.");
41065
+ }
41024
41066
  console.error((reason === null || reason === void 0 ? void 0 : reason.stack) || "no stack");
41025
- delete reason.stack;
41067
+ if (reason && reason.stack)
41068
+ delete reason.stack;
41026
41069
  console.error(reason);
41027
41070
  console.error(`Please surround your use of the RTSDK with a try/catch block.`);
41028
41071
  process.exit(1);
@@ -41033,4 +41076,4 @@ process.on("uncaughtException", function (err) {
41033
41076
  process.exit(1);
41034
41077
  });
41035
41078
 
41036
- export { AssetFactory, DroppedAssetFactory, SceneFactory, Topia, UserFactory, VisitorFactory, WorldActivityFactory, WorldFactory };
41079
+ export { AssetFactory, DroppedAssetClickType, DroppedAssetFactory, DroppedAssetMediaType, SceneFactory, Topia, UserFactory, VisitorFactory, WorldActivityFactory, WorldFactory };
@@ -282,6 +282,23 @@ export class DroppedAsset extends Asset {
282
282
  throw this.errorHandler({ error });
283
283
  }
284
284
  }
285
+ /**
286
+ * @summary
287
+ * Updates webhook zone options for a dropped asset.
288
+ *
289
+ * @usage
290
+ * ```ts
291
+ * await droppedAsset.updateWebhookZone(true);
292
+ * ```
293
+ */
294
+ updateWebhookZone(isWebhookZoneEnabled) {
295
+ try {
296
+ return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { isWebhookZoneEnabled }, "set-webhook-zone");
297
+ }
298
+ catch (error) {
299
+ throw this.errorHandler({ error });
300
+ }
301
+ }
285
302
  /**
286
303
  * @summary
287
304
  * Moves a dropped asset to specified coordinates.
@@ -305,7 +322,7 @@ export class DroppedAsset extends Asset {
305
322
  *
306
323
  * @usage
307
324
  * ```ts
308
- * await droppedAsset.updateMuteZone({
325
+ * await droppedAsset.updatePrivateZone({
309
326
  * "isPrivateZone": false,
310
327
  * "isPrivateZoneChatDisabled": true,
311
328
  * "privateZoneUserCap": 10
@@ -393,7 +410,7 @@ export class DroppedAsset extends Asset {
393
410
  addWebhook({ dataObject, description, isUniqueOnly, title, type, url, }) {
394
411
  return __awaiter(this, void 0, void 0, function* () {
395
412
  try {
396
- yield this.topiaPublicApi().post(`/world/${this.urlSlug}/webhooks`, {
413
+ const response = yield this.topiaPublicApi().post(`/world/${this.urlSlug}/webhooks`, {
397
414
  active: true,
398
415
  assetId: this.id,
399
416
  dataObject,
@@ -405,6 +422,7 @@ export class DroppedAsset extends Asset {
405
422
  url,
406
423
  urlSlug: this.urlSlug,
407
424
  }, this.requestOptions);
425
+ return response.data.webhookId;
408
426
  }
409
427
  catch (error) {
410
428
  throw this.errorHandler({ error });
@@ -46,31 +46,40 @@ export class SDKController {
46
46
  this.requestOptions = { headers };
47
47
  }
48
48
  topiaPublicApi() {
49
- this.stackTrace = new Error("Thrown here:");
50
49
  return this.topia.axios;
51
50
  }
52
51
  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";
52
+ var _a, _b;
53
+ const stackTrace = new Error("Thrown here:");
54
+ let data = {}, errorMessage = message, method = "unknown", stack = "empty", status = 500, url = "unknown";
55
55
  if (error instanceof AxiosError) {
56
56
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || message;
57
57
  if (error.response) {
58
58
  status = error.response.status;
59
59
  data = error.response.data;
60
+ if (error.response.data.errors)
61
+ errorMessage = error.response.data.errors[0].message;
60
62
  }
61
63
  if ((_a = error === null || error === void 0 ? void 0 : error.config) === null || _a === void 0 ? void 0 : _a.url)
62
64
  url = error.config.url;
63
65
  if ((_b = error === null || error === void 0 ? void 0 : error.config) === null || _b === void 0 ? void 0 : _b.method)
64
66
  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
+ stack = `${error.stack}\n${stackTrace.stack}`;
67
68
  }
68
69
  else if (error instanceof Error) {
69
70
  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}`;
71
+ stack = `${error.stack}\n${stackTrace.stack}`;
72
72
  }
73
- return { success: false, status, url, method, message: errorMessage, data, stack };
73
+ return {
74
+ data,
75
+ message: errorMessage,
76
+ method,
77
+ stack,
78
+ stackTrace,
79
+ status,
80
+ success: false,
81
+ url,
82
+ };
74
83
  }
75
84
  }
76
85
  export default SDKController;
@@ -127,7 +127,6 @@ export class World extends SDKController {
127
127
  // create temp map and then update private property only once
128
128
  const tempDroppedAssetsMap = {};
129
129
  for (const index in response.data) {
130
- // tempDroppedAssetsMap[id] = createDroppedAsset(this.apiKey, response.data[id], this.urlSlug);
131
130
  tempDroppedAssetsMap[index] = new DroppedAsset(this.topia, response.data[index].id, this.urlSlug, {
132
131
  attributes: response.data[index],
133
132
  credentials: this.credentials,
package/dist/src/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  export { Topia } from "controllers";
2
2
  export { AssetFactory, DroppedAssetFactory, SceneFactory, UserFactory, VisitorFactory, WorldActivityFactory, WorldFactory, } from "factories";
3
+ export * from "types";
3
4
  Error.stackTraceLimit = 20;
4
5
  process.on("unhandledRejection", (reason) => {
5
- if (reason.data) {
6
+ if (reason && reason.data) {
6
7
  const { errors } = reason.data;
7
8
  if (Array.isArray(errors)) {
8
9
  for (const error of errors) {
@@ -10,8 +11,12 @@ process.on("unhandledRejection", (reason) => {
10
11
  }
11
12
  }
12
13
  }
14
+ else {
15
+ console.error("Unhandled rejection failed with no defined reason.");
16
+ }
13
17
  console.error((reason === null || reason === void 0 ? void 0 : reason.stack) || "no stack");
14
- delete reason.stack;
18
+ if (reason && reason.stack)
19
+ delete reason.stack;
15
20
  console.error(reason);
16
21
  console.error(`Please surround your use of the RTSDK with a try/catch block.`);
17
22
  process.exit(1);
package/package.json CHANGED
@@ -56,5 +56,5 @@
56
56
  "local-publish": "yarn build && yalc publish --push --no-scripts"
57
57
  },
58
58
  "type": "module",
59
- "version": "0.0.31"
59
+ "version": "0.1.0"
60
60
  }