@rtsdk/topia 0.11.0 → 0.11.2

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,10 +1,59 @@
1
+ <hr />
2
+
1
3
  # Javascript RTSDK - Topia Client Library
2
4
 
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)!
5
+ <hr/>
6
+
7
+ <br>
8
+
9
+ ### Create integrated, interactive experiences with Topia’s SDK and API
10
+
11
+ Topia offers a robust SDK and API that allows anyone to build custom apps or integrate any 3rd-party content, application, game or learning experience. Dedicated deployments launch with dozens of SDK Applications, including mini-games and social apps made by the Topia team and our developer community
12
+
13
+ ### Topia’s SDK/API can be used to:
14
+
15
+ - Turn existing applications and systems into multiplayer, cooperative experiences
16
+ - Integrate existing content into multiplayer learning journeys
17
+ - Create your own custom, dynamic social experiences and games
18
+ - Store and persist JSON data objects across sessions
19
+ - Add Social Connectivity Networking capabilities to your existing platforms
20
+
21
+ ### Key Features:
22
+
23
+ - Built-in safety and security via an interactive credentialing system
24
+ - Control over the code and IP of your creations
25
+ - Integrated via i-frame, in-world assets, and server-based bi-directional data flow
26
+ - Every object, world, and visitor has a JSON database you use to build interactivity and data persistence
27
+ - Powerful SDK classes and methods enable control of every aspect of Topia
28
+
29
+ ### Resources:
30
+
31
+ - [NPM Package](https://www.npmjs.com/package/@rtsdk/topia)
32
+ - [Demo World](https://topia.io/sdk-demos)
33
+ - [Typescript Boilerplate](https://github.com/metaversecloud-com/sdk-ts-boilerplate)
34
+ - [Javascript Boilerplate](https://github.com/metaversecloud-com/sdk-ts-boilerplate)
35
+
36
+ #### Need inspiration?! Check out the following applications which utilizes the SDK to create new and enhanced features inside [topia.io](https://topia.io/):
37
+
38
+ - **Bulletin Board:** A message board style application where users can submit messages and/or images for approval and an admin can approve the message so that it can be added to the world.
39
+ - [Github](https://github.com/metaversecloud-com/sdk-bulletin-board-app)
40
+ - [Demo](https://topia.io/bulletin-board-prod)
41
+ - **Jukebox:** A real-time interactive music player.
42
+ - [Github](https://github.com/metaversecloud-com/jukebox)
43
+ - [Demo](https://topia.io/jukebox-prod)
44
+ - **TicTacToe:** A turn based multiplayer game built completely on the canvas.
45
+ - [Github](https://github.com/metaversecloud-com/sdk-tictactoe)
46
+ - [Demo](https://topia.io/tictactoe-prod)
47
+ - **Quest:** A dynamic hide and seek game where an admin can drop multiple quest items within a world for users to find.
48
+ - [Github](https://github.com/metaversecloud-com/sdk-quest)
49
+ - [Demo](https://topia.io/quest-prod)
50
+
51
+ Questions, comments, or have something exciting to share with the Topia team? Reach out to [developers@topia.io](mailto:developers@topia.io)!
52
+ <br/>
4
53
 
5
54
  ## Authorization
6
55
 
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).
56
+ 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.
8
57
 
9
58
  ### Want to build interactive assets? This is how you can get started:
10
59
 
@@ -42,37 +91,24 @@ await DroppedAsset.get(assetId, urlSlug, {
42
91
  });
43
92
  ```
44
93
 
45
- <br />
94
+ ![Interactive Application Development Diagram](https://raw.githubusercontent.com/metaversecloud-com/mc-sdk-js/main/clients/client-topia/InteractiveApplicationDevelopment.png)
46
95
 
47
- ### Need an API Key to test locally? This is how you can create one:
96
+ ### Want to enable want world owners / admins to use the app outside of Topia, but still have ability to modify things in worlds where they have the permission to do so? This is how you can create an API Key:
97
+
98
+ 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 **when not currently in a Topia world**. In most case the ability to interact with an SDK application should be controlled per user using Interactive Credentials (see above).
48
99
 
49
100
  - Navigate directly to your [integrations page](https://topia.io/t/dashboard/integrations) or follow the steps below from within a world.
50
101
  - Click on your image (or circle) at the top left of the left hand navbar.
51
102
  - Click Edit Profile. This will bring you to a separate dashboard.
52
- - Click Integrations on the left nav
53
- - Click Generate New API Key and copy the API Key to be used in your .env and while using https://sdk-examples.metaversecloud.com
54
-
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.
56
-
57
- ![Interactive Application Development Diagram](https://raw.githubusercontent.com/metaversecloud-com/mc-sdk-js/main/clients/client-topia/InteractiveApplicationDevelopment.png)
103
+ - Click Integrations on the left nav.
104
+ - Click Generate New API Key and copy the API Key to be used in your .env file.
58
105
 
59
106
  <br>
60
107
 
61
- <hr/>
62
-
63
108
  # Developers
64
109
 
65
110
  <hr/>
66
111
 
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)
75
-
76
112
  <br>
77
113
 
78
114
  ## Get Started
@@ -133,6 +169,8 @@ export const getAssetAndDataObject = async (req) => {
133
169
  };
134
170
  ```
135
171
 
172
+ <br/><br/>
173
+
136
174
  ## Data Objects
137
175
 
138
176
  Data Objects can be used to store information such as game state, configurations, themes, and analytics.
@@ -167,9 +205,8 @@ There are three types of Data Objects:
167
205
  ```
168
206
  - **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
207
  - **Example - Update totalMessagesSentCount by a user across all worlds:**
170
- ```js
171
- await world.incrementDataObjectValue([`totalMessagesSentCount`], 1);
172
- ```
208
+ `` js await world.incrementDataObjectValue([`totalMessagesSentCount`], 1); ``
209
+ <br/>
173
210
 
174
211
  ### Data Object Locking
175
212
 
@@ -216,10 +253,6 @@ Note: This does NOT impact the data objects themselves but rather allows you to
216
253
 
217
254
  <br>
218
255
 
219
- <hr/>
220
-
221
- <br>
222
-
223
256
  # Contributors
224
257
 
225
258
  <hr/>
package/dist/index.cjs CHANGED
@@ -40861,9 +40861,9 @@ class World extends SDKController {
40861
40861
  * { sceneDropId: sceneId-timestamp, success: true }
40862
40862
  * ```
40863
40863
  */
40864
- dropScene({ assetSuffix, position, sceneId, }) {
40864
+ dropScene({ assetSuffix, position, sceneDropId, sceneId, }) {
40865
40865
  return __awaiter(this, void 0, void 0, function* () {
40866
- const params = { assetSuffix, position, sceneId };
40866
+ const params = { assetSuffix, position, sceneDropId, sceneId };
40867
40867
  try {
40868
40868
  const result = yield this.topiaPublicApi().post(`/world/${this.urlSlug}/drop-scene`, params, this.requestOptions);
40869
40869
  return result;
@@ -41137,99 +41137,179 @@ class User extends SDKController {
41137
41137
  *
41138
41138
  * @usage
41139
41139
  * ```ts
41140
- * const { avatarId, spriteSheetId } = await user.addAvatar({
41141
- * name: "ExampleAvatar",
41142
- * animationMeta: {
41143
- * dance: {
41144
- * loop: true,
41145
- * x: 0,
41146
- * y: -20,
41147
- * hideLoop: true,
41148
- * },
41149
- * },
41150
- * animations: {
41151
- * "dance": [
41152
- * "dance/1.png",
41153
- * "dance/2.png",
41154
- * "dance/3.png",
41155
- * "dance/4.png",
41156
- * "dance/5.png",
41157
- * ],
41140
+ * const animationMeta = {
41141
+ * "emote": { "loop": false, "x": 0, "y": 0, "hideLoop": true }
41142
+ * }
41143
+ *
41144
+ * const spriteSheetJSON = {
41145
+ * "animations": {
41146
+ * "emote": [
41147
+ * "emote/1.png"
41148
+ * ]
41158
41149
  * },
41159
- * frames: {
41160
- * "dance/1.png": {
41150
+ * "frames": {
41151
+ * "emote/1.png": {
41161
41152
  * "frame": {
41162
- * "x": 1,
41163
- * "y": 1040,
41164
- * "w": 58,
41165
- * "h": 107
41166
- * },
41167
- * "rotated": true,
41168
- * "trimmed": true,
41169
- * "spriteSourceSize": {
41170
- * "x": 50,
41171
- * "y": 58,
41172
- * "w": 58,
41173
- * "h": 107
41174
- * },
41175
- * "sourceSize": {
41176
- * "w": 159,
41177
- * "h": 200
41178
- * }
41179
- * },
41180
- * },
41181
- * "spriteSheetType": "PLAYER_AVATAR",
41182
- * "spriteSheetTypeMeta": {
41183
- * "meta": {
41184
- * "image": "spriteSheets%2FTvHNjgoMkiErDNSrVqHU%2FspriteSheet.png?alt=media",
41185
- * "format": "RGBA8888",
41186
- * "size": {
41187
- * "w": 2006,
41188
- * "h": 1099,
41189
- * },
41190
- * "scale": "1",
41191
- * },
41192
- * });
41153
+ * "x": 1911,
41154
+ * "y": 778,
41155
+ * "w": 58,
41156
+ * "h": 91
41157
+ * },
41158
+ * "rotated": true,
41159
+ * "trimmed": true,
41160
+ * "spriteSourceSize": {
41161
+ * "x": 50,
41162
+ * "y": 33,
41163
+ * "w": 58,
41164
+ * "h": 91
41165
+ * },
41166
+ * "sourceSize": {
41167
+ * "w": 159,
41168
+ * "h": 159
41169
+ * }
41170
+ * }
41171
+ * },
41172
+ * "spriteSheetTypeMeta": {
41173
+ * "nameplate": {
41174
+ * "x": 0,
41175
+ * "y": -70
41176
+ * }
41177
+ * },
41178
+ * "meta": {
41179
+ * "image": "spriteSheets%2FTvHNjgoMkiErDNSrVqHU%2FspriteSheet.png?alt=media",
41180
+ * "format": "RGBA8888",
41181
+ * "size": {
41182
+ * "w": 2006,
41183
+ * "h": 1099
41184
+ * },
41185
+ * "scale": "1"
41186
+ * }
41187
+ * }
41188
+ *
41189
+ * const formData = new FormData();
41190
+ * formData.append('animationMeta', animationMeta);
41191
+ * formData.append('name', "ExampleAvatarName");
41192
+ * formData.append('spriteSheetJSON', spriteSheetJSON);
41193
+ * formData.append('expression_dance', expression_dance);
41194
+ * formData.append('expression_emote', expression_emote);
41195
+ * formData.append('expression_sit', expression_sit);
41196
+ * formData.append('expression_stand', expression_stand);
41197
+ * formData.append('expression_transport', expression_transport);
41198
+ * formData.append('preview', preview);
41199
+ * formData.append('spriteSheet', spriteSheet);
41200
+ * formData.append('unityPackage', unityPackage);
41201
+ * await user.uploadAvatarFiles("exampleAvatarId", formData);
41193
41202
  * ```
41194
41203
  */
41195
- addAvatar({ animationMeta, animations, name, frames, meta, }) {
41204
+ addAvatar(formData) {
41196
41205
  return __awaiter(this, void 0, void 0, function* () {
41197
- const params = { animationMeta, animations, name, frames, meta };
41198
41206
  try {
41199
- const response = yield this.topiaPublicApi().post(`/avatars`, params, this.requestOptions);
41207
+ const response = yield this.topiaPublicApi().post(`/avatars`, formData, this.requestOptions);
41200
41208
  return response.data;
41201
41209
  }
41202
41210
  catch (error) {
41203
- throw this.errorHandler({ error, params, sdkMethod: "User.addAvatar" });
41211
+ throw this.errorHandler({ error, params: formData, sdkMethod: "User.addAvatar" });
41204
41212
  }
41205
41213
  });
41206
41214
  }
41207
41215
  /**
41208
41216
  * @summary
41209
- * Upload sprite sheet and avatar preview .png files to existing sprite sheet and avatar storage buckets
41217
+ * Update avatar and sprite sheet records and upload files to existing sprite sheet and avatar storage buckets
41210
41218
  *
41211
41219
  * @usage
41212
41220
  * ```ts
41221
+ * const animationMeta = {
41222
+ * "emote": { "loop": false, "x": 0, "y": 0, "hideLoop": true }
41223
+ * }
41224
+ *
41225
+ * const spriteSheetJSON = {
41226
+ * "animations": {
41227
+ * "emote": [
41228
+ * "emote/1.png"
41229
+ * ]
41230
+ * },
41231
+ * "frames": {
41232
+ * "emote/1.png": {
41233
+ * "frame": {
41234
+ * "x": 1911,
41235
+ * "y": 778,
41236
+ * "w": 58,
41237
+ * "h": 91
41238
+ * },
41239
+ * "rotated": true,
41240
+ * "trimmed": true,
41241
+ * "spriteSourceSize": {
41242
+ * "x": 50,
41243
+ * "y": 33,
41244
+ * "w": 58,
41245
+ * "h": 91
41246
+ * },
41247
+ * "sourceSize": {
41248
+ * "w": 159,
41249
+ * "h": 159
41250
+ * }
41251
+ * }
41252
+ * },
41253
+ * "spriteSheetTypeMeta": {
41254
+ * "nameplate": {
41255
+ * "x": 0,
41256
+ * "y": -70
41257
+ * }
41258
+ * },
41259
+ * "meta": {
41260
+ * "image": "spriteSheets%2FTvHNjgoMkiErDNSrVqHU%2FspriteSheet.png?alt=media",
41261
+ * "format": "RGBA8888",
41262
+ * "size": {
41263
+ * "w": 2006,
41264
+ * "h": 1099
41265
+ * },
41266
+ * "scale": "1"
41267
+ * }
41268
+ * }
41269
+ *
41213
41270
  * const formData = new FormData();
41214
- * formData.append('dancePreviewImage', dancePreviewImage);
41215
- * formData.append('emotePreviewImage', emotePreviewImage);
41216
- * formData.append('previewImageFile', previewImageFile);
41217
- * formData.append('sitPreviewImage', sitPreviewImage);
41218
- * formData.append('standPreviewImage', standPreviewImage);
41271
+ * formData.append('animationMeta', animationMeta);
41272
+ * formData.append('name', "ExampleAvatarName");
41273
+ * formData.append('spriteSheetJSON', spriteSheetJSON);
41274
+ * formData.append('expression_dance', expression_dance);
41275
+ * formData.append('expression_emote', expression_emote);
41276
+ * formData.append('expression_sit', expression_sit);
41277
+ * formData.append('expression_stand', expression_stand);
41278
+ * formData.append('expression_transport', expression_transport);
41279
+ * formData.append('preview', preview);
41219
41280
  * formData.append('spriteSheet', spriteSheet);
41220
- * formData.append('transportPreviewImage', transportPreviewImage);
41221
41281
  * formData.append('unityPackage', unityPackage);
41222
41282
  * await user.uploadAvatarFiles("exampleAvatarId", formData);
41223
41283
  * ```
41224
41284
  */
41225
- uploadAvatarFiles(avatarId, formData) {
41285
+ updateAvatar(avatarId, formData) {
41226
41286
  return __awaiter(this, void 0, void 0, function* () {
41227
41287
  try {
41228
- const response = yield this.topiaPublicApi().post(`/avatars/${avatarId}/upload-files`, formData, this.requestOptions);
41288
+ const response = yield this.topiaPublicApi().post(`/avatars/${avatarId}`, formData, this.requestOptions);
41229
41289
  return response.data;
41230
41290
  }
41231
41291
  catch (error) {
41232
- throw this.errorHandler({ error, sdkMethod: "User.uploadAvatarFiles" });
41292
+ throw this.errorHandler({ error, params: formData, sdkMethod: "User.updateAvatar" });
41293
+ }
41294
+ });
41295
+ }
41296
+ /**
41297
+ * @summary
41298
+ * Update avatar and sprite sheet records and upload files to existing sprite sheet and avatar storage buckets
41299
+ *
41300
+ * @usage
41301
+ * ```ts
41302
+ * await user.deleteAvatar("exampleAvatarId");
41303
+ * ```
41304
+ */
41305
+ deleteAvatar(avatarId) {
41306
+ return __awaiter(this, void 0, void 0, function* () {
41307
+ try {
41308
+ const response = yield this.topiaPublicApi().delete(`/avatars/${avatarId}`, this.requestOptions);
41309
+ return response.data;
41310
+ }
41311
+ catch (error) {
41312
+ throw this.errorHandler({ error, sdkMethod: "User.deleteAvatar" });
41233
41313
  }
41234
41314
  });
41235
41315
  }
@@ -41908,10 +41988,19 @@ class WorldActivity extends SDKController {
41908
41988
  return __classPrivateFieldGet(this, _WorldActivity_visitorsMap, "f");
41909
41989
  }
41910
41990
  //////// visitors
41911
- fetchVisitors(droppedAssetId) {
41991
+ fetchVisitors(droppedAssetId, shouldIncludeAdminPermissions) {
41912
41992
  return __awaiter(this, void 0, void 0, function* () {
41913
41993
  try {
41914
- const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors${droppedAssetId ? `?droppedAssetId=${droppedAssetId}` : ""}`, this.requestOptions);
41994
+ let queryParams = "";
41995
+ if (droppedAssetId) {
41996
+ queryParams = `?droppedAssetId=${droppedAssetId}`;
41997
+ if (shouldIncludeAdminPermissions)
41998
+ queryParams += `&shouldIncludeAdminPermissions=${shouldIncludeAdminPermissions}`;
41999
+ }
42000
+ else if (shouldIncludeAdminPermissions) {
42001
+ queryParams = `?shouldIncludeAdminPermissions=${shouldIncludeAdminPermissions}`;
42002
+ }
42003
+ const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors${queryParams}`, this.requestOptions);
41915
42004
  // create temp map and then update private property only once
41916
42005
  const tempVisitorsMap = {};
41917
42006
  for (const id in response.data) {
@@ -41959,6 +42048,8 @@ class WorldActivity extends SDKController {
41959
42048
  fetchVisitorsInZone(droppedAssetId) {
41960
42049
  return __awaiter(this, void 0, void 0, function* () {
41961
42050
  try {
42051
+ if (!droppedAssetId)
42052
+ throw "A landmark zone id (droppedAssetId) is required.";
41962
42053
  yield this.fetchVisitors(droppedAssetId);
41963
42054
  return this.visitors;
41964
42055
  }
package/dist/index.d.ts CHANGED
@@ -2,55 +2,6 @@ import * as axios from 'axios';
2
2
  import { AxiosResponse, AxiosInstance, AxiosError } from 'axios';
3
3
  import jwt from 'jsonwebtoken';
4
4
 
5
- type AnimationMetaType = {
6
- loop: boolean;
7
- x: number;
8
- y: number;
9
- hideLoop: boolean;
10
- };
11
- type FrameType = {
12
- frame: {
13
- x: number;
14
- y: number;
15
- w: number;
16
- h: number;
17
- };
18
- rotated: boolean;
19
- trimmed: boolean;
20
- spriteSourceSize: {
21
- x: number;
22
- y: number;
23
- w: number;
24
- h: number;
25
- };
26
- sourceSize: {
27
- w: number;
28
- h: number;
29
- };
30
- };
31
- type SpriteSheetJSONType = {
32
- name: string;
33
- animations: {
34
- [key: string]: string[];
35
- };
36
- animationMeta: {
37
- [key: string]: AnimationMetaType;
38
- };
39
- frames: {
40
- [key: string]: FrameType;
41
- };
42
- meta: {
43
- image: string;
44
- format: string;
45
- size: {
46
- w: number;
47
- h: number;
48
- };
49
- scale: string;
50
- };
51
- spriteSheetType: string;
52
- };
53
-
54
5
  declare enum DroppedAssetClickType {
55
6
  NONE = "none",
56
7
  LINK = "link",
@@ -703,9 +654,10 @@ declare class World extends SDKController implements WorldInterface {
703
654
  * { sceneDropId: sceneId-timestamp, success: true }
704
655
  * ```
705
656
  */
706
- dropScene({ assetSuffix, position, sceneId, }: {
707
- assetSuffix: string;
657
+ dropScene({ assetSuffix, position, sceneDropId, sceneId, }: {
658
+ assetSuffix?: string;
708
659
  position: object;
660
+ sceneDropId?: string;
709
661
  sceneId: string;
710
662
  }): Promise<object | ResponseType$1>;
711
663
  /**
@@ -912,81 +864,152 @@ declare class User extends SDKController implements UserInterface {
912
864
  *
913
865
  * @usage
914
866
  * ```ts
915
- * const { avatarId, spriteSheetId } = await user.addAvatar({
916
- * name: "ExampleAvatar",
917
- * animationMeta: {
918
- * dance: {
919
- * loop: true,
920
- * x: 0,
921
- * y: -20,
922
- * hideLoop: true,
923
- * },
924
- * },
925
- * animations: {
926
- * "dance": [
927
- * "dance/1.png",
928
- * "dance/2.png",
929
- * "dance/3.png",
930
- * "dance/4.png",
931
- * "dance/5.png",
932
- * ],
867
+ * const animationMeta = {
868
+ * "emote": { "loop": false, "x": 0, "y": 0, "hideLoop": true }
869
+ * }
870
+ *
871
+ * const spriteSheetJSON = {
872
+ * "animations": {
873
+ * "emote": [
874
+ * "emote/1.png"
875
+ * ]
933
876
  * },
934
- * frames: {
935
- * "dance/1.png": {
877
+ * "frames": {
878
+ * "emote/1.png": {
936
879
  * "frame": {
937
- * "x": 1,
938
- * "y": 1040,
939
- * "w": 58,
940
- * "h": 107
941
- * },
942
- * "rotated": true,
943
- * "trimmed": true,
944
- * "spriteSourceSize": {
945
- * "x": 50,
946
- * "y": 58,
947
- * "w": 58,
948
- * "h": 107
949
- * },
950
- * "sourceSize": {
951
- * "w": 159,
952
- * "h": 200
953
- * }
954
- * },
955
- * },
956
- * "spriteSheetType": "PLAYER_AVATAR",
957
- * "spriteSheetTypeMeta": {
958
- * "meta": {
959
- * "image": "spriteSheets%2FTvHNjgoMkiErDNSrVqHU%2FspriteSheet.png?alt=media",
960
- * "format": "RGBA8888",
961
- * "size": {
962
- * "w": 2006,
963
- * "h": 1099,
964
- * },
965
- * "scale": "1",
966
- * },
967
- * });
880
+ * "x": 1911,
881
+ * "y": 778,
882
+ * "w": 58,
883
+ * "h": 91
884
+ * },
885
+ * "rotated": true,
886
+ * "trimmed": true,
887
+ * "spriteSourceSize": {
888
+ * "x": 50,
889
+ * "y": 33,
890
+ * "w": 58,
891
+ * "h": 91
892
+ * },
893
+ * "sourceSize": {
894
+ * "w": 159,
895
+ * "h": 159
896
+ * }
897
+ * }
898
+ * },
899
+ * "spriteSheetTypeMeta": {
900
+ * "nameplate": {
901
+ * "x": 0,
902
+ * "y": -70
903
+ * }
904
+ * },
905
+ * "meta": {
906
+ * "image": "spriteSheets%2FTvHNjgoMkiErDNSrVqHU%2FspriteSheet.png?alt=media",
907
+ * "format": "RGBA8888",
908
+ * "size": {
909
+ * "w": 2006,
910
+ * "h": 1099
911
+ * },
912
+ * "scale": "1"
913
+ * }
914
+ * }
915
+ *
916
+ * const formData = new FormData();
917
+ * formData.append('animationMeta', animationMeta);
918
+ * formData.append('name', "ExampleAvatarName");
919
+ * formData.append('spriteSheetJSON', spriteSheetJSON);
920
+ * formData.append('expression_dance', expression_dance);
921
+ * formData.append('expression_emote', expression_emote);
922
+ * formData.append('expression_sit', expression_sit);
923
+ * formData.append('expression_stand', expression_stand);
924
+ * formData.append('expression_transport', expression_transport);
925
+ * formData.append('preview', preview);
926
+ * formData.append('spriteSheet', spriteSheet);
927
+ * formData.append('unityPackage', unityPackage);
928
+ * await user.uploadAvatarFiles("exampleAvatarId", formData);
968
929
  * ```
969
930
  */
970
- addAvatar({ animationMeta, animations, name, frames, meta, }: SpriteSheetJSONType): Promise<void | ResponseType$1>;
931
+ addAvatar(formData: FormData): Promise<void | ResponseType$1>;
971
932
  /**
972
933
  * @summary
973
- * Upload sprite sheet and avatar preview .png files to existing sprite sheet and avatar storage buckets
934
+ * Update avatar and sprite sheet records and upload files to existing sprite sheet and avatar storage buckets
974
935
  *
975
936
  * @usage
976
937
  * ```ts
938
+ * const animationMeta = {
939
+ * "emote": { "loop": false, "x": 0, "y": 0, "hideLoop": true }
940
+ * }
941
+ *
942
+ * const spriteSheetJSON = {
943
+ * "animations": {
944
+ * "emote": [
945
+ * "emote/1.png"
946
+ * ]
947
+ * },
948
+ * "frames": {
949
+ * "emote/1.png": {
950
+ * "frame": {
951
+ * "x": 1911,
952
+ * "y": 778,
953
+ * "w": 58,
954
+ * "h": 91
955
+ * },
956
+ * "rotated": true,
957
+ * "trimmed": true,
958
+ * "spriteSourceSize": {
959
+ * "x": 50,
960
+ * "y": 33,
961
+ * "w": 58,
962
+ * "h": 91
963
+ * },
964
+ * "sourceSize": {
965
+ * "w": 159,
966
+ * "h": 159
967
+ * }
968
+ * }
969
+ * },
970
+ * "spriteSheetTypeMeta": {
971
+ * "nameplate": {
972
+ * "x": 0,
973
+ * "y": -70
974
+ * }
975
+ * },
976
+ * "meta": {
977
+ * "image": "spriteSheets%2FTvHNjgoMkiErDNSrVqHU%2FspriteSheet.png?alt=media",
978
+ * "format": "RGBA8888",
979
+ * "size": {
980
+ * "w": 2006,
981
+ * "h": 1099
982
+ * },
983
+ * "scale": "1"
984
+ * }
985
+ * }
986
+ *
977
987
  * const formData = new FormData();
978
- * formData.append('dancePreviewImage', dancePreviewImage);
979
- * formData.append('emotePreviewImage', emotePreviewImage);
980
- * formData.append('previewImageFile', previewImageFile);
981
- * formData.append('sitPreviewImage', sitPreviewImage);
982
- * formData.append('standPreviewImage', standPreviewImage);
988
+ * formData.append('animationMeta', animationMeta);
989
+ * formData.append('name', "ExampleAvatarName");
990
+ * formData.append('spriteSheetJSON', spriteSheetJSON);
991
+ * formData.append('expression_dance', expression_dance);
992
+ * formData.append('expression_emote', expression_emote);
993
+ * formData.append('expression_sit', expression_sit);
994
+ * formData.append('expression_stand', expression_stand);
995
+ * formData.append('expression_transport', expression_transport);
996
+ * formData.append('preview', preview);
983
997
  * formData.append('spriteSheet', spriteSheet);
984
- * formData.append('transportPreviewImage', transportPreviewImage);
985
998
  * formData.append('unityPackage', unityPackage);
986
999
  * await user.uploadAvatarFiles("exampleAvatarId", formData);
987
1000
  * ```
988
1001
  */
989
- uploadAvatarFiles(avatarId: string, formData: FormData): Promise<void | ResponseType$1>;
1002
+ updateAvatar(avatarId: string, formData: FormData): Promise<void | ResponseType$1>;
1003
+ /**
1004
+ * @summary
1005
+ * Update avatar and sprite sheet records and upload files to existing sprite sheet and avatar storage buckets
1006
+ *
1007
+ * @usage
1008
+ * ```ts
1009
+ * await user.deleteAvatar("exampleAvatarId");
1010
+ * ```
1011
+ */
1012
+ deleteAvatar(avatarId: string): Promise<void | ResponseType$1>;
990
1013
  /**
991
1014
  * @summary
992
1015
  * Returns all assets owned by User when an email address is provided.
package/dist/index.js CHANGED
@@ -40859,9 +40859,9 @@ class World extends SDKController {
40859
40859
  * { sceneDropId: sceneId-timestamp, success: true }
40860
40860
  * ```
40861
40861
  */
40862
- dropScene({ assetSuffix, position, sceneId, }) {
40862
+ dropScene({ assetSuffix, position, sceneDropId, sceneId, }) {
40863
40863
  return __awaiter(this, void 0, void 0, function* () {
40864
- const params = { assetSuffix, position, sceneId };
40864
+ const params = { assetSuffix, position, sceneDropId, sceneId };
40865
40865
  try {
40866
40866
  const result = yield this.topiaPublicApi().post(`/world/${this.urlSlug}/drop-scene`, params, this.requestOptions);
40867
40867
  return result;
@@ -41135,99 +41135,179 @@ class User extends SDKController {
41135
41135
  *
41136
41136
  * @usage
41137
41137
  * ```ts
41138
- * const { avatarId, spriteSheetId } = await user.addAvatar({
41139
- * name: "ExampleAvatar",
41140
- * animationMeta: {
41141
- * dance: {
41142
- * loop: true,
41143
- * x: 0,
41144
- * y: -20,
41145
- * hideLoop: true,
41146
- * },
41147
- * },
41148
- * animations: {
41149
- * "dance": [
41150
- * "dance/1.png",
41151
- * "dance/2.png",
41152
- * "dance/3.png",
41153
- * "dance/4.png",
41154
- * "dance/5.png",
41155
- * ],
41138
+ * const animationMeta = {
41139
+ * "emote": { "loop": false, "x": 0, "y": 0, "hideLoop": true }
41140
+ * }
41141
+ *
41142
+ * const spriteSheetJSON = {
41143
+ * "animations": {
41144
+ * "emote": [
41145
+ * "emote/1.png"
41146
+ * ]
41156
41147
  * },
41157
- * frames: {
41158
- * "dance/1.png": {
41148
+ * "frames": {
41149
+ * "emote/1.png": {
41159
41150
  * "frame": {
41160
- * "x": 1,
41161
- * "y": 1040,
41162
- * "w": 58,
41163
- * "h": 107
41164
- * },
41165
- * "rotated": true,
41166
- * "trimmed": true,
41167
- * "spriteSourceSize": {
41168
- * "x": 50,
41169
- * "y": 58,
41170
- * "w": 58,
41171
- * "h": 107
41172
- * },
41173
- * "sourceSize": {
41174
- * "w": 159,
41175
- * "h": 200
41176
- * }
41177
- * },
41178
- * },
41179
- * "spriteSheetType": "PLAYER_AVATAR",
41180
- * "spriteSheetTypeMeta": {
41181
- * "meta": {
41182
- * "image": "spriteSheets%2FTvHNjgoMkiErDNSrVqHU%2FspriteSheet.png?alt=media",
41183
- * "format": "RGBA8888",
41184
- * "size": {
41185
- * "w": 2006,
41186
- * "h": 1099,
41187
- * },
41188
- * "scale": "1",
41189
- * },
41190
- * });
41151
+ * "x": 1911,
41152
+ * "y": 778,
41153
+ * "w": 58,
41154
+ * "h": 91
41155
+ * },
41156
+ * "rotated": true,
41157
+ * "trimmed": true,
41158
+ * "spriteSourceSize": {
41159
+ * "x": 50,
41160
+ * "y": 33,
41161
+ * "w": 58,
41162
+ * "h": 91
41163
+ * },
41164
+ * "sourceSize": {
41165
+ * "w": 159,
41166
+ * "h": 159
41167
+ * }
41168
+ * }
41169
+ * },
41170
+ * "spriteSheetTypeMeta": {
41171
+ * "nameplate": {
41172
+ * "x": 0,
41173
+ * "y": -70
41174
+ * }
41175
+ * },
41176
+ * "meta": {
41177
+ * "image": "spriteSheets%2FTvHNjgoMkiErDNSrVqHU%2FspriteSheet.png?alt=media",
41178
+ * "format": "RGBA8888",
41179
+ * "size": {
41180
+ * "w": 2006,
41181
+ * "h": 1099
41182
+ * },
41183
+ * "scale": "1"
41184
+ * }
41185
+ * }
41186
+ *
41187
+ * const formData = new FormData();
41188
+ * formData.append('animationMeta', animationMeta);
41189
+ * formData.append('name', "ExampleAvatarName");
41190
+ * formData.append('spriteSheetJSON', spriteSheetJSON);
41191
+ * formData.append('expression_dance', expression_dance);
41192
+ * formData.append('expression_emote', expression_emote);
41193
+ * formData.append('expression_sit', expression_sit);
41194
+ * formData.append('expression_stand', expression_stand);
41195
+ * formData.append('expression_transport', expression_transport);
41196
+ * formData.append('preview', preview);
41197
+ * formData.append('spriteSheet', spriteSheet);
41198
+ * formData.append('unityPackage', unityPackage);
41199
+ * await user.uploadAvatarFiles("exampleAvatarId", formData);
41191
41200
  * ```
41192
41201
  */
41193
- addAvatar({ animationMeta, animations, name, frames, meta, }) {
41202
+ addAvatar(formData) {
41194
41203
  return __awaiter(this, void 0, void 0, function* () {
41195
- const params = { animationMeta, animations, name, frames, meta };
41196
41204
  try {
41197
- const response = yield this.topiaPublicApi().post(`/avatars`, params, this.requestOptions);
41205
+ const response = yield this.topiaPublicApi().post(`/avatars`, formData, this.requestOptions);
41198
41206
  return response.data;
41199
41207
  }
41200
41208
  catch (error) {
41201
- throw this.errorHandler({ error, params, sdkMethod: "User.addAvatar" });
41209
+ throw this.errorHandler({ error, params: formData, sdkMethod: "User.addAvatar" });
41202
41210
  }
41203
41211
  });
41204
41212
  }
41205
41213
  /**
41206
41214
  * @summary
41207
- * Upload sprite sheet and avatar preview .png files to existing sprite sheet and avatar storage buckets
41215
+ * Update avatar and sprite sheet records and upload files to existing sprite sheet and avatar storage buckets
41208
41216
  *
41209
41217
  * @usage
41210
41218
  * ```ts
41219
+ * const animationMeta = {
41220
+ * "emote": { "loop": false, "x": 0, "y": 0, "hideLoop": true }
41221
+ * }
41222
+ *
41223
+ * const spriteSheetJSON = {
41224
+ * "animations": {
41225
+ * "emote": [
41226
+ * "emote/1.png"
41227
+ * ]
41228
+ * },
41229
+ * "frames": {
41230
+ * "emote/1.png": {
41231
+ * "frame": {
41232
+ * "x": 1911,
41233
+ * "y": 778,
41234
+ * "w": 58,
41235
+ * "h": 91
41236
+ * },
41237
+ * "rotated": true,
41238
+ * "trimmed": true,
41239
+ * "spriteSourceSize": {
41240
+ * "x": 50,
41241
+ * "y": 33,
41242
+ * "w": 58,
41243
+ * "h": 91
41244
+ * },
41245
+ * "sourceSize": {
41246
+ * "w": 159,
41247
+ * "h": 159
41248
+ * }
41249
+ * }
41250
+ * },
41251
+ * "spriteSheetTypeMeta": {
41252
+ * "nameplate": {
41253
+ * "x": 0,
41254
+ * "y": -70
41255
+ * }
41256
+ * },
41257
+ * "meta": {
41258
+ * "image": "spriteSheets%2FTvHNjgoMkiErDNSrVqHU%2FspriteSheet.png?alt=media",
41259
+ * "format": "RGBA8888",
41260
+ * "size": {
41261
+ * "w": 2006,
41262
+ * "h": 1099
41263
+ * },
41264
+ * "scale": "1"
41265
+ * }
41266
+ * }
41267
+ *
41211
41268
  * const formData = new FormData();
41212
- * formData.append('dancePreviewImage', dancePreviewImage);
41213
- * formData.append('emotePreviewImage', emotePreviewImage);
41214
- * formData.append('previewImageFile', previewImageFile);
41215
- * formData.append('sitPreviewImage', sitPreviewImage);
41216
- * formData.append('standPreviewImage', standPreviewImage);
41269
+ * formData.append('animationMeta', animationMeta);
41270
+ * formData.append('name', "ExampleAvatarName");
41271
+ * formData.append('spriteSheetJSON', spriteSheetJSON);
41272
+ * formData.append('expression_dance', expression_dance);
41273
+ * formData.append('expression_emote', expression_emote);
41274
+ * formData.append('expression_sit', expression_sit);
41275
+ * formData.append('expression_stand', expression_stand);
41276
+ * formData.append('expression_transport', expression_transport);
41277
+ * formData.append('preview', preview);
41217
41278
  * formData.append('spriteSheet', spriteSheet);
41218
- * formData.append('transportPreviewImage', transportPreviewImage);
41219
41279
  * formData.append('unityPackage', unityPackage);
41220
41280
  * await user.uploadAvatarFiles("exampleAvatarId", formData);
41221
41281
  * ```
41222
41282
  */
41223
- uploadAvatarFiles(avatarId, formData) {
41283
+ updateAvatar(avatarId, formData) {
41224
41284
  return __awaiter(this, void 0, void 0, function* () {
41225
41285
  try {
41226
- const response = yield this.topiaPublicApi().post(`/avatars/${avatarId}/upload-files`, formData, this.requestOptions);
41286
+ const response = yield this.topiaPublicApi().post(`/avatars/${avatarId}`, formData, this.requestOptions);
41227
41287
  return response.data;
41228
41288
  }
41229
41289
  catch (error) {
41230
- throw this.errorHandler({ error, sdkMethod: "User.uploadAvatarFiles" });
41290
+ throw this.errorHandler({ error, params: formData, sdkMethod: "User.updateAvatar" });
41291
+ }
41292
+ });
41293
+ }
41294
+ /**
41295
+ * @summary
41296
+ * Update avatar and sprite sheet records and upload files to existing sprite sheet and avatar storage buckets
41297
+ *
41298
+ * @usage
41299
+ * ```ts
41300
+ * await user.deleteAvatar("exampleAvatarId");
41301
+ * ```
41302
+ */
41303
+ deleteAvatar(avatarId) {
41304
+ return __awaiter(this, void 0, void 0, function* () {
41305
+ try {
41306
+ const response = yield this.topiaPublicApi().delete(`/avatars/${avatarId}`, this.requestOptions);
41307
+ return response.data;
41308
+ }
41309
+ catch (error) {
41310
+ throw this.errorHandler({ error, sdkMethod: "User.deleteAvatar" });
41231
41311
  }
41232
41312
  });
41233
41313
  }
@@ -41906,10 +41986,19 @@ class WorldActivity extends SDKController {
41906
41986
  return __classPrivateFieldGet(this, _WorldActivity_visitorsMap, "f");
41907
41987
  }
41908
41988
  //////// visitors
41909
- fetchVisitors(droppedAssetId) {
41989
+ fetchVisitors(droppedAssetId, shouldIncludeAdminPermissions) {
41910
41990
  return __awaiter(this, void 0, void 0, function* () {
41911
41991
  try {
41912
- const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors${droppedAssetId ? `?droppedAssetId=${droppedAssetId}` : ""}`, this.requestOptions);
41992
+ let queryParams = "";
41993
+ if (droppedAssetId) {
41994
+ queryParams = `?droppedAssetId=${droppedAssetId}`;
41995
+ if (shouldIncludeAdminPermissions)
41996
+ queryParams += `&shouldIncludeAdminPermissions=${shouldIncludeAdminPermissions}`;
41997
+ }
41998
+ else if (shouldIncludeAdminPermissions) {
41999
+ queryParams = `?shouldIncludeAdminPermissions=${shouldIncludeAdminPermissions}`;
42000
+ }
42001
+ const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors${queryParams}`, this.requestOptions);
41913
42002
  // create temp map and then update private property only once
41914
42003
  const tempVisitorsMap = {};
41915
42004
  for (const id in response.data) {
@@ -41957,6 +42046,8 @@ class WorldActivity extends SDKController {
41957
42046
  fetchVisitorsInZone(droppedAssetId) {
41958
42047
  return __awaiter(this, void 0, void 0, function* () {
41959
42048
  try {
42049
+ if (!droppedAssetId)
42050
+ throw "A landmark zone id (droppedAssetId) is required.";
41960
42051
  yield this.fetchVisitors(droppedAssetId);
41961
42052
  return this.visitors;
41962
42053
  }
package/package.json CHANGED
@@ -59,5 +59,5 @@
59
59
  "local-publish": "yarn build && yalc publish --push --no-scripts"
60
60
  },
61
61
  "type": "module",
62
- "version": "0.11.0"
62
+ "version": "0.11.2"
63
63
  }