hcloud-sdk 0.0.7 → 0.0.8

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 MoovIT Software Products GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import hcloud from './lib/hcloud';
1
+ import hcloud from "./lib/hcloud";
2
2
  export default hcloud;
package/lib/base.d.ts CHANGED
@@ -1,9 +1,7 @@
1
- import AxiosService from './Axios';
2
1
  export interface Options {
3
2
  api: string;
4
3
  }
5
4
  export default abstract class Base {
6
5
  protected opts: Options;
7
- protected axios: AxiosService;
8
6
  constructor(opts: Options);
9
7
  }
package/lib/base.js CHANGED
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Axios_1 = require("./Axios");
4
3
  class Base {
5
4
  constructor(opts) {
6
5
  this.opts = opts;
7
- this.axios = new Axios_1.default();
8
6
  }
9
7
  }
10
8
  exports.default = Base;
package/lib/dto/IDP.d.ts CHANGED
@@ -7,10 +7,6 @@ export interface User {
7
7
  export interface Token {
8
8
  token: string;
9
9
  }
10
- export interface UserAndToken {
11
- user: User;
12
- token: Token;
13
- }
14
10
  export interface ErrorMessage {
15
11
  status: number;
16
12
  message: string;
package/lib/hcloud.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import base, { Options } from './base';
2
- import IDPService from './service/IDP';
3
- import High5Service from './service/High5';
1
+ import base, { Options } from "./base";
2
+ import IDPService from "./service/IDP";
3
+ import High5Service from "./service/High5";
4
4
  export default class hcloud extends base {
5
5
  IDP: IDPService;
6
6
  High5: High5Service;
@@ -1,4 +1,4 @@
1
- import base from '../base';
1
+ import base from "../base";
2
2
  export default class High5 extends base {
3
3
  private getEndpoint;
4
4
  }
@@ -1,5 +1,5 @@
1
- import base from '../base';
2
- import { Token, User } from '../dto/IDP';
1
+ import base from "../base";
2
+ import { Token, User } from "../dto/IDP";
3
3
  export default class IDP extends base {
4
4
  /**
5
5
  * Authorize validates a token
@@ -20,9 +20,7 @@ class IDP extends base_1.default {
20
20
  * @returns User object
21
21
  */
22
22
  this.authorize = (token) => __awaiter(this, void 0, void 0, function* () {
23
- const resp = yield axios_1.default
24
- .post(this.getEndpoint('/v1/authenticate'), {}, { headers: { Authorization: token } })
25
- .catch((err) => {
23
+ const resp = yield axios_1.default.post(this.getEndpoint("/v1/authenticate"), {}, { headers: { Authorization: token } }).catch((err) => {
26
24
  throw err;
27
25
  });
28
26
  return resp.data;
@@ -36,7 +34,7 @@ class IDP extends base_1.default {
36
34
  */
37
35
  this.register = (name, email, password) => __awaiter(this, void 0, void 0, function* () {
38
36
  const resp = yield axios_1.default
39
- .post(this.getEndpoint('/v1/registration'), { name: name, email: email, password: password })
37
+ .post(this.getEndpoint("/v1/registration"), { name: name, email: email, password: password })
40
38
  .catch((err) => {
41
39
  throw err;
42
40
  });
@@ -49,9 +47,7 @@ class IDP extends base_1.default {
49
47
  * @returns Bearer Token
50
48
  */
51
49
  this.authenticate = (email, password) => __awaiter(this, void 0, void 0, function* () {
52
- const resp = yield axios_1.default
53
- .post(this.getEndpoint('/v1/authorize'), { email: email, password: password })
54
- .catch((err) => {
50
+ const resp = yield axios_1.default.post(this.getEndpoint("/v1/authorize"), { email: email, password: password }).catch((err) => {
55
51
  throw err;
56
52
  });
57
53
  // tslint-disable: no-string-literal
@@ -65,9 +61,7 @@ class IDP extends base_1.default {
65
61
  * @returns User object
66
62
  */
67
63
  this.authenticateReturnUser = (email, password) => __awaiter(this, void 0, void 0, function* () {
68
- const resp = yield axios_1.default
69
- .post(this.getEndpoint('/v1/authorize'), { email: email, password: password })
70
- .catch((err) => {
64
+ const resp = yield axios_1.default.post(this.getEndpoint("/v1/authorize"), { email: email, password: password }).catch((err) => {
71
65
  throw err;
72
66
  });
73
67
  return resp.data;
package/package.json CHANGED
@@ -1,43 +1,43 @@
1
1
  {
2
- "name": "hcloud-sdk",
3
- "version": "0.0.7",
4
- "description": "hcloud platform sdk",
5
- "main": "index.js",
6
- "types": "index.d.ts",
7
- "scripts": {
8
- "test": "mocha -r ts-node/register test/**/*.test.ts",
9
- "format": "prettier --write \"src/**/*.ts\"",
10
- "lint": "tslint -p tsconfig.json",
11
- "build": "tsc"
12
- },
13
- "repository": {
14
- "type": "git",
15
- "url": "git+https://github.com/moovit-sp-gmbh/hcloud-sdk-js.git"
16
- },
17
- "keywords": [
18
- "hcloud",
19
- "sdk"
20
- ],
21
- "license": "ISC",
22
- "bugs": {
23
- "url": "https://github.com/moovit-sp-gmbh/hcloud-sdk-js/issues"
24
- },
25
- "author": "moovit-sp-gmbh",
26
- "homepage": "https://github.com/moovit-sp-gmbh/hcloud-sdk-js#readme",
27
- "devDependencies": {
28
- "@types/chai": "^4.3.1",
29
- "@types/mocha": "^9.1.1",
30
- "@types/uuid": "^8.3.4",
31
- "chai": "^4.3.6",
32
- "mocha": "^10.0.0",
33
- "prettier": "^2.6.2",
34
- "ts-node": "^10.8.0",
35
- "tslint": "^6.1.3",
36
- "tslint-config-prettier": "^1.18.0",
37
- "typescript": "^4.7.2",
38
- "uuid": "^8.3.2"
39
- },
40
- "dependencies": {
41
- "axios": "^0.27.2"
42
- }
2
+ "name": "hcloud-sdk",
3
+ "version": "0.0.8",
4
+ "description": "hcloud platform sdk",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "scripts": {
8
+ "test": "mocha -r ts-node/register tests/**/*.test.ts",
9
+ "format": "prettier --write \"src/**/*.ts\" \"tests/**/*.test.ts\"",
10
+ "lint": "tslint -p tsconfig.json",
11
+ "build": "tsc"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/moovit-sp-gmbh/hcloud-sdk-js.git"
16
+ },
17
+ "keywords": [
18
+ "hcloud",
19
+ "sdk"
20
+ ],
21
+ "license": "MIT",
22
+ "bugs": {
23
+ "url": "https://github.com/moovit-sp-gmbh/hcloud-sdk-js/issues"
24
+ },
25
+ "author": "moovit-sp-gmbh",
26
+ "homepage": "https://github.com/moovit-sp-gmbh/hcloud-sdk-js#readme",
27
+ "devDependencies": {
28
+ "@types/chai": "^4.3.1",
29
+ "@types/mocha": "^9.1.1",
30
+ "@types/uuid": "^8.3.4",
31
+ "chai": "^4.3.6",
32
+ "mocha": "^10.0.0",
33
+ "prettier": "^2.6.2",
34
+ "ts-node": "^10.8.0",
35
+ "tslint": "^6.1.3",
36
+ "tslint-config-prettier": "^1.18.0",
37
+ "typescript": "^4.7.2",
38
+ "uuid": "^8.3.2"
39
+ },
40
+ "dependencies": {
41
+ "axios": "^0.27.2"
42
+ }
43
43
  }
package/lib/Axios.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { AxiosPromise } from 'axios';
2
- export default class AxiosService {
3
- get: (url: string) => Promise<AxiosPromise>;
4
- post: (url: string, body: any) => Promise<AxiosPromise>;
5
- }
package/lib/Axios.js DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const axios_1 = require("axios");
13
- class AxiosService {
14
- constructor() {
15
- this.get = (url) => __awaiter(this, void 0, void 0, function* () {
16
- return axios_1.default.get(url);
17
- });
18
- this.post = (url, body) => __awaiter(this, void 0, void 0, function* () {
19
- return axios_1.default.post(url, body, {});
20
- });
21
- }
22
- }
23
- exports.default = AxiosService;
package/lib/common.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import AxiosService from './Axios';
2
- export interface options {
3
- api: string;
4
- }
5
- export default abstract class common {
6
- protected opts: options;
7
- protected axios: AxiosService;
8
- constructor(opts: options);
9
- }
package/lib/common.js DELETED
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const Axios_1 = require("./Axios");
4
- // tslint:disable-next-line
5
- class common {
6
- constructor(opts) {
7
- this.opts = opts;
8
- this.axios = new Axios_1.default();
9
- }
10
- }
11
- exports.default = common;