@rtsdk/topia 0.19.2 → 0.19.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -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
- * Create an instance of SDKController class with credentials.
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
- * const credentials = {
39622
- * assetId: "exampleAsset",
39623
- * interactiveNonce: "exampleNonce"
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,42 @@ 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
+ * @param error - The error object from the failed operation (AxiosError, Error, or unknown)
39731
+ * @param message - Optional custom error message (defaults to generic message)
39732
+ * @param params - Optional parameters that were passed to the failed method
39733
+ * @param sdkMethod - Optional name of the SDK method that failed (e.g., "World.fetchDetails")
39734
+ *
39735
+ * @returns {object} Standardized error object with properties: data, message, method, params, sdkMethod, stack, status, success, url
39736
+ */
39676
39737
  errorHandler({ error, message = "Something went wrong. Please try again or contact support.", params = {}, sdkMethod, }) {
39677
39738
  var _a, _b;
39678
39739
  const stackTrace = new Error("Thrown here:");
@@ -39716,6 +39777,7 @@ AI RULES for code assistants
39716
39777
  CONTEXT
39717
39778
  - "Controllers" expose operations on domain objects (e.g., Asset).
39718
39779
  - Consumers obtain controller instances via factory methods (e.g., AssetFactory.get).
39780
+ - This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
39719
39781
 
39720
39782
  DO
39721
39783
  - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
@@ -39726,6 +39788,10 @@ AI RULES for code assistants
39726
39788
  - Do NOT suggest non-existent methods: getById, fetch, find
39727
39789
  - Do NOT mutate controller shape or return ad-hoc fields.
39728
39790
 
39791
+ AVAILABLE METHODS:
39792
+ - fetchAssetById(): Retrieves platform asset details
39793
+ - updateAsset(options): Updates asset properties (name, layers, tags, visibility)
39794
+
39729
39795
  CANONICAL USAGE (consumer app):
39730
39796
  // utils/topiaInit.ts
39731
39797
  import { Topia, AssetFactory } from "@rtsdk/topia";
@@ -39887,6 +39953,7 @@ AI RULES for code assistants
39887
39953
  CONTEXT
39888
39954
  - "Controllers" expose operations on domain objects (e.g., DroppedAsset).
39889
39955
  - Consumers obtain controller instances via factory methods (e.g., DroppedAssetFactory.get).
39956
+ - This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
39890
39957
 
39891
39958
  DO
39892
39959
  - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
@@ -39897,6 +39964,35 @@ AI RULES for code assistants
39897
39964
  - Do NOT suggest non-existent methods: getById, fetch, find
39898
39965
  - Do NOT mutate controller shape or return ad-hoc fields.
39899
39966
 
39967
+ AVAILABLE METHODS:
39968
+ - fetchDroppedAssetById(): Retrieves dropped asset details
39969
+ - updateDroppedAsset(options): Updates dropped asset properties
39970
+ - deleteDroppedAsset(): Removes the dropped asset from the world
39971
+ - fetchDataObject(appPublicKey?, appJWT?, sharedAppPublicKey?, sharedAppJWT?): Gets asset's data object
39972
+ - setDataObject(dataObject, options?): Sets asset's entire data object
39973
+ - updateDataObject(dataObject, options?): Updates specific fields in data object
39974
+ - incrementDataObjectValue(path, amount, options?): Increments numeric value
39975
+ - updateBroadcast(options): Updates broadcast settings
39976
+ - updateClickType(options): Updates click behavior and link settings
39977
+ - setClickableLinkMulti(options): Adds multiple links to asset
39978
+ - updateClickableLinkMulti(options): Updates specific clickable link
39979
+ - removeClickableLink(options): Removes a clickable link
39980
+ - updateCustomTextAsset(style, text): Updates text and styling
39981
+ - updateMediaType(options): Updates media (video/audio) settings
39982
+ - updateMuteZone(isMutezone): Toggles mute zone
39983
+ - updateLandmarkZone(options): Updates landmark zone settings
39984
+ - updateWebhookZone(isEnabled): Toggles webhook zone
39985
+ - updatePosition(x, y, yOrderAdjust?): Moves the asset
39986
+ - updatePrivateZone(options): Updates private zone settings
39987
+ - updateScale(assetScale): Changes asset size
39988
+ - flip(): Flips the asset horizontally
39989
+ - updateUploadedMediaSelected(mediaId): Changes embedded media
39990
+ - updateWebImageLayers(bottom, top): Updates image layers
39991
+ - addWebhook(options): Adds a webhook to the asset
39992
+ - setInteractiveSettings(options): Configures interactive settings
39993
+ - checkExists(): Verifies asset exists with app's public key
39994
+ - fetchDroppedAssetAnalytics(options): Gets analytics data for the asset
39995
+
39900
39996
  CANONICAL USAGE (consumer app):
39901
39997
  // utils/topiaInit.ts
39902
39998
  import { Topia, DroppedAssetFactory } from "@rtsdk/topia";
@@ -40786,12 +40882,17 @@ class InventoryItem extends SDKController {
40786
40882
  /**
40787
40883
  * Fetches the inventory item details from the platform and assigns them to this instance.
40788
40884
  *
40885
+ * @keywords get, fetch, retrieve, load, inventory, item, details
40886
+ *
40887
+ * @category Inventory
40888
+ *
40789
40889
  * @example
40790
40890
  * ```ts
40791
40891
  * await item.fetchInventoryItemById();
40892
+ * const { name, description, type } = item;
40792
40893
  * ```
40793
40894
  *
40794
- * @returns {Promise<InventoryItem>} Returns when the item has been fetched and assigned.
40895
+ * @returns {Promise<InventoryItem>} Returns this InventoryItem instance with all properties populated from the platform.
40795
40896
  */
40796
40897
  fetchInventoryItemById() {
40797
40898
  return __awaiter(this, void 0, void 0, function* () {
@@ -40819,6 +40920,13 @@ AI RULES for code assistants
40819
40920
  - Do NOT suggest non-existent methods: getById, fetch, find
40820
40921
  - Do NOT mutate controller shape or return ad-hoc fields.
40821
40922
 
40923
+ AVAILABLE METHODS:
40924
+ - fetchDataObject(appPublicKey?, appJWT?, sharedAppPublicKey?, sharedAppJWT?): Retrieves ecosystem-wide data object
40925
+ - setDataObject(dataObject, options?): Sets entire ecosystem data object
40926
+ - updateDataObject(dataObject, options?): Updates specific fields in ecosystem data object
40927
+ - incrementDataObjectValue(path, amount, options?): Increments a numeric value in ecosystem data
40928
+ - fetchInventoryItems(): Retrieves all inventory items for the app's keyholder
40929
+
40822
40930
  CANONICAL USAGE (consumer app):
40823
40931
  // utils/topiaInit.ts
40824
40932
  import { Topia, Ecosystem } from "@rtsdk/topia";
@@ -40853,7 +40961,7 @@ class Ecosystem extends SDKController {
40853
40961
  /**
40854
40962
  * Retrieves the data object for a Topia ecosystem. Requires canUpdateEcosystemDataObjects permission to be set to true for the public key.
40855
40963
  *
40856
- * @keywords get, fetch, retrieve, load, data, object, state
40964
+ * @keywords get, fetch, retrieve, load, ecosystem, data, object, state, global, platform
40857
40965
  *
40858
40966
  * @category Data Objects
40859
40967
  *
@@ -40862,7 +40970,7 @@ class Ecosystem extends SDKController {
40862
40970
  * const dataObject = await ecosystem.fetchDataObject("exampleAppPublicKey", "exampleAppPublicKeyJWT");
40863
40971
  * ```
40864
40972
  *
40865
- * @returns {Promise<object | ResponseType>} Returns the data object or an error response.
40973
+ * @returns {Promise<void | ResponseType>} Populates the dataObject property with ecosystem-wide data, or returns an error response.
40866
40974
  */
40867
40975
  fetchDataObject(appPublicKey, appJWT, sharedAppPublicKey, sharedAppJWT) {
40868
40976
  return __awaiter(this, void 0, void 0, function* () {
@@ -40889,7 +40997,7 @@ class Ecosystem extends SDKController {
40889
40997
  *
40890
40998
  * 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
40999
  *
40892
- * @keywords set, assign, store, save, data, object, state
41000
+ * @keywords set, assign, store, save, ecosystem, data, object, state, global, platform
40893
41001
  *
40894
41002
  * @category Data Objects
40895
41003
  *
@@ -40901,6 +41009,8 @@ class Ecosystem extends SDKController {
40901
41009
  * });
40902
41010
  * const { exampleKey } = ecosystem.dataObject;
40903
41011
  * ```
41012
+ *
41013
+ * @returns {Promise<void | ResponseType>} Returns success or an error response.
40904
41014
  */
40905
41015
  setDataObject(dataObject, options = {}) {
40906
41016
  return __awaiter(this, void 0, void 0, function* () {
@@ -40921,7 +41031,7 @@ class Ecosystem extends SDKController {
40921
41031
  *
40922
41032
  * 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
41033
  *
40924
- * @keywords update, modify, change, edit, alter, data, object, state
41034
+ * @keywords update, modify, change, edit, alter, ecosystem, data, object, state, global, platform
40925
41035
  *
40926
41036
  * @category Data Objects
40927
41037
  *
@@ -40939,6 +41049,8 @@ class Ecosystem extends SDKController {
40939
41049
  * });
40940
41050
  * const { exampleKey } = ecosystem.dataObject;
40941
41051
  * ```
41052
+ *
41053
+ * @returns {Promise<void | ResponseType>} Returns success or an error response.
40942
41054
  */
40943
41055
  updateDataObject(dataObject, options = {}) {
40944
41056
  return __awaiter(this, void 0, void 0, function* () {
@@ -40959,7 +41071,7 @@ class Ecosystem extends SDKController {
40959
41071
  *
40960
41072
  * 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
41073
  *
40962
- * @keywords increment, increase, add, count, data, object, state
41074
+ * @keywords increment, increase, add, count, ecosystem, data, object, state, global, platform
40963
41075
  *
40964
41076
  * @category Data Objects
40965
41077
  *
@@ -40970,6 +41082,8 @@ class Ecosystem extends SDKController {
40970
41082
  * sharedAppJWT: "exampleAppPublicKeyJWT",}
40971
41083
  * });
40972
41084
  * ```
41085
+ *
41086
+ * @returns {Promise<void | ResponseType>} Returns success or an error response.
40973
41087
  */
40974
41088
  incrementDataObjectValue(path, amount, options = {}) {
40975
41089
  return __awaiter(this, void 0, void 0, function* () {
@@ -40988,14 +41102,17 @@ class Ecosystem extends SDKController {
40988
41102
  /**
40989
41103
  * Retrieves all inventory items for a given keyholder (app public key).
40990
41104
  *
40991
- * @keywords get, fetch, retrieve, list, inventory, items, keyholder
41105
+ * @keywords get, fetch, retrieve, list, inventory, items, keyholder, ecosystem, catalog
41106
+ *
41107
+ * @category Inventory
40992
41108
  *
40993
41109
  * @example
40994
41110
  * ```ts
40995
- * const items = await ecosystem.fetchInventoryItems("appPublicKey", "appJWT");
41111
+ * await ecosystem.fetchInventoryItems();
41112
+ * const items = ecosystem.inventoryItems;
40996
41113
  * ```
40997
41114
  *
40998
- * @returns {Promise<object[]>} Returns an array of InventoryItem objects.
41115
+ * @returns {Promise<void>} Populates the inventoryItems property with an array of InventoryItem objects.
40999
41116
  */
41000
41117
  fetchInventoryItems() {
41001
41118
  return __awaiter(this, void 0, void 0, function* () {
@@ -41029,6 +41146,10 @@ _Ecosystem_inventoryItems = new WeakMap();
41029
41146
  *
41030
41147
  * @remarks
41031
41148
  * This class should be instantiated via UserInventoryItemFactory only.
41149
+ * UserInventoryItem represents an instance of an InventoryItem owned by a specific user or visitor.
41150
+ * It includes ownership details like quantity, grant_source, and user-specific metadata.
41151
+ *
41152
+ * @keywords inventory, item, user, visitor, owned, granted
41032
41153
  *
41033
41154
  * @property inventoryItemId - The root inventory item's id
41034
41155
  */
@@ -41039,26 +41160,33 @@ class UserInventoryItem extends InventoryItem {
41039
41160
  super(topia, item_id, { attributes: options.attributes, credentials: options.credentials });
41040
41161
  Object.assign(this, options.attributes);
41041
41162
  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, } = options.attributes;
41163
+ 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
41164
  this.item_id = item_id;
41044
41165
  this.quantity = quantity;
41045
41166
  this.grant_source = grant_source;
41046
41167
  this.user_id = user_id;
41047
41168
  this.type = type;
41169
+ this.image_url = image_url;
41048
41170
  this.metadata = metadata;
41049
41171
  this.created_at = created_at;
41050
41172
  this.updated_at = updated_at;
41051
41173
  this.profile_id = profile_id;
41174
+ this.item = item;
41052
41175
  }
41053
41176
  /**
41054
41177
  * Fetches the user inventory item details from the platform and assigns them to this instance.
41055
41178
  *
41179
+ * @keywords get, fetch, retrieve, load, user, inventory, item, details, owned
41180
+ *
41181
+ * @category Inventory
41182
+ *
41056
41183
  * @example
41057
41184
  * ```ts
41058
41185
  * await userInventoryItem.fetchUserInventoryItemById();
41186
+ * const { quantity, grant_source, item } = userInventoryItem;
41059
41187
  * ```
41060
41188
  *
41061
- * @returns {Promise<void>} Returns when the item has been fetched and assigned.
41189
+ * @returns {Promise<void>} Populates this UserInventoryItem instance with all properties from the platform.
41062
41190
  */
41063
41191
  fetchUserInventoryItemById() {
41064
41192
  return __awaiter(this, void 0, void 0, function* () {
@@ -41076,6 +41204,7 @@ AI RULES for code assistants
41076
41204
  CONTEXT
41077
41205
  - "Controllers" expose operations on domain objects (e.g., Scene).
41078
41206
  - Consumers obtain controller instances via factory methods (e.g., SceneFactory.get).
41207
+ - This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
41079
41208
 
41080
41209
  DO
41081
41210
  - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
@@ -41086,6 +41215,9 @@ AI RULES for code assistants
41086
41215
  - Do NOT suggest non-existent methods: getById, fetch, find
41087
41216
  - Do NOT mutate controller shape or return ad-hoc fields.
41088
41217
 
41218
+ AVAILABLE METHODS:
41219
+ - fetchSceneById(): Retrieves scene details and configuration
41220
+
41089
41221
  CANONICAL USAGE (consumer app):
41090
41222
  // utils/topiaInit.ts
41091
41223
  import { Topia, SceneFactory } from "@rtsdk/topia";
@@ -41095,6 +41227,7 @@ AI RULES for code assistants
41095
41227
  // controllers/myController.ts (consumer app)
41096
41228
  import { Scene } from "utils/topiaInit.ts";
41097
41229
  const scene = await Scene.get(sceneId, { credentials });
41230
+ await scene.fetchSceneById();
41098
41231
 
41099
41232
  ============================================================================ */
41100
41233
  /**
@@ -41140,16 +41273,68 @@ class Scene extends SDKController {
41140
41273
  }
41141
41274
  }
41142
41275
 
41276
+ /* ============================================================================
41277
+ AI RULES for code assistants
41278
+
41279
+ CONTEXT
41280
+ - Topia is the main client class that initializes the SDK.
41281
+ - This class should be instantiated ONCE in the consumer app (e.g., utils/topiaInit.ts).
41282
+ - The Topia instance is passed to all factory classes to create controllers.
41283
+ - This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
41284
+
41285
+ DO
41286
+ - Expect consumers to create ONE Topia instance at app initialization.
41287
+ - This instance is then used to instantiate all factories (WorldFactory, VisitorFactory, etc.).
41288
+ - The Topia class configures the Axios client with proper authentication.
41289
+
41290
+ DO NOT
41291
+ - Do NOT suggest creating multiple Topia instances; one per app is sufficient.
41292
+ - Do NOT suggest instantiating controllers directly; always use factories.
41293
+ - Do NOT modify the Axios instance after creation; configure it through constructor.
41294
+
41295
+ AVAILABLE METHODS:
41296
+ - constructor(config): Initializes the Topia client with API credentials
41297
+
41298
+ CANONICAL USAGE (consumer app):
41299
+ // utils/topiaInit.ts - Create ONE instance
41300
+ import { Topia, WorldFactory, VisitorFactory } from "@rtsdk/topia";
41301
+
41302
+ const topia = new Topia({
41303
+ apiKey: "your-api-key",
41304
+ apiDomain: "api.topia.io",
41305
+ interactiveKey: "your-public-key",
41306
+ interactiveSecret: "your-secret-key",
41307
+ });
41308
+
41309
+ export const World = new WorldFactory(topia);
41310
+ export const Visitor = new VisitorFactory(topia);
41311
+
41312
+ ============================================================================ */
41143
41313
  /**
41144
- * Create a single instance of Topia axios used for all calls to the public API in all classes
41314
+ * Main Topia SDK client for configuring API access and authentication.
41315
+ *
41316
+ * @remarks
41317
+ * This class should be instantiated ONCE per application at initialization time.
41318
+ * The instance configures the Axios HTTP client with proper authentication headers
41319
+ * and base URL, and is passed to all factory classes to create controllers.
41320
+ *
41321
+ * Configuration options:
41322
+ * - apiKey: Your Topia API key for server-side authentication
41323
+ * - interactiveKey/interactiveSecret: For interactive iframe applications
41324
+ * - apiDomain: API endpoint domain (defaults to "api.topia.io")
41325
+ * - apiProtocol: HTTP protocol (defaults to "https")
41326
+ *
41327
+ * @keywords topia, client, sdk, initialization, config, setup, api
41145
41328
  *
41146
41329
  * @example
41147
41330
  * ```ts
41148
- * const topia = await new Topia({
41331
+ * import { Topia } from "@rtsdk/topia";
41332
+ *
41333
+ * const topia = new Topia({
41334
+ * apiKey: "your-api-key",
41149
41335
  * apiDomain: "api.topia.io",
41150
- * apiKey: "exampleKey",
41151
- * interactiveKey: "key",
41152
- * interactiveSecret: "secret",
41336
+ * interactiveKey: "your-public-key",
41337
+ * interactiveSecret: "your-secret-key",
41153
41338
  * });
41154
41339
  * ```
41155
41340
  */
@@ -41184,6 +41369,7 @@ AI RULES for code assistants
41184
41369
  CONTEXT
41185
41370
  - "Controllers" expose operations on domain objects (e.g., World).
41186
41371
  - Consumers obtain controller instances via factory methods (e.g., WorldFactory.get).
41372
+ - This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
41187
41373
 
41188
41374
  DO
41189
41375
  - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
@@ -41194,6 +41380,30 @@ AI RULES for code assistants
41194
41380
  - Do NOT suggest non-existent methods: getById, fetch, find
41195
41381
  - Do NOT mutate controller shape or return ad-hoc fields.
41196
41382
 
41383
+ AVAILABLE METHODS:
41384
+ - fetchDetails(): Retrieves world details and settings
41385
+ - updateDetails(options): Updates world settings (name, description, size, spawn position, controls)
41386
+ - updateCloseWorldSettings(options): Updates world close/open settings
41387
+ - fetchDroppedAssets(): Gets all dropped assets in the world
41388
+ - fetchDroppedAssetsWithUniqueName(uniqueName): Gets dropped assets by unique name
41389
+ - fetchDroppedAssetsBySceneDropId(sceneDropId): Gets dropped assets by scene drop ID
41390
+ - updateCustomTextDroppedAssets(assets, style): Bulk updates text styling for assets
41391
+ - fetchLandmarkZones(landmarkZoneName?, sceneDropId?): Gets landmark zones in the world
41392
+ - fetchSceneDropIds(): Retrieves all scene drop IDs in the world
41393
+ - fetchScenes(): Gets all scenes used in the world
41394
+ - dropScene(options): Drops a scene into the world
41395
+ - replaceScene(sceneId): Replaces entire world with a scene
41396
+ - getAllParticles(): Gets all particle effects in the world
41397
+ - triggerParticle(options): Triggers a particle effect
41398
+ - triggerActivity(options): Triggers a world activity event
41399
+ - fireToast(options): Shows toast notification to all visitors
41400
+ - fetchDataObject(): Gets world's data object
41401
+ - setDataObject(dataObject, options?): Sets world's entire data object
41402
+ - updateDataObject(dataObject, options?): Updates specific fields in world data
41403
+ - incrementDataObjectValue(path, amount, options?): Increments numeric value
41404
+ - fetchWebhooks(): Gets all webhooks configured for the world
41405
+ - fetchWorldAnalytics(options): Retrieves analytics data for the world
41406
+
41197
41407
  CANONICAL USAGE (consumer app):
41198
41408
  // utils/topiaInit.ts
41199
41409
  import { Topia, WorldFactory } from "@rtsdk/topia";
@@ -41993,6 +42203,7 @@ AI RULES for code assistants
41993
42203
  CONTEXT
41994
42204
  - "Controllers" expose operations on domain objects (e.g., User).
41995
42205
  - Consumers obtain controller instances via factory methods (e.g., UserFactory.get).
42206
+ - This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
41996
42207
 
41997
42208
  DO
41998
42209
  - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
@@ -42003,6 +42214,28 @@ AI RULES for code assistants
42003
42214
  - Do NOT suggest non-existent methods: getById, fetch, find
42004
42215
  - Do NOT mutate controller shape or return ad-hoc fields.
42005
42216
 
42217
+ AVAILABLE METHODS:
42218
+ - checkInteractiveCredentials(): Validates interactive credentials
42219
+ - fetchAvatars(): Gets all avatars owned by the user
42220
+ - addAvatar(formData): Uploads and creates a new avatar
42221
+ - updateAvatar(avatarId, formData): Updates an existing avatar
42222
+ - deleteAvatar(avatarId): Deletes an avatar
42223
+ - fetchAssets(): Gets all assets owned by the user
42224
+ - fetchPlatformAssets(): Gets platform-provided assets
42225
+ - fetchScenes(): Gets all scenes owned by the user
42226
+ - fetchWorldsByKey(): Gets worlds owned by the user
42227
+ - fetchAdminWorldsByKey(): Gets worlds where user has admin access
42228
+ - fetchInteractiveWorldsByKey(interactivePublicKey): Gets worlds with specific interactive key
42229
+ - sendEmail(options): Sends an email through Topia's email service
42230
+ - getExpressions(options): Gets avatar expressions/emotes
42231
+ - fetchDataObject(appPublicKey?, appJWT?): Gets user's data object
42232
+ - setDataObject(dataObject, options?): Sets user's entire data object
42233
+ - updateDataObject(dataObject, options?): Updates specific fields in user data
42234
+ - incrementDataObjectValue(path, amount, options?): Increments numeric value
42235
+ - fetchInventoryItems(): Gets all inventory items owned by user
42236
+ - grantInventoryItem(item, quantity?): Grants inventory item to user
42237
+ - modifyInventoryItemQuantity(item, quantity): Updates inventory item quantity
42238
+
42006
42239
  CANONICAL USAGE (consumer app):
42007
42240
  // utils/topiaInit.ts
42008
42241
  import { Topia, UserFactory } from "@rtsdk/topia";
@@ -42766,6 +42999,7 @@ AI RULES for code assistants
42766
42999
  CONTEXT
42767
43000
  - "Controllers" expose operations on domain objects (e.g., Visitor).
42768
43001
  - Consumers obtain controller instances via factory methods (e.g., VisitorFactory.get).
43002
+ - This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
42769
43003
 
42770
43004
  DO
42771
43005
  - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
@@ -42774,7 +43008,25 @@ AI RULES for code assistants
42774
43008
  DO NOT
42775
43009
  - Do NOT suggest creating Topia clients or factories inside controllers.
42776
43010
  - Do NOT suggest non-existent methods: getById, fetch, find
42777
- - Do NOT mutate controller shape or return ad-hoc fields.
43011
+ - DO NOT mutate controller shape or return ad-hoc fields.
43012
+
43013
+ AVAILABLE METHODS:
43014
+ - fetchVisitor(): Retrieves visitor details from the world
43015
+ - fetchDataObject(): Gets visitor's data object
43016
+ - setDataObject(dataObject, options?): Sets visitor's entire data object
43017
+ - updateDataObject(dataObject, options?): Updates specific fields in visitor data
43018
+ - incrementDataObjectValue(path, amount, options?): Increments numeric value
43019
+ - moveVisitor(options): Moves or teleports visitor to coordinates
43020
+ - sendMessage(message): Sends chat message as the visitor
43021
+ - openIframe(options): Opens iframe for this visitor
43022
+ - closeIframe(): Closes visitor's open iframe
43023
+ - fireToast(options): Shows toast notification to visitor
43024
+ - getNpc(): Gets visitor's NPC if one exists
43025
+ - createNpc(userInventoryItemId, options?): Creates NPC follower
43026
+ - deleteNpc(): Removes visitor's NPC
43027
+ - fetchInventoryItems(): Gets all inventory items owned by visitor
43028
+ - grantInventoryItem(item, quantity?): Grants inventory item to visitor
43029
+ - modifyInventoryItemQuantity(item, quantity): Updates inventory item quantity
42778
43030
 
42779
43031
  CANONICAL USAGE (consumer app):
42780
43032
  // utils/topiaInit.ts
@@ -43339,14 +43591,30 @@ class Visitor extends User {
43339
43591
  });
43340
43592
  }
43341
43593
  /**
43342
- * Gets an NPC for this visitor, if one exists.
43594
+ * Retrieves the NPC (Non-Player Character) associated with this visitor, if one exists.
43595
+ *
43596
+ * @remarks
43597
+ * Each visitor can have one NPC per application public key. NPCs are AI-controlled
43598
+ * characters that follow the visitor around the world. They are created using inventory
43599
+ * items of type "npc" and appear as additional avatars that track the visitor's position.
43600
+ * If no NPC exists for this visitor and app, returns null.
43601
+ *
43602
+ * @keywords get, fetch, retrieve, npc, bot, follower, character, assistant, companion
43603
+ *
43604
+ * @category NPCs
43343
43605
  *
43344
43606
  * @example
43345
43607
  * ```ts
43346
- * await visitor.getNpc();
43608
+ * const npc = await visitor.getNpc();
43609
+ * if (npc) {
43610
+ * console.log(`NPC position: ${npc.position}`);
43611
+ * console.log(`NPC ID: ${npc.id}`);
43612
+ * } else {
43613
+ * console.log('No NPC found for this visitor');
43614
+ * }
43347
43615
  * ```
43348
43616
  *
43349
- * @returns {Promise<Visitor | null>} Returns a Visitor object representing the NPC.
43617
+ * @returns {Promise<Visitor | null>} Returns a Visitor object representing the NPC, or null if none exists.
43350
43618
  */
43351
43619
  getNpc() {
43352
43620
  return __awaiter(this, void 0, void 0, function* () {
@@ -43365,12 +43633,25 @@ class Visitor extends User {
43365
43633
  });
43366
43634
  }
43367
43635
  /**
43368
- * Creates an NPC that follows this visitor using an inventory item the visitor owns.
43369
- * One NPC is allowed per visitor, per application public key.
43636
+ * Creates an NPC (Non-Player Character) that follows this visitor using an inventory item the visitor owns.
43637
+ *
43638
+ * @remarks
43639
+ * One NPC is allowed per visitor, per application public key. NPCs are AI-controlled
43640
+ * characters that automatically follow the visitor around the world. They appear as
43641
+ * additional avatars and can be useful for companions, guides, or assistant characters.
43642
+ *
43643
+ * Requirements:
43644
+ * - The visitor must own a user inventory item of type "npc"
43645
+ * - The item must have been granted to the visitor before calling this method
43646
+ * - Only one NPC can exist per visitor per app at a time
43647
+ *
43648
+ * @keywords create, spawn, add, npc, bot, follower, character, assistant, companion
43649
+ *
43650
+ * @category NPCs
43370
43651
  *
43371
- * @param userInventoryItemId The ID of the user's inventory item (must be an NPC type item owned by this visitor).
43372
- * @param options Optional configuration for the NPC.
43373
- * @param options.showNameplate Whether to display a nameplate above the NPC (default: true).
43652
+ * @param userInventoryItemId - The ID of the user's inventory item (must be an NPC type item owned by this visitor)
43653
+ * @param options - Optional configuration for the NPC
43654
+ * @param options.showNameplate - Whether to display a nameplate above the NPC (default: true)
43374
43655
  *
43375
43656
  * @example
43376
43657
  * ```ts
@@ -43384,7 +43665,7 @@ class Visitor extends User {
43384
43665
  * const npc = await visitor.createNpc(userItem.id, { showNameplate: false });
43385
43666
  * ```
43386
43667
  *
43387
- * @returns {Promise<Visitor>} Returns a Visitor object representing the created NPC.
43668
+ * @returns {Promise<Visitor>} Returns a Visitor object representing the created NPC. The NPC will automatically follow the visitor.
43388
43669
  */
43389
43670
  createNpc(userInventoryItemId, options) {
43390
43671
  return __awaiter(this, void 0, void 0, function* () {
@@ -43401,11 +43682,25 @@ class Visitor extends User {
43401
43682
  });
43402
43683
  }
43403
43684
  /**
43404
- * Deletes the NPC this app has assigned to this visitor.
43685
+ * Deletes the NPC (Non-Player Character) this app has assigned to this visitor.
43686
+ *
43687
+ * @remarks
43688
+ * This method removes the NPC associated with this visitor for the current application.
43689
+ * The NPC will immediately disappear from the world. The underlying inventory item
43690
+ * is not consumed and can be used to create a new NPC later.
43691
+ *
43692
+ * @keywords delete, remove, destroy, dismiss, despawn, npc, bot, follower, character
43693
+ *
43694
+ * @category NPCs
43405
43695
  *
43406
43696
  * @example
43407
43697
  * ```ts
43408
- * await visitor.deleteNpc();
43698
+ * // Check if NPC exists before deleting
43699
+ * const npc = await visitor.getNpc();
43700
+ * if (npc) {
43701
+ * await visitor.deleteNpc();
43702
+ * console.log('NPC removed successfully');
43703
+ * }
43409
43704
  * ```
43410
43705
  *
43411
43706
  * @returns {Promise<void>} Returns nothing if successful.
@@ -43457,15 +43752,32 @@ class Visitor extends User {
43457
43752
  /**
43458
43753
  * Grants an inventory item to this visitor.
43459
43754
  *
43460
- * @param item The InventoryItem to modify.
43461
- * @param quantity The new quantity to set.
43755
+ * @remarks
43756
+ * This method requires that the inventory item is already defined in your application's inventory system.
43757
+ * Each visitor can only be granted an item once. Use modifyInventoryItemQuantity() to adjust quantities
43758
+ * for items the visitor already owns. The grant_source will be set to track where the item came from.
43759
+ *
43760
+ * Important: This method will throw an error if the visitor already owns this inventory item.
43761
+ * Check visitorInventoryItems first or use modifyInventoryItemQuantity() to update existing items.
43762
+ *
43763
+ * @keywords grant, give, add, inventory, item, visitor, award, reward
43764
+ *
43765
+ * @category Inventory
43766
+ *
43767
+ * @param item - The InventoryItem to grant to the visitor
43768
+ * @param quantity - The quantity to grant (default: 1)
43462
43769
  *
43463
43770
  * @example
43464
43771
  * ```ts
43465
- * await visitor.grantInventoryItem("item-id-123", 2);
43772
+ * // First create or fetch the inventory item
43773
+ * const item = await InventoryItem.get("item-id-123");
43774
+ *
43775
+ * // Grant it to the visitor
43776
+ * const userItem = await visitor.grantInventoryItem(item, 2);
43777
+ * console.log(`Granted ${userItem.quantity} items to visitor`);
43466
43778
  * ```
43467
43779
  *
43468
- * @returns {Promise<UserInventoryItem>} Returns the updated inventory item or a response object.
43780
+ * @returns {Promise<UserInventoryItem>} Returns the granted UserInventoryItem with quantity and metadata.
43469
43781
  */
43470
43782
  grantInventoryItem(item, quantity = 1) {
43471
43783
  var _a;
@@ -43531,14 +43843,56 @@ class Visitor extends User {
43531
43843
  }
43532
43844
  _Visitor_visitorInventoryItems = new WeakMap();
43533
43845
 
43846
+ /* ============================================================================
43847
+ AI RULES for code assistants
43848
+
43849
+ CONTEXT
43850
+ - "Controllers" expose operations on domain objects (e.g., WebRTCConnector).
43851
+ - Consumers obtain controller instances via factory methods (e.g., WebRTCConnectorFactory.create).
43852
+ - This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
43853
+
43854
+ DO
43855
+ - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
43856
+ - Use ONLY the methods defined & documented in this file's types/TSDoc.
43857
+
43858
+ DO NOT
43859
+ - Do NOT suggest creating Topia clients or factories inside controllers.
43860
+ - Do NOT suggest non-existent methods: getById, fetch, find
43861
+ - Do NOT mutate controller shape or return ad-hoc fields.
43862
+
43863
+ AVAILABLE METHODS:
43864
+ - getTwilioConfig(): Retrieves Twilio configuration for WebRTC video/audio
43865
+
43866
+ CANONICAL USAGE (consumer app):
43867
+ // utils/topiaInit.ts
43868
+ import { Topia, WebRTCConnectorFactory } from "@rtsdk/topia";
43869
+ const topia = new Topia({ config });
43870
+ export const WebRTC = new WebRTCConnectorFactory(topia);
43871
+
43872
+ // controllers/myController.ts (consumer app)
43873
+ import { WebRTC } from "utils/topiaInit.ts";
43874
+ const webrtc = await WebRTC.create(urlSlug, { credentials });
43875
+ await webrtc.getTwilioConfig();
43876
+
43877
+ ============================================================================ */
43534
43878
  /**
43535
- * Create an instance of WebRTCConnector class with optional session credentials.
43879
+ * WebRTC connector for managing real-time video and audio connections in Topia worlds.
43880
+ *
43881
+ * @remarks
43882
+ * This class should NOT be instantiated directly. Use WebRTCConnectorFactory to create instances.
43883
+ * The WebRTCConnector provides access to Twilio configuration needed for establishing
43884
+ * peer-to-peer video and audio connections between visitors in a world.
43885
+ *
43886
+ * @see WebRTCConnectorFactory for proper instantiation
43887
+ *
43888
+ * @keywords webrtc, video, audio, twilio, real-time, communication, voice, peer
43536
43889
  *
43537
43890
  * @example
43538
43891
  * ```ts
43539
- * const webRTC = await new WebRTCConnector(topia, {
43540
- * credentials: { interactivePublicKey: "examplePublicKey", interactiveNonce: "exampleNonce", assetId: "exampleDroppedAssetId", profileId: "exampleProfileId", visitorId: 1, urlSlug: "exampleUrlSlug" }
43541
- * });
43892
+ * import { WebRTC } from "utils/topiaInit.ts";
43893
+ *
43894
+ * const webrtc = await WebRTC.create(urlSlug, { credentials });
43895
+ * const config = await webrtc.getTwilioConfig();
43542
43896
  * ```
43543
43897
  */
43544
43898
  class WebRTCConnector extends SDKController {
@@ -43549,12 +43903,25 @@ class WebRTCConnector extends SDKController {
43549
43903
  this.urlSlug = urlSlug;
43550
43904
  }
43551
43905
  /**
43552
- * Get twilio
43906
+ * Retrieves the Twilio configuration for WebRTC connections in a world.
43907
+ *
43908
+ * @remarks
43909
+ * This method fetches the Twilio room configuration needed to establish peer-to-peer
43910
+ * video and audio connections between visitors. The configuration includes authentication
43911
+ * tokens and room settings. Call this before initializing WebRTC connections.
43912
+ *
43913
+ * @keywords get, fetch, retrieve, webrtc, twilio, configuration, video, audio, connection
43914
+ *
43915
+ * @category WebRTC
43553
43916
  *
43554
43917
  * @example
43555
43918
  * ```ts
43556
43919
  * await webRTCConnector.getTwilioConfig();
43920
+ * const { twilioConfig } = webRTCConnector;
43921
+ * console.log(twilioConfig); // Use for WebRTC setup
43557
43922
  * ```
43923
+ *
43924
+ * @returns {Promise<void | ResponseType>} Populates twilioConfig property with Twilio room configuration, or returns an error response.
43558
43925
  */
43559
43926
  getTwilioConfig() {
43560
43927
  return __awaiter(this, void 0, void 0, function* () {
@@ -43577,6 +43944,7 @@ AI RULES for code assistants
43577
43944
  CONTEXT
43578
43945
  - "Controllers" expose operations on domain objects (e.g., WorldActivity).
43579
43946
  - Consumers obtain controller instances via factory methods (e.g., WorldActivityFactory.get).
43947
+ - This SDK is installed as an NPM package (@rtsdk/topia) in consumer applications.
43580
43948
 
43581
43949
  DO
43582
43950
  - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
@@ -43587,6 +43955,12 @@ AI RULES for code assistants
43587
43955
  - Do NOT suggest non-existent methods: getById, fetch, find
43588
43956
  - Do NOT mutate controller shape or return ad-hoc fields.
43589
43957
 
43958
+ AVAILABLE METHODS:
43959
+ - currentVisitors(shouldIncludeAdminPermissions?): Retrieves all visitors currently in the world
43960
+ - fetchVisitorsInZone(options): Gets visitors in a specific landmark zone
43961
+ - moveAllVisitors(options): Moves all visitors to specified coordinates
43962
+ - moveVisitors(visitorsToMove): Moves specific visitors to various coordinates
43963
+
43590
43964
  CANONICAL USAGE (consumer app):
43591
43965
  // utils/topiaInit.ts
43592
43966
  import { Topia, WorldActivityFactory } from "@rtsdk/topia";