@squiz/optimization-utils 2.0.0 → 2.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/CHANGELOG.md +12 -0
- package/dist/cloudflare/ImplCloudflareKVHttpService.d.ts +2 -2
- package/dist/cloudflare/ImplCloudflareKVHttpService.js +8 -10
- package/dist/cloudflare/ImplCloudflareKVHttpService.js.map +1 -1
- package/dist/config/ConfigurationLoader.d.ts +1 -1
- package/dist/config/ConfigurationLoader.js +3 -4
- package/dist/config/ConfigurationLoader.js.map +1 -1
- package/dist/index.d.ts +0 -11
- package/dist/index.js +0 -11
- package/dist/index.js.map +1 -1
- package/dist/scheduler/EventBridgeScheduler.d.ts +1 -1
- package/dist/scheduler/EventBridgeScheduler.js +4 -5
- package/dist/scheduler/EventBridgeScheduler.js.map +1 -1
- package/dist/testing/mock.d.ts +0 -8
- package/dist/testing/mock.js +1 -35
- package/dist/testing/mock.js.map +1 -1
- package/package.json +4 -1
- package/src/cloudflare/ImplCloudflareKVHttpService.ts +5 -4
- package/src/cloudflare/__tests__/ImplCloudflareKVHttpService.spec.ts +4 -4
- package/src/config/ConfigurationLoader.ts +4 -2
- package/src/config/__tests__/ConfigurationLoader.spec.ts +3 -3
- package/src/event/__tests__/DynamoDBEventMapper.spec.ts +1 -1
- package/src/index.ts +0 -16
- package/src/scheduler/EventBridgeScheduler.ts +1 -2
- package/src/scheduler/__tests__/EventBridgeScheduler.spec.ts +2 -5
- package/src/testing/mock.ts +0 -47
- package/dist/exception/DomainException.d.ts +0 -18
- package/dist/exception/DomainException.js +0 -41
- package/dist/exception/DomainException.js.map +0 -1
- package/dist/httpClient/FetchHttpClient.d.ts +0 -7
- package/dist/httpClient/FetchHttpClient.js +0 -86
- package/dist/httpClient/FetchHttpClient.js.map +0 -1
- package/dist/httpClient/HttpClient.d.ts +0 -25
- package/dist/httpClient/HttpClient.js +0 -45
- package/dist/httpClient/HttpClient.js.map +0 -1
- package/dist/httpClient/HttpRequestBuilder.d.ts +0 -22
- package/dist/httpClient/HttpRequestBuilder.js +0 -126
- package/dist/httpClient/HttpRequestBuilder.js.map +0 -1
- package/dist/logger/Logger.d.ts +0 -10
- package/dist/logger/Logger.js +0 -30
- package/dist/logger/Logger.js.map +0 -1
- package/dist/logger/LoggerMessage.d.ts +0 -43
- package/dist/logger/LoggerMessage.js +0 -111
- package/dist/logger/LoggerMessage.js.map +0 -1
- package/dist/logger/LogsHandler.d.ts +0 -11
- package/dist/logger/LogsHandler.js +0 -66
- package/dist/logger/LogsHandler.js.map +0 -1
- package/dist/logger/LogsLambdaHandler.d.ts +0 -13
- package/dist/logger/LogsLambdaHandler.js +0 -31
- package/dist/logger/LogsLambdaHandler.js.map +0 -1
- package/dist/logger/RemoteLogger.d.ts +0 -30
- package/dist/logger/RemoteLogger.js +0 -35
- package/dist/logger/RemoteLogger.js.map +0 -1
- package/dist/logger/SquizRemoteLogger.d.ts +0 -53
- package/dist/logger/SquizRemoteLogger.js +0 -128
- package/dist/logger/SquizRemoteLogger.js.map +0 -1
- package/dist/validation/handleValidation.d.ts +0 -2
- package/dist/validation/handleValidation.js +0 -11
- package/dist/validation/handleValidation.js.map +0 -1
- package/dist/valueObject/TenantId.d.ts +0 -10
- package/dist/valueObject/TenantId.js +0 -23
- package/dist/valueObject/TenantId.js.map +0 -1
- package/src/exception/DomainException.ts +0 -34
- package/src/httpClient/FetchHttpClient.ts +0 -92
- package/src/httpClient/HttpClient.ts +0 -46
- package/src/httpClient/HttpRequestBuilder.ts +0 -120
- package/src/httpClient/__tests__/FetchHttpClient.spec.ts +0 -146
- package/src/httpClient/__tests__/HttpClient.spec.ts +0 -52
- package/src/httpClient/__tests__/httpRequestBuilder.spec.ts +0 -75
- package/src/logger/Logger.ts +0 -40
- package/src/logger/LoggerMessage.ts +0 -179
- package/src/logger/LogsHandler.ts +0 -66
- package/src/logger/LogsLambdaHandler.ts +0 -43
- package/src/logger/RemoteLogger.ts +0 -32
- package/src/logger/SquizRemoteLogger.ts +0 -154
- package/src/logger/__tests__/LoggerMessage.spec.ts +0 -147
- package/src/logger/__tests__/LogsHandler.spec.ts +0 -77
- package/src/logger/__tests__/SquizRemoteLogger.spec.ts +0 -185
- package/src/validation/handleValidation.ts +0 -13
- package/src/valueObject/TenantId.ts +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BatchValueData, CloudflareKey, CloudflareKVHttpService } from './CloudflareKVHttpService';
|
|
2
2
|
import { ZodType } from 'zod';
|
|
3
|
-
import { HttpRequestBuilderFactory } from '
|
|
4
|
-
import { Logger } from '
|
|
3
|
+
import { HttpRequestBuilderFactory } from '@squiz/optimization-http-client';
|
|
4
|
+
import { Logger } from '@squiz/optimization-logger';
|
|
5
5
|
export type CloudflareConfig = {
|
|
6
6
|
domain: string;
|
|
7
7
|
accountId: string;
|
|
@@ -13,10 +13,8 @@ exports.ImplCloudflareKVHttpService = void 0;
|
|
|
13
13
|
const inversify_1 = require("inversify");
|
|
14
14
|
const util_1 = require("util");
|
|
15
15
|
const CloudflareKVHttpService_1 = require("./CloudflareKVHttpService");
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const HttpClient_1 = require("../httpClient/HttpClient");
|
|
19
|
-
const LoggerMessage_1 = require("../logger/LoggerMessage");
|
|
16
|
+
const optimization_http_client_1 = require("@squiz/optimization-http-client");
|
|
17
|
+
const optimization_logger_1 = require("@squiz/optimization-logger");
|
|
20
18
|
let ImplCloudflareKVHttpService = class ImplCloudflareKVHttpService {
|
|
21
19
|
cloudflareConfigProvider;
|
|
22
20
|
httpRequestBuilderFactory;
|
|
@@ -31,7 +29,7 @@ let ImplCloudflareKVHttpService = class ImplCloudflareKVHttpService {
|
|
|
31
29
|
async getValues(key) {
|
|
32
30
|
const response = await this.callApi({
|
|
33
31
|
path: `/values/${key}`,
|
|
34
|
-
method:
|
|
32
|
+
method: optimization_http_client_1.HttpMethod.GET,
|
|
35
33
|
handleNotFoundAsEmpty: true,
|
|
36
34
|
});
|
|
37
35
|
return this.schema.parse(typeof response === 'string' ? JSON.parse(response) : {});
|
|
@@ -44,7 +42,7 @@ let ImplCloudflareKVHttpService = class ImplCloudflareKVHttpService {
|
|
|
44
42
|
throw new Error(`The max items count has been exceeded. The max items count is ${CloudflareKVHttpService_1.MAX_BATCH_DATA_ITEMS}`);
|
|
45
43
|
}
|
|
46
44
|
await this.callApi({
|
|
47
|
-
method:
|
|
45
|
+
method: optimization_http_client_1.HttpMethod.PUT,
|
|
48
46
|
body: batchData.map((data) => ({
|
|
49
47
|
...data,
|
|
50
48
|
value: JSON.stringify(data.value),
|
|
@@ -57,7 +55,7 @@ let ImplCloudflareKVHttpService = class ImplCloudflareKVHttpService {
|
|
|
57
55
|
return;
|
|
58
56
|
}
|
|
59
57
|
await this.callApi({
|
|
60
|
-
method:
|
|
58
|
+
method: optimization_http_client_1.HttpMethod.DELETE,
|
|
61
59
|
body: keys,
|
|
62
60
|
path: `/bulk`,
|
|
63
61
|
});
|
|
@@ -68,7 +66,7 @@ let ImplCloudflareKVHttpService = class ImplCloudflareKVHttpService {
|
|
|
68
66
|
`${config.accountId}/storage/kv/namespaces/` +
|
|
69
67
|
`${config.namespace}`;
|
|
70
68
|
const url = baseUrl + path;
|
|
71
|
-
const logMessage = (0,
|
|
69
|
+
const logMessage = (0, optimization_logger_1.createLog)()
|
|
72
70
|
.attachMetadata({ path, method, url })
|
|
73
71
|
.create(this);
|
|
74
72
|
this.logger.debug(...logMessage('started calling http endpoint'));
|
|
@@ -90,7 +88,7 @@ let ImplCloudflareKVHttpService = class ImplCloudflareKVHttpService {
|
|
|
90
88
|
exports.ImplCloudflareKVHttpService = ImplCloudflareKVHttpService;
|
|
91
89
|
exports.ImplCloudflareKVHttpService = ImplCloudflareKVHttpService = __decorate([
|
|
92
90
|
(0, inversify_1.injectable)(),
|
|
93
|
-
__metadata("design:paramtypes", [Function,
|
|
94
|
-
|
|
91
|
+
__metadata("design:paramtypes", [Function, optimization_http_client_1.HttpRequestBuilderFactory,
|
|
92
|
+
optimization_logger_1.Logger, Object])
|
|
95
93
|
], ImplCloudflareKVHttpService);
|
|
96
94
|
//# sourceMappingURL=ImplCloudflareKVHttpService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImplCloudflareKVHttpService.js","sourceRoot":"","sources":["../../src/cloudflare/ImplCloudflareKVHttpService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuC;AACvC,+BAA+B;AAC/B,uEAKmC;AAEnC,
|
|
1
|
+
{"version":3,"file":"ImplCloudflareKVHttpService.js","sourceRoot":"","sources":["../../src/cloudflare/ImplCloudflareKVHttpService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuC;AACvC,+BAA+B;AAC/B,uEAKmC;AAEnC,8EAGyC;AACzC,oEAA+D;AAWxD,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAInB;IACA;IACA;IACA;IAJnB,YACmB,wBAAkD,EAClD,yBAAoD,EACpD,MAAc,EACd,MAAiD;QAHjD,6BAAwB,GAAxB,wBAAwB,CAA0B;QAClD,8BAAyB,GAAzB,yBAAyB,CAA2B;QACpD,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAA2C;IACjE,CAAC;IAEJ,KAAK,CAAC,SAAS,CAAC,GAAW;QACzB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC;YAClC,IAAI,EAAE,WAAW,GAAG,EAAE;YACtB,MAAM,EAAE,qCAAU,CAAC,GAAG;YACtB,qBAAqB,EAAE,IAAI;SAC5B,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CACtB,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CACzD,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CAA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aACrC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEhB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,+BAA+B,CAAC,CAAC,CAAC;QAClE,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,GAAG,UAAU,CAAC,qBAAqB,IAAA,cAAO,EAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAClE,CAAC;QACF,MAAM,WAAW,GAAG,IAAI,CAAC,yBAAyB;aAC/C,MAAM,EAAE;aACR,GAAG,CAAC,GAAG,CAAC;aACR,MAAM,CAAC,MAAM,CAAC;aACd,IAAI,CAAC,IAAI,CAAC;aACV,eAAe,EAAE;aACjB,qBAAqB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAExC,qBAAqB,IAAI,WAAW,CAAC,cAAc,EAAE,CAAC;QAEtD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,WAAW,EAAE,CAAC;QAEjD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,gCAAgC,CAAC,CAAC,CAAC;QACnE,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,GAAG,UAAU,CACX,kBAAkB,OAAO,QAAQ,CAAC,IAAI,qBAAqB,IAAA,cAAO,EAChE,QAAQ,CAAC,IAAI,EACb,EAAE,KAAK,EAAE,CAAC,EAAE,CACb,EAAE,CACJ,CACF,CAAC;QACF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF,CAAA;AAxGY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,sBAAU,GAAE;+CAMmC,oDAAyB;QAC5C,4BAAM;GANtB,2BAA2B,CAwGvC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z, ZodType } from 'zod';
|
|
2
|
-
import { HttpRequestBuilderFactory } from '
|
|
2
|
+
import { HttpRequestBuilderFactory } from '@squiz/optimization-http-client';
|
|
3
3
|
export declare abstract class ConfigurationLoader<TSchema extends ZodType> {
|
|
4
4
|
abstract load(): Promise<z.infer<TSchema>>;
|
|
5
5
|
}
|
|
@@ -37,8 +37,7 @@ const dotenv_1 = require("dotenv");
|
|
|
37
37
|
const process = __importStar(require("process"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
const inversify_1 = require("inversify");
|
|
40
|
-
const
|
|
41
|
-
const HttpClient_1 = require("../httpClient/HttpClient");
|
|
40
|
+
const optimization_http_client_1 = require("@squiz/optimization-http-client");
|
|
42
41
|
class ConfigurationLoader {
|
|
43
42
|
}
|
|
44
43
|
exports.ConfigurationLoader = ConfigurationLoader;
|
|
@@ -86,7 +85,7 @@ let LambdaLayerAppConfigConfigurationLoader = class LambdaLayerAppConfigConfigur
|
|
|
86
85
|
const response = await this.httpRequestBuilderFactory
|
|
87
86
|
.create()
|
|
88
87
|
.url(url)
|
|
89
|
-
.method(
|
|
88
|
+
.method(optimization_http_client_1.HttpMethod.GET)
|
|
90
89
|
.sendRequest();
|
|
91
90
|
return response.body;
|
|
92
91
|
}
|
|
@@ -94,6 +93,6 @@ let LambdaLayerAppConfigConfigurationLoader = class LambdaLayerAppConfigConfigur
|
|
|
94
93
|
exports.LambdaLayerAppConfigConfigurationLoader = LambdaLayerAppConfigConfigurationLoader;
|
|
95
94
|
exports.LambdaLayerAppConfigConfigurationLoader = LambdaLayerAppConfigConfigurationLoader = __decorate([
|
|
96
95
|
(0, inversify_1.injectable)(),
|
|
97
|
-
__metadata("design:paramtypes", [Object,
|
|
96
|
+
__metadata("design:paramtypes", [Object, optimization_http_client_1.HttpRequestBuilderFactory, Object])
|
|
98
97
|
], LambdaLayerAppConfigConfigurationLoader);
|
|
99
98
|
//# sourceMappingURL=ConfigurationLoader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurationLoader.js","sourceRoot":"","sources":["../../src/config/ConfigurationLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;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;IAC1C,CAAC;IAEO,KAAK,CAAC,YAAY;QACxB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;QAC5C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QAClC,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC;QAClD,iFAAiF;QACjF,yHAAyH;QACzH,MAAM,GAAG,GACP,uBAAuB;YACvB,iBAAiB,WAAW,iBAAiB,WAAW,mBAAmB,aAAa,EAAE,CAAC;QAE7F,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,yBAAyB;aAClD,MAAM,EAAE;aACR,GAAG,CAAC,GAAG,CAAC;aACR,MAAM,CAAC,qCAAU,CAAC,GAAG,CAAC;aACtB,WAAW,EAAE,CAAC;QAEjB,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF,CAAA;AAjCY,0FAAuC;kDAAvC,uCAAuC;IADnD,IAAA,sBAAU,GAAE;6CAMmC,oDAAyB;GAL5D,uCAAuC,CAiCnD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
export * from './valueObject/TenantId';
|
|
2
|
-
export * from './validation/handleValidation';
|
|
3
1
|
export * from './typesUtils/utilities';
|
|
4
2
|
export * from './typesUtils/DynamoDB';
|
|
5
3
|
export * from './testing/mock';
|
|
6
4
|
export * from './scheduler/Scheduler';
|
|
7
5
|
export * from './scheduler/EventBridgeScheduler';
|
|
8
|
-
export * from './logger/SquizRemoteLogger';
|
|
9
|
-
export * from './logger/RemoteLogger';
|
|
10
|
-
export * from './logger/LoggerMessage';
|
|
11
|
-
export * from './logger/Logger';
|
|
12
|
-
export * from './logger/LogsLambdaHandler';
|
|
13
|
-
export * from './httpClient/HttpRequestBuilder';
|
|
14
|
-
export * from './httpClient/HttpClient';
|
|
15
|
-
export * from './httpClient/FetchHttpClient';
|
|
16
|
-
export * from './exception/DomainException';
|
|
17
6
|
export * from './event/DynamoDBEventMapper';
|
|
18
7
|
export * from './event/DomainEvent';
|
|
19
8
|
export * from './event/AggregateRoot';
|
package/dist/index.js
CHANGED
|
@@ -14,22 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./valueObject/TenantId"), exports);
|
|
18
|
-
__exportStar(require("./validation/handleValidation"), exports);
|
|
19
17
|
__exportStar(require("./typesUtils/utilities"), exports);
|
|
20
18
|
__exportStar(require("./typesUtils/DynamoDB"), exports);
|
|
21
19
|
__exportStar(require("./testing/mock"), exports);
|
|
22
20
|
__exportStar(require("./scheduler/Scheduler"), exports);
|
|
23
21
|
__exportStar(require("./scheduler/EventBridgeScheduler"), exports);
|
|
24
|
-
__exportStar(require("./logger/SquizRemoteLogger"), exports);
|
|
25
|
-
__exportStar(require("./logger/RemoteLogger"), exports);
|
|
26
|
-
__exportStar(require("./logger/LoggerMessage"), exports);
|
|
27
|
-
__exportStar(require("./logger/Logger"), exports);
|
|
28
|
-
__exportStar(require("./logger/LogsLambdaHandler"), exports);
|
|
29
|
-
__exportStar(require("./httpClient/HttpRequestBuilder"), exports);
|
|
30
|
-
__exportStar(require("./httpClient/HttpClient"), exports);
|
|
31
|
-
__exportStar(require("./httpClient/FetchHttpClient"), exports);
|
|
32
|
-
__exportStar(require("./exception/DomainException"), exports);
|
|
33
22
|
__exportStar(require("./event/DynamoDBEventMapper"), exports);
|
|
34
23
|
__exportStar(require("./event/DomainEvent"), exports);
|
|
35
24
|
__exportStar(require("./event/AggregateRoot"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,wDAAsC;AAEtC,iDAA+B;AAE/B,wDAAsC;AACtC,mEAAiD;AAEjD,8DAA4C;AAC5C,sDAAoC;AACpC,wDAAsC;AAEtC,yDAAuC;AACvC,uDAAqC;AAErC,+DAA6C;AAE7C,2EAAyD;AACzD,uEAAqD;AAErD,uDAAqC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SchedulerClient } from '@aws-sdk/client-scheduler';
|
|
2
2
|
import { DomainEvent } from '../event/DomainEvent';
|
|
3
3
|
import { ScheduleName, Scheduler, SchedulerOptions } from './Scheduler';
|
|
4
|
-
import { Logger } from '
|
|
4
|
+
import { Logger } from '@squiz/optimization-logger';
|
|
5
5
|
export type EventBridgeSchedulerConfig = {
|
|
6
6
|
region: string;
|
|
7
7
|
groupName: string;
|
|
@@ -14,9 +14,8 @@ const inversify_1 = require("inversify");
|
|
|
14
14
|
const client_scheduler_1 = require("@aws-sdk/client-scheduler");
|
|
15
15
|
const DynamoDBEventMapper_1 = require("../event/DynamoDBEventMapper");
|
|
16
16
|
const crypto_1 = require("crypto");
|
|
17
|
-
const Logger_1 = require("../logger/Logger");
|
|
18
|
-
const LoggerMessage_1 = require("../logger/LoggerMessage");
|
|
19
17
|
const util_dynamodb_1 = require("@aws-sdk/util-dynamodb");
|
|
18
|
+
const optimization_logger_1 = require("@squiz/optimization-logger");
|
|
20
19
|
let EventBridgeScheduler = class EventBridgeScheduler {
|
|
21
20
|
config;
|
|
22
21
|
client;
|
|
@@ -27,7 +26,7 @@ let EventBridgeScheduler = class EventBridgeScheduler {
|
|
|
27
26
|
this.logger = logger;
|
|
28
27
|
}
|
|
29
28
|
async schedule(domainEvent, options) {
|
|
30
|
-
const logMessage = (0,
|
|
29
|
+
const logMessage = (0, optimization_logger_1.createLog)()
|
|
31
30
|
.attachEventName(domainEvent.name)
|
|
32
31
|
.create(this);
|
|
33
32
|
this.logger.debug(...logMessage('started scheduling'));
|
|
@@ -90,7 +89,7 @@ let EventBridgeScheduler = class EventBridgeScheduler {
|
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
91
|
async deleteSchedule(scheduleName) {
|
|
93
|
-
const logMessage = (0,
|
|
92
|
+
const logMessage = (0, optimization_logger_1.createLog)()
|
|
94
93
|
.attachMetadata({ scheduleName })
|
|
95
94
|
.create(this);
|
|
96
95
|
return this._deleteSchedule(scheduleName, logMessage);
|
|
@@ -126,6 +125,6 @@ exports.EventBridgeScheduler = EventBridgeScheduler;
|
|
|
126
125
|
exports.EventBridgeScheduler = EventBridgeScheduler = __decorate([
|
|
127
126
|
(0, inversify_1.injectable)(),
|
|
128
127
|
__metadata("design:paramtypes", [Object, client_scheduler_1.SchedulerClient,
|
|
129
|
-
|
|
128
|
+
optimization_logger_1.Logger])
|
|
130
129
|
], EventBridgeScheduler);
|
|
131
130
|
//# sourceMappingURL=EventBridgeScheduler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventBridgeScheduler.js","sourceRoot":"","sources":["../../src/scheduler/EventBridgeScheduler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuC;AACvC,gEAOmC;AAGnC,sEAA+D;AAC/D,mCAAoC;AAEpC,
|
|
1
|
+
{"version":3,"file":"EventBridgeScheduler.js","sourceRoot":"","sources":["../../src/scheduler/EventBridgeScheduler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuC;AACvC,gEAOmC;AAGnC,sEAA+D;AAC/D,mCAAoC;AAEpC,0DAAkD;AAClD,oEAA2E;AAUpE,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAEZ;IACA;IACA;IAHnB,YACmB,MAAkC,EAClC,MAAuB,EACvB,MAAc;QAFd,WAAM,GAAN,MAAM,CAA4B;QAClC,WAAM,GAAN,MAAM,CAAiB;QACvB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AC9C,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;YAChC,IAAI,EAAE,mBAAmB;SAC1B,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEtC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,4BAA4B,CAAC,CAAC,CAAC;IACjE,CAAC;CACF,CAAA;AAlJY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,sBAAU,GAAE;6CAIgB,kCAAe;QACf,4BAAM;GAJtB,oBAAoB,CAkJhC"}
|
package/dist/testing/mock.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import { HttpClient } from '../httpClient/HttpClient';
|
|
2
|
-
import { Logger } from '../logger/Logger';
|
|
3
|
-
import { RemoteLogger } from '../logger/RemoteLogger';
|
|
4
1
|
import { SchedulerClient } from '@aws-sdk/client-scheduler';
|
|
5
2
|
import { Scheduler } from '../scheduler/Scheduler';
|
|
6
|
-
export type FetchMock = jest.Mock<ReturnType<typeof fetch>, Parameters<typeof fetch>>;
|
|
7
|
-
export declare const createResponse: <T>(status: number, body?: T, headers?: Record<string, string>) => Response;
|
|
8
|
-
export declare const createHttpClientMock: () => HttpClient;
|
|
9
|
-
export declare const createLoggerMock: () => Logger;
|
|
10
|
-
export declare const createRemoteLoggerMock: () => RemoteLogger;
|
|
11
3
|
export declare const createSchedulerClientMock: () => SchedulerClient;
|
|
12
4
|
export declare const createSchedulerMock: () => Scheduler;
|
package/dist/testing/mock.js
CHANGED
|
@@ -1,40 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSchedulerMock = exports.createSchedulerClientMock =
|
|
4
|
-
const createResponse = (status, body, headers) => ({
|
|
5
|
-
status,
|
|
6
|
-
ok: status < 400,
|
|
7
|
-
headers: new Map(Object.entries(headers ?? {})),
|
|
8
|
-
json: async () => body,
|
|
9
|
-
text: async () => JSON.stringify(body),
|
|
10
|
-
});
|
|
11
|
-
exports.createResponse = createResponse;
|
|
12
|
-
const createHttpClientMock = () => {
|
|
13
|
-
return {
|
|
14
|
-
sendRequest: jest.fn(),
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
exports.createHttpClientMock = createHttpClientMock;
|
|
18
|
-
const createLoggerMock = () => {
|
|
19
|
-
return {
|
|
20
|
-
debug: jest.fn(),
|
|
21
|
-
error: jest.fn(),
|
|
22
|
-
info: jest.fn(),
|
|
23
|
-
log: jest.fn(),
|
|
24
|
-
verbose: jest.fn(),
|
|
25
|
-
warn: jest.fn(),
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
exports.createLoggerMock = createLoggerMock;
|
|
29
|
-
const createRemoteLoggerMock = () => {
|
|
30
|
-
return {
|
|
31
|
-
log: jest.fn(),
|
|
32
|
-
info: jest.fn(),
|
|
33
|
-
warn: jest.fn(),
|
|
34
|
-
error: jest.fn(),
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
exports.createRemoteLoggerMock = createRemoteLoggerMock;
|
|
3
|
+
exports.createSchedulerMock = exports.createSchedulerClientMock = void 0;
|
|
38
4
|
const createSchedulerClientMock = () => {
|
|
39
5
|
return {
|
|
40
6
|
send: jest.fn(),
|
package/dist/testing/mock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.js","sourceRoot":"","sources":["../../src/testing/mock.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"mock.js","sourceRoot":"","sources":["../../src/testing/mock.ts"],"names":[],"mappings":";;;AAGO,MAAM,yBAAyB,GAAG,GAAoB,EAAE;IAC7D,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;KACc,CAAC;AAClC,CAAC,CAAC;AAJW,QAAA,yBAAyB,6BAIpC;AAEK,MAAM,mBAAmB,GAAG,GAAc,EAAE;IACjD,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;QACnB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;KAC1B,CAAC;AACJ,CAAC,CAAC;AALW,QAAA,mBAAmB,uBAK9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squiz/optimization-utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
"build:check": "tsc --noEmit"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
+
"@squiz/optimization-http-client": "^1.0.0",
|
|
14
|
+
"@squiz/optimization-logger": "^1.0.1",
|
|
15
|
+
"@squiz/optimization-value-objects": "^1.0.0",
|
|
13
16
|
"node-fetch-commonjs": "^3.3.2",
|
|
14
17
|
"dotenv": "^16.4.5",
|
|
15
18
|
"@aws-sdk/client-dynamodb": "^3.614.0",
|
|
@@ -7,10 +7,11 @@ import {
|
|
|
7
7
|
MAX_BATCH_DATA_ITEMS,
|
|
8
8
|
} from './CloudflareKVHttpService';
|
|
9
9
|
import { ZodType } from 'zod';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
import {
|
|
11
|
+
HttpRequestBuilderFactory,
|
|
12
|
+
HttpMethod,
|
|
13
|
+
} from '@squiz/optimization-http-client';
|
|
14
|
+
import { createLog, Logger } from '@squiz/optimization-logger';
|
|
14
15
|
|
|
15
16
|
export type CloudflareConfig = {
|
|
16
17
|
domain: string;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { createHttpClientMock, createLoggerMock } from '../../testing/mock';
|
|
2
1
|
import {
|
|
3
2
|
CloudflareConfig,
|
|
4
3
|
ImplCloudflareKVHttpService,
|
|
5
4
|
} from '../ImplCloudflareKVHttpService';
|
|
6
5
|
import { Container } from 'inversify';
|
|
7
|
-
import { HttpRequestBuilderFactory } from '../../httpClient/HttpRequestBuilder';
|
|
8
6
|
import {
|
|
7
|
+
createHttpClientMock,
|
|
8
|
+
HttpRequestBuilderFactory,
|
|
9
9
|
HttpClient,
|
|
10
10
|
HttpMethod,
|
|
11
11
|
HttpRequestOptions,
|
|
12
12
|
HttpResponse,
|
|
13
|
-
} from '
|
|
14
|
-
import { Logger } from '
|
|
13
|
+
} from '@squiz/optimization-http-client';
|
|
14
|
+
import { Logger, createLoggerMock } from '@squiz/optimization-logger';
|
|
15
15
|
import { faker } from '@faker-js/faker';
|
|
16
16
|
import { z } from 'zod';
|
|
17
17
|
|
|
@@ -3,8 +3,10 @@ import * as process from 'process';
|
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import { injectable } from 'inversify';
|
|
5
5
|
import { z, ZodType } from 'zod';
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
HttpMethod,
|
|
8
|
+
HttpRequestBuilderFactory,
|
|
9
|
+
} from '@squiz/optimization-http-client';
|
|
8
10
|
|
|
9
11
|
export abstract class ConfigurationLoader<TSchema extends ZodType> {
|
|
10
12
|
abstract load(): Promise<z.infer<TSchema>>;
|
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
LambdaLayerAppConfigConfigurationLoader,
|
|
4
4
|
LambdaLayerAppConfigConfigurationLoaderConfig,
|
|
5
5
|
} from '../ConfigurationLoader';
|
|
6
|
-
import { HttpRequestBuilderFactory } from '../../httpClient/HttpRequestBuilder';
|
|
7
6
|
import {
|
|
7
|
+
HttpRequestBuilderFactory,
|
|
8
8
|
HttpClient,
|
|
9
9
|
HttpMethod,
|
|
10
10
|
HttpResponse,
|
|
11
|
-
|
|
11
|
+
createHttpClientMock,
|
|
12
|
+
} from '@squiz/optimization-http-client';
|
|
12
13
|
import { faker } from '@faker-js/faker';
|
|
13
|
-
import { createHttpClientMock } from '../../testing/mock';
|
|
14
14
|
import { z } from 'zod';
|
|
15
15
|
|
|
16
16
|
describe('LambdaLayerAppConfigConfigurationLoader', () => {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from '../DynamoDBEventMapper';
|
|
7
7
|
import { faker } from '@faker-js/faker';
|
|
8
8
|
import { marshall } from '@aws-sdk/util-dynamodb';
|
|
9
|
-
import { TenantIdValue } from '
|
|
9
|
+
import { TenantIdValue } from '@squiz/optimization-value-objects';
|
|
10
10
|
import { AsDomainEvent, DomainEvent } from '../DomainEvent';
|
|
11
11
|
|
|
12
12
|
type ExampleEventDetail = {
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
export * from './valueObject/TenantId';
|
|
2
|
-
|
|
3
|
-
export * from './validation/handleValidation';
|
|
4
|
-
|
|
5
1
|
export * from './typesUtils/utilities';
|
|
6
2
|
export * from './typesUtils/DynamoDB';
|
|
7
3
|
|
|
@@ -10,18 +6,6 @@ export * from './testing/mock';
|
|
|
10
6
|
export * from './scheduler/Scheduler';
|
|
11
7
|
export * from './scheduler/EventBridgeScheduler';
|
|
12
8
|
|
|
13
|
-
export * from './logger/SquizRemoteLogger';
|
|
14
|
-
export * from './logger/RemoteLogger';
|
|
15
|
-
export * from './logger/LoggerMessage';
|
|
16
|
-
export * from './logger/Logger';
|
|
17
|
-
export * from './logger/LogsLambdaHandler';
|
|
18
|
-
|
|
19
|
-
export * from './httpClient/HttpRequestBuilder';
|
|
20
|
-
export * from './httpClient/HttpClient';
|
|
21
|
-
export * from './httpClient/FetchHttpClient';
|
|
22
|
-
|
|
23
|
-
export * from './exception/DomainException';
|
|
24
|
-
|
|
25
9
|
export * from './event/DynamoDBEventMapper';
|
|
26
10
|
export * from './event/DomainEvent';
|
|
27
11
|
export * from './event/AggregateRoot';
|
|
@@ -12,9 +12,8 @@ import { PutItemCommandInput } from '@aws-sdk/client-dynamodb';
|
|
|
12
12
|
import { eventToDynamoDB } from '../event/DynamoDBEventMapper';
|
|
13
13
|
import { randomUUID } from 'crypto';
|
|
14
14
|
import { ScheduleName, Scheduler, SchedulerOptions } from './Scheduler';
|
|
15
|
-
import { Logger } from '../logger/Logger';
|
|
16
|
-
import { createLog, LogMessage } from '../logger/LoggerMessage';
|
|
17
15
|
import { marshall } from '@aws-sdk/util-dynamodb';
|
|
16
|
+
import { createLog, Logger, LogMessage } from '@squiz/optimization-logger';
|
|
18
17
|
|
|
19
18
|
export type EventBridgeSchedulerConfig = {
|
|
20
19
|
region: string;
|
|
@@ -13,11 +13,8 @@ import { randomUUID } from 'crypto';
|
|
|
13
13
|
import { faker } from '@faker-js/faker';
|
|
14
14
|
import { ExceptionOptionType } from '@smithy/smithy-client/dist-types/exceptions';
|
|
15
15
|
import { SchedulerServiceException } from '@aws-sdk/client-scheduler/dist-types/models/SchedulerServiceException';
|
|
16
|
-
import { Logger } from '
|
|
17
|
-
import {
|
|
18
|
-
createLoggerMock,
|
|
19
|
-
createSchedulerClientMock,
|
|
20
|
-
} from '../../testing/mock';
|
|
16
|
+
import { Logger, createLoggerMock } from '@squiz/optimization-logger';
|
|
17
|
+
import { createSchedulerClientMock } from '../../testing/mock';
|
|
21
18
|
import { eventToDynamoDB } from '../../event/DynamoDBEventMapper';
|
|
22
19
|
import { Scheduler } from '../Scheduler';
|
|
23
20
|
import {
|
package/src/testing/mock.ts
CHANGED
|
@@ -1,53 +1,6 @@
|
|
|
1
|
-
import { HttpClient } from '../httpClient/HttpClient';
|
|
2
|
-
import { Logger } from '../logger/Logger';
|
|
3
|
-
import { RemoteLogger } from '../logger/RemoteLogger';
|
|
4
1
|
import { SchedulerClient } from '@aws-sdk/client-scheduler';
|
|
5
2
|
import { Scheduler } from '../scheduler/Scheduler';
|
|
6
3
|
|
|
7
|
-
export type FetchMock = jest.Mock<
|
|
8
|
-
ReturnType<typeof fetch>,
|
|
9
|
-
Parameters<typeof fetch>
|
|
10
|
-
>;
|
|
11
|
-
|
|
12
|
-
export const createResponse = <T>(
|
|
13
|
-
status: number,
|
|
14
|
-
body?: T,
|
|
15
|
-
headers?: Record<string, string>,
|
|
16
|
-
): Response =>
|
|
17
|
-
({
|
|
18
|
-
status,
|
|
19
|
-
ok: status < 400,
|
|
20
|
-
headers: new Map(Object.entries(headers ?? {})) as unknown as Headers,
|
|
21
|
-
json: async () => body,
|
|
22
|
-
text: async () => JSON.stringify(body),
|
|
23
|
-
}) as Response;
|
|
24
|
-
|
|
25
|
-
export const createHttpClientMock = (): HttpClient => {
|
|
26
|
-
return {
|
|
27
|
-
sendRequest: jest.fn(),
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const createLoggerMock = (): Logger => {
|
|
32
|
-
return {
|
|
33
|
-
debug: jest.fn(),
|
|
34
|
-
error: jest.fn(),
|
|
35
|
-
info: jest.fn(),
|
|
36
|
-
log: jest.fn(),
|
|
37
|
-
verbose: jest.fn(),
|
|
38
|
-
warn: jest.fn(),
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const createRemoteLoggerMock = (): RemoteLogger => {
|
|
43
|
-
return {
|
|
44
|
-
log: jest.fn(),
|
|
45
|
-
info: jest.fn(),
|
|
46
|
-
warn: jest.fn(),
|
|
47
|
-
error: jest.fn(),
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
4
|
export const createSchedulerClientMock = (): SchedulerClient => {
|
|
52
5
|
return {
|
|
53
6
|
send: jest.fn(),
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare abstract class DomainException extends Error {
|
|
2
|
-
protected constructor(message: string);
|
|
3
|
-
}
|
|
4
|
-
export declare class ValidationException extends DomainException {
|
|
5
|
-
readonly message: string;
|
|
6
|
-
readonly details?: unknown | undefined;
|
|
7
|
-
constructor(message?: string, details?: unknown | undefined);
|
|
8
|
-
}
|
|
9
|
-
export declare class UnprocessableEntityException extends DomainException {
|
|
10
|
-
readonly message: string;
|
|
11
|
-
readonly details?: unknown | undefined;
|
|
12
|
-
constructor(message?: string, details?: unknown | undefined);
|
|
13
|
-
}
|
|
14
|
-
export declare class NotFoundException extends DomainException {
|
|
15
|
-
readonly message: string;
|
|
16
|
-
readonly details?: unknown | undefined;
|
|
17
|
-
constructor(message?: string, details?: unknown | undefined);
|
|
18
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotFoundException = exports.UnprocessableEntityException = exports.ValidationException = exports.DomainException = void 0;
|
|
4
|
-
class DomainException extends Error {
|
|
5
|
-
constructor(message) {
|
|
6
|
-
super(message);
|
|
7
|
-
Error.captureStackTrace(this, this.constructor);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.DomainException = DomainException;
|
|
11
|
-
class ValidationException extends DomainException {
|
|
12
|
-
message;
|
|
13
|
-
details;
|
|
14
|
-
constructor(message = 'Validation failed', details) {
|
|
15
|
-
super(message);
|
|
16
|
-
this.message = message;
|
|
17
|
-
this.details = details;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.ValidationException = ValidationException;
|
|
21
|
-
class UnprocessableEntityException extends DomainException {
|
|
22
|
-
message;
|
|
23
|
-
details;
|
|
24
|
-
constructor(message = 'Unprocessable entity', details) {
|
|
25
|
-
super(message);
|
|
26
|
-
this.message = message;
|
|
27
|
-
this.details = details;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.UnprocessableEntityException = UnprocessableEntityException;
|
|
31
|
-
class NotFoundException extends DomainException {
|
|
32
|
-
message;
|
|
33
|
-
details;
|
|
34
|
-
constructor(message = 'Not found', details) {
|
|
35
|
-
super(message);
|
|
36
|
-
this.message = message;
|
|
37
|
-
this.details = details;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.NotFoundException = NotFoundException;
|
|
41
|
-
//# sourceMappingURL=DomainException.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DomainException.js","sourceRoot":"","sources":["../../src/exception/DomainException.ts"],"names":[],"mappings":";;;AAAA,MAAsB,eAAgB,SAAQ,KAAK;IACjD,YAAsB,OAAe;QACnC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;CACF;AAND,0CAMC;AAED,MAAa,mBAAoB,SAAQ,eAAe;IAE3C;IACA;IAFX,YACW,UAAU,mBAAmB,EAC7B,OAAiB;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,YAAO,GAAP,OAAO,CAAsB;QAC7B,YAAO,GAAP,OAAO,CAAU;IAG5B,CAAC;CACF;AAPD,kDAOC;AAED,MAAa,4BAA6B,SAAQ,eAAe;IAEpD;IACA;IAFX,YACW,UAAU,sBAAsB,EAChC,OAAiB;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,YAAO,GAAP,OAAO,CAAyB;QAChC,YAAO,GAAP,OAAO,CAAU;IAG5B,CAAC;CACF;AAPD,oEAOC;AAED,MAAa,iBAAkB,SAAQ,eAAe;IAEzC;IACA;IAFX,YACW,UAAU,WAAW,EACrB,OAAiB;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,YAAO,GAAP,OAAO,CAAc;QACrB,YAAO,GAAP,OAAO,CAAU;IAG5B,CAAC;CACF;AAPD,8CAOC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Logger } from '../logger/Logger';
|
|
2
|
-
import { HttpClient, HttpRequestOptions, HttpResponse } from '../httpClient/HttpClient';
|
|
3
|
-
export declare class FetchHttpClient implements HttpClient {
|
|
4
|
-
private readonly logger;
|
|
5
|
-
constructor(logger: Logger);
|
|
6
|
-
sendRequest({ headers, url, method, body, handleHttpErrorStatusCodes, }: HttpRequestOptions): Promise<HttpResponse>;
|
|
7
|
-
}
|