@aligent/microservice-util-lib 1.5.0 → 1.6.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aligent/microservice-util-lib",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "A set of utility functions for Aligent Microservices",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"@aws-sdk/client-ssm": "^3.922.0",
|
|
16
16
|
"oauth-sign": "^0.9.0",
|
|
17
17
|
"object-hash": "^3.0.0",
|
|
18
|
-
"openapi-fetch": "^0.17.0"
|
|
18
|
+
"openapi-fetch": "^0.17.0",
|
|
19
|
+
"openapi-typescript-helpers": "0.1.0"
|
|
19
20
|
},
|
|
20
21
|
"author": "Aligent",
|
|
21
22
|
"license": "MIT",
|
package/src/index.d.ts
CHANGED
|
@@ -5,8 +5,10 @@ import hasDefinedProperties from './has-properties-defined/has-properties-define
|
|
|
5
5
|
import { ApiKey, Basic, OAuth10a, OAuth20, apiKeyAuthMiddleware, basicAuthMiddleware, oAuth10aAuthMiddleware, oAuth20AuthMiddleware, resignOauth10aRequest } from './openapi-fetch-middlewares/authentications';
|
|
6
6
|
import { LogLevel, Logger, logMiddleware } from './openapi-fetch-middlewares/log';
|
|
7
7
|
import { RetryConfig as RetryMiddlewareConfig, retryMiddleware } from './openapi-fetch-middlewares/retry';
|
|
8
|
+
import { ErrorThrowingClient, asErrorThrowingClient } from './openapi-fetch-middlewares/throwing-client';
|
|
9
|
+
import { HttpResponseError, isHttpResponseError } from './openapi-fetch-middlewares/utils/http-response-error';
|
|
8
10
|
import remap, { ObjectMap, Remap } from './remap/remap';
|
|
9
11
|
import retryWrapper, { RetryConfig } from './retry-wrapper/retry-wrapper';
|
|
10
12
|
import S3Dao from './s3/s3';
|
|
11
|
-
export type { ApiKey, Basic, LogLevel, Logger, OAuth10a, OAuth20, ObjectMap, Remap, RetryConfig, RetryMiddlewareConfig, S3Dao, };
|
|
12
|
-
export { apiKeyAuthMiddleware, basicAuthMiddleware, chunkBy, fetchSsmParams, getAwsIdFromArn, hasDefinedProperties, logMiddleware, oAuth10aAuthMiddleware, oAuth20AuthMiddleware, remap, resignOauth10aRequest, retryMiddleware, retryWrapper, };
|
|
13
|
+
export type { ApiKey, Basic, ErrorThrowingClient, LogLevel, Logger, OAuth10a, OAuth20, ObjectMap, Remap, RetryConfig, RetryMiddlewareConfig, S3Dao, };
|
|
14
|
+
export { HttpResponseError, apiKeyAuthMiddleware, asErrorThrowingClient, basicAuthMiddleware, chunkBy, fetchSsmParams, getAwsIdFromArn, hasDefinedProperties, isHttpResponseError, logMiddleware, oAuth10aAuthMiddleware, oAuth20AuthMiddleware, remap, resignOauth10aRequest, retryMiddleware, retryWrapper, };
|
package/src/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.retryWrapper = exports.retryMiddleware = exports.resignOauth10aRequest = exports.remap = exports.oAuth20AuthMiddleware = exports.oAuth10aAuthMiddleware = exports.logMiddleware = exports.hasDefinedProperties = exports.getAwsIdFromArn = exports.fetchSsmParams = exports.chunkBy = exports.basicAuthMiddleware = exports.apiKeyAuthMiddleware = void 0;
|
|
6
|
+
exports.retryWrapper = exports.retryMiddleware = exports.resignOauth10aRequest = exports.remap = exports.oAuth20AuthMiddleware = exports.oAuth10aAuthMiddleware = exports.logMiddleware = exports.isHttpResponseError = exports.hasDefinedProperties = exports.getAwsIdFromArn = exports.fetchSsmParams = exports.chunkBy = exports.basicAuthMiddleware = exports.asErrorThrowingClient = exports.apiKeyAuthMiddleware = exports.HttpResponseError = void 0;
|
|
7
7
|
/* v8 ignore start */
|
|
8
8
|
const chunk_by_1 = __importDefault(require("./chunk-by/chunk-by"));
|
|
9
9
|
exports.chunkBy = chunk_by_1.default;
|
|
@@ -23,6 +23,11 @@ const log_1 = require("./openapi-fetch-middlewares/log");
|
|
|
23
23
|
Object.defineProperty(exports, "logMiddleware", { enumerable: true, get: function () { return log_1.logMiddleware; } });
|
|
24
24
|
const retry_1 = require("./openapi-fetch-middlewares/retry");
|
|
25
25
|
Object.defineProperty(exports, "retryMiddleware", { enumerable: true, get: function () { return retry_1.retryMiddleware; } });
|
|
26
|
+
const throwing_client_1 = require("./openapi-fetch-middlewares/throwing-client");
|
|
27
|
+
Object.defineProperty(exports, "asErrorThrowingClient", { enumerable: true, get: function () { return throwing_client_1.asErrorThrowingClient; } });
|
|
28
|
+
const http_response_error_1 = require("./openapi-fetch-middlewares/utils/http-response-error");
|
|
29
|
+
Object.defineProperty(exports, "HttpResponseError", { enumerable: true, get: function () { return http_response_error_1.HttpResponseError; } });
|
|
30
|
+
Object.defineProperty(exports, "isHttpResponseError", { enumerable: true, get: function () { return http_response_error_1.isHttpResponseError; } });
|
|
26
31
|
const remap_1 = __importDefault(require("./remap/remap"));
|
|
27
32
|
exports.remap = remap_1.default;
|
|
28
33
|
const retry_wrapper_1 = __importDefault(require("./retry-wrapper/retry-wrapper"));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Client } from 'openapi-fetch';
|
|
2
|
+
import type { MediaType } from 'openapi-typescript-helpers';
|
|
3
|
+
/**
|
|
4
|
+
* A Client whose HTTP methods return only the success branch
|
|
5
|
+
* ({ data: D; response: Response }), reflecting the runtime contract
|
|
6
|
+
* when retryMiddleware is registered with throwOnNotOk: true (the default).
|
|
7
|
+
*
|
|
8
|
+
* Errors are thrown as HttpResponseError, never returned in the union.
|
|
9
|
+
*/
|
|
10
|
+
export type ErrorThrowingClient<Paths extends Record<string, unknown>, Media extends MediaType = MediaType> = {
|
|
11
|
+
[K in keyof Client<Paths, Media>]: Client<Paths, Media>[K] extends (...args: infer A) => Promise<infer R> ? (...args: A) => Promise<Extract<R, {
|
|
12
|
+
error?: never;
|
|
13
|
+
}>> : Client<Paths, Media>[K];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Cast an openapi-fetch Client to an ErrorThrowingClient.
|
|
17
|
+
*
|
|
18
|
+
* Use this after registering retryMiddleware (with default throwOnNotOk: true),
|
|
19
|
+
* which throws HttpResponseError on !response.ok and makes the error branch
|
|
20
|
+
* of the discriminated union unreachable. Zero runtime cost — purely a type narrowing.
|
|
21
|
+
*
|
|
22
|
+
* WARNING: Do not use if retryMiddleware is configured with throwOnNotOk: false.
|
|
23
|
+
*/
|
|
24
|
+
export declare function asErrorThrowingClient<Paths extends Record<string, unknown>, Media extends MediaType = MediaType>(client: Client<Paths, Media>): ErrorThrowingClient<Paths, Media>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asErrorThrowingClient = asErrorThrowingClient;
|
|
4
|
+
/**
|
|
5
|
+
* Cast an openapi-fetch Client to an ErrorThrowingClient.
|
|
6
|
+
*
|
|
7
|
+
* Use this after registering retryMiddleware (with default throwOnNotOk: true),
|
|
8
|
+
* which throws HttpResponseError on !response.ok and makes the error branch
|
|
9
|
+
* of the discriminated union unreachable. Zero runtime cost — purely a type narrowing.
|
|
10
|
+
*
|
|
11
|
+
* WARNING: Do not use if retryMiddleware is configured with throwOnNotOk: false.
|
|
12
|
+
*/
|
|
13
|
+
function asErrorThrowingClient(client) {
|
|
14
|
+
return client;
|
|
15
|
+
}
|