@rtsdk/topia 0.1.0 → 0.1.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 +0 -13
- package/dist/index.js +1 -14
- package/dist/types/example.d.ts +6 -0
- package/dist/types/src/__mocks__/assets.d.ts +99 -0
- package/dist/{src/__mocks__/index.js → types/src/__mocks__/index.d.ts} +4 -4
- package/dist/types/src/__mocks__/scenes.d.ts +79 -0
- package/dist/types/src/__mocks__/visitors.d.ts +83 -0
- package/dist/types/src/__mocks__/worlds.d.ts +73 -0
- package/dist/types/src/controllers/Asset.d.ts +20 -0
- package/dist/types/src/controllers/DroppedAsset.d.ts +285 -0
- package/dist/types/src/controllers/SDKController.d.ts +48 -0
- package/dist/types/src/controllers/Scene.d.ts +19 -0
- package/dist/types/src/controllers/Topia.d.ts +33 -0
- package/dist/types/src/controllers/User.d.ts +58 -0
- package/dist/types/src/controllers/Visitor.d.ts +50 -0
- package/dist/types/src/controllers/World.d.ts +143 -0
- package/dist/types/src/controllers/WorldActivity.d.ts +83 -0
- package/dist/{src/interfaces/AssetInterfaces.js → types/src/controllers/__tests__/asset.test.d.ts} +1 -1
- package/dist/{src/interfaces/DroppedAssetInterfaces.js → types/src/controllers/__tests__/droppedAsset.test.d.ts} +1 -1
- package/dist/{src/interfaces/SDKInterfaces.js → types/src/controllers/__tests__/scene.test.d.ts} +1 -1
- package/dist/{src/interfaces/SceneInterfaces.js → types/src/controllers/__tests__/user.test.d.ts} +1 -1
- package/dist/types/src/controllers/__tests__/visitor.test.d.ts +1 -0
- package/dist/types/src/controllers/__tests__/world.test.d.ts +1 -0
- package/dist/types/src/controllers/__tests__/worldActivity.test.d.ts +1 -0
- package/dist/{src/controllers/index.js → types/src/controllers/index.d.ts} +9 -9
- package/dist/types/src/factories/AssetFactory.d.ts +8 -0
- package/dist/types/src/factories/DroppedAssetFactory.d.ts +16 -0
- package/dist/types/src/factories/SceneFactory.d.ts +9 -0
- package/dist/types/src/factories/UserFactory.d.ts +8 -0
- package/dist/types/src/factories/VisitorFactory.d.ts +9 -0
- package/dist/types/src/factories/WorldActivityFactory.d.ts +8 -0
- package/dist/types/src/factories/WorldFactory.d.ts +8 -0
- package/dist/{src/factories/index.js → types/src/factories/index.d.ts} +7 -7
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/interfaces/AssetInterfaces.d.ts +26 -0
- package/dist/types/src/interfaces/DroppedAssetInterfaces.d.ts +102 -0
- package/dist/types/src/interfaces/SDKInterfaces.d.ts +8 -0
- package/dist/types/src/interfaces/SceneInterfaces.d.ts +27 -0
- package/dist/types/src/interfaces/TopiaInterfaces.d.ts +10 -0
- package/dist/types/src/interfaces/UserInterfaces.d.ts +6 -0
- package/dist/types/src/interfaces/VisitorInterfaces.d.ts +37 -0
- package/dist/types/src/interfaces/WorldActivityInterfaces.d.ts +11 -0
- package/dist/types/src/interfaces/WorldInterfaces.d.ts +32 -0
- package/dist/{src/interfaces/index.js → types/src/interfaces/index.d.ts} +9 -9
- package/dist/types/src/types/DroppedAssetTypes.d.ts +10 -0
- package/dist/types/src/types/InteractiveCredentialsTypes.d.ts +8 -0
- package/dist/types/src/types/OptionsTypes.d.ts +21 -0
- package/dist/types/src/types/ResponseTypes.d.ts +4 -0
- package/dist/types/src/types/VisitorTypes.d.ts +33 -0
- package/dist/{src/types/index.js → types/src/types/index.d.ts} +5 -4
- package/dist/types/src/utils/__tests__/removeUndefined.test.d.ts +1 -0
- package/dist/types/src/utils/__tests__/scatterVisitors.test.d.ts +1 -0
- package/dist/types/src/utils/getBrowserWarning.d.ts +1 -0
- package/dist/{src/utils/index.js → types/src/utils/index.d.ts} +3 -3
- package/dist/types/src/utils/removeUndefined.d.ts +8 -0
- package/dist/types/src/utils/scatterVisitors.d.ts +4 -0
- package/package.json +3 -2
- package/dist/example.js +0 -32
- package/dist/src/__mocks__/assets.js +0 -249
- package/dist/src/__mocks__/scenes.js +0 -104
- package/dist/src/__mocks__/visitors.js +0 -83
- package/dist/src/__mocks__/worlds.js +0 -52
- package/dist/src/controllers/Asset.js +0 -39
- package/dist/src/controllers/DroppedAsset.js +0 -461
- package/dist/src/controllers/SDKController.js +0 -85
- package/dist/src/controllers/Scene.js +0 -39
- package/dist/src/controllers/Topia.js +0 -39
- package/dist/src/controllers/User.js +0 -139
- package/dist/src/controllers/Visitor.js +0 -92
- package/dist/src/controllers/World.js +0 -256
- package/dist/src/controllers/WorldActivity.js +0 -162
- package/dist/src/controllers/__tests__/asset.test.js +0 -37
- package/dist/src/controllers/__tests__/droppedAsset.test.js +0 -98
- package/dist/src/controllers/__tests__/scene.test.js +0 -38
- package/dist/src/controllers/__tests__/user.test.js +0 -49
- package/dist/src/controllers/__tests__/visitor.test.js +0 -47
- package/dist/src/controllers/__tests__/world.test.js +0 -51
- package/dist/src/controllers/__tests__/worldActivity.test.js +0 -63
- package/dist/src/factories/AssetFactory.js +0 -11
- package/dist/src/factories/DroppedAssetFactory.js +0 -42
- package/dist/src/factories/SceneFactory.js +0 -27
- package/dist/src/factories/UserFactory.js +0 -10
- package/dist/src/factories/VisitorFactory.js +0 -26
- package/dist/src/factories/WorldActivityFactory.js +0 -10
- package/dist/src/factories/WorldFactory.js +0 -10
- package/dist/src/index.js +0 -28
- package/dist/src/interfaces/TopiaInterfaces.js +0 -1
- package/dist/src/interfaces/UserInterfaces.js +0 -1
- package/dist/src/interfaces/VisitorInterfaces.js +0 -1
- package/dist/src/interfaces/WorldActivityInterfaces.js +0 -1
- package/dist/src/interfaces/WorldInterfaces.js +0 -1
- package/dist/src/types/DroppedAssetTypes.js +0 -12
- package/dist/src/types/InteractiveCredentialsTypes.js +0 -1
- package/dist/src/types/OptionsTypes.js +0 -1
- package/dist/src/types/ResponseTypes.js +0 -1
- package/dist/src/types/VisitorTypes.js +0 -1
- package/dist/src/utils/__tests__/removeUndefined.test.js +0 -10
- package/dist/src/utils/__tests__/scatterVisitors.test.js +0 -11
- package/dist/src/utils/getBrowserWarning.js +0 -5
- package/dist/src/utils/removeUndefined.js +0 -11
- package/dist/src/utils/scatterVisitors.js +0 -8
|
@@ -1,98 +0,0 @@
|
|
|
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 { droppedAssets } from "__mocks__";
|
|
11
|
-
import { Topia } from "controllers";
|
|
12
|
-
import { DroppedAssetClickType, DroppedAssetMediaType } from "types";
|
|
13
|
-
import MockAdapter from "axios-mock-adapter";
|
|
14
|
-
import { DroppedAssetFactory } from "factories";
|
|
15
|
-
const apiDomain = "api.topia.io";
|
|
16
|
-
const attributes = droppedAssets[0];
|
|
17
|
-
const BASE_URL = `https://api.topia.io/api/v1/world/exampleWorld/assets/${droppedAssets[0].id}`;
|
|
18
|
-
const id = droppedAssets[0].id;
|
|
19
|
-
describe("DroppedAsset Class", () => {
|
|
20
|
-
let DroppedAsset, mock, testDroppedAsset, topia;
|
|
21
|
-
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
-
topia = new Topia({
|
|
23
|
-
apiDomain,
|
|
24
|
-
apiKey: "key",
|
|
25
|
-
apiProtocol: "https",
|
|
26
|
-
});
|
|
27
|
-
mock = new MockAdapter(topia.axios);
|
|
28
|
-
DroppedAsset = new DroppedAssetFactory(topia);
|
|
29
|
-
testDroppedAsset = yield DroppedAsset.create(id, "exampleWorld");
|
|
30
|
-
}));
|
|
31
|
-
afterEach(() => {
|
|
32
|
-
mock.restore();
|
|
33
|
-
jest.resetAllMocks();
|
|
34
|
-
});
|
|
35
|
-
it("should fetch dropped asset by id", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
mock.onGet(BASE_URL).reply(200, droppedAssets[0]);
|
|
37
|
-
yield testDroppedAsset.fetchDroppedAssetById();
|
|
38
|
-
expect(mock.history.get.length).toBe(1);
|
|
39
|
-
expect(testDroppedAsset.urlSlug).toBeDefined();
|
|
40
|
-
}));
|
|
41
|
-
it("should update dropped asset broadcast zone", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
mock.onPut(`${BASE_URL}/set-asset-broadcast`).reply(200);
|
|
43
|
-
const broadcastArgs = Object.assign(Object.assign({}, attributes), { assetBroadcast: true, assetBroadcastAll: false, broadcasterEmail: "test@test.com" });
|
|
44
|
-
yield testDroppedAsset.updateBroadcast(broadcastArgs);
|
|
45
|
-
expect(mock.history.put.length).toBe(1);
|
|
46
|
-
}));
|
|
47
|
-
it("should update dropped asset click type", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
-
mock.onPut(`${BASE_URL}/change-click-type`).reply(200);
|
|
49
|
-
const clickTypeArgs = Object.assign(Object.assign({}, attributes), { clickType: DroppedAssetClickType.LINK, clickableLink: "www.test.com", clickableLinkTitle: "Test", clickableDisplayTextDescription: "Description", clickableDisplayTextHeadline: "Title", portalName: "Test", position: {
|
|
50
|
-
x: 0,
|
|
51
|
-
y: 0,
|
|
52
|
-
} });
|
|
53
|
-
yield testDroppedAsset.updateClickType(clickTypeArgs);
|
|
54
|
-
expect(mock.history.put.length).toBe(1);
|
|
55
|
-
}));
|
|
56
|
-
it("should update dropped asset custom text", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
-
mock.onPut(`${BASE_URL}/set-custom-text`).reply(200);
|
|
58
|
-
yield testDroppedAsset.updateCustomTextAsset({ textColor: "#abc123" }, "hello world");
|
|
59
|
-
expect(mock.history.put.length).toBe(1);
|
|
60
|
-
}));
|
|
61
|
-
it("should update dropped asset media type", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
-
mock.onPut(`${BASE_URL}/change-media-type`).reply(200);
|
|
63
|
-
const mediaTypeArgs = Object.assign(Object.assign({}, attributes), { audioRadius: 0, audioSliderVolume: 30, isVideo: true, mediaLink: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", mediaName: "string", mediaType: DroppedAssetMediaType.LINK, portalName: "community", syncUserMedia: true });
|
|
64
|
-
yield testDroppedAsset.updateMediaType(mediaTypeArgs);
|
|
65
|
-
expect(mock.history.put.length).toBe(1);
|
|
66
|
-
}));
|
|
67
|
-
it("should update dropped asset mute zone", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
-
mock.onPut(`${BASE_URL}/set-mute-zone`).reply(200);
|
|
69
|
-
yield testDroppedAsset.updateMuteZone(true);
|
|
70
|
-
expect(mock.history.put.length).toBe(1);
|
|
71
|
-
}));
|
|
72
|
-
it("should update dropped asset position", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
-
mock.onPut(`${BASE_URL}/set-position`).reply(200);
|
|
74
|
-
yield testDroppedAsset.updatePosition(100, 100);
|
|
75
|
-
expect(mock.history.put.length).toBe(1);
|
|
76
|
-
}));
|
|
77
|
-
it("should update dropped asset private zone", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
-
mock.onPut(`${BASE_URL}/set-private-zone`).reply(200);
|
|
79
|
-
const privateZoneArgs = Object.assign(Object.assign({}, attributes), { isPrivateZone: true, isPrivateZoneChatDisabled: false, privateZoneUserCap: 10 });
|
|
80
|
-
yield testDroppedAsset.updatePrivateZone(privateZoneArgs);
|
|
81
|
-
expect(mock.history.put.length).toBe(1);
|
|
82
|
-
}));
|
|
83
|
-
it("should update dropped asset scale", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
-
mock.onPut(`${BASE_URL}/change-scale`).reply(200);
|
|
85
|
-
yield testDroppedAsset.updateScale(75);
|
|
86
|
-
expect(mock.history.put.length).toBe(1);
|
|
87
|
-
}));
|
|
88
|
-
it("should update dropped asset uploaded media selected", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
|
-
mock.onPut(`${BASE_URL}/change-uploaded-media-selected`).reply(200);
|
|
90
|
-
yield testDroppedAsset.updateUploadedMediaSelected("abc123");
|
|
91
|
-
expect(mock.history.put.length).toBe(1);
|
|
92
|
-
}));
|
|
93
|
-
it("should update dropped asset web image layers", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
-
mock.onPut(`${BASE_URL}/set-webimage-layers`).reply(200);
|
|
95
|
-
yield testDroppedAsset.updateWebImageLayers("test", "test");
|
|
96
|
-
expect(mock.history.put.length).toBe(1);
|
|
97
|
-
}));
|
|
98
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
-
apiProtocol: "https",
|
|
22
|
-
interactiveKey: "key",
|
|
23
|
-
interactiveSecret: "secret",
|
|
24
|
-
});
|
|
25
|
-
mock = new MockAdapter(topia.axios);
|
|
26
|
-
Scene = new SceneFactory(topia);
|
|
27
|
-
testScene = Scene.create(scenes[0].id);
|
|
28
|
-
}));
|
|
29
|
-
afterEach(() => {
|
|
30
|
-
mock.restore();
|
|
31
|
-
jest.resetAllMocks();
|
|
32
|
-
});
|
|
33
|
-
it("should return a scene by id", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
mock.onGet(`https://${apiDomain}/api/v1/scenes/${scenes[0].id}`).reply(200);
|
|
35
|
-
yield testScene.fetchSceneById();
|
|
36
|
-
expect(mock.history.get.length).toBe(1);
|
|
37
|
-
}));
|
|
38
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
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 { droppedAssets, scenes, worlds } from "__mocks__";
|
|
12
|
-
import { Topia } from "controllers";
|
|
13
|
-
import { UserFactory } from "factories";
|
|
14
|
-
const apiDomain = "api-stage.topia.io";
|
|
15
|
-
describe("User Class", () => {
|
|
16
|
-
let mock, testUser, topia, User;
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
topia = new Topia({
|
|
19
|
-
apiDomain,
|
|
20
|
-
apiKey: "key",
|
|
21
|
-
apiProtocol: "https",
|
|
22
|
-
});
|
|
23
|
-
mock = new MockAdapter(topia.axios);
|
|
24
|
-
User = new UserFactory(topia);
|
|
25
|
-
testUser = User.create();
|
|
26
|
-
});
|
|
27
|
-
afterEach(() => {
|
|
28
|
-
mock.restore();
|
|
29
|
-
jest.resetAllMocks();
|
|
30
|
-
});
|
|
31
|
-
it("should return an array of assets owned by specific email address", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
-
testUser.fetchAssets = jest.fn().mockReturnValue(droppedAssets);
|
|
33
|
-
const mockAssets = yield testUser.fetchAssets();
|
|
34
|
-
expect(testUser.fetchAssets).toHaveBeenCalled();
|
|
35
|
-
expect(mockAssets).toBeDefined();
|
|
36
|
-
}));
|
|
37
|
-
it("should return an array of scenes owned by specific user", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
-
testUser.fetchScenes = jest.fn().mockReturnValue(scenes);
|
|
39
|
-
const mockScenes = yield testUser.fetchScenes();
|
|
40
|
-
expect(testUser.fetchScenes).toHaveBeenCalled();
|
|
41
|
-
expect(mockScenes).toBeDefined();
|
|
42
|
-
}));
|
|
43
|
-
it("should update user.worlds", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
-
mock.onGet(`https://${apiDomain}/api/v1/user/worlds`).reply(200, worlds);
|
|
45
|
-
yield testUser.fetchWorldsByKey();
|
|
46
|
-
expect(mock.history.get.length).toBe(1);
|
|
47
|
-
expect(Object.keys(testUser.worlds).length).toBe(Object.keys(worlds).length);
|
|
48
|
-
}));
|
|
49
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
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 { visitor } from "__mocks__";
|
|
12
|
-
import { Topia } from "controllers";
|
|
13
|
-
import { VisitorFactory } from "factories";
|
|
14
|
-
const apiDomain = "api.topia.io";
|
|
15
|
-
const id = visitor.visitorId;
|
|
16
|
-
const urlSlug = "exampleWorld";
|
|
17
|
-
describe("Visitor Class", () => {
|
|
18
|
-
let mock, testVisitor, topia, Visitor;
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
topia = new Topia({
|
|
21
|
-
apiDomain,
|
|
22
|
-
apiKey: "key",
|
|
23
|
-
apiProtocol: "https",
|
|
24
|
-
});
|
|
25
|
-
mock = new MockAdapter(topia.axios);
|
|
26
|
-
Visitor = new VisitorFactory(topia);
|
|
27
|
-
testVisitor = Visitor.create(id, urlSlug);
|
|
28
|
-
});
|
|
29
|
-
afterEach(() => {
|
|
30
|
-
mock.restore();
|
|
31
|
-
jest.resetAllMocks();
|
|
32
|
-
});
|
|
33
|
-
it("should update visitor details", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
mock.onGet(`https://${apiDomain}/api/v1/world/exampleWorld/visitors/1`).reply(200, visitor);
|
|
35
|
-
yield testVisitor.fetchVisitor();
|
|
36
|
-
expect(mock.history.get.length).toBe(1);
|
|
37
|
-
}));
|
|
38
|
-
it("should move a list of visitors to uniquely specified coordinates", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
mock.onPut(`https://${apiDomain}/api/v1/world/${urlSlug}/visitors/${id}/move`).reply(200);
|
|
40
|
-
yield testVisitor.moveVisitor({
|
|
41
|
-
shouldTeleportVisitor: true,
|
|
42
|
-
x: 100,
|
|
43
|
-
y: 100,
|
|
44
|
-
});
|
|
45
|
-
expect(mock.history.put.length).toBe(1);
|
|
46
|
-
}));
|
|
47
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
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 { worlds } from "__mocks__";
|
|
12
|
-
import { Topia } from "controllers";
|
|
13
|
-
import { WorldFactory } from "factories";
|
|
14
|
-
const urlSlug = worlds[1].urlSlug;
|
|
15
|
-
describe("World Class", () => {
|
|
16
|
-
let mock, testWorld, topia, World;
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
topia = new Topia({
|
|
19
|
-
apiDomain: "api.topia.io",
|
|
20
|
-
apiKey: "key",
|
|
21
|
-
apiProtocol: "https",
|
|
22
|
-
});
|
|
23
|
-
mock = new MockAdapter(topia.axios);
|
|
24
|
-
World = new WorldFactory(topia);
|
|
25
|
-
testWorld = World.create(urlSlug);
|
|
26
|
-
});
|
|
27
|
-
afterEach(() => {
|
|
28
|
-
mock.restore();
|
|
29
|
-
jest.resetAllMocks();
|
|
30
|
-
});
|
|
31
|
-
it("should return details of a world", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
-
expect(testWorld.urlSlug).toEqual("exampleWorld");
|
|
33
|
-
testWorld.fetchDetails = jest.fn().mockReturnValue(worlds[1]);
|
|
34
|
-
const mockDetails = yield testWorld.fetchDetails();
|
|
35
|
-
expect(testWorld.fetchDetails).toHaveBeenCalled();
|
|
36
|
-
expect(mockDetails).toBeDefined();
|
|
37
|
-
}));
|
|
38
|
-
// it("should update details of a world", async () => {
|
|
39
|
-
// mock.onPut(`${BASE_URL}/world-details`).reply(200);
|
|
40
|
-
// const worldArgs = {
|
|
41
|
-
// controls: {
|
|
42
|
-
// allowMuteAll: false,
|
|
43
|
-
// },
|
|
44
|
-
// description: "testing update details",
|
|
45
|
-
// name: "exampleWorld",
|
|
46
|
-
// };
|
|
47
|
-
// await testWorld.updateDetails(worldArgs);
|
|
48
|
-
// expect(mock.history.put.length).toBe(1);
|
|
49
|
-
// expect(testWorld.urlSlug).toEqual("exampleWorld");
|
|
50
|
-
// });
|
|
51
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
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
|
-
apiProtocol: "https",
|
|
23
|
-
});
|
|
24
|
-
mock = new MockAdapter(topia.axios);
|
|
25
|
-
WorldActivity = new WorldActivityFactory(topia);
|
|
26
|
-
testWorldActivity = WorldActivity.create(urlSlug);
|
|
27
|
-
});
|
|
28
|
-
afterEach(() => {
|
|
29
|
-
mock.restore();
|
|
30
|
-
jest.resetAllMocks();
|
|
31
|
-
});
|
|
32
|
-
it("should move all visitors within a world to a single set of coordinates", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
-
mock.onGet(`${BASE_URL}/visitors`).reply(200, visitors);
|
|
34
|
-
mock.onPut(`${BASE_URL}/visitors/1/move`).reply(200);
|
|
35
|
-
mock.onPut(`${BASE_URL}/visitors/2/move`).reply(200);
|
|
36
|
-
const attributes = {
|
|
37
|
-
shouldFetchVisitors: true,
|
|
38
|
-
shouldTeleportVisitors: true,
|
|
39
|
-
scatterVisitorsBy: 100,
|
|
40
|
-
x: 20,
|
|
41
|
-
y: 40,
|
|
42
|
-
};
|
|
43
|
-
yield testWorldActivity.moveAllVisitors(attributes);
|
|
44
|
-
expect(mock.history.put.length).toBe(Object.keys(visitors).length);
|
|
45
|
-
}));
|
|
46
|
-
it("should return success if world doesn't have visitors", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
const attributes = { shouldFetchVisitors: false, scatterVisitorsBy: 100, x: 20, y: 40 };
|
|
48
|
-
yield testWorldActivity.moveAllVisitors(attributes);
|
|
49
|
-
expect(mock.history.put.length).toBe(0);
|
|
50
|
-
}));
|
|
51
|
-
it("should move a list of visitors to uniquely specified coordinates", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
-
mock.onPut(`${BASE_URL}/visitors/1/move`).reply(200);
|
|
53
|
-
mock.onPut(`${BASE_URL}/visitors/2/move`).reply(200);
|
|
54
|
-
const v1 = new Visitor(topia, visitors["1"].visitorId, urlSlug, { attributes: visitors["1"] });
|
|
55
|
-
const v2 = new Visitor(topia, visitors["2"].visitorId, urlSlug, { attributes: visitors["2"] });
|
|
56
|
-
const testVisitors = [
|
|
57
|
-
{ visitorObj: v1, shouldTeleportVisitor: true, x: 0, y: 0 },
|
|
58
|
-
{ visitorObj: v2, shouldTeleportVisitor: false, x: 100, y: 100 },
|
|
59
|
-
];
|
|
60
|
-
yield testWorldActivity.moveVisitors(testVisitors);
|
|
61
|
-
expect(mock.history.put.length).toBe(2);
|
|
62
|
-
}));
|
|
63
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
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 { DroppedAsset, SDKController } from "controllers";
|
|
11
|
-
export class DroppedAssetFactory extends SDKController {
|
|
12
|
-
constructor(topia) {
|
|
13
|
-
super(topia);
|
|
14
|
-
}
|
|
15
|
-
create(id, urlSlug, options) {
|
|
16
|
-
return new DroppedAsset(this.topia, id, urlSlug, options);
|
|
17
|
-
}
|
|
18
|
-
get(id, urlSlug, options) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const droppedAsset = new DroppedAsset(this.topia, id, urlSlug, options);
|
|
21
|
-
yield droppedAsset.fetchDroppedAssetById();
|
|
22
|
-
return droppedAsset;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
drop(asset, { position: { x, y }, uniqueName, urlSlug, }) {
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
try {
|
|
28
|
-
const response = yield this.topiaPublicApi().post(`/world/${urlSlug}/assets`, {
|
|
29
|
-
assetId: asset.id,
|
|
30
|
-
position: { x, y },
|
|
31
|
-
uniqueName,
|
|
32
|
-
}, asset.requestOptions);
|
|
33
|
-
const { id } = response.data;
|
|
34
|
-
return new DroppedAsset(this.topia, id, urlSlug, { credentials: asset.credentials });
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
throw this.errorHandler({ error });
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export default DroppedAssetFactory;
|
|
@@ -1,27 +0,0 @@
|
|
|
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;
|
|
@@ -1,26 +0,0 @@
|
|
|
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 { Visitor } from "controllers";
|
|
11
|
-
export class VisitorFactory {
|
|
12
|
-
constructor(topia) {
|
|
13
|
-
this.topia = topia;
|
|
14
|
-
}
|
|
15
|
-
create(id, urlSlug, options) {
|
|
16
|
-
return new Visitor(this.topia, id, urlSlug, options);
|
|
17
|
-
}
|
|
18
|
-
get(id, urlSlug, options) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const visitor = new Visitor(this.topia, id, urlSlug, options);
|
|
21
|
-
yield visitor.fetchVisitor();
|
|
22
|
-
return visitor;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export default VisitorFactory;
|
|
@@ -1,10 +0,0 @@
|
|
|
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;
|
package/dist/src/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export { Topia } from "controllers";
|
|
2
|
-
export { AssetFactory, DroppedAssetFactory, SceneFactory, UserFactory, VisitorFactory, WorldActivityFactory, WorldFactory, } from "factories";
|
|
3
|
-
export * from "types";
|
|
4
|
-
Error.stackTraceLimit = 20;
|
|
5
|
-
process.on("unhandledRejection", (reason) => {
|
|
6
|
-
if (reason && reason.data) {
|
|
7
|
-
const { errors } = reason.data;
|
|
8
|
-
if (Array.isArray(errors)) {
|
|
9
|
-
for (const error of errors) {
|
|
10
|
-
console.error(error);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
console.error("Unhandled rejection failed with no defined reason.");
|
|
16
|
-
}
|
|
17
|
-
console.error((reason === null || reason === void 0 ? void 0 : reason.stack) || "no stack");
|
|
18
|
-
if (reason && reason.stack)
|
|
19
|
-
delete reason.stack;
|
|
20
|
-
console.error(reason);
|
|
21
|
-
console.error(`Please surround your use of the RTSDK with a try/catch block.`);
|
|
22
|
-
process.exit(1);
|
|
23
|
-
});
|
|
24
|
-
process.on("uncaughtException", function (err) {
|
|
25
|
-
// Handle the error safely
|
|
26
|
-
console.trace(err);
|
|
27
|
-
process.exit(1);
|
|
28
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export var DroppedAssetClickType;
|
|
2
|
-
(function (DroppedAssetClickType) {
|
|
3
|
-
DroppedAssetClickType["NONE"] = "none";
|
|
4
|
-
DroppedAssetClickType["LINK"] = "link";
|
|
5
|
-
DroppedAssetClickType["PORTAL"] = "portal";
|
|
6
|
-
DroppedAssetClickType["TELEPORT"] = "teleport";
|
|
7
|
-
})(DroppedAssetClickType || (DroppedAssetClickType = {}));
|
|
8
|
-
export var DroppedAssetMediaType;
|
|
9
|
-
(function (DroppedAssetMediaType) {
|
|
10
|
-
DroppedAssetMediaType["NONE"] = "none";
|
|
11
|
-
DroppedAssetMediaType["LINK"] = "link";
|
|
12
|
-
})(DroppedAssetMediaType || (DroppedAssetMediaType = {}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { removeUndefined } from "../removeUndefined";
|
|
2
|
-
afterEach(() => {
|
|
3
|
-
jest.resetAllMocks();
|
|
4
|
-
});
|
|
5
|
-
describe("remove undefined values util", () => {
|
|
6
|
-
it("should return an object without overriding with undefined values", () => {
|
|
7
|
-
const testRemoveUndefined = removeUndefined({ a: "abc", b: undefined, c: "123", d: null });
|
|
8
|
-
expect(testRemoveUndefined).toEqual({ a: "abc", c: "123", d: null });
|
|
9
|
-
});
|
|
10
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { scatterVisitors } from "../scatterVisitors";
|
|
2
|
-
afterEach(() => {
|
|
3
|
-
jest.resetAllMocks();
|
|
4
|
-
});
|
|
5
|
-
describe("scatter visitors util", () => {
|
|
6
|
-
it("should scatter visitors by 50", () => {
|
|
7
|
-
const testScatter = scatterVisitors(10, 50);
|
|
8
|
-
expect(testScatter).toBeGreaterThanOrEqual(-40);
|
|
9
|
-
expect(testScatter).toBeLessThanOrEqual(60);
|
|
10
|
-
});
|
|
11
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a random whole number within range of (original number - scatterBy) to (original number + scatterBy)
|
|
3
|
-
*/
|
|
4
|
-
export const scatterVisitors = (original, scatterBy) => {
|
|
5
|
-
const min = original - scatterBy;
|
|
6
|
-
const max = original + scatterBy;
|
|
7
|
-
return Math.floor(Math.random() * (max - min) + min);
|
|
8
|
-
};
|