@rtsdk/topia 0.19.4 → 0.19.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -240,44 +240,70 @@ export const getDroppedAssetAndVisitor = async (req: Request, res: Response) =>
240
240
  };
241
241
  ```
242
242
 
243
- <br/><br/>
244
-
245
243
  ## Data Objects
246
244
 
247
245
  Data Objects can be used to store information such as game state, configurations, themes, and analytics.
248
246
  There are three types of Data Objects:
249
247
 
250
- - **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.
251
- - **Example - Update two specific data points:**
252
- ```ts
253
- await world.updateDataObject({
254
- [`keyAssets.${keyAssetId}.itemsCollectedByUser.${profileId}`]: { [dateKey]: { count: 1 }, total: 1 },
255
- [`profileMapper.${profileId}`]: username,
256
- });
257
- ```
258
- - **Example - Increment a specific value within the data object by 1:**
259
- ```ts
260
- await world.incrementDataObjectValue([`keyAssets.${keyAssetId}.totalItemsCollected.count`], 1);
261
- ```
262
- - **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!
263
- - **Example - Initialize data object with default data and keyAssetId:**
264
- ```ts
265
- await droppedAsset.setDataObject(
266
- {
267
- ...defaultGameData,
268
- keyAssetId: droppedAsset.id,
269
- },
270
- { lock: { lockId, releaseLock: true } },
271
- );
272
- ```
273
- - **Example - Update lastInteraction date and playerCount:**
274
- ```ts
275
- await droppedAsset.updateDataObject({ lastInteraction: new Date(), playerCount: playerCount + 1 });
276
- ```
277
- - **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.
278
- - **Example - Update totalMessagesSentCount by a user across all worlds:**
279
- `` js await world.incrementDataObjectValue([`totalMessagesSentCount`], 1); ``
280
- <br/>
248
+ ### World:
249
+
250
+ The data object attached to the world will store information for every instance of the app in a given world by keyAssetId or sceneDropId and will persist even if a specific instance is removed from world. Data stored in the World data object should be minimal to avoid running into limits.
251
+
252
+ #### Example - Update two specific data points:
253
+
254
+ ```ts
255
+ await world.updateDataObject({
256
+ [sceneDropId]: { keyAssetId: droppedAsset.id, themeId: "custom", totalInteractions: 1 },
257
+ });
258
+ ```
259
+
260
+ #### Example - Increment a specific value within the data object by 1:
261
+
262
+ ```ts
263
+ await world.incrementDataObjectValue([`${sceneDropId}.totalInteractions`], 1);
264
+ ```
265
+
266
+ ### Dropped Asset:
267
+
268
+ 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!
269
+
270
+ #### Example - Initialize data object with default data and keyAssetId:
271
+
272
+ ```ts
273
+ await droppedAsset.setDataObject(
274
+ {
275
+ ...defaultGameData,
276
+ keyAssetId: droppedAsset.id,
277
+ },
278
+ { lock: { lockId, releaseLock: true } },
279
+ );
280
+ ```
281
+
282
+ #### Example - Update lastInteraction date and playerCount:
283
+
284
+ ```ts
285
+ await droppedAsset.updateDataObject({ lastInteraction: new Date(), playerCount: playerCount + 1 });
286
+ ```
287
+
288
+ ### User:
289
+
290
+ The data object attached to the visitor should store information related specifically to the visitor i.e. progress. For tracking across multiple world/instances use `${urlSlug}_${sceneDropId}` as a unique key.
291
+
292
+ #### Example - Initialize data object with default data and keyAssetId:
293
+
294
+ ```ts
295
+ await visitor.setDataObject(
296
+ {
297
+ [`${urlSlug}_${sceneDropId}`]: {
298
+ currentStreak: 0,
299
+ lastCollectedDate: null,
300
+ longestStreak: 0,
301
+ totalCollected: 0,
302
+ },
303
+ },
304
+ { lock: { lockId, releaseLock: true } },
305
+ );
306
+ ```
281
307
 
282
308
  ### Data Object Locking
283
309
 
@@ -324,7 +350,7 @@ await world.setDataObject({ hello: "world" }, { analytics: [{ analyticName: "res
324
350
 
325
351
  await world.updateDataObject({}, { analytics: [ {analyticName: "matches", uniqueKey: `${playerOneProfileId}-${playerTwoProfileId}`, urlSlug }], });
326
352
 
327
- await world.incrementDataObjectValue(`keyAssets.${assetId}.completions`, 1, { analytics: [{ analyticName:"completions", incrementBy: 2, profileId, uniqueKey: profileId, urlSlug }] });
353
+ await world.incrementDataObjectValue(`${sceneDropId}.completions`, 1, { analytics: [{ analyticName:"completions", incrementBy: 2, profileId, uniqueKey: profileId, urlSlug }] });
328
354
  ```
329
355
 
330
356
  Examples leveraging Visitor data objects calls:
@@ -345,7 +371,7 @@ await visitor.incrementDataObjectValue(`completions`, 1, {
345
371
  });
346
372
  ```
347
373
 
348
- Note: passing an empty object does NOT impact the data objects themselves but rather allows you to track custom analytics (incremented by 1) across all instances of your application with a given Public Key.
374
+ Note: passing an empty object does NOT impact the data objects themselves but rather allows you to track custom analytics across all instances of your application with a given Public Key.
349
375
 
350
376
  <br>
351
377
 
@@ -353,26 +379,18 @@ Note: passing an empty object does NOT impact the data objects themselves but ra
353
379
 
354
380
  <hr/>
355
381
 
356
- <br>
357
-
358
382
  ## Get Started
359
383
 
360
384
  Run `gh repo clone metaversecloud-com/mc-sdk-js`
361
385
 
362
- <br>
363
-
364
386
  ## Issues
365
387
 
366
388
  We've added an Issue template to help standardize Issues and ensure they have enough detail for a developer to start work and help prevent contributors from forgetting to add an important piece of information.
367
389
 
368
- <br>
369
-
370
390
  ## Pull Requests
371
391
 
372
392
  We've added a Pull Request template to help make it easier for developers to clarify what the proposed changes will do. This helps facilitate clear communication between all contributors of the SDK and ensures that we are all on the same page!
373
393
 
374
- <br>
375
-
376
394
  ## Documentation
377
395
 
378
396
  ### Styles
package/dist/index.cjs CHANGED
@@ -39727,11 +39727,6 @@ class SDKController {
39727
39727
  *
39728
39728
  * @keywords error, exception, handler, debugging, api error, http error
39729
39729
  *
39730
- * @param error - The error object from the failed operation (AxiosError, Error, or unknown)
39731
- * @param message - Optional custom error message (defaults to generic message)
39732
- * @param params - Optional parameters that were passed to the failed method
39733
- * @param sdkMethod - Optional name of the SDK method that failed (e.g., "World.fetchDetails")
39734
- *
39735
39730
  * @returns {object} Standardized error object with properties: data, message, method, params, sdkMethod, stack, status, success, url
39736
39731
  */
39737
39732
  errorHandler({ error, message = "Something went wrong. Please try again or contact support.", params = {}, sdkMethod, }) {
package/dist/index.d.ts CHANGED
@@ -74,7 +74,7 @@ type DroppedAssetLinkType = {
74
74
  linkSamlQueryParams?: string;
75
75
  };
76
76
 
77
- type InteractiveCredentials = {
77
+ type InteractiveCredentials$1 = {
78
78
  apiKey?: string;
79
79
  assetId?: string;
80
80
  interactiveNonce?: string;
@@ -88,22 +88,22 @@ type InteractiveCredentials = {
88
88
 
89
89
  type AssetOptions = {
90
90
  attributes?: AssetInterface | undefined;
91
- credentials?: InteractiveCredentials | undefined;
91
+ credentials?: InteractiveCredentials$1 | undefined;
92
92
  };
93
93
  type DroppedAssetOptions = {
94
94
  attributes?: DroppedAssetInterface | undefined;
95
- credentials?: InteractiveCredentials | undefined;
95
+ credentials?: InteractiveCredentials$1 | undefined;
96
96
  };
97
97
  type UserOptions = {
98
- credentials?: InteractiveCredentials | undefined;
98
+ credentials?: InteractiveCredentials$1 | undefined;
99
99
  };
100
100
  type VisitorOptions = {
101
101
  attributes?: VisitorInterface | undefined;
102
- credentials?: InteractiveCredentials | undefined;
102
+ credentials?: InteractiveCredentials$1 | undefined;
103
103
  };
104
104
  type WorldOptions = {
105
105
  attributes?: WorldDetailsInterface | undefined;
106
- credentials?: InteractiveCredentials | undefined;
106
+ credentials?: InteractiveCredentials$1 | undefined;
107
107
  };
108
108
 
109
109
  type ResponseType = {
@@ -2294,7 +2294,7 @@ declare enum WorldActivityType {
2294
2294
  }
2295
2295
 
2296
2296
  interface SDKInterface {
2297
- credentials?: InteractiveCredentials;
2297
+ credentials?: InteractiveCredentials$1;
2298
2298
  jwt?: string;
2299
2299
  requestOptions: object;
2300
2300
  topia: Topia;
@@ -2331,7 +2331,7 @@ interface AssetInterface extends SDKInterface {
2331
2331
  }
2332
2332
  type AssetOptionalInterface = {
2333
2333
  attributes?: AssetInterface | object;
2334
- credentials?: InteractiveCredentials;
2334
+ credentials?: InteractiveCredentials$1;
2335
2335
  };
2336
2336
 
2337
2337
  interface DroppedAssetInterface extends AssetInterface {
@@ -2453,7 +2453,7 @@ interface DroppedAssetOptionalInterface {
2453
2453
  text?: string;
2454
2454
  urlSlug?: string;
2455
2455
  };
2456
- credentials?: InteractiveCredentials | object;
2456
+ credentials?: InteractiveCredentials$1 | object;
2457
2457
  }
2458
2458
  interface UpdateBroadcastInterface {
2459
2459
  assetBroadcast?: boolean;
@@ -2545,7 +2545,7 @@ interface EcosystemInterface extends SDKInterface {
2545
2545
  incrementDataObjectValue(path: string, amount: number, options: object): Promise<void | ResponseType>;
2546
2546
  }
2547
2547
  interface EcosystemOptionalInterface {
2548
- credentials?: InteractiveCredentials;
2548
+ credentials?: InteractiveCredentials$1;
2549
2549
  }
2550
2550
 
2551
2551
  interface SceneInterface {
@@ -2573,7 +2573,7 @@ interface SceneInterface {
2573
2573
  }
2574
2574
  type SceneOptionalInterface = {
2575
2575
  attributes?: SceneInterface | object;
2576
- credentials?: InteractiveCredentials;
2576
+ credentials?: InteractiveCredentials$1;
2577
2577
  };
2578
2578
 
2579
2579
  interface FireToastInterface {
@@ -2621,7 +2621,7 @@ interface UserInterface {
2621
2621
  dataObject?: object | null;
2622
2622
  }
2623
2623
  interface UserOptionalInterface {
2624
- credentials?: InteractiveCredentials;
2624
+ credentials?: InteractiveCredentials$1;
2625
2625
  profileId?: string | null;
2626
2626
  visitorId?: number | null;
2627
2627
  urlSlug?: string;
@@ -2697,7 +2697,7 @@ interface VisitorInterface extends SDKInterface {
2697
2697
  }
2698
2698
  interface VisitorOptionalInterface {
2699
2699
  attributes?: VisitorInterface | object;
2700
- credentials?: InteractiveCredentials;
2700
+ credentials?: InteractiveCredentials$1;
2701
2701
  }
2702
2702
  interface MoveVisitorInterface {
2703
2703
  shouldTeleportVisitor: boolean;
@@ -2730,12 +2730,12 @@ interface WebRTCConnectorInterface {
2730
2730
  getTwilioConfig(): Promise<void | ResponseType>;
2731
2731
  }
2732
2732
  interface WebRTCConnectorOptionalInterface {
2733
- credentials?: InteractiveCredentials;
2733
+ credentials?: InteractiveCredentials$1;
2734
2734
  twilioConfig?: object;
2735
2735
  }
2736
2736
 
2737
2737
  interface WorldActivityOptionalInterface {
2738
- credentials?: InteractiveCredentials;
2738
+ credentials?: InteractiveCredentials$1;
2739
2739
  }
2740
2740
  interface MoveAllVisitorsInterface {
2741
2741
  shouldFetchVisitors?: boolean;
@@ -2825,13 +2825,13 @@ interface WorldInterface extends SDKInterface, WorldDetailsInterface {
2825
2825
  }
2826
2826
  interface WorldOptionalInterface {
2827
2827
  attributes?: WorldDetailsInterface | object;
2828
- credentials?: InteractiveCredentials;
2828
+ credentials?: InteractiveCredentials$1;
2829
2829
  }
2830
2830
  interface WorldWebhooksInterface {
2831
2831
  webhooks: Array<WebhookInterface>;
2832
2832
  }
2833
2833
 
2834
- type InteractiveCredentials$1 = {
2834
+ type InteractiveCredentials = {
2835
2835
  apiKey?: string;
2836
2836
  assetId?: string;
2837
2837
  interactiveNonce?: string;
@@ -2862,7 +2862,7 @@ interface InventoryItemInterface extends SDKInterface {
2862
2862
  }
2863
2863
  type InventoryItemOptionalInterface = {
2864
2864
  attributes?: InventoryItemInterface | object;
2865
- credentials?: InteractiveCredentials$1;
2865
+ credentials?: InteractiveCredentials;
2866
2866
  };
2867
2867
 
2868
2868
  /**
@@ -2880,7 +2880,7 @@ interface UserInventoryItemInterface extends InventoryItemInterface {
2880
2880
  }
2881
2881
  type UserInventoryItemOptionalInterface = {
2882
2882
  attributes?: UserInventoryItemInterface | object;
2883
- credentials?: InteractiveCredentials$1;
2883
+ credentials?: InteractiveCredentials;
2884
2884
  };
2885
2885
  type UserInventoryItemMetadataType = {
2886
2886
  id: string;
@@ -2959,11 +2959,11 @@ declare class Topia implements TopiaInterface {
2959
2959
  * ```
2960
2960
  */
2961
2961
  declare abstract class SDKController implements SDKInterface {
2962
- credentials: InteractiveCredentials | undefined;
2962
+ credentials: InteractiveCredentials$1 | undefined;
2963
2963
  jwt?: string;
2964
2964
  requestOptions: object;
2965
2965
  topia: Topia;
2966
- constructor(topia: Topia, credentials?: InteractiveCredentials);
2966
+ constructor(topia: Topia, credentials?: InteractiveCredentials$1);
2967
2967
  /**
2968
2968
  * Returns the configured Axios instance for making API calls to Topia's Public API.
2969
2969
  *
@@ -2991,11 +2991,6 @@ declare abstract class SDKController implements SDKInterface {
2991
2991
  *
2992
2992
  * @keywords error, exception, handler, debugging, api error, http error
2993
2993
  *
2994
- * @param error - The error object from the failed operation (AxiosError, Error, or unknown)
2995
- * @param message - Optional custom error message (defaults to generic message)
2996
- * @param params - Optional parameters that were passed to the failed method
2997
- * @param sdkMethod - Optional name of the SDK method that failed (e.g., "World.fetchDetails")
2998
- *
2999
2994
  * @returns {object} Standardized error object with properties: data, message, method, params, sdkMethod, stack, status, success, url
3000
2995
  */
3001
2996
  errorHandler({ error, message, params, sdkMethod, }: {
@@ -3608,7 +3603,7 @@ declare class DroppedAssetFactory extends SDKController {
3608
3603
  *
3609
3604
  * @returns {Promise<DroppedAsset>} Returns a new DroppedAsset object with all properties already fetched.
3610
3605
  */
3611
- getWithUniqueName(uniqueName: string, urlSlug: string, interactiveSecret: string, credentials: InteractiveCredentials): Promise<DroppedAsset>;
3606
+ getWithUniqueName(uniqueName: string, urlSlug: string, interactiveSecret: string, credentials: InteractiveCredentials$1): Promise<DroppedAsset>;
3612
3607
  /**
3613
3608
  * Drops an asset in a world and returns a new instance of DroppedAsset class with all properties.
3614
3609
  *
@@ -4190,4 +4185,4 @@ declare class WorldFactory extends SDKController {
4190
4185
  }>;
4191
4186
  }
4192
4187
 
4193
- export { AnalyticType, AnimationMetaType, Asset, AssetFactory, AssetInterface, AssetOptionalInterface, AssetOptions, AssetType, DroppedAsset, DroppedAssetClickType, DroppedAssetFactory, DroppedAssetInterface, DroppedAssetLinkType, DroppedAssetMediaType, DroppedAssetMediaVolumeRadius, DroppedAssetOptionalInterface, DroppedAssetOptions, Ecosystem, EcosystemFactory, EcosystemInterface, EcosystemOptionalInterface, FireToastInterface, FrameType, InteractiveCredentials, InventoryItemInterface, InventoryItemOptionalInterface, MoveAllVisitorsInterface, MoveVisitorInterface, OpenIframeInterface, RemoveClickableLinkInterface, ResponseType, SDKController, SDKInterface, Scene, SceneFactory, SceneInterface, SceneOptionalInterface, SetClickableLinkMultiInterface, Topia, TopiaInterface, UpdateBroadcastInterface, UpdateClickTypeInterface, UpdateClickableLinkMultiInterface, UpdateDroppedAssetInterface, UpdateMediaTypeInterface, UpdatePrivateZoneInterface, User, UserFactory, UserInterface, UserInventoryItemInterface, UserInventoryItemMetadataType, UserInventoryItemOptionalInterface, UserOptionalInterface, UserOptions, Visitor, VisitorFactory, VisitorInterface, VisitorOptionalInterface, VisitorOptions, VisitorType, VisitorsToMoveArrayType, VisitorsToMoveType, WebRTCConnector, WebRTCConnectorFactory, WebRTCConnectorInterface, WebRTCConnectorOptionalInterface, WebhookInterface, World, WorldActivity, WorldActivityFactory, WorldActivityOptionalInterface, WorldActivityType, WorldDetailsInterface, WorldFactory, WorldInterface, WorldOptionalInterface, WorldOptions, WorldWebhooksInterface };
4188
+ export { AnalyticType, AnimationMetaType, Asset, AssetFactory, AssetInterface, AssetOptionalInterface, AssetOptions, AssetType, DroppedAsset, DroppedAssetClickType, DroppedAssetFactory, DroppedAssetInterface, DroppedAssetLinkType, DroppedAssetMediaType, DroppedAssetMediaVolumeRadius, DroppedAssetOptionalInterface, DroppedAssetOptions, Ecosystem, EcosystemFactory, EcosystemInterface, EcosystemOptionalInterface, FireToastInterface, FrameType, InteractiveCredentials$1 as InteractiveCredentials, InventoryItemInterface, InventoryItemOptionalInterface, MoveAllVisitorsInterface, MoveVisitorInterface, OpenIframeInterface, RemoveClickableLinkInterface, ResponseType, SDKController, SDKInterface, Scene, SceneFactory, SceneInterface, SceneOptionalInterface, SetClickableLinkMultiInterface, Topia, TopiaInterface, UpdateBroadcastInterface, UpdateClickTypeInterface, UpdateClickableLinkMultiInterface, UpdateDroppedAssetInterface, UpdateMediaTypeInterface, UpdatePrivateZoneInterface, User, UserFactory, UserInterface, UserInventoryItemInterface, UserInventoryItemMetadataType, UserInventoryItemOptionalInterface, UserOptionalInterface, UserOptions, Visitor, VisitorFactory, VisitorInterface, VisitorOptionalInterface, VisitorOptions, VisitorType, VisitorsToMoveArrayType, VisitorsToMoveType, WebRTCConnector, WebRTCConnectorFactory, WebRTCConnectorInterface, WebRTCConnectorOptionalInterface, WebhookInterface, World, WorldActivity, WorldActivityFactory, WorldActivityOptionalInterface, WorldActivityType, WorldDetailsInterface, WorldFactory, WorldInterface, WorldOptionalInterface, WorldOptions, WorldWebhooksInterface };
package/dist/index.js CHANGED
@@ -39725,11 +39725,6 @@ class SDKController {
39725
39725
  *
39726
39726
  * @keywords error, exception, handler, debugging, api error, http error
39727
39727
  *
39728
- * @param error - The error object from the failed operation (AxiosError, Error, or unknown)
39729
- * @param message - Optional custom error message (defaults to generic message)
39730
- * @param params - Optional parameters that were passed to the failed method
39731
- * @param sdkMethod - Optional name of the SDK method that failed (e.g., "World.fetchDetails")
39732
- *
39733
39728
  * @returns {object} Standardized error object with properties: data, message, method, params, sdkMethod, stack, status, success, url
39734
39729
  */
39735
39730
  errorHandler({ error, message = "Something went wrong. Please try again or contact support.", params = {}, sdkMethod, }) {
package/package.json CHANGED
@@ -61,5 +61,5 @@
61
61
  "yalc-push": "yarn build && yalc publish --push --dev --no-scripts"
62
62
  },
63
63
  "type": "module",
64
- "version": "0.19.04"
64
+ "version": "0.19.05"
65
65
  }