@rtsdk/topia 0.8.5 → 0.9.0

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 CHANGED
@@ -1,12 +1,10 @@
1
1
  # Javascript RTSDK - Topia Client Library
2
2
 
3
- The Topia Client Library leverages the Topia Public API and allows users to interact with the topia systems and modify their world programmatically. With the SDK you can now build new features to be used in Topia! Check out a list of examples [here](https://github.com/metaversecloud-com/sdk-examples). Questions, comments, or have something exciting to share with the Topia team? Reach out to [developers@topia.io](mailto:developers@topia.io)!
4
-
5
- <br>
3
+ The Topia Client Library leverages the Topia Public API and allows users to interact with the topia systems and modify their world programmatically. With the SDK you can now build new features to be used in Topia! Questions, comments, or have something exciting to share with the Topia team? Reach out to [developers@topia.io](mailto:developers@topia.io)!
6
4
 
7
5
  ## Authorization
8
6
 
9
- A Topia provided API Key can be included with every object initialization as a parameter named `apiKey`. This API Key is used to in authorization headers in all calls to the Public API.
7
+ A Topia provided API Key can be included with every object initialization as a parameter named `apiKey`. This API Key is used to in authorization headers in all calls to the Public API. Use it wisely and sparingly! The API Key should only be used to authorize your app (and therefore all of it's users) to perform specific actions. In most case the ability to interact with an SDK application should be controlled per user using Interactive Credentials (see below).
10
8
 
11
9
  ### Want to build interactive assets? This is how you can get started:
12
10
 
@@ -37,11 +35,9 @@ Make an asset “interactive” by adding your PUBLIC key to the integrations pa
37
35
  ```ts
38
36
  await DroppedAsset.get(assetId, urlSlug, {
39
37
  credentials: {
40
- assetId,
41
38
  interactivePublicKey,
42
39
  interactiveNonce,
43
40
  visitorId,
44
- urlSlug,
45
41
  },
46
42
  });
47
43
  ```
@@ -58,7 +54,7 @@ await DroppedAsset.get(assetId, urlSlug, {
58
54
 
59
55
  Alternatively, visitors of a [topia.io](https://topia.io/) world interact with each other and the interactively configured assets in your world without the need for an API Key. This is all made possible through Interactive Session credentials passed to the SDK with every request, when applicable. What does this mean for you? Not much, actually! All of the magic happens behind the scenes and all you have to do is make sure that new class constructors include an options object like this: `options: WorldOptionalInterface = { attributes: {}, credentials: {} }` and all calls to `this.topia.axios` include the inherited `this.requestOptions` parameter.
60
56
 
61
- ![Interactive Application Development Diagram](./InteractiveApplicationDevelopment.png)
57
+ ![Interactive Application Development Diagram](https://raw.githubusercontent.com/metaversecloud-com/mc-sdk-js/main/clients/client-topia/InteractiveApplicationDevelopment.png)
62
58
 
63
59
  <br>
64
60
 
@@ -66,12 +62,28 @@ Alternatively, visitors of a [topia.io](https://topia.io/) world interact with e
66
62
 
67
63
  # Developers
68
64
 
69
- Need inspiration?! Check out our [example application](https://sdk-examples.metaversecloud.com/) which utilizes the SDK to create new and enhanced features inside [topia.io](https://topia.io/).
65
+ <hr/>
66
+
67
+ Need inspiration?! Check out the following applications which utilizes the SDK to create new and enhanced features inside [topia.io](https://topia.io/):
68
+
69
+ - **TicTacToe:** A turn based multiplayer game built completely on the canvas.
70
+ - [Github](https://github.com/metaversecloud-com/sdk-tictactoe)
71
+ - [Demo](https://topia.io/tictactoe-prod)
72
+ - **Quest:** A dynamic hide and seek game where an admin can drop multiple quest items within a world for users to find.
73
+ - [Github](https://github.com/metaversecloud-com/sdk-quest)
74
+ - [Demo](https://topia.io/quest-prod)
70
75
 
71
76
  <br>
72
77
 
73
78
  ## Get Started
74
79
 
80
+ ### Boilerplates
81
+
82
+ We have two boilerplates available to help you get started. Pick the one that best suits your needs, clone it, and let the coding begin!
83
+
84
+ - [Javascript](https://github.com/metaversecloud-com/sdk-boilerplate)
85
+ - [Typescript](https://github.com/metaversecloud-com/sdk-ts-boilerplate)
86
+
75
87
  Run `yarn add @rtsdk/topia` or `npm install @rtsdk/topia`
76
88
 
77
89
  Create your instance of Topia and instantiate the factories you need:
@@ -84,7 +96,6 @@ import { AssetFactory, Topia, DroppedAssetFactory, UserFactory, WorldFactory } f
84
96
 
85
97
  const config = {
86
98
  apiDomain: process.env.INSTANCE_DOMAIN || "https://api.topia.io/",
87
- apiKey: process.env.API_KEY,
88
99
  interactiveKey: process.env.INTERACTIVE_KEY,
89
100
  interactiveSecret: process.env.INTERACTIVE_SECRET,
90
101
  };
@@ -107,10 +118,14 @@ Put it to use:
107
118
  import { DroppedAsset } from "./pathToAboveCode";
108
119
 
109
120
  export const getAssetAndDataObject = async (req) => {
110
- const { assetId, urlSlug } = req.body;
121
+ const { assetId, interactiveNonce, interactivePublicKey, urlSlug, visitorId } = req.query;
111
122
 
112
123
  const droppedAsset = await DroppedAsset.get(assetId, urlSlug, {
113
- credentials: req.body,
124
+ credentials: {
125
+ interactiveNonce,
126
+ interactivePublicKey,
127
+ visitorId,
128
+ },
114
129
  });
115
130
 
116
131
  await droppedAsset.fetchDroppedAssetDataObject();
@@ -118,10 +133,90 @@ export const getAssetAndDataObject = async (req) => {
118
133
  };
119
134
  ```
120
135
 
136
+ ## Data Objects
137
+
138
+ Data Objects can be used to store information such as game state, configurations, themes, and analytics.
139
+ There are three types of Data Objects:
140
+
141
+ - **World:** The World data object should be used to store information unique to your app in a given world but not necessarily specific details about an instance or an active game. This information would persist even if the app was removed from the world.
142
+ - **Example - Update two specific data points:**
143
+ ```js
144
+ await world.updateDataObject({
145
+ [`keyAssets.${keyAssetId}.itemsCollectedByUser.${profileId}`]: { [dateKey]: { count: 1 }, total: 1 },
146
+ [`profileMapper.${profileId}`]: username,
147
+ });
148
+ ```
149
+ - **Example - Increment a specific value within the data object by 1:**
150
+ ```js
151
+ await world.incrementDataObjectValue([`keyAssets.${keyAssetId}.totalItemsCollected.count`], 1);
152
+ ```
153
+ - **Dropped Asset:** The Dropped Asset data object should only store what is unique to the specific instance of the app in the world such as game state. If the Dropped Asset is deleted, the data object would be lost as well so be sure to only store information here the doesn't need to persist!
154
+ - **Example - Initialize data object with default data and keyAssetId:**
155
+ ```js
156
+ await droppedAsset.setDataObject(
157
+ {
158
+ ...defaultGameData,
159
+ keyAssetId: droppedAsset.id,
160
+ },
161
+ { lock: { lockId, releaseLock: true } },
162
+ );
163
+ ```
164
+ - **Example - Update lastInteraction date and playerCount:**
165
+ ```js
166
+ await droppedAsset.updateDataObject({ lastInteraction: new Date(), playerCount: playerCount + 1 });
167
+ ```
168
+ - **User:** The User data object should be used to store information unique to a user that is NOT unique to a world or instance (dropped asset) of an app.
169
+ - **Example - Update totalMessagesSentCount by a user across all worlds:**
170
+ ```js
171
+ await world.incrementDataObjectValue([`totalMessagesSentCount`], 1);
172
+ ```
173
+
174
+ ### Data Object Locking
175
+
176
+ All of our data object set, update, and increment methods have an optional lock argument. You can create a lock id using that parameters specific to the action you are taking plus a timestamp so that the lock will expire after a certain amount of time has passed. As an example, TicTacToe allows users to Reset the game board so that they can start a new game but we'd only want the reset to happen once even if the user(s) press the button multiple times. To prevent multiple resets from happening within a 10 second window (stopping the calls from going through and preventing the race condition), we'd lock the object by doing the following:
177
+
178
+ ```js
179
+ try {
180
+ await droppedAsset.updateDataObject(
181
+ { isResetInProgress: true },
182
+ {
183
+ lock: { lockId: `${assetId}-${resetCount}-${new Date(Math.round(new Date().getTime() / 10000) * 10000)}` },
184
+ },
185
+ );
186
+ } catch (error) {
187
+ return res.status(409).json({ message: "Reset already in progress." });
188
+ }
189
+ ```
190
+
191
+ Using the code above would also allow us to check if `isResetInProgress === true` and prevent the code from progress immediately. Make sure that when using a lock such as this that you also call `await droppedAsset.updateDataObject({ isResetInProgress: false })};` after all reset functionality has been executed.
192
+
193
+ **Turn based locking**
194
+ Locking data object updates can also be extremely helpful when building a turn based game. As an example, TicTacToe should only allow one user to take a turn at a time. To prevent multiple moves at once we could use the following:
195
+
196
+ ```js
197
+ try {
198
+ const timestamp = new Date(Math.round(new Date().getTime() / 5000) * 5000);
199
+ const lockId = `${keyAssetId}-${resetCount}-${turnCount}-${timestamp}`;
200
+ await droppedAsset.updateDataObject({}, { lock: { lockId, releaseLock: false } });
201
+ } catch (error) {
202
+ return res.status(409).json({ message: "Move already in progress." });
203
+ }
204
+ ```
205
+
206
+ Once complete be sure to also call `await keyAsset.updateDataObject({ turnCount: turnCount + 1 });` so that the next player is free to take their turn!
207
+
208
+ <br>
209
+
121
210
  <hr/>
122
211
 
212
+ <br>
213
+
123
214
  # Contributors
124
215
 
216
+ <hr/>
217
+
218
+ <br>
219
+
125
220
  ## Get Started
126
221
 
127
222
  Run `gh repo clone metaversecloud-com/mc-sdk-js`
package/dist/index.cjs CHANGED
@@ -39717,7 +39717,7 @@ class SDKController {
39717
39717
  */
39718
39718
  class Asset extends SDKController {
39719
39719
  constructor(topia, id, options = { attributes: {}, credentials: {} }) {
39720
- var _a, _b, _c, _d, _e;
39720
+ var _a, _b, _c, _d, _e, _f;
39721
39721
  // assetId and urlSlug should only be used when Asset is extended by DroppedAsset
39722
39722
  super(topia, {
39723
39723
  apiKey: (_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.apiKey,
@@ -39727,12 +39727,23 @@ class Asset extends SDKController {
39727
39727
  visitorId: (_e = options === null || options === void 0 ? void 0 : options.credentials) === null || _e === void 0 ? void 0 : _e.visitorId,
39728
39728
  });
39729
39729
  this.id = id;
39730
+ this.urlSlug = (_f = options === null || options === void 0 ? void 0 : options.credentials) === null || _f === void 0 ? void 0 : _f.urlSlug;
39730
39731
  Object.assign(this, options.attributes);
39731
39732
  }
39733
+ /**
39734
+ * @summary
39735
+ * Retrieves platform asset details.
39736
+ *
39737
+ * @usage
39738
+ * ```ts
39739
+ * await asset.fetchAssetById();
39740
+ * const { assetName } = asset;
39741
+ * ```
39742
+ */
39732
39743
  fetchAssetById() {
39733
39744
  return __awaiter(this, void 0, void 0, function* () {
39734
39745
  try {
39735
- const response = yield this.topiaPublicApi().get(`/assets/${this.id}`, this.requestOptions);
39746
+ const response = yield this.topiaPublicApi().get(`/assets/${this.urlSlug}/${this.id}`, this.requestOptions);
39736
39747
  return response.data;
39737
39748
  }
39738
39749
  catch (error) {
@@ -39852,8 +39863,8 @@ class DroppedAsset extends Asset {
39852
39863
  setDataObject(dataObject, options = {}) {
39853
39864
  return __awaiter(this, void 0, void 0, function* () {
39854
39865
  try {
39855
- const { lock = {} } = options;
39856
- yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/set-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
39866
+ const { analytics = [], lock = {} } = options;
39867
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/set-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
39857
39868
  this.dataObject = dataObject || this.dataObject;
39858
39869
  }
39859
39870
  catch (error) {
@@ -39878,8 +39889,8 @@ class DroppedAsset extends Asset {
39878
39889
  updateDataObject(dataObject, options = {}) {
39879
39890
  return __awaiter(this, void 0, void 0, function* () {
39880
39891
  try {
39881
- const { lock = {} } = options;
39882
- yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/update-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
39892
+ const { analytics = [], lock = {} } = options;
39893
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/update-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
39883
39894
  this.dataObject = Object.assign(Object.assign({}, (this.dataObject || {})), (dataObject || {}));
39884
39895
  }
39885
39896
  catch (error) {
@@ -39904,8 +39915,8 @@ class DroppedAsset extends Asset {
39904
39915
  incrementDataObjectValue(path, amount, options = {}) {
39905
39916
  return __awaiter(this, void 0, void 0, function* () {
39906
39917
  try {
39907
- const { lock = {} } = options;
39908
- yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/increment-data-object-value`, { path, amount, lock }, this.requestOptions);
39918
+ const { analytics = [], lock = {} } = options;
39919
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/assets/${this.id}/increment-data-object-value`, { path, amount, analytics, lock }, this.requestOptions);
39909
39920
  }
39910
39921
  catch (error) {
39911
39922
  throw this.errorHandler({
@@ -40313,6 +40324,16 @@ class Scene extends SDKController {
40313
40324
  this.id = id;
40314
40325
  Object.assign(this, options.attributes);
40315
40326
  }
40327
+ /**
40328
+ * @summary
40329
+ * Retrieves scene details.
40330
+ *
40331
+ * @usage
40332
+ * ```ts
40333
+ * await scene.fetchSceneById();
40334
+ * const { name } = scene;
40335
+ * ```
40336
+ */
40316
40337
  fetchSceneById() {
40317
40338
  return __awaiter(this, void 0, void 0, function* () {
40318
40339
  try {
@@ -40413,8 +40434,8 @@ class World extends SDKController {
40413
40434
  */
40414
40435
  this.setDataObject = (dataObject, options = {}) => __awaiter(this, void 0, void 0, function* () {
40415
40436
  try {
40416
- const { lock = {} } = options;
40417
- yield this.topiaPublicApi().put(`/world/${this.urlSlug}/set-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
40437
+ const { analytics = [], lock = {} } = options;
40438
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/set-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
40418
40439
  this.dataObject = Object.assign(Object.assign({}, (this.dataObject || {})), (dataObject || {}));
40419
40440
  }
40420
40441
  catch (error) {
@@ -40437,8 +40458,8 @@ class World extends SDKController {
40437
40458
  */
40438
40459
  this.updateDataObject = (dataObject, options = {}) => __awaiter(this, void 0, void 0, function* () {
40439
40460
  try {
40440
- const { lock = {} } = options;
40441
- yield this.topiaPublicApi().put(`/world/${this.urlSlug}/update-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
40461
+ const { analytics = [], lock = {} } = options;
40462
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/update-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
40442
40463
  this.dataObject = dataObject || this.dataObject;
40443
40464
  }
40444
40465
  catch (error) {
@@ -40830,8 +40851,8 @@ class World extends SDKController {
40830
40851
  incrementDataObjectValue(path, amount, options = {}) {
40831
40852
  return __awaiter(this, void 0, void 0, function* () {
40832
40853
  try {
40833
- const { lock = {} } = options;
40834
- yield this.topiaPublicApi().put(`/world/${this.urlSlug}/increment-data-object-value`, { path, amount, lock }, this.requestOptions);
40854
+ const { analytics, lock = {} } = options;
40855
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/increment-data-object-value`, { path, amount, analytics, lock }, this.requestOptions);
40835
40856
  }
40836
40857
  catch (error) {
40837
40858
  throw this.errorHandler({
@@ -40955,6 +40976,12 @@ class User extends SDKController {
40955
40976
  /**
40956
40977
  * @summary
40957
40978
  * Returns all assets owned by User when an email address is provided.
40979
+ *
40980
+ * @usage
40981
+ * ```ts
40982
+ * await user.fetchAssets();
40983
+ * const userAssets = user.assets;
40984
+ * ```
40958
40985
  */
40959
40986
  fetchAssets() {
40960
40987
  return __awaiter(this, void 0, void 0, function* () {
@@ -40977,7 +41004,12 @@ class User extends SDKController {
40977
41004
  }
40978
41005
  /**
40979
41006
  * @summary
40980
- * Returns all platform assets
41007
+ * Returns all platform assets.
41008
+ *
41009
+ * @usage
41010
+ * ```ts
41011
+ * const assets = await user.fetchPlatformAssets();
41012
+ * ```
40981
41013
  */
40982
41014
  fetchPlatformAssets() {
40983
41015
  return __awaiter(this, void 0, void 0, function* () {
@@ -40992,7 +41024,13 @@ class User extends SDKController {
40992
41024
  }
40993
41025
  /**
40994
41026
  * @summary
40995
- * Returns all scenes owned by User
41027
+ * Returns all scenes owned by User.
41028
+ *
41029
+ * @usage
41030
+ * ```ts
41031
+ * await user.fetchScenes();
41032
+ * const userScenes = user.scenes;
41033
+ * ```
40996
41034
  */
40997
41035
  fetchScenes() {
40998
41036
  return __awaiter(this, void 0, void 0, function* () {
@@ -41141,8 +41179,8 @@ class User extends SDKController {
41141
41179
  try {
41142
41180
  if (!this.profileId)
41143
41181
  throw "This method requires the use of a profileId";
41144
- const { lock = {} } = options;
41145
- yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/set-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
41182
+ const { analytics = [], lock = {} } = options;
41183
+ yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/set-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
41146
41184
  this.dataObject = dataObject || this.dataObject;
41147
41185
  }
41148
41186
  catch (error) {
@@ -41168,8 +41206,8 @@ class User extends SDKController {
41168
41206
  try {
41169
41207
  if (!this.profileId)
41170
41208
  throw "This method requires the use of a profileId";
41171
- const { lock = {} } = options;
41172
- yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/update-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
41209
+ const { analytics = [], lock = {} } = options;
41210
+ yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/update-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
41173
41211
  this.dataObject = Object.assign(Object.assign({}, (this.dataObject || {})), (dataObject || {}));
41174
41212
  }
41175
41213
  catch (error) {
@@ -41194,8 +41232,8 @@ class User extends SDKController {
41194
41232
  incrementDataObjectValue(path, amount, options = {}) {
41195
41233
  return __awaiter(this, void 0, void 0, function* () {
41196
41234
  try {
41197
- const { lock = {} } = options;
41198
- yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/increment-data-object-value`, { path, amount, lock }, this.requestOptions);
41235
+ const { analytics = [], lock = {} } = options;
41236
+ yield this.topiaPublicApi().put(`/user/dataObjects/${this.profileId}/increment-data-object-value`, { path, amount, analytics, lock }, this.requestOptions);
41199
41237
  }
41200
41238
  catch (error) {
41201
41239
  throw this.errorHandler({ error, params: { path, amount, options }, sdkMethod: "User.incrementDataObjectValue" });
@@ -41466,8 +41504,8 @@ class Visitor extends User {
41466
41504
  setDataObject(dataObject, options = {}) {
41467
41505
  return __awaiter(this, void 0, void 0, function* () {
41468
41506
  try {
41469
- const { lock = {} } = options;
41470
- yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/set-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
41507
+ const { analytics = [], lock = {} } = options;
41508
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/set-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
41471
41509
  this.dataObject = Object.assign(Object.assign({}, (this.dataObject || {})), (dataObject || {}));
41472
41510
  }
41473
41511
  catch (error) {
@@ -41491,8 +41529,8 @@ class Visitor extends User {
41491
41529
  updateDataObject(dataObject, options = {}) {
41492
41530
  return __awaiter(this, void 0, void 0, function* () {
41493
41531
  try {
41494
- const { lock = {} } = options;
41495
- yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/update-data-object`, { dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
41532
+ const { analytics = [], lock = {} } = options;
41533
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/update-data-object`, { analytics, dataObject: dataObject || this.dataObject, lock }, this.requestOptions);
41496
41534
  this.dataObject = dataObject || this.dataObject;
41497
41535
  }
41498
41536
  catch (error) {
@@ -41517,8 +41555,8 @@ class Visitor extends User {
41517
41555
  incrementDataObjectValue(path, amount, options = {}) {
41518
41556
  return __awaiter(this, void 0, void 0, function* () {
41519
41557
  try {
41520
- const { lock = {} } = options;
41521
- yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/increment-data-object-value`, { path, amount, lock }, this.requestOptions);
41558
+ const { analytics = [], lock = {} } = options;
41559
+ yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/increment-data-object-value`, { path, amount, analytics, lock }, this.requestOptions);
41522
41560
  }
41523
41561
  catch (error) {
41524
41562
  throw this.errorHandler({
@@ -41713,23 +41751,62 @@ class Topia {
41713
41751
  }
41714
41752
  }
41715
41753
 
41754
+ /**
41755
+ * @usage
41756
+ * ```ts
41757
+ * const Asset = new AssetFactory(myTopiaInstance);
41758
+ * ```
41759
+ */
41716
41760
  class AssetFactory {
41717
41761
  constructor(topia) {
41718
41762
  this.topia = topia;
41719
41763
  this.create;
41720
41764
  }
41765
+ /**
41766
+ * @summary
41767
+ * Instantiate a new instance of Asset class.
41768
+ *
41769
+ * @usage
41770
+ * ```
41771
+ * const assetInstance = await Asset.create(id, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
41772
+ * ```
41773
+ */
41721
41774
  create(id, options) {
41722
41775
  return new Asset(this.topia, id, options);
41723
41776
  }
41724
41777
  }
41725
41778
 
41779
+ /**
41780
+ * @usage
41781
+ * ```ts
41782
+ * const DroppedAsset = new DroppedAssetFactory(myTopiaInstance);
41783
+ * ```
41784
+ */
41726
41785
  class DroppedAssetFactory extends SDKController {
41727
41786
  constructor(topia) {
41728
41787
  super(topia);
41729
41788
  }
41789
+ /**
41790
+ * @summary
41791
+ * Instantiate a new instance of DroppedAsset class.
41792
+ *
41793
+ * @usage
41794
+ * ```
41795
+ * const droppedAssetInstance = await DroppedAsset.create(assetId, urlSlug, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
41796
+ * ```
41797
+ */
41730
41798
  create(id, urlSlug, options) {
41731
41799
  return new DroppedAsset(this.topia, id, urlSlug, options);
41732
41800
  }
41801
+ /**
41802
+ * @summary
41803
+ * Instantiate a new instance of DroppedAsset class and retrieve all properties.
41804
+ *
41805
+ * @usage
41806
+ * ```
41807
+ * const droppedAssetInstance = await DroppedAsset.get(assetId, urlSlug, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
41808
+ * ```
41809
+ */
41733
41810
  get(id, urlSlug, options) {
41734
41811
  return __awaiter(this, void 0, void 0, function* () {
41735
41812
  const droppedAsset = new DroppedAsset(this.topia, id, urlSlug, options);
@@ -41737,6 +41814,15 @@ class DroppedAssetFactory extends SDKController {
41737
41814
  return droppedAsset;
41738
41815
  });
41739
41816
  }
41817
+ /**
41818
+ * @summary
41819
+ * Searches dropped assets within a world by a provide `uniqueName`. If a single match is found, a new instance of DroppedAsset class is returned all properties.
41820
+ *
41821
+ * @usage
41822
+ * ```
41823
+ * const droppedAssetInstance = await DroppedAsset.getWithUniqueName("exampleUniqueName", urlSlug, { interactivePublicKey, interactiveSecret });
41824
+ * ```
41825
+ */
41740
41826
  getWithUniqueName(uniqueName, urlSlug, credentials) {
41741
41827
  return __awaiter(this, void 0, void 0, function* () {
41742
41828
  const { apiKey, interactivePublicKey, interactiveSecret } = credentials;
@@ -41759,6 +41845,26 @@ class DroppedAssetFactory extends SDKController {
41759
41845
  }
41760
41846
  });
41761
41847
  }
41848
+ /**
41849
+ * @summary
41850
+ * Drops an asset in a world and returns a new instance of DroppedAsset class with all properties.
41851
+ *
41852
+ * @usage
41853
+ * ```
41854
+ * const assetInstance = await Asset.create(id, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
41855
+ * const droppedAssetInstance = await DroppedAsset.get(assetInstance, {
41856
+ assetScale: 1.5,
41857
+ flipped: true,
41858
+ layer0: "",
41859
+ layer1: "https://pathtoimage.png",
41860
+ interactivePublicKey,
41861
+ isInteractive: true,
41862
+ position: { x: 0, y: 0 },
41863
+ uniqueName: "exampleUniqueName",
41864
+ urlSlug,
41865
+ });
41866
+ * ```
41867
+ */
41762
41868
  drop(asset, { assetScale = 1, flipped, interactivePublicKey, isInteractive, layer0 = "", layer1 = "", position: { x, y }, sceneDropId, text, textColor, textSize, textWeight, textWidth, uniqueName, urlSlug, yOrderAdjust, }) {
41763
41869
  return __awaiter(this, void 0, void 0, function* () {
41764
41870
  let specialType = null;
@@ -41803,14 +41909,38 @@ class DroppedAssetFactory extends SDKController {
41803
41909
  }
41804
41910
  }
41805
41911
 
41912
+ /**
41913
+ * @usage
41914
+ * ```ts
41915
+ * const Scene = new SceneFactory(myTopiaInstance);
41916
+ * ```
41917
+ */
41806
41918
  class SceneFactory {
41807
41919
  constructor(topia) {
41808
41920
  this.topia = topia;
41809
41921
  this.create;
41810
41922
  }
41923
+ /**
41924
+ * @summary
41925
+ * Instantiate a new instance of Scene class.
41926
+ *
41927
+ * @usage
41928
+ * ```
41929
+ * const sceneInstance = await Scene.create(id, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
41930
+ * ```
41931
+ */
41811
41932
  create(id, options) {
41812
41933
  return new Scene(this.topia, id, options);
41813
41934
  }
41935
+ /**
41936
+ * @summary
41937
+ * Instantiate a new instance of Scene class and retrieve all properties.
41938
+ *
41939
+ * @usage
41940
+ * ```
41941
+ * const sceneInstance = await Scene.get(id, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
41942
+ * ```
41943
+ */
41814
41944
  get(id, options) {
41815
41945
  return __awaiter(this, void 0, void 0, function* () {
41816
41946
  const scene = yield new Scene(this.topia, id, options);
@@ -41820,22 +41950,61 @@ class SceneFactory {
41820
41950
  }
41821
41951
  }
41822
41952
 
41953
+ /**
41954
+ * @usage
41955
+ * ```ts
41956
+ * const User = new UserFactory(myTopiaInstance);
41957
+ * ```
41958
+ */
41823
41959
  class UserFactory {
41824
41960
  constructor(topia) {
41825
41961
  this.topia = topia;
41826
41962
  }
41963
+ /**
41964
+ * @summary
41965
+ * Instantiate a new instance of User class.
41966
+ *
41967
+ * @usage
41968
+ * ```
41969
+ * const userInstance = await User.create({ credentials: { interactiveNonce, interactivePublicKey, visitorId } });
41970
+ * ```
41971
+ */
41827
41972
  create(options) {
41828
41973
  return new User(this.topia, options);
41829
41974
  }
41830
41975
  }
41831
41976
 
41977
+ /**
41978
+ * @usage
41979
+ * ```ts
41980
+ * const Visitor = new VisitorFactory(myTopiaInstance);
41981
+ * ```
41982
+ */
41832
41983
  class VisitorFactory {
41833
41984
  constructor(topia) {
41834
41985
  this.topia = topia;
41835
41986
  }
41987
+ /**
41988
+ * @summary
41989
+ * Instantiate a new instance of Visitor class.
41990
+ *
41991
+ * @usage
41992
+ * ```
41993
+ * const visitorInstance = await Visitor.create(id, urlSlug, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
41994
+ * ```
41995
+ */
41836
41996
  create(id, urlSlug, options) {
41837
41997
  return new Visitor(this.topia, id, urlSlug, options);
41838
41998
  }
41999
+ /**
42000
+ * @summary
42001
+ * Instantiate a new instance of Visitor class and retrieve all properties.
42002
+ *
42003
+ * @usage
42004
+ * ```
42005
+ * const visitorInstance = await Visitor.get(id, urlSlug, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
42006
+ * ```
42007
+ */
41839
42008
  get(id, urlSlug, options) {
41840
42009
  return __awaiter(this, void 0, void 0, function* () {
41841
42010
  const visitor = new Visitor(this.topia, id, urlSlug, options);
@@ -41845,22 +42014,61 @@ class VisitorFactory {
41845
42014
  }
41846
42015
  }
41847
42016
 
42017
+ /**
42018
+ * @usage
42019
+ * ```ts
42020
+ * const WorldActivity = new WorldActivityFactory(myTopiaInstance);
42021
+ * ```
42022
+ */
41848
42023
  class WorldActivityFactory {
41849
42024
  constructor(topia) {
41850
42025
  this.topia = topia;
41851
42026
  }
42027
+ /**
42028
+ * @summary
42029
+ * Instantiate a new instance of WorldActivity class.
42030
+ *
42031
+ * @usage
42032
+ * ```
42033
+ * const worldActivityInstance = await WorldActivity.create(urlSlug, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
42034
+ * ```
42035
+ */
41852
42036
  create(urlSlug, options) {
41853
42037
  return new WorldActivity(this.topia, urlSlug, options);
41854
42038
  }
41855
42039
  }
41856
42040
 
42041
+ /**
42042
+ * @usage
42043
+ * ```ts
42044
+ * const World = new WorldFactory(myTopiaInstance);
42045
+ * ```
42046
+ */
41857
42047
  class WorldFactory extends SDKController {
41858
42048
  constructor(topia) {
41859
42049
  super(topia);
41860
42050
  }
42051
+ /**
42052
+ * @summary
42053
+ * Instantiate a new instance of World class.
42054
+ *
42055
+ * @usage
42056
+ * ```
42057
+ * const worldInstance = await World.create(urlSlug, { credentials: { interactiveNonce, interactivePublicKey, visitorId } });
42058
+ * ```
42059
+ */
41861
42060
  create(urlSlug, options) {
41862
42061
  return new World(this.topia, urlSlug, options);
41863
42062
  }
42063
+ /**
42064
+ * @summary
42065
+ * Deletes an array of Dropped Assets from within a world and returns success: true
42066
+ *
42067
+ * @usage
42068
+ * ```
42069
+ * await World.deleteDroppedAssets(urlSlug, ["exampleDroppedAssetId1", "exampleDroppedAssetId2"], { interactiveNonce, interactivePublicKey, visitorId });
42070
+ * ```
42071
+ */
41864
42072
  deleteDroppedAssets(urlSlug, droppedAssetIds, credentials) {
41865
42073
  return __awaiter(this, void 0, void 0, function* () {
41866
42074
  const { apiKey, interactivePublicKey, interactiveSecret } = credentials;