@rtsdk/topia 0.17.9 → 0.18.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 +362 -9
- package/dist/index.d.ts +239 -34
- package/dist/index.js +362 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40729,6 +40729,52 @@ class DroppedAsset extends Asset {
|
|
|
40729
40729
|
}
|
|
40730
40730
|
_DroppedAsset_updateDroppedAsset = new WeakMap();
|
|
40731
40731
|
|
|
40732
|
+
// TODO: Define InventoryItemInterface and InventoryItemOptionalInterface
|
|
40733
|
+
/**
|
|
40734
|
+
* InventoryItem represents an item in a user's inventory.
|
|
40735
|
+
*
|
|
40736
|
+
* @remarks
|
|
40737
|
+
* This class should be instantiated via InventoryFactory only.
|
|
40738
|
+
*
|
|
40739
|
+
* @keywords inventory, item, asset, object
|
|
40740
|
+
*/
|
|
40741
|
+
class InventoryItem extends SDKController {
|
|
40742
|
+
// Add more properties as needed (e.g., name, quantity, metadata)
|
|
40743
|
+
constructor(topia, id, options = { attributes: {}, credentials: {} }) {
|
|
40744
|
+
super(topia, Object.assign({}, options.credentials));
|
|
40745
|
+
this.id = id;
|
|
40746
|
+
Object.assign(this, options.attributes);
|
|
40747
|
+
const { name = "", description = "", type = "", created_at = new Date(), updated_at = new Date(), metadata = null, image_path = "", interactive_key_id = "", status = "", } = options.attributes;
|
|
40748
|
+
this.name = name;
|
|
40749
|
+
this.description = description;
|
|
40750
|
+
this.type = type;
|
|
40751
|
+
this.created_at = created_at;
|
|
40752
|
+
this.updated_at = updated_at;
|
|
40753
|
+
this.metadata = metadata;
|
|
40754
|
+
this.image_path = image_path;
|
|
40755
|
+
this.interactive_key_id = interactive_key_id;
|
|
40756
|
+
this.status = status;
|
|
40757
|
+
}
|
|
40758
|
+
/**
|
|
40759
|
+
* Fetches the inventory item details from the platform and assigns them to this instance.
|
|
40760
|
+
*
|
|
40761
|
+
* @example
|
|
40762
|
+
* ```ts
|
|
40763
|
+
* await item.fetchInventoryItemById();
|
|
40764
|
+
* ```
|
|
40765
|
+
*
|
|
40766
|
+
* @returns {Promise<InventoryItem>} Returns when the item has been fetched and assigned.
|
|
40767
|
+
*/
|
|
40768
|
+
fetchInventoryItemById() {
|
|
40769
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40770
|
+
const response = yield this.topiaPublicApi().get(`/inventory/${this.id}`, this.requestOptions);
|
|
40771
|
+
Object.assign(this, response.data);
|
|
40772
|
+
return this;
|
|
40773
|
+
});
|
|
40774
|
+
}
|
|
40775
|
+
}
|
|
40776
|
+
|
|
40777
|
+
var _Ecosystem_inventoryItems;
|
|
40732
40778
|
/* ============================================================================
|
|
40733
40779
|
AI RULES for code assistants
|
|
40734
40780
|
|
|
@@ -40772,7 +40818,9 @@ AI RULES for code assistants
|
|
|
40772
40818
|
class Ecosystem extends SDKController {
|
|
40773
40819
|
constructor(topia, options = { credentials: {} }) {
|
|
40774
40820
|
super(topia, options.credentials);
|
|
40821
|
+
_Ecosystem_inventoryItems.set(this, void 0);
|
|
40775
40822
|
this.dataObject = {};
|
|
40823
|
+
__classPrivateFieldSet(this, _Ecosystem_inventoryItems, [], "f");
|
|
40776
40824
|
}
|
|
40777
40825
|
/**
|
|
40778
40826
|
* Retrieves the data object for a Topia ecosystem. Requires canUpdateEcosystemDataObjects permission to be set to true for the public key.
|
|
@@ -40909,6 +40957,88 @@ class Ecosystem extends SDKController {
|
|
|
40909
40957
|
}
|
|
40910
40958
|
});
|
|
40911
40959
|
}
|
|
40960
|
+
/**
|
|
40961
|
+
* Retrieves all inventory items for a given keyholder (app public key).
|
|
40962
|
+
*
|
|
40963
|
+
* @keywords get, fetch, retrieve, list, inventory, items, keyholder
|
|
40964
|
+
*
|
|
40965
|
+
* @example
|
|
40966
|
+
* ```ts
|
|
40967
|
+
* const items = await ecosystem.fetchInventoryItems("appPublicKey", "appJWT");
|
|
40968
|
+
* ```
|
|
40969
|
+
*
|
|
40970
|
+
* @returns {Promise<object[]>} Returns an array of InventoryItem objects.
|
|
40971
|
+
*/
|
|
40972
|
+
fetchInventoryItems() {
|
|
40973
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40974
|
+
try {
|
|
40975
|
+
// const query = appJWT ? `?appPublicKey=${appPublicKey}&appJWT=${appJWT}` : `?appPublicKey=${appPublicKey}`;
|
|
40976
|
+
const response = yield this.topiaPublicApi().get(`/inventory/`, this.requestOptions);
|
|
40977
|
+
// TODO: Replace 'object' with InventoryItem and instantiate InventoryItem objects if needed
|
|
40978
|
+
// create temp map and then update private property only once
|
|
40979
|
+
const tempItems = [];
|
|
40980
|
+
for (const index in response.data) {
|
|
40981
|
+
tempItems.push(new InventoryItem(this.topia, response.data[index].id, {
|
|
40982
|
+
attributes: response.data[index],
|
|
40983
|
+
credentials: this.credentials,
|
|
40984
|
+
}));
|
|
40985
|
+
}
|
|
40986
|
+
__classPrivateFieldSet(this, _Ecosystem_inventoryItems, tempItems, "f");
|
|
40987
|
+
}
|
|
40988
|
+
catch (error) {
|
|
40989
|
+
throw this.errorHandler({ error, sdkMethod: "Ecosystem.fetchInventoryItems" });
|
|
40990
|
+
}
|
|
40991
|
+
});
|
|
40992
|
+
}
|
|
40993
|
+
get inventoryItems() {
|
|
40994
|
+
return __classPrivateFieldGet(this, _Ecosystem_inventoryItems, "f");
|
|
40995
|
+
}
|
|
40996
|
+
}
|
|
40997
|
+
_Ecosystem_inventoryItems = new WeakMap();
|
|
40998
|
+
|
|
40999
|
+
/**
|
|
41000
|
+
* Controller for a user's owned inventory item.
|
|
41001
|
+
*
|
|
41002
|
+
* @remarks
|
|
41003
|
+
* This class should be instantiated via UserInventoryItemFactory only.
|
|
41004
|
+
*
|
|
41005
|
+
* @property inventoryItemId - The root inventory item's id
|
|
41006
|
+
*/
|
|
41007
|
+
class UserInventoryItem extends InventoryItem {
|
|
41008
|
+
constructor(topia, id, options = { attributes: {}, credentials: {} }) {
|
|
41009
|
+
const { attributes = {} } = options;
|
|
41010
|
+
const { item_id = "" } = attributes;
|
|
41011
|
+
super(topia, item_id, { attributes: options.attributes, credentials: options.credentials });
|
|
41012
|
+
Object.assign(this, options.attributes);
|
|
41013
|
+
this.userItemId = id;
|
|
41014
|
+
const { user_id = "", quantity = 0, grant_source = "unknown", type = "unknown", metadata = {}, created_at = new Date(), updated_at = new Date(), } = options.attributes;
|
|
41015
|
+
this.item_id = item_id;
|
|
41016
|
+
this.quantity = quantity;
|
|
41017
|
+
this.grant_source = grant_source;
|
|
41018
|
+
this.user_id = user_id;
|
|
41019
|
+
this.type = type;
|
|
41020
|
+
this.metadata = metadata;
|
|
41021
|
+
this.created_at = created_at;
|
|
41022
|
+
this.updated_at = updated_at;
|
|
41023
|
+
}
|
|
41024
|
+
/**
|
|
41025
|
+
* Fetches the user inventory item details from the platform and assigns them to this instance.
|
|
41026
|
+
*
|
|
41027
|
+
* @example
|
|
41028
|
+
* ```ts
|
|
41029
|
+
* await userInventoryItem.fetchUserInventoryItemById();
|
|
41030
|
+
* ```
|
|
41031
|
+
*
|
|
41032
|
+
* @returns {Promise<void>} Returns when the item has been fetched and assigned.
|
|
41033
|
+
*/
|
|
41034
|
+
fetchUserInventoryItemById() {
|
|
41035
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41036
|
+
// TODO: Implement API call to fetch user inventory item details
|
|
41037
|
+
// Example:
|
|
41038
|
+
// const response = await this.topia.api.get(`/inventory/user-items/${this.userId}/${this.inventoryItemId}`, this.options?.credentials);
|
|
41039
|
+
// Object.assign(this, response.data);
|
|
41040
|
+
});
|
|
41041
|
+
}
|
|
40912
41042
|
}
|
|
40913
41043
|
|
|
40914
41044
|
/* ============================================================================
|
|
@@ -41819,7 +41949,7 @@ class World extends SDKController {
|
|
|
41819
41949
|
}
|
|
41820
41950
|
_World_droppedAssetsMap = new WeakMap();
|
|
41821
41951
|
|
|
41822
|
-
var _User_adminWorldsMap, _User_assetsMap, _User_scenesMap, _User_worldsMap;
|
|
41952
|
+
var _User_userInventoryItems, _User_adminWorldsMap, _User_assetsMap, _User_scenesMap, _User_worldsMap;
|
|
41823
41953
|
/* ============================================================================
|
|
41824
41954
|
AI RULES for code assistants
|
|
41825
41955
|
|
|
@@ -41864,6 +41994,7 @@ AI RULES for code assistants
|
|
|
41864
41994
|
class User extends SDKController {
|
|
41865
41995
|
constructor(topia, options = { profileId: null, credentials: {} }) {
|
|
41866
41996
|
super(topia, Object.assign({ profileId: options === null || options === void 0 ? void 0 : options.profileId }, options.credentials));
|
|
41997
|
+
_User_userInventoryItems.set(this, void 0);
|
|
41867
41998
|
_User_adminWorldsMap.set(this, void 0);
|
|
41868
41999
|
_User_assetsMap.set(this, void 0);
|
|
41869
42000
|
_User_scenesMap.set(this, void 0);
|
|
@@ -41875,6 +42006,7 @@ class User extends SDKController {
|
|
|
41875
42006
|
__classPrivateFieldSet(this, _User_assetsMap, {}, "f");
|
|
41876
42007
|
__classPrivateFieldSet(this, _User_scenesMap, {}, "f");
|
|
41877
42008
|
__classPrivateFieldSet(this, _User_worldsMap, {}, "f");
|
|
42009
|
+
__classPrivateFieldSet(this, _User_userInventoryItems, [], "f");
|
|
41878
42010
|
}
|
|
41879
42011
|
get adminWorlds() {
|
|
41880
42012
|
return __classPrivateFieldGet(this, _User_adminWorldsMap, "f");
|
|
@@ -42489,9 +42621,46 @@ class User extends SDKController {
|
|
|
42489
42621
|
}
|
|
42490
42622
|
});
|
|
42491
42623
|
}
|
|
42624
|
+
/**
|
|
42625
|
+
* Retrieves all inventory items owned by this visitor and app's key.
|
|
42626
|
+
*
|
|
42627
|
+
* @keywords get, fetch, retrieve, list, inventory, items, visitor
|
|
42628
|
+
*
|
|
42629
|
+
* @example
|
|
42630
|
+
* ```ts
|
|
42631
|
+
* const items = await visitor.fetchInventoryItems();
|
|
42632
|
+
* ```
|
|
42633
|
+
*
|
|
42634
|
+
* @returns {Promise<void>} Returns an array of InventoryItem objects.
|
|
42635
|
+
*/
|
|
42636
|
+
fetchInventoryItems() {
|
|
42637
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42638
|
+
try {
|
|
42639
|
+
if (!this.profileId)
|
|
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);
|
|
42642
|
+
// TODO: Replace 'object' with InventoryItem and instantiate InventoryItem objects if needed
|
|
42643
|
+
const tempItems = [];
|
|
42644
|
+
for (const index in response.data) {
|
|
42645
|
+
tempItems.push(new UserInventoryItem(this.topia, response.data[index].id, {
|
|
42646
|
+
attributes: response.data[index],
|
|
42647
|
+
credentials: this.credentials,
|
|
42648
|
+
}));
|
|
42649
|
+
}
|
|
42650
|
+
__classPrivateFieldSet(this, _User_userInventoryItems, tempItems, "f");
|
|
42651
|
+
}
|
|
42652
|
+
catch (error) {
|
|
42653
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.fetchInventoryItems" });
|
|
42654
|
+
}
|
|
42655
|
+
});
|
|
42656
|
+
}
|
|
42657
|
+
get inventoryItems() {
|
|
42658
|
+
return __classPrivateFieldGet(this, _User_userInventoryItems, "f");
|
|
42659
|
+
}
|
|
42492
42660
|
}
|
|
42493
|
-
_User_adminWorldsMap = new WeakMap(), _User_assetsMap = new WeakMap(), _User_scenesMap = new WeakMap(), _User_worldsMap = new WeakMap();
|
|
42661
|
+
_User_userInventoryItems = new WeakMap(), _User_adminWorldsMap = new WeakMap(), _User_assetsMap = new WeakMap(), _User_scenesMap = new WeakMap(), _User_worldsMap = new WeakMap();
|
|
42494
42662
|
|
|
42663
|
+
var _Visitor_visitorInventoryItems;
|
|
42495
42664
|
/* ============================================================================
|
|
42496
42665
|
AI RULES for code assistants
|
|
42497
42666
|
|
|
@@ -42533,9 +42702,11 @@ AI RULES for code assistants
|
|
|
42533
42702
|
class Visitor extends User {
|
|
42534
42703
|
constructor(topia, id, urlSlug, options = { attributes: {}, credentials: {} }) {
|
|
42535
42704
|
super(topia, { credentials: Object.assign({ urlSlug }, options.credentials) });
|
|
42705
|
+
_Visitor_visitorInventoryItems.set(this, void 0);
|
|
42536
42706
|
Object.assign(this, options.attributes);
|
|
42537
42707
|
this.id = id;
|
|
42538
42708
|
this.urlSlug = urlSlug;
|
|
42709
|
+
__classPrivateFieldSet(this, _Visitor_visitorInventoryItems, [], "f");
|
|
42539
42710
|
}
|
|
42540
42711
|
/**
|
|
42541
42712
|
* Get a single visitor from a world
|
|
@@ -43042,7 +43213,138 @@ class Visitor extends User {
|
|
|
43042
43213
|
}
|
|
43043
43214
|
});
|
|
43044
43215
|
}
|
|
43045
|
-
|
|
43216
|
+
/**
|
|
43217
|
+
* Retrieves all inventory items owned by this visitor and app's key.
|
|
43218
|
+
*
|
|
43219
|
+
* @keywords get, fetch, retrieve, list, inventory, items, visitor
|
|
43220
|
+
*
|
|
43221
|
+
* @example
|
|
43222
|
+
* ```ts
|
|
43223
|
+
* const items = await visitor.fetchInventoryItems();
|
|
43224
|
+
* ```
|
|
43225
|
+
*
|
|
43226
|
+
* @returns {Promise<void>} Returns an array of InventoryItem objects.
|
|
43227
|
+
*/
|
|
43228
|
+
fetchInventoryItem(item) {
|
|
43229
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43230
|
+
try {
|
|
43231
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors/${this.id}/get-visitor-inventory-items/${item.id}`, this.requestOptions);
|
|
43232
|
+
return new UserInventoryItem(this.topia, response.data.id, {
|
|
43233
|
+
attributes: response.data,
|
|
43234
|
+
credentials: this.credentials,
|
|
43235
|
+
});
|
|
43236
|
+
}
|
|
43237
|
+
catch (error) {
|
|
43238
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.fetchInventoryItems" });
|
|
43239
|
+
}
|
|
43240
|
+
});
|
|
43241
|
+
}
|
|
43242
|
+
/**
|
|
43243
|
+
* Retrieves all inventory items owned by this visitor and app's key.
|
|
43244
|
+
*
|
|
43245
|
+
* @keywords get, fetch, retrieve, list, inventory, items, visitor
|
|
43246
|
+
*
|
|
43247
|
+
* @example
|
|
43248
|
+
* ```ts
|
|
43249
|
+
* const items = await visitor.fetchInventoryItems();
|
|
43250
|
+
* ```
|
|
43251
|
+
*
|
|
43252
|
+
* @returns {Promise<void>} Returns an array of InventoryItem objects.
|
|
43253
|
+
*/
|
|
43254
|
+
fetchInventoryItems() {
|
|
43255
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43256
|
+
try {
|
|
43257
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors/${this.id}/get-visitor-inventory-items`, this.requestOptions);
|
|
43258
|
+
// TODO: Replace 'object' with InventoryItem and instantiate InventoryItem objects if needed
|
|
43259
|
+
const tempItems = [];
|
|
43260
|
+
for (const index in response.data) {
|
|
43261
|
+
tempItems.push(new UserInventoryItem(this.topia, response.data[index].id, {
|
|
43262
|
+
attributes: response.data[index],
|
|
43263
|
+
credentials: this.credentials,
|
|
43264
|
+
}));
|
|
43265
|
+
}
|
|
43266
|
+
__classPrivateFieldSet(this, _Visitor_visitorInventoryItems, tempItems, "f");
|
|
43267
|
+
}
|
|
43268
|
+
catch (error) {
|
|
43269
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.fetchInventoryItems" });
|
|
43270
|
+
}
|
|
43271
|
+
});
|
|
43272
|
+
}
|
|
43273
|
+
get inventoryItems() {
|
|
43274
|
+
return __classPrivateFieldGet(this, _Visitor_visitorInventoryItems, "f");
|
|
43275
|
+
}
|
|
43276
|
+
/**
|
|
43277
|
+
* Grants an inventory item to this visitor.
|
|
43278
|
+
*
|
|
43279
|
+
* @param itemId The ID of the inventory item to grant.
|
|
43280
|
+
* @param quantity The quantity to grant (default 1).
|
|
43281
|
+
*
|
|
43282
|
+
* @example
|
|
43283
|
+
* ```ts
|
|
43284
|
+
* await visitor.grantInventoryItem("item-id-123", 2);
|
|
43285
|
+
* ```
|
|
43286
|
+
*
|
|
43287
|
+
* @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
|
|
43288
|
+
*/
|
|
43289
|
+
grantInventoryItem(item, quantity = 1) {
|
|
43290
|
+
var _a;
|
|
43291
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43292
|
+
// Error if item already exists in #visitorInventoryItems
|
|
43293
|
+
const exists = (_a = __classPrivateFieldGet(this, _Visitor_visitorInventoryItems, "f")) === null || _a === void 0 ? void 0 : _a.some((visitorItem) => visitorItem.id === item.id);
|
|
43294
|
+
if (exists) {
|
|
43295
|
+
throw new Error(`Inventory item with id '${item.id}' already exists in visitorInventoryItems.`);
|
|
43296
|
+
}
|
|
43297
|
+
try {
|
|
43298
|
+
const response = yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/grant-visitor-inventory-item`, { itemId: item.id, quantity }, this.requestOptions);
|
|
43299
|
+
const userInventoryItemFactory = new UserInventoryItemFactory(this.topia);
|
|
43300
|
+
const { inventoryItem, user_id, quantity: newQuantity } = response.data;
|
|
43301
|
+
return userInventoryItemFactory.create(inventoryItem, user_id, newQuantity, {
|
|
43302
|
+
attributes: response.data,
|
|
43303
|
+
credentials: this.credentials,
|
|
43304
|
+
});
|
|
43305
|
+
}
|
|
43306
|
+
catch (error) {
|
|
43307
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.grantInventoryItem" });
|
|
43308
|
+
}
|
|
43309
|
+
});
|
|
43310
|
+
}
|
|
43311
|
+
/**
|
|
43312
|
+
* Modifies the quantity of an inventory item in this visitor's inventory.
|
|
43313
|
+
*
|
|
43314
|
+
* @param itemId The ID of the inventory item to modify.
|
|
43315
|
+
* @param quantity The new quantity to set.
|
|
43316
|
+
*
|
|
43317
|
+
* @example
|
|
43318
|
+
* ```ts
|
|
43319
|
+
* await visitor.modifyInventoryItemQuantity("item-id-123", 5);
|
|
43320
|
+
* ```
|
|
43321
|
+
*
|
|
43322
|
+
* @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
|
|
43323
|
+
*/
|
|
43324
|
+
modifyInventoryItemQuantity(item, quantity) {
|
|
43325
|
+
var _a;
|
|
43326
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43327
|
+
// Check for existence in #visitorInventoryItems
|
|
43328
|
+
const found = (_a = __classPrivateFieldGet(this, _Visitor_visitorInventoryItems, "f")) === null || _a === void 0 ? void 0 : _a.some((visitorItem) => visitorItem.id === item.userItemId);
|
|
43329
|
+
if (!found) {
|
|
43330
|
+
throw new Error(`Inventory item with id '${item.userItemId}' does not exist in visitorInventoryItems.`);
|
|
43331
|
+
}
|
|
43332
|
+
try {
|
|
43333
|
+
const response = yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/update-visitor-inventory-item-quantity`, { userItemId: item.id, itemId: item.item_id, quantity }, this.requestOptions);
|
|
43334
|
+
const userInventoryItemFactory = new UserInventoryItemFactory(this.topia);
|
|
43335
|
+
const { inventoryItem, user_id, quantity: newQuantity } = response.data;
|
|
43336
|
+
return userInventoryItemFactory.create(inventoryItem, user_id, newQuantity, {
|
|
43337
|
+
attributes: response.data,
|
|
43338
|
+
credentials: this.credentials,
|
|
43339
|
+
});
|
|
43340
|
+
}
|
|
43341
|
+
catch (error) {
|
|
43342
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.modifyInventoryItemQuantity" });
|
|
43343
|
+
}
|
|
43344
|
+
});
|
|
43345
|
+
}
|
|
43346
|
+
}
|
|
43347
|
+
_Visitor_visitorInventoryItems = new WeakMap();
|
|
43046
43348
|
|
|
43047
43349
|
/**
|
|
43048
43350
|
* Create an instance of WebRTCConnector class with optional session credentials.
|
|
@@ -43354,7 +43656,7 @@ class AssetFactory extends SDKController {
|
|
|
43354
43656
|
super(topia);
|
|
43355
43657
|
}
|
|
43356
43658
|
/**
|
|
43357
|
-
* Instantiate a new instance of Asset class with the specified asset
|
|
43659
|
+
* Instantiate a new instance of Asset class with the specified asset id.
|
|
43358
43660
|
*
|
|
43359
43661
|
* @remarks
|
|
43360
43662
|
* This method creates a new Asset controller instance that can be used to interact with an existing asset.
|
|
@@ -43572,7 +43874,7 @@ class DroppedAssetFactory extends SDKController {
|
|
|
43572
43874
|
*
|
|
43573
43875
|
* @remarks
|
|
43574
43876
|
* This method leverages the handleGetDroppedAssetByUniqueName endpoint in the Public API and assumes there is exactly one dropped asset with the matching uniqueName for the given urlSlug.
|
|
43575
|
-
* Use this when you need to find a dropped asset by its uniqueName rather than its
|
|
43877
|
+
* Use this when you need to find a dropped asset by its uniqueName rather than its id.
|
|
43576
43878
|
*
|
|
43577
43879
|
* @keywords find, search, unique name, retrieve, locate, lookup, dropped asset
|
|
43578
43880
|
*
|
|
@@ -43874,7 +44176,7 @@ class SceneFactory {
|
|
|
43874
44176
|
*
|
|
43875
44177
|
* @remarks
|
|
43876
44178
|
* This method creates a controller instance for working with a scene but does not fetch its properties.
|
|
43877
|
-
* Use this when you need to interact with a specific scene by its
|
|
44179
|
+
* Use this when you need to interact with a specific scene by its id.
|
|
43878
44180
|
*
|
|
43879
44181
|
* @keywords create, instantiate, scene, initialize, instance, template
|
|
43880
44182
|
*
|
|
@@ -43981,7 +44283,7 @@ class UserFactory {
|
|
|
43981
44283
|
*
|
|
43982
44284
|
* @remarks
|
|
43983
44285
|
* This method creates a controller instance for interacting with user-specific operations.
|
|
43984
|
-
* The User controller doesn't require an
|
|
44286
|
+
* The User controller doesn't require an id since it represents the currently authenticated user.
|
|
43985
44287
|
*
|
|
43986
44288
|
* @keywords create, instantiate, user, initialize, account, profile, member
|
|
43987
44289
|
*
|
|
@@ -44080,7 +44382,7 @@ class VisitorFactory {
|
|
|
44080
44382
|
*
|
|
44081
44383
|
* // Create a Visitor instance with credentials
|
|
44082
44384
|
* const visitorInstance = Visitor.create(
|
|
44083
|
-
* 12345, // visitor
|
|
44385
|
+
* 12345, // visitor id
|
|
44084
44386
|
* "my-world-slug",
|
|
44085
44387
|
* {
|
|
44086
44388
|
* credentials: {
|
|
@@ -44118,7 +44420,7 @@ class VisitorFactory {
|
|
|
44118
44420
|
*
|
|
44119
44421
|
* // Get a fully populated Visitor instance
|
|
44120
44422
|
* const visitorInstance = await Visitor.get(
|
|
44121
|
-
* 12345, // visitor
|
|
44423
|
+
* 12345, // visitor id
|
|
44122
44424
|
* "my-world-slug",
|
|
44123
44425
|
* {
|
|
44124
44426
|
* credentials: {
|
|
@@ -44455,6 +44757,57 @@ class WorldFactory extends SDKController {
|
|
|
44455
44757
|
}
|
|
44456
44758
|
}
|
|
44457
44759
|
|
|
44760
|
+
// import { UserInventoryItem } from "controllers";
|
|
44761
|
+
/**
|
|
44762
|
+
* Factory for creating UserInventoryItem instances. Use this factory to work with user-owned inventory items.
|
|
44763
|
+
*
|
|
44764
|
+
* @remarks
|
|
44765
|
+
* This factory should be instantiated once per application and reused across your codebase.
|
|
44766
|
+
*
|
|
44767
|
+
* @example
|
|
44768
|
+
* ```ts
|
|
44769
|
+
* // In your initialization file (e.g., utils/topiaInit.ts)
|
|
44770
|
+
* import { Topia, UserInventoryItemFactory } from "@rtsdk/topia";
|
|
44771
|
+
* const topia = new Topia({ config });
|
|
44772
|
+
* export const UserInventoryItem = new UserInventoryItemFactory(topia);
|
|
44773
|
+
* ```
|
|
44774
|
+
*/
|
|
44775
|
+
class UserInventoryItemFactory {
|
|
44776
|
+
constructor(topia) {
|
|
44777
|
+
this.topia = topia;
|
|
44778
|
+
}
|
|
44779
|
+
/**
|
|
44780
|
+
* Instantiate a new instance of UserInventoryItem class for a user's owned item.
|
|
44781
|
+
*
|
|
44782
|
+
* @example
|
|
44783
|
+
* ```ts
|
|
44784
|
+
* const userItem = UserInventoryItem.create("item-id-123", 42, 5, { credentials });
|
|
44785
|
+
* ```
|
|
44786
|
+
*
|
|
44787
|
+
* @returns {UserInventoryItem} Returns a new UserInventoryItem object for interacting with the specified item.
|
|
44788
|
+
*/
|
|
44789
|
+
create(inventoryItemId, userId, quantity, options) {
|
|
44790
|
+
return new UserInventoryItem(this.topia, inventoryItemId, options);
|
|
44791
|
+
}
|
|
44792
|
+
/**
|
|
44793
|
+
* Retrieve a user inventory item and all its properties.
|
|
44794
|
+
*
|
|
44795
|
+
* @example
|
|
44796
|
+
* ```ts
|
|
44797
|
+
* const userItem = await UserInventoryItem.get("item-id-123", 42, { credentials });
|
|
44798
|
+
* ```
|
|
44799
|
+
*
|
|
44800
|
+
* @returns {Promise<UserInventoryItem>} Returns a new UserInventoryItem object with all properties.
|
|
44801
|
+
*/
|
|
44802
|
+
get(inventoryItemId, options) {
|
|
44803
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44804
|
+
const userItem = new UserInventoryItem(this.topia, inventoryItemId, options);
|
|
44805
|
+
yield userItem.fetchUserInventoryItemById();
|
|
44806
|
+
return userItem;
|
|
44807
|
+
});
|
|
44808
|
+
}
|
|
44809
|
+
}
|
|
44810
|
+
|
|
44458
44811
|
Error.stackTraceLimit = 20;
|
|
44459
44812
|
process.on("unhandledRejection", (reason) => {
|
|
44460
44813
|
if (reason && reason.data) {
|
package/package.json
CHANGED