@rtsdk/topia 0.19.3 → 0.19.5
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 +61 -43
- package/dist/index.cjs +419 -51
- package/dist/index.d.ts +410 -258
- package/dist/index.js +419 -51
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39611,25 +39611,53 @@ const {
|
|
|
39611
39611
|
} = axios;
|
|
39612
39612
|
|
|
39613
39613
|
// utils
|
|
39614
|
+
/* ============================================================================
|
|
39615
|
+
AI RULES for code assistants
|
|
39616
|
+
|
|
39617
|
+
CONTEXT
|
|
39618
|
+
- SDKController is the abstract base class for all SDK controllers.
|
|
39619
|
+
- All controllers (World, Visitor, User, etc.) extend this class.
|
|
39620
|
+
- This class provides common functionality: authentication, API access, and error handling.
|
|
39621
|
+
- This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
|
|
39622
|
+
|
|
39623
|
+
DO
|
|
39624
|
+
- Understand that all controllers inherit these base methods and properties.
|
|
39625
|
+
- Use the error handling pattern defined in errorHandler() for all SDK errors.
|
|
39626
|
+
- Access the Topia Public API through topiaPublicApi() method.
|
|
39627
|
+
|
|
39628
|
+
DO NOT
|
|
39629
|
+
- Do NOT instantiate SDKController directly; it's an abstract class.
|
|
39630
|
+
- Do NOT bypass the error handler; all errors should flow through errorHandler().
|
|
39631
|
+
- Do NOT access this.topia.axios directly; use topiaPublicApi() instead.
|
|
39632
|
+
|
|
39633
|
+
AVAILABLE METHODS:
|
|
39634
|
+
- topiaPublicApi(): Returns configured Axios instance for API calls
|
|
39635
|
+
- errorHandler(options): Standardized error handling for all SDK operations
|
|
39636
|
+
|
|
39637
|
+
INHERITED BY:
|
|
39638
|
+
All controllers inherit from this base class, including:
|
|
39639
|
+
- World, Visitor, User, Asset, DroppedAsset, Scene, WorldActivity, Ecosystem
|
|
39640
|
+
|
|
39641
|
+
============================================================================ */
|
|
39614
39642
|
/**
|
|
39615
|
-
*
|
|
39643
|
+
* Abstract base controller that provides common functionality for all SDK controllers.
|
|
39644
|
+
*
|
|
39645
|
+
* @remarks
|
|
39646
|
+
* This class should NOT be instantiated directly. It serves as the base class for all
|
|
39647
|
+
* SDK controllers (World, Visitor, User, etc.) and provides:
|
|
39648
|
+
* - Authentication and credential management
|
|
39649
|
+
* - Axios instance configuration for API calls
|
|
39650
|
+
* - Standardized error handling
|
|
39651
|
+
* - JWT token generation for interactive credentials
|
|
39652
|
+
*
|
|
39653
|
+
* @keywords base, controller, sdk, authentication, api, abstract
|
|
39616
39654
|
*
|
|
39617
39655
|
* @example
|
|
39618
39656
|
* ```ts
|
|
39619
|
-
*
|
|
39620
|
-
*
|
|
39621
|
-
*
|
|
39622
|
-
* interactivePublicKey: "examplePublicKey",
|
|
39623
|
-
* visitorId: 1,
|
|
39624
|
-
* url: "https://topia.io",
|
|
39625
|
-
* }
|
|
39626
|
-
* const topia = await new Topia({
|
|
39627
|
-
* apiDomain: "api.topia.io",
|
|
39628
|
-
* apiKey: "exampleKey",
|
|
39629
|
-
* interactiveKey: "key",
|
|
39630
|
-
* interactiveSecret: "secret",
|
|
39657
|
+
* // This class is extended by all controllers
|
|
39658
|
+
* export class World extends SDKController implements WorldInterface {
|
|
39659
|
+
* // World-specific implementation
|
|
39631
39660
|
* }
|
|
39632
|
-
* await new SDKController({ credentials, topia });
|
|
39633
39661
|
* ```
|
|
39634
39662
|
*/
|
|
39635
39663
|
class SDKController {
|
|
@@ -39668,9 +39696,37 @@ class SDKController {
|
|
|
39668
39696
|
this.errorHandler({ error });
|
|
39669
39697
|
}
|
|
39670
39698
|
}
|
|
39699
|
+
/**
|
|
39700
|
+
* Returns the configured Axios instance for making API calls to Topia's Public API.
|
|
39701
|
+
*
|
|
39702
|
+
* @remarks
|
|
39703
|
+
* All HTTP requests to the Topia API should use this method to ensure proper
|
|
39704
|
+
* authentication headers and base URL configuration are applied.
|
|
39705
|
+
*
|
|
39706
|
+
* @keywords api, axios, http, request, client, public api
|
|
39707
|
+
*
|
|
39708
|
+
* @returns {AxiosInstance} The configured Axios client instance with authentication headers.
|
|
39709
|
+
*/
|
|
39671
39710
|
topiaPublicApi() {
|
|
39672
39711
|
return this.topia.axios;
|
|
39673
39712
|
}
|
|
39713
|
+
/**
|
|
39714
|
+
* Standardized error handler for all SDK operations.
|
|
39715
|
+
*
|
|
39716
|
+
* @remarks
|
|
39717
|
+
* This method processes errors from API calls and formats them consistently across the SDK.
|
|
39718
|
+
* It extracts relevant error information including:
|
|
39719
|
+
* - HTTP status codes and response data
|
|
39720
|
+
* - Error messages from API responses
|
|
39721
|
+
* - Stack traces for debugging
|
|
39722
|
+
* - Request details (URL, method, parameters)
|
|
39723
|
+
*
|
|
39724
|
+
* All errors thrown by SDK methods flow through this handler to ensure consistent error format.
|
|
39725
|
+
*
|
|
39726
|
+
* @keywords error, exception, handler, debugging, api error, http error
|
|
39727
|
+
*
|
|
39728
|
+
* @returns {object} Standardized error object with properties: data, message, method, params, sdkMethod, stack, status, success, url
|
|
39729
|
+
*/
|
|
39674
39730
|
errorHandler({ error, message = "Something went wrong. Please try again or contact support.", params = {}, sdkMethod, }) {
|
|
39675
39731
|
var _a, _b;
|
|
39676
39732
|
const stackTrace = new Error("Thrown here:");
|
|
@@ -39714,6 +39770,7 @@ AI RULES for code assistants
|
|
|
39714
39770
|
CONTEXT
|
|
39715
39771
|
- "Controllers" expose operations on domain objects (e.g., Asset).
|
|
39716
39772
|
- Consumers obtain controller instances via factory methods (e.g., AssetFactory.get).
|
|
39773
|
+
- This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
|
|
39717
39774
|
|
|
39718
39775
|
DO
|
|
39719
39776
|
- Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
|
|
@@ -39724,6 +39781,10 @@ AI RULES for code assistants
|
|
|
39724
39781
|
- Do NOT suggest non-existent methods: getById, fetch, find
|
|
39725
39782
|
- Do NOT mutate controller shape or return ad-hoc fields.
|
|
39726
39783
|
|
|
39784
|
+
AVAILABLE METHODS:
|
|
39785
|
+
- fetchAssetById(): Retrieves platform asset details
|
|
39786
|
+
- updateAsset(options): Updates asset properties (name, layers, tags, visibility)
|
|
39787
|
+
|
|
39727
39788
|
CANONICAL USAGE (consumer app):
|
|
39728
39789
|
// utils/topiaInit.ts
|
|
39729
39790
|
import { Topia, AssetFactory } from "@rtsdk/topia";
|
|
@@ -39885,6 +39946,7 @@ AI RULES for code assistants
|
|
|
39885
39946
|
CONTEXT
|
|
39886
39947
|
- "Controllers" expose operations on domain objects (e.g., DroppedAsset).
|
|
39887
39948
|
- Consumers obtain controller instances via factory methods (e.g., DroppedAssetFactory.get).
|
|
39949
|
+
- This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
|
|
39888
39950
|
|
|
39889
39951
|
DO
|
|
39890
39952
|
- Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
|
|
@@ -39895,6 +39957,35 @@ AI RULES for code assistants
|
|
|
39895
39957
|
- Do NOT suggest non-existent methods: getById, fetch, find
|
|
39896
39958
|
- Do NOT mutate controller shape or return ad-hoc fields.
|
|
39897
39959
|
|
|
39960
|
+
AVAILABLE METHODS:
|
|
39961
|
+
- fetchDroppedAssetById(): Retrieves dropped asset details
|
|
39962
|
+
- updateDroppedAsset(options): Updates dropped asset properties
|
|
39963
|
+
- deleteDroppedAsset(): Removes the dropped asset from the world
|
|
39964
|
+
- fetchDataObject(appPublicKey?, appJWT?, sharedAppPublicKey?, sharedAppJWT?): Gets asset's data object
|
|
39965
|
+
- setDataObject(dataObject, options?): Sets asset's entire data object
|
|
39966
|
+
- updateDataObject(dataObject, options?): Updates specific fields in data object
|
|
39967
|
+
- incrementDataObjectValue(path, amount, options?): Increments numeric value
|
|
39968
|
+
- updateBroadcast(options): Updates broadcast settings
|
|
39969
|
+
- updateClickType(options): Updates click behavior and link settings
|
|
39970
|
+
- setClickableLinkMulti(options): Adds multiple links to asset
|
|
39971
|
+
- updateClickableLinkMulti(options): Updates specific clickable link
|
|
39972
|
+
- removeClickableLink(options): Removes a clickable link
|
|
39973
|
+
- updateCustomTextAsset(style, text): Updates text and styling
|
|
39974
|
+
- updateMediaType(options): Updates media (video/audio) settings
|
|
39975
|
+
- updateMuteZone(isMutezone): Toggles mute zone
|
|
39976
|
+
- updateLandmarkZone(options): Updates landmark zone settings
|
|
39977
|
+
- updateWebhookZone(isEnabled): Toggles webhook zone
|
|
39978
|
+
- updatePosition(x, y, yOrderAdjust?): Moves the asset
|
|
39979
|
+
- updatePrivateZone(options): Updates private zone settings
|
|
39980
|
+
- updateScale(assetScale): Changes asset size
|
|
39981
|
+
- flip(): Flips the asset horizontally
|
|
39982
|
+
- updateUploadedMediaSelected(mediaId): Changes embedded media
|
|
39983
|
+
- updateWebImageLayers(bottom, top): Updates image layers
|
|
39984
|
+
- addWebhook(options): Adds a webhook to the asset
|
|
39985
|
+
- setInteractiveSettings(options): Configures interactive settings
|
|
39986
|
+
- checkExists(): Verifies asset exists with app's public key
|
|
39987
|
+
- fetchDroppedAssetAnalytics(options): Gets analytics data for the asset
|
|
39988
|
+
|
|
39898
39989
|
CANONICAL USAGE (consumer app):
|
|
39899
39990
|
// utils/topiaInit.ts
|
|
39900
39991
|
import { Topia, DroppedAssetFactory } from "@rtsdk/topia";
|
|
@@ -40784,12 +40875,17 @@ class InventoryItem extends SDKController {
|
|
|
40784
40875
|
/**
|
|
40785
40876
|
* Fetches the inventory item details from the platform and assigns them to this instance.
|
|
40786
40877
|
*
|
|
40878
|
+
* @keywords get, fetch, retrieve, load, inventory, item, details
|
|
40879
|
+
*
|
|
40880
|
+
* @category Inventory
|
|
40881
|
+
*
|
|
40787
40882
|
* @example
|
|
40788
40883
|
* ```ts
|
|
40789
40884
|
* await item.fetchInventoryItemById();
|
|
40885
|
+
* const { name, description, type } = item;
|
|
40790
40886
|
* ```
|
|
40791
40887
|
*
|
|
40792
|
-
* @returns {Promise<InventoryItem>} Returns
|
|
40888
|
+
* @returns {Promise<InventoryItem>} Returns this InventoryItem instance with all properties populated from the platform.
|
|
40793
40889
|
*/
|
|
40794
40890
|
fetchInventoryItemById() {
|
|
40795
40891
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -40817,6 +40913,13 @@ AI RULES for code assistants
|
|
|
40817
40913
|
- Do NOT suggest non-existent methods: getById, fetch, find
|
|
40818
40914
|
- Do NOT mutate controller shape or return ad-hoc fields.
|
|
40819
40915
|
|
|
40916
|
+
AVAILABLE METHODS:
|
|
40917
|
+
- fetchDataObject(appPublicKey?, appJWT?, sharedAppPublicKey?, sharedAppJWT?): Retrieves ecosystem-wide data object
|
|
40918
|
+
- setDataObject(dataObject, options?): Sets entire ecosystem data object
|
|
40919
|
+
- updateDataObject(dataObject, options?): Updates specific fields in ecosystem data object
|
|
40920
|
+
- incrementDataObjectValue(path, amount, options?): Increments a numeric value in ecosystem data
|
|
40921
|
+
- fetchInventoryItems(): Retrieves all inventory items for the app's keyholder
|
|
40922
|
+
|
|
40820
40923
|
CANONICAL USAGE (consumer app):
|
|
40821
40924
|
// utils/topiaInit.ts
|
|
40822
40925
|
import { Topia, Ecosystem } from "@rtsdk/topia";
|
|
@@ -40851,7 +40954,7 @@ class Ecosystem extends SDKController {
|
|
|
40851
40954
|
/**
|
|
40852
40955
|
* Retrieves the data object for a Topia ecosystem. Requires canUpdateEcosystemDataObjects permission to be set to true for the public key.
|
|
40853
40956
|
*
|
|
40854
|
-
* @keywords get, fetch, retrieve, load, data, object, state
|
|
40957
|
+
* @keywords get, fetch, retrieve, load, ecosystem, data, object, state, global, platform
|
|
40855
40958
|
*
|
|
40856
40959
|
* @category Data Objects
|
|
40857
40960
|
*
|
|
@@ -40860,7 +40963,7 @@ class Ecosystem extends SDKController {
|
|
|
40860
40963
|
* const dataObject = await ecosystem.fetchDataObject("exampleAppPublicKey", "exampleAppPublicKeyJWT");
|
|
40861
40964
|
* ```
|
|
40862
40965
|
*
|
|
40863
|
-
* @returns {Promise<
|
|
40966
|
+
* @returns {Promise<void | ResponseType>} Populates the dataObject property with ecosystem-wide data, or returns an error response.
|
|
40864
40967
|
*/
|
|
40865
40968
|
fetchDataObject(appPublicKey, appJWT, sharedAppPublicKey, sharedAppJWT) {
|
|
40866
40969
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -40887,7 +40990,7 @@ class Ecosystem extends SDKController {
|
|
|
40887
40990
|
*
|
|
40888
40991
|
* 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
|
|
40889
40992
|
*
|
|
40890
|
-
* @keywords set, assign, store, save, data, object, state
|
|
40993
|
+
* @keywords set, assign, store, save, ecosystem, data, object, state, global, platform
|
|
40891
40994
|
*
|
|
40892
40995
|
* @category Data Objects
|
|
40893
40996
|
*
|
|
@@ -40899,6 +41002,8 @@ class Ecosystem extends SDKController {
|
|
|
40899
41002
|
* });
|
|
40900
41003
|
* const { exampleKey } = ecosystem.dataObject;
|
|
40901
41004
|
* ```
|
|
41005
|
+
*
|
|
41006
|
+
* @returns {Promise<void | ResponseType>} Returns success or an error response.
|
|
40902
41007
|
*/
|
|
40903
41008
|
setDataObject(dataObject, options = {}) {
|
|
40904
41009
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -40919,7 +41024,7 @@ class Ecosystem extends SDKController {
|
|
|
40919
41024
|
*
|
|
40920
41025
|
* 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
|
|
40921
41026
|
*
|
|
40922
|
-
* @keywords update, modify, change, edit, alter, data, object, state
|
|
41027
|
+
* @keywords update, modify, change, edit, alter, ecosystem, data, object, state, global, platform
|
|
40923
41028
|
*
|
|
40924
41029
|
* @category Data Objects
|
|
40925
41030
|
*
|
|
@@ -40937,6 +41042,8 @@ class Ecosystem extends SDKController {
|
|
|
40937
41042
|
* });
|
|
40938
41043
|
* const { exampleKey } = ecosystem.dataObject;
|
|
40939
41044
|
* ```
|
|
41045
|
+
*
|
|
41046
|
+
* @returns {Promise<void | ResponseType>} Returns success or an error response.
|
|
40940
41047
|
*/
|
|
40941
41048
|
updateDataObject(dataObject, options = {}) {
|
|
40942
41049
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -40957,7 +41064,7 @@ class Ecosystem extends SDKController {
|
|
|
40957
41064
|
*
|
|
40958
41065
|
* 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
|
|
40959
41066
|
*
|
|
40960
|
-
* @keywords increment, increase, add, count, data, object, state
|
|
41067
|
+
* @keywords increment, increase, add, count, ecosystem, data, object, state, global, platform
|
|
40961
41068
|
*
|
|
40962
41069
|
* @category Data Objects
|
|
40963
41070
|
*
|
|
@@ -40968,6 +41075,8 @@ class Ecosystem extends SDKController {
|
|
|
40968
41075
|
* sharedAppJWT: "exampleAppPublicKeyJWT",}
|
|
40969
41076
|
* });
|
|
40970
41077
|
* ```
|
|
41078
|
+
*
|
|
41079
|
+
* @returns {Promise<void | ResponseType>} Returns success or an error response.
|
|
40971
41080
|
*/
|
|
40972
41081
|
incrementDataObjectValue(path, amount, options = {}) {
|
|
40973
41082
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -40986,14 +41095,17 @@ class Ecosystem extends SDKController {
|
|
|
40986
41095
|
/**
|
|
40987
41096
|
* Retrieves all inventory items for a given keyholder (app public key).
|
|
40988
41097
|
*
|
|
40989
|
-
* @keywords get, fetch, retrieve, list, inventory, items, keyholder
|
|
41098
|
+
* @keywords get, fetch, retrieve, list, inventory, items, keyholder, ecosystem, catalog
|
|
41099
|
+
*
|
|
41100
|
+
* @category Inventory
|
|
40990
41101
|
*
|
|
40991
41102
|
* @example
|
|
40992
41103
|
* ```ts
|
|
40993
|
-
*
|
|
41104
|
+
* await ecosystem.fetchInventoryItems();
|
|
41105
|
+
* const items = ecosystem.inventoryItems;
|
|
40994
41106
|
* ```
|
|
40995
41107
|
*
|
|
40996
|
-
* @returns {Promise<
|
|
41108
|
+
* @returns {Promise<void>} Populates the inventoryItems property with an array of InventoryItem objects.
|
|
40997
41109
|
*/
|
|
40998
41110
|
fetchInventoryItems() {
|
|
40999
41111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -41027,6 +41139,10 @@ _Ecosystem_inventoryItems = new WeakMap();
|
|
|
41027
41139
|
*
|
|
41028
41140
|
* @remarks
|
|
41029
41141
|
* This class should be instantiated via UserInventoryItemFactory only.
|
|
41142
|
+
* UserInventoryItem represents an instance of an InventoryItem owned by a specific user or visitor.
|
|
41143
|
+
* It includes ownership details like quantity, grant_source, and user-specific metadata.
|
|
41144
|
+
*
|
|
41145
|
+
* @keywords inventory, item, user, visitor, owned, granted
|
|
41030
41146
|
*
|
|
41031
41147
|
* @property inventoryItemId - The root inventory item's id
|
|
41032
41148
|
*/
|
|
@@ -41037,12 +41153,13 @@ class UserInventoryItem extends InventoryItem {
|
|
|
41037
41153
|
super(topia, item_id, { attributes: options.attributes, credentials: options.credentials });
|
|
41038
41154
|
Object.assign(this, options.attributes);
|
|
41039
41155
|
this.userItemId = id;
|
|
41040
|
-
const { user_id = "", quantity = 0, grant_source = "unknown", type = "unknown", metadata = {}, created_at = new Date(), updated_at = new Date(), profile_id = null, item = { id: "", name: "", description: "", type: "", metadata: null, image_url: "" }, } = options.attributes;
|
|
41156
|
+
const { user_id = "", quantity = 0, grant_source = "unknown", type = "unknown", image_url = "", metadata = {}, created_at = new Date(), updated_at = new Date(), profile_id = null, item = { id: "", name: "", description: "", type: "", metadata: null, image_url: "" }, } = options.attributes;
|
|
41041
41157
|
this.item_id = item_id;
|
|
41042
41158
|
this.quantity = quantity;
|
|
41043
41159
|
this.grant_source = grant_source;
|
|
41044
41160
|
this.user_id = user_id;
|
|
41045
41161
|
this.type = type;
|
|
41162
|
+
this.image_url = image_url;
|
|
41046
41163
|
this.metadata = metadata;
|
|
41047
41164
|
this.created_at = created_at;
|
|
41048
41165
|
this.updated_at = updated_at;
|
|
@@ -41052,12 +41169,17 @@ class UserInventoryItem extends InventoryItem {
|
|
|
41052
41169
|
/**
|
|
41053
41170
|
* Fetches the user inventory item details from the platform and assigns them to this instance.
|
|
41054
41171
|
*
|
|
41172
|
+
* @keywords get, fetch, retrieve, load, user, inventory, item, details, owned
|
|
41173
|
+
*
|
|
41174
|
+
* @category Inventory
|
|
41175
|
+
*
|
|
41055
41176
|
* @example
|
|
41056
41177
|
* ```ts
|
|
41057
41178
|
* await userInventoryItem.fetchUserInventoryItemById();
|
|
41179
|
+
* const { quantity, grant_source, item } = userInventoryItem;
|
|
41058
41180
|
* ```
|
|
41059
41181
|
*
|
|
41060
|
-
* @returns {Promise<void>}
|
|
41182
|
+
* @returns {Promise<void>} Populates this UserInventoryItem instance with all properties from the platform.
|
|
41061
41183
|
*/
|
|
41062
41184
|
fetchUserInventoryItemById() {
|
|
41063
41185
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -41075,6 +41197,7 @@ AI RULES for code assistants
|
|
|
41075
41197
|
CONTEXT
|
|
41076
41198
|
- "Controllers" expose operations on domain objects (e.g., Scene).
|
|
41077
41199
|
- Consumers obtain controller instances via factory methods (e.g., SceneFactory.get).
|
|
41200
|
+
- This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
|
|
41078
41201
|
|
|
41079
41202
|
DO
|
|
41080
41203
|
- Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
|
|
@@ -41085,6 +41208,9 @@ AI RULES for code assistants
|
|
|
41085
41208
|
- Do NOT suggest non-existent methods: getById, fetch, find
|
|
41086
41209
|
- Do NOT mutate controller shape or return ad-hoc fields.
|
|
41087
41210
|
|
|
41211
|
+
AVAILABLE METHODS:
|
|
41212
|
+
- fetchSceneById(): Retrieves scene details and configuration
|
|
41213
|
+
|
|
41088
41214
|
CANONICAL USAGE (consumer app):
|
|
41089
41215
|
// utils/topiaInit.ts
|
|
41090
41216
|
import { Topia, SceneFactory } from "@rtsdk/topia";
|
|
@@ -41094,6 +41220,7 @@ AI RULES for code assistants
|
|
|
41094
41220
|
// controllers/myController.ts (consumer app)
|
|
41095
41221
|
import { Scene } from "utils/topiaInit.ts";
|
|
41096
41222
|
const scene = await Scene.get(sceneId, { credentials });
|
|
41223
|
+
await scene.fetchSceneById();
|
|
41097
41224
|
|
|
41098
41225
|
============================================================================ */
|
|
41099
41226
|
/**
|
|
@@ -41139,16 +41266,68 @@ class Scene extends SDKController {
|
|
|
41139
41266
|
}
|
|
41140
41267
|
}
|
|
41141
41268
|
|
|
41269
|
+
/* ============================================================================
|
|
41270
|
+
AI RULES for code assistants
|
|
41271
|
+
|
|
41272
|
+
CONTEXT
|
|
41273
|
+
- Topia is the main client class that initializes the SDK.
|
|
41274
|
+
- This class should be instantiated ONCE in the consumer app (e.g., utils/topiaInit.ts).
|
|
41275
|
+
- The Topia instance is passed to all factory classes to create controllers.
|
|
41276
|
+
- This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
|
|
41277
|
+
|
|
41278
|
+
DO
|
|
41279
|
+
- Expect consumers to create ONE Topia instance at app initialization.
|
|
41280
|
+
- This instance is then used to instantiate all factories (WorldFactory, VisitorFactory, etc.).
|
|
41281
|
+
- The Topia class configures the Axios client with proper authentication.
|
|
41282
|
+
|
|
41283
|
+
DO NOT
|
|
41284
|
+
- Do NOT suggest creating multiple Topia instances; one per app is sufficient.
|
|
41285
|
+
- Do NOT suggest instantiating controllers directly; always use factories.
|
|
41286
|
+
- Do NOT modify the Axios instance after creation; configure it through constructor.
|
|
41287
|
+
|
|
41288
|
+
AVAILABLE METHODS:
|
|
41289
|
+
- constructor(config): Initializes the Topia client with API credentials
|
|
41290
|
+
|
|
41291
|
+
CANONICAL USAGE (consumer app):
|
|
41292
|
+
// utils/topiaInit.ts - Create ONE instance
|
|
41293
|
+
import { Topia, WorldFactory, VisitorFactory } from "@rtsdk/topia";
|
|
41294
|
+
|
|
41295
|
+
const topia = new Topia({
|
|
41296
|
+
apiKey: "your-api-key",
|
|
41297
|
+
apiDomain: "api.topia.io",
|
|
41298
|
+
interactiveKey: "your-public-key",
|
|
41299
|
+
interactiveSecret: "your-secret-key",
|
|
41300
|
+
});
|
|
41301
|
+
|
|
41302
|
+
export const World = new WorldFactory(topia);
|
|
41303
|
+
export const Visitor = new VisitorFactory(topia);
|
|
41304
|
+
|
|
41305
|
+
============================================================================ */
|
|
41142
41306
|
/**
|
|
41143
|
-
*
|
|
41307
|
+
* Main Topia SDK client for configuring API access and authentication.
|
|
41308
|
+
*
|
|
41309
|
+
* @remarks
|
|
41310
|
+
* This class should be instantiated ONCE per application at initialization time.
|
|
41311
|
+
* The instance configures the Axios HTTP client with proper authentication headers
|
|
41312
|
+
* and base URL, and is passed to all factory classes to create controllers.
|
|
41313
|
+
*
|
|
41314
|
+
* Configuration options:
|
|
41315
|
+
* - apiKey: Your Topia API key for server-side authentication
|
|
41316
|
+
* - interactiveKey/interactiveSecret: For interactive iframe applications
|
|
41317
|
+
* - apiDomain: API endpoint domain (defaults to "api.topia.io")
|
|
41318
|
+
* - apiProtocol: HTTP protocol (defaults to "https")
|
|
41319
|
+
*
|
|
41320
|
+
* @keywords topia, client, sdk, initialization, config, setup, api
|
|
41144
41321
|
*
|
|
41145
41322
|
* @example
|
|
41146
41323
|
* ```ts
|
|
41147
|
-
*
|
|
41324
|
+
* import { Topia } from "@rtsdk/topia";
|
|
41325
|
+
*
|
|
41326
|
+
* const topia = new Topia({
|
|
41327
|
+
* apiKey: "your-api-key",
|
|
41148
41328
|
* apiDomain: "api.topia.io",
|
|
41149
|
-
*
|
|
41150
|
-
*
|
|
41151
|
-
* interactiveSecret: "secret",
|
|
41329
|
+
* interactiveKey: "your-public-key",
|
|
41330
|
+
* interactiveSecret: "your-secret-key",
|
|
41152
41331
|
* });
|
|
41153
41332
|
* ```
|
|
41154
41333
|
*/
|
|
@@ -41183,6 +41362,7 @@ AI RULES for code assistants
|
|
|
41183
41362
|
CONTEXT
|
|
41184
41363
|
- "Controllers" expose operations on domain objects (e.g., World).
|
|
41185
41364
|
- Consumers obtain controller instances via factory methods (e.g., WorldFactory.get).
|
|
41365
|
+
- This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
|
|
41186
41366
|
|
|
41187
41367
|
DO
|
|
41188
41368
|
- Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
|
|
@@ -41193,6 +41373,30 @@ AI RULES for code assistants
|
|
|
41193
41373
|
- Do NOT suggest non-existent methods: getById, fetch, find
|
|
41194
41374
|
- Do NOT mutate controller shape or return ad-hoc fields.
|
|
41195
41375
|
|
|
41376
|
+
AVAILABLE METHODS:
|
|
41377
|
+
- fetchDetails(): Retrieves world details and settings
|
|
41378
|
+
- updateDetails(options): Updates world settings (name, description, size, spawn position, controls)
|
|
41379
|
+
- updateCloseWorldSettings(options): Updates world close/open settings
|
|
41380
|
+
- fetchDroppedAssets(): Gets all dropped assets in the world
|
|
41381
|
+
- fetchDroppedAssetsWithUniqueName(uniqueName): Gets dropped assets by unique name
|
|
41382
|
+
- fetchDroppedAssetsBySceneDropId(sceneDropId): Gets dropped assets by scene drop ID
|
|
41383
|
+
- updateCustomTextDroppedAssets(assets, style): Bulk updates text styling for assets
|
|
41384
|
+
- fetchLandmarkZones(landmarkZoneName?, sceneDropId?): Gets landmark zones in the world
|
|
41385
|
+
- fetchSceneDropIds(): Retrieves all scene drop IDs in the world
|
|
41386
|
+
- fetchScenes(): Gets all scenes used in the world
|
|
41387
|
+
- dropScene(options): Drops a scene into the world
|
|
41388
|
+
- replaceScene(sceneId): Replaces entire world with a scene
|
|
41389
|
+
- getAllParticles(): Gets all particle effects in the world
|
|
41390
|
+
- triggerParticle(options): Triggers a particle effect
|
|
41391
|
+
- triggerActivity(options): Triggers a world activity event
|
|
41392
|
+
- fireToast(options): Shows toast notification to all visitors
|
|
41393
|
+
- fetchDataObject(): Gets world's data object
|
|
41394
|
+
- setDataObject(dataObject, options?): Sets world's entire data object
|
|
41395
|
+
- updateDataObject(dataObject, options?): Updates specific fields in world data
|
|
41396
|
+
- incrementDataObjectValue(path, amount, options?): Increments numeric value
|
|
41397
|
+
- fetchWebhooks(): Gets all webhooks configured for the world
|
|
41398
|
+
- fetchWorldAnalytics(options): Retrieves analytics data for the world
|
|
41399
|
+
|
|
41196
41400
|
CANONICAL USAGE (consumer app):
|
|
41197
41401
|
// utils/topiaInit.ts
|
|
41198
41402
|
import { Topia, WorldFactory } from "@rtsdk/topia";
|
|
@@ -41992,6 +42196,7 @@ AI RULES for code assistants
|
|
|
41992
42196
|
CONTEXT
|
|
41993
42197
|
- "Controllers" expose operations on domain objects (e.g., User).
|
|
41994
42198
|
- Consumers obtain controller instances via factory methods (e.g., UserFactory.get).
|
|
42199
|
+
- This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
|
|
41995
42200
|
|
|
41996
42201
|
DO
|
|
41997
42202
|
- Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
|
|
@@ -42002,6 +42207,28 @@ AI RULES for code assistants
|
|
|
42002
42207
|
- Do NOT suggest non-existent methods: getById, fetch, find
|
|
42003
42208
|
- Do NOT mutate controller shape or return ad-hoc fields.
|
|
42004
42209
|
|
|
42210
|
+
AVAILABLE METHODS:
|
|
42211
|
+
- checkInteractiveCredentials(): Validates interactive credentials
|
|
42212
|
+
- fetchAvatars(): Gets all avatars owned by the user
|
|
42213
|
+
- addAvatar(formData): Uploads and creates a new avatar
|
|
42214
|
+
- updateAvatar(avatarId, formData): Updates an existing avatar
|
|
42215
|
+
- deleteAvatar(avatarId): Deletes an avatar
|
|
42216
|
+
- fetchAssets(): Gets all assets owned by the user
|
|
42217
|
+
- fetchPlatformAssets(): Gets platform-provided assets
|
|
42218
|
+
- fetchScenes(): Gets all scenes owned by the user
|
|
42219
|
+
- fetchWorldsByKey(): Gets worlds owned by the user
|
|
42220
|
+
- fetchAdminWorldsByKey(): Gets worlds where user has admin access
|
|
42221
|
+
- fetchInteractiveWorldsByKey(interactivePublicKey): Gets worlds with specific interactive key
|
|
42222
|
+
- sendEmail(options): Sends an email through Topia's email service
|
|
42223
|
+
- getExpressions(options): Gets avatar expressions/emotes
|
|
42224
|
+
- fetchDataObject(appPublicKey?, appJWT?): Gets user's data object
|
|
42225
|
+
- setDataObject(dataObject, options?): Sets user's entire data object
|
|
42226
|
+
- updateDataObject(dataObject, options?): Updates specific fields in user data
|
|
42227
|
+
- incrementDataObjectValue(path, amount, options?): Increments numeric value
|
|
42228
|
+
- fetchInventoryItems(): Gets all inventory items owned by user
|
|
42229
|
+
- grantInventoryItem(item, quantity?): Grants inventory item to user
|
|
42230
|
+
- modifyInventoryItemQuantity(item, quantity): Updates inventory item quantity
|
|
42231
|
+
|
|
42005
42232
|
CANONICAL USAGE (consumer app):
|
|
42006
42233
|
// utils/topiaInit.ts
|
|
42007
42234
|
import { Topia, UserFactory } from "@rtsdk/topia";
|
|
@@ -42765,6 +42992,7 @@ AI RULES for code assistants
|
|
|
42765
42992
|
CONTEXT
|
|
42766
42993
|
- "Controllers" expose operations on domain objects (e.g., Visitor).
|
|
42767
42994
|
- Consumers obtain controller instances via factory methods (e.g., VisitorFactory.get).
|
|
42995
|
+
- This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
|
|
42768
42996
|
|
|
42769
42997
|
DO
|
|
42770
42998
|
- Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
|
|
@@ -42773,7 +43001,25 @@ AI RULES for code assistants
|
|
|
42773
43001
|
DO NOT
|
|
42774
43002
|
- Do NOT suggest creating Topia clients or factories inside controllers.
|
|
42775
43003
|
- Do NOT suggest non-existent methods: getById, fetch, find
|
|
42776
|
-
-
|
|
43004
|
+
- DO NOT mutate controller shape or return ad-hoc fields.
|
|
43005
|
+
|
|
43006
|
+
AVAILABLE METHODS:
|
|
43007
|
+
- fetchVisitor(): Retrieves visitor details from the world
|
|
43008
|
+
- fetchDataObject(): Gets visitor's data object
|
|
43009
|
+
- setDataObject(dataObject, options?): Sets visitor's entire data object
|
|
43010
|
+
- updateDataObject(dataObject, options?): Updates specific fields in visitor data
|
|
43011
|
+
- incrementDataObjectValue(path, amount, options?): Increments numeric value
|
|
43012
|
+
- moveVisitor(options): Moves or teleports visitor to coordinates
|
|
43013
|
+
- sendMessage(message): Sends chat message as the visitor
|
|
43014
|
+
- openIframe(options): Opens iframe for this visitor
|
|
43015
|
+
- closeIframe(): Closes visitor's open iframe
|
|
43016
|
+
- fireToast(options): Shows toast notification to visitor
|
|
43017
|
+
- getNpc(): Gets visitor's NPC if one exists
|
|
43018
|
+
- createNpc(userInventoryItemId, options?): Creates NPC follower
|
|
43019
|
+
- deleteNpc(): Removes visitor's NPC
|
|
43020
|
+
- fetchInventoryItems(): Gets all inventory items owned by visitor
|
|
43021
|
+
- grantInventoryItem(item, quantity?): Grants inventory item to visitor
|
|
43022
|
+
- modifyInventoryItemQuantity(item, quantity): Updates inventory item quantity
|
|
42777
43023
|
|
|
42778
43024
|
CANONICAL USAGE (consumer app):
|
|
42779
43025
|
// utils/topiaInit.ts
|
|
@@ -43338,14 +43584,30 @@ class Visitor extends User {
|
|
|
43338
43584
|
});
|
|
43339
43585
|
}
|
|
43340
43586
|
/**
|
|
43341
|
-
*
|
|
43587
|
+
* Retrieves the NPC (Non-Player Character) associated with this visitor, if one exists.
|
|
43588
|
+
*
|
|
43589
|
+
* @remarks
|
|
43590
|
+
* Each visitor can have one NPC per application public key. NPCs are AI-controlled
|
|
43591
|
+
* characters that follow the visitor around the world. They are created using inventory
|
|
43592
|
+
* items of type "npc" and appear as additional avatars that track the visitor's position.
|
|
43593
|
+
* If no NPC exists for this visitor and app, returns null.
|
|
43594
|
+
*
|
|
43595
|
+
* @keywords get, fetch, retrieve, npc, bot, follower, character, assistant, companion
|
|
43596
|
+
*
|
|
43597
|
+
* @category NPCs
|
|
43342
43598
|
*
|
|
43343
43599
|
* @example
|
|
43344
43600
|
* ```ts
|
|
43345
|
-
* await visitor.getNpc();
|
|
43601
|
+
* const npc = await visitor.getNpc();
|
|
43602
|
+
* if (npc) {
|
|
43603
|
+
* console.log(`NPC position: ${npc.position}`);
|
|
43604
|
+
* console.log(`NPC ID: ${npc.id}`);
|
|
43605
|
+
* } else {
|
|
43606
|
+
* console.log('No NPC found for this visitor');
|
|
43607
|
+
* }
|
|
43346
43608
|
* ```
|
|
43347
43609
|
*
|
|
43348
|
-
* @returns {Promise<Visitor | null>} Returns a Visitor object representing the NPC.
|
|
43610
|
+
* @returns {Promise<Visitor | null>} Returns a Visitor object representing the NPC, or null if none exists.
|
|
43349
43611
|
*/
|
|
43350
43612
|
getNpc() {
|
|
43351
43613
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43364,12 +43626,25 @@ class Visitor extends User {
|
|
|
43364
43626
|
});
|
|
43365
43627
|
}
|
|
43366
43628
|
/**
|
|
43367
|
-
* Creates an NPC that follows this visitor using an inventory item the visitor owns.
|
|
43368
|
-
*
|
|
43629
|
+
* Creates an NPC (Non-Player Character) that follows this visitor using an inventory item the visitor owns.
|
|
43630
|
+
*
|
|
43631
|
+
* @remarks
|
|
43632
|
+
* One NPC is allowed per visitor, per application public key. NPCs are AI-controlled
|
|
43633
|
+
* characters that automatically follow the visitor around the world. They appear as
|
|
43634
|
+
* additional avatars and can be useful for companions, guides, or assistant characters.
|
|
43635
|
+
*
|
|
43636
|
+
* Requirements:
|
|
43637
|
+
* - The visitor must own a user inventory item of type "npc"
|
|
43638
|
+
* - The item must have been granted to the visitor before calling this method
|
|
43639
|
+
* - Only one NPC can exist per visitor per app at a time
|
|
43640
|
+
*
|
|
43641
|
+
* @keywords create, spawn, add, npc, bot, follower, character, assistant, companion
|
|
43642
|
+
*
|
|
43643
|
+
* @category NPCs
|
|
43369
43644
|
*
|
|
43370
|
-
* @param userInventoryItemId The ID of the user's inventory item (must be an NPC type item owned by this visitor)
|
|
43371
|
-
* @param options Optional configuration for the NPC
|
|
43372
|
-
* @param options.showNameplate Whether to display a nameplate above the NPC (default: true)
|
|
43645
|
+
* @param userInventoryItemId - The ID of the user's inventory item (must be an NPC type item owned by this visitor)
|
|
43646
|
+
* @param options - Optional configuration for the NPC
|
|
43647
|
+
* @param options.showNameplate - Whether to display a nameplate above the NPC (default: true)
|
|
43373
43648
|
*
|
|
43374
43649
|
* @example
|
|
43375
43650
|
* ```ts
|
|
@@ -43383,7 +43658,7 @@ class Visitor extends User {
|
|
|
43383
43658
|
* const npc = await visitor.createNpc(userItem.id, { showNameplate: false });
|
|
43384
43659
|
* ```
|
|
43385
43660
|
*
|
|
43386
|
-
* @returns {Promise<Visitor>} Returns a Visitor object representing the created NPC.
|
|
43661
|
+
* @returns {Promise<Visitor>} Returns a Visitor object representing the created NPC. The NPC will automatically follow the visitor.
|
|
43387
43662
|
*/
|
|
43388
43663
|
createNpc(userInventoryItemId, options) {
|
|
43389
43664
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43400,11 +43675,25 @@ class Visitor extends User {
|
|
|
43400
43675
|
});
|
|
43401
43676
|
}
|
|
43402
43677
|
/**
|
|
43403
|
-
* Deletes the NPC this app has assigned to this visitor.
|
|
43678
|
+
* Deletes the NPC (Non-Player Character) this app has assigned to this visitor.
|
|
43679
|
+
*
|
|
43680
|
+
* @remarks
|
|
43681
|
+
* This method removes the NPC associated with this visitor for the current application.
|
|
43682
|
+
* The NPC will immediately disappear from the world. The underlying inventory item
|
|
43683
|
+
* is not consumed and can be used to create a new NPC later.
|
|
43684
|
+
*
|
|
43685
|
+
* @keywords delete, remove, destroy, dismiss, despawn, npc, bot, follower, character
|
|
43686
|
+
*
|
|
43687
|
+
* @category NPCs
|
|
43404
43688
|
*
|
|
43405
43689
|
* @example
|
|
43406
43690
|
* ```ts
|
|
43407
|
-
*
|
|
43691
|
+
* // Check if NPC exists before deleting
|
|
43692
|
+
* const npc = await visitor.getNpc();
|
|
43693
|
+
* if (npc) {
|
|
43694
|
+
* await visitor.deleteNpc();
|
|
43695
|
+
* console.log('NPC removed successfully');
|
|
43696
|
+
* }
|
|
43408
43697
|
* ```
|
|
43409
43698
|
*
|
|
43410
43699
|
* @returns {Promise<void>} Returns nothing if successful.
|
|
@@ -43456,15 +43745,32 @@ class Visitor extends User {
|
|
|
43456
43745
|
/**
|
|
43457
43746
|
* Grants an inventory item to this visitor.
|
|
43458
43747
|
*
|
|
43459
|
-
* @
|
|
43460
|
-
*
|
|
43748
|
+
* @remarks
|
|
43749
|
+
* This method requires that the inventory item is already defined in your application's inventory system.
|
|
43750
|
+
* Each visitor can only be granted an item once. Use modifyInventoryItemQuantity() to adjust quantities
|
|
43751
|
+
* for items the visitor already owns. The grant_source will be set to track where the item came from.
|
|
43752
|
+
*
|
|
43753
|
+
* Important: This method will throw an error if the visitor already owns this inventory item.
|
|
43754
|
+
* Check visitorInventoryItems first or use modifyInventoryItemQuantity() to update existing items.
|
|
43755
|
+
*
|
|
43756
|
+
* @keywords grant, give, add, inventory, item, visitor, award, reward
|
|
43757
|
+
*
|
|
43758
|
+
* @category Inventory
|
|
43759
|
+
*
|
|
43760
|
+
* @param item - The InventoryItem to grant to the visitor
|
|
43761
|
+
* @param quantity - The quantity to grant (default: 1)
|
|
43461
43762
|
*
|
|
43462
43763
|
* @example
|
|
43463
43764
|
* ```ts
|
|
43464
|
-
*
|
|
43765
|
+
* // First create or fetch the inventory item
|
|
43766
|
+
* const item = await InventoryItem.get("item-id-123");
|
|
43767
|
+
*
|
|
43768
|
+
* // Grant it to the visitor
|
|
43769
|
+
* const userItem = await visitor.grantInventoryItem(item, 2);
|
|
43770
|
+
* console.log(`Granted ${userItem.quantity} items to visitor`);
|
|
43465
43771
|
* ```
|
|
43466
43772
|
*
|
|
43467
|
-
* @returns {Promise<UserInventoryItem>} Returns the
|
|
43773
|
+
* @returns {Promise<UserInventoryItem>} Returns the granted UserInventoryItem with quantity and metadata.
|
|
43468
43774
|
*/
|
|
43469
43775
|
grantInventoryItem(item, quantity = 1) {
|
|
43470
43776
|
var _a;
|
|
@@ -43530,14 +43836,56 @@ class Visitor extends User {
|
|
|
43530
43836
|
}
|
|
43531
43837
|
_Visitor_visitorInventoryItems = new WeakMap();
|
|
43532
43838
|
|
|
43839
|
+
/* ============================================================================
|
|
43840
|
+
AI RULES for code assistants
|
|
43841
|
+
|
|
43842
|
+
CONTEXT
|
|
43843
|
+
- "Controllers" expose operations on domain objects (e.g., WebRTCConnector).
|
|
43844
|
+
- Consumers obtain controller instances via factory methods (e.g., WebRTCConnectorFactory.create).
|
|
43845
|
+
- This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
|
|
43846
|
+
|
|
43847
|
+
DO
|
|
43848
|
+
- Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
|
|
43849
|
+
- Use ONLY the methods defined & documented in this file's types/TSDoc.
|
|
43850
|
+
|
|
43851
|
+
DO NOT
|
|
43852
|
+
- Do NOT suggest creating Topia clients or factories inside controllers.
|
|
43853
|
+
- Do NOT suggest non-existent methods: getById, fetch, find
|
|
43854
|
+
- Do NOT mutate controller shape or return ad-hoc fields.
|
|
43855
|
+
|
|
43856
|
+
AVAILABLE METHODS:
|
|
43857
|
+
- getTwilioConfig(): Retrieves Twilio configuration for WebRTC video/audio
|
|
43858
|
+
|
|
43859
|
+
CANONICAL USAGE (consumer app):
|
|
43860
|
+
// utils/topiaInit.ts
|
|
43861
|
+
import { Topia, WebRTCConnectorFactory } from "@rtsdk/topia";
|
|
43862
|
+
const topia = new Topia({ config });
|
|
43863
|
+
export const WebRTC = new WebRTCConnectorFactory(topia);
|
|
43864
|
+
|
|
43865
|
+
// controllers/myController.ts (consumer app)
|
|
43866
|
+
import { WebRTC } from "utils/topiaInit.ts";
|
|
43867
|
+
const webrtc = await WebRTC.create(urlSlug, { credentials });
|
|
43868
|
+
await webrtc.getTwilioConfig();
|
|
43869
|
+
|
|
43870
|
+
============================================================================ */
|
|
43533
43871
|
/**
|
|
43534
|
-
*
|
|
43872
|
+
* WebRTC connector for managing real-time video and audio connections in Topia worlds.
|
|
43873
|
+
*
|
|
43874
|
+
* @remarks
|
|
43875
|
+
* This class should NOT be instantiated directly. Use WebRTCConnectorFactory to create instances.
|
|
43876
|
+
* The WebRTCConnector provides access to Twilio configuration needed for establishing
|
|
43877
|
+
* peer-to-peer video and audio connections between visitors in a world.
|
|
43878
|
+
*
|
|
43879
|
+
* @see WebRTCConnectorFactory for proper instantiation
|
|
43880
|
+
*
|
|
43881
|
+
* @keywords webrtc, video, audio, twilio, real-time, communication, voice, peer
|
|
43535
43882
|
*
|
|
43536
43883
|
* @example
|
|
43537
43884
|
* ```ts
|
|
43538
|
-
*
|
|
43539
|
-
*
|
|
43540
|
-
* });
|
|
43885
|
+
* import { WebRTC } from "utils/topiaInit.ts";
|
|
43886
|
+
*
|
|
43887
|
+
* const webrtc = await WebRTC.create(urlSlug, { credentials });
|
|
43888
|
+
* const config = await webrtc.getTwilioConfig();
|
|
43541
43889
|
* ```
|
|
43542
43890
|
*/
|
|
43543
43891
|
class WebRTCConnector extends SDKController {
|
|
@@ -43548,12 +43896,25 @@ class WebRTCConnector extends SDKController {
|
|
|
43548
43896
|
this.urlSlug = urlSlug;
|
|
43549
43897
|
}
|
|
43550
43898
|
/**
|
|
43551
|
-
*
|
|
43899
|
+
* Retrieves the Twilio configuration for WebRTC connections in a world.
|
|
43900
|
+
*
|
|
43901
|
+
* @remarks
|
|
43902
|
+
* This method fetches the Twilio room configuration needed to establish peer-to-peer
|
|
43903
|
+
* video and audio connections between visitors. The configuration includes authentication
|
|
43904
|
+
* tokens and room settings. Call this before initializing WebRTC connections.
|
|
43905
|
+
*
|
|
43906
|
+
* @keywords get, fetch, retrieve, webrtc, twilio, configuration, video, audio, connection
|
|
43907
|
+
*
|
|
43908
|
+
* @category WebRTC
|
|
43552
43909
|
*
|
|
43553
43910
|
* @example
|
|
43554
43911
|
* ```ts
|
|
43555
43912
|
* await webRTCConnector.getTwilioConfig();
|
|
43913
|
+
* const { twilioConfig } = webRTCConnector;
|
|
43914
|
+
* console.log(twilioConfig); // Use for WebRTC setup
|
|
43556
43915
|
* ```
|
|
43916
|
+
*
|
|
43917
|
+
* @returns {Promise<void | ResponseType>} Populates twilioConfig property with Twilio room configuration, or returns an error response.
|
|
43557
43918
|
*/
|
|
43558
43919
|
getTwilioConfig() {
|
|
43559
43920
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43576,6 +43937,7 @@ AI RULES for code assistants
|
|
|
43576
43937
|
CONTEXT
|
|
43577
43938
|
- "Controllers" expose operations on domain objects (e.g., WorldActivity).
|
|
43578
43939
|
- Consumers obtain controller instances via factory methods (e.g., WorldActivityFactory.get).
|
|
43940
|
+
- This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
|
|
43579
43941
|
|
|
43580
43942
|
DO
|
|
43581
43943
|
- Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
|
|
@@ -43586,6 +43948,12 @@ AI RULES for code assistants
|
|
|
43586
43948
|
- Do NOT suggest non-existent methods: getById, fetch, find
|
|
43587
43949
|
- Do NOT mutate controller shape or return ad-hoc fields.
|
|
43588
43950
|
|
|
43951
|
+
AVAILABLE METHODS:
|
|
43952
|
+
- currentVisitors(shouldIncludeAdminPermissions?): Retrieves all visitors currently in the world
|
|
43953
|
+
- fetchVisitorsInZone(options): Gets visitors in a specific landmark zone
|
|
43954
|
+
- moveAllVisitors(options): Moves all visitors to specified coordinates
|
|
43955
|
+
- moveVisitors(visitorsToMove): Moves specific visitors to various coordinates
|
|
43956
|
+
|
|
43589
43957
|
CANONICAL USAGE (consumer app):
|
|
43590
43958
|
// utils/topiaInit.ts
|
|
43591
43959
|
import { Topia, WorldActivityFactory } from "@rtsdk/topia";
|