updown.io 3.4.6 → 3.5.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # updown.io [![npm version](https://img.shields.io/npm/v/updown.io.svg)](https://www.npmjs.com/package/updown.io)
2
2
 
3
- An [updown.io](https://updown.io) API client. For a documentation on the API see https://updown.io/api/.
3
+ An [updown.io](https://updown.io) API client. For a documentation on the API see [the updown.io API reference](https://updown.io/api/).
4
4
 
5
5
  ### Installation
6
6
 
@@ -0,0 +1,26 @@
1
+ export declare const Endpoint: {
2
+ API: string;
3
+ CHECKS: string;
4
+ Checks: {
5
+ check(token: string): string;
6
+ downtimes(token: string): string;
7
+ metrics(token: string): string;
8
+ };
9
+ checks(token?: string): string;
10
+ DOWNTIMES: string;
11
+ IPS: string;
12
+ IPV4: string;
13
+ IPV6: string;
14
+ METRICS: string;
15
+ NODES: string;
16
+ Nodes: {
17
+ ips(): string;
18
+ ipv4(): string;
19
+ ipv6(): string;
20
+ };
21
+ nodes(): string;
22
+ RECIPIENTS: string;
23
+ recipients(id?: string): string;
24
+ STATUS_PAGES: string;
25
+ statusPages(token?: string): string;
26
+ };
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Endpoint = void 0;
4
+ const encode = encodeURIComponent;
5
+ exports.Endpoint = {
6
+ API: 'api',
7
+ CHECKS: 'checks',
8
+ Checks: {
9
+ check(token) {
10
+ return `/${exports.Endpoint.API}/${exports.Endpoint.CHECKS}/${encode(token)}/`;
11
+ },
12
+ downtimes(token) {
13
+ return `/${exports.Endpoint.API}/${exports.Endpoint.CHECKS}/${encode(token)}/${exports.Endpoint.DOWNTIMES}/`;
14
+ },
15
+ metrics(token) {
16
+ return `/${exports.Endpoint.API}/${exports.Endpoint.CHECKS}/${encode(token)}/${exports.Endpoint.METRICS}/`;
17
+ },
18
+ },
19
+ checks(token) {
20
+ return `/${exports.Endpoint.API}/${exports.Endpoint.CHECKS}/${token ? `${encode(token)}/` : ''}`;
21
+ },
22
+ DOWNTIMES: 'downtimes',
23
+ IPS: 'ips',
24
+ IPV4: 'ipv4',
25
+ IPV6: 'ipv6',
26
+ METRICS: 'metrics',
27
+ NODES: 'nodes',
28
+ Nodes: {
29
+ ips() {
30
+ return `/${exports.Endpoint.API}/${exports.Endpoint.NODES}/${exports.Endpoint.IPS}/`;
31
+ },
32
+ ipv4() {
33
+ return `/${exports.Endpoint.API}/${exports.Endpoint.NODES}/${exports.Endpoint.IPV4}/`;
34
+ },
35
+ ipv6() {
36
+ return `/${exports.Endpoint.API}/${exports.Endpoint.NODES}/${exports.Endpoint.IPV6}/`;
37
+ },
38
+ },
39
+ nodes() {
40
+ return `/${exports.Endpoint.API}/${exports.Endpoint.NODES}/`;
41
+ },
42
+ RECIPIENTS: 'recipients',
43
+ recipients(id) {
44
+ return `/${exports.Endpoint.API}/${exports.Endpoint.RECIPIENTS}/${id ? `${encode(id)}/` : ''}`;
45
+ },
46
+ STATUS_PAGES: 'status_pages',
47
+ statusPages(token) {
48
+ return `/${exports.Endpoint.API}/${exports.Endpoint.STATUS_PAGES}/${token ? `${encode(token)}/` : ''}`;
49
+ },
50
+ };
@@ -0,0 +1,12 @@
1
+ import type { API, ClientOptions } from './interfaces';
2
+ export declare class UpdownIO {
3
+ api: API;
4
+ private readonly apiClient;
5
+ constructor(apiKey?: string);
6
+ constructor(options?: ClientOptions);
7
+ /**
8
+ * Set a new API URL.
9
+ * @param newURL The new API url
10
+ */
11
+ setApiUrl(newURL: string): void;
12
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdownIO = void 0;
4
+ const api_client_1 = require("@ffflorian/api-client");
5
+ const api_1 = require("./api");
6
+ class UpdownIO {
7
+ constructor(options) {
8
+ var _a;
9
+ if (typeof options === 'string') {
10
+ options = { apiKey: options };
11
+ }
12
+ this.apiClient = new api_client_1.APIClient((_a = options === null || options === void 0 ? void 0 : options.apiUrl) !== null && _a !== void 0 ? _a : 'https://updown.io', {
13
+ headers: Object.assign({}, ((options === null || options === void 0 ? void 0 : options.apiKey) && { 'X-API-KEY': options.apiKey })),
14
+ });
15
+ this.api = {
16
+ checks: new api_1.ChecksAPI(this.apiClient),
17
+ nodes: new api_1.NodesAPI(this.apiClient),
18
+ recipients: new api_1.RecipientsAPI(this.apiClient),
19
+ statusPages: new api_1.StatusPagesAPI(this.apiClient),
20
+ };
21
+ }
22
+ /**
23
+ * Set a new API URL.
24
+ * @param newURL The new API url
25
+ */
26
+ setApiUrl(newURL) {
27
+ this.api.checks.setApiUrl(newURL);
28
+ this.api.nodes.setApiUrl(newURL);
29
+ this.api.recipients.setApiUrl(newURL);
30
+ this.api.statusPages.setApiUrl(newURL);
31
+ }
32
+ }
33
+ exports.UpdownIO = UpdownIO;
@@ -0,0 +1,56 @@
1
+ import type { APIClient } from '@ffflorian/api-client';
2
+ import type { Check, CheckOptions, Deleted, Downtime, Metrics, MetricsOptions } from '../interfaces';
3
+ export declare class ChecksAPI {
4
+ private readonly apiClient;
5
+ constructor(apiClient: APIClient);
6
+ private static mapCheckOptions;
7
+ /**
8
+ * Add a new check.
9
+ * @param url The URL you want to monitor.
10
+ * @param options Further check adding options
11
+ */
12
+ addCheck(url: string, options?: CheckOptions): Promise<Check>;
13
+ /**
14
+ * Delete a check.
15
+ * @param token The check unique token
16
+ */
17
+ deleteCheck(token: string): Promise<Deleted>;
18
+ /**
19
+ * Show a single check.
20
+ * @param token The check unique token
21
+ * @param metrics Include performance metrics (last hour only)
22
+ */
23
+ getCheck(token: string, metrics?: boolean): Promise<Check>;
24
+ /** List all your checks. */
25
+ getChecks(): Promise<Check[]>;
26
+ /**
27
+ * Get all the downtimes of a check.
28
+ *
29
+ * @param token The check unique token
30
+ * @param page The page to fetch (100 per page)
31
+ */
32
+ getDowntimes(token: string, page?: number): Promise<Downtime[]>;
33
+ /**
34
+ * Get detailed metrics about the check.
35
+ *
36
+ * Statistic are aggregated per hour which means you can't get more
37
+ * precise results than this. For example all requests performed
38
+ * between 5:00 and 5:59 will be reported at 5:00 in this API.
39
+ * The time range needs to be at least one hour to get data.
40
+ *
41
+ * @param token The check unique token
42
+ * @param options Metrics options
43
+ */
44
+ getMetrics(token: string, options?: MetricsOptions): Promise<Metrics>;
45
+ /**
46
+ * Set a new API URL.
47
+ * @param newURL The new API url
48
+ */
49
+ setApiUrl(newURL: string): void;
50
+ /**
51
+ * Update a check.
52
+ * @param token The check unique token
53
+ * @param options Further check updating options
54
+ */
55
+ updateCheck(token: string, options?: CheckOptions): Promise<Check>;
56
+ }
@@ -0,0 +1,131 @@
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
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.ChecksAPI = void 0;
24
+ const Endpoints_1 = require("../Endpoints");
25
+ class ChecksAPI {
26
+ constructor(apiClient) {
27
+ this.apiClient = apiClient;
28
+ }
29
+ static mapCheckOptions(options) {
30
+ if (!options) {
31
+ return {};
32
+ }
33
+ const { customHeaders, disabledLocations } = options, rest = __rest(options, ["customHeaders", "disabledLocations"]);
34
+ return Object.assign(Object.assign(Object.assign({}, rest), (customHeaders && { custom_headers: customHeaders })), (disabledLocations && { disabled_locations: disabledLocations }));
35
+ }
36
+ /**
37
+ * Add a new check.
38
+ * @param url The URL you want to monitor.
39
+ * @param options Further check adding options
40
+ */
41
+ addCheck(url, options) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const endpoint = Endpoints_1.Endpoint.checks();
44
+ const params = Object.assign({ url }, ChecksAPI.mapCheckOptions(options));
45
+ const { data } = yield this.apiClient.post(endpoint, params);
46
+ return data;
47
+ });
48
+ }
49
+ /**
50
+ * Delete a check.
51
+ * @param token The check unique token
52
+ */
53
+ deleteCheck(token) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const endpoint = Endpoints_1.Endpoint.checks(token);
56
+ const { data } = yield this.apiClient.delete(endpoint);
57
+ return data;
58
+ });
59
+ }
60
+ /**
61
+ * Show a single check.
62
+ * @param token The check unique token
63
+ * @param metrics Include performance metrics (last hour only)
64
+ */
65
+ getCheck(token, metrics) {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ const endpoint = Endpoints_1.Endpoint.Checks.check(token);
68
+ const { data } = yield this.apiClient.get(endpoint, { params: { metrics } });
69
+ return data;
70
+ });
71
+ }
72
+ /** List all your checks. */
73
+ getChecks() {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ const endpoint = Endpoints_1.Endpoint.checks();
76
+ const { data } = yield this.apiClient.get(endpoint);
77
+ return data;
78
+ });
79
+ }
80
+ /**
81
+ * Get all the downtimes of a check.
82
+ *
83
+ * @param token The check unique token
84
+ * @param page The page to fetch (100 per page)
85
+ */
86
+ getDowntimes(token, page) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ const endpoint = Endpoints_1.Endpoint.Checks.downtimes(token);
89
+ const { data } = yield this.apiClient.get(endpoint, { params: { page } });
90
+ return data;
91
+ });
92
+ }
93
+ /**
94
+ * Get detailed metrics about the check.
95
+ *
96
+ * Statistic are aggregated per hour which means you can't get more
97
+ * precise results than this. For example all requests performed
98
+ * between 5:00 and 5:59 will be reported at 5:00 in this API.
99
+ * The time range needs to be at least one hour to get data.
100
+ *
101
+ * @param token The check unique token
102
+ * @param options Metrics options
103
+ */
104
+ getMetrics(token, options) {
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ const endpoint = Endpoints_1.Endpoint.Checks.metrics(token);
107
+ const { data } = yield this.apiClient.get(endpoint, { params: options });
108
+ return data;
109
+ });
110
+ }
111
+ /**
112
+ * Set a new API URL.
113
+ * @param newURL The new API url
114
+ */
115
+ setApiUrl(newURL) {
116
+ this.apiClient.setBaseURL(newURL);
117
+ }
118
+ /**
119
+ * Update a check.
120
+ * @param token The check unique token
121
+ * @param options Further check updating options
122
+ */
123
+ updateCheck(token, options) {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ const endpoint = Endpoints_1.Endpoint.checks(token);
126
+ const { data } = yield this.apiClient.put(endpoint, ChecksAPI.mapCheckOptions(options));
127
+ return data;
128
+ });
129
+ }
130
+ }
131
+ exports.ChecksAPI = ChecksAPI;
@@ -0,0 +1,19 @@
1
+ import type { APIClient } from '@ffflorian/api-client';
2
+ import type { Nodes } from '../interfaces';
3
+ export declare class NodesAPI {
4
+ private readonly apiClient;
5
+ constructor(apiClient: APIClient);
6
+ /** List all updown.io monitoring nodes IPv4 addresses. */
7
+ getIps(): Promise<string[]>;
8
+ /** List all updown.io monitoring nodes IPv4 addresses. */
9
+ getIpv4Nodes(): Promise<string[]>;
10
+ /** List all updown.io monitoring nodes IPv6 addresses. */
11
+ getIpv6Nodes(): Promise<string[]>;
12
+ /** List all updown.io monitoring nodes. */
13
+ getNodes(): Promise<Nodes>;
14
+ /**
15
+ * Set a new API URL.
16
+ * @param newURL The new API url
17
+ */
18
+ setApiUrl(newURL: string): void;
19
+ }
@@ -0,0 +1,58 @@
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
+ exports.NodesAPI = void 0;
13
+ const Endpoints_1 = require("../Endpoints");
14
+ class NodesAPI {
15
+ constructor(apiClient) {
16
+ this.apiClient = apiClient;
17
+ }
18
+ /** List all updown.io monitoring nodes IPv4 addresses. */
19
+ getIps() {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const endpoint = Endpoints_1.Endpoint.Nodes.ips();
22
+ const { data } = yield this.apiClient.get(endpoint);
23
+ return data;
24
+ });
25
+ }
26
+ /** List all updown.io monitoring nodes IPv4 addresses. */
27
+ getIpv4Nodes() {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const endpoint = Endpoints_1.Endpoint.Nodes.ipv4();
30
+ const { data } = yield this.apiClient.get(endpoint);
31
+ return data;
32
+ });
33
+ }
34
+ /** List all updown.io monitoring nodes IPv6 addresses. */
35
+ getIpv6Nodes() {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const endpoint = Endpoints_1.Endpoint.Nodes.ipv6();
38
+ const { data } = yield this.apiClient.get(endpoint);
39
+ return data;
40
+ });
41
+ }
42
+ /** List all updown.io monitoring nodes. */
43
+ getNodes() {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const endpoint = Endpoints_1.Endpoint.nodes();
46
+ const { data } = yield this.apiClient.get(endpoint);
47
+ return data;
48
+ });
49
+ }
50
+ /**
51
+ * Set a new API URL.
52
+ * @param newURL The new API url
53
+ */
54
+ setApiUrl(newURL) {
55
+ this.apiClient.setBaseURL(newURL);
56
+ }
57
+ }
58
+ exports.NodesAPI = NodesAPI;
@@ -0,0 +1,17 @@
1
+ import type { APIClient } from '@ffflorian/api-client';
2
+ import type { Deleted, Recipient, RecipientOptions } from '../interfaces';
3
+ export declare class RecipientsAPI {
4
+ private readonly apiClient;
5
+ constructor(apiClient: APIClient);
6
+ /** Add a new recipient. */
7
+ addRecipient(options: RecipientOptions): Promise<Recipient>;
8
+ /** Delete a recipient. */
9
+ deleteRecipient(id: string): Promise<Deleted>;
10
+ /** List all possible alert recipients/channels on your account. */
11
+ getRecipients(): Promise<Recipient[]>;
12
+ /**
13
+ * Set a new API URL.
14
+ * @param newURL The new API url
15
+ */
16
+ setApiUrl(newURL: string): void;
17
+ }
@@ -0,0 +1,50 @@
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
+ exports.RecipientsAPI = void 0;
13
+ const Endpoints_1 = require("../Endpoints");
14
+ class RecipientsAPI {
15
+ constructor(apiClient) {
16
+ this.apiClient = apiClient;
17
+ }
18
+ /** Add a new recipient. */
19
+ addRecipient(options) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const endpoint = Endpoints_1.Endpoint.recipients();
22
+ const { data } = yield this.apiClient.post(endpoint, options);
23
+ return data;
24
+ });
25
+ }
26
+ /** Delete a recipient. */
27
+ deleteRecipient(id) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const endpoint = Endpoints_1.Endpoint.recipients(id);
30
+ const { data } = yield this.apiClient.delete(endpoint);
31
+ return data;
32
+ });
33
+ }
34
+ /** List all possible alert recipients/channels on your account. */
35
+ getRecipients() {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const endpoint = Endpoints_1.Endpoint.recipients();
38
+ const { data } = yield this.apiClient.get(endpoint);
39
+ return data;
40
+ });
41
+ }
42
+ /**
43
+ * Set a new API URL.
44
+ * @param newURL The new API url
45
+ */
46
+ setApiUrl(newURL) {
47
+ this.apiClient.setBaseURL(newURL);
48
+ }
49
+ }
50
+ exports.RecipientsAPI = RecipientsAPI;
@@ -0,0 +1,19 @@
1
+ import type { APIClient } from '@ffflorian/api-client';
2
+ import type { Deleted, StatusPage, StatusPageOptions } from '../interfaces';
3
+ export declare class StatusPagesAPI {
4
+ private readonly apiClient;
5
+ constructor(apiClient: APIClient);
6
+ /** Add a new status page. */
7
+ addStatusPage(options: StatusPageOptions): Promise<StatusPage>;
8
+ /** Delete a status page. */
9
+ deleteStatusPage(token: string): Promise<Deleted>;
10
+ /** List all status pages. */
11
+ getStatusPages(): Promise<StatusPage[]>;
12
+ /**
13
+ * Set a new API URL.
14
+ * @param newURL The new API url
15
+ */
16
+ setApiUrl(newURL: string): void;
17
+ /** Update a status page. */
18
+ updateStatusPage(token: string, options: StatusPageOptions): Promise<StatusPage>;
19
+ }
@@ -0,0 +1,58 @@
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
+ exports.StatusPagesAPI = void 0;
13
+ const Endpoints_1 = require("../Endpoints");
14
+ class StatusPagesAPI {
15
+ constructor(apiClient) {
16
+ this.apiClient = apiClient;
17
+ }
18
+ /** Add a new status page. */
19
+ addStatusPage(options) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const endpoint = Endpoints_1.Endpoint.statusPages();
22
+ const { data } = yield this.apiClient.post(endpoint, options);
23
+ return data;
24
+ });
25
+ }
26
+ /** Delete a status page. */
27
+ deleteStatusPage(token) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const endpoint = Endpoints_1.Endpoint.statusPages(token);
30
+ const { data } = yield this.apiClient.delete(endpoint);
31
+ return data;
32
+ });
33
+ }
34
+ /** List all status pages. */
35
+ getStatusPages() {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const endpoint = Endpoints_1.Endpoint.statusPages();
38
+ const { data } = yield this.apiClient.get(endpoint);
39
+ return data;
40
+ });
41
+ }
42
+ /**
43
+ * Set a new API URL.
44
+ * @param newURL The new API url
45
+ */
46
+ setApiUrl(newURL) {
47
+ this.apiClient.setBaseURL(newURL);
48
+ }
49
+ /** Update a status page. */
50
+ updateStatusPage(token, options) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ const endpoint = Endpoints_1.Endpoint.statusPages(token);
53
+ const { data } = yield this.apiClient.put(endpoint, options);
54
+ return data;
55
+ });
56
+ }
57
+ }
58
+ exports.StatusPagesAPI = StatusPagesAPI;
@@ -0,0 +1,4 @@
1
+ export * from './ChecksAPI';
2
+ export * from './NodesAPI';
3
+ export * from './RecipientsAPI';
4
+ export * from './StatusPagesAPI';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ChecksAPI"), exports);
18
+ __exportStar(require("./NodesAPI"), exports);
19
+ __exportStar(require("./RecipientsAPI"), exports);
20
+ __exportStar(require("./StatusPagesAPI"), exports);
@@ -0,0 +1,3 @@
1
+ export * from './api/';
2
+ export * from './interfaces/';
3
+ export * from './UpdownIO';
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./api/"), exports);
18
+ __exportStar(require("./interfaces/"), exports);
19
+ __exportStar(require("./UpdownIO"), exports);
@@ -0,0 +1,7 @@
1
+ import { ChecksAPI, NodesAPI, RecipientsAPI, StatusPagesAPI } from '../api/';
2
+ export interface API {
3
+ checks: ChecksAPI;
4
+ nodes: NodesAPI;
5
+ recipients: RecipientsAPI;
6
+ statusPages: StatusPagesAPI;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,40 @@
1
+ import type { CustomHeaders } from './Options';
2
+ export interface Check {
3
+ alias: string;
4
+ apdex_t: number;
5
+ created_at: string;
6
+ custom_headers: CustomHeaders;
7
+ disabled_locations: string[];
8
+ domain?: {
9
+ expires_at: string;
10
+ remaining_days: number;
11
+ source: string;
12
+ tested_at: string;
13
+ };
14
+ down: boolean;
15
+ down_since: null | string;
16
+ enabled: boolean;
17
+ error: null | string;
18
+ favicon_url: null | string;
19
+ http_body: string;
20
+ http_verb: string;
21
+ last_check_at: string;
22
+ last_status: null | number;
23
+ mute_until: null | string;
24
+ next_check_at: string;
25
+ period: number;
26
+ published: boolean;
27
+ recipients: string[];
28
+ ssl: {
29
+ error: null | string;
30
+ expires_at?: string;
31
+ tested_at: string;
32
+ valid: boolean;
33
+ };
34
+ string_match: string;
35
+ token: string;
36
+ type: string;
37
+ up_since: null | string;
38
+ uptime: number;
39
+ url: string;
40
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export interface Deleted {
2
+ deleted: boolean;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ export interface Downtime {
2
+ details_url: string;
3
+ duration: number;
4
+ ended_at: null | string;
5
+ error: string;
6
+ id: string;
7
+ partial: boolean;
8
+ started_at: string;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,26 @@
1
+ export interface Metrics {
2
+ apdex: number;
3
+ requests: {
4
+ by_response_time: {
5
+ under1000: number;
6
+ under125: number;
7
+ under2000: number;
8
+ under250: number;
9
+ under4000: number;
10
+ under500: number;
11
+ };
12
+ failures: number;
13
+ samples: number;
14
+ satisfied: number;
15
+ tolerated: number;
16
+ };
17
+ timings: {
18
+ connection: number;
19
+ handshake: number;
20
+ namelookup: number;
21
+ redirect: number;
22
+ response: number;
23
+ total: number;
24
+ };
25
+ uptime?: number;
26
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ export interface Nodes {
2
+ [name: string]: {
3
+ city: string;
4
+ country: string;
5
+ country_code: string;
6
+ ip: string;
7
+ ip6: string;
8
+ lat: number;
9
+ lng: number;
10
+ };
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,95 @@
1
+ export interface CheckOptions {
2
+ /** Human readable name */
3
+ alias?: string;
4
+ /** APDEX threshold in seconds (0.125, 0.25, 0.5, 1.0 or 2.0) */
5
+ apdex_t?: number;
6
+ custom_headers?: CustomHeaders;
7
+ /** The HTTP headers you want in updown requests. Ex: custom_headers[X-Api-Key]=xxxxxxxxx */
8
+ customHeaders?: CustomHeaders;
9
+ disabled_locations?: string[];
10
+ /** Disabled monitoring locations. It's an array of abbreviated location names. Can be any of these: ["lan", "mia", "bhs", "gra", "fra", "sin", "tok", "syd"]. Ex: disabled_locations[]=lan&disabled_locations[]=syd */
11
+ disabledLocations?: string[];
12
+ /** Is the check enabled (true or false) */
13
+ enabled?: boolean;
14
+ /** The HTTP body sent alongside the request */
15
+ http_body?: string;
16
+ /** The HTTP verb used to perform the request */
17
+ http_verb?: HttpVerb;
18
+ /** Mute notifications until given time, accepts a time, 'recovery' or 'forever' */
19
+ mute_until?: string;
20
+ /** Interval in seconds (15, 30, 60, 120, 300, 600, 1800 or 3600) */
21
+ period?: number;
22
+ /** Shall the status page be public (true or false) */
23
+ published?: boolean;
24
+ /** Selected alert recipients */
25
+ recipients?: string[];
26
+ /** Search for this string in the page */
27
+ string_match?: string;
28
+ /** The type of check to create */
29
+ type?: CheckType;
30
+ }
31
+ export type CheckType = 'http' | 'https' | 'icmp' | 'pulse' | 'tcp' | 'tcps';
32
+ export interface ClientOptions {
33
+ apiKey: string;
34
+ apiUrl?: string;
35
+ }
36
+ export interface CustomHeaders {
37
+ [key: string]: boolean | number | string;
38
+ }
39
+ export type HttpMethod = 'delete' | 'get' | 'post' | 'put';
40
+ export type HttpVerb = 'DELETE' | 'GET/HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT';
41
+ export type MetricsGroup = 'host' | 'time';
42
+ export interface MetricsOptions {
43
+ /** Start time, default to 1 month ago */
44
+ from?: string;
45
+ /** Group data by 'time' (hour) or 'host' (location) */
46
+ group: MetricsGroup;
47
+ /** End time, default to now */
48
+ to?: string;
49
+ }
50
+ export interface RecipientOptions {
51
+ /** Optional user-friendly label for supported recipient types */
52
+ name?: string;
53
+ /** Initial state on all existing checks */
54
+ selected?: boolean;
55
+ /** Type of recipient */
56
+ type: RecipientType;
57
+ /** Recipient value (email, phone or URL) */
58
+ value: string;
59
+ }
60
+ export type RecipientType = 'email' | 'msteams' | 'slack_compatible' | 'sms' | 'webhook';
61
+ export interface RequestOptions {
62
+ alias?: string;
63
+ apdex_t?: number;
64
+ 'api-key'?: string;
65
+ custom_headers?: CustomHeaders;
66
+ disabled_locations?: string[];
67
+ enabled?: boolean;
68
+ from?: string;
69
+ group?: MetricsGroup;
70
+ http_body?: string;
71
+ http_verb?: HttpVerb;
72
+ metrics?: boolean;
73
+ mute_until?: string;
74
+ page?: number;
75
+ period?: number;
76
+ published?: boolean;
77
+ recipients?: string[];
78
+ string_match?: string;
79
+ to?: string;
80
+ type?: CheckType;
81
+ url?: string;
82
+ }
83
+ export interface StatusPageOptions {
84
+ /** Access key for protected pages */
85
+ access_key?: string;
86
+ /** List of checks to show in the page */
87
+ checks?: string[];
88
+ /** Description text */
89
+ description?: string;
90
+ /** Name of the status page */
91
+ name?: string;
92
+ /** Page visibility */
93
+ visibility?: StatusPageVisibility;
94
+ }
95
+ export type StatusPageVisibility = 'private' | 'protected' | 'public';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import type { RecipientType } from './Options';
2
+ export interface Recipient {
3
+ id: string;
4
+ immutable?: boolean;
5
+ name?: string;
6
+ type: RecipientType;
7
+ value?: string;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ import type { StatusPageVisibility } from './Options';
2
+ export interface StatusPage {
3
+ access_key: null | string;
4
+ checks: string[];
5
+ description: null | string;
6
+ name: string;
7
+ token: string;
8
+ url: string;
9
+ visibility: StatusPageVisibility;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ export * from './API';
2
+ export * from './Check';
3
+ export * from './Deleted';
4
+ export * from './Downtime';
5
+ export * from './Metrics';
6
+ export * from './Nodes';
7
+ export * from './Options';
8
+ export * from './Recipient';
9
+ export * from './StatusPage';
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./API"), exports);
18
+ __exportStar(require("./Check"), exports);
19
+ __exportStar(require("./Deleted"), exports);
20
+ __exportStar(require("./Downtime"), exports);
21
+ __exportStar(require("./Metrics"), exports);
22
+ __exportStar(require("./Nodes"), exports);
23
+ __exportStar(require("./Options"), exports);
24
+ __exportStar(require("./Recipient"), exports);
25
+ __exportStar(require("./StatusPage"), exports);
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "author": "Florian Imdahl <git@ffflorian.de>",
3
3
  "dependencies": {
4
- "@ffflorian/api-client": "2.5.0"
4
+ "@ffflorian/api-client": "2.5.1"
5
5
  },
6
6
  "description": "An updown.io API client",
7
7
  "devDependencies": {
8
8
  "@types/node": "~24",
9
+ "nock": "14.0.12",
9
10
  "rimraf": "6.1.3",
10
- "typedoc": "0.28.18",
11
- "typescript": "6.0.2"
11
+ "typedoc": "0.28.19",
12
+ "typescript": "6.0.3",
13
+ "vitest": "4.1.4"
12
14
  },
13
15
  "engines": {
14
16
  "node": ">= 21"
@@ -29,11 +31,12 @@
29
31
  "readme": "https://github.com/ffflorian/api-clients#readme",
30
32
  "repository": "https://github.com/ffflorian/api-clients.git",
31
33
  "scripts": {
34
+ "build": "yarn build:ts",
32
35
  "build:ts": "tsc -p tsconfig.build.json",
33
36
  "build:docs": "typedoc --tsconfig tsconfig.build.json --options ../../typedoc.json --out ../../docs/packages/updown.io src/index.ts",
34
37
  "clean": "rimraf dist",
35
- "dist": "yarn clean && yarn build:ts",
36
- "test": "exit 0"
38
+ "dist": "yarn clean && yarn build",
39
+ "test": "vitest"
37
40
  },
38
- "version": "3.4.6"
41
+ "version": "3.5.0"
39
42
  }