@rtsdk/topia 0.17.7 → 0.17.9

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
@@ -39710,14 +39710,44 @@ class SDKController {
39710
39710
  }
39711
39711
  }
39712
39712
 
39713
+ /* ============================================================================
39714
+ AI RULES for code assistants
39715
+
39716
+ CONTEXT
39717
+ - "Controllers" expose operations on domain objects (e.g., Asset).
39718
+ - Consumers obtain controller instances via factory methods (e.g., AssetFactory.get).
39719
+
39720
+ DO
39721
+ - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
39722
+ - Use ONLY the methods defined & documented in this file's types/TSDoc.
39723
+
39724
+ DO NOT
39725
+ - Do NOT suggest creating Topia clients or factories inside controllers.
39726
+ - Do NOT suggest non-existent methods: getById, fetch, find
39727
+ - Do NOT mutate controller shape or return ad-hoc fields.
39728
+
39729
+ CANONICAL USAGE (consumer app):
39730
+ // utils/topiaInit.ts
39731
+ import { Topia, AssetFactory } from "@rtsdk/topia";
39732
+ const topia = new Topia({ config });
39733
+ export const Asset = new AssetFactory(topia);
39734
+
39735
+ // controllers/myController.ts (consumer app)
39736
+ import { Asset } from "utils/topiaInit.ts";
39737
+ const asset = await Asset.create(assetId, { credentials });
39738
+ await asset.fetchAssetById();
39739
+
39740
+ ============================================================================ */
39713
39741
  /**
39714
39742
  * Create an instance of Asset class with a given asset id and optional attributes and session credentials.
39715
39743
  *
39716
39744
  * @example
39717
39745
  * ```ts
39718
- * const asset = await new Asset(topia, "id", {
39746
+ * import { Asset } from "utils/topiaInit.ts";
39747
+ *
39748
+ * const asset = await Asset.create(assetId, {
39719
39749
  * attributes: { assetName: "My Asset", isPublic: false },
39720
- * credentials: { interactiveNonce: "exampleNonce", assetId: "droppedAssetId", visitorId: 1, urlSlug: "exampleWorld" }
39750
+ * credentials: { interactivePublicKey: "examplePublicKey", interactiveNonce: "exampleNonce", assetId: "exampleDroppedAssetId", visitorId: 1, urlSlug: "exampleUrlSlug" }
39721
39751
  * });
39722
39752
  * ```
39723
39753
  */
@@ -39731,6 +39761,8 @@ class Asset extends SDKController {
39731
39761
  /**
39732
39762
  * Retrieves platform asset details and assigns response data to the instance.
39733
39763
  *
39764
+ * @keywords get, fetch, retrieve, load, details, info, information
39765
+ *
39734
39766
  * @example
39735
39767
  * ```ts
39736
39768
  * await asset.fetchAssetById();
@@ -39754,6 +39786,8 @@ class Asset extends SDKController {
39754
39786
  /**
39755
39787
  * Updates platform asset details.
39756
39788
  *
39789
+ * @keywords update, modify, change, edit, alter, transform
39790
+ *
39757
39791
  * @example
39758
39792
  * ```ts
39759
39793
  * await asset.updateAsset({
@@ -39847,14 +39881,43 @@ const scatterVisitors = (original, scatterBy) => {
39847
39881
  };
39848
39882
 
39849
39883
  var _DroppedAsset_updateDroppedAsset;
39884
+ /* ============================================================================
39885
+ AI RULES for code assistants
39886
+
39887
+ CONTEXT
39888
+ - "Controllers" expose operations on domain objects (e.g., DroppedAsset).
39889
+ - Consumers obtain controller instances via factory methods (e.g., DroppedAssetFactory.get).
39890
+
39891
+ DO
39892
+ - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
39893
+ - Use ONLY the methods defined & documented in this file's types/TSDoc.
39894
+
39895
+ DO NOT
39896
+ - Do NOT suggest creating Topia clients or factories inside controllers.
39897
+ - Do NOT suggest non-existent methods: getById, fetch, find
39898
+ - Do NOT mutate controller shape or return ad-hoc fields.
39899
+
39900
+ CANONICAL USAGE (consumer app):
39901
+ // utils/topiaInit.ts
39902
+ import { Topia, DroppedAssetFactory } from "@rtsdk/topia";
39903
+ const topia = new Topia({ config });
39904
+ export const DroppedAsset = new DroppedAssetFactory(topia);
39905
+
39906
+ // controllers/myController.ts (consumer app)
39907
+ import { DroppedAsset } from "utils/topiaInit.ts";
39908
+ const da = await DroppedAsset.get(droppedAssetId, urlSlug, { credentials });
39909
+ await da.fetchDataObject();
39910
+
39911
+ ============================================================================ */
39850
39912
  /**
39851
39913
  * Create an instance of Dropped Asset class with a given dropped asset id, url slug, and optional attributes and session credentials.
39852
39914
  *
39853
39915
  * @example
39854
39916
  * ```ts
39855
- * const droppedAsset = await new DroppedAsset(topia, "1giFZb0sQ3X27L7uGyQX", "example", {
39856
- * attributes: { text: "My Dropped Asset" },
39857
- * credentials: { interactiveNonce: "exampleNonce", assetId: "droppedAssetId", visitorId: 1, urlSlug: "exampleWorld" }
39917
+ * import { DroppedAsset } from "utils/topiaInit.ts";
39918
+ *
39919
+ * const droppedAsset = await DroppedAsset.get(exampleDroppedAssetId, exampleUrlSlug, {
39920
+ * credentials: { interactivePublicKey: "examplePublicKey", interactiveNonce: "exampleNonce", assetId: "exampleDroppedAssetId", visitorId: 1, urlSlug: "exampleUrlSlug" }
39858
39921
  * });
39859
39922
  * ```
39860
39923
  */
@@ -39882,6 +39945,8 @@ class DroppedAsset extends Asset {
39882
39945
  /**
39883
39946
  * Retrieves dropped asset details and assigns response data to the instance.
39884
39947
  *
39948
+ * @keywords get, fetch, retrieve, load, details, info, information
39949
+ *
39885
39950
  * @example
39886
39951
  * ```ts
39887
39952
  * await droppedAsset.fetchDroppedAssetById();
@@ -39904,6 +39969,8 @@ class DroppedAsset extends Asset {
39904
39969
  /**
39905
39970
  * Updates dropped asset details and assigns the response data to the instance. Requires Public Key to have the `canUpdateDroppedAssets` permission.
39906
39971
  *
39972
+ * @keywords update, modify, change, edit, alter, transform
39973
+ *
39907
39974
  * @example
39908
39975
  * ```ts
39909
39976
  * const payload = {
@@ -39978,6 +40045,8 @@ class DroppedAsset extends Asset {
39978
40045
  /**
39979
40046
  * Deletes the dropped asset (removes it from the world).
39980
40047
  *
40048
+ * @keywords remove, delete, erase, destroy, eliminate
40049
+ *
39981
40050
  * @example
39982
40051
  * ```ts
39983
40052
  * await droppedAsset.deleteDroppedAsset();
@@ -39996,6 +40065,8 @@ class DroppedAsset extends Asset {
39996
40065
  /**
39997
40066
  * Retrieves the data object for a dropped asset.
39998
40067
  *
40068
+ * @keywords get, fetch, retrieve, load, data, object, state
40069
+ *
39999
40070
  * @category Data Objects
40000
40071
  *
40001
40072
  * @example
@@ -40028,6 +40099,8 @@ class DroppedAsset extends Asset {
40028
40099
  * @remarks
40029
40100
  * Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
40030
40101
  *
40102
+ * @keywords set, assign, store, save, data, object, state
40103
+ *
40031
40104
  * @category Data Objects
40032
40105
  *
40033
40106
  * @example
@@ -40060,6 +40133,8 @@ class DroppedAsset extends Asset {
40060
40133
  * @remarks
40061
40134
  * Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
40062
40135
  *
40136
+ * @keywords update, modify, change, edit, alter, data, object, state
40137
+ *
40063
40138
  * @category Data Objects
40064
40139
  *
40065
40140
  * @example
@@ -40089,6 +40164,8 @@ class DroppedAsset extends Asset {
40089
40164
  * @remarks
40090
40165
  * Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id
40091
40166
  *
40167
+ * @keywords increment, increase, add, count, data, object, state
40168
+ *
40092
40169
  * @category Data Objects
40093
40170
  *
40094
40171
  * @example
@@ -40113,6 +40190,8 @@ class DroppedAsset extends Asset {
40113
40190
  /**
40114
40191
  * Updates broadcast options for a dropped asset.
40115
40192
  *
40193
+ * @keywords broadcast, dropped asset settings
40194
+ *
40116
40195
  * @example
40117
40196
  * ```ts
40118
40197
  * await droppedAsset.updateBroadcast({
@@ -40136,6 +40215,8 @@ class DroppedAsset extends Asset {
40136
40215
  /**
40137
40216
  * Updates click options for a dropped asset.
40138
40217
  *
40218
+ * @keywords click, link, interaction, url, dropped asset settings
40219
+ *
40139
40220
  * @example
40140
40221
  * ```ts
40141
40222
  * await droppedAsset.updateClickType({
@@ -40176,6 +40257,8 @@ class DroppedAsset extends Asset {
40176
40257
  /**
40177
40258
  * Adds an array of links to an asset. Maximum is 20 links.
40178
40259
  *
40260
+ * @keywords links, multiple, clickable, urls, hyperlinks, dropped asset settings
40261
+ *
40179
40262
  * @example
40180
40263
  * ```ts
40181
40264
  * await droppedAsset.setClickableLinkMulti({
@@ -40216,6 +40299,8 @@ class DroppedAsset extends Asset {
40216
40299
  * @remarks
40217
40300
  * Pass in an 'existingLinkId' to edit an existing link.
40218
40301
  *
40302
+ * @keywords links, multiple, clickable, urls, dropped asset settings
40303
+ *
40219
40304
  * @example
40220
40305
  * ```ts
40221
40306
  * await droppedAsset.updateClickableLinkMulti({
@@ -40249,6 +40334,8 @@ class DroppedAsset extends Asset {
40249
40334
  /**
40250
40335
  * Removes a clickable link from a dropped asset.
40251
40336
  *
40337
+ * @keywords remove, delete, link, clickable, url, erase, dropped asset settings
40338
+ *
40252
40339
  * @example
40253
40340
  * ```ts
40254
40341
  * await droppedAsset.removeClickableLink({ linkId: "link-id" });
@@ -40270,6 +40357,8 @@ class DroppedAsset extends Asset {
40270
40357
  /**
40271
40358
  * Updates text and style of a dropped asset.
40272
40359
  *
40360
+ * @keywords text, style, dropped asset settings
40361
+ *
40273
40362
  * @example
40274
40363
  * ```ts
40275
40364
  * const style = {
@@ -40296,6 +40385,8 @@ class DroppedAsset extends Asset {
40296
40385
  /**
40297
40386
  * Updates media options for a dropped asset.
40298
40387
  *
40388
+ * @keywords media, video, audio, dropped asset settings
40389
+ *
40299
40390
  * @example
40300
40391
  * ```ts
40301
40392
  * await droppedAsset.updateMediaType({
@@ -40333,6 +40424,8 @@ class DroppedAsset extends Asset {
40333
40424
  /**
40334
40425
  * Updates mute zone options for a dropped asset.
40335
40426
  *
40427
+ * @keywords mute, zone, dropped asset settings
40428
+ *
40336
40429
  * @example
40337
40430
  * ```ts
40338
40431
  * await droppedAsset.updateMuteZone(true);
@@ -40351,6 +40444,8 @@ class DroppedAsset extends Asset {
40351
40444
  /**
40352
40445
  * Updates landmark zone options for a dropped asset.
40353
40446
  *
40447
+ * @keywords landmark, zone, dropped asset settings
40448
+ *
40354
40449
  * @example
40355
40450
  * ```ts
40356
40451
  * await droppedAsset.updateLandmarkZone({
@@ -40374,6 +40469,8 @@ class DroppedAsset extends Asset {
40374
40469
  /**
40375
40470
  * Updates webhook zone options for a dropped asset.
40376
40471
  *
40472
+ * @keywords webhook, zone, dropped asset settings
40473
+ *
40377
40474
  * @example
40378
40475
  * ```ts
40379
40476
  * await droppedAsset.updateWebhookZone(true);
@@ -40392,6 +40489,8 @@ class DroppedAsset extends Asset {
40392
40489
  /**
40393
40490
  * Moves a dropped asset to specified coordinates.
40394
40491
  *
40492
+ * @keywords position, dropped asset settings
40493
+ *
40395
40494
  * @example
40396
40495
  * ```ts
40397
40496
  * await droppedAsset.updatePosition(100, 200, 100);
@@ -40411,6 +40510,8 @@ class DroppedAsset extends Asset {
40411
40510
  /**
40412
40511
  * Updates private zone options for a dropped asset.
40413
40512
  *
40513
+ * @keywords private, zone, dropped asset settings
40514
+ *
40414
40515
  * @example
40415
40516
  * ```ts
40416
40517
  * await droppedAsset.updatePrivateZone({
@@ -40434,6 +40535,8 @@ class DroppedAsset extends Asset {
40434
40535
  /**
40435
40536
  * Updates the size of a dropped asset.
40436
40537
  *
40538
+ * @keywords size, scale, dropped asset settings
40539
+ *
40437
40540
  * @example
40438
40541
  * ```ts
40439
40542
  * await droppedAsset.assetScale(.5);
@@ -40452,6 +40555,8 @@ class DroppedAsset extends Asset {
40452
40555
  /**
40453
40556
  * Flip an dropped asset.
40454
40557
  *
40558
+ * @keywords flip, layout, dropped asset settings
40559
+ *
40455
40560
  * @example
40456
40561
  * ```ts
40457
40562
  * await droppedAsset.flip(.5);
@@ -40470,6 +40575,8 @@ class DroppedAsset extends Asset {
40470
40575
  /**
40471
40576
  * Change or remove media embedded in a dropped asset.
40472
40577
  *
40578
+ * @keywords media, update, dropped asset settings
40579
+ *
40473
40580
  * @example
40474
40581
  * ```ts
40475
40582
  * await droppedAsset.updateUploadedMediaSelected("LVWyxwNxI96eLjnXWwYO");
@@ -40488,6 +40595,8 @@ class DroppedAsset extends Asset {
40488
40595
  /**
40489
40596
  * Change or remove top and bottom layers of a dropped asset.
40490
40597
  *
40598
+ * @keywords layers, images, urls, dropped asset settings
40599
+ *
40491
40600
  * @example
40492
40601
  * ```ts
40493
40602
  * await droppedAsset.updateWebImageLayers("","https://www.shutterstock.com/image-vector/colorful-illustration-test-word-260nw-1438324490.jpg");
@@ -40507,6 +40616,8 @@ class DroppedAsset extends Asset {
40507
40616
  /**
40508
40617
  * Add a webhook to a dropped asset
40509
40618
  *
40619
+ * @keywords webhook, dropped asset settings
40620
+ *
40510
40621
  * @example
40511
40622
  * ```ts
40512
40623
  * await droppedAsset.addWebhook({
@@ -40546,6 +40657,8 @@ class DroppedAsset extends Asset {
40546
40657
  /**
40547
40658
  * Set the interactive settings on a dropped asset
40548
40659
  *
40660
+ * @keywords interactive, dropped asset settings
40661
+ *
40549
40662
  * @example
40550
40663
  * ```ts
40551
40664
  * await droppedAsset.setInteractiveSettings({
@@ -40573,6 +40686,8 @@ class DroppedAsset extends Asset {
40573
40686
  /**
40574
40687
  * Retrieve analytics for a dropped asset by day, week, month, quarter, or year
40575
40688
  *
40689
+ * @keywords get, fetch, retrieve, load, analytics
40690
+ *
40576
40691
  * @example
40577
40692
  * ```ts
40578
40693
  * const analytics = await droppedAsset.fetchDroppedAssetAnalytics({
@@ -40616,13 +40731,43 @@ class DroppedAsset extends Asset {
40616
40731
  }
40617
40732
  _DroppedAsset_updateDroppedAsset = new WeakMap();
40618
40733
 
40734
+ /* ============================================================================
40735
+ AI RULES for code assistants
40736
+
40737
+ CONTEXT
40738
+ - "Controllers" expose operations on domain objects (e.g., Ecosystem).
40739
+ - Consumers obtain controller instances via factory methods (e.g., EcosystemFactory.get).
40740
+
40741
+ DO
40742
+ - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
40743
+ - Use ONLY the methods defined & documented in this file's types/TSDoc.
40744
+
40745
+ DO NOT
40746
+ - Do NOT suggest creating Topia clients or factories inside controllers.
40747
+ - Do NOT suggest non-existent methods: getById, fetch, find
40748
+ - Do NOT mutate controller shape or return ad-hoc fields.
40749
+
40750
+ CANONICAL USAGE (consumer app):
40751
+ // utils/topiaInit.ts
40752
+ import { Topia, Ecosystem } from "@rtsdk/topia";
40753
+ const topia = new Topia({ config });
40754
+ export const Ecosystem = new EcosystemFactory(topia);
40755
+
40756
+ // controllers/myController.ts (consumer app)
40757
+ import { Ecosystem } from "utils/topiaInit.ts";
40758
+ const ecosystem = await Ecosystem.create({ credentials });
40759
+ await ecosystem.fetchDataObject();
40760
+
40761
+ ============================================================================ */
40619
40762
  /**
40620
40763
  * Create an instance of Ecosystem class with optional session credentials
40621
40764
  *
40622
40765
  * @example
40623
40766
  * ```ts
40624
- * const ecosystem =await new Ecosystem(topia, {
40625
- * credentials: { interactiveNonce: "exampleNonce", assetId: "droppedAssetId", visitorId: 1, urlSlug: "exampleWorld" }
40767
+ * import { Ecosystem } from "utils/topiaInit.ts";
40768
+ *
40769
+ * const ecosystem = await Ecosystem.create({
40770
+ * credentials: { interactivePublicKey: "examplePublicKey", interactiveNonce: "exampleNonce", assetId: "exampleDroppedAssetId", visitorId: 1, urlSlug: "exampleUrlSlug" }
40626
40771
  * });
40627
40772
  * ```
40628
40773
  */
@@ -40634,6 +40779,8 @@ class Ecosystem extends SDKController {
40634
40779
  /**
40635
40780
  * Retrieves the data object for a Topia ecosystem. Requires canUpdateEcosystemDataObjects permission to be set to true for the public key.
40636
40781
  *
40782
+ * @keywords get, fetch, retrieve, load, data, object, state
40783
+ *
40637
40784
  * @category Data Objects
40638
40785
  *
40639
40786
  * @example
@@ -40668,6 +40815,8 @@ class Ecosystem extends SDKController {
40668
40815
  *
40669
40816
  * 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
40670
40817
  *
40818
+ * @keywords set, assign, store, save, data, object, state
40819
+ *
40671
40820
  * @category Data Objects
40672
40821
  *
40673
40822
  * @example
@@ -40698,6 +40847,8 @@ class Ecosystem extends SDKController {
40698
40847
  *
40699
40848
  * 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
40700
40849
  *
40850
+ * @keywords update, modify, change, edit, alter, data, object, state
40851
+ *
40701
40852
  * @category Data Objects
40702
40853
  *
40703
40854
  * @example
@@ -40734,6 +40885,8 @@ class Ecosystem extends SDKController {
40734
40885
  *
40735
40886
  * 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
40736
40887
  *
40888
+ * @keywords increment, increase, add, count, data, object, state
40889
+ *
40737
40890
  * @category Data Objects
40738
40891
  *
40739
40892
  * @example
@@ -40760,14 +40913,43 @@ class Ecosystem extends SDKController {
40760
40913
  }
40761
40914
  }
40762
40915
 
40916
+ /* ============================================================================
40917
+ AI RULES for code assistants
40918
+
40919
+ CONTEXT
40920
+ - "Controllers" expose operations on domain objects (e.g., Scene).
40921
+ - Consumers obtain controller instances via factory methods (e.g., SceneFactory.get).
40922
+
40923
+ DO
40924
+ - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
40925
+ - Use ONLY the methods defined & documented in this file's types/TSDoc.
40926
+
40927
+ DO NOT
40928
+ - Do NOT suggest creating Topia clients or factories inside controllers.
40929
+ - Do NOT suggest non-existent methods: getById, fetch, find
40930
+ - Do NOT mutate controller shape or return ad-hoc fields.
40931
+
40932
+ CANONICAL USAGE (consumer app):
40933
+ // utils/topiaInit.ts
40934
+ import { Topia, SceneFactory } from "@rtsdk/topia";
40935
+ const topia = new Topia({ config });
40936
+ export const Scene = new SceneFactory(topia);
40937
+
40938
+ // controllers/myController.ts (consumer app)
40939
+ import { Scene } from "utils/topiaInit.ts";
40940
+ const scene = await Scene.get(sceneId, { credentials });
40941
+
40942
+ ============================================================================ */
40763
40943
  /**
40764
40944
  * Create an instance of Scene class with a given scene id and optional attributes and session credentials.
40765
40945
  *
40766
40946
  * @example
40767
40947
  * ```ts
40768
- * const scene = await new Scene(topia, "sceneId", {
40948
+ * import { Scene } from "utils/topiaInit.ts";
40949
+ *
40950
+ * const scene = await Scene.get(exampleSceneId, {
40769
40951
  * attributes: { name: "My Scene" },
40770
- * credentials: { interactiveNonce: "exampleNonce", assetId: "droppedAssetId", visitorId: 1, urlSlug: "exampleWorld" }
40952
+ * credentials: { interactivePublicKey: "examplePublicKey", interactiveNonce: "exampleNonce", assetId: "exampleDroppedAssetId", visitorId: 1, urlSlug: "exampleUrlSlug" }
40771
40953
  * });
40772
40954
  * ```
40773
40955
  */
@@ -40780,6 +40962,8 @@ class Scene extends SDKController {
40780
40962
  /**
40781
40963
  * Retrieves scene details and assigns response data to the instance.
40782
40964
  *
40965
+ * @keywords get, fetch, retrieve, load, details, info, information, scene
40966
+ *
40783
40967
  * @example
40784
40968
  * ```ts
40785
40969
  * await scene.fetchSceneById();
@@ -40837,14 +41021,44 @@ class Topia {
40837
41021
  }
40838
41022
 
40839
41023
  var _World_droppedAssetsMap;
41024
+ /* ============================================================================
41025
+ AI RULES for code assistants
41026
+
41027
+ CONTEXT
41028
+ - "Controllers" expose operations on domain objects (e.g., World).
41029
+ - Consumers obtain controller instances via factory methods (e.g., WorldFactory.get).
41030
+
41031
+ DO
41032
+ - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
41033
+ - Use ONLY the methods defined & documented in this file's types/TSDoc.
41034
+
41035
+ DO NOT
41036
+ - Do NOT suggest creating Topia clients or factories inside controllers.
41037
+ - Do NOT suggest non-existent methods: getById, fetch, find
41038
+ - Do NOT mutate controller shape or return ad-hoc fields.
41039
+
41040
+ CANONICAL USAGE (consumer app):
41041
+ // utils/topiaInit.ts
41042
+ import { Topia, WorldFactory } from "@rtsdk/topia";
41043
+ const topia = new Topia({ config });
41044
+ export const World = new WorldFactory(topia);
41045
+
41046
+ // controllers/myController.ts (consumer app)
41047
+ import { World } from "utils/topiaInit.ts";
41048
+ const world = await World.create(urlSlug, { credentials });
41049
+ await world.fetchDetails();
41050
+
41051
+ ============================================================================ */
40840
41052
  /**
40841
41053
  * Create an instance of World class with a given url slug and optional attributes and session credentials.
40842
41054
  *
40843
41055
  * @example
40844
41056
  * ```ts
40845
- * const world = await new World(topia, "exampleWorld", {
41057
+ * import { World } from "utils/topiaInit.ts";
41058
+ *
41059
+ * const world = await World.create(exampleUrlSlug, {
40846
41060
  * attributes: { name: "Example World" },
40847
- * credentials: { interactiveNonce: "exampleNonce", assetId: "droppedAssetId", visitorId: 1, urlSlug: "exampleWorld" }
41061
+ * credentials: { interactivePublicKey: "examplePublicKey", interactiveNonce: "exampleNonce", assetId: "exampleDroppedAssetId", visitorId: 1, urlSlug: "exampleUrlSlug" }
40848
41062
  * });
40849
41063
  * ```
40850
41064
  */
@@ -40857,6 +41071,8 @@ class World extends SDKController {
40857
41071
  /**
40858
41072
  * Retrieves the data object for a world. Must have valid interactive credentials from a visitor in the world.
40859
41073
  *
41074
+ * @keywords get, fetch, retrieve, load, data, object, state
41075
+ *
40860
41076
  * @category Data Objects
40861
41077
  *
40862
41078
  * @example
@@ -40886,6 +41102,8 @@ class World extends SDKController {
40886
41102
  * @remarks
40887
41103
  * 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
40888
41104
  *
41105
+ * @keywords set, assign, store, save, data, object, state
41106
+ *
40889
41107
  * @category Data Objects
40890
41108
  *
40891
41109
  * @example
@@ -40915,6 +41133,8 @@ class World extends SDKController {
40915
41133
  * @remarks
40916
41134
  * 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
40917
41135
  *
41136
+ * @keywords update, modify, change, edit, alter, data, object, state
41137
+ *
40918
41138
  * @category Data Objects
40919
41139
  *
40920
41140
  * @example
@@ -40946,6 +41166,8 @@ class World extends SDKController {
40946
41166
  /**
40947
41167
  * Retrieves details of a world.
40948
41168
  *
41169
+ * @keywords get, fetch, retrieve, details, info, information, world
41170
+ *
40949
41171
  * @example
40950
41172
  * ```ts
40951
41173
  * await world.fetchDetails();
@@ -40966,6 +41188,8 @@ class World extends SDKController {
40966
41188
  /**
40967
41189
  * Update details of a world.
40968
41190
  *
41191
+ * @keywords update, modify, change, edit, world, settings, details
41192
+ *
40969
41193
  * @example
40970
41194
  * ```ts
40971
41195
  * await world.updateDetails({
@@ -41010,6 +41234,8 @@ class World extends SDKController {
41010
41234
  /**
41011
41235
  * Set close world settings
41012
41236
  *
41237
+ * @keywords update, modify, change, edit, world, settings, details, close, closed
41238
+ *
41013
41239
  * @example
41014
41240
  * ```ts
41015
41241
  * await world.updateCloseWorldSettings({
@@ -41049,6 +41275,8 @@ class World extends SDKController {
41049
41275
  /**
41050
41276
  * Retrieve all assets dropped in a world.
41051
41277
  *
41278
+ * @keywords get, fetch, retrieve, list, current, dropped assets
41279
+ *
41052
41280
  * @category Dropped Assets
41053
41281
  *
41054
41282
  * @example
@@ -41079,6 +41307,8 @@ class World extends SDKController {
41079
41307
  /**
41080
41308
  * Retrieve all assets dropped in a world matching uniqueName.
41081
41309
  *
41310
+ * @keywords get, fetch, retrieve, list, current, dropped assets, uniqueName
41311
+ *
41082
41312
  * @category Dropped Assets
41083
41313
  *
41084
41314
  * @example
@@ -41113,6 +41343,8 @@ class World extends SDKController {
41113
41343
  /**
41114
41344
  * Retrieve all assets dropped in a world matching sceneDropId.
41115
41345
  *
41346
+ * @keywords get, fetch, retrieve, list, current, dropped assets, sceneDropId
41347
+ *
41116
41348
  * @category Dropped Assets
41117
41349
  *
41118
41350
  * @example
@@ -41153,6 +41385,8 @@ class World extends SDKController {
41153
41385
  /**
41154
41386
  * Update multiple custom text dropped assets with a single style while preserving text for specified dropped assets only.
41155
41387
  *
41388
+ * @keywords update, modify, change, edit, dropped assets, custom text, style, text
41389
+ *
41156
41390
  * @category Dropped Assets
41157
41391
  *
41158
41392
  * @example
@@ -41184,6 +41418,8 @@ class World extends SDKController {
41184
41418
  /**
41185
41419
  * Retrieve all landmark zone assets dropped in a world.
41186
41420
  *
41421
+ * @keywords get, fetch, retrieve, list, landmark, zones, dropped assets
41422
+ *
41187
41423
  * @category Dropped Assets
41188
41424
  *
41189
41425
  * @example
@@ -41255,6 +41491,8 @@ class World extends SDKController {
41255
41491
  /**
41256
41492
  * Fetch a list of all scene drop ids and dropped assets in a world
41257
41493
  *
41494
+ * @keywords get, fetch, retrieve, list, scenes
41495
+ *
41258
41496
  * @category Scenes
41259
41497
  *
41260
41498
  * @example
@@ -41296,6 +41534,8 @@ class World extends SDKController {
41296
41534
  /**
41297
41535
  * Drops a scene in a world and returns sceneDropId.
41298
41536
  *
41537
+ * @keywords drop, add, place, scene
41538
+ *
41299
41539
  * @category Scenes
41300
41540
  *
41301
41541
  * @example
@@ -41330,6 +41570,8 @@ class World extends SDKController {
41330
41570
  /**
41331
41571
  * Replace the current scene of a world.
41332
41572
  *
41573
+ * @keywords replace, change, scene
41574
+ *
41333
41575
  * @category Scenes
41334
41576
  *
41335
41577
  * @example
@@ -41360,6 +41602,8 @@ class World extends SDKController {
41360
41602
  /**
41361
41603
  * Get all particles available
41362
41604
  *
41605
+ * @keywords get, fetch, retrieve, list, particles
41606
+ *
41363
41607
  * @category Particles
41364
41608
  *
41365
41609
  * @example
@@ -41383,6 +41627,8 @@ class World extends SDKController {
41383
41627
  /**
41384
41628
  * Trigger a particle effect at a position in the world
41385
41629
  *
41630
+ * @keywords trigger, start, play, particle, effect
41631
+ *
41386
41632
  * @category Particles
41387
41633
  *
41388
41634
  * @example
@@ -41419,6 +41665,8 @@ class World extends SDKController {
41419
41665
  * Add an activity to a world
41420
41666
  * excludeFromNotification is an array of visitorIds to exclude from the notification
41421
41667
  *
41668
+ * @keywords start, trigger, activity
41669
+ *
41422
41670
  * @example
41423
41671
  * ```ts
41424
41672
  * await world.triggerActivity({ type: "GAME_ON", assetId: "abc123" });
@@ -41441,6 +41689,8 @@ class World extends SDKController {
41441
41689
  /**
41442
41690
  * Display a message via a toast to all visitors currently in a world.
41443
41691
  *
41692
+ * @keywords send, display, show, toast, message, notification
41693
+ *
41444
41694
  * @example
41445
41695
  * ```ts
41446
41696
  * await world.fireToast({
@@ -41474,6 +41724,8 @@ class World extends SDKController {
41474
41724
  * @remarks
41475
41725
  * 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
41476
41726
  *
41727
+ * @keywords increment, increase, add, count, data, object, state
41728
+ *
41477
41729
  * @category Data Objects
41478
41730
  *
41479
41731
  * @example
@@ -41499,6 +41751,8 @@ class World extends SDKController {
41499
41751
  /**
41500
41752
  * Retrieve all webhooks in a world.
41501
41753
  *
41754
+ * @keywords get, fetch, retrieve, list, current, webhooks
41755
+ *
41502
41756
  * @category Webhooks
41503
41757
  *
41504
41758
  * @example
@@ -41522,6 +41776,8 @@ class World extends SDKController {
41522
41776
  /**
41523
41777
  * Retrieve world analytics by day, week, month, quarter, or year
41524
41778
  *
41779
+ * @keywords get, fetch, retrieve, analytics, stats, statistics, data, metrics
41780
+ *
41525
41781
  * @category Analytics
41526
41782
  *
41527
41783
  * @example
@@ -41566,14 +41822,44 @@ class World extends SDKController {
41566
41822
  _World_droppedAssetsMap = new WeakMap();
41567
41823
 
41568
41824
  var _User_adminWorldsMap, _User_assetsMap, _User_scenesMap, _User_worldsMap;
41825
+ /* ============================================================================
41826
+ AI RULES for code assistants
41827
+
41828
+ CONTEXT
41829
+ - "Controllers" expose operations on domain objects (e.g., User).
41830
+ - Consumers obtain controller instances via factory methods (e.g., UserFactory.get).
41831
+
41832
+ DO
41833
+ - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
41834
+ - Use ONLY the methods defined & documented in this file's types/TSDoc.
41835
+
41836
+ DO NOT
41837
+ - Do NOT suggest creating Topia clients or factories inside controllers.
41838
+ - Do NOT suggest non-existent methods: getById, fetch, find
41839
+ - Do NOT mutate controller shape or return ad-hoc fields.
41840
+
41841
+ CANONICAL USAGE (consumer app):
41842
+ // utils/topiaInit.ts
41843
+ import { Topia, UserFactory } from "@rtsdk/topia";
41844
+ const topia = new Topia({ config });
41845
+ export const User = new UserFactory(topia);
41846
+
41847
+ // controllers/myController.ts (consumer app)
41848
+ import { User } from "utils/topiaInit.ts";
41849
+ const user = await User.create({ credentials });
41850
+ await user.fetchDataObject();
41851
+
41852
+ ============================================================================ */
41569
41853
  /**
41570
41854
  * Create an instance of User class with optional session credentials.
41571
41855
  *
41572
41856
  * @example
41573
41857
  * ```ts
41574
- * const user = await new User(topia, {
41575
- * profileId: 1,
41576
- * credentials: { interactiveNonce: "exampleNonce", assetId: "droppedAssetId", visitorId: 1, urlSlug: "exampleWorld" }
41858
+ * import { User } from "utils/topiaInit.ts";
41859
+ *
41860
+ * const user = await User.create({
41861
+ * profileId: "exampleProfileId",
41862
+ * credentials: { interactivePublicKey: "examplePublicKey", interactiveNonce: "exampleNonce", assetId: "exampleDroppedAssetId", profileId: "exampleProfileId", visitorId: 1, urlSlug: "exampleUrlSlug" }
41577
41863
  * });
41578
41864
  * ```
41579
41865
  */
@@ -41607,6 +41893,8 @@ class User extends SDKController {
41607
41893
  /*
41608
41894
  * Verify user has valid interactive credentials
41609
41895
  *
41896
+ * @keywords check, verify, validate, credentials, authentication, authorization, interactive
41897
+ *
41610
41898
  * @example
41611
41899
  * ```ts
41612
41900
  * await user.checkInteractiveCredentials();
@@ -41628,6 +41916,8 @@ class User extends SDKController {
41628
41916
  /**
41629
41917
  * Returns all avatars owned by User
41630
41918
  *
41919
+ * @keywords get, fetch, retrieve, list, avatars, characters
41920
+ *
41631
41921
  * @category Avatars
41632
41922
  *
41633
41923
  * @example
@@ -41651,6 +41941,8 @@ class User extends SDKController {
41651
41941
  /**
41652
41942
  * Add a new avatar
41653
41943
  *
41944
+ * @keywords add, create, upload, avatar, character
41945
+ *
41654
41946
  * @category Avatars
41655
41947
  *
41656
41948
  * @example
@@ -41733,6 +42025,8 @@ class User extends SDKController {
41733
42025
  /**
41734
42026
  * Update avatar and sprite sheet records and upload files to existing sprite sheet and avatar storage buckets
41735
42027
  *
42028
+ * @keywords update, modify, change, edit, avatar, character
42029
+ *
41736
42030
  * @category Avatars
41737
42031
  *
41738
42032
  * @example
@@ -41815,6 +42109,8 @@ class User extends SDKController {
41815
42109
  /**
41816
42110
  * Update avatar and sprite sheet records and upload files to existing sprite sheet and avatar storage buckets
41817
42111
  *
42112
+ * @keywords delete, remove, erase, destroy, eliminate, avatar
42113
+ *
41818
42114
  * @category Avatars
41819
42115
  *
41820
42116
  * @example
@@ -41836,6 +42132,8 @@ class User extends SDKController {
41836
42132
  /**
41837
42133
  * Returns all assets owned by User when an email address is provided.
41838
42134
  *
42135
+ * @keywords get, fetch, retrieve, list, user assets, objects
42136
+ *
41839
42137
  * @category Assets
41840
42138
  *
41841
42139
  * @example
@@ -41866,6 +42164,8 @@ class User extends SDKController {
41866
42164
  /**
41867
42165
  * Returns all platform assets.
41868
42166
  *
42167
+ * @keywords get, fetch, retrieve, list, platform assets, objects
42168
+ *
41869
42169
  * @category Assets
41870
42170
  *
41871
42171
  * @example
@@ -41889,6 +42189,8 @@ class User extends SDKController {
41889
42189
  /**
41890
42190
  * Returns all scenes owned by User.
41891
42191
  *
42192
+ * @keywords get, fetch, retrieve, list, user scenes
42193
+ *
41892
42194
  * @category Scenes
41893
42195
  *
41894
42196
  * @example
@@ -41919,6 +42221,8 @@ class User extends SDKController {
41919
42221
  /**
41920
42222
  * Retrieves all worlds owned by user with matching API Key, creates a new World object for each, and creates new map of Worlds accessible via user.worlds.
41921
42223
  *
42224
+ * @keywords get, fetch, retrieve, list, user worlds
42225
+ *
41922
42226
  * @category Worlds
41923
42227
  *
41924
42228
  * @example
@@ -41954,6 +42258,8 @@ class User extends SDKController {
41954
42258
  /**
41955
42259
  * Retrieves all worlds a user with matching API Key is an admin in, creates a new World object for each, and creates new map of Worlds accessible via user.adminWorlds.
41956
42260
  *
42261
+ * @keywords get, fetch, retrieve, list, admin worlds, user worlds
42262
+ *
41957
42263
  * @category Worlds
41958
42264
  *
41959
42265
  * @example
@@ -41983,6 +42289,8 @@ class User extends SDKController {
41983
42289
  /**
41984
42290
  * Retrieves ids of all dropped assets in all worlds with a matching interactivePublicKey.
41985
42291
  *
42292
+ * @keywords get, fetch, retrieve, list, interactive worlds, public key
42293
+ *
41986
42294
  * @category Dropped Assets
41987
42295
  *
41988
42296
  * @example
@@ -42007,6 +42315,8 @@ class User extends SDKController {
42007
42315
  /**
42008
42316
  * Send an email
42009
42317
  *
42318
+ * @keywords send, email, message, notify
42319
+ *
42010
42320
  * @example
42011
42321
  * ```ts
42012
42322
  * const html = `<p><b>Hello World!</b></p><p>This email is being sent from via SDK.</p>`
@@ -42030,6 +42340,8 @@ class User extends SDKController {
42030
42340
  /**
42031
42341
  * Get expressions
42032
42342
  *
42343
+ * @keywords get, fetch, retrieve, list, expressions, emotes
42344
+ *
42033
42345
  * @category Expressions
42034
42346
  *
42035
42347
  * @example
@@ -42056,6 +42368,8 @@ class User extends SDKController {
42056
42368
  /**
42057
42369
  * Retrieves the data object for a user.
42058
42370
  *
42371
+ * @keywords get, fetch, retrieve, load, data, object, state
42372
+ *
42059
42373
  * @category Data Objects
42060
42374
  *
42061
42375
  * @example
@@ -42085,6 +42399,8 @@ class User extends SDKController {
42085
42399
  /**
42086
42400
  * Sets the data object for a user.
42087
42401
  *
42402
+ * @keywords set, assign, store, save, data, object, state
42403
+ *
42088
42404
  * @remarks
42089
42405
  * 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
42090
42406
  *
@@ -42119,6 +42435,8 @@ class User extends SDKController {
42119
42435
  /**
42120
42436
  * Updates the data object for a user.
42121
42437
  *
42438
+ * @keywords update, modify, change, edit, alter, data, object, state
42439
+ *
42122
42440
  * @remarks
42123
42441
  * 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
42124
42442
  *
@@ -42151,6 +42469,8 @@ class User extends SDKController {
42151
42469
  /**
42152
42470
  * Increments a specific value in the data object for a user by the amount specified. Must have valid interactive credentials from a visitor in the world.
42153
42471
  *
42472
+ * @keywords increment, increase, add, count, data, object, state
42473
+ *
42154
42474
  * @remarks
42155
42475
  * 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
42156
42476
  *
@@ -42174,12 +42494,42 @@ class User extends SDKController {
42174
42494
  }
42175
42495
  _User_adminWorldsMap = new WeakMap(), _User_assetsMap = new WeakMap(), _User_scenesMap = new WeakMap(), _User_worldsMap = new WeakMap();
42176
42496
 
42497
+ /* ============================================================================
42498
+ AI RULES for code assistants
42499
+
42500
+ CONTEXT
42501
+ - "Controllers" expose operations on domain objects (e.g., Visitor).
42502
+ - Consumers obtain controller instances via factory methods (e.g., VisitorFactory.get).
42503
+
42504
+ DO
42505
+ - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
42506
+ - Use ONLY the methods defined & documented in this file's types/TSDoc.
42507
+
42508
+ DO NOT
42509
+ - Do NOT suggest creating Topia clients or factories inside controllers.
42510
+ - Do NOT suggest non-existent methods: getById, fetch, find
42511
+ - Do NOT mutate controller shape or return ad-hoc fields.
42512
+
42513
+ CANONICAL USAGE (consumer app):
42514
+ // utils/topiaInit.ts
42515
+ import { Topia, VisitorFactory } from "@rtsdk/topia";
42516
+ const topia = new Topia({ config });
42517
+ export const Visitor = new VisitorFactory(topia);
42518
+
42519
+ // controllers/myController.ts (consumer app)
42520
+ import { Visitor } from "utils/topiaInit.ts";
42521
+ const visitor = await Visitor.get(visitorId, urlSlug, { credentials });
42522
+ await visitor.fetchDataObject();
42523
+
42524
+ ============================================================================ */
42177
42525
  /**
42178
42526
  * Create an instance of Visitor class with a given id and optional attributes and session credentials.
42179
42527
  *
42180
42528
  * @example
42181
42529
  * ```ts
42182
- * const visitor = await new Visitor(topia, id, urlSlug, { attributes: { moveTo: { x: 0, y: 0 } }, credentials: { interactiveNonce: "exampleNonce", assetId: "droppedAssetId", visitorId: 1, urlSlug: "exampleWorld" } });
42530
+ * import { Visitor } from "utils/topiaInit.ts";
42531
+ *
42532
+ * const visitor = await Visitor.get(visitorId, urlSlug, { attributes: { moveTo: { x: 0, y: 0 } }, credentials: { interactivePublicKey: "examplePublicKey", interactiveNonce: "exampleNonce", assetId: "exampleDroppedAssetId", profileId: "exampleProfileId", visitorId: 1, urlSlug: "exampleUrlSlug" } });
42183
42533
  * ```
42184
42534
  */
42185
42535
  class Visitor extends User {
@@ -42192,6 +42542,8 @@ class Visitor extends User {
42192
42542
  /**
42193
42543
  * Get a single visitor from a world
42194
42544
  *
42545
+ * @keywords get, fetch, retrieve, load, visitor, details
42546
+ *
42195
42547
  * @example
42196
42548
  * ```ts
42197
42549
  * await visitor.fetchVisitor();
@@ -42225,6 +42577,8 @@ class Visitor extends User {
42225
42577
  /**
42226
42578
  * Teleport or walk a visitor currently in a world to a single set of coordinates.
42227
42579
  *
42580
+ * @keywords move, teleport, walk, position, coordinate, location, place
42581
+ *
42228
42582
  * @example
42229
42583
  * ```ts
42230
42584
  * await visitor.moveVisitor({
@@ -42257,6 +42611,8 @@ class Visitor extends User {
42257
42611
  /**
42258
42612
  * Display a message via a toast to a visitor currently in a world.
42259
42613
  *
42614
+ * @keywords toast, message, notification, alert, display, show, popup
42615
+ *
42260
42616
  * @example
42261
42617
  * ```ts
42262
42618
  * await visitor.fireToast({
@@ -42287,6 +42643,8 @@ class Visitor extends User {
42287
42643
  /**
42288
42644
  * Open an iframe in a drawer or modal for a visitor currently in a world.
42289
42645
  *
42646
+ * @keywords open, iframe, drawer, modal, link, url, website, web page
42647
+ *
42290
42648
  * @category iframes
42291
42649
  *
42292
42650
  * @example
@@ -42321,6 +42679,8 @@ class Visitor extends User {
42321
42679
  /**
42322
42680
  * Reload an iframe for a visitor currently in a world.
42323
42681
  *
42682
+ * @keywords reload, iframe, drawer, modal, link, url, website, web page
42683
+ *
42324
42684
  * @category iframes
42325
42685
  *
42326
42686
  * @example
@@ -42344,6 +42704,8 @@ class Visitor extends User {
42344
42704
  /**
42345
42705
  * Close an iframe for a visitor currently in a world.
42346
42706
  *
42707
+ * @keywords close, iframe, drawer, modal
42708
+ *
42347
42709
  * @category iframes
42348
42710
  *
42349
42711
  * @example
@@ -42367,6 +42729,8 @@ class Visitor extends User {
42367
42729
  /**
42368
42730
  * Mute and turn video off for a visitor currently in a world.
42369
42731
  *
42732
+ * @keywords mute, video, av, turn off, disable
42733
+ *
42370
42734
  * @example
42371
42735
  * ```ts
42372
42736
  * await visitor.turnAVOff();
@@ -42388,6 +42752,8 @@ class Visitor extends User {
42388
42752
  /**
42389
42753
  * Get expressions
42390
42754
  *
42755
+ * @keywords get, fetch, retrieve, list, expressions, emotes
42756
+ *
42391
42757
  * @category Expressions
42392
42758
  *
42393
42759
  * @example
@@ -42413,6 +42779,8 @@ class Visitor extends User {
42413
42779
  /**
42414
42780
  * Grant expression to a visitor by id or name.
42415
42781
  *
42782
+ * @keywords grant, give, add, expression, emote
42783
+ *
42416
42784
  * @category Expressions
42417
42785
  *
42418
42786
  * @example
@@ -42444,6 +42812,8 @@ class Visitor extends User {
42444
42812
  /**
42445
42813
  * Get all particles available
42446
42814
  *
42815
+ * @keywords get, fetch, retrieve, list, particles, effects
42816
+ *
42447
42817
  * @category Particle Effects
42448
42818
  *
42449
42819
  * @example
@@ -42467,6 +42837,8 @@ class Visitor extends User {
42467
42837
  /**
42468
42838
  * Trigger a particle effect on a visitor
42469
42839
  *
42840
+ * @keywords trigger, particle, effect, spawn, start, play
42841
+ *
42470
42842
  * @category Particle Effects
42471
42843
  *
42472
42844
  * @example
@@ -42500,6 +42872,8 @@ class Visitor extends User {
42500
42872
  /**
42501
42873
  * Retrieves the data object for a visitor.
42502
42874
  *
42875
+ * @keywords get, fetch, retrieve, load, data, object, state
42876
+ *
42503
42877
  * @category Data Objects
42504
42878
  *
42505
42879
  * @example
@@ -42529,6 +42903,8 @@ class Visitor extends User {
42529
42903
  /**
42530
42904
  * Sets the data object for a visitor.
42531
42905
  *
42906
+ * @keywords set, assign, store, save, data, object, state
42907
+ *
42532
42908
  * @remarks
42533
42909
  * 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
42534
42910
  *
@@ -42564,6 +42940,8 @@ class Visitor extends User {
42564
42940
  * @remarks
42565
42941
  * 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
42566
42942
  *
42943
+ * @keywords update, modify, change, edit, alter, data, object, state
42944
+ *
42567
42945
  * @category Data Objects
42568
42946
  *
42569
42947
  * @example
@@ -42594,6 +42972,8 @@ class Visitor extends User {
42594
42972
  * @remarks
42595
42973
  * 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
42596
42974
  *
42975
+ * @keywords increment, increase, add, count, data, object, state
42976
+ *
42597
42977
  * @category Data Objects
42598
42978
  *
42599
42979
  * @example
@@ -42618,6 +42998,8 @@ class Visitor extends User {
42618
42998
  /**
42619
42999
  * Update analytics for a given public key. Must have valid interactive credentials from a visitor in the world.
42620
43000
  *
43001
+ * @keywords update, modify, change, edit, analytics, analytic, stats, statistics, data
43002
+ *
42621
43003
  * @example
42622
43004
  * ```ts
42623
43005
  * await visitor.updatePublicKeyAnalytics([{ analyticName: "joins", profileId, uniqueKey: profileId, urlSlug }]);
@@ -42640,6 +43022,8 @@ class Visitor extends User {
42640
43022
  /**
42641
43023
  * Setup signal to visitor
42642
43024
  *
43025
+ * @keywords signal, webrtc, answer, connect, p2p
43026
+ *
42643
43027
  * @example
42644
43028
  * ```ts
42645
43029
  * await visitor.sendSignalToVisitor(iceServers);
@@ -42668,7 +43052,7 @@ class Visitor extends User {
42668
43052
  * @example
42669
43053
  * ```ts
42670
43054
  * const webRTC = await new WebRTCConnector(topia, {
42671
- * credentials: { interactiveNonce: "exampleNonce", assetId: "droppedAssetId", visitorId: 1, urlSlug: "exampleWorld" }
43055
+ * credentials: { interactivePublicKey: "examplePublicKey", interactiveNonce: "exampleNonce", assetId: "exampleDroppedAssetId", profileId: "exampleProfileId", visitorId: 1, urlSlug: "exampleUrlSlug" }
42672
43056
  * });
42673
43057
  * ```
42674
43058
  */
@@ -42702,6 +43086,34 @@ class WebRTCConnector extends SDKController {
42702
43086
  }
42703
43087
 
42704
43088
  var _WorldActivity_visitorsMap;
43089
+ /* ============================================================================
43090
+ AI RULES for code assistants
43091
+
43092
+ CONTEXT
43093
+ - "Controllers" expose operations on domain objects (e.g., WorldActivity).
43094
+ - Consumers obtain controller instances via factory methods (e.g., WorldActivityFactory.get).
43095
+
43096
+ DO
43097
+ - Expect consumers to import a pre-instantiated factory from their app (e.g., utils/topiaInit.ts).
43098
+ - Use ONLY the methods defined & documented in this file's types/TSDoc.
43099
+
43100
+ DO NOT
43101
+ - Do NOT suggest creating Topia clients or factories inside controllers.
43102
+ - Do NOT suggest non-existent methods: getById, fetch, find
43103
+ - Do NOT mutate controller shape or return ad-hoc fields.
43104
+
43105
+ CANONICAL USAGE (consumer app):
43106
+ // utils/topiaInit.ts
43107
+ import { Topia, WorldActivityFactory } from "@rtsdk/topia";
43108
+ const topia = new Topia({ config });
43109
+ export const WorldActivity = new WorldActivityFactory(topia);
43110
+
43111
+ // controllers/myController.ts (consumer app)
43112
+ import { WorldActivity } from "utils/topiaInit.ts";
43113
+ const activity = await WorldActivity.create(urlSlug, { credentials });
43114
+ await activity.currentVisitors();
43115
+
43116
+ ============================================================================ */
42705
43117
  /**
42706
43118
  * Create an instance of WorldActivity class with a given url slug and optional attributes and session credentials.
42707
43119
  *
@@ -42710,9 +43122,11 @@ var _WorldActivity_visitorsMap;
42710
43122
  *
42711
43123
  * @example
42712
43124
  * ```ts
42713
- * const activity = await new WorldActivity(topia, "exampleWorld", {
43125
+ * import { WorldActivity } from "utils/topiaInit.ts";
43126
+ *
43127
+ * const activity = await WorldActivity.create(urlSlug, {
42714
43128
  * attributes: { name: "Example World" },
42715
- * credentials: { interactiveNonce: "exampleNonce", assetId: "droppedAssetId", visitorId: 1, urlSlug: "exampleWorld" }
43129
+ * credentials: { interactivePublicKey: "examplePublicKey", interactiveNonce: "exampleNonce", assetId: "exampleDroppedAssetId", visitorId: 1, urlSlug: "exampleUrlSlug" }
42716
43130
  * });
42717
43131
  * ```
42718
43132
  */
@@ -42759,6 +43173,8 @@ class WorldActivity extends SDKController {
42759
43173
  /**
42760
43174
  * Retrieve all visitors currently in a world.
42761
43175
  *
43176
+ * @keywords get, fetch, retrieve, list, current, visitors, users, players
43177
+ *
42762
43178
  * @category Visitors
42763
43179
  *
42764
43180
  * @example
@@ -42782,6 +43198,8 @@ class WorldActivity extends SDKController {
42782
43198
  /**
42783
43199
  * Retrieve all visitors currently in a Landmark Zone.
42784
43200
  *
43201
+ * @keywords get, fetch, retrieve, list, zone, area, landmark, visitors, users
43202
+ *
42785
43203
  * @category Visitors
42786
43204
  *
42787
43205
  * @example
@@ -42811,6 +43229,8 @@ class WorldActivity extends SDKController {
42811
43229
  * Optionally refetch visitors, teleport or walk visitors to new location,
42812
43230
  * and scatter visitors by any number so that they don't all move to the exact same location.
42813
43231
  *
43232
+ * @keywords move, teleport, position, coordinate, visitors, users, relocate
43233
+ *
42814
43234
  * @category Visitors
42815
43235
  *
42816
43236
  * @example
@@ -42847,6 +43267,8 @@ class WorldActivity extends SDKController {
42847
43267
  /**
42848
43268
  * Teleport or walk a list of visitors currently in a world to various coordinates.
42849
43269
  *
43270
+ * @keywords move, teleport, position, coordinate, visitor, user, relocate
43271
+ *
42850
43272
  * @category Visitors
42851
43273
  *
42852
43274
  * @example
@@ -42883,10 +43305,50 @@ class WorldActivity extends SDKController {
42883
43305
  }
42884
43306
  _WorldActivity_visitorsMap = new WeakMap();
42885
43307
 
43308
+ /* ============================================================================
43309
+ AI RULES for code assistants
43310
+
43311
+ - Consumers MUST create a single Topia client in their app (e.g. utils/topiaInit.ts).
43312
+ - Consumers MUST instantiate this factory ONCE using that client and RE-USE it.
43313
+ - Controllers/services MUST import the app’s exported factory instance.
43314
+ - Use ONLY methods defined in this file’s types and TSDoc.
43315
+ - Methods that DO NOT exist and MUST NOT be suggested.
43316
+
43317
+ RIGHT ✅ Correct usage pattern (consumer app):
43318
+ // utils/topiaInit.ts
43319
+ import { Topia, AssetFactory } from "@rtsdk/topia";
43320
+ const topia = new Topia({ config });
43321
+ export const Asset = new AssetFactory(topia);
43322
+
43323
+ RIGHT ✅ Correct usage pattern (controller):
43324
+ // controllers/myController.ts
43325
+ import { Asset } from "utils/topiaInit.ts";
43326
+ const asset = await Asset.create(assetId, { credentials });
43327
+ await asset.fetchAssetById();
43328
+
43329
+ WRONG ❌ Incorrect usage pattern (controller):
43330
+ // controllers/myController.ts
43331
+ import { AssetFactory, Topia } from "@rtsdk/topia";
43332
+ const topia = new Topia(config); // ❌ new client per request
43333
+ const Asset = new AssetFactory(topia); // ❌ ad-hoc factory
43334
+ const asset = await Asset.getById(assetId); // ❌ method does not exist
43335
+
43336
+ Do NOT instantiate factories in controllers. Do NOT invent methods.
43337
+ ============================================================================ */
42886
43338
  /**
43339
+ * Factory for creating Asset instances. Use this factory to create or upload assets in the Topia platform.
43340
+ *
43341
+ * @remarks
43342
+ * This factory should be instantiated once per application and reused across your codebase.
43343
+ *
43344
+ * @keywords asset, factory, create, upload, instantiate, topia
43345
+ *
42887
43346
  * @example
42888
43347
  * ```ts
42889
- * const Asset = new AssetFactory(myTopiaInstance);
43348
+ * // In your initialization file (e.g., utils/topiaInit.ts)
43349
+ * import { Topia, AssetFactory } from "@rtsdk/topia";
43350
+ * const topia = new Topia({ config });
43351
+ * export const Asset = new AssetFactory(topia);
42890
43352
  * ```
42891
43353
  */
42892
43354
  class AssetFactory extends SDKController {
@@ -42894,11 +43356,32 @@ class AssetFactory extends SDKController {
42894
43356
  super(topia);
42895
43357
  }
42896
43358
  /**
42897
- * Instantiate a new instance of Asset class.
43359
+ * Instantiate a new instance of Asset class with the specified asset ID.
43360
+ *
43361
+ * @remarks
43362
+ * This method creates a new Asset controller instance that can be used to interact with an existing asset.
43363
+ * It does not create a new asset in the database.
43364
+ *
43365
+ * @keywords create, instantiate, asset, initialize, get, instance
42898
43366
  *
42899
43367
  * @example
42900
- * ```
42901
- * const assetInstance = await Asset.create(id, { credentials: { interactiveNonce, interactivePublicKey, assetId, urlSlug, visitorId } });
43368
+ * ```ts
43369
+ * // Import the pre-initialized factory from your app's initialization file
43370
+ * import { Asset } from "utils/topiaInit.ts";
43371
+ *
43372
+ * // Create an Asset instance with credentials
43373
+ * const assetInstance = await Asset.create(assetId, {
43374
+ * credentials: {
43375
+ * interactiveNonce,
43376
+ * interactivePublicKey,
43377
+ * assetId,
43378
+ * urlSlug,
43379
+ * visitorId
43380
+ * }
43381
+ * });
43382
+ *
43383
+ * // Use the instance to interact with the asset
43384
+ * await assetInstance.fetchAssetById();
42902
43385
  * ```
42903
43386
  *
42904
43387
  * @returns {Asset} Returns a new Asset object with the asset id.
@@ -42907,22 +43390,37 @@ class AssetFactory extends SDKController {
42907
43390
  return new Asset(this.topia, id, options);
42908
43391
  }
42909
43392
  /**
42910
- * Upload a new Asset and return a new instance of Asset class.
43393
+ * Upload a new Asset to the Topia platform and return a new instance of Asset class.
43394
+ *
43395
+ * @remarks
43396
+ * This method both creates a new asset in the database and returns an Asset controller instance.
43397
+ * A valid API key with appropriate permissions is required.
43398
+ *
43399
+ * @keywords upload, create, new, asset, add, store
42911
43400
  *
42912
43401
  * @example
42913
- * ```
43402
+ * ```ts
43403
+ * // Import the pre-initialized factory from your app's initialization file
43404
+ * import { Asset } from "utils/topiaInit.ts";
43405
+ *
43406
+ * // Prepare the asset payload
42914
43407
  * const assetPayload = {
42915
- * assetName: "exampleAssetName"
42916
- * bottomLayerURL: "https://example.bottomLayerURL"
43408
+ * assetName: "My Decorative Asset",
43409
+ * bottomLayerURL: "https://example.com/bottom-layer.png",
42917
43410
  * creatorTags: { "decorations": true },
42918
43411
  * tagJson: "[{"label":"decorations","value":"decorations"}]",
42919
43412
  * isPublic: true,
42920
- * topLayerURL: "https://example.topLayerURL"
42921
- * }
43413
+ * topLayerURL: "https://example.com/top-layer.png"
43414
+ * };
43415
+ *
43416
+ * // Upload the asset using your API key
42922
43417
  * const asset = await Asset.upload(assetPayload, apiKey);
43418
+ *
43419
+ * // Access the new asset's properties
43420
+ * console.log(asset.id);
42923
43421
  * ```
42924
43422
  *
42925
- * @returns {AssetType} Returns a new Asset object with the asset details.
43423
+ * @returns {Asset} Returns a new Asset object with the asset details.
42926
43424
  */
42927
43425
  upload(assetPayload, apiKey) {
42928
43426
  return __awaiter(this, void 0, void 0, function* () {
@@ -42941,10 +43439,50 @@ class AssetFactory extends SDKController {
42941
43439
  }
42942
43440
  }
42943
43441
 
43442
+ /* ============================================================================
43443
+ AI RULES for code assistants
43444
+
43445
+ - Consumers MUST create a single Topia client in their app (e.g. utils/topiaInit.ts).
43446
+ - Consumers MUST instantiate this factory ONCE using that client and RE-USE it.
43447
+ - Controllers/services MUST import the app’s exported factory instance.
43448
+ - Use ONLY methods defined in this file’s types and TSDoc.
43449
+ - Methods that DO NOT exist and MUST NOT be suggested.
43450
+
43451
+ RIGHT ✅ Correct usage pattern (consumer app):
43452
+ // utils/topiaInit.ts
43453
+ import { Topia, DroppedAssetFactory } from "@rtsdk/topia";
43454
+ const topia = new Topia({ config });
43455
+ export const DroppedAsset = new DroppedAssetFactory(topia);
43456
+
43457
+ RIGHT ✅ Correct usage pattern (controller):
43458
+ // controllers/myController.ts
43459
+ import { DroppedAsset } from "utils/topiaInit.ts";
43460
+ const da = await DroppedAsset.get(droppedAssetId, urlSlug, { credentials });
43461
+ await da.fetchDataObject();
43462
+
43463
+ WRONG ❌ Incorrect usage pattern (controller):
43464
+ // controllers/myController.ts
43465
+ import { DroppedAssetFactory, Topia } from "@rtsdk/topia";
43466
+ const topia = new Topia(config); // ❌ new client per request
43467
+ const DroppedAsset = new DroppedAssetFactory(topia); // ❌ ad-hoc factory
43468
+ const da = await DroppedAsset.getById(droppedAssetId); // ❌ method does not exist
43469
+
43470
+ Do NOT instantiate factories in controllers. Do NOT invent methods.
43471
+ ============================================================================ */
42944
43472
  /**
43473
+ * Factory for creating and retrieving DroppedAsset instances. Use this factory to work with assets that have been placed in a Topia world.
43474
+ *
43475
+ * @remarks
43476
+ * This factory should be instantiated once per application and reused across your codebase.
43477
+ *
43478
+ * @keywords dropped asset, factory, create, get, retrieve, instantiate, topia
43479
+ *
42945
43480
  * @example
42946
43481
  * ```ts
42947
- * const DroppedAsset = new DroppedAssetFactory(myTopiaInstance);
43482
+ * // In your initialization file (e.g., utils/topiaInit.ts)
43483
+ * import { Topia, DroppedAssetFactory } from "@rtsdk/topia";
43484
+ * const topia = new Topia({ config });
43485
+ * export const DroppedAsset = new DroppedAssetFactory(topia);
42948
43486
  * ```
42949
43487
  */
42950
43488
  class DroppedAssetFactory extends SDKController {
@@ -42952,27 +43490,77 @@ class DroppedAssetFactory extends SDKController {
42952
43490
  super(topia);
42953
43491
  }
42954
43492
  /**
42955
- * Instantiate a new instance of DroppedAsset class.
43493
+ * Instantiate a new instance of DroppedAsset class for an existing dropped asset in a world.
43494
+ *
43495
+ * @remarks
43496
+ * This method creates a controller instance for an existing dropped asset but does not fetch its properties.
43497
+ * Use this when you need a lightweight instance and will fetch properties separately if needed or when you already have the properties.
43498
+ *
43499
+ * @keywords create, instantiate, dropped asset, initialize, instance
42956
43500
  *
42957
43501
  * @example
42958
- * ```
42959
- * const droppedAssetInstance = await DroppedAsset.create(assetId, urlSlug, { credentials: { interactiveNonce, interactivePublicKey, assetId, urlSlug, visitorId } });
43502
+ * ```ts
43503
+ * // Import the pre-initialized factory from your app's initialization file
43504
+ * import { DroppedAsset } from "utils/topiaInit.ts";
43505
+ *
43506
+ * // Create a DroppedAsset instance with credentials
43507
+ * const droppedAssetInstance = DroppedAsset.create(
43508
+ * assetId,
43509
+ * urlSlug,
43510
+ * {
43511
+ * credentials: {
43512
+ * interactiveNonce,
43513
+ * interactivePublicKey,
43514
+ * assetId,
43515
+ * urlSlug,
43516
+ * visitorId
43517
+ * }
43518
+ * }
43519
+ * );
43520
+ *
43521
+ * // Later fetch its properties if needed
43522
+ * await droppedAssetInstance.fetchDroppedAssetById();
42960
43523
  * ```
42961
43524
  *
42962
- * @returns {DroppedAsset} Returns a new DroppedAsset object.
43525
+ * @returns {DroppedAsset} Returns a new DroppedAsset object without fetching its properties.
42963
43526
  */
42964
43527
  create(id, urlSlug, options) {
42965
43528
  return new DroppedAsset(this.topia, id, urlSlug, options);
42966
43529
  }
42967
43530
  /**
42968
- * Instantiate a new instance of DroppedAsset class and retrieve all properties.
43531
+ * Instantiate a new instance of DroppedAsset class and automatically fetch all its properties.
43532
+ *
43533
+ * @remarks
43534
+ * This method creates a controller instance and immediately fetches all properties of the dropped asset.
43535
+ * It's a convenience method that combines creating an instance and calling fetchDroppedAssetById().
43536
+ *
43537
+ * @keywords get, fetch, retrieve, dropped asset, load, instance
42969
43538
  *
42970
43539
  * @example
42971
- * ```
42972
- * const droppedAssetInstance = await DroppedAsset.get(assetId, urlSlug, { credentials: { interactiveNonce, interactivePublicKey, assetId, urlSlug, visitorId } });
43540
+ * ```ts
43541
+ * // Import the pre-initialized factory from your app's initialization file
43542
+ * import { DroppedAsset } from "utils/topiaInit.ts";
43543
+ *
43544
+ * // Get a fully populated DroppedAsset instance
43545
+ * const droppedAssetInstance = await DroppedAsset.get(
43546
+ * assetId,
43547
+ * urlSlug,
43548
+ * {
43549
+ * credentials: {
43550
+ * interactiveNonce,
43551
+ * interactivePublicKey,
43552
+ * assetId,
43553
+ * urlSlug,
43554
+ * visitorId
43555
+ * }
43556
+ * }
43557
+ * );
43558
+ *
43559
+ * // The properties are already loaded, so you can use them immediately
43560
+ * console.log(droppedAssetInstance.position);
42973
43561
  * ```
42974
43562
  *
42975
- * @returns {Promise<DroppedAsset>} Returns a new DroppedAsset object with all properties.
43563
+ * @returns {Promise<DroppedAsset>} Returns a new DroppedAsset object with all properties already fetched.
42976
43564
  */
42977
43565
  get(id, urlSlug, options) {
42978
43566
  return __awaiter(this, void 0, void 0, function* () {
@@ -42982,17 +43570,36 @@ class DroppedAssetFactory extends SDKController {
42982
43570
  });
42983
43571
  }
42984
43572
  /**
42985
- * Searches dropped assets within a world by a provide `uniqueName`. If a single match is found, a new instance of DroppedAsset class is returned all properties.
43573
+ * Searches for and retrieves a dropped asset by its unique name within a world.
42986
43574
  *
42987
43575
  * @remarks
42988
- * This method leverages the handleGetDroppedAssetByUniqueName endpoint in the Public API and assumes there is exactly one dropped asset with matching uniqueName for the given urlSlug.
43576
+ * This method leverages the handleGetDroppedAssetByUniqueName endpoint in the Public API and assumes there is exactly one dropped asset with the matching uniqueName for the given urlSlug.
43577
+ * Use this when you need to find a dropped asset by its uniqueName rather than its ID.
43578
+ *
43579
+ * @keywords find, search, unique name, retrieve, locate, lookup, dropped asset
42989
43580
  *
42990
43581
  * @example
42991
- * ```
42992
- * const droppedAssetInstance = await DroppedAsset.getWithUniqueName("exampleUniqueName", urlSlug, interactiveSecret, credentials);
43582
+ * ```ts
43583
+ * // Import the pre-initialized factory from your app's initialization file
43584
+ * import { DroppedAsset } from "utils/topiaInit.ts";
43585
+ *
43586
+ * // Find and retrieve a dropped asset by its unique name
43587
+ * const droppedAssetInstance = await DroppedAsset.getWithUniqueName(
43588
+ * "banner-sign-northeast",
43589
+ * "my-world-slug",
43590
+ * "your-interactive-secret",
43591
+ * {
43592
+ * apiKey: "your-api-key",
43593
+ * interactivePublicKey: "your-public-key",
43594
+ * // other credentials...
43595
+ * }
43596
+ * );
43597
+ *
43598
+ * // The properties are already loaded, so you can use them immediately
43599
+ * console.log(droppedAssetInstance.position);
42993
43600
  * ```
42994
43601
  *
42995
- * @returns {Promise<DroppedAsset>} Returns a new DroppedAsset object with all properties.
43602
+ * @returns {Promise<DroppedAsset>} Returns a new DroppedAsset object with all properties already fetched.
42996
43603
  */
42997
43604
  getWithUniqueName(uniqueName, urlSlug, interactiveSecret, credentials) {
42998
43605
  return __awaiter(this, void 0, void 0, function* () {
@@ -43019,23 +43626,59 @@ class DroppedAssetFactory extends SDKController {
43019
43626
  /**
43020
43627
  * Drops an asset in a world and returns a new instance of DroppedAsset class with all properties.
43021
43628
  *
43629
+ * @remarks
43630
+ * This method places an existing Asset into a world at specified coordinates, effectively "dropping" it into the environment.
43631
+ * You can customize various properties of the dropped asset during placement, such as scale, position, interactive settings, and visual layers.
43632
+ *
43633
+ * @keywords drop, place, add, create, position, asset, deploy
43634
+ *
43022
43635
  * @example
43023
- * ```
43024
- * const assetInstance = await Asset.create(id, { credentials: { interactiveNonce, interactivePublicKey, assetId, urlSlug, visitorId } });
43025
- * const droppedAssetInstance = await DroppedAsset.get(assetInstance, {
43026
- assetScale: 1.5,
43027
- flipped: true,
43028
- layer0: "",
43029
- layer1: "https://pathtoimage.png",
43030
- interactivePublicKey,
43031
- isInteractive: true,
43032
- position: { x: 0, y: 0 },
43033
- uniqueName: "exampleUniqueName",
43034
- urlSlug,
43035
- });
43636
+ * ```ts
43637
+ * // Import the pre-initialized factories from your app's initialization file
43638
+ * import { Asset, DroppedAsset } from "utils/topiaInit.ts";
43639
+ *
43640
+ * // First get an asset instance
43641
+ * const assetInstance = Asset.create("asset-id-123", {
43642
+ * credentials: {
43643
+ * interactiveNonce,
43644
+ * interactivePublicKey,
43645
+ * assetId,
43646
+ * urlSlug,
43647
+ * visitorId
43648
+ * }
43649
+ * });
43650
+ *
43651
+ * // Then drop (place) the asset in a world
43652
+ * const droppedAssetInstance = await DroppedAsset.drop(
43653
+ * assetInstance,
43654
+ * {
43655
+ * // Basic positioning and appearance
43656
+ * position: { x: 250, y: 350 },
43657
+ * assetScale: 1.5,
43658
+ * flipped: true,
43659
+ * uniqueName: "welcome-sign",
43660
+ * urlSlug: "my-world-slug",
43661
+ *
43662
+ * // For web images (optional)
43663
+ * layer0: "https://example.com/background.png",
43664
+ * layer1: "https://example.com/foreground.png",
43665
+ *
43666
+ * // For interactive assets (optional)
43667
+ * interactivePublicKey: "your-public-key",
43668
+ * isInteractive: true,
43669
+ *
43670
+ * // For clickable assets (optional)
43671
+ * clickType: "link",
43672
+ * clickableLink: "https://example.com",
43673
+ * clickableLinkTitle: "Visit Example"
43674
+ * }
43675
+ * );
43676
+ *
43677
+ * // The dropped asset is ready to use
43678
+ * console.log(droppedAssetInstance.id);
43036
43679
  * ```
43037
43680
  *
43038
- * @returns {Promise<DroppedAsset>} Returns a new DroppedAsset object with all properties.
43681
+ * @returns {Promise<DroppedAsset>} Returns a new DroppedAsset object representing the placed asset in the world.
43039
43682
  */
43040
43683
  drop(asset, { assetScale = 1, clickType, clickableDisplayTextDescription, clickableDisplayTextHeadline, clickableLink, clickableLinkTitle, flipped, interactivePublicKey, isInteractive, isForceLinkInIframe, isOpenLinkInDrawer, isTextTopLayer = false, layer0, layer1, position: { x, y }, sceneDropId, text, textColor, textFontFamily, textSize, textWeight, textWidth, uniqueName, urlSlug, yOrderAdjust, }) {
43041
43684
  return __awaiter(this, void 0, void 0, function* () {
@@ -43089,10 +43732,51 @@ class DroppedAssetFactory extends SDKController {
43089
43732
  }
43090
43733
  }
43091
43734
 
43735
+ /* ============================================================================
43736
+ AI RULES for code assistants
43737
+
43738
+ - Consumers MUST create a single Topia client in their app (e.g. utils/topiaInit.ts).
43739
+ - Consumers MUST instantiate this factory ONCE using that client and RE-USE it.
43740
+ - Controllers/services MUST import the app’s exported factory instance.
43741
+ - Use ONLY methods defined in this file’s types and TSDoc.
43742
+ - Methods that DO NOT exist and MUST NOT be suggested.
43743
+
43744
+ RIGHT ✅ Correct usage pattern (consumer app):
43745
+ // utils/topiaInit.ts
43746
+ import { Topia, Ecosystem } from "@rtsdk/topia";
43747
+ const topia = new Topia({ config });
43748
+ export const Ecosystem = new EcosystemFactory(topia);
43749
+
43750
+ RIGHT ✅ Correct usage pattern (controller):
43751
+ // controllers/myController.ts
43752
+ import { Ecosystem } from "utils/topiaInit.ts";
43753
+ const ecosystem = await Ecosystem.create({ credentials });
43754
+ await ecosystem.fetchDataObject();
43755
+
43756
+ WRONG ❌ Incorrect usage pattern (controller):
43757
+ // controllers/myController.ts
43758
+ import { Ecosystem, Topia } from "@rtsdk/topia";
43759
+ const topia = new Topia(config); // ❌ new client per request
43760
+ const Ecosystem = new EcosystemFactory(topia); // ❌ ad-hoc factory
43761
+ const ecosystem = await Ecosystem.getById(id); // ❌ method does not exist
43762
+
43763
+ Do NOT instantiate factories in controllers. Do NOT invent methods.
43764
+ ============================================================================ */
43092
43765
  /**
43766
+ * Factory for creating Ecosystem instances. Use this factory to work with ecosystem-wide data and operations.
43767
+ *
43768
+ * @remarks
43769
+ * This factory should be instantiated once per application and reused across your codebase.
43770
+ * The Ecosystem controller provides methods to interact with data shared across multiple worlds.
43771
+ *
43772
+ * @keywords ecosystem, factory, create, multi-world, global, shared data, platform
43773
+ *
43093
43774
  * @example
43094
43775
  * ```ts
43095
- * const Ecosystem = new EcosystemFactory(myTopiaInstance);
43776
+ * // In your initialization file (e.g., utils/topiaInit.ts)
43777
+ * import { Topia, EcosystemFactory } from "@rtsdk/topia";
43778
+ * const topia = new Topia({ config });
43779
+ * export const Ecosystem = new EcosystemFactory(topia);
43096
43780
  * ```
43097
43781
  */
43098
43782
  class EcosystemFactory {
@@ -43100,24 +43784,86 @@ class EcosystemFactory {
43100
43784
  this.topia = topia;
43101
43785
  }
43102
43786
  /**
43103
- * Instantiate a new instance of Ecosystem class.
43787
+ * Instantiate a new instance of Ecosystem class for interacting with ecosystem-wide data.
43788
+ *
43789
+ * @remarks
43790
+ * This method creates a controller instance for accessing and managing data that spans multiple worlds.
43791
+ * Use this for cross-world data sharing, global data objects, and ecosystem-wide operations.
43792
+ *
43793
+ * @keywords create, instantiate, ecosystem, initialize, global, shared data, platform
43104
43794
  *
43105
43795
  * @example
43106
- * ```
43107
- * const ecosystemInstance = await Ecosystem.create({ credentials: { interactiveNonce, interactivePublicKey, assetId, urlSlug, visitorId }});
43796
+ * ```ts
43797
+ * // Import the pre-initialized factory from your app's initialization file
43798
+ * import { Ecosystem } from "utils/topiaInit.ts";
43799
+ *
43800
+ * // Create an Ecosystem instance with credentials
43801
+ * const ecosystemInstance = Ecosystem.create({
43802
+ * credentials: {
43803
+ * interactiveNonce,
43804
+ * interactivePublicKey,
43805
+ * assetId,
43806
+ * urlSlug,
43807
+ * visitorId
43808
+ * }
43809
+ * });
43810
+ *
43811
+ * // Work with ecosystem-wide data objects
43812
+ * await ecosystemInstance.fetchDataObject("global-leaderboard");
43813
+ * await ecosystemInstance.setDataObject("global-leaderboard", { scores: [...] });
43108
43814
  * ```
43109
43815
  *
43110
- * @returns {Ecosystem} Returns a new Ecosystem object.
43816
+ * @returns {Ecosystem} Returns a new Ecosystem object for interacting with ecosystem-wide data.
43111
43817
  */
43112
43818
  create(options) {
43113
43819
  return new Ecosystem(this.topia, options);
43114
43820
  }
43115
43821
  }
43116
43822
 
43823
+ /* ============================================================================
43824
+ AI RULES for code assistants
43825
+
43826
+ - Consumers MUST create a single Topia client in their app (e.g. utils/topiaInit.ts).
43827
+ - Consumers MUST instantiate this factory ONCE using that client and RE-USE it.
43828
+ - Controllers/services MUST import the app’s exported factory instance.
43829
+ - Use ONLY methods defined in this file’s types and TSDoc.
43830
+ - Methods that DO NOT exist and MUST NOT be suggested.
43831
+
43832
+ RIGHT ✅ Correct usage pattern (consumer app):
43833
+ // utils/topiaInit.ts
43834
+ import { Topia, SceneFactory } from "@rtsdk/topia";
43835
+ const topia = new Topia({ config });
43836
+ export const Scene = new SceneFactory(topia);
43837
+
43838
+ RIGHT ✅ Correct usage pattern (controller):
43839
+ // controllers/myController.ts
43840
+ import { Scene } from "utils/topiaInit.ts";
43841
+ const scene = await Scene.get(sceneId, { credentials });
43842
+
43843
+ WRONG ❌ Incorrect usage pattern (controller):
43844
+ // controllers/myController.ts
43845
+ import { SceneFactory, Topia } from "@rtsdk/topia";
43846
+ const topia = new Topia(config); // ❌ new client per request
43847
+ const Scene = new SceneFactory(topia); // ❌ ad-hoc factory
43848
+ const scene = await Scene.getById(sceneId); // ❌ method does not exist
43849
+
43850
+ Do NOT instantiate factories in controllers. Do NOT invent methods.
43851
+ ============================================================================ */
43117
43852
  /**
43853
+ * Factory for creating Scene instances. Use this factory to work with scenes in the Topia platform.
43854
+ *
43855
+ * @remarks
43856
+ * This factory should be instantiated once per application and reused across your codebase.
43857
+ * Scenes represent the template or blueprint for a world's design and layout.
43858
+ *
43859
+ * @keywords scene, factory, create, template, blueprint, layout, design
43860
+ *
43118
43861
  * @example
43119
43862
  * ```ts
43120
- * const Scene = new SceneFactory(myTopiaInstance);
43863
+ * // In your initialization file (e.g., utils/topiaInit.ts)
43864
+ * import { Topia, SceneFactory } from "@rtsdk/topia";
43865
+ * const topia = new Topia({ config });
43866
+ * export const Scene = new SceneFactory(topia);
43121
43867
  * ```
43122
43868
  */
43123
43869
  class SceneFactory {
@@ -43126,14 +43872,38 @@ class SceneFactory {
43126
43872
  this.create;
43127
43873
  }
43128
43874
  /**
43129
- * Instantiate a new instance of Scene class.
43875
+ * Instantiate a new instance of Scene class for an existing scene in the platform.
43876
+ *
43877
+ * @remarks
43878
+ * This method creates a controller instance for working with a scene but does not fetch its properties.
43879
+ * Use this when you need to interact with a specific scene by its ID.
43880
+ *
43881
+ * @keywords create, instantiate, scene, initialize, instance, template
43130
43882
  *
43131
43883
  * @example
43132
- * ```
43133
- * const sceneInstance = await Scene.create(id, { credentials: { interactiveNonce, interactivePublicKey, assetId, urlSlug, visitorId } });
43884
+ * ```ts
43885
+ * // Import the pre-initialized factory from your app's initialization file
43886
+ * import { Scene } from "utils/topiaInit.ts";
43887
+ *
43888
+ * // Create a Scene instance with credentials
43889
+ * const sceneInstance = Scene.create(
43890
+ * "scene-id-123",
43891
+ * {
43892
+ * credentials: {
43893
+ * interactiveNonce,
43894
+ * interactivePublicKey,
43895
+ * assetId,
43896
+ * urlSlug,
43897
+ * visitorId
43898
+ * }
43899
+ * }
43900
+ * );
43901
+ *
43902
+ * // Fetch scene details if needed
43903
+ * await sceneInstance.fetchSceneById();
43134
43904
  * ```
43135
43905
  *
43136
- * @returns {Scene} Returns a new Scene object.
43906
+ * @returns {Scene} Returns a new Scene object for interacting with the specified scene.
43137
43907
  */
43138
43908
  create(id, options) {
43139
43909
  return new Scene(this.topia, id, options);
@@ -43157,10 +43927,51 @@ class SceneFactory {
43157
43927
  }
43158
43928
  }
43159
43929
 
43930
+ /* ============================================================================
43931
+ AI RULES for code assistants
43932
+
43933
+ - Consumers MUST create a single Topia client in their app (e.g. utils/topiaInit.ts).
43934
+ - Consumers MUST instantiate this factory ONCE using that client and RE-USE it.
43935
+ - Controllers/services MUST import the app’s exported factory instance.
43936
+ - Use ONLY methods defined in this file’s types and TSDoc.
43937
+ - Methods that DO NOT exist and MUST NOT be suggested.
43938
+
43939
+ RIGHT ✅ Correct usage pattern (consumer app):
43940
+ // utils/topiaInit.ts
43941
+ import { Topia, UserFactory } from "@rtsdk/topia";
43942
+ const topia = new Topia({ config });
43943
+ export const User = new UserFactory(topia);
43944
+
43945
+ RIGHT ✅ Correct usage pattern (controller):
43946
+ // controllers/myController.ts
43947
+ import { User } from "utils/topiaInit.ts";
43948
+ const user = await User.create({ credentials });
43949
+ await user.fetchDataObject();
43950
+
43951
+ WRONG ❌ Incorrect usage pattern (controller):
43952
+ // controllers/myController.ts
43953
+ import { UserFactory, Topia } from "@rtsdk/topia";
43954
+ const topia = new Topia(config); // ❌ new client per request
43955
+ const User = new UserFactory(topia); // ❌ ad-hoc factory
43956
+ const user = await User.getById(userId); // ❌ method does not exist
43957
+
43958
+ Do NOT instantiate factories in controllers. Do NOT invent methods.
43959
+ ============================================================================ */
43160
43960
  /**
43961
+ * Factory for creating User instances. Use this factory to work with user data in the Topia platform.
43962
+ *
43963
+ * @remarks
43964
+ * This factory should be instantiated once per application and reused across your codebase.
43965
+ * The User controller allows you to interact with user-specific information and operations.
43966
+ *
43967
+ * @keywords user, factory, create, account, profile, member, visitor
43968
+ *
43161
43969
  * @example
43162
43970
  * ```ts
43163
- * const User = new UserFactory(myTopiaInstance);
43971
+ * // In your initialization file (e.g., utils/topiaInit.ts)
43972
+ * import { Topia, UserFactory } from "@rtsdk/topia";
43973
+ * const topia = new Topia({ config });
43974
+ * export const User = new UserFactory(topia);
43164
43975
  * ```
43165
43976
  */
43166
43977
  class UserFactory {
@@ -43168,24 +43979,87 @@ class UserFactory {
43168
43979
  this.topia = topia;
43169
43980
  }
43170
43981
  /**
43171
- * Instantiate a new instance of User class.
43982
+ * Instantiate a new instance of User class for working with user data.
43983
+ *
43984
+ * @remarks
43985
+ * This method creates a controller instance for interacting with user-specific operations.
43986
+ * The User controller doesn't require an ID since it represents the currently authenticated user.
43987
+ *
43988
+ * @keywords create, instantiate, user, initialize, account, profile, member
43172
43989
  *
43173
43990
  * @example
43174
- * ```
43175
- * const userInstance = await User.create({ credentials: { interactiveNonce, interactivePublicKey, assetId, urlSlug, visitorId } });
43991
+ * ```ts
43992
+ * // Import the pre-initialized factory from your app's initialization file
43993
+ * import { User } from "utils/topiaInit.ts";
43994
+ *
43995
+ * // Create a User instance with credentials
43996
+ * const userInstance = User.create({
43997
+ * credentials: {
43998
+ * interactiveNonce,
43999
+ * interactivePublicKey,
44000
+ * assetId,
44001
+ * urlSlug,
44002
+ * visitorId
44003
+ * }
44004
+ * });
44005
+ *
44006
+ * // Use methods on the user instance
44007
+ * await userInstance.checkInteractiveCredentials();
44008
+ * const avatars = await userInstance.fetchAvatars();
43176
44009
  * ```
43177
44010
  *
43178
- * @returns {User} Returns a new User object.
44011
+ * @returns {User} Returns a new User object for interacting with user data.
43179
44012
  */
43180
44013
  create(options) {
43181
44014
  return new User(this.topia, options);
43182
44015
  }
43183
44016
  }
43184
44017
 
44018
+ /* ============================================================================
44019
+ AI RULES for code assistants
44020
+
44021
+ - Consumers MUST create a single Topia client in their app (e.g. utils/topiaInit.ts).
44022
+ - Consumers MUST instantiate this factory ONCE using that client and RE-USE it.
44023
+ - Controllers/services MUST import the app’s exported factory instance.
44024
+ - Use ONLY methods defined in this file’s types and TSDoc.
44025
+ - Methods that DO NOT exist and MUST NOT be suggested.
44026
+
44027
+ RIGHT ✅ Correct usage pattern (consumer app):
44028
+ // utils/topiaInit.ts
44029
+ import { Topia, VisitorFactory } from "@rtsdk/topia";
44030
+ const topia = new Topia({ config });
44031
+ export const Visitor = new VisitorFactory(topia);
44032
+
44033
+ RIGHT ✅ Correct usage pattern (controller):
44034
+ // controllers/myController.ts
44035
+ import { Visitor } from "utils/topiaInit.ts";
44036
+ const visitor = await Visitor.get(visitorId, urlSlug, { credentials });
44037
+ await visitor.fetchDataObject();
44038
+
44039
+ WRONG ❌ Incorrect usage pattern (controller):
44040
+ // controllers/myController.ts
44041
+ import { VisitorFactory, Topia } from "@rtsdk/topia";
44042
+ const topia = new Topia(config); // ❌ new client per request
44043
+ const Visitor = new VisitorFactory(topia); // ❌ ad-hoc factory
44044
+ const visitor = await Visitor.getById(visitorId); // ❌ method does not exist
44045
+
44046
+ Do NOT instantiate factories in controllers. Do NOT invent methods.
44047
+ ============================================================================ */
43185
44048
  /**
44049
+ * Factory for creating Visitor instances. Use this factory to work with visitors in Topia worlds.
44050
+ *
44051
+ * @remarks
44052
+ * This factory should be instantiated once per application and reused across your codebase.
44053
+ * The Visitor controller represents a specific visitor/avatar instance in a world.
44054
+ *
44055
+ * @keywords visitor, factory, create, get, avatar, user, participant
44056
+ *
43186
44057
  * @example
43187
44058
  * ```ts
43188
- * const Visitor = new VisitorFactory(myTopiaInstance);
44059
+ * // In your initialization file (e.g., utils/topiaInit.ts)
44060
+ * import { Topia, VisitorFactory } from "@rtsdk/topia";
44061
+ * const topia = new Topia({ config });
44062
+ * export const Visitor = new VisitorFactory(topia);
43189
44063
  * ```
43190
44064
  */
43191
44065
  class VisitorFactory {
@@ -43193,27 +44067,78 @@ class VisitorFactory {
43193
44067
  this.topia = topia;
43194
44068
  }
43195
44069
  /**
43196
- * Instantiate a new instance of Visitor class.
44070
+ * Instantiate a new instance of Visitor class for an existing visitor in a world.
44071
+ *
44072
+ * @remarks
44073
+ * This method creates a controller instance for a visitor but does not fetch its properties.
44074
+ * Use this when you need a lightweight instance and will fetch properties separately or when you already have the properties.
44075
+ *
44076
+ * @keywords create, instantiate, visitor, initialize, avatar, instance
43197
44077
  *
43198
44078
  * @example
43199
- * ```
43200
- * const visitorInstance = await Visitor.create(id, urlSlug, { credentials: { interactiveNonce, interactivePublicKey, assetId, urlSlug, visitorId } });
44079
+ * ```ts
44080
+ * // Import the pre-initialized factory from your app's initialization file
44081
+ * import { Visitor } from "utils/topiaInit.ts";
44082
+ *
44083
+ * // Create a Visitor instance with credentials
44084
+ * const visitorInstance = Visitor.create(
44085
+ * 12345, // visitor ID
44086
+ * "my-world-slug",
44087
+ * {
44088
+ * credentials: {
44089
+ * interactiveNonce,
44090
+ * interactivePublicKey,
44091
+ * assetId,
44092
+ * urlSlug,
44093
+ * visitorId
44094
+ * }
44095
+ * }
44096
+ * );
44097
+ *
44098
+ * // Later fetch visitor properties if needed
44099
+ * await visitorInstance.fetchVisitor();
43201
44100
  * ```
43202
44101
  *
43203
- * @returns {Visitor} Returns a new Visitor object.
44102
+ * @returns {Visitor} Returns a new Visitor object without fetching its properties.
43204
44103
  */
43205
44104
  create(id, urlSlug, options) {
43206
44105
  return new Visitor(this.topia, id, urlSlug, options);
43207
44106
  }
43208
44107
  /**
43209
- * Instantiate a new instance of Visitor class and retrieve all properties.
44108
+ * Instantiate a new instance of Visitor class and automatically fetch all its properties.
44109
+ *
44110
+ * @remarks
44111
+ * This method creates a controller instance and immediately fetches all properties of the visitor.
44112
+ * It's a convenience method that combines creating an instance and calling fetchVisitor().
44113
+ *
44114
+ * @keywords get, fetch, retrieve, visitor, load, avatar, instance
43210
44115
  *
43211
44116
  * @example
43212
- * ```
43213
- * const visitorInstance = await Visitor.get(id, urlSlug, { credentials: { interactiveNonce, interactivePublicKey, assetId, urlSlug, visitorId } });
44117
+ * ```ts
44118
+ * // Import the pre-initialized factory from your app's initialization file
44119
+ * import { Visitor } from "utils/topiaInit.ts";
44120
+ *
44121
+ * // Get a fully populated Visitor instance
44122
+ * const visitorInstance = await Visitor.get(
44123
+ * 12345, // visitor ID
44124
+ * "my-world-slug",
44125
+ * {
44126
+ * credentials: {
44127
+ * interactiveNonce,
44128
+ * interactivePublicKey,
44129
+ * assetId,
44130
+ * urlSlug,
44131
+ * visitorId
44132
+ * }
44133
+ * }
44134
+ * );
44135
+ *
44136
+ * // The properties are already loaded, so you can use them immediately
44137
+ * console.log(visitorInstance.username);
44138
+ * console.log(visitorInstance.position);
43214
44139
  * ```
43215
44140
  *
43216
- * @returns {Promise<Visitor>} Returns a new Visitor object with all properties.
44141
+ * @returns {Promise<Visitor>} Returns a new Visitor object with all properties already fetched.
43217
44142
  */
43218
44143
  get(id, urlSlug, options) {
43219
44144
  return __awaiter(this, void 0, void 0, function* () {
@@ -43225,9 +44150,20 @@ class VisitorFactory {
43225
44150
  }
43226
44151
 
43227
44152
  /**
44153
+ * Factory for creating WebRTCConnector instances. Use this factory to establish WebRTC connections for audio/video in Topia worlds.
44154
+ *
44155
+ * @remarks
44156
+ * This factory should be instantiated once per application and reused across your codebase.
44157
+ * The WebRTCConnector provides methods to set up and manage real-time audio/video communication.
44158
+ *
44159
+ * @keywords webrtc, factory, create, audio, video, communication, real-time, conference
44160
+ *
43228
44161
  * @example
43229
44162
  * ```ts
43230
- * const WebRTCConnector = new WebRTCConnectorFactory(myTopiaInstance);
44163
+ * // In your initialization file (e.g., utils/topiaInit.ts)
44164
+ * import { Topia, WebRTCConnectorFactory } from "@rtsdk/topia";
44165
+ * const topia = new Topia({ config });
44166
+ * export const WebRTCConnector = new WebRTCConnectorFactory(topia);
43231
44167
  * ```
43232
44168
  */
43233
44169
  class WebRTCConnectorFactory {
@@ -43235,24 +44171,92 @@ class WebRTCConnectorFactory {
43235
44171
  this.topia = topia;
43236
44172
  }
43237
44173
  /**
43238
- * Instantiate a new instance of WebRTCConnector class.
44174
+ * Instantiate a new instance of WebRTCConnector class for managing audio/video communication.
44175
+ *
44176
+ * @remarks
44177
+ * This method creates a controller instance for establishing and managing WebRTC connections.
44178
+ * Use this for implementing real-time audio/video communication features in Topia worlds.
44179
+ *
44180
+ * @keywords create, instantiate, webrtc, initialize, audio, video, communication, stream
43239
44181
  *
43240
44182
  * @example
43241
- * ```
43242
- * const webRTCInstance = await WebRTCConnector.create({ credentials: { interactiveNonce, interactivePublicKey, assetId, urlSlug, visitorId }, twilioConfig: {} });
44183
+ * ```ts
44184
+ * // Import the pre-initialized factory from your app's initialization file
44185
+ * import { WebRTCConnector } from "utils/topiaInit.ts";
44186
+ *
44187
+ * // Create a WebRTCConnector instance with credentials and configuration
44188
+ * const webRTCInstance = WebRTCConnector.create(
44189
+ * "my-world-slug",
44190
+ * {
44191
+ * credentials: {
44192
+ * interactiveNonce,
44193
+ * interactivePublicKey,
44194
+ * assetId,
44195
+ * urlSlug,
44196
+ * visitorId
44197
+ * },
44198
+ * twilioConfig: {
44199
+ * // Twilio configuration options
44200
+ * }
44201
+ * }
44202
+ * );
44203
+ *
44204
+ * // Use the instance to establish connections
44205
+ * await webRTCInstance.connect();
43243
44206
  * ```
43244
44207
  *
43245
- * @returns {WebRTCConnector} Returns a new WebRTCConnector object.
44208
+ * @returns {WebRTCConnector} Returns a new WebRTCConnector object for managing audio/video communication.
43246
44209
  */
43247
44210
  create(urlSlug, options) {
43248
44211
  return new WebRTCConnector(this.topia, urlSlug, options);
43249
44212
  }
43250
44213
  }
43251
44214
 
44215
+ /* ============================================================================
44216
+ AI RULES for code assistants
44217
+
44218
+ - Consumers MUST create a single Topia client in their app (e.g. utils/topiaInit.ts).
44219
+ - Consumers MUST instantiate this factory ONCE using that client and RE-USE it.
44220
+ - Controllers/services MUST import the app’s exported factory instance.
44221
+ - Use ONLY methods defined in this file’s types and TSDoc.
44222
+ - Methods that DO NOT exist and MUST NOT be suggested.
44223
+
44224
+ RIGHT ✅ Correct usage pattern (consumer app):
44225
+ // utils/topiaInit.ts
44226
+ import { Topia, WorldActivityFactory } from "@rtsdk/topia";
44227
+ const topia = new Topia({ config });
44228
+ export const WorldActivity = new WorldActivityFactory(topia);
44229
+
44230
+ RIGHT ✅ Correct usage pattern (controller):
44231
+ // controllers/myController.ts
44232
+ import { WorldActivity } from "utils/topiaInit.ts";
44233
+ const activity = await WorldActivity.create(urlSlug, { credentials });
44234
+ await activity.currentVisitors();
44235
+
44236
+ WRONG ❌ Incorrect usage pattern (controller):
44237
+ // controllers/myController.ts
44238
+ import { WorldActivity, Topia } from "@rtsdk/topia";
44239
+ const topia = new Topia(config); // ❌ new client per request
44240
+ const WorldActivity = new WorldActivityFactory(topia); // ❌ ad-hoc factory
44241
+ const activity = await WorldActivity.getAllVisitors(); // ❌ method does not exist
44242
+
44243
+ Do NOT instantiate factories in controllers. Do NOT invent methods.
44244
+ ============================================================================ */
43252
44245
  /**
44246
+ * Factory for creating WorldActivity instances. Use this factory to monitor and manage visitor activity in Topia worlds.
44247
+ *
44248
+ * @remarks
44249
+ * This factory should be instantiated once per application and reused across your codebase.
44250
+ * The WorldActivity controller provides methods to interact with real-time visitor activities and movements.
44251
+ *
44252
+ * @keywords world activity, factory, create, visitors, movement, tracking, presence, real-time
44253
+ *
43253
44254
  * @example
43254
44255
  * ```ts
43255
- * const WorldActivity = new WorldActivityFactory(myTopiaInstance);
44256
+ * // In your initialization file (e.g., utils/topiaInit.ts)
44257
+ * import { Topia, WorldActivityFactory } from "@rtsdk/topia";
44258
+ * const topia = new Topia({ config });
44259
+ * export const WorldActivity = new WorldActivityFactory(topia);
43256
44260
  * ```
43257
44261
  */
43258
44262
  class WorldActivityFactory {
@@ -43260,24 +44264,93 @@ class WorldActivityFactory {
43260
44264
  this.topia = topia;
43261
44265
  }
43262
44266
  /**
43263
- * Instantiate a new instance of WorldActivity class.
44267
+ * Instantiate a new instance of WorldActivity class for monitoring visitor activity in a specific world.
44268
+ *
44269
+ * @remarks
44270
+ * This method creates a controller instance for tracking and managing visitor activity in a world.
44271
+ * Use this to fetch current visitors, move visitors, or monitor specific zones within a world.
44272
+ *
44273
+ * @keywords create, instantiate, world activity, initialize, visitors, tracking, presence
43264
44274
  *
43265
44275
  * @example
43266
- * ```
43267
- * const worldActivityInstance = await WorldActivity.create(urlSlug, { credentials: { interactiveNonce, interactivePublicKey, assetId, urlSlug, visitorId } });
44276
+ * ```ts
44277
+ * // Import the pre-initialized factory from your app's initialization file
44278
+ * import { WorldActivity } from "utils/topiaInit.ts";
44279
+ *
44280
+ * // Create a WorldActivity instance with credentials
44281
+ * const worldActivityInstance = WorldActivity.create(
44282
+ * "my-world-slug",
44283
+ * {
44284
+ * credentials: {
44285
+ * interactiveNonce,
44286
+ * interactivePublicKey,
44287
+ * assetId,
44288
+ * urlSlug,
44289
+ * visitorId
44290
+ * }
44291
+ * }
44292
+ * );
44293
+ *
44294
+ * // Get current visitors in the world
44295
+ * const visitors = await worldActivityInstance.currentVisitors();
44296
+ * console.log(`There are ${visitors.length} visitors in the world`);
44297
+ *
44298
+ * // Check visitors in a specific zone
44299
+ * const zoneVisitors = await worldActivityInstance.fetchVisitorsInZone("stage-area");
43268
44300
  * ```
43269
44301
  *
43270
- * @returns {WorldActivity} Returns a new WorldActivity object.
44302
+ * @returns {WorldActivity} Returns a new WorldActivity object for tracking and managing visitor activity.
43271
44303
  */
43272
44304
  create(urlSlug, options) {
43273
44305
  return new WorldActivity(this.topia, urlSlug, options);
43274
44306
  }
43275
44307
  }
43276
44308
 
44309
+ /* ============================================================================
44310
+ AI RULES for code assistants
44311
+
44312
+ - Consumers MUST create a single Topia client in their app (e.g. utils/topiaInit.ts).
44313
+ - Consumers MUST instantiate this factory ONCE using that client and RE-USE it.
44314
+ - Controllers/services MUST import the app’s exported factory instance.
44315
+ - Use ONLY methods defined in this file’s types and TSDoc.
44316
+ - Methods that DO NOT exist and MUST NOT be suggested.
44317
+
44318
+ RIGHT ✅ Correct usage pattern (consumer app):
44319
+ // utils/topiaInit.ts
44320
+ import { Topia, WorldFactory } from "@rtsdk/topia";
44321
+ const topia = new Topia({ config });
44322
+ export const World = new WorldFactory(topia);
44323
+
44324
+ RIGHT ✅ Correct usage pattern (controller):
44325
+ // controllers/myController.ts
44326
+ import { World } from "utils/topiaInit.ts";
44327
+ const world = await World.create(urlSlug, { credentials });
44328
+ await world.fetchDetails();
44329
+
44330
+ WRONG ❌ Incorrect usage pattern (controller):
44331
+ // controllers/myController.ts
44332
+ import { World, Topia } from "@rtsdk/topia";
44333
+ const topia = new Topia(config); // ❌ new client per request
44334
+ const World = new WorldFactory(topia); // ❌ ad-hoc factory
44335
+ const world = await World.update({}); // ❌ method does not exist
44336
+
44337
+ Do NOT instantiate factories in controllers. Do NOT invent methods.
44338
+ ============================================================================ */
43277
44339
  /**
44340
+ * Factory for creating World instances. Use this factory to interact with Topia worlds.
44341
+ *
44342
+ * @remarks
44343
+ * This factory should be instantiated once per application and reused across your codebase.
44344
+ * The World controller provides methods to manage world settings, retrieve world details, and perform world-level operations.
44345
+ *
44346
+ * @keywords world, factory, create, virtual space, environment, room, topia
44347
+ *
43278
44348
  * @example
43279
44349
  * ```ts
43280
- * const World = new WorldFactory(myTopiaInstance);
44350
+ * // In your initialization file (e.g., utils/topiaInit.ts)
44351
+ * import { Topia, WorldFactory } from "@rtsdk/topia";
44352
+ * const topia = new Topia({ config });
44353
+ * export const World = new WorldFactory(topia);
43281
44354
  * ```
43282
44355
  */
43283
44356
  class WorldFactory extends SDKController {
@@ -43285,27 +44358,75 @@ class WorldFactory extends SDKController {
43285
44358
  super(topia);
43286
44359
  }
43287
44360
  /**
43288
- * Instantiate a new instance of World class.
44361
+ * Instantiate a new instance of World class for interacting with a specific Topia world.
44362
+ *
44363
+ * @remarks
44364
+ * This method creates a controller instance for a world identified by its URL slug.
44365
+ * The world controller can be used to fetch details, update world settings, and perform other world-level operations.
44366
+ *
44367
+ * @keywords create, instantiate, world, initialize, virtual space, environment, room
43289
44368
  *
43290
44369
  * @example
43291
- * ```
43292
- * const worldInstance = await World.create(urlSlug, { credentials: { interactiveNonce, interactivePublicKey, assetId, urlSlug, visitorId } });
44370
+ * ```ts
44371
+ * // Import the pre-initialized factory from your app's initialization file
44372
+ * import { World } from "utils/topiaInit.ts";
44373
+ *
44374
+ * // Create a World instance with credentials
44375
+ * const worldInstance = World.create(
44376
+ * "my-world-slug",
44377
+ * {
44378
+ * credentials: {
44379
+ * interactiveNonce,
44380
+ * interactivePublicKey,
44381
+ * assetId,
44382
+ * urlSlug,
44383
+ * visitorId
44384
+ * }
44385
+ * }
44386
+ * );
44387
+ *
44388
+ * // Fetch world details
44389
+ * await worldInstance.fetchDetails();
44390
+ * console.log(worldInstance.name);
43293
44391
  * ```
43294
44392
  *
43295
- * @returns {World} Returns a new World object.
44393
+ * @returns {World} Returns a new World object for interacting with the specified world.
43296
44394
  */
43297
44395
  create(urlSlug, options) {
43298
44396
  return new World(this.topia, urlSlug, options);
43299
44397
  }
43300
44398
  /**
43301
- * Deletes an array of Dropped Assets from within a world and returns success: true
44399
+ * Deletes multiple dropped assets from a world in a single operation.
44400
+ *
44401
+ * @remarks
44402
+ * This method provides a convenient way to delete multiple dropped assets at once rather than
44403
+ * deleting them one by one. Requires appropriate permissions via interactive credentials.
44404
+ *
44405
+ * @keywords delete, remove, dropped assets, multiple, batch, cleanup, world
43302
44406
  *
43303
44407
  * @example
43304
- * ```
43305
- * await World.deleteDroppedAssets(urlSlug, ["exampleDroppedAssetId1", "exampleDroppedAssetId2"], interactiveSecret, credentials);
44408
+ * ```ts
44409
+ * // Import the pre-initialized factory from your app's initialization file
44410
+ * import { World } from "utils/topiaInit.ts";
44411
+ *
44412
+ * // Delete multiple dropped assets from a world
44413
+ * const result = await World.deleteDroppedAssets(
44414
+ * "my-world-slug",
44415
+ * ["asset-id-123", "asset-id-456", "asset-id-789"],
44416
+ * "your-interactive-secret",
44417
+ * {
44418
+ * apiKey: "your-api-key",
44419
+ * interactivePublicKey: "your-public-key",
44420
+ * visitorId: 12345
44421
+ * }
44422
+ * );
44423
+ *
44424
+ * if (result.success) {
44425
+ * console.log("Assets successfully deleted");
44426
+ * }
43306
44427
  * ```
43307
44428
  *
43308
- * @returns {Promise<{ success: boolean }>} Returns `{ success: true }` or an error.
44429
+ * @returns {Promise<{ success: boolean }>} Returns `{ success: true }` if all assets were deleted successfully.
43309
44430
  */
43310
44431
  deleteDroppedAssets(urlSlug, droppedAssetIds, interactiveSecret, credentials) {
43311
44432
  return __awaiter(this, void 0, void 0, function* () {