@rtsdk/topia 0.7.2 → 0.8.1

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/dist/index.cjs CHANGED
@@ -40130,6 +40130,23 @@ class DroppedAsset extends Asset {
40130
40130
  throw this.errorHandler({ error, params: { assetScale }, sdkMethod: "DroppedAsset.updateScale" });
40131
40131
  }
40132
40132
  }
40133
+ /**
40134
+ * @summary
40135
+ * Flip an dropped asset.
40136
+ *
40137
+ * @usage
40138
+ * ```ts
40139
+ * await droppedAsset.flip(.5);
40140
+ * ```
40141
+ */
40142
+ flip() {
40143
+ try {
40144
+ return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, {}, "flip");
40145
+ }
40146
+ catch (error) {
40147
+ throw this.errorHandler({ error, params: {}, sdkMethod: "DroppedAsset.flip" });
40148
+ }
40149
+ }
40133
40150
  /**
40134
40151
  * @summary
40135
40152
  * Change or remove media embedded in a dropped asset.
@@ -41520,7 +41537,7 @@ class WorldActivity extends SDKController {
41520
41537
  *
41521
41538
  * @usage
41522
41539
  * ```ts
41523
- * const visitors = await world.currentVisitors();
41540
+ * const visitors = await worldActivity.currentVisitors();
41524
41541
  * ```
41525
41542
  */
41526
41543
  currentVisitors() {
@@ -41542,7 +41559,7 @@ class WorldActivity extends SDKController {
41542
41559
  *
41543
41560
  * @usage
41544
41561
  * ```ts
41545
- * await world.moveAllVisitors({
41562
+ * await worldActivity.moveAllVisitors({
41546
41563
  * shouldFetchVisitors: true,
41547
41564
  * shouldTeleportVisitors: true,
41548
41565
  * scatterVisitorsBy: 40,
@@ -41552,7 +41569,7 @@ class WorldActivity extends SDKController {
41552
41569
  * ```
41553
41570
  *
41554
41571
  * @result
41555
- * Updates each Visitor instance and world.visitors map.
41572
+ * Updates each Visitor instance and worldActivity.visitors map.
41556
41573
  */
41557
41574
  moveAllVisitors({ shouldFetchVisitors = true, shouldTeleportVisitors = true, scatterVisitorsBy = 0, x, y, }) {
41558
41575
  return __awaiter(this, void 0, void 0, function* () {
@@ -41579,22 +41596,22 @@ class WorldActivity extends SDKController {
41579
41596
  * ```ts
41580
41597
  * const visitorsToMove = [
41581
41598
  * {
41582
- * visitorObj: world.visitors["1"],
41599
+ * visitorObj: worldActivity.visitors["1"],
41583
41600
  * shouldTeleportVisitor: true,
41584
41601
  * x: 100,
41585
41602
  * y: 100
41586
41603
  * }, {
41587
- * visitorObj: world.visitors["2"],
41604
+ * visitorObj: worldActivity.visitors["2"],
41588
41605
  * shouldTeleportVisitor: false,
41589
41606
  * x: 100,
41590
41607
  * y: 100
41591
41608
  * }
41592
41609
  * ];
41593
- * await world.moveVisitors(visitorsToMove);
41610
+ * await worldActivity.moveVisitors(visitorsToMove);
41594
41611
  * ```
41595
41612
  *
41596
41613
  * @result
41597
- * Updates each Visitor instance and world.visitors map.
41614
+ * Updates each Visitor instance and worldActivity.visitors map.
41598
41615
  */
41599
41616
  moveVisitors(visitorsToMove) {
41600
41617
  return __awaiter(this, void 0, void 0, function* () {
@@ -41672,8 +41689,8 @@ class DroppedAssetFactory extends SDKController {
41672
41689
  getWithUniqueName(uniqueName, urlSlug, interactivePublicKey, interactiveSecret) {
41673
41690
  return __awaiter(this, void 0, void 0, function* () {
41674
41691
  const params = { uniqueName, urlSlug, interactivePublicKey, interactiveSecret };
41675
- const interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
41676
41692
  try {
41693
+ const interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
41677
41694
  const response = yield this.topiaPublicApi().get(`/world/${urlSlug}/asset-by-unique-name/${uniqueName}`, { headers: { interactiveJWT, publickey: interactivePublicKey } });
41678
41695
  const { id } = response.data;
41679
41696
  return new DroppedAsset(this.topia, id, urlSlug, { attributes: response.data });
@@ -41683,9 +41700,31 @@ class DroppedAssetFactory extends SDKController {
41683
41700
  }
41684
41701
  });
41685
41702
  }
41686
- drop(asset, { interactivePublicKey, isInteractive, position: { x, y }, sceneDropId, uniqueName, urlSlug, yOrderAdjust, }) {
41703
+ drop(asset, { assetScale = 1, flipped, interactivePublicKey, isInteractive, layer0, layer1, position: { x, y }, sceneDropId, text, textColor, textSize, textWeight, textWidth, uniqueName, urlSlug, yOrderAdjust, }) {
41687
41704
  return __awaiter(this, void 0, void 0, function* () {
41688
- const params = { interactivePublicKey, isInteractive, sceneDropId, uniqueName, urlSlug, yOrderAdjust };
41705
+ let specialType;
41706
+ if (layer0 || layer1)
41707
+ specialType = "webImage";
41708
+ else if (text)
41709
+ specialType = "text";
41710
+ const params = {
41711
+ assetScale,
41712
+ flipped,
41713
+ layer0,
41714
+ layer1,
41715
+ interactivePublicKey,
41716
+ isInteractive,
41717
+ sceneDropId,
41718
+ specialType,
41719
+ text,
41720
+ textColor,
41721
+ textSize,
41722
+ textWeight,
41723
+ textWidth,
41724
+ uniqueName,
41725
+ urlSlug,
41726
+ yOrderAdjust,
41727
+ };
41689
41728
  if (isInteractive && !interactivePublicKey) {
41690
41729
  throw this.errorHandler({
41691
41730
  message: "interactivePublicKey is required",
@@ -41694,15 +41733,7 @@ class DroppedAssetFactory extends SDKController {
41694
41733
  });
41695
41734
  }
41696
41735
  try {
41697
- const response = yield this.topiaPublicApi().post(`/world/${urlSlug}/assets`, {
41698
- assetId: asset.id,
41699
- interactivePublicKey,
41700
- isInteractive,
41701
- position: { x, y },
41702
- sceneDropId,
41703
- uniqueName,
41704
- yOrderAdjust,
41705
- }, asset.requestOptions);
41736
+ const response = yield this.topiaPublicApi().post(`/world/${urlSlug}/assets`, Object.assign(Object.assign({}, params), { assetId: asset.id, position: { x, y } }), asset.requestOptions);
41706
41737
  const { id } = response.data;
41707
41738
  return new DroppedAsset(this.topia, id, urlSlug, { credentials: asset.credentials });
41708
41739
  }
@@ -41764,13 +41795,33 @@ class WorldActivityFactory {
41764
41795
  }
41765
41796
  }
41766
41797
 
41767
- class WorldFactory {
41798
+ class WorldFactory extends SDKController {
41768
41799
  constructor(topia) {
41769
- this.topia = topia;
41800
+ super(topia);
41770
41801
  }
41771
41802
  create(urlSlug, options) {
41772
41803
  return new World(this.topia, urlSlug, options);
41773
41804
  }
41805
+ deleteDroppedAssets(urlSlug, droppedAssetIds, interactivePublicKey, interactiveSecret) {
41806
+ return __awaiter(this, void 0, void 0, function* () {
41807
+ const params = { droppedAssetIds, urlSlug, interactivePublicKey, interactiveSecret };
41808
+ try {
41809
+ const interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
41810
+ const promiseArray = [];
41811
+ for (const id of droppedAssetIds) {
41812
+ promiseArray.push(this.topiaPublicApi().delete(`/world/${urlSlug}/assets/${id}`, {
41813
+ headers: { interactiveJWT, publickey: interactivePublicKey },
41814
+ }));
41815
+ }
41816
+ const result = yield Promise.all(promiseArray);
41817
+ console.log(result);
41818
+ return { success: true };
41819
+ }
41820
+ catch (error) {
41821
+ throw this.errorHandler({ error, params, sdkMethod: "DroppedAssetFactory.getWithUniqueName" });
41822
+ }
41823
+ });
41824
+ }
41774
41825
  }
41775
41826
 
41776
41827
  Error.stackTraceLimit = 20;
package/dist/index.d.ts CHANGED
@@ -302,6 +302,16 @@ declare class DroppedAsset extends Asset implements DroppedAssetInterface {
302
302
  * ```
303
303
  */
304
304
  updateScale(assetScale: number): Promise<void | ResponseType>;
305
+ /**
306
+ * @summary
307
+ * Flip an dropped asset.
308
+ *
309
+ * @usage
310
+ * ```ts
311
+ * await droppedAsset.flip(.5);
312
+ * ```
313
+ */
314
+ flip(): Promise<void | ResponseType>;
305
315
  /**
306
316
  * @summary
307
317
  * Change or remove media embedded in a dropped asset.
@@ -1551,7 +1561,7 @@ declare class WorldActivity extends SDKController {
1551
1561
  *
1552
1562
  * @usage
1553
1563
  * ```ts
1554
- * const visitors = await world.currentVisitors();
1564
+ * const visitors = await worldActivity.currentVisitors();
1555
1565
  * ```
1556
1566
  */
1557
1567
  currentVisitors(): Promise<{
@@ -1565,7 +1575,7 @@ declare class WorldActivity extends SDKController {
1565
1575
  *
1566
1576
  * @usage
1567
1577
  * ```ts
1568
- * await world.moveAllVisitors({
1578
+ * await worldActivity.moveAllVisitors({
1569
1579
  * shouldFetchVisitors: true,
1570
1580
  * shouldTeleportVisitors: true,
1571
1581
  * scatterVisitorsBy: 40,
@@ -1575,7 +1585,7 @@ declare class WorldActivity extends SDKController {
1575
1585
  * ```
1576
1586
  *
1577
1587
  * @result
1578
- * Updates each Visitor instance and world.visitors map.
1588
+ * Updates each Visitor instance and worldActivity.visitors map.
1579
1589
  */
1580
1590
  moveAllVisitors({ shouldFetchVisitors, shouldTeleportVisitors, scatterVisitorsBy, x, y, }: MoveAllVisitorsInterface): Promise<(void | ResponseType)[] | undefined>;
1581
1591
  /**
@@ -1586,22 +1596,22 @@ declare class WorldActivity extends SDKController {
1586
1596
  * ```ts
1587
1597
  * const visitorsToMove = [
1588
1598
  * {
1589
- * visitorObj: world.visitors["1"],
1599
+ * visitorObj: worldActivity.visitors["1"],
1590
1600
  * shouldTeleportVisitor: true,
1591
1601
  * x: 100,
1592
1602
  * y: 100
1593
1603
  * }, {
1594
- * visitorObj: world.visitors["2"],
1604
+ * visitorObj: worldActivity.visitors["2"],
1595
1605
  * shouldTeleportVisitor: false,
1596
1606
  * x: 100,
1597
1607
  * y: 100
1598
1608
  * }
1599
1609
  * ];
1600
- * await world.moveVisitors(visitorsToMove);
1610
+ * await worldActivity.moveVisitors(visitorsToMove);
1601
1611
  * ```
1602
1612
  *
1603
1613
  * @result
1604
- * Updates each Visitor instance and world.visitors map.
1614
+ * Updates each Visitor instance and worldActivity.visitors map.
1605
1615
  */
1606
1616
  moveVisitors(visitorsToMove: VisitorsToMoveArrayType): Promise<(void | ResponseType)[]>;
1607
1617
  }
@@ -1617,14 +1627,23 @@ declare class DroppedAssetFactory extends SDKController {
1617
1627
  create(id: string, urlSlug: string, options?: DroppedAssetOptionalInterface): DroppedAsset;
1618
1628
  get(id: string, urlSlug: string, options?: DroppedAssetOptionalInterface): Promise<DroppedAsset>;
1619
1629
  getWithUniqueName(uniqueName: string, urlSlug: string, interactivePublicKey: string, interactiveSecret: string): Promise<DroppedAsset>;
1620
- drop(asset: Asset, { interactivePublicKey, isInteractive, position: { x, y }, sceneDropId, uniqueName, urlSlug, yOrderAdjust, }: {
1630
+ drop(asset: Asset, { assetScale, flipped, interactivePublicKey, isInteractive, layer0, layer1, position: { x, y }, sceneDropId, text, textColor, textSize, textWeight, textWidth, uniqueName, urlSlug, yOrderAdjust, }: {
1631
+ assetScale?: number;
1632
+ flipped?: boolean;
1621
1633
  interactivePublicKey?: string;
1622
1634
  isInteractive?: boolean;
1635
+ layer0?: string;
1636
+ layer1?: string;
1623
1637
  position: {
1624
1638
  x: number;
1625
1639
  y: number;
1626
1640
  };
1627
1641
  sceneDropId?: string;
1642
+ text?: string;
1643
+ textColor?: string;
1644
+ textSize?: number;
1645
+ textWeight?: string;
1646
+ textWidth?: number;
1628
1647
  uniqueName?: string;
1629
1648
  urlSlug: string;
1630
1649
  yOrderAdjust?: number;
@@ -1657,10 +1676,12 @@ declare class WorldActivityFactory {
1657
1676
  create(urlSlug: string, options?: WorldOptionalInterface): WorldActivity;
1658
1677
  }
1659
1678
 
1660
- declare class WorldFactory {
1661
- topia: Topia;
1679
+ declare class WorldFactory extends SDKController {
1662
1680
  constructor(topia: Topia);
1663
1681
  create(urlSlug: string, options?: WorldOptionalInterface): World;
1682
+ deleteDroppedAssets(urlSlug: string, droppedAssetIds: string[], interactivePublicKey: string, interactiveSecret: string): Promise<{
1683
+ success: boolean;
1684
+ }>;
1664
1685
  }
1665
1686
 
1666
1687
  export { Asset, AssetFactory, AssetInterface, AssetOptionalInterface, AssetOptions, DroppedAsset, DroppedAssetClickType, DroppedAssetFactory, DroppedAssetInterface, DroppedAssetMediaType, DroppedAssetOptionalInterface, DroppedAssetOptions, FireToastInterface, InteractiveCredentials, MoveAllVisitorsInterface, MoveVisitorInterface, OpenIframeInterface, ResponseType, SDKController, SDKInterface, Scene, SceneFactory, SceneInterface, SceneOptionalInterface, Topia, TopiaInterface, UpdateBroadcastInterface, UpdateClickTypeInterface, UpdateMediaTypeInterface, UpdatePrivateZoneInterface, User, UserFactory, UserInterface, UserOptionalInterface, UserOptions, Visitor, VisitorFactory, VisitorInterface, VisitorOptionalInterface, VisitorOptions, VisitorType, VisitorsToMoveArrayType, VisitorsToMoveType, WebhookInterface, World, WorldActivity, WorldActivityFactory, WorldActivityOptionalInterface, WorldDetailsInterface, WorldFactory, WorldInterface, WorldOptionalInterface, WorldOptions, WorldWebhooksInterface };
package/dist/index.js CHANGED
@@ -40128,6 +40128,23 @@ class DroppedAsset extends Asset {
40128
40128
  throw this.errorHandler({ error, params: { assetScale }, sdkMethod: "DroppedAsset.updateScale" });
40129
40129
  }
40130
40130
  }
40131
+ /**
40132
+ * @summary
40133
+ * Flip an dropped asset.
40134
+ *
40135
+ * @usage
40136
+ * ```ts
40137
+ * await droppedAsset.flip(.5);
40138
+ * ```
40139
+ */
40140
+ flip() {
40141
+ try {
40142
+ return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, {}, "flip");
40143
+ }
40144
+ catch (error) {
40145
+ throw this.errorHandler({ error, params: {}, sdkMethod: "DroppedAsset.flip" });
40146
+ }
40147
+ }
40131
40148
  /**
40132
40149
  * @summary
40133
40150
  * Change or remove media embedded in a dropped asset.
@@ -41518,7 +41535,7 @@ class WorldActivity extends SDKController {
41518
41535
  *
41519
41536
  * @usage
41520
41537
  * ```ts
41521
- * const visitors = await world.currentVisitors();
41538
+ * const visitors = await worldActivity.currentVisitors();
41522
41539
  * ```
41523
41540
  */
41524
41541
  currentVisitors() {
@@ -41540,7 +41557,7 @@ class WorldActivity extends SDKController {
41540
41557
  *
41541
41558
  * @usage
41542
41559
  * ```ts
41543
- * await world.moveAllVisitors({
41560
+ * await worldActivity.moveAllVisitors({
41544
41561
  * shouldFetchVisitors: true,
41545
41562
  * shouldTeleportVisitors: true,
41546
41563
  * scatterVisitorsBy: 40,
@@ -41550,7 +41567,7 @@ class WorldActivity extends SDKController {
41550
41567
  * ```
41551
41568
  *
41552
41569
  * @result
41553
- * Updates each Visitor instance and world.visitors map.
41570
+ * Updates each Visitor instance and worldActivity.visitors map.
41554
41571
  */
41555
41572
  moveAllVisitors({ shouldFetchVisitors = true, shouldTeleportVisitors = true, scatterVisitorsBy = 0, x, y, }) {
41556
41573
  return __awaiter(this, void 0, void 0, function* () {
@@ -41577,22 +41594,22 @@ class WorldActivity extends SDKController {
41577
41594
  * ```ts
41578
41595
  * const visitorsToMove = [
41579
41596
  * {
41580
- * visitorObj: world.visitors["1"],
41597
+ * visitorObj: worldActivity.visitors["1"],
41581
41598
  * shouldTeleportVisitor: true,
41582
41599
  * x: 100,
41583
41600
  * y: 100
41584
41601
  * }, {
41585
- * visitorObj: world.visitors["2"],
41602
+ * visitorObj: worldActivity.visitors["2"],
41586
41603
  * shouldTeleportVisitor: false,
41587
41604
  * x: 100,
41588
41605
  * y: 100
41589
41606
  * }
41590
41607
  * ];
41591
- * await world.moveVisitors(visitorsToMove);
41608
+ * await worldActivity.moveVisitors(visitorsToMove);
41592
41609
  * ```
41593
41610
  *
41594
41611
  * @result
41595
- * Updates each Visitor instance and world.visitors map.
41612
+ * Updates each Visitor instance and worldActivity.visitors map.
41596
41613
  */
41597
41614
  moveVisitors(visitorsToMove) {
41598
41615
  return __awaiter(this, void 0, void 0, function* () {
@@ -41670,8 +41687,8 @@ class DroppedAssetFactory extends SDKController {
41670
41687
  getWithUniqueName(uniqueName, urlSlug, interactivePublicKey, interactiveSecret) {
41671
41688
  return __awaiter(this, void 0, void 0, function* () {
41672
41689
  const params = { uniqueName, urlSlug, interactivePublicKey, interactiveSecret };
41673
- const interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
41674
41690
  try {
41691
+ const interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
41675
41692
  const response = yield this.topiaPublicApi().get(`/world/${urlSlug}/asset-by-unique-name/${uniqueName}`, { headers: { interactiveJWT, publickey: interactivePublicKey } });
41676
41693
  const { id } = response.data;
41677
41694
  return new DroppedAsset(this.topia, id, urlSlug, { attributes: response.data });
@@ -41681,9 +41698,31 @@ class DroppedAssetFactory extends SDKController {
41681
41698
  }
41682
41699
  });
41683
41700
  }
41684
- drop(asset, { interactivePublicKey, isInteractive, position: { x, y }, sceneDropId, uniqueName, urlSlug, yOrderAdjust, }) {
41701
+ drop(asset, { assetScale = 1, flipped, interactivePublicKey, isInteractive, layer0, layer1, position: { x, y }, sceneDropId, text, textColor, textSize, textWeight, textWidth, uniqueName, urlSlug, yOrderAdjust, }) {
41685
41702
  return __awaiter(this, void 0, void 0, function* () {
41686
- const params = { interactivePublicKey, isInteractive, sceneDropId, uniqueName, urlSlug, yOrderAdjust };
41703
+ let specialType;
41704
+ if (layer0 || layer1)
41705
+ specialType = "webImage";
41706
+ else if (text)
41707
+ specialType = "text";
41708
+ const params = {
41709
+ assetScale,
41710
+ flipped,
41711
+ layer0,
41712
+ layer1,
41713
+ interactivePublicKey,
41714
+ isInteractive,
41715
+ sceneDropId,
41716
+ specialType,
41717
+ text,
41718
+ textColor,
41719
+ textSize,
41720
+ textWeight,
41721
+ textWidth,
41722
+ uniqueName,
41723
+ urlSlug,
41724
+ yOrderAdjust,
41725
+ };
41687
41726
  if (isInteractive && !interactivePublicKey) {
41688
41727
  throw this.errorHandler({
41689
41728
  message: "interactivePublicKey is required",
@@ -41692,15 +41731,7 @@ class DroppedAssetFactory extends SDKController {
41692
41731
  });
41693
41732
  }
41694
41733
  try {
41695
- const response = yield this.topiaPublicApi().post(`/world/${urlSlug}/assets`, {
41696
- assetId: asset.id,
41697
- interactivePublicKey,
41698
- isInteractive,
41699
- position: { x, y },
41700
- sceneDropId,
41701
- uniqueName,
41702
- yOrderAdjust,
41703
- }, asset.requestOptions);
41734
+ const response = yield this.topiaPublicApi().post(`/world/${urlSlug}/assets`, Object.assign(Object.assign({}, params), { assetId: asset.id, position: { x, y } }), asset.requestOptions);
41704
41735
  const { id } = response.data;
41705
41736
  return new DroppedAsset(this.topia, id, urlSlug, { credentials: asset.credentials });
41706
41737
  }
@@ -41762,13 +41793,33 @@ class WorldActivityFactory {
41762
41793
  }
41763
41794
  }
41764
41795
 
41765
- class WorldFactory {
41796
+ class WorldFactory extends SDKController {
41766
41797
  constructor(topia) {
41767
- this.topia = topia;
41798
+ super(topia);
41768
41799
  }
41769
41800
  create(urlSlug, options) {
41770
41801
  return new World(this.topia, urlSlug, options);
41771
41802
  }
41803
+ deleteDroppedAssets(urlSlug, droppedAssetIds, interactivePublicKey, interactiveSecret) {
41804
+ return __awaiter(this, void 0, void 0, function* () {
41805
+ const params = { droppedAssetIds, urlSlug, interactivePublicKey, interactiveSecret };
41806
+ try {
41807
+ const interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
41808
+ const promiseArray = [];
41809
+ for (const id of droppedAssetIds) {
41810
+ promiseArray.push(this.topiaPublicApi().delete(`/world/${urlSlug}/assets/${id}`, {
41811
+ headers: { interactiveJWT, publickey: interactivePublicKey },
41812
+ }));
41813
+ }
41814
+ const result = yield Promise.all(promiseArray);
41815
+ console.log(result);
41816
+ return { success: true };
41817
+ }
41818
+ catch (error) {
41819
+ throw this.errorHandler({ error, params, sdkMethod: "DroppedAssetFactory.getWithUniqueName" });
41820
+ }
41821
+ });
41822
+ }
41772
41823
  }
41773
41824
 
41774
41825
  Error.stackTraceLimit = 20;
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.7.2"
62
+ "version": "0.8.1"
63
63
  }