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