btrz-api-client 8.32.0 → 8.33.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/lib/client-standalone-min.js +3 -3
- package/lib/client.js +2 -0
- package/lib/endpoints/coltrane/healthcheck.js +35 -0
- package/lib/endpoints/coltrane/info.js +35 -0
- package/lib/endpoints/coltrane/paths.js +17 -13
- package/package.json +1 -1
- package/src/client.js +2 -0
- package/src/endpoints/coltrane/healthcheck.js +28 -0
- package/src/endpoints/coltrane/info.js +28 -0
- package/src/endpoints/coltrane/paths.js +17 -13
- package/test/endpoints/coltrane/healthcheck.test.js +13 -0
- package/test/endpoints/coltrane/info.test.js +13 -0
package/lib/client.js
CHANGED
|
@@ -187,6 +187,8 @@ function createColtrane(_ref3) {
|
|
|
187
187
|
|
|
188
188
|
return {
|
|
189
189
|
docs: require("./endpoints/coltrane/docs.js")({ client: client }),
|
|
190
|
+
healthcheck: require("./endpoints/coltrane/healthcheck.js")({ client: client }),
|
|
191
|
+
info: require("./endpoints/coltrane/info.js")({ client: client }),
|
|
190
192
|
paths: require("./endpoints/coltrane/paths.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
191
193
|
mergedFareTables: require("./endpoints/coltrane/merged-fare-tables.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
192
194
|
__test: {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Factory for Coltrane healthcheck API (btrz-api-coltrane) — liveness probe.
|
|
5
|
+
* @param {Object} deps
|
|
6
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
7
|
+
* @returns {{ get: function }}
|
|
8
|
+
*/
|
|
9
|
+
function healthcheckFactory(_ref) {
|
|
10
|
+
var client = _ref.client;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* GET /healthcheck — liveness probe. Returns 200 with empty body when the service is running. No authentication required.
|
|
14
|
+
* @param {Object} [opts]
|
|
15
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
16
|
+
* @returns {Promise<import("axios").AxiosResponse<{ data: {} }>>}
|
|
17
|
+
* @throws {import("axios").AxiosError} 500 Service unhealthy or shutting down
|
|
18
|
+
*/
|
|
19
|
+
function get() {
|
|
20
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
21
|
+
headers = _ref2.headers;
|
|
22
|
+
|
|
23
|
+
return client({
|
|
24
|
+
url: "/healthcheck",
|
|
25
|
+
method: "get",
|
|
26
|
+
headers: headers || {}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
get: get
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = healthcheckFactory;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable max-len */
|
|
4
|
+
/**
|
|
5
|
+
* Factory for Coltrane info API (btrz-api-coltrane) — service and dependency status.
|
|
6
|
+
* @param {Object} deps
|
|
7
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
8
|
+
* @returns {{ get: function }}
|
|
9
|
+
*/
|
|
10
|
+
function infoFactory(_ref) {
|
|
11
|
+
var client = _ref.client;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* GET /info — get Coltrane API service status and dependency health. No authentication required.
|
|
15
|
+
* @param {Object} [opts]
|
|
16
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
17
|
+
* @returns {Promise<import("axios").AxiosResponse<{ data: { status: number, services: Array<{ name: string, status: number }>, build?: string, instanceId?: string, commit?: string } }>>}
|
|
18
|
+
* @throws {import("axios").AxiosError} 500 Internal server error or dependency check failure
|
|
19
|
+
*/
|
|
20
|
+
function get() {
|
|
21
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
22
|
+
headers = _ref2.headers;
|
|
23
|
+
|
|
24
|
+
return client({
|
|
25
|
+
url: "/info",
|
|
26
|
+
headers: headers || {}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
get: get
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = infoFactory;
|
|
@@ -5,15 +5,16 @@ var _require = require("./../endpoints_helpers.js"),
|
|
|
5
5
|
authorizationHeaders = _require.authorizationHeaders;
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Query params for GET /paths (btrz-api-coltrane).
|
|
8
|
+
* Query params for GET /paths (btrz-api-coltrane). All except metrics and preferredAlgorithm are required by the API.
|
|
9
9
|
* @typedef {Object} ColtranePathsListQuery
|
|
10
|
-
* @property {string} [providerId] - Account ID of the travel provider (
|
|
11
|
-
* @property {string} [productId] - Product ID belonging to the provider (
|
|
12
|
-
* @property {string} [originId] - Origin station
|
|
13
|
-
* @property {string} [destinationId] - Destination station
|
|
14
|
-
* @property {string} [departureFromDate] - Start of
|
|
15
|
-
* @property {string} [departureToDate] - End of
|
|
16
|
-
* @property {string} [
|
|
10
|
+
* @property {string} [providerId] - Account ID of the travel provider (24-char hex)
|
|
11
|
+
* @property {string} [productId] - Product ID belonging to the provider (24-char hex)
|
|
12
|
+
* @property {string} [originId] - Origin station ID (24-char hex); must differ from destinationId
|
|
13
|
+
* @property {string} [destinationId] - Destination station ID (24-char hex)
|
|
14
|
+
* @property {string} [departureFromDate] - Start of departure interval; ISO 8601 (e.g. 2021-10-07T17:30:00.000-0400)
|
|
15
|
+
* @property {string} [departureToDate] - End of departure interval; ISO 8601; interval max 25h, must be after departureFromDate
|
|
16
|
+
* @property {string} [preferredAlgorithm] - "search_algorithm_fast" or "search_algorithm_exhaustive"
|
|
17
|
+
* @property {string|boolean} [metrics] - If true, response includes metrics object (debugging)
|
|
17
18
|
*/
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -30,12 +31,15 @@ function coltraneFactory(_ref) {
|
|
|
30
31
|
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
|
-
* GET /paths
|
|
34
|
+
* GET /paths — search for travel paths between two stations in a departure time interval.
|
|
34
35
|
* @param {Object} opts
|
|
35
|
-
* @param {string} [opts.token] - API key
|
|
36
|
-
* @param {ColtranePathsListQuery} [opts.query] - Query params
|
|
37
|
-
* @param {Object} [opts.headers] - Optional headers
|
|
38
|
-
* @returns {Promise<import("axios").AxiosResponse>}
|
|
36
|
+
* @param {string} [opts.token] - API key (X-API-KEY)
|
|
37
|
+
* @param {ColtranePathsListQuery} [opts.query] - Query params; providerId, productId, originId, destinationId, departureFromDate, departureToDate required
|
|
38
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
39
|
+
* @returns {Promise<import("axios").AxiosResponse<{ data: { paths: Array<{ segments: Array<{ scheduleId: string, manifestDay: string, fromLegIndex: number, toLegIndex: number }> }>, metrics?: object } }>>}
|
|
40
|
+
* @throws {import("axios").AxiosError} 400 INVALID_QUERY_PARAMETERS (invalid params, originId=destinationId, interval > 25h, or invalid preferredAlgorithm)
|
|
41
|
+
* @throws {import("axios").AxiosError} 401 Unauthorized
|
|
42
|
+
* @throws {import("axios").AxiosError} 500 Internal server error
|
|
39
43
|
*/
|
|
40
44
|
function all(_ref2) {
|
|
41
45
|
var token = _ref2.token,
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -160,6 +160,8 @@ function createColtrane({baseURL, headers, timeout, overrideFn, internalAuthToke
|
|
|
160
160
|
|
|
161
161
|
return {
|
|
162
162
|
docs: require("./endpoints/coltrane/docs.js")({client}),
|
|
163
|
+
healthcheck: require("./endpoints/coltrane/healthcheck.js")({client}),
|
|
164
|
+
info: require("./endpoints/coltrane/info.js")({client}),
|
|
163
165
|
paths: require("./endpoints/coltrane/paths.js")({client, internalAuthTokenProvider}),
|
|
164
166
|
mergedFareTables: require("./endpoints/coltrane/merged-fare-tables.js")({client, internalAuthTokenProvider}),
|
|
165
167
|
__test: {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory for Coltrane healthcheck API (btrz-api-coltrane) — liveness probe.
|
|
3
|
+
* @param {Object} deps
|
|
4
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
5
|
+
* @returns {{ get: function }}
|
|
6
|
+
*/
|
|
7
|
+
function healthcheckFactory({client}) {
|
|
8
|
+
/**
|
|
9
|
+
* GET /healthcheck — liveness probe. Returns 200 with empty body when the service is running. No authentication required.
|
|
10
|
+
* @param {Object} [opts]
|
|
11
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
12
|
+
* @returns {Promise<import("axios").AxiosResponse<{ data: {} }>>}
|
|
13
|
+
* @throws {import("axios").AxiosError} 500 Service unhealthy or shutting down
|
|
14
|
+
*/
|
|
15
|
+
function get({headers} = {}) {
|
|
16
|
+
return client({
|
|
17
|
+
url: "/healthcheck",
|
|
18
|
+
method: "get",
|
|
19
|
+
headers: headers || {}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
get
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = healthcheckFactory;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
/**
|
|
3
|
+
* Factory for Coltrane info API (btrz-api-coltrane) — service and dependency status.
|
|
4
|
+
* @param {Object} deps
|
|
5
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
6
|
+
* @returns {{ get: function }}
|
|
7
|
+
*/
|
|
8
|
+
function infoFactory({client}) {
|
|
9
|
+
/**
|
|
10
|
+
* GET /info — get Coltrane API service status and dependency health. No authentication required.
|
|
11
|
+
* @param {Object} [opts]
|
|
12
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
13
|
+
* @returns {Promise<import("axios").AxiosResponse<{ data: { status: number, services: Array<{ name: string, status: number }>, build?: string, instanceId?: string, commit?: string } }>>}
|
|
14
|
+
* @throws {import("axios").AxiosError} 500 Internal server error or dependency check failure
|
|
15
|
+
*/
|
|
16
|
+
function get({headers} = {}) {
|
|
17
|
+
return client({
|
|
18
|
+
url: "/info",
|
|
19
|
+
headers: headers || {}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
get
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = infoFactory;
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
const {authorizationHeaders} = require("./../endpoints_helpers.js");
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Query params for GET /paths (btrz-api-coltrane).
|
|
5
|
+
* Query params for GET /paths (btrz-api-coltrane). All except metrics and preferredAlgorithm are required by the API.
|
|
6
6
|
* @typedef {Object} ColtranePathsListQuery
|
|
7
|
-
* @property {string} [providerId] - Account ID of the travel provider (
|
|
8
|
-
* @property {string} [productId] - Product ID belonging to the provider (
|
|
9
|
-
* @property {string} [originId] - Origin station
|
|
10
|
-
* @property {string} [destinationId] - Destination station
|
|
11
|
-
* @property {string} [departureFromDate] - Start of
|
|
12
|
-
* @property {string} [departureToDate] - End of
|
|
13
|
-
* @property {string} [
|
|
7
|
+
* @property {string} [providerId] - Account ID of the travel provider (24-char hex)
|
|
8
|
+
* @property {string} [productId] - Product ID belonging to the provider (24-char hex)
|
|
9
|
+
* @property {string} [originId] - Origin station ID (24-char hex); must differ from destinationId
|
|
10
|
+
* @property {string} [destinationId] - Destination station ID (24-char hex)
|
|
11
|
+
* @property {string} [departureFromDate] - Start of departure interval; ISO 8601 (e.g. 2021-10-07T17:30:00.000-0400)
|
|
12
|
+
* @property {string} [departureToDate] - End of departure interval; ISO 8601; interval max 25h, must be after departureFromDate
|
|
13
|
+
* @property {string} [preferredAlgorithm] - "search_algorithm_fast" or "search_algorithm_exhaustive"
|
|
14
|
+
* @property {string|boolean} [metrics] - If true, response includes metrics object (debugging)
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -22,12 +23,15 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
|
|
|
22
23
|
*/
|
|
23
24
|
function coltraneFactory({client, internalAuthTokenProvider}) {
|
|
24
25
|
/**
|
|
25
|
-
* GET /paths
|
|
26
|
+
* GET /paths — search for travel paths between two stations in a departure time interval.
|
|
26
27
|
* @param {Object} opts
|
|
27
|
-
* @param {string} [opts.token] - API key
|
|
28
|
-
* @param {ColtranePathsListQuery} [opts.query] - Query params
|
|
29
|
-
* @param {Object} [opts.headers] - Optional headers
|
|
30
|
-
* @returns {Promise<import("axios").AxiosResponse>}
|
|
28
|
+
* @param {string} [opts.token] - API key (X-API-KEY)
|
|
29
|
+
* @param {ColtranePathsListQuery} [opts.query] - Query params; providerId, productId, originId, destinationId, departureFromDate, departureToDate required
|
|
30
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
31
|
+
* @returns {Promise<import("axios").AxiosResponse<{ data: { paths: Array<{ segments: Array<{ scheduleId: string, manifestDay: string, fromLegIndex: number, toLegIndex: number }> }>, metrics?: object } }>>}
|
|
32
|
+
* @throws {import("axios").AxiosError} 400 INVALID_QUERY_PARAMETERS (invalid params, originId=destinationId, interval > 25h, or invalid preferredAlgorithm)
|
|
33
|
+
* @throws {import("axios").AxiosError} 401 Unauthorized
|
|
34
|
+
* @throws {import("axios").AxiosError} 500 Internal server error
|
|
31
35
|
*/
|
|
32
36
|
function all({token, query = {}, headers}) {
|
|
33
37
|
return client({
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const {axiosMock, expectRequest} = require("../../test-helpers.js");
|
|
2
|
+
const api = require("../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
3
|
+
|
|
4
|
+
describe("coltrane/healthcheck", () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
axiosMock.reset();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("should get healthcheck (liveness)", () => {
|
|
10
|
+
axiosMock.onGet("/healthcheck").reply(expectRequest({statusCode: 200, withoutApiKey: true}));
|
|
11
|
+
return api.coltrane.healthcheck.get();
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const {axiosMock, expectRequest} = require("../../test-helpers.js");
|
|
2
|
+
const api = require("../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
3
|
+
|
|
4
|
+
describe("coltrane/info", () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
axiosMock.reset();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("should get Coltrane service info (status and dependencies)", () => {
|
|
10
|
+
axiosMock.onGet("/info").reply(expectRequest({statusCode: 200, withoutApiKey: true}));
|
|
11
|
+
return api.coltrane.info.get();
|
|
12
|
+
});
|
|
13
|
+
});
|