@rtsdk/topia 0.0.5 → 0.0.7

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.
@@ -0,0 +1,71 @@
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 axios from "axios";
11
+ const API_URL = "https://api.topia.io/api";
12
+ class World {
13
+ constructor(apiKey, urlSlug) {
14
+ this.apiKey = apiKey;
15
+ this.urlSlug = urlSlug;
16
+ }
17
+ fetchDetails() {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ return new Promise((resolve, reject) => {
20
+ axios
21
+ .get(`${API_URL}/world/${this.urlSlug}/world-details`, {
22
+ headers: { Authorization: this.apiKey },
23
+ })
24
+ .then((response) => {
25
+ console.log("🚀 ~ file: World.ts ~ line 21 ~ World ~ .then ~ response", response);
26
+ resolve(response.data);
27
+ })
28
+ .catch(reject);
29
+ });
30
+ });
31
+ }
32
+ fetchVisitors() {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ return new Promise((resolve, reject) => {
35
+ axios
36
+ .get(`${API_URL}/world/${this.urlSlug}/visitors`, {
37
+ headers: { Authorization: this.apiKey },
38
+ })
39
+ .then((response) => {
40
+ console.log("🚀 ~ file: World.ts ~ line 35 ~ World ~ .then ~ response", response);
41
+ resolve(response.data);
42
+ })
43
+ .catch(reject);
44
+ });
45
+ });
46
+ }
47
+ moveVisitor(visitor) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ return new Promise((resolve, reject) => {
50
+ const requestOptions = {
51
+ headers: { Authorization: this.apiKey },
52
+ body: {
53
+ moveTo: {
54
+ x: visitor.coordinates.x,
55
+ y: visitor.coordinates.y,
56
+ },
57
+ teleport: true,
58
+ },
59
+ };
60
+ axios
61
+ .put(`${API_URL}/world/${this.urlSlug}/visitors/${visitor.visitorId}/move`, requestOptions)
62
+ .then((response) => {
63
+ console.log("🚀 ~ file: World.ts ~ line 49 ~ World ~ .then ~ response", response);
64
+ resolve(response.data);
65
+ })
66
+ .catch(reject);
67
+ });
68
+ });
69
+ }
70
+ }
71
+ export { World };
package/dist/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var require$$1 = require('util');
6
4
  var stream = require('stream');
7
5
  var require$$1$1 = require('path');
@@ -15,6 +13,31 @@ var require$$0$2 = require('os');
15
13
  var zlib = require('zlib');
16
14
  var EventEmitter = require('events');
17
15
 
16
+ /******************************************************************************
17
+ Copyright (c) Microsoft Corporation.
18
+
19
+ Permission to use, copy, modify, and/or distribute this software for any
20
+ purpose with or without fee is hereby granted.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
23
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
25
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
26
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
27
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28
+ PERFORMANCE OF THIS SOFTWARE.
29
+ ***************************************************************************** */
30
+
31
+ function __awaiter(thisArg, _arguments, P, generator) {
32
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
33
+ return new (P || (P = Promise))(function (resolve, reject) {
34
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
35
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
36
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
37
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
38
+ });
39
+ }
40
+
18
41
  function bind(fn, thisArg) {
19
42
  return function wrap() {
20
43
  return fn.apply(thisArg, arguments);
@@ -17815,19 +17838,65 @@ axios.formToJSON = thing => {
17815
17838
  return formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
17816
17839
  };
17817
17840
 
17818
- function getWorldDetails(urlSlug) {
17819
- return new Promise((resolve, reject) => {
17820
- axios
17821
- .get(`https://api.topia.io/api/world/${urlSlug}/world-details`, {
17822
- headers: { Authorization: process.env.API_KEY },
17823
- })
17824
- .then((response) => {
17825
- resolve(response.data);
17826
- })
17827
- .catch(reject);
17828
- });
17829
- }
17830
- var index = { getWorldDetails };
17841
+ const API_URL = "https://api.topia.io/api";
17842
+ class World {
17843
+ constructor(apiKey, urlSlug) {
17844
+ this.apiKey = apiKey;
17845
+ this.urlSlug = urlSlug;
17846
+ }
17847
+ fetchDetails() {
17848
+ return __awaiter(this, void 0, void 0, function* () {
17849
+ return new Promise((resolve, reject) => {
17850
+ axios
17851
+ .get(`${API_URL}/world/${this.urlSlug}/world-details`, {
17852
+ headers: { Authorization: this.apiKey },
17853
+ })
17854
+ .then((response) => {
17855
+ console.log("🚀 ~ file: World.ts ~ line 21 ~ World ~ .then ~ response", response);
17856
+ resolve(response.data);
17857
+ })
17858
+ .catch(reject);
17859
+ });
17860
+ });
17861
+ }
17862
+ fetchVisitors() {
17863
+ return __awaiter(this, void 0, void 0, function* () {
17864
+ return new Promise((resolve, reject) => {
17865
+ axios
17866
+ .get(`${API_URL}/world/${this.urlSlug}/visitors`, {
17867
+ headers: { Authorization: this.apiKey },
17868
+ })
17869
+ .then((response) => {
17870
+ console.log("🚀 ~ file: World.ts ~ line 35 ~ World ~ .then ~ response", response);
17871
+ resolve(response.data);
17872
+ })
17873
+ .catch(reject);
17874
+ });
17875
+ });
17876
+ }
17877
+ moveVisitor(visitor) {
17878
+ return __awaiter(this, void 0, void 0, function* () {
17879
+ return new Promise((resolve, reject) => {
17880
+ const requestOptions = {
17881
+ headers: { Authorization: this.apiKey },
17882
+ body: {
17883
+ moveTo: {
17884
+ x: visitor.coordinates.x,
17885
+ y: visitor.coordinates.y,
17886
+ },
17887
+ teleport: true,
17888
+ },
17889
+ };
17890
+ axios
17891
+ .put(`${API_URL}/world/${this.urlSlug}/visitors/${visitor.visitorId}/move`, requestOptions)
17892
+ .then((response) => {
17893
+ console.log("🚀 ~ file: World.ts ~ line 49 ~ World ~ .then ~ response", response);
17894
+ resolve(response.data);
17895
+ })
17896
+ .catch(reject);
17897
+ });
17898
+ });
17899
+ }
17900
+ }
17831
17901
 
17832
- exports.default = index;
17833
- exports.getWorldDetails = getWorldDetails;
17902
+ exports.World = World;
@@ -7,10 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { getWorldDetails } from ".";
11
- describe("getWorldDetails", () => {
10
+ import { World } from ".";
11
+ const API_KEY = "c3e68f35-2b03-42ab-8946-e9a78dd92f57";
12
+ describe("get world details", () => {
12
13
  it("should return details of a world", () => __awaiter(void 0, void 0, void 0, function* () {
13
- const result = yield getWorldDetails("lina");
14
- expect(result).toBeDefined();
14
+ const myWorld = new World(API_KEY, "lina");
15
+ const details = myWorld.fetchDetails();
16
+ console.log("🚀 ~ file: index.test.ts ~ line 7 ~ it ~ details", details);
17
+ // expect(result).toBeDefined();
15
18
  }));
16
19
  });
package/package.json CHANGED
@@ -20,12 +20,13 @@
20
20
  "rollup": "^3.4.0",
21
21
  "rollup-plugin-typescript2": "^0.34.1",
22
22
  "ts-jest": "^29.0.3",
23
- "typescript": "^4.9.3"
23
+ "typescript": "^4.9.3",
24
+ "yalc": "^1.0.0-pre.53"
24
25
  },
25
26
  "files": [
26
27
  "dist/*"
27
28
  ],
28
- "gitHead": "69d40bacabdddb61f753a133ea5204e8c92d0170",
29
+ "gitHead": "7eef1f7fd9b3b0af395f95cb908add3011abf808",
29
30
  "homepage": "https://github.com/metaversecloud-com/mc-sdk-js/tree/main/clients/client-topia",
30
31
  "license": "ISC",
31
32
  "keywords": [],
@@ -44,8 +45,9 @@
44
45
  "build": "tsc && rollup -c",
45
46
  "test": "ENV=testing jest --watchAll=false",
46
47
  "lint": "eslint \"src/**\"",
47
- "publish": "npm publish"
48
+ "publish": "npm publish",
49
+ "local-publish": "yarn build && yalc publish --push"
48
50
  },
49
51
  "type": "module",
50
- "version": "0.0.5"
52
+ "version": "0.0.7"
51
53
  }