@rtsdk/topia 0.18.1 → 0.18.3

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
@@ -42624,13 +42624,13 @@ class User extends SDKController {
42624
42624
  });
42625
42625
  }
42626
42626
  /**
42627
- * Retrieves all inventory items owned by this visitor and app's key.
42627
+ * Retrieves all inventory items owned by this user and app's key.
42628
42628
  *
42629
- * @keywords get, fetch, retrieve, list, inventory, items, visitor
42629
+ * @keywords get, fetch, retrieve, list, inventory, items, user
42630
42630
  *
42631
42631
  * @example
42632
42632
  * ```ts
42633
- * const items = await visitor.fetchInventoryItems();
42633
+ * const items = await user.fetchInventoryItems();
42634
42634
  * ```
42635
42635
  *
42636
42636
  * @returns {Promise<void>} Returns an array of InventoryItem objects.
@@ -42640,7 +42640,7 @@ class User extends SDKController {
42640
42640
  try {
42641
42641
  if (!this.profileId)
42642
42642
  throw "This method requires the use of a profileId";
42643
- const response = yield this.topiaPublicApi().get(`/user/${this.profileId}/get-user-inventory-items`, this.requestOptions);
42643
+ const response = yield this.topiaPublicApi().get(`/user/inventory/${this.profileId}/get-user-inventory-items`, this.requestOptions);
42644
42644
  // TODO: Replace 'object' with InventoryItem and instantiate InventoryItem objects if needed
42645
42645
  const tempItems = [];
42646
42646
  for (const index in response.data) {
@@ -42659,6 +42659,68 @@ class User extends SDKController {
42659
42659
  get inventoryItems() {
42660
42660
  return __classPrivateFieldGet(this, _User_userInventoryItems, "f");
42661
42661
  }
42662
+ /**
42663
+ * Grants an inventory item to this user.
42664
+ *
42665
+ * @param item The InventoryItem to modify.
42666
+ * @param quantity The new quantity to set.
42667
+ *
42668
+ * @example
42669
+ * ```ts
42670
+ * const items = await user.grantInventoryItem("item-id-123", 2);
42671
+ * ```
42672
+ *
42673
+ * @returns {Promise<UserInventoryItem>} Returns the UserInventoryItem granted.
42674
+ */
42675
+ grantInventoryItem(item, quantity = 1) {
42676
+ return __awaiter(this, void 0, void 0, function* () {
42677
+ try {
42678
+ if (!this.profileId)
42679
+ throw "This method requires the use of a profileId";
42680
+ const response = yield this.topiaPublicApi().put(`/user/inventory/${this.profileId}/grant-user-inventory-item`, { itemId: item.id, quantity }, this.requestOptions);
42681
+ const userInventoryItemFactory = new UserInventoryItemFactory(this.topia);
42682
+ const { inventoryItem, user_id, quantity: newQuantity } = response.data;
42683
+ return userInventoryItemFactory.create(inventoryItem, user_id, newQuantity, {
42684
+ attributes: response.data,
42685
+ credentials: this.credentials,
42686
+ });
42687
+ }
42688
+ catch (error) {
42689
+ throw this.errorHandler({ error, sdkMethod: "Visitor.grantInventoryItem" });
42690
+ }
42691
+ });
42692
+ }
42693
+ /**
42694
+ * Modifies the quantity of an inventory item in this user's inventory.
42695
+ *
42696
+ * @param item The UserInventoryItem to modify.
42697
+ * @param quantity The new quantity to set.
42698
+ *
42699
+ * @example
42700
+ * ```ts
42701
+ * await user.modifyInventoryItemQuantity("item-id-123", 5);
42702
+ * ```
42703
+ *
42704
+ * @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
42705
+ */
42706
+ modifyInventoryItemQuantity(item, quantity) {
42707
+ return __awaiter(this, void 0, void 0, function* () {
42708
+ try {
42709
+ if (!this.profileId)
42710
+ throw "This method requires the use of a profileId";
42711
+ 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);
42712
+ const userInventoryItemFactory = new UserInventoryItemFactory(this.topia);
42713
+ const { inventoryItem, user_id, quantity: newQuantity } = response.data;
42714
+ return userInventoryItemFactory.create(inventoryItem, user_id, newQuantity, {
42715
+ attributes: response.data,
42716
+ credentials: this.credentials,
42717
+ });
42718
+ }
42719
+ catch (error) {
42720
+ throw this.errorHandler({ error, sdkMethod: "Visitor.modifyInventoryItemQuantity" });
42721
+ }
42722
+ });
42723
+ }
42662
42724
  }
42663
42725
  _User_userInventoryItems = new WeakMap(), _User_adminWorldsMap = new WeakMap(), _User_assetsMap = new WeakMap(), _User_scenesMap = new WeakMap(), _User_worldsMap = new WeakMap();
42664
42726
 
@@ -43278,8 +43340,8 @@ class Visitor extends User {
43278
43340
  /**
43279
43341
  * Grants an inventory item to this visitor.
43280
43342
  *
43281
- * @param item The ID of the inventory item to grant.
43282
- * @param quantity The quantity to grant (default 1).
43343
+ * @param item The InventoryItem to modify.
43344
+ * @param quantity The new quantity to set.
43283
43345
  *
43284
43346
  * @example
43285
43347
  * ```ts
@@ -43313,7 +43375,7 @@ class Visitor extends User {
43313
43375
  /**
43314
43376
  * Modifies the quantity of an inventory item in this visitor's inventory.
43315
43377
  *
43316
- * @param item The ID of the inventory item to modify.
43378
+ * @param item The UserInventoryItem to modify.
43317
43379
  * @param quantity The new quantity to set.
43318
43380
  *
43319
43381
  * @example
package/dist/index.d.ts CHANGED
@@ -1204,6 +1204,39 @@ declare class UserInventoryItem extends InventoryItem implements UserInventoryIt
1204
1204
  fetchUserInventoryItemById(): Promise<void>;
1205
1205
  }
1206
1206
 
1207
+ /**
1208
+ * InventoryItem represents an item in a user's inventory.
1209
+ *
1210
+ * @remarks
1211
+ * This class should be instantiated via InventoryFactory only.
1212
+ *
1213
+ * @keywords inventory, item, asset, object
1214
+ */
1215
+ declare class InventoryItem extends SDKController implements InventoryItemInterface {
1216
+ id: string;
1217
+ name?: string;
1218
+ description?: string;
1219
+ type?: string;
1220
+ created_at?: Date;
1221
+ updated_at?: Date;
1222
+ metadata?: object | null;
1223
+ image_path?: string;
1224
+ interactive_key_id?: string;
1225
+ status?: string;
1226
+ constructor(topia: Topia, id: string, options?: InventoryItemOptionalInterface);
1227
+ /**
1228
+ * Fetches the inventory item details from the platform and assigns them to this instance.
1229
+ *
1230
+ * @example
1231
+ * ```ts
1232
+ * await item.fetchInventoryItemById();
1233
+ * ```
1234
+ *
1235
+ * @returns {Promise<InventoryItem>} Returns when the item has been fetched and assigned.
1236
+ */
1237
+ fetchInventoryItemById(): Promise<InventoryItem>;
1238
+ }
1239
+
1207
1240
  /**
1208
1241
  * Create an instance of User class with optional session credentials.
1209
1242
  *
@@ -1648,52 +1681,47 @@ declare class User extends SDKController implements UserInterface {
1648
1681
  };
1649
1682
  }): Promise<void | ResponseType$1>;
1650
1683
  /**
1651
- * Retrieves all inventory items owned by this visitor and app's key.
1684
+ * Retrieves all inventory items owned by this user and app's key.
1652
1685
  *
1653
- * @keywords get, fetch, retrieve, list, inventory, items, visitor
1686
+ * @keywords get, fetch, retrieve, list, inventory, items, user
1654
1687
  *
1655
1688
  * @example
1656
1689
  * ```ts
1657
- * const items = await visitor.fetchInventoryItems();
1690
+ * const items = await user.fetchInventoryItems();
1658
1691
  * ```
1659
1692
  *
1660
1693
  * @returns {Promise<void>} Returns an array of InventoryItem objects.
1661
1694
  */
1662
1695
  fetchInventoryItems(): Promise<void>;
1663
1696
  get inventoryItems(): UserInventoryItem[];
1664
- }
1665
-
1666
- /**
1667
- * InventoryItem represents an item in a user's inventory.
1668
- *
1669
- * @remarks
1670
- * This class should be instantiated via InventoryFactory only.
1671
- *
1672
- * @keywords inventory, item, asset, object
1673
- */
1674
- declare class InventoryItem extends SDKController implements InventoryItemInterface {
1675
- id: string;
1676
- name?: string;
1677
- description?: string;
1678
- type?: string;
1679
- created_at?: Date;
1680
- updated_at?: Date;
1681
- metadata?: object | null;
1682
- image_path?: string;
1683
- interactive_key_id?: string;
1684
- status?: string;
1685
- constructor(topia: Topia, id: string, options?: InventoryItemOptionalInterface);
1686
1697
  /**
1687
- * Fetches the inventory item details from the platform and assigns them to this instance.
1698
+ * Grants an inventory item to this user.
1699
+ *
1700
+ * @param item The InventoryItem to modify.
1701
+ * @param quantity The new quantity to set.
1688
1702
  *
1689
1703
  * @example
1690
1704
  * ```ts
1691
- * await item.fetchInventoryItemById();
1705
+ * const items = await user.grantInventoryItem("item-id-123", 2);
1692
1706
  * ```
1693
1707
  *
1694
- * @returns {Promise<InventoryItem>} Returns when the item has been fetched and assigned.
1708
+ * @returns {Promise<UserInventoryItem>} Returns the UserInventoryItem granted.
1695
1709
  */
1696
- fetchInventoryItemById(): Promise<InventoryItem>;
1710
+ grantInventoryItem(item: InventoryItem, quantity?: number): Promise<UserInventoryItem>;
1711
+ /**
1712
+ * Modifies the quantity of an inventory item in this user's inventory.
1713
+ *
1714
+ * @param item The UserInventoryItem to modify.
1715
+ * @param quantity The new quantity to set.
1716
+ *
1717
+ * @example
1718
+ * ```ts
1719
+ * await user.modifyInventoryItemQuantity("item-id-123", 5);
1720
+ * ```
1721
+ *
1722
+ * @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
1723
+ */
1724
+ modifyInventoryItemQuantity(item: UserInventoryItem, quantity: number): Promise<UserInventoryItem>;
1697
1725
  }
1698
1726
 
1699
1727
  /**
@@ -2055,8 +2083,8 @@ declare class Visitor extends User implements VisitorInterface {
2055
2083
  /**
2056
2084
  * Grants an inventory item to this visitor.
2057
2085
  *
2058
- * @param item The ID of the inventory item to grant.
2059
- * @param quantity The quantity to grant (default 1).
2086
+ * @param item The InventoryItem to modify.
2087
+ * @param quantity The new quantity to set.
2060
2088
  *
2061
2089
  * @example
2062
2090
  * ```ts
@@ -2069,7 +2097,7 @@ declare class Visitor extends User implements VisitorInterface {
2069
2097
  /**
2070
2098
  * Modifies the quantity of an inventory item in this visitor's inventory.
2071
2099
  *
2072
- * @param item The ID of the inventory item to modify.
2100
+ * @param item The UserInventoryItem to modify.
2073
2101
  * @param quantity The new quantity to set.
2074
2102
  *
2075
2103
  * @example
@@ -2441,6 +2469,10 @@ interface UserInterface {
2441
2469
  fetchDataObject(appPublicKey?: string, appJWT?: string): Promise<void | ResponseType$1>;
2442
2470
  setDataObject(dataObject: object | null | undefined, options: object): Promise<void | ResponseType$1>;
2443
2471
  incrementDataObjectValue(path: string, amount: number, options: object): Promise<void | ResponseType$1>;
2472
+ fetchInventoryItems(): Promise<void>;
2473
+ inventoryItems: UserInventoryItem[];
2474
+ grantInventoryItem(item: InventoryItem, quantity: number): Promise<UserInventoryItem>;
2475
+ modifyInventoryItemQuantity(item: UserInventoryItem, quantity: number): Promise<UserInventoryItem>;
2444
2476
  dataObject?: object | null;
2445
2477
  }
2446
2478
  interface UserOptionalInterface {
package/dist/index.js CHANGED
@@ -42622,13 +42622,13 @@ class User extends SDKController {
42622
42622
  });
42623
42623
  }
42624
42624
  /**
42625
- * Retrieves all inventory items owned by this visitor and app's key.
42625
+ * Retrieves all inventory items owned by this user and app's key.
42626
42626
  *
42627
- * @keywords get, fetch, retrieve, list, inventory, items, visitor
42627
+ * @keywords get, fetch, retrieve, list, inventory, items, user
42628
42628
  *
42629
42629
  * @example
42630
42630
  * ```ts
42631
- * const items = await visitor.fetchInventoryItems();
42631
+ * const items = await user.fetchInventoryItems();
42632
42632
  * ```
42633
42633
  *
42634
42634
  * @returns {Promise<void>} Returns an array of InventoryItem objects.
@@ -42638,7 +42638,7 @@ class User extends SDKController {
42638
42638
  try {
42639
42639
  if (!this.profileId)
42640
42640
  throw "This method requires the use of a profileId";
42641
- const response = yield this.topiaPublicApi().get(`/user/${this.profileId}/get-user-inventory-items`, this.requestOptions);
42641
+ const response = yield this.topiaPublicApi().get(`/user/inventory/${this.profileId}/get-user-inventory-items`, this.requestOptions);
42642
42642
  // TODO: Replace 'object' with InventoryItem and instantiate InventoryItem objects if needed
42643
42643
  const tempItems = [];
42644
42644
  for (const index in response.data) {
@@ -42657,6 +42657,68 @@ class User extends SDKController {
42657
42657
  get inventoryItems() {
42658
42658
  return __classPrivateFieldGet(this, _User_userInventoryItems, "f");
42659
42659
  }
42660
+ /**
42661
+ * Grants an inventory item to this user.
42662
+ *
42663
+ * @param item The InventoryItem to modify.
42664
+ * @param quantity The new quantity to set.
42665
+ *
42666
+ * @example
42667
+ * ```ts
42668
+ * const items = await user.grantInventoryItem("item-id-123", 2);
42669
+ * ```
42670
+ *
42671
+ * @returns {Promise<UserInventoryItem>} Returns the UserInventoryItem granted.
42672
+ */
42673
+ grantInventoryItem(item, quantity = 1) {
42674
+ return __awaiter(this, void 0, void 0, function* () {
42675
+ try {
42676
+ if (!this.profileId)
42677
+ throw "This method requires the use of a profileId";
42678
+ const response = yield this.topiaPublicApi().put(`/user/inventory/${this.profileId}/grant-user-inventory-item`, { itemId: item.id, quantity }, this.requestOptions);
42679
+ const userInventoryItemFactory = new UserInventoryItemFactory(this.topia);
42680
+ const { inventoryItem, user_id, quantity: newQuantity } = response.data;
42681
+ return userInventoryItemFactory.create(inventoryItem, user_id, newQuantity, {
42682
+ attributes: response.data,
42683
+ credentials: this.credentials,
42684
+ });
42685
+ }
42686
+ catch (error) {
42687
+ throw this.errorHandler({ error, sdkMethod: "Visitor.grantInventoryItem" });
42688
+ }
42689
+ });
42690
+ }
42691
+ /**
42692
+ * Modifies the quantity of an inventory item in this user's inventory.
42693
+ *
42694
+ * @param item The UserInventoryItem to modify.
42695
+ * @param quantity The new quantity to set.
42696
+ *
42697
+ * @example
42698
+ * ```ts
42699
+ * await user.modifyInventoryItemQuantity("item-id-123", 5);
42700
+ * ```
42701
+ *
42702
+ * @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
42703
+ */
42704
+ modifyInventoryItemQuantity(item, quantity) {
42705
+ return __awaiter(this, void 0, void 0, function* () {
42706
+ try {
42707
+ if (!this.profileId)
42708
+ throw "This method requires the use of a profileId";
42709
+ 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);
42710
+ const userInventoryItemFactory = new UserInventoryItemFactory(this.topia);
42711
+ const { inventoryItem, user_id, quantity: newQuantity } = response.data;
42712
+ return userInventoryItemFactory.create(inventoryItem, user_id, newQuantity, {
42713
+ attributes: response.data,
42714
+ credentials: this.credentials,
42715
+ });
42716
+ }
42717
+ catch (error) {
42718
+ throw this.errorHandler({ error, sdkMethod: "Visitor.modifyInventoryItemQuantity" });
42719
+ }
42720
+ });
42721
+ }
42660
42722
  }
42661
42723
  _User_userInventoryItems = new WeakMap(), _User_adminWorldsMap = new WeakMap(), _User_assetsMap = new WeakMap(), _User_scenesMap = new WeakMap(), _User_worldsMap = new WeakMap();
42662
42724
 
@@ -43276,8 +43338,8 @@ class Visitor extends User {
43276
43338
  /**
43277
43339
  * Grants an inventory item to this visitor.
43278
43340
  *
43279
- * @param item The ID of the inventory item to grant.
43280
- * @param quantity The quantity to grant (default 1).
43341
+ * @param item The InventoryItem to modify.
43342
+ * @param quantity The new quantity to set.
43281
43343
  *
43282
43344
  * @example
43283
43345
  * ```ts
@@ -43311,7 +43373,7 @@ class Visitor extends User {
43311
43373
  /**
43312
43374
  * Modifies the quantity of an inventory item in this visitor's inventory.
43313
43375
  *
43314
- * @param item The ID of the inventory item to modify.
43376
+ * @param item The UserInventoryItem to modify.
43315
43377
  * @param quantity The new quantity to set.
43316
43378
  *
43317
43379
  * @example
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.18.01"
64
+ "version": "0.18.03"
65
65
  }