hcloud-sdk 0.0.13 → 0.0.16

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 (39) hide show
  1. package/lib/base.d.ts +5 -0
  2. package/lib/hcloud.d.ts +6 -2
  3. package/lib/hcloud.js +12 -3
  4. package/{src/lib → lib}/interfaces/Auditor.d.ts +9 -3
  5. package/{src/lib → lib}/interfaces/Auditor.js +6 -0
  6. package/{src/lib → lib}/interfaces/Global.d.ts +0 -0
  7. package/{src/lib → lib}/interfaces/Global.js +0 -0
  8. package/{src/lib → lib}/interfaces/IDP.d.ts +0 -0
  9. package/lib/{dto → interfaces}/IDP.js +0 -0
  10. package/lib/interfaces/Mail.d.ts +29 -0
  11. package/lib/interfaces/Mail.js +8 -0
  12. package/lib/service/Auditor.d.ts +22 -0
  13. package/lib/service/Auditor.js +61 -0
  14. package/{src/lib/service/Auditor.d.ts → lib/service/AuditorInternal.d.ts} +1 -15
  15. package/{src/lib/service/Auditor.js → lib/service/AuditorInternal.js} +6 -42
  16. package/lib/service/IDP.d.ts +7 -1
  17. package/lib/service/IDP.js +10 -0
  18. package/lib/service/Mailer.d.ts +13 -0
  19. package/lib/{Axios.js → service/Mailer.js} +19 -8
  20. package/lib/service/MailerInternal.d.ts +32 -0
  21. package/lib/service/MailerInternal.js +64 -0
  22. package/package.json +3 -2
  23. package/lib/Axios.d.ts +0 -5
  24. package/lib/common.d.ts +0 -9
  25. package/lib/common.js +0 -11
  26. package/lib/dto/IDP.d.ts +0 -14
  27. package/src/index.d.ts +0 -2
  28. package/src/index.js +0 -4
  29. package/src/lib/base.d.ts +0 -12
  30. package/src/lib/base.js +0 -8
  31. package/src/lib/dto/IDP.d.ts +0 -14
  32. package/src/lib/dto/IDP.js +0 -2
  33. package/src/lib/hcloud.d.ts +0 -11
  34. package/src/lib/hcloud.js +0 -27
  35. package/src/lib/interfaces/IDP.js +0 -2
  36. package/src/lib/service/High5.d.ts +0 -4
  37. package/src/lib/service/High5.js +0 -9
  38. package/src/lib/service/IDP.d.ts +0 -39
  39. package/src/lib/service/IDP.js +0 -84
package/lib/base.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  export interface Options {
2
2
  api: string;
3
+ auditor?: {
4
+ queue?: {
5
+ executionInterval?: number;
6
+ };
7
+ };
3
8
  }
4
9
  export default abstract class Base {
5
10
  protected opts: Options;
package/lib/hcloud.d.ts CHANGED
@@ -1,9 +1,13 @@
1
1
  import base, { Options } from "./base";
2
2
  import IDPService from "./service/IDP";
3
+ import AuditorService from "./service/Auditor";
3
4
  import High5Service from "./service/High5";
5
+ import MailerService from "./service/Mailer";
4
6
  export default class hcloud extends base {
5
- IDP: IDPService;
7
+ Auditor: AuditorService;
6
8
  High5: High5Service;
9
+ IDP: IDPService;
10
+ Mailer: MailerService;
7
11
  constructor(opts: Options);
8
- setAuthToken(token: string): void;
12
+ setAuthToken(token: string): hcloud;
9
13
  }
package/lib/hcloud.js CHANGED
@@ -2,19 +2,28 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const base_1 = require("./base");
4
4
  const IDP_1 = require("./service/IDP");
5
+ const Auditor_1 = require("./service/Auditor");
5
6
  const High5_1 = require("./service/High5");
7
+ const Mailer_1 = require("./service/Mailer");
6
8
  const axios_1 = require("axios");
9
+ const package_json_1 = require("../package.json");
7
10
  // tslint:disable-next-line
8
11
  class hcloud extends base_1.default {
9
12
  constructor(opts) {
10
13
  super(opts);
11
- this.IDP = new IDP_1.default(this.opts);
14
+ this.Auditor = new Auditor_1.default(this.opts);
12
15
  this.High5 = new High5_1.default(this.opts);
16
+ this.IDP = new IDP_1.default(this.opts);
17
+ this.Mailer = new Mailer_1.default(this.opts);
18
+ axios_1.default.defaults.headers.common = {
19
+ "User-Agent": "hcloud-sdk-js/v" + package_json_1.version,
20
+ };
13
21
  }
14
22
  setAuthToken(token) {
15
- axios_1.default.defaults.headers.common = {
23
+ axios_1.default.defaults.headers.common = Object.assign(axios_1.default.defaults.headers.common, {
16
24
  Authorization: token,
17
- };
25
+ });
26
+ return this;
18
27
  }
19
28
  }
20
29
  exports.default = hcloud;
@@ -6,7 +6,9 @@ export declare enum Level {
6
6
  }
7
7
  export declare enum Origin {
8
8
  IDP = "idp",
9
- High5 = "high5"
9
+ High5 = "high5",
10
+ Auditor = "auditor",
11
+ Mailer = "mailer"
10
12
  }
11
13
  export declare enum Event {
12
14
  Login = "login",
@@ -15,10 +17,12 @@ export declare enum Event {
15
17
  Organization = "organization",
16
18
  App = "app",
17
19
  Event = "event",
18
- Stream = "stream"
20
+ Stream = "stream",
21
+ Mail = "mail"
19
22
  }
20
23
  export declare enum Type {
21
24
  Read = "read",
25
+ Write = "write",
22
26
  Create = "create",
23
27
  Update = "update",
24
28
  Delete = "delete",
@@ -26,7 +30,9 @@ export declare enum Type {
26
30
  Connect = "connect",
27
31
  Disconnect = "disconnect",
28
32
  Add = "add",
29
- Remove = "remove"
33
+ Remove = "remove",
34
+ Send = "send",
35
+ Receive = "receive"
30
36
  }
31
37
  export interface AuditLog {
32
38
  level: Level;
@@ -12,6 +12,8 @@ var Origin;
12
12
  (function (Origin) {
13
13
  Origin["IDP"] = "idp";
14
14
  Origin["High5"] = "high5";
15
+ Origin["Auditor"] = "auditor";
16
+ Origin["Mailer"] = "mailer";
15
17
  })(Origin = exports.Origin || (exports.Origin = {}));
16
18
  var Event;
17
19
  (function (Event) {
@@ -22,10 +24,12 @@ var Event;
22
24
  Event["App"] = "app";
23
25
  Event["Event"] = "event";
24
26
  Event["Stream"] = "stream";
27
+ Event["Mail"] = "mail";
25
28
  })(Event = exports.Event || (exports.Event = {}));
26
29
  var Type;
27
30
  (function (Type) {
28
31
  Type["Read"] = "read";
32
+ Type["Write"] = "write";
29
33
  Type["Create"] = "create";
30
34
  Type["Update"] = "update";
31
35
  Type["Delete"] = "delete";
@@ -34,4 +38,6 @@ var Type;
34
38
  Type["Disconnect"] = "disconnect";
35
39
  Type["Add"] = "add";
36
40
  Type["Remove"] = "remove";
41
+ Type["Send"] = "send";
42
+ Type["Receive"] = "receive";
37
43
  })(Type = exports.Type || (exports.Type = {}));
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,29 @@
1
+ export declare enum Template {
2
+ REGISTER = "register",
3
+ RESET_PASSWORD = "reset_password"
4
+ }
5
+ export interface Mail {
6
+ recipients: string[];
7
+ subject: string;
8
+ }
9
+ export interface MailReplacement {
10
+ key: string;
11
+ value: string;
12
+ }
13
+ export interface TemplateMail extends Mail {
14
+ template: Template;
15
+ replacements: MailReplacement[];
16
+ }
17
+ /**
18
+ * @param html base64 encoded html string
19
+ */
20
+ export interface HtmlMail extends Mail {
21
+ html: string;
22
+ }
23
+ /**
24
+ * @param html base64 encoded html string
25
+ */
26
+ export interface MustacheMail extends Mail {
27
+ html: string;
28
+ replacements: MailReplacement[];
29
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Template = void 0;
4
+ var Template;
5
+ (function (Template) {
6
+ Template["REGISTER"] = "register";
7
+ Template["RESET_PASSWORD"] = "reset_password";
8
+ })(Template = exports.Template || (exports.Template = {}));
@@ -0,0 +1,22 @@
1
+ import base, { Options } from "../base";
2
+ import { AuditLog } from "../interfaces/Auditor";
3
+ import { Version } from "../interfaces/Global";
4
+ import { AuditorInternal } from "./AuditorInternal";
5
+ export default class Auditor extends base {
6
+ internal: AuditorInternal;
7
+ constructor(opts: Options);
8
+ /**
9
+ * Version requests the endpoint version
10
+ * @returns Version object
11
+ */
12
+ version: () => Promise<Version>;
13
+ /**
14
+ * GetAuditLog requests logs from
15
+ * @param organizationId an optional organization ID to receive audit logs for
16
+ * @param limit an opitional response limit (1-1000; dafaults to 500)
17
+ * @param page an opitional page to skip certain results (page * limit; defaults to 0)
18
+ * @returns User object
19
+ */
20
+ getAuditLogs: (organizationId: string | null, limit: number | null, page: number | null) => Promise<AuditLog[]>;
21
+ private getEndpoint;
22
+ }
@@ -0,0 +1,61 @@
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 base_1 = require("../base");
13
+ const axios_1 = require("axios");
14
+ const AuditorInternal_1 = require("./AuditorInternal");
15
+ class Auditor extends base_1.default {
16
+ constructor(opts) {
17
+ super(opts);
18
+ /**
19
+ * Version requests the endpoint version
20
+ * @returns Version object
21
+ */
22
+ this.version = () => __awaiter(this, void 0, void 0, function* () {
23
+ const resp = yield axios_1.default.get(this.getEndpoint("/v1/version"), {}).catch((err) => {
24
+ throw err;
25
+ });
26
+ return resp.data;
27
+ });
28
+ /**
29
+ * GetAuditLog requests logs from
30
+ * @param organizationId an optional organization ID to receive audit logs for
31
+ * @param limit an opitional response limit (1-1000; dafaults to 500)
32
+ * @param page an opitional page to skip certain results (page * limit; defaults to 0)
33
+ * @returns User object
34
+ */
35
+ this.getAuditLogs = (organizationId, limit, page) => __awaiter(this, void 0, void 0, function* () {
36
+ const parameters = [];
37
+ let url = "";
38
+ if (organizationId !== null) {
39
+ parameters.push("organization=" + organizationId);
40
+ }
41
+ if (limit !== null) {
42
+ parameters.push("limit=" + limit);
43
+ }
44
+ if (page !== null) {
45
+ parameters.push("page=" + page);
46
+ }
47
+ if (parameters.length > 0) {
48
+ url = "?" + parameters.join("&");
49
+ }
50
+ const resp = yield axios_1.default.get(this.getEndpoint("/v1/logs") + url, {}).catch((err) => {
51
+ throw err;
52
+ });
53
+ return resp.data;
54
+ });
55
+ this.internal = new AuditorInternal_1.AuditorInternal(opts);
56
+ }
57
+ getEndpoint(endpoint) {
58
+ return `${this.opts.api}/api/auditor${endpoint}`;
59
+ }
60
+ }
61
+ exports.default = Auditor;
@@ -1,23 +1,9 @@
1
1
  import base from "../base";
2
2
  import { AuditLog } from "../interfaces/Auditor";
3
- import { Version } from "../interfaces/Global";
4
- export default class Auditor extends base {
3
+ export declare class AuditorInternal extends base {
5
4
  private queueExecutionInterval;
6
5
  private logQueue;
7
6
  private logQueueTimer;
8
- /**
9
- * Version requests the endpoint version
10
- * @returns Version object
11
- */
12
- version: () => Promise<Version>;
13
- /**
14
- * GetAuditLog requests logs from
15
- * @param organizationId an optional organization ID to receive audit logs for
16
- * @param limit an opitional response limit (1-1000; dafaults to 500)
17
- * @param page an opitional page to skip certain results (page * limit; defaults to 0)
18
- * @returns User object
19
- */
20
- getAuditLogs: (organizationId: string | null, limit: number | null, page: number | null) => Promise<AuditLog[]>;
21
7
  /**
22
8
  * AddAuditLogs adds log entries
23
9
  *
@@ -9,51 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- const base_1 = require("../base");
12
+ exports.AuditorInternal = void 0;
13
13
  const axios_1 = require("axios");
14
- class Auditor extends base_1.default {
14
+ const base_1 = require("../base");
15
+ class AuditorInternal extends base_1.default {
15
16
  constructor() {
16
17
  var _a, _b;
17
18
  super(...arguments);
18
19
  this.queueExecutionInterval = ((_b = (_a = this.opts.auditor) === null || _a === void 0 ? void 0 : _a.queue) === null || _b === void 0 ? void 0 : _b.executionInterval) || 500;
19
20
  this.logQueue = [];
20
- /**
21
- * Version requests the endpoint version
22
- * @returns Version object
23
- */
24
- this.version = () => __awaiter(this, void 0, void 0, function* () {
25
- const resp = yield axios_1.default.get(this.getEndpoint("/v1/version"), {}).catch((err) => {
26
- throw err;
27
- });
28
- return resp.data;
29
- });
30
- /**
31
- * GetAuditLog requests logs from
32
- * @param organizationId an optional organization ID to receive audit logs for
33
- * @param limit an opitional response limit (1-1000; dafaults to 500)
34
- * @param page an opitional page to skip certain results (page * limit; defaults to 0)
35
- * @returns User object
36
- */
37
- this.getAuditLogs = (organizationId, limit, page) => __awaiter(this, void 0, void 0, function* () {
38
- const parameters = [];
39
- let url = "";
40
- if (organizationId !== null) {
41
- parameters.push("organization=" + organizationId);
42
- }
43
- if (limit !== null) {
44
- parameters.push("limit=" + limit);
45
- }
46
- if (page !== null) {
47
- parameters.push("page=" + page);
48
- }
49
- if (parameters.length > 0) {
50
- url = "?" + parameters.join("&");
51
- }
52
- const resp = yield axios_1.default.get(this.getEndpoint("/v1/logs") + url, {}).catch((err) => {
53
- throw err;
54
- });
55
- return resp.data;
56
- });
57
21
  /**
58
22
  * AddAuditLogs adds log entries
59
23
  *
@@ -64,7 +28,7 @@ class Auditor extends base_1.default {
64
28
  * @returns AuditLog array
65
29
  */
66
30
  this.addAuditLogs = (logs) => __awaiter(this, void 0, void 0, function* () {
67
- const resp = yield axios_1.default.post(this.getEndpoint("/logs"), logs).catch((err) => {
31
+ const resp = yield axios_1.default.post(this.getEndpoint("/v1/logs"), logs).catch((err) => {
68
32
  throw err;
69
33
  });
70
34
  return resp.data;
@@ -95,7 +59,7 @@ class Auditor extends base_1.default {
95
59
  }
96
60
  }
97
61
  getEndpoint(endpoint) {
98
- return `${this.opts.api}/api/auditor${endpoint}`;
62
+ return `${this.opts.api}/api/auditor/internal${endpoint}`;
99
63
  }
100
64
  }
101
- exports.default = Auditor;
65
+ exports.AuditorInternal = AuditorInternal;
@@ -1,6 +1,12 @@
1
1
  import base from "../base";
2
- import { Token, User } from "../dto/IDP";
2
+ import { Token, User } from "../interfaces/IDP";
3
+ import { Version } from "../interfaces/Global";
3
4
  export default class IDP extends base {
5
+ /**
6
+ * Version requests the endpoint version
7
+ * @returns Version object
8
+ */
9
+ version: () => Promise<Version>;
4
10
  /**
5
11
  * Authorize validates a token
6
12
  * @param token
@@ -14,6 +14,16 @@ const axios_1 = require("axios");
14
14
  class IDP extends base_1.default {
15
15
  constructor() {
16
16
  super(...arguments);
17
+ /**
18
+ * Version requests the endpoint version
19
+ * @returns Version object
20
+ */
21
+ this.version = () => __awaiter(this, void 0, void 0, function* () {
22
+ const resp = yield axios_1.default.get(this.getEndpoint("/v1/version"), {}).catch((err) => {
23
+ throw err;
24
+ });
25
+ return resp.data;
26
+ });
17
27
  /**
18
28
  * Authorize validates a token
19
29
  * @param token
@@ -0,0 +1,13 @@
1
+ import base, { Options } from "../base";
2
+ import { Version } from "../interfaces/Global";
3
+ import MailerInternal from "./MailerInternal";
4
+ export default class Mailer extends base {
5
+ interal: MailerInternal;
6
+ constructor(opts: Options);
7
+ /**
8
+ * Version requests the endpoint version
9
+ * @returns Version object
10
+ */
11
+ version: () => Promise<Version>;
12
+ private getEndpoint;
13
+ }
@@ -9,15 +9,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ const base_1 = require("../base");
12
13
  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, {});
14
+ const MailerInternal_1 = require("./MailerInternal");
15
+ class Mailer extends base_1.default {
16
+ constructor(opts) {
17
+ super(opts);
18
+ /**
19
+ * Version requests the endpoint version
20
+ * @returns Version object
21
+ */
22
+ this.version = () => __awaiter(this, void 0, void 0, function* () {
23
+ const resp = yield axios_1.default.get(this.getEndpoint("/v1/version"), {}).catch((err) => {
24
+ throw err;
25
+ });
26
+ return resp.data;
20
27
  });
28
+ this.interal = new MailerInternal_1.default(opts);
29
+ }
30
+ getEndpoint(endpoint) {
31
+ return `${this.opts.api}/api/mailer${endpoint}`;
21
32
  }
22
33
  }
23
- exports.default = AxiosService;
34
+ exports.default = Mailer;
@@ -0,0 +1,32 @@
1
+ import base from "../base";
2
+ import { HtmlMail, MustacheMail, TemplateMail } from "../interfaces/Mail";
3
+ export default class MailerInternal extends base {
4
+ /**
5
+ * sendMailMustache sends a new mail based on a mustache html body
6
+ *
7
+ * THIS ENDPOINT WORKS INTERNALLY ONLY
8
+ *
9
+ * CAN ONLY BE USED FROM BACKENDS WITHIN THE hcloud DEPLOYMENT AS THE ENDPOINT IS NOT PUBLICLY EXPOSED
10
+ * @param mail TemplateMail
11
+ */
12
+ sendMailMustache: (mail: MustacheMail) => Promise<void>;
13
+ /**
14
+ * sendMailHtml sends a new mail based on a html body
15
+ *
16
+ * THIS ENDPOINT WORKS INTERNALLY ONLY
17
+ *
18
+ * CAN ONLY BE USED FROM BACKENDS WITHIN THE hcloud DEPLOYMENT AS THE ENDPOINT IS NOT PUBLICLY EXPOSED
19
+ * @param mail TemplateMail
20
+ */
21
+ sendMailHtml: (mail: HtmlMail) => Promise<void>;
22
+ /**
23
+ * sendMailTemplate sends a new mail based on an existing template
24
+ *
25
+ * THIS ENDPOINT WORKS INTERNALLY ONLY
26
+ *
27
+ * CAN ONLY BE USED FROM BACKENDS WITHIN THE hcloud DEPLOYMENT AS THE ENDPOINT IS NOT PUBLICLY EXPOSED
28
+ * @param mail TemplateMail
29
+ */
30
+ sendMailTemplate: (mail: TemplateMail) => Promise<void>;
31
+ private getEndpoint;
32
+ }
@@ -0,0 +1,64 @@
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 base_1 = require("../base");
13
+ const axios_1 = require("axios");
14
+ class MailerInternal extends base_1.default {
15
+ constructor() {
16
+ super(...arguments);
17
+ /**
18
+ * sendMailMustache sends a new mail based on a mustache html body
19
+ *
20
+ * THIS ENDPOINT WORKS INTERNALLY ONLY
21
+ *
22
+ * CAN ONLY BE USED FROM BACKENDS WITHIN THE hcloud DEPLOYMENT AS THE ENDPOINT IS NOT PUBLICLY EXPOSED
23
+ * @param mail TemplateMail
24
+ */
25
+ this.sendMailMustache = (mail) => __awaiter(this, void 0, void 0, function* () {
26
+ const resp = yield axios_1.default.post(this.getEndpoint("/v1/send/mustache"), mail).catch((err) => {
27
+ throw err;
28
+ });
29
+ return resp.data;
30
+ });
31
+ /**
32
+ * sendMailHtml sends a new mail based on a html body
33
+ *
34
+ * THIS ENDPOINT WORKS INTERNALLY ONLY
35
+ *
36
+ * CAN ONLY BE USED FROM BACKENDS WITHIN THE hcloud DEPLOYMENT AS THE ENDPOINT IS NOT PUBLICLY EXPOSED
37
+ * @param mail TemplateMail
38
+ */
39
+ this.sendMailHtml = (mail) => __awaiter(this, void 0, void 0, function* () {
40
+ const resp = yield axios_1.default.post(this.getEndpoint("/v1/send/html"), mail).catch((err) => {
41
+ throw err;
42
+ });
43
+ return resp.data;
44
+ });
45
+ /**
46
+ * sendMailTemplate sends a new mail based on an existing template
47
+ *
48
+ * THIS ENDPOINT WORKS INTERNALLY ONLY
49
+ *
50
+ * CAN ONLY BE USED FROM BACKENDS WITHIN THE hcloud DEPLOYMENT AS THE ENDPOINT IS NOT PUBLICLY EXPOSED
51
+ * @param mail TemplateMail
52
+ */
53
+ this.sendMailTemplate = (mail) => __awaiter(this, void 0, void 0, function* () {
54
+ const resp = yield axios_1.default.post(this.getEndpoint("/v1/send/template"), mail).catch((err) => {
55
+ throw err;
56
+ });
57
+ return resp.data;
58
+ });
59
+ }
60
+ getEndpoint(endpoint) {
61
+ return `${this.opts.api}/api/mailer/internal${endpoint}`;
62
+ }
63
+ }
64
+ exports.default = MailerInternal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hcloud-sdk",
3
- "version": "0.0.13",
3
+ "version": "0.0.16",
4
4
  "description": "hcloud platform sdk",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -46,5 +46,6 @@
46
46
  "doc:dev": "vuepress dev _docs/src",
47
47
  "doc:export": "vuepress export _docs/src",
48
48
  "build": "tsc"
49
- }
49
+ },
50
+ "readme": "# hcloud-sdk\n[![MIT License](https://img.shields.io/badge/license-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Latest Release](https://img.shields.io/npm/v/hcloud-sdk.svg)](https://www.npmjs.com/package/hcloud-sdk)\n"
50
51
  }
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/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;
package/lib/dto/IDP.d.ts DELETED
@@ -1,14 +0,0 @@
1
- export interface User {
2
- _id: string;
3
- name: string;
4
- email: string;
5
- company: string;
6
- }
7
- export interface Token {
8
- token: string;
9
- }
10
- export interface ErrorMessage {
11
- code: string;
12
- error: string;
13
- message: string;
14
- }
package/src/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import hcloud from "./lib/hcloud";
2
- export default hcloud;
package/src/index.js DELETED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const hcloud_1 = require("./lib/hcloud");
4
- exports.default = hcloud_1.default;
package/src/lib/base.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export interface Options {
2
- api: string;
3
- auditor?: {
4
- queue?: {
5
- executionInterval?: number;
6
- };
7
- };
8
- }
9
- export default abstract class Base {
10
- protected opts: Options;
11
- constructor(opts: Options);
12
- }
package/src/lib/base.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class Base {
4
- constructor(opts) {
5
- this.opts = opts;
6
- }
7
- }
8
- exports.default = Base;
@@ -1,14 +0,0 @@
1
- export interface User {
2
- _id: string;
3
- name: string;
4
- email: string;
5
- company: string;
6
- }
7
- export interface Token {
8
- token: string;
9
- }
10
- export interface ErrorMessage {
11
- code: string;
12
- error: string;
13
- message: string;
14
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +0,0 @@
1
- import base, { Options } from "./base";
2
- import IDPService from "./service/IDP";
3
- import AuditorService from "./service/Auditor";
4
- import High5Service from "./service/High5";
5
- export default class hcloud extends base {
6
- Auditor: AuditorService;
7
- High5: High5Service;
8
- IDP: IDPService;
9
- constructor(opts: Options);
10
- setAuthToken(token: string): hcloud;
11
- }
package/src/lib/hcloud.js DELETED
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const base_1 = require("./base");
4
- const IDP_1 = require("./service/IDP");
5
- const Auditor_1 = require("./service/Auditor");
6
- const High5_1 = require("./service/High5");
7
- const axios_1 = require("axios");
8
- const package_json_1 = require("../../package.json");
9
- // tslint:disable-next-line
10
- class hcloud extends base_1.default {
11
- constructor(opts) {
12
- super(opts);
13
- this.Auditor = new Auditor_1.default(this.opts);
14
- this.High5 = new High5_1.default(this.opts);
15
- this.IDP = new IDP_1.default(this.opts);
16
- axios_1.default.defaults.headers.common = {
17
- "User-Agent": "hcloud-sdk-js/v" + package_json_1.version,
18
- };
19
- }
20
- setAuthToken(token) {
21
- axios_1.default.defaults.headers.common = Object.assign(axios_1.default.defaults.headers.common, {
22
- Authorization: token,
23
- });
24
- return this;
25
- }
26
- }
27
- exports.default = hcloud;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- import base from "../base";
2
- export default class High5 extends base {
3
- private getEndpoint;
4
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const base_1 = require("../base");
4
- class High5 extends base_1.default {
5
- getEndpoint(endpoint) {
6
- return `${this.opts.api}/api/high5${endpoint}`;
7
- }
8
- }
9
- exports.default = High5;
@@ -1,39 +0,0 @@
1
- import base from "../base";
2
- import { Token, User } from "../interfaces/IDP";
3
- import { Version } from "../interfaces/Global";
4
- export default class IDP extends base {
5
- /**
6
- * Version requests the endpoint version
7
- * @returns Version object
8
- */
9
- version: () => Promise<Version>;
10
- /**
11
- * Authorize validates a token
12
- * @param token
13
- * @returns User object
14
- */
15
- authorize: () => Promise<User>;
16
- /**
17
- * Register against the identity provider
18
- * @param name
19
- * @param email
20
- * @param password
21
- * @returns Bearer Token
22
- */
23
- register: (name: string, email: string, password: string) => Promise<User>;
24
- /**
25
- * Authenticate against the identity provider with a given email and password.
26
- * @param email
27
- * @param password
28
- * @returns Bearer Token
29
- */
30
- authenticate: (email: string, password: string) => Promise<Token>;
31
- /**
32
- * authenticateReturnUser against the identity provider with a given email and password.
33
- * @param email
34
- * @param password
35
- * @returns User object
36
- */
37
- authenticateReturnUser: (email: string, password: string) => Promise<User>;
38
- private getEndpoint;
39
- }
@@ -1,84 +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 base_1 = require("../base");
13
- const axios_1 = require("axios");
14
- class IDP extends base_1.default {
15
- constructor() {
16
- super(...arguments);
17
- /**
18
- * Version requests the endpoint version
19
- * @returns Version object
20
- */
21
- this.version = () => __awaiter(this, void 0, void 0, function* () {
22
- const resp = yield axios_1.default.get(this.getEndpoint("/v1/version"), {}).catch((err) => {
23
- throw err;
24
- });
25
- return resp.data;
26
- });
27
- /**
28
- * Authorize validates a token
29
- * @param token
30
- * @returns User object
31
- */
32
- this.authorize = () => __awaiter(this, void 0, void 0, function* () {
33
- const resp = yield axios_1.default.get(this.getEndpoint("/v1/authorize"), {}).catch((err) => {
34
- throw err;
35
- });
36
- return resp.data;
37
- });
38
- /**
39
- * Register against the identity provider
40
- * @param name
41
- * @param email
42
- * @param password
43
- * @returns Bearer Token
44
- */
45
- this.register = (name, email, password) => __awaiter(this, void 0, void 0, function* () {
46
- const resp = yield axios_1.default
47
- .post(this.getEndpoint("/v1/registration"), { name: name, email: email, password: password })
48
- .catch((err) => {
49
- throw err;
50
- });
51
- return resp.data;
52
- });
53
- /**
54
- * Authenticate against the identity provider with a given email and password.
55
- * @param email
56
- * @param password
57
- * @returns Bearer Token
58
- */
59
- this.authenticate = (email, password) => __awaiter(this, void 0, void 0, function* () {
60
- const resp = yield axios_1.default.post(this.getEndpoint("/v1/authenticate"), { email: email, password: password }).catch((err) => {
61
- throw err;
62
- });
63
- // tslint-disable: no-string-literal
64
- const token = { token: resp.headers.authorization };
65
- return token;
66
- });
67
- /**
68
- * authenticateReturnUser against the identity provider with a given email and password.
69
- * @param email
70
- * @param password
71
- * @returns User object
72
- */
73
- this.authenticateReturnUser = (email, password) => __awaiter(this, void 0, void 0, function* () {
74
- const resp = yield axios_1.default.post(this.getEndpoint("/v1/authenticate"), { email: email, password: password }).catch((err) => {
75
- throw err;
76
- });
77
- return resp.data;
78
- });
79
- }
80
- getEndpoint(endpoint) {
81
- return `${this.opts.api}/api/account${endpoint}`;
82
- }
83
- }
84
- exports.default = IDP;