@rtsdk/topia 0.0.23 → 0.0.25

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.
Files changed (31) hide show
  1. package/LICENSE.md +1 -2
  2. package/README.md +56 -56
  3. package/dist/example.js +3 -3
  4. package/dist/index.js +358 -231
  5. package/dist/src/__mocks__/scenes.js +1 -1
  6. package/dist/src/controllers/DroppedAsset.js +13 -5
  7. package/dist/src/controllers/SDKController.js +1 -1
  8. package/dist/src/controllers/Scene.js +39 -0
  9. package/dist/src/controllers/Topia.js +2 -2
  10. package/dist/src/controllers/User.js +38 -15
  11. package/dist/src/controllers/Visitor.js +7 -7
  12. package/dist/src/controllers/World.js +52 -145
  13. package/dist/src/controllers/WorldActivity.js +160 -0
  14. package/dist/src/controllers/__tests__/asset.test.js +2 -2
  15. package/dist/src/controllers/__tests__/droppedAsset.test.js +1 -1
  16. package/dist/src/controllers/__tests__/scene.test.js +37 -0
  17. package/dist/src/controllers/__tests__/user.test.js +14 -15
  18. package/dist/src/controllers/__tests__/visitor.test.js +10 -4
  19. package/dist/src/controllers/__tests__/world.test.js +2 -34
  20. package/dist/src/controllers/__tests__/worldActivity.test.js +62 -0
  21. package/dist/src/controllers/index.js +2 -0
  22. package/dist/src/factories/SceneFactory.js +27 -0
  23. package/dist/src/factories/UserFactory.js +2 -2
  24. package/dist/src/factories/VisitorFactory.js +3 -3
  25. package/dist/src/factories/WorldActivityFactory.js +10 -0
  26. package/dist/src/factories/index.js +2 -0
  27. package/dist/src/index.js +1 -1
  28. package/dist/src/interfaces/SceneInterfaces.js +1 -0
  29. package/dist/src/interfaces/WorldActivityInterfaces.js +1 -0
  30. package/dist/src/interfaces/index.js +2 -0
  31. package/package.json +1 -1
@@ -0,0 +1,160 @@
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
+ };
10
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
11
+ if (kind === "m") throw new TypeError("Private method is not writable");
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
14
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
15
+ };
16
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
17
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
18
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
19
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
20
+ };
21
+ var _WorldActivity_visitorsMap;
22
+ import { SDKController } from "controllers/SDKController";
23
+ import { Visitor } from "controllers/Visitor";
24
+ // utils
25
+ import { scatterVisitors } from "utils";
26
+ /**
27
+ * @summary
28
+ * Create an instance of WorldActivity class with a given url slug and optional attributes and session credentials.
29
+ *
30
+ * This class is responsible for all activity of a specified world including editing dropped assets, moving current visitors, etc.
31
+ *
32
+ * @usage
33
+ * ```ts
34
+ * await new WorldActivity(topia, "exampleWorld", { attributes: { name: "Example World" } });
35
+ * ```
36
+ */
37
+ export class WorldActivity extends SDKController {
38
+ constructor(topia, urlSlug, options = { credentials: {} }) {
39
+ super(topia, options.credentials);
40
+ _WorldActivity_visitorsMap.set(this, void 0);
41
+ __classPrivateFieldSet(this, _WorldActivity_visitorsMap, {}, "f");
42
+ this.urlSlug = urlSlug;
43
+ }
44
+ get visitors() {
45
+ return __classPrivateFieldGet(this, _WorldActivity_visitorsMap, "f");
46
+ }
47
+ //////// visitors
48
+ fetchVisitors() {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ try {
51
+ const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors`, this.requestOptions);
52
+ // create temp map and then update private property only once
53
+ const tempVisitorsMap = {};
54
+ for (const id in response.data) {
55
+ tempVisitorsMap[id] = new Visitor(this.topia, response.data[id].playerId, this.urlSlug, {
56
+ attributes: response.data[id],
57
+ });
58
+ }
59
+ __classPrivateFieldSet(this, _WorldActivity_visitorsMap, tempVisitorsMap, "f");
60
+ }
61
+ catch (error) {
62
+ throw this.errorHandler({ error });
63
+ }
64
+ });
65
+ }
66
+ /**
67
+ * @summary
68
+ * Retrieve all visitors currently in a world.
69
+ *
70
+ * @usage
71
+ * ```ts
72
+ * const visitors = await world.currentVisitors();
73
+ * ```
74
+ */
75
+ currentVisitors() {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ try {
78
+ yield this.fetchVisitors();
79
+ return this.visitors;
80
+ }
81
+ catch (error) {
82
+ return error;
83
+ }
84
+ });
85
+ }
86
+ /**
87
+ * @summary
88
+ * Move all visitors currently in a world to a single set of coordinates.
89
+ * Optionally refetch visitors, teleport or walk visitors to new location,
90
+ * and scatter visitors by any number so that they don't all move to the exact same location.
91
+ *
92
+ * @usage
93
+ * ```ts
94
+ * await world.moveAllVisitors({
95
+ * shouldFetchVisitors: true,
96
+ * shouldTeleportVisitors: true,
97
+ * scatterVisitorsBy: 40,
98
+ * x: 100,
99
+ * y: 100,
100
+ * });
101
+ * ```
102
+ *
103
+ * @result
104
+ * Updates each Visitor instance and world.visitors map.
105
+ */
106
+ moveAllVisitors({ shouldFetchVisitors = true, shouldTeleportVisitors = true, scatterVisitorsBy = 0, x, y, }) {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ if (shouldFetchVisitors)
109
+ yield this.fetchVisitors();
110
+ const allPromises = [];
111
+ if (!this.visitors)
112
+ return;
113
+ const objectKeys = Object.keys(this.visitors);
114
+ objectKeys.forEach((key) => allPromises.push(__classPrivateFieldGet(this, _WorldActivity_visitorsMap, "f")[key].moveVisitor({
115
+ shouldTeleportVisitor: shouldTeleportVisitors,
116
+ x: scatterVisitors(x, scatterVisitorsBy),
117
+ y: scatterVisitors(y, scatterVisitorsBy),
118
+ })));
119
+ const outcomes = yield Promise.all(allPromises);
120
+ return outcomes;
121
+ });
122
+ }
123
+ /**
124
+ * @summary
125
+ * Teleport or walk a list of visitors currently in a world to various coordinates.
126
+ *
127
+ * @usage
128
+ * ```ts
129
+ * const visitorsToMove = [
130
+ * {
131
+ * visitorObj: world.visitors["1"],
132
+ * shouldTeleportVisitor: true,
133
+ * x: 100,
134
+ * y: 100
135
+ * }, {
136
+ * visitorObj: world.visitors["2"],
137
+ * shouldTeleportVisitor: false,
138
+ * x: 100,
139
+ * y: 100
140
+ * }
141
+ * ];
142
+ * await world.moveVisitors(visitorsToMove);
143
+ * ```
144
+ *
145
+ * @result
146
+ * Updates each Visitor instance and world.visitors map.
147
+ */
148
+ moveVisitors(visitorsToMove) {
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ const allPromises = [];
151
+ visitorsToMove.forEach((v) => {
152
+ allPromises.push(v.visitorObj.moveVisitor({ shouldTeleportVisitor: v.shouldTeleportVisitor, x: v.x, y: v.y }));
153
+ });
154
+ const outcomes = yield Promise.all(allPromises);
155
+ return outcomes;
156
+ });
157
+ }
158
+ }
159
+ _WorldActivity_visitorsMap = new WeakMap();
160
+ export default WorldActivity;
@@ -15,7 +15,7 @@ describe("Asset Class", () => {
15
15
  let Asset, mock, testAsset, topia;
16
16
  beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
17
17
  topia = new Topia({
18
- apiDomain: "api.topia.io",
18
+ apiDomain,
19
19
  apiKey: "exampleKey",
20
20
  interactiveKey: "key",
21
21
  interactiveSecret: "secret",
@@ -29,7 +29,7 @@ describe("Asset Class", () => {
29
29
  jest.resetAllMocks();
30
30
  });
31
31
  it("should return an array of assets owned by specific email address", () => __awaiter(void 0, void 0, void 0, function* () {
32
- mock.onGet(`https://${apiDomain}/api/assets/topia-assets`).reply(200);
32
+ mock.onGet(`https://${apiDomain}/api/v1/assets/topia-assets`).reply(200);
33
33
  yield testAsset.fetchPlatformAssets();
34
34
  expect(mock.history.get.length).toBe(1);
35
35
  }));
@@ -14,7 +14,7 @@ import MockAdapter from "axios-mock-adapter";
14
14
  import { DroppedAssetFactory } from "factories";
15
15
  const apiDomain = "api.topia.io";
16
16
  const attributes = droppedAssets[0];
17
- const BASE_URL = `https://api.topia.io/api/world/exampleWorld/assets/${droppedAssets[0].id}`;
17
+ const BASE_URL = `https://api.topia.io/api/v1/world/exampleWorld/assets/${droppedAssets[0].id}`;
18
18
  const id = droppedAssets[0].id;
19
19
  describe("DroppedAsset Class", () => {
20
20
  let DroppedAsset, mock, testDroppedAsset, topia;
@@ -0,0 +1,37 @@
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
+ };
10
+ import MockAdapter from "axios-mock-adapter";
11
+ import { SceneFactory } from "factories";
12
+ import { Topia } from "controllers/Topia";
13
+ import { scenes } from "__mocks__";
14
+ const apiDomain = "api.topia.io";
15
+ describe("Scene Class", () => {
16
+ let Scene, mock, testScene, topia;
17
+ beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
18
+ topia = new Topia({
19
+ apiDomain,
20
+ apiKey: "exampleKey",
21
+ interactiveKey: "key",
22
+ interactiveSecret: "secret",
23
+ });
24
+ mock = new MockAdapter(topia.axios);
25
+ Scene = new SceneFactory(topia);
26
+ testScene = Scene.create(scenes[0].id);
27
+ }));
28
+ afterEach(() => {
29
+ mock.restore();
30
+ jest.resetAllMocks();
31
+ });
32
+ it("should return a scene by id", () => __awaiter(void 0, void 0, void 0, function* () {
33
+ mock.onGet(`https://${apiDomain}/api/v1/scenes/${scenes[0].id}`).reply(200);
34
+ yield testScene.fetchSceneById();
35
+ expect(mock.history.get.length).toBe(1);
36
+ }));
37
+ });
@@ -12,7 +12,6 @@ import { droppedAssets, scenes, worlds } from "__mocks__";
12
12
  import { Topia } from "controllers";
13
13
  import { UserFactory } from "factories";
14
14
  const apiDomain = "api.topia.io";
15
- const email = "test@email.com";
16
15
  describe("User Class", () => {
17
16
  let mock, testUser, topia, User;
18
17
  beforeEach(() => {
@@ -22,28 +21,28 @@ describe("User Class", () => {
22
21
  });
23
22
  mock = new MockAdapter(topia.axios);
24
23
  User = new UserFactory(topia);
25
- testUser = User.create(email);
24
+ testUser = User.create();
26
25
  });
27
26
  afterEach(() => {
28
27
  mock.restore();
29
28
  jest.resetAllMocks();
30
29
  });
30
+ it("should return an array of assets owned by specific email address", () => __awaiter(void 0, void 0, void 0, function* () {
31
+ testUser.fetchAssets = jest.fn().mockReturnValue(droppedAssets);
32
+ const mockAssets = yield testUser.fetchAssets();
33
+ expect(testUser.fetchAssets).toHaveBeenCalled();
34
+ expect(mockAssets).toBeDefined();
35
+ }));
36
+ it("should return an array of scenes owned by specific user", () => __awaiter(void 0, void 0, void 0, function* () {
37
+ testUser.fetchScenes = jest.fn().mockReturnValue(scenes);
38
+ const mockScenes = yield testUser.fetchScenes();
39
+ expect(testUser.fetchScenes).toHaveBeenCalled();
40
+ expect(mockScenes).toBeDefined();
41
+ }));
31
42
  it("should update user.worlds", () => __awaiter(void 0, void 0, void 0, function* () {
32
- mock.onGet(`https://${apiDomain}/api/user/worlds`).reply(200, worlds);
43
+ mock.onGet(`https://${apiDomain}/api/v1/user/worlds`).reply(200, worlds);
33
44
  yield testUser.fetchWorldsByKey();
34
45
  expect(mock.history.get.length).toBe(1);
35
46
  expect(Object.keys(testUser.worlds).length).toBe(Object.keys(worlds).length);
36
47
  }));
37
- it("should return an array of scenes owned by specific email address", () => __awaiter(void 0, void 0, void 0, function* () {
38
- testUser.fetchScenesByEmail = jest.fn().mockReturnValue(scenes);
39
- const mockScenes = yield testUser.fetchScenesByEmail();
40
- expect(testUser.fetchScenesByEmail).toHaveBeenCalled();
41
- expect(mockScenes).toBeDefined();
42
- }));
43
- it("should return an array of assets owned by specific email address", () => __awaiter(void 0, void 0, void 0, function* () {
44
- testUser.fetchAssetsByEmail = jest.fn().mockReturnValue(droppedAssets);
45
- const mockAssets = yield testUser.fetchAssetsByEmail("lina@topia.io");
46
- expect(testUser.fetchAssetsByEmail).toHaveBeenCalled();
47
- expect(mockAssets).toBeDefined();
48
- }));
49
48
  });
@@ -8,11 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import MockAdapter from "axios-mock-adapter";
11
- import { visitors } from "../../__mocks__";
11
+ import { visitor } from "__mocks__";
12
12
  import { Topia } from "controllers";
13
13
  import { VisitorFactory } from "factories";
14
14
  const apiDomain = "api.topia.io";
15
- const id = visitors["1"].playerId;
15
+ const id = visitor.playerId;
16
+ const urlSlug = "exampleWorld";
16
17
  describe("Visitor Class", () => {
17
18
  let mock, testVisitor, topia, Visitor;
18
19
  beforeEach(() => {
@@ -22,14 +23,19 @@ describe("Visitor Class", () => {
22
23
  });
23
24
  mock = new MockAdapter(topia.axios);
24
25
  Visitor = new VisitorFactory(topia);
25
- testVisitor = Visitor.create(id, "exampleWorld");
26
+ testVisitor = Visitor.create(id, urlSlug);
26
27
  });
27
28
  afterEach(() => {
28
29
  mock.restore();
29
30
  jest.resetAllMocks();
30
31
  });
32
+ it("should update visitor details", () => __awaiter(void 0, void 0, void 0, function* () {
33
+ mock.onGet(`https://${apiDomain}/api/v1/world/exampleWorld/visitors/1`).reply(200, visitor);
34
+ yield testVisitor.fetchVisitor();
35
+ expect(mock.history.get.length).toBe(1);
36
+ }));
31
37
  it("should move a list of visitors to uniquely specified coordinates", () => __awaiter(void 0, void 0, void 0, function* () {
32
- mock.onPut(`https://${apiDomain}/api/world/exampleWorld/visitors/${id}/move`).reply(200);
38
+ mock.onPut(`https://${apiDomain}/api/v1/world/${urlSlug}/visitors/${id}/move`).reply(200);
33
39
  yield testVisitor.moveVisitor({
34
40
  shouldTeleportVisitor: true,
35
41
  x: 100,
@@ -8,10 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import MockAdapter from "axios-mock-adapter";
11
- import { visitors, worlds } from "../../__mocks__";
12
- import { Visitor, Topia } from "controllers";
11
+ import { worlds } from "__mocks__";
12
+ import { Topia } from "controllers";
13
13
  import { WorldFactory } from "factories";
14
- const BASE_URL = "https://api.topia.io/api/world/exampleWorld";
15
14
  const urlSlug = worlds[1].urlSlug;
16
15
  describe("World Class", () => {
17
16
  let mock, testWorld, topia, World;
@@ -48,35 +47,4 @@ describe("World Class", () => {
48
47
  // expect(mock.history.put.length).toBe(1);
49
48
  // expect(testWorld.urlSlug).toEqual("exampleWorld");
50
49
  // });
51
- it("should move all visitors within a world to a single set of coordinates", () => __awaiter(void 0, void 0, void 0, function* () {
52
- mock.onGet(`${BASE_URL}/visitors`).reply(200, visitors);
53
- mock.onPut(`${BASE_URL}/visitors/1/move`).reply(200);
54
- mock.onPut(`${BASE_URL}/visitors/2/move`).reply(200);
55
- const attributes = {
56
- shouldFetchVisitors: true,
57
- shouldTeleportVisitors: true,
58
- scatterVisitorsBy: 100,
59
- x: 20,
60
- y: 40,
61
- };
62
- yield testWorld.moveAllVisitors(attributes);
63
- expect(mock.history.put.length).toBe(Object.keys(visitors).length);
64
- }));
65
- it("should return success if world doesn't have visitors", () => __awaiter(void 0, void 0, void 0, function* () {
66
- const attributes = { shouldFetchVisitors: false, scatterVisitorsBy: 100, x: 20, y: 40 };
67
- yield testWorld.moveAllVisitors(attributes);
68
- expect(mock.history.put.length).toBe(0);
69
- }));
70
- it("should move a list of visitors to uniquely specified coordinates", () => __awaiter(void 0, void 0, void 0, function* () {
71
- mock.onPut(`${BASE_URL}/visitors/1/move`).reply(200);
72
- mock.onPut(`${BASE_URL}/visitors/2/move`).reply(200);
73
- const v1 = new Visitor(topia, visitors["1"].playerId, urlSlug, { attributes: visitors["1"] });
74
- const v2 = new Visitor(topia, visitors["2"].playerId, urlSlug, { attributes: visitors["2"] });
75
- const testVisitors = [
76
- { visitorObj: v1, shouldTeleportVisitor: true, x: 0, y: 0 },
77
- { visitorObj: v2, shouldTeleportVisitor: false, x: 100, y: 100 },
78
- ];
79
- yield testWorld.moveVisitors(testVisitors);
80
- expect(mock.history.put.length).toBe(2);
81
- }));
82
50
  });
@@ -0,0 +1,62 @@
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
+ };
10
+ import MockAdapter from "axios-mock-adapter";
11
+ import { visitors, worlds } from "__mocks__";
12
+ import { Visitor, Topia } from "controllers";
13
+ import { WorldActivityFactory } from "factories";
14
+ const BASE_URL = "https://api.topia.io/api/v1/world/exampleWorld";
15
+ const urlSlug = worlds[1].urlSlug;
16
+ describe("WorldActivity Class", () => {
17
+ let mock, testWorldActivity, topia, WorldActivity;
18
+ beforeEach(() => {
19
+ topia = new Topia({
20
+ apiDomain: "api.topia.io",
21
+ apiKey: "key",
22
+ });
23
+ mock = new MockAdapter(topia.axios);
24
+ WorldActivity = new WorldActivityFactory(topia);
25
+ testWorldActivity = WorldActivity.create(urlSlug);
26
+ });
27
+ afterEach(() => {
28
+ mock.restore();
29
+ jest.resetAllMocks();
30
+ });
31
+ it("should move all visitors within a world to a single set of coordinates", () => __awaiter(void 0, void 0, void 0, function* () {
32
+ mock.onGet(`${BASE_URL}/visitors`).reply(200, visitors);
33
+ mock.onPut(`${BASE_URL}/visitors/1/move`).reply(200);
34
+ mock.onPut(`${BASE_URL}/visitors/2/move`).reply(200);
35
+ const attributes = {
36
+ shouldFetchVisitors: true,
37
+ shouldTeleportVisitors: true,
38
+ scatterVisitorsBy: 100,
39
+ x: 20,
40
+ y: 40,
41
+ };
42
+ yield testWorldActivity.moveAllVisitors(attributes);
43
+ expect(mock.history.put.length).toBe(Object.keys(visitors).length);
44
+ }));
45
+ it("should return success if world doesn't have visitors", () => __awaiter(void 0, void 0, void 0, function* () {
46
+ const attributes = { shouldFetchVisitors: false, scatterVisitorsBy: 100, x: 20, y: 40 };
47
+ yield testWorldActivity.moveAllVisitors(attributes);
48
+ expect(mock.history.put.length).toBe(0);
49
+ }));
50
+ it("should move a list of visitors to uniquely specified coordinates", () => __awaiter(void 0, void 0, void 0, function* () {
51
+ mock.onPut(`${BASE_URL}/visitors/1/move`).reply(200);
52
+ mock.onPut(`${BASE_URL}/visitors/2/move`).reply(200);
53
+ const v1 = new Visitor(topia, visitors["1"].playerId, urlSlug, { attributes: visitors["1"] });
54
+ const v2 = new Visitor(topia, visitors["2"].playerId, urlSlug, { attributes: visitors["2"] });
55
+ const testVisitors = [
56
+ { visitorObj: v1, shouldTeleportVisitor: true, x: 0, y: 0 },
57
+ { visitorObj: v2, shouldTeleportVisitor: false, x: 100, y: 100 },
58
+ ];
59
+ yield testWorldActivity.moveVisitors(testVisitors);
60
+ expect(mock.history.put.length).toBe(2);
61
+ }));
62
+ });
@@ -1,7 +1,9 @@
1
1
  export { Asset } from "./Asset";
2
2
  export { DroppedAsset } from "./DroppedAsset";
3
+ export { Scene } from "./Scene";
3
4
  export { SDKController } from "./SDKController";
4
5
  export { User } from "./User";
5
6
  export { Visitor } from "./Visitor";
6
7
  export { World } from "./World";
8
+ export { WorldActivity } from "./WorldActivity";
7
9
  export { Topia } from "./Topia";
@@ -0,0 +1,27 @@
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
+ };
10
+ import { Scene } from "controllers";
11
+ export class SceneFactory {
12
+ constructor(topia) {
13
+ this.topia = topia;
14
+ this.create;
15
+ }
16
+ create(id, options) {
17
+ return new Scene(this.topia, id, options);
18
+ }
19
+ get(id, options) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const scene = yield new Scene(this.topia, id, options);
22
+ yield scene.fetchSceneById();
23
+ return scene;
24
+ });
25
+ }
26
+ }
27
+ export default SceneFactory;
@@ -3,8 +3,8 @@ export class UserFactory {
3
3
  constructor(topia) {
4
4
  this.topia = topia;
5
5
  }
6
- create(email, options) {
7
- return new User(this.topia, email, options);
6
+ create(options) {
7
+ return new User(this.topia, options);
8
8
  }
9
9
  }
10
10
  export default UserFactory;
@@ -12,6 +12,9 @@ export class VisitorFactory {
12
12
  constructor(topia) {
13
13
  this.topia = topia;
14
14
  }
15
+ create(id, urlSlug, options) {
16
+ return new Visitor(this.topia, id, urlSlug, options);
17
+ }
15
18
  get(id, urlSlug, options) {
16
19
  return __awaiter(this, void 0, void 0, function* () {
17
20
  const visitor = new Visitor(this.topia, id, urlSlug, options);
@@ -19,8 +22,5 @@ export class VisitorFactory {
19
22
  return visitor;
20
23
  });
21
24
  }
22
- create(id, urlSlug, options) {
23
- return new Visitor(this.topia, id, urlSlug, options);
24
- }
25
25
  }
26
26
  export default VisitorFactory;
@@ -0,0 +1,10 @@
1
+ import { WorldActivity } from "controllers";
2
+ export class WorldActivityFactory {
3
+ constructor(topia) {
4
+ this.topia = topia;
5
+ }
6
+ create(urlSlug, options) {
7
+ return new WorldActivity(this.topia, urlSlug, options);
8
+ }
9
+ }
10
+ export default WorldActivityFactory;
@@ -1,5 +1,7 @@
1
1
  export { AssetFactory } from "./AssetFactory";
2
2
  export { DroppedAssetFactory } from "./DroppedAssetFactory";
3
+ export { SceneFactory } from "./SceneFactory";
3
4
  export { UserFactory } from "./UserFactory";
4
5
  export { VisitorFactory } from "./VisitorFactory";
6
+ export { WorldActivityFactory } from "./WorldActivityFactory";
5
7
  export { WorldFactory } from "./WorldFactory";
package/dist/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { Topia } from "controllers";
2
- export { AssetFactory, DroppedAssetFactory, UserFactory, VisitorFactory, WorldFactory } from "factories";
2
+ export { AssetFactory, DroppedAssetFactory, SceneFactory, UserFactory, VisitorFactory, WorldActivityFactory, WorldFactory, } from "factories";
3
3
  Error.stackTraceLimit = 20;
4
4
  process.on("unhandledRejection", (reason) => {
5
5
  if (reason.data) {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,9 @@
1
1
  export * from "./AssetInterfaces";
2
2
  export * from "./DroppedAssetInterfaces";
3
+ export * from "./SceneInterfaces";
3
4
  export * from "./SDKInterfaces";
4
5
  export * from "./TopiaInterfaces";
5
6
  export * from "./UserInterfaces";
6
7
  export * from "./VisitorInterfaces";
8
+ export * from "./WorldActivityInterfaces";
7
9
  export * from "./WorldInterfaces";
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.23"
59
+ "version": "0.0.25"
60
60
  }