@fern-api/postman 0.0.2
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 +271 -0
- package/dist/cjs/BaseClient.d.ts +39 -0
- package/dist/cjs/BaseClient.js +62 -0
- package/dist/cjs/Client.d.ts +25 -0
- package/dist/cjs/Client.js +103 -0
- package/dist/cjs/api/index.d.ts +1 -0
- package/dist/cjs/api/index.js +17 -0
- package/dist/cjs/api/resources/collection/client/Client.d.ts +43 -0
- package/dist/cjs/api/resources/collection/client/Client.js +165 -0
- package/dist/cjs/api/resources/collection/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/collection/client/index.js +17 -0
- package/dist/cjs/api/resources/collection/client/requests/PublishCollectionRequest.d.ts +12 -0
- package/dist/cjs/api/resources/collection/client/requests/PublishCollectionRequest.js +3 -0
- package/dist/cjs/api/resources/collection/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/collection/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/collection/errors/CollectionDoesNotExistError.d.ts +6 -0
- package/dist/cjs/api/resources/collection/errors/CollectionDoesNotExistError.js +54 -0
- package/dist/cjs/api/resources/collection/errors/index.d.ts +1 -0
- package/dist/cjs/api/resources/collection/errors/index.js +17 -0
- package/dist/cjs/api/resources/collection/index.d.ts +3 -0
- package/dist/cjs/api/resources/collection/index.js +19 -0
- package/dist/cjs/api/resources/collection/types/CollectionId.d.ts +4 -0
- package/dist/cjs/api/resources/collection/types/CollectionId.js +3 -0
- package/dist/cjs/api/resources/collection/types/CollectionStatusFailed.d.ts +3 -0
- package/dist/cjs/api/resources/collection/types/CollectionStatusFailed.js +3 -0
- package/dist/cjs/api/resources/collection/types/CollectionStatusPublished.d.ts +4 -0
- package/dist/cjs/api/resources/collection/types/CollectionStatusPublished.js +3 -0
- package/dist/cjs/api/resources/collection/types/CollectionStatusPublishing.d.ts +3 -0
- package/dist/cjs/api/resources/collection/types/CollectionStatusPublishing.js +3 -0
- package/dist/cjs/api/resources/collection/types/GetCollectionStatusResponse.d.ts +25 -0
- package/dist/cjs/api/resources/collection/types/GetCollectionStatusResponse.js +3 -0
- package/dist/cjs/api/resources/collection/types/TeamId.d.ts +4 -0
- package/dist/cjs/api/resources/collection/types/TeamId.js +3 -0
- package/dist/cjs/api/resources/collection/types/UserId.d.ts +4 -0
- package/dist/cjs/api/resources/collection/types/UserId.js +3 -0
- package/dist/cjs/api/resources/collection/types/index.d.ts +7 -0
- package/dist/cjs/api/resources/collection/types/index.js +23 -0
- package/dist/cjs/api/resources/index.d.ts +4 -0
- package/dist/cjs/api/resources/index.js +43 -0
- package/dist/cjs/auth/BearerAuthProvider.d.ts +20 -0
- package/dist/cjs/auth/BearerAuthProvider.js +79 -0
- package/dist/cjs/auth/index.d.ts +1 -0
- package/dist/cjs/auth/index.js +5 -0
- package/dist/cjs/core/auth/AuthProvider.d.ts +7 -0
- package/dist/cjs/core/auth/AuthProvider.js +2 -0
- package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
- package/dist/cjs/core/auth/AuthRequest.js +2 -0
- package/dist/cjs/core/auth/BasicAuth.d.ts +8 -0
- package/dist/cjs/core/auth/BasicAuth.js +27 -0
- package/dist/cjs/core/auth/BearerToken.d.ts +7 -0
- package/dist/cjs/core/auth/BearerToken.js +16 -0
- package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +5 -0
- package/dist/cjs/core/auth/NoOpAuthProvider.js +9 -0
- package/dist/cjs/core/auth/index.d.ts +5 -0
- package/dist/cjs/core/auth/index.js +9 -0
- package/dist/cjs/core/base64.d.ts +2 -0
- package/dist/cjs/core/base64.js +26 -0
- package/dist/cjs/core/exports.d.ts +1 -0
- package/dist/cjs/core/exports.js +17 -0
- package/dist/cjs/core/fetcher/APIResponse.d.ts +20 -0
- package/dist/cjs/core/fetcher/APIResponse.js +2 -0
- package/dist/cjs/core/fetcher/BinaryResponse.d.ts +19 -0
- package/dist/cjs/core/fetcher/BinaryResponse.js +17 -0
- package/dist/cjs/core/fetcher/EndpointMetadata.d.ts +13 -0
- package/dist/cjs/core/fetcher/EndpointMetadata.js +2 -0
- package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +12 -0
- package/dist/cjs/core/fetcher/EndpointSupplier.js +22 -0
- package/dist/cjs/core/fetcher/Fetcher.d.ts +48 -0
- package/dist/cjs/core/fetcher/Fetcher.js +316 -0
- package/dist/cjs/core/fetcher/Headers.d.ts +2 -0
- package/dist/cjs/core/fetcher/Headers.js +84 -0
- package/dist/cjs/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/dist/cjs/core/fetcher/HttpResponsePromise.js +103 -0
- package/dist/cjs/core/fetcher/RawResponse.d.ts +29 -0
- package/dist/cjs/core/fetcher/RawResponse.js +44 -0
- package/dist/cjs/core/fetcher/Supplier.d.ts +4 -0
- package/dist/cjs/core/fetcher/Supplier.js +22 -0
- package/dist/cjs/core/fetcher/createRequestUrl.d.ts +1 -0
- package/dist/cjs/core/fetcher/createRequestUrl.js +8 -0
- package/dist/cjs/core/fetcher/getErrorResponseBody.d.ts +1 -0
- package/dist/cjs/core/fetcher/getErrorResponseBody.js +45 -0
- package/dist/cjs/core/fetcher/getFetchFn.d.ts +1 -0
- package/dist/cjs/core/fetcher/getFetchFn.js +17 -0
- package/dist/cjs/core/fetcher/getHeader.d.ts +1 -0
- package/dist/cjs/core/fetcher/getHeader.js +11 -0
- package/dist/cjs/core/fetcher/getRequestBody.d.ts +7 -0
- package/dist/cjs/core/fetcher/getRequestBody.js +27 -0
- package/dist/cjs/core/fetcher/getResponseBody.d.ts +1 -0
- package/dist/cjs/core/fetcher/getResponseBody.js +69 -0
- package/dist/cjs/core/fetcher/index.d.ts +11 -0
- package/dist/cjs/core/fetcher/index.js +17 -0
- package/dist/cjs/core/fetcher/makeRequest.d.ts +1 -0
- package/dist/cjs/core/fetcher/makeRequest.js +40 -0
- package/dist/cjs/core/fetcher/requestWithRetries.d.ts +1 -0
- package/dist/cjs/core/fetcher/requestWithRetries.js +67 -0
- package/dist/cjs/core/fetcher/signals.d.ts +5 -0
- package/dist/cjs/core/fetcher/signals.js +24 -0
- package/dist/cjs/core/headers.d.ts +2 -0
- package/dist/cjs/core/headers.js +31 -0
- package/dist/cjs/core/index.d.ts +6 -0
- package/dist/cjs/core/index.js +45 -0
- package/dist/cjs/core/json.d.ts +15 -0
- package/dist/cjs/core/json.js +24 -0
- package/dist/cjs/core/logging/exports.d.ts +18 -0
- package/dist/cjs/core/logging/exports.js +45 -0
- package/dist/cjs/core/logging/index.d.ts +1 -0
- package/dist/cjs/core/logging/index.js +17 -0
- package/dist/cjs/core/logging/logger.d.ts +126 -0
- package/dist/cjs/core/logging/logger.js +144 -0
- package/dist/cjs/core/runtime/index.d.ts +1 -0
- package/dist/cjs/core/runtime/index.js +5 -0
- package/dist/cjs/core/runtime/runtime.d.ts +9 -0
- package/dist/cjs/core/runtime/runtime.js +103 -0
- package/dist/cjs/core/url/encodePathParam.d.ts +1 -0
- package/dist/cjs/core/url/encodePathParam.js +21 -0
- package/dist/cjs/core/url/index.d.ts +3 -0
- package/dist/cjs/core/url/index.js +9 -0
- package/dist/cjs/core/url/join.d.ts +1 -0
- package/dist/cjs/core/url/join.js +68 -0
- package/dist/cjs/core/url/qs.d.ts +6 -0
- package/dist/cjs/core/url/qs.js +64 -0
- package/dist/cjs/environments.d.ts +5 -0
- package/dist/cjs/environments.js +8 -0
- package/dist/cjs/errors/FernPostmanError.d.ts +12 -0
- package/dist/cjs/errors/FernPostmanError.js +32 -0
- package/dist/cjs/errors/FernPostmanTimeoutError.d.ts +3 -0
- package/dist/cjs/errors/FernPostmanTimeoutError.js +15 -0
- package/dist/cjs/errors/handleNonStatusCodeError.d.ts +2 -0
- package/dist/cjs/errors/handleNonStatusCodeError.js +65 -0
- package/dist/cjs/errors/index.d.ts +2 -0
- package/dist/cjs/errors/index.js +7 -0
- package/dist/cjs/exports.d.ts +1 -0
- package/dist/cjs/exports.js +17 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +48 -0
- package/dist/cjs/version.d.ts +1 -0
- package/dist/cjs/version.js +4 -0
- package/dist/esm/BaseClient.d.mts +39 -0
- package/dist/esm/BaseClient.mjs +25 -0
- package/dist/esm/Client.d.mts +25 -0
- package/dist/esm/Client.mjs +66 -0
- package/dist/esm/api/index.d.mts +1 -0
- package/dist/esm/api/index.mjs +1 -0
- package/dist/esm/api/resources/collection/client/Client.d.mts +43 -0
- package/dist/esm/api/resources/collection/client/Client.mjs +128 -0
- package/dist/esm/api/resources/collection/client/index.d.mts +1 -0
- package/dist/esm/api/resources/collection/client/index.mjs +1 -0
- package/dist/esm/api/resources/collection/client/requests/PublishCollectionRequest.d.mts +12 -0
- package/dist/esm/api/resources/collection/client/requests/PublishCollectionRequest.mjs +2 -0
- package/dist/esm/api/resources/collection/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/collection/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/collection/errors/CollectionDoesNotExistError.d.mts +6 -0
- package/dist/esm/api/resources/collection/errors/CollectionDoesNotExistError.mjs +17 -0
- package/dist/esm/api/resources/collection/errors/index.d.mts +1 -0
- package/dist/esm/api/resources/collection/errors/index.mjs +1 -0
- package/dist/esm/api/resources/collection/index.d.mts +3 -0
- package/dist/esm/api/resources/collection/index.mjs +3 -0
- package/dist/esm/api/resources/collection/types/CollectionId.d.mts +4 -0
- package/dist/esm/api/resources/collection/types/CollectionId.mjs +2 -0
- package/dist/esm/api/resources/collection/types/CollectionStatusFailed.d.mts +3 -0
- package/dist/esm/api/resources/collection/types/CollectionStatusFailed.mjs +2 -0
- package/dist/esm/api/resources/collection/types/CollectionStatusPublished.d.mts +4 -0
- package/dist/esm/api/resources/collection/types/CollectionStatusPublished.mjs +2 -0
- package/dist/esm/api/resources/collection/types/CollectionStatusPublishing.d.mts +3 -0
- package/dist/esm/api/resources/collection/types/CollectionStatusPublishing.mjs +2 -0
- package/dist/esm/api/resources/collection/types/GetCollectionStatusResponse.d.mts +25 -0
- package/dist/esm/api/resources/collection/types/GetCollectionStatusResponse.mjs +2 -0
- package/dist/esm/api/resources/collection/types/TeamId.d.mts +4 -0
- package/dist/esm/api/resources/collection/types/TeamId.mjs +2 -0
- package/dist/esm/api/resources/collection/types/UserId.d.mts +4 -0
- package/dist/esm/api/resources/collection/types/UserId.mjs +2 -0
- package/dist/esm/api/resources/collection/types/index.d.mts +7 -0
- package/dist/esm/api/resources/collection/types/index.mjs +7 -0
- package/dist/esm/api/resources/index.d.mts +4 -0
- package/dist/esm/api/resources/index.mjs +4 -0
- package/dist/esm/auth/BearerAuthProvider.d.mts +20 -0
- package/dist/esm/auth/BearerAuthProvider.mjs +42 -0
- package/dist/esm/auth/index.d.mts +1 -0
- package/dist/esm/auth/index.mjs +1 -0
- package/dist/esm/core/auth/AuthProvider.d.mts +7 -0
- package/dist/esm/core/auth/AuthProvider.mjs +1 -0
- package/dist/esm/core/auth/AuthRequest.d.mts +9 -0
- package/dist/esm/core/auth/AuthRequest.mjs +1 -0
- package/dist/esm/core/auth/BasicAuth.d.mts +8 -0
- package/dist/esm/core/auth/BasicAuth.mjs +24 -0
- package/dist/esm/core/auth/BearerToken.d.mts +7 -0
- package/dist/esm/core/auth/BearerToken.mjs +13 -0
- package/dist/esm/core/auth/NoOpAuthProvider.d.mts +5 -0
- package/dist/esm/core/auth/NoOpAuthProvider.mjs +5 -0
- package/dist/esm/core/auth/index.d.mts +5 -0
- package/dist/esm/core/auth/index.mjs +3 -0
- package/dist/esm/core/base64.d.mts +2 -0
- package/dist/esm/core/base64.mjs +22 -0
- package/dist/esm/core/exports.d.mts +1 -0
- package/dist/esm/core/exports.mjs +1 -0
- package/dist/esm/core/fetcher/APIResponse.d.mts +20 -0
- package/dist/esm/core/fetcher/APIResponse.mjs +1 -0
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +19 -0
- package/dist/esm/core/fetcher/BinaryResponse.mjs +14 -0
- package/dist/esm/core/fetcher/EndpointMetadata.d.mts +13 -0
- package/dist/esm/core/fetcher/EndpointMetadata.mjs +1 -0
- package/dist/esm/core/fetcher/EndpointSupplier.d.mts +12 -0
- package/dist/esm/core/fetcher/EndpointSupplier.mjs +19 -0
- package/dist/esm/core/fetcher/Fetcher.d.mts +48 -0
- package/dist/esm/core/fetcher/Fetcher.mjs +312 -0
- package/dist/esm/core/fetcher/Headers.d.mts +2 -0
- package/dist/esm/core/fetcher/Headers.mjs +82 -0
- package/dist/esm/core/fetcher/HttpResponsePromise.d.mts +58 -0
- package/dist/esm/core/fetcher/HttpResponsePromise.mjs +99 -0
- package/dist/esm/core/fetcher/RawResponse.d.mts +29 -0
- package/dist/esm/core/fetcher/RawResponse.mjs +40 -0
- package/dist/esm/core/fetcher/Supplier.d.mts +4 -0
- package/dist/esm/core/fetcher/Supplier.mjs +19 -0
- package/dist/esm/core/fetcher/createRequestUrl.d.mts +1 -0
- package/dist/esm/core/fetcher/createRequestUrl.mjs +5 -0
- package/dist/esm/core/fetcher/getErrorResponseBody.d.mts +1 -0
- package/dist/esm/core/fetcher/getErrorResponseBody.mjs +42 -0
- package/dist/esm/core/fetcher/getFetchFn.d.mts +1 -0
- package/dist/esm/core/fetcher/getFetchFn.mjs +14 -0
- package/dist/esm/core/fetcher/getHeader.d.mts +1 -0
- package/dist/esm/core/fetcher/getHeader.mjs +8 -0
- package/dist/esm/core/fetcher/getRequestBody.d.mts +7 -0
- package/dist/esm/core/fetcher/getRequestBody.mjs +24 -0
- package/dist/esm/core/fetcher/getResponseBody.d.mts +1 -0
- package/dist/esm/core/fetcher/getResponseBody.mjs +66 -0
- package/dist/esm/core/fetcher/index.d.mts +11 -0
- package/dist/esm/core/fetcher/index.mjs +6 -0
- package/dist/esm/core/fetcher/makeRequest.d.mts +1 -0
- package/dist/esm/core/fetcher/makeRequest.mjs +36 -0
- package/dist/esm/core/fetcher/requestWithRetries.d.mts +1 -0
- package/dist/esm/core/fetcher/requestWithRetries.mjs +64 -0
- package/dist/esm/core/fetcher/signals.d.mts +5 -0
- package/dist/esm/core/fetcher/signals.mjs +20 -0
- package/dist/esm/core/headers.d.mts +2 -0
- package/dist/esm/core/headers.mjs +27 -0
- package/dist/esm/core/index.d.mts +6 -0
- package/dist/esm/core/index.mjs +6 -0
- package/dist/esm/core/json.d.mts +15 -0
- package/dist/esm/core/json.mjs +19 -0
- package/dist/esm/core/logging/exports.d.mts +18 -0
- package/dist/esm/core/logging/exports.mjs +9 -0
- package/dist/esm/core/logging/index.d.mts +1 -0
- package/dist/esm/core/logging/index.mjs +1 -0
- package/dist/esm/core/logging/logger.d.mts +126 -0
- package/dist/esm/core/logging/logger.mjs +138 -0
- package/dist/esm/core/runtime/index.d.mts +1 -0
- package/dist/esm/core/runtime/index.mjs +1 -0
- package/dist/esm/core/runtime/runtime.d.mts +9 -0
- package/dist/esm/core/runtime/runtime.mjs +100 -0
- package/dist/esm/core/url/encodePathParam.d.mts +1 -0
- package/dist/esm/core/url/encodePathParam.mjs +18 -0
- package/dist/esm/core/url/index.d.mts +3 -0
- package/dist/esm/core/url/index.mjs +3 -0
- package/dist/esm/core/url/join.d.mts +1 -0
- package/dist/esm/core/url/join.mjs +65 -0
- package/dist/esm/core/url/qs.d.mts +6 -0
- package/dist/esm/core/url/qs.mjs +61 -0
- package/dist/esm/environments.d.mts +5 -0
- package/dist/esm/environments.mjs +5 -0
- package/dist/esm/errors/FernPostmanError.d.mts +12 -0
- package/dist/esm/errors/FernPostmanError.mjs +28 -0
- package/dist/esm/errors/FernPostmanTimeoutError.d.mts +3 -0
- package/dist/esm/errors/FernPostmanTimeoutError.mjs +11 -0
- package/dist/esm/errors/handleNonStatusCodeError.d.mts +2 -0
- package/dist/esm/errors/handleNonStatusCodeError.mjs +29 -0
- package/dist/esm/errors/index.d.mts +2 -0
- package/dist/esm/errors/index.mjs +2 -0
- package/dist/esm/exports.d.mts +1 -0
- package/dist/esm/exports.mjs +1 -0
- package/dist/esm/index.d.mts +6 -0
- package/dist/esm/index.mjs +5 -0
- package/dist/esm/version.d.mts +1 -0
- package/dist/esm/version.mjs +1 -0
- package/package.json +69 -0
- package/reference.md +193 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
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
|
+
import { CollectionClient } from "./api/resources/collection/client/Client.mjs";
|
|
12
|
+
import { normalizeClientOptionsWithAuth } from "./BaseClient.mjs";
|
|
13
|
+
import { mergeHeaders } from "./core/headers.mjs";
|
|
14
|
+
import * as core from "./core/index.mjs";
|
|
15
|
+
import * as environments from "./environments.mjs";
|
|
16
|
+
import { handleNonStatusCodeError } from "./errors/handleNonStatusCodeError.mjs";
|
|
17
|
+
import * as errors from "./errors/index.mjs";
|
|
18
|
+
export class FernPostmanClient {
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
21
|
+
}
|
|
22
|
+
get collection() {
|
|
23
|
+
var _a;
|
|
24
|
+
return ((_a = this._collection) !== null && _a !== void 0 ? _a : (this._collection = new CollectionClient(this._options)));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Check endpoint to verify the API key is valid.
|
|
28
|
+
*
|
|
29
|
+
* @param {FernPostmanClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* await client.check()
|
|
33
|
+
*/
|
|
34
|
+
check(requestOptions) {
|
|
35
|
+
return core.HttpResponsePromise.fromPromise(this.__check(requestOptions));
|
|
36
|
+
}
|
|
37
|
+
__check(requestOptions) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
40
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
41
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
42
|
+
const _response = yield core.fetcher({
|
|
43
|
+
url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.FernPostmanEnvironment.Production, "/api/postman/check"),
|
|
44
|
+
method: "GET",
|
|
45
|
+
headers: _headers,
|
|
46
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
47
|
+
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
48
|
+
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
49
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
50
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
51
|
+
logging: this._options.logging,
|
|
52
|
+
});
|
|
53
|
+
if (_response.ok) {
|
|
54
|
+
return { data: undefined, rawResponse: _response.rawResponse };
|
|
55
|
+
}
|
|
56
|
+
if (_response.error.reason === "status-code") {
|
|
57
|
+
throw new errors.FernPostmanError({
|
|
58
|
+
statusCode: _response.error.statusCode,
|
|
59
|
+
body: _response.error.body,
|
|
60
|
+
rawResponse: _response.rawResponse,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/api/postman/check");
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./resources/index.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./resources/index.mjs";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
3
|
+
import * as core from "../../../../core/index.mjs";
|
|
4
|
+
import * as FernPostman from "../../../index.mjs";
|
|
5
|
+
export declare namespace CollectionClient {
|
|
6
|
+
type Options = BaseClientOptions;
|
|
7
|
+
interface RequestOptions extends BaseRequestOptions {
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare class CollectionClient {
|
|
11
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<CollectionClient.Options>;
|
|
12
|
+
constructor(options: CollectionClient.Options);
|
|
13
|
+
/**
|
|
14
|
+
* Returns the publishing status of the Postman collection as documentation.
|
|
15
|
+
*
|
|
16
|
+
* @param {FernPostman.CollectionId} collectionId
|
|
17
|
+
* @param {CollectionClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
18
|
+
*
|
|
19
|
+
* @throws {@link FernPostman.CollectionDoesNotExistError}
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* await client.collection.getStatus("collectionId")
|
|
23
|
+
*/
|
|
24
|
+
getStatus(collectionId: FernPostman.CollectionId, requestOptions?: CollectionClient.RequestOptions): core.HttpResponsePromise<FernPostman.GetCollectionStatusResponse>;
|
|
25
|
+
private __getStatus;
|
|
26
|
+
/**
|
|
27
|
+
* Initiates a request to publish the Postman collection as a Fern documentation site.
|
|
28
|
+
*
|
|
29
|
+
* @param {FernPostman.CollectionId} collectionId
|
|
30
|
+
* @param {FernPostman.PublishCollectionRequest} request
|
|
31
|
+
* @param {CollectionClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
32
|
+
*
|
|
33
|
+
* @throws {@link FernPostman.CollectionDoesNotExistError}
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* await client.collection.publish("collectionId", {
|
|
37
|
+
* userId: "userId",
|
|
38
|
+
* teamId: "teamId"
|
|
39
|
+
* })
|
|
40
|
+
*/
|
|
41
|
+
publish(collectionId: FernPostman.CollectionId, request: FernPostman.PublishCollectionRequest, requestOptions?: CollectionClient.RequestOptions): core.HttpResponsePromise<void>;
|
|
42
|
+
private __publish;
|
|
43
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
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
|
+
import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
12
|
+
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
13
|
+
import * as core from "../../../../core/index.mjs";
|
|
14
|
+
import * as environments from "../../../../environments.mjs";
|
|
15
|
+
import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.mjs";
|
|
16
|
+
import * as errors from "../../../../errors/index.mjs";
|
|
17
|
+
import * as FernPostman from "../../../index.mjs";
|
|
18
|
+
export class CollectionClient {
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the publishing status of the Postman collection as documentation.
|
|
24
|
+
*
|
|
25
|
+
* @param {FernPostman.CollectionId} collectionId
|
|
26
|
+
* @param {CollectionClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
27
|
+
*
|
|
28
|
+
* @throws {@link FernPostman.CollectionDoesNotExistError}
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* await client.collection.getStatus("collectionId")
|
|
32
|
+
*/
|
|
33
|
+
getStatus(collectionId, requestOptions) {
|
|
34
|
+
return core.HttpResponsePromise.fromPromise(this.__getStatus(collectionId, requestOptions));
|
|
35
|
+
}
|
|
36
|
+
__getStatus(collectionId, requestOptions) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
39
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
40
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
41
|
+
const _response = yield core.fetcher({
|
|
42
|
+
url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.FernPostmanEnvironment.Production, `/api/postman/publish/collection/${core.url.encodePathParam(collectionId)}/status`),
|
|
43
|
+
method: "GET",
|
|
44
|
+
headers: _headers,
|
|
45
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
46
|
+
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
47
|
+
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
48
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
49
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
50
|
+
logging: this._options.logging,
|
|
51
|
+
});
|
|
52
|
+
if (_response.ok) {
|
|
53
|
+
return {
|
|
54
|
+
data: _response.body,
|
|
55
|
+
rawResponse: _response.rawResponse,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (_response.error.reason === "status-code") {
|
|
59
|
+
switch (_response.error.statusCode) {
|
|
60
|
+
case 404:
|
|
61
|
+
throw new FernPostman.CollectionDoesNotExistError(_response.error.body, _response.rawResponse);
|
|
62
|
+
default:
|
|
63
|
+
throw new errors.FernPostmanError({
|
|
64
|
+
statusCode: _response.error.statusCode,
|
|
65
|
+
body: _response.error.body,
|
|
66
|
+
rawResponse: _response.rawResponse,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/api/postman/publish/collection/{collectionId}/status");
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Initiates a request to publish the Postman collection as a Fern documentation site.
|
|
75
|
+
*
|
|
76
|
+
* @param {FernPostman.CollectionId} collectionId
|
|
77
|
+
* @param {FernPostman.PublishCollectionRequest} request
|
|
78
|
+
* @param {CollectionClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
79
|
+
*
|
|
80
|
+
* @throws {@link FernPostman.CollectionDoesNotExistError}
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* await client.collection.publish("collectionId", {
|
|
84
|
+
* userId: "userId",
|
|
85
|
+
* teamId: "teamId"
|
|
86
|
+
* })
|
|
87
|
+
*/
|
|
88
|
+
publish(collectionId, request, requestOptions) {
|
|
89
|
+
return core.HttpResponsePromise.fromPromise(this.__publish(collectionId, request, requestOptions));
|
|
90
|
+
}
|
|
91
|
+
__publish(collectionId, request, requestOptions) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
94
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
95
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
96
|
+
const _response = yield core.fetcher({
|
|
97
|
+
url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.FernPostmanEnvironment.Production, `/api/postman/publish/collection/${core.url.encodePathParam(collectionId)}`),
|
|
98
|
+
method: "POST",
|
|
99
|
+
headers: _headers,
|
|
100
|
+
contentType: "application/json",
|
|
101
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
102
|
+
requestType: "json",
|
|
103
|
+
body: request,
|
|
104
|
+
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
105
|
+
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
106
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
107
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
108
|
+
logging: this._options.logging,
|
|
109
|
+
});
|
|
110
|
+
if (_response.ok) {
|
|
111
|
+
return { data: undefined, rawResponse: _response.rawResponse };
|
|
112
|
+
}
|
|
113
|
+
if (_response.error.reason === "status-code") {
|
|
114
|
+
switch (_response.error.statusCode) {
|
|
115
|
+
case 404:
|
|
116
|
+
throw new FernPostman.CollectionDoesNotExistError(_response.error.body, _response.rawResponse);
|
|
117
|
+
default:
|
|
118
|
+
throw new errors.FernPostmanError({
|
|
119
|
+
statusCode: _response.error.statusCode,
|
|
120
|
+
body: _response.error.body,
|
|
121
|
+
rawResponse: _response.rawResponse,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/api/postman/publish/collection/{collectionId}");
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests/index.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests/index.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { PublishCollectionRequest } from "./PublishCollectionRequest.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type * as core from "../../../../core/index.mjs";
|
|
2
|
+
import * as errors from "../../../../errors/index.mjs";
|
|
3
|
+
import type * as FernPostman from "../../../index.mjs";
|
|
4
|
+
export declare class CollectionDoesNotExistError extends errors.FernPostmanError {
|
|
5
|
+
constructor(body: FernPostman.CollectionId, rawResponse?: core.RawResponse);
|
|
6
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
import * as errors from "../../../../errors/index.mjs";
|
|
3
|
+
export class CollectionDoesNotExistError extends errors.FernPostmanError {
|
|
4
|
+
constructor(body, rawResponse) {
|
|
5
|
+
super({
|
|
6
|
+
message: "CollectionDoesNotExistError",
|
|
7
|
+
statusCode: 404,
|
|
8
|
+
body: body,
|
|
9
|
+
rawResponse: rawResponse,
|
|
10
|
+
});
|
|
11
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
12
|
+
if (Error.captureStackTrace) {
|
|
13
|
+
Error.captureStackTrace(this, this.constructor);
|
|
14
|
+
}
|
|
15
|
+
this.name = this.constructor.name;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./CollectionDoesNotExistError.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./CollectionDoesNotExistError.mjs";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type * as FernPostman from "../../../index.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Discriminated union representing the status of publishing the collection as documentation.
|
|
4
|
+
*/
|
|
5
|
+
export type GetCollectionStatusResponse =
|
|
6
|
+
/**
|
|
7
|
+
* The collection publication is in progress. */
|
|
8
|
+
FernPostman.GetCollectionStatusResponse.Publishing
|
|
9
|
+
/**
|
|
10
|
+
* The collection has been successfully published as documentation. */
|
|
11
|
+
| FernPostman.GetCollectionStatusResponse.Published
|
|
12
|
+
/**
|
|
13
|
+
* The collection publication failed. */
|
|
14
|
+
| FernPostman.GetCollectionStatusResponse.Failed;
|
|
15
|
+
export declare namespace GetCollectionStatusResponse {
|
|
16
|
+
interface Publishing extends FernPostman.CollectionStatusPublishing {
|
|
17
|
+
type: "publishing";
|
|
18
|
+
}
|
|
19
|
+
interface Published extends FernPostman.CollectionStatusPublished {
|
|
20
|
+
type: "published";
|
|
21
|
+
}
|
|
22
|
+
interface Failed extends FernPostman.CollectionStatusFailed {
|
|
23
|
+
type: "failed";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./CollectionId.mjs";
|
|
2
|
+
export * from "./CollectionStatusFailed.mjs";
|
|
3
|
+
export * from "./CollectionStatusPublished.mjs";
|
|
4
|
+
export * from "./CollectionStatusPublishing.mjs";
|
|
5
|
+
export * from "./GetCollectionStatusResponse.mjs";
|
|
6
|
+
export * from "./TeamId.mjs";
|
|
7
|
+
export * from "./UserId.mjs";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./CollectionId.mjs";
|
|
2
|
+
export * from "./CollectionStatusFailed.mjs";
|
|
3
|
+
export * from "./CollectionStatusPublished.mjs";
|
|
4
|
+
export * from "./CollectionStatusPublishing.mjs";
|
|
5
|
+
export * from "./GetCollectionStatusResponse.mjs";
|
|
6
|
+
export * from "./TeamId.mjs";
|
|
7
|
+
export * from "./UserId.mjs";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as core from "../core/index.mjs";
|
|
2
|
+
declare const TOKEN_PARAM: "token";
|
|
3
|
+
export declare class BearerAuthProvider implements core.AuthProvider {
|
|
4
|
+
private readonly options;
|
|
5
|
+
constructor(options: BearerAuthProvider.Options);
|
|
6
|
+
static canCreate(options: Partial<BearerAuthProvider.Options>): boolean;
|
|
7
|
+
getAuthRequest({ endpointMetadata, }?: {
|
|
8
|
+
endpointMetadata?: core.EndpointMetadata;
|
|
9
|
+
}): Promise<core.AuthRequest>;
|
|
10
|
+
}
|
|
11
|
+
export declare namespace BearerAuthProvider {
|
|
12
|
+
const AUTH_SCHEME: "bearer";
|
|
13
|
+
const AUTH_CONFIG_ERROR_MESSAGE: string;
|
|
14
|
+
type Options = AuthOptions;
|
|
15
|
+
type AuthOptions = {
|
|
16
|
+
[TOKEN_PARAM]: core.Supplier<core.BearerToken>;
|
|
17
|
+
};
|
|
18
|
+
function createInstance(options: Options): core.AuthProvider;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
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
|
+
import * as core from "../core/index.mjs";
|
|
12
|
+
import * as errors from "../errors/index.mjs";
|
|
13
|
+
const TOKEN_PARAM = "token";
|
|
14
|
+
export class BearerAuthProvider {
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.options = options;
|
|
17
|
+
}
|
|
18
|
+
static canCreate(options) {
|
|
19
|
+
return (options === null || options === void 0 ? void 0 : options[TOKEN_PARAM]) != null;
|
|
20
|
+
}
|
|
21
|
+
getAuthRequest() {
|
|
22
|
+
return __awaiter(this, arguments, void 0, function* ({ endpointMetadata, } = {}) {
|
|
23
|
+
const token = yield core.Supplier.get(this.options[TOKEN_PARAM]);
|
|
24
|
+
if (token == null) {
|
|
25
|
+
throw new errors.FernPostmanError({
|
|
26
|
+
message: BearerAuthProvider.AUTH_CONFIG_ERROR_MESSAGE,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
(function (BearerAuthProvider) {
|
|
36
|
+
BearerAuthProvider.AUTH_SCHEME = "bearer";
|
|
37
|
+
BearerAuthProvider.AUTH_CONFIG_ERROR_MESSAGE = `Please provide '${TOKEN_PARAM}' when initializing the client`;
|
|
38
|
+
function createInstance(options) {
|
|
39
|
+
return new BearerAuthProvider(options);
|
|
40
|
+
}
|
|
41
|
+
BearerAuthProvider.createInstance = createInstance;
|
|
42
|
+
})(BearerAuthProvider || (BearerAuthProvider = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BearerAuthProvider } from "./BearerAuthProvider.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BearerAuthProvider } from "./BearerAuthProvider.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { base64Decode, base64Encode } from "../base64.mjs";
|
|
2
|
+
const BASIC_AUTH_HEADER_PREFIX = /^Basic /i;
|
|
3
|
+
export const BasicAuth = {
|
|
4
|
+
toAuthorizationHeader: (basicAuth) => {
|
|
5
|
+
if (basicAuth == null) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
const token = base64Encode(`${basicAuth.username}:${basicAuth.password}`);
|
|
9
|
+
return `Basic ${token}`;
|
|
10
|
+
},
|
|
11
|
+
fromAuthorizationHeader: (header) => {
|
|
12
|
+
const credentials = header.replace(BASIC_AUTH_HEADER_PREFIX, "");
|
|
13
|
+
const decoded = base64Decode(credentials);
|
|
14
|
+
const [username, ...passwordParts] = decoded.split(":");
|
|
15
|
+
const password = passwordParts.length > 0 ? passwordParts.join(":") : undefined;
|
|
16
|
+
if (username == null || password == null) {
|
|
17
|
+
throw new Error("Invalid basic auth");
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
username,
|
|
21
|
+
password,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type BearerToken = string;
|
|
2
|
+
declare function toAuthorizationHeader(token: string | undefined): string | undefined;
|
|
3
|
+
export declare const BearerToken: {
|
|
4
|
+
toAuthorizationHeader: typeof toAuthorizationHeader;
|
|
5
|
+
fromAuthorizationHeader: (header: string) => BearerToken;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i;
|
|
2
|
+
function toAuthorizationHeader(token) {
|
|
3
|
+
if (token == null) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
return `Bearer ${token}`;
|
|
7
|
+
}
|
|
8
|
+
export const BearerToken = {
|
|
9
|
+
toAuthorizationHeader: toAuthorizationHeader,
|
|
10
|
+
fromAuthorizationHeader: (header) => {
|
|
11
|
+
return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim();
|
|
12
|
+
},
|
|
13
|
+
};
|