@rtsdk/topia 0.19.6 → 0.19.7

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
@@ -39751,6 +39751,11 @@ class SDKController {
39751
39751
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || message;
39752
39752
  stack = `${error.stack}\n${stackTrace.stack}`;
39753
39753
  }
39754
+ else if (error !== undefined && error !== null) {
39755
+ // Handle bare string throws and other non-Error types
39756
+ errorMessage = typeof error === "string" ? error : JSON.stringify(error);
39757
+ stack = stackTrace.stack || "empty";
39758
+ }
39754
39759
  return {
39755
39760
  data,
39756
39761
  message: errorMessage,
@@ -42258,6 +42263,7 @@ AI RULES for code assistants
42258
42263
  */
42259
42264
  class User extends SDKController {
42260
42265
  constructor(topia, options = { profileId: null, credentials: {} }) {
42266
+ var _a;
42261
42267
  super(topia, Object.assign({ profileId: options === null || options === void 0 ? void 0 : options.profileId }, options.credentials));
42262
42268
  _User_userInventoryItems.set(this, void 0);
42263
42269
  _User_adminWorldsMap.set(this, void 0);
@@ -42265,6 +42271,13 @@ class User extends SDKController {
42265
42271
  _User_scenesMap.set(this, void 0);
42266
42272
  _User_worldsMap.set(this, void 0);
42267
42273
  this.profileId = options === null || options === void 0 ? void 0 : options.profileId;
42274
+ // Warn devs about common mistake: passing profileId only inside credentials
42275
+ if (!this.profileId && ((_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.profileId)) {
42276
+ console.warn(`[@rtsdk/topia] User created without top-level profileId. ` +
42277
+ `You passed profileId inside credentials but not in options. ` +
42278
+ `Methods like grantInventoryItem will fail. ` +
42279
+ `Fix: User.create({ profileId: "${options.credentials.profileId}", credentials: { ... } })`);
42280
+ }
42268
42281
  this.dataObject = {};
42269
42282
  this.profile = {};
42270
42283
  __classPrivateFieldSet(this, _User_adminWorldsMap, {}, "f");
@@ -42778,7 +42791,7 @@ class User extends SDKController {
42778
42791
  return __awaiter(this, void 0, void 0, function* () {
42779
42792
  try {
42780
42793
  if (!this.profileId)
42781
- throw "This method requires the use of a profileId";
42794
+ throw new Error("This method requires the use of a profileId. Pass profileId as a top-level option: User.create({ profileId, credentials: { ... } })");
42782
42795
  let query = "";
42783
42796
  if (appPublicKey)
42784
42797
  query = `?appPublicKey=${appPublicKey}&appJWT=${appJWT}`;
@@ -42818,7 +42831,7 @@ class User extends SDKController {
42818
42831
  return __awaiter(this, void 0, void 0, function* () {
42819
42832
  try {
42820
42833
  if (!this.profileId)
42821
- throw "This method requires the use of a profileId";
42834
+ throw new Error("This method requires the use of a profileId. Pass profileId as a top-level option: User.create({ profileId, credentials: { ... } })");
42822
42835
  yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/set-data-object`, Object.assign(Object.assign({}, options), { dataObject: dataObject || this.dataObject }), this.requestOptions);
42823
42836
  this.dataObject = dataObject || this.dataObject;
42824
42837
  }
@@ -42852,7 +42865,7 @@ class User extends SDKController {
42852
42865
  return __awaiter(this, void 0, void 0, function* () {
42853
42866
  try {
42854
42867
  if (!this.profileId)
42855
- throw "This method requires the use of a profileId";
42868
+ throw new Error("This method requires the use of a profileId. Pass profileId as a top-level option: User.create({ profileId, credentials: { ... } })");
42856
42869
  yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/update-data-object`, Object.assign(Object.assign({}, options), { dataObject: dataObject || this.dataObject }), this.requestOptions);
42857
42870
  this.dataObject = Object.assign(Object.assign({}, (this.dataObject || {})), (dataObject || {}));
42858
42871
  }
@@ -42902,7 +42915,7 @@ class User extends SDKController {
42902
42915
  return __awaiter(this, void 0, void 0, function* () {
42903
42916
  try {
42904
42917
  if (!this.profileId)
42905
- throw "This method requires the use of a profileId";
42918
+ throw new Error("This method requires the use of a profileId. Pass profileId as a top-level option: User.create({ profileId, credentials: { ... } })");
42906
42919
  const response = yield this.topiaPublicApi().get(`/user/inventory/${this.profileId}/get-user-inventory-items`, this.requestOptions);
42907
42920
  // TODO: Replace 'object' with InventoryItem and instantiate InventoryItem objects if needed
42908
42921
  const tempItems = [];
@@ -42915,7 +42928,7 @@ class User extends SDKController {
42915
42928
  __classPrivateFieldSet(this, _User_userInventoryItems, tempItems, "f");
42916
42929
  }
42917
42930
  catch (error) {
42918
- throw this.errorHandler({ error, sdkMethod: "Visitor.fetchInventoryItems" });
42931
+ throw this.errorHandler({ error, sdkMethod: "User.fetchInventoryItems" });
42919
42932
  }
42920
42933
  });
42921
42934
  }
@@ -42939,7 +42952,7 @@ class User extends SDKController {
42939
42952
  return __awaiter(this, void 0, void 0, function* () {
42940
42953
  try {
42941
42954
  if (!this.profileId)
42942
- throw "This method requires the use of a profileId";
42955
+ throw new Error("This method requires the use of a profileId. Pass profileId as a top-level option: User.create({ profileId, credentials: { ... } })");
42943
42956
  const response = yield this.topiaPublicApi().put(`/user/inventory/${this.profileId}/grant-user-inventory-item`, { itemId: item.id, quantity }, this.requestOptions);
42944
42957
  const userInventoryItemFactory = new UserInventoryItemFactory(this.topia);
42945
42958
  const { inventoryItem, user_id, quantity: newQuantity } = response.data;
@@ -42949,7 +42962,7 @@ class User extends SDKController {
42949
42962
  });
42950
42963
  }
42951
42964
  catch (error) {
42952
- throw this.errorHandler({ error, sdkMethod: "Visitor.grantInventoryItem" });
42965
+ throw this.errorHandler({ error, sdkMethod: "User.grantInventoryItem" });
42953
42966
  }
42954
42967
  });
42955
42968
  }
@@ -42970,7 +42983,7 @@ class User extends SDKController {
42970
42983
  return __awaiter(this, void 0, void 0, function* () {
42971
42984
  try {
42972
42985
  if (!this.profileId)
42973
- throw "This method requires the use of a profileId";
42986
+ throw new Error("This method requires the use of a profileId. Pass profileId as a top-level option: User.create({ profileId, credentials: { ... } })");
42974
42987
  const response = yield this.topiaPublicApi().put(`/user/inventory/${this.profileId}/update-user-inventory-item-quantity`, { userItemId: item.id, itemId: item.item_id, quantity }, this.requestOptions);
42975
42988
  const userInventoryItemFactory = new UserInventoryItemFactory(this.topia);
42976
42989
  const { inventoryItem, user_id, quantity: newQuantity } = response.data;
@@ -42980,7 +42993,7 @@ class User extends SDKController {
42980
42993
  });
42981
42994
  }
42982
42995
  catch (error) {
42983
- throw this.errorHandler({ error, sdkMethod: "Visitor.modifyInventoryItemQuantity" });
42996
+ throw this.errorHandler({ error, sdkMethod: "User.modifyInventoryItemQuantity" });
42984
42997
  }
42985
42998
  });
42986
42999
  }
package/dist/index.js CHANGED
@@ -39749,6 +39749,11 @@ class SDKController {
39749
39749
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || message;
39750
39750
  stack = `${error.stack}\n${stackTrace.stack}`;
39751
39751
  }
39752
+ else if (error !== undefined && error !== null) {
39753
+ // Handle bare string throws and other non-Error types
39754
+ errorMessage = typeof error === "string" ? error : JSON.stringify(error);
39755
+ stack = stackTrace.stack || "empty";
39756
+ }
39752
39757
  return {
39753
39758
  data,
39754
39759
  message: errorMessage,
@@ -42256,6 +42261,7 @@ AI RULES for code assistants
42256
42261
  */
42257
42262
  class User extends SDKController {
42258
42263
  constructor(topia, options = { profileId: null, credentials: {} }) {
42264
+ var _a;
42259
42265
  super(topia, Object.assign({ profileId: options === null || options === void 0 ? void 0 : options.profileId }, options.credentials));
42260
42266
  _User_userInventoryItems.set(this, void 0);
42261
42267
  _User_adminWorldsMap.set(this, void 0);
@@ -42263,6 +42269,13 @@ class User extends SDKController {
42263
42269
  _User_scenesMap.set(this, void 0);
42264
42270
  _User_worldsMap.set(this, void 0);
42265
42271
  this.profileId = options === null || options === void 0 ? void 0 : options.profileId;
42272
+ // Warn devs about common mistake: passing profileId only inside credentials
42273
+ if (!this.profileId && ((_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.profileId)) {
42274
+ console.warn(`[@rtsdk/topia] User created without top-level profileId. ` +
42275
+ `You passed profileId inside credentials but not in options. ` +
42276
+ `Methods like grantInventoryItem will fail. ` +
42277
+ `Fix: User.create({ profileId: "${options.credentials.profileId}", credentials: { ... } })`);
42278
+ }
42266
42279
  this.dataObject = {};
42267
42280
  this.profile = {};
42268
42281
  __classPrivateFieldSet(this, _User_adminWorldsMap, {}, "f");
@@ -42776,7 +42789,7 @@ class User extends SDKController {
42776
42789
  return __awaiter(this, void 0, void 0, function* () {
42777
42790
  try {
42778
42791
  if (!this.profileId)
42779
- throw "This method requires the use of a profileId";
42792
+ throw new Error("This method requires the use of a profileId. Pass profileId as a top-level option: User.create({ profileId, credentials: { ... } })");
42780
42793
  let query = "";
42781
42794
  if (appPublicKey)
42782
42795
  query = `?appPublicKey=${appPublicKey}&appJWT=${appJWT}`;
@@ -42816,7 +42829,7 @@ class User extends SDKController {
42816
42829
  return __awaiter(this, void 0, void 0, function* () {
42817
42830
  try {
42818
42831
  if (!this.profileId)
42819
- throw "This method requires the use of a profileId";
42832
+ throw new Error("This method requires the use of a profileId. Pass profileId as a top-level option: User.create({ profileId, credentials: { ... } })");
42820
42833
  yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/set-data-object`, Object.assign(Object.assign({}, options), { dataObject: dataObject || this.dataObject }), this.requestOptions);
42821
42834
  this.dataObject = dataObject || this.dataObject;
42822
42835
  }
@@ -42850,7 +42863,7 @@ class User extends SDKController {
42850
42863
  return __awaiter(this, void 0, void 0, function* () {
42851
42864
  try {
42852
42865
  if (!this.profileId)
42853
- throw "This method requires the use of a profileId";
42866
+ throw new Error("This method requires the use of a profileId. Pass profileId as a top-level option: User.create({ profileId, credentials: { ... } })");
42854
42867
  yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/update-data-object`, Object.assign(Object.assign({}, options), { dataObject: dataObject || this.dataObject }), this.requestOptions);
42855
42868
  this.dataObject = Object.assign(Object.assign({}, (this.dataObject || {})), (dataObject || {}));
42856
42869
  }
@@ -42900,7 +42913,7 @@ class User extends SDKController {
42900
42913
  return __awaiter(this, void 0, void 0, function* () {
42901
42914
  try {
42902
42915
  if (!this.profileId)
42903
- throw "This method requires the use of a profileId";
42916
+ throw new Error("This method requires the use of a profileId. Pass profileId as a top-level option: User.create({ profileId, credentials: { ... } })");
42904
42917
  const response = yield this.topiaPublicApi().get(`/user/inventory/${this.profileId}/get-user-inventory-items`, this.requestOptions);
42905
42918
  // TODO: Replace 'object' with InventoryItem and instantiate InventoryItem objects if needed
42906
42919
  const tempItems = [];
@@ -42913,7 +42926,7 @@ class User extends SDKController {
42913
42926
  __classPrivateFieldSet(this, _User_userInventoryItems, tempItems, "f");
42914
42927
  }
42915
42928
  catch (error) {
42916
- throw this.errorHandler({ error, sdkMethod: "Visitor.fetchInventoryItems" });
42929
+ throw this.errorHandler({ error, sdkMethod: "User.fetchInventoryItems" });
42917
42930
  }
42918
42931
  });
42919
42932
  }
@@ -42937,7 +42950,7 @@ class User extends SDKController {
42937
42950
  return __awaiter(this, void 0, void 0, function* () {
42938
42951
  try {
42939
42952
  if (!this.profileId)
42940
- throw "This method requires the use of a profileId";
42953
+ throw new Error("This method requires the use of a profileId. Pass profileId as a top-level option: User.create({ profileId, credentials: { ... } })");
42941
42954
  const response = yield this.topiaPublicApi().put(`/user/inventory/${this.profileId}/grant-user-inventory-item`, { itemId: item.id, quantity }, this.requestOptions);
42942
42955
  const userInventoryItemFactory = new UserInventoryItemFactory(this.topia);
42943
42956
  const { inventoryItem, user_id, quantity: newQuantity } = response.data;
@@ -42947,7 +42960,7 @@ class User extends SDKController {
42947
42960
  });
42948
42961
  }
42949
42962
  catch (error) {
42950
- throw this.errorHandler({ error, sdkMethod: "Visitor.grantInventoryItem" });
42963
+ throw this.errorHandler({ error, sdkMethod: "User.grantInventoryItem" });
42951
42964
  }
42952
42965
  });
42953
42966
  }
@@ -42968,7 +42981,7 @@ class User extends SDKController {
42968
42981
  return __awaiter(this, void 0, void 0, function* () {
42969
42982
  try {
42970
42983
  if (!this.profileId)
42971
- throw "This method requires the use of a profileId";
42984
+ throw new Error("This method requires the use of a profileId. Pass profileId as a top-level option: User.create({ profileId, credentials: { ... } })");
42972
42985
  const response = yield this.topiaPublicApi().put(`/user/inventory/${this.profileId}/update-user-inventory-item-quantity`, { userItemId: item.id, itemId: item.item_id, quantity }, this.requestOptions);
42973
42986
  const userInventoryItemFactory = new UserInventoryItemFactory(this.topia);
42974
42987
  const { inventoryItem, user_id, quantity: newQuantity } = response.data;
@@ -42978,7 +42991,7 @@ class User extends SDKController {
42978
42991
  });
42979
42992
  }
42980
42993
  catch (error) {
42981
- throw this.errorHandler({ error, sdkMethod: "Visitor.modifyInventoryItemQuantity" });
42994
+ throw this.errorHandler({ error, sdkMethod: "User.modifyInventoryItemQuantity" });
42982
42995
  }
42983
42996
  });
42984
42997
  }
package/package.json CHANGED
@@ -61,5 +61,5 @@
61
61
  "yalc-push": "yarn build && yalc publish --push --dev --no-scripts"
62
62
  },
63
63
  "type": "module",
64
- "version": "0.19.06"
64
+ "version": "0.19.07"
65
65
  }