@rtsdk/topia 0.0.9 → 0.0.11
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 +19 -0
- package/dist/__mocks__/worlds.js +1 -0
- package/dist/controllers/Asset.js +2 -44
- package/dist/controllers/DroppedAsset.js +36 -35
- package/dist/controllers/User.js +91 -0
- package/dist/controllers/Visitor.js +4 -43
- package/dist/controllers/World.js +112 -63
- package/dist/controllers/__tests__/asset.test.js +13 -4
- package/dist/controllers/__tests__/droppedAsset.test.js +55 -71
- package/dist/controllers/__tests__/user.test.js +23 -0
- package/dist/controllers/__tests__/visitor.test.js +17 -5
- package/dist/controllers/__tests__/world.test.js +49 -24
- package/dist/controllers/index.js +1 -1
- package/dist/index.js +2 -18268
- package/dist/{types/DroppedAssetType.js → interfaces/AssetInterfaces.js} +0 -0
- package/dist/{types/VisitorType.js → interfaces/VisitorInterfaces.js} +0 -0
- package/dist/interfaces/index.js +2 -0
- package/dist/utils/__tests__/removeUndefined.test.js +10 -0
- package/dist/utils/__tests__/scatterVisitors.test.js +4 -4
- package/dist/utils/getErrorMessage.js +2 -2
- package/dist/utils/index.js +1 -1
- package/dist/utils/publicAPI.js +0 -1
- package/dist/utils/removeUndefined.js +8 -0
- package/package.json +3 -1
- package/dist/controllers/Scene.js +0 -22
- package/dist/controllers/__tests__/scene.test.js +0 -14
- package/dist/types/Visitors.js +0 -1
- package/dist/utils/createVisitor.js +0 -3
|
File without changes
|
|
File without changes
|
package/dist/interfaces/index.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
});
|
|
@@ -2,10 +2,10 @@ import { scatterVisitors } from "../scatterVisitors";
|
|
|
2
2
|
afterEach(() => {
|
|
3
3
|
jest.resetAllMocks();
|
|
4
4
|
});
|
|
5
|
-
describe("
|
|
6
|
-
it("should
|
|
5
|
+
describe("scatter visitors util", () => {
|
|
6
|
+
it("should scatter visitors by 50", () => {
|
|
7
7
|
const testScatter = scatterVisitors(10, 50);
|
|
8
|
-
expect(testScatter).
|
|
9
|
-
expect(testScatter).
|
|
8
|
+
expect(testScatter).toBeGreaterThanOrEqual(-40);
|
|
9
|
+
expect(testScatter).toBeLessThanOrEqual(60);
|
|
10
10
|
});
|
|
11
11
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const getErrorMessage = (error) => {
|
|
2
|
-
|
|
3
|
-
const errorMessage = error
|
|
2
|
+
var _a, _b, _c;
|
|
3
|
+
const errorMessage = (_c = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.errors[0]) === null || _c === void 0 ? void 0 : _c.message;
|
|
4
4
|
return errorMessage || "Something went wrong. Please try again or contact support.";
|
|
5
5
|
};
|
package/dist/utils/index.js
CHANGED
package/dist/utils/publicAPI.js
CHANGED
package/package.json
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"rollup-plugin-terser": "^7.0.2",
|
|
24
24
|
"rollup-plugin-typescript2": "^0.34.1",
|
|
25
25
|
"ts-jest": "^29.0.3",
|
|
26
|
+
"typedoc": "^0.23.23",
|
|
26
27
|
"typescript": "^4.9.3",
|
|
27
28
|
"yalc": "^1.0.0-pre.53"
|
|
28
29
|
},
|
|
@@ -48,9 +49,10 @@
|
|
|
48
49
|
"build": "tsc && rollup -c",
|
|
49
50
|
"test": "ENV=testing jest --watchAll=false",
|
|
50
51
|
"lint": "eslint \"src/**\"",
|
|
52
|
+
"docs": "typedoc",
|
|
51
53
|
"pkg": "npm publish",
|
|
52
54
|
"local-publish": "yarn build && yalc publish --push --no-scripts"
|
|
53
55
|
},
|
|
54
56
|
"type": "module",
|
|
55
|
-
"version": "0.0.
|
|
57
|
+
"version": "0.0.11"
|
|
56
58
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { getErrorMessage, publicAPI } from "utils";
|
|
2
|
-
export class Scene {
|
|
3
|
-
apiKey;
|
|
4
|
-
email;
|
|
5
|
-
constructor(apiKey, email) {
|
|
6
|
-
this.apiKey = apiKey;
|
|
7
|
-
this.email = email;
|
|
8
|
-
}
|
|
9
|
-
fetchScenesByEmail() {
|
|
10
|
-
return new Promise((resolve, reject) => {
|
|
11
|
-
publicAPI(this.apiKey)
|
|
12
|
-
.get(`/scenes/my-scenes?email=${this.email}`)
|
|
13
|
-
.then((response) => {
|
|
14
|
-
resolve(response.data);
|
|
15
|
-
})
|
|
16
|
-
.catch((error) => {
|
|
17
|
-
reject(new Error(getErrorMessage(error)));
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export default Scene;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { scenes } from "../../__mocks__";
|
|
2
|
-
import { Scene } from "..";
|
|
3
|
-
afterEach(() => {
|
|
4
|
-
jest.resetAllMocks();
|
|
5
|
-
});
|
|
6
|
-
describe("Scene Class", () => {
|
|
7
|
-
it("should return an array of scenes owned by specific email address", async () => {
|
|
8
|
-
const testScene = await new Scene("key", "lina@topia.io");
|
|
9
|
-
testScene.fetchScenesByEmail = jest.fn().mockReturnValue(scenes);
|
|
10
|
-
const mockScenes = await testScene.fetchScenesByEmail();
|
|
11
|
-
expect(testScene.fetchScenesByEmail).toHaveBeenCalled();
|
|
12
|
-
expect(mockScenes).toBeDefined();
|
|
13
|
-
});
|
|
14
|
-
});
|
package/dist/types/Visitors.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export const createVisitor = (Visitor, apiKey, data, urlSlug) => {
|
|
2
|
-
return new Visitor(apiKey, data.color, data.displayName, data.gestureType, data.hidden, data.isAdmin, data.isBackground, data.isMobile, data.isRecording, data.isRecordingBot, data.lastUpdate, data.moveFrom, data.movedOn, data.moveTo, data.muted, data.performer, data.performerNear, data.playerId, data.shareScreen, data.sitting, urlSlug, data.username);
|
|
3
|
-
};
|