@rtsdk/topia 0.4.0 → 0.5.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
@@ -50,12 +50,12 @@ await DroppedAsset.get(assetId, urlSlug, {
50
50
 
51
51
  ### Need an API Key to test locally? This is how you can create one:
52
52
 
53
- - While logged in to [topia.io](https://topia.io/), click on your image (or gray circle) in the top left of the screen to open My Account
54
- - In the side menu, select Integrations
53
+ - Navigate directly to your [integrations page](https://topia.io/t/dashboard/integrations) or follow the steps below from within a world.
54
+ - Click on your image (or circle) at the top left of the left hand navbar.
55
+ - Click Edit Profile. This will bring you to a separate dashboard.
56
+ - Click Integrations on the left nav
55
57
  - Click Generate New API Key and copy the API Key to be used in your .env and while using https://sdk-examples.metaversecloud.com
56
58
 
57
- <br>
58
-
59
59
  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
60
 
61
61
  ![Interactive Application Development Diagram](./InteractiveApplicationDevelopment.png)
package/dist/index.cjs CHANGED
@@ -39742,7 +39742,7 @@ var _DroppedAsset_updateDroppedAsset;
39742
39742
  class DroppedAsset extends Asset {
39743
39743
  constructor(topia, id, urlSlug, options = { attributes: { text: "" }, credentials: {} }) {
39744
39744
  var _a;
39745
- super(topia, id, options);
39745
+ super(topia, id, { attributes: options.attributes, credentials: Object.assign(Object.assign({}, options.credentials), { urlSlug }) });
39746
39746
  // private methods
39747
39747
  _DroppedAsset_updateDroppedAsset.set(this, (payload, updateType) => __awaiter(this, void 0, void 0, function* () {
39748
39748
  try {
@@ -40197,6 +40197,40 @@ class DroppedAsset extends Asset {
40197
40197
  }
40198
40198
  });
40199
40199
  }
40200
+ ////////// analytics
40201
+ /**
40202
+ * @summary
40203
+ * Retrieve analytics for a dropped asset by day, week, month, quarter, or year
40204
+ *
40205
+ * @usage
40206
+ * ```ts
40207
+ * const analytics = await droppedAsset.fetchDroppedAssetAnalytics({
40208
+ * periodType: "quarter",
40209
+ * dateValue: 3,
40210
+ * year: 2023,
40211
+ * });
40212
+ * ```
40213
+ */
40214
+ fetchDroppedAssetAnalytics({ periodType, dateValue, year, }) {
40215
+ return __awaiter(this, void 0, void 0, function* () {
40216
+ try {
40217
+ let query = "";
40218
+ switch (periodType) {
40219
+ case "week":
40220
+ query = `&week=W${dateValue}`;
40221
+ case "month":
40222
+ query = `&month=${dateValue}`;
40223
+ case "quarter":
40224
+ query = `&quarter=Q${dateValue}`;
40225
+ }
40226
+ const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/dropped-asset-analytics/${this.id}?year=${year}${query}`, this.requestOptions);
40227
+ return response.data;
40228
+ }
40229
+ catch (error) {
40230
+ throw this.errorHandler({ error });
40231
+ }
40232
+ });
40233
+ }
40200
40234
  }
40201
40235
  _DroppedAsset_updateDroppedAsset = new WeakMap();
40202
40236
 
@@ -40707,6 +40741,40 @@ class World extends SDKController {
40707
40741
  }
40708
40742
  });
40709
40743
  }
40744
+ ////////// analytics
40745
+ /**
40746
+ * @summary
40747
+ * Retrieve world analytics by day, week, month, quarter, or year
40748
+ *
40749
+ * @usage
40750
+ * ```ts
40751
+ * const analytics = await world.fetchWorldAnalytics({
40752
+ * periodType: "week",
40753
+ * dateValue: 40,
40754
+ * year: 2023,
40755
+ * });
40756
+ * ```
40757
+ */
40758
+ fetchWorldAnalytics({ periodType, dateValue, year, }) {
40759
+ return __awaiter(this, void 0, void 0, function* () {
40760
+ try {
40761
+ let query = "";
40762
+ switch (periodType) {
40763
+ case "week":
40764
+ query = `&week=W${dateValue}`;
40765
+ case "month":
40766
+ query = `&month=${dateValue}`;
40767
+ case "quarter":
40768
+ query = `&quarter=Q${dateValue}`;
40769
+ }
40770
+ const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/world-analytics?year=${year}${query}`, this.requestOptions);
40771
+ return response.data;
40772
+ }
40773
+ catch (error) {
40774
+ throw this.errorHandler({ error });
40775
+ }
40776
+ });
40777
+ }
40710
40778
  }
40711
40779
  _World_droppedAssetsMap = new WeakMap();
40712
40780
 
@@ -40996,7 +41064,7 @@ _User_adminWorldsMap = new WeakMap(), _User_assetsMap = new WeakMap(), _User_sce
40996
41064
  */
40997
41065
  class Visitor extends User {
40998
41066
  constructor(topia, id, urlSlug, options = { attributes: {}, credentials: {} }) {
40999
- super(topia, { credentials: options.credentials });
41067
+ super(topia, { credentials: Object.assign(Object.assign({}, options.credentials), { urlSlug }) });
41000
41068
  Object.assign(this, options.attributes);
41001
41069
  this.id = id;
41002
41070
  this.urlSlug = urlSlug;
@@ -41140,6 +41208,32 @@ class Visitor extends User {
41140
41208
  }
41141
41209
  });
41142
41210
  }
41211
+ /**
41212
+ * @summary
41213
+ * Grant expression to a visitor by id or name.
41214
+ *
41215
+ * @usage
41216
+ * ```ts
41217
+ * await visitor.grantExpression({ name: "Eyes" });
41218
+ * ```
41219
+ */
41220
+ grantExpression({ id, name }) {
41221
+ return __awaiter(this, void 0, void 0, function* () {
41222
+ if (!id && !name)
41223
+ throw "An expression id or name is required.";
41224
+ try {
41225
+ let expressionId = id;
41226
+ if (name) {
41227
+ expressionId = yield this.topiaPublicApi().get(`/expressions?name=${name}`, this.requestOptions);
41228
+ }
41229
+ const result = yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/grant-expression/${expressionId}`, {}, this.requestOptions);
41230
+ return result;
41231
+ }
41232
+ catch (error) {
41233
+ throw this.errorHandler({ error });
41234
+ }
41235
+ });
41236
+ }
41143
41237
  /**
41144
41238
  * @summary
41145
41239
  * Retrieves the data object for a visitor.
@@ -41435,6 +41529,19 @@ class DroppedAssetFactory extends SDKController {
41435
41529
  return droppedAsset;
41436
41530
  });
41437
41531
  }
41532
+ getWithUniqueName(uniqueName, urlSlug, interactivePublicKey, interactiveSecret) {
41533
+ return __awaiter(this, void 0, void 0, function* () {
41534
+ const interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
41535
+ try {
41536
+ const response = yield this.topiaPublicApi().get(`/world/${urlSlug}/asset-by-unique-name/${uniqueName}`, { headers: { interactiveJWT, publickey: interactivePublicKey } });
41537
+ const { id } = response.data;
41538
+ return new DroppedAsset(this.topia, id, urlSlug, { attributes: response.data });
41539
+ }
41540
+ catch (error) {
41541
+ throw this.errorHandler({ error });
41542
+ }
41543
+ });
41544
+ }
41438
41545
  drop(asset, { interactivePublicKey, position: { x, y }, sceneDropId, uniqueName, urlSlug, yOrderAdjust, }) {
41439
41546
  return __awaiter(this, void 0, void 0, function* () {
41440
41547
  try {
package/dist/index.d.ts CHANGED
@@ -358,6 +358,24 @@ declare class DroppedAsset extends Asset implements DroppedAssetInterface {
358
358
  isInteractive?: boolean;
359
359
  interactivePublicKey: string;
360
360
  }): Promise<void | ResponseType>;
361
+ /**
362
+ * @summary
363
+ * Retrieve analytics for a dropped asset by day, week, month, quarter, or year
364
+ *
365
+ * @usage
366
+ * ```ts
367
+ * const analytics = await droppedAsset.fetchDroppedAssetAnalytics({
368
+ * periodType: "quarter",
369
+ * dateValue: 3,
370
+ * year: 2023,
371
+ * });
372
+ * ```
373
+ */
374
+ fetchDroppedAssetAnalytics({ periodType, dateValue, year, }: {
375
+ periodType: "week" | "month" | "quarter" | "year";
376
+ dateValue: number;
377
+ year: number;
378
+ }): Promise<void | ResponseType>;
361
379
  }
362
380
 
363
381
  /**
@@ -650,6 +668,24 @@ declare class World extends SDKController implements WorldInterface {
650
668
  * ```
651
669
  */
652
670
  fetchWebhooks(): Promise<void | ResponseType>;
671
+ /**
672
+ * @summary
673
+ * Retrieve world analytics by day, week, month, quarter, or year
674
+ *
675
+ * @usage
676
+ * ```ts
677
+ * const analytics = await world.fetchWorldAnalytics({
678
+ * periodType: "week",
679
+ * dateValue: 40,
680
+ * year: 2023,
681
+ * });
682
+ * ```
683
+ */
684
+ fetchWorldAnalytics({ periodType, dateValue, year, }: {
685
+ periodType: "week" | "month" | "quarter" | "year";
686
+ dateValue: number;
687
+ year: number;
688
+ }): Promise<void | ResponseType>;
653
689
  }
654
690
 
655
691
  /**
@@ -883,6 +919,19 @@ declare class Visitor extends User implements VisitorInterface {
883
919
  * ```
884
920
  */
885
921
  turnAVOff(): Promise<void | ResponseType>;
922
+ /**
923
+ * @summary
924
+ * Grant expression to a visitor by id or name.
925
+ *
926
+ * @usage
927
+ * ```ts
928
+ * await visitor.grantExpression({ name: "Eyes" });
929
+ * ```
930
+ */
931
+ grantExpression({ id, name }: {
932
+ id?: string;
933
+ name?: string;
934
+ }): Promise<object | ResponseType>;
886
935
  /**
887
936
  * @summary
888
937
  * Retrieves the data object for a visitor.
@@ -1517,6 +1566,7 @@ declare class DroppedAssetFactory extends SDKController {
1517
1566
  constructor(topia: Topia);
1518
1567
  create(id: string, urlSlug: string, options?: DroppedAssetOptionalInterface): DroppedAsset;
1519
1568
  get(id: string, urlSlug: string, options?: DroppedAssetOptionalInterface): Promise<DroppedAsset>;
1569
+ getWithUniqueName(uniqueName: string, urlSlug: string, interactivePublicKey: string, interactiveSecret: string): Promise<DroppedAsset>;
1520
1570
  drop(asset: Asset, { interactivePublicKey, position: { x, y }, sceneDropId, uniqueName, urlSlug, yOrderAdjust, }: {
1521
1571
  interactivePublicKey?: string;
1522
1572
  position: {
package/dist/index.js CHANGED
@@ -39740,7 +39740,7 @@ var _DroppedAsset_updateDroppedAsset;
39740
39740
  class DroppedAsset extends Asset {
39741
39741
  constructor(topia, id, urlSlug, options = { attributes: { text: "" }, credentials: {} }) {
39742
39742
  var _a;
39743
- super(topia, id, options);
39743
+ super(topia, id, { attributes: options.attributes, credentials: Object.assign(Object.assign({}, options.credentials), { urlSlug }) });
39744
39744
  // private methods
39745
39745
  _DroppedAsset_updateDroppedAsset.set(this, (payload, updateType) => __awaiter(this, void 0, void 0, function* () {
39746
39746
  try {
@@ -40195,6 +40195,40 @@ class DroppedAsset extends Asset {
40195
40195
  }
40196
40196
  });
40197
40197
  }
40198
+ ////////// analytics
40199
+ /**
40200
+ * @summary
40201
+ * Retrieve analytics for a dropped asset by day, week, month, quarter, or year
40202
+ *
40203
+ * @usage
40204
+ * ```ts
40205
+ * const analytics = await droppedAsset.fetchDroppedAssetAnalytics({
40206
+ * periodType: "quarter",
40207
+ * dateValue: 3,
40208
+ * year: 2023,
40209
+ * });
40210
+ * ```
40211
+ */
40212
+ fetchDroppedAssetAnalytics({ periodType, dateValue, year, }) {
40213
+ return __awaiter(this, void 0, void 0, function* () {
40214
+ try {
40215
+ let query = "";
40216
+ switch (periodType) {
40217
+ case "week":
40218
+ query = `&week=W${dateValue}`;
40219
+ case "month":
40220
+ query = `&month=${dateValue}`;
40221
+ case "quarter":
40222
+ query = `&quarter=Q${dateValue}`;
40223
+ }
40224
+ const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/dropped-asset-analytics/${this.id}?year=${year}${query}`, this.requestOptions);
40225
+ return response.data;
40226
+ }
40227
+ catch (error) {
40228
+ throw this.errorHandler({ error });
40229
+ }
40230
+ });
40231
+ }
40198
40232
  }
40199
40233
  _DroppedAsset_updateDroppedAsset = new WeakMap();
40200
40234
 
@@ -40705,6 +40739,40 @@ class World extends SDKController {
40705
40739
  }
40706
40740
  });
40707
40741
  }
40742
+ ////////// analytics
40743
+ /**
40744
+ * @summary
40745
+ * Retrieve world analytics by day, week, month, quarter, or year
40746
+ *
40747
+ * @usage
40748
+ * ```ts
40749
+ * const analytics = await world.fetchWorldAnalytics({
40750
+ * periodType: "week",
40751
+ * dateValue: 40,
40752
+ * year: 2023,
40753
+ * });
40754
+ * ```
40755
+ */
40756
+ fetchWorldAnalytics({ periodType, dateValue, year, }) {
40757
+ return __awaiter(this, void 0, void 0, function* () {
40758
+ try {
40759
+ let query = "";
40760
+ switch (periodType) {
40761
+ case "week":
40762
+ query = `&week=W${dateValue}`;
40763
+ case "month":
40764
+ query = `&month=${dateValue}`;
40765
+ case "quarter":
40766
+ query = `&quarter=Q${dateValue}`;
40767
+ }
40768
+ const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/world-analytics?year=${year}${query}`, this.requestOptions);
40769
+ return response.data;
40770
+ }
40771
+ catch (error) {
40772
+ throw this.errorHandler({ error });
40773
+ }
40774
+ });
40775
+ }
40708
40776
  }
40709
40777
  _World_droppedAssetsMap = new WeakMap();
40710
40778
 
@@ -40994,7 +41062,7 @@ _User_adminWorldsMap = new WeakMap(), _User_assetsMap = new WeakMap(), _User_sce
40994
41062
  */
40995
41063
  class Visitor extends User {
40996
41064
  constructor(topia, id, urlSlug, options = { attributes: {}, credentials: {} }) {
40997
- super(topia, { credentials: options.credentials });
41065
+ super(topia, { credentials: Object.assign(Object.assign({}, options.credentials), { urlSlug }) });
40998
41066
  Object.assign(this, options.attributes);
40999
41067
  this.id = id;
41000
41068
  this.urlSlug = urlSlug;
@@ -41138,6 +41206,32 @@ class Visitor extends User {
41138
41206
  }
41139
41207
  });
41140
41208
  }
41209
+ /**
41210
+ * @summary
41211
+ * Grant expression to a visitor by id or name.
41212
+ *
41213
+ * @usage
41214
+ * ```ts
41215
+ * await visitor.grantExpression({ name: "Eyes" });
41216
+ * ```
41217
+ */
41218
+ grantExpression({ id, name }) {
41219
+ return __awaiter(this, void 0, void 0, function* () {
41220
+ if (!id && !name)
41221
+ throw "An expression id or name is required.";
41222
+ try {
41223
+ let expressionId = id;
41224
+ if (name) {
41225
+ expressionId = yield this.topiaPublicApi().get(`/expressions?name=${name}`, this.requestOptions);
41226
+ }
41227
+ const result = yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/grant-expression/${expressionId}`, {}, this.requestOptions);
41228
+ return result;
41229
+ }
41230
+ catch (error) {
41231
+ throw this.errorHandler({ error });
41232
+ }
41233
+ });
41234
+ }
41141
41235
  /**
41142
41236
  * @summary
41143
41237
  * Retrieves the data object for a visitor.
@@ -41433,6 +41527,19 @@ class DroppedAssetFactory extends SDKController {
41433
41527
  return droppedAsset;
41434
41528
  });
41435
41529
  }
41530
+ getWithUniqueName(uniqueName, urlSlug, interactivePublicKey, interactiveSecret) {
41531
+ return __awaiter(this, void 0, void 0, function* () {
41532
+ const interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
41533
+ try {
41534
+ const response = yield this.topiaPublicApi().get(`/world/${urlSlug}/asset-by-unique-name/${uniqueName}`, { headers: { interactiveJWT, publickey: interactivePublicKey } });
41535
+ const { id } = response.data;
41536
+ return new DroppedAsset(this.topia, id, urlSlug, { attributes: response.data });
41537
+ }
41538
+ catch (error) {
41539
+ throw this.errorHandler({ error });
41540
+ }
41541
+ });
41542
+ }
41436
41543
  drop(asset, { interactivePublicKey, position: { x, y }, sceneDropId, uniqueName, urlSlug, yOrderAdjust, }) {
41437
41544
  return __awaiter(this, void 0, void 0, function* () {
41438
41545
  try {
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.4.0"
62
+ "version": "0.5.0"
63
63
  }