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