@rtsdk/topia 0.17.8 → 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/README.md +3 -2
- package/dist/index.cjs +1082 -85
- package/dist/index.d.ts +957 -110
- package/dist/index.js +1082 -85
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -39761,6 +39761,8 @@ class Asset extends SDKController {
|
|
|
39761
39761
|
/**
|
|
39762
39762
|
* Retrieves platform asset details and assigns response data to the instance.
|
|
39763
39763
|
*
|
|
39764
|
+
* @keywords get, fetch, retrieve, load, details, info, information
|
|
39765
|
+
*
|
|
39764
39766
|
* @example
|
|
39765
39767
|
* ```ts
|
|
39766
39768
|
* await asset.fetchAssetById();
|
|
@@ -39784,6 +39786,8 @@ class Asset extends SDKController {
|
|
|
39784
39786
|
/**
|
|
39785
39787
|
* Updates platform asset details.
|
|
39786
39788
|
*
|
|
39789
|
+
* @keywords update, modify, change, edit, alter, transform
|
|
39790
|
+
*
|
|
39787
39791
|
* @example
|
|
39788
39792
|
* ```ts
|
|
39789
39793
|
* await asset.updateAsset({
|
|
@@ -39941,6 +39945,8 @@ class DroppedAsset extends Asset {
|
|
|
39941
39945
|
/**
|
|
39942
39946
|
* Retrieves dropped asset details and assigns response data to the instance.
|
|
39943
39947
|
*
|
|
39948
|
+
* @keywords get, fetch, retrieve, load, details, info, information
|
|
39949
|
+
*
|
|
39944
39950
|
* @example
|
|
39945
39951
|
* ```ts
|
|
39946
39952
|
* await droppedAsset.fetchDroppedAssetById();
|
|
@@ -39963,6 +39969,8 @@ class DroppedAsset extends Asset {
|
|
|
39963
39969
|
/**
|
|
39964
39970
|
* Updates dropped asset details and assigns the response data to the instance. Requires Public Key to have the `canUpdateDroppedAssets` permission.
|
|
39965
39971
|
*
|
|
39972
|
+
* @keywords update, modify, change, edit, alter, transform
|
|
39973
|
+
*
|
|
39966
39974
|
* @example
|
|
39967
39975
|
* ```ts
|
|
39968
39976
|
* const payload = {
|
|
@@ -40037,6 +40045,8 @@ class DroppedAsset extends Asset {
|
|
|
40037
40045
|
/**
|
|
40038
40046
|
* Deletes the dropped asset (removes it from the world).
|
|
40039
40047
|
*
|
|
40048
|
+
* @keywords remove, delete, erase, destroy, eliminate
|
|
40049
|
+
*
|
|
40040
40050
|
* @example
|
|
40041
40051
|
* ```ts
|
|
40042
40052
|
* await droppedAsset.deleteDroppedAsset();
|
|
@@ -40055,6 +40065,8 @@ class DroppedAsset extends Asset {
|
|
|
40055
40065
|
/**
|
|
40056
40066
|
* Retrieves the data object for a dropped asset.
|
|
40057
40067
|
*
|
|
40068
|
+
* @keywords get, fetch, retrieve, load, data, object, state
|
|
40069
|
+
*
|
|
40058
40070
|
* @category Data Objects
|
|
40059
40071
|
*
|
|
40060
40072
|
* @example
|
|
@@ -40087,6 +40099,8 @@ class DroppedAsset extends Asset {
|
|
|
40087
40099
|
* @remarks
|
|
40088
40100
|
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
40089
40101
|
*
|
|
40102
|
+
* @keywords set, assign, store, save, data, object, state
|
|
40103
|
+
*
|
|
40090
40104
|
* @category Data Objects
|
|
40091
40105
|
*
|
|
40092
40106
|
* @example
|
|
@@ -40119,6 +40133,8 @@ class DroppedAsset extends Asset {
|
|
|
40119
40133
|
* @remarks
|
|
40120
40134
|
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
40121
40135
|
*
|
|
40136
|
+
* @keywords update, modify, change, edit, alter, data, object, state
|
|
40137
|
+
*
|
|
40122
40138
|
* @category Data Objects
|
|
40123
40139
|
*
|
|
40124
40140
|
* @example
|
|
@@ -40148,6 +40164,8 @@ class DroppedAsset extends Asset {
|
|
|
40148
40164
|
* @remarks
|
|
40149
40165
|
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
40150
40166
|
*
|
|
40167
|
+
* @keywords increment, increase, add, count, data, object, state
|
|
40168
|
+
*
|
|
40151
40169
|
* @category Data Objects
|
|
40152
40170
|
*
|
|
40153
40171
|
* @example
|
|
@@ -40172,6 +40190,8 @@ class DroppedAsset extends Asset {
|
|
|
40172
40190
|
/**
|
|
40173
40191
|
* Updates broadcast options for a dropped asset.
|
|
40174
40192
|
*
|
|
40193
|
+
* @keywords broadcast, dropped asset settings
|
|
40194
|
+
*
|
|
40175
40195
|
* @example
|
|
40176
40196
|
* ```ts
|
|
40177
40197
|
* await droppedAsset.updateBroadcast({
|
|
@@ -40195,6 +40215,8 @@ class DroppedAsset extends Asset {
|
|
|
40195
40215
|
/**
|
|
40196
40216
|
* Updates click options for a dropped asset.
|
|
40197
40217
|
*
|
|
40218
|
+
* @keywords click, link, interaction, url, dropped asset settings
|
|
40219
|
+
*
|
|
40198
40220
|
* @example
|
|
40199
40221
|
* ```ts
|
|
40200
40222
|
* await droppedAsset.updateClickType({
|
|
@@ -40235,6 +40257,8 @@ class DroppedAsset extends Asset {
|
|
|
40235
40257
|
/**
|
|
40236
40258
|
* Adds an array of links to an asset. Maximum is 20 links.
|
|
40237
40259
|
*
|
|
40260
|
+
* @keywords links, multiple, clickable, urls, hyperlinks, dropped asset settings
|
|
40261
|
+
*
|
|
40238
40262
|
* @example
|
|
40239
40263
|
* ```ts
|
|
40240
40264
|
* await droppedAsset.setClickableLinkMulti({
|
|
@@ -40275,6 +40299,8 @@ class DroppedAsset extends Asset {
|
|
|
40275
40299
|
* @remarks
|
|
40276
40300
|
* Pass in an 'existingLinkId' to edit an existing link.
|
|
40277
40301
|
*
|
|
40302
|
+
* @keywords links, multiple, clickable, urls, dropped asset settings
|
|
40303
|
+
*
|
|
40278
40304
|
* @example
|
|
40279
40305
|
* ```ts
|
|
40280
40306
|
* await droppedAsset.updateClickableLinkMulti({
|
|
@@ -40308,6 +40334,8 @@ class DroppedAsset extends Asset {
|
|
|
40308
40334
|
/**
|
|
40309
40335
|
* Removes a clickable link from a dropped asset.
|
|
40310
40336
|
*
|
|
40337
|
+
* @keywords remove, delete, link, clickable, url, erase, dropped asset settings
|
|
40338
|
+
*
|
|
40311
40339
|
* @example
|
|
40312
40340
|
* ```ts
|
|
40313
40341
|
* await droppedAsset.removeClickableLink({ linkId: "link-id" });
|
|
@@ -40329,6 +40357,8 @@ class DroppedAsset extends Asset {
|
|
|
40329
40357
|
/**
|
|
40330
40358
|
* Updates text and style of a dropped asset.
|
|
40331
40359
|
*
|
|
40360
|
+
* @keywords text, style, dropped asset settings
|
|
40361
|
+
*
|
|
40332
40362
|
* @example
|
|
40333
40363
|
* ```ts
|
|
40334
40364
|
* const style = {
|
|
@@ -40355,6 +40385,8 @@ class DroppedAsset extends Asset {
|
|
|
40355
40385
|
/**
|
|
40356
40386
|
* Updates media options for a dropped asset.
|
|
40357
40387
|
*
|
|
40388
|
+
* @keywords media, video, audio, dropped asset settings
|
|
40389
|
+
*
|
|
40358
40390
|
* @example
|
|
40359
40391
|
* ```ts
|
|
40360
40392
|
* await droppedAsset.updateMediaType({
|
|
@@ -40392,6 +40424,8 @@ class DroppedAsset extends Asset {
|
|
|
40392
40424
|
/**
|
|
40393
40425
|
* Updates mute zone options for a dropped asset.
|
|
40394
40426
|
*
|
|
40427
|
+
* @keywords mute, zone, dropped asset settings
|
|
40428
|
+
*
|
|
40395
40429
|
* @example
|
|
40396
40430
|
* ```ts
|
|
40397
40431
|
* await droppedAsset.updateMuteZone(true);
|
|
@@ -40410,6 +40444,8 @@ class DroppedAsset extends Asset {
|
|
|
40410
40444
|
/**
|
|
40411
40445
|
* Updates landmark zone options for a dropped asset.
|
|
40412
40446
|
*
|
|
40447
|
+
* @keywords landmark, zone, dropped asset settings
|
|
40448
|
+
*
|
|
40413
40449
|
* @example
|
|
40414
40450
|
* ```ts
|
|
40415
40451
|
* await droppedAsset.updateLandmarkZone({
|
|
@@ -40433,6 +40469,8 @@ class DroppedAsset extends Asset {
|
|
|
40433
40469
|
/**
|
|
40434
40470
|
* Updates webhook zone options for a dropped asset.
|
|
40435
40471
|
*
|
|
40472
|
+
* @keywords webhook, zone, dropped asset settings
|
|
40473
|
+
*
|
|
40436
40474
|
* @example
|
|
40437
40475
|
* ```ts
|
|
40438
40476
|
* await droppedAsset.updateWebhookZone(true);
|
|
@@ -40451,6 +40489,8 @@ class DroppedAsset extends Asset {
|
|
|
40451
40489
|
/**
|
|
40452
40490
|
* Moves a dropped asset to specified coordinates.
|
|
40453
40491
|
*
|
|
40492
|
+
* @keywords position, dropped asset settings
|
|
40493
|
+
*
|
|
40454
40494
|
* @example
|
|
40455
40495
|
* ```ts
|
|
40456
40496
|
* await droppedAsset.updatePosition(100, 200, 100);
|
|
@@ -40470,6 +40510,8 @@ class DroppedAsset extends Asset {
|
|
|
40470
40510
|
/**
|
|
40471
40511
|
* Updates private zone options for a dropped asset.
|
|
40472
40512
|
*
|
|
40513
|
+
* @keywords private, zone, dropped asset settings
|
|
40514
|
+
*
|
|
40473
40515
|
* @example
|
|
40474
40516
|
* ```ts
|
|
40475
40517
|
* await droppedAsset.updatePrivateZone({
|
|
@@ -40493,6 +40535,8 @@ class DroppedAsset extends Asset {
|
|
|
40493
40535
|
/**
|
|
40494
40536
|
* Updates the size of a dropped asset.
|
|
40495
40537
|
*
|
|
40538
|
+
* @keywords size, scale, dropped asset settings
|
|
40539
|
+
*
|
|
40496
40540
|
* @example
|
|
40497
40541
|
* ```ts
|
|
40498
40542
|
* await droppedAsset.assetScale(.5);
|
|
@@ -40511,6 +40555,8 @@ class DroppedAsset extends Asset {
|
|
|
40511
40555
|
/**
|
|
40512
40556
|
* Flip an dropped asset.
|
|
40513
40557
|
*
|
|
40558
|
+
* @keywords flip, layout, dropped asset settings
|
|
40559
|
+
*
|
|
40514
40560
|
* @example
|
|
40515
40561
|
* ```ts
|
|
40516
40562
|
* await droppedAsset.flip(.5);
|
|
@@ -40529,6 +40575,8 @@ class DroppedAsset extends Asset {
|
|
|
40529
40575
|
/**
|
|
40530
40576
|
* Change or remove media embedded in a dropped asset.
|
|
40531
40577
|
*
|
|
40578
|
+
* @keywords media, update, dropped asset settings
|
|
40579
|
+
*
|
|
40532
40580
|
* @example
|
|
40533
40581
|
* ```ts
|
|
40534
40582
|
* await droppedAsset.updateUploadedMediaSelected("LVWyxwNxI96eLjnXWwYO");
|
|
@@ -40547,6 +40595,8 @@ class DroppedAsset extends Asset {
|
|
|
40547
40595
|
/**
|
|
40548
40596
|
* Change or remove top and bottom layers of a dropped asset.
|
|
40549
40597
|
*
|
|
40598
|
+
* @keywords layers, images, urls, dropped asset settings
|
|
40599
|
+
*
|
|
40550
40600
|
* @example
|
|
40551
40601
|
* ```ts
|
|
40552
40602
|
* await droppedAsset.updateWebImageLayers("","https://www.shutterstock.com/image-vector/colorful-illustration-test-word-260nw-1438324490.jpg");
|
|
@@ -40566,6 +40616,8 @@ class DroppedAsset extends Asset {
|
|
|
40566
40616
|
/**
|
|
40567
40617
|
* Add a webhook to a dropped asset
|
|
40568
40618
|
*
|
|
40619
|
+
* @keywords webhook, dropped asset settings
|
|
40620
|
+
*
|
|
40569
40621
|
* @example
|
|
40570
40622
|
* ```ts
|
|
40571
40623
|
* await droppedAsset.addWebhook({
|
|
@@ -40605,6 +40657,8 @@ class DroppedAsset extends Asset {
|
|
|
40605
40657
|
/**
|
|
40606
40658
|
* Set the interactive settings on a dropped asset
|
|
40607
40659
|
*
|
|
40660
|
+
* @keywords interactive, dropped asset settings
|
|
40661
|
+
*
|
|
40608
40662
|
* @example
|
|
40609
40663
|
* ```ts
|
|
40610
40664
|
* await droppedAsset.setInteractiveSettings({
|
|
@@ -40632,6 +40686,8 @@ class DroppedAsset extends Asset {
|
|
|
40632
40686
|
/**
|
|
40633
40687
|
* Retrieve analytics for a dropped asset by day, week, month, quarter, or year
|
|
40634
40688
|
*
|
|
40689
|
+
* @keywords get, fetch, retrieve, load, analytics
|
|
40690
|
+
*
|
|
40635
40691
|
* @example
|
|
40636
40692
|
* ```ts
|
|
40637
40693
|
* const analytics = await droppedAsset.fetchDroppedAssetAnalytics({
|
|
@@ -40675,6 +40731,52 @@ class DroppedAsset extends Asset {
|
|
|
40675
40731
|
}
|
|
40676
40732
|
_DroppedAsset_updateDroppedAsset = new WeakMap();
|
|
40677
40733
|
|
|
40734
|
+
// TODO: Define InventoryItemInterface and InventoryItemOptionalInterface
|
|
40735
|
+
/**
|
|
40736
|
+
* InventoryItem represents an item in a user's inventory.
|
|
40737
|
+
*
|
|
40738
|
+
* @remarks
|
|
40739
|
+
* This class should be instantiated via InventoryFactory only.
|
|
40740
|
+
*
|
|
40741
|
+
* @keywords inventory, item, asset, object
|
|
40742
|
+
*/
|
|
40743
|
+
class InventoryItem extends SDKController {
|
|
40744
|
+
// Add more properties as needed (e.g., name, quantity, metadata)
|
|
40745
|
+
constructor(topia, id, options = { attributes: {}, credentials: {} }) {
|
|
40746
|
+
super(topia, Object.assign({}, options.credentials));
|
|
40747
|
+
this.id = id;
|
|
40748
|
+
Object.assign(this, options.attributes);
|
|
40749
|
+
const { name = "", description = "", type = "", created_at = new Date(), updated_at = new Date(), metadata = null, image_path = "", interactive_key_id = "", status = "", } = options.attributes;
|
|
40750
|
+
this.name = name;
|
|
40751
|
+
this.description = description;
|
|
40752
|
+
this.type = type;
|
|
40753
|
+
this.created_at = created_at;
|
|
40754
|
+
this.updated_at = updated_at;
|
|
40755
|
+
this.metadata = metadata;
|
|
40756
|
+
this.image_path = image_path;
|
|
40757
|
+
this.interactive_key_id = interactive_key_id;
|
|
40758
|
+
this.status = status;
|
|
40759
|
+
}
|
|
40760
|
+
/**
|
|
40761
|
+
* Fetches the inventory item details from the platform and assigns them to this instance.
|
|
40762
|
+
*
|
|
40763
|
+
* @example
|
|
40764
|
+
* ```ts
|
|
40765
|
+
* await item.fetchInventoryItemById();
|
|
40766
|
+
* ```
|
|
40767
|
+
*
|
|
40768
|
+
* @returns {Promise<InventoryItem>} Returns when the item has been fetched and assigned.
|
|
40769
|
+
*/
|
|
40770
|
+
fetchInventoryItemById() {
|
|
40771
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40772
|
+
const response = yield this.topiaPublicApi().get(`/inventory/${this.id}`, this.requestOptions);
|
|
40773
|
+
Object.assign(this, response.data);
|
|
40774
|
+
return this;
|
|
40775
|
+
});
|
|
40776
|
+
}
|
|
40777
|
+
}
|
|
40778
|
+
|
|
40779
|
+
var _Ecosystem_inventoryItems;
|
|
40678
40780
|
/* ============================================================================
|
|
40679
40781
|
AI RULES for code assistants
|
|
40680
40782
|
|
|
@@ -40718,11 +40820,15 @@ AI RULES for code assistants
|
|
|
40718
40820
|
class Ecosystem extends SDKController {
|
|
40719
40821
|
constructor(topia, options = { credentials: {} }) {
|
|
40720
40822
|
super(topia, options.credentials);
|
|
40823
|
+
_Ecosystem_inventoryItems.set(this, void 0);
|
|
40721
40824
|
this.dataObject = {};
|
|
40825
|
+
__classPrivateFieldSet(this, _Ecosystem_inventoryItems, [], "f");
|
|
40722
40826
|
}
|
|
40723
40827
|
/**
|
|
40724
40828
|
* Retrieves the data object for a Topia ecosystem. Requires canUpdateEcosystemDataObjects permission to be set to true for the public key.
|
|
40725
40829
|
*
|
|
40830
|
+
* @keywords get, fetch, retrieve, load, data, object, state
|
|
40831
|
+
*
|
|
40726
40832
|
* @category Data Objects
|
|
40727
40833
|
*
|
|
40728
40834
|
* @example
|
|
@@ -40757,6 +40863,8 @@ class Ecosystem extends SDKController {
|
|
|
40757
40863
|
*
|
|
40758
40864
|
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
40759
40865
|
*
|
|
40866
|
+
* @keywords set, assign, store, save, data, object, state
|
|
40867
|
+
*
|
|
40760
40868
|
* @category Data Objects
|
|
40761
40869
|
*
|
|
40762
40870
|
* @example
|
|
@@ -40787,6 +40895,8 @@ class Ecosystem extends SDKController {
|
|
|
40787
40895
|
*
|
|
40788
40896
|
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
40789
40897
|
*
|
|
40898
|
+
* @keywords update, modify, change, edit, alter, data, object, state
|
|
40899
|
+
*
|
|
40790
40900
|
* @category Data Objects
|
|
40791
40901
|
*
|
|
40792
40902
|
* @example
|
|
@@ -40823,6 +40933,8 @@ class Ecosystem extends SDKController {
|
|
|
40823
40933
|
*
|
|
40824
40934
|
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
40825
40935
|
*
|
|
40936
|
+
* @keywords increment, increase, add, count, data, object, state
|
|
40937
|
+
*
|
|
40826
40938
|
* @category Data Objects
|
|
40827
40939
|
*
|
|
40828
40940
|
* @example
|
|
@@ -40847,6 +40959,88 @@ class Ecosystem extends SDKController {
|
|
|
40847
40959
|
}
|
|
40848
40960
|
});
|
|
40849
40961
|
}
|
|
40962
|
+
/**
|
|
40963
|
+
* Retrieves all inventory items for a given keyholder (app public key).
|
|
40964
|
+
*
|
|
40965
|
+
* @keywords get, fetch, retrieve, list, inventory, items, keyholder
|
|
40966
|
+
*
|
|
40967
|
+
* @example
|
|
40968
|
+
* ```ts
|
|
40969
|
+
* const items = await ecosystem.fetchInventoryItems("appPublicKey", "appJWT");
|
|
40970
|
+
* ```
|
|
40971
|
+
*
|
|
40972
|
+
* @returns {Promise<object[]>} Returns an array of InventoryItem objects.
|
|
40973
|
+
*/
|
|
40974
|
+
fetchInventoryItems() {
|
|
40975
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40976
|
+
try {
|
|
40977
|
+
// const query = appJWT ? `?appPublicKey=${appPublicKey}&appJWT=${appJWT}` : `?appPublicKey=${appPublicKey}`;
|
|
40978
|
+
const response = yield this.topiaPublicApi().get(`/inventory/`, this.requestOptions);
|
|
40979
|
+
// TODO: Replace 'object' with InventoryItem and instantiate InventoryItem objects if needed
|
|
40980
|
+
// create temp map and then update private property only once
|
|
40981
|
+
const tempItems = [];
|
|
40982
|
+
for (const index in response.data) {
|
|
40983
|
+
tempItems.push(new InventoryItem(this.topia, response.data[index].id, {
|
|
40984
|
+
attributes: response.data[index],
|
|
40985
|
+
credentials: this.credentials,
|
|
40986
|
+
}));
|
|
40987
|
+
}
|
|
40988
|
+
__classPrivateFieldSet(this, _Ecosystem_inventoryItems, tempItems, "f");
|
|
40989
|
+
}
|
|
40990
|
+
catch (error) {
|
|
40991
|
+
throw this.errorHandler({ error, sdkMethod: "Ecosystem.fetchInventoryItems" });
|
|
40992
|
+
}
|
|
40993
|
+
});
|
|
40994
|
+
}
|
|
40995
|
+
get inventoryItems() {
|
|
40996
|
+
return __classPrivateFieldGet(this, _Ecosystem_inventoryItems, "f");
|
|
40997
|
+
}
|
|
40998
|
+
}
|
|
40999
|
+
_Ecosystem_inventoryItems = new WeakMap();
|
|
41000
|
+
|
|
41001
|
+
/**
|
|
41002
|
+
* Controller for a user's owned inventory item.
|
|
41003
|
+
*
|
|
41004
|
+
* @remarks
|
|
41005
|
+
* This class should be instantiated via UserInventoryItemFactory only.
|
|
41006
|
+
*
|
|
41007
|
+
* @property inventoryItemId - The root inventory item's id
|
|
41008
|
+
*/
|
|
41009
|
+
class UserInventoryItem extends InventoryItem {
|
|
41010
|
+
constructor(topia, id, options = { attributes: {}, credentials: {} }) {
|
|
41011
|
+
const { attributes = {} } = options;
|
|
41012
|
+
const { item_id = "" } = attributes;
|
|
41013
|
+
super(topia, item_id, { attributes: options.attributes, credentials: options.credentials });
|
|
41014
|
+
Object.assign(this, options.attributes);
|
|
41015
|
+
this.userItemId = id;
|
|
41016
|
+
const { user_id = "", quantity = 0, grant_source = "unknown", type = "unknown", metadata = {}, created_at = new Date(), updated_at = new Date(), } = options.attributes;
|
|
41017
|
+
this.item_id = item_id;
|
|
41018
|
+
this.quantity = quantity;
|
|
41019
|
+
this.grant_source = grant_source;
|
|
41020
|
+
this.user_id = user_id;
|
|
41021
|
+
this.type = type;
|
|
41022
|
+
this.metadata = metadata;
|
|
41023
|
+
this.created_at = created_at;
|
|
41024
|
+
this.updated_at = updated_at;
|
|
41025
|
+
}
|
|
41026
|
+
/**
|
|
41027
|
+
* Fetches the user inventory item details from the platform and assigns them to this instance.
|
|
41028
|
+
*
|
|
41029
|
+
* @example
|
|
41030
|
+
* ```ts
|
|
41031
|
+
* await userInventoryItem.fetchUserInventoryItemById();
|
|
41032
|
+
* ```
|
|
41033
|
+
*
|
|
41034
|
+
* @returns {Promise<void>} Returns when the item has been fetched and assigned.
|
|
41035
|
+
*/
|
|
41036
|
+
fetchUserInventoryItemById() {
|
|
41037
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41038
|
+
// TODO: Implement API call to fetch user inventory item details
|
|
41039
|
+
// Example:
|
|
41040
|
+
// const response = await this.topia.api.get(`/inventory/user-items/${this.userId}/${this.inventoryItemId}`, this.options?.credentials);
|
|
41041
|
+
// Object.assign(this, response.data);
|
|
41042
|
+
});
|
|
41043
|
+
}
|
|
40850
41044
|
}
|
|
40851
41045
|
|
|
40852
41046
|
/* ============================================================================
|
|
@@ -40898,6 +41092,8 @@ class Scene extends SDKController {
|
|
|
40898
41092
|
/**
|
|
40899
41093
|
* Retrieves scene details and assigns response data to the instance.
|
|
40900
41094
|
*
|
|
41095
|
+
* @keywords get, fetch, retrieve, load, details, info, information, scene
|
|
41096
|
+
*
|
|
40901
41097
|
* @example
|
|
40902
41098
|
* ```ts
|
|
40903
41099
|
* await scene.fetchSceneById();
|
|
@@ -41005,6 +41201,8 @@ class World extends SDKController {
|
|
|
41005
41201
|
/**
|
|
41006
41202
|
* Retrieves the data object for a world. Must have valid interactive credentials from a visitor in the world.
|
|
41007
41203
|
*
|
|
41204
|
+
* @keywords get, fetch, retrieve, load, data, object, state
|
|
41205
|
+
*
|
|
41008
41206
|
* @category Data Objects
|
|
41009
41207
|
*
|
|
41010
41208
|
* @example
|
|
@@ -41034,6 +41232,8 @@ class World extends SDKController {
|
|
|
41034
41232
|
* @remarks
|
|
41035
41233
|
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
41036
41234
|
*
|
|
41235
|
+
* @keywords set, assign, store, save, data, object, state
|
|
41236
|
+
*
|
|
41037
41237
|
* @category Data Objects
|
|
41038
41238
|
*
|
|
41039
41239
|
* @example
|
|
@@ -41063,6 +41263,8 @@ class World extends SDKController {
|
|
|
41063
41263
|
* @remarks
|
|
41064
41264
|
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
41065
41265
|
*
|
|
41266
|
+
* @keywords update, modify, change, edit, alter, data, object, state
|
|
41267
|
+
*
|
|
41066
41268
|
* @category Data Objects
|
|
41067
41269
|
*
|
|
41068
41270
|
* @example
|
|
@@ -41094,6 +41296,8 @@ class World extends SDKController {
|
|
|
41094
41296
|
/**
|
|
41095
41297
|
* Retrieves details of a world.
|
|
41096
41298
|
*
|
|
41299
|
+
* @keywords get, fetch, retrieve, details, info, information, world
|
|
41300
|
+
*
|
|
41097
41301
|
* @example
|
|
41098
41302
|
* ```ts
|
|
41099
41303
|
* await world.fetchDetails();
|
|
@@ -41114,6 +41318,8 @@ class World extends SDKController {
|
|
|
41114
41318
|
/**
|
|
41115
41319
|
* Update details of a world.
|
|
41116
41320
|
*
|
|
41321
|
+
* @keywords update, modify, change, edit, world, settings, details
|
|
41322
|
+
*
|
|
41117
41323
|
* @example
|
|
41118
41324
|
* ```ts
|
|
41119
41325
|
* await world.updateDetails({
|
|
@@ -41158,6 +41364,8 @@ class World extends SDKController {
|
|
|
41158
41364
|
/**
|
|
41159
41365
|
* Set close world settings
|
|
41160
41366
|
*
|
|
41367
|
+
* @keywords update, modify, change, edit, world, settings, details, close, closed
|
|
41368
|
+
*
|
|
41161
41369
|
* @example
|
|
41162
41370
|
* ```ts
|
|
41163
41371
|
* await world.updateCloseWorldSettings({
|
|
@@ -41197,6 +41405,8 @@ class World extends SDKController {
|
|
|
41197
41405
|
/**
|
|
41198
41406
|
* Retrieve all assets dropped in a world.
|
|
41199
41407
|
*
|
|
41408
|
+
* @keywords get, fetch, retrieve, list, current, dropped assets
|
|
41409
|
+
*
|
|
41200
41410
|
* @category Dropped Assets
|
|
41201
41411
|
*
|
|
41202
41412
|
* @example
|
|
@@ -41227,6 +41437,8 @@ class World extends SDKController {
|
|
|
41227
41437
|
/**
|
|
41228
41438
|
* Retrieve all assets dropped in a world matching uniqueName.
|
|
41229
41439
|
*
|
|
41440
|
+
* @keywords get, fetch, retrieve, list, current, dropped assets, uniqueName
|
|
41441
|
+
*
|
|
41230
41442
|
* @category Dropped Assets
|
|
41231
41443
|
*
|
|
41232
41444
|
* @example
|
|
@@ -41261,6 +41473,8 @@ class World extends SDKController {
|
|
|
41261
41473
|
/**
|
|
41262
41474
|
* Retrieve all assets dropped in a world matching sceneDropId.
|
|
41263
41475
|
*
|
|
41476
|
+
* @keywords get, fetch, retrieve, list, current, dropped assets, sceneDropId
|
|
41477
|
+
*
|
|
41264
41478
|
* @category Dropped Assets
|
|
41265
41479
|
*
|
|
41266
41480
|
* @example
|
|
@@ -41301,6 +41515,8 @@ class World extends SDKController {
|
|
|
41301
41515
|
/**
|
|
41302
41516
|
* Update multiple custom text dropped assets with a single style while preserving text for specified dropped assets only.
|
|
41303
41517
|
*
|
|
41518
|
+
* @keywords update, modify, change, edit, dropped assets, custom text, style, text
|
|
41519
|
+
*
|
|
41304
41520
|
* @category Dropped Assets
|
|
41305
41521
|
*
|
|
41306
41522
|
* @example
|
|
@@ -41332,6 +41548,8 @@ class World extends SDKController {
|
|
|
41332
41548
|
/**
|
|
41333
41549
|
* Retrieve all landmark zone assets dropped in a world.
|
|
41334
41550
|
*
|
|
41551
|
+
* @keywords get, fetch, retrieve, list, landmark, zones, dropped assets
|
|
41552
|
+
*
|
|
41335
41553
|
* @category Dropped Assets
|
|
41336
41554
|
*
|
|
41337
41555
|
* @example
|
|
@@ -41403,6 +41621,8 @@ class World extends SDKController {
|
|
|
41403
41621
|
/**
|
|
41404
41622
|
* Fetch a list of all scene drop ids and dropped assets in a world
|
|
41405
41623
|
*
|
|
41624
|
+
* @keywords get, fetch, retrieve, list, scenes
|
|
41625
|
+
*
|
|
41406
41626
|
* @category Scenes
|
|
41407
41627
|
*
|
|
41408
41628
|
* @example
|
|
@@ -41444,6 +41664,8 @@ class World extends SDKController {
|
|
|
41444
41664
|
/**
|
|
41445
41665
|
* Drops a scene in a world and returns sceneDropId.
|
|
41446
41666
|
*
|
|
41667
|
+
* @keywords drop, add, place, scene
|
|
41668
|
+
*
|
|
41447
41669
|
* @category Scenes
|
|
41448
41670
|
*
|
|
41449
41671
|
* @example
|
|
@@ -41478,6 +41700,8 @@ class World extends SDKController {
|
|
|
41478
41700
|
/**
|
|
41479
41701
|
* Replace the current scene of a world.
|
|
41480
41702
|
*
|
|
41703
|
+
* @keywords replace, change, scene
|
|
41704
|
+
*
|
|
41481
41705
|
* @category Scenes
|
|
41482
41706
|
*
|
|
41483
41707
|
* @example
|
|
@@ -41508,6 +41732,8 @@ class World extends SDKController {
|
|
|
41508
41732
|
/**
|
|
41509
41733
|
* Get all particles available
|
|
41510
41734
|
*
|
|
41735
|
+
* @keywords get, fetch, retrieve, list, particles
|
|
41736
|
+
*
|
|
41511
41737
|
* @category Particles
|
|
41512
41738
|
*
|
|
41513
41739
|
* @example
|
|
@@ -41531,6 +41757,8 @@ class World extends SDKController {
|
|
|
41531
41757
|
/**
|
|
41532
41758
|
* Trigger a particle effect at a position in the world
|
|
41533
41759
|
*
|
|
41760
|
+
* @keywords trigger, start, play, particle, effect
|
|
41761
|
+
*
|
|
41534
41762
|
* @category Particles
|
|
41535
41763
|
*
|
|
41536
41764
|
* @example
|
|
@@ -41567,6 +41795,8 @@ class World extends SDKController {
|
|
|
41567
41795
|
* Add an activity to a world
|
|
41568
41796
|
* excludeFromNotification is an array of visitorIds to exclude from the notification
|
|
41569
41797
|
*
|
|
41798
|
+
* @keywords start, trigger, activity
|
|
41799
|
+
*
|
|
41570
41800
|
* @example
|
|
41571
41801
|
* ```ts
|
|
41572
41802
|
* await world.triggerActivity({ type: "GAME_ON", assetId: "abc123" });
|
|
@@ -41589,6 +41819,8 @@ class World extends SDKController {
|
|
|
41589
41819
|
/**
|
|
41590
41820
|
* Display a message via a toast to all visitors currently in a world.
|
|
41591
41821
|
*
|
|
41822
|
+
* @keywords send, display, show, toast, message, notification
|
|
41823
|
+
*
|
|
41592
41824
|
* @example
|
|
41593
41825
|
* ```ts
|
|
41594
41826
|
* await world.fireToast({
|
|
@@ -41622,6 +41854,8 @@ class World extends SDKController {
|
|
|
41622
41854
|
* @remarks
|
|
41623
41855
|
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
41624
41856
|
*
|
|
41857
|
+
* @keywords increment, increase, add, count, data, object, state
|
|
41858
|
+
*
|
|
41625
41859
|
* @category Data Objects
|
|
41626
41860
|
*
|
|
41627
41861
|
* @example
|
|
@@ -41647,6 +41881,8 @@ class World extends SDKController {
|
|
|
41647
41881
|
/**
|
|
41648
41882
|
* Retrieve all webhooks in a world.
|
|
41649
41883
|
*
|
|
41884
|
+
* @keywords get, fetch, retrieve, list, current, webhooks
|
|
41885
|
+
*
|
|
41650
41886
|
* @category Webhooks
|
|
41651
41887
|
*
|
|
41652
41888
|
* @example
|
|
@@ -41670,6 +41906,8 @@ class World extends SDKController {
|
|
|
41670
41906
|
/**
|
|
41671
41907
|
* Retrieve world analytics by day, week, month, quarter, or year
|
|
41672
41908
|
*
|
|
41909
|
+
* @keywords get, fetch, retrieve, analytics, stats, statistics, data, metrics
|
|
41910
|
+
*
|
|
41673
41911
|
* @category Analytics
|
|
41674
41912
|
*
|
|
41675
41913
|
* @example
|
|
@@ -41713,7 +41951,7 @@ class World extends SDKController {
|
|
|
41713
41951
|
}
|
|
41714
41952
|
_World_droppedAssetsMap = new WeakMap();
|
|
41715
41953
|
|
|
41716
|
-
var _User_adminWorldsMap, _User_assetsMap, _User_scenesMap, _User_worldsMap;
|
|
41954
|
+
var _User_userInventoryItems, _User_adminWorldsMap, _User_assetsMap, _User_scenesMap, _User_worldsMap;
|
|
41717
41955
|
/* ============================================================================
|
|
41718
41956
|
AI RULES for code assistants
|
|
41719
41957
|
|
|
@@ -41758,6 +41996,7 @@ AI RULES for code assistants
|
|
|
41758
41996
|
class User extends SDKController {
|
|
41759
41997
|
constructor(topia, options = { profileId: null, credentials: {} }) {
|
|
41760
41998
|
super(topia, Object.assign({ profileId: options === null || options === void 0 ? void 0 : options.profileId }, options.credentials));
|
|
41999
|
+
_User_userInventoryItems.set(this, void 0);
|
|
41761
42000
|
_User_adminWorldsMap.set(this, void 0);
|
|
41762
42001
|
_User_assetsMap.set(this, void 0);
|
|
41763
42002
|
_User_scenesMap.set(this, void 0);
|
|
@@ -41769,6 +42008,7 @@ class User extends SDKController {
|
|
|
41769
42008
|
__classPrivateFieldSet(this, _User_assetsMap, {}, "f");
|
|
41770
42009
|
__classPrivateFieldSet(this, _User_scenesMap, {}, "f");
|
|
41771
42010
|
__classPrivateFieldSet(this, _User_worldsMap, {}, "f");
|
|
42011
|
+
__classPrivateFieldSet(this, _User_userInventoryItems, [], "f");
|
|
41772
42012
|
}
|
|
41773
42013
|
get adminWorlds() {
|
|
41774
42014
|
return __classPrivateFieldGet(this, _User_adminWorldsMap, "f");
|
|
@@ -41785,6 +42025,8 @@ class User extends SDKController {
|
|
|
41785
42025
|
/*
|
|
41786
42026
|
* Verify user has valid interactive credentials
|
|
41787
42027
|
*
|
|
42028
|
+
* @keywords check, verify, validate, credentials, authentication, authorization, interactive
|
|
42029
|
+
*
|
|
41788
42030
|
* @example
|
|
41789
42031
|
* ```ts
|
|
41790
42032
|
* await user.checkInteractiveCredentials();
|
|
@@ -41806,6 +42048,8 @@ class User extends SDKController {
|
|
|
41806
42048
|
/**
|
|
41807
42049
|
* Returns all avatars owned by User
|
|
41808
42050
|
*
|
|
42051
|
+
* @keywords get, fetch, retrieve, list, avatars, characters
|
|
42052
|
+
*
|
|
41809
42053
|
* @category Avatars
|
|
41810
42054
|
*
|
|
41811
42055
|
* @example
|
|
@@ -41829,6 +42073,8 @@ class User extends SDKController {
|
|
|
41829
42073
|
/**
|
|
41830
42074
|
* Add a new avatar
|
|
41831
42075
|
*
|
|
42076
|
+
* @keywords add, create, upload, avatar, character
|
|
42077
|
+
*
|
|
41832
42078
|
* @category Avatars
|
|
41833
42079
|
*
|
|
41834
42080
|
* @example
|
|
@@ -41911,6 +42157,8 @@ class User extends SDKController {
|
|
|
41911
42157
|
/**
|
|
41912
42158
|
* Update avatar and sprite sheet records and upload files to existing sprite sheet and avatar storage buckets
|
|
41913
42159
|
*
|
|
42160
|
+
* @keywords update, modify, change, edit, avatar, character
|
|
42161
|
+
*
|
|
41914
42162
|
* @category Avatars
|
|
41915
42163
|
*
|
|
41916
42164
|
* @example
|
|
@@ -41993,6 +42241,8 @@ class User extends SDKController {
|
|
|
41993
42241
|
/**
|
|
41994
42242
|
* Update avatar and sprite sheet records and upload files to existing sprite sheet and avatar storage buckets
|
|
41995
42243
|
*
|
|
42244
|
+
* @keywords delete, remove, erase, destroy, eliminate, avatar
|
|
42245
|
+
*
|
|
41996
42246
|
* @category Avatars
|
|
41997
42247
|
*
|
|
41998
42248
|
* @example
|
|
@@ -42014,6 +42264,8 @@ class User extends SDKController {
|
|
|
42014
42264
|
/**
|
|
42015
42265
|
* Returns all assets owned by User when an email address is provided.
|
|
42016
42266
|
*
|
|
42267
|
+
* @keywords get, fetch, retrieve, list, user assets, objects
|
|
42268
|
+
*
|
|
42017
42269
|
* @category Assets
|
|
42018
42270
|
*
|
|
42019
42271
|
* @example
|
|
@@ -42044,6 +42296,8 @@ class User extends SDKController {
|
|
|
42044
42296
|
/**
|
|
42045
42297
|
* Returns all platform assets.
|
|
42046
42298
|
*
|
|
42299
|
+
* @keywords get, fetch, retrieve, list, platform assets, objects
|
|
42300
|
+
*
|
|
42047
42301
|
* @category Assets
|
|
42048
42302
|
*
|
|
42049
42303
|
* @example
|
|
@@ -42067,6 +42321,8 @@ class User extends SDKController {
|
|
|
42067
42321
|
/**
|
|
42068
42322
|
* Returns all scenes owned by User.
|
|
42069
42323
|
*
|
|
42324
|
+
* @keywords get, fetch, retrieve, list, user scenes
|
|
42325
|
+
*
|
|
42070
42326
|
* @category Scenes
|
|
42071
42327
|
*
|
|
42072
42328
|
* @example
|
|
@@ -42097,6 +42353,8 @@ class User extends SDKController {
|
|
|
42097
42353
|
/**
|
|
42098
42354
|
* Retrieves all worlds owned by user with matching API Key, creates a new World object for each, and creates new map of Worlds accessible via user.worlds.
|
|
42099
42355
|
*
|
|
42356
|
+
* @keywords get, fetch, retrieve, list, user worlds
|
|
42357
|
+
*
|
|
42100
42358
|
* @category Worlds
|
|
42101
42359
|
*
|
|
42102
42360
|
* @example
|
|
@@ -42132,6 +42390,8 @@ class User extends SDKController {
|
|
|
42132
42390
|
/**
|
|
42133
42391
|
* Retrieves all worlds a user with matching API Key is an admin in, creates a new World object for each, and creates new map of Worlds accessible via user.adminWorlds.
|
|
42134
42392
|
*
|
|
42393
|
+
* @keywords get, fetch, retrieve, list, admin worlds, user worlds
|
|
42394
|
+
*
|
|
42135
42395
|
* @category Worlds
|
|
42136
42396
|
*
|
|
42137
42397
|
* @example
|
|
@@ -42161,6 +42421,8 @@ class User extends SDKController {
|
|
|
42161
42421
|
/**
|
|
42162
42422
|
* Retrieves ids of all dropped assets in all worlds with a matching interactivePublicKey.
|
|
42163
42423
|
*
|
|
42424
|
+
* @keywords get, fetch, retrieve, list, interactive worlds, public key
|
|
42425
|
+
*
|
|
42164
42426
|
* @category Dropped Assets
|
|
42165
42427
|
*
|
|
42166
42428
|
* @example
|
|
@@ -42185,6 +42447,8 @@ class User extends SDKController {
|
|
|
42185
42447
|
/**
|
|
42186
42448
|
* Send an email
|
|
42187
42449
|
*
|
|
42450
|
+
* @keywords send, email, message, notify
|
|
42451
|
+
*
|
|
42188
42452
|
* @example
|
|
42189
42453
|
* ```ts
|
|
42190
42454
|
* const html = `<p><b>Hello World!</b></p><p>This email is being sent from via SDK.</p>`
|
|
@@ -42208,6 +42472,8 @@ class User extends SDKController {
|
|
|
42208
42472
|
/**
|
|
42209
42473
|
* Get expressions
|
|
42210
42474
|
*
|
|
42475
|
+
* @keywords get, fetch, retrieve, list, expressions, emotes
|
|
42476
|
+
*
|
|
42211
42477
|
* @category Expressions
|
|
42212
42478
|
*
|
|
42213
42479
|
* @example
|
|
@@ -42234,6 +42500,8 @@ class User extends SDKController {
|
|
|
42234
42500
|
/**
|
|
42235
42501
|
* Retrieves the data object for a user.
|
|
42236
42502
|
*
|
|
42503
|
+
* @keywords get, fetch, retrieve, load, data, object, state
|
|
42504
|
+
*
|
|
42237
42505
|
* @category Data Objects
|
|
42238
42506
|
*
|
|
42239
42507
|
* @example
|
|
@@ -42263,6 +42531,8 @@ class User extends SDKController {
|
|
|
42263
42531
|
/**
|
|
42264
42532
|
* Sets the data object for a user.
|
|
42265
42533
|
*
|
|
42534
|
+
* @keywords set, assign, store, save, data, object, state
|
|
42535
|
+
*
|
|
42266
42536
|
* @remarks
|
|
42267
42537
|
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
42268
42538
|
*
|
|
@@ -42297,6 +42567,8 @@ class User extends SDKController {
|
|
|
42297
42567
|
/**
|
|
42298
42568
|
* Updates the data object for a user.
|
|
42299
42569
|
*
|
|
42570
|
+
* @keywords update, modify, change, edit, alter, data, object, state
|
|
42571
|
+
*
|
|
42300
42572
|
* @remarks
|
|
42301
42573
|
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
42302
42574
|
*
|
|
@@ -42329,6 +42601,8 @@ class User extends SDKController {
|
|
|
42329
42601
|
/**
|
|
42330
42602
|
* Increments a specific value in the data object for a user by the amount specified. Must have valid interactive credentials from a visitor in the world.
|
|
42331
42603
|
*
|
|
42604
|
+
* @keywords increment, increase, add, count, data, object, state
|
|
42605
|
+
*
|
|
42332
42606
|
* @remarks
|
|
42333
42607
|
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
42334
42608
|
*
|
|
@@ -42349,9 +42623,46 @@ class User extends SDKController {
|
|
|
42349
42623
|
}
|
|
42350
42624
|
});
|
|
42351
42625
|
}
|
|
42626
|
+
/**
|
|
42627
|
+
* Retrieves all inventory items owned by this visitor and app's key.
|
|
42628
|
+
*
|
|
42629
|
+
* @keywords get, fetch, retrieve, list, inventory, items, visitor
|
|
42630
|
+
*
|
|
42631
|
+
* @example
|
|
42632
|
+
* ```ts
|
|
42633
|
+
* const items = await visitor.fetchInventoryItems();
|
|
42634
|
+
* ```
|
|
42635
|
+
*
|
|
42636
|
+
* @returns {Promise<void>} Returns an array of InventoryItem objects.
|
|
42637
|
+
*/
|
|
42638
|
+
fetchInventoryItems() {
|
|
42639
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42640
|
+
try {
|
|
42641
|
+
if (!this.profileId)
|
|
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);
|
|
42644
|
+
// TODO: Replace 'object' with InventoryItem and instantiate InventoryItem objects if needed
|
|
42645
|
+
const tempItems = [];
|
|
42646
|
+
for (const index in response.data) {
|
|
42647
|
+
tempItems.push(new UserInventoryItem(this.topia, response.data[index].id, {
|
|
42648
|
+
attributes: response.data[index],
|
|
42649
|
+
credentials: this.credentials,
|
|
42650
|
+
}));
|
|
42651
|
+
}
|
|
42652
|
+
__classPrivateFieldSet(this, _User_userInventoryItems, tempItems, "f");
|
|
42653
|
+
}
|
|
42654
|
+
catch (error) {
|
|
42655
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.fetchInventoryItems" });
|
|
42656
|
+
}
|
|
42657
|
+
});
|
|
42658
|
+
}
|
|
42659
|
+
get inventoryItems() {
|
|
42660
|
+
return __classPrivateFieldGet(this, _User_userInventoryItems, "f");
|
|
42661
|
+
}
|
|
42352
42662
|
}
|
|
42353
|
-
_User_adminWorldsMap = new WeakMap(), _User_assetsMap = new WeakMap(), _User_scenesMap = new WeakMap(), _User_worldsMap = new WeakMap();
|
|
42663
|
+
_User_userInventoryItems = new WeakMap(), _User_adminWorldsMap = new WeakMap(), _User_assetsMap = new WeakMap(), _User_scenesMap = new WeakMap(), _User_worldsMap = new WeakMap();
|
|
42354
42664
|
|
|
42665
|
+
var _Visitor_visitorInventoryItems;
|
|
42355
42666
|
/* ============================================================================
|
|
42356
42667
|
AI RULES for code assistants
|
|
42357
42668
|
|
|
@@ -42393,13 +42704,17 @@ AI RULES for code assistants
|
|
|
42393
42704
|
class Visitor extends User {
|
|
42394
42705
|
constructor(topia, id, urlSlug, options = { attributes: {}, credentials: {} }) {
|
|
42395
42706
|
super(topia, { credentials: Object.assign({ urlSlug }, options.credentials) });
|
|
42707
|
+
_Visitor_visitorInventoryItems.set(this, void 0);
|
|
42396
42708
|
Object.assign(this, options.attributes);
|
|
42397
42709
|
this.id = id;
|
|
42398
42710
|
this.urlSlug = urlSlug;
|
|
42711
|
+
__classPrivateFieldSet(this, _Visitor_visitorInventoryItems, [], "f");
|
|
42399
42712
|
}
|
|
42400
42713
|
/**
|
|
42401
42714
|
* Get a single visitor from a world
|
|
42402
42715
|
*
|
|
42716
|
+
* @keywords get, fetch, retrieve, load, visitor, details
|
|
42717
|
+
*
|
|
42403
42718
|
* @example
|
|
42404
42719
|
* ```ts
|
|
42405
42720
|
* await visitor.fetchVisitor();
|
|
@@ -42433,6 +42748,8 @@ class Visitor extends User {
|
|
|
42433
42748
|
/**
|
|
42434
42749
|
* Teleport or walk a visitor currently in a world to a single set of coordinates.
|
|
42435
42750
|
*
|
|
42751
|
+
* @keywords move, teleport, walk, position, coordinate, location, place
|
|
42752
|
+
*
|
|
42436
42753
|
* @example
|
|
42437
42754
|
* ```ts
|
|
42438
42755
|
* await visitor.moveVisitor({
|
|
@@ -42465,6 +42782,8 @@ class Visitor extends User {
|
|
|
42465
42782
|
/**
|
|
42466
42783
|
* Display a message via a toast to a visitor currently in a world.
|
|
42467
42784
|
*
|
|
42785
|
+
* @keywords toast, message, notification, alert, display, show, popup
|
|
42786
|
+
*
|
|
42468
42787
|
* @example
|
|
42469
42788
|
* ```ts
|
|
42470
42789
|
* await visitor.fireToast({
|
|
@@ -42495,6 +42814,8 @@ class Visitor extends User {
|
|
|
42495
42814
|
/**
|
|
42496
42815
|
* Open an iframe in a drawer or modal for a visitor currently in a world.
|
|
42497
42816
|
*
|
|
42817
|
+
* @keywords open, iframe, drawer, modal, link, url, website, web page
|
|
42818
|
+
*
|
|
42498
42819
|
* @category iframes
|
|
42499
42820
|
*
|
|
42500
42821
|
* @example
|
|
@@ -42529,6 +42850,8 @@ class Visitor extends User {
|
|
|
42529
42850
|
/**
|
|
42530
42851
|
* Reload an iframe for a visitor currently in a world.
|
|
42531
42852
|
*
|
|
42853
|
+
* @keywords reload, iframe, drawer, modal, link, url, website, web page
|
|
42854
|
+
*
|
|
42532
42855
|
* @category iframes
|
|
42533
42856
|
*
|
|
42534
42857
|
* @example
|
|
@@ -42552,6 +42875,8 @@ class Visitor extends User {
|
|
|
42552
42875
|
/**
|
|
42553
42876
|
* Close an iframe for a visitor currently in a world.
|
|
42554
42877
|
*
|
|
42878
|
+
* @keywords close, iframe, drawer, modal
|
|
42879
|
+
*
|
|
42555
42880
|
* @category iframes
|
|
42556
42881
|
*
|
|
42557
42882
|
* @example
|
|
@@ -42575,6 +42900,8 @@ class Visitor extends User {
|
|
|
42575
42900
|
/**
|
|
42576
42901
|
* Mute and turn video off for a visitor currently in a world.
|
|
42577
42902
|
*
|
|
42903
|
+
* @keywords mute, video, av, turn off, disable
|
|
42904
|
+
*
|
|
42578
42905
|
* @example
|
|
42579
42906
|
* ```ts
|
|
42580
42907
|
* await visitor.turnAVOff();
|
|
@@ -42596,6 +42923,8 @@ class Visitor extends User {
|
|
|
42596
42923
|
/**
|
|
42597
42924
|
* Get expressions
|
|
42598
42925
|
*
|
|
42926
|
+
* @keywords get, fetch, retrieve, list, expressions, emotes
|
|
42927
|
+
*
|
|
42599
42928
|
* @category Expressions
|
|
42600
42929
|
*
|
|
42601
42930
|
* @example
|
|
@@ -42621,6 +42950,8 @@ class Visitor extends User {
|
|
|
42621
42950
|
/**
|
|
42622
42951
|
* Grant expression to a visitor by id or name.
|
|
42623
42952
|
*
|
|
42953
|
+
* @keywords grant, give, add, expression, emote
|
|
42954
|
+
*
|
|
42624
42955
|
* @category Expressions
|
|
42625
42956
|
*
|
|
42626
42957
|
* @example
|
|
@@ -42652,6 +42983,8 @@ class Visitor extends User {
|
|
|
42652
42983
|
/**
|
|
42653
42984
|
* Get all particles available
|
|
42654
42985
|
*
|
|
42986
|
+
* @keywords get, fetch, retrieve, list, particles, effects
|
|
42987
|
+
*
|
|
42655
42988
|
* @category Particle Effects
|
|
42656
42989
|
*
|
|
42657
42990
|
* @example
|
|
@@ -42675,6 +43008,8 @@ class Visitor extends User {
|
|
|
42675
43008
|
/**
|
|
42676
43009
|
* Trigger a particle effect on a visitor
|
|
42677
43010
|
*
|
|
43011
|
+
* @keywords trigger, particle, effect, spawn, start, play
|
|
43012
|
+
*
|
|
42678
43013
|
* @category Particle Effects
|
|
42679
43014
|
*
|
|
42680
43015
|
* @example
|
|
@@ -42708,6 +43043,8 @@ class Visitor extends User {
|
|
|
42708
43043
|
/**
|
|
42709
43044
|
* Retrieves the data object for a visitor.
|
|
42710
43045
|
*
|
|
43046
|
+
* @keywords get, fetch, retrieve, load, data, object, state
|
|
43047
|
+
*
|
|
42711
43048
|
* @category Data Objects
|
|
42712
43049
|
*
|
|
42713
43050
|
* @example
|
|
@@ -42737,6 +43074,8 @@ class Visitor extends User {
|
|
|
42737
43074
|
/**
|
|
42738
43075
|
* Sets the data object for a visitor.
|
|
42739
43076
|
*
|
|
43077
|
+
* @keywords set, assign, store, save, data, object, state
|
|
43078
|
+
*
|
|
42740
43079
|
* @remarks
|
|
42741
43080
|
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
42742
43081
|
*
|
|
@@ -42772,6 +43111,8 @@ class Visitor extends User {
|
|
|
42772
43111
|
* @remarks
|
|
42773
43112
|
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
42774
43113
|
*
|
|
43114
|
+
* @keywords update, modify, change, edit, alter, data, object, state
|
|
43115
|
+
*
|
|
42775
43116
|
* @category Data Objects
|
|
42776
43117
|
*
|
|
42777
43118
|
* @example
|
|
@@ -42802,6 +43143,8 @@ class Visitor extends User {
|
|
|
42802
43143
|
* @remarks
|
|
42803
43144
|
* Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
|
|
42804
43145
|
*
|
|
43146
|
+
* @keywords increment, increase, add, count, data, object, state
|
|
43147
|
+
*
|
|
42805
43148
|
* @category Data Objects
|
|
42806
43149
|
*
|
|
42807
43150
|
* @example
|
|
@@ -42826,6 +43169,8 @@ class Visitor extends User {
|
|
|
42826
43169
|
/**
|
|
42827
43170
|
* Update analytics for a given public key. Must have valid interactive credentials from a visitor in the world.
|
|
42828
43171
|
*
|
|
43172
|
+
* @keywords update, modify, change, edit, analytics, analytic, stats, statistics, data
|
|
43173
|
+
*
|
|
42829
43174
|
* @example
|
|
42830
43175
|
* ```ts
|
|
42831
43176
|
* await visitor.updatePublicKeyAnalytics([{ analyticName: "joins", profileId, uniqueKey: profileId, urlSlug }]);
|
|
@@ -42848,6 +43193,8 @@ class Visitor extends User {
|
|
|
42848
43193
|
/**
|
|
42849
43194
|
* Setup signal to visitor
|
|
42850
43195
|
*
|
|
43196
|
+
* @keywords signal, webrtc, answer, connect, p2p
|
|
43197
|
+
*
|
|
42851
43198
|
* @example
|
|
42852
43199
|
* ```ts
|
|
42853
43200
|
* await visitor.sendSignalToVisitor(iceServers);
|
|
@@ -42868,7 +43215,138 @@ class Visitor extends User {
|
|
|
42868
43215
|
}
|
|
42869
43216
|
});
|
|
42870
43217
|
}
|
|
42871
|
-
|
|
43218
|
+
/**
|
|
43219
|
+
* Retrieves all inventory items owned by this visitor and app's key.
|
|
43220
|
+
*
|
|
43221
|
+
* @keywords get, fetch, retrieve, list, inventory, items, visitor
|
|
43222
|
+
*
|
|
43223
|
+
* @example
|
|
43224
|
+
* ```ts
|
|
43225
|
+
* const items = await visitor.fetchInventoryItems();
|
|
43226
|
+
* ```
|
|
43227
|
+
*
|
|
43228
|
+
* @returns {Promise<void>} Returns an array of InventoryItem objects.
|
|
43229
|
+
*/
|
|
43230
|
+
fetchInventoryItem(item) {
|
|
43231
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43232
|
+
try {
|
|
43233
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors/${this.id}/get-visitor-inventory-items/${item.id}`, this.requestOptions);
|
|
43234
|
+
return new UserInventoryItem(this.topia, response.data.id, {
|
|
43235
|
+
attributes: response.data,
|
|
43236
|
+
credentials: this.credentials,
|
|
43237
|
+
});
|
|
43238
|
+
}
|
|
43239
|
+
catch (error) {
|
|
43240
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.fetchInventoryItems" });
|
|
43241
|
+
}
|
|
43242
|
+
});
|
|
43243
|
+
}
|
|
43244
|
+
/**
|
|
43245
|
+
* Retrieves all inventory items owned by this visitor and app's key.
|
|
43246
|
+
*
|
|
43247
|
+
* @keywords get, fetch, retrieve, list, inventory, items, visitor
|
|
43248
|
+
*
|
|
43249
|
+
* @example
|
|
43250
|
+
* ```ts
|
|
43251
|
+
* const items = await visitor.fetchInventoryItems();
|
|
43252
|
+
* ```
|
|
43253
|
+
*
|
|
43254
|
+
* @returns {Promise<void>} Returns an array of InventoryItem objects.
|
|
43255
|
+
*/
|
|
43256
|
+
fetchInventoryItems() {
|
|
43257
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43258
|
+
try {
|
|
43259
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors/${this.id}/get-visitor-inventory-items`, this.requestOptions);
|
|
43260
|
+
// TODO: Replace 'object' with InventoryItem and instantiate InventoryItem objects if needed
|
|
43261
|
+
const tempItems = [];
|
|
43262
|
+
for (const index in response.data) {
|
|
43263
|
+
tempItems.push(new UserInventoryItem(this.topia, response.data[index].id, {
|
|
43264
|
+
attributes: response.data[index],
|
|
43265
|
+
credentials: this.credentials,
|
|
43266
|
+
}));
|
|
43267
|
+
}
|
|
43268
|
+
__classPrivateFieldSet(this, _Visitor_visitorInventoryItems, tempItems, "f");
|
|
43269
|
+
}
|
|
43270
|
+
catch (error) {
|
|
43271
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.fetchInventoryItems" });
|
|
43272
|
+
}
|
|
43273
|
+
});
|
|
43274
|
+
}
|
|
43275
|
+
get inventoryItems() {
|
|
43276
|
+
return __classPrivateFieldGet(this, _Visitor_visitorInventoryItems, "f");
|
|
43277
|
+
}
|
|
43278
|
+
/**
|
|
43279
|
+
* Grants an inventory item to this visitor.
|
|
43280
|
+
*
|
|
43281
|
+
* @param itemId The ID of the inventory item to grant.
|
|
43282
|
+
* @param quantity The quantity to grant (default 1).
|
|
43283
|
+
*
|
|
43284
|
+
* @example
|
|
43285
|
+
* ```ts
|
|
43286
|
+
* await visitor.grantInventoryItem("item-id-123", 2);
|
|
43287
|
+
* ```
|
|
43288
|
+
*
|
|
43289
|
+
* @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
|
|
43290
|
+
*/
|
|
43291
|
+
grantInventoryItem(item, quantity = 1) {
|
|
43292
|
+
var _a;
|
|
43293
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43294
|
+
// Error if item already exists in #visitorInventoryItems
|
|
43295
|
+
const exists = (_a = __classPrivateFieldGet(this, _Visitor_visitorInventoryItems, "f")) === null || _a === void 0 ? void 0 : _a.some((visitorItem) => visitorItem.id === item.id);
|
|
43296
|
+
if (exists) {
|
|
43297
|
+
throw new Error(`Inventory item with id '${item.id}' already exists in visitorInventoryItems.`);
|
|
43298
|
+
}
|
|
43299
|
+
try {
|
|
43300
|
+
const response = yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/grant-visitor-inventory-item`, { itemId: item.id, quantity }, this.requestOptions);
|
|
43301
|
+
const userInventoryItemFactory = new UserInventoryItemFactory(this.topia);
|
|
43302
|
+
const { inventoryItem, user_id, quantity: newQuantity } = response.data;
|
|
43303
|
+
return userInventoryItemFactory.create(inventoryItem, user_id, newQuantity, {
|
|
43304
|
+
attributes: response.data,
|
|
43305
|
+
credentials: this.credentials,
|
|
43306
|
+
});
|
|
43307
|
+
}
|
|
43308
|
+
catch (error) {
|
|
43309
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.grantInventoryItem" });
|
|
43310
|
+
}
|
|
43311
|
+
});
|
|
43312
|
+
}
|
|
43313
|
+
/**
|
|
43314
|
+
* Modifies the quantity of an inventory item in this visitor's inventory.
|
|
43315
|
+
*
|
|
43316
|
+
* @param itemId The ID of the inventory item to modify.
|
|
43317
|
+
* @param quantity The new quantity to set.
|
|
43318
|
+
*
|
|
43319
|
+
* @example
|
|
43320
|
+
* ```ts
|
|
43321
|
+
* await visitor.modifyInventoryItemQuantity("item-id-123", 5);
|
|
43322
|
+
* ```
|
|
43323
|
+
*
|
|
43324
|
+
* @returns {Promise<UserInventoryItem>} Returns the updated inventory or a response object.
|
|
43325
|
+
*/
|
|
43326
|
+
modifyInventoryItemQuantity(item, quantity) {
|
|
43327
|
+
var _a;
|
|
43328
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43329
|
+
// Check for existence in #visitorInventoryItems
|
|
43330
|
+
const found = (_a = __classPrivateFieldGet(this, _Visitor_visitorInventoryItems, "f")) === null || _a === void 0 ? void 0 : _a.some((visitorItem) => visitorItem.id === item.userItemId);
|
|
43331
|
+
if (!found) {
|
|
43332
|
+
throw new Error(`Inventory item with id '${item.userItemId}' does not exist in visitorInventoryItems.`);
|
|
43333
|
+
}
|
|
43334
|
+
try {
|
|
43335
|
+
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);
|
|
43336
|
+
const userInventoryItemFactory = new UserInventoryItemFactory(this.topia);
|
|
43337
|
+
const { inventoryItem, user_id, quantity: newQuantity } = response.data;
|
|
43338
|
+
return userInventoryItemFactory.create(inventoryItem, user_id, newQuantity, {
|
|
43339
|
+
attributes: response.data,
|
|
43340
|
+
credentials: this.credentials,
|
|
43341
|
+
});
|
|
43342
|
+
}
|
|
43343
|
+
catch (error) {
|
|
43344
|
+
throw this.errorHandler({ error, sdkMethod: "Visitor.modifyInventoryItemQuantity" });
|
|
43345
|
+
}
|
|
43346
|
+
});
|
|
43347
|
+
}
|
|
43348
|
+
}
|
|
43349
|
+
_Visitor_visitorInventoryItems = new WeakMap();
|
|
42872
43350
|
|
|
42873
43351
|
/**
|
|
42874
43352
|
* Create an instance of WebRTCConnector class with optional session credentials.
|
|
@@ -42997,6 +43475,8 @@ class WorldActivity extends SDKController {
|
|
|
42997
43475
|
/**
|
|
42998
43476
|
* Retrieve all visitors currently in a world.
|
|
42999
43477
|
*
|
|
43478
|
+
* @keywords get, fetch, retrieve, list, current, visitors, users, players
|
|
43479
|
+
*
|
|
43000
43480
|
* @category Visitors
|
|
43001
43481
|
*
|
|
43002
43482
|
* @example
|
|
@@ -43020,6 +43500,8 @@ class WorldActivity extends SDKController {
|
|
|
43020
43500
|
/**
|
|
43021
43501
|
* Retrieve all visitors currently in a Landmark Zone.
|
|
43022
43502
|
*
|
|
43503
|
+
* @keywords get, fetch, retrieve, list, zone, area, landmark, visitors, users
|
|
43504
|
+
*
|
|
43023
43505
|
* @category Visitors
|
|
43024
43506
|
*
|
|
43025
43507
|
* @example
|
|
@@ -43049,6 +43531,8 @@ class WorldActivity extends SDKController {
|
|
|
43049
43531
|
* Optionally refetch visitors, teleport or walk visitors to new location,
|
|
43050
43532
|
* and scatter visitors by any number so that they don't all move to the exact same location.
|
|
43051
43533
|
*
|
|
43534
|
+
* @keywords move, teleport, position, coordinate, visitors, users, relocate
|
|
43535
|
+
*
|
|
43052
43536
|
* @category Visitors
|
|
43053
43537
|
*
|
|
43054
43538
|
* @example
|
|
@@ -43085,6 +43569,8 @@ class WorldActivity extends SDKController {
|
|
|
43085
43569
|
/**
|
|
43086
43570
|
* Teleport or walk a list of visitors currently in a world to various coordinates.
|
|
43087
43571
|
*
|
|
43572
|
+
* @keywords move, teleport, position, coordinate, visitor, user, relocate
|
|
43573
|
+
*
|
|
43088
43574
|
* @category Visitors
|
|
43089
43575
|
*
|
|
43090
43576
|
* @example
|
|
@@ -43152,9 +43638,19 @@ _WorldActivity_visitorsMap = new WeakMap();
|
|
|
43152
43638
|
Do NOT instantiate factories in controllers. Do NOT invent methods.
|
|
43153
43639
|
============================================================================ */
|
|
43154
43640
|
/**
|
|
43641
|
+
* Factory for creating Asset instances. Use this factory to create or upload assets in the Topia platform.
|
|
43642
|
+
*
|
|
43643
|
+
* @remarks
|
|
43644
|
+
* This factory should be instantiated once per application and reused across your codebase.
|
|
43645
|
+
*
|
|
43646
|
+
* @keywords asset, factory, create, upload, instantiate, topia
|
|
43647
|
+
*
|
|
43155
43648
|
* @example
|
|
43156
43649
|
* ```ts
|
|
43157
|
-
*
|
|
43650
|
+
* // In your initialization file (e.g., utils/topiaInit.ts)
|
|
43651
|
+
* import { Topia, AssetFactory } from "@rtsdk/topia";
|
|
43652
|
+
* const topia = new Topia({ config });
|
|
43653
|
+
* export const Asset = new AssetFactory(topia);
|
|
43158
43654
|
* ```
|
|
43159
43655
|
*/
|
|
43160
43656
|
class AssetFactory extends SDKController {
|
|
@@ -43162,11 +43658,32 @@ class AssetFactory extends SDKController {
|
|
|
43162
43658
|
super(topia);
|
|
43163
43659
|
}
|
|
43164
43660
|
/**
|
|
43165
|
-
* Instantiate a new instance of Asset class.
|
|
43661
|
+
* Instantiate a new instance of Asset class with the specified asset id.
|
|
43662
|
+
*
|
|
43663
|
+
* @remarks
|
|
43664
|
+
* This method creates a new Asset controller instance that can be used to interact with an existing asset.
|
|
43665
|
+
* It does not create a new asset in the database.
|
|
43666
|
+
*
|
|
43667
|
+
* @keywords create, instantiate, asset, initialize, get, instance
|
|
43166
43668
|
*
|
|
43167
43669
|
* @example
|
|
43168
|
-
* ```
|
|
43169
|
-
*
|
|
43670
|
+
* ```ts
|
|
43671
|
+
* // Import the pre-initialized factory from your app's initialization file
|
|
43672
|
+
* import { Asset } from "utils/topiaInit.ts";
|
|
43673
|
+
*
|
|
43674
|
+
* // Create an Asset instance with credentials
|
|
43675
|
+
* const assetInstance = await Asset.create(assetId, {
|
|
43676
|
+
* credentials: {
|
|
43677
|
+
* interactiveNonce,
|
|
43678
|
+
* interactivePublicKey,
|
|
43679
|
+
* assetId,
|
|
43680
|
+
* urlSlug,
|
|
43681
|
+
* visitorId
|
|
43682
|
+
* }
|
|
43683
|
+
* });
|
|
43684
|
+
*
|
|
43685
|
+
* // Use the instance to interact with the asset
|
|
43686
|
+
* await assetInstance.fetchAssetById();
|
|
43170
43687
|
* ```
|
|
43171
43688
|
*
|
|
43172
43689
|
* @returns {Asset} Returns a new Asset object with the asset id.
|
|
@@ -43175,22 +43692,37 @@ class AssetFactory extends SDKController {
|
|
|
43175
43692
|
return new Asset(this.topia, id, options);
|
|
43176
43693
|
}
|
|
43177
43694
|
/**
|
|
43178
|
-
* Upload a new Asset and return a new instance of Asset class.
|
|
43695
|
+
* Upload a new Asset to the Topia platform and return a new instance of Asset class.
|
|
43696
|
+
*
|
|
43697
|
+
* @remarks
|
|
43698
|
+
* This method both creates a new asset in the database and returns an Asset controller instance.
|
|
43699
|
+
* A valid API key with appropriate permissions is required.
|
|
43700
|
+
*
|
|
43701
|
+
* @keywords upload, create, new, asset, add, store
|
|
43179
43702
|
*
|
|
43180
43703
|
* @example
|
|
43181
|
-
* ```
|
|
43704
|
+
* ```ts
|
|
43705
|
+
* // Import the pre-initialized factory from your app's initialization file
|
|
43706
|
+
* import { Asset } from "utils/topiaInit.ts";
|
|
43707
|
+
*
|
|
43708
|
+
* // Prepare the asset payload
|
|
43182
43709
|
* const assetPayload = {
|
|
43183
|
-
* assetName: "
|
|
43184
|
-
* bottomLayerURL: "https://example.
|
|
43710
|
+
* assetName: "My Decorative Asset",
|
|
43711
|
+
* bottomLayerURL: "https://example.com/bottom-layer.png",
|
|
43185
43712
|
* creatorTags: { "decorations": true },
|
|
43186
43713
|
* tagJson: "[{"label":"decorations","value":"decorations"}]",
|
|
43187
43714
|
* isPublic: true,
|
|
43188
|
-
* topLayerURL: "https://example.
|
|
43189
|
-
* }
|
|
43715
|
+
* topLayerURL: "https://example.com/top-layer.png"
|
|
43716
|
+
* };
|
|
43717
|
+
*
|
|
43718
|
+
* // Upload the asset using your API key
|
|
43190
43719
|
* const asset = await Asset.upload(assetPayload, apiKey);
|
|
43720
|
+
*
|
|
43721
|
+
* // Access the new asset's properties
|
|
43722
|
+
* console.log(asset.id);
|
|
43191
43723
|
* ```
|
|
43192
43724
|
*
|
|
43193
|
-
* @returns {
|
|
43725
|
+
* @returns {Asset} Returns a new Asset object with the asset details.
|
|
43194
43726
|
*/
|
|
43195
43727
|
upload(assetPayload, apiKey) {
|
|
43196
43728
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43240,9 +43772,19 @@ class AssetFactory extends SDKController {
|
|
|
43240
43772
|
Do NOT instantiate factories in controllers. Do NOT invent methods.
|
|
43241
43773
|
============================================================================ */
|
|
43242
43774
|
/**
|
|
43775
|
+
* Factory for creating and retrieving DroppedAsset instances. Use this factory to work with assets that have been placed in a Topia world.
|
|
43776
|
+
*
|
|
43777
|
+
* @remarks
|
|
43778
|
+
* This factory should be instantiated once per application and reused across your codebase.
|
|
43779
|
+
*
|
|
43780
|
+
* @keywords dropped asset, factory, create, get, retrieve, instantiate, topia
|
|
43781
|
+
*
|
|
43243
43782
|
* @example
|
|
43244
43783
|
* ```ts
|
|
43245
|
-
*
|
|
43784
|
+
* // In your initialization file (e.g., utils/topiaInit.ts)
|
|
43785
|
+
* import { Topia, DroppedAssetFactory } from "@rtsdk/topia";
|
|
43786
|
+
* const topia = new Topia({ config });
|
|
43787
|
+
* export const DroppedAsset = new DroppedAssetFactory(topia);
|
|
43246
43788
|
* ```
|
|
43247
43789
|
*/
|
|
43248
43790
|
class DroppedAssetFactory extends SDKController {
|
|
@@ -43250,27 +43792,77 @@ class DroppedAssetFactory extends SDKController {
|
|
|
43250
43792
|
super(topia);
|
|
43251
43793
|
}
|
|
43252
43794
|
/**
|
|
43253
|
-
* Instantiate a new instance of DroppedAsset class.
|
|
43795
|
+
* Instantiate a new instance of DroppedAsset class for an existing dropped asset in a world.
|
|
43796
|
+
*
|
|
43797
|
+
* @remarks
|
|
43798
|
+
* This method creates a controller instance for an existing dropped asset but does not fetch its properties.
|
|
43799
|
+
* Use this when you need a lightweight instance and will fetch properties separately if needed or when you already have the properties.
|
|
43800
|
+
*
|
|
43801
|
+
* @keywords create, instantiate, dropped asset, initialize, instance
|
|
43254
43802
|
*
|
|
43255
43803
|
* @example
|
|
43256
|
-
* ```
|
|
43257
|
-
*
|
|
43804
|
+
* ```ts
|
|
43805
|
+
* // Import the pre-initialized factory from your app's initialization file
|
|
43806
|
+
* import { DroppedAsset } from "utils/topiaInit.ts";
|
|
43807
|
+
*
|
|
43808
|
+
* // Create a DroppedAsset instance with credentials
|
|
43809
|
+
* const droppedAssetInstance = DroppedAsset.create(
|
|
43810
|
+
* assetId,
|
|
43811
|
+
* urlSlug,
|
|
43812
|
+
* {
|
|
43813
|
+
* credentials: {
|
|
43814
|
+
* interactiveNonce,
|
|
43815
|
+
* interactivePublicKey,
|
|
43816
|
+
* assetId,
|
|
43817
|
+
* urlSlug,
|
|
43818
|
+
* visitorId
|
|
43819
|
+
* }
|
|
43820
|
+
* }
|
|
43821
|
+
* );
|
|
43822
|
+
*
|
|
43823
|
+
* // Later fetch its properties if needed
|
|
43824
|
+
* await droppedAssetInstance.fetchDroppedAssetById();
|
|
43258
43825
|
* ```
|
|
43259
43826
|
*
|
|
43260
|
-
* @returns {DroppedAsset} Returns a new DroppedAsset object.
|
|
43827
|
+
* @returns {DroppedAsset} Returns a new DroppedAsset object without fetching its properties.
|
|
43261
43828
|
*/
|
|
43262
43829
|
create(id, urlSlug, options) {
|
|
43263
43830
|
return new DroppedAsset(this.topia, id, urlSlug, options);
|
|
43264
43831
|
}
|
|
43265
43832
|
/**
|
|
43266
|
-
* Instantiate a new instance of DroppedAsset class and
|
|
43833
|
+
* Instantiate a new instance of DroppedAsset class and automatically fetch all its properties.
|
|
43834
|
+
*
|
|
43835
|
+
* @remarks
|
|
43836
|
+
* This method creates a controller instance and immediately fetches all properties of the dropped asset.
|
|
43837
|
+
* It's a convenience method that combines creating an instance and calling fetchDroppedAssetById().
|
|
43838
|
+
*
|
|
43839
|
+
* @keywords get, fetch, retrieve, dropped asset, load, instance
|
|
43267
43840
|
*
|
|
43268
43841
|
* @example
|
|
43269
|
-
* ```
|
|
43270
|
-
*
|
|
43842
|
+
* ```ts
|
|
43843
|
+
* // Import the pre-initialized factory from your app's initialization file
|
|
43844
|
+
* import { DroppedAsset } from "utils/topiaInit.ts";
|
|
43845
|
+
*
|
|
43846
|
+
* // Get a fully populated DroppedAsset instance
|
|
43847
|
+
* const droppedAssetInstance = await DroppedAsset.get(
|
|
43848
|
+
* assetId,
|
|
43849
|
+
* urlSlug,
|
|
43850
|
+
* {
|
|
43851
|
+
* credentials: {
|
|
43852
|
+
* interactiveNonce,
|
|
43853
|
+
* interactivePublicKey,
|
|
43854
|
+
* assetId,
|
|
43855
|
+
* urlSlug,
|
|
43856
|
+
* visitorId
|
|
43857
|
+
* }
|
|
43858
|
+
* }
|
|
43859
|
+
* );
|
|
43860
|
+
*
|
|
43861
|
+
* // The properties are already loaded, so you can use them immediately
|
|
43862
|
+
* console.log(droppedAssetInstance.position);
|
|
43271
43863
|
* ```
|
|
43272
43864
|
*
|
|
43273
|
-
* @returns {Promise<DroppedAsset>} Returns a new DroppedAsset object with all properties.
|
|
43865
|
+
* @returns {Promise<DroppedAsset>} Returns a new DroppedAsset object with all properties already fetched.
|
|
43274
43866
|
*/
|
|
43275
43867
|
get(id, urlSlug, options) {
|
|
43276
43868
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43280,17 +43872,36 @@ class DroppedAssetFactory extends SDKController {
|
|
|
43280
43872
|
});
|
|
43281
43873
|
}
|
|
43282
43874
|
/**
|
|
43283
|
-
* Searches
|
|
43875
|
+
* Searches for and retrieves a dropped asset by its unique name within a world.
|
|
43284
43876
|
*
|
|
43285
43877
|
* @remarks
|
|
43286
|
-
* This method leverages the handleGetDroppedAssetByUniqueName endpoint in the Public API and assumes there is exactly one dropped asset with matching uniqueName for the given urlSlug.
|
|
43878
|
+
* 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.
|
|
43879
|
+
* Use this when you need to find a dropped asset by its uniqueName rather than its id.
|
|
43880
|
+
*
|
|
43881
|
+
* @keywords find, search, unique name, retrieve, locate, lookup, dropped asset
|
|
43287
43882
|
*
|
|
43288
43883
|
* @example
|
|
43289
|
-
* ```
|
|
43290
|
-
*
|
|
43884
|
+
* ```ts
|
|
43885
|
+
* // Import the pre-initialized factory from your app's initialization file
|
|
43886
|
+
* import { DroppedAsset } from "utils/topiaInit.ts";
|
|
43887
|
+
*
|
|
43888
|
+
* // Find and retrieve a dropped asset by its unique name
|
|
43889
|
+
* const droppedAssetInstance = await DroppedAsset.getWithUniqueName(
|
|
43890
|
+
* "banner-sign-northeast",
|
|
43891
|
+
* "my-world-slug",
|
|
43892
|
+
* "your-interactive-secret",
|
|
43893
|
+
* {
|
|
43894
|
+
* apiKey: "your-api-key",
|
|
43895
|
+
* interactivePublicKey: "your-public-key",
|
|
43896
|
+
* // other credentials...
|
|
43897
|
+
* }
|
|
43898
|
+
* );
|
|
43899
|
+
*
|
|
43900
|
+
* // The properties are already loaded, so you can use them immediately
|
|
43901
|
+
* console.log(droppedAssetInstance.position);
|
|
43291
43902
|
* ```
|
|
43292
43903
|
*
|
|
43293
|
-
* @returns {Promise<DroppedAsset>} Returns a new DroppedAsset object with all properties.
|
|
43904
|
+
* @returns {Promise<DroppedAsset>} Returns a new DroppedAsset object with all properties already fetched.
|
|
43294
43905
|
*/
|
|
43295
43906
|
getWithUniqueName(uniqueName, urlSlug, interactiveSecret, credentials) {
|
|
43296
43907
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43317,23 +43928,59 @@ class DroppedAssetFactory extends SDKController {
|
|
|
43317
43928
|
/**
|
|
43318
43929
|
* Drops an asset in a world and returns a new instance of DroppedAsset class with all properties.
|
|
43319
43930
|
*
|
|
43931
|
+
* @remarks
|
|
43932
|
+
* This method places an existing Asset into a world at specified coordinates, effectively "dropping" it into the environment.
|
|
43933
|
+
* You can customize various properties of the dropped asset during placement, such as scale, position, interactive settings, and visual layers.
|
|
43934
|
+
*
|
|
43935
|
+
* @keywords drop, place, add, create, position, asset, deploy
|
|
43936
|
+
*
|
|
43320
43937
|
* @example
|
|
43321
|
-
* ```
|
|
43322
|
-
*
|
|
43323
|
-
*
|
|
43324
|
-
|
|
43325
|
-
|
|
43326
|
-
|
|
43327
|
-
|
|
43328
|
-
|
|
43329
|
-
|
|
43330
|
-
|
|
43331
|
-
|
|
43332
|
-
|
|
43333
|
-
|
|
43938
|
+
* ```ts
|
|
43939
|
+
* // Import the pre-initialized factories from your app's initialization file
|
|
43940
|
+
* import { Asset, DroppedAsset } from "utils/topiaInit.ts";
|
|
43941
|
+
*
|
|
43942
|
+
* // First get an asset instance
|
|
43943
|
+
* const assetInstance = Asset.create("asset-id-123", {
|
|
43944
|
+
* credentials: {
|
|
43945
|
+
* interactiveNonce,
|
|
43946
|
+
* interactivePublicKey,
|
|
43947
|
+
* assetId,
|
|
43948
|
+
* urlSlug,
|
|
43949
|
+
* visitorId
|
|
43950
|
+
* }
|
|
43951
|
+
* });
|
|
43952
|
+
*
|
|
43953
|
+
* // Then drop (place) the asset in a world
|
|
43954
|
+
* const droppedAssetInstance = await DroppedAsset.drop(
|
|
43955
|
+
* assetInstance,
|
|
43956
|
+
* {
|
|
43957
|
+
* // Basic positioning and appearance
|
|
43958
|
+
* position: { x: 250, y: 350 },
|
|
43959
|
+
* assetScale: 1.5,
|
|
43960
|
+
* flipped: true,
|
|
43961
|
+
* uniqueName: "welcome-sign",
|
|
43962
|
+
* urlSlug: "my-world-slug",
|
|
43963
|
+
*
|
|
43964
|
+
* // For web images (optional)
|
|
43965
|
+
* layer0: "https://example.com/background.png",
|
|
43966
|
+
* layer1: "https://example.com/foreground.png",
|
|
43967
|
+
*
|
|
43968
|
+
* // For interactive assets (optional)
|
|
43969
|
+
* interactivePublicKey: "your-public-key",
|
|
43970
|
+
* isInteractive: true,
|
|
43971
|
+
*
|
|
43972
|
+
* // For clickable assets (optional)
|
|
43973
|
+
* clickType: "link",
|
|
43974
|
+
* clickableLink: "https://example.com",
|
|
43975
|
+
* clickableLinkTitle: "Visit Example"
|
|
43976
|
+
* }
|
|
43977
|
+
* );
|
|
43978
|
+
*
|
|
43979
|
+
* // The dropped asset is ready to use
|
|
43980
|
+
* console.log(droppedAssetInstance.id);
|
|
43334
43981
|
* ```
|
|
43335
43982
|
*
|
|
43336
|
-
* @returns {Promise<DroppedAsset>} Returns a new DroppedAsset object
|
|
43983
|
+
* @returns {Promise<DroppedAsset>} Returns a new DroppedAsset object representing the placed asset in the world.
|
|
43337
43984
|
*/
|
|
43338
43985
|
drop(asset, { assetScale = 1, clickType, clickableDisplayTextDescription, clickableDisplayTextHeadline, clickableLink, clickableLinkTitle, flipped, interactivePublicKey, isInteractive, isForceLinkInIframe, isOpenLinkInDrawer, isTextTopLayer = false, layer0, layer1, position: { x, y }, sceneDropId, text, textColor, textFontFamily, textSize, textWeight, textWidth, uniqueName, urlSlug, yOrderAdjust, }) {
|
|
43339
43986
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43418,9 +44065,20 @@ class DroppedAssetFactory extends SDKController {
|
|
|
43418
44065
|
Do NOT instantiate factories in controllers. Do NOT invent methods.
|
|
43419
44066
|
============================================================================ */
|
|
43420
44067
|
/**
|
|
44068
|
+
* Factory for creating Ecosystem instances. Use this factory to work with ecosystem-wide data and operations.
|
|
44069
|
+
*
|
|
44070
|
+
* @remarks
|
|
44071
|
+
* This factory should be instantiated once per application and reused across your codebase.
|
|
44072
|
+
* The Ecosystem controller provides methods to interact with data shared across multiple worlds.
|
|
44073
|
+
*
|
|
44074
|
+
* @keywords ecosystem, factory, create, multi-world, global, shared data, platform
|
|
44075
|
+
*
|
|
43421
44076
|
* @example
|
|
43422
44077
|
* ```ts
|
|
43423
|
-
*
|
|
44078
|
+
* // In your initialization file (e.g., utils/topiaInit.ts)
|
|
44079
|
+
* import { Topia, EcosystemFactory } from "@rtsdk/topia";
|
|
44080
|
+
* const topia = new Topia({ config });
|
|
44081
|
+
* export const Ecosystem = new EcosystemFactory(topia);
|
|
43424
44082
|
* ```
|
|
43425
44083
|
*/
|
|
43426
44084
|
class EcosystemFactory {
|
|
@@ -43428,14 +44086,36 @@ class EcosystemFactory {
|
|
|
43428
44086
|
this.topia = topia;
|
|
43429
44087
|
}
|
|
43430
44088
|
/**
|
|
43431
|
-
* Instantiate a new instance of Ecosystem class.
|
|
44089
|
+
* Instantiate a new instance of Ecosystem class for interacting with ecosystem-wide data.
|
|
44090
|
+
*
|
|
44091
|
+
* @remarks
|
|
44092
|
+
* This method creates a controller instance for accessing and managing data that spans multiple worlds.
|
|
44093
|
+
* Use this for cross-world data sharing, global data objects, and ecosystem-wide operations.
|
|
44094
|
+
*
|
|
44095
|
+
* @keywords create, instantiate, ecosystem, initialize, global, shared data, platform
|
|
43432
44096
|
*
|
|
43433
44097
|
* @example
|
|
43434
|
-
* ```
|
|
43435
|
-
*
|
|
44098
|
+
* ```ts
|
|
44099
|
+
* // Import the pre-initialized factory from your app's initialization file
|
|
44100
|
+
* import { Ecosystem } from "utils/topiaInit.ts";
|
|
44101
|
+
*
|
|
44102
|
+
* // Create an Ecosystem instance with credentials
|
|
44103
|
+
* const ecosystemInstance = Ecosystem.create({
|
|
44104
|
+
* credentials: {
|
|
44105
|
+
* interactiveNonce,
|
|
44106
|
+
* interactivePublicKey,
|
|
44107
|
+
* assetId,
|
|
44108
|
+
* urlSlug,
|
|
44109
|
+
* visitorId
|
|
44110
|
+
* }
|
|
44111
|
+
* });
|
|
44112
|
+
*
|
|
44113
|
+
* // Work with ecosystem-wide data objects
|
|
44114
|
+
* await ecosystemInstance.fetchDataObject("global-leaderboard");
|
|
44115
|
+
* await ecosystemInstance.setDataObject("global-leaderboard", { scores: [...] });
|
|
43436
44116
|
* ```
|
|
43437
44117
|
*
|
|
43438
|
-
* @returns {Ecosystem} Returns a new Ecosystem object.
|
|
44118
|
+
* @returns {Ecosystem} Returns a new Ecosystem object for interacting with ecosystem-wide data.
|
|
43439
44119
|
*/
|
|
43440
44120
|
create(options) {
|
|
43441
44121
|
return new Ecosystem(this.topia, options);
|
|
@@ -43472,9 +44152,20 @@ class EcosystemFactory {
|
|
|
43472
44152
|
Do NOT instantiate factories in controllers. Do NOT invent methods.
|
|
43473
44153
|
============================================================================ */
|
|
43474
44154
|
/**
|
|
44155
|
+
* Factory for creating Scene instances. Use this factory to work with scenes in the Topia platform.
|
|
44156
|
+
*
|
|
44157
|
+
* @remarks
|
|
44158
|
+
* This factory should be instantiated once per application and reused across your codebase.
|
|
44159
|
+
* Scenes represent the template or blueprint for a world's design and layout.
|
|
44160
|
+
*
|
|
44161
|
+
* @keywords scene, factory, create, template, blueprint, layout, design
|
|
44162
|
+
*
|
|
43475
44163
|
* @example
|
|
43476
44164
|
* ```ts
|
|
43477
|
-
*
|
|
44165
|
+
* // In your initialization file (e.g., utils/topiaInit.ts)
|
|
44166
|
+
* import { Topia, SceneFactory } from "@rtsdk/topia";
|
|
44167
|
+
* const topia = new Topia({ config });
|
|
44168
|
+
* export const Scene = new SceneFactory(topia);
|
|
43478
44169
|
* ```
|
|
43479
44170
|
*/
|
|
43480
44171
|
class SceneFactory {
|
|
@@ -43483,14 +44174,38 @@ class SceneFactory {
|
|
|
43483
44174
|
this.create;
|
|
43484
44175
|
}
|
|
43485
44176
|
/**
|
|
43486
|
-
* Instantiate a new instance of Scene class.
|
|
44177
|
+
* Instantiate a new instance of Scene class for an existing scene in the platform.
|
|
44178
|
+
*
|
|
44179
|
+
* @remarks
|
|
44180
|
+
* This method creates a controller instance for working with a scene but does not fetch its properties.
|
|
44181
|
+
* Use this when you need to interact with a specific scene by its id.
|
|
44182
|
+
*
|
|
44183
|
+
* @keywords create, instantiate, scene, initialize, instance, template
|
|
43487
44184
|
*
|
|
43488
44185
|
* @example
|
|
43489
|
-
* ```
|
|
43490
|
-
*
|
|
44186
|
+
* ```ts
|
|
44187
|
+
* // Import the pre-initialized factory from your app's initialization file
|
|
44188
|
+
* import { Scene } from "utils/topiaInit.ts";
|
|
44189
|
+
*
|
|
44190
|
+
* // Create a Scene instance with credentials
|
|
44191
|
+
* const sceneInstance = Scene.create(
|
|
44192
|
+
* "scene-id-123",
|
|
44193
|
+
* {
|
|
44194
|
+
* credentials: {
|
|
44195
|
+
* interactiveNonce,
|
|
44196
|
+
* interactivePublicKey,
|
|
44197
|
+
* assetId,
|
|
44198
|
+
* urlSlug,
|
|
44199
|
+
* visitorId
|
|
44200
|
+
* }
|
|
44201
|
+
* }
|
|
44202
|
+
* );
|
|
44203
|
+
*
|
|
44204
|
+
* // Fetch scene details if needed
|
|
44205
|
+
* await sceneInstance.fetchSceneById();
|
|
43491
44206
|
* ```
|
|
43492
44207
|
*
|
|
43493
|
-
* @returns {Scene} Returns a new Scene object.
|
|
44208
|
+
* @returns {Scene} Returns a new Scene object for interacting with the specified scene.
|
|
43494
44209
|
*/
|
|
43495
44210
|
create(id, options) {
|
|
43496
44211
|
return new Scene(this.topia, id, options);
|
|
@@ -43545,9 +44260,20 @@ class SceneFactory {
|
|
|
43545
44260
|
Do NOT instantiate factories in controllers. Do NOT invent methods.
|
|
43546
44261
|
============================================================================ */
|
|
43547
44262
|
/**
|
|
44263
|
+
* Factory for creating User instances. Use this factory to work with user data in the Topia platform.
|
|
44264
|
+
*
|
|
44265
|
+
* @remarks
|
|
44266
|
+
* This factory should be instantiated once per application and reused across your codebase.
|
|
44267
|
+
* The User controller allows you to interact with user-specific information and operations.
|
|
44268
|
+
*
|
|
44269
|
+
* @keywords user, factory, create, account, profile, member, visitor
|
|
44270
|
+
*
|
|
43548
44271
|
* @example
|
|
43549
44272
|
* ```ts
|
|
43550
|
-
*
|
|
44273
|
+
* // In your initialization file (e.g., utils/topiaInit.ts)
|
|
44274
|
+
* import { Topia, UserFactory } from "@rtsdk/topia";
|
|
44275
|
+
* const topia = new Topia({ config });
|
|
44276
|
+
* export const User = new UserFactory(topia);
|
|
43551
44277
|
* ```
|
|
43552
44278
|
*/
|
|
43553
44279
|
class UserFactory {
|
|
@@ -43555,14 +44281,36 @@ class UserFactory {
|
|
|
43555
44281
|
this.topia = topia;
|
|
43556
44282
|
}
|
|
43557
44283
|
/**
|
|
43558
|
-
* Instantiate a new instance of User class.
|
|
44284
|
+
* Instantiate a new instance of User class for working with user data.
|
|
44285
|
+
*
|
|
44286
|
+
* @remarks
|
|
44287
|
+
* This method creates a controller instance for interacting with user-specific operations.
|
|
44288
|
+
* The User controller doesn't require an id since it represents the currently authenticated user.
|
|
44289
|
+
*
|
|
44290
|
+
* @keywords create, instantiate, user, initialize, account, profile, member
|
|
43559
44291
|
*
|
|
43560
44292
|
* @example
|
|
43561
|
-
* ```
|
|
43562
|
-
*
|
|
44293
|
+
* ```ts
|
|
44294
|
+
* // Import the pre-initialized factory from your app's initialization file
|
|
44295
|
+
* import { User } from "utils/topiaInit.ts";
|
|
44296
|
+
*
|
|
44297
|
+
* // Create a User instance with credentials
|
|
44298
|
+
* const userInstance = User.create({
|
|
44299
|
+
* credentials: {
|
|
44300
|
+
* interactiveNonce,
|
|
44301
|
+
* interactivePublicKey,
|
|
44302
|
+
* assetId,
|
|
44303
|
+
* urlSlug,
|
|
44304
|
+
* visitorId
|
|
44305
|
+
* }
|
|
44306
|
+
* });
|
|
44307
|
+
*
|
|
44308
|
+
* // Use methods on the user instance
|
|
44309
|
+
* await userInstance.checkInteractiveCredentials();
|
|
44310
|
+
* const avatars = await userInstance.fetchAvatars();
|
|
43563
44311
|
* ```
|
|
43564
44312
|
*
|
|
43565
|
-
* @returns {User} Returns a new User object.
|
|
44313
|
+
* @returns {User} Returns a new User object for interacting with user data.
|
|
43566
44314
|
*/
|
|
43567
44315
|
create(options) {
|
|
43568
44316
|
return new User(this.topia, options);
|
|
@@ -43600,9 +44348,20 @@ class UserFactory {
|
|
|
43600
44348
|
Do NOT instantiate factories in controllers. Do NOT invent methods.
|
|
43601
44349
|
============================================================================ */
|
|
43602
44350
|
/**
|
|
44351
|
+
* Factory for creating Visitor instances. Use this factory to work with visitors in Topia worlds.
|
|
44352
|
+
*
|
|
44353
|
+
* @remarks
|
|
44354
|
+
* This factory should be instantiated once per application and reused across your codebase.
|
|
44355
|
+
* The Visitor controller represents a specific visitor/avatar instance in a world.
|
|
44356
|
+
*
|
|
44357
|
+
* @keywords visitor, factory, create, get, avatar, user, participant
|
|
44358
|
+
*
|
|
43603
44359
|
* @example
|
|
43604
44360
|
* ```ts
|
|
43605
|
-
*
|
|
44361
|
+
* // In your initialization file (e.g., utils/topiaInit.ts)
|
|
44362
|
+
* import { Topia, VisitorFactory } from "@rtsdk/topia";
|
|
44363
|
+
* const topia = new Topia({ config });
|
|
44364
|
+
* export const Visitor = new VisitorFactory(topia);
|
|
43606
44365
|
* ```
|
|
43607
44366
|
*/
|
|
43608
44367
|
class VisitorFactory {
|
|
@@ -43610,27 +44369,78 @@ class VisitorFactory {
|
|
|
43610
44369
|
this.topia = topia;
|
|
43611
44370
|
}
|
|
43612
44371
|
/**
|
|
43613
|
-
* Instantiate a new instance of Visitor class.
|
|
44372
|
+
* Instantiate a new instance of Visitor class for an existing visitor in a world.
|
|
44373
|
+
*
|
|
44374
|
+
* @remarks
|
|
44375
|
+
* This method creates a controller instance for a visitor but does not fetch its properties.
|
|
44376
|
+
* Use this when you need a lightweight instance and will fetch properties separately or when you already have the properties.
|
|
44377
|
+
*
|
|
44378
|
+
* @keywords create, instantiate, visitor, initialize, avatar, instance
|
|
43614
44379
|
*
|
|
43615
44380
|
* @example
|
|
43616
|
-
* ```
|
|
43617
|
-
*
|
|
44381
|
+
* ```ts
|
|
44382
|
+
* // Import the pre-initialized factory from your app's initialization file
|
|
44383
|
+
* import { Visitor } from "utils/topiaInit.ts";
|
|
44384
|
+
*
|
|
44385
|
+
* // Create a Visitor instance with credentials
|
|
44386
|
+
* const visitorInstance = Visitor.create(
|
|
44387
|
+
* 12345, // visitor id
|
|
44388
|
+
* "my-world-slug",
|
|
44389
|
+
* {
|
|
44390
|
+
* credentials: {
|
|
44391
|
+
* interactiveNonce,
|
|
44392
|
+
* interactivePublicKey,
|
|
44393
|
+
* assetId,
|
|
44394
|
+
* urlSlug,
|
|
44395
|
+
* visitorId
|
|
44396
|
+
* }
|
|
44397
|
+
* }
|
|
44398
|
+
* );
|
|
44399
|
+
*
|
|
44400
|
+
* // Later fetch visitor properties if needed
|
|
44401
|
+
* await visitorInstance.fetchVisitor();
|
|
43618
44402
|
* ```
|
|
43619
44403
|
*
|
|
43620
|
-
* @returns {Visitor} Returns a new Visitor object.
|
|
44404
|
+
* @returns {Visitor} Returns a new Visitor object without fetching its properties.
|
|
43621
44405
|
*/
|
|
43622
44406
|
create(id, urlSlug, options) {
|
|
43623
44407
|
return new Visitor(this.topia, id, urlSlug, options);
|
|
43624
44408
|
}
|
|
43625
44409
|
/**
|
|
43626
|
-
* Instantiate a new instance of Visitor class and
|
|
44410
|
+
* Instantiate a new instance of Visitor class and automatically fetch all its properties.
|
|
44411
|
+
*
|
|
44412
|
+
* @remarks
|
|
44413
|
+
* This method creates a controller instance and immediately fetches all properties of the visitor.
|
|
44414
|
+
* It's a convenience method that combines creating an instance and calling fetchVisitor().
|
|
44415
|
+
*
|
|
44416
|
+
* @keywords get, fetch, retrieve, visitor, load, avatar, instance
|
|
43627
44417
|
*
|
|
43628
44418
|
* @example
|
|
43629
|
-
* ```
|
|
43630
|
-
*
|
|
44419
|
+
* ```ts
|
|
44420
|
+
* // Import the pre-initialized factory from your app's initialization file
|
|
44421
|
+
* import { Visitor } from "utils/topiaInit.ts";
|
|
44422
|
+
*
|
|
44423
|
+
* // Get a fully populated Visitor instance
|
|
44424
|
+
* const visitorInstance = await Visitor.get(
|
|
44425
|
+
* 12345, // visitor id
|
|
44426
|
+
* "my-world-slug",
|
|
44427
|
+
* {
|
|
44428
|
+
* credentials: {
|
|
44429
|
+
* interactiveNonce,
|
|
44430
|
+
* interactivePublicKey,
|
|
44431
|
+
* assetId,
|
|
44432
|
+
* urlSlug,
|
|
44433
|
+
* visitorId
|
|
44434
|
+
* }
|
|
44435
|
+
* }
|
|
44436
|
+
* );
|
|
44437
|
+
*
|
|
44438
|
+
* // The properties are already loaded, so you can use them immediately
|
|
44439
|
+
* console.log(visitorInstance.username);
|
|
44440
|
+
* console.log(visitorInstance.position);
|
|
43631
44441
|
* ```
|
|
43632
44442
|
*
|
|
43633
|
-
* @returns {Promise<Visitor>} Returns a new Visitor object with all properties.
|
|
44443
|
+
* @returns {Promise<Visitor>} Returns a new Visitor object with all properties already fetched.
|
|
43634
44444
|
*/
|
|
43635
44445
|
get(id, urlSlug, options) {
|
|
43636
44446
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43642,9 +44452,20 @@ class VisitorFactory {
|
|
|
43642
44452
|
}
|
|
43643
44453
|
|
|
43644
44454
|
/**
|
|
44455
|
+
* Factory for creating WebRTCConnector instances. Use this factory to establish WebRTC connections for audio/video in Topia worlds.
|
|
44456
|
+
*
|
|
44457
|
+
* @remarks
|
|
44458
|
+
* This factory should be instantiated once per application and reused across your codebase.
|
|
44459
|
+
* The WebRTCConnector provides methods to set up and manage real-time audio/video communication.
|
|
44460
|
+
*
|
|
44461
|
+
* @keywords webrtc, factory, create, audio, video, communication, real-time, conference
|
|
44462
|
+
*
|
|
43645
44463
|
* @example
|
|
43646
44464
|
* ```ts
|
|
43647
|
-
*
|
|
44465
|
+
* // In your initialization file (e.g., utils/topiaInit.ts)
|
|
44466
|
+
* import { Topia, WebRTCConnectorFactory } from "@rtsdk/topia";
|
|
44467
|
+
* const topia = new Topia({ config });
|
|
44468
|
+
* export const WebRTCConnector = new WebRTCConnectorFactory(topia);
|
|
43648
44469
|
* ```
|
|
43649
44470
|
*/
|
|
43650
44471
|
class WebRTCConnectorFactory {
|
|
@@ -43652,14 +44473,41 @@ class WebRTCConnectorFactory {
|
|
|
43652
44473
|
this.topia = topia;
|
|
43653
44474
|
}
|
|
43654
44475
|
/**
|
|
43655
|
-
* Instantiate a new instance of WebRTCConnector class.
|
|
44476
|
+
* Instantiate a new instance of WebRTCConnector class for managing audio/video communication.
|
|
44477
|
+
*
|
|
44478
|
+
* @remarks
|
|
44479
|
+
* This method creates a controller instance for establishing and managing WebRTC connections.
|
|
44480
|
+
* Use this for implementing real-time audio/video communication features in Topia worlds.
|
|
44481
|
+
*
|
|
44482
|
+
* @keywords create, instantiate, webrtc, initialize, audio, video, communication, stream
|
|
43656
44483
|
*
|
|
43657
44484
|
* @example
|
|
43658
|
-
* ```
|
|
43659
|
-
*
|
|
44485
|
+
* ```ts
|
|
44486
|
+
* // Import the pre-initialized factory from your app's initialization file
|
|
44487
|
+
* import { WebRTCConnector } from "utils/topiaInit.ts";
|
|
44488
|
+
*
|
|
44489
|
+
* // Create a WebRTCConnector instance with credentials and configuration
|
|
44490
|
+
* const webRTCInstance = WebRTCConnector.create(
|
|
44491
|
+
* "my-world-slug",
|
|
44492
|
+
* {
|
|
44493
|
+
* credentials: {
|
|
44494
|
+
* interactiveNonce,
|
|
44495
|
+
* interactivePublicKey,
|
|
44496
|
+
* assetId,
|
|
44497
|
+
* urlSlug,
|
|
44498
|
+
* visitorId
|
|
44499
|
+
* },
|
|
44500
|
+
* twilioConfig: {
|
|
44501
|
+
* // Twilio configuration options
|
|
44502
|
+
* }
|
|
44503
|
+
* }
|
|
44504
|
+
* );
|
|
44505
|
+
*
|
|
44506
|
+
* // Use the instance to establish connections
|
|
44507
|
+
* await webRTCInstance.connect();
|
|
43660
44508
|
* ```
|
|
43661
44509
|
*
|
|
43662
|
-
* @returns {WebRTCConnector} Returns a new WebRTCConnector object.
|
|
44510
|
+
* @returns {WebRTCConnector} Returns a new WebRTCConnector object for managing audio/video communication.
|
|
43663
44511
|
*/
|
|
43664
44512
|
create(urlSlug, options) {
|
|
43665
44513
|
return new WebRTCConnector(this.topia, urlSlug, options);
|
|
@@ -43697,9 +44545,20 @@ class WebRTCConnectorFactory {
|
|
|
43697
44545
|
Do NOT instantiate factories in controllers. Do NOT invent methods.
|
|
43698
44546
|
============================================================================ */
|
|
43699
44547
|
/**
|
|
44548
|
+
* Factory for creating WorldActivity instances. Use this factory to monitor and manage visitor activity in Topia worlds.
|
|
44549
|
+
*
|
|
44550
|
+
* @remarks
|
|
44551
|
+
* This factory should be instantiated once per application and reused across your codebase.
|
|
44552
|
+
* The WorldActivity controller provides methods to interact with real-time visitor activities and movements.
|
|
44553
|
+
*
|
|
44554
|
+
* @keywords world activity, factory, create, visitors, movement, tracking, presence, real-time
|
|
44555
|
+
*
|
|
43700
44556
|
* @example
|
|
43701
44557
|
* ```ts
|
|
43702
|
-
*
|
|
44558
|
+
* // In your initialization file (e.g., utils/topiaInit.ts)
|
|
44559
|
+
* import { Topia, WorldActivityFactory } from "@rtsdk/topia";
|
|
44560
|
+
* const topia = new Topia({ config });
|
|
44561
|
+
* export const WorldActivity = new WorldActivityFactory(topia);
|
|
43703
44562
|
* ```
|
|
43704
44563
|
*/
|
|
43705
44564
|
class WorldActivityFactory {
|
|
@@ -43707,14 +44566,42 @@ class WorldActivityFactory {
|
|
|
43707
44566
|
this.topia = topia;
|
|
43708
44567
|
}
|
|
43709
44568
|
/**
|
|
43710
|
-
* Instantiate a new instance of WorldActivity class.
|
|
44569
|
+
* Instantiate a new instance of WorldActivity class for monitoring visitor activity in a specific world.
|
|
44570
|
+
*
|
|
44571
|
+
* @remarks
|
|
44572
|
+
* This method creates a controller instance for tracking and managing visitor activity in a world.
|
|
44573
|
+
* Use this to fetch current visitors, move visitors, or monitor specific zones within a world.
|
|
44574
|
+
*
|
|
44575
|
+
* @keywords create, instantiate, world activity, initialize, visitors, tracking, presence
|
|
43711
44576
|
*
|
|
43712
44577
|
* @example
|
|
43713
|
-
* ```
|
|
43714
|
-
*
|
|
44578
|
+
* ```ts
|
|
44579
|
+
* // Import the pre-initialized factory from your app's initialization file
|
|
44580
|
+
* import { WorldActivity } from "utils/topiaInit.ts";
|
|
44581
|
+
*
|
|
44582
|
+
* // Create a WorldActivity instance with credentials
|
|
44583
|
+
* const worldActivityInstance = WorldActivity.create(
|
|
44584
|
+
* "my-world-slug",
|
|
44585
|
+
* {
|
|
44586
|
+
* credentials: {
|
|
44587
|
+
* interactiveNonce,
|
|
44588
|
+
* interactivePublicKey,
|
|
44589
|
+
* assetId,
|
|
44590
|
+
* urlSlug,
|
|
44591
|
+
* visitorId
|
|
44592
|
+
* }
|
|
44593
|
+
* }
|
|
44594
|
+
* );
|
|
44595
|
+
*
|
|
44596
|
+
* // Get current visitors in the world
|
|
44597
|
+
* const visitors = await worldActivityInstance.currentVisitors();
|
|
44598
|
+
* console.log(`There are ${visitors.length} visitors in the world`);
|
|
44599
|
+
*
|
|
44600
|
+
* // Check visitors in a specific zone
|
|
44601
|
+
* const zoneVisitors = await worldActivityInstance.fetchVisitorsInZone("stage-area");
|
|
43715
44602
|
* ```
|
|
43716
44603
|
*
|
|
43717
|
-
* @returns {WorldActivity} Returns a new WorldActivity object.
|
|
44604
|
+
* @returns {WorldActivity} Returns a new WorldActivity object for tracking and managing visitor activity.
|
|
43718
44605
|
*/
|
|
43719
44606
|
create(urlSlug, options) {
|
|
43720
44607
|
return new WorldActivity(this.topia, urlSlug, options);
|
|
@@ -43752,9 +44639,20 @@ class WorldActivityFactory {
|
|
|
43752
44639
|
Do NOT instantiate factories in controllers. Do NOT invent methods.
|
|
43753
44640
|
============================================================================ */
|
|
43754
44641
|
/**
|
|
44642
|
+
* Factory for creating World instances. Use this factory to interact with Topia worlds.
|
|
44643
|
+
*
|
|
44644
|
+
* @remarks
|
|
44645
|
+
* This factory should be instantiated once per application and reused across your codebase.
|
|
44646
|
+
* The World controller provides methods to manage world settings, retrieve world details, and perform world-level operations.
|
|
44647
|
+
*
|
|
44648
|
+
* @keywords world, factory, create, virtual space, environment, room, topia
|
|
44649
|
+
*
|
|
43755
44650
|
* @example
|
|
43756
44651
|
* ```ts
|
|
43757
|
-
*
|
|
44652
|
+
* // In your initialization file (e.g., utils/topiaInit.ts)
|
|
44653
|
+
* import { Topia, WorldFactory } from "@rtsdk/topia";
|
|
44654
|
+
* const topia = new Topia({ config });
|
|
44655
|
+
* export const World = new WorldFactory(topia);
|
|
43758
44656
|
* ```
|
|
43759
44657
|
*/
|
|
43760
44658
|
class WorldFactory extends SDKController {
|
|
@@ -43762,27 +44660,75 @@ class WorldFactory extends SDKController {
|
|
|
43762
44660
|
super(topia);
|
|
43763
44661
|
}
|
|
43764
44662
|
/**
|
|
43765
|
-
* Instantiate a new instance of World class.
|
|
44663
|
+
* Instantiate a new instance of World class for interacting with a specific Topia world.
|
|
44664
|
+
*
|
|
44665
|
+
* @remarks
|
|
44666
|
+
* This method creates a controller instance for a world identified by its URL slug.
|
|
44667
|
+
* The world controller can be used to fetch details, update world settings, and perform other world-level operations.
|
|
44668
|
+
*
|
|
44669
|
+
* @keywords create, instantiate, world, initialize, virtual space, environment, room
|
|
43766
44670
|
*
|
|
43767
44671
|
* @example
|
|
43768
|
-
* ```
|
|
43769
|
-
*
|
|
44672
|
+
* ```ts
|
|
44673
|
+
* // Import the pre-initialized factory from your app's initialization file
|
|
44674
|
+
* import { World } from "utils/topiaInit.ts";
|
|
44675
|
+
*
|
|
44676
|
+
* // Create a World instance with credentials
|
|
44677
|
+
* const worldInstance = World.create(
|
|
44678
|
+
* "my-world-slug",
|
|
44679
|
+
* {
|
|
44680
|
+
* credentials: {
|
|
44681
|
+
* interactiveNonce,
|
|
44682
|
+
* interactivePublicKey,
|
|
44683
|
+
* assetId,
|
|
44684
|
+
* urlSlug,
|
|
44685
|
+
* visitorId
|
|
44686
|
+
* }
|
|
44687
|
+
* }
|
|
44688
|
+
* );
|
|
44689
|
+
*
|
|
44690
|
+
* // Fetch world details
|
|
44691
|
+
* await worldInstance.fetchDetails();
|
|
44692
|
+
* console.log(worldInstance.name);
|
|
43770
44693
|
* ```
|
|
43771
44694
|
*
|
|
43772
|
-
* @returns {World} Returns a new World object.
|
|
44695
|
+
* @returns {World} Returns a new World object for interacting with the specified world.
|
|
43773
44696
|
*/
|
|
43774
44697
|
create(urlSlug, options) {
|
|
43775
44698
|
return new World(this.topia, urlSlug, options);
|
|
43776
44699
|
}
|
|
43777
44700
|
/**
|
|
43778
|
-
* Deletes
|
|
44701
|
+
* Deletes multiple dropped assets from a world in a single operation.
|
|
44702
|
+
*
|
|
44703
|
+
* @remarks
|
|
44704
|
+
* This method provides a convenient way to delete multiple dropped assets at once rather than
|
|
44705
|
+
* deleting them one by one. Requires appropriate permissions via interactive credentials.
|
|
44706
|
+
*
|
|
44707
|
+
* @keywords delete, remove, dropped assets, multiple, batch, cleanup, world
|
|
43779
44708
|
*
|
|
43780
44709
|
* @example
|
|
43781
|
-
* ```
|
|
43782
|
-
*
|
|
44710
|
+
* ```ts
|
|
44711
|
+
* // Import the pre-initialized factory from your app's initialization file
|
|
44712
|
+
* import { World } from "utils/topiaInit.ts";
|
|
44713
|
+
*
|
|
44714
|
+
* // Delete multiple dropped assets from a world
|
|
44715
|
+
* const result = await World.deleteDroppedAssets(
|
|
44716
|
+
* "my-world-slug",
|
|
44717
|
+
* ["asset-id-123", "asset-id-456", "asset-id-789"],
|
|
44718
|
+
* "your-interactive-secret",
|
|
44719
|
+
* {
|
|
44720
|
+
* apiKey: "your-api-key",
|
|
44721
|
+
* interactivePublicKey: "your-public-key",
|
|
44722
|
+
* visitorId: 12345
|
|
44723
|
+
* }
|
|
44724
|
+
* );
|
|
44725
|
+
*
|
|
44726
|
+
* if (result.success) {
|
|
44727
|
+
* console.log("Assets successfully deleted");
|
|
44728
|
+
* }
|
|
43783
44729
|
* ```
|
|
43784
44730
|
*
|
|
43785
|
-
* @returns {Promise<{ success: boolean }>} Returns `{ success: true }`
|
|
44731
|
+
* @returns {Promise<{ success: boolean }>} Returns `{ success: true }` if all assets were deleted successfully.
|
|
43786
44732
|
*/
|
|
43787
44733
|
deleteDroppedAssets(urlSlug, droppedAssetIds, interactiveSecret, credentials) {
|
|
43788
44734
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43813,6 +44759,57 @@ class WorldFactory extends SDKController {
|
|
|
43813
44759
|
}
|
|
43814
44760
|
}
|
|
43815
44761
|
|
|
44762
|
+
// import { UserInventoryItem } from "controllers";
|
|
44763
|
+
/**
|
|
44764
|
+
* Factory for creating UserInventoryItem instances. Use this factory to work with user-owned inventory items.
|
|
44765
|
+
*
|
|
44766
|
+
* @remarks
|
|
44767
|
+
* This factory should be instantiated once per application and reused across your codebase.
|
|
44768
|
+
*
|
|
44769
|
+
* @example
|
|
44770
|
+
* ```ts
|
|
44771
|
+
* // In your initialization file (e.g., utils/topiaInit.ts)
|
|
44772
|
+
* import { Topia, UserInventoryItemFactory } from "@rtsdk/topia";
|
|
44773
|
+
* const topia = new Topia({ config });
|
|
44774
|
+
* export const UserInventoryItem = new UserInventoryItemFactory(topia);
|
|
44775
|
+
* ```
|
|
44776
|
+
*/
|
|
44777
|
+
class UserInventoryItemFactory {
|
|
44778
|
+
constructor(topia) {
|
|
44779
|
+
this.topia = topia;
|
|
44780
|
+
}
|
|
44781
|
+
/**
|
|
44782
|
+
* Instantiate a new instance of UserInventoryItem class for a user's owned item.
|
|
44783
|
+
*
|
|
44784
|
+
* @example
|
|
44785
|
+
* ```ts
|
|
44786
|
+
* const userItem = UserInventoryItem.create("item-id-123", 42, 5, { credentials });
|
|
44787
|
+
* ```
|
|
44788
|
+
*
|
|
44789
|
+
* @returns {UserInventoryItem} Returns a new UserInventoryItem object for interacting with the specified item.
|
|
44790
|
+
*/
|
|
44791
|
+
create(inventoryItemId, userId, quantity, options) {
|
|
44792
|
+
return new UserInventoryItem(this.topia, inventoryItemId, options);
|
|
44793
|
+
}
|
|
44794
|
+
/**
|
|
44795
|
+
* Retrieve a user inventory item and all its properties.
|
|
44796
|
+
*
|
|
44797
|
+
* @example
|
|
44798
|
+
* ```ts
|
|
44799
|
+
* const userItem = await UserInventoryItem.get("item-id-123", 42, { credentials });
|
|
44800
|
+
* ```
|
|
44801
|
+
*
|
|
44802
|
+
* @returns {Promise<UserInventoryItem>} Returns a new UserInventoryItem object with all properties.
|
|
44803
|
+
*/
|
|
44804
|
+
get(inventoryItemId, options) {
|
|
44805
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44806
|
+
const userItem = new UserInventoryItem(this.topia, inventoryItemId, options);
|
|
44807
|
+
yield userItem.fetchUserInventoryItemById();
|
|
44808
|
+
return userItem;
|
|
44809
|
+
});
|
|
44810
|
+
}
|
|
44811
|
+
}
|
|
44812
|
+
|
|
43816
44813
|
Error.stackTraceLimit = 20;
|
|
43817
44814
|
process.on("unhandledRejection", (reason) => {
|
|
43818
44815
|
if (reason && reason.data) {
|