@rtsdk/topia 0.0.14 → 0.0.16

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.
@@ -64,6 +64,8 @@ export const droppedAssets = [
64
64
  clickableLinkTitle: null,
65
65
  clickablePortal: null,
66
66
  creationDatetime: 1624557784470,
67
+ clickableDisplayTextDescription: null,
68
+ clickableDisplayTextHeadline: null,
67
69
  position: {
68
70
  x: -247.6349071195266,
69
71
  y: 1373.5047340020942,
@@ -112,6 +114,8 @@ export const droppedAssets = [
112
114
  clickableLinkTitle: null,
113
115
  clickablePortal: null,
114
116
  creationDatetime: 1624476120886,
117
+ clickableDisplayTextDescription: null,
118
+ clickableDisplayTextHeadline: null,
115
119
  position: {
116
120
  x: 1101.8736822470964,
117
121
  y: -815.1441116727156,
@@ -160,6 +164,8 @@ export const droppedAssets = [
160
164
  clickableLinkTitle: null,
161
165
  clickablePortal: null,
162
166
  creationDatetime: 1624559093102,
167
+ clickableDisplayTextDescription: null,
168
+ clickableDisplayTextHeadline: null,
163
169
  position: {
164
170
  x: -1024.6450136852004,
165
171
  y: 1534.5126935363705,
@@ -208,6 +214,8 @@ export const droppedAssets = [
208
214
  clickableLinkTitle: null,
209
215
  clickablePortal: null,
210
216
  creationDatetime: 1624557083983,
217
+ clickableDisplayTextDescription: null,
218
+ clickableDisplayTextHeadline: null,
211
219
  position: {
212
220
  x: 383.4917021726642,
213
221
  y: 937.6441853712226,
@@ -8,10 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  // controllers
11
+ import { DroppedAsset } from "controllers/DroppedAsset";
11
12
  import { SDKController } from "controllers/SDKController";
12
13
  // utils
13
14
  import { getErrorResponse } from "utils";
14
- import { DroppedAsset } from "controllers";
15
15
  /**
16
16
  * Create an instance of Asset class with a given asset id and optional attributes and session credentials.
17
17
  *
@@ -181,6 +181,8 @@ export class DroppedAsset extends Asset {
181
181
  * "clickType": "portal",
182
182
  * "clickableLink": "https://topia.io",
183
183
  * "clickableLinkTitle": "My awesome link!",
184
+ * "clickableDisplayTextDescription": "Description",
185
+ * "clickableDisplayTextHeadline": "Title",
184
186
  * "position": {
185
187
  * "x": 0,
186
188
  * "y": 0
@@ -189,9 +191,17 @@ export class DroppedAsset extends Asset {
189
191
  * });
190
192
  * ```
191
193
  */
192
- updateClickType({ clickType, clickableLink, clickableLinkTitle, portalName, position, }) {
194
+ updateClickType({ clickType, clickableLink, clickableLinkTitle, clickableDisplayTextDescription, clickableDisplayTextHeadline, portalName, position, }) {
193
195
  try {
194
- return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, { clickType, clickableLink, clickableLinkTitle, portalName, position }, "change-click-type");
196
+ return __classPrivateFieldGet(this, _DroppedAsset_updateDroppedAsset, "f").call(this, {
197
+ clickType,
198
+ clickableLink,
199
+ clickableLinkTitle,
200
+ clickableDisplayTextDescription,
201
+ clickableDisplayTextHeadline,
202
+ portalName,
203
+ position,
204
+ }, "change-click-type");
195
205
  }
196
206
  catch (error) {
197
207
  throw getErrorResponse({ error });
@@ -361,7 +371,6 @@ export class DroppedAsset extends Asset {
361
371
  * ```ts
362
372
  * await droppedAsset.addWebhook({
363
373
  * active: true,
364
- * assetId: "id",
365
374
  * dataObject: {},
366
375
  * description: "Webhook desc",
367
376
  * enteredBy: "you",
@@ -373,12 +382,12 @@ export class DroppedAsset extends Asset {
373
382
  * });
374
383
  * ```
375
384
  */
376
- addWebhook({ assetId, dataObject, description, isUniqueOnly, title, type, url, }) {
385
+ addWebhook({ dataObject, description, isUniqueOnly, title, type, url, }) {
377
386
  return __awaiter(this, void 0, void 0, function* () {
378
387
  try {
379
388
  yield this.topia.axios.post(`/world/${this.urlSlug}/webhooks`, {
380
389
  active: true,
381
- assetId,
390
+ assetId: this.id,
382
391
  dataObject,
383
392
  description,
384
393
  enteredBy: "",
@@ -394,6 +403,33 @@ export class DroppedAsset extends Asset {
394
403
  }
395
404
  });
396
405
  }
406
+ /**
407
+ * @summary
408
+ * Set the interactive settings on a dropped asset
409
+ *
410
+ * @usage
411
+ * ```ts
412
+ * await droppedAsset.setInteractiveSettings({
413
+ * isInteractive: true,
414
+ * interactivePublicKey: "xyz"
415
+ * });
416
+ * ```
417
+ */
418
+ setInteractiveSettings({ isInteractive = false, interactivePublicKey = "", }) {
419
+ return __awaiter(this, void 0, void 0, function* () {
420
+ try {
421
+ yield this.topia.axios.put(`/world/${this.urlSlug}/assets/${this.id}/set-asset-interactive-settings`, {
422
+ interactivePublicKey,
423
+ isInteractive,
424
+ }, this.requestOptions);
425
+ this.isInteractive = isInteractive;
426
+ this.interactivePublicKey = interactivePublicKey;
427
+ }
428
+ catch (error) {
429
+ throw getErrorResponse({ error });
430
+ }
431
+ });
432
+ }
397
433
  }
398
434
  _DroppedAsset_updateDroppedAsset = new WeakMap();
399
435
  export default DroppedAsset;
@@ -22,10 +22,12 @@ import jwt from "jsonwebtoken";
22
22
  */
23
23
  export class SDKController {
24
24
  constructor(topia, credentials = {}) {
25
- this.credentials = credentials;
25
+ const { assetId, interactiveNonce, visitorId, apiKey } = credentials;
26
26
  this.topia = topia;
27
- const { assetId, interactiveNonce, visitorId } = credentials;
27
+ this.credentials = credentials;
28
+ this.requestOptions = {};
28
29
  let payload = {};
30
+ const headers = {};
29
31
  if (visitorId && assetId && interactiveNonce) {
30
32
  payload = {
31
33
  interactiveNonce,
@@ -33,11 +35,12 @@ export class SDKController {
33
35
  assetId,
34
36
  };
35
37
  this.jwt = jwt.sign(payload, topia.interactiveSecret);
36
- this.requestOptions = { headers: { Interactivejwt: this.jwt } };
38
+ headers.Interactivejwt = this.jwt;
37
39
  }
38
- else {
39
- this.requestOptions = {};
40
+ if (apiKey) {
41
+ headers.Authorization = apiKey;
40
42
  }
43
+ this.requestOptions = { headers };
41
44
  }
42
45
  }
43
46
  export default SDKController;
@@ -21,7 +21,6 @@ export class Topia {
21
21
  this.interactiveSecret = interactiveSecret;
22
22
  const headers = {
23
23
  "Content-Type": "application/json",
24
- "Accept-Encoding": "",
25
24
  };
26
25
  if (apiKey)
27
26
  headers.Authorization = apiKey;
@@ -24,7 +24,34 @@ export class Visitor extends SDKController {
24
24
  Object.assign(this, options.attributes);
25
25
  this.id = id;
26
26
  this.urlSlug = urlSlug;
27
- this.moveVisitor;
27
+ }
28
+ /**
29
+ * @summary
30
+ * Get a single visitor from a world
31
+ *
32
+ * @usage
33
+ * ```ts
34
+ * await visitor.fetchVisitor();
35
+ * ```
36
+ *
37
+ * @result
38
+ * Updates each Visitor instance and world.visitors map.
39
+ */
40
+ fetchVisitor() {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ try {
43
+ const response = yield this.topia.axios.get(`/world/${this.urlSlug}/visitors/${this.id}`, this.requestOptions);
44
+ if (response.data.success) {
45
+ Object.assign(this, response.data).players[0];
46
+ }
47
+ else {
48
+ throw "This visitor is not active";
49
+ }
50
+ }
51
+ catch (error) {
52
+ throw getErrorResponse({ error });
53
+ }
54
+ });
28
55
  }
29
56
  /**
30
57
  * @summary
@@ -45,7 +45,7 @@ describe("DroppedAsset Class", () => {
45
45
  }));
46
46
  it("should update dropped asset click type", () => __awaiter(void 0, void 0, void 0, function* () {
47
47
  mock.onPut(`${BASE_URL}/change-click-type`).reply(200);
48
- const clickTypeArgs = Object.assign(Object.assign({}, attributes), { clickType: DroppedAssetClickType.LINK, clickableLink: "www.test.com", clickableLinkTitle: "Test", portalName: "Test", position: {
48
+ const clickTypeArgs = Object.assign(Object.assign({}, attributes), { clickType: DroppedAssetClickType.LINK, clickableLink: "www.test.com", clickableLinkTitle: "Test", clickableDisplayTextDescription: "Description", clickableDisplayTextHeadline: "Title", portalName: "Test", position: {
49
49
  x: 0,
50
50
  y: 0,
51
51
  } });
@@ -1,8 +1,24 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { Visitor } from "controllers";
2
11
  export class VisitorFactory {
3
12
  constructor(topia) {
4
13
  this.topia = topia;
5
14
  }
15
+ get(id, urlSlug, options) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const visitor = new Visitor(this.topia, id, urlSlug, options);
18
+ yield visitor.fetchVisitor();
19
+ return visitor;
20
+ });
21
+ }
6
22
  create(id, urlSlug, options) {
7
23
  return new Visitor(this.topia, id, urlSlug, options);
8
24
  }
package/package.json CHANGED
@@ -56,5 +56,5 @@
56
56
  "local-publish": "yarn build && yalc publish --push --no-scripts"
57
57
  },
58
58
  "type": "module",
59
- "version": "0.0.14"
59
+ "version": "0.0.16"
60
60
  }